| | |
| | | package com.by4cloud.platformx.business.service.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.ObjUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | |
| | | 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; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | ; |
| | | |
| | | /** |
| | | * 抵抹账 |
| | |
| | | |
| | | private final ContractService contractService; |
| | | private final PaymentConfirmMapper paymentConfirmMapper; |
| | | private final BusinessCustomerMapper businessCustomerMapper; |
| | | private final ContractPaymentScheduleMapper contractPaymentScheduleMapper; |
| | | private final CurrentOverdueMapper currentOverdueMapper; |
| | | private final HistoryOverdueMapper historyOverdueMapper; |
| | |
| | | @Override |
| | | public R add(PaymentOffset paymentOffset) { |
| | | baseMapper.insert(paymentOffset); |
| | | BusinessCustomer customer = businessCustomerMapper.selectById(paymentOffset.getBusGuestId()); |
| | | |
| | | Contract contract = contractService.getById(paymentOffset.getContractId()); |
| | | |
| | | //新增付款单 |
| | | PaymentSlip slip = new PaymentSlip(); |
| | | slip.setBusGuestId(paymentOffset.getBusGuestId()); |
| | | slip.setBusGuestName(paymentOffset.getBusGuestName()); |
| | | slip.setBusGuestName(customer.getCompanyName()); |
| | | slip.setPayeeCompId(contract.getPartyBId()); |
| | | slip.setPayee(contract.getPartyB()); |
| | | slip.setPaymentTime(paymentOffset.getOffsetTime()); |
| | |
| | | entity.setContractName(contract.getContractName()); |
| | | entity.setContractNo(contract.getContractNo()); |
| | | entity.setBusGuestId(paymentOffset.getBusGuestId()); |
| | | entity.setBusGuestName(paymentOffset.getBusGuestName()); |
| | | entity.setBusGuestName(customer.getCompanyName()); |
| | | entity.setBusinessType("抵抹账"); |
| | | entity.setConfirmTime(paymentOffset.getOffsetTime()); |
| | | entity.setTransationAmount(paymentOffset.getOffsetAmount()); |
| | |
| | | //更新付款阶段付款 |
| | | List<ContractPaymentSchedule> scheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery() |
| | | .eq(ContractPaymentSchedule::getContractId,contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus,2) |
| | | .orderByAsc(ContractPaymentSchedule::getCreateTime)); |
| | | if (ArrayUtil.isNotEmpty(scheduleList.toArray())){ |
| | | .ne(ContractPaymentSchedule::getPaymentStatus,3).orderByAsc(ContractPaymentSchedule::getCreateTime)); |
| | | if (CollUtil.isNotEmpty(scheduleList)){ |
| | | BigDecimal remain = paymentOffset.getOffsetAmount(); |
| | | for (ContractPaymentSchedule schedule:scheduleList) { |
| | | BigDecimal lastRemain = remain; |
| | |
| | | } |
| | | 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 (.isNotEmpty(scheduleList)){ |
| | | // if (scheduleList.stream().allMatch(item -> Objects.equals(item.getPaymentStatus(), 2))){ |
| | | // contract.setContractStatus(3); |
| | | // contractService.updateById(contract); |
| | | // }; |
| | | // } |
| | | return R.ok(); |
| | | } |
| | | } |