Beispiel #1
0
def login(request):
    '''登陆'''
    if request.method == 'GET':
        response = render_to_response(request, "login.html")
        return response

    elif request.method == 'POST':
        username = request.POST.get('username', None)
        password = request.POST.get('password', None)

        if not username or not password:
            error_message = "用户名或者密码不能都不填写,请重新登录。"
            data = {
                'error_message': error_message,
                'post_path': request.get_full_path()
            }
            return render_to_response(request, 'login.html', data)
        else:
            r, session_id_or_msg = user_roles.login(username, password)
            if r == 0:
                #redirect_to = request.GET.get(REDIRECT_FIELD_NAME, '/index/')
                response = redirect('/index/')
                response.set_cookie(user_roles.SESSION_KEY, session_id_or_msg)
                return response
            else:
                data = {
                    'username': username,
                    'post_path': request.get_full_path(),
                    "error_message": session_id_or_msg
                }
                return render_to_response(request, 'login.html', data)
Beispiel #2
0
def login(request):
    '''登陆'''
    if request.method == 'GET':
        response = render_to_response(request, "login.html")
        return response

    elif request.method == 'POST':
        username = request.POST.get('username',None)
        password = request.POST.get('password',None)

        if not username or not password:
            error_message = "用户名或者密码不能都不填写,请重新登录。"
            data = {'error_message': error_message,
                    'post_path': request.get_full_path()}
            return render_to_response(request, 'login.html', data)
        else:
            r, session_id_or_msg = user_roles.login(username, password)
            if r == 0:
                #redirect_to = request.GET.get(REDIRECT_FIELD_NAME, '/index/')
                response = redirect('/index/')
                response.set_cookie(user_roles.SESSION_KEY, session_id_or_msg)    
                return response
            else:
                data = {'username': username,
                        'post_path': request.get_full_path(),
                        "error_message": session_id_or_msg}
                return render_to_response(request, 'login.html', data)
Beispiel #3
0
def add_partner(request):
    if request.method == "GET":
        return render_to_response(request, 'admin/add_partner.html')
    else:
        p_num = request.POST.get("p_num", None)
        p_name = request.POST.get("p_name", None)
        if not p_name or not p_num:
            error_message = "所有的字段都不能为空"
            data = {
                'error_message': error_message,
                'post_path': request.get_full_path()
            }
            return render_to_response(request, 'admin/add_partner.html', data)
        else:
            partner = Partner()
            partner.p_num = p_num
            partner.p_name = p_name
            partner.create_time = datetime.datetime.now()

            error_message = None
            try:
                partner.persist()
            except Exception, e:
                error_message = "出错了!"
                response = render_to_response(request,
                                              "admin/add_partner.html",
                                              {'error_message': error_message})
                return response
            return redirect('/partner/')
Beispiel #4
0
def login(request):
    if not request.POST:
        user = user_roles.get_userinfo(request)
        username = user and user.username or None
        data = {'username': username,
                'post_path': request.get_full_path()}
        return render_to_response(request, 'admin/login.html', data)
    
    # login post back
    username = request.POST.get('username', None)
    password = request.POST.get('password', None)

    if not username or not password:
        error_message = "用户名或者密码不能都不填写,请重新登录。";
        data = {'error_message': error_message,
                'post_path': request.get_full_path()}
        return render_to_response(request, 'admin/login.html', data) 
    
    r, session_id_or_msg = user_roles.login(username, password)
    if r == 0:
        redirect_to = request.GET.get("to", "/")
        response = HttpResponseRedirect(redirect_to)
        response.set_cookie(user_roles.SESSION_KEY, session_id_or_msg)
        return response
    else:
        data = {'username': username,
                'post_path': request.get_full_path(),
                "error_message": session_id_or_msg}
        return render_to_response(request, 'admin/login.html', data)
Beispiel #5
0
def add_partner(request):
    if request.method == "GET":
        return render_to_response(request, 'admin/add_partner.html')
    else:
        p_num = request.POST.get("p_num",None)
        p_name = request.POST.get("p_name",None)
        if not p_name or not p_num  :
            error_message = "所有的字段都不能为空"
            data = {'error_message': error_message,
                    'post_path': request.get_full_path()}
            return render_to_response(request, 'admin/add_partner.html', data)
        else:
            partner = Partner()
            partner.p_num = p_num
            partner.p_name = p_name
            partner.create_time = datetime.datetime.now()
            
            error_message = None
            try:
                partner.persist()
            except Exception, e:
                error_message = "出错了!"
                response = render_to_response(request, "admin/add_partner.html",{'error_message': error_message})
                return response
            return redirect('/partner/')
