コード例 #1
0
def update_user_level(server_id, user_id, level):
    level = int(level)
    db_config = server_business.get_server_db_connect(server_id=server_id)
    connect = get_connection(db_config)
    cursor = connect.cursor()
    try:
        info = cursor.fetchone("select exp from system_user_level where user_level = %s" % (level + 1))
        if info:
            exp = info["exp"] - 10
        else:
            exp = 10000 * 10000
        
        server = server_business.get_server(server_id)
        host = server.server_host
    
        path = "/gameApi/updateUserLevel.do"
        logging.debug("host:[%s], path[%s]" % (host, path))
        data = {"userId": user_id, "level": level, "exp": exp}
    
        post = Post(data, host, path, port=8088)
        content = post.submit(result_keyword=None, get_content=True, debug=True)
        try:
            info = json.loads(content)
            return info.get("rc", 3000) == 1000
        except:
            logging.debug("bad json format:[%s]" % content)
    finally:
        cursor.close()
コード例 #2
0
def server_name(server_id):
    server = server_business.get_server(server_id)
    if server:
        if server.is_test:
            return u"%s-%s" % (server.server_name, server.server_id)
        else:
            return u"%s-%s" % (server.server_name, server.server_id)
コード例 #3
0
def server_name(server_id):
    server = server_business.get_server(server_id)
    if server:
        if server.is_test:
            return u"%s-%s" % (server.server_name, server.server_id)
        else:
            return u"%s-%s" % (server.server_name, server.server_id)
コード例 #4
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())
コード例 #5
0
def add_system_mail(request, info):
    """保存系统邮件"""
    logging.info(u"保存系统邮件")
    user = user_roles.get_userinfo(request)
    if user:
        username = user.username
    else:
        username = ""
        
    info["created_user"] = username
    info["status"] = 0
    info["approve_time"] = datetime.now()
    if not info["date"]:
        info["date"] = datetime.now()
        
    if info.get("lodo_ids"):
        lodo_id_set = set()
        lodo_id_list = info["lodo_ids"].split(",")
        for lodo_id in lodo_id_list:
            lodo_id_set.add(str(lodo_id.strip()))
        info["lodo_ids"] = ",".join(lodo_id_set)

    server_ids = info["server_ids"]
    server_id_list = server_ids.split(",")
    for server_id in server_id_list:
        server = server_business.get_server(server_id)
        if server.is_test == 0:#没有正式服权限
            if not user_roles.had_privilege(request, PageConstant.page_send_mail_id, 11):
                return -1

    return mail_business.add_system_mail(info)
コード例 #6
0
def update_user_level(server_id, user_id, level):
    level = int(level)
    db_config = server_business.get_server_db_connect(server_id=server_id)
    connect = get_connection(db_config)
    cursor = connect.cursor()
    try:
        info = cursor.fetchone(
            "select exp from system_user_level where user_level = %s" %
            (level + 1))
        if info:
            exp = info["exp"] - 10
        else:
            exp = 10000 * 10000

        server = server_business.get_server(server_id)
        host = server.server_host

        path = "/gameApi/updateUserLevel.do"
        logging.debug("host:[%s], path[%s]" % (host, path))
        data = {"userId": user_id, "level": level, "exp": exp}

        post = Post(data, host, path, port=8088)
        content = post.submit(result_keyword=None,
                              get_content=True,
                              debug=True)
        try:
            info = json.loads(content)
            return info.get("rc", 3000) == 1000
        except:
            logging.debug("bad json format:[%s]" % content)
    finally:
        cursor.close()
コード例 #7
0
ファイル: user_service.py プロジェクト: smsg-game/smsg-server
def update_user_vip_level(request, server_id, user_id, vip_level):
    """用户调级"""
    logging.info(u"用户VIP调级.server_id[%s, user_id[%s], level[%s]" % (server_id, user_id, vip_level))
    server = server_business.get_server(server_id)
    if server.is_test == 0:#没有正式服权限
        if not user_roles.had_privilege(request, PageConstant.page_update_user_vip_level, 11):
            return -1
    user_business.update_user_vip_level(server_id, user_id, vip_level)
    return 1
