request; if ($retuest->isAjax) { if ($retuest->isGet) { $get = Yii::$app->request->get(); // 检查提交的参数 $res = Yii::$app->services->validate->validate($get,[ [['user_id','mobile','user_keyword','name','create_time'], 'safe'], [['limit'],'default','value' => '15'], ]); if($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage()); $where = []; if (!empty($get['user_keyword'])) { $user_ids = User::find()->select("id")->where(['mall_id' => $this->mall_id])->andWhere(['like', 'mobile', $get['user_keyword'] . '%', false])->asArray()->column(); $user_name = User::find()->select("id")->where(['mall_id' => $this->mall_id])->andWhere(['like', 'nickname', $get['user_keyword'] . '%', false])->asArray()->column(); $user_ids = $user_ids + $user_name; if (empty($user_ids)) $this->success('查无此用户'); $where[] = ['in', 'user_id', $user_ids]; } if($get['create_time']) $where[] = ['between', 'created_at', strtotime($get['create_time'][0]),strtotime($get['create_time'][1])]; $with = ['user']; if(!empty($get['user_id'])) $where[] = ['=', 'user_id', $get['user_id']]; //筛选出正在进行的活动 $active = Recommen::find()->select("id")->where(['mall_id' => $this->mall_id])->andWhere(['>', 'start_time', time()])->andWhere(['<', 'end_time', time()])->asArray()->column(); if($active) { $where[] = ['in', 'active_id', $active]; } $where[] = ['=', 'mall_id', $this->mall_id]; $where[] = ['>=', 'status', StatusEnum::DISABLED]; $order = 'new_num desc'; $params = array('where' => $where,'with' => $with,'group'=>'user_id','order'=>$order, 'limit' => $get['limit']); $params['select'] = 'user_id,max(new_num) as new_num'; $list = RecommenLog::listPage($params, false, true); $this->success('获取成功', $list); } } else { return $this->render($this->action->id); } } }