当前位置: 首页>>代码示例>>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;未经允许,请勿转载。