k94314517
2025-07-04 50fb58286ed3b718c39a97e0987ee7561a295651
server/service/src/main/java/com/doumee/service/business/impl/TaxesServiceImpl.java
@@ -189,6 +189,20 @@
        update.setImgurl(taxes.getImgurl());
        taxesMapper.updateById(update);
        //查询开票明细记录
        List<TaxDetial> taxDetialList = taxDetialMapper.selectList(new QueryWrapper<TaxDetial>().lambda()
                .eq(TaxDetial::getTaxId,taxes.getId())
                .eq(TaxDetial::getType,Constants.TWO));
        if(CollectionUtils.isNotEmpty(taxDetialList)){
            for (TaxDetial taxDetial:taxDetialList) {
                taxesMapper.update(null,new UpdateWrapper<Taxes>().lambda()
                                .set(Taxes::getEditDate,new Date())
                                .set(Taxes::getEditor,user.getId())
                        .set(Taxes::getStatus,3).eq(Taxes::getId,taxDetial.getDelTaxId()));
            }
        }
        //存储待办信息
        Constants.NoticeObjectType noticeObjectType = Constants.NoticeObjectType.TAXES;
        //删除其他待办
@@ -235,7 +249,9 @@
        MPJLambdaWrapper<Taxes> queryWrapper = new MPJLambdaWrapper<>();
        queryWrapper.selectAll(Taxes.class);
        queryWrapper.selectAs(Solutions::getName,Taxes::getSolutionName);
        queryWrapper.selectAs(SystemUser::getRealname,Taxes::getCancelUserName);
        queryWrapper.leftJoin(Solutions.class,Solutions::getId,Taxes::getSolutionId);
        queryWrapper.leftJoin(SystemUser.class,SystemUser::getId,Taxes::getCancelUserId);
        Taxes model =taxesJoinMapper.selectById(id);
        if(model==null || !Constants.equalsInteger(model.getIsdeleted(),Constants.ZERO)){
            throw  new BusinessException(ResponseStatus.DATA_EMPTY);
@@ -357,6 +373,8 @@
        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()));
@@ -458,9 +476,10 @@
            ){
                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())
            );
@@ -468,7 +487,8 @@
                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()+"】可报销金额错误【"+insuranceApply.getCurrentFee().subtract(insuranceApply.getTaxesMoney())+"】");
                throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"保单号【"+taxDetial.getApplyCode()+"】不满足开票条件");
            }
            taxDetial.setCreator(user.getId());
            taxDetial.setCreateDate(new Date());
@@ -477,7 +497,7 @@
            taxDetial.setTotalFee(insuranceApply.getCurrentFee());
            taxDetial.setType(Constants.ZERO);
        }
        taxDetailJoinMapper.insertBatchSomeColumn(taxDetialList);
        taxDetailJoinMapper.insert(taxDetialList);
        //存储待办信息
@@ -648,7 +668,7 @@
            taxDetial.setTaxId(taxes.getId());
            taxDetial.setTotalFee(taxesInvoicingVO.getAmount());
            taxDetial.setFee(taxesInvoicingVO.getAmount());
            taxDetial.setInsuranceApplyId(taxes.getApplyId());
            taxDetial.setInsuranceApplyId(taxes.getInsuranceApplyId());
            if(taxesInvoicingVO.getType().equals(Constants.ZERO)){
                taxDetial.setType(taxesInvoicingVO.getType());
            }else if(taxesInvoicingVO.getType().equals(Constants.ONE)){
@@ -675,12 +695,13 @@
                taxDetial.setTotalFee(chTaxes.getPrice());
                taxDetial.setFee(chTaxes.getPrice());
                taxDetial.setDelTaxId(chTaxes.getId());
                taxDetial.setInsuranceApplyId(taxes.getInsuranceApplyId());
                taxDetial.setType(Constants.TWO);
                taxDetailList.add(taxDetial);
            }
        }
        if(CollectionUtils.isNotEmpty(taxDetailList)){
            taxDetailJoinMapper.insertBatchSomeColumn(taxDetailList);
            taxDetailJoinMapper.insert(taxDetailList);
        }else{
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"无可开票数据,操作失败");
        }