From 6d420f5b426884c8c155c30598a5181f5c941dcc Mon Sep 17 00:00:00 2001 From: devil_gong Date: Tue, 12 Mar 2019 18:06:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BF=AB=E9=80=92=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/Common.php | 33 ++ .../admin/view/default/order/index.html | 9 + .../admin/view/default/public/footer.html | 34 ++ .../admin/view/default/public/header.html | 34 +- .../index/view/default/order/index.html | 14 + application/plugins/expressforkdn/Admin.php | 65 ++++ application/plugins/expressforkdn/Hook.php | 317 ++++++++++++++++++ application/plugins/expressforkdn/config.json | 42 +++ .../view/expressforkdn/admin/content.html | 10 + .../view/expressforkdn/admin/index.html | 54 +++ .../view/expressforkdn/admin/saveinfo.html | 44 +++ application/service/OrderService.php | 30 ++ application/tags.php | 25 ++ changelog.txt | 5 +- .../plugins/css/expressforkdn/admin.css | 32 ++ .../2019/03/11/1552286675575734.png | Bin 0 -> 17303 bytes 16 files changed, 745 insertions(+), 3 deletions(-) create mode 100644 application/plugins/expressforkdn/Admin.php create mode 100644 application/plugins/expressforkdn/Hook.php create mode 100644 application/plugins/expressforkdn/config.json create mode 100644 application/plugins/view/expressforkdn/admin/content.html create mode 100644 application/plugins/view/expressforkdn/admin/index.html create mode 100644 application/plugins/view/expressforkdn/admin/saveinfo.html create mode 100755 public/static/plugins/css/expressforkdn/admin.css create mode 100644 public/static/upload/images/plugins_expressforkdn/2019/03/11/1552286675575734.png diff --git a/application/admin/controller/Common.php b/application/admin/controller/Common.php index 89096b426..c640e4025 100755 --- a/application/admin/controller/Common.php +++ b/application/admin/controller/Common.php @@ -10,6 +10,7 @@ // +---------------------------------------------------------------------- namespace app\admin\controller; +use think\facade\Hook; use think\Controller; use app\service\AdminPowerService; use app\service\ConfigService; @@ -59,8 +60,40 @@ class Common extends Controller // 视图初始化 $this->ViewInit(); + + // 公共钩子初始化 + $this->CommonPluginsInit(); } + /** + * 公共钩子初始化 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2018-12-07 + * @desc description + */ + private function CommonPluginsInit() + { + // css钩子 + $this->assign('plugins_admin_css_data', Hook::listen('plugins_admin_css', ['hook_name'=>'plugins_admin_css', 'is_backend'=>false])); + + // js钩子 + $this->assign('plugins_admin_js_data', Hook::listen('plugins_admin_js', ['hook_name'=>'plugins_admin_js', 'is_backend'=>false])); + + // 公共header内钩子 + $this->assign('plugins_admin_common_header_data', Hook::listen('plugins_admin_common_header', ['hook_name'=>'plugins_admin_common_header', 'is_backend'=>false, 'admin'=>$this->admin])); + + // 公共页面底部钩子 + $this->assign('plugins_admin_common_page_bottom_data', Hook::listen('plugins_admin_common_page_bottom', ['hook_name'=>'plugins_admin_common_page_bottom', 'is_backend'=>false, 'admin'=>$this->admin])); + + // 公共顶部钩子 + $this->assign('plugins_admin_view_common_top_data', Hook::listen('plugins_admin_view_common_top', ['hook_name'=>'plugins_admin_view_common_top', 'is_backend'=>false, 'admin'=>$this->admin])); + + // 公共底部钩子 + $this->assign('plugins_admin_view_common_bottom_data', Hook::listen('plugins_admin_view_common_bottom', ['hook_name'=>'plugins_admin_view_common_bottom', 'is_backend'=>false, 'admin'=>$this->admin])); + } + /** * 系统初始化 * @author Devil diff --git a/application/admin/view/default/order/index.html b/application/admin/view/default/order/index.html index d08bc1f3e..89e606d60 100755 --- a/application/admin/view/default/order/index.html +++ b/application/admin/view/default/order/index.html @@ -259,6 +259,15 @@ {{if in_array($v['status'], [5,6])}} {{/if}} + + + {{if !empty($v['plugins_service_order_handle_operation_html']) and is_array($v['plugins_service_order_handle_operation_html'])}} + {{foreach $v.plugins_service_order_handle_operation_html as $hook}} + {{if is_string($hook) or is_int($hook)}} + {{$hook|raw}} + {{/if}} + {{/foreach}} + {{/if}} {{/foreach}} diff --git a/application/admin/view/default/public/footer.html b/application/admin/view/default/public/footer.html index c74f6b266..4d5f3fd45 100755 --- a/application/admin/view/default/public/footer.html +++ b/application/admin/view/default/public/footer.html @@ -1,5 +1,15 @@ + + +{{if !empty($plugins_admin_view_common_bottom_data) and is_array($plugins_admin_view_common_bottom_data) and (!isset($is_footer) or $is_footer eq 1)}} + {{foreach $plugins_admin_view_common_bottom_data as $hook}} + {{if is_string($hook) or is_int($hook)}} + {{$hook|raw}} + {{/if}} + {{/foreach}} +{{/if}} + @@ -55,4 +65,28 @@ {{if !empty($module_js)}} +{{/if}} + + +{{if !empty($plugins_admin_js_data) and is_array($plugins_admin_js_data)}} + {{foreach $plugins_admin_js_data as $hook}} + {{if is_string($hook)}} + + {{elseif is_array($hook) /}} + {{foreach $hook as $hook_js}} + {{if is_string($hook_js)}} + + {{/if}} + {{/foreach}} + {{/if}} + {{/foreach}} +{{/if}} + + +{{if !empty($plugins_admin_common_page_bottom_data) and is_array($plugins_admin_common_page_bottom_data)}} + {{foreach $plugins_admin_common_page_bottom_data as $hook}} + {{if is_string($hook) or is_int($hook)}} + {{$hook|raw}} + {{/if}} + {{/foreach}} {{/if}} \ No newline at end of file diff --git a/application/admin/view/default/public/header.html b/application/admin/view/default/public/header.html index 6c9f39fba..ffa76ed8e 100755 --- a/application/admin/view/default/public/header.html +++ b/application/admin/view/default/public/header.html @@ -15,8 +15,40 @@ {{if !empty($module_css)}} {{/if}} + + + {{if !empty($plugins_admin_css_data) and is_array($plugins_admin_css_data)}} + {{foreach $plugins_admin_css_data as $hook}} + {{if is_string($hook)}} + + {{elseif is_array($hook) /}} + {{foreach $hook as $hook_css}} + {{if is_string($hook_css)}} + + {{/if}} + {{/foreach}} + {{/if}} + {{/foreach}} + {{/if}} + + + {{if !empty($plugins_admin_common_header_data) and is_array($plugins_admin_common_header_data)}} + {{foreach $plugins_admin_common_header_data as $hook}} + {{if is_string($hook) or is_int($hook)}} + {{$hook|raw}} + {{/if}} + {{/foreach}} + {{/if}} - \ No newline at end of file + + +{{if !empty($plugins_admin_view_common_top_data) and is_array($plugins_admin_view_common_top_data) and (!isset($is_header) or $is_header eq 1)}} + {{foreach $plugins_admin_view_common_top_data as $hook}} + {{if is_string($hook) or is_int($hook)}} + {{$hook|raw}} + {{/if}} + {{/foreach}} +{{/if}} \ No newline at end of file diff --git a/application/index/view/default/order/index.html b/application/index/view/default/order/index.html index 3f2a3d33b..eecbab79e 100755 --- a/application/index/view/default/order/index.html +++ b/application/index/view/default/order/index.html @@ -204,6 +204,20 @@ {{if in_array($order['status'], [4,5,6])}} {{/if}} + + + {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}} +
+ plugins_service_order_handle_operation_html +
+ {{/if}} + {{if !empty($order['plugins_service_order_handle_operation_html']) and is_array($order['plugins_service_order_handle_operation_html'])}} + {{foreach $order.plugins_service_order_handle_operation_html as $hook}} + {{if is_string($hook) or is_int($hook)}} + {{$hook|raw}} + {{/if}} + {{/foreach}} + {{/if}} {{/if}} diff --git a/application/plugins/expressforkdn/Admin.php b/application/plugins/expressforkdn/Admin.php new file mode 100644 index 000000000..f29d24fb1 --- /dev/null +++ b/application/plugins/expressforkdn/Admin.php @@ -0,0 +1,65 @@ +assign('express_list', ExpressService::ExpressList()); + $this->assign('data', $ret['data']); + return $this->fetch('../../../plugins/view/expressforkdn/admin/index'); + } else { + return $ret['msg']; + } + } + + /** + * 编辑页面 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @datetime 2019-02-07T08:21:54+0800 + * @param [array] $params [输入参数] + */ + public function saveinfo($params = []) + { + $ret = PluginsService::PluginsData('expressforkdn'); + if($ret['code'] == 0) + { + $this->assign('express_list', ExpressService::ExpressList()); + $this->assign('data', $ret['data']); + return $this->fetch('../../../plugins/view/expressforkdn/admin/saveinfo'); + } else { + return $ret['msg']; + } + } + /** + * 数据保存 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @datetime 2019-02-07T08:21:54+0800 + * @param [array] $params [输入参数] + */ + public function save($params = []) + { + return PluginsService::PluginsDataSave(['plugins'=>'expressforkdn', 'data'=>$params]); + } +} +?> \ No newline at end of file diff --git a/application/plugins/expressforkdn/Hook.php b/application/plugins/expressforkdn/Hook.php new file mode 100644 index 000000000..6a3ac4ef9 --- /dev/null +++ b/application/plugins/expressforkdn/Hook.php @@ -0,0 +1,317 @@ +operation($params); + break; + + // 弹窗代码 + case 'plugins_view_common_bottom' : + case 'plugins_admin_view_common_bottom' : + $ret = $this->html($params); + break; + + // 页面底部 + case 'plugins_common_page_bottom' : + case 'plugins_admin_common_page_bottom' : + $ret = $this->js($params); + break; + + // header代码 + case 'plugins_common_header' : + case 'plugins_admin_common_header' : + $ret = $this->css($params); + break; + + default : + $ret = ''; + } + return $ret; + } + return ''; + } + + /** + * css + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @datetime 2019-02-06T16:16:34+0800 + * @param [array] $params [输入参数] + */ + public function css($params = []) + { + return ''; + } + + /** + * js + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @datetime 2019-02-06T16:16:34+0800 + * @param [array] $params [输入参数] + */ + public function js($params = []) + { + return ''; + } + + /** + * 视图 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @datetime 2019-02-06T16:16:34+0800 + * @param [array] $params [输入参数] + */ + public function html($params = []) + { + // 获取应用数据 + $ret = PluginsService::PluginsData('expressforkdn', ['images']); + if($ret['code'] == 0) + { + $this->assign('data', $ret['data']); + return $this->fetch('../../../plugins/view/expressforkdn/admin/content'); + } else { + return $ret['msg']; + } + } + + /** + * 操作 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @datetime 2019-02-06T16:16:34+0800 + * @param [array] $params [输入参数] + */ + public function operation($params = []) + { + if(empty($params['order'])) + { + return DataReturn('订单为空', -1); + } + + // 钩子html + if(isset($params['order']['status']) && in_array($params['order']['status'], [3,4])) + { + + $params['order']['plugins_service_order_handle_operation_html'][] = ''; + } + + 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 .= '