1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?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;
- use think\facade\Log;
- /**
- * 快递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'],$arg['type'] ?? 1,$arg['company']);
- return $this->renderSuccess(compact('list'));
- }
- public function dynamic(){
- $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 \app\common\model\Express($config['kuaidi100']);
- // 请求订阅接口
- $list = $Kuaidi100->dynamic($arg['name'],$arg['code'] ?? 1,$arg['no'],$arg['phone'] ?? '');
- return $this->renderSuccess(compact('list'));
- }
- /**
- * 快递推送回调接口
- * @return array
- * @author: zjwhust
- * @Time: 2021/9/29 14:06
- */
- public function callback(){
- $model = new KuaidiModel;
- Log::info('callback:'.':'.json_encode($this->request->param()));
- if ($model->upd($this->request->param())) {
- return json([
- "result"=>true,
- "returnCode"=>"200",
- "message"=>"成功"
- ]);
- }
- return json([
- "result"=>true,
- "returnCode"=>"500",
- "message"=>"没有接收到订单信息"
- ]);
- }
- }
|