params['service_status']; $work_ids = ServiceWork::where(['user_id' => $this->userId])->where(function ($query) use($service_status) { if($service_status != 'all'){ $query->where(['service_status' => $service_status]); } })->column('id'); if($service_status != 'all'){ $where['pay_status'] = $service_status==4?2:1; } $work_ids = !empty($work_ids)?implode(',',$work_ids):'999999'; $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','work_status','user_confirm_status','appointment_time'])->append(['service_status_text','work_status_text','user_confirm_status_text','user_service_status','user_service_status_text']); }]) ->where($where) ->whereIn('work_id',$work_ids) ->field('id, sn, payment_type, order_total,work_id, pay_status, create_time, SUM(order_amount) as order_amount') ->visible(['id','sn','payment_type','order_total','pay_status','create_time','order_amount']) ->where([ 'order_type' => 0, 'user_id' => $this->userId, ]) ->limit($this->limitOffset, $this->limitLength) ->group('work_id') ->order('id', 'desc') ->select()->each(function ($item) { //用户按钮状态显示 }) ->toArray(); $this->count = RechargeOrder::where([ 'order_type' => 0, 'user_id' => $this->userId, ]) ->where($where) ->whereIn('work_id',$work_ids) ->group('work_id') ->count(); return $lists; } /** * @notes 获取数量 * @return int */ public function count(): int { return $this->count; } }