Ejemplo n.º 1
0
def get_consume_table(search_start_date, search_end_date, server_id):
    #获取搜索区间日志
    new_log_lst = dat_log_util.read_file_with_filename("CONSUME_EQUIP",
                                                       search_start_date,
                                                       search_end_date,
                                                       server_id, 'tables')
    search_monster_log_list = []
    create_monster_action = set()
    head_name_lst = []
    for monster_log in new_log_lst:
        search_monster_log_list.append(monster_log)
        for action, num in monster_log[1].items():
            create_monster_action.add(action)

    for _act in create_monster_action:
        head_name_lst.append(game_define.EVENT_LOG_ACTION_DICT[_act])

    table_lst = []
    for create_monster_log in search_monster_log_list:
        item_config = game_config.get_item_config(create_monster_log[0])
        _name = item_config['name']
        row_lst = [
            _name,
        ]
        for _act in create_monster_action:
            row_lst.append(int(math.fabs(create_monster_log[1].get(_act, 0))))
        table_lst.append(row_lst)
    return table_lst, head_name_lst
Ejemplo n.º 2
0
def get_consume_table(search_start_date, search_end_date,server_id):
    #获取搜索区间日志
    new_log_lst = dat_log_util.read_file_with_filename("CONSUME_EQUIP",search_start_date,search_end_date,server_id,'tables')
    search_monster_log_list = []
    create_monster_action = set()
    head_name_lst = []
    for monster_log in new_log_lst:
        search_monster_log_list.append(monster_log)
        for action,num in monster_log[1].items():
            create_monster_action.add(action)

    for _act in create_monster_action:
        head_name_lst.append(game_define.EVENT_LOG_ACTION_DICT[_act])

    table_lst = []
    for create_monster_log in search_monster_log_list:
        item_config = game_config.get_item_config(create_monster_log[0])
        _name = item_config['name']
        row_lst = [
            _name,
        ]
        for _act in create_monster_action:
            row_lst.append(int(math.fabs(create_monster_log[1].get(_act, 0))))
        table_lst.append(row_lst)
    return table_lst, head_name_lst
Ejemplo n.º 3
0
def gift_package_lst(request):
    """
    礼包类型列表
    """
    data = {}
    table_list = []
    all_gift_dict = gift_package.get_all_gift()
    for key, val in all_gift_dict.items():
        temp_content = []
        str_server_lst = list_to_string(val['server_int_lst'])
        temp_content.insert(0, str(val['id']))
        temp_content.insert(
            1, str(game_define.PLAT_FORM_NAME_DICT[val['platform_id']]))
        temp_content.insert(2, str_server_lst)
        temp_content.insert(3, str(val['time']))
        temp_content.insert(4, str(val['endtime']))
        temp_content.insert(5, str(val['name']))
        item_config = game_config.get_item_config(val['item_id1'])
        if item_config:
            temp_content.insert(6, str(item_config['name']))
        else:
            temp_content.insert(6, str(u''))
        temp_content.insert(7, str(val['item_num1']))

        item_config = game_config.get_item_config(val['item_id2'])
        if item_config:
            temp_content.insert(8, str(item_config['name']))
        else:
            temp_content.insert(8, str(u''))
        temp_content.insert(9, str(val['item_num2']))

        item_config = game_config.get_item_config(val['item_id3'])
        if item_config:
            temp_content.insert(10, str(item_config['name']))
        else:
            temp_content.insert(10, str(u''))
        temp_content.insert(11, str(val['item_num3']))

        temp_content.insert(12, str(val['gold']))
        temp_content.insert(13, str(val['stone']))
        table_list.append(temp_content)
    data['gift_package'] = table_list
    data['head_lst'] = head_lst
    return render_to_response("gift_package/gift_package_lst.html", data,
                              RequestContext(request))
Ejemplo n.º 4
0
def gift_package_lst(request):
    """
    礼包类型列表
    """
    data = {}
    table_list = []
    all_gift_dict = gift_package.get_all_gift()
    for key, val in all_gift_dict.items():
        temp_content = []
        str_server_lst = list_to_string(val['server_int_lst'])
        temp_content.insert(0,str(val['id']))
        temp_content.insert(1,str(game_define.PLAT_FORM_NAME_DICT[val['platform_id']]))
        temp_content.insert(2,str_server_lst)
        temp_content.insert(3,str(val['time']))
        temp_content.insert(4,str(val['endtime']))
        temp_content.insert(5,str(val['name']))
        item_config = game_config.get_item_config(val['item_id1'])
        if item_config:
            temp_content.insert(6,str(item_config['name']))
        else:
            temp_content.insert(6,str(u''))
        temp_content.insert(7,str(val['item_num1']))

        item_config = game_config.get_item_config(val['item_id2'])
        if item_config:
            temp_content.insert(8,str(item_config['name']))
        else:
            temp_content.insert(8,str(u''))
        temp_content.insert(9,str(val['item_num2']))

        item_config = game_config.get_item_config(val['item_id3'])
        if item_config:
            temp_content.insert(10,str(item_config['name']))
        else:
            temp_content.insert(10,str(u''))
        temp_content.insert(11,str(val['item_num3']))

        temp_content.insert(12,str(val['gold']))
        temp_content.insert(13,str(val['stone']))
        table_list.append(temp_content)
    data['gift_package'] = table_list
    data['head_lst'] = head_lst
    return render_to_response("gift_package/gift_package_lst.html", data, RequestContext(request))
Ejemplo n.º 5
0
def system_mail_del_confirm(request):
    """
    删除邮件确认
    """
    if request.method == 'POST':
        version = str(request.POST.get("version"))
        del_notice_dict = dict()
        all_cmem_dict = server_define.CMEM_MAP
        for key, val in all_cmem_dict.items():
            cmem_url = str(val)
            if cmem_url:
                server_notice_box_model = memcache.get_cmem_val(
                    cmem_url, model_define.SYSTEM_MAIL_BOX_MODEL)
                if server_notice_box_model:
                    memcache.put_cmem_val(cmem_url,
                                          model_define.SYSTEM_MAIL_BOX_MODEL,
                                          server_notice_box_model)
                    print server_notice_box_model
                    check_system_expiry(server_notice_box_model)
                    notices_lst = server_notice_box_model['mails']
                    if notices_lst:
                        for notice_dict in notices_lst:
                            if notice_dict:
                                if version == str(notice_dict['version']):
                                    del_notice_dict = notice_dict
                                    break

        del_notice_dict['send_time'] = str(
            del_notice_dict['send_time'].strftime('%Y-%m-%d %H:%M:%S'))
        del_notice_dict['expiry_date'] = str(
            del_notice_dict['expiry_date'].strftime('%Y-%m-%d %H:%M:%S'))
        item_config = game_config.get_item_config(del_notice_dict['item'])
        if item_config:
            del_notice_dict['item'] = str(item_config['name'])
        else:
            del_notice_dict['item'] = str(u'')

        monster_config = game_config.get_monster_config(
            del_notice_dict['monster'])
        if monster_config:
            del_notice_dict['monster'] = str(monster_config['name'])
        else:
            del_notice_dict['monster'] = str(u'')

        return render_to_response("system_mail/system_mail_del_confirm.html", {
            'system_mail_info': del_notice_dict,
            'head_lst': head_lst
        }, RequestContext(request))
    else:
        return HttpResponseRedirect('/Tyranitar6/server/system_mail_lst/')
Ejemplo n.º 6
0
def system_mail_del_confirm(request):
    """
    删除邮件确认
    """
    if request.method == "POST":
        version = str(request.POST.get("version"))
        del_notice_dict = dict()
        all_cmem_dict = server_define.CMEM_MAP
        for key, val in all_cmem_dict.items():
            cmem_url = str(val)
            if cmem_url:
                server_notice_box_model = memcache.get_cmem_val(cmem_url, model_define.SYSTEM_MAIL_BOX_MODEL)
                if server_notice_box_model:
                    memcache.put_cmem_val(cmem_url, model_define.SYSTEM_MAIL_BOX_MODEL, server_notice_box_model)
                    print server_notice_box_model
                    check_system_expiry(server_notice_box_model)
                    notices_lst = server_notice_box_model["mails"]
                    if notices_lst:
                        for notice_dict in notices_lst:
                            if notice_dict:
                                if version == str(notice_dict["version"]):
                                    del_notice_dict = notice_dict
                                    break

        del_notice_dict["send_time"] = str(del_notice_dict["send_time"].strftime("%Y-%m-%d %H:%M:%S"))
        del_notice_dict["expiry_date"] = str(del_notice_dict["expiry_date"].strftime("%Y-%m-%d %H:%M:%S"))
        item_config = game_config.get_item_config(del_notice_dict["item"])
        if item_config:
            del_notice_dict["item"] = str(item_config["name"])
        else:
            del_notice_dict["item"] = str(u"")

        monster_config = game_config.get_monster_config(del_notice_dict["monster"])
        if monster_config:
            del_notice_dict["monster"] = str(monster_config["name"])
        else:
            del_notice_dict["monster"] = str(u"")

        return render_to_response(
            "system_mail/system_mail_del_confirm.html",
            {"system_mail_info": del_notice_dict, "head_lst": head_lst},
            RequestContext(request),
        )
    else:
        return HttpResponseRedirect("/Tyranitar6/server/system_mail_lst/")
Ejemplo n.º 7
0
def get_player_activity_holiday_shop_function(request, templates):
    """
        玩家运营数据编辑 假日商店
        source {'reward_end_date': datetime.date(2015, 8, 15),
                'num_dict': {2: 3, 3: 2, 5: 1, 7: 1},
                'version': u'20150716_22_09',
                'uid': '1000103005'}
        holiday_shop_config
                {"goldGet": 0, "stoneGet": 0, "stoneNeed": 50, "idItemGet": 86001, "numItemGet": 50,
                 "numItemNeed": 0, "idItemNeed": 0, "leftTimes": 1, "freeDrawGet": 0, "goldNeed": 0, "id": 12}}
    """
    # 以函数的指针方式传递函数并调用
    function_name = 'data_edit.player_activity_holiday_shop.{function}'.format(function=set_player_activity_holiday_shop_function.__name__)
    print 'function_name', function_name
    server_list, platform_list = daily_log._get_server_list(None, None)
    try:
        server_list.remove(server_list[0])
    except:
        pass

    return_uid = '请输入uid'
    return_openid = "请输入openid"
    return_name = "请输入玩家昵称"
    if request.method == 'POST':
        user_uid = request.POST.get('user_uid')
        user_name = request.POST.get('user_name').encode('utf-8')
        user_openid = request.POST.get('user_openid')
        server_id = int(request.POST.get('server_id'))
        type_hidden = 'visible'
        cmem_url = server_define.CMEM_MAP[int(server_id)]

        head_lst = [
            {'name': u'名称'},
            {'name': u'数量'},
        ]
        if cmem_url:
            try:
                source = dict()
                if len(user_uid):
                    source = memcache.get_cmem_val(cmem_url, model_define.PLAYER_ACTIVITY_HOLIDAY_SHOP_MODEL.format(user_id=user_uid))
                elif len(user_name):
                    name = hashlib.md5(user_name).hexdigest().upper()
                    key = model_define.PLAYER_NICK_NAME_MODEL.format(player_nick_md5=name)
                    user_uid = memcache.get_cmem_val_no_pick(cmem_url, key)
                    return_name = user_name
                    source = memcache.get_cmem_val(cmem_url, model_define.PLAYER_ACTIVITY_HOLIDAY_SHOP_MODEL.format(user_id=user_uid))
                elif len(user_openid):
                    result = memcache.get_cmem_val(cmem_url, model_define.ACCOUNT_MAPPING_MODEL.format(open_id=user_openid))
                    user_uid = result['uid']
                    return_openid = user_openid
                    source = memcache.get_cmem_val(cmem_url, model_define.PLAYER_ACTIVITY_HOLIDAY_SHOP_MODEL.format(user_id=user_uid))
                if source:
                    # print 'source', source
                    row_dict = collections.OrderedDict()  # 有序字典
                    # -----------------------------------不可改元素---------------------------------------------------------------#
                    # [[[0,1],[0,1]],[[0,1],[0,1]]] 三层[]
                    # ------------------------用户UID
                    uid = source.get('uid', 'None')
                    if uid != 'None':
                        uid_lst = [[u'用户UID', uid]]
                    else:
                        uid_lst = []
                    # ------------------运营活动奖励结束时间
                    try:
                        reward_end_date = source['reward_end_date'].strftime('%Y-%m-%d')   # 运营活动奖励结束时间
                        reward_end_date_lst = [[u'运营活动奖励结束时间', reward_end_date]]
                    except:
                        reward_end_date_lst = []
                    # ------------------运营活动当前版本
                    try:
                        version = source['version']   # 运营活动当前版本
                        version_lst = [[u'运营活动当前版本', version]]
                    except:
                        version_lst = []
                    # ---------------- 玩家已触发购买信息-------------------------------------
                    try:
                        completed_dic = source.get('num_dict', {})                # 已兑换信息表
                        reward_lst = []
                        for shop_even_id, get_item_num in completed_dic.items():  # 事件字典
                            reward_str = ''                                       # 字符串
                            if completed_dic:
                                cur_shop_even_id_config_dic = game_config.get_holiday_shop_config_with_id(int(shop_even_id))  # 策划填的配置表中的一条
                                for key, each_int_value in cur_shop_even_id_config_dic.items():             # 遍历每个key 与 值
                                    if each_int_value:                                                      # 有值
                                        if key in CUR_CON_STR_DIT:                                          # 且在配置字典
                                            if key in SPECIAL_CON_STR_LST.keys():                           # 特殊处理key
                                                if u'idItemGet' == key:  # 商城兑换物品要加“兑换”字符串
                                                    each_item_str = u'兑换——'
                                                    each_item_str += game_config.get_item_config(each_int_value)['name']    # 取物品名
                                                    each_item_str += u": "
                                                    each_item_val = cur_shop_even_id_config_dic[SPECIAL_CON_STR_LST[key]]  # 取数量
                                                else:
                                                    each_item_str = game_config.get_item_config(each_int_value)['name']    # 取物品名
                                                    each_item_str += u": "
                                                    each_item_val = cur_shop_even_id_config_dic[SPECIAL_CON_STR_LST[key]]  # 取数量
                                            else:
                                                each_item_str = CUR_CON_STR_DIT[key]                         # 取物品名
                                                each_item_val = each_int_value                               # 取数量
                                            reward_str += each_item_str                                      # 字符串拼接名字
                                            reward_str += str(each_item_val) + ";   "                        # 字符串拼接值
                                        else:
                                            continue
                                    else:
                                        continue
                                reward_str += u'已经兑换次数:' + str(get_item_num)
                                reward_str += '-----------'

                            reward_lst.append([u'玩家已触发商城事件ID_'+str(shop_even_id),reward_str])
                            # print reward_lst
                    except:
                        completed_dic = {}
                    # ---------------- 玩家已触发购买信息-------------------------------------

                    # ------------------- 汇总 有就加入总表(三层列表 [[[],[]],[[],[]]])
                    all_immutable_lst = []
                    if uid_lst:
                        all_immutable_lst.append(uid_lst)
                    if reward_end_date_lst:
                        all_immutable_lst.append(reward_end_date_lst)
                    if version_lst:
                        all_immutable_lst.append(version_lst)
                    if reward_lst:
                        all_immutable_lst.append(reward_lst)
                    # -------------------------------------------------------------------------------------------------------------------#

                    # -----------------------------------可改元素-------------------------------------------------------------------------#
                    # {key1:{'name':X,'num':X},key2:{'name':X,'num':X}}

                    # ---------------- 商城所有可购买次数修改-------------------------------------
                    player_completed_dic = source.get('num_dict', {})
                    # 便利商店购买次数
                    for each_eve_id, each_eve_dic in (game_config.get_all_holiday_shop_config()).items():
                        _each_item_str = ""
                        # 1.已触发的购买事件 修改
                        if int(each_eve_id) in player_completed_dic.keys():     # 玩家已触发商城购买ID事件
                            for _each_key, _each_value in each_eve_dic.items():
                                if _each_value:
                                    if u"idItemGet" == _each_key:  # 物品
                                        _each_item_str += game_config.get_item_config(_each_value)['name']    # 取物品名
                                    elif _each_key in SHOP_BUY_NOT_ITEM_LST:  # 非物品
                                        _each_item_str = SHOP_BUY_NOT_ITEM_LST[_each_key]

                            row_dict[int(each_eve_id)] = {'name': u'便利商店事件__%s__<%s>__<购买次数上限%s>' % (str(each_eve_id), _each_item_str, each_eve_dic.get('leftTimes',-1)), 'num': player_completed_dic[int(each_eve_id)]}
                        # 2.未触发的购买事件 修改
                        else:                                                   # 玩家未触发商城购买ID事件 要显示未触发的所有
                            for _each_key, _each_value in each_eve_dic.items():
                                if _each_value:  # 物品
                                    if u"idItemGet" == _each_key:  # 物品
                                        _each_item_str += game_config.get_item_config(_each_value)['name']    # 取物品名
                                    elif _each_key in SHOP_BUY_NOT_ITEM_LST:  # 非物品
                                        _each_item_str = SHOP_BUY_NOT_ITEM_LST[_each_key]
                            row_dict[int(each_eve_id)] = {'name': u'便利商店事件__%s__<%s>__<购买次数上限%s>' % (str(each_eve_id), _each_item_str, each_eve_dic.get('leftTimes',-1)), 'num': 0}

                    # -----------------------------------------------------------------------------------------------------------------------#
                else:
                    if user_uid:
                        return_uid = user_uid
                        if user_openid:
                            return_openid = user_openid
                        if user_name:
                            return_name = user_name

                return render_to_response(templates, locals(), RequestContext(request))

            except UnboundLocalError:
                type_hidden = 'hidden'
                return render_to_response(templates, locals(), RequestContext(request))

            except TypeError:
                type_hidden = 'hidden'
                return render_to_response(templates, locals(), RequestContext(request))

    else:
        row_list = []
        type_hidden = 'hidden'
        return render_to_response(templates, locals(), RequestContext(request))
