40 行
1.1 KiB
PHP
40 行
1.1 KiB
PHP
<?php
|
||
|
||
namespace addons\shopro_aliyun_express\controller;
|
||
|
||
use addons\shopro\controller\Base;
|
||
use addons\shopro_aliyun_express\library\Bridge;
|
||
use addons\shopro_aliyun_express\library\ExpressConfig;
|
||
|
||
class Express extends Base
|
||
{
|
||
protected $noNeedLogin = [];
|
||
protected $noNeedRight = ['*'];
|
||
|
||
/**
|
||
* 独立快递查询 API(小程序/调试)
|
||
* GET waybill_number, phone, express_code(可选)
|
||
*/
|
||
public function query()
|
||
{
|
||
if (!ExpressConfig::getInstance()->isEnabled()) {
|
||
$this->error('快递查询插件未启用');
|
||
}
|
||
|
||
$waybillNo = trim($this->request->get('waybill_number', ''));
|
||
$phone = trim($this->request->get('phone', ''));
|
||
$expressCode = trim($this->request->get('express_code', ''));
|
||
|
||
if ($waybillNo === '') {
|
||
$this->error('请提供快递单号');
|
||
}
|
||
|
||
try {
|
||
$result = Bridge::queryTrack($waybillNo, $phone, $expressCode, false);
|
||
$this->success('查询成功', $result);
|
||
} catch (\Exception $e) {
|
||
$this->error($e->getMessage());
|
||
}
|
||
}
|
||
}
|