コード例 #1
0
ファイル: game_user.py プロジェクト: DJune12138/flask_demo
def get_game_user_detail():
    status_msg = dict()
    status_msg['beginDate'] = False
    status_msg['endDate'] = False
    status_msg['access_level'] = session['access_level']
    status_msg['PlayerID'] = ""
    status_msg['NickName'] = ""
    status_msg['date1'] = time_util.formatDate(time_util.now_sec() - 7 * 86400)
    status_msg['date2'] = time_util.formatDate(time_util.now_sec())

    return render_template('user_game_detail.html',
                           status_msg=status_msg,
                           base_player={})
コード例 #2
0
def show_player_money_details():
    """玩家加扣款页面"""

    status_msg = dict()
    status_msg['beginDate'] = False
    status_msg['endDate'] = False
    status_msg['access_level'] = session['access_level']
    status_msg['PlayerID'] = ""
    status_msg['NickName'] = ""
    status_msg['date1'] = time_util.formatDate(time_util.now_sec() - 7 * 86400)
    status_msg['date2'] = time_util.formatDate(time_util.now_sec())

    return render_template('player_monies.html',
                           status_msg=status_msg,
                           base_player={})
コード例 #3
0
def search_daily_presentation_today():
    present_type = int(request.args.get('present_type'))
    channel = session['select_channel']
    start = request.args.get('beginDate')
    today0 = time_util.today0()

    pre_line = dict()
    pre_line['date_text'] = time_util.formatDate(today0)

    # 注册人数
    sql = '''
        select count(1)
        from log_role_reg
        where time >= %d
    ''' % (today0)
    pre_line['reg_count'] = LogQry(channel).qry(sql)[0][0]

    # 活跃人数
    sql = '''
        select count(distinct pid)
        from log_account_login
        where time >= %d
    ''' % (today0)
    pre_line['active_count'] = LogQry(channel).qry(sql)[0][0]

    pre_line['bankrupt_player_count'] = 0
    pre_line['bankrupt_count'] = 0

    ## 查询赠送情况
    sql0 = '''
        select count(1), ifnull(sum(money), 0), ifnull(sum(pump), 0), count(distinct give_id), count(distinct recv_id)
        from log_bank_give
        where time >= %d
        %s
    '''
    if present_type == 0:
        sql = sql0 % (today0, "")
    elif present_type == 1:
        sql = sql0 % (today0, "and give_agent = 0 and recv_agent = 0")
    elif present_type == 2:
        sql = sql0 % (today0, "and give_agent = 0 and recv_agent = 1")
    elif present_type == 3:
        sql = sql0 % (today0, "and give_agent = 1 and recv_agent = 1")
    elif present_type == 4:
        sql = sql0 % (today0, "and give_agent = 1 and recv_agent = 0")

    [total_give_times, total_give_coin, total_give_pump, total_give_player_num, total_recv_player_num] = \
        LogQry(channel).qry(sql)[0]

    pre_line['money'] = float(total_give_coin)
    pre_line['pump'] = float(total_give_pump)
    pre_line['give_count'] = total_give_player_num
    pre_line['recv_count'] = total_recv_player_num
    pre_line['present_count'] = total_give_times
    pre_line['averge_presentation'] = 0
    if total_give_times > 0:
        pre_line['averge_presentation'] = total_give_coin / total_give_times

    return jsonify(result='ok', data=[pre_line])
