| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace mobile\controllers;
- use biz\tool\services\GuaGuaAttendService;
- use biz\tool\services\GuaGuaPrizeService;
- use biz\tool\services\GuaGuaService;
- use biz\tool\services\GuaGuaWinService;
- use common\components\util;
- use Yii;
- use yii\helpers\Json;
- class GuaController extends MobileendController
- {
-
- public $withoutLogin = ['index'];
-
- public $layout = false;
-
- public function beforeAction($action)
- {
-
- return parent::beforeAction($action);
- }
-
- public function actionIndex()
- {
- $id = Yii::$app->request->get('id');
- $card = GuaGuaService::getById($id);
- if (empty($card) || $card['merchantId'] != $this->merchantId) {
- echo '非法访问';
- Yii::$app->end();
- }
- $remainNum = 0;
- //增加访问次数和访问用户数
- GuaGuaService::addVisit($id);
- $winUser = GuaGuaWinService::getWinUser($card);
- $userInfo = [];
- if ($this->isLogin) {
- //创建更新用户的参与信息并获取剩余次数
- $remainNum = GuaGuaAttendService::getRemainNum($card);
- $userInfo = $this->user;
- }
- return $this->render('index', ['card' => $card, 'remainNum' => $remainNum, 'userInfo' => $userInfo, 'winUser' => $winUser]);
- }
-
- /*
- * 刮一次的时候确认奖品
- */
- public function actionGua()
- {
- $id = Yii::$app->request->get('id');
- $data = GuaGuaPrizeService::getPrize($id);
- if ($this->error->hasError) {
- util::failInfo($this->error->getError());
- }
- util::successInfo('success', 'A0001', $data);
- }
-
- //我的奖品 shish 2019.8.10
- public function actionMyPrize()
- {
- $id = Yii::$app->request->get('id');
- $prize = GuaGuaWinService::getMyPrize($id);
- return $this->render('myPrize', ['prize' => $prize, 'userInfo' => $this->user]);
- }
-
- }
|