123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- namespace app\api\controller;
- use app\common\enum\Setting as SettingEnum;
- use app\common\library\express\Kuaidi100;
- use app\api\model\Kuaidi as KuaidiModel;
- use app\common\model\store\Setting as SettingModel;
- /**
- * 快递100接口
- * Class Index
- * @package app\api\controller
- */
- class Kuaidi extends Controller
- {
- //订阅请求接口
- public function subscribe(){
- $arg = $this->request->param();
- // 获取快递100配置项
- // 实例化快递100类
- $config = SettingModel::getItem(SettingEnum::DELIVERY);
- if (empty($config['kuaidi100']['customer']) || empty($config['kuaidi100']['key'])) {
- throwError('请先到后台-设置-配送方式 补充物流查询API配置');
- }
- // 实例化快递100类
- $Kuaidi100 = new Kuaidi100($config['kuaidi100']);
- // 请求订阅接口
- $list = $Kuaidi100->subscribe($arg['number']);
- return $this->renderSuccess(compact('list'));
- }
- /**
- * 快递推送回调接口
- * @return array
- * @author: zjwhust
- * @Time: 2021/9/29 14:06
- */
- public function callback(){
- $model = new KuaidiModel;
- if ($model->upd($this->request->param())) {
- return json([
- "result"=>true,
- "returnCode"=>"200",
- "message"=>"成功"
- ]);
- }
- return json([
- "result"=>true,
- "returnCode"=>"500",
- "message"=>"没有接收到订单信息"
- ]);
- }
- }
|