Pu Zhibing
6 天以前 4c99ee7028c3fe58a2cd4b8273b22c75c45574fc
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
/*
package com.stylefeng.guns.modular.system.util;
 
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.icbc.api.DefaultIcbcClient;
import com.icbc.api.IcbcApiException;
import com.icbc.api.IcbcConstants;
import com.icbc.api.request.*;
import com.icbc.api.response.*;
import com.icbc.api.utils.IcbcSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.text.SimpleDateFormat;
import java.util.*;
 
*/
/**
 * 工商银行支付工具类
 *//*
 
@Component
public class ICBCPayUtil {
 
    private String app_id = "10000000000003159405";
 
    private String privateKey = "MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCBnf5bNOMF106sxlN6reQKs4wvUpnvRxXxFCzm13Bz70V6Oldx0EF4mFw/LCXMxwftGEanzjXOwDdk9apVeIYjedb8jsBjgwlREVLmpe3kFo65DedEao3MykpoXrm9kt8FPuxLAkTbfFuqim9f+nruXP1DA7cLt3N4PEzsfDA/WG4wXJgqWkHJaDbzcJOEX7pNZXWtTjoMznKufELsUEf3sdX+9/anIyObmq2+kv2w8H5RcRxBY+2M4K8Hd3Zf9u2Ffvr/phOsUB14XLrjfdXeWbZzHtHfGlfIQf5EK9HySEcaQHMHluEQSkriHdW7dlanIzzLY9M0lH+2Ok9j3Yp5AgMBAAECggEAVnHEfZecAP1DXz811Y+7kteEGtuABnDmVU4bVClCuk9NiuL2BtXZlFAo1Yjf/N6QjrOuC6Qfhq/zQcYFv9MNwwMzOmUKMlPmFsby/xiSu5e/v/Nh1eMqhvYzAcCLJ7+YNattc+kjey5JBEgnV196NRaXYeZMYegLfpjYxK9ejh+85kxp9ElXxZsSwrgzvICtyZ0Bl2ZD28kXr9/89dNIQX5sWRBN/dpxj99Ctz3JtlaMhxdnZ3cZKLeIAIAYFtqw5lSqeL7/7a6LPGpNa0kA+8KvHNEAnkpcEFg427k7h7nerFl2PQV/y5LuRLbUMZkdaIoo25Sh90xhtwfGCTAkcQKBgQC71mNkQL5HPYJbRirG3CjbLRAubztzlqtTSE/RZnPNiIinwACWZVHQ7Ob2+WLaIEOqIq6h1zWyYFO+peFNfCbcdZTfQHxiYfmzrY7ZlBtRJM3ez20RQ85TJvej08HjTM4vVKXt9DDqlBu4IATcmNlJqgBKeNXsDYORTNqTZlrocwKBgQCwpxdmd2yhRIrWXx9K4lZYfpGEUUMKrCI2SGX0bdiNtgn2p2HK3cDVO/gh8Iz6tKLI53HS3OTTsVZq1xoUm3M+27sPUk6KiUBQqOsDmYVayKjOY2IciwU0SmS/9C9ptYpchUrZSR7mejKvk7QKBkH3utBUnfYCQmqhyAnjHBhCYwKBgHBVxNc+CQ3d8UnY6thG7oA1sQm0KB/2qbuC8YlP9k2jK+b24uMO8SE7rN1jRAUjapQjbcEITerBxROtbNLEPxF1mHTzwe+snIMidt4Uv0mF80EfWCENJiWAlnV5vOjNFDomK53lfiOsM++n5oBvQPPXIZloLrefVWHeTpH8kr2VAoGAbB+JqhT0r2yVkgqcy6fnc7jcdmGKqFCdjB4aEVbekjZWuNrQd2vtaFaRVKy4jYbckB1hRNAhWxUTMMfB1dUj39h8ES+ulQrXC8eoOQbRYbSp5dFcrt3EbLIQIpFiJ9CPBHwtSPuBZ05qEZ9VNkGIRQnaE8CvX8ipHaajrpd2ncMCgYAdjW2LFmc+K9tai8idbhEu1uzez+HPT8PgE5iy6ZE8gxQvzUdHaqgO+OgNhWEY+QJOEyM0YJuidaN9qiTiWJHs04/03qAy1wCZCYhvHuRMh1mPvqdA9ybUmG/K0bMqkqS9B2GxKQPtlnmeUG/pXjQ12U8WrS2ayjDoHBtimuxkIQ==";
 
    private String icbcPulicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCMpjaWjngB4E3ATh+G1DVAmQnIpiPEFAEDqRfNGAVvvH35yDetqewKi0l7OEceTMN1C6NPym3zStvSoQayjYV+eIcZERkx31KhtFu9clZKgRTyPjdKMIth/wBtPKjL/5+PYalLdomM4ONthrPgnkN4x4R0+D4+EBpXo8gNiAFsNwIDAQAB";
 
    private String mer_id = "210541210043";//商户编号
 
    private String mer_id1 = "210541210044";//商户编号
 
    private String mer_prtcl_no = "2105412100430201";//收单产品协议编号
 
    private String mer_acct = "2105402019300157124";//商户账号,商户入账账号,只能交易时指定。(商户付给银行手续费的账户,可以在开户的时候指定,也可以用交易指定方式;用交易指定方式则使用此商户账号)目前暂不支持
 
    private String wx_appid_user = "wx0071ebcb539570f8";
 
    private String wx_appid_driver = "wx65d2c03f04352f90";
 
    private String wx_appid_user1 = "wx7608ef3dae49b691";//小程序
 
    private String ali_appid_user = "2016120203722668";
 
    private String ali_appid_driver = "2021001165630930";
 
    private String payer_account = "2105455809300020994";//银行账户
 
    private String payer_cnname = "广西云森科技有限公司";//账户名称
 
    @Autowired
    private JuHeUtil juHeUtil;
 
    @Autowired
    private HttpClientUtil httpClientUtil;
 
    @Autowired
    private RestTemplate restTemplate;
 
    private String bank = "{\"CDB\":\"国家开发银行\",\"ICBC\":\"中国工商银行\",\"ABC\":\"中国农业银行\",\"BOC\":\"中国银行\",\"CCB\":\"中国建设银行\",\"PSBC\":\"中国邮政储蓄银行\",\"COMM\":\"交通银行\",\"CMB\":\"招商银行\",\"SPDB\":\"上海浦东发展银行\",\"CIB\":\"兴业银行\",\"HXBANK\":\"华夏银行\",\"GDB\":\"广东发展银行\",\"CMBC\":\"中国民生银行\",\"CITIC\":\"中信银行\",\"CEB\":\"中国光大银行\",\"EGBANK\":\"恒丰银行\",\"CZBANK\":\"浙商银行\",\"BOHAIB\":\"渤海银行\",\"SPABANK\":\"平安银行\",\"SHRCB\":\"上海农村商业银行\",\"YXCCB\":\"玉溪市商业银行\",\"YDRCB\":\"尧都农商行\",\"BJBANK\":\"北京银行\",\"SHBANK\":\"上海银行\",\"JSBANK\":\"江苏银行\",\"HZCB\":\"杭州银行\",\"NJCB\":\"南京银行\",\"NBBANK\":\"宁波银行\",\"HSBANK\":\"徽商银行\",\"CSCB\":\"长沙银行\",\"CDCB\":\"成都银行\",\"CQBANK\":\"重庆银行\",\"DLB\":\"大连银行\",\"NCB\":\"南昌银行\",\"FJHXBC\":\"福建海峡银行\",\"HKB\":\"汉口银行\",\"WZCB\":\"温州银行\",\"QDCCB\":\"青岛银行\",\"TZCB\":\"台州银行\",\"JXBANK\":\"嘉兴银行\",\"CSRCB\":\"常熟农村商业银行\",\"NHB\":\"南海农村信用联社\",\"CZRCB\":\"常州农村信用联社\",\"H3CB\":\"内蒙古银行\",\"SXCB\":\"绍兴银行\",\"SDEB\":\"顺德农商银行\",\"WJRCB\":\"吴江农商银行\",\"ZBCB\":\"齐商银行\",\"GYCB\":\"贵阳市商业银行\",\"ZYCBANK\":\"遵义市商业银行\",\"HZCCB\":\"湖州市商业银行\",\"DAQINGB\":\"龙江银行\",\"JINCHB\":\"晋城银行JCBANK\",\"ZJTLCB\":\"浙江泰隆商业银行\",\"GDRCC\":\"广东省农村信用社联合社\",\"DRCBCL\":\"东莞农村商业银行\",\"MTBANK\":\"浙江民泰商业银行\",\"GCB\":\"广州银行\",\"LYCB\":\"辽阳市商业银行\",\"JSRCU\":\"江苏省农村信用联合社\",\"LANGFB\":\"廊坊银行\",\"CZCB\":\"浙江稠州商业银行\",\"DYCB\":\"德阳商业银行\",\"JZBANK\":\"晋中市商业银行\",\"BOSZ\":\"苏州银行\",\"GLBANK\":\"桂林银行\",\"URMQCCB\":\"乌鲁木齐市商业银行\",\"CDRCB\":\"成都农商银行\",\"ZRCBANK\":\"张家港农村商业银行\",\"BOD\":\"东莞银行\",\"LSBANK\":\"莱商银行\",\"BJRCB\":\"北京农村商业银行\",\"TRCB\":\"天津农商银行\",\"SRBANK\":\"上饶银行\",\"FDB\":\"富滇银行\",\"CRCBANK\":\"重庆农村商业银行\",\"ASCB\":\"鞍山银行\",\"NXBANK\":\"宁夏银行\",\"BHB\":\"河北银行\",\"HRXJB\":\"华融湘江银行\",\"ZGCCB\":\"自贡市商业银行\",\"YNRCC\":\"云南省农村信用社\",\"JLBANK\":\"吉林银行\",\"DYCCB\":\"东营市商业银行\",\"KLB\":\"昆仑银行\",\"ORBANK\":\"鄂尔多斯银行\",\"XTB\":\"邢台银行\",\"JSB\":\"晋商银行\",\"TCCB\":\"天津银行\",\"BOYK\":\"营口银行\",\"JLRCU\":\"吉林农信\",\"SDRCU\":\"山东农信\",\"XABANK\":\"西安银行\",\"HBRCU\":\"河北省农村信用社\",\"NXRCU\":\"宁夏黄河农村商业银行\",\"GZRCU\":\"贵州省农村信用社\",\"FXCB\":\"阜新银行\",\"HBHSBANK\":\"湖北银行黄石分行\",\"ZJNX\":\"浙江省农村信用社联合社\",\"XXBANK\":\"新乡银行\",\"HBYCBANK\":\"湖北银行宜昌分行\",\"LSCCB\":\"乐山市商业银行\",\"TCRCB\":\"江苏太仓农村商业银行\",\"BZMD\":\"驻马店银行\",\"GZB\":\"赣州银行\",\"WRCB\":\"无锡农村商业银行\",\"BGB\":\"广西北部湾银行\",\"GRCB\":\"广州农商银行\",\"JRCB\":\"江苏江阴农村商业银行\",\"BOP\":\"平顶山银行\",\"TACCB\":\"泰安市商业银行\",\"CGNB\":\"南充市商业银行\",\"CCQTGB\":\"重庆三峡银行\",\"XLBANK\":\"中山小榄村镇银行\",\"HDBANK\":\"邯郸银行\",\"KORLABANK\":\"库尔勒市商业银行\",\"BOJZ\":\"锦州银行\",\"QLBANK\":\"齐鲁银行\",\"BOQH\":\"青海银行\",\"YQCCB\":\"阳泉银行\",\"SJBANK\":\"盛京银行\",\"FSCB\":\"抚顺银行\",\"ZZBANK\":\"郑州银行\",\"SRCB\":\"深圳农村商业银行\",\"BANKWF\":\"潍坊银行\",\"JJBANK\":\"九江银行\",\"JXRCU\":\"江西省农村信用\",\"HNRCU\":\"河南省农村信用\",\"GSRCU\":\"甘肃省农村信用\",\"SCRCU\":\"四川省农村信用\",\"GXRCU\":\"广西省农村信用\",\"SXRCCU\":\"陕西信合\",\"WHRCB\":\"武汉农村商业银行\",\"YBCCB\":\"宜宾市商业银行\",\"KSRB\":\"昆山农村商业银行\",\"SZSBK\":\"石嘴山银行\",\"HSBK\":\"衡水银行\",\"XYBANK\":\"信阳银行\",\"NBYZ\":\"鄞州银行\",\"ZJKCCB\":\"张家口市商业银行\",\"XCYH\":\"许昌银行\",\"JNBANK\":\"济宁银行\",\"CBKF\":\"开封市商业银行\",\"WHCCB\":\"威海市商业银行\",\"HBC\":\"湖北银行\",\"BOCD\":\"承德银行\",\"BODD\":\"丹东银行\",\"JHBANK\":\"金华银行\",\"BOCY\":\"朝阳银行\",\"LSBC\":\"临商银行\",\"BSB\":\"包商银行\",\"LZYH\":\"兰州银行\",\"BOZK\":\"周口银行\",\"DZBANK\":\"德州银行\",\"SCCB\":\"三门峡银行\",\"AYCB\":\"安阳银行\",\"ARCU\":\"安徽省农村信用社\",\"HURCB\":\"湖北省农村信用社\",\"HNRCC\":\"湖南省农村信用社\",\"NYNB\":\"广东南粤银行\",\"LYBANK\":\"洛阳银行\",\"NHQS\":\"农信银清算中心\",\"CBBQS\":\"城市商业银行资金清算中心\"}";
 
 
 
    */
