Bläddra i källkod

合同变更问题处理

yzc 1 år sedan
förälder
incheckning
0f92cb18be
1 ändrade filer med 27 tillägg och 25 borttagningar
  1. 27 25
      hx-sale/src/main/java/com/fjhx/sale/flow/ContractUpdateFlow.java

+ 27 - 25
hx-sale/src/main/java/com/fjhx/sale/flow/ContractUpdateFlow.java

@@ -132,7 +132,7 @@ public class ContractUpdateFlow extends FlowDelegate {
             newCp.setExpendQuantity(newCp.getQuantity());
             if (ObjectUtil.isNotEmpty(newCp.getId())) {//如果新合同产品ID不为空
                 //取出旧合同
-                ContractProduct oldContractProduct = oldContractProductMap.getOrDefault(newCp.getId(),null).get(0);
+                ContractProduct oldContractProduct = oldContractProductMap.getOrDefault(newCp.getId(), null).get(0);
 //                //取出旧合同包装方式
 //                JSONObject oldJson = JSONObject.parseObject(oldContractProduct.getEhsdJson());
 //                String oldPackMethod = oldJson.getOrDefault("packMethod",null)==null?null:oldJson.getOrDefault("packMethod",null).toString();
@@ -142,10 +142,10 @@ public class ContractUpdateFlow extends FlowDelegate {
                 /**
                  * 商品英文名、尺寸、包装方式、数量 没有变更---取原本的剩余数量
                  */
-                if(oldContractProduct.getQuantity().compareTo(newCp.getQuantity())==0){//如果数量没有变动
+                if (oldContractProduct.getQuantity().compareTo(newCp.getQuantity()) == 0) {//如果数量没有变动
                     //取出旧的剩余数量
                     newCp.setExpendQuantity(oldContractProduct.getExpendQuantity());
-                }else{//变动了
+                } else {//变动了
                     BigDecimal quantity = newCp.getQuantity().subtract(oldContractProduct.getQuantity()).subtract(oldContractProduct.getExpendQuantity());//剩余数量
                     newCp.setExpendQuantity(quantity);
                 }
@@ -289,30 +289,32 @@ public class ContractUpdateFlow extends FlowDelegate {
         contractService.updateById(oldContract);
 
 
-        List<ClaimContract> claimContractList = claimContractService.list(Wrappers.<ClaimContract>query().lambda().eq(ClaimContract::getContractId,oldContractId));
-        List<Long> claimIds = claimContractList.stream().map(ClaimContract::getClaimId).collect(Collectors.toList());
-        List<Long> claimContractIds = claimContractList.stream().map(ClaimContract::getId).collect(Collectors.toList());
-        //取出到账认领数据
-        List<Claim> claims = claimService.list(q -> q.in(Claim::getId, claimIds));
-        for(Claim c : claims){
-            //查询流水数据
-            AccountRunningWater accountRunningWater = accountRunningWaterService.getById(c.getBusinessId());
-            BigDecimal sumClaimMoney = accountRunningWater.getClaimAmount().subtract(c.getAmount());
-            //更新流水数据为认领状态---已认领金额还原
-            AccountRunningWater water = new AccountRunningWater();
-            if(accountRunningWater.getAmount().compareTo(sumClaimMoney)>0){
-                water.setIsClaim(2);//部分认领
-            }else{
-                water.setIsClaim(0);//未认领
+        List<ClaimContract> claimContractList = claimContractService.list(Wrappers.<ClaimContract>query().lambda().eq(ClaimContract::getContractId, oldContractId));
+        if (ObjectUtil.isNotEmpty(claimContractList)) {
+            List<Long> claimIds = claimContractList.stream().map(ClaimContract::getClaimId).collect(Collectors.toList());
+            List<Long> claimContractIds = claimContractList.stream().map(ClaimContract::getId).collect(Collectors.toList());
+            //取出到账认领数据
+            List<Claim> claims = claimService.list(q -> q.in(Claim::getId, claimIds));
+            for (Claim c : claims) {
+                //查询流水数据
+                AccountRunningWater accountRunningWater = accountRunningWaterService.getById(c.getBusinessId());
+                BigDecimal sumClaimMoney = accountRunningWater.getClaimAmount().subtract(c.getAmount());
+                //更新流水数据为认领状态---已认领金额还原
+                AccountRunningWater water = new AccountRunningWater();
+                if (accountRunningWater.getAmount().compareTo(sumClaimMoney) > 0) {
+                    water.setIsClaim(2);//部分认领
+                } else {
+                    water.setIsClaim(0);//未认领
+                }
+                water.setId(c.getBusinessId());
+                water.setClaimAmount(sumClaimMoney);
+                accountRunningWaterService.updateById(water);
             }
-            water.setId(c.getBusinessId());
-            water.setClaimAmount(sumClaimMoney);
-            accountRunningWaterService.updateById(water);
+            //删除到账认领数据
+            claimContractService.remove(q -> q.in(ClaimContract::getId, claimContractIds));
+            //删除到账认领数据
+            claimService.remove(q -> q.in(Claim::getId, claimIds));
         }
-        //删除到账认领数据
-        claimContractService.remove(q -> q.in(ClaimContract::getId, claimContractIds));
-        //删除到账认领数据
-        claimService.remove(q -> q.in(Claim::getId, claimIds));
 
 
         oldContract.setUpId(temOldId);