1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the overtrue/wechat. |
5
|
|
|
* |
6
|
|
|
* (c) overtrue <[email protected]> |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the MIT license that is bundled |
9
|
|
|
* with this source code in the file LICENSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace EasyWeChat\Payment\Redpack; |
13
|
|
|
|
14
|
|
|
use EasyWeChat\Kernel\Support; |
15
|
|
|
use EasyWeChat\Payment\Kernel\BaseClient; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Class Client. |
19
|
|
|
* |
20
|
|
|
* @author tianyong90 <[email protected]> |
21
|
|
|
*/ |
22
|
|
|
class Client extends BaseClient |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* Query redpack. |
26
|
|
|
* |
27
|
|
|
* @param mixed $mchBillno |
28
|
|
|
* |
29
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string |
30
|
|
|
* |
31
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException |
32
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
33
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
34
|
|
|
*/ |
35
|
1 |
|
public function info($mchBillno) |
36
|
|
|
{ |
37
|
1 |
|
$params = is_array($mchBillno) ? $mchBillno : ['mch_billno' => $mchBillno]; |
38
|
|
|
$base = [ |
39
|
1 |
|
'appid' => $this->app['config']->app_id, |
40
|
1 |
|
'bill_type' => 'MCHT', |
41
|
|
|
]; |
42
|
|
|
|
43
|
1 |
|
return $this->safeRequest('mmpaymkttransfers/gethbinfo', array_merge($base, $params)); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Send miniprogram normal redpack. |
48
|
|
|
* |
49
|
|
|
* @param array $params |
50
|
|
|
* |
51
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string |
52
|
|
|
* |
53
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
54
|
|
|
*/ |
55
|
|
|
public function sendMiniprogramNormal(array $params) |
56
|
|
|
{ |
57
|
|
|
$base = [ |
58
|
|
|
'total_num' => 1, |
59
|
|
|
'client_ip' => $params['client_ip'] ?? Support\get_server_ip(), |
|
|
|
|
60
|
|
|
'wxappid' => $this->app['config']->app_id, |
61
|
|
|
]; |
62
|
|
|
|
63
|
|
|
return $this->safeRequest('mmpaymkttransfers/sendminiprogramhb', array_merge($base, $params)); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Send normal redpack. |
68
|
|
|
* |
69
|
|
|
* @param array $params |
70
|
|
|
* |
71
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string |
72
|
|
|
* |
73
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException |
74
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
75
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
76
|
|
|
*/ |
77
|
1 |
|
public function sendNormal(array $params) |
78
|
|
|
{ |
79
|
|
|
$base = [ |
80
|
1 |
|
'total_num' => 1, |
81
|
1 |
|
'client_ip' => $params['client_ip'] ?? Support\get_server_ip(), |
|
|
|
|
82
|
1 |
|
'wxappid' => $this->app['config']->app_id, |
83
|
|
|
]; |
84
|
|
|
|
85
|
1 |
|
return $this->safeRequest('mmpaymkttransfers/sendredpack', array_merge($base, $params)); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Send group redpack. |
90
|
|
|
* |
91
|
|
|
* @param array $params |
92
|
|
|
* |
93
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string |
94
|
|
|
* |
95
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException |
96
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
97
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
98
|
|
|
*/ |
99
|
1 |
|
public function sendGroup(array $params) |
100
|
|
|
{ |
101
|
|
|
$base = [ |
102
|
1 |
|
'amt_type' => 'ALL_RAND', |
103
|
1 |
|
'wxappid' => $this->app['config']->app_id, |
104
|
|
|
]; |
105
|
|
|
|
106
|
1 |
|
return $this->safeRequest('mmpaymkttransfers/sendgroupredpack', array_merge($base, $params)); |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|