Esempio n. 1
0
 /**
  * Finds the Activity model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Activity the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Activity::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 2
0
 public function actionView($slug)
 {
     $this->layout = 'singlepage';
     $model = Activity::findOne(['slug' => $slug]);
     if (!$model) {
         throw new NotFoundHttpException();
     }
     return $this->render('view', ['model' => $model]);
 }
Esempio n. 3
0
 /**
  * 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;
 }
Esempio n. 4
0
 /**
  * @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;
 }
Esempio n. 5
0
 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
 }
Esempio n. 6
0
 /**
  * 发布资金活动
  * @return boolean
  */
 public function publish()
 {
     //生成随机数据
     $total = $this->gift_price;
     //红包总金额
     $num = $this->gift_nums;
     // 分成10个红包,支持10人随机领取
     $moneyArray = [];
     $time = time();
     $addip = \Yii::$app->request->userIP;
     for ($i = 0; $i < $num; $i++) {
         $money = $this->gift_price;
         $moneyArray[$i] = [0, $this->activity_id, $this->gift_name, $money, 0, $time, 0, 0, $addip];
     }
     \Yii::$app->db->createCommand()->batchInsert(Gift::tableName(), ['user_id', 'activity_id', 'gift_name', 'gift_price', 'gift_status', 'addtime', 'updatetime', 'fittime', 'addip'], $moneyArray)->execute();
     Activity::updateAll(['ac_status' => 1], 'id=' . $this->activity_id);
     return true;
 }
Esempio n. 7
0
<?php

