From 617bbcea64a2e81fc4543250648725debfc1db3c Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期三, 24 一月 2024 09:15:01 +0800
Subject: [PATCH] Mr.Shi
---
server/service/src/main/java/com/doumee/service/business/impl/TaxesServiceImpl.java | 161 ++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 146 insertions(+), 15 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 8f35fa4..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) {
@@ -209,25 +217,41 @@
if(model==null || !Constants.equalsInteger(model.getIsdeleted(),Constants.ZERO)){
throw new BusinessException(ResponseStatus.DATA_EMPTY);
}
- //鏌ヨ鏄庣粏鍒楄〃
- List<TaxDetial> detialList = getJoinDetailListById(id);
- List<TaxDetial> applyList = new ArrayList<>();//鎶曚繚鍜屽姞鍑忎繚
- List<TaxDetial> delList = new ArrayList<>();//鍐茬孩鍗�
- if(detialList!=null){
- for(TaxDetial d :delList){
- 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)){
- applyList.add(d);
- }else if(Constants.equalsInteger(d.getType(),Constants.TWO)){
- delList.add(d);
+ if(Constants.equalsInteger(model.getType(),Constants.ZERO)){
+ List<TaxDetial> detialList = getDetailsApplysListById(id);
+ model.setApplyList(detialList);
+ }else{
+ //鏌ヨ鏄庣粏鍒楄〃
+ List<TaxDetial> detialList = getJoinDetailListById(id);
+ List<TaxDetial> applyList = new ArrayList<>();//鎶曚繚鍜屽姞鍑忎繚
+ List<TaxDetial> delList = new ArrayList<>();//鍐茬孩鍗�
+ if(detialList!=null){
+ for(TaxDetial d :delList){
+ 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)){
+ applyList.add(d);
+ }else if(Constants.equalsInteger(d.getType(),Constants.TWO)){
+ delList.add(d);
+ }
}
}
+ model.setApplyList(applyList);
+ model.setDelTaxList(delList);
}
- model.setApplyList(applyList);
- model.setDelTaxList(delList);
return model;
+ }
+
+ private List<TaxDetial> getDetailsApplysListById(Integer id) {
+ MPJLambdaWrapper<TaxDetial> queryWrapper = new MPJLambdaWrapper<>();
+ queryWrapper.selectAll(TaxDetial.class);
+ queryWrapper.selectAs(InsuranceApply::getCode,TaxDetial::getApplyCode);
+ queryWrapper.selectAs(Solutions::getName,TaxDetial::getSolutionName);
+ queryWrapper.leftJoin(InsuranceApply.class,InsuranceApply::getId,TaxDetial::getInsuranceApplyId);
+ queryWrapper.leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId);
+ List<TaxDetial> detialList = taxDetailJoinMapper.selectJoinList(TaxDetial.class,queryWrapper.orderByAsc(TaxDetial::getType));
+ return detialList;
}
@Override
@@ -289,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