| | |
| | | package com.by4cloud.platformx.business.service.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.date.DatePattern; |
| | | import cn.hutool.core.date.DateUtil; |
| | |
| | | import java.util.concurrent.atomic.AtomicReference; |
| | | import java.util.stream.Collectors; |
| | | |
| | | ; |
| | | |
| | | /** |
| | | * @author cd |
| | | * @description |
| | |
| | | private final PaymentSlipMapper paymentSlipMapper; |
| | | private final ContractInvoiceMapper contractInvoiceMapper; |
| | | private final StringRedisTemplate redisTemplate; |
| | | private final ContractOutBoundMapper contractOutBoundMapper; |
| | | |
| | | @Value("${erp.ymj}") |
| | | private String ymjErp; |
| | |
| | | } |
| | | } |
| | | |
| | | if (ArrayUtil.isEmpty(addDTO.getContractSubjectMatter().toArray())){ |
| | | if (CollUtil.isEmpty(addDTO.getContractSubjectMatter())){ |
| | | return R.failed("标的物不能为空"); |
| | | } |
| | | |
| | |
| | | } |
| | | baseMapper.insert(contract); |
| | | |
| | | if (ArrayUtil.isNotEmpty(addDTO.getContractSubjectMatter())) { |
| | | if (CollUtil.isNotEmpty(addDTO.getContractSubjectMatter())) { |
| | | addDTO.getContractSubjectMatter().stream().forEach(contractSubjectMatterAddDTO -> { |
| | | ContractSubjectMatter subjectMatter = BeanUtil.copyProperties(contractSubjectMatterAddDTO, ContractSubjectMatter.class); |
| | | subjectMatter.setContractId(contract.getId()); |
| | |
| | | |
| | | } |
| | | |
| | | if (ArrayUtil.isNotEmpty(addDTO.getContractPaymentSchedule())) { |
| | | if (CollUtil.isNotEmpty(addDTO.getContractPaymentSchedule())) { |
| | | AtomicInteger index = new AtomicInteger(1); |
| | | addDTO.getContractPaymentSchedule().stream().forEach(contractPaymentScheduleAddDTO -> { |
| | | int currentIndex = index.getAndIncrement(); |
| | |
| | | } |
| | | baseMapper.updateById(contract); |
| | | |
| | | if (ArrayUtil.isNotEmpty(updateDTO.getContractSubjectMatter())) { |
| | | if (CollUtil.isNotEmpty(updateDTO.getContractSubjectMatter())) { |
| | | contractSubjectMatterMapper.delete(Wrappers.<ContractSubjectMatter>lambdaQuery().eq(ContractSubjectMatter::getContractId, contract.getId())); |
| | | |
| | | updateDTO.getContractSubjectMatter().stream().forEach(contractSubjectMatterAddDTO -> { |
| | |
| | | }); |
| | | } |
| | | |
| | | if (ArrayUtil.isNotEmpty(updateDTO.getContractPaymentSchedule())) { |
| | | if (CollUtil.isNotEmpty(updateDTO.getContractPaymentSchedule())) { |
| | | contractPaymentScheduleMapper.delete(Wrappers.<ContractPaymentSchedule>lambdaQuery().eq(ContractPaymentSchedule::getContractId, contract.getId())); |
| | | |
| | | AtomicInteger index = new AtomicInteger(1); |
| | |
| | | if (ObjUtil.isNotNull(a)){ |
| | | detailVo.setPartyAOrgCode(a.getCreditCode()); |
| | | } |
| | | List<ContractOutBound> outBoundList = contractOutBoundMapper.selectList(Wrappers.<ContractOutBound>lambdaQuery() |
| | | .eq(ContractOutBound::getContractId,id).orderByAsc(ContractOutBound::getOutBoundTime)); |
| | | if (CollUtil.isNotEmpty(outBoundList)){ |
| | | detailVo.setContractOutBound(outBoundList); |
| | | } |
| | | List<ContractInvoice> invoiceList = contractInvoiceMapper.selectList(Wrappers.<ContractInvoice>lambdaQuery() |
| | | .eq(ContractInvoice::getContractId,id).orderByAsc(ContractInvoice::getCreateTime)); |
| | | if (CollUtil.isNotEmpty(invoiceList)){ |
| | | detailVo.setContractInvoice(invoiceList); |
| | | } |
| | | List<PaymentSlip> slipList = paymentSlipMapper.selectList(Wrappers.<PaymentSlip>lambdaQuery() |
| | | .eq(PaymentSlip::getContractId,id).orderByAsc(PaymentSlip::getPaymentTime)); |
| | | if (CollUtil.isNotEmpty(slipList)){ |
| | | detailVo.setPaymentSlip(slipList); |
| | | } |
| | | return detailVo; |
| | | } |
| | | |
| | |
| | | List<ContractSubjectMatter> subjectMatterList = contractSubjectMatterMapper.selectList(Wrappers.<ContractSubjectMatter>lambdaQuery() |
| | | .eq(ContractSubjectMatter::getContractId,id)); |
| | | if (StrUtil.isNotEmpty(contract.getContractCategory()) && StrUtil.equals(contract.getContractCategory(), "water_house")) { |
| | | if (ArrayUtil.isNotEmpty(subjectMatterList.toArray())) { |
| | | if (CollUtil.isNotEmpty(subjectMatterList)) { |
| | | for (ContractSubjectMatter contractSubjectMatter: subjectMatterList) { |
| | | if (StrUtil.equals(contract.getExecFrequency(), "1")) { |
| | | Long weeksTrue = DateUtil.betweenWeek(DateUtil.beginOfWeek(contract.getEffectiveDate()), |
| | |
| | | .eq(ContractPaymentSchedule::getContractId, fitstSchedule.getContractId()) |
| | | .gt(ContractPaymentSchedule::getStageOrder, fitstSchedule.getStageOrder()) |
| | | .orderByAsc(ContractPaymentSchedule::getCreateTime)); |
| | | if (ArrayUtil.isNotEmpty(afterSchedule.toArray()) && afterSchedule.size() == 1) { |
| | | if (ArrayUtil.isNotEmpty(afterSchedule) && afterSchedule.size() == 1) { |
| | | //最后阶段生效时间 |
| | | ContractPaymentSchedule endSchedule = afterSchedule.get(0); |
| | | if (StrUtil.equals(endSchedule.getStageName(), "质保金")) { |
| | |
| | | contract.setNextScheduleName(endSchedule.getStageName()); |
| | | baseMapper.updateById(contract); |
| | | } |
| | | if (ArrayUtil.isNotEmpty(afterSchedule.toArray()) && afterSchedule.size() > 1) { |
| | | if (ArrayUtil.isNotEmpty(afterSchedule) && afterSchedule.size() > 1) { |
| | | //第一阶段生效时间 |
| | | // fitstSchedule.setEffectiveEndDate(DateUtil.offsetDay(contract.getSignDate(),fitstSchedule.getAgreedDays())); |
| | | // contractPaymentScheduleMapper.updateById(fitstSchedule); |
| | |
| | | baseMapper.updateById(contract); |
| | | } |
| | | //只有当前合同签字阶段 |
| | | // if(ArrayUtil.isEmpty(afterSchedule.toArray())){ |
| | | // if(ArrayUtil.isEmpty(afterSchedule)){ |
| | | // fitstSchedule.setEffectiveEndDate(DateUtil.offsetDay(contract.getSignDate(),fitstSchedule.getAgreedDays())); |
| | | // contractPaymentScheduleMapper.updateById(fitstSchedule); |
| | | // } |
| | |
| | | request.put("moneySum",contract.getAmount()); |
| | | request.put("signManner","面签"); |
| | | request.put("salesman",""); |
| | | if (ArrayUtil.isNotEmpty(subjectMatterList.toArray())){ |
| | | if (ArrayUtil.isNotEmpty(subjectMatterList)){ |
| | | JSONArray subjectMatter = new JSONArray(); |
| | | subjectMatterList.stream().forEach(contractSubjectMatter -> { |
| | | JSONObject subjectMatterItem = new JSONObject(); |
| | |
| | | outAmountList.add(outConfirm.getTransationAmount()); |
| | | } |
| | | } |
| | | if (ArrayUtil.isNotEmpty(outAmountList.toArray())) { |
| | | if (ArrayUtil.isNotEmpty(outAmountList)) { |
| | | BigDecimal currentInSum = outAmountList.stream().reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | //新增当前合同 资金转入 |
| | | PaymentConfirm inConfirm = BeanUtil.copyProperties(paymentConfirm, PaymentConfirm.class, "id", "transationAmount", |
| | |
| | | .lt(ContractPaymentSchedule::getEffectiveEndDate, DateUtil.today()) |
| | | .ne(ContractPaymentSchedule::getPaymentStatus, "2") |
| | | .ne(ContractPaymentSchedule::getPaymentStatus, 3)); |
| | | if (ArrayUtil.isNotEmpty(scheduleList.toArray())) { |
| | | if (ArrayUtil.isNotEmpty(scheduleList)) { |
| | | scheduleList.stream().forEach(contractPaymentSchedule -> { |
| | | Contract contract = baseMapper.selectById(contractPaymentSchedule.getContractId()); |
| | | if (ObjUtil.isNotNull(contract)) { |
| | |
| | | public R genCycleReceiced() { |
| | | List<ContractExecDate> execDateList = contractExecDateMapper.selectList(Wrappers.<ContractExecDate>lambdaQuery() |
| | | .le(ContractExecDate::getExecDate, DateUtil.today()).eq(ContractExecDate::getGenFlag,"0")); |
| | | if (ArrayUtil.isNotEmpty(execDateList.toArray())) { |
| | | if (ArrayUtil.isNotEmpty(execDateList)) { |
| | | execDateList.stream().forEach(contractExecDate -> { |
| | | Contract contract = baseMapper.selectById(contractExecDate.getContractId()); |
| | | ContractSubjectMatter subjectMatter = contractSubjectMatterMapper.selectOne(Wrappers.<ContractSubjectMatter>lambdaQuery() |
| | |
| | | |
| | | @Override |
| | | public R addContractSgb(ContractAddDTO addDTO) { |
| | | if (ArrayUtil.isEmpty(addDTO.getContractSubjectMatter().toArray())){ |
| | | if (ArrayUtil.isEmpty(addDTO.getContractSubjectMatter())){ |
| | | return R.failed("请添加标的物"); |
| | | } |
| | | if (ArrayUtil.isEmpty(addDTO.getContractPaymentSchedule().toArray())){ |
| | | if (ArrayUtil.isEmpty(addDTO.getContractPaymentSchedule())){ |
| | | return R.failed("请添加付款阶段或付款阶段缺少"); |
| | | } |
| | | if (!isValidPaymentStages(addDTO.getContractPaymentSchedule())){ |
| | |
| | | |
| | | @Override |
| | | public R updateContractSgb(ContractUpdateDTO updateDTO) { |
| | | if (ArrayUtil.isEmpty(updateDTO.getContractSubjectMatter().toArray())){ |
| | | if (ArrayUtil.isEmpty(updateDTO.getContractSubjectMatter())){ |
| | | return R.failed("请添加标的物"); |
| | | } |
| | | if (ArrayUtil.isEmpty(updateDTO.getContractPaymentSchedule().toArray())){ |
| | | if (ArrayUtil.isEmpty(updateDTO.getContractPaymentSchedule())){ |
| | | return R.failed("请添加付款阶段或付款阶段缺少"); |
| | | } |
| | | if (!isValidPaymentStages(updateDTO.getContractPaymentSchedule())){ |
| | |
| | | @Override |
| | | public Page fourAssociation(Page page,ContractQueryDTO queryDTO) { |
| | | Page<FourAssociationPageVo> page1 = baseMapper.fourAssociation(page,queryDTO,DataScope.of("comp_id")); |
| | | if (ArrayUtil.isNotEmpty(page1.getRecords().toArray())){ |
| | | if (ArrayUtil.isNotEmpty(page1.getRecords())){ |
| | | page1.getRecords().stream().forEach(fourAssociationPageVo -> { |
| | | List<PaymentSlip> slips = paymentSlipMapper.selectList(Wrappers.<PaymentSlip>lambdaQuery().eq(PaymentSlip::getContractId,fourAssociationPageVo.getId()) |
| | | .orderByAsc(PaymentSlip::getPaymentTime)); |
| | | if (ArrayUtil.isNotEmpty(slips.toArray())){ |
| | | if (ArrayUtil.isNotEmpty(slips)){ |
| | | fourAssociationPageVo.setSlipVoList(BeanUtil.copyToList(slips,ContractSlipVo.class)); |
| | | } |
| | | List<ContractInvoice> invoices = contractInvoiceMapper.selectList(Wrappers.<ContractInvoice>lambdaQuery().eq(ContractInvoice::getContractId,fourAssociationPageVo.getId()) |
| | | .orderByAsc(ContractInvoice::getInvoiceTime)); |
| | | if (ArrayUtil.isNotEmpty(invoices.toArray())){ |
| | | if (ArrayUtil.isNotEmpty(invoices)){ |
| | | fourAssociationPageVo.setInvoiceVoList(BeanUtil.copyToList(invoices, ContractInvoiceVo.class)); |
| | | } |
| | | if (fourAssociationPageVo.getAmount().compareTo(fourAssociationPageVo.getPaidAmount())==0&& |
| | | fourAssociationPageVo.getAmount().compareTo(fourAssociationPageVo.getBillingAmout())==0){ |
| | | fourAssociationPageVo.getAmount().compareTo(fourAssociationPageVo.getBillingAmout())==0&& |
| | | ArrayUtil.isNotEmpty(slips)&&ArrayUtil.isNotEmpty(invoices) |
| | | ){ |
| | | fourAssociationPageVo.setAssociation("已完成"); |
| | | } |
| | | }); |