|
@@ -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,18 +212,15 @@ 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);
|
|
|
- contracts.setPlanMoneyTotal(planMoneyTotal);
|
|
|
//实收金额总计
|
|
|
BigDecimal workMoneyTotal = paymentList.stream().map(Payment::getWorkMoney).reduce(ZERO, BigDecimal::add);
|
|
|
contracts.setWorkMoneyTotal(workMoneyTotal);
|
|
@@ -230,7 +228,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"));
|
|
|
}
|
|
|
}
|