| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607 |
- package com.ydtech.modules.ins.controller;
- import com.alibaba.fastjson.JSONArray;
- import com.alibaba.fastjson.JSONObject;
- 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.service.SysDeptService;
- import com.ydtech.modules.admin.service.SysUserService;
- import com.ydtech.modules.esm.model.EsmAgreement;
- import com.ydtech.modules.esm.model.EsmAgreementProd;
- import com.ydtech.modules.esm.model.EsmRetail;
- import com.ydtech.modules.esm.service.EsmAgreementProdService;
- import com.ydtech.modules.esm.service.EsmAgreementService;
- import com.ydtech.modules.esm.service.EsmRetailService;
- import com.ydtech.modules.esm.service.EsmUserInternalService;
- import com.ydtech.modules.ins.model.*;
- import com.ydtech.modules.ins.service.HuanongService;
- import com.ydtech.modules.ins.service.InsOrderService;
- import com.ydtech.modules.ins.service.InsTaskHistoryService;
- import com.ydtech.modules.ins.vo.*;
- import com.ydtech.utils.StringUtils;
- import com.ydtech.utils.baidu.Idcard;
- import com.ydtech.utils.baidu.MultiObjectDetect;
- import com.ydtech.utils.idgen.IdGenerate;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import java.math.BigDecimal;
- import java.text.SimpleDateFormat;
- import java.util.*;
- /**
- * @author qinfenglong
- * @version 1.0.0
- * @description InsHuanongController
- * @since 2020/11/16 16:43
- */
- @RestController
- @RequestMapping("/api/huanong")
- public class InsHuanongController {
- @Autowired
- HuanongService huanongService;
- @Autowired
- InsTaskHistoryService insTaskHistoryService;
- @Autowired
- InsOrderService insOrderService;
- @Autowired
- SysUserService sysUserService;
- @Autowired
- SysDeptService sysDeptService;
- @Autowired
- EsmAgreementService esmAgreementService;
- @Autowired
- EsmAgreementProdService esmAgreementProdService;
- @Autowired
- EsmRetailService esmRetailService;
- @Autowired
- EsmUserInternalService esmUserInternalService;
- // @GetMapping("/login")
- public void login() {
- huanongService.login();
- huanongService.querySales();
- }
- @PostMapping("/imgAI")
- public HttpResult imgAI(@RequestBody ImgInfo imgInfo) {
- HttpResult httpResult = new HttpResult();
- //图片识别
- JSONObject result = null;
- if (imgInfo.getImgType().equals("1")) {
- httpResult = Idcard.getIdCard(imgInfo.getImage());
- } else {
- httpResult = MultiObjectDetect.multiObjectDetect(imgInfo.getImage());
- }
- return httpResult;
- }
- // @PostMapping("/modelQuery")
- public HnValueVo modelQuery(HnValueVo hnValueVo) {
- String localModelCode = "";
- //实际价值
- JSONObject result = huanongService.modelQuery(hnValueVo.getLocalModelCode());
- if ("200".equals(result.getString("state"))) {
- JSONArray array = result.getJSONArray("data");
- for (int i = 0; i < array.size(); i++) {
- JSONObject obj = array.getJSONObject(i);
- if (hnValueVo.getPurchasePrice().equals(obj.getString("purchasePrice"))) {
- hnValueVo.setLocalModelCode(obj.getString("modelcode"));
- }
- }
- } else {
- login(); // 先登录
- result = huanongService.modelQuery(hnValueVo.getLocalModelCode());
- JSONArray array = result.getJSONArray("data");
- for (int i = 0; i < array.size(); i++) {
- JSONObject obj = array.getJSONObject(i);
- if (hnValueVo.getPurchasePrice().equals(obj.getString("purchasePrice"))) {
- hnValueVo.setLocalModelCode(obj.getString("modelcode"));
- }
- }
- }
- return hnValueVo;
- }
- // @PostMapping("/actualValue")
- public HttpResult actualValue(@RequestBody HnValueVo hnValueVo) {
- HttpResult httpResult = new HttpResult();
- hnValueVo = modelQuery(hnValueVo);
- //实际价值
- JSONObject result = huanongService.actualValue(hnValueVo);
- if ("200".equals(result.getString("state"))) {
- httpResult.setMsg(result.getString("message"));
- httpResult.setData(result.getJSONObject("data"));
- } else {
- login(); // 先登录
- result = huanongService.actualValue(hnValueVo);
- httpResult.setMsg(result.getString("message"));
- httpResult.setData(result.getJSONObject("data"));
- }
- return httpResult;
- }
- // @PostMapping("/quote")
- public HttpResult quote(@RequestBody QuoteInfoVo quoteInfo) {
- HttpResult httpResult = new HttpResult();
- HnQuoteInfo hnQuoteInfo = parseOjb(quoteInfo);
- //保存订单信息
- InsOrder insOrder = new InsOrder();
- String orderno = IdGenerate.nextId();
- // String quoteno = String.valueOf(new Date().getTime());
- insOrder.setOrderno(orderno);
- insOrder.setQuoteno(quoteInfo.getQuoteno());
- insOrder.setOrderstatus("0"); //0报价 1待核保 2已核保待缴费 3核保退回 4核保不通过
- insOrder.setFrameNo(quoteInfo.getCarInfo().getFrameNo());
- insOrder.setLicenseNo(quoteInfo.getCarInfo().getLicenseNo());
- insOrder.setCarinfo(JSONObject.parseObject(JSONObject.toJSONString(quoteInfo.getCarInfo())));
- SysUser user = sysUserService.selectByPk(quoteInfo.getUserId());
- if (user == null) {
- httpResult.setMsg("userId不存在");
- return httpResult;
- }
- //
- if (org.springframework.util.StringUtils.isEmpty(quoteInfo.getCarInfo().getFrameNo())) {
- httpResult.setMsg("车架号不能为空");
- return httpResult;
- }
- // 关闭订单 不含当前报价号
- InsOrder orderObj = insOrderService.queryQuoteno(new Object[]{quoteInfo.getUserId(), quoteInfo.getCarInfo().getFrameNo(), quoteInfo.getQuoteno()});
- if (orderObj != null) {
- List<InsOrder> list = insOrderService.selectList(" where quoteno=?", new Object[]{orderObj.getQuoteno()});
- String status = "0";
- for (InsOrder order : list) {
- if (!"0".equals(order.getOrderstatus())) {
- status = order.getOrderstatus();
- }
- }
- //0报价中 1待核保 2已核保 3核保退回 4核保不通过 5已核保待缴费 6已缴费 7已承保 99已关闭
- if ("0".equals(status)) {//关闭订单
- insOrderService.closeOrder(orderObj.getQuoteno(), "99");
- } else if (!"99".equals(status)) {
- httpResult.setMsg("此车辆已提交核保,重新报价请先关闭订单,任务号:" + orderObj.getQuoteno());
- return httpResult;
- }
- }
- insOrder.setUserid(quoteInfo.getUserId());
- insOrder.setUsername(user.getName());
- insOrder.setDeptid(user.getDeptId());
- SysDept dept = sysDeptService.getById(user.getDeptId());
- insOrder.setDeptname(dept == null ? "" : dept.getName());
- double retailRate = countRetail(user.getDeptId(), user.getId());
- // insOrder.setFeerate(0);
- // insOrder.setDisrate(0);
- insOrder.setOwnerinfo(JSONObject.parseObject(JSONObject.toJSONString(quoteInfo.getOwnerInfo())));
- insOrder.setApplyinfo(JSONObject.parseObject(JSONObject.toJSONString(quoteInfo.getPolicyHolderInfo())));
- insOrder.setInsureinfo(JSONObject.parseObject(JSONObject.toJSONString(quoteInfo.getInsuredPersonInfo())));
- insOrder.setInsuredname(quoteInfo.getPolicyHolderInfo().getName());
- List<RiskInfoVo> risks = quoteInfo.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());
- }
- }
- // insOrder.setJqstartdate("");
- // insOrder.setJqenddate("");
- // insOrder.setSystartdate("");
- // insOrder.setSyenddate("");
- // ZG01001 单交强
- // ZG01002 单三者
- // ZG01003 单商业
- // ZG01004 交强+三者 交强+三者 (交强的费用)
- // ZG01005 交强+三者 交强+三者(三者的费用)
- // ZG01006 交强+商业 交强+商业(交强的费用)
- // ZG01007 交强+商业 交强+商业(商业的费用)
- List<KindInfoVo> kinds = quoteInfo.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[]{"000002%", "%" + user.getDeptId() + "%"});
- if (agreements.size() == 0) {
- httpResult.setMsg("不存在有效协议或机构" + user.getDeptId() + "未授权");
- return httpResult;
- }
- 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(quoteInfo.getRiskList())));
- insOrder.setKindinfo(JSONObject.parseArray(JSONObject.toJSONString(quoteInfo.getKindList())));
- // insOrder.setJqpremium(0);
- // insOrder.setSypremium(0);
- // insOrder.setTaxamount(0);
- // insOrder.setSumpremium(0);
- insOrder.setInscompany("华农财险");
- // insOrder.setQuotestatus("0"); //报价状态 0失败 1成功
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- insOrder.setCreatetime(sdf.format(new Date()));
- insOrder.setReqtxt(JSONObject.parseObject(JSONObject.toJSONString(quoteInfo)));
- // insOrder.setReptxt("");
- //报价
- JSONObject result = huanongService.quote(hnQuoteInfo);
- if (!"200".equals(result.getString("state"))) {
- login(); // 先登录
- result = huanongService.quote(hnQuoteInfo);
- }
- if ("200".equals(result.getString("state"))) {
- QuoteRespVo quoteRespVo = new QuoteRespVo();
- JSONObject data = result.getJSONObject("data");
- quoteRespVo.setCiSumPermium(data.getDouble("ciSumPermium"));
- quoteRespVo.setSumPermium(data.getDouble("sumPermium"));
- quoteRespVo.setTotalAdjustRate(data.getDouble("totalAdjustRate"));
- quoteRespVo.setTaxAmount(data.getJSONObject("tax").getDouble("sumTax"));
- quoteRespVo.setILogPreUdwMess(data.getString("iLogPreUdwMess"));
- quoteRespVo.setOrderno(orderno); //订单号
- JSONArray riskList = data.getJSONArray("riskList");
- JSONArray kindList = data.getJSONArray("kindList");
- JSONObject obj = JSONObject.parseObject(JSONObject.toJSONString(quoteRespVo));
- obj.put("riskList", riskList);
- obj.put("kindList", kindList);
- httpResult.setData(obj);
- httpResult.setMsg("成功");
- //报价成功更新险种信息
- insOrder.setRiskinfo(JSONObject.parseArray(JSONObject.toJSONString(riskList)));
- insOrder.setKindinfo(JSONObject.parseArray(JSONObject.toJSONString(kindList)));
- BigDecimal jqPremium = new BigDecimal(data.getDouble("ciSumPermium") - data.getJSONObject("tax").getDouble("sumTax"));
- jqPremium = jqPremium.setScale(2, BigDecimal.ROUND_HALF_UP);
- insOrder.setJqpremium(jqPremium.doubleValue());
- double syPremium = data.getDouble("sumPermium") - data.getDouble("ciSumPermium");
- BigDecimal bd = new BigDecimal(syPremium);
- bd = bd.setScale(2, BigDecimal.ROUND_HALF_UP);
- syPremium = bd.doubleValue();
- insOrder.setSypremium(syPremium);
- insOrder.setTaxamount(data.getJSONObject("tax").getDouble("sumTax"));
- insOrder.setSumpremium(data.getDouble("sumPermium"));
- insOrder.setQuotestatus("1"); //报价状态 0失败 1成功
- } else if ("2".equals(result.getString("state"))) { //请选择品牌型号
- httpResult.setData(result.getJSONArray("data"));
- httpResult.setMsg(result.getString("message"));
- insOrder.setQuotestatus("0"); //报价状态 0失败 1成功
- } else if ("201".equals(result.getString("state"))) { //重复投保
- if (!StringUtils.isNullOrEmpty(result.getJSONObject("data").getString("quoteMessage"))) {
- httpResult.setMsg(result.getJSONObject("data").getString("quoteMessage"));
- } else {
- httpResult.setMsg(result.getString("message"));
- }
- JSONObject data = result.getJSONObject("data");
- JSONObject returnData = new JSONObject();
- returnData.put("state", result.getString("state"));
- returnData.put("lastDateBI", data.getString("lastDateBI"));
- returnData.put("lastDateCI", data.getString("lastDateCI"));
- if (data != null && data.getJSONObject("car") != null && !StringUtils.isNullOrEmpty(data.getJSONObject("car").getString("vin"))) {
- returnData.put("car", data.getJSONObject("car"));
- }
- // 返回报价结果
- QuoteRespVo quoteRespVo = new QuoteRespVo();
- quoteRespVo.setCiSumPermium(data.getDouble("ciSumPermium"));
- quoteRespVo.setSumPermium(data.getDouble("sumPermium"));
- quoteRespVo.setTotalAdjustRate(data.getDouble("totalAdjustRate"));
- quoteRespVo.setTaxAmount(data.getJSONObject("tax").getDouble("sumTax"));
- quoteRespVo.setILogPreUdwMess(data.getString("iLogPreUdwMess"));
- quoteRespVo.setOrderno(orderno); //订单号
- JSONArray riskList = data.getJSONArray("riskList");
- JSONArray kindList = data.getJSONArray("kindList");
- JSONObject obj = JSONObject.parseObject(JSONObject.toJSONString(quoteRespVo));
- obj.put("riskList", riskList);
- obj.put("kindList", kindList);
- returnData.put("data", obj);
- httpResult.setData(returnData);
- //报价成功更新险种信息
- insOrder.setRiskinfo(JSONObject.parseArray(JSONObject.toJSONString(riskList)));
- insOrder.setKindinfo(JSONObject.parseArray(JSONObject.toJSONString(kindList)));
- BigDecimal jqpremium = new BigDecimal(data.getDouble("ciSumPermium") - data.getJSONObject("tax").getDouble("sumTax"));
- jqpremium = jqpremium.setScale(2, BigDecimal.ROUND_HALF_UP);
- insOrder.setJqpremium(jqpremium.doubleValue());
- double syPremium = data.getDouble("sumPermium") - data.getDouble("ciSumPermium");
- BigDecimal bd = new BigDecimal(syPremium);
- bd = bd.setScale(2, BigDecimal.ROUND_HALF_UP);
- syPremium = bd.doubleValue();
- insOrder.setSypremium(syPremium);
- insOrder.setTaxamount(data.getJSONObject("tax").getDouble("sumTax"));
- insOrder.setSumpremium(data.getDouble("sumPermium"));
- insOrder.setQuotestatus("1"); //报价状态 0失败 1成功
- } else {
- JSONObject data = result.getJSONObject("data");
- JSONObject returnData = new JSONObject();
- returnData.put("state", result.getString("state"));
- if (data != null) {
- returnData.put("lastDateBI", data.getString("lastDateBI"));
- returnData.put("lastDateCI", data.getString("lastDateCI"));
- if (data != null && data.getJSONObject("car") != null && !StringUtils.isNullOrEmpty(data.getJSONObject("car").getString("vin"))) {
- returnData.put("car", data.getJSONObject("car"));
- }
- }
- httpResult.setMsg(result.getString("message"));
- httpResult.setData(returnData);
- insOrder.setQuotestatus("0"); //报价状态 0失败 1成功
- }
- insOrder.setReptxt(JSONObject.parseObject(JSONObject.toJSONString(httpResult)));
- insOrderService.insert(insOrder);
- //插入轨迹表
- SimpleDateFormat sdfm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- InsTaskHistory history = new InsTaskHistory();
- history.setId(String.valueOf(new Date().getTime()));
- history.setCompany(insOrder.getInscompany());
- history.setTaskid(insOrder.getOrderno());
- history.setOperatorid(insOrder.getAuditid());
- history.setOperator(insOrder.getUserid());
- history.setCreatetime(sdfm.format(new Date()));
- history.setOperator(insOrder.getInsuredname());
- history.setStatus("0");
- history.setRemark("报价中");
- insTaskHistoryService.insert(history);
- return httpResult;
- }
- /**
- * 获取缴费二维码
- *
- * @return
- * @PostMapping("/getPayCode") public HttpResult getPayCode(@RequestParam String orderno){
- * HttpResult httpResult = null;
- * InsOrder order = insOrderService.selectByPk(orderno);
- * if(order == null){
- * return HttpResult.error("订单不存在");
- * }
- * String licenseno = order.getLicenseNo();
- * String carowner = order.getInsuredname();
- * login(); // 先登录
- * httpResult = huanongService.queryOrder(licenseno);
- * <p>
- * return httpResult;
- * }
- */
- // @PostMapping("/queryCarInfo")
- public HttpResult queryCarInfo(@RequestBody QuoteInfoVo quoteInfo) {
- HttpResult httpResult = new HttpResult();
- HnQuoteInfo hnQuoteInfo = parseOjb(quoteInfo);
- //报价
- JSONObject result = huanongService.quote(hnQuoteInfo);
- if (!"200".equals(result.getString("state"))) {
- login(); // 先登录
- result = huanongService.quote(hnQuoteInfo);
- }
- if ("200".equals(result.getString("state"))) {
- QuoteRespVo quoteRespVo = new QuoteRespVo();
- JSONObject data = result.getJSONObject("data");
- quoteRespVo.setCiSumPermium(data.getDouble("ciSumPermium"));
- quoteRespVo.setSumPermium(data.getDouble("sumPermium"));
- quoteRespVo.setTotalAdjustRate(data.getDouble("totalAdjustRate"));
- quoteRespVo.setTaxAmount(data.getJSONObject("tax").getDouble("sumTax"));
- quoteRespVo.setILogPreUdwMess(data.getString("iLogPreUdwMess"));
- JSONArray riskList = data.getJSONArray("riskList");
- JSONArray kindList = data.getJSONArray("kindList");
- JSONObject obj = JSONObject.parseObject(JSONObject.toJSONString(quoteRespVo));
- obj.put("riskList", riskList);
- obj.put("kindList", kindList);
- httpResult.setData(obj);
- httpResult.setMsg("成功");
- } else if ("2".equals(result.getString("state"))) { //请选择品牌型号
- httpResult.setData(result.getJSONArray("data"));
- httpResult.setMsg(result.getString("message"));
- } else if ("201".equals(result.getString("state"))) { //重复投保
- if (!StringUtils.isNullOrEmpty(result.getJSONObject("data").getString("quoteMessage"))) {
- httpResult.setMsg(result.getJSONObject("data").getString("quoteMessage"));
- } else {
- httpResult.setMsg(result.getString("message"));
- }
- JSONObject data = result.getJSONObject("data");
- JSONObject returnData = new JSONObject();
- returnData.put("state", result.getString("state"));
- returnData.put("lastDateBI", data.getString("lastDateBI"));
- returnData.put("lastDateCI", data.getString("lastDateCI"));
- if (data != null && data.getJSONObject("car") != null && !StringUtils.isNullOrEmpty(data.getJSONObject("car").getString("vin"))) {
- returnData.put("car", data.getJSONObject("car"));
- }
- // 返回报价结果
- QuoteRespVo quoteRespVo = new QuoteRespVo();
- quoteRespVo.setCiSumPermium(data.getDouble("ciSumPermium"));
- quoteRespVo.setSumPermium(data.getDouble("sumPermium"));
- quoteRespVo.setTotalAdjustRate(data.getDouble("totalAdjustRate"));
- quoteRespVo.setTaxAmount(data.getJSONObject("tax").getDouble("sumTax"));
- quoteRespVo.setILogPreUdwMess(data.getString("iLogPreUdwMess"));
- JSONArray riskList = data.getJSONArray("riskList");
- JSONArray kindList = data.getJSONArray("kindList");
- JSONObject obj = JSONObject.parseObject(JSONObject.toJSONString(quoteRespVo));
- obj.put("riskList", riskList);
- obj.put("kindList", kindList);
- returnData.put("data", obj);
- httpResult.setData(returnData);
- } else {
- JSONObject data = result.getJSONObject("data");
- JSONObject returnData = new JSONObject();
- returnData.put("state", result.getString("state"));
- if (data != null) {
- returnData.put("lastDateBI", data.getString("lastDateBI"));
- returnData.put("lastDateCI", data.getString("lastDateCI"));
- if (data != null && data.getJSONObject("car") != null && !StringUtils.isNullOrEmpty(data.getJSONObject("car").getString("vin"))) {
- returnData.put("car", data.getJSONObject("car"));
- }
- }
- httpResult.setMsg(result.getString("message"));
- httpResult.setData(returnData);
- }
- return httpResult;
- }
- public HnQuoteInfo parseOjb(QuoteInfoVo quoteInfo) {
- //请求参数转换
- HnQuoteInfo hnQuoteInfo = new HnQuoteInfo();
- // 车辆信息
- HnCar car = new HnCar();
- car.setEcdemicVehicleFlag(false);
- car.setEngine(quoteInfo.getCarInfo().getEngineNo());
- car.setFirstBeneMan(quoteInfo.getCarInfo().getFirstBeneMan());
- car.setIssueDate(quoteInfo.getCarInfo().getIssueDate());
- car.setLoanStatus(quoteInfo.getCarInfo().isLoanStatus());
- car.setLocalModelCode(quoteInfo.getCarInfo().getModelCode());
- car.setModel(quoteInfo.getCarInfo().getModelcname());
- car.setModelCode(quoteInfo.getCarInfo().getCiModelCode());
- car.setMotorTypeCode(quoteInfo.getCarInfo().getCartype());
- car.setMotorUsageTypeCode(quoteInfo.getCarInfo().getCarnature());
- car.setNoLicenseFlag(quoteInfo.getCarInfo().isNoLicenseFlag());
- car.setPlateNo(quoteInfo.getCarInfo().getLicenseNo());
- car.setPlateType("02");
- car.setRegisterDate(quoteInfo.getCarInfo().getRegisterDate());
- car.setTransferFlag(quoteInfo.getCarInfo().isTransferFlag());
- car.setVin(quoteInfo.getCarInfo().getVinNo());
- hnQuoteInfo.setCar(car);
- // 客户信息
- HnCustomer customer = new HnCustomer();
- customer.setAddr(quoteInfo.getOwnerInfo().getAddr());
- customer.setIdentifyNo(quoteInfo.getOwnerInfo().getIdentifyNumber());
- customer.setIdentifyType(quoteInfo.getOwnerInfo().getIdentifyType());
- customer.setName(quoteInfo.getOwnerInfo().getName());
- customer.setType("1");
- hnQuoteInfo.setCustomer(customer);
- hnQuoteInfo.setKindList(quoteInfo.getKindList());
- hnQuoteInfo.setRiskList(quoteInfo.getRiskList());
- hnQuoteInfo.setUpdateDateFlag(false);
- //车船税
- HnTax tax = new HnTax();
- hnQuoteInfo.setTax(tax);
- return hnQuoteInfo;
- }
- /**
- * 分销费用统计
- *
- * @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;
- }
- @GetMapping("/vinQuery")
- public HttpResult vinQuery(@RequestParam String frameNo) {
- if(org.springframework.util.StringUtils.isEmpty(frameNo)){
- throw new SystemException("车架号不能为空");
- }
- return huanongService.vinQuery(frameNo);
- }
- }
|