Exemplo n.º 1
0
def search_daily_topup():
    start = request.args.get('beginDate', '')
    end = request.args.get('endDate', '')

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

    today0 = time_util.today0()
    if start_date == today0:
        return get_today_topup()

    channel_id = session['select_channel']

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

    start_date = int(time_util.formatTimeWithDesc(start_date, "%Y%m%d"))
    end_date = int(time_util.formatTimeWithDesc(end_date, "%Y%m%d"))
    search_sql = '''
        SELECT time, ifnull(sum(reg_count), 0), ifnull(sum(active_count), 0), 
                ifnull(sum(recharge_player_count), 0), ifnull(sum(recharge_count), 0),
            ifnull(sum(total_recharge), 0), ifnull(sum(withdraw), 0), ifnull(sum(withdraw_count), 0),
                ifnull(sum(recharge_count_reg), 0), ifnull(sum(total_recharge_reg), 0),
            ifnull(sum(recharge_count2_reg), 0)
        FROM t_system 
        WHERE time>=%d 
        AND time<=%d
        group by time
        ORDER BY time;
        ''' % (start_date, end_date)

    game_db_qrl = LogQry(int(channel_id))
    print search_sql
    alltime_search_datas = game_db_qrl.qry(search_sql)

    # 最终展示的数据列表
    allday_datas = []

    for line in alltime_search_datas:
        if not line[0]:
            continue
        pre_line = dict()
        pre_line['date_text'] = time_util.date_str(line[0])
        pre_line['reg_count'] = int(line[1])
        pre_line['active_count'] = int(line[2])
        pre_line['recharge_player_num'] = int(line[3])
        pre_line['recharge_count'] = int(line[4])
        pre_line['total_recharge'] = int(line[5])
        pre_line['withdraw'] = int(line[6])
        pre_line['withdraw_count'] = int(line[7])

        pre_line['recharge_count_reg'] = int(line[8])
        pre_line['total_recharge_reg'] = int(line[9])
        pre_line['recharge_count2_reg'] = int(line[10])
        allday_datas.append(pre_line)

    return jsonify(result='ok', data=allday_datas)
Exemplo n.º 2
0
def gen_order_no(channel, pay_channel):
    key = "%s_%s" % (PAY_ORDER_TABLE, channel)
    count = redis_conn.incrby(key)
    if count >= 90000:
        redis_conn.set(key, 0)
    datestr = time_util.formatTimeWithDesc(time_util.now_sec(), "%y%m%d%H%M%S")
    orderno = "%s_%s_%s%05d%03d" % (channel, pay_channel, datestr, count,
                                    rand(1, 999))

    return orderno
Exemplo n.º 3
0
def game_data_compare():
    beginDate1 = time_util.formatTimeWithDesc(time_util.now_sec() - 86400, '%Y-%m-%d')
    endDate1 = time_util.formatTimeWithDesc(time_util.now_sec() - 86400, '%Y-%m-%d')
    beginDate2 = time_util.formatTimeWithDesc(time_util.now_sec(), '%Y-%m-%d')
    endDate2 = time_util.formatTimeWithDesc(time_util.now_sec(), '%Y-%m-%d')
    status_msg = dict()
    status_msg['beginDate'] = False
    status_msg['endDate'] = False
    status_msg['OThers'] = [u'''<td colspan=1>
                                    日期1:<input class="Wdate" type="text" readonly onClick="WdatePicker({dateFmt:\'yyyy-mm-dd\'})" 
                                        id="beginDate1" name="beginDate1" value="%s" required>
                                    --<input class="Wdate" type="text" readonly onClick="WdatePicker({dateFmt:\'yyyy-mm-dd\'})" 
                                        id="endDate1" name="endDate1" value="%s" required> 
                            </td> ''' % (beginDate1, endDate1),
                            u'''<td colspan=1>数据对比</td> ''',
                            u'''<td colspan=1>
                                    日期2:<input class="Wdate" type="text" readonly onClick="WdatePicker({dateFmt:\'yyyy-mm-dd\'})" 
                                        id="beginDate2" name="beginDate2" value="%s" required>
                                    --<input class="Wdate" type="text" readonly onClick="WdatePicker({dateFmt:\'yyyy-mm-dd\'})" 
                                        id="endDate2" name="endDate2" value="%s" required> 
                            </td> ''' % (beginDate2, endDate2)]

    return render_template('game_data_compare.html', status_msg=status_msg, pre={}, cur={})
