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


PHP UserAction::refreshThew方法代碼示例

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


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

示例1: exeGetTaskReward

 /**
  * API:領取任務獎勵
  *
  * @access public
  * @param 無
  * @return JsonView 響應json
  */
 public function exeGetTaskReward()
 {
     $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'];
     $task_id = $requestJsonParam['task_id'];
     $session_key = $requestParam['session_key'];
     $userTask = UserCache::getByKey($user_id, self::TASK_STRING);
     if (!$userTask) {
         $userTask = TaskAchieveModel::getUserInfoByCondition($user_id, self::TASK_STRING);
         UserCache::setByKey($user_id, self::TASK_STRING, $userTask);
     }
     $str = "task_id = " . $task_id . "_" . $userTask[0][$task_id];
     $file = IniFileManager::getRootDir() . "/files/csv/task.csv";
     $taskInfo = CharacterAction::readCsv($file, $str);
     //完成條件的判斷
     if ($userTask[$task_id]['n_num'] < $taskInfo[0]['condition']) {
         $messageArr['error'] = "領取條件不足!";
         $messageArr['session_key'] = CharacterModel::setSessionKey($user_id, $session_key);
         $view = new JsonView();
         return $this->getViewByJson($view, $messageArr, 0, "task_and_achieve/get_task_reward");
     }
     //是否領取的判斷
     if ($userTask[$task_id]['n_reward'] != 0) {
         $messageArr['error'] = "已領取該獎勵!";
         $messageArr['session_key'] = CharacterModel::setSessionKey($user_id, $session_key);
         $view = new JsonView();
         return $this->getViewByJson($view, $messageArr, 0, "task_and_achieve/get_task_reward");
     }
     //更新任務狀態,及金錢
     $price_type = $this->price_type;
     $type = $price_type[$taskInfo[0]['reward_type']];
     $money = UserCache::getByKey($user_id, $type);
     if (!$money) {
         $userInfo = TaskAchieveModel::getUserInfo($user_id);
         $money = $userInfo[$type];
     }
     $money = $money + $taskInfo[0]['reward_num'];
     //體力領取恢複時間更新
     if ($type == $price_type[4]) {
         $thewArr['n_thew'] = $money;
         $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']);
         }
     } else {
         $res = CharacterModel::update(array($type => $money), array('n_id' => $user_id));
         UserCache::setByKey($user_id, $type, $money);
     }
     $userTask[$task_id]['n_reward'] = 1;
     $s_task_info = serialize($userTask);
     $res = TaskAchieveModel::update(array('s_task_info' => $s_task_info), array('n_id' => $user_id));
     if (!$res) {
         throw new Exception("update false");
     }
     UserCache::setByKey($user_id, self::TASK_STRING, $userTask);
     //任務成就統計
     if ($type == $price_type[1]) {
         TaskAndAchieveAction::taskStatistic($user_id, array('reward' => $taskInfo[0]['reward_num']));
     }
     if ($type == $price_type[3]) {
         //TaskAndAchieveAction::taskStatistic($user_id,array('soul'=>$taskInfo[0]['reward_num']));
         TaskAndAchieveAction::achieveStatistic($user_id, array('soul' => $taskInfo[0]['reward_num']));
     }
     //sessdion_key
     $messageArr['session_key'] = CharacterModel::setSessionKey($user_id, $session_key);
     $messageArr['achieveInfo'] = self::getAchieveInfo($user_id);
     $messageArr['taskInfo'] = self::getTaskInfo($user_id);
     $view = new JsonView();
     return $this->getViewByJson($view, $messageArr, 1, "task_and_achieve/get_task_reward");
 }
開發者ID:YYLP,項目名稱:y_game,代碼行數:91,代碼來源:TaskAndAchieveAction.class.php

示例2: 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

示例3: 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


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