コード例 #4
0
def get_today_topup():
    channel_id = session['select_channel']
    today0 = time_util.today0()

    pre_line = {}
    pre_line['date_text'] = time_util.formatDate(today0)

    # 注册人数
    sql = '''
        select count(1)
        from log_role_reg
        where time >= %d
    ''' % (today0)
    pre_line['reg_count'] = LogQry(channel_id).qry(sql)[0][0]

    # 活跃人数
    sql = '''
        select count(distinct pid)
        from log_account_login
        where time >= %d
    ''' % (today0)
    pre_line['active_count'] = LogQry(channel_id).qry(sql)[0][0]

    # 充值相关
    sql = '''
        select count(1), ifnull(sum(cost), 0), count(distinct pid)
        from admin_recharge
        where time >= %d
        and state = 1
    ''' % (today0)
    Result = LogQry(channel_id).qry(sql)[0]
    pre_line['recharge_count'] = Result[0]
    pre_line['total_recharge'] = float(Result[1])
    pre_line['recharge_player_num'] = Result[2]

    ## 当日新增充值情况
    pre_line['recharge_count_reg'] = 0
    pre_line['total_recharge_reg'] = 0
    pre_line['recharge_count2_reg'] = 0
    sql = '''
        select pid, sum(cost), count(1)
        from admin_recharge a, player p
        where time >= %d
        and state = 1
        and a.pid = p.id
        and p.reg_time >= %d
    ''' % (today0, today0)
    for pid, cost, num in LogQry(channel_id).qry(sql):
        if not pid:
            continue
        ## 当日注册充值人数
        pre_line['recharge_count_reg'] += 1
        ## 当日注册充值总额
        pre_line['total_recharge_reg'] += cost
        ## 当日注册多次充值人数
        if num > 1:
            pre_line['recharge_count2_reg'] += 1

    return jsonify(result='ok', data=[pre_line])
コード例 #5
0
def search_player_money_detail():
    """玩家搜索"""

    access_level = session['access_level']
    PID = request.args.get('PlayerID', '')
    NickName = request.args.get('NickName', '')
    # 接收渠道id
    channel = session['select_channel']

    print access_level, "access_level"

    status_msg = dict()
    status_msg['beginDate'] = False
    status_msg['endDate'] = False
    status_msg['access_level'] = access_level
    status_msg['PlayerID'] = PID
    status_msg['NickName'] = NickName
    status_msg['channel'] = channel
    status_msg['date1'] = time_util.formatDate(time_util.now_sec() - 7 * 86400)
    status_msg['date2'] = time_util.formatDate(time_util.now_sec())

    WHERE = ""
    if PID:
        WHERE += " and id = %s" % PID
    if NickName:
        WHERE += " and nick = '%s'" % NickName

    if not WHERE:
        return render_template('player_monies.html',
                               status_msg=status_msg,
                               base_player={})

    sql = '''
        select id, nick, reg_time, client_id, reg_ip,
            coin, counter, device, did, last_login_ip,
            phone, last_login_time, did, subgame, total_recharge_rmb,
            total_withdraw, time_long, (select count(1) from t_player_general where pid = a.id),
                ifnull((select p_code from player_agent where pid = a.id), ""),
                ifnull((select invite_code from player_agent where pid = a.id), ""),
            ban, account_id
        from player a
        where 1=1 %s
    ''' % WHERE

    base_player = {}
    for line in LogQry(channel).qry(sql):
        status_msg['PlayerID'] = line[0]
        base_player["id"] = line[0]
        base_player["nick"] = line[1]
        base_player["reg_time"] = time_util.formatDateTime(line[2])
        base_player["channel_id"] = line[3]
        base_player["reg_ip"] = line[4]
        base_player["account_id"] = line[21]

        coin = GameWeb(channel).post("/api/get_player_info",
                                     {'pid': int(line[0])})['result']['coin']
        bank = GameWeb(channel).post("/api/get_player_info",
                                     {'pid': int(line[0])})['result']['dep']
        base_player["coin"] = game_util.coin_translate(channel, coin)
        base_player["banker"] = game_util.coin_translate(channel, bank)

        base_player["platform"] = line[7]
        base_player["did"] = line[8]
        base_player["last_login_ip"] = line[9]

        base_player["phone"] = line[10]
        base_player["last_login_time"] = time_util.formatDateTime(line[11])
        base_player["did"] = line[12]

        base_player["subgame"] = game_parameter.get_subgame_name(line[13])
        base_player["total_recharge_rmb"] = line[14]

        base_player["total_withdraw"] = line[15]
        base_player["time_long"] = line[16]
        base_player["game_count"] = line[17]
        base_player["p_code"] = line[18]
        base_player["invite_code"] = line[19]
        base_player["status"] = get_player_state(line[20])

        ## 查询新手卡数
        sql = '''
            select count(1)
            from log_activity
            where activity_type = 4
            and detail like '%%%d,%%'
        ''' % line[0]
        base_player["newbie_card"] = LogQry(channel).qry(sql)[0][0]

    return render_template('player_monies.html',
                           status_msg=status_msg,
                           base_player=base_player)
