Ejemplo n.º 1
0
def agent_list_lower_agent():
    """代理列表下级代理查询"""
    channel_id = session['select_channel']
    ## 查询所有层级
    sql = 'select id, level_name from admin_agent_level'
    agent_level = {}
    for k, v in LogQry(channel_id).qry(sql):
        agent_level[k] = v

    # 获取参数
    pid = request.args.get('pid')
    size = request.args.get('size')
    offset = request.args.get('offset')

    ## 查询总数
    sql = 'select count(1) from player_agent where invite_id = %s' % pid
    total_count = LogQry(channel_id).qry(sql)[0][0]

    ## 查询代理列表
    sql = """
        SELECT (select agent_level from admin_agent_list where pid = a.pid), pid
        FROM player_agent a
        WHERE invite_id = %s
        LIMIT %s, %s;
    """ % (pid, offset, size)
    data = LogQry(int(channel_id)).qry(sql)
    data_list = list()
    for lv, pid in data:
        data_dict = dict()
        if lv:
            data_dict['agent_level'] = agent_level[lv]
        else:
            data_dict['agent_level'] = ""
        data_dict['pid'] = pid

        sql = '''
            select nick, coin, counter, reg_time, last_login_time 
            from player 
            where id = %d
        ''' % pid
        name, coin, counter, register_time, last_login_time = LogQry(
            channel_id).qry(sql)[0]

        data_dict['name'] = name
        data_dict['register_time'] = register_time
        data_dict['login_time'] = last_login_time
        data_dict['coin'] = coin
        data_dict['bank'] = game_util.get_bank_coin(counter)
        data_list.append(data_dict)

    # 返回数据
    return jsonify(result=1, data=data_list, dataLength=total_count)
Ejemplo n.º 2
0
def add_user_to_black():
    pid = int(request.json.get('pid'))
    channel_id = session['select_channel']
    remark = request.json.get('remark') if request.json.get('remark') else ''

    game_player_sql = """
        SELECT id, nick, total_recharge_rmb, total_withdraw, coin, 
            counter
        FROM player 
        WHERE id=%d""" % pid
    game_count_sql = """SELECT ifnull(sum(game_count), 0) FROM t_player_subgame WHERE pid=%d""" % pid

    game_db_qrl = LogQry(channel_id)
    player_data = game_db_qrl.qry(game_player_sql)
    game_count_data = game_db_qrl.qry(game_count_sql)

    total_recharge = player_data[0][2]
    total_withdraw = player_data[0][3]
    coin = player_data[0][4]
    counter = player_data[0][5]
    game_count = game_count_data[0][0]

    counter_v = game_util.get_bank_coin(counter)

    sql_oper = SqlOperate()
    insert_sql = """INSERT INTO admin_black_list VALUES(%d, %d, %d, %d, %d, %d, '%s')""" \
                 % (pid, total_recharge, total_withdraw, coin, counter_v, game_count, remark)
    print insert_sql
    try:
        LogQry(channel_id).execute(insert_sql)
    except Exception as e:
        print e
        return jsonify(errmsg='加入黑名单失败')

    sql = '''
        insert into admin_opt_log 
            (channel, log_type, operator, obj, val, 
            timestamp, maintype)
        values 
            (%d, %d, %d, %d, "", 
            %d, %d)
    ''' % (channel_id, log_type_d["black"], session['user_id'], pid,
           time_util.now_sec(), log_main_type_d["player"])
    LogQry(channel_id).execute(sql)

    payload = {"pid": pid, "handle": "blacklist", "hanle_val": 1}
    GameWeb(channel_id).post("/api/handle_player", payload)

    return jsonify(errmsg='加入黑名单成功')
