Browse Source

add 基础信息配置

GITZYY 7 months ago
parent
commit
efd906fa8f

+ 8 - 0
egress-gateway-service-domain/pom.xml

@@ -28,5 +28,13 @@
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
         </dependency>
+        <dependency>
+            <groupId>commons-codec</groupId>
+            <artifactId>commons-codec</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+        </dependency>
     </dependencies>
 </project>

+ 318 - 0
egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/common/utils/PrivacyAesUtil.java

@@ -0,0 +1,318 @@
+package com.hrsk.cloud.eg.domain.common.utils;
+
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import javax.crypto.Cipher;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author zhangyy
+ * @version 1.0
+ * @description: PrivacyAesUtil 个人信息 加密方法
+ * @date 2024/8/26 17:58
+ */
+public class PrivacyAesUtil {
+
+    private static final Logger log = LoggerFactory.getLogger(PrivacyAesUtil.class);
+    private static byte[] Keys = {0x41, 0x72, 0x65, 0x79, 0x6F, 0x75, 0x6D, 0x79, 0x53, 0x6E, 0x6F, 0x77, 0x6D, 0x61, 0x6E, 0x3F};
+
+    private final static String AesDecKey = "47FC4124CF94E070";
+
+    private final static String AesDecIv = "ovOh2xYoRdfATob6";
+
+    public final static String RESULT = "result";
+    public final static String SALT = "salt";
+
+
+    public static String encryptCBCPKCS5(String sSrc, String sKey,String ivKey) throws Exception {
+        if (sKey == null) {
+            System.out.print("Key为空null");
+            return null;
+        }
+        // 判断Key是否为16位
+        if (sKey.length() != 16) {
+            System.out.print("Key长度不是16位");
+            return null;
+        }
+        byte[] raw = sKey.getBytes("utf-8");
+        SecretKeySpec keySpec = new SecretKeySpec(raw, "AES");
+        Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");//"算法/模式/补码方式"
+        IvParameterSpec iv = new IvParameterSpec(ivKey.getBytes());//使用CBC模式,需要一个向量iv,可增加加密算法的强度
+        cipher.init(Cipher.ENCRYPT_MODE, keySpec, iv);
+        byte[] encrypted = cipher.doFinal(sSrc.getBytes());
+        return encode(encrypted);//此处使用BASE64做转码功能,同时能起到2次加密的作用。
+    }
+
+    public static String decryptAESCbc(String data, String key, String iv) throws Exception {
+        try {
+
+            byte[] encrypted1 = decode(data);
+            Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
+            SecretKeySpec keyspace = new SecretKeySpec(key.getBytes(), "AES");
+            IvParameterSpec specie = new IvParameterSpec(iv.getBytes());
+
+            cipher.init(Cipher.DECRYPT_MODE, keyspace, specie);
+
+            byte[] original = cipher.doFinal(encrypted1);
+            String originalString = new String(original);
+            return originalString.trim();
+        } catch (Exception e) {
+            log.error("decryptAESCbc fail",e);
+            return null;
+        }
+    }
+
+
+
+    /**
+     * @param data 明文
+     * @param key  密钥,长度16
+     * @return 密文
+     * AES算法加密明文
+     */
+    public static String encryptAES(String data, String key, String iv) throws Exception {
+        try {
+            Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
+//            String iv = "0000000000000000";
+            int blockSize = cipher.getBlockSize();
+            byte[] dataBytes = data.getBytes();
+            int plaintextLength = dataBytes.length;
+
+            if (plaintextLength % blockSize != 0) {
+                plaintextLength = plaintextLength + (blockSize - (plaintextLength % blockSize));
+            }
+
+            byte[] plaintext = new byte[plaintextLength];
+            System.arraycopy(dataBytes, 0, plaintext, 0, dataBytes.length);
+
+            SecretKeySpec keyspec = new SecretKeySpec(key.getBytes(), "AES");
+            IvParameterSpec ivspec = new IvParameterSpec(iv.getBytes());
+
+            cipher.init(Cipher.ENCRYPT_MODE, keyspec, ivspec);
+            byte[] encrypted = cipher.doFinal(plaintext);
+
+            return encode(encrypted).trim();
+
+        } catch (Exception e) {
+           log.error("encryptAES fail",e);
+            return null;
+        }
+    }
+
+    /**
+     * @param data 密文
+     * @param key  密钥,长度16
+     * @return 明文
+     * AES算法解密密文
+     */
+    public static String decryptAES(String data, String key, String iv) throws Exception {
+        try {
+
+            byte[] encrypted1 = decode(data);
+            Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
+            SecretKeySpec keyspace = new SecretKeySpec(key.getBytes(), "AES");
+            IvParameterSpec specie = new IvParameterSpec(iv.getBytes());
+
+            cipher.init(Cipher.DECRYPT_MODE, keyspace, specie);
+
+            byte[] original = cipher.doFinal(encrypted1);
+            String originalString = new String(original);
+            return originalString.trim();
+        } catch (Exception e) {
+           log.error("decryptAES fail ",e);
+            return null;
+        }
+    }
+
+
+    /**
+     * 编码
+     *
+     * @param byteArray
+     * @return
+     */
+    private static String encode(byte[] byteArray) {
+        return new String(new Base64().encode(byteArray));
+    }
+    /**
+     * 解码
+     *
+     * @param base64EncodedString
+     * @return
+     */
+    private static byte[] decode(String base64EncodedString) {
+        return new Base64().decode(base64EncodedString);
+    }
+
+    /**
+     * 用于手机号。身份证号等长于4位的字符串类型加密 用原字符串后四位进行加密  身份证结果44位,手机号结果24位
+     * @param sourceStr 待加密字符串
+     * @return
+     */
+    public static Map<String, String> encryptNum(String sourceStr)  {
+        String key = "47FC4124CF94";
+        String iv = "rffgzmz2fedyts9s";
+        Map<String, String> resultMap = new HashMap<>();
+        if(StringUtils.isEmpty(sourceStr) || "null".equals(sourceStr)){
+            return resultMap;
+        }
+        if(sourceStr.length()<4){
+            resultMap.put(PrivacyAesUtil.SALT, "1234");
+            resultMap.put(PrivacyAesUtil.RESULT, encryptSortNum(sourceStr));
+            return resultMap;
+        }
+        String subStr = sourceStr.substring(sourceStr.length()-4,sourceStr.length());
+        subStr = subStr.replaceAll("(x|X)", "A").replaceAll("[^0-9aA]", "B");
+
+        key += subStr;
+        String resultStr = "";
+        try {
+            resultStr = encryptCBCPKCS5(sourceStr, key, AesDecIv);
+        }catch (Exception e){
+            System.out.println(key);
+            e.printStackTrace();
+        }
+        resultMap.put(PrivacyAesUtil.SALT, subStr);
+        resultMap.put(PrivacyAesUtil.RESULT, resultStr);
+        return resultMap;
+    }
+
+    /**
+     * 4位以下的字符串类型加密 用固定key进行加密
+     * @param sourceStr 待加密字符串
+     * @return
+     */
+    private static String encryptSortNum(String sourceStr) {
+        String key = "47FC4124CF941234";
+        String iv = "rffgzmz2fedyts9s";
+        String resultStr = "";
+        try {
+            resultStr = encryptCBCPKCS5(sourceStr, key, AesDecIv);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return resultStr;
+    }
+
+    /**
+     * 将加密后信息及加密盐放入待加密map
+     * @param map
+     * @param keyName
+     * @param keySaltName
+     */
+    public static void encFillMap(Map map, String keyName, String keySaltName){
+        if(null == map || map.isEmpty()){
+            return;
+        }
+        if(StringUtils.isEmpty(String.valueOf(map.get(keyName))) || null == map.get(keyName)){
+            return;
+        }
+        Map<String, String> encResultMap = PrivacyAesUtil.encryptNum(String.valueOf(map.get(keyName)));
+        map.put(keyName, encResultMap.get(PrivacyAesUtil.RESULT));
+        map.put(keySaltName, encResultMap.get(PrivacyAesUtil.SALT));
+    }
+
+    /**
+     * 将查询结果解密放到待解密map中
+     * @param map
+     * @param keyName
+     * @param keySaltName
+     */
+    public static void decFillMap(Map map, String keyName, String keySaltName){
+        if(null == map || map.isEmpty() || StringUtils.isEmpty(String.valueOf(map.get(keyName))) || StringUtils.isEmpty(String.valueOf(map.get(keySaltName)))){
+            return;
+        }
+        map.put(keyName, decryptNum(String.valueOf(map.get(keyName)), String.valueOf(map.get(keySaltName))));
+    }
+
+    /**
+     * 对应encryptNum 及 encryptSortNum函数的解密
+     * @param sourceStr 待解密字符串
+     * @param salt 盐
+     * @return
+     */
+    public static String decryptNum(String sourceStr, String salt) {
+        if("null".equals(sourceStr)){
+            return null;
+        }
+        if(StringUtils.isEmpty(sourceStr)||StringUtils.isEmpty(salt) || "null".equals(salt)){
+            return sourceStr;
+        }
+        String key = "47FC4124CF94"+salt;
+        String resultStr = "";
+        try{
+            resultStr = decryptAESCbc(sourceStr, key, AesDecIv);
+        }catch (Exception e){
+            log.warn("解密出错源{},",sourceStr);
+        }
+        if (StringUtils.isBlank(resultStr)){
+            if (sourceStr.length() == 11 && sourceStr.startsWith("1") && sourceStr.endsWith(salt)){
+                return sourceStr;
+            }
+        }
+        return resultStr;
+    }
+
+    public static void main(String[] args){
+        Map<String, Object> testMap = new HashMap<>();
+        testMap.put("mobile","18190742697");
+        PrivacyAesUtil.encFillMap(testMap, "mobile", "mobileSalt");
+        System.out.println(testMap);
+        String rtn = String.valueOf(testMap.get("mobile"));
+        System.out.println("rtn:"+rtn);
+        System.out.println(PrivacyAesUtil.decryptNum(rtn, String.valueOf(testMap.get("mobileSalt"))));
+        try {
+            System.out.println(PrivacyAesUtil.decryptNum("Hhn8PDX1wLDtfcgmXc8PXA==", "1199"));
+            System.out.println("--------------------------------------");
+            System.out.println(PrivacyAesUtil.encryptAES("M/n254m1qm5z1YTw6C3Flg==", "47FC4124CF946428", AesDecIv));
+        }catch (Exception e){
+
+        }
+
+    }
+
+    public static String encryptEcb5(String sSrc, String sKey) {
+        if (sKey == null) {
+            return null;
+        }// 判断 Key 是否为 16 位
+        if (sKey.length() != 16) {
+            if(sKey.length()!=32){
+                return null;
+            }
+        }
+        try {
+            byte[] raw = sKey.getBytes("utf-8");
+            SecretKeySpec skySpec = new SecretKeySpec(raw, "AES"); // "算法/模式/补码方式"
+            Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
+            cipher.init(Cipher.ENCRYPT_MODE, skySpec);
+            byte[] encrypted = cipher.doFinal(sSrc.getBytes("utf-8")); // 此处使用 BASE64 做转码功能,同时能起到 2 次加密的作用。
+            return Base64.encodeBase64String(encrypted);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return null;
+    }
+
+    public static String decryptEcb5(String sSrc, String sKey) throws Exception {
+        if (sKey == null) {
+            return null;
+        }// 判断 Key 是否为 16 位
+        if (sKey.length() != 16) {
+            if(sKey.length()!=32){
+                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[] encrypted = cipher.doFinal(Base64.decodeBase64(sSrc)); // 此处使用 BASE64 做转码功能,同时能起到 2 次加密的作用。
+        return new String(encrypted);
+    }
+}

+ 8 - 0
egress-gateway-service-infrastructure/pom.xml

@@ -41,6 +41,14 @@
             <groupId>com.alibaba</groupId>
             <artifactId>druid-spring-boot-starter</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>commons-codec</groupId>
+            <artifactId>commons-codec</artifactId>
+        </dependency>
         <dependency>
             <groupId>com.h2database</groupId>
             <artifactId>h2</artifactId>

+ 201 - 0
egress-gateway-service-infrastructure/src/main/java/com/hrsk/cloud/eg/infrastructure/repository/database/entity/XdOrderInfo.java

@@ -0,0 +1,201 @@
+package com.hrsk.cloud.eg.infrastructure.repository.database.entity;
+
+import com.hrsk.cloud.eg.domain.common.utils.PrivacyAesUtil;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.Map;
+
+/**
+ * <p>
+ * 信贷订单表
+ * </p>
+ *
+ * @author
+ * @since 2019-09-29
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class XdOrderInfo implements Serializable {
+
+    //@TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    //申请id
+    private Integer applyId;
+
+    private Long userId;
+
+
+    //产品id
+    private Integer productId;
+
+    //抢单状态 -2.无匹配 -1.待推送 0.待抢单(初始状态) " +
+    //            "1.已抢单 2.被拒绝(系统策略拒绝,或后台初审拒绝) 3.订单关闭(长时间无人抢单,订单被关闭) 4.被退单 5.订单完成(已结算)6.超时关闭(超过5天未处理,平台方关闭该订单)
+    private Integer status;
+
+    //订单状态  0-申请成功 2-申请失败 3退单 4取消订单
+    private Integer oStatus;
+
+    //抢单方式 1.独享 2.共享 3.未知
+    private Integer orderType;
+
+    private Date createTime;
+
+    private String createBy;
+
+    private Date updateTime;
+
+
+    private String updateBy;
+
+    private String submitTime;
+
+    private String reason;
+
+    /*
+        borrow_money,
+        borrow_limit,
+        borrow_purpose,
+        is_grab,
+        is_apply,
+        user_mobile,
+        real_name,
+        channel_name,
+        product_name
+        借款金额 单位万元,1-100之间的整数。
+     */
+    private Integer borrowMoney;
+
+    //借款金额
+    private Integer borrowRange;
+
+    //借款期限 1. 1个月 2. 3个月 3. 6个月 4. 9个月 5. 12个月 6. 24个月 7. 36个月 8. 36个月以上
+    private Integer borrowLimit;
+
+    //借款用途 1.购车贷款 2.购房贷款 3.装修贷款 4.教育贷款 5.消费贷款 6.过桥贷款 7.结婚贷款 8.旅游贷款 9.医疗贷款 10.其他贷款
+    private Integer borrowPurpose;
+
+
+    //用户电话
+    private String userMobile;
+
+    //用户真实姓名
+    private String realName;
+
+    //推广渠道名
+    private String channelName;
+
+    //推广渠道
+    private String channelCode;
+
+    //信贷产品名
+    private String productName;
+
+    //商务后台状态: 0:待处理,1:待跟进,2:有效用户,3:无效用户
+    private Integer merchantStatus;
+
+    //商务后台备注
+    private String merchantRemark;
+
+
+    //投放渠道
+    private Integer deliveryMethod;
+
+
+    //单价
+    private BigDecimal price;
+
+    //对接的crm平台
+    private String crmPlatform;
+
+    //车产
+    private Integer carType;
+
+    //房产
+    private Integer houseType;
+
+    //寿险
+    private Integer insuranceType;
+
+    //公积金
+    private Integer accumulation;
+
+    //社保
+    private Integer socialSecurity;
+
+    //信用卡
+    private Integer creditCard;
+
+    //芝麻分
+    private Integer sesame;
+
+    //城市
+    private String city;
+
+    //职业
+    private Integer profession;
+
+    //车产估值
+    private Integer carAppraisement;
+    //房产估值
+    private Integer houseAppraisement;
+     //保单保价
+    private Integer insuranceAppraisement;
+    //车辆是否抵押
+    private Integer carImpawn;
+
+    //房子是否抵押
+    private Integer houseImpawn;
+
+    //机构id
+    private String busiId;
+    //机构id
+    private String mainAccount;
+
+    //月收入code
+    private Integer monthlyIncomeCode;
+
+   //表单id
+    private Integer formId;
+
+    //交易流水号
+    private String tradeNo;
+
+
+    private String userSex;
+
+   // 是否逾期 0:无逾期 1:逾期一月内 2 逾期三个月内 3逾期超过三个月
+    private Integer overdue;
+
+    //订单失败原因
+    private String applyFailReason;
+
+
+    private String userMobileSalt;
+
+    private String ip;
+
+    //商户查看状态,1-已查看,其他-未查看
+    private Integer viewStatus;
+
+    private String userMobileMd5;
+
+    /** 归因渠道编号 */
+    private String ascriptionChannelCode;
+
+    public void encAll(){
+        Map<String,String> mobileMap = PrivacyAesUtil.encryptNum(this.userMobile);
+        this.userMobile = mobileMap.get(PrivacyAesUtil.RESULT);
+        this.userMobileSalt = mobileMap.get(PrivacyAesUtil.SALT);
+    }
+    public void decAll(){
+        this.userMobile = PrivacyAesUtil.decryptNum(this.userMobile, this.userMobileSalt);
+    }
+
+}

+ 0 - 1
egress-gateway-service-infrastructure/src/main/java/com/hrsk/cloud/eg/infrastructure/repository/database/entity/package-info.java

@@ -1 +0,0 @@
-package com.hrsk.cloud.eg.infrastructure.repository.database.entity;

+ 0 - 1
egress-gateway-service-infrastructure/src/main/java/com/hrsk/cloud/eg/infrastructure/repository/database/package-info.java

@@ -1 +0,0 @@
-package com.hrsk.cloud.eg.infrastructure.repository.database;

+ 12 - 1
pom.xml

@@ -20,6 +20,8 @@
         <mybatis-starter.version>2.2.2</mybatis-starter.version>
         <mybatis-plus.version>3.5.4.1</mybatis-plus.version>
         <druid-starter.version>1.2.9</druid-starter.version>
+        <commons-lang3.version>3.9</commons-lang3.version>
+        <commons-codec.version>1.16.1</commons-codec.version>
     </properties>
 
     <dependencies>
@@ -69,7 +71,16 @@
                 <version>1.0-SNAPSHOT</version>
             </dependency>
             <!-- 应用模块依赖-end -->
-
+            <dependency>
+                <groupId>org.apache.commons</groupId>
+                <artifactId>commons-lang3</artifactId>
+                <version>${commons-lang3.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>commons-codec</groupId>
+                <artifactId>commons-codec</artifactId>
+                <version>${commons-codec.version}</version>
+            </dependency>
             <dependency>
                 <groupId>com.hrsk.pangu</groupId>
                 <artifactId>pangu-component-bom</artifactId>

+ 1 - 0
start/src/main/java/com/hrsk/cloud/eg/Application.java

@@ -2,6 +2,7 @@ package com.hrsk.cloud.eg;
 
 import lombok.extern.slf4j.Slf4j;
 import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.beans.BeanUtils;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 

+ 3 - 2
start/src/main/resources/application.yaml

@@ -10,9 +10,10 @@ spring:
   profiles:
     active: pre
 #mybatis
-mybatis:
-  config-location: classpath:mybatis-config.xml
 mybatis-plus:
+  mapper-locations: classpath*:mapper/**/*.xml
+  config-location: classpath:mybatis-config.xml
+  global-config.banner: true
   configurationProperties:
     log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
 #pageHelper