Beispiel #6
0
def add_service(request):
    '''添加修改服务器'''
    if request.method == 'GET':
        response = render_to_response(request, "admin/add_service.html")
        return response

    elif request.method == 'POST':
        sid = request.POST.get('sid', None)
        s_num = request.POST.get('s_num', None)
        s_name = request.POST.get('s_name', None)
        db_connect = request.POST.get('db_connect', None)
        open_time = request.POST.get('open_time', None)
        isdel = request.POST.get('isdel', None)
        s_port = request.POST.get('s_port', None)
        db_connect_stat = request.POST.get('db_connect_stat', None)

        if not s_num or not s_name or not db_connect or not open_time or not isdel or not s_port or not db_connect_stat:
            error_message = "所有的字段都不能为空"
            data = {
                'error_message': error_message,
                'post_path': request.get_full_path()
            }
            return render_to_response(request, 'admin/add_service.html', data)
        else:
            service = Service()
            service.s_num = s_num
            service.s_name = s_name
            service.db_connect = db_connect
            service.open_time = open_time
            service.isdel = isdel
            service.s_port = s_port
            service.db_connect_stat = db_connect_stat
            service.edit_time = datetime.datetime.now()
            service.sid = sid
            error_message = None
            try:
                service.persist()
            except Exception, e:
                error_message = "出错了!"
                response = render_to_response(
                    request, "admin/add_service.html", {
                        'error_message': error_message,
                        'service': service
                    })
                return response

            services = Service.query()
            data = {'post_path': request.get_full_path(), 'services': services}
            response = render_to_response(request, "admin/index.html", data)
            return response
Beispiel #7
0
def battle_client_list(request):
    infos = client_business.get_battle_client_list()
    
    now = datetime.now()
    
    client_maps = {}
    for info in infos:
        last_report_time = info.last_report_time
        s = (now - last_report_time).seconds
        if s > 300:
            info.status = 0
        else:
            info.status = 1
    
        server_id = info.server_id
        
        if not server_id:
            server_id = "d1"
            
        server = server_business.get_server(server_id)
        if server:
            server_zone = server.server_zone
            server_zone_client_list = client_maps.get(server_zone, [])  
            server_zone_client_list.append(info)      
            setattr(info, "sort", int(server_id[1:]))
            client_maps[server_zone] = server_zone_client_list
            
    for k, values in client_maps.iteritems():
        values = sorted(values, cmp=lambda x, y : cmp(x.sort, y.sort))
        client_maps[k] = values
    
    return render_to_response(request, "system/battle_client_list.html", locals())
Beispiel #8
0
def user_gold_use_log(request):
    
    now = datetime.now()
    yesterday = now - timedelta(days=1)
    
    name = request.REQUEST.get('name', "")
    page = int(request.REQUEST.get('page', 1))
    pagesize = int(request.REQUEST.get('pagesize', 20))
    server_id = request.REQUEST.get('server_id', '')
    use_type = int(request.REQUEST.get('use_type', 0))
    flag = int(request.REQUEST.get('flag', 0))
    amount = request.REQUEST.get('amount', 0)
    start_time = request.REQUEST.get('start_time', yesterday.strftime("%Y-%m-%d 00:00:00"))
    end_time = request.REQUEST.get('end_time', now.strftime("%Y-%m-%d 00:00:00"))
    logging.debug(u"查询用户金币日志.name[%s], server_id[%s]" % (name, server_id))
    if name and server_id:    
        total, infos = user_business.get_user_gold_use_log(server_id, name, start_time, end_time, use_type, flag, page, pagesize, amount)
    else:
        total, infos = 0, []
        
    use_type_list = set()
    for info in infos:
        use_type_list.add(info["use_type"])
        
    return render_to_response(request, "manager/user_gold_use_log.html", locals())
Beispiel #9
0
def user_hero_log(request):

    now = datetime.now()
    yesterday = now - timedelta(days=1)

    name = request.REQUEST.get('name', "")
    page = int(request.REQUEST.get('page', 1))
    pagesize = int(request.REQUEST.get('pagesize', 20))
    server_id = request.REQUEST.get('server_id', '')
    use_type = int(request.REQUEST.get('use_type', 0))
    flag = int(request.REQUEST.get('flag', 0))
    hero_name = request.REQUEST.get('hero_name', "")
    start_time = request.REQUEST.get('start_time',
                                     yesterday.strftime("%Y-%m-%d 00:00:00"))
    end_time = request.REQUEST.get('end_time',
                                   now.strftime("%Y-%m-%d 00:00:00"))
    logging.debug(u"查询用户武将日志.name[%s], server_id[%s]" % (name, server_id))
    if name and server_id:
        total, infos = user_business.get_user_hero_log(server_id, name,
                                                       hero_name, start_time,
                                                       end_time, use_type,
                                                       flag, page, pagesize)
    else:
        total, infos = 0, []

    use_type_list = tool_use_type_map.keys()

    return render_to_response(request, "manager/user_hero_log.html", locals())
Beispiel #10
0
def user_level_stat(request):
    server_id = request.REQUEST.get("server_id", None)
    date = request.REQUEST.get("date", None)
    if not date:
        date = datetime.now().strftime("%Y-%m-%d")
    logging.debug(u"用户等级统计.date[%s], server_id[%s]" % (date, server_id))

    datas = {}

    if server_id:
        user_level_stat = stat_business.get_user_level_stat(server_id, date)
        if user_level_stat:
            stat_data = json.loads(user_level_stat.data)
            level_infos = []
            for i in range(1, 121):
                new_line = False
                if i % 10 == 0:
                    new_line = True
                level_infos.append({"level": i, "total": stat_data.get(u"%s" % i, 0), "new_line": new_line})
            datas["level_infos"] = level_infos

    datas["date"] = date
    datas["server_id"] = server_id

    return render_to_response(request, "stat/user_level_stat.html", datas)