Ejemplo n.º 8
0
def index(request, equip_info_edit):
    """
        ①
        玩家装备数据
        此函数功能:1.显示最新数据 2.修改装备 3.删除装备 4.添加装备
    """
    # 获取当前管理员
    # 1.公用代码部分 即每次修改 删除 添加 数据后 显示最新数据
    manager = GameManager.get_by_request(request)
    server_list, platform_list = daily_log._get_server_list(None, None)
    server_list.remove(server_list[0])
    if request.method == 'POST':

        user_uid = request.POST.get("user_uid")
        user_name = request.POST.get("user_name")
        user_openid = request.POST.get("user_openid")
        server_id = int(request.POST.get("server_id"))

        type_hidden = 'visible'
        cmem_url = server_define.CMEM_MAP[int(server_id)]
        if cmem_url:
            print 'cmem_url', cmem_url
            try:
                source = {}
                if len(user_uid):
                    source = memcache.get_cmem_val(
                        cmem_url,
                        model_define.EQUIP_MODEL.format(user_id=user_uid))
                    # print source
                elif len(user_name):
                    name = hashlib.md5(
                        user_name.encode('utf-8')).hexdigest().upper()
                    key = model_define.PLAYER_NICK_NAME_MODEL.format(
                        player_nick_md5=name)
                    user_uid = memcache.get_cmem_val_no_pick(cmem_url, key)
                    source = memcache.get_cmem_val(
                        cmem_url,
                        model_define.EQUIP_MODEL.format(user_id=user_uid))
                    # print source
                elif len(user_openid):
                    result = memcache.get_cmem_val(
                        cmem_url,
                        model_define.ACCOUNT_MAPPING_MODEL.format(
                            open_id=user_openid))
                    user_uid = result['uid']
                    source = memcache.get_cmem_val(
                        cmem_url,
                        model_define.EQUIP_MODEL.format(user_id=user_uid))
                    # print source
                if source:
                    """以上是公用部分,以下是修改 删除 添加"""
                    # 2.修改装备
                    try:
                        old_edit_data = eval(request.POST.get("old_edit_data"))
                        old_edit_data.pop('name')  # 得到编辑的源数据
                        will_edit_tid = request.POST.get(
                            "will_edit_tid")  # 要改成装备tid
                        will_edit_tid_level = request.POST.get(
                            "will_edit_tid_level")  # 要改的装备的等级
                        result = edit_function(cmem_url, source, old_edit_data,
                                               int(will_edit_tid),
                                               int(will_edit_tid_level))
                        if result:
                            # 操作日志记录
                            insert_action_change_equip(manager, str(server_id),
                                                       str(source['uid']),
                                                       old_edit_data['uid'],
                                                       old_edit_data['tid'],
                                                       will_edit_tid,
                                                       old_edit_data['level'],
                                                       will_edit_tid_level)
                    except:
                        # 不是编辑 或 数据不对 跳过
                        pass

                    # 3.删除装备 删除比较简单不单写函数
                    try:
                        delete_data = eval(request.POST.get('delete_data'))
                        delete_data.pop('name')
                        if delete_data:
                            # 操作日志记录
                            insert_action_delete_equip(manager, str(server_id),
                                                       str(user_uid),
                                                       delete_data['uid'],
                                                       delete_data['tid'],
                                                       delete_data['level'])

                            source['equips'].remove(delete_data)
                            result = memcache.put_cmem_val(
                                cmem_url,
                                model_define.EQUIP_MODEL.format(
                                    user_id=int(user_uid)), source)
                    except:
                        # 不是删除 或 数据不对 跳过
                        pass

                    # 4.添加装备 添加比较简单不单写函数
                    try:
                        add_data = eval(request.POST.get('add_data'))
                        if add_data:
                            will_edit_tid = request.POST.get("will_edit_tid")
                            will_edit_tid_level = request.POST.get(
                                "will_edit_tid_level")
                            if will_edit_tid and will_edit_tid_level:
                                equip_config = game_config.get_equipment_config(
                                    int(will_edit_tid))
                                source['equips'].append({
                                    'uid':
                                    int(add_data),
                                    'tid':
                                    int(will_edit_tid),
                                    'level':
                                    int(will_edit_tid_level),
                                    'type':
                                    int(equip_config['type'])
                                })
                                # 下个装备序列计数加1
                                source['seq_id'] = int(add_data) + 1
                                result = memcache.put_cmem_val(
                                    cmem_url,
                                    model_define.EQUIP_MODEL.format(
                                        user_id=int(user_uid)), source)
                                # 操作日志记录
                                insert_action_add_equip(
                                    manager, str(server_id), str(user_uid),
                                    add_data, will_edit_tid,
                                    will_edit_tid_level)
                                print "Finish"
                    except:
                        # 不是添加 或 数据不对 跳过
                        pass
                """以下是公用部分,以上是修改 删除 添加"""
                if source:
                    row_list = source['equips']
                    for each_value in row_list:
                        equip_config = game_config.get_item_config(
                            each_value['tid'])
                        each_value['name'] = equip_config['name']

                return render_to_response(equip_info_edit, locals(),
                                          RequestContext(request))
            except UnboundLocalError:
                type_hidden = 'hidden'
                return render_to_response(equip_info_edit, locals(),
                                          RequestContext(request))
            except TypeError:
                type_hidden = 'hidden'
                return render_to_response(equip_info_edit, locals(),
                                          RequestContext(request))

    else:
        row_list = []
        type_hidden = 'hidden'
        row_dict = {}
        return render_to_response(equip_info_edit, locals(),
                                  RequestContext(request))
Ejemplo n.º 9
0
def index(request, equip_info_edit):
    """
        ①
        玩家装备数据
        此函数功能:1.显示最新数据 2.修改装备 3.删除装备 4.添加装备
    """
    # 获取当前管理员
    # 1.公用代码部分 即每次修改 删除 添加 数据后 显示最新数据
    manager = GameManager.get_by_request(request)
    server_list, platform_list = daily_log._get_server_list(None, None)
    server_list.remove(server_list[0])
    if request.method == 'POST':

        user_uid = request.POST.get("user_uid")
        user_name = request.POST.get("user_name")
        user_openid = request.POST.get("user_openid")
        server_id = int(request.POST.get("server_id"))

        type_hidden = 'visible'
        cmem_url = server_define.CMEM_MAP[int(server_id)]
        if cmem_url:
            print 'cmem_url', cmem_url
            try:
                source = {}
                if len(user_uid):
                    source = memcache.get_cmem_val(cmem_url, model_define.EQUIP_MODEL.format(user_id=user_uid))
                    # print source
                elif len(user_name):
                    name = hashlib.md5(user_name.encode('utf-8')).hexdigest().upper()
                    key = model_define.PLAYER_NICK_NAME_MODEL.format(player_nick_md5=name)
                    user_uid = memcache.get_cmem_val_no_pick(cmem_url, key)
                    source = memcache.get_cmem_val(cmem_url, model_define.EQUIP_MODEL.format(user_id=user_uid))
                    # print source
                elif len(user_openid):
                    result = memcache.get_cmem_val(cmem_url,model_define.ACCOUNT_MAPPING_MODEL.format(open_id=user_openid))
                    user_uid = result['uid']
                    source = memcache.get_cmem_val(cmem_url, model_define.EQUIP_MODEL.format(user_id=user_uid))
                    # print source
                if source:
                    """以上是公用部分,以下是修改 删除 添加"""
                    # 2.修改装备
                    try:
                        old_edit_data = eval(request.POST.get("old_edit_data"))
                        old_edit_data.pop('name')                                       # 得到编辑的源数据
                        will_edit_tid = request.POST.get("will_edit_tid")               # 要改成装备tid
                        will_edit_tid_level = request.POST.get("will_edit_tid_level")   # 要改的装备的等级
                        result = edit_function(cmem_url, source, old_edit_data, int(will_edit_tid), int(will_edit_tid_level))
                        if result:
                            # 操作日志记录
                            insert_action_change_equip(manager, str(server_id), str(source['uid']), old_edit_data['uid'], old_edit_data['tid'], will_edit_tid, old_edit_data['level'], will_edit_tid_level)
                    except:
                        # 不是编辑 或 数据不对 跳过
                        pass

                    # 3.删除装备 删除比较简单不单写函数
                    try:
                        delete_data = eval(request.POST.get('delete_data'))
                        delete_data.pop('name')
                        if delete_data:
                            # 操作日志记录
                            insert_action_delete_equip(manager, str(server_id), str(user_uid), delete_data['uid'], delete_data['tid'], delete_data['level'])

                            source['equips'].remove(delete_data)
                            result = memcache.put_cmem_val(cmem_url, model_define.EQUIP_MODEL.format(user_id=int(user_uid)), source)
                    except:
                        # 不是删除 或 数据不对 跳过
                        pass

                    # 4.添加装备 添加比较简单不单写函数
                    try:
                        add_data = eval(request.POST.get('add_data'))
                        if add_data:
                            will_edit_tid = request.POST.get("will_edit_tid")
                            will_edit_tid_level = request.POST.get("will_edit_tid_level")
                            if will_edit_tid and will_edit_tid_level:
                                equip_config = game_config.get_equipment_config(int(will_edit_tid))
                                source['equips'].append({
                                    'uid': int(add_data),
                                    'tid': int(will_edit_tid),
                                    'level': int(will_edit_tid_level),
                                    'type': int(equip_config['type'])
                                    })
                                # 下个装备序列计数加1
                                source['seq_id'] = int(add_data) + 1
                                result = memcache.put_cmem_val(cmem_url,model_define.EQUIP_MODEL.format(user_id=int(user_uid)), source)
                                # 操作日志记录
                                insert_action_add_equip(manager, str(server_id), str(user_uid), add_data, will_edit_tid, will_edit_tid_level)
                                print "Finish"
                    except:
                        # 不是添加 或 数据不对 跳过
                        pass

                """以下是公用部分,以上是修改 删除 添加"""
                if source:
                    row_list = source['equips']
                    for each_value in row_list:
                        equip_config = game_config.get_item_config(each_value['tid'])
                        each_value['name'] = equip_config['name']

                return render_to_response(equip_info_edit, locals(), RequestContext(request))
            except UnboundLocalError:
                type_hidden = 'hidden'
                return render_to_response(equip_info_edit, locals(), RequestContext(request))
            except TypeError:
                type_hidden = 'hidden'
                return render_to_response(equip_info_edit, locals(), RequestContext(request))

    else:
        row_list = []
        type_hidden = 'hidden'
        row_dict = {}
        return render_to_response(equip_info_edit, locals(), RequestContext(request))
