Jelajahi Sumber

收款修改合同金额总计

别傲 5 tahun lalu
induk
melakukan
fa0ec3dbee

+ 4 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/contract/dao/entity/model/response/PaymentListResponse.java

@@ -40,6 +40,10 @@ public class PaymentListResponse {
      * 实收金额
      */
     private BigDecimal workMoney;
+    /**
+     * 未收金额
+     */
+    private BigDecimal uncollectedMoney;
     /**
      * 应收时间
      */

+ 23 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/contract/service/PaymentService.java

@@ -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);
     }
 

+ 2 - 0
lift-business-service/src/main/resources/mapper/contract/PaymentMapper.xml

@@ -41,6 +41,7 @@
 			   p.project_name                  AS projectName,
 			   c.plan_money_total              AS planMoney,
 			   c.work_money_total              AS workMoney,
+		       (c.plan_money_total - c.work_money_total) as uncollectedMoney,
 		       c.end_date                      AS endDate,
 		       ui.name                         AS cashierUser
 		FROM contracts c
@@ -62,6 +63,7 @@
 			cr.project_name                 AS projectName,
 			c.plan_money_total              AS planMoney,
 			c.work_money_total              AS workMoney,
+		   (c.plan_money_total - c.work_money_total) as uncollectedMoney,
 			c.end_date                      AS endDate,
 			ui.name                         AS cashierUser
 		FROM contracts c