Commit 737cb2cc by HlQ

[fix] 更新合同时,合同更新成功,再重新计算合同相关金额

1 parent fd276d2b
......@@ -19,4 +19,7 @@
</excludes>
</resource>
</resources>
```
\ No newline at end of file
```
## 更新合同金额
需要在 ``Contract.class`` 把 金额上面的四个注解 ``@ReverseAutoMapping(targetClass = ContractDTO.class, ignore = true)``
注释掉,然后调用更新接口。
\ No newline at end of file
package vion.service.impl;
import org.dromara.hutool.core.math.NumberUtil;
import org.dromara.hutool.core.util.ObjUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.yulichang.base.MPJBaseServiceImpl;
import lombok.RequiredArgsConstructor;
import org.dromara.hutool.core.math.NumberUtil;
import org.dromara.hutool.core.util.ObjUtil;
import org.springframework.stereotype.Service;
import vion.mapper.ContractPaymentMapper;
import vion.mapper.SettlementDiffMapper;
......@@ -31,8 +31,8 @@ public class ContractPaymentServiceImpl extends MPJBaseServiceImpl<ContractPayme
/**
* 当合同状态变化或者应收款变化时,重新计算款项
*
* @param existContract
* @param dto
* @param existContract 数据库中当前合同记录
* @param dto 要变更的合同记录
*/
@Override
public void calMoney(Contract existContract, Contract dto) {
......@@ -45,7 +45,7 @@ public class ContractPaymentServiceImpl extends MPJBaseServiceImpl<ContractPayme
Map<Integer, BigDecimal> type2RatioMap = contractPaymentList.stream().collect(Collectors.toMap(ContractPayment::getPaymentType, ContractPayment::getPaymentRatio));
Integer status = dto.getStatus() == null ? existContract.getStatus() : dto.getStatus();
BigDecimal sumRatio = new BigDecimal(0);
BigDecimal sumRatio = BigDecimal.ZERO;
for (int i = 1; i <= status; i++) {
BigDecimal ratio = type2RatioMap.get(i);
sumRatio = NumberUtil.add(ratio, sumRatio);
......
......@@ -299,8 +299,8 @@ public class ContractServiceImpl extends MPJBaseServiceImpl<ContractMapper, Cont
Long contractId = existContract.getId();
String existContractNo = existContract.getContractNo();
contract.setId(contractId);
contractPaymentService.calMoney(existContract, contract);
if (this.updateById(contract)) {
contractPaymentService.calMoney(existContract, contract);
Opt.ofNullable(dto.getNodeDate())
.ifPresent(date -> contractPaymentService.lambdaUpdate()
.set(ContractPayment::getNodeDate, date)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!