Ejemplo n.º 1
0
 public static function toupiaoAjax($author_openid, $vote_openid)
 {
     $qingshi_vote = self::findOne(['vote_openid' => $vote_openid]);
     if (empty($qingshi_vote)) {
         $qingshi_vote = new \app\models\MQingshiVote();
     } else {
         //已经投过一次票了,提示用户已投过票,只能每人只能投一次票哟
         return \yii\helpers\Json::encode(['code' => 11]);
     }
     $qingshi_vote->author_openid = $author_openid;
     $qingshi_vote->vote_openid = $vote_openid;
     $qingshi_vote->save(false);
     //写入到投票表中;
     $qingshi_score = \app\models\MQingshiScore::findOne(['author_openid' => $author_openid]);
     U::W($qingshi_score);
     if (empty($qingshi_score)) {
         $qingshi_score = new \app\models\MQingshiScore();
     }
     $qa = \app\models\MQingshiAuthor::findOne(['author_openid' => $author_openid]);
     $qingshi_score->author_openid = $author_openid;
     $qingshi_score->score = $qingshi_score->score + 1;
     $qingshi_score->status = 0;
     $qingshi_score->create_time = $qa->create_time;
     $qingshi_score->save(false);
     return \yii\helpers\Json::encode(['code' => 0]);
 }
Ejemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = MQingshiScore::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['score_id' => $this->score_id, 'author_openid' => $this->author_openid, 'score' => $this->score, 'status' => $this->status]);
     return $dataProvider;
 }
Ejemplo n.º 3
0
 /**
  * Finds the MQingshiScore model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return MQingshiScore the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = MQingshiScore::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 4
0
	<!--
    <//?= $form->field($model, 'author_openid')->textInput() ?>

    <//?= $form->field($model, 'score')->textInput() ?>
    -->
	

    <?php 
echo "<img width=128 src=" . $model->user->headimgurl . ">";
echo '<h1>' . emoji_unified_to_html(emoji_softbank_to_unified($model->user->nickname)) . "</h1><br>";
echo '<h1>' . $model->score . "票</h1>";
?>

 	<br> <br>

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

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? '新建' : '修改', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

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

</div>
Ejemplo n.º 5
0
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <!--
    <p>
        <//?= Html::a('Create Mqingshi Score', ['create'], ['class' => 'btn btn-success']) ?>
    </p>
    -->
    <p>
        <?php 
echo Html::a('情诗审核', ['qingshi-author/index'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['attribute' => 'score_id', 'headerOptions' => array('style' => 'width:90px;')], ['label' => '微信昵称', 'format' => 'html', 'value' => function ($model, $key, $index, $column) {
    $user = $model->user;
    return empty($user) ? '' : "<img width=48 src=" . $model->user->headimgurl . ">&nbsp;&nbsp;" . emoji_unified_to_html(emoji_softbank_to_unified($user->nickname));
}, 'filter' => false, 'headerOptions' => array('style' => 'width:450px;')], 'create_time', 'score', ['attribute' => 'status', 'label' => '是否领奖', 'value' => function ($model, $key, $index, $column) {
    return MQingshiScore::getQingshiScoreStatusOption($model->status);
}, 'filter' => MQingshiScore::getQingshiScoreStatusOption(), 'headerOptions' => array('style' => 'width:80px;')], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update}', 'buttons' => ['update' => function ($url, $model) {
    return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, ['title' => Yii::t('yii', 'Update'), 'data-pjax' => '0']);
}]]]]);
?>

</div>
Ejemplo n.º 6
0

    <div id='tppm'  class='modal'>
        <header class="bar bar-nav">
            <a class="icon icon-close pull-right" href="#tppm"></a>
            <h1 class='title'>投票排名</h1>
        </header>
        <div class="content">
            <?php 
// $votes = \app\models\MQingshiVote::find()
//    ->groupBy(['author_openid'])
//   ->all();
$top = 0;
//$votes = \app\models\MQingshiVote::find()->select('*, count(*) as c')->groupBy(['author_openid'])->orderBy('c DESC')->limit(50)->all();
//至少获得10票 才能上榜
$votes = \app\models\MQingshiScore::find()->where(['>', 'score', 9])->orderBy(['score' => SORT_DESC, 'create_time' => SORT_ASC])->limit(50)->all();
?>

            <ul class="table-view">

            <li class="table-view-cell media">
                <div class="media-body">
                    名次
                </div>

                <span class="badge" style="font-size: 12pt">
                    所得票数
                </span>
            </li>

            <?php 
Ejemplo n.º 7
0
            <?php 
} else {
    ?>
                <img width="128" src='/wx/web/images/wxmpres/headimg-blank.png' ><br>
                <?php 
    echo emoji_unified_to_html(emoji_softbank_to_unified($qingshi_author->user->nickname));
    ?>
            <?php 
}
?>
        </p>

        <center>

            <?php 
$vote_count = \app\models\MQingshiScore::findOne(['author_openid' => $qingshi_author->author_openid]);
if (empty($vote_count)) {
    ?>
                <span class="vt">得</span>
                <span class="badge" style="color:#bbb6d4; font-size: 14pt">
                    0
                </span>
                <span class="vt">票</span>
            <?php 
} else {
    ?>
                <span class="vt">得</span>
                <span class="badge" style="font-size: 14pt">
                    <?php 
    echo $vote_count->score;
    ?>