| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117 |
- package com.ydtech.modules.fnc.service.impl;
- import cn.afterturn.easypoi.excel.entity.ExportParams;
- import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- import com.fasterxml.jackson.databind.JsonNode;
- import com.fasterxml.jackson.databind.ObjectMapper;
- import com.github.pagehelper.PageHelper;
- import com.github.pagehelper.PageInfo;
- import com.ydtech.constants.enums.dict.agreement.ProductsType;
- import com.ydtech.core.page.HttpResult;
- import com.ydtech.exception.SystemException;
- import com.ydtech.modules.base.controller.BaseController;
- import com.ydtech.modules.esm.model.EsmInsCompany;
- import com.ydtech.modules.esm.service.EsmInsCompanyService;
- import com.ydtech.modules.fnc.dao.InsPlyIncomeMapper;
- import com.ydtech.modules.fnc.entity.*;
- import com.ydtech.modules.fnc.service.*;
- import com.ydtech.modules.fnc.vo.InsPlyIncomeVo;
- import com.ydtech.modules.fnc.vo.SettlementDocumentaryFeesVo;
- import com.ydtech.modules.ins.model.vo.res.*;
- import com.ydtech.modules.inv.model.dto.*;
- import com.ydtech.modules.inv.utils.EasyExcelUtils;
- import com.ydtech.modules.order.entity.BasePageResult;
- import com.ydtech.modules.order.entity.InsOrders;
- import com.ydtech.modules.order.service.InsAreaCompanyService;
- import com.ydtech.modules.order.service.InsOrdersService;
- import com.ydtech.modules.protocol.entity.po.PtlAgreement;
- import com.ydtech.modules.protocol.entity.vo.PtlAgreementQueryVo;
- import com.ydtech.modules.protocol.service.PtlAgreementService;
- import com.ydtech.modules.protocols.entity.po.InsFeeOrderNew;
- import com.ydtech.modules.protocols.service.InsFeeOrderNewService;
- import com.ydtech.utils.BigDecimalUtils;
- import com.ydtech.utils.SnowFlakeUtil;
- import com.ydtech.utils.StringOperations;
- import com.ydtech.utils.excel.ExcelEasypoiUtils;
- import com.ydtech.utils.excel.ExcelStyleUtil;
- import lombok.extern.slf4j.Slf4j;
- import org.apache.commons.lang3.ObjectUtils;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.beans.BeanUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.context.annotation.Lazy;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import org.springframework.util.CollectionUtils;
- import org.springframework.web.multipart.MultipartFile;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import java.io.IOException;
- import java.math.BigDecimal;
- import java.math.RoundingMode;
- import java.nio.file.Files;
- import java.nio.file.Path;
- import java.nio.file.Paths;
- import java.time.LocalDate;
- import java.time.LocalDateTime;
- import java.time.YearMonth;
- import java.util.*;
- /**
- * <p>
- * 保司结算手续费 服务实现类
- * </p>
- *
- * @author gws
- * @since 2024-01-05
- */
- @Slf4j
- @Service
- public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, InsPlyIncome> implements InsPlyIncomeService {
- @Autowired
- @Lazy
- private InsOrdersService insOrdersService;
- @Autowired
- private InsAreaCompanyService insAreaCompanyService;
- @Autowired
- private InsFeeOrderNewService insFeeOrderNewService;
- @Autowired
- private SettlementDocumentaryFeesService settlementDocumentaryFeesService;
- @Autowired
- private SettlementDocumentaryLogService settlementDocumentaryLogService;
- @Autowired
- private PtlAgreementService ptlAgreementService;
- @Autowired
- private EsmInsCompanyService EsmInsCompanyService;
- @Autowired
- private ImportAsyncService importAsyncService;
- @Autowired
- private IncomeTaskRelationshipService incomeTaskRelationshipService;
- @Value("${upload.file.path}")
- private String uploadPath;
- @Value("${upload.file.url}")
- private String uploadUrl;
- public HttpResult<BasePageResult<InsPlyIncome>> queryplyIncome(InsPlyIncomeVo insPlyIncomeVo){
- try{
- Page<InsOrders> page = new Page<>(insPlyIncomeVo.getPageNum(), insPlyIncomeVo.getPageSize());
- PageInfo<List<InsPlyIncome>> pageHelper = null;
- PageHelper.startPage(insPlyIncomeVo.getPageNum(),insPlyIncomeVo.getPageSize());
- List<InsPlyIncome> list= this.baseMapper.selectByCondition(insPlyIncomeVo);
- pageHelper=new PageInfo(list);
- BasePageResult<InsPlyIncome> pageResult=new BasePageResult<InsPlyIncome>(insPlyIncomeVo.getPageNum(), insPlyIncomeVo.getPageSize(), pageHelper.getTotal(), pageHelper.getPages(), list);
- return HttpResult.ok(pageResult);
- }catch (Exception e){
- e.printStackTrace();
- return HttpResult.error("查询异常");
- }
- }
- @Override
- public void saveBalanceNew(InsOrders order, InsFeeOrderNew insFeeOrderNew, InsAreaCompany insAreaCompany) {
- if (ObjectUtils.isEmpty(order) || ObjectUtils.isEmpty(insFeeOrderNew) || ObjectUtils.isEmpty(insAreaCompany)) {
- return;
- }
- String agreeType = this.judgeAgreeType(insAreaCompany.getAgreementId());
- if (StringUtils.isNotEmpty(agreeType)) {
- // 判断协议类型 平台 保险
- if ("1".equals(agreeType)) {
- this.savePinTai(order,insFeeOrderNew,insAreaCompany); //手续费不分非车不非车 跟单也不分
- }else { // 保险 逻辑: 手续费生成一条 跟单费生成一条 非车手续费一条 非车跟单费一条
- if (((insFeeOrderNew.getJqSuperviseCostsPremiums() != null && insFeeOrderNew.getJqSuperviseCostsPremiums().compareTo(BigDecimal.ZERO) != 0)) || (insFeeOrderNew.getSySuperviseCostsPremiums() != null && insFeeOrderNew.getSySuperviseCostsPremiums().compareTo(BigDecimal.ZERO) != 0)) { //手续费
- this.saveInsuranceProcedures(order,insFeeOrderNew,insAreaCompany);
- }
- if(insFeeOrderNew.getJqOtherCostsPremiums()!=null && insFeeOrderNew.getJqOtherCostsPremiums().compareTo(BigDecimal.ZERO) != 0){ //跟单费
- this.saveOtherAmount(order,insFeeOrderNew,insAreaCompany);
- }
- if(insFeeOrderNew.getNoSuperviseCostsPremiums() !=null && insFeeOrderNew.getNoSuperviseCostsPremiums().compareTo(BigDecimal.ZERO) != 0) { // 非车手续费
- this.saveNoSupervise(order,insFeeOrderNew,insAreaCompany);
- }
- if(insFeeOrderNew.getNoOtherCostsPremiums() !=null && insFeeOrderNew.getNoOtherCostsPremiums().compareTo(BigDecimal.ZERO) != 0){ // 非车跟单费
- this.saveNoOtherAmount(order,insFeeOrderNew,insAreaCompany);
- }
- }
- }
- }
- private void saveNoOtherAmount(InsOrders order, InsFeeOrderNew insFeeOrderNew, InsAreaCompany insAreaCompany) {
- InsPlyIncome insPlyIncome = new InsPlyIncome();
- insPlyIncome.setOrderno(insFeeOrderNew.getInsOrderNo()); // 子订单号
- String noPolicyno = this.setNoPolicyno(insAreaCompany);
- if(StringUtils.isNotEmpty(noPolicyno)){
- insPlyIncome.setNoPolicyno(noPolicyno); // 非车保单号
- }
- insPlyIncome.setOtherFeevalue(insFeeOrderNew.getNoOtherCostsPremiums()); //非车跟单费
- insPlyIncome.setOtherFeerate(insFeeOrderNew.getNoOtherCostsProportion()); //非车跟单费用比例
- // insPlyIncome.setDeptId(insFeeOrderNew.getDeptId());
- this.saveRiskCode(order.getProductid(),insPlyIncome);
- insPlyIncome.setPayDate(insAreaCompany.getPayDate());
- insPlyIncome.setSignDate(insAreaCompany.getSigningTime());
- insPlyIncome.setCompanyId(insAreaCompany.getCompanyId());
- insPlyIncome.setAgreementId(insFeeOrderNew.getAgreementId());
- insPlyIncome.setLicenseno(order.getLicenseno());
- insPlyIncome.setTaxamount(insAreaCompany.getTaxamount());
- insPlyIncome.setNoTaxPremium(insFeeOrderNew.getNoNoTaxPremium());
- insPlyIncome.setCreateTime(LocalDate.now());
- insPlyIncome.setDocumentaryFeesStatus("0");
- insPlyIncome.setHandlingFeesStatus("0");
- insPlyIncome.setNoNoTaxPremium(insPlyIncome.getNoNoTaxPremium());
- insPlyIncome.setNoPremium(insPlyIncome.getNoPremium());
- insPlyIncome.setIsNotCar("1");
- insPlyIncome.setIsNotDocumentary("1");
- insPlyIncome.setJqStartDate(insAreaCompany.getJqStartDate());
- insPlyIncome.setJqEndDate(insAreaCompany.getJqEndDate());
- insPlyIncome.setSyStartDate(insAreaCompany.getSyStartDate());
- insPlyIncome.setSyEndDate(insAreaCompany.getSyEndDate());
- insPlyIncome.setAllFeeValue(insFeeOrderNew.getNoOtherCostsPremiums());
- insPlyIncome.setNoOtherCostsPremium(insFeeOrderNew.getNoOtherCostsPremiums());
- insPlyIncome.setNoOtherCostsProportion(insFeeOrderNew.getNoOtherCostsProportion());
- this.saveByCompanyId(insFeeOrderNew ,insAreaCompany.getCompanyId(),insPlyIncome);
- this.getDeptId(insPlyIncome);
- baseMapper.insert(insPlyIncome);
- }
- private void saveNoSupervise(InsOrders order, InsFeeOrderNew insFeeOrderNew, InsAreaCompany insAreaCompany) {
- InsPlyIncome insPlyIncome = new InsPlyIncome();
- insPlyIncome.setOrderno(insFeeOrderNew.getInsOrderNo()); // 子订单号
- insPlyIncome.setCommissionFeevalue(insFeeOrderNew.getNoSuperviseCostsPremiums());// 非车手续费
- insPlyIncome.setCommissionFeerate(insFeeOrderNew.getNoSuperviseCostsProportion());// 非车手续费比例
- String noPolicyno = this.setNoPolicyno(insAreaCompany);
- if(StringUtils.isNotEmpty(noPolicyno)){
- insPlyIncome.setNoPolicyno(noPolicyno); // 非车保单号
- }
- // insPlyIncome.setDeptId(insFeeOrderNew.getDeptId());
- this.saveRiskCode(order.getProductid(),insPlyIncome);
- insPlyIncome.setPayDate(insAreaCompany.getPayDate());
- insPlyIncome.setSignDate(insAreaCompany.getSigningTime());
- insPlyIncome.setCompanyId(insAreaCompany.getCompanyId());
- insPlyIncome.setAgreementId(insFeeOrderNew.getAgreementId());
- insPlyIncome.setLicenseno(order.getLicenseno());
- insPlyIncome.setTaxamount(insAreaCompany.getTaxamount());
- insPlyIncome.setCreateTime(LocalDate.now());
- insPlyIncome.setDocumentaryFeesStatus("0");
- insPlyIncome.setHandlingFeesStatus("0");
- insPlyIncome.setIsNotCar("1");
- insPlyIncome.setIsNotDocumentary("0");
- insPlyIncome.setAllFeeValue(insFeeOrderNew.getNoSuperviseCostsPremiums());
- insPlyIncome.setUserId(insFeeOrderNew.getUserId());
- insPlyIncome.setInsuredName(order.getInsuredname());
- insPlyIncome.setNoPremium(insFeeOrderNew.getNoPremium()); //非车保费
- insPlyIncome.setNoNoTaxPremium(insFeeOrderNew.getNoNoTaxPremium()); //非车不含税保费
- insPlyIncome.setJqStartDate(insAreaCompany.getJqStartDate());
- insPlyIncome.setJqEndDate(insAreaCompany.getJqEndDate());
- insPlyIncome.setSyStartDate(insAreaCompany.getSyStartDate());
- insPlyIncome.setSyEndDate(insAreaCompany.getSyEndDate());
- insPlyIncome.setNoSuperviseCostsPremiums(insFeeOrderNew.getNoSuperviseCostsPremiums());
- insPlyIncome.setNoSuperviseCostsProportion(insFeeOrderNew.getNoSuperviseCostsProportion());
- this.getDeptId(insPlyIncome);
- this.saveByCompanyId(insFeeOrderNew ,insAreaCompany.getCompanyId(),insPlyIncome);
- baseMapper.insert(insPlyIncome);
- }
- private void saveRiskCode(String productid,InsPlyIncome insPlyIncome) {
- if(ProductsType.PT_0330.getCode().equals(productid)){
- insPlyIncome.setRiskcode(ProductsType.PT_0330.getDesc());
- }
- if(ProductsType.PT_034001.getCode().equals(productid)){
- insPlyIncome.setRiskcode(ProductsType.PT_034001.getDesc());
- }
- if(ProductsType.PT_034002.getCode().equals(productid)){
- insPlyIncome.setRiskcode(ProductsType.PT_034002.getDesc());
- }
- if(ProductsType.PT_0330034002.getCode().equals(productid)){
- insPlyIncome.setRiskcode(ProductsType.PT_0330034002.getDesc());
- }
- if(ProductsType.PT_0330034001.getCode().equals(productid)){
- insPlyIncome.setRiskcode(ProductsType.PT_0330034001.getDesc());
- }
- }
- private void saveOtherAmount(InsOrders order, InsFeeOrderNew insFeeOrderNew, InsAreaCompany insAreaCompany) {
- BigDecimal otherAmount = this.calculateTotal(insFeeOrderNew.getJqOtherCostsPremiums(), insFeeOrderNew.getSyOtherCostsPremiums(),null);
- BigDecimal otherProportion = this.calculateTotal(insFeeOrderNew.getSyOtherCostsProportion(), insFeeOrderNew.getJqOtherCostsProportion(),null);
- BigDecimal allNoTaxPremium = this.calculateTotal(insFeeOrderNew.getJqNoTaxPremium(), insFeeOrderNew.getSyNoTaxPremium(), null); //交强不含税保费
- BigDecimal allPremium = this.calculateTotal(insFeeOrderNew.getJqPremium(), insFeeOrderNew.getSyPremium(), null);// 总保费
- InsPlyIncome insPlyIncome = new InsPlyIncome(insFeeOrderNew.getInsOrderNo(),insAreaCompany.getJqpolicyno(),insAreaCompany.getSypolicyno(),null,null,null,null,order.getProductid(),insAreaCompany.getPayDate(),insAreaCompany.getSigningTime(),insAreaCompany.getCompanyId(),null,insFeeOrderNew.getAgreementId(),order.getLicenseno(),insAreaCompany.getTaxamount(),
- allNoTaxPremium,null,otherProportion,null,otherAmount,otherAmount,null,null,LocalDate.now(),null,null,null,"0","0","0","1");
- this.saveRiskCode(order.getProductid(),insPlyIncome);
- insPlyIncome.setTaxPremium(allPremium);
- insPlyIncome.setJqPremium(insFeeOrderNew.getJqPremium());
- insPlyIncome.setSyPremium(insFeeOrderNew.getSyPremium());
- insPlyIncome.setJqNoTaxPremium(insFeeOrderNew.getJqNoTaxPremium());
- insPlyIncome.setSyNoTaxPremium(insFeeOrderNew.getSyNoTaxPremium());
- insPlyIncome.setJqOtherCostsProportion(insFeeOrderNew.getJqOtherCostsProportion()); //交强跟单费比例
- insPlyIncome.setSyOtherCostsProportion(insFeeOrderNew.getSyOtherCostsProportion()); //商业跟单费比例
- insPlyIncome.setSyOtherCostsPremium(insFeeOrderNew.getSyOtherCostsPremiums());
- insPlyIncome.setJqOtherCostsPremium(insFeeOrderNew.getJqOtherCostsPremiums());
- insPlyIncome.setJqStartDate(insAreaCompany.getJqStartDate());
- insPlyIncome.setJqEndDate(insAreaCompany.getJqEndDate());
- insPlyIncome.setSyStartDate(insAreaCompany.getSyStartDate());
- insPlyIncome.setSyEndDate(insAreaCompany.getSyEndDate());
- insPlyIncome.setUserId(insFeeOrderNew.getUserId());
- insPlyIncome.setInsuredName(order.getInsuredname());
- this.getDeptId(insPlyIncome);
- this.saveByCompanyId(insFeeOrderNew ,insAreaCompany.getCompanyId(),insPlyIncome);
- baseMapper.insert(insPlyIncome);
- }
- private void saveInsuranceProcedures(InsOrders order, InsFeeOrderNew insFeeOrderNew, InsAreaCompany insAreaCompany) {
- // 保险手续费
- BigDecimal handlingAmount = this.calculateTotal(insFeeOrderNew.getJqSuperviseCostsPremiums(), insFeeOrderNew.getSySuperviseCostsPremiums(),null);
- BigDecimal handlingProportion = this.calculateTotal(insFeeOrderNew.getJqSuperviseCostsProportion(), insFeeOrderNew.getSySuperviseCostsProportion(),null);
- BigDecimal allNoTaxPremium = this.calculateTotal(insFeeOrderNew.getJqNoTaxPremium(), insFeeOrderNew.getSyNoTaxPremium(), null);//不含税保费
- InsPlyIncome insPlyIncome = new InsPlyIncome(insFeeOrderNew.getInsOrderNo(),insAreaCompany.getJqpolicyno(),insAreaCompany.getSypolicyno(),null,null,null,null,order.getProductid(),insAreaCompany.getPayDate(),insAreaCompany.getSigningTime(),insAreaCompany.getCompanyId(),null,insFeeOrderNew.getAgreementId(),order.getLicenseno(),insAreaCompany.getTaxamount()
- ,allNoTaxPremium,handlingProportion,null,handlingAmount,null,handlingAmount,null,null,LocalDate.now(),null,null,null,"0","0","0","0");
- BigDecimal allTaxPremium = this.calculateTotal(insFeeOrderNew.getJqPremium(), insFeeOrderNew.getSyPremium(), null);
- insPlyIncome.setJqPremium(insFeeOrderNew.getJqPremium());
- insPlyIncome.setSyPremium(insFeeOrderNew.getSyPremium());
- insPlyIncome.setJqNoTaxPremium(insFeeOrderNew.getJqNoTaxPremium());
- insPlyIncome.setSyNoTaxPremium(insFeeOrderNew.getSyNoTaxPremium());
- insPlyIncome.setJqSuperviseCostsProportion(insFeeOrderNew.getJqSuperviseCostsProportion());
- insPlyIncome.setJqSuperviseCostsPremiums(insFeeOrderNew.getJqSuperviseCostsPremiums());
- insPlyIncome.setSySuperviseCostsProportion(insFeeOrderNew.getSySuperviseCostsProportion());
- insPlyIncome.setSySuperviseCostsPremiums(insFeeOrderNew.getSySuperviseCostsPremiums());
- this.saveRiskCode(order.getProductid(),insPlyIncome);
- insPlyIncome.setTaxPremium(allTaxPremium);
- insPlyIncome.setUserId(insFeeOrderNew.getUserId());
- insPlyIncome.setInsuredName(order.getInsuredname());
- insPlyIncome.setJqStartDate(insAreaCompany.getJqStartDate());
- insPlyIncome.setJqEndDate(insAreaCompany.getJqEndDate());
- insPlyIncome.setSyStartDate(insAreaCompany.getSyStartDate());
- insPlyIncome.setSyEndDate(insAreaCompany.getSyEndDate());
- this.saveByCompanyId(insFeeOrderNew ,insAreaCompany.getCompanyId(),insPlyIncome);
- this.getDeptId(insPlyIncome);
- baseMapper.insert(insPlyIncome);
- }
- private String setNoPolicyno(com.ydtech.modules.fnc.entity.InsAreaCompany insAreaCompany) {
- String crossInsurance = insAreaCompany.getCrossInsurance();
- if (StringUtils.isEmpty(crossInsurance)) {
- return null;
- }
- try {
- ObjectMapper objJson = new ObjectMapper();
- JsonNode jsonArryNode = objJson.readTree(crossInsurance);
- if (jsonArryNode.isArray() && jsonArryNode.size() > 0) {
- JsonNode firstNode = jsonArryNode.get(0);
- JsonNode policyNumberNode = firstNode.get("policyNumber");
- if (policyNumberNode != null) {
- return policyNumberNode.asText();
- } else {
- return firstNode.get("policy").asText();
- }
- }
- } catch (IOException e) {
- e.printStackTrace(); // 可以打印异常信息
- }
- return null;
- }
- private void savePinTai(InsOrders order, InsFeeOrderNew insFeeOrderNew, InsAreaCompany insAreaCompany) {
- BigDecimal handlingAmount = this.calculateTotal(insFeeOrderNew.getJqSuperviseCostsPremiums(), insFeeOrderNew.getSySuperviseCostsPremiums(),insFeeOrderNew.getNoSuperviseCostsPremiums()); //手续费
- BigDecimal handlingProportion = this.calculateTotal(insFeeOrderNew.getJqSuperviseCostsProportion(), insFeeOrderNew.getSySuperviseCostsProportion(),insFeeOrderNew.getNoSuperviseCostsProportion());//手续费比例
- BigDecimal otherAmount = this.calculateTotal(insFeeOrderNew.getJqOtherCostsPremiums(), insFeeOrderNew.getSyOtherCostsPremiums(),insFeeOrderNew.getNoOtherCostsPremiums());//跟单费
- BigDecimal otherProportion = this.calculateTotal(insFeeOrderNew.getSyOtherCostsProportion(), insFeeOrderNew.getJqOtherCostsProportion(),insFeeOrderNew.getNoOtherCostsProportion()); //跟单费比例
- // 不含税保费
- BigDecimal allNoTaxPremium = this.calculateTotal(insFeeOrderNew.getJqNoTaxPremium(), insFeeOrderNew.getSyNoTaxPremium(), insFeeOrderNew.getNoNoTaxPremium());
- BigDecimal allAmount = this.calculateTotal(otherAmount, handlingAmount, null);
- BigDecimal jqReceivableProportion = this.calculateTotal(insFeeOrderNew.getJqSuperviseCostsProportion(), insFeeOrderNew.getJqOtherCostsProportion(), null);// 交强应收 比例
- BigDecimal syReceivableProportion = this.calculateTotal(insFeeOrderNew.getSySuperviseCostsProportion(), insFeeOrderNew.getSyOtherCostsProportion(), null);//商业应收比例
- BigDecimal noReceivableProportion = this.calculateTotal(insFeeOrderNew.getNoSuperviseCostsProportion(), insFeeOrderNew.getNoOtherCostsProportion(), null);
- String noPolicyno = this.setNoPolicyno(insAreaCompany);
- InsPlyIncome insPlyIncome = new InsPlyIncome(insFeeOrderNew.getInsOrderNo(),insAreaCompany.getJqpolicyno(),insAreaCompany.getSypolicyno(),
- noPolicyno,null,null, null,order.getProductid(),insAreaCompany.getPayDate(),insAreaCompany.getSigningTime(),insAreaCompany.getCompanyId(),
- null,insFeeOrderNew.getAgreementId(),order.getLicenseno(),insAreaCompany.getTaxamount(),allNoTaxPremium,handlingProportion,
- otherProportion,handlingAmount,otherAmount,allAmount,null,null,LocalDate.now(),null,null,null,"0","0","0","0");
- insPlyIncome.setJqReceivableProportion(jqReceivableProportion);
- insPlyIncome.setSyReceivableProportion(syReceivableProportion);
- insPlyIncome.setNoReceivableProportion(noReceivableProportion);
- // 应收金额 = 商业手续费+商业跟单 + 交强手续费 +交强跟单费 + 非车手续费 + 非车跟单费 = allAmount
- insPlyIncome.setJqSuperviseCostsPremiums(insFeeOrderNew.getJqSuperviseCostsPremiums()); // 交强手续费
- insPlyIncome.setSySuperviseCostsPremiums(insFeeOrderNew.getSySuperviseCostsPremiums()); // 商业手续费
- insPlyIncome.setNoSuperviseCostsPremiums(insFeeOrderNew.getNoSuperviseCostsPremiums()); // 非车手续费
- insPlyIncome.setJqSuperviseCostsProportion(insFeeOrderNew.getJqSuperviseCostsProportion()); //交强手续费 比例
- insPlyIncome.setSySuperviseCostsProportion(insFeeOrderNew.getSySuperviseCostsProportion()); // 商业手续费 比例
- insPlyIncome.setNoSuperviseCostsProportion(insFeeOrderNew.getNoSuperviseCostsProportion());// 非车手续费 比例
- insPlyIncome.setJqOtherCostsProportion(insFeeOrderNew.getJqOtherCostsProportion()); //交强跟单费比例
- insPlyIncome.setSyOtherCostsProportion(insFeeOrderNew.getSyOtherCostsProportion()); //商业跟单费比例
- insPlyIncome.setNoOtherCostsProportion(insFeeOrderNew.getNoOtherCostsProportion()); //非车跟单费比例
- insPlyIncome.setJqPremium(insFeeOrderNew.getJqPremium());
- insPlyIncome.setSyPremium(insFeeOrderNew.getSyPremium());
- insPlyIncome.setNoPremium(insFeeOrderNew.getNoPremium());
- insPlyIncome.setJqNoTaxPremium(insFeeOrderNew.getJqNoTaxPremium());
- insPlyIncome.setSyNoTaxPremium(insFeeOrderNew.getSyNoTaxPremium());
- insPlyIncome.setNoNoTaxPremium(insFeeOrderNew.getNoNoTaxPremium());
- insPlyIncome.setUserId(insFeeOrderNew.getUserId());
- insPlyIncome.setJqStartDate(StringOperations.emptyStringToNull(insAreaCompany.getJqStartDate()));
- insPlyIncome.setJqEndDate(StringOperations.emptyStringToNull(insAreaCompany.getJqEndDate()));
- insPlyIncome.setSyStartDate(StringOperations.emptyStringToNull(insAreaCompany.getSyStartDate()));
- insPlyIncome.setSyEndDate(StringOperations.emptyStringToNull(insAreaCompany.getSyEndDate()));
- this.getDeptId(insPlyIncome);
- this.saveRiskCode(order.getProductid(),insPlyIncome);
- insPlyIncome.setInsuredName(order.getInsuredname());
- this.saveByCompanyId(insFeeOrderNew ,insAreaCompany.getCompanyId(),insPlyIncome);
- baseMapper.insert(insPlyIncome);
- }
- private void getDeptId(InsPlyIncome insPlyIncome) {
- PtlAgreement ptlAgreement = ptlAgreementService.getById(insPlyIncome.getAgreementId());
- String deptId = ptlAgreement.getDeptId();
- insPlyIncome.setDeptId(deptId);
- }
- private void saveByCompanyId(InsFeeOrderNew insFeeOrderNew,String companyId, InsPlyIncome insPlyIncome) {
- PtlAgreement ptlAgreementQueryVo = this.ptlAgreementService.getByAgreementIdNew(insFeeOrderNew.getAgreementId());
- if(ObjectUtils.isNotEmpty(ptlAgreementQueryVo)){
- if(StringUtils.isNotEmpty(ptlAgreementQueryVo.getPartnerCompaniesId())){
- // 合作公司id
- String partnerCompaniesId = ptlAgreementQueryVo.getPartnerCompaniesId();
- insPlyIncome.setPartnerCompaniesId(partnerCompaniesId);
- EsmInsCompany esmInsCompany = EsmInsCompanyService.getById(partnerCompaniesId);
- String name = esmInsCompany.getNamesimple(); //合作名称
- insPlyIncome.setPartnerCompaniesName(name);
- insPlyIncome.setPartnerCompaniesId(ptlAgreementQueryVo.getPartnerCompaniesId());
- }
- if(StringUtils.isNotEmpty(ptlAgreementQueryVo.getInsuranceCompanyId())){
- String insuranceCompanyId = ptlAgreementQueryVo.getInsuranceCompanyId();
- EsmInsCompany esmInsCompany = EsmInsCompanyService.getById(insuranceCompanyId);
- String name = esmInsCompany.getNamesimple(); //保险公司名称 简称
- insPlyIncome.setCompanyName(name);
- }
- }
- }
- private BigDecimal calculateTotal(BigDecimal value1, BigDecimal value2, BigDecimal value3) {
- BigDecimal total = BigDecimal.ZERO;
- if (value1 != null) {
- total = total.add(value1);
- }
- if (value2 != null) {
- total = total.add(value2);
- }
- if (value3 != null) {
- total = total.add(value3);
- }
- return total;
- }
- private String judgeAgreeType(Long agreementId) {
- if (agreementId == null) {
- return null;
- }
- HttpResult<PtlAgreementQueryVo> byAgreementId = ptlAgreementService.getByAgreementId(agreementId.toString());
- if (byAgreementId != null && ObjectUtils.isNotEmpty(byAgreementId.getData())) {
- PtlAgreement agreement = byAgreementId.getData().getAgreement();
- String agreementType = agreement.getAgreementType();
- if (StringUtils.isNotEmpty(agreementType)) {
- return agreementType;
- }
- }
- return null;
- }
- public HttpResult<BasePageResult<InsPlyIncome>> queryNew(InsPlyIncomeVo insPlyIncomeVo){
- try{
- HashMap<String, Object> params = new HashMap<>();
- PageInfo<List<InsPlyIncome>> pageHelper = null;
- PageHelper.startPage(insPlyIncomeVo.getPageNum(),insPlyIncomeVo.getPageSize());
- params.put("pageNum",insPlyIncomeVo.getPageNum());
- params.put("pageSize",insPlyIncomeVo.getPageSize());
- params =this.saveParams(insPlyIncomeVo,params);
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getIds())){
- params.put("ids",insPlyIncomeVo.getIds().split(","));
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getId())) {
- SettlementDocumentaryFeesEntity settlementDocumentaryFeesEntity = settlementDocumentaryFeesService.getById(insPlyIncomeVo.getId());
- // 通过任务id查询 明细
- String taskId = settlementDocumentaryFeesEntity.getTaskId();
- List<String> incomeIds = incomeTaskRelationshipService.getByTaskId(taskId);
- if (!CollectionUtils.isEmpty(incomeIds)) {
- params.put("incomeIds", incomeIds);
- params.remove("handlingFeesStatus");
- }
- }
- List<InsPlyIncome> list = this.baseMapper.queryNew(params);
- pageHelper=new PageInfo(list);
- BasePageResult<InsPlyIncome> pageResult=new BasePageResult<InsPlyIncome>(insPlyIncomeVo.getPageNum(), insPlyIncomeVo.getPageSize(), pageHelper.getTotal(), pageHelper.getPages(), list);
- return HttpResult.ok(pageResult);
- }catch (Exception e){
- e.printStackTrace();
- return HttpResult.error("查询异常");
- }
- }
- @Override
- public HashMap<String,Object> totalAmount(List<String> selectIds) {
- HashMap<String, Object> params = new HashMap<>();
- params.put("selectIds",selectIds);
- HashMap<String,Object> resultMap =baseMapper.totalAmount(params);
- return resultMap;
- }
- @Override
- @Transactional
- public HttpResult<Object> batchPinBalance(InsPlyIncomeVo insPlyIncomeVo) {
- if(!CollectionUtils.isEmpty(insPlyIncomeVo.getSelectIds())){
- List<String> selectIds = insPlyIncomeVo.getSelectIds();
- for(String id: selectIds){
- InsPlyIncome insPlyIncome = new InsPlyIncome();
- insPlyIncome.setHandlingFeesStatus("1");
- insPlyIncome.setSettlementTime(LocalDate.now());
- insPlyIncome.setId(id);
- baseMapper.updateById(insPlyIncome);
- }
- }
- SettlementDocumentaryLogEntity settlementDocumentaryLogEntity = new SettlementDocumentaryLogEntity();
- settlementDocumentaryLogEntity.setIds(insPlyIncomeVo.getIds());
- // settlementDocumentaryLogEntity.setCompanyId(insPlyIncomeVo.getCompanyId());
- settlementDocumentaryLogEntity.setAmount(insPlyIncomeVo.getOtherFeevalue()); //跟单费金额
- settlementDocumentaryLogEntity.setHandingAmount(insPlyIncomeVo.getCommissionFeevalue()); //手续费金额
- settlementDocumentaryLogEntity.setCreateTime(new Date());
- settlementDocumentaryLogService.save(settlementDocumentaryLogEntity);
- return HttpResult.ok();
- }
- @Override
- public List<InsPlyIncome> totalPinAmount(InsPlyIncomeVo insPlyIncomeVo) {
- HashMap<String, Object> params = new HashMap<>();
- params = this.saveParams(insPlyIncomeVo,params);
- List<InsPlyIncome> result=baseMapper.totalPinAmount(params);
- return result;
- }
- private HashMap<String, Object> saveParams(InsPlyIncomeVo insPlyIncomeVo, HashMap<String, Object> params) {
- if(ObjectUtils.isNotEmpty(insPlyIncomeVo.getStartDate())){
- params.put("startDate",insPlyIncomeVo.getStartDate().toString());
- }
- if(ObjectUtils.isNotEmpty(insPlyIncomeVo.getEndDate())){
- params.put("endDate",insPlyIncomeVo.getEndDate().toString());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getOrderno())){
- params.put("orderno",insPlyIncomeVo.getOrderno());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotDocumentary())){
- params.put("isOther",insPlyIncomeVo.getIsNotDocumentary());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotCar())){
- params.put("isNotCar",insPlyIncomeVo.getIsNotCar());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getAgreementType())){
- params.put("agreementType",insPlyIncomeVo.getAgreementType());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getLicenseno())){
- params.put("licenseno", insPlyIncomeVo.getLicenseno());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getUserId())){
- params.put("userId",insPlyIncomeVo.getUserId());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getCompanyId())){
- params.put("companyId",insPlyIncomeVo.getCompanyId());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getRiskcode())){
- params.put("riskcode",insPlyIncomeVo.getRiskcode());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getPolicyno())){
- params.put("policyno",insPlyIncomeVo.getPolicyno());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getSyPolicyno())){
- params.put("syPolicyno",insPlyIncomeVo.getSyPolicyno());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getNoPolicyno())){
- params.put("noPolicyno",insPlyIncomeVo.getNoPolicyno());
- }
- if(insPlyIncomeVo.getCreateTime()!=null){
- params.put("createTime",insPlyIncomeVo.getCreateTime().toString());
- }
- if(insPlyIncomeVo.getSettlementTime()!=null){
- params.put("settlementTime",insPlyIncomeVo.getSettlementTime().toString());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getHandlingFeesStatus())){
- params.put("handlingFeesStatus",insPlyIncomeVo.getHandlingFeesStatus());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getPartnerCompaniesId())){
- params.put("partnerCompaniesId",insPlyIncomeVo.getPartnerCompaniesId());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getYear())){
- params.put("year",insPlyIncomeVo.getYear());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getMonth())){
- params.put("month",insPlyIncomeVo.getMonth());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getDay())){
- params.put("day",insPlyIncomeVo.getDay());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getSignDateEnd())){
- params.put("signDateEnd",insPlyIncomeVo.getSignDateEnd());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getSignDateStart())){
- params.put("signDateStart",insPlyIncomeVo.getSignDateStart());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getCompanyName())){
- params.put("companyName",insPlyIncomeVo.getCompanyName());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getInsuredName())){
- params.put("insuredName",insPlyIncomeVo.getInsuredName());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getPartnerCompaniesName())){
- params.put("partnerCompaniesName",insPlyIncomeVo.getPartnerCompaniesName());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getDockingPerson())){
- params.put("dockingPerson",insPlyIncomeVo.getDockingPerson());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getYeartsStart()) && StringUtils.isNotEmpty(insPlyIncomeVo.getYeartsEnd())){
- params.put("yeartsStart",insPlyIncomeVo.getYeartsStart());
- params.put("yeartsEnd",insPlyIncomeVo.getYeartsEnd());
- }
- if(insPlyIncomeVo.getJqStartDate() !=null){
- params.put("jqStartDate",insPlyIncomeVo.getJqStartDate());
- }
- if(insPlyIncomeVo.getJqStartDate() !=null){
- params.put("jqEndDate",insPlyIncomeVo.getJqEndDate());
- }
- if(insPlyIncomeVo.getSyStartDate() !=null){
- params.put("syStartDate",insPlyIncomeVo.getSyStartDate());
- }
- if(insPlyIncomeVo.getSyEndDate() !=null){
- params.put("syEndDate",insPlyIncomeVo.getSyEndDate());
- }
- if( StringUtils.isNotEmpty(insPlyIncomeVo.getProvinceId())){
- params.put("provinceId",insPlyIncomeVo.getProvinceId());
- }
- if( StringUtils.isNotEmpty(insPlyIncomeVo.getCityId())){
- params.put("cityId",insPlyIncomeVo.getCityId());
- }
- if( StringUtils.isNotEmpty(insPlyIncomeVo.getCountyId())){
- params.put("countyId",insPlyIncomeVo.getCountyId());
- }
- if( StringUtils.isNotEmpty(insPlyIncomeVo.getDeptId())){
- params.put("deptId",insPlyIncomeVo.getDeptId());
- }
- if( StringUtils.isNotEmpty(insPlyIncomeVo.getAllPartnerCompaniesId())){
- params.put("allPartnerCompaniesId",insPlyIncomeVo.getAllPartnerCompaniesId().substring(0,5));
- }
- if( StringUtils.isNotEmpty(insPlyIncomeVo.getProvincePartnerCompaniesId())){
- params.put("provincePartnerCompaniesId",insPlyIncomeVo.getProvincePartnerCompaniesId());
- }
- if(!CollectionUtils.isEmpty(insPlyIncomeVo.getSelectIds())){
- params.put("selectIds",insPlyIncomeVo.getSelectIds());
- }
- if(!CollectionUtils.isEmpty(insPlyIncomeVo.getPartnerCompaniesIdList())){
- params.put("partnerCompaniesIdList",insPlyIncomeVo.getPartnerCompaniesIdList());
- }
- return params;
- }
- @Override
- public HttpResult<BasePageResult<InsPlyIncome>> nonSettlementQuery(InsPlyIncomeVo insPlyIncomeVo) {
- try{
- HashMap<String, Object> params = new HashMap<>();
- PageInfo<List<InsPlyIncome>> pageHelper = null;
- PageHelper.startPage(insPlyIncomeVo.getPageNum(),insPlyIncomeVo.getPageSize());
- params.put("pageNum",insPlyIncomeVo.getPageNum());
- params.put("pageSize",insPlyIncomeVo.getPageSize());
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotCar())){
- params.put("isNotCar",insPlyIncomeVo.getIsNotCar());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotDocumentary())){
- params.put("isOther",insPlyIncomeVo.getIsNotDocumentary());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getYear())){
- params.put("year",insPlyIncomeVo.getYear());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getMonth())){
- params.put("month",insPlyIncomeVo.getMonth());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getDocumentaryFeesStatus())){
- params.put("documentaryFeesStatus",insPlyIncomeVo.getDocumentaryFeesStatus());
- }
- List<InsPlyIncome> list= this.baseMapper.NonSettlementQuery(params);
- pageHelper=new PageInfo(list);
- BasePageResult<InsPlyIncome> pageResult=new BasePageResult<InsPlyIncome>(insPlyIncomeVo.getPageNum(), insPlyIncomeVo.getPageSize(), pageHelper.getTotal(), pageHelper.getPages(), list);
- return HttpResult.ok(pageResult);
- }catch (Exception e){
- e.printStackTrace();
- return HttpResult.error("查询异常");
- }
- }
- @Override
- public HttpResult<List<InsPlyIncome>> nonSettldetail(InsPlyIncomeVo insPlyIncomeVo) {
- try {
- String ids = insPlyIncomeVo.getIds();
- ArrayList<InsPlyIncome> resultList = new ArrayList<>();
- if (ObjectUtils.isNotEmpty(ids)) {
- String[] split = ids.split(",");
- for (int i =0; i <split.length ; i++) {
- String id = split[i];
- resultList.add(this.baseMapper.getById(id));
- }
- }
- return HttpResult.ok(resultList);
- } catch (Exception e) {
- e.printStackTrace();
- return HttpResult.error("查询异常");
- }
- }
- /**
- *
- * @param multipartFile
- * @return totalAmount 总金额
- * totalHandingAmount 总手续费金额
- * totalOtherAmount 总跟单费金额
- * resultHashMap 返回 ids 已经上面的金额
- * resultNoSelect 未匹配的车牌号
- */
- @Override
- public HashMap<String, Object> importData(MultipartFile multipartFile) {
- BigDecimal totalAmount=BigDecimal.ZERO;
- BigDecimal totalHandingAmount=BigDecimal.ZERO;
- BigDecimal totalOtherAmount=BigDecimal.ZERO;
- HashMap<String, Object> params = new HashMap<>();
- HashMap<String, Object> resultHashMap = new HashMap<>();
- ArrayList<HashMap<String,Object>> resultNoSelect = new ArrayList<>();
- try {
- List<InsPlyIncomeExcelDto> dtoList = ExcelEasypoiUtils.importExcel(multipartFile, InsPlyIncomeExcelDto.class, 0, 1, 1);
- for (InsPlyIncomeExcelDto excelItem : dtoList) {
- params.clear();
- if(StringUtils.isNotEmpty(excelItem.getLicenseno())){
- params.put("licenseno",excelItem.getLicenseno());//车牌号
- }
- if(StringUtils.isNotEmpty(excelItem.getPolicyno())){
- params.put("policyno",excelItem.getPolicyno()); //交强保单号
- }
- if(StringUtils.isNotEmpty(excelItem.getSyPolicyno())){
- params.put("syPolicyno", excelItem.getSyPolicyno());//商业保单号
- }
- if(StringUtils.isNotEmpty(excelItem.getNoPolicyno())){
- params.put("noPolicyno",excelItem.getNoPolicyno()); //非车保单号
- }
- InsPlyIncome insPlyIncome=baseMapper.findByLicenseno(params);
- if(ObjectUtils.isNotEmpty(insPlyIncome)){
- if(insPlyIncome.getAllFeeValue()!=null && insPlyIncome.getAllFeeValue().compareTo(BigDecimal.ZERO)!=0){
- totalAmount = totalAmount.add(insPlyIncome.getAllFeeValue()); //总金额
- }
- if(insPlyIncome.getCommissionFeevalue()!=null && insPlyIncome.getCommissionFeevalue().compareTo(BigDecimal.ZERO)!=0){
- totalHandingAmount=totalHandingAmount.add(insPlyIncome.getCommissionFeevalue()); //总手续费
- }
- if(insPlyIncome.getOtherFeevalue()!=null && insPlyIncome.getOtherFeevalue().compareTo(BigDecimal.ZERO)!=0){
- totalOtherAmount=totalOtherAmount.add(insPlyIncome.getOtherFeevalue()); //总跟单费
- }
- }else {
- resultNoSelect.add(params); // 添加未匹配的车牌号
- }
- }
- resultHashMap.put("totalAmount",totalAmount);
- resultHashMap.put("totalHandingAmount",totalHandingAmount);
- resultHashMap.put("totalOtherAmount",totalOtherAmount);
- resultHashMap.put("resultList",resultNoSelect);
- return resultHashMap;
- } catch (IOException e) {
- throw new SystemException("导入失败!");
- }
- }
- /**
- *
- * @param multipartFile
- * @return resultList 包含总金额 还有 未匹配表中的数据
- */
- @Override
- public HashMap<String, Object> bxImportData(MultipartFile multipartFile,String isNotCar) {
- BigDecimal totalAmount=BigDecimal.ZERO;
- HashMap<String, Object> params = new HashMap<>();
- ArrayList<HashMap<String, Object>> resultList = new ArrayList<>();
- HashMap<String, Object> resultMap = new HashMap<>();
- StringBuffer strBuilder = new StringBuffer();
- boolean open=true;
- String ids="";
- try {
- List<InsBxPlyIncomeExcelDto> dtoList = ExcelEasypoiUtils.importExcel(multipartFile, InsBxPlyIncomeExcelDto.class, 0, 1, 1);
- Integer i=0;
- if(!CollectionUtils.isEmpty(dtoList)){
- for (InsBxPlyIncomeExcelDto excelItem : dtoList) {
- String reason ="";
- i=i+1;
- params.clear();
- if(StringUtils.isNotEmpty(excelItem.getLicenseno())){
- String licenseno = excelItem.getLicenseno();//车牌号
- params.put("licenseno",licenseno);
- InsPlyIncome byBxLicenseno = baseMapper.findByBxLicenseno(params);
- if(ObjectUtils.isEmpty(byBxLicenseno)){
- reason="该数据车牌号有问题";
- }
- }
- if(StringUtils.isNotEmpty(excelItem.getPolicyno())){
- String policyno = excelItem.getPolicyno(); //交强保单号
- params.put("policyno",policyno);
- InsPlyIncome byBxLicenseno = baseMapper.findByBxLicenseno(params);
- if(ObjectUtils.isEmpty(byBxLicenseno)){
- reason="该数据交强保单号有问题";
- }
- }
- if(StringUtils.isNotEmpty(excelItem.getSyPolicyno())){
- String syPolicyno = excelItem.getSyPolicyno(); //商业保单号
- params.put("syPolicyno",syPolicyno);
- InsPlyIncome byBxLicenseno = baseMapper.findByBxLicenseno(params);
- if(ObjectUtils.isEmpty(byBxLicenseno)){
- reason="该数据商业保单号有问题";
- }
- }
- if(excelItem.getJqSuperviseCostsPremiums() !=null && excelItem.getJqSuperviseCostsPremiums().compareTo(BigDecimal.ZERO)!=0){
- params.put("jqSuperviseCostsPremiums",excelItem.getJqSuperviseCostsPremiums());
- InsPlyIncome byBxLicenseno = baseMapper.findByBxLicenseno(params);
- if(ObjectUtils.isEmpty(byBxLicenseno)){
- reason="该数据交强手续费金额有问题";
- }
- }
- if(excelItem.getJqSuperviseCostsProportion() !=null && excelItem.getJqSuperviseCostsProportion().compareTo(BigDecimal.ZERO)!=0){
- params.put("jqSuperviseCostsProportion",excelItem.getJqSuperviseCostsProportion());
- InsPlyIncome byBxLicenseno = baseMapper.findByBxLicenseno(params);
- if(ObjectUtils.isEmpty(byBxLicenseno)){
- reason="该数据交强手续费比例有问题";
- }
- }
- if(excelItem.getSySuperviseCostsProportion() !=null && excelItem.getSySuperviseCostsProportion().compareTo(BigDecimal.ZERO)!=0){
- params.put("sySuperviseCostsProportion",excelItem.getSySuperviseCostsProportion());
- InsPlyIncome byBxLicenseno = baseMapper.findByBxLicenseno(params);
- if(ObjectUtils.isEmpty(byBxLicenseno)){
- reason="该数据商业手续费比例有问题";
- }
- }
- if(excelItem.getSySuperviseCostsPremiums() !=null && excelItem.getSySuperviseCostsPremiums().compareTo(BigDecimal.ZERO)!=0){
- params.put("sySuperviseCostsPremiums",excelItem.getSySuperviseCostsPremiums());
- InsPlyIncome byBxLicenseno = baseMapper.findByBxLicenseno(params);
- if(ObjectUtils.isEmpty(byBxLicenseno)){
- reason="该数据商业手续费金额有问题";
- }
- }
- if(excelItem.getJqPremium() !=null && excelItem.getJqPremium().compareTo(BigDecimal.ZERO)!=0){
- params.put("jqPremium",excelItem.getJqPremium());
- InsPlyIncome byBxLicenseno = baseMapper.findByBxLicenseno(params);
- if(ObjectUtils.isEmpty(byBxLicenseno)){
- reason="该数据交强保费有问题";
- }
- }
- if(excelItem.getSyPremium() !=null && excelItem.getSyPremium().compareTo(BigDecimal.ZERO)!=0){
- params.put("syPremium",excelItem.getSyPremium());
- InsPlyIncome byBxLicenseno = baseMapper.findByBxLicenseno(params);
- if(ObjectUtils.isEmpty(byBxLicenseno)){
- reason="该数据商业保费有问题";
- }
- }
- // 只查手续费
- params.put("isOther","0");
- params.put("isNotCar",isNotCar);
- InsPlyIncome insPlyIncome = baseMapper.findByBxLicenseno(params);
- if(ObjectUtils.isNotEmpty(insPlyIncome) && open){
- open=false;
- resultMap.put("companyId",insPlyIncome.getCompanyId()); // 保险公司id
- resultMap.put("partnerCompaniesId",insPlyIncome.getPartnerCompaniesId()); //合作公司id
- resultMap.put("agreementId",insPlyIncome.getAgreementId()); //协议id
- }
- if(ObjectUtils.isNotEmpty(insPlyIncome)){ // 比配上汇总金额 未匹配则返回到数据当中
- strBuilder.append(insPlyIncome.getId()).append(",");
- if( insPlyIncome.getCommissionFeevalue()!=null && insPlyIncome.getCommissionFeevalue().compareTo(BigDecimal.ZERO)!=0){
- totalAmount = totalAmount.add(insPlyIncome.getCommissionFeevalue()); //添加总手续费
- }
- }else {
- HashMap<String, Object> noMatching = new HashMap<>();
- if(StringUtils.isNotEmpty(excelItem.getLicenseno())){
- noMatching.put("licenseno",excelItem.getLicenseno());
- }
- if(StringUtils.isNotEmpty(excelItem.getPolicyno())){
- noMatching.put("policyno",excelItem.getPolicyno());
- }
- if(StringUtils.isNotEmpty(excelItem.getSyPolicyno())){
- noMatching.put("syPolicyno",excelItem.getSyPolicyno());
- }
- resultList.add(noMatching);
- }
- resultMap.put("reason",reason);
- }
- }
- if(strBuilder.length() >0){
- ids = strBuilder.deleteCharAt(strBuilder.length() - 1).toString();
- }
- resultMap.put("ids",ids);
- resultMap.put("totalAmount",totalAmount);
- resultMap.put("resultList",resultList);
- return resultMap;
- } catch (IOException e) {
- throw new SystemException("导入失败!");
- }
- }
- @Override
- public HashMap<String, Object> bxImportNoData(MultipartFile multipartFile,String isNotCar) {
- BigDecimal totalAmount=BigDecimal.ZERO;
- HashMap<String, Object> params = new HashMap<>();
- HashMap<String, Object> resultMap = new HashMap<>();
- ArrayList<HashMap<String, Object>> resultList = new ArrayList<>();
- StringBuffer strBuilder = new StringBuffer();
- String ids="";
- try {
- Integer i=0;
- List<InsBxNoPlyIncomeExcelDto> dtoList = ExcelEasypoiUtils.importExcel(multipartFile, InsBxNoPlyIncomeExcelDto.class, 0, 1, 1);
- if(!CollectionUtils.isEmpty(dtoList)){
- for (InsBxNoPlyIncomeExcelDto excelItem : dtoList) {
- String reason ="";
- i=i+1;
- params.clear();
- if(StringUtils.isNotEmpty(excelItem.getLicenseno())){
- String licenseno = excelItem.getLicenseno();//车牌号
- params.put("licenseno",licenseno);
- InsPlyIncome byBxLicenseno = baseMapper.findByBxLicenseno(params);
- if(ObjectUtils.isEmpty(byBxLicenseno)){
- reason="该数据车牌号有问题";
- }
- }
- if(StringUtils.isNotEmpty(excelItem.getNoPolicyno())){
- String policyno = excelItem.getNoPolicyno(); //非车保单号
- params.put("NoPolicyno",policyno);
- InsPlyIncome byBxLicenseno = baseMapper.findByBxLicenseno(params);
- if(ObjectUtils.isEmpty(byBxLicenseno)){
- reason="该数据非车保单号有问题";
- }
- }
- if(excelItem.getNoPremium() !=null && excelItem.getNoPremium().compareTo(BigDecimal.ZERO)!=0){
- params.put("noPolicyno",excelItem.getNoPremium());
- InsPlyIncome byBxLicenseno = baseMapper.findByBxLicenseno(params);
- if(ObjectUtils.isEmpty(byBxLicenseno)){
- reason="该数据非车保费有问题";
- }
- }
- if( excelItem.getNoSuperviseCostsPremiums() !=null && excelItem.getNoSuperviseCostsPremiums().compareTo(BigDecimal.ZERO)!=0){
- params.put("noSuperviseCostsPremiums",excelItem.getNoSuperviseCostsPremiums());
- InsPlyIncome byBxLicenseno = baseMapper.findByBxLicenseno(params);
- if(ObjectUtils.isEmpty(byBxLicenseno)){
- reason="该数据非车手续费有问题";
- }
- }
- if(excelItem.getNoSuperviseCostsProportion() != null && excelItem.getNoSuperviseCostsProportion().compareTo(BigDecimal.ZERO)!=0){
- params.put("noSuperviseCostsProportion",excelItem.getNoSuperviseCostsProportion());
- InsPlyIncome byBxLicenseno = baseMapper.findByBxLicenseno(params);
- if(ObjectUtils.isEmpty(byBxLicenseno)){
- reason="该数据非车手续费比例有问题";
- }
- }
- // 只查手续费
- params.put("isOther","0");
- params.put("isNotCar",isNotCar);
- InsPlyIncome insPlyIncome = baseMapper.findByBxLicenseno(params);
- if(i==dtoList.size() && ObjectUtils.isNotEmpty(insPlyIncome)){
- resultMap.put("companyId",insPlyIncome.getCompanyId()); // 保险公司id
- resultMap.put("partnerCompaniesId",insPlyIncome.getPartnerCompaniesId()); //合作公司id
- resultMap.put("agreementId",insPlyIncome.getAgreementId()); //协议id
- }
- if(ObjectUtils.isNotEmpty(insPlyIncome)){ // 比配上汇总金额 未匹配则返回到数据当中
- strBuilder.append(insPlyIncome.getId()).append(",");
- if( insPlyIncome.getCommissionFeevalue()!=null && insPlyIncome.getCommissionFeevalue().compareTo(BigDecimal.ZERO)!=0){
- totalAmount = totalAmount.add(insPlyIncome.getCommissionFeevalue()); //添加总手续费
- }
- }else {
- HashMap<String, Object> noMatching = new HashMap<>();
- if(StringUtils.isNotEmpty(excelItem.getLicenseno())){
- noMatching.put("licenseno",excelItem.getLicenseno());
- }
- if(StringUtils.isNotEmpty(excelItem.getNoPolicyno())){
- noMatching.put("NoPolicyno",excelItem.getNoPolicyno());
- }
- resultList.add(noMatching);
- }
- resultMap.put("reason",reason);
- }
- if(strBuilder.length() >0){
- ids = strBuilder.deleteCharAt(strBuilder.length() - 1).toString();
- }
- resultMap.put("ids",ids);
- resultMap.put("totalAmount",totalAmount);
- resultMap.put("resultList",resultList);
- }
- return resultMap;
- } catch (IOException e) {
- throw new SystemException("导入失败!");
- }
- }
- @Override
- public HttpResult bxOtherDetailsExcel(InsPlyIncomeVo insPlyIncomeVo, HttpServletRequest request, HttpServletResponse response) {
- HashMap<String, Object> params = new HashMap<>();
- params =this.saveParams(insPlyIncomeVo,params);
- List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params);
- String filePathName ="";
- List<BxOtherDetailsNorExcel> resultNoList=new ArrayList<>();
- List<BxOtherDetailsExcel> resultList=new ArrayList<>();
- //判断是否是非车 1 是非车
- if("1".equals(insPlyIncomeVo.getIsNotCar())){
- filePathName="非车跟单明细导出";
- ExportParams exportParams = new ExportParams("非车跟单明细", null, ExcelType.HSSF);
- exportParams.setStyle(ExcelStyleUtil.class);
- for (InsPlyIncome item :insPlyIncomes){
- BxOtherDetailsNorExcel bxOtherDetailsNorExcel = new BxOtherDetailsNorExcel();
- LocalDateTime signDate = item.getSignDate();
- BeanUtils.copyProperties(item, bxOtherDetailsNorExcel);
- bxOtherDetailsNorExcel.setSigndate(signDate);
- resultNoList.add(bxOtherDetailsNorExcel);
- }
- }else{
- filePathName="车险跟单明细导出";
- ExportParams exportParams = new ExportParams("车险跟单明细", null, ExcelType.HSSF);
- exportParams.setStyle(ExcelStyleUtil.class);
- for (InsPlyIncome item :insPlyIncomes){
- BxOtherDetailsExcel bxOtherDetailsExcel = new BxOtherDetailsExcel();
- LocalDateTime signDate = item.getSignDate();
- BeanUtils.copyProperties(item, bxOtherDetailsExcel);
- bxOtherDetailsExcel.setSigndate(signDate);
- resultList.add(bxOtherDetailsExcel);
- }
- }
- String uploadPath = this.uploadPath + "/excel/";
- Path path = Paths.get(uploadPath);
- if (!Files.exists(path)) {
- try {
- Files.createDirectories(path);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- String fileName="";
- if("1".equals(insPlyIncomeVo.getIsNotCar())){
- fileName = EasyExcelUtils.downExcel(uploadPath, filePathName, BxOtherDetailsNorExcel.class, resultNoList);
- }else{
- fileName = EasyExcelUtils.downExcel(uploadPath, filePathName, BxOtherDetailsExcel.class, resultList);
- }
- return HttpResult.ok("",uploadUrl + "excel/" + fileName);
- }
- /**
- *
- * @param insPlyIncomeVo 传参字段
- * ids 通过ids中的id进行开票分组
- *
- * @return
- */
- @Override
- public HttpResult<List<HashMap<String,Object>>> invicdetail(InsPlyIncomeVo insPlyIncomeVo) {
- HashMap<String, Object> params = new HashMap<>();
- params =this.saveParams(insPlyIncomeVo,params);
- if (StringUtils.isEmpty(insPlyIncomeVo.getIsSettlement())){
- params.put("isSettlement","1");
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getSettlementStatus())){
- params.put("settlementStatus",insPlyIncomeVo.getSettlementStatus());
- }
- List<HashMap<String, Object>> resultList = settlementDocumentaryFeesService.getOtherSettldetail(params);
- if (resultList.size() > 0) {
- return HttpResult.ok(resultList);
- }
- return HttpResult.ok();
- }
- /***
- *
- * @param insPlyIncomeVo
- * @param request
- * @param response
- * @return 保险非车跟单明细导出
- */
- @Override
- public HttpResult bxNoOtherDetailsExcel(InsPlyIncomeVo insPlyIncomeVo, HttpServletRequest request, HttpServletResponse response) {
- HashMap<String, Object> params = new HashMap<>();
- params =this.saveParams(insPlyIncomeVo,params);
- List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params);
- ExportParams exportParams = new ExportParams("保险非车跟单明细导出", null, ExcelType.HSSF);
- exportParams.setStyle(ExcelStyleUtil.class);
- List<BxNoOtherDetailsExcel> resultList = new ArrayList<>();
- for (InsPlyIncome item :insPlyIncomes){
- BxNoOtherDetailsExcel bxNoOtherDetailsExcel = new BxNoOtherDetailsExcel();
- BeanUtils.copyProperties(item, bxNoOtherDetailsExcel);
- resultList.add(bxNoOtherDetailsExcel);
- }
- String uploadPath = this.uploadPath + "/excel/";
- Path path = Paths.get(uploadPath);
- if (!Files.exists(path)) {
- try {
- Files.createDirectories(path);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- String fileName = EasyExcelUtils.downExcel(uploadPath, "保险非车跟单明细导出", BxNoOtherDetailsExcel.class, resultList);
- return HttpResult.ok("",uploadUrl + "excel/" + fileName);
- }
- /**
- *
- * @param insPlyIncomeVo 开票ids
- * @return 返回开票号 开票金额 开票时间
- */
- @Override
- public HttpResult<List<HashMap<String, Object>>> otherSettldetail(InsPlyIncomeVo insPlyIncomeVo) {
- HashMap<String, Object> params = new HashMap<>();
- params =this.saveParams(insPlyIncomeVo,params);
- List<HashMap<String, Object>> resultList = settlementDocumentaryFeesService.getOtherSettldetail(params);
- if (resultList.size() > 0) {
- return HttpResult.ok(resultList);
- }
- return HttpResult.ok();
- }
- @Override
- public InsPlyIncome getEntityById(String id) {
- return baseMapper.getEntityById(id);
- }
- @Override
- @Transactional
- public void updateByEntity(InsPlyIncomeVo insPlyIncomeVo) {
- // 根据协议 如果是含增值税结算 用保费 * 如果是 不含税保费
- InsPlyIncome insPlyIncome = new InsPlyIncome();
- BeanUtils.copyProperties(insPlyIncomeVo, insPlyIncome);
- this.amountCalculate(insPlyIncomeVo,insPlyIncome);
- baseMapper.updateById(insPlyIncome);
- insPlyIncomeVo.setCrudStatus("2");
- this.saveLog(insPlyIncomeVo);
- }
- /**
- *
- * @param insPlyIncomeVo
- * @param insPlyIncome
- *
- * 重新计算金额 通过比例
- * 计算逻辑 交强不含税保费* 交强跟单比例 = 交强跟单金额
- */
- private void amountCalculate(InsPlyIncomeVo insPlyIncomeVo,InsPlyIncome insPlyIncome) {
- if("1".equals(insPlyIncomeVo.getAgreementType())){ //平台
- // 平台 手续费 +跟单费 = 应收 手续费 = 手续费比例*保费 应收比例=手续费比例 + 跟单比例
- BigDecimal jqSuperviseCostsProportion = initializationBigdecimal(insPlyIncomeVo.getJqSuperviseCostsProportion());//交强手续费比例
- BigDecimal sySuperviseCostsProportion = initializationBigdecimal(insPlyIncomeVo.getSySuperviseCostsProportion()); //商业手续费比例
- BigDecimal noSuperviseCostsProportion = initializationBigdecimal(insPlyIncomeVo.getNoSuperviseCostsProportion()); //非车手续费比例
- BigDecimal jqOtherCostsProportion = initializationBigdecimal(insPlyIncomeVo.getJqOtherCostsProportion()); //交强跟单比例
- BigDecimal syOtherCostsProportion = initializationBigdecimal(insPlyIncomeVo.getSyOtherCostsProportion()); //商业跟单比例
- BigDecimal noOtherCostsProportion = initializationBigdecimal(insPlyIncomeVo.getNoOtherCostsProportion()); //非车跟单比例
- BigDecimal jqPremium = initializationBigdecimal(insPlyIncomeVo.getJqPremium()); //交强保费
- BigDecimal syPremium = initializationBigdecimal(insPlyIncomeVo.getSyPremium()); //商业保费
- BigDecimal noPremium = initializationBigdecimal(insPlyIncomeVo.getNoPremium()); //非车保费
- //手续费比例
- insPlyIncome.setCommissionFeerate(this.calculateTotal(jqSuperviseCostsProportion,sySuperviseCostsProportion,noSuperviseCostsProportion)); //手续费比例 = 商业手续费比例 + 交强手续费比例 + 非车手续费比例
- if(jqSuperviseCostsProportion !=null && jqPremium!=null ){
- insPlyIncome.setJqSuperviseCostsPremiums(this.algorithmAmount(jqPremium,jqSuperviseCostsProportion)); //交强手续费
- }
- if(sySuperviseCostsProportion !=null && syPremium !=null){
- insPlyIncome.setSySuperviseCostsPremiums(this.algorithmAmount(syPremium,sySuperviseCostsProportion)); //商业手续费
- }
- if(noSuperviseCostsProportion !=null && noPremium!=null){
- insPlyIncome.setNoSuperviseCostsPremiums(this.algorithmAmount(noPremium,noSuperviseCostsProportion)); //非车手续费
- }
- if(jqOtherCostsProportion !=null && jqPremium!=null ){
- insPlyIncome.setJqOtherCostsPremium(this.algorithmAmount(jqPremium,jqOtherCostsProportion)); //交强跟单费
- }
- if(syOtherCostsProportion !=null && syPremium !=null ){
- insPlyIncome.setSyOtherCostsPremium(this.algorithmAmount(syPremium,syOtherCostsProportion)); //商业跟单费
- }
- if(noOtherCostsProportion !=null && noPremium !=null){
- insPlyIncome.setNoOtherCostsPremium(this.algorithmAmount(noPremium,noOtherCostsProportion)); //非车跟单费
- }
- insPlyIncome.setCommissionFeevalue(this.calculateTotal(insPlyIncome.getJqSuperviseCostsPremiums(),insPlyIncome.getSySuperviseCostsPremiums(),insPlyIncome.getNoSuperviseCostsPremiums())); //手续费
- insPlyIncome.setCommissionFeerate(this.calculateTotal(jqSuperviseCostsProportion,sySuperviseCostsProportion,noSuperviseCostsProportion)); //手续费比例
- insPlyIncome.setOtherFeevalue(this.calculateTotal(insPlyIncome.getJqOtherCostsPremium(),insPlyIncome.getSyOtherCostsPremium(),insPlyIncome.getNoOtherCostsPremium())); //跟单费金额
- insPlyIncome.setOtherFeerate(this.calculateTotal(jqOtherCostsProportion,syOtherCostsProportion,noOtherCostsProportion)); //跟单费比例
- insPlyIncome.setAllFeeValue(this.calculateTotal(insPlyIncome.getCommissionFeevalue(),insPlyIncome.getOtherFeevalue(),null)); // 总费用 = 手续费+跟单费
- //应收比例 交强应收比例=交强手续费比例+交强非跟单比例
- insPlyIncome.setJqReceivableProportion(this.calculateTotal(jqSuperviseCostsProportion,jqOtherCostsProportion,null)); //交强应收
- insPlyIncome.setSyReceivableProportion(this.calculateTotal(sySuperviseCostsProportion,syOtherCostsProportion,null)); //商业应收
- insPlyIncome.setNoReceivableProportion(this.calculateTotal(noSuperviseCostsProportion,noOtherCostsProportion,null)); //非车应收
- }else {
- BigDecimal jqNoTaxPremium = insPlyIncomeVo.getJqNoTaxPremium();// 交强手续费 按照思路 交强不含税保费* 交强手续费比例 =交强手续费
- BigDecimal syNoTaxPremium = insPlyIncomeVo.getSyNoTaxPremium();// 商业手续费 按照思路 商业不含税保费* 商业手续费比例 =商业手续费
- BigDecimal noNoTaxPremium = insPlyIncomeVo.getNoNoTaxPremium();// 非车手续费 按照思路 非车不含税保费* 非车手续费比例 =非车手续费
- if(insPlyIncomeVo.getJqSuperviseCostsProportion().compareTo(BigDecimal.ZERO) != 0){
- BigDecimal jqhandingFee = jqNoTaxPremium.multiply(insPlyIncomeVo.getJqSuperviseCostsProportion().divide(new BigDecimal(100)));
- insPlyIncome.setJqSuperviseCostsPremiums(jqhandingFee);
- }
- if(insPlyIncomeVo.getSySuperviseCostsProportion().compareTo(BigDecimal.ZERO) != 0){
- BigDecimal syhandingFee = syNoTaxPremium.multiply(insPlyIncomeVo.getSySuperviseCostsProportion().divide(new BigDecimal(100)));
- insPlyIncome.setSySuperviseCostsPremiums(syhandingFee);
- }
- if(insPlyIncomeVo.getNoSuperviseCostsProportion().compareTo(BigDecimal.ZERO) != 0){
- BigDecimal nohandingFee = noNoTaxPremium.multiply(insPlyIncomeVo.getNoSuperviseCostsProportion().divide(new BigDecimal(100)));
- insPlyIncome.setNoSuperviseCostsPremiums(nohandingFee);
- }
- if(insPlyIncomeVo.getJqOtherCostsProportion().compareTo(BigDecimal.ZERO) != 0){
- BigDecimal jqother = jqNoTaxPremium.multiply(insPlyIncomeVo.getJqOtherCostsProportion().divide(new BigDecimal(100)));//交强跟单费 按照思路 交强不含税保费* 交强跟单比例 = 交强跟单金额
- insPlyIncome.setJqOtherCostsPremium(jqother);
- }
- if(insPlyIncomeVo.getSyOtherCostsProportion().compareTo(BigDecimal.ZERO) != 0){
- BigDecimal syother = syNoTaxPremium.multiply(insPlyIncomeVo.getSyOtherCostsProportion().divide(new BigDecimal(100)));//交强跟单费 按照思路 交强不含税保费* 交强跟单比例 = 交强跟单金额
- insPlyIncome.setSyOtherCostsPremium(syother);
- }
- if(insPlyIncomeVo.getNoOtherCostsProportion().compareTo(BigDecimal.ZERO) != 0){
- BigDecimal syother = syNoTaxPremium.multiply(insPlyIncomeVo.getNoOtherCostsProportion().divide(new BigDecimal(100)));//非车跟单费 按照思路 非车不含税保费* 非车跟单比例 = 非车跟单金额
- insPlyIncome.setNoOtherCostsPremium(syother);
- }
- if("0".equals(insPlyIncomeVo.getIsNotDocumentary()) && "0".equals(insPlyIncomeVo.getIsNotCar())){ //保险 手续费 =不含税保费* 手续费比例
- insPlyIncome.setCommissionFeevalue(this.calculateTotal(insPlyIncome.getJqSuperviseCostsPremiums(),insPlyIncome.getSySuperviseCostsPremiums(),null)); // 手续费
- insPlyIncome.setCommissionFeerate(this.calculateTotal(insPlyIncome.getJqSuperviseCostsProportion(),insPlyIncome.getSySuperviseCostsProportion(),null));//手续费比例
- insPlyIncome.setAllFeeValue(this.calculateTotal(insPlyIncome.getCommissionFeevalue(),null,null));//总金额
- }else if ("1".equals(insPlyIncomeVo.getIsNotDocumentary()) && "0".equals(insPlyIncomeVo.getIsNotCar())){ //保险跟单费 交强跟单+商业跟单
- insPlyIncome.setOtherFeevalue(this.calculateTotal(insPlyIncome.getJqOtherCostsPremium(),insPlyIncome.getSyOtherCostsPremium(),null));
- insPlyIncome.setOtherFeerate(this.calculateTotal(insPlyIncome.getJqOtherCostsProportion(),insPlyIncome.getSyOtherCostsProportion(),null));
- insPlyIncome.setAllFeeValue(this.calculateTotal(insPlyIncome.getOtherFeevalue(),null,null));//总金额
- }
- if("0".equals(insPlyIncomeVo.getIsNotDocumentary()) && "1".equals(insPlyIncomeVo.getIsNotCar())){// 非车
- insPlyIncome.setCommissionFeevalue(this.calculateTotal(insPlyIncome.getNoSuperviseCostsPremiums(),null,null)); // 非车手续费
- insPlyIncome.setCommissionFeerate(this.calculateTotal(insPlyIncome.getNoSuperviseCostsProportion(),null,null)); //非车比例
- insPlyIncome.setAllFeeValue(this.calculateTotal(insPlyIncome.getCommissionFeevalue(),null,null));//总金额
- }else if ("1".equals(insPlyIncomeVo.getIsNotDocumentary()) && "1".equals(insPlyIncomeVo.getIsNotCar())){ //非车跟单
- insPlyIncome.setOtherFeevalue(this.calculateTotal(insPlyIncome.getNoOtherCostsPremium(),null,null)); //非车跟单金额
- insPlyIncome.setOtherFeerate(this.calculateTotal(insPlyIncome.getNoOtherCostsProportion(),null,null)); // 非车跟单比例
- insPlyIncome.setAllFeeValue(this.calculateTotal(insPlyIncome.getOtherFeevalue(),null,null));//总金额
- }
- }
- }
- /**
- *
- * @param value1 保费
- * @param value2 比例
- * @return 费用
- */
- private BigDecimal algorithmAmount(BigDecimal value1, BigDecimal value2) {
- return value1.multiply(value2.divide(new BigDecimal(100)));
- }
- private BigDecimal initializationBigdecimal(BigDecimal value) {
- return value != null ? value : BigDecimal.ZERO;
- }
- private void saveLog(InsPlyIncomeVo insPlyIncomeVo) {
- // 添加记录
- SettlementDocumentaryLogEntity settlementDocumentaryLogEntity = new SettlementDocumentaryLogEntity();
- settlementDocumentaryLogEntity.setCrudStatus(insPlyIncomeVo.getCrudStatus());
- settlementDocumentaryLogEntity.setAmount(insPlyIncomeVo.getOtherFeevalue());
- settlementDocumentaryLogEntity.setSettlementDocumentaryId(insPlyIncomeVo.getId());
- settlementDocumentaryLogEntity.setAmountType("2");
- settlementDocumentaryLogService.save(settlementDocumentaryLogEntity);
- }
- @Override
- @Transactional
- public HttpResult<InsPlyIncome> insertByEntity(InsPlyIncomeVo insPlyIncomeVo) {
- Long id = new SnowFlakeUtil().nextId();
- InsPlyIncome insPlyIncome = new InsPlyIncome();
- insPlyIncomeVo.setOrderno(id.toString());
- BeanUtils.copyProperties(insPlyIncomeVo, insPlyIncome);
- insPlyIncome.setUserId(BaseController.getUser().getId());
- insPlyIncome.setDocumentaryFeesStatus("0");
- insPlyIncome.setHandlingFeesStatus("0");
- insPlyIncome.setIsNotCar(insPlyIncomeVo.getIsNotCar()); // 是否是非车
- insPlyIncome.setIsNotDocumentary(insPlyIncomeVo.getIsNotDocumentary()); //是否是跟单
- HashMap<String, Object> params = new HashMap<>();
- params.put("companyId",insPlyIncomeVo.getCompanyId());
- params.put("partnerCompaniesId",insPlyIncomeVo.getPartnerCompaniesId());
- PtlAgreement ptlAgreement = ptlAgreementService.selectAgreeId(params);
- if(ObjectUtils.isEmpty(ptlAgreement)){
- return HttpResult.error("协议匹配不上");
- }
- insPlyIncome.setAgreementId(ptlAgreement.getId());
- baseMapper.insert(insPlyIncome);
- insPlyIncomeVo.setId(insPlyIncome.getId());
- insPlyIncomeVo.setCrudStatus("1");
- this.saveLog(insPlyIncomeVo); //添加日志
- // HashMap<String, Object> params = new HashMap<>();
- //
- // if(StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotCar())){
- // params.put("isNotCar",insPlyIncomeVo.getIsNotCar());
- // }
- // params.put("isOther","1");
- // if(StringUtils.isNotEmpty(insPlyIncomeVo.getYear())){
- // params.put("year",insPlyIncomeVo.getYear());
- // }
- // if(StringUtils.isNotEmpty(insPlyIncomeVo.getCompanyId())){
- // params.put("companyId",insPlyIncomeVo.getCompanyId());
- // }
- //
- // List<InsPlyIncome> list= this.baseMapper.NonSettlementQuery(params);
- // if(!CollectionUtils.isEmpty(list)){
- // for (InsPlyIncome item :list){
- // return HttpResult.ok(item.getIds());
- // }
- // }
- return HttpResult.ok();
- }
- @Override
- @Transactional
- public HttpResult<InsPlyIncome> deleteById(InsPlyIncomeVo insPlyIncomeVo) {
- HashMap<String, Object> params = new HashMap<>();
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotCar())){
- params.put("isNotCar",insPlyIncomeVo.getIsNotCar());
- }
- params.put("isOther","1");
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getYear())){
- params.put("year",insPlyIncomeVo.getYear());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getCompanyId())){
- params.put("companyId",insPlyIncomeVo.getCompanyId());
- }
- baseMapper.deleteById(insPlyIncomeVo.getId());
- insPlyIncomeVo.setCrudStatus("3");
- this.saveLog(insPlyIncomeVo);
- List<InsPlyIncome> list = this.baseMapper.NonSettlementQuery(params);
- if (!CollectionUtils.isEmpty(list)) {
- for (InsPlyIncome item : list) {
- return HttpResult.ok(item.getIds());
- }
- } else {
- return HttpResult.ok(null);
- }
- return HttpResult.ok("删除成功");
- }
- @Override
- @Transactional
- public void uodateBalance(InsPlyIncomeVo insPlyIncomeVo) {
- InsPlyIncome insPlyIncome = new InsPlyIncome();
- insPlyIncomeVo.setHandlingFeesStatus("1");
- insPlyIncomeVo.setSettlementTime(LocalDate.now());
- BeanUtils.copyProperties(insPlyIncomeVo, insPlyIncome);
- baseMapper.updateById(insPlyIncome);
- // 生成记录
- SettlementDocumentaryLogEntity settlementDocumentaryLogEntity = new SettlementDocumentaryLogEntity();
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getAgreementType()) && "1".equals(insPlyIncomeVo.getAgreementType())){
- // 只有平台协议 才会跟单费一笔结算
- settlementDocumentaryLogEntity.setAmount(insPlyIncomeVo.getOtherFeevalue()); // 跟单费金额
- }
- settlementDocumentaryLogEntity.setHandingAmount(insPlyIncomeVo.getCommissionFeevalue()); // 手续费金额
- settlementDocumentaryLogEntity.setSettlementDocumentaryId(insPlyIncomeVo.getId()); // 关联id
- settlementDocumentaryLogEntity.setAmountType("1"); //手续费结算
- settlementDocumentaryLogEntity.setCreateTime(new Date());
- settlementDocumentaryLogService.save(settlementDocumentaryLogEntity);
- }
- @Override
- @Transactional
- public HttpResult<BasePageResult<InsPlyIncome>> totalQuery(InsPlyIncomeVo insPlyIncomeVo) {
- HashMap<String, Object> params = new HashMap<>();
- PageInfo<List<InsPlyIncome>> pageHelper = null;
- if(insPlyIncomeVo.getStartDate()!=null){
- params.put("startDate",insPlyIncomeVo.getStartDate().toString());
- }
- if(insPlyIncomeVo.getEndDate()!=null){
- params.put("endDate",insPlyIncomeVo.getEndDate().toString());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getYear())){
- params.put("year",insPlyIncomeVo.getYear());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotCar())){
- params.put("isNotCar",insPlyIncomeVo.getIsNotCar());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotDocumentary())){
- params.put("isOther",insPlyIncomeVo.getIsNotDocumentary());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getDocumentaryFeesStatus())){
- params.put("documentaryFeesStatus",insPlyIncomeVo.getDocumentaryFeesStatus());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getCompanyId())){
- params.put("companyId",insPlyIncomeVo.getCompanyId());
- }
- params.put("pageNum",insPlyIncomeVo.getPageNum());
- params.put("pageSize",insPlyIncomeVo.getPageSize());
- List<InsPlyIncome> list= this.baseMapper.totalQuery(params);
- pageHelper=new PageInfo(list);
- return HttpResult.ok(new BasePageResult<>(insPlyIncomeVo.getPageNum(), insPlyIncomeVo.getPageSize(), pageHelper.getTotal(), pageHelper.getPages(), list));
- }
- /**
- *
- * @param insPlyIncomeVo ids ins_ply_income 这个表的ids incomeIds settlement_documentary_fees 这个表的ids
- * @return
- */
- /**
- * 跟单费结算 有分批结算的情况
- * @param insPlyIncomeVo
- * @return
- */
- @Override
- @Transactional
- public HttpResult batchBalance(InsPlyIncomeVo insPlyIncomeVo) {
- // 通过ids 查出跟单非结算单
- BigDecimal allAmount = BigDecimal.ZERO;
- // 分批结算
- SettlementDocumentaryFeesVo settlementDocumentaryFeesVo = new SettlementDocumentaryFeesVo();
- settlementDocumentaryFeesVo.setInvoiceId(insPlyIncomeVo.getInvoicId()); //开票号
- settlementDocumentaryFeesVo.setSettlementTime(insPlyIncomeVo.getSettlementTime()); //结算时间
- settlementDocumentaryFeesVo.setSettlementStatus("2"); //2为结算状态
- settlementDocumentaryFeesVo.setCompanyId(insPlyIncomeVo.getCompanyId()); // 保险公司id
- settlementDocumentaryFeesVo.setPartnerCompaniesId(insPlyIncomeVo.getPartnerCompaniesId()); //合作公司id
- settlementDocumentaryFeesVo.setUnsettledAmount(insPlyIncomeVo.getInvoicCommissionFeevalue().subtract(insPlyIncomeVo.getSettlementAmount())); //未结算金额
- settlementDocumentaryFeesVo.setIsNotCar(insPlyIncomeVo.getIsNotCar()); // 是否是非车
- settlementDocumentaryFeesVo.setInvoicingMethod(insPlyIncomeVo.getInvoicingMethod()); //开票方式
- settlementDocumentaryFeesVo.setTaxPoints(insPlyIncomeVo.getTaxPoints()); //税点
- if ("0".equals(insPlyIncomeVo.getInvoicingMethod())) {
- settlementDocumentaryFeesVo.setExpendAmount(insPlyIncomeVo.getSettlementAmount().multiply(BigDecimal.ONE.subtract(insPlyIncomeVo.getTaxPoints().divide(new BigDecimal(100)))));
- } else {
- settlementDocumentaryFeesVo.setExpendAmount(insPlyIncomeVo.getSettlementAmount()); //进账金额
- }
- settlementDocumentaryFeesVo.setSettlementAmount(insPlyIncomeVo.getSettlementAmount()); //进账金额
- settlementDocumentaryFeesVo.setHandlingFeesStatus(insPlyIncomeVo.getHandlingFeesStatus());
- settlementDocumentaryFeesVo.setTotalAmount(insPlyIncomeVo.getInvoicCommissionFeevalue());
- settlementDocumentaryFeesVo.setCreateTime(LocalDateTime.now());
- settlementDocumentaryFeesVo.setParentId(insPlyIncomeVo.getId());
- settlementDocumentaryFeesVo.setAgreementType("2"); //1平台 2 保险
- settlementDocumentaryFeesService.inertSettle(settlementDocumentaryFeesVo);
- return HttpResult.ok();
- }
- /**
- *
- * @param insPlyIncomeVo
- * @return
- */
- @Override
- public List<InsPlyIncome> totalBxAmount(InsPlyIncomeVo insPlyIncomeVo) {
- HashMap<String, Object> params = new HashMap<>();
- params=this.saveParams(insPlyIncomeVo,params);
- params.remove("handlingFeesStatus");
- List<InsPlyIncome> resultList = baseMapper.totalBxAmount(params);
- // 数据库数据太多是 用sql拼接id会丢失 所以只能逻辑拼接
- List<InsPlyIncome> idList=baseMapper.getIncomeIdList(params);
- if(!CollectionUtils.isEmpty(idList) && !CollectionUtils.isEmpty(resultList)){
- this.splicingIds(idList,resultList);
- }
- return resultList;
- }
- /**
- *
- * @param idList 要开票的数据集合
- * @param resultList 总返回数据
- */
- private void splicingIds(List<InsPlyIncome> idList, List<InsPlyIncome> resultList) {
- // 使用Map来存储agreementId到其id列表的映射
- Map<String, List<String>> idMap = new HashMap<>();
- for (InsPlyIncome idItem : idList) {
- String partnerCompaniesId = idItem.getPartnerCompaniesId();
- idMap.computeIfAbsent(partnerCompaniesId, k -> new ArrayList<>()).add(idItem.getId());
- }
- for (InsPlyIncome resultItem : resultList) {
- List<String> ids = idMap.getOrDefault(resultItem.getPartnerCompaniesId(), Collections.emptyList());
- String idsString = String.join(",", ids);
- resultItem.setIds(idsString);
- }
- }
- /**
- *
- * @param insPlyIncomeVo
- * @return 保险手续费改成多次结算
- */
- @Override
- @Transactional
- public HttpResult<Object> batchInvoicing(InsPlyIncomeVo insPlyIncomeVo) {
- ImportResult importResult = importAsyncService.getById(insPlyIncomeVo.getSelectIds().get(0)); // 查询 任务
- HashMap<String, Object> params = new HashMap<>();
- if (StringUtils.isNotEmpty(importResult.getId())) {
- params.put("companyId",importResult.getCompanyId());
- params.put("partnerCompaniesId",importResult.getPartnerCompaniesId());
- params.put("isOther","0");
- if (StringUtils.isNotEmpty(importResult.getHandStatus())) {
- if ("0".equals(importResult.getHandStatus())) {
- params.put("isNotCar", "0");
- } else if ("1".equals(importResult.getHandStatus())) {
- params.put("isNotCar", "1");
- }
- }
- List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params);
- if (!CollectionUtils.isEmpty(insPlyIncomes)) {
- if (insPlyIncomeVo != null) { // 确保insPlyIncomeVo不是null
- for (InsPlyIncome item : insPlyIncomes) {
- item.setInvoicTime(LocalDate.now());
- item.setInvoicId(insPlyIncomeVo.getInvoicId());
- item.setHandlingFeesStatus("2");
- if (StringUtils.isNotEmpty(item.getTaskId())) {
- return HttpResult.error("该单据已经开票 ");
- } else {
- item.setTaskId(importResult.getId());
- baseMapper.updateById(item);
- }
- }
- }
- }
- }
- insPlyIncomeVo.setNoInvoicCommissionFeevalue(importResult.getTotalAmount());
- insPlyIncomeVo.setOtherFeevalue(importResult.getTotalAmount());
- insPlyIncomeVo.setHandlingFeesStatus("0"); // 0手续费 1 跟单费
- insPlyIncomeVo.setIsNotCar(insPlyIncomeVo.getIsNotCar());
- insPlyIncomeVo.setAgreementId(importResult.getAgreementId());
- insPlyIncomeVo.setPartnerCompaniesId(importResult.getPartnerCompaniesId());
- insPlyIncomeVo.setSettlementAmount(importResult.getTotalAmount());
- insPlyIncomeVo.setContractId(insPlyIncomeVo.getInvoicId());
- insPlyIncomeVo.setCompanyId(importResult.getCompanyId());
- insPlyIncomeVo.setTaskId(importResult.getId());
- this.batchInvoic(insPlyIncomeVo);
- return HttpResult.ok();
- }
- @Override
- public HttpResult<InsPlyIncome> queryInvoicing(InsPlyIncomeVo insPlyIncomeVo) {
- HashMap<String, Object> params = new HashMap<>();
- params = this.saveParams(insPlyIncomeVo, params);
- InsPlyIncome result= baseMapper.queryInvoicing(params); //总金额
- params.put("handlingFeesStatus","0");
- InsPlyIncome noResult= baseMapper.queryInvoicing(params); //未结算金额
- result.setReadyCommissionFeevalue(noResult.getCommissionFeevalue());
- return HttpResult.ok(result);
- }
- @Override
- public HttpResult<Object> batchBxBalance(InsPlyIncomeVo insPlyIncomeVo) {
- // 表内总金额
- BigDecimal invoicCommissionFeevalue = insPlyIncomeVo.getInvoicCommissionFeevalue();
- BigDecimal settlementAmount = insPlyIncomeVo.getSettlementAmount();
- HashMap<String, Object> params = new HashMap<>();
- params = this.saveParams(insPlyIncomeVo,params);
- params.put("handlingFeesStatus",insPlyIncomeVo.getHandlingFeesStatus());
- List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params);
- for (InsPlyIncome item : insPlyIncomes){
- if(settlementAmount.compareTo(invoicCommissionFeevalue) ==0){
- item.setHandlingFeesStatus("1");
- baseMapper.updateById(item);
- }
- }
- // 分批结算
- SettlementDocumentaryFeesVo settlementDocumentaryFeesVo = new SettlementDocumentaryFeesVo();
- String id = String.valueOf(new SnowFlakeUtil().nextId());
- settlementDocumentaryFeesVo.setId(id);
- settlementDocumentaryFeesVo.setInvoiceId(insPlyIncomeVo.getInvoicId()); //开票号
- settlementDocumentaryFeesVo.setSettlementTime(insPlyIncomeVo.getSettlementTime()); //结算时间
- settlementDocumentaryFeesVo.setSettlementStatus("2"); //2为结算状态
- settlementDocumentaryFeesVo.setCompanyId(insPlyIncomeVo.getCompanyId()); // 保险公司id
- settlementDocumentaryFeesVo.setPartnerCompaniesId(insPlyIncomeVo.getPartnerCompaniesId()); //合作公司id
- settlementDocumentaryFeesVo.setIsNotCar(insPlyIncomeVo.getIsNotCar()); // 是否是非车
- settlementDocumentaryFeesVo.setInvoicingMethod(insPlyIncomeVo.getInvoicingMethod()); //开票方式
- settlementDocumentaryFeesVo.setTaxPoints(insPlyIncomeVo.getTaxPoints()); //税点
- settlementDocumentaryFeesVo.setExpendAmount(insPlyIncomeVo.getInvoicCommissionFeevalue().multiply(BigDecimal.ONE.subtract(insPlyIncomeVo.getTaxPoints().divide(new BigDecimal(100)))));
- settlementDocumentaryFeesVo.setSettlementAmount(insPlyIncomeVo.getSettlementAmount()); //进账金额
- settlementDocumentaryFeesVo.setTotalAmount(insPlyIncomeVo.getInvoicCommissionFeevalue());
- settlementDocumentaryFeesVo.setHandlingFeesStatus("0");
- settlementDocumentaryFeesVo.setParentId(id);
- settlementDocumentaryFeesVo.setSettlementImageId(insPlyIncomeVo.getSettlementImageId());
- settlementDocumentaryFeesVo.setCreateTime(LocalDateTime.now());
- settlementDocumentaryFeesVo.setAgreementType("2"); //1平台 2 保险
- settlementDocumentaryFeesService.inertSettle(settlementDocumentaryFeesVo);
- return HttpResult.ok();
- }
- private void changeHandStatus(String ids, InsPlyIncomeVo insPlyIncomeVo) {
- String[] split = ids.split(",");
- SettlementDocumentaryFeesEntity byId = settlementDocumentaryFeesService.getById(insPlyIncomeVo.getId());
- BigDecimal totalAmount = byId.getTotalAmount(); //开票总金额
- BigDecimal settlementAmount = insPlyIncomeVo.getSettlementAmount(); //本次结算金额
- //多次结算 表中已经结算的金额
- SettlementDocumentaryFeesEntity settlementAmountEntity = settlementDocumentaryFeesService.getByParentSettlementAmount(insPlyIncomeVo.getId());
- if(ObjectUtils.isNotEmpty(settlementAmountEntity)){
- BigDecimal all = settlementAmount.add(settlementAmountEntity.getTotalAmount());
- if(all.equals(totalAmount)){
- baseMapper.updateByIds(split);
- }
- }
- }
- @Override
- public HttpResult<InsPlyIncome> querySettInvoicing(InsPlyIncomeVo insPlyIncomeVo) {
- HashMap<String, Object> params = new HashMap<>();
- params = this.saveParams(insPlyIncomeVo, params);
- InsPlyIncome insPlyIncome = baseMapper.queryInvoicing(params); //已经开票
- return HttpResult.ok(insPlyIncome);
- }
- /**
- *
- * @param insPlyIncomeVo
- * @return
- */
- @Override
- public HttpResult<List<InsPlyIncome>> allOtherAmount(InsPlyIncomeVo insPlyIncomeVo) {
- HashMap<String, Object> params = new HashMap<>();
- params = this.saveParams(insPlyIncomeVo, params);
- List<InsPlyIncome> result = baseMapper.allOtherAmount(params);
- return HttpResult.ok(result);
- }
- @Override
- @Transactional
- public HttpResult<Object> batchInvoic(InsPlyIncomeVo insPlyIncomeVo) {
- SettlementDocumentaryFeesVo settlementDocumentaryFeesVo = new SettlementDocumentaryFeesVo(); // 生成跟单费结算表
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getYear())){
- settlementDocumentaryFeesVo.setTimeFrame(insPlyIncomeVo.getYear());//年度
- }
- if(!CollectionUtils.isEmpty(insPlyIncomeVo.getMultipleSelection())){
- InsPlyIncomeVo insPlyIncomeVo1 = insPlyIncomeVo.getMultipleSelection().get(0);
- insPlyIncomeVo.setSettlementAmount(insPlyIncomeVo1.getSettlementAmount());
- insPlyIncomeVo.setOtherFeevalue(insPlyIncomeVo1.getAllTotalOtherFeevalue());
- YearMonth yearMonth = YearMonth.parse(insPlyIncomeVo1.getMonthYear());
- LocalDate signingTime = yearMonth.atDay(1);
- settlementDocumentaryFeesVo.setSigningTime(signingTime);
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getYear())){
- settlementDocumentaryFeesVo.setYear(insPlyIncomeVo.getYear());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getMonth())){
- settlementDocumentaryFeesVo.setMonth(insPlyIncomeVo.getMonth());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getDay())){
- settlementDocumentaryFeesVo.setDay(insPlyIncomeVo.getDay());
- }
- settlementDocumentaryFeesVo.setCompanyId(insPlyIncomeVo.getCompanyId());// 保险公司id
- settlementDocumentaryFeesVo.setPartnerCompaniesId(insPlyIncomeVo.getPartnerCompaniesId()); //合作公司id
- settlementDocumentaryFeesVo.setAgreementId(insPlyIncomeVo.getAgreementId());
- settlementDocumentaryFeesVo.setTotalAmount(insPlyIncomeVo.getOtherFeevalue()); //其他费用金额
- settlementDocumentaryFeesVo.setUnsettledAmount(insPlyIncomeVo.getNoInvoicCommissionFeevalue().subtract(insPlyIncomeVo.getSettlementAmount())); //未结算
- settlementDocumentaryFeesVo.setSettlementAmount(insPlyIncomeVo.getSettlementAmount());//已经开票
- settlementDocumentaryFeesVo.setCreateTime(LocalDateTime.now());
- settlementDocumentaryFeesVo.setSettlementStatus("1");
- settlementDocumentaryFeesVo.setIsNotCar(insPlyIncomeVo.getIsNotCar());
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getContractId())){
- settlementDocumentaryFeesVo.setInvoiceId(insPlyIncomeVo.getContractId()); //开票号
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getTaskId())){
- settlementDocumentaryFeesVo.setTaskId(insPlyIncomeVo.getTaskId());
- }
- settlementDocumentaryFeesVo.setHandlingFeesStatus(insPlyIncomeVo.getHandlingFeesStatus());
- settlementDocumentaryFeesVo.setInvoicingMethod(insPlyIncomeVo.getInvoicingMethod()); //开票方式
- settlementDocumentaryFeesVo.setTaxPoints(insPlyIncomeVo.getTaxPoints()); //税点
- settlementDocumentaryFeesVo.setIds(insPlyIncomeVo.getIds());
- // 税点支出
- if( "0".equals(insPlyIncomeVo.getInvoicingMethod()) && BigDecimalUtils.nullToZero(insPlyIncomeVo.getTaxPoints()) !=null && insPlyIncomeVo.getTaxPoints().compareTo(BigDecimal.ZERO) != 0 && BigDecimalUtils.nullToZero(insPlyIncomeVo.getSettlementAmount()) !=null){
- BigDecimal settlementAmount = insPlyIncomeVo.getSettlementAmount();
- settlementDocumentaryFeesVo.setExpendAmount(settlementAmount.multiply(BigDecimal.ONE.subtract(insPlyIncomeVo.getTaxPoints().divide(new BigDecimal(100)))));
- }else {
- settlementDocumentaryFeesVo.setExpendAmount(insPlyIncomeVo.getSettlementAmount());
- }
- return settlementDocumentaryFeesService.inertSettle(settlementDocumentaryFeesVo);
- }
- @Override
- public HttpResult pinHandlingexcel(InsPlyIncomeVo insPlyIncomeVo, HttpServletRequest request, HttpServletResponse response) {
- HashMap<String, Object> params = new HashMap<>();
- params =this.saveParams(insPlyIncomeVo,params);
- List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params);
- ExportParams exportParams = new ExportParams("平台手续费", null, ExcelType.HSSF);
- exportParams.setStyle(ExcelStyleUtil.class);
- List<SettlementFeesExcel> resultList = new ArrayList<>();
- for (InsPlyIncome item :insPlyIncomes){
- SettlementFeesExcel bxSettlementFeesExcel = new SettlementFeesExcel();
- BeanUtils.copyProperties(item, bxSettlementFeesExcel);
- if("1".equals(item.getHandlingFeesStatus())){
- bxSettlementFeesExcel.setHandlingFeesStatus("已结算");
- }else {
- bxSettlementFeesExcel.setHandlingFeesStatus("未结算");
- }
- resultList.add(bxSettlementFeesExcel);
- }
- String uploadPath = this.uploadPath + "/excel/";
- Path path = Paths.get(uploadPath);
- if (!Files.exists(path)) {
- try {
- Files.createDirectories(path);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- String fileName = EasyExcelUtils.downExcel(uploadPath, "平台手续费导出", SettlementFeesExcel.class, resultList);
- return HttpResult.ok("",uploadUrl + "excel/" + fileName);
- }
- @Override
- public HttpResult bxHandlingexcel(InsPlyIncomeVo insPlyIncomeVo, HttpServletRequest request, HttpServletResponse response) {
- HashMap<String, Object> params = new HashMap<>();
- params =this.saveParams(insPlyIncomeVo,params);
- List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params);
- String filePathName ="";
- List<BxSettlementFeesNorExcel> resultNoList=new ArrayList<>();
- List<BxSettlementFeesExcel> resultList=new ArrayList<>();
- //判断是否是非车 1 是非车
- if("1".equals(insPlyIncomeVo.getIsNotCar())){
- filePathName="非车手续费导出";
- ExportParams exportParams = new ExportParams("非车手续费", null, ExcelType.HSSF);
- exportParams.setStyle(ExcelStyleUtil.class);
- for (InsPlyIncome item :insPlyIncomes){
- BxSettlementFeesNorExcel bxSettlementFeesNorExcel = new BxSettlementFeesNorExcel();
- LocalDateTime signDate = item.getSignDate();
- BeanUtils.copyProperties(item, bxSettlementFeesNorExcel);
- bxSettlementFeesNorExcel.setSigndate(signDate);
- resultNoList.add(bxSettlementFeesNorExcel);
- }
- }else{
- filePathName="车险手续费导出";
- ExportParams exportParams = new ExportParams("车险手续费", null, ExcelType.HSSF);
- exportParams.setStyle(ExcelStyleUtil.class);
- for (InsPlyIncome item :insPlyIncomes){
- BxSettlementFeesExcel bxSettlementFeesExcel = new BxSettlementFeesExcel();
- LocalDateTime signDate = item.getSignDate();
- BeanUtils.copyProperties(item, bxSettlementFeesExcel);
- bxSettlementFeesExcel.setSigndate(signDate);
- resultList.add(bxSettlementFeesExcel);
- }
- }
- String uploadPath = this.uploadPath + "/excel/";
- Path path = Paths.get(uploadPath);
- if (!Files.exists(path)) {
- try {
- Files.createDirectories(path);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- String fileName="";
- if("1".equals(insPlyIncomeVo.getIsNotCar())){
- fileName = EasyExcelUtils.downExcel(uploadPath, filePathName, BxSettlementFeesNorExcel.class, resultNoList);
- }else{
- fileName = EasyExcelUtils.downExcel(uploadPath, filePathName, BxSettlementFeesExcel.class, resultList);
- }
- return HttpResult.ok("",uploadUrl + "excel/" + fileName);
- }
- @Override
- public HttpResult bxOtherExcel(InsPlyIncomeVo insPlyIncomeVo, HttpServletRequest request, HttpServletResponse response) {
- HashMap<String, Object> params = new HashMap<>();
- params =this.saveParams(insPlyIncomeVo,params);
- params.put("agreementType","2");
- params.put("isOther","1");
- params.put("isNotCar","0");
- List<InsPlyIncome> insPlyIncomes = baseMapper.allOtherAmount(params);
- ExportParams exportParams = new ExportParams("跟单费导出", null, ExcelType.HSSF);
- exportParams.setStyle(ExcelStyleUtil.class);
- List<BxOtherExcel> resultList = new ArrayList<>();
- for (InsPlyIncome item :insPlyIncomes){
- BxOtherExcel bxSettlementFeesExcel = new BxOtherExcel();
- BeanUtils.copyProperties(item, bxSettlementFeesExcel);
- resultList.add(bxSettlementFeesExcel);
- }
- String uploadPath = this.uploadPath + "/excel/";
- Path path = Paths.get(uploadPath);
- if (!Files.exists(path)) {
- try {
- Files.createDirectories(path);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- String fileName = EasyExcelUtils.downExcel(uploadPath, "跟单费导出", BxOtherExcel.class, resultList);
- return HttpResult.ok("",uploadUrl + "excel/" + fileName);
- }
- @Override
- public InsPlyIncome bxTotalAmount(InsPlyIncomeVo insPlyIncomeVo) {
- HashMap<String, Object> params = new HashMap<>();
- params = this.saveParams(insPlyIncomeVo, params);
- InsPlyIncome totalledAmount =baseMapper.bxTotalAmount(params); //总金额
- return totalledAmount;
- }
- @Override
- public InsPlyIncome ptTotalAmount(InsPlyIncomeVo insPlyIncomeVo) {
- HashMap<String, Object> params = new HashMap<>();
- params = this.saveParams(insPlyIncomeVo, params);
- params.remove("handlingFeesStatus");
- InsPlyIncome totalledAmount =baseMapper.ptTotalAmount(params); //总金额
- return totalledAmount;
- }
- @Override
- public HttpResult<List<HashMap<String,Object>>> otherTimeDetail(InsPlyIncomeVo insPlyIncomeVo) {
- HashMap<String, Object> params = new HashMap<>();
- this.saveParams(insPlyIncomeVo,params);
- List<HashMap<String,Object>> resultMap=baseMapper.otherTimeDetail(params);
- Set<String> uniqueYears = new HashSet<>();
- for (Map<String, Object> map : resultMap) {
- // 假设年份是以 "year" 为键的,并且它的值是 String 类型
- String year = String.valueOf(map.get("year")) ;
- if (year != null) { // 确保年份不是 null
- uniqueYears.add(year);
- }
- }
- this.addMonthYear(uniqueYears,resultMap);
- return HttpResult.ok(resultMap);
- }
- /**
- * uniqueYears 年份间隔 resultMap 返回结果
- * @param uniqueYears
- * @param resultMap 返回一到十二月数据
- */
- private void addMonthYear(Set<String> uniqueYears, List<HashMap<String, Object>> resultMap) {
- // 存储已存在的年份-月份组合,以便快速查找
- Set<String> existingYearMonths = new HashSet<>();
- for (Map<String, Object> entry : resultMap) {
- String year = String.valueOf(entry.get("year")) ;
- int month = (Integer) entry.get("monthNumber");
- existingYearMonths.add(year + "-" + month);
- }
- // 遍历所有年份和月份,并添加缺失的条目
- for (String year : uniqueYears) {
- for (int month = 1; month <= 12; month++) {
- String yearMonth = year + "-" + month;
- if (!existingYearMonths.contains(yearMonth)) {
- // 创建一个新的条目并添加到resultMap中
- HashMap<String, Object> newEntry = new HashMap<>();
- newEntry.put("year", year);
- newEntry.put("monthNumber", month);
- newEntry.put("allTotalOtherFeevalue", 0);
- newEntry.put("invoicCommissionFeevalue", 0);
- newEntry.put("monthYear", yearMonth);
- newEntry.put("noInvoicCommissionFeevalue", 0);
- resultMap.add(newEntry);
- }
- }
- }
- // 使用自定义Comparator对resultMap进行排序
- Collections.sort(resultMap, new Comparator<HashMap<String, Object>>() {
- @Override
- public int compare(HashMap<String, Object> o1, HashMap<String, Object> o2) {
- // 比较 year
- String year1 = String.valueOf(o1.get("year")) ;
- String year2 =String.valueOf(o2.get("year"));
- int yearComparison = year1.compareTo(year2);
- if (yearComparison != 0) {
- return yearComparison;
- }
- // 如果 year 相同,则比较 monthNumber
- Integer monthNum1 = (Integer) o1.get("monthNumber");
- Integer monthNum2 = (Integer) o2.get("monthNumber");
- return monthNum1.compareTo(monthNum2);
- }
- });
- }
- @Override
- public HttpResult<Object> singleInvoic(InsPlyIncomeVo insPlyIncomeVo) {
- // 通过ids 查出跟单非结算单
- SettlementDocumentaryFeesVo settlementDocumentaryFeesVo = new SettlementDocumentaryFeesVo(); // 生成跟单费结算表
- if (!CollectionUtils.isEmpty(insPlyIncomeVo.getMultipleSelection())) {
- for (InsPlyIncomeVo insPlyIncomeVo1 : insPlyIncomeVo.getMultipleSelection()) {
- insPlyIncomeVo.setSettlementAmount(insPlyIncomeVo1.getSettlementAmount());
- insPlyIncomeVo.setOtherFeevalue(insPlyIncomeVo1.getAllTotalOtherFeevalue());
- YearMonth yearMonth = YearMonth.parse(insPlyIncomeVo1.getMonthYear());
- LocalDate signingTime = yearMonth.atDay(1);
- settlementDocumentaryFeesVo.setSigningTime(signingTime);
- }
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getYear())) {
- settlementDocumentaryFeesVo.setTimeFrame(insPlyIncomeVo.getYear());//年度
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getYear())) {
- settlementDocumentaryFeesVo.setYear(insPlyIncomeVo.getYear());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getMonth())) {
- settlementDocumentaryFeesVo.setMonth(insPlyIncomeVo.getMonth());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getDay())) {
- settlementDocumentaryFeesVo.setDay(insPlyIncomeVo.getDay());
- }
- settlementDocumentaryFeesVo.setCompanyId(insPlyIncomeVo.getCompanyId());// 保险公司id
- settlementDocumentaryFeesVo.setPartnerCompaniesId(insPlyIncomeVo.getPartnerCompaniesId()); //合作公司id
- settlementDocumentaryFeesVo.setTotalAmount(insPlyIncomeVo.getOtherFeevalue()); //其他费用金额
- settlementDocumentaryFeesVo.setUnsettledAmount(insPlyIncomeVo.getNoInvoicCommissionFeevalue().subtract(insPlyIncomeVo.getSettlementAmount())); //未结算
- settlementDocumentaryFeesVo.setSettlementAmount(insPlyIncomeVo.getSettlementAmount());//已经开票
- settlementDocumentaryFeesVo.setCreateTime(LocalDateTime.now());
- settlementDocumentaryFeesVo.setIds(insPlyIncomeVo.getIncomeIds());
- settlementDocumentaryFeesVo.setSettlementStatus("1");
- settlementDocumentaryFeesVo.setIsNotCar(insPlyIncomeVo.getIsNotCar());
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getContractId())) {
- settlementDocumentaryFeesVo.setInvoiceId(insPlyIncomeVo.getContractId()); //开票号
- }
- settlementDocumentaryFeesVo.setHandlingFeesStatus(insPlyIncomeVo.getHandlingFeesStatus());
- settlementDocumentaryFeesVo.setInvoicingMethod(insPlyIncomeVo.getInvoicingMethod()); //开票方式
- settlementDocumentaryFeesVo.setTaxPoints(insPlyIncomeVo.getTaxPoints()); //税点
- settlementDocumentaryFeesVo.setIds(insPlyIncomeVo.getIds());
- settlementDocumentaryFeesVo.setSigningTime(insPlyIncomeVo.getSettlementTime()); //签单日期
- // 税点支出
- if (BigDecimalUtils.nullToZero(insPlyIncomeVo.getTaxPoints()) != null && BigDecimalUtils.nullToZero(insPlyIncomeVo.getSettlementAmount()) != null) {
- BigDecimal settlementAmount = insPlyIncomeVo.getSettlementAmount();
- settlementDocumentaryFeesVo.setExpendAmount(settlementAmount.multiply(BigDecimal.ONE.subtract(insPlyIncomeVo.getTaxPoints().divide(new BigDecimal(100)))));
- }
- settlementDocumentaryFeesService.inertSettle(settlementDocumentaryFeesVo);
- return HttpResult.ok();
- }
- @Override
- public void batchUpdate(InsPlyIncomeVo insPlyIncomeVo) {
- HashMap<String, Object> params = new HashMap<>();
- params= this.saveParams(insPlyIncomeVo,params);
- List<InsPlyIncome> list= this.baseMapper.queryNew(params);
- for ( InsPlyIncome item : list){
- item.setContractFileId( insPlyIncomeVo.getContractFileId());
- item.setSettleOtherStatus("1");
- baseMapper.updateById(item);
- }
- }
- @Override
- @Transactional
- public HashMap<String, Object> bxImportOther(MultipartFile multipartFile,String isNotCar) {
- HashMap<String, Object> resultMap = new HashMap<>();
- List<HashMap<String,Object>> resultList=new ArrayList<>();
- HashMap<String, Object> params = new HashMap<>();
- BigDecimal allAmount = BigDecimal.ZERO;
- params.put("isNotCar",isNotCar);
- try {
- List<InsBxOtherExcelDto> dtoList = ExcelEasypoiUtils.importExcel(multipartFile, InsBxOtherExcelDto.class, 0, 1, 1);
- for (InsBxOtherExcelDto item : dtoList){
- if(StringUtils.isNotEmpty(item.getLicenseno())){
- params.put("licenseno",item.getLicenseno());
- }
- if(StringUtils.isNotEmpty(item.getPolicyno())){
- params.put("policyno",item.getPolicyno());
- }
- if(StringUtils.isNotEmpty(item.getSyPolicyno())){
- params.put("syPolicyno",item.getSyPolicyno());
- }
- params.put("handlingFeesStatus","0");
- // isOther
- params.put("isOther","1");
- params.put("isNotCar","0");
- InsPlyIncome byBxLicenseno = baseMapper.findByBxLicenseno(params);
- if (item.getJqOtherCostsProportion() ==null){
- item.setJqOtherCostsProportion(BigDecimal.ZERO);
- }
- if(item.getSyOtherCostsProportion() == null){
- item.setSyOtherCostsProportion(BigDecimal.ZERO);
- }
- if(byBxLicenseno.getJqOtherCostsProportion().compareTo(item.getJqOtherCostsProportion()) !=0 || byBxLicenseno.getSyOtherCostsProportion().compareTo(item.getSyOtherCostsProportion()) != 0){
- // 如果比例不相等
- BigDecimal jqOtherCostsProportion = item.getJqOtherCostsProportion();
- BigDecimal syOtherCostsProportion = item.getSyOtherCostsProportion();
- BigDecimal divisor = new BigDecimal("1.06"); // 最好是使用字符串来避免精度损失
- BigDecimal jqNoTaxPremium = byBxLicenseno.getJqPremium().divide(divisor, 5, RoundingMode.HALF_UP);//交强保费 / 1.06
- BigDecimal syNoTaxPremium = byBxLicenseno.getSyPremium().divide(divisor, 5, RoundingMode.HALF_UP);// 商业 保费 /1.06
- BigDecimal jqOtherAmount = jqNoTaxPremium.multiply(item.getJqOtherCostsProportion().divide(new BigDecimal(100))); //交强跟单费用
- BigDecimal syOtherAmount = syNoTaxPremium.multiply(item.getSyOtherCostsProportion().divide(new BigDecimal(100)));
- byBxLicenseno.setJqOtherCostsPremium(jqOtherAmount);
- byBxLicenseno.setSyOtherCostsPremium(syOtherAmount);
- byBxLicenseno.setJqOtherCostsProportion(jqOtherCostsProportion);
- byBxLicenseno.setSyOtherCostsProportion(syOtherCostsProportion);
- byBxLicenseno.setOtherFeevalue(this.calculateTotal(jqOtherAmount,syOtherAmount,null));
- byBxLicenseno.setOtherFeerate(this.calculateTotal(jqOtherCostsProportion,syOtherCostsProportion ,null));
- byBxLicenseno.setAllFeeValue(this.calculateTotal(jqOtherAmount,syOtherAmount,null));
- baseMapper.updateById(byBxLicenseno);
- HashMap<String, Object> map = new HashMap<>();
- map.put("licenseno",item.getLicenseno());
- map.put("policyno",item.getPolicyno());
- map.put("syPolicyno",item.getSyPolicyno());
- map.put("jqOtherCostsPremium",jqOtherAmount);
- map.put("syOtherCostsPremium",syOtherAmount);
- map.put("otherFeevalue",byBxLicenseno.getOtherFeevalue());
- map.put("otherFeerate",byBxLicenseno.getOtherFeerate());
- resultList.add(map);
- allAmount = allAmount.add(jqOtherAmount).add(syOtherAmount);
- }
- }
- resultMap.put("allAmount",allAmount);
- resultMap.put("resultList",resultList);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- return resultMap;
- }
- @Override
- @Transactional
- public HashMap<String, Object> noBxImportOther(MultipartFile multipartFile, String isNotCar) {
- HashMap<String, Object> resultMap = new HashMap<>();
- List<HashMap<String,Object>> resultList=new ArrayList<>();
- HashMap<String, Object> params = new HashMap<>();
- BigDecimal allAmount = BigDecimal.ZERO;
- params.put("isNotCar",isNotCar);
- try {
- List<InsNoBxOtherExcelDto> dtoList = ExcelEasypoiUtils.importExcel(multipartFile, InsNoBxOtherExcelDto.class, 0, 1, 1);
- for (InsNoBxOtherExcelDto item : dtoList){
- if(StringUtils.isNotEmpty(item.getLicenseno())){
- params.put("licenseno",item.getLicenseno());
- }
- if(StringUtils.isNotEmpty(item.getNoPolicyno())){
- params.put("noPolicyno",item.getNoPolicyno());
- }
- params.put("handlingFeesStatus","0");
- params.put("isNotCar","1");
- params.put("isOther","1");
- InsPlyIncome byBxLicenseno = baseMapper.findByBxLicenseno(params);
- if(byBxLicenseno.getNoOtherCostsProportion().compareTo(item.getNoOtherCostsProportion()) !=0 ){
- // 如果比例不相等
- BigDecimal noOtherCostsProportion = item.getNoOtherCostsProportion();
- BigDecimal noNoTaxPremium = byBxLicenseno.getNoNoTaxPremium();
- BigDecimal noOtherAmount = noNoTaxPremium.multiply(item.getNoOtherCostsProportion().divide(new BigDecimal(100))); //交强跟单费用
- byBxLicenseno.setOtherFeevalue(this.calculateTotal(noOtherAmount,null,null));
- byBxLicenseno.setOtherFeerate(this.calculateTotal(noOtherCostsProportion,null ,null));
- baseMapper.updateById(byBxLicenseno);
- resultMap.put("licenseno",item.getLicenseno());
- resultMap.put("noPolicyno",item.getNoPolicyno());
- resultMap.put("noOtherCostsPremium",noOtherAmount);
- resultMap.put("otherFeevalue",byBxLicenseno.getOtherFeevalue());
- resultMap.put("otherFeerate",byBxLicenseno.getOtherFeerate());
- resultList.add(resultMap);
- allAmount = allAmount.add(noOtherAmount);
- }
- }
- resultMap.put("allAmount",allAmount);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- return resultMap;
- }
- @Override
- public void batchUpdateVoucher(InsPlyIncomeVo insPlyIncomeVo) {
- String s = insPlyIncomeVo.getSelectIds().get(0);
- ImportResult importResult = importAsyncService.getById(s);
- String[] split = importResult.getIds().split(",");
- InsPlyIncome insPlyIncome = new InsPlyIncome();
- for (String id :split){
- insPlyIncome.setId(id);
- insPlyIncome.setSettlementImageId(insPlyIncomeVo.getSettlementImageId());
- insPlyIncome.setSettleOtherStatus("1");
- baseMapper.updateById(insPlyIncome);
- }
- }
- /**
- * 通过任务id 去查询关联表
- * @param insPlyIncomeVo
- * @return
- */
- @Override
- public HttpResult<Object> reconciliation(InsPlyIncomeVo insPlyIncomeVo) {
- String taskId = insPlyIncomeVo.getTaskId();
- List<String> incomeIdList = incomeTaskRelationshipService.getByTaskId(taskId);
- for (String incomeId :incomeIdList){
- InsPlyIncome insPlyIncome = baseMapper.getById(incomeId);
- insPlyIncome.setSettleOtherStatus("1");
- insPlyIncome.setSettlementImageId(insPlyIncomeVo.getSettlementImageId());
- baseMapper.updateById(insPlyIncome);
- }
- return HttpResult.ok();
- }
- }
|