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;
|
}
|
}
|