From f6876cd05c95a3e8f6f6130fc3f687e3c9a35230 Mon Sep 17 00:00:00 2001 From: winter <664946893@qq.com> Date: Tue, 1 Jul 2025 17:00:51 +0800 Subject: [PATCH] fix --- .../contract/WxAgileContractController.java | 36 +++++++++++++++++-- .../service/WxAgileContractService.java | 2 ++ .../impl/WxAgileContractServiceImpl.java | 6 ++++ 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxAgileContractController.java b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxAgileContractController.java index 759c3389d..822e115df 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxAgileContractController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxAgileContractController.java @@ -255,13 +255,45 @@ public class WxAgileContractController extends WxContractBaseController { } ResultData result = wxAgileContractService.saveOrUpdate(wxRentContract, user); //如果是有效的合同编辑,则复制其他设置到影子合同 - if (result.code == Result.SUCCESS && null != oldRentContract && isValidEdit) { - wxAgileContractService.copyContractConfig(false,wxRentContract, oldRentContract, user, false); + if (result.code == Result.SUCCESS && null != oldRentContract) { + + //有效的合同编辑,则复制其他设置到影子合同 + if(isValidEdit) { + wxAgileContractService.copyContractConfig(false,wxRentContract, oldRentContract, user, false); + }else { + //如果修改了合同时间,则所有费用需要重置。 + if (isResetFees(wxRentContract,oldRentContract)) { + wxAgileContractService.deleteContractFees(wxRentContract.getId(),wxRentContract); + } + } } return result; } + private boolean isResetFees(WxRentContract newContract,WxRentContract oldContract) { + if (newContract.getType().intValue() != oldContract.getType().intValue() || newContract.getDayPriceCalcute().intValue() != oldContract.getDayPriceCalcute().intValue() + || (newContract.getDayPriceCalcute().intValue() == oldContract.getDayPriceCalcute().intValue() && newContract.getMonthAverageDays().intValue() != oldContract.getMonthAverageDays().intValue()) + || newContract.getRentalStartDate().compareTo(oldContract.getRentalStartDate()) != 0 || newContract.getRentalEndDate().compareTo(oldContract.getRentalEndDate()) != 0) { + return true; + } + Map newShopAreaMap = newContract.getRentShopArea(); + Map oldShopAreaMap = oldContract.getRentShopArea(); + if (newShopAreaMap.size() != oldShopAreaMap.size()) { + return true; + } + for (Iterator it = newShopAreaMap.keySet().iterator();it.hasNext();) { + Long shopId = it.next(); + BigDecimal nsa = newShopAreaMap.get(shopId); + BigDecimal osa = oldShopAreaMap.get(shopId); + if (null == osa || nsa.compareTo(nsa) != 0 ) { + return true; + } + + } + return false; + } + private void handleSaveData(WxRentContract wxRentContract) { if (null == wxRentContract.getDayPriceCalcute()) { throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"请选择日均单价计费规则"); diff --git a/mallinkService/src/main/java/com/iformall/service/WxAgileContractService.java b/mallinkService/src/main/java/com/iformall/service/WxAgileContractService.java index c3882dc92..798f10af5 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxAgileContractService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxAgileContractService.java @@ -90,4 +90,6 @@ public interface WxAgileContractService { List getRentContractYears(WxRentContract rentContract); void deleteContract(Long id,TenantEntity tenantEntity); + + void deleteContractFees(Long id,TenantEntity tenantEntity); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxAgileContractServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxAgileContractServiceImpl.java index d3b884be8..3269b5e12 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxAgileContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxAgileContractServiceImpl.java @@ -1459,6 +1459,12 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { csq.setContractId(id); wxContractShopMapper.deleteByCondition(csq); + deleteContractFees(id,tenantEntity); + } + + @Transactional(rollbackFor = {Exception.class}) + @Override + public void deleteContractFees(Long id, TenantEntity tenantEntity) { WxRentContractAgileDeposit cadq = new WxRentContractAgileDeposit(); cadq.updateTenantInfo(tenantEntity); cadq.setRentContractId(id);