-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathLogistic.php
246 lines (217 loc) · 7.77 KB
/
Logistic.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
<?php
declare(strict_types=1);
namespace EasyMeiTuan\Services;
use EasyMeiTuan\Client;
use EasyMeiTuan\Support\Validator;
use Illuminate\Validation\Rule;
use Symfony\Contracts\HttpClient\ResponseInterface;
class Logistic extends Client
{
public const STATUS_PENDING = 0;
public const STATUS_CONFIRMED = 10;
public const STATUS_ARRIVED_STORE = 15;
public const STATUS_PICKED_UP_MEALS = 20;
public const STATUS_DELIVERED = 40;
public const STATUS_CANCELED = 100;
public const STATUS_LABELS = [
self::STATUS_PENDING => '配送单发往配送',
self::STATUS_CONFIRMED => '配送单已确认',
self::STATUS_ARRIVED_STORE => '骑手已到店',
self::STATUS_PICKED_UP_MEALS => '骑手已取餐',
self::STATUS_DELIVERED => '骑手已送达',
self::STATUS_CANCELED => '配送单已取消',
];
/**
* 下发美团配送订单
* https://developer.waimai.meituan.com/home/docDetail/136
*/
public function push(int $orderId): ResponseInterface
{
return $this->get('order/logistics/push', ['order_id' => $orderId]);
}
/**
* 取消美团配送订单
* https://developer.waimai.meituan.com/home/docDetail/139
*/
public function cancel(int $orderId): ResponseInterface
{
return $this->get('order/logistics/cancel', ['order_id' => $orderId]);
}
/**
* 获取配送订单状态
* https://developer.waimai.meituan.com/home/docDetail/142
*/
public function status(int $orderId): ResponseInterface
{
return $this->get('order/logistics/status', ['order_id' => $orderId]);
}
/**
* 专快混配送转为商家自配送
* https://developer.waimai.meituan.com/home/docDetail/236
*/
public function change2PoiSelf(int $orderId): ResponseInterface
{
return $this->post('order/logistics/change/poi_self', ['order_id' => $orderId]);
}
/**
* 自配订单同步配送信息
* https://developer.waimai.meituan.com/home/docDetail/325
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function riderPosition(array $params): ResponseInterface
{
Validator::verify($params, [
'order_id' => 'required|integer',
'logistics_status' => [
'required',
Rule::in(\array_keys(self::STATUS_LABELS))
],
'courier_name' => 'required|string',
'courier_phone' => 'required|string',
'third_logistics_id' => 'required|integer',
'latitude' => 'required|string',
'longitude' => 'required|string',
'back_flow_time' => 'required|integer',
]);
return $this->post('order/riderPosition', $params);
}
/**
* 拉取骑手真实手机号(必接)
* https://developer.waimai.meituan.com/home/docDetail/385
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function getRiderInfoPhoneNumber(array $params): ResponseInterface
{
Validator::verify($params, [
'app_poi_code' => 'integer',
'offset' => 'required|integer',
'limit' => 'required|integer',
]);
return $this->post('order/getRiderInfoPhoneNumber', $params);
}
/**
* 获取取消跑腿配送原因列表
* https://developer.waimai.meituan.com/home/docDetail/432
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function getCancelDeliveryReason(array $params): ResponseInterface
{
Validator::verify($params, [
'order_id' => 'required|integer',
'app_poi_code' => 'required|integer',
]);
return $this->post('order/getCancelDeliveryReason', $params);
}
/**
* 取消跑腿配送
* https://developer.waimai.meituan.com/home/docDetail/433
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function cancelLogisticsByWmOrderId(array $params): ResponseInterface
{
Validator::verify($params, [
'order_id' => 'required|integer',
'reason_code' => 'required|string',
'detail_content' => 'required|string',
'app_poi_code' => 'required|string',
]);
return $this->post('order/cancelLogisticsByWmOrderId', $params);
}
/**
* 三方配送-查询已绑定和可绑定门店配送商和服务包
* https://developer.waimai.meituan.com/home/docDetail/446
*/
public function getDistributorList(string $appPoiCode): ResponseInterface
{
return $this->post('order/thirdLogistics/getDistributorList', ['app_poi_code' => $appPoiCode]);
}
/**
* 三方配送-预发配送
* https://developer.waimai.meituan.com/home/docDetail/447
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function prePushThirdLogistics(array $params): ResponseInterface
{
Validator::verify($params, [
'order_id' => 'required|integer',
'app_poi_code' => 'required|string',
'distributor_code' => 'required|string',
'service_package_code' => 'required|string',
]);
return $this->post('order/thirdLogistics/prePushThirdLogistics', $params);
}
/**
* 三方配送-发起配送
* https://developer.waimai.meituan.com/home/docDetail/448
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function pushThirdLogistics(array $params): ResponseInterface
{
Validator::verify($params, [
'data' => 'required|json',
]);
return $this->post('order/thirdLogistics/pushThirdLogistics', $params);
}
/**
* 三方配送-添加小费
* https://developer.waimai.meituan.com/home/docDetail/449
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function addTipAmount(array $params): ResponseInterface
{
Validator::verify($params, [
'order_id' => 'required|integer',
'app_poi_code' => 'required|string',
'distributor_code' => 'required|string',
'service_package_code' => 'required|string',
'tip_amount' => 'required|integer',
]);
return $this->post('order/thirdLogistics/addTipAmount', $params);
}
/**
* 三方配送-获取取消配送原因列表
* https://developer.waimai.meituan.com/home/docDetail/450
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function getCancelReasonList(array $params): ResponseInterface
{
Validator::verify($params, [
'order_id' => 'required|integer',
'app_poi_code' => 'required|string',
]);
return $this->post('order/thirdLogistics/getCancelReasonList', $params);
}
/**
* 三方配送-取消配送
* https://developer.waimai.meituan.com/home/docDetail/451
*
* @throws \EasyMeiTuan\Exceptions\InvalidParamsException
*/
public function cancelThirdLogistics(array $params): ResponseInterface
{
Validator::verify($params, [
'order_id' => 'required|integer',
'app_poi_code' => 'required|string',
'cancel_code' => 'required|integer',
'cancel_reason' => 'required|string',
'cancel_other_reason' => 'string',
]);
return $this->post('order/thirdLogistics/cancelThirdLogistics', $params);
}
/**
* 三方配送-查询三方配送发配送服务商
* https://developer.waimai.meituan.com/home/docDetail/452
*/
public function getThirdLogisticsPushList(string $appPoiCode): ResponseInterface
{
return $this->post('order/thirdLogistics/getThirdLogisticsPushList', ['app_poi_code' => $appPoiCode]);
}
}