Forráskód Böngészése

仓库预发机修复

mac 2 éve
szülő
commit
f679c63913

+ 15 - 20
kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/service/impl/KxsMachineAdvanceServiceImpl.java

@@ -165,18 +165,17 @@ public class KxsMachineAdvanceServiceImpl extends ServiceImpl<KxsMachineAdvanceM
         //查询主订单预发机
         KxsMachineAdvance kxsMachineAdvance = baseMapper.selectById(machineAdvanceInfo.getOrderId());
 
-        if(Objects.equals(machineAdvanceInfo.getIsUseAmount(), CommonConstants.SUCCESS)){
-
-            //查询品牌
-            R<KxsBrand> kxsBrandR = remoteKxsProductService.loadByBrand(kxsMachineAdvance.getBrandId(), SecurityConstants.FROM_IN);
-            KxsBrand brand = RetOps.of(kxsBrandR)
-                    .getData()
-                    .orElseThrow(() -> new GlobalCustomerException(StoreErrorTypeEnum.DATA_ERROR.getDescription()));
+        //查询品牌
+        R<KxsBrand> kxsBrandR = remoteKxsProductService.loadByBrand(kxsMachineAdvance.getBrandId(), SecurityConstants.FROM_IN);
+        KxsBrand brand = RetOps.of(kxsBrandR)
+                .getData()
+                .orElseThrow(() -> new GlobalCustomerException(StoreErrorTypeEnum.DATA_ERROR.getDescription()));
 
-            //小分仓减少已用额度 刷新可用额度
-            Integer price = EnumUtil.getFieldBy(BrandTypeEnum::getType, BrandTypeEnum::getDescription, String.valueOf(brand.getBrandType()));
+        Integer price = EnumUtil.getFieldBy(BrandTypeEnum::getType, BrandTypeEnum::getDescription, String.valueOf(brand.getBrandType()));
+        if(Objects.equals(machineAdvanceInfo.getIsUseAmount(), CommonConstants.SUCCESS)){
+            //小分仓增加可用额度
             kxsWarehouseLimitService.refreshUserAmount(kxsMachineAdvance.getToUserId(), price, KindTypeEnum.SUB.getType());
-            //增加仓库已用额度减少仓库可用额度
+            //减少仓库可用额度
             kxsWarehouseLimitService.refreshWarehouseAmount(kxsMachineAdvance.getSendUserId(), price, KindTypeEnum.ADD.getType());
         }
         //直接删除记录
@@ -350,19 +349,15 @@ public class KxsMachineAdvanceServiceImpl extends ServiceImpl<KxsMachineAdvanceM
                 }
                 //额度充足
                 if (userLimit.getValidAmount().compareTo(BigDecimal.valueOf(amount)) >= 0) {
+                    //修改为占用预发额度标签
+                    machineAdvanceInfo.setIsUseAmount(CommonConstants.SUCCESS);
 
-                    //小分仓增加已用额度 刷新可用额度
-                    userLimit.setUsedAmount(NumberUtil.add(userLimit.getUsedAmount(), amount));
-                    userLimit.setValidAmount(NumberUtil.sub(userLimit.getValidAmount(), amount));
-                    kxsWarehouseLimitMapper.updateById(userLimit);
-
-                    //减少仓库已用额度增加仓库可用额度
+                    //小分仓减少可用额度
+                    kxsWarehouseLimitService.refreshUserAmount(userLimit.getUserId(), amount, KindTypeEnum.SUB.getType());
+                    //增加仓库可用额度
                     kxsWarehouseLimitService.refreshWarehouseAmount(warehouse.getUserId(), amount, KindTypeEnum.SUB.getType());
                 }
-                //修改为占用预发额度标签
-                if (userLimit.getValidAmount().compareTo(BigDecimal.valueOf(amount)) >= 0) {
-                    machineAdvanceInfo.setIsUseAmount(CommonConstants.SUCCESS);
-                }
+
                 machineAdvanceInfo.setIsConfirm(CommonConstants.SUCCESS);
                 kxsMachineAdvanceInfoMapper.updateById(machineAdvanceInfo);
                 //给预发对象发送通知

+ 0 - 8
kxs-store/kxs-store-biz/src/main/java/com/kxs/store/biz/service/impl/KxsWarehouseLimitServiceImpl.java

@@ -143,13 +143,9 @@ public class KxsWarehouseLimitServiceImpl extends ServiceImpl<KxsWarehouseLimitM
                 .eq(KxsWarehouseLimit::getUserId, userId));
 
         if(KindTypeEnum.ADD.getType().equals(kind)){
-            //已用额度增加
-//            userLimit.setUsedAmount(NumberUtil.add(userLimit.getUsedAmount(), amount));
             //可用额度减少
             userLimit.setValidAmount(NumberUtil.sub(userLimit.getValidAmount(), amount));
         }else{
-            //已用额度减少
-//            userLimit.setUsedAmount(NumberUtil.sub(userLimit.getUsedAmount(), amount));
             //可用额度增加
             userLimit.setValidAmount(NumberUtil.add(userLimit.getValidAmount(), amount));
         }
@@ -166,13 +162,9 @@ public class KxsWarehouseLimitServiceImpl extends ServiceImpl<KxsWarehouseLimitM
                 .eq(KxsWarehouseLimit::getUserId, userId));
 
         if(KindTypeEnum.ADD.getType().equals(kind)){
-            //已用额度增加
-//            warehouseLimit.setUsedAmount(NumberUtil.add(warehouseLimit.getUsedAmount(), amount));
             //可用额度减少
             warehouseLimit.setValidAmount(NumberUtil.sub(warehouseLimit.getValidAmount(), amount));
         }else{
-            //已用额度减少
-//            warehouseLimit.setUsedAmount(NumberUtil.sub(warehouseLimit.getUsedAmount(), amount));
             //可用额度增加
             warehouseLimit.setValidAmount(NumberUtil.add(warehouseLimit.getValidAmount(), amount));
         }