Beispiel #11
0
def user_gold_use_log(request):

    now = datetime.now()
    yesterday = now - timedelta(days=1)

    name = request.REQUEST.get('name', "")
    page = int(request.REQUEST.get('page', 1))
    pagesize = int(request.REQUEST.get('pagesize', 20))
    server_id = request.REQUEST.get('server_id', '')
    use_type = int(request.REQUEST.get('use_type', 0))
    flag = int(request.REQUEST.get('flag', 0))
    amount = request.REQUEST.get('amount', 0)
    start_time = request.REQUEST.get('start_time',
                                     yesterday.strftime("%Y-%m-%d 00:00:00"))
    end_time = request.REQUEST.get('end_time',
                                   now.strftime("%Y-%m-%d 00:00:00"))
    logging.debug(u"查询用户金币日志.name[%s], server_id[%s]" % (name, server_id))
    if name and server_id:
        total, infos = user_business.get_user_gold_use_log(
            server_id, name, start_time, end_time, use_type, flag, page,
            pagesize, amount)
    else:
        total, infos = 0, []

    use_type_list = set()
    for info in infos:
        use_type_list.add(info["use_type"])

    return render_to_response(request, "manager/user_gold_use_log.html",
                              locals())
Beispiel #12
0
def add_partner_service(request):
    if request.method == "POST":
        pid = request.POST.get("pid", None)
        for s in request.POST.getlist('selectedServer'):
            partnerServices = PartnerService()
            partnerServices.sid = int(s)
            partnerServices.pid = int(pid)
            partnerServices.persist()

        partners = Partner.query()
        partnerServices = PartnerService.query(condition='pid=' + pid)
        services = []
        filterservices = Service.query()
        for p in partnerServices:
            service = Service.load(sid=p.sid)
            services.append(service)
        if services:
            filterservices.extend(services)
            filterservices = list(set(filterservices))
        data = {
            'post_path': request.get_full_path(),
            'services': services,
            'partners': partners,
            'pid': pid,
            'filterservices': filterservices
        }
        response = render_to_response(request, "admin/partner.html", data)
        return response
Beispiel #13
0
def index(request):
    '''首页'''
    services = Service.query()
    data = {'post_path': request.get_full_path(), 'services': services}
    response = render_to_response(request, "index.html", data)

    return response
Beispiel #14
0
def white_ip_list(request):
    page = int(request.REQUEST.get("page", 1))
    pagesize = int(request.REQUEST.get("pagesize", 20))
    ucenter = request.REQUEST.get("ucenter", "android")
    ip = request.REQUEST.get("ip", "")
    infos, total = admin_business.get_game_web_white_ip_list(ucenter, page, pagesize, ip)
    return render_to_response(request, "admin/white_ip_list.html", locals())
Beispiel #15
0
def notice_list(request):

    page = int(request.REQUEST.get("page", 1))
    pagesize = int(request.REQUEST.get("pagesize", 15))
    infos, total = notice_business.get_notice_list(page, pagesize)

    return render_to_response(request, "manager/notice_list.html", locals())
Beispiel #16
0
def user_hero_info(request):
    name = request.REQUEST.get('name', "")
    server_id = request.REQUEST.get('server_id', 0)
    logging.debug(u"查询用户武将信息.name[%s], server_id[%s]" % (name, server_id))
    if name and server_id:
        user_hero_info = user_business.get_user_hero_info(server_id, name)
    return render_to_response(request, "manager/user_hero_info.html", locals())
Beispiel #17
0
def system_mall_discount_sync(request):

    did = int(request.REQUEST.get('did', 0))

    system_mall_discount = activity_business.get_system_mall_discount(did)
    server_id = system_mall_discount.server_ids.split(",")[0]

    detail_list = activity_business.get_system_mall_discount_detail_list(did)
    discount_map = {}
    for detail in detail_list:
        discount_map[detail.mall_id] = detail.discount

    mall_list = activity_business.get_system_mall_list(server_id)
    infos = []
    for mall in mall_list:
        mall_id = mall["mall_id"]
        amount = mall["amount"]
        money_type = mall["money_type"]
        discount = discount_map.get(mall_id, 100)
        if discount == 100:
            continue
        discount_price = amount * discount / 100
        infos.append({
            "name": mall["name"],
            "mall_id": mall_id,
            "discount": discount,
            "money_type": money_type,
            "amount": amount,
            "price": amount,
            "discount_price": discount_price
        })

    return render_to_response(request,
                              "manager/system_mall_discount_sync.html",
                              locals())
Beispiel #18
0
def user_level_stat(request):
    server_id = request.REQUEST.get('server_id', None)
    date = request.REQUEST.get('date', None)
    if not date:
        date = datetime.now().strftime("%Y-%m-%d")
    logging.debug(u"用户等级统计.date[%s], server_id[%s]" % (date, server_id))
    
    datas = {}
    
    if server_id:
        user_level_stat = stat_business.get_user_level_stat(server_id, date)
        if user_level_stat:
            stat_data = json.loads(user_level_stat.data)
            level_infos = []
            for i in range(1, 121):
                new_line = False
                if i % 10 == 0:
                    new_line = True
                level_infos.append({'level': i, 'total': stat_data.get(u'%s' % i, 0), 'new_line': new_line})
            datas['level_infos'] = level_infos
   
    datas['date'] = date 
    datas['server_id'] = server_id 
    
    return render_to_response(request, "stat/user_level_stat.html", datas)
