544782275@qq.com 3 years ago
parent
commit
a637def2f9

+ 107 - 0
application/store/controller/ConsultDetail.php

@@ -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');
+        }
+
+    }
+}

+ 19 - 0
application/store/view/consult_detail/answer.html

@@ -0,0 +1,19 @@
+
+<form onsubmit="return false;" action="{:request()->url()}" data-auto="true" method="post" class='layui-form layui-card' autocomplete="off" style="padding: 0 20px;">
+
+    <div class="layui-card-body">
+        <div class="layui-row margin-bottom-15">
+            <label class="layui-col-xs2 think-form-label">解答内容</label>
+            <label class="layui-col-xs10">
+                <input name="answer_content" required value='' placeholder="请输入解答内容" class="layui-input">
+            </label>
+        </div>
+    </div>
+
+    <div class="hr-line-dashed"></div>
+    <div class="layui-form-item text-center">
+        <input type='hidden' value='{$id}' name='id'>
+        <button class="layui-btn" type='submit'>立即解答</button>
+        <button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消吗?" data-close>取消解答</button>
+    </div>
+</form>

+ 57 - 0
application/store/view/consult_detail/index.html

@@ -0,0 +1,57 @@
+{extend name='admin@main'}
+
+{block name="content"}
+<div class="think-box-shadow">
+    <table class="layui-table margin-top-10" lay-skin="line">
+        {notempty name='list'}
+        <thead>
+        <tr>
+            <th class='list-table-check-td think-checkbox'>
+                <input data-auto-none data-check-target='.list-check-box' type='checkbox'>
+            </th>
+            <th class="text-left nowrap">会员/工程师信息</th>
+            <th class='text-left nowrap'>问题/解答内容</th>
+            <th class='text-left nowrap'>类型</th>
+            <th class='text-left nowrap'>时间</th>
+            {if $engineer_id > 0}
+            <th class='text-left nowrap'>操作</th>
+            {/if}
+        </tr>
+        </thead>
+        {/notempty}
+        <tbody>
+        {foreach $list as $key=>$vo}
+        <tr>
+            <td class='list-table-check-td think-checkbox'><input class="list-check-box" value='{$vo.id}' type='checkbox'></td>
+            <td class="text-left nowrap relative">
+                {notempty name='vo.member.headimg'}
+                <img data-tips-image style="width:40px;height:40px" src="{$vo.member.headimg|default=''}" class="margin-right-5 text-top">
+                {/notempty}
+                <div class="inline-block">
+                    姓名:{$vo.member.name|default='--'}<br>
+                    手机号:{$vo.member.phone|default='--'}<br>
+                </div>
+            </td>
+            <td class='text-left nowrap'>
+                {$vo.content}
+            </td>
+            <td class='text-left nowrap'>
+                {$vo.type_name}
+            </td>
+            <td class='text-left nowrap'>
+               {$vo.create_time}
+            </td>
+            <td class="text-center nowrap">
+                {if $engineer_id > 0 && $vo.is_answer == 0 && $vo.type == 3}
+                <a data-title="立即解答" class="layui-btn layui-btn-sm layui-bg-orange" data-modal='{:url("answer")}?id={$vo.id}'>立即解答</a>
+                {/if}
+            </td>
+        </tr>
+        {/foreach}
+        </tbody>
+    </table>
+
+    {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
+
+</div>
+{/block}