123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- <?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('非法操作');
- }
- $this->engineer_id = session('user.engineer_id');
- $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)
- {
- $type_arr = array('1'=>'提问','2'=>'解答','3'=>'追问');
- foreach ($data as &$vo) {
- if($vo['type'] == 2){
- $table_name = 'store_engineer';
- }else{
- $table_name = 'store_member';
- }
- $vo['member'] = Db::name($table_name)->field('headimg,name,phone')->where('id',$vo['user_id'])->find();
- $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);
- //添加消息通知
- $user_id = Db::name('store_consult')->where('id',$id)->value('user_id');
- $new_data = array(
- 'user_id' => $user_id,
- 'content' => '您咨询的问题得到了新的回复,赶紧快来查看~',
- 'consult_id' => $root_consult_id,
- 'type' => 2
- );
- Db::name('store_news')->insert($new_data);
- $this->success('解答成功');
- } else {
- $this->_form($this->table, 'answer');
- }
- }
- }
|