Beispiel #19
0
def add_partner_service(request):
    if request.method == "POST":
        pid = request.POST.get("pid",None)
        for s in request.POST.getlist('selectedServer'):
            partnerServices = PartnerService()
            partnerServices.sid = int(s)
            partnerServices.pid = int(pid)
            partnerServices.persist()
            
        partners = Partner.query()
        partnerServices = PartnerService.query(condition='pid='+pid) 
        services = []
        filterservices = Service.query()
        for p in partnerServices:
            service = Service.load(sid=p.sid)
            services.append(service)
        if services:
            filterservices.extend(services)
            filterservices = list(set(filterservices))
        data = {
            'post_path': request.get_full_path(),
            'services': services,
            'partners':partners,
            'pid':pid,
            'filterservices':filterservices
            } 
        response = render_to_response(request, "admin/partner.html",data)
        return response
Beispiel #20
0
def add_service(request):
    '''添加修改服务器'''
    if request.method == 'GET':
        response = render_to_response(request, "admin/add_service.html")
        return response

    elif request.method == 'POST':
        sid = request.POST.get('sid',None)
        s_num = request.POST.get('s_num',None)
        s_name = request.POST.get('s_name',None)
        db_connect = request.POST.get('db_connect',None)
        open_time = request.POST.get('open_time',None)
        isdel = request.POST.get('isdel',None)
        s_port = request.POST.get('s_port',None)
        db_connect_stat = request.POST.get('db_connect_stat',None)
        
        if not s_num or not s_name or not db_connect or not open_time or not isdel or not s_port or not db_connect_stat :
            error_message = "所有的字段都不能为空"
            data = {'error_message': error_message,
                    'post_path': request.get_full_path()}
            return render_to_response(request, 'admin/add_service.html', data)
        else:
            service = Service()
            service.s_num = s_num
            service.s_name = s_name
            service.db_connect = db_connect
            service.open_time = open_time
            service.isdel = isdel
            service.s_port = s_port
            service.db_connect_stat = db_connect_stat
            service.edit_time = datetime.datetime.now() 
            service.sid = sid
            error_message = None
            try:
                service.persist()
            except Exception, e:
                error_message = "出错了!"
                response = render_to_response(request, "admin/add_service.html",{'error_message': error_message,'service': service})
                return response
            
            services = Service.query()
            data = {
                    'post_path': request.get_full_path(),
                    'services': services
                    } 
            response = render_to_response(request, "admin/index.html",data)
            return response
Beispiel #21
0
def currdate_register(request):
    begindate = request.REQUEST.get('begindate', "")
    server_id = request.REQUEST.get('server_id', "")
    logging.debug(u"查询注册数据信息.begindate[%s], server_id[%s]" %
                  (begindate, server_id))
    if begindate and server_id:
        stats = user_business.get_user_register(server_id, begindate)
    return render_to_response(request, "manager/user_register.html", locals())
Beispiel #22
0
def system_mall_discount_list(request):
    page = int(request.REQUEST.get('page', 1))
    pagesize = int(request.REQUEST.get('pagesize', 20))
    infos, total = activity_business.get_system_mall_discount_list(
        page, pagesize)
    return render_to_response(request,
                              "manager/system_mall_discount_list.html",
                              locals())
Beispiel #23
0
def system_mail_list(request):

    page = int(request.REQUEST.get("page", 1))
    pagesize = int(request.REQUEST.get("pagesize", 15))
    infos, total = mail_business.get_system_mail_list(page, pagesize)

    return render_to_response(request, "manager/system_mail_list.html",
                              locals())
Beispiel #24
0
def update_service(request,offset):
    try:
        offset = int(offset)
        service = Service.load(sid = offset)
        response = render_to_response(request, "admin/add_service.html",{'service': service})
        return response
    except ValueError:
        raise Http404()
Beispiel #25
0
def stat_liucun_server(request):
    logging.debug(u"查询服务器留存信息")
    server_id = request.REQUEST.get('server_id', "")
    if server_id:
        stats = stat_server_business.get_stat_liucun_server(server_id)
    return render_to_response(request,
                              "manager/stat_server_liucun_server.html",
                              locals())
Beispiel #26
0
def update_service(request, offset):
    try:
        offset = int(offset)
        service = Service.load(sid=offset)
        response = render_to_response(request, "admin/add_service.html",
                                      {'service': service})
        return response
    except ValueError:
        raise Http404()
Beispiel #27
0
def service(request):
    '''服务器列表'''
    services = Service.query()
    data = {
            'post_path': request.get_full_path(),
            'services': services
            } 
    response = render_to_response(request, "admin/index.html",data)
    return response
Beispiel #28
0
def black_imei_list(request):
    """升级包列表"""
    ucenter = request.REQUEST.get('ucenter', 'android')
    page = int(request.REQUEST.get('pagesize', 1))
    imei = request.REQUEST.get('imei', "")
    
    pagesize = 20
    total, infos = blackimei_business.get_black_imei_list(ucenter, page, imei, pagesize)
    return render_to_response(request, "admin/black_imei_list.html", locals())
Beispiel #29
0
def user_payment_stat(request):
    
    now = datetime.now()
    
    server_id = request.REQUEST.get('server_id', 0)
    start_date = request.REQUEST.get('start_date', now.strftime("%Y-%m-%d"))
    end_date = request.REQUEST.get('end_date', now.strftime("%Y-%m-%d"))
    
    if server_id:
        user_payment_stat = stat_business.get_user_payment_stat(server_id, start_date, end_date)
    return render_to_response(request, "stat/user_payment_stat.html", locals())
