Exemplo n.º 1
0
def init1(admin_type):
    if admin_type == "API":
        return
    from zs_backend.busi.channel import load_channel
    from zs_backend.busi.game_parameter import load_game_paramter
    print "system init"
    ## 初始化系统账号
    user_count = SqlOperate().select('select count(1) from user')[0][0]
    if user_count == 0:
        sql = '''
            insert into user (name, nick, password, role_str) values ('admin', 'admin', '%s', '1')
        ''' % generate_password_hash('123456')
        SqlOperate().insert(sql)

    role_count = SqlOperate().select('select count(1) from role')[0][0]
    if role_count == 0:
        sql = '''
            insert into role (id, name, parent_id) values (1, '管理员组', 1)
        '''
        SqlOperate().insert(sql)

    ## 加载渠道配置到redis
    try:
        load_channel()
    except BaseException as e:
        print "load_channel:", e
    ## 加载游戏参数
    load_game_paramter()
Exemplo n.º 2
0
def delete_white_player():
    pid = int(request.json.get('pid'))
    channel = session['select_channel']

    sql_oper = SqlOperate()
    delete_sql = """DELETE FROM admin_white_list WHERE pid=%d""" % pid

    try:
        LogQry(channel).execute(delete_sql)
    except Exception as e:
        print e
        return jsonify(errmsg='移除白名单失败')

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

    payload = {"pid": pid, "handle": "whitelist", "hanle_val": 0}
    GameWeb(channel).post("/api/handle_player", payload)

    return jsonify(errmsg='移除白名单成功')
Exemplo n.º 3
0
def show_users_list():
    qry_pid = request.form.get('pid', '')
    Where = ""
    if qry_pid:
        Where = " and pid = %s" % qry_pid
    channel = session['select_channel']

    sql_oper = SqlOperate()

    black_search_sql = """SELECT pid, game_count, total_recharge_rmb, total_withdraw, coin, counter, remark 
                FROM admin_black_list where 1 = 1 %s""" % (Where)
    black_tuple = LogQry(channel).qry(black_search_sql)

    white_search_sql = """SELECT pid, game_count, total_recharge_rmb, total_withdraw, coin, counter, remark 
                FROM admin_white_list where 1 = 1 %s""" % (Where)
    white_tuple = LogQry(channel).qry(white_search_sql)

    datas = dict()
    if len(black_tuple) > 0:
        black_list = list()
        for pid, game_count, total_recharge, total_withdraw, coin, counter, remark in black_tuple:
            data_dict = dict()
            data_dict['pid'] = pid
            data_dict['game_count'] = game_count
            data_dict['total_recharge'] = total_recharge
            data_dict['total_withdraw'] = total_withdraw
            data_dict['coin'] = game_util.coin_translate(channel, coin)
            data_dict['counter'] = game_util.coin_translate(channel, counter)
            data_dict['remark'] = remark
            black_list.append(data_dict)
        datas['black_list'] = black_list

    if len(white_tuple) > 0:
        white_list = list()
        for pid, game_count, total_recharge, total_withdraw, coin, counter, remark in white_tuple:
            data_dict = dict()
            data_dict['pid'] = pid
            data_dict['game_count'] = game_count
            data_dict['total_recharge'] = total_recharge
            data_dict['total_withdraw'] = total_withdraw
            data_dict['coin'] = game_util.coin_translate(channel, coin)
            data_dict['counter'] = game_util.coin_translate(channel, counter)
            data_dict['remark'] = remark
            white_list.append(data_dict)
        datas['white_list'] = white_list

    status_msg = dict()
    status_msg['pid'] = qry_pid

    return render_template('black_white_list.html',
                           status_msg=status_msg,
                           datas=datas)
Exemplo n.º 4
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='加入黑名单成功')
Exemplo n.º 5
0
def show_manipulate_log_data():
    start = request.form.get('beginDate')
    end = request.form.get('endDate')
    channel = session['select_channel']

    start = time_util.start(start)
    end = time_util.end(end)

    sql = '''
		select log_type, operator, obj, val, timestamp 
		from admin_opt_log 
		where channel = %d and timestamp >= %d and timestamp <= %d and maintype = %d
		order by timestamp desc limit 30
	''' % (channel, start, end, log_main_type_d["win_ctl"])

    page = deepcopy(init_page)

    page["beginDate"] = start
    page["endDate"] = end
    page["SelectChannel"] = channel

    ## 查询子游戏列表
    SubGameList = game_parameter.get_subgame_list()

    for log_type, operator, obj, val, timestamp in LogQry(channel).qry(sql):
        OperatorName = SqlOperate().select(
            "select name from user where id = %d" % operator)[0][0]
        if log_type == log_type_d["single_ctl"]:
            log_type_str = u"单控"
            obj_sql = "select nick from player where id = %d" % obj
            try:
                obj_name = LogQry(channel).qry(obj_sql)[0][0]
            except:
                obj_name = ""

            log_content = u"管理员%s对玩家%s(%s)设置了保护值:%s" % \
                          (blue_html(OperatorName), blue_html(obj_name), blue_html(obj), red_html(val))
        elif log_type == log_type_d["full_game_ctl"]:
            log_type_str = u"控大盘"
            [room_name, water] = val.split("_")
            log_content = u"管理员%s对%s(%s)水池调整成:%s" % \
                          (blue_html(OperatorName), blue_html(game_parameter.get_subgame_by_id(SubGameList, obj)),
                           blue_html(room_name), red_html(water))

        page["list"].append(
            [OperatorName, log_type_str, log_content, timestamp])

    return jsonify(result='ok', data=page)
