diff --git a/webapp/controller/BaseAuthedController.class.php b/webapp/controller/BaseAuthedController.class.php index bfa607a3..b37a4961 100644 --- a/webapp/controller/BaseAuthedController.class.php +++ b/webapp/controller/BaseAuthedController.class.php @@ -45,19 +45,6 @@ class BaseAuthedController extends BaseController { return $registertime; } - public function _getMysql($data) - { - $mysql_conf = getMysqlConfig(crc32($data)); - $conn = new phpcommon\Mysql(array( - 'host' => $mysql_conf['host'], - 'port' => $mysql_conf['port'], - 'user' => $mysql_conf['user'], - 'passwd' => $mysql_conf['passwd'], - 'dbname' => DBNAME_PREFIX . $mysql_conf['instance_id'] - )); - return $conn; - } - public function _getSelfMysql() { if (!$this->mysqlConn) { @@ -66,18 +53,6 @@ class BaseAuthedController extends BaseController { return $this->mysqlConn; } - public function _getRedis($data) - { - $redis_conf = getRedisConfig(crc32($data)); - $r = new phpcommon\Redis(array( - 'host' => $redis_conf['host'], - 'port' => $redis_conf['port'], - 'passwd' => $redis_conf['passwd'] - - )); - return $r; - } - public function _getUserInfo($fields) { $row = SqlHelper::selectOne @@ -269,83 +244,6 @@ class BaseAuthedController extends BaseController { } } - public function _deleteItem($item) - { - $tmpItemID = $item["item_id"]; - $beDeleteNum = $item['item_num']; - $accountID = $this->_getAccountId(); - $conn = $this->_getMysql($accountID); - $sqlStr = "SELECT id,num FROM bag WHERE accountid=:accountid AND id=:itemId"; - $row = $conn->execQuery($sqlStr,array(':accountid' => $accountID,':itemId' =>$tmpItemID)); - $code = 100; - if($row) - { - $num1 = $row[0]['num']; - if($num1 < $beDeleteNum) - { - $code = 98;//道具不足 - } - } - else - { - $code = 99;//道具不存在 - } - - return $code; - } - - public function _decGold($decGold) - { - SqlHelper::update - ( - $this->_getSelfMysql(), - 'user', - array( - 'accountid' => $this->_getAccountId() - ), - array( - 'coin_num' => function () use($decGold) { return "CASE coin_num WHEN coin_num < {$decGold} THEN 0 ELSE coin_num - {$decGold} END"; } - ) - ); - // $this->incV(TN_CONSUME_GOLD, 0, $decGold); - // $this->incV(TN_CONSUME_GOLD, $this->_getNowDaySeconds(), $decGold); - } - - public function _addGold($addGold) - { - SqlHelper::update - ( - $this->_getSelfMysql(), - 'user', - array( - 'accountid' => $this->_getAccountId() - ), - array( - 'coin_num' => function () use($addGold) { return "coin_num + {$addGold}"; } - ) - ); - } - - public function _getTalentLv($skillId, $skillTypeId) - { - $row = SqlHelper::selectOne - ( - $this->_getSelfMysql(), - 'gun_intensify', - array( - 'gun_type_id', - 'skill_id', - 'skill_lv' - ), - array( - 'accountid' => $this->_getAccountId(), - 'skill_id' => $skillId, - 'gun_type_id' => $skillTypeId - ) - ); - return $row ? $row['skill_iv'] : 0; - } - public function _hasEnoughItemsEx($items, &$lackItem) { $userInfo = $this->_getUserInfo(array( @@ -367,22 +265,4 @@ class BaseAuthedController extends BaseController { return true; } - public function _redisSetAndExpire($pk, $key, $val, $time) - { - $r = $this->_getRedis($pk); - $r->set($key, $val); - $r->pexpire($key, $time); - } - - public function _redisGetJson($pk, $key) - { - $r = $this->_getRedis($pk); - $dataStr = $r->get($key); - $result = null; - if (!empty($dataStr)) { - $result = json_decode($dataStr, true); - } - return $result; - } - } diff --git a/webapp/controller/BaseController.class.php b/webapp/controller/BaseController.class.php index 2cd3e254..6b3ae119 100644 --- a/webapp/controller/BaseController.class.php +++ b/webapp/controller/BaseController.class.php @@ -64,4 +64,47 @@ class BaseController { echo json_encode($rawData); } + public function _getMysql($data) + { + $mysql_conf = getMysqlConfig(crc32($data)); + $conn = new phpcommon\Mysql(array( + 'host' => $mysql_conf['host'], + 'port' => $mysql_conf['port'], + 'user' => $mysql_conf['user'], + 'passwd' => $mysql_conf['passwd'], + 'dbname' => DBNAME_PREFIX . $mysql_conf['instance_id'] + )); + return $conn; + } + + public function _getRedis($data) + { + $redis_conf = getRedisConfig(crc32($data)); + $r = new phpcommon\Redis(array( + 'host' => $redis_conf['host'], + 'port' => $redis_conf['port'], + 'passwd' => $redis_conf['passwd'] + + )); + return $r; + } + + public function _redisSetAndExpire($pk, $key, $val, $time) + { + $r = $this->_getRedis($pk); + $r->set($key, $val); + $r->pexpire($key, $time); + } + + public function _redisGetJson($pk, $key) + { + $r = $this->_getRedis($pk); + $dataStr = $r->get($key); + $result = null; + if (!empty($dataStr)) { + $result = json_decode($dataStr, true); + } + return $result; + } + }