コード例 #6
0
ファイル: game_user.py プロジェクト: DJune12138/flask_demo
def prestented_data_tj():
    PID = request.args.get('PlayerID', '')
    # 接收渠道id
    channel = session['select_channel']
    NickName = request.args.get('NickName', '')
    date1 = time_util.formatDatestamp(request.args.get('date1'))
    date2 = time_util.formatDatestamp(request.args.get('date2')) + 86400

    ## 查询玩家ID
    Where = ""
    if NickName:
        Where += "and nick = '%s'" % NickName
    if PID:
        Where += " and id = %s" % PID
    print "WHERE:", Where
    if not Where:
        return jsonify([])
    PID = LogQry(channel).qry("select id from player where 1 =1 %s" %
                              Where)[0][0]

    sql = '''
        select time, give_id, recv_id, money, pump
        from log_bank_give
        where time >= %d and time <= %d
        and (give_id = %d or recv_id = %d)
        order by time
    ''' % (date1, date2, PID, PID)

    datas = []
    pre_date = 0
    pre_record = {}
    print sql
    for search_data in LogQry(channel).qry(sql):
        cur_date = time_util.formatDate(search_data[0])

        if cur_date == pre_date:
            if search_data[1] == PID:
                ## 卖分
                pre_record[
                    "down_coin"] = pre_record["down_coin"] + search_data[3]
            if search_data[2] == PID:
                ## 卖分
                pre_record["up_coin"] = pre_record["up_coin"] + search_data[3]
            pre_record["pump"] = pre_record["pump"] + search_data[4]
            pre_record["count"] = pre_record["count"] + 1
            continue

        if pre_record:
            datas.append(pre_record)

        pre_record = {}
        pre_date = cur_date
        pre_record['time'] = cur_date
        pre_record["up_coin"] = 0
        pre_record["down_coin"] = 0
        if search_data[1] == PID:
            ## 卖分
            pre_record["down_coin"] = search_data[3]
        if search_data[2] == PID:
            ## 卖分
            pre_record["up_coin"] = search_data[3]
        pre_record["pump"] = search_data[4]
        pre_record["count"] = 1

    if pre_record:
        datas.append(pre_record)

    total_count = len(datas)

    return jsonify({
        "errcode": 0,
        "dataLength": total_count,
        "rowDatas": datas
    })
