文件
xionggeshop/addons/shopro_aliyun_express/controller/Express.php

40 行
1.1 KiB
PHP

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<?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());
}
}
}