コード例 #1
0
def get_user_mail_list(server_id, name, source_id=0, page=1, pagesize=20):
    db_config = server_business.get_server_db_connect(server_id=server_id)
    total, infos = 0, []
    connect = get_connection(db_config)
    cursor = connect.cursor()
    try:
        user_info = cursor.fetchone("select user_id from user where username='******'" % name)
        if not user_info:
            user_info = cursor.fetchone("select user_id from user where lodo_id='%s'" % name)
        if user_info:
            user_id = user_info["user_id"]
            table_index = table_util.get_table_index(user_id)
            table = "user_mail_%s" % table_index
            where = "user_id = '%s' " % user_id
            if source_id:
                mail_info = cursor.fetchone("select * from system_mail where source_id = %s " % source_id)
                if mail_info:
                    where += " and system_mail_id = '%s' " % mail_info["system_mail_id"]
                else:
                    where += " and system_mail_id = '-1' "
            total = cursor.fetchone("select count(1) as total from %s where %s " % (table, where))["total"]
            if total > 0:
                start = (page - 1) * pagesize
                infos = cursor.fetchall("select * from %s where %s order by created_time desc limit %s, %s" % (table, where, start, pagesize))
                
                infos = infos.to_list()
                for info in infos:
                    info["mail_info"] = cursor.fetchone("select * from system_mail where system_mail_id ='%s'" % info["system_mail_id"])
    finally:
        cursor.close()
        
    return total, infos
コード例 #2
0
def get_user_tool_use_log(server_id,
                          name,
                          start_time,
                          end_time,
                          use_type=0,
                          flag=0,
                          page=1,
                          pagesize=20,
                          tool_type=0,
                          tool_id=0):
    """获取用户道具日志"""
    start = (page - 1) * pagesize
    limit = pagesize

    db_config = server_business.get_server_db_connect(server_id=server_id)
    connect = get_connection(db_config)
    cursor = connect.cursor()
    total, infos = 0, []
    try:
        user_info = cursor.fetchone("select * from user where lodo_id='%s'" %
                                    name)
        if not user_info:
            user_info = cursor.fetchone(
                "select * from user where username='******'" % name)
        if user_info:
            user_id = user_info['user_id']
            table = "user_tool_use_log_%s" % table_util.get_table_index(
                user_id)
            where = " user_id = '%s' " % user_id
            if use_type:
                where += " and use_type = %s " % use_type
            if flag:
                where += " and flag = %s " % flag
            if tool_type:
                where += " and tool_type = %s " % tool_type
            if tool_id:
                where += " and tool_id = %s " % tool_id
            if start_time:
                where += " and created_time >= '%s' " % start_time
            if end_time:
                where += " and created_time <= '%s' " % end_time
            sql = "select count(1) as total from %s where %s " % (table, where)
            total = cursor.fetchone(sql)["total"]
            if total > 0:
                sql = "select * from %s where %s order by log_id desc limit %s, %s" % (
                    table, where, start, limit)
                infos = cursor.fetchall(sql)
                infos = infos.to_list()
    finally:
        cursor.close()

    return total, infos
コード例 #3
0
def get_user_hero_log(server_id, name, hero_name, start_time, end_time, use_type=0, flag=0, page=1, pagesize=20):
    """获取用户武将日志"""
    start = (page - 1)  * pagesize
    limit = pagesize
    
    db_config = server_business.get_server_db_connect(server_id=server_id)
    connect = get_connection(db_config)
    cursor = connect.cursor()
    total, infos = 0, []    
    try:
        user_info = cursor.fetchone("select * from user where lodo_id='%s'" % name)
        if not user_info:
            user_info = cursor.fetchone("select * from user where username='******'" % name)
        if user_info:
            user_id = user_info['user_id']
            table = "user_hero_log_%s" % table_util.get_table_index(user_id)
            
            where = " user_id = '%s' " % user_info['user_id']
            if use_type:
                where += " and use_type = %s " % use_type
            if flag:
                where += " and flag = %s " % flag
            if start_time:
                where += " and created_time >= '%s' " % start_time
            if end_time:
                where += " and created_time <= '%s' " % end_time
            if hero_name:
                where += " and system_hero_id in (select system_hero_id from system_hero where hero_name like '%%%s%%') " % hero_name
            sql = "select count(1) as total from %s where %s " % (table, where)
            total = cursor.fetchone(sql)["total"]
            if total > 0:
                sql = "select * from %s where %s order by log_id desc limit %s, %s" % (table, where, start, limit)
                
                infos = cursor.fetchall(sql)
                
                hero_info_map = {}
                infos = infos.to_list()
                for info in infos:
                    system_hero_id = info["system_hero_id"]
                    if system_hero_id in hero_info_map:
                        hero_info = hero_info_map[system_hero_id]
                    else:
                        hero_info =  cursor.fetchone("select * from system_hero where system_hero_id = %s " % system_hero_id )
                    if hero_info:
                        hero_info_map[system_hero_id] = hero_info
                    info["hero_info"] = hero_info
                    
                
    finally:
        cursor.close()
        
    return total, infos
コード例 #4
0
def open_all_scene(server_id, user_id):
    db_config = server_business.get_server_db_connect(server_id=server_id)
    table = "user_forces_%s" % table_util.get_table_index(user_id)

    connect = get_connection(db_config)
    cursor = connect.cursor()
    try:
        sql = OPEN_FORCES_SQL % (table, user_id, table, user_id)
        cursor.execute(sql)
    finally:
        cursor.close()

    return True
