Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
    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))
Exemplo n.º 3
0
    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))
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
    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)
Exemplo n.º 6
0
    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)
Exemplo n.º 7
0
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"]
Exemplo n.º 8
0
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
Exemplo n.º 9
0
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
Exemplo n.º 10
0
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"]