Пример #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]);
     }
 }
Пример #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getRd()
 {
     return $this->hasOne(RewardsDetails::className(), ['rdId' => 'rdId']);
 }
Пример #3
0
 public function statusUpdate($rdId)
 {
     $RequestDetails = RewardsDetails::find()->where(['rdId' => $rdId])->one();
     $vendorId = Yii::$app->user->id;
     $getRewardAmount = StoresMaster::find()->where("vendorId = {$vendorId} and offerStartDate <='{$RequestDetails->purchaseDate}' and offerEndDate >= '{$RequestDetails->purchaseDate}' and \tofferType = 'Cash Back'")->one();
     $amountCount = count($getRewardAmount);
     //print_r($amountCount);exit();
     if ($amountCount == 1) {
         $RequestDetails->rewardsFlag = 'CONFIRMED';
         $RequestDetails->newRewards = $getRewardAmount->offer;
         $requestUpdate = $RequestDetails->update();
         if ($requestUpdate) {
             $rewardsMain = RewardsMain::find()->where(['rdId' => $rdId])->one();
             $rewardsCount = count($rewardsMain);
             if ($rewardsCount != 0) {
                 $rewardsMain->rewards = $RequestDetails->newRewards + $rewardsMain->rewards;
                 $rewardsMain->rdId = $RequestDetails->rdId;
                 $rewardsMain->storeId = $RequestDetails->storeId;
                 $rewardsMain->uId = $RequestDetails->uId;
                 $response = $rewardsMain->update();
             } else {
                 $model = new RewardsMain();
                 $model->rewards = $RequestDetails->newRewards;
                 $model->rdId = $RequestDetails->rdId;
                 $model->storeId = $RequestDetails->storeId;
                 $model->uId = $RequestDetails->uId;
                 $response = $model->save();
             }
         }
     } else {
         $response = 0;
     }
     return $response;
 }
Пример #4
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]);
 }