Exemplo n.º 6
0
def game_parameter_retrieve():
    """游戏参数查询"""

    # 获取参数
    type_id = request.args.get('type', str(TAG_COIN_LOG))

    # 获取数据
    retrieve_sql = """SELECT config FROM game_parameter WHERE type=%s;""" % type_id
    data = SqlOperate().select(retrieve_sql)

    # 处理数据
    try:
        config = eval(data[0][0])
    except IndexError:
        config = []
    # 返回数据
    return jsonify(result='ok', data=config)
Exemplo n.º 7
0
def game_parameter_update():
    """游戏参数新建"""

    # 获取参数
    type_id = request.form.get('type')
    config = request.form.get('config')

    # 校验参数
    try:
        eval(config)
        redis_conn.hset(GAME_PARAMTER_TABLE, type_id, config)
    except ValueError:
        return jsonify(result='fail', msg=u'内容不合法')

    # 存进数据库
    update_sql = """replace into game_parameter (type, config) values (%s, '%s')""" % (
        type_id, config)
    SqlOperate().update(update_sql)

    # 返回应答
    return jsonify(result='ok', msg=u'新建成功!')
Exemplo n.º 8
0
def search_users_manage_log():
    start = time_util.formatDatestamp(request.args.get('beginDate'))
    end = time_util.formatDatestamp(request.args.get('endDate'))

    role_str = session['role_str']
    highest_role = get_highest_role_id(role_str)

    if highest_role == 1:
        sql = '''
            select log_type, operator, obj, val, timestamp 
            from admin_opt_log 
            where channel=0 and timestamp >= %d and timestamp <= %d and maintype = 1
            order by timestamp desc limit 30;
        ''' % (start, end + 86400)

    else:
        sql = '''
            select log_type, operator, obj, val, timestamp 
            from admin_opt_log 
            where channel=0 and val=%s and timestamp >= %d and timestamp <= %d and maintype = 1
            order by timestamp desc limit 30;
        ''' % (highest_role, start, end + 86400)

    print sql

    page = deepcopy(init_page)

    page["beginDate"] = start
    page["endDate"] = end

    for log_type, operator, obj, val, timestamp in SqlOperate().select(sql):
        print obj
        OperatorName = SqlOperate().select(
            "select name from user where id = %d" % operator)[0][0]

        if log_type == log_type_d["delete_staff"]:
            obj_sql = "select name from user where id = %d" % obj
            if SqlOperate().select(obj_sql):
                name = SqlOperate().select(obj_sql)[0][0]
            else:
                name = ''
            obj_name = name + "(ID:%d)" % obj
            log_content = u"管理员%s删除员工%s" % \
                          (blue_html(OperatorName), red_html(obj_name))

        if log_type == log_type_d["add_staff"]:
            obj_sql = "select name from user where id = %d" % obj
            print obj_sql
            if SqlOperate().select(obj_sql):
                name = SqlOperate().select(obj_sql)[0][0]
            else:
                name = ''
            obj_name = name + "(ID:%d)" % obj
            print 'obj_name', obj_name
            log_content = u"管理员%s添加员工%s" % \
                          (blue_html(OperatorName), red_html(obj_name))

        if log_type == log_type_d["edit_staff"]:
            obj_sql = "select name from user where id = %d" % obj
            if SqlOperate().select(obj_sql):
                name = SqlOperate().select(obj_sql)[0][0]
            else:
                name = ''
            obj_name = name + "(ID:%d)" % obj
            log_content = u"管理员%s修改员工%s" % \
                          (blue_html(OperatorName), red_html(obj_name))

        if log_type == log_type_d["add_channel"]:
            obj_sql = "select name from channel where id = %d" % obj
            if SqlOperate().select(obj_sql):
                name = SqlOperate().select(obj_sql)[0][0]
            else:
                name = ''
            obj_name = name + "(ID:%d)" % obj
            log_content = u"管理员%s添加渠道%s" % \
                          (blue_html(OperatorName), red_html(obj_name))

        if log_type == log_type_d["edit_channel"]:
            obj_sql = "select name from channel where id = %d" % obj
            if SqlOperate().select(obj_sql):
                name = SqlOperate().select(obj_sql)[0][0]
            else:
                name = ''
            obj_name = name + "(ID:%d)" % obj
            log_content = u"管理员%s修改渠道%s" % \
                          (blue_html(OperatorName), red_html(obj_name))

        if log_type == log_type_d["delete_channel"]:
            obj_sql = "select name from channel where id = %d" % obj
            if SqlOperate().select(obj_sql):
                name = SqlOperate().select(obj_sql)[0][0]
            else:
                name = ''
            obj_name = name + "(ID:%d)" % obj
            log_content = u"管理员%s删除渠道%s" % \
                          (blue_html(OperatorName), red_html(obj_name))

        page["list"].append([OperatorName, obj_name, log_content, timestamp])

    return render_template('user_managed_log.html', page=page)
