-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathProduct.php
426 lines (377 loc) · 12.7 KB
/
Product.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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
<?php
declare(strict_types=1);
namespace EasyMeiTuan\Services;
use EasyMeiTuan\Client;
use EasyMeiTuan\Support\Validator;
use Symfony\Contracts\HttpClient\ResponseInterface;
class Product extends Client
{
/**
* 查询门店菜品列表
* https://developer.waimai.meituan.com/home/docDetail/57
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function list(array $params): ResponseInterface
{
Validator::verify($params, [
'app_poi_code' => 'required|string|max:128',
'offset' => 'integer',
'limit' => 'integer',
]);
return $this->get('food/list', $params);
}
/**
* 创建菜品(新版)
* https://developer.waimai.meituan.com/home/docDetail/55
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function create(array $params): ResponseInterface
{
Validator::verify($params, [
'app_poi_code' => 'required|string|max:128',
'app_food_code' => 'required|string|max:128',
'name' => 'required|string|max:30',
'description' => 'string|max:255',
'spuAttr' => 'json',
'skus' => 'json',
'price' => 'required|numeric',
'min_order_count' => 'required|integer',
'unit' => 'required|string',
'box_num' => 'required|integer',
'box_price' => 'required|numeric',
'category_name' => 'required|string',
'is_sold_out' => 'required|integer',
'picture' => 'string',
'sequence' => 'integer',
'pictures' => 'string',
'speciality' => 'integer',
'is_not_single' => 'integer',
]);
return $this->post('food/save', $params);
}
/**
* 更新菜品(新版)
* https://developer.waimai.meituan.com/home/docDetail/55
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function update(array $params): ResponseInterface
{
Validator::verify($params, [
'app_poi_code' => 'required|string|max:128',
'app_food_code' => 'required|string|max:128',
'name' => 'string|max:30',
'description' => 'string|max:255',
'price' => 'numeric',
'min_order_count' => 'integer',
'unit' => 'string',
'box_num' => 'integer',
'box_price' => 'numeric',
'category_name' => 'string',
'is_sold_out' => 'integer',
'picture' => 'string',
'sequence' => 'integer',
]);
return $this->post('food/save', $params);
}
/**
* 删除菜品
* https://developer.waimai.meituan.com/home/docDetail/56
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function destroy(array $params): ResponseInterface
{
Validator::verify($params, [
'app_poi_code' => 'required|string|max:128',
'app_food_code' => 'required|string|max:128',
]);
return $this->post('food/delete', $params);
}
/**
* 批量创建菜品(新版)
* https://developer.waimai.meituan.com/home/docDetail/59
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function batchCreate(array $params): ResponseInterface
{
Validator::verify($params, [
'app_poi_code' => 'required|string|max:128',
'sku_overwrite' => 'boolean',
'food_data' => 'required|json',
]);
return $this->post('food/batchinitdata', $params);
}
/**
* 批量更新菜品(新版)
* https://developer.waimai.meituan.com/home/docDetail/59
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function batchUpdate(array $params): ResponseInterface
{
return $this->batchCreate($params);
}
/**
* 创建 SKU 信息
* https://developer.waimai.meituan.com/home/docDetail/61
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function createSku(array $params): ResponseInterface
{
Validator::verify($params, [
'app_poi_code' => 'required|string|max:128',
'app_food_code' => 'required|string|max:128',
'skus' => 'json',
]);
return $this->post('food/sku/save', $params);
}
/**
* 更新 SKU 信息
* https://developer.waimai.meituan.com/home/docDetail/61
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function updateSku(array $params): ResponseInterface
{
return $this->createSku($params);
}
/**
* 删除 SKU 信息
* https://developer.waimai.meituan.com/home/docDetail/62
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function destroySku(array $params): ResponseInterface
{
Validator::verify($params, [
'app_poi_code' => 'required|string|max:128',
'app_food_code' => 'required|string|max:128',
'sku_id' => 'required|string',
]);
return $this->post('food/sku/delete', $params);
}
/**
* 更新 SKU 价格
* https://developer.waimai.meituan.com/home/docDetail/63
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function updateSkuPrice(array $params): ResponseInterface
{
Validator::verify($params, [
'app_poi_code' => 'required|string|max:128',
'food_data' => 'required|json',
]);
return $this->post('food/sku/price', $params);
}
/**
* 更新 SKU 库存
* https://developer.waimai.meituan.com/home/docDetail/64
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function updateSkuStock(array $params): ResponseInterface
{
Validator::verify($params, [
'app_poi_code' => 'required|string|max:128',
'food_data' => 'required|json',
]);
return $this->post('food/sku/stock', $params);
}
/**
* 增加 SKU 库存
* https://developer.waimai.meituan.com/home/docDetail/65
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function addSkuStock(array $params): ResponseInterface
{
Validator::verify($params, [
'app_poi_code' => 'required|string|max:128',
'food_data' => 'required|json',
]);
return $this->post('food/sku/inc_stock', $params);
}
/**
* 减少 SKU 库存
* https://developer.waimai.meituan.com/home/docDetail/66
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function reduceSkuStock(array $params): ResponseInterface
{
Validator::verify($params, [
'app_poi_code' => 'required|string|max:128',
'food_data' => 'required|json',
]);
return $this->post('food/sku/desc_stock', $params);
}
/**
* 绑定菜品属性
* https://developer.waimai.meituan.com/home/docDetail/67
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function bindProperties(array $params): ResponseInterface
{
Validator::verify($params, [
'app_poi_code' => 'required|string|max:128',
'food_property' => 'required|json',
]);
return $this->post('food/bind/property', $params);
}
/**
* 菜品属性列表
* https://developer.waimai.meituan.com/home/docDetail/68
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function properties(array $params): ResponseInterface
{
Validator::verify($params, [
'app_poi_code' => 'required|string|max:128',
'app_food_code' => 'required|string|max:128',
]);
return $this->get('food/property/list', $params);
}
/**
* 查询菜品详情
* https://developer.waimai.meituan.com/home/docDetail/69
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function show(array $params): ResponseInterface
{
Validator::verify($params, [
'app_poi_code' => 'required|string|max:128',
'app_food_code' => 'required|string|max:128',
]);
return $this->get('food/get', $params);
}
/**
* 批量更新售卖状态
* https://developer.waimai.meituan.com/home/docDetail/70
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function batchUpdateSellStatus(array $params): ResponseInterface
{
Validator::verify($params, [
'app_poi_code' => 'required|string|max:128',
'food_data' => 'required|json',
'sell_status' => 'required|integer',
]);
return $this->get('food/sku/sellStatus', $params);
}
/**
* 根据原商品编码更换新商品编码
* https://developer.waimai.meituan.com/home/docDetail/294
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function updateAppFoodCodeByOrigin(array $params): ResponseInterface
{
Validator::verify($params, [
'app_poi_code' => 'required|string|max:128',
'app_food_code_origin' => 'required|string|max:128',
'app_food_code' => 'required|string|max:128',
'sku_id_origin' => 'string',
'sku_id' => 'string',
]);
return $this->get('food/updateAppFoodCodeByOrigin', $params);
}
/**
* 根据商品名称和规格名称更换新的商品编码
* https://developer.waimai.meituan.com/home/docDetail/295
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function updateAppFoodCodeByNameAndSpec(array $params): ResponseInterface
{
Validator::verify($params, [
'app_poi_code' => 'required|string|max:128',
'name' => 'required|string',
'category_name' => 'required|string',
'spec' => 'string',
'app_food_code' => 'required|string|max:128',
'sku_id' => 'string',
]);
return $this->get('food/updateAppFoodCodeByNameAndSpec', $params);
}
/**
* 批量创建或更新菜品(同步逻辑)
* 如果菜品原来不存在,本次存在就新增;如果菜品原来存在,本次存在就更新;如果菜品原来存在,本次不存在就删除
* https://developer.waimai.meituan.com/home/docDetail/301
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function batchSync(array $params): ResponseInterface
{
Validator::verify($params, [
'app_poi_code' => 'required|string|max:128',
'food_data' => 'required|json',
]);
return $this->get('food/batchbulksave', $params);
}
/**
* 查询商品DNA
* https://developer.waimai.meituan.com/home/docDetail/405
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function getTemplateBySpuId(array $params): ResponseInterface
{
Validator::verify($params, [
'app_poi_code' => 'required|string',
'app_food_code' => 'required|string',
]);
return $this->post('foodDna/getTemplateBySpuId', $params);
}
/**
* 保存商品DNA
* https://developer.waimai.meituan.com/home/docDetail/406
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function saveFoodDna(array $params): ResponseInterface
{
Validator::verify($params, [
'app_poi_code' => 'required|string',
'food_data' => 'required|json',
]);
return $this->post('foodDna/saveFoodDna', $params);
}
/**
* 批量查询商品DNA
* https://developer.waimai.meituan.com/home/docDetail/674
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function batchQueryFoodDna(array $params): ResponseInterface
{
Validator::verify($params, [
'app_poi_code' => 'required|string',
'app_food_codes' => 'required|string',
]);
return $this->post('foodDna/batchQueryFoodDna', $params);
}
/**
* 批量删除商品
* https://developer.waimai.meituan.com/home/docDetail/690
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function batchDelSpu(array $params): ResponseInterface
{
Validator::verify($params, [
'app_poi_code' => 'required|string',
'app_food_codes' => 'required|string',
]);
return $this->post('food/batchDelSpu', $params);
}
}