初始版本
This commit is contained in:
41
server/app/shopapi/lists/MyGoodsLists.php
Executable file
41
server/app/shopapi/lists/MyGoodsLists.php
Executable file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
namespace app\shopapi\lists;
|
||||
use app\coachapi\lists\BaseCoachApiDataLists;
|
||||
use app\common\enum\GoodsEnum;
|
||||
use app\common\model\goods\Goods;
|
||||
use app\common\model\goods\GoodsCategory;
|
||||
use app\common\model\shop\ShopGoodsIndex;
|
||||
|
||||
/**
|
||||
* 服务列表
|
||||
* Class MyGoodsLists
|
||||
* @package app\shopapi\lists
|
||||
*/
|
||||
class MyGoodsLists extends BaseShopApiDataLists
|
||||
{
|
||||
public function setWhere()
|
||||
{
|
||||
$where = [];
|
||||
$where[] = ['status','=',1];
|
||||
$where[] = ['audit_status','=',GoodsEnum::AUDIT_STATUS_PASS];
|
||||
$goodsIds = ShopGoodsIndex::where(['shop_id'=>$this->shopId])->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,status,price,audit_status,virtual_order_num+order_num as order_num')
|
||||
->append(['audit_status_desc','status_desc'])
|
||||
->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