['paid','status','is_writeoff'], 'between_time' => 'create_time', '%like%' => ['order_id'], ]; } /** * @notes 零售订单列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @date 2024/04/27 11:26 */ public function lists(): array { $userId=$this->request->userId; if(!$userId) return []; return StoreOrder::with(['store'])->where($this->searchWhere)->where('uid',$userId) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select() ->each(function($item){ $item['goods_list']=StoreOrderCartInfo::where('oid',$item['id'])->with(['goodsName'=> function ($query) { $query->withTrashed(); }])->field('product_id,cart_num,verify_code,is_writeoff,writeoff_time')->limit(3)->select(); $item['goods_count']=count(explode(',',$item['cart_id'])); }) ->toArray(); } /** * @notes 零售订单数量 * @return int * @date 2024/04/27 11:26 */ public function count(): int { $userId=$this->request->userId; return StoreOrder::where($this->searchWhere)->where('uid',$userId)->count(); } }