1 | <?php |
||
2 | namespace zhangv\wechat\pay\service; |
||
3 | use \zhangv\wechat\pay\WechatPay; |
||
4 | use \Exception; |
||
5 | |||
6 | /** |
||
7 | * 代金券 |
||
8 | * @license MIT |
||
9 | * @zhangv |
||
10 | * @link https://pay.weixin.qq.com/wiki/doc/api/tools/sp_coupon.php?chapter=12_1 |
||
11 | * |
||
12 | */ |
||
13 | class Coupon extends WechatPay { |
||
14 | |||
15 | /** |
||
16 | * 发放代金券 |
||
17 | * @param $coupon_stock_id |
||
18 | * @param $open_id |
||
19 | * @param $partner_trade_no |
||
20 | * @param string $op_user_id |
||
21 | * @param array $ext |
||
22 | * @return array |
||
23 | * @throws Exception |
||
24 | */ |
||
25 | 2 | public function sendCoupon($coupon_stock_id,$open_id,$partner_trade_no,$op_user_id = '',$ext = array()){ |
|
26 | 2 | $data = (!empty($ext) && is_array($ext))?$ext:array(); |
|
27 | 2 | $data["partner_trade_no"] = $partner_trade_no; |
|
28 | 2 | $data["coupon_stock_id"] = $coupon_stock_id; |
|
29 | 2 | $data["openid_count"] = 1; |
|
30 | 2 | $data["open_id"] = $open_id; |
|
31 | 2 | $data["op_user_id"] = $op_user_id; |
|
32 | 2 | return $this->post(self::URL_SEND_COUPON,$data,true); |
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
33 | } |
||
34 | |||
35 | /** |
||
36 | * 查询代金券批次 |
||
37 | * @param $coupon_stock_id |
||
38 | * @param string $op_user_id |
||
39 | * @return array |
||
40 | * @throws Exception |
||
41 | */ |
||
42 | 1 | public function queryCouponStock($coupon_stock_id,$op_user_id = ''){ |
|
43 | 1 | $data = array(); |
|
44 | 1 | $data["coupon_stock_id"] = $coupon_stock_id; |
|
45 | 1 | $data["op_user_id"] = $op_user_id; |
|
46 | 1 | return $this->post(self::URL_QUERY_COUPON_STOCK,$data,false); |
|
0 ignored issues
–
show
|
|||
47 | } |
||
48 | |||
49 | /** |
||
50 | * 查询代金券信息 |
||
51 | * @param $coupon_id |
||
52 | * @param $open_id |
||
53 | * @param $stock_id |
||
54 | * @param string $op_user_id |
||
55 | * @param array $ext |
||
56 | * @return array |
||
57 | * @throws Exception |
||
58 | */ |
||
59 | 1 | public function queryCouponsInfo($coupon_id,$open_id,$stock_id,$op_user_id = '',$ext = array()){ |
|
60 | 1 | $data = (!empty($ext) && is_array($ext))?$ext:array(); |
|
61 | 1 | $data["coupon_id"] = $coupon_id; |
|
62 | 1 | $data["stock_id"] = $stock_id; |
|
63 | 1 | $data["open_id"] = $open_id; |
|
64 | 1 | $data["op_user_id"] = $op_user_id; |
|
65 | 1 | return $this->post(self::URL_QUERY_COUPON_INFO,$data,false); |
|
0 ignored issues
–
show
|
|||
66 | } |
||
67 | |||
68 | } |