コード例 #1
0
 public function actionCharge()
 {
     $contentId = (int) Yii::app()->request->getParam('id');
     $contentCode = (int) Yii::app()->request->getParam('code');
     $contentType = htmlspecialchars(Yii::app()->request->getParam('type'));
     $bmUrl = yii::app()->params['bmConfig']['remote_wsdl'];
     $client = new SoapClient($bmUrl, array('trace' => 1));
     $fromPhone = Yii::app()->user->getState('msisdn');
     $options = array();
     if (Yii::app()->user->getState('isWifi')) {
         $options['note'] = 'WIFI';
     }
     $result = new stdClass();
     switch ($contentType) {
         case "downloadSong":
             $params = array('code' => $contentCode, 'from_phone' => yii::app()->user->getState('msisdn'), 'to_phone' => yii::app()->user->getState('msisdn'), 'source_type' => 'wap', 'promotion' => 0, 'smsId' => '', 'noteOptions' => $options);
             $result = $client->__soapCall('downloadSong', $params);
             if ($result->errorCode == 0) {
                 $song = WapSongModel::model()->findByPk($contentId);
                 $deviceId = yii::app()->session['deviceId'];
                 $downloadUrl = WapSongModel::model()->getNiceDownloadUrl($song->id, $deviceId, 'http', $song->profile_ids, $song->url_key, $song->artist_name);
                 $result->url = $downloadUrl;
             }
             if (isset(Yii::app()->params['charging']["{$result->message}"])) {
                 $result->message = Yii::app()->params['charging']["{$result->message}"];
             } else {
                 $result->message = Yii::t("wap", "Your account balance is not enough");
             }
             break;
         case "playSong":
             if (Yii::app()->session['src'] == 'ads') {
                 $promotion = 1;
                 $options['note'] = 'ADS';
             } else {
                 $promotion = 0;
             }
             $params = array('code' => $contentCode, 'from_phone' => Yii::app()->user->getState('msisdn'), 'source_type' => 'wap', 'promotion' => $promotion, 'noteOptions' => $options);
             $result = $client->__soapCall('playSong', $params);
             if (isset(Yii::app()->params['charging']["{$result->message}"])) {
                 $result->message = Yii::app()->params['charging']["{$result->message}"];
             } else {
                 $result->message = Yii::t("wap", "Your account balance is not enough");
             }
             //Chua dang ky goi cuoc -> log tinh luot play free trong ngay
             if (empty($this->userPhone)) {
                 $params = array('content_id' => $contentId, 'type' => 'song');
                 FreeContentOnDayModel::model()->add($params);
             }
             break;
         case "playVideo":
             $params = array('code' => $contentCode, 'from_phone' => yii::app()->user->getState('msisdn'), 'source_type' => 'wap', 'promotion' => 0, 'noteOptions' => $options);
             $result = $client->__soapCall('playVideo', $params);
             if (isset(Yii::app()->params['charging']["{$result->message}"])) {
                 $result->message = Yii::app()->params['charging']["{$result->message}"];
             } else {
                 $result->message = Yii::t("wap", "Your account balance is not enough");
             }
             //Chua dang ky goi cuoc -> log tinh luot play free trong ngay
             if (empty($this->userPhone)) {
                 $params = array('content_id' => $contentId, 'type' => 'video');
                 FreeContentOnDayModel::model()->add($params);
             }
             break;
         case "downloadVideo":
             $params = array('code' => $contentCode, 'from_phone' => yii::app()->user->getState('msisdn'), 'to_phone' => yii::app()->user->getState('msisdn'), 'source_type' => 'wap', 'promotion' => 0, 'smsId' => '', 'noteOptions' => $options);
             $result = $client->__soapCall('downloadVideo', $params);
             if ($result->errorCode == 0) {
                 $video = WapVideoModel::model()->findByPk($contentId);
                 $deviceId = yii::app()->session['deviceId'];
                 $downloadUrl = VideoModel::model()->getNiceDownloadUrl($contentId, $deviceId, 'http', true, $video->url_key);
                 $result->url = $downloadUrl;
             }
             //$result->message = Yii::app()->params['charging']["{$result->message}"];
             if (isset(Yii::app()->params['charging']["{$result->message}"])) {
                 $result->message = Yii::app()->params['charging']["{$result->message}"];
             } else {
                 $result->message = Yii::t("wap", "Your account balance is not enough");
             }
             break;
         case "subscribe":
             $packageCode = 'CHACHAFUN';
             $params = array('phone' => Yii::app()->user->getState('msisdn'), 'package' => $packageCode, 'source' => 'wap', 'promotion' => 0);
             $result = $client->__soapCall('userRegister', $params);
             break;
         case "playAlbum":
             $params = array('id' => $contentId, 'from_phone' => yii::app()->user->getState('msisdn'), 'source_type' => 'wap', 'promotion' => 0);
             $result = $client->__soapCall('playAlbum', $params);
             if (isset(Yii::app()->params['charging']["{$result->message}"])) {
                 $result->message = Yii::app()->params['charging']["{$result->message}"];
             } else {
                 $result->message = Yii::t("wap", "Your account balance is not enough");
             }
             //$result->message = Yii::app()->params['charging']["{$result->message}"];
             break;
     }
     header("Content-type: application/json");
     echo json_encode($result);
     Yii::app()->end();
 }
コード例 #2
0
 public function actionCheckPlayNoSub()
 {
     $ret = new stdClass();
     $userPhone = Yii::app()->user->getState('msisdn');
     $userPhone = Formatter::formatPhone($userPhone);
     $countPlayInDay = UserTransactionModel::model()->getNumTransContentPlay($userPhone);
     $count_free_in_day = FreeContentOnDayModel::model()->Check_Free_On_Day();
     // Nghe wifi
     $total_play = $countPlayInDay + $count_free_in_day;
     if ($total_play >= 5) {
         $ret->error = 1;
         $ret->count = $total_play;
         $ret->message = "Thiết bị đã nghe xem {$total_play} nội dung trong ngày";
     } else {
         $ret->error = 0;
         $ret->count = $total_play;
         $ret->message = "Success";
     }
     header("Content-type: application/json");
     echo json_encode($ret);
     Yii::app()->end();
 }