| | |
| | | private final ContractOutBoundMapper contractOutBoundMapper; |
| | | private final RemoteDictService remoteDictService; |
| | | private final ContractPaymentScheduleProcessService processService; |
| | | private final ContractSubjectMatterChangeMapper changeMapper; |
| | | |
| | | @Value("${erp.ymj}") |
| | | private String ymjErp; |
| | |
| | | detailVo.setPaymentSlip(slipList); |
| | | } |
| | | BusinessCustomer customer = businessCustomerMapper.selectById(contract.getPartyAId()); |
| | | |
| | | ContractInvoiceBipVo bipVo = new ContractInvoiceBipVo(); |
| | | bipVo.setDjrq(DateUtil.today()); |
| | | R<SysDept> r = remoteDeptService.getById(contract.getPartyBId()); |
| | | if (r.isOk()) { |
| | | bipVo.setKpzz(r.getData().getBipCode()); |
| | | } |
| | | |
| | | if (ObjUtil.isNotNull(customer)) { |
| | | detailVo.setInvoiceType(customer.getInvoiceType()); |
| | | bipVo.setYwzz(r.getData().getBipCode()); |
| | | } |
| | | R<SysDept> rDept = remoteDeptService.getById(SecurityUtils.getUser().getDeptId()); |
| | | if (rDept.isOk()) { |
| | | bipVo.setBm(rDept.getData().getOrgCode()); |
| | | bipVo.setHsdy(rDept.getData().getOrgCode()); |
| | | } |
| | | bipVo.setYwy(SecurityUtils.getUser().getNickname()); |
| | | bipVo.setPzzdr(SecurityUtils.getUser().getNickname()); |
| | | bipVo.setJylx("ZBYXGLXT"); |
| | | bipVo.setWldxlx("1"); |
| | | bipVo.setKh(customer.getCreditCode()); |
| | | bipVo.setBz("人民币"); |
| | | bipVo.setFjzs("1"); |
| | | bipVo.setSfzy("是"); |
| | | bipVo.setSfnbwl("是"); |
| | | bipVo.setSfjyjs("否"); |
| | | bipVo.setDjfx("1"); |
| | | detailVo.setBipVo(bipVo); |
| | | return detailVo; |
| | | } |
| | | |
| | |
| | | request.put("moneySum", contract.getAmount()); |
| | | request.put("signManner", "面签"); |
| | | request.put("salesman", ""); |
| | | if (ArrayUtil.isNotEmpty(subjectMatterList)) { |
| | | if (CollUtil.isNotEmpty(subjectMatterList)) { |
| | | JSONArray subjectMatter = new JSONArray(); |
| | | subjectMatterList.stream().forEach(contractSubjectMatter -> { |
| | | JSONObject subjectMatterItem = new JSONObject(); |
| | |
| | | request.put("moneySum", contract.getAmount()); |
| | | request.put("signManner", "面签"); |
| | | request.put("salesman", ""); |
| | | if (ArrayUtil.isNotEmpty(subjectMatterList)) { |
| | | if (CollUtil.isNotEmpty(subjectMatterList)) { |
| | | JSONArray subjectMatter = new JSONArray(); |
| | | subjectMatterList.stream().forEach(contractSubjectMatter -> { |
| | | JSONObject subjectMatterItem = new JSONObject(); |
| | |
| | | .lt(ContractPaymentSchedule::getEffectiveEndDate, DateUtil.today()) |
| | | .ne(ContractPaymentSchedule::getPaymentStatus, "2") |
| | | .ne(ContractPaymentSchedule::getPaymentStatus, 3)); |
| | | if (ArrayUtil.isNotEmpty(scheduleList)) { |
| | | if (CollUtil.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)) { |
| | | if (CollUtil.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())) { |
| | | if (CollUtil.isEmpty(addDTO.getContractSubjectMatter())) { |
| | | return R.failed("请添加标的物"); |
| | | } |
| | | if (ArrayUtil.isEmpty(addDTO.getContractPaymentSchedule())) { |
| | | if (CollUtil.isEmpty(addDTO.getContractPaymentSchedule())) { |
| | | return R.failed("请添加付款阶段或付款阶段缺少"); |
| | | } |
| | | if (!isValidPaymentStages(addDTO.getContractPaymentSchedule())) { |
| | |
| | | } |
| | | 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(); |
| | |
| | | |
| | | @Override |
| | | public R updateContractSgb(ContractUpdateDTO updateDTO) { |
| | | if (ArrayUtil.isEmpty(updateDTO.getContractSubjectMatter())) { |
| | | if (CollUtil.isEmpty(updateDTO.getContractSubjectMatter())) { |
| | | return R.failed("请添加标的物"); |
| | | } |
| | | if (ArrayUtil.isEmpty(updateDTO.getContractPaymentSchedule())) { |
| | | if (CollUtil.isEmpty(updateDTO.getContractPaymentSchedule())) { |
| | | return R.failed("请添加付款阶段或付款阶段缺少"); |
| | | } |
| | | if (!isValidPaymentStages(updateDTO.getContractPaymentSchedule())) { |
| | |
| | | } |
| | | 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); |
| | |
| | | @Override |
| | | public Page fourAssociation(Page page, ContractQueryDTO queryDTO) { |
| | | Page<FourAssociationPageVo> page1 = baseMapper.fourAssociation(page, queryDTO, DataScope.of("comp_id")); |
| | | if (ArrayUtil.isNotEmpty(page1.getRecords())) { |
| | | if (CollUtil.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)) { |
| | | if (CollUtil.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)) { |
| | | if (CollUtil.isNotEmpty(invoices)) { |
| | | fourAssociationPageVo.setInvoiceVoList(BeanUtil.copyToList(invoices, ContractInvoiceVo.class)); |
| | | } |
| | | if (fourAssociationPageVo.getAmount().compareTo(fourAssociationPageVo.getPaidAmount()) == 0 && |
| | | fourAssociationPageVo.getAmount().compareTo(fourAssociationPageVo.getBillingAmout()) == 0 && |
| | | ArrayUtil.isNotEmpty(slips) && ArrayUtil.isNotEmpty(invoices) |
| | | CollUtil.isNotEmpty(slips) && CollUtil.isNotEmpty(invoices) |
| | | ) { |
| | | fourAssociationPageVo.setAssociation("已完成"); |
| | | } |
| | |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public R subjectChange(ContractSubjectChangeDTO changeDTO) { |
| | | Contract contract = baseMapper.selectById(changeDTO.getId()); |
| | | if (ObjUtil.isNull(contract)){ |
| | | return R.failed("合同状态异常"); |
| | | } |
| | | if (contract.getBillingAmout().compareTo(new BigDecimal("0"))>0){ |
| | | return R.failed("合同已开票,不能进行变更"); |
| | | } |
| | | if (ObjUtil.isNotNull(contract.getOutBoundAmout())&&contract.getOutBoundAmout().compareTo(new BigDecimal("0"))>0){ |
| | | return R.failed("合同标的物已出库,不能进行变更"); |
| | | } |
| | | if (CollUtil.isEmpty(changeDTO.getContractSubjectMatter())){ |
| | | return R.failed("合同变更后标的物不能为空"); |
| | | } |
| | | BigDecimal changeAmount = changeDTO.getContractSubjectMatter().stream().map(subject->subject.getUnitPrice().multiply(subject.getQuantity())).reduce(BigDecimal.ZERO,BigDecimal::add); |
| | | if (contract.getAmount().compareTo(changeAmount)!=0){ |
| | | return R.failed("合同变更后标的物总价必须与合同总价一致"); |
| | | } |
| | | List<ContractSubjectMatter> beforeList = contractSubjectMatterMapper.selectList(Wrappers.<ContractSubjectMatter>lambdaQuery().eq(ContractSubjectMatter::getContractId,changeDTO.getId())); |
| | | ContractSubjectMatterChange change = new ContractSubjectMatterChange(); |
| | | change.setContractId(contract.getId()); |
| | | change.setBeforeChange(JSONObject.toJSONString(beforeList)); |
| | | change.setAfterChange(JSONObject.toJSONString(changeDTO.getContractSubjectMatter())); |
| | | changeMapper.insert(change); |
| | | contractSubjectMatterMapper.delete(Wrappers.<ContractSubjectMatter>lambdaQuery().eq(ContractSubjectMatter::getContractId,changeDTO.getId())); |
| | | changeDTO.getContractSubjectMatter().stream().forEach(contractSubjectMatterAddDTO -> { |
| | | ContractSubjectMatter subjectMatter = BeanUtil.copyProperties(contractSubjectMatterAddDTO, ContractSubjectMatter.class); |
| | | subjectMatter.setContractId(contract.getId()); |
| | | subjectMatter.setLineNo(ItemGeneratorUtil.nextId()); |
| | | subjectMatter.setDeliveredQuantity(new BigDecimal("0")); |
| | | subjectMatter.setDeliveryStatus(0); |
| | | subjectMatter.setTotalAmount(contractSubjectMatterAddDTO.getQuantity().multiply(contractSubjectMatterAddDTO.getUnitPrice())); |
| | | contractSubjectMatterMapper.insert(subjectMatter); |
| | | }); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Override |
| | | public Page subjectChangePage(Page page, ContracQueryDTO queryDTO) { |
| | | return changeMapper.subjectChangePage(page,queryDTO,DataScope.of("comp_id")); |
| | | } |
| | | } |