render('/order/index'); } public function actionList() { try { $activity_id = \Yii::$app->request->get('activity_id') ?? 0; $order_no = \Yii::$app->request->get('order_no') ?? ''; $mobile = \Yii::$app->request->get('mobile') ?? ''; $user_id = \Yii::$app->request->get('user_id') ?? ''; $begin = \Yii::$app->request->get('begin') ?? ''; $end = \Yii::$app->request->get('end') ?? ''; $page = \Yii::$app->request->get('page', 1); $limit = \Yii::$app->request->get('limit', $this->pageSize); $where[] = ['and', ['mall_id' => $this->mall_id], ['!=', 'status', StatusEnum::DELETE],['=', 'order_source', SeckillEnum::ADDONS_NAME]]; if($activity_id){ $where[] = ['=', 'extra_info', 'seckill_activity_'.$activity_id]; } if($order_no){ $where[] = ['=', 'order_no', $order_no]; } if($user_id){ $where[] = ['=', 'user_id', $user_id]; } if($mobile){ $uids = User::find()->select('id')->where(['like','mobile',$mobile.'%',false])->column(); !empty($uids) && $where[] = ['in', 'user_id', $uids]; } ($begin ?? false) && $where[] = ['>=', 'created_at', strtotime($begin)]; ($end ?? false) && $where[] = ['<=', 'created_at', strtotime($end)]; $with = ['base_user', 'detail']; $order = "id desc"; $params = compact('where', 'with', 'order'); $page_data = Order::listPage($params, false, true); $extra_info = array_column($page_data['list'],'extra_info'); $activity_ids = []; foreach($extra_info as $value){ $id = str_replace('seckill_activity_','',$value); $id && $activity_ids[] = $id; } $activity_ids = array_unique($activity_ids); //查询活动 $activity_list = SeckillActivity::find()->where(['id' => $activity_ids])->select('id,title,price')->asArray()->all(); $activity_list = array_column($activity_list,null,'id'); foreach($page_data['list'] as $key =>$value){ $activity_id = str_replace('seckill_activity_','',$value['extra_info']); $value['activity_title'] = $activity_list[$activity_id]['title'] ?? ''; $value['activity_price'] = $activity_list[$activity_id]['price'] ?? 0; $page_data['list'][$key] = $value; } return $this->success('请求成功', $page_data); } catch (\Exception $exception) { return $this->error($exception->getMessage()); } } }