@@ -382,37 +382,44 @@ public WxEntPayQueryResult queryEntPay(String partnerTradeNo) throws WxErrorExce
382
382
383
383
@ Override
384
384
public byte [] createScanPayQrcodeMode1 (String productId , File logoFile , Integer sideLength ) {
385
- //weixin://wxpay/bizpayurl?sign=XXXXX&appid=XXXXX&mch_id=XXXXX&product_id=XXXXXX&time_stamp=XXXXXX&nonce_str=XXXXX
385
+ String content = createScanPayQrcodeMode1 (productId );
386
+ return createQrcode (content , logoFile , sideLength );
387
+ }
388
+
389
+ @ Override
390
+ public String createScanPayQrcodeMode1 (String productId ){
391
+ //weixin://wxpay/bizpayurl?sign=XXXXX&appid=XXXXX&mch_id=XXXXX&product_id=XXXXXX&time_stamp=XXXXXX&nonce_str=XXXXX
386
392
StringBuilder codeUrl = new StringBuilder ("weixin://wxpay/bizpayurl?" );
387
393
Map <String , String > params = Maps .newHashMap ();
388
394
params .put ("appid" , this .getConfig ().getAppId ());
389
395
params .put ("mch_id" , this .getConfig ().getMchId ());
390
396
params .put ("product_id" , productId );
391
- params .put ("time_stamp" , String .valueOf (System .currentTimeMillis ()));
397
+ params .put ("time_stamp" , String .valueOf (System .currentTimeMillis () / 1000 ));//这里需要秒,10位数字
392
398
params .put ("nonce_str" , String .valueOf (System .currentTimeMillis ()));
393
399
394
400
String sign = this .createSign (params );
395
401
params .put ("sign" , sign );
396
402
403
+
397
404
for (String key : params .keySet ()) {
398
405
codeUrl .append (key + "=" + params .get (key ) + "&" );
399
406
}
400
407
401
408
String content = codeUrl .toString ().substring (0 , codeUrl .length () - 1 );
402
- if (sideLength == null || sideLength < 1 ) {
403
- return QrcodeUtils .createQrcode (content , logoFile );
404
- }
405
-
406
- return QrcodeUtils .createQrcode (content , sideLength , logoFile );
409
+ log .debug ("扫码支付模式一生成二维码的URL:{}" ,content );
410
+ return content ;
407
411
}
408
412
409
413
@ Override
410
414
public byte [] createScanPayQrcodeMode2 (String codeUrl , File logoFile , Integer sideLength ) {
411
- if (sideLength == null || sideLength < 1 ) {
412
- return QrcodeUtils .createQrcode (codeUrl , logoFile );
415
+ return createQrcode (codeUrl , logoFile , sideLength );
416
+ }
417
+
418
+ private byte [] createQrcode (String content , File logoFile , Integer sideLength ) {
419
+ if (sideLength == null || sideLength < 1 ) {
420
+ return QrcodeUtils .createQrcode (content , logoFile );
413
421
}
414
-
415
- return QrcodeUtils .createQrcode (codeUrl , sideLength , logoFile );
422
+ return QrcodeUtils .createQrcode (content , sideLength , logoFile );
416
423
}
417
424
418
425
public void report (WxPayReportRequest request ) throws WxErrorException {
0 commit comments