Showing
1 changed file
with
9 additions
and
3 deletions
| ... | ... | @@ -1051,13 +1051,19 @@ public class ContractDistributorStandardServiceImpl extends |
| 1051 | 1051 | .eq(ContractDistributorStandard::getParentId, vo.getId()); |
| 1052 | 1052 | |
| 1053 | 1053 | List<ContractDistributorStandard> childContractList = getBaseMapper().selectList(childWrapper); |
| 1054 | - BigDecimal allChildTotalQuantity = vo.getTotalQuantity().add(CollectionUtils.isEmpty(childContractList) ? new BigDecimal(0) : childContractList.get(0).getTotalQuantity()); | |
| 1054 | + //已锁规数量 | |
| 1055 | + BigDecimal totalLockedQuantity = childContractList.stream() | |
| 1056 | + .map(ContractDistributorStandard::getTotalQuantity) | |
| 1057 | + .filter(Objects::nonNull) | |
| 1058 | + .reduce(BigDecimal.ZERO, BigDecimal::add); | |
| 1059 | + | |
| 1060 | + BigDecimal allChildTotalQuantity = vo.getTotalQuantity().add(totalLockedQuantity); | |
| 1055 | 1061 | if (allChildTotalQuantity.compareTo(data.getTotalQuantity()) > 0) { |
| 1056 | 1062 | throw new DefaultClientException("锁规总数量大于合同总数量,锁规失败!"); |
| 1057 | 1063 | } |
| 1058 | 1064 | |
| 1059 | - // 判断锁规是否完成(锁规两次或锁规数量等于合同数量) | |
| 1060 | - boolean checkPriceSpecLocked = CollectionUtils.isNotEmpty(childContractList) || (allChildTotalQuantity.compareTo(data.getTotalQuantity()) == 0); | |
| 1065 | + // 判断锁规是否完成(锁规数量等于合同数量) | |
| 1066 | + boolean checkPriceSpecLocked = allChildTotalQuantity.compareTo(data.getTotalQuantity()) == 0; | |
| 1061 | 1067 | |
| 1062 | 1068 | data.setId(IdUtil.getUUID()); |
| 1063 | 1069 | data.setTotalQuantity(vo.getTotalQuantity()); | ... | ... |