111
k94314517
2024-02-05 15e588eb6a7549ecd2aaffb45e67f11e68354eb6
server/service/src/main/java/com/doumee/service/business/impl/TaxesServiceImpl.java
@@ -129,11 +129,12 @@
    private List<TaxDetial> getJoinDetailListById(Integer id) {
        MPJLambdaWrapper<TaxDetial> queryWrapper = new MPJLambdaWrapper<>();
        queryWrapper.selectAll(TaxDetial.class);
        queryWrapper.selectAs(Solutions::getName,TaxDetial::getSolutionName);
        queryWrapper.selectAs(Taxes::getDoneCode,TaxDetial::getTaxDoneCode);
        queryWrapper.selectAs(Taxes::getCreateDate,TaxDetial::getTaxCreateDate);
        queryWrapper.selectAs(InsuranceApply::getCode,TaxDetial::getApplyCode);
        queryWrapper.selectAs(ApplyChange::getCode,TaxDetial::getChangApplyCode);
        queryWrapper.select("(CASE t.type\n" +
        queryWrapper.selectAs(ApplyChange::getValidCode,TaxDetial::getChangApplyCode);
/*        queryWrapper.select("(CASE t.type\n" +
                "WHEN 0 THEN (select count(1) from apply_detail c where c.APPLY_ID=t.INSURANCE_APPLY_ID) \n" +
                "ELSE 0  \n" +
                "END) as applyNum,\n" +
@@ -144,10 +145,12 @@
                "(CASE t.type \n" +
                "WHEN 1 THEN  (select count(1) from apply_chagne_detail c where c.APPLY_CHANGE_ID=t.APPLY_CHANGE_ID)  \n" +
                "ELSE 0  \n" +
                "END) as applyChangeAddNum");
                "END) as applyChangeAddNum");*/
        queryWrapper.leftJoin(InsuranceApply.class,InsuranceApply::getId,TaxDetial::getInsuranceApplyId);
        queryWrapper.leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId);
        queryWrapper.leftJoin(ApplyChange.class,ApplyChange::getId,TaxDetial::getApplyChangeId);
        queryWrapper.leftJoin(Taxes.class,Taxes::getId,TaxDetial::getDelTaxId);
        queryWrapper.eq(  TaxDetial::getTaxId,id);
        List<TaxDetial> detialList =  taxDetailJoinMapper.selectJoinList(TaxDetial.class,queryWrapper.orderByAsc(TaxDetial::getType));
@@ -246,11 +249,12 @@
            List<TaxDetial> applyList = new ArrayList<>();//投保和加减保
            List<TaxDetial> delList = new ArrayList<>();//冲红单
            if(detialList!=null){
                for(TaxDetial d :delList){
                    d.setSolutionName(model.getSolutionName());
                for(TaxDetial d :detialList){
//                    d.setSolutionName(model.getSolutionName());
                    d.setFee(Constants.formatBigdecimal(d.getFee()));
                    d.setTotalFee(Constants.formatBigdecimal(d.getTotalFee()));
                    if(Constants.equalsInteger(d.getType(),Constants.ZERO) || Constants.equalsInteger(d.getType(),Constants.ONE)){
                    if(Constants.equalsInteger(d.getType(),Constants.ZERO)
                            || Constants.equalsInteger(d.getType(),Constants.ONE)){
                        applyList.add(d);
                    }else  if(Constants.equalsInteger(d.getType(),Constants.TWO)){
                        delList.add(d);
@@ -343,6 +347,7 @@
        queryWrapper.selectAll(Taxes.class);
        queryWrapper.selectAs(SystemUser::getRealname,Taxes::getCreatorName);
        queryWrapper.leftJoin(SystemUser.class,SystemUser::getId,Taxes::getCreator);
        Utils.MP.blankToNull(pageWrap.getModel());
        queryWrapper.eq(Taxes::getIsdeleted, Constants.ZERO);
        Taxes queryModel = pageWrap.getModel();
@@ -371,6 +376,38 @@
    @Override
    public List<Taxes> findListForCompany(Taxes queryModel) {
        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
        MPJLambdaWrapper<Taxes> queryWrapper = new MPJLambdaWrapper<>();
        queryWrapper.selectAll(Taxes.class);
        queryWrapper.selectAs(SystemUser::getRealname,Taxes::getCreatorName);
        queryWrapper.leftJoin(SystemUser.class,SystemUser::getId,Taxes::getCreator);
        queryWrapper.eq(Taxes::getIsdeleted, Constants.ZERO);
        if(!user.getType().equals(Constants.ONE)){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非企业用户无法进行该业务查询");
        }
        if(!Objects.isNull(queryModel)){
            queryWrapper.ge(queryModel.getStartDate() != null,Taxes::getCreateDate, (queryModel.getStartDate()));
            queryWrapper.le(queryModel.getEndDate() != null,Taxes::getCreateDate,  (queryModel.getEndDate()));
            queryWrapper.eq(!Objects.isNull(queryModel.getInsuranceApplyId()),Taxes::getInsuranceApplyId,queryModel.getInsuranceApplyId());
            queryWrapper.eq(!Objects.isNull(queryModel.getStatus()),Taxes::getStatus,queryModel.getStatus());
            queryWrapper.exists(!Objects.isNull(queryModel.getApplyId())," select 1 from tax_detial td where td.insurance_apply_id = "+queryModel.getApplyId()+" and t.id = td.tax_id ");
        }
        queryWrapper.orderByAsc(Taxes::getCreateDate);
        List<Taxes> result = taxesJoinMapper.selectJoinList(Taxes.class, queryWrapper);
        String path =systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode()+systemDictDataBiz.queryByCode(Constants.OSS,Constants.TAXES_FILE).getCode();
        for(Taxes t : result){
            if(StringUtils.isNotBlank(t.getImgurl())){
                t.setImgurlFull(path + t.getImgurl());
            }
        }
        return result;
    }
    @Override
@@ -381,7 +418,7 @@
            || Objects.isNull(entrustInvoicingDTO.getInvoicingMoney())
            || Objects.isNull(entrustInvoicingDTO.getType())
            || Objects.isNull(entrustInvoicingDTO.getTaxDetialList())
            || StringUtils.isNotBlank(entrustInvoicingDTO.getAddress())
            || StringUtils.isBlank(entrustInvoicingDTO.getAddress())
        ){
            throw new BusinessException(ResponseStatus.BAD_REQUEST);
        }
@@ -419,7 +456,7 @@
            //查询每个保单下可以投保的金额
            InsuranceApply insuranceApply = insuranceApplyJoinMapper.selectJoinOne(InsuranceApply.class,new MPJLambdaWrapper<InsuranceApply>()
                    .selectAll(InsuranceApply.class)
                    .select(" ( select sum(td.fee) from taxes ts inner join tax_detial td on ts.TAX_ID = ts.id  where ts.status != 2 and td.INSURANCE_APPLY_ID = t.id ) 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)){