Ejemplo n.º 3
0
def agent_list_retrieve():
    """代理列表查询"""

    # 获取参数
    channel_id = session['select_channel']
    agent_level = request.args.get('agent_level')
    PlayerID = request.args.get('PlayerID')
    NickName = request.args.get('NickName')
    Account = request.args.get('Account')
    # sort = request.args.get('sort')
    size = request.args.get('size')
    offset = request.args.get('offset')

    # 校验参数
    if (PlayerID and NickName) or (PlayerID and Account) or (NickName
                                                             and Account):
        return jsonify(result=0, msg=u'玩家ID、玩家昵称、玩家账号只能输入其一!')
    if PlayerID:
        try:
            int(PlayerID)
        except ValueError:
            return jsonify(result=0, msg=u'玩家ID为整数纯数字!')

    ## 判断是否有代理 没有则添加一个顶级代理
    sql = 'select count(1) from admin_agent_list where pid <> 0'
    if LogQry(channel_id).qry(sql)[0][0] == 0:
        sql = 'insert into admin_agent_list (pid, agent_level, status, pre_pid) values (0, 1, 1, 0)'
        LogQry(channel_id).execute(sql)

    # 处理参数
    where = ''
    if agent_level and agent_level != '0':
        where += ' AND agent_level=%s' % agent_level
    if PlayerID:
        where += ' AND pid=%s' % PlayerID
    elif NickName:
        retrieve_sql = """SELECT id
                          FROM player
                          WHERE nick='%s';""" % NickName
        pid = LogQry(channel_id).qry(retrieve_sql)[0][0]
        where += ' AND pid=%s' % pid
    elif Account:
        retrieve_sql = """SELECT id
                          FROM player
                          WHERE account_name='%s';""" % Account
        pid = LogQry(channel_id).qry(retrieve_sql)[0][0]
        where += ' AND pid=%s' % pid

    # 查询数据
    retrieve_sql = """SELECT count(*) FROM admin_agent_list where 1 = 1 %s;""" % where
    total_count = LogQry(channel_id).qry(retrieve_sql)[0][0]
    retrieve_sql = """SELECT (select level_name from admin_agent_level where id=agent_level),pid,status,pre_pid,
                                (select account_id from player where id=pid),
                              (select nick from player where id=pid),(select coin from player where id=pid) as coin,
                                (select counter from player where id=pid),
                                (select reg_time from player where id=pid) as reg_time,
                                (select last_login_time from player where id=pid) as last_login_time
                      FROM admin_agent_list
                      WHERE 1 = 1
                        %s
                      ORDER BY status DESC
                      LIMIT %s,%s;""" \
                   % (where, offset, size)
    data = LogQry(channel_id).qry(retrieve_sql)

    # 处理数据
    data_list = list()
    for lv, pid, status, pre_pid, account_id, \
        name, coin, counter, register_time, last_login_time in data:
        if pid == 0:
            continue
        data_dict = dict()
        data_dict['agent_level'] = lv
        data_dict['pid'] = pid
        data_dict['status'] = map_agent_status[status]
        data_dict['pre_pid'] = pre_pid
        data_dict['account_id'] = account_id
        data_dict['name'] = name
        data_dict['register_time'] = register_time
        data_dict['login_time'] = last_login_time
        data_dict['coin'] = coin
        data_dict['bank'] = game_util.get_bank_coin(counter)
        data_list.append(data_dict)

    # 返回数据
    return jsonify(result=1, data=data_list, dataLength=total_count)
