提交 6dbd5c9e 作者: xiaowang

bug修复

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