protected function _exec()
 {
     $gameuid = $this->getParam('gameuid', 'int');
     $itemId = $this->getParam('itemId', 'int');
     $count = $this->getParam('count', 'int');
     $useGem = $this->getParam('useGem', 'bool');
     $characterId = $this->getParam('heroid', 'int');
     $itemDef = get_xml_def($itemId);
     if (empty($itemDef)) {
         $this->throwException("itemId is not item {$itemId}");
     }
     $cost = 0;
     if ($useGem) {
         $cost = $itemDef['gem'] * $count;
     } else {
         $cost = $itemDef['coin'] * $count;
     }
     if ($cost <= 0) {
         $this->throwException("itemId is no cost  useGem {$useGem} : {$cost}");
     }
     $itemMgr = new UserGameItemManager($characterId);
     $itemMgr->addItem($itemId, $count);
     $user_mgr = new UserAccountManager();
     $user_account = $user_mgr->getUserAccount($gameuid);
     if ($useGem) {
         if ($user_account['gem'] < $cost) {
             $this->throwException("character {$gameuid} not enough gem {$cost}");
         }
         $user_mgr->updateUserMoney($gameuid, -$cost);
     } else {
         if ($user_account['coin'] < $cost) {
             $this->throwException("character {$gameuid} not enough coin {$cost}");
         }
         $user_mgr->updateUserCoin($gameuid, -$cost);
     }
     $itemMgr->commitToDB();
     return array("state" => TRUE);
 }
 protected function _exec()
 {
     $gameuid = $this->getParam('gameuid', 'int');
     $heroid = $this->getParam('heroid', 'int');
     $name = $this->getParam('name', 'string');
     $user_clan_mgr = new UserClanManager();
     $clanInfo = $user_clan_mgr->getUserClanInfo($heroid);
     if (!empty($clanInfo)) {
         $this->throwException("user {$heroid} already have clan ");
     }
     $account_mgr = new UserAccountManager();
     $account_info = $account_mgr->getUserAccount($gameuid);
     if ($account_info['gem'] < 20) {
         $this->throwException("user {$gameuid} not enough gem to buy Clan ");
     }
     $clan_mgr = new ClanManager();
     $result = $clan_mgr->creatClan($heroid, $name);
     $user_clan_info = $user_clan_mgr->creatUserClan($heroid, $result['data_id']);
     $account_mgr->updateUserMoney($gameuid, 20);
     $hero_mgr = new CharacterAccountManager();
     $result['admin'] = $hero_mgr->getCharacterAccount($heroid);
     $result['membersArr'] = array($user_clan_info);
     return array('clan' => $result);
 }