| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763 |
- package com.ydtech.modules.ins.service.impl;
- import com.alibaba.fastjson.JSONObject;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.fasterxml.jackson.annotation.JsonInclude;
- import com.fasterxml.jackson.core.JsonProcessingException;
- import com.fasterxml.jackson.databind.*;
- import com.fasterxml.jackson.dataformat.xml.XmlMapper;
- import com.ydtech.components.InsAlltrustRequestApiComponents;
- import com.ydtech.constants.InsTaskHistoryEnum;
- import com.ydtech.constants.enums.InsOrderStatus;
- import com.ydtech.constants.enums.InsQuoteFlow;
- import com.ydtech.constants.enums.dict.AttachInsureEnum;
- import com.ydtech.constants.enums.dict.WhetherEnum;
- import com.ydtech.core.page.HttpResult;
- import com.ydtech.exception.SystemException;
- import com.ydtech.modules.admin.service.SysDeptService;
- import com.ydtech.modules.admin.service.SysUserService;
- import com.ydtech.modules.esm.dao.EsmInsAttachInsureDetailsMapper;
- import com.ydtech.modules.esm.dao.EsmInsAttachInsureMapper;
- import com.ydtech.modules.esm.model.*;
- import com.ydtech.modules.esm.service.*;
- import com.ydtech.modules.ins.dao.InsAlltrustRegionMapper;
- import com.ydtech.modules.ins.model.InsApiLog;
- import com.ydtech.modules.ins.model.vo.CarInfoVo;
- import com.ydtech.modules.ins.model.vo.CustomerInfoVo;
- import com.ydtech.modules.ins.model.vo.QuoteRespVo;
- import com.ydtech.modules.ins.model.vo.RiskInfoVo;
- import com.ydtech.modules.ins.model.ya.CarModelDTO;
- import com.ydtech.modules.ins.model.ya.CarModel_Req;
- import com.ydtech.modules.ins.model.ya.YaQuoteInfoVo;
- import com.ydtech.modules.ins.model.yc.*;
- import com.ydtech.modules.ins.model.yc.accident.response.ResponseYwCvrg;
- import com.ydtech.modules.ins.model.yc.audit.Audit;
- import com.ydtech.modules.ins.model.yc.audit.response.AuditResponse;
- import com.ydtech.modules.ins.model.yc.callbackAnOrder.CallbackAnOrder;
- import com.ydtech.modules.ins.model.yc.imageUp.ImageUp;
- import com.ydtech.modules.ins.model.yc.imageUp.response.ImageUpResponse;
- import com.ydtech.modules.ins.model.yc.modelsQuery.ModelsQueryResponse;
- import com.ydtech.modules.ins.model.yc.modelsQuery.ModelsQueryXml;
- import com.ydtech.modules.ins.model.yc.accident.Accident;
- import com.ydtech.modules.ins.model.yc.pay.Pay;
- import com.ydtech.modules.ins.model.yc.pay.response.AccidentResponse;
- import com.ydtech.modules.ins.model.yc.pay.response.PayResponse;
- import com.ydtech.modules.ins.model.yc.policy.Policy;
- import com.ydtech.modules.ins.model.yc.policy.response.PolicyResponse;
- import com.ydtech.modules.ins.model.yc.ruote.*;
- import com.ydtech.modules.ins.model.yc.ruote.response.RuoteResponse;
- import com.ydtech.modules.ins.service.*;
- import com.ydtech.modules.order.components.ConfigureParametersComponents;
- import com.ydtech.modules.order.components.InsOrdersComponents;
- import com.ydtech.modules.order.entity.InsAreaCompany;
- import com.ydtech.modules.order.entity.InsOrders;
- import com.ydtech.modules.order.entity.vo.*;
- import com.ydtech.modules.order.service.InsAreaCompanyService;
- import com.ydtech.modules.order.service.InsOrdersService;
- import com.ydtech.utils.*;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.BeanUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import java.io.IOException;
- import java.math.BigDecimal;
- import java.text.SimpleDateFormat;
- import java.time.LocalDate;
- import java.time.LocalDateTime;
- import java.util.*;
- import java.util.concurrent.atomic.AtomicInteger;
- @Service
- public class InsAlltrustApiServiceImpl implements InsAlltrustApiService {
- private static final Logger log = LoggerFactory.getLogger("alltrust");
- @Autowired
- private InsAlltrustRequestApiComponents apiComponents;
- @Autowired
- private InsAlltrustRegionMapper insAlltrustRegionMapper;
- @Autowired
- private InsOrdersComponents insOrdersComponents;
- private AuthorityDataXml authorityDataXml = null;
- private ObjectMapper xmlMapper = null;
- @Autowired
- private YcBuildData ycBuildData;
- @Autowired
- private SysUserService sysUserService;
- @Autowired
- private SysDeptService sysDeptService;
- @Autowired
- private EsmRetailService esmRetailService;
- @Autowired
- private EsmAgreementService esmAgreementService;
- @Autowired
- private EsmAgreementProdService esmAgreementProdService;
- // @Autowired
- // private EsmUserInternalService esmUserInternalService;
- @Autowired
- private InsTaskHistoryService insTaskHistoryService;
- @Autowired
- private InsAreaCompanyService insAreaCompanyService;
- @Autowired
- private InsOrdersService insOrdersService;
- @Autowired
- private InsTaskImageService insTaskImageService;
- @Autowired
- private EsmInsAttachInsureMapper esmInsAttachInsureMapper;
- @Autowired
- private EsmInsAttachInsureDetailsMapper esmInsAttachInsureDetailsMapper;
- @Autowired
- private EsmInsCompanyService esmInsCompanyService;
- @Autowired
- InsApiLogService insApiLogService;
- @Autowired
- ConfigureParametersComponents configureParametersComponents;
- // /**
- // * @description: 获取验证数据
- // * @author: lig
- // * @date: 2023年02月07日 0007
- // */
- // private AuthorityDataXml gainAuthorityDataXml() {
- // if (null == authorityDataXml) {
- // authorityDataXml = new AuthorityDataXml();
- // authorityDataXml.setUserName(apiComponents.getUserName());
- // authorityDataXml.setPassword(apiComponents.getPassword());
- // }
- // return authorityDataXml;
- // }
- // /**
- // * 获取渠道
- // */
- // public Agent gainAgent() {
- // return apiComponents.gainAgent();
- //// if (null == agent) {
- //// agent = new Agent();
- //// agent.setAgentCode(agentCode);
- //// agent.setConferCode(agentType);
- //// agent.setAgentType(agentType);
- //// agent.setAgentNme(agentNme);
- //// agent.setQlftNo(qlftNo);
- //// agent.setCustNature(custNature);
- //// agent.setAgentProfId(agentCode);
- //// agent.setSubCoNo(agentType);
- //// }
- //// return agent;
- // }
- private ObjectMapper gainXmlMapper() {
- if (null == xmlMapper) {
- xmlMapper = new XmlMapper();
- xmlMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- xmlMapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false);
- xmlMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
- xmlMapper.setPropertyNamingStrategy(PropertyNamingStrategy.UPPER_CAMEL_CASE);
- xmlMapper.enable(MapperFeature.USE_STD_BEAN_NAMING);
- xmlMapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);
- }
- return xmlMapper;
- }
- //
- //==============================API 方式
- //
- /**
- * 1 车型查询接口
- */
- @Override
- public HttpResult modelsQueryApi(CarModel_Req carModelReq) {
- // if (org.springframework.util.StringUtils.isEmpty(carModelReq.getFrameNo()) || org.springframework.util.StringUtils.isEmpty(carModelReq.getEnrollDate()) || org.springframework.util.StringUtils.isEmpty(carModelReq.getModelName())) {
- // return HttpResult.error("frameNo, enrollDate, modelName 这些参数不能为空!");
- // }
- // gainAuthorityDataXml(), apiComponents.gainAgent()
- // 获取协议配置信息
- YcConfigureParameters ycConfigureParameters = gainYcConfigParams(carModelReq.getAgreementId());
- ModelsQueryXml m = buildModelsQueryParam(carModelReq, ycConfigureParameters);
- ObjectMapper xmlMapper = this.gainXmlMapper();
- log.info("===永诚--车型查询接口请求开始===");
- InsApiLog apiLog = httpPost(xmlMapper, m, YcBuildData.API_MODEL);
- String responseData = apiLog.getResponseData();
- log.info("===永诚--车型查询接口请求结束===");
- try {
- String cleanStr = YcBuildData.cleanResponseStr(responseData);
- ModelsQueryResponse rd = xmlMapper.readValue(cleanStr, ModelsQueryResponse.class);
- if (rd.getReturnCode().equals("E0001")) {
- return HttpResult.ok(rd.getMsg());
- }
- return HttpResult.ok(buildCarModel(rd));
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- @Override
- public List<ModelsQueryResponse.VehicleInfo> modelsQuery(CarModel_Req carModelReq) {
- // public List<CarModelDTO> modelsQuery(CarModel_Req carModelReq) {
- // 获取协议配置信息
- YcConfigureParameters ycConfigureParameters = gainYcConfigParams(carModelReq.getAgreementId());
- ModelsQueryXml m = buildModelsQueryParam(carModelReq, ycConfigureParameters);
- ObjectMapper xmlMapper = this.gainXmlMapper();
- log.info("===永诚--车型查询接口请求开始===");
- InsApiLog apiLog = httpPost(xmlMapper, m, YcBuildData.API_MODEL);
- String responseData = apiLog.getResponseData();
- log.info("===永诚--车型查询接口请求结束===");
- try {
- String cleanStr = YcBuildData.cleanResponseStr(responseData);
- ModelsQueryResponse rd = xmlMapper.readValue(cleanStr, ModelsQueryResponse.class);
- return buildCarModel(rd);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- public void gainVehicleModel(YcConfigureParameters ycConfigureParameters, CarInfoVo carInfo) {
- CarModel_Req carModelReq = new CarModel_Req();
- carModelReq.setFrameNo(carInfo.getFrameNo());
- carModelReq.setEngineNo(carInfo.getEngineNo());
- carModelReq.setEnrollDate(carInfo.getRegisterDate().replaceAll("-",""));
- log.info("===永诚--车型查询接口请求 =====参数确认:--"+ycConfigureParameters.getDptCde()+"===");
- ModelsQueryXml m = buildModelsQueryParam(carModelReq, ycConfigureParameters);
- ObjectMapper xmlMapper = this.gainXmlMapper();
- log.info("===永诚--车型查询接口请求开始--"+carInfo.getLicenseNo()+"===");
- InsApiLog apiLog = httpPost(xmlMapper, m, YcBuildData.API_MODEL);
- String responseData = apiLog.getResponseData();
- log.info("===永诚--车型查询接口请求结束--"+carInfo.getLicenseNo()+"===");
- try {
- String cleanStr = YcBuildData.cleanResponseStr(responseData);
- ModelsQueryResponse rd = xmlMapper.readValue(cleanStr, ModelsQueryResponse.class);
- List<ModelsQueryResponse.VehicleInfo> vehicleInfoList = buildCarModel(rd);
- BigDecimal matchNum = BigDecimal.ZERO;
- //匹配车辆信息
- vehicleInfoList.stream().forEach(a ->{
- //购置价匹配
- if(a.getVehiclePrice().equals(carInfo.getPurchasePrice())){
- carInfo.setModelCode(a.getVehicleId());
- // carInfo.setCiModelCode(a.getModelCode());
- carInfo.setCiCarName(a.getVehicleName());
- carInfo.setModelcname(a.getVehicleName());
- matchNum.add(BigDecimal.ONE);
- }
- });
- //未匹配
- if(matchNum == BigDecimal.ZERO){
- carInfo.setModelCode(vehicleInfoList.get(0).getVehicleId());
- // carInfo.setCiModelCode(a.getModelCode());
- carInfo.setCiCarName(vehicleInfoList.get(0).getVehicleName());
- carInfo.setModelcname(vehicleInfoList.get(0).getVehicleName());
- }
- // long count = vehicleInfoList.stream().filter(x -> x.getModelCode().equals(carInfo.getModelCode())).count();
- //
- // if(count < 1 ){
- //
- // }
- } catch (IOException e) {
- throw new SystemException("车型查询接口异常,请联系管理。");
- }
- }
- /**
- * 2 报价
- */
- @Override
- public HttpResult quoteApi(BaseQuoteVo<AccidentalDrivingVo> quoteVo) {
- // 获取协议配置信息
- YcConfigureParameters ycConfigureParameters = gainYcConfigParams(quoteVo.getAgreementId());
- BaseQuoteInfoVo yaQuoteInfoVo = insOrdersComponents.getQuoteInfo(quoteVo.getOrderNo());
- //构造车辆信息
- gainVehicleModel(ycConfigureParameters, yaQuoteInfoVo.getCarInfo());
- HttpResult httpResult = new HttpResult();
- ObjectMapper xmlMapper = this.gainXmlMapper();
- InsAreaCompany iac = null;
- InsOrders order = insOrdersService.getById(yaQuoteInfoVo.getOrderNo());
- AccidentalDrivingVo adVo = quoteVo.getAccidentalDrivingVo();
- //1.1必填校验
- checkEmpty(yaQuoteInfoVo);
- //组装参数
- Ruote m = Ruote.buildQuoteParam(yaQuoteInfoVo, ycConfigureParameters, apiComponents, adVo);
- //构造地区
- buildRegion(m);
- // //请求转保处理
- // if (StringUtils.isNotEmpty(quoteVo.getRenewalCodeJq()) || StringUtils.isNotEmpty(quoteVo.getRenewalCodeSy())) {
- // m.getRequestLabel().getCondition().getVhl().setCCheckCodeJQ(quoteVo.getRenewalCodeJq());
- // m.getRequestLabel().getCondition().getVhl().setCCheckCodeSY(quoteVo.getRenewalCodeSy());
- // m.getRequestLabel().getCondition().getVhl().setCBusType("2");
- // m.getRequestLabel().getCondition().getVhl().setCQryCdeJQ(quoteVo.getCQryCdeJq());
- // m.getRequestLabel().getCondition().getVhl().setCQryCdeSY(quoteVo.getCQryCdeSy());
- //
- // }
- RuoteResponse rr = requestApi(m, new RuoteResponse(), iac, YcBuildData.API_QUOTE, InsQuoteFlow.Q_S_0);
- if (null == rr) return HttpResult.error("远程请求报价失败");
- if (!rr.getHead().getErrorCode().equals("000000")) return HttpResult.error(rr.getHead().getErrorMessage());
- RuoteResponse rr2 = quoteExternalApi(rr,quoteVo,iac,m);
- if (!rr2.getHead().getErrorCode().equals("000000")) return HttpResult.error(rr2.getHead().getErrorMessage());
- QuoteRespVo quoteRespVo = YcBuildData.buildQuoteRespVo(order, rr2, yaQuoteInfoVo);
- //8 生成订单
- iac = response_order(order, quoteRespVo, m, rr2, quoteVo);
- // updateApiLog(apiLog, iac);
- quoteRespVo.setCompanyId(iac.getId());
- return HttpResult.ok("报价成功", quoteRespVo);
- }
- /**
- * 报价响应处理
- */
- public RuoteResponse quoteExternalApi(RuoteResponse rr,BaseQuoteVo<AccidentalDrivingVo> quoteVo,InsAreaCompany iac,Ruote m ) {
- int i = 0;
- if (rr.getHead().getErrorCode().equals("000000") && i < 3) {
- i++;
- String cCheckCodeJQ = rr.getVhl().getCCheckCodeJQ();
- String cCheckCodeSY = rr.getVhl().getCCheckCodeSY();
- //转保调用自动识别转保码
- if (StringUtils.isNotEmpty(cCheckCodeJQ) || StringUtils.isNotEmpty(cCheckCodeSY)) {
- //调用python ocr
- String sendBody = "";
- Map bodyMap = new HashMap();
- bodyMap.put("jqImage", StringUtils.isNotEmpty(cCheckCodeJQ) ? cCheckCodeJQ : "");
- bodyMap.put("syImage", StringUtils.isNotEmpty(cCheckCodeSY) ? cCheckCodeSY : "");
- sendBody = JsonUtils.toJson(bodyMap);
- String ocrStr = HttpUtil.sendPost("http://47.92.254.66:8088/getres", sendBody);
- Map ocrMap = JsonUtils.toObject(ocrStr, Map.class);
- m.getRequestLabel().getCondition().getVhl().setCBusType("2");
- //交强
- m.getRequestLabel().getCondition().getVhl().setCCheckCodeJQ(ocrMap.get("jqImageCode").toString());
- // m.getRequestLabel().getCondition().getVhl().setCCheckCodeJQ(ocrMap.get("jqImageCode").toString());
- m.getRequestLabel().getCondition().getVhl().setCQryCdeJQ(rr.getVhl().getCQryCdeJQ());
- //商业
- m.getRequestLabel().getCondition().getVhl().setCCheckCodeSY(ocrMap.get("syImageCode").toString());
- m.getRequestLabel().getCondition().getVhl().setCQryCdeSY(rr.getVhl().getCQryCdeSY());
- // return requestApi(m, new RuoteResponse(), iac, YcBuildData.API_QUOTE, InsQuoteFlow.Q_S_0);
- // RuoteResponse rrTemp = requestApi(m, new RuoteResponse(), iac, YcBuildData.API_QUOTE, InsQuoteFlow.Q_S_0);
- rr = requestApi(m, new RuoteResponse(), iac, YcBuildData.API_QUOTE, InsQuoteFlow.Q_S_0);
- quoteExternalApi(rr,quoteVo,iac,m );
- // if(ocrMap.get("code").equals("400")){
- // boolean flagTransferInsJQ = StringUtils.isNotEmpty(rr.getVhl().getCCheckCodeJQ()) &&
- // StringUtils.isNotEmpty(rr.getVhl().getCQryCdeJQ());
- // boolean flagTransferInsSY = StringUtils.isNotEmpty(rr.getVhl().getCCheckCodeSY()) &&
- // StringUtils.isNotEmpty(rr.getVhl().getCQryCdeSY());
- // boolean flagTransferIns = StringUtils.isNotEmpty(rr.getVhl().getCBusType()) && (flagTransferInsJQ || flagTransferInsSY);
- // //响应 转保单
- // if (flagTransferIns) {
- // quoteVo.setRenewalCodeJq(cCheckCodeJQ);
- // quoteVo.setRenewalCodeSy(cCheckCodeSY);
- // quoteVo.setCQryCdeJq(rr.getVhl().getCQryCdeJQ());
- // quoteVo.setCQryCdeSy(rr.getVhl().getCQryCdeSY());
- // return HttpResult.error(101, quoteVo, "转保单");
- // }
- // }else{
- //
- }
- }
- return rr;
- }
- /**
- * 3 核保
- *
- * @param quoteOrderNo
- */
- @Override
- @Transactional
- public HttpResult auditApi(String quoteOrderNo) {
- ObjectMapper xmlMapper = this.gainXmlMapper();
- String msg = "提交成功";
- HttpResult h = HttpResult.ok(msg);
- try {
- //子订单
- InsAreaCompany iac = insAreaCompanyService.getById(quoteOrderNo);
- if (iac == null) {
- return HttpResult.error("订单不存在");
- }
- InsOrders order = insOrdersService.getById(iac.getOrderno());
- // 获取协议配置信息
- YcConfigureParameters ycConfigureParameters = gainYcConfigParams(iac.getAgreementId());
- // if (InsOrderStatus.S_5.getCode().equals(iac.getOrderstatus()) || InsOrderStatus.S_4.getCode().equals(iac.getOrderstatus())) {
- // return HttpResult.ok(InsOrderStatus.matchKey(iac.getOrderstatus()).getDesc());
- // }
- //车主
- CustomerInfoVo ownerInfo = JSONObject.parseObject(order.getOwnerinfo().toJSONString(), CustomerInfoVo.class);
- //被保人
- CustomerInfoVo insureInfo = JSONObject.parseObject(order.getInsureinfo().toJSONString(), CustomerInfoVo.class);
- //投保人
- CustomerInfoVo applyInfo = JSONObject.parseObject(order.getApplyinfo().toJSONString(), CustomerInfoVo.class);
- //组装参数
- Audit m = Audit.buildAuditParam(ownerInfo, insureInfo, applyInfo, ycConfigureParameters, iac);
- //处理地区
- Map<String, String> insureMap = gainRegionCode(insureInfo.getAddr());
- if (null != insureMap && insureMap.size() > 0) {
- m.getRequestLabel().getCondition().getCustomer().setCProvince(insureMap.get("provinceCode"));
- m.getRequestLabel().getCondition().getCustomer().setCCity(insureMap.get("cityCode"));
- m.getRequestLabel().getCondition().getCustomer().setCCounty(insureMap.get("areaCode"));
- } else {
- throw new SystemException("永诚 - 被保人地区获取失败,请联系管理员");
- }
- log.debug("=========永诚API方式 - xml请求 - 核保开始======");
- //接口请求
- InsApiLog apiLog = httpPost(xmlMapper, m, YcBuildData.API_AUDIT);
- log.debug("=========永诚API方式 - xml请求 - 核保结束!======");
- verifyRequest(apiLog, iac, InsQuoteFlow.Q_S_1);
- String responseData = apiLog.getResponseData();
- String cleanStr = YcBuildData.cleanResponseStr(responseData);
- AuditResponse rd = xmlMapper.readValue(cleanStr, AuditResponse.class);
- if (rd.getResponseHead().getReturnCode().equals("0000")) {
- // if (rd.getResponseHead().getReturnCode().equals("E0000")) {
- String statusJq = StringUtils.toString(rd.getStatusJq(), "");
- String statusSy = StringUtils.toString(rd.getStatusSY(), "");
- if (statusJq.equals("0") || statusSy.equals("0")) {
- iac.setOrderstatus(InsOrderStatus.S_1.getCode());
- } else if (statusJq.equals("3") || statusSy.equals("3")) {
- iac.setOrderstatus(InsOrderStatus.S_4.getCode());
- } else {
- iac.setOrderstatus(InsOrderStatus.S_2.getCode());
- }
- if (StringUtils.toInt(order.getOrderstatus()) < StringUtils.toInt(iac.getOrderstatus())) {
- order.setOrderstatus(iac.getOrderstatus());
- }
- } else {
- msg = rd.getResponseHead().getReturnMessage();
- return HttpResult.error("核保失败" + msg);
- }
- iac.setAuditid(order.getUserid());
- iac.setInsOrderNo(rd.getOrderCode());
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- iac.setAudittime(LocalDateTime.now());
- iac.setJqapplyno(StringUtils.toString(rd.getPolicyAppNoJQ(), ""));
- iac.setSyapplyno(StringUtils.toString(rd.getPolicyAppNoSY(), ""));
- iac.setJqappoint(""); //交强特别约定
- iac.setSyappoint(""); //商业特别约定
- if (InsOrderStatus.S_2.getCode().equals(InsOrderStatus.matchKey(iac.getOrderstatus()).getCode())) {
- //获取缴费地址
- getPayUrlApi(iac);
- } else {
- h = HttpResult.error(msg + "状态:" + InsOrderStatus.matchKey(iac.getOrderstatus()).getDesc());
- }
- insAreaCompanyService.updateById(iac);
- insOrdersService.updateByOrderStatus(order.getOrderno(), order.getOrderstatus());
- // if (InsOrderStatus.S_2.getCode().equals(InsOrderStatus.matchKey(iac.getOrderstatus()).getCode())) {
- // return HttpResult.ok(msg);
- // } else {
- // return HttpResult.error(msg + "状态:" + InsOrderStatus.matchKey(iac.getOrderstatus()).getDesc());
- // }
- // //插入轨迹表
- // insTaskHistoryService.insertByOrderStatus(order);
- } catch (SystemException e) {
- return HttpResult.error(e.getMessage());
- } catch (Exception e) {
- // e.printStackTrace();
- log.error("===永诚API方式--核保报错(订单号-{}):{}", quoteOrderNo, e.getMessage());
- return HttpResult.error("系统错误,请联系管理员");
- }
- return h;
- }
- /**
- * 4 影像上传
- */
- @Override
- public HttpResult UploadImageApi(String quoteOrderNo) {
- HttpResult resutl = HttpResult.ok();
- InsAreaCompany iac = insAreaCompanyService.getByIdIsExist(quoteOrderNo);
- InsOrders order = insOrdersService.getById(iac.getOrderno());
- List<InsTaskImage> insTaskImages = insTaskImageService.selectByTaskId(order.getQuoteno());
- //获取协议配置信息
- YcConfigureParameters ycConfigureParameters = gainYcConfigParams(iac.getAgreementId());
- insTaskImages.stream().forEach(a -> {
- InsApiLog apiLog = null;
- //组装参数
- log.debug("=========永诚API方式 - xml请求 - 影像上传开始======");
- //接口请求
- ImageUp iUp = ImageUp.buildImageUpParam(order, ycConfigureParameters, a.getImage(), a.getImgtype());
- log.debug("=========永诚API方式 - xml请求 - 影像上传结束!======");
- ObjectMapper xmlMapper = gainXmlMapper();
- //接口请求
- apiLog = httpPost(xmlMapper, iUp, YcBuildData.API_UPLOAD);
- verifyRequest(apiLog, iac, InsQuoteFlow.Q_S_2);
- try {
- String responseData = apiLog.getResponseData();
- String cleanStr = YcBuildData.cleanResponseStr(responseData);
- log.error("===永诚API方式--上传影像清洗返回参数:" + cleanStr);
- ImageUpResponse iur = xmlMapper.readValue(cleanStr, ImageUpResponse.class);
- } catch (IOException e) {
- e.printStackTrace();
- log.error("===永诚API方式--上传影像报错:" + e.getMessage());
- throw new SystemException("系统错误,请联系管理员");
- }
- });
- return HttpResult.ok();
- }
- /**
- * 5 支付
- */
- @Override
- public InsAreaCompany getPayUrlApi(InsAreaCompany iac) {
- try {
- // 获取协议配置信息
- YcConfigureParameters ycConfigureParameters = gainYcConfigParams(iac.getAgreementId());
- //组装参数
- Pay pay = Pay.buildPayParam(iac, ycConfigureParameters.gainAuthorityDataXml(), apiComponents.getPayCallBack());
- ObjectMapper xmlMapper = gainXmlMapper();
- //接口请求
- log.debug("=========永诚API方式 - xml请求 - 获取缴费链接开始======");
- InsApiLog apiLog = httpPost(xmlMapper, pay, YcBuildData.API_PAY);
- log.debug("=========永诚API方式 - xml请求 - 获取缴费链接结束!======");
- verifyRequest(apiLog, iac, InsQuoteFlow.Q_S_3);
- String responseData = apiLog.getResponseData();
- String cleanStr = YcBuildData.cleanResponseStr(responseData);
- PayResponse payResp = xmlMapper.readValue(cleanStr, PayResponse.class);
- if (payResp.getReturnCode().equals("E0000")) {
- iac.setPaymentLink(payResp.getPayTransUrl());
- // insAreaCompanyService.updateById(iac);
- } else {
- log.error("永诚API方式 - 获取支付连接失败:" + payResp.getReturnMessage());
- }
- } catch (Exception e) {
- e.printStackTrace();
- throw new SystemException("获取支付连接失败");
- }
- return iac;
- }
- /**
- * 补传回调
- */
- @Override
- public HttpResult callbackAnOrder(String quoteOrderNo) {
- // log.debug("=========永诚API方式 - xml请求 - 补传回调开始======");
- HttpResult httpResult = new HttpResult();
- try {
- InsAreaCompany iac = insAreaCompanyService.getById(quoteOrderNo);
- InsOrders order = insOrdersService.getById(iac.getOrderno());
- if (iac == null) {
- return HttpResult.error("报价订单不存在");
- }
- if(StringUtils.isEmpty(iac.getAgreementId()))return HttpResult.error("协议号空");
- // 获取协议配置信息
- YcConfigureParameters ycConfigureParameters = gainYcConfigParams(iac.getAgreementId());
- //0 支付回调 1核保回调 5直接返回字符串信息
- // String type = "0";
- String type = "5";
- // if(iac.getOrderstatus().equals(InsOrderStatus.S_1.getCode())) type = "1";
- //组装参数
- CallbackAnOrder o = CallbackAnOrder.buildCallbackAnOrderParam(iac, ycConfigureParameters.gainAuthorityDataXml(), type);
- ObjectMapper xmlMapper = gainXmlMapper();
- //接口请求
- // InsApiLog apiLog = httpPostResultLog(xmlMapper, o, YcBuildData.API_ORDER_QUERY);
- String respData = httpPostResultLog(xmlMapper, o, YcBuildData.API_ORDER_QUERY);
- // log.info("永诚API方式 - xml请求 - 参数:" + apiLog.getRequestData());
- // log.info("永诚API方式 - xml请求 ------------分割线----------------");
- // log.info("永诚API方式 - xml请求 - 响应:" + apiLog.getResponseData());
- // verifyRequest(apiLog, iac, InsQuoteFlow.Q_S_5);
- // String responseData = apiLog.getResponseData();
- String cleanStr = YcBuildData.cleanResponseStr(respData);
- // CallbackAnOrderResponse callbackAnOrderResponse = xmlMapper.readValue(cleanStr, CallbackAnOrderResponse.class);
- if (StringUtils.isNotEmpty(cleanStr)) {
- if(cleanStr.equals("账户不存在或没有权限")) return HttpResult.ok("账户不存在或没有权限");
- log.info("永诚API方式 - 补传回调 - 参数:" + cleanStr);
- CallBackRequest param = CallBackRequest.buildCallBackParam(cleanStr);
- //成功
- if (param.getResult().equals("0")) {
- // LambdaQueryWrapper<InsAreaCompany> lqw = new LambdaQueryWrapper();
- // //交强投保单号查询
- // lqw.eq(StringUtils.isNotEmpty(param.getCiPolicyAppNo()), InsAreaCompany::getJqapplyno, param.getCiPolicyAppNo());
- // //商业投保单号查询
- // lqw.eq(StringUtils.isNotEmpty(param.getBizPolicyAppNo()), InsAreaCompany::getSyapplyno, param.getBizPolicyAppNo());
- // InsAreaCompany iac = insAreaCompanyService.getOne(lqw);
- if (StringUtils.isNotEmpty(param.getBizPolicyNo())) iac.setSypolicyno(param.getBizPolicyNo());
- if (StringUtils.isNotEmpty(param.getCiPolicyNo())) iac.setJqpolicyno(param.getCiPolicyNo());
- iac = buildCallBack(iac, param);
- if (StringUtils.toInt(order.getOrderstatus()) < StringUtils.toInt(iac.getOrderstatus())) {
- order.setOrderstatus(iac.getOrderstatus());
- }
- insAreaCompanyService.updateById(iac);
- insOrdersService.updateByOrderStatus(order.getOrderno(), order.getOrderstatus());
- } else {
- //失败原因
- httpResult = HttpResult.error(param.getMessage());
- log.info(String.format("永诚API方式 - 补传回调 - 失败,交强保单号:{} ,商业保单号:{},类型:{}", param.getCiPolicyNo(), param.getBizPolicyNo(), param.getType()));
- }
- return HttpResult.ok(param);
- }
- // if (cleanStr.equals("0000")) {
- // httpResult.setMsg("操作成功");
- // } else {
- // httpResult.setMsg(cleanStr);
- // }
- } catch (SystemException e) {
- return HttpResult.error(e.getMessage());
- } catch (Exception e) {
- e.printStackTrace();
- return HttpResult.error("系统错误,请联系管理员");
- }
- // log.debug("=========永诚API方式 - xml请求 - 补传回调结束!======");
- return httpResult;
- }
- /**
- * 补传回调
- */
- @Override
- public void callbackAnOrder() {
- LambdaQueryWrapper<InsAreaCompany> lqw = new LambdaQueryWrapper<>();
- lqw.eq(InsAreaCompany::getOrderstatus,InsOrderStatus.S_2.getCode());
- lqw.gt(InsAreaCompany::getAudittime, LocalDate.now().minusDays(1));
- List<InsAreaCompany> list = insAreaCompanyService.list(lqw);
- if(null != list && list.size()>0){
- list.stream().forEach(a ->{
- callbackAnOrder(a.getId());
- });
- }
- }
- /**
- * 6 电子保单
- */
- @Override
- public HttpResult getPolicyPrintApi(PolicyPrintVo policyPrintVo) {
- HttpResult httpResult = new HttpResult();
- try {
- InsAreaCompany iac = insAreaCompanyService.getById(policyPrintVo.getCompanyId());
- // InsOrder order = insOrderService.selectByPk(orderno);
- if (iac == null) {
- return HttpResult.error("报价订单不存在");
- }
- // 获取协议配置信息
- YcConfigureParameters ycConfigureParameters = gainYcConfigParams(iac.getAgreementId());
- String policyNo = policyPrintVo.getRiskCode().equals("0507") ? iac.getJqpolicyno() : iac.getSypolicyno();
- //组装参数
- Policy p = Policy.buildPolicyParam(policyNo, ycConfigureParameters.gainAuthorityDataXml());
- ObjectMapper xmlMapper = gainXmlMapper();
- //接口请求
- log.debug("=========永诚API方式 - xml请求 - 获取保单开始======");
- InsApiLog apiLog = httpPost(xmlMapper, p, YcBuildData.API_GUARANTEE_SLIP);
- log.debug("=========永诚API方式 - xml请求 - 获取保单结束!======");
- verifyRequest(apiLog, iac, InsQuoteFlow.Q_S_4);
- String responseData = apiLog.getResponseData();
- String cleanStr = YcBuildData.cleanResponseStr(responseData);
- PolicyResponse pResp = xmlMapper.readValue(cleanStr, PolicyResponse.class);
- if (pResp.getHead().getResponseCompleteMessageStatus().getMessageStatusCode().equals("E0000")) {
- Map m = new HashMap();
- if (policyPrintVo.getType().equals("1")) {
- m.put("jqFlagUrl", pResp.getPolicyBZUrl());
- m.put("jqUrl", "");
- m.put("syUrl", "");
- }
- if (policyPrintVo.getType().equals("2")) {
- m.put("jqFlagUrl", pResp.getPolicyBZUrl());
- m.put("jqUrl", pResp.getJqpolicyUrl());
- m.put("syUrl", pResp.getSypolicyUrl());
- }
- // httpResult.setData(m);
- // httpResult.setMsg(pResp.getHead().getResponseCompleteMessageStatus().getMessageStatusDescription());
- return HttpResult.ok(pResp.getHead().getResponseCompleteMessageStatus().getMessageStatusDescription(), m);
- } else {
- return HttpResult.error(pResp.getHead().getResponseCompleteMessageStatus().getMessageStatusDescription());
- }
- } catch (Exception e) {
- e.printStackTrace();
- return HttpResult.error("系统错误,请联系管理员");
- }
- }
- /**
- * 驾意外险
- */
- @Override
- public HttpResult gainAccidentList(AccidentalDrivingQueryVo accidentalDrivingVo) {
- HttpResult httpResult = new HttpResult();
- try {
- // InsAreaCompany iac = insAreaCompanyService.getById(quoteOrderNo);
- // InsOrders order = insOrdersService.getById(iac.getOrderno());
- // if (iac == null) {
- // return HttpResult.error("报价订单不存在");
- // }
- // 获取协议配置信息
- YcConfigureParameters ycConfigureParameters = gainYcConfigParams(accidentalDrivingVo.getAgreementId());
- //组装参数
- Accident accident = Accident.buildPayParam(accidentalDrivingVo, ycConfigureParameters, null);
- ObjectMapper xmlMapper = gainXmlMapper();
- //接口请求
- log.debug("=========永诚API方式 - xml请求 - 获取意健险方案及险种查询开始======");
- InsApiLog apiLog = httpPost(xmlMapper, accident, YcBuildData.API_ACCIDENT);
- log.debug("=========永诚API方式 - xml请求 - 获取意健险方案及险种查询结束!======");
- // verifyRequest(apiLog, iac,InsQuoteFlow.);
- String responseData = apiLog.getResponseData();
- String cleanStr = YcBuildData.cleanResponseStr(responseData);
- AccidentResponse accidentResp = xmlMapper.readValue(cleanStr, AccidentResponse.class);
- if (accidentResp.getHead().getResponseCompleteMessageStatus().getMessageStatusCode().equals("E0000")) {
- //清空旧的存入表
- LambdaQueryWrapper<EsmInsAttachInsure> lqw = new LambdaQueryWrapper<EsmInsAttachInsure>();
- lqw.eq(EsmInsAttachInsure::getCompanyId, accidentalDrivingVo.getCompanyCode());
- lqw.eq(EsmInsAttachInsure::getSeating, accidentalDrivingVo.getSeatNum());
- esmInsAttachInsureMapper.delete(lqw);
- List<ResponseYwCvrg.CvrgList> cList = accidentResp.getResponseYwCvrg().getCvrgList();
- List<EsmInsAttachInsure> eiaiList = new ArrayList<>();
- cList.stream().forEach(a -> {
- EsmInsAttachInsure ati = new EsmInsAttachInsure();
- ati.setCode(a.getCInsuranceTypeCode());
- ati.setName(a.getCInsuranceType());
- ati.setSeating(accidentalDrivingVo.getSeatNum() + "");
- ati.setCompanyId(accidentalDrivingVo.getCompanyCode());
- ati.setType(AttachInsureEnum.AI001.getCode());
- ati.setEnable(WhetherEnum.YES.getCode());
- ati.setRestrictNum(StringUtils.toInt(a.getNPurchaseLimitsNum()));
- esmInsAttachInsureMapper.insert(ati);
- eiaiList.add(ati);
- });
- httpResult.setData(eiaiList);
- // httpResult.setData(accidentResp.getResponseYwCvrg().getCvrgList());
- httpResult.setMsg(accidentResp.getHead().getResponseCompleteMessageStatus().getMessageStatusDescription());
- } else {
- httpResult.setMsg(accidentResp.getHead().getResponseCompleteMessageStatus().getMessageStatusDescription());
- }
- } catch (SystemException e) {
- return HttpResult.error(e.getMessage());
- } catch (Exception e) {
- e.printStackTrace();
- return HttpResult.error("系统错误,请联系管理员");
- }
- return httpResult;
- }
- /**
- * 驾意外险 同步
- */
- @Override
- public HttpResult syncAccidentInsure(AccidentalDrivingQueryVo accidentalDrivingVo) {
- AccidentResponse ar = gainAccidentInsure(accidentalDrivingVo, null);
- // List<EsmInsAttachInsure> eiaiList = new ArrayList<>();
- if (ar.getHead().getResponseCompleteMessageStatus().getMessageStatusCode().equals("E0000")) {
- //清空旧的存入表
- LambdaQueryWrapper<EsmInsAttachInsure> lqw = new LambdaQueryWrapper<EsmInsAttachInsure>();
- lqw.eq(EsmInsAttachInsure::getCompanyId, accidentalDrivingVo.getCompanyCode());
- lqw.eq(EsmInsAttachInsure::getSeating, accidentalDrivingVo.getSeatNum());
- lqw.select(EsmInsAttachInsure::getId);
- List<EsmInsAttachInsure> eiaiList = esmInsAttachInsureMapper.selectList(lqw);
- //删除已经存在的数据
- if (null != eiaiList && eiaiList.size() > 0) {
- List<String> ids = new ArrayList<>();
- eiaiList.stream().forEach(i -> {
- ids.add(i.getId());
- });
- LambdaQueryWrapper<EsmInsAttachInsureDetails> lqwDetails = new LambdaQueryWrapper<>();
- lqwDetails.in(EsmInsAttachInsureDetails::getAttachInsureId, ids);
- //详情删除
- esmInsAttachInsureDetailsMapper.delete(lqwDetails);
- // esmInsAttachInsureMapper.delete(lqw);
- esmInsAttachInsureMapper.deleteBatchIds(ids);
- }
- List<ResponseYwCvrg.CvrgList> cList = ar.getResponseYwCvrg().getCvrgList();
- cList.stream().forEach(a -> {
- EsmInsAttachInsure ati = new EsmInsAttachInsure();
- ati.setCode(a.getCInsuranceTypeCode());
- ati.setName(a.getCInsuranceType());
- ati.setSeating(accidentalDrivingVo.getSeatNum() + "");
- ati.setCompanyId(accidentalDrivingVo.getCompanyCode());
- ati.setType(AttachInsureEnum.AI001.getCode());
- ati.setEnable(WhetherEnum.YES.getCode());
- ati.setRestrictNum(StringUtils.toInt(a.getNPurchaseLimitsNum()));
- esmInsAttachInsureMapper.insert(ati);
- //具体方案信息
- AccidentResponse arCode = gainAccidentInsure(accidentalDrivingVo, a.getCInsuranceTypeCode());
- if (arCode.getHead().getResponseCompleteMessageStatus().getMessageStatusCode().equals("E0000")) {
- AtomicInteger total = new AtomicInteger(0);
- List<ResponseYwCvrg.CvrgList> cListDetails = arCode.getResponseYwCvrg().getCvrgList();
- cListDetails.stream().forEach(d -> {
- EsmInsAttachInsureDetails atiDetails = new EsmInsAttachInsureDetails();
- atiDetails.setAttachInsureId(ati.getId());
- atiDetails.setName(d.getCInsuranceLiability());
- atiDetails.setCarSum(d.getNInsuranceAmountCar());
- atiDetails.setSeatSum(d.getNInsuranceAmountSeat());
- atiDetails.setPremium(d.getNLiabilityPremium());
- total.addAndGet(StringUtils.toInt(d.getNLiabilityPremium()));
- esmInsAttachInsureDetailsMapper.insert(atiDetails);
- });
- ati.setPremium(total.get() + "");
- esmInsAttachInsureMapper.updateById(ati);
- }
- // eiaiList.add(ati);
- });
- }
- return HttpResult.ok("同步成功");
- }
- /**
- * 驾意外险
- */
- @Override
- public AccidentResponse gainAccidentInsure(AccidentalDrivingQueryVo accidentalDrivingVo, String schemeNo) {
- HttpResult httpResult = new HttpResult();
- // 获取协议配置信息
- YcConfigureParameters ycConfigureParameters = gainYcConfigParams(accidentalDrivingVo.getAgreementId());
- //组装参数
- Accident accident = Accident.buildPayParam(accidentalDrivingVo, ycConfigureParameters, schemeNo);
- ObjectMapper xmlMapper = gainXmlMapper();
- //接口请求
- log.debug("=========永诚API方式 - xml请求 - 获取意健险方案及险种查询开始======");
- InsApiLog apiLog = httpPost(xmlMapper, accident, YcBuildData.API_ACCIDENT);
- log.debug("=========永诚API方式 - xml请求 - 获取意健险方案及险种查询结束!======");
- // verifyRequest(apiLog, iac,InsQuoteFlow.);
- String responseData = apiLog.getResponseData();
- String cleanStr = YcBuildData.cleanResponseStr(responseData);
- AccidentResponse accidentResp = null;
- try {
- accidentResp = xmlMapper.readValue(cleanStr, AccidentResponse.class);
- } catch (JsonProcessingException e) {
- log.error("转换错误 方法:gainAccidentInsure 类:AccidentResponse");
- throw new RuntimeException(e);
- }
- return accidentResp;
- // if (accidentResp.getHead().getResponseCompleteMessageStatus().getMessageStatusCode().equals("E0000")) {
- // //清空旧的存入表
- // LambdaQueryWrapper<EsmInsAttachInsure> lqw = new LambdaQueryWrapper<EsmInsAttachInsure>();
- // lqw.eq(EsmInsAttachInsure::getCompanyId,accidentalDrivingVo.getCompanyCode());
- // lqw.eq(EsmInsAttachInsure::getSeating,accidentalDrivingVo.getSeatNum());
- // esmInsAttachInsureMapper.delete(lqw);
- //
- // List<ResponseYwCvrg.CvrgList> cList = accidentResp.getResponseYwCvrg().getCvrgList();
- //
- // List<EsmInsAttachInsure> eiaiList = new ArrayList<>();
- // cList.stream().forEach(a ->{
- // EsmInsAttachInsure ati = new EsmInsAttachInsure();
- // ati.setCode(a.getCInsuranceTypeCode());
- // ati.setName(a.getCInsuranceType());
- // ati.setSeating(accidentalDrivingVo.getSeatNum() + "");
- // ati.setCompanyId(accidentalDrivingVo.getCompanyCode());
- // ati.setType(AttachInsureEnum.AI001.getCode());
- // ati.setEnable(WhetherEnum.YES.getCode());
- // ati.setRestrictNum(StringUtils.toInt(a.getNPurchaseLimitsNum()));
- //
- // esmInsAttachInsureMapper.insert(ati);
- // eiaiList.add(ati);
- // });
- //
- //
- //
- //
- // httpResult.setData(eiaiList);
- //// httpResult.setData(accidentResp.getResponseYwCvrg().getCvrgList());
- // httpResult.setMsg(accidentResp.getHead().getResponseCompleteMessageStatus().getMessageStatusDescription());
- // } else {
- // httpResult.setMsg(accidentResp.getHead().getResponseCompleteMessageStatus().getMessageStatusDescription());
- // }
- }
- @Override
- @Transactional
- public HttpResult callBackApi(CallBackRequest param) {
- // if (StringUtils.isNotEmpty(param.getType())) return HttpResult.error("字段:type(回调类型) 参数为空");
- //成功
- if (param.getResult().equals("0")) {
- LambdaQueryWrapper<InsAreaCompany> lqw = new LambdaQueryWrapper();
- //交强投保单号查询
- lqw.eq(StringUtils.isNotEmpty(param.getCiPolicyAppNo()), InsAreaCompany::getJqapplyno, param.getCiPolicyAppNo());
- //商业投保单号查询
- lqw.eq(StringUtils.isNotEmpty(param.getBizPolicyAppNo()), InsAreaCompany::getSyapplyno, param.getBizPolicyAppNo());
- InsAreaCompany iac = insAreaCompanyService.getOne(lqw);
- if (null != iac) {
- if (StringUtils.isNotEmpty(param.getBizPolicyNo())) iac.setSypolicyno(param.getBizPolicyNo());
- if (StringUtils.isNotEmpty(param.getCiPolicyNo())) iac.setJqpolicyno(param.getCiPolicyNo());
- iac = buildCallBack(iac, param);
- InsOrders order = insOrdersService.getById(iac.getOrderno());
- if (StringUtils.toInt(order.getOrderstatus()) < StringUtils.toInt(iac.getOrderstatus())) {
- order.setOrderstatus(iac.getOrderstatus());
- }
- insAreaCompanyService.updateById(iac);
- insOrdersService.updateByOrderStatus(order.getOrderno(), order.getOrderstatus());
- //支付后 手工确认意外险
- } else {
- log.info(String.format("永诚API方式 - 回调 - 信息,订单不存在,交强保单号:{} ,商业保单号:{}", param.getCiPolicyNo(), param.getBizPolicyNo()));
- }
- } else {
- //失败原因
- param.getMessage();
- log.info(String.format("永诚API方式 - 回调 - 失败,交强保单号:{} ,商业保单号:{},类型:{}", param.getCiPolicyNo(), param.getBizPolicyNo(), param.getType()));
- }
- return HttpResult.ok(param);
- }
- /**
- * @description:构造车型查询参数
- * @author: lig
- * @date: 2023年02月08日 0008
- */
- private ModelsQueryXml buildModelsQueryParam(CarModel_Req carModelReq, YcConfigureParameters ycConfigureParameters) {
- ModelsQueryXml m = new ModelsQueryXml();
- ModelsQueryXml.RequestLabel requestLabel = new ModelsQueryXml.RequestLabel();
- requestLabel.setSearchKeyword(carModelReq.getFrameNo().substring(0, 8));
- requestLabel.setVid(carModelReq.getFrameNo());
- requestLabel.setEngineNo(carModelReq.getEngineNo());
- requestLabel.setDptCde(ycConfigureParameters.getDptCde());
- requestLabel.setProno("0326");
- requestLabel.setMotorTypeCode("11");
- requestLabel.setCFstRegYm(carModelReq.getEnrollDate());
- requestLabel.setAuthorityData(ycConfigureParameters.gainAuthorityDataXml());
- m.setRequestLabel(requestLabel);
- return m;
- }
- /**
- * @description: 构造返回内容,参考永安
- * @author: lig
- * @date: 2023年02月07日 0007
- */
- private List<ModelsQueryResponse.VehicleInfo> buildCarModel(ModelsQueryResponse modelsQueryResponse) {
- // private List<CarModelDTO> buildCarModel(ModelsQueryResponse modelsQueryResponse) {
- List<ModelsQueryResponse.VehicleInfo> vList = modelsQueryResponse.getVehicleInfoList();
- return vList;
- // List<CarModelDTO> carModelList = new ArrayList<>();
- //
- // vList.stream().forEach(a -> {
- // CarModelDTO dto = new CarModelDTO();
- // BeanUtils.copyProperties(a, dto);
- // carModelList.add(dto);
- // });
- // return carModelList;
- }
- private <T> InsApiLog httpPost(ObjectMapper mapper, T requestData, String apiName) {
- String xmlString = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:tns=\"http://newWS.front.app.echannel.ebiz.alltrust.com/\">";
- xmlString += "<soapenv:Body>";
- try {
- mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
- xmlString += mapper.writeValueAsString(requestData);
- xmlString += "</soapenv:Body>\n" +
- "</soapenv:Envelope>";
- } catch (JsonProcessingException e) {
- throw new RuntimeException("永诚API方式-xml转换失败");
- }
- InsApiLog iplog = HttpXmlUtil.sendXmlPost(apiComponents.getUrl() + apiName, xmlString);
- log.info("永诚API方式 - xml请求 - 参数:" + iplog.getRequestData());
- log.info("永诚API方式 - xml请求 ------------分割线----------------");
- log.info("永诚API方式 - xml请求 - 响应:" + iplog.getResponseData());
- return iplog;
- }
- /**
- * 日志返回处理
- *
- * @author: lig
- * @date: 2023年09月02日 0002
- */
- private <T> String httpPostResultLog(ObjectMapper mapper, T requestData, String apiName) {
- String xmlString = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:tns=\"http://newWS.front.app.echannel.ebiz.alltrust.com/\">";
- xmlString += "<soapenv:Body>";
- try {
- mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
- xmlString += mapper.writeValueAsString(requestData);
- xmlString += "</soapenv:Body>\n" +
- "</soapenv:Envelope>";
- } catch (JsonProcessingException e) {
- throw new RuntimeException("永诚API方式-xml转换失败");
- }
- // InsApiLog iplog = HttpXmlUtil.sendXmlPost(apiComponents.getUrl() + apiName, xmlString);
- return HttpXmlUtil.sendXmlPostReq(apiComponents.getUrl() + apiName, xmlString,null);
- }
- // /**
- // * 日志返回处理
- // *
- // * @author: lig
- // * @date: 2023年09月02日 0002
- // */
- // private <T> InsApiLog httpPostResultLog(ObjectMapper mapper, T requestData, String apiName) {
- //
- // String xmlString = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:tns=\"http://newWS.front.app.echannel.ebiz.alltrust.com/\">";
- // xmlString += "<soapenv:Body>";
- // try {
- // mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
- // xmlString += mapper.writeValueAsString(requestData);
- //
- // xmlString += "</soapenv:Body>\n" +
- // "</soapenv:Envelope>";
- //
- // } catch (JsonProcessingException e) {
- // throw new RuntimeException("永诚API方式-xml转换失败");
- // }
- // InsApiLog iplog = HttpXmlUtil.sendXmlPost(apiComponents.getUrl() + apiName, xmlString);
- //
- // return iplog;
- // }
- /**
- * @description: 拷贝永安方法,可以封装
- * @author: lig
- * @date: 2023年02月08日 0008
- */
- private void checkEmpty(YaQuoteInfoVo yaQuoteInfoVo) {
- if (yaQuoteInfoVo.getCarInfo() == null) {
- throw new SystemException("carInfo不能为空!");
- }
- if (yaQuoteInfoVo.getPolicyHolderInfo() == null || yaQuoteInfoVo.getInsuredPersonInfo() == null) {
- throw new SystemException("policyHolderInfo/insuredPersonInfo 不能为空!");
- }
- if (yaQuoteInfoVo.getRiskList() == null || yaQuoteInfoVo.getRiskList().size() == 0) {
- throw new SystemException("riskList 不能为空!");
- } else {
- for (RiskInfoVo riskInfoVo : yaQuoteInfoVo.getRiskList()) {
- if (riskInfoVo.getStartDate() == null || riskInfoVo.getEndDate() == null) {
- throw new SystemException("riskList.startDate / riskList.endDate不能为空!");
- }
- }
- }
- }
- // /**
- // * 生成订单 拷贝永安
- // *
- // * @author: lig
- // * @date: 2023年02月16日 0016
- // */
- // protected InsOrders gene_order(YaQuoteInfoVo record) {
- // InsOrders insOrder = new InsOrders();
- // String orderno = IdGenerate.nextId();
- // insOrder.setOrderno(orderno);
- // insOrder.setQuoteno(String.valueOf(record.getQuoteno()));
- // insOrder.setOrderstatus("0"); //0报价 1待核保 2已核保待缴费 3核保退回 4核保不通过
- // insOrder.setFrameno(record.getCarInfo().getFrameNo());
- // insOrder.setLicenseno(record.getCarInfo().getLicenseNo());
- //
- // insOrder.setCarinfo(JSONObject.parseObject(JSONObject.toJSONString(record.getCarInfo())));
- // SysUser user = sysUserService.selectByPk(record.getUserId());
- // if (user == null) {
- // throw new SystemException("userId不存在");
- // }
- // if (org.springframework.util.StringUtils.isEmpty(record.getCarInfo().getFrameNo())) {
- // throw new SystemException("车架号不能为空");
- // }
- // // 关闭订单 不含当前报价号
- // InsOrders orderObj = insOrderService.queryQuoteno(new Object[]{record.getUserId(), record.getCarInfo().getFrameNo(), record.getQuoteno()});
- // if (orderObj != null) {
- // List<InsOrder> listo = insOrderService.selectList(" where quoteno=?", new Object[]{orderObj.getQuoteno()});
- // String status = "0";
- // for (InsOrder order : listo) {
- // if (!"0".equals(order.getOrderstatus())) {
- // status = order.getOrderstatus();
- // }
- // }
- // //0报价中 1待核保 2已核保 3核保退回 4核保不通过 5已核保待缴费 6已缴费 7已承保 99已关闭
- // if ("0".equals(status)) {//关闭订单
- // insOrderService.closeOrder(orderObj.getOrderno(), "99");
- // } else if (!"99".equals(status)) {
- // throw new SystemException("此车辆已提交核保,重新报价请先关闭订单,任务号:" + orderObj.getQuoteno());
- // }
- // }
- // insOrder.setUserid(user.getId());
- // insOrder.setUsername(user.getName());
- // insOrder.setDeptid(user.getDeptId());
- // SysDept dept = sysDeptService.selectByPk(user.getDeptId());
- // insOrder.setDeptname(dept == null ? "" : dept.getName());
- //
- // double retailRate = countRetail(user.getDeptId(), user.getId());
- //
- // insOrder.setOwnerinfo(JSONObject.parseObject(JSONObject.toJSONString(record.getOwnerInfo())));
- // insOrder.setApplyinfo(JSONObject.parseObject(JSONObject.toJSONString(record.getPolicyHolderInfo())));
- // insOrder.setInsureinfo(JSONObject.parseObject(JSONObject.toJSONString(record.getInsuredPersonInfo())));
- //
- // insOrder.setInsuredname(record.getPolicyHolderInfo().getName());
- //
- //
- // List<RiskInfoVo> risks = record.getRiskList();
- // for (RiskInfoVo risk : risks) {
- // if ("0507".equals(risk.getRiskCode())) {//交强
- // insOrder.setJqstartdate(risk.getStartDate());
- // insOrder.setJqenddate(risk.getEndDate());
- // }
- // if ("0510".equals(risk.getRiskCode())) {//商业
- // insOrder.setSystartdate(risk.getStartDate());
- // insOrder.setSyenddate(risk.getEndDate());
- // }
- // }
- //
- // List<KindInfoVo> kinds = record.getKindList();
- // String productId = "";
- // String productname = "";
- //
- // List<EsmAgreement> agreements = esmAgreementService.selectList(" where t.agreestatus='1' and t.insure1 like ? " + "and exists (select 1 from esm_agreement_prod t2 where t.id=t2.agreeid and t2.authcomcode like ?)", new Object[]{"000006140400%", "%" + user.getDeptId() + "%"});
- // if (agreements.size() == 0) {
- // throw new SystemException("不存在有效协议或机构" + user.getDeptId() + "未授权");
- // }
- // String agreeid = agreements.get(0).getId();
- // insOrder.setAgreeid(agreeid);
- // //匹配协议,获取费用
- // StringBuffer whereStr = new StringBuffer();
- // List params = new ArrayList();// where t.agreeid=? and t.productid in ()
- // whereStr.append("where t.agreeid=? ");
- // params.add(agreeid);
- // if (risks.size() == 1 && "0507".equals(risks.get(0).getRiskCode())) {
- // productId = "ZG01001";
- // productname = "单交强";
- // whereStr.append(" and t.productid=?");
- // params.add(productId);
- // } else if (risks.size() == 1 && kinds.size() == 1 && "B".equals(kinds.get(0).getKindCode())) {
- // productId = "ZG01002";
- // productname = "单三者";
- // whereStr.append(" and t.productid=?");
- // params.add(productId);
- // } else if (risks.size() == 1) {
- // productId = "ZG01003";
- // productname = "单商业";
- // whereStr.append(" and t.productid=?");
- // params.add(productId);
- // } else if (risks.size() == 2 && kinds.size() == 1 && "B".equals(kinds.get(0).getKindCode())) {
- // productId = "ZG01004";
- // productname = "交强+三者";
- // whereStr.append(" and t.productid in (?,?)");
- // params.add("ZG01004");
- // params.add("ZG01005");
- // } else {
- // productId = "ZG01006";
- // productname = "交强+商业";
- // whereStr.append(" and t.productid in (?,?)");
- // params.add("ZG01006");
- // params.add("ZG01007");
- // }
- //
- // insOrder.setProductid(productId);
- // insOrder.setProduct(productname);
- // List<EsmAgreementProd> agreementProds = esmAgreementProdService.selectList(whereStr.toString(), params.toArray());
- // for (EsmAgreementProd prod : agreementProds) {
- // if ("ZG01001".equals(prod.getProductid()) || "ZG01004".equals(prod.getProductid()) || "ZG01006".equals(prod.getProductid())) {
- //
- // insOrder.setFeerate(prod.getProductrate()); //交强手续费比例
- // insOrder.setJqdiscountrate(prod.getFeerate() - retailRate); //交强优惠比例=业务员绩效-分销费用
- // } else {
- // insOrder.setDisrate(prod.getProductrate()); //商业手续费比例
- // insOrder.setSydiscountrate(prod.getFeerate() - retailRate); //商业优惠比例=业务员绩效-分销费用
- //
- // }
- // insOrder.setProductid(prod.getId());
- // }
- //
- // insOrder.setRiskinfo(JSONObject.parseArray(JSONObject.toJSONString(record.getRiskList())));
- // insOrder.setKindinfo(JSONObject.parseArray(JSONObject.toJSONString(record.getKindList())));
- // SimpleDateFormat sdfm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- //
- // insOrder.setInscompany("永安财险");
- // insOrder.setCreatetime(sdfm.format(new Date()));
- //
- // return insOrder;
- //
- // }
- // /**
- // * 分销费用统计 拷贝永安
- // *
- // * @param deptid
- // * @param userid
- // * @return
- // */
- // public double countRetail(String deptid, String userid) {
- // double retailRate = 0;
- //
- // //1、根据机构匹配分销规则,获取分销比例
- // List<EsmRetail> list = esmRetailService.selectList(" where deptid = ? and status=?", new Object[]{deptid, "1"});
- // //2、根据userid查询三级推荐人
- // List<SysUser> users = esmUserInternalService.getSuperior(userid);
- //
- // if (list != null && list.size() > 0 && users.size() > 0 && !"0".equals(list.get(0).getRetailtype())) {
- // EsmRetail retail = list.get(0);
- // List<Double> rateList = new ArrayList<Double>();
- // rateList.add(retail.getDisrate1());
- // rateList.add(retail.getDisrate2());
- // rateList.add(retail.getDisrate3());
- //
- // if ("1".equals(retail.getRetailtype())) {//一级分销
- // retailRate += rateList.get(0);
- // } else if ("2".equals(retail.getRetailtype())) {//二级分销
- // int num = users.size() > 2 ? 2 : users.size();
- // for (int i = 0; i < num; i++) {
- // retailRate += rateList.get(i);
- // }
- //
- // } else {//三级分销
- // int num = users.size() > 2 ? 3 : users.size();
- // for (int i = 0; i < num; i++) {
- // retailRate += rateList.get(i);
- // }
- //
- // }
- //
- // }
- //
- // return retailRate;
- // }
- /**
- * 新订单 - 子订单
- *
- * @author: lig
- * @date: 2023年02月16日 0016
- */
- private InsAreaCompany response_order(InsOrders insOrder, QuoteRespVo quoteRespVo, Ruote requestData, RuoteResponse responseData, BaseQuoteVo<AccidentalDrivingVo> quoteVo) {
- //交强保费 含税
- double jqPremium = StringUtils.toDouble(responseData.getBase().getNBefTaxPrmJQ()) + StringUtils.toDouble(responseData.getBase().getNAppTaxAmtJQ());
- //商业保费 含税
- double syPremium = StringUtils.toDouble(responseData.getBase().getNBefTaxPrmSY()) + StringUtils.toDouble(responseData.getBase().getNAppTaxAmtSY());
- //保险公司订单号
- String insOrderNo = responseData.getBase().getCresvTxt6();
- //查询码交强
- String queryCodeJq = responseData.getVhl().getCQryCdeJQ();
- //查询码商业
- String queryCodeSy = responseData.getVhl().getCQryCdeSY();
- EsmInsCompany eic = esmInsCompanyService.getById(quoteVo.getCompanyId());
- boolean jq_falg = jqPremium > 0 ? true : false;
- //保存订单信息
- InsAreaCompany insAreaCompany = new InsAreaCompany();
- insAreaCompany.setOrderno(insOrder.getOrderno());
- insAreaCompany.setReptxt(JSONObject.parseObject(JSONObject.toJSONString(responseData)));
- insAreaCompany.setJqpremium(BigDecimal.valueOf(jq_falg ? jqPremium : 0));
- insAreaCompany.setSypremium(BigDecimal.valueOf(syPremium));
- insAreaCompany.setTaxamount(BigDecimal.valueOf(jq_falg ? quoteRespVo.getTaxAmount() : 0));
- insAreaCompany.setSumpremium(BigDecimal.valueOf(quoteRespVo.getSumPermium()));
- // insAreaCompany.setSumpremium(BigDecimal.valueOf(add(quoteRespVo.getSumPermium(), insOrder.getTaxamount())));
- insAreaCompany.setOrderstatus(InsTaskHistoryEnum.WAITING_NUCLEAR_INSURANCE.getState() + "");
- insAreaCompany.setRiskinfo(JSONObject.parseArray(JSONObject.toJSONString(quoteRespVo.getRiskList())));
- insAreaCompany.setKindinfo(JSONObject.parseArray(JSONObject.toJSONString(quoteRespVo.getKindList())));
- insAreaCompany.setCreatetime(LocalDateTime.now());
- insAreaCompany.setInsOrderNo(insOrderNo);
- insAreaCompany.setJqapplyno(queryCodeJq);
- insAreaCompany.setSyapplyno(queryCodeSy);
- insAreaCompany.setCompanyId(eic.getId());
- insAreaCompany.setInscompany(eic.getNamesimple());
- insAreaCompany.setAgreementId(quoteVo.getAgreementId());
- insAreaCompanyService.save(insAreaCompany);
- return insAreaCompany;
- // //插入轨迹表
- // InsTaskHistory history = new InsTaskHistory();
- // history.setId(String.valueOf(new Date().getTime()));
- // history.setCompany(insOrder.getInscompany());
- // history.setTaskid(insOrder.getOrderno());
- // history.setOperatorid(insOrder.getUserid());
- // history.setOperator(insOrder.getUsername());
- // SimpleDateFormat sdfm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- // history.setCreatetime(sdfm.format(new Date()));
- // history.setOperator(insOrder.getUsername());
- // history.setStatus("0");
- // history.setRemark("报价中");
- // insTaskHistoryService.insert(history);
- }
- public static double add(double v1, double v2) {
- BigDecimal b1 = new BigDecimal(Double.toString(v1));
- BigDecimal b2 = new BigDecimal(Double.toString(v2));
- return b1.add(b2).doubleValue();
- }
- public static String getUserName() {
- return "";
- // String userName = null;
- // Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
- //
- // if (principal instanceof UserDetails) {
- // userName = ((UserDetails) principal).getUsername();
- // } else {
- // userName = principal.toString();
- // }
- // return userName;
- }
- /**
- * 验证远程请求
- *
- * @author: lig
- * @date: 2023年02月22日 0022
- */
- private void verifyRequest(InsApiLog apiLog, InsAreaCompany insAreaCompany, InsQuoteFlow iqf) {
- //增加api日志
- insApiLogService.insertAsync(new InsApiLog(insAreaCompany, apiLog, iqf));
- if (StringUtils.isNotEmpty(apiLog.getExceptionMsg())) {
- throw new SystemException("远程接口调用异常");
- // throw new RuntimeException("远程接口调用异常");
- }
- }
- // /**
- // * 验证远程请求
- // *
- // * @author: lig
- // * @date: 2023年02月22日 0022
- // */
- // private void verifyRequest(InsApiLog apiLog, InsAreaCompany insAreaCompany) {
- // //增加api日志
- // insApiLogService.insertAsync(new InsApiLog(insAreaCompany, apiLog));
- // if (StringUtils.isNotEmpty(apiLog.getExceptionMsg())) {
- // throw new RuntimeException("远程接口调用异常");
- // }
- //
- // }
- /**
- * 更新api log
- *
- * @author: lig
- * @date: 2023-03-21
- */
- private void updateApiLog(InsApiLog apiLog, InsAreaCompany iac) {
- if (null != apiLog && null != iac) {
- apiLog.setOrderNo(StringUtils.toString(iac.getId()));
- // apiLog.setOrderStatus(iac.getOrderstatus());
- insApiLogService.UpdateAsync(apiLog);
- }
- }
- @Override
- public Map<String, String> gainRegionCode(String address) {
- log.debug("*********永诚API方式 - 身份证地址解析 参数:" + address);
- Map<String, String> m = IDCardUtils.addressResolution(address);
- if (null == m) return null;
- String city = m.get("city");
- String district = m.get("district");
- // if(StringUtils.isNullOrEmpty(district)){
- // //第二级赋值到第三级
- // district = city;
- // }
- List<InsAlltrustRegion> areaList = new ArrayList<>();
- if (StringUtils.isNotEmpty(district)) {
- //查询地区
- LambdaQueryWrapper<InsAlltrustRegion> lqw = new LambdaQueryWrapper<>();
- lqw.eq(InsAlltrustRegion::getArea, district);
- areaList = insAlltrustRegionMapper.selectList(lqw);
- }
- //如果地区查不到 用城市当地区查
- if (null == areaList || areaList.size() < 1) {
- LambdaQueryWrapper<InsAlltrustRegion> cityLqw = new LambdaQueryWrapper<>();
- cityLqw.eq(InsAlltrustRegion::getArea, city);
- areaList = insAlltrustRegionMapper.selectList(cityLqw);
- }
- if (null != areaList && areaList.size() > 0) {
- Map rMap = new HashMap();
- rMap.put("provinceCode", areaList.get(0).getProvinceCode());
- rMap.put("cityCode", areaList.get(0).getCityCode());
- rMap.put("areaCode", areaList.get(0).getAreaCode());
- return rMap;
- }
- return null;
- }
- private void buildRegion(Ruote m) {
- //车主
- Vhlowner owner = m.getRequestLabel().getCondition().getVhlowner();
- //被保人
- Insured i = m.getRequestLabel().getCondition().getInsured();
- //投保人
- Applicant a = m.getRequestLabel().getCondition().getApplicant();
- String provinceCode = "provinceCode";
- String cityCode = "cityCode";
- String areaCode = "areaCode";
- // owner.getCAreaCde()
- Map<String, String> ownerMap = gainRegionCode(owner.getCWaddress());
- if (null != ownerMap && ownerMap.size() > 0) {
- owner.setCProvince(ownerMap.get(provinceCode));
- owner.setCCity(ownerMap.get(cityCode));
- owner.setCCounty(ownerMap.get(areaCode));
- //清空格式化 自建数据
- owner.setCWaddress(null);
- } else {
- throw new SystemException("永诚 - 车主地区获取失败,请联系管理员");
- }
- Map<String, String> iMap = gainRegionCode(i.getCClntAddr());
- if (null != iMap && iMap.size() > 0) {
- i.setCProvince(iMap.get(provinceCode));
- i.setCCity(iMap.get(cityCode));
- i.setCCounty(iMap.get(areaCode));
- } else {
- throw new SystemException("永诚 - 被保人地区获取失败,请联系管理员");
- }
- Map<String, String> aMap = gainRegionCode(a.getCClntAddr());
- if (null != aMap && aMap.size() > 0) {
- a.setCProvince(aMap.get(provinceCode));
- a.setCCity(aMap.get(cityCode));
- a.setCCounty(aMap.get(areaCode));
- } else {
- throw new SystemException("永诚 - 投保人地区获取失败,请联系管理员");
- }
- }
- /**
- * 构造回调
- * 依赖 buildCallBack
- *
- * @author: lig
- * @date: 2023-05-06
- */
- private InsAreaCompany buildCallBack(InsAreaCompany iac, CallBackRequest param) {
- //正常回调 与 补传回调
- if (StringUtils.isNotEmpty(param.getStatus())) {
- iac = buildCallBackStatus(iac, param.getStatus());
- } else {
- if (StringUtils.isNotEmpty(param.getJqstatus())) {
- iac = buildCallBackStatus(iac, param.getJqstatus());
- }
- if (StringUtils.isNotEmpty(param.getSystatus())) {
- iac = buildCallBackStatus(iac, param.getSystatus());
- }
- }
- return iac;
- }
- /**
- * 构造回调状态
- *
- * @author: lig
- * @date: 2023-05-06
- */
- private InsAreaCompany buildCallBackStatus(InsAreaCompany iac, String status) {
- if (status.equals("9")) {
- iac.setOrderstatus(InsOrderStatus.S_2.getCode());
- //更新支付连接
- log.debug("准备进入获取支付连接######################");
- iac = getPayUrlApi(iac);
- log.debug("结束 - 准备进入获取支付连接######################");
- }
- if (status.equals("3")) {
- iac.setOrderstatus(InsOrderStatus.S_4.getCode());
- }
- if (status.equals("1")) {
- iac.setOrderstatus(InsOrderStatus.S_3.getCode());
- }
- return iac;
- }
- // /**
- // * 通过修改参数后 报价
- // *
- // * @author: lig
- // * @date: 2023年05月17日 0017
- // */
- // private RuoteResponse quoteApiByEdit(Ruote m) {
- //
- // RuoteResponse rd = null;
- //
- // log.debug("=========永诚API方式 - xml请求 - (修改参数后)报价开始======");
- // InsApiLog apiLog = httpPost(xmlMapper, m, YcBuildData.API_QUOTE);
- // log.debug("=========永诚API方式 - xml请求 - (修改参数后)报价结束!======");
- // verifyRequest(apiLog, null, InsQuoteFlow.Q_S_0);
- //
- // String responseData = apiLog.getResponseData();
- //
- // try {
- // String cleanStr = YcBuildData.cleanResponseStr(responseData);
- // rd = xmlMapper.readValue(cleanStr, RuoteResponse.class);
- //
- //
- // } catch (IOException e) {
- // log.error("=========永诚API方式 - xml请求 - (修改参数后)报价 错误:" + e.getMessage());
- // throw new RuntimeException(e);
- // }
- // return rd;
- //
- // }
- /**
- * 请求API接口,返回对象
- *
- * @author: lig
- * @date: 2023年05月18日 0018
- */
- private <T> T requestApi(Object m, T response, InsAreaCompany iac, String reqUrl, InsQuoteFlow iqf) {
- // private Object aaa(T m,T ruoteResponse,InsAreaCompany iac){
- //6 接口请求
- log.debug("=========永诚API方式 - xml请求 - {}开始======", iqf.getDesc());
- InsApiLog apiLog = httpPost(xmlMapper, m, reqUrl);
- log.debug("=========永诚API方式 - xml请求 - {}结束!======", iqf.getDesc());
- verifyRequest(apiLog, iac, iqf);
- String responseData = apiLog.getResponseData();
- String cleanStr = YcBuildData.cleanResponseStr(responseData);
- // Object rd = null;
- try {
- response = (T) xmlMapper.readValue(cleanStr, response.getClass());
- return response;
- } catch (JsonProcessingException e) {
- log.debug("=========永诚API方式 - xml请求 - {}解析报错:{}", iqf.getDesc(), e.getMessage());
- // throw new RuntimeException(e);
- throw new SystemException("请求接口失败,对象转换错误,请联系管理员。");
- }
- }
- // private boolean gainResultFlag(RuoteResponse rd,Ruote m){
- // boolean flag = false;
- // if (null == rd) {
- // throw new SystemException("远程请求报价失败");
- // }
- //
- // if (rd.getHead().getErrorCode().equals("000000")) {
- // //获取失败
- // boolean fail = !(StringUtils.isNotEmpty(rd.getVhl().getCQryCdeJQ()) || StringUtils.isNotEmpty(rd.getVhl().getCQryCdeSY()));
- // if (fail) {
- // //如果类型错误,修改类型后,继续报价
- // if (StringUtils.isNotEmpty(rd.getVhl().getCBusType())) {
- // //修改类型继续报价
- // m.getRequestLabel().getCondition().getVhl().setCBusType(rd.getVhl().getCBusType());
- // rd = requestApi(m, new RuoteResponse(), iac, YcBuildData.API_QUOTE, InsQuoteFlow.Q_S_0);
- // if (null == rd) return HttpResult.error("远程请求报价失败");
- // if (fail) {
- // throw new SystemException(rd.getHead().getErrorMessage());
- // }
- // }
- // throw new SystemException(rd.getHead().getErrorMessage());
- // }
- // } else {
- // throw new SystemException(rd.getHead().getErrorMessage());
- // }
- //
- // }
- private YcConfigureParameters gainYcConfigParams(String agreementId) {
- YcConfigureParameters ycConfigureParameters = new YcConfigureParameters();
- configureParametersComponents.toEntity(ycConfigureParameters, agreementId);
- return ycConfigureParameters;
- }
- }
|