当前位置: 首页>>代码示例>>PHP>>正文


PHP UserCache::setByKey方法代码示例

本文整理汇总了PHP中UserCache::setByKey方法的典型用法代码示例。如果您正苦于以下问题:PHP UserCache::setByKey方法的具体用法?PHP UserCache::setByKey怎么用?PHP UserCache::setByKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserCache的用法示例。


在下文中一共展示了UserCache::setByKey方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setSessionKey

 public static function setSessionKey($user_id, $oldSessionKey)
 {
     // 生成缓存
     $newSessionKey = Util::generateSessionKey($user_id);
     Logger::debug('SessionKey1:' . $oldSessionKey);
     Logger::debug('SessionKey2:' . $newSessionKey);
     UserCache::setByKey($user_id, Constants::PREVIOUS_SESSION_KEY, $oldSessionKey);
     UserCache::setByKey($user_id, Constants::CURRENT_SESSION_KEY, $newSessionKey);
     return $newSessionKey;
 }
开发者ID:YYLP,项目名称:y_game,代码行数:10,代码来源:CharacterModel.class.php

示例2: exeGetRank

 /**
  * API:获取解锁关卡基本信息
  *
  * @access public
  * @param 无
  * @return JsonView 响应json
  */
 public function exeGetRank()
 {
     $requestParam = $this->getAllParameters();
     Logger::debug('requestParam:' . print_r($requestParam, true));
     $requestJsonParam = $this->getDecodedJsonRequest();
     Logger::debug('requestJsonParam:' . print_r($requestJsonParam, true));
     // 获取用户表信息
     $userInfo = UserCache::getAllUserCache($requestParam['user_id']);
     if (!$userInfo) {
         $userInfo = UserAction::iniUserInfo($requestParam['user_id']);
     }
     if ($requestJsonParam['type'] == 'world') {
         $messageArr = self::getWorldRank($requestParam['user_id']);
         $messageArr['userInfo'] = RankModel::getUserRank($requestParam['user_id']);
         $messageArr['userInfo']['id'] = $userInfo['n_id'];
         $messageArr['userInfo']['head'] = $userInfo['n_head'];
         $messageArr['userInfo']['name'] = $userInfo['s_name'];
         $messageArr['userInfo']['sex'] = $userInfo['n_sex'];
         $messageArr['userInfo']['level'] = $userInfo['n_level'];
         $messageArr['userInfo']['checkpoint'] = $userInfo['n_max_checkpoint'];
         $messageArr['userInfo']['battle'] = $userInfo['n_battle'];
     } else {
         if ($requestJsonParam['type'] == 'friend') {
             $messageArr = self::getFriendRank($requestParam['user_id']);
         } else {
             $view = new JsonView();
             return $this->getViewByJson($view, '', 0, "rank/get_rank");
         }
     }
     // 生成缓存
     $newSessionKey = Util::generateSessionKey($requestParam['user_id']);
     $oldSessionKey = $requestParam['session_key'];
     Logger::debug('SessionKey1:' . $oldSessionKey);
     Logger::debug('SessionKey2:' . $newSessionKey);
     UserCache::setByKey($requestParam['user_id'], Constants::PREVIOUS_SESSION_KEY, $oldSessionKey);
     UserCache::setByKey($requestParam['user_id'], Constants::CURRENT_SESSION_KEY, $newSessionKey);
     //UserCache::setByKey($user_id, 'userInfo', $userInfo);
     $messageArr['session_key'] = $newSessionKey;
     $view = new JsonView();
     return $this->getViewByJson($view, $messageArr, 1, "system/get_bulletin");
 }
开发者ID:YYLP,项目名称:y_game,代码行数:48,代码来源:RankAction.class.php

