Преглед изворни кода

调整代码,添加必要的日志输出

wangzhijun пре 1 недеља
родитељ
комит
0c402296d5

+ 2 - 3
nightFragrance-massage/src/main/java/com/ylx/giftCard/service/impl/GiftCardOrderServiceImpl.java

@@ -7,7 +7,6 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ylx.common.core.domain.model.WxLoginUser;
 import com.ylx.common.exception.ServiceException;
 import com.ylx.common.utils.DateUtils;
-import com.ylx.common.utils.SecurityUtils;
 import com.ylx.giftCard.domain.GiftCard;
 import com.ylx.giftCard.domain.GiftCardOrder;
 import com.ylx.giftCard.enums.GiftCardOrderStatusEnum;
@@ -36,10 +35,10 @@ public class GiftCardOrderServiceImpl extends ServiceImpl<GiftCardOrderMapper, G
 
         // 1. 参数校验
         if (ObjectUtil.isNull(card)) {
-            throw new IllegalArgumentException("购物卡信息不能为空");
+            throw new ServiceException("购物卡信息不能为空");
         }
         if (ObjectUtil.isNull(quantity) || quantity <= 0) {
-            throw new IllegalArgumentException("购买数量必须大于0");
+            throw new ServiceException("购买数量必须大于0");
         }
 
         // 2. 创建订单对象

+ 6 - 0
nightFragrance-massage/src/main/java/com/ylx/giftCard/service/impl/GiftCardServiceImpl.java

@@ -96,6 +96,12 @@ public class GiftCardServiceImpl extends ServiceImpl<GiftCardMapper, GiftCard> i
 
         // 4. 创建订单
         GiftCardOrder order = this.giftCardOrderService.buildOrder(card, quantity, merchantId, wxLoginUser);
+        if(ObjectUtil.isNull(order)){
+            log.warn("购物卡订单创建失败,购物卡ID: {},下单人ID: {}", card.getId(), wxLoginUser.getId());
+            throw new ServiceException("购物卡订单创建失败");
+        }
+
+        log.info("购物卡订单创建,购物卡ID: {}, 订单编号: {}", id, order.getOrderNo());
 
         //  5. 调用微信支付
         return createWxPayOrder(order, wxLoginUser);