/**
     * 统一下单接口
     * @param out_trade_no      商户订单号
     * @param pay_mode          支付方式,9-微信,10-支付宝
     * @param access_type       收单接入方式,5-APP,7-微信公众号,8-支付宝生活号,9-微信小程序
     * @param deciveInfo        设备号(设备唯一编号)
     * @param body
     * @param total_fee
     * @param mer_url           回调地址(完整地址)
     * @param attach            附加信息
     * @param type              支付端类型(1:用户端,2:司机端,3:小程序)
     * @throws UnknownHostException
     *//*
 
    public Map<String, String> placeAnOrder(String out_trade_no, Integer pay_mode, Integer access_type, String deciveInfo, String body, Double total_fee, String mer_url, String attach, Integer type, String openId) throws Exception {
        //签名类型为RSA时,需传入appid,私钥和网关公钥,签名类型使用定值IcbcConstants.SIGN_TYPE_RSA,其他参数使用缺省值
        DefaultIcbcClient client = new DefaultIcbcClient(app_id, IcbcConstants.SIGN_TYPE_RSA2, privateKey, icbcPulicKey);
        CardbusinessAggregatepayB2cOnlineConsumepurchaseRequestV1 request = new
                CardbusinessAggregatepayB2cOnlineConsumepurchaseRequestV1();
        //根据测试环境和生产环境替换相应ip和端口
        request.setServiceUrl("https://gw.open.icbc.com.cn/api/cardbusiness/aggregatepay/b2c/online/consumepurchase/V1");
        CardbusinessAggregatepayB2cOnlineConsumepurchaseRequestV1.CardbusinessAggregatepayB2cOnlineConsumepurchaseRequestV1Biz bizContent = new CardbusinessAggregatepayB2cOnlineConsumepurchaseRequestV1.CardbusinessAggregatepayB2cOnlineConsumepurchaseRequestV1Biz();
        request.setBizContent(bizContent);
        //请对照接口文档用bizContent.setxxx()方法对业务上送数据进行赋值
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
        String format = sdf.format(new Date());
        bizContent.setMer_id(mer_id);
        bizContent.setOut_trade_no(out_trade_no);
        bizContent.setPay_mode(pay_mode.toString());
        bizContent.setAccess_type(access_type.toString());
        bizContent.setMer_prtcl_no(mer_prtcl_no);
        bizContent.setOrig_date_time(format);
        bizContent.setDecive_info(deciveInfo);
        bizContent.setBody("OK出行-" + body);
        bizContent.setFee_type("001");
        InetAddress ip4 = Inet4Address.getLocalHost();
        bizContent.setSpbill_create_ip(ip4.getHostAddress());
        bizContent.setTotal_fee(Double.valueOf(total_fee * 100).intValue() + "");
        bizContent.setMer_url(mer_url);
        bizContent.setOpen_id("");
        bizContent.setShop_appid("");
        bizContent.setUnion_id("");
        bizContent.setIcbc_appid(app_id);
        if(pay_mode == 9){
            switch (type){
                case 1://用户端
                    bizContent.setShop_appid(wx_appid_user);
                    break;
                case 2://司机端
                    bizContent.setShop_appid(wx_appid_driver);
                    break;
                case 3://小程序
                    bizContent.setShop_appid(wx_appid_user1);
                    bizContent.setAccess_type("9");
                    bizContent.setOpen_id(openId);
                    break;
            }
        }
        if(pay_mode == 10){
            switch (type){
                case 1://用户端
                    bizContent.setUnion_id(ali_appid_user);
                    break;
                case 2://司机端
                    bizContent.setUnion_id(ali_appid_driver);
                    break;
            }
        }
        bizContent.setMer_acct(mer_acct);
        bizContent.setExpire_time("120");
        bizContent.setAttach(attach);
        bizContent.setNotify_type("HS");
        bizContent.setResult_type("0");
        bizContent.setPay_limit("no_credit");
        bizContent.setOrder_apd_inf("");
        CardbusinessAggregatepayB2cOnlineConsumepurchaseResponseV1 response;
        response = client.execute(request, System.currentTimeMillis()+"");//msgId消息通讯唯一编号,要求每次调用独立生成,APP级唯一
        Map<String, String> map = new HashMap<>();
        if (response.getReturnCode() == 0) {
            // 6、业务成功处理,请根据接口文档用response.getxxx()获取同步返回的业务数据
            System.err.println("ReturnCode:"+response.getReturnCode());
            System.err.println("response:" + JSON.toJSONString(response));
            if(pay_mode == 9){//微信
                String order_id = response.getOrder_id();//工行订单号
                String out_trade_no1 = response.getOut_trade_no();//商户订单号
                map.put("order_id", order_id);
                map.put("out_trade_no1", out_trade_no1);
                map.put("data", response.getWx_data_package());
                map.put("code", "200");
                map.put("msg", "成功");
 
                return map;
            }
            if(pay_mode == 10){//支付宝
                String order_id = response.getOrder_id();//工行订单号
                String out_trade_no1 = response.getOut_trade_no();//商户订单号
                map.put("order_id", order_id);
                map.put("out_trade_no1", out_trade_no1);
                map.put("data", response.getZfb_data_package());
                map.put("code", "200");
                map.put("msg", "成功");
                return map;
            }
        }
        if(response.getReturnCode() == 92209500){
            System.err.println("response:" + JSON.toJSONString(response));
            System.err.println("ReturnCode:"+response.getReturnCode());
            System.err.println("ReturnMsg:"+response.getReturnMsg());
            map.put("order_id", "");
            map.put("out_trade_no1", "");
            map.put("data", "");
            map.put("code", "300");
            map.put("msg", "支付失败,请过两分钟后再重新支付!");
            return map;
        }else {
            // 失败
            System.err.println("response:" + JSON.toJSONString(response));
            System.err.println("ReturnCode:"+response.getReturnCode());
            System.err.println("ReturnMsg:"+response.getReturnMsg());
            map.put("order_id", "");
            map.put("out_trade_no1", "");
            map.put("data", "");
            map.put("code", "300");
            map.put("msg", "支付失败");
            return map;
        }
    }
 
 
 
 
    */
