PayData.php
8.75 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
<?php
namespace LibModels\Web\Product;
use Api\Sign;
use Api\Yohobuy;
/**
* 支付操作类
*
* @package LibModels\Web\Product
* @author Gtskk
* @copyright 2016/3/24 14:23 Gtskk<iamgtskk@gmail.com>
* @version: 0.0.1
*/
class PayData
{
/**
* 获取指定用户的订单数目
*
* @param int $uid 用户ID
* @return mixed
*/
public static function getOrderCountByUid($uid)
{
$param = Yohobuy::param();
$param['client_type'] = 'web';
$param['uid'] = intval($uid);
$param['private_key'] = Yohobuy::$privateKeyList['web'];
$param['method'] = 'web.SpaceOrders.getOrderCountByUid';
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 获取支付方式列表
*
* @return mixed
*/
public static function getPaymentList()
{
$param = Yohobuy::param();
$param['client_type'] = 'web';
$param['private_key'] = Yohobuy::$privateKeyList['web'];
$param['method'] = 'web.SpaceOrders.getPaymentList';
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 根据支付方式id获取单个支付方式有关信息
*
* @param int $id 支付方式id
* @return mixed
*/
public static function getPaymentById($id)
{
$param = Yohobuy::param();
$param['client_type'] = 'web';
$param['private_key'] = Yohobuy::$privateKeyList['web'];
$param['method'] = 'web.SpaceOrders.getPaymentById';
$param['id'] = $id;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* ERP提交订单状态
*
* @param string $orderCode 订单号
* @param int $payment 支付方式id
* @param string $bankName 银行名称
* @param string $bankCode 银行代码
* @param string $amount 金额
* @param string $payOrderCode 支付订单代码
* @param string $tradeNo 交易码
* @param string $bankBillNo 银行订单码
* @return mixed
*/
public static function submitOrderStatus($orderCode, $payment, $bankName, $bankCode, $amount, $payOrderCode, $tradeNo, $bankBillNo)
{
$param = Yohobuy::param();
$param['client_type'] = 'web';
$param['private_key'] = Yohobuy::$privateKeyList['web'];
$param['method'] = 'web.SpaceOrders.submitOrderStatus';
$param['order_code'] = $orderCode;
$param['payment'] = $payment;
$param['bank_name'] = $bankName;
$param['bank_code'] = $bankCode;
$param['amount'] = $amount;
$param['payOrderCode'] = $payOrderCode;
$param['trade_no'] = $tradeNo;
$param['bank_bill_no'] = $bankBillNo;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 更新订单的状态
*
* @param int $id 订单ID
* @param int $uid 用户ID
* @param int $payment 支付方式ID
* @param string $paymentStatus 支付状态(Y或者N)
* @param string $bankCode 银行代码
* @return mixed
*/
public static function updateOrderStatus($id, $uid, $payment, $paymentStatus, $bankCode)
{
$param = Yohobuy::param();
$param['client_type'] = 'web';
$param['private_key'] = Yohobuy::$privateKeyList['web'];
$param['method'] = 'web.SpaceOrders.updatePaymentStatus';
$param['id'] = $id;
$param['uid'] = $uid;
$param['payment'] = $payment;
$param['payment_status'] = $paymentStatus;
$param['bank_code'] = $bankCode;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 获取订单的支付银行
*
* @param string $orderCode 订单号
* @return mixed
*/
public static function getBankByOrder($orderCode)
{
$param = Yohobuy::param();
$param['client_type'] = 'web';
$param['private_key'] = Yohobuy::$privateKeyList['web'];
$param['method'] = 'web.SpaceOrders.getOrderPayBank';
$param['orderCode'] = $orderCode;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 添加订单支付银行记录
*
* @param string $orderCode 订单号
* @param int $payment 支付方式ID
* @param string $bankCode 银行码
* @return mixed
*/
public static function setOrderPayBank($orderCode, $payment, $bankCode)
{
$param = Yohobuy::param();
$param['client_type'] = 'web';
$param['private_key'] = Yohobuy::$privateKeyList['web'];
$param['method'] = 'web.SpaceOrders.addOrderPayBank';
$param['orderCode'] = $orderCode;
$param['payment'] = $payment;
$param['bankCode'] = $bankCode;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 更改订单支付银行记录
*
* @param string $orderCode 订单号
* @param int $payment 支付方式ID
* @param string $bankCode 银行码
* @return mixed
*/
public static function updateOrderPayBank($orderCode, $payment, $bankCode)
{
$param = Yohobuy::param();
$param['client_type'] = 'web';
$param['private_key'] = Yohobuy::$privateKeyList['web'];
$param['method'] = 'web.SpaceOrders.modifyOrderPayBank';
$param['orderCode'] = $orderCode;
$param['payment'] = $payment;
$param['bankCode'] = $bankCode;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 发送短信息(默认不传递area参数,传递了就是给特定国家码的手机号发送短信)
*
* @param string $mobile 手机号
* @param string $template 模板类型
* @param string $codes 对应模板中的参数
* @return mixed
*/
public static function sendMessage($mobile, $template, $codes)
{
$param = Yohobuy::param();
$param['client_type'] = 'web';
$param['private_key'] = Yohobuy::$privateKeyList['web'];
$param['method'] = 'app.message.sendMsg';
$param['mobile'] = $mobile;
$param['template'] = $template;
$param['codes'] = $codes;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 支付成功后--更新订单状态
* @param type string $orderCode 订单号
* @param type int $payment 支付方式
* @param type double $amount 金额(单位:元)
* @param type string $bankName 银行名称
* @param type string $bankCode 银行代码
* @param type string $tradeNo 交易流水号
* @param type string $bankBillNo 银行流水号
* @return type []
*/
public static function pcpayNotify($orderCode, $payment, $amount, $bankName = '', $bankCode = '', $tradeNo = '', $bankBillNo = '')
{
$param = Yohobuy::param();
$param['client_type'] = 'web';
$param['private_key'] = Yohobuy::$privateKeyList['web'];
$param['method'] = 'web.SpaceOrders.pcpayNotify';
$param['order_code'] = $orderCode;
$param['payment'] = $payment;
$param['bank_name'] = $bankName;
$param['bank_code'] = $bankCode;
$param['amount'] = $amount;
$param['trade_no'] = $tradeNo;
$param['bank_bill_no'] = $bankBillNo;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 支付成功后--支付确认接口
* @param type int $orderCode 订单号
* @param type int $paymentId 支付方式
* @param type int $uid 用户ID
* @return type []
*/
public static function payConfirm($orderCode, $paymentId, $uid)
{
// 构建必传参数
$param = Yohobuy::param();
$param['client_type'] = 'web';
$param['private_key'] = Yohobuy::$privateKeyList['web'];
$param['method'] = 'app.SpaceOrders.payConfirm';
$param['order_code'] = $orderCode;
$param['payment_id'] = $paymentId;
$param['uid'] = intval($uid);
$param['client_secret'] = Sign::getSign($param);
// 调用接口获得数据
return Yohobuy::post(Yohobuy::API_URL, $param);
}
}