修复微信支付失败的bug(更改微信扫码轮训的查询方式)
Code Review By Rock Zhang
Showing
1 changed file
with
8 additions
and
45 deletions
@@ -9,8 +9,10 @@ use WebPlugin\Pay\Banks; | @@ -9,8 +9,10 @@ use WebPlugin\Pay\Banks; | ||
9 | use WebPlugin\Pay\PayFactory; | 9 | use WebPlugin\Pay\PayFactory; |
10 | use WebPlugin\Pay\Reqparams; | 10 | use WebPlugin\Pay\Reqparams; |
11 | use WebPlugin\Pay\Rspparams; | 11 | use WebPlugin\Pay\Rspparams; |
12 | +use WebPlugin\Pay\weixin\lib\WxPayApi; | ||
12 | use WebPlugin\Pay\weixin\lib\WxPayConfig; | 13 | use WebPlugin\Pay\weixin\lib\WxPayConfig; |
13 | use WebPlugin\Pay\weixin\lib\WxPayNativePay; | 14 | use WebPlugin\Pay\weixin\lib\WxPayNativePay; |
15 | +use WebPlugin\Pay\weixin\lib\WxPayOrderQuery; | ||
14 | use WebPlugin\Pay\weixin\lib\WxPayUnifiedOrder; | 16 | use WebPlugin\Pay\weixin\lib\WxPayUnifiedOrder; |
15 | 17 | ||
16 | /** | 18 | /** |
@@ -403,46 +405,6 @@ class PayModel | @@ -403,46 +405,6 @@ class PayModel | ||
403 | return $result; | 405 | return $result; |
404 | } | 406 | } |
405 | 407 | ||
406 | - | ||
407 | - /** | ||
408 | - * 处理支付结果数据 | ||
409 | - * | ||
410 | - * @param int $uid 用户ID | ||
411 | - * @param string $orderCode 订单号 | ||
412 | - * @return array | ||
413 | - */ | ||
414 | - public static function getPayDetail($uid, $orderCode) | ||
415 | - { | ||
416 | - $result = array( | ||
417 | - 'code' => 500, | ||
418 | - 'message' => '支付失败' | ||
419 | - ); | ||
420 | - | ||
421 | - do { | ||
422 | - $orderInfo = OrderData::getOrderDetail($uid, $orderCode); | ||
423 | - if (!isset($orderInfo['data']['payment_status']) || $orderInfo['data']['payment_status'] !== 'Y') { | ||
424 | - break; | ||
425 | - } | ||
426 | - $result['code'] = 200; | ||
427 | - $result['message'] = '支付成功,请等待发货'; | ||
428 | - $orderData = $orderInfo['data']; | ||
429 | - $result['data'] = array( | ||
430 | - 'pay' => $orderData['payment_amount'], | ||
431 | - 'orderNum' => $orderData['order_code'], | ||
432 | - 'checkOrderUrl' => Helpers::url('/home/orders/detail', array('order_code' => $orderData['order_code'])), | ||
433 | - 'payMode' => ($orderData['payment_type'] == 1 ? '在线支付' : '货到付款'), | ||
434 | - 'currency' => $orderData['yoho_give_coin'], | ||
435 | - 'yohoCoinUrl' => Helpers::url('/help', array('category_id' => 87)), | ||
436 | - 'vipSum' => $orderData['order_code'], | ||
437 | - 'returnGoodsUrl' => Helpers::url('/help', array('category_id' => 121)), | ||
438 | - 'vipUrl' => Helpers::url('/help', array('category_id' => 91)), | ||
439 | - 'returnHomeUrl' => Helpers::url('/') | ||
440 | - ); | ||
441 | - } while (false); | ||
442 | - | ||
443 | - return $result; | ||
444 | - } | ||
445 | - | ||
446 | /** | 408 | /** |
447 | * 检查微信扫码支付结果 | 409 | * 检查微信扫码支付结果 |
448 | * | 410 | * |
@@ -462,12 +424,13 @@ class PayModel | @@ -462,12 +424,13 @@ class PayModel | ||
462 | break; | 424 | break; |
463 | } | 425 | } |
464 | 426 | ||
465 | - $orderInfo = OrderData::getOrderDetail($uid, $orderCode); | ||
466 | - if (!isset($orderInfo['data']) || empty($orderInfo['data'])) { | ||
467 | - break; | ||
468 | - } | 427 | + // 组装微信支付的订单号 |
428 | + $tradeNo = 'YOHOBuy_' . $orderCode; | ||
429 | + $input = new WxPayOrderQuery(); | ||
430 | + $input->SetOut_trade_no($tradeNo); | ||
431 | + $result = WxPayApi::orderQuery($input); | ||
469 | 432 | ||
470 | - if ($orderInfo['data']['payment_status'] === 'Y') { | 433 | + if (array_key_exists("return_code", $result) && array_key_exists("result_code", $result) && $result["return_code"] == "SUCCESS" && $result["result_code"] == "SUCCESS") { |
471 | $result = array( | 434 | $result = array( |
472 | 'code' => '200', | 435 | 'code' => '200', |
473 | 'message' => 'success' | 436 | 'message' => 'success' |
-
Please register or login to post a comment