Beispiel #30
0
def user_payment_stat(request):

    now = datetime.now()

    server_id = request.REQUEST.get("server_id", 0)
    start_date = request.REQUEST.get("start_date", now.strftime("%Y-%m-%d"))
    end_date = request.REQUEST.get("end_date", now.strftime("%Y-%m-%d"))

    if server_id:
        user_payment_stat = stat_business.get_user_payment_stat(server_id, start_date, end_date)
    return render_to_response(request, "stat/user_payment_stat.html", locals())
Beispiel #31
0
def stat_server(request):
    begindate = request.REQUEST.get('begindate', "")
    enddate = request.REQUEST.get('enddate', "")
    logging.debug(u"查询服务器信息.begindate[%s], enddate[%s]" % (begindate, enddate))
    if enddate:
        stat_server_datas_map, total, server_zone_map = stat_server_business.get_stat_server(
            begindate, enddate)
    else:
        stat_server_datas_map, total, server_zone_map = stat_server_business.get_stat_server(
            begindate)
    return render_to_response(request, "manager/server_stat.html", locals())
Beispiel #32
0
def system_mall_discount_detail_list(request):

    did = int(request.REQUEST.get('did', 0))

    if request.method == "POST":
        infos = []
        for i in range(1, 300):
            mall_id = request.REQUEST.get("mall_id_%s" % i)
            discount = request.REQUEST.get("discount_%s" % i, 100)
            if not discount:
                discount = 100
            discount = int(discount)
            if mall_id and discount and discount != 100:
                info = {
                    'system_mall_discount_activity_id': did,
                    'discount': discount,
                    'mall_id': mall_id
                }
                infos.append(info)
        #save
        activity_business.save_system_mall_discount_detail(did, infos)

        return redirect("/manager/system_mall_discount_detail_list?did=%s" %
                        did)

    system_mall_discount = activity_business.get_system_mall_discount(did)
    server_id = system_mall_discount.server_ids.split(",")[0]

    detail_list = activity_business.get_system_mall_discount_detail_list(did)
    discount_map = {}
    for detail in detail_list:
        discount_map[detail.mall_id] = detail.discount

    mall_list = activity_business.get_system_mall_list(server_id)
    infos = []
    for mall in mall_list:
        mall_id = mall["mall_id"]
        amount = mall["amount"]
        money_type = mall["money_type"]
        discount = discount_map.get(mall_id, 100)
        discount_price = amount * discount / 100
        infos.append({
            "name": mall["name"],
            "mall_id": mall_id,
            "discount": discount,
            "money_type": money_type,
            "amount": amount,
            "price": amount,
            "discount_price": discount_price
        })

    return render_to_response(request,
                              "manager/system_mall_discount_detail_list.html",
                              locals())
Beispiel #33
0
def package_list(request):
    """升级包列表"""
    ucenter = request.REQUEST.get('ucenter', 'android')
    page = int(request.REQUEST.get('page', 1))
    version = request.REQUEST.get('version', "")
    pagesize = 20
    
    is_test = 0 if user_roles.had_privilege(request, PageConstant.page_package_info_id, 11) else 1
    
    total, infos = package_business.get_package_list(ucenter, version, page, pagesize)
    return render_to_response(request, "admin/package_list.html", locals())
Beispiel #34
0
def game_web_status_list(request):
    
    infos = []
    if DEBUG:
        ucenter_list = ("android", "ios",)
    else:
        ucenter_list = ("android", "ios",)
    for ucenter in ucenter_list:
        status = admin_business.get_game_web_status(ucenter)
        infos.append({"ucenter": ucenter, "status": status})
        
    return render_to_response(request, "admin/game_web_status_list.html", locals())         
Beispiel #35
0
def delete_service(request, offset):
    '''删除服务器'''
    try:
        offset = int(offset)
    except ValueError:
        raise Http404()
    service = Service.load(sid=offset)
    service.isdel = 1
    service.persist()
    services = Service.query()
    data = {'post_path': request.get_full_path(), 'services': services}
    response = render_to_response(request, "admin/index.html", data)
    return response
Beispiel #36
0
def system_exchange_sync(request):

    eid = int(request.REQUEST.get('eid', 0))

    infos = activity_business.get_system_tool_exchange_detail_list(eid)
    max_index = 1
    for info in infos:
        setattr(info, "index", max_index)
        max_index += 1

    exchange_info = activity_business.get_system_tool_exchange(eid)

    return render_to_response(request, "manager/system_exchange_sync.html",
                              locals())
Beispiel #37
0
def system_exchange_list(request):
    page = int(request.REQUEST.get('page', 1))
    show_all = int(request.REQUEST.get('all', 0))
    pagesize = int(request.REQUEST.get('pagesize', 20))
    username = None
    if show_all == 0:
        user = user_roles.get_userinfo(request)
        if user:
            username = user.username

    infos, total = activity_business.get_system_tool_exchange_list(
        page, pagesize, username=username)
    return render_to_response(request, "manager/system_exchange_list.html",
                              locals())
