|
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 $params |
|
28
|
|
|
* |
|
29
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string |
|
30
|
|
|
* |
|
31
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
|
32
|
|
|
*/ |
|
33
|
1 |
|
public function info($mchBillno) |
|
34
|
|
|
{ |
|
35
|
1 |
|
$params = is_array($mchBillno) ? $mchBillno : ['mch_billno' => $mchBillno]; |
|
36
|
|
|
$base = [ |
|
37
|
1 |
|
'appid' => $this->app['config']->app_id, |
|
38
|
1 |
|
'bill_type' => 'MCHT', |
|
39
|
|
|
]; |
|
40
|
|
|
|
|
41
|
1 |
|
return $this->safeRequest('mmpaymkttransfers/gethbinfo', array_merge($base, $params)); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Send normal redpack. |
|
46
|
|
|
* |
|
47
|
|
|
* @param array $params |
|
48
|
|
|
* |
|
49
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string |
|
50
|
|
|
* |
|
51
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
|
52
|
|
|
*/ |
|
53
|
1 |
|
public function sendNormal(array $params) |
|
54
|
|
|
{ |
|
55
|
|
|
$base = [ |
|
56
|
1 |
|
'total_num' => 1, |
|
57
|
1 |
|
'client_ip' => $params['client_ip'] ?? Support\get_server_ip(), |
|
|
|
|
|
|
58
|
1 |
|
'wxappid' => $this->app['config']->app_id, |
|
59
|
|
|
]; |
|
60
|
|
|
|
|
61
|
1 |
|
return $this->safeRequest('mmpaymkttransfers/sendredpack', array_merge($base, $params)); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Send group redpack. |
|
66
|
|
|
* |
|
67
|
|
|
* @param array $params |
|
68
|
|
|
* |
|
69
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string |
|
70
|
|
|
* |
|
71
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
|
72
|
|
|
*/ |
|
73
|
1 |
|
public function sendGroup(array $params) |
|
74
|
|
|
{ |
|
75
|
|
|
$base = [ |
|
76
|
1 |
|
'amt_type' => 'ALL_RAND', |
|
77
|
1 |
|
'wxappid' => $this->app['config']->app_id, |
|
78
|
|
|
]; |
|
79
|
|
|
|
|
80
|
1 |
|
return $this->safeRequest('mmpaymkttransfers/sendgroupredpack', array_merge($base, $params)); |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|