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

View File

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

View File

@ -33,7 +33,7 @@ class BaseController {
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)

View File

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

View File

@ -193,7 +193,7 @@ class FriendController extends BaseAuthedController {
public function createRoleInfo()
{
$account_id = $_REQUEST['account_id'];
$conn = $this->getMysql($account_id);
$conn = $this->_getMysql($account_id);
$user_name = $_REQUEST['user_name'];
$avatar_url = $_REQUEST['avatar_url'];
$sex = $_REQUEST['sex'];
@ -233,7 +233,7 @@ class FriendController extends BaseAuthedController {
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 ' .
' WHERE accountid=:accountid;',
array(

View File

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

View File

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

View File

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

View File

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

View File

@ -45,7 +45,7 @@ class TeamController extends BaseAuthedController {
$hiFrameID = $_REQUEST['hiFrameID'];
}
$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;',
array(
'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 -> pexpire(TEAMID_KEY . $team_uuid, 1000*600);
@ -92,7 +92,7 @@ class TeamController extends BaseAuthedController {
return;
}
$team_uuid = $_REQUEST['team_uuid'];
$r = $this->getRedis($team_uuid);
$r = $this->_getRedis($team_uuid);
$accountid = $_REQUEST['account_id'];
@ -119,7 +119,7 @@ class TeamController extends BaseAuthedController {
return;
}
$team_uuid = $_REQUEST['team_uuid'];
$r = $this->getRedis($team_uuid);
$r = $this->_getRedis($team_uuid);
$accountid = $_REQUEST['account_id'];
@ -168,7 +168,7 @@ class TeamController extends BaseAuthedController {
return;
}
$team_uuid = $_REQUEST['team_uuid'];
$r = $this->getRedis($team_uuid);
$r = $this->_getRedis($team_uuid);
$accountid = $_REQUEST['account_id'];
@ -215,7 +215,7 @@ class TeamController extends BaseAuthedController {
}
$team_uuid = $_REQUEST['team_uuid'];
$r = $this->getRedis($team_uuid);
$r = $this->_getRedis($team_uuid);
$user_db_str = $r->get(TEAMID_KEY.$team_uuid);
if (empty($user_db_str)) {
@ -263,7 +263,7 @@ class TeamController extends BaseAuthedController {
}
$team_uuid = $_REQUEST['team_uuid'];
$r = $this->getRedis($team_uuid);
$r = $this->_getRedis($team_uuid);
$user_db_str = $r->get(TEAMID_KEY.$team_uuid);
if (empty($user_db_str)) {
@ -300,7 +300,7 @@ class TeamController extends BaseAuthedController {
}
$team_uuid = $_REQUEST['team_uuid'];
$r = $this->getRedis($team_uuid);
$r = $this->_getRedis($team_uuid);
$user_db_str = $r->get(TEAMID_KEY.$team_uuid);
if (empty($user_db_str)) {
@ -351,7 +351,7 @@ class TeamController extends BaseAuthedController {
$hiFrameID = $_REQUEST['hiFrameID'];
}
$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;',
array(
'accountid' => $accountid,
@ -389,7 +389,7 @@ class TeamController extends BaseAuthedController {
return;
}
$team_uuid = $_REQUEST['team_uuid'];
$r = $this->getRedis($team_uuid);
$r = $this->_getRedis($team_uuid);
if (!$r) {
echo 'is null';
} else {
@ -434,7 +434,7 @@ class TeamController extends BaseAuthedController {
return;
}
$team_uuid = $_REQUEST['team_uuid'];
$r = $this->getRedis($team_uuid);
$r = $this->_getRedis($team_uuid);
$roomManager = $_REQUEST['roomManager'];
if (!$r) {
@ -491,7 +491,7 @@ class TeamController extends BaseAuthedController {
return;
}
$team_uuid = $_REQUEST['team_uuid'];
$r = $this->getRedis($team_uuid);
$r = $this->_getRedis($team_uuid);
if (!$r){
echo 'is null';
@ -533,7 +533,7 @@ class TeamController extends BaseAuthedController {
}
$team_uuid = $_REQUEST['team_uuid'];
//error_log("剔除玩家===");
$r = $this->getRedis($team_uuid);
$r = $this->_getRedis($team_uuid);
if (!$r) {
echo 'is null';

View File

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