/**
     * 查询交易(商户订单号和工行订单号二选其一)
     * @param out_trade_no  商户订单号
     * @param order_id      工行订单号
     * @return
     *//*
 
    public String queryTransaction(String out_trade_no, String order_id){
        //签名类型为RSA时,需传入appid,私钥和网关公钥,签名类型使用定值IcbcConstants.SIGN_TYPE_RSA,其他参数使用缺省值
        DefaultIcbcClient client = new DefaultIcbcClient(app_id, IcbcConstants.SIGN_TYPE_RSA2, privateKey, icbcPulicKey);
        CardbusinessAggregatepayB2cOnlineOrderqryRequestV1 request = new CardbusinessAggregatepayB2cOnlineOrderqryRequestV1();
        //根据测试环境和生产环境替换相应ip和端口
        request.setServiceUrl("https://gw.open.icbc.com.cn/api/cardbusiness/aggregatepay/b2c/online/orderqry/V1");
        CardbusinessAggregatepayB2cOnlineOrderqryRequestV1.CardbusinessAggregatepayB2cOnlineOrderqryRequestV1Biz bizContent = new
                CardbusinessAggregatepayB2cOnlineOrderqryRequestV1.CardbusinessAggregatepayB2cOnlineOrderqryRequestV1Biz();
        request.setBizContent(bizContent);
        //请对照接口文档用bizContent.setxxx()方法对业务上送数据进行赋值
        bizContent.setMer_id(mer_id);
        bizContent.setOut_trade_no(out_trade_no);
        bizContent.setOrder_id(order_id);
        bizContent.setDeal_flag("0");//操作标志,0-查询;1-关单
        bizContent.setIcbc_appid(app_id);
        CardbusinessAggregatepayB2cOnlineOrderqryResponseV1 response;
        try {
            response = client.execute(request, System.currentTimeMillis()+"");//msgId消息通讯唯一编号,要求每次调用独立生成,APP级唯一
            if (response.getReturnCode() == 0) {
                // 6、业务成功处理,请根据接口文档用response.getxxx()获取同步返回的业务数据
                System.out.println("ReturnCode:"+response.getReturnCode());
                System.out.println("response:" + JSON.toJSONString(response));
 
                String pay_status = response.getPay_status();
 
                return pay_status;
            } else {
                // 失败
                System.out.println("response:" + JSON.toJSONString(response));
                System.out.println("ReturnCode:"+response.getReturnCode());
                System.out.println("ReturnMsg:"+response.getReturnMsg());
            }
        } catch (IcbcApiException e) {
            e.printStackTrace();
        }
        return "";
    }
 
 
 
    */
