|
@@ -0,0 +1,107 @@
|
|
|
+<?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 GoodsCate
|
|
|
+ * @package app\store\controller
|
|
|
+ */
|
|
|
+class ConsultDetail extends Controller
|
|
|
+{
|
|
|
+ /**
|
|
|
+ * 绑定数据表
|
|
|
+ * @var string
|
|
|
+ */
|
|
|
+ protected $table = 'store_consult';
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 全部解答管理
|
|
|
+ * @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 = '全部解答管理';
|
|
|
+ $consult_id = input('consult_id');
|
|
|
+ if(empty($consult_id)){
|
|
|
+ $this->error('非法操作');
|
|
|
+ }
|
|
|
+ $query = $this->_query($this->table);
|
|
|
+ $query->where('root_consult_id',$consult_id)->dateBetween('create_at')->order('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(array &$data)
|
|
|
+ {
|
|
|
+ $mids = array_unique(array_merge(array_column($data, 'user_id'), array_column($data, 'from_mid')));
|
|
|
+ $memberList = Db::name('StoreMember')->whereIn('id', $mids)->select();
|
|
|
+ $type_arr = array('1'=>'提问','2'=>'解答','3'=>'追问');
|
|
|
+ foreach ($data as &$vo) {
|
|
|
+
|
|
|
+ list($vo['member'], $vo['from_member'], $vo['list']) = [[], [], []];
|
|
|
+
|
|
|
+ foreach ($memberList as $member) if ($member['id'] === $vo['user_id']) {
|
|
|
+ $vo['member'] = $member;
|
|
|
+ }
|
|
|
+ $vo['type_name'] = $type_arr[$vo['type']];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 立即解答
|
|
|
+ * @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 answer()
|
|
|
+ {
|
|
|
+ $id = $this->app->request->get('id');
|
|
|
+ $this->assign('id', $id);
|
|
|
+ $post = $this->app->request->post();
|
|
|
+ if (isset($post['id']) && $post['id']) {
|
|
|
+ $root_consult_id = Db::name('store_consult')->where('id',$id)->value('root_consult_id');
|
|
|
+ $data = array(
|
|
|
+ 'user_id' => session('user.engineer_id'),
|
|
|
+ 'content' => $post['answer_content'],
|
|
|
+ 'consult_id' => $id,
|
|
|
+ 'root_consult_id' => $root_consult_id,
|
|
|
+ 'type' => 2
|
|
|
+ );
|
|
|
+ Db::name('store_consult')->where('id',$id)->update(array('is_answer'=>1,'from_user_id'=>session('user.engineer_id')));
|
|
|
+ Db::name('store_consult')->insert($data);
|
|
|
+ $this->success('解答成功');
|
|
|
+ } else {
|
|
|
+ $this->_form($this->table, 'answer');
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+}
|