コード例 #8
0
ファイル: user_service.py プロジェクト: smsg-game/smsg-server
def block_user(request, server_id, user_id, due_time):
    """封号"""
    logging.info(u"用户封号.server_id[%s, user_id[%s], due_time[%s]" % (server_id, user_id, due_time))
    server = server_business.get_server(server_id)
    if server.is_test == 0:#没有正式服权限
        if not user_roles.had_privilege(request, PageConstant.page_ban_user, 11):
            return -1
    user_business.block_user(server_id, user_id, due_time)
    return 1
コード例 #9
0
def update_user_vip_level(request, server_id, user_id, vip_level):
    """用户调级"""
    logging.info(u"用户VIP调级.server_id[%s, user_id[%s], level[%s]" %
                 (server_id, user_id, vip_level))
    server = server_business.get_server(server_id)
    if server.is_test == 0:  #没有正式服权限
        if not user_roles.had_privilege(
                request, PageConstant.page_update_user_vip_level, 11):
            return -1
    user_business.update_user_vip_level(server_id, user_id, vip_level)
    return 1
コード例 #10
0
def block_user(request, server_id, user_id, due_time):
    """封号"""
    logging.info(u"用户封号.server_id[%s, user_id[%s], due_time[%s]" %
                 (server_id, user_id, due_time))
    server = server_business.get_server(server_id)
    if server.is_test == 0:  #没有正式服权限
        if not user_roles.had_privilege(request, PageConstant.page_ban_user,
                                        11):
            return -1
    user_business.block_user(server_id, user_id, due_time)
    return 1
コード例 #11
0
def sync_system_pay_reward(request, rid):

    system_pay_reward = activity_business.get_system_pay_reward(rid)
    server_id_list = system_pay_reward.server_ids.split(",")
    for server_id in server_id_list:
        server = server_business.get_server(server_id)
        if server.is_test == 0:  #没有正式服权限
            if not user_roles.had_privilege(
                    request, PageConstant.page_pay_reward_sync_id, 11):
                return -1, None

    return activity_business.sync_system_pay_reward(rid)
コード例 #12
0
def sync_system_tool_exchange(request, eid):

    system_tool_exchange = activity_business.get_system_tool_exchange(eid)
    server_id_list = system_tool_exchange.server_ids.split(",")
    for server_id in server_id_list:
        server = server_business.get_server(server_id)
        if server.is_test == 0:  #没有正式服权限
            if not user_roles.had_privilege(
                    request, PageConstant.page_tool_exchange_sync_id, 11):
                return -1, None

    return activity_business.sync_system_tool_exchange(eid)
コード例 #13
0
def sync_system_mall_discount(request, did):
    print did
    system_mall_discount = activity_business.get_system_mall_discount(did)
    server_id_list = system_mall_discount.server_ids.split(",")
    for server_id in server_id_list:
        server = server_business.get_server(server_id)
        if server.is_test == 0:  #没有正式服权限
            if not user_roles.had_privilege(
                    request, PageConstant.page_mall_discount_sync_id, 11):
                return -1, None

    return activity_business.sync_system_mall_discount(did)
コード例 #14
0
def block_user(server_id, user_id, due_time):
    info = {}
    info["userId"] = user_id
    info["dueTime"] = due_time

    server = server_business.get_server(server_id=server_id)
    url = "http://" + server.server_host + ":8088//gameApiAdmin/banUser.do"
    success, ret_val = http_util.request(url, info)
    if success:
        result = json.loads(ret_val)
        return result.get("rt") == 1000
    
    return False
コード例 #15
0
def block_user(server_id, user_id, due_time):
    info = {}
    info["userId"] = user_id
    info["dueTime"] = due_time

    server = server_business.get_server(server_id=server_id)
    url = "http://" + server.server_host + ":8088//gameApiAdmin/banUser.do"
    success, ret_val = http_util.request(url, info)
    if success:
        result = json.loads(ret_val)
        return result.get("rt") == 1000

    return False
コード例 #16
0
def update_user_vip_level(server_id, user_id, vip_level):
    info = {}
    info["userId"] = user_id
    info["vipLevel"] = vip_level

    server = server_business.get_server(server_id=server_id)
    url = "http://" + server.server_host + ":8088//gameApiAdmin/assignVipLevel.do"
    success, ret_val = http_util.request(url, info)
    if success:
        result = json.loads(ret_val)
        return result.get("rt") == 1000

    return False
