| | |
| | | import com.by4cloud.platformx.business.service.ContractService; |
| | | import com.by4cloud.platformx.business.service.PaymentOffsetService; |
| | | import com.by4cloud.platformx.common.core.util.R; |
| | | import com.by4cloud.platformx.common.security.util.SecurityUtils; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | private final ContractPaymentScheduleMapper contractPaymentScheduleMapper; |
| | | private final CurrentOverdueMapper currentOverdueMapper; |
| | | private final HistoryOverdueMapper historyOverdueMapper; |
| | | private final PaymentSlipMapper paymentSlipMapper; |
| | | |
| | | |
| | | @Override |
| | | public R add(PaymentOffset paymentOffset) { |
| | | baseMapper.insert(paymentOffset); |
| | | |
| | | Contract contract = contractService.getById(paymentOffset.getContractId()); |
| | | |
| | | //新增付款单 |
| | | PaymentSlip slip = new PaymentSlip(); |
| | | slip.setBusGuestId(paymentOffset.getBusGuestId()); |
| | | slip.setBusGuestName(paymentOffset.getBusGuestName()); |
| | | slip.setPayeeCompId(contract.getPartyBId()); |
| | | slip.setPayee(contract.getPartyB()); |
| | | slip.setPaymentTime(paymentOffset.getOffsetTime()); |
| | | slip.setPaymentAmount(paymentOffset.getOffsetAmount()); |
| | | slip.setPayType("3"); |
| | | paymentSlipMapper.insert(slip); |
| | | |
| | | |
| | | |
| | | PaymentConfirm lastConfirm = paymentConfirmMapper.selectOne(Wrappers.<PaymentConfirm>lambdaQuery().eq(PaymentConfirm::getContractId,contract.getId()) |
| | | .orderByDesc(PaymentConfirm::getCreateTime).last("limit 1")); |
| | |
| | | //更新付款阶段付款 |
| | | List<ContractPaymentSchedule> scheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery() |
| | | .eq(ContractPaymentSchedule::getContractId,contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus,2) |
| | | .orderByAsc(ContractPaymentSchedule::getCreateTime)); |
| | | .ne(ContractPaymentSchedule::getPaymentStatus,3).orderByAsc(ContractPaymentSchedule::getCreateTime)); |
| | | if (ArrayUtil.isNotEmpty(scheduleList.toArray())){ |
| | | BigDecimal remain = paymentOffset.getOffsetAmount(); |
| | | for (ContractPaymentSchedule schedule:scheduleList) { |
| | |
| | | } |
| | | paid = paid.add(paymentOffset.getOffsetAmount()); |
| | | contract.setPaidAmount(paid); |
| | | if (paid.compareTo(contract.getAmount())>0){ |
| | | contract.setPaidAmount(contract.getAmount()); |
| | | if (paid.compareTo(contract.getAmount())==0){ |
| | | contract.setBillingStatus("2"); |
| | | contract.setContractStatus(3); |
| | | } |
| | | contractService.updateById(contract); |
| | | // 查询所有付款阶段是否都付款完成 |
| | | if (ArrayUtil.isNotEmpty(scheduleList.toArray())){ |
| | | if (scheduleList.stream().allMatch(item -> Objects.equals(item.getPaymentStatus(), 2))){ |
| | | contract.setContractStatus(3); |
| | | contractService.updateById(contract); |
| | | }; |
| | | } |
| | | // if (ArrayUtil.isNotEmpty(scheduleList.toArray())){ |
| | | // if (scheduleList.stream().allMatch(item -> Objects.equals(item.getPaymentStatus(), 2))){ |
| | | // contract.setContractStatus(3); |
| | | // contractService.updateById(contract); |
| | | // }; |
| | | // } |
| | | return R.ok(); |
| | | } |
| | | } |