/**
     * 支付回调处理
     * @param request
     * @return
     * @throws Exception
     *//*
 
    public Map<String, String> payCallback(HttpServletRequest request) throws Exception{
        String biz_content1 = request.getParameter("biz_content");
        JSONObject biz_content = JSON.parseObject(biz_content1);
        int return_code = biz_content.getIntValue("return_code");
        String return_msg = biz_content.getString("return_msg");
        Map<String, String> map = new HashMap<>();
        if(return_code == 0){
            String out_trade_no = biz_content.getString("out_trade_no");//商家订单编号
            String order_id = biz_content.getString("order_id");//工行订单号
            String third_trade_no = biz_content.getString("third_trade_no");//第三方订单号(微信/支付宝)
            String attach = biz_content.getString("attach");//附加信息
            String pay_time = biz_content.getString("pay_time");//支付完成时间"20190112"
 
            map.put("out_trade_no", out_trade_no);
            map.put("order_id", order_id);
            map.put("third_trade_no", third_trade_no);
            map.put("attach", attach);
            map.put("pay_time", pay_time);
        }else{
            System.err.println("支付失败:" + return_msg);
        }
        return map;
    }
 
 
    */
/**
     * 回调通知应答
     * @param response
     * @throws Exception
     *//*
 
    public void answer(HttpServletResponse response) throws Exception{
        response.setContentType("application/json;charset=UTF-8");
        StringBuffer sb = new StringBuffer();
        String nativeUUID = UUIDUtil.getNativeUUID();
        sb.append("\"response_biz_content\":{\"return_code\":0,\"return_msg\":\"success\",\"msg_id\":\"" + nativeUUID + "\"},\"sign_type\":\"RSA2\"");
        String sign = IcbcSignature.sign(sb.toString(), IcbcConstants.SIGN_TYPE_RSA2, privateKey, "UTF-8");
        StringBuffer string = new StringBuffer();
        string.append("{\"response_biz_content\":{\"return_code\":0,\"return_msg\":\"success\",\"msg_id\":\"" + nativeUUID + "\"},\"sign_type\":\"RSA2\",\"sign\":\"" + sign + "\"}");
        PrintWriter out = response.getWriter();
        out.write(string.toString());
        out.flush();
        out.close();
    }
 
 
 
 
 
    */
