Commit 9b5241dd7ffa955527b598da6bf5dd372b87c9dc
Committed by
GitHub
Merge pull request #1241 from dadiyang/fix/crm-contract-total-price-validation
[BUG] CRM:合同金额边界缺口——无明细合同的填写金额被重算覆盖为 0;合同金额字段无负值校验
Showing
2 changed files
with
6 additions
and
0 deletions
yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/contract/CrmContractSaveReqVO.java
| ... | ... | @@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmCustomerParseFun |
| 6 | 6 | import cn.iocoder.yudao.module.crm.framework.operatelog.core.SysAdminUserParseFunction; |
| 7 | 7 | import com.mzt.logapi.starter.annotation.DiffLogField; |
| 8 | 8 | import io.swagger.v3.oas.annotations.media.Schema; |
| 9 | +import jakarta.validation.constraints.DecimalMin; | |
| 9 | 10 | import jakarta.validation.constraints.NotNull; |
| 10 | 11 | import lombok.AllArgsConstructor; |
| 11 | 12 | import lombok.Data; |
| ... | ... | @@ -67,6 +68,7 @@ public class CrmContractSaveReqVO { |
| 67 | 68 | |
| 68 | 69 | @Schema(description = "合同金额", example = "5617") |
| 69 | 70 | @DiffLogField(name = "合同金额") |
| 71 | + @DecimalMin(value = "0", message = "合同金额不能小于 0") | |
| 70 | 72 | private BigDecimal totalPrice; |
| 71 | 73 | |
| 72 | 74 | @Schema(description = "客户签约人编号", example = "18546") | ... | ... |
yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractServiceImpl.java
| ... | ... | @@ -217,6 +217,10 @@ public class CrmContractServiceImpl implements CrmContractService { |
| 217 | 217 | |
| 218 | 218 | private void calculateTotalPrice(CrmContractDO contract, List<CrmContractProductDO> contractProducts) { |
| 219 | 219 | contract.setTotalProductPrice(getSumValue(contractProducts, CrmContractProductDO::getTotalPrice, BigDecimal::add, BigDecimal.ZERO)); |
| 220 | + // 无产品明细的合同,合同金额以传入值为准(支持手工填写合同金额),不做重算覆盖 | |
| 221 | + if (CollUtil.isEmpty(contractProducts)) { | |
| 222 | + return; | |
| 223 | + } | |
| 220 | 224 | BigDecimal discountPrice = MoneyUtils.priceMultiplyPercent(contract.getTotalProductPrice(), contract.getDiscountPercent()); |
| 221 | 225 | contract.setTotalPrice(contract.getTotalProductPrice().subtract(discountPrice)); |
| 222 | 226 | } | ... | ... |