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\MiniProgram\Store; |
13
|
|
|
|
14
|
|
|
use EasyWeChat\Kernel\BaseClient; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Class Client. |
18
|
|
|
* |
19
|
|
|
* @author bigface <[email protected]> |
20
|
|
|
*/ |
21
|
|
|
class Client extends BaseClient |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* Get WXA supported categories. |
25
|
|
|
* |
26
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string |
27
|
|
|
*/ |
28
|
|
|
public function categories() |
29
|
|
|
{ |
30
|
|
|
return $this->httpGet('wxa/get_merchant_category'); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Get district from tencent map . |
35
|
|
|
* |
36
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string |
37
|
|
|
*/ |
38
|
|
|
public function districts() |
39
|
|
|
{ |
40
|
|
|
return $this->httpGet('wxa/get_district'); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Search store from tencent map. |
45
|
|
|
* |
46
|
|
|
* @param int $districtId |
47
|
|
|
* @param string $keyword |
48
|
|
|
* |
49
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string |
50
|
|
|
*/ |
51
|
|
|
public function searchFromMap(int $districtId, string $keyword) |
52
|
|
|
{ |
53
|
|
|
$params = [ |
54
|
|
|
'districtid' => $districtId, |
55
|
|
|
'keyword' => $keyword, |
56
|
|
|
]; |
57
|
|
|
|
58
|
|
|
return $this->httpPostJson('wxa/search_map_poi', $params); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Get store check status. |
63
|
|
|
* |
64
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string |
65
|
|
|
*/ |
66
|
|
|
public function getStatus() |
67
|
|
|
{ |
68
|
|
|
return $this->httpPostJson('wxa/get_merchant_audit_info'); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Create a merchant. |
73
|
|
|
* |
74
|
|
|
* @param array $baseInfo |
75
|
|
|
* |
76
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string |
77
|
|
|
*/ |
78
|
|
|
public function createMerchant(array $baseInfo) |
79
|
|
|
{ |
80
|
|
|
return $this->httpPostJson('wxa/apply_merchant', $baseInfo); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Update a merchant. |
85
|
|
|
* |
86
|
|
|
* @param array $params |
87
|
|
|
* |
88
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string |
89
|
|
|
*/ |
90
|
|
|
public function updateMerchant(array $params) |
91
|
|
|
{ |
92
|
|
|
return $this->httpPostJson('wxa/modify_merchant', $params); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Create a store from tencent map. |
97
|
|
|
* |
98
|
|
|
* @param array $baseInfo |
99
|
|
|
* |
100
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string |
101
|
|
|
*/ |
102
|
|
|
public function createFromMap(array $baseInfo) |
103
|
|
|
{ |
104
|
|
|
return $this->httpPostJson('wxa/create_map_poi', $baseInfo); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Create a store. |
109
|
|
|
* |
110
|
|
|
* @param array $baseInfo |
111
|
|
|
* |
112
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string |
113
|
|
|
*/ |
114
|
|
|
public function create(array $baseInfo) |
115
|
|
|
{ |
116
|
|
|
return $this->httpPostJson('wxa/add_store', $baseInfo); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* Update a store. |
121
|
|
|
* |
122
|
|
|
* @param int $poiId |
123
|
|
|
* @param array $baseInfo |
124
|
|
|
* |
125
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string |
126
|
|
|
*/ |
127
|
|
|
public function update(int $poiId, array $baseInfo) |
128
|
|
|
{ |
129
|
|
|
$params = array_merge($baseInfo, ['poi_id' => $poiId]); |
130
|
|
|
|
131
|
|
|
return $this->httpPostJson('wxa/update_store', $params); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* Get store by ID. |
136
|
|
|
* |
137
|
|
|
* @param int $poiId |
138
|
|
|
* |
139
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string |
140
|
|
|
*/ |
141
|
|
|
public function get(int $poiId) |
142
|
|
|
{ |
143
|
|
|
return $this->httpPostJson('wxa/get_store_info', ['poi_id' => $poiId]); |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* List store. |
148
|
|
|
* |
149
|
|
|
* @param int $offset |
150
|
|
|
* @param int $limit |
151
|
|
|
* |
152
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string |
153
|
|
|
*/ |
154
|
|
|
public function list(int $offset = 0, int $limit = 10) |
155
|
|
|
{ |
156
|
|
|
$params = [ |
157
|
|
|
'begin' => $offset, |
158
|
|
|
'limit' => $limit, |
159
|
|
|
]; |
160
|
|
|
|
161
|
|
|
return $this->httpPostJson('wxa/get_store_list', $params); |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* Delete a store. |
166
|
|
|
* |
167
|
|
|
* @param int $poiId |
168
|
|
|
* |
169
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string |
170
|
|
|
*/ |
171
|
|
|
public function delete(int $poiId) |
172
|
|
|
{ |
173
|
|
|
return $this->httpPostJson('wxa/del_store', ['poi_id' => $poiId]); |
174
|
|
|
} |
175
|
|
|
} |
176
|
|
|
|