Air
2024-11-04 a1f06d31b7b4cac569c34bdfbb68de77f2858ffe
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
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
package com.nova.sankuai.domain.api.yixin;
 
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSON;
import com.nova.sankuai.domain.api.yixin.dto.*;
import com.nova.sankuai.domain.api.yixin.response.*;
import com.nova.sankuai.domain.api.yixin.vo.RepayVo;
import com.nova.sankuai.domain.entity.Customer;
import com.nova.sankuai.domain.enums.capitalInfo.CapitalInfoTypeCodeEnum;
import com.nova.sankuai.domain.enums.customerinfo.*;
import com.nova.sankuai.domain.enums.yixin.YiXinFriendRelationEnum;
import com.nova.sankuai.domain.enums.yixin.YiXinHomeRelationEnum;
import com.nova.sankuai.domain.enums.yixin.YiXinLivestEnum;
import com.nova.sankuai.security.HttpClientUtil;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang.StringUtils;
import org.apache.http.util.TextUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
 
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.*;
 
/**
 * 绿地对接
 */
@Component
public class YXUtil {
 
    @ApiModelProperty(value = "资金方-宜信")
    public static final String FUNDING_YIXIN = "YIXIN";
    @ApiModelProperty(value = "资金方-小花钱包")
    public static final String FUNDING_XHQB = "XHQB";
    @ApiModelProperty(value = "资金方-洋钱罐对接")
    public static final String FUNDING_JQTX = "JQTX";
    @ApiModelProperty(value = "资金方-普融花")
    public static final String FUNDING_PRH = "JUNHANG";
 
    @Value("${yixin.path}")
    private String yxPath;
 
    @Value("${tengxunyun.suyihua.appId}")
    private String syhAppId;
 
    @Value("${tengxunyun.suyihua.secret}")
    private String syhSecret;
 
    @Value("${yixin.publickey}")
    private String yxPubKey;
 
    @Value("${tengxunyun.jieyidai.appId}")
    private String jydAppId;
 
    @Value("${tengxunyun.jieyidai.secret}")
    private String jydSecret;
 
    @Value("${tengxunyun.sankuaifenqi.appId}")
    private String skAppId;
 
    @Value("${tengxunyun.sankuaifenqi.secret}")
    private String skSecret;
 
    @Value("${tengxunyun.jixianghua.appId}")
    private String jxhAppId;
 
    @Value("${tengxunyun.jixianghua.secret}")
    private String jxhSecret;
 
    @Value("${tengxunyun.weixianghua.appId}")
    private String wxhAppId;
 
    @Value("${tengxunyun.weixianghua.secret}")
    private String wxhSecret;
 
    @Value("${tengxunyun.kadana.appId}")
    private String kdnAppId;
 
    @Value("${tengxunyun.kadana.secret}")
    private String kdnSecret;
 
    @Value("${tengxunyun.jxd.appId}")
    private String jxdAppId;
 
    @Value("${tengxunyun.jxd.secret}")
    private String jxdSecret;
 
    public String getSerialNo() {
        UUID uuid = UUID.randomUUID();
        String serialNo = uuid.toString().replace("-", "");
        return serialNo;
    }
 
    public String createRepayApplyNo() {
        long nextId = IdUtil.getSnowflake().nextId();
        String serialNo = "XD_LD_" + YXSignUtil.reqSysCode + "_" + nextId;
        return serialNo;
    }
 
    public String getFunding(String code) {
        String funding;
        if (CapitalInfoTypeCodeEnum.XIAO_HUA_QIAN_BAO.getCode().equals(code)) {
            funding = YXUtil.FUNDING_XHQB;
        } else if (CapitalInfoTypeCodeEnum.JIN_QIAN_TIAN_XIA.getCode().equals(code)) {
            funding = YXUtil.FUNDING_JQTX;
        } else if (CapitalInfoTypeCodeEnum.PU_RONG_HUA.getCode().equals(code)) {
            funding = YXUtil.FUNDING_PRH;
        } else {
            funding = YXUtil.FUNDING_YIXIN;
        }
        return funding;
    }
 
