42 lines
1.2 KiB
PHP
Executable File
42 lines
1.2 KiB
PHP
Executable File
<?php
|
|
namespace app\shopapi\lists;
|
|
use app\coachapi\lists\BaseCoachApiDataLists;
|
|
use app\common\enum\GoodsEnum;
|
|
use app\common\model\goods\Goods;
|
|
|
|
/**
|
|
* 服务列表
|
|
* Class GoodsShopLists
|
|
* @package app\shopapi\lists
|
|
*/
|
|
class ShopGoodsLists extends BaseShopApiDataLists
|
|
{
|
|
public function setWhere()
|
|
{
|
|
$where = [];
|
|
// $where[] = ['status','=',1];
|
|
// $where[] = ['audit_status','=',GoodsEnum::AUDIT_STATUS_PASS];
|
|
$where[] = ['shop_id','=',$this->shopId];
|
|
if(isset($this->params['category_id']) && $this->params['category_id']){
|
|
$where[] = ['category_id','=',$this->params['category_id']];
|
|
}
|
|
if(isset($this->params['status']) && '' !== $this->params['status']){
|
|
$where[] = ['audit_status','=',$this->params['status']];
|
|
}
|
|
return $where;
|
|
}
|
|
|
|
public function lists(): array
|
|
{
|
|
$lists = Goods::where($this->setWhere())
|
|
->field('id,name,image,audit_status,price,virtual_order_num+order_num as order_num,status')
|
|
->limit($this->limitOffset, $this->limitLength)
|
|
->select()->toArray();
|
|
return $lists;
|
|
}
|
|
|
|
public function count(): int
|
|
{
|
|
return Goods::where($this->setWhere())->count();
|
|
}
|
|
} |