Browse Source

库存不足提示

刘俊驰 1 year ago
parent
commit
2e4e2fcf88

+ 1 - 1
mec-common/common-core/src/main/java/com/ym/mec/common/dto/OrderCreate.java

@@ -27,7 +27,7 @@ public class OrderCreate {
 //    @ApiModelProperty("订单总金额")
     private BigDecimal totalAmount;
 
-//    @ApiModelProperty("支付类型  1->支付宝;2->微信")
+//    @ApiModelProperty("支付类型  1->支付宝;2->微信  3余额")
     private Integer payType;
 
 //    @ApiModelProperty(value = "收货人姓名")

+ 1 - 1
mec-mall/mall-admin/src/main/java/com/yonge/cooleshow/admin/dto/OrderCreate.java

@@ -28,7 +28,7 @@ public class OrderCreate {
     @ApiModelProperty("订单总金额")
     private BigDecimal totalAmount;
 
-    @ApiModelProperty("支付类型  1->支付宝;2->微信")
+    @ApiModelProperty("支付类型  1->支付宝;2->微信 3余额")
     private Integer payType;
 
     @ApiModelProperty(value = "收货人姓名")

+ 8 - 4
mec-mall/mall-admin/src/main/java/com/yonge/cooleshow/admin/service/impl/OmsOrderServiceImpl.java

@@ -175,6 +175,9 @@ public class OmsOrderServiceImpl implements OmsOrderService {
         if (CollectionUtils.isEmpty(omsOrderItems)) {
             throw new BizException("订单详情不存在");
         }
+        // skuID 商品名称 map
+        Map<Long,String > skuMap = omsOrderItems.stream().collect(Collectors.toMap(OmsOrderItem::getProductSkuId, OmsOrderItem::getProductName,(o1, o2)->o1));
+
         // skuID集合
         List<Long> skuIds = omsOrderItems.stream().map(OmsOrderItem::getProductSkuId).distinct().collect(Collectors.toList());
         // 查询库存
@@ -182,7 +185,8 @@ public class OmsOrderServiceImpl implements OmsOrderService {
         stockRecordExample.createCriteria().andProductSkuIdIn(skuIds);
         List<PmsProductSkuStockRecord> productSkuStockRecords = pmsProductSkuStockRecordMapper.selectByExample(stockRecordExample);
         if (CollectionUtils.isEmpty(productSkuStockRecords)) {
-            throw new BizException("库存不足");
+            ArrayList<String> list = new ArrayList<>(skuMap.values());
+            throw new BizException(list.get(0) +"库存不足");
         }
         //id 集合
         List<Long> stockRecordIds = productSkuStockRecords.stream().map(PmsProductSkuStockRecord::getId).collect(Collectors.toList());
@@ -205,7 +209,7 @@ public class OmsOrderServiceImpl implements OmsOrderService {
             v.stream().forEach(o -> {
                 List<PmsProductSkuStockRecord> skuStockRecords = skuStockRecordMap.get(o.getProductSkuId());
                 if (CollectionUtils.isEmpty(skuStockRecords)) {
-                    throw new BizException("库存不足");
+                    throw new BizException(skuMap.get(o.getProductSkuId()) +"库存不足");
                 }
                 int count1 = o.getProductQuantity();
                 // 扣减内部库存
@@ -270,7 +274,7 @@ public class OmsOrderServiceImpl implements OmsOrderService {
                     }
                 }
                 if (count1 > 0) {
-                    throw new BizException("库存不足");
+                    throw new BizException(skuMap.get(o.getProductSkuId())+"库存不足");
                 }
             });
             skuSyncList.add(skuSync);
@@ -286,7 +290,7 @@ public class OmsOrderServiceImpl implements OmsOrderService {
         try {
             HttpResponseResult httpResponseResult = webFeignService.updateShippedStatus(skuSyncList);
             if (httpResponseResult.getCode() != 200 && !httpResponseResult.getStatus()) {
-                throw new BizException("发货通知失败");
+                throw new BizException("发货通知失败:"+httpResponseResult.getMsg());
             }
         } catch (Exception e) {
             throw new BizException("发货通知失败");