本文整理匯總了PHP中UserCache::getAllUserCache方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserCache::getAllUserCache方法的具體用法?PHP UserCache::getAllUserCache怎麽用?PHP UserCache::getAllUserCache使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類UserCache
的用法示例。
在下文中一共展示了UserCache::getAllUserCache方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: 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");
}
示例2: exeEndGame
/**
* API:遊戲結算
*
* @access public
* @param 無
* @return JsonView 響應json
* {"scoreInfo":{"combo":[5,3,4],"award":10,"deduction":[3,2],"kill":{"monster":5,"boss":2}},"checkpoint_id":3,"scr_length":5,"star_num":5,"diamond":2,"pass":1}
*/
public function exeEndGame()
{
$requestParam = $this->getAllParameters();
Logger::debug('requestParam:' . print_r($requestParam, true));
$requestJsonParam = $this->getDecodedJsonRequest();
Logger::debug('requestJsonParam:' . print_r($requestJsonParam, true));
//------------------------------------統計分數---------------------------------------
$checkPointId = $requestJsonParam['checkpoint_id'];
// 評級總分
$dir = IniFileManager::getRootDir() . "files/csv/" . self::CHECKPOINT_LIST . ".csv";
$str = "checkpoint_id = " . $checkPointId;
$checkpointArr = Util::readCsv($dir, $str);
if (empty($checkpointArr)) {
$view = new JsonView();
$messageArr['error'] = "關卡不存在";
return $this->getViewByJson($view, $messageArr, 0, "game/end_game");
}
$gradeScore = $checkpointArr[0]['grade_score'];
$scoreInfo = $requestJsonParam['scoreInfo'];
// 連擊獎勵分總和
if (count($scoreInfo['combo']) > 0) {
foreach ($scoreInfo['combo'] as $key => $value) {
$comboNum = $value;
}
}
$comboTotal = $comboNum * 3;
// 得人參果分總和
$rewardTotal = $scoreInfo['award'];
// 殺怪總分
$killTotal = $scoreInfo['kill']['monster'] + $scoreInfo['kill']['boss'] * 3;
// 被擊扣分總和
$deduction = $scoreInfo['deduction'][0] * 5 + $scoreInfo['deduction'][1] * 5;
// 通關分
$passScore = $gradeScore * 0.1;
// 技巧評分
$skillScore = ($comboTotal + $rewardTotal + $killTotal + $passScore - $deduction) / $gradeScore * 100;
//------------------------------------最優關卡信息---------------------------------------
// 獲取原有最優信息
$userInfo = UserCache::getAllUserCache($requestParam['user_id']);
if (!$userInfo) {
$userInfo = UserAction::iniUserInfo($requestParam['user_id']);
}
$checkPointInfo = $userInfo['s_checkpoint_info'];
// 此次遊戲需對比信息
$newInfo['score'] = $skillScore;
$newInfo['scr_length'] = $requestJsonParam['scr_length'];
$newInfo['reward'] = $scoreInfo['award'];
$newInfo['kill_num'] = $scoreInfo['kill']['monster'] + $scoreInfo['kill']['boss'];
$newInfo['star_num'] = $requestJsonParam['star_num'];
$addStarNum = 0;
if ($checkPointInfo[$checkPointId]) {
// 分數判斷
if ($newInfo['score'] > $checkPointInfo[$checkPointId]['score']) {
$checkPointInfo[$checkPointId]['score'] = $newInfo['score'];
$updateType = 1;
}
// 最短劃痕
if ($newInfo['scr_length'] < $checkPointInfo[$checkPointId]['scr_length']) {
$checkPointInfo[$checkPointId]['scr_length'] = $newInfo['scr_length'];
$updateType = 1;
}
// 單局最多人生果
if ($newInfo['reward'] > $checkPointInfo[$checkPointId]['reward']) {
$checkPointInfo[$checkPointId]['reward'] = $newInfo['reward'];
$updateType = 1;
}
// 單局殺死最多怪物數
if ($newInfo['kill_num'] > $checkPointInfo[$checkPointId]['kill_num']) {
$checkPointInfo[$checkPointId]['kill_num'] = $newInfo['kill_num'];
$updateType = 1;
}
// 該關卡獲得星星數
if ($newInfo['star_num'] > $checkPointInfo[$checkPointId]['star_num']) {
$checkPointInfo[$checkPointId]['star_num'] = $newInfo['star_num'];
$updateType = 1;
$addStarNum = $newInfo['star_num'] - $checkPointInfo[$checkPointId]['star_num'];
}
} else {
$updateType = 1;
$checkPointInfo[$checkPointId] = $newInfo;
// 預留激活下一關
}
// 增加鑽石
if ($requestJsonParam['diamond']) {
$newUserInfo['n_diamond'] = $userInfo['n_diamond'] + $requestJsonParam['diamond'];
$updateType = 1;
}
// 增加魂石數
if ($requestJsonParam['soul']) {
$newUserInfo['n_soul'] = $userInfo['n_soul'] + $requestJsonParam['soul'];
$updateType = 1;
}
//.........這裏部分代碼省略.........
示例3: getFriendRank
/**
* API:獲取好友排行
*
* @access public
* @param 無
* @return JsonView 響應json
*/
public function getFriendRank($user_id)
{
// 好友列表加入緩存後此處需要修改
$friendList = FriendAction::getFriend($user_id);
if ($friendList && count($friendList)) {
foreach ($friendList as $key => $value) {
$userInfo = UserCache::getAllUserCache($value);
if (!$userInfo['n_id'] || !$userInfo['n_head'] || !$userInfo['s_name'] || !$userInfo['n_sex'] || !$userInfo['n_level'] || !$userInfo['n_max_checkpoint']) {
$userInfo = UserAction::iniUserInfo($value);
}
$rankInfo['id'] = $userInfo['n_id'];
$rankInfo['head'] = $userInfo['n_head'];
$rankInfo['name'] = $userInfo['s_name'];
$rankInfo['sex'] = $userInfo['n_sex'];
$rankInfo['level'] = $userInfo['n_level'];
$rankInfo['checkpoint'] = $userInfo['n_max_checkpoint'];
$rankInfo['battle'] = $userInfo['n_battle'];
$FriendRankInfo[] = $rankInfo;
}
}
$userInfo = UserCache::getAllUserCache($user_id);
if (!$userInfo) {
$userInfo = UserAction::iniUserInfo($user_id);
}
$rankInfo['id'] = $userInfo['n_id'];
$rankInfo['head'] = $userInfo['n_head'];
$rankInfo['name'] = $userInfo['s_name'];
$rankInfo['sex'] = $userInfo['n_sex'];
$rankInfo['level'] = $userInfo['n_level'];
$rankInfo['checkpoint'] = $userInfo['n_max_checkpoint'];
$rankInfo['battle'] = $userInfo['n_battle'];
$FriendRankInfo[] = $rankInfo;
return $FriendRankInfo;
}
示例4: 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");
}