| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <?php
- /**
- *
- */
- namespace app\controller\admin\user;
- use crmeb\basic\BaseController;
- use think\App;
- use app\common\repositories\user\FeedbackRepository as repository;
- use think\facade\Db;
- class FeedBack extends BaseController
- {
- /**
- * @var UserRepository
- */
- protected $repository;
- /**
- * User constructor.
- * @param App $app
- * @param $repository
- */
- public function __construct(App $app, repository $repository)
- {
- parent::__construct($app);
- $this->repository = $repository;
- }
- /**
- * @return mixed
- * @author Qinii
- */
- public function lst()
- {
- $where = $this->request->params(['keyword', 'type', 'status','realname',['is_del',0]]);
- [$page, $limit] = $this->getPage();
- return app('json')->success($this->repository->getList($where, $page, $limit));
- }
- /**
- * @param $id
- * @return mixed
- * @author Qinii
- */
- public function detail($id)
- {
- if (!$this->repository->fieldExists('feedback_id',$id))
- return app('json')->fail('数据不存在');
- $feedback = $this->repository->get($id)->toArray();
- //[$feedback['category'], $feedback['type']] = explode('/', $feedback['type'], 2);
- return app('json')->success($feedback);
- }
- /**
- * @param $id
- * @return mixed
- * @throws \think\db\exception\DbException
- * @author Qinii
- */
- public function reply($id)
- {
- if (!$this->repository->fieldExists('feedback_id',$id))
- return app('json')->fail('数据不存在');
- $data = $this->request->params(['reply', 'remake', 'status']);
- $data['reply_time'] = date("Y-m-d H:i:s");
- $this->repository->update($id,$data);
- return app('json')->success('回复成功');
- }
- /**
- * @param $id
- * @return mixed
- * @author Qinii
- */
- public function delete($id)
- {
- if (!$this->repository->fieldExists('feedback_id',$id))
- return app('json')->fail('数据不存在');
- $this->repository->update($id,['is_del' => 1]);
- return app('json')->success('删除成功');
- }
- /**
- * 意见反馈详情,展示意见反馈内容与图片,反馈人员以及处理结果
- */
- public function feedback_detail($id)
- {
- $data=Db::name('feedback')->where('feedback_id',$id)->find();
- if(empty($data)){
- return app('json')->fail('没有此条反馈');
- }
- $return_data=[
- 'user'=>Db::name('user')->where('uid',$data['uid'])->field('nickname,avatar,uid')->find(),
- 'content'=>$data['content'],
- 'images'=>$data['images'],
- 'realname'=>$data['realname'],
- 'contact'=>$data['contact'],
- 'create_time'=>$data['create_time'],
- 'status'=>$data['status'],
- 'reply'=>$data['reply'],
- 'remake'=>$data['remake'],
- 'reply_time'=>$data['reply_time'],
- 'is_del'=>$data['is_del'],
- 'type'=>Db::name('feedback_category')->where('feedback_category_id',$data['type'])->value('cate_name')
- ];
- return app('json')->success($return_data);
- }
- }
|