|
|
@@ -371,23 +371,7 @@ class OrderPackageService
|
|
|
'message' => '输入快递单号为空',
|
|
|
];
|
|
|
}
|
|
|
-// $orderPackageCount = OrderPackage::query()->whereIn('logistic_number', $logistic_numbers)
|
|
|
-// ->whereIn('order_id', function ($query) {
|
|
|
-// $query->from('orders')->select('id')->whereIn('logistic_id', function ($query) {
|
|
|
-// $query->from('logistics')->select('id')->whereIn('code', [
|
|
|
-// 'ZTO',
|
|
|
-// 'ZTO-1',
|
|
|
-// 'WPZTO',
|
|
|
-// ]);
|
|
|
-// });
|
|
|
-// })->count();
|
|
|
-// if ($orderPackageCount !== count($logistic_numbers)) {
|
|
|
-// return [
|
|
|
-// 'success' => false,
|
|
|
-// 'message' => '输入的快递单号异常,请检查承运商是否全部为中通',
|
|
|
-// ];
|
|
|
-// }
|
|
|
-
|
|
|
+ //根据环境获取中通接口参数
|
|
|
$url = env('APP_ENV') === 'production' ? config('api_logistic.collectUpload.ZTO.prod.url') : config('api_logistic.collectUpload.ZTO.test.url');
|
|
|
$xAppKey = env('APP_ENV') === 'production' ? config('api_logistic.collectUpload.ZTO.prod.x-appKey') : config('api_logistic.collectUpload.ZTO.test.x-appKey');
|
|
|
$appSecret = env('APP_ENV') === 'production' ? config('api_logistic.collectUpload.ZTO.prod.appSecret') : config('api_logistic.collectUpload.ZTO.test.appSecret');
|
|
|
@@ -411,25 +395,38 @@ class OrderPackageService
|
|
|
];
|
|
|
}
|
|
|
try {
|
|
|
+ //调用中通接口
|
|
|
$response = $this->sentReqToZOP($collectUploadDTOS, $appSecret, $xAppKey, $url);
|
|
|
+
|
|
|
+ //接口返回的异常包装
|
|
|
+ $responseBody = json_decode($response->body());
|
|
|
+ if ($responseBody->statusCode === 'S210' ||//无权限
|
|
|
+ $responseBody->statusCode === 'PARAM_ERROR' ||//揽收上传信息为空
|
|
|
+ $responseBody->statusCode === 'SYSTEM_ERROR'//系统异常,请联系系统管理员
|
|
|
+ ) {
|
|
|
+ //有异常包装
|
|
|
+ $errorMessage[] = [
|
|
|
+ 'status_code' => $responseBody->statusCode,
|
|
|
+ 'message' => $responseBody->message,
|
|
|
+ 'logistic_number' => $logistic_numbers_chunked_items,
|
|
|
+ ];
|
|
|
+ } else {
|
|
|
+ //没有异常将对应包裹标记为手动揽收
|
|
|
+ OrderPackage::query()
|
|
|
+ ->select('weight', 'logistic_number')
|
|
|
+ ->whereIn('logistic_number', $logistic_numbers_chunked_items)->update([
|
|
|
+ 'collecting_status' => 1,
|
|
|
+ ]);
|
|
|
+ }
|
|
|
} catch (\Exception $e) {
|
|
|
+ //调用异常,构建异常返回体
|
|
|
$errorMessage[] = [
|
|
|
'status_code' => 'REQUEST_ERROR',
|
|
|
'message' => [$e->getMessage()],
|
|
|
'logistic_number' => $logistic_numbers_chunked_items,
|
|
|
];
|
|
|
}
|
|
|
- $responseBody = json_decode($response->body());
|
|
|
- if ($responseBody->statusCode === 'S210' ||//无权限
|
|
|
- $responseBody->statusCode === 'PARAM_ERROR' ||//揽收上传信息为空
|
|
|
- $responseBody->statusCode === 'SYSTEM_ERROR'//系统异常,请联系系统管理员
|
|
|
- ) {
|
|
|
- $errorMessage[] = [
|
|
|
- 'status_code' => $responseBody->statusCode,
|
|
|
- 'message' => $responseBody->message,
|
|
|
- 'logistic_number' => $logistic_numbers_chunked_items,
|
|
|
- ];
|
|
|
- }
|
|
|
+
|
|
|
}
|
|
|
if (empty($errorMessage)) {
|
|
|
return ['success' => true, 'message' => '一键揽收上传成功'];
|