Exemplo n.º 9
0
def show_manage_log_data():
    start = request.args.get('beginDate')
    end = request.args.get('endDate')
    pid = request.args.get('PlayerID')
    nick = request.args.get('NickName')
    channel = session['select_channel']
    size = int(request.args.get('size', ''))
    offset = int(request.args.get('offset', ''))

    start = time_util.start(start)
    end = time_util.end(end)

    # 校验参数
    if pid:
        try:
            int(pid)
        except ValueError:
            return jsonify(result='fail', msg=u'玩家ID为整数纯数字!')
    if pid and nick:
        return jsonify(result='fail', msg=u'玩家ID与玩家昵称只能输入其一!')
    if start >= end:
        return jsonify(result='fail', mag=u'结束日期不能小于开始日期!')

    # 转换昵称
    if nick:
        retrieve_sql = """SELECT id FROM player WHERE nick='%s';""" % nick
        pid = LogQry(channel).qry(retrieve_sql)[0][0]

    if pid or nick:
        sql = '''
            select log_type, operator, obj, val, timestamp 
            from admin_opt_log 
            where channel = %d and timestamp >= %d and timestamp <= %d and maintype = %d and obj = %s
            order by timestamp desc 
            LIMIT %d,%d
        ''' % (channel, start, end, log_main_type_d["player"], pid, offset,
               size)

        count_sql = '''
            select count(1)
            from admin_opt_log 
            where channel = %d and timestamp >= %d and timestamp <= %d and maintype = %d and obj = %s
            order by timestamp desc;
        ''' % (channel, start, end, log_main_type_d["player"], pid)
    else:
        sql = '''
                    select log_type, operator, obj, val, timestamp 
                    from admin_opt_log 
                    where channel = %d and timestamp >= %d and timestamp <= %d and maintype = %d 
                    order by timestamp desc 
                    LIMIT %d,%d
                ''' % (channel, start, end, log_main_type_d["player"], offset,
                       size)

        count_sql = '''
                    select count(1)
                    from admin_opt_log 
                    where channel = %d and timestamp >= %d and timestamp <= %d and maintype = %d 
                    order by timestamp desc;
                ''' % (channel, start, end, log_main_type_d["player"])

    total_count = LogQry(channel).qry(count_sql)

    page = deepcopy(init_page)

    page["beginDate"] = start
    page["endDate"] = end
    page["SelectChannel"] = channel

    for log_type, operator, obj, val, timestamp in LogQry(channel).qry(sql):
        OperatorName = SqlOperate().select(
            "select name from user where id = %d" % operator)[0][0]
        if log_type == log_type_d["white"]:
            obj_sql = "select nick from player where id = %d" % obj
            if LogQry(channel).qry(obj_sql):
                nick = LogQry(channel).qry(obj_sql)[0][0]
            else:
                nick = ''
            obj_name = nick + "(ID:%d)" % obj
            log_content = u"管理员%s对玩家%s加入白名单" % \
                          (blue_html(OperatorName), red_html_link(obj, nick, channel, obj_name))

        elif log_type == log_type_d["black"]:
            obj_sql = "select nick from player where id = %d" % obj
            if LogQry(channel).qry(obj_sql):
                nick = LogQry(channel).qry(obj_sql)[0][0]
            else:
                nick = ''
            obj_name = nick + "(ID:%d)" % obj
            log_content = u"管理员%s对玩家%s加入黑名单" % \
                          (blue_html(OperatorName), red_html_link(obj, nick, channel, obj_name))

        elif log_type == log_type_d["forbid"]:
            obj_sql = "select nick from player where id = %d" % obj
            if LogQry(channel).qry(obj_sql):
                nick = LogQry(channel).qry(obj_sql)[0][0]
            else:
                nick = ''
            obj_name = nick + "(ID:%d)" % obj
            log_content = u"管理员%s对玩家%s封号,原因为:%s" % \
                          (blue_html(OperatorName), red_html_link(obj, nick, channel, obj_name), red_html(val))

        elif log_type == log_type_d["cancel_forbid"]:
            obj_sql = "select nick from player where id = %d" % obj
            if LogQry(channel).qry(obj_sql):
                nick = LogQry(channel).qry(obj_sql)[0][0]
            else:
                nick = ''
            obj_name = nick + "(ID:%d)" % obj
            log_content = u"管理员%s对玩家%s解封" % \
                          (blue_html(OperatorName), red_html_link(obj, nick, channel, obj_name))

        elif log_type == log_type_d["cold"]:
            obj_sql = "select nick from player where id = %d" % obj
            if LogQry(channel).qry(obj_sql):
                nick = LogQry(channel).qry(obj_sql)[0][0]
            else:
                nick = ''
            obj_name = nick + "(ID:%d)" % obj
            log_content = u"管理员%s对玩家%s资金冻结" % \
                          (blue_html(OperatorName), red_html_link(obj, nick, channel, obj_name))

        elif log_type == log_type_d["cancel_cold"]:
            obj_sql = "select nick from player where id = %d" % obj
            if LogQry(channel).qry(obj_sql):
                nick = LogQry(channel).qry(obj_sql)[0][0]
            else:
                nick = ''
            obj_name = nick + "(ID:%d)" % obj
            log_content = u"管理员%s对玩家%s资金解冻" % \
                          (blue_html(OperatorName), red_html_link(obj, nick, channel, obj_name))

        elif log_type == log_type_d["alter_pass"]:
            obj_sql = "select nick from player where id = %d" % obj
            if LogQry(channel).qry(obj_sql):
                nick = LogQry(channel).qry(obj_sql)[0][0]
            else:
                nick = ''
            obj_name = nick + "(ID:%d)" % obj
            log_content = u"管理员%s对玩家%s修改登录密码" % \
                          (blue_html(OperatorName), red_html_link(obj, nick, channel, obj_name))

        elif log_type == log_type_d["send_coin"]:
            obj_sql = "select nick from player where id = %d" % obj
            if LogQry(channel).qry(obj_sql):
                nick = LogQry(channel).qry(obj_sql)[0][0]
            else:
                nick = ''
            obj_name = nick + "(ID:%d)" % obj
            log_content = u"管理员%s对玩家%s赠送金币%s" % \
                          (blue_html(OperatorName), red_html_link(obj, nick, channel, obj_name), red_html(val))

        elif log_type == log_type_d["send_item"]:
            obj_sql = "select nick from player where id = %d" % obj
            if LogQry(channel).qry(obj_sql):
                nick = LogQry(channel).qry(obj_sql)[0][0]
            else:
                nick = ''
            obj_name = nick + "(ID:%d)" % obj
            log_content = u"管理员%s对玩家%s赠送喇叭%s" % \
                          (blue_html(OperatorName), red_html_link(obj, nick, channel, obj_name), red_html(val))

        elif log_type == log_type_d["del_white"]:
            obj_sql = "select nick from player where id = %d" % obj
            if LogQry(channel).qry(obj_sql):
                nick = LogQry(channel).qry(obj_sql)[0][0]
            else:
                nick = ''
            obj_name = nick + "(ID:%d)" % obj
            log_content = u"管理员%s对玩家%s移除白名单" % \
                          (blue_html(OperatorName), red_html_link(obj, nick, channel, obj_name))

        elif log_type == log_type_d["del_black"]:
            obj_sql = "select nick from player where id = %d" % obj
            if LogQry(channel).qry(obj_sql):
                nick = LogQry(channel).qry(obj_sql)[0][0]
            else:
                nick = ''
            obj_name = nick + "(ID:%d)" % obj
            log_content = u"管理员%s对玩家%s移除黑名单" % \
                          (blue_html(OperatorName), red_html_link(obj, nick, channel, obj_name))

        elif log_type == log_type_d["alter_bank_pwd"]:
            obj_sql = "select nick from player where id = %d" % obj
            if LogQry(channel).qry(obj_sql):
                nick = LogQry(channel).qry(obj_sql)[0][0]
            else:
                nick = ''
            obj_name = nick + "(ID:%d)" % obj
            log_content = u"管理员%s对玩家%s修改保险柜密码" % \
                          (blue_html(OperatorName), red_html_link(obj, nick, channel, obj_name))

        elif log_type == log_type_d["alter_nick"]:
            obj_sql = "select nick from player where id = %d" % obj
            if LogQry(channel).qry(obj_sql):
                nick = LogQry(channel).qry(obj_sql)[0][0]
            else:
                nick = ''
            obj_name = nick + "(ID:%d)" % obj
            log_content = u"管理员%s对玩家%s修改昵称为:%s" % \
                          (blue_html(OperatorName), red_html_link(obj, nick, channel, obj_name), blue_html(val))

        elif log_type == log_type_d["alter_vip"]:
            obj_sql = "select nick from player where id = %d" % obj
            if LogQry(channel).qry(obj_sql):
                nick = LogQry(channel).qry(obj_sql)[0][0]
            else:
                nick = ''
            obj_name = nick + "(ID:%d)" % obj
            log_content = u"管理员%s对玩家%s调整了会员层级为%s" % \
                          (blue_html(OperatorName), red_html_link(obj, nick, channel, obj_name), red_html(val))

        elif log_type == log_type_d["alter_zfb"]:
            obj_sql = "select nick from player where id = %d" % obj
            if LogQry(channel).qry(obj_sql):
                nick = LogQry(channel).qry(obj_sql)[0][0]
            else:
                nick = ''
            obj_name = nick + "(ID:%d)" % obj
            log_content = u"管理员%s对玩家%s绑定了支付宝%s" % \
                          (blue_html(OperatorName), red_html_link(obj, nick, channel, obj_name), red_html(val))

        elif log_type == log_type_d["alter_bank"]:
            obj_sql = "select nick from player where id = %d" % obj
            if LogQry(channel).qry(obj_sql):
                nick = LogQry(channel).qry(obj_sql)[0][0]
            else:
                nick = ''
            obj_name = nick + "(ID:%d)" % obj
            log_content = u"管理员%s对玩家%s绑定了银行卡%s" % \
                          (blue_html(OperatorName), red_html_link(obj, nick, channel, obj_name), red_html(val))

        elif log_type == log_type_d["alter_code"]:
            obj_sql = "select nick from player where id = %d" % obj
            if LogQry(channel).qry(obj_sql):
                nick = LogQry(channel).qry(obj_sql)[0][0]
            else:
                nick = ''
            obj_name = nick + "(ID:%d)" % obj
            log_content = u"管理员%s对玩家%s修改了受邀码为%s" % \
                          (blue_html(OperatorName), red_html_link(obj, nick, channel, obj_name), red_html(val))

        page["list"].append({
            "OperatorName": OperatorName,
            "obj_name": obj_name,
            "log_content": log_content,
            "timestamp": timestamp
        })

    return jsonify({
        "result": "ok",
        "errcode": 0,
        "dataLength": total_count,
        "rowDatas": page["list"]
    })
