Bladeren bron

起卸优化

fanzherong_v 1 dag geleden
bovenliggende
commit
502e7c477d

+ 21 - 0
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/bizloadappoint/service/impl/BizLoadAppointServiceImpl.java

@@ -214,6 +214,27 @@ public class BizLoadAppointServiceImpl extends ServiceImpl<BizLoadAppointMapper,
     public void edit(BizLoadAppointEditParam bizLoadAppointEditParam) {
         BizLoadAppoint bizLoadAppoint = this.queryEntity(bizLoadAppointEditParam.getId());
         checkParam(bizLoadAppointEditParam,bizLoadAppoint);
+        //判断是否修改了支付方式
+        if(!StringUtils.equals(bizLoadAppoint.getPayType(),bizLoadAppointEditParam.getPayType())){
+            BizServiceCustomerAccount customerAccount = bizServiceCustomerAccountService.getOne(new QueryWrapper<BizServiceCustomerAccount>().lambda().
+                    eq(BizServiceCustomerAccount::getServiceCustomerId, bizLoadAppointEditParam.getCustomerId()).
+                    last("limit 1"));
+            //修改了支付方式,判断当前传参的支付方式值
+            if(StringUtils.equals(bizLoadAppointEditParam.getPayType(),"1")){
+                //当前为预付,说明之前新增时选的授信,添加锁定金额
+                //订单起卸费(起卸单价*订单数量)
+                BigDecimal orderPrice = bizLoadAppointEditParam.getLoadPrice().multiply(bizLoadAppointEditParam.getOrderWeight());
+                customerAccount.setLockAmount(customerAccount.getLockAmount().add(orderPrice));
+                bizServiceCustomerAccountService.updateById(customerAccount);
+            }
+            if(StringUtils.equals(bizLoadAppointEditParam.getPayType(),"2")){
+                //当前为授信,说明之前新增时选的预付,释放锁定金额
+                //订单起卸费(起卸单价*订单数量)
+                BigDecimal orderPrice = bizLoadAppointEditParam.getLoadPrice().multiply(bizLoadAppointEditParam.getOrderWeight());
+                customerAccount.setLockAmount(customerAccount.getLockAmount().subtract(orderPrice));
+                bizServiceCustomerAccountService.updateById(customerAccount);
+            }
+        }
         BeanUtil.copyProperties(bizLoadAppointEditParam, bizLoadAppoint);
         //吨转kg
         bizLoadAppoint.setOrderWeight(bizLoadAppointEditParam.getOrderWeight().multiply(new BigDecimal(1000)));