|
|
@@ -19,6 +19,7 @@ use cores\exception\BaseException;
|
|
|
/**
|
|
|
* 阿里云物流查询驱动
|
|
|
* Class Aliyun
|
|
|
+ * 接口文档: https://market.aliyun.com/products/57126001/cmapi023201.html
|
|
|
* @package app\common\library\express\provider\driver
|
|
|
*/
|
|
|
class Aliyun extends Driver
|
|
|
@@ -39,6 +40,11 @@ class Aliyun extends Driver
|
|
|
// 授权参数
|
|
|
$appCode = $this->options['appCode'];
|
|
|
$headers = ["Authorization: APPCODE " . $appCode];
|
|
|
+ // 查询顺丰时 物流单号需要加上手机尾号
|
|
|
+ if ($code === 'SF') {
|
|
|
+ $lastPhoneNumber = \mb_substr($extra['phone'], -4);
|
|
|
+ $expressNo = "{$expressNo}:$lastPhoneNumber";
|
|
|
+ }
|
|
|
// 物流查询参数
|
|
|
$querys = ['n' => $expressNo, 't' => $code];
|
|
|
// 请求API
|
|
|
@@ -46,6 +52,10 @@ class Aliyun extends Driver
|
|
|
$data = helper::jsonDecode($result);
|
|
|
// 记录日志
|
|
|
log_record(['name' => '查询物流轨迹', 'provider' => 'aliyun', 'param' => $querys, 'result' => $data]);
|
|
|
+ // 错误信息
|
|
|
+ if ($data['State'] == -1 || !$data['Success']) {
|
|
|
+ throwError('阿里云物流查询API失败:' . $data['Reason']);
|
|
|
+ }
|
|
|
// 格式化返回的数据
|
|
|
return $this->formatTraces($data['Traces']);
|
|
|
}
|