Ejemplo n.º 10
0
def get_player_treasure_function(request, player_treasure_edit):
    """
        玩家夺宝数据编辑
        source {
        'grab_msg_lst': [{'id': 100001, 'name': '\xe8\xbd\xbb\xe7\xa6\xbb', 'time': 1435990209.13243}, {'id': 100002, 'name': '400501g', 'time': 1436947184.663864}],
        'last_refresh_time': 1437884014.024381,
        'reset_treasure_date': datetime.date(2015, 7, 26),
        'uid': '1000000950',
        'open_synthesize_set': set([20001, 20004, 20005]),

        'treasure_point': 8,
        'reset_treasure_count': 0,
        'treasure_fragment_dict': {100001: 0, 100002: 1, 100003: 2, 100014: 2, 100015: 1, 83001: 1, 100026: 0, 83003: 1, 100028: 0, 100029: 0, 100030: 0, 100031: 0, 100032: 0, 100033: 0, 100034: 0, 100035: 0, 100036: 0, 100037: 2, 100038: 0, 100039: 2, 100040: 0, 100041: 0, 100042: 1, 100043: 0, 100044: 0, 100045: 0, 100046: 0, 100047: 0, 100048: 0, 100025: 0, 100027: 0}}
    """
    # 以函数的指针方式传递函数并调用
    function_name = 'data_edit.player_treasure.{function}'.format(function=set_player_treasure_function.__name__)
    print 'function_name', function_name
    server_list, platform_list = daily_log._get_server_list(None, None)
    try:
        server_list.remove(server_list[0])
    except:
        pass

    return_uid = '请输入uid'
    return_openid = "请输入openid"
    return_name = "请输入玩家昵称"
    if request.method == 'POST':
        user_uid = request.POST.get('user_uid')
        user_name = request.POST.get('user_name').encode('utf-8')
        user_openid = request.POST.get('user_openid')
        server_id = int(request.POST.get('server_id'))
        type_hidden = 'visible'
        cmem_url = server_define.CMEM_MAP[int(server_id)]

        head_lst = [
            {'name': u'名称'},
            {'name': u'数量'},
        ]
        if cmem_url:
            try:
                source = dict()

                if len(user_uid):
                    source = memcache.get_cmem_val(cmem_url, model_define.TREASURE_MODEL.format(user_id=user_uid))
                elif len(user_name):
                    name = hashlib.md5(user_name).hexdigest().upper()
                    key = model_define.PLAYER_NICK_NAME_MODEL.format(player_nick_md5=name)
                    user_uid = memcache.get_cmem_val_no_pick(cmem_url, key)
                    return_name = user_name
                    source = memcache.get_cmem_val(cmem_url, model_define.TREASURE_MODEL.format(user_id=user_uid))
                elif len(user_openid):
                    result = memcache.get_cmem_val(cmem_url, model_define.ACCOUNT_MAPPING_MODEL.format(open_id=user_openid))
                    user_uid = result['uid']
                    return_openid = user_openid
                    source = memcache.get_cmem_val(cmem_url, model_define.TREASURE_MODEL.format(user_id=user_uid))
                if source:
                    # print 'source', source
                    row_dict = collections.OrderedDict()  # 有序字典
                    treasure_lst = []
                    # -----------------------------------不可改元素---------------------------------------------------------------#
                    # [[[0,1],[0,1]],[[0,1],[0,1]]] 三层[]
                    # ------------------------用户UID
                    uid = source.get('uid', 'None')
                    if uid != 'None':
                        uid_lst = [[u'用户UID', uid]]
                    else:
                        uid_lst = []
                    # ----------------- 已合成宝石 注:没有数目
                    open_synthesize_set = source.get('open_synthesize_set', [])
                    for treasure_id in open_synthesize_set:
                        treasure_lst.append(game_config.get_item_config(treasure_id)['name'])
                    treasure_lst = [[u'已合成宝石', u' '.join(treasure_lst)]]
                    # ------------------重置夺宝时间
                    try:
                        reset_treasure_date = source['reset_treasure_date'].strftime('%Y-%m-%d')   # 重置夺宝时间
                        reset_treasure_date_lst = [[u'重置夺宝时间', reset_treasure_date]]
                    except:
                        reset_treasure_date_lst = []
                    # ------------------最后刷新时间
                    try:
                        last_refresh_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(source['last_refresh_time']))  # 最后刷新时间
                        last_refresh_time_lst = [[u'最后刷新时间', last_refresh_time]]
                    except:
                        last_refresh_time_lst = []

                    # ---------------- 被抢夺信息
                    try:
                        grab_msg_lst = source.get('grab_msg_lst', [])   # 被抢夺信息 [{'id':x,name:'','time':3}{}]
                        _tmp_grab_lst = []
                        num = 0
                        for each_msg_dict in grab_msg_lst:
                            num += 1
                            # 字符串拼接 例如:“在时间:2015-07-04 14:10:09 被玩家:轻离 掠夺物品:100001一个”
                            _tmp_grab_lst.append([u'被抢夺信息0'+str(num), '在时间:'+str(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(each_msg_dict['time'])))+' 被玩家:'+each_msg_dict['name']+' 掠夺物品:'+str(each_msg_dict['id']) + '一个'])
                        new_grab_msg_lst = [_tmp_grab_lst]
                    except:
                        new_grab_msg_lst = []
                    # ------------------- 汇总 有就加入总表(三层列表 [[[],[]],[[],[]]])
                    all_immutable_lst = []
                    if uid_lst:
                        all_immutable_lst.append(uid_lst)
                    if treasure_lst:
                        all_immutable_lst.append(treasure_lst)
                    if reset_treasure_date_lst:
                        all_immutable_lst.append(reset_treasure_date_lst)
                    if last_refresh_time_lst:
                        all_immutable_lst.append(last_refresh_time_lst)
                    if new_grab_msg_lst:
                        all_immutable_lst.extend(new_grab_msg_lst)

                    # -------------------------------------------------------------------------------------------------------------------#
                    # -----------------------------------可改元素-------------------------------------------------------------------------#
                    # {key1:{'name':X,'num':X},key2:{'name':X,'num':X}}
                    treasure_point = source.get('treasure_point', 0)  # 夺宝次数
                    reset_treasure_count = source.get('reset_treasure_count', 0)  # 夺宝刷新次数
                    # 宝石碎片id + num
                    treasure_fragment_dict = source.get('treasure_fragment_dict', {})  # 夺宝宝石碎片字典 暂时没有物品名字列表 TODO 加上宝石碎片物品列表
                    if treasure_fragment_dict:
                        for treasure_debris_id, _value in treasure_fragment_dict.items():
                            row_dict[treasure_debris_id] = {'name': '宝石碎片_' + str(treasure_debris_id), 'num': _value}
                    # 夺宝剩余次数
                    row_dict['treasure_point'] = {'name': u'夺宝剩余次数', 'num': treasure_point}
                    # 夺宝刷新次数
                    row_dict['reset_treasure_count'] = {'name': u'夺宝刷新次数', 'num': reset_treasure_count}
                    # -----------------------------------------------------------------------------------------------------------------------#
                else:
                    if user_uid:
                        return_uid = user_uid
                        if user_openid:
                            return_openid = user_openid
                        if user_name:
                            return_name = user_name

                return render_to_response(player_treasure_edit, locals(), RequestContext(request))

            except UnboundLocalError:
                type_hidden = 'hidden'
                return render_to_response(player_treasure_edit, locals(), RequestContext(request))

            except TypeError:
                type_hidden = 'hidden'
                return render_to_response(player_treasure_edit, locals(), RequestContext(request))

    else:
        row_list = []
        type_hidden = 'hidden'
        return render_to_response(player_treasure_edit, locals(), RequestContext(request))
def get_player_activity_weixin_share_function(request, templates):
    """
        玩家运营数据编辑 单笔充值

        source {'reward_end_date': datetime.date(2015, 8, 15),
                'complete': [2,3],          # 可完成   #微信分享没有用
                'version': u'20150716_14_09',
                'has_reward_lst': [2],      # 完成并交接
                'uid': '1000103005'}

        reward_share_weixin_config
                {"itemId": 0, "stone": 500, "star": 0, "power": 0,"gold": 0, "freeDrop": 0,
                 "itemNum": 0, "playerLevel": 50, "id": 5, "stage": 0}
    """

    # 以函数的指针方式传递函数并调用
    function_name = 'data_edit.player_activity_weixin_share.{function}'.format(function=set_player_activity_weixin_share_function.__name__)
    print 'function_name', function_name
    server_list, platform_list = daily_log._get_server_list(None, None)
    try:
        server_list.remove(server_list[0])
    except:
        pass

    return_uid = '请输入uid'
    return_openid = "请输入openid"
    return_name = "请输入玩家昵称"
    if request.method == 'POST':
        user_uid = request.POST.get('user_uid')
        user_name = request.POST.get('user_name').encode('utf-8')
        user_openid = request.POST.get('user_openid')
        server_id = int(request.POST.get('server_id'))
        type_hidden = 'visible'
        cmem_url = server_define.CMEM_MAP[int(server_id)]

        head_lst = [
            {'name': u'名称'},
            {'name': u'1代表已有——0代表没有'},
        ]
        if cmem_url:
            try:
                source = dict()
                if len(user_uid):
                    source = memcache.get_cmem_val(cmem_url, model_define.PLAYER_ACTIVITY_WEIXIN_SHARE_MODEL.format(user_id=user_uid))
                elif len(user_name):
                    name = hashlib.md5(user_name).hexdigest().upper()
                    key = model_define.PLAYER_NICK_NAME_MODEL.format(player_nick_md5=name)
                    user_uid = memcache.get_cmem_val_no_pick(cmem_url, key)
                    return_name = user_name
                    source = memcache.get_cmem_val(cmem_url, model_define.PLAYER_ACTIVITY_WEIXIN_SHARE_MODEL.format(user_id=user_uid))
                elif len(user_openid):
                    result = memcache.get_cmem_val(cmem_url, model_define.ACCOUNT_MAPPING_MODEL.format(open_id=user_openid))
                    user_uid = result['uid']
                    return_openid = user_openid
                    source = memcache.get_cmem_val(cmem_url, model_define.PLAYER_ACTIVITY_WEIXIN_SHARE_MODEL.format(user_id=user_uid))
                if source:
                    print 'source', source
                    row_dict = collections.OrderedDict()  # 有序字典
                    # -----------------------------------不可改元素---------------------------------------------------------------#
                    # [[[0,1],[0,1]],[[0,1],[0,1]]] 三层[]
                    # ------------------------用户UID
                    uid = source.get('uid', 'None')
                    if uid != 'None':
                        uid_lst = [[u'用户UID', uid]]
                    else:
                        uid_lst = []
                    # ------------------运营活动奖励结束时间
                    try:
                        reward_end_date = source['reward_end_date'].strftime('%Y-%m-%d')   # 运营活动奖励结束时间
                        reward_end_date_lst = [[u'运营活动奖励结束时间', reward_end_date]]
                    except:
                        reward_end_date_lst = []
                    # ------------------运营活动当前版本
                    try:
                        version = source['version']   # 运营活动当前版本
                        version_lst = [[u'运营活动当前版本', version]]
                    except:
                        version_lst = []

                    # ---------------- 玩家领取的奖励
                    try:
                        reward_lst = source.get('has_reward_lst', [])                   # [1,2,3,4,5]
                        reward_str = ''                                                                 # 字符串
                        cur_reward_config_lst = game_config.get_all_reward_share_weixin_config()  # 策划填的配置表
                        if reward_lst:
                            for reward_id in reward_lst:
                                each_conf_lst = cur_reward_config_lst[str(reward_id)]       # 取出每条配置表
                                for key, each_int_value in each_conf_lst.items():           # 遍历每个key 值
                                    if each_int_value:                                      # 有值
                                        if key in CUR_CON_STR_DIT:                          # 且在配置字典
                                            if key in SPECIAL_CON_STR_LST.keys():           # 是特殊处理key
                                                each_item_str = game_config.get_item_config(each_int_value)['name']  # 取物品名
                                                each_item_str += u": "
                                                each_item_val = each_conf_lst[SPECIAL_CON_STR_LST[key]]              # 取数量
                                            else:
                                                if u'stage' == key:
                                                    stage_dic = game_config.get_stages_config(each_int_value)
                                                    each_item_str = u'通过副本_' + stage_dic['stageInfo'] + u'_'
                                                    each_item_val = each_int_value
                                                else:
                                                    each_item_str = CUR_CON_STR_DIT[key]                         # 取物品名
                                                    each_item_val = each_int_value                               # 取数量
                                            reward_str += each_item_str                                      # 字符串拼接名字
                                            reward_str += str(each_item_val) + ";   "                        # 字符串拼接值
                                        else:
                                            continue
                                    else:
                                        continue
                                reward_str += '-----------'
                            reward_lst = [[u'玩家已奖励信息',reward_str]]
                            # print reward_lst
                    except:
                        reward_lst = []
                    # ---------------- 玩家已完成充值
                    try:
                        complete_reward_lst = source.get('complete', [])                   # [1,2,3,4,5]
                        reward_str = ''                                                                 # 字符串
                        cur_reward_config_lst = game_config.get_all_reward_share_weixin_config()  # 策划填的配置表
                        if complete_reward_lst:
                            for reward_id in complete_reward_lst:
                                each_conf_lst = cur_reward_config_lst[str(reward_id)]       # 取出每条配置表
                                for key, each_int_value in each_conf_lst.items():           # 遍历每个key 值
                                    if each_int_value:                                      # 有值
                                        if key in CUR_CON_STR_DIT:                          # 且在配置字典
                                            if key in SPECIAL_CON_STR_LST.keys():           # 是特殊处理key
                                                each_item_str = game_config.get_item_config(each_int_value)['name']  # 取物品名
                                                each_item_str += u": "
                                                each_item_val = each_conf_lst[SPECIAL_CON_STR_LST[key]]              # 取数量
                                            else:
                                                if u'stage' == key:
                                                    stage_dic = game_config.get_stages_config(each_int_value)
                                                    each_item_str = u'通过副本_' + stage_dic['stageInfo'] + u'_'
                                                    each_item_val = each_int_value
                                                else:
                                                    each_item_str = CUR_CON_STR_DIT[key]                         # 取物品名
                                                    each_item_val = each_int_value                               # 取数量                         # 取数量
                                            reward_str += each_item_str                                      # 字符串拼接名字
                                            reward_str += str(each_item_val) + ";   "                        # 字符串拼接值
                                        else:
                                            continue
                                    else:
                                        continue
                                reward_str += '-----------'
                            complete_reward_lst = [[u'玩家可领取奖励信息',reward_str]]
                            # print complete_reward_lst
                    except:
                        complete_reward_lst = []
                    # ------------------- 汇总 有就加入总表(三层列表 [[[],[]],[[],[]]])
                    all_immutable_lst = []
                    if uid_lst:
                        all_immutable_lst.append(uid_lst)
                    if reward_end_date_lst:
                        all_immutable_lst.append(reward_end_date_lst)
                    if version_lst:
                        all_immutable_lst.append(version_lst)
                    if reward_lst:
                        all_immutable_lst.append(reward_lst)
                    if complete_reward_lst:
                        all_immutable_lst.append(complete_reward_lst)
                    # -------------------------------------------------------------------------------------------------------------------#
                    # -----------------------------------可改元素-------------------------------------------------------------------------#
                    # {key1:{'name':X,'num':X},key2:{'name':X,'num':X}}
                    # complete has_reward_lst
                    # 单笔充值 可改元素 完成未交任务表 完成并交任务表
                    # _complete = source.get('complete', [])
                    _has_reward_lst = source.get('has_reward_lst', [])
                    cur_reward_config_lst = game_config.get_all_reward_share_weixin_config()        # 策划填的配置表
                    # key1 ==> "has_reward_lst$$1"
                    for i in xrange(1, len(cur_reward_config_lst)+1):
                        key_str = string.join(['has_reward_lst', str(i)], '$$')
                        key_str1 = string.join(['complete', str(i)], '$$')
                        # if i in _complete:
                        #     row_dict[key_str1] = {'name': u'可领奖励%s'%(str(i)), 'num': 1}
                        # else:
                        #     row_dict[key_str1] = {'name': u'可领奖励%s'%(str(i)), 'num': 0}
                        if i in _has_reward_lst:
                            row_dict[key_str] = {'name': u'已领奖励%s'%(str(i)), 'num': 1}
                        else:
                            row_dict[key_str] = {'name': u'已领奖励%s'%(str(i)), 'num': 0}
                    # -----------------------------------------------------------------------------------------------------------------------#
                else:
                    if user_uid:
                        return_uid = user_uid
                        if user_openid:
                            return_openid = user_openid
                        if user_name:
                            return_name = user_name

                return render_to_response(templates, locals(), RequestContext(request))

            except UnboundLocalError:
                type_hidden = 'hidden'
                return render_to_response(templates, locals(), RequestContext(request))

            except TypeError:
                type_hidden = 'hidden'
                return render_to_response(templates, locals(), RequestContext(request))

    else:
        row_list = []
        type_hidden = 'hidden'
        return render_to_response(templates, locals(), RequestContext(request))
