| | |
| | | @Column(columnDefinition = "datetime comment '收款日期'") |
| | | private Date paymentDate; |
| | | |
| | | @Schema(description = "收款阶段生效日期(隐性要素 - 履约时间起点,即该节点实际达成的日期)") |
| | | @Schema(description = "收款阶段生效日期(作废 以截止日期为准)") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm") |
| | | @Column(columnDefinition = "date comment '收款阶段生效日期(履约节点实际达成日期)'") |
| | | @Column(columnDefinition = "date comment '收款阶段生效日期(履约节点实际达成日期) 作废 以截止日期为准'") |
| | | private Date effectiveDate; |
| | | |
| | | @Schema(description = "收款阶段截止日期") |
| | |
| | | @Data |
| | | public class ContractIncomeAnalysisVo { |
| | | |
| | | private String compId; |
| | | |
| | | private String compName; |
| | | |
| | | private String srMonth1; |
| | |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.persistence.Column; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | public class ContractPaymentScheduleVo { |
| | |
| | | @Schema(description = "收款阶段名称(显性要素,如:合同签订预付、发货前付款、货到签收付款、调试完成付款、质保金)") |
| | | private String stageName; |
| | | |
| | | @Schema(description = "收款比例(%,如30表示30%)(显性要素)") |
| | | private BigDecimal paymentRatio; |
| | | |
| | | @Schema(description = "计划收款金额(根据合同总金额*比例自动计算)") |
| | | private BigDecimal plannedAmount; |
| | | |
| | |
| | | public R contractAmountAnalysisByExportBus(@RequestBody AnalysisCommonDTO commonDTO) { |
| | | return statisticService.contractAmountAnalysisByExportBus(commonDTO); |
| | | } |
| | | |
| | | /** |
| | | * 分销售模式合同金额统计 |
| | | * @return R |
| | | */ |
| | | @PostMapping("/contractAmountAnalysisBySaleModel") |
| | | public R contractAmountAnalysisBySaleModel(@RequestBody AnalysisCommonDTO commonDTO) { |
| | | return statisticService.contractAmountAnalysisBySaleModel(commonDTO); |
| | | } |
| | | } |
| | |
| | | @Param("tfCompId") Long tfgs,@Param("ymjCompId") Long ymj); |
| | | |
| | | List<ContractAmountAnalysisCompVo> contractAmountAnalysisByComp(@Param("queryDTO")AnalysisCommonDTO commonDTO,@Param("compId") Long compId); |
| | | |
| | | List<ContractIncomeAnalysisAreaVo> contractAmountAnalysisBySaleModel(@Param("queryDTO")AnalysisCommonDTO commonDTO |
| | | ,@Param("compIds")List<Long> compIds,@Param("smjCompId") Long smj, |
| | | @Param("sgbCompId")Long sgb, @Param("jxcCompId")Long jxc, |
| | | @Param("tfCompId") Long tfgs,@Param("ymjCompId") Long ymj); |
| | | } |
| | |
| | | R contractAmountAnalysisByExportBus(AnalysisCommonDTO commonDTO); |
| | | |
| | | R contractAmountAnalysisByComp(AnalysisCommonDTO commonDTO); |
| | | |
| | | R contractAmountAnalysisBySaleModel(AnalysisCommonDTO commonDTO); |
| | | } |
| | |
| | | |
| | | //更新当前阶段 |
| | | if (ObjUtil.isNull(schedule.getEffectiveDate()) && ObjUtil.isNull(schedule.getEffectiveEndDate())) { |
| | | schedule.setEffectiveDate(DateUtil.offsetDay(addDTO.getProcessDate(), schedule.getAgreedDays())); |
| | | schedule.setEffectiveEndDate(DateUtil.offsetDay(addDTO.getProcessDate(), schedule.getAgreedDays())); |
| | | contractPaymentScheduleMapper.updateById(schedule); |
| | | } |
| | | |
| | | //查询是否有之前阶段 |
| | | ContractPaymentSchedule beforeSchedule = contractPaymentScheduleMapper.selectOne(Wrappers.<ContractPaymentSchedule>lambdaQuery().eq(ContractPaymentSchedule::getContractId, schedule.getContractId()) |
| | | .lt(ContractPaymentSchedule::getStageOrder, schedule.getStageOrder()).orderByDesc(ContractPaymentSchedule::getCreateTime).last("limit 1")); |
| | | if (ObjUtil.isNotNull(beforeSchedule) && ObjUtil.isNull(beforeSchedule.getEffectiveEndDate())) { |
| | | beforeSchedule.setEffectiveEndDate(schedule.getEffectiveDate()); |
| | | contractPaymentScheduleMapper.updateById(beforeSchedule); |
| | | } |
| | | // //查询是否有之前阶段 |
| | | // ContractPaymentSchedule beforeSchedule = contractPaymentScheduleMapper.selectOne(Wrappers.<ContractPaymentSchedule>lambdaQuery().eq(ContractPaymentSchedule::getContractId, schedule.getContractId()) |
| | | // .lt(ContractPaymentSchedule::getStageOrder, schedule.getStageOrder()).orderByDesc(ContractPaymentSchedule::getCreateTime).last("limit 1")); |
| | | // if (ObjUtil.isNotNull(beforeSchedule) && ObjUtil.isNull(beforeSchedule.getEffectiveEndDate())) { |
| | | // beforeSchedule.setEffectiveEndDate(schedule.getEffectiveDate()); |
| | | // contractPaymentScheduleMapper.updateById(beforeSchedule); |
| | | // } |
| | | |
| | | List<ContractOutBound> contractOutBoundList = contractOutBoundMapper.selectList(Wrappers.<ContractOutBound>lambdaQuery().eq(ContractOutBound::getContractId, contract.getId()) |
| | | .isNotNull(ContractOutBound::getArrivalTime)); |
| | |
| | | //最后阶段生效时间 |
| | | ContractPaymentSchedule endSchedule = afterSchedule.get(0); |
| | | if (StrUtil.equals(endSchedule.getStageName(), "质保金")) { |
| | | endSchedule.setEffectiveDate(DateUtil.offsetDay(addDTO.getProcessDate(), endSchedule.getAgreedDays())); |
| | | endSchedule.setEffectiveEndDate(contract.getExpirationDate()); |
| | | endSchedule.setEffectiveEndDate(DateUtil.offsetDay(addDTO.getProcessDate(), endSchedule.getAgreedDays())); |
| | | contractPaymentScheduleMapper.updateById(endSchedule); |
| | | //当前阶段生效时间 |
| | | schedule.setEffectiveDate(DateUtil.offsetDay(addDTO.getProcessDate(), schedule.getAgreedDays())); |
| | | schedule.setEffectiveEndDate(endSchedule.getEffectiveDate()); |
| | | contractPaymentScheduleMapper.updateById(schedule); |
| | | // schedule.setEffectiveEndDate(DateUtil.offsetDay(addDTO.getProcessDate(), schedule.getAgreedDays())); |
| | | // contractPaymentScheduleMapper.updateById(schedule); |
| | | //最后阶段应收 |
| | | PaymentConfirm newConfim = new PaymentConfirm(); |
| | | newConfim.setBusinessType(endSchedule.getStageName() + "应收"); |
| | |
| | | contractMapper.updateById(contract); |
| | | } |
| | | if (ArrayUtil.isEmpty(afterSchedule.toArray())) { |
| | | schedule.setEffectiveEndDate(contract.getExpirationDate()); |
| | | contractPaymentScheduleMapper.updateById(schedule); |
| | | // schedule.setEffectiveEndDate(contract.getExpirationDate()); |
| | | // contractPaymentScheduleMapper.updateById(schedule); |
| | | //更新合同下个阶段 |
| | | contract.setNextScheduleName("无"); |
| | | contractMapper.updateById(contract); |
| | |
| | | //最后阶段生效时间 |
| | | ContractPaymentSchedule endSchedule = afterSchedule.get(0); |
| | | if (StrUtil.equals(endSchedule.getStageName(), "质保金")) { |
| | | endSchedule.setEffectiveDate(DateUtil.offsetDay(addDTO.getProcessDate(), endSchedule.getAgreedDays())); |
| | | endSchedule.setEffectiveEndDate(contract.getExpirationDate()); |
| | | endSchedule.setEffectiveEndDate(DateUtil.offsetDay(addDTO.getProcessDate(), endSchedule.getAgreedDays())); |
| | | contractPaymentScheduleMapper.updateById(endSchedule); |
| | | //当前阶段生效时间 |
| | | schedule.setEffectiveDate(DateUtil.offsetDay(addDTO.getProcessDate(), schedule.getAgreedDays())); |
| | | schedule.setEffectiveEndDate(endSchedule.getEffectiveDate()); |
| | | schedule.setEffectiveEndDate(DateUtil.offsetDay(addDTO.getProcessDate(), schedule.getAgreedDays())); |
| | | contractPaymentScheduleMapper.updateById(schedule); |
| | | //最后阶段应收 |
| | | PaymentConfirm newConfim = new PaymentConfirm(); |
| | |
| | | contractMapper.updateById(contract); |
| | | } |
| | | if (ArrayUtil.isEmpty(afterSchedule.toArray())) { |
| | | schedule.setEffectiveEndDate(contract.getExpirationDate()); |
| | | contractPaymentScheduleMapper.updateById(schedule); |
| | | // schedule.setEffectiveEndDate(contract.getExpirationDate()); |
| | | // contractPaymentScheduleMapper.updateById(schedule); |
| | | //更新合同下个阶段 |
| | | contract.setNextScheduleName("无"); |
| | | contractMapper.updateById(contract); |
| | |
| | | ContractPaymentSchedule::getPlannedAmount, ContractPaymentSchedule::getPlannedAmount, |
| | | ContractPaymentSchedule::getEffectiveEndDate, ContractPaymentSchedule::getPaymentDate, |
| | | ContractPaymentSchedule::getPaymentStatus, ContractPaymentSchedule::getActualAmount, |
| | | ContractPaymentSchedule::getAgreedDays) |
| | | ContractPaymentSchedule::getAgreedDays,ContractPaymentSchedule::getPaymentRatio) |
| | | .select(ContractPaymentScheduleProcess::getProcessDate) |
| | | .leftJoin(ContractPaymentScheduleProcess.class, ContractPaymentScheduleProcess::getScheduleId, ContractPaymentSchedule::getId) |
| | | .eq(ContractPaymentSchedule::getContractId, id) |
| | |
| | | int currentIndex = index.getAndIncrement(); |
| | | ContractPaymentSchedule schedule = BeanUtil.copyProperties(contractPaymentScheduleAddDTO, ContractPaymentSchedule.class); |
| | | if (contractPaymentScheduleAddDTO.getStageName().equals("合同签订")){ |
| | | schedule.setEffectiveDate(DateUtil.offsetDay(contract.getSignDate(),contractPaymentScheduleAddDTO.getAgreedDays())); |
| | | schedule.setEffectiveEndDate(DateUtil.offsetDay(contract.getSignDate(), contractPaymentScheduleAddDTO.getAgreedDays())); |
| | | } |
| | | if (ObjUtil.isNotNull(schedule.getEffectiveDate())) { |
| | | if (schedule.getEffectiveDate().before(DateUtil.date())) { |
| | |
| | | schedule.setFulfillmentStatus(0); |
| | | } |
| | | } |
| | | if (contractPaymentScheduleAddDTO.getPaymentRatio().compareTo(new BigDecimal("0")) > 0) { |
| | | schedule.setPaymentStatus(0); |
| | | }else { |
| | | schedule.setPaymentStatus(3); |
| | | } |
| | | schedule.setContractId(contract.getId()); |
| | | schedule.setContractName(contract.getContractName()); |
| | | schedule.setPlannedAmount(contract.getAmount().multiply(schedule.getPaymentRatio().divide(new BigDecimal("100")))); |
| | |
| | | }); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | return R.ok(); |
| | |
| | | schedule.setContractName(contract.getContractName()); |
| | | schedule.setPlannedAmount(contract.getAmount().multiply(schedule.getPaymentRatio().divide(new BigDecimal("100")))); |
| | | schedule.setStageOrder(currentIndex); |
| | | if (contractPaymentScheduleAddDTO.getPaymentRatio().compareTo(new BigDecimal("0")) > 0) { |
| | | schedule.setPaymentStatus(0); |
| | | }else { |
| | | schedule.setPaymentStatus(3); |
| | | } |
| | | contractPaymentScheduleMapper.insert(schedule); |
| | | if (contractPaymentScheduleAddDTO.getStageName().equals("货到签收")){ |
| | | contract.setArrivalScheduleId(schedule.getId()); |
| | |
| | | //最后阶段生效时间 |
| | | ContractPaymentSchedule endSchedule = afterSchedule.get(0); |
| | | if (StrUtil.equals(endSchedule.getStageName(),"质保金")){ |
| | | endSchedule.setEffectiveDate(DateUtil.offsetDay(new Date(),endSchedule.getAgreedDays())); |
| | | endSchedule.setEffectiveEndDate(contract.getExpirationDate()); |
| | | contractPaymentScheduleMapper.updateById(endSchedule); |
| | | //第一阶段生效时间 |
| | | fitstSchedule.setEffectiveDate(DateUtil.offsetDay(contract.getSignDate(),fitstSchedule.getAgreedDays())); |
| | | fitstSchedule.setEffectiveEndDate(endSchedule.getEffectiveDate()); |
| | | contractPaymentScheduleMapper.updateById(fitstSchedule); |
| | | |
| | | // endSchedule.setEffectiveEndDate(DateUtil.offsetDay(new Date(),endSchedule.getAgreedDays())); |
| | | // contractPaymentScheduleMapper.updateById(endSchedule); |
| | | //最后阶段应收 |
| | | PaymentConfirm newConfim = new PaymentConfirm(); |
| | | newConfim.setBusinessType(endSchedule.getStageName()+"应收"); |
| | |
| | | } |
| | | if(ArrayUtil.isNotEmpty(afterSchedule.toArray())&&afterSchedule.size()>1){ |
| | | //第一阶段生效时间 |
| | | fitstSchedule.setEffectiveDate(DateUtil.offsetDay(contract.getSignDate(),fitstSchedule.getAgreedDays())); |
| | | contractPaymentScheduleMapper.updateById(fitstSchedule); |
| | | // fitstSchedule.setEffectiveEndDate(DateUtil.offsetDay(contract.getSignDate(),fitstSchedule.getAgreedDays())); |
| | | // contractPaymentScheduleMapper.updateById(fitstSchedule); |
| | | //更新合同下个阶段 |
| | | contract.setNextScheduleName(afterSchedule.get(0).getStageName()); |
| | | baseMapper.updateById(contract); |
| | | } |
| | | //只有当前合同签字阶段 |
| | | if(ArrayUtil.isEmpty(afterSchedule.toArray())){ |
| | | fitstSchedule.setEffectiveDate(DateUtil.offsetDay(contract.getSignDate(),fitstSchedule.getAgreedDays())); |
| | | fitstSchedule.setEffectiveEndDate(contract.getExpirationDate()); |
| | | contractPaymentScheduleMapper.updateById(fitstSchedule); |
| | | } |
| | | // if(ArrayUtil.isEmpty(afterSchedule.toArray())){ |
| | | // fitstSchedule.setEffectiveEndDate(DateUtil.offsetDay(contract.getSignDate(),fitstSchedule.getAgreedDays())); |
| | | // contractPaymentScheduleMapper.updateById(fitstSchedule); |
| | | // } |
| | | } |
| | | |
| | | private void savePaymentConfirm(Contract contract, ContractPaymentSchedule schedule) { |
| | |
| | | public R genCurrentOverdue() { |
| | | List<ContractPaymentSchedule> scheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery() |
| | | .lt(ContractPaymentSchedule::getEffectiveEndDate, DateUtil.today()) |
| | | .ne(ContractPaymentSchedule::getPaymentStatus,"2")); |
| | | .ne(ContractPaymentSchedule::getPaymentStatus, "2") |
| | | .ne(ContractPaymentSchedule::getPaymentStatus,3)); |
| | | if (ArrayUtil.isNotEmpty(scheduleList.toArray())){ |
| | | scheduleList.stream().forEach(contractPaymentSchedule -> { |
| | | Contract contract = baseMapper.selectById(contractPaymentSchedule.getContractId()); |
| | |
| | | |
| | | //更新发货前收款生效时间 |
| | | if (ObjUtil.isNull(schedule.getEffectiveDate())) { |
| | | schedule.setEffectiveDate(DateUtil.offsetDay(addDTO.getOutBoundTime(), schedule.getAgreedDays())); |
| | | schedule.setEffectiveEndDate(DateUtil.offsetDay(addDTO.getOutBoundTime(), schedule.getAgreedDays())); |
| | | //查询是否有后续阶段 |
| | | List<ContractPaymentSchedule> afterSchedule = scheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery().eq(ContractPaymentSchedule::getContractId, contractId) |
| | | .gt(ContractPaymentSchedule::getStageOrder, schedule.getStageOrder())); |
| | | if (ArrayUtil.isEmpty(afterSchedule.toArray())) { |
| | | schedule.setEffectiveEndDate(contract.getExpirationDate()); |
| | | } |
| | | // List<ContractPaymentSchedule> afterSchedule = scheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery().eq(ContractPaymentSchedule::getContractId, contractId) |
| | | // .gt(ContractPaymentSchedule::getStageOrder, schedule.getStageOrder())); |
| | | // if (ArrayUtil.isEmpty(afterSchedule.toArray())) { |
| | | // schedule.setEffectiveEndDate(contract.getExpirationDate()); |
| | | // } |
| | | scheduleMapper.updateById(schedule); |
| | | //查询是否有之前阶段 |
| | | ContractPaymentSchedule beforeSchedule = scheduleMapper.selectOne(Wrappers.<ContractPaymentSchedule>lambdaQuery().eq(ContractPaymentSchedule::getContractId, schedule.getContractId()) |
| | | .lt(ContractPaymentSchedule::getStageOrder, schedule.getStageOrder()).orderByDesc(ContractPaymentSchedule::getCreateTime).last("limit 1")); |
| | | if (ObjUtil.isNotNull(beforeSchedule)) { |
| | | beforeSchedule.setEffectiveEndDate(schedule.getEffectiveDate()); |
| | | scheduleMapper.updateById(beforeSchedule); |
| | | } |
| | | // ContractPaymentSchedule beforeSchedule = scheduleMapper.selectOne(Wrappers.<ContractPaymentSchedule>lambdaQuery().eq(ContractPaymentSchedule::getContractId, schedule.getContractId()) |
| | | // .lt(ContractPaymentSchedule::getStageOrder, schedule.getStageOrder()).orderByDesc(ContractPaymentSchedule::getCreateTime).last("limit 1")); |
| | | // if (ObjUtil.isNotNull(beforeSchedule)) { |
| | | // beforeSchedule.setEffectiveEndDate(schedule.getEffectiveDate()); |
| | | // scheduleMapper.updateById(beforeSchedule); |
| | | // } |
| | | //更新履约 |
| | | ContractPaymentScheduleProcess contractPaymentScheduleProcess = new ContractPaymentScheduleProcess(); |
| | | contractPaymentScheduleProcess.setContractId(schedule.getContractId()); |
| | |
| | | contractPaymentScheduleProcess.setScheduleId(schedule.getId()); |
| | | contractPaymentScheduleProcess.setScheduleName(schedule.getStageName()); |
| | | contractPaymentScheduleProcess.setProcessDate(addDTO.getOutBoundTime()); |
| | | ContractPaymentScheduleProcess lastProcess = scheduleProcessMapper.selectOne(Wrappers.<ContractPaymentScheduleProcess>lambdaQuery().eq(ContractPaymentScheduleProcess::getContractId, schedule.getContractId()) |
| | | .eq(ContractPaymentScheduleProcess::getScheduleId, schedule.getId()).last("limit 1")); |
| | | if (ObjUtil.isNull(lastProcess)) { |
| | | scheduleProcessMapper.insert(contractPaymentScheduleProcess); |
| | | } |
| | | } |
| | | |
| | | //查询是否有后续阶段 |
| | |
| | | //最后阶段生效时间 |
| | | ContractPaymentSchedule endSchedule = afterSchedule.get(0); |
| | | if (StrUtil.equals(endSchedule.getStageName(), "质保金")) { |
| | | endSchedule.setEffectiveDate(DateUtil.offsetDay(addDTO.getOutBoundTime(), endSchedule.getAgreedDays())); |
| | | endSchedule.setEffectiveEndDate(contract.getExpirationDate()); |
| | | scheduleMapper.updateById(endSchedule); |
| | | // endSchedule.setEffectiveEndDate(DateUtil.offsetDay(addDTO.getOutBoundTime(), endSchedule.getAgreedDays())); |
| | | // scheduleMapper.updateById(endSchedule); |
| | | //当前阶段生效时间 |
| | | schedule.setEffectiveDate(DateUtil.offsetDay(addDTO.getOutBoundTime(), schedule.getAgreedDays())); |
| | | schedule.setEffectiveEndDate(endSchedule.getEffectiveDate()); |
| | | scheduleMapper.updateById(schedule); |
| | | // schedule.setEffectiveEndDate(DateUtil.offsetDay(addDTO.getOutBoundTime(), schedule.getAgreedDays())); |
| | | // scheduleMapper.updateById(schedule); |
| | | //最后阶段应收 |
| | | PaymentConfirm newConfim = new PaymentConfirm(); |
| | | newConfim.setBusinessType(endSchedule.getStageName() + "应收"); |
| | |
| | | contractMapper.updateById(contract); |
| | | } |
| | | if (ArrayUtil.isEmpty(afterSchedule.toArray())) { |
| | | schedule.setEffectiveEndDate(contract.getExpirationDate()); |
| | | scheduleMapper.updateById(schedule); |
| | | // schedule.setEffectiveEndDate(contract.getExpirationDate()); |
| | | // scheduleMapper.updateById(schedule); |
| | | //更新合同下个阶段 |
| | | contract.setNextScheduleName("无"); |
| | | contractMapper.updateById(contract); |
| | |
| | | } |
| | | //更新付款阶段付款 |
| | | List<ContractPaymentSchedule> scheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery() |
| | | .eq(ContractPaymentSchedule::getContractId, contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus, 2) |
| | | .eq(ContractPaymentSchedule::getContractId, contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus, 2).ne(ContractPaymentSchedule::getPaymentStatus, 3) |
| | | .orderByAsc(ContractPaymentSchedule::getCreateTime)); |
| | | if (ArrayUtil.isNotEmpty(scheduleList.toArray())) { |
| | | BigDecimal remain = addDTO.getTransationAmount(); |
| | |
| | | break; |
| | | } else { |
| | | entity.setTransationAmount(transtionRemainAmount.subtract(lastTotal)); |
| | | entity.setTotalAmount(transtionAmount); |
| | | entity.setReceivableAmount(transtionRemainAmount.multiply(new BigDecimal("-1"))); |
| | | entity.setTotalAmount(transtionRemainAmount); |
| | | entity.setConfirmTime(payDate); |
| | | baseMapper.insert(entity); |
| | | payContractList.add(contract); |
| | |
| | | //更新付款阶段付款 |
| | | List<ContractPaymentSchedule> scheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery() |
| | | .eq(ContractPaymentSchedule::getContractId, contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus, 2) |
| | | .ne(ContractPaymentSchedule::getPaymentStatus, 3) |
| | | .orderByAsc(ContractPaymentSchedule::getCreateTime)); |
| | | if (ArrayUtil.isNotEmpty(scheduleList.toArray())) { |
| | | BigDecimal remain = transtionAmount; |
| | |
| | | //合同所有付款阶段 |
| | | List<ContractPaymentSchedule> payComScheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery() |
| | | .eq(ContractPaymentSchedule::getContractId, contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus, 0) |
| | | ); |
| | | .ne(ContractPaymentSchedule::getPaymentStatus, 3)); |
| | | if (ArrayUtil.isNotEmpty(payComScheduleList.toArray())){ |
| | | BigDecimal payTotal = payComScheduleList.stream().map(item->StrUtil.equals(item.getPaymentStatus() + "", "0") ? item.getPlannedAmount() : |
| | | BigDecimal payTotal = payComScheduleList.stream().map(item->StrUtil.equals(item.getPaymentStatus() + "", "2") ? item.getPlannedAmount() : |
| | | item.getActualAmount()).reduce(BigDecimal.ZERO,BigDecimal::add); |
| | | contract.setPaidAmount(payTotal); |
| | | if (payComScheduleList.stream().allMatch(item -> Objects.equals(item.getPaymentStatus(), 2))) { |
| | | contract.setContractStatus(3); |
| | | } |
| | | // if (payComScheduleList.stream().allMatch(item -> Objects.equals(item.getPaymentStatus(), 2))) { |
| | | // contract.setContractStatus(3); |
| | | // } |
| | | contractService.updateById(contract); |
| | | if (contract.getAmount().compareTo(contract.getPaidAmount()) == 0) { |
| | | contract.setBillingStatus("2"); |
| | | contract.setContractStatus(3); |
| | | payCompleteContractList.add(contract); |
| | | } |
| | | //付款 且 付款未全付 |
| | |
| | | payContractList.stream().forEach(contract -> { |
| | | //更新付款阶段付款 |
| | | List<ContractPaymentSchedule> scheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery() |
| | | .eq(ContractPaymentSchedule::getContractId, contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus, 2) |
| | | .eq(ContractPaymentSchedule::getContractId, contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus, 2).ne(ContractPaymentSchedule::getPaymentStatus, 3) |
| | | .orderByAsc(ContractPaymentSchedule::getCreateTime)); |
| | | if (ArrayUtil.isNotEmpty(scheduleList.toArray())) { |
| | | BigDecimal remain = transtionAmount; |
| | |
| | | } |
| | | //合同所有付款阶段 |
| | | List<ContractPaymentSchedule> payComScheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery() |
| | | .eq(ContractPaymentSchedule::getContractId, contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus, 0) |
| | | .eq(ContractPaymentSchedule::getContractId, contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus, 0).ne(ContractPaymentSchedule::getPaymentStatus,3) |
| | | ); |
| | | if (ArrayUtil.isNotEmpty(payComScheduleList.toArray())){ |
| | | BigDecimal payTotal = payComScheduleList.stream().map(item->StrUtil.equals(item.getPaymentStatus() + "", "0") ? item.getPlannedAmount() : |
| | |
| | | //更新付款阶段付款 |
| | | 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(); |
| | | } |
| | | } |
| | |
| | | package com.by4cloud.platformx.business.service.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.by4cloud.platformx.admin.api.entity.SysDept; |
| | | import com.by4cloud.platformx.admin.api.entity.SysDictItem; |
| | | import com.by4cloud.platformx.admin.api.feign.RemoteDeptService; |
| | | import com.by4cloud.platformx.admin.api.feign.RemoteDictService; |
| | |
| | | import com.by4cloud.platformx.common.core.util.R; |
| | | import com.by4cloud.platformx.common.security.util.SecurityUtils; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | |
| | | @Service |
| | | @RequiredArgsConstructor |
| | |
| | | compIds.add(Long.valueOf(ymj)); |
| | | compIds.add(Long.valueOf(jxc)); |
| | | List<ContractIncomeAnalysisVo> contractIncomeAnalysisVoList = contractMapper.contractIncomeAnalysis(commonDTO,compIds); |
| | | if (ArrayUtil.isNotEmpty(contractIncomeAnalysisVoList.toArray())){ |
| | | contractIncomeAnalysisVoList.stream().forEach(contractIncomeAnalysisVo -> { |
| | | if(StrUtil.equals(contractIncomeAnalysisVo.getCompId(),sgb)){ |
| | | contractIncomeAnalysisVo.setCompName("石工泵"); |
| | | } |
| | | if(StrUtil.equals(contractIncomeAnalysisVo.getCompId(),smj)){ |
| | | contractIncomeAnalysisVo.setCompName("石煤机"); |
| | | } |
| | | if(StrUtil.equals(contractIncomeAnalysisVo.getCompId(),ymj)){ |
| | | contractIncomeAnalysisVo.setCompName("一煤机"); |
| | | } |
| | | if(StrUtil.equals(contractIncomeAnalysisVo.getCompId(),tfgs)){ |
| | | contractIncomeAnalysisVo.setCompName("通方公司"); |
| | | } |
| | | if(StrUtil.equals(contractIncomeAnalysisVo.getCompId(),jxc)){ |
| | | contractIncomeAnalysisVo.setCompName("机械厂"); |
| | | } |
| | | }); |
| | | } |
| | | return R.ok(contractIncomeAnalysisVoList); |
| | | } |
| | | |
| | |
| | | return R.ok(contractIncomeAnalysisVoList); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public R contractAmountAnalysisBySaleModel(AnalysisCommonDTO commonDTO) { |
| | | R<List<SysDictItem>> r = remoteDictService.getDictByType("sales_model"); |
| | | List<SysDictItem> items = r.getData(); |
| | | if (ArrayUtil.isEmpty(items.toArray())){ |
| | | return R.failed("区域字段获取异常"); |
| | | } |
| | | List<Long> compIds = new ArrayList<>(); |
| | | compIds.add(Long.valueOf(sgb)); |
| | | compIds.add(Long.valueOf(smj)); |
| | | compIds.add(Long.valueOf(tfgs)); |
| | | compIds.add(Long.valueOf(ymj)); |
| | | compIds.add(Long.valueOf(jxc)); |
| | | List<ContractIncomeAnalysisAreaVo> contractIncomeAnalysisVoList = items.stream().map(item -> { |
| | | ContractIncomeAnalysisAreaVo analysisAreaVo = new ContractIncomeAnalysisAreaVo(); |
| | | analysisAreaVo.setAreaId(item.getItemValue()); |
| | | analysisAreaVo.setAreaName(item.getLabel()); |
| | | return analysisAreaVo; |
| | | }).collect(Collectors.toList()); |
| | | contractMapper.setSession(); |
| | | List<ContractIncomeAnalysisAreaVo> statisticList = contractMapper.contractAmountAnalysisBySaleModel(commonDTO |
| | | ,compIds,Long.valueOf(smj),Long.valueOf(sgb),Long.valueOf(jxc),Long.valueOf(tfgs),Long.valueOf(ymj)); |
| | | contractIncomeAnalysisVoList.stream().forEach(vo1->{ |
| | | statisticList.stream().forEach(vo2->{ |
| | | if (StrUtil.equals(vo1.getAreaId(),vo2.getAreaId())){ |
| | | vo1.setJxczb(vo2.getJxczb()); |
| | | vo1.setJxcze(vo2.getJxcze()); |
| | | vo1.setSgbzb(vo2.getSgbzb()); |
| | | vo1.setSgbze(vo2.getSgbze()); |
| | | vo1.setSmjzb(vo2.getSmjzb()); |
| | | vo1.setSmjze(vo2.getSmjze()); |
| | | vo1.setTfzb(vo2.getTfzb()); |
| | | vo1.setTfze(vo2.getTfze()); |
| | | vo1.setYmjzb(vo2.getYmjzb()); |
| | | vo1.setYmjze(vo2.getYmjze()); |
| | | } |
| | | }); |
| | | }); |
| | | return R.ok(contractIncomeAnalysisVoList); |
| | | } |
| | | } |
| | |
| | | <select id="contractIncomeAnalysis" |
| | | resultType="com.by4cloud.platformx.business.vo.ContractIncomeAnalysisVo"> |
| | | SELECT |
| | | compName, |
| | | compId, |
| | | SUM(CASE WHEN month_num = 1 THEN total_amount ELSE 0 END) AS 'srMonth1', |
| | | SUM(CASE WHEN month_num = 1 AND pay_type = 1 THEN total_amount ELSE 0 END) AS 'xhMonth1', |
| | | SUM(CASE WHEN month_num = 1 AND pay_type = 2 THEN total_amount ELSE 0 END) AS 'cdMonth1', |
| | |
| | | SUM(CASE WHEN month_num = 4 AND pay_type = 2 THEN total_amount ELSE 0 END) AS 'cdMonth4', |
| | | SUM(CASE WHEN month_num = 4 AND pay_type = 3 THEN total_amount ELSE 0 END) AS 'qtMonth4', |
| | | SUM(CASE WHEN month_num = 5 THEN total_amount ELSE 0 END) AS 'srMonth5', |
| | | SUM(CASE WHEN month_num = 5 AND pay_type = 0 THEN total_amount ELSE 0 END) AS 'xhMonth5', |
| | | SUM(CASE WHEN month_num = 5 AND pay_type = 1 THEN total_amount ELSE 0 END) AS 'cdMonth5', |
| | | SUM(CASE WHEN month_num = 5 AND pay_type = 2 THEN total_amount ELSE 0 END) AS 'qtMonth5', |
| | | SUM(CASE WHEN month_num = 5 AND pay_type = 1 THEN total_amount ELSE 0 END) AS 'xhMonth5', |
| | | SUM(CASE WHEN month_num = 5 AND pay_type = 2 THEN total_amount ELSE 0 END) AS 'cdMonth5', |
| | | SUM(CASE WHEN month_num = 5 AND pay_type = 3 THEN total_amount ELSE 0 END) AS 'qtMonth5', |
| | | SUM(CASE WHEN month_num = 6 THEN total_amount ELSE 0 END) AS 'srMonth6', |
| | | SUM(CASE WHEN month_num = 6 AND pay_type = 1 THEN total_amount ELSE 0 END) AS 'xhMonth6', |
| | | SUM(CASE WHEN month_num = 6 AND pay_type = 2 THEN total_amount ELSE 0 END) AS 'cdMonth6', |
| | |
| | | SUM(CASE WHEN month_num = 12 AND pay_type = 3 THEN total_amount ELSE 0 END) AS 'qtMonth12' |
| | | FROM ( |
| | | SELECT |
| | | COALESCE(pc.payee_comp_id, '未知单位') AS compName, |
| | | COALESCE(pc.payee_comp_id, '未知单位') AS compId, |
| | | MONTH(payment_time) AS month_num, |
| | | pay_type, |
| | | COALESCE(payment_amount, 0) AS total_amount |
| | |
| | | #{id} |
| | | </foreach> |
| | | ) AS source_data |
| | | GROUP BY compName |
| | | GROUP BY compId |
| | | |
| | | </select> |
| | | <select id="contractIncomeAnalysisByComp" |
| | |
| | | SELECT |
| | | SUM( amount ) |
| | | FROM |
| | | contract |
| | | contract ct |
| | | WHERE |
| | | party_b_id IN |
| | | ct.del_flag = '0' |
| | | and ct.supply_attribute = c.supply_attribute |
| | | and ct.party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | | </foreach> |
| | |
| | | SELECT |
| | | SUM( amount ) |
| | | FROM |
| | | contract |
| | | contract ct |
| | | WHERE |
| | | party_b_id IN |
| | | ct.del_flag = '0' |
| | | and ct.supply_attribute = c.supply_attribute |
| | | and ct.party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | | </foreach> |
| | |
| | | SELECT |
| | | SUM( amount ) |
| | | FROM |
| | | contract |
| | | contract ct |
| | | WHERE |
| | | party_b_id IN |
| | | ct.del_flag = '0' |
| | | and ct.supply_attribute = c.supply_attribute |
| | | and ct.party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | | </foreach> |
| | |
| | | SELECT |
| | | SUM( amount ) |
| | | FROM |
| | | contract |
| | | contract ct |
| | | WHERE |
| | | party_b_id IN |
| | | ct.del_flag = '0' |
| | | and ct.supply_attribute = c.supply_attribute |
| | | and ct.party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | | </foreach> |
| | |
| | | SELECT |
| | | SUM( amount ) |
| | | FROM |
| | | contract |
| | | contract ct |
| | | WHERE |
| | | party_b_id IN |
| | | ct.del_flag = '0' |
| | | and ct.supply_attribute = c.supply_attribute |
| | | and ct.party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | | </foreach> |
| | |
| | | FROM |
| | | contract c |
| | | WHERE |
| | | c.supply_attribute IS NOT NULL |
| | | c.del_flag = '0' |
| | | and c.supply_attribute IS NOT NULL |
| | | AND YEAR ( sign_date ) = #{queryDTO.year} |
| | | GROUP BY |
| | | c.supply_attribute |
| | |
| | | ORDER BY m.month_num |
| | | |
| | | </select> |
| | | <select id="contractAmountAnalysisBySaleModel" |
| | | resultType="com.by4cloud.platformx.business.vo.ContractIncomeAnalysisAreaVo"> |
| | | SELECT |
| | | b.sales_model area_id, |
| | | SUM( CASE WHEN c.party_b_id = #{sgbCompId} THEN c.amount ELSE 0 END ) AS sgbze, |
| | | ROUND( |
| | | SUM( CASE WHEN c.party_b_id = #{sgbCompId} THEN c.amount ELSE 0 END ) / ( |
| | | SELECT |
| | | SUM( amount ) |
| | | FROM |
| | | contract c, business_customer bc |
| | | WHERE |
| | | bc.id = c.party_a_id |
| | | and c.del_flag = '0' |
| | | and bc.del_flag = '0' |
| | | and bc.sales_model = b.sales_model |
| | | and party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | | </foreach> |
| | | ) * 100, |
| | | 2 |
| | | ) AS sgbzb, |
| | | SUM( CASE WHEN c.party_b_id = #{jxcCompId} THEN c.amount ELSE 0 END ) AS jxcze, |
| | | ROUND( |
| | | SUM( CASE WHEN c.party_b_id = #{jxcCompId} THEN c.amount ELSE 0 END ) / ( |
| | | SELECT |
| | | SUM( amount ) |
| | | FROM |
| | | contract c, business_customer bc |
| | | WHERE |
| | | bc.id = c.party_a_id |
| | | and c.del_flag = '0' |
| | | and bc.del_flag = '0' |
| | | and bc.sales_model = b.sales_model |
| | | and party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | | </foreach> |
| | | ) * 100, |
| | | 2 |
| | | ) AS jxczb , |
| | | SUM( CASE WHEN c.party_b_id = #{smjCompId} THEN c.amount ELSE 0 END ) AS smjze, |
| | | ROUND( |
| | | SUM( CASE WHEN c.party_b_id = #{smjCompId} THEN c.amount ELSE 0 END ) / ( |
| | | SELECT |
| | | SUM( amount ) |
| | | FROM |
| | | contract c, business_customer bc |
| | | WHERE |
| | | bc.id = c.party_a_id |
| | | and c.del_flag = '0' |
| | | and bc.del_flag = '0' |
| | | and bc.sales_model = b.sales_model |
| | | and party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | | </foreach> |
| | | ) * 100, |
| | | 2 |
| | | ) AS smjzb , |
| | | SUM( CASE WHEN c.party_b_id = #{ymjCompId} THEN c.amount ELSE 0 END ) AS ymjze, |
| | | ROUND( |
| | | SUM( CASE WHEN c.party_b_id = #{ymjCompId} THEN c.amount ELSE 0 END ) / ( |
| | | SELECT |
| | | SUM( amount ) |
| | | FROM |
| | | contract c, business_customer bc |
| | | WHERE |
| | | bc.id = c.party_a_id |
| | | and c.del_flag = '0' |
| | | and bc.del_flag = '0' |
| | | and bc.sales_model = b.sales_model |
| | | and party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | | </foreach> |
| | | ) * 100, |
| | | 2 |
| | | ) AS ymjzb , |
| | | SUM( CASE WHEN c.party_b_id = #{tfCompId} THEN c.amount ELSE 0 END ) AS tfze, |
| | | ROUND( |
| | | SUM( CASE WHEN c.party_b_id = #{tfCompId} THEN c.amount ELSE 0 END ) / ( |
| | | SELECT |
| | | SUM( amount ) |
| | | FROM |
| | | contract c, business_customer bc |
| | | WHERE |
| | | bc.id = c.party_a_id |
| | | and c.del_flag = '0' |
| | | and bc.del_flag = '0' |
| | | and bc.sales_model = b.sales_model |
| | | and party_b_id IN |
| | | <foreach collection="compIds" item="id" open="(" close=")" separator=","> |
| | | #{id} |
| | | </foreach> |
| | | ) * 100, |
| | | 2 |
| | | ) AS tfzb |
| | | FROM |
| | | contract c |
| | | JOIN business_customer b ON c.party_a_id = b.id |
| | | WHERE |
| | | b.sales_model IS NOT NULL |
| | | AND YEAR ( sign_date ) = #{queryDTO.year} |
| | | GROUP BY |
| | | b.sales_model |
| | | |
| | | </select> |
| | | </mapper> |