初始版本

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,52 @@
<?php
namespace app\coachapi\lists;
use app\common\enum\coach\CoachEnum;
use app\common\enum\GoodsEnum;
use app\common\model\coach\Coach;
use app\common\model\coach\CoachGoodsIndex;
use app\common\model\goods\Goods;
use app\common\model\goods\GoodsSkillIndex;
class GoodsLists extends BaseCoachApiDataLists
{
public function setWhere(){
$where = [];
$where[] = ['status','=',1];
$id = $this->params['id'] ?? 0;
$isCoach = $this->params['is_coach'] ?? 0;
$where[] = ['audit_status','=',GoodsEnum::AUDIT_STATUS_PASS];
$shopId = Coach::where(['id'=>$this->coachId])->value('shop_id');
if($shopId){
$where[] = ['shop_id','in',[$shopId,0]];
}else{
$where[] = ['shop_id','=',0];
}
if($id){
$goodsIds = GoodsSkillIndex::where(['skill_id'=>$id])->column('goods_id');
empty($goodsIds) && $goodsIds = [];
$where[] = ['id','in',implode(',',$goodsIds)];
}
if($isCoach){
$goodsIds = CoachGoodsIndex::where(['coach_id'=>$this->coachId])->column('goods_id');
empty($goodsIds) && $goodsIds = [];
$where[] = ['id','in',implode(',',$goodsIds)];
}
return $where;
}
public function lists(): array
{
$lists = Goods::where($this->setWhere())
->field('id,name,image,price')
->limit($this->limitOffset, $this->limitLength)
->select()->toArray();
return $lists;
}
public function count(): int
{
return Goods::where(['status'=>1])
->where($this->setWhere())
->count();
}
}