Ejemplo n.º 12
0
def index(request, template):
    """  类型看格式
    {'data_version': '3',
    'uid': '1000105733',
    #循环取出物品中文名字在前台显示。
    'items': {
    81025: 2,
    80008: 21,
    80009: 31,
    80010: 4,
    80011: 2,
    80012: 1,
    80013: 1,
    80014: 0,
    80015: 0,
    81056: 13,
    80302: 198,
    80303: 1087,
    80048: 125,
    80306: 297,
    81086: 16,
    81098: 10,
    82006: 11,
    82007: 20,
    82008: 20,
    81113: 9,
    80101: 3,
    80102: 5,
    80103: 0,
    81010: 11
    }}
    """
    item_lst = collections.OrderedDict()
    item_dict_name, item_lst_type = game_config.get_item_config_with_id_name()
    add_item_function = 'data_edit.items_info.{function}'.format(function=add_item.__name__)
    function_name = 'data_edit.items_info.{function}'.format(function=set_memcache.__name__)
    del_item_function = 'data_edit.items_info.{function}'.format(function=del_item.__name__)
    server_list, platform_list = daily_log._get_server_list(None, None)
    server_list.remove(server_list[0])
    if request.method == 'POST':
        user_uid = request.POST.get('user_uid')
        user_name = request.POST.get('user_name').encode('utf-8')
        user_openid = request.POST.get('user_openid')
        server_id = int(request.POST.get('server_id'))
        cmem_url = server_define.CMEM_MAP[int(server_id)]

        if cmem_url:
            try:
                if len(user_uid):
                    source = memcache.get_cmem_val(cmem_url, model_define.ITEM_MODEL.format(user_id=user_uid))
                elif len(user_name):
                    name = hashlib.md5(user_name).hexdigest().upper()
                    key = model_define.PLAYER_NICK_NAME_MODEL.format(player_nick_md5=name)
                    user_uid = memcache.get_cmem_val_no_pick(cmem_url, key)
                    source = memcache.get_cmem_val(cmem_url, model_define.ITEM_MODEL.format(user_id=user_uid))
                elif len(user_openid):
                    result = memcache.get_cmem_val(cmem_url,
                                                   model_define.ACCOUNT_MAPPING_MODEL.format(open_id=user_openid))
                    source = memcache.get_cmem_val(cmem_url, model_define.ITEM_MODEL.format(user_id=result['uid']))
                    user_uid = user_id = result['uid']
                row_dict = collections.OrderedDict()

                for _key, _value in source['items'].items():
                    row_dict[_key] = {'name': game_config.get_item_config(_key)['name'],
                                      'num': _value}

                return render_to_response(template, locals(), RequestContext(request))

            except UnicodeEncodeError:
                return render_to_response(template, locals(), RequestContext(request))

            except TypeError:
                return render_to_response(template, locals(), RequestContext(request))
            except UnboundLocalError:
                return render_to_response(template, locals(), RequestContext(request))
    else:
        row_list = []

    return render_to_response(template, locals(), RequestContext(request))
Ejemplo n.º 13
0
def system_mail_lst(request):
    """
    广播列表
    """
    data = {}
    table_list = []
    all_background_notice_dict = dict()
    all_cmem_dict = server_define.CMEM_MAP
    for key, val in all_cmem_dict.items():
        cmem_url = str(val)
        if cmem_url:
            server_notice_box_model = memcache.get_cmem_val(
                cmem_url, model_define.SYSTEM_MAIL_BOX_MODEL)
            if server_notice_box_model:
                memcache.put_cmem_val(cmem_url,
                                      model_define.SYSTEM_MAIL_BOX_MODEL,
                                      server_notice_box_model)
                print server_notice_box_model
                check_system_expiry(server_notice_box_model)
                notices_lst = server_notice_box_model['mails']
                if notices_lst:
                    for mail_dict in notices_lst:
                        if mail_dict:
                            print mail_dict
                            mail_dict['version'] = mail_dict.get('version', 0)
                            if 'send_time' in mail_dict:
                                send_time = mail_dict['send_time']
                                mail_dict['send_time'] = send_time.strftime(
                                    "%Y-%m-%d %H:%M:%S")
                                if send_time <= datetime.datetime.now():
                                    mail_dict['send_time'] += " (已开始)"
                            else:
                                mail_dict['send_time'] = " 错误 "

                            if 'expiry_date' in mail_dict:
                                expiry_date = mail_dict['expiry_date']
                                mail_dict[
                                    'expiry_date'] = expiry_date.strftime(
                                        "%Y-%m-%d %H:%M:%S")
                                if expiry_date <= datetime.datetime.now():
                                    mail_dict['expiry_date'] += " (已开始)"
                            else:
                                mail_dict['expiry_date'] = " 错误 "
                            all_background_notice_dict[
                                mail_dict['version']] = mail_dict

    print("all_background_notice_dict: " + str(all_background_notice_dict))
    for key_uid, value in all_background_notice_dict.items():
        if value:
            temp_content = []
            temp_content.insert(0, str(key_uid))
            temp_content.insert(1, value.get('server_id', ''))
            temp_content.insert(2, value['target_user_uid'])
            temp_content.insert(3, str(value['title']))
            temp_content.insert(4, value['send_time'])
            temp_content.insert(5, value['expiry_date'])
            temp_content.insert(6, str(value['gold']))
            temp_content.insert(7, str(value['stone']))
            temp_content.insert(8, str(value['free_draw_material']))
            item_config = game_config.get_item_config(value['item'])
            if item_config:
                temp_content.insert(9, str(item_config['name']))
            else:
                temp_content.insert(9, str(u''))
            temp_content.insert(10, str(value['item_num']))

            monster_config = game_config.get_monster_config(value['monster'])
            if monster_config:
                temp_content.insert(11, str(monster_config['name']))
            else:
                temp_content.insert(11, str(u''))

            temp_content.insert(12, str(value['monster_star_level']))
            table_list.append(temp_content)

    data['system_mail_info'] = table_list
    data['head_lst'] = head_lst
    return render_to_response("system_mail/system_mail_lst.html", data,
                              RequestContext(request))
Ejemplo n.º 14
0
def index(request, template):
    """  玩家联盟商店
    author : 全勇男
    get_union_shop_items_config

    {'uid': '1000110564',
    'union_item_lst': [12, 15, 35, 53, 70, 76], # 商店商品列表
    'union_item_state_dict': {35: 0, 70: 0, 12: 0, 76: 0, 15: 0, 53: 0}, # 物品状态
    'reward_date': datetime.date(2015, 8, 1),
    'refresh_date': datetime.datetime(2015, 8, 1, 13, 3, 25, 588918), #最后刷新时间
    'refresh_num': 4} #刷新次数

    """
    server_list, platform_list = daily_log._get_server_list(None, None)
    server_list.remove(server_list[0])

    if request.method == 'POST':
        user_uid = request.POST.get('user_uid')
        user_name = request.POST.get('user_name').encode('utf-8')
        user_openid = request.POST.get('user_openid')
        server_id = int(request.POST.get('server_id'))
        cmem_url = server_define.CMEM_MAP[int(server_id)]
        row_lst = []
        try:
            if cmem_url:
                if len(user_uid):
                    source = memcache.get_cmem_val(cmem_url, model_define.UNION_SHOP_MODEL.format(user_id=user_uid))

                elif len(user_name):
                    name = hashlib.md5(user_name).hexdigest().upper()
                    key = model_define.PLAYER_NICK_NAME_MODEL.format(player_nick_md5=name)
                    user_uid = memcache.get_cmem_val_no_pick(cmem_url, key)
                    source = memcache.get_cmem_val(cmem_url, model_define.UNION_SHOP_MODEL.format(user_id=user_uid))
                elif len(user_openid):
                    result = memcache.get_cmem_val(cmem_url,
                                                   model_define.ACCOUNT_MAPPING_MODEL.format(open_id=user_openid))
                    source = memcache.get_cmem_val(cmem_url, model_define.UNION_SHOP_MODEL.format(user_id=result['uid']))
                for item_num in source['union_item_lst']:
                    item_name = game_config.get_item_config(game_config.get_union_shop_items_by_num(item_num))['name']

                    print item_name
                    row_lst.append( [
                        source['reward_date'],
                        item_name,
                        source['union_item_state_dict'][item_num]])
                    print row_lst
                last_refresh = source['refresh_date']
                refresh_count = source['refresh_num']
                return render_to_response(template, locals(), RequestContext(request))

        except UnicodeEncodeError:
            return render_to_response(template, locals(), RequestContext(request))

        except TypeError:
            return render_to_response(template, locals(), RequestContext(request))

        except UnboundLocalError:
            return render_to_response(template, locals(), RequestContext(request))

    else:
        row_dict = {}
        return render_to_response(template, locals(), RequestContext(request))