Exemplo n.º 10
0
def load_game_paramter():
    sql = 'SELECT type, config FROM game_parameter'
    for stype, config in SqlOperate().select(sql):
        redis_conn.hset(GAME_PARAMTER_TABLE, stype, config)
Exemplo n.º 11
0
def agent_commission_show():
    # 获取参数
    channel = session['select_channel']
    begin_time = request.args.get('begin_time')
    end_time = request.args.get('end_time')
    pid = request.args.get("pid", "")

    if end_time < begin_time:
        return jsonify(u'查询结束日期必须大于开始日期')

    ## pid为空 则为查询本账号绑定的代理ID
    if pid == "":
        ## 获取该账号绑定ID
        sql = 'select game_player_id from user where id = %d' % session[
            'user_id']
        pid = SqlOperate().select(sql)[0][0]

        ## 如果pid为0 则表示总代 那就查询所有顶级代理
        ## 如果不为0 则查询该id是否为代理 是代理 则查询该代理明细
        if pid == "":
            return jsonify(datas=[])

    if pid == "0":
        sql = 'select pid from admin_agent_list where pid > 0'
    else:
        sql = 'select pid from admin_agent_list where pid = %s or pre_pid = %s' % (
            pid, pid)
    agent_pids = [str(i[0]) for i in LogQry(channel).qry(sql)]
    if not agent_pids:
        return jsonify(datas=[])

    ## 查询所有层级
    sql = '''
		select id, level_name, first_ladder, second_ladder, third_ladder, 
			fourth_ladder, fifth_ladder
		from admin_agent_level'''
    agent_lv_map = {}
    for k, name, l1, l2, l3, l4, l5 in LogQry(channel).qry(sql):
        agent_lv_map[k] = {
            "name": name,
            "ladder": [l1, l2, l3, l4, l5],
        }

    ## 查询对应代理的对应层级
    sql = '''
		select pid, agent_level, (select nick from player where id = pid), 
				(select count(1) from player_agent where invite_id = pid)
		from admin_agent_list
		where pid in (%s)
	''' % ",".join(agent_pids)
    agent_list = {}
    for pid, lv, name, count in LogQry(channel).qry(sql):
        agent_list[pid] = [lv, name, count]

    ## 转换查询日期格式
    begin_time = begin_time[0:4] + begin_time[5:7] + begin_time[8:]
    end_time = end_time[0:4] + end_time[5:7] + end_time[8:]

    ## 根据查询日期 查询出这段时间里边代理总的佣金等
    ## 需要去除已经结算的
    sql = '''
		select pid, ifnull(sum(pump), 0), ifnull(sum(win), 0)
		from t_agent_day a
		where pid in (%s)
		and time >= %s and time <= %s
		and time > 
			(select ifnull(max(date2) , 0)
			from admin_agent_settlement 
			where pid = a.pid)
		group by pid
	''' % (",".join(agent_pids), begin_time, end_time)
    datas = {}
    for pid, pump, win in LogQry(channel).qry(sql):
        lv = agent_list[pid][0]
        pump = int(pump)
        win = int(win)
        pump_commission, pump_rate = calc_pump_commission(
            agent_lv_map[lv]["ladder"], pump)
        win_commission, win_rate = calc_win_commission(
            agent_lv_map[lv]["ladder"], win)
        datas[pid] = {
            "lv": agent_lv_map[lv]["name"],
            "pid": pid,
            "name": agent_list[pid][1],
            "player_count": agent_list[pid][2],
            "pump": pump,
            "win": win,
            "pump_commission": pump_commission,
            "win_commission": win_commission,
            "pump_rate": pump_rate,
            "win_rate": win_rate,
        }

    return jsonify(datas=datas)
