|
@@ -382,6 +382,9 @@ public class MajorProductionServiceImpl extends ServiceImpl<MajorProductionMappe
|
|
|
|
|
|
for (OrderReportDTO orderReportDTO : claimOrders){
|
|
|
BigDecimal thisTimeAmount = orderReportDTO.getThisTimeAmount();
|
|
|
+ if (thisTimeAmount==null || thisTimeAmount.compareTo(BigDecimal.ZERO)==0){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
Long productionFundId = orderReportDTO.getProductionFundId();
|
|
|
if (productionFundId==null){
|
|
|
MajorProduction production = majorProductionMapper.selectOne(new LambdaQueryWrapper<MajorProduction>().eq(BaseEntity::getId,orderReportDTO.getId()).eq(BaseEntity::getDeleted, Boolean.FALSE)
|
|
@@ -425,7 +428,10 @@ public class MajorProductionServiceImpl extends ServiceImpl<MajorProductionMappe
|
|
|
public synchronized Boolean allotRealAmountToOrder(List<OrderReportDTO> claimOrders) {
|
|
|
return majorProductionService.doAllotRealAmountToOrder(claimOrders);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
+ @Transactional
|
|
|
public Boolean doAllotRealAmountToOrder(List<OrderReportDTO> claimOrders) {
|
|
|
if (CollectionUtil.isNotEmpty(claimOrders)){
|
|
|
//先校验各订单此次认领金额之和是否大于这笔实收款的剩余金额
|
|
@@ -439,6 +445,9 @@ public class MajorProductionServiceImpl extends ServiceImpl<MajorProductionMappe
|
|
|
|
|
|
for (OrderReportDTO orderReportDTO : claimOrders){
|
|
|
BigDecimal thisTimeAmount = orderReportDTO.getThisTimeAmount();
|
|
|
+ if (thisTimeAmount==null || thisTimeAmount.compareTo(BigDecimal.ZERO)==0){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
//更新订单实收款
|
|
|
Long orderFundId = orderReportDTO.getOrderFundId();
|
|
|
orderFundMapper.updateRealAmount(orderFundId, thisTimeAmount);
|
|
@@ -514,30 +523,34 @@ public class MajorProductionServiceImpl extends ServiceImpl<MajorProductionMappe
|
|
|
public synchronized Boolean allotRealAmountToProduction(OrderReportDTO orderReportDTO) {
|
|
|
List<ReportDTO> reports = orderReportDTO.getReports();
|
|
|
Long orderFundId = orderReportDTO.getOrderFundId();
|
|
|
- BigDecimal totalAmount = reports.stream().filter(x->x.getRealAmount()!=null).map(ReportDTO::getRealAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal residueAmount = orderFundMapper.residueNotAllotAmount(orderFundId);
|
|
|
+ BigDecimal totalAmount = reports.stream().filter(x->x.getThisTimeAmount()!=null).map(ReportDTO::getThisTimeAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
if (orderReportDTO.getRealAmount()==null){
|
|
|
ErrorCode.throwBusinessException(ErrorCode.CUSTOM_ERROR,"该订单还未认领实收款,请先认领实收款后再分配。");
|
|
|
}
|
|
|
- if (totalAmount.compareTo(orderReportDTO.getRealAmount())>0){
|
|
|
- ErrorCode.throwBusinessException(ErrorCode.CUSTOM_ERROR,"产品分配金额不能大于订单已认领金额,请检查后再试。");
|
|
|
+ if (totalAmount.compareTo(residueAmount)>0){
|
|
|
+ ErrorCode.throwBusinessException(ErrorCode.CUSTOM_ERROR,"产品分配金额不能大于订单未分配金额,请检查后再试。");
|
|
|
}
|
|
|
if (CollectionUtil.isNotEmpty(reports)){
|
|
|
for (ReportDTO reportDTO :reports){
|
|
|
- if (reportDTO.getProductionFundId()==null){
|
|
|
+ Long productionFundId = reportDTO.getProductionFundId();
|
|
|
+ if (reportDTO.getThisTimeAmount()==null || reportDTO.getThisTimeAmount().compareTo(BigDecimal.ZERO)==0){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (productionFundId==null){
|
|
|
MajorProduction production = majorProductionMapper.selectOne(new LambdaQueryWrapper<MajorProduction>().eq(BaseEntity::getId,reportDTO.getId()).eq(BaseEntity::getDeleted, Boolean.FALSE)
|
|
|
.select(MajorProduction::getReportNo, MajorProduction::getMajorId, MajorProduction::getProduction, MajorProduction::getEvaluateAmount));
|
|
|
ProductionFund productionFund = new ProductionFund();
|
|
|
productionFund.setProductionType(production.getProduction());
|
|
|
productionFund.setBusinessType(MainBusinessEnum.MAJOR_BUSINESS.name());
|
|
|
- productionFund.setOrderFundId(orderFundId);
|
|
|
+ productionFund.setOrderFundId(orderReportDTO.getOrderFundId());
|
|
|
productionFund.setBusinessId(production.getMajorId());
|
|
|
productionFund.setProductionNo(production.getReportNo());
|
|
|
- productionFund.setRealAmount(reportDTO.getRealAmount());
|
|
|
- productionFund.setEvaluateAmount(reportDTO.getEvaluateAmount());
|
|
|
+ productionFund.setRealAmount(reportDTO.getThisTimeAmount());
|
|
|
+ productionFund.setEvaluateAmount(production.getEvaluateAmount());
|
|
|
productionFundService.add(productionFund);
|
|
|
- }
|
|
|
- else {
|
|
|
- productionFundService.update(new LambdaUpdateWrapper<ProductionFund>().set(ProductionFund::getRealAmount,reportDTO.getRealAmount()).eq(BaseEntity::getId,reportDTO.getProductionFundId()));
|
|
|
+ }else {
|
|
|
+ productionFundMapper.updateRealAmount(productionFundId,reportDTO.getThisTimeAmount());
|
|
|
}
|
|
|
}
|
|
|
return Boolean.TRUE;
|