Beispiel #38
0
def user_tool_use_log(request):

    now = datetime.now()
    yesterday = now - timedelta(days=1)

    name = request.REQUEST.get('name', "")
    page = int(request.REQUEST.get('page', 1))
    pagesize = int(request.REQUEST.get('pagesize', 20))
    server_id = request.REQUEST.get('server_id', '')
    use_type = int(request.REQUEST.get('use_type', 0))
    flag = int(request.REQUEST.get('flag', 0))
    tool_type = int(request.REQUEST.get('tool_type', 0))
    tool_id = int(request.REQUEST.get('tool_id', 0))
    start_time = request.REQUEST.get('start_time',
                                     yesterday.strftime("%Y-%m-%d 00:00:00"))
    end_time = request.REQUEST.get('end_time',
                                   now.strftime("%Y-%m-%d 00:00:00"))
    logging.debug(u"查询用户道具日志.name[%s], server_id[%s]" % (name, server_id))
    if name and server_id:
        total, infos = user_business.get_user_tool_use_log(
            server_id, name, start_time, end_time, use_type, flag, page,
            pagesize, tool_type, tool_id)
    else:
        total, infos = 0, []

    #use_type_list = set()
    tool_type_list = set()
    tool_id_list = set()
    tool_id_infos = []
    for info in infos:
        info_tool_id = info["tool_id"]
        info_tool_type = info["tool_type"]
        #use_type_list.add(info["use_type"])
        tool_type_list.add(info["tool_type"])
        tool_name = user_business.get_tool_name(server_id, info_tool_type,
                                                info_tool_id)
        info["tool_name"] = tool_name
        if info_tool_type not in (ToolType.TOOL_TYPE_HERO,
                                  ToolType.TOOL_TYPE_EQUIP):
            if info_tool_id not in tool_id_list:
                tool_id_list.add(info_tool_id)
                tool_id_infos.append({
                    "tool_id": info_tool_id,
                    "tool_name": tool_name
                })

    use_type_list = tool_use_type_map.keys()

    return render_to_response(request, "manager/user_tool_use_log.html",
                              locals())
Beispiel #39
0
def user_level_rank_stat(request):
    server_id = request.REQUEST.get('server_id', None)
    date = request.REQUEST.get('date', None)
    if not date:
        date = datetime.now().strftime("%Y-%m-%d")
    logging.debug(u"用户等级排名统计.date[%s], server_id[%s]" % (date, server_id))
    
    datas = {}
    
    if server_id:
        user_level_rank_stat = stat_business.get_user_level_rank_stat(server_id, date)
        if user_level_rank_stat:
            infos = json.loads(user_level_rank_stat.data)
   
    return render_to_response(request, "stat/user_level_rank_stat.html", locals())
Beispiel #40
0
def system_notice_list(request):
    
    if SERVER_TYPE == 1:
        default_ucenter = "android"
    else:
        default_ucenter = "android"
    ucenter = request.REQUEST.get('ucenter', default_ucenter)
    page = int(request.REQUEST.get('page', 1))
    server_id = request.REQUEST.get('server_id', "")
    partner_id = request.REQUEST.get('partner_id', "")
    pagesize = 20
    
    total, infos = admin_business.get_notice_list(ucenter, server_id, partner_id, page, pagesize)

    return render_to_response(request, "admin/notice_list.html", locals()) 
Beispiel #41
0
def user_level_rank_stat(request):
    server_id = request.REQUEST.get("server_id", None)
    date = request.REQUEST.get("date", None)
    if not date:
        date = datetime.now().strftime("%Y-%m-%d")
    logging.debug(u"用户等级排名统计.date[%s], server_id[%s]" % (date, server_id))

    datas = {}

    if server_id:
        user_level_rank_stat = stat_business.get_user_level_rank_stat(server_id, date)
        if user_level_rank_stat:
            infos = json.loads(user_level_rank_stat.data)

    return render_to_response(request, "stat/user_level_rank_stat.html", locals())
Beispiel #42
0
def delete_service(request,offset):
    '''删除服务器'''
    try:
        offset = int(offset)
    except ValueError:
        raise Http404()
    service = Service.load(sid=offset)
    service.isdel = 1
    service.persist()
    services = Service.query()
    data = {
            'post_path': request.get_full_path(),
            'services': services
            } 
    response = render_to_response(request, "admin/index.html",data)
    return response
Beispiel #43
0
def user_draw_time_rank(request):

    server_id = request.REQUEST.get("server_id", None)
    to_excel = int(request.REQUEST.get("to_excel", 0))
    if server_id:
        infos = stat_business.get_user_draw_time_rank(server_id)
        if to_excel == 1:
            datas = []
            datas.append(u"排名,玩家名称,玩家ID,积分")
            for i, info in enumerate(infos):
                datas.append(u"%s,%s,%s,%s" % (i + 1, info["username"], info["lodo_id"], info["score"]))
            response = HttpResponse("\n".join(datas), mimetype="application/vnd.ms-excel")
            response["Content-Disposition"] = "attachment; filename=user_draw_rank_%s.csv" % server_id
            return response

    return render_to_response(request, "stat/user_draw_time_rank.html", locals())
