Payment.php
3.62 KB
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
<?php
namespace Shopping;
use LibModels\Web\Home\OrderData;
use LibModels\Web\Product\PayData;
use Plugin\Helpers;
use WebPlugin\Cache;
use WebPlugin\Pay\Banks;
use WebPlugin\Pay\PayFactory;
use WebPlugin\Pay\Reqparams;
use WebPlugin\Pay\Rspparams;
use WebPlugin\Pay\weixin\lib\WxPayApi;
use WebPlugin\Pay\weixin\lib\WxPayConfig;
use WebPlugin\Pay\weixin\lib\WxPayNativePay;
use WebPlugin\Pay\weixin\lib\WxPayOrderQuery;
use WebPlugin\Pay\weixin\lib\WxPayUnifiedOrder;
/**
* 支付有关方法 改版
* @copyright 2016/5/22 14:19 xiaoxiao<xiaoxiao.hao@yoho.cn>
*/
class PaymentModel
{
protected static $code = array(
'code' => 500,
'message' => '支付失败'
);
// 存储的UID键名
const SESSION_UID_KEY = 'payUserid';
public static function procOrderData($payResult)
{
do {
if (empty($payResult->orderCode)) {
self::$code['message'] = '未查到订单信息,订单状态更新失败!';
break;
}
$orderCode = $payResult->orderCode;
$uid = '';
if (USE_CACHE) {
// 通过订单号,从缓存记录中获取uid
$uid = Cache::get(self::SESSION_UID_KEY . $orderCode);
}
$orderInfo = OrderData::getOrderDetail($uid, $payResult->orderCode);
if (empty($orderInfo['data'])) {
self::$code['message'] = '未查到订单信息,订单状态更新失败!';
break;
}
$orderData = $orderInfo['data'];
$amount = $orderData['payment_amount'];
if ($orderData['is_cancel'] === 'Y') {
// 给用户发送短信
PayData::sendMessage($orderData['mobile'], 'error_sms', '支付成功,但订单已取消,订单号为' . $orderCode);
self::$code['code'] = 417;
self::$code['message'] = '支付成功,但订单已取消,需联系客服!';
break;
}
// if ($orderData['payment_status'] === 'N') {
// logup::info(
// '用户支付成功,同步地址返回,查询订单状态为未付款,有可能异步地址还未即时更新状态',
// array('payResult' => $payResult, 'orderData' => $orderData)
// );
// }
// 支付金额与订单金额不一致
if (round($amount, 2) !== round($payResult->totalFee, 2)) {
self::$code['code'] = 415;
self::$code['message'] = '支付金额与订单金额不一致,订单状态更新失败!';
break;
}
self::$code['code'] = 200;
self::$code['message'] = '支付成功,请等待发货';
self::$code['data'] = array(
'pay' => $amount,
'orderNum' => $orderData['order_code'],
'checkOrderUrl' => Helpers::url('/home/orders/detail', array('orderCode' => $orderData['order_code'])),
'payMode' => ($orderData['payment_type'] == 1 ? '在线支付' : '货到付款'),
'currency' => $orderData['yoho_give_coin'],
'yohoCoinUrl' => Helpers::url('/help', array('category_id' => 87)),
'ordersUrl' => Helpers::url('/home/orders'),
'returnGoodsUrl' => Helpers::url('/help', array('category_id' => 121)),
'vipSum' => $amount,
'vipUrl' => Helpers::url('/help', array('category_id' => 91)),
'returnHomeUrl' => Helpers::url('/')
);
} while (false);
return self::$code;
}
}