Quellcode durchsuchen

修复订单自动取消异常

赵冬冬 vor 4 Jahren
Ursprung
Commit
5f912cdeee

+ 23 - 20
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/service/impl/OrderInfoServiceImpl.java

@@ -284,28 +284,31 @@ public class OrderInfoServiceImpl implements OrderInfoService {
                 //更新订单信息
                 String orderId = goodsPayOrderForm.getFkOrderId();
                 GoodsOrderInfo goodsOrderInfo = goodsOrderInfoMapper.selectByPrimaryKey(orderId);
-                goodsOrderInfo.setOrderStatus(state);
-                goodsOrderInfo.setModifiedTime(new Date());
-                int i = goodsOrderInfoMapper.updateByPrimaryKeySelective(goodsOrderInfo);
-                if (i > 0) {
-                    //更新支付订单信息
-                    goodsPayOrderForm.setPayStatus(state);
-                    goodsPayOrderForm.setPayTime(new Date());
-                    int j = orderPayService.modifyByPrimaryKeySelective(goodsPayOrderForm);
-                    if (j == 0) {
-                        throw new RuntimeException();
+                if(!StringUtils.isEmpty(goodsOrderInfo)){
+                    goodsOrderInfo.setOrderStatus(state);
+                    goodsOrderInfo.setModifiedTime(new Date());
+                    int i = goodsOrderInfoMapper.updateByPrimaryKeySelective(goodsOrderInfo);
+                    if (i > 0) {
+                        //更新支付订单信息
+                        goodsPayOrderForm.setPayStatus(state);
+                        goodsPayOrderForm.setPayTime(new Date());
+                        int j = orderPayService.modifyByPrimaryKeySelective(goodsPayOrderForm);
+                        if (j == 0) {
+                            throw new RuntimeException();
+                        }
+                        //更新农户收入信息
+                        updateFarmerSaleInfo(orderId);
+                        //生成证书信息
+                        applicationContext.publishEvent(new CredentialInfoEvent(this, orderId));
+                        //生成购买碳汇数据
+                        applicationContext.publishEvent(new CustomerCarbonValEvent(this, orderId));
+
+                        return i;
                     }
-                    //更新农户收入信息
-                    updateFarmerSaleInfo(orderId);
-                    //生成证书信息
-                    applicationContext.publishEvent(new CredentialInfoEvent(this, orderId));
-                    //生成购买碳汇数据
-                    applicationContext.publishEvent(new CustomerCarbonValEvent(this, orderId));
-
-                    return i;
-                } else {
-                    throw new RuntimeException();
+                }else{
+                    log.info("订单不存在无法更新!");
                 }
+
             }
         }