Exemplo n.º 12
0
def search_topup_order_detail():
    start = request.args.get('beginDate')
    end = request.args.get('endDate')
    player_id = request.args.get('PlayerID', '')
    account = request.args.get('Account', '')
    stype = request.args.get('type')
    pay_state = request.args.get('pay_state')
    offset = int(request.args.get("offset", "0"))
    pagesize = int(request.args.get("size", "100"))

    # 接收渠道id
    channel = session['select_channel']

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

    where = ""
    use_index = "force index(time)"
    if stype != "0":
        where += "and type = %s " % stype
    if pay_state != "-1":
        where += "and state = %s " % pay_state
    if player_id != "":
        use_index = "force index(pid)"
        where += "and pid = %s " % player_id
    if account != "":
        use_index = "force index(pid)"
        where += "and pid = (select id from player where account_id = '%s') " % account

    ## 查询满足条件的总数
    count_sql = '''
        select count(1)
        from admin_recharge
        %s
        where time >= %d 
        and time <= %d
        %s
    ''' % (use_index, start_date, end_date, where)
    total_count = LogQry(channel).qry(count_sql)[0][0]

    ## 查询支付通道名字
    pc = {}
    sql = '''
        select id, name, config
        from admin_pay_channel
    '''
    for line in LogQry(channel).qry(sql):
        pc[line[0]] = [line[1], line[2]]

    sql = '''
        select id, api_name
        from admin_online_payment
        where channel_id = %d
    ''' % (channel)
    for line in LogQry(channel).qry(sql):
        pc[line[0]] = [line[1], ""]

    ml = {}
    ml[0] = u"默认"
    sql = '''
        select id, member_level_name
        from admin_member_level
        where channel_id = %d
    ''' % channel
    for line in LogQry(channel).qry(sql):
        ml[line[0]] = line[1]

    ## 操作员查询
    operator = {0: ""}
    sql = '''
        select id, name
        from user
    '''
    for line in SqlOperate().select(sql):
        operator[line[0]] = line[1]

    ## 查询满足条件的订单详情
    sql = '''
        select time, pid, vip, (select account_id from player where id = pid),
                (select nick from player where id = pid),
            orderno, platformno, cost, state, type,
            pay_channel, request_pid, review_time, review_pid, memo,
            coin, pay_name
        from admin_recharge
        %s
        where time >= %d 
        and time <= %d
        %s 
        order by state desc, time desc
        limit %s, %s
    ''' % (use_index, start_date, end_date, where, offset, pagesize)
    datas = []
    for line in LogQry(channel).qry(sql):
        d = {}
        d["request_time"] = line[0]
        d["id"] = line[1]
        d["vip"] = ml.get(line[2])
        d["account"] = line[3]
        d["nick"] = line[4]

        d["order_no"] = line[5]
        d["cost"] = line[7]
        d["state"] = line[8]
        d["pay_type"] = line[9]

        d["pay_chanel"] = pc[line[10]][0]
        d["request_pid"] = operator[line[11]]
        d["review_time"] = line[12]
        d["review_pid"] = operator[line[13]]
        d["memo"] = line[14]
        d["coin"] = line[15]
        d["name"] = line[16]

        d["pay_chanel_config"] = pc[line[10]][1]

        datas.append(d)

    return jsonify({
        "errcode": 0,
        "dataLength": total_count,
        "rowDatas": datas
    })