Exemplo n.º 4
0
def search_daily_presentation():
    start = request.args.get('beginDate', '')
    end = request.args.get('endDate', '')
    present_type = int(request.args.get('present_type'))
    channel = session['select_channel']

    start_date = time_util.formatDatestamp(start)
    end_date = time_util.formatDatestamp(end)
    today0 = time_util.today0()
    if start_date == today0:
        return search_daily_presentation_today()

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

    start_date = int(time_util.formatTimeWithDesc(start_date, "%Y%m%d"))
    end_date = int(time_util.formatTimeWithDesc(end_date, "%Y%m%d"))
    search_t_sql = """
        SELECT time, sum(reg_count), sum(active_count), sum(recharge_player_count), sum(bankrupt_player_count),
            sum(bankrupt_count), give_coin_a2a, give_coin_a2p, give_coin_p2a, give_coin_p2p
        FROM t_system 
        WHERE time>=%d 
        AND time<=%d 
        group by time
        """ % (start_date, end_date)

    ## 最终数据
    allday_datas = []
    for line in LogQry(channel).qry(search_t_sql):
        if not line[0]:
            ## 防止没有数据时报错
            continue
        pre_line = dict()
        pre_line['date_text'] = time_util.date_str(line[0])
        pre_line['reg_count'] = float(line[1])
        pre_line['active_count'] = float(line[2])
        pre_line['recharge_player_num'] = float(line[3])
        pre_line['bankrupt_player_count'] = float(line[4])
        pre_line['bankrupt_count'] = float(line[5])

        if present_type == 0:  ## 查询全部赠送情况
            D0 = json.loads(line[6])
            D1 = json.loads(line[7])
            D2 = json.loads(line[8])
            D3 = json.loads(line[9])
            total_give_times = D0["give_times"] + D1["give_times"] + D2[
                "give_times"] + D3["give_times"]
            total_give_coin = D0["give_coin"] + D1["give_coin"] + D2[
                "give_coin"] + D3["give_coin"]
            total_give_pump = D0["give_pump"] + D1["give_pump"] + D2[
                "give_pump"] + D3["give_pump"]
            total_give_player_num = D0["give_player_num"] + D1["give_player_num"] + D2["give_player_num"] \
                                    + D3["give_player_num"]
            total_recv_player_num = D0["recv_coin_player_num"] + D1["recv_coin_player_num"] + \
                                    D2["recv_coin_player_num"] + D3["recv_coin_player_num"]
        elif present_type == 1:
            D0 = json.loads(line[9])
            total_give_times = D0["give_times"]
            total_give_coin = D0["give_coin"]
            total_give_pump = D0["give_pump"]
            total_give_player_num = D0["give_player_num"]
            total_recv_player_num = D0["recv_coin_player_num"]
        elif present_type == 2:
            D0 = json.loads(line[8])
            total_give_times = D0["give_times"]
            total_give_coin = D0["give_coin"]
            total_give_pump = D0["give_pump"]
            total_give_player_num = D0["give_player_num"]
            total_recv_player_num = D0["recv_coin_player_num"]
        elif present_type == 3:
            D0 = json.loads(line[6])
            total_give_times = D0["give_times"]
            total_give_coin = D0["give_coin"]
            total_give_pump = D0["give_pump"]
            total_give_player_num = D0["give_player_num"]
            total_recv_player_num = D0["recv_coin_player_num"]
        elif present_type == 4:
            D0 = json.loads(line[7])
            total_give_times = D0["give_times"]
            total_give_coin = D0["give_coin"]
            total_give_pump = D0["give_pump"]
            total_give_player_num = D0["give_player_num"]
            total_recv_player_num = D0["recv_coin_player_num"]

        pre_line['money'] = total_give_coin
        pre_line['pump'] = 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

        allday_datas.append(pre_line)

    return jsonify(result='ok', data=allday_datas)
