From 02bc3bfe47e3d5311a0bb041c94e70a34b1ca73c Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期二, 09 四月 2024 09:03:01 +0800
Subject: [PATCH] git ch

---
 server/service/src/main/java/com/doumee/service/business/impl/TaxesServiceImpl.java |   51 +++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 43 insertions(+), 8 deletions(-)

diff --git a/server/service/src/main/java/com/doumee/service/business/impl/TaxesServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/TaxesServiceImpl.java
index f9c781b..36414c2 100644
--- a/server/service/src/main/java/com/doumee/service/business/impl/TaxesServiceImpl.java
+++ b/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,12 +249,14 @@
         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);
         }
-        if(Constants.equalsInteger(model.getType(),Constants.ZERO)){
+        if(Constants.equalsInteger(model.getApplyType(),Constants.ZERO)){
             List<TaxDetial> detialList = getDetailsApplysListById(id);
             model.setApplyList(detialList);
         }else{
@@ -272,8 +288,12 @@
             queryWrapper.selectAll(TaxDetial.class);
             queryWrapper.selectAs(InsuranceApply::getCode,TaxDetial::getApplyCode);
             queryWrapper.selectAs(Solutions::getName,TaxDetial::getSolutionName);
+            queryWrapper.selectAs(ApplyChange::getValidCode,TaxDetial::getChangApplyCode);
             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.in(TaxDetial::getType,Constants.ZERO,Constants.ONE);
+            queryWrapper.eq(TaxDetial::getTaxId,id);
             List<TaxDetial> detialList =  taxDetailJoinMapper.selectJoinList(TaxDetial.class,queryWrapper.orderByAsc(TaxDetial::getType));
             return detialList;
     }
@@ -393,9 +413,18 @@
             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);
-        return taxesJoinMapper.selectJoinList(Taxes.class, queryWrapper);
+
+        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;
     }
 
 
@@ -409,7 +438,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);
         }
@@ -434,6 +463,7 @@
         taxes.setAddr(entrustInvoicingDTO.getAddress());
         taxes.setCompanyName(company.getName());
         taxes.setApplyType(Constants.ZERO);
+        taxes.setTaxBank(company.getTaxBank());
         taxesMapper.insert(taxes);
 
         List<TaxDetial> taxDetialList = entrustInvoicingDTO.getTaxDetialList();
@@ -447,7 +477,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)){
@@ -531,6 +561,7 @@
         List<ApplyChange> applyChangeList = applyChangeJoinMapper.selectJoinList(ApplyChange.class,new MPJLambdaWrapper<ApplyChange>()
                 .selectAll(ApplyChange.class)
                 .selectAs(InsuranceApply::getCode,ApplyChange::getApplyCode)
+                .selectAs(Solutions::getName,ApplyChange::getSolutionsName)
                 .select("( select count(1) from apply_chagne_detail ad where t.id = ad.APPLY_CHANGE_ID and ad.TYPE = 0  ) as addNum ")
                 .select("( select count(1) from apply_chagne_detail ad where t.id = ad.APPLY_CHANGE_ID and ad.TYPE = 1  ) as delNum ")
                 .select("( select ifnull(sum(ad.FEE),0) from apply_chagne_detail ad where t.id = ad.APPLY_CHANGE_ID  ) as changeMoney" )
@@ -544,11 +575,13 @@
 
         if(CollectionUtils.isNotEmpty(applyChangeList)){
             for (ApplyChange applyChange:applyChangeList) {
-                insuranceApply.setFee(insuranceApply.getFee().subtract(applyChange.getFee()));
-                TaxesInvoicingVO taxesInvoicingVO = applyChange.toTaxesInvoicingVO();
                 if(!Objects.isNull(insuranceApply)){
-                    taxesInvoicingVO.setAmount(BigDecimal.ZERO);
+                    insuranceApply.setFee(insuranceApply.getFee().subtract(applyChange.getFee()));
                 }
+                TaxesInvoicingVO taxesInvoicingVO = applyChange.toTaxesInvoicingVO();
+//                if(!Objects.isNull(insuranceApply)){
+//                    taxesInvoicingVO.setAmount(BigDecimal.ZERO);
+//                }
                 taxesInvoicingVOList.add(taxesInvoicingVO);
             }
         }
@@ -604,6 +637,7 @@
         taxes.setType(directInvoicingDTO.getType());
         taxes.setTaxCode(company.getTaxCode());
         taxes.setTaxAccount(company.getTaxAccount());
+        taxes.setTaxBank(company.getTaxBank());
         taxes.setTaxAddr(company.getTaxAddr());
         taxes.setAddr(directInvoicingDTO.getAddress());
         taxes.setCompanyName(company.getName());
@@ -630,8 +664,8 @@
             taxDetial.setTaxId(taxes.getId());
             taxDetial.setTotalFee(taxesInvoicingVO.getAmount());
             taxDetial.setFee(taxesInvoicingVO.getAmount());
+            taxDetial.setInsuranceApplyId(taxes.getInsuranceApplyId());
             if(taxesInvoicingVO.getType().equals(Constants.ZERO)){
-                taxDetial.setInsuranceApplyId(taxesInvoicingVO.getId());
                 taxDetial.setType(taxesInvoicingVO.getType());
             }else if(taxesInvoicingVO.getType().equals(Constants.ONE)){
                 taxDetial.setApplyChangeId(taxesInvoicingVO.getId());
@@ -657,6 +691,7 @@
                 taxDetial.setTotalFee(chTaxes.getPrice());
                 taxDetial.setFee(chTaxes.getPrice());
                 taxDetial.setDelTaxId(chTaxes.getId());
+                taxDetial.setInsuranceApplyId(taxes.getInsuranceApplyId());
                 taxDetial.setType(Constants.TWO);
                 taxDetailList.add(taxDetial);
             }

--
Gitblit v1.9.3