def post(self): try: platform = self.get_argument("platform", "") if not auth_utils.check_param_legal(platform): self.finish(json_encode({"mc": MsgCode['ParamError']})) return tmp_account_id = None while not tmp_account_id: tmp_account_id = gen_account_id() account = Account.get_account("%s_%s" % (platform, tmp_account_id)) if not isinstance(account, Account): tmp_account_id = None tmp_password = gen_password() complete_account_id = "%s_%s" % (platform, tmp_account_id) Account.register(complete_account_id, tmp_password, 0) msg = build_login_game_data(platform, tmp_account_id, auth_utils.white_ip_check(self)) msg["data"]["password"] = tmp_password self.write(json_encode(msg)) except Exception,e: self.interal_error_handle(e)
def post(self): try: platform = self.get_argument("platform", "") if not auth_utils.check_param_legal(platform): self.finish(json_encode({"mc": MsgCode['ParamError']})) return tmp_account_id = None while not tmp_account_id: tmp_account_id = gen_account_id() account = Account.get_account("%s_%s" % (platform, tmp_account_id)) if not isinstance(account, Account): tmp_account_id = None tmp_password = gen_password() complete_account_id = "%s_%s" % (platform, tmp_account_id) Account.register(complete_account_id, tmp_password, 0) msg = build_login_game_data(platform, tmp_account_id, auth_utils.white_ip_check(self)) msg["data"]["password"] = tmp_password self.write(json_encode(msg)) except Exception, e: self.interal_error_handle(e)
def auth_XTZJ(platform, params): """ uid_100010|session_28BzIMEXzVUMqBac """ try: params_list = params.split("|") uid = params_list[0].split("_")[1] session = params_list[1].split("_")[1] # 开发阶段,自己的账号系统 session即password except: return False, MsgCode['AccountAuthParamError'], None if not auth_utils.check_param_legal(platform, uid, session): return False, MsgCode['AccountAuthParamError'], None # 检查玩家账号是否存在,不存在则注册,若存在则验证密码通过 complete_account_id = "%s_%s" % (platform, uid) if not Account.check_account_exist(complete_account_id): return False, MsgCode['AccountAuthFail'], None # Account.register(complete_account_id, session, 1) if not Account.check_user_password(complete_account_id, session): return False, MsgCode['AccountPasswordError'], None return True, None, complete_account_id
def post(self): try: platform = self.get_argument("platform", "") tmp_auth_params = self.get_argument("tmp_auth_params", "") auth_params = self.get_argument("auth_params", "") if not auth_utils.check_param_legal(platform): self.finish(json_encode({"mc": MsgCode['ParamError']})) return try: params_list = auth_params.split("|") account_id = params_list[0].split("_")[1] password = params_list[1].split("_")[1] # 自己的账号系统 params_list1 = tmp_auth_params.split("|") tmp_account_id = params_list1[0].split("_")[1] tmp_password = params_list1[1].split("_")[1] # 自己的账号系统 if not auth_utils.check_param_legal( account_id, password, tmp_account_id, tmp_password): raise if len(account_id) < 6 or len(account_id) > 18 or len( password) < 6 or len(password) > 18: raise except Exception, e: self.finish( json_encode({"mc": MsgCode['AccountRegistParamsError']})) return complete_account_id = "%s_%s" % (platform, tmp_account_id) complete_account_id1 = "%s_%s" % (platform, account_id) if not Account.check_user_password(complete_account_id, tmp_password): self.finish(json_encode({"mc": MsgCode['AccountAuthFail']})) return # 只有临时账户可以绑定账号 if Account.account_type(complete_account_id) != 0: self.finish(json_encode({"mc": MsgCode['AccountBindRepeat']})) return if Account.check_account_exist(complete_account_id1): self.finish(json_encode({"mc": MsgCode['AccountAlreadyExist']})) return result = Account.bind_account_auth_data(complete_account_id, complete_account_id1, password) if result: self.write(json_encode({"mc": MsgCode['AccountBindSucc']})) else: self.write(json_encode({"mc": MsgCode['AccountBindFail']}))
def post(self): try: platform = self.get_argument("platform", "") tmp_auth_params = self.get_argument("tmp_auth_params", "") auth_params = self.get_argument("auth_params", "") if not auth_utils.check_param_legal(platform): self.finish(json_encode({"mc": MsgCode['ParamError']})) return try: params_list = auth_params.split("|") account_id = params_list[0].split("_")[1] password = params_list[1].split("_")[1] # 自己的账号系统 params_list1 = tmp_auth_params.split("|") tmp_account_id = params_list1[0].split("_")[1] tmp_password = params_list1[1].split("_")[1] # 自己的账号系统 if not auth_utils.check_param_legal(account_id, password, tmp_account_id, tmp_password): raise if len(account_id) < 6 or len(account_id) > 18 or len(password) < 6 or len(password) > 18: raise except Exception,e: self.finish(json_encode({"mc": MsgCode['AccountRegistParamsError']})) return complete_account_id = "%s_%s" % (platform, tmp_account_id) complete_account_id1 = "%s_%s" % (platform, account_id) if not Account.check_user_password(complete_account_id, tmp_password): self.finish(json_encode({"mc": MsgCode['AccountAuthFail']})) return # 只有临时账户可以绑定账号 if Account.account_type(complete_account_id) != 0: self.finish(json_encode({"mc": MsgCode['AccountBindRepeat']})) return if Account.check_account_exist(complete_account_id1): self.finish(json_encode({"mc": MsgCode['AccountAlreadyExist']})) return result = Account.bind_account_auth_data(complete_account_id, complete_account_id1, password) if result: self.write(json_encode({"mc": MsgCode['AccountBindSucc']})) else: self.write(json_encode({"mc": MsgCode['AccountBindFail']}))
def post(self): platform = self.get_argument("platform", "") auth_params = self.get_argument("auth_params", "") if not auth_utils.check_param_legal(platform): self.finish(json_encode({"mc": MsgCode['ParamError']})) return # 根据平台不同进行分发 platform_config = Platform.get_plat_config(platform) if not platform_config: self.finish(json_encode({"mc": MsgCode['PlatformNotExist']})) return if not hasattr(platform_auth, platform_config["checker"]): self.finish(json_encode({"mc": MsgCode['AccountAuthParamError']})) return func = getattr(platform_auth, platform_config["checker"]) success, code, complete_account_id = func(platform, auth_params) if not success: self.finish(json_encode({"mc": code})) return if platform_config["sign"] in NEED_OPEN_ID_PLATS: account = Account.get_account(complete_account_id) if not account.open_id: # 0 - 未检测 1 - 已预约 2 - 没预约 3 - 已兑奖 open_id = platform_auth.fetch_plat_openid(auth_params) account.update_open_id(open_id) account_id = complete_account_id.split("_")[1] msg = build_login_game_data(platform, account_id, auth_utils.white_ip_check(self)) self.write(json_encode(msg))
def install_default_datas(self): """默认获得姬甲,排布阵容等 """ from apps.logics import hero as hero_logic hero_logic.add_heros(self, [{100050: 1}]) self.array.update(1, [0, 100050, 0, 0, 0, 0]) self.arena.init_when_install(self.sid) # 创建角色时,检测是否需要发[ 应用宝的预约礼包 | uc封测测试奖励 | 360封测测试奖励 ] if self.platform in ["YSDK", "UC", "QIHOO"]: account = Account.get_account("%s_%s" % (self.platform, self.account_id)) if not isinstance(account, Account): return if self.platform == "YSDK" and redis_client.sismember(rediskey_config.YYB_ORDERED_SET % self.sid, account.open_id): order_awards_cfg = game_config.gift_key_config.get("YY02", {}) if order_awards_cfg: MailService.send_game(self.uid, 5003, [], order_awards_cfg["award"]) if self.platform in ["UC", "QIHOO"]: # 1.最终等级达到x级 2.累计登陆x天 3.竞技场最终排名x awards,logins = pregift_service.uc_qihoo_test_award_4003(self.sid, self.platform, account.open_id) if awards: MailService.send_game(self.uid, 5000, [logins], awards) awards1,days = pregift_service.uc_qihoo_test_award_4004(self.sid, self.platform, account.open_id) if awards1: MailService.send_game(self.uid, 5001, [days], awards1) awards2,rank = pregift_service.uc_qihoo_test_award_4005(self.sid, self.platform, account.open_id) if awards2: MailService.send_game(self.uid, 5002, [rank], awards2)
def post(self): try: platform = self.get_argument("platform", "") auth_params = self.get_argument("auth_params", "") if not auth_utils.check_param_legal(platform): self.finish(json_encode({"mc": MsgCode['ParamError']})) return try: params_list = auth_params.split("|") account_id = params_list[0].split("_")[1] password = params_list[1].split("_")[1] # 自己的账号系统 if not auth_utils.check_param_legal(account_id, password): raise if len(account_id) < 6 or len(account_id) > 18 or len( password) < 6 or len(password) > 18: raise except: self.finish( json_encode({"mc": MsgCode['AccountRegistParamsError']})) return complete_account_id = "%s_%s" % (platform, account_id) if Account.check_account_exist(complete_account_id): self.finish(json_encode({"mc": MsgCode['AccountAlreadyExist']})) return Account.register(complete_account_id, password) msg = build_login_game_data(platform, account_id, auth_utils.white_ip_check(self)) self.write(json_encode(msg)) except Exception, e: self.interal_error_handle(e)
def build_login_game_data(platform, account_id, white_ip): """ """ now_time = int(time.time()) session_id = auth_utils.build_session_id(account_id, now_time) account = Account.get_account("%s_%s" % (platform, account_id)) servers = Server.get_all_servers() login_history = Account.get_login_history("%s_%s" % (platform, account_id)) msg = {} msg["mc"] = 100 msg["data"] = {} msg["data"]["session_id"] = session_id msg["data"]["account_id"] = account_id msg["data"]["account_type"] = account.type msg["data"]["servers_info"] = fectch_server_info(servers, white_ip) msg["data"]["login_history"] = login_history notice = NoticeService.get_login_notices() msg["data"]["notices"] = notice return msg
def post(self): try: platform = self.get_argument("platform", "") auth_params = self.get_argument("auth_params", "") if not auth_utils.check_param_legal(platform): self.finish(json_encode({"mc": MsgCode['ParamError']})) return try: params_list = auth_params.split("|") account_id = params_list[0].split("_")[1] password = params_list[1].split("_")[1] # 自己的账号系统 if not auth_utils.check_param_legal(account_id, password): raise if len(account_id) < 6 or len(account_id) > 18 or len(password) < 6 or len(password) > 18: raise except: self.finish(json_encode({"mc": MsgCode['AccountRegistParamsError']})) return complete_account_id = "%s_%s" % (platform, account_id) if Account.check_account_exist(complete_account_id): self.finish(json_encode({"mc": MsgCode['AccountAlreadyExist']})) return Account.register(complete_account_id, password) msg = build_login_game_data(platform, account_id, auth_utils.white_ip_check(self)) self.write(json_encode(msg)) except Exception,e: self.interal_error_handle(e)
def install_default_datas(self): """默认获得姬甲,排布阵容等 """ from apps.logics import hero as hero_logic hero_logic.add_heros(self, [{100050: 1}]) self.array.update(1, [0, 100050, 0, 0, 0, 0]) self.arena.init_when_install(self.sid) # 创建角色时,检测是否需要发[ 应用宝的预约礼包 | uc封测测试奖励 | 360封测测试奖励 ] if self.platform in ["YSDK", "UC", "QIHOO"]: account = Account.get_account("%s_%s" % (self.platform, self.account_id)) if not isinstance(account, Account): return if self.platform == "YSDK" and redis_client.sismember( rediskey_config.YYB_ORDERED_SET % self.sid, account.open_id): order_awards_cfg = game_config.gift_key_config.get("YY02", {}) if order_awards_cfg: MailService.send_game(self.uid, 5003, [], order_awards_cfg["award"]) if self.platform in ["UC", "QIHOO"]: # 1.最终等级达到x级 2.累计登陆x天 3.竞技场最终排名x awards, logins = pregift_service.uc_qihoo_test_award_4003( self.sid, self.platform, account.open_id) if awards: MailService.send_game(self.uid, 5000, [logins], awards) awards1, days = pregift_service.uc_qihoo_test_award_4004( self.sid, self.platform, account.open_id) if awards1: MailService.send_game(self.uid, 5001, [days], awards1) awards2, rank = pregift_service.uc_qihoo_test_award_4005( self.sid, self.platform, account.open_id) if awards2: MailService.send_game(self.uid, 5002, [rank], awards2)
def charge(context): """充值接口 Args: index 充值券编号 Returns: """ ki_user = context.user complete_account_id = "%s_%s" % (ki_user.platform, ki_user.account_id) account = Account.get_account(complete_account_id) if account.type == 2: context.result['mc'] = MsgCode['VipChargeTmpAccountCantCharge'] return index = context.get_parameter("index") cfg = game_config.charge_cfg.get(index, {}) if not cfg: context.result['mc'] = MsgCode['VipChargeIndexNotExist'] return order = generate_charge_order(index, cfg["rmb"], ki_user) result = charge_service.insert_order(order) if not result: context.result['mc'] = MsgCode['VipChargeFailed'] return try: stat_service.charge(ki_user.platform, ki_user.account_id, ki_user.uid, order["orderid"], order["price"], ORDER_PREPARE) except: logging.error("ERROR:【order status: 0 record charge log failed. 】") context.result["data"] = {} context.result["data"]["orderid"] = order["orderid"] context.result["data"]["money"] = cfg["rmb"]
def post(self): """游戏登录接口 """ account_id = self.get_argument("account_id") server_id = self.get_argument("server_id") platform = self.get_argument("platform") session_id = self.get_argument("session_id") server = Server.get_server_by_id(server_id) if not server: self.finish(json_encode({"mc": MsgCode['ServerNotExist']})) return # 当服务器还未开启或者维护时,内部账户随意进出游戏 if int(server["state"]) != settings.SERVER_STATE_OPEN and not auth_utils.white_ip_check(self): code = MsgCode['ServerNotOpen'] if int(server["state"]) == settings.SERVER_STATE_CLOSE else MsgCode['ServerUpdateing'] self.finish(json_encode({'mc': code})) return check_result = auth_utils.login_auth(session_id, account_id, server_id) if check_result: self.finish(json_encode(check_result)) return complete_account_id = "%s_%s" % (platform, account_id) uid = Account.get_user_id(complete_account_id, server_id) if not uid: self.finish(json_encode({"mc": MsgCode['GameLoginFail']})) return user_login_data = {"aid": account_id, "uid": uid, "sid": server_id, "pf": platform} ki_user = User.install(user_login_data) if not isinstance(ki_user, User): self.finish(json_encode({"mc": MsgCode['GameLoginFail']})) return if ki_user.ext_info.ban_account and ki_user.ext_info.ban_account > int(time.time()): self.finish(json_encode({"mc": MsgCode["UserFrozen"]})) return server_time = int(time.time()) ki_user.update_user_login_info(server_time) user_guide_checker(ki_user) # 为前端加引导保护器,防止玩家引导断掉 导致无法进行游戏 ki_user.vip.update_card_when_request() # 更新玩家vip月卡信息 ki_user.activity.update_effective_acts(ki_user.sid, ki_user.game_info.role_level) # 更新活动数据 act_helper.update_after_login(ki_user) if charge_service.ismember_of_paid_set(uid): vip_logic.charge_refresh(ki_user) # 如果有未发送元宝的订单,立即发送元宝 _set_secure_cookie(self, account_id, uid, platform, server_time, server_id) # 返回COOKIE # boss_hero_rank = BossService.login_notice(ki_user.sid, ki_user.uid) # if boss_hero_rank and boss_hero_rank == 1: # NoticeService.broadcast(ki_user.sid, 20, {'uid': ki_user.uid, 'name': ki_user.name}, boss_hero_rank) msg = {} msg["mc"] = MsgCode['GameLoginSucc'] msg["data"] = {} msg["data"]["user_data"] = fetch_user_data(ki_user) msg["data"]["server_time"] = server_time self.write(json_encode(msg))