Beispiel #44
0
def user_level_up_log(request):
    
    now = datetime.now()
    yesterday = now - timedelta(days=1)
    
    name = request.REQUEST.get('name', "")
    page = int(request.REQUEST.get('page', 1))
    pagesize = int(request.REQUEST.get('pagesize', 20))
    server_id = request.REQUEST.get('server_id', '')
    logging.debug(u"查询用户升级日志.name[%s], server_id[%s]" % (name, server_id))
    if name and server_id:    
        total, infos = user_business.get_user_level_up_log(server_id, name, page, pagesize)
    else:
        total, infos = 0, []

    return render_to_response(request, "manager/user_level_up_log.html", locals())
Beispiel #45
0
def user_payment_log(request):
    
    now = datetime.now()
    yesterday = now - timedelta(days=1)
    
    name = request.REQUEST.get('name', "")
    page = int(request.REQUEST.get('page', 1))
    pagesize = int(request.REQUEST.get('pagesize', 20))
    server_id = request.REQUEST.get('server_id', '')
    start_time = request.REQUEST.get('start_time', yesterday.strftime("%Y-%m-%d 00:00:00"))
    end_time = request.REQUEST.get('end_time', now.strftime("%Y-%m-%d 00:00:00"))
    logging.debug(u"查询用户充值日志.name[%s], server_id[%s]" % (name, server_id))
    if name and server_id:    
        total, infos = user_business.get_user_payment_log(server_id, name, start_time, end_time, page, pagesize)
    else:
        total, infos = 0, []
        
    return render_to_response(request, "manager/user_payment_log.html", locals())
Beispiel #46
0
def user_reg_stat(request):

    now = datetime.now()

    server_id = request.REQUEST.get("server_id", 0)
    partner_id = request.REQUEST.get("partner_id", 0)
    start_date = request.REQUEST.get("start_date", now.strftime("%Y-%m-%d"))
    end_date = request.REQUEST.get("end_date", now.strftime("%Y-%m-%d"))

    if server_id:
        if partner_id:
            user_reg_stat = []
            partner_id = int(partner_id)
            data = stat_business.get_user_reg_stat_by_pid(server_id, partner_id, start_date, end_date)
            user_reg_stat.append(data)
        else:
            user_reg_stat = stat_business.get_user_reg_stat_all(server_id, start_date, end_date)
    return render_to_response(request, "stat/user_reg_stat.html", locals())
Beispiel #47
0
def add_privilege(request):
    params = request.GET.get('params', '')
    user_id = request.GET.get('user_id','')
    if params and user_id:      
        ps = params.split("-")
        for p in ps:
            if not p:
                continue
            infos = p.split(",")
            if len(infos)==3:
                user_page_id, key, value = infos[0], infos[1], infos[2]
                userpage_business.add_userpage(user_id, key, value,user_page_id)
            else:
                key, value = infos[0], infos[1]
                userpage_business.add_userpage(user_id, key, value)
    
    infos = admin_business.get_page_all_list(user_id)
    return render_to_response(request, "admin/privilege.html", locals())
Beispiel #48
0
def user_payment_rank(request):
    server_id = request.REQUEST.get("server_id", None)
    now = datetime.now()
    start_date = request.REQUEST.get("start_date", now.strftime("%Y-%m-%d"))
    end_date = request.REQUEST.get("end_date", now.strftime("%Y-%m-%d"))
    amount = request.REQUEST.get("amount", 0)
    to_excel = int(request.REQUEST.get("to_excel", 0))
    if server_id:
        infos = stat_business.get_user_payment_rank(server_id, start_date, end_date, amount)
        if to_excel == 1:
            datas = []
            datas.append(u"排名,玩家名称,玩家ID,充值金额")
            for i, info in enumerate(infos):
                datas.append(u"%s,%s,%s,%s" % (i + 1, info["username"], info["lodo_id"], info["amount"]))
            response = HttpResponse("\n".join(datas), mimetype="application/vnd.ms-excel")
            response["Content-Disposition"] = "attachment; filename=user_payment_rank_%s.csv" % server_id
            return response

    return render_to_response(request, "stat/user_payment_rank.html", locals())
Beispiel #49
0
def payment_order_list(request):
    """订单列表"""
    default_ucenter = 'android'
    if SERVER_TYPE == 2:
        default_ucenter = 'android'
    ucenter = request.REQUEST.get('ucenter', default_ucenter)
    page = int(request.REQUEST.get('page', 1))
    server_id = request.REQUEST.get('server_id', "")
    name = request.REQUEST.get('name', "")
    
    pagesize = 20
    total, infos = 0, []
    
    is_test = 0 if user_roles.had_privilege(request, PageConstant.page_fill_order, 11) else 1
    
    if server_id and name:
        total, infos = payment_business.get_payment_order_list(ucenter, name, server_id, page, pagesize)
    
    return render_to_response(request, "admin/payment_order_list.html", locals())    
Beispiel #50
0
def user_draw_power_rank(request):

    server_id = request.REQUEST.get("server_id", None)
    to_excel = int(request.REQUEST.get("to_excel", 0))
    now = datetime.now()
    date = request.REQUEST.get("start_date", now.strftime("%Y-%m-%d"))
    if server_id:
        infos = stat_business.get_user_draw_power_rank(server_id, date)
        for info in infos:
            jsoninfo = json.loads(info["rank_data"])
        if to_excel == 1:
            datas = []
            datas.append(u"排名,玩家名称,战力")
            for i, info in enumerate(jsoninfo):
                datas.append(u"%s,%s,%s" % (i + 1, info["username"], info["power"]))
            response = HttpResponse("\n".join(datas), mimetype="application/vnd.ms-excel")
            response["Content-Disposition"] = "attachment; filename=user_draw_rank_%s.csv" % server_id
            return response

    return render_to_response(request, "stat/user_draw_power_rank.html", locals())
