package com.nova.sankuai.domain.api.jinzhanggui;
|
|
import com.alibaba.fastjson.JSONObject;
|
import com.nova.sankuai.domain.dto.CustomerCompareDto;
|
import com.nova.sankuai.domain.entity.Customer;
|
import com.nova.sankuai.domain.enums.ProfessionInfoEnum;
|
import com.nova.sankuai.domain.enums.customerinfo.*;
|
import org.apache.commons.lang.StringUtils;
|
import org.slf4j.Logger;
|
import org.slf4j.LoggerFactory;
|
import org.springframework.stereotype.Component;
|
import org.springframework.util.DigestUtils;
|
|
import java.util.HashMap;
|
|
/**
|
* @Author Lilinhong
|
* @Date 2022/7/21 11:15
|
*/
|
@Component
|
public class JinZhangGuiUtil {
|
|
public static final String HIT_URL = "http://system.rhw6688.com/api/checkUser";
|
|
public static final String COMMIT_URL = "http://system.rhw6688.com/api/json_reg";
|
|
public static final Integer CID = 513;
|
|
public static final String SRC = "中银e融-5";
|
|
public static final String KEY = "08f5b8786d5d88a17f0c50da5b277b1b";
|
|
private static final Logger log = LoggerFactory.getLogger("apiCompanyInfoLogger");
|
|
public static final String SUCCESS = "0";
|
|
public static HashMap parseHitParam(Customer customer) {
|
HashMap<String, Object> hitParam = new HashMap<>();
|
hitParam.put("cid", CID);
|
hitParam.put("mobile", DigestUtils.md5DigestAsHex(customer.getPhone().getBytes()));
|
hitParam.put("v", DigestUtils.md5DigestAsHex((JinZhangGuiUtil.CID + JinZhangGuiUtil.KEY).getBytes()));
|
return hitParam;
|
}
|
|
public static JSONObject parseCommitParam(Customer customer) {
|
CustomerCompareDto parse = CustomerCompareDto.parse(customer);
|
JSONObject param = new JSONObject();
|
param.put("cid", CID);
|
String v = customer.getPhone() + CID + KEY;
|
param.put("v", DigestUtils.md5DigestAsHex(v.getBytes()));
|
param.put("src", SRC);
|
param.put("name", customer.getName());
|
param.put("age", customer.getAge());
|
String birthday = customer.getBirthday();
|
if (StringUtils.isNotEmpty(birthday)) {
|
StringBuffer stringBuffer = new StringBuffer(birthday);
|
stringBuffer.insert(6, "-");
|
stringBuffer.insert(4, "-");
|
birthday = stringBuffer.toString();
|
}
|
param.put("birthday", birthday);
|
param.put("sex", "男".equals(customer.getSex()) ? 1 : 2);
|
param.put("mobile", customer.getPhone());
|
param.put("ip", customer.getIpAddres());
|
if (StringUtils.isNotEmpty(customer.getCityName()) && customer.getCityName().endsWith("市")) {
|
param.put("city", customer.getCityName().substring(0, customer.getCityName().indexOf("市")));
|
} else {
|
param.put("city", customer.getCityName());
|
}
|
float moneyFloat = parse.getQuota() / 10000f;
|
int moneyInt = parse.getQuota() / 10000;
|
if (moneyFloat - moneyInt > 0.45) {
|
++moneyInt;
|
}
|
param.put("loan_amount", moneyInt);
|
Integer houseParse = houseParse(customer.getHousePayment());
|
param.put("houses", houseParse);
|
param.put("car", parse.isCarStatus() ? 1 : 0);
|
param.put("life_policy", parse.isInsurancePolicy() ? 1 : 2);
|
param.put("epf_time", parse.isProvidentFund() ? 1 : 0);
|
param.put("social_security", parse.isSocialSecurity() ? 1 : 0);
|
Integer weilidai = weilidaiParse(customer.getMicroLoan());
|
param.put("particle_loan", weilidai);
|
Integer zhima = zhimaParse(customer.getSesame());
|
param.put("sesame_credit", zhima);
|
param.put("credit_card", parse.isCreditCard() ? 1 : 2);
|
Integer occupationParse = occupationParse(customer.getProfessionInfo());
|
param.put("occupation", occupationParse);
|
Integer incomeRange = incomeRangeParse(customer.getMonthlyIncome());
|
param.put("income_range", incomeRange);
|
param.put("reg_time", System.currentTimeMillis() / 1000);
|
return param;
|
}
|
|
|
public static Integer houseParse(Integer housePayment) {
|
if (housePayment != null) {
|
if (HousePaymentEnum.HousePayment_2.getCode().equals(housePayment)) {
|
return 2;
|
}
|
if (HousePaymentEnum.HousePayment_3.getCode().equals(housePayment)) {
|
return 1;
|
}
|
}
|
return 12;
|
}
|
|
public static Integer incomeRangeParse(Integer incomeRange) {
|
if (incomeRange != null && !MonthlyIncomeEnum.Income_6.getCode().equals(incomeRange)) {
|
if (MonthlyIncomeEnum.Income_3Q_6Q.getCode().equals(incomeRange) ||
|
MonthlyIncomeEnum.INCOME_3Q_UNDER.getCode().equals(incomeRange) ||
|
MonthlyIncomeEnum.Income_5Q_UNDER.getCode().equals(incomeRange)) {
|
return 1;
|
} else if (MonthlyIncomeEnum.Income_6Q_1W.getCode().equals(incomeRange) ||
|
MonthlyIncomeEnum.Income_5Q_1W.getCode().equals(incomeRange) ||
|
MonthlyIncomeEnum.Income_1W_UNDER.getCode().equals(incomeRange)) {
|
return 2;
|
} else {
|
return 3;
|
}
|
}
|
return 1;
|
}
|
|
|
|
public static Integer occupationParse(Integer occupation) {
|
if (occupation != null) {
|
if (ProfessionInfoEnum.OFFICE_WORKER.getCode().equals(occupation)) {
|
return 3;
|
}
|
if (ProfessionInfoEnum.FREELANCE.getCode().equals(occupation)) {
|
return 5;
|
}
|
if (ProfessionInfoEnum.BUSINESS_OWNERS.getCode().equals(occupation)) {
|
return 1;
|
}
|
if (ProfessionInfoEnum.SELF_EMPLOYED.getCode().equals(occupation)) {
|
return 2;
|
}
|
if (ProfessionInfoEnum.CIVIL_SERVANTS.getCode().equals(occupation)) {
|
return 3;
|
}
|
|
}
|
return 4;
|
}
|
|
public static Integer weilidaiParse(Integer weilidai) {
|
if (weilidai != null) {
|
if (MicroLoanEnum.MicroLoanEnum_2.getCode().equals(weilidai)) {
|
return 1;
|
}
|
if (MicroLoanEnum.MicroLoanEnum_3.getCode().equals(weilidai)) {
|
return 1;
|
}
|
}
|
return 2;
|
}
|
|
public static Integer zhimaParse(Integer zhima) {
|
if (zhima != null) {
|
if (SesameStatusEnum.Sesame_2.getCode().equals(zhima)) {
|
return 1;
|
}
|
if (SesameStatusEnum.Sesame_3.getCode().equals(zhima)) {
|
return 2;
|
}
|
if (SesameStatusEnum.Sesame_4.getCode().equals(zhima)) {
|
return 3;
|
}
|
if (SesameStatusEnum.Sesame_5.getCode().equals(zhima)) {
|
return 3;
|
}
|
}
|
return 4;
|
}
|
|
public static void main(String[] args) {
|
Customer customer = new Customer();
|
customer.setCarStatus(1);
|
CustomerCompareDto parse = CustomerCompareDto.parse(customer);
|
System.out.println(parse.isCarStatus() ? 1 : 2);
|
}
|
}
|