|
@@ -21,10 +21,13 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import static java.math.BigDecimal.ZERO;
|
|
|
+
|
|
|
/**
|
|
|
* @author bieao
|
|
|
* @date 2019/12/11
|
|
@@ -36,6 +39,9 @@ public class PaymentService extends ServiceImpl<PaymentMapper, Payment> {
|
|
|
@Resource
|
|
|
private PaymentHistoryService paymentHistoryService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private ContractService contractService;
|
|
|
+
|
|
|
/**
|
|
|
* @param request 付款列表查询条件
|
|
|
* @return RestResponse 付款分页列表结果
|
|
@@ -211,6 +217,23 @@ public class PaymentService extends ServiceImpl<PaymentMapper, Payment> {
|
|
|
entry.setCode("PA" + DateUtils.generateCode());
|
|
|
entry.setType(request.getContractType());
|
|
|
});
|
|
|
+ Long contractId = request.getContractId();
|
|
|
+ Contracts contracts = contractService.getOne(contractId);
|
|
|
+ if (Objects.nonNull(contracts)) {
|
|
|
+ //应收金额总计
|
|
|
+ BigDecimal planMoneyTotal = paymentList.stream().map(Payment::getPlanMoney).reduce(ZERO, BigDecimal::add);
|
|
|
+ contracts.setPlanMoneyTotal(planMoneyTotal);
|
|
|
+ //实收金额总计
|
|
|
+ BigDecimal workMoneyTotal = paymentList.stream().map(Payment::getWorkMoney).reduce(ZERO, BigDecimal::add);
|
|
|
+ contracts.setWorkMoneyTotal(workMoneyTotal);
|
|
|
+ //开票金额总计
|
|
|
+ BigDecimal invoiceTotal = paymentList.stream().map(Payment::getAmountInvoice).reduce(ZERO, BigDecimal::add);
|
|
|
+ contracts.setInvoiceMoneyTotal(invoiceTotal);
|
|
|
+ boolean result = contractService.updateById(contracts);
|
|
|
+ if (result) {
|
|
|
+ return RestResponse.fail(MessageUtils.get("msg.modify.fail"));
|
|
|
+ }
|
|
|
+ }
|
|
|
return modifyPayment(oldPaymentList, paymentList);
|
|
|
}
|
|
|
|