初始版本

This commit is contained in:
贾祥聪
2025-08-19 14:16:51 +08:00
commit f937a1f9b9
4373 changed files with 359728 additions and 0 deletions

View File

@@ -0,0 +1,68 @@
<?php
namespace app\coachapi\lists;
use app\common\model\goods\GoodsComment;
use app\common\model\user\User;
/**
* 订单评论列表
* Class GoodsComment
* @package app\coachapi\lists
*/
class GoodsCommentLists extends BaseCoachApiDataLists
{
public function setWhere()
{
$where = [];
$id = $this->params['id'] ?? 0;
switch ($id){
case 1:
$coachOrderId = GoodsComment::alias('GC')
->where(['GC.coach_id'=>$this->coachId])
->join('goods_comment_image GCI','GC.id = GCI.comment_id')
->column('GC.id') ?: [];
$where[] = ['id','in',$coachOrderId];
break;
case 2:
$where[] = ['service_comment','>',3];
break;
case 3:
$where[] = ['service_comment','<=',3];
break;
}
return $where;
}
public function lists(): array
{
$lists = GoodsComment::where(['coach_id'=>$this->coachId])
->where($this->setWhere())
->with(['goods_comment_image'])
->field('id,user_id,service_comment,comment,reply,create_time')
->limit($this->limitOffset, $this->limitLength)
->order('id desc')
->select()->toArray();
$userIds = array_column($lists,'user_id');
$userLists = [];
if($userIds){
$userLists = User::where(['id'=>$userIds])->field('id,nickname,avatar')->select()->toArray();
$userLists = array_column($userLists,null,'id');
}
foreach ($lists as $key => $goodsComment){
$lists[$key]['nickname'] = $userLists[$goodsComment['user_id']]['nickname'];
$lists[$key]['avatar'] = $userLists[$goodsComment['user_id']]['avatar'];
}
return $lists;
}
public function count(): int
{
return GoodsComment::where(['coach_id'=>$this->coachId])
->where($this->setWhere())
->count();
}
}