Browse Source

update eg

GITZYY 1 week ago
parent
commit
16050f7767

+ 173 - 52
egress-gateway-service-infrastructure/src/main/java/com/hrsk/cloud/eg/infrastructure/loanMannager/threedocking/impl/BeiJingChongHeCreditService.java

@@ -1,23 +1,31 @@
 package com.hrsk.cloud.eg.infrastructure.loanMannager.threedocking.impl;
 
+import com.alibaba.fastjson2.JSON;
 import com.alibaba.fastjson2.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.hrsk.cloud.eg.clinet.dto.data.plan.command.EgLoanApiConfigInfoCmd;
 import com.hrsk.cloud.eg.clinet.dto.data.plan.command.PlanCmd;
-import com.hrsk.cloud.eg.clinet.dto.data.user.command.UserBaseInfoCmd;
+import com.hrsk.cloud.eg.clinet.dto.data.user.command.*;
 import com.hrsk.cloud.eg.clinet.vo.DataVo;
+import com.hrsk.cloud.eg.clinet.vo.OrderResponseVo;
 import com.hrsk.cloud.eg.domain.common.constant.ServerCodeEnums;
+import com.hrsk.cloud.eg.domain.utils.Md5Util;
 import com.hrsk.cloud.eg.infrastructure.config.client.HessianUtils;
 import com.hrsk.cloud.eg.infrastructure.config.client.RetryRestTemplate;
 import com.hrsk.cloud.eg.infrastructure.loanMannager.threedocking.LoanDockingApi;
 import com.hrsk.cloud.eg.infrastructure.service.EgApiService;
+import com.hrsk.cloud.eg.infrastructure.utils.DateUtil;
+import com.hrsk.cloud.eg.infrastructure.utils.UserUtils;
 import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.codec.binary.Base64;
+import org.springframework.scheduling.annotation.AsyncResult;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import javax.crypto.Cipher;
 import javax.crypto.spec.SecretKeySpec;