コード例 #7
0
def search_distribution_detail():
    date = request.args.get('date')
    start = request.args.get('beginDate')
    end = request.args.get('endDate')
    agent_id = request.args.get('agent_id', '')
    channel_id = session['select_channel']

    if date:
        start_date = time_util.formatDatestamp(date)
        end_date = time_util.formatDatestamp(date)
    elif start and end:
        start_date = time_util.formatDatestamp(start)
        end_date = time_util.formatDatestamp(end)

    status_msg = init_status_msg(begin=start_date,
                                 end=end_date,
                                 channel=channel_id,
                                 OThers_list=[{
                                     'agent_id': agent_id
                                 }])

    if start_date > end_date:
        status_msg['errmsg'] = u"终止日期不能小于起始日期"
        return render_template('distribution_detail.html',
                               status_msg=status_msg)

    if agent_id:
        agent_str = ' AND pid=%s' % agent_id
    else:
        status_msg['errmsg'] = u"请输入代理游戏ID查询"
        return render_template('distribution_detail.html',
                               status_msg=status_msg)

    search_t_sql = """SELECT time, pid, pump, pump1, pump2, pump3, nick
                    FROM t_distribution_day 
                    LEFT JOIN 
                    player ON pid=id 
                    WHERE time>=%d 
                    AND time<%d 
                    %s;""" \
                   % (start_date, end_date + 86400, agent_str)
    print search_t_sql

    game_db_qrl = LogQry(int(channel_id))
    t_pump_datas = game_db_qrl.qry(search_t_sql)
    print t_pump_datas

    allday_datas = []
    for day_stamp, pid, pump, pump1, pump2, pump3, nick in t_pump_datas:
        day_dict = dict()
        day_dict['date'] = time_util.formatDate(day_stamp)
        day_dict['channel_id'] = channel_id
        day_dict['pid'] = pid
        day_dict['nick'] = nick
        day_dict['pump'] = pump
        day_dict['pump1'] = 0
        day_dict['pump2'] = 0
        day_dict['pump3'] = 0
        day_dict['pump1_list'] = []
        day_dict['pump2_list'] = []
        day_dict['pump3_list'] = []
        for pid_1, pump11 in json.loads(pump1).items():
            pump1_dict = dict()
            day_dict['pump1'] += pump11

            select_sql = """SELECT nick from player WHERE id=%s""" % pid_1
            player_nick = game_db_qrl.qry(select_sql)[0][0]
            pump1_dict['pid'] = pid_1
            pump1_dict['nick'] = player_nick
            pump1_dict['pump'] = pump11
            day_dict['pump1_list'].append(pump1_dict)

        for pid_2, pump22 in json.loads(pump2).items():
            pump2_dict = dict()
            day_dict['pump2'] += pump22

            select_sql = """SELECT nick from player WHERE id=%s""" % pid_2
            player_nick = game_db_qrl.qry(select_sql)[0][0]
            pump2_dict['pid'] = pid_2
            pump2_dict['nick'] = player_nick
            pump2_dict['pump'] = pump22
            day_dict['pump2_list'].append(pump2_dict)

        for pid_3, pump33 in json.loads(pump3).items():
            pump3_dict = dict()
            day_dict['pump3'] += pump33

            select_sql = """SELECT nick from player WHERE id=%s""" % pid_3
            player_nick = game_db_qrl.qry(select_sql)[0][0]
            pump3_dict['pid'] = pid_3
            pump3_dict['nick'] = player_nick
            pump3_dict['pump'] = pump33
            day_dict['pump3_list'].append(pump3_dict)
        allday_datas.append(day_dict)

    return render_template('distribution_detail.html',
                           status_msg=status_msg,
                           datas=allday_datas)
コード例 #8
0
def search_distribution_daily():
    start = request.args.get('beginDate')
    end = request.args.get('endDate')
    agent_id = request.args.get('agent_id', '')
    channel_id = session['select_channel']

    if agent_id:
        agent_str = ' AND pid=%s' % agent_id
    else:
        agent_str = ''

    start_date = time_util.formatDatestamp(start)
    end_date = time_util.formatDatestamp(end)

    status_msg = init_status_msg(begin=start_date,
                                 end=end_date,
                                 channel=channel_id,
                                 OThers_list=[{
                                     'agent_id': agent_id
                                 }])

    if start_date > end_date:
        status_msg['errmsg'] = u"终止日期不能小于起始日期"
        return render_template('distribution_daily.html',
                               status_msg=status_msg)

    search_t_sql = """SELECT time, pid, pump, pump1, pump2, pump3, nick
                    FROM t_distribution_day 
                    LEFT JOIN player 
                    ON pid=id 
                    WHERE time>=%d 
                    AND time<%d 
                    %s ORDER BY time;""" \
                   % (start_date, end_date + 86400, agent_str)

    game_db_qrl = LogQry(int(channel_id))
    t_pump_datas = game_db_qrl.qry(search_t_sql)

    allday_datas = []
    day_dict = dict()
    for day_stamp, pid, pump, pump1, pump2, pump3, nick in t_pump_datas:
        day_dict['date'] = time_util.formatDate(day_stamp)
        day_dict['channel_id'] = channel_id
        day_dict['pid'] = pid
        day_dict['nick'] = nick
        day_dict['pump'] = pump
        day_dict['pump1'] = 0
        day_dict['pump2'] = 0
        day_dict['pump3'] = 0
        for pid_1, pump11 in json.loads(pump1).items():
            day_dict['pump1'] += pump11
        for pid_2, pump22 in json.loads(pump2).items():
            day_dict['pump2'] += pump22
        for pid_3, pump33 in json.loads(pump3).items():
            day_dict['pump3'] += pump33
        allday_datas.append(day_dict)
        day_dict = {}

    return render_template('distribution_daily.html',
                           status_msg=status_msg,
                           datas=allday_datas)
