Просмотр исходного кода

修复bug:付款金额问题

别傲 5 лет назад
Родитель
Сommit
a2da9c572c

+ 6 - 5
lift-business-service/src/main/java/cn/com/ty/lift/business/contract/service/PaymentService.java

@@ -15,6 +15,7 @@ import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.collection.IterUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -132,7 +133,7 @@ public class PaymentService extends ServiceImpl<PaymentMapper, Payment> {
         if (IterUtil.isNotEmpty(insertList)) {
             for (Payment payment : insertList) {
                 PaymentHistory history = new PaymentHistory();
-                history.setPaymentId(payment.getId());
+                history.setPaymentId(IdWorker.getId());
                 history.setContractsId(payment.getContractsId());
                 history.setDescription("新增收款项");
                 history.setBeforeContent("--");
@@ -211,14 +212,14 @@ public class PaymentService extends ServiceImpl<PaymentMapper, Payment> {
         List<Long> paymentIdList = paymentList.stream().map(Payment::getId).collect(Collectors.toList());
         //查询原有付款列表
         Collection<Payment> oldPaymentList = paymentList(paymentIdList);
+        Long contractsId = paymentList.get(0).getContractsId();
         //设置合同付款的合同id
         paymentList.forEach(entry -> {
-            entry.setContractsId(request.getContractId());
+            entry.setContractsId(contractsId);
             entry.setCode("PA" + DateUtils.generateCode());
             entry.setType(request.getContractType());
         });
-        Long contractId = request.getContractId();
-        Contracts contracts = contractService.getOne(contractId);
+        Contracts contracts = contractService.getOne(contractsId);
         if (Objects.nonNull(contracts)) {
             //应收金额总计
             BigDecimal planMoneyTotal = paymentList.stream().map(Payment::getPlanMoney).reduce(ZERO, BigDecimal::add);
@@ -230,7 +231,7 @@ public class PaymentService extends ServiceImpl<PaymentMapper, Payment> {
             BigDecimal invoiceTotal = paymentList.stream().map(Payment::getAmountInvoice).reduce(ZERO, BigDecimal::add);
             contracts.setInvoiceMoneyTotal(invoiceTotal);
             boolean result = contractService.updateById(contracts);
-            if (result) {
+            if (!result) {
                 return RestResponse.fail(MessageUtils.get("msg.modify.fail"));
             }
         }