當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Globals::authcode方法代碼示例

本文整理匯總了PHP中Globals::authcode方法的典型用法代碼示例。如果您正苦於以下問題:PHP Globals::authcode方法的具體用法?PHP Globals::authcode怎麽用?PHP Globals::authcode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Globals的用法示例。


在下文中一共展示了Globals::authcode方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: actionActive

 public function actionActive()
 {
     $result = -1;
     $prize = 1;
     $msg = '活動已結束';
     $sinDate = 0;
     $table = 'active_awards';
     $logTable = 'active_log';
     $encryption = Yii::app()->request->getParam('encryption');
     list($openId, $activeId, $type) = explode('|', Globals::authcode($encryption, 'DECODE'));
     $active = ActiveModel::model()->findByPk($activeId);
     //活動是否開始
     if ($active->startTime > date('Y-m-d H:i:s')) {
         $prize = 1;
     } elseif ($active->endTime < date('Y-m-d H:i:s')) {
         $prize = 1;
     } elseif ($active->status == 0) {
         $prize = 1;
     }
     $prize = $active->status == 0 ? 0 : $prize;
     if ($prize == 1) {
         //檢查今天是否已經簽到
         $startTime = strtotime(date('Y-m-d'));
         $endTime = strtotime(date('Y-m-d', strtotime('+1 days'))) - 1;
         $logExit = ActiveLogModel::model($logTable)->find('activeId=:activeId and openId=:openId and
         datetime>=' . $startTime . ' and datetime<=' . $endTime, array(':activeId' => $activeId, ':openId' => $openId));
         if ($logExit) {
             $result = 1;
             //簽到過了
             $msg = '你今天已經簽過到了';
         } else {
             $count = ActiveLogModel::model($logTable)->count('activeId=:activeId and openId=:openId', array(':activeId' => $activeId, ':openId' => $openId));
             $count = $count + 1;
             $awardsArray = unserialize($active->awards);
             if (isset($awardsArray[$count])) {
                 //獲取禮包碼
                 $code = ActiveAwardsModel::model($table)->find('activeId=:activeId and grade=:grade and
                     type=:type and openId is null', array(':activeId' => $activeId, ':grade' => $count, ':type' => $type));
                 if ($code) {
                     $code->status = 2;
                     $code->awardsInfo = $awardsArray[$count]['name'];
                     $code->openId = $openId;
                     $code->datetime = time();
                     $code->save();
                     $result = 2;
                     //  $msg = '恭喜你,獲得' . $awardsArray[$count]['name'] . ',禮包碼為:'.$code->code;
                     $msg = '恭喜簽到' . $count . '次,活動禮包激活碼:' . $code->code;
                 } else {
                     $result = -3;
                     $msg = '抱歉,禮包碼發完了,請聯係客服';
                 }
             } else {
                 $result = 3;
                 $msg = '恭喜你,簽到成功';
             }
             $sinDate = date('md');
             //log
             $log = new ActiveLogModel($logTable);
             $log->datetime = time();
             $log->openId = $openId;
             $log->activeId = $activeId;
             $log->save();
         }
     }
     echo json_encode(array('success' => $result, 'msg' => $msg, 'sinDate' => $sinDate));
 }
開發者ID:00606,項目名稱:wechat,代碼行數:66,代碼來源:HandleController.php

示例2: actionSave

 public function actionSave()
 {
     //status 更新為2
     $success = false;
     $table = 'scratch_awards';
     $tel = $_POST['tel'];
     $msg = '中獎信息失效或係統異常';
     $encryption = $_POST['encryption'];
     $name = $_POST['code'];
     list($openid, $grade, $scratchId) = explode('|', Globals::authcode($encryption, 'DECODE'));
     $scratchInfo = ScratchModel::model()->findByPk($scratchId);
     if ($scratchInfo && $tel) {
         $awards = unserialize($scratchInfo->awards);
         if ($awards[$grade] && $awards[$grade]['name'] == $name) {
             $success = true;
             $msg = '你的信息已收錄,我們會及時聯係你';
             //存儲用戶信息
             $codeInfo = ScratchAwardsModel::model($table)->find('openId=:openId and scratchId=:scratchId and grade=:grade', array(':openId' => $openid, ':scratchId' => $scratchId, ':grade' => $grade));
             $codeInfo->status = 2;
             $codeInfo->telphone = $tel;
             $codeInfo->save();
         }
     }
     echo json_encode(array('success' => $success, 'msg' => $msg));
 }
開發者ID:00606,項目名稱:wechat,代碼行數:25,代碼來源:HandleController.php

示例3: _getRegistration

 private function _getRegistration($responseId, $openId, $type)
 {
     $active = ActiveModel::model()->findByPk($responseId);
     if (!$type) {
         $keywords = KeywordsModel::model()->find('type=:type and responseId=:responseId', array(':type' => Globals::TYPE_ACTIVE, ':responseId' => $responseId));
         $content = '參與' . $active->title . '請回複:正版(混版,pps)' . $keywords->name . '參與活動。回複:' . $keywords->name . '中獎查詢,查詢中獎信息';
         $responseObj = new WeChatTextResponse($content);
         return $responseObj;
     }
     if ($type == -1) {
         $content = $this->_getActiveAwards($openId, $responseId, Globals::TYPE_REGISTRATION);
     } else {
         if ($active->startTime > date('Y-m-d H:i:s')) {
             $content = $active->unstartMsg ? $active->unstartMsg : "抱歉,還未開始呢";
         } elseif ($active->endTime < date('Y-m-d H:i:s')) {
             $content = $active->endMsg ? $active->endMsg : "抱歉,你來晚了";
         } elseif ($active->status == 0) {
             $content = $active->pauseMsg ? $active->pauseMsg : "抱歉,活動暫時停止";
         } else {
             $string = $openId . '|' . $responseId . '|' . $type;
             $code = Globals::authcode($string, 'ENCODE');
             $url = Yii::app()->params['siteUrl'] . Yii::app()->createUrl('registration/handle', array('code' => $code));
             $responseObj = new WeChatArticleResponse();
             $responseObj->add_article($active->title, '', Yii::app()->params['siteUrl'] . '/wechat/upload/market/registration/active.jpg', $url);
         }
     }
     $responseObj = isset($responseObj) ? $responseObj : new WeChatTextResponse($content);
     return $responseObj;
 }
開發者ID:00606,項目名稱:wechat,代碼行數:29,代碼來源:ApiController.php

示例4: actionSave

 public function actionSave()
 {
     //status 更新為2
     $success = false;
     $table = 'wheel_awards';
     $area = $_POST['area'];
     $role = $_POST['role'];
     $banben = $_POST['banben'];
     $msg = '中獎信息失效或係統異常';
     $encryption = $_POST['encryption'];
     list($openid, $grade, $wheelId) = explode('|', Globals::authcode($encryption, 'DECODE'));
     $wheelInfo = WheelModel::model()->findByPk($wheelId);
     if ($wheelInfo) {
         $awards = unserialize($wheelInfo->awards);
         if ($awards[$grade]) {
             $success = true;
             $msg = '你的信息已收錄,我們會及時聯係你';
             //存儲用戶信息
             $codeInfo = WheelAwardsModel::model($table)->find('openId=:openId and wheelId=:wheelId and grade=:grade', array(':openId' => $openid, ':wheelId' => $wheelId, ':grade' => $grade));
             $codeInfo->status = 2;
             $codeInfo->area = $area;
             $codeInfo->role = $role;
             $codeInfo->banben = $banben;
             $codeInfo->save();
         }
     }
     echo json_encode(array('success' => $success, 'msg' => $msg));
 }
開發者ID:00606,項目名稱:wechat,代碼行數:28,代碼來源:HandleController.php


注:本文中的Globals::authcode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。