Air
2024-11-04 cb3b3801255082c53145bd752230339eae5d3e5a
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
package com.nova.sankuai.domain.api.huizhixin;
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.nova.sankuai.domain.api.huizhixin.vo.LoanBeforeVo;
import com.nova.sankuai.domain.api.huizhixin.vo.LoanVo;
import com.nova.sankuai.domain.entity.Customer;
import com.nova.sankuai.domain.enums.ProfessionInfoEnum;
import com.nova.sankuai.domain.enums.customerinfo.*;
import com.nova.sankuai.domain.enums.huizhixin.*;
import com.nova.sankuai.domain.enums.yixin.YiXinCompanyNatureEnum;
import com.nova.sankuai.domain.enums.yixin.YiXinJobTitleEnum;
import com.nova.sankuai.domain.enums.yixin.YiXinOccupationEnum;
import com.nova.sankuai.infra.utils.RsaSecretUtils;
import com.nova.sankuai.security.HttpClientUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.http.util.TextUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
 
import java.nio.charset.StandardCharsets;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
 
/**
 * 汇智信工具类
 */
@Component
@Slf4j
public class HzxUtil {
 
    /**
     * 对方公钥base64
     */
    @Value("${hzx.other.public}")
    private String publicKeyBase64;
 
    /**
     * 己方私钥base64
     */
    @Value("${hzx.self.private}")
    private String privateKeyBase64;
 
    /**
     * 产品号
     */
    @Value("${hzx.product_cid}")
    private String productCid;
 
 
    /**
     * 回调域名
     */
    @Value("${hzx.callBackDomain}")
    private String callBackDomain;
 
    private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
 
    /**
     * 请求地址
     */
    @Value("${hzx.url}")
    private String url;
 
    private static final Logger logger = LoggerFactory.getLogger("capitalLogger");
 
    private final RsaSecretUtils rsaSecretUtils;
 
    public HzxUtil(RsaSecretUtils rsaSecretUtils) {
        this.rsaSecretUtils = rsaSecretUtils;
    }
 
    /**
     * 前置检测接口
     *
     * @param id    身份证号
     * @param phone 手机号
     * @param name  姓名
     * @return
     */
    public HzxResponse<HzxResponseData> checkUser(String id, String phone, String name) {
        // 请求体
        Map<String, Object> body = new HashMap<>(16);
        // 原始参数
        Map<String, Object> param = new HashMap<>(16);
        param.put("f", "check_user");
        param.put("id", id);
        param.put("phone", phone);
        param.put("name", name);
        String response = "";
        try {
            logger.info("前置检测接口参数->:{}", param);
            // 使用对方公钥加密后的字节数组
            byte[] encryptByte = RsaSecretUtils.publicEncrypt(OBJECT_MAPPER.writeValueAsString(param).getBytes(StandardCharsets.UTF_8), publicKeyBase64);
            // 使用己方私钥加签
            String signStr = RsaSecretUtils.rsaSign(encryptByte, privateKeyBase64);
            logger.info("前置检测接口加密参数->:{}", encryptByte);
            logger.info("前置检测接口加签->:{}", signStr);
            body.put("content", RsaSecretUtils.byte2Base64(encryptByte));
            body.put("sign", signStr);
            response = HttpClientUtil.getInstance().postJsonData(url + "/check_user", OBJECT_MAPPER.writeValueAsString(body));
            logger.info("前置检测接口加密返回->:{}", response);
        } catch (Exception e) {
            logger.error("前置检测接口加密返回失败->:{}", response);
            e.printStackTrace();
            return null;
        }
        if (StringUtils.isEmpty(response)) {
            logger.error("前置检测接口加密返回数据失败");
            return null;
        }
        JSONObject jsonObject = null;
        try {
            jsonObject = JSONObject.parseObject(response);
            logger.info("前置检测接口加密返回转换返回:{}", jsonObject);
        } catch (Exception e) {
            logger.error("前置检测接口加密返回转换json失败->:{}", jsonObject);
            e.printStackTrace();
            return null;
        }
        // 验签
        boolean signPass = RsaSecretUtils.rsaSignCheck(Base64Utils.decode(jsonObject.getString("content")), Base64Utils.decode(jsonObject.getString("sign")), publicKeyBase64);
        logger.info("前置检测验签:{}", signPass);
        if (signPass == false) {
            logger.info("前置检测接口验签失败");
            return null;
        }
        String data = "";
        HzxResponse<HzxResponseData> hzxResponse = null;
        try {
            data = new String(RsaSecretUtils.privateDecrypt(Base64Utils.decode(jsonObject.getString("content")), privateKeyBase64));
            logger.info("汇智信原始返回数据:{}", data);
            hzxResponse = JSON.parseObject(data, new TypeReference<HzxResponse<HzxResponseData>>() {
            });
        } catch (Exception e) {
            logger.error("前置检测接口加密返回验签解签失败->:{}", data);
            e.printStackTrace();
            return null;
        }
        return hzxResponse;
    }
 
