Merge branch 'temp'
Showing
8 changed files
with
49 additions
and
40 deletions
@@ -359,7 +359,7 @@ class Helpers | @@ -359,7 +359,7 @@ class Helpers | ||
359 | $result['classification'] = $articleData['category_name']; | 359 | $result['classification'] = $articleData['category_name']; |
360 | $result['isReco'] = $articleData['is_recommended'] ? true : false; | 360 | $result['isReco'] = $articleData['is_recommended'] ? true : false; |
361 | $result['url'] = $isApp ? $articleData['url'] : self::url('/'.$articleData['id'].'.html', array(), 'guang'); | 361 | $result['url'] = $isApp ? $articleData['url'] : self::url('/'.$articleData['id'].'.html', array(), 'guang'); |
362 | - $result['img'] = self::getImageUrl($articleData['src'], $width, $height); | 362 | + $result['img'] = self::getImageUrl($articleData['src'], $width, $height, 1); |
363 | $result['isSquareImg'] = $isSquareImage; | 363 | $result['isSquareImg'] = $isSquareImage; |
364 | $result['title'] = $articleData['title']; | 364 | $result['title'] = $articleData['title']; |
365 | if(empty($articleData['author'])){ | 365 | if(empty($articleData['author'])){ |
@@ -6,6 +6,8 @@ use WebPlugin\Pay\PayAbstract; | @@ -6,6 +6,8 @@ use WebPlugin\Pay\PayAbstract; | ||
6 | use WebPlugin\Pay\Reqparams; | 6 | use WebPlugin\Pay\Reqparams; |
7 | use WebPlugin\Pay\Rspparams; | 7 | use WebPlugin\Pay\Rspparams; |
8 | use WebPlugin\Pay\Signature; | 8 | use WebPlugin\Pay\Signature; |
9 | +use WebPlugin\Pay\weixin\lib\WxPayApi; | ||
10 | +use WebPlugin\Pay\weixin\lib\WxPayOrderQuery; | ||
9 | 11 | ||
10 | class Service extends PayAbstract | 12 | class Service extends PayAbstract |
11 | { | 13 | { |
@@ -74,25 +76,33 @@ class Service extends PayAbstract | @@ -74,25 +76,33 @@ class Service extends PayAbstract | ||
74 | return array('pay_url' => $payUrl); | 76 | return array('pay_url' => $payUrl); |
75 | } | 77 | } |
76 | 78 | ||
77 | - public function parseResponse(array $arrResponse) { | 79 | + public function parseResponse(array $data) { |
78 | /* 返回示例 | 80 | /* 返回示例 |
79 | * http://www.yohobuy.com/pay/notice/wechatqrcodereturn?ordercode=93465435 | 81 | * http://www.yohobuy.com/pay/notice/wechatqrcodereturn?ordercode=93465435 |
80 | */ | 82 | */ |
83 | + // 组装微信支付的订单号 | ||
84 | + $tradeNo = 'YOHOBuy_' . $data['orderCode']; | ||
85 | + $input = new WxPayOrderQuery(); | ||
86 | + $input->SetOut_trade_no($tradeNo); | ||
87 | + $result = WxPayApi::orderQuery($input); | ||
88 | + | ||
81 | $rsp = new Rspparams(); | 89 | $rsp = new Rspparams(); |
82 | - if($arrResponse['payResult'] == 200){ | 90 | + // 支付成功 |
91 | + if(array_key_exists("return_code", $result) && array_key_exists("result_code", $result) && $result["return_code"] == "SUCCESS" && $result["result_code"] == "SUCCESS"){ | ||
83 | $rsp->payResult = 200; | 92 | $rsp->payResult = 200; |
84 | $rsp->bankName = "WX"; | 93 | $rsp->bankName = "WX"; |
85 | - $rsp->orderCode = $arrResponse['order_code']; | ||
86 | - $rsp->payTime = $arrResponse["arrive_time"]; | ||
87 | - $rsp->totalFee = $arrResponse["amount"]; | 94 | + $rsp->orderCode = $data['orderCode']; |
95 | + $rsp->payTime = $result["time_end"]; | ||
96 | + $rsp->totalFee = $result["total_fee"]; | ||
88 | $rsp->resultMsg = '支付成功'; | 97 | $rsp->resultMsg = '支付成功'; |
89 | //添加支付订单号和交易号 | 98 | //添加支付订单号和交易号 |
90 | - $rsp->payOrderCode = $arrResponse["order_code"]; | ||
91 | - $rsp->tradeNo = ""; | ||
92 | - $rsp->bankBillNo = ""; | 99 | + $rsp->payOrderCode = $data["orderCode"]; |
100 | + $rsp->tradeNo = $result["out_trade_no"]; | ||
101 | + $rsp->bankBillNo = $result['bank_type']; | ||
93 | }else{ | 102 | }else{ |
94 | $rsp->payResult = -1; | 103 | $rsp->payResult = -1; |
95 | } | 104 | } |
105 | + | ||
96 | return $rsp; | 106 | return $rsp; |
97 | } | 107 | } |
98 | 108 |
@@ -4,6 +4,7 @@ namespace WebPlugin\Pay\weixin; | @@ -4,6 +4,7 @@ namespace WebPlugin\Pay\weixin; | ||
4 | 4 | ||
5 | use WebPlugin\Pay\weixin\lib\WxPayApi; | 5 | use WebPlugin\Pay\weixin\lib\WxPayApi; |
6 | use WebPlugin\Pay\weixin\lib\WxPayNotify; | 6 | use WebPlugin\Pay\weixin\lib\WxPayNotify; |
7 | +use WebPlugin\Pay\weixin\lib\WxPayOrderQuery; | ||
7 | 8 | ||
8 | class PayNotifyCallBack extends WxPayNotify | 9 | class PayNotifyCallBack extends WxPayNotify |
9 | { | 10 | { |
@@ -31,7 +31,7 @@ class WxPayConfig | @@ -31,7 +31,7 @@ class WxPayConfig | ||
31 | const APPSECRET = 'ce21ae4a3f93852279175a167e54509b'; | 31 | const APPSECRET = 'ce21ae4a3f93852279175a167e54509b'; |
32 | //=======【异步通知url设置】=================================== | 32 | //=======【异步通知url设置】=================================== |
33 | //异步通知url,商户根据实际开发过程设定 | 33 | //异步通知url,商户根据实际开发过程设定 |
34 | - const NOTIFY_URL = 'http://www.yohobuy.com/pay/notice/wechatqrcodereturn'; | 34 | + const NOTIFY_URL = 'http://www.yohobuy.com/pay/notice/wechatqrcodenotify'; |
35 | //=======【证书路径设置】===================================== | 35 | //=======【证书路径设置】===================================== |
36 | /** | 36 | /** |
37 | * TODO:设置商户证书路径 | 37 | * TODO:设置商户证书路径 |
@@ -80,7 +80,7 @@ class WxPayNotify extends WxPayNotifyReply | @@ -80,7 +80,7 @@ class WxPayNotify extends WxPayNotifyReply | ||
80 | { | 80 | { |
81 | //如果需要签名 | 81 | //如果需要签名 |
82 | if ($needSign == true && | 82 | if ($needSign == true && |
83 | - $this->GetReturn_code($return_code) == "SUCCESS") { | 83 | + $this->GetReturn_code() == "SUCCESS") { |
84 | $this->SetSign(); | 84 | $this->SetSign(); |
85 | } | 85 | } |
86 | WxpayApi::replyNotify($this->ToXml()); | 86 | WxpayApi::replyNotify($this->ToXml()); |
@@ -62,6 +62,8 @@ class PayModel | @@ -62,6 +62,8 @@ class PayModel | ||
62 | $result['ordersUrl'] = Helpers::url('/home/orders'); | 62 | $result['ordersUrl'] = Helpers::url('/home/orders'); |
63 | // 退换货地址 | 63 | // 退换货地址 |
64 | $result['backGoodsUrl'] = Helpers::url('/help', array('category_id' => 121)); | 64 | $result['backGoodsUrl'] = Helpers::url('/help', array('category_id' => 121)); |
65 | + // 返回首页地址 | ||
66 | + $result['returnHomeUrl'] = Helpers::url('/'); | ||
65 | break; | 67 | break; |
66 | } | 68 | } |
67 | 69 | ||
@@ -340,10 +342,9 @@ class PayModel | @@ -340,10 +342,9 @@ class PayModel | ||
340 | * | 342 | * |
341 | * @param int $uid 用户ID | 343 | * @param int $uid 用户ID |
342 | * @param string $orderCode 订单号 | 344 | * @param string $orderCode 订单号 |
343 | - * @param int $paymentCode 支付方式ID | ||
344 | * @return array | 345 | * @return array |
345 | */ | 346 | */ |
346 | - public static function weixinQrcode($uid, $orderCode, $paymentCode) | 347 | + public static function weixinQrcode($uid, $orderCode) |
347 | { | 348 | { |
348 | $result = array(); | 349 | $result = array(); |
349 | 350 |
@@ -2,9 +2,9 @@ | @@ -2,9 +2,9 @@ | ||
2 | 2 | ||
3 | use Action\WebAction; | 3 | use Action\WebAction; |
4 | use Shopping\PayModel; | 4 | use Shopping\PayModel; |
5 | -use WebPlugin\Helpers; | ||
6 | use WebPlugin\Pay\PayFactory; | 5 | use WebPlugin\Pay\PayFactory; |
7 | use WebPlugin\Pay\Rspparams; | 6 | use WebPlugin\Pay\Rspparams; |
7 | +use WebPlugin\Pay\weixin\PayNotifyCallBack; | ||
8 | 8 | ||
9 | /** | 9 | /** |
10 | * 支付Notice | 10 | * 支付Notice |
@@ -237,24 +237,34 @@ class NoticeController extends WebAction | @@ -237,24 +237,34 @@ class NoticeController extends WebAction | ||
237 | } | 237 | } |
238 | 238 | ||
239 | /** | 239 | /** |
240 | - * 微信扫码支付返回返回 | 240 | + * 微信扫码支付结果商户通知地址 |
241 | */ | 241 | */ |
242 | - public function wechatqrcodereturnAction() | 242 | + public function wechatqrcodenotifyAction() |
243 | { | 243 | { |
244 | - //判断是否登录 | ||
245 | - $uid = $this->auditJumpLogin(); | 244 | + $notify = new PayNotifyCallBack(); |
245 | + $notify->handle(false); | ||
246 | + } | ||
246 | 247 | ||
247 | - do { | ||
248 | - $orderCode = isset($_GET['order_code']) ? $_GET['order_code'] : 0; | ||
249 | - if (empty($orderCode)) { | 248 | + /** |
249 | + * 微信扫码支付返回 | ||
250 | + */ | ||
251 | + public function wechatqrcodereturnAction() | ||
252 | + { | ||
250 | $dealResult = array( | 253 | $dealResult = array( |
251 | 'code' => 500, | 254 | 'code' => 500, |
252 | 'message' => '支付失败' | 255 | 'message' => '支付失败' |
253 | ); | 256 | ); |
257 | + | ||
258 | + do { | ||
259 | + $orderCode = isset($_GET['order_code']) ? $_GET['order_code'] : 0; | ||
260 | + if (empty($orderCode)) { | ||
254 | break; | 261 | break; |
255 | } | 262 | } |
256 | 263 | ||
257 | - $dealResult = PayModel::getPayDetail($uid, $orderCode); | 264 | + $payment = PayModel::getPaymentById(21); |
265 | + $payService = PayFactory::factory($payment); | ||
266 | + $res = $payService->parseResponse(array('orderCode' => $orderCode)); | ||
267 | + $dealResult = $this->payResultProc($res, 21); | ||
258 | $dealResult['payData'] = array('payWay' => '微信扫码支付'); | 268 | $dealResult['payData'] = array('payWay' => '微信扫码支付'); |
259 | } while (false); | 269 | } while (false); |
260 | 270 | ||
@@ -266,23 +276,11 @@ class NoticeController extends WebAction | @@ -266,23 +276,11 @@ class NoticeController extends WebAction | ||
266 | */ | 276 | */ |
267 | public function unionpaywebreturnAction() | 277 | public function unionpaywebreturnAction() |
268 | { | 278 | { |
269 | - //判断是否登录 | ||
270 | - $uid = $this->auditJumpLogin(); | ||
271 | - | ||
272 | - do { | ||
273 | - $orderCode = isset($_GET['order_code']) ? $_GET['order_code'] : 0; | ||
274 | - if (empty($orderCode)) { | ||
275 | - $dealResult = array( | ||
276 | - 'code' => 500, | ||
277 | - 'message' => '支付失败' | ||
278 | - ); | ||
279 | - break; | ||
280 | - } | ||
281 | - | ||
282 | - $dealResult = PayModel::getPayDetail($uid, $orderCode); | 279 | + $payment = PayModel::getPaymentById(25); |
280 | + $payService = PayFactory::factory($payment); | ||
281 | + $res = $payService->parseResponse($_REQUEST); | ||
282 | + $dealResult = $this->payResultProc($res, 25); | ||
283 | $dealResult['payData'] = array('payWay' => '银联在线支付'); | 283 | $dealResult['payData'] = array('payWay' => '银联在线支付'); |
284 | - } while (false); | ||
285 | - | ||
286 | $this->commonShowResult($dealResult); | 284 | $this->commonShowResult($dealResult); |
287 | } | 285 | } |
288 | 286 |
@@ -19,8 +19,7 @@ class WechatqrcodeController extends WebAction | @@ -19,8 +19,7 @@ class WechatqrcodeController extends WebAction | ||
19 | } | 19 | } |
20 | 20 | ||
21 | $orderCode = $this->get('order_code', $this->get('ordercode')); | 21 | $orderCode = $this->get('order_code', $this->get('ordercode')); |
22 | - $paymentCode = $this->get('payment_code'); | ||
23 | - $data = PayModel::weixinQrcode($uid, $orderCode, $paymentCode); | 22 | + $data = PayModel::weixinQrcode($uid, $orderCode); |
24 | if (isset($data['error'])) { | 23 | if (isset($data['error'])) { |
25 | $this->helpJsRedirect($data['message']); | 24 | $this->helpJsRedirect($data['message']); |
26 | } | 25 | } |
-
Please register or login to post a comment