Ejemplo n.º 15
0
def get_player_activity_hard_stage_function(request,
                                            player_activity_hard_stage):
    """
        玩家困难运营数据编辑
        source {'reward_end_date': datetime.date(2015, 8, 14),
                'single_activity_has_reward_lst': [1, 2],
                'version': u'20150715_5_35',
                'uid': '1000000950'

                'num': 35,
                }
        config_dict   {"stone": 50, "pokeBall": 1, "num1": 0, "gold": 0, "num3": 0, "item2": 0, "item3": 0, "item1": 0,
                        "equipmentId": 0, "experience": 100, "times": 10, "num2": 0, "id": 1},
    """
    # 以函数的指针方式传递函数并调用
    function_name = 'data_edit.PlayerActivityHardStage.{function}'.format(
        function=set_player_activity_hard_stage_function.__name__)
    print 'function_name', function_name
    server_list, platform_list = daily_log._get_server_list(None, None)
    try:
        server_list.remove(server_list[0])
    except:
        pass

    return_uid = '请输入uid'
    return_openid = "请输入openid"
    return_name = "请输入玩家昵称"
    if request.method == 'POST':
        user_uid = request.POST.get('user_uid')
        user_name = request.POST.get('user_name').encode('utf-8')
        user_openid = request.POST.get('user_openid')
        server_id = int(request.POST.get('server_id'))
        type_hidden = 'visible'
        cmem_url = server_define.CMEM_MAP[int(server_id)]

        head_lst = [
            {
                'name': u'名称'
            },
            {
                'name': u'数量'
            },
        ]
        if cmem_url:
            try:
                source = dict()
                if len(user_uid):
                    source = memcache.get_cmem_val(
                        cmem_url,
                        model_define.PLAYER_ACTIVITY_HARD_STAGE_MODEL.format(
                            user_id=user_uid))
                elif len(user_name):
                    name = hashlib.md5(user_name).hexdigest().upper()
                    key = model_define.PLAYER_NICK_NAME_MODEL.format(
                        player_nick_md5=name)
                    user_uid = memcache.get_cmem_val_no_pick(cmem_url, key)
                    return_name = user_name
                    source = memcache.get_cmem_val(
                        cmem_url,
                        model_define.PLAYER_ACTIVITY_HARD_STAGE_MODEL.format(
                            user_id=user_uid))
                elif len(user_openid):
                    result = memcache.get_cmem_val(
                        cmem_url,
                        model_define.ACCOUNT_MAPPING_MODEL.format(
                            open_id=user_openid))
                    user_uid = result['uid']
                    return_openid = user_openid
                    source = memcache.get_cmem_val(
                        cmem_url,
                        model_define.PLAYER_ACTIVITY_HARD_STAGE_MODEL.format(
                            user_id=user_uid))
                if source:
                    # print 'source', source
                    row_dict = collections.OrderedDict()  # 有序字典
                    # -----------------------------------不可改元素---------------------------------------------------------------#
                    # [[[0,1],[0,1]],[[0,1],[0,1]]] 三层[]
                    # ------------------------用户UID
                    uid = source.get('uid', 'None')
                    if uid != 'None':
                        uid_lst = [[u'用户UID', uid]]
                    else:
                        uid_lst = []
                    # ------------------运营活动奖励结束时间
                    try:
                        reward_end_date = source['reward_end_date'].strftime(
                            '%Y-%m-%d')  # 运营活动奖励结束时间
                        reward_end_date_lst = [[
                            u'运营活动奖励结束时间', reward_end_date
                        ]]
                    except:
                        reward_end_date_lst = []
                    # ------------------运营活动当前版本
                    try:
                        version = source['version']  # 运营活动当前版本
                        version_lst = [[u'运营活动当前版本', version]]
                    except:
                        version_lst = []
                    # ---------------- 玩家奖励信息
                    try:
                        reward_lst = source.get(
                            'single_activity_has_reward_lst',
                            [])  # [1,2,3,4,5]
                        reward_str = ''  # 字符串
                        cur_reward_config_lst = game_config.get_all_reward_times_hard_stage_config(
                        )  # 策划填的配置表
                        if reward_lst:
                            for reward_id in reward_lst:
                                each_conf_lst = cur_reward_config_lst[str(
                                    reward_id)]  # 取出每条配置表
                                for key, each_int_value in each_conf_lst.items(
                                ):  # 遍历每个key 值
                                    if each_int_value:  # 有值
                                        if key in CUR_CON_STR_DIT:  # 且在配置字典
                                            if key in SPECIAL_CON_STR_LST.keys(
                                            ):  # 是特殊处理key
                                                each_item_str = game_config.get_item_config(
                                                    each_int_value)[
                                                        'name']  # 取物品名
                                                each_item_str += u": "
                                                each_item_val = each_conf_lst[
                                                    SPECIAL_CON_STR_LST[
                                                        key]]  # 取数量
                                            else:
                                                each_item_str = CUR_CON_STR_DIT[
                                                    key]  # 取物品名
                                                each_item_val = each_int_value  # 取数量
                                            reward_str += each_item_str  # 字符串拼接名字
                                            reward_str += str(
                                                each_item_val
                                            ) + ";   "  # 字符串拼接值
                                        else:
                                            continue
                                    else:
                                        continue
                                reward_str += '-----------'
                            reward_lst = [[u'玩家奖励信息', reward_str]]
                            # print reward_lst
                    except:
                        reward_lst = []
                    # ------------------- 汇总 有就加入总表(三层列表 [[[],[]],[[],[]]])
                    all_immutable_lst = []
                    if uid_lst:
                        all_immutable_lst.append(uid_lst)
                    if reward_end_date_lst:
                        all_immutable_lst.append(reward_end_date_lst)
                    if version_lst:
                        all_immutable_lst.append(version_lst)
                    if reward_lst:
                        all_immutable_lst.append(reward_lst)
                    # -------------------------------------------------------------------------------------------------------------------#
                    # -----------------------------------可改元素-------------------------------------------------------------------------#
                    # {key1:{'name':X,'num':X},key2:{'name':X,'num':X}}
                    # 困难副本战胜次数
                    hard_win_count = source.get('num', 'None')
                    if hard_win_count != 'None':
                        row_dict['hard_win_count'] = {
                            'name': u'困难副本战胜次数',
                            'num': hard_win_count
                        }
                    # -----------------------------------------------------------------------------------------------------------------------#
                else:
                    if user_uid:
                        return_uid = user_uid
                        if user_openid:
                            return_openid = user_openid
                        if user_name:
                            return_name = user_name

                return render_to_response(player_activity_hard_stage, locals(),
                                          RequestContext(request))

            except UnboundLocalError:
                type_hidden = 'hidden'
                return render_to_response(player_activity_hard_stage, locals(),
                                          RequestContext(request))

            except TypeError:
                type_hidden = 'hidden'
                return render_to_response(player_activity_hard_stage, locals(),
                                          RequestContext(request))

    else:
        row_list = []
        type_hidden = 'hidden'
        return render_to_response(player_activity_hard_stage, locals(),
                                  RequestContext(request))
Ejemplo n.º 16
0
def index(request, template):
    """  类型看格式
    {'data_version': '3',
    'uid': '1000105733',
    #循环取出物品中文名字在前台显示。
    'items': {
    81025: 2,
    80008: 21,
    80009: 31,
    80010: 4,
    80011: 2,
    80012: 1,
    80013: 1,
    80014: 0,
    80015: 0,
    81056: 13,
    80302: 198,
    80303: 1087,
    80048: 125,
    80306: 297,
    81086: 16,
    81098: 10,
    82006: 11,
    82007: 20,
    82008: 20,
    81113: 9,
    80101: 3,
    80102: 5,
    80103: 0,
    81010: 11
    }}
    """
    item_lst = collections.OrderedDict()
    item_dict_name, item_lst_type = game_config.get_item_config_with_id_name()
    add_item_function = 'data_edit.items_info.{function}'.format(
        function=add_item.__name__)
    function_name = 'data_edit.items_info.{function}'.format(
        function=set_memcache.__name__)
    del_item_function = 'data_edit.items_info.{function}'.format(
        function=del_item.__name__)
    server_list, platform_list = daily_log._get_server_list(None, None)
    server_list.remove(server_list[0])
    if request.method == 'POST':
        user_uid = request.POST.get('user_uid')
        user_name = request.POST.get('user_name').encode('utf-8')
        user_openid = request.POST.get('user_openid')
        server_id = int(request.POST.get('server_id'))
        cmem_url = server_define.CMEM_MAP[int(server_id)]

        if cmem_url:
            try:
                if len(user_uid):
                    source = memcache.get_cmem_val(
                        cmem_url,
                        model_define.ITEM_MODEL.format(user_id=user_uid))
                elif len(user_name):
                    name = hashlib.md5(user_name).hexdigest().upper()
                    key = model_define.PLAYER_NICK_NAME_MODEL.format(
                        player_nick_md5=name)
                    user_uid = memcache.get_cmem_val_no_pick(cmem_url, key)
                    source = memcache.get_cmem_val(
                        cmem_url,
                        model_define.ITEM_MODEL.format(user_id=user_uid))
                elif len(user_openid):
                    result = memcache.get_cmem_val(
                        cmem_url,
                        model_define.ACCOUNT_MAPPING_MODEL.format(
                            open_id=user_openid))
                    source = memcache.get_cmem_val(
                        cmem_url,
                        model_define.ITEM_MODEL.format(user_id=result['uid']))
                    user_uid = user_id = result['uid']
                row_dict = collections.OrderedDict()

                for _key, _value in source['items'].items():
                    row_dict[_key] = {
                        'name': game_config.get_item_config(_key)['name'],
                        'num': _value
                    }

                return render_to_response(template, locals(),
                                          RequestContext(request))

            except UnicodeEncodeError:
                return render_to_response(template, locals(),
                                          RequestContext(request))

            except TypeError:
                return render_to_response(template, locals(),
                                          RequestContext(request))
            except UnboundLocalError:
                return render_to_response(template, locals(),
                                          RequestContext(request))
    else:
        row_list = []

    return render_to_response(template, locals(), RequestContext(request))
Ejemplo n.º 17
0
def system_mail_lst(request):
    """
    广播列表
    """
    data = {}
    table_list = []
    all_background_notice_dict = dict()
    all_cmem_dict = server_define.CMEM_MAP
    for key, val in all_cmem_dict.items():
        cmem_url = str(val)
        if cmem_url:
            server_notice_box_model = memcache.get_cmem_val(cmem_url, model_define.SYSTEM_MAIL_BOX_MODEL)
            if server_notice_box_model:
                memcache.put_cmem_val(cmem_url, model_define.SYSTEM_MAIL_BOX_MODEL, server_notice_box_model)
                print server_notice_box_model
                check_system_expiry(server_notice_box_model)
                notices_lst = server_notice_box_model["mails"]
                if notices_lst:
                    for mail_dict in notices_lst:
                        if mail_dict:
                            print mail_dict
                            mail_dict["version"] = mail_dict.get("version", 0)
                            if "send_time" in mail_dict:
                                send_time = mail_dict["send_time"]
                                mail_dict["send_time"] = send_time.strftime("%Y-%m-%d %H:%M:%S")
                                if send_time <= datetime.datetime.now():
                                    mail_dict["send_time"] += " (已开始)"
                            else:
                                mail_dict["send_time"] = " 错误 "

                            if "expiry_date" in mail_dict:
                                expiry_date = mail_dict["expiry_date"]
                                mail_dict["expiry_date"] = expiry_date.strftime("%Y-%m-%d %H:%M:%S")
                                if expiry_date <= datetime.datetime.now():
                                    mail_dict["expiry_date"] += " (已开始)"
                            else:
                                mail_dict["expiry_date"] = " 错误 "
                            all_background_notice_dict[mail_dict["version"]] = mail_dict

    print ("all_background_notice_dict: " + str(all_background_notice_dict))
    for key_uid, value in all_background_notice_dict.items():
        if value:
            temp_content = []
            temp_content.insert(0, str(key_uid))
            temp_content.insert(1, value.get("server_id", ""))
            temp_content.insert(2, value["target_user_uid"])
            temp_content.insert(3, str(value["title"]))
            temp_content.insert(4, value["send_time"])
            temp_content.insert(5, value["expiry_date"])
            temp_content.insert(6, str(value["gold"]))
            temp_content.insert(7, str(value["stone"]))
            temp_content.insert(8, str(value["free_draw_material"]))
            item_config = game_config.get_item_config(value["item"])
            if item_config:
                temp_content.insert(9, str(item_config["name"]))
            else:
                temp_content.insert(9, str(u""))
            temp_content.insert(10, str(value["item_num"]))

            monster_config = game_config.get_monster_config(value["monster"])
            if monster_config:
                temp_content.insert(11, str(monster_config["name"]))
            else:
                temp_content.insert(11, str(u""))

            temp_content.insert(12, str(value["monster_star_level"]))
            table_list.append(temp_content)

    data["system_mail_info"] = table_list
    data["head_lst"] = head_lst
    return render_to_response("system_mail/system_mail_lst.html", data, RequestContext(request))