Exemplo n.º 13
0
def recharge_discounts_create_update():
    """充值优惠设置新建/修改"""

    # 获取参数
    channel_id = session['select_channel']
    user_id = g.user_id
    activity_title = request.form.get('activity_title')
    show_picture_url = request.form.get('show_picture_url')
    tab1_url = request.form.get('tab1_url')
    tab2_url = request.form.get('tab2_url')
    activity_type = request.form.get('activity_type')
    participation_member = request.form.get('participation_member')
    participation_level = request.form.get('participation_level')
    activity_content = request.form.get('activity_content')
    recharge_detail = request.form.get('recharge_detail')
    journal_require = request.form.get('journal_require')
    request_times = request.form.get('request_times')
    max_add_recharge = request.form.get('max_add_recharge')
    begin_time = request.form.get('begin_time')
    end_time = request.form.get('end_time')
    priority = request.form.get('priority')
    activity_id = request.form.get('activity_id')

    # 校验并处理参数
    if not all([begin_time, end_time, priority, activity_content]):
        return jsonify(result=0, msg=u'请输入所有必填项!')
    try:
        int(priority)
        int(journal_require)
        int(request_times)
        max_add_recharge = int(max_add_recharge) * 100
    except ValueError:
        return jsonify(result=0, msg=u'流水要求、申请次数、最高赠送、优先级为整数纯数字!')
    try:
        recharge_detail = eval(recharge_detail)
    except Exception:
        return jsonify(result=0, msg=u'所有充值梯度里的项都是必填项,且为整数纯数字!')
    for one in recharge_detail:
        i = 0
        for one_in_one in one:
            try:
                one[i] = int(one_in_one) * 100
            except ValueError:
                return jsonify(result=0, msg=u'所有充值梯度里的项都是必填项,且为整数纯数字!')
            i += 1
    if participation_level == ']':
        participation_level = ''
    begin_time = time_util.formatTimestamp(begin_time)
    end_time = time_util.formatTimestamp(end_time)
    if begin_time > end_time:
        return jsonify(result=0, msg=u'开始时间不能大于结束时间!')

    # 向游戏服发送请求
    times = [begin_time] + [end_time]
    game_status = GameWeb(channel_id).post(
        '/api/up_activity', {
            'id': int(activity_type),
            'icon1': tab1_url,
            'icon2': tab2_url,
            'mark': activity_title,
            'ord': int(priority),
            'detail': show_picture_url,
            'times': times,
            'rules': activity_content
        })
    if game_status['result'] != 'ok':
        return jsonify(result=0, msg='创建失败!')

    # 根据当前时间判定新建的活动的状态
    if begin_time < time_util.now_sec() < end_time:
        status = TAKE_EFFECT
    else:
        status = LOSE_EFFICACY

    # 查询账号名
    retrieve_sql = """SELECT name
                      FROM user
                      WHERE id=%s;""" % user_id
    user_id = SqlOperate().select(retrieve_sql)[0][0]

    # 新建充值优惠
    if not activity_id:
        # 先把同活动类型为生效状态的活动改状态为失效
        update_sql = """UPDATE admin_recharge_discounts
                        SET status=%s
                        WHERE status=%s
                        AND activity_type=%s;""" \
                     % (LOSE_EFFICACY, TAKE_EFFECT, activity_type)
        LogQry(channel_id).execute(update_sql)
        # 再新建新的活动
        create_sql = """INSERT INTO admin_recharge_discounts
                        VALUES (0,'%s',%s,'%s','%s',%s,
                                %s,'%s','%s','%s',%s,
                                %s,'%s','%s',%s,%s,
                                %s,%s);""" \
                     % (user_id, priority, activity_title, activity_content, activity_type,
                        participation_member, show_picture_url, tab1_url, tab2_url, begin_time,
                        end_time, participation_level, recharge_detail, request_times, max_add_recharge,
                        journal_require, status)
        LogQry(channel_id).execute(create_sql)
        return jsonify(result=1, msg=u'新建成功!')

    # 修改充值优惠
    else:
        # 先把同活动类型为生效状态的活动改状态为失效
        update_sql = """UPDATE admin_recharge_discounts
                        SET status=%s
                        WHERE status=%s
                        AND activity_type=%s;""" \
                     % (LOSE_EFFICACY, TAKE_EFFECT, activity_type)
        LogQry(channel_id).execute(update_sql)
        # 再修改活动
        update_sql = """UPDATE admin_recharge_discounts
                        SET priority=%s,activity_title='%s',activity_content='%s',activity_type=%s,participation_member=%s,
                            show_picture_url='%s',tab1_url='%s',tab2_url='%s',begin_time=%s,end_time=%s,
                            participation_level='%s',recharge_detail='%s',request_times=%s,max_add_recharge=%s,journal_require=%s,
                            status=%s,user_id='%s'
                        WHERE id=%s;""" \
                     % (priority, activity_title, activity_content, activity_type, participation_member,
                        show_picture_url, tab1_url, tab2_url, begin_time, end_time,
                        participation_level, recharge_detail, request_times, max_add_recharge, journal_require,
                        status, user_id, activity_id)
        LogQry(channel_id).execute(update_sql)
        return jsonify(result=1, msg=u'修改成功!')
