|
@@ -0,0 +1,168 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+// | ThinkAdmin
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+// | 官方网站: http://demo.thinkadmin.top
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+// | 开源协议 ( https://mit-license.org )
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+// | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
|
|
+// | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+
|
|
|
+namespace app\store\controller;
|
|
|
+
|
|
|
+use library\Controller;
|
|
|
+use library\tools\Data;
|
|
|
+use think\Db;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 咨询管理
|
|
|
+ * Class Goods
|
|
|
+ * @package app\store\controller
|
|
|
+ */
|
|
|
+class Consult extends Controller
|
|
|
+{
|
|
|
+ /**
|
|
|
+ * 指定数据表
|
|
|
+ * @var string
|
|
|
+ */
|
|
|
+ protected $table = 'StoreConsult';
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 咨询管理
|
|
|
+ * @auth true
|
|
|
+ * @menu true
|
|
|
+ * @throws \think\Exception
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
+ */
|
|
|
+ public function index()
|
|
|
+ {
|
|
|
+ $this->title = '咨询管理';
|
|
|
+ $query = $this->_query($this->table)->equal('status,cate_id')->like('title');
|
|
|
+ $query->where(['is_deleted' => '0'])->order(['is_top'=>'desc','sort'=>'desc','id'=>'desc'])->page();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 数据列表处理
|
|
|
+ * @param array $data
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ */
|
|
|
+ protected function _index_page_filter(&$data)
|
|
|
+ {
|
|
|
+ foreach ($data as &$vo) {
|
|
|
+ $vo['cate_name'] = Db::name('store_goods_cate')->where('id',$vo['cate_id'])->value('title');
|
|
|
+ $media_info = Db::name('store_media')->field('logo,title')->where('id',$vo['media_id'])->find();
|
|
|
+ $vo['media_logo'] = $media_info['logo'];
|
|
|
+ $vo['media_title'] = $media_info['title'];
|
|
|
+ }
|
|
|
+ $this->cate_arr = Db::name('store_goods_cate')->field('id,title')->where('status',1)->where('is_deleted',0)->select();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加咨询
|
|
|
+ * @auth true
|
|
|
+ * @throws \think\Exception
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
+ */
|
|
|
+ public function add()
|
|
|
+ {
|
|
|
+ $this->title = '添加咨询信息';
|
|
|
+ $this->cate_arr = Db::name('store_goods_cate')->field('id,title')->where('status',1)->where('is_deleted',0)->select();
|
|
|
+ $this->media_arr = Db::name('store_media')->field('id,title')->where('status',1)->where('is_deleted',0)->select();
|
|
|
+ $this->is_top = array('0'=>'不置顶','1'=>'置顶');
|
|
|
+ $this->_form($this->table, 'form');
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 编辑咨询
|
|
|
+ * @auth true
|
|
|
+ * @throws \think\Exception
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
+ */
|
|
|
+ public function edit()
|
|
|
+ {
|
|
|
+ $this->title = '编辑咨询信息';
|
|
|
+ $this->_form($this->table, 'form');
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 表单数据处理
|
|
|
+ * @param array $data
|
|
|
+ * @throws \think\Exception
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
+ */
|
|
|
+ protected function _form_filter(&$data)
|
|
|
+ {
|
|
|
+ // 生成活动ID
|
|
|
+ if ($this->request->isGet()) {
|
|
|
+ $this->cate_arr = Db::name('store_goods_cate')->field('id,title')->where('status',1)->where('is_deleted',0)->select();
|
|
|
+ $this->media_arr = Db::name('store_media')->field('id,title')->where('status',1)->where('is_deleted',0)->select();
|
|
|
+ $this->is_top = array('0'=>'不置顶','1'=>'置顶');
|
|
|
+ } elseif ($this->request->isPost()) {
|
|
|
+ if (empty($data['image'])) $this->error('展示图片不能为空,请上传图片');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 表单结果处理
|
|
|
+ * @param boolean $result
|
|
|
+ */
|
|
|
+ protected function _form_result($result)
|
|
|
+ {
|
|
|
+ if ($result && $this->request->isPost()) {
|
|
|
+ $this->success('活动编辑成功!', 'javascript:history.back()');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 禁用咨询
|
|
|
+ * @auth true
|
|
|
+ * @throws \think\Exception
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
+ */
|
|
|
+ public function forbid()
|
|
|
+ {
|
|
|
+ $this->_save($this->table, ['status' => '0']);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 启用咨询
|
|
|
+ * @auth true
|
|
|
+ * @throws \think\Exception
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
+ */
|
|
|
+ public function resume()
|
|
|
+ {
|
|
|
+ $this->_save($this->table, ['status' => '1']);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除咨询
|
|
|
+ * @auth true
|
|
|
+ * @throws \think\Exception
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
+ */
|
|
|
+ public function remove()
|
|
|
+ {
|
|
|
+ $this->_delete($this->table);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|