| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533 |
- package com.ydtech.modules.fee.service.impl;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.ydtech.constants.enums.dict.agreement.ProductsType;
- import com.ydtech.constants.enums.dict.insurance.EnergyType;
- import com.ydtech.constants.enums.dict.insurance.NatureOfVehicleUse;
- import com.ydtech.constants.enums.dict.insurance.VehicleType;
- import com.ydtech.exception.SystemException;
- import com.ydtech.modules.admin.model.SysUser;
- import com.ydtech.modules.admin.service.SysChannelGroupService;
- import com.ydtech.modules.admin.service.SysSwitchConfigService;
- import com.ydtech.modules.admin.service.SysUserAccountService;
- import com.ydtech.modules.admin.service.SysUserService;
- import com.ydtech.modules.esm.model.EsmRetail;
- import com.ydtech.modules.esm.model.EsmUserReferrer;
- import com.ydtech.modules.esm.service.EsmRetailService;
- import com.ydtech.modules.esm.service.EsmUserReferrerService;
- import com.ydtech.modules.fee.constants.CostAllocation;
- import com.ydtech.modules.fee.dto.po.InsFeeOrderConfig;
- import com.ydtech.modules.fee.dto.vo.ReCalcuLateProportion;
- import com.ydtech.modules.fee.dto.vo.RetailProportion;
- import com.ydtech.modules.fee.dto.vo.RuleAttrMappingVo;
- import com.ydtech.modules.fee.service.FeeRuleSchemeNewService;
- import com.ydtech.modules.fee.service.FeeRuleSchemeService;
- import com.ydtech.modules.fee.service.InsFeeOrderConfigService;
- import com.ydtech.modules.fee.service.InsFeeOrderNewHistoryService;
- import com.ydtech.modules.order.entity.InsAreaCompany;
- import com.ydtech.modules.order.entity.InsOrders;
- import com.ydtech.modules.order.entity.api.dajia.constants.TypeVehicleMapping;
- import com.ydtech.modules.order.entity.vo.ExternalOrderFeeVo;
- import com.ydtech.modules.order.entity.vo.FeeOrderNewVo;
- import com.ydtech.modules.order.entity.vo.QueryOrderFeeResultVo;
- import com.ydtech.modules.order.entity.vo.QueryOrderFeeVo;
- import com.ydtech.modules.order.service.InsOrdersService;
- import com.ydtech.modules.protocol.entity.po.PtlAgreement;
- import com.ydtech.modules.protocol.entity.po.PtlNewCarJudgeRules;
- import com.ydtech.modules.protocol.service.PtlAgreementService;
- import com.ydtech.modules.protocol.service.PtlNewCarJudgeRulesService;
- import com.ydtech.modules.protocols.entity.po.*;
- import com.ydtech.modules.protocols.entity.vo.AgreementProductCosts;
- import com.ydtech.modules.protocols.service.*;
- import com.ydtech.utils.idgen.IdGenerate;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import javax.annotation.Resource;
- import java.math.BigDecimal;
- import java.math.RoundingMode;
- import java.text.DateFormat;
- import java.time.LocalDate;
- import java.time.LocalDateTime;
- import java.time.format.DateTimeFormatter;
- import java.util.*;
- import java.util.concurrent.atomic.AtomicBoolean;
- import java.util.stream.Collectors;
- /**
- * @author: tz
- * @description: 费用接口中相关功能的实现类
- * @create: 2024-3-1 11:45:33
- */
- @Service
- public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
- private static final Logger log = LoggerFactory.getLogger("fee");
- @Resource
- private InsOrdersService insOrdersService;
- @Resource
- private PtlAgreementProductCostsNewService ptlAgreementProductCostsNewService;
- @Resource
- private PtlAgreementUndwrtRulesAttrService ptlAgreementUndwrtRulesAttrService;
- @Resource
- private PtlAgreementProductCostsExportService ptlAgreementProductCostsExportService;
- @Resource
- private PtlAgreementProductCostsAttrLinkService ptlAgreementProductCostsAttrLinkService;
- @Resource
- private PtlAgreementUndwrtRulesNewService ptlAgreementUndwrtRulesNewService;
- @Resource
- private SysUserService sysUserService;
- @Resource
- private EsmRetailService esmRetailService;
- @Resource
- private InsFeeOrderNewService insFeeOrderNewService;
- @Autowired
- private EsmUserReferrerService esmUserReferrerService;
- @Autowired
- private SysUserAccountService sysUserAccountService;
- @Autowired
- private PtlNewCarJudgeRulesService ptlNewCarJudgeRulesService;
- @Autowired
- private PtlAgreementService ptlAgreementService;
- @Autowired
- private FeeRuleSchemeService feeRuleSchemeService;
- @Autowired
- private InsFeeOrderConfigService insFeeOrderConfigService;
- @Autowired
- private SysSwitchConfigService sysSwitchConfigService;
- @Autowired
- private InsFeeOrderNewHistoryService insFeeOrderNewHistoryService;
- @Autowired
- private SysChannelGroupService sysChannelGroupService;
- @Override
- public QueryOrderFeeVo queryFeeOrderInfo(String companyId) {
- return null;
- }
- @Override
- public List<QueryOrderFeeResultVo> convertOrderFeeVoData(QueryOrderFeeVo orderFeeVo) {
- return null;
- }
- @Override
- public void compareAndUpdateFeeOrderInfo(String insOrderNo, String jqCostsProportionStr, String syCostsProportionStr, String dealUser) {
- }
- /**
- * 校验费用因子
- */
- @Override
- public void verificationCostFactor(InsAreaCompany insAreaCompany, InsOrders insOrders, StringBuilder logs) {
- List<AgreementProductCosts> agreementProductCostsNoMatched =
- ptlAgreementProductCostsNewService.costsGetList(insAreaCompany.getAgreementId(), insAreaCompany.getProductid());
- List<AgreementProductCosts> agreementProductCosts = new ArrayList<>();
- //过滤费用因子 根据使用性质,能源种类,车辆种类过滤
- agreementProductCostsNoMatched.forEach(item->{
- AtomicBoolean matching = new AtomicBoolean(true);
- item.getCostsAttrLinks().forEach(attr->{
- //判断能源类型 燃油 新能源
- if(attr.getAttrCode().equals("NewEnergy")){
- //传入的能源类型
- String energyType = EnergyType.isNewEnergy(insOrders.getCarinfo().getString("energyType")) ? "1" : "0";
- if(!attr.getMin().equals(energyType)) {
- matching.set(false);
- }
- }
- //使用性质 营业 非营业
- if(attr.getAttrCode().equals("NatureOfUse")){
- String[] split = attr.getMin().split(",");
- boolean isPipei = false;
- for(int i=0;i<split.length;i++){
- if(split[i].equals(TypeVehicleMapping.getByCode(insOrders.getCarinfo().getString("vehicleUse")))){
- isPipei = true;
- }
- }
- if(!isPipei){
- matching.set(false);
- }
- }
- //车辆种类 客车 货车
- if(attr.getAttrCode().equals("CarType")){
- if(!attr.getMin().contains(VehicleType.getByCode(insOrders.getCarinfo().getString("cimodelclass")))){
- matching.set(false);
- }
- }
- });
- if(matching.get()){
- agreementProductCosts.add(item);
- }
- });
- // if(agreementProductCosts == null || agreementProductCosts.size() == 0){
- // throw new SystemException("协议费用因子为空");
- // }
- for (int i = 0; i < agreementProductCosts.size(); i++) {
- if (agreementProductCosts.get(i).getPriorityLevel() == null) {
- agreementProductCosts.get(i).setPriorityLevel(10);
- }
- }
- if (!agreementProductCosts.isEmpty()) {
- //按优先级进行排序
- Collections.sort(agreementProductCosts, Comparator.comparingInt(AgreementProductCosts::getPriorityLevel));
- //遍历费用因子
- String costsId = verificationCosts(agreementProductCosts, insAreaCompany, insOrders, logs);
- if (costsId != null) {
- calcCosts(costsId, insAreaCompany);
- log.debug("费用因子校验通过,子订单id:" + insAreaCompany.getId() + ",费用id:" + costsId);
- }
- } else {
- logs.append("没有找到该协议的费用信息" + "\n");
- }
- }
- /**
- * 校验承保规则
- *
- * @param insAreaCompany
- * @param insOrders
- */
- @Override
- public void verificationRuleFactor(InsAreaCompany insAreaCompany, InsOrders insOrders) {
- List<PtlAgreementUndwrtRulesNew> ptlAgreementUndwrtRules =
- ptlAgreementUndwrtRulesNewService.rulesList(insAreaCompany.getAgreementId());
- verificationRules(ptlAgreementUndwrtRules, insAreaCompany, insOrders);
- }
- //BigDecimal取两位
- private BigDecimal twoPeople(BigDecimal number) {
- return number.setScale(2, BigDecimal.ROUND_DOWN);
- }
- /**
- * 重新计算分销和机构比例
- *
- * @param sumCostsProportion 总入口费用比例
- * @param deptProportion 机构管理总比例
- * @param retailProportion 默认分销总比例
- * @param retailLevel 分销级别
- * @return 如果不够减则 返回新的分销比例
- */
- public ReCalcuLateProportion recalculateProportion(BigDecimal sumCostsProportion,
- BigDecimal deptProportion,
- BigDecimal retailProportion,
- BigDecimal taxRadio,
- Integer retailLevel,
- PtlAgreementProductCostsExport ptlAgreementProductCostsExport,
- RetailProportion originalRetailProportion,
- String type,
- BigDecimal enterProportion) {
- ReCalcuLateProportion reCalcuLateProportion = new ReCalcuLateProportion();
- BigDecimal costsProportion = sumCostsProportion.divide(taxRadio, 2, BigDecimal.ROUND_DOWN);
- List<InsFeeOrderConfig> list = insFeeOrderConfigService.list();
- //总比例 / 比例 / 分销等级
- // 不够减扣除比例
- Map<String, BigDecimal> notEnoughReduce = list.stream().collect(Collectors.toMap(InsFeeOrderConfig::getKeyword, InsFeeOrderConfig::getVal));
- //分销配置的比例
- BigDecimal retailProportionConfig = notEnoughReduce.get(CostAllocation.CA_01.getCode());
- BigDecimal retailSettingProportion = new BigDecimal(retailProportionConfig.toString());
- // 机构配置的比例
- BigDecimal deptProportionConfig = notEnoughReduce.get(CostAllocation.CA_02.getCode());
- // 代课录单比例
- BigDecimal proxyProportionConfig = notEnoughReduce.get(CostAllocation.CA_03.getCode());
- BigDecimal deptSettingProportion = new BigDecimal(deptProportionConfig.toString());
- //机构比例均分
- BigDecimal jqAverageDept = twoPeople(twoPeople(costsProportion.multiply(deptSettingProportion)).divide(new BigDecimal(5)));
- //如果不够减的话
- if (deptProportion.add(retailProportion).add(enterProportion).compareTo(costsProportion) > 0) {
- //分销比例均分
- BigDecimal jqAverageRetail = new BigDecimal(0);
- if (retailLevel != 0) {
- jqAverageRetail = twoPeople(twoPeople(costsProportion.multiply(retailSettingProportion)).divide(new BigDecimal(retailLevel), 2, RoundingMode.DOWN));
- }
- if (enterProportion.compareTo(BigDecimal.ZERO) == 0) {
- reCalcuLateProportion.setProxyProportion(BigDecimal.ZERO);
- } else {
- // 代客比例
- BigDecimal proxyProportion = costsProportion.multiply(proxyProportionConfig);
- reCalcuLateProportion.setProxyProportion(twoPeople(proxyProportion));
- }
- if (retailLevel >= 3) {
- reCalcuLateProportion.setRetail_level_3_proportion(jqAverageRetail);
- }
- if (retailLevel >= 2) {
- reCalcuLateProportion.setRetail_level_2_proportion(jqAverageRetail);
- }
- if (retailLevel >= 1) {
- reCalcuLateProportion.setRetail_level_1_proportion(jqAverageRetail);
- }
- reCalcuLateProportion.setDept_level_1_proportion(jqAverageDept);
- reCalcuLateProportion.setDept_level_2_proportion(jqAverageDept);
- reCalcuLateProportion.setDept_level_3_proportion(jqAverageDept);
- reCalcuLateProportion.setDept_level_4_proportion(jqAverageDept);
- reCalcuLateProportion.setDept_level_5_proportion(jqAverageDept);
- } else {
- if (type.equals("jq")) {
- reCalcuLateProportion.setDept_level_1_proportion(ptlAgreementProductCostsExport.getJqExportRadioLevel1());
- reCalcuLateProportion.setDept_level_2_proportion(ptlAgreementProductCostsExport.getJqExportRadioLevel2());
- reCalcuLateProportion.setDept_level_3_proportion(ptlAgreementProductCostsExport.getJqExportRadioLevel3());
- reCalcuLateProportion.setDept_level_4_proportion(ptlAgreementProductCostsExport.getJqExportRadioLevel4());
- reCalcuLateProportion.setDept_level_5_proportion(ptlAgreementProductCostsExport.getJqExportRadioLevel5());
- reCalcuLateProportion.setRetail_level_1_proportion(originalRetailProportion.getJqRetailLevel1Proportion());
- reCalcuLateProportion.setRetail_level_2_proportion(originalRetailProportion.getJqRetailLevel2Proportion());
- reCalcuLateProportion.setRetail_level_3_proportion(originalRetailProportion.getJqRetailLevel3Proportion());
- } else if (type.equals("sy")) {
- reCalcuLateProportion.setDept_level_1_proportion(ptlAgreementProductCostsExport.getSyExportRadioLevel1());
- reCalcuLateProportion.setDept_level_2_proportion(ptlAgreementProductCostsExport.getSyExportRadioLevel2());
- reCalcuLateProportion.setDept_level_3_proportion(ptlAgreementProductCostsExport.getSyExportRadioLevel3());
- reCalcuLateProportion.setDept_level_4_proportion(ptlAgreementProductCostsExport.getSyExportRadioLevel4());
- reCalcuLateProportion.setDept_level_5_proportion(ptlAgreementProductCostsExport.getSyExportRadioLevel5());
- reCalcuLateProportion.setRetail_level_1_proportion(originalRetailProportion.getSyRetailLevel1Proportion());
- reCalcuLateProportion.setRetail_level_2_proportion(originalRetailProportion.getSyRetailLevel2Proportion());
- reCalcuLateProportion.setRetail_level_3_proportion(originalRetailProportion.getSyRetailLevel3Proportion());
- } else if (type.equals("no")) {
- reCalcuLateProportion.setDept_level_1_proportion(ptlAgreementProductCostsExport.getNoCarExportRadioLevel1());
- reCalcuLateProportion.setDept_level_2_proportion(ptlAgreementProductCostsExport.getNoCarExportRadioLevel2());
- reCalcuLateProportion.setDept_level_3_proportion(ptlAgreementProductCostsExport.getNoCarExportRadioLevel3());
- reCalcuLateProportion.setDept_level_4_proportion(ptlAgreementProductCostsExport.getNoCarExportRadioLevel4());
- reCalcuLateProportion.setDept_level_5_proportion(ptlAgreementProductCostsExport.getNoCarExportRadioLevel5());
- reCalcuLateProportion.setRetail_level_1_proportion(originalRetailProportion.getNoRetailLevel1Proportion());
- reCalcuLateProportion.setRetail_level_2_proportion(originalRetailProportion.getNoRetailLevel2Proportion());
- reCalcuLateProportion.setRetail_level_3_proportion(originalRetailProportion.getNoRetailLevel3Proportion());
- }
- // 代课比例
- reCalcuLateProportion.setProxyProportion(enterProportion);
- }
- return reCalcuLateProportion;
- }
- /**
- * 计算费用
- *
- * @param costsId
- * @param insAreaCompany
- */
- @Override
- public void calcCosts(String costsId, InsAreaCompany insAreaCompany) {
- //获取协议信息
- PtlAgreement ptlAgreement = ptlAgreementService.getById(insAreaCompany.getAgreementId());
- InsOrders insOrders = insOrdersService.getById(insAreaCompany.getOrderno());
- SysUser sysUser = sysUserService.findByUserId(insOrders.getUserid());
- BigDecimal taxRadio = new BigDecimal("1.00");
- //如果是外部订单则 不含税
- if (ptlAgreement.getWithTax().equals("否") && ptlAgreement.getIsExternal() == 0) {
- taxRadio = new BigDecimal("1.06");
- }
- //税比例 固定1.06
- //查找入口与出口费用比例
- //入口配置
- PtlAgreementProductCostsNew ptlAgreementProductCostsNew = ptlAgreementProductCostsNewService.getById(costsId);
- ptlAgreementProductCostsNew.blank();
- //出口配置
- PtlAgreementProductCostsExport ptlAgreementProductCostsExport =
- ptlAgreementProductCostsExportService.getOne(new LambdaQueryWrapper<PtlAgreementProductCostsExport>().eq(PtlAgreementProductCostsExport::getCostsId, costsId));
- InsFeeOrderNew insFeeOrderNew = new InsFeeOrderNew();
- insFeeOrderNew.setId(IdGenerate.nextId());
- insFeeOrderNew.setCostsId(costsId);
- insFeeOrderNew.setAgreementId(insAreaCompany.getAgreementId());
- //存储部门id与用户id
- InsOrders order = insOrdersService.getById(insAreaCompany.getOrderno());
- InsFeeOrderNew insFeeOrderNewByCompanyId = insFeeOrderNewService.getInsFeeOrderNewByCompanyId(insAreaCompany.getId());
- if (insFeeOrderNewByCompanyId != null) {
- insFeeOrderNew.setId(insFeeOrderNewByCompanyId.getId());
- }
- insFeeOrderNew.setDeptId(order.getDeptid());
- insFeeOrderNew.setUserId(order.getUserid());
- insFeeOrderNew.setInsOrderNo(insAreaCompany.getId());
- insFeeOrderNew.setJqPremium(insAreaCompany.getJqpremium());
- insFeeOrderNew.setSyPremium(insAreaCompany.getSypremium());
- insFeeOrderNew.setNoPremium(insAreaCompany.getJypremium());
- //不含税
- BigDecimal bigDecimal = new BigDecimal("1.06");
- insFeeOrderNew.setJqNoTaxPremium(insAreaCompany.getJqpremium().divide(bigDecimal, 2));
- insFeeOrderNew.setSyNoTaxPremium(insAreaCompany.getSypremium().divide(bigDecimal, 2));
- insFeeOrderNew.setNoNoTaxPremium(insAreaCompany.getJypremium().divide(bigDecimal, 2));
- //region 计算入口费用
- //交强入口信息
- FeeOrderNewVo.EntranceFee jqEntranceFee = feeRuleSchemeService.calcEntranceFee(
- insFeeOrderNew.getJqPremium(),
- new BigDecimal(ptlAgreementProductCostsNew.getJqCarCostsProportion()),
- new BigDecimal(ptlAgreementProductCostsNew.getJqCarOtherCostsProportion()),
- taxRadio);
- insFeeOrderNew.setJqCostsProportion(jqEntranceFee.getTotalProportion());
- insFeeOrderNew.setJqSuperviseCostsProportion(jqEntranceFee.getSuperviseCosts());
- insFeeOrderNew.setJqSuperviseCostsPremiums(jqEntranceFee.getSuperviseCostsPremiums());
- insFeeOrderNew.setJqOtherCostsProportion(jqEntranceFee.getOtherCostsProportion());
- insFeeOrderNew.setJqOtherCostsPremiums(jqEntranceFee.getOtherCostsPremiums());
- insFeeOrderNew.setJqCostsPremiums(insFeeOrderNew.getJqSuperviseCostsPremiums().add(insFeeOrderNew.getJqOtherCostsPremiums()));
- //商业入口信息
- FeeOrderNewVo.EntranceFee syEntranceFee = feeRuleSchemeService.calcEntranceFee(insFeeOrderNew.getSyPremium(),
- new BigDecimal(ptlAgreementProductCostsNew.getSyCarCostsProportion()) ,
- new BigDecimal(ptlAgreementProductCostsNew.getSyCarOtherCostsProportion()), taxRadio);
- insFeeOrderNew.setSyCostsProportion(syEntranceFee.getTotalProportion());
- insFeeOrderNew.setSySuperviseCostsProportion(syEntranceFee.getSuperviseCosts());
- insFeeOrderNew.setSySuperviseCostsPremiums(syEntranceFee.getSuperviseCostsPremiums());
- insFeeOrderNew.setSyOtherCostsProportion(syEntranceFee.getOtherCostsProportion());
- insFeeOrderNew.setSyOtherCostsPremiums(syEntranceFee.getOtherCostsPremiums());
- insFeeOrderNew.setSyCostsPremiums(insFeeOrderNew.getSySuperviseCostsPremiums().add(insFeeOrderNew.getSyOtherCostsPremiums()));
- //非车入口信息
- FeeOrderNewVo.EntranceFee noEntranceFee = feeRuleSchemeService.calcEntranceFee(insFeeOrderNew.getNoPremium(),
- new BigDecimal(ptlAgreementProductCostsNew.getNoCarCostsProportion()),
- new BigDecimal(ptlAgreementProductCostsNew.getNoCarOtherCostsProportion()), taxRadio);
- insFeeOrderNew.setNoCostsProportion(noEntranceFee.getTotalProportion());
- insFeeOrderNew.setNoSuperviseCostsProportion(noEntranceFee.getSuperviseCosts());
- insFeeOrderNew.setNoSuperviseCostsPremiums(noEntranceFee.getSuperviseCostsPremiums());
- insFeeOrderNew.setNoOtherCostsProportion(noEntranceFee.getOtherCostsProportion());
- insFeeOrderNew.setNoOtherCostsPremiums(noEntranceFee.getOtherCostsPremiums());
- insFeeOrderNew.setNoCostsPremiums(insFeeOrderNew.getNoSuperviseCostsPremiums().add(insFeeOrderNew.getNoOtherCostsPremiums()));
- //endregion
- //region 重新计算管理费比例和分销比例
- List<EsmRetail> esmRetailList = esmRetailService.selectList(" where t.deptid=? and t.status = '1' ",
- new Object[]{sysUser.getDeptId()});
- Integer retailLevel = 0;
- //默认分销比例设置
- RetailProportion retailProportion = new RetailProportion();
- if (!Objects.isNull(esmRetailList) && !esmRetailList.isEmpty()) {
- retailLevel = Integer.parseInt(esmRetailList.get(0).getRetailtype());
- //赋值默认的分销比例
- retailProportion.setProportion(esmRetailList.get(0).getDisrate1(), esmRetailList.get(0).getDisrate2(), esmRetailList.get(0).getDisrate3());
- }
- //获取交强机构管理费总比例
- BigDecimal jqDeptProportion = ptlAgreementProductCostsExport.getJqExportRadioLevel1()
- .add(ptlAgreementProductCostsExport.getJqExportRadioLevel2())
- .add(ptlAgreementProductCostsExport.getJqExportRadioLevel3())
- .add(ptlAgreementProductCostsExport.getJqExportRadioLevel4())
- .add(ptlAgreementProductCostsExport.getJqExportRadioLevel5());
- //获取商业机构管理费总比例
- BigDecimal syDeptProportion = ptlAgreementProductCostsExport.getSyExportRadioLevel1()
- .add(ptlAgreementProductCostsExport.getSyExportRadioLevel2())
- .add(ptlAgreementProductCostsExport.getSyExportRadioLevel3())
- .add(ptlAgreementProductCostsExport.getSyExportRadioLevel4())
- .add(ptlAgreementProductCostsExport.getSyExportRadioLevel5());
- //获取非车机构管理费总比例
- BigDecimal noDeptProportion = ptlAgreementProductCostsExport.getNoCarExportRadioLevel1()
- .add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel2())
- .add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel3())
- .add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel4())
- .add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel5());
- //获取交强分销总比例
- BigDecimal jqRetailProportion = retailProportion.getJqRetailLevel1Proportion()
- .add(retailProportion.getJqRetailLevel2Proportion())
- .add(retailProportion.getJqRetailLevel3Proportion());
- //获取商业分销总比例
- BigDecimal syRetailProportion = retailProportion.getSyRetailLevel1Proportion()
- .add(retailProportion.getSyRetailLevel2Proportion())
- .add(retailProportion.getSyRetailLevel3Proportion());
- //获取非车分销总比例
- BigDecimal noRetailProportion = retailProportion.getNoRetailLevel1Proportion()
- .add(retailProportion.getNoRetailLevel2Proportion())
- .add(retailProportion.getNoRetailLevel3Proportion());
- // 外部订单比例
- BigDecimal enterProportion = sysSwitchConfigService.getEnterProportion(insOrders.getDeptid(), insOrders.getEntryStatus());
- //重新计算比例 入口是否超出支付的比例
- ReCalcuLateProportion jqReCalcuLateProportion = recalculateProportion(
- new BigDecimal(ptlAgreementProductCostsNew.getJqCostsProportion()),
- jqDeptProportion,
- jqRetailProportion,
- taxRadio,
- retailLevel,
- ptlAgreementProductCostsExport,
- retailProportion,
- "jq",
- enterProportion
- );
- ReCalcuLateProportion syReCalcuLateProportion = recalculateProportion(
- new BigDecimal(ptlAgreementProductCostsNew.getSyCostsProportion()),
- syDeptProportion,
- syRetailProportion,
- taxRadio,
- retailLevel,
- ptlAgreementProductCostsExport,
- retailProportion,
- "sy",
- enterProportion
- );
- ReCalcuLateProportion noReCalcuLateProportion = recalculateProportion(
- new BigDecimal(ptlAgreementProductCostsNew.getNoCostsProportion()),
- noDeptProportion,
- noRetailProportion,
- taxRadio,
- retailLevel,
- ptlAgreementProductCostsExport,
- retailProportion,
- "no",
- enterProportion
- );
- retailProportion.setProportion(jqReCalcuLateProportion, syReCalcuLateProportion, noReCalcuLateProportion);
- // ptlAgreementProductCostsExportService.updateById(ptlAgreementProductCostsExport);
- //endregion
- //region 计算分销费用
- //获取分销比例
- //分销总比例
- BigDecimal jqRetailRadio = new BigDecimal("0");
- BigDecimal syRetailRadio = new BigDecimal("0");
- BigDecimal noRetailRadio = new BigDecimal("0");
- FeeOrderNewVo.RetailFee retailFeeLevel3 = new FeeOrderNewVo.RetailFee();
- FeeOrderNewVo.RetailFee retailFeeLevel2 = new FeeOrderNewVo.RetailFee();
- FeeOrderNewVo.RetailFee retailFeeLevel1 = new FeeOrderNewVo.RetailFee();
- if (esmRetailList != null && !esmRetailList.isEmpty()) {
- EsmRetail esmRetail = esmRetailList.get(0);
- //分销等级
- insFeeOrderNew.setDistributionStatus(esmRetailList.get(0).getRetailtype());
- //用户分销人员id
- List<EsmUserReferrer> parents = esmUserReferrerService.findParents(sysUser.getId());
- if (esmRetail != null) {
- if (Integer.parseInt(esmRetail.getRetailtype()) >= 3) {
- insFeeOrderNew.setThirdDetailProportion(retailProportion.getJqRetailLevel3Proportion());
- retailFeeLevel3 = feeRuleSchemeService.calcRetail(insFeeOrderNew.getJqPremium(),
- insFeeOrderNew.getJqCostsProportion(),
- insFeeOrderNew.getSyPremium(),
- insFeeOrderNew.getSyCostsProportion().add(insFeeOrderNew.getSyOtherCostsProportion()),
- insFeeOrderNew.getNoPremium(),
- insFeeOrderNew.getNoCostsProportion().add(insFeeOrderNew.getNoOtherCostsProportion()),
- retailProportion.getJqRetailLevel3Proportion(),
- retailProportion.getSyRetailLevel3Proportion(),
- retailProportion.getNoRetailLevel3Proportion());
- insFeeOrderNew.setThirdDetailPremiums(retailFeeLevel3.getTotalRetailPremiums());
- if (parents != null && parents.size() > 2) {
- insFeeOrderNew.setThreeLevelUserId(parents.get(2).getId());
- }
- } else {
- insFeeOrderNew.setThirdDetailProportion(new BigDecimal(0));
- }
- if (Integer.parseInt(esmRetail.getRetailtype()) >= 2) {
- insFeeOrderNew.setSecondDetailProportion(retailProportion.getJqRetailLevel2Proportion());
- retailFeeLevel2 = feeRuleSchemeService.calcRetail(insFeeOrderNew.getJqPremium(),
- insFeeOrderNew.getJqCostsProportion(),
- insFeeOrderNew.getSyPremium(),
- insFeeOrderNew.getSyCostsProportion(),
- insFeeOrderNew.getNoPremium(),
- insFeeOrderNew.getNoCostsProportion(),
- retailProportion.getJqRetailLevel2Proportion(),
- retailProportion.getSyRetailLevel2Proportion(),
- retailProportion.getNoRetailLevel2Proportion());
- insFeeOrderNew.setSecondDetailPremiums(retailFeeLevel2.getTotalRetailPremiums());
- if (parents != null && parents.size() > 1) {
- insFeeOrderNew.setTwoLevelUserId(parents.get(1).getId());
- }
- } else {
- insFeeOrderNew.setSecondDetailProportion(new BigDecimal(0));
- }
- if (Integer.parseInt(esmRetail.getRetailtype()) >= 1) {
- insFeeOrderNew.setFirstDetailProportion(retailProportion.getJqRetailLevel1Proportion());
- retailFeeLevel1 = feeRuleSchemeService.calcRetail(insFeeOrderNew.getJqPremium(),
- insFeeOrderNew.getJqCostsProportion(),
- insFeeOrderNew.getSyPremium(),
- insFeeOrderNew.getSyCostsProportion(),
- insFeeOrderNew.getNoPremium(),
- insFeeOrderNew.getNoCostsProportion(),
- retailProportion.getJqRetailLevel1Proportion(),
- retailProportion.getSyRetailLevel1Proportion(),
- retailProportion.getNoRetailLevel1Proportion());
- insFeeOrderNew.setFirstDetailPremiums(retailFeeLevel1.getTotalRetailPremiums());
- if (parents != null && !parents.isEmpty()) {
- insFeeOrderNew.setFirstLevelUserId(parents.get(0).getId());
- }
- } else {
- insFeeOrderNew.setFirstDetailProportion(new BigDecimal(0));
- }
- } else {
- insFeeOrderNew.setFirstDetailPremiums(new BigDecimal(0));
- insFeeOrderNew.setSecondDetailPremiums(new BigDecimal(0));
- insFeeOrderNew.setThirdDetailPremiums(new BigDecimal(0));
- }
- } else {
- insFeeOrderNew.setFirstDetailProportion(new BigDecimal(0));
- insFeeOrderNew.setSecondDetailProportion(new BigDecimal(0));
- insFeeOrderNew.setThirdDetailProportion(new BigDecimal(0));
- }
- jqRetailRadio = jqRetailRadio.add(retailFeeLevel1.getJqRetailProportion())
- .add(retailFeeLevel2.getJqRetailProportion())
- .add(retailFeeLevel3.getJqRetailProportion());
- syRetailRadio = syRetailRadio.add(retailFeeLevel1.getSyRetailProportion())
- .add(retailFeeLevel2.getSyRetailProportion())
- .add(retailFeeLevel3.getSyRetailProportion());
- noRetailRadio = noRetailRadio.add(retailFeeLevel1.getNoRetailProportion())
- .add(retailFeeLevel2.getNoRetailProportion())
- .add(retailFeeLevel3.getNoRetailProportion());
- insFeeOrderNew.assignRetail(retailFeeLevel1, retailFeeLevel2, retailFeeLevel3);
- //endregion
- //region 设置机构管理费
- //交强机构管理费
- BigDecimal jqDeptRadio =
- jqReCalcuLateProportion.getDept_level_1_proportion()
- .add(jqReCalcuLateProportion.getDept_level_2_proportion())
- .add(jqReCalcuLateProportion.getDept_level_3_proportion())
- .add(jqReCalcuLateProportion.getDept_level_4_proportion())
- .add(jqReCalcuLateProportion.getDept_level_5_proportion());
- FeeOrderNewVo.DeptManagerFee jqDeptManagerFee = feeRuleSchemeService.calcDeptManagerFee(
- insFeeOrderNew.getJqPremium(),
- jqReCalcuLateProportion.getDept_level_1_proportion(),
- jqReCalcuLateProportion.getDept_level_2_proportion(),
- jqReCalcuLateProportion.getDept_level_3_proportion(),
- jqReCalcuLateProportion.getDept_level_4_proportion(),
- jqReCalcuLateProportion.getDept_level_5_proportion());
- BigDecimal syDeptRadio =
- syReCalcuLateProportion.getDept_level_1_proportion()
- .add(syReCalcuLateProportion.getDept_level_2_proportion())
- .add(syReCalcuLateProportion.getDept_level_3_proportion())
- .add(syReCalcuLateProportion.getDept_level_4_proportion())
- .add(syReCalcuLateProportion.getDept_level_5_proportion());
- FeeOrderNewVo.DeptManagerFee syDeptManagerFee = feeRuleSchemeService.calcDeptManagerFee(
- insFeeOrderNew.getSyPremium(),
- syReCalcuLateProportion.getDept_level_1_proportion(),
- syReCalcuLateProportion.getDept_level_2_proportion(),
- syReCalcuLateProportion.getDept_level_3_proportion(),
- syReCalcuLateProportion.getDept_level_4_proportion(),
- syReCalcuLateProportion.getDept_level_5_proportion());
- BigDecimal noDeptRadio =
- noReCalcuLateProportion.getDept_level_1_proportion()
- .add(noReCalcuLateProportion.getDept_level_2_proportion())
- .add(noReCalcuLateProportion.getDept_level_3_proportion())
- .add(noReCalcuLateProportion.getDept_level_4_proportion())
- .add(noReCalcuLateProportion.getDept_level_5_proportion());
- FeeOrderNewVo.DeptManagerFee noDeptManagerFee = feeRuleSchemeService.calcDeptManagerFee(
- insFeeOrderNew.getNoPremium(),
- noReCalcuLateProportion.getDept_level_1_proportion(),
- noReCalcuLateProportion.getDept_level_2_proportion(),
- noReCalcuLateProportion.getDept_level_3_proportion(),
- noReCalcuLateProportion.getDept_level_4_proportion(),
- noReCalcuLateProportion.getDept_level_5_proportion());
- insFeeOrderNew.assignDept(jqDeptManagerFee, syDeptManagerFee, noDeptManagerFee);
- //endregion
- //region 出口费用
- //交强出口手续费比例
- FeeOrderNewVo.ExportFee jqExportFee = feeRuleSchemeService.calcExportFee(
- insFeeOrderNew.getJqPremium(),
- new BigDecimal(ptlAgreementProductCostsNew.getJqCostsExportProportion()),
- insFeeOrderNew.getJqCostsProportion(),
- jqDeptRadio,
- jqRetailRadio,
- taxRadio,
- jqReCalcuLateProportion.getProxyProportion()
- );
- //商业出口手续费比例
- FeeOrderNewVo.ExportFee syExportFee = feeRuleSchemeService.calcExportFee(
- insFeeOrderNew.getSyPremium(),
- new BigDecimal(ptlAgreementProductCostsNew.getSyCostsExportProportion()),
- insFeeOrderNew.getSyCostsProportion(),
- syDeptRadio,
- syRetailRadio,
- taxRadio,
- syReCalcuLateProportion.getProxyProportion()
- );
- //非车出口手续费比例
- FeeOrderNewVo.ExportFee noExportFee = feeRuleSchemeService.calcExportFee(
- insFeeOrderNew.getNoPremium(),
- new BigDecimal(ptlAgreementProductCostsNew.getNoCostsExportProportion()),
- insFeeOrderNew.getNoCostsProportion(),
- noDeptRadio,
- noRetailRadio,
- taxRadio,
- noReCalcuLateProportion.getProxyProportion()
- );
- //出口手续费用
- insFeeOrderNew.setJqExportSuperviseCostsPremiums(twoPeople(jqExportFee.getSuperviseCostsPremiums()));
- insFeeOrderNew.setSyExportSuperviseCostsPremiums(twoPeople(syExportFee.getSuperviseCostsPremiums()));
- insFeeOrderNew.setNoExportSuperviseCostsPremiums(twoPeople(noExportFee.getSuperviseCostsPremiums()));
- //出口其他费用比例
- insFeeOrderNew.setJqExportOtherCostsProportion(twoPeople(jqExportFee.getOtherCostsProportion()));
- insFeeOrderNew.setSyExportOtherCostsProportion(twoPeople(syExportFee.getOtherCostsProportion()));
- insFeeOrderNew.setNoExportOtherCostsProportion(twoPeople(noExportFee.getOtherCostsProportion()));
- //出口其他费用
- insFeeOrderNew.setJqExportOtherCostsPremiums(twoPeople(jqExportFee.getOtherCostsPremiums()));
- insFeeOrderNew.setSyExportOtherCostsPremiums(twoPeople(syExportFee.getOtherCostsPremiums()));
- insFeeOrderNew.setNoExportOtherCostsPremiums(twoPeople(noExportFee.getOtherCostsPremiums()));
- //设置出口手续费比例
- insFeeOrderNew.setJqCostsExportProportion(twoPeople(jqExportFee.getSuperviseCosts()));
- insFeeOrderNew.setSyCostsExportProportion(twoPeople(syExportFee.getSuperviseCosts()));
- insFeeOrderNew.setNoCostsExportProportion(twoPeople(noExportFee.getSuperviseCosts()));
- // 外部费用
- insFeeOrderNew.setJqExternalProportion(jqExportFee.getExternalProportion());
- insFeeOrderNew.setJqExternalPremiums(jqExportFee.getExternalPremiums());
- insFeeOrderNew.setSyExternalProportion(syExportFee.getExternalProportion());
- insFeeOrderNew.setSyExternalPremiums(syExportFee.getExternalPremiums());
- insFeeOrderNew.setNoExternalProportion(noExportFee.getExternalProportion());
- insFeeOrderNew.setNoExternalPremiums(noExportFee.getExternalPremiums());
- //endregion
- //region 计算利润差值
- //入口 - 出口 - 机构管理费 1-5级 - 分销费 = 差值
- //分销交强费用
- //分开算 1 2 3 级
- BigDecimal jqFirst = insFeeOrderNew.getJqPremium().multiply(insFeeOrderNew.getJqRetailProportionLevel1().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- BigDecimal jqSecond = insFeeOrderNew.getJqPremium().multiply(insFeeOrderNew.getJqRetailProportionLevel2().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- BigDecimal jqThird = insFeeOrderNew.getJqPremium().multiply(insFeeOrderNew.getJqRetailProportionLevel3().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- BigDecimal jqFenXiao = jqFirst.add(jqSecond).add(jqThird);
- //分销商业费用
- BigDecimal syFirst = insFeeOrderNew.getSyPremium().multiply(insFeeOrderNew.getSyRetailProportionLevel1().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- BigDecimal sySecond = insFeeOrderNew.getSyPremium().multiply(insFeeOrderNew.getSyRetailProportionLevel2().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- BigDecimal syThird = insFeeOrderNew.getSyPremium().multiply(insFeeOrderNew.getSyRetailProportionLevel3().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- BigDecimal syFenXiao = syFirst.add(sySecond).add(syThird);
- //分销非车费用
- BigDecimal noFirst = insFeeOrderNew.getNoPremium().multiply(insFeeOrderNew.getNoRetailProportionLevel1().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- BigDecimal noSecond = insFeeOrderNew.getNoPremium().multiply(insFeeOrderNew.getNoRetailProportionLevel2().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- BigDecimal noThird = insFeeOrderNew.getNoPremium().multiply(insFeeOrderNew.getNoRetailProportionLevel3().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- BigDecimal noFenXiao = noFirst.add(noSecond).add(noThird);
- BigDecimal jqDifference = jqEntranceFee.getTotalAmount()
- .subtract(jqExportFee.getExternalPremiums())
- .subtract(
- (jqExportFee.getSuperviseCostsPremiums().add(jqExportFee.getOtherCostsPremiums())))
- .subtract(
- (jqDeptManagerFee.getDeptPremiumsLevelOne().add(jqDeptManagerFee.getDeptPremiumsLevelTwo().add(jqDeptManagerFee.getDeptPremiumsLevelThree()).add(jqDeptManagerFee.getDeptPremiumsLevelFoure()).add(jqDeptManagerFee.getDeptPremiumsLevelFive())))
- )
- .subtract(jqFenXiao)
- .setScale(5, BigDecimal.ROUND_HALF_DOWN);
- insFeeOrderNew.setJqProfitMarginPremiums(jqDifference);
- BigDecimal syDifference = syEntranceFee.getTotalAmount()
- .subtract(syExportFee.getExternalPremiums())
- .subtract(
- (syExportFee.getSuperviseCostsPremiums().add(syExportFee.getOtherCostsPremiums())))
- .subtract(
- (syDeptManagerFee.getDeptPremiumsLevelOne().add(syDeptManagerFee.getDeptPremiumsLevelTwo().add(syDeptManagerFee.getDeptPremiumsLevelThree()).add(syDeptManagerFee.getDeptPremiumsLevelFoure()).add(syDeptManagerFee.getDeptPremiumsLevelFive())))
- )
- .subtract(syFenXiao)
- .setScale(5, BigDecimal.ROUND_HALF_DOWN);
- insFeeOrderNew.setSyProfitMarginPremiums(syDifference);
- BigDecimal noDifference = noEntranceFee.getTotalAmount()
- .subtract(noExportFee.getExternalPremiums())
- .subtract(
- (noExportFee.getSuperviseCostsPremiums().add(noExportFee.getOtherCostsPremiums())))
- .subtract(
- (noDeptManagerFee.getDeptPremiumsLevelOne().add(noDeptManagerFee.getDeptPremiumsLevelTwo().add(noDeptManagerFee.getDeptPremiumsLevelThree()).add(noDeptManagerFee.getDeptPremiumsLevelFoure()).add(noDeptManagerFee.getDeptPremiumsLevelFive())))
- )
- .subtract(noFenXiao)
- .setScale(5, BigDecimal.ROUND_HALF_DOWN);
- insFeeOrderNew.setNoProfitMarginPremiums(noDifference);
- //endregion
- //region 比例逆推是否等于0
- if (!feeRuleSchemeService.calculateProportion(jqEntranceFee, jqDeptManagerFee, jqExportFee, jqRetailRadio, taxRadio, insFeeOrderNew.getJqPremium()))
- throw new SystemException("交强比例异常");
- if (!feeRuleSchemeService.calculateProportion(syEntranceFee, syDeptManagerFee, syExportFee, syRetailRadio, taxRadio, insFeeOrderNew.getSyPremium()))
- throw new SystemException("商业比例异常");
- if (!feeRuleSchemeService.calculateProportion(noEntranceFee, noDeptManagerFee, noExportFee, noRetailRadio, taxRadio, insFeeOrderNew.getNoPremium()))
- throw new SystemException("非车比例异常");
- //endregion
- sysChannelGroupService.costCompute(insFeeOrderNew,ptlAgreement,ptlAgreementProductCostsNew,sysUser,insAreaCompany,insOrders);
- insFeeOrderNewService.saveOrUpdate(insFeeOrderNew);
- }
- /**
- * 计算费用测试方法 没有数据库保存操作 只带入值进行计算核对
- *
- * @param costsId
- * @param insAreaCompany
- */
- @Override
- public void calcCostsTest(String costsId, InsAreaCompany insAreaCompany) {
- // //获取协议信息
- // PtlAgreement ptlAgreement = ptlAgreementService.getById(insAreaCompany.getAgreementId());
- // BigDecimal taxRadio = new BigDecimal("1.00");
- // //如果是外部订单则 不含税
- // if (ptlAgreement.getWithTax().equals("否") && ptlAgreement.getIsExternal() == 0) {
- // taxRadio = new BigDecimal("1.06");
- // }
- // //税比例 固定1.06
- // //查找入口与出口费用比例
- // //入口配置
- // PtlAgreementProductCostsNew ptlAgreementProductCostsNew = ptlAgreementProductCostsNewService.getById(costsId);
- //
- // //出口配置
- // PtlAgreementProductCostsExport ptlAgreementProductCostsExport =
- // ptlAgreementProductCostsExportService.getOne(new LambdaQueryWrapper<PtlAgreementProductCostsExport>().eq(PtlAgreementProductCostsExport::getCostsId, costsId));
- // InsFeeOrderNew insFeeOrderNew = new InsFeeOrderNew();
- // insFeeOrderNew.setId(IdGenerate.nextId());
- // insFeeOrderNew.setCostsId(costsId);
- // insFeeOrderNew.setAgreementId(insAreaCompany.getAgreementId());
- //
- // //存储部门id与用户id
- // InsOrders order = insOrdersService.getById(insAreaCompany.getOrderno());
- // InsFeeOrderNew insFeeOrderNewByCompanyId = insFeeOrderNewService.getInsFeeOrderNewByCompanyId(insAreaCompany.getId());
- // if (insFeeOrderNewByCompanyId != null) {
- // insFeeOrderNew.setId(insFeeOrderNewByCompanyId.getId());
- // }
- // insFeeOrderNew.setDeptId(order.getDeptid());
- // insFeeOrderNew.setUserId(order.getUserid());
- // insFeeOrderNew.setInsOrderNo(insAreaCompany.getId());
- // insFeeOrderNew.setJqPremium(insAreaCompany.getJqpremium());
- // insFeeOrderNew.setSyPremium(insAreaCompany.getSypremium());
- // insFeeOrderNew.setNoPremium(insAreaCompany.getJypremium());
- // //不含税
- // BigDecimal bigDecimal = new BigDecimal("1.06");
- // insFeeOrderNew.setJqNoTaxPremium(insAreaCompany.getJqpremium().divide(bigDecimal, 2));
- // insFeeOrderNew.setSyNoTaxPremium(insAreaCompany.getSypremium().divide(bigDecimal, 2));
- // insFeeOrderNew.setNoNoTaxPremium(insAreaCompany.getJypremium().divide(bigDecimal, 2));
- //
- // //region 计算入口费用
- //
- // //交强入口信息
- // FeeOrderNewVo.EntranceFee jqEntranceFee = feeRuleSchemeService.calcEntranceFee(insFeeOrderNew.getJqPremium(),
- // new BigDecimal(ptlAgreementProductCostsNew.getJqCarCostsProportion()),
- // new BigDecimal(ptlAgreementProductCostsNew.getJqCarOtherCostsProportion()), taxRadio);
- // insFeeOrderNew.setJqCostsProportion(jqEntranceFee.getTotalProportion());
- // insFeeOrderNew.setJqSuperviseCostsProportion(jqEntranceFee.getSuperviseCosts());
- // insFeeOrderNew.setJqSuperviseCostsPremiums(jqEntranceFee.getSuperviseCostsPremiums());
- // insFeeOrderNew.setJqOtherCostsProportion(jqEntranceFee.getOtherCostsProportion());
- // insFeeOrderNew.setJqOtherCostsPremiums(jqEntranceFee.getOtherCostsPremiums());
- // insFeeOrderNew.setJqCostsPremiums(insFeeOrderNew.getJqSuperviseCostsPremiums().add(insFeeOrderNew.getJqOtherCostsPremiums()));
- //
- // //商业入口信息
- // FeeOrderNewVo.EntranceFee syEntranceFee = feeRuleSchemeService.calcEntranceFee(insFeeOrderNew.getSyPremium(),
- // new BigDecimal(ptlAgreementProductCostsNew.getSyCarCostsProportion()),
- // new BigDecimal(ptlAgreementProductCostsNew.getSyCarOtherCostsProportion()), taxRadio);
- // insFeeOrderNew.setSyCostsProportion(syEntranceFee.getTotalProportion());
- // insFeeOrderNew.setSySuperviseCostsProportion(syEntranceFee.getSuperviseCosts());
- // insFeeOrderNew.setSySuperviseCostsPremiums(syEntranceFee.getSuperviseCostsPremiums());
- // insFeeOrderNew.setSyOtherCostsProportion(syEntranceFee.getOtherCostsProportion());
- // insFeeOrderNew.setSyOtherCostsPremiums(syEntranceFee.getOtherCostsPremiums());
- // insFeeOrderNew.setSyCostsPremiums(insFeeOrderNew.getSySuperviseCostsPremiums().add(insFeeOrderNew.getSyOtherCostsPremiums()));
- //
- // //非车入口信息
- // FeeOrderNewVo.EntranceFee noEntranceFee = feeRuleSchemeService.calcEntranceFee(insFeeOrderNew.getNoPremium(),
- // new BigDecimal(ptlAgreementProductCostsNew.getNoCarCostsProportion()),
- // new BigDecimal(ptlAgreementProductCostsNew.getNoCarOtherCostsProportion()), taxRadio);
- // insFeeOrderNew.setNoCostsProportion(noEntranceFee.getTotalProportion());
- // insFeeOrderNew.setNoSuperviseCostsProportion(noEntranceFee.getSuperviseCosts());
- // insFeeOrderNew.setNoSuperviseCostsPremiums(noEntranceFee.getSuperviseCostsPremiums());
- // insFeeOrderNew.setNoOtherCostsProportion(noEntranceFee.getOtherCostsProportion());
- // insFeeOrderNew.setNoOtherCostsPremiums(noEntranceFee.getOtherCostsPremiums());
- // insFeeOrderNew.setNoCostsPremiums(insFeeOrderNew.getNoSuperviseCostsPremiums().add(insFeeOrderNew.getNoOtherCostsPremiums()));
- // //endregion
- //
- // //region 计算分销费用
- // InsOrders insOrders = insOrdersService.getById(insAreaCompany.getOrderno());
- // SysUser sysUser = sysUserService.findByUserId(insOrders.getUserid());
- //
- // //获取分销比例
- // List<EsmRetail> esmRetailList = esmRetailService.selectList(" where t.deptid=? and t.status = '1' ",
- // new Object[]{sysUser.getDeptId()});
- //
- // //分销总比例
- // BigDecimal retailRadio = new BigDecimal("0");
- // if (esmRetailList != null && !esmRetailList.isEmpty()) {
- // EsmRetail esmRetail = esmRetailList.get(0);
- // //分销等级
- // insFeeOrderNew.setDistributionStatus(esmRetailList.get(0).getRetailtype());
- // //用户分销人员id
- // List<EsmUserReferrer> parents = esmUserReferrerService.findParents(sysUser.getId());
- //
- // if (esmRetail != null) {
- // BigDecimal sumPremium = insFeeOrderNew.getJqPremium().add(insFeeOrderNew.getSyPremium()).add(insFeeOrderNew.getNoPremium());
- // if (Integer.parseInt(esmRetail.getRetailtype()) >= 3) {
- // insFeeOrderNew.setThirdDetailProportion(new BigDecimal(String.valueOf(esmRetail.getDisrate3())));
- // retailRadio = retailRadio.add(insFeeOrderNew.getThirdDetailProportion()).setScale(2, BigDecimal.ROUND_DOWN);
- // BigDecimal thirdDetailPremiums = feeRuleSchemeService.calcRetail(insFeeOrderNew.getJqPremium(),
- // insFeeOrderNew.getJqCostsProportion().add(insFeeOrderNew.getJqOtherCostsProportion()),
- // insFeeOrderNew.getSyPremium(),
- // insFeeOrderNew.getSyCostsProportion().add(insFeeOrderNew.getSyOtherCostsProportion()),
- // insFeeOrderNew.getNoPremium(),
- // insFeeOrderNew.getNoCostsProportion().add(insFeeOrderNew.getNoOtherCostsProportion()),
- // insFeeOrderNew.getThirdDetailProportion());
- // insFeeOrderNew.setThirdDetailPremiums(thirdDetailPremiums);
- // if (parents != null && parents.size() > 2) {
- // insFeeOrderNew.setThreeLevelUserId(parents.get(2).getId());
- // }
- // }else{
- // insFeeOrderNew.setThirdDetailProportion(new BigDecimal(0));
- // }
- // if (Integer.parseInt(esmRetail.getRetailtype()) >= 2) {
- // insFeeOrderNew.setSecondDetailProportion(new BigDecimal(String.valueOf(esmRetail.getDisrate2())));
- // retailRadio = retailRadio.add(insFeeOrderNew.getSecondDetailProportion()).setScale(2, BigDecimal.ROUND_DOWN);
- // BigDecimal secondDetailPremiums = feeRuleSchemeService.calcRetail(insFeeOrderNew.getJqPremium(),
- // insFeeOrderNew.getJqCostsProportion().add(insFeeOrderNew.getJqOtherCostsProportion()),
- // insFeeOrderNew.getSyPremium(),
- // insFeeOrderNew.getSyCostsProportion().add(insFeeOrderNew.getSyOtherCostsProportion()),
- // insFeeOrderNew.getNoPremium(),
- // insFeeOrderNew.getNoCostsProportion().add(insFeeOrderNew.getNoOtherCostsProportion()),
- // insFeeOrderNew.getSecondDetailProportion());
- // insFeeOrderNew.setSecondDetailPremiums(secondDetailPremiums);
- // if (parents != null && parents.size() > 1) {
- // insFeeOrderNew.setTwoLevelUserId(parents.get(1).getId());
- // }
- // }else{
- // insFeeOrderNew.setSecondDetailProportion(new BigDecimal(0));
- // }
- // if (Integer.parseInt(esmRetail.getRetailtype()) >= 1) {
- // insFeeOrderNew.setFirstDetailProportion(new BigDecimal(String.valueOf(esmRetail.getDisrate1())));
- // retailRadio = retailRadio.add(insFeeOrderNew.getFirstDetailProportion()).setScale(2, BigDecimal.ROUND_DOWN);
- // BigDecimal firstDetailPremiums = feeRuleSchemeService.calcRetail(insFeeOrderNew.getJqPremium(),
- // insFeeOrderNew.getJqCostsProportion().add(insFeeOrderNew.getJqOtherCostsProportion()),
- // insFeeOrderNew.getSyPremium(),
- // insFeeOrderNew.getSyCostsProportion().add(insFeeOrderNew.getSyOtherCostsProportion()),
- // insFeeOrderNew.getNoPremium(),
- // insFeeOrderNew.getNoCostsProportion().add(insFeeOrderNew.getNoOtherCostsProportion()),
- // insFeeOrderNew.getFirstDetailProportion());
- // insFeeOrderNew.setFirstDetailPremiums(firstDetailPremiums);
- // if (parents != null && parents.size() > 0) {
- // insFeeOrderNew.setFirstLevelUserId(parents.get(0).getId());
- // }
- // }else{
- // insFeeOrderNew.setFirstDetailProportion(new BigDecimal(0));
- // }
- // }else{
- // insFeeOrderNew.setFirstDetailPremiums(new BigDecimal(0));
- // insFeeOrderNew.setSecondDetailPremiums(new BigDecimal(0));
- // insFeeOrderNew.setThirdDetailPremiums(new BigDecimal(0));
- // }
- // }else{
- // insFeeOrderNew.setFirstDetailProportion(new BigDecimal(0));
- // insFeeOrderNew.setSecondDetailProportion(new BigDecimal(0));
- // insFeeOrderNew.setThirdDetailProportion(new BigDecimal(0));
- // }
- //
- //
- // //endregion
- //
- // //region 设置机构管理费
- //
- // //交强机构管理费
- // BigDecimal jqDeptRadio =
- // ptlAgreementProductCostsExport.getJqExportRadioLevel1().add(ptlAgreementProductCostsExport.getJqExportRadioLevel2()).add(ptlAgreementProductCostsExport.getJqExportRadioLevel3()).add(ptlAgreementProductCostsExport.getJqExportRadioLevel4()).add(ptlAgreementProductCostsExport.getJqExportRadioLevel5());
- // FeeOrderNewVo.DeptManagerFee jqDeptManagerFee = feeRuleSchemeService.calcDeptManagerFee(insFeeOrderNew.getJqPremium(),
- // ptlAgreementProductCostsExport.getJqExportRadioLevel1(), ptlAgreementProductCostsExport.getJqExportRadioLevel2(),
- // ptlAgreementProductCostsExport.getJqExportRadioLevel3(), ptlAgreementProductCostsExport.getJqExportRadioLevel4(),
- // ptlAgreementProductCostsExport.getJqExportRadioLevel5());
- // insFeeOrderNew.setJqDeptProportionLevel1(jqDeptManagerFee.getDeptProportionLevelOne());
- // insFeeOrderNew.setJqDeptPremiumsLevel1(twoPeople(jqDeptManagerFee.getDeptPremiumsLevelOne()));
- // insFeeOrderNew.setJqDeptProportionLevel2(jqDeptManagerFee.getDeptProportionLevelTwo());
- // insFeeOrderNew.setJqDeptPremiumsLevel2(twoPeople(jqDeptManagerFee.getDeptPremiumsLevelTwo()));
- // insFeeOrderNew.setJqDeptProportionLevel3(jqDeptManagerFee.getDeptProportionLevelThree());
- // insFeeOrderNew.setJqDeptPremiumsLevel3(twoPeople(jqDeptManagerFee.getDeptPremiumsLevelThree()));
- // insFeeOrderNew.setJqDeptProportionLevel4(jqDeptManagerFee.getDeptProportionLevelFoure());
- // insFeeOrderNew.setJqDeptPremiumsLevel4(twoPeople(jqDeptManagerFee.getDeptPremiumsLevelFoure()));
- // insFeeOrderNew.setJqDeptProportionLevel5(jqDeptManagerFee.getDeptProportionLevelFive());
- // insFeeOrderNew.setJqDeptPremiumsLevel5(twoPeople(jqDeptManagerFee.getDeptPremiumsLevelFive()));
- //
- // BigDecimal syDeptRadio =
- // ptlAgreementProductCostsExport.getSyExportRadioLevel1().add(ptlAgreementProductCostsExport.getSyExportRadioLevel2()).add(ptlAgreementProductCostsExport.getSyExportRadioLevel3()).add(ptlAgreementProductCostsExport.getSyExportRadioLevel4()).add(ptlAgreementProductCostsExport.getSyExportRadioLevel5());
- // FeeOrderNewVo.DeptManagerFee syDeptManagerFee = feeRuleSchemeService.calcDeptManagerFee(insFeeOrderNew.getSyPremium(),
- // ptlAgreementProductCostsExport.getSyExportRadioLevel1(), ptlAgreementProductCostsExport.getSyExportRadioLevel2(),
- // ptlAgreementProductCostsExport.getSyExportRadioLevel3(), ptlAgreementProductCostsExport.getSyExportRadioLevel4(),
- // ptlAgreementProductCostsExport.getSyExportRadioLevel5());
- // insFeeOrderNew.setSyDeptProportionLevel1(syDeptManagerFee.getDeptProportionLevelOne());
- // insFeeOrderNew.setSyDeptPremiumsLevel1(twoPeople(syDeptManagerFee.getDeptPremiumsLevelOne()));
- // insFeeOrderNew.setSyDeptProportionLevel2(syDeptManagerFee.getDeptProportionLevelTwo());
- // insFeeOrderNew.setSyDeptPremiumsLevel2(twoPeople(syDeptManagerFee.getDeptPremiumsLevelTwo()));
- // insFeeOrderNew.setSyDeptProportionLevel3(syDeptManagerFee.getDeptProportionLevelThree());
- // insFeeOrderNew.setSyDeptPremiumsLevel3(twoPeople(syDeptManagerFee.getDeptPremiumsLevelThree()));
- // insFeeOrderNew.setSyDeptProportionLevel4(syDeptManagerFee.getDeptProportionLevelFoure());
- // insFeeOrderNew.setSyDeptPremiumsLevel4(twoPeople(syDeptManagerFee.getDeptPremiumsLevelFoure()));
- // insFeeOrderNew.setSyDeptProportionLevel5(syDeptManagerFee.getDeptProportionLevelFive());
- // insFeeOrderNew.setSyDeptPremiumsLevel5(twoPeople(syDeptManagerFee.getDeptPremiumsLevelFive()));
- //
- // BigDecimal noDeptRadio =
- // ptlAgreementProductCostsExport.getNoCarExportRadioLevel1().add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel2()).add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel3()).add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel4()).add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel5());
- // FeeOrderNewVo.DeptManagerFee noDeptManagerFee = feeRuleSchemeService.calcDeptManagerFee(insFeeOrderNew.getNoPremium(),
- // ptlAgreementProductCostsExport.getNoCarExportRadioLevel1(), ptlAgreementProductCostsExport.getNoCarExportRadioLevel2(),
- // ptlAgreementProductCostsExport.getNoCarExportRadioLevel3(), ptlAgreementProductCostsExport.getNoCarExportRadioLevel4(),
- // ptlAgreementProductCostsExport.getNoCarExportRadioLevel5());
- // insFeeOrderNew.setNoDeptProportionLevel1(noDeptManagerFee.getDeptProportionLevelOne());
- // insFeeOrderNew.setNoDeptPremiumsLevel1(twoPeople(noDeptManagerFee.getDeptPremiumsLevelOne()));
- // insFeeOrderNew.setNoDeptProportionLevel2(noDeptManagerFee.getDeptProportionLevelTwo());
- // insFeeOrderNew.setNoDeptPremiumsLevel2(twoPeople(noDeptManagerFee.getDeptPremiumsLevelTwo()));
- // insFeeOrderNew.setNoDeptProportionLevel3(noDeptManagerFee.getDeptProportionLevelThree());
- // insFeeOrderNew.setNoDeptPremiumsLevel3(twoPeople(noDeptManagerFee.getDeptPremiumsLevelThree()));
- // insFeeOrderNew.setNoDeptProportionLevel4(noDeptManagerFee.getDeptProportionLevelFoure());
- // insFeeOrderNew.setNoDeptPremiumsLevel4(twoPeople(noDeptManagerFee.getDeptPremiumsLevelFoure()));
- // insFeeOrderNew.setNoDeptProportionLevel5(noDeptManagerFee.getDeptProportionLevelFive());
- // insFeeOrderNew.setNoDeptPremiumsLevel5(twoPeople(noDeptManagerFee.getDeptPremiumsLevelFive()));
- //
- // //endregion
- //
- // //region 出口费用
- //
- // //交强出口手续费比例
- // FeeOrderNewVo.ExportFee jqExportFee = feeRuleSchemeService.calcExportFee(insFeeOrderNew.getJqPremium(), new BigDecimal(ptlAgreementProductCostsNew.getJqCostsExportProportion()),
- // insFeeOrderNew.getJqCostsProportion(), jqDeptRadio, retailRadio, taxRadio);
- //
- // //商业出口手续费比例
- // FeeOrderNewVo.ExportFee syExportFee = feeRuleSchemeService.calcExportFee(insFeeOrderNew.getSyPremium(), new BigDecimal(ptlAgreementProductCostsNew.getSyCostsExportProportion()),
- // insFeeOrderNew.getSyCostsProportion(), syDeptRadio, retailRadio, taxRadio);
- //
- // //非车出口手续费比例
- // FeeOrderNewVo.ExportFee noExportFee = feeRuleSchemeService.calcExportFee(insFeeOrderNew.getNoPremium(), new BigDecimal(ptlAgreementProductCostsNew.getNoCostsExportProportion()),
- // insFeeOrderNew.getNoCostsProportion(), noDeptRadio, retailRadio, taxRadio);
- //
- // //出口手续费用
- // insFeeOrderNew.setJqExportSuperviseCostsPremiums(twoPeople(jqExportFee.getSuperviseCostsPremiums()));
- // insFeeOrderNew.setSyExportSuperviseCostsPremiums(twoPeople(syExportFee.getSuperviseCostsPremiums()));
- // insFeeOrderNew.setNoExportSuperviseCostsPremiums(twoPeople(noExportFee.getSuperviseCostsPremiums()));
- //
- // //出口其他费用比例
- // insFeeOrderNew.setJqExportOtherCostsProportion(twoPeople(jqExportFee.getOtherCostsProportion()));
- // insFeeOrderNew.setSyExportOtherCostsProportion(twoPeople(syExportFee.getOtherCostsProportion()));
- // insFeeOrderNew.setNoExportOtherCostsProportion(twoPeople(noExportFee.getOtherCostsProportion()));
- //
- // //出口其他费用
- // insFeeOrderNew.setJqExportOtherCostsPremiums(twoPeople(jqExportFee.getOtherCostsPremiums()));
- // insFeeOrderNew.setSyExportOtherCostsPremiums(twoPeople(syExportFee.getOtherCostsPremiums()));
- // insFeeOrderNew.setNoExportOtherCostsPremiums(twoPeople(noExportFee.getOtherCostsPremiums()));
- //
- // //设置出口手续费比例
- // insFeeOrderNew.setJqCostsExportProportion(twoPeople(jqExportFee.getSuperviseCosts()));
- // insFeeOrderNew.setSyCostsExportProportion(twoPeople(syExportFee.getSuperviseCosts()));
- // insFeeOrderNew.setNoCostsExportProportion(twoPeople(noExportFee.getSuperviseCosts()));
- //
- // //endregion
- //
- // //region 计算利润差值
- // //入口 - 出口 - 机构管理费 1-5级 - 分销费 = 差值
- //
- // //分销交强费用
- // //分开算 1 2 3 级
- // BigDecimal jqFirst = insFeeOrderNew.getJqPremium().multiply(insFeeOrderNew.getFirstDetailProportion().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
- // BigDecimal jqSecond = insFeeOrderNew.getJqPremium().multiply(insFeeOrderNew.getSecondDetailProportion().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
- // BigDecimal jqThird = insFeeOrderNew.getJqPremium().multiply(insFeeOrderNew.getThirdDetailProportion().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
- // BigDecimal jqFenXiao = jqFirst.add(jqSecond).add(jqThird);
- // //分销商业费用
- // BigDecimal syFirst = insFeeOrderNew.getSyPremium().multiply(insFeeOrderNew.getFirstDetailProportion().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
- // BigDecimal sySecond = insFeeOrderNew.getSyPremium().multiply(insFeeOrderNew.getSecondDetailProportion().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
- // BigDecimal syThird = insFeeOrderNew.getSyPremium().multiply(insFeeOrderNew.getThirdDetailProportion().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
- // BigDecimal syFenXiao = syFirst.add(sySecond).add(syThird);
- // //分销非车费用
- // BigDecimal noFirst = insFeeOrderNew.getNoPremium().multiply(insFeeOrderNew.getFirstDetailProportion().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
- // BigDecimal noSecond = insFeeOrderNew.getNoPremium().multiply(insFeeOrderNew.getSecondDetailProportion().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
- // BigDecimal noThird = insFeeOrderNew.getNoPremium().multiply(insFeeOrderNew.getThirdDetailProportion().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
- // BigDecimal noFenXiao = noFirst.add(noSecond).add(noThird);
- //
- //
- // BigDecimal jqDifference = jqEntranceFee.getTotalAmount().subtract(
- // (jqExportFee.getSuperviseCostsPremiums().add(jqExportFee.getOtherCostsPremiums())))
- // .subtract(
- // (jqDeptManagerFee.getDeptPremiumsLevelOne().add(jqDeptManagerFee.getDeptPremiumsLevelTwo().add(jqDeptManagerFee.getDeptPremiumsLevelThree()).add(jqDeptManagerFee.getDeptPremiumsLevelFoure()).add(jqDeptManagerFee.getDeptPremiumsLevelFive())))
- // )
- // .subtract(jqFenXiao).setScale(5, BigDecimal.ROUND_HALF_DOWN);
- // insFeeOrderNew.setJqProfitMarginPremiums(jqDifference);
- //
- // BigDecimal syDifference = syEntranceFee.getTotalAmount().subtract(
- // (syExportFee.getSuperviseCostsPremiums().add(syExportFee.getOtherCostsPremiums())))
- // .subtract(
- // (syDeptManagerFee.getDeptPremiumsLevelOne().add(syDeptManagerFee.getDeptPremiumsLevelTwo().add(syDeptManagerFee.getDeptPremiumsLevelThree()).add(syDeptManagerFee.getDeptPremiumsLevelFoure()).add(syDeptManagerFee.getDeptPremiumsLevelFive())))
- // )
- // .subtract(syFenXiao).setScale(5, BigDecimal.ROUND_HALF_DOWN);
- // insFeeOrderNew.setSyProfitMarginPremiums(syDifference);
- //
- //
- // BigDecimal noDifference = noEntranceFee.getTotalAmount().subtract(
- // (noExportFee.getSuperviseCostsPremiums().add(noExportFee.getOtherCostsPremiums())))
- // .subtract(
- // (noDeptManagerFee.getDeptPremiumsLevelOne().add(noDeptManagerFee.getDeptPremiumsLevelTwo().add(noDeptManagerFee.getDeptPremiumsLevelThree()).add(noDeptManagerFee.getDeptPremiumsLevelFoure()).add(noDeptManagerFee.getDeptPremiumsLevelFive())))
- // )
- // .subtract(noFenXiao).setScale(5, BigDecimal.ROUND_HALF_DOWN);
- //
- // insFeeOrderNew.setNoProfitMarginPremiums(noDifference);
- //
- // //endregion
- //
- // //region 比例逆推是否等于0
- //
- // if(!feeRuleSchemeService.calculateProportion(jqEntranceFee,jqDeptManagerFee,jqExportFee,retailRadio,taxRadio,insFeeOrderNew.getJqPremium()))
- // throw new SystemException("交强比例异常");
- //
- // if(!feeRuleSchemeService.calculateProportion(syEntranceFee,syDeptManagerFee,syExportFee,retailRadio,taxRadio,insFeeOrderNew.getSyPremium()))
- // throw new SystemException("商业比例异常");
- //
- // if(!feeRuleSchemeService.calculateProportion(noEntranceFee,noDeptManagerFee,noExportFee,retailRadio,taxRadio,insFeeOrderNew.getNoPremium()))
- // throw new SystemException("非车比例异常");
- //endregion
- // insFeeOrderNewService.saveOrUpdate(insFeeOrderNew);
- }
- @Override
- public void calcCostsExternal(PtlAgreementProductCostsNew ptlAgreementProductCostsNew, InsAreaCompany insAreaCompany) {
- //获取协议信息
- // 外部订单比例
- ptlAgreementProductCostsNew.blank();
- PtlAgreement ptlAgreement = ptlAgreementService.getById(insAreaCompany.getAgreementId());
- InsOrders insOrders = insOrdersService.getById(insAreaCompany.getOrderno());
- SysUser sysUser = sysUserService.findByUserId(insOrders.getUserid());
- BigDecimal enterProportion = sysSwitchConfigService.getEnterProportion(insOrders.getDeptid(), insOrders.getEntryStatus());
- BigDecimal taxRadio = new BigDecimal("1.00");
- //如果是外部订单则 不含税
- if (ptlAgreement.getWithTax().equals("否")) {
- taxRadio = new BigDecimal("1.06");
- }
- //税比例 固定1.06
- //查找入口与出口费用比例
- //出口配置
- PtlAgreementProductCostsExport ptlAgreementProductCostsExport =
- ptlAgreementProductCostsExportService.getOne(new LambdaQueryWrapper<PtlAgreementProductCostsExport>().eq(PtlAgreementProductCostsExport::getCostsId, ptlAgreementProductCostsNew.getId()));
- InsFeeOrderNew insFeeOrderNew = new InsFeeOrderNew();
- insFeeOrderNew.setId(IdGenerate.nextId());
- insFeeOrderNew.setCostsId(ptlAgreementProductCostsNew.getId());
- insFeeOrderNew.setAgreementId(insAreaCompany.getAgreementId());
- //存储部门id与用户id
- InsOrders order = insOrdersService.getById(insAreaCompany.getOrderno());
- InsFeeOrderNew insFeeOrderNewByCompanyId = insFeeOrderNewService.getInsFeeOrderNewByCompanyId(insAreaCompany.getId());
- if (insFeeOrderNewByCompanyId != null) {
- insFeeOrderNew.setId(insFeeOrderNewByCompanyId.getId());
- }
- insFeeOrderNew.setDeptId(order.getDeptid());
- insFeeOrderNew.setUserId(order.getUserid());
- insFeeOrderNew.setInsOrderNo(insAreaCompany.getId());
- insFeeOrderNew.setJqPremium(insAreaCompany.getJqpremium());
- insFeeOrderNew.setSyPremium(insAreaCompany.getSypremium());
- insFeeOrderNew.setNoPremium(insAreaCompany.getJypremium());
- //不含税
- BigDecimal bigDecimal = new BigDecimal("1.06");
- insFeeOrderNew.setJqNoTaxPremium(insAreaCompany.getJqpremium().divide(bigDecimal, 2));
- insFeeOrderNew.setSyNoTaxPremium(insAreaCompany.getSypremium().divide(bigDecimal, 2));
- insFeeOrderNew.setNoNoTaxPremium(insAreaCompany.getJypremium().divide(bigDecimal, 2));
- //region 计算入口费用
- //交强入口信息
- FeeOrderNewVo.EntranceFee jqEntranceFee = feeRuleSchemeService.calcEntranceFee(insFeeOrderNew.getJqPremium(),
- new BigDecimal(ptlAgreementProductCostsNew.getJqCarCostsProportion()),
- new BigDecimal(ptlAgreementProductCostsNew.getJqCarOtherCostsProportion()), taxRadio);
- insFeeOrderNew.setJqCostsProportion(jqEntranceFee.getTotalProportion());
- insFeeOrderNew.setJqSuperviseCostsProportion(jqEntranceFee.getSuperviseCosts());
- insFeeOrderNew.setJqSuperviseCostsPremiums(jqEntranceFee.getSuperviseCostsPremiums());
- insFeeOrderNew.setJqOtherCostsProportion(jqEntranceFee.getOtherCostsProportion());
- insFeeOrderNew.setJqOtherCostsPremiums(jqEntranceFee.getOtherCostsPremiums());
- insFeeOrderNew.setJqCostsPremiums(insFeeOrderNew.getJqSuperviseCostsPremiums().add(insFeeOrderNew.getJqOtherCostsPremiums()));
- //商业入口信息
- FeeOrderNewVo.EntranceFee syEntranceFee = feeRuleSchemeService.calcEntranceFee(insFeeOrderNew.getSyPremium(),
- new BigDecimal(ptlAgreementProductCostsNew.getSyCarCostsProportion()),
- new BigDecimal(ptlAgreementProductCostsNew.getSyCarOtherCostsProportion()), taxRadio);
- insFeeOrderNew.setSyCostsProportion(syEntranceFee.getTotalProportion());
- insFeeOrderNew.setSySuperviseCostsProportion(syEntranceFee.getSuperviseCosts());
- insFeeOrderNew.setSySuperviseCostsPremiums(syEntranceFee.getSuperviseCostsPremiums());
- insFeeOrderNew.setSyOtherCostsProportion(syEntranceFee.getOtherCostsProportion());
- insFeeOrderNew.setSyOtherCostsPremiums(syEntranceFee.getOtherCostsPremiums());
- insFeeOrderNew.setSyCostsPremiums(insFeeOrderNew.getSySuperviseCostsPremiums().add(insFeeOrderNew.getSyOtherCostsPremiums()));
- //非车入口信息
- FeeOrderNewVo.EntranceFee noEntranceFee = feeRuleSchemeService.calcEntranceFee(insFeeOrderNew.getNoPremium(),
- new BigDecimal(ptlAgreementProductCostsNew.getNoCarCostsProportion()),
- new BigDecimal(ptlAgreementProductCostsNew.getNoCarOtherCostsProportion()), taxRadio);
- insFeeOrderNew.setNoCostsProportion(noEntranceFee.getTotalProportion());
- insFeeOrderNew.setNoSuperviseCostsProportion(noEntranceFee.getSuperviseCosts());
- insFeeOrderNew.setNoSuperviseCostsPremiums(noEntranceFee.getSuperviseCostsPremiums());
- insFeeOrderNew.setNoOtherCostsProportion(noEntranceFee.getOtherCostsProportion());
- insFeeOrderNew.setNoOtherCostsPremiums(noEntranceFee.getOtherCostsPremiums());
- insFeeOrderNew.setNoCostsPremiums(insFeeOrderNew.getNoSuperviseCostsPremiums().add(insFeeOrderNew.getNoOtherCostsPremiums()));
- //endregion
- //region 重新计算管理费比例和分销比例
- List<EsmRetail> esmRetailList = esmRetailService.selectList(" where t.deptid=? and t.status = '1' ",
- new Object[]{sysUser.getDeptId()});
- Integer retailLevel = 0;
- //默认分销比例设置
- RetailProportion retailProportion = new RetailProportion();
- if (!Objects.isNull(esmRetailList) && !esmRetailList.isEmpty()) {
- retailLevel = Integer.parseInt(esmRetailList.get(0).getRetailtype());
- //赋值默认的分销比例
- retailProportion.setProportion(esmRetailList.get(0).getDisrate1(), esmRetailList.get(0).getDisrate2(), esmRetailList.get(0).getDisrate3());
- }
- //获取交强机构管理费总比例
- BigDecimal jqDeptProportion = ptlAgreementProductCostsExport.getJqExportRadioLevel1()
- .add(ptlAgreementProductCostsExport.getJqExportRadioLevel2())
- .add(ptlAgreementProductCostsExport.getJqExportRadioLevel3())
- .add(ptlAgreementProductCostsExport.getJqExportRadioLevel4())
- .add(ptlAgreementProductCostsExport.getJqExportRadioLevel5());
- //获取商业机构管理费总比例
- BigDecimal syDeptProportion = ptlAgreementProductCostsExport.getSyExportRadioLevel1()
- .add(ptlAgreementProductCostsExport.getSyExportRadioLevel2())
- .add(ptlAgreementProductCostsExport.getSyExportRadioLevel3())
- .add(ptlAgreementProductCostsExport.getSyExportRadioLevel4())
- .add(ptlAgreementProductCostsExport.getSyExportRadioLevel5());
- //获取非车机构管理费总比例
- BigDecimal noDeptProportion = ptlAgreementProductCostsExport.getNoCarExportRadioLevel1()
- .add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel2())
- .add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel3())
- .add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel4())
- .add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel5());
- //获取交强分销总比例
- BigDecimal jqRetailProportion = retailProportion.getJqRetailLevel1Proportion()
- .add(retailProportion.getJqRetailLevel2Proportion())
- .add(retailProportion.getJqRetailLevel3Proportion());
- //获取商业分销总比例
- BigDecimal syRetailProportion = retailProportion.getSyRetailLevel1Proportion()
- .add(retailProportion.getSyRetailLevel2Proportion())
- .add(retailProportion.getSyRetailLevel3Proportion());
- //获取非车分销总比例
- BigDecimal noRetailProportion = retailProportion.getNoRetailLevel1Proportion()
- .add(retailProportion.getNoRetailLevel2Proportion())
- .add(retailProportion.getNoRetailLevel3Proportion());
- //重新计算比例 入口是否超出支付的比例
- ReCalcuLateProportion jqReCalcuLateProportion = recalculateProportion(
- new BigDecimal(ptlAgreementProductCostsNew.getJqCostsProportion()),
- jqDeptProportion,
- jqRetailProportion,
- taxRadio,
- retailLevel,
- ptlAgreementProductCostsExport,
- retailProportion,
- "jq",
- enterProportion
- );
- ReCalcuLateProportion syReCalcuLateProportion = recalculateProportion(
- new BigDecimal(ptlAgreementProductCostsNew.getSyCostsProportion()),
- syDeptProportion,
- syRetailProportion,
- taxRadio,
- retailLevel,
- ptlAgreementProductCostsExport,
- retailProportion,
- "sy",
- enterProportion
- );
- ReCalcuLateProportion noReCalcuLateProportion = recalculateProportion(
- new BigDecimal(ptlAgreementProductCostsNew.getNoCostsProportion()),
- noDeptProportion,
- noRetailProportion,
- taxRadio,
- retailLevel,
- ptlAgreementProductCostsExport,
- retailProportion,
- "no",
- enterProportion
- );
- retailProportion.setProportion(jqReCalcuLateProportion, syReCalcuLateProportion, noReCalcuLateProportion);
- // ptlAgreementProductCostsExportService.updateById(ptlAgreementProductCostsExport);
- //endregion
- //region 计算分销费用
- //分销总比例
- // BigDecimal jqRetailRadio = new BigDecimal("0");
- // BigDecimal syRetailRadio = new BigDecimal("0");
- // BigDecimal noRetailRadio = new BigDecimal("0");
- FeeOrderNewVo.RetailFee retailFeeLevel3 = new FeeOrderNewVo.RetailFee();
- FeeOrderNewVo.RetailFee retailFeeLevel2 = new FeeOrderNewVo.RetailFee();
- FeeOrderNewVo.RetailFee retailFeeLevel1 = new FeeOrderNewVo.RetailFee();
- //分销总比例
- BigDecimal retailRadio = new BigDecimal("0");
- if (esmRetailList != null && !esmRetailList.isEmpty()) {
- EsmRetail esmRetail = esmRetailList.get(0);
- //分销等级
- insFeeOrderNew.setDistributionStatus(esmRetailList.get(0).getRetailtype());
- //用户分销人员id
- List<EsmUserReferrer> parents = esmUserReferrerService.findParents(sysUser.getId());
- if (esmRetail != null) {
- BigDecimal sumPremium = insFeeOrderNew.getJqPremium().add(insFeeOrderNew.getSyPremium()).add(insFeeOrderNew.getNoPremium());
- if (Integer.parseInt(esmRetail.getRetailtype()) >= 3) {
- insFeeOrderNew.setThirdDetailProportion(new BigDecimal(String.valueOf(esmRetail.getDisrate3())));
- retailRadio = retailRadio.add(insFeeOrderNew.getThirdDetailProportion()).setScale(2, BigDecimal.ROUND_DOWN);
- retailFeeLevel3 = feeRuleSchemeService.calcRetail(
- insFeeOrderNew.getJqPremium(),
- insFeeOrderNew.getJqCostsProportion(),
- insFeeOrderNew.getSyPremium(),
- insFeeOrderNew.getSyCostsProportion(),
- insFeeOrderNew.getNoPremium(),
- insFeeOrderNew.getNoCostsProportion(),
- retailProportion.getJqRetailLevel3Proportion(),
- retailProportion.getSyRetailLevel3Proportion(),
- retailProportion.getNoRetailLevel3Proportion());
- insFeeOrderNew.setThirdDetailPremiums(retailFeeLevel3.getTotalRetailPremiums());
- if (parents != null && parents.size() > 2) {
- insFeeOrderNew.setThreeLevelUserId(parents.get(2).getId());
- }
- } else {
- insFeeOrderNew.setThirdDetailProportion(new BigDecimal(0));
- }
- if (Integer.parseInt(esmRetail.getRetailtype()) >= 2) {
- insFeeOrderNew.setSecondDetailProportion(new BigDecimal(String.valueOf(esmRetail.getDisrate2())));
- retailRadio = retailRadio.add(insFeeOrderNew.getSecondDetailProportion()).setScale(2, BigDecimal.ROUND_DOWN);
- retailFeeLevel2 = feeRuleSchemeService.calcRetail(insFeeOrderNew.getJqPremium(),
- insFeeOrderNew.getJqCostsProportion(),
- insFeeOrderNew.getSyPremium(),
- insFeeOrderNew.getSyCostsProportion(),
- insFeeOrderNew.getNoPremium(),
- insFeeOrderNew.getNoCostsProportion(),
- retailProportion.getJqRetailLevel2Proportion(),
- retailProportion.getSyRetailLevel2Proportion(),
- retailProportion.getNoRetailLevel2Proportion());
- insFeeOrderNew.setSecondDetailPremiums(retailFeeLevel2.getTotalRetailPremiums());
- if (parents != null && parents.size() > 1) {
- insFeeOrderNew.setTwoLevelUserId(parents.get(1).getId());
- }
- } else {
- insFeeOrderNew.setSecondDetailProportion(new BigDecimal(0));
- }
- if (Integer.parseInt(esmRetail.getRetailtype()) >= 1) {
- insFeeOrderNew.setFirstDetailProportion(new BigDecimal(String.valueOf(esmRetail.getDisrate1())));
- retailRadio = retailRadio.add(insFeeOrderNew.getFirstDetailProportion()).setScale(2, BigDecimal.ROUND_DOWN);
- retailFeeLevel1 = feeRuleSchemeService.calcRetail(insFeeOrderNew.getJqPremium(),
- insFeeOrderNew.getJqCostsProportion(),
- insFeeOrderNew.getSyPremium(),
- insFeeOrderNew.getSyCostsProportion(),
- insFeeOrderNew.getNoPremium(),
- insFeeOrderNew.getNoCostsProportion(),
- retailProportion.getJqRetailLevel1Proportion(),
- retailProportion.getSyRetailLevel1Proportion(),
- retailProportion.getNoRetailLevel1Proportion());
- insFeeOrderNew.setFirstDetailPremiums(retailFeeLevel1.getTotalRetailPremiums());
- if (parents != null && !parents.isEmpty()) {
- insFeeOrderNew.setFirstLevelUserId(parents.get(0).getId());
- }
- } else {
- insFeeOrderNew.setFirstDetailProportion(new BigDecimal(0));
- }
- } else {
- insFeeOrderNew.setFirstDetailPremiums(new BigDecimal(0));
- insFeeOrderNew.setSecondDetailPremiums(new BigDecimal(0));
- insFeeOrderNew.setThirdDetailPremiums(new BigDecimal(0));
- }
- } else {
- insFeeOrderNew.setFirstDetailProportion(new BigDecimal(0));
- insFeeOrderNew.setSecondDetailProportion(new BigDecimal(0));
- insFeeOrderNew.setThirdDetailProportion(new BigDecimal(0));
- }
- insFeeOrderNew.assignRetail(retailFeeLevel1, retailFeeLevel2, retailFeeLevel3);
- //endregion
- //region 设置机构管理费
- //交强机构管理费
- BigDecimal jqDeptRadio =
- ptlAgreementProductCostsExport.getJqExportRadioLevel1().add(ptlAgreementProductCostsExport.getJqExportRadioLevel2()).add(ptlAgreementProductCostsExport.getJqExportRadioLevel3()).add(ptlAgreementProductCostsExport.getJqExportRadioLevel4()).add(ptlAgreementProductCostsExport.getJqExportRadioLevel5());
- FeeOrderNewVo.DeptManagerFee jqDeptManagerFee = feeRuleSchemeService.calcDeptManagerFee(insFeeOrderNew.getJqPremium(),
- ptlAgreementProductCostsExport.getJqExportRadioLevel1(), ptlAgreementProductCostsExport.getJqExportRadioLevel2(),
- ptlAgreementProductCostsExport.getJqExportRadioLevel3(), ptlAgreementProductCostsExport.getJqExportRadioLevel4(),
- ptlAgreementProductCostsExport.getJqExportRadioLevel5());
- insFeeOrderNew.setJqDeptProportionLevel1(jqDeptManagerFee.getDeptProportionLevelOne());
- insFeeOrderNew.setJqDeptPremiumsLevel1(twoPeople(jqDeptManagerFee.getDeptPremiumsLevelOne()));
- insFeeOrderNew.setJqDeptProportionLevel2(jqDeptManagerFee.getDeptProportionLevelTwo());
- insFeeOrderNew.setJqDeptPremiumsLevel2(twoPeople(jqDeptManagerFee.getDeptPremiumsLevelTwo()));
- insFeeOrderNew.setJqDeptProportionLevel3(jqDeptManagerFee.getDeptProportionLevelThree());
- insFeeOrderNew.setJqDeptPremiumsLevel3(twoPeople(jqDeptManagerFee.getDeptPremiumsLevelThree()));
- insFeeOrderNew.setJqDeptProportionLevel4(jqDeptManagerFee.getDeptProportionLevelFoure());
- insFeeOrderNew.setJqDeptPremiumsLevel4(twoPeople(jqDeptManagerFee.getDeptPremiumsLevelFoure()));
- insFeeOrderNew.setJqDeptProportionLevel5(jqDeptManagerFee.getDeptProportionLevelFive());
- insFeeOrderNew.setJqDeptPremiumsLevel5(twoPeople(jqDeptManagerFee.getDeptPremiumsLevelFive()));
- BigDecimal syDeptRadio =
- ptlAgreementProductCostsExport.getSyExportRadioLevel1().add(ptlAgreementProductCostsExport.getSyExportRadioLevel2()).add(ptlAgreementProductCostsExport.getSyExportRadioLevel3()).add(ptlAgreementProductCostsExport.getSyExportRadioLevel4()).add(ptlAgreementProductCostsExport.getSyExportRadioLevel5());
- FeeOrderNewVo.DeptManagerFee syDeptManagerFee = feeRuleSchemeService.calcDeptManagerFee(insFeeOrderNew.getSyPremium(),
- ptlAgreementProductCostsExport.getSyExportRadioLevel1(), ptlAgreementProductCostsExport.getSyExportRadioLevel2(),
- ptlAgreementProductCostsExport.getSyExportRadioLevel3(), ptlAgreementProductCostsExport.getSyExportRadioLevel4(),
- ptlAgreementProductCostsExport.getSyExportRadioLevel5());
- insFeeOrderNew.setSyDeptProportionLevel1(syDeptManagerFee.getDeptProportionLevelOne());
- insFeeOrderNew.setSyDeptPremiumsLevel1(twoPeople(syDeptManagerFee.getDeptPremiumsLevelOne()));
- insFeeOrderNew.setSyDeptProportionLevel2(syDeptManagerFee.getDeptProportionLevelTwo());
- insFeeOrderNew.setSyDeptPremiumsLevel2(twoPeople(syDeptManagerFee.getDeptPremiumsLevelTwo()));
- insFeeOrderNew.setSyDeptProportionLevel3(syDeptManagerFee.getDeptProportionLevelThree());
- insFeeOrderNew.setSyDeptPremiumsLevel3(twoPeople(syDeptManagerFee.getDeptPremiumsLevelThree()));
- insFeeOrderNew.setSyDeptProportionLevel4(syDeptManagerFee.getDeptProportionLevelFoure());
- insFeeOrderNew.setSyDeptPremiumsLevel4(twoPeople(syDeptManagerFee.getDeptPremiumsLevelFoure()));
- insFeeOrderNew.setSyDeptProportionLevel5(syDeptManagerFee.getDeptProportionLevelFive());
- insFeeOrderNew.setSyDeptPremiumsLevel5(twoPeople(syDeptManagerFee.getDeptPremiumsLevelFive()));
- BigDecimal noDeptRadio =
- ptlAgreementProductCostsExport.getNoCarExportRadioLevel1().add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel2()).add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel3()).add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel4()).add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel5());
- FeeOrderNewVo.DeptManagerFee noDeptManagerFee = feeRuleSchemeService.calcDeptManagerFee(insFeeOrderNew.getNoPremium(),
- ptlAgreementProductCostsExport.getNoCarExportRadioLevel1(), ptlAgreementProductCostsExport.getNoCarExportRadioLevel2(),
- ptlAgreementProductCostsExport.getNoCarExportRadioLevel3(), ptlAgreementProductCostsExport.getNoCarExportRadioLevel4(),
- ptlAgreementProductCostsExport.getNoCarExportRadioLevel5());
- insFeeOrderNew.setNoDeptProportionLevel1(noDeptManagerFee.getDeptProportionLevelOne());
- insFeeOrderNew.setNoDeptPremiumsLevel1(twoPeople(noDeptManagerFee.getDeptPremiumsLevelOne()));
- insFeeOrderNew.setNoDeptProportionLevel2(noDeptManagerFee.getDeptProportionLevelTwo());
- insFeeOrderNew.setNoDeptPremiumsLevel2(twoPeople(noDeptManagerFee.getDeptPremiumsLevelTwo()));
- insFeeOrderNew.setNoDeptProportionLevel3(noDeptManagerFee.getDeptProportionLevelThree());
- insFeeOrderNew.setNoDeptPremiumsLevel3(twoPeople(noDeptManagerFee.getDeptPremiumsLevelThree()));
- insFeeOrderNew.setNoDeptProportionLevel4(noDeptManagerFee.getDeptProportionLevelFoure());
- insFeeOrderNew.setNoDeptPremiumsLevel4(twoPeople(noDeptManagerFee.getDeptPremiumsLevelFoure()));
- insFeeOrderNew.setNoDeptProportionLevel5(noDeptManagerFee.getDeptProportionLevelFive());
- insFeeOrderNew.setNoDeptPremiumsLevel5(twoPeople(noDeptManagerFee.getDeptPremiumsLevelFive()));
- //endregion
- //region 出口费用
- //交强出口手续费比例
- FeeOrderNewVo.ExportFee jqExportFee = feeRuleSchemeService.calcExportFee(insFeeOrderNew.getJqPremium(), new BigDecimal(ptlAgreementProductCostsNew.getJqCostsExportProportion()),
- insFeeOrderNew.getJqCostsProportion(), jqDeptRadio, retailRadio, taxRadio, jqReCalcuLateProportion.getProxyProportion());
- //商业出口手续费比例
- FeeOrderNewVo.ExportFee syExportFee = feeRuleSchemeService.calcExportFee(insFeeOrderNew.getSyPremium(), new BigDecimal(ptlAgreementProductCostsNew.getSyCostsExportProportion()),
- insFeeOrderNew.getSyCostsProportion(), syDeptRadio, retailRadio, taxRadio, syReCalcuLateProportion.getProxyProportion());
- //非车出口手续费比例
- FeeOrderNewVo.ExportFee noExportFee = feeRuleSchemeService.calcExportFee(insFeeOrderNew.getNoPremium(), new BigDecimal(ptlAgreementProductCostsNew.getNoCostsExportProportion()),
- insFeeOrderNew.getNoCostsProportion(), noDeptRadio, retailRadio, taxRadio, noReCalcuLateProportion.getProxyProportion());
- //出口手续费用
- insFeeOrderNew.setJqExportSuperviseCostsPremiums(twoPeople(jqExportFee.getSuperviseCostsPremiums()));
- insFeeOrderNew.setSyExportSuperviseCostsPremiums(twoPeople(syExportFee.getSuperviseCostsPremiums()));
- insFeeOrderNew.setNoExportSuperviseCostsPremiums(twoPeople(noExportFee.getSuperviseCostsPremiums()));
- //出口其他费用比例
- insFeeOrderNew.setJqExportOtherCostsProportion(twoPeople(jqExportFee.getOtherCostsProportion()));
- insFeeOrderNew.setSyExportOtherCostsProportion(twoPeople(syExportFee.getOtherCostsProportion()));
- insFeeOrderNew.setNoExportOtherCostsProportion(twoPeople(noExportFee.getOtherCostsProportion()));
- //出口其他费用
- insFeeOrderNew.setJqExportOtherCostsPremiums(twoPeople(jqExportFee.getOtherCostsPremiums()));
- insFeeOrderNew.setSyExportOtherCostsPremiums(twoPeople(syExportFee.getOtherCostsPremiums()));
- insFeeOrderNew.setNoExportOtherCostsPremiums(twoPeople(noExportFee.getOtherCostsPremiums()));
- //设置出口手续费比例
- insFeeOrderNew.setJqCostsExportProportion(twoPeople(jqExportFee.getSuperviseCosts()));
- insFeeOrderNew.setSyCostsExportProportion(twoPeople(syExportFee.getSuperviseCosts()));
- insFeeOrderNew.setNoCostsExportProportion(twoPeople(noExportFee.getSuperviseCosts()));
- // 外部订单费用
- insFeeOrderNew.setJqExternalProportion(jqExportFee.getExternalProportion());
- insFeeOrderNew.setJqExternalPremiums(jqExportFee.getExternalPremiums());
- insFeeOrderNew.setSyExternalProportion(syExportFee.getExternalProportion());
- insFeeOrderNew.setSyExternalPremiums(syExportFee.getExternalPremiums());
- insFeeOrderNew.setNoExternalProportion(noExportFee.getExternalProportion());
- insFeeOrderNew.setNoExternalPremiums(noExportFee.getExternalPremiums());
- //endregion
- //region 计算利润差值
- //入口 - 出口 - 机构管理费 1-5级 - 分销费 = 差值
- //分销交强费用
- //分开算 1 2 3 级
- BigDecimal jqFirst = insFeeOrderNew.getJqPremium().multiply(insFeeOrderNew.getFirstDetailProportion().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- BigDecimal jqSecond = insFeeOrderNew.getJqPremium().multiply(insFeeOrderNew.getSecondDetailProportion().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- BigDecimal jqThird = insFeeOrderNew.getJqPremium().multiply(insFeeOrderNew.getThirdDetailProportion().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- BigDecimal jqFenXiao = jqFirst.add(jqSecond).add(jqThird);
- //分销商业费用
- BigDecimal syFirst = insFeeOrderNew.getSyPremium().multiply(insFeeOrderNew.getFirstDetailProportion().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- BigDecimal sySecond = insFeeOrderNew.getSyPremium().multiply(insFeeOrderNew.getSecondDetailProportion().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- BigDecimal syThird = insFeeOrderNew.getSyPremium().multiply(insFeeOrderNew.getThirdDetailProportion().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- BigDecimal syFenXiao = syFirst.add(sySecond).add(syThird);
- //分销非车费用
- BigDecimal noFirst = insFeeOrderNew.getNoPremium().multiply(insFeeOrderNew.getFirstDetailProportion().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- BigDecimal noSecond = insFeeOrderNew.getNoPremium().multiply(insFeeOrderNew.getSecondDetailProportion().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- BigDecimal noThird = insFeeOrderNew.getNoPremium().multiply(insFeeOrderNew.getThirdDetailProportion().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- BigDecimal noFenXiao = noFirst.add(noSecond).add(noThird);
- BigDecimal jqDifference = jqEntranceFee.getTotalAmount()
- .subtract(jqExportFee.getExternalPremiums())
- .subtract(
- (jqExportFee.getSuperviseCostsPremiums().add(jqExportFee.getOtherCostsPremiums())))
- .subtract(
- (jqDeptManagerFee.getDeptPremiumsLevelOne().add(jqDeptManagerFee.getDeptPremiumsLevelTwo().add(jqDeptManagerFee.getDeptPremiumsLevelThree()).add(jqDeptManagerFee.getDeptPremiumsLevelFoure()).add(jqDeptManagerFee.getDeptPremiumsLevelFive())))
- )
- .subtract(jqFenXiao).setScale(5, BigDecimal.ROUND_HALF_DOWN);
- insFeeOrderNew.setJqProfitMarginPremiums(jqDifference);
- BigDecimal syDifference = syEntranceFee.getTotalAmount()
- .subtract(syExportFee.getExternalPremiums())
- .subtract(
- (syExportFee.getSuperviseCostsPremiums().add(syExportFee.getOtherCostsPremiums())))
- .subtract(
- (syDeptManagerFee.getDeptPremiumsLevelOne().add(syDeptManagerFee.getDeptPremiumsLevelTwo().add(syDeptManagerFee.getDeptPremiumsLevelThree()).add(syDeptManagerFee.getDeptPremiumsLevelFoure()).add(syDeptManagerFee.getDeptPremiumsLevelFive())))
- )
- .subtract(syFenXiao).setScale(5, BigDecimal.ROUND_HALF_DOWN);
- insFeeOrderNew.setSyProfitMarginPremiums(syDifference);
- BigDecimal noDifference = noEntranceFee.getTotalAmount()
- .subtract(noExportFee.getExternalPremiums())
- .subtract(
- (noExportFee.getSuperviseCostsPremiums().add(noExportFee.getOtherCostsPremiums())))
- .subtract(
- (noDeptManagerFee.getDeptPremiumsLevelOne().add(noDeptManagerFee.getDeptPremiumsLevelTwo().add(noDeptManagerFee.getDeptPremiumsLevelThree()).add(noDeptManagerFee.getDeptPremiumsLevelFoure()).add(noDeptManagerFee.getDeptPremiumsLevelFive())))
- )
- .subtract(noFenXiao).setScale(5, BigDecimal.ROUND_HALF_DOWN);
- insFeeOrderNew.setNoProfitMarginPremiums(noDifference);
- //endregion
- //region 比例逆推是否等于0
- if (!feeRuleSchemeService.calculateProportion(jqEntranceFee, jqDeptManagerFee, jqExportFee, retailRadio, taxRadio, insFeeOrderNew.getJqPremium()))
- throw new SystemException("交强比例异常");
- if (!feeRuleSchemeService.calculateProportion(syEntranceFee, syDeptManagerFee, syExportFee, retailRadio, taxRadio, insFeeOrderNew.getSyPremium()))
- throw new SystemException("商业比例异常");
- if (!feeRuleSchemeService.calculateProportion(noEntranceFee, noDeptManagerFee, noExportFee, retailRadio, taxRadio, insFeeOrderNew.getNoPremium()))
- throw new SystemException("非车比例异常");
- //endregion
- insFeeOrderNewService.saveOrUpdate(insFeeOrderNew);
- }
- @Override
- public ExternalOrderFeeVo calcCostsExternalExportData(PtlAgreement ptlAgreement, PtlAgreementProductCostsNew ptlAgreementProductCostsNew, ExternalOrderFeeVo externalOrderFeeVo) {
- //获取协议信息
- // 外部订单比例
- ptlAgreementProductCostsNew.blank();
- SysUser sysUser = sysUserService.findByUserId(externalOrderFeeVo.getUserId());
- BigDecimal enterProportion = sysSwitchConfigService.getEnterProportion(sysUser.getDeptId(), 3);
- BigDecimal taxRadio = new BigDecimal("1.00");
- //如果是外部订单则 不含税
- if (ptlAgreement.getWithTax().equals("否")) {
- taxRadio = new BigDecimal("1.06");
- }
- //税比例 固定1.06
- //查找入口与出口费用比例
- //出口配置
- PtlAgreementProductCostsExport ptlAgreementProductCostsExport =
- ptlAgreementProductCostsExportService.getOne(new LambdaQueryWrapper<PtlAgreementProductCostsExport>()
- .eq(PtlAgreementProductCostsExport::getCostsId, ptlAgreementProductCostsNew.getId()));
- //不含税
- BigDecimal bigDecimal = new BigDecimal("1.06");
- externalOrderFeeVo.setJqNoTaxPremium(externalOrderFeeVo.getJqPremium().divide(bigDecimal, 2));
- externalOrderFeeVo.setSyNoTaxPremium(externalOrderFeeVo.getSyPremium().divide(bigDecimal, 2));
- externalOrderFeeVo.setNoNoTaxPremium(externalOrderFeeVo.getNoPremium().divide(bigDecimal, 2));
- //region 计算入口费用
- //交强入口信息
- FeeOrderNewVo.EntranceFee jqEntranceFee = feeRuleSchemeService.calcEntranceFee(externalOrderFeeVo.getJqPremium(),
- new BigDecimal(ptlAgreementProductCostsNew.getJqCarCostsProportion()),
- externalOrderFeeVo.getJqRadio(), taxRadio);
- //endregion
- //region 重新计算管理费比例和分销比例
- List<EsmRetail> esmRetailList = esmRetailService.selectList(" where t.deptid=? and t.status = '1' ",
- new Object[]{sysUser.getDeptId()});
- Integer retailLevel = 0;
- //默认分销比例设置
- RetailProportion retailProportion = new RetailProportion();
- if (!Objects.isNull(esmRetailList) && !esmRetailList.isEmpty()) {
- retailLevel = Integer.parseInt(esmRetailList.get(0).getRetailtype());
- //赋值默认的分销比例
- retailProportion.setProportion(esmRetailList.get(0).getDisrate1(), esmRetailList.get(0).getDisrate2(), esmRetailList.get(0).getDisrate3());
- }
- //获取交强机构管理费总比例
- BigDecimal jqDeptProportion = ptlAgreementProductCostsExport.getJqExportRadioLevel1()
- .add(ptlAgreementProductCostsExport.getJqExportRadioLevel2())
- .add(ptlAgreementProductCostsExport.getJqExportRadioLevel3())
- .add(ptlAgreementProductCostsExport.getJqExportRadioLevel4())
- .add(ptlAgreementProductCostsExport.getJqExportRadioLevel5());
- //获取商业机构管理费总比例
- BigDecimal syDeptProportion = ptlAgreementProductCostsExport.getSyExportRadioLevel1()
- .add(ptlAgreementProductCostsExport.getSyExportRadioLevel2())
- .add(ptlAgreementProductCostsExport.getSyExportRadioLevel3())
- .add(ptlAgreementProductCostsExport.getSyExportRadioLevel4())
- .add(ptlAgreementProductCostsExport.getSyExportRadioLevel5());
- //获取非车机构管理费总比例
- BigDecimal noDeptProportion = ptlAgreementProductCostsExport.getNoCarExportRadioLevel1()
- .add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel2())
- .add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel3())
- .add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel4())
- .add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel5());
- //获取交强分销总比例
- BigDecimal jqRetailProportion = retailProportion.getJqRetailLevel1Proportion()
- .add(retailProportion.getJqRetailLevel2Proportion())
- .add(retailProportion.getJqRetailLevel3Proportion());
- //获取商业分销总比例
- BigDecimal syRetailProportion = retailProportion.getSyRetailLevel1Proportion()
- .add(retailProportion.getSyRetailLevel2Proportion())
- .add(retailProportion.getSyRetailLevel3Proportion());
- //获取非车分销总比例
- BigDecimal noRetailProportion = retailProportion.getNoRetailLevel1Proportion()
- .add(retailProportion.getNoRetailLevel2Proportion())
- .add(retailProportion.getNoRetailLevel3Proportion());
- //重新计算比例 入口是否超出支付的比例
- ReCalcuLateProportion jqReCalcuLateProportion = recalculateProportion(
- new BigDecimal(ptlAgreementProductCostsNew.getJqCostsProportion()),
- jqDeptProportion,
- jqRetailProportion,
- taxRadio,
- retailLevel,
- ptlAgreementProductCostsExport,
- retailProportion,
- "jq",
- enterProportion
- );
- ReCalcuLateProportion syReCalcuLateProportion = recalculateProportion(
- new BigDecimal(ptlAgreementProductCostsNew.getSyCostsProportion()),
- syDeptProportion,
- syRetailProportion,
- taxRadio,
- retailLevel,
- ptlAgreementProductCostsExport,
- retailProportion,
- "sy",
- enterProportion
- );
- ReCalcuLateProportion noReCalcuLateProportion = recalculateProportion(
- new BigDecimal(ptlAgreementProductCostsNew.getNoCostsProportion()),
- noDeptProportion,
- noRetailProportion,
- taxRadio,
- retailLevel,
- ptlAgreementProductCostsExport,
- retailProportion,
- "no",
- enterProportion
- );
- retailProportion.setProportion(jqReCalcuLateProportion, syReCalcuLateProportion, noReCalcuLateProportion);
- // ptlAgreementProductCostsExportService.updateById(ptlAgreementProductCostsExport);
- //endregion
- //region 计算分销费用
- //分销总比例
- BigDecimal jqRetailRadio = new BigDecimal("0");
- BigDecimal syRetailRadio = new BigDecimal("0");
- BigDecimal noRetailRadio = new BigDecimal("0");
- FeeOrderNewVo.RetailFee retailFeeLevel3 = new FeeOrderNewVo.RetailFee();
- FeeOrderNewVo.RetailFee retailFeeLevel2 = new FeeOrderNewVo.RetailFee();
- FeeOrderNewVo.RetailFee retailFeeLevel1 = new FeeOrderNewVo.RetailFee();
- //分销总比例
- BigDecimal retailRadio = new BigDecimal("0");
- if (esmRetailList != null && !esmRetailList.isEmpty()) {
- EsmRetail esmRetail = esmRetailList.get(0);
- if (esmRetail != null) {
- BigDecimal sumPremium = externalOrderFeeVo.getJqPremium().add(externalOrderFeeVo.getSyPremium()).add(externalOrderFeeVo.getNoPremium());
- if (Integer.parseInt(esmRetail.getRetailtype()) >= 3) {
- retailRadio = retailRadio.add(new BigDecimal(String.valueOf(esmRetail.getDisrate3()))).setScale(2, BigDecimal.ROUND_DOWN);
- retailFeeLevel3 = feeRuleSchemeService.calcRetail(
- externalOrderFeeVo.getJqPremium(),
- externalOrderFeeVo.getJqRadio(),
- externalOrderFeeVo.getSyPremium(),
- externalOrderFeeVo.getSyRadio(),
- externalOrderFeeVo.getNoPremium(),
- externalOrderFeeVo.getNoRadio(),
- retailProportion.getJqRetailLevel3Proportion(),
- retailProportion.getSyRetailLevel3Proportion(),
- retailProportion.getNoRetailLevel3Proportion());
- //三级分销费用 retailFeeLevel3.getTotalRetailPremiums()
- } else {
- //三级分销费用为 空值0
- }
- if (Integer.parseInt(esmRetail.getRetailtype()) >= 2) {
- retailRadio = retailRadio.add(new BigDecimal(String.valueOf(esmRetail.getDisrate2()))).setScale(2, BigDecimal.ROUND_DOWN);
- retailFeeLevel2 = feeRuleSchemeService.calcRetail(
- externalOrderFeeVo.getJqPremium(),
- externalOrderFeeVo.getJqRadio(),
- externalOrderFeeVo.getSyPremium(),
- externalOrderFeeVo.getSyRadio(),
- externalOrderFeeVo.getNoPremium(),
- externalOrderFeeVo.getNoRadio(),
- retailProportion.getJqRetailLevel2Proportion(),
- retailProportion.getSyRetailLevel2Proportion(),
- retailProportion.getNoRetailLevel2Proportion());
- //二级分销费用 retailFeeLevel2.getTotalRetailPremiums()
- } else {
- // 空的
- }
- if (Integer.parseInt(esmRetail.getRetailtype()) >= 1) {
- retailRadio = retailRadio.add(new BigDecimal(String.valueOf(esmRetail.getDisrate1()))).setScale(2, BigDecimal.ROUND_DOWN);
- retailFeeLevel1 = feeRuleSchemeService.calcRetail(
- externalOrderFeeVo.getJqPremium(),
- externalOrderFeeVo.getJqRadio(),
- externalOrderFeeVo.getSyPremium(),
- externalOrderFeeVo.getSyRadio(),
- externalOrderFeeVo.getNoPremium(),
- externalOrderFeeVo.getNoRadio(),
- retailProportion.getJqRetailLevel1Proportion(),
- retailProportion.getSyRetailLevel1Proportion(),
- retailProportion.getNoRetailLevel1Proportion());
- //一级 retailFeeLevel1.getTotalRetailPremiums()
- } else {
- // 空的
- }
- } else {
- //null
- }
- } else {
- // null
- }
- //endregion
- //region 设置机构管理费
- //交强机构管理费
- BigDecimal jqDeptRadio =
- ptlAgreementProductCostsExport.getJqExportRadioLevel1().add(ptlAgreementProductCostsExport.getJqExportRadioLevel2()).add(ptlAgreementProductCostsExport.getJqExportRadioLevel3()).add(ptlAgreementProductCostsExport.getJqExportRadioLevel4()).add(ptlAgreementProductCostsExport.getJqExportRadioLevel5());
- FeeOrderNewVo.DeptManagerFee jqDeptManagerFee = feeRuleSchemeService.calcDeptManagerFee(externalOrderFeeVo.getJqPremium(),
- ptlAgreementProductCostsExport.getJqExportRadioLevel1(), ptlAgreementProductCostsExport.getJqExportRadioLevel2(),
- ptlAgreementProductCostsExport.getJqExportRadioLevel3(), ptlAgreementProductCostsExport.getJqExportRadioLevel4(),
- ptlAgreementProductCostsExport.getJqExportRadioLevel5());
- BigDecimal syDeptRadio =
- ptlAgreementProductCostsExport.getSyExportRadioLevel1().add(ptlAgreementProductCostsExport.getSyExportRadioLevel2()).add(ptlAgreementProductCostsExport.getSyExportRadioLevel3()).add(ptlAgreementProductCostsExport.getSyExportRadioLevel4()).add(ptlAgreementProductCostsExport.getSyExportRadioLevel5());
- FeeOrderNewVo.DeptManagerFee syDeptManagerFee = feeRuleSchemeService.calcDeptManagerFee(externalOrderFeeVo.getSyPremium(),
- ptlAgreementProductCostsExport.getSyExportRadioLevel1(), ptlAgreementProductCostsExport.getSyExportRadioLevel2(),
- ptlAgreementProductCostsExport.getSyExportRadioLevel3(), ptlAgreementProductCostsExport.getSyExportRadioLevel4(),
- ptlAgreementProductCostsExport.getSyExportRadioLevel5());
- BigDecimal noDeptRadio =
- ptlAgreementProductCostsExport.getNoCarExportRadioLevel1().add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel2()).add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel3()).add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel4()).add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel5());
- FeeOrderNewVo.DeptManagerFee noDeptManagerFee = feeRuleSchemeService.calcDeptManagerFee(externalOrderFeeVo.getNoPremium(),
- ptlAgreementProductCostsExport.getNoCarExportRadioLevel1(), ptlAgreementProductCostsExport.getNoCarExportRadioLevel2(),
- ptlAgreementProductCostsExport.getNoCarExportRadioLevel3(), ptlAgreementProductCostsExport.getNoCarExportRadioLevel4(),
- ptlAgreementProductCostsExport.getNoCarExportRadioLevel5());
- //endregion
- //region 出口费用
- //交强出口手续费比例
- FeeOrderNewVo.ExportFee jqExportFee = feeRuleSchemeService.calcExportFee(
- externalOrderFeeVo.getJqPremium(),
- new BigDecimal(ptlAgreementProductCostsNew.getJqCostsExportProportion()),
- externalOrderFeeVo.getJqRadio(),
- jqDeptRadio,
- retailRadio,
- taxRadio,
- jqReCalcuLateProportion.getProxyProportion());
- //商业出口手续费比例
- FeeOrderNewVo.ExportFee syExportFee = feeRuleSchemeService.calcExportFee(
- externalOrderFeeVo.getSyPremium(),
- new BigDecimal(ptlAgreementProductCostsNew.getSyCostsExportProportion()),
- externalOrderFeeVo.getSyRadio(),
- syDeptRadio,
- retailRadio,
- taxRadio,
- syReCalcuLateProportion.getProxyProportion());
- //非车出口手续费比例
- FeeOrderNewVo.ExportFee noExportFee = feeRuleSchemeService.calcExportFee(
- externalOrderFeeVo.getNoPremium(),
- new BigDecimal(ptlAgreementProductCostsNew.getNoCostsExportProportion()),
- externalOrderFeeVo.getNoRadio(),
- noDeptRadio,
- retailRadio,
- taxRadio,
- noReCalcuLateProportion.getProxyProportion());
- externalOrderFeeVo.setJqExportPremium(jqExportFee.getTotalAmount());
- externalOrderFeeVo.setJqExportRadio(jqExportFee.getTotalProportion());
- externalOrderFeeVo.setSyExportPremium(syExportFee.getTotalAmount());
- externalOrderFeeVo.setSyExportRadio(syExportFee.getTotalProportion());
- externalOrderFeeVo.setNoExportPremium(noExportFee.getTotalAmount());
- externalOrderFeeVo.setNoExportRadio(noExportFee.getTotalProportion());
- //endregion
- return externalOrderFeeVo;
- }
- @Override
- public void calcCostsExternalTest(PtlAgreementProductCostsNew ptlAgreementProductCostsNew, InsAreaCompany insAreaCompany) {
- //获取协议信息
- // 外部订单比例
- PtlAgreement ptlAgreement = ptlAgreementService.getById(insAreaCompany.getAgreementId());
- InsOrders insOrders = insOrdersService.getById(insAreaCompany.getOrderno());
- SysUser sysUser = sysUserService.findByUserId(insOrders.getUserid());
- BigDecimal enterProportion = sysSwitchConfigService.getEnterProportion(insOrders.getDeptid(), insOrders.getEntryStatus());
- BigDecimal taxRadio = new BigDecimal("1.00");
- //如果是外部订单则 不含税
- if (ptlAgreement.getWithTax().equals("否")) {
- taxRadio = new BigDecimal("1.06");
- }
- //税比例 固定1.06
- //查找入口与出口费用比例
- //出口配置
- PtlAgreementProductCostsExport ptlAgreementProductCostsExport =
- ptlAgreementProductCostsExportService.getOne(new LambdaQueryWrapper<PtlAgreementProductCostsExport>().eq(PtlAgreementProductCostsExport::getCostsId, ptlAgreementProductCostsNew.getId()));
- InsFeeOrderNew insFeeOrderNew = new InsFeeOrderNew();
- insFeeOrderNew.setId(IdGenerate.nextId());
- insFeeOrderNew.setCostsId(ptlAgreementProductCostsNew.getId());
- insFeeOrderNew.setAgreementId(insAreaCompany.getAgreementId());
- //存储部门id与用户id
- InsOrders order = insOrdersService.getById(insAreaCompany.getOrderno());
- InsFeeOrderNew insFeeOrderNewByCompanyId = insFeeOrderNewService.getInsFeeOrderNewByCompanyId(insAreaCompany.getId());
- if (insFeeOrderNewByCompanyId != null) {
- insFeeOrderNew.setId(insFeeOrderNewByCompanyId.getId());
- }
- insFeeOrderNew.setDeptId(order.getDeptid());
- insFeeOrderNew.setUserId(order.getUserid());
- insFeeOrderNew.setInsOrderNo(insAreaCompany.getId());
- insFeeOrderNew.setJqPremium(insAreaCompany.getJqpremium());
- insFeeOrderNew.setSyPremium(insAreaCompany.getSypremium());
- insFeeOrderNew.setNoPremium(insAreaCompany.getJypremium());
- //不含税
- BigDecimal bigDecimal = new BigDecimal("1.06");
- insFeeOrderNew.setJqNoTaxPremium(insAreaCompany.getJqpremium().divide(bigDecimal, 2));
- insFeeOrderNew.setSyNoTaxPremium(insAreaCompany.getSypremium().divide(bigDecimal, 2));
- insFeeOrderNew.setNoNoTaxPremium(insAreaCompany.getJypremium().divide(bigDecimal, 2));
- //region 计算入口费用
- //交强入口信息
- FeeOrderNewVo.EntranceFee jqEntranceFee = feeRuleSchemeService.calcEntranceFee(insFeeOrderNew.getJqPremium(),
- new BigDecimal(ptlAgreementProductCostsNew.getJqCarCostsProportion()),
- new BigDecimal(ptlAgreementProductCostsNew.getJqCarOtherCostsProportion()), taxRadio);
- insFeeOrderNew.setJqCostsProportion(jqEntranceFee.getTotalProportion());
- insFeeOrderNew.setJqSuperviseCostsProportion(jqEntranceFee.getSuperviseCosts());
- insFeeOrderNew.setJqSuperviseCostsPremiums(jqEntranceFee.getSuperviseCostsPremiums());
- insFeeOrderNew.setJqOtherCostsProportion(jqEntranceFee.getOtherCostsProportion());
- insFeeOrderNew.setJqOtherCostsPremiums(jqEntranceFee.getOtherCostsPremiums());
- insFeeOrderNew.setJqCostsPremiums(insFeeOrderNew.getJqSuperviseCostsPremiums().add(insFeeOrderNew.getJqOtherCostsPremiums()));
- //商业入口信息
- FeeOrderNewVo.EntranceFee syEntranceFee = feeRuleSchemeService.calcEntranceFee(insFeeOrderNew.getSyPremium(),
- new BigDecimal(ptlAgreementProductCostsNew.getSyCarCostsProportion()),
- new BigDecimal(ptlAgreementProductCostsNew.getSyCarOtherCostsProportion()), taxRadio);
- insFeeOrderNew.setSyCostsProportion(syEntranceFee.getTotalProportion());
- insFeeOrderNew.setSySuperviseCostsProportion(syEntranceFee.getSuperviseCosts());
- insFeeOrderNew.setSySuperviseCostsPremiums(syEntranceFee.getSuperviseCostsPremiums());
- insFeeOrderNew.setSyOtherCostsProportion(syEntranceFee.getOtherCostsProportion());
- insFeeOrderNew.setSyOtherCostsPremiums(syEntranceFee.getOtherCostsPremiums());
- insFeeOrderNew.setSyCostsPremiums(insFeeOrderNew.getSySuperviseCostsPremiums().add(insFeeOrderNew.getSyOtherCostsPremiums()));
- //非车入口信息
- FeeOrderNewVo.EntranceFee noEntranceFee = feeRuleSchemeService.calcEntranceFee(insFeeOrderNew.getNoPremium(),
- new BigDecimal(ptlAgreementProductCostsNew.getNoCarCostsProportion()),
- new BigDecimal(ptlAgreementProductCostsNew.getNoCarOtherCostsProportion()), taxRadio);
- insFeeOrderNew.setNoCostsProportion(noEntranceFee.getTotalProportion());
- insFeeOrderNew.setNoSuperviseCostsProportion(noEntranceFee.getSuperviseCosts());
- insFeeOrderNew.setNoSuperviseCostsPremiums(noEntranceFee.getSuperviseCostsPremiums());
- insFeeOrderNew.setNoOtherCostsProportion(noEntranceFee.getOtherCostsProportion());
- insFeeOrderNew.setNoOtherCostsPremiums(noEntranceFee.getOtherCostsPremiums());
- insFeeOrderNew.setNoCostsPremiums(insFeeOrderNew.getNoSuperviseCostsPremiums().add(insFeeOrderNew.getNoOtherCostsPremiums()));
- //endregion
- //region 重新计算管理费比例和分销比例
- List<EsmRetail> esmRetailList = esmRetailService.selectList(" where t.deptid=? and t.status = '1' ",
- new Object[]{sysUser.getDeptId()});
- Integer retailLevel = 0;
- //默认分销比例设置
- RetailProportion retailProportion = new RetailProportion();
- if (!Objects.isNull(esmRetailList) && !esmRetailList.isEmpty()) {
- retailLevel = Integer.parseInt(esmRetailList.get(0).getRetailtype());
- //赋值默认的分销比例
- retailProportion.setProportion(esmRetailList.get(0).getDisrate1(), esmRetailList.get(0).getDisrate2(), esmRetailList.get(0).getDisrate3());
- }
- //获取交强机构管理费总比例
- BigDecimal jqDeptProportion = ptlAgreementProductCostsExport.getJqExportRadioLevel1()
- .add(ptlAgreementProductCostsExport.getJqExportRadioLevel2())
- .add(ptlAgreementProductCostsExport.getJqExportRadioLevel3())
- .add(ptlAgreementProductCostsExport.getJqExportRadioLevel4())
- .add(ptlAgreementProductCostsExport.getJqExportRadioLevel5());
- //获取商业机构管理费总比例
- BigDecimal syDeptProportion = ptlAgreementProductCostsExport.getSyExportRadioLevel1()
- .add(ptlAgreementProductCostsExport.getSyExportRadioLevel2())
- .add(ptlAgreementProductCostsExport.getSyExportRadioLevel3())
- .add(ptlAgreementProductCostsExport.getSyExportRadioLevel4())
- .add(ptlAgreementProductCostsExport.getSyExportRadioLevel5());
- //获取非车机构管理费总比例
- BigDecimal noDeptProportion = ptlAgreementProductCostsExport.getNoCarExportRadioLevel1()
- .add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel2())
- .add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel3())
- .add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel4())
- .add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel5());
- //获取交强分销总比例
- BigDecimal jqRetailProportion = retailProportion.getJqRetailLevel1Proportion()
- .add(retailProportion.getJqRetailLevel2Proportion())
- .add(retailProportion.getJqRetailLevel3Proportion());
- //获取商业分销总比例
- BigDecimal syRetailProportion = retailProportion.getSyRetailLevel1Proportion()
- .add(retailProportion.getSyRetailLevel2Proportion())
- .add(retailProportion.getSyRetailLevel3Proportion());
- //获取非车分销总比例
- BigDecimal noRetailProportion = retailProportion.getNoRetailLevel1Proportion()
- .add(retailProportion.getNoRetailLevel2Proportion())
- .add(retailProportion.getNoRetailLevel3Proportion());
- //重新计算比例 入口是否超出支付的比例
- ReCalcuLateProportion jqReCalcuLateProportion = recalculateProportion(
- new BigDecimal(ptlAgreementProductCostsNew.getJqCostsProportion()),
- jqDeptProportion,
- jqRetailProportion,
- taxRadio,
- retailLevel,
- ptlAgreementProductCostsExport,
- retailProportion,
- "jq",
- enterProportion
- );
- ReCalcuLateProportion syReCalcuLateProportion = recalculateProportion(
- new BigDecimal(ptlAgreementProductCostsNew.getSyCostsProportion()),
- syDeptProportion,
- syRetailProportion,
- taxRadio,
- retailLevel,
- ptlAgreementProductCostsExport,
- retailProportion,
- "sy",
- enterProportion
- );
- ReCalcuLateProportion noReCalcuLateProportion = recalculateProportion(
- new BigDecimal(ptlAgreementProductCostsNew.getNoCostsProportion()),
- noDeptProportion,
- noRetailProportion,
- taxRadio,
- retailLevel,
- ptlAgreementProductCostsExport,
- retailProportion,
- "no",
- enterProportion
- );
- retailProportion.setProportion(jqReCalcuLateProportion, syReCalcuLateProportion, noReCalcuLateProportion);
- // ptlAgreementProductCostsExportService.updateById(ptlAgreementProductCostsExport);
- //endregion
- //region 计算分销费用
- //分销总比例
- BigDecimal jqRetailRadio = new BigDecimal("0");
- BigDecimal syRetailRadio = new BigDecimal("0");
- BigDecimal noRetailRadio = new BigDecimal("0");
- FeeOrderNewVo.RetailFee retailFeeLevel3 = new FeeOrderNewVo.RetailFee();
- FeeOrderNewVo.RetailFee retailFeeLevel2 = new FeeOrderNewVo.RetailFee();
- FeeOrderNewVo.RetailFee retailFeeLevel1 = new FeeOrderNewVo.RetailFee();
- //分销总比例
- BigDecimal retailRadio = new BigDecimal("0");
- if (esmRetailList != null && !esmRetailList.isEmpty()) {
- EsmRetail esmRetail = esmRetailList.get(0);
- //分销等级
- insFeeOrderNew.setDistributionStatus(esmRetailList.get(0).getRetailtype());
- //用户分销人员id
- List<EsmUserReferrer> parents = esmUserReferrerService.findParents(sysUser.getId());
- if (esmRetail != null) {
- BigDecimal sumPremium = insFeeOrderNew.getJqPremium().add(insFeeOrderNew.getSyPremium()).add(insFeeOrderNew.getNoPremium());
- if (Integer.parseInt(esmRetail.getRetailtype()) >= 3) {
- insFeeOrderNew.setThirdDetailProportion(new BigDecimal(String.valueOf(esmRetail.getDisrate3())));
- retailRadio = retailRadio.add(insFeeOrderNew.getThirdDetailProportion()).setScale(2, BigDecimal.ROUND_DOWN);
- retailFeeLevel3 = feeRuleSchemeService.calcRetail(
- insFeeOrderNew.getJqPremium(),
- insFeeOrderNew.getJqCostsProportion(),
- insFeeOrderNew.getSyPremium(),
- insFeeOrderNew.getSyCostsProportion(),
- insFeeOrderNew.getNoPremium(),
- insFeeOrderNew.getNoCostsProportion(),
- retailProportion.getJqRetailLevel3Proportion(),
- retailProportion.getSyRetailLevel3Proportion(),
- retailProportion.getNoRetailLevel3Proportion());
- insFeeOrderNew.setThirdDetailPremiums(retailFeeLevel3.getTotalRetailPremiums());
- if (parents != null && parents.size() > 2) {
- insFeeOrderNew.setThreeLevelUserId(parents.get(2).getId());
- }
- } else {
- insFeeOrderNew.setThirdDetailProportion(new BigDecimal(0));
- }
- if (Integer.parseInt(esmRetail.getRetailtype()) >= 2) {
- insFeeOrderNew.setSecondDetailProportion(new BigDecimal(String.valueOf(esmRetail.getDisrate2())));
- retailRadio = retailRadio.add(insFeeOrderNew.getSecondDetailProportion()).setScale(2, BigDecimal.ROUND_DOWN);
- retailFeeLevel2 = feeRuleSchemeService.calcRetail(insFeeOrderNew.getJqPremium(),
- insFeeOrderNew.getJqCostsProportion(),
- insFeeOrderNew.getSyPremium(),
- insFeeOrderNew.getSyCostsProportion(),
- insFeeOrderNew.getNoPremium(),
- insFeeOrderNew.getNoCostsProportion(),
- retailProportion.getJqRetailLevel2Proportion(),
- retailProportion.getSyRetailLevel2Proportion(),
- retailProportion.getNoRetailLevel2Proportion());
- insFeeOrderNew.setSecondDetailPremiums(retailFeeLevel2.getTotalRetailPremiums());
- if (parents != null && parents.size() > 1) {
- insFeeOrderNew.setTwoLevelUserId(parents.get(1).getId());
- }
- } else {
- insFeeOrderNew.setSecondDetailProportion(new BigDecimal(0));
- }
- if (Integer.parseInt(esmRetail.getRetailtype()) >= 1) {
- insFeeOrderNew.setFirstDetailProportion(new BigDecimal(String.valueOf(esmRetail.getDisrate1())));
- retailRadio = retailRadio.add(insFeeOrderNew.getFirstDetailProportion()).setScale(2, BigDecimal.ROUND_DOWN);
- retailFeeLevel1 = feeRuleSchemeService.calcRetail(insFeeOrderNew.getJqPremium(),
- insFeeOrderNew.getJqCostsProportion(),
- insFeeOrderNew.getSyPremium(),
- insFeeOrderNew.getSyCostsProportion(),
- insFeeOrderNew.getNoPremium(),
- insFeeOrderNew.getNoCostsProportion(),
- retailProportion.getJqRetailLevel1Proportion(),
- retailProportion.getSyRetailLevel1Proportion(),
- retailProportion.getNoRetailLevel1Proportion());
- insFeeOrderNew.setFirstDetailPremiums(retailFeeLevel1.getTotalRetailPremiums());
- if (parents != null && !parents.isEmpty()) {
- insFeeOrderNew.setFirstLevelUserId(parents.get(0).getId());
- }
- } else {
- insFeeOrderNew.setFirstDetailProportion(new BigDecimal(0));
- }
- } else {
- insFeeOrderNew.setFirstDetailPremiums(new BigDecimal(0));
- insFeeOrderNew.setSecondDetailPremiums(new BigDecimal(0));
- insFeeOrderNew.setThirdDetailPremiums(new BigDecimal(0));
- }
- } else {
- insFeeOrderNew.setFirstDetailProportion(new BigDecimal(0));
- insFeeOrderNew.setSecondDetailProportion(new BigDecimal(0));
- insFeeOrderNew.setThirdDetailProportion(new BigDecimal(0));
- }
- insFeeOrderNew.assignRetail(retailFeeLevel1, retailFeeLevel2, retailFeeLevel3);
- //endregion
- //region 设置机构管理费
- //交强机构管理费
- BigDecimal jqDeptRadio =
- ptlAgreementProductCostsExport.getJqExportRadioLevel1().add(ptlAgreementProductCostsExport.getJqExportRadioLevel2()).add(ptlAgreementProductCostsExport.getJqExportRadioLevel3()).add(ptlAgreementProductCostsExport.getJqExportRadioLevel4()).add(ptlAgreementProductCostsExport.getJqExportRadioLevel5());
- FeeOrderNewVo.DeptManagerFee jqDeptManagerFee = feeRuleSchemeService.calcDeptManagerFee(insFeeOrderNew.getJqPremium(),
- ptlAgreementProductCostsExport.getJqExportRadioLevel1(), ptlAgreementProductCostsExport.getJqExportRadioLevel2(),
- ptlAgreementProductCostsExport.getJqExportRadioLevel3(), ptlAgreementProductCostsExport.getJqExportRadioLevel4(),
- ptlAgreementProductCostsExport.getJqExportRadioLevel5());
- insFeeOrderNew.setJqDeptProportionLevel1(jqDeptManagerFee.getDeptProportionLevelOne());
- insFeeOrderNew.setJqDeptPremiumsLevel1(twoPeople(jqDeptManagerFee.getDeptPremiumsLevelOne()));
- insFeeOrderNew.setJqDeptProportionLevel2(jqDeptManagerFee.getDeptProportionLevelTwo());
- insFeeOrderNew.setJqDeptPremiumsLevel2(twoPeople(jqDeptManagerFee.getDeptPremiumsLevelTwo()));
- insFeeOrderNew.setJqDeptProportionLevel3(jqDeptManagerFee.getDeptProportionLevelThree());
- insFeeOrderNew.setJqDeptPremiumsLevel3(twoPeople(jqDeptManagerFee.getDeptPremiumsLevelThree()));
- insFeeOrderNew.setJqDeptProportionLevel4(jqDeptManagerFee.getDeptProportionLevelFoure());
- insFeeOrderNew.setJqDeptPremiumsLevel4(twoPeople(jqDeptManagerFee.getDeptPremiumsLevelFoure()));
- insFeeOrderNew.setJqDeptProportionLevel5(jqDeptManagerFee.getDeptProportionLevelFive());
- insFeeOrderNew.setJqDeptPremiumsLevel5(twoPeople(jqDeptManagerFee.getDeptPremiumsLevelFive()));
- BigDecimal syDeptRadio =
- ptlAgreementProductCostsExport.getSyExportRadioLevel1().add(ptlAgreementProductCostsExport.getSyExportRadioLevel2()).add(ptlAgreementProductCostsExport.getSyExportRadioLevel3()).add(ptlAgreementProductCostsExport.getSyExportRadioLevel4()).add(ptlAgreementProductCostsExport.getSyExportRadioLevel5());
- FeeOrderNewVo.DeptManagerFee syDeptManagerFee = feeRuleSchemeService.calcDeptManagerFee(insFeeOrderNew.getSyPremium(),
- ptlAgreementProductCostsExport.getSyExportRadioLevel1(), ptlAgreementProductCostsExport.getSyExportRadioLevel2(),
- ptlAgreementProductCostsExport.getSyExportRadioLevel3(), ptlAgreementProductCostsExport.getSyExportRadioLevel4(),
- ptlAgreementProductCostsExport.getSyExportRadioLevel5());
- insFeeOrderNew.setSyDeptProportionLevel1(syDeptManagerFee.getDeptProportionLevelOne());
- insFeeOrderNew.setSyDeptPremiumsLevel1(twoPeople(syDeptManagerFee.getDeptPremiumsLevelOne()));
- insFeeOrderNew.setSyDeptProportionLevel2(syDeptManagerFee.getDeptProportionLevelTwo());
- insFeeOrderNew.setSyDeptPremiumsLevel2(twoPeople(syDeptManagerFee.getDeptPremiumsLevelTwo()));
- insFeeOrderNew.setSyDeptProportionLevel3(syDeptManagerFee.getDeptProportionLevelThree());
- insFeeOrderNew.setSyDeptPremiumsLevel3(twoPeople(syDeptManagerFee.getDeptPremiumsLevelThree()));
- insFeeOrderNew.setSyDeptProportionLevel4(syDeptManagerFee.getDeptProportionLevelFoure());
- insFeeOrderNew.setSyDeptPremiumsLevel4(twoPeople(syDeptManagerFee.getDeptPremiumsLevelFoure()));
- insFeeOrderNew.setSyDeptProportionLevel5(syDeptManagerFee.getDeptProportionLevelFive());
- insFeeOrderNew.setSyDeptPremiumsLevel5(twoPeople(syDeptManagerFee.getDeptPremiumsLevelFive()));
- BigDecimal noDeptRadio =
- ptlAgreementProductCostsExport.getNoCarExportRadioLevel1().add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel2()).add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel3()).add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel4()).add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel5());
- FeeOrderNewVo.DeptManagerFee noDeptManagerFee = feeRuleSchemeService.calcDeptManagerFee(insFeeOrderNew.getNoPremium(),
- ptlAgreementProductCostsExport.getNoCarExportRadioLevel1(), ptlAgreementProductCostsExport.getNoCarExportRadioLevel2(),
- ptlAgreementProductCostsExport.getNoCarExportRadioLevel3(), ptlAgreementProductCostsExport.getNoCarExportRadioLevel4(),
- ptlAgreementProductCostsExport.getNoCarExportRadioLevel5());
- insFeeOrderNew.setNoDeptProportionLevel1(noDeptManagerFee.getDeptProportionLevelOne());
- insFeeOrderNew.setNoDeptPremiumsLevel1(twoPeople(noDeptManagerFee.getDeptPremiumsLevelOne()));
- insFeeOrderNew.setNoDeptProportionLevel2(noDeptManagerFee.getDeptProportionLevelTwo());
- insFeeOrderNew.setNoDeptPremiumsLevel2(twoPeople(noDeptManagerFee.getDeptPremiumsLevelTwo()));
- insFeeOrderNew.setNoDeptProportionLevel3(noDeptManagerFee.getDeptProportionLevelThree());
- insFeeOrderNew.setNoDeptPremiumsLevel3(twoPeople(noDeptManagerFee.getDeptPremiumsLevelThree()));
- insFeeOrderNew.setNoDeptProportionLevel4(noDeptManagerFee.getDeptProportionLevelFoure());
- insFeeOrderNew.setNoDeptPremiumsLevel4(twoPeople(noDeptManagerFee.getDeptPremiumsLevelFoure()));
- insFeeOrderNew.setNoDeptProportionLevel5(noDeptManagerFee.getDeptProportionLevelFive());
- insFeeOrderNew.setNoDeptPremiumsLevel5(twoPeople(noDeptManagerFee.getDeptPremiumsLevelFive()));
- //endregion
- //region 出口费用
- //交强出口手续费比例
- FeeOrderNewVo.ExportFee jqExportFee = feeRuleSchemeService.calcExportFee(insFeeOrderNew.getJqPremium(), new BigDecimal(ptlAgreementProductCostsNew.getJqCostsExportProportion()),
- insFeeOrderNew.getJqCostsProportion(), jqDeptRadio, retailRadio, taxRadio, jqReCalcuLateProportion.getProxyProportion());
- //商业出口手续费比例
- FeeOrderNewVo.ExportFee syExportFee = feeRuleSchemeService.calcExportFee(insFeeOrderNew.getSyPremium(), new BigDecimal(ptlAgreementProductCostsNew.getSyCostsExportProportion()),
- insFeeOrderNew.getSyCostsProportion(), syDeptRadio, retailRadio, taxRadio, syReCalcuLateProportion.getProxyProportion());
- //非车出口手续费比例
- FeeOrderNewVo.ExportFee noExportFee = feeRuleSchemeService.calcExportFee(insFeeOrderNew.getNoPremium(), new BigDecimal(ptlAgreementProductCostsNew.getNoCostsExportProportion()),
- insFeeOrderNew.getNoCostsProportion(), noDeptRadio, retailRadio, taxRadio, noReCalcuLateProportion.getProxyProportion());
- //出口手续费用
- insFeeOrderNew.setJqExportSuperviseCostsPremiums(twoPeople(jqExportFee.getSuperviseCostsPremiums()));
- insFeeOrderNew.setSyExportSuperviseCostsPremiums(twoPeople(syExportFee.getSuperviseCostsPremiums()));
- insFeeOrderNew.setNoExportSuperviseCostsPremiums(twoPeople(noExportFee.getSuperviseCostsPremiums()));
- //出口其他费用比例
- insFeeOrderNew.setJqExportOtherCostsProportion(twoPeople(jqExportFee.getOtherCostsProportion()));
- insFeeOrderNew.setSyExportOtherCostsProportion(twoPeople(syExportFee.getOtherCostsProportion()));
- insFeeOrderNew.setNoExportOtherCostsProportion(twoPeople(noExportFee.getOtherCostsProportion()));
- //出口其他费用
- insFeeOrderNew.setJqExportOtherCostsPremiums(twoPeople(jqExportFee.getOtherCostsPremiums()));
- insFeeOrderNew.setSyExportOtherCostsPremiums(twoPeople(syExportFee.getOtherCostsPremiums()));
- insFeeOrderNew.setNoExportOtherCostsPremiums(twoPeople(noExportFee.getOtherCostsPremiums()));
- //设置出口手续费比例
- insFeeOrderNew.setJqCostsExportProportion(twoPeople(jqExportFee.getSuperviseCosts()));
- insFeeOrderNew.setSyCostsExportProportion(twoPeople(syExportFee.getSuperviseCosts()));
- insFeeOrderNew.setNoCostsExportProportion(twoPeople(noExportFee.getSuperviseCosts()));
- // 外部订单费用
- insFeeOrderNew.setJqExternalProportion(jqExportFee.getExternalProportion());
- insFeeOrderNew.setJqExternalPremiums(jqExportFee.getExternalPremiums());
- insFeeOrderNew.setSyExternalProportion(syExportFee.getExternalProportion());
- insFeeOrderNew.setSyExternalPremiums(syExportFee.getExternalPremiums());
- insFeeOrderNew.setNoExternalProportion(noExportFee.getExternalProportion());
- insFeeOrderNew.setNoExternalPremiums(noExportFee.getExternalPremiums());
- //endregion
- //region 计算利润差值
- //入口 - 出口 - 机构管理费 1-5级 - 分销费 = 差值
- //分销交强费用
- //分开算 1 2 3 级
- BigDecimal jqFirst = insFeeOrderNew.getJqPremium().multiply(insFeeOrderNew.getFirstDetailProportion().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- BigDecimal jqSecond = insFeeOrderNew.getJqPremium().multiply(insFeeOrderNew.getSecondDetailProportion().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- BigDecimal jqThird = insFeeOrderNew.getJqPremium().multiply(insFeeOrderNew.getThirdDetailProportion().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- BigDecimal jqFenXiao = jqFirst.add(jqSecond).add(jqThird);
- //分销商业费用
- BigDecimal syFirst = insFeeOrderNew.getSyPremium().multiply(insFeeOrderNew.getFirstDetailProportion().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- BigDecimal sySecond = insFeeOrderNew.getSyPremium().multiply(insFeeOrderNew.getSecondDetailProportion().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- BigDecimal syThird = insFeeOrderNew.getSyPremium().multiply(insFeeOrderNew.getThirdDetailProportion().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- BigDecimal syFenXiao = syFirst.add(sySecond).add(syThird);
- //分销非车费用
- BigDecimal noFirst = insFeeOrderNew.getNoPremium().multiply(insFeeOrderNew.getFirstDetailProportion().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- BigDecimal noSecond = insFeeOrderNew.getNoPremium().multiply(insFeeOrderNew.getSecondDetailProportion().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- BigDecimal noThird = insFeeOrderNew.getNoPremium().multiply(insFeeOrderNew.getThirdDetailProportion().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- BigDecimal noFenXiao = noFirst.add(noSecond).add(noThird);
- BigDecimal jqDifference = jqEntranceFee.getTotalAmount()
- .subtract(jqExportFee.getExternalPremiums())
- .subtract(
- (jqExportFee.getSuperviseCostsPremiums().add(jqExportFee.getOtherCostsPremiums())))
- .subtract(
- (jqDeptManagerFee.getDeptPremiumsLevelOne().add(jqDeptManagerFee.getDeptPremiumsLevelTwo().add(jqDeptManagerFee.getDeptPremiumsLevelThree()).add(jqDeptManagerFee.getDeptPremiumsLevelFoure()).add(jqDeptManagerFee.getDeptPremiumsLevelFive())))
- )
- .subtract(jqFenXiao).setScale(5, BigDecimal.ROUND_HALF_DOWN);
- insFeeOrderNew.setJqProfitMarginPremiums(jqDifference);
- BigDecimal syDifference = syEntranceFee.getTotalAmount()
- .subtract(syExportFee.getExternalPremiums())
- .subtract(
- (syExportFee.getSuperviseCostsPremiums().add(syExportFee.getOtherCostsPremiums())))
- .subtract(
- (syDeptManagerFee.getDeptPremiumsLevelOne().add(syDeptManagerFee.getDeptPremiumsLevelTwo().add(syDeptManagerFee.getDeptPremiumsLevelThree()).add(syDeptManagerFee.getDeptPremiumsLevelFoure()).add(syDeptManagerFee.getDeptPremiumsLevelFive())))
- )
- .subtract(syFenXiao).setScale(5, BigDecimal.ROUND_HALF_DOWN);
- insFeeOrderNew.setSyProfitMarginPremiums(syDifference);
- BigDecimal noDifference = noEntranceFee.getTotalAmount()
- .subtract(noExportFee.getExternalPremiums())
- .subtract(
- (noExportFee.getSuperviseCostsPremiums().add(noExportFee.getOtherCostsPremiums())))
- .subtract(
- (noDeptManagerFee.getDeptPremiumsLevelOne().add(noDeptManagerFee.getDeptPremiumsLevelTwo().add(noDeptManagerFee.getDeptPremiumsLevelThree()).add(noDeptManagerFee.getDeptPremiumsLevelFoure()).add(noDeptManagerFee.getDeptPremiumsLevelFive())))
- )
- .subtract(noFenXiao).setScale(5, BigDecimal.ROUND_HALF_DOWN);
- insFeeOrderNew.setNoProfitMarginPremiums(noDifference);
- //endregion
- //region 比例逆推是否等于0
- if (!feeRuleSchemeService.calculateProportion(jqEntranceFee, jqDeptManagerFee, jqExportFee, retailRadio, taxRadio, insFeeOrderNew.getJqPremium()))
- throw new SystemException("交强比例异常");
- if (!feeRuleSchemeService.calculateProportion(syEntranceFee, syDeptManagerFee, syExportFee, retailRadio, taxRadio, insFeeOrderNew.getSyPremium()))
- throw new SystemException("商业比例异常");
- if (!feeRuleSchemeService.calculateProportion(noEntranceFee, noDeptManagerFee, noExportFee, retailRadio, taxRadio, insFeeOrderNew.getNoPremium()))
- throw new SystemException("非车比例异常");
- //endregion
- insFeeOrderNewService.saveOrUpdate(insFeeOrderNew);
- }
- @Override
- public void calcCostsExternalTelemarketing(PtlAgreementProductCostsExport ptlAgreementProductCostsExport, InsAreaCompany insAreaCompany) {
- //获取协议信息
- PtlAgreement ptlAgreement = ptlAgreementService.getById(insAreaCompany.getAgreementId());
- InsOrders insOrders = insOrdersService.getById(insAreaCompany.getOrderno());
- SysUser sysUser = sysUserService.findByUserId(insOrders.getUserid());
- //入口配置
- PtlAgreementProductCostsNew ptlAgreementProductCostsNew = ptlAgreementProductCostsNewService.getById(ptlAgreementProductCostsExport.getCostsId());
- ptlAgreementProductCostsNew.blank();
- BigDecimal taxRadio = new BigDecimal("1.00");
- //如果是外部订单则 不含税
- if (ptlAgreement.getWithTax().equals("否") && ptlAgreement.getIsExternal() == 0) {
- taxRadio = new BigDecimal("1.06");
- }
- InsFeeOrderNew insFeeOrderNew = new InsFeeOrderNew();
- insFeeOrderNew.setId(IdGenerate.nextId());
- insFeeOrderNew.setCostsId(ptlAgreementProductCostsNew.getId());
- insFeeOrderNew.setAgreementId(insAreaCompany.getAgreementId());
- //存储部门id与用户id
- InsOrders order = insOrdersService.getById(insAreaCompany.getOrderno());
- InsFeeOrderNew insFeeOrderNewByCompanyId = insFeeOrderNewService.getInsFeeOrderNewByCompanyId(insAreaCompany.getId());
- if (insFeeOrderNewByCompanyId != null) {
- insFeeOrderNew.setId(insFeeOrderNewByCompanyId.getId());
- }
- insFeeOrderNew.setDeptId(order.getDeptid());
- insFeeOrderNew.setUserId(order.getUserid());
- insFeeOrderNew.setInsOrderNo(insAreaCompany.getId());
- insFeeOrderNew.setJqPremium(insAreaCompany.getJqpremium());
- insFeeOrderNew.setSyPremium(insAreaCompany.getSypremium());
- insFeeOrderNew.setNoPremium(insAreaCompany.getJypremium());
- //不含税
- BigDecimal bigDecimal = new BigDecimal("1.06");
- insFeeOrderNew.setJqNoTaxPremium(insAreaCompany.getJqpremium().divide(bigDecimal, 2));
- insFeeOrderNew.setSyNoTaxPremium(insAreaCompany.getSypremium().divide(bigDecimal, 2));
- insFeeOrderNew.setNoNoTaxPremium(insAreaCompany.getJypremium().divide(bigDecimal, 2));
- //region 计算入口费用
- //交强入口信息
- FeeOrderNewVo.EntranceFee jqEntranceFee = feeRuleSchemeService.calcEntranceFee(
- insFeeOrderNew.getJqPremium(),
- new BigDecimal(ptlAgreementProductCostsNew.getJqCarCostsProportion()),
- new BigDecimal(ptlAgreementProductCostsNew.getJqCarOtherCostsProportion()),
- taxRadio);
- insFeeOrderNew.setJqCostsProportion(jqEntranceFee.getTotalProportion());
- insFeeOrderNew.setJqSuperviseCostsProportion(jqEntranceFee.getSuperviseCosts());
- insFeeOrderNew.setJqSuperviseCostsPremiums(jqEntranceFee.getSuperviseCostsPremiums());
- insFeeOrderNew.setJqOtherCostsProportion(jqEntranceFee.getOtherCostsProportion());
- insFeeOrderNew.setJqOtherCostsPremiums(jqEntranceFee.getOtherCostsPremiums());
- insFeeOrderNew.setJqCostsPremiums(insFeeOrderNew.getJqSuperviseCostsPremiums().add(insFeeOrderNew.getJqOtherCostsPremiums()));
- //商业入口信息
- FeeOrderNewVo.EntranceFee syEntranceFee = feeRuleSchemeService.calcEntranceFee(insFeeOrderNew.getSyPremium(),
- new BigDecimal(ptlAgreementProductCostsNew.getSyCarCostsProportion()),
- new BigDecimal(ptlAgreementProductCostsNew.getSyCarOtherCostsProportion()), taxRadio);
- insFeeOrderNew.setSyCostsProportion(syEntranceFee.getTotalProportion());
- insFeeOrderNew.setSySuperviseCostsProportion(syEntranceFee.getSuperviseCosts());
- insFeeOrderNew.setSySuperviseCostsPremiums(syEntranceFee.getSuperviseCostsPremiums());
- insFeeOrderNew.setSyOtherCostsProportion(syEntranceFee.getOtherCostsProportion());
- insFeeOrderNew.setSyOtherCostsPremiums(syEntranceFee.getOtherCostsPremiums());
- insFeeOrderNew.setSyCostsPremiums(insFeeOrderNew.getSySuperviseCostsPremiums().add(insFeeOrderNew.getSyOtherCostsPremiums()));
- //非车入口信息
- FeeOrderNewVo.EntranceFee noEntranceFee = feeRuleSchemeService.calcEntranceFee(insFeeOrderNew.getNoPremium(),
- new BigDecimal(ptlAgreementProductCostsNew.getNoCarCostsProportion()),
- new BigDecimal(ptlAgreementProductCostsNew.getNoCarOtherCostsProportion()), taxRadio);
- insFeeOrderNew.setNoCostsProportion(noEntranceFee.getTotalProportion());
- insFeeOrderNew.setNoSuperviseCostsProportion(noEntranceFee.getSuperviseCosts());
- insFeeOrderNew.setNoSuperviseCostsPremiums(noEntranceFee.getSuperviseCostsPremiums());
- insFeeOrderNew.setNoOtherCostsProportion(noEntranceFee.getOtherCostsProportion());
- insFeeOrderNew.setNoOtherCostsPremiums(noEntranceFee.getOtherCostsPremiums());
- insFeeOrderNew.setNoCostsPremiums(insFeeOrderNew.getNoSuperviseCostsPremiums().add(insFeeOrderNew.getNoOtherCostsPremiums()));
- //endregion
- //region 重新计算管理费比例和分销比例
- List<EsmRetail> esmRetailList = esmRetailService.selectList(" where t.deptid=? and t.status = '1' ",
- new Object[]{sysUser.getDeptId()});
- Integer retailLevel = 0;
- //默认分销比例设置
- RetailProportion retailProportion = new RetailProportion();
- if (!Objects.isNull(esmRetailList) && !esmRetailList.isEmpty()) {
- retailLevel = Integer.parseInt(esmRetailList.get(0).getRetailtype());
- //赋值默认的分销比例
- retailProportion.setProportion(esmRetailList.get(0).getDisrate1(), esmRetailList.get(0).getDisrate2(), esmRetailList.get(0).getDisrate3());
- }
- //获取交强机构管理费总比例
- BigDecimal jqDeptProportion = ptlAgreementProductCostsExport.getJqExportRadioLevel1()
- .add(ptlAgreementProductCostsExport.getJqExportRadioLevel2())
- .add(ptlAgreementProductCostsExport.getJqExportRadioLevel3())
- .add(ptlAgreementProductCostsExport.getJqExportRadioLevel4())
- .add(ptlAgreementProductCostsExport.getJqExportRadioLevel5());
- //获取商业机构管理费总比例
- BigDecimal syDeptProportion = ptlAgreementProductCostsExport.getSyExportRadioLevel1()
- .add(ptlAgreementProductCostsExport.getSyExportRadioLevel2())
- .add(ptlAgreementProductCostsExport.getSyExportRadioLevel3())
- .add(ptlAgreementProductCostsExport.getSyExportRadioLevel4())
- .add(ptlAgreementProductCostsExport.getSyExportRadioLevel5());
- //获取非车机构管理费总比例
- BigDecimal noDeptProportion = ptlAgreementProductCostsExport.getNoCarExportRadioLevel1()
- .add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel2())
- .add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel3())
- .add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel4())
- .add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel5());
- //获取交强分销总比例
- BigDecimal jqRetailProportion = retailProportion.getJqRetailLevel1Proportion()
- .add(retailProportion.getJqRetailLevel2Proportion())
- .add(retailProportion.getJqRetailLevel3Proportion());
- //获取商业分销总比例
- BigDecimal syRetailProportion = retailProportion.getSyRetailLevel1Proportion()
- .add(retailProportion.getSyRetailLevel2Proportion())
- .add(retailProportion.getSyRetailLevel3Proportion());
- //获取非车分销总比例
- BigDecimal noRetailProportion = retailProportion.getNoRetailLevel1Proportion()
- .add(retailProportion.getNoRetailLevel2Proportion())
- .add(retailProportion.getNoRetailLevel3Proportion());
- // 外部订单比例
- BigDecimal enterProportion = sysSwitchConfigService.getEnterProportion(insOrders.getDeptid(), insOrders.getEntryStatus());
- //重新计算比例 入口是否超出支付的比例
- ReCalcuLateProportion jqReCalcuLateProportion = recalculateProportion(
- new BigDecimal(ptlAgreementProductCostsNew.getJqCostsProportion()),
- jqDeptProportion,
- jqRetailProportion,
- taxRadio,
- retailLevel,
- ptlAgreementProductCostsExport,
- retailProportion,
- "jq",
- enterProportion
- );
- ReCalcuLateProportion syReCalcuLateProportion = recalculateProportion(
- new BigDecimal(ptlAgreementProductCostsNew.getSyCostsProportion()),
- syDeptProportion,
- syRetailProportion,
- taxRadio,
- retailLevel,
- ptlAgreementProductCostsExport,
- retailProportion,
- "sy",
- enterProportion
- );
- ReCalcuLateProportion noReCalcuLateProportion = recalculateProportion(
- new BigDecimal(ptlAgreementProductCostsNew.getNoCostsProportion()),
- noDeptProportion,
- noRetailProportion,
- taxRadio,
- retailLevel,
- ptlAgreementProductCostsExport,
- retailProportion,
- "no",
- enterProportion
- );
- retailProportion.setProportion(jqReCalcuLateProportion, syReCalcuLateProportion, noReCalcuLateProportion);
- //endregion
- //region 计算分销费用
- //获取分销比例
- //分销总比例
- BigDecimal jqRetailRadio = new BigDecimal("0");
- BigDecimal syRetailRadio = new BigDecimal("0");
- BigDecimal noRetailRadio = new BigDecimal("0");
- FeeOrderNewVo.RetailFee retailFeeLevel3 = new FeeOrderNewVo.RetailFee();
- FeeOrderNewVo.RetailFee retailFeeLevel2 = new FeeOrderNewVo.RetailFee();
- FeeOrderNewVo.RetailFee retailFeeLevel1 = new FeeOrderNewVo.RetailFee();
- if (esmRetailList != null && !esmRetailList.isEmpty()) {
- EsmRetail esmRetail = esmRetailList.get(0);
- //分销等级
- insFeeOrderNew.setDistributionStatus(esmRetailList.get(0).getRetailtype());
- //用户分销人员id
- List<EsmUserReferrer> parents = esmUserReferrerService.findParents(sysUser.getId());
- if (esmRetail != null) {
- if (Integer.parseInt(esmRetail.getRetailtype()) >= 3) {
- insFeeOrderNew.setThirdDetailProportion(retailProportion.getJqRetailLevel3Proportion());
- retailFeeLevel3 = feeRuleSchemeService.calcRetail(insFeeOrderNew.getJqPremium(),
- insFeeOrderNew.getJqCostsProportion(),
- insFeeOrderNew.getSyPremium(),
- insFeeOrderNew.getSyCostsProportion().add(insFeeOrderNew.getSyOtherCostsProportion()),
- insFeeOrderNew.getNoPremium(),
- insFeeOrderNew.getNoCostsProportion().add(insFeeOrderNew.getNoOtherCostsProportion()),
- retailProportion.getJqRetailLevel3Proportion(),
- retailProportion.getSyRetailLevel3Proportion(),
- retailProportion.getNoRetailLevel3Proportion());
- insFeeOrderNew.setThirdDetailPremiums(retailFeeLevel3.getTotalRetailPremiums());
- if (parents != null && parents.size() > 2) {
- insFeeOrderNew.setThreeLevelUserId(parents.get(2).getId());
- }
- } else {
- insFeeOrderNew.setThirdDetailProportion(new BigDecimal(0));
- }
- if (Integer.parseInt(esmRetail.getRetailtype()) >= 2) {
- insFeeOrderNew.setSecondDetailProportion(retailProportion.getJqRetailLevel2Proportion());
- retailFeeLevel2 = feeRuleSchemeService.calcRetail(insFeeOrderNew.getJqPremium(),
- insFeeOrderNew.getJqCostsProportion(),
- insFeeOrderNew.getSyPremium(),
- insFeeOrderNew.getSyCostsProportion(),
- insFeeOrderNew.getNoPremium(),
- insFeeOrderNew.getNoCostsProportion(),
- retailProportion.getJqRetailLevel2Proportion(),
- retailProportion.getSyRetailLevel2Proportion(),
- retailProportion.getNoRetailLevel2Proportion());
- insFeeOrderNew.setSecondDetailPremiums(retailFeeLevel2.getTotalRetailPremiums());
- if (parents != null && parents.size() > 1) {
- insFeeOrderNew.setTwoLevelUserId(parents.get(1).getId());
- }
- } else {
- insFeeOrderNew.setSecondDetailProportion(new BigDecimal(0));
- }
- if (Integer.parseInt(esmRetail.getRetailtype()) >= 1) {
- insFeeOrderNew.setFirstDetailProportion(retailProportion.getJqRetailLevel1Proportion());
- retailFeeLevel1 = feeRuleSchemeService.calcRetail(insFeeOrderNew.getJqPremium(),
- insFeeOrderNew.getJqCostsProportion(),
- insFeeOrderNew.getSyPremium(),
- insFeeOrderNew.getSyCostsProportion(),
- insFeeOrderNew.getNoPremium(),
- insFeeOrderNew.getNoCostsProportion(),
- retailProportion.getJqRetailLevel1Proportion(),
- retailProportion.getSyRetailLevel1Proportion(),
- retailProportion.getNoRetailLevel1Proportion());
- insFeeOrderNew.setFirstDetailPremiums(retailFeeLevel1.getTotalRetailPremiums());
- if (parents != null && !parents.isEmpty()) {
- insFeeOrderNew.setFirstLevelUserId(parents.get(0).getId());
- }
- } else {
- insFeeOrderNew.setFirstDetailProportion(new BigDecimal(0));
- }
- } else {
- insFeeOrderNew.setFirstDetailPremiums(new BigDecimal(0));
- insFeeOrderNew.setSecondDetailPremiums(new BigDecimal(0));
- insFeeOrderNew.setThirdDetailPremiums(new BigDecimal(0));
- }
- } else {
- insFeeOrderNew.setFirstDetailProportion(new BigDecimal(0));
- insFeeOrderNew.setSecondDetailProportion(new BigDecimal(0));
- insFeeOrderNew.setThirdDetailProportion(new BigDecimal(0));
- }
- jqRetailRadio = jqRetailRadio.add(retailFeeLevel1.getJqRetailProportion())
- .add(retailFeeLevel2.getJqRetailProportion())
- .add(retailFeeLevel3.getJqRetailProportion());
- syRetailRadio = syRetailRadio.add(retailFeeLevel1.getSyRetailProportion())
- .add(retailFeeLevel2.getSyRetailProportion())
- .add(retailFeeLevel3.getSyRetailProportion());
- noRetailRadio = noRetailRadio.add(retailFeeLevel1.getNoRetailProportion())
- .add(retailFeeLevel2.getNoRetailProportion())
- .add(retailFeeLevel3.getNoRetailProportion());
- insFeeOrderNew.assignRetail(retailFeeLevel1, retailFeeLevel2, retailFeeLevel3);
- //endregion
- //region 设置机构管理费
- //交强机构管理费
- BigDecimal jqDeptRadio =
- jqReCalcuLateProportion.getDept_level_1_proportion()
- .add(jqReCalcuLateProportion.getDept_level_2_proportion())
- .add(jqReCalcuLateProportion.getDept_level_3_proportion())
- .add(jqReCalcuLateProportion.getDept_level_4_proportion())
- .add(jqReCalcuLateProportion.getDept_level_5_proportion());
- FeeOrderNewVo.DeptManagerFee jqDeptManagerFee = feeRuleSchemeService.calcDeptManagerFee(
- insFeeOrderNew.getJqPremium(),
- jqReCalcuLateProportion.getDept_level_1_proportion(),
- jqReCalcuLateProportion.getDept_level_2_proportion(),
- jqReCalcuLateProportion.getDept_level_3_proportion(),
- jqReCalcuLateProportion.getDept_level_4_proportion(),
- jqReCalcuLateProportion.getDept_level_5_proportion());
- BigDecimal syDeptRadio =
- syReCalcuLateProportion.getDept_level_1_proportion()
- .add(syReCalcuLateProportion.getDept_level_2_proportion())
- .add(syReCalcuLateProportion.getDept_level_3_proportion())
- .add(syReCalcuLateProportion.getDept_level_4_proportion())
- .add(syReCalcuLateProportion.getDept_level_5_proportion());
- FeeOrderNewVo.DeptManagerFee syDeptManagerFee = feeRuleSchemeService.calcDeptManagerFee(
- insFeeOrderNew.getSyPremium(),
- syReCalcuLateProportion.getDept_level_1_proportion(),
- syReCalcuLateProportion.getDept_level_2_proportion(),
- syReCalcuLateProportion.getDept_level_3_proportion(),
- syReCalcuLateProportion.getDept_level_4_proportion(),
- syReCalcuLateProportion.getDept_level_5_proportion());
- BigDecimal noDeptRadio =
- noReCalcuLateProportion.getDept_level_1_proportion()
- .add(noReCalcuLateProportion.getDept_level_2_proportion())
- .add(noReCalcuLateProportion.getDept_level_3_proportion())
- .add(noReCalcuLateProportion.getDept_level_4_proportion())
- .add(noReCalcuLateProportion.getDept_level_5_proportion());
- FeeOrderNewVo.DeptManagerFee noDeptManagerFee = feeRuleSchemeService.calcDeptManagerFee(
- insFeeOrderNew.getNoPremium(),
- noReCalcuLateProportion.getDept_level_1_proportion(),
- noReCalcuLateProportion.getDept_level_2_proportion(),
- noReCalcuLateProportion.getDept_level_3_proportion(),
- noReCalcuLateProportion.getDept_level_4_proportion(),
- noReCalcuLateProportion.getDept_level_5_proportion());
- insFeeOrderNew.assignDept(jqDeptManagerFee, syDeptManagerFee, noDeptManagerFee);
- //endregion
- //region 出口费用
- //交强出口手续费比例
- FeeOrderNewVo.ExportFee jqExportFee = feeRuleSchemeService.calcExportFee(
- insFeeOrderNew.getJqPremium(),
- new BigDecimal(ptlAgreementProductCostsNew.getJqCostsExportProportion()),
- insFeeOrderNew.getJqCostsProportion(),
- jqDeptRadio,
- jqRetailRadio,
- taxRadio,
- jqReCalcuLateProportion.getProxyProportion()
- );
- //商业出口手续费比例
- FeeOrderNewVo.ExportFee syExportFee = feeRuleSchemeService.calcExportFee(
- insFeeOrderNew.getSyPremium(),
- new BigDecimal(ptlAgreementProductCostsNew.getSyCostsExportProportion()),
- insFeeOrderNew.getSyCostsProportion(),
- syDeptRadio,
- syRetailRadio,
- taxRadio,
- syReCalcuLateProportion.getProxyProportion()
- );
- //非车出口手续费比例
- FeeOrderNewVo.ExportFee noExportFee = feeRuleSchemeService.calcExportFee(
- insFeeOrderNew.getNoPremium(),
- new BigDecimal(ptlAgreementProductCostsNew.getNoCostsExportProportion()),
- insFeeOrderNew.getNoCostsProportion(),
- noDeptRadio,
- noRetailRadio,
- taxRadio,
- noReCalcuLateProportion.getProxyProportion()
- );
- //出口手续费用
- insFeeOrderNew.setJqExportSuperviseCostsPremiums(twoPeople(jqExportFee.getSuperviseCostsPremiums()));
- insFeeOrderNew.setSyExportSuperviseCostsPremiums(twoPeople(syExportFee.getSuperviseCostsPremiums()));
- insFeeOrderNew.setNoExportSuperviseCostsPremiums(twoPeople(noExportFee.getSuperviseCostsPremiums()));
- //出口其他费用比例
- insFeeOrderNew.setJqExportOtherCostsProportion(twoPeople(jqExportFee.getOtherCostsProportion()));
- insFeeOrderNew.setSyExportOtherCostsProportion(twoPeople(syExportFee.getOtherCostsProportion()));
- insFeeOrderNew.setNoExportOtherCostsProportion(twoPeople(noExportFee.getOtherCostsProportion()));
- //出口其他费用
- insFeeOrderNew.setJqExportOtherCostsPremiums(twoPeople(jqExportFee.getOtherCostsPremiums()));
- insFeeOrderNew.setSyExportOtherCostsPremiums(twoPeople(syExportFee.getOtherCostsPremiums()));
- insFeeOrderNew.setNoExportOtherCostsPremiums(twoPeople(noExportFee.getOtherCostsPremiums()));
- //设置出口手续费比例
- insFeeOrderNew.setJqCostsExportProportion(twoPeople(jqExportFee.getSuperviseCosts()));
- insFeeOrderNew.setSyCostsExportProportion(twoPeople(syExportFee.getSuperviseCosts()));
- insFeeOrderNew.setNoCostsExportProportion(twoPeople(noExportFee.getSuperviseCosts()));
- // 外部费用
- insFeeOrderNew.setJqExternalProportion(jqExportFee.getExternalProportion());
- insFeeOrderNew.setJqExternalPremiums(jqExportFee.getExternalPremiums());
- insFeeOrderNew.setSyExternalProportion(syExportFee.getExternalProportion());
- insFeeOrderNew.setSyExternalPremiums(syExportFee.getExternalPremiums());
- insFeeOrderNew.setNoExternalProportion(noExportFee.getExternalProportion());
- insFeeOrderNew.setNoExternalPremiums(noExportFee.getExternalPremiums());
- //endregion
- //region 计算利润差值
- //入口 - 出口 - 机构管理费 1-5级 - 分销费 = 差值
- //分销交强费用
- //分开算 1 2 3 级
- BigDecimal jqFirst = insFeeOrderNew.getJqPremium().multiply(insFeeOrderNew.getJqRetailProportionLevel1().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- BigDecimal jqSecond = insFeeOrderNew.getJqPremium().multiply(insFeeOrderNew.getJqRetailProportionLevel2().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- BigDecimal jqThird = insFeeOrderNew.getJqPremium().multiply(insFeeOrderNew.getJqRetailProportionLevel3().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- BigDecimal jqFenXiao = jqFirst.add(jqSecond).add(jqThird);
- //分销商业费用
- BigDecimal syFirst = insFeeOrderNew.getSyPremium().multiply(insFeeOrderNew.getSyRetailProportionLevel1().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- BigDecimal sySecond = insFeeOrderNew.getSyPremium().multiply(insFeeOrderNew.getSyRetailProportionLevel2().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- BigDecimal syThird = insFeeOrderNew.getSyPremium().multiply(insFeeOrderNew.getSyRetailProportionLevel3().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- BigDecimal syFenXiao = syFirst.add(sySecond).add(syThird);
- //分销非车费用
- BigDecimal noFirst = insFeeOrderNew.getNoPremium().multiply(insFeeOrderNew.getNoRetailProportionLevel1().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- BigDecimal noSecond = insFeeOrderNew.getNoPremium().multiply(insFeeOrderNew.getNoRetailProportionLevel2().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- BigDecimal noThird = insFeeOrderNew.getNoPremium().multiply(insFeeOrderNew.getNoRetailProportionLevel3().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
- BigDecimal noFenXiao = noFirst.add(noSecond).add(noThird);
- BigDecimal jqDifference = jqEntranceFee.getTotalAmount()
- .subtract(jqExportFee.getExternalPremiums())
- .subtract(
- (jqExportFee.getSuperviseCostsPremiums().add(jqExportFee.getOtherCostsPremiums())))
- .subtract(
- (jqDeptManagerFee.getDeptPremiumsLevelOne().add(jqDeptManagerFee.getDeptPremiumsLevelTwo().add(jqDeptManagerFee.getDeptPremiumsLevelThree()).add(jqDeptManagerFee.getDeptPremiumsLevelFoure()).add(jqDeptManagerFee.getDeptPremiumsLevelFive())))
- )
- .subtract(jqFenXiao)
- .setScale(5, BigDecimal.ROUND_HALF_DOWN);
- insFeeOrderNew.setJqProfitMarginPremiums(jqDifference);
- BigDecimal syDifference = syEntranceFee.getTotalAmount()
- .subtract(syExportFee.getExternalPremiums())
- .subtract(
- (syExportFee.getSuperviseCostsPremiums().add(syExportFee.getOtherCostsPremiums())))
- .subtract(
- (syDeptManagerFee.getDeptPremiumsLevelOne().add(syDeptManagerFee.getDeptPremiumsLevelTwo().add(syDeptManagerFee.getDeptPremiumsLevelThree()).add(syDeptManagerFee.getDeptPremiumsLevelFoure()).add(syDeptManagerFee.getDeptPremiumsLevelFive())))
- )
- .subtract(syFenXiao)
- .setScale(5, BigDecimal.ROUND_HALF_DOWN);
- insFeeOrderNew.setSyProfitMarginPremiums(syDifference);
- BigDecimal noDifference = noEntranceFee.getTotalAmount()
- .subtract(noExportFee.getExternalPremiums())
- .subtract(
- (noExportFee.getSuperviseCostsPremiums().add(noExportFee.getOtherCostsPremiums())))
- .subtract(
- (noDeptManagerFee.getDeptPremiumsLevelOne().add(noDeptManagerFee.getDeptPremiumsLevelTwo().add(noDeptManagerFee.getDeptPremiumsLevelThree()).add(noDeptManagerFee.getDeptPremiumsLevelFoure()).add(noDeptManagerFee.getDeptPremiumsLevelFive())))
- )
- .subtract(noFenXiao)
- .setScale(5, BigDecimal.ROUND_HALF_DOWN);
- insFeeOrderNew.setNoProfitMarginPremiums(noDifference);
- //endregion
- //region 比例逆推是否等于0
- if (!feeRuleSchemeService.calculateProportion(jqEntranceFee, jqDeptManagerFee, jqExportFee, jqRetailRadio, taxRadio, insFeeOrderNew.getJqPremium()))
- throw new SystemException("交强比例异常");
- if (!feeRuleSchemeService.calculateProportion(syEntranceFee, syDeptManagerFee, syExportFee, syRetailRadio, taxRadio, insFeeOrderNew.getSyPremium()))
- throw new SystemException("商业比例异常");
- if (!feeRuleSchemeService.calculateProportion(noEntranceFee, noDeptManagerFee, noExportFee, noRetailRadio, taxRadio, insFeeOrderNew.getNoPremium()))
- throw new SystemException("非车比例异常");
- //endregion
- insFeeOrderNewHistoryService.saveInsFeeOrderNewHistory(insFeeOrderNew);
- insFeeOrderNewService.saveOrUpdate(insFeeOrderNew);
- }
- /**
- * 判断是否包含非车险
- *
- * @param insAreaCompany
- * @return
- */
- private boolean isContainNonCar(InsAreaCompany insAreaCompany) {
- if (insAreaCompany.getCrossInsurance() != null && insAreaCompany.getJypremium().equals(BigDecimal.ZERO)) {
- return false;
- }
- return true;
- }
- /**
- * 匹配费用因子
- *
- * @param agreementProductCosts
- * @param insAreaCompany
- * @param insOrders
- * @return
- */
- private String verificationCosts(List<AgreementProductCosts> agreementProductCosts, InsAreaCompany insAreaCompany,
- InsOrders insOrders, StringBuilder logs) {
- //匹配费用因子
- //获取所有费用属性
- List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList = ptlAgreementUndwrtRulesAttrService.getUndwrtRulesAttrList();
- //获取新旧车信息
- PtlNewCarJudgeRules carJudgeRule = getCarJudgeRule(insAreaCompany.getCompanyId());
- //获取所有费用属性关联
- List<RuleAttrMappingVo> ruleAttrMappingVoList = RuleAttrMappingVo.getRuleAttrMappingVoList(insAreaCompany, insOrders,
- undwrtRulesAttrList, carJudgeRule);
- for (int i = 0; i < agreementProductCosts.size(); i++) {
- //判断是否匹配
- log.debug("费用因子匹配开始:" + agreementProductCosts.get(i).getId());
- log.debug("车牌号:" + insOrders.getLicenseno());
- log.debug("费用因子备注:" + agreementProductCosts.get(i).getCostsDescription());
- logs.append("费用id:" + agreementProductCosts.get(i).getId() + "\n");
- logs.append("费用因子描述:" + agreementProductCosts.get(i).getCostsDescription() + "\n");
- if (judgements(agreementProductCosts.get(i).getCostsAttrLinks(), undwrtRulesAttrList, ruleAttrMappingVoList, logs)) {
- //返回 费用id 如果需要匹配非车的情况 将返回值返回list 后赛选
- return agreementProductCosts.get(i).getId();
- }
- log.debug("当前费用因子匹配结束\n");
- }
- return null;
- // throw new SystemException("费用因子匹配失败");
- }
- private boolean verificationRules(List<PtlAgreementUndwrtRulesNew> ptlAgreementUndwrtRulesNews, InsAreaCompany insAreaCompany,
- InsOrders insOrders) {
- StringBuilder logs = new StringBuilder();
- //匹配承保规则
- //获取所有承保规则属性
- List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList = ptlAgreementUndwrtRulesAttrService.getUndwrtRulesAttrList();
- //获取所有费用属性关联
- List<RuleAttrMappingVo> ruleAttrMappingVoList = RuleAttrMappingVo.getRuleAttrMappingVoList(insAreaCompany, insOrders,
- undwrtRulesAttrList, getCarJudgeRule(insAreaCompany.getCompanyId()));
- for (int i = 0; i < ptlAgreementUndwrtRulesNews.size(); i++) {
- logs.append("触发承保规则:" + ptlAgreementUndwrtRulesNews.get(i).getRuleDescription() + "\n");
- //判断是否匹配
- if (!judgementsRules(ptlAgreementUndwrtRulesNews.get(i).getRulesAttrList(), undwrtRulesAttrList, ruleAttrMappingVoList, logs,insOrders)) {
- throw new SystemException(logs.toString());
- }else{
- //如果没有出现异常则清空匹配消息
- logs.delete(0,logs.length());
- }
- }
- return true;
- }
- /**
- * 费用因子的对比
- *
- * @param ptlAgreementProductCostsAttrLinks 费用因子范围规则
- * @param rulesAttrs 费用因子属性
- * @param ruleAttrMappingVoList 表单提交的值
- * @return
- */
- private boolean judgements(List<PtlAgreementProductCostsAttrLink> ptlAgreementProductCostsAttrLinks,
- List<PtlAgreementUndwrtRulesAttr> rulesAttrs, List<RuleAttrMappingVo> ruleAttrMappingVoList,
- StringBuilder logs) {
- boolean useFlag = true;
- for (PtlAgreementProductCostsAttrLink ptlAgreementProductCostsAttrLink : ptlAgreementProductCostsAttrLinks) {
- //查找规则中的 传值属性
- RuleAttrMappingVo ruleAttrMappingVo = ruleAttrMappingVoList.stream()
- .filter(x -> x.getAttrCode().equals(ptlAgreementProductCostsAttrLink.getAttrCode()))
- .findFirst()
- .orElse(null);
- //如果查找不到 传值属性 直接费用对比失败
- if (ruleAttrMappingVo == null) {
- log.debug("传入的值找不到该属性:" + ptlAgreementProductCostsAttrLink.getAttrCode());
- log.debug("规则匹配失败:" + ptlAgreementProductCostsAttrLink.getAttrCode());
- List<PtlAgreementUndwrtRulesAttr> collect = rulesAttrs.stream()
- .filter(x -> x.getAttrCode().equals(ptlAgreementProductCostsAttrLink.getAttrCode()))
- .collect(Collectors.toList());
- if (!collect.isEmpty()) {
- logs.append("规则匹配失败:" + collect.get(0).getAttrName() + "\n");
- }
- return false;
- }
- //查找 费用因子规则
- PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr = rulesAttrs.stream()
- .filter(x -> x.getAttrCode().equals(ptlAgreementProductCostsAttrLink.getAttrCode()))
- .findFirst()
- .get();
- if(!Objects.isNull(ruleAttrMappingVo.getValue())) {
- useFlag = attrEqual(ptlAgreementProductCostsAttrLink, ptlAgreementUndwrtRulesAttr, ruleAttrMappingVo.getValue());
- }else{
- useFlag = false;
- }
- if (!useFlag) {
- log.debug("检验的值:" + ptlAgreementProductCostsAttrLink.getMin());
- log.debug("传入的值:" + ruleAttrMappingVo.getValue());
- log.debug("规则匹配失败:" + ptlAgreementProductCostsAttrLink.getAttrCode());
- List<PtlAgreementUndwrtRulesAttr> collect = rulesAttrs.stream()
- .filter(x -> x.getAttrCode().equals(ptlAgreementProductCostsAttrLink.getAttrCode()))
- .collect(Collectors.toList());
- if (ptlAgreementProductCostsAttrLink.getMin() != null) {
- logs.append("检验的值:" + ptlAgreementProductCostsAttrLink.getMin() + "\n");
- } else {
- logs.append("检验的值:" + ptlAgreementProductCostsAttrLink.getMax() + "\n");
- }
- logs.append("传入的值:" + ruleAttrMappingVo.getValue() + "\n");
- if (!collect.isEmpty()) {
- logs.append("<span style=\"color:red;\">规则匹配失败:" + collect.get(0).getAttrName() + "</span>\n");
- }
- return false;
- }
- }
- return useFlag;
- }
- /**
- * 承保规则因子的对比
- *
- * @param ptlAgreementUndwrtRulesAttrLinks
- * @param rulesAttrs
- * @param ruleAttrMappingVoList
- * @return
- */
- private boolean judgementsRules(List<PtlAgreementUndwrtRulesAttrLink> ptlAgreementUndwrtRulesAttrLinks,
- List<PtlAgreementUndwrtRulesAttr> rulesAttrs, List<RuleAttrMappingVo> ruleAttrMappingVoList,
- StringBuilder logs,InsOrders insOrders) {
- boolean useFlag = true;
- for (int i = 0; i < ptlAgreementUndwrtRulesAttrLinks.size(); i++) {
- int finalI = i;
- //查找规则中的 传值属性
- RuleAttrMappingVo ruleAttrMappingVo = ruleAttrMappingVoList.stream().filter(x ->
- x.getAttrCode().equals(ptlAgreementUndwrtRulesAttrLinks.get(finalI).getAttrCode())).findFirst().orElse(null);
- //如果查找不到 传值属性 直接费用对比失败
- if (ruleAttrMappingVo == null) {
- return true;
- }
- //查找 费用因子规则
- PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr =
- rulesAttrs.stream().filter(x -> x.getAttrCode().equals(ptlAgreementUndwrtRulesAttrLinks.get(finalI).getAttrCode())).findFirst().get();
- //如果是多选 对value进行转换
- if (ptlAgreementUndwrtRulesAttr.getAttrType().equals("checkbox")) {
- PtlAgreementUndwrtRulesDictLabal ptlAgreementUndwrtRulesDictLabal =
- ptlAgreementUndwrtRulesAttr.getDictLabal().stream().filter(x ->
- x.getName().equals(ruleAttrMappingVo.getValue())).findFirst().orElse(null);
- ruleAttrMappingVo.setValue(ptlAgreementUndwrtRulesDictLabal.getName());
- }
- //如果是单选 并且是 性别的话 转换为code
- if (ptlAgreementUndwrtRulesAttr.getAttrType().equals("radio")) {
- if ("CarOwnersSex".equals(ptlAgreementUndwrtRulesAttr.getAttrCode()) || "ApplicantSex".equals(ptlAgreementUndwrtRulesAttr.getAttrCode()) ||
- "InsuredSex".equals(ptlAgreementUndwrtRulesAttr.getAttrCode())) {
- PtlAgreementUndwrtRulesDictLabal ptlAgreementUndwrtRulesDictLabal =
- ptlAgreementUndwrtRulesAttr.getDictLabal().stream().filter(x ->
- x.getCode().equals(ruleAttrMappingVo.getValue())).findFirst().orElse(null);
- ruleAttrMappingVo.setValue(ptlAgreementUndwrtRulesDictLabal.getCode());
- }
- }
- if(!Objects.isNull(ruleAttrMappingVo.getValue())) {
- useFlag = attrEqual(ptlAgreementUndwrtRulesAttrLinks.get(i), ptlAgreementUndwrtRulesAttr, ruleAttrMappingVo.getValue(),insOrders);
- }else{
- useFlag = false;
- }
- if (useFlag) {
- return true;
- } else {
- logs.append("规则匹配失败:" + ptlAgreementUndwrtRulesAttrLinks.get(i).getAttrCode() + "\n");
- if (ptlAgreementUndwrtRulesAttrLinks.get(i).getMin() != null) {
- logs.append("校验的值:" + ptlAgreementUndwrtRulesAttrLinks.get(i).getMin() + "\n");
- } else {
- logs.append("校验的值:" + ptlAgreementUndwrtRulesAttrLinks.get(i).getMax() + "\n");
- }
- logs.append("传入的值:" + ruleAttrMappingVo.getValue() + "\n");
- }
- }
- return useFlag;
- }
- /**
- * 费用因子的对比 强制非车险
- *
- * @param ptlAgreementProductCostsAttrLinks 费用因子范围规则
- * @param rulesAttrs 费用因子属性
- * @param ruleAttrMappingVoList 表单提交的值
- * @return
- */
- private boolean judgementsIsNoCar(List<PtlAgreementProductCostsAttrLink> ptlAgreementProductCostsAttrLinks,
- List<PtlAgreementUndwrtRulesAttr> rulesAttrs, List<RuleAttrMappingVo> ruleAttrMappingVoList) {
- boolean useFlag = true;
- for (int i = 0; i < ptlAgreementProductCostsAttrLinks.size(); i++) {
- int finalI = i;
- //查找规则中的 传值属性
- RuleAttrMappingVo ruleAttrMappingVo =
- ruleAttrMappingVoList.stream().filter(x -> x.getAttrCode().equals(ptlAgreementProductCostsAttrLinks.get(finalI).getAttrCode())).findFirst().orElse(null);
- //如果是强制非车险
- if (ptlAgreementProductCostsAttrLinks.get(i).getAttrCode().equals("IsNonMotorInsurance"))
- continue;
- //如果查找不到 传值属性 直接费用对比失败
- if (ruleAttrMappingVo == null)
- return false;
- //查找 费用因子规则
- PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr =
- rulesAttrs.stream().filter(x -> x.getAttrCode().equals(ptlAgreementProductCostsAttrLinks.get(finalI).getAttrCode())).findFirst().get();
- //如果是多选 对value进行转换
- if (ptlAgreementUndwrtRulesAttr.getAttrType().equals("checkbox")) {
- PtlAgreementUndwrtRulesDictLabal ptlAgreementUndwrtRulesDictLabal =
- ptlAgreementUndwrtRulesAttr.getDictLabal().stream().filter(x ->
- x.getCode().equals(ruleAttrMappingVo.getValue())).findFirst().orElse(null);
- ruleAttrMappingVo.setValue(ptlAgreementUndwrtRulesDictLabal.getName());
- }
- //如果是单选 并且是 性别的话 转换为code
- if (ptlAgreementUndwrtRulesAttr.getAttrType().equals("radio")) {
- if ("CarOwnersSex".equals(ptlAgreementUndwrtRulesAttr.getAttrCode()) || "ApplicantSex".equals(ptlAgreementUndwrtRulesAttr.getAttrCode()) ||
- "InsuredSex".equals(ptlAgreementUndwrtRulesAttr.getAttrCode())) {
- PtlAgreementUndwrtRulesDictLabal ptlAgreementUndwrtRulesDictLabal =
- ptlAgreementUndwrtRulesAttr.getDictLabal().stream().filter(x ->
- x.getName().equals(ruleAttrMappingVo.getValue())).findFirst().orElse(null);
- ruleAttrMappingVo.setValue(ptlAgreementUndwrtRulesDictLabal.getCode());
- }
- }
- useFlag = attrEqual(ptlAgreementProductCostsAttrLinks.get(i), ptlAgreementUndwrtRulesAttr, ruleAttrMappingVo.getValue());
- if (!useFlag) {
- System.out.printf("规则匹配失败:" + ptlAgreementProductCostsAttrLinks.get(i).getAttrCode());
- return false;
- }
- }
- return useFlag;
- }
- /**
- * 属性比较 返回 是否匹配
- *
- * @param ptlAgreementProductCostsAttrLink
- * @param ptlAgreementUndwrtRulesAttr
- * @param value
- * @return
- */
- private boolean attrEqual(PtlAgreementProductCostsAttrLink ptlAgreementProductCostsAttrLink,
- PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr, String value) {
- if (ptlAgreementUndwrtRulesAttr.getAttrType().equals("checkbox")) {
- return checkBoxEqual(ptlAgreementProductCostsAttrLink, value);
- } else if (ptlAgreementUndwrtRulesAttr.getAttrType().equals("inputNumber")) {
- return inputNumberEqual(ptlAgreementProductCostsAttrLink, value);
- } else if (ptlAgreementUndwrtRulesAttr.getAttrType().equals("input")) {
- //截取身份证号码
- if (ptlAgreementProductCostsAttrLink.getAttrCode().equals("CarOwnersIDNumber") || ptlAgreementProductCostsAttrLink.getAttrCode().equals("ApplicantIDNumber") ||
- ptlAgreementProductCostsAttrLink.getAttrCode().equals("InsuredIDNumber")) {
- value = value.substring(0, ptlAgreementProductCostsAttrLink.getMin().length());
- }
- return inputTextEqual(ptlAgreementProductCostsAttrLink, value);
- } else if (ptlAgreementUndwrtRulesAttr.getAttrType().equals("select")) {
- //截取车牌
- if (ptlAgreementUndwrtRulesAttr.getAttrCode().equals("LicenseNo")) {
- value = value.substring(0, 2);
- }
- return selectEqual(ptlAgreementProductCostsAttrLink, value);
- } else if (ptlAgreementUndwrtRulesAttr.getAttrType().equals("radio")) {
- return radioEqual(ptlAgreementProductCostsAttrLink, value);
- } else if (ptlAgreementUndwrtRulesAttr.getAttrType().equals("datetime")){ // 时间
- return dateTimeEqual(ptlAgreementProductCostsAttrLink, value);
- } else if (ptlAgreementUndwrtRulesAttr.getAttrType().equals("date")){
- return dateEqual(ptlAgreementProductCostsAttrLink, value);
- }
- return false;
- }
- private boolean attrEqual(PtlAgreementUndwrtRulesAttrLink ptlAgreementUndwrtRulesAttrLink,
- PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr, String value,InsOrders insOrders) {
- if (ptlAgreementUndwrtRulesAttr.getAttrType().equals("checkbox")) {
- return checkBoxEqual(ptlAgreementUndwrtRulesAttrLink, value);
- } else if (ptlAgreementUndwrtRulesAttr.getAttrType().equals("inputNumber")) {
- //如果是空字符串 则返回false
- // if(value.equals("")){
- // return false;
- // }
- return inputNumberEqual(ptlAgreementUndwrtRulesAttrLink, value);
- } else if (ptlAgreementUndwrtRulesAttr.getAttrType().equals("input")) {
- //截取身份证号码
- if (ptlAgreementUndwrtRulesAttr.getAttrCode().equals("CarOwnersIDNumber") || ptlAgreementUndwrtRulesAttr.getAttrCode().equals("ApplicantIDNumber") ||
- ptlAgreementUndwrtRulesAttr.getAttrCode().equals("InsuredIDNumber")) {
- value = value.substring(0, ptlAgreementUndwrtRulesAttrLink.getMin().length());
- }
- return inputTextEqual(ptlAgreementUndwrtRulesAttrLink, value);
- } else if (ptlAgreementUndwrtRulesAttr.getAttrType().equals("select")) {
- //截取车牌
- if (ptlAgreementUndwrtRulesAttr.getAttrCode().equals("LicenseNo")) {
- value = value.substring(0, 2);
- }
- return selectEqual(ptlAgreementUndwrtRulesAttrLink, value);
- } else if (ptlAgreementUndwrtRulesAttr.getAttrType().equals("radio")) {
- return radioEqual(ptlAgreementUndwrtRulesAttrLink, value);
- } else if(ptlAgreementUndwrtRulesAttr.getAttrType().equals("datetime")){
- return dateTimeEqual(ptlAgreementUndwrtRulesAttrLink, value, insOrders);
- } else if(ptlAgreementUndwrtRulesAttr.getAttrType().equals("date")){
- return dateEqual(ptlAgreementUndwrtRulesAttrLink,value);
- }
- return false;
- }
- /**
- * 属性为多选判断
- *
- * @param ptlAgreementProductCostsAttrLink
- * @param value
- * @return
- */
- private boolean checkBoxEqual(PtlAgreementProductCostsAttrLink ptlAgreementProductCostsAttrLink, String value) {
- String[] split = ptlAgreementProductCostsAttrLink.getMin().split(",");
- for (String sp : split) {
- if (sp.equals(value)) {
- return true;
- }
- }
- return false;
- }
- private boolean checkBoxEqual(PtlAgreementUndwrtRulesAttrLink ptlAgreementUndwrtRulesAttrLink, String value) {
- if (!ptlAgreementUndwrtRulesAttrLink.getMin().equals(value)) {
- return true;
- }
- return false;
- }
- /**
- * 属性为数值型判断
- *
- * @param ptlAgreementProductCostsAttrLink
- * @param value
- * @return
- */
- private boolean inputNumberEqual(PtlAgreementProductCostsAttrLink ptlAgreementProductCostsAttrLink, String value) {
- double v = Double.parseDouble(value);
- //统一处理数值
- if ("1".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
- if (Double.parseDouble(ptlAgreementProductCostsAttrLink.getMin()) <= v &&
- Double.parseDouble(ptlAgreementProductCostsAttrLink.getMax()) >= v) {
- return true;
- }
- } else if ("2".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
- if (Double.parseDouble(ptlAgreementProductCostsAttrLink.getMin()) > v) {
- return true;
- }
- } else if ("3".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
- if (Double.parseDouble(ptlAgreementProductCostsAttrLink.getMin()) >= v) {
- return true;
- }
- } else if ("4".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
- if (Double.parseDouble(ptlAgreementProductCostsAttrLink.getMax()) < v) {
- return true;
- }
- } else if ("5".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
- if (Double.parseDouble(ptlAgreementProductCostsAttrLink.getMax()) <= v) {
- return true;
- }
- }
- return false;
- }
- private boolean inputNumberEqual(PtlAgreementUndwrtRulesAttrLink ptlAgreementUndwrtRulesAttrLink, String value) {
- double v = Double.parseDouble(value);
- //统一处理数值
- if ("1".equals(ptlAgreementUndwrtRulesAttrLink.getOperator())) {
- if (Double.parseDouble(ptlAgreementUndwrtRulesAttrLink.getMin()) <= v &&
- Double.parseDouble(ptlAgreementUndwrtRulesAttrLink.getMax()) >= v) {
- return false;
- }
- } else if ("2".equals(ptlAgreementUndwrtRulesAttrLink.getOperator())) {
- if (Double.parseDouble(ptlAgreementUndwrtRulesAttrLink.getMin()) > v) {
- return false;
- }
- } else if ("3".equals(ptlAgreementUndwrtRulesAttrLink.getOperator())) {
- if (Double.parseDouble(ptlAgreementUndwrtRulesAttrLink.getMin()) >= v) {
- return false;
- }
- } else if ("4".equals(ptlAgreementUndwrtRulesAttrLink.getOperator())) {
- if (Double.parseDouble(ptlAgreementUndwrtRulesAttrLink.getMax()) < v) {
- return false;
- }
- } else if ("5".equals(ptlAgreementUndwrtRulesAttrLink.getOperator())) {
- if (Double.parseDouble(ptlAgreementUndwrtRulesAttrLink.getMax()) <= v) {
- return false;
- }
- }
- return true;
- }
- /**
- * 属性为输入框判断
- *
- * @param ptlAgreementProductCostsAttrLink
- * @param value
- * @return
- */
- private boolean inputTextEqual(PtlAgreementProductCostsAttrLink ptlAgreementProductCostsAttrLink, String value) {
- //将值进行分割
- String[] split = ptlAgreementProductCostsAttrLink.getMin().split(",");
- AtomicBoolean returnBool = new AtomicBoolean(false);
- List<String> equalsMap = new ArrayList<>();
- //字符型评分
- equalsMap.add("CharacterBasedRating");
- //交强字符型评分
- equalsMap.add("JqCharacterBasedRating");
- //商业字符型评分
- equalsMap.add("SyCharacterBasedRating");
- //equest 等于判断
- if(equalsMap.contains(ptlAgreementProductCostsAttrLink.getAttrCode())){
- boolean b = Arrays.stream(split).anyMatch(value::equals);
- returnBool.set(b);
- }else if((ptlAgreementProductCostsAttrLink.getAttrCode().equals("BrandandModel") || ptlAgreementProductCostsAttrLink.getAttrCode().equals("CarOwnerName")
- || ptlAgreementProductCostsAttrLink.getAttrCode().equals("CarOwnersAddress") || ptlAgreementProductCostsAttrLink.getAttrCode().equals("ApplicantAddress")
- || ptlAgreementProductCostsAttrLink.getAttrCode().equals("InsuredAddress"))
- && ptlAgreementProductCostsAttrLink.getOperator().equals("2")){
- //处理品牌型号 不包含的情况
- boolean anyMatch = Arrays.stream(split)
- .anyMatch(value::contains);
- returnBool.set(!anyMatch);
- }else {
- boolean anyMatch = Arrays.stream(split)
- .anyMatch(value::contains);
- returnBool.set(anyMatch);
- }
- return returnBool.get();
- }
- private boolean inputTextEqual(PtlAgreementUndwrtRulesAttrLink ptlAgreementUndwrtRulesAttrLink, String value) {
- //将值进行分割
- String[] split = ptlAgreementUndwrtRulesAttrLink.getMin().split(",");
- AtomicBoolean returnBool = new AtomicBoolean(false);
- List<String> equalsMap = new ArrayList<>();
- //字符型评分
- equalsMap.add("CharacterBasedRating");
- //交强字符型评分
- equalsMap.add("JqCharacterBasedRating");
- //商业字符型评分
- equalsMap.add("SyCharacterBasedRating");
- //equest 等于判断
- if(equalsMap.contains(ptlAgreementUndwrtRulesAttrLink.getAttrCode())){
- boolean b = Arrays.stream(split).anyMatch(value::equals);
- returnBool.set(b);
- }else if((ptlAgreementUndwrtRulesAttrLink.getAttrCode().equals("BrandandModel") || ptlAgreementUndwrtRulesAttrLink.getAttrCode().equals("CarOwnerName")
- || ptlAgreementUndwrtRulesAttrLink.getAttrCode().equals("CarOwnersAddress") || ptlAgreementUndwrtRulesAttrLink.getAttrCode().equals("ApplicantAddress")
- || ptlAgreementUndwrtRulesAttrLink.getAttrCode().equals("InsuredAddress"))
- && ptlAgreementUndwrtRulesAttrLink.getOperator().equals("2")){
- //处理品牌型号 不包含的情况
- boolean anyMatch = Arrays.stream(split)
- .anyMatch(value::contains);
- returnBool.set(!anyMatch);
- }else {
- boolean anyMatch = Arrays.stream(split)
- .anyMatch(value::contains);
- returnBool.set(anyMatch);
- }
- return !returnBool.get();
- }
- /**
- * 属性为下拉框判断
- *
- * @param ptlAgreementProductCostsAttrLink
- * @param value
- * @return
- */
- private boolean selectEqual(PtlAgreementProductCostsAttrLink ptlAgreementProductCostsAttrLink, String value) {
- if (ptlAgreementProductCostsAttrLink.getMin() != null && ptlAgreementProductCostsAttrLink.getMin().contains(value)) {
- return true;
- }
- return false;
- }
- /**
- * 属性为选择框判断
- *
- * @param ptlAgreementUndwrtRulesAttrLink
- * @param value
- * @return
- */
- private boolean selectEqual(PtlAgreementUndwrtRulesAttrLink ptlAgreementUndwrtRulesAttrLink, String value) {
- if (ptlAgreementUndwrtRulesAttrLink.getMin() == null) {
- return false;
- }
- if (!ptlAgreementUndwrtRulesAttrLink.getMin().contains(value)) {
- return true;
- }
- return false;
- }
- /**
- * 属性为单选框判断
- *
- * @param ptlAgreementProductCostsAttrLink
- * @param value
- * @return
- */
- private boolean radioEqual(PtlAgreementProductCostsAttrLink ptlAgreementProductCostsAttrLink, String value) {
- //新能源判断
- if ("NewEnergy".equals(ptlAgreementProductCostsAttrLink.getAttrCode())) {
- // 是否是新能源车
- boolean newEnergy = EnergyType.isNewEnergy(value);
- if (newEnergy && ptlAgreementProductCostsAttrLink.getMin().equals("1")) {
- return true;
- } else if (!newEnergy && ptlAgreementProductCostsAttrLink.getMin().equals("0")) {
- return true;
- }
- } else if (ptlAgreementProductCostsAttrLink.getMin().contains(value)) {
- return true;
- }
- return false;
- }
- private boolean radioEqual(PtlAgreementUndwrtRulesAttrLink ptlAgreementUndwrtRulesAttrLink, String value) {
- //新能源判断
- if ("NewEnergy".equals(ptlAgreementUndwrtRulesAttrLink.getAttrCode())) {
- // 是否是新能源车
- boolean newEnergy = EnergyType.isNewEnergy(value);
- if (newEnergy && ptlAgreementUndwrtRulesAttrLink.getMin().equals("1")) {
- return false;
- } else if (!newEnergy && ptlAgreementUndwrtRulesAttrLink.getMin().equals("0")) {
- return false;
- }
- } else if (ptlAgreementUndwrtRulesAttrLink.getMin().contains(value)) {
- return false;
- }
- return true;
- }
- public boolean dateTimeEqual(PtlAgreementProductCostsAttrLink ptlAgreementProductCostsAttrLink, String value){
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
- if(Objects.isNull(value) || value.equals("")){
- return false;
- }
- LocalDateTime v = LocalDateTime.parse(value,formatter);
- LocalDateTime min = null,max = null;
- if(!Objects.isNull(ptlAgreementProductCostsAttrLink.getMin())){
- min = LocalDateTime.parse(ptlAgreementProductCostsAttrLink.getMin(),formatter);
- }
- if(!Objects.isNull(ptlAgreementProductCostsAttrLink.getMax())){
- max = LocalDateTime.parse(ptlAgreementProductCostsAttrLink.getMax(),formatter);
- }
- //统一处理数值
- if ("1".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
- if (v.isAfter(min) && v.isBefore(max)) {
- return true;
- }
- } else if ("2".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
- if (v.isBefore(min)) {
- return true;
- }
- } else if ("3".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
- if (v.isBefore(min) || v.isEqual(min)) {
- return true;
- }
- } else if ("4".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
- if (v.isAfter(max)) {
- return true;
- }
- } else if ("5".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
- if (v.isAfter(max) || v.isEqual(max)) {
- return true;
- }
- }
- return false;
- }
- public boolean dateEqual(PtlAgreementProductCostsAttrLink ptlAgreementProductCostsAttrLink, String value){
- // DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
- if(Objects.isNull(value) || value.equals("")){
- return false;
- }
- LocalDateTime v = LocalDate.parse(value).atStartOfDay();
- LocalDateTime min = null,max = null;
- if(!Objects.isNull(ptlAgreementProductCostsAttrLink.getMin())){
- min = LocalDate.parse(ptlAgreementProductCostsAttrLink.getMin()).atStartOfDay();
- }
- if(!Objects.isNull(ptlAgreementProductCostsAttrLink.getMax())){
- max = LocalDate.parse(ptlAgreementProductCostsAttrLink.getMax()).atStartOfDay();
- }
- //统一处理数值
- if ("1".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
- if (v.isAfter(min) && v.isBefore(max)) {
- return true;
- }
- } else if ("2".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
- if (v.isBefore(min)) {
- return true;
- }
- } else if ("3".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
- if (v.isBefore(min) || v.isEqual(min)) {
- return true;
- }
- } else if ("4".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
- if (v.isAfter(max)) {
- return true;
- }
- } else if ("5".equals(ptlAgreementProductCostsAttrLink.getOperator())) {
- if (v.isAfter(max) || v.isEqual(max)) {
- return true;
- }
- }
- return false;
- }
- public boolean dateTimeEqual(PtlAgreementUndwrtRulesAttrLink ptlAgreementUndwrtRulesAttrLink, String value, InsOrders insOrders){
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
- //判断险种 的起保时间
- if(ptlAgreementUndwrtRulesAttrLink.getAttrCode().equals("SyStartTime") || ptlAgreementUndwrtRulesAttrLink.getAttrCode().equals("JqStartTime"))
- {
- if(insOrders.getProductid().equals(ProductsType.PT_0330.getCode()) && ptlAgreementUndwrtRulesAttrLink.getAttrCode().equals("SyStartTime")){
- return true;
- }
- if(insOrders.getProductid().equals(ProductsType.PT_034001.getCode()) && ptlAgreementUndwrtRulesAttrLink.getAttrCode().equals("JqStartTime")){
- return true;
- }
- }
- if(!Objects.isNull(value) && !value.isEmpty()) {
- LocalDateTime v = LocalDateTime.parse(value, formatter);
- LocalDateTime min = null, max = null;
- if (!Objects.isNull(ptlAgreementUndwrtRulesAttrLink.getMin())) {
- min = LocalDateTime.parse(ptlAgreementUndwrtRulesAttrLink.getMin(), formatter);
- }
- if (!Objects.isNull(ptlAgreementUndwrtRulesAttrLink.getMax())) {
- max = LocalDateTime.parse(ptlAgreementUndwrtRulesAttrLink.getMax(), formatter);
- }
- //统一处理数值
- if ("1".equals(ptlAgreementUndwrtRulesAttrLink.getOperator())) {
- if (!v.isAfter(min) && v.isBefore(max)) {
- return true;
- }
- } else if ("2".equals(ptlAgreementUndwrtRulesAttrLink.getOperator())) {
- if (!v.isBefore(min)) {
- return true;
- }
- } else if ("3".equals(ptlAgreementUndwrtRulesAttrLink.getOperator())) {
- if (!v.isBefore(min)) {
- return true;
- }
- } else if ("4".equals(ptlAgreementUndwrtRulesAttrLink.getOperator())) {
- if (!v.isAfter(max)) {
- return true;
- }
- } else if ("5".equals(ptlAgreementUndwrtRulesAttrLink.getOperator())) {
- if (!v.isAfter(max)) {
- return true;
- }
- }
- }
- return false;
- }
- public boolean dateEqual(PtlAgreementUndwrtRulesAttrLink ptlAgreementUndwrtRulesAttrLink, String value){
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
- if(!Objects.isNull(value) && !value.isEmpty()) {
- LocalDateTime v = LocalDate.parse(value).atStartOfDay();
- LocalDateTime min = null, max = null;
- if (!Objects.isNull(ptlAgreementUndwrtRulesAttrLink.getMin())) {
- min = LocalDate.parse(ptlAgreementUndwrtRulesAttrLink.getMin()).atStartOfDay();
- }
- if (!Objects.isNull(ptlAgreementUndwrtRulesAttrLink.getMax())) {
- max = LocalDate.parse(ptlAgreementUndwrtRulesAttrLink.getMax()).atStartOfDay();
- }
- //统一处理数值
- if ("1".equals(ptlAgreementUndwrtRulesAttrLink.getOperator())) {
- if (!v.isAfter(min) && v.isBefore(max)) {
- return true;
- }
- } else if ("2".equals(ptlAgreementUndwrtRulesAttrLink.getOperator())) {
- if (!v.isBefore(min)) {
- return true;
- }
- } else if ("3".equals(ptlAgreementUndwrtRulesAttrLink.getOperator())) {
- if (!v.isBefore(min)) {
- return true;
- }
- } else if ("4".equals(ptlAgreementUndwrtRulesAttrLink.getOperator())) {
- if (!v.isAfter(max)) {
- return true;
- }
- } else if ("5".equals(ptlAgreementUndwrtRulesAttrLink.getOperator())) {
- if (!v.isAfter(max)) {
- return true;
- }
- }
- }
- return false;
- }
- /**
- * 获取车辆新旧车信息
- *
- * @param companyId
- * @return
- */
- private PtlNewCarJudgeRules getCarJudgeRule(String companyId) {
- //获取车辆新旧车信息
- List<PtlNewCarJudgeRules> list =
- ptlNewCarJudgeRulesService.list(new LambdaQueryWrapper<PtlNewCarJudgeRules>().eq(PtlNewCarJudgeRules::getCompanyId,
- companyId));
- if (list.size() > 0) {
- return list.get(0);
- }
- return null;
- }
- }
|