params['service_status'])) { $work_ids = ServiceWork::where(['user_id' => $this->userId])->where(function ($query) { if($this->params['service_status'] != 'all'){ $query->where(['service_status' => $this->params['service_status']]); } })->column('id'); $where['work_id'] = ['in', $work_ids]; } return $where; } /** * @notes 获取列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function lists(): array { $lists = RechargeOrder::with(['order_goods'=>function ($query) { $query->visible(['goods_name','goods_image','goods_number','good_unit']); },'service_work'=>function ($query) { $query->visible(['service_status']); }]) ->where($this->queryWhere()) ->visible(['id','sn','order_total','order_amount','pay_status','create_time']) ->where([ 'order_type' => 0, 'user_id' => $this->userId, ]) ->limit($this->limitOffset, $this->limitLength) ->group('work_id') ->order('id', 'desc') ->select() ->toArray(); $this->count = RechargeOrder::where([ 'order_type' => 0, 'user_id' => $this->userId, ]) ->group('work_id') ->count(); return $lists; } /** * @notes 获取数量 * @return int */ public function count(): int { return $this->count; } }