Exemplo n.º 14
0
def update_activity():
    """修改活动"""

    # 获取参数
    picture_url = request.form.get('picture_url')
    activity_title = request.form.get('activity_title')
    tab1_url = request.form.get('tab1_url')
    tab2_url = request.form.get('tab2_url')
    begin_time = request.form.get('begin_time')
    end_time = request.form.get('end_time')
    entry_fee = request.form.get('entry_fee')
    activity_content = request.form.get('activity_content')
    priority = request.form.get('priority')
    activity_type = request.form.get('activity_type')
    activity_id = request.form.get('activity_id')
    user_id = g.user_id
    channel_id = session['select_channel']

    # 校验并处理参数
    if not all([begin_time, end_time, priority, activity_content]):
        return jsonify(result=2, errormsg=u'请输入必填项!')
    if entry_fee:
        try:
            int(entry_fee)
        except ValueError as e:
            return jsonify(result=2, errormsg=u'报名费为整数纯数字!')
    else:
        entry_fee = 'null'
    try:
        int(priority)
    except ValueError as e:
        return jsonify(result=2, errormsg=u'优先级为整数纯数字!')
    begin_time = time_util.formatTimestamp(begin_time)
    end_time = time_util.formatTimestamp(end_time)

    # 向游戏服发送请求
    times = [begin_time] + [end_time]
    if activity_type == '2':
        game_status = GameWeb(channel_id).post(
            '/api/up_activity', {
                'id': int(activity_type),
                'icon1': tab1_url,
                'icon2': tab2_url,
                'mark': activity_title,
                'ord': int(priority),
                'detail': picture_url,
                'entry_fee': int(entry_fee),
                'times': times,
                'rules': activity_content
            })
    else:
        game_status = GameWeb(channel_id).post(
            '/api/up_activity', {
                'id': int(activity_type),
                'icon1': tab1_url,
                'icon2': tab2_url,
                'mark': activity_title,
                'ord': int(priority),
                'detail': picture_url,
                'times': times,
                'rules': activity_content
            })
    if game_status['result'] != 'ok':
        return jsonify(result=2, msg='修改失败!')

    # 根据当前时间判定新建的活动的状态
    if begin_time < time_util.now_sec() < end_time:
        status = TAKE_EFFECT
    else:
        status = LOSE_EFFICACY

    # 同活动类型为生效状态的活动改状态为失效
    update_sql = """UPDATE admin_activity
                    SET status=%s
                    WHERE status=%s
                    AND activity_type=%s;""" \
                 % (LOSE_EFFICACY, TAKE_EFFECT, activity_type)
    LogQry(channel_id).execute(update_sql)

    # 查询账号名
    retrieve_sql = """SELECT name
                      FROM user
                      WHERE id=%s;""" % user_id
    user_id = SqlOperate().select(retrieve_sql)[0][0]

    # 存进数据库
    update_activity_sql = """UPDATE admin_activity
                              SET activity_title='%s',activity_content='%s',picture_url='%s',tab1_url='%s',tab2_url='%s',
                                  begin_time=%s,end_time=%s,entry_fee=%s,priority=%s,activity_type=%s,
                                  status=%s,user_id='%s'
                              WHERE id=%s;""" \
                          % (activity_title, activity_content, picture_url, tab1_url, tab2_url,
                             begin_time, end_time, entry_fee, priority, activity_type,
                             status, user_id, activity_id)
    LogQry(channel_id).execute(update_activity_sql)

    # 返回应答
    return jsonify(result=1)