Beispiel #51
0
def server_partner_list(request):
    server_id = request.REQUEST.get("server_id")
    server_zone = int(request.REQUEST.get("server_zone", 0))
    if not server_zone:
        server = server_business.get_server(server_id)
        server_zone = server.server_zone
        
    infos = partner_business.get_partner_list_by_server_zone(server_zone)
    
    server_partner_list = server_business.get_server_partner_list(server_id)
    server_partner_set = set()
    for server_partner in server_partner_list:
        server_partner_set.add(server_partner.partner_id)

    for info in infos:
        if info.partner_id in server_partner_set:
            setattr(info, "checked", 1)
        else:
            setattr(info, "checked", 0)
        
    return render_to_response(request, "admin/server_partner_list.html", locals())
Beispiel #52
0
def giftcode_list(request):
    """礼包码管理"""
    category = request.REQUEST.get('category', 'ad')
    gift_bag_type = request.REQUEST.get('gift_bag_type', "")
    sub_type = request.REQUEST.get('sub_type', 0)
    gift_code = request.REQUEST.get('gift_code', "")
    page = int(request.REQUEST.get('page', 1))
    to_excel = int(request.REQUEST.get('to_excel', 0))
    total, pagesize = 0, 20
    if gift_bag_type:
        if to_excel == 1:
            pagesize = 1000000
        total, infos = gift_code_business.get_giftcode_list(category, gift_bag_type, sub_type, gift_code, page, pagesize)
        if to_excel == 1:
            datas = []
            for info in infos:
                datas.append(u"%s" % info["code"])    
            response = HttpResponse("\r\n".join(datas), mimetype='text/plain')
            response['Content-Disposition'] = 'attachment; filename=gift_code_%s_%s_%s.txt' % (gift_bag_type, sub_type, category)
            return response
    return render_to_response(request, "admin/gift_code_list.html", locals())
Beispiel #53
0
def user_tool_use_log(request):
    
    now = datetime.now()
    yesterday = now - timedelta(days=1)
    
    name = request.REQUEST.get('name', "")
    page = int(request.REQUEST.get('page', 1))
    pagesize = int(request.REQUEST.get('pagesize', 20))
    server_id = request.REQUEST.get('server_id', '')
    use_type = int(request.REQUEST.get('use_type', 0))
    flag = int(request.REQUEST.get('flag', 0))
    tool_type = int(request.REQUEST.get('tool_type', 0))
    tool_id = int(request.REQUEST.get('tool_id', 0))
    start_time = request.REQUEST.get('start_time', yesterday.strftime("%Y-%m-%d 00:00:00"))
    end_time = request.REQUEST.get('end_time', now.strftime("%Y-%m-%d 00:00:00"))
    logging.debug(u"查询用户道具日志.name[%s], server_id[%s]" % (name, server_id))
    if name and server_id:    
        total, infos = user_business.get_user_tool_use_log(server_id, name, start_time, end_time, use_type, flag, page, pagesize, tool_type, tool_id)
    else:
        total, infos = 0, []
        
    #use_type_list = set()
    tool_type_list = set()
    tool_id_list = set()
    tool_id_infos = []
    for info in infos:
        info_tool_id = info["tool_id"]
        info_tool_type = info["tool_type"]
        #use_type_list.add(info["use_type"])
        tool_type_list.add(info["tool_type"])
        tool_name= user_business.get_tool_name(server_id, info_tool_type, info_tool_id)
        info["tool_name"] = tool_name
        if info_tool_type not in (ToolType.TOOL_TYPE_HERO, ToolType.TOOL_TYPE_EQUIP):
            if info_tool_id not in tool_id_list:
                tool_id_list.add(info_tool_id)
                tool_id_infos.append({"tool_id": info_tool_id, "tool_name": tool_name})
                
    use_type_list = tool_use_type_map.keys()
        
    return render_to_response(request, "manager/user_tool_use_log.html", locals())
Beispiel #54
0
def user_hero_log(request):
    
    now = datetime.now()
    yesterday = now - timedelta(days=1)
    
    name = request.REQUEST.get('name', "")
    page = int(request.REQUEST.get('page', 1))
    pagesize = int(request.REQUEST.get('pagesize', 20))
    server_id = request.REQUEST.get('server_id', '')
    use_type = int(request.REQUEST.get('use_type', 0))
    flag = int(request.REQUEST.get('flag', 0))
    hero_name = request.REQUEST.get('hero_name', "")
    start_time = request.REQUEST.get('start_time', yesterday.strftime("%Y-%m-%d 00:00:00"))
    end_time = request.REQUEST.get('end_time', now.strftime("%Y-%m-%d 00:00:00"))
    logging.debug(u"查询用户武将日志.name[%s], server_id[%s]" % (name, server_id))
    if name and server_id:    
        total, infos = user_business.get_user_hero_log(server_id, name, hero_name, start_time, end_time, use_type, flag, page, pagesize)
    else:
        total, infos = 0, []
        
    use_type_list = tool_use_type_map.keys()
        
    return render_to_response(request, "manager/user_hero_log.html", locals())