Evaluate.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkAdmin
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://demo.thinkadmin.top
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // +----------------------------------------------------------------------
  11. // | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
  12. // | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
  13. // +----------------------------------------------------------------------
  14. namespace app\store\controller;
  15. use library\Controller;
  16. use library\tools\Data;
  17. use think\Db;
  18. /**
  19. * 评论列表
  20. * Class GoodsCate
  21. * @package app\store\controller
  22. */
  23. class Evaluate extends Controller
  24. {
  25. /**
  26. * 绑定数据表
  27. * @var string
  28. */
  29. protected $table = 'store_evaluate';
  30. /**
  31. * 评论列表管理
  32. * @auth true
  33. * @menu true
  34. * @throws \think\Exception
  35. * @throws \think\db\exception\DataNotFoundException
  36. * @throws \think\db\exception\ModelNotFoundException
  37. * @throws \think\exception\DbException
  38. * @throws \think\exception\PDOException
  39. */
  40. public function index()
  41. {
  42. $this->title = '评论列表管理';
  43. $query = $this->_query($this->table);
  44. $where[]=['a.is_deleted','=',0];
  45. if($this->request->request('phone')){
  46. $where[]=['m.phone','like','%'.$this->request->request('phone').'%'];
  47. }
  48. if($this->request->request('name')){
  49. $where[]=['m.name','like','%'.$this->request->request('name').'%'];
  50. }
  51. if($this->request->request('content')){
  52. $where[]=['a.content','like','%'.$this->request->request('content').'%'];
  53. }
  54. $query
  55. ->alias('a')
  56. ->field('a.*,m.phone,m.name')
  57. ->join('store_member m','a.user_id = m.id')
  58. ->where($where)
  59. ->order('a.id desc')
  60. ->page();
  61. }
  62. /**需求列表处理
  63. * @param array $data
  64. * @throws \think\db\exception\DataNotFoundException
  65. * @throws \think\db\exception\ModelNotFoundException
  66. * @throws \think\exception\DbException
  67. */
  68. protected function _index_page_filter(array &$data)
  69. {
  70. $mids = array_unique(array_merge(array_column($data, 'user_id'), array_column($data, 'from_mid')));
  71. $memberList = Db::name('StoreMember')->whereIn('id', $mids)->select();
  72. foreach ($data as &$vo) {
  73. if($vo['images']){
  74. $vo['images'] = image_path($vo['images']);
  75. }
  76. list($vo['member'], $vo['from_member'], $vo['list']) = [[], [], []];
  77. foreach ($memberList as $member) if ($member['id'] === $vo['user_id']) {
  78. $vo['member'] = $member;
  79. }
  80. }
  81. }
  82. /**
  83. * 删除评论
  84. * @auth true
  85. * @throws \think\Exception
  86. * @throws \think\exception\PDOException
  87. */
  88. public function remove()
  89. {
  90. $this->_save($this->table, ['is_deleted' => '1']);
  91. }
  92. }