完成controler改造

This commit is contained in:
aozhiwei 2021-11-26 14:22:38 +08:00
parent 88c64e6700
commit d12e58e6b8
11 changed files with 181 additions and 181 deletions

View File

@ -27,7 +27,7 @@ class BagController extends BaseAuthedController {
public function getBagInfo() public function getBagInfo()
{ {
$account_id = $_REQUEST['account_id']; $account_id = $_REQUEST['account_id'];
$conn = $this->getMysql($account_id); $conn = $this->_getMysql($account_id);
$bag_list = array(); $bag_list = array();
$rows = $conn->execQuery('SELECT * FROM bag WHERE accountid=:account_id;', $rows = $conn->execQuery('SELECT * FROM bag WHERE accountid=:account_id;',
array( array(
@ -80,7 +80,7 @@ class BagController extends BaseAuthedController {
$account_id = $_REQUEST['account_id']; $account_id = $_REQUEST['account_id'];
$item_id = $_REQUEST['item_id']; $item_id = $_REQUEST['item_id'];
$color_id = $_REQUEST['color_id']; $color_id = $_REQUEST['color_id'];
$conn = $this->getMysql($account_id); $conn = $this->_getMysql($account_id);
$b = $this->getBag($item_id); $b = $this->getBag($item_id);
$bag_meta_table = require('../res/bag@bag.php'); $bag_meta_table = require('../res/bag@bag.php');
//正在装备的道具 //正在装备的道具
@ -153,7 +153,7 @@ class BagController extends BaseAuthedController {
{ {
$account_id = $_REQUEST['account_id']; $account_id = $_REQUEST['account_id'];
$item_id = $_REQUEST['item_id']; $item_id = $_REQUEST['item_id'];
$conn = $this->getMysql($account_id); $conn = $this->_getMysql($account_id);
$b = $this->getBag($item_id); $b = $this->getBag($item_id);
$row = $conn->execQueryOne('SELECT status,active_time FROM bag WHERE accountid=:accountid AND id=:id;', $row = $conn->execQueryOne('SELECT status,active_time FROM bag WHERE accountid=:accountid AND id=:id;',
@ -194,7 +194,7 @@ class BagController extends BaseAuthedController {
{ {
$account_id = $_REQUEST['account_id']; $account_id = $_REQUEST['account_id'];
$item_id = $_REQUEST['item_id']; $item_id = $_REQUEST['item_id'];
$conn = $this->getMysql($account_id); $conn = $this->_getMysql($account_id);
$exchange_ret = $conn->execScript('UPDATE bag SET color_id=0, modify_time=:modify_time ' . $exchange_ret = $conn->execScript('UPDATE bag SET color_id=0, modify_time=:modify_time ' .
' WHERE accountid = :account_id AND id = :id;', ' WHERE accountid = :account_id AND id = :id;',
array( array(
@ -219,7 +219,7 @@ class BagController extends BaseAuthedController {
{ {
$account_id = $_REQUEST['account_id']; $account_id = $_REQUEST['account_id'];
$item_id = $_REQUEST['item_id']; $item_id = $_REQUEST['item_id'];
$conn = $this->getMysql($account_id); $conn = $this->_getMysql($account_id);
$addreward = new classes\AddReward(); $addreward = new classes\AddReward();
$ptime = mt\Parameter::getOldParam(RECOMMEND_TIME); $ptime = mt\Parameter::getOldParam(RECOMMEND_TIME);
$addreward->addReward($item_id, 1, $account_id, $ptime['param_value'], 0); $addreward->addReward($item_id, 1, $account_id, $ptime['param_value'], 0);
@ -277,7 +277,7 @@ class BagController extends BaseAuthedController {
public function updateWeizhuang() public function updateWeizhuang()
{ {
$account_id = $_REQUEST['account_id']; $account_id = $_REQUEST['account_id'];
$conn = $this->getMysql($account_id); $conn = $this->_getMysql($account_id);
$arr = json_decode($_REQUEST['arr'], true); $arr = json_decode($_REQUEST['arr'], true);
foreach ($arr as $a) { foreach ($arr as $a) {
$row = $conn->execQueryOne('SELECT status FROM bag WHERE accountid=:account_id AND id=:id;', $row = $conn->execQueryOne('SELECT status FROM bag WHERE accountid=:account_id AND id=:id;',
@ -315,7 +315,7 @@ class BagController extends BaseAuthedController {
public function deleteItem() public function deleteItem()
{ {
$account_id = $_REQUEST['account_id']; $account_id = $_REQUEST['account_id'];
$conn = $this->getMysql($account_id); $conn = $this->_getMysql($account_id);
$id = $_REQUEST['id']; $id = $_REQUEST['id'];
$row = $conn->execQueryOne('SELECT num, status FROM bag WHERE accountid=:account_id AND id=:id;', $row = $conn->execQueryOne('SELECT num, status FROM bag WHERE accountid=:account_id AND id=:id;',
array( array(
@ -372,7 +372,7 @@ class BagController extends BaseAuthedController {
array_push($itemArr,$itemData); array_push($itemArr,$itemData);
error_log("itemTest=01====".$itemIDArr[$i]."==".$itemN); error_log("itemTest=01====".$itemIDArr[$i]."==".$itemN);
} }
$this->addItem($itemArr); $this->_addItem($itemArr);
$this->sendDataToClient(1,"test03",null); $this->sendDataToClient(1,"test03",null);
} }
public function saleItem() public function saleItem()
@ -387,12 +387,12 @@ class BagController extends BaseAuthedController {
$deleteItem = array("item_id"=>$itemID,"item_num"=>$itemNum); $deleteItem = array("item_id"=>$itemID,"item_num"=>$itemNum);
array_push($itemArr,$deleteItem); array_push($itemArr,$deleteItem);
$code = $this->deleteItem($deleteItem); $code = $this->_deleteItem($deleteItem);
//error_log("准备删除道具======".$code); //error_log("准备删除道具======".$code);
if($code == 100) if($code == 100)
{ {
$this->decItem($itemArr); $this->_decItem($itemArr);
$this->addGold($singlePrice*$itemNum); $this->_addGold($singlePrice*$itemNum);
} }
$resultArr = array('saleMoney'=>$singlePrice*$itemNum,'itemID'=>$itemID,'itemNum'=>$itemNum); $resultArr = array('saleMoney'=>$singlePrice*$itemNum,'itemID'=>$itemID,'itemNum'=>$itemNum);
@ -410,10 +410,10 @@ class BagController extends BaseAuthedController {
$itemArr = array(); $itemArr = array();
$deleteItem = array("item_id"=>$itemID,"item_num"=>$itemNum); $deleteItem = array("item_id"=>$itemID,"item_num"=>$itemNum);
array_push($itemArr,$deleteItem); array_push($itemArr,$deleteItem);
$code = $this->deleteItem($deleteItem); $code = $this->_deleteItem($deleteItem);
if($code == 100) if($code == 100)
{ {
$this->decItem($itemArr); $this->_decItem($itemArr);
//合并打开礼包的获得的道具开始-- //合并打开礼包的获得的道具开始--
if($dropID >0) if($dropID >0)
{ {
@ -445,7 +445,7 @@ class BagController extends BaseAuthedController {
$resultDropItemLen = count($item_list); $resultDropItemLen = count($item_list);
if($resultDropItemLen >0) if($resultDropItemLen >0)
{ {
$this->addItem($item_list); $this->_addItem($item_list);
} }
} }
@ -462,7 +462,7 @@ class BagController extends BaseAuthedController {
public function getAllItem() public function getAllItem()
{ {
$account_id = $_REQUEST['account_id']; $account_id = $_REQUEST['account_id'];
$conn = $this->getMysql($account_id); $conn = $this->_getMysql($account_id);
$sqlStr = "SELECT * FROM bag WHERE accountid=:accountid; "; $sqlStr = "SELECT * FROM bag WHERE accountid=:accountid; ";
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id)); $row = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
if($row) { if($row) {
@ -473,7 +473,7 @@ class BagController extends BaseAuthedController {
public function getAllYokeItem() public function getAllYokeItem()
{ {
$account_id = $_REQUEST['account_id']; $account_id = $_REQUEST['account_id'];
$conn = $this->getMysql($account_id); $conn = $this->_getMysql($account_id);
$sqlStr = "SELECT * FROM bag WHERE accountid=:accountid; "; $sqlStr = "SELECT * FROM bag WHERE accountid=:accountid; ";
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id)); $row = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
$allYokeItem = array(); $allYokeItem = array();

View File

@ -31,7 +31,7 @@ class BaseAuthedController extends BaseController {
public function _getChannel() public function _getChannel()
{ {
return phpcommon\extractChannel($this->getAccountId()); return phpcommon\extractChannel($this->_getAccountId());
} }
public function _getSessionId() public function _getSessionId()
@ -61,7 +61,7 @@ class BaseAuthedController extends BaseController {
public function _getSelfMysql() public function _getSelfMysql()
{ {
if (!$this->mysqlConn) { if (!$this->mysqlConn) {
$this->mysqlConn = $this->getMysql($this->getAccountId()); $this->mysqlConn = $this->_getMysql($this->_getAccountId());
} }
return $this->mysqlConn; return $this->mysqlConn;
} }
@ -86,16 +86,16 @@ class BaseAuthedController extends BaseController {
public function _getUserInfo($fields) public function _getUserInfo($fields)
{ {
$row = SqlHelper::selectOne $row = SqlHelper::selectOne
($this->getSelfMysql(), ($this->_getSelfMysql(),
't_user', 't_user',
$fields, $fields,
array( array(
'accountid' => $this->getAccountId() 'accountid' => $this->_getAccountId()
) )
); );
if (empty($row)) { if (empty($row)) {
phpcommon\sendError(500, '服务器内部错误'); phpcommon\sendError(500, '服务器内部错误');
error_log('getUserInfo error '. $this->getAccountId()); error_log('getUserInfo error '. $this->_getAccountId());
die(); die();
} }
return $row; return $row;
@ -104,15 +104,15 @@ class BaseAuthedController extends BaseController {
public function _getOrmUserInfo() public function _getOrmUserInfo()
{ {
$row = SqlHelper::ormSelectOne $row = SqlHelper::ormSelectOne
($this->getSelfMysql(), ($this->_getSelfMysql(),
't_user', 't_user',
array( array(
'accountid' => $this->getAccountId() 'accountid' => $this->_getAccountId()
) )
); );
if (empty($row)) { if (empty($row)) {
phpcommon\sendError(500, '服务器内部错误'); phpcommon\sendError(500, '服务器内部错误');
error_log('getUserInfo error '. $this->getAccountId()); error_log('getUserInfo error '. $this->_getAccountId());
die(); die();
} }
return $row; return $row;
@ -121,10 +121,10 @@ class BaseAuthedController extends BaseController {
public function _safeGetOrmUserInfo() public function _safeGetOrmUserInfo()
{ {
$row = SqlHelper::ormSelectOne $row = SqlHelper::ormSelectOne
($this->getSelfMysql(), ($this->_getSelfMysql(),
't_user', 't_user',
array( array(
'accountid' => $this->getAccountId() 'accountid' => $this->_getAccountId()
) )
); );
return $row ? $row : null; return $row ? $row : null;
@ -133,10 +133,10 @@ class BaseAuthedController extends BaseController {
public function _updateUserInfo($fieldsKv) public function _updateUserInfo($fieldsKv)
{ {
SqlHelper::update SqlHelper::update
($this->getSelfMysql(), ($this->_getSelfMysql(),
'user', 'user',
array( array(
'accountid' => $this->getAccountId() 'accountid' => $this->_getAccountId()
), ),
$fieldsKv $fieldsKv
); );
@ -154,7 +154,7 @@ class BaseAuthedController extends BaseController {
public function _getItem($itemId) public function _getItem($itemId)
{ {
$row = SqlHelper::selectOne $row = SqlHelper::selectOne
($this->getSelfMysql(), ($this->_getSelfMysql(),
'bag', 'bag',
array( array(
'id', 'id',
@ -162,7 +162,7 @@ class BaseAuthedController extends BaseController {
), ),
array( array(
'id' => $itemId, 'id' => $itemId,
'accountid' => $this->getAccountId() 'accountid' => $this->_getAccountId()
)); ));
if (empty($row)) { if (empty($row)) {
return null; return null;
@ -194,7 +194,7 @@ class BaseAuthedController extends BaseController {
default: default:
{ {
$row = SqlHelper::selectOne $row = SqlHelper::selectOne
($this->getSelfMysql(), ($this->_getSelfMysql(),
'bag', 'bag',
array( array(
'id', 'id',
@ -202,7 +202,7 @@ class BaseAuthedController extends BaseController {
), ),
array( array(
'id' => $itemId, 'id' => $itemId,
'accountid' => $this->getAccountId() 'accountid' => $this->_getAccountId()
)); ));
return $row ? $row['num'] : 0; return $row ? $row['num'] : 0;
} }
@ -227,19 +227,19 @@ class BaseAuthedController extends BaseController {
public function _addItem($items) public function _addItem($items)
{ {
foreach ($items as $item) { foreach ($items as $item) {
if ($this->isVirtualItem($item['item_id'])) { if ($this->_isVirtualItem($item['item_id'])) {
if ($item['item_id'] == $this->goldID) { if ($item['item_id'] == $this->goldID) {
$this->addGold($item['item_num']); $this->_addGold($item['item_num']);
} }
else if ($item['item_id'] == $this->lotteryID){ else if ($item['item_id'] == $this->lotteryID){
$this->addLottery($item['item_num']); $this->addLottery($item['item_num']);
} }
} else { } else {
SqlHelper::upsert SqlHelper::upsert
($this->getSelfMysql(), ($this->_getSelfMysql(),
't_bag', 't_bag',
array( array(
'accountid' => $this->getAccountId(), 'accountid' => $this->_getAccountId(),
'item_id' => $item['item_id'] 'item_id' => $item['item_id']
), ),
array( array(
@ -247,7 +247,7 @@ class BaseAuthedController extends BaseController {
'modifytime' => $this->_getNowTime() 'modifytime' => $this->_getNowTime()
), ),
array( array(
'accountid' => $this->getAccountId(), 'accountid' => $this->_getAccountId(),
'item_id' => $item['item_id'], 'item_id' => $item['item_id'],
'color_id' => 0, 'color_id' => 0,
'status' => 1, 'status' => 1,
@ -263,22 +263,22 @@ class BaseAuthedController extends BaseController {
public function _decItems($items) public function _decItems($items)
{ {
$this->decItem($items); $this->_decItem($items);
} }
public function _decItem($items) public function _decItem($items)
{ {
foreach ($items as $item) { foreach ($items as $item) {
if ($this->isVirtualItem($item['item_id'])) { if ($this->_isVirtualItem($item['item_id'])) {
// if ($item['item_id'] == VIRTUAL_ITEM_GOLD_ID) { // if ($item['item_id'] == VIRTUAL_ITEM_GOLD_ID) {
// $this->decGold($item['item_num']); // $this->_decGold($item['item_num']);
// } // }
} else { } else {
SqlHelper::update SqlHelper::update
($this->getSelfMysql(), ($this->_getSelfMysql(),
'bag', 'bag',
array( array(
'accountid' => $this->getAccountId(), 'accountid' => $this->_getAccountId(),
'id' => $item['item_id'] 'id' => $item['item_id']
), ),
array( array(
@ -296,8 +296,8 @@ class BaseAuthedController extends BaseController {
{ {
$tmpItemID = $item["item_id"]; $tmpItemID = $item["item_id"];
$beDeleteNum = $item['item_num']; $beDeleteNum = $item['item_num'];
$accountID = $this->getAccountId(); $accountID = $this->_getAccountId();
$conn = $this->getMysql($accountID); $conn = $this->_getMysql($accountID);
$sqlStr = "SELECT id,num FROM bag WHERE accountid=:accountid AND id=:itemId"; $sqlStr = "SELECT id,num FROM bag WHERE accountid=:accountid AND id=:itemId";
$row = $conn->execQuery($sqlStr,array(':accountid' => $accountID,':itemId' =>$tmpItemID)); $row = $conn->execQuery($sqlStr,array(':accountid' => $accountID,':itemId' =>$tmpItemID));
$code = 100; $code = 100;
@ -321,27 +321,27 @@ class BaseAuthedController extends BaseController {
{ {
SqlHelper::update SqlHelper::update
( (
$this->getSelfMysql(), $this->_getSelfMysql(),
'user', 'user',
array( array(
'accountid' => $this->getAccountId() 'accountid' => $this->_getAccountId()
), ),
array( array(
'coin_num' => function () use($decGold) { return "CASE coin_num WHEN coin_num < {$decGold} THEN 0 ELSE coin_num - {$decGold} END"; } '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, 0, $decGold);
// $this->incV(TN_CONSUME_GOLD, $this->getNowDaySeconds(), $decGold); // $this->incV(TN_CONSUME_GOLD, $this->_getNowDaySeconds(), $decGold);
} }
public function _addGold($addGold) public function _addGold($addGold)
{ {
SqlHelper::update SqlHelper::update
( (
$this->getSelfMysql(), $this->_getSelfMysql(),
'user', 'user',
array( array(
'accountid' => $this->getAccountId() 'accountid' => $this->_getAccountId()
), ),
array( array(
'coin_num' => function () use($addGold) { return "coin_num + {$addGold}"; } 'coin_num' => function () use($addGold) { return "coin_num + {$addGold}"; }
@ -353,7 +353,7 @@ class BaseAuthedController extends BaseController {
{ {
$row = SqlHelper::selectOne $row = SqlHelper::selectOne
( (
$this->getSelfMysql(), $this->_getSelfMysql(),
'gun_intensify', 'gun_intensify',
array( array(
'gun_type_id', 'gun_type_id',
@ -361,7 +361,7 @@ class BaseAuthedController extends BaseController {
'skill_lv' 'skill_lv'
), ),
array( array(
'accountid' => $this->getAccountId(), 'accountid' => $this->_getAccountId(),
'skill_id' => $skillId, 'skill_id' => $skillId,
'gun_type_id' => $skillTypeId 'gun_type_id' => $skillTypeId
) )
@ -371,13 +371,13 @@ class BaseAuthedController extends BaseController {
public function _hasEnoughItemsEx($items, &$lackItem) public function _hasEnoughItemsEx($items, &$lackItem)
{ {
$userInfo = $this->getUserInfo(array( $userInfo = $this->_getUserInfo(array(
'coin_num', 'coin_num',
'diamond_num', 'diamond_num',
'rmb_num' 'rmb_num'
)); ));
foreach ($items as $item) { foreach ($items as $item) {
$inventory = $this->getItemCount($item['item_id'], $userInfo); $inventory = $this->_getItemCount($item['item_id'], $userInfo);
if ($inventory < $item['item_num']) { if ($inventory < $item['item_num']) {
$lackItem = array( $lackItem = array(
'item_id' => $item['item_id'], 'item_id' => $item['item_id'],
@ -393,13 +393,13 @@ class BaseAuthedController extends BaseController {
public function _getUsingEquipId() public function _getUsingEquipId()
{ {
$row = SqlHelper::selectOne $row = SqlHelper::selectOne
($this->getSelfMysql(), ($this->_getSelfMysql(),
'equip', 'equip',
array( array(
'using_id', 'using_id',
), ),
array( array(
'accountid' => $this->getAccountId(), 'accountid' => $this->_getAccountId(),
) )
); );
return $row ? $row['using_id'] : 0; return $row ? $row['using_id'] : 0;
@ -407,14 +407,14 @@ class BaseAuthedController extends BaseController {
public function _redisSetAndExpire($pk, $key, $val, $time) public function _redisSetAndExpire($pk, $key, $val, $time)
{ {
$r = $this->getRedis($pk); $r = $this->_getRedis($pk);
$r->set($key, $val); $r->set($key, $val);
$r->pexpire($key, $time); $r->pexpire($key, $time);
} }
public function _redisGetJson($pk, $key) public function _redisGetJson($pk, $key)
{ {
$r = $this->getRedis($pk); $r = $this->_getRedis($pk);
$dataStr = $r->get($key); $dataStr = $r->get($key);
$result = null; $result = null;
if (!empty($dataStr)) { if (!empty($dataStr)) {

View File

@ -33,7 +33,7 @@ class BaseController {
public function _getTodayRemainSeconds() public function _getTodayRemainSeconds()
{ {
return max(0, $this->getNowDaySeconds() + 3600 * 24 - $this->_getNowTime()); return max(0, $this->_getNowDaySeconds() + 3600 * 24 - $this->_getNowTime());
} }
public function _rspErr($errcode, $errmsg) public function _rspErr($errcode, $errmsg)

View File

@ -12,7 +12,7 @@ class EquipController extends BaseAuthedController {
{ {
$account_id = $_REQUEST['account_id']; $account_id = $_REQUEST['account_id'];
$conn = $this->getMysql($account_id); $conn = $this->_getMysql($account_id);
$equip_list = array(); $equip_list = array();
$rows = $conn->execQuery('SELECT * FROM equip WHERE accountid=:account_id;', $rows = $conn->execQuery('SELECT * FROM equip WHERE accountid=:account_id;',
array( array(
@ -89,7 +89,7 @@ class EquipController extends BaseAuthedController {
public function speedUpTime() public function speedUpTime()
{ {
$account_id = $_REQUEST['account_id']; $account_id = $_REQUEST['account_id'];
$conn = $this->getMysql($account_id); $conn = $this->_getMysql($account_id);
$id = 0; $id = 0;
if (isset($_REQUEST['id'])) { if (isset($_REQUEST['id'])) {
$id = $_REQUEST['id']; $id = $_REQUEST['id'];
@ -111,7 +111,7 @@ class EquipController extends BaseAuthedController {
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个装备'); phpcommon\sendError(ERR_USER_BASE + 2, '没有这个装备');
return; return;
} }
$view_list = $this->getExplode($e['reduce_time']); $view_list = $this->_getExplode($e['reduce_time']);
$reduce_time = $view_list[$row['lv'] - 1][0]; $reduce_time = $view_list[$row['lv'] - 1][0];
$flag = 0; $flag = 0;
//error_log($e['reduce_time']); //error_log($e['reduce_time']);
@ -125,13 +125,13 @@ class EquipController extends BaseAuthedController {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return; return;
} }
$diamond_arr = $this->getExplode($e['diamond_cost']); $diamond_arr = $this->_getExplode($e['diamond_cost']);
$diamond_cost = $diamond_arr[$row['lv'] - 1][0]; $diamond_cost = $diamond_arr[$row['lv'] - 1][0];
if ($rowUser['rmb_num'] < $diamond_cost) { if ($rowUser['rmb_num'] < $diamond_cost) {
phpcommon\sendError(ERR_USER_BASE + 3, '钻石不足'); phpcommon\sendError(ERR_USER_BASE + 3, '钻石不足');
return; return;
} }
$diamond_list = $this->getExplode($e['diamond_time']); $diamond_list = $this->_getExplode($e['diamond_time']);
$diamond_time = $diamond_list[$row['lv'] - 1][0]; $diamond_time = $diamond_list[$row['lv'] - 1][0];
$sub_time = $row['sub_time'] - floor($row['sub_time'] * $diamond_time * 0.01); $sub_time = $row['sub_time'] - floor($row['sub_time'] * $diamond_time * 0.01);
$retUser = $conn->execScript('UPDATE user SET rmb_num=:rmb_num, modify_time=:modify_time ' . $retUser = $conn->execScript('UPDATE user SET rmb_num=:rmb_num, modify_time=:modify_time ' .
@ -182,7 +182,7 @@ class EquipController extends BaseAuthedController {
{ {
$account_id = $_REQUEST['account_id']; $account_id = $_REQUEST['account_id'];
$equip_id = $_REQUEST['id']; $equip_id = $_REQUEST['id'];
$conn = $this->getMysql($account_id); $conn = $this->_getMysql($account_id);
$row = $conn->execQueryOne('SELECT * FROM equip WHERE accountid=:account_id AND id=:id;', $row = $conn->execQueryOne('SELECT * FROM equip WHERE accountid=:account_id AND id=:id;',
array( array(
':account_id' => $account_id, ':account_id' => $account_id,
@ -220,7 +220,7 @@ class EquipController extends BaseAuthedController {
{ {
$account_id = $_REQUEST['account_id']; $account_id = $_REQUEST['account_id'];
$equip_id = $_REQUEST['id']; $equip_id = $_REQUEST['id'];
$conn = $this->getMysql($account_id); $conn = $this->_getMysql($account_id);
$e = mt\Equip::getOldEquip($equip_id); $e = mt\Equip::getOldEquip($equip_id);
if (!$e) { if (!$e) {
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个装备'); phpcommon\sendError(ERR_USER_BASE + 2, '没有这个装备');
@ -354,7 +354,7 @@ class EquipController extends BaseAuthedController {
protected function subCoin($item_id, $item_num, $account_id) protected function subCoin($item_id, $item_num, $account_id)
{ {
$conn = $this->getMysql($account_id); $conn = $this->_getMysql($account_id);
$row = $conn->execQueryOne('SELECT coin_num, rmb_num FROM user WHERE accountid=:account_id;', $row = $conn->execQueryOne('SELECT coin_num, rmb_num FROM user WHERE accountid=:account_id;',
array( array(
':account_id' => $account_id, ':account_id' => $account_id,
@ -423,7 +423,7 @@ class EquipController extends BaseAuthedController {
{ {
$account_id = $_REQUEST['account_id']; $account_id = $_REQUEST['account_id'];
$equip_id = $_REQUEST['id']; $equip_id = $_REQUEST['id'];
$conn = $this->getMysql($account_id); $conn = $this->_getMysql($account_id);
$row = $conn->execQueryOne('SELECT id, using_id, lv, exp FROM equip WHERE accountid=:account_id AND id=:id;', $row = $conn->execQueryOne('SELECT id, using_id, lv, exp FROM equip WHERE accountid=:account_id AND id=:id;',
array( array(
':account_id' => $account_id, ':account_id' => $account_id,
@ -488,7 +488,7 @@ class EquipController extends BaseAuthedController {
} }
$active_time = phpcommon\getNowTime(); $active_time = phpcommon\getNowTime();
$sub_list = $this->getExplode($e['equip_upgradetime']); $sub_list = $this->_getExplode($e['equip_upgradetime']);
$sub_time = $sub_list[$lv][0]; $sub_time = $sub_list[$lv][0];
if ($sub_time == 0) { if ($sub_time == 0) {
$active_time = 0; $active_time = 0;
@ -526,7 +526,7 @@ class EquipController extends BaseAuthedController {
protected function checkcoin($id, $num, $account_id) protected function checkcoin($id, $num, $account_id)
{ {
$conn = $this->getMysql($account_id); $conn = $this->_getMysql($account_id);
$row = $conn->execQueryOne('SELECT coin_num, rmb_num FROM user WHERE accountid=:account_id;', $row = $conn->execQueryOne('SELECT coin_num, rmb_num FROM user WHERE accountid=:account_id;',
array( array(
':account_id' => $account_id, ':account_id' => $account_id,
@ -576,7 +576,7 @@ class EquipController extends BaseAuthedController {
public function unlockEquip() public function unlockEquip()
{ {
$account_id = $_REQUEST['account_id']; $account_id = $_REQUEST['account_id'];
$conn = $this->getMysql($account_id); $conn = $this->_getMysql($account_id);
$id = $_REQUEST['id']; $id = $_REQUEST['id'];
$row = $conn->execQueryOne('SELECT num FROM bag WHERE accountid=:account_id AND id=:id;', $row = $conn->execQueryOne('SELECT num FROM bag WHERE accountid=:account_id AND id=:id;',
array( array(

View File

@ -193,7 +193,7 @@ class FriendController extends BaseAuthedController {
public function createRoleInfo() public function createRoleInfo()
{ {
$account_id = $_REQUEST['account_id']; $account_id = $_REQUEST['account_id'];
$conn = $this->getMysql($account_id); $conn = $this->_getMysql($account_id);
$user_name = $_REQUEST['user_name']; $user_name = $_REQUEST['user_name'];
$avatar_url = $_REQUEST['avatar_url']; $avatar_url = $_REQUEST['avatar_url'];
$sex = $_REQUEST['sex']; $sex = $_REQUEST['sex'];
@ -233,7 +233,7 @@ class FriendController extends BaseAuthedController {
protected function updateRoleInfo($account_id, $user_name, $avatar_url, $sex) protected function updateRoleInfo($account_id, $user_name, $avatar_url, $sex)
{ {
$conn = $this->getMysql($account_id); $conn = $this->_getMysql($account_id);
$ret = $conn->execScript('UPDATE user SET user_name=:user_name, avatar_url=:avatar_url, modify_time=:modify_time, create_user=1, sex=:sex ' . $ret = $conn->execScript('UPDATE user SET user_name=:user_name, avatar_url=:avatar_url, modify_time=:modify_time, create_user=1, sex=:sex ' .
' WHERE accountid=:accountid;', ' WHERE accountid=:accountid;',
array( array(

View File

@ -10,7 +10,7 @@ class GunController extends BaseAuthedController {
{ {
$data = array(); $data = array();
phpcommon\SqlHelper::select phpcommon\SqlHelper::select
($this->getSelfMysql(), ($this->_getSelfMysql(),
'gun_intensify', 'gun_intensify',
array( array(
'gun_type_id', 'gun_type_id',
@ -18,7 +18,7 @@ class GunController extends BaseAuthedController {
'skill_lv' 'skill_lv'
), ),
array( array(
'accountid' => $this->getAccountId() 'accountid' => $this->_getAccountId()
), ),
function ($row) use(&$data) { function ($row) use(&$data) {
array_push($data, array( array_push($data, array(
@ -28,7 +28,7 @@ class GunController extends BaseAuthedController {
)); ));
} }
); );
$this->rspDataOld($data); $this->_rspDataOld($data);
} }
public function skillLvUp() public function skillLvUp()
@ -37,45 +37,45 @@ class GunController extends BaseAuthedController {
$gunTypeId = $_REQUEST['skill_type_id']; $gunTypeId = $_REQUEST['skill_type_id'];
$talentLvMeta = mt\GunTalentLv::get($talentId); $talentLvMeta = mt\GunTalentLv::get($talentId);
if (!$talentLvMeta) { if (!$talentLvMeta) {
$this->rspErr(99, "技能不存在"); $this->_rspErr(99, "技能不存在");
return; return;
} }
$gunTalentMeta = mt\GunTalentLv::get($gunTypeId); $gunTalentMeta = mt\GunTalentLv::get($gunTypeId);
if (!$gunTalentMeta) { if (!$gunTalentMeta) {
$this->rspErr(1, "参数错误"); $this->_rspErr(1, "参数错误");
return; return;
} }
if (!mt\GunTalentLv::isValidTalent($gunTypeId, $talentId)) { if (!mt\GunTalentLv::isValidTalent($gunTypeId, $talentId)) {
$this->rspErr(1, "参数错误"); $this->_rspErr(1, "参数错误");
return; return;
} }
$talentLv = $this->getTalentLv($talentId, $gunTypeId); $talentLv = $this->_getTalentLv($talentId, $gunTypeId);
if (mt\GunTalentLv::isFullLv($talentLvMeta, $talentLv)) { if (mt\GunTalentLv::isFullLv($talentLvMeta, $talentLv)) {
$this->rspErr(98, "已满级"); $this->_rspErr(98, "已满级");
return; return;
} }
$nextLvMeta = mt\GunTalentLv::getByLv($meta, $talentLv + 1); $nextLvMeta = mt\GunTalentLv::getByLv($meta, $talentLv + 1);
if (!$nextLvMeta) { if (!$nextLvMeta) {
$this->rspErr(2, "配置表错误"); $this->_rspErr(2, "配置表错误");
return; return;
} }
$costList = mt\GunTalentLv::getCostList($nextLvMeta); $costList = mt\GunTalentLv::getCostList($nextLvMeta);
$lackItem = array(); $lackItem = array();
if (!$this->hasEnoughItemsEx($costItem, $lackItem)) { if (!$this->_hasEnoughItemsEx($costItem, $lackItem)) {
switch ($lackItem['item_id']) { switch ($lackItem['item_id']) {
case V_ITEM_GOLD: case V_ITEM_GOLD:
{ {
$this->rspErr(97, "金币不足"); $this->_rspErr(97, "金币不足");
} }
break; break;
case V_ITEM_DIAMOND: case V_ITEM_DIAMOND:
{ {
$this->rspErr(96, "钻石不足"); $this->_rspErr(96, "钻石不足");
} }
break; break;
default: default:
{ {
$this->rspErr(95, "道具不足"); $this->_rspErr(95, "道具不足");
} }
break; break;
} }
@ -83,10 +83,10 @@ class GunController extends BaseAuthedController {
} }
++$talentLv; ++$talentLv;
phpcommon\SqlHelper::upsert phpcommon\SqlHelper::upsert
($this->getSelfMysql(), ($this->_getSelfMysql(),
'gun_intensify', 'gun_intensify',
array( array(
'accountid' => $this->getAccountId(), 'accountid' => $this->_getAccountId(),
'gun_type_id' => $gunTypeId, 'gun_type_id' => $gunTypeId,
'skill_id' => $talentId 'skill_id' => $talentId
), ),
@ -95,7 +95,7 @@ class GunController extends BaseAuthedController {
'modifytime' => $this->_getNowTime() 'modifytime' => $this->_getNowTime()
), ),
array( array(
'accountid' => $this->getAccountId(), 'accountid' => $this->_getAccountId(),
'gun_type_id' => $gunTypeId, 'gun_type_id' => $gunTypeId,
'skill_id' => $talentId, 'skill_id' => $talentId,
'skill_lv' => $talentLv, 'skill_lv' => $talentLv,
@ -103,7 +103,7 @@ class GunController extends BaseAuthedController {
'modifytime' => $this->_getNowTime() 'modifytime' => $this->_getNowTime()
) )
); );
$this->rspRawData(array( $this->_rspRawData(array(
'errcode' => 100, 'errcode' => 100,
'errmsg' => '', 'errmsg' => '',
'data' => array( 'data' => array(
@ -118,14 +118,14 @@ class GunController extends BaseAuthedController {
{ {
$data = array(); $data = array();
phpcommon\SqlHelper::select phpcommon\SqlHelper::select
($this->getSelfMysql(), ($this->_getSelfMysql(),
'gun', 'gun',
array( array(
'gun_id', 'gun_id',
'skin_id' 'skin_id'
), ),
array( array(
'accountid' => $this->getAccountId() 'accountid' => $this->_getAccountId()
), ),
function ($row) use(&$data) { function ($row) use(&$data) {
array_push($data, array( array_push($data, array(
@ -135,14 +135,14 @@ class GunController extends BaseAuthedController {
} }
); );
phpcommon\SqlHelper::select phpcommon\SqlHelper::select
($this->getSelfMysql(), ($this->_getSelfMysql(),
'gun_skin', 'gun_skin',
array( array(
'gun_id', 'gun_id',
'skin_id' 'skin_id'
), ),
array( array(
'accountid' => $this->getAccountId() 'accountid' => $this->_getAccountId()
), ),
function ($row) use(&$data) { function ($row) use(&$data) {
array_push($data, array( array_push($data, array(
@ -151,7 +151,7 @@ class GunController extends BaseAuthedController {
)); ));
} }
); );
$this->rspRawData(array( $this->_rspRawData(array(
'errcode' => 100, 'errcode' => 100,
'errmsg' => '', 'errmsg' => '',
'data' => $data 'data' => $data
@ -164,16 +164,16 @@ class GunController extends BaseAuthedController {
$skinId = $_REQUEST['skin_id']; $skinId = $_REQUEST['skin_id'];
phpcommon\SqlHelper::upsert phpcommon\SqlHelper::upsert
($this->getSelfMysql(), ($this->_getSelfMysql(),
'gun', 'gun',
array( array(
'accountid' => $this->getAccountId(), 'accountid' => $this->_getAccountId(),
'gun_id' => $gunId 'gun_id' => $gunId
), ),
array( array(
), ),
array( array(
'accountid' => $this->getAccountId(), 'accountid' => $this->_getAccountId(),
'gun_id' => $gunId, 'gun_id' => $gunId,
'skin_id' => $skinId, 'skin_id' => $skinId,
'trytime' => 0, 'trytime' => 0,
@ -181,7 +181,7 @@ class GunController extends BaseAuthedController {
'modifytime' => $this->_getNowTime() 'modifytime' => $this->_getNowTime()
) )
); );
$this->rspRawData(array( $this->_rspRawData(array(
'errcode' => 100, 'errcode' => 100,
'errmsg' => '', 'errmsg' => '',
'data' => array( 'data' => array(
@ -200,12 +200,12 @@ class GunController extends BaseAuthedController {
$shopMeta = mt\NewShop::getShopItemById(3); $shopMeta = mt\NewShop::getShopItemById(3);
if (!$shopMeta) { if (!$shopMeta) {
$this->rspErr(1, "参数错误"); $this->_rspErr(1, "参数错误");
return; return;
} }
$goodsInfo = mt\NewShop::getGoodsInfo($shopMeta, $goodsId); $goodsInfo = mt\NewShop::getGoodsInfo($shopMeta, $goodsId);
if (!$goodsInfo) { if (!$goodsInfo) {
$this->rspErr(1, "参数错误"); $this->_rspErr(1, "参数错误");
return; return;
} }
$costList = array( $costList = array(
@ -215,21 +215,21 @@ class GunController extends BaseAuthedController {
) )
); );
$lackItem = array(); $lackItem = array();
if (!$this->hasEnoughItemsEx($costItem, $lackItem)) { if (!$this->_hasEnoughItemsEx($costItem, $lackItem)) {
switch ($lackItem['item_id']) { switch ($lackItem['item_id']) {
case V_ITEM_GOLD: case V_ITEM_GOLD:
{ {
$this->rspErr(88, "金币不足"); $this->_rspErr(88, "金币不足");
} }
break; break;
case V_ITEM_DIAMOND: case V_ITEM_DIAMOND:
{ {
$this->rspErr(87, "钻石不足"); $this->_rspErr(87, "钻石不足");
} }
break; break;
default: default:
{ {
$this->rspErr(86, "道具不足"); $this->_rspErr(86, "道具不足");
} }
break; break;
} }
@ -237,10 +237,10 @@ class GunController extends BaseAuthedController {
} }
{ {
phpcommon\SqlHelper::upsert phpcommon\SqlHelper::upsert
($this->getSelfMysql(), ($this->_getSelfMysql(),
'gun_skin', 'gun_skin',
array( array(
'accountid' => $this->getAccountId(), 'accountid' => $this->_getAccountId(),
'gun_id' => $gunId, 'gun_id' => $gunId,
'skin_id' => $skinId 'skin_id' => $skinId
), ),
@ -249,7 +249,7 @@ class GunController extends BaseAuthedController {
'modifytime' => $this->_getNowTime() 'modifytime' => $this->_getNowTime()
), ),
array( array(
'accountid' => $this->getAccountId(), 'accountid' => $this->_getAccountId(),
'gun_id' => $gunId, 'gun_id' => $gunId,
'skin_id' => $skinId, 'skin_id' => $skinId,
'trytime' => 0, 'trytime' => 0,
@ -259,10 +259,10 @@ class GunController extends BaseAuthedController {
); );
phpcommon\SqlHelper::upsert phpcommon\SqlHelper::upsert
($this->getSelfMysql(), ($this->_getSelfMysql(),
'gun', 'gun',
array( array(
'accountid' => $this->getAccountId(), 'accountid' => $this->_getAccountId(),
'gun_id' => $gunId 'gun_id' => $gunId
), ),
array( array(
@ -270,7 +270,7 @@ class GunController extends BaseAuthedController {
'modifytime' => $this->_getNowTime() 'modifytime' => $this->_getNowTime()
), ),
array( array(
'accountid' => $this->getAccountId(), 'accountid' => $this->_getAccountId(),
'gun_id' => $gunId, 'gun_id' => $gunId,
'skin_id' => $skinId, 'skin_id' => $skinId,
'trytime' => 0, 'trytime' => 0,
@ -279,7 +279,7 @@ class GunController extends BaseAuthedController {
) )
); );
} }
$this->rspRawData(array( $this->_rspRawData(array(
'errcode' => 100, 'errcode' => 100,
'errmsg' => '', 'errmsg' => '',
'data' => array( 'data' => array(

View File

@ -17,16 +17,16 @@ class HeroController extends BaseAuthedController {
{ {
$heroList = array(); $heroList = array();
SqlHelper::ormSelect( SqlHelper::ormSelect(
$this->getSelfMysql(), $this->_getSelfMysql(),
't_hero', 't_hero',
array( array(
'accountid' => $this->getAccountId() 'accountid' => $this->_getAccountId()
), ),
function ($row) use(&$heroList) { function ($row) use(&$heroList) {
array_push($heroList, Hero::toDto($row)); array_push($heroList, Hero::toDto($row));
} }
); );
$this->rspData(array( $this->_rspData(array(
'hero_list' => $heroList 'hero_list' => $heroList
)); ));
} }
@ -35,16 +35,16 @@ class HeroController extends BaseAuthedController {
{ {
$skinList = array(); $skinList = array();
SqlHelper::ormSelect( SqlHelper::ormSelect(
$this->getSelfMysql(), $this->_getSelfMysql(),
't_hero_skin', 't_hero_skin',
array( array(
'accountid' => $this->getAccountId() 'accountid' => $this->_getAccountId()
), ),
function ($row) use(&$skinList) { function ($row) use(&$skinList) {
array_push($skinList, HeroSkin::toDto($row)); array_push($skinList, HeroSkin::toDto($row));
} }
); );
$this->rspData(array( $this->_rspData(array(
'skin_list' => $skinList 'skin_list' => $skinList
)); ));
} }
@ -55,25 +55,25 @@ class HeroController extends BaseAuthedController {
$buyType = getReqVal('buy_type', 0); $buyType = getReqVal('buy_type', 0);
$heroMeta = mt\Hero::get($heroId); $heroMeta = mt\Hero::get($heroId);
if ($heroMeta) { if ($heroMeta) {
$this->rspErr(1, 'hero_id参数错误'); $this->_rspErr(1, 'hero_id参数错误');
return; return;
} }
if (empty($heroMeta['itemid'])) { if (empty($heroMeta['itemid'])) {
$this->rspErr(2, 'hero.item_id配置错误'); $this->_rspErr(2, 'hero.item_id配置错误');
return; return;
} }
if (!in_array($buyType, array(0, 1))) { if (!in_array($buyType, array(0, 1))) {
$this->rspErr(1, 'buy_type参数错误'); $this->_rspErr(1, 'buy_type参数错误');
return; return;
} }
$shopMeta = mt\Shop::get(mt\Shop::HERO_SHOP_ID); $shopMeta = mt\Shop::get(mt\Shop::HERO_SHOP_ID);
if (!$shopMeta) { if (!$shopMeta) {
$this->rspErr(2, '配置表错误'); $this->_rspErr(2, '配置表错误');
return; return;
} }
$goodsInfo = mt\Shop::getGoodsInfo($shopMeta, $heroMeta['itemid']); $goodsInfo = mt\Shop::getGoodsInfo($shopMeta, $heroMeta['itemid']);
if (empty($goodsInfo)) { if (empty($goodsInfo)) {
$this->rspErr(2, '配置表错误'); $this->_rspErr(2, '配置表错误');
return; return;
} }
$costItems = array( $costItems = array(
@ -81,11 +81,11 @@ class HeroController extends BaseAuthedController {
'item_num' => $goodsInfo['costItemNum'], 'item_num' => $goodsInfo['costItemNum'],
); );
$lackItem = null; $lackItem = null;
if (!$this->hasEnoughItemsEx($costItems, $lackItem)) { if (!$this->_hasEnoughItemsEx($costItems, $lackItem)) {
$this->rspErr(3, '道具不足'); $this->_rspErr(3, '道具不足');
return; return;
} }
$this->decItems($costItems); $this->_decItems($costItems);
Hero::addHero($heroMeta); Hero::addHero($heroMeta);
} }
@ -94,11 +94,11 @@ class HeroController extends BaseAuthedController {
$skinId = getReqVal('skin_id', 0); $skinId = getReqVal('skin_id', 0);
$skinMeta = mt\Item::get($skinId); $skinMeta = mt\Item::get($skinId);
if (!$skinMeta) { if (!$skinMeta) {
$this->rspErr(1, 'skin_id参数错误'); $this->_rspErr(1, 'skin_id参数错误');
return; return;
} }
if (!mt\Item::isType($skinMeta, mt\Item::SKIN_TYPE)){ if (!mt\Item::isType($skinMeta, mt\Item::SKIN_TYPE)){
$this->rspErr(1, 'skin_id参数错误'); $this->_rspErr(1, 'skin_id参数错误');
return; return;
} }
HeroSkin::addSkin($skinId); HeroSkin::addSkin($skinId);
@ -111,15 +111,15 @@ class HeroController extends BaseAuthedController {
$heroDb = Hero::find($heroId); $heroDb = Hero::find($heroId);
$heroSkinDb = Hero::find($skinId); $heroSkinDb = Hero::find($skinId);
if (!$heroDb) { if (!$heroDb) {
$this->rspErr(1, '你还没这个英雄'); $this->_rspErr(1, '你还没这个英雄');
return; return;
} }
if (!$heroSkinDb) { if (!$heroSkinDb) {
$this->rspErr(2, '你还没这个皮肤'); $this->_rspErr(2, '你还没这个皮肤');
return; return;
} }
Hero::takeonSkin($heroId, $skinId); Hero::takeonSkin($heroId, $skinId);
$this->rspOk(); $this->_rspOk();
} }
public function upgradeSkill() public function upgradeSkill()
@ -128,15 +128,15 @@ class HeroController extends BaseAuthedController {
$skillIdx = getReqVal('skill_idx', 0); $skillIdx = getReqVal('skill_idx', 0);
$heroDb = Hero::find($heroId); $heroDb = Hero::find($heroId);
if (!$heroDb) { if (!$heroDb) {
$this->rspErr(1, '你还没这个英雄'); $this->_rspErr(1, '你还没这个英雄');
return; return;
} }
if (!in_array($skillIdx, array(0, 1))) { if (!in_array($skillIdx, array(0, 1))) {
$this->rspErr(1, 'skill_idx参数必须为0-1'); $this->_rspErr(1, 'skill_idx参数必须为0-1');
return; return;
} }
Hero::upgradeSkill($heroId, $skillIdx); Hero::upgradeSkill($heroId, $skillIdx);
$this->rspOk(); $this->_rspOk();
} }
public function useYokeItem() public function useYokeItem()
@ -144,7 +144,7 @@ class HeroController extends BaseAuthedController {
$heroId = getReqVal('hero_id', 0); $heroId = getReqVal('hero_id', 0);
$itemId = getReqVal('item_id', 0); $itemId = getReqVal('item_id', 0);
$itemNum = getReqVal('item_num', 0); $itemNum = getReqVal('item_num', 0);
$this->rspOk(); $this->_rspOk();
} }
} }

View File

@ -9,7 +9,7 @@ class RankController extends BaseAuthedController {
public function rankInfo() public function rankInfo()
{ {
$account_id = $_REQUEST['account_id']; $account_id = $_REQUEST['account_id'];
$conn = $this->getMysql($account_id); $conn = $this->_getMysql($account_id);
$kill_list = array(); $kill_list = array();
$kill_rank = 0; $kill_rank = 0;
$win_list = array(); $win_list = array();
@ -76,7 +76,7 @@ class RankController extends BaseAuthedController {
} }
ini_set('memory_limit','3072M'); ini_set('memory_limit','3072M');
//击杀榜 //击杀榜
$r = $this->getRedis(''); $r = $this->_getRedis('');
//胜场榜 //胜场榜
$channel = phpcommon\extractChannel($account_id); $channel = phpcommon\extractChannel($account_id);
$win_rank_db = $r->get("game2005api:win_rank_" . $channel); $win_rank_db = $r->get("game2005api:win_rank_" . $channel);
@ -254,7 +254,7 @@ class RankController extends BaseAuthedController {
{ {
$account_id = $_REQUEST['account_id']; $account_id = $_REQUEST['account_id'];
$conn = $this->getMysql($account_id); $conn = $this->_getMysql($account_id);
$killResultArr = array(); $killResultArr = array();

View File

@ -30,7 +30,7 @@ class ShopController extends BaseAuthedController {
} }
protected function readRecActDB($account_id) { protected function readRecActDB($account_id) {
$conn = $this->getMysql($account_id); $conn = $this->_getMysql($account_id);
$row = $conn->execQueryOne('SELECT blobdata FROM recharge_activity WHERE accountid=:accountid;', $row = $conn->execQueryOne('SELECT blobdata FROM recharge_activity WHERE accountid=:accountid;',
array( array(
':accountid' => $account_id ':accountid' => $account_id
@ -45,7 +45,7 @@ class ShopController extends BaseAuthedController {
} }
protected function saveRecActDB($account_id, $rec_db) { protected function saveRecActDB($account_id, $rec_db) {
$conn = $this->getMysql($account_id); $conn = $this->_getMysql($account_id);
$row = $conn->execQueryOne('SELECT accountid FROM recharge_activity WHERE accountid=:accountid;', $row = $conn->execQueryOne('SELECT accountid FROM recharge_activity WHERE accountid=:accountid;',
array( array(
':accountid' => $account_id ':accountid' => $account_id
@ -77,7 +77,7 @@ class ShopController extends BaseAuthedController {
} }
protected function readShopDB($account_id) { protected function readShopDB($account_id) {
$conn = $this->getMysql($account_id); $conn = $this->_getMysql($account_id);
$row = $conn->execQueryOne('SELECT blobdata FROM shop_data WHERE accountid=:accountid;', $row = $conn->execQueryOne('SELECT blobdata FROM shop_data WHERE accountid=:accountid;',
array( array(
':accountid' => $account_id ':accountid' => $account_id
@ -92,7 +92,7 @@ class ShopController extends BaseAuthedController {
} }
protected function saveShopDB($account_id, $shop_db) { protected function saveShopDB($account_id, $shop_db) {
$conn = $this->getMysql($account_id); $conn = $this->_getMysql($account_id);
$beginTick = phpcommon\getTickCount(); $beginTick = phpcommon\getTickCount();
$row = $conn->execQueryOne('SELECT accountid FROM shop_data WHERE accountid=:accountid;', $row = $conn->execQueryOne('SELECT accountid FROM shop_data WHERE accountid=:accountid;',
array( array(
@ -129,7 +129,7 @@ class ShopController extends BaseAuthedController {
{ {
$account_id = $_REQUEST['account_id']; $account_id = $_REQUEST['account_id'];
$conn = $this->getMysql($account_id); $conn = $this->_getMysql($account_id);
$new_shop_uuid = 'game2005api_shop_uuid_new:' . $_REQUEST['account_id']; $new_shop_uuid = 'game2005api_shop_uuid_new:' . $_REQUEST['account_id'];
//商店信息 //商店信息
$this->getNewShopInfo($new_shop_uuid, $account_id); $this->getNewShopInfo($new_shop_uuid, $account_id);
@ -342,7 +342,7 @@ class ShopController extends BaseAuthedController {
protected function flushNormalShop($account_id, $id, $type) protected function flushNormalShop($account_id, $id, $type)
{ {
$conn = $this->getMysql($account_id); $conn = $this->_getMysql($account_id);
$user_db = $this->readShopDB($account_id); $user_db = $this->readShopDB($account_id);
if (empty($user_db) || !$user_db) { if (empty($user_db) || !$user_db) {
phpcommon\sendError(ERR_USER_BASE + 2,'没有这个商品'); phpcommon\sendError(ERR_USER_BASE + 2,'没有这个商品');
@ -383,7 +383,7 @@ class ShopController extends BaseAuthedController {
protected function flushRecShop($account_id, $id) protected function flushRecShop($account_id, $id)
{ {
$conn = $this->getMysql($account_id); $conn = $this->_getMysql($account_id);
$user_db = $this->readRecActDB($account_id); $user_db = $this->readRecActDB($account_id);
if (!$user_db || empty($user_db)) { if (!$user_db || empty($user_db)) {
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
@ -525,9 +525,9 @@ class ShopController extends BaseAuthedController {
phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励'); phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励');
die(); die();
} }
$item_id_array = $this->getExplode($d['item_id']); $item_id_array = $this->_getExplode($d['item_id']);
$item_num_array = $this->getExplode($d['num']); $item_num_array = $this->_getExplode($d['num']);
$weight_array = $this->getExplode($d['weight']); $weight_array = $this->_getExplode($d['weight']);
if ($d['type'] == 2) { if ($d['type'] == 2) {
$weight_sum = 0; $weight_sum = 0;
$keys = 0; $keys = 0;
@ -723,7 +723,7 @@ class ShopController extends BaseAuthedController {
$id = $_REQUEST['id']; $id = $_REQUEST['id'];
$type = $_REQUEST['type']; $type = $_REQUEST['type'];
$num = $_REQUEST['num']; $num = $_REQUEST['num'];
$conn = $this->getMysql($account_id); $conn = $this->_getMysql($account_id);
$i = mt\Item::getOldItem($id); $i = mt\Item::getOldItem($id);
$price = 0; $price = 0;
if ($i['shop_type'] == 1) { if ($i['shop_type'] == 1) {
@ -796,7 +796,7 @@ class ShopController extends BaseAuthedController {
protected function subCoin($coin_num, $account_id, $tips, $isview) protected function subCoin($coin_num, $account_id, $tips, $isview)
{ {
$conn = $this->getMysql($account_id); $conn = $this->_getMysql($account_id);
$rowCoin = $conn->execQueryOne('SELECT coin_num, guildcoin_num, shop_view_times, first_day_ad, rmb_num FROM user WHERE accountid=:accountid;', $rowCoin = $conn->execQueryOne('SELECT coin_num, guildcoin_num, shop_view_times, first_day_ad, rmb_num FROM user WHERE accountid=:accountid;',
array( array(
':accountid' => $account_id ':accountid' => $account_id

View File

@ -45,7 +45,7 @@ class TeamController extends BaseAuthedController {
$hiFrameID = $_REQUEST['hiFrameID']; $hiFrameID = $_REQUEST['hiFrameID'];
} }
$account_id = $_REQUEST['account_id']; $account_id = $_REQUEST['account_id'];
$conn = $this->getMysql($account_id); $conn = $this->_getMysql($account_id);
$row = $conn->execQueryOne('SELECT game_times, win_times, kills, create_time FROM user WHERE accountid=:accountid;', $row = $conn->execQueryOne('SELECT game_times, win_times, kills, create_time FROM user WHERE accountid=:accountid;',
array( array(
'accountid' => $account_id, 'accountid' => $account_id,
@ -76,7 +76,7 @@ class TeamController extends BaseAuthedController {
) )
)); ));
$r = $this->getRedis($team_uuid); $r = $this->_getRedis($team_uuid);
$r -> set(TEAMID_KEY . $team_uuid, json_encode($team_db)); $r -> set(TEAMID_KEY . $team_uuid, json_encode($team_db));
$r -> pexpire(TEAMID_KEY . $team_uuid, 1000*600); $r -> pexpire(TEAMID_KEY . $team_uuid, 1000*600);
@ -92,7 +92,7 @@ class TeamController extends BaseAuthedController {
return; return;
} }
$team_uuid = $_REQUEST['team_uuid']; $team_uuid = $_REQUEST['team_uuid'];
$r = $this->getRedis($team_uuid); $r = $this->_getRedis($team_uuid);
$accountid = $_REQUEST['account_id']; $accountid = $_REQUEST['account_id'];
@ -119,7 +119,7 @@ class TeamController extends BaseAuthedController {
return; return;
} }
$team_uuid = $_REQUEST['team_uuid']; $team_uuid = $_REQUEST['team_uuid'];
$r = $this->getRedis($team_uuid); $r = $this->_getRedis($team_uuid);
$accountid = $_REQUEST['account_id']; $accountid = $_REQUEST['account_id'];
@ -168,7 +168,7 @@ class TeamController extends BaseAuthedController {
return; return;
} }
$team_uuid = $_REQUEST['team_uuid']; $team_uuid = $_REQUEST['team_uuid'];
$r = $this->getRedis($team_uuid); $r = $this->_getRedis($team_uuid);
$accountid = $_REQUEST['account_id']; $accountid = $_REQUEST['account_id'];
@ -215,7 +215,7 @@ class TeamController extends BaseAuthedController {
} }
$team_uuid = $_REQUEST['team_uuid']; $team_uuid = $_REQUEST['team_uuid'];
$r = $this->getRedis($team_uuid); $r = $this->_getRedis($team_uuid);
$user_db_str = $r->get(TEAMID_KEY.$team_uuid); $user_db_str = $r->get(TEAMID_KEY.$team_uuid);
if (empty($user_db_str)) { if (empty($user_db_str)) {
@ -263,7 +263,7 @@ class TeamController extends BaseAuthedController {
} }
$team_uuid = $_REQUEST['team_uuid']; $team_uuid = $_REQUEST['team_uuid'];
$r = $this->getRedis($team_uuid); $r = $this->_getRedis($team_uuid);
$user_db_str = $r->get(TEAMID_KEY.$team_uuid); $user_db_str = $r->get(TEAMID_KEY.$team_uuid);
if (empty($user_db_str)) { if (empty($user_db_str)) {
@ -300,7 +300,7 @@ class TeamController extends BaseAuthedController {
} }
$team_uuid = $_REQUEST['team_uuid']; $team_uuid = $_REQUEST['team_uuid'];
$r = $this->getRedis($team_uuid); $r = $this->_getRedis($team_uuid);
$user_db_str = $r->get(TEAMID_KEY.$team_uuid); $user_db_str = $r->get(TEAMID_KEY.$team_uuid);
if (empty($user_db_str)) { if (empty($user_db_str)) {
@ -351,7 +351,7 @@ class TeamController extends BaseAuthedController {
$hiFrameID = $_REQUEST['hiFrameID']; $hiFrameID = $_REQUEST['hiFrameID'];
} }
$accountid = $_REQUEST['account_id']; $accountid = $_REQUEST['account_id'];
$conn = $this->getMysql($accountid); $conn = $this->_getMysql($accountid);
$row = $conn->execQueryOne('SELECT game_times, win_times, kills, create_time FROM user WHERE accountid=:accountid;', $row = $conn->execQueryOne('SELECT game_times, win_times, kills, create_time FROM user WHERE accountid=:accountid;',
array( array(
'accountid' => $accountid, 'accountid' => $accountid,
@ -389,7 +389,7 @@ class TeamController extends BaseAuthedController {
return; return;
} }
$team_uuid = $_REQUEST['team_uuid']; $team_uuid = $_REQUEST['team_uuid'];
$r = $this->getRedis($team_uuid); $r = $this->_getRedis($team_uuid);
if (!$r) { if (!$r) {
echo 'is null'; echo 'is null';
} else { } else {
@ -434,7 +434,7 @@ class TeamController extends BaseAuthedController {
return; return;
} }
$team_uuid = $_REQUEST['team_uuid']; $team_uuid = $_REQUEST['team_uuid'];
$r = $this->getRedis($team_uuid); $r = $this->_getRedis($team_uuid);
$roomManager = $_REQUEST['roomManager']; $roomManager = $_REQUEST['roomManager'];
if (!$r) { if (!$r) {
@ -491,7 +491,7 @@ class TeamController extends BaseAuthedController {
return; return;
} }
$team_uuid = $_REQUEST['team_uuid']; $team_uuid = $_REQUEST['team_uuid'];
$r = $this->getRedis($team_uuid); $r = $this->_getRedis($team_uuid);
if (!$r){ if (!$r){
echo 'is null'; echo 'is null';
@ -533,7 +533,7 @@ class TeamController extends BaseAuthedController {
} }
$team_uuid = $_REQUEST['team_uuid']; $team_uuid = $_REQUEST['team_uuid'];
//error_log("剔除玩家==="); //error_log("剔除玩家===");
$r = $this->getRedis($team_uuid); $r = $this->_getRedis($team_uuid);
if (!$r) { if (!$r) {
echo 'is null'; echo 'is null';

View File

@ -29,15 +29,15 @@ class UserController extends BaseAuthedController {
$userName = '极乐玩家'; $userName = '极乐玩家';
$avatarUrl = '18003'; $avatarUrl = '18003';
$userInfo = $this->safeGetOrmUserInfo(); $userInfo = $this->_safeGetOrmUserInfo();
if (!$userInfo) { if (!$userInfo) {
$this->createNewUser($userName, $avatarUrl); $this->createNewUser($userName, $avatarUrl);
$userInfo = $this->getOrmUserInfo(); $userInfo = $this->_getOrmUserInfo();
} }
if (!$this->loginCheck($userInfo)) { if (!$this->loginCheck($userInfo)) {
$userInfo = $this->getOrmUserInfo(); $userInfo = $this->_getOrmUserInfo();
} }
$this->rspData(array( $this->_rspData(array(
'info' => User::show($userInfo) 'info' => User::show($userInfo)
)); ));
} }
@ -50,15 +50,15 @@ class UserController extends BaseAuthedController {
private function createNewUser($userName, $avatarUrl) private function createNewUser($userName, $avatarUrl)
{ {
SqlHelper::upsert SqlHelper::upsert
($this->getSelfMysql(), ($this->_getSelfMysql(),
't_user', 't_user',
array( array(
'accountid' => $this->getAccountId() 'accountid' => $this->_getAccountId()
), ),
array( array(
), ),
array( array(
'accountid' => $this->getAccountId(), 'accountid' => $this->_getAccountId(),
'name' => $userName, 'name' => $userName,
#'avatar_url' => $avatar_url, #'avatar_url' => $avatar_url,
'gold' => 10000, 'gold' => 10000,
@ -85,7 +85,7 @@ class UserController extends BaseAuthedController {
} }
} }
{ {
$this->addItem(array( $this->_addItem(array(
array( array(
'item_id' => 16001, 'item_id' => 16001,
'item_num' => 0, 'item_num' => 0,
@ -96,17 +96,17 @@ class UserController extends BaseAuthedController {
public function clientBattleReport() public function clientBattleReport()
{ {
$this->updateUserInfo(array( $this->_updateUserInfo(array(
'first_fight' => function () { 'first_fight' => function () {
return '1'; return '1';
} }
)); ));
$this->rspOk(); $this->_rspOk();
} }
public function battleReport() public function battleReport()
{ {
$userInfo = $this->getOrmUserInfo(); $userInfo = $this->_getOrmUserInfo();
if (!$userInfo) { if (!$userInfo) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家1'); phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家1');
return; return;
@ -141,15 +141,15 @@ class UserController extends BaseAuthedController {
$integral = $_REQUEST['rank_score']; //排位积分 $integral = $_REQUEST['rank_score']; //排位积分
$score = $_REQUEST['pass_score']; //通行证积分 $score = $_REQUEST['pass_score']; //通行证积分
$nowDaySeconds = $this->getNowDaySeconds(); $nowDaySeconds = $this->_getNowDaySeconds();
if ($_REQUEST['items'] != '') { if ($_REQUEST['items'] != '') {
$item_list = splitStr1($_REQUEST['items']); $item_list = splitStr1($_REQUEST['items']);
$addreward = new classes\AddReward(); $addreward = new classes\AddReward();
$addreward->addReward((int)$item_list[0][0], (int)$item_list[0][1], $this->getAccountId(), 0, 0); $addreward->addReward((int)$item_list[0][0], (int)$item_list[0][1], $this->_getAccountId(), 0, 0);
} }
{ {
$addreward = new classes\AddReward(); $addreward = new classes\AddReward();
$val = $addreward->getVipVal($this->getAccountId(), 1); $val = $addreward->getVipVal($this->_getAccountId(), 1);
$coin_num = floor($coin_num + $coin_num * $val / 100); $coin_num = floor($coin_num + $coin_num * $val / 100);
} }
//更新击杀信息时间 //更新击杀信息时间
@ -158,13 +158,13 @@ class UserController extends BaseAuthedController {
$k = $userInfo['kill_his'] / $userInfo['game_times']; $k = $userInfo['kill_his'] / $userInfo['game_times'];
} }
if (($userInfo['kill_his'] + $kills) / ($userInfo['game_times'] + 1) != $k) { if (($userInfo['kill_his'] + $kills) / ($userInfo['game_times'] + 1) != $k) {
$this->updateUserInfo(array( $this->_updateUserInfo(array(
'kill_modifytime' => $this->_getNowTime(), 'kill_modifytime' => $this->_getNowTime(),
)); ));
} }
//更新胜场信息时间 //更新胜场信息时间
if ($rank == 1) { if ($rank == 1) {
$this->updateUserInfo(array( $this->_updateUserInfo(array(
'win_times' => $userInfo['win_times'] + 1, 'win_times' => $userInfo['win_times'] + 1,
'season_win' => $userInfo['season_win'] + 1, 'season_win' => $userInfo['season_win'] + 1,
'win_modifytime' => $this->_getNowTime(), 'win_modifytime' => $this->_getNowTime(),
@ -180,7 +180,7 @@ class UserController extends BaseAuthedController {
if ($isProtect && $minScore > $updateScore) { if ($isProtect && $minScore > $updateScore) {
$update_score = $minScore; $update_score = $minScore;
} }
$this->updateUserInfo(array( $this->_updateUserInfo(array(
'integral' => $update_score, 'integral' => $update_score,
'rank_modifytime' => $this->_getNowTime(), 'rank_modifytime' => $this->_getNowTime(),
'max_integral' => $update_maxscore, 'max_integral' => $update_maxscore,
@ -214,7 +214,7 @@ class UserController extends BaseAuthedController {
$game_times2++; $game_times2++;
} }
} }
$this->updateUserInfo(array( $this->_updateUserInfo(array(
'game_times' => function () { 'game_times' => function () {
return 'game_times + 1'; return 'game_times + 1';
}, },
@ -260,7 +260,7 @@ class UserController extends BaseAuthedController {
)); ));
$addreward = new classes\Addreward(); $addreward = new classes\Addreward();
$vip_level = $addreward->getVipLevel($this->getAccountId()); $vip_level = $addreward->getVipLevel($this->_getAccountId());
echo json_encode(array( echo json_encode(array(
'errcode' => 0, 'errcode' => 0,
'errmsg' => '', 'errmsg' => '',