/**
     * 转账
     * @param money             转账金额(分)
     * @param payeeAccount      收款账户(默认使用工行账户)
     * @param payeeCnname       收款账户名称
     * @return
     *//*
 
    public ResultUtil<String> transfer(Long money, String payeeAccount, String payeeCnname) throws Exception{
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        SimpleDateFormat sdf_ = new SimpleDateFormat("HHmmssSSS");
        Date date = new Date();
        String url = "https://gw.open.icbc.com.cn/api/mybank/enterprise/pay/payent/V1";
        DefaultIcbcClient client = new DefaultIcbcClient(app_id, IcbcConstants.SIGN_TYPE_RSA2, privateKey, icbcPulicKey);
        MybankEnterprisePayPayentRequestV1.MybankEnterprisePayPayentRequestBizV1 bizContent =
                new MybankEnterprisePayPayentRequestV1.MybankEnterprisePayPayentRequestBizV1();
        MybankEnterprisePayPayentRequestV1 request = new MybankEnterprisePayPayentRequestV1();
        // 请对照接⼝⽂档⽤bizContent.setxxx()⽅法对业务上送数据进⾏赋值
        bizContent.setTransCode("PAYPER");
        bizContent.setCis("210590000448207");//集团CIS号
        bizContent.setBankCode("102");//归属银行编号
        bizContent.setLoginId("GXYS01.y.2105");//证书ID
        bizContent.setTranDate(sdf.format(date));
        bizContent.setTranTime(sdf_.format(date));
        bizContent.setfSeqno(System.currentTimeMillis() + "");
        bizContent.setSettleMode(0);//入账方式。0:逐笔记账;2:并笔记账
        bizContent.setInstrCount(1);//总笔数
        bizContent.setTotalAmount(new BigDecimal(money));//总金额(分)
        ArrayList<MybankEnterprisePayPayentRequestV1.MybankEnterprisePayPayentRequestRdV1> list = new ArrayList<>();
        MybankEnterprisePayPayentRequestV1.MybankEnterprisePayPayentRequestRdV1 rd = new MybankEnterprisePayPayentRequestV1.MybankEnterprisePayPayentRequestRdV1();
        rd.setiSeqno(UUIDUtil.getRandomCode());//指令顺序号:每笔指令的序号,本包内不重复
        rd.setPayType("1");//记账处理方式:1:加急;2:普通;3:跨行快汇。联机批量标志为2-批量时,此字段无意义,上送1即可
        rd.setPayerAccount(mer_acct);//本方账户
        rd.setPayerCnname(payer_cnname);//本方账户名
        rd.setPayeeAccount(payeeAccount);//收方账号
        rd.setPayeeCnname(payeeCnname);//收方账户名
        rd.setIoFlag("1");//系统内外标志:1:系统内;2:系统外
        rd.setCurrency("CNY");
        rd.setAmount(new BigDecimal(money));//金额:无正负号,以分为单位
        rd.setPurpose("代收款");//用途描述
 
        list.add(rd);
        bizContent.setRd(list);
        request.setServiceUrl(url);
        request.setBizContent(bizContent);
        MybankEnterprisePayPayentResponseV1 response = client.execute(request);
        if (response.isSuccess()) {
            // 业务成功处理
            System.err.println("ReturnCode:"+response.getReturnCode());
            System.err.println("response:" + JSON.toJSONString(response));
            if(response.getReturnCode() == 0){
                return ResultUtil.success(response.getSerialNo());
            }else{
                return ResultUtil.error("转账申请提交失败(" + response.getReturnMsg() + ")");
            }
        } else {
            System.err.println("response:" + JSON.toJSONString(response));
            System.err.println("ReturnCode:"+response.getReturnCode());
            System.err.println("ReturnMsg:"+response.getReturnMsg());
            return ResultUtil.error("转账申请提交失败(" + response.getReturnMsg() + ")");
        }
    }
 
 
    */