コード例 #9
0
def search_agent_presentation():
    start = request.args.get('beginDate', '')
    end = request.args.get('endDate', '')
    player_id = request.args.get('player_id', '')
    channel = session['select_channel']

    start_date = formatDatestamp(start)
    end_date = formatDatestamp(end)

    if start_date > end_date:
        return jsonify(result='fail', msg=u'结束时间不能小于开始时间!')

    where1 = ""
    where2 = ""
    if player_id:
        where1 = "and give_id = %s" % player_id
        where2 = "and recv_id = %s" % player_id

    datas = {}
    PIDS = {}
    start_date1 = start_date
    while start_date1 <= end_date:
        ## 查询当日赠送情况
        date = time_util.formatDate(start_date1)
        sql = '''
            SELECT give_id, sum(if(recv_agent = 0, money, 0)), sum(if(recv_agent = 0, pump, 0)), 
                    sum(if(recv_agent = 1, money, 0)), sum(if(recv_agent = 1, pump, 0))
            FROM log_bank_give 
            WHERE time>=%d 
            AND time<=%d 
            AND give_agent = 1
            %s
            group by give_id
        ''' % (start_date1, start_date1 + 86400, where1)
        for line in LogQry(channel).qry(sql):
            PIDS[str(line[0])] = True
            r = init_agent_daily_data()
            r["dateStamp"] = date
            r["total_down_coin"] = float(line[1])
            r["total_down_coin_pump"] = float(line[2])
            r["total_agent_present"] = float(line[3])
            r["total_agent_present_pump"] = float(line[4])
            datas[line[0]] = r

        ## 查询当日被赠送情况
        sql = '''
            SELECT recv_id, sum(if(give_agent = 0, money, 0)), sum(if(give_agent = 0, pump, 0)), 
                    sum(if(give_agent = 1, money, 0)), sum(if(give_agent = 1, pump, 0))
            FROM log_bank_give 
            WHERE time>=%d 
            AND time<=%d 
            AND recv_agent = 1
            %s
            group by recv_id
        ''' % (start_date1, start_date1 + 86400, where2)
        for line in LogQry(channel).qry(sql):
            PIDS[str(line[0])] = True
            if datas.has_key(line[0]):
                r = datas[line[0]]
            else:
                r = init_agent_daily_data()
            r["dateStamp"] = date
            r["total_up_coin"] = float(line[1])
            r["total_up_coin_pump"] = float(line[2])
            r["total_agent_recv"] = float(line[3])
            r["total_agent_recv_pump"] = float(line[4])
            datas[line[0]] = r

        start_date1 += 86400
    ## 查询这些代理的昵称
    pdatas = {}
    if PIDS:
        sql = '''
            select id, nick 
            from player
            where id in (%s)
        ''' % ",".join(PIDS.keys())
        for line in LogQry(channel).qry(sql):
            pdatas[line[0]] = line[1]

    return jsonify(result='ok', data=datas, pdatas=pdatas)