|  |  |  | 
|---|
|  |  |  | package com.doumee.service.business.impl; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.doumee.biz.system.SystemDictDataBiz; | 
|---|
|  |  |  | import com.doumee.core.constants.ResponseStatus; | 
|---|
|  |  |  | import com.doumee.core.exception.BusinessException; | 
|---|
|  |  |  | import com.doumee.core.model.LoginUserInfo; | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SystemUserMapper systemUserMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SystemDictDataBiz systemDictDataBiz; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) | 
|---|
|  |  |  | 
|---|
|  |  |  | ywContractRevenue.setContractId(ywContractBill.getContractId()); | 
|---|
|  |  |  | //根据收支情况 更新账单数据 | 
|---|
|  |  |  | //查询当前账单下 已支付的费用 | 
|---|
|  |  |  | List<YwContractRevenue> ywContractRevenueList = ywContractRevenueMapper.selectList(new QueryWrapper<YwContractRevenue>().lambda().eq(YwContractRevenue::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | List<YwContractRevenue> ywContractRevenueList = ywContractRevenueMapper.selectList(new QueryWrapper<YwContractRevenue>() | 
|---|
|  |  |  | .lambda().eq(YwContractRevenue::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(YwContractRevenue::getStatus,Constants.ZERO) | 
|---|
|  |  |  | .eq(YwContractRevenue::getBillId,ywContractRevenue.getBillId()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | //已支付金额 | 
|---|
|  |  |  | BigDecimal payTotal = BigDecimal.ZERO; | 
|---|
|  |  |  | 
|---|
|  |  |  | //待支付的流水 如果为收入 则比对 金额值  如果是支出 则获取绝对值 进行对比 | 
|---|
|  |  |  | if(Constants.equalsInteger(ywContractRevenue.getRevenueType(),Constants.ZERO)){ | 
|---|
|  |  |  | //如果支付金额 大于 待支付金额 则提示异常 如果支付金额小于 待支付金额 则状态不变化 其他状态 异常 | 
|---|
|  |  |  | if(waitPayTotal.compareTo(ywContractRevenue.getActReceivableFee())>Constants.ZERO){ | 
|---|
|  |  |  | if(waitPayTotal.compareTo(ywContractRevenue.getActReceivableFee())<Constants.ZERO){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"请输入正确的金额!"); | 
|---|
|  |  |  | }else if(waitPayTotal.compareTo(ywContractRevenue.getActReceivableFee())==Constants.ZERO){ | 
|---|
|  |  |  | ywContractBill.setPayStatus(Constants.ONE); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | waitPayTotal = waitPayTotal.abs(); | 
|---|
|  |  |  | if(waitPayTotal.compareTo(ywContractRevenue.getActReceivableFee())>Constants.ZERO){ | 
|---|
|  |  |  | if(waitPayTotal.compareTo(ywContractRevenue.getActReceivableFee())<Constants.ZERO){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"请输入正确的金额!"); | 
|---|
|  |  |  | }else if(waitPayTotal.compareTo(ywContractRevenue.getActReceivableFee())==Constants.ZERO){ | 
|---|
|  |  |  | ywContractBill.setPayStatus(Constants.ONE); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | this.getRecordData(ywContractRevenue); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //附件数据 | 
|---|
|  |  |  | List<Multifile> multifileList = multifileMapper.selectJoinList(Multifile.class,new MPJLambdaWrapper<Multifile>() | 
|---|
|  |  |  | .selectAll(Multifile.class) | 
|---|
|  |  |  | .selectAs(SystemUser::getRealname,Multifile::getUserName) | 
|---|
|  |  |  | .leftJoin(SystemUser.class,SystemUser::getId,Multifile::getCreator) | 
|---|
|  |  |  | .eq(Multifile::getObjId,id) | 
|---|
|  |  |  | .eq(Multifile::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(Multifile::getObjType,Constants.MultiFile.FN_CONTRACT_REVENUE_FILE.getKey())); | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(multifileList)){ | 
|---|
|  |  |  | String path = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_RESOURCE_PATH).getCode() | 
|---|
|  |  |  | +systemDictDataBiz.queryByCode(Constants.FTP,Constants.YW_CONTRACT_BILL).getCode(); | 
|---|
|  |  |  | for (Multifile multifile:multifileList) { | 
|---|
|  |  |  | if(StringUtils.isNotBlank(multifile.getFileurl())){ | 
|---|
|  |  |  | multifile.setFileurlFull(path + multifile.getFileurl()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ywContractRevenue.setMultifileList(multifileList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ywContractRevenue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | if(Objects.isNull(ywContract)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(Constants.equalsInteger(ywContract.getStatus(),Constants.THREE)){ | 
|---|
|  |  |  | if(Constants.equalsInteger(ywContract.getStatus(),Constants.FOUR)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"合同状态已流转,无法操作"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(Constants.equalsInteger(ywContractBill.getPayStatus(),Constants.ONE) | 
|---|
|  |  |  | || Constants.equalsInteger(ywContractBill.getPayStatus(),Constants.TWO)){ | 
|---|
|  |  |  | || Constants.equalsInteger(ywContractBill.getPayStatus(),Constants.FIVE)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"账单状态已流转,无法操作"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //查询账单下 所有的账单 | 
|---|