| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- namespace app\workerapi\lists\shops;
- use app\common\lists\ListsSearchInterface;
- use app\common\model\shops\ShopCart;
- use app\workerapi\lists\BaseWorkerDataLists;
- use think\db\Query;
- /**
- * ShopCartLists列表
- * Class ShopCartLists
- * @package app\api\lists\goods_category
- */
- class ShopCartLists extends BaseWorkerDataLists implements ListsSearchInterface
- {
- /**
- *
- * @return array[]
- */
- public function setSearch(): array
- {
- return [
- '=' => ['shop_goods_id', 'goods_specs_inventory_id'],
- ];
- }
- public function querySearch():array
- {
- $where = [];
- $where[] = ['worker_id', '=', $this->userId];
- return $where;
- }
- /**
- * @notes 获取列表
- * @return array
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- * @author whitef
- * @date 2024/07/07 18:23
- */
- public function lists(): array
- {
- $lists = ShopCart::with([
- 'goods' => function(Query $query){
- $query->field(['id','goods_name','delivery_type','shop_goods_type','goods_image','goods_status','specs_type','custom_attribute_items','company_name',])->append(['delivery_type_text','shop_goods_type_text']);
- },
- 'goodSpecsInventory' => function(Query $query) {
- $query->field(['id','remaining_inventory','specs','service_fee','service_total']);
- }
- ])
- ->where($this->searchWhere)
- ->where($this->querySearch())
- ->field(['id', 'shop_goods_id' ,'goods_specs_inventory_id', 'number'])
- ->limit($this->limitOffset, $this->limitLength)
- ->select()
- ->toArray();
- return $lists;
- }
- /**
- * @notes 获取数量
- * @return int
- * @author whitef
- * @date 2024/07/07 18:23
- */
- public function count(): int
- {
- return ShopCart::where($this->searchWhere) ->where($this->querySearch())->count();
- }
- }
|