| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546 |
- 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.ins.model.vo.QuoteRespVo;
- 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.BigInteger;
- 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(QuoteRespVo quoteRespVo, InsAreaCompany insAreaCompany, InsOrders insOrders, StringBuilder logs, boolean isInternalAgreement) {
- 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, quoteRespVo, insAreaCompany, insOrders, logs);
- if (costsId != null) {
- calcCosts(costsId, insAreaCompany, isInternalAgreement);
- 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, boolean isInternalAgreement) {
- //获取协议信息
- 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 = new BigDecimal(BigInteger.ZERO);
-
- // 待客录单订单比例 根据前端传值 判断是否使用待客录单比例
- if(!isInternalAgreement){
- 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, QuoteRespVo quoteRespVo, InsAreaCompany insAreaCompany,
- InsOrders insOrders, StringBuilder logs) {
- //匹配费用因子
- //获取所有费用属性
- List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList = ptlAgreementUndwrtRulesAttrService.getUndwrtRulesAttrList();
- //获取新旧车信息
- PtlNewCarJudgeRules carJudgeRule = getCarJudgeRule(insAreaCompany.getCompanyId(), insOrders.getCarinfo().getString("cimodelclass"));
- //获取所有费用属性关联
- List<RuleAttrMappingVo> ruleAttrMappingVoList = RuleAttrMappingVo.getRuleAttrMappingVoList(quoteRespVo, 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(null,insAreaCompany, insOrders,
- undwrtRulesAttrList, getCarJudgeRule(insAreaCompany.getCompanyId(),insOrders.getCarinfo().getString("cimodelclass")));
- 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) && ptlAgreementProductCostsAttrLink.getOperator().equals("0")) {
- return true;
- }
- // 不包含的情况
- if (ptlAgreementProductCostsAttrLink.getMin()!= null && !ptlAgreementProductCostsAttrLink.getMin().contains(value) && ptlAgreementProductCostsAttrLink.getOperator().equals("1")) {
- 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, String vehicleType) {
- //获取车辆新旧车信息
- List<PtlNewCarJudgeRules> list =
- ptlNewCarJudgeRulesService.list(new LambdaQueryWrapper<PtlNewCarJudgeRules>()
- .eq(PtlNewCarJudgeRules::getCompanyId,companyId)
- .eq(PtlNewCarJudgeRules::getVehicleType,vehicleType));
- if (list.size() > 0) {
- return list.get(0);
- }
- return null;
- }
- }
|