public static function addUserHistory($serverId) { $server = \common\models\GameServer::findOne($serverId); $game = $server->getGame()->one(); $user = \Yii::$app->user->identity; $user = User::findOne(2); $userHistory = new UserHistory(); $userHistory->user_id = $user->getId(); $userHistory->game_id = $server->game_id; $userHistory->server_id = $server->id; $userHistory->status = UserHistory::STATUS_IN_USE; if ($userHistory->save()) { return $userHistory; } else { return null; } }
<?php // echo $this->render('_search', ['model' => $searchModel]); ?> <?php if (Yii::$app->user->can('administrator')) { ?> <p> <?php echo Html::a(Yii::t('backend', 'Create {modelClass}', ['modelClass' => Yii::t('common', 'Kefu Selfservice')]), ['create'], ['class' => 'btn btn-success']); ?> </p> <?php } ?> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'sn', ['attribute' => 'game_server', 'value' => function ($model) { return \common\models\GameServer::findOne($model->game_server)['server_name']; }, 'filter' => ArrayHelper::map(\common\models\GameServer::find()->all(), 'id', 'server_name')], 'game_role', ['attribute' => 'category_id', 'value' => function ($model) { return $model->category ? $model->category->title : null; }, 'filter' => ArrayHelper::map(\common\models\KefuSelfserviceCat::find()->all(), 'id', 'title')], 'created_at:datetime', ['class' => \common\grid\EnumColumn::className(), 'attribute' => 'status', 'enum' => KefuSelfservice::getStatus()], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{view} {update} {result} {delete}', 'buttons' => ['result' => function ($url, $model, $key) { if ($model->status == KefuSelfservice::STATUS_YICHULI) { return ""; } return Html::a('<span class="glyphicon glyphicon-check"></span>', ['/kefu-selfservice/result', 'id' => $model->id], ['title' => Yii::t('common', 'check'), 'id' => 'check' . $model->id]); }]]]]); ?> </div>
</div> </div> <div class="row"> <div class="col-md-12"> <div class="tag-box tag-box-v3"> <div class="headline"><h3><?php echo $this->title; ?> </h3></div> <?php $attachmentsImags = ''; foreach ($model->attachments as $ss) { $attachmentsImags .= Html::img(Yii::$app->glide->createSignedUrl(['glide/index', 'path' => $ss['path'], 'w' => 200], true), ['class' => 'img-responsive']); } ?> <?php echo DetailView::widget(['model' => $model, 'attributes' => [['attribute' => 'category_id', 'value' => \common\models\KefuSelfserviceCat::findOne($model->category_id)['title']], 'sn', 'game_role', ['attribute' => 'game_server', 'value' => \common\models\GameServer::findOne($model->game_server)['server_name']], ['attribute' => 'attachments', 'format' => 'html', 'value' => $attachmentsImags], 'content:html', 'created_at:datetime', ['attribute' => 'status', 'value' => ArrayHelper::getValue(KefuSelfservice::getStatus(), $model->status)], ['attribute' => 'result', 'format' => 'html', 'headerOptions' => ['width' => '500px']]]]); ?> </div> </div> </div> </div> <?php $js = <<<JS \$('.jie-guo').addClass('active'); JS; $this->registerJs($js);
?> ">首页</a></li> <li class="active">充值中心</li> </ul> </div> </div> <?php $this->endBlock(); ?> <div class="container content"> <div class="row"> <div class="col-md-12"> <div class="headline"><h3 class="heading-sm">确认充值信息</h3></div> <?php echo DetailView::widget(['model' => $model, 'attributes' => ['user_id', ['attribute' => 'game_id', 'value' => \common\models\Game::findOne($model->game_id)['name']], ['attribute' => 'server_id', 'value' => \common\models\GameServer::findOne($model->server_id)['server_name']], 'pay_mode', ['attribute' => 'amount', 'value' => $model->amount . '元'], ['attribute' => '获得元宝数量', 'value' => $model->amount * 10 . '元宝']]]); ?> <?php $form = \kartik\form\ActiveForm::begin(['type' => \kartik\form\ActiveForm::TYPE_HORIZONTAL]); ?> <?php echo $form->field($model, 'user_id')->textInput(['value' => Yii::$app->user->identity->username, 'readonly' => 'readonly']); ?> <?php echo $form->field($model, 'game_id')->dropDownList(ArrayHelper::map(\common\models\Game::find()->statusInUse()->all(), 'id', 'name'), ['prompt' => '']); ?> <?php echo $form->field($model, 'server_id')->dropDownList(ArrayHelper::map(\common\models\GameServer::find()->statusInUse()->all(), 'id', 'server_name'), ['prompt' => '']);
/** * Finds the GameServer model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return GameServer the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = GameServer::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }