| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970 |
- package com.ydtech.modules.fnc.service.impl;
- import cn.afterturn.easypoi.excel.entity.ExportParams;
- import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
- import com.alibaba.fastjson.JSON;
- import com.alibaba.fastjson.JSONArray;
- import com.alipay.api.domain.VehicleIovData;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- import com.github.pagehelper.PageHelper;
- import com.github.pagehelper.PageInfo;
- import com.ydtech.constants.InsuranceEnum;
- import com.ydtech.constants.enums.dict.agreement.ProductsType;
- import com.ydtech.core.page.HttpResult;
- import com.ydtech.exception.SystemException;
- import com.ydtech.modules.admin.model.SysDept;
- import com.ydtech.modules.admin.model.SysUser;
- import com.ydtech.modules.admin.model.report.financialReceivables.*;
- import com.ydtech.modules.admin.service.SysUserService;
- import com.ydtech.modules.admin.utils.SliceUpDateUtil;
- import com.ydtech.modules.base.controller.BaseController;
- import com.ydtech.modules.esm.model.EsmInsCompany;
- import com.ydtech.modules.esm.model.EsmInsPackage;
- import com.ydtech.modules.esm.service.EsmInsCompanyService;
- import com.ydtech.modules.fnc.dao.FncInsAreaCompanyMapper;
- import com.ydtech.modules.fnc.dao.InsPlyIncomeMapper;
- import com.ydtech.modules.fnc.dto.InsPlyIncomePTCompanyDto;
- import com.ydtech.modules.fnc.dto.InsPlyIncomePTDto;
- import com.ydtech.modules.fnc.dto.InsuranceHandlingSettlementMonthDto;
- import com.ydtech.modules.fnc.dto.PlatformSettlementRecordDto;
- import com.ydtech.modules.fnc.entity.*;
- import com.ydtech.modules.fnc.service.*;
- import com.ydtech.modules.fnc.vo.*;
- import com.ydtech.modules.ins.model.vo.res.*;
- import com.ydtech.modules.inv.model.dto.*;
- import com.ydtech.modules.inv.model.excel.*;
- import com.ydtech.modules.inv.utils.CheckInsPlyComeUtils;
- import com.ydtech.modules.inv.utils.EasyExcelUtils;
- import com.ydtech.modules.order.entity.BasePageResult;
- import com.ydtech.modules.order.entity.InsOrders;
- import com.ydtech.modules.order.entity.api.dajia.response.NVHLODR1001Response;
- import com.ydtech.modules.order.entity.api.zhongmei.response.SubmitResponse;
- import com.ydtech.modules.order.entity.crawler.response.CrawlerVerifyPaymentResponse;
- import com.ydtech.modules.order.entity.dto.DrivingInsuranceDto;
- import com.ydtech.modules.order.service.InsAreaCompanyService;
- import com.ydtech.modules.order.service.InsOrdersService;
- import com.ydtech.modules.protocol.entity.constants.PtlApiType;
- import com.ydtech.modules.protocol.entity.po.PtlAgreement;
- import com.ydtech.modules.protocol.entity.vo.PtlAgreementQueryVo;
- import com.ydtech.modules.protocol.service.PtlAgreementService;
- import com.ydtech.modules.protocols.entity.po.InsFeeOrderNew;
- import com.ydtech.modules.protocols.service.InsFeeOrderNewService;
- import com.ydtech.utils.BigDecimalUtils;
- import com.ydtech.utils.SnowFlakeUtil;
- import com.ydtech.utils.StringOperations;
- import com.ydtech.utils.excel.ExcelEasypoiUtils;
- import com.ydtech.utils.excel.ExcelStyleUtil;
- import lombok.extern.slf4j.Slf4j;
- import org.apache.commons.lang3.ObjectUtils;
- import org.apache.commons.lang3.StringUtils;
- import org.apache.ibatis.annotations.Param;
- import org.springframework.beans.BeanUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.context.annotation.Lazy;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import org.springframework.util.CollectionUtils;
- import org.springframework.web.multipart.MultipartFile;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import java.io.IOException;
- import java.math.BigDecimal;
- import java.math.MathContext;
- import java.math.RoundingMode;
- import java.nio.file.Files;
- import java.nio.file.Path;
- import java.nio.file.Paths;
- import java.time.LocalDate;
- import java.time.LocalDateTime;
- import java.time.LocalTime;
- import java.time.YearMonth;
- import java.time.format.DateTimeFormatter;
- import java.util.*;
- import java.util.function.BinaryOperator;
- import java.util.function.Function;
- import java.util.stream.Collectors;
- /**
- * <p>
- * 保司结算手续费 服务实现类
- * </p>
- *
- * @author gws
- * @since 2024-01-05
- */
- @Slf4j
- @Service
- public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, InsPlyIncome> implements InsPlyIncomeService {
- @Autowired
- @Lazy
- private InsOrdersService insOrdersService;
- @Autowired
- private SysUserService sysUserService;
- @Autowired
- private InsFeeOrderNewService insFeeOrderNewService;
- @Autowired
- private SettlementDocumentaryFeesService settlementDocumentaryFeesService;
- @Autowired
- private SettlementDocumentaryLogService settlementDocumentaryLogService;
- @Autowired
- private PtlAgreementService ptlAgreementService;
- @Autowired
- private EsmInsCompanyService EsmInsCompanyService;
- @Autowired
- private ImportAsyncService importAsyncService;
- @Autowired
- private IncomeTaskRelationshipService incomeTaskRelationshipService;
- @Autowired
- private SettlementDocumentaryFeesSumService settlementDocumentaryFeesSumService;
- @Autowired
- private InsPlyIncomeLogService insPlyIncomeLogService;
- @Value("${upload.file.path}")
- private String uploadPath;
- @Value("${upload.file.url}")
- private String uploadUrl;
- @Autowired
- private FncInsAreaCompanyMapper fncInsAreaCompanyMapper;
- @Autowired
- private InsuranceHandlingSettlementMonthService insuranceHandlingSettlementMonthService;
- public HttpResult<BasePageResult<InsPlyIncome>> queryplyIncome(InsPlyIncomeVo insPlyIncomeVo) {
- try {
- Page<InsOrders> page = new Page<>(insPlyIncomeVo.getPageNum(), insPlyIncomeVo.getPageSize());
- PageInfo<List<InsPlyIncome>> pageHelper = null;
- PageHelper.startPage(insPlyIncomeVo.getPageNum(), insPlyIncomeVo.getPageSize());
- List<InsPlyIncome> list = this.baseMapper.selectByCondition(insPlyIncomeVo);
- pageHelper = new PageInfo(list);
- BasePageResult<InsPlyIncome> pageResult = new BasePageResult<InsPlyIncome>(insPlyIncomeVo.getPageNum(),
- insPlyIncomeVo.getPageSize(), pageHelper.getTotal(), pageHelper.getPages(), list);
- return HttpResult.ok(pageResult);
- } catch (Exception e) {
- e.printStackTrace();
- return HttpResult.error("查询异常");
- }
- }
- @Override
- public void saveBalanceNew(InsOrders order, InsFeeOrderNew insFeeOrderNew, InsAreaCompany insAreaCompany, String leaderId, String leaderName) {
- if (ObjectUtils.isEmpty(order) || ObjectUtils.isEmpty(insFeeOrderNew) || ObjectUtils.isEmpty(insAreaCompany)) {
- return;
- }
- String agreeType = this.judgeAgreeType(insAreaCompany.getAgreementId());
- if (StringUtils.isNotEmpty(agreeType)) {
- // 判断协议类型 平台 保险
- if ("1".equals(agreeType)) {
- this.savePinTai(order, insFeeOrderNew, insAreaCompany); //手续费不分非车不非车 跟单也不分
- } else { // 保险 逻辑: 手续费生成一条 跟单费生成一条 非车手续费一条 非车跟单费一条
- if (((insFeeOrderNew.getJqSuperviseCostsPremiums() != null && insFeeOrderNew.getJqSuperviseCostsPremiums().compareTo(BigDecimal.ZERO) != 0)) || (insFeeOrderNew.getSySuperviseCostsPremiums() != null && insFeeOrderNew.getSySuperviseCostsPremiums().compareTo(BigDecimal.ZERO) != 0)) { //手续费
- this.saveInsuranceProcedures(order, insFeeOrderNew, insAreaCompany, leaderId, leaderName);
- }
- if (insFeeOrderNew.getJqOtherCostsPremiums() != null && insFeeOrderNew.getJqOtherCostsPremiums().compareTo(BigDecimal.ZERO) != 0) { //跟单费
- this.saveOtherAmount(order, insFeeOrderNew, insAreaCompany, leaderId, leaderName);
- }
- if (insFeeOrderNew.getNoSuperviseCostsPremiums() != null && insFeeOrderNew.getNoSuperviseCostsPremiums().compareTo(BigDecimal.ZERO) != 0) { // 非车手续费
- this.saveNoSupervise(order, insFeeOrderNew, insAreaCompany, leaderId, leaderName);
- }
- if (insFeeOrderNew.getNoOtherCostsPremiums() != null && insFeeOrderNew.getNoOtherCostsPremiums().compareTo(BigDecimal.ZERO) != 0) { // 非车跟单费
- this.saveNoOtherAmount(order, insFeeOrderNew, insAreaCompany, leaderId, leaderName);
- }
- }
- }
- }
- private void saveNoOtherAmount(InsOrders order, InsFeeOrderNew insFeeOrderNew, InsAreaCompany insAreaCompany, String leaderId, String leaderName) {
- InsPlyIncome insPlyIncome = new InsPlyIncome();
- insPlyIncome.setOrderno(insFeeOrderNew.getInsOrderNo()); // 子订单号
- String noPolicyno = this.setNoPolicyno(insAreaCompany);
- if (StringUtils.isNotEmpty(noPolicyno)) {
- insPlyIncome.setNoPolicyno(noPolicyno); // 非车保单号
- }
- insPlyIncome.setOtherFeevalue(insFeeOrderNew.getNoOtherCostsPremiums()); //非车跟单费
- insPlyIncome.setOtherFeerate(insFeeOrderNew.getNoOtherCostsProportion()); //非车跟单费用比例
- //add by hxl 2024-07-31 修改插入结算表中险种信息错误的bug 将大订单中的险种信息改为小订单的险种信息
- this.saveRiskCode(insAreaCompany.getProductid(), insPlyIncome);
- //this.saveRiskCode(order.getProductid(), insPlyIncome);
- insPlyIncome.setPayDate(insAreaCompany.getPayDate());
- insPlyIncome.setSignDate(insAreaCompany.getSigningTime());
- insPlyIncome.setCompanyId(insAreaCompany.getCompanyId());
- insPlyIncome.setAgreementId(insFeeOrderNew.getAgreementId());
- insPlyIncome.setLicenseno(order.getLicenseno());
- insPlyIncome.setTaxamount(insAreaCompany.getTaxamount());
- insPlyIncome.setNoTaxPremium(insFeeOrderNew.getNoNoTaxPremium());
- insPlyIncome.setCreateTime(LocalDateTime.now());
- insPlyIncome.setDocumentaryFeesStatus("0");
- insPlyIncome.setInsuredName(order.getInsuredname());
- insPlyIncome.setHandlingFeesStatus("0");
- insPlyIncome.setNoNoTaxPremium(insFeeOrderNew.getNoNoTaxPremium());
- insPlyIncome.setNoPremium(insFeeOrderNew.getNoPremium());
- insPlyIncome.setIsNotCar("1");
- insPlyIncome.setIsNotDocumentary("1");
- insPlyIncome.setJqStartDate(StringOperations.emptyStringToNull(insAreaCompany.getJqStartDate()));
- insPlyIncome.setJqEndDate(StringOperations.emptyStringToNull(insAreaCompany.getJqEndDate()));
- insPlyIncome.setSyStartDate(StringOperations.emptyStringToNull(insAreaCompany.getSyStartDate()));
- insPlyIncome.setSyEndDate(StringOperations.emptyStringToNull(insAreaCompany.getSyEndDate()));
- insPlyIncome.setReceivableAmount(insFeeOrderNew.getNoOtherCostsPremiums());
- insPlyIncome.setAllFeeValue(insFeeOrderNew.getNoOtherCostsPremiums());
- insPlyIncome.setNoOtherCostsPremium(insFeeOrderNew.getNoOtherCostsPremiums());
- insPlyIncome.setNoOtherCostsProportion(insFeeOrderNew.getNoOtherCostsProportion());
- this.saveByCompanyId(insFeeOrderNew, insAreaCompany.getCompanyId(), insPlyIncome);
- this.getDeptId(insPlyIncome);
- baseMapper.insert(insPlyIncome);
- InsPlyIncomeLog insPlyIncomeLog = new InsPlyIncomeLog();
- insPlyIncomeLog.setIncomeId(insPlyIncome.getId());
- BeanUtils.copyProperties(insPlyIncome,insPlyIncomeLog);
- insPlyIncomeLog.setId(null);
- insPlyIncomeLog.setOperationStatus("1");
- insPlyIncomeLogService.saveLog(insPlyIncomeLog); //添加日志
- }
- private void saveNoSupervise(InsOrders order, InsFeeOrderNew insFeeOrderNew, InsAreaCompany insAreaCompany, String leaderId, String leaderName) {
- InsPlyIncome insPlyIncome = new InsPlyIncome();
- insPlyIncome.setOrderno(insFeeOrderNew.getInsOrderNo()); // 子订单号
- insPlyIncome.setCommissionFeevalue(insFeeOrderNew.getNoSuperviseCostsPremiums());// 非车手续费
- insPlyIncome.setCommissionFeerate(insFeeOrderNew.getNoSuperviseCostsProportion());// 非车手续费比例
- String noPolicyno = this.setNoPolicyno(insAreaCompany);
- if (StringUtils.isNotEmpty(noPolicyno)) {
- insPlyIncome.setNoPolicyno(noPolicyno); // 非车保单号
- }
- // insPlyIncome.setDeptId(insFeeOrderNew.getDeptId());
- //add by hxl 2024-07-31 修改插入结算表中险种信息错误的bug 将大订单中的险种信息改为小订单的险种信息
- this.saveRiskCode(insAreaCompany.getProductid(), insPlyIncome);
- //this.saveRiskCode(order.getProductid(), insPlyIncome);
- insPlyIncome.setPayDate(insAreaCompany.getPayDate());
- insPlyIncome.setSignDate(insAreaCompany.getSigningTime());
- insPlyIncome.setCompanyId(insAreaCompany.getCompanyId());
- insPlyIncome.setAgreementId(insFeeOrderNew.getAgreementId());
- insPlyIncome.setLicenseno(order.getLicenseno());
- insPlyIncome.setTaxamount(insAreaCompany.getTaxamount());
- insPlyIncome.setCreateTime(LocalDateTime.now());
- insPlyIncome.setDocumentaryFeesStatus("0");
- insPlyIncome.setHandlingFeesStatus("0");
- insPlyIncome.setIsNotCar("1");
- insPlyIncome.setIsNotDocumentary("0");
- insPlyIncome.setAllFeeValue(insFeeOrderNew.getNoSuperviseCostsPremiums());
- insPlyIncome.setUserId(insFeeOrderNew.getUserId());
- insPlyIncome.setInsuredName(order.getInsuredname());
- insPlyIncome.setNoPremium(insFeeOrderNew.getNoPremium()); //非车保费
- insPlyIncome.setNoNoTaxPremium(insFeeOrderNew.getNoNoTaxPremium()); //非车不含税保费
- insPlyIncome.setJqStartDate(StringOperations.emptyStringToNull(insAreaCompany.getJqStartDate()));
- insPlyIncome.setJqEndDate(StringOperations.emptyStringToNull(insAreaCompany.getJqEndDate()));
- insPlyIncome.setSyStartDate(StringOperations.emptyStringToNull(insAreaCompany.getSyStartDate()));
- insPlyIncome.setSyEndDate(StringOperations.emptyStringToNull(insAreaCompany.getSyEndDate()));
- insPlyIncome.setNoSuperviseCostsPremiums(insFeeOrderNew.getNoSuperviseCostsPremiums());
- insPlyIncome.setNoSuperviseCostsProportion(insFeeOrderNew.getNoSuperviseCostsProportion());
- this.getDeptId(insPlyIncome);
- this.saveByCompanyId(insFeeOrderNew, insAreaCompany.getCompanyId(), insPlyIncome);
- insPlyIncome.setReceivableAmount(insFeeOrderNew.getNoSuperviseCostsPremiums());
- baseMapper.insert(insPlyIncome);
- InsPlyIncomeLog insPlyIncomeLog = new InsPlyIncomeLog();
- insPlyIncomeLog.setIncomeId(insPlyIncome.getId());
- BeanUtils.copyProperties(insPlyIncome,insPlyIncomeLog);
- insPlyIncomeLog.setId(null);
- insPlyIncomeLog.setOperationStatus("1");
- insPlyIncomeLogService.saveLog(insPlyIncomeLog); //添加日志
- }
- private void saveRiskCode(String productid, InsPlyIncome insPlyIncome) {
- if (ProductsType.PT_0330.getCode().equals(productid)) {
- insPlyIncome.setRiskcode(ProductsType.PT_0330.getDesc());
- }
- if (ProductsType.PT_034001.getCode().equals(productid)) {
- insPlyIncome.setRiskcode(ProductsType.PT_034001.getDesc());
- }
- if (ProductsType.PT_034002.getCode().equals(productid)) {
- insPlyIncome.setRiskcode(ProductsType.PT_034002.getDesc());
- }
- if (ProductsType.PT_0330034002.getCode().equals(productid)) {
- insPlyIncome.setRiskcode(ProductsType.PT_0330034002.getDesc());
- }
- if (ProductsType.PT_0330034001.getCode().equals(productid)) {
- insPlyIncome.setRiskcode(ProductsType.PT_0330034001.getDesc());
- }
- }
- private void saveOtherAmount(InsOrders order, InsFeeOrderNew insFeeOrderNew, InsAreaCompany insAreaCompany, String leaderId, String leaderName) {
- BigDecimal otherAmount = this.calculateTotal(insFeeOrderNew.getJqOtherCostsPremiums(), insFeeOrderNew.getSyOtherCostsPremiums(),
- null);
- BigDecimal otherProportion = this.calculateTotal(insFeeOrderNew.getSyOtherCostsProportion(),
- insFeeOrderNew.getJqOtherCostsProportion(), null);
- BigDecimal allNoTaxPremium = this.calculateTotal(insFeeOrderNew.getJqNoTaxPremium(), insFeeOrderNew.getSyNoTaxPremium(), null);
- //交强不含税保费
- BigDecimal allPremium = this.calculateTotal(insFeeOrderNew.getJqPremium(), insFeeOrderNew.getSyPremium(), null);// 总保费
- InsPlyIncome insPlyIncome = new InsPlyIncome(insFeeOrderNew.getInsOrderNo(), insAreaCompany.getJqpolicyno(),
- insAreaCompany.getSypolicyno(), null, null, null, null, order.getProductid(), insAreaCompany.getPayDate(),
- insAreaCompany.getSigningTime(), insAreaCompany.getCompanyId(), null, insFeeOrderNew.getAgreementId(), order.getLicenseno(),
- insAreaCompany.getTaxamount(),
- allNoTaxPremium, null, otherProportion, null, otherAmount, otherAmount, null, null, LocalDateTime.now(), null, null, null, "0"
- , "0", "0", "1");
- //add by hxl 2024-07-31 修改插入结算表中险种信息错误的bug 将大订单中的险种信息改为小订单的险种信息
- this.saveRiskCode(insAreaCompany.getProductid(), insPlyIncome);
- //this.saveRiskCode(order.getProductid(), insPlyIncome);
- insPlyIncome.setTaxPremium(allPremium);
- insPlyIncome.setJqPremium(insFeeOrderNew.getJqPremium());
- insPlyIncome.setSyPremium(insFeeOrderNew.getSyPremium());
- insPlyIncome.setJqNoTaxPremium(insFeeOrderNew.getJqNoTaxPremium());
- insPlyIncome.setSyNoTaxPremium(insFeeOrderNew.getSyNoTaxPremium());
- insPlyIncome.setJqOtherCostsProportion(insFeeOrderNew.getJqOtherCostsProportion()); //交强跟单费比例
- insPlyIncome.setSyOtherCostsProportion(insFeeOrderNew.getSyOtherCostsProportion()); //商业跟单费比例
- insPlyIncome.setSyOtherCostsPremium(insFeeOrderNew.getSyOtherCostsPremiums());
- insPlyIncome.setJqOtherCostsPremium(insFeeOrderNew.getJqOtherCostsPremiums());
- insPlyIncome.setJqStartDate(StringOperations.emptyStringToNull(insAreaCompany.getJqStartDate()));
- insPlyIncome.setJqEndDate(StringOperations.emptyStringToNull(insAreaCompany.getJqEndDate()));
- insPlyIncome.setSyStartDate(StringOperations.emptyStringToNull(insAreaCompany.getSyStartDate()));
- insPlyIncome.setSyEndDate(StringOperations.emptyStringToNull(insAreaCompany.getSyEndDate()));
- insPlyIncome.setUserId(insFeeOrderNew.getUserId());
- insPlyIncome.setInsuredName(order.getInsuredname());
- insPlyIncome.setReceivableAmount(otherAmount);
- this.getDeptId(insPlyIncome);
- this.saveByCompanyId(insFeeOrderNew, insAreaCompany.getCompanyId(), insPlyIncome);
- baseMapper.insert(insPlyIncome);
- InsPlyIncomeLog insPlyIncomeLog = new InsPlyIncomeLog();
- insPlyIncomeLog.setIncomeId(insPlyIncome.getId());
- BeanUtils.copyProperties(insPlyIncome,insPlyIncomeLog);
- insPlyIncomeLog.setId(null);
- insPlyIncomeLog.setOperationStatus("1");
- insPlyIncomeLogService.saveLog(insPlyIncomeLog); //添加日志
- }
- private void saveInsuranceProcedures(InsOrders order, InsFeeOrderNew insFeeOrderNew, InsAreaCompany insAreaCompany, String leaderId, String leaderName) {
- // 保险手续费
- BigDecimal handlingAmount = this.calculateTotal(insFeeOrderNew.getJqSuperviseCostsPremiums(),
- insFeeOrderNew.getSySuperviseCostsPremiums(), null);
- BigDecimal handlingProportion = this.calculateTotal(insFeeOrderNew.getJqSuperviseCostsProportion(),
- insFeeOrderNew.getSySuperviseCostsProportion(), null);
- BigDecimal allNoTaxPremium = this.calculateTotal(insFeeOrderNew.getJqNoTaxPremium(), insFeeOrderNew.getSyNoTaxPremium(), null);
- //不含税保费
- InsPlyIncome insPlyIncome = new InsPlyIncome(insFeeOrderNew.getInsOrderNo(), insAreaCompany.getJqpolicyno(),
- insAreaCompany.getSypolicyno(), null, null, null, null, order.getProductid(), insAreaCompany.getPayDate(),
- insAreaCompany.getSigningTime(), insAreaCompany.getCompanyId(), null, insFeeOrderNew.getAgreementId(), order.getLicenseno(),
- insAreaCompany.getTaxamount()
- , allNoTaxPremium, handlingProportion, null, handlingAmount, null, handlingAmount, null, null, LocalDateTime.now(), null,
- null, null, "0", "0", "0", "0");
- BigDecimal allTaxPremium = this.calculateTotal(insFeeOrderNew.getJqPremium(), insFeeOrderNew.getSyPremium(), null);
- insPlyIncome.setJqPremium(insFeeOrderNew.getJqPremium());
- insPlyIncome.setSyPremium(insFeeOrderNew.getSyPremium());
- insPlyIncome.setJqNoTaxPremium(insFeeOrderNew.getJqNoTaxPremium());
- insPlyIncome.setSyNoTaxPremium(insFeeOrderNew.getSyNoTaxPremium());
- insPlyIncome.setJqSuperviseCostsProportion(insFeeOrderNew.getJqSuperviseCostsProportion());
- insPlyIncome.setJqSuperviseCostsPremiums(insFeeOrderNew.getJqSuperviseCostsPremiums());
- insPlyIncome.setSySuperviseCostsProportion(insFeeOrderNew.getSySuperviseCostsProportion());
- insPlyIncome.setSySuperviseCostsPremiums(insFeeOrderNew.getSySuperviseCostsPremiums());
- //add by hxl 2024-07-31 修改插入结算表中险种信息错误的bug 将大订单中的险种信息改为小订单的险种信息
- this.saveRiskCode(insAreaCompany.getProductid(), insPlyIncome);
- //this.saveRiskCode(order.getProductid(), insPlyIncome);
- insPlyIncome.setTaxPremium(allTaxPremium);
- insPlyIncome.setUserId(insFeeOrderNew.getUserId());
- insPlyIncome.setInsuredName(order.getInsuredname());
- insPlyIncome.setJqStartDate(StringOperations.emptyStringToNull(insAreaCompany.getJqStartDate()));
- insPlyIncome.setJqEndDate(StringOperations.emptyStringToNull(insAreaCompany.getJqEndDate()));
- insPlyIncome.setSyStartDate(StringOperations.emptyStringToNull(insAreaCompany.getSyStartDate()));
- insPlyIncome.setSyEndDate(StringOperations.emptyStringToNull(insAreaCompany.getSyEndDate()));
- insPlyIncome.setReceivableAmount(handlingAmount);
- this.saveByCompanyId(insFeeOrderNew, insAreaCompany.getCompanyId(), insPlyIncome);
- this.getDeptId(insPlyIncome);
- baseMapper.insert(insPlyIncome);
- InsPlyIncomeLog insPlyIncomeLog = new InsPlyIncomeLog();
- insPlyIncomeLog.setIncomeId(insPlyIncome.getId());
- BeanUtils.copyProperties(insPlyIncome,insPlyIncomeLog);
- insPlyIncomeLog.setId(null);
- insPlyIncomeLog.setOperationStatus("1");
- insPlyIncomeLogService.saveLog(insPlyIncomeLog); //添加日志
- }
- private String setNoPolicyno(InsAreaCompany insAreaCompany) {
- if (insAreaCompany.getJypremium() == null || insAreaCompany.getJypremium().compareTo(BigDecimal.ZERO) == 0) { // 非车跟单费
- return null;
- }
- String crossInsurance = insAreaCompany.getCrossInsurance();
- if (StringUtils.isEmpty(crossInsurance)) {
- return null;
- }
- JSONArray objects = JSON.parseArray(crossInsurance);
- if (objects.isEmpty()) {
- return null;
- }
- if (ObjectUtils.isEmpty(insAreaCompany.getApiType()) || PtlApiType.PTL_API_2.getCode() == insAreaCompany.getApiType()) {
- List<CrawlerVerifyPaymentResponse.DrivingInsurancesDTO> drivingInsurancesDTOS = objects.toJavaList(CrawlerVerifyPaymentResponse.DrivingInsurancesDTO.class);
- return drivingInsurancesDTOS.get(0).getApplication();
- }
- // 永诚
- if(insAreaCompany.getCompanyId().contains(InsuranceEnum.AICS.getCode())){
- List<DrivingInsuranceDto> javaList = objects.toJavaList(DrivingInsuranceDto.class);
- return javaList.get(0).getPolicyNumber();
- }
- // 大家
- if(insAreaCompany.getCompanyId().contains(InsuranceEnum.DJPC.getCode())){
- List<NVHLODR1001Response.policyInfosDTO> javaList = objects.toJavaList(NVHLODR1001Response.policyInfosDTO.class);
- return javaList.get(0).getPlyNo();
- }
- // 国任
- if(insAreaCompany.getCompanyId().contains(InsuranceEnum.XDCX.getCode())){
- List<DrivingInsuranceDto> javaList = objects.toJavaList(DrivingInsuranceDto.class);
- return javaList.get(0).getPolicyNumber();
- }
- // 中煤
- if(insAreaCompany.getCompanyId().contains(InsuranceEnum.ZMBX.getCode())){
- List<SubmitResponse.AccidentNo> javaList = objects.toJavaList(SubmitResponse.AccidentNo.class);
- return javaList.get(0).getRideProposalNo();
- }
- // 紫金
- if(insAreaCompany.getCompanyId().contains(InsuranceEnum.ZKIC.getCode())){
- List<DrivingInsuranceDto> javaList = objects.toJavaList(DrivingInsuranceDto.class);
- return javaList.get(0).getPolicyNumber();
- }
- return null;
- }
- private void savePinTai(InsOrders order, InsFeeOrderNew insFeeOrderNew, InsAreaCompany insAreaCompany) {
- BigDecimal handlingAmount = this.calculateTotal(insFeeOrderNew.getJqSuperviseCostsPremiums(),
- insFeeOrderNew.getSySuperviseCostsPremiums(), insFeeOrderNew.getNoSuperviseCostsPremiums()); //手续费
- BigDecimal handlingProportion = this.calculateTotal(insFeeOrderNew.getJqSuperviseCostsProportion(),
- insFeeOrderNew.getSySuperviseCostsProportion(), insFeeOrderNew.getNoSuperviseCostsProportion());//手续费比例
- BigDecimal otherAmount = this.calculateTotal(insFeeOrderNew.getJqOtherCostsPremiums(), insFeeOrderNew.getSyOtherCostsPremiums(),
- insFeeOrderNew.getNoOtherCostsPremiums());//跟单费
- BigDecimal otherProportion = this.calculateTotal(insFeeOrderNew.getSyOtherCostsProportion(),
- insFeeOrderNew.getJqOtherCostsProportion(), insFeeOrderNew.getNoOtherCostsProportion()); //跟单费比例
- // 不含税保费
- BigDecimal allNoTaxPremium = this.calculateTotal(insFeeOrderNew.getJqNoTaxPremium(), insFeeOrderNew.getSyNoTaxPremium(),
- insFeeOrderNew.getNoNoTaxPremium());
- BigDecimal allAmount = this.calculateTotal(otherAmount, handlingAmount, null);
- BigDecimal jqReceivableProportion = this.calculateTotal(insFeeOrderNew.getJqSuperviseCostsProportion(),
- insFeeOrderNew.getJqOtherCostsProportion(), null);// 交强应收 比例
- BigDecimal syReceivableProportion = this.calculateTotal(insFeeOrderNew.getSySuperviseCostsProportion(),
- insFeeOrderNew.getSyOtherCostsProportion(), null);//商业应收比例
- BigDecimal noReceivableProportion = this.calculateTotal(insFeeOrderNew.getNoSuperviseCostsProportion(),
- insFeeOrderNew.getNoOtherCostsProportion(), null);
- String noPolicyno = this.setNoPolicyno(insAreaCompany);
- InsPlyIncome insPlyIncome = new InsPlyIncome(insFeeOrderNew.getInsOrderNo(), insAreaCompany.getJqpolicyno(),
- insAreaCompany.getSypolicyno(),
- noPolicyno, null, null, null, order.getProductid(), insAreaCompany.getPayDate(), insAreaCompany.getSigningTime(),
- insAreaCompany.getCompanyId(),
- null, insFeeOrderNew.getAgreementId(), order.getLicenseno(), insAreaCompany.getTaxamount(), allNoTaxPremium,
- handlingProportion,
- otherProportion, handlingAmount, otherAmount, allAmount, null, null, LocalDateTime.now(), null, null, null, "0", "0", "0", "0");
- insPlyIncome.setJqReceivableProportion(jqReceivableProportion);
- insPlyIncome.setSyReceivableProportion(syReceivableProportion);
- insPlyIncome.setNoReceivableProportion(noReceivableProportion);
- // 应收金额 = 商业手续费+商业跟单 + 交强手续费 +交强跟单费 + 非车手续费 + 非车跟单费 = allAmount
- insPlyIncome.setJqSuperviseCostsPremiums(insFeeOrderNew.getJqSuperviseCostsPremiums()); // 交强手续费
- insPlyIncome.setSySuperviseCostsPremiums(insFeeOrderNew.getSySuperviseCostsPremiums()); // 商业手续费
- insPlyIncome.setNoSuperviseCostsPremiums(insFeeOrderNew.getNoSuperviseCostsPremiums()); // 非车手续费
- insPlyIncome.setJqSuperviseCostsProportion(insFeeOrderNew.getJqSuperviseCostsProportion()); //交强手续费 比例
- insPlyIncome.setSySuperviseCostsProportion(insFeeOrderNew.getSySuperviseCostsProportion()); // 商业手续费 比例
- insPlyIncome.setNoSuperviseCostsProportion(insFeeOrderNew.getNoSuperviseCostsProportion());// 非车手续费 比例
- insPlyIncome.setJqOtherCostsProportion(insFeeOrderNew.getJqOtherCostsProportion()); //交强跟单费比例
- insPlyIncome.setSyOtherCostsProportion(insFeeOrderNew.getSyOtherCostsProportion()); //商业跟单费比例
- insPlyIncome.setNoOtherCostsProportion(insFeeOrderNew.getNoOtherCostsProportion()); //非车跟单费比例
- insPlyIncome.setJqPremium(insFeeOrderNew.getJqPremium());
- insPlyIncome.setSyPremium(insFeeOrderNew.getSyPremium());
- insPlyIncome.setNoPremium(insFeeOrderNew.getNoPremium());
- insPlyIncome.setReceivableAmount(allAmount);
- insPlyIncome.setJqNoTaxPremium(insFeeOrderNew.getJqNoTaxPremium());
- insPlyIncome.setSyNoTaxPremium(insFeeOrderNew.getSyNoTaxPremium());
- insPlyIncome.setNoNoTaxPremium(insFeeOrderNew.getNoNoTaxPremium());
- insPlyIncome.setUserId(insFeeOrderNew.getUserId());
- insPlyIncome.setJqStartDate(StringOperations.emptyStringToNull(insAreaCompany.getJqStartDate()));
- insPlyIncome.setJqEndDate(StringOperations.emptyStringToNull(insAreaCompany.getJqEndDate()));
- insPlyIncome.setSyStartDate(StringOperations.emptyStringToNull(insAreaCompany.getSyStartDate()));
- insPlyIncome.setSyEndDate(StringOperations.emptyStringToNull(insAreaCompany.getSyEndDate()));
- this.getDeptId(insPlyIncome);
- //add by hxl 2024-07-31 修改插入结算表中险种信息错误的bug 将大订单中的险种信息改为小订单的险种信息
- this.saveRiskCode(insAreaCompany.getProductid(), insPlyIncome);
- //this.saveRiskCode(order.getProductid(), insPlyIncome);
- insPlyIncome.setInsuredName(order.getInsuredname());
- this.saveByCompanyId(insFeeOrderNew, insAreaCompany.getCompanyId(), insPlyIncome);
- baseMapper.insert(insPlyIncome);
- InsPlyIncomeLog insPlyIncomeLog = new InsPlyIncomeLog();
- insPlyIncomeLog.setIncomeId(insPlyIncome.getId());
- BeanUtils.copyProperties(insPlyIncome,insPlyIncomeLog);
- insPlyIncomeLog.setId(null);
- insPlyIncomeLog.setOperationStatus("1");
- insPlyIncomeLogService.saveLog(insPlyIncomeLog); //添加日志
- }
- private void getDeptId(InsPlyIncome insPlyIncome) {
- PtlAgreement ptlAgreement = ptlAgreementService.getById(insPlyIncome.getAgreementId());
- String deptId = ptlAgreement.getDeptId();
- insPlyIncome.setDeptId(deptId);
- }
- private void saveByCompanyId(InsFeeOrderNew insFeeOrderNew, String companyId, InsPlyIncome insPlyIncome) {
- PtlAgreement ptlAgreementQueryVo = this.ptlAgreementService.getByAgreementIdNew(insFeeOrderNew.getAgreementId());
- if (ObjectUtils.isNotEmpty(ptlAgreementQueryVo)) {
- if (StringUtils.isNotEmpty(ptlAgreementQueryVo.getPartnerCompaniesId())) {
- // 合作公司id
- String partnerCompaniesId = ptlAgreementQueryVo.getPartnerCompaniesId();
- insPlyIncome.setPartnerCompaniesId(partnerCompaniesId);
- EsmInsCompany esmInsCompany = EsmInsCompanyService.getById(partnerCompaniesId);
- String name = esmInsCompany.getNamesimple(); //合作名称
- insPlyIncome.setPartnerCompaniesName(name);
- insPlyIncome.setPartnerCompaniesId(ptlAgreementQueryVo.getPartnerCompaniesId());
- }
- if (StringUtils.isNotEmpty(ptlAgreementQueryVo.getInsuranceCompanyId())) {
- String insuranceCompanyId = ptlAgreementQueryVo.getInsuranceCompanyId();
- EsmInsCompany esmInsCompany = EsmInsCompanyService.getById(insuranceCompanyId);
- String name = esmInsCompany.getNamesimple(); //保险公司名称 简称
- insPlyIncome.setCompanyName(name);
- }
- }
- }
- private BigDecimal calculateTotal(BigDecimal value1, BigDecimal value2, BigDecimal value3) {
- BigDecimal total = BigDecimal.ZERO;
- if (value1 != null) {
- total = total.add(value1);
- }
- if (value2 != null) {
- total = total.add(value2);
- }
- if (value3 != null) {
- total = total.add(value3);
- }
- return total;
- }
- private String judgeAgreeType(Long agreementId) {
- if (agreementId == null) {
- return null;
- }
- HttpResult<PtlAgreementQueryVo> byAgreementId = ptlAgreementService.getByAgreementId(agreementId.toString());
- if (byAgreementId != null && ObjectUtils.isNotEmpty(byAgreementId.getData())) {
- PtlAgreement agreement = byAgreementId.getData().getAgreement();
- String agreementType = agreement.getAgreementType();
- if (StringUtils.isNotEmpty(agreementType)) {
- return agreementType;
- }
- }
- return null;
- }
- public HttpResult<BasePageResult<InsPlyIncome>> queryNew(InsPlyIncomeVo insPlyIncomeVo) {
- try {
- HashMap<String, Object> params = new HashMap<>();
- PageInfo<List<InsPlyIncome>> pageHelper = null;
- PageHelper.startPage(insPlyIncomeVo.getPageNum(), insPlyIncomeVo.getPageSize());
- params.put("pageNum", insPlyIncomeVo.getPageNum());
- params.put("pageSize", insPlyIncomeVo.getPageSize());
- params = this.saveParams(insPlyIncomeVo, params);
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getIds())) {
- params.put("ids", insPlyIncomeVo.getIds().split(","));
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getId())) {
- SettlementDocumentaryFeesEntity settlementDocumentaryFeesEntity =
- settlementDocumentaryFeesService.getById(insPlyIncomeVo.getId());
- // 通过任务id查询 明细
- String taskId = settlementDocumentaryFeesEntity.getTaskId();
- List<String> incomeIds = incomeTaskRelationshipService.getByTaskId(taskId);
- if (!CollectionUtils.isEmpty(incomeIds)) {
- params.put("incomeIds", incomeIds);
- params.remove("handlingFeesStatus");
- params.remove("id");
- }
- }
- List<InsPlyIncome> list = this.baseMapper.queryNew(params);
- pageHelper = new PageInfo(list);
- BasePageResult<InsPlyIncome> pageResult = new BasePageResult<InsPlyIncome>(insPlyIncomeVo.getPageNum(),
- insPlyIncomeVo.getPageSize(), pageHelper.getTotal(), pageHelper.getPages(), list);
- return HttpResult.ok(pageResult);
- } catch (Exception e) {
- e.printStackTrace();
- return HttpResult.error("查询异常");
- }
- }
- @Override
- public HashMap<String, Object> totalAmount(List<String> selectIds) {
- HashMap<String, Object> params = new HashMap<>();
- params.put("selectIds", selectIds);
- HashMap<String, Object> resultMap = baseMapper.totalAmount(params);
- return resultMap;
- }
- @Override
- @Transactional
- public HttpResult<Object> batchPinBalance(InsPlyIncomeVo insPlyIncomeVo) {
- LocalDateTime now = LocalDateTime.now();
- if (!CollectionUtils.isEmpty(insPlyIncomeVo.getSelectIds())) {
- List<String> selectIds = insPlyIncomeVo.getSelectIds();
- for (String id : selectIds) {
- InsPlyIncome insPlyIncome = new InsPlyIncome();
- insPlyIncome.setHandlingFeesStatus("1");
- insPlyIncome.setSettlementTime(now);
- insPlyIncome.setSettlementUserId(BaseController.getUser().getId());
- insPlyIncome.setId(id);
- baseMapper.updateById(insPlyIncome);
- }
- }
- SettlementDocumentaryLogEntity settlementDocumentaryLogEntity = new SettlementDocumentaryLogEntity();
- settlementDocumentaryLogEntity.setIds(insPlyIncomeVo.getIds());
- // settlementDocumentaryLogEntity.setCompanyId(insPlyIncomeVo.getCompanyId());
- settlementDocumentaryLogEntity.setAmount(insPlyIncomeVo.getOtherFeevalue()); //跟单费金额
- settlementDocumentaryLogEntity.setHandingAmount(insPlyIncomeVo.getCommissionFeevalue()); //手续费金额
- settlementDocumentaryLogEntity.setCreateTime(new Date());
- settlementDocumentaryLogService.save(settlementDocumentaryLogEntity);
- return HttpResult.ok();
- }
- @Override
- public List<InsPlyIncome> totalPinAmount(InsPlyIncomeVo insPlyIncomeVo) {
- HashMap<String, Object> params = new HashMap<>();
- params = this.saveParams(insPlyIncomeVo, params);
- List<InsPlyIncome> result = baseMapper.totalPinAmount(params);
- return result;
- }
- private HashMap<String, Object> saveParams(InsPlyIncomeVo insPlyIncomeVo, HashMap<String, Object> params) {
- if (ObjectUtils.isNotEmpty(insPlyIncomeVo.getId())) {
- params.put("id", insPlyIncomeVo.getId());
- }
- if (ObjectUtils.isNotEmpty(insPlyIncomeVo.getStartDate())) {
- params.put("startDate", insPlyIncomeVo.getStartDate().toString());
- }
- if (ObjectUtils.isNotEmpty(insPlyIncomeVo.getEndDate())) {
- params.put("endDate", insPlyIncomeVo.getEndDate().toString());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getOrderno())) {
- params.put("orderno", insPlyIncomeVo.getOrderno());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotDocumentary())) {
- params.put("isOther", insPlyIncomeVo.getIsNotDocumentary());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotCar())) {
- params.put("isNotCar", insPlyIncomeVo.getIsNotCar());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getAgreementType())) {
- params.put("agreementType", insPlyIncomeVo.getAgreementType());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getLicenseno())) {
- params.put("licenseno", insPlyIncomeVo.getLicenseno());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getUserId())) {
- params.put("userId", insPlyIncomeVo.getUserId());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getCompanyId())) {
- params.put("companyId", insPlyIncomeVo.getCompanyId());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getRiskcode())) {
- params.put("riskcode", insPlyIncomeVo.getRiskcode());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getPolicyno())) {
- params.put("policyno", insPlyIncomeVo.getPolicyno());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getSyPolicyno())) {
- params.put("syPolicyno", insPlyIncomeVo.getSyPolicyno());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getNoPolicyno())) {
- params.put("noPolicyno", insPlyIncomeVo.getNoPolicyno());
- }
- if (insPlyIncomeVo.getCreateTime() != null) {
- params.put("createTime", insPlyIncomeVo.getCreateTime().toString());
- }
- if (insPlyIncomeVo.getSettlementTime() != null) {
- params.put("settlementTime", insPlyIncomeVo.getSettlementTime().toString());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getHandlingFeesStatus())) {
- params.put("handlingFeesStatus", insPlyIncomeVo.getHandlingFeesStatus());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getPartnerCompaniesId())) {
- params.put("partnerCompaniesId", insPlyIncomeVo.getPartnerCompaniesId());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getYear())) {
- params.put("year", insPlyIncomeVo.getYear());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getMonth())) {
- params.put("month", insPlyIncomeVo.getMonth());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getDay())) {
- params.put("day", insPlyIncomeVo.getDay());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getSignDateEnd())) {
- params.put("signDateEnd", insPlyIncomeVo.getSignDateEnd());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getSignDateStart())) {
- params.put("signDateStart", insPlyIncomeVo.getSignDateStart());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getCompanyName())) {
- params.put("companyName", insPlyIncomeVo.getCompanyName());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getInsuredName())) {
- params.put("insuredName", insPlyIncomeVo.getInsuredName());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getPartnerCompaniesName())) {
- params.put("partnerCompaniesName", insPlyIncomeVo.getPartnerCompaniesName());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getDockingPerson())) {
- params.put("dockingPerson", insPlyIncomeVo.getDockingPerson());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getYeartsStart()) && StringUtils.isNotEmpty(insPlyIncomeVo.getYeartsEnd())) {
- params.put("yeartsStart", insPlyIncomeVo.getYeartsStart());
- params.put("yeartsEnd", insPlyIncomeVo.getYeartsEnd());
- }
- if (insPlyIncomeVo.getJqStartDate() != null) {
- params.put("jqStartDate", insPlyIncomeVo.getJqStartDate());
- }
- if (insPlyIncomeVo.getJqStartDate() != null) {
- params.put("jqEndDate", insPlyIncomeVo.getJqEndDate());
- }
- if (insPlyIncomeVo.getSyStartDate() != null) {
- params.put("syStartDate", insPlyIncomeVo.getSyStartDate());
- }
- if (insPlyIncomeVo.getSyEndDate() != null) {
- params.put("syEndDate", insPlyIncomeVo.getSyEndDate());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getProvinceId())) {
- params.put("provinceId", insPlyIncomeVo.getProvinceId());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getCityId())) {
- params.put("cityId", insPlyIncomeVo.getCityId());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getCountyId())) {
- params.put("countyId", insPlyIncomeVo.getCountyId());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getDeptId())) {
- params.put("deptId", insPlyIncomeVo.getDeptId());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getAllPartnerCompaniesId())) {
- params.put("allPartnerCompaniesId", insPlyIncomeVo.getAllPartnerCompaniesId().substring(0, 5));
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getProvincePartnerCompaniesId())) {
- params.put("provincePartnerCompaniesId", insPlyIncomeVo.getProvincePartnerCompaniesId());
- }
- if (!CollectionUtils.isEmpty(insPlyIncomeVo.getSelectIds())) {
- params.put("selectIds", insPlyIncomeVo.getSelectIds());
- }
- if (!CollectionUtils.isEmpty(insPlyIncomeVo.getPartnerCompaniesIdList())) {
- params.put("partnerCompaniesIdList", insPlyIncomeVo.getPartnerCompaniesIdList());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getCreateTimeQuery())){
- params.put("createTimeQuery", insPlyIncomeVo.getCreateTimeQuery());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getSettlementDate())){
- params.put("settlementDate", insPlyIncomeVo.getSettlementDate());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getIsExternal())){
- params.put("isExternal", insPlyIncomeVo.getIsExternal());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getCreateTimeEnd())){
- params.put("createTimeEnd", insPlyIncomeVo.getCreateTimeEnd());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getCreateTimeStart())){
- params.put("createTimeStart", insPlyIncomeVo.getCreateTimeStart());
- }
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getStatus())){
- params.put("status", insPlyIncomeVo.getStatus());
- }
- if(StringUtils.isNotBlank(insPlyIncomeVo.getAddType())){
- params.put("addType", insPlyIncomeVo.getAddType());
- }
- return params;
- }
- @Override
- public HttpResult<BasePageResult<InsPlyIncome>> nonSettlementQuery(InsPlyIncomeVo insPlyIncomeVo) {
- try {
- HashMap<String, Object> params = new HashMap<>();
- PageInfo<List<InsPlyIncome>> pageHelper = null;
- PageHelper.startPage(insPlyIncomeVo.getPageNum(), insPlyIncomeVo.getPageSize());
- params.put("pageNum", insPlyIncomeVo.getPageNum());
- params.put("pageSize", insPlyIncomeVo.getPageSize());
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotCar())) {
- params.put("isNotCar", insPlyIncomeVo.getIsNotCar());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotDocumentary())) {
- params.put("isOther", insPlyIncomeVo.getIsNotDocumentary());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getYear())) {
- params.put("year", insPlyIncomeVo.getYear());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getMonth())) {
- params.put("month", insPlyIncomeVo.getMonth());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getDocumentaryFeesStatus())) {
- params.put("documentaryFeesStatus", insPlyIncomeVo.getDocumentaryFeesStatus());
- }
- List<InsPlyIncome> list = this.baseMapper.NonSettlementQuery(params);
- pageHelper = new PageInfo(list);
- BasePageResult<InsPlyIncome> pageResult = new BasePageResult<InsPlyIncome>(insPlyIncomeVo.getPageNum(),
- insPlyIncomeVo.getPageSize(), pageHelper.getTotal(), pageHelper.getPages(), list);
- return HttpResult.ok(pageResult);
- } catch (Exception e) {
- e.printStackTrace();
- return HttpResult.error("查询异常");
- }
- }
- @Override
- public HttpResult<List<InsPlyIncome>> nonSettldetail(InsPlyIncomeVo insPlyIncomeVo) {
- try {
- String ids = insPlyIncomeVo.getIds();
- ArrayList<InsPlyIncome> resultList = new ArrayList<>();
- if (ObjectUtils.isNotEmpty(ids)) {
- String[] split = ids.split(",");
- for (int i = 0; i < split.length; i++) {
- String id = split[i];
- resultList.add(this.baseMapper.getById(id));
- }
- }
- return HttpResult.ok(resultList);
- } catch (Exception e) {
- e.printStackTrace();
- return HttpResult.error("查询异常");
- }
- }
- /**
- * @param multipartFile
- * @return totalAmount 总金额
- * totalHandingAmount 总手续费金额
- * totalOtherAmount 总跟单费金额
- * resultHashMap 返回 ids 已经上面的金额
- * resultNoSelect 未匹配的车牌号
- */
- @Override
- public HashMap<String, Object> importData(MultipartFile multipartFile) {
- BigDecimal totalAmount = BigDecimal.ZERO;
- BigDecimal totalHandingAmount = BigDecimal.ZERO;
- BigDecimal totalOtherAmount = BigDecimal.ZERO;
- HashMap<String, Object> resultHashMap = new HashMap<>();
- HashSet<String> partnerCompaniesIdSet = new HashSet<>();
- List<String> ids = new ArrayList<>();
- LocalDateTime now = LocalDateTime.now();
- ArrayList<HashMap<String, Object>> resultNoSelect = new ArrayList<>();
- try {
- List<InsPlyIncomeExcelDto> dtoList = ExcelEasypoiUtils.importExcel(multipartFile, InsPlyIncomeExcelDto.class, 0, 1, 1);
- for (InsPlyIncomeExcelDto excelItem : dtoList) {
- String reason ="";
- HashMap<String, Object> objectObjectHashMap = new HashMap<>();
- if (StringUtils.isNotEmpty(excelItem.getLicenseno())) {
- objectObjectHashMap.put("licenseno", excelItem.getLicenseno());//车牌号
- }
- if (StringUtils.isNotEmpty(excelItem.getPolicyno())) {
- objectObjectHashMap.put("policyno", excelItem.getPolicyno()); //交强保单号
- }
- if (StringUtils.isNotEmpty(excelItem.getSyPolicyno())) {
- objectObjectHashMap.put("syPolicyno", excelItem.getSyPolicyno());//商业保单号
- }
- if (StringUtils.isNotEmpty(excelItem.getNoPolicyno())) {
- objectObjectHashMap.put("noPolicyno", excelItem.getNoPolicyno()); //非车保单号
- }
- objectObjectHashMap.put("agreementType","1");
- InsPlyIncome insPlyIncome = baseMapper.findByLicenseno(objectObjectHashMap);
- if (ObjectUtils.isNotEmpty(insPlyIncome)) {
- // 如果能查询出来则 修改结算 变成已结算
- if(excelItem.getJqReceivableProportion()!=null && excelItem.getJqReceivableProportion().compareTo(BigDecimal.ZERO) !=0 ){
- objectObjectHashMap.put("jqReceivableProportion", excelItem.getJqReceivableProportion()); //非车保单号
- List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(objectObjectHashMap);
- if(insPlyIncomes.isEmpty()){
- reason="交强应收比例错误!";
- }
- }
- if(excelItem.getSyReceivableProportion()!=null && excelItem.getSyReceivableProportion().compareTo(BigDecimal.ZERO) !=0 ){
- objectObjectHashMap.put("syReceivableProportion", excelItem.getSyReceivableProportion()); //非车保单号
- List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(objectObjectHashMap);
- if(insPlyIncomes.isEmpty() && StringUtils.isEmpty(reason)){
- reason="商业应收比例错误!";
- }
- }
- if(excelItem.getNoReceivableProportion()!=null && excelItem.getNoReceivableProportion().compareTo(BigDecimal.ZERO) !=0 ){
- objectObjectHashMap.put("noReceivableProportion", excelItem.getNoReceivableProportion()); //非车保单号
- List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(objectObjectHashMap);
- if(insPlyIncomes.isEmpty() && StringUtils.isEmpty(reason)){
- reason="非车应收比例错误!";
- }
- }
- //判断是否是相同保司机构
- partnerCompaniesIdSet.add(insPlyIncome.getPartnerCompaniesId());
- if(StringUtils.isNotEmpty(reason)){
- objectObjectHashMap.put("reason",reason);
- resultNoSelect.add(objectObjectHashMap); // 添加未匹配的车牌号
- }else {
- ids.add(insPlyIncome.getId());
- if (insPlyIncome.getAllFeeValue() != null && insPlyIncome.getAllFeeValue().compareTo(BigDecimal.ZERO) != 0) {
- totalAmount = totalAmount.add(insPlyIncome.getAllFeeValue()); //总金额
- }
- if (insPlyIncome.getCommissionFeevalue() != null && insPlyIncome.getCommissionFeevalue().compareTo(BigDecimal.ZERO) != 0) {
- totalHandingAmount = totalHandingAmount.add(insPlyIncome.getCommissionFeevalue()); //总手续费
- }
- if (insPlyIncome.getOtherFeevalue() != null && insPlyIncome.getOtherFeevalue().compareTo(BigDecimal.ZERO) != 0) {
- totalOtherAmount = totalOtherAmount.add(insPlyIncome.getOtherFeevalue()); //总跟单费
- }
- }
- } else {
- objectObjectHashMap.put("reason","未查询车辆");
- resultNoSelect.add(objectObjectHashMap); // 添加未匹配的车牌号
- }
- }
- // if(partnerCompaniesIdSet.size()>1){
- // throw new SystemException("表里有不同保司机构");
- // }
- resultHashMap.put("totalAmount", totalAmount);
- resultHashMap.put("totalHandingAmount", totalHandingAmount);
- resultHashMap.put("totalOtherAmount", totalOtherAmount);
- resultHashMap.put("resultList", resultNoSelect);
- resultHashMap.put("settIdList",ids);
- return resultHashMap;
- } catch (IOException e) {
- throw new SystemException("导入失败!");
- }
- }
- /**
- * @param multipartFile
- * @return resultList 包含总金额 还有 未匹配表中的数据
- */
- @Override
- public HashMap<String, Object> bxImportData(MultipartFile multipartFile, String isNotCar) {
- BigDecimal totalAmount = BigDecimal.ZERO;
- HashMap<String, Object> params = new HashMap<>();
- ArrayList<HashMap<String, Object>> resultList = new ArrayList<>();
- HashMap<String, Object> resultMap = new HashMap<>();
- StringBuffer strBuilder = new StringBuffer();
- boolean open = true;
- String ids = "";
- try {
- List<InsBxPlyIncomeExcelDto> dtoList = ExcelEasypoiUtils.importExcel(multipartFile, InsBxPlyIncomeExcelDto.class, 0, 1, 1);
- Integer i = 0;
- if (!CollectionUtils.isEmpty(dtoList)) {
- for (InsBxPlyIncomeExcelDto excelItem : dtoList) {
- String reason = "";
- i = i + 1;
- params.clear();
- if (StringUtils.isNotEmpty(excelItem.getLicenseno())) {
- String licenseno = excelItem.getLicenseno();//车牌号
- params.put("licenseno", licenseno);
- InsPlyIncome byBxLicenseno = baseMapper.findByBxLicenseno(params);
- if (ObjectUtils.isEmpty(byBxLicenseno)) {
- reason = "该数据车牌号有问题";
- }
- }
- if (StringUtils.isNotEmpty(excelItem.getPolicyno())) {
- String policyno = excelItem.getPolicyno(); //交强保单号
- params.put("policyno", policyno);
- InsPlyIncome byBxLicenseno = baseMapper.findByBxLicenseno(params);
- if (ObjectUtils.isEmpty(byBxLicenseno)) {
- reason = "该数据交强保单号有问题";
- }
- }
- if (StringUtils.isNotEmpty(excelItem.getSyPolicyno())) {
- String syPolicyno = excelItem.getSyPolicyno(); //商业保单号
- params.put("syPolicyno", syPolicyno);
- InsPlyIncome byBxLicenseno = baseMapper.findByBxLicenseno(params);
- if (ObjectUtils.isEmpty(byBxLicenseno)) {
- reason = "该数据商业保单号有问题";
- }
- }
- if (excelItem.getJqSuperviseCostsProportion() != null && excelItem.getJqSuperviseCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
- params.put("jqSuperviseCostsProportion", excelItem.getJqSuperviseCostsProportion());
- InsPlyIncome byBxLicenseno = baseMapper.findByBxLicenseno(params);
- if (ObjectUtils.isEmpty(byBxLicenseno)) {
- reason = "该数据交强手续费比例有问题";
- }
- }
- if (excelItem.getSySuperviseCostsProportion() != null && excelItem.getSySuperviseCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
- params.put("sySuperviseCostsProportion", excelItem.getSySuperviseCostsProportion());
- InsPlyIncome byBxLicenseno = baseMapper.findByBxLicenseno(params);
- if (ObjectUtils.isEmpty(byBxLicenseno)) {
- reason = "该数据商业手续费比例有问题";
- }
- }
- // 只查手续费
- params.put("isOther", "0");
- params.put("isNotCar", isNotCar);
- InsPlyIncome insPlyIncome = baseMapper.findByBxLicenseno(params);
- if (ObjectUtils.isNotEmpty(insPlyIncome) && open) {
- open = false;
- resultMap.put("companyId", insPlyIncome.getCompanyId()); // 保险公司id
- resultMap.put("partnerCompaniesId", insPlyIncome.getPartnerCompaniesId()); //合作公司id
- resultMap.put("agreementId", insPlyIncome.getAgreementId()); //协议id
- }
- if (ObjectUtils.isNotEmpty(insPlyIncome)) { // 比配上汇总金额 未匹配则返回到数据当中
- strBuilder.append(insPlyIncome.getId()).append(",");
- if (insPlyIncome.getCommissionFeevalue() != null && insPlyIncome.getCommissionFeevalue().compareTo(BigDecimal.ZERO) != 0) {
- totalAmount = totalAmount.add(insPlyIncome.getCommissionFeevalue()); //添加总手续费
- }
- } else {
- HashMap<String, Object> noMatching = new HashMap<>();
- if (StringUtils.isNotEmpty(excelItem.getLicenseno())) {
- noMatching.put("licenseno", excelItem.getLicenseno());
- }
- if (StringUtils.isNotEmpty(excelItem.getPolicyno())) {
- noMatching.put("policyno", excelItem.getPolicyno());
- }
- if (StringUtils.isNotEmpty(excelItem.getSyPolicyno())) {
- noMatching.put("syPolicyno", excelItem.getSyPolicyno());
- }
- resultList.add(noMatching);
- }
- resultMap.put("reason", reason);
- }
- }
- if (strBuilder.length() > 0) {
- ids = strBuilder.deleteCharAt(strBuilder.length() - 1).toString();
- }
- resultMap.put("ids", ids);
- resultMap.put("totalAmount", totalAmount);
- resultMap.put("resultList", resultList);
- return resultMap;
- } catch (IOException e) {
- throw new SystemException("导入失败!");
- }
- }
- @Override
- public HashMap<String, Object> bxImportNoData(MultipartFile multipartFile, String isNotCar) {
- BigDecimal totalAmount = BigDecimal.ZERO;
- HashMap<String, Object> params = new HashMap<>();
- HashMap<String, Object> resultMap = new HashMap<>();
- ArrayList<HashMap<String, Object>> resultList = new ArrayList<>();
- StringBuffer strBuilder = new StringBuffer();
- String ids = "";
- try {
- Integer i = 0;
- List<InsBxNoPlyIncomeExcelDto> dtoList = ExcelEasypoiUtils.importExcel(multipartFile, InsBxNoPlyIncomeExcelDto.class, 0, 1, 1);
- if (!CollectionUtils.isEmpty(dtoList)) {
- for (InsBxNoPlyIncomeExcelDto excelItem : dtoList) {
- String reason = "";
- i = i + 1;
- params.clear();
- if (StringUtils.isNotEmpty(excelItem.getLicenseno())) {
- String licenseno = excelItem.getLicenseno();//车牌号
- params.put("licenseno", licenseno);
- InsPlyIncome byBxLicenseno = baseMapper.findByBxLicenseno(params);
- if (ObjectUtils.isEmpty(byBxLicenseno)) {
- reason = "该数据车牌号有问题";
- }
- }
- if (StringUtils.isNotEmpty(excelItem.getNoPolicyno())) {
- String policyno = excelItem.getNoPolicyno(); //非车保单号
- params.put("NoPolicyno", policyno);
- InsPlyIncome byBxLicenseno = baseMapper.findByBxLicenseno(params);
- if (ObjectUtils.isEmpty(byBxLicenseno)) {
- reason = "该数据非车保单号有问题";
- }
- }
- if (excelItem.getNoSuperviseCostsProportion() != null && excelItem.getNoSuperviseCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
- params.put("noSuperviseCostsProportion", excelItem.getNoSuperviseCostsProportion());
- InsPlyIncome byBxLicenseno = baseMapper.findByBxLicenseno(params);
- if (ObjectUtils.isEmpty(byBxLicenseno)) {
- reason = "该数据非车手续费比例有问题";
- }
- }
- // 只查手续费
- params.put("isOther", "0");
- params.put("isNotCar", isNotCar);
- InsPlyIncome insPlyIncome = baseMapper.findByBxLicenseno(params);
- if (i == dtoList.size() && ObjectUtils.isNotEmpty(insPlyIncome)) {
- resultMap.put("companyId", insPlyIncome.getCompanyId()); // 保险公司id
- resultMap.put("partnerCompaniesId", insPlyIncome.getPartnerCompaniesId()); //合作公司id
- resultMap.put("agreementId", insPlyIncome.getAgreementId()); //协议id
- }
- if (ObjectUtils.isNotEmpty(insPlyIncome)) { // 比配上汇总金额 未匹配则返回到数据当中
- strBuilder.append(insPlyIncome.getId()).append(",");
- if (insPlyIncome.getCommissionFeevalue() != null && insPlyIncome.getCommissionFeevalue().compareTo(BigDecimal.ZERO) != 0) {
- totalAmount = totalAmount.add(insPlyIncome.getCommissionFeevalue()); //添加总手续费
- }
- } else {
- HashMap<String, Object> noMatching = new HashMap<>();
- if (StringUtils.isNotEmpty(excelItem.getLicenseno())) {
- noMatching.put("licenseno", excelItem.getLicenseno());
- }
- if (StringUtils.isNotEmpty(excelItem.getNoPolicyno())) {
- noMatching.put("NoPolicyno", excelItem.getNoPolicyno());
- }
- resultList.add(noMatching);
- }
- resultMap.put("reason", reason);
- }
- if (strBuilder.length() > 0) {
- ids = strBuilder.deleteCharAt(strBuilder.length() - 1).toString();
- }
- resultMap.put("ids", ids);
- resultMap.put("totalAmount", totalAmount);
- resultMap.put("resultList", resultList);
- }
- return resultMap;
- } catch (IOException e) {
- throw new SystemException("导入失败!");
- }
- }
- @Override
- public HttpResult bxOtherDetailsExcel(InsPlyIncomeVo insPlyIncomeVo, HttpServletRequest request, HttpServletResponse response) {
- HashMap<String, Object> params = new HashMap<>();
- params = this.saveParams(insPlyIncomeVo, params);
- List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params);
- String filePathName = "";
- List<BxOtherDetailsNorExcel> resultNoList = new ArrayList<>();
- List<BxOtherDetailsExcel> resultList = new ArrayList<>();
- //判断是否是非车 1 是非车
- if ("1".equals(insPlyIncomeVo.getIsNotCar())) {
- filePathName = "非车跟单明细导出";
- ExportParams exportParams = new ExportParams("非车跟单明细", null, ExcelType.HSSF);
- exportParams.setStyle(ExcelStyleUtil.class);
- for (InsPlyIncome item : insPlyIncomes) {
- BxOtherDetailsNorExcel bxOtherDetailsNorExcel = new BxOtherDetailsNorExcel();
- LocalDateTime signDate = item.getSignDate();
- BeanUtils.copyProperties(item, bxOtherDetailsNorExcel);
- bxOtherDetailsNorExcel.setSigndate(signDate);
- resultNoList.add(bxOtherDetailsNorExcel);
- }
- } else {
- filePathName = "车险跟单明细导出";
- ExportParams exportParams = new ExportParams("车险跟单明细", null, ExcelType.HSSF);
- exportParams.setStyle(ExcelStyleUtil.class);
- for (InsPlyIncome item : insPlyIncomes) {
- BxOtherDetailsExcel bxOtherDetailsExcel = new BxOtherDetailsExcel();
- LocalDateTime signDate = item.getSignDate();
- BeanUtils.copyProperties(item, bxOtherDetailsExcel);
- bxOtherDetailsExcel.setSigndate(signDate);
- resultList.add(bxOtherDetailsExcel);
- }
- }
- String uploadPath = this.uploadPath + "/excel/";
- Path path = Paths.get(uploadPath);
- if (!Files.exists(path)) {
- try {
- Files.createDirectories(path);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- String fileName = "";
- if ("1".equals(insPlyIncomeVo.getIsNotCar())) {
- fileName = EasyExcelUtils.downExcel(uploadPath, filePathName, BxOtherDetailsNorExcel.class, resultNoList);
- } else {
- fileName = EasyExcelUtils.downExcel(uploadPath, filePathName, BxOtherDetailsExcel.class, resultList);
- }
- return HttpResult.ok("", uploadUrl + "excel/" + fileName);
- }
- /**
- * @param insPlyIncomeVo 传参字段
- * ids 通过ids中的id进行开票分组
- * @return
- */
- @Override
- public HttpResult<List<SettlementDocumentaryFeesEntity>> invicdetail(InsPlyIncomeVo insPlyIncomeVo) {
- HashMap<String, Object> params = new HashMap<>();
- params = this.saveParams(insPlyIncomeVo, params);
- if (StringUtils.isEmpty(insPlyIncomeVo.getIsSettlement())) {
- params.put("isSettlement", "1");
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getSettlementStatus())) {
- params.put("settlementStatus", insPlyIncomeVo.getSettlementStatus());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getCompletionStatus())) {
- params.put("completionStatus", insPlyIncomeVo.getCompletionStatus());
- }
- List<SettlementDocumentaryFeesEntity> resultList = settlementDocumentaryFeesService.querySettleNew(params);
- if (resultList.size() > 0) {
- return HttpResult.ok(resultList);
- }
- return HttpResult.ok();
- }
- /***
- *
- * @param insPlyIncomeVo
- * @param request
- * @param response
- * @return 保险非车跟单明细导出
- */
- @Override
- public HttpResult bxNoOtherDetailsExcel(InsPlyIncomeVo insPlyIncomeVo, HttpServletRequest request, HttpServletResponse response) {
- HashMap<String, Object> params = new HashMap<>();
- params = this.saveParams(insPlyIncomeVo, params);
- List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params);
- ExportParams exportParams = new ExportParams("保险非车跟单明细导出", null, ExcelType.HSSF);
- exportParams.setStyle(ExcelStyleUtil.class);
- List<BxNoOtherDetailsExcel> resultList = new ArrayList<>();
- for (InsPlyIncome item : insPlyIncomes) {
- BxNoOtherDetailsExcel bxNoOtherDetailsExcel = new BxNoOtherDetailsExcel();
- BeanUtils.copyProperties(item, bxNoOtherDetailsExcel);
- resultList.add(bxNoOtherDetailsExcel);
- }
- String uploadPath = this.uploadPath + "/excel/";
- Path path = Paths.get(uploadPath);
- if (!Files.exists(path)) {
- try {
- Files.createDirectories(path);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- String fileName = EasyExcelUtils.downExcel(uploadPath, "保险非车跟单明细导出", BxNoOtherDetailsExcel.class, resultList);
- return HttpResult.ok("", uploadUrl + "excel/" + fileName);
- }
- /**
- * @param insPlyIncomeVo 开票ids
- * @return 返回开票号 开票金额 开票时间
- */
- @Override
- public HttpResult<List<HashMap<String, Object>>> otherSettldetail(InsPlyIncomeVo insPlyIncomeVo) {
- HashMap<String, Object> params = new HashMap<>();
- params = this.saveParams(insPlyIncomeVo, params);
- List<HashMap<String, Object>> resultList = settlementDocumentaryFeesService.getOtherSettldetail(params);
- if (resultList.size() > 0) {
- return HttpResult.ok(resultList);
- }
- return HttpResult.ok();
- }
- @Override
- public InsPlyIncome getEntityById(String id) {
- return baseMapper.getEntityById(id);
- }
- @Override
- @Transactional
- public void updateByEntity(InsPlyIncomeVo insPlyIncomeVo) {
- // 根据协议 如果是含增值税结算 用保费 * 如果是 不含税保费
- InsPlyIncome insPlyIncome = new InsPlyIncome();
- BeanUtils.copyProperties(insPlyIncomeVo, insPlyIncome);
- InsPlyIncome byId = baseMapper.getById(insPlyIncomeVo.getId());
- InsPlyIncomeLog insPlyIncomeLog = new InsPlyIncomeLog();
- insPlyIncomeLog.setIncomeId(insPlyIncome.getId());
- BeanUtils.copyProperties(byId,insPlyIncomeLog);
- insPlyIncomeLog.setId(null);
- insPlyIncomeLog.setOperationStatus("2");
- insPlyIncomeLogService.saveLog(insPlyIncomeLog); //添加日志
- this.amountCalculate(insPlyIncomeVo, insPlyIncome);
- String agreementId = insPlyIncomeVo.getAgreementId();
- if(StringUtils.isNotEmpty(agreementId)){
- PtlAgreement byId1 = ptlAgreementService.getById(agreementId);
- if(ObjectUtils.isNotEmpty(byId1)){
- String partnerCompaniesId = byId1.getPartnerCompaniesId();
- String insuranceCompanyId = byId1.getInsuranceCompanyId();
- String insuranceCompany = byId1.getInsuranceCompany();
- if(StringUtils.isNotEmpty(partnerCompaniesId)){
- insPlyIncome.setPartnerCompaniesId(partnerCompaniesId);
- EsmInsCompany esmInsCompany = EsmInsCompanyService.getById(partnerCompaniesId);
- String name = esmInsCompany.getNamesimple(); //合作名称
- insPlyIncome.setPartnerCompaniesName(name);
- }
- insPlyIncome.setCompanyId(insuranceCompanyId);
- insPlyIncome.setCompanyName(insuranceCompany);
- }
- }
- insPlyIncome.setUpdateUserId(BaseController.getUser().getId());
- baseMapper.updateById(insPlyIncome);
- }
- @Override
- public void updateNoHand(InsPlyIncomeVo insPlyIncomeVo) {
- // 根据协议 如果是含增值税结算 用保费 * 如果是 不含税保费
- InsPlyIncome insPlyIncome = baseMapper.getById(insPlyIncomeVo.getId());
- BigDecimal bigDecimal = this.getBigDecimal(insPlyIncome.getNoPremium(), insPlyIncomeVo.getNoSuperviseCostsProportion());
- insPlyIncome.setCommissionFeevalue(bigDecimal);
- insPlyIncome.setCommissionFeerate(insPlyIncomeVo.getNoSuperviseCostsProportion());
- insPlyIncome.setNoSuperviseCostsPremiums(bigDecimal);
- insPlyIncome.setAllFeeValue(bigDecimal);
- insPlyIncome.setUpdateUserId(BaseController.getUser().getId());
- insPlyIncome.setNoSuperviseCostsProportion(insPlyIncomeVo.getNoSuperviseCostsProportion());
- insPlyIncome.setAgreementId(insPlyIncomeVo.getAgreementId());
- insPlyIncome.setAddType(insPlyIncomeVo.getAddType());
- baseMapper.updateById(insPlyIncome);
- InsPlyIncomeLog insPlyIncomeLog = new InsPlyIncomeLog();
- insPlyIncomeLog.setIncomeId(insPlyIncome.getId());
- BeanUtils.copyProperties(insPlyIncome,insPlyIncomeLog);
- insPlyIncomeLog.setId(null);
- insPlyIncomeLog.setOperationStatus("2");
- insPlyIncomeLogService.saveLog(insPlyIncomeLog); //添加日志
- insPlyIncomeVo.setOtherFeevalue(insPlyIncomeVo.getNoSuperviseCostsPremiums());
- insPlyIncomeVo.setCrudStatus("2");
- this.saveLog(insPlyIncomeVo);
- }
- @Override
- public HttpResult<Object> batchPinBalanceNew(InsPlyIncomeVo insPlyIncomeVo) {
- LocalDateTime now = LocalDateTime.now();
- if(!CollectionUtils.isEmpty(insPlyIncomeVo.getSettIdList())){
- for (String id : insPlyIncomeVo.getSettIdList()){
- InsPlyIncome insPlyIncome = baseMapper.getById(id);
- if("1".equals(insPlyIncome.getHandlingFeesStatus())){
- throw new SystemException("有已结算数据");
- }
- insPlyIncome.setSettlementImageId(insPlyIncomeVo.getSettlementImageId());
- insPlyIncome.setSettlementUserId(BaseController.getUser().getId());
- insPlyIncome.setSettlementTime(now);
- insPlyIncome.setId(id);
- insPlyIncome.setHandlingFeesStatus("1");
- baseMapper.updateById(insPlyIncome);
- }
- }
- return HttpResult.ok();
- }
- /**
- * @param insPlyIncomeVo
- * @param insPlyIncome 重新计算金额 通过比例
- * 计算逻辑 交强不含税保费* 交强跟单比例 = 交强跟单金额
- */
- private void amountCalculate(InsPlyIncomeVo insPlyIncomeVo, InsPlyIncome insPlyIncome) {
- if ("1".equals(insPlyIncomeVo.getAgreementType())) { //平台
- // 平台 手续费 +跟单费 = 应收 手续费 = 手续费比例*保费 应收比例=手续费比例 + 跟单比例
- BigDecimal jqSuperviseCostsProportion = initializationBigdecimal(insPlyIncomeVo.getJqSuperviseCostsProportion());//交强手续费比例
- BigDecimal sySuperviseCostsProportion = initializationBigdecimal(insPlyIncomeVo.getSySuperviseCostsProportion()); //商业手续费比例
- BigDecimal noSuperviseCostsProportion = initializationBigdecimal(insPlyIncomeVo.getNoSuperviseCostsProportion()); //非车手续费比例
- BigDecimal jqOtherCostsProportion = initializationBigdecimal(insPlyIncomeVo.getJqOtherCostsProportion()); //交强跟单比例
- BigDecimal syOtherCostsProportion = initializationBigdecimal(insPlyIncomeVo.getSyOtherCostsProportion()); //商业跟单比例
- BigDecimal noOtherCostsProportion = initializationBigdecimal(insPlyIncomeVo.getNoOtherCostsProportion()); //非车跟单比例
- BigDecimal jqPremium = initializationBigdecimal(insPlyIncomeVo.getJqPremium()); //交强保费
- BigDecimal syPremium = initializationBigdecimal(insPlyIncomeVo.getSyPremium()); //商业保费
- BigDecimal noPremium = initializationBigdecimal(insPlyIncomeVo.getNoPremium()); //非车保费
- //手续费比例
- insPlyIncome.setCommissionFeerate(this.calculateTotal(jqSuperviseCostsProportion, sySuperviseCostsProportion,
- noSuperviseCostsProportion)); //手续费比例 = 商业手续费比例 + 交强手续费比例 + 非车手续费比例
- if (jqSuperviseCostsProportion != null && jqPremium != null) {
- insPlyIncome.setJqSuperviseCostsPremiums(algorithmAmount(jqPremium, jqSuperviseCostsProportion)); //交强手续费
- insPlyIncome.setJqSuperviseCostsProportion(jqSuperviseCostsProportion);
- }
- if (sySuperviseCostsProportion != null && syPremium != null) {
- insPlyIncome.setSySuperviseCostsPremiums(algorithmAmount(syPremium, sySuperviseCostsProportion)); //商业手续费
- insPlyIncome.setSySuperviseCostsProportion(sySuperviseCostsProportion);
- }
- if (noSuperviseCostsProportion != null && noPremium != null) {
- insPlyIncome.setNoSuperviseCostsPremiums(algorithmAmount(noPremium, noSuperviseCostsProportion)); //非车手续费
- insPlyIncome.setNoSuperviseCostsProportion(noSuperviseCostsProportion);
- }
- if (jqOtherCostsProportion != null && jqPremium != null) {
- insPlyIncome.setJqOtherCostsPremium(algorithmAmount(jqPremium, jqOtherCostsProportion)); //交强跟单费
- insPlyIncome.setJqOtherCostsProportion(jqOtherCostsProportion);
- }
- if (syOtherCostsProportion != null && syPremium != null) {
- insPlyIncome.setSyOtherCostsPremium(algorithmAmount(syPremium, syOtherCostsProportion)); //商业跟单费
- insPlyIncome.setSyOtherCostsProportion(syOtherCostsProportion);
- }
- if (noOtherCostsProportion != null && noPremium != null) {
- insPlyIncome.setNoOtherCostsPremium(algorithmAmount(noPremium, noOtherCostsProportion)); //非车跟单费
- insPlyIncome.setNoOtherCostsProportion(noOtherCostsProportion);
- }
- insPlyIncome.setCommissionFeevalue(this.calculateTotal(insPlyIncome.getJqSuperviseCostsPremiums(), insPlyIncome.getSySuperviseCostsPremiums(), insPlyIncome.getNoSuperviseCostsPremiums())); //手续费
- insPlyIncome.setCommissionFeerate(this.calculateTotal(jqSuperviseCostsProportion, sySuperviseCostsProportion,
- noSuperviseCostsProportion)); //手续费比例
- insPlyIncome.setOtherFeevalue(this.calculateTotal(insPlyIncome.getJqOtherCostsPremium(), insPlyIncome.getSyOtherCostsPremium(), insPlyIncome.getNoOtherCostsPremium())); //跟单费金额
- insPlyIncome.setOtherFeerate(this.calculateTotal(jqOtherCostsProportion, syOtherCostsProportion, noOtherCostsProportion));
- //跟单费比例
- //应收比例 交强应收比例=交强手续费比例+交强非跟单比例
- insPlyIncome.setJqReceivableProportion(this.calculateTotal(jqSuperviseCostsProportion, jqOtherCostsProportion, null)); //交强应收
- insPlyIncome.setSyReceivableProportion(this.calculateTotal(sySuperviseCostsProportion, syOtherCostsProportion, null)); //商业应收
- insPlyIncome.setNoReceivableProportion(this.calculateTotal(noSuperviseCostsProportion, noOtherCostsProportion, null)); //非车应收
- if(insPlyIncomeVo.getPtCommissionFeevalue()!=null && insPlyIncomeVo.getPtCommissionFeevalue().compareTo(BigDecimal.ZERO) >0){
- insPlyIncome.setCommissionFeevalue(insPlyIncomeVo.getPtCommissionFeevalue());
- }
- if(insPlyIncomeVo.getPtOtherFeevalue()!=null && insPlyIncomeVo.getPtOtherFeevalue().compareTo(BigDecimal.ZERO) >0){
- insPlyIncome.setOtherFeevalue(insPlyIncomeVo.getPtOtherFeevalue());
- }
- insPlyIncome.setAllFeeValue(this.calculateTotal(insPlyIncome.getCommissionFeevalue(), insPlyIncome.getOtherFeevalue(), null)); // 总费用 = 手续费+跟单费
- insPlyIncome.setReceivableAmount(this.calculateTotal(insPlyIncome.getCommissionFeevalue(), insPlyIncome.getOtherFeevalue(), null));
- } else {
- String agreementId = insPlyIncomeVo.getAgreementId();
- BigDecimal jqNoTaxPremium = insPlyIncomeVo.getJqPremium();// 交强手续费 按照思路 交强不含税保费* 交强手续费比例 =交强手续费
- BigDecimal syNoTaxPremium = insPlyIncomeVo.getSyPremium();// 商业手续费 按照思路 商业不含税保费* 商业手续费比例 =商业手续费
- BigDecimal noNoTaxPremium = insPlyIncomeVo.getNoPremium();// 非车手续费 按照思路 非车不含税保费* 非车手续费比例 =非车手续费
- if(StringUtils.isNotEmpty(agreementId)){
- PtlAgreement ptlAgreement = ptlAgreementService.getById(agreementId);
- if(StringUtils.isNotEmpty(ptlAgreement.getWithTax()) && "是".equals(ptlAgreement.getWithTax())){
- if (jqNoTaxPremium != null && insPlyIncomeVo.getJqSuperviseCostsProportion() != null && insPlyIncomeVo.getJqSuperviseCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
- insPlyIncome.setJqSuperviseCostsPremiums(algorithmAmount(jqNoTaxPremium, insPlyIncomeVo.getJqSuperviseCostsProportion()));
- insPlyIncome.setJqSuperviseCostsProportion(insPlyIncomeVo.getJqSuperviseCostsProportion());
- }
- if (syNoTaxPremium != null && insPlyIncomeVo.getSySuperviseCostsProportion() != null && insPlyIncomeVo.getSySuperviseCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
- insPlyIncome.setSySuperviseCostsPremiums(algorithmAmount(syNoTaxPremium, insPlyIncomeVo.getSySuperviseCostsProportion()));
- insPlyIncome.setSySuperviseCostsProportion(insPlyIncomeVo.getSySuperviseCostsProportion());
- }
- if (noNoTaxPremium != null && insPlyIncomeVo.getNoSuperviseCostsProportion() != null && insPlyIncomeVo.getNoSuperviseCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
- insPlyIncome.setNoSuperviseCostsProportion(insPlyIncome.getNoSuperviseCostsProportion());
- insPlyIncome.setNoSuperviseCostsPremiums(algorithmAmount(noNoTaxPremium, insPlyIncomeVo.getNoSuperviseCostsProportion()));
- }
- if (jqNoTaxPremium != null && insPlyIncomeVo.getJqOtherCostsProportion() != null && insPlyIncomeVo.getJqOtherCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
- insPlyIncome.setJqOtherCostsPremium(algorithmAmount(jqNoTaxPremium, insPlyIncomeVo.getJqOtherCostsProportion()));
- insPlyIncome.setJqOtherCostsProportion(insPlyIncomeVo.getJqOtherCostsProportion());
- }
- if (syNoTaxPremium != null && insPlyIncomeVo.getSyOtherCostsProportion() != null && insPlyIncomeVo.getSyOtherCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
- insPlyIncome.setSyOtherCostsProportion(insPlyIncome.getSyOtherCostsProportion());
- insPlyIncome.setSyOtherCostsPremium(algorithmAmount(syNoTaxPremium, insPlyIncomeVo.getSyOtherCostsProportion()));
- }
- if (noNoTaxPremium != null && insPlyIncomeVo.getOtherFeerate() != null && insPlyIncomeVo.getOtherFeerate().compareTo(BigDecimal.ZERO) != 0) {
- insPlyIncome.setNoOtherCostsProportion(insPlyIncome.getOtherFeerate());
- insPlyIncome.setNoOtherCostsPremium(algorithmAmount(noNoTaxPremium, insPlyIncomeVo.getOtherFeerate()));
- }
- }else {
- if (jqNoTaxPremium != null && insPlyIncomeVo.getJqSuperviseCostsProportion() != null && insPlyIncomeVo.getJqSuperviseCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
- insPlyIncome.setJqSuperviseCostsPremiums(getBigDecimal(jqNoTaxPremium, insPlyIncomeVo.getJqSuperviseCostsProportion()));
- insPlyIncome.setJqSuperviseCostsProportion(insPlyIncomeVo.getJqSuperviseCostsProportion());
- }
- if (syNoTaxPremium != null && insPlyIncomeVo.getSySuperviseCostsProportion() != null && insPlyIncomeVo.getSySuperviseCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
- insPlyIncome.setSySuperviseCostsPremiums(getBigDecimal(syNoTaxPremium, insPlyIncomeVo.getSySuperviseCostsProportion()));
- insPlyIncome.setSySuperviseCostsProportion(insPlyIncomeVo.getSySuperviseCostsProportion());
- }
- if (noNoTaxPremium != null && insPlyIncomeVo.getNoSuperviseCostsProportion() != null && insPlyIncomeVo.getNoSuperviseCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
- insPlyIncome.setNoSuperviseCostsProportion(insPlyIncome.getNoSuperviseCostsProportion());
- insPlyIncome.setNoSuperviseCostsPremiums(getBigDecimal(noNoTaxPremium, insPlyIncomeVo.getNoSuperviseCostsProportion()));
- }
- if (jqNoTaxPremium != null && insPlyIncomeVo.getJqOtherCostsProportion() != null && insPlyIncomeVo.getJqOtherCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
- insPlyIncome.setJqOtherCostsPremium(getBigDecimal(jqNoTaxPremium, insPlyIncomeVo.getJqOtherCostsProportion()));
- insPlyIncome.setJqOtherCostsProportion(insPlyIncomeVo.getJqOtherCostsProportion());
- }
- if (syNoTaxPremium != null && insPlyIncomeVo.getSyOtherCostsProportion() != null && insPlyIncomeVo.getSyOtherCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
- insPlyIncome.setSyOtherCostsProportion(insPlyIncome.getSyOtherCostsProportion());
- insPlyIncome.setSyOtherCostsPremium(getBigDecimal(syNoTaxPremium, insPlyIncomeVo.getSyOtherCostsProportion()));
- }
- if (noNoTaxPremium != null && insPlyIncomeVo.getOtherFeerate() != null && insPlyIncomeVo.getOtherFeerate().compareTo(BigDecimal.ZERO) != 0) {
- insPlyIncome.setNoOtherCostsProportion(insPlyIncome.getOtherFeerate());
- insPlyIncome.setNoOtherCostsPremium(getBigDecimal(noNoTaxPremium, insPlyIncomeVo.getOtherFeerate()));
- }
- }
- }
- if ("0".equals(insPlyIncomeVo.getIsNotDocumentary()) && "0".equals(insPlyIncomeVo.getIsNotCar())) { //保险 手续费 =不含税保费* 手续费比例
- insPlyIncome.setCommissionFeevalue(this.calculateTotal(insPlyIncome.getJqSuperviseCostsPremiums(), insPlyIncome.getSySuperviseCostsPremiums(), null)); // 手续费
- insPlyIncome.setCommissionFeerate(this.calculateTotal(insPlyIncome.getJqSuperviseCostsProportion(), insPlyIncome.getSySuperviseCostsProportion(), null));//手续费比例
- insPlyIncome.setAllFeeValue(this.calculateTotal(insPlyIncome.getCommissionFeevalue(), null, null));//总金额
- } else if ("1".equals(insPlyIncomeVo.getIsNotDocumentary()) && "0".equals(insPlyIncomeVo.getIsNotCar())) { //保险跟单费 交强跟单+商业跟单
- insPlyIncome.setOtherFeevalue(this.calculateTotal(insPlyIncome.getJqOtherCostsPremium(), insPlyIncome.getSyOtherCostsPremium(), null));
- insPlyIncome.setOtherFeerate(this.calculateTotal(insPlyIncome.getJqOtherCostsProportion(), insPlyIncome.getSyOtherCostsProportion(), null));
- insPlyIncome.setAllFeeValue(this.calculateTotal(insPlyIncome.getOtherFeevalue(), null, null));//总金额
- }
- if ("0".equals(insPlyIncomeVo.getIsNotDocumentary()) && "1".equals(insPlyIncomeVo.getIsNotCar())) {// 非车
- insPlyIncome.setCommissionFeevalue(this.calculateTotal(insPlyIncome.getNoSuperviseCostsPremiums(), null, null)); // 非车手续费
- insPlyIncome.setCommissionFeerate(this.calculateTotal(insPlyIncome.getNoSuperviseCostsProportion(), null, null)); //非车比例
- insPlyIncome.setAllFeeValue(this.calculateTotal(insPlyIncome.getCommissionFeevalue(), null, null));//总金额
- } else if ("1".equals(insPlyIncomeVo.getIsNotDocumentary()) && "1".equals(insPlyIncomeVo.getIsNotCar())) { //非车跟单
- insPlyIncome.setOtherFeevalue(this.calculateTotal(insPlyIncome.getNoOtherCostsPremium(), null, null)); //非车跟单金额
- insPlyIncome.setOtherFeerate(this.calculateTotal(insPlyIncome.getNoOtherCostsProportion(), null, null)); // 非车跟单比例
- insPlyIncome.setAllFeeValue(this.calculateTotal(insPlyIncome.getOtherFeevalue(), null, null));//总金额
- }
- }
- }
- /**
- * 计算 金额
- *
- * @param taxPremium
- * @param proportion
- * @return
- */
- private static BigDecimal getBigDecimal(BigDecimal taxPremium, BigDecimal proportion) {
- BigDecimal divisor = new BigDecimal("1.06"); // 示例除数
- // 先进行除法,保留5位小数,不进行四舍五入(使用RoundingMode.DOWN)
- BigDecimal dividedAmount = taxPremium.divide(divisor, 5, BigDecimal.ROUND_DOWN);
- // 将比例除以100,假设proportion是一个百分比值
- // 然后进行乘法,并进行舍入到5位小数
- BigDecimal result = dividedAmount.multiply( proportion.divide(new BigDecimal(100))).setScale(5, BigDecimal.ROUND_DOWN);
- return result;
- }
- /**
- * @param value1 保费
- * @param value2 比例
- * @return 费用
- */
- private BigDecimal algorithmAmount(BigDecimal value1, BigDecimal value2) {
- BigDecimal divide = value2.divide(new BigDecimal(100));
- return value1.multiply(divide).setScale(5,BigDecimal.ROUND_DOWN);
- }
- private BigDecimal initializationBigdecimal(BigDecimal value) {
- return value != null ? value : BigDecimal.ZERO;
- }
- private void saveLog(InsPlyIncomeVo insPlyIncomeVo) {
- // 添加记录
- SettlementDocumentaryLogEntity settlementDocumentaryLogEntity = new SettlementDocumentaryLogEntity();
- settlementDocumentaryLogEntity.setCrudStatus(insPlyIncomeVo.getCrudStatus());
- settlementDocumentaryLogEntity.setAmount(insPlyIncomeVo.getOtherFeevalue());
- settlementDocumentaryLogEntity.setSettlementDocumentaryId(insPlyIncomeVo.getId());
- settlementDocumentaryLogEntity.setAmountType("2");
- settlementDocumentaryLogService.save(settlementDocumentaryLogEntity);
- }
- @Override
- @Transactional
- public HttpResult<InsPlyIncome> insertByEntity(InsPlyIncomeVo insPlyIncomeVo) {
- Long id = new SnowFlakeUtil().nextId();
- InsPlyIncome insPlyIncome = new InsPlyIncome();
- insPlyIncomeVo.setOrderno(id.toString());
- String signdateStr = insPlyIncomeVo.getSignDate();
- LocalDateTime localDateTime = this.LocalDatePareLocalDateTime(signdateStr);
- insPlyIncomeVo.setSignDate(null);
- BeanUtils.copyProperties(insPlyIncomeVo, insPlyIncome);
- insPlyIncome.setUserId(BaseController.getUser().getId());
- insPlyIncome.setDocumentaryFeesStatus("0");
- insPlyIncome.setHandlingFeesStatus("0");
- insPlyIncome.setIsNotCar(insPlyIncomeVo.getIsNotCar()); // 是否是非车
- insPlyIncome.setIsNotDocumentary(insPlyIncomeVo.getIsNotDocumentary()); //是否是跟单
- insPlyIncome.setSignDate(localDateTime);
- insPlyIncome.setDeptId(BaseController.getUser().getDeptId());
- insPlyIncome.setCreateTime(LocalDateTime.now());
- insPlyIncome.setOtherFeerate(this.calculateTotal(insPlyIncomeVo.getJqOtherCostsProportion(),insPlyIncomeVo.getSyOtherCostsProportion(),insPlyIncomeVo.getNoOtherCostsProportion()));
- insPlyIncome.setCommissionFeerate(this.calculateTotal(insPlyIncomeVo.getJqSuperviseCostsProportion(),insPlyIncomeVo.getSySuperviseCostsProportion(),insPlyIncomeVo.getNoSuperviseCostsProportion()));
- if (insPlyIncome.getJqPremium() != null && insPlyIncome.getJqPremium().compareTo(BigDecimal.ZERO) != 0 && insPlyIncome.getJqSuperviseCostsProportion() != null && insPlyIncome.getJqSuperviseCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
- insPlyIncome.setJqSuperviseCostsPremiums(getBigDecimal(insPlyIncome.getJqPremium(), insPlyIncomeVo.getJqSuperviseCostsProportion()));
- }
- if (insPlyIncome.getSyPremium() != null && insPlyIncome.getSyPremium().compareTo(BigDecimal.ZERO) != 0 && insPlyIncome.getSySuperviseCostsProportion() != null && insPlyIncome.getSySuperviseCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
- insPlyIncome.setSySuperviseCostsPremiums(getBigDecimal(insPlyIncome.getSyPremium(), insPlyIncomeVo.getSySuperviseCostsProportion()));
- }
- if (insPlyIncome.getNoPremium() != null && insPlyIncome.getNoPremium().compareTo(BigDecimal.ZERO) != 0 && insPlyIncome.getNoSuperviseCostsProportion() != null && insPlyIncome.getNoSuperviseCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
- insPlyIncome.setNoSuperviseCostsPremiums(getBigDecimal(insPlyIncome.getNoPremium(), insPlyIncomeVo.getNoSuperviseCostsProportion()));
- }
- if (insPlyIncome.getJqPremium() != null && insPlyIncome.getJqPremium().compareTo(BigDecimal.ZERO) != 0 && insPlyIncome.getJqOtherCostsProportion() != null && insPlyIncome.getJqOtherCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
- insPlyIncome.setJqOtherCostsPremium(getBigDecimal(insPlyIncome.getJqPremium(), insPlyIncomeVo.getJqOtherCostsProportion()));
- }
- if (insPlyIncome.getSyPremium() != null && insPlyIncome.getSyPremium().compareTo(BigDecimal.ZERO) != 0 && insPlyIncome.getSyOtherCostsProportion() != null && insPlyIncome.getSyOtherCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
- insPlyIncome.setSyOtherCostsPremium(getBigDecimal(insPlyIncome.getSyPremium(), insPlyIncomeVo.getSyOtherCostsProportion()));
- }
- if (insPlyIncome.getNoPremium() != null && insPlyIncome.getNoPremium().compareTo(BigDecimal.ZERO) != 0 && insPlyIncome.getNoOtherCostsProportion() != null && insPlyIncome.getNoOtherCostsProportion().compareTo(BigDecimal.ZERO) != 0) {
- insPlyIncome.setNoOtherCostsPremium(getBigDecimal(insPlyIncome.getNoPremium(), insPlyIncomeVo.getNoOtherCostsProportion()));
- }
- insPlyIncome.setAllFeeValue(this.calculateTotal(insPlyIncome.getCommissionFeevalue(),insPlyIncome.getOtherFeevalue(),null));
- String partnerCompaniesId = insPlyIncome.getPartnerCompaniesId();
- insPlyIncome.setPartnerCompaniesId(partnerCompaniesId);
- EsmInsCompany esmInsCompany = EsmInsCompanyService.getById(partnerCompaniesId);
- String name = esmInsCompany.getNamesimple(); //合作名称
- insPlyIncome.setPartnerCompaniesName(name);
- HashMap<String, Object> params = new HashMap<>();
- params.put("agreeId",insPlyIncomeVo.getAgreeId());
- PtlAgreement ptlAgreement = ptlAgreementService.selectAgreeId(params);
- if (ObjectUtils.isEmpty(ptlAgreement)) {
- return HttpResult.error("协议匹配不上");
- }
- insPlyIncome.setAgreementId(ptlAgreement.getId());
- baseMapper.insert(insPlyIncome);
- InsPlyIncomeLog insPlyIncomeLog = new InsPlyIncomeLog();
- insPlyIncomeLog.setIncomeId(insPlyIncome.getId());
- BeanUtils.copyProperties(insPlyIncome,insPlyIncomeLog);
- insPlyIncomeLog.setId(null);
- insPlyIncomeLog.setOperationStatus("1");
- insPlyIncomeLogService.saveLog(insPlyIncomeLog); //添加日志
- return HttpResult.ok();
- }
- private LocalDateTime LocalDatePareLocalDateTime(String signdateStr) {
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
- // 将字符串解析为LocalDate
- LocalDate signdate = LocalDate.parse(signdateStr, formatter);
- // 创建一个 LocalTime 对象表示中午12点
- LocalTime noon = LocalTime.of(12, 0);
- // 使用 LocalDate 和 LocalTime 来创建 LocalDateTime
- return LocalDateTime.of(signdate, noon);
- }
- /**
- * 删除id 已开票或者已结算都不可以进行 删除
- * 因为跟单没有关联表 也无法关联到开票表所以只能按照 条件去查询判断 保司机构 id
- * @param insPlyIncomeVo
- * @return
- */
- @Override
- @Transactional
- public HttpResult<InsPlyIncome> deleteById(InsPlyIncomeVo insPlyIncomeVo) {
- HashMap<String, Object> params = new HashMap<>();
- params.put("id",insPlyIncomeVo.getId());
- List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params);
- InsPlyIncome insPlyIncome = insPlyIncomes.get(0);
- if (StringUtils.isNotEmpty(insPlyIncome.getAgreementType()) && "1".equals(insPlyIncome.getAgreementType())) {
- if ("1".equals(insPlyIncome.getHandlingFeesStatus())) {
- throw new SystemException("已结算不可以进行删除");
- }
- } else if (StringUtils.isNotEmpty(insPlyIncome.getAgreementType()) && "2".equals(insPlyIncome.getAgreementType())) {
- if ("0".equals(insPlyIncome.getIsNotDocumentary())) {
- String taskId = insPlyIncome.getTaskId();
- if (StringUtils.isNotEmpty(taskId)) {
- throw new SystemException("已开票不能进行删除");
- }
- } else {
- // 因为跟单没有关联表 也无法关联到开票表所以只能按照 条件去进行判断
- if(StringUtils.isNotEmpty( insPlyIncome.getSettleOtherStatus()) && "1".equals( insPlyIncome.getSettleOtherStatus())){
- throw new SystemException("已经对账不能进行删除");
- }
- }
- }
- InsPlyIncomeLog insPlyIncomeLog = new InsPlyIncomeLog();
- insPlyIncomeLog.setIncomeId(insPlyIncome.getId());
- BeanUtils.copyProperties(insPlyIncome,insPlyIncomeLog);
- insPlyIncomeLog.setId(null);
- insPlyIncomeLog.setOperationStatus("3");
- insPlyIncomeLogService.saveLog(insPlyIncomeLog); //添加日志
- baseMapper.deleteById(insPlyIncomeVo.getId()); //删除 结算 然后删除结算表
- return HttpResult.ok("删除成功");
- }
- @Override
- @Transactional
- public void uodateBalance(InsPlyIncomeVo insPlyIncomeVo) {
- InsPlyIncome insPlyIncome = new InsPlyIncome();
- insPlyIncomeVo.setHandlingFeesStatus("1");
- BeanUtils.copyProperties(insPlyIncomeVo, insPlyIncome);
- insPlyIncome.setSettlementUserId(BaseController.getUser().getId());
- insPlyIncome.setSettlementTime(LocalDateTime.now());
- baseMapper.updateById(insPlyIncome);
- // 生成记录
- SettlementDocumentaryLogEntity settlementDocumentaryLogEntity = new SettlementDocumentaryLogEntity();
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getAgreementType()) && "1".equals(insPlyIncomeVo.getAgreementType())) {
- // 只有平台协议 才会跟单费一笔结算
- settlementDocumentaryLogEntity.setAmount(insPlyIncomeVo.getOtherFeevalue()); // 跟单费金额
- }
- settlementDocumentaryLogEntity.setHandingAmount(insPlyIncomeVo.getCommissionFeevalue()); // 手续费金额
- settlementDocumentaryLogEntity.setSettlementDocumentaryId(insPlyIncomeVo.getId()); // 关联id
- settlementDocumentaryLogEntity.setAmountType("1"); //手续费结算
- settlementDocumentaryLogEntity.setCreateTime(new Date());
- settlementDocumentaryLogService.save(settlementDocumentaryLogEntity);
- }
- @Override
- @Transactional
- public HttpResult<BasePageResult<InsPlyIncome>> totalQuery(InsPlyIncomeVo insPlyIncomeVo) {
- HashMap<String, Object> params = new HashMap<>();
- PageInfo<List<InsPlyIncome>> pageHelper = null;
- if (insPlyIncomeVo.getStartDate() != null) {
- params.put("startDate", insPlyIncomeVo.getStartDate().toString());
- }
- if (insPlyIncomeVo.getEndDate() != null) {
- params.put("endDate", insPlyIncomeVo.getEndDate().toString());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getYear())) {
- params.put("year", insPlyIncomeVo.getYear());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotCar())) {
- params.put("isNotCar", insPlyIncomeVo.getIsNotCar());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotDocumentary())) {
- params.put("isOther", insPlyIncomeVo.getIsNotDocumentary());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getDocumentaryFeesStatus())) {
- params.put("documentaryFeesStatus", insPlyIncomeVo.getDocumentaryFeesStatus());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getCompanyId())) {
- params.put("companyId", insPlyIncomeVo.getCompanyId());
- }
- params.put("pageNum", insPlyIncomeVo.getPageNum());
- params.put("pageSize", insPlyIncomeVo.getPageSize());
- List<InsPlyIncome> list = this.baseMapper.totalQuery(params);
- pageHelper = new PageInfo(list);
- return HttpResult.ok(new BasePageResult<>(insPlyIncomeVo.getPageNum(), insPlyIncomeVo.getPageSize(), pageHelper.getTotal(),
- pageHelper.getPages(), list));
- }
- /**
- *
- * @param insPlyIncomeVo ids ins_ply_income 这个表的ids incomeIds settlement_documentary_fees 这个表的ids
- * @return
- */
- /**
- * 跟单费结算 有分批结算的情况
- *
- * @param insPlyIncomeVo
- * @return
- */
- @Override
- @Transactional
- public HttpResult batchBalance(InsPlyIncomeVo insPlyIncomeVo) {
- // 分批结算
- SettlementDocumentaryFeesVo settlementDocumentaryFeesVo = new SettlementDocumentaryFeesVo();
- String id = insPlyIncomeVo.getId(); // 开票id
- SettlementDocumentaryFeesEntity settlementDocumentaryFeesServiceById = settlementDocumentaryFeesService.getById(id); //
- BigDecimal allAmount = settlementDocumentaryFeesServiceById.getSettlementAmount();
- HashMap<String, Object> params = new HashMap<>();
- params.put("id", insPlyIncomeVo.getId());
- params.put("handlingFeesStatus", "1");
- SettlementDocumentaryFeesEntity parentSettlementDocumentaryFeesEntity =
- settlementDocumentaryFeesService.getByParentSettlementAmount(params);
- if (ObjectUtils.isNotEmpty(parentSettlementDocumentaryFeesEntity)) { // 多次结算
- BigDecimal totalAmount = parentSettlementDocumentaryFeesEntity.getTotalAmount();
- totalAmount = totalAmount.add(insPlyIncomeVo.getSettlementAmount());
- if (allAmount.compareTo(totalAmount) < 0) {
- return HttpResult.error("结算金额超出开票金额");
- }
- } else {
- if (allAmount.compareTo(insPlyIncomeVo.getSettlementAmount()) < 0) {
- return HttpResult.error("结算金额超出开票金额");
- }
- }
- settlementDocumentaryFeesVo.setInvoiceId(insPlyIncomeVo.getInvoicId()); //开票号
- settlementDocumentaryFeesVo.setSettlementTime(insPlyIncomeVo.getSettlementTime()); //结算时间
- settlementDocumentaryFeesVo.setSettlementStatus("2"); //2为结算状态
- settlementDocumentaryFeesVo.setCompanyId(insPlyIncomeVo.getCompanyId()); // 保险公司id
- settlementDocumentaryFeesVo.setPartnerCompaniesId(insPlyIncomeVo.getPartnerCompaniesId()); //合作公司id
- settlementDocumentaryFeesVo.setUnsettledAmount(insPlyIncomeVo.getInvoicCommissionFeevalue().subtract(insPlyIncomeVo.getSettlementAmount())); //未结算金额
- settlementDocumentaryFeesVo.setIsNotCar(insPlyIncomeVo.getIsNotCar()); // 是否是非车
- settlementDocumentaryFeesVo.setInvoicingMethod(insPlyIncomeVo.getInvoicingMethod()); //开票方式
- settlementDocumentaryFeesVo.setTaxPoints(insPlyIncomeVo.getTaxPoints()); //税点
- settlementDocumentaryFeesVo.setSettlementImageId(insPlyIncomeVo.getSettlementImageId());
- if ("0".equals(insPlyIncomeVo.getInvoicingMethod())) {
- settlementDocumentaryFeesVo.setExpendAmount(insPlyIncomeVo.getSettlementAmount().multiply(BigDecimal.ONE.subtract(insPlyIncomeVo.getTaxPoints().divide(new BigDecimal(100)))));
- } else {
- settlementDocumentaryFeesVo.setExpendAmount(insPlyIncomeVo.getSettlementAmount()); //进账金额
- }
- settlementDocumentaryFeesVo.setSettlementAmount(insPlyIncomeVo.getSettlementAmount()); //进账金额
- settlementDocumentaryFeesVo.setHandlingFeesStatus(insPlyIncomeVo.getHandlingFeesStatus());
- settlementDocumentaryFeesVo.setTotalAmount(insPlyIncomeVo.getInvoicCommissionFeevalue());
- settlementDocumentaryFeesVo.setCreateTime(LocalDateTime.now());
- settlementDocumentaryFeesVo.setParentId(insPlyIncomeVo.getId());
- settlementDocumentaryFeesVo.setAgreementType("2"); //1平台 2 保险
- settlementDocumentaryFeesService.inertSettle(settlementDocumentaryFeesVo);
- return HttpResult.ok();
- }
- @Override
- @Transactional
- public HttpResult<Object> batchSumBalance(InsPlyIncomeVo insPlyIncomeVo) {
- List<InsPlyIncomeVo> multipleSelection = insPlyIncomeVo.getMultipleSelection();
- HashMap<String, Object> params = new HashMap<>();
- Date date = new Date();
- BigDecimal settleMentAmount = BigDecimal.ZERO;
- BigDecimal settleNotMentAmount = BigDecimal.ZERO;
- for (InsPlyIncomeVo item : multipleSelection){
- SettlementDocumentaryFeesEntity settlementDocumentaryFeesVo = new SettlementDocumentaryFeesEntity();
- if(item.getInvoicCommissionFeevalue() ==null || item .getInvoicCommissionFeevalue().compareTo(BigDecimal.ZERO) <=0){
- throw new SystemException("请输入正确金额");
- }
- String id = item.getId();
- SettlementDocumentaryFeesEntity settlementDocumentaryFeesEntity = settlementDocumentaryFeesService.getBaseMapper().selectById(id); // 开票
- BigDecimal invoicedNotSettledAmount = settlementDocumentaryFeesEntity.getInvoicedNotSettledAmount();//未结算金额
- if(item.getInvoicCommissionFeevalue().compareTo(invoicedNotSettledAmount) >0){
- throw new SystemException("结算金额大于未结算金额");
- }
- if(item.getInvoicCommissionFeevalue().compareTo(BigDecimal.ZERO) >0){
- settlementDocumentaryFeesVo.setInvoiceId(settlementDocumentaryFeesEntity.getInvoicId()); //开票号
- settlementDocumentaryFeesVo.setSettlementTime(insPlyIncomeVo.getSettlementTime()); //结算时间
- settlementDocumentaryFeesVo.setSettlementStatus("2"); //2为结算状态
- settlementDocumentaryFeesVo.setCompanyId(settlementDocumentaryFeesEntity.getCompanyId()); // 保险公司id
- settlementDocumentaryFeesVo.setPartnerCompaniesId(settlementDocumentaryFeesEntity.getPartnerCompaniesId()); //合作公司id
- // settlementDocumentaryFeesVo.setUnsettledAmount(insPlyIncomeVo.getInvoicCommissionFeevalue().subtract(insPlyIncomeVo.getSettlementAmount())); //未结算金额
- settlementDocumentaryFeesVo.setIsNotCar(settlementDocumentaryFeesEntity.getIsNotCar()); // 是否是非车
- settlementDocumentaryFeesVo.setInvoicingMethod(settlementDocumentaryFeesEntity.getInvoicingMethod()); //开票方式
- settlementDocumentaryFeesVo.setTaxPoints(settlementDocumentaryFeesEntity.getTaxPoints()); //税点
- settlementDocumentaryFeesVo.setSettlementImageId(insPlyIncomeVo.getSettlementImageId());
- if ("0".equals(insPlyIncomeVo.getInvoicingMethod())) {
- settlementDocumentaryFeesVo.setExpendAmount(item.getInvoicCommissionFeevalue().multiply(BigDecimal.ONE.subtract(insPlyIncomeVo.getTaxPoints().divide(new BigDecimal(100)))));
- } else {
- settlementDocumentaryFeesVo.setExpendAmount(item.getInvoicCommissionFeevalue()); //进账金额
- }
- settlementDocumentaryFeesVo.setSettlementAmount(item.getInvoicCommissionFeevalue()); //进账金额
- settlementDocumentaryFeesVo.setHandlingFeesStatus(settlementDocumentaryFeesEntity.getHandlingFeesStatus());
- settlementDocumentaryFeesVo.setTotalAmount(settlementDocumentaryFeesEntity.getSettlementAmount());
- settlementDocumentaryFeesVo.setCreateTime(LocalDateTime.now());
- settlementDocumentaryFeesVo.setSettlementTime(LocalDate.now());
- settlementDocumentaryFeesVo.setParentId(insPlyIncomeVo.getId());
- settlementDocumentaryFeesVo.setAgreementType("2"); //1平台 2 保险
- settlementDocumentaryFeesVo.setInvoicedSettledAmount(item.getInvoicCommissionFeevalue());
- settlementDocumentaryFeesVo.setInvoicedNotSettledAmount(BigDecimal.ZERO);
- // 生成跟单费结算记录
- SettlementDocumentaryLogEntity settlementDocumentaryLogEntity = new SettlementDocumentaryLogEntity();
- settlementDocumentaryLogEntity.setAmount(item.getInvoicCommissionFeevalue()); // 结算金额
- settlementDocumentaryLogEntity.setSettlementDocumentaryId(settlementDocumentaryFeesEntity.getId()); // 关联id
- settlementDocumentaryLogEntity.setAmountType("2"); //跟单费结算
- settlementDocumentaryLogEntity.setCreateTime(date);
- settlementDocumentaryFeesVo.setSettlementSumId(insPlyIncomeVo.getSettlementSumId());
- settlementDocumentaryFeesService.getBaseMapper().insert(settlementDocumentaryFeesVo);
- settlementDocumentaryLogService.save(settlementDocumentaryLogEntity);
- //修改开票金额
- BigDecimal add = settlementDocumentaryFeesEntity.getInvoicedSettledAmount().add(item.getInvoicCommissionFeevalue());
- settlementDocumentaryFeesEntity.setInvoicedSettledAmount(add);
- BigDecimal subtract = settlementDocumentaryFeesEntity.getSettlementAmount().subtract(add);
- settlementDocumentaryFeesEntity.setInvoicedNotSettledAmount(subtract);
- if (subtract.compareTo(BigDecimal.ZERO) == 0) {
- settlementDocumentaryFeesEntity.setCompletionStatus("2");
- } else if (subtract.compareTo(BigDecimal.ZERO) != 0) {
- settlementDocumentaryFeesEntity.setCompletionStatus("1");
- }
- settlementDocumentaryFeesService.updateById(settlementDocumentaryFeesEntity);
- settleMentAmount = settleMentAmount.add(settlementDocumentaryFeesEntity.getInvoicedSettledAmount());
- settleNotMentAmount = settleNotMentAmount.add(settlementDocumentaryFeesEntity.getInvoicedNotSettledAmount());
- }
- // 更新金额
- SettlementDocumentaryFeesSumEntity settlementDocumentaryFeesSumEntity = settlementDocumentaryFeesSumService.getById(insPlyIncomeVo.getSettlementSumId());
- settlementDocumentaryFeesSumEntity.setInvoicedSettledAmount(settleMentAmount);
- settlementDocumentaryFeesSumEntity.setInvoicedNotSettledAmount(settleNotMentAmount);
- if (settleNotMentAmount.compareTo(BigDecimal.ZERO) == 0) {
- settlementDocumentaryFeesSumEntity.setCompletionStatus("2");
- } else if (settleNotMentAmount.compareTo(BigDecimal.ZERO) != 0) {
- settlementDocumentaryFeesSumEntity.setCompletionStatus("1");
- }
- settlementDocumentaryFeesSumService.updateById(settlementDocumentaryFeesSumEntity);
- }
- return HttpResult.ok();
- }
- /**
- * @param insPlyIncomeVo
- * @return
- */
- @Override
- public List<InsPlyIncome> totalBxAmount(InsPlyIncomeVo insPlyIncomeVo) {
- HashMap<String, Object> params = new HashMap<>();
- params = this.saveParams(insPlyIncomeVo, params);
- params.remove("handlingFeesStatus");
- List<InsPlyIncome> resultList = baseMapper.totalBxAmountNew(params);
- return resultList.stream()
- .sorted(Comparator.comparing(InsPlyIncome::getUnSettledAmount, Comparator.reverseOrder()))
- .collect(Collectors.toList());
- }
- /**
- * @param idList 要开票的数据集合
- * @param resultList 总返回数据
- */
- private void splicingIds(List<InsPlyIncome> idList, List<InsPlyIncome> resultList) {
- // 使用Map来存储agreementId到其id列表的映射
- Map<String, List<String>> idMap = new HashMap<>();
- for (InsPlyIncome idItem : idList) {
- String partnerCompaniesId = idItem.getPartnerCompaniesId();
- idMap.computeIfAbsent(partnerCompaniesId, k -> new ArrayList<>()).add(idItem.getId());
- }
- for (InsPlyIncome resultItem : resultList) {
- List<String> ids = idMap.getOrDefault(resultItem.getPartnerCompaniesId(), Collections.emptyList());
- String idsString = String.join(",", ids);
- resultItem.setIds(idsString);
- }
- }
- /**
- * @param insPlyIncomeVo
- * @return 保险手续费改成多次结算
- */
- @Override
- @Transactional
- public HttpResult<Object> batchInvoicing(InsPlyIncomeVo insPlyIncomeVo) {
- ImportResult importResult = importAsyncService.getById(insPlyIncomeVo.getSelectIds().get(0)); // 查询 任务
- List<String> byTaskId = incomeTaskRelationshipService.getByTaskId(importResult.getId());
- HashMap<String, Object> params = new HashMap<>();
- if (StringUtils.isNotEmpty(importResult.getId())) {
- params.put("companyId", importResult.getCompanyId());
- params.put("partnerCompaniesId", importResult.getPartnerCompaniesId());
- params.put("isOther", "0");
- if (StringUtils.isNotEmpty(importResult.getHandStatus())) {
- if ("0".equals(importResult.getHandStatus())) {
- params.put("isNotCar", "0");
- } else if ("1".equals(importResult.getHandStatus())) {
- params.put("isNotCar", "1");
- }
- }
- if (!CollectionUtils.isEmpty(byTaskId)) {
- params.put("incomeIds", byTaskId);
- }
- List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params);
- if (!CollectionUtils.isEmpty(insPlyIncomes)) {
- if (insPlyIncomeVo != null) { // 确保insPlyIncomeVo不是null
- for (InsPlyIncome item : insPlyIncomes) {
- item.setInvoicTime(LocalDate.now());
- item.setInvoicId(insPlyIncomeVo.getInvoicId());
- item.setHandlingFeesStatus("2");
- if (StringUtils.isNotEmpty(item.getTaskId())) {
- return HttpResult.error("该单据已经开票 ");
- } else {
- item.setTaskId(importResult.getId());
- item.setSettlementTime(LocalDateTime.now());
- baseMapper.updateById(item);
- }
- }
- }
- }
- }
- insPlyIncomeVo.setNoInvoicCommissionFeevalue(importResult.getTotalAmount());
- insPlyIncomeVo.setOtherFeevalue(importResult.getTotalAmount());
- insPlyIncomeVo.setHandlingFeesStatus("0"); // 0手续费 1 跟单费
- insPlyIncomeVo.setIsNotCar(insPlyIncomeVo.getIsNotCar());
- insPlyIncomeVo.setAgreementId(importResult.getAgreementId());
- insPlyIncomeVo.setAgreementType(insPlyIncomeVo.getAgreementType());
- insPlyIncomeVo.setPartnerCompaniesId(importResult.getPartnerCompaniesId());
- insPlyIncomeVo.setSettlementAmount(importResult.getTotalAmount());
- insPlyIncomeVo.setContractId(insPlyIncomeVo.getInvoicId());
- insPlyIncomeVo.setCompanyId(importResult.getCompanyId());
- insPlyIncomeVo.setTaskId(importResult.getId());
- this.batchInvoic(insPlyIncomeVo);
- return HttpResult.ok();
- }
- @Override
- public HttpResult<InsPlyIncome> queryInvoicing(InsPlyIncomeVo insPlyIncomeVo) {
- HashMap<String, Object> params = new HashMap<>();
- params = this.saveParams(insPlyIncomeVo, params);
- InsPlyIncome result = baseMapper.queryInvoicing(params); //总金额
- params.put("handlingFeesStatus", "0");
- InsPlyIncome noResult = baseMapper.queryInvoicing(params); //未结算金额
- result.setReadyCommissionFeevalue(noResult.getCommissionFeevalue());
- return HttpResult.ok(result);
- }
- @Override
- @Transactional
- public HttpResult<Object> batchBxBalance(InsPlyIncomeVo insPlyIncomeVo) {
- if( insPlyIncomeVo.getSettlementAmount() ==null || insPlyIncomeVo.getSettlementAmount().compareTo(BigDecimal.ZERO) <=0){
- throw new SystemException("金额未填写");
- }
- // 表内总金额
- SettlementDocumentaryFeesEntity byIdSettlementDocumentaryFeesEntity =
- settlementDocumentaryFeesService.getById(insPlyIncomeVo.getId());
- BigDecimal invoicAmount = byIdSettlementDocumentaryFeesEntity.getTotalAmount();
- String taskId = byIdSettlementDocumentaryFeesEntity.getTaskId();
- List<String> byTaskId = incomeTaskRelationshipService.getByTaskId(taskId);
- HashMap<String, Object> params = new HashMap<>();
- params.put("id", insPlyIncomeVo.getId());
- params.put("handlingFeesStatus", "0");
- SettlementDocumentaryFeesEntity parentSettlementDocumentaryFeesEntity =
- settlementDocumentaryFeesService.getByParentSettlementAmount(params);
- if (ObjectUtils.isNotEmpty(parentSettlementDocumentaryFeesEntity)) { // 多次结算
- BigDecimal totalAmount = parentSettlementDocumentaryFeesEntity.getTotalAmount();
- totalAmount = totalAmount.add(insPlyIncomeVo.getSettlementAmount());
- if (invoicAmount.compareTo(totalAmount) < 0) {
- return HttpResult.error("结算金额大于开票金额");
- }
- if(totalAmount.compareTo(invoicAmount) ==0){
- HashMap<String, Object> incomeParams = new HashMap<>();
- incomeParams.put("incomeIds", byTaskId);
- List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(incomeParams);
- for (InsPlyIncome item : insPlyIncomes) {
- item.setHandlingFeesStatus("1");
- item.setSettlementUserId(BaseController.getUser().getId());
- baseMapper.updateById(item);
- }
- }
- } else {
- if (invoicAmount.compareTo(insPlyIncomeVo.getSettlementAmount()) < 0) {
- return HttpResult.error("结算金额大于开票金额");
- } else if (invoicAmount.compareTo(insPlyIncomeVo.getSettlementAmount()) == 0) {
- HashMap<String, Object> incomeParams = new HashMap<>();
- incomeParams.put("incomeIds", byTaskId);
- List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(incomeParams);
- for (InsPlyIncome item : insPlyIncomes) {
- item.setHandlingFeesStatus("1");
- item.setSettlementUserId(BaseController.getUser().getId());
- baseMapper.updateById(item);
- }
- }
- }
- SettlementDocumentaryFeesVo settlementDocumentaryFeesVo = new SettlementDocumentaryFeesVo();
- settlementDocumentaryFeesVo.setInvoiceId(insPlyIncomeVo.getInvoicId()); //开票号
- settlementDocumentaryFeesVo.setSettlementTime(insPlyIncomeVo.getSettlementTime()); //结算时间
- settlementDocumentaryFeesVo.setSettlementStatus("2"); //2为结算状态
- settlementDocumentaryFeesVo.setCompanyId(insPlyIncomeVo.getCompanyId()); // 保险公司id
- settlementDocumentaryFeesVo.setPartnerCompaniesId(insPlyIncomeVo.getPartnerCompaniesId()); //合作公司id
- settlementDocumentaryFeesVo.setIsNotCar(insPlyIncomeVo.getIsNotCar()); // 是否是非车
- settlementDocumentaryFeesVo.setInvoicingMethod(insPlyIncomeVo.getInvoicingMethod()); //开票方式
- settlementDocumentaryFeesVo.setTaxPoints(insPlyIncomeVo.getTaxPoints()); //税点
- settlementDocumentaryFeesVo.setExpendAmount(insPlyIncomeVo.getInvoicCommissionFeevalue().multiply(BigDecimal.ONE.subtract(insPlyIncomeVo.getTaxPoints().divide(new BigDecimal(100)))));
- settlementDocumentaryFeesVo.setTaskId(insPlyIncomeVo.getTaskId());
- settlementDocumentaryFeesVo.setSettlementAmount(insPlyIncomeVo.getSettlementAmount()); //进账金额
- settlementDocumentaryFeesVo.setTotalAmount(insPlyIncomeVo.getInvoicCommissionFeevalue());
- settlementDocumentaryFeesVo.setHandlingFeesStatus("0");
- settlementDocumentaryFeesVo.setParentId(insPlyIncomeVo.getId());
- settlementDocumentaryFeesVo.setPartnerCompaniesId(insPlyIncomeVo.getPartnerCompaniesId());
- settlementDocumentaryFeesVo.setSettlementImageId(insPlyIncomeVo.getSettlementImageId());
- settlementDocumentaryFeesVo.setCreateTime(LocalDateTime.now());
- settlementDocumentaryFeesVo.setAgreementType("2"); //1平台 2 保险
- BigDecimal add = byIdSettlementDocumentaryFeesEntity.getInvoicedSettledAmount().add(insPlyIncomeVo.getSettlementAmount());
- byIdSettlementDocumentaryFeesEntity.setInvoicedSettledAmount(add);
- BigDecimal subtract = byIdSettlementDocumentaryFeesEntity.getTotalAmount().subtract(add);
- byIdSettlementDocumentaryFeesEntity.setInvoicedNotSettledAmount(subtract);
- if (subtract.compareTo(BigDecimal.ZERO) == 0) {
- byIdSettlementDocumentaryFeesEntity.setCompletionStatus("2");
- } else if (subtract.compareTo(BigDecimal.ZERO) != 0) {
- byIdSettlementDocumentaryFeesEntity.setCompletionStatus("1");
- }
- settlementDocumentaryFeesService.updateById(byIdSettlementDocumentaryFeesEntity);
- settlementDocumentaryFeesService.inertSettle(settlementDocumentaryFeesVo);
- List<InsuranceHandlingSettlementMonthEntity> insuranceHandlingList = insPlyIncomeVo.getInsuranceHandlingList();
- ArrayList<InsuranceHandlingSettlementMonthEntity> insuranceHandlingListNew = new ArrayList<>();
- // 判断是否是第一次结算
- InsuranceHandlingSettlementMonthVo insuranceHandlingSettlementMonthVo = new InsuranceHandlingSettlementMonthVo();
- insuranceHandlingSettlementMonthVo.setPartnerCompaniesId(insPlyIncomeVo.getPartnerCompaniesId());
- insuranceHandlingSettlementMonthVo.setTaskId(insPlyIncomeVo.getTaskId());
- List<InsuranceHandlingSettlementMonthDto> insuranceHandlingSettlementMonthDtos = insuranceHandlingSettlementMonthService.getQueryLists(insuranceHandlingSettlementMonthVo);
- // 分批结算
- BigDecimal allsettlementAmount = BigDecimal.ZERO;
- for(InsuranceHandlingSettlementMonthEntity item : insuranceHandlingList){
- String incomeSigningTime = item.getIncomeSigningTime();
- DateTimeFormatter yearMonthFormatter = DateTimeFormatter.ofPattern("yyyy-MM");
- // 尝试解析为LocalDate(这里实际上解析为YearMonth,但使用LocalDate的parse方法,因为它会接受只有年和月的TemporalQuery)
- // 注意:这里直接解析为LocalDate可能会引发异常,因为DateTimeFormatter应该与要解析的Temporal类型精确匹配。
- // 但由于Java的灵活性,以及默认行为(假设日为1),这通常可以工作。
- LocalDate date = YearMonth.parse(incomeSigningTime, yearMonthFormatter).atDay(1);
- // 将LocalDate转换为LocalDateTime,时间为00:00:00
- LocalDateTime localDateTime = date.atStartOfDay();
- item.setIsNotCar(insPlyIncomeVo.getIsNotCar());
- BigDecimal totalAmount = item.getRemainingAmount(); //开票未结算
- BigDecimal settlementAmount = item.getSettlementAmount(); //结算金额
- InsuranceHandlingSettlementMonthEntity byId = insuranceHandlingSettlementMonthService.getById(item.getId());
- if(ObjectUtils.isNotEmpty(byId)){
- allsettlementAmount = this.calculateTotal(byId.getSettlementAmount(),item.getSettlementAmount(),null);
- item.setSettlementAmount(allsettlementAmount);
- }else {
- item.setSettlementAmount(item.getSettlementAmount());
- }
- BigDecimal subtract1 = totalAmount.subtract(settlementAmount);
- item.setRemainingAmount(subtract1);
- item.setCreateTime(LocalDateTime.now());
- item.setPartnerCompaniesId(insPlyIncomeVo.getPartnerCompaniesId());
- item.setSigningTime(localDateTime);
- item.setSettlementDocumentaryFeesId(byIdSettlementDocumentaryFeesEntity.getId());
- insuranceHandlingListNew.add(item);
- }
- if(insuranceHandlingSettlementMonthDtos.size()>0){
- insuranceHandlingSettlementMonthService.updateBatchById(insuranceHandlingListNew);
- }else{
- insuranceHandlingSettlementMonthService.saveBatch(insuranceHandlingListNew);
- }
- return HttpResult.ok();
- }
- @Override
- public HttpResult<InsPlyIncome> querySettInvoicing(InsPlyIncomeVo insPlyIncomeVo) {
- HashMap<String, Object> params = new HashMap<>();
- params = this.saveParams(insPlyIncomeVo, params);
- InsPlyIncome insPlyIncome = baseMapper.queryInvoicing(params); //已经开票
- return HttpResult.ok(insPlyIncome);
- }
- /**
- * @param insPlyIncomeVo
- * @return
- */
- @Override
- public HttpResult<List<InsPlyIncome>> allOtherAmount(InsPlyIncomeVo insPlyIncomeVo) {
- HashMap<String, Object> params = new HashMap<>();
- params = this.saveParams(insPlyIncomeVo, params);
- List<InsPlyIncome> resultList = baseMapper.totalBxAmount(params);
- //总跟单费
- for (InsPlyIncome item : resultList) {
- BigDecimal otherFeevalue = BigDecimal.ZERO; //总跟单金额
- BigDecimal invoicCommissionFeevalue = BigDecimal.ZERO; //已开票跟单费
- BigDecimal readyCommissionFeevalue = BigDecimal.ZERO; // 已开票已结算 跟单费
- BigDecimal noInvoicCommissionFeevalue = BigDecimal.ZERO; //未开票跟单金额
- BigDecimal unSettledAmount = BigDecimal.ZERO; //未结算跟单金额
- BigDecimal expendAmount = BigDecimal.ZERO; //实收金额
- BigDecimal taxesFees = BigDecimal.ZERO; //税费
- BigDecimal taxPoints = BigDecimal.ZERO; //税点
- params.put("partnerCompaniesId", item.getPartnerCompaniesId());
- params.remove("handlingFeesStatus");
- List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params); // 总跟单费
- for (InsPlyIncome all : insPlyIncomes) {
- otherFeevalue = otherFeevalue.add(all.getOtherFeevalue());
- }
- //已开票金额 = 开票未结算+ 开票已结算
- params.put("handlingFeesStatus", "1"); // 开票
- params.put("settlementStatus", "1"); // 开票
- List<SettlementDocumentaryFeesEntity> invoicInsPlyIncomes = settlementDocumentaryFeesService.queryNew(params); //金额总数
- for (SettlementDocumentaryFeesEntity invoicInsPlyIncome : invoicInsPlyIncomes) {
- BigDecimal invoicIcommissionFeevalue = invoicInsPlyIncome.getSettlementAmount();// 已经开票金额
- invoicCommissionFeevalue = invoicCommissionFeevalue.add(invoicIcommissionFeevalue); //开票金额
- }
- params.put("settlementStatus", "2"); // 结算
- List<SettlementDocumentaryFeesEntity> settleInsPlyIncomes = settlementDocumentaryFeesService.queryNew(params); //金额总数
- for (SettlementDocumentaryFeesEntity settleInsPlyIncome : settleInsPlyIncomes) {
- BigDecimal settleIcommissionFeevalue = settleInsPlyIncome.getSettlementAmount();// 已结算金额
- readyCommissionFeevalue = readyCommissionFeevalue.add(settleIcommissionFeevalue); //已结算总
- BigDecimal divide = new BigDecimal(100).subtract(settleInsPlyIncome.getTaxPoints()).divide(new BigDecimal(100));
- expendAmount = expendAmount.add(settleInsPlyIncome.getSettlementAmount().multiply(divide));
- }
- params.put("settlementStatus", 0); //未开票金额
- List<SettlementDocumentaryFeesEntity> noInvoicInsPlyIncomes = settlementDocumentaryFeesService.queryNew(params); //金额总数
- for (SettlementDocumentaryFeesEntity noInvoicInsPlyIncome : noInvoicInsPlyIncomes) {
- BigDecimal noInvoicIcommissionFeevalue = noInvoicInsPlyIncome.getSettlementAmount();// 未开票金额
- noInvoicCommissionFeevalue = noInvoicCommissionFeevalue.add(noInvoicIcommissionFeevalue); //未开票总金额
- }
- noInvoicCommissionFeevalue = otherFeevalue.subtract(invoicCommissionFeevalue);// 未开票
- unSettledAmount = otherFeevalue.subtract(readyCommissionFeevalue); //未结算
- //已开票金额
- item.setOtherFeevalue(otherFeevalue); //总手续费
- item.setAllInvoicCommissionFeevalue(invoicCommissionFeevalue); //总开票金额
- // 开票未结算 = 开票金额 - 已开票已结算
- invoicCommissionFeevalue = invoicCommissionFeevalue.subtract(readyCommissionFeevalue);
- item.setInvoicCommissionFeevalue(invoicCommissionFeevalue); //开票未结算
- item.setReadyCommissionFeevalue(readyCommissionFeevalue); //已开票已结算
- item.setNoInvoicCommissionFeevalue(noInvoicCommissionFeevalue); //未开票金额
- item.setUnSettledAmount(unSettledAmount); // 未结算金额
- // 实收金额 = 结算金额 *1-税点
- taxesFees = readyCommissionFeevalue.subtract(expendAmount);
- item.setExpendAmount(expendAmount);
- item.setTaxesFees(taxesFees);
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getStatus())) {
- if ("0".equals(insPlyIncomeVo.getStatus())) {
- return HttpResult.ok(resultList.stream().filter(insPlyIncome -> insPlyIncome.getAllInvoicCommissionFeevalue().compareTo(insPlyIncome.getReadyCommissionFeevalue()) > 0).sorted(Comparator.comparing(InsPlyIncome::getUnSettledAmount, Comparator.reverseOrder())).collect(Collectors.toList()));
- }else if ("1".equals(insPlyIncomeVo.getStatus())){
- return HttpResult.ok(resultList.stream().filter(insPlyIncome -> insPlyIncome.getAllInvoicCommissionFeevalue().compareTo(insPlyIncome.getReadyCommissionFeevalue()) == 0).sorted(Comparator.comparing(InsPlyIncome::getUnSettledAmount, Comparator.reverseOrder())).collect(Collectors.toList())) ;
- }
- }
- return HttpResult.ok(resultList);
- }
- @Override
- @Transactional
- public HttpResult<Object> batchInvoic(InsPlyIncomeVo insPlyIncomeVo) {
- SettlementDocumentaryFeesVo settlementDocumentaryFeesVo = new SettlementDocumentaryFeesVo(); // 生成跟单费结算表
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getYear())) {
- settlementDocumentaryFeesVo.setTimeFrame(insPlyIncomeVo.getYear());//年度
- }
- if (!CollectionUtils.isEmpty(insPlyIncomeVo.getMultipleSelection())) {
- InsPlyIncomeVo insPlyIncomeVo1 = insPlyIncomeVo.getMultipleSelection().get(0);
- insPlyIncomeVo.setSettlementAmount(insPlyIncomeVo1.getSettlementAmount());
- insPlyIncomeVo.setOtherFeevalue(insPlyIncomeVo1.getAllTotalOtherFeevalue());
- YearMonth yearMonth = YearMonth.parse(insPlyIncomeVo1.getMonthYear());
- LocalDate signingTime = yearMonth.atDay(1);
- settlementDocumentaryFeesVo.setSigningTime(signingTime);
- }
- if (insPlyIncomeVo.getOtherFeevalue().compareTo(BigDecimal.ZERO) == 0) {
- throw new SystemException("总金额为0不允许开票");
- }
- if (insPlyIncomeVo.getNoInvoicCommissionFeevalue().compareTo(BigDecimal.ZERO) == 0) {
- throw new SystemException("未开票金额为0不允许开票");
- }
- if (insPlyIncomeVo.getSettlementAmount() == null || insPlyIncomeVo.getSettlementAmount().compareTo(BigDecimal.ZERO) <= 0) {
- throw new SystemException("开票金额错误不允许开票");
- }
- if (insPlyIncomeVo.getNoInvoicCommissionFeevalue().compareTo(insPlyIncomeVo.getSettlementAmount()) < 0) {
- throw new SystemException("开票金额必须小于未开票金额 不允许开票");
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getYear())) {
- settlementDocumentaryFeesVo.setYear(insPlyIncomeVo.getYear());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getMonth())) {
- settlementDocumentaryFeesVo.setMonth(insPlyIncomeVo.getMonth());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getDay())) {
- settlementDocumentaryFeesVo.setDay(insPlyIncomeVo.getDay());
- }
- settlementDocumentaryFeesVo.setCompanyId(insPlyIncomeVo.getCompanyId());// 保险公司id
- settlementDocumentaryFeesVo.setPartnerCompaniesId(insPlyIncomeVo.getPartnerCompaniesId()); //合作公司id
- settlementDocumentaryFeesVo.setAgreementId(insPlyIncomeVo.getAgreementId());
- settlementDocumentaryFeesVo.setTotalAmount(insPlyIncomeVo.getOtherFeevalue()); //其他费用金额
- settlementDocumentaryFeesVo.setUnsettledAmount(insPlyIncomeVo.getNoInvoicCommissionFeevalue().subtract(insPlyIncomeVo.getSettlementAmount())); //未结算
- settlementDocumentaryFeesVo.setSettlementAmount(insPlyIncomeVo.getSettlementAmount());//已经开票
- settlementDocumentaryFeesVo.setCreateTime(LocalDateTime.now());
- settlementDocumentaryFeesVo.setSettlementStatus("1");
- settlementDocumentaryFeesVo.setIsNotCar(insPlyIncomeVo.getIsNotCar());
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getContractId())) {
- settlementDocumentaryFeesVo.setInvoiceId(insPlyIncomeVo.getContractId()); //开票号
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getTaskId())) {
- settlementDocumentaryFeesVo.setTaskId(insPlyIncomeVo.getTaskId());
- }
- settlementDocumentaryFeesVo.setAgreementType("2");
- settlementDocumentaryFeesVo.setHandlingFeesStatus(insPlyIncomeVo.getHandlingFeesStatus());
- settlementDocumentaryFeesVo.setCompletionStatus("0");
- settlementDocumentaryFeesVo.setInvoicedSettledAmount(BigDecimal.ZERO);
- settlementDocumentaryFeesVo.setInvoicedNotSettledAmount(insPlyIncomeVo.getSettlementAmount());
- settlementDocumentaryFeesVo.setInvoicingMethod(insPlyIncomeVo.getInvoicingMethod()); //开票方式
- settlementDocumentaryFeesVo.setTaxPoints(insPlyIncomeVo.getTaxPoints()); //税点
- settlementDocumentaryFeesVo.setIds(insPlyIncomeVo.getIds());
- // 税点支出
- if ("0".equals(insPlyIncomeVo.getInvoicingMethod()) && BigDecimalUtils.nullToZero(insPlyIncomeVo.getTaxPoints()) != null && insPlyIncomeVo.getTaxPoints().compareTo(BigDecimal.ZERO) != 0 && BigDecimalUtils.nullToZero(insPlyIncomeVo.getSettlementAmount()) != null) {
- BigDecimal settlementAmount = insPlyIncomeVo.getSettlementAmount();
- settlementDocumentaryFeesVo.setExpendAmount(settlementAmount.multiply(BigDecimal.ONE.subtract(insPlyIncomeVo.getTaxPoints().divide(new BigDecimal(100)))));
- } else {
- settlementDocumentaryFeesVo.setExpendAmount(insPlyIncomeVo.getSettlementAmount());
- }
- // 跟单生成批次表
- SettlementDocumentaryFeesSumEntity settlementDocumentaryFeesSumEntity = this.saveSumSettlement(insPlyIncomeVo);
- if(ObjectUtils.isNotEmpty(settlementDocumentaryFeesSumEntity)){
- settlementDocumentaryFeesVo.setSettlementSumId(settlementDocumentaryFeesSumEntity.getId());
- }
- return settlementDocumentaryFeesService.inertSettle(settlementDocumentaryFeesVo);
- }
- private SettlementDocumentaryFeesSumEntity saveSumSettlement(InsPlyIncomeVo insPlyIncomeVo) {
- String handlingFeesStatus = insPlyIncomeVo.getHandlingFeesStatus();
- SettlementDocumentaryFeesSumEntity settlementDocumentaryFeesSumEntity = new SettlementDocumentaryFeesSumEntity();
- BigDecimal totalAmount = BigDecimal.ZERO;
- if("1".equals(handlingFeesStatus)){
- List<InsPlyIncomeVo> nowInsPlyIncomeVo = insPlyIncomeVo.getMultipleSelection();
- for (InsPlyIncomeVo item: nowInsPlyIncomeVo ){
- totalAmount = totalAmount.add(item.getSettlementAmount()) ;
- }
- settlementDocumentaryFeesSumEntity.setPartnerCompaniesId(insPlyIncomeVo.getPartnerCompaniesId());
- settlementDocumentaryFeesSumEntity.setCompanyId(insPlyIncomeVo.getCompanyId());
- settlementDocumentaryFeesSumEntity.setCreateTime(new Date());
- settlementDocumentaryFeesSumEntity.setInvoicId(insPlyIncomeVo.getContractId());
- settlementDocumentaryFeesSumEntity.setInvoicingMethod(insPlyIncomeVo.getInvoicingMethod());
- settlementDocumentaryFeesSumEntity.setIsNotCar(insPlyIncomeVo.getIsNotCar());
- settlementDocumentaryFeesSumEntity.setSettlementStatus("1");
- settlementDocumentaryFeesSumEntity.setUserId(BaseController.getUser().getId());
- settlementDocumentaryFeesSumEntity.setInvoicedSettledAmount(BigDecimal.ZERO);
- settlementDocumentaryFeesSumEntity.setCompletionStatus("0");
- settlementDocumentaryFeesSumEntity.setTotalAmount(totalAmount);// 开票总额
- settlementDocumentaryFeesSumEntity.setInvoicedNotSettledAmount(totalAmount);
- settlementDocumentaryFeesSumService.getBaseMapper().insert(settlementDocumentaryFeesSumEntity);
- return settlementDocumentaryFeesSumEntity;
- }
- return settlementDocumentaryFeesSumEntity;
- }
- @Override
- public HttpResult pinHandlingexcel(InsPlyIncomeVo insPlyIncomeVo, HttpServletRequest request, HttpServletResponse response) {
- HashMap<String, Object> params = new HashMap<>();
- params = this.saveParams(insPlyIncomeVo, params);
- List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params);
- ExportParams exportParams = new ExportParams("平台手续费", null, ExcelType.HSSF);
- exportParams.setStyle(ExcelStyleUtil.class);
- List<SettlementFeesExcel> resultList = new ArrayList<>();
- for (InsPlyIncome item : insPlyIncomes) {
- SettlementFeesExcel bxSettlementFeesExcel = new SettlementFeesExcel();
- BeanUtils.copyProperties(item, bxSettlementFeesExcel);
- if ("1".equals(item.getHandlingFeesStatus())) {
- bxSettlementFeesExcel.setHandlingFeesStatus("已结算");
- } else {
- bxSettlementFeesExcel.setHandlingFeesStatus("未结算");
- }
- resultList.add(bxSettlementFeesExcel);
- }
- String uploadPath = this.uploadPath + "/excel/";
- Path path = Paths.get(uploadPath);
- if (!Files.exists(path)) {
- try {
- Files.createDirectories(path);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- String fileName = EasyExcelUtils.downExcel(uploadPath, "平台手续费导出", SettlementFeesExcel.class, resultList);
- return HttpResult.ok("", uploadUrl + "excel/" + fileName);
- }
- @Override
- public HttpResult bxHandlingexcel(InsPlyIncomeVo insPlyIncomeVo, HttpServletRequest request, HttpServletResponse response) {
- HashMap<String, Object> params = new HashMap<>();
- params = this.saveParams(insPlyIncomeVo, params);
- List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params);
- String filePathName = "";
- List<BxSettlementFeesNorExcel> resultNoList = new ArrayList<>();
- List<BxSettlementFeesExcel> resultList = new ArrayList<>();
- //判断是否是非车 1 是非车
- if ("1".equals(insPlyIncomeVo.getIsNotCar())) {
- filePathName = "非车手续费导出";
- ExportParams exportParams = new ExportParams("非车手续费", null, ExcelType.HSSF);
- exportParams.setStyle(ExcelStyleUtil.class);
- for (InsPlyIncome item : insPlyIncomes) {
- BxSettlementFeesNorExcel bxSettlementFeesNorExcel = new BxSettlementFeesNorExcel();
- LocalDateTime signDate = item.getSignDate();
- BeanUtils.copyProperties(item, bxSettlementFeesNorExcel);
- bxSettlementFeesNorExcel.setSigndate(signDate);
- if (item.getHandlingFeesStatus().equals("0")) {
- bxSettlementFeesNorExcel.setHandlingFeesStatus("未开票");
- }
- if (item.getHandlingFeesStatus().equals("1")) {
- bxSettlementFeesNorExcel.setHandlingFeesStatus("已开票");
- }
- if (item.getHandlingFeesStatus().equals("2")) {
- bxSettlementFeesNorExcel.setHandlingFeesStatus("已开票未结算");
- }
- resultNoList.add(bxSettlementFeesNorExcel);
- }
- } else {
- filePathName = "车险手续费导出";
- ExportParams exportParams = new ExportParams("车险手续费", null, ExcelType.HSSF);
- exportParams.setStyle(ExcelStyleUtil.class);
- for (InsPlyIncome item : insPlyIncomes) {
- BxSettlementFeesExcel bxSettlementFeesExcel = new BxSettlementFeesExcel();
- LocalDateTime signDate = item.getSignDate();
- BeanUtils.copyProperties(item, bxSettlementFeesExcel);
- bxSettlementFeesExcel.setSigndate(signDate);
- if (item.getHandlingFeesStatus().equals("0")) {
- bxSettlementFeesExcel.setHandlingFeesStatus("未开票");
- }
- if (item.getHandlingFeesStatus().equals("1")) {
- bxSettlementFeesExcel.setHandlingFeesStatus("已开票");
- }
- if (item.getHandlingFeesStatus().equals("2")) {
- bxSettlementFeesExcel.setHandlingFeesStatus("已开票未结算");
- }
- resultList.add(bxSettlementFeesExcel);
- }
- }
- String uploadPath = this.uploadPath + "/excel/";
- Path path = Paths.get(uploadPath);
- if (!Files.exists(path)) {
- try {
- Files.createDirectories(path);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- String fileName = "";
- if ("1".equals(insPlyIncomeVo.getIsNotCar())) {
- fileName = EasyExcelUtils.downExcel(uploadPath, filePathName, BxSettlementFeesNorExcel.class, resultNoList);
- } else {
- fileName = EasyExcelUtils.downExcel(uploadPath, filePathName, BxSettlementFeesExcel.class, resultList);
- }
- return HttpResult.ok("", uploadUrl + "excel/" + fileName);
- }
- @Override
- public HttpResult bxOtherExcel(InsPlyIncomeVo insPlyIncomeVo, HttpServletRequest request, HttpServletResponse response) {
- HashMap<String, Object> params = new HashMap<>();
- params = this.saveParams(insPlyIncomeVo, params);
- params.put("agreementType", "2");
- params.put("isOther", "1");
- params.put("isNotCar", "0");
- List<InsPlyIncome> insPlyIncomes = baseMapper.allOtherAmount(params);
- ExportParams exportParams = new ExportParams("跟单费导出", null, ExcelType.HSSF);
- exportParams.setStyle(ExcelStyleUtil.class);
- List<BxOtherExcel> resultList = new ArrayList<>();
- for (InsPlyIncome item : insPlyIncomes) {
- BxOtherExcel bxSettlementFeesExcel = new BxOtherExcel();
- BeanUtils.copyProperties(item, bxSettlementFeesExcel);
- resultList.add(bxSettlementFeesExcel);
- }
- String uploadPath = this.uploadPath + "/excel/";
- Path path = Paths.get(uploadPath);
- if (!Files.exists(path)) {
- try {
- Files.createDirectories(path);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- String fileName = EasyExcelUtils.downExcel(uploadPath, "跟单费导出", BxOtherExcel.class, resultList);
- return HttpResult.ok("", uploadUrl + "excel/" + fileName);
- }
- @Override
- public InsPlyIncome bxTotalAmount(InsPlyIncomeVo insPlyIncomeVo) {
- InsPlyIncome insPlyIncome = new InsPlyIncome();
- HashMap<String, Object> params = new HashMap<>();
- params = this.saveParams(insPlyIncomeVo, params);
- BigDecimal sumCommissionFeevalue = BigDecimal.ZERO; //总金额
- BigDecimal sumInvoicCommissionFeevalue = BigDecimal.ZERO; //开票未结算
- BigDecimal sumReadyCommissionFeevalue = BigDecimal.ZERO; // 已开票已结算
- BigDecimal sumNoInvoicCommissionFeevalue = BigDecimal.ZERO; //未开票金额
- BigDecimal sumUnSettledAmount = BigDecimal.ZERO; //未结算金额
- BigDecimal sumAllInvoicCommissionFeevalue = BigDecimal.ZERO; //总开票
- List<InsPlyIncome> resultList = baseMapper.totalBxAmount(params);
- for (InsPlyIncome item : resultList) {
- BigDecimal commissionFeevalue = BigDecimal.ZERO; //总金额
- BigDecimal invoicCommissionFeevalue = BigDecimal.ZERO; //开票未结算
- BigDecimal readyCommissionFeevalue = BigDecimal.ZERO; // 已开票已结算
- BigDecimal noInvoicCommissionFeevalue = BigDecimal.ZERO; //未开票金额
- BigDecimal unSettledAmount; //未结算金额
- params.put("partnerCompaniesId", item.getPartnerCompaniesId());
- params.remove("handlingFeesStatus");
- List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params); //金额总数
- for (InsPlyIncome all : insPlyIncomes) {
- if(ObjectUtils.isNotEmpty(all)){
- commissionFeevalue = commissionFeevalue.add(all.getCommissionFeevalue());
- }
- }
- //已开票金额 = 开票未结算+ 开票已结算
- params.put("handlingFeesStatus", "0"); // 开票
- params.put("settlementStatus", "1"); // 开票
- List<SettlementDocumentaryFeesEntity> invoicInsPlyIncomes = settlementDocumentaryFeesService.queryNew(params); //金额总数
- for (SettlementDocumentaryFeesEntity invoicInsPlyIncome : invoicInsPlyIncomes) {
- BigDecimal invoicIcommissionFeevalue = invoicInsPlyIncome.getSettlementAmount();// 已经开票金额
- invoicCommissionFeevalue = invoicCommissionFeevalue.add(invoicIcommissionFeevalue); //开票金额
- }
- params.put("settlementStatus", "2"); // 结算
- List<SettlementDocumentaryFeesEntity> settleInsPlyIncomes = settlementDocumentaryFeesService.queryNew(params); //金额总数
- for (SettlementDocumentaryFeesEntity settleInsPlyIncome : settleInsPlyIncomes) {
- BigDecimal settleIcommissionFeevalue = settleInsPlyIncome.getSettlementAmount();// 已结算金额
- readyCommissionFeevalue = readyCommissionFeevalue.add(settleIcommissionFeevalue); //已结算总
- }
- params.put("settlementStatus", 0); //未开票金额
- List<SettlementDocumentaryFeesEntity> noInvoicInsPlyIncomes = settlementDocumentaryFeesService.queryNew(params); //金额总数
- for (SettlementDocumentaryFeesEntity noInvoicInsPlyIncome : noInvoicInsPlyIncomes) {
- BigDecimal noInvoicIcommissionFeevalue = noInvoicInsPlyIncome.getSettlementAmount();// 未开票金额
- noInvoicCommissionFeevalue = noInvoicCommissionFeevalue.add(noInvoicIcommissionFeevalue); //未开票总金额
- }
- noInvoicCommissionFeevalue = commissionFeevalue.subtract(invoicCommissionFeevalue);// 未开票
- unSettledAmount = commissionFeevalue.subtract(readyCommissionFeevalue); //未结算
- //已开票金额
- item.setCommissionFeevalue(commissionFeevalue); //总手续费
- item.setAllInvoicCommissionFeevalue(invoicCommissionFeevalue); //总开票金额
- // 开票未结算 = 开票金额 - 已开票已结算
- invoicCommissionFeevalue = invoicCommissionFeevalue.subtract(readyCommissionFeevalue);
- item.setInvoicCommissionFeevalue(invoicCommissionFeevalue); //开票未结算
- item.setReadyCommissionFeevalue(readyCommissionFeevalue); //已开票已结算
- item.setNoInvoicCommissionFeevalue(noInvoicCommissionFeevalue); //未开票金额
- item.setUnSettledAmount(unSettledAmount); // 未结算金额
- sumCommissionFeevalue = sumCommissionFeevalue.add(item.getCommissionFeevalue());
- sumInvoicCommissionFeevalue = sumInvoicCommissionFeevalue.add(item.getInvoicCommissionFeevalue());
- sumReadyCommissionFeevalue = sumReadyCommissionFeevalue.add(item.getReadyCommissionFeevalue());
- sumNoInvoicCommissionFeevalue = sumNoInvoicCommissionFeevalue.add(item.getNoInvoicCommissionFeevalue());
- sumUnSettledAmount = sumUnSettledAmount.add(item.getUnSettledAmount());
- sumAllInvoicCommissionFeevalue = sumAllInvoicCommissionFeevalue.add(item.getAllInvoicCommissionFeevalue());
- }
- if(sumCommissionFeevalue.compareTo(sumReadyCommissionFeevalue) <0){
- sumAllInvoicCommissionFeevalue=sumCommissionFeevalue;
- sumReadyCommissionFeevalue=sumCommissionFeevalue;
- sumNoInvoicCommissionFeevalue =sumCommissionFeevalue.subtract(sumAllInvoicCommissionFeevalue);
- sumUnSettledAmount=sumAllInvoicCommissionFeevalue.subtract(sumReadyCommissionFeevalue);
- }
- insPlyIncome.setCommissionFeevalue(sumCommissionFeevalue);
- insPlyIncome.setInvoicCommissionFeevalue(sumInvoicCommissionFeevalue);
- insPlyIncome.setReadyCommissionFeevalue(sumReadyCommissionFeevalue);
- insPlyIncome.setNoInvoicCommissionFeevalue(sumNoInvoicCommissionFeevalue);
- insPlyIncome.setAllInvoicCommissionFeevalue(sumAllInvoicCommissionFeevalue);
- insPlyIncome.setUnSettledAmount(sumUnSettledAmount);
- return insPlyIncome;
- }
- @Override
- public InsPlyIncome ptTotalAmount(InsPlyIncomeVo insPlyIncomeVo) {
- HashMap<String, Object> params = new HashMap<>();
- params = this.saveParams(insPlyIncomeVo, params);
- InsPlyIncome totalledAmount = baseMapper.ptTotalAmount(params); //总金额
- return totalledAmount;
- }
- @Override
- public HttpResult<List<HashMap<String, Object>>> otherTimeDetail(InsPlyIncomeVo insPlyIncomeVo) {
- HashMap<String, Object> params = new HashMap<>();
- this.saveParams(insPlyIncomeVo, params);
- List<HashMap<String, Object>> resultMap = baseMapper.otherTimeDetail(params);
- Set<String> uniqueYears = new HashSet<>();
- for (Map<String, Object> map : resultMap) {
- // 假设年份是以 "year" 为键的,并且它的值是 String 类型
- String year = String.valueOf(map.get("year"));
- if (year != null) { // 确保年份不是 null
- uniqueYears.add(year);
- }
- }
- this.addMonthYear(uniqueYears, resultMap);
- return HttpResult.ok(resultMap);
- }
- /**
- * uniqueYears 年份间隔 resultMap 返回结果
- *
- * @param uniqueYears
- * @param resultMap 返回一到十二月数据
- */
- private void addMonthYear(Set<String> uniqueYears, List<HashMap<String, Object>> resultMap) {
- // 存储已存在的年份-月份组合,以便快速查找
- Set<String> existingYearMonths = new HashSet<>();
- for (Map<String, Object> entry : resultMap) {
- String monthYear = String.valueOf(entry.get("monthYear"));
- existingYearMonths.add(monthYear);
- }
- // 遍历所有年份和月份,并添加缺失的条目
- for (String year : uniqueYears) {
- for (int month = 1; month <= 12; month++) {
- String strNumber = String.valueOf(month);
- if (strNumber.length() < 2) {
- strNumber = String.format("%02d", Integer.parseInt(strNumber));
- }
- String yearMonth = year + "-" + strNumber;
- if (!existingYearMonths.contains(yearMonth)) {
- // 创建一个新的条目并添加到resultMap中
- HashMap<String, Object> newEntry = new HashMap<>();
- newEntry.put("year", year);
- newEntry.put("monthNumber", strNumber);
- newEntry.put("allTotalOtherFeevalue", 0);
- newEntry.put("invoicCommissionFeevalue", 0);
- newEntry.put("monthYear", yearMonth);
- newEntry.put("noInvoicCommissionFeevalue", 0);
- resultMap.add(newEntry);
- }
- }
- }
- // 使用自定义Comparator对resultMap进行排序
- Collections.sort(resultMap, new Comparator<HashMap<String, Object>>() {
- @Override
- public int compare(HashMap<String, Object> o1, HashMap<String, Object> o2) {
- // 比较 year
- String year1 = String.valueOf(o1.get("year"));
- String year2 = String.valueOf(o2.get("year"));
- int yearComparison = year1.compareTo(year2);
- if (yearComparison != 0) {
- return yearComparison;
- }
- // 如果 year 相同,则比较 monthNumber
- Integer monthNum1 = Integer.parseInt(String.format("%2s", o1.get("monthNumber")).replaceAll(" ", "0"));
- Integer monthNum2 = Integer.parseInt(String.format("%2s", o2.get("monthNumber")).replaceAll(" ", "0"));
- return monthNum1.compareTo(monthNum2);
- }
- });
- }
- @Override
- @Transactional
- public HttpResult<Object> singleInvoic(InsPlyIncomeVo insPlyIncomeVo) {
- // 通过ids 查出跟单非结算单
- SettlementDocumentaryFeesVo settlementDocumentaryFeesVo = new SettlementDocumentaryFeesVo(); // 生成跟单费结算表
- if (!CollectionUtils.isEmpty(insPlyIncomeVo.getMultipleSelection())) {
- SettlementDocumentaryFeesSumEntity settlementDocumentaryFeesSumEntity = this.saveSumSettlement(insPlyIncomeVo);
- for (InsPlyIncomeVo insPlyIncomeVo1 : insPlyIncomeVo.getMultipleSelection()) {
- insPlyIncomeVo.setSettlementAmount(insPlyIncomeVo1.getSettlementAmount());
- insPlyIncomeVo.setOtherFeevalue(insPlyIncomeVo1.getAllTotalOtherFeevalue());
- YearMonth yearMonth = YearMonth.parse(insPlyIncomeVo1.getMonthYear());
- LocalDate signingTime = yearMonth.atDay(1);
- settlementDocumentaryFeesVo.setSigningTime(signingTime);
- if (insPlyIncomeVo.getOtherFeevalue().compareTo(BigDecimal.ZERO) == 0) {
- throw new SystemException("总金额为0不允许开票");
- }
- if (insPlyIncomeVo.getNoInvoicCommissionFeevalue().compareTo(BigDecimal.ZERO) == 0) {
- throw new SystemException("未开票金额为0不允许开票");
- }
- if (insPlyIncomeVo.getSettlementAmount() == null || insPlyIncomeVo.getSettlementAmount().compareTo(BigDecimal.ZERO) <= 0) {
- throw new SystemException("开票金额错误不允许开票");
- }
- if (insPlyIncomeVo.getNoInvoicCommissionFeevalue().compareTo(insPlyIncomeVo.getSettlementAmount()) < 0) {
- throw new SystemException("开票金额必须小于未开票金额 不允许开票");
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getYear())) {
- settlementDocumentaryFeesVo.setTimeFrame(insPlyIncomeVo.getYear());//年度
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getYear())) {
- settlementDocumentaryFeesVo.setYear(insPlyIncomeVo.getYear());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getMonth())) {
- settlementDocumentaryFeesVo.setMonth(insPlyIncomeVo.getMonth());
- }
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getDay())) {
- settlementDocumentaryFeesVo.setDay(insPlyIncomeVo.getDay());
- }
- settlementDocumentaryFeesVo.setCompletionStatus("0");
- settlementDocumentaryFeesVo.setInvoicedSettledAmount(BigDecimal.ZERO);
- settlementDocumentaryFeesVo.setInvoicedNotSettledAmount(insPlyIncomeVo.getSettlementAmount());
- settlementDocumentaryFeesVo.setCompanyId(insPlyIncomeVo.getCompanyId());// 保险公司id
- settlementDocumentaryFeesVo.setPartnerCompaniesId(insPlyIncomeVo.getPartnerCompaniesId()); //合作公司id
- settlementDocumentaryFeesVo.setTotalAmount(insPlyIncomeVo.getOtherFeevalue()); //其他费用金额
- settlementDocumentaryFeesVo.setUnsettledAmount(insPlyIncomeVo.getNoInvoicCommissionFeevalue().subtract(insPlyIncomeVo.getSettlementAmount())); //未结算
- settlementDocumentaryFeesVo.setSettlementAmount(insPlyIncomeVo.getSettlementAmount());//已经开票
- settlementDocumentaryFeesVo.setCreateTime(LocalDateTime.now());
- settlementDocumentaryFeesVo.setAgreementType("2");
- settlementDocumentaryFeesVo.setIds(insPlyIncomeVo.getIncomeIds());
- settlementDocumentaryFeesVo.setSettlementStatus("1");
- settlementDocumentaryFeesVo.setIsNotCar(insPlyIncomeVo.getIsNotCar());
- if (StringUtils.isNotEmpty(insPlyIncomeVo.getContractId())) {
- settlementDocumentaryFeesVo.setInvoiceId(insPlyIncomeVo.getContractId()); //开票号
- }
- settlementDocumentaryFeesVo.setHandlingFeesStatus(insPlyIncomeVo.getHandlingFeesStatus());
- settlementDocumentaryFeesVo.setInvoicingMethod(insPlyIncomeVo.getInvoicingMethod()); //开票方式
- settlementDocumentaryFeesVo.setTaxPoints(insPlyIncomeVo.getTaxPoints()); //税点
- settlementDocumentaryFeesVo.setIds(insPlyIncomeVo.getIds());
- // settlementDocumentaryFeesVo.setSigningTime(insPlyIncomeVo.getSettlementTime()); //签单日期
- // 税点支出
- if (BigDecimalUtils.nullToZero(insPlyIncomeVo.getTaxPoints()) != null && BigDecimalUtils.nullToZero(insPlyIncomeVo.getSettlementAmount()) != null) {
- BigDecimal settlementAmount = insPlyIncomeVo.getSettlementAmount();
- settlementDocumentaryFeesVo.setExpendAmount(settlementAmount.multiply(BigDecimal.ONE.subtract(insPlyIncomeVo.getTaxPoints().divide(new BigDecimal(100)))));
- }
- if(ObjectUtils.isNotEmpty(settlementDocumentaryFeesSumEntity)){
- settlementDocumentaryFeesVo.setSettlementSumId(settlementDocumentaryFeesSumEntity.getId());
- }
- settlementDocumentaryFeesService.inertSettle(settlementDocumentaryFeesVo);
- }
- }
- return HttpResult.ok();
- }
- @Override
- public void batchUpdate(InsPlyIncomeVo insPlyIncomeVo) {
- HashMap<String, Object> params = new HashMap<>();
- params = this.saveParams(insPlyIncomeVo, params);
- List<InsPlyIncome> list = this.baseMapper.queryNew(params);
- for (InsPlyIncome item : list) {
- item.setContractFileId(insPlyIncomeVo.getContractFileId());
- item.setSettleOtherStatus("1");
- baseMapper.updateById(item);
- }
- }
- @Override
- @Transactional
- public HashMap<String, Object> bxImportOther(MultipartFile multipartFile, String isNotCar) {
- HashMap<String, Object> resultMap = new HashMap<>();
- List<HashMap<String, Object>> resultList = new ArrayList<>();
- HashMap<String, Object> params = new HashMap<>();
- BigDecimal allAmount = BigDecimal.ZERO;
- params.put("isNotCar", isNotCar);
- try {
- List<InsBxOtherExcelDto> dtoList = ExcelEasypoiUtils.importExcel(multipartFile, InsBxOtherExcelDto.class, 0, 1, 1);
- for (InsBxOtherExcelDto item : dtoList) {
- if (StringUtils.isNotEmpty(item.getLicenseno())) {
- params.put("licenseno", item.getLicenseno());
- }
- if (StringUtils.isNotEmpty(item.getPolicyno())) {
- params.put("policyno", item.getPolicyno());
- }
- if (StringUtils.isNotEmpty(item.getSyPolicyno())) {
- params.put("syPolicyno", item.getSyPolicyno());
- }
- params.put("handlingFeesStatus", "0");
- // isOther
- params.put("isOther", "1");
- params.put("isNotCar", "0");
- InsPlyIncome byBxLicenseno = baseMapper.findByBxLicenseno(params);
- if (item.getJqOtherCostsProportion() == null) {
- item.setJqOtherCostsProportion(BigDecimal.ZERO);
- }
- if (item.getSyOtherCostsProportion() == null) {
- item.setSyOtherCostsProportion(BigDecimal.ZERO);
- }
- if (ObjectUtils.isNotEmpty(byBxLicenseno) && (byBxLicenseno.getJqOtherCostsProportion().compareTo(item.getJqOtherCostsProportion()) != 0 || byBxLicenseno.getSyOtherCostsProportion().compareTo(item.getSyOtherCostsProportion()) != 0)) {
- // InsPlyIncomeLog insPlyIncomeLog = new InsPlyIncomeLog();
- // BeanUtils.copyProperties(byBxLicenseno,insPlyIncomeLog);
- // insPlyIncomeLog.setOperationStatus("2");
- // insPlyIncomeLog.setId(null);
- // insPlyIncomeLog.setIncomeId(byBxLicenseno.getId());
- // insPlyIncomeLogService.saveLog(insPlyIncomeLog); //添加日志
- // 如果比例不相等
- BigDecimal jqOtherCostsProportion = item.getJqOtherCostsProportion();
- BigDecimal syOtherCostsProportion = item.getSyOtherCostsProportion();
- BigDecimal jqOtherAmount = getBigDecimal( byBxLicenseno.getJqPremium(),item.getJqOtherCostsProportion());
- BigDecimal syOtherAmount = getBigDecimal( byBxLicenseno.getSyPremium(),item.getSyOtherCostsProportion());
- // byBxLicenseno.setJqOtherCostsPremium(jqOtherAmount);
- // byBxLicenseno.setSyOtherCostsPremium(syOtherAmount);
- // byBxLicenseno.setJqOtherCostsProportion(jqOtherCostsProportion);
- // byBxLicenseno.setSyOtherCostsProportion(syOtherCostsProportion);
- // byBxLicenseno.setOtherFeevalue(this.calculateTotal(jqOtherAmount, syOtherAmount, null));
- // byBxLicenseno.setOtherFeerate(this.calculateTotal(jqOtherCostsProportion, syOtherCostsProportion, null));
- // byBxLicenseno.setAllFeeValue(this.calculateTotal(jqOtherAmount, syOtherAmount, null));
- // byBxLicenseno.setUpdateUserId(BaseController.getUser().getId());
- // byBxLicenseno.setUpdateUserName(BaseController.getUser().getName());
- // baseMapper.updateById(byBxLicenseno);
- HashMap<String, Object> map = new HashMap<>();
- map.put("licenseno", item.getLicenseno());
- map.put("policyno", item.getPolicyno());
- map.put("syPolicyno", item.getSyPolicyno());
- map.put("jqOtherCostsPremium", jqOtherAmount);
- map.put("syOtherCostsPremium", syOtherAmount);
- map.put("jqOtherCostsProportion", jqOtherCostsProportion);
- map.put("syOtherCostsProportion", syOtherCostsProportion);
- map.put("otherFeevalue", byBxLicenseno.getOtherFeevalue());
- map.put("otherFeerate", byBxLicenseno.getOtherFeerate());
- map.put("id", byBxLicenseno.getId());
- resultList.add(map);
- allAmount = allAmount.add(jqOtherAmount).add(syOtherAmount);
- }
- }
- resultMap.put("allAmount", allAmount);
- resultMap.put("resultList", resultList);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- return resultMap;
- }
- @Override
- @Transactional
- public void bxImportOtherConfirm(InsPlyIncomeVo insPlyIncomeVo) {
- if (ObjectUtils.isEmpty(insPlyIncomeVo)) {
- throw new SystemException("请导入文件");
- }
- if (!CollectionUtils.isEmpty(insPlyIncomeVo.getResultList())) {
- for (InsPlyIncome item : insPlyIncomeVo.getResultList()) {
- InsPlyIncomeLog insPlyIncomeLog = new InsPlyIncomeLog();
- BeanUtils.copyProperties(item,insPlyIncomeLog);
- insPlyIncomeLog.setOperationStatus("2");
- insPlyIncomeLog.setId(null);
- insPlyIncomeLog.setIncomeId(item.getId());
- insPlyIncomeLogService.saveLog(insPlyIncomeLog); //添加日志
- item.setOtherFeevalue(this.calculateTotal(item.getJqOtherCostsPremium(), item.getSyOtherCostsPremium(), null));
- item.setOtherFeerate(this.calculateTotal(item.getJqOtherCostsProportion(), item.getSyOtherCostsProportion(), null));
- item.setAllFeeValue(this.calculateTotal(item.getJqOtherCostsPremium(), item.getSyOtherCostsPremium(), null));
- item.setUpdateUserId(BaseController.getUser().getId());
- item.setUpdateUserName(BaseController.getUser().getName());
- baseMapper.updateById(item);
- }
- }
- }
- @Override
- public HashMap<String, Object> ptImportOther(MultipartFile multipartFile) {
- HashMap<String, Object> resultMap = new HashMap<>();
- List<HashMap<String, Object>> resultList = new ArrayList<>();
- HashMap<String, Object> params = new HashMap<>();
- BigDecimal allAmount = BigDecimal.ZERO;
- try {
- List<InsPtHandExcelDto> dtoList = ExcelEasypoiUtils.importExcel(multipartFile, InsPtHandExcelDto.class, 0, 1, 1);
- for (InsPtHandExcelDto item : dtoList) {
- if (StringUtils.isNotEmpty(item.getLicenseno())) {
- params.put("licenseno", item.getLicenseno());
- }
- if (StringUtils.isNotEmpty(item.getPolicyno())) {
- params.put("policyno", item.getPolicyno());
- }
- if (StringUtils.isNotEmpty(item.getSyPolicyno())) {
- params.put("syPolicyno", item.getSyPolicyno());
- }
- if (StringUtils.isNotEmpty(item.getNoPolicyno())) {
- params.put("noPolicyno", item.getNoPolicyno());
- }
- params.put("handlingFeesStatus", "0");
- // isOther
- params.put("isOther", "0");
- params.put("isNotCar", "0");
- InsPlyIncome byBxLicenseno = baseMapper.findByBxLicenseno(params);
- if (item.getNoOtherCostsProportion() == null) {
- item.setNoOtherCostsProportion(BigDecimal.ZERO);
- }
- if (item.getJqOtherCostsProportion() == null) {
- item.setJqOtherCostsProportion(BigDecimal.ZERO);
- }
- if (item.getSyOtherCostsProportion() == null) {
- item.setSyOtherCostsProportion(BigDecimal.ZERO);
- }
- if (item.getJqSuperviseCostsProportion() == null) {
- item.setJqSuperviseCostsProportion(BigDecimal.ZERO);
- }
- if (item.getSySuperviseCostsProportion() == null) {
- item.setSySuperviseCostsProportion(BigDecimal.ZERO);
- }
- if (item.getNoSuperviseCostsProportion() == null) {
- item.setNoSuperviseCostsProportion(BigDecimal.ZERO);
- }
- if (ObjectUtils.isNotEmpty(byBxLicenseno) && (byBxLicenseno.getJqOtherCostsProportion().compareTo(item.getJqOtherCostsProportion()) != 0 || byBxLicenseno.getSyOtherCostsProportion().compareTo(item.getSyOtherCostsProportion()) != 0)) {
- InsPlyIncomeLog insPlyIncomeLog = new InsPlyIncomeLog();
- BeanUtils.copyProperties(byBxLicenseno,insPlyIncomeLog);
- insPlyIncomeLog.setOperationStatus("2");
- insPlyIncomeLog.setId(null);
- insPlyIncomeLog.setIncomeId(byBxLicenseno.getId());
- insPlyIncomeLogService.saveLog(insPlyIncomeLog); //添加日志
- // 如果比例不相等
- BigDecimal jqOtherCostsProportion = item.getJqOtherCostsProportion();
- BigDecimal syOtherCostsProportion = item.getSyOtherCostsProportion();
- BigDecimal noOtherCostsProportion = item.getNoOtherCostsProportion();
- BigDecimal jqSuperviseCostsProportion = item.getJqSuperviseCostsProportion();
- BigDecimal sySuperviseCostsProportion = item.getSySuperviseCostsProportion();
- BigDecimal noSuperviseCostsProportion = item.getNoSuperviseCostsProportion();
- BigDecimal jqOtherAmount = algorithmAmount( byBxLicenseno.getJqPremium(),jqOtherCostsProportion);
- BigDecimal syOtherAmount = algorithmAmount( byBxLicenseno.getSyPremium(),syOtherCostsProportion);
- BigDecimal noOtherAmount = algorithmAmount( byBxLicenseno.getNoPremium(),noOtherCostsProportion);
- BigDecimal jqSuperviseCostsAmount = algorithmAmount( byBxLicenseno.getJqPremium(),jqSuperviseCostsProportion);
- BigDecimal sySuperviseCostsAmount = algorithmAmount( byBxLicenseno.getSyPremium(),sySuperviseCostsProportion);
- BigDecimal noSuperviseCostsAmount = algorithmAmount( byBxLicenseno.getNoPremium(),noSuperviseCostsProportion);
- byBxLicenseno.setJqOtherCostsPremium(jqOtherAmount);
- byBxLicenseno.setSyOtherCostsPremium(syOtherAmount);
- byBxLicenseno.setNoOtherCostsPremium(noOtherAmount);
- byBxLicenseno.setJqSuperviseCostsPremiums(jqSuperviseCostsAmount);
- byBxLicenseno.setSySuperviseCostsPremiums(sySuperviseCostsAmount);
- byBxLicenseno.setNoSuperviseCostsPremiums(noSuperviseCostsAmount);
- byBxLicenseno.setJqOtherCostsProportion(jqOtherCostsProportion);
- byBxLicenseno.setSyOtherCostsProportion(syOtherCostsProportion);
- byBxLicenseno.setNoOtherCostsProportion(noOtherCostsProportion);
- byBxLicenseno.setJqSuperviseCostsProportion(jqSuperviseCostsProportion);
- byBxLicenseno.setSySuperviseCostsProportion(sySuperviseCostsProportion);
- byBxLicenseno.setNoSuperviseCostsProportion(noSuperviseCostsProportion);
- byBxLicenseno.setOtherFeevalue(this.calculateTotal(jqOtherAmount, syOtherAmount, noOtherAmount));
- byBxLicenseno.setOtherFeerate(this.calculateTotal(jqOtherCostsProportion, syOtherCostsProportion, noOtherCostsProportion));
- byBxLicenseno.setCommissionFeevalue(this.calculateTotal(jqSuperviseCostsAmount, sySuperviseCostsAmount, noSuperviseCostsAmount));
- byBxLicenseno.setCommissionFeerate(this.calculateTotal(jqSuperviseCostsProportion,sySuperviseCostsProportion,noSuperviseCostsProportion));
- byBxLicenseno.setAllFeeValue(this.calculateTotal(byBxLicenseno.getOtherFeevalue(),byBxLicenseno.getCommissionFeevalue(),null));
- byBxLicenseno.setJqReceivableProportion(this.calculateTotal(jqSuperviseCostsProportion,jqOtherCostsProportion,null));
- byBxLicenseno.setSyReceivableProportion(this.calculateTotal(sySuperviseCostsProportion,syOtherCostsProportion,null));
- byBxLicenseno.setNoReceivableProportion(this.calculateTotal(noSuperviseCostsProportion,noOtherCostsProportion,null));
- byBxLicenseno.setUpdateUserId(BaseController.getUser().getId());
- byBxLicenseno.setUpdateUserName(BaseController.getUser().getName());
- baseMapper.updateById(byBxLicenseno);
- HashMap<String, Object> map = new HashMap<>();
- map.put("licenseno", item.getLicenseno());
- map.put("policyno", item.getPolicyno());
- map.put("syPolicyno", item.getSyPolicyno());
- map.put("noPolicyno", item.getNoPolicyno());
- map.put("jqOtherCostsPremium", jqOtherAmount);
- map.put("syOtherCostsPremium", syOtherAmount);
- map.put("noOtherCostsPremium", noOtherAmount);
- map.put("jqSuperviseCostsPremiums", jqSuperviseCostsAmount);
- map.put("sySuperviseCostsPremiums", sySuperviseCostsAmount);
- map.put("noSuperviseCostsPremiums", noSuperviseCostsAmount);
- map.put("jqOtherCostsProportion", jqOtherCostsProportion);
- map.put("syOtherCostsProportion", syOtherCostsProportion);
- map.put("noOtherCostsProportion", noOtherCostsProportion);
- map.put("jqSuperviseCostsProportion", jqSuperviseCostsProportion);
- map.put("sySuperviseCostsProportion", sySuperviseCostsProportion);
- map.put("noSuperviseCostsProportion", noSuperviseCostsProportion);
- map.put("otherFeevalue", byBxLicenseno.getOtherFeevalue());
- map.put("otherFeerate", byBxLicenseno.getOtherFeerate());
- resultList.add(map);
- allAmount = allAmount.add(jqOtherAmount).add(syOtherAmount).add(noOtherAmount);
- }
- }
- resultMap.put("allAmount", allAmount);
- resultMap.put("resultList", resultList);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- return resultMap;
- }
- @Override
- @Transactional
- public HashMap<String, Object> noBxImportOther(MultipartFile multipartFile, String isNotCar) {
- HashMap<String, Object> resultMap = new HashMap<>();
- List<HashMap<String, Object>> resultList = new ArrayList<>();
- HashMap<String, Object> params = new HashMap<>();
- BigDecimal allAmount = BigDecimal.ZERO;
- params.put("isNotCar", isNotCar);
- try {
- List<InsNoBxOtherExcelDto> dtoList = ExcelEasypoiUtils.importExcel(multipartFile, InsNoBxOtherExcelDto.class, 0, 1, 1);
- for (InsNoBxOtherExcelDto item : dtoList) {
- if (StringUtils.isNotEmpty(item.getLicenseno())) {
- params.put("licenseno", item.getLicenseno());
- }
- if (StringUtils.isNotEmpty(item.getNoPolicyno())) {
- params.put("noPolicyno", item.getNoPolicyno());
- }
- params.put("handlingFeesStatus", "0");
- params.put("isNotCar", "1");
- params.put("isOther", "1");
- InsPlyIncome byBxLicenseno = baseMapper.findByBxLicenseno(params);
- if (ObjectUtils.isNotEmpty(byBxLicenseno) && byBxLicenseno.getNoOtherCostsProportion().compareTo(item.getNoOtherCostsProportion()) != 0) {
- InsPlyIncomeLog insPlyIncomeLog = new InsPlyIncomeLog();
- insPlyIncomeLog.setIncomeId(byBxLicenseno.getId());
- BeanUtils.copyProperties(byBxLicenseno,insPlyIncomeLog);
- insPlyIncomeLog.setOperationStatus("2");
- insPlyIncomeLog.setId(null);
- insPlyIncomeLogService.saveLog(insPlyIncomeLog); //添加日志
- HashMap<String, Object> newMap = new HashMap<>();
- // 如果比例不相等
- BigDecimal noOtherCostsProportion = item.getNoOtherCostsProportion();
- BigDecimal noNoTaxPremium = byBxLicenseno.getNoPremium();
- BigDecimal divisor = new BigDecimal("1.06"); // 最好是使用字符串来避免精度损失
- BigDecimal noOtherAmount = getBigDecimal( noNoTaxPremium,item.getNoOtherCostsProportion());
- // byBxLicenseno.setNoOtherCostsPremium(noOtherAmount);
- // byBxLicenseno.setNoOtherCostsProportion(item.getNoOtherCostsProportion());
- // byBxLicenseno.setAllFeeValue(this.calculateTotal(noOtherAmount, null, null));
- //
- // byBxLicenseno.setOtherFeevalue(this.calculateTotal(noOtherAmount, null, null));
- // byBxLicenseno.setOtherFeerate(this.calculateTotal(noOtherCostsProportion, null, null));
- // baseMapper.updateById(byBxLicenseno);
- newMap.put("licenseno", item.getLicenseno());
- newMap.put("noPolicyno", item.getNoPolicyno());
- newMap.put("noOtherCostsPremium", noOtherAmount);
- newMap.put("noOtherCostsProportion", item.getNoOtherCostsProportion());
- newMap.put("otherFeevalue", byBxLicenseno.getOtherFeevalue());
- newMap.put("otherFeerate", byBxLicenseno.getOtherFeerate());
- newMap.put("id", byBxLicenseno.getId());
- resultList.add(newMap);
- allAmount = allAmount.add(noOtherAmount);
- }
- }
- resultMap.put("allAmount", allAmount);
- resultMap.put("resultList", resultList);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- return resultMap;
- }
- @Override
- @Transactional
- public void noBxImportOtherConfirm(InsPlyIncomeVo insPlyIncomeVo) {
- if (ObjectUtils.isEmpty(insPlyIncomeVo)) {
- throw new SystemException("请导入文件");
- }
- if (!CollectionUtils.isEmpty(insPlyIncomeVo.getResultList())) {
- for (InsPlyIncome item : insPlyIncomeVo.getResultList()) {
- InsPlyIncomeLog insPlyIncomeLog = new InsPlyIncomeLog();
- insPlyIncomeLog.setIncomeId(item.getId());
- BeanUtils.copyProperties(item,insPlyIncomeLog);
- insPlyIncomeLog.setOperationStatus("2");
- insPlyIncomeLog.setId(null);
- insPlyIncomeLogService.saveLog(insPlyIncomeLog); //添加日志
- item.setAllFeeValue(this.calculateTotal(item.getNoOtherCostsPremium(), null, null));
- item.setOtherFeevalue(this.calculateTotal(item.getNoOtherCostsPremium(), null, null));
- item.setOtherFeerate(this.calculateTotal(item.getNoOtherCostsProportion(), null, null));
- baseMapper.updateById(item);
- }
- }
- }
- @Override
- public void batchUpdateVoucher(InsPlyIncomeVo insPlyIncomeVo) {
- String s = insPlyIncomeVo.getSelectIds().get(0);
- ImportResult importResult = importAsyncService.getById(s);
- String[] split = importResult.getIds().split(",");
- InsPlyIncome insPlyIncome = new InsPlyIncome();
- for (String id : split) {
- insPlyIncome.setId(id);
- insPlyIncome.setSettlementImageId(insPlyIncomeVo.getSettlementImageId());
- insPlyIncome.setSettleOtherStatus("1");
- baseMapper.updateById(insPlyIncome);
- }
- }
- /**
- * 通过任务id 去查询关联表
- *
- * @param insPlyIncomeVo
- * @return
- */
- @Override
- public HttpResult<Object> reconciliation(InsPlyIncomeVo insPlyIncomeVo) {
- String taskId = insPlyIncomeVo.getTaskId();
- List<String> incomeIdList = incomeTaskRelationshipService.getByTaskId(taskId);
- for (String incomeId : incomeIdList) {
- InsPlyIncome insPlyIncome = baseMapper.getById(incomeId);
- insPlyIncome.setSettleOtherStatus("1");
- insPlyIncome.setSettlementImageId(insPlyIncomeVo.getSettlementImageId());
- baseMapper.updateById(insPlyIncome);
- }
- return HttpResult.ok();
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2024/6/18 10:14
- * @Description: 通过保险公司id和状态查询平台的记录
- */
- @Override
- public List<PlatformSettlementRecordDto> platformSettlementRecord(InsPlyIncomeVo insPlyIncomeVo) {
- // if(insPlyIncomeVo.getPartnerCompaniesId()==null || "".equals(insPlyIncomeVo.getPartnerCompaniesId())){
- // throw new SystemException("合作公司编码(partnerCompaniesId)不能为空");
- // }
- if(insPlyIncomeVo.getHandlingFeesStatus()==null || "".equals(insPlyIncomeVo.getHandlingFeesStatus())){
- throw new SystemException("结算状态 0 未结算 1已结算(handlingFeesStatus)不能为空");
- }
- return baseMapper.platformSettlementRecord(insPlyIncomeVo.getPartnerCompaniesId(),insPlyIncomeVo.getHandlingFeesStatus(),insPlyIncomeVo.getDockingPerson());
- }
- /**
- * @param insPlyIncomeVo
- * @Description: 平台新增
- * @return InsPlyIncome
- */
- @Override
- public HttpResult<InsPlyIncome> ptInsert(InsPlyIncomeVo insPlyIncomeVo) {
- InsPlyIncome insPlyIncome = new InsPlyIncome();
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
- String agreementId = insPlyIncomeVo.getAgreementId();
- if(StringUtils.isNotEmpty(agreementId)){
- HttpResult<PtlAgreementQueryVo> byAgreementId = ptlAgreementService.getByAgreementId(agreementId);
- if(byAgreementId!=null && ObjectUtils.isNotEmpty(byAgreementId.getData())){
- PtlAgreementQueryVo data = byAgreementId.getData();
- PtlAgreement agreement = data.getAgreement();
- if(ObjectUtils.isNotEmpty(agreement)){
- insPlyIncomeVo.setPartnerCompaniesId(agreement.getPartnerCompaniesId());
- insPlyIncomeVo.setCompanyId(agreement.getInsuranceCompanyId());
- }
- }
- }
- BeanUtils.copyProperties(insPlyIncomeVo, insPlyIncome);
- if (StringUtils.isNotEmpty(insPlyIncome.getPartnerCompaniesId())) {
- // 合作公司id
- String partnerCompaniesId = insPlyIncome.getPartnerCompaniesId();
- insPlyIncome.setPartnerCompaniesId(partnerCompaniesId);
- EsmInsCompany esmInsCompany = EsmInsCompanyService.getById(partnerCompaniesId);
- String name = esmInsCompany.getNamesimple(); //合作名称
- insPlyIncome.setPartnerCompaniesName(name);
- insPlyIncome.setPartnerCompaniesId(insPlyIncome.getPartnerCompaniesId());
- }
- if (StringUtils.isNotEmpty(insPlyIncome.getCompanyId())) {
- String insuranceCompanyId = insPlyIncome.getCompanyId();
- EsmInsCompany esmInsCompany = EsmInsCompanyService.getById(insuranceCompanyId);
- String name = esmInsCompany.getNamesimple(); //保险公司名称 简称
- insPlyIncome.setCompanyName(name);
- }
- // if (insPlyIncome.getJqPremium() != null && insPlyIncome.getJqPremium().compareTo(BigDecimal.ZERO) > 0 && insPlyIncome.getJqSuperviseCostsProportion() != null && insPlyIncome.getJqSuperviseCostsProportion().compareTo(BigDecimal.ZERO) > 0) {
- // insPlyIncome.setJqSuperviseCostsPremiums(this.getBigDecimal(insPlyIncome.getJqPremium(),insPlyIncome.getJqSuperviseCostsProportion()));
- // }
- // if (insPlyIncome.getSyPremium() != null && insPlyIncome.getSyPremium().compareTo(BigDecimal.ZERO) > 0 && insPlyIncome.getSySuperviseCostsProportion() != null && insPlyIncome.getSySuperviseCostsProportion().compareTo(BigDecimal.ZERO) > 0) {
- // insPlyIncome.setSySuperviseCostsPremiums(this.getBigDecimal(insPlyIncome.getSyPremium(),insPlyIncome.getSySuperviseCostsProportion()));
- // }
- // if (insPlyIncome.getNoPremium() != null && insPlyIncome.getNoPremium().compareTo(BigDecimal.ZERO) > 0 && insPlyIncome.getNoSuperviseCostsProportion() != null && insPlyIncome.getNoSuperviseCostsProportion().compareTo(BigDecimal.ZERO) > 0) {
- // insPlyIncome.setNoSuperviseCostsPremiums(this.getBigDecimal(insPlyIncome.getNoPremium(),insPlyIncome.getNoSuperviseCostsProportion()));
- // }
- // if (insPlyIncome.getJqPremium() != null && insPlyIncome.getJqPremium().compareTo(BigDecimal.ZERO) > 0 && insPlyIncome.getJqOtherCostsProportion() != null && insPlyIncome.getJqOtherCostsProportion().compareTo(BigDecimal.ZERO) > 0) {
- // insPlyIncome.setJqOtherCostsPremium(this.getBigDecimal(insPlyIncome.getJqPremium(),insPlyIncome.getJqOtherCostsProportion()));
- // }
- // if (insPlyIncome.getSyPremium() != null && insPlyIncome.getSyPremium().compareTo(BigDecimal.ZERO) > 0 && insPlyIncome.getSyOtherCostsProportion() != null && insPlyIncome.getSyOtherCostsProportion().compareTo(BigDecimal.ZERO) > 0) {
- // insPlyIncome.setSyOtherCostsPremium(this.getBigDecimal(insPlyIncome.getSyPremium(),insPlyIncome.getSyOtherCostsProportion()));
- // }
- // if (insPlyIncome.getNoPremium() != null && insPlyIncome.getNoPremium().compareTo(BigDecimal.ZERO) > 0 && insPlyIncome.getNoOtherCostsProportion() != null && insPlyIncome.getNoOtherCostsProportion().compareTo(BigDecimal.ZERO) > 0) {
- // insPlyIncome.setNoOtherCostsPremium(this.getBigDecimal(insPlyIncome.getNoPremium(),insPlyIncome.getNoOtherCostsProportion()));
- // }
- HashMap<String, Object> params = new HashMap<>();
- params.put("agreeId",insPlyIncomeVo.getAgreeId());
- PtlAgreement ptlAgreement = ptlAgreementService.selectAgreeId(params);
- if (ObjectUtils.isEmpty(ptlAgreement)) {
- return HttpResult.error("协议匹配不上");
- }
- insPlyIncome.setAgreementId(ptlAgreement.getId());
- insPlyIncome.setJqReceivableProportion(this.calculateTotal(insPlyIncome.getJqSuperviseCostsProportion(),insPlyIncome.getNoOtherCostsProportion(),null));
- insPlyIncome.setSyReceivableProportion(this.calculateTotal(insPlyIncome.getSySuperviseCostsProportion(),insPlyIncome.getNoOtherCostsProportion(),null));
- insPlyIncome.setNoReceivableProportion(this.calculateTotal(insPlyIncome.getNoSuperviseCostsProportion(),insPlyIncome.getNoOtherCostsProportion(),null));
- insPlyIncome.setCreateTime(LocalDateTime.now());
- insPlyIncome.setCommissionFeerate(this.calculateTotal(insPlyIncome.getJqSuperviseCostsProportion(),insPlyIncome.getSySuperviseCostsProportion(),insPlyIncome.getNoSuperviseCostsPremiums()));
- insPlyIncome.setCommissionFeevalue(this.calculateTotal(insPlyIncome.getJqSuperviseCostsPremiums(),insPlyIncome.getSySuperviseCostsPremiums(),insPlyIncome.getNoSuperviseCostsPremiums()));
- insPlyIncome.setOtherFeerate(this.calculateTotal(insPlyIncome.getJqOtherCostsProportion(),insPlyIncome.getSyOtherCostsProportion(),insPlyIncome.getNoOtherCostsProportion()));
- insPlyIncome.setOtherFeevalue(this.calculateTotal(insPlyIncome.getJqOtherCostsPremium(),insPlyIncome.getSyOtherCostsPremium(),insPlyIncome.getNoOtherCostsPremium()));
- insPlyIncome.setAllFeeValue(this.calculateTotal(insPlyIncome.getCommissionFeevalue(),insPlyIncome.getOtherFeevalue(),null));
- insPlyIncome.setAgreementType("1");
- insPlyIncome.setHandlingFeesStatus("0");
- insPlyIncome.setCommissionFeevalue(insPlyIncomeVo.getCommissionFeevalue());
- insPlyIncome.setOtherFeevalue(insPlyIncomeVo.getOtherFeevalue());
- insPlyIncome.setIsNotCar("0");
- insPlyIncome.setIsNotDocumentary("0");
- insPlyIncome.setDocumentaryFeesStatus("0");
- insPlyIncome.setAllFeeValue(insPlyIncome.getReceivableAmount());
- if(StringUtils.isNotEmpty(insPlyIncomeVo.getSignDate())){
- LocalDate signDate = LocalDate.parse(insPlyIncomeVo.getSignDate(), formatter);
- insPlyIncome.setSignDate(signDate.atStartOfDay());
- }
- InsPlyIncomeLog insPlyIncomeLog = new InsPlyIncomeLog();
- insPlyIncomeLog.setIncomeId(insPlyIncome.getId());
- insPlyIncome.setId(null);
- BeanUtils.copyProperties(insPlyIncome,insPlyIncomeLog);
- insPlyIncomeLog.setOperationStatus("1");
- insPlyIncomeLogService.saveLog(insPlyIncomeLog); //添加日志
- baseMapper.insert(insPlyIncome);
- return HttpResult.ok();
- }
- /***
- *
- * @param insPlyIncomeVo
- * @return 返回私有 平台 应收 已收 未收
- */
- @Override
- public HttpResult<ArrayList<Map<String,Object>>> totalReceivables(InsPlyIncomeVo insPlyIncomeVo) {
- ArrayList<Map<String,Object>> resultList = new ArrayList<>();
- BigDecimal bxhandAmount = BigDecimal.ZERO; //保险手续费应收
- BigDecimal receivedAmount = BigDecimal.ZERO; //保险手续费应收
- HashMap<String, Object> ptParams = new HashMap<>();
- ptParams.put("agreementType","1");
- InsPlyIncome totalledAmount = baseMapper.ptTotalAmount(ptParams); //应收 未收 已收
- ptParams.clear();
- ptParams.put("commissionFeevalue",totalledAmount.getCommissionFeevalue());
- ptParams.put("noInvoicCommissionFeevalue",totalledAmount.getNoInvoicCommissionFeevalue());
- ptParams.put("readyCommissionFeevalue",totalledAmount.getReadyCommissionFeevalue());
- resultList.add(ptParams);
- //手续费应收
- HashMap<String, Object> privateParams= new HashMap<>();
- privateParams.put("agreementType","2");
- List<InsPlyIncome> bxHandList = baseMapper.queryNew(privateParams);
- for (InsPlyIncome bxhandItem : bxHandList){
- bxhandAmount=bxhandAmount.add(bxhandItem.getAllFeeValue());
- }
- privateParams.clear();
- //已开票金额 = 开票未结算+ 开票已结算
- privateParams.put("settlementStatus", "2"); // 结算
- List<SettlementDocumentaryFeesEntity> invoicInsPlyIncomes = settlementDocumentaryFeesService.queryNew(privateParams); //金额总数
- for (SettlementDocumentaryFeesEntity invoicInsPlyIncome : invoicInsPlyIncomes) {
- receivedAmount =receivedAmount.add(invoicInsPlyIncome.getSettlementAmount());
- }
- if(receivedAmount.compareTo(BigDecimal.ZERO)== 0){
- receivedAmount=bxhandAmount;
- }
- BigDecimal subtract = bxhandAmount.subtract(receivedAmount);
- privateParams.clear();
- privateParams.put("commissionFeevalue",bxhandAmount);
- privateParams.put("noInvoicCommissionFeevalue",receivedAmount);
- privateParams.put("readyCommissionFeevalue",subtract);
- resultList.add(privateParams);
- return HttpResult.ok(resultList);
- }
- /**
- * 根据签单日期月份分组
- * @param insPlyIncomeVo
- * @return 平台 私有 应收 已收
- */
- @Override
- public HttpResult<List<HashMap<String, Object>>> monthTotalReceivables(InsPlyIncomeVo insPlyIncomeVo) {
- HashMap<String, Object> params = new HashMap<>();
- params.put("agreementType", insPlyIncomeVo.getAgreementType());
- if ("1".equals(insPlyIncomeVo.getAgreementType())) { //平台
- params.put("year", insPlyIncomeVo.getYear());
- List<HashMap<String, Object>> ptResultList = baseMapper.ptSumGroupByMonth(params);
- params.put("handlingFeesStatus", "1");
- List<HashMap<String, Object>> ptSettleResultList = baseMapper.ptSumGroupByMonth(params);
- Map<String, BigDecimal> ptMap = new HashMap<>(); // 假设commissionFeevalue是BigDecimal类型
- for (HashMap<String, Object> ptSettleResultListItem : ptSettleResultList) {
- String month = (String) ptSettleResultListItem.get("month");
- if (month == null) {
- // 处理month为null的情况
- continue;
- }
- BigDecimal commissionFeevalue = (BigDecimal) ptSettleResultListItem.get("commissionFeevalue");
- if (commissionFeevalue == null) {
- // 处理commissionFeevalue为null的情况
- continue;
- }
- ptMap.put(month, commissionFeevalue);
- }
- for (HashMap<String, Object> ptResultListItem : ptResultList) {
- BigDecimal bigDecimal1 = ptMap.get(ptResultListItem.get("month"));
- ptResultListItem.put("readyCommissionFeevalue", bigDecimal1);
- BigDecimal commissionFeevalue = new BigDecimal(ptResultListItem.get("commissionFeevalue").toString());
- if (bigDecimal1 !=null && bigDecimal1.compareTo(BigDecimal.ZERO) > 0) {
- BigDecimal subtract = commissionFeevalue.subtract(bigDecimal1);
- ptResultListItem.put("noInvoicCommissionFeevalue", subtract);
- } else {
- ptResultListItem.put("noInvoicCommissionFeevalue", ptResultListItem.get("commissionFeevalue"));
- }
- }
- return HttpResult.ok(ptResultList);
- } else if ("2".equals(insPlyIncomeVo.getAgreementType())) {
- params.put("year", insPlyIncomeVo.getYear());
- List<HashMap<String, Object>> bxResultList = baseMapper.ptSumGroupByMonth(params);
- params.clear();
- params.put("settlementStatus", "2");
- List<HashMap<String, Object>> bxReadyCommissionFeevalue = settlementDocumentaryFeesService.bxSumGroupByMonth(params);
- Map<String, BigDecimal> bxMap = new HashMap<>(); // 假设commissionFeevalue是BigDecimal类型
- for (HashMap<String, Object> bxSettleResultListItem : bxReadyCommissionFeevalue) {
- String month = (String) bxSettleResultListItem.get("month");
- if (month == null) {
- // 处理month为null的情况
- continue;
- }
- BigDecimal commissionFeevalue = (BigDecimal) bxSettleResultListItem.get("commissionFeevalue");
- if (commissionFeevalue == null) {
- // 处理commissionFeevalue为null的情况
- continue;
- }
- bxMap.put(month, commissionFeevalue);
- }
- for (HashMap<String, Object> bxResultListItem : bxResultList) {
- BigDecimal bigDecimal1 = bxMap.get(bxResultListItem.get("month"));
- bxResultListItem.put("readyCommissionFeevalue", bigDecimal1);
- BigDecimal commissionFeevalue = new BigDecimal(bxResultListItem.get("commissionFeevalue").toString());
- if (bigDecimal1 !=null && bigDecimal1.compareTo(BigDecimal.ZERO) > 0) {
- BigDecimal subtract = commissionFeevalue.subtract(bigDecimal1);
- bxResultListItem.put("noInvoicCommissionFeevalue", subtract);
- } else {
- bxResultListItem.put("noInvoicCommissionFeevalue", bxResultListItem.get("commissionFeevalue"));
- }
- }
- return HttpResult.ok(bxResultList);
- }
- return HttpResult.ok();
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2024/8/1 9:28
- * @Description: 查询平台、私有数据
- */
- @Override
- public FinancialReceivablesAllVo queryDateByType(FinancialReceivablesQueryVo financialReceivablesQueryVo) {
- //检查参数
- if(StringUtils.isBlank(financialReceivablesQueryVo.getType())){
- throw new SystemException("应收类型不能为空,1为平台2为私有,默认传1");
- }
- int year =0;
- if(StringUtils.isBlank(financialReceivablesQueryVo.getYear())){
- Calendar cale = Calendar.getInstance();
- year = cale.get(Calendar.YEAR);
- }else{
- year = Integer.parseInt(financialReceivablesQueryVo.getYear());
- }
- List<FinancialReceivablesVo> list = new ArrayList<>();
- if("2".equals(financialReceivablesQueryVo.getType())){
- list.addAll(baseMapper.queryDateByType(financialReceivablesQueryVo)) ;
- }else {
- list.addAll(baseMapper.queryDateByTypePt(financialReceivablesQueryVo)) ;
- }
- financialReceivablesQueryVo.setBeginDate(SliceUpDateUtil.getYearBeginDateStr(year)+" 00:00:00");
- financialReceivablesQueryVo.setEndDate(SliceUpDateUtil.getYearEndDateStr(year)+" 23:59:59");
- //总应收
- financialReceivablesQueryVo.setType("1");
- BigDecimal ptSumAmount = baseMapper.queryDateByTypeSumAmount(financialReceivablesQueryVo);
- financialReceivablesQueryVo.setType("2");
- //总应收
- BigDecimal sySumAmount = baseMapper.queryDateByTypeSumAmount(financialReceivablesQueryVo);
- return new FinancialReceivablesAllVo(ptSumAmount !=null? ptSumAmount.toString(): "0",sySumAmount !=null ? sySumAmount.toString() : "0",year+"",list);
- }
- /**
- * @version
- * @author: whp
- * @Date: 2024/8/7
- * @Description: 私有 车险
- */
- @Override
- public FinancialReceivablesAllVo queryPrivateCar(FinancialReceivablesQueryVo financialReceivablesQueryVo) {
- int year =0;
- if(StringUtils.isBlank(financialReceivablesQueryVo.getYear())){
- Calendar cale = Calendar.getInstance();
- year = cale.get(Calendar.YEAR);
- }else{
- year = Integer.parseInt(financialReceivablesQueryVo.getYear());
- }
- FinancialReceivablesAllVo resultVo = new FinancialReceivablesAllVo();
- // 私有总金额
- financialReceivablesQueryVo.setBeginDate(SliceUpDateUtil.getYearBeginDateStr(year)+" 00:00:00");
- financialReceivablesQueryVo.setEndDate(SliceUpDateUtil.getYearEndDateStr(year)+" 23:59:59");
- // 私有应收
- BigDecimal syAmount = baseMapper.queryDateByTypeSumAmount(financialReceivablesQueryVo);
- if(syAmount!=null){
- resultVo.setSySumAmount(syAmount.toString());
- }
- resultVo.setYear(year+"");
- List<FinancialReceivablesVo> result= baseMapper.queryPrivateCar(financialReceivablesQueryVo);
- resultVo.setList(result);
- return resultVo;
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2024/8/5 9:56
- * @Description: 应收月份统计接口
- */
- @Override
- public FinancialReceivablesAllMonthVo queryDateByTypeByMonth(FinancialReceivablesQueryMonthVo financialReceivablesQueryVo) {
- //检查参数
- if (StringUtils.isBlank(financialReceivablesQueryVo.getType())) {
- throw new SystemException("应收类型不能为空,1为平台2为私有,默认传1");
- }
- //检查参数
- if (StringUtils.isBlank(financialReceivablesQueryVo.getYearAndMonth())) {
- throw new SystemException("月份不能为空");
- }
- String yearAndMonth = financialReceivablesQueryVo.getYearAndMonth();
- int year = Integer.parseInt(yearAndMonth.split("-")[0]);
- int month = Integer.parseInt(yearAndMonth.split("-")[1]);
- financialReceivablesQueryVo.setBeginDate(SliceUpDateUtil.getStartOfMonth(year, month));
- financialReceivablesQueryVo.setEndDate(SliceUpDateUtil.getEndOfMonth(year, month));
- //查询总数
- FinancialReceivablesAllMonthVo vo = baseMapper.queryDateByTypeByMonth(financialReceivablesQueryVo);
- if(vo!= null){
- // 第二层数据
- List<FinancialReceivablesMonthSignleVo> resultData = vo.getList();
- vo.setYearAndMonth(yearAndMonth);
- HashMap<String, BigDecimal> amountMap;
- if ("2".equals(financialReceivablesQueryVo.getType())) {
- amountMap = this.privateSett(resultData, financialReceivablesQueryVo);
- } else {
- amountMap = this.platformSett(resultData, financialReceivablesQueryVo);
- }
- vo.setYisSumAmount(amountMap.get("yishouAmount").toString());
- vo.setYsSumAmount(amountMap.get("yinshouAmount").toString());
- vo.setWsSumAmount(amountMap.get("weishouAmount").toString());
- }
- return vo;
- }
- private HashMap<String, BigDecimal> platformSett(List<FinancialReceivablesMonthSignleVo> resultData, FinancialReceivablesQueryMonthVo financialReceivablesQueryVo) {
- List<BigDecimal> yinShouAmountList = new ArrayList<>();
- List<BigDecimal> yishouAmountList = new ArrayList<>();
- List<BigDecimal> weishouAmountList = new ArrayList<>();
- BigDecimal yinshouAmount = new BigDecimal("0.00");
- BigDecimal yishouAmount = new BigDecimal("0.00");
- BigDecimal weishouAmount = new BigDecimal("0.00");
- HashMap<String, BigDecimal> resultMap = new HashMap<>();
- //平台手续费
- List<FinancialReceivablesMonthVo> handList = baseMapper.queryPlatHanding(financialReceivablesQueryVo);
- List<FinancialReceivablesMonthVo> patherIdList = baseMapper.getPatherId(financialReceivablesQueryVo);
- Map<String, List<FinancialReceivablesMonthVo>> groupedByPartnerCompaniesId = handList.stream()
- .collect(Collectors.groupingBy(FinancialReceivablesMonthVo::getPartnerCompaniesId));
- patherIdList.stream().filter(item -> groupedByPartnerCompaniesId.containsKey(item.getPartnerCompaniesId()))
- .forEach(item ->{
- List<FinancialReceivablesMonthVo> financialReceivablesMonthVosList = groupedByPartnerCompaniesId.get(item.getPartnerCompaniesId());
- FinancialReceivablesMonthSignleVo financialReceivablesMonthSignleVo = new FinancialReceivablesMonthSignleVo();
- List<FinancialReceivablesMonthVo> financialReceivablesMonthVos = financialReceivablesMonthSignleVo.getList();
- financialReceivablesMonthSignleVo.setCompanyName(item.getCompanyName());
- financialReceivablesMonthSignleVo.setAreaName(item.getAreaName());
- financialReceivablesMonthVos.addAll(financialReceivablesMonthVosList);
- resultData.add(financialReceivablesMonthSignleVo);
- financialReceivablesMonthVosList.forEach(financialReceivablesMonthVo ->{
- if("合计".equals(financialReceivablesMonthVo.getIsHand())){
- yinShouAmountList.add(this.stringToBigdecimal(financialReceivablesMonthVo.getCommissionFeevalue()));
- yishouAmountList.add(this.stringToBigdecimal(financialReceivablesMonthVo.getReadyCommissionFeevalue()));
- weishouAmountList.add(this.stringToBigdecimal(financialReceivablesMonthVo.getNoInvoicCommissionFeevalue()));
- }
- });
- });
- yinshouAmount = yinshouAmount.add(yinShouAmountList.stream().reduce(BigDecimal.ZERO, BigDecimal::add));
- yishouAmount = yishouAmount.add(yishouAmountList.stream().reduce(BigDecimal.ZERO, BigDecimal::add));
- weishouAmount = weishouAmount.add(weishouAmountList.stream().reduce(BigDecimal.ZERO, BigDecimal::add));
- resultMap.put("yinshouAmount",yinshouAmount);
- resultMap.put("yishouAmount",yishouAmount);
- resultMap.put("weishouAmount",weishouAmount);
- return resultMap;
- }
- private HashMap<String, BigDecimal> privateSett(List<FinancialReceivablesMonthSignleVo> resultData, FinancialReceivablesQueryMonthVo financialReceivablesQueryVo) {
- List<BigDecimal> yinShouAmountList = new ArrayList<>();
- List<BigDecimal> yishouAmountList = new ArrayList<>();
- List<BigDecimal> weishouAmountList = new ArrayList<>();
- BigDecimal yinshouAmount = new BigDecimal("0.00");
- BigDecimal yishouAmount = new BigDecimal("0.00");
- BigDecimal weishouAmount = new BigDecimal("0.00");
- HashMap<String, BigDecimal> resultMap = new HashMap<>();
- //手续费未接应收
- List<FinancialReceivablesMonthVo> list = baseMapper.queryDateByTypeByMonthList(financialReceivablesQueryVo);
- //跟单统计
- List<FinancialReceivablesMonthVo> otherList = baseMapper.queryDateByTypeByMonthOtherList(financialReceivablesQueryVo);
- Map<String, FinancialReceivablesMonthVo> otherCollect = otherList.stream().collect(Collectors.toMap(FinancialReceivablesMonthVo::getPartnerCompaniesId, Function.identity()));
- Map<String, FinancialReceivablesMonthVo> commCollect= list.stream().collect(Collectors.toMap(FinancialReceivablesMonthVo::getPartnerCompaniesId, Function.identity()));
- list.forEach(item -> {
- if(otherCollect.containsKey(item.getPartnerCompaniesId())){
- FinancialReceivablesMonthVo otherItem = otherCollect.get(item.getPartnerCompaniesId());
- FinancialReceivablesMonthSignleVo financialReceivablesMonthSignleVo = new FinancialReceivablesMonthSignleVo();
- List<FinancialReceivablesMonthVo> financialReceivablesMonthVos = financialReceivablesMonthSignleVo.getList();
- financialReceivablesMonthSignleVo.setCompanyName(item.getCompanyName());
- financialReceivablesMonthSignleVo.setAreaName(item.getAreaName());
- // 合计信息
- FinancialReceivablesMonthVo financialReceivablesMonthVo = new FinancialReceivablesMonthVo();
- financialReceivablesMonthVo.setCommissionFeevalue(this.calculateTotal(this.stringToBigdecimal(item.getCommissionFeevalue()), new BigDecimal(otherItem.getCommissionFeevalue()), null).toString());
- financialReceivablesMonthVo.setNoInvoicCommissionFeevalue(this.calculateTotal(this.stringToBigdecimal(item.getNoInvoicCommissionFeevalue()), new BigDecimal(otherItem.getNoInvoicCommissionFeevalue()), null).toString());
- financialReceivablesMonthVo.setReadyCommissionFeevalue(this.calculateTotal(this.stringToBigdecimal(item.getReadyCommissionFeevalue()), new BigDecimal(otherItem.getReadyCommissionFeevalue()), null).toString());
- financialReceivablesMonthVo.setSettlementAmount(this.calculateTotal(this.stringToBigdecimal(item.getSettlementAmount()), new BigDecimal(otherItem.getSettlementAmount()), null).toString());
- financialReceivablesMonthVo.setNoSettlementAmount(this.calculateTotal(this.stringToBigdecimal(item.getNoSettlementAmount()), new BigDecimal(otherItem.getNoSettlementAmount()), null).toString());
- financialReceivablesMonthVo.setIsHand("合计");
- financialReceivablesMonthVos.add(otherItem);
- financialReceivablesMonthVos.add(item);
- financialReceivablesMonthVos.add(financialReceivablesMonthVo);
- yishouAmountList.add(this.stringToBigdecimal(financialReceivablesMonthVo.getReadyCommissionFeevalue()));
- yinShouAmountList.add(this.stringToBigdecimal(financialReceivablesMonthVo.getCommissionFeevalue()));
- weishouAmountList.add(this.stringToBigdecimal(financialReceivablesMonthVo.getNoInvoicCommissionFeevalue()));
- resultData.add(financialReceivablesMonthSignleVo);
- }else {
- FinancialReceivablesMonthVo otherItem = new FinancialReceivablesMonthVo() ;
- otherItem.setIsHand("跟单费");
- otherItem.setCommissionFeevalue(BigDecimal.ZERO.toString());
- otherItem.setNoInvoicCommissionFeevalue(BigDecimal.ZERO.toString());
- otherItem.setReadyCommissionFeevalue(BigDecimal.ZERO.toString());
- otherItem.setSettlementAmount(BigDecimal.ZERO.toString());
- otherItem.setNoSettlementAmount(BigDecimal.ZERO.toString());
- FinancialReceivablesMonthSignleVo financialReceivablesMonthSignleVo = new FinancialReceivablesMonthSignleVo();
- List<FinancialReceivablesMonthVo> financialReceivablesMonthVos = financialReceivablesMonthSignleVo.getList();
- financialReceivablesMonthSignleVo.setCompanyName(item.getCompanyName());
- financialReceivablesMonthSignleVo.setAreaName(item.getAreaName());
- // 合计信息
- FinancialReceivablesMonthVo financialReceivablesMonthVo = new FinancialReceivablesMonthVo();
- financialReceivablesMonthVo.setCommissionFeevalue(this.calculateTotal(this.stringToBigdecimal(item.getCommissionFeevalue()), BigDecimal.ZERO, null).toString());
- financialReceivablesMonthVo.setNoInvoicCommissionFeevalue(this.calculateTotal(this.stringToBigdecimal(item.getNoInvoicCommissionFeevalue()), BigDecimal.ZERO, null).toString());
- financialReceivablesMonthVo.setReadyCommissionFeevalue(this.calculateTotal(this.stringToBigdecimal(item.getReadyCommissionFeevalue()), BigDecimal.ZERO, null).toString());
- financialReceivablesMonthVo.setSettlementAmount(this.calculateTotal(this.stringToBigdecimal(item.getSettlementAmount()), BigDecimal.ZERO, null).toString());
- financialReceivablesMonthVo.setNoSettlementAmount(this.calculateTotal(this.stringToBigdecimal(item.getNoSettlementAmount()), BigDecimal.ZERO, null).toString());
- financialReceivablesMonthVo.setIsHand("合计");
- financialReceivablesMonthVos.add(otherItem);
- financialReceivablesMonthVos.add(item);
- financialReceivablesMonthVos.add(financialReceivablesMonthVo);
- yishouAmountList.add(this.stringToBigdecimal(financialReceivablesMonthVo.getReadyCommissionFeevalue()));
- yinShouAmountList.add(this.stringToBigdecimal(financialReceivablesMonthVo.getCommissionFeevalue()));
- weishouAmountList.add(this.stringToBigdecimal(financialReceivablesMonthVo.getNoInvoicCommissionFeevalue()));
- resultData.add(financialReceivablesMonthSignleVo);
- }
- }
- );
- yinshouAmount = yinshouAmount.add(yinShouAmountList.stream().reduce(BigDecimal.ZERO, BigDecimal::add));
- yishouAmount = yishouAmount.add(yishouAmountList.stream().reduce(BigDecimal.ZERO, BigDecimal::add));
- weishouAmount = weishouAmount.add(weishouAmountList.stream().reduce(BigDecimal.ZERO, BigDecimal::add));
- resultMap.put("yinshouAmount",yinshouAmount);
- resultMap.put("yishouAmount",yishouAmount);
- resultMap.put("weishouAmount",weishouAmount);
- return resultMap;
- }
- private BigDecimal stringToBigdecimal(String value) {
- return new BigDecimal(value).setScale(5, RoundingMode.DOWN);
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2024/8/7 11:20
- * @Description: 修正协议变动重新生成数据逻辑
- */
- @Override
- public HttpResult<List<InsPlyIncome>> createData(InsPlyIncomeIdsVo insPlyIncomeIdsVo) {
- if(insPlyIncomeIdsVo.getIds()==null || insPlyIncomeIdsVo.getIds().size()==0){
- throw new SystemException("子订单id不能为空!!");
- }
- List<String> ids = insPlyIncomeIdsVo.getIds();
- List<InsPlyIncome> newList=new ArrayList<>();
- for(String subOrderId:ids){
- //查询子订单对象 com.ydtech.modules.order.entity
- InsAreaCompany insAreaCompany = fncInsAreaCompanyMapper.selectById(subOrderId);
- //大订单对象
- InsOrders order = insOrdersService.existOrder(insAreaCompany.getOrderno());
- SysUser sysUser = sysUserService.getById(order.getUserid());
- //获取该订单的费用
- InsFeeOrderNew insFeeOrderNew = insFeeOrderNewService.getOne(new LambdaQueryWrapper<InsFeeOrderNew>()
- .eq(InsFeeOrderNew::getInsOrderNo, insAreaCompany.getId()));
- saveBalanceNew(order, insFeeOrderNew,insAreaCompany, sysUser.getLeaderId(), sysUser.getLeaderName()) ;
- }
- return HttpResult.ok(newList);
- }
- @Override
- public List<InsuranceHandlingSettlementMonthDto> getInvociAmount(InsuranceHandlingSettlementMonthVo insuranceHandlingSettlementMonthVo) {
- return baseMapper.getInvociAmount(insuranceHandlingSettlementMonthVo);
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2024/9/20 9:58
- * @Description: 平台结算情况统计
- */
- @Override
- public List<InsPlyIncomePTDto> totalPTAmount(InsPlyIncomePTVo insPlyIncomeVo) {
- return baseMapper.totalPTAmount(insPlyIncomeVo);
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2024/9/20 11:01
- * @Description: 通过结算人查询保险公司结算数据
- */
- @Override
- public List<InsPlyIncomePTCompanyDto> findListByDockingPerson(InsPlyIncomeQueryPTVo insPlyIncomeVo) {
- return baseMapper.findListByDockingPerson(insPlyIncomeVo);
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2024/9/21 14:14
- * @Description: 批量导入
- */
- @Override
- public void importDataAddType(MultipartFile file, String type) throws Exception {
- List<InsPlyIncome> list =new ArrayList<InsPlyIncome>();
- //导入验证
- if("1".equals(type)){
- //车险手续费
- List<AddTypeCXSXFExcel> dtoList = ExcelEasypoiUtils.importExcel(file, AddTypeCXSXFExcel.class, 0, 1, 1);
- try{
- list=checkData(type,dtoList,null,null,null,null);
- }catch(SystemException e){
- throw new SystemException(e.getMessage());
- }
- }else if("2".equals(type)){
- //车险跟单
- List<AddTypeCXGDExcel> dtoList = ExcelEasypoiUtils.importExcel(file, AddTypeCXGDExcel.class, 0, 1, 1);
- try{
- list=checkData(type,null,dtoList,null,null,null);
- }catch(SystemException e){
- throw new SystemException(e.getMessage());
- }
- }else if("3".equals(type)){
- //非车手续费
- List<AddTypeFCSXFExcel> dtoList = ExcelEasypoiUtils.importExcel(file, AddTypeFCSXFExcel.class, 0, 1, 1);
- try{
- list=checkData(type,null,null,dtoList,null,null);
- }catch(SystemException e){
- throw new SystemException(e.getMessage());
- }
- }else if("4".equals(type)){
- //非车跟单
- List<AddTypeFCGDExcel> dtoList = ExcelEasypoiUtils.importExcel(file, AddTypeFCGDExcel.class, 0, 1, 1);
- try{
- list=checkData(type,null,null,null,dtoList,null);
- }catch(SystemException e){
- throw new SystemException(e.getMessage());
- }
- }
- else if("5".equals(type)){
- //平台结算
- List<AddTypePTJSExcel> dtoList = ExcelEasypoiUtils.importExcel(file, AddTypePTJSExcel.class, 0, 1, 1);
- try{
- list=checkData(type,null,null,null,null,dtoList);
- }catch(SystemException e){
- throw new SystemException(e.getMessage());
- }
- }
- //批量插入
- if(list!=null && list.size()>0){
- this.saveBatch(list);
- }
- }
- /** 批量修改 手续费金额
- *
- * @param multipartFile
- * @param isNotCar 是否是非车
- * @return
- */
- @Override
- public HashMap<String, Object> insuranceHandlingFeeBathUpdate(MultipartFile multipartFile, String isNotCar) {
- HashMap<String, Object> resultMap = new HashMap<>();
- List<HashMap<String, Object>> resultList = new ArrayList<>();
- HashMap<String, Object> params = new HashMap<>();
- BigDecimal allAmount = BigDecimal.ZERO;
- params.put("isNotCar", isNotCar);
- try {
- List<InsBxPlyIncomeExcelDto> dtoList = ExcelEasypoiUtils.importExcel(multipartFile, InsBxPlyIncomeExcelDto.class, 0, 1, 1);
- for (InsBxPlyIncomeExcelDto item : dtoList) {
- if (StringUtils.isNotEmpty(item.getLicenseno())) {
- params.put("licenseno", item.getLicenseno());
- }
- if (StringUtils.isNotEmpty(item.getPolicyno())) {
- params.put("policyno", item.getPolicyno());
- }
- if (StringUtils.isNotEmpty(item.getSyPolicyno())) {
- params.put("syPolicyno", item.getSyPolicyno());
- }
- params.put("handlingFeesStatus", "0");
- params.put("isOther", "0");
- params.put("isNotCar", "0");
- InsPlyIncome byBxLicenseno = baseMapper.findByBxLicenseno(params);
- if (item.getJqSuperviseCostsProportion() == null) {
- item.setJqSuperviseCostsProportion(BigDecimal.ZERO);
- }
- if (item.getSySuperviseCostsProportion() == null) {
- item.setSySuperviseCostsProportion(BigDecimal.ZERO);
- }
- if (ObjectUtils.isNotEmpty(byBxLicenseno) && (byBxLicenseno.getJqOtherCostsProportion().compareTo(item.getJqSuperviseCostsProportion()) != 0 || byBxLicenseno.getSySuperviseCostsProportion().compareTo(item.getSySuperviseCostsProportion()) != 0)) {
- // 如果比例不相等
- BigDecimal jqSuperviseCostsProportion = item.getJqSuperviseCostsProportion();
- BigDecimal sySuperviseCostsProportion = item.getSySuperviseCostsProportion();
- BigDecimal jqSupervisePremium = getBigDecimal( byBxLicenseno.getJqPremium(),jqSuperviseCostsProportion);
- BigDecimal sySupervisePremium = getBigDecimal( byBxLicenseno.getSyPremium(),sySuperviseCostsProportion);
- HashMap<String, Object> map = new HashMap<>();
- map.put("licenseno", item.getLicenseno());
- map.put("policyno", item.getPolicyno());
- map.put("syPolicyno", item.getSyPolicyno());
- map.put("jqSuperviseCostsPremiums", jqSupervisePremium);
- map.put("sySuperviseCostsPremiums", sySupervisePremium);
- map.put("jqSuperviseCostsProportion", jqSuperviseCostsProportion);
- map.put("sySuperviseCostsProportion", sySuperviseCostsProportion);
- map.put("id", byBxLicenseno.getId());
- resultList.add(map);
- allAmount = allAmount.add(jqSupervisePremium).add(sySupervisePremium);
- }
- }
- resultMap.put("allAmount", allAmount);
- resultMap.put("resultList", resultList);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- return resultMap;
- }
- /**
- * 保险手续费批量修改
- * @param insPlyIncomeVo
- */
- @Override
- @Transactional
- public void insuranceHandlingFeeBathConfirm(InsPlyIncomeVo insPlyIncomeVo) {
- if (ObjectUtils.isEmpty(insPlyIncomeVo)) {
- throw new SystemException("请导入文件");
- }
- if(CollectionUtils.isEmpty(insPlyIncomeVo.getResultList())){
- throw new SystemException("请导入文件");
- }
- ArrayList<InsPlyIncome> batchUpdateItem = new ArrayList<>();
- for (InsPlyIncome item : insPlyIncomeVo.getResultList()) {
- InsPlyIncomeLog insPlyIncomeLog = new InsPlyIncomeLog();
- insPlyIncomeLog.setIncomeId(item.getId());
- BeanUtils.copyProperties(item, insPlyIncomeLog);
- insPlyIncomeLog.setOperationStatus("2");
- insPlyIncomeLog.setId(null);
- insPlyIncomeLogService.saveLog(insPlyIncomeLog); //添加日志
- item.setAllFeeValue(this.calculateTotal(item.getJqSuperviseCostsPremiums(), item.getSySuperviseCostsPremiums(), null));
- item.setCommissionFeevalue(this.calculateTotal(item.getJqSuperviseCostsPremiums(), item.getSySuperviseCostsPremiums(), null));
- item.setCommissionFeerate(this.calculateTotal(item.getJqSuperviseCostsProportion(), item.getSySuperviseCostsProportion(), null));
- batchUpdateItem.add(item);
- // baseMapper.updateById(item);
- }
- this.saveOrUpdateBatch(batchUpdateItem);
- }
- @Override
- public HashMap<String, Object> insuranceHandlingFeeBathNotCarImport(MultipartFile multipartFile, String isNotCar) {
- HashMap<String, Object> resultMap = new HashMap<>();
- List<HashMap<String, Object>> resultList = new ArrayList<>();
- HashMap<String, Object> params = new HashMap<>();
- BigDecimal allAmount = BigDecimal.ZERO;
- params.put("isNotCar", isNotCar);
- try {
- List<InsBxNoPlyIncomeExcelDto> dtoList = ExcelEasypoiUtils.importExcel(multipartFile, InsBxNoPlyIncomeExcelDto.class, 0, 1, 1);
- for (InsBxNoPlyIncomeExcelDto item : dtoList) {
- if (StringUtils.isNotEmpty(item.getLicenseno())) {
- params.put("licenseno", item.getLicenseno());
- }
- if (StringUtils.isNotEmpty(item.getNoPolicyno())) {
- params.put("noPolicyno", item.getNoPolicyno());
- }
- params.put("handlingFeesStatus", "0");
- params.put("isOther", "0");
- params.put("isNotCar", "1");
- InsPlyIncome byBxLicenseno = baseMapper.findByBxLicenseno(params);
- if (item.getNoSuperviseCostsProportion() == null) {
- item.setNoSuperviseCostsProportion(BigDecimal.ZERO);
- }
- if (ObjectUtils.isNotEmpty(byBxLicenseno) && (byBxLicenseno.getNoSuperviseCostsProportion().compareTo(item.getNoSuperviseCostsProportion()) != 0 )) {
- // 如果比例不相等
- BigDecimal noSuperviseCostsProportion = item.getNoSuperviseCostsProportion();
- BigDecimal noSuperviseCostsPremiums = getBigDecimal(byBxLicenseno.getNoPremium(),noSuperviseCostsProportion);
- HashMap<String, Object> map = new HashMap<>();
- map.put("licenseno", item.getLicenseno());
- map.put("noPolicyno", item.getNoPolicyno());
- map.put("noSuperviseCostsPremiums", noSuperviseCostsPremiums);
- map.put("noSuperviseCostsProportion", noSuperviseCostsProportion);
- map.put("id", byBxLicenseno.getId());
- resultList.add(map);
- allAmount = allAmount.add(noSuperviseCostsPremiums);
- }
- }
- resultMap.put("allAmount", allAmount);
- resultMap.put("resultList", resultList);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- return resultMap;
- }
- /**
- * 保险手续费批量修改
- * @param insPlyIncomeVo
- */
- @Override
- @Transactional
- public void insuranceHandlingNotCarFeeBathConfirm(InsPlyIncomeVo insPlyIncomeVo) {
- if (ObjectUtils.isEmpty(insPlyIncomeVo)) {
- throw new SystemException("请导入文件");
- }
- if(CollectionUtils.isEmpty(insPlyIncomeVo.getResultList())){
- throw new SystemException("请导入文件");
- }
- ArrayList<InsPlyIncome> batchUpdateItem = new ArrayList<>();
- for (InsPlyIncome item : insPlyIncomeVo.getResultList()) {
- InsPlyIncomeLog insPlyIncomeLog = new InsPlyIncomeLog();
- insPlyIncomeLog.setIncomeId(item.getId());
- BeanUtils.copyProperties(item, insPlyIncomeLog);
- insPlyIncomeLog.setOperationStatus("2");
- insPlyIncomeLog.setId(null);
- insPlyIncomeLogService.saveLog(insPlyIncomeLog); //添加日志
- item.setAllFeeValue(this.calculateTotal(item.getNoSuperviseCostsPremiums(), null, null));
- item.setCommissionFeevalue(this.calculateTotal(item.getNoSuperviseCostsPremiums(), null, null));
- item.setCommissionFeerate(this.calculateTotal(item.getNoSuperviseCostsProportion(), null, null));
- batchUpdateItem.add(item);
- // baseMapper.updateById(item);
- }
- this.saveOrUpdateBatch(batchUpdateItem);
- }
- public List<InsPlyIncome> checkData(String type,List<AddTypeCXSXFExcel> cxsxfList,List<AddTypeCXGDExcel> cxgdList, List<AddTypeFCSXFExcel> fcsxfList, List<AddTypeFCGDExcel> fcgdList,List<AddTypePTJSExcel> ptjsList) throws SystemException{
- List<InsPlyIncome> list =new ArrayList<InsPlyIncome>();
- if("1".equals(type)){
- int index=1;
- //车险手续费
- if(cxsxfList!=null && cxsxfList.size()>0){
- for(AddTypeCXSXFExcel dto : cxsxfList){
- index++;
- Map<String, Object> map = CheckInsPlyComeUtils.checkDataDto1(dto);
- if(!"".equals(map.get("msg"))){
- throw new SystemException("第" + index + "行数据" + map.get("msg").toString());
- }else{
- InsPlyIncome insPlyIncome = (InsPlyIncome)map.get("dto");
- list.add(insPlyIncome);
- }
- }
- }
- }else if("2".equals(type)){
- int index=1;
- //车险跟单
- if(cxgdList!=null && cxgdList.size()>0){
- for(AddTypeCXGDExcel dto : cxgdList){
- index++;
- Map<String, Object> map = CheckInsPlyComeUtils.checkDataDto2(dto);
- if(!"".equals(map.get("msg"))){
- throw new SystemException("第" + index + "行数据" + map.get("msg").toString());
- }else{
- InsPlyIncome insPlyIncome = (InsPlyIncome)map.get("dto");
- list.add(insPlyIncome);
- }
- }
- }
- }else if("3".equals(type)){
- int index=1;
- if(fcsxfList!=null && fcsxfList.size()>0){
- for(AddTypeFCSXFExcel dto : fcsxfList){
- index++;
- Map<String, Object> map = CheckInsPlyComeUtils.checkDataDto3(dto);
- if(!"".equals(map.get("msg"))){
- throw new SystemException("第" + index + "行数据" + map.get("msg").toString());
- }else{
- InsPlyIncome insPlyIncome = (InsPlyIncome)map.get("dto");
- list.add(insPlyIncome);
- }
- }
- }
- }else if("4".equals(type)){
- int index=1;
- if(fcgdList!=null && fcgdList.size()>0){
- for(AddTypeFCGDExcel dto : fcgdList){
- index++;
- Map<String, Object> map = CheckInsPlyComeUtils.checkDataDto4(dto);
- if(!"".equals(map.get("msg"))){
- throw new SystemException("第" + index + "行数据" + map.get("msg").toString());
- }else{
- InsPlyIncome insPlyIncome = (InsPlyIncome)map.get("dto");
- list.add(insPlyIncome);
- }
- }
- }
- }
- else if("5".equals(type)){
- int index=1;
- if(ptjsList!=null && ptjsList.size()>0){
- for(AddTypePTJSExcel dto : ptjsList){
- index++;
- Map<String, Object> map = CheckInsPlyComeUtils.checkDataDto5(dto);
- if(!"".equals(map.get("msg"))){
- throw new SystemException("第" + index + "行数据" + map.get("msg").toString());
- }else{
- InsPlyIncome insPlyIncome = (InsPlyIncome)map.get("dto");
- list.add(insPlyIncome);
- }
- }
- }
- }
- return list;
- }
- }
|