/**
     * 查询转账交易状态
     * @param serialNo      转账申请序列号(转账接口返回)
     * @return              -1=查询异常,0=交易成功,1=交易处理中,2=交易拒绝
     *//*
 
    public Integer queryTransfer(String serialNo){
        String url = "https://gw.open.icbc.com.cn/api/mybank/enterprise/pay/qpayent/V1";
        DefaultIcbcClient client = new DefaultIcbcClient(app_id, IcbcConstants.SIGN_TYPE_RSA2, privateKey, icbcPulicKey);
        try {
            MybankEnterprisePayQpayentRequestV1.MybankEnterprisePayQpayentRequestBizV1 bizContent =
                    new MybankEnterprisePayQpayentRequestV1.MybankEnterprisePayQpayentRequestBizV1();
            MybankEnterprisePayQpayentRequestV1 request = new MybankEnterprisePayQpayentRequestV1();
            Date date = new Date();
            SimpleDateFormat sdf1 = new SimpleDateFormat("yyyyMMdd");
            SimpleDateFormat sdf2 = new SimpleDateFormat("HHmmssSSS");
            bizContent.setTransCode("QPAYPER");//交易代码
            bizContent.setTranDate(sdf1.format(date));//交易日期:ERP系统产生,格式是yyyyMMdd
            bizContent.setTranTime(sdf2.format(date));//交易时间:ERP系统产生,格式如HHmmssSSS,精确到毫秒
            bizContent.setLanguage("zh_CN");
            bizContent.setfSeqNo(UUIDUtil.getRandomCode());//指令包序列号:ERP系统产生,一个集团永远不能重复
            bizContent.setQryfSeqno("");//待查指令包序列号:判断待查指令包序列号和待查平台交易流水号必须至少有一项有值
            bizContent.setQrySerialNo(serialNo);//待查平台交易序列号
            request.setServiceUrl(url);
            request.setBizContent(bizContent);
            MybankEnterprisePayQpayentResponseV1 response = client.execute(request);
            if (response.isSuccess()) {
                int returnCode = response.getReturnCode();//返回码,交易成功返回0,正表示业务报错,负表示系统报错,负值时须考虑疑帐
                String returnMsg = response.getReturnMsg();//返回说明
                if(0 == returnCode){
                    List<MybankEnterprisePayQpayentResponseV1.MybankEnterprisePayQpayentResponseRdV1> rd = response.getRd();
                    MybankEnterprisePayQpayentResponseV1.MybankEnterprisePayQpayentResponseRdV1 bank = rd.get(0);
                    String result = bank.getResult();//指令状态:0:提交成功,等待银行处理 1:授权成功, 等待银行处理 2:等待授权 3:等待二次授权 4:等待银行答复 5:主机返回待处理 6:被银行拒绝 7:处理成功 8:指令被拒绝授权 9:银行正在处理 10:预约指令 11:预约取消 86:等待电话核实 95:待核查 98:区域中心通讯可疑
                    if(result.equals("7")){//交易成功
                        return 0;
                    }
                    if(result.equals("6") || result.equals("8")){//交易拒绝
                        return 2;
                    }
                    return 1;//交易处理中
                }else{
                    System.err.println(returnMsg);
                    return -1;
                }
            } else {
                return -1;
            }
        } catch (Exception e) {
            e.printStackTrace();
            return -1;
        }
    }
 
 
    */