Exemplo n.º 5
0
def search_game_data_compare():
    start1 = request.args.get('beginDate1', '')
    end1 = request.args.get('endDate1', '')
    start2 = request.args.get('beginDate2', '')
    end2 = request.args.get('endDate2', '')
    channel = session['select_channel']

    start_date1 = time_util.start(start1)
    end_date1 = time_util.end(end1)
    start_date2 = time_util.start(start2)
    end_date2 = time_util.end(end2)

    if start_date1 > end_date1 or start_date2 > end_date2:
        return jsonify(result='fail', msg=u'结束时间不能小于开始时间!')

    # --------------------------
    # 页面左边日期输入框所查数据
    start_time1 = int(time_util.formatTimeWithDesc(start_date1, "%Y%m%d"))
    end_time1 = int(time_util.formatTimeWithDesc(end_date1, "%Y%m%d"))

    game_normal_sql_1 = """
            SELECT time, os, reg_count, active_count, total_recharge, game_win, withdraw
            FROM t_system
            WHERE time>=%d AND time<%d
            order by time desc;
        """ % (start_time1, end_time1)
    print 'game_normal_sql_1', game_normal_sql_1
    print LogQry(channel).qry(game_normal_sql_1)
    left_record = {
        "reg_count": 0,
        "active_count": 0,
        "game_win": 0,
        "up_coin": 0,
        "down_coin": 0,
        "recharge": 0,
        "withdraw": 0
    }
    left_pre_date = 0
    for time_int, platform, reg_count, active_count, total_recharge, game_win, withdraw in LogQry(channel).qry(
            game_normal_sql_1):
        left_record['reg_count'] += reg_count
        left_record['active_count'] += active_count
        left_record['recharge'] += total_recharge
        left_record['game_win'] += game_win
        left_record['withdraw'] += withdraw

    bank_give_sql_1 = """SELECT give_agent, recv_agent, money 
                            FROM log_bank_give
                            WHERE time>=%d AND time<%d 
                            AND ((give_agent=1 AND recv_agent=0) 
                            OR (give_agent=0 AND recv_agent=1));
                            """ % (start_date1, end_date1 + 86400)
    for give_agent, recv_agent, money in LogQry(channel).qry(bank_give_sql_1):
        if give_agent == 1:
            left_record['down_coin'] += money
        elif recv_agent == 1:
            left_record['up_coin'] += money
    print left_record, "left_record"
    # --------------------------
    # 页面右边日期输入框所查数据
    start_time2 = int(time_util.formatTimeWithDesc(start_date2, "%Y%m%d"))
    end_time2 = int(time_util.formatTimeWithDesc(end_date2, "%Y%m%d"))

    game_normal_sql_2 = """
            SELECT time, reg_count, active_count, total_recharge, game_win, withdraw
            FROM t_system
            WHERE time>=%d AND time<%d
            order by time desc;
        """ % (start_time2, end_time2)
    print game_normal_sql_2, start_time2

    right_record = {
        "reg_count": 0,
        "active_count": 0,
        "game_win": 0,
        "up_coin": 0,
        "down_coin": 0,
        "recharge": 0,
        "withdraw": 0
    }
    right_pre_date = 0
    for time_int, reg_count, active_count, total_recharge, game_win, withdraw in LogQry(channel).qry(
            game_normal_sql_2):
        right_record['reg_count'] += reg_count
        right_record['active_count'] += active_count
        right_record['recharge'] += total_recharge
        right_record['game_win'] += game_win
        right_record['withdraw'] += withdraw

    bank_give_sql_2 = """SELECT give_agent, recv_agent, money 
                            FROM log_bank_give
                            WHERE time>=%d AND time<%d 
                            AND ((give_agent=1 AND recv_agent=0) 
                            OR (give_agent=0 AND recv_agent=1));
                            """ % (start_date2, end_date2 + 86400)
    for give_agent, recv_agent, money in LogQry(channel).qry(bank_give_sql_2):
        if give_agent == 1:
            right_record['down_coin'] += money
        elif recv_agent == 1:
            right_record['up_coin'] += money

    return jsonify(result='ok', pre=left_record, cur=right_record)