Ejemplo n.º 18
0
def get_player_activity_one_charge_function(request, templates):
    """
        玩家运营数据编辑 单笔充值

        source {'reward_end_date': datetime.date(2015, 8, 15),
                'one_charge_complete': [2], # 可完成
                'version': u'20150716_14_09',
                'has_reward_lst': [2],      # 完成并交接
                'uid': '1000103005'}

        reward_time_recharge_short_config
                {"monsterId": 0, "stone": 0, "pokeBall": 5, "num1": 1000,
                 "gold": 200000000, "num3": 0, "item2": 0, "money": 20000,
                  "item1": 80008, "equipmentId": 0, "experience": 0,
                   "item3": 0, "monsterStar": 0, "num2": 0, "id": 16}
    """

    # 以函数的指针方式传递函数并调用
    function_name = 'data_edit.player_activity_one_charge.{function}'.format(function=set_player_activity_one_charge_function.__name__)
    print 'function_name', function_name
    server_list, platform_list = daily_log._get_server_list(None, None)
    try:
        server_list.remove(server_list[0])
    except:
        pass

    return_uid = '请输入uid'
    return_openid = "请输入openid"
    return_name = "请输入玩家昵称"
    if request.method == 'POST':
        user_uid = request.POST.get('user_uid')
        user_name = request.POST.get('user_name').encode('utf-8')
        user_openid = request.POST.get('user_openid')
        server_id = int(request.POST.get('server_id'))
        type_hidden = 'visible'
        cmem_url = server_define.CMEM_MAP[int(server_id)]

        head_lst = [
            {'name': u'名称'},
            {'name': u'1代表已有——0代表没有'},
        ]
        if cmem_url:
            try:
                source = dict()
                if len(user_uid):
                    source = memcache.get_cmem_val(cmem_url, model_define.PLAYER_ACTIVITY_ONE_RECHARGE_MODEL.format(user_id=user_uid))
                elif len(user_name):
                    name = hashlib.md5(user_name).hexdigest().upper()
                    key = model_define.PLAYER_NICK_NAME_MODEL.format(player_nick_md5=name)
                    user_uid = memcache.get_cmem_val_no_pick(cmem_url, key)
                    return_name = user_name
                    source = memcache.get_cmem_val(cmem_url, model_define.PLAYER_ACTIVITY_ONE_RECHARGE_MODEL.format(user_id=user_uid))
                elif len(user_openid):
                    result = memcache.get_cmem_val(cmem_url, model_define.ACCOUNT_MAPPING_MODEL.format(open_id=user_openid))
                    user_uid = result['uid']
                    return_openid = user_openid
                    source = memcache.get_cmem_val(cmem_url, model_define.PLAYER_ACTIVITY_ONE_RECHARGE_MODEL.format(user_id=user_uid))
                if source:
                    print 'source', source
                    row_dict = collections.OrderedDict()  # 有序字典
                    # -----------------------------------不可改元素---------------------------------------------------------------#
                    # [[[0,1],[0,1]],[[0,1],[0,1]]] 三层[]
                    # ------------------------用户UID
                    uid = source.get('uid', 'None')
                    if uid != 'None':
                        uid_lst = [[u'用户UID', uid]]
                    else:
                        uid_lst = []
                    # ------------------运营活动奖励结束时间
                    try:
                        reward_end_date = source['reward_end_date'].strftime('%Y-%m-%d')   # 运营活动奖励结束时间
                        reward_end_date_lst = [[u'运营活动奖励结束时间', reward_end_date]]
                    except:
                        reward_end_date_lst = []
                    # ------------------运营活动当前版本
                    try:
                        version = source['version']   # 运营活动当前版本
                        version_lst = [[u'运营活动当前版本', version]]
                    except:
                        version_lst = []

                    # ---------------- 玩家领取的奖励
                    try:
                        reward_lst = source.get('has_reward_lst', [])                   # [1,2,3,4,5]
                        reward_str = ''                                                                 # 字符串
                        cur_reward_config_lst = game_config.get_all_reward_one_recharge_config()  # 策划填的配置表
                        if reward_lst:
                            for reward_id in reward_lst:
                                each_conf_lst = cur_reward_config_lst[str(reward_id)]       # 取出每条配置表
                                for key, each_int_value in each_conf_lst.items():           # 遍历每个key 值
                                    if each_int_value:                                      # 有值
                                        if key in CUR_CON_STR_DIT:                          # 且在配置字典
                                            if key in SPECIAL_CON_STR_LST.keys():           # 是特殊处理key
                                                each_item_str = game_config.get_item_config(each_int_value)['name']  # 取物品名
                                                each_item_str += u": "
                                                each_item_val = each_conf_lst[SPECIAL_CON_STR_LST[key]]              # 取数量
                                            else:
                                                each_item_str = CUR_CON_STR_DIT[key]                         # 取物品名
                                                each_item_val = each_int_value                               # 取数量
                                            reward_str += each_item_str                                      # 字符串拼接名字
                                            reward_str += str(each_item_val) + ";   "                        # 字符串拼接值
                                        else:
                                            continue
                                    else:
                                        continue
                                reward_str += '-----------'
                            reward_lst = [[u'玩家已奖励信息',reward_str]]
                            # print reward_lst
                    except:
                        reward_lst = []
                    # ---------------- 玩家已完成充值
                    try:
                        complete_reward_lst = source.get('one_charge_complete', [])                   # [1,2,3,4,5]
                        reward_str = ''                                                                 # 字符串
                        cur_reward_config_lst = game_config.get_all_reward_one_recharge_config()  # 策划填的配置表
                        if complete_reward_lst:
                            for reward_id in complete_reward_lst:
                                each_conf_lst = cur_reward_config_lst[str(reward_id)]       # 取出每条配置表
                                for key, each_int_value in each_conf_lst.items():           # 遍历每个key 值
                                    if each_int_value:                                      # 有值
                                        if key in CUR_CON_STR_DIT:                          # 且在配置字典
                                            if key in SPECIAL_CON_STR_LST.keys():           # 是特殊处理key
                                                each_item_str = game_config.get_item_config(each_int_value)['name']  # 取物品名
                                                each_item_str += u": "
                                                each_item_val = each_conf_lst[SPECIAL_CON_STR_LST[key]]              # 取数量
                                            else:
                                                each_item_str = CUR_CON_STR_DIT[key]                         # 取物品名
                                                each_item_val = each_int_value                               # 取数量
                                            reward_str += each_item_str                                      # 字符串拼接名字
                                            reward_str += str(each_item_val) + ";   "                        # 字符串拼接值
                                        else:
                                            continue
                                    else:
                                        continue
                                reward_str += '-----------'
                            complete_reward_lst = [[u'玩家可领取奖励信息',reward_str]]
                            # print complete_reward_lst
                    except:
                        complete_reward_lst = []
                    # ------------------- 汇总 有就加入总表(三层列表 [[[],[]],[[],[]]])
                    all_immutable_lst = []
                    if uid_lst:
                        all_immutable_lst.append(uid_lst)
                    if reward_end_date_lst:
                        all_immutable_lst.append(reward_end_date_lst)
                    if version_lst:
                        all_immutable_lst.append(version_lst)
                    if reward_lst:
                        all_immutable_lst.append(reward_lst)
                    if complete_reward_lst:
                        all_immutable_lst.append(complete_reward_lst)
                    # -------------------------------------------------------------------------------------------------------------------#
                    # -----------------------------------可改元素-------------------------------------------------------------------------#
                    # {key1:{'name':X,'num':X},key2:{'name':X,'num':X}}
                    # one_charge_complete has_reward_lst
                    # 单笔充值 可改元素 完成未交任务表 完成并交任务表
                    _one_charge_complete = source.get('one_charge_complete', [])
                    _has_reward_lst = source.get('has_reward_lst', [])
                    cur_reward_config_lst = game_config.get_all_reward_one_recharge_config()        # 策划填的配置表

                    # key1 ==> "has_reward_lst$$1"
                    for i in xrange(1, len(cur_reward_config_lst)+1):
                        key_str = string.join(['has_reward_lst', str(i)], '$$')
                        key_str1 = string.join(['one_charge_complete', str(i)], '$$')
                        if i in _one_charge_complete:
                            row_dict[key_str1] = {'name': u'可领奖励%s状态(单笔充值%s元)'%(str(i), cur_reward_config_lst[str(i)]['money']), 'num': 1}
                        else:
                            row_dict[key_str1] = {'name': u'可领奖励%s状态(单笔充值%s元)'%(str(i), cur_reward_config_lst[str(i)]['money']), 'num': 0}
                        if i in _has_reward_lst:
                            row_dict[key_str] = {'name': u'已领奖励%s状态(单笔充值%s元)'%(str(i), cur_reward_config_lst[str(i)]['money']), 'num': 1}
                        else:
                            row_dict[key_str] = {'name': u'已领奖励%s状态(单笔充值%s元)'%(str(i), cur_reward_config_lst[str(i)]['money']), 'num': 0}
                    # -----------------------------------------------------------------------------------------------------------------------#
                else:
                    if user_uid:
                        return_uid = user_uid
                        if user_openid:
                            return_openid = user_openid
                        if user_name:
                            return_name = user_name

                return render_to_response(templates, locals(), RequestContext(request))

            except UnboundLocalError:
                type_hidden = 'hidden'
                return render_to_response(templates, locals(), RequestContext(request))

            except TypeError:
                type_hidden = 'hidden'
                return render_to_response(templates, locals(), RequestContext(request))

    else:
        row_list = []
        type_hidden = 'hidden'
        return render_to_response(templates, locals(), RequestContext(request))
def get_player_activity_regist_recharge_function(request, templates):
    """
        玩家运营数据编辑 豪华充值(签到)
        source {'uid': '1000099479',
                'complete_id': 20,
                'recharge_date': None,
                'has_reward_lst': [3, 13, 16, 22, 12, 17],
                'reward_end_date': datetime.date(2015, 8, 3),
                'active_id': 21
                }
        regist_recharge_config
        {"itemId": 81373, "stone": 0, "gold": 0, "freeDrop": 0, "itemNum": 10, "id": 30}
    """
    # 以函数的指针方式传递函数并调用
    function_name = 'data_edit.player_activity_regist_recharge.{function}'.format(function=set_player_activity_regist_recharge_function.__name__)
    print 'function_name', function_name
    server_list, platform_list = daily_log._get_server_list(None, None)
    try:
        server_list.remove(server_list[0])
    except:
        pass

    return_uid = '请输入uid'
    return_openid = "请输入openid"
    return_name = "请输入玩家昵称"
    if request.method == 'POST':
        user_uid = request.POST.get('user_uid')
        user_name = request.POST.get('user_name').encode('utf-8')
        user_openid = request.POST.get('user_openid')
        server_id = int(request.POST.get('server_id'))
        type_hidden = 'visible'
        cmem_url = server_define.CMEM_MAP[int(server_id)]

        head_lst = [
            {'name': u'名称'},
            {'name': u'数量'},
        ]

        if cmem_url:
            try:
                source = dict()
                if len(user_uid):
                    source = memcache.get_cmem_val(cmem_url, model_define.PLAYER_ACTIVITY_REGIST_RECHARGE_MODEL.format(user_id=user_uid))
                elif len(user_name):
                    name = hashlib.md5(user_name).hexdigest().upper()
                    key = model_define.PLAYER_NICK_NAME_MODEL.format(player_nick_md5=name)
                    user_uid = memcache.get_cmem_val_no_pick(cmem_url, key)
                    return_name = user_name
                    source = memcache.get_cmem_val(cmem_url, model_define.PLAYER_ACTIVITY_REGIST_RECHARGE_MODEL.format(user_id=user_uid))
                elif len(user_openid):
                    result = memcache.get_cmem_val(cmem_url, model_define.ACCOUNT_MAPPING_MODEL.format(open_id=user_openid))
                    user_uid = result['uid']
                    return_openid = user_openid
                    source = memcache.get_cmem_val(cmem_url, model_define.PLAYER_ACTIVITY_REGIST_RECHARGE_MODEL.format(user_id=user_uid))
                if source:
                    print 'source', source
                    # -----------------------------------不可改元素---------------------------------------------------------------#
                    # [[[0,1],[0,1]],[[0,1],[0,1]]] 三层[]
                    # ------------------------用户UID
                    uid = source.get('uid', 'None')
                    if uid != 'None':
                        uid_lst = [[u'用户UID', uid]]
                    else:
                        uid_lst = []
                    # ------------------奖励可领取最后时间
                    try:
                        reward_end_date = source['reward_end_date'].strftime('%Y-%m-%d')   # 运营活动奖励结束时间
                        reward_end_date_lst = [[u'玩家最后奖励领取时间', reward_end_date]]
                    except:
                        reward_end_date_lst = []
                    # ------------------运营活动当前版本recharge_date
                    try:
                        recharge_date = source['recharge_date'].strftime('%Y-%m-%d')   # 运营活动奖励结束时间
                        recharge_date_lst = [[u'今天充值时间', reward_end_date]]
                    except:
                        reward_end_date_lst = []
                    # ---------------- 玩家奖励信息
                    try:
                        reward_lst = source.get('has_reward_lst', [])                   # [1,2,3,4,5]
                        reward_str = ''                                                                 # 字符串
                        cur_reward_config_lst = game_config.get_all_regist_recharge_config()  # 策划填的配置表
                        if reward_lst:
                            for reward_id in reward_lst:
                                each_conf_lst = cur_reward_config_lst[str(reward_id)]       # 取出每条配置表
                                for key, each_int_value in each_conf_lst.items():           # 遍历每个key 值
                                    if each_int_value:                                      # 有值
                                        if key in CUR_CON_STR_DIT:                          # 且在配置字典
                                            if key in SPECIAL_CON_STR_LST.keys():           # 是特殊处理key
                                                each_item_str = game_config.get_item_config(each_int_value)['name']  # 取物品名
                                                each_item_str += u": "
                                                each_item_val = each_conf_lst[SPECIAL_CON_STR_LST[key]]              # 取数量
                                            else:
                                                each_item_str = CUR_CON_STR_DIT[key]                         # 取物品名
                                                each_item_val = each_int_value                               # 取数量
                                            reward_str += each_item_str                                      # 字符串拼接名字
                                            reward_str += str(each_item_val) + ";   "                        # 字符串拼接值
                                        else:
                                            continue
                                    else:
                                        continue
                                reward_str += '-----------'
                            reward_lst = [[u'玩家奖励信息',reward_str]]
                            # print reward_lst
                    except:
                        reward_lst = []
                    # ------------------- 汇总 有就加入总表(三层列表 [[[],[]],[[],[]]])
                    all_immutable_lst = []
                    if uid_lst:
                        all_immutable_lst.append(uid_lst)
                    if reward_end_date_lst:
                        all_immutable_lst.append(reward_end_date_lst)
                    if recharge_date_lst:
                        all_immutable_lst.append(recharge_date_lst)
                    if reward_lst:
                        all_immutable_lst.append(reward_lst)
                    # -----------------------------------可改元素-------------------------------------------------------------------------#
                    # {key1:{'name':X,'num':X},key2:{'name':X,'num':X}}
                    row_dict = collections.OrderedDict()  # 有序字典
                    # has_reward_lst complete_id  active_id ==>> 奖励表 充值到哪天 可领奖到哪天
                    # 单笔充值 可改元素 完成未交任务表 完成并交任务表
                    _has_reward_lst = source.get('has_reward_lst', [])
                    _complete_id = source.get('complete_id', 0)
                    _active_id = source.get('active_id', 0)
                    cur_reward_config_lst = game_config.get_all_regist_recharge_config()        # 策划填的配置表

                    key_str = string.join(['complete_id', '-1'], '$$')
                    row_dict[key_str] = {'name': u'签到已完成充值到第几天','num': _complete_id}
                    key_str = string.join(['active_id', '-1'], '$$')
                    row_dict[key_str] = {'name': u'签到可领取奖励到第几天','num': _active_id}
                    # key1 ==> "has_reward_lst$$1"
                    for i in xrange(1, len(cur_reward_config_lst)+1):
                        key_str = string.join(['has_reward_lst', str(i)], '$$')
                        if i >= 10:
                            if i in _has_reward_lst:
                                row_dict[key_str] = {'name': u'签到第__%s__天奖励状态(1/0:已领/未领)'%(str(i)), 'num': 1}
                            else:
                                row_dict[key_str] = {'name': u'签到第__%s__天奖励状态(1/0:已领/未领)'%(str(i)), 'num': 0}
                        else:
                            if i in _has_reward_lst:
                                row_dict[key_str] = {'name': u'签到第__0%s__天奖励状态(1/0:已领/未领)'%(str(i)), 'num': 1}
                            else:
                                row_dict[key_str] = {'name': u'签到第__0%s__天奖励状态(1/0:已领/未领)'%(str(i)), 'num': 0}
                    # -----------------------------------------------------------------------------------------------------------------------#
                else:
                    if user_uid:
                        return_uid = user_uid
                        if user_openid:
                            return_openid = user_openid
                        if user_name:
                            return_name = user_name

                return render_to_response(templates, locals(), RequestContext(request))

            except UnboundLocalError:
                type_hidden = 'hidden'
                return render_to_response(templates, locals(), RequestContext(request))

            except TypeError:
                type_hidden = 'hidden'
                return render_to_response(templates, locals(), RequestContext(request))

    else:
        row_list = []
        type_hidden = 'hidden'
        return render_to_response(templates, locals(), RequestContext(request))