/**
     * 获取扫码支付二维码(客户扫商户二维码)
     * @param out_trade_no      商户系统订单号
     * @param order_amt         订单金额
     * @param orderTime         订单生成时间
     * @param attach            附加信息
     * @param notify_url        支付成功回调地址
     * @return
     * @throws Exception
     *//*
 
    public ResultUtil<Map<String, Object>> generate(String out_trade_no, Double order_amt, Date orderTime, String attach, String notify_url) throws Exception{
        order_amt = order_amt * 100;
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        SimpleDateFormat sdf1 = new SimpleDateFormat("HHmmss");
        //签名类型为RSA2时,需传入appid,私钥和网关公钥,签名类型使用定值IcbcConstants.SIGN_TYPE_RSA2,其他参数使用缺省值
        DefaultIcbcClient client = new DefaultIcbcClient(app_id, IcbcConstants.SIGN_TYPE_RSA2, privateKey, icbcPulicKey);
        QrcodeGenerateRequestV2 request = new QrcodeGenerateRequestV2();
        request.setServiceUrl("https://gw.open.icbc.com.cn/api/qrcode/V2/generate");
        QrcodeGenerateRequestV2.QrcodeGenerateRequestV2Biz bizContent = new QrcodeGenerateRequestV2.QrcodeGenerateRequestV2Biz();
        bizContent.setMerId(mer_id1);
        bizContent.setStoreCode("21050022636");//E生活编号
        bizContent.setOutTradeNo(out_trade_no);
        bizContent.setOrderAmt(order_amt.intValue() + "");
        bizContent.setTradeDate(sdf.format(orderTime));
        bizContent.setTradeTime(sdf1.format(orderTime));
        bizContent.setAttach(attach);//该字段非必输项
        bizContent.setPayExpire("1200");
        bizContent.setNotifyUrl(notify_url);//该字段非必输项
        bizContent.setTporderCreateIp(InetAddress.getLocalHost().getHostAddress());
        bizContent.setSpFlag("0");//该字段非必输项
        bizContent.setNotifyFlag("1");
        request.setBizContent(bizContent);
        QrcodeGenerateResponseV2 response = client.execute(request, System.currentTimeMillis()+"");
        if (response.isSuccess()) {
            // 业务成功处理
            System.out.println("ReturnCode:"+response.getReturnCode());
            System.out.println("response:" + response);
            Map<String, Object> map = new HashMap<>();
            map.put("qrcode", response.getQrcode());
            map.put("attach", response.getAttach());
            return ResultUtil.success(map);
        } else {
            // 失败
            System.out.println("ReturnCode:" + response.getReturnCode());
            System.out.println("ReturnMsg:" + response.getReturnMsg());
            return ResultUtil.error("获取支付二维码失败(" + response.getReturnMsg() + ")");
        }
    }
 
 
    */
/**
     * 扫码支付成功回调客户扫商户二维码)
     * @param request
     * @return
     * @throws Exception
     *//*
 
    public Map<String, String> generatePayCallback(HttpServletRequest request) throws Exception{
        String biz_content1 = request.getParameter("biz_content");
        JSONObject biz_content = JSON.parseObject(biz_content1);
        int return_code = biz_content.getIntValue("return_code");
        String return_msg = biz_content.getString("return_msg");
        Map<String, String> map = new HashMap<>();
        if(return_code == 0){
            String out_trade_no = biz_content.getString("out_trade_no");//商家订单编号
            String order_id = biz_content.getString("order_id");//工行订单号
//            String third_trade_no = biz_content.getString("third_trade_no");//第三方订单号(微信/支付宝)
            String attach = biz_content.getString("attach");//附加信息
            String pay_time = biz_content.getString("pay_time");//支付完成时间"20190112"
 
            map.put("out_trade_no", out_trade_no);
            map.put("order_id", order_id);
//            map.put("third_trade_no", third_trade_no);
            map.put("attach", attach);
            map.put("pay_time", pay_time);
        }else{
            System.err.println("支付失败:" + return_msg);
        }
        return map;
    }
 
 
 
 
    */
/**
     * 退款申请
     * @param order_id          工行下单订单号(与“商户系统下单订单号”二选一)
     * @param out_trade_no      商户系统下单订单号(与“工行下单订单号”二选一)
     * @param ret_total_amt     退款金额
     * @param order_apd_inf     附加信息
     * @param outtrx_serial_no  外部退货流水号
     * @return
     * @throws Exception
     *//*
 
    public Map<String, Object> merrefund(String order_id, String out_trade_no, Double ret_total_amt, String order_apd_inf, String outtrx_serial_no) throws Exception{
        ret_total_amt = ret_total_amt * 100;
        //签名类型为RSA2时,需传入appid,私钥和网关公钥,签名类型使用定值IcbcConstants.SIGN_TYPE_RSA2,其他参数使用缺省值
        DefaultIcbcClient client = new DefaultIcbcClient(app_id, IcbcConstants.SIGN_TYPE_RSA2, privateKey, icbcPulicKey);
        CardbusinessAggregatepayB2cOnlineMerrefundRequestV1 request = new CardbusinessAggregatepayB2cOnlineMerrefundRequestV1();
        //根据测试环境和生产环境替换相应ip和端口
        request.setServiceUrl("https://gw.open.icbc.com.cn/api/cardbusiness/aggregatepay/b2c/online/merrefund/V1");
        //请对照接口文档用bizContent.setxxx()方法对业务上送数据进行赋值
        CardbusinessAggregatepayB2cOnlineMerrefundRequestV1.CardbusinessAggregatepayB2cOnlineMerrefundRequestV1Biz bizContent = new
                CardbusinessAggregatepayB2cOnlineMerrefundRequestV1.CardbusinessAggregatepayB2cOnlineMerrefundRequestV1Biz();
        request.setBizContent(bizContent);
        bizContent.setOrder_id(order_id);//消费工行订单号,工行订单号,商户订单号或行内订单号必须其中一个不为空
        bizContent.setMer_id(mer_id);//商户编号‐必输项
        bizContent.setOut_trade_no(out_trade_no);//商户订单号,工行订单号,商户订单号或行内订单号必须其中一个不为空
        bizContent.setOuttrx_serial_no(outtrx_serial_no);//外部退货流水号‐必输项
        bizContent.setRet_total_amt(ret_total_amt.intValue() + "");//退货总金额‐必输项
        bizContent.setTrnsc_ccy("001");//交易币种‐必输项
        bizContent.setOrder_apd_inf(order_apd_inf);//备注信息
        bizContent.setIcbc_appid(app_id);
        bizContent.setMer_acct("");
        CardbusinessAggregatepayB2cOnlineMerrefundResponseV1 response;
        Map<String, Object> map = new HashMap<>();
        try {
            response = client.execute(request, "msgId3");//msgId消息通讯唯一编号,要求每次调用独立生成,APP级唯一
            if (response.isSuccess()) {
                // 业务成功处理,请根据接口文档用response.getxxx()获取同步返回的业务数据
                System.out.println("ReturnCode:"+response.getReturnCode());
                System.out.println("ReturnCode:"+response.getReturnCode());
                System.out.println("response:" + response);
                map.put("intrx_serial_no", response.getIntrx_serial_no());//退货工行流水号
                map.put("code", response.getReturnCode());
                map.put("mag", response.getReturnMsg());
            } else {
                // 失败
                System.out.println("ReturnCode:"+response.getReturnCode());
                System.out.println("ReturnMsg:"+response.getReturnMsg());
                map.put("code", response.getReturnCode());
                map.put("mag", response.getReturnMsg());
            }
        } catch (IcbcApiException e) {
            e.printStackTrace();
        }
        return map;
    }
 
 
    */