コード例 #5
0
def open_all_scene(server_id, user_id):
    db_config = server_business.get_server_db_connect(server_id=server_id)
    table = "user_forces_%s" % table_util.get_table_index(user_id)
    
    connect = get_connection(db_config)
    cursor = connect.cursor()
    try:
        sql = OPEN_FORCES_SQL % (table, user_id, table, user_id)
        cursor.execute(sql)
    finally:
        cursor.close()
        
    return True
コード例 #6
0
def get_user_mail_list(server_id, name, source_id=0, page=1, pagesize=20):
    db_config = server_business.get_server_db_connect(server_id=server_id)
    total, infos = 0, []
    connect = get_connection(db_config)
    cursor = connect.cursor()
    try:
        user_info = cursor.fetchone(
            "select user_id from user where username='******'" % name)
        if not user_info:
            user_info = cursor.fetchone(
                "select user_id from user where lodo_id='%s'" % name)
        if user_info:
            user_id = user_info["user_id"]
            table_index = table_util.get_table_index(user_id)
            table = "user_mail_%s" % table_index
            where = "user_id = '%s' " % user_id
            if source_id:
                mail_info = cursor.fetchone(
                    "select * from system_mail where source_id = %s " %
                    source_id)
                if mail_info:
                    where += " and system_mail_id = '%s' " % mail_info[
                        "system_mail_id"]
                else:
                    where += " and system_mail_id = '-1' "
            total = cursor.fetchone(
                "select count(1) as total from %s where %s " %
                (table, where))["total"]
            if total > 0:
                start = (page - 1) * pagesize
                infos = cursor.fetchall(
                    "select * from %s where %s order by created_time desc limit %s, %s"
                    % (table, where, start, pagesize))

                infos = infos.to_list()
                for info in infos:
                    info["mail_info"] = cursor.fetchone(
                        "select * from system_mail where system_mail_id ='%s'"
                        % info["system_mail_id"])
    finally:
        cursor.close()

    return total, infos
コード例 #7
0
def get_user_tool_use_log(server_id, name, start_time, end_time, use_type=0, flag=0, page=1, pagesize=20, tool_type=0, tool_id=0):
    """获取用户道具日志"""
    start = (page - 1)  * pagesize
    limit = pagesize
    
    db_config = server_business.get_server_db_connect(server_id=server_id)
    connect = get_connection(db_config)
    cursor = connect.cursor()
    total, infos = 0, []    
    try:
        user_info = cursor.fetchone("select * from user where lodo_id='%s'" % name)
        if not user_info:
            user_info = cursor.fetchone("select * from user where username='******'" % name)
        if user_info:
            user_id = user_info['user_id']
            table = "user_tool_use_log_%s" % table_util.get_table_index(user_id)
            where = " user_id = '%s' " % user_id
            if use_type:
                where += " and use_type = %s " % use_type
            if flag:
                where += " and flag = %s " % flag
            if tool_type:
                where += " and tool_type = %s " % tool_type
            if tool_id:
                where += " and tool_id = %s " % tool_id
            if start_time:
                where += " and created_time >= '%s' " % start_time
            if end_time:
                where += " and created_time <= '%s' " % end_time
            sql = "select count(1) as total from %s where %s " % (table, where)
            total = cursor.fetchone(sql)["total"]
            if total > 0:
                sql = "select * from %s where %s order by log_id desc limit %s, %s" % (table, where, start, limit)
                infos = cursor.fetchall(sql)
                infos = infos.to_list();
    finally:
        cursor.close()
        
    return total, infos
コード例 #8
0
def get_user_hero_log(server_id,
                      name,
                      hero_name,
                      start_time,
                      end_time,
                      use_type=0,
                      flag=0,
                      page=1,
                      pagesize=20):
    """获取用户武将日志"""
    start = (page - 1) * pagesize
    limit = pagesize

    db_config = server_business.get_server_db_connect(server_id=server_id)
    connect = get_connection(db_config)
    cursor = connect.cursor()
    total, infos = 0, []
    try:
        user_info = cursor.fetchone("select * from user where lodo_id='%s'" %
                                    name)
        if not user_info:
            user_info = cursor.fetchone(
                "select * from user where username='******'" % name)
        if user_info:
            user_id = user_info['user_id']
            table = "user_hero_log_%s" % table_util.get_table_index(user_id)

            where = " user_id = '%s' " % user_info['user_id']
            if use_type:
                where += " and use_type = %s " % use_type
            if flag:
                where += " and flag = %s " % flag
            if start_time:
                where += " and created_time >= '%s' " % start_time
            if end_time:
                where += " and created_time <= '%s' " % end_time
            if hero_name:
                where += " and system_hero_id in (select system_hero_id from system_hero where hero_name like '%%%s%%') " % hero_name
            sql = "select count(1) as total from %s where %s " % (table, where)
            total = cursor.fetchone(sql)["total"]
            if total > 0:
                sql = "select * from %s where %s order by log_id desc limit %s, %s" % (
                    table, where, start, limit)

                infos = cursor.fetchall(sql)

                hero_info_map = {}
                infos = infos.to_list()
                for info in infos:
                    system_hero_id = info["system_hero_id"]
                    if system_hero_id in hero_info_map:
                        hero_info = hero_info_map[system_hero_id]
                    else:
                        hero_info = cursor.fetchone(
                            "select * from system_hero where system_hero_id = %s "
                            % system_hero_id)
                    if hero_info:
                        hero_info_map[system_hero_id] = hero_info
                    info["hero_info"] = hero_info

    finally:
        cursor.close()

    return total, infos