    /**
     * 进件申请
     *
     * @param applyId 订单号,36位字符
     * @return
     */
    public HzxResponse apply(String applyId) {
        // 请求体
        Map<String, Object> body = new HashMap<>(16);
        // 原始参数
        Map<String, Object> param = new HashMap<>(16);
        param.put("f", "apply");
        param.put("apply_id", applyId);
        param.put("product_cid", productCid + ";" + callBackDomain);
 
        String response = "";
        try {
            logger.info("进件申请接口参数->:{}", param);
            // 使用对方公钥加密后的字节数组
            byte[] encryptByte = RsaSecretUtils.publicEncrypt(OBJECT_MAPPER.writeValueAsString(param).getBytes(StandardCharsets.UTF_8), publicKeyBase64);
            // 使用己方私钥加签
            String signStr = RsaSecretUtils.rsaSign(encryptByte, privateKeyBase64);
            logger.info("进件申请接口加密参数->:{}", encryptByte);
            logger.info("进件申请接口加签->:{}", signStr);
            body.put("content", RsaSecretUtils.byte2Base64(encryptByte));
            body.put("sign", signStr);
            response = HttpClientUtil.getInstance().postJsonData(url + "/apply", OBJECT_MAPPER.writeValueAsString(body));
            logger.info("进件申请接口加密返回->:{}", response);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
        if (StringUtils.isEmpty(response)) {
            logger.error("进件申请接口加密返回数据失败");
            return null;
        }
        JSONObject jsonObject = null;
        try {
            jsonObject = JSONObject.parseObject(response);
        } catch (Exception e) {
            logger.error("进件申请接口加密返回转换json失败->:{}", jsonObject);
            e.printStackTrace();
            return null;
        }
        // 验签
        boolean signPass = RsaSecretUtils.rsaSignCheck(Base64Utils.decode(jsonObject.getString("content")), Base64Utils.decode(jsonObject.getString("sign")), publicKeyBase64);
        logger.info("进件申请验签:{}", signPass);
        if (signPass == false) {
            logger.info("进件申请接口验签失败");
            return null;
        }
        HzxResponse hzxResponse = null;
        String data = null;
        try {
            data = new String(RsaSecretUtils.privateDecrypt(Base64Utils.decode(jsonObject.getString("content")), privateKeyBase64));
            hzxResponse = JSON.parseObject(data, HzxResponse.class);
        } catch (Exception e) {
            logger.error("进件申请接口加密返回验签解签失败失败->:{}", hzxResponse);
            e.printStackTrace();
            return null;
        }
        return hzxResponse;
    }
 
    /**
     * 获取订单信息接口
     *
     * @param productCid 产品号
     * @param applyId    订单号
     * @param time       时间
     * @return
     */
    public HzxResponse loadApplyExtInfo(String productCid, String applyId, String time) {
        // 请求体
        Map<String, Object> body = new HashMap<>(16);
        // 原始参数
        Map<String, Object> param = new HashMap<>(16);
        param.put("f", "load_apply_ext_info");
        param.put("product_cid", productCid);
        param.put("apply_id", applyId);
        param.put("time", new Date());
        try {
            logger.info("获取订单信息接口参数->:{}", param);
            // 使用对方公钥加密后的字节数组
            byte[] encryptByte = RsaSecretUtils.publicEncrypt(OBJECT_MAPPER.writeValueAsString(param).getBytes(StandardCharsets.UTF_8), publicKeyBase64);
            // 使用己方私钥加签
            String signStr = RsaSecretUtils.rsaSign(encryptByte, privateKeyBase64);
            logger.info("获取订单信息接口加密参数->:{}", encryptByte);
            logger.info("获取订单信息接口加签->:{}", signStr);
            body.put("content", RsaSecretUtils.byte2Base64(encryptByte));
            body.put("sign", signStr);
 
            String response = HttpClientUtil.getInstance().postJsonData(url + "/load_apply_ext_info", OBJECT_MAPPER.writeValueAsString(body));
            logger.info("获取订单信息接口加密返回->:{}", response);
            if (!TextUtils.isEmpty(response)) {
                JSONObject jsonObject = JSONObject.parseObject(response);
                // 返回签名
                String sign = jsonObject.getString("sign");
                // 验签
                boolean signPass = RsaSecretUtils.rsaSignCheck(Base64Utils.decode(jsonObject.getString("content")), Base64Utils.decode(jsonObject.getString("sign")), publicKeyBase64);
                String data = new String(RsaSecretUtils.privateDecrypt(Base64Utils.decode(jsonObject.getString("content")), privateKeyBase64));
                System.out.println(data);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
 
    /**
     * 参数解密、验签
     *
     * @param encodeData 密文
     * @param signString 加签
     * @return
     */
    public String paramDecode(String encodeData, String signString) {
        logger.info("密文->:{}", encodeData);
        try {
            // 使用己方私钥解密
            byte[] decryptBytes = RsaSecretUtils.privateDecrypt(encodeData.getBytes(StandardCharsets.UTF_8), this.privateKeyBase64);
            // 使用对方公钥验签
            boolean result = RsaSecretUtils.rsaSignCheck(Base64Utils.decode(encodeData), Base64Utils.decode(signString), this.publicKeyBase64);
            if (result) {
                return new String(decryptBytes);
            }
        } catch (Exception e) {
            return null;
        }
        return null;
    }
 
    /**
     * 获取合作方其他 url
     *
     * @param apply_id   订单号
     * @param return_url 操作成功之后的回调地址
     * @return
     */
    public HzxGetResponse getPartnerUrl(String apply_id, String return_url) {
        // 请求体
        Map<String, Object> body = new HashMap<>(16);
        // 原始参数
        Map<String, Object> param = new HashMap<>(16);
        param.put("f", "get_partner_url");
        param.put("apply_id", apply_id);
        param.put("return_url", return_url);
        String response = "";
        try {
            logger.info("获取合作方其他 url接口参数->:{}", param);
            // 使用对方公钥加密后的字节数组
            byte[] encryptByte = RsaSecretUtils.publicEncrypt(OBJECT_MAPPER.writeValueAsString(param).getBytes(StandardCharsets.UTF_8), publicKeyBase64);
            // 使用己方私钥加签
            String signStr = RsaSecretUtils.rsaSign(encryptByte, privateKeyBase64);
            logger.info("获取合作方其他url加密参数->:{}", encryptByte);
            logger.info("获取合作方其他url加签->:{}", signStr);
            body.put("content", RsaSecretUtils.byte2Base64(encryptByte));
            body.put("sign", signStr);
            response = HttpClientUtil.getInstance().postJsonData(url + "/get_partner_url", OBJECT_MAPPER.writeValueAsString(body));
            logger.info("获取合作方其他url加密返回->:{}", response);
        } catch (Exception e) {
            logger.error("获取合作方其他url加密返回失败->:{}", response);
            e.printStackTrace();
            return null;
        }
        if (StringUtils.isEmpty(response)) {
            logger.error("获取合作方接口加密返回数据失败");
            return null;
        }
        JSONObject jsonObject = null;
        try {
            jsonObject = JSONObject.parseObject(response);
        } catch (Exception e) {
            logger.error("获取合作方其他url加密返回转换json失败->:{}", jsonObject);
            e.printStackTrace();
            return null;
        }
        // 验签
        boolean signPass = RsaSecretUtils.rsaSignCheck(Base64Utils.decode(jsonObject.getString("content")), Base64Utils.decode(jsonObject.getString("sign")), publicKeyBase64);
        logger.info("获取地址验签:{}", signPass);
        if (signPass == false) {
            logger.info("获取合作方其他url验签失败");
            return null;
        }
        String data = "";
        HzxGetResponse hzxResponse = null;
        try {
            data = new String(RsaSecretUtils.privateDecrypt(Base64Utils.decode(jsonObject.getString("content")), privateKeyBase64));
            logger.info("获取下载链接地址:{}", data);
            hzxResponse = JSON.parseObject(data, HzxGetResponse.class);
            logger.info("获取下载链接地址转化:{}", hzxResponse.toString());
        } catch (Exception e) {
            logger.error("获取合作方其他url加密返回转换失败->:{}", data);
            e.printStackTrace();
            return null;
        }
        return hzxResponse;
    }
 
 
    public void educationParse(LoanBeforeVo loanBeforeVo, Customer latestCustomer) {
        if (StringUtils.isEmpty(latestCustomer.getEducation())) {
            loanBeforeVo.setEducation(LoanEducationEnum.Education_4.getCode());
        } else {
            if (EducationEnum.Education_1.getCode().equals(latestCustomer.getEducation())
                    || EducationEnum.Education_06.getCode().equals(latestCustomer.getEducation())
                    || EducationEnum.Education_07.getCode().equals(latestCustomer.getEducation())) {
                loanBeforeVo.setEducation(LoanEducationEnum.Education_1.getCode());
            } else if (EducationEnum.Education_2.getCode().equals(latestCustomer.getEducation())
                    || EducationEnum.Education_05.getCode().equals(latestCustomer.getEducation())) {
                loanBeforeVo.setEducation(LoanEducationEnum.Education_2.getCode());
            } else if (EducationEnum.Education_3.getCode().equals(latestCustomer.getEducation())
                    || EducationEnum.Education_04.getCode().equals(latestCustomer.getEducation())) {
                loanBeforeVo.setEducation(LoanEducationEnum.Education_3.getCode());
            } else {
                loanBeforeVo.setEducation(LoanEducationEnum.Education_4.getCode());
            }
        }
    }
 
    public void maritalStatusParse(LoanBeforeVo loanBeforeVo, Customer latestCustomer) {
        if (StringUtils.isEmpty(latestCustomer.getMaritalStatus())) {
            loanBeforeVo.setMarriage(LoanMarriageEnum.Marriage_1.getCode());
        } else {
            if (MaritalStatusEnum.MaritalStatus_1.getSys().equals(latestCustomer.getMaritalStatus())
                    || MaritalStatusEnum.MaritalStatus_6.getSys().equals(latestCustomer.getMaritalStatus())) {
                loanBeforeVo.setMarriage(LoanMarriageEnum.Marriage_2.getCode());
            } else if (MaritalStatusEnum.MaritalStatus_2.getSys().equals(latestCustomer.getMaritalStatus())
                    || MaritalStatusEnum.MaritalStatus_5.getSys().equals(latestCustomer.getMaritalStatus())) {
                loanBeforeVo.setMarriage(LoanMarriageEnum.Marriage_1.getCode());
            } else if (MaritalStatusEnum.MaritalStatus_3.getSys().equals(latestCustomer.getMaritalStatus())
                    || MaritalStatusEnum.MaritalStatus_7.getSys().equals(latestCustomer.getMaritalStatus())) {
                loanBeforeVo.setMarriage(LoanMarriageEnum.Marriage_3.getCode());
            } else {
                loanBeforeVo.setMarriage(LoanMarriageEnum.Marriage_4.getCode());
            }
        }
    }
 
    public void industryParse(LoanBeforeVo loanBeforeVo, Customer latestCustomer) {
        if (latestCustomer.getProfessionInfo() == null) {
            loanBeforeVo.setIndustry(LoanIndustryEnum.Industry_17.getCode());
        } else {
            if (ProfessionInfoEnum.OFFICE_WORKER.getCode().equals(latestCustomer.getProfessionInfo().toString())) {
                loanBeforeVo.setIndustry(LoanIndustryEnum.Industry_18.getCode());
            } else if (ProfessionInfoEnum.FREELANCE.getCode().equals(latestCustomer.getProfessionInfo().toString())) {
                loanBeforeVo.setIndustry(LoanIndustryEnum.Industry_17.getCode());
            } else if (ProfessionInfoEnum.BUSINESS_OWNERS.getCode().equals(latestCustomer.getProfessionInfo().toString())
                    || ProfessionInfoEnum.SELF_EMPLOYED.getCode().equals(latestCustomer.getProfessionInfo().toString())) {
                loanBeforeVo.setIndustry(LoanIndustryEnum.Industry_16.getCode());
            } else if (ProfessionInfoEnum.CIVIL_SERVANTS.getCode().equals(latestCustomer.getProfessionInfo().toString())) {
                loanBeforeVo.setIndustry(LoanIndustryEnum.Industry_1.getCode());
            } else {
                loanBeforeVo.setIndustry(LoanIndustryEnum.Industry_18.getCode());
            }
        }
    }
 
    public void positionParse(LoanBeforeVo loanBeforeVo, Customer latestCustomer) {
        if (StringUtils.isEmpty(latestCustomer.getJobTitle())) {
            loanBeforeVo.setPosition(LoanPositionEnum.Position_1.getCode());
        } else {
            if (YiXinJobTitleEnum.SENIOR_LEADER.getCode().equals(latestCustomer.getJobTitle())) {
                loanBeforeVo.setPosition(LoanPositionEnum.Position_4.getCode());
            } else if (YiXinJobTitleEnum.MID_LEADER.getCode().equals(latestCustomer.getJobTitle())) {
                loanBeforeVo.setPosition(LoanPositionEnum.Position_2.getCode());
            } else {
                loanBeforeVo.setPosition(LoanPositionEnum.Position_1.getCode());
            }
        }
    }
 
    public void monthlySalaryParse(LoanBeforeVo loanBeforeVo, Customer latestCustomer) {
        if (latestCustomer.getMonthlyIncome() == null) {
            loanBeforeVo.setMonthlySalary(LoanMonthlySalaryEnum.MonthlySalary_1.getCode());
        } else {
            if (MonthlyIncomeEnum.INCOME_3Q_UNDER.getCode().equals(latestCustomer.getMonthlyIncome())) {
                loanBeforeVo.setMonthlySalary(LoanMonthlySalaryEnum.MonthlySalary_1.getCode());
            } else if (MonthlyIncomeEnum.Income_3Q_6Q.getCode().equals(latestCustomer.getMonthlyIncome())) {
                loanBeforeVo.setMonthlySalary(LoanMonthlySalaryEnum.MonthlySalary_2.getCode());
            } else if (MonthlyIncomeEnum.Income_6Q_1W.getCode().equals(latestCustomer.getMonthlyIncome())) {
                loanBeforeVo.setMonthlySalary(LoanMonthlySalaryEnum.MonthlySalary_3.getCode());
            } else if (MonthlyIncomeEnum.Income_1W_3W.getCode().equals(latestCustomer.getMonthlyIncome())) {
                loanBeforeVo.setMonthlySalary(LoanMonthlySalaryEnum.MonthlySalary_6.getCode());
            } else {
                loanBeforeVo.setMonthlySalary(LoanMonthlySalaryEnum.MonthlySalary_7.getCode());
            }
        }
    }
 
    public void loanPurposeParse(LoanBeforeVo loanBeforeVo, Customer latestCustomer) {
        if (StringUtils.isEmpty(latestCustomer.getUseOfLoan())) {
            loanBeforeVo.setLoanPurpose(LoanPurposeEnum.Purpose_6.getCode());
        } else {
            if (UseOfLoanEnum.Loan_1.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_3.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_5.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_6.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_9.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_11.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_12.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_13.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_15.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_17.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_18.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_19.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_20.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_21.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_22.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_23.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_24.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_25.getCode().equals(latestCustomer.getUseOfLoan())) {
                loanBeforeVo.setLoanPurpose(LoanPurposeEnum.Purpose_6.getCode());
            } else if (UseOfLoanEnum.Loan_2.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_7.getCode().equals(latestCustomer.getUseOfLoan())) {
                loanBeforeVo.setLoanPurpose(LoanPurposeEnum.Purpose_4.getCode());
            } else if (UseOfLoanEnum.Loan_4.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_16.getCode().equals(latestCustomer.getUseOfLoan())) {
                loanBeforeVo.setLoanPurpose(LoanPurposeEnum.Purpose_1.getCode());
            } else if (UseOfLoanEnum.Loan_8.getCode().equals(latestCustomer.getUseOfLoan())) {
                loanBeforeVo.setLoanPurpose(LoanPurposeEnum.Purpose_2.getCode());
            } else if (UseOfLoanEnum.Loan_10.getCode().equals(latestCustomer.getUseOfLoan())) {
                loanBeforeVo.setLoanPurpose(LoanPurposeEnum.Purpose_5.getCode());
            } else if (UseOfLoanEnum.Loan_14.getCode().equals(latestCustomer.getUseOfLoan())) {
                loanBeforeVo.setLoanPurpose(LoanPurposeEnum.Purpose_3.getCode());
            } else {
                loanBeforeVo.setLoanPurpose(LoanPurposeEnum.Purpose_6.getCode());
            }
        }
    }
 
    public void relationshipParse(LoanBeforeVo loanBeforeVo, Customer latestCustomer) {
        if (!StringUtils.isEmpty(latestCustomer.getRelationship())) {
            if (RelationshipEnum.Relationship_1.getCode().equals(latestCustomer.getRelationship())
                    || RelationshipEnum.Relationship_4.getCode().equals(latestCustomer.getRelationship())) {
                loanBeforeVo.setFirstContactRelation(LoanFirstContactEnum.FirstContact_2.getCode());
            } else if (RelationshipEnum.Relationship_3.getCode().equals(latestCustomer.getRelationship())) {
                loanBeforeVo.setFirstContactRelation(LoanFirstContactEnum.FirstContact_1.getCode());
            } else {
                loanBeforeVo.setFirstContactRelation(LoanFirstContactEnum.FirstContact_2.getCode());
            }
        } else {
            loanBeforeVo.setFirstContactRelation(LoanFirstContactEnum.FirstContact_1.getCode());
        }
    }
 
    public void secondContactParse(LoanBeforeVo loanBeforeVo, Customer latestCustomer) {
        if (!StringUtils.isEmpty(latestCustomer.getContactRelation())) {
            if (RelationshipEnum.Relationship_8.getCode().equals(latestCustomer.getRelationship())) {
                loanBeforeVo.setSecondContactRelation(LoanSecondContactEnum.SecondContact_1.getCode());
            } else if (RelationshipEnum.Relationship_7.getCode().equals(latestCustomer.getRelationship())) {
                loanBeforeVo.setSecondContactRelation(LoanSecondContactEnum.SecondContact_4.getCode());
            } else if (RelationshipEnum.Relationship_9.getCode().equals(latestCustomer.getRelationship())) {
                loanBeforeVo.setSecondContactRelation(LoanSecondContactEnum.SecondContact_2.getCode());
            } else {
                loanBeforeVo.setSecondContactRelation(LoanSecondContactEnum.SecondContact_4.getCode());
            }
        } else {
            loanBeforeVo.setSecondContactRelation(LoanSecondContactEnum.SecondContact_4.getCode());
        }
    }
 
    public void houseSituationParse(LoanVo loanVo, Customer latestCustomer) {
        if (latestCustomer.getHouseStatus() != null) {
            if (HouseStatusEnum.House_1.getCode().equals(latestCustomer.getHouseStatus())) {
                loanVo.setHouseSituation(LoanHouseSituationEnum.HouseSituation_1.getCode());
            } else if (HouseStatusEnum.House_2.getCode().equals(latestCustomer.getHouseStatus())) {
                loanVo.setHouseSituation(LoanHouseSituationEnum.HouseSituation_4.getCode());
            } else if (HouseStatusEnum.House_3.getCode().equals(latestCustomer.getHouseStatus())) {
                loanVo.setHouseSituation(LoanHouseSituationEnum.HouseSituation_6.getCode());
            } else {
                loanVo.setHouseSituation(LoanHouseSituationEnum.HouseSituation_5.getCode());
            }
        } else {
            loanVo.setHouseSituation(LoanHouseSituationEnum.HouseSituation_7.getCode());
        }
    }
 
    public void loanOccupationParse(LoanVo loanVo, Customer latestCustomer) {
        if (!StringUtils.isEmpty(latestCustomer.getOccupation())) {
            if (YiXinOccupationEnum.PUBLIC.getCode().equals(latestCustomer.getOccupation())) {
                loanVo.setOccupation(LoanOccupationEnum.Occupation_1.getCode());
            } else if (YiXinOccupationEnum.PROFESSIONAL.getCode().equals(latestCustomer.getOccupation())) {
                loanVo.setOccupation(LoanOccupationEnum.Occupation_2.getCode());
            } else if (YiXinOccupationEnum.OFFICE.getCode().equals(latestCustomer.getOccupation())) {
                loanVo.setOccupation(LoanOccupationEnum.Occupation_3.getCode());
            } else if (YiXinOccupationEnum.SERVICE.getCode().equals(latestCustomer.getOccupation())) {
                loanVo.setOccupation(LoanOccupationEnum.Occupation_4.getCode());
            } else if (YiXinOccupationEnum.CONSERVANCY.getCode().equals(latestCustomer.getOccupation())) {
                loanVo.setOccupation(LoanOccupationEnum.Occupation_5.getCode());
            } else if (YiXinOccupationEnum.HARD_CLASSIFY.getCode().equals(latestCustomer.getOccupation())) {
                loanVo.setOccupation(LoanOccupationEnum.Occupation_8.getCode());
            } else if (YiXinOccupationEnum.SOLDIER.getCode().equals(latestCustomer.getOccupation())) {
                loanVo.setOccupation(LoanOccupationEnum.Occupation_7.getCode());
            } else if (YiXinOccupationEnum.TRANSPORTATION.getCode().equals(latestCustomer.getOccupation())) {
                loanVo.setOccupation(LoanOccupationEnum.Occupation_6.getCode());
            } else if (YiXinOccupationEnum.UNKNOWN.getCode().equals(latestCustomer.getOccupation())) {
                loanVo.setOccupation(LoanOccupationEnum.Occupation_9.getCode());
            } else {
                loanVo.setOccupation(LoanOccupationEnum.Occupation_9.getCode());
            }
        } else {
            loanVo.setOccupation(LoanOccupationEnum.Occupation_9.getCode());
        }
    }
 
    public void positionDutyParse(LoanVo loanVo, Customer latestCustomer) {
        if (!StringUtils.isEmpty(latestCustomer.getJobTitle())) {
            if (YiXinJobTitleEnum.SENIOR_LEADER.getCode().equals(latestCustomer.getJobTitle())) {
                loanVo.setPositionDuty(LoanPositonDutyEnum.PositonDuty_4.getCode());
            } else if (YiXinJobTitleEnum.MID_LEADER.getCode().equals(latestCustomer.getJobTitle())) {
                loanVo.setPositionDuty(LoanPositonDutyEnum.PositonDuty_1.getCode());
            } else {
                loanVo.setPositionDuty(LoanPositonDutyEnum.PositonDuty_7.getCode());
            }
        } else {
            loanVo.setPositionDuty(LoanPositonDutyEnum.PositonDuty_7.getCode());
        }
    }
 
    public void companyTypeParse(LoanVo loanVo, Customer latestCustomer) {
        if (!StringUtils.isEmpty(latestCustomer.getCompanyNature())) {
            if (YiXinCompanyNatureEnum.Nature_1.getCode().equals(latestCustomer.getCompanyNature())) {
                loanVo.setCompanyType(LoanCompanyNatureEnum.CompanyNature_1.getCode());
            } else if (YiXinCompanyNatureEnum.Nature_2.getCode().equals(latestCustomer.getCompanyNature())) {
                loanVo.setCompanyType(LoanCompanyNatureEnum.CompanyNature_3.getCode());
            } else if (YiXinCompanyNatureEnum.Nature_3.getCode().equals(latestCustomer.getCompanyNature())) {
                loanVo.setCompanyType(LoanCompanyNatureEnum.CompanyNature_5.getCode());
            } else if (YiXinCompanyNatureEnum.Nature_4.getCode().equals(latestCustomer.getCompanyNature())) {
                loanVo.setCompanyType(LoanCompanyNatureEnum.CompanyNature_7.getCode());
            } else if (YiXinCompanyNatureEnum.Nature_5.getCode().equals(latestCustomer.getCompanyNature())) {
                loanVo.setCompanyType(LoanCompanyNatureEnum.CompanyNature_11.getCode());
            } else {
                loanVo.setCompanyType(LoanCompanyNatureEnum.CompanyNature_11.getCode());
            }
        } else {
            loanVo.setCompanyType(LoanCompanyNatureEnum.CompanyNature_11.getCode());
        }
    }
 
    public void pullLoanPurposeParse(LoanVo loanVo, Customer latestCustomer) {
        if (StringUtils.isEmpty(latestCustomer.getUseOfLoan())) {
            loanVo.setLoanPurpose(LoanPurposeEnum.Purpose_6.getCode());
        } else {
            if (UseOfLoanEnum.Loan_1.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_3.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_5.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_6.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_9.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_11.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_12.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_13.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_15.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_17.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_18.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_19.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_20.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_21.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_22.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_23.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_24.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_25.getCode().equals(latestCustomer.getUseOfLoan())) {
                loanVo.setLoanPurpose(LoanPurposeEnum.Purpose_6.getCode());
            } else if (UseOfLoanEnum.Loan_2.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_7.getCode().equals(latestCustomer.getUseOfLoan())) {
                loanVo.setLoanPurpose(LoanPurposeEnum.Purpose_4.getCode());
            } else if (UseOfLoanEnum.Loan_4.getCode().equals(latestCustomer.getUseOfLoan())
                    || UseOfLoanEnum.Loan_16.getCode().equals(latestCustomer.getUseOfLoan())) {
                loanVo.setLoanPurpose(LoanPurposeEnum.Purpose_1.getCode());
            } else if (UseOfLoanEnum.Loan_8.getCode().equals(latestCustomer.getUseOfLoan())) {
                loanVo.setLoanPurpose(LoanPurposeEnum.Purpose_2.getCode());
            } else if (UseOfLoanEnum.Loan_10.getCode().equals(latestCustomer.getUseOfLoan())) {
                loanVo.setLoanPurpose(LoanPurposeEnum.Purpose_5.getCode());
            } else if (UseOfLoanEnum.Loan_14.getCode().equals(latestCustomer.getUseOfLoan())) {
                loanVo.setLoanPurpose(LoanPurposeEnum.Purpose_3.getCode());
            } else {
                loanVo.setLoanPurpose(LoanPurposeEnum.Purpose_6.getCode());
            }
        }
    }
 
}