|
|
@@ -1,311 +0,0 @@
|
|
|
-package com.ydtech.modules.order.service.impl;
|
|
|
-
|
|
|
-
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.ydtech.components.RenbaoRequestComponents;
|
|
|
-import com.ydtech.constants.enums.InsOrderStatus;
|
|
|
-import com.ydtech.core.page.HttpResult;
|
|
|
-import com.ydtech.exception.SystemException;
|
|
|
-import com.ydtech.modules.ins.convert.RenbaoQuoteResponseConvert;
|
|
|
-import com.ydtech.modules.ins.model.request.RenbaoAuditBody;
|
|
|
-import com.ydtech.modules.ins.model.request.RenbaoQuoteRespVo;
|
|
|
-import com.ydtech.modules.ins.model.request.RenbaoQuoteResponse;
|
|
|
-import com.ydtech.modules.ins.model.vo.*;
|
|
|
-import com.ydtech.modules.ins.model.ya.YaQuoteInfoVo;
|
|
|
-import com.ydtech.modules.order.entity.InsAreaCompany;
|
|
|
-import com.ydtech.modules.order.entity.InsOrders;
|
|
|
-import com.ydtech.modules.order.entity.vo.BaseQuoteInfoVo;
|
|
|
-import com.ydtech.modules.order.entity.vo.BaseQuoteVo;
|
|
|
-import com.ydtech.modules.order.service.InsAreaCompanyService;
|
|
|
-import com.ydtech.modules.order.service.InsOrdersService;
|
|
|
-import com.ydtech.modules.order.service.RenBaoOrderService;
|
|
|
-import com.ydtech.utils.idgen.IdGenerate;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.util.StringUtils;
|
|
|
-
|
|
|
-import java.math.BigDecimal;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-
|
|
|
-import static com.ydtech.constants.RedisConstant.INS_RENBAO_KEY;
|
|
|
-
|
|
|
-@Slf4j
|
|
|
-@Service
|
|
|
-public class RenBaoOrderServiceImpl implements RenBaoOrderService {
|
|
|
-
|
|
|
- private final RenbaoRequestComponents renbaoRequestComponents;
|
|
|
-
|
|
|
- private final StringRedisTemplate redisTemplate;
|
|
|
-
|
|
|
- private final InsAreaCompanyService insAreaCompanyService;
|
|
|
-
|
|
|
- private final InsOrdersService insOrdersService;
|
|
|
-
|
|
|
- public RenBaoOrderServiceImpl(RenbaoRequestComponents renbaoRequestComponents, StringRedisTemplate redisTemplate, InsAreaCompanyService insAreaCompanyService, InsOrdersService insOrdersService) {
|
|
|
- this.renbaoRequestComponents = renbaoRequestComponents;
|
|
|
- this.redisTemplate = redisTemplate;
|
|
|
- this.insAreaCompanyService = insAreaCompanyService;
|
|
|
- this.insOrdersService = insOrdersService;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public HttpResult quote(BaseQuoteInfoVo quoteInfoVo, BaseQuoteVo<Object> quoteVo) {
|
|
|
-
|
|
|
- // 1.封装人保请求
|
|
|
- RenbaoQuoteResponse body = renbaoRequestComponents.quote(quoteInfoVo, RenbaoQuoteResponse.class);
|
|
|
- if (body == null) {
|
|
|
- throw new SystemException("人保接口请求失败");
|
|
|
- }
|
|
|
- log.info(body.toString());
|
|
|
- if (body.getToken() == null) {
|
|
|
- String message = "人保--报价失败:" + body.getError();
|
|
|
- log.info(message);
|
|
|
- return HttpResult.error(message);
|
|
|
- }
|
|
|
- // 2.将人保的token存入redis
|
|
|
- RenbaoAuditBody renbaoAuditBody = RenbaoQuoteResponseConvert.INSTANCE.quote2Audit(body);
|
|
|
- String s = JSONObject.toJSONString(renbaoAuditBody);
|
|
|
- String orderNo = quoteInfoVo.getOrderNo();
|
|
|
- redisTemplate.opsForValue().set(INS_RENBAO_KEY + orderNo, s);
|
|
|
- RenbaoQuoteRespVo quoteRespVo = getQuoteRespVo(orderNo, Integer.parseInt(quoteInfoVo.getCarInfo().getSeatCount()), body, quoteInfoVo);
|
|
|
- // 3.插入订单
|
|
|
- return responseOrder(orderNo, body, quoteRespVo);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public HttpResult audit(String companyId) {
|
|
|
- InsAreaCompany insAreaCompany = insAreaCompanyService.getByIdIsExist(companyId);
|
|
|
- InsOrders insOrders = insOrdersService.getById(insAreaCompany.getOrderno());
|
|
|
- if (insOrders == null) {
|
|
|
- return HttpResult.error("订单不存在");
|
|
|
- }
|
|
|
-
|
|
|
- // 1.通过redis获取请求人保参数token
|
|
|
- String s = redisTemplate.opsForValue().get(INS_RENBAO_KEY + insOrders.getOrderno());
|
|
|
- RenbaoAuditBody response = JSON.parseObject(s, RenbaoAuditBody.class);
|
|
|
- // 2.请求人保核保接口
|
|
|
-// List<InsTaskImage> insTaskImages = insTaskImageService.selectByTaskId(orderno);
|
|
|
-// response.setInsTaskImageList(insTaskImages);
|
|
|
- Map body = renbaoRequestComponents.audit(response, Map.class);
|
|
|
- if (body == null) {
|
|
|
- throw new SystemException("人保接口请求失败");
|
|
|
- }
|
|
|
-
|
|
|
- // 3.核保不通过插入轨迹表
|
|
|
- if (StringUtils.isEmpty(body.get("epolicyUrlImg"))) {
|
|
|
-// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
-// InsTaskHistory history = new InsTaskHistory();
|
|
|
-// history.setId(String.valueOf(new Date().getTime()));
|
|
|
-// history.setCompany(order.getInscompany());
|
|
|
-// history.setTaskid(order.getOrderno());
|
|
|
-// history.setOperatorid(order.getUserid());
|
|
|
-// history.setOperator(order.getUsername());
|
|
|
-// history.setCreatetime(sdf.format(new Date()));
|
|
|
-// history.setStatus("4");
|
|
|
-// history.setRemark("核保不通过");
|
|
|
-// insTaskHistoryService.insert(history);
|
|
|
- return HttpResult.error("人保--核保失败:" + body.get("error"));
|
|
|
- }
|
|
|
-
|
|
|
- // 4. 更新订单表
|
|
|
- String epolicyUrlImg = (String) body.get("epolicyUrlImg");
|
|
|
- insAreaCompany.setAuditid(insOrders.getUserid());
|
|
|
- insAreaCompany.setPaymentLink(epolicyUrlImg);
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
-// order.setSubmittime(sdf.format(new Date()));
|
|
|
-// order.setJqapplyno(jqApplyno == null ? "" : jqApplyno);
|
|
|
-// order.setSyapplyno(syApplyno == null ? "" : syApplyno);
|
|
|
- insAreaCompany.setJqappoint(""); //交强特别约定
|
|
|
- insAreaCompany.setSyappoint(""); //商业特别约定
|
|
|
- insAreaCompany.setOrderstatus(InsOrderStatus.S_2.getCode()); // 5
|
|
|
-
|
|
|
- insAreaCompanyService.updateById(insAreaCompany);
|
|
|
-
|
|
|
- // 5.成功插入轨迹表
|
|
|
-// InsTaskHistory history = new InsTaskHistory();
|
|
|
-// history.setId(String.valueOf(new Date().getTime()));
|
|
|
-// history.setCompany(order.getInscompany());
|
|
|
-// history.setTaskid(order.getOrderno());
|
|
|
-// history.setOperatorid(order.getUserid());
|
|
|
-// history.setOperator(order.getUsername());
|
|
|
-// history.setCreatetime(sdf.format(new Date()));
|
|
|
-// history.setStatus(order.getOrderstatus());
|
|
|
-// history.setRemark("已核保待缴费");
|
|
|
-// insTaskHistoryService.insert(history);
|
|
|
- return HttpResult.ok();
|
|
|
- }
|
|
|
-
|
|
|
- private RenbaoQuoteRespVo getQuoteRespVo(String orderNo, int seatCount, RenbaoQuoteResponse response, YaQuoteInfoVo yaQuoteInfoVo) {
|
|
|
-
|
|
|
- double jqPremium = response.getKindCode_jiaoqiang();
|
|
|
- double syPremium = response.getKindCode_shangye();
|
|
|
-
|
|
|
- RenbaoQuoteRespVo quoteRespVo = new RenbaoQuoteRespVo();
|
|
|
-
|
|
|
- List<QuoteRiskRespVo> riskList1 = new ArrayList<>();
|
|
|
- List<QuoteKindRespVo> kindList1 = new ArrayList<>();
|
|
|
- List<RiskInfoVo> riskList = yaQuoteInfoVo.getRiskList();
|
|
|
- for (RiskInfoVo riskInfoVo : riskList) {
|
|
|
-
|
|
|
- if ("0507".equals(riskInfoVo.getRiskCode()) && jqPremium != 0) {
|
|
|
- QuoteRiskRespVo risk = new QuoteRiskRespVo();
|
|
|
- risk.setRiskCode("0507");
|
|
|
- risk.setRiskName("机动车交通事故责任强制保险");
|
|
|
- risk.setPremium(jqPremium);
|
|
|
- risk.setStartDate(riskInfoVo.getStartDate());
|
|
|
- risk.setEndDate(riskInfoVo.getEndDate());
|
|
|
- riskList1.add(risk);
|
|
|
- }
|
|
|
- if ("0510".equals(riskInfoVo.getRiskCode()) && syPremium != 0) {
|
|
|
- QuoteRiskRespVo risk = new QuoteRiskRespVo();
|
|
|
- risk.setRiskCode("0510");
|
|
|
- risk.setRiskName("机动车商业保险");
|
|
|
- risk.setPremium(syPremium);
|
|
|
- risk.setStartDate(riskInfoVo.getStartDate());
|
|
|
- risk.setEndDate(riskInfoVo.getEndDate());
|
|
|
- riskList1.add(risk);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- QuoteKindRespVo kind;
|
|
|
- List<KindInfoVo> kindList = yaQuoteInfoVo.getKindList();
|
|
|
- QuoteKindRespVo respVo = new QuoteKindRespVo();
|
|
|
-
|
|
|
- // 添加驾意险
|
|
|
- respVo.setKindCode("JYX");
|
|
|
- respVo.setKindName("驾意险");
|
|
|
- respVo.setAmount(response.getKindCode_EAD());
|
|
|
- respVo.setCoveragePremium(response.getKindCode_csx());
|
|
|
- kindList1.add(respVo);
|
|
|
- for (KindInfoVo kindInfoVo : kindList) {
|
|
|
- if ("A".equals(kindInfoVo.getKindCode())) {
|
|
|
- kind = new QuoteKindRespVo();
|
|
|
- kind.setKindCode("A");
|
|
|
- kind.setKindName("车辆损失保险");
|
|
|
- kind.setAmount(kindInfoVo.getAmount());
|
|
|
- kind.setCoveragePremium(response.getKindCode_csx());
|
|
|
- kindList1.add(kind);
|
|
|
- }
|
|
|
- if ("B".equals(kindInfoVo.getKindCode())) {
|
|
|
- kind = new QuoteKindRespVo();
|
|
|
- kind.setKindCode("B");
|
|
|
- kind.setKindName("第三者责任险");
|
|
|
- kind.setAmount(kindInfoVo.getAmount());
|
|
|
- kind.setCoveragePremium(response.getKindCode_dsz());
|
|
|
- kindList1.add(kind);
|
|
|
- }
|
|
|
- if ("D3".equals(kindInfoVo.getKindCode())) {
|
|
|
- kind = new QuoteKindRespVo();
|
|
|
- kind.setKindCode("D3");
|
|
|
- kind.setKindName("司机责任险");
|
|
|
- kind.setAmount(kindInfoVo.getAmount());
|
|
|
- kind.setCoveragePremium(response.getKindCode_cssj());
|
|
|
- kind.setUnitAmount(kindInfoVo.getUnitAmount());
|
|
|
- kindList1.add(kind);
|
|
|
- }
|
|
|
- if ("D4".equals(kindInfoVo.getKindCode())) {
|
|
|
- int seat = seatCount - 1;
|
|
|
- kind = new QuoteKindRespVo();
|
|
|
- kind.setKindCode("D4");
|
|
|
- kind.setKindName("乘客责任险");
|
|
|
- kind.setAmount(kindInfoVo.getAmount() / seat);
|
|
|
- kind.setAmount(kindInfoVo.getAmount());
|
|
|
- kind.setCoveragePremium(response.getKindCode_csck());
|
|
|
- kind.setQuantity(String.valueOf(seat));
|
|
|
- kind.setUnitAmount(kindInfoVo.getUnitAmount());
|
|
|
- kindList1.add(kind);
|
|
|
- }
|
|
|
- if ("MJ1".equals(kindInfoVo.getKindCode())) {
|
|
|
- kind = new QuoteKindRespVo();
|
|
|
- kind.setKindCode("MJ1");
|
|
|
- kind.setKindName("绝对免赔率特约险(车损)");
|
|
|
- kind.setAmount(kindInfoVo.getAmount());
|
|
|
- kind.setCoveragePremium(response.getKindCode_mplcs());
|
|
|
- kind.setDeductibleRate(Double.parseDouble(kindInfoVo.getDeductibleRate()));
|
|
|
- kindList1.add(kind);
|
|
|
- }
|
|
|
- if ("MJ2".equals(kindInfoVo.getKindCode())) {
|
|
|
- kind = new QuoteKindRespVo();
|
|
|
- kind.setKindCode("MJ2");
|
|
|
- kind.setKindName("绝对免赔率特约险(三者)");
|
|
|
- kind.setAmount(kindInfoVo.getAmount());
|
|
|
- kind.setCoveragePremium(response.getKindCode_dsz());
|
|
|
- kind.setDeductibleRate(Double.parseDouble(kindInfoVo.getDeductibleRate()));
|
|
|
- kindList1.add(kind);
|
|
|
- }
|
|
|
- if ("MJ3".equals(kindInfoVo.getKindCode())) {
|
|
|
- kind = new QuoteKindRespVo();
|
|
|
- kind.setKindCode("MJ3");
|
|
|
- kind.setKindName("绝对免赔率特约险(司机)");
|
|
|
- kind.setAmount(kindInfoVo.getAmount());
|
|
|
- kind.setCoveragePremium(response.getKindCode_sj());
|
|
|
- kind.setDeductibleRate(Double.parseDouble(kindInfoVo.getDeductibleRate()));
|
|
|
- kindList1.add(kind);
|
|
|
- }
|
|
|
- if ("MJ4".equals(kindInfoVo.getKindCode())) {
|
|
|
- kind = new QuoteKindRespVo();
|
|
|
- kind.setKindCode("MJ4");
|
|
|
- kind.setKindName("绝对免赔率特约险(乘客)");
|
|
|
- kind.setAmount(kindInfoVo.getAmount());
|
|
|
- kind.setCoveragePremium(response.getKindCode_ck());
|
|
|
- kind.setDeductibleRate(Double.parseDouble(kindInfoVo.getDeductibleRate()));
|
|
|
- kindList1.add(kind);
|
|
|
- }
|
|
|
- if ("L".equals(kindInfoVo.getKindCode())) {
|
|
|
- kind = new QuoteKindRespVo();
|
|
|
- kind.setKindCode("L");
|
|
|
- kind.setKindName("车身划痕损失险");
|
|
|
- kind.setAmount(kindInfoVo.getAmount());
|
|
|
- kind.setCoveragePremium(response.getKindCode_huahen());
|
|
|
- kindList1.add(kind);
|
|
|
- }
|
|
|
- if ("BD".equals(kindInfoVo.getKindCode())) {
|
|
|
- kind = new QuoteKindRespVo();
|
|
|
- kind.setKindCode("BD");
|
|
|
- kind.setKindName("法定节假日限额翻倍险");
|
|
|
- kind.setAmount(kindInfoVo.getAmount());
|
|
|
- kind.setCoveragePremium(response.getKindCode_fdfb());
|
|
|
- kindList1.add(kind);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- quoteRespVo.setDrivingAccidentPremium(response.getKindCode_EAD());
|
|
|
- quoteRespVo.setRiskList(riskList1);
|
|
|
- quoteRespVo.setKindList(kindList1);
|
|
|
- quoteRespVo.setJqPremium(jqPremium);
|
|
|
- quoteRespVo.setSyPremium(syPremium);
|
|
|
- quoteRespVo.setCiSumPermium(response.getKindCode_jiaoqiang() + response.getKindCode_chechuan());//交强险和车船税合计
|
|
|
- quoteRespVo.setSumPermium(response.getAll_price());//保费合计
|
|
|
- quoteRespVo.setTaxAmount(response.getKindCode_chechuan());//车船税
|
|
|
- quoteRespVo.setTotalAdjustRate(1);
|
|
|
- quoteRespVo.setILogPreUdwMess("0");//评分
|
|
|
- quoteRespVo.setOrderno(orderNo); //订单号
|
|
|
- return quoteRespVo;
|
|
|
- }
|
|
|
-
|
|
|
- private HttpResult responseOrder(String insOrder, RenbaoQuoteResponse response, QuoteRespVo quoteRespVo) {
|
|
|
- //保存订单信息
|
|
|
- InsAreaCompany insAreaCompany = new InsAreaCompany();
|
|
|
- insAreaCompany.setId(IdGenerate.nextId());
|
|
|
- insAreaCompany.setOrderno(insOrder);
|
|
|
- insAreaCompany.setReptxt(JSONObject.parseObject(JSONObject.toJSONString(response)));
|
|
|
- insAreaCompany.setJqpremium(BigDecimal.valueOf(response.getKindCode_jiaoqiang()));
|
|
|
- insAreaCompany.setSypremium(BigDecimal.valueOf(response.getKindCode_shangye()));
|
|
|
- insAreaCompany.setTaxamount(BigDecimal.valueOf(response.getKindCode_chechuan()));
|
|
|
- insAreaCompany.setSumpremium(BigDecimal.valueOf((response.getAll_price())));
|
|
|
- insAreaCompany.setOrderstatus(InsOrderStatus.S_0.getCode()); // 1
|
|
|
- insAreaCompany.setRiskinfo(JSONObject.parseArray(JSONObject.toJSONString(quoteRespVo.getRiskList())));
|
|
|
- insAreaCompany.setKindinfo(JSONObject.parseArray(JSONObject.toJSONString(quoteRespVo.getKindList())));
|
|
|
-// insAreaCompany.setJypremium(response.getKindCode_EAD());
|
|
|
- insAreaCompanyService.save(insAreaCompany);
|
|
|
- insAreaCompany.setInscompany("人保财险");
|
|
|
- quoteRespVo.setCompanyId(insAreaCompany.getId());
|
|
|
- return HttpResult.ok("成功", quoteRespVo);
|
|
|
- }
|
|
|
-
|
|
|
-}
|