/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Activity::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'category_id' => $this->category_id, 'start_time' => $this->start_time, 'end_time' => $this->end_time, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'status' => $this->status]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'url', $this->url])->andFilterWhere(['like', 'thumbnail_base_url', $this->thumbnail_base_url])->andFilterWhere(['like', 'thumbnail_path', $this->thumbnail_path])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'slug', $this->slug]); return $dataProvider; }
/** * 获得活动分类 * @return type */ public function showActivity() { $fitArray = []; $result = Activity::find()->select(['id', 'ac_cname'])->where('ac_status=0 and UNIX_TIMESTAMP() BETWEEN ac_starttime AND ac_endtime ')->asArray()->indexBy('id')->all(); if ($result) { foreach ($result as $key => $value) { $fitArray[$key] = $value['ac_cname']; } } return $fitArray; }
/** * @return array|bool */ public function actionChangeactivity() { if (Yii::$app->request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; $id = intval(Yii::$app->request->post('id')); if ($id) { $new_activity = Activity::find()->where('id != :id', ['id' => $id])->orderBy('RAND()')->one(); return $new_activity; } } return false; }
public function init() { // $presents = (new Present())->presents; $presents = (new Present())->getPresentsList(); $activity = Activity::find()->orderBy('RAND()')->one(); $query = Participant::find()->orderBy(['id' => SORT_DESC]); $countQuery = clone $query; $p_pages = new Pagination(['totalCount' => $countQuery->count()]); $p_pages->pageSize = 10; $models = $query->offset($p_pages->offset)->limit($p_pages->limit)->all(); $winners = Participant::find()->where(['winner' => 1])->all(); $this->getView()->params = ['participants' => $models, 'participants_pages' => $p_pages, 'presents' => $presents, 'activity' => $activity, 'winners' => $winners]; parent::init(); // TODO: Change the autogenerated stub }
/** * Lists all Activity models. * @return mixed */ public function actionIndex() { $dataProvider = new ActiveDataProvider(['query' => Activity::find()]); return $this->render('index', ['dataProvider' => $dataProvider]); }
<div class="participant-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'name')->textInput(['maxlength' => true, 'readonly' => true]); ?> <?php echo $form->field($model, 'phone')->textInput(['maxlength' => true, 'readonly' => true]); ?> <?php echo $form->field($model, 'activity')->dropDownList(ArrayHelper::map(Activity::find()->where(['id' => $model->activity])->all(), 'id', 'text'), ['readonly' => true]); ?> <?php echo $form->field($model, 'text')->textarea(['maxlength' => true, 'readonly' => true]); ?> <?php echo $form->field($model, 'winner')->checkbox(); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div>
public static function getActivitiesByLimit($limit) { return Activity::find()->statusInUse()->orderBy('sort DESC')->limit($limit)->all(); }
/** * */ public static function getRollRestul($object, User $weixinuser, $gift_type) { $pertime = $weixinuser->purview; $fitime = mktime(0, 0, 0, date("m", $pertime), date("d", $pertime), date("Y", $pertime)); $time = mktime(0, 0, 0, date("m"), date("d"), date("Y")); if ((int) $fitime === $time) { $reply = "您今天已经抽过奖了,请明天再来吧。"; } else { #是否已经提醒过 $activity = Activity::find()->where("ac_name=:ac_name", [':ac_name' => 'year2016'])->one(); if (!$activity) { #不存在 $reply = '这个活动不存在'; } else { if (!$activity->isInDate()) { $reply = $activity->isInDateRemark(); } elseif (!$activity->isRightStatus()) { $reply = $activity->isRightStatusRemark(); } else { //获得是否提醒过 switch ($gift_type) { case 1: $fitActivity = Activity::find()->where("ac_name=:ac_name", [':ac_name' => 'year2016money'])->one(); break; case 2: $fitActivity = Activity::find()->where("ac_name=:ac_name", [':ac_name' => 'year2016gift'])->one(); break; case 3: $fitActivity = Activity::find()->where("ac_name=:ac_name", [':ac_name' => 'year2016agio'])->one(); break; default: $fitActivity = Activity::find()->where("ac_name=:ac_name", [':ac_name' => 'year2016money'])->one(); break; } if (!$fitActivity) { $reply = '这个活动不存在'; } else { $remind_nums = ActivityRemind::find()->where('activity_id=:ac_id AND user_id=:user_id', [':ac_id' => $activity->id, ':user_id' => $weixinuser->user_id])->count(); if ($remind_nums < 1) { self::toBigPicArctileShow($object, $weixinuser, $fitActivity, $activity); } else { $result = $activity->toRollActivity($weixinuser, $fitActivity->id); $reply = $result['remark']; if ($result['status'] != 2) { User::updateAll(['purview' => time()], 'user_id=:user_id', [':user_id' => $weixinuser->user_id]); } } } } } } WechatCheck::_transmitText($object, $reply); }