-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathStore.php
260 lines (231 loc) · 7.74 KB
/
Store.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
<?php
declare(strict_types=1);
namespace EasyMeiTuan\Services;
use EasyMeiTuan\Client;
use EasyMeiTuan\Interfaces\ResponseInterface;
use EasyMeiTuan\Support\Validator;
use Illuminate\Validation\Rule;
class Store extends Client
{
public const DELIVERABLE_BUSINESS_STATUS = 1;
public const RESTING_BUSINESS_STATUS = 3;
// 营业状态
public const BUSINESS_STATUS_LABELS = [
self::DELIVERABLE_BUSINESS_STATUS => '可配送',
self::RESTING_BUSINESS_STATUS => '休息中',
];
/**
* 获取门店ID
* https://developer.waimai.meituan.com/home/docDetail/4
*
* 批量获取门店详细信息
* https://developer.waimai.meituan.com/home/docDetail/7
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function list(array $params = []): ResponseInterface
{
Validator::verify($params, [
'only_id' => 'boolean',
'app_poi_codes' => [
'array',
Rule::requiredIf(!$onlyId = (\data_get($params, 'only_id', false))),
],
]);
if (!$onlyId) {
$params['app_poi_codes'] = join(',', $params['app_poi_codes']);
}
return $this->get($onlyId ? 'poi/getids' : 'poi/mget', $params);
}
/**
* 创建门店信息
* https://developer.waimai.meituan.com/home/docDetail/1
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function create(array $params): ResponseInterface
{
Validator::verify($params, [
'app_poi_code' => 'required|string|max:128',
'name' => 'required|string',
'address' => 'required|string',
'latitude' => 'required|numeric',
'longitude' => 'required|numeric',
'pic_url' => 'string',
'pic_url_large' => 'string',
'phone' => 'required|string',
'standby_tel' => 'string',
'shipping_fee' => 'required|numeric',
'shipping_time' => 'required|string',
'promotion_info' => 'required|string',
'open_level' => [
'required',
Rule::in(\array_keys(self::BUSINESS_STATUS_LABELS))
],
'is_online' => 'required|in:0,1',
'invoice_support' => 'integer',
'invoice_min_price' => 'integer',
'invoice_description' => 'string',
'third_tag_name' => 'required|string',
'pre_book' => 'integer',
'time_select' => 'integer',
'app_brand_code' => 'string',
]);
return $this->post('poi/save', $params);
}
/**
* 更新门店信息
* https://developer.waimai.meituan.com/home/docDetail/1
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function update(array $params): ResponseInterface
{
return $this->create($params);
}
/**
* 获取门店详细信息
* https://developer.waimai.meituan.com/home/docDetail/7
*/
public function show(string $appPoiCode): ResponseInterface
{
return $this->get('poi/mget', ['app_poi_codes' => $appPoiCode]);
}
/**
* 门店设置为休息状态
* https://developer.waimai.meituan.com/home/docDetail/13
*/
public function markAsClose(string $appPoiCode): ResponseInterface
{
return $this->post('poi/close', ['app_poi_codes' => $appPoiCode]);
}
/**
* 门店设置为上线状态
* https://developer.waimai.meituan.com/home/docDetail/19
*/
public function markAsOnline(string $appPoiCode): ResponseInterface
{
return $this->post('poi/online', ['app_poi_codes' => $appPoiCode]);
}
/**
* 门店设置为营业状态
* https://developer.waimai.meituan.com/home/docDetail/347
*/
public function markAsOpen(string $appPoiCode): ResponseInterface
{
return $this->post('poi/open', ['app_poi_code' => $appPoiCode]);
}
/**
* 门店设置为下线状态
* https://developer.waimai.meituan.com/home/docDetail/348
*/
public function markAsOffline(string $appPoiCode): ResponseInterface
{
return $this->post('poi/offline', ['app_poi_code' => $appPoiCode]);
}
/**
* 获取门店品类列表
* https://developer.waimai.meituan.com/home/docDetail/28
*/
public function categories(): ResponseInterface
{
return $this->post('poiTag/list');
}
/**
* 更改门店公告信息
* https://developer.waimai.meituan.com/home/docDetail/25
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function updatePromotionInfo(array $params): ResponseInterface
{
Validator::verify($params, [
'app_poi_code' => 'required|string',
'promotion_info' => 'string',
]);
return $this->post('poi/updatepromoteinfo', $params);
}
/**
* 更新门店营业时间
* https://developer.waimai.meituan.com/home/docDetail/31
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function updateShippingTime(array $params): ResponseInterface
{
Validator::verify($params, [
'app_poi_code' => 'required|string',
'shipping_time' => 'required|string',
]);
return $this->post('shippingtime/update', $params);
}
/**
* 查询门店是否延迟发配送
* https://developer.waimai.meituan.com/home/docDetail/34
*/
public function isDelayPush(string $appPoiCode): ResponseInterface
{
return $this->post('logistics/isDelayPush', ['app_poi_code' => $appPoiCode]);
}
/**
* 设置门店延迟发配送时间
* https://developer.waimai.meituan.com/home/docDetail/37
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function setDelayPush(array $params): ResponseInterface
{
Validator::verify($params, [
'app_poi_code' => 'required|string',
'delay_seconds' => 'required|integer',
]);
return $this->post('logistics/setDelayPush');
}
/**
* 门店是否可开启加权
* https://developer.waimai.meituan.com/home/docDetail/284
*/
public function canOpen(string $appPoiCode): ResponseInterface
{
return $this->get('weight/canOpen', ['app_poi_code' => $appPoiCode]);
}
/**
* 门店开启加权
* https://developer.waimai.meituan.com/home/docDetail/285
*/
public function open(string $appPoiCode): ResponseInterface
{
return $this->post('weight/open', ['app_poi_code' => $appPoiCode]);
}
/**
* 获取门店日账单
* https://developer.waimai.meituan.com/home/docDetail/326
*
* 根据交易类型查询交易列表
* https://developer.waimai.meituan.com/home/docDetail/588
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function bills(array $params): ResponseInterface
{
Validator::verify($params, [
'app_poi_code' => 'required|string',
'start_date' => 'required|integer',
'end_date' => 'required|integer',
'offset' => 'required|integer',
'limit' => 'required|integer',
'partner_type' => [
'integer',
Rule::requiredIf($hasPartnerType = \data_get($params, 'partner_type', false))
],
'bill_charge_types' => [
'integer',
Rule::requiredIf($hasChargeType = \data_get($params, 'bill_charge_types', false))
],
]);
if ($hasPartnerType && $hasChargeType) {
return $this->get('wm/bill/getOrderBill', $params);
}
return $this->get('wm/bill/list', $params);
}
}