Browse Source

订单发货抽奖

yuhongqi 15 hours ago
parent
commit
23fbdc47e2

+ 29 - 3
fs-service-system/src/main/java/com/fs/live/service/impl/LiveOrderServiceImpl.java

@@ -2258,9 +2258,35 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
             if(liveOrder==null || !liveOrder.getStatus().equals(1)){
                 throw new CustomException("当前订单未找到或者订单状态不为待支付! orderId:" + orderId);
             }
-            String payCode = liveOrder.getOrderCode();
-
-            LiveOrderPayment storePayment = liveOrderPaymentMapper.selectLiveOrderPaymentByPaymentCode(payCode);
+            FsUser user = userMapper.selectFsUserByUserId(Long.valueOf(liveOrder.getUserId()));
+            if(user == null) return R.error("用户不存在");
+            String json = configService.selectConfigByKey("store.pay");
+            FsPayConfig fsPayConfig = JSON.parseObject(json, FsPayConfig.class);
+            String payCode =  SnowflakeUtils.nextId();
+            if(StringUtils.isEmpty(payCode)){
+                return R.error("订单生成失败,请重试");
+            }
+            LiveOrderPayment storePayment = liveOrderPaymentMapper.selectByBuissnessId(liveOrder.getOrderId());
+            if (storePayment != null) {
+                storePayment.setStatus(1);
+                liveOrderPaymentMapper.updateLiveOrderPayment(storePayment);
+            } else {
+                storePayment = new LiveOrderPayment();
+                storePayment.setStatus(1);
+                storePayment.setPayMode(fsPayConfig.getType());
+                storePayment.setBusinessCode(liveOrder.getOrderCode());
+                storePayment.setPayCode(payCode);
+                storePayment.setPayMoney(liveOrder.getPayMoney());
+//                storePayment.setPayMoney(new BigDecimal("0.01"));
+                storePayment.setCreateTime(new Date());
+                storePayment.setPayTypeCode("weixin");
+                storePayment.setBusinessType(5);
+                storePayment.setRemark("直播商品订单支付");
+                storePayment.setOpenId(user.getMaOpenId());
+                storePayment.setUserId(user.getUserId());
+                storePayment.setBusinessId(liveOrder.getOrderId().toString());
+                liveOrderPaymentMapper.insertLiveOrderPayment(storePayment);
+            }
             if (storePayment!=null){
                 if(storePayment.getStatus().equals(0)){
                     LiveOrderPayment paymentMap=new LiveOrderPayment();