Exemplo n.º 1
0
 public function actionShare()
 {
     $userPhone = yii::app()->user->getState('msisdn');
     $isShare = GameEventActivityModel::isShareOnDay($userPhone, date('Y-m-d'));
     if ($isShare) {
         $this->redirect('/event/play/thank');
         Yii::app()->end();
     }
     $error = 0;
     $isSend = false;
     if (Yii::app()->request->isPostRequest) {
         $isSend = 0;
         $phoneList = $_POST['phone_list'];
         if ($phoneList != '') {
             $phoneArr = explode(',', $phoneList);
             if ($phoneArr) {
                 foreach ($phoneArr as $key => $value) {
                     $phone = Formatter::formatPhone($value);
                     if (Formatter::isVinaphoneNumber($phone)) {
                         $isSend++;
                         $sms = new SmsClient();
                         $content = 'DV Chacha - Vinaphone kinh chao Quy Khach. Quy Khach vua duoc thue bao ' . $userPhone . ' moi dua tai trong chuong trinh "Vui cung Chacha - Nhan qua nhu y" voi giai thuong hap dan len toi 20 trieu dong. Chi tiet moi Quy Khach xem tai day http://m.chacha.vn/event';
                         $sms->sentMT("9234", $phone, 0, $content, 0, "", time(), 9234);
                     }
                 }
                 if ($isSend > 0) {
                     //chia se it nhat duoc 1 so vinaphone
                     $gameActivity = new GameEventActivityModel();
                     $gameActivity->setAttribute('user_phone', $userPhone);
                     $gameActivity->setAttribute('activity', 'share');
                     $gameActivity->setAttribute('point', 1);
                     $gameActivity->setAttribute('updated_time', date('Y-m-d H:i:s'));
                     $gameActivity->setAttribute('note', $phoneList, PDO::PARAM_STR);
                     $gameActivity->save();
                     $this->redirect('/event/play/thank');
                 }
             }
         } else {
             //ko có sô dt nao
             $error = 1;
         }
     }
     $this->render('share', array('isShare' => $isShare, 'error' => $error, 'isSend' => $isSend));
 }