lazhaoqian 3 vuotta sitten
vanhempi
commit
8faa00428a

+ 13 - 13
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/impl/TWarehouseBillsServiceImpl.java

@@ -2222,18 +2222,18 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
                 TWarehousebillsfees wareHouse = new TWarehousebillsfees();
                 wareHouse.setfId(warehousebillsfee.getfId());
                 warehouseBills.setfCorpid(warehousebillsfee.getfCorpid());
-                TWhgenleg tWhgenleg = this.anPinQueryTWhgenleg(warehouseBills, warehousebillsfee);
-                if (tWhgenleg == null){
-                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-                    return AjaxResult.error("库存不足");
-                }
-                if (tWhgenleg.getfGrossweightblc().compareTo(warehousebillsfee.getfQty())< 0){
-                    TFees tFees = tFeesMapper.selectTFeesById(warehousebillsfee.getfFeeid());
-                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-                    return AjaxResult.error("库存不足,当前"+tFees.getfName()+"库存为:"+ tWhgenleg.getfGrossweightblc());
-                }
                 if (billType.equals("CK")){
                     //先给原经销商和库区减去
+                    TWhgenleg tWhgenleg = this.anPinQueryTWhgenleg(warehouseBills, warehousebillsfee);
+                    if (tWhgenleg == null){
+                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                        return AjaxResult.error("库存不足");
+                    }
+                    if (tWhgenleg.getfGrossweightblc().compareTo(warehousebillsfee.getfQty())< 0){
+                        TFees tFees = tFeesMapper.selectTFeesById(warehousebillsfee.getfFeeid());
+                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                        return AjaxResult.error("库存不足,当前"+tFees.getfName()+"库存为:"+ tWhgenleg.getfGrossweightblc());
+                    }
                     this.anPinUpdateTWhgenlegData(warehousebillsfee,tWhgenleg.getfId(),billType);
                     //在给现经销商和库区加上
                     warehousebillsfee.setfWarehouseid(warehousebillsfee.getfAllotWarehouseid());
@@ -2254,9 +2254,9 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
                     if (leg.getfGrossweightblc().compareTo(warehousebillsfee.getfQty())< 0){
                         TFees tFees = tFeesMapper.selectTFeesById(warehousebillsfee.getfFeeid());
                         TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-                        return AjaxResult.error("库存不足,当前"+tFees.getfName()+"库存为:"+ tWhgenleg.getfGrossweightblc());
+                        return AjaxResult.error("库存不足,当前"+tFees.getfName()+"库存为:"+ leg.getfGrossweightblc());
                     }
-                    this.anPinUpdateTWhgenlegData(warehousebillsfee,tWhgenleg.getfId(),billType);
+                    this.anPinUpdateTWhgenlegData(warehousebillsfee,leg.getfId(),billType);
                     //在给调入的经销商库区减去
                     warehousebillsfee.setfWarehouseid(warehousebillsfee.getfAllotWarehouseid());
                     warehouseBills.setfWarehouseid(warehouseBills.getfAllotWarehouseid());
@@ -2268,7 +2268,7 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
                     if (whgenleg.getfGrossweightblc().compareTo(warehousebillsfee.getfQty())< 0){
                         TFees tFees = tFeesMapper.selectTFeesById(warehousebillsfee.getfFeeid());
                         TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-                        return AjaxResult.error("库存不足,当前"+tFees.getfName()+"库存为:"+ tWhgenleg.getfGrossweightblc());
+                        return AjaxResult.error("库存不足,当前"+tFees.getfName()+"库存为:"+ whgenleg.getfGrossweightblc());
                     }
                     this.anPinUpdateTWhgenlegData(warehousebillsfee,whgenleg.getfId(),"CK");