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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
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);
    }
}