From 0c6faf64f2a02ae94b0d719729754f7ca29da416 Mon Sep 17 00:00:00 2001
From: ab <myjf007@126.com>
Date: Tue, 05 Nov 2024 09:57:20 +0800
Subject: [PATCH] [fixed]我来贷未推送数据存入到定时器中

---
 src/main/java/com/nova/sankuai/infra/utils/wolaidai/WolaidaiUtil.java |  365 +++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 293 insertions(+), 72 deletions(-)

diff --git a/src/main/java/com/nova/sankuai/infra/utils/wolaidai/WolaidaiUtil.java b/src/main/java/com/nova/sankuai/infra/utils/wolaidai/WolaidaiUtil.java
index 17e782a..4b4600c 100644
--- a/src/main/java/com/nova/sankuai/infra/utils/wolaidai/WolaidaiUtil.java
+++ b/src/main/java/com/nova/sankuai/infra/utils/wolaidai/WolaidaiUtil.java
@@ -12,10 +12,7 @@
 import com.nova.sankuai.domain.api.rongbei.ApplyData; // 申请数据类
 import com.nova.sankuai.domain.api.rongbei.RbResponse; // 响应结果类
 import com.nova.sankuai.domain.api.yinsheng.SerialGenerator;
-import com.nova.sankuai.domain.dto.rongbei.ApplyDto; // 申请DTO
-import com.nova.sankuai.domain.dto.rongbei.ContactListDto; // 联系人列表DTO
-import com.nova.sankuai.domain.dto.rongbei.ProfileDictDto;
-import com.nova.sankuai.domain.dto.rongbei.RongBeBasicDto; // 融贝基础DTO
+import com.nova.sankuai.domain.dto.rongbei.*;
 import com.nova.sankuai.domain.entity.*;
 import com.nova.sankuai.infra.utils.ConstantsUtil;
 import com.nova.sankuai.infra.utils.eshidai.EsdUtil;
@@ -177,13 +174,14 @@
     private final ICustomerCheckRecordService customerCheckRecordService; // 用户准入务
     private final ICustomerH5ClickService customerH5ClickService; // H5用户点击埋点服务
     private final ICapitalInfoService capitalInfoService; // 资金信息服务
+    private final ICustomerWldPushRecordService customerWldPushRecordService; // 我来贷推送记录服务
     private final EsdUtil esdUtil;
     private final HjqbUtil hjqbUtil;
     private final SyhUtil syhUtil;
     private final HhtUtil hhtUtil;
     private final QingHuaYouPinUtil qingHuaYouPinUtil;
 