コード例 #17
0
def update_user_vip_level(server_id, user_id, vip_level):
    info = {}
    info["userId"] = user_id
    info["vipLevel"] = vip_level

    server = server_business.get_server(server_id=server_id)
    url = "http://" + server.server_host + ":8088//gameApiAdmin/assignVipLevel.do"
    success, ret_val = http_util.request(url, info)
    if success:
        result = json.loads(ret_val)
        return result.get("rt") == 1000
    
    return False
コード例 #18
0
    def send_notice_to_server(self, server_id, content):
        info = {}
        timestamp = int(time.time() * 1000)
        info["timestamp"] = timestamp
        info["sign"] = md5mgr.mkmd5fromstr("%s%s%s" % (content, timestamp, "gCvKaE0tTcWtHsPkbRdE"))
        info["partnerIds"] = "all"
        info["content"] = content

        server = server_business.get_server(server_id=server_id)
        url = "http://" + server.server_host + ":8088//gameApi/sendSysMsg.do"
        success, ret_val = http_util.request(url, info)
        if success:
            result = json.loads(ret_val)
            return result.get("rt") == 1000
コード例 #19
0
def system_mail_approve(request, system_mail_id, approve):
    user = user_roles.get_userinfo(request)
    if user:
        username = user.username
    else:
        username = ""
        
    system_mail = mail_business.get_system_mail(system_mail_id)
    server_id_list = system_mail.server_ids.split(",")
    for server_id in server_id_list:
        server = server_business.get_server(server_id)
        if server.is_test == 0:#没有正式服权限
            if not user_roles.had_privilege(request, PageConstant.page_approve_mail_id, 11):
                return -1, None
           
    return mail_business.system_mail_approve(system_mail_id, username, int(approve) == 1)
コード例 #20
0
def add_system_pay_reward(request, rid, name, reward_type, server_ids):
    user = user_roles.get_userinfo(request)
    if user:
        username = user.username
    else:
        username = ""

    server_id_list = server_ids.split(",")
    for server_id in server_id_list:
        server = server_business.get_server(server_id)
        if server.is_test == 0:  #没有正式服权限
            if not user_roles.had_privilege(
                    request, PageConstant.page_pay_reward_id, 11):
                return -1

    return activity_business.add_system_pay_reward(rid, name, reward_type,
                                                   server_ids, username)
コード例 #21
0
def server_names(server_ids):
    s = ""
    if not server_ids:
        return ""
    server_id_list = server_ids.split(",")
    for server_id in server_id_list:
        server = server_business.get_server(server_id)
        if server:
            if s:
                s = "%s|%s[%s]" % (s, server.server_name, server_id)
            else:
                s = "%s[%s]" % (server.server_name, server_id)
        else:
            if s:
                s = "%s|%s[%s]" % (s, server_id, server_id)
            else:
                s = "%s[%s]" % (server_id, server_id)
    return s
コード例 #22
0
def server_names(server_ids):
    s = ""
    if not server_ids:
        return ""
    server_id_list = server_ids.split(",")
    for server_id in server_id_list:
        server = server_business.get_server(server_id)
        if server:
            if s:
                s = "%s|%s[%s]" % (s, server.server_name, server_id)
            else:
                s = "%s[%s]" % (server.server_name, server_id)
        else:
            if s:
                s = "%s|%s[%s]" % (s, server_id, server_id)
            else:
                s = "%s[%s]" % (server_id, server_id)
    return s
コード例 #23
0
def add_system_mall_discount(request, did, name, start_time, end_time,
                             server_ids):
    user = user_roles.get_userinfo(request)
    if user:
        username = user.username
    else:
        username = ""

    server_id_list = server_ids.split(",")
    for server_id in server_id_list:
        server = server_business.get_server(server_id)
        if server.is_test == 0:  #没有正式服权限
            if not user_roles.had_privilege(
                    request, PageConstant.page_mall_discount_id, 11):
                return -1

    return activity_business.add_system_mall_discount(did, name, start_time,
                                                      end_time, server_ids,
                                                      username)
コード例 #24
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())