Authored by LUOXC

FIXBUG

@@ -70,12 +70,12 @@ public abstract class AbstractWeixinPayService extends AbstractPayService { @@ -70,12 +70,12 @@ public abstract class AbstractWeixinPayService extends AbstractPayService {
70 public boolean notifyVerify(Map<String, String> paramsMap) { 70 public boolean notifyVerify(Map<String, String> paramsMap) {
71 //验证业务结果 71 //验证业务结果
72 String resultCode = paramsMap.get(WeixinPayConfig.ApiConstants.RETURN_RESULT_CODE); 72 String resultCode = paramsMap.get(WeixinPayConfig.ApiConstants.RETURN_RESULT_CODE);
73 - if(!WeixinPayConfig.ApiConstants.PREPAY_RESULT_SUCCESS.equals(resultCode)){ 73 + if (!WeixinPayConfig.ApiConstants.PREPAY_RESULT_SUCCESS.equals(resultCode)) {
74 log.error("[{}] trade failed, resultCode: {}", paramsMap.get("out_trade_no"), resultCode); 74 log.error("[{}] trade failed, resultCode: {}", paramsMap.get("out_trade_no"), resultCode);
75 return false; 75 return false;
76 } 76 }
77 77
78 - if(!verifySign(paramsMap)) { 78 + if (!verifySign(paramsMap)) {
79 log.error("[{}] sign verify failed", paramsMap.get("out_trade_no")); 79 log.error("[{}] sign verify failed", paramsMap.get("out_trade_no"));
80 return false; 80 return false;
81 } 81 }
@@ -84,8 +84,6 @@ public abstract class AbstractWeixinPayService extends AbstractPayService { @@ -84,8 +84,6 @@ public abstract class AbstractWeixinPayService extends AbstractPayService {
84 } 84 }
85 85
86 86
87 -  
88 -  
89 public PayQueryBo payQuery(String tradeNo, int orderCreateTime) { 87 public PayQueryBo payQuery(String tradeNo, int orderCreateTime) {
90 Map<String, String> queryParams = buildPayQureyParams(tradeNo); 88 Map<String, String> queryParams = buildPayQureyParams(tradeNo);
91 String requestXml = WXUtils.createWXPayXml(queryParams); 89 String requestXml = WXUtils.createWXPayXml(queryParams);
@@ -96,18 +94,18 @@ public abstract class AbstractWeixinPayService extends AbstractPayService { @@ -96,18 +94,18 @@ public abstract class AbstractWeixinPayService extends AbstractPayService {
96 94
97 private PayQueryBo queryConvert(String respXml) { 95 private PayQueryBo queryConvert(String respXml) {
98 PayQueryBo queryBo = new PayQueryBo(); 96 PayQueryBo queryBo = new PayQueryBo();
99 - if(StringUtils.isEmpty(respXml)) { 97 + if (StringUtils.isEmpty(respXml)) {
100 return queryBo; 98 return queryBo;
101 } 99 }
102 100
103 Map<String, String> queryMap = WXUtils.parseWXPayXml(respXml); 101 Map<String, String> queryMap = WXUtils.parseWXPayXml(respXml);
104 - if(queryMap == null || queryMap.isEmpty()) { 102 + if (queryMap == null || queryMap.isEmpty()) {
105 return queryBo; 103 return queryBo;
106 } 104 }
107 105
108 String returnCode = queryMap.get(WeixinPayConfig.ApiConstants.RETURN_CODE); 106 String returnCode = queryMap.get(WeixinPayConfig.ApiConstants.RETURN_CODE);
109 - String resultCode = queryMap.get(WeixinPayConfig.ApiConstants.RETURN_RESULT_CODE);  
110 - if(!"SUCCESS".equals(returnCode) || !"SUCCESS".equals(resultCode)) { 107 + String resultCode = queryMap.get(WeixinPayConfig.ApiConstants.RETURN_RESULT_CODE);
  108 + if (!"SUCCESS".equals(returnCode) || !"SUCCESS".equals(resultCode)) {
111 return queryBo; 109 return queryBo;
112 } 110 }
113 111
@@ -116,7 +114,7 @@ public abstract class AbstractWeixinPayService extends AbstractPayService { @@ -116,7 +114,7 @@ public abstract class AbstractWeixinPayService extends AbstractPayService {
116 queryBo.setPayStatus(payStatus); 114 queryBo.setPayStatus(payStatus);
117 queryBo.setRefundStatus(refundStatus); 115 queryBo.setRefundStatus(refundStatus);
118 116
119 - if( payStatus || refundStatus) { 117 + if (payStatus || refundStatus) {
120 String out_trade_no = queryMap.get("out_trade_no"); 118 String out_trade_no = queryMap.get("out_trade_no");
121 int index = out_trade_no.indexOf(WeixinPayConfig.WECHAT_TRADE_NO_PREFIX); 119 int index = out_trade_no.indexOf(WeixinPayConfig.WECHAT_TRADE_NO_PREFIX);
122 if (index >= 0) { 120 if (index >= 0) {
@@ -138,9 +136,9 @@ public abstract class AbstractWeixinPayService extends AbstractPayService { @@ -138,9 +136,9 @@ public abstract class AbstractWeixinPayService extends AbstractPayService {
138 } 136 }
139 137
140 138
141 -  
142 /** 139 /**
143 * 支付查询请求 140 * 支付查询请求
  141 + *
144 * @param tradeNo 142 * @param tradeNo
145 * @param requestXml 143 * @param requestXml
146 * @return 144 * @return
@@ -162,6 +160,7 @@ public abstract class AbstractWeixinPayService extends AbstractPayService { @@ -162,6 +160,7 @@ public abstract class AbstractWeixinPayService extends AbstractPayService {
162 160
163 /** 161 /**
164 * 支付查询请求参数 162 * 支付查询请求参数
  163 + *
165 * @param tradeNo 164 * @param tradeNo
166 * @return 165 * @return
167 */ 166 */
@@ -188,14 +187,14 @@ public abstract class AbstractWeixinPayService extends AbstractPayService { @@ -188,14 +187,14 @@ public abstract class AbstractWeixinPayService extends AbstractPayService {
188 return sign; 187 return sign;
189 } 188 }
190 189
191 - protected Map<String, String> withHmacSha256Sign(Map<String, String> signParams){ 190 + protected Map<String, String> withHmacSha256Sign(Map<String, String> signParams) {
192 signParams.put(WeixinPayConfig.ApiConstants.SIGN_TYPE, "HMAC-SHA256"); 191 signParams.put(WeixinPayConfig.ApiConstants.SIGN_TYPE, "HMAC-SHA256");
193 String sign = hmacSha256(signParams); 192 String sign = hmacSha256(signParams);
194 signParams.put(WeixinPayConfig.ApiConstants.SIGN, sign); 193 signParams.put(WeixinPayConfig.ApiConstants.SIGN, sign);
195 return signParams; 194 return signParams;
196 } 195 }
197 196
198 - protected Map<String, String> withHmacSha256SignWithoutSignType(Map<String, String> signParams){ 197 + protected Map<String, String> withHmacSha256SignWithoutSignType(Map<String, String> signParams) {
199 signParams.put(WeixinPayConfig.ApiConstants.SIGN_TYPE, "HMAC-SHA256"); 198 signParams.put(WeixinPayConfig.ApiConstants.SIGN_TYPE, "HMAC-SHA256");
200 String sign = hmacSha256(signParams); 199 String sign = hmacSha256(signParams);
201 signParams.put(WeixinPayConfig.ApiConstants.SIGN, sign); 200 signParams.put(WeixinPayConfig.ApiConstants.SIGN, sign);
@@ -251,7 +250,7 @@ public abstract class AbstractWeixinPayService extends AbstractPayService { @@ -251,7 +250,7 @@ public abstract class AbstractWeixinPayService extends AbstractPayService {
251 } 250 }
252 251
253 252
254 - public PayRefundBo refundOpenApi(PayRefundBo refundBo){ 253 + public PayRefundBo refundOpenApi(PayRefundBo refundBo) {
255 Map<String, String> queryParams = buildRefundParams(refundBo); 254 Map<String, String> queryParams = buildRefundParams(refundBo);
256 String requestXml = WXUtils.createWXPayXml(queryParams); 255 String requestXml = WXUtils.createWXPayXml(queryParams);
257 String respXml = sendRefundRequest(String.valueOf(refundBo.getPayOrderCode()), requestXml); 256 String respXml = sendRefundRequest(String.valueOf(refundBo.getPayOrderCode()), requestXml);
@@ -267,13 +266,13 @@ public abstract class AbstractWeixinPayService extends AbstractPayService { @@ -267,13 +266,13 @@ public abstract class AbstractWeixinPayService extends AbstractPayService {
267 return bo; 266 return bo;
268 } 267 }
269 268
270 - Map<String, String> reponseMap = WXUtils.parseWXPayXml(responseXml);  
271 - if(!"SUCCESS".equals(reponseMap.get("return_code"))) { 269 + Map<String, String> reponseMap = WXUtils.parseWXPayXml(responseXml);
  270 + if (!"SUCCESS".equals(reponseMap.get("return_code"))) {
272 bo.setRefundStatus(RefundContant.PAYMENT_REFUND_RESULTCODE_REQERR); 271 bo.setRefundStatus(RefundContant.PAYMENT_REFUND_RESULTCODE_REQERR);
273 bo.setRefundMsg(reponseMap.get("return_msg")); 272 bo.setRefundMsg(reponseMap.get("return_msg"));
274 return bo; 273 return bo;
275 } 274 }
276 - if(!"SUCCESS".equals(reponseMap.get("result_code"))) { 275 + if (!"SUCCESS".equals(reponseMap.get("result_code"))) {
277 bo.setRefundStatus(RefundContant.PAYMENT_REFUND_RESULTCODE_FAIL); 276 bo.setRefundStatus(RefundContant.PAYMENT_REFUND_RESULTCODE_FAIL);
278 bo.setRefundMsg(reponseMap.get("err_code") + ": " + reponseMap.get("err_code_des")); 277 bo.setRefundMsg(reponseMap.get("err_code") + ": " + reponseMap.get("err_code_des"));
279 return bo; 278 return bo;
@@ -289,6 +288,7 @@ public abstract class AbstractWeixinPayService extends AbstractPayService { @@ -289,6 +288,7 @@ public abstract class AbstractWeixinPayService extends AbstractPayService {
289 288
290 /** 289 /**
291 * 退款请求 290 * 退款请求
  291 + *
292 * @param requestXml 292 * @param requestXml
293 * @return 293 * @return
294 */ 294 */
@@ -297,7 +297,7 @@ public abstract class AbstractWeixinPayService extends AbstractPayService { @@ -297,7 +297,7 @@ public abstract class AbstractWeixinPayService extends AbstractPayService {
297 297
298 String respXml = ""; 298 String respXml = "";
299 HttpClient httpClient = getSslHttpClient(); 299 HttpClient httpClient = getSslHttpClient();
300 - if(httpClient == null) { 300 + if (httpClient == null) {
301 log.error("init weixin ssl httpclient faild, unable refund weixinpay"); 301 log.error("init weixin ssl httpclient faild, unable refund weixinpay");
302 return respXml; 302 return respXml;
303 } 303 }
@@ -315,16 +315,17 @@ public abstract class AbstractWeixinPayService extends AbstractPayService { @@ -315,16 +315,17 @@ public abstract class AbstractWeixinPayService extends AbstractPayService {
315 315
316 public JSONObject prepayRequest(OrderInfo orderInfo) { 316 public JSONObject prepayRequest(OrderInfo orderInfo) {
317 log.info("[{}] prepayRequest begin", orderInfo.getOrderCode()); 317 log.info("[{}] prepayRequest begin", orderInfo.getOrderCode());
318 - Map<String, String> requestParams = buildPrepayParams( orderInfo); 318 + Map<String, String> requestParams = buildPrepayParams(orderInfo);
319 String requestXml = WXUtils.createWXPayXml(requestParams); 319 String requestXml = WXUtils.createWXPayXml(requestParams);
320 String respXml = sendPrepayRequest(orderInfo.getOrderCode(), requestXml); 320 String respXml = sendPrepayRequest(orderInfo.getOrderCode(), requestXml);
321 - if(StringUtils.isEmpty(respXml)) { 321 + if (StringUtils.isEmpty(respXml)) {
322 log.error("[{}] prepayRequest failed", orderInfo.getOrderCode()); 322 log.error("[{}] prepayRequest failed", orderInfo.getOrderCode());
323 return null; 323 return null;
324 } 324 }
325 325
326 Map<String, String> reponseMap = WXUtils.parseWXPayXml(respXml); 326 Map<String, String> reponseMap = WXUtils.parseWXPayXml(respXml);
327 - if(!checkPrepayResponse(orderInfo.getOrderCode(), reponseMap)) { 327 + String requestSignType = requestParams.get(WeixinPayConfig.ApiConstants.SIGN_TYPE);
  328 + if (!checkPrepayResponse(orderInfo.getOrderCode(), reponseMap,requestSignType)) {
328 log.error("[{}] valid prepay response failed", orderInfo.getOrderCode()); 329 log.error("[{}] valid prepay response failed", orderInfo.getOrderCode());
329 return null; 330 return null;
330 } 331 }
@@ -344,8 +345,8 @@ public abstract class AbstractWeixinPayService extends AbstractPayService { @@ -344,8 +345,8 @@ public abstract class AbstractWeixinPayService extends AbstractPayService {
344 paramMap.put("out_refund_no", refundBo.getRefundOrderCode()); 345 paramMap.put("out_refund_no", refundBo.getRefundOrderCode());
345 346
346 //String totalFee = String.valueOf((int)YHMath.mul(amount, 100)); //微信金额必须以分为单位,且不能包含小数点 347 //String totalFee = String.valueOf((int)YHMath.mul(amount, 100)); //微信金额必须以分为单位,且不能包含小数点
347 - paramMap.put("total_fee", String.valueOf((int)YHMath.mul(refundBo.getOrderTotalFee(), 100)));  
348 - paramMap.put("refund_fee", String.valueOf((int)YHMath.mul(refundBo.getAmount(), 100))); 348 + paramMap.put("total_fee", String.valueOf((int) YHMath.mul(refundBo.getOrderTotalFee(), 100)));
  349 + paramMap.put("refund_fee", String.valueOf((int) YHMath.mul(refundBo.getAmount(), 100)));
349 paramMap.put("op_user_id", getMchId()); 350 paramMap.put("op_user_id", getMchId());
350 351
351 //签名 352 //签名
@@ -353,22 +354,20 @@ public abstract class AbstractWeixinPayService extends AbstractPayService { @@ -353,22 +354,20 @@ public abstract class AbstractWeixinPayService extends AbstractPayService {
353 } 354 }
354 355
355 356
356 -  
357 /** 357 /**
358 * 获取预支付的返回数据 358 * 获取预支付的返回数据
  359 + *
359 * @param requestParams 360 * @param requestParams
360 * @param responseParams 361 * @param responseParams
361 * @return 362 * @return
362 */ 363 */
363 protected JSONObject getPrepayData(Map<String, String> requestParams, Map<String, String> responseParams) { 364 protected JSONObject getPrepayData(Map<String, String> requestParams, Map<String, String> responseParams) {
364 JSONObject prepayJson = null; 365 JSONObject prepayJson = null;
365 - if(WeixinPayConfig.TRADE_TYPE_NATIVE.equals(getTradeType())) { 366 + if (WeixinPayConfig.TRADE_TYPE_NATIVE.equals(getTradeType())) {
366 prepayJson = getNativePrepayData(requestParams, responseParams); 367 prepayJson = getNativePrepayData(requestParams, responseParams);
367 - }  
368 - else if(WeixinPayConfig.TRADE_TYPE_JSAPI.equals(getTradeType())) { 368 + } else if (WeixinPayConfig.TRADE_TYPE_JSAPI.equals(getTradeType())) {
369 prepayJson = getJSAPIPrepayData(requestParams, responseParams); 369 prepayJson = getJSAPIPrepayData(requestParams, responseParams);
370 - }  
371 - else { 370 + } else {
372 prepayJson = getAppPrepayData(requestParams, responseParams); 371 prepayJson = getAppPrepayData(requestParams, responseParams);
373 } 372 }
374 return prepayJson; 373 return prepayJson;
@@ -377,13 +376,14 @@ public abstract class AbstractWeixinPayService extends AbstractPayService { @@ -377,13 +376,14 @@ public abstract class AbstractWeixinPayService extends AbstractPayService {
377 376
378 /** 377 /**
379 * 返回扫码预支付 378 * 返回扫码预支付
  379 + *
380 * @param requestParams 380 * @param requestParams
381 * @param responseParams 381 * @param responseParams
382 * @return 382 * @return
383 */ 383 */
384 private JSONObject getNativePrepayData(Map<String, String> requestParams, Map<String, String> responseParams) { 384 private JSONObject getNativePrepayData(Map<String, String> requestParams, Map<String, String> responseParams) {
385 String codeUrl = responseParams.get(WeixinPayConfig.ApiConstants.RETURN_CODE_URL); 385 String codeUrl = responseParams.get(WeixinPayConfig.ApiConstants.RETURN_CODE_URL);
386 - if(StringUtils.isEmpty(codeUrl)) { 386 + if (StringUtils.isEmpty(codeUrl)) {
387 log.error("[{}] obtain codeUrl failed", requestParams.get(WeixinPayConfig.ApiConstants.OUT_TRADE_NO)); 387 log.error("[{}] obtain codeUrl failed", requestParams.get(WeixinPayConfig.ApiConstants.OUT_TRADE_NO));
388 return null; 388 return null;
389 } 389 }
@@ -399,7 +399,7 @@ public abstract class AbstractWeixinPayService extends AbstractPayService { @@ -399,7 +399,7 @@ public abstract class AbstractWeixinPayService extends AbstractPayService {
399 */ 399 */
400 private JSONObject getJSAPIPrepayData(Map<String, String> requestParams, Map<String, String> responseParams) { 400 private JSONObject getJSAPIPrepayData(Map<String, String> requestParams, Map<String, String> responseParams) {
401 String prepayId = responseParams.get(WeixinPayConfig.ApiConstants.RETURN_PREPAY_ID); 401 String prepayId = responseParams.get(WeixinPayConfig.ApiConstants.RETURN_PREPAY_ID);
402 - if(StringUtils.isEmpty(prepayId)) { 402 + if (StringUtils.isEmpty(prepayId)) {
403 log.error("[{}] obtain prepayId failed", requestParams.get(WeixinPayConfig.ApiConstants.OUT_TRADE_NO)); 403 log.error("[{}] obtain prepayId failed", requestParams.get(WeixinPayConfig.ApiConstants.OUT_TRADE_NO));
404 return null; 404 return null;
405 } 405 }
@@ -426,13 +426,12 @@ public abstract class AbstractWeixinPayService extends AbstractPayService { @@ -426,13 +426,12 @@ public abstract class AbstractWeixinPayService extends AbstractPayService {
426 } 426 }
427 427
428 428
429 -  
430 /** 429 /**
431 * 组织预支付返回给APP的数据 430 * 组织预支付返回给APP的数据
432 */ 431 */
433 private JSONObject getAppPrepayData(Map<String, String> requestParams, Map<String, String> responseParams) { 432 private JSONObject getAppPrepayData(Map<String, String> requestParams, Map<String, String> responseParams) {
434 String prepayId = responseParams.get(WeixinPayConfig.ApiConstants.RETURN_PREPAY_ID); 433 String prepayId = responseParams.get(WeixinPayConfig.ApiConstants.RETURN_PREPAY_ID);
435 - if(StringUtils.isEmpty(prepayId)) { 434 + if (StringUtils.isEmpty(prepayId)) {
436 log.error("[{}] obtain prepayId failed", requestParams.get(WeixinPayConfig.ApiConstants.OUT_TRADE_NO)); 435 log.error("[{}] obtain prepayId failed", requestParams.get(WeixinPayConfig.ApiConstants.OUT_TRADE_NO));
437 return null; 436 return null;
438 } 437 }
@@ -450,7 +449,7 @@ public abstract class AbstractWeixinPayService extends AbstractPayService { @@ -450,7 +449,7 @@ public abstract class AbstractWeixinPayService extends AbstractPayService {
450 withHmacSha256SignWithoutSignType(prePayData); 449 withHmacSha256SignWithoutSignType(prePayData);
451 450
452 JSONObject sendData = new JSONObject(); 451 JSONObject sendData = new JSONObject();
453 - sendData.put("prePayUrl", weixinPayConfig.prepayUrl()); //实际上没用,为兼容APP,暂且保留 452 + sendData.put("prePayUrl", weixinPayConfig.prepayUrl()); //实际上没用,为兼容APP,暂且保留
454 sendData.put("token", "xxxxx"); //实际上没用,为兼容APP,暂且保留 453 sendData.put("token", "xxxxx"); //实际上没用,为兼容APP,暂且保留
455 sendData.put("prePayData", prePayData); 454 sendData.put("prePayData", prePayData);
456 455
@@ -461,30 +460,31 @@ public abstract class AbstractWeixinPayService extends AbstractPayService { @@ -461,30 +460,31 @@ public abstract class AbstractWeixinPayService extends AbstractPayService {
461 460
462 /** 461 /**
463 * 获取并校验预支付返回参数 462 * 获取并校验预支付返回参数
  463 + *
464 * @param orderCode 464 * @param orderCode
465 * @param reponseMap 465 * @param reponseMap
466 * @return 466 * @return
467 */ 467 */
468 - private boolean checkPrepayResponse(long orderCode, Map<String, String> reponseMap) {  
469 - if(reponseMap == null || reponseMap.size() == 0) { 468 + private boolean checkPrepayResponse(long orderCode, Map<String, String> reponseMap, String signType) {
  469 + if (reponseMap == null || reponseMap.size() == 0) {
470 log.error("[{}] Prepay response parse failed", orderCode); 470 log.error("[{}] Prepay response parse failed", orderCode);
471 return false; 471 return false;
472 } 472 }
473 473
474 String returnCode = reponseMap.get(WeixinPayConfig.ApiConstants.RETURN_CODE); 474 String returnCode = reponseMap.get(WeixinPayConfig.ApiConstants.RETURN_CODE);
475 - String resultCode = reponseMap.get(WeixinPayConfig.ApiConstants.RETURN_RESULT_CODE);  
476 - if(!WeixinPayConfig.ApiConstants.PREPAY_RESULT_SUCCESS.equals(returnCode)) { 475 + String resultCode = reponseMap.get(WeixinPayConfig.ApiConstants.RETURN_RESULT_CODE);
  476 + if (!WeixinPayConfig.ApiConstants.PREPAY_RESULT_SUCCESS.equals(returnCode)) {
477 log.error("[{}] prepay returnCode error: {}", orderCode, returnCode); 477 log.error("[{}] prepay returnCode error: {}", orderCode, returnCode);
478 return false; 478 return false;
479 } 479 }
480 480
481 //验证签名 481 //验证签名
482 - if(!verifySign(reponseMap)){ 482 + if (!verifySign(reponseMap, signType)) {
483 log.error("[{}] sign verify failed", orderCode); 483 log.error("[{}] sign verify failed", orderCode);
484 return false; 484 return false;
485 } 485 }
486 //return_code和result_code都为SUCCESS时,返回prepayId 486 //return_code和result_code都为SUCCESS时,返回prepayId
487 - if(!WeixinPayConfig.ApiConstants.PREPAY_RESULT_SUCCESS.equals(resultCode)){ 487 + if (!WeixinPayConfig.ApiConstants.PREPAY_RESULT_SUCCESS.equals(resultCode)) {
488 log.error("[{}] prepay resultCode error: {}", orderCode, resultCode); 488 log.error("[{}] prepay resultCode error: {}", orderCode, resultCode);
489 return false; 489 return false;
490 } 490 }
@@ -494,10 +494,13 @@ public abstract class AbstractWeixinPayService extends AbstractPayService { @@ -494,10 +494,13 @@ public abstract class AbstractWeixinPayService extends AbstractPayService {
494 494
495 495
496 public boolean verifySign(Map<String, String> paramsMap) { 496 public boolean verifySign(Map<String, String> paramsMap) {
  497 + return verifySign(paramsMap, paramsMap.get(WeixinPayConfig.ApiConstants.SIGN_TYPE));
  498 + }
  499 +
  500 + public boolean verifySign(Map<String, String> paramsMap, String signType) {
497 if (paramsMap == null) { 501 if (paramsMap == null) {
498 return false; 502 return false;
499 } 503 }
500 - String signType = paramsMap.get(WeixinPayConfig.ApiConstants.SIGN_TYPE);  
501 if (Objects.equals(signType, "HMAC-SHA256")) { 504 if (Objects.equals(signType, "HMAC-SHA256")) {
502 return hmacSha256(paramsMap).equals(paramsMap.get(WeixinPayConfig.ApiConstants.SIGN)); 505 return hmacSha256(paramsMap).equals(paramsMap.get(WeixinPayConfig.ApiConstants.SIGN));
503 } else { 506 } else {
@@ -507,6 +510,7 @@ public abstract class AbstractWeixinPayService extends AbstractPayService { @@ -507,6 +510,7 @@ public abstract class AbstractWeixinPayService extends AbstractPayService {
507 510
508 /** 511 /**
509 * 预支付请求 512 * 预支付请求
  513 + *
510 * @param orderCode 514 * @param orderCode
511 * @param requestXml 515 * @param requestXml
512 * @return 516 * @return
@@ -528,6 +532,7 @@ public abstract class AbstractWeixinPayService extends AbstractPayService { @@ -528,6 +532,7 @@ public abstract class AbstractWeixinPayService extends AbstractPayService {
528 532
529 /** 533 /**
530 * 生成预支付请求参数 534 * 生成预支付请求参数
  535 + *
531 * @param orderInfo 536 * @param orderInfo
532 * @return 537 * @return
533 */ 538 */
@@ -548,7 +553,7 @@ public abstract class AbstractWeixinPayService extends AbstractPayService { @@ -548,7 +553,7 @@ public abstract class AbstractWeixinPayService extends AbstractPayService {
548 parameters.put(WeixinPayConfig.ApiConstants.NOTIFY_URL, notifyURL); 553 parameters.put(WeixinPayConfig.ApiConstants.NOTIFY_URL, notifyURL);
549 //parameters.put(WeixinPayConfig.ApiConstants.TRADE_TYPE, "APP"); 554 //parameters.put(WeixinPayConfig.ApiConstants.TRADE_TYPE, "APP");
550 parameters.put(WeixinPayConfig.ApiConstants.TRADE_TYPE, getTradeType()); 555 parameters.put(WeixinPayConfig.ApiConstants.TRADE_TYPE, getTradeType());
551 - if(WeixinPayConfig.TRADE_TYPE_JSAPI.equals(getTradeType())) { 556 + if (WeixinPayConfig.TRADE_TYPE_JSAPI.equals(getTradeType())) {
552 parameters.put(WeixinPayConfig.ApiConstants.OPEN_ID, orderInfo.getOpenid()); 557 parameters.put(WeixinPayConfig.ApiConstants.OPEN_ID, orderInfo.getOpenid());
553 } 558 }
554 parameters.put(WeixinPayConfig.ApiConstants.TIME_EXPIRE, getPayExpireTimeStr(orderInfo)); 559 parameters.put(WeixinPayConfig.ApiConstants.TIME_EXPIRE, getPayExpireTimeStr(orderInfo));
@@ -561,9 +566,9 @@ public abstract class AbstractWeixinPayService extends AbstractPayService { @@ -561,9 +566,9 @@ public abstract class AbstractWeixinPayService extends AbstractPayService {
561 return withHmacSha256Sign(parameters); 566 return withHmacSha256Sign(parameters);
562 } 567 }
563 568
564 - private String getPayExpireTimeStr(OrderInfo orderInfo){ 569 + private String getPayExpireTimeStr(OrderInfo orderInfo) {
565 570
566 - int payExpireTime = DateUtil.getCurrentTimeSecond() + orderInfo.getPayExpireTime()*60; 571 + int payExpireTime = DateUtil.getCurrentTimeSecond() + orderInfo.getPayExpireTime() * 60;
567 // 超时时间秒 572 // 超时时间秒
568 return DateUtil.formatYYMMddHHmmss(payExpireTime); 573 return DateUtil.formatYYMMddHHmmss(payExpireTime);
569 574