Exemplo n.º 1
0
    def generate_account_info_mysql(cls, account_id, server_id, uid):
        """将信息备份到mysql数据库中,方便统计和登录时候发送登录历史
        """
        now = int(time.time())
        engine = app.get_storage_engine("mysql")
        sql = "INSERT INTO accounts (account_id, server_id, uid, create_time, last_login) \
               VALUES ('%s', %s, '%s', %s, %s);" % (account_id, server_id, uid, now, now)

        engine.master_execute(sql)
Exemplo n.º 2
0
    def get_login_history(cls, account_id):
        """获取账号登录历史服务器
        """
        engine = app.get_storage_engine("mysql")
        sql = "SELECT server_id, last_login FROM accounts WHERE account_id = '%s';" % account_id

        rows = engine.master_query(sql)

        return rows[:5] if rows else []
Exemplo n.º 3
0
    def update_account_info_mysql(cls, account_id, server_id):
        """将信息备份到mysql数据库中,方便统计和登录时候发送登录历史
        """
        now = int(time.time())
        engine = app.get_storage_engine("mysql")
        sql = "UPDATE accounts SET last_login = %s WHERE account_id = '%s' \
               AND server_id = %s;" % (now, account_id, server_id)

        engine.master_execute(sql)
            "server_id": 1,
            "server_config": {
                "server_id": 1,
                "server_name": "本地一服",
                "domain": "http://127.0.0.1:8000",
                "plat": "dev",
                "state": 1,
                "tags": 0,
                "open_time": int(time.time()),
            }
        }
    else:
        sys.exit()

#  ==================== REDIS & MYSQL ======================  #
redis_client = app.get_storage_engine('redis').client.current

redis_client.hmset("xtzj.%s.config" % PLAT.lower(), pconfig)
redis_client.hmset("xtzj.%s.plats" % PLAT.lower(), platconfig)
redis_client.hset("xtzj.%s.servers" % PLAT.lower(), sconfig["server_id"], pickle.dumps(sconfig["server_config"]))

# from sqlalchemy import create_engine
# mysql = app.get_storage_engine("mysql")
# mysql_master_config = mysql.servers["master"] # ("10.137.218.249:3306", "admin", "Whwj12345*", "xtzj_game_whwj")

# pair = mysql_master_config[0].split(":")
# mysql_host = pair[0]

# admin_mysql_name = "xtzj_admin"
# mysql_engine = create_engine("mysql://%s:%s@%s/%s?charset=utf8&connect_timeout=3" % (mysql_master_config[1], mysql_master_config[2], mysql_host, admin_mysql_name), pool_recycle=7200)
Exemplo n.º 5
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# @Date : 2015-10-10 11:15:58
# @Author : Jiank (http://jiankg.github.com)
# @doc
#     物品兑换码服务
# @end
# @copyright (C) 2015, kimech

from libs.rklib.core import app

mysql_engine = app.get_storage_engine("mysql")

def check_code_exist(code):
    """检测兑换码是否存在

    Args:
        code 兑换码
    """
    key_tag = code[:4]
    try:
        result = mysql_engine.master_get("SELECT * FROM cdkey_%s WHERE code = '%s'" % (key_tag, code))
        if result:
            return True
        else:
            return False
    except:
        return False

def check_code_used_by_other(code):
Exemplo n.º 6
0
# @doc
#     物品兑换码服务
# @end
# @copyright (C) 2015, kimech

import copy
import time
import logging
import datetime

from libs.rklib.core import app
from torngas.settings_manager import settings

from apps.configs import rediskey_config

redis_client = app.get_storage_engine('redis').client.current
mysql_engine = app.get_storage_engine("mysql")


def add_uid_paid_set(uid):
    """把充值已付费的玩家uid放入集合 等待通知ta
    """
    redis_client.sadd(rediskey_config.CHARGE_PAID_SET_KEY, str(uid))


def ismember_of_paid_set(uid):
    """检查玩家是否在充值已付费名单中
    """
    result = redis_client.sismember(rediskey_config.CHARGE_PAID_SET_KEY,
                                    str(uid))