Exemplo n.º 6
0
def search_bar(Action,
               beginDate=True,
               endDate=False,
               PT=False,
               SelectChannel=None,
               Channels=True,
               ChannelSize=1,
               PlayerID=False,
               NickName=False,
               Account=False,
               QueryType=2,
               OThers=[],
               Method="post",
               PrecisionSecond=False):

    Html = u'''
	<script src="/static/js/jquery-2.1.1.min.js"></script>
	<script src="/static/js/bootstrap.min.js"></script>
	<script src="/static/js/my97date/WdatePicker.js"></script>
	<script src="/static/js/all.js?%f"></script>
	<form id="query_form" action="%s" method="%s" accept-charset="UTF-8">
		<div class='search'>
	        %s
        </div>
    </form>
'''

    QueryButtonHtml = u""
    if QueryType == 3:
        QueryButtonHtml = u'''
			<input type="button" id="query_btn" class="btn btn-primary btn-sm" value="查询"/>
		'''
    else:
        QueryButtonHtml = u'''
			<input type="submit" id="query_btn" class="btn btn-primary btn-sm" value="查询"/>
		'''

    ## 日期选择
    DaterStr = u""
    if beginDate != False:
        if beginDate == True:
            beginDate = time_util.Monday0()
        elif beginDate == 7:
            beginDate = time_util.formatTimestampFormat(
                str(
                    time_util.date_add(
                        datetime.date.today().strftime('%Y%m%d'), -7)),
                '%Y%m%d')
        elif beginDate == 11:
            beginDate = int(
                time.mktime(datetime.datetime.now().date().timetuple()))
        elif beginDate == 1:
            beginDate = time_util.today0()
        if not PrecisionSecond:
            DaterStr = u'''<span>
				日期:<input class="Wdate" type="text" readonly onClick="WdatePicker({firstDayOfWeek:1, isShowClear:false, isShowOK:false, isShowToday:false, autoPickDate:true})" id="beginDate" name="beginDate" value="%s" required>
			''' % time_util.formatTimeWithDesc(beginDate, '%Y-%m-%d')
        else:
            DaterStr = u'''<span>
				日期:<input class="Wdate" type="text" readonly onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss', firstDayOfWeek:1, isShowClear:false, isShowOK:false, isShowToday:false, autoPickDate:true})" id="beginDate" name="beginDate" value="%s" required>
			''' % time_util.formatTimeWithDesc(beginDate, '%Y-%m-%d %H:%M:%S')
    if endDate != False:
        if endDate == True:
            endDate = time_util.now_sec()
        elif endDate == 11:
            endDate = int(
                time.mktime(
                    datetime.datetime.now().date().timetuple())) + 86400
        if not PrecisionSecond:
            DaterStr += u'''
				--<input class="Wdate" type="text" readonly onClick="WdatePicker({firstDayOfWeek:1, isShowClear:false, isShowOK:false, isShowToday:false, autoPickDate:true})" id="endDate" name="endDate" value="%s" required>
			''' % time_util.formatTimeWithDesc(endDate, '%Y-%m-%d')
        else:
            DaterStr += u'''
				--<input class="Wdate" type="text" readonly onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss', firstDayOfWeek:1, isShowClear:false, isShowOK:false, isShowToday:false, autoPickDate:true})" id="endDate" name="endDate" value="%s" required>
			''' % time_util.formatTimeWithDesc(endDate, '%Y-%m-%d %H:%M:%S')
    if DaterStr:
        DaterStr += u'%s</span>' % QueryButtonHtml
    else:
        DaterStr = u'<span>%s</span>' % QueryButtonHtml

    ## 平台选择
    PTStr = u""

    ## 渠道选择
    ChannelStr = u""

    ## 玩家选择
    PlayerStr = u""
    if PlayerID != False:
        PlayerStr = u'''
				<span> 玩家ID:<input type="text" id="PlayerID" name="PlayerID" value="%s" placeholder=""></span>
			''' % PlayerID
    if NickName != False:
        PlayerStr += u'''
				<span> 玩家昵称:<input type="text" id="NickName" name="NickName" value="%s" placeholder=""> </span>
			''' % NickName
    if Account != False:
        PlayerStr += u'''
				<span> 玩家账号:<input type="text" id="Account" name="Account" value="%s" placeholder=""> </span>
			''' % Account

    ## 日期快速查询
    dateFast = u""
    if endDate != False:
        dateFast = u'''
	        <ul class="date_fast">
	            <li time="last_month">上月</li>
	            <li time="month">本月</li>
	            <li time="last_week">上周</li>
	            <li time="week">本周</li>
	            <li time="yesterday">昨日</li>
	            <li time="today">今日</li>
	        </ul>
			'''

    if OThers:
        SubL = [PTStr, ChannelStr] + OThers + [PlayerStr, DaterStr, dateFast]
    else:
        SubL = [PTStr, ChannelStr, PlayerStr, DaterStr, dateFast]

    return Html % (random.random(), Action, Method, "".join(SubL))