Ejemplo n.º 4
0
def search_gold_rank():
    user_type = request.args.get('user_type')
    channel_id = session['select_channel']

    backend_agent_sql = "SELECT pid FROM admin_agent_list"
    agent_tup = LogQry(channel_id).qry(backend_agent_sql)

    agent_id_list = list()
    for agent_id in agent_tup:
        agent_id_list.append(agent_id[0])

    if user_type == '0':
        user_type_str = "1=1"
    elif user_type == '1':
        if len(agent_id_list) == 0:
            user_type_str = '1=1'
        else:
            user_type_str = 'id NOT IN %s' % str(tuple(agent_id_list))
    else:
        if len(agent_id_list) == 0:
            user_type_str = '1=0'
        else:
            user_type_str = 'id IN %s' % str(tuple(agent_id_list))

    search_sql = """SELECT id, nick, total_recharge_rmb, total_withdraw, coin, counter, last_login_ip, delivery_address 
                    FROM player 
                    WHERE %s
                    ORDER BY coin DESC LIMIT 100;""" % user_type_str

    game_db_qrl = LogQry(channel_id)

    coin_rank_datas = game_db_qrl.qry(search_sql)

    player_rank_list = list()
    pid_list = list()
    player_dict = dict()
    i = 1  # 排名
    for pid, nick, total_recharge, total_withdraw, coin, counter, last_login_ip, delivery_address in coin_rank_datas:
        pid_list.append(pid)
        player_dict['pid'] = pid
        player_dict['nick'] = nick
        player_dict['total_recharge'] = total_recharge
        player_dict['total_withdraw'] = total_withdraw
        player_dict['coin'] = coin
        player_dict['last_login_ip'] = last_login_ip
        player_dict['counter'] = get_bank_coin(counter)
        player_dict['game_count'] = 0
        player_dict['rank'] = i
        player_rank_list.append(player_dict)
        player_dict = dict()
        i += 1

    if len(pid_list) == 1:
        pid_str = '(' + str(pid_list[0]) + ')'
    elif len(pid_list) == 0:
        pid_str = '(0)'
    else:
        pid_str = str(tuple(pid_list))

    game_count_sql = """SELECT pid, time, game_count
                        FROM t_player_subgame
                        WHERE pid IN %s
                        ORDER BY time desc""" \
                     % pid_str

    game_count_datas = game_db_qrl.qry(game_count_sql)

    game_count_dict = dict()
    for pid, time_stamp, game_count in game_count_datas:
        if not game_count_dict.has_key(pid):
            game_count_dict[pid] = game_count
        game_count_dict[pid] += game_count

    for pid, game_count in game_count_dict.items():
        for value_dict in player_rank_list:
            if value_dict['pid'] == pid:
                value_dict['game_count'] = game_count

    return jsonify(result='ok', data=player_rank_list)
Ejemplo n.º 5
0
def search_game_user_data():
    start = request.args.get('beginDate', '')
    end = request.args.get('endDate', '')
    player_id = request.args.get('PlayerID', '')
    nick = request.args.get('NickName', '')
    reg_ip = request.args.get('reg_ip', '')
    # 接收渠道id
    channel = session['select_channel']
    level = int(request.args.get('level', ''))

    offset = int(request.args.get("offset"))
    pagesize = int(request.args.get("size"))

    Where = ""
    if player_id:
        Where += " AND p.id='%s'" % player_id
    if nick:
        Where += " AND p.nick='%s'" % nick
    if level > 0:
        Where += " AND p.vip=%d" % level
    if reg_ip:
        Where += " AND p.reg_ip='%s'" % reg_ip

    ## 判断是否是当日查询
    start_date = time_util.formatTimestamp(start)
    end_date = time_util.formatTimestamp(end)
    Where += ' AND p.reg_time >= %d ' % start_date
    Where += ' AND p.reg_time <= %d ' % end_date

    ## 查询满足条件的所有玩家
    sql = '''
        select count(1)
        from player p
        where 1 = 1
        %s
    ''' % Where
    total_count = LogQry(channel).qry(sql)[0][0]

    ## 查询所有层级
    memberl_lv = {}
    sql = '''
        select id, member_level_name
        from admin_member_level
    '''
    for k, v in LogQry(channel).qry(sql):
        memberl_lv[k] = v

    sql = '''
        select p.id, p.nick, p.reg_time, p.coin, 
                ifnull((select invite_id from player_agent where pid = p.id), ""),
            p.counter, p.last_login_time, p.account_id, p.vip, p.reg_ip
        from player as p
        where 1 =1 
        %s
        order by p.reg_time desc
        limit %d,%d
    ''' % (Where, offset, pagesize)
    pdatas = []
    for line in LogQry(channel).qry(sql):
        try:
            memberl_lv_name = memberl_lv[max(line[8], 1)]
        except:
            memberl_lv_name = line[8]
        d = {
            "id": line[0],
            "nick": line[1].encode("utf-8"),
            "reg_time": line[2],
            "coin": line[3] + game_util.get_bank_coin(line[5]),
            "agent": line[4],
            "last_login_time": line[6],
            "account_id": line[7],
            "memberl_lv": memberl_lv_name,
            "reg_ip": line[9]
        }
        pdatas.append(d)

    return jsonify({
        "errcode": 0,
        "dataLength": total_count,
        "rowDatas": pdatas
    })