| | |
| | | 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.*; |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 发票信息表Service实现 |
| | |
| | | private TaxDetailJoinMapper taxDetailJoinMapper; |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | @Autowired |
| | | private CompanyMapper companyMapper; |
| | | @Autowired |
| | | private InsuranceApplyJoinMapper insuranceApplyJoinMapper; |
| | | |
| | | @Override |
| | | public Integer create(Taxes taxes) { |
| | |
| | | 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); |
| | | } |
| | | |
| | | |
| | | |
| | | } |