use yii\helpers\Html;
use yii\helpers\ArrayHelper;
use yii\widgets\DetailView;
use common\models\Activity;
/* @var $this yii\web\View */
/* @var $model common\models\Activity */
$this->title = $model->title;
$this->params['breadcrumbs'][] = ['label' => Yii::t('common', 'Activity'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="activity-view">

	<p>
		<?php 
echo Html::a(Yii::t('backend', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
?>
		<?php 
echo Html::a(Yii::t('backend', 'Delete'), ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => Yii::t('backend', 'Are you sure you want to delete this item?'), 'method' => 'post']]);
?>
	</p>

	<?php 
echo DetailView::widget(['model' => $model, 'attributes' => [['attribute' => 'category_id', 'value' => $model->category->title], ['attribute' => 'relation_game_id', 'value' => $model->game->name], 'title', 'description:ntext', 'url:url', 'start_time:datetime', 'end_time:datetime', 'guize:html', 'jiangli:html', 'jiangli_fangfa:html', ['attribute' => 'thumbnail', 'format' => 'html', 'value' => Html::img($model->getThumbnailUrl(), ['class' => 'img-responsive'])], ['attribute' => 'bg_image', 'format' => 'html', 'value' => Html::img($model->getBgUrl(), ['class' => 'img-responsive'])], 'content:html', 'slug', 'created_at:datetime', 'updated_at:datetime', ['attribute' => 'status', 'value' => ArrayHelper::getValue(Activity::getStatus(), $model->status)]]]);
?>

</div>
Esempio n. 8
0
 public function getActivity()
 {
     //同样第一个参数指定关联的子表模型类名
     //
     return $this->hasOne(Activity::className(), ['id' => 'activity_id']);
 }
Esempio n. 9
0
File: _form.php Progetto: ninetor/23
<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>
Esempio n. 10
0
 public static function getActivitiesByLimit($limit)
 {
     return Activity::find()->statusInUse()->orderBy('sort DESC')->limit($limit)->all();
 }
Esempio n. 11
0
 /**
  * 发布资金活动
  * @return boolean
  */
 public function publish()
 {
     //生成随机数据
     $total = $this->gift_price;
     //红包总金额
     $num = $this->gift_nums;
     // 分成10个红包,支持10人随机领取
     $min = $this->gift_min;
     //每个人最少能收到0.01元
     $max = $this->gift_max;
     $moneyArray = [];
     $time = time();
     $addip = \Yii::$app->request->userIP;
     for ($i = 1; $i < $num; $i++) {
         $safe_total = ($total - ($num - $i) * $min) / ($num - $i);
         //随机安全上限
         if ($max < $safe_total) {
             $safe_total = $max;
         }
         $money = mt_rand($min * 100, $safe_total * 100) / 100;
         $moneyArray[$i] = [0, $this->activity_id, $this->gift_name, $money, 0, $time, 0, 0, $addip];
         $total = $total - $money;
     }
     $moneyArray[$num] = [0, $this->activity_id, $this->gift_name, $total, 0, $time, 0, 0, $addip];
     \Yii::$app->db->createCommand()->batchInsert(Gift::tableName(), ['user_id', 'activity_id', 'gift_name', 'gift_price', 'gift_status', 'addtime', 'updatetime', 'fittime', 'addip'], $moneyArray)->execute();
     Activity::updateAll(['ac_status' => 1], 'id=' . $this->activity_id);
     return true;
 }
Esempio n. 12
0
echo $form->field($model, 'jiangli')->widget(\yii\imperavi\Widget::className(), ['plugins' => ['fullscreen', 'fontcolor', 'video', 'fontsize'], 'options' => ['lang' => 'zh', 'minHeight' => 150, 'maxHeight' => 400, 'buttonSource' => true, 'convertDivs' => false, 'removeEmptyTags' => false, 'imageUpload' => Yii::$app->urlManager->createUrl(['/file-storage/upload-imperavi'])]]);
?>

	<?php 
echo $form->field($model, 'jiangli_fangfa')->widget(\yii\imperavi\Widget::className(), ['plugins' => ['fullscreen', 'fontcolor', 'video', 'fontsize'], 'options' => ['lang' => 'zh', 'minHeight' => 150, 'maxHeight' => 400, 'buttonSource' => true, 'convertDivs' => false, 'removeEmptyTags' => false, 'imageUpload' => Yii::$app->urlManager->createUrl(['/file-storage/upload-imperavi'])]]);
?>

	<?php 
echo $form->field($model, 'content')->widget(\yii\imperavi\Widget::className(), ['plugins' => ['fullscreen', 'fontcolor', 'video', 'fontsize'], 'options' => ['lang' => 'zh', 'minHeight' => 600, 'maxHeight' => 800, 'buttonSource' => true, 'convertDivs' => false, 'removeEmptyTags' => false, 'imageUpload' => Yii::$app->urlManager->createUrl(['/file-storage/upload-imperavi'])]]);
?>

	<?php 
echo $form->field($model, 'sort');
?>

	<?php 
echo $form->field($model, 'status')->dropDownList(Activity::getStatus());
?>

	<div class="form-group">
		<?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('backend', 'Create') : Yii::t('backend', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
	</div>

	<?php 
ActiveForm::end();
?>

</div>
Esempio n. 13
0
 public static function toBigPicArctileShow($object, User $weixinuser, Activity $activity, Activity $re_activity)
 {
     $strPicurl = "https://mmbiz.qlogo.cn/mmbiz/3Nsx3YNMeOv6rg4at4Txeak4b9Wkiaq9ibIw7z3V0jFgoXRnCoAfs06y6VRYdzbsSicMRia4nIAyDzkzcjMxzdA3aw/0?wx_fmt=jpeg";
     $strUrl = "http://mp.weixin.qq.com/s?__biz=MzAwNDU3NjAwMw==&mid=402239047&idx=1&sn=96477c6d8807242d4bd75ecf021fbde0#rd";
     $result = $activity->toRollActivity($weixinuser, $activity->id);
     #增加提醒记录
     $activityRemind = new ActivityRemind();
     $activityRemind->setAttributes(['activity_id' => $re_activity->id, 'user_id' => $weixinuser->user_id, 'remind_name' => $re_activity->ac_name, 'remind_mark' => $re_activity->ac_cname, 'remind_type' => 0, 'addtime' => time()]);
     $activityRemind->save();
     if ($result['status'] != 2) {
         User::updateAll(['purview' => time()], 'user_id=:user_id', [':user_id' => $weixinuser->user_id]);
     }
     if ($result['status'] == 1) {
         $strPicurl = "https://mmbiz.qlogo.cn/mmbiz/3Nsx3YNMeOv6rg4at4Txeak4b9Wkiaq9ibIw7z3V0jFgoXRnCoAfs06y6VRYdzbsSicMRia4nIAyDzkzcjMxzdA3aw/0?wx_fmt=jpeg";
         $strUrl = "http://mp.weixin.qq.com/s?__biz=MzAwNDU3NjAwMw==&mid=402239047&idx=1&sn=96477c6d8807242d4bd75ecf021fbde0#rd";
     }
     $strTitle = $result['remark'];
     $strDes = $result['remark'];
     $content = [0 => ['title' => $strTitle, 'des' => $strDes, 'picurl' => $strPicurl, 'url' => $strUrl], 1 => ['title' => '春节初一至初十五天天抽奖。抽完为止。', 'des' => 'ooo', 'picurl' => 'https://mmbiz.qlogo.cn/mmbiz/3Nsx3YNMeOv6rg4at4Txeak4b9Wkiaq9ib9tjFrJOGZQmfeAC4WapMdKMA7ZkfBLjicel4rwxdicOxhCHN3Z1y1rTQ/0?wx_fmt=jpeg', 'url' => 'http://mp.weixin.qq.com/s?__biz=MzAwNDU3NjAwMw==&mid=402303743&idx=1&sn=e9f6232ec4b8cf5e0b6faa8f89b28cbe#rd'], 2 => ['title' => '免费获取各种商品打折券,春节就要省省省。', 'des' => 'xxx', 'picurl' => 'https://mmbiz.qlogo.cn/mmbiz/3Nsx3YNMeOv6rg4at4Txeak4b9Wkiaq9ibuiamOrlB3usT9VuzibYFdAn0EFAANbic6C94U969Iy9oIqIUJa80N15cg/0?wx_fmt=jpeg', 'url' => 'http://mp.weixin.qq.com/s?__biz=MzAwNDU3NjAwMw==&mid=402303933&idx=1&sn=9f1b157a47d14c2dee8da2c14fc6abb4#rd']];
     WechatCheck::_transmitArticleAndPic($object, $content);
 }
Esempio n. 14
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getActivities()
 {
     return $this->hasMany(Activity::className(), ['category_id' => 'id']);
 }
Esempio n. 15
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getActivity0()
 {
     return $this->hasOne(Activity::className(), ['id' => 'activity']);
 }
Esempio n. 16
0
use yii\helpers\ArrayHelper;
use yii\grid\GridView;
use common\models\Activity;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\search\ActivitySearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('common', 'Activity');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="activity-index">

	<?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

	<p>
		<?php 
echo Html::a(Yii::t('backend', 'Create {modelClass}', ['modelClass' => Yii::t('common', 'Activity')]), ['create'], ['class' => 'btn btn-success']);
?>
	</p>

	<?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'category_id', 'value' => function ($model) {
    return $model->category ? $model->category->title : null;
}, 'filter' => ArrayHelper::map(\common\models\ActivityCategory::find()->all(), 'id', 'title')], 'title', 'start_time:datetime', 'end_time:datetime', ['attribute' => 'thumbnail', 'format' => 'html', 'value' => function ($model) {
    return Html::img($model->getThumbnailUrl(), ['class' => 'img-responsive', 'styles' => 'width:100px;']);
}], ['class' => \common\grid\EnumColumn::className(), 'attribute' => 'status', 'enum' => Activity::getStatus()], 'sort', ['class' => 'yii\\grid\\ActionColumn']], 'layout' => "{items}\n{summary}\n{pager}"]);
?>

</div>