| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 | 
							- <?php
 
- namespace app\api\controller;
 
- use app\common\model\Comment as CommentModel;
 
- use app\common\model\Order;
 
- use app\common\model\OrderAftersales;
 
- use app\common\model\OrderAction;
 
- use app\common\Service\Goods\CommentService;
 
- use app\api\validate\Comment as CommentValidate;
 
- use app\common\Enum\CommentEnum;
 
- use think\Db;
 
- use app\common\Enum\OrderEnum;
 
- /**
 
-  * 评论
 
-  */
 
- class Comment extends Base
 
- {
 
-     protected $noNeedLogin = ['index'];
 
-     /**
 
-      * 评论列表
 
-      */
 
-     public function index()
 
-     {
 
-         $params = $this->request->post();
 
-         
 
-         // 验证参数
 
-         $validate = new CommentValidate();
 
-         if (!$validate->scene('index')->check($params)) {
 
-             $this->error($validate->getError());
 
-         }
 
-         
 
-         $list = CommentService::getCommentList($params);
 
-         foreach ($list as $item) {
 
-             if ($item->user) {
 
-                 $item->user->avatar = cdnurl($item->user->avatar, true);
 
-                 $item->user->visible(explode(',', 'id,nickname,avatar'));
 
-             }
 
-             $item->hidden(explode(',', 'subscribe,status,ip,useragent'));
 
-         }
 
-         $this->success('获取成功', $list);
 
-     }
 
-     /**
 
-      * 添加评论
 
-      */
 
-     public function add()
 
-     {
 
-         $params = $this->request->param();
 
-         
 
-         // 验证参数
 
-         $validate = new CommentValidate();
 
-         if (!$validate->scene('add')->check($params)) {
 
-             $this->error($validate->getError());
 
-         }
 
-         $pid = isset($params['pid']) ? (int)$params['pid'] : 0;
 
-         $order_id = (int)$params['order_id'];
 
-         $remark = $params['remark'];
 
-         CommentService::addComment($this->auth->id, $order_id, $remark, $pid);
 
-         $this->success('添加评论成功,等待审核!');
 
-        
 
-     }
 
-     /**
 
-      * 我的评价
 
-      */
 
-     public function myList()
 
-     {
 
-         $params = $this->request->param();
 
-         
 
-         // 验证参数
 
-         $validate = new CommentValidate();
 
-         if (!$validate->scene('myList')->check($params)) {
 
-             $this->error($validate->getError());
 
-         }
 
-         
 
-         $page = isset($params['page']) ? (int)$params['page'] : 1;
 
-         $pagesize = isset($params['pagesize']) ? (int)$params['pagesize'] : 10;
 
-         
 
-         $list = CommentService::getUserCommentList($this->auth->id, $page, $pagesize);
 
-         
 
-         foreach ($list as $item) {
 
-             $item->hidden(['ip', 'subscribe', 'useragent', 'comments']);
 
-         }
 
-         
 
-         $this->success('获取成功', $list);
 
-     }
 
-     /**
 
-      * 获取商品评论统计
 
-      */
 
-     public function stats()
 
-     {
 
-         $params = $this->request->param();
 
-         
 
-         // 验证参数
 
-         $validate = new CommentValidate();
 
-         if (!$validate->scene('stats')->check($params)) {
 
-             $this->error($validate->getError());
 
-         }
 
-         
 
-         $goods_id = (int)$params['goods_id'];
 
-         $stats = CommentService::getCommentStats($goods_id);
 
-         
 
-         $this->success('获取成功', $stats);
 
-     }
 
-     /**
 
-      * 审核评论 (管理员功能)
 
-      */
 
-     public function audit()
 
-     {
 
-         $params = $this->request->param();
 
-         
 
-         // 验证参数
 
-         $validate = new CommentValidate();
 
-         if (!$validate->scene('audit')->check($params)) {
 
-             $this->error($validate->getError());
 
-         }
 
-         
 
-         $comment_id = (int)$params['comment_id'];
 
-         $evaluate_status = (int)$params['evaluate_status'];
 
-         
 
-         CommentService::auditComment($comment_id, $evaluate_status);
 
-         $this->success('审核成功');
 
-     
 
-     }
 
-     /**
 
-      * 获取评论状态列表
 
-      */
 
-     public function getStatusList()
 
-     {
 
-         $data = [
 
-             'evaluate_status' => CommentEnum::getEvaluateStatusList(),
 
-             'status' => CommentEnum::getStatusList(),
 
-             'has_picture' => CommentEnum::getHasPictureList(),
 
-         ];
 
-         
 
-         $this->success('获取成功', $data);
 
-     }
 
- }
 
 
  |