['sn'], '=' => ['user_id'], ]; } /** * @notes 获取用户订单列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author 段誉 * @date 2022/3/14 14:50 */ public function lists(): array { $goodFields = [ 'order_id', 'goods_id', 'item_id', 'goods_snap', 'goods_name', 'goods_price', 'goods_num' ]; $lists = Order::with([ 'order_goods' => function ($query) use ($goodFields) { $query->field($goodFields) ->append(['goods_image', 'spec_value_str']) ->hidden(['goods_snap']); }]) ->field(['id', 'sn', 'order_status', 'order_amount','order_type', 'create_time']) ->where($this->searchWhere) ->append(['order_status_desc', 'order_type_desc']) ->limit($this->limitOffset, $this->limitLength) ->order('id desc') ->select()->toArray(); return $lists; } /** * @notes 记录数量 * @return int * @author 段誉 * @date 2022/3/14 14:51 */ public function count(): int { return Order::where($this->searchWhere)->count(); } }