['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(); } }