-    public RbResponse saveH5ClickRecord(String mobile, Integer type){
+    public RbResponse saveH5ClickRecord(String mobile, Integer type) {
         CustomerH5Click customerH5Click = new CustomerH5Click();
         customerH5Click.setMobile(mobile);
         customerH5Click.setType(type);
@@ -197,9 +195,10 @@
 
     /**
      * 设置公共的查询条件
+     *
      * @return LambdaQueryWrapper<CapitalInfo>
      */
-    private LambdaQueryWrapper<CapitalInfo> getWrapper(){
+    private LambdaQueryWrapper<CapitalInfo> getWrapper() {
         LambdaQueryWrapper<CapitalInfo> wrapper = new LambdaQueryWrapper<>(); // 创建查询条件
         wrapper.eq(CapitalInfo::getFundType, FUND_TYPE_BANK_LOAN); // 资金类型:银行直贷
         wrapper.eq(CapitalInfo::getEnableFlag, ENABLE_FLAG); // 是否启用:启用
@@ -210,6 +209,7 @@
 
     /**
      * 获取要推送的半流程资方
+     *
      * @return 资金信息列表
      */
     private List<CapitalInfo> getCapitalInfoList() {
@@ -225,6 +225,7 @@
 
     /**
      * 获取要推送的非半流程资方
+     *
      * @return 资金信息列表
      */
     private List<CapitalInfo> getNotHalfCapitalInfoList() {
@@ -237,6 +238,7 @@
 
     /**
      * 获取要推送的非半流程资金类型线上资方
+     *
      * @return 资金信息列表
      */
     private List<CapitalInfo> getNotHalfFundTypeCapitalInfoList() {
@@ -252,8 +254,10 @@
         wrapper.orderByAsc(CapitalInfo::getSeq); // 按序号升序排列
         return capitalInfoService.list(wrapper); // 返回匹配的资金信息列表
     }
+
     /**
      * 根据资金名获取配置
+     *
      * @param capitalName 资金名
      * @return 配置映射
      */
@@ -330,6 +334,7 @@
 
     /**
      * 根据方法名返回相应的数据
+     *
      * @param action 方法名
      * @return 配置映射
      */
@@ -350,7 +355,8 @@
 
     /**
      * 接收我来贷请求的数据并中转给下游资方
-     * @param body 请求体
+     *
+     * @param body   请求体
      * @param action 方法名
      * @return RbResponse
      */
@@ -363,7 +369,7 @@
         String decryptStr = "";
         resp.setMsg("成功");
         try {
-            log.info("日志编号:{} , {}方法:{}, 接收到的数据:{}", logNumber, basicInfo.get("targetName"),  action, body); // 记录接收的数据
+            log.info("日志编号:{} , {}方法:{}, 接收到的数据:{}", logNumber, basicInfo.get("targetName"), action, body); // 记录接收的数据
             JSONObject getFullData = new JSONObject(); // 创建JSON对象存储数据
             getFullData.putOpt("partner_id", body.getPartner_id()); // 存储合作伙伴ID
             getFullData.putOpt("timestamp", body.getTimestamp()); // 存储时间戳
@@ -385,7 +391,7 @@
 
                     // 数据保存到数据库中
                     ApplyDto applyDto = JSON.parseObject(decryptStr, ApplyDto.class);
-                    ProfileDictDto profileDictDto =  applyDto.getProfile_dict();
+                    ProfileDictDto profileDictDto = applyDto.getProfile_dict();
                     profileDictDto.setRequest_amount(String.valueOf(randomValue));
                     applyDto.setProfile_dict(profileDictDto);
                     chnOrderId = applyDto.getChn_order_id();
@@ -413,11 +419,11 @@
                         String h5Url = "";
                         // 如果是慧钱,随易花,e时贷,好汇推,则转为乐享融的指定id:28
                         if (capitalId == 12L || capitalId == 41L || capitalId == 36L || capitalId == 25L || capitalId == 4L) {
-                            h5Url = h5HalfUrl + "&capitalId="+ capitalId + "&mobile=" + customerApplyOrder.getPhone();
+                            h5Url = h5HalfUrl + "&capitalId=" + capitalId + "&mobile=" + customerApplyOrder.getPhone();
                             //h5Url = rbH5Url + "&capitalId=28";
-                        }else{
+                        } else {
                             //h5Url = rbH5Url + "&capitalId="+ capitalId + "&mobile=" + customerApplyOrder.getPhone();
-                            h5Url = rbH5Url + "&capitalId="+ capitalId;
+                            h5Url = rbH5Url + "&capitalId=" + capitalId;
                         }
                         obj.putOpt("url", h5Url);
                         obj.putOpt("remind", "");
@@ -425,7 +431,7 @@
                         capitalName = customerApplyOrder.getCapitalName();
                         flag = true;
                     }
-                }else {
+                } else {
                     // 遍历半流程资金信息列表
                     List<CapitalInfo> capitalInfoList = getCapitalInfoList();
                     for (CapitalInfo capitalInfo : capitalInfoList) {
@@ -498,7 +504,7 @@
 
                                                     // 调用接受授信结果接口推送授信结果给我来贷
                                                     autoPushCreditResult(chnOrderId, applyData.getPartner_flow_id());
-                                                }else {
+                                                } else {
                                                     if (StringUtils.isEmpty(fBizDataStr)) {
                                                         fBizDataStr = decryptHjStr;
                                                         fCapitalName = capitalInfo.getName();
@@ -562,7 +568,7 @@
                             // 保存准入记录
                             CustomerCheckRecord customerCheckRecord = getCustomerCheckRecord(capitalInfo.getId(), capitalInfo.getName(), decryptStr, 1);
                             customerCheckRecordService.save(customerCheckRecord);
-                        }else if (Objects.equals(action, "apply")) {
+                        } else if (Objects.equals(action, "apply")) {
                             ApplyData applyData = new ApplyData();
                             applyData.setStatus(1);
                             applyData.setPartner_flow_id("");
@@ -685,6 +691,10 @@
                 log.error("日志编号:{},【我来贷】{}参数验签失败,jsonData:{} ex:{}", logNumber, basicInfo.get("targetName"), body, "验签失败");
             }
         } catch (Exception e) {
+            // 失败,未执行的数据,则保存到记录表,后面再用定时器执行
+            CustomerWldPushRecord customerWldPushRecord = new CustomerWldPushRecord();
+            BeanUtils.copyProperties(customerWldPushRecord, body);
+            savePushData(customerWldPushRecord);
             resp.setMsg(e.getMessage());
             log.error("日志编号:{},【我来贷】{},请求失败:{} 错误原因:{}", logNumber, basicInfo.get("targetName"), body, e.getMessage());
         }
@@ -699,18 +709,18 @@
                 // 保存准入记录
                 CustomerCheckRecord customerCheckRecord = getCustomerCheckRecord(0L, "", decryptStr, 0);
                 customerCheckRecordService.save(customerCheckRecord);
-            }else if (Objects.equals(action, "apply")) {
+            } else if (Objects.equals(action, "apply")) {
                 bizData.putOpt("status", 1);
                 bizData.putOpt("partner_flow_id", "");
                 bizData.putOpt("msg", "请求失败");
-            }else if (Objects.equals(action, "order_status")) {
+            } else if (Objects.equals(action, "order_status")) {
                 bizData.putOpt("status", 100);
                 bizData.putOpt("chn_order_id", "");
                 bizData.putOpt("update_time", System.currentTimeMillis() / 1000);
-            }else if (Objects.equals(action, "h5_url")) {
+            } else if (Objects.equals(action, "h5_url")) {
                 bizData.putOpt("url", "");
                 bizData.putOpt("remind", "");
-            }else{
+            } else {
                 bizData.putOpt("status", 1);
                 bizData.putOpt("msg", "请求失败");
             }
@@ -721,6 +731,194 @@
         resp.setData(String.valueOf(hjData));
 
         return resp;
+    }
+
+    public void wldCronPush(CustomerWldPushRecord customerWldPushRecord) {
+        String logNumber = IdUtil.randomUUID(); // 生成日志编号
+        log.info("日志编号:{} , 定时器自动进件, 要推送的数据:{}", logNumber, customerWldPushRecord);
+        JSONObject getFullData = new JSONObject(); // 创建JSON对象存储数据
+        getFullData.putOpt("partner_id", customerWldPushRecord.getPartnerId()); // 存储合作伙伴ID
+        getFullData.putOpt("timestamp", customerWldPushRecord.getTimestamp()); // 存储时间戳
+        getFullData.putOpt("biz_data", customerWldPushRecord.getBizData()); // 存储业务数据
+        Map<String, String> basicInfo = getBasicInfoByAction("apply");
+        String chnOrderId = "";
+        // 解密+验签
+        String decryptStr = decrypt(getFullData, customerWldPushRecord.getSign(), wldPublicKey);// 解密
+        if (StringUtils.isNotEmpty(decryptStr)) {
+            Customer customer = new Customer();
+            // 修改借款额度,采用随机生成
+            Random random = new Random();
+            int lowerBound = 5000; // 最小值
+            int upperBound = 50000; // 最大值
+
+            // 生成随机的100倍数
+            int randomValue = lowerBound + (random.nextInt((upperBound - lowerBound) / 100 + 1) * 100);
+            // 数据保存到数据库中
+            ApplyDto applyDto = JSON.parseObject(decryptStr, ApplyDto.class);
+            ProfileDictDto profileDictDto = applyDto.getProfile_dict();
+            profileDictDto.setRequest_amount(String.valueOf(randomValue));
+            applyDto.setProfile_dict(profileDictDto);
+            //取出订单编号
+            chnOrderId = applyDto.getChn_order_id();
+            log.info("日志编号:{},定时器自动进件, 保存进件数据:{}", logNumber, applyDto);
+            customer = saveData(applyDto);
+            JSON.toJSONString(applyDto);
+            decryptStr = JSON.toJSONString(applyDto);
+
+            // 遍历半流程资金信息列表
+            List<CapitalInfo> capitalInfoList = getCapitalInfoList();
+            log.info("日志编号:{},定时器自动进件, 半半流程的资方列表:【{}】", logNumber, capitalInfoList); // 半流程的资方列表
+            CustomerApplyOrder customerApplyOrder;
+            LambdaQueryWrapper<CustomerApplyOrder> wrapper = new LambdaQueryWrapper<>();
+            wrapper.eq(CustomerApplyOrder::getChnOrderId, chnOrderId);
+            wrapper.last("limit 1");
+            for (CapitalInfo capitalInfo : capitalInfoList) {
+                // 先判断有没有推过,如果有则不再推送
+                wrapper.eq(CustomerApplyOrder::getCapitalId, capitalInfo.getId());
+                customerApplyOrder = customerApplyOrderService.getOne(wrapper);
+                if (Objects.isNull(customerApplyOrder)) {
+                    Map<String, String> config = getConfigByCapitalName(capitalInfo.getName());// 获取对应的配置
+                    log.info("日志编号:{},定时器自动进件, 资方名:【{}】,config配置信息: {}", logNumber, capitalInfo.getName(), config); // 记录资金信息
+                    JSONObject fullData = new JSONObject();// 创建完整数据的JSON对象
+                    fullData.putOpt("partner_id", config.get("partnerId")); // 设置合作伙伴ID
+                    fullData.putOpt("timestamp", System.currentTimeMillis());// 设置当前时间戳
+                    fullData.putOpt("biz_data", encrypt(decryptStr)); // 设置业务数据
+                    //生成新的签名
+                    fullData.putOpt("sign", getSign(fullData, config.get("publicKey")));// 计算签名
+                    String result = null;// 初始化结果
+                    if (StringUtils.isNotEmpty(config.get("basicUrl"))) {// 如果基础URL有效
+                        try {
+                            result = HttpClientUtil.getInstance().postJsonData(config.get("basicUrl") + basicInfo.get("url"), String.valueOf(fullData)); // 调用接口
+                            log.info("日志编号:{},定时器自动进件,资方名:【{}】,参数:{},result: {}", logNumber, capitalInfo.getName(), fullData, result);// 记录接口结果
+                            if (result != null) { // 确保result不为空
+                                RbResponse resp = JSON.parseObject(result, RbResponse.class);// 解析响应
+                                String data = resp.getData();// 获取数据部分
+                                JSONObject hjData = new JSONObject();
+                                RongBeBasicDto rb = JSON.parseObject(data, RongBeBasicDto.class); // 解析业务DTO
+                                hjData.putOpt("biz_data", rb.getBiz_data());// 获取业务数据
+                                if (Objects.equals(resp.getCode(), SUCCESS_CODE)) { // // 判断是否成功
+                                    // 解密biz_data
+                                    hjData.putOpt("partner_id", rb.getPartner_id()); // 设置合作伙伴ID为融呗,我来贷只认融呗的信息
+                                    hjData.putOpt("timestamp", rb.getTimestamp()); // 设置时间戳
+                                    String decryptHjStr = decrypt(hjData, rb.getSign(), config.get("publicKey"));// 解密hjData
+                                    if (StringUtils.isNotEmpty(decryptHjStr)) {// 判断解密结果
+                                        ApplyData applyData = JSON.parseObject(decryptHjStr, ApplyData.class);
+                                        if (applyData.getStatus() == 0) { // 进件成功后才保存
+                                            // 进件成功后,调用接受订单状态接口推送数据给我来贷
+                                            OrderStatusByWld(chnOrderId, applyData.getPartner_flow_id());
+
+                                            // 调用接受授信结果接口推送授信结果给我来贷
+                                            autoPushCreditResult(chnOrderId, applyData.getPartner_flow_id());
+                                        }
+                                        // 保存进件记录
+                                        customerApplyOrder = getCustomerApplyOrder(chnOrderId, applyData, capitalInfo, config.get("partnerId"), decryptStr);
+                                        customerApplyOrderService.save(customerApplyOrder);
+                                        log.info("日志编号:{},【{}】,定时器自动进件解密结果:{}", logNumber, capitalInfo.getName(), decryptHjStr);
+                                    } else {
+                                        log.error("日志编号:{}, 【{}】,定时器自动进件解密结果失败:{}", logNumber, capitalInfo.getName(), decryptHjStr);
+                                    }
+                                } else {
+                                    log.error("日志编号:{}, 资方:【{}】定时器自动进件失败:{}", logNumber, capitalInfo.getName(), result);
+                                }
+                            }
+                        } catch (Exception ex) {
+                            // 处理请求异常
+                            log.error("日志编号:{},定时器自动进件, 资方名:【{}】,传参:{} ex:{}", logNumber, capitalInfo.getName(), fullData, ex.getMessage());//记录异常堆栈
+                        }
+                    }
+                }
+
+            }
+            // 遍历非半流程资金信息列表
+            List<CapitalInfo> lst = getNotHalfCapitalInfoList();
+            log.info("日志编号:{},定时器自动进件, 非半流程的资方列表:【{}】", logNumber, lst); // 非半流程的资方列表
+            for (CapitalInfo capitalInfo : lst) {
+                // 先判断有没有推过,如果有则不再推送
+                wrapper.eq(CustomerApplyOrder::getCapitalId, capitalInfo.getId());
+                customerApplyOrder = customerApplyOrderService.getOne(wrapper);
+                if (Objects.isNull(customerApplyOrder)) {
+                    boolean halfFlag = false;
+                    ApplyData applyData = new ApplyData();
+                    applyData.setStatus(1);
+                    applyData.setPartner_flow_id("");
+                    //调用对应资方的推送机制
+                    if (capitalInfo.getId() == 25L) { //e时贷
+                        halfFlag = esdUtil.wldPushToEsd(customer, logNumber);
+                        if (halfFlag) {
+                            applyData.setStatus(0);
+                            applyData.setPartner_flow_id(SerialGenerator.getOrder());
+                        }
+
+                    } else if (capitalInfo.getId() == 12L) { //慧借钱包
+                        halfFlag = hjqbUtil.wldPushToHjqb(customer, logNumber);
+                        if (halfFlag) {
+                            applyData.setStatus(0);
+                            applyData.setPartner_flow_id(SerialGenerator.getOrder());
+                        }
+                    } else if (capitalInfo.getId() == 41L) { //好汇推
+                        halfFlag = hhtUtil.wldPushToHht(customer, logNumber);
+                        if (halfFlag) {
+                            applyData.setStatus(0);
+                            applyData.setPartner_flow_id(SerialGenerator.getOrder());
+                        }
+
+                    } else if (capitalInfo.getId() == 36L) { //随易花
+                        halfFlag = syhUtil.wldPushToSyh(customer, logNumber);
+                        if (halfFlag) {
+                            applyData.setStatus(0);
+                            applyData.setPartner_flow_id(SerialGenerator.getOrder());
+                        }
+                    }
+
+                    if (halfFlag) {
+                        // 进件成功后,调用接受订单状态接口推送数据给我来贷
+                        OrderStatusByWld(chnOrderId, applyData.getPartner_flow_id());
+
+                        // 调用接受授信结果接口推送授信结果给我来贷
+                        autoPushCreditResult(chnOrderId, applyData.getPartner_flow_id());
+                    }
+
+                    // 保存进件记录
+                    customerApplyOrder = getCustomerApplyOrder(chnOrderId, applyData, capitalInfo, "28", decryptStr);
+                    customerApplyOrderService.save(customerApplyOrder);
+                }
+            }
+            // 遍历非半流程资金方式线上贷款信息列表
+            List<CapitalInfo> notHalfFundTypeCapitalInfoList = getNotHalfFundTypeCapitalInfoList();
+            log.info("日志编号:{},定时器自动进件, 非半流程资金方式线上贷款信息列表:【{}】", logNumber, lst); // 非半流程资金方式线上贷款信息列表
+            for (CapitalInfo capitalInfo : notHalfFundTypeCapitalInfoList) {
+                // 先判断有没有推过,如果有则不再推送
+                wrapper.eq(CustomerApplyOrder::getCapitalId, capitalInfo.getId());
+                customerApplyOrder = customerApplyOrderService.getOne(wrapper);
+                if (Objects.isNull(customerApplyOrder)) {
+                    boolean halfFundTypeFlag = false;
+                    ApplyData applyData = new ApplyData();
+                    applyData.setStatus(1);
+                    applyData.setPartner_flow_id("");
+                    //调用对应资方的推送机制
+                    if (capitalInfo.getId() == 4L) { //青花优品
+                        applyDto = JSON.parseObject(decryptStr, ApplyDto.class);
+                        customer.setCreditNo(ConstantsUtil.getCreditNo());
+                        halfFundTypeFlag = qingHuaYouPinUtil.wldPushToQHYP(capitalInfo, applyDto, customer, logNumber);
+                        if (halfFundTypeFlag) {
+                            applyData.setStatus(0);
+                            applyData.setPartner_flow_id(customer.getCreditNo());
+                        }
+                    }
+                    if (halfFundTypeFlag) {
+
+                        // 进件成功后,调用接受订单状态接口推送数据给我来贷
+                        OrderStatusByWld(chnOrderId, applyData.getPartner_flow_id());
+
+                        // 调用接受授信结果接口推送授信结果给我来贷
+                        autoPushCreditResult(chnOrderId, applyData.getPartner_flow_id());
+                    }
+                    // 保存进件记录
+                    customerApplyOrder = getCustomerApplyOrder(chnOrderId, applyData, capitalInfo, "28", decryptStr);
+                    customerApplyOrderService.save(customerApplyOrder);
+                }
+            }
+        }
     }
 
     private static @NotNull CustomerApplyOrder getCustomerApplyOrder(String chnOrderId, ApplyData applyData, CapitalInfo capitalInfo, String partnerId, String decryptStr) {
@@ -757,7 +955,17 @@
     }
 
     /**
+     * 保存我来贷推送的数据记录
+     *
+     * @param customerWldPushRecord 要保存的数据
+     */
+    private void savePushData(CustomerWldPushRecord customerWldPushRecord) {
+        customerWldPushRecordService.save(customerWldPushRecord);
+    }
+
+    /**
      * 保存数据
+     *
      * @param applyDto 数据对象
      */
     private Customer saveData(ApplyDto applyDto) {
@@ -814,11 +1022,11 @@
             int sesame = applyDto.getProfile_dict().getSesame_point();
             if (sesame == 2) {
                 sesame = 1;
-            }else if (sesame == 3) {
+            } else if (sesame == 3) {
                 sesame = 2;
-            }else if (sesame == 4) {
+            } else if (sesame == 4) {
                 sesame = 3;
-            }else {
+            } else {
                 sesame = random.nextInt(3) + 1;
             }
             customerZcy.setSesame(sesame);
@@ -841,25 +1049,25 @@
             String education = applyDto.getProfile_dict().getEducation();
             if ("2".equals(education)) {
                 education = "1";
-            }else if ("3".equals(education)) {
+            } else if ("3".equals(education)) {
                 education = "2";
-            }else if ("4".equals(education)) {
+            } else if ("4".equals(education)) {
                 education = "3";
-            }else {
+            } else {
                 education = "4";
             }
             // 1. 高中及以下 2. 专科 3. 本科 4. 研究生及以上
-            customerZcy.setEducation("0"+education);
+            customerZcy.setEducation("0" + education);
             customerZcy.setCompanyName(applyDto.getProfile_dict().getOrganize_name());
             //婚姻状况
             String maritalStatus = applyDto.getProfile_dict().getMarital_status().toString();
             if ("2".equals(maritalStatus)) {
                 maritalStatus = "3";
-            }else if ("3".equals(maritalStatus) || "4".equals(maritalStatus) || "5".equals(maritalStatus) || "7".equals(maritalStatus)) {
+            } else if ("3".equals(maritalStatus) || "4".equals(maritalStatus) || "5".equals(maritalStatus) || "7".equals(maritalStatus)) {
                 maritalStatus = "2";
-            }else if ("6".equals(maritalStatus)) {
+            } else if ("6".equals(maritalStatus)) {
                 maritalStatus = "4";
-            }else {
+            } else {
                 int num = random.nextInt(4) + 1;
                 maritalStatus = String.valueOf(num);
             }
@@ -871,9 +1079,9 @@
             int mi = Objects.isNull(monthlyIncome) ? 0 : monthlyIncome.intValue();
             if (mi < 10000) { //'10000以下'
                 mi = 3;
-            }else if (mi < 30000){ //'10000-30000'
+            } else if (mi < 30000) { //'10000-30000'
                 mi = 4;
-            }else { //'30000以上'
+            } else { //'30000以上'
                 mi = 13;
             }
             customerZcy.setMonthlyIncome(mi);
@@ -904,41 +1112,41 @@
             String companyTrade = applyDto.getProfile_dict().getIndustry();
             if ("1".equals(companyTrade)) { //建筑业
                 companyTrade = "E";
-            }else if ("2".equals(companyTrade)) { //电力,热力,燃气及水生产和供应业
+            } else if ("2".equals(companyTrade)) { //电力,热力,燃气及水生产和供应业
                 companyTrade = "D";
-            }else if ("3".equals(companyTrade)) { //交通运输、仓储和邮政业
+            } else if ("3".equals(companyTrade)) { //交通运输、仓储和邮政业
                 companyTrade = "G";
-            }else if ("4".equals(companyTrade)) { //教育
+            } else if ("4".equals(companyTrade)) { //教育
                 companyTrade = "P";
-            }else if ("5".equals(companyTrade)) { //房地产业
+            } else if ("5".equals(companyTrade)) { //房地产业
                 companyTrade = "K";
-            }else if ("6".equals(companyTrade)) { //住宿和餐饮业
+            } else if ("6".equals(companyTrade)) { //住宿和餐饮业
                 companyTrade = "H";
-            }else if ("7".equals(companyTrade)) { //批发和零售业
+            } else if ("7".equals(companyTrade)) { //批发和零售业
                 companyTrade = "F";
-            }else if ("8".equals(companyTrade)) { //租赁和商务服务业
+            } else if ("8".equals(companyTrade)) { //租赁和商务服务业
                 companyTrade = "L";
-            }else if ("9".equals(companyTrade)) { //信息传输、软件和信息技术服务业
+            } else if ("9".equals(companyTrade)) { //信息传输、软件和信息技术服务业
                 companyTrade = "I";
-            }else if ("10".equals(companyTrade)) { //金融业
+            } else if ("10".equals(companyTrade)) { //金融业
                 companyTrade = "J";
-            }else if ("11".equals(companyTrade)) { //文化、体育和娱乐业
+            } else if ("11".equals(companyTrade)) { //文化、体育和娱乐业
                 companyTrade = "R";
-            }else if ("12".equals(companyTrade)) { //制造业
+            } else if ("12".equals(companyTrade)) { //制造业
                 companyTrade = "C";
-            }else if ("13".equals(companyTrade)) { //水利、环境和公共设施管理业
+            } else if ("13".equals(companyTrade)) { //水利、环境和公共设施管理业
                 companyTrade = "N";
-            }else if ("14".equals(companyTrade)) {  //采矿业
+            } else if ("14".equals(companyTrade)) {  //采矿业
                 companyTrade = "B";
-            }else if ("15".equals(companyTrade)) { //农、林、牧、渔业
+            } else if ("15".equals(companyTrade)) { //农、林、牧、渔业
                 companyTrade = "A";
-            }else if ("16".equals(companyTrade)) { //居民服务、修理和其他服务业
+            } else if ("16".equals(companyTrade)) { //居民服务、修理和其他服务业
                 companyTrade = "O";
-            }else if ("17".equals(companyTrade)) { //卫生和社会工作
+            } else if ("17".equals(companyTrade)) { //卫生和社会工作
                 companyTrade = "Q";
-            }else if ("18".equals(companyTrade)) { //科学研究和技术服务业
+            } else if ("18".equals(companyTrade)) { //科学研究和技术服务业
                 companyTrade = "M";
-            }else if ("19".equals(companyTrade)) { //公共管理、社会保障和社会组织
+            } else if ("19".equals(companyTrade)) { //公共管理、社会保障和社会组织
                 companyTrade = "S";
             }
             customerZcy.setCompanyTrade(companyTrade);
@@ -959,9 +1167,9 @@
             int professionInfo = 1;
             if ("1".equals(jobType)) {
                 professionInfo = 2;
-            }else if ("3".equals(jobType)) {
+            } else if ("3".equals(jobType)) {
                 professionInfo = 3;
-            }else {
+            } else {
                 professionInfo = random.nextInt(4) + 1;
             }
             customerZcy.setProfessionInfo(professionInfo);
@@ -978,21 +1186,26 @@
             if (!Objects.isNull(applyDto.getLive_info().getLive_data())) {
                 // 活体分类
                 customerZcy.setVerifySimilarity(applyDto.getLive_info().getLive_data().getFace_score());
+                customerZcy.setVerifySimilarityName(applyDto.getLive_info().getService_provider());
+                customerZcy.setFacePhotoPath(applyDto.getLive_info().getBest_face_image());
             }
-            customerZcy.setVerifySimilarityName(applyDto.getLive_info().getService_provider());
-            customerZcy.setFacePhotoPath(applyDto.getLive_info().getBest_face_image());
+
 
             //设备信息
-            customerZcy.setOs(applyDto.getDevice_info().getOs());
-            customerZcy.setClientIp(applyDto.getDevice_info().getIp());
-            String gps = applyDto.getDevice_info().getGps();
-            if (StringUtils.isNotEmpty(gps)) {
-                String[] gpsArray = gps.split(",");
-                if (gpsArray.length == 2) {
-                    customerZcy.setLng(gpsArray[0]);
-                    customerZcy.setLat(gpsArray[1]);
+            DeviceInfoDto deviceInfo = applyDto.getDevice_info();
+            if (!Objects.isNull(deviceInfo)) {
+                customerZcy.setOs(deviceInfo.getOs());
+                customerZcy.setClientIp(deviceInfo.getIp());
+                String gps = deviceInfo.getGps();
+                if (StringUtils.isNotEmpty(gps)) {
+                    String[] gpsArray = gps.split(",");
+                    if (gpsArray.length == 2) {
+                        customerZcy.setLng(gpsArray[0]);
+                        customerZcy.setLat(gpsArray[1]);
+                    }
                 }
             }
+
             // 标记为我来数科的数据
             customerZcy.setMark(2);
             customerZcyService.save(customerZcy);
@@ -1006,18 +1219,19 @@
         int relation = dto.getRelation();
         if (relation == 1) {
             relation = 2;
-        }else if (relation == 2) {
+        } else if (relation == 2) {
             relation = 1;
-        }else if (relation >=5){
+        } else if (relation >= 5) {
             Random random = new Random();
             int[] values = {2, 3, 4};
             relation = values[random.nextInt(values.length)];
         }
-        return "0"+ relation;
+        return "0" + relation;
     }
 
     /**
      * 从我来贷请求查询接受订单状态接口
+     *
      * @param body 请求体
      * @return RbResponse
      */
@@ -1041,7 +1255,7 @@
                     resp = JSON.parseObject(result, RbResponse.class);
                     return resp;
                 } catch (Exception ex) {
-                    log.error("日志编号:{}, 【我来贷】查询接受订单状态接口请求失败,传参:{} ex:{}",logNumber, fullData, ex.getMessage());
+                    log.error("日志编号:{}, 【我来贷】查询接受订单状态接口请求失败,传参:{} ex:{}", logNumber, fullData, ex.getMessage());
                 }
                 try {
                     resp.setCode("0");
@@ -1069,7 +1283,7 @@
             //解密biz_data
             JSONObject fullData = new JSONObject();
             JSONObject bizData = new JSONObject();
-            bizData.putOpt("chn_order_id",chnOrderId);
+            bizData.putOpt("chn_order_id", chnOrderId);
             bizData.putOpt("partner_flow_id", partnerFlowId);
             bizData.putOpt("status", 101);
             bizData.putOpt("update_time", System.currentTimeMillis() / 1000);
@@ -1083,7 +1297,7 @@
                 result = HttpClientUtil.getInstance().postJsonData(wldUrl + "order_status", String.valueOf(fullData));
                 log.info("日志编号:{} 【我来贷】查询接受订单状态接口请求失败,传参:{},返回结果:{}", logNumber, fullData, result);
             } catch (Exception ex) {
-                log.error("日志编号:{} 【我来贷】查询接受订单状态接口请求,传参:{} ex:{}",logNumber, fullData, ex.getMessage());
+                log.error("日志编号:{} 【我来贷】查询接受订单状态接口请求,传参:{} ex:{}", logNumber, fullData, ex.getMessage());
             }
             try {
                 if (result != null) {
@@ -1121,7 +1335,7 @@
             bizData.putOpt("min_amount", 80000);
             bizData.putOpt("range_amount", 10000);
             Random random = new Random();
-            int[] values  = {3, 6, 9, 12};
+            int[] values = {3, 6, 9, 12};
             int[] loanTerms = new int[1];
             int val = values[random.nextInt(values.length)];
             loanTerms[0] = val;
@@ -1142,7 +1356,7 @@
                 log.error("日志编号:{} 【我来贷】接受授信结果接口请求失败,传参:{} ex:{}", logNumber, fullData, ex.getMessage());
             }
             try {
-                if ( result != null) {
+                if (result != null) {
                     log.info("日志编号:{} 【我来贷】接受授信结果接口数据处理:{}", logNumber, result);
                 }
             } catch (Exception ex) {
@@ -1153,8 +1367,10 @@
             log.error("日志编号:{} 【我来贷】接受授信结果接口请求失败,参数:{}-{},错误原因:{}", logNumber, chnOrderId, partnerFlowId, e.getMessage());
         }
     }
+
     /**
      * 从我来贷请求接受授信结果接口
+     *
      * @return RbResponse
      */
     public RbResponse creditResultByWld(RongBeBasicDto body) {
@@ -1199,6 +1415,7 @@
 
     /**
      * 从我来贷请求接受还款计划接口
+     *
      * @param body 请求体
      * @return RbResponse
      */
@@ -1243,6 +1460,7 @@
 
     /**
      * 加密
+     *
      * @param oriData 要加密的内容串
      * @return String
      */
@@ -1255,7 +1473,8 @@
 
     /**
      * 生成签名(融呗私钥加密)
-     * @param fullData 用于签名的对象
+     *
+     * @param fullData  用于签名的对象
      * @param publicKey 公钥
      * @return String
      */
@@ -1263,13 +1482,14 @@
         //排序
         TreeMap treeMap = JSONUtil.toBean(fullData, TreeMap.class);
         String oriSignData = MapUtil.sortJoin(treeMap, "&", "=", true);
-        RsaSupport rsaSupport = new RsaSupport("RSA", "SHA256WithRSA","RSA/ECB/PKCS1Padding", "utf-8", publicKey, privateKey);
+        RsaSupport rsaSupport = new RsaSupport("RSA", "SHA256WithRSA", "RSA/ECB/PKCS1Padding", "utf-8", publicKey, privateKey);
         return rsaSupport.signByPrivateKey(oriSignData);
     }
 
     /**
      * 解密(公钥解密)
-     * @param fullData 要解密的内容
+     *
+     * @param fullData  要解密的内容
      * @param publicKey 公钥
      * @return String
      */
@@ -1296,6 +1516,7 @@
 
     /**
      * 提供我来贷进件发送短信
+     *
      * @param phone
      */
     public void smsNotify(String phone) {

--
Gitblit v1.9.3