diff --git a/application/admin/controller/Plugins.php b/application/admin/controller/Plugins.php index 14f84ee2e..ee3adb8de 100755 --- a/application/admin/controller/Plugins.php +++ b/application/admin/controller/Plugins.php @@ -110,16 +110,26 @@ class Plugins extends Common $plugins = '\app\plugins\\'.$pluginsname.'\admin\\'.ucfirst($pluginscontrol); if(!class_exists($plugins)) { - $this->assign('msg', ucfirst($pluginscontrol).' 应用控制器未定义'); - return $this->fetch('public/tips_error'); + if(IS_AJAX) + { + return DataReturn(ucfirst($pluginscontrol).' 应用控制器未定义', -1); + } else { + $this->assign('msg', ucfirst($pluginscontrol).' 应用控制器未定义'); + return $this->fetch('public/tips_error'); + } } // 调用方法 $obj = new $plugins(); if(!method_exists($obj, $pluginsaction)) { - $this->assign('msg', ucfirst($pluginsaction).' 应用方法未定义'); - return $this->fetch('public/tips_error'); + if(IS_AJAX) + { + return DataReturn(ucfirst($pluginsaction).' 应用方法未定义', -1); + } else { + $this->assign('msg', ucfirst($pluginsaction).' 应用方法未定义'); + return $this->fetch('public/tips_error'); + } } return $obj->$pluginsaction($params); } diff --git a/application/index/controller/Plugins.php b/application/index/controller/Plugins.php index 9deee7ce5..3bbc8ce8b 100755 --- a/application/index/controller/Plugins.php +++ b/application/index/controller/Plugins.php @@ -104,16 +104,26 @@ class Plugins extends Common $plugins = '\app\plugins\\'.$pluginsname.'\index\\'.ucfirst($pluginscontrol); if(!class_exists($plugins)) { - $this->assign('msg', ucfirst($pluginscontrol).' 应用控制器未定义'); - return $this->fetch('public/tips_error'); + if(IS_AJAX) + { + return DataReturn(ucfirst($pluginscontrol).' 应用控制器未定义', -1); + } else { + $this->assign('msg', ucfirst($pluginscontrol).' 应用控制器未定义'); + return $this->fetch('public/tips_error'); + } } // 调用方法 $obj = new $plugins(); if(!method_exists($obj, $pluginsaction)) { - $this->assign('msg', ucfirst($pluginsaction).' 应用方法未定义'); - return $this->fetch('public/tips_error'); + if(IS_AJAX) + { + return DataReturn(ucfirst($pluginsaction).' 应用方法未定义', -1); + } else { + $this->assign('msg', ucfirst($pluginsaction).' 应用方法未定义'); + return $this->fetch('public/tips_error'); + } } return $obj->$pluginsaction($params); } diff --git a/application/plugins/expressforkdn/Hook.php b/application/plugins/expressforkdn/Hook.php index e0b266ddb..03873f040 100755 --- a/application/plugins/expressforkdn/Hook.php +++ b/application/plugins/expressforkdn/Hook.php @@ -85,7 +85,7 @@ class Hook extends Controller $(".plugins-expressforkdn-submit").on("click", function() { $.ajax({ - url:"'.PluginsHomeUrl('expressforkdn', 'hook', 'getexpinfo').'", + url:"'.PluginsHomeUrl('expressforkdn', 'index', 'getexpinfo').'", type:"POST", dataType:"json", data: {express_id: $(this).data("exp-id"), express_number: $(this).data("exp-num")}, @@ -150,168 +150,5 @@ class Hook extends Controller return DataReturn('处理成功', 0); } - - /** - * 获取物流信息 - * @author Devil - * @blog http://gong.gg/ - * @version 1.0.0 - * @date 2019-03-12 - * @desc description - * @param [array] $params [输入参数] - * @return [type] [description] - */ - public function getexpinfo($params = []) - { - // html - $html = ''; - - // 请求参数 - $p = [ - [ - 'checked_type' => 'empty', - 'key_name' => 'express_id', - 'error_msg' => '快递id有误', - ], - [ - 'checked_type' => 'empty', - 'key_name' => 'express_number', - 'error_msg' => '快递单号有误', - ], - ]; - $ret = ParamsChecked($params, $p); - if($ret !== true) - { - return DataReturn($ret, -1, '
'.$ret.'
'); - } - - // 获取配置数据 - $ret = PluginsService::PluginsData('expressforkdn'); - if($ret['code'] == 0) - { - // 是否配置物流代码 - if(empty($ret['data']['express_ids'][$params['express_id']])) - { - return DataReturn('请先再后台配置物流代码', -1, '请先再后台配置物流代码
'); - } - - // 获取快递信息 - $data = $this->expresstraces(['shipper_code'=>$ret['data']['express_ids'][$params['express_id']],'logistic_code'=>$params['express_number'], 'config'=>$ret['data']]); - - // 状态列表 - $status_arr = [ - 0 => '暂无物流信息', - 1 => '快递公司已揽收', - 2 => '快递正在配送途中...', - 3 => '该物流已被签收', - 4 => '该物流问题件,请咨询物流商处理!', - ]; - if(!isset($data['State']) || !isset($status_arr[$data['State']])) - { - return DataReturn('查询失败', -1, '查询失败
'); - } - - // 开始处理 - $html .=''.$status_arr[$data['State']].'
'; - $html .= ''.$ret.'
'); + } + + // 获取配置数据 + $ret = PluginsService::PluginsData('expressforkdn'); + if($ret['code'] == 0) + { + // 是否配置物流代码 + if(empty($ret['data']['express_ids'][$params['express_id']])) + { + return DataReturn('请先再后台配置物流代码', -1, '请先再后台配置物流代码
'); + } + + // 获取快递信息 + $data = $this->expresstraces(['shipper_code'=>$ret['data']['express_ids'][$params['express_id']],'logistic_code'=>$params['express_number'], 'config'=>$ret['data']]); + + // 状态列表 + $status_arr = [ + 0 => '暂无物流信息', + 1 => '快递公司已揽收', + 2 => '快递正在配送途中...', + 3 => '该物流已被签收', + 4 => '该物流问题件,请咨询物流商处理!', + ]; + if(!isset($data['State']) || !isset($status_arr[$data['State']])) + { + return DataReturn('查询失败', -1, '查询失败
'); + } + + // 开始处理 + $html .=''.$status_arr[$data['State']].'
'; + $html .= '