Ejemplo n.º 20
0
def index(request, template):
    """  玩家联盟商店
    author : 全勇男
    get_union_shop_items_config

    {'uid': '1000110564',
    'union_item_lst': [12, 15, 35, 53, 70, 76], # 商店商品列表
    'union_item_state_dict': {35: 0, 70: 0, 12: 0, 76: 0, 15: 0, 53: 0}, # 物品状态
    'reward_date': datetime.date(2015, 8, 1),
    'refresh_date': datetime.datetime(2015, 8, 1, 13, 3, 25, 588918), #最后刷新时间
    'refresh_num': 4} #刷新次数

    """
    server_list, platform_list = daily_log._get_server_list(None, None)
    server_list.remove(server_list[0])

    if request.method == 'POST':
        user_uid = request.POST.get('user_uid')
        user_name = request.POST.get('user_name').encode('utf-8')
        user_openid = request.POST.get('user_openid')
        server_id = int(request.POST.get('server_id'))
        cmem_url = server_define.CMEM_MAP[int(server_id)]
        row_lst = []
        try:
            if cmem_url:
                if len(user_uid):
                    source = memcache.get_cmem_val(
                        cmem_url,
                        model_define.UNION_SHOP_MODEL.format(user_id=user_uid))

                elif len(user_name):
                    name = hashlib.md5(user_name).hexdigest().upper()
                    key = model_define.PLAYER_NICK_NAME_MODEL.format(
                        player_nick_md5=name)
                    user_uid = memcache.get_cmem_val_no_pick(cmem_url, key)
                    source = memcache.get_cmem_val(
                        cmem_url,
                        model_define.UNION_SHOP_MODEL.format(user_id=user_uid))
                elif len(user_openid):
                    result = memcache.get_cmem_val(
                        cmem_url,
                        model_define.ACCOUNT_MAPPING_MODEL.format(
                            open_id=user_openid))
                    source = memcache.get_cmem_val(
                        cmem_url,
                        model_define.UNION_SHOP_MODEL.format(
                            user_id=result['uid']))
                for item_num in source['union_item_lst']:
                    item_name = game_config.get_item_config(
                        game_config.get_union_shop_items_by_num(
                            item_num))['name']

                    print item_name
                    row_lst.append([
                        source['reward_date'], item_name,
                        source['union_item_state_dict'][item_num]
                    ])
                    print row_lst
                last_refresh = source['refresh_date']
                refresh_count = source['refresh_num']
                return render_to_response(template, locals(),
                                          RequestContext(request))

        except UnicodeEncodeError:
            return render_to_response(template, locals(),
                                      RequestContext(request))

        except TypeError:
            return render_to_response(template, locals(),
                                      RequestContext(request))

        except UnboundLocalError:
            return render_to_response(template, locals(),
                                      RequestContext(request))

    else:
        row_dict = {}
        return render_to_response(template, locals(), RequestContext(request))
def get_player_activity_normal_stage_function(request, player_activity_normal_stage):
    """
        玩家普通运营数据编辑
        source {'reward_end_date': datetime.date(2015, 8, 14),
                'single_activity_has_reward_lst': [1, 2],
                'version': u'20150715_5_35',
                'uid': '1000000950'

                'num': 35,
                }
        config_dict   {"stone": 50, "pokeBall": 1, "num1": 0, "gold": 0, "num3": 0, "item2": 0, "item3": 0, "item1": 0,
                        "equipmentId": 0, "experience": 100, "times": 10, "num2": 0, "id": 1},
    """
    # 以函数的指针方式传递函数并调用
    function_name = 'data_edit.PlayerActivityNormalStage.{function}'.format(function=set_player_activity_normal_stage_function.__name__)
    print 'function_name', function_name
    server_list, platform_list = daily_log._get_server_list(None, None)
    try:
        server_list.remove(server_list[0])
    except:
        pass

    return_uid = '请输入uid'
    return_openid = "请输入openid"
    return_name = "请输入玩家昵称"
    if request.method == 'POST':
        user_uid = request.POST.get('user_uid')
        user_name = request.POST.get('user_name').encode('utf-8')
        user_openid = request.POST.get('user_openid')
        server_id = int(request.POST.get('server_id'))
        type_hidden = 'visible'
        cmem_url = server_define.CMEM_MAP[int(server_id)]

        head_lst = [
            {'name': u'名称'},
            {'name': u'数量'},
        ]
        if cmem_url:
            try:
                source = dict()
                if len(user_uid):
                    source = memcache.get_cmem_val(cmem_url, model_define.PLAYER_ACTIVITY_NORMAL_STAGE_MODEL.format(user_id=user_uid))
                elif len(user_name):
                    name = hashlib.md5(user_name).hexdigest().upper()
                    key = model_define.PLAYER_NICK_NAME_MODEL.format(player_nick_md5=name)
                    user_uid = memcache.get_cmem_val_no_pick(cmem_url, key)
                    return_name = user_name
                    source = memcache.get_cmem_val(cmem_url, model_define.PLAYER_ACTIVITY_NORMAL_STAGE_MODEL.format(user_id=user_uid))
                elif len(user_openid):
                    result = memcache.get_cmem_val(cmem_url, model_define.ACCOUNT_MAPPING_MODEL.format(open_id=user_openid))
                    user_uid = result['uid']
                    return_openid = user_openid
                    source = memcache.get_cmem_val(cmem_url, model_define.PLAYER_ACTIVITY_NORMAL_STAGE_MODEL.format(user_id=user_uid))
                if source:
                    # print 'source', source
                    row_dict = collections.OrderedDict()  # 有序字典
                    # -----------------------------------不可改元素---------------------------------------------------------------#
                    # [[[0,1],[0,1]],[[0,1],[0,1]]] 三层[]
                    # ------------------------用户UID
                    uid = source.get('uid', 'None')
                    if uid != 'None':
                        uid_lst = [[u'用户UID', uid]]
                    else:
                        uid_lst = []
                    # ------------------运营活动奖励结束时间
                    try:
                        reward_end_date = source['reward_end_date'].strftime('%Y-%m-%d')   # 运营活动奖励结束时间
                        reward_end_date_lst = [[u'运营活动奖励结束时间', reward_end_date]]
                    except:
                        reward_end_date_lst = []
                    # ------------------运营活动当前版本
                    try:
                        version = source['version']   # 运营活动当前版本
                        version_lst = [[u'运营活动当前版本', version]]
                    except:
                        version_lst = []
                    # ---------------- 玩家奖励信息
                    try:
                        reward_lst = source.get('single_activity_has_reward_lst', [])                   # [1,2,3,4,5]
                        reward_str = ''                                                                 # 字符串
                        cur_reward_config_lst = game_config.get_all_reward_times_normal_stage_config()  # 策划填的配置表
                        if reward_lst:
                            for reward_id in reward_lst:
                                each_conf_lst = cur_reward_config_lst[str(reward_id)]       # 取出每条配置表
                                for key, each_int_value in each_conf_lst.items():           # 遍历每个key 值
                                    if each_int_value:                                      # 有值
                                        if key in CUR_CON_STR_DIT:                          # 且在配置字典
                                            if key in SPECIAL_CON_STR_LST.keys():           # 是特殊处理key
                                                each_item_str = game_config.get_item_config(each_int_value)['name']  # 取物品名
                                                each_item_str += u": "
                                                each_item_val = each_conf_lst[SPECIAL_CON_STR_LST[key]]              # 取数量
                                            else:
                                                each_item_str = CUR_CON_STR_DIT[key]                         # 取物品名
                                                each_item_val = each_int_value                               # 取数量
                                            reward_str += each_item_str                                      # 字符串拼接名字
                                            reward_str += str(each_item_val) + ";   "                        # 字符串拼接值
                                        else:
                                            continue
                                    else:
                                        continue
                                reward_str += '-----------'
                            reward_lst = [[u'玩家奖励信息',reward_str]]
                            # print reward_lst
                    except:
                        reward_lst = []
                    # ------------------- 汇总 有就加入总表(三层列表 [[[],[]],[[],[]]])
                    all_immutable_lst = []
                    if uid_lst:
                        all_immutable_lst.append(uid_lst)
                    if reward_end_date_lst:
                        all_immutable_lst.append(reward_end_date_lst)
                    if version_lst:
                        all_immutable_lst.append(version_lst)
                    if reward_lst:
                        all_immutable_lst.append(reward_lst)
                    # -------------------------------------------------------------------------------------------------------------------#
                    # -----------------------------------可改元素-------------------------------------------------------------------------#
                    # {key1:{'name':X,'num':X},key2:{'name':X,'num':X}}
                    # 普通副本战胜次数
                    normal_win_count = source.get('num', 'None')
                    if normal_win_count != 'None':
                        row_dict['normal_win_count'] = {'name': u'普通副本战胜次数', 'num': normal_win_count}
                    # -----------------------------------------------------------------------------------------------------------------------#
                else:
                    if user_uid:
                        return_uid = user_uid
                        if user_openid:
                            return_openid = user_openid
                        if user_name:
                            return_name = user_name

                return render_to_response(player_activity_normal_stage, locals(), RequestContext(request))

            except UnboundLocalError:
                type_hidden = 'hidden'
                return render_to_response(player_activity_normal_stage, locals(), RequestContext(request))

            except TypeError:
                type_hidden = 'hidden'
                return render_to_response(player_activity_normal_stage, locals(), RequestContext(request))

    else:
        row_list = []
        type_hidden = 'hidden'
        return render_to_response(player_activity_normal_stage, locals(), RequestContext(request))
Ejemplo n.º 22
0
def get_table(search_start_date,
              search_end_date,
              register_start_date=None,
              register_end_date=None,
              server_id=-1):
    """
        获取展示表格
        register_start_date 注册开始时间
        register_end_date 注册结束时间
        search_start_date 查询开始时间
        search_end_date 查询结束时间
    """
    all_stone_shop_log_lst = dat_log_util.read_file(
        game_define.EVENT_ACTION_STONE_SHOP_BUY, search_start_date,
        search_end_date, server_id)
    # if channel_id >= 0:
    #     all_stone_shop_log_lst = daily_log_dat.filter_logs(all_stone_shop_log_lst, function=lambda x: x['platform_id'] == channel_id)
    # if server_id >= 0:
    #     all_stone_shop_log_lst = daily_log_dat.filter_logs(all_stone_shop_log_lst, function=lambda x: x['server_id'] == server_id)

    #获取符合条件的日志
    if register_start_date and register_end_date:
        all_stone_shop_log_lst = daily_log_dat.filter_logs(
            all_stone_shop_log_lst,
            function=lambda log: register_start_date <= log[
                'install'] <= register_end_date)
    # print all_stone_shop_log_lst
    # 全部钻石商城物品购买日志
    # print("all_stone_shop_log_lst: "+str(all_stone_shop_log_lst))
    # 获取所有钻石商城物品玩家设备
    # device_lst = daily_log_dat.get_set_with_key(all_stone_shop_log_lst, 'dev_id')

    # 获取所有钻石商城物品购买日志玩家UID
    all_uid_lst = daily_log_dat.get_set_with_key(all_stone_shop_log_lst, 'uid')

    # 消耗钻石总数
    total_cost_stone = daily_log_dat.get_sum_int_with_key(
        all_stone_shop_log_lst, 'cost_stone')

    # 根据ID拆分日志
    item_logs_dict = dict()
    for _log in all_stone_shop_log_lst:
        _item_info = _log['add_item_list']
        _item_tid = _item_info[0]

        if _item_tid in item_logs_dict:
            item_logs_dict[_item_tid].append(_log)
        else:
            lst = [_log]
            item_logs_dict[_item_tid] = lst

    table_lst = []
    for _item_tid, _log in item_logs_dict.items():

        user_num = daily_log_dat.get_set_num_with_key(_log, 'uid')
        # 购买物品
        item_config = game_config.get_item_config(int(_item_tid))

        event_log_act = item_config['name']
        # 钻石数
        cost_stone = daily_log_dat.get_sum_int_with_key(_log, 'cost_stone')
        # 次数
        cost_num = len(_log)
        # 参与率
        take_part_rate = _get_rate(user_num, len(all_uid_lst))
        # 钻石比率
        first_cost_stone_rate = _get_rate(cost_stone, total_cost_stone)
        # 人数比率
        # cur_user_num_rate = _get_rate(user_num, len(all_uid_lst))

        row = [
            event_log_act, cost_stone, user_num, cost_num,
            str(take_part_rate * 100) + "%",
            str(first_cost_stone_rate * 100) + "%"
        ]
        table_lst.append(row)

    return table_lst
