1
This commit is contained in:
parent
388487cee2
commit
b388dc2ee1
@ -40,6 +40,11 @@ function emptyReplace($val, $defVal)
|
|||||||
return !empty($val) ? $val :$defVal;
|
return !empty($val) ? $val :$defVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isValidSex($sex)
|
||||||
|
{
|
||||||
|
return in_array($sex, array(0, 1, 2));
|
||||||
|
}
|
||||||
|
|
||||||
$_myself = null;
|
$_myself = null;
|
||||||
|
|
||||||
function myself()
|
function myself()
|
||||||
|
@ -11,6 +11,7 @@ require_once('mt/Rank.php');
|
|||||||
|
|
||||||
require_once('services/PropertyChgService.php');
|
require_once('services/PropertyChgService.php');
|
||||||
require_once('services/SeasonService.php');
|
require_once('services/SeasonService.php');
|
||||||
|
require_once('services/NameService.php');
|
||||||
|
|
||||||
use phpcommon\SqlHelper;
|
use phpcommon\SqlHelper;
|
||||||
use models\User;
|
use models\User;
|
||||||
@ -102,6 +103,49 @@ class UserController extends BaseAuthedController {
|
|||||||
$sex = getReqVal('sex', 0);
|
$sex = getReqVal('sex', 0);
|
||||||
$headId = getReqVal('head_id', 0);
|
$headId = getReqVal('head_id', 0);
|
||||||
$headFrame = getReqVal('head_frame', 0);
|
$headFrame = getReqVal('head_frame', 0);
|
||||||
|
|
||||||
|
$userInfo = $this->_getOrmUserInfo();
|
||||||
|
if ($userInfo['activated']) {
|
||||||
|
$this->_rspErr(10, '不能重复激活');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$nameService = new services\NameService();
|
||||||
|
if (!$nameService->verifyNameSign($param1, $param2)){
|
||||||
|
$this->_rspErr(1, '参数错误名,签名校验失败');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!$nameService->nameUsed($param1)){
|
||||||
|
$this->_rspErr(2, '名字已被占用');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!isValidSex($sex)) {
|
||||||
|
$this->_rspErr(1, '参数错误名,sex不合法');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (User::isValidHeadId($userInfo, $headId)) {
|
||||||
|
$this->_rspErr(1, '参数错误名,head_id不合法');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (User::isValidHeadFrame($userInfo, $headFrame)) {
|
||||||
|
$this->_rspErr(1, '参数错误名,head_frame不合法');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!$nameService->useName($name)) {
|
||||||
|
$this->_rspErr(2, '名字已被占用');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->_updateUserInfo(array(
|
||||||
|
'name' => $name,
|
||||||
|
'sex' => $sex,
|
||||||
|
'head_id' => $headId,
|
||||||
|
'head_frame' => $headFrame,
|
||||||
|
'activated' => 1
|
||||||
|
));
|
||||||
|
$propertyChgService = new services\PropertyChgService();
|
||||||
|
$propertyChgService->addUserChg();
|
||||||
|
$this->_rspData(array(
|
||||||
|
'property_chg' => $propertyChgService->toDto()
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update()
|
public function update()
|
||||||
|
@ -21,8 +21,8 @@ class User extends BaseModel {
|
|||||||
'diamond' => $row['diamond'],
|
'diamond' => $row['diamond'],
|
||||||
'hero_id' => $row['hero_id'],
|
'hero_id' => $row['hero_id'],
|
||||||
'first_fight' => $row['first_fight'],
|
'first_fight' => $row['first_fight'],
|
||||||
'head_list' => !empty($row['head_list']) ? json_decode($row['head_list'], true) : array(),
|
'head_list' => self::getHeadList($row),
|
||||||
'head_frame_list' => !empty($row['head_frame_list']) ? json_decode($row['head_frame_list'], true) : array(),
|
'head_frame_list' => emptyReplace(json_decode($row['head_frame_list'], true), array()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,9 +43,30 @@ class User extends BaseModel {
|
|||||||
'diamond' => $row['diamond'],
|
'diamond' => $row['diamond'],
|
||||||
'hero_id' => $row['hero_id'],
|
'hero_id' => $row['hero_id'],
|
||||||
'first_fight' => $row['first_fight'],
|
'first_fight' => $row['first_fight'],
|
||||||
'head_list' => !empty($row['head_list']) ? json_decode($row['head_list'], true) : array(),
|
'head_list' => self::getHeadList($row),
|
||||||
'head_frame_list' => !empty($row['head_frame_list']) ? json_decode($row['head_frame_list'], true) : array(),
|
'head_frame_list' => emptyReplace(json_decode($row['head_frame_list'], true), array()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function isValidHeadId($userInfo, $headId)
|
||||||
|
{
|
||||||
|
$headList = self::getHeadList($userInfo);
|
||||||
|
return in_array($headId, $headList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function isValidHeadFrame($userInfo, $headFrame)
|
||||||
|
{
|
||||||
|
$headFrameList = !empty($userInfo['head_frame_list']) ?
|
||||||
|
json_decode($userInfo['head_frame_list'], true) : array();
|
||||||
|
return in_array($headFrame, $headFrameList);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function getHeadList($userInfo)
|
||||||
|
{
|
||||||
|
$headList = !empty($userInfo['head_list']) ? json_decode($userInfo['head_list'], true) : array();
|
||||||
|
$heroList = array();
|
||||||
|
$heroSkinList = array();
|
||||||
|
return $headList;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user