/**
     * 退款查询
     * @param out_trade_no          商户系统消费下单订单号
     * @param order_id              工行消费下单订单号
     * @param outtrx_serial_no      商户系统退货编号
     * @return
     *//*
 
    public Map<String, Object> refundqry(String out_trade_no, String order_id, String outtrx_serial_no){
        // 签名类型为RSA时,需传入appid,私钥和网关公钥,签名类型使用定值IcbcConstants.SIGN_TYPE_RSA,其他参数使用缺省值
        DefaultIcbcClient client = new DefaultIcbcClient(app_id, IcbcConstants.SIGN_TYPE_RSA2, privateKey, icbcPulicKey);
        CardbusinessAggregatepayB2cOnlineRefundqryRequestV1 request = new CardbusinessAggregatepayB2cOnlineRefundqryRequestV1();
        // 根据测试环境和生产环境替换相应ip和端口
        request.setServiceUrl("https://gw.open.icbc.com.cn/api/cardbusiness/aggregatepay/b2c/online/refundqry/V1");
        CardbusinessAggregatepayB2cOnlineRefundqryRequestV1.CardbusinessAggregatepayB2cOnlineRefundqryRequestV1Biz bizContent = new
                CardbusinessAggregatepayB2cOnlineRefundqryRequestV1.CardbusinessAggregatepayB2cOnlineRefundqryRequestV1Biz();
        request.setBizContent(bizContent);
        // 请对照接口文档用bizContent.setxxx()方法对业务上送数据进行赋值
        bizContent.setMer_id(mer_id);
        bizContent.setOut_trade_no(out_trade_no);
        bizContent.setOuttrx_serial_no(outtrx_serial_no);
        bizContent.setOrder_id(order_id);
        CardbusinessAggregatepayB2cOnlineRefundqryResponseV1 response;
        Map<String, Object> map = new HashMap<>();
        try {
            response = client.execute(request, System.currentTimeMillis() + "");// msgId消息通讯唯一编号,要求每次调用独立生成,APP级唯一
            if (response.getReturnCode() == 0) {
                // 业务成功处理,请根据接口文档用response.getxxx()获取同步返回的业务数据
                System.out.println("ReturnCode:" + response.getReturnCode());
                System.out.println("response:" + JSON.toJSONString(response));
                map.put("code", response.getReturnCode());//0
                map.put("msg", response.getReturnMsg());
                map.put("pay_status", response.getPay_status());//订单状态说明:0-退货成功;1-退货失败;2-退货状态未知
            } else {
                // 失败
                System.out.println("response:" + JSON.toJSONString(response));
                System.out.println("ReturnCode:" + response.getReturnCode());
                System.out.println("ReturnMsg:" + response.getReturnMsg());
                map.put("code", response.getReturnCode());//0
                map.put("msg", response.getReturnMsg());
            }
        } catch (IcbcApiException e) {
            e.printStackTrace();
        }
        return map;
    }
 
 
 
 
    */
/**
     * 获取银行卡号归属地
     * @param code
     * @return
     *//*
 
    public Map<String, String> queryBank(String code){
        String url = "https://bankaddress.shumaidata.com/bankaddress?bankcard=" + code;
        Map<String, String> header = new HashMap<>();
        header.put("Authorization", "APPCODE b7d32437d08149099457dcb50fb57df2");
        String get = httpClientUtil.pushHttpRequset("GET", url, null, header, "form");
        JSONObject jsonObject = JSON.parseObject(get);
        int code1 = jsonObject.getIntValue("code");
        Map<String, String> map = new HashMap<>();
        if(code1 == 200){
            map.put("msg", "success");
            JSONObject data = jsonObject.getJSONObject("data");
            map.put("province", data.getString("province"));//开通省
            map.put("city", data.getString("city"));//开通市
            map.put("abbreviation", data.getString("abbreviation"));//银行英文大写
            map.put("type", data.getString("type"));//卡类型(借记卡)
            map.put("bank", data.getString("bank"));//总行名称
        }else{
            map.put("msg", jsonObject.getString("msg"));
        }
        return map;
    }
}
*/