From 8a7797cf8ba37fa1beec625209a6964a3668b994 Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期二, 23 一月 2024 18:18:33 +0800
Subject: [PATCH] 111

---
 server/service/src/main/java/com/doumee/service/business/impl/TaxesServiceImpl.java |  115 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 115 insertions(+), 0 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 62e836d..27ae00a 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
@@ -8,8 +8,11 @@
 import com.doumee.core.model.PageWrap;
 import com.doumee.core.utils.Constants;
 import com.doumee.core.utils.Utils;
+import com.doumee.dao.business.CompanyMapper;
 import com.doumee.dao.business.TaxDetialMapper;
 import com.doumee.dao.business.TaxesMapper;
+import com.doumee.dao.business.dto.EntrustInvoicingDTO;
+import com.doumee.dao.business.join.InsuranceApplyJoinMapper;
 import com.doumee.dao.business.join.TaxDetailJoinMapper;
 import com.doumee.dao.business.join.TaxesJoinMapper;
 import com.doumee.dao.business.model.*;
@@ -30,6 +33,7 @@
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.Objects;
 
 /**
  * 鍙戠エ淇℃伅琛⊿ervice瀹炵幇
@@ -49,6 +53,10 @@
     private TaxDetailJoinMapper taxDetailJoinMapper;
     @Autowired
     private SystemDictDataBiz systemDictDataBiz;
+    @Autowired
+    private CompanyMapper companyMapper;
+    @Autowired
+    private InsuranceApplyJoinMapper insuranceApplyJoinMapper;
 
     @Override
     public Integer create(Taxes taxes) {
@@ -305,4 +313,111 @@
         QueryWrapper<Taxes> wrapper = new QueryWrapper<>(taxes);
         return taxesMapper.selectCount(wrapper);
     }
+
+
+    @Override
+    public PageData<Taxes> findPageForCompany(PageWrap<Taxes> pageWrap) {
+        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
+        IPage<Taxes> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity());
+        MPJLambdaWrapper<Taxes> queryWrapper = new MPJLambdaWrapper<>();
+        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();
+        if(!user.getType().equals(Constants.ONE)){
+            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"闈炰紒涓氱敤鎴锋棤娉曡繘琛岃涓氬姟鏌ヨ");
+        }
+        if(!Objects.isNull(queryModel)){
+            queryWrapper.ge(pageWrap.getModel().getStartDate() != null,Taxes::getCreateDate, Utils.Date.getStart(pageWrap.getModel().getStartDate()));
+            queryWrapper.le(SignRecord::getCreateDate, Utils.Date.getEnd(pageWrap.getModel().getEndDate()));
+            queryWrapper.eq(!Objects.isNull(queryModel.getInsuranceApplyId()),Taxes::getInsuranceApplyId,queryModel.getInsuranceApplyId());
+            queryWrapper.eq(!Objects.isNull(queryModel.getStatus()),Taxes::getStatus,queryModel.getStatus());
+        }
+
+        queryWrapper.orderByAsc(Taxes::getCreateDate);
+        PageData<Taxes>  result =PageData.from(taxesJoinMapper.selectJoinPage(page,Taxes.class, queryWrapper));
+        if(result!=null && result.getRecords()!=null){
+            String path =systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode()+systemDictDataBiz.queryByCode(Constants.OSS,Constants.TAXES_FILE).getCode();
+            for(Taxes t : result.getRecords()){
+                if(StringUtils.isNotBlank(t.getImgurl())){
+                    t.setImgurlFull(path + t.getImgurl());
+                }
+            }
+        }
+        return result;
+    }
+
+
+
+
+
+    @Override
+    @Transactional(rollbackFor = {BusinessException.class,Exception.class})
+    public void entrustInvoicing(EntrustInvoicingDTO entrustInvoicingDTO){
+        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
+        if(Objects.isNull(entrustInvoicingDTO)
+            || Objects.isNull(entrustInvoicingDTO.getInvoicingMoney())
+            || Objects.isNull(entrustInvoicingDTO.getType())
+            || Objects.isNull(entrustInvoicingDTO.getTaxDetialList())
+            || StringUtils.isNotBlank(entrustInvoicingDTO.getAddress())
+        ){
+            throw new BusinessException(ResponseStatus.BAD_REQUEST);
+        }
+        if(!user.getType().equals(Constants.ONE)){
+            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"闈炰紒涓氱敤鎴锋棤娉曡繘琛岃涓氬姟鏌ヨ");
+        }
+        Company company = companyMapper.selectById(user.getCompanyId());
+        if(Objects.isNull(company)){
+            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈煡璇㈠埌浼佷笟淇℃伅");
+        }
+        Taxes taxes = new Taxes();
+        taxes.setCreator(user.getId());
+        taxes.setCreateDate(new Date());
+        taxes.setIsdeleted(Constants.ZERO);
+        taxes.setStatus(Constants.ZERO);
+        taxes.setCompanyId(company.getId());
+        taxes.setPrice(entrustInvoicingDTO.getInvoicingMoney());
+        taxes.setType(entrustInvoicingDTO.getType());
+        taxes.setTaxCode(company.getTaxCode());
+        taxes.setTaxAccount(company.getTaxAccount());
+        taxes.setTaxAddr(company.getTaxAddr());
+        taxes.setAddr(entrustInvoicingDTO.getAddress());
+        taxes.setCompanyName(company.getName());
+        taxes.setApplyType(Constants.ZERO);
+        taxesMapper.insert(taxes);
+
+        List<TaxDetial> taxDetialList = entrustInvoicingDTO.getTaxDetialList();
+        for (TaxDetial taxDetial:taxDetialList) {
+            if(Objects.isNull(taxDetial)
+                    || Objects.isNull(taxDetial.getInsuranceApplyId())
+                    || Objects.isNull(taxDetial.getFee())
+            ){
+                throw new BusinessException(ResponseStatus.BAD_REQUEST);
+            }
+            //鏌ヨ姣忎釜淇濆崟涓嬪彲浠ユ姇淇濈殑閲戦
+            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 ")
+                    .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())+"銆�");
+            }
+            taxDetial.setCreator(user.getId());
+            taxDetial.setCreateDate(new Date());
+            taxDetial.setIsdeleted(Constants.ZERO);
+            taxDetial.setTaxId(taxes.getId());
+            taxDetial.setTotalFee(insuranceApply.getCurrentFee());
+            taxDetial.setType(Constants.ZERO);
+        }
+        taxDetailJoinMapper.insertBatchSomeColumn(taxDetialList);
+    }
+
+
+
 }

--
Gitblit v1.9.3