|  |  |  | 
|---|
|  |  |  | Taxes queryModel = pageWrap.getModel(); | 
|---|
|  |  |  | if(!user.getType().equals(Constants.ONE)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非企业用户无法进行该业务查询"); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | queryWrapper.eq(Taxes::getCompanyId,user.getCompanyId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(!Objects.isNull(queryModel)){ | 
|---|
|  |  |  | queryWrapper.ge(pageWrap.getModel().getStartDate() != null,Taxes::getCreateDate, (pageWrap.getModel().getStartDate())); | 
|---|
|  |  |  | 
|---|
|  |  |  | ){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //查询每个保单下可以投保的金额 | 
|---|
|  |  |  | //查询每个保单下可以报销的金额 | 
|---|
|  |  |  | InsuranceApply insuranceApply = insuranceApplyJoinMapper.selectJoinOne(InsuranceApply.class,new MPJLambdaWrapper<InsuranceApply>() | 
|---|
|  |  |  | .selectAll(InsuranceApply.class) | 
|---|
|  |  |  | //                    .select(" ifnull(( select sum(td.fee) from taxes ts inner join tax_detial td on td.TAX_ID = ts.id  where ts.status  = 1 and td.INSURANCE_APPLY_ID = t.id ),0) as taxesMoney") | 
|---|
|  |  |  | .select(" ifnull(( select sum(td.fee) from taxes ts inner join tax_detial td on td.TAX_ID = ts.id  where ts.status != 2 and td.INSURANCE_APPLY_ID = t.id ),0) as taxesMoney ") | 
|---|
|  |  |  | .eq(InsuranceApply::getId,taxDetial.getInsuranceApplyId()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | //            if(Objects.isNull(insuranceApply)){ | 
|---|
|  |  |  | //                throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"保单号【"+taxDetial.getApplyCode()+"】未查询到保单信息"); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | //            if(insuranceApply.getCurrentFee().subtract(insuranceApply.getTaxesMoney()).compareTo(taxDetial.getFee())!=Constants.ZERO){ | 
|---|
|  |  |  | //                //throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"保单号【"+taxDetial.getApplyCode()+"】可报销金额错误【"+insuranceApply.getCurrentFee().subtract(insuranceApply.getTaxesMoney())+"】"); | 
|---|
|  |  |  | //                throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"保单号【"+taxDetial.getApplyCode()+"】可报销金额错误"); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | if(Objects.isNull(insuranceApply)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"保单号【"+taxDetial.getApplyCode()+"】未查询到保单信息"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(insuranceApply.getCurrentFee().subtract(insuranceApply.getTaxesMoney()).compareTo(taxDetial.getFee())!=Constants.ZERO){ | 
|---|
|  |  |  | //throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"保单号【"+taxDetial.getApplyCode()+"】可报销金额错误【"+insuranceApply.getCurrentFee().subtract(insuranceApply.getTaxesMoney())+"】"); | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"保单号【"+taxDetial.getApplyCode()+"】不满足开票条件"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | taxDetial.setCreator(user.getId()); | 
|---|
|  |  |  | taxDetial.setCreateDate(new Date()); | 
|---|
|  |  |  | taxDetial.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | 
|---|
|  |  |  | taxDetial.setTotalFee(insuranceApply.getCurrentFee()); | 
|---|
|  |  |  | taxDetial.setType(Constants.ZERO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | taxDetailJoinMapper.insertBatchSomeColumn(taxDetialList); | 
|---|
|  |  |  | taxDetailJoinMapper.insert(taxDetialList); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //存储待办信息 | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(CollectionUtils.isNotEmpty(taxDetailList)){ | 
|---|
|  |  |  | taxDetailJoinMapper.insertBatchSomeColumn(taxDetailList); | 
|---|
|  |  |  | taxDetailJoinMapper.insert(taxDetailList); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"无可开票数据,操作失败"); | 
|---|
|  |  |  | } | 
|---|