def get_player_activity_time_limited_shift_shop_function(request, templates):
    """
        玩家运营数据编辑 友好商店
        source {'reward_end_date': datetime.date(2015, 8, 15),
                'num_dict': {2: 3, 3: 2, 5: 1, 7: 1},
                'version': u'20150716_22_09',
                'uid': '1000103005'}
        time_limited_shift_shop_config
             {"goldGet": 0, "stoneGet": 0, "stoneNeed": 100, "idItemGet": 80303,
              "numItemGet": 120, "freeDrawGet": 0, "numItemNeed2": 0, "leftTimes": 1,
              "idItemNeed1": 81143, "idItemNeed2": 0, "goldNeed": 0, "id": 12, "numItemNeed1": 5}
    """
    # 以函数的指针方式传递函数并调用
    function_name = 'data_edit.player_activity_time_limited_shift_shop.{function}'.format(function=set_player_activity_time_limited_shift_shop_function.__name__)
    print 'function_name', function_name
    server_list, platform_list = daily_log._get_server_list(None, None)
    try:
        server_list.remove(server_list[0])
    except:
        pass

    return_uid = '请输入uid'
    return_openid = "请输入openid"
    return_name = "请输入玩家昵称"
    if request.method == 'POST':
        user_uid = request.POST.get('user_uid')
        user_name = request.POST.get('user_name').encode('utf-8')
        user_openid = request.POST.get('user_openid')
        server_id = int(request.POST.get('server_id'))
        type_hidden = 'visible'
        cmem_url = server_define.CMEM_MAP[int(server_id)]

        head_lst = [
            {'name': u'名称'},
            {'name': u'数量'},
        ]
        if cmem_url:
            try:
                source = dict()
                if len(user_uid):
                    source = memcache.get_cmem_val(cmem_url, model_define.PLAYER_ACTIVITY_TIME_LIMITED_SHIFT_SHOP_MODEL.format(user_id=user_uid))
                elif len(user_name):
                    name = hashlib.md5(user_name).hexdigest().upper()
                    key = model_define.PLAYER_NICK_NAME_MODEL.format(player_nick_md5=name)
                    user_uid = memcache.get_cmem_val_no_pick(cmem_url, key)
                    return_name = user_name
                    source = memcache.get_cmem_val(cmem_url, model_define.PLAYER_ACTIVITY_TIME_LIMITED_SHIFT_SHOP_MODEL.format(user_id=user_uid))
                elif len(user_openid):
                    result = memcache.get_cmem_val(cmem_url, model_define.ACCOUNT_MAPPING_MODEL.format(open_id=user_openid))
                    user_uid = result['uid']
                    return_openid = user_openid
                    source = memcache.get_cmem_val(cmem_url, model_define.PLAYER_ACTIVITY_TIME_LIMITED_SHIFT_SHOP_MODEL.format(user_id=user_uid))
                if source:
                    # print 'source', source
                    row_dict = collections.OrderedDict()  # 有序字典
                    # -----------------------------------不可改元素---------------------------------------------------------------#
                    # [[[0,1],[0,1]],[[0,1],[0,1]]] 三层[]
                    # ------------------------用户UID
                    uid = source.get('uid', 'None')
                    if uid != 'None':
                        uid_lst = [[u'用户UID', uid]]
                    else:
                        uid_lst = []
                    # ------------------运营活动奖励结束时间
                    try:
                        reward_end_date = source['reward_end_date'].strftime('%Y-%m-%d')   # 运营活动奖励结束时间
                        reward_end_date_lst = [[u'运营活动奖励结束时间', reward_end_date]]
                    except:
                        reward_end_date_lst = []
                    # ------------------运营活动当前版本
                    try:
                        version = source['version']   # 运营活动当前版本
                        version_lst = [[u'运营活动当前版本', version]]
                    except:
                        version_lst = []
                    # ---------------- 玩家已触发购买信息-------------------------------------
                    try:
                        completed_dic = source.get('num_dict', {})                # 已兑换信息表
                        reward_lst = []
                        for shop_even_id, get_item_num in completed_dic.items():  # 事件字典
                            reward_str = ''                                       # 字符串
                            if completed_dic:
                                cur_shop_even_id_config_dic = game_config.get_time_limited_shift_shop_config_with_id(int(shop_even_id))  # 策划填的配置表中的一条
                                for key, each_int_value in cur_shop_even_id_config_dic.items():             # 遍历每个key 与 值
                                    if each_int_value:                                                      # 有值
                                        if key in CUR_CON_STR_DIT:                                          # 且在配置字典
                                            if key in SPECIAL_CON_STR_LST.keys():                           # 特殊处理key
                                                if u'idItemGet' == key:  # 商城兑换物品要加“兑换”字符串
                                                    each_item_str = u'兑换——'
                                                    each_item_str += game_config.get_item_config(each_int_value)['name']    # 取物品名
                                                    each_item_str += u": "
                                                    each_item_val = cur_shop_even_id_config_dic[SPECIAL_CON_STR_LST[key]]  # 取数量
                                                else:
                                                    each_item_str = game_config.get_item_config(each_int_value)['name']    # 取物品名
                                                    each_item_str += u": "
                                                    each_item_val = cur_shop_even_id_config_dic[SPECIAL_CON_STR_LST[key]]  # 取数量
                                            else:
                                                each_item_str = CUR_CON_STR_DIT[key]                         # 取物品名
                                                each_item_val = each_int_value                               # 取数量
                                            reward_str += each_item_str                                      # 字符串拼接名字
                                            reward_str += str(each_item_val) + ";   "                        # 字符串拼接值
                                        else:
                                            continue
                                    else:
                                        continue
                                reward_str += u'已经兑换次数:' + str(get_item_num)
                                reward_str += '-----------'

                            reward_lst.append([u'玩家已触发商城事件ID_'+str(shop_even_id),reward_str])
                            # print reward_lst
                    except:
                        completed_dic = {}
                    # ---------------- 玩家已触发购买信息-------------------------------------

                    # ------------------- 汇总 有就加入总表(三层列表 [[[],[]],[[],[]]])
                    all_immutable_lst = []
                    if uid_lst:
                        all_immutable_lst.append(uid_lst)
                    if reward_end_date_lst:
                        all_immutable_lst.append(reward_end_date_lst)
                    if version_lst:
                        all_immutable_lst.append(version_lst)
                    if reward_lst:
                        all_immutable_lst.append(reward_lst)
                    # -------------------------------------------------------------------------------------------------------------------#

                    # -----------------------------------可改元素-------------------------------------------------------------------------#
                    # {key1:{'name':X,'num':X},key2:{'name':X,'num':X}}

                    # ---------------- 商城所有可购买次数修改-------------------------------------
                    player_completed_dic = source.get('num_dict', {})
                    # 友好商店购买次数
                    for each_eve_id, each_eve_dic in (game_config.get_all_time_limited_shift_shop_config()).items():
                        _each_item_str = ""
                        # 1.已触发的购买事件 修改
                        if int(each_eve_id) in player_completed_dic.keys():     # 玩家已触发商城购买ID事件
                            for _each_key, _each_value in each_eve_dic.items():
                                if _each_value:
                                    if u"idItemGet" == _each_key:  # 物品
                                        _each_item_str += game_config.get_item_config(_each_value)['name']    # 取物品名
                                    elif _each_key in SHOP_BUY_NOT_ITEM_LST:  # 非物品
                                        _each_item_str = SHOP_BUY_NOT_ITEM_LST[_each_key]

                            row_dict[int(each_eve_id)] = {'name': u'友好商店事件__%s__<%s>__<购买次数上限%s>' % (str(each_eve_id), _each_item_str, each_eve_dic.get('leftTimes',-1)), 'num': player_completed_dic[int(each_eve_id)]}
                        # 2.未触发的购买事件 修改
                        else:                                                   # 玩家未触发商城购买ID事件 要显示未触发的所有
                            for _each_key, _each_value in each_eve_dic.items():
                                if _each_value:  # 物品
                                    if u"idItemGet" == _each_key:  # 物品
                                        _each_item_str += game_config.get_item_config(_each_value)['name']    # 取物品名
                                    elif _each_key in SHOP_BUY_NOT_ITEM_LST:  # 非物品
                                        _each_item_str = SHOP_BUY_NOT_ITEM_LST[_each_key]
                            row_dict[int(each_eve_id)] = {'name': u'友好商店事件__%s__<%s>__<购买次数上限%s>' % (str(each_eve_id), _each_item_str, each_eve_dic.get('leftTimes',-1)), 'num': 0}

                    # -----------------------------------------------------------------------------------------------------------------------#
                else:
                    if user_uid:
                        return_uid = user_uid
                        if user_openid:
                            return_openid = user_openid
                        if user_name:
                            return_name = user_name

                return render_to_response(templates, locals(), RequestContext(request))

            except UnboundLocalError:
                type_hidden = 'hidden'
                return render_to_response(templates, locals(), RequestContext(request))

            except TypeError:
                type_hidden = 'hidden'
                return render_to_response(templates, locals(), RequestContext(request))

    else:
        row_list = []
        type_hidden = 'hidden'
        return render_to_response(templates, locals(), RequestContext(request))
def get_player_activity_regist_recharge_function(request, templates):
    """
        玩家运营数据编辑 豪华充值(签到)
        source {'uid': '1000099479',
                'complete_id': 20,
                'recharge_date': None,
                'has_reward_lst': [3, 13, 16, 22, 12, 17],
                'reward_end_date': datetime.date(2015, 8, 3),
                'active_id': 21
                }
        regist_recharge_config
        {"itemId": 81373, "stone": 0, "gold": 0, "freeDrop": 0, "itemNum": 10, "id": 30}
    """
    # 以函数的指针方式传递函数并调用
    function_name = 'data_edit.player_activity_regist_recharge.{function}'.format(
        function=set_player_activity_regist_recharge_function.__name__)
    print 'function_name', function_name
    server_list, platform_list = daily_log._get_server_list(None, None)
    try:
        server_list.remove(server_list[0])
    except:
        pass

    return_uid = '请输入uid'
    return_openid = "请输入openid"
    return_name = "请输入玩家昵称"
    if request.method == 'POST':
        user_uid = request.POST.get('user_uid')
        user_name = request.POST.get('user_name').encode('utf-8')
        user_openid = request.POST.get('user_openid')
        server_id = int(request.POST.get('server_id'))
        type_hidden = 'visible'
        cmem_url = server_define.CMEM_MAP[int(server_id)]

        head_lst = [
            {
                'name': u'名称'
            },
            {
                'name': u'数量'
            },
        ]

        if cmem_url:
            try:
                source = dict()
                if len(user_uid):
                    source = memcache.get_cmem_val(
                        cmem_url,
                        model_define.PLAYER_ACTIVITY_REGIST_RECHARGE_MODEL.
                        format(user_id=user_uid))
                elif len(user_name):
                    name = hashlib.md5(user_name).hexdigest().upper()
                    key = model_define.PLAYER_NICK_NAME_MODEL.format(
                        player_nick_md5=name)
                    user_uid = memcache.get_cmem_val_no_pick(cmem_url, key)
                    return_name = user_name
                    source = memcache.get_cmem_val(
                        cmem_url,
                        model_define.PLAYER_ACTIVITY_REGIST_RECHARGE_MODEL.
                        format(user_id=user_uid))
                elif len(user_openid):
                    result = memcache.get_cmem_val(
                        cmem_url,
                        model_define.ACCOUNT_MAPPING_MODEL.format(
                            open_id=user_openid))
                    user_uid = result['uid']
                    return_openid = user_openid
                    source = memcache.get_cmem_val(
                        cmem_url,
                        model_define.PLAYER_ACTIVITY_REGIST_RECHARGE_MODEL.
                        format(user_id=user_uid))
                if source:
                    print 'source', source
                    # -----------------------------------不可改元素---------------------------------------------------------------#
                    # [[[0,1],[0,1]],[[0,1],[0,1]]] 三层[]
                    # ------------------------用户UID
                    uid = source.get('uid', 'None')
                    if uid != 'None':
                        uid_lst = [[u'用户UID', uid]]
                    else:
                        uid_lst = []
                    # ------------------奖励可领取最后时间
                    try:
                        reward_end_date = source['reward_end_date'].strftime(
                            '%Y-%m-%d')  # 运营活动奖励结束时间
                        reward_end_date_lst = [[
                            u'玩家最后奖励领取时间', reward_end_date
                        ]]
                    except:
                        reward_end_date_lst = []
                    # ------------------运营活动当前版本recharge_date
                    try:
                        recharge_date = source['recharge_date'].strftime(
                            '%Y-%m-%d')  # 运营活动奖励结束时间
                        recharge_date_lst = [[u'今天充值时间', reward_end_date]]
                    except:
                        reward_end_date_lst = []
                    # ---------------- 玩家奖励信息
                    try:
                        reward_lst = source.get('has_reward_lst',
                                                [])  # [1,2,3,4,5]
                        reward_str = ''  # 字符串
                        cur_reward_config_lst = game_config.get_all_regist_recharge_config(
                        )  # 策划填的配置表
                        if reward_lst:
                            for reward_id in reward_lst:
                                each_conf_lst = cur_reward_config_lst[str(
                                    reward_id)]  # 取出每条配置表
                                for key, each_int_value in each_conf_lst.items(
                                ):  # 遍历每个key 值
                                    if each_int_value:  # 有值
                                        if key in CUR_CON_STR_DIT:  # 且在配置字典
                                            if key in SPECIAL_CON_STR_LST.keys(
                                            ):  # 是特殊处理key
                                                each_item_str = game_config.get_item_config(
                                                    each_int_value)[
                                                        'name']  # 取物品名
                                                each_item_str += u": "
                                                each_item_val = each_conf_lst[
                                                    SPECIAL_CON_STR_LST[
                                                        key]]  # 取数量
                                            else:
                                                each_item_str = CUR_CON_STR_DIT[
                                                    key]  # 取物品名
                                                each_item_val = each_int_value  # 取数量
                                            reward_str += each_item_str  # 字符串拼接名字
                                            reward_str += str(
                                                each_item_val
                                            ) + ";   "  # 字符串拼接值
                                        else:
                                            continue
                                    else:
                                        continue
                                reward_str += '-----------'
                            reward_lst = [[u'玩家奖励信息', reward_str]]
                            # print reward_lst
                    except:
                        reward_lst = []
                    # ------------------- 汇总 有就加入总表(三层列表 [[[],[]],[[],[]]])
                    all_immutable_lst = []
                    if uid_lst:
                        all_immutable_lst.append(uid_lst)
                    if reward_end_date_lst:
                        all_immutable_lst.append(reward_end_date_lst)
                    if recharge_date_lst:
                        all_immutable_lst.append(recharge_date_lst)
                    if reward_lst:
                        all_immutable_lst.append(reward_lst)
                    # -----------------------------------可改元素-------------------------------------------------------------------------#
                    # {key1:{'name':X,'num':X},key2:{'name':X,'num':X}}
                    row_dict = collections.OrderedDict()  # 有序字典
                    # has_reward_lst complete_id  active_id ==>> 奖励表 充值到哪天 可领奖到哪天
                    # 单笔充值 可改元素 完成未交任务表 完成并交任务表
                    _has_reward_lst = source.get('has_reward_lst', [])
                    _complete_id = source.get('complete_id', 0)
                    _active_id = source.get('active_id', 0)
                    cur_reward_config_lst = game_config.get_all_regist_recharge_config(
                    )  # 策划填的配置表

                    key_str = string.join(['complete_id', '-1'], '$$')
                    row_dict[key_str] = {
                        'name': u'签到已完成充值到第几天',
                        'num': _complete_id
                    }
                    key_str = string.join(['active_id', '-1'], '$$')
                    row_dict[key_str] = {
                        'name': u'签到可领取奖励到第几天',
                        'num': _active_id
                    }
                    # key1 ==> "has_reward_lst$$1"
                    for i in xrange(1, len(cur_reward_config_lst) + 1):
                        key_str = string.join(['has_reward_lst', str(i)], '$$')
                        if i >= 10:
                            if i in _has_reward_lst:
                                row_dict[key_str] = {
                                    'name':
                                    u'签到第__%s__天奖励状态(1/0:已领/未领)' % (str(i)),
                                    'num': 1
                                }
                            else:
                                row_dict[key_str] = {
                                    'name':
                                    u'签到第__%s__天奖励状态(1/0:已领/未领)' % (str(i)),
                                    'num': 0
                                }
                        else:
                            if i in _has_reward_lst:
                                row_dict[key_str] = {
                                    'name':
                                    u'签到第__0%s__天奖励状态(1/0:已领/未领)' % (str(i)),
                                    'num':
                                    1
                                }
                            else:
                                row_dict[key_str] = {
                                    'name':
                                    u'签到第__0%s__天奖励状态(1/0:已领/未领)' % (str(i)),
                                    'num':
                                    0
                                }
                    # -----------------------------------------------------------------------------------------------------------------------#
                else:
                    if user_uid:
                        return_uid = user_uid
                        if user_openid:
                            return_openid = user_openid
                        if user_name:
                            return_name = user_name

                return render_to_response(templates, locals(),
                                          RequestContext(request))

            except UnboundLocalError:
                type_hidden = 'hidden'
                return render_to_response(templates, locals(),
                                          RequestContext(request))

            except TypeError:
                type_hidden = 'hidden'
                return render_to_response(templates, locals(),
                                          RequestContext(request))

    else:
        row_list = []
        type_hidden = 'hidden'
        return render_to_response(templates, locals(), RequestContext(request))