初始版本
This commit is contained in:
42
server/app/shopapi/lists/ShopGoodsLists.php
Executable file
42
server/app/shopapi/lists/ShopGoodsLists.php
Executable file
@@ -0,0 +1,42 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user