示例3: exeUpdateAllMail

 /**
  * API:接受所有邮件
  *
  * @access public
  * @param 无
  * @return JsonView 响应json
  */
 public function exeUpdateAllMail()
 {
     $requestParam = $this->getAllParameters();
     Logger::debug('requestParam:' . print_r($requestParam, true));
     $requestJsonParam = $this->getDecodedJsonRequest();
     Logger::debug('requestJsonParam:' . print_r($requestJsonParam, true));
     $user_id = $requestParam['user_id'];
     $session_key = $requestParam['session_key'];
     $mailInfo = MailModel::getSystemMail($user_id);
     $userInfo = UserCache::getAllUserCache($user_id);
     if (!$userInfo) {
         $userInfo = UserAction::iniUserInfo($user_id);
     }
     if (!$mailInfo) {
         $messageArr['error'] = "没有系统邮件";
         $messageArr['session_key'] = CharacterModel::setSessionKey($user_id, $session_key);
         $view = new JsonView();
         return $this->getViewByJson($view, $messageArr, 0, "mail/update_all_mail");
     }
     $price_type = $this->price_type;
     foreach ($mailInfo as $key => $value) {
         foreach ($price_type as $key2 => $value2) {
             if ($key2 == $value['n_item_type']) {
                 $userInfo[$value2] = $userInfo[$value2] + $value['n_item_num'];
                 if ($key2 == 4) {
                     $n_thew = $userInfo[$value2];
                 } else {
                     $newInfo[$value2] = $userInfo[$value2];
                 }
                 if ($key2 == 1) {
                     $n_coin = $n_coin + $value['n_item_num'];
                 }
                 if ($key2 == 3) {
                     $n_soul = $n_soul + $value['n_item_num'];
                 }
             }
         }
     }
     if ($n_thew) {
         $thewArr['n_thew'] = $n_thew;
         $thewArr['n_refresh_time'] = UserCache::getBykey($user_id, 'n_refresh_time');
         if (!$thewArr['n_refresh_time']) {
             $userInfo = MailModel::getUserInfo($user_id);
             $thewArr['n_refresh_time'] = $userInfo['n_refresh_time'];
         }
         $getArr = UserAction::refreshThew($thewArr);
         if (!$getArr) {
             $res = CharacterModel::update($thewArr, array('n_id' => $user_id));
             UserCache::setByKey($user_id, 'n_thew', $thewArr['n_thew']);
             UserCache::setByKey($user_id, 'n_refresh_time', $thewArr['n_refresh_time']);
         } else {
             $res = CharacterModel::update($getArr, array('n_id' => $user_id));
             UserCache::setByKey($user_id, 'n_thew', $getArr['n_thew']);
             UserCache::setByKey($user_id, 'n_refresh_time', $getArr['n_refresh_time']);
         }
     }
     //任务成就统计
     TaskAndAchieveAction::taskStatistic($user_id, array('reward' => $n_coin));
     //TaskAndAchieveAction::taskStatistic($user_id,array('soul'=>$n_soul));
     TaskAndAchieveAction::achieveStatistic($user_id, array('soul' => $n_soul));
     $res = MailModel::update(array('n_type' => 0), array('n_receive_id' => $user_id));
     $res = CharacterModel::update($newInfo, array('n_id' => $user_id));
     foreach ($newInfo as $key => $value) {
         UserCache::setByKey($user_id, $key, $value);
     }
     foreach ($price_type as $key => $value) {
         $moneyArr[$value] = UserCache::getByKey($user_id, $value);
         if (!$moneyArr[$value]) {
             $userInfo = MailModel::getUserInfo($user_id);
             $moneyArr[$value] = $userInfo[$value];
         }
     }
     $messageArr['moneyInfo'] = $moneyArr;
     //任务成就界面
     $messageArr['achieveInfo'] = TaskAndAchieveAction::getAchieveInfo($user_id);
     $messageArr['taskInfo'] = TaskAndAchieveAction::getTaskInfo($user_id);
     $messageArr['friend_mail'] = MailModel::getFriendMail($user_id);
     $messageArr['system_mail'] = MailModel::getSystemMail($user_id);
     $messageArr['session_key'] = CharacterModel::setSessionKey($user_id, $session_key);
     $view = new JsonView();
     return $this->getViewByJson($view, $messageArr, 1, "mail/update_all_mail");
 }
开发者ID:YYLP,项目名称:y_game,代码行数:89,代码来源:MailAction.class.php

