_safeGetOrmUserInfo(); if (!$userInfo) { $this->createNewUser($userName, $avatarUrl); $userInfo = $this->_getOrmUserInfo(); } if (!$this->loginCheck($userInfo)) { $userInfo = $this->_getOrmUserInfo(); } $this->_rspData(array( 'info' => User::show($userInfo) )); } private function loginCheck($userInfo) { if (!$this->_checkSeason()) { return false; } return true; } private function createNewUser($userName, $avatarUrl) { $rankMeta = mt\Rank::get(1); SqlHelper::upsert ($this->_getSelfMysql(), 't_user', array( 'account_id' => $this->_getAccountId() ), array( ), array( 'account_id' => $this->_getAccountId(), 'name' => $userName, 'sex' => 2, #'avatar_url' => $avatar_url, 'gold' => 10000 * 10000, 'diamond' => 10000 * 10000, 'head_frame' => 19003, 'level' => 100, 'exp' => 0, 'rank' => $rankMeta ? $rankMeta['rank'] : 0, 'score' => $rankMeta ? $rankMeta['min_score'] : 0, 'head_id' => 18001, 'hero_id' => 30100, 'createtime' => $this->_getNowTime(), 'modifytime' => $this->_getNowTime(), ) ); { foreach (mt\Parameter::getListValue('creator_hero_id') as $heroId) { $heroMeta = mt\Hero::get($heroId); if ($heroMeta) { Hero::addHero($heroMeta); } } } { $this->_addItems(array( array( 'item_id' => 16001, 'item_num' => 0, ) )); } } public function update() { $validFields = array( 'hero_id' => array( 'field_name' => 'hero_id', 'val_func' => function ($val) { return $val; }, 'valid_func' => function ($val, &$errCode, &$errMsg) { if (Hero::find($val)) { return true; } else { $errCode = 1; $errMsg = '英雄不存在'; return false; } } ), 'first_fight' => array( 'field_name' => 'first_fight', 'val_func' => function ($val) { return empty($val) ? 0 : 1; }, 'valid_func' => function ($val, &$errCode, &$errMsg) { return true; } ) ); $fieldsKv = array(); $errCod = 0; $errMsg = ''; foreach ($validFields as $key => $field) { $reqVal = getReqVal($key, ''); if (!empty($reqVal)) { if (isset($field['valid_func'])) { if (!$field['valid_func']($reqVal, $errCode, $errMsg)) { $this->_rspErr($errCode, $errMsg); return; } $fieldsKv[$field['field_name']] = $field['val_func']($reqVal); } } } if (count($fieldsKv) > 0) { $this->_updateUserInfo($fieldsKv); } $propertyChgService = new services\PropertyChgService(); $propertyChgService->addUserChg(); $this->_rspData(array( 'property_chg' => $propertyChgService->toDto() )); } public function info() { $targetId = getReqVal('target_id', ''); $userDb = SqlHelper::ormSelectOne ($this->_getMysql($targetId), 't_user', array( 'account_id' => $targetId ) ); if (!$userDb) { $this->_rspErr(1, '账号不存在'); return; } $this->_rspData(array( 'info' => User::info($userDb) )); } }