用户信息添加hero_uniid自动
This commit is contained in:
parent
9f3f3fde5a
commit
5ed06adc39
@ -61,7 +61,7 @@ class User(object):
|
||||
['sex', 0, '更新性别(可选参数,不传就不更新)'],
|
||||
['head_id', 0, '更新头像(可选参数,不传就不更新)'],
|
||||
['head_frame', 0, '更新头像框(可选参数,不传就不更新)'],
|
||||
['hero_id', 0, '更新上阵英雄id(可选参数,不传就不更新)'],
|
||||
['hero_uniid', 0, '更新上阵英雄唯一id(可选参数,不传就不更新)'],
|
||||
['first_fight', 0, '更新首次战斗(可选参数,不传就不更新)']
|
||||
],
|
||||
'response': [
|
||||
|
@ -57,6 +57,7 @@ class UserInfo(object):
|
||||
['history_best_rank', 0, '历史最高段位'],
|
||||
['gold', 0, '金币'],
|
||||
['diamond', 0, '钻石'],
|
||||
['hero_uniid', 0, '当前使用的英雄唯一ID'],
|
||||
['hero_id', 0, '当前使用的英雄ID'],
|
||||
['first_fight', 0, '是否是第一次战斗'],
|
||||
['!head_list', [0], '拥有的头像列表'],
|
||||
@ -77,6 +78,7 @@ class UserDetailInfo(object):
|
||||
['max_exp', 0, '经验(上限)'],
|
||||
['gold', 0, '金币'],
|
||||
['diamond', 0, '钻石'],
|
||||
['hero_uniid', 0, '当前使用的英雄唯一ID'],
|
||||
['hero_id', 0, '当前使用的英雄ID'],
|
||||
['current_rank', 0, '当前段位'],
|
||||
['history_best_rank', 0, '历史最高段位'],
|
||||
|
@ -40,6 +40,7 @@ CREATE TABLE `t_user` (
|
||||
`score` int(11) NOT NULL DEFAULT '0' COMMENT '积分',
|
||||
`gold` int(11) NOT NULL DEFAULT '0' COMMENT '金币',
|
||||
`diamond` int(11) NOT NULL DEFAULT '0' COMMENT '钻石',
|
||||
`hero_uniid` int(11) NOT NULL DEFAULT '0' COMMENT '当前上阵英雄唯一id',
|
||||
`hero_id` int(11) NOT NULL DEFAULT '0' COMMENT '当前上阵英雄id',
|
||||
`first_fight` int(11) NOT NULL DEFAULT '0' COMMENT '是否首战',
|
||||
`last_season_id` int(11) NOT NULL DEFAULT '0' COMMENT '最后一次赛季id',
|
||||
|
@ -119,11 +119,13 @@ class UserController extends BaseAuthedController {
|
||||
}
|
||||
$headId = !empty($headList) ? $headList[rand() % count($headList)] : 0;
|
||||
$headFrame = !empty($headFrameList) ? $headFrameList[rand() % count($headFrameList)] : 0;
|
||||
$heroUniId = 0;
|
||||
$heroId = !empty($heroList) ? $heroList[rand() % count($heroList)]['id'] : 0;
|
||||
if ($headId == 0 || count($headList) <= 1) {
|
||||
$headId = !empty($haveHeadHeroList) ?
|
||||
$haveHeadHeroList[rand() % count($haveHeadHeroList)]['hero_head'] : 0;
|
||||
}
|
||||
Hero::randHero($heroUniId, $heroId);
|
||||
SqlHelper::upsert
|
||||
($this->_getSelfMysql(),
|
||||
't_user',
|
||||
@ -146,6 +148,7 @@ class UserController extends BaseAuthedController {
|
||||
'history_best_rank' => $initRankMeta ? $initRankMeta['rank'] : 1,
|
||||
'score' => $initRankMeta ? $initRankMeta['min_score'] : 0,
|
||||
'head_id' => $headId,
|
||||
'hero_uniid' => $heroUniId,
|
||||
'hero_id' => $heroId,
|
||||
'last_season_id' => $currSeasonMeta ? $currSeasonMeta['id'] : 0,
|
||||
'head_list' => json_encode($headList),
|
||||
@ -216,6 +219,7 @@ class UserController extends BaseAuthedController {
|
||||
public function update()
|
||||
{
|
||||
$userInfo = $this->_getOrmUserInfo();
|
||||
$heroId = $userInfo['hero_id'];
|
||||
$validFields = array(
|
||||
'sex' => array(
|
||||
'field_name' => 'sex',
|
||||
@ -262,13 +266,15 @@ class UserController extends BaseAuthedController {
|
||||
}
|
||||
}
|
||||
),
|
||||
'hero_id' => array(
|
||||
'field_name' => 'hero_id',
|
||||
'hero_uniid' => array(
|
||||
'field_name' => 'hero_uniid',
|
||||
'val_func' => function ($val) {
|
||||
return $val;
|
||||
},
|
||||
'valid_func' => function ($val, &$errCode, &$errMsg) {
|
||||
if (Hero::find($val)) {
|
||||
'valid_func' => function ($val, &$errCode, &$errMsg) use (&$heroId) {
|
||||
$heroDb = Hero::find($val);
|
||||
if ($heroDb) {
|
||||
$heroId = $heroDb['hero_id'];
|
||||
return true;
|
||||
} else {
|
||||
$errCode = 1;
|
||||
|
@ -44,6 +44,7 @@ class Hero extends BaseModel {
|
||||
}
|
||||
$tradeLocktime = max(0, $row['unlock_trade_time'] - myself()->_getNowTime());
|
||||
$dto = array(
|
||||
'hero_uniid' => $row['idx'],
|
||||
'hero_id' => $row['hero_id'],
|
||||
'hero_lv' => $row['hero_lv'],
|
||||
'hero_tili' => $row['hero_tili'],
|
||||
@ -127,4 +128,27 @@ class Hero extends BaseModel {
|
||||
);
|
||||
}
|
||||
|
||||
public static function randHero(&$heroUniId, &$heroId)
|
||||
{
|
||||
$heroUniId = 0;
|
||||
$heroId = 0;
|
||||
$rows = SqlHelper::select(
|
||||
myself()->_getSelfMysql(),
|
||||
't_hero',
|
||||
array(
|
||||
'idx',
|
||||
'hero_id'
|
||||
),
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
'state' => self::GETED_STATE
|
||||
)
|
||||
);
|
||||
$key = array_rand($rows, 1);
|
||||
if (!is_null($key)) {
|
||||
$heroUniId = $rows[$key]['idx'];
|
||||
$heroId = $rows[$key]['hero_id'];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ class User extends BaseModel {
|
||||
'score' => $row['score'],
|
||||
'gold' => $row['gold'],
|
||||
'diamond' => $row['diamond'],
|
||||
'hero_uniid' => $row['hero_uniid'],
|
||||
'hero_id' => $row['hero_id'],
|
||||
'first_fight' => $row['first_fight'],
|
||||
'head_list' => self::getHeadList($row),
|
||||
@ -62,6 +63,7 @@ class User extends BaseModel {
|
||||
'score' => $row['score'],
|
||||
'gold' => $row['gold'],
|
||||
'diamond' => $row['diamond'],
|
||||
'hero_uniid' => $row['hero_uniid'],
|
||||
'hero_id' => $row['hero_id'],
|
||||
'first_fight' => $row['first_fight'],
|
||||
'head_list' => self::getHeadList($row),
|
||||
|
Loading…
x
Reference in New Issue
Block a user