InsHuanongController.java 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. package com.ydtech.modules.ins.controller;
  2. import com.alibaba.fastjson.JSONArray;
  3. import com.alibaba.fastjson.JSONObject;
  4. import com.ydtech.core.page.HttpResult;
  5. import com.ydtech.exception.SystemException;
  6. import com.ydtech.modules.admin.model.SysDept;
  7. import com.ydtech.modules.admin.model.SysUser;
  8. import com.ydtech.modules.admin.service.SysDeptService;
  9. import com.ydtech.modules.admin.service.SysUserService;
  10. import com.ydtech.modules.esm.model.EsmAgreement;
  11. import com.ydtech.modules.esm.model.EsmAgreementProd;
  12. import com.ydtech.modules.esm.model.EsmRetail;
  13. import com.ydtech.modules.esm.service.EsmAgreementProdService;
  14. import com.ydtech.modules.esm.service.EsmAgreementService;
  15. import com.ydtech.modules.esm.service.EsmRetailService;
  16. import com.ydtech.modules.esm.service.EsmUserInternalService;
  17. import com.ydtech.modules.ins.model.*;
  18. import com.ydtech.modules.ins.service.HuanongService;
  19. import com.ydtech.modules.ins.service.InsOrderService;
  20. import com.ydtech.modules.ins.service.InsTaskHistoryService;
  21. import com.ydtech.modules.ins.vo.*;
  22. import com.ydtech.utils.StringUtils;
  23. import com.ydtech.utils.baidu.Idcard;
  24. import com.ydtech.utils.baidu.MultiObjectDetect;
  25. import com.ydtech.utils.idgen.IdGenerate;
  26. import org.springframework.beans.factory.annotation.Autowired;
  27. import org.springframework.web.bind.annotation.*;
  28. import java.math.BigDecimal;
  29. import java.text.SimpleDateFormat;
  30. import java.util.*;
  31. /**
  32. * @author qinfenglong
  33. * @version 1.0.0
  34. * @description InsHuanongController
  35. * @since 2020/11/16 16:43
  36. */
  37. @RestController
  38. @RequestMapping("/api/huanong")
  39. public class InsHuanongController {
  40. @Autowired
  41. HuanongService huanongService;
  42. @Autowired
  43. InsTaskHistoryService insTaskHistoryService;
  44. @Autowired
  45. InsOrderService insOrderService;
  46. @Autowired
  47. SysUserService sysUserService;
  48. @Autowired
  49. SysDeptService sysDeptService;
  50. @Autowired
  51. EsmAgreementService esmAgreementService;
  52. @Autowired
  53. EsmAgreementProdService esmAgreementProdService;
  54. @Autowired
  55. EsmRetailService esmRetailService;
  56. @Autowired
  57. EsmUserInternalService esmUserInternalService;
  58. // @GetMapping("/login")
  59. public void login() {
  60. huanongService.login();
  61. huanongService.querySales();
  62. }
  63. @PostMapping("/imgAI")
  64. public HttpResult imgAI(@RequestBody ImgInfo imgInfo) {
  65. HttpResult httpResult = new HttpResult();
  66. //图片识别
  67. JSONObject result = null;
  68. if (imgInfo.getImgType().equals("1")) {
  69. httpResult = Idcard.getIdCard(imgInfo.getImage());
  70. } else {
  71. httpResult = MultiObjectDetect.multiObjectDetect(imgInfo.getImage());
  72. }
  73. return httpResult;
  74. }
  75. // @PostMapping("/modelQuery")
  76. public HnValueVo modelQuery(HnValueVo hnValueVo) {
  77. String localModelCode = "";
  78. //实际价值
  79. JSONObject result = huanongService.modelQuery(hnValueVo.getLocalModelCode());
  80. if ("200".equals(result.getString("state"))) {
  81. JSONArray array = result.getJSONArray("data");
  82. for (int i = 0; i < array.size(); i++) {
  83. JSONObject obj = array.getJSONObject(i);
  84. if (hnValueVo.getPurchasePrice().equals(obj.getString("purchasePrice"))) {
  85. hnValueVo.setLocalModelCode(obj.getString("modelcode"));
  86. }
  87. }
  88. } else {
  89. login(); // 先登录
  90. result = huanongService.modelQuery(hnValueVo.getLocalModelCode());
  91. JSONArray array = result.getJSONArray("data");
  92. for (int i = 0; i < array.size(); i++) {
  93. JSONObject obj = array.getJSONObject(i);
  94. if (hnValueVo.getPurchasePrice().equals(obj.getString("purchasePrice"))) {
  95. hnValueVo.setLocalModelCode(obj.getString("modelcode"));
  96. }
  97. }
  98. }
  99. return hnValueVo;
  100. }
  101. // @PostMapping("/actualValue")
  102. public HttpResult actualValue(@RequestBody HnValueVo hnValueVo) {
  103. HttpResult httpResult = new HttpResult();
  104. hnValueVo = modelQuery(hnValueVo);
  105. //实际价值
  106. JSONObject result = huanongService.actualValue(hnValueVo);
  107. if ("200".equals(result.getString("state"))) {
  108. httpResult.setMsg(result.getString("message"));
  109. httpResult.setData(result.getJSONObject("data"));
  110. } else {
  111. login(); // 先登录
  112. result = huanongService.actualValue(hnValueVo);
  113. httpResult.setMsg(result.getString("message"));
  114. httpResult.setData(result.getJSONObject("data"));
  115. }
  116. return httpResult;
  117. }
  118. // @PostMapping("/quote")
  119. public HttpResult quote(@RequestBody QuoteInfoVo quoteInfo) {
  120. HttpResult httpResult = new HttpResult();
  121. HnQuoteInfo hnQuoteInfo = parseOjb(quoteInfo);
  122. //保存订单信息
  123. InsOrder insOrder = new InsOrder();
  124. String orderno = IdGenerate.nextId();
  125. // String quoteno = String.valueOf(new Date().getTime());
  126. insOrder.setOrderno(orderno);
  127. insOrder.setQuoteno(quoteInfo.getQuoteno());
  128. insOrder.setOrderstatus("0"); //0报价 1待核保 2已核保待缴费 3核保退回 4核保不通过
  129. insOrder.setFrameNo(quoteInfo.getCarInfo().getFrameNo());
  130. insOrder.setLicenseNo(quoteInfo.getCarInfo().getLicenseNo());
  131. insOrder.setCarinfo(JSONObject.parseObject(JSONObject.toJSONString(quoteInfo.getCarInfo())));
  132. SysUser user = sysUserService.selectByPk(quoteInfo.getUserId());
  133. if (user == null) {
  134. httpResult.setMsg("userId不存在");
  135. return httpResult;
  136. }
  137. //
  138. if (org.springframework.util.StringUtils.isEmpty(quoteInfo.getCarInfo().getFrameNo())) {
  139. httpResult.setMsg("车架号不能为空");
  140. return httpResult;
  141. }
  142. // 关闭订单 不含当前报价号
  143. InsOrder orderObj = insOrderService.queryQuoteno(new Object[]{quoteInfo.getUserId(), quoteInfo.getCarInfo().getFrameNo(), quoteInfo.getQuoteno()});
  144. if (orderObj != null) {
  145. List<InsOrder> list = insOrderService.selectList(" where quoteno=?", new Object[]{orderObj.getQuoteno()});
  146. String status = "0";
  147. for (InsOrder order : list) {
  148. if (!"0".equals(order.getOrderstatus())) {
  149. status = order.getOrderstatus();
  150. }
  151. }
  152. //0报价中 1待核保 2已核保 3核保退回 4核保不通过 5已核保待缴费 6已缴费 7已承保 99已关闭
  153. if ("0".equals(status)) {//关闭订单
  154. insOrderService.closeOrder(orderObj.getQuoteno(), "99");
  155. } else if (!"99".equals(status)) {
  156. httpResult.setMsg("此车辆已提交核保,重新报价请先关闭订单,任务号:" + orderObj.getQuoteno());
  157. return httpResult;
  158. }
  159. }
  160. insOrder.setUserid(quoteInfo.getUserId());
  161. insOrder.setUsername(user.getName());
  162. insOrder.setDeptid(user.getDeptId());
  163. SysDept dept = sysDeptService.getById(user.getDeptId());
  164. insOrder.setDeptname(dept == null ? "" : dept.getName());
  165. double retailRate = countRetail(user.getDeptId(), user.getId());
  166. // insOrder.setFeerate(0);
  167. // insOrder.setDisrate(0);
  168. insOrder.setOwnerinfo(JSONObject.parseObject(JSONObject.toJSONString(quoteInfo.getOwnerInfo())));
  169. insOrder.setApplyinfo(JSONObject.parseObject(JSONObject.toJSONString(quoteInfo.getPolicyHolderInfo())));
  170. insOrder.setInsureinfo(JSONObject.parseObject(JSONObject.toJSONString(quoteInfo.getInsuredPersonInfo())));
  171. insOrder.setInsuredname(quoteInfo.getPolicyHolderInfo().getName());
  172. List<RiskInfoVo> risks = quoteInfo.getRiskList();
  173. for (RiskInfoVo risk : risks) {
  174. if ("0507".equals(risk.getRiskCode())) {//交强
  175. insOrder.setJqstartdate(risk.getStartDate());
  176. insOrder.setJqenddate(risk.getEndDate());
  177. }
  178. if ("0510".equals(risk.getRiskCode())) {//商业
  179. insOrder.setSystartdate(risk.getStartDate());
  180. insOrder.setSyenddate(risk.getEndDate());
  181. }
  182. }
  183. // insOrder.setJqstartdate("");
  184. // insOrder.setJqenddate("");
  185. // insOrder.setSystartdate("");
  186. // insOrder.setSyenddate("");
  187. // ZG01001 单交强
  188. // ZG01002 单三者
  189. // ZG01003 单商业
  190. // ZG01004 交强+三者 交强+三者 (交强的费用)
  191. // ZG01005 交强+三者 交强+三者(三者的费用)
  192. // ZG01006 交强+商业 交强+商业(交强的费用)
  193. // ZG01007 交强+商业 交强+商业(商业的费用)
  194. List<KindInfoVo> kinds = quoteInfo.getKindList();
  195. String productId = "";
  196. String productname = "";
  197. List<EsmAgreement> agreements = esmAgreementService.selectList(" where t.agreestatus='1' and t.insure1 like ? " +
  198. "and exists (select 1 from esm_agreement_prod t2 where t.id=t2.agreeid and t2.authcomcode like ?)", new Object[]{"000002%", "%" + user.getDeptId() + "%"});
  199. if (agreements.size() == 0) {
  200. httpResult.setMsg("不存在有效协议或机构" + user.getDeptId() + "未授权");
  201. return httpResult;
  202. }
  203. String agreeid = agreements.get(0).getId();
  204. insOrder.setAgreeid(agreeid);
  205. //匹配协议,获取费用
  206. StringBuffer whereStr = new StringBuffer();
  207. List params = new ArrayList();// where t.agreeid=? and t.productid in ()
  208. whereStr.append("where t.agreeid=? ");
  209. params.add(agreeid);
  210. if (risks.size() == 1 && "0507".equals(risks.get(0).getRiskCode())) {
  211. productId = "ZG01001";
  212. productname = "单交强";
  213. whereStr.append(" and t.productid=?");
  214. params.add(productId);
  215. } else if (risks.size() == 1 && kinds.size() == 1 && "B".equals(kinds.get(0).getKindCode())) {
  216. productId = "ZG01002";
  217. productname = "单三者";
  218. whereStr.append(" and t.productid=?");
  219. params.add(productId);
  220. } else if (risks.size() == 1) {
  221. productId = "ZG01003";
  222. productname = "单商业";
  223. whereStr.append(" and t.productid=?");
  224. params.add(productId);
  225. } else if (risks.size() == 2 && kinds.size() == 1 && "B".equals(kinds.get(0).getKindCode())) {
  226. productId = "ZG01004";
  227. productname = "交强+三者";
  228. whereStr.append(" and t.productid in (?,?)");
  229. params.add("ZG01004");
  230. params.add("ZG01005");
  231. } else {
  232. productId = "ZG01006";
  233. productname = "交强+商业";
  234. whereStr.append(" and t.productid in (?,?)");
  235. params.add("ZG01006");
  236. params.add("ZG01007");
  237. }
  238. insOrder.setProductid(productId);
  239. insOrder.setProduct(productname);
  240. List<EsmAgreementProd> agreementProds = esmAgreementProdService.selectList(whereStr.toString(), params.toArray());
  241. for (EsmAgreementProd prod : agreementProds) {
  242. if ("ZG01001".equals(prod.getProductid()) || "ZG01004".equals(prod.getProductid()) || "ZG01006".equals(prod.getProductid())) {
  243. insOrder.setFeerate(prod.getProductrate());//交强手续费比例
  244. insOrder.setJqdiscountrate(prod.getFeerate() - retailRate); //交强优惠比例=业务员绩效-分销费用
  245. } else {
  246. insOrder.setDisrate(prod.getProductrate()); //商业手续费比例
  247. insOrder.setSydiscountrate(prod.getFeerate() - retailRate); //商业优惠比例=业务员绩效-分销费用
  248. }
  249. insOrder.setProductid(prod.getId());
  250. }
  251. insOrder.setRiskinfo(JSONObject.parseArray(JSONObject.toJSONString(quoteInfo.getRiskList())));
  252. insOrder.setKindinfo(JSONObject.parseArray(JSONObject.toJSONString(quoteInfo.getKindList())));
  253. // insOrder.setJqpremium(0);
  254. // insOrder.setSypremium(0);
  255. // insOrder.setTaxamount(0);
  256. // insOrder.setSumpremium(0);
  257. insOrder.setInscompany("华农财险");
  258. // insOrder.setQuotestatus("0"); //报价状态 0失败 1成功
  259. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  260. insOrder.setCreatetime(sdf.format(new Date()));
  261. insOrder.setReqtxt(JSONObject.parseObject(JSONObject.toJSONString(quoteInfo)));
  262. // insOrder.setReptxt("");
  263. //报价
  264. JSONObject result = huanongService.quote(hnQuoteInfo);
  265. if (!"200".equals(result.getString("state"))) {
  266. login(); // 先登录
  267. result = huanongService.quote(hnQuoteInfo);
  268. }
  269. if ("200".equals(result.getString("state"))) {
  270. QuoteRespVo quoteRespVo = new QuoteRespVo();
  271. JSONObject data = result.getJSONObject("data");
  272. quoteRespVo.setCiSumPermium(data.getDouble("ciSumPermium"));
  273. quoteRespVo.setSumPermium(data.getDouble("sumPermium"));
  274. quoteRespVo.setTotalAdjustRate(data.getDouble("totalAdjustRate"));
  275. quoteRespVo.setTaxAmount(data.getJSONObject("tax").getDouble("sumTax"));
  276. quoteRespVo.setILogPreUdwMess(data.getString("iLogPreUdwMess"));
  277. quoteRespVo.setOrderno(orderno); //订单号
  278. JSONArray riskList = data.getJSONArray("riskList");
  279. JSONArray kindList = data.getJSONArray("kindList");
  280. JSONObject obj = JSONObject.parseObject(JSONObject.toJSONString(quoteRespVo));
  281. obj.put("riskList", riskList);
  282. obj.put("kindList", kindList);
  283. httpResult.setData(obj);
  284. httpResult.setMsg("成功");
  285. //报价成功更新险种信息
  286. insOrder.setRiskinfo(JSONObject.parseArray(JSONObject.toJSONString(riskList)));
  287. insOrder.setKindinfo(JSONObject.parseArray(JSONObject.toJSONString(kindList)));
  288. BigDecimal jqPremium = new BigDecimal(data.getDouble("ciSumPermium") - data.getJSONObject("tax").getDouble("sumTax"));
  289. jqPremium = jqPremium.setScale(2, BigDecimal.ROUND_HALF_UP);
  290. insOrder.setJqpremium(jqPremium.doubleValue());
  291. double syPremium = data.getDouble("sumPermium") - data.getDouble("ciSumPermium");
  292. BigDecimal bd = new BigDecimal(syPremium);
  293. bd = bd.setScale(2, BigDecimal.ROUND_HALF_UP);
  294. syPremium = bd.doubleValue();
  295. insOrder.setSypremium(syPremium);
  296. insOrder.setTaxamount(data.getJSONObject("tax").getDouble("sumTax"));
  297. insOrder.setSumpremium(data.getDouble("sumPermium"));
  298. insOrder.setQuotestatus("1"); //报价状态 0失败 1成功
  299. } else if ("2".equals(result.getString("state"))) { //请选择品牌型号
  300. httpResult.setData(result.getJSONArray("data"));
  301. httpResult.setMsg(result.getString("message"));
  302. insOrder.setQuotestatus("0"); //报价状态 0失败 1成功
  303. } else if ("201".equals(result.getString("state"))) { //重复投保
  304. if (!StringUtils.isNullOrEmpty(result.getJSONObject("data").getString("quoteMessage"))) {
  305. httpResult.setMsg(result.getJSONObject("data").getString("quoteMessage"));
  306. } else {
  307. httpResult.setMsg(result.getString("message"));
  308. }
  309. JSONObject data = result.getJSONObject("data");
  310. JSONObject returnData = new JSONObject();
  311. returnData.put("state", result.getString("state"));
  312. returnData.put("lastDateBI", data.getString("lastDateBI"));
  313. returnData.put("lastDateCI", data.getString("lastDateCI"));
  314. if (data != null && data.getJSONObject("car") != null && !StringUtils.isNullOrEmpty(data.getJSONObject("car").getString("vin"))) {
  315. returnData.put("car", data.getJSONObject("car"));
  316. }
  317. // 返回报价结果
  318. QuoteRespVo quoteRespVo = new QuoteRespVo();
  319. quoteRespVo.setCiSumPermium(data.getDouble("ciSumPermium"));
  320. quoteRespVo.setSumPermium(data.getDouble("sumPermium"));
  321. quoteRespVo.setTotalAdjustRate(data.getDouble("totalAdjustRate"));
  322. quoteRespVo.setTaxAmount(data.getJSONObject("tax").getDouble("sumTax"));
  323. quoteRespVo.setILogPreUdwMess(data.getString("iLogPreUdwMess"));
  324. quoteRespVo.setOrderno(orderno); //订单号
  325. JSONArray riskList = data.getJSONArray("riskList");
  326. JSONArray kindList = data.getJSONArray("kindList");
  327. JSONObject obj = JSONObject.parseObject(JSONObject.toJSONString(quoteRespVo));
  328. obj.put("riskList", riskList);
  329. obj.put("kindList", kindList);
  330. returnData.put("data", obj);
  331. httpResult.setData(returnData);
  332. //报价成功更新险种信息
  333. insOrder.setRiskinfo(JSONObject.parseArray(JSONObject.toJSONString(riskList)));
  334. insOrder.setKindinfo(JSONObject.parseArray(JSONObject.toJSONString(kindList)));
  335. BigDecimal jqpremium = new BigDecimal(data.getDouble("ciSumPermium") - data.getJSONObject("tax").getDouble("sumTax"));
  336. jqpremium = jqpremium.setScale(2, BigDecimal.ROUND_HALF_UP);
  337. insOrder.setJqpremium(jqpremium.doubleValue());
  338. double syPremium = data.getDouble("sumPermium") - data.getDouble("ciSumPermium");
  339. BigDecimal bd = new BigDecimal(syPremium);
  340. bd = bd.setScale(2, BigDecimal.ROUND_HALF_UP);
  341. syPremium = bd.doubleValue();
  342. insOrder.setSypremium(syPremium);
  343. insOrder.setTaxamount(data.getJSONObject("tax").getDouble("sumTax"));
  344. insOrder.setSumpremium(data.getDouble("sumPermium"));
  345. insOrder.setQuotestatus("1"); //报价状态 0失败 1成功
  346. } else {
  347. JSONObject data = result.getJSONObject("data");
  348. JSONObject returnData = new JSONObject();
  349. returnData.put("state", result.getString("state"));
  350. if (data != null) {
  351. returnData.put("lastDateBI", data.getString("lastDateBI"));
  352. returnData.put("lastDateCI", data.getString("lastDateCI"));
  353. if (data != null && data.getJSONObject("car") != null && !StringUtils.isNullOrEmpty(data.getJSONObject("car").getString("vin"))) {
  354. returnData.put("car", data.getJSONObject("car"));
  355. }
  356. }
  357. httpResult.setMsg(result.getString("message"));
  358. httpResult.setData(returnData);
  359. insOrder.setQuotestatus("0"); //报价状态 0失败 1成功
  360. }
  361. insOrder.setReptxt(JSONObject.parseObject(JSONObject.toJSONString(httpResult)));
  362. insOrderService.insert(insOrder);
  363. //插入轨迹表
  364. SimpleDateFormat sdfm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  365. InsTaskHistory history = new InsTaskHistory();
  366. history.setId(String.valueOf(new Date().getTime()));
  367. history.setCompany(insOrder.getInscompany());
  368. history.setTaskid(insOrder.getOrderno());
  369. history.setOperatorid(insOrder.getAuditid());
  370. history.setOperator(insOrder.getUserid());
  371. history.setCreatetime(sdfm.format(new Date()));
  372. history.setOperator(insOrder.getInsuredname());
  373. history.setStatus("0");
  374. history.setRemark("报价中");
  375. insTaskHistoryService.insert(history);
  376. return httpResult;
  377. }
  378. /**
  379. * 获取缴费二维码
  380. *
  381. * @return
  382. * @PostMapping("/getPayCode") public HttpResult getPayCode(@RequestParam String orderno){
  383. * HttpResult httpResult = null;
  384. * InsOrder order = insOrderService.selectByPk(orderno);
  385. * if(order == null){
  386. * return HttpResult.error("订单不存在");
  387. * }
  388. * String licenseno = order.getLicenseNo();
  389. * String carowner = order.getInsuredname();
  390. * login(); // 先登录
  391. * httpResult = huanongService.queryOrder(licenseno);
  392. * <p>
  393. * return httpResult;
  394. * }
  395. */
  396. // @PostMapping("/queryCarInfo")
  397. public HttpResult queryCarInfo(@RequestBody QuoteInfoVo quoteInfo) {
  398. HttpResult httpResult = new HttpResult();
  399. HnQuoteInfo hnQuoteInfo = parseOjb(quoteInfo);
  400. //报价
  401. JSONObject result = huanongService.quote(hnQuoteInfo);
  402. if (!"200".equals(result.getString("state"))) {
  403. login(); // 先登录
  404. result = huanongService.quote(hnQuoteInfo);
  405. }
  406. if ("200".equals(result.getString("state"))) {
  407. QuoteRespVo quoteRespVo = new QuoteRespVo();
  408. JSONObject data = result.getJSONObject("data");
  409. quoteRespVo.setCiSumPermium(data.getDouble("ciSumPermium"));
  410. quoteRespVo.setSumPermium(data.getDouble("sumPermium"));
  411. quoteRespVo.setTotalAdjustRate(data.getDouble("totalAdjustRate"));
  412. quoteRespVo.setTaxAmount(data.getJSONObject("tax").getDouble("sumTax"));
  413. quoteRespVo.setILogPreUdwMess(data.getString("iLogPreUdwMess"));
  414. JSONArray riskList = data.getJSONArray("riskList");
  415. JSONArray kindList = data.getJSONArray("kindList");
  416. JSONObject obj = JSONObject.parseObject(JSONObject.toJSONString(quoteRespVo));
  417. obj.put("riskList", riskList);
  418. obj.put("kindList", kindList);
  419. httpResult.setData(obj);
  420. httpResult.setMsg("成功");
  421. } else if ("2".equals(result.getString("state"))) { //请选择品牌型号
  422. httpResult.setData(result.getJSONArray("data"));
  423. httpResult.setMsg(result.getString("message"));
  424. } else if ("201".equals(result.getString("state"))) { //重复投保
  425. if (!StringUtils.isNullOrEmpty(result.getJSONObject("data").getString("quoteMessage"))) {
  426. httpResult.setMsg(result.getJSONObject("data").getString("quoteMessage"));
  427. } else {
  428. httpResult.setMsg(result.getString("message"));
  429. }
  430. JSONObject data = result.getJSONObject("data");
  431. JSONObject returnData = new JSONObject();
  432. returnData.put("state", result.getString("state"));
  433. returnData.put("lastDateBI", data.getString("lastDateBI"));
  434. returnData.put("lastDateCI", data.getString("lastDateCI"));
  435. if (data != null && data.getJSONObject("car") != null && !StringUtils.isNullOrEmpty(data.getJSONObject("car").getString("vin"))) {
  436. returnData.put("car", data.getJSONObject("car"));
  437. }
  438. // 返回报价结果
  439. QuoteRespVo quoteRespVo = new QuoteRespVo();
  440. quoteRespVo.setCiSumPermium(data.getDouble("ciSumPermium"));
  441. quoteRespVo.setSumPermium(data.getDouble("sumPermium"));
  442. quoteRespVo.setTotalAdjustRate(data.getDouble("totalAdjustRate"));
  443. quoteRespVo.setTaxAmount(data.getJSONObject("tax").getDouble("sumTax"));
  444. quoteRespVo.setILogPreUdwMess(data.getString("iLogPreUdwMess"));
  445. JSONArray riskList = data.getJSONArray("riskList");
  446. JSONArray kindList = data.getJSONArray("kindList");
  447. JSONObject obj = JSONObject.parseObject(JSONObject.toJSONString(quoteRespVo));
  448. obj.put("riskList", riskList);
  449. obj.put("kindList", kindList);
  450. returnData.put("data", obj);
  451. httpResult.setData(returnData);
  452. } else {
  453. JSONObject data = result.getJSONObject("data");
  454. JSONObject returnData = new JSONObject();
  455. returnData.put("state", result.getString("state"));
  456. if (data != null) {
  457. returnData.put("lastDateBI", data.getString("lastDateBI"));
  458. returnData.put("lastDateCI", data.getString("lastDateCI"));
  459. if (data != null && data.getJSONObject("car") != null && !StringUtils.isNullOrEmpty(data.getJSONObject("car").getString("vin"))) {
  460. returnData.put("car", data.getJSONObject("car"));
  461. }
  462. }
  463. httpResult.setMsg(result.getString("message"));
  464. httpResult.setData(returnData);
  465. }
  466. return httpResult;
  467. }
  468. public HnQuoteInfo parseOjb(QuoteInfoVo quoteInfo) {
  469. //请求参数转换
  470. HnQuoteInfo hnQuoteInfo = new HnQuoteInfo();
  471. // 车辆信息
  472. HnCar car = new HnCar();
  473. car.setEcdemicVehicleFlag(false);
  474. car.setEngine(quoteInfo.getCarInfo().getEngineNo());
  475. car.setFirstBeneMan(quoteInfo.getCarInfo().getFirstBeneMan());
  476. car.setIssueDate(quoteInfo.getCarInfo().getIssueDate());
  477. car.setLoanStatus(quoteInfo.getCarInfo().isLoanStatus());
  478. car.setLocalModelCode(quoteInfo.getCarInfo().getModelCode());
  479. car.setModel(quoteInfo.getCarInfo().getModelcname());
  480. car.setModelCode(quoteInfo.getCarInfo().getCiModelCode());
  481. car.setMotorTypeCode(quoteInfo.getCarInfo().getCartype());
  482. car.setMotorUsageTypeCode(quoteInfo.getCarInfo().getCarnature());
  483. car.setNoLicenseFlag(quoteInfo.getCarInfo().isNoLicenseFlag());
  484. car.setPlateNo(quoteInfo.getCarInfo().getLicenseNo());
  485. car.setPlateType("02");
  486. car.setRegisterDate(quoteInfo.getCarInfo().getRegisterDate());
  487. car.setTransferFlag(quoteInfo.getCarInfo().isTransferFlag());
  488. car.setVin(quoteInfo.getCarInfo().getVinNo());
  489. hnQuoteInfo.setCar(car);
  490. // 客户信息
  491. HnCustomer customer = new HnCustomer();
  492. customer.setAddr(quoteInfo.getOwnerInfo().getAddr());
  493. customer.setIdentifyNo(quoteInfo.getOwnerInfo().getIdentifyNumber());
  494. customer.setIdentifyType(quoteInfo.getOwnerInfo().getIdentifyType());
  495. customer.setName(quoteInfo.getOwnerInfo().getName());
  496. customer.setType("1");
  497. hnQuoteInfo.setCustomer(customer);
  498. hnQuoteInfo.setKindList(quoteInfo.getKindList());
  499. hnQuoteInfo.setRiskList(quoteInfo.getRiskList());
  500. hnQuoteInfo.setUpdateDateFlag(false);
  501. //车船税
  502. HnTax tax = new HnTax();
  503. hnQuoteInfo.setTax(tax);
  504. return hnQuoteInfo;
  505. }
  506. /**
  507. * 分销费用统计
  508. *
  509. * @param deptid
  510. * @param userid
  511. * @return
  512. */
  513. public double countRetail(String deptid, String userid) {
  514. double retailRate = 0;
  515. //1、根据机构匹配分销规则,获取分销比例
  516. List<EsmRetail> list = esmRetailService.selectList(" where deptid = ? and status=?", new Object[]{deptid, "1"});
  517. //2、根据userid查询三级推荐人
  518. List<SysUser> users = esmUserInternalService.getSuperior(userid);
  519. if (list != null && list.size() > 0 && users.size() > 0 && !"0".equals(list.get(0).getRetailtype())) {
  520. EsmRetail retail = list.get(0);
  521. List<Double> rateList = new ArrayList<Double>();
  522. rateList.add(retail.getDisrate1());
  523. rateList.add(retail.getDisrate2());
  524. rateList.add(retail.getDisrate3());
  525. if ("1".equals(retail.getRetailtype())) {//一级分销
  526. retailRate += rateList.get(0);
  527. } else if ("2".equals(retail.getRetailtype())) {//二级分销
  528. int num = users.size() > 2 ? 2 : users.size();
  529. for (int i = 0; i < num; i++) {
  530. retailRate += rateList.get(i);
  531. }
  532. } else {//三级分销
  533. int num = users.size() > 2 ? 3 : users.size();
  534. for (int i = 0; i < num; i++) {
  535. retailRate += rateList.get(i);
  536. }
  537. }
  538. }
  539. return retailRate;
  540. }
  541. @GetMapping("/vinQuery")
  542. public HttpResult vinQuery(@RequestParam String frameNo) {
  543. if(org.springframework.util.StringUtils.isEmpty(frameNo)){
  544. throw new SystemException("车架号不能为空");
  545. }
  546. return huanongService.vinQuery(frameNo);
  547. }
  548. }