Exemplo n.º 15
0
def update_mail():
    """修改邮件"""

    # 获取参数
    mail_title = request.form.get('mail_title')
    mail_content = request.form.get('mail_content')
    push_player_id = request.form.get('push_player_id')
    is_all = int(request.form.get('is_all'))
    mail_accessories = request.form.get('mail_accessories')
    expire = request.form.get('expire')
    user_id = g.user_id
    channel_id = session['select_channel']
    mail_id = int(request.form.get('mail_id'))

    # 校验参数并处理数据
    if is_all:
        push_player_id = u'全服推送'
    else:
        for player_id in push_player_id.split(','):
            try:
                int(player_id)
            except ValueError as e:
                return jsonify(result=2, errormsg=u'玩家ID之间半角逗号隔开,且为整数纯数字!')
    if not all([push_player_id, mail_title, mail_content]):
        return jsonify(result=2, errormsg=u'除附件外,其余都是必填项!')
    if mail_accessories == u'{':
        mail_accessories = ''
    else:
        mail_accessories_dict = eval(mail_accessories)
        for num, quantity in mail_accessories_dict.items():
            try:
                mail_accessories_dict[num] = int(quantity)
            except ValueError as e:
                return jsonify(result=2, errormsg=u'附件选中的道具数量不能为空,且为整数纯数字!')
        mail_accessories = str(mail_accessories_dict)
    if is_all:
        try:
            expire = int(expire)
        except ValueError:
            return jsonify(result=2, errormsg=u'有效时间为必填项,且为整数纯数字!')
        if expire < 1 or expire > 30:
            return jsonify(result=2, errormsg=u'有效时间为大于等于1小于等于30的数字!')
    else:
        expire = 'null'

    # 查询账号名
    retrieve_sql = """SELECT name
                      FROM user
                      WHERE id=%s;""" % user_id
    user_id = SqlOperate().select(retrieve_sql)[0][0]

    # 存进数据库
    update_mail_sql = """UPDATE admin_mail 
                          SET mail_title='%s',mail_content='%s',mail_accessories='%s',push_player_id='%s',expire=%s,
                              user_id='%s' 
                          WHERE id=%s;""" \
                      % (mail_title, mail_content, mail_accessories, push_player_id, expire,
                         user_id, mail_id)
    LogQry(channel_id).execute(update_mail_sql)

    # 返回应答
    return jsonify(result=1)
Exemplo n.º 16
0
def create_marquee():
    """新建跑马灯"""

    # 获取参数
    channel_id = session['select_channel']
    user_id = g.user_id
    marquee_content = request.form.get('marquee_content')
    push_times = request.form.get('push_times')
    begin_time = request.form.get('begin_time')
    end_time = request.form.get('end_time')

    # 校验并处理数据
    if not all([marquee_content, push_times, begin_time, end_time]):
        return jsonify(result=2)
    try:
        push_times = int(push_times)
    except ValueError as e:
        return jsonify(result=3)
    if int(push_times) < -1:
        return jsonify(result=3)
    begin_time = time_util.formatTimestamp(begin_time)
    end_time = time_util.formatTimestamp(end_time)
    if begin_time > end_time:
        return jsonify(result=5)

    # 根据时间戳和账号ID生成公告ID
    key_id = int(str(time_util.now_sec()) + str(user_id))

    # 向游戏端发送请求
    if push_times == -1:
        game_push_times = 88888
    else:
        game_push_times = push_times
    game_status = GameWeb(channel_id).post(
        '/api/send_notice', {
            'notice': marquee_content,
            'start': begin_time,
            'end': end_time,
            'max': game_push_times,
            'id': key_id
        })
    if game_status['result'] != 'succ':
        return jsonify(result=4)

    # 查询账号名
    retrieve_sql = """SELECT name
                      FROM user
                      WHERE id=%s;""" % user_id
    user_id = SqlOperate().select(retrieve_sql)[0][0]

    # 存进数据库
    create_marquee_sql = """INSERT INTO admin_marquee (user_id,marquee_content,push_times,begin_time,end_time,
                                    status,id) 
                            VALUE('%s','%s',%s,%s,%s,
                                    %s,%s);""" \
                         % (user_id, marquee_content, push_times, begin_time, end_time,
                            TAKE_EFFECT, key_id)
    LogQry(channel_id).execute(create_marquee_sql)

    # 返回应答
    return jsonify(result=1)