提交 6dbd5c9e 作者: xiaowang

bug修复

上级 6448a0fb
......@@ -4,7 +4,7 @@ import com.mmc.oms.common.result.ResultBody;
import com.mmc.oms.feign.hystrix.UserAppApiHystrix;
import com.mmc.oms.model.vo.wallet.TopUpOrderVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
/**
......@@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RequestBody;
*/
@FeignClient(url = "${userapp.url}", name = "cms-svc", fallback = UserAppApiHystrix.class)
public interface UserAppApi {
@GetMapping("pay/feignTopUpCash")
@PostMapping("pay/feignTopUpCash")
public ResultBody feignTopUpCash(@RequestBody TopUpOrderVO topUpOrderVO);
}
......@@ -20,7 +20,7 @@ public class FeignConfiguration {
}
@Bean(name = "userAppApiHystrix")
public UserAppApiHystrix userApp() {
public UserAppApiHystrix userAppApi() {
return new UserAppApiHystrix();
}
......
......@@ -25,6 +25,7 @@ import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.*;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;
......@@ -71,6 +72,7 @@ public class DemandReleaseOrderServiceImpl implements DemandReleaseOrderService
}
@Override
@Transactional(rollbackFor = Exception.class)
public ResultBody orderPayment(CommonPaymentVO commonPaymentVO, HttpServletRequest request, Integer userAccountId) {
String token = request.getHeader("token");
switch (commonPaymentVO.getOrderPort().toString()) {
......@@ -89,23 +91,29 @@ public class DemandReleaseOrderServiceImpl implements DemandReleaseOrderService
@Transactional(rollbackFor = Exception.class)
public ResultBody topUpOrder(CommonPaymentVO commonPaymentVO, String token, Integer userAccountId) {
// 生成充值订单编号 规则T加时间戳加用户id加随机数4位
String TOrderNo = "T" + TDateUtil.getDateStr(new Date(), TDateUtil.TYPE) + userAccountId + CodeUtil.getRandomNum(4);
OrderRequestParamsVO orderRequestParamsVO = new OrderRequestParamsVO();
orderRequestParamsVO.setAmount(commonPaymentVO.getAmount());
orderRequestParamsVO.setOrderNo(TOrderNo);
orderRequestParamsVO.setDescription("云享金充值");
orderRequestParamsVO.setOrderPort(5);
orderRequestParamsVO.setAttach("TOP_UP");
TopUpOrderDO topUpOrderDO = new TopUpOrderDO(orderRequestParamsVO, userAccountId);
topUpOrderDO.setTradeState("WAIT");
topUpOrderDO.setDescription("充值云享金");
// 充值订单记录至充值订单表
topUpOrderDao.insertTopUpOrder(topUpOrderDO);
ResultBody resultBody = releaseOrder(orderRequestParamsVO, token);
if (!"200".equals(resultBody.getCode())) {
throw new RuntimeException("调用微信支付方法失败!");
ResultBody resultBody = null;
try {
String TOrderNo = "T" + TDateUtil.getDateStr(new Date(), TDateUtil.TYPE) + userAccountId + CodeUtil.getRandomNum(4);
OrderRequestParamsVO orderRequestParamsVO = new OrderRequestParamsVO();
orderRequestParamsVO.setAmount(commonPaymentVO.getAmount());
orderRequestParamsVO.setOrderNo(TOrderNo);
orderRequestParamsVO.setDescription("云享金充值");
orderRequestParamsVO.setOrderPort(5);
orderRequestParamsVO.setAttach("TOP_UP");
TopUpOrderDO topUpOrderDO = new TopUpOrderDO(orderRequestParamsVO, userAccountId);
topUpOrderDO.setTradeState("WAIT");
topUpOrderDO.setDescription("充值云享金");
// 充值订单记录至充值订单表
topUpOrderDao.insertTopUpOrder(topUpOrderDO);
resultBody = releaseOrder(orderRequestParamsVO, token);
if (!"200".equals(resultBody.getCode())) {
throw new RuntimeException("调用微信支付方法失败!");
}
} catch (RuntimeException e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
} finally {
return resultBody;
}
return resultBody;
}
/**
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论