    /**
     * 2.4.7.还款结果查询接口
     *
     * @param funding   资金方代码
     * @param logNumber 日志编号
     * @param logger    日志对象
     */
    public YxRepaymentResultResponse yxRepaymentResult(YxRepaymentResultDto dto,
                                                       String funding, Logger logger, String logNumber) {
        String url = "/flow/repaymentResult";
        Map<String, Object> param = new HashMap<>(16);
        param.put("userId", dto.getUserId());
        param.put("repayApplyNo", dto.getRepayApplyNo());
        try {
            logger.info("日志编号:" + logNumber + "还款结果查询接口参数 -> {}", param);
            String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
//            logger.info("日志编号:" + logNumber + "还款结果查询接口加密参数 -> {}", paramStr);
            String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + url, paramStr);
//            logger.info("日志编号:" + logNumber + "还款结果查询接口加密返回 -> {}", yxResult);
            if (!TextUtils.isEmpty(yxResult)) {
                Map<String, String> map = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
                logger.info("日志编号:" + logNumber + "还款结果查询接口加密返回 -> {}", map);
                if (!TextUtils.isEmpty(map.get("params"))) {
                    return JSON.parseObject(map.get("params"), YxRepaymentResultResponse.class);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
 
    /**
     * 2.3.1 支持银行列表查询接口
     *
     * @param funding   资金方代码
     * @param logNumber 日志编号
     * @param logger    日志对象
     */
    public YxGetUsableBankListResponse yxGetUsableBankList(Long userId,
                                                           String funding, Logger logger, String logNumber) {
        String url = "/flow/getUsableBankList";
        Map<String, Object> param = new HashMap<>(16);
        param.put("userId", userId);
        try {
            logger.info("日志编号:" + logNumber + "支持银行列表查询接口参数 -> {}", param);
            String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
//            logger.info("日志编号:" + logNumber + "支持银行列表查询接口加密参数 -> {}", paramStr);
            String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + url, paramStr);
//            logger.info("日志编号:" + logNumber + "支持银行列表查询接口加密返回 -> {}", yxResult);
            if (!TextUtils.isEmpty(yxResult)) {
                Map<String, String> map = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
                logger.info("日志编号:" + logNumber + "支持银行列表查询接口加密返回 -> {}", map);
                if (!TextUtils.isEmpty(map.get("params"))) {
                    return JSON.parseObject(map.get("params"), YxGetUsableBankListResponse.class);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
 
    /**
     * 2.3.1 绑卡获取验证码参数
     *
     * @param logger    日志对象
     * @param logNumber 日志编号
     * @param dto       绑卡获取验证码参数Dto
     * @param funding   资金方代码
     */
    public YxBindBankSmsResponse yxBindBankSms(YxBindBankSmsDto dto,
                                               String funding, Logger logger, String logNumber) {
        String url = "/flow/getBindBankSMS";
        Map<String, Object> param = new HashMap<>(16);
        param.put("serialNo", dto.getSerialNo());
        param.put("fundCode", funding);
        param.put("scene", dto.getScene());
        param.put("loanNo", dto.getLoanNo());
        param.put("creditNo", dto.getCreditNo());
        param.put("idNo", dto.getIdNo());
        param.put("custName", dto.getCustName());
        param.put("phoneNo", dto.getPhoneNo());
        param.put("userId", dto.getUserId());
        param.put("custName", dto.getCustName());
        param.put("bankCardNum", dto.getBankCardNum());
        param.put("bankCode", dto.getBankCode());
 
        try {
            logger.info("日志编号:" + logNumber + "绑卡获取验证码接口参数 -> {}", param);
            String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
//            logger.info("日志编号:" + logNumber + "绑卡获取验证码加密参数 -> {}", paramStr);
            String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + url, paramStr);
//            logger.info("日志编号:" + logNumber + "绑卡获取验证码加密返回 -> {}", yxResult);
            if (!TextUtils.isEmpty(yxResult)) {
                Map<String, String> map = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
                logger.info("日志编号:" + logNumber + "绑卡获取验证码加密返回 -> {}", map);
                if (!TextUtils.isEmpty(map.get("params"))) {
                    return JSON.parseObject(map.get("params"), YxBindBankSmsResponse.class);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
 
    /**
     * 2.3.2 绑卡验证码提交
     *
     * @param funding   资金方代码
     * @param dto       绑卡验证码提交参数Dto
     * @param logger    日志对象
     * @param logNumber 日志编号
     */
    public YxBindBankSubmitResponse yxVerifyBindBankSMS(YxBindBankSubmitDto dto,
                                                        String funding, Logger logger, String logNumber) {
        String url = "/flow/verifyBindBankSMS";
        Map<String, Object> param = new HashMap<>(16);
        param.put("serialNo", dto.getSerialNo());
        param.put("fundCode", funding);
        param.put("scene", dto.getScene());
        param.put("loanNo", dto.getLoanNo());
        param.put("creditNo", dto.getCreditNo());
        param.put("messageNo", dto.getMessageNo());
        param.put("bankCardNum", dto.getBankCardNum());
        param.put("verifyCode", dto.getVerifyCode());
 
        try {
            logger.info("日志编号:" + logNumber + "绑卡验证码提交接口参数 -> {}", param);
            String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
//            logger.info("日志编号:" + logNumber + "绑卡验证码提交加密参数 -> {}", paramStr);
            String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + url, paramStr);
//            logger.info("日志编号:" + logNumber + "绑卡验证码提交加密返回 -> {}", yxResult);
            if (!TextUtils.isEmpty(yxResult)) {
                Map<String, String> map = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
                logger.info("日志编号:" + logNumber + "绑卡验证码提交加密返回 -> {}", map);
                if (!TextUtils.isEmpty(map.get("params"))) {
                    return JSON.parseObject(map.get("params"), YxBindBankSubmitResponse.class);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
 
    /**
     * 2.3.3 用户银行卡列表查询接口
     *
     * @param logger    日志对象
     * @param dto       用户银行卡列表查询接口
     * @param funding   资金方代码
     * @param logNumber 日志编号
     */
    public YxQueryUserBankListResponse yxQueryUserBankList(YxQueryUserBankListDto dto,
                                                           String funding, Logger logger, String logNumber) {
        String url = "/flow/queryUserBankList";
        Map<String, Object> param = new HashMap<>(16);
        param.put("userId", dto.getUserId());
        param.put("loanNo", dto.getLoanNo());
        try {
            logger.info("日志编号:" + logNumber + "用户银行卡列表查询接口参数 -> {}", param);
            String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
//            logger.info("日志编号:" + logNumber + "用户银行卡列表查询加密参数 -> {}", paramStr);
            String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + url, paramStr);
//            logger.info("日志编号:" + logNumber + "用户银行卡列表查询返回 -> {}", yxResult);
            if (!TextUtils.isEmpty(yxResult)) {
                Map<String, String> map = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
                logger.info("日志编号:" + logNumber + "用户银行卡列表查询加密返回 -> {}", map);
                if (!TextUtils.isEmpty(map.get("params"))) {
                    return JSON.parseObject(map.get("params"), YxQueryUserBankListResponse.class);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
 
    /**
     * 2.3.4 获取H5绑卡页面
     *
     * @param logNumber 日志编号
     * @param funding   资金方代码
     * @param logger    日志对象
     * @param queryDTO
     */
    public YxGetBindCardUrlResponse yxGetBindCardUrl(YxGetBindCardUrlDto queryDTO,
                                                     String funding, Logger logger, String logNumber) {
        String url = "/flow/getBindCardUrl";
        Map<String, Object> param = BeanUtil.beanToMap(queryDTO);
        try {
            logger.info("日志编号:" + logNumber + "用户银行卡列表查询接口参数 -> {}", param);
            String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
//            logger.info("日志编号:" + logNumber + "用户银行卡列表查询加密参数 -> {}", paramStr);
            String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + url, paramStr);
//            logger.info("日志编号:" + logNumber + "用户银行卡列表查询返回 -> {}", yxResult);
            if (!TextUtils.isEmpty(yxResult)) {
                Map<String, String> map = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
                logger.info("日志编号:" + logNumber + "用户银行卡列表查询加密返回 -> {}", map);
                if (!TextUtils.isEmpty(map.get("params"))) {
                    return JSON.parseObject(map.get("params"), YxGetBindCardUrlResponse.class);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
 
    /**
     * 2.1.1.MD5初筛撞库接口
     *
     * @param serialNo  流水号
     * @param idNoMd5   身份证号MD5
     * @param phoneMd5  手机号MD5
     * @param userId    用户Id
     * @param funding   资金方代码
     * @param logNumber 日志编号
     * @param logger    日志对象
     * @return
     */
    public YxApplyCheckResponse yxApplyCheckMd5(String serialNo, String idNoMd5, String phoneMd5, String userId,
                                                String funding, Logger logger, String logNumber) {
        // 请求url
        String url = "/flow/applyCheck";
        // 组装请求体
        Map<String, Object> param = new HashMap<>();
        param.put("serialNo", serialNo);
        param.put("idNoMD5", idNoMd5);
        param.put("phoneMD5", phoneMd5);
        param.put("userId", userId);
        try {
            logger.info("日志编号:" + logNumber + "MD5初筛撞库接口参数->:{}", param);
            String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
//            logger.info("日志编号:" + logNumber + "MD5初筛撞库接口加密参数->:{}", paramStr);
            String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + url, paramStr);
//            logger.info("日志编号:" + logNumber + "MD5初筛撞库接口加密返回结果->:{}", yxResult);
            if (!TextUtils.isEmpty(yxResult)) {
                Map<String, String> resultMap = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
                logger.info("日志编号:" + logNumber + "MD5初筛撞库接口加密返回resultMap->:{}", resultMap);
                if (!TextUtils.isEmpty(resultMap.get("params"))) {
                    return JSON.parseObject(resultMap.get("params"), YxApplyCheckResponse.class);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("日志编号:" + logNumber + "MD5初筛撞库接口异常->:{}", e.getMessage());
        }
        return null;
    }
 
    /**
     * 2.1.1.初筛撞库接口
     *
     * @param serialNo  流水号
     * @param name      姓名
     * @param idNo      身份证号
     * @param phone     手机号
     * @param userId    用户编号
     * @param funding   资金方代码
     * @param logger    日志对象
     * @param logNumber 日志编号
     * @return
     */
    public YxApplyCheckResponse yxApplyCheck(String serialNo, String name, String idNo, String phone, String userId,
                                             String funding, Logger logger, String logNumber) {
        // 请求url
        String url = "/flow/applyCheck";
        // 组装请求体
        Map<String, Object> param = new HashMap<>(16);
        param.put("serialNo", serialNo);
        param.put("name", name);
        param.put("idNo", idNo);
        param.put("phoneNo", phone);
        param.put("userId", userId);
        try {
            logger.info("日志编号:" + logNumber + "初筛撞库接口请求参数->:{}", param);
            String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
//            logger.info("日志编号:" + logNumber + "初筛撞库接口请求加密参数->:{}", paramStr);
            String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + url, paramStr);
//            logger.info("日志编号:" + logNumber + "初筛撞库接口加密返回结果->:{}", yxResult);
            if (!TextUtils.isEmpty(yxResult)) {
                Map<String, String> resultMap = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
                logger.info("日志编号:" + logNumber + "初筛撞库接口加密返回resultMap->:{}", resultMap);
                if (!TextUtils.isEmpty(resultMap.get("params"))) {
                    return JSON.parseObject(resultMap.get("params"), YxApplyCheckResponse.class);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("日志编号:" + logNumber + "初筛撞库接口异常->:{}", e.getMessage());
        }
        return null;
    }
 
 
    /**
     * 2.2.2.借款试算接口,用于借款前
     *
     * @param logger    日志对象
     * @param funding   资金方代码
     * @param logNumber 日志编号
     * @param trialDto  借款试算接口Dto
     */
    public YxTrialResponse yxTrial(YxTrialDto trialDto,
                                   String funding, Logger logger, String logNumber) {
        String trial = "/flow/trial";
        Map<String, Object> param = new HashMap<>();
        param.put("loanNo", trialDto.getLoanNo());
        param.put("creditNo", trialDto.getCreditNo());
        param.put("applyAmount", trialDto.getApplyAmount());
        param.put("applyTerm", trialDto.getApplyTerm());
        param.put("termType", trialDto.getTermType());
        param.put("userId", trialDto.getUserId());
        try {
            logger.info("日志编号:" + logNumber + "借款试算参数->:{}", param);
            String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
//            logger.info("日志编号:" + logNumber + "借款试算加密参数->:{}", paramStr);
            String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + trial, paramStr);
//            logger.info("日志编号:" + logNumber + "借款试算加密返回->:{}", yxResult);
            if (!TextUtils.isEmpty(yxResult)) {
                Map<String, String> resultMap = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
                logger.info("日志编号:" + logNumber + "借款试算加密返回resultMap->:{}", resultMap);
                if (!TextUtils.isEmpty(resultMap.get("params"))) {
                    return JSON.parseObject(resultMap.get("params"), YxTrialResponse.class);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
 
 
    /**
     * 2.2.3.用信信息传输接口
     *
     * @param logNumber    日志编号
     * @param funding      资金方代码
     * @param logger       日志对象
     * @param loanApplyDto 用信信息传输接口Dto
     */
    public YxLoanApplyResponse yxLoanApply(YxLoanApplyDto loanApplyDto,
                                           String funding, Logger logger, String logNumber) {
        String loanApply = "/flow/loanApply";
        Map<String, Object> param = new HashMap<>();
        param.put("loanNo", loanApplyDto.getLoanNo());
        param.put("creditNo", loanApplyDto.getCreditNo());
        param.put("applyAmount", loanApplyDto.getApplyAmount());
        param.put("applyTerm", loanApplyDto.getApplyTerm());
        param.put("termType", loanApplyDto.getTermType());
        param.put("payWay", loanApplyDto.getPayWay());
        if (StringUtils.isNotEmpty(loanApplyDto.getVerifyCode())) {
            param.put("verifyCode", loanApplyDto.getVerifyCode());
        }
        param.put("userId", loanApplyDto.getUserId());
        try {
            logger.info("日志编号:" + logNumber + "用信信息传输接口参数->:{}", param);
            String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
//            logger.info("日志编号:" + logNumber + "用信信息传输接口加密参数->:{}", paramStr);
            String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + loanApply, paramStr);
//            logger.info("日志编号:" + logNumber + "用信信息传输接口加密返回->:{}", yxResult);
            if (!TextUtils.isEmpty(yxResult)) {
                Map<String, String> resultMap = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
                logger.info("日志编号:" + logNumber + "用信信息传输接口加密返回resultMap->:{}", resultMap);
                if (!TextUtils.isEmpty(resultMap.get("params"))) {
                    return JSON.parseObject(resultMap.get("params"), YxLoanApplyResponse.class);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
 
 
    /**
     * 2.2.4.用信结果查询接口
     *
     * @param logger             日志对象
     * @param funding            资金方代码
     * @param logNumber          日志编号
     * @param loanStatusQueryDto 用信结果查询接口Dto
     */
    public YxLoanResultQueryResponse yxLoanStatusQuery(YxLoanStatusQueryDto loanStatusQueryDto,
                                                       String funding, Logger logger, String logNumber) {
        String loanStatusQuery = "/flow/loanStatusQuery";
        Map<String, Object> param = new HashMap<>();
        param.put("loanNo", loanStatusQueryDto.getLoanNo());
        try {
            logger.info("日志编号:" + logNumber + "用信结果查询接口参数->:{}", param);
            String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
//            logger.info("日志编号:" + logNumber + "用信结果查询接口加密参数->:{}", paramStr);
            String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + loanStatusQuery, paramStr);
//            logger.info("日志编号:" + logNumber + "用信结果查询接口加密返回->:{}", yxResult);
            if (!TextUtils.isEmpty(yxResult)) {
                Map<String, String> resultMap = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
                logger.info("日志编号:" + logNumber + "用信结果查询接口加密返回resultMap->:{}", resultMap);
                if (!TextUtils.isEmpty(resultMap.get("params"))) {
                    return JSON.parseObject(resultMap.get("params"), YxLoanResultQueryResponse.class);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
 
 
    /**
     * 2.4.1.还款试算接口,用于放款后
     *
     * @param logNumber 日志编号
     * @param funding   资金方代码
     * @param logger    日志对象
     * @param applyDto  还款试算接口Dto
     */
    public YxPreRepayApplyResponse yxPreRepayApply(YxPreRepayApplyDto applyDto,
                                                   String funding, Logger logger, String logNumber) {
        String getPreRepayApply = "/flow/preRepayApply";
        Map<String, Object> param = new HashMap<>();
        param.put("userId", applyDto.getUserId());
        param.put("loanNo", applyDto.getLoanNo());
        param.put("prePayType", applyDto.getPrePayType());
        param.put("term", applyDto.getTerm());
        try {
            logger.info("日志编号:" + logNumber + "还款试算参数->:{}", param);
            String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
//            logger.info("日志编号:" + logNumber + "还款试算加密参数->:{}", paramStr);
            String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + getPreRepayApply, paramStr);
//            logger.info("日志编号:" + logNumber + "还款试算加密返回->:{}", yxResult);
            if (!TextUtils.isEmpty(yxResult)) {
                Map<String, String> resultMap = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
                logger.info("日志编号:" + logNumber + "还款试算加密返回resultMap->:{}", resultMap);
                if (!TextUtils.isEmpty(resultMap.get("params"))) {
                    return JSON.parseObject(resultMap.get("params"), YxPreRepayApplyResponse.class);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
 
 
    /**
     * 2.4.2.还款计划查询接口-合作方查询资金方还款计划
     *
     * @param logger       日志对象
     * @param funding      资金方代码
     * @param logNumber    日志编号
     * @param planQueryDto 还款计划查询接口Dto
     */
    public YxRepaymentPlanQueryResponse yxRepaymentPlanQuery(YxRepaymentPlanQueryDto planQueryDto,
                                                             String funding, Logger logger, String logNumber) {
        String repaymentPlanQuery = "/flow/repaymentPlanQuery";
        Map<String, Object> param = new HashMap<>();
        param.put("userId", planQueryDto.getUserId());
        param.put("loanNo", planQueryDto.getLoanNo());
        param.put("reqSysCode", YXSignUtil.reqSysCode);
        try {
            logger.info("日志编号:" + logNumber + "还款计划查询参数->:{}", param);
            String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
//            logger.info("日志编号:" + logNumber + "还款计划查询加密参数->:{}", paramStr);
            String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + repaymentPlanQuery, paramStr);
//            logger.info("日志编号:" + logNumber + "还款计划查询加密返回->:{}", yxResult);
            if (!TextUtils.isEmpty(yxResult)) {
                Map<String, String> resultMap = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
                logger.info("日志编号:" + logNumber + "还款计划查询加密返回resultMap->:{}", resultMap);
                if (!TextUtils.isEmpty(resultMap.get("params"))) {
                    return JSON.parseObject(resultMap.get("params"), YxRepaymentPlanQueryResponse.class);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
 
    /**
     * 2.4.3.用户还款请求接口-通过接口还款
     *
     * @param logNumber         日志编号
     * @param repaymentApplyDto 用户还款请求接口Dto
     * @param funding           资金方代码
     * @param logger            日志对象
     */
    public YxRepaymentApplyResponse yxRepaymentApply(YxRepaymentApplyDto repaymentApplyDto,
                                                     String funding, Logger logger, String logNumber) {
        String repaymentApply = "/flow/repaymentApply";
        Map<String, Object> param = new HashMap<>();
        param.put("repayApplyNo", repaymentApplyDto.getRepayApplyNo());
        param.put("userId", repaymentApplyDto.getUserId());
        param.put("loanNo", repaymentApplyDto.getLoanNo());
        param.put("repayType", repaymentApplyDto.getRepayType());
        if (StringUtils.isNotEmpty(repaymentApplyDto.getAmount())) {
            param.put("amount", repaymentApplyDto.getAmount());
        }
        param.put("bankCardNo", repaymentApplyDto.getBankCardNo());
        List<Map<String, String>> repayList = new ArrayList<>();
        for (RepayVo repayVo : repaymentApplyDto.getRepayList()) {
            Map<String, String> repayParam = new HashMap<>();
            if (StringUtils.isNotEmpty(repayVo.getRepayAmt())) {
                repayParam.put("repayAmt", repayVo.getRepayAmt());
            }
            repayParam.put("repayTerm", repayVo.getRepayTerm());
            repayList.add(repayParam);
        }
        param.put("repayList", repayList);
        try {
            logger.info("日志编号:" + logNumber + "用户还款请求接口参数->:{}", param);
            String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
//            logger.info("日志编号:" + logNumber + "用户还款请求接口加密参数->:{}", paramStr);
            String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + repaymentApply, paramStr);
//            logger.info("日志编号:" + logNumber + "用户还款请求接口加密返回->:{}", yxResult);
            if (!TextUtils.isEmpty(yxResult)) {
                Map<String, String> resultMap = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
                logger.info("用户还款请求接口加密返回resultMap->:{}", resultMap);
                if (!TextUtils.isEmpty(resultMap.get("params"))) {
                    return JSON.parseObject(resultMap.get("params"), YxRepaymentApplyResponse.class);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
 
    /**
     * 2.4.4.用户还款确认接口-通过接口还款,需要验证码时使用此接口
     *
     * @param logger            日志对象
     * @param logNumber         日志编号
     * @param funding           资金方代码
     * @param repaymentApplyDto 用户还款请求接口Dto
     */
    public YxRepaymentApplyResponse yxRepaymentConfirm(YxRepaymentApplyDto repaymentApplyDto,
                                                       String funding, Logger logger, String logNumber) {
        String repaymentApply = "/flow/repaymentConfirm";
        Map<String, Object> param = new HashMap<>();
        param.put("repayApplyNo", repaymentApplyDto.getRepayApplyNo());
        param.put("userId", repaymentApplyDto.getUserId());
        param.put("loanNo", repaymentApplyDto.getLoanNo());
        param.put("repayType", repaymentApplyDto.getRepayType());
        if (StringUtils.isNotEmpty(repaymentApplyDto.getAmount())) {
            param.put("amount", repaymentApplyDto.getAmount());
        }
        param.put("bankCardNo", repaymentApplyDto.getBankCardNo());
        param.put("verifyCode", repaymentApplyDto.getVerifyCode());
        List<Map<String, String>> repayList = new ArrayList<>();
        for (RepayVo repayVo : repaymentApplyDto.getRepayList()) {
            Map<String, String> repayParam = new HashMap<>();
            if (StringUtils.isNotEmpty(repayVo.getRepayAmt())) {
                repayParam.put("repayAmt", repayVo.getRepayAmt());
            }
            repayParam.put("repayTerm", repayVo.getRepayTerm());
            repayList.add(repayParam);
        }
        param.put("repayList", repayList);
        try {
            logger.info("日志编号:" + logNumber + "用户还款确认接口参数->:{}", param);
            String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
//            logger.info("日志编号:" + logNumber + "用户还款确认接口加密参数->:{}", paramStr);
            String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + repaymentApply, paramStr);
//            logger.info("日志编号:" + logNumber + "用户还款确认接口加密返回->:{}", yxResult);
            if (!TextUtils.isEmpty(yxResult)) {
                Map<String, String> resultMap = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
                logger.info("日志编号:" + logNumber + "用户还款确认接口加密返回resultMap->:{}", resultMap);
                if (!TextUtils.isEmpty(resultMap.get("params"))) {
                    return JSON.parseObject(resultMap.get("params"), YxRepaymentApplyResponse.class);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
 
    /**
     * 2.4.5.获取还款H5页面
     *
     * @param funding         资金方代码
     * @param logNumber       日志编号
     * @param logger          日志对象
     * @param repaymentUrlDto 获取还款H5页面Dto
     */
    public YxRepaymentUrlResponse yxRepaymentUrl(YxRepaymentUrlDto repaymentUrlDto,
                                                 String funding, Logger logger, String logNumber) {
        String repaymentUrl = "/flow/repaymentUrl";
        Map<String, Object> param = new HashMap<>();
        param.put("loanNo", repaymentUrlDto.getLoanNo());
        param.put("userId", repaymentUrlDto.getUserId());
        param.put("returnUrl", repaymentUrlDto.getReturnUrl());
        try {
            logger.info("日志编号:" + logNumber + "还款计划查询参数->:{}", param);
            String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
//            logger.info("日志编号:" + logNumber + "还款计划查询加密参数->:{}", paramStr);
            String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + repaymentUrl, paramStr);
//            logger.info("日志编号:" + logNumber + "还款计划查询加密返回->:{}", yxResult);
            if (!TextUtils.isEmpty(yxResult)) {
                Map<String, String> resultMap = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
                logger.info("日志编号:" + logNumber + "还款计划查询加密返回resultMap->:{}", resultMap);
                if (!TextUtils.isEmpty(resultMap.get("params"))) {
                    return JSON.parseObject(resultMap.get("params"), YxRepaymentUrlResponse.class);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
 
    /**
     * 2.1.2.授信申请
     *
     * @param logger    日志对象
     * @param logNumber 日志编号
     * @param userId    用户Id
     * @param funding   资金方代码
     * @param customer  客户申请记录
     */
    public YXResponse yxCreditApply(Customer customer, String userId,
                                    String funding, Logger logger, String logNumber) {
        //流量方调用资金方进行授信信息传输,资金方对该信息进行校验,此接口为实时接口
        String creditApplyUrl = "/flow/creditApply";
 
        Map<String, Object> param = new HashMap<>();
        param.put("creditNo", customer.getCreditNo());
        param.put("sourceChannel", customer.getSourceChannel());
 
        //用户授信信息
        Map<String, Object> creditInfo = new HashMap<>();
        creditInfo.put("userId", userId);
        creditInfo.put("creditApplyAmount", customer.parseLoadAmount());
        creditInfo.put("applyTerm", customer.getLoanTerm());
        creditInfo.put("applyUse", customer.getUseOfLoan());
        creditInfo.put("custName", customer.getName());
        creditInfo.put("idNo", customer.getIdCard());
        creditInfo.put("phoneNo", customer.getPhone());
        creditInfo.put("sex", customer.getSex());
        if (StringUtils.isNotEmpty(customer.getNationality())) {
            creditInfo.put("nationality", customer.getNationality());
        } else {
            creditInfo.put("nationality", "中国");
        }
        creditInfo.put("nation", customer.getNation());
        creditInfo.put("birthday", DateUtil.formatDate(DateUtil.parse(customer.getBirthday())));
        creditInfo.put("idAddress", customer.getIdAddress());
        creditInfo.put("signOrganization", customer.getSignOrganization());
        creditInfo.put("idValidDateBegin", DateUtil.formatDate(DateUtil.parse(customer.getIdValidDateBegin())));
        creditInfo.put("idValidDateEnd", DateUtil.formatDate(DateUtil.parse(customer.getIdValidDateEnd())));
        if ("长期".equals(customer.getIdValidDateEnd())) {
            creditInfo.put("idLongTerm", "1");
        }
        creditInfo.put("custEducation", formatYXEducation(customer.getEducation()));
        creditInfo.put("marriage", formatYXMarriage(customer.getMaritalStatus()));
        creditInfo.put("verifySimilarity", customer.getVerifySimilarity());
        creditInfo.put("verifySimilarityName", customer.getVerifySimilarityName());
        if (StringUtils.isNotEmpty(customer.getEmail())) {
            creditInfo.put("email", customer.getEmail());
        }
        if (StringUtils.isNotEmpty(customer.getLng())) {
            creditInfo.put("lng", customer.getLng());
        } else {
            creditInfo.put("lng", "0000-0000");
        }
        if (StringUtils.isNotEmpty(customer.getLat())) {
            creditInfo.put("lat", customer.getLat());
        } else {
            creditInfo.put("lat", "0000-0000");
        }
        if (StringUtils.isNotEmpty(customer.getMac())) {
            creditInfo.put("Mac", customer.getMac());
        }
        creditInfo.put("deviceID", customer.getDeviceId());
        creditInfo.put("deviceOsVersion", customer.getDeviceOsVersion());
        if (StringUtils.isNotEmpty(customer.getIdfa())) {
            creditInfo.put("idfa", customer.getIdfa());
        }
        if (StringUtils.isNotEmpty(customer.getIdfv())) {
            creditInfo.put("idfv", customer.getIdfv());
        }
        creditInfo.put("os", customer.getOs());
        if (StringUtils.isNotEmpty(customer.getAndroidId())) {
            creditInfo.put("androidId", customer.getAndroidId());
        }
        if (customer.getIsRoot() != null) {
            creditInfo.put("isRoot", customer.getIsRoot());
        } else {
            creditInfo.put("isRoot", 0);
        }
        if (StringUtils.isNotEmpty(customer.getImei())) {
            creditInfo.put("IMEI", customer.getImei());
        }
        creditInfo.put("liveProvince", customer.getLiveProvince());
        creditInfo.put("liveCity", customer.getCity());
        creditInfo.put("liveArea", customer.getLiveArea());
        creditInfo.put("liveAddress", customer.getAddress());
        creditInfo.put("client_ip", customer.getClientIp());
        creditInfo.put("haveCar", CarStatusEnum.Car_1.getCode().equals(customer.getCarStatus()) ? 0 : 1);
        creditInfo.put("haveHouse", HouseStatusEnum.House_1.getCode().equals(customer.getHouseStatus()) ? 0 : 1);
        if (customer.getApplyDate() != null) {
            creditInfo.put("registerDateTime", DateUtil.formatDateTime(customer.getApplyDate()));
        }
        creditInfo.put("familyMonthlyIncome", customer.getFamilyMonthlyIncome());
        if (StringUtils.isNotEmpty(customer.getLivest())) {
            creditInfo.put("livest", customer.getLivest());
        } else {
            creditInfo.put("livest", YiXinLivestEnum.UNKNOWN.getCode());
        }
        if (StringUtils.isNotEmpty(customer.getGpsProvince())) {
            creditInfo.put("gpsProvince", customer.getGpsProvince());
        } else {
            creditInfo.put("gpsProvince", customer.getCompanyProvince());
        }
        if (StringUtils.isNotEmpty(customer.getGpsCity())) {
            creditInfo.put("gpsCity", customer.getGpsCity());
        } else {
            creditInfo.put("gpsCity", customer.getCompanyCity());
        }
        if (StringUtils.isNotEmpty(customer.getGpsArea())) {
            creditInfo.put("gpsArea", customer.getGpsArea());
        } else {
            creditInfo.put("gpsArea", customer.getCompanyArea());
        }
        creditInfo.put("gpsAddress", "0000-0000");
        if (StringUtils.isNotEmpty(customer.getDeviceBrand())) {
            creditInfo.put("deviceBrand", customer.getDeviceBrand());
        } else {
            creditInfo.put("deviceBrand", "华为");
        }
        //设备型号 例如: P30
        creditInfo.put("deviceModel", "0000-0000");
        //联系人列表,列表中需要包含家庭联系人、其它联系人,两种类型各一个
        List<Map<String, String>> contactRelationLists = new ArrayList<>();
        //家庭联系人
        Map<String, String> HomeRelation = new HashMap<>();
        String homeShip = formatYXRelationship(customer.getRelationship());
        HomeRelation.put("contactRelation", homeShip);
        HomeRelation.put("contactName", customer.getRelationshipName());
        HomeRelation.put("contactPhoneNo", customer.getRelationshipPhone());
        if (RelationshipEnum.Relationship_3.getCode().equals(homeShip)) {
            if (StringUtils.isNotEmpty(customer.getCertNo()) && StringUtils.isNotEmpty(customer.getContactCompany())) {
                HomeRelation.put("certNo", customer.getCertNo());
                HomeRelation.put("contactCompany", customer.getContactCompany());
            } else {
                creditInfo.replace("marriage", MaritalStatusEnum.MaritalStatus_9.getSys());
                HomeRelation.replace("contactRelation", YiXinHomeRelationEnum.BROTHERS.getCode());
            }
        }
        contactRelationLists.add(HomeRelation);
        //其他联系人
        Map<String, String> otherRelation = new HashMap<>();
        if (StringUtils.isNotEmpty(customer.getContactRelation())) {
            otherRelation.put("contactRelation", customer.getContactRelation());
        } else {
            otherRelation.put("contactRelation", YiXinFriendRelationEnum.OTHER.getCode());
        }
        otherRelation.put("contactName", customer.getContactName());
        otherRelation.put("contactPhoneNo", customer.getContactPhone());
        contactRelationLists.add(otherRelation);
        creditInfo.put("contactRelationLists", contactRelationLists);
 
        //图片列表
        List<Map<String, String>> pictureList = new ArrayList<>();
 
        //正面身份证
        Map<String, String> pictureFront = new HashMap<>();
        pictureFront.put("methods", "0");
        pictureFront.put("pictureType", "0");
        pictureFront.put("pictureUrl", customer.getIdCardFrontPath());
        pictureList.add(pictureFront);
 
        //反面身份证
        Map<String, String> pictureBack = new HashMap<>();
        pictureBack.put("methods", "0");
        pictureBack.put("pictureType", "1");
        pictureBack.put("pictureUrl", customer.getIdCardBackPath());
        pictureList.add(pictureBack);
        creditInfo.put("pictureList", pictureList);
 
        //活检照片
        Map<String, String> pictureFace = new HashMap<>();
        pictureFace.put("methods", "0");
        pictureFace.put("pictureType", "2");
        pictureFace.put("pictureUrl", customer.getFacePhotoPath());
        pictureList.add(pictureFace);
        creditInfo.put("pictureList", pictureList);
 
        param.put("creditInfo", creditInfo);
 
 
        //职位信息
        Map<String, String> dutyInfo = new HashMap<>();
        dutyInfo.put("income", MonthlyIncomeEnum.parseAmount(customer.getMonthlyIncome()));
        dutyInfo.put("companyName", customer.getCompanyName());
        dutyInfo.put("companyAddress", customer.getCompanyAddress());
        dutyInfo.put("companyProvince", customer.getCompanyProvince());
        dutyInfo.put("companyCity", customer.getCompanyCity());
        dutyInfo.put("companyArea", customer.getCompanyArea());
        dutyInfo.put("companyPhone", customer.getCompanyPhone());
        dutyInfo.put("occupation", customer.getOccupation());
        dutyInfo.put("duty", customer.getJobTitle());
        dutyInfo.put("jobNature", customer.getCompanyNature());
 
        param.put("dutyInfo", dutyInfo);
 
        //银行卡相关
        Map<String, String> debitCardInfo = new HashMap<>();
        if (!TextUtils.isEmpty(customer.getCardNo())) {
            debitCardInfo.put("cardNo", customer.getCardNo());
        }
        if (!TextUtils.isEmpty(customer.getBankCode())) {
            debitCardInfo.put("bankCode", customer.getBankCode());
        }
        if (!TextUtils.isEmpty(customer.getBankName())) {
            debitCardInfo.put("bankName", customer.getBankName());
        }
        if (!TextUtils.isEmpty(customer.getBankPhoneNo())) {
            debitCardInfo.put("phoneNo", customer.getBankPhoneNo());
        }
        if (!TextUtils.isEmpty(customer.getBankCardName())) {
            debitCardInfo.put("cardName", customer.getBankCardName());
        }
        param.put("debitCardInfo", debitCardInfo);
 
 
        try {
            logger.info("授信申请参数->:{}", param);
            String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
//            logger.info("授信申请加密参数->:{}", paramStr);
            String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + creditApplyUrl, paramStr);
//            logger.info("授信申请加密返回->:{}", yxResult);
            if (!TextUtils.isEmpty(yxResult)) {
                Map<String, String> resultMap = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
                logger.info("授信结果查询加密返回resultMap->:{}", resultMap);
                if (!TextUtils.isEmpty(resultMap.get("params"))) {
                    return JSON.parseObject(resultMap.get("params"), YXResponse.class);
                }
            }
        } catch (Exception e) {
            logger.error("授信结果查询失败", e);
        }
        return null;
    }
 
    private String formatYXEducation(String eduction) {
        if (EducationEnum.Education_0.getCode().equals(eduction)) {
            return "06";
        } else if (EducationEnum.Education_1.getCode().equals(eduction)) {
            return "05";
        } else if (EducationEnum.Education_2.getCode().equals(eduction)) {
            return "04";
        } else if (EducationEnum.Education_3.getCode().equals(eduction)) {
            return "03";
        } else if (EducationEnum.Education_4.getCode().equals(eduction)) {
            return "02";
        } else if (EducationEnum.Education_5.getCode().equals(eduction)) {
            return "06";
        } else {
            return eduction;
        }
    }
 
    private String formatYXMarriage(String marriage) {
        if (MaritalStatusEnum.MaritalStatus_1.getSys().equals(marriage)) {
            return "02";
        } else if (MaritalStatusEnum.MaritalStatus_2.getSys().equals(marriage)) {
            return "01";
        } else if (MaritalStatusEnum.MaritalStatus_3.getSys().equals(marriage)) {
            return "03";
        } else if (MaritalStatusEnum.MaritalStatus_4.getSys().equals(marriage)) {
            return "04";
        } else {
            return marriage;
        }
    }
 
    private String formatYXRelationship(String relationship) {
        if (RelationshipEnum.Relationship_1.equals(relationship)) {
            return "02";
        } else if (RelationshipEnum.Relationship_2.equals(relationship)) {
            return "03";
        } else {
            return relationship;
        }
    }
 
 
    /**
     * 2.1.3.授信审批查询
     *
     * @param creditNo  授信编号
     * @param funding   资金方代码
     * @param userId    用户Id
     * @param logNumber 日志编号
     * @param logger    日志对象
     */
    public YXAuditResponse yxGetCreditAudit(String userId, String creditNo,
                                            String funding, Logger logger, String logNumber) {
 
        String getCreditAudit = "/flow/getCreditAudit";
        Map<String, Object> param = new HashMap<>();
        param.put("creditNo", creditNo);
        param.put("userId", userId);
        try {
            logger.info("日志编号:" + logNumber + "授信结果查询参数->:{}", param);
            String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
//            logger.info("日志编号:" + logNumber + "授信结果查询加密参数->:{}", paramStr);
            String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + getCreditAudit, paramStr);
//            logger.info("日志编号:" + logNumber + "授信结果查询加密返回->:{}", yxResult);
            if (!TextUtils.isEmpty(yxResult)) {
                Map<String, String> resultMap = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
                logger.info("日志编号:" + logNumber + "授信结果查询加密返回resultMap->:{}", resultMap);
                if (!TextUtils.isEmpty(resultMap.get("params"))) {
                    return JSON.parseObject(resultMap.get("params"), YXAuditResponse.class);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
 
    /**
     * 2.1.5.额度查询接口
     *
     * @param logger    日志对象
     * @param logNumber 日志编号
     * @param userId    用户Id
     * @param funding   资金方代码
     * @param creditNo  授信编号
     * @return
     */
    public YXCreditLimitResponse yxGetCreditLimit(String userId, String creditNo,
                                                  String funding, Logger logger, String logNumber) {
        String getCreditLimit = "/flow/getCreditLimit";
        Map<String, Object> param = new HashMap<>();
        param.put("creditNo", creditNo);
        param.put("userId", userId);
        try {
            logger.info("日志编号:" + logNumber + "额度查询接口参数->:{}", param);
            String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
//            logger.info("日志编号:" + logNumber + "额度查询接口加密参数->:{}", paramStr);
            String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + getCreditLimit, paramStr);
//            logger.info("日志编号:" + logNumber + "额度查询接口加密返回->:{}", yxResult);
            if (!TextUtils.isEmpty(yxResult)) {
                Map<String, String> resultMap = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
                logger.info("额度查询接口加密返回resultMap->:{}", resultMap);
                if (!TextUtils.isEmpty(resultMap.get("params"))) {
                    return JSON.parseObject(resultMap.get("params"), YXCreditLimitResponse.class);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
 
 
    /**
     * 2.5.1.合同列表查询接口
     *
     * @param funding   资金方代码
     * @param userId    用户Id
     * @param scene     使用场景 01用信绑卡 02还款绑卡 03借款申请相关 04贷后合同 05授信申请
     * @param logNumber 日志编号
     * @param logger    日志对象
     * @param loanNo    贷款编号
     * @return
     */
    public YxContractResponse yxContractListQuery(String userId, String scene, String loanNo,
                                                  String funding, Logger logger, String logNumber) {
        String getCreditLimit = "/flow/contractListQuery";
        Map<String, Object> param = new HashMap<>();
        param.put("scene", scene);
        param.put("userId", userId);
        param.put("reqSysCode", YXSignUtil.reqSysCode);
        if (StringUtils.isNotEmpty(loanNo)) {
            param.put("loanNo", loanNo);
        }
        try {
//            logger.info("日志编号:" + logNumber + "合同接口请求参数->:{}", param);
            String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
//            logger.info("日志编号:" + logNumber + "合同接口请求加密参数->:{}", paramStr);
            String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + getCreditLimit, paramStr);
//            logger.info("日志编号:" + logNumber + "合同接口加密返回->:{}", yxResult);
            if (!TextUtils.isEmpty(yxResult)) {
                Map<String, String> resultMap = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
//                logger.info("日志编号:" + logNumber + "合同接口加密返回resultMap->:{}", resultMap);
                if (!TextUtils.isEmpty(resultMap.get("params"))) {
                    return JSON.parseObject(resultMap.get("params"), YxContractResponse.class);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
 
    }
 
    /**
     * 2.2.1.获取借款链接
     *
     * @param userId    用户id
     * @param platform  平台来源
     * @param funding   资金方代码
     * @param creditNo  授信编号
     * @param logger    日志对象
     * @param logNumber 日志编号
     * @return
     */
    public YxLoanResponse yxGetLoanUrl(String userId, String creditNo, String platform,
                                       String funding, Logger logger, String logNumber) {
        // 请求url
        String url = "/flow/getLoanUrl";
        // 组装请求体
        Map<String, Object> param = new HashMap<>(16);
        param.put("userId", userId);
        param.put("creditNo", creditNo);
        param.put("platform", platform);
        try {
            logger.info("日志编号:" + logNumber + "借款链接接口请求参数->:{}", param);
            String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
//            logger.info("日志编号:" + logNumber + "借款链接接口加密参数->:{}", paramStr);
            String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + url, paramStr);
//            logger.info("日志编号:" + logNumber + "借款链接接口加密返回结果->:{}", yxResult);
            if (!TextUtils.isEmpty(yxResult)) {
                Map<String, String> resultMap = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
                logger.info("日志编号:" + logNumber + "借款链接接口加密返回resultMap->:{}", resultMap);
                if (!TextUtils.isEmpty(resultMap.get("params"))) {
                    return JSON.parseObject(resultMap.get("params"), YxLoanResponse.class);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("日志编号:" + logNumber + "借款链接接口异常->:{}", e.getMessage());
        }
        return null;
    }
 
    /**
     * 获取私钥
     *
     * @return
     */
    public static PrivateKey getLocalPrivateKey() throws Exception {
        PrivateKey privateKey = getPrivateKey(YXSignUtil.LOCAL_PRIVATE_KEY);
        return privateKey;
    }
 
    /**
     * 获取公钥
     *
     * @return
     */
    public PublicKey getLvDiPublicKey() throws Exception {
        PublicKey pubK = getPublicKey(yxPubKey);
        return pubK;
    }
 
 
    //获取公钥
    public static PublicKey getPublicKey(String key) throws Exception {
        byte[] decoded = java.util.Base64.getDecoder().decode(key);
        RSAPublicKey pubKey = (RSAPublicKey) KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(decoded));
        return pubKey;
    }
 
    //获取私钥
    public static PrivateKey getPrivateKey(String key) throws Exception {
        //Base64编码的私钥
        byte[] decoded = java.util.Base64.getDecoder().decode(key);
        PrivateKey priKey = KeyFactory.getInstance("RSA").generatePrivate(new PKCS8EncodedKeySpec(decoded));
        return priKey;
    }
 
    public Map<String, String> getTxKeyInfo(String channelInfo) {
        Map<String, String> keys = new HashMap<>();
        if (!TextUtils.isEmpty(channelInfo) && (channelInfo.equals("suyihua") || channelInfo.equals("SUYIHUA"))) {
            keys.put("appId", syhAppId);
            keys.put("secret", syhSecret);
        } else if (!TextUtils.isEmpty(channelInfo) && (channelInfo.equals("jixianghua") || channelInfo.equals("JIXIANGHUA"))) {
            keys.put("appId", jxhAppId);
            keys.put("secret", jxhSecret);
        } else if (!TextUtils.isEmpty(channelInfo) && (channelInfo.equals("sankuaifenqi") || channelInfo.equals("SANKUAIFENQI"))) {
            keys.put("appId", skAppId);
            keys.put("secret", skSecret);
        } else if (!TextUtils.isEmpty(channelInfo) && (channelInfo.equals("weixianghua") || channelInfo.equals("WEIXIANGHUA"))) {
            keys.put("appId", wxhAppId);
            keys.put("secret", wxhSecret);
        } else if (!TextUtils.isEmpty(channelInfo) && (channelInfo.equals("kadana") || channelInfo.equals("KADANA"))) {
            keys.put("appId", kdnAppId);
            keys.put("secret", kdnSecret);
        } else if (!TextUtils.isEmpty(channelInfo) && (channelInfo.equals("jxd") || channelInfo.equals("JXD"))) {
            keys.put("appId", jxdAppId);
            keys.put("secret", jxdSecret);
        }else {
            keys.put("appId", jydAppId);
            keys.put("secret", jydSecret);
        }
        return keys;
    }
 
}