Beispiel #1
0
 public function actionRedeemupdate($uId)
 {
     $model = new RewardsDetails();
     $rewardsMain = new RewardsMain();
     $rewardsMainAry = $rewardsMain->getRewardsByuId($uId);
     $model->uId = $rewardsMainAry->uId;
     $model->availableRewards = $rewardsMainAry->rewards;
     $model->storeId = $rewardsMainAry->storeId;
     if ($model->load(Yii::$app->request->post())) {
         $model->createdBy = Yii::$app->user->id;
         $model->updatedBy = Yii::$app->user->id;
         $model->rewardsFlag = 'REEDEEMED';
         $model->confirmFlag = 0;
         $redeemUpdate = $model->save();
         //print_r($model->redeemRewards);exit();
         if ($redeemUpdate) {
             $rewardsMain = RewardsMain::find()->where(['uId' => $model->uId])->one();
             $rewardsMain->rewards = $rewardsMain->rewards - $model->redeemRewards;
             $rewardsMain->rdId = $model->rdId;
             $rewardsMain->storeId = $model->storeId;
             $rewardsMain->uId = $model->uId;
             $response = $rewardsMain->update();
         }
         if ($response) {
             return $this->redirect(['redeemupdate', 'uId' => $model->uId]);
         }
     } else {
         return $this->render('redeemUpdate', ['model' => $model]);
     }
 }
Beispiel #2
0
 public function actionRequestrewards()
 {
     $model = new RewardsDetails();
     if ($model->load(Yii::$app->request->post())) {
         $model->createdBy = Yii::$app->user->id;
         $model->updatedBy = Yii::$app->user->id;
         $model->uId = Yii::$app->user->id;
         $model->rewardsFlag = 'ADD';
         $model->confirmFlag = 0;
         $model->save();
     }
     return $this->render('rewards', ['model' => $model]);
 }