|
|
@@ -1518,50 +1518,189 @@ public class RenBaoNewCrawlerRequestImpl implements RenBaoNewCrawlerRequest {
|
|
|
headers
|
|
|
);
|
|
|
|
|
|
- OrderStatusResultVo resultVo = new OrderStatusResultVo();
|
|
|
-
|
|
|
- // 解析订单状态
|
|
|
- String status = parseOrderStatus(checkResult);
|
|
|
- resultVo.setOrderStatusStr(status);
|
|
|
-
|
|
|
- // 解析投保单号和保单号
|
|
|
- parsePolicyNumbers(checkResult, resultVo);
|
|
|
-
|
|
|
- return resultVo;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 解析订单状态
|
|
|
- */
|
|
|
- private String parseOrderStatus(Map<String, Object> checkResult) {
|
|
|
- if (checkResult == null || !checkResult.containsKey("data")) {
|
|
|
- return "UNKNOWN";
|
|
|
+ // 校验查询结果
|
|
|
+ if (checkResult == null || !"Success".equals(checkResult.get("message"))) {
|
|
|
+ String errorMsg = checkResult != null ? (String) checkResult.get("statusText") : "查询订单响应为空";
|
|
|
+ throw new SystemException("查询订单异常: " + errorMsg);
|
|
|
}
|
|
|
|
|
|
Map<String, Object> data = (Map<String, Object>) checkResult.get("data");
|
|
|
if (data == null || !data.containsKey("result")) {
|
|
|
- return "UNKNOWN";
|
|
|
+ throw new SystemException("查询订单异常: 未查询到订单");
|
|
|
}
|
|
|
|
|
|
List<Map<String, Object>> itemList = (List<Map<String, Object>>) data.get("result");
|
|
|
if (itemList == null || itemList.isEmpty()) {
|
|
|
- return "NOT_FOUND";
|
|
|
+ throw new SystemException("未查询到订单");
|
|
|
+ }
|
|
|
+ if (itemList.size() > 2) {
|
|
|
+ throw new SystemException("查询订单异常");
|
|
|
}
|
|
|
|
|
|
- // 获取第一个订单的状态
|
|
|
- Map<String, Object> firstItem = itemList.get(0);
|
|
|
- String underWriteFlag = (String) firstItem.get("underWriteFlag");
|
|
|
-
|
|
|
- // 状态映射:0-初始值, 1-通过, 2-不通过, 3-自动核保通过, 4-见费出单待缴费, 5-见费出单待缴费,
|
|
|
- // 6-待同步, 7-自动待同步, 9-待核保, A-送见费失败, B-送见费失败, C-待取消, D-自动核保待转保单,
|
|
|
- // E-人工核保待转保单, F-预核保转人工
|
|
|
- return switch (underWriteFlag) {
|
|
|
- case "1", "3" -> "APPROVED";
|
|
|
- case "2" -> "REJECTED";
|
|
|
- case "4", "5" -> "PAYMENT_PENDING";
|
|
|
- case "9" -> "UNDERWRITING";
|
|
|
- default -> "PROCESSING";
|
|
|
- };
|
|
|
+ // 2. 提取交强/商业单号及驾意险单号(对应Python逻辑)
|
|
|
+ Map<String, Object> orderInfo = itemList.get(0);
|
|
|
+ String jqApplication = "";
|
|
|
+ String syApplication = "";
|
|
|
+ List<String> documentnolist = new ArrayList<>();
|
|
|
+ List<String> jyxBusinessNoList = new ArrayList<>();
|
|
|
+
|
|
|
+ for (Map<String, Object> item : itemList) {
|
|
|
+ String bNo = (String) item.get("businessNo");
|
|
|
+ if (bNo != null) {
|
|
|
+ if (bNo.contains("DZA")) {
|
|
|
+ jqApplication = bNo;
|
|
|
+ documentnolist.add(bNo);
|
|
|
+ } else if (bNo.contains("DAA")) {
|
|
|
+ syApplication = bNo;
|
|
|
+ documentnolist.add(bNo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 提取驾意险关联单号
|
|
|
+ if (orderInfo.containsKey("relationUPolicyInfolist")) {
|
|
|
+ List<Map<String, Object>> relationList = (List<Map<String, Object>>) orderInfo.get("relationUPolicyInfolist");
|
|
|
+ if (relationList != null) {
|
|
|
+ for (Map<String, Object> relItem : relationList) {
|
|
|
+ String connectProposalNo = (String) relItem.get("connectProposalNo");
|
|
|
+ if (connectProposalNo != null && !connectProposalNo.isEmpty()) {
|
|
|
+ documentnolist.add(connectProposalNo);
|
|
|
+ jyxBusinessNoList.add(connectProposalNo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3. 获取核保状态
|
|
|
+ String underWriteFlag = (String) orderInfo.get("underWriteFlag");
|
|
|
+ log.info("订单状态 underWriteFlag={}, jq={}, sy={}, jyx={}", underWriteFlag, jqApplication, syApplication, jyxBusinessNoList);
|
|
|
+
|
|
|
+ // 4. 根据状态处理
|
|
|
+ OrderStatusResultVo resultVo = new OrderStatusResultVo();
|
|
|
+ resultVo.setJqApplyNo(jqApplication);
|
|
|
+ resultVo.setSyApplyNo(syApplication);
|
|
|
+ resultVo.setJyApplyNo(jyxBusinessNoList.isEmpty() ? "" : String.join(",", jyxBusinessNoList));
|
|
|
+
|
|
|
+ // 状态为4或5:核保通过待缴费 → 获取支付链接
|
|
|
+ if ("4".equals(underWriteFlag) || "5".equals(underWriteFlag)) {
|
|
|
+ log.info("订单核保通过,获取支付链接");
|
|
|
+ // 构建支付请求
|
|
|
+ RenBaoNewCrawlerPayRequest payRequest = new RenBaoNewCrawlerPayRequest();
|
|
|
+ payRequest.setDocumentnolist(documentnolist);
|
|
|
+ payRequest.setUserCode(loginInfo.getUserCode());
|
|
|
+ payRequest.setComCode(loginInfo.getComCode());
|
|
|
+ payRequest.setPayType("");
|
|
|
+ payRequest.setPayFee("");
|
|
|
+ payRequest.setCurrency("");
|
|
|
+ payRequest.setLinkurlflag("1");
|
|
|
+ payRequest.setBrowseWay("");
|
|
|
+
|
|
|
+ // 带重试获取支付链接(对应Python的while循环)
|
|
|
+ int retryCount = 0;
|
|
|
+ while (true) {
|
|
|
+ RenBaoNewCrawlerPayResponse payResponse = requestComponent.getPayUrl(payRequest, headers);
|
|
|
+ if (payResponse != null && "Success".equals(payResponse.getMessage())) {
|
|
|
+ String qrcodeimg = payResponse.getData() != null ? payResponse.getData().getQrcodeimg() : null;
|
|
|
+ if (qrcodeimg == null || qrcodeimg.isEmpty()) {
|
|
|
+ retryCount++;
|
|
|
+ if (retryCount > 3) {
|
|
|
+ String errMsg = payResponse.getData() != null ? payResponse.getData().getErrorMessage() : "支付二维码为空";
|
|
|
+ throw new SystemException("提取支付异常," + errMsg);
|
|
|
+ }
|
|
|
+ log.info("支付二维码为空,重试 {}/3", retryCount);
|
|
|
+ try {
|
|
|
+ Thread.sleep(1000);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ Thread.currentThread().interrupt();
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 成功获取支付链接
|
|
|
+ resultVo.setPaymentLink(qrcodeimg);
|
|
|
+ resultVo.setOrderStatus(InsOrderStatusEnum.PAY_PENDING);
|
|
|
+ resultVo.setOrderStatusStr("待支付");
|
|
|
+ log.info("获取支付链接成功");
|
|
|
+ } else {
|
|
|
+ String errorMsg = payResponse != null ? payResponse.getStatusText() : "支付响应为空";
|
|
|
+ throw new SystemException("提取支付异常," + errorMsg);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 状态为9:待核保
|
|
|
+ else if ("9".equals(underWriteFlag)) {
|
|
|
+ Map<String, Object> processInfo = requestComponent.getUndwrtProcessInfo(businessNo, headers);
|
|
|
+ if (processInfo != null && processInfo.containsKey("data")) {
|
|
|
+ Map<String, Object> processData = (Map<String, Object>) processInfo.get("data");
|
|
|
+ if (processData != null && processData.containsKey("underwritingInfos")) {
|
|
|
+ List<Map<String, Object>> infos = (List<Map<String, Object>>) processData.get("underwritingInfos");
|
|
|
+ if (infos != null && !infos.isEmpty()) {
|
|
|
+ String msg = (String) infos.get(0).get("msg");
|
|
|
+ resultVo.setErrorMsg(msg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resultVo.setOrderStatus(InsOrderStatusEnum.STAFF_PROCESS);
|
|
|
+ resultVo.setOrderStatusStr("待核保");
|
|
|
+ }
|
|
|
+ // 状态为2:不通过
|
|
|
+ else if ("2".equals(underWriteFlag)) {
|
|
|
+ StringBuilder errorMsg = new StringBuilder();
|
|
|
+ if (!jqApplication.isEmpty()) {
|
|
|
+ Map<String, Object> viewResult = requestComponent.viewUndwrt(jqApplication, loginInfo.getUserCode(), headers);
|
|
|
+ if (viewResult != null && viewResult.containsKey("data")) {
|
|
|
+ List<Map<String, Object>> dataList = (List<Map<String, Object>>) viewResult.get("data");
|
|
|
+ if (dataList != null && !dataList.isEmpty()) {
|
|
|
+ String handleText = (String) dataList.get(0).get("handleText");
|
|
|
+ errorMsg.append("交强返回:").append(handleText).append("; ");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!syApplication.isEmpty()) {
|
|
|
+ Map<String, Object> viewResult = requestComponent.viewUndwrt(syApplication, loginInfo.getUserCode(), headers);
|
|
|
+ if (viewResult != null && viewResult.containsKey("data")) {
|
|
|
+ List<Map<String, Object>> dataList = (List<Map<String, Object>>) viewResult.get("data");
|
|
|
+ if (dataList != null && !dataList.isEmpty()) {
|
|
|
+ String handleText = (String) dataList.get(0).get("handleText");
|
|
|
+ errorMsg.append("商业返回:").append(handleText);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resultVo.setErrorMsg(errorMsg.toString());
|
|
|
+ resultVo.setOrderStatus(InsOrderStatusEnum.AUDIT_FAIL);
|
|
|
+ resultVo.setOrderStatusStr("核保不通过");
|
|
|
+ }
|
|
|
+ // 状态为1或3:已通过
|
|
|
+ else if ("1".equals(underWriteFlag) || "3".equals(underWriteFlag)) {
|
|
|
+ resultVo.setOrderStatus(InsOrderStatusEnum.UNDERWRITED);
|
|
|
+ resultVo.setOrderStatusStr("已支付");
|
|
|
+ }
|
|
|
+ // 其他状态
|
|
|
+ else {
|
|
|
+ // 解析状态文本
|
|
|
+ String[][] statusMap = {
|
|
|
+ {"0", "初始值"}, {"1", "通过"}, {"2", "不通过"}, {"3", "自动核保通过"},
|
|
|
+ {"4", "见费出单待缴费"}, {"5", "见费出单待缴费"}, {"6", "待同步"},
|
|
|
+ {"7", "自动待同步"}, {"9", "待核保"}, {"A", "送见费失败"},
|
|
|
+ {"B", "送见费失败"}, {"C", "待取消"}, {"D", "自动核保待转保单"},
|
|
|
+ {"E", "人工核保待转保单"}, {"F", "预核保转人工"}
|
|
|
+ };
|
|
|
+ String statusTxt = underWriteFlag;
|
|
|
+ for (String[] entry : statusMap) {
|
|
|
+ if (entry[0].equals(underWriteFlag)) {
|
|
|
+ statusTxt = entry[1];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.info("订单状态: {}", statusTxt);
|
|
|
+ resultVo.setOrderStatus(InsOrderStatusEnum.AUDIT_ING);
|
|
|
+ resultVo.setOrderStatusStr(statusTxt);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 解析保单号(如果已有)
|
|
|
+ parsePolicyNumbers(checkResult, resultVo);
|
|
|
+
|
|
|
+ return resultVo;
|
|
|
}
|
|
|
|
|
|
/**
|