zbb378@sohu.com
2024-11-04 b2bad51be3c8d3e78d7f81a19415faeac2d0297c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package com.nova.sankuai.domain.api.yidai;
 
import com.alibaba.fastjson.JSONObject;
import com.nova.sankuai.domain.entity.Customer;
import com.nova.sankuai.infra.utils.RSAUtils;
import com.nova.sankuai.security.MD5Encryption;
import io.swagger.annotations.ApiModel;
import lombok.Data;
 
import java.util.ArrayList;
 
/**
 * @author gankk
 * @date 2022/2/18
 */
@Data
@ApiModel("北京亿代信息渠道对接")
public class YiDaiUtil {
 
    //前置撞库接口
    public static final String YIDAI_ZC_URL = "http://123.56.175.54:10183/cust-info/checkPhoneNum";
 
    //公钥加密接口
    public static final String YIDAI_RSA_URL = "http://123.56.175.54:10183/cust-info/saveFromOut/withCheck";
 
    /**
     * 撞库参数对象
     * @param customer
     * @return
     */
    public static JSONObject parseMd5Param (Customer customer) {
        JSONObject jsonObject = new JSONObject();
        String phone = MD5Encryption.getMD5(customer.getPhone());
        jsonObject.put("phoneNumEncrypt",phone);
        return jsonObject;
    }
 
    /**
     * 将客户信息转换成参数对象
     * @param customer
     * @return
     */
    public static JSONObject parseParam (Customer customer) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("custName",customer.getName());
        jsonObject.put("phoneNum",customer.getPhone());
        jsonObject.put("age",customer.getAge() == null ? 30 : customer.getAge());
        jsonObject.put("sex",1);
        jsonObject.put("marryStatus",customer.getMaritalStatus());
        jsonObject.put("profession",customer.getProfessionInfo());
        jsonObject.put("education",customer.getEducation());
        jsonObject.put("loanAmount",customer.getLoanAmount());
        jsonObject.put("annualIncome",customer.getMonthlyIncome() == null ? 0 : customer.getMonthlyIncome()*12);
        jsonObject.put("house",customer.getHouseStatus());
        jsonObject.put("providentFund",customer.getProvidentFund());
        jsonObject.put("socialSecurity",customer.getSocialSecurity());
        jsonObject.put("car",customer.getCarStatus());
        jsonObject.put("creditCard",customer.getCreditCard());
//        jsonObject.put("corporateTax",customer.getEnterpriseInfo());
        jsonObject.put("insurancePolicy",customer.getInsurancePolicy());
        jsonObject.put("microLoan",customer.getMicroLoan());
//        jsonObject.put("businessLicense",customer.get)
//        jsonObject.put("onBehalfOf")
        jsonObject.put("dataFrom","三块分期");
        return jsonObject;
    }
 
    /**
     * 公钥加密参数对象
     * @param object
     * @return
     */
    public static JSONObject parseRSAParam(JSONObject object) {
        JSONObject jsonObject = new JSONObject();
        JSONObject jsonObject1 = new JSONObject();
        ArrayList<JSONObject> objects = new ArrayList<>();
        objects.add(object);
        String publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCIS7ibl2Wds7Go5IkC8hVztKnIXK0nXDLJmenKGv0BuRDR9B8k9irwW+YGydEnmjjI92b9JHDidwunETorKfYLWTRKU3QDqnTQiWWaqK1nK4+F55UhcHshxvZJNGT+b6k6LXxNHgpEJaUyBUhUTx69Em/WsWAisoYqRerUwp0ErQIDAQAB";
        try {
            jsonObject.put("reqBody",objects);
            String encrypt = RSAUtils.encrypt(jsonObject.toJSONString(), publicKey);
            jsonObject1.put("encryptionData",encrypt);
            return jsonObject1;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}