This commit is contained in:
hujiabin 2024-06-07 14:55:15 +08:00
parent 024fcade01
commit faf2ffca5c
3 changed files with 36 additions and 25 deletions

View File

@ -196,5 +196,17 @@ class User(object):
_common.RspHead(),
['data', 0, '游戏场次'],
]
},{
'name': 'refreshUserInfo',
'desc': '刷新用户信息',
'group': 'User',
'url': 'webapp/index.php?c=User&a=refreshUserInfo',
'params': [
_common.ReqHead(),
],
'response': [
_common.RspHead(),
['info',_common.UserInfo(), '用户信息'],
]
},
]

View File

@ -88,23 +88,6 @@ class UserController extends BaseAuthedController {
$this->_incDailyV(TN_DAILY_LOGINS, 0, 1);
}
private function _setBattleHero($userInfo){
$heroUniId = 0;
$heroId = 0;
Hero::randHero($heroUniId,$heroId);
$heroMeta = mt\Item::get($heroId);
$headList = emptyReplace(json_decode($userInfo['head_list'], true), array());
if ($heroMeta['hero_head'] && !in_array($heroMeta['hero_head'],$headList)){
array_push($headList,$heroMeta['hero_head']);
}
User::update(array(
'hero_id' => $heroUniId,
'head_id' => $heroMeta['hero_head'],
'head_frame' => 60000,
'head_list' => json_encode($headList),
'head_frame_list' => json_encode(array(60000)),
));
}
private function _addFreeItem(){
$addItems =array();
@ -451,6 +434,23 @@ class UserController extends BaseAuthedController {
));
}
public function refreshUserInfo(){
$userInfo = $this->_getOrmUserInfo();
$heroDb = Hero::findByAccountId(myself()->_getAccountId(), $userInfo['hero_id']);
if (!$heroDb){
$heroUniId = 0;
$heroId = 0;
Hero::randHero($heroUniId,$heroId);
User::update(array(
'hero_id' => $heroUniId,
));
$userInfo = $this->_getOrmUserInfo();
}
$this->_rspData(array(
'info' => User::info($userInfo)
));
}
public function getMapConf()
{
$modeId = getReqVal('mode_id', 0);

View File

@ -71,11 +71,9 @@ class User extends BaseModel {
public static function show($row)
{
$heroDb = Hero::find($row['hero_id']);
$heroId = 0;
if ($heroDb){
$heroId = $heroDb['hero_id'];
}
$heroDb = Hero::findByAccountId($row['account_id'],$row['hero_id']);
$heroUniid = $heroDb ? $row['hero_id'] : 0;
$heroId = $heroDb ? $heroDb['hero_id'] : 0;
$honorInfo = array();
if ($row['address']){
$honorInfo = UserHonor::info($row['address']);
@ -98,7 +96,7 @@ class User extends BaseModel {
'bceg' => cegFormat($row['bceg']),
'gold' => cegFormat($row['gold']),
'diamond' => cecFormat($row['diamond']),
'hero_uniid' => $row['hero_id'],
'hero_uniid' => $heroUniid,
'hero_id' => $heroId,
'first_fight' => $row['first_fight'],
'already_guide' => $row['already_guide'],
@ -124,7 +122,8 @@ class User extends BaseModel {
{
$heroDb = Hero::findByAccountId($row['account_id'],$row['hero_id']);
$heroId = $heroDb['hero_id'];
$heroUniid = $heroDb ? $row['hero_id'] : 0;
$heroId = $heroDb ? $heroDb['hero_id'] : 0;
$honorInfo = array();
if ($row['address']){
$honorInfo = UserHonor::info($row['address']);
@ -147,7 +146,7 @@ class User extends BaseModel {
'bceg' => cegFormat($row['bceg']),
'gold' => cegFormat($row['gold']),
'diamond' => cecFormat($row['diamond']),
'hero_uniid' => $row['hero_id'],
'hero_uniid' => $heroUniid,
'hero_id' => $heroId,
'first_fight' => $row['first_fight'],
'already_guide' => $row['already_guide'],