package com.ydtech.modules.nai.controller; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.ydtech.core.page.HttpResult; 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.*; import com.ydtech.modules.esm.service.*; import com.ydtech.modules.ins.model.*; import com.ydtech.modules.ins.service.*; import com.ydtech.modules.ins.model.vo.KindInfoVo; import com.ydtech.modules.ins.model.vo.QuoteKindRespVo; import com.ydtech.modules.ins.model.vo.QuoteRespVo; import com.ydtech.modules.ins.model.vo.QuoteRiskRespVo; import com.ydtech.modules.nai.httpvo.*; import com.ydtech.utils.HttpsPostUtil; import com.ydtech.utils.idgen.IdGenerate; import io.swagger.annotations.Api; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; /** * @ClassName ChinaCoalInterface * @Description: TODO * @Author * @Date 2021/5/25 **/ @RestController @RequestMapping("zm") @Api(tags = "中煤API对接") public class ChinaCoalInterface { private static final Logger logger = LoggerFactory.getLogger(ChinaCoalInterface.class); @Autowired private InsTaskImageService InsTaskImageService; @Autowired Environment environment; @Autowired RenbaoService renbaoService; @Autowired InsOrderService insOrderService; @Autowired SysUserService sysUserService; @Autowired SysDeptService sysDeptService; @Autowired EsmAgreementService esmAgreementService; @Autowired EsmAgreementProdService esmAgreementProdService; @Autowired EsmRetailService esmRetailService; @Autowired EsmUserInternalService esmUserInternalService; @Autowired InsOrderTaskService insOrderTaskService; @Autowired InsTaskHistoryService insTaskHistoryService; @Autowired private InsFileLogService insFileLogService; @Autowired InsFeeDetailService insFeeDetailService; @Autowired EsmAgreementProdfeeService esmAgreementProdfeeService; @Autowired InsDeptFeeService insDeptFeeService; @Autowired InsCommissionService insCommissionService; /** * 车型查询接口 * * @param record * @param request * @return */ @PostMapping(value = "/ModelsQuery") public HttpResult ModelsQuery(@RequestBody ModelsQueryHeadVO record, HttpServletRequest request) { List list = null; //获取请求方法名称 String file = request.getRequestURI(); String method = file.substring(file.lastIndexOf("/") + 1); //获取请求地址 String zmUrl = environment.getProperty("ZMUrl"); String url = zmUrl + method + ".do"; logger.info("请求地址为:" + url); record.setModelName(record.getModelName()); HeadVO head = head(method); head.setToken(environment.getProperty("ZMToken")); record.setHead(head); String json = JSON.toJSONString(record); logger.info("请求参数为:" + json); String post = HttpsPostUtil.sendPost(url, json); if (!StringUtils.isEmpty(post)) { JSONObject jsonObject = null; jsonObject = JSONObject.parseObject(post); Map map = jsonObject; String simpleStadarCar = map.get("simpleStadarCar").toString(); list = JSONObject.parseArray(simpleStadarCar, SimpleStadarCarVO.class); logger.info("======车型查询接口返回为===============" + list); } return HttpResult.ok(list); } /** * 续保查询接口 * * @param record * @param request * @return */ @PostMapping(value = "/RenewalQuery") public HttpResult RenewalQuery(@RequestBody RenewalQueryHeadVO record, HttpServletRequest request) { //获取请求方法名称 String file = request.getRequestURI(); String method = file.substring(file.lastIndexOf("/") + 1); logger.info("最后一个/后的数据为:" + method); //获取请求地址 String zmUrl = environment.getProperty("ZMUrl"); logger.info("获取自定义属性路径为:" + environment.getProperty("ZMUrl")); String url = zmUrl + method + ".do"; record.setProvince("140000"); HeadVO head = head(method); head.setToken(environment.getProperty("ZMToken")); record.setHead(head); String json = JSON.toJSONString(record); logger.info("请求参数为:" + json); String post = HttpsPostUtil.sendPost(url, json); logger.info("==========续保查询接口返回===========" + post); return HttpResult.ok(post); } /** * 报价 * * @param record * @param request * @return */ @PostMapping(value = "/QuotedPrice") public HttpResult QuotedPrice(@RequestBody OfferVO record, HttpServletRequest request) { //获取请求方法名称 String s1 = JSONObject.toJSONString(record); logger.info("中煤报价接口QuotedPrice请求参数为" + s1); SimpleDateFormat sdfm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); HttpResult httpResult = new HttpResult(); QuotedPriceHeadVO recordHeadVO = new QuotedPriceHeadVO(); PolicyLocationVO policyLocationVO = new PolicyLocationVO(); BusinessDataVO businessDataVO = new BusinessDataVO(); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date = null; String file = request.getRequestURI(); String method = file.substring(file.lastIndexOf("/") + 1); //获取请求地址 String zmUrl = environment.getProperty("ZMUrl"); String url = zmUrl + method + ".do"; logger.info("请求地址为:" + url); policyLocationVO.setCity("140400"); policyLocationVO.setDistrict("140431"); policyLocationVO.setProvince("140000"); //参数组装 ZMCarInfoVO carInfo = record.getCarInfo(); List riskList = record.getRiskList(); PolicyCarVO policyCar = new PolicyCarVO(); SimpleStadarCarVO simpleStadarCarVO = new SimpleStadarCarVO(); InsuredObjectVO insuredObjectVO = new InsuredObjectVO(); ModelsQueryHeadVO records = new ModelsQueryHeadVO(); HeadVO shead = head("ModelsQuery"); records.setModelCode(carInfo.getLocalModelCode()); records.setModelName(carInfo.getBrandName()); records.setHead(shead); String json = JSON.toJSONString(records); logger.info("请求参数为:" + json); logger.info("车型查询接口请求地址" + url); String post = HttpsPostUtil.sendPost(url, json); logger.info("车型查询接口返回为" + post); String sumPremium = null; String bizPremium = null; String coverageList = null; String renewal; if (!StringUtils.isEmpty(post)) { JSONObject jsonObject = null; jsonObject = JSONObject.parseObject(post); Map map = jsonObject; String simpleStadarCar = map.get("simpleStadarCar").toString(); List s = JSONObject.parseArray(simpleStadarCar, SimpleStadarCarVO.class); for (int i = 0; i < s.size(); i++) { simpleStadarCarVO.setLocalModelCode(s.get(i).getLocalModelCode()); simpleStadarCarVO.setModelCode(s.get(i).getModelCode()); simpleStadarCarVO.setApprovedLoad(s.get(i).getApprovedLoad()); simpleStadarCarVO.setApprovedPassengersCapacity(s.get(i).getApprovedPassengersCapacity());//参数转换 simpleStadarCarVO.setDisplacement(s.get(i).getDisplacement());//类型转换 simpleStadarCarVO.setOriginalPurchasePrice(s.get(i).getOriginalPurchasePrice());//类型 simpleStadarCarVO.setEnergyTypes(s.get(i).getEnergyTypes()); simpleStadarCarVO.setBrand(s.get(i).getBrand()); simpleStadarCarVO.setBrandCode(s.get(i).getBrandCode()); // simpleStadarCarVO.setSeries(s.get(i).getSeries()); simpleStadarCarVO.setSeriesCode(s.get(i).getSeriesCode());// simpleStadarCarVO.setPower(s.get(i).getPower());//车牌号 simpleStadarCarVO.setUnladenMass(s.get(i).getUnladenMass());//类型转换 simpleStadarCarVO.setGrossMass(s.get(i).getGrossMass());// simpleStadarCarVO.setTractionMass(s.get(i).getTractionMass());// simpleStadarCarVO.setPurchasePrice(s.get(i).getPurchasePrice()); } } //policyCar组装 policyCar.setEngine(carInfo.getEngineNo()); policyCar.setNewCarSign(carInfo.getNoLicenseFlag()); policyCar.setPlateNo(carInfo.getLicenseNo()); policyCar.setVIN(carInfo.getVinNo()); policyCar.setEcdemicVehicleFlag(false); if (!Integer.toString(carInfo.getTransferFlag()).equals("")) { int transferFlag = carInfo.getTransferFlag(); if (transferFlag == 1) { policyCar.setChgOwnerFlag("01"); String transferDate = format.format(carInfo.getTransferDate()) + " 00:00:00"; policyCar.setTransferDate(transferDate); } else { policyCar.setChgOwnerFlag(Integer.toString(carInfo.getTransferFlag())); } } else { policyCar.setChgOwnerFlag(Integer.toString(carInfo.getTransferFlag())); } String a = format.format(carInfo.getRegisterDate()) + " 00:00:00"; policyCar.setRegisterDate(a); String c = format.format(carInfo.getIssueDate()) + " 00:00:00"; policyCar.setIssueDate(c);//carInfo.getIssueDate()时间类型 policyCar.setPlateType(carInfo.getLicenseTypeCode()); policyCar.setCarUseType(carInfo.getCarnature()); policyCar.setPlateColorCode("01"); policyCar.setCarCheckStatus("2"); //simpleStadarCar组装 insuredObjectVO.setPolicyCar(policyCar); List list = new ArrayList(); insuredObjectVO.setSimpleStadarCar(simpleStadarCarVO); CustomerVO customerVO = new CustomerVO(); ZMOwnerInfoVO zmOwnerInfoVO = record.getOwnerInfo(); ZMInsuredPersonInfoVO insuredPersonInfo = record.getInsuredPersonInfo(); ZMPolicyHolderInfoVO policyHolderInfo = record.getPolicyHolderInfo(); Map map = new HashMap(); Map map1 = new HashMap(); Map map2 = new HashMap(); int quantity = 0; if (zmOwnerInfoVO != null) { map.put("name", zmOwnerInfoVO.getName()); map.put("identifyType", zmOwnerInfoVO.getIdentifyType()); map.put("mobile", zmOwnerInfoVO.getMobile()); map.put("identifyNumber", zmOwnerInfoVO.getIdentifyNumber()); map.put("addr", zmOwnerInfoVO.getAddr()); map.put("role", "3"); map.put("invocieType", "026"); list.add(map); } if (policyHolderInfo != null) { map1.put("name", policyHolderInfo.getName()); map1.put("identifyType", policyHolderInfo.getIdentifyType()); map1.put("mobile", policyHolderInfo.getMobile()); map1.put("identifyNumber", policyHolderInfo.getIdentifyNumber()); map1.put("addr", policyHolderInfo.getAddr()); map1.put("role", "1"); map1.put("invocieType", "026"); map1.put("identifyValidDate", "2008/1/1 00:00:00"); map1.put("identifyValidEndDate", "2038/12/31 23:59:59"); list.add(map1); } if (insuredPersonInfo != null) { map2.put("name", insuredPersonInfo.getName()); map2.put("identifyType", insuredPersonInfo.getIdentifyType()); map2.put("mobile", insuredPersonInfo.getMobile()); map2.put("identifyNumber", insuredPersonInfo.getIdentifyNumber()); map2.put("addr", insuredPersonInfo.getAddr()); map2.put("role", "2"); map2.put("invocieType", "026"); list.add(map2); } InsOrder insOrder = new InsOrder(); 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.getById(record.getUserId()); if (user == null) { httpResult.setMsg("userId不存在"); return httpResult; } // if (org.springframework.util.StringUtils.isEmpty(record.getCarInfo().getFrameNo())) { httpResult.setMsg("车架号不能为空"); return httpResult; } // 关闭订单 不含当前报价号 InsOrder orderObj = insOrderService.queryQuoteno(new Object[]{record.getUserId(), record.getCarInfo().getFrameNo(), record.getQuoteno()}); if (orderObj != null) { List 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)) { httpResult.setMsg("此车辆已提交核保,重新报价请先关闭订单,任务号:" + orderObj.getQuoteno()); return httpResult; } } 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.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()); Map map4 = new HashMap(); List lists = new ArrayList(); List listt = new ArrayList(); List list2 = new ArrayList(); List list6 = new ArrayList(); String startDate0510 = null; String endDate0510 = null; String endDate0507 = null; String startDate0507 = null; double unitAmounts = 0; for (int i = 0; i < riskList.size(); i++) { ContractVO contractVOx = new ContractVO(); if (riskList.get(i).getRiskCode().equals("0510")) { List kindList = record.getKindList(); for (int j = 0; j < kindList.size(); j++) { KindInfoVo kindInfoVo = kindList.get(j); String deductibleRate = kindInfoVo.getDeductibleRate(); BigDecimal setScale = null; if (deductibleRate != null) { BigDecimal b1 = new BigDecimal(Double.parseDouble(deductibleRate)); BigDecimal b2 = b1.divide(new BigDecimal(-1d)); setScale = b2.setScale(4, 4); } //第三者责任险 if (kindList.get(j).getKindCode().equals("B")) { Map mapsv = new HashMap(); mapsv.put("amount", (int) kindList.get(j).getAmount()); mapsv.put("unitAmount", 0); mapsv.put("deductibleRate", setScale); mapsv.put("deductible", "0.0"); mapsv.put("relatedInd", "1"); mapsv.put("kindCode", "02"); mapsv.put("kindName", kindList.get(j).getKindName()); lists.add(mapsv); } //乘客责任险 if (kindList.get(j).getKindCode().equals("D4")) { Map mapsq = new HashMap(); mapsq.put("amount", (int) kindList.get(j).getUnitAmount() * (simpleStadarCarVO.getApprovedPassengersCapacity() - 1)); unitAmounts = kindList.get(j).getUnitAmount(); mapsq.put("unitAmount", kindList.get(j).getUnitAmount()); mapsq.put("deductibleRate", setScale); quantity = simpleStadarCarVO.getApprovedPassengersCapacity(); mapsq.put("quantity", simpleStadarCarVO.getApprovedPassengersCapacity() - 1); mapsq.put("relatedInd", "1"); mapsq.put("kindCode", "044"); mapsq.put("kindName", kindList.get(j).getKindName()); lists.add(mapsq); } //机动车损失险 if (kindList.get(j).getKindCode().equals("A")) { Map mapsa = new HashMap(); mapsa.put("amount", 0); mapsa.put("unitAmount", 0); mapsa.put("deductibleRate", setScale); mapsa.put("deductible", "0.0"); mapsa.put("relatedInd", "1"); mapsa.put("kindCode", "01"); mapsa.put("kindName", kindList.get(j).getKindName()); lists.add(mapsa); } //司机责任险 if (kindList.get(j).getKindCode().equals("D3")) { Map mapsd = new HashMap(); mapsd.put("amount", (int) kindList.get(j).getAmount()); mapsd.put("unitAmount", kindList.get(j).getAmount()); mapsd.put("deductibleRate", setScale); mapsd.put("quantity", "1"); mapsd.put("deductible", "0.0"); mapsd.put("relatedInd", "1"); mapsd.put("kindCode", "041"); mapsd.put("kindName", kindList.get(j).getKindName()); lists.add(mapsd); } if (kindList.get(j).getKindCode().equals("MJ1")) { Map mapsd = new HashMap(); mapsd.put("amount", (int) kindList.get(j).getAmount()); mapsd.put("unitAmount", kindList.get(j).getAmount()); mapsd.put("deductibleRate", setScale); mapsd.put("quantity", "1"); mapsd.put("deductible", "0.0"); mapsd.put("relatedInd", "1"); //附加绝对免赔率特约条款(车损) mapsd.put("kindCode", "501"); mapsd.put("kindName", kindList.get(j).getKindName()); mapsd.put("deductibleRate", setScale); lists.add(mapsd); } if (kindList.get(j).getKindCode().equals("MJ2")) { Map mapsd = new HashMap(); mapsd.put("amount", (int) kindList.get(j).getAmount()); mapsd.put("unitAmount", kindList.get(j).getAmount()); mapsd.put("deductibleRate", setScale); mapsd.put("quantity", "1"); mapsd.put("deductible", "0.0"); mapsd.put("relatedInd", "1"); mapsd.put("kindCode", "502"); mapsd.put("kindName", kindList.get(j).getKindName()); mapsd.put("deductibleRate", setScale); lists.add(mapsd); } if (kindList.get(j).getKindCode().equals("MJ3")) { Map mapsd = new HashMap(); mapsd.put("amount", (int) kindList.get(j).getAmount()); mapsd.put("unitAmount", kindList.get(j).getAmount()); mapsd.put("deductibleRate", setScale); mapsd.put("quantity", "1"); mapsd.put("deductible", "0.0"); mapsd.put("relatedInd", "1"); mapsd.put("kindCode", "5041"); mapsd.put("kindName", kindList.get(j).getKindName()); mapsd.put("deductibleRate", setScale); lists.add(mapsd); } if (kindList.get(j).getKindCode().equals("MJ4")) { Map mapsd = new HashMap(); mapsd.put("amount", (int) kindList.get(j).getAmount()); mapsd.put("unitAmount", kindList.get(j).getAmount()); mapsd.put("deductibleRate", setScale); mapsd.put("quantity", "1"); mapsd.put("deductible", "0.0"); mapsd.put("relatedInd", "1"); mapsd.put("deductibleRate", setScale); mapsd.put("kindCode", "5044"); mapsd.put("kindName", kindList.get(j).getKindName()); lists.add(mapsd); } if (kindList.get(j).getKindCode().equals("L")) { Map mapsd = new HashMap(); mapsd.put("amount", (int) kindList.get(j).getAmount()); mapsd.put("unitAmount", kindList.get(j).getAmount()); mapsd.put("deductibleRate", setScale); mapsd.put("quantity", "1"); mapsd.put("deductible", "0.0"); mapsd.put("relatedInd", "1"); mapsd.put("deductibleRate", setScale); mapsd.put("kindCode", "21"); mapsd.put("kindName", kindList.get(j).getKindName()); lists.add(mapsd); } if (kindList.get(j).getKindCode().equals("BD")) { Map mapsd = new HashMap(); mapsd.put("amount", (int) kindList.get(j).getAmount()); mapsd.put("unitAmount", kindList.get(j).getAmount()); mapsd.put("deductibleRate", setScale); mapsd.put("quantity", "1"); mapsd.put("deductible", "0.0"); mapsd.put("relatedInd", "1"); mapsd.put("deductibleRate", setScale); mapsd.put("kindCode", "49"); mapsd.put("kindName", kindList.get(j).getKindName()); lists.add(mapsd); } } ContractMainVO me = new ContractMainVO(); try { String endDate = riskList.get(i).getEndDate() + ":00"; String sdate = "00:00"; String substring = endDate.substring(endDate.length() - 5); if (sdate.equals(substring)) { date = format.parse(riskList.get(i).getEndDate() + ":00"); date.setTime(date.getTime() - 1000 + +1000 * 60 * 60 * 24 * 1); } else { date = format.parse(riskList.get(i).getEndDate() + ":00"); map4.put("ReinsuranceFlag", "1"); } } catch (ParseException e) { e.printStackTrace(); } me.setExpiryDate(df.format(date)); me.setRiskCode("0361"); startDate0510 = riskList.get(i).getStartDate() + ":00".toString(); endDate0510 = riskList.get(i).getEndDate() + ":00".toString(); me.setValidDate(riskList.get(i).getStartDate() + ":00".toString()); map4.put("expiryDate", df.format(date)); map4.put("riskCode", "0361"); map4.put("validDate", riskList.get(i).getStartDate() + ":00"); list2.add(map4); contractVOx.setContractMain(me); contractVOx.setCoverage(lists); } if (riskList.get(i).getRiskCode().equals("0507")) { ContractMainVO me = new ContractMainVO(); try { date = format.parse(riskList.get(i).getEndDate() + ":00"); } catch (ParseException e) { e.printStackTrace(); } startDate0507 = riskList.get(i).getStartDate() + ":00"; endDate0507 = riskList.get(i).getEndDate() + ":00"; date.setTime(date.getTime() - 1000 + 1000 * 60 * 60 * 24 * 1); me.setExpiryDate(df.format(date)); me.setRiskCode("0330"); String startDate = riskList.get(i).getStartDate() + ":00"; String endDate = riskList.get(i).getEndDate() + ":00"; me.setValidDate(riskList.get(i).getStartDate() + ":00"); Map mapwe = new HashMap(); mapwe.put("amount", 2000); mapwe.put("kindCode", "BZ"); mapwe.put("kindName", "机动车交通事故责任强制险"); listt.add(mapwe); contractVOx.setCoverage(listt); contractVOx.setContractMain(me); } list6.add(contractVOx); } customerVO.setMobile(insuredPersonInfo.getMobile()); customerVO.setName(insuredPersonInfo.getName()); customerVO.setInsuredType(026); customerVO.setRole("3"); insOrder.setInsuredname(record.getPolicyHolderInfo().getName()); HeadVO heads = head(method); businessDataVO.setCustomer(list); businessDataVO.setInsuredObject(insuredObjectVO); businessDataVO.setPolicyLocation(policyLocationVO); businessDataVO.setContract(list6); recordHeadVO.setHead(heads); recordHeadVO.setBusinessData(businessDataVO); String json1 = JSON.toJSONString(recordHeadVO); logger.info("报价接口请求参数为:" + json1); String posts = HttpsPostUtil.sendPost(url, json1); logger.info("报价接口返回参数为:" + posts); HeadMessage headMessage = null; String returnMessage = null; String returnCode = null; if (posts != null && !posts.equals("")) { headMessage = HttpsPostUtil.HeadMessage(posts); returnMessage = headMessage.getReturnMessage(); returnCode = headMessage.getReturnCode(); } Double Vehicle = null; //保存订单信息 if (returnCode != null && returnCode.equals("0")) { List risks = record.getRiskList(); for (ZMRiskListVO 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 kinds = record.getKindList(); String productId = ""; String productname = ""; List 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[]{"000019%", "%" + 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 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()))); insOrder.setInscompany("中煤财险"); insOrder.setCreatetime(sdfm.format(new Date())); List quoteKindRespVos = new ArrayList<>(); QuoteRespVo quoteRespVo = new QuoteRespVo(); QuoteRiskRespVo riskLists = new QuoteRiskRespVo(); QuoteKindRespVo kindList = new QuoteKindRespVo(); JSONObject jsonObject = JSONObject.parseObject(posts); Map maps = jsonObject; String payTax = null; String sumPayTax = null; String taxinfo = null; Object s = maps.get("taxinfo"); if (s != null) { taxinfo = maps.get("taxinfo").toString(); } if (taxinfo != null) { jsonObject = JSONObject.parseObject(taxinfo); Map mapssx = jsonObject; sumPayTax = mapssx.get("sumPayTax").toString(); if (!StringUtils.isEmpty(mapssx.get("payTax").toString())) { payTax = mapssx.get("payTax").toString(); } } Object t = maps.get("bizPremium"); if (t != null) { bizPremium = maps.get("bizPremium").toString(); } if (bizPremium != null) { jsonObject = JSONObject.parseObject(bizPremium); Map mapsss = jsonObject; sumPremium = mapsss.get("sumPremium").toString(); jsonObject = JSONObject.parseObject(bizPremium); Map mapssss = jsonObject; coverageList = mapssss.get("coverageList").toString(); // renewal = mapssss.get("isRenewal").toString(); riskLists.setPremium(Double.parseDouble(sumPremium)); } String forcePrimium = null; Object z = maps.get("forcePrimium"); String premium = null; String amount = null; if (z != null) { forcePrimium = maps.get("forcePrimium").toString(); jsonObject = JSONObject.parseObject(forcePrimium); Map mapsx = jsonObject; premium = mapsx.get("premium").toString(); Vehicle = Double.parseDouble(premium); amount = mapsx.get("amount").toString(); } List listz = new ArrayList(); JSONArray jsonArraysss; quoteKindRespVos.add(kindList); if (sumPayTax != null) { quoteRespVo.setTaxAmount(Double.parseDouble(sumPayTax)); } if (premium != null) { kindList.setCoveragePremium(Double.parseDouble(premium)); } quoteRespVo.setKindList(quoteKindRespVos); List riskList1 = new ArrayList<>(); QuoteRiskRespVo risk = new QuoteRiskRespVo(); if (forcePrimium != null) { risk.setRiskCode("0507"); risk.setRiskName("机动车交通事故责任强制保险"); risk.setPremium(Double.parseDouble(premium)); Double premium2 = Double.parseDouble(premium); risk.setAmount(Double.parseDouble(amount)); risk.setStartDate(startDate0507); risk.setEndDate(endDate0507); riskList1.add(risk); } double syPremium = 0; if (bizPremium != null && !bizPremium.equals("")) { risk = new QuoteRiskRespVo(); risk.setRiskCode("0510"); risk.setRiskName("机动车商业保险"); BigDecimal bd = new BigDecimal(sumPremium); bd = bd.setScale(2, BigDecimal.ROUND_HALF_UP); syPremium = bd.doubleValue(); risk.setPremium(syPremium); risk.setStartDate(startDate0510); risk.setEndDate(endDate0510); riskList1.add(risk); } List kindList1 = new ArrayList<>(); if (JSONObject.parseArray(coverageList) != null) { jsonArraysss = JSONObject.parseArray(coverageList); for (int i = 0; i < jsonArraysss.size(); i++) { JSONObject object = jsonArraysss.getJSONObject(i); listz.add(premium); } for (int i = 0; i < jsonArraysss.size(); i++) { JSONObject obj = jsonArraysss.getJSONObject(i); String kindcode = obj.getString("kindCode"); QuoteKindRespVo kind = null; if ("01".equals(obj.getString("kindCode"))) { kind = new QuoteKindRespVo(); kind.setKindCode("A"); kind.setKindName("车辆损失保险"); kind.setAmount(obj.getDouble("amount")); kind.setCoveragePremium(obj.getDouble("premium")); kindList1.add(kind); } if ("02".equals(obj.getString("kindCode"))) { kind = new QuoteKindRespVo(); kind.setKindCode("B"); kind.setKindName("第三者责任险"); kind.setAmount(obj.getDouble("amount")); kind.setCoveragePremium(obj.getDouble("premium")); kindList1.add(kind); } if ("041".equals(obj.getString("kindCode"))) { kind = new QuoteKindRespVo(); kind.setKindCode("D3"); kind.setKindName("司机责任险"); kind.setAmount(obj.getDouble("amount")); kind.setCoveragePremium(obj.getDouble("premium")); kind.setUnitAmount(obj.getDouble("amount")); kindList1.add(kind); } if ("044".equals(obj.getString("kindCode"))) { kind = new QuoteKindRespVo(); kind.setKindCode("D4"); kind.setKindName("乘客责任险"); kind.setUnitAmount(unitAmounts); kind.setAmount(obj.getDouble("amount")); kind.setCoveragePremium(obj.getDouble("premium")); kind.setQuantity(String.valueOf(quantity - 1)); // kind.setUnitAmount(obj.getDouble("unitAmount")); kindList1.add(kind); } if ("501".equals(obj.getString("kindCode"))) { kind = new QuoteKindRespVo(); kind.setKindCode("MJ1"); kind.setKindName("绝对免赔率特约险(车损)"); kind.setAmount(obj.getDouble("amount")); kind.setCoveragePremium(obj.getDouble("premium")); kindList1.add(kind); } if ("502".equals(obj.getString("kindCode"))) { kind = new QuoteKindRespVo(); kind.setKindCode("MJ2"); kind.setKindName("绝对免赔率特约险(三者)"); kind.setAmount(obj.getDouble("amount")); kind.setCoveragePremium(obj.getDouble("premium")); kindList1.add(kind); } if ("5041".equals(obj.getString("kindCode"))) { kind = new QuoteKindRespVo(); kind.setKindCode("MJ3"); kind.setKindName("绝对免赔率特约险(司机)"); kind.setAmount(obj.getDouble("amount")); kind.setCoveragePremium(obj.getDouble("premium")); kindList1.add(kind); } if ("5044".equals(obj.getString("kindCode"))) { kind = new QuoteKindRespVo(); kind.setKindCode("MJ4"); kind.setKindName("绝对免赔率特约险(乘客)"); kind.setAmount(obj.getDouble("amount")); kind.setCoveragePremium(obj.getDouble("premium")); kindList1.add(kind); } if ("21".equals(obj.getString("kindCode"))) { kind = new QuoteKindRespVo(); kind.setKindCode("L"); kind.setKindName("车身划痕损失险"); kind.setAmount(obj.getDouble("amount")); kind.setCoveragePremium(obj.getDouble("premium")); kindList1.add(kind); } if ("49".equals(obj.getString("kindCode"))) { kind = new QuoteKindRespVo(); kind.setKindCode("BD"); kind.setKindName("法定节假日限额翻倍险"); kind.setAmount(obj.getDouble("amount")); kind.setCoveragePremium(obj.getDouble("premium")); kindList1.add(kind); } } } //贴过来的 if (premium != null) { BigDecimal sumPremium2 = new BigDecimal(premium); sumPremium2 = sumPremium2.setScale(2, BigDecimal.ROUND_HALF_UP); BigDecimal jqpremium = new BigDecimal(sumPremium2.doubleValue() + Double.parseDouble(payTax)); jqpremium = jqpremium.setScale(2, BigDecimal.ROUND_HALF_UP); quoteRespVo.setCiSumPermium(jqpremium.doubleValue()); //交强险和车船税合计 } if (premium != null && !premium.equals("") && sumPremium != null && !sumPremium.equals("") && sumPayTax != null && !sumPayTax.equals("")) { BigDecimal jqpremium = new BigDecimal(Double.parseDouble(premium) + Double.parseDouble(sumPremium) + Double.parseDouble(sumPayTax)); jqpremium = jqpremium.setScale(2, BigDecimal.ROUND_HALF_UP); quoteRespVo.setSumPermium(jqpremium.doubleValue()); //交强+商业+车船总和 } else if (premium != null && !premium.equals("") && sumPremium != null && !sumPremium.equals("")) { BigDecimal jqpremium = new BigDecimal(Double.parseDouble(premium) + Double.parseDouble(sumPremium)); jqpremium = jqpremium.setScale(2, BigDecimal.ROUND_HALF_UP); quoteRespVo.setSumPermium(jqpremium.doubleValue());//交强+商业+车船总和 } else if (premium != null && !premium.equals("") && sumPayTax != null && !sumPayTax.equals("")) { BigDecimal jqpremium = new BigDecimal(Double.parseDouble(premium) + Double.parseDouble(sumPayTax)); jqpremium = jqpremium.setScale(2, BigDecimal.ROUND_HALF_UP); quoteRespVo.setSumPermium(jqpremium.doubleValue());//交强+商业+车船总和 } else if (sumPremium != null && !sumPremium.equals("")) { BigDecimal jqpremium = new BigDecimal(Double.parseDouble(sumPremium)); jqpremium = jqpremium.setScale(2, BigDecimal.ROUND_HALF_UP); quoteRespVo.setSumPermium(jqpremium.doubleValue()); } quoteRespVo.setTotalAdjustRate(1); if (payTax != null) { quoteRespVo.setTaxAmount(Double.parseDouble(payTax)); } quoteRespVo.setILogPreUdwMess("0");//评分 quoteRespVo.setOrderno(orderno); //订单号 quoteRespVo.setRiskList(riskList1); quoteRespVo.setKindList(kindList1); httpResult.setData(quoteRespVo); httpResult.setMsg("成功"); //报价成功更新险种信息 insOrder.setRiskinfo(JSONObject.parseArray(JSONObject.toJSONString(riskList1))); insOrder.setKindinfo(JSONObject.parseArray(JSONObject.toJSONString(kindList1))); if (Vehicle != null) { BigDecimal Vehiclemium = new BigDecimal(Vehicle); Vehiclemium = Vehiclemium.setScale(2, BigDecimal.ROUND_HALF_UP); insOrder.setJqpremium(Vehiclemium.doubleValue()); } if (premium != null) { syPremium = syPremium - Double.parseDouble(premium); BigDecimal bd = new BigDecimal(syPremium); bd = bd.setScale(2, BigDecimal.ROUND_HALF_UP); syPremium = bd.doubleValue(); insOrder.setSypremium(syPremium); } if (sumPayTax != null) { insOrder.setTaxamount(Double.parseDouble(sumPayTax)); } BigDecimal bd = new BigDecimal(quoteRespVo.getSumPermium()); bd = bd.setScale(2, BigDecimal.ROUND_HALF_UP); insOrder.setSumpremium(bd.doubleValue()); //报价状态 0失败 1成功 httpResult.setCode(200); httpResult.setMsg(returnMessage); insOrder.setSypremium(insOrder.getSypremium() + insOrder.getJqpremium()); BigDecimal bds = new BigDecimal(insOrder.getSypremium()); BigDecimal bd1 = bds.setScale(2, BigDecimal.ROUND_HALF_UP); insOrder.setSypremium(bd1.doubleValue()); insOrder.setQuotestatus("1"); insOrder.setReqtxt(JSONObject.parseObject(json1)); insOrder.setReptxt(JSONObject.parseObject(posts)); insOrder.setUserid(user.getId()); logger.info("用户id====" + insOrder.getUserid()); insOrderService.insert(insOrder); //插入轨迹表 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()); history.setCreatetime(sdfm.format(new Date())); history.setOperator(insOrder.getUsername()); history.setStatus("0"); history.setRemark("报价中"); insTaskHistoryService.insert(history); } else { httpResult.setCode(200); httpResult.setMsg(returnMessage); insOrder.setQuotestatus("0"); //报价状态 0失败 1成功 } return httpResult; } /** * 提交核保 * * @param request * @return */ // @GetMapping(value = "/Submit") public HttpResult Submit(@RequestParam String orderno, @RequestParam String jqappoint, @RequestParam String syappoint, HttpServletRequest request) { SubmitHeadVO record = new SubmitHeadVO(); DeliveryInfoVO deliveryInfo = new DeliveryInfoVO(); //查询订单 InsOrder order = insOrderService.selectZMByPk(orderno); if (order != null) { //获取请求方法名称 String file = request.getRequestURI(); String method = file.substring(file.lastIndexOf("/") + 1); //获取请求地址 String zmUrl = environment.getProperty("ZMUrl"); String url = zmUrl + method + ".do"; record.setOrderNo("140000"); JSONObject reptxt = order.getReptxt(); Map reptxtmap = reptxt; JSONObject reqtxt = order.getReqtxt(); Map reqtxtmap = reqtxt; // Object ownerInfo = order.getOwnerinfo(); JSONObject ownerInfoObject = order.getOwnerinfo(); Object orderNo = reptxtmap.get("orderNo"); Object vin = reptxtmap.get("vin"); record.setOrderNo(orderNo.toString()); record.setVIN(vin.toString()); deliveryInfo.setName(ownerInfoObject.get("name").toString()); deliveryInfo.setMobile(ownerInfoObject.get("mobile").toString()); deliveryInfo.setProvince("140000"); deliveryInfo.setCity("140400"); deliveryInfo.setDistrict("140431"); deliveryInfo.setDetail(ownerInfoObject.get("addr").toString()); record.setPageUrl("http://www.baidu.com"); record.setCallbackUrl(environment.getProperty("CallbackUrl")); record.setPassMsgUrl(environment.getProperty("RGCallbackUrl")); record.setBusSrePcMAC("12-E1-AD-45-A2-65"); record.setBusSrePcIP("47.92.254.66"); //参数组装 HeadVO head = head(method); head.setToken(environment.getProperty("ZMToken")); record.setHead(head); record.setDeliveryInfo(deliveryInfo); String json = JSON.toJSONString(record); logger.info("核保接口请求参数为:" + json); String post = HttpsPostUtil.sendPost(url, json); logger.info("核保接口返回参数为:" + post); HeadMessage headMessage = HttpsPostUtil.HeadMessage(post); String returnMessage = headMessage.getReturnMessage(); String returnCode = headMessage.getReturnCode(); if (returnCode != null) { order.setOrderstatus("1"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); order.setSubmittime(sdf.format(new Date())); order.setJqappoint(jqappoint); //交强特别约定 order.setSyappoint(syappoint); //商业特别约定 order.setJqapplyno(JSONObject.parseObject(post).getString("proposalNo")); //主投保单号 //匹配任务接收人 String licenseno = order.getLicenseNo().substring(0, 2); List list = insOrderTaskService.selectList(" where t.status='1' and t.insname=? and t.licenseno=? and t.orderstatus=?", new Object[]{order.getInscompany(), licenseno, "1"}); if (list.size() > 0) { order.setAuditid(list.get(0).getAuditid()); order.setAuditname(list.get(0).getAuditname()); } insOrderService.update(order); //插入轨迹表 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("1"); history.setRemark("提交核保"); insTaskHistoryService.insert(history); return HttpResult.ok(returnMessage); } else { return HttpResult.error(returnMessage); } } return HttpResult.ok("提交成功"); } /** * 缴费查询接口 * * @param record * @param request * @return */ @PostMapping(value = "/OrderStatus") public HttpResult OrderStatus(@RequestBody OrderStatusHeadVO record, HttpServletRequest request) { String file = request.getRequestURI(); String method = file.substring(file.lastIndexOf("/") + 1); String zmUrl = environment.getProperty("ZMUrl"); String url = zmUrl + method + ".do"; InsOrder order = insOrderService.selectZMByPk(record.getOrderNo()); JSONObject reptxt = order.getReptxt(); Map reptxtmap = reptxt; Object orderNo = reptxtmap.get("orderNo"); record.setOrderNo(orderNo.toString()); HeadVO head = head(method); head.setToken(environment.getProperty("ZMToken")); record.setHead(head); String json = JSON.toJSONString(record); String post = HttpsPostUtil.sendPost(url, json); return HttpResult.ok(post); } /** * 核保状态查询 * * @param record * @param request * @return */ @PostMapping(value = "/SubmitStatusQuery") public HttpResult SubmitStatusQuery(@RequestBody SubmitStatusQueryHeadVO record, HttpServletRequest request) { String file = request.getRequestURI(); String method = file.substring(file.lastIndexOf("/") + 1); String zmUrl = environment.getProperty("ZMUrl"); String url = zmUrl + "SubmitStatus" + ".do"; // InsOrder order = insOrderService.selectZMByPk(record.getOrderNo()); // JSONObject reptxt = order.getReptxt(); // Map reptxtmap = reptxt; // Object orderNo = reptxtmap.get("orderNo"); // record.setOrderNo(orderNo.toString()); PayinfoVO payinfo = insOrderService.selectPayinfo(" where orderno=?", new Object[]{record.getOrderNo()}); record.setProposalNo(payinfo.getPolicyNo()); //主投保单号 HeadVO head = head(method); head.setToken(environment.getProperty("ZMToken")); record.setHead(head); String json = JSON.toJSONString(record); logger.info("核保状态查询请求参数为:" + json); String post = HttpsPostUtil.sendPost(url, json); logger.info("核保状态查询返回结果为:" + post); JSONObject obj = JSONObject.parseObject(post); payinfo.setReptxt(obj); insOrderService.updatePayinfo(payinfo); return HttpResult.ok(obj.getString("underWriteInd"), obj.getString("payUrl")); } /** * 电子保单下载 * * @param dirId * @param request * @return */ @GetMapping(value = "/InsurancePolicyPrint") public HttpResult InsurancePolicyPrint(@RequestParam("dirId") String dirId, HttpServletRequest request) { InsurancePolicyPrintHeadVO record = new InsurancePolicyPrintHeadVO(); String file = request.getRequestURI(); String method = file.substring(file.lastIndexOf("/") + 1); String zmUrl = environment.getProperty("ZMUrl"); String url = zmUrl + method + ".do"; InsOrder order = insOrderService.selectZMByPk(dirId); JSONObject reptxt = order.getReptxt(); JSONObject reqtxt = order.getReqtxt(); Map reptxtmap = reptxt; Object forcePrimium = reptxtmap.get("forcePrimium"); String kindName = null; JSONObject jsonObject = JSONObject.parseObject(forcePrimium.toString()); if (jsonObject != null) { kindName = jsonObject.get("kindName").toString(); } record.setPolicyNo(reptxtmap.get("orderNo").toString()); HeadVO head = head(method); head.setToken(environment.getProperty("ZMToken")); record.setHead(head); String json = JSON.toJSONString(record); String post = HttpsPostUtil.sendPost(url, json); return HttpResult.ok(post); } /** * 影像上传 * * @param record * @param request * @return */ @PostMapping(value = "/UploadImage") public HttpResult UploadImage(@RequestBody InsTaskImage record, HttpServletRequest request) { Integer result = 0; String msg = "保存成功"; NodeBeanlistVO nodeBean = new NodeBeanlistVO(); List nodeBeanList = new ArrayList(); UploadImageHeadVO uploadHead = new UploadImageHeadVO(); ImageBeanListVO imgVO = new ImageBeanListVO(); List imageBeanList = new ArrayList<>(); List list = new ArrayList(); if (record.getTaskid() == null || record.getTaskid().equalsIgnoreCase("")) { return HttpResult.ok("任务号taskid不能为空", result); } if (record.getImgtype() == null || record.getImgtype().equalsIgnoreCase("")) { return HttpResult.ok("图片类型imgtype不能为空", result); } if (record.getImgList() == null || record.getImgList().size() == 0) { return HttpResult.ok("图片列表imgList不能为空", result); } InsTaskImageService.delete(record.getTaskid(), record.getImgtype()); for (String image : record.getImgList()) { List imgList = new ArrayList(); record.setId(IdGenerate.nextId()); nodeBean.setId(record.getId()); record.setCreator(getUserName()); imgVO.setFileName(record.getCreator()); record.setCreatetime(new Date()); record.setImage(image); imgVO.setImage(record.getImage()); if (record.getImgtype() != null && record.getImgtype().equals("C01")) { nodeBean.setId("UW_0305"); } else if (record.getImgtype() != null && record.getImgtype().equals("C03")) { nodeBean.setId("UW_0302"); } else if (record.getImgtype() != null && record.getImgtype().equals("C05")) { nodeBean.setId("UW_0301"); } imgList.add(imgVO); nodeBean.setImageBeanList(imgList); //imageBeanList.add(imgVO); nodeBeanList.add(nodeBean); // list.add(imageBeanList); InsTaskImageService.insert(record); } String file = request.getRequestURI(); String method = file.substring(file.lastIndexOf("/") + 1); String zmUrl = environment.getProperty("ZMIMGUrl"); String url = zmUrl + method + ".do"; PayinfoVO payinfo = insOrderService.selectPayinfo(" where orderno=?", new Object[]{record.getTaskid()}); if (payinfo == null) { return HttpResult.error("请先提交核保!"); } HeadVO heads = head(method); heads.setToken(environment.getProperty("ZMToken")); uploadHead.setHead(heads); uploadHead.setNodeBeanlist(nodeBeanList); uploadHead.setContractNo(payinfo.getPolicyNo()); String jsons = JSON.toJSONString(uploadHead); String posts = HttpsPostUtil.sendPost(url, jsons); return HttpResult.ok(posts); } /** * 校验发短信接口 * * @param record * @param request * @return */ @PostMapping(value = "/CheckSMScode") public HttpResult CheckSMScode(@RequestBody CheckSMScodeHeadVO record, HttpServletRequest request) { String file = request.getRequestURI(); String method = file.substring(file.lastIndexOf("/") + 1); String zmUrl = environment.getProperty("ZMSMSUrl"); String url = zmUrl + method + ".do"; //参数组装 HeadVO head = head(method); head.setToken(environment.getProperty("ZMToken")); record.setHead(head); String json = JSON.toJSONString(record); String post = HttpsPostUtil.sendPost(url, json); return HttpResult.ok(post); } /** * 验证校验码正确 * * @param record * @param request * @return */ @PostMapping(value = "/ValidSMScode") public HttpResult ValidSMScode(@RequestBody ValidSMScodeHeadVO record, HttpServletRequest request) { String file = request.getRequestURI(); String method = file.substring(file.lastIndexOf("/") + 1); String zmUrl = environment.getProperty("ZMSMSUrl"); String url = zmUrl + method + ".do"; //参数组装 HeadVO head = head(method); head.setToken(environment.getProperty("ZMToken")); record.setHead(head); String json = JSON.toJSONString(record); String post = HttpsPostUtil.sendPost(url, json); return HttpResult.ok(post); } /** * 分销费用统计 * * @param deptid * @param userid * @return */ public double countRetail(String deptid, String userid) { double retailRate = 0; //1、根据机构匹配分销规则,获取分销比例 List list = esmRetailService.selectList(" where deptid = ? and status=?", new Object[]{deptid, "1"}); //2、根据userid查询三级推荐人 List 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 rateList = new ArrayList(); 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; } public 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; } /** * 承保回调 * * @param record * @param request * @return */ @PostMapping(value = "/Underwriting") public HeadMessage Underwriting(@RequestBody UnderwritingVO record, HttpServletRequest request) { logger.info("回调Underwriting接口" + record.toString()); String studentJson = JSON.toJSONString(record);//将对象转json logger.info("回调Underwriting接口" + studentJson); JSONObject jsonObject = JSONObject.parseObject(studentJson); Map map = jsonObject; StringBuffer whereStr = new StringBuffer(" where 1=1"); ArrayList array = new ArrayList(); if (map.get("bizProposalNo") != null && !map.get("bizProposalNo").equals("")) { String bizPolicyNo = map.get("bizPolicyNo").toString(); String bizProposalNo = map.get("bizProposalNo").toString();//商业险投保单号 whereStr.append(" and syapplyno=?"); array.add(bizProposalNo); } else { String forceProposalNo = map.get("forceProposalNo").toString();//交强险投保单号 String forcePolicyNo = map.get("forcePolicyNo").toString(); whereStr.append(" and jqapplyno=?"); array.add(forceProposalNo); } String proposalNo = map.get("proposalNo").toString(); HeadVO heads = record.getHead(); String status = map.get("status").toString(); HeadMessage headmess = new HeadMessage(); if (status != null && !status.equals("")) { InsOrder order = insOrderService.selectSyapplyno(whereStr.toString(), array.toArray()); logger.info("通过保单号查询" + proposalNo); if (order != null && !order.equals("")) { if (record.getBizPolicyNo() != null) { order.setSypolicyno(record.getBizPolicyNo()); } if (record.getForcePolicyNo() != null) { order.setJqpolicyno(record.getForcePolicyNo()); } if (record.getBizProposalNo() != null) { order.setSyapplyno(record.getBizProposalNo()); } if (record.getForceProposalNo() != null) { order.setJqapplyno(record.getForceProposalNo()); } String orders = JSON.toJSONString(order);//将对象转json logger.info("修改参数" + orders); order.setOrderstatus("6"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); order.setPaytime(sdf.format(new Date())); // saveFeeDetail(order); insOrderService.update(order); //插入轨迹表 InsTaskHistory history = new InsTaskHistory(); history.setId(String.valueOf(new Date().getTime())); history.setCompany(order.getInscompany()); history.setTaskid(order.getOrderno()); history.setOperatorid(order.getAuditid()); history.setOperator(order.getAuditname()); history.setCreatetime(sdf.format(new Date())); history.setStatus("6"); history.setRemark("已缴费待配送"); insTaskHistoryService.insert(history); } } else { headmess.setReturnMessage("-1"); HttpResult.error("失败"); } headmess.setReturnMessage("0"); return headmess; } /** * 人工核保承保回调 * * @param record * @param request * @return */ @PostMapping(value = "/ArtificialUnderwriting") public HeadMessage ArtificialUnderwriting(@RequestBody ArtificialVO record, HttpServletRequest request) { HeadMessage headmess = new HeadMessage(); String rep = JSON.toJSONString(record);//将对象转json logger.info("人工核保回调接入参" + rep); JSONObject reptext = JSONObject.parseObject(rep); StringBuffer whereStr = new StringBuffer(" where 1=1"); ArrayList array = new ArrayList(); //插入轨迹表 InsTaskHistory history = new InsTaskHistory(); if (record.getContractNo() != null && !record.getContractNo().equals("")) { String contractNo = record.getContractNo(); whereStr.append(" and policyNo=? "); array.add(contractNo); } PayinfoVO payinfo = insOrderService.selectPayinfo(whereStr.toString(), array.toArray()); logger.info("人工核保回调接查询到的信息" + JSON.toJSONString(payinfo)); if (payinfo != null && !payinfo.equals("")) { InsOrder order = insOrderService.selectByPk(payinfo.getOrderno()); JSONObject reptxt = payinfo.getReptxt(); Map reptxtmap = reptxt; reptxtmap.put("payUrl", record.getPayUrl()); payinfo.setReptxt(JSONObject.parseObject(reptxtmap.toString())); } else { headmess.setReturnMessage("FAILD"); return headmess; } String statusCode = record.getStatusCode(); if (statusCode != null && !statusCode.equals("")) { InsOrder order = insOrderService.selectSyapplyno(" where orderno=? ", new Object[]{payinfo.getOrderno()}); logger.info("人工核保订单号查询" + order.getOrderno()); if (record.getStatusCode() != null && record.getStatusCode().equals("1")) { insOrderService.updatePayinfo(payinfo); if (record.getProposalNoS() != null) { order.setSypolicyno(record.getProposalNoS()); } if (record.getProposalNoJ() != null) { order.setJqpolicyno(record.getProposalNoJ()); } order.setOrderstatus("5"); history.setStatus("5"); history.setRemark("已核保待缴费"); } else if (record.getStatusCode() != null && record.getStatusCode().equals("2")) { order.setOrderstatus("1"); history.setStatus("1"); history.setRemark("待核保"); } else if (record.getStatusCode() != null && record.getStatusCode().equals("4")) { order.setOrderstatus("99"); history.setStatus("99"); history.setRemark("拒保"); } String orders = JSON.toJSONString(order);//将对象转json logger.info("修改参数" + orders); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); order.setPaytime(sdf.format(new Date())); insOrderService.update(order); history.setId(String.valueOf(new Date().getTime())); history.setCompany(order.getInscompany()); history.setTaskid(order.getOrderno()); history.setOperatorid(order.getAuditid()); history.setOperator(order.getAuditname()); history.setCreatetime(sdf.format(new Date())); insTaskHistoryService.insert(history); } else { headmess.setReturnMessage("-1"); HttpResult.error("失败"); } headmess.setReturnMessage("OK"); return headmess; } public HeadVO head(String methodName) { HeadVO headVO = new HeadVO(); headVO.setTransCode(methodName); headVO.setTransType("Req"); //测试 // headVO.setToken("THIRDSCOuloft2020052818346904zmYBSX"); //生产 headVO.setToken(environment.getProperty("ZMToken")); headVO.setSource("326"); return headVO; } }