| | |
| | | package com.by4cloud.platformx.business.service.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | import cn.hutool.core.util.ObjUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | |
| | | import com.by4cloud.platformx.business.mapper.*; |
| | | import com.by4cloud.platformx.business.service.ContractPaymentScheduleProcessService; |
| | | import com.by4cloud.platformx.business.vo.ContractPaymentScheduleVo; |
| | | import com.by4cloud.platformx.business.vo.ScheduleProcessVo; |
| | | import com.by4cloud.platformx.common.core.util.R; |
| | | import com.by4cloud.platformx.common.security.util.SecurityUtils; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | |
| | | if (ObjUtil.isNull(schedule)) { |
| | | return R.failed("履约阶段与合同不一致,请联系技术人员"); |
| | | } |
| | | if (schedule.getStageName().equals("货到签收") && ArrayUtil.isEmpty(addDTO.getContractOutBoundIds().toArray())) { |
| | | if (schedule.getStageName().equals("货到签收") && CollUtil.isEmpty(addDTO.getContractOutBoundIds())) { |
| | | return R.failed("请选择到货的出库信息"); |
| | | } |
| | | //合同 |
| | | Contract contract = contractMapper.selectById(schedule.getContractId()); |
| | | List<ContractSubjectMatter> subjectMatterList = subjectMatterMapper.selectList(Wrappers.<ContractSubjectMatter>lambdaQuery().eq(ContractSubjectMatter::getContractId, contract.getId())); |
| | | if (ArrayUtil.isEmpty(subjectMatterList.toArray())) { |
| | | if (CollUtil.isEmpty(subjectMatterList)) { |
| | | return R.failed("该合同标的物异常,请联系技术人员"); |
| | | } |
| | | // if (!subjectMatterList.stream().allMatch(item -> item.getDeliveryStatus() == 2)) { |
| | |
| | | List<ContractOutBound> contractOutBoundList = contractOutBoundMapper.selectList(Wrappers.<ContractOutBound>lambdaQuery().eq(ContractOutBound::getContractId, contract.getId()) |
| | | .isNotNull(ContractOutBound::getArrivalTime)); |
| | | if (schedule.getStageName().equals("货到签收")) { |
| | | if (ArrayUtil.isNotEmpty(contractOutBoundList.toArray()) |
| | | && ArrayUtil.isNotEmpty(subjectMatterList.toArray())) { |
| | | if (CollUtil.isNotEmpty(contractOutBoundList) |
| | | && CollUtil.isNotEmpty(subjectMatterList)) { |
| | | Map<String, BigDecimal> sumMap = contractOutBoundList.stream() |
| | | .collect(Collectors.groupingBy( |
| | | ContractOutBound::getSubjectMatterCode, |
| | |
| | | //客户付款完成合同 |
| | | List<Contract> customerCompleteContractList = contractMapper.selectList(Wrappers.<Contract>lambdaQuery().eq(Contract::getPartyAId, contract.getPartyAId()) |
| | | .eq(Contract::getPartyBId, SecurityUtils.getUser().getCompId()).apply(" amount = paid_amount")); |
| | | if (ArrayUtil.isNotEmpty(customerCompleteContractList)){ |
| | | if (CollUtil.isNotEmpty(customerCompleteContractList)){ |
| | | List<BigDecimal> outAmountList = new ArrayList<>(); |
| | | for (Contract completeContract:customerCompleteContractList |
| | | ) { |
| | |
| | | outAmountList.add(outConfirm.getTransationAmount()); |
| | | } |
| | | } |
| | | if (ArrayUtil.isNotEmpty(outAmountList.toArray())){ |
| | | if (CollUtil.isNotEmpty(outAmountList)){ |
| | | BigDecimal currentSum = new BigDecimal("0"); |
| | | for (BigDecimal currentAmount:outAmountList |
| | | ) { |
| | |
| | | List<ContractPaymentSchedule> afterSchedule = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery() |
| | | .eq(ContractPaymentSchedule::getContractId, schedule.getContractId()) |
| | | .gt(ContractPaymentSchedule::getStageOrder, schedule.getStageOrder())); |
| | | if (ArrayUtil.isNotEmpty(afterSchedule.toArray()) && afterSchedule.size() == 1) { |
| | | if (CollUtil.isNotEmpty(afterSchedule) && afterSchedule.size() == 1) { |
| | | //最后阶段生效时间 |
| | | ContractPaymentSchedule endSchedule = afterSchedule.get(0); |
| | | if (StrUtil.equals(endSchedule.getStageName(), "质保金")) { |
| | |
| | | contract.setNextScheduleName(endSchedule.getStageName()); |
| | | contractMapper.updateById(contract); |
| | | } |
| | | if (ArrayUtil.isNotEmpty(afterSchedule.toArray()) && afterSchedule.size() > 1) { |
| | | if (CollUtil.isNotEmpty(afterSchedule) && afterSchedule.size() > 1) { |
| | | //更新合同下个阶段 |
| | | contract.setNextScheduleName(afterSchedule.get(0).getStageName()); |
| | | contractMapper.updateById(contract); |
| | | } |
| | | if (ArrayUtil.isEmpty(afterSchedule.toArray())) { |
| | | if (CollUtil.isEmpty(afterSchedule)) { |
| | | // schedule.setEffectiveEndDate(contract.getExpirationDate()); |
| | | // contractPaymentScheduleMapper.updateById(schedule); |
| | | //更新合同下个阶段 |
| | |
| | | .eq(ContractPaymentSchedule::getContractId, schedule.getContractId()) |
| | | .gt(ContractPaymentSchedule::getStageOrder, schedule.getStageOrder()) |
| | | .gt(ContractPaymentSchedule::getPaymentRatio,"0")); |
| | | if (ArrayUtil.isNotEmpty(afterSchedule.toArray()) && afterSchedule.size() == 1) { |
| | | if (CollUtil.isNotEmpty(afterSchedule) && afterSchedule.size() == 1) { |
| | | //最后阶段生效时间 |
| | | ContractPaymentSchedule endSchedule = afterSchedule.get(0); |
| | | // if (StrUtil.equals(endSchedule.getStageName(), "质保金")) { |
| | |
| | | contract.setNextScheduleName(endSchedule.getStageName()); |
| | | contractMapper.updateById(contract); |
| | | } |
| | | if (ArrayUtil.isNotEmpty(afterSchedule.toArray()) && afterSchedule.size() > 1) { |
| | | if (CollUtil.isNotEmpty(afterSchedule) && afterSchedule.size() > 1) { |
| | | //更新合同下个阶段 |
| | | contract.setNextScheduleName(afterSchedule.get(0).getStageName()); |
| | | contractMapper.updateById(contract); |
| | | } |
| | | if (ArrayUtil.isEmpty(afterSchedule.toArray())) { |
| | | if (CollUtil.isEmpty(afterSchedule)) { |
| | | // schedule.setEffectiveEndDate(contract.getExpirationDate()); |
| | | // contractPaymentScheduleMapper.updateById(schedule); |
| | | //更新合同下个阶段 |