+import java.time.LocalDateTime;
 
 /**
  * @Author Liu Tao
@@ -39,6 +47,170 @@ public class BeiJingChongHeCreditService implements LoanDockingApi {
         return ServerCodeEnums.BeiJingChongHe;
     }
 
+    @Override
+    public OrderResponseVo qualityApply(UserBaseInfoCmd user, PlanCmd planDto, EgLoanApiConfigInfoCmd configInfoCmd) {
+        try {
+            log.info("credit BeiJingChongHeCreditService createApplyAndOrder begin...userId:{}",user.getUserId());
+            String configJson = HessianUtils.deserialize(configInfoCmd.getRequestConfig()).toString();
+            JSONObject config = JSONObject.parseObject(configJson);
+            log.info("北京重和对接参数:{}", JSON.toJSONString(config));
+
+            ApplyInfo applyInfoApi = new ApplyInfo();
+            applyInfoApi.setChannel_code(config.getInteger("channel_code"));
+            applyInfoApi.setPhone(ApiAesUtil.Encrypt(user.getUserMobile(),config.getString("channel_secret_key")));
+            applyInfoApi.setName(UserUtils.getUserName(user.getRealName(),user.getPoliceSex()));
+            if (user.getPoliceSex()!=null) {
+                applyInfoApi.setSex(user.getPoliceSex().equals("男")?1 : 2);
+            }
+            if (user.getPoliceBirthBate()!=null)
+                applyInfoApi.setAge(DateUtil.getAgeByBirth(DateUtil.convertString2Date(user.getPoliceBirthBate(), "yyyy-MM-dd")));
+            else if (user.getAge() !=null){
+                applyInfoApi.setAge(user.getAge());
+            } else {
+                applyInfoApi.setAge(0);
+            }
+            UserAssetHouseInfoCmd houseInfo = user.getHouseInfo();
+            UserAssetCarInfoCmd carInfo = user.getCarInfo();
+
+            UserProfessionEcommerceOwnersCmd businessOwners = user.getEcommerceOwners();
+
+            UserProfessionBusinessOwnerCmd businessOwner = user.getBusinessOwner();
+
+            UserProfessionSelfEmployedCmd employed = user.getSelfEmployed();
+
+            applyInfoApi.setQuota(user.getXdApplyParam().getBorrowMoney());
+            getHouse(houseInfo, applyInfoApi);//房产
+            getCar(carInfo,applyInfoApi);//车产
+            getSocialSecurity(user,applyInfoApi);//社保
+            getCreditCard(user,applyInfoApi);//信用卡
+            getBusinessLicense(businessOwners,businessOwner,employed,user,applyInfoApi);
+
+            log.info("北京重和请求参数:{},手机加密前:{}",JSON.toJSONString(applyInfoApi),JSON.toJSONString(user.getUserMobile()));
+            String url = config.getString("applyUrl");
+            JSONObject response = null;
+            try{
+                response =httpRestTemplate.restTemplate().postForObject(url, applyInfoApi, JSONObject.class);
+            }catch (Exception e){
+                log.error("北京重和申请异常,异常信息:{}", e.getMessage(), e);
+            }
+            log.info("credit createApplyAndOrder BeiJingChongHeCreditService response userId:{}, result:{}",user.getUserId(), response);
+            if (response == null) {
+                return OrderResponseVo.fail("返回数据为空",ServerCodeEnums.BeiJingChongHe.getMsg());
+            }
+            if (response.getInteger("code") == 0) {
+
+              return OrderResponseVo.ok(ServerCodeEnums.BeiJingChongHe.getMsg());
+            }
+            return OrderResponseVo.fail(response.getJSONObject("data").getString("error_info"),ServerCodeEnums.BeiJingChongHe.getMsg());
+        }catch (Exception e) {
+            log.error("北京重和申请失败", e);
+            return OrderResponseVo.fail("请求失败",ServerCodeEnums.BeiJingChongHe.getMsg());
+        }
+    }
+
+
+    private void getBusinessLicense(UserProfessionEcommerceOwnersCmd businessOwners, UserProfessionBusinessOwnerCmd businessOwner,
+                                    UserProfessionSelfEmployedCmd employed, UserBaseInfoCmd userBasicInfo, ApplyInfo applyInfoApi) {
+        if (userBasicInfo == null || null == userBasicInfo.getProfession()) {
+            applyInfoApi.setBusiness_license(0);
+        }else if (userBasicInfo.getProfession() == 2 ){//个体户
+            if (employed.getBusinessLicense()==1){
+                applyInfoApi.setBusiness_license(0);
+            }else {
+                applyInfoApi.setBusiness_license(1);
+            }
+        }else if (userBasicInfo.getProfession()==3){//电商主
+            if (businessOwners.getBusinessLicense()==1){
+                applyInfoApi.setBusiness_license(0);
+            }else {
+                applyInfoApi.setBusiness_license(1);
+            }
+        }
+    }
+
+    private void getCreditCard(UserBaseInfoCmd userBasicInfo, ApplyInfo applyInfoApi) {
+        if (null==userBasicInfo||userBasicInfo.getCreditCard()==5){
+            applyInfoApi.setCredit_card(0);
+        }else {
+            applyInfoApi.setCredit_card(1);
+        }
+    }
+
+    private void getSocialSecurity(UserBaseInfoCmd userBasicInfo, ApplyInfo applyInfoApi) {
+        if (null==userBasicInfo||userBasicInfo.getSocialSecurity()==0){
+            applyInfoApi.setSocial_security(0);
+        }else {
+            applyInfoApi.setSocial_security(1);
+        }
+    }
+
+    private void getCar(UserAssetCarInfoCmd carInfo, ApplyInfo applyInfoApi) {
+        if (null==carInfo||carInfo.getCarType()==1){
+            applyInfoApi.setCar(0);
+        }else {
+            applyInfoApi.setCar(1);
+        }
+    }
+
+
+    private void getHouse(UserAssetHouseInfoCmd houseInfo, ApplyInfo applyInfoApi) {
+        if (null==houseInfo || houseInfo.getHouseType()==2){
+            applyInfoApi.setHouse(0);
+        }else {
+            applyInfoApi.setHouse(1);
+        }
+    }
+
+    private static class ApiAesUtil {
+        public static String Encrypt(String sSrc, String sKey) throws Exception {
+            if (sKey == null) {
+                System.out.print("Key为空null");
+                return null;
+            }
+            if (sKey.length() != 16) {
+                System.out.print("Key长度不是16位");
+                return null;
+            }
+            byte[] raw = sKey.getBytes("utf-8");
+            SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
+            Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");//"算法/模式/补码方式"
+            cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
+            byte[] encrypted = cipher.doFinal(sSrc.getBytes("utf-8"));
+
+            return Base64.encodeBase64String(encrypted);//此处使用BASE64做转码功能,同时能起到2次加密的作用。
+        }
+
+        public static String Decrypt(String sSrc, String sKey) throws Exception {
+            try {
+                if (sKey == null) {
+                    System.out.print("Key为空null");
+                    return null;
+                }
+                if (sKey.length() != 16) {
+                    System.out.print("Key长度不是16位");
+                    return null;
+                }
+                byte[] raw = sKey.getBytes("utf-8");
+                SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
+                Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
+                cipher.init(Cipher.DECRYPT_MODE, skeySpec);
+                byte[] encrypted1 = Base64.decodeBase64(sSrc);//先用base64解密
+                try {
+                    byte[] original = cipher.doFinal(encrypted1);
+                    String originalString = new String(original,"utf-8");
+                    return originalString;
+                } catch (Exception e) {
+                    System.out.println(e.toString());
+                    return null;
+                }
+            } catch (Exception ex) {
+                System.out.println(ex.toString());
+                return null;
+            }
+        }
+
+    }
+
     @Data
     private static class CheckInfo{
         private Integer channel_code;//渠道编码
@@ -207,55 +379,4 @@ public class BeiJingChongHeCreditService implements LoanDockingApi {
 
     }
 
-
-    private static class ApiAesUtil {
-        public static String Encrypt(String sSrc, String sKey) throws Exception {
-            if (sKey == null) {
-                System.out.print("Key为空null");
-                return null;
-            }
-            if (sKey.length() != 16) {
-                System.out.print("Key长度不是16位");
-                return null;
-            }
-            byte[] raw = sKey.getBytes("utf-8");
-            SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
-            Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");//"算法/模式/补码方式"
-            cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
-            byte[] encrypted = cipher.doFinal(sSrc.getBytes("utf-8"));
-
-            return Base64.encodeBase64String(encrypted);//此处使用BASE64做转码功能,同时能起到2次加密的作用。
-        }
-
-        public static String Decrypt(String sSrc, String sKey) throws Exception {
-            try {
-                if (sKey == null) {
-                    System.out.print("Key为空null");
-                    return null;
-                }
-                if (sKey.length() != 16) {
-                    System.out.print("Key长度不是16位");
-                    return null;
-                }
-                byte[] raw = sKey.getBytes("utf-8");
-                SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
-                Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
-                cipher.init(Cipher.DECRYPT_MODE, skeySpec);
-                byte[] encrypted1 = Base64.decodeBase64(sSrc);//先用base64解密
-                try {
-                    byte[] original = cipher.doFinal(encrypted1);
-                    String originalString = new String(original,"utf-8");
-                    return originalString;
-                } catch (Exception e) {
-                    System.out.println(e.toString());
-                    return null;
-                }
-            } catch (Exception ex) {
-                System.out.println(ex.toString());
-                return null;
-            }
-        }
-
-    }
-
 }