初始版本
This commit is contained in:
111
server/app/api/lists/ShopCommentGoodsLists.php
Executable file
111
server/app/api/lists/ShopCommentGoodsLists.php
Executable file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\lists;
|
||||
|
||||
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\lists\ListsExtendInterface;
|
||||
use app\common\model\coach\Coach;
|
||||
use app\common\model\goods\Goods;
|
||||
use app\common\model\order\Order;
|
||||
use app\common\model\order\OrderGoods;
|
||||
use app\common\model\user\User;
|
||||
use app\common\service\FileService;
|
||||
|
||||
class ShopCommentGoodsLists extends BaseApiDataLists
|
||||
{
|
||||
/**
|
||||
* @notes 搜索条件
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/2/18 2:25 下午
|
||||
*/
|
||||
public function setSearch()
|
||||
{
|
||||
$shopId = $this->params['shop_id'];
|
||||
$coachIds = Coach::where(['shop_id'=>$shopId])->field('id')->select()->toArray();
|
||||
$coachIds = array_column($coachIds,'id');
|
||||
$orderGoodsIds = Order::alias('O')
|
||||
->join('order_goods OG','O.id = OG.order_id')
|
||||
->where(['coach_id'=>$coachIds])
|
||||
->field('OG.id')->select()->toArray();
|
||||
$orderGoodsIds = array_column($orderGoodsIds,'id');
|
||||
$where[] = ['og.id','in',$orderGoodsIds];
|
||||
$where[] = ['o.order_status', '=', OrderEnum::ORDER_STATUS_SERVER_FINISH];
|
||||
$where[] = ['og.is_comment','=',1];
|
||||
return $where;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 评价商品列表
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/2/21 5:59 下午
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$lists = OrderGoods::alias('og')
|
||||
->join('order o', 'o.id = og.order_id')
|
||||
->field('o.user_id,og.id,coach_id,og.goods_id,og.goods_name,og.goods_price,og.is_comment,appoint_time,og.goods_snap')
|
||||
->append(['goods_comment'])
|
||||
->where($this->setSearch())
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order('og.id','desc')
|
||||
->group('og.id')
|
||||
->select()
|
||||
->toArray();
|
||||
// $goodsIds = array_column($lists,'goods_id');
|
||||
// $coachIds = array_column($lists,'coach_id');
|
||||
// $goodsLists = Goods::where(['id'=>$goodsIds])->column('tags,order_num','id');
|
||||
// $coachLists = Coach::where(['id'=>$coachIds])->column('name,work_photo','id');
|
||||
$userIds = array_column($lists,'user_id');
|
||||
$userLists = User::where(['id'=>$userIds])->column('id,nickname,avatar','id');
|
||||
foreach ($lists as &$list) {
|
||||
// $list['goods_snap']['image'] = FileService::getFileUrl($list['goods_snap']['image']);
|
||||
// $list['goods_snap']['tags'] = $goodsLists[$list['goods_id']]['tags'];
|
||||
// $list['goods_snap']['order_num'] = $goodsLists[$list['goods_id']]['order_num'];
|
||||
// $list['appoint_date'] = date('m-d',$list['appoint_time']);
|
||||
// $list['appoint_time'] = date('H:i',$list['appoint_time']);
|
||||
// $list['coach_info'] = $coachLists[$list['coach_id']] ?? [];
|
||||
$list['nickname'] = $userLists[$list['user_id']]['nickname'] ?? '';
|
||||
$list['avatar'] = FileService::getFileUrl($userLists[$list['user_id']]['avatar'] ?? '');
|
||||
}
|
||||
|
||||
return $lists;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 评价商品总数
|
||||
* @return int
|
||||
* @author ljj
|
||||
* @date 2022/2/21 5:59 下午
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return OrderGoods::alias('og')
|
||||
->join('order o', 'o.id = og.order_id')
|
||||
->where($this->setSearch())
|
||||
->group('og.id')
|
||||
->select()
|
||||
->count();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user