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\MicroMerchant\Base; |
13
|
|
|
|
14
|
|
|
use EasyWeChat\MicroMerchant\Kernel\BaseClient; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Class Client. |
18
|
|
|
* |
19
|
|
|
* @author liuml <[email protected]> |
20
|
|
|
* @DateTime 2019-05-30 14:19 |
21
|
|
|
*/ |
22
|
|
|
class Client extends BaseClient |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* apply to settle in to become a small micro merchant. |
26
|
|
|
* |
27
|
|
|
* @param array $params |
28
|
|
|
* |
29
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
30
|
|
|
* |
31
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException |
32
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
33
|
|
|
* @throws \EasyWeChat\MicroMerchant\Kernel\Exceptions\EncryptException |
34
|
|
|
*/ |
35
|
|
|
public function submitApplication(array $params) |
36
|
|
|
{ |
37
|
|
|
$params = $this->processParams(array_merge($params, [ |
38
|
|
|
'version' => '3.0', |
39
|
|
|
'cert_sn' => '', |
40
|
|
|
'sign_type' => 'HMAC-SHA256', |
41
|
|
|
'nonce_str' => uniqid('micro'), |
42
|
|
|
])); |
43
|
|
|
|
44
|
|
|
return $this->safeRequest('applyment/micro/submit', $params); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* query application status. |
49
|
|
|
* |
50
|
|
|
* @param string $applymentId |
51
|
|
|
* @param string $businessCode |
52
|
|
|
* |
53
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
54
|
|
|
* |
55
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException |
56
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
57
|
|
|
*/ |
58
|
|
|
public function getStatus(string $applymentId, string $businessCode = '') |
59
|
|
|
{ |
60
|
|
|
if (!empty($applymentId)) { |
61
|
|
|
$params = [ |
62
|
|
|
'applyment_id' => $applymentId, |
63
|
|
|
]; |
64
|
|
|
} else { |
65
|
|
|
$params = [ |
66
|
|
|
'business_code' => $businessCode, |
67
|
|
|
]; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
$params = array_merge($params, [ |
71
|
|
|
'version' => '1.0', |
72
|
|
|
'sign_type' => 'HMAC-SHA256', |
73
|
|
|
'nonce_str' => '9ZtG8fAuVMkekKMs3UDaG8EIAoduDO5G'// uniqid('micro'), |
|
|
|
|
74
|
|
|
]); |
75
|
|
|
|
76
|
|
|
return $this->safeRequest('applyment/micro/getstate', $params); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* merchant upgrade api. |
81
|
|
|
* |
82
|
|
|
* @param array $params |
83
|
|
|
* |
84
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
85
|
|
|
* |
86
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException |
87
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
88
|
|
|
* @throws \EasyWeChat\MicroMerchant\Kernel\Exceptions\EncryptException |
89
|
|
|
*/ |
90
|
|
|
public function upgrade(array $params) |
91
|
|
|
{ |
92
|
|
|
$params['sub_mch_id'] = $params['sub_mch_id'] ?? $this->app['config']->sub_mch_id; |
93
|
|
|
$params = $this->processParams(array_merge($params, [ |
|
|
|
|
94
|
|
|
'version' => '1.0', |
95
|
|
|
'cert_sn' => '', |
96
|
|
|
'sign_type' => 'HMAC-SHA256', |
97
|
|
|
'nonce_str' => uniqid('micro'), |
98
|
|
|
])); |
99
|
|
|
|
100
|
|
|
return $this->safeRequest('applyment/micro/submitupgrade', $params); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* get upgrade status. |
105
|
|
|
* |
106
|
|
|
* @param string $subMchId |
107
|
|
|
* |
108
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
109
|
|
|
* |
110
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException |
111
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
112
|
|
|
*/ |
113
|
|
|
public function getUpgradeStatus(string $subMchId = '') |
114
|
|
|
{ |
115
|
|
|
return $this->safeRequest('applyment/micro/getupgradestate', [ |
116
|
|
|
'version' => '1.0', |
117
|
|
|
'sign_type' => 'HMAC-SHA256', |
118
|
|
|
'sub_mch_id' => $subMchId ?: $this->app['config']->sub_mch_id, |
119
|
|
|
'nonce_str' => uniqid('micro'), |
120
|
|
|
]); |
121
|
|
|
} |
122
|
|
|
} |
123
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.