示例4: achieveStatistic

 /**
  * API:成就统计
  *
  * @access public
  * @param int $user_id 用户ID
  * @return array
  */
 public function achieveStatistic($user_id, $dataArr)
 {
     $pointArr = array(6 => 1, 12 => 2, 22 => 3, 30 => 4);
     $userAchieve = UserCache::getByKey($user_id, self::ACHIEVEMENT_STRING);
     if (!$userAchieve) {
         $userAchieve = TaskAchieveModel::getUserInfoByCondition($user_id, self::ACHIEVEMENT_STRING);
         UserCache::setByKey($user_id, self::ACHIEVEMENT_STRING, $userAchieve);
     }
     foreach ($userAchieve as $key => $value) {
         $str = "achievement_id = " . $key . "_" . ($userAchieve[$key]['n_level'] + 1);
         $file = IniFileManager::getRootDir() . "/files/csv/achievement.csv";
         $achieveInfo = CharacterAction::readCsv($file, $str);
         if ($userAchieve[$key]['n_level'] < $userAchieve[$key]['max_level'] && $userAchieve[$key]['n_num'] < $achieveInfo[0]['condition']) {
             //1
             if ($dataArr['friend_help'] == 1 && $key == 1) {
                 $totalNum = $userAchieve[$key]['n_num'] + $dataArr['friend_help'];
                 if ($totalNum >= $achieveInfo[0]['condition']) {
                     $totalNum = $achieveInfo[0]['condition'];
                 }
                 $userAchieve[$key]['n_num'] = $totalNum;
             }
             //2
             if ($dataArr['login_day'] == 1 && $key == 2) {
                 $totalNum = $userAchieve[$key]['n_num'] + $dataArr['login_day'];
                 if ($totalNum >= $achieveInfo[0]['condition']) {
                     $totalNum = $achieveInfo[0]['condition'];
                 }
                 $userAchieve[$key]['n_num'] = $totalNum;
             }
             //3
             if ($dataArr['monster'] && $key == 3) {
                 $totalNum = $userAchieve[$key]['n_num'] + $dataArr['monster'];
                 if ($totalNum >= $achieveInfo[0]['condition']) {
                     $totalNum = $achieveInfo[0]['condition'];
                 }
                 $userAchieve[$key]['n_num'] = $totalNum;
             }
             //4
             if ($dataArr['star_num'] && $key == 4) {
                 $totalNum = $userAchieve[$key]['n_num'] + $dataArr['star_num'];
                 if ($totalNum >= $achieveInfo[0]['condition']) {
                     $totalNum = $achieveInfo[0]['condition'];
                 }
                 $userAchieve[$key]['n_num'] = $totalNum;
             }
             //5
             if ($dataArr['pro_num'] && $key == 5) {
                 $totalNum = $userAchieve[$key]['n_num'] + $dataArr['pro_num'];
                 if ($totalNum >= $achieveInfo[0]['condition']) {
                     $totalNum = $achieveInfo[0]['condition'];
                 }
                 $userAchieve[$key]['n_num'] = $totalNum;
             }
             //6
             if (($dataArr['pass'] === 0 || $dataArr['pass'] === 1) && $key == 6) {
                 $totalNum = $userAchieve[$key]['n_num'] + 1;
                 if ($totalNum >= $achieveInfo[0]['condition']) {
                     $totalNum = $achieveInfo[0]['condition'];
                 }
                 $userAchieve[$key]['n_num'] = $totalNum;
             }
             //7
             if ($dataArr['away'] === 0 && $dataArr['attack'] === 0 && $key == 7) {
                 $totalNum = $userAchieve[$key]['n_num'] + 1;
                 if ($totalNum >= $achieveInfo[0]['condition']) {
                     $totalNum = $achieveInfo[0]['condition'];
                 }
                 $userAchieve[$key]['n_num'] = $totalNum;
             }
             //8
             if ($dataArr['skill_num'] && $key == 8) {
                 $totalNum = $userAchieve[$key]['n_num'] + $dataArr['skill_num'];
                 if ($totalNum >= $achieveInfo[0]['condition']) {
                     $totalNum = $achieveInfo[0]['condition'];
                 }
                 $userAchieve[$key]['n_num'] = $totalNum;
             }
             //9
             if ($dataArr['cost'] && $key == 9) {
                 $totalNum = $userAchieve[$key]['n_num'] + $dataArr['cost'];
                 if ($totalNum >= $achieveInfo[0]['condition']) {
                     $totalNum = $achieveInfo[0]['condition'];
                 }
                 $userAchieve[$key]['n_num'] = $totalNum;
             }
             //11
             if ($dataArr['pass'] === 0 && $key == 11) {
                 $totalNum = $userAchieve[$key]['n_num'] + 1;
                 if ($totalNum >= $achieveInfo[0]['condition']) {
                     $totalNum = $achieveInfo[0]['condition'];
                 }
                 $userAchieve[$key]['n_num'] = $totalNum;
             }
//.........这里部分代码省略.........
开发者ID:YYLP,项目名称:y_game,代码行数:101,代码来源:TaskAndAchieveAction.class.php

示例5: exeUserLogin

 /**
  * API:用户登陆
  *
  * @access public
  * @param 无
  * @return JsonView 响应json
  */
 public function exeUserLogin()
 {
     $requestParam = $this->getAllParameters();
     Logger::debug('requestParam:' . print_r($requestParam, true));
     $requestJsonParam = $this->getDecodedJsonRequest();
     Logger::debug('requestJsonParam:' . print_r($requestJsonParam, true));
     // 获取用户id
     $user_id = AuthModel::getUserID($requestJsonParam['account'], $requestJsonParam['password'], $pdo);
     if (!$user_id) {
         $view = new JsonView();
         $messageArr['error'] = "密码不正确,请重新输入";
         return $this->getViewByJson($view, $messageArr, 0, "auth/user_login");
     }
     // 初始化缓存
     $userInfo = UserAction::iniUserInfo($user_id);
     $loginInfo = UserAction::getUserLoginInfo($userInfo['s_login_info']);
     if ($loginInfo != false) {
         $taskInfo = TaskAndAchieveAction::randTask($user_id);
         $updateArr['s_login_info'] = serialize($loginInfo);
         $updateArr['s_task_info'] = serialize($taskInfo);
         UserCache::setByKey($user_id, 's_login_info', $loginInfo);
         UserCache::setByKey($user_id, 's_task_info', $taskInfo);
         $userInfo['s_login_info'] = $loginInfo;
         $userInfo['s_task_info'] = $taskInfo;
         UserModel::update($updateArr, $user = array('n_id' => $user_id), $pdo);
         //清零合体次数
         FriendModel::clearFitNum($user_id);
         // // 成就
         // $statisticArr['login_day'] = 1;
         // TaskAndAchieveAction::achieveStatistic( $user_id, $statisticArr );
     }
     //$user_id = $requestParam['user_id'];
     //$userInfo = AuthModel::getUserInfo( $user_id, $pdo );
     // 生成缓存
     $newSessionKey = Util::generateSessionKey($user_id);
     $oldSessionKey = $requestParam['session_key'];
     Logger::debug('SessionKey1:' . $oldSessionKey);
     Logger::debug('SessionKey2:' . $newSessionKey);
     UserCache::setByKey($user_id, Constants::PREVIOUS_SESSION_KEY, $oldSessionKey);
     UserCache::setByKey($user_id, Constants::CURRENT_SESSION_KEY, $newSessionKey);
     //UserCache::setByKey($user_id, 'userInfo', $userInfo);
     //$messageArr['user'] = $userInfo;
     $messageArr['n_id'] = $user_id;
     $messageArr['total_day'] = $userInfo['s_login_info']['total_day'];
     $messageArr['session_key'] = $newSessionKey;
     $view = new JsonView();
     return $this->getViewByJson($view, $messageArr, 1, "auth/user_login");
 }
开发者ID:YYLP,项目名称:y_game,代码行数:55,代码来源:AuthAction.class.php

示例6: exeBuyMall

 /**
  * API:购买商城物品
  *
  * @access public
  * @param 无
  * @return JsonView 响应json
  */
 public function exeBuyMall()
 {
     $requestParam = $this->getAllParameters();
     Logger::debug('requestParam:' . print_r($requestParam, true));
     $requestJsonParam = $this->getDecodedJsonRequest();
     Logger::debug('requestJsonParam:' . print_r($requestJsonParam, true));
     $user_id = $requestParam['user_id'];
     $mall_id = $requestJsonParam['mall_id'];
     $session_key = $requestParam['session_key'];
     $str = "mall_id = " . $mall_id;
     $file = IniFileManager::getRootDir() . "/files/csv/mall.csv";
     $itemInfo = CharacterAction::readCsv($file, $str);
     $price_type = self::$price_type;
     //余额判断
     $type1 = $price_type[$itemInfo[0]['price_type']];
     $type2 = $price_type[$itemInfo[0]['buy_type']];
     $money1 = UserCache::getByKey($user_id, $type1);
     $money2 = UserCache::getByKey($user_id, $type2);
     if (!$money1) {
         $userInfo = BuyPropModel::getUserInfo($user_id);
         $money1 = $userInfo[$type1];
     }
     if (!$money2) {
         $userInfo = BuyPropModel::getUserInfo($user_id);
         $money2 = $userInfo[$type2];
     }
     $money1 = $money1 - $itemInfo[0]['price_num'];
     $money2 = $money2 + $itemInfo[0]['buy_num'];
     if ($money1 < 0) {
         $messageArr['session_key'] = CharacterModel::setSessionKey($user_id, $session_key);
         $messageArr['error'] = "人生果/钻石不足!";
         $view = new JsonView();
         return $this->getViewByJson($view, $messageArr, 0, "buy_prop/buy_mall");
     }
     //任务成就统计
     if ($type2 == $price_type[1]) {
         TaskAndAchieveAction::taskStatistic($user_id, array('reward' => $itemInfo[0]['buy_num']));
     }
     if ($type1 == $price_type[1]) {
         TaskAndAchieveAction::achieveStatistic($user_id, array('cost' => $itemInfo[0]['price_num']));
     }
     //购买体力是更新体力时间
     if ($type2 == $price_type[3]) {
         $thewArr['n_thew'] = $money2;
         $thewArr['n_refresh_time'] = UserCache::getBykey($user_id, 'n_refresh_time');
         if (!$thewArr['n_refresh_time']) {
             $userInfo = MailModel::getUserInfo($user_id);
             $thewArr['n_refresh_time'] = $userInfo['n_refresh_time'];
         }
         $getArr = UserAction::refreshThew($thewArr);
         if (!$getArr) {
             $res = CharacterModel::update($thewArr, array('n_id' => $user_id));
             UserCache::setByKey($user_id, 'n_thew', $thewArr['n_thew']);
             UserCache::setByKey($user_id, 'n_refresh_time', $thewArr['n_refresh_time']);
         } else {
             $res = CharacterModel::update($getArr, array('n_id' => $user_id));
             UserCache::setByKey($user_id, 'n_thew', $getArr['n_thew']);
             UserCache::setByKey($user_id, 'n_refresh_time', $getArr['n_refresh_time']);
         }
         $res = BuyPropModel::update(array($type1 => $money1), array('n_id' => $user_id));
         UserCache::setByKey($user_id, $type1, $money1);
     } else {
         $res = BuyPropModel::update(array($type1 => $money1, $type2 => $money2), array('n_id' => $user_id));
         UserCache::setByKey($user_id, $type1, $money1);
         UserCache::setByKey($user_id, $type2, $money2);
     }
     $messageArr['moneyInfo'] = BuyPropModel::getUserInfo($user_id);
     $messageArr['session_key'] = CharacterModel::setSessionKey($user_id, $session_key);
     //任务成就界面
     $messageArr['achieveInfo'] = TaskAndAchieveAction::getAchieveInfo($user_id);
     $messageArr['taskInfo'] = TaskAndAchieveAction::getTaskInfo($user_id);
     $view = new JsonView();
     return $this->getViewByJson($view, $messageArr, 1, "buy_prop/buy_mall");
 }
开发者ID:YYLP,项目名称:y_game,代码行数:81,代码来源:BuyPropAction.class.php

示例7: getFriend

 /**
  * 好友列表
  *
  * @access public
  * @param 无
  * @return arrary
  */
 public function getFriend($user_id)
 {
     $str = $user_id . '_friend';
     $friendList = UserCache::getByKey($str, 'friend_list');
     if (!$friendList) {
         $friendInfo = FriendModel::getFriendList($user_id);
         foreach ($friendInfo as $key => $value) {
             $friendList[] = $value['n_id'];
         }
         UserCache::setByKey($str, 'friend_list', $friendList);
     }
     return $friendList;
 }
开发者ID:YYLP,项目名称:y_game,代码行数:20,代码来源:FriendAction.class.php

示例8: exeResurrect

 /**
  * API:复活
  *
  * @access public
  * @param 无
  * @return JsonView 响应json
  * 
  */
 public function exeResurrect()
 {
     $requestParam = $this->getAllParameters();
     Logger::debug('requestParam:' . print_r($requestParam, true));
     $requestJsonParam = $this->getDecodedJsonRequest();
     Logger::debug('requestJsonParam:' . print_r($requestJsonParam, true));
     $user_id = $requestParam['user_id'];
     $type = self::$price_type[Constants::RESURE_TYPE];
     $money = UserCache::getByKey($user_id, $type);
     if (!$money) {
         $userInfo = FriendModel::getUserInfo($user_id);
         $money = $userInfo[$type];
     }
     $money = $money - Constants::RESURE_COST;
     if ($money < 0) {
         $messageArr['error'] = "人生果/钻石不足!";
         $messageArr['session_key'] = CharacterModel::setSessionKey($user_id, $session_key);
         $view = new JsonView();
         return $this->getViewByJson($view, $messageArr, 0, "game/resurrect");
     }
     $ret = CharacterModel::update(array($type => $money), array('n_id' => $user_id));
     UserCache::setByKey($user_id, $type, $money);
     $messageArr['session_key'] = CharacterModel::setSessionKey($user_id, $session_key);
     $view = new JsonView();
     return $this->getViewByJson($view, $messageArr, 1, "game/resurrect");
 }
开发者ID:YYLP,项目名称:y_game,代码行数:34,代码来源:GameAction.class.php

示例9: nowCharacterInfo

 /**
  * API:获取当前上阵主角信息
  *
  * @access public
  * @param $integer $user_id $general_id 用户ID,武将ID
  * @return array 
  */
 public function nowCharacterInfo($user_id)
 {
     $userCharacter = UserCache::getByKey($user_id, self::CHARACTER_STRING);
     if (!$userCharacter) {
         $userCharacter = CharacterModel::getUserCharacterInfo($user_id);
         UserCache::setByKey($user_id, self::CHARACTER_STRING, $userCharacter);
     }
     return self::GetCharacterAttribute($user_id, $userCharacter[0]);
 }
开发者ID:YYLP,项目名称:y_game,代码行数:16,代码来源:CharacterAction.class.php

示例10: isUnlock

 /**
  * API:武将解锁直接拥有
  *
  * @access public
  * @param int $user_id 用户ID $general_id主角ID
  * @return array
  */
 public function isUnlock($user_id)
 {
     $starNum = GameAction::getUserStar($user_id);
     $userGeneral = UserCache::getByKey($user_id, 's_general_info');
     if (!$userGeneral) {
         $userGeneral = GeneralModel::getUserGeneralInfo($user_id);
         UserCache::setByKey($user_id, 's_general_info', $userGeneral);
     }
     //读取系统武将,属性列表
     $file = IniFileManager::getRootDir() . "/files/csv/general.csv";
     $generalArr = CharacterAction::readCsv($file);
     foreach ($generalArr as $key => $value) {
         if (!$userGeneral[$value['general_id']]) {
             if ($starNum >= $value['unlock_star']) {
                 //添加新武将到武将信息字段、更新用户金钱
                 $userGeneral[$value['general_id']] = array('n_continue_level' => 0, 'n_cool_level' => 0);
                 $unlockInfo = $value['general_id'];
             }
         }
     }
     $s_general_info = serialize($userGeneral);
     $ret = GeneralModel::update(array('s_general_info' => $s_general_info), array('n_id' => $user_id));
     UserCache::setByKey($user_id, 's_general_info', $userGeneral);
     //更新战斗力
     $battle = UserAction::getUserBattle($user_id);
     GeneralModel::update(array('n_battle' => $battle), array('n_id' => $user_id));
     UserCache::setByKey($user_id, 'n_battle', $battle);
     return $unlockInfo ? $unlockInfo : 0;
 }
开发者ID:YYLP,项目名称:y_game,代码行数:36,代码来源:GeneralAction.class.php

示例11: exeLogin

 /**
  * API:用户签到
  *
  * @access public
  * @param 无
  * @return JsonView 响应json
  */
 public function exeLogin()
 {
     $requestParam = $this->getAllParameters();
     Logger::debug('requestParam:' . print_r($requestParam, true));
     $requestJsonParam = $this->getDecodedJsonRequest();
     Logger::debug('requestJsonParam:' . print_r($requestJsonParam, true));
     // 获取用户表信息
     $userInfo = UserCache::getAllUserCache($requestParam['user_id']);
     if (!$userInfo) {
         $userInfo = self::iniUserInfo($requestParam['user_id']);
     }
     if ($userInfo['s_login_info']['type'] == 0) {
         $rewardTypeArr = array(1 => 'n_coin', 2 => 'n_diamond', 3 => 'n_thew', 4 => 'n_soul');
         /*$reward = $userInfo['s_login_info']['reward'];
           $updateArr[$rewardTypeArr[$reward['type']]] = $userInfo[$rewardTypeArr[$reward['type']]] = $userInfo[$rewardTypeArr[$reward['type']]] + $reward['num'];
           $userInfo['s_login_info']['type'] = 1;
           $updateArr['s_login_info'] = serialize( $userInfo['s_login_info'] );*/
         $userInfo['s_login_info']['con_day'] = $userInfo['s_login_info']['con_day'] + 1;
         $userInfo['s_login_info']['total_day'] = $userInfo['s_login_info']['total_day'] + 1;
         // 非连续签到
         if (strtotime(date('Y-m-d', time())) - $userInfo['s_login_info']['time'] > 86400) {
             $userInfo['s_login_info']['con_day'] = 1;
         }
         $userInfo['s_login_info']['time'] = time();
         $rewardNum = $userInfo['s_login_info']['rewardArr']['check'];
         $reward = $userInfo['s_login_info']['rewardArr']['box_info'][$rewardNum];
         $updateArr[$rewardTypeArr[$reward['type']]] = $userInfo[$rewardTypeArr[$reward['type']]] = $userInfo[$rewardTypeArr[$reward['type']]] + $reward['num'];
         $userInfo['s_login_info']['type'] = 1;
         $updateArr['s_login_info'] = serialize($userInfo['s_login_info']);
         // 成就
         if ($reward['type'] == 1) {
             $statisticArr['reward'] = $reward['num'];
             TaskAndAchieveAction::taskStatistic($requestParam['user_id'], $statisticArr);
         } elseif ($reward['type'] == 4) {
             $statisticArr['soul'] = $reward['num'];
         }
         $statisticArr['login_day'] = 1;
         TaskAndAchieveAction::achieveStatistic($requestParam['user_id'], $statisticArr);
         UserModel::update($updateArr, array('n_id' => $requestParam['user_id']));
         UserCache::setByKey($requestParam['user_id'], $rewardTypeArr[$reward['type']], $userInfo[$rewardTypeArr[$reward['type']]]);
         UserCache::setByKey($requestParam['user_id'], 's_login_info', $userInfo['s_login_info']);
     } else {
         $messageArr['error'] = "今天已签到";
         $view = new JsonView();
         return $this->getViewByJson($view, $messageArr, 0, "user/login");
     }
     // 生成缓存
     $newSessionKey = Util::generateSessionKey($requestParam['user_id']);
     $oldSessionKey = $requestParam['session_key'];
     Logger::debug('SessionKey1:' . $oldSessionKey);
     Logger::debug('SessionKey2:' . $newSessionKey);
     UserCache::setByKey($requestParam['user_id'], Constants::PREVIOUS_SESSION_KEY, $oldSessionKey);
     UserCache::setByKey($requestParam['user_id'], Constants::CURRENT_SESSION_KEY, $newSessionKey);
     //UserCache::setByKey($user_id, 'userInfo', $userInfo);
     $messageArr['n_id'] = $requestParam['user_id'];
     //$messageArr = $userInfo;
     $messageArr['n_coin'] = $userInfo['n_coin'];
     $messageArr['n_diamond'] = $userInfo['n_diamond'];
     $messageArr['n_soul'] = $userInfo['n_soul'];
     $messageArr['n_thew'] = $userInfo['n_thew'];
     //$messageArr['n_reward'] = $userInfo['n_reward'];
     //任务成就界面
     $messageArr['achieveInfo'] = TaskAndAchieveAction::getAchieveInfo($requestParam['user_id']);
     $messageArr['taskInfo'] = TaskAndAchieveAction::getTaskInfo($requestParam['user_id']);
     $messageArr['session_key'] = $newSessionKey;
     $view = new JsonView();
     return $this->getViewByJson($view, $messageArr, 1, "user/login");
 }
开发者ID:YYLP,项目名称:y_game,代码行数:75,代码来源:UserAction.class.php


注:本文中的UserCache::setByKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。