def getGameNoticeDel(redis,session,action="hall"): """ 删除活动消息 """ lang = getLang() action = action.upper() active_id = request.GET.get('active_id','').strip() if not active_id: return {'code':1,'msg':'active_id[%s]不存在'%(active_id)} active_table = FORMAT_GAMEHALL_ACTIVE_TABEL%(active_id) senderId = redis.hget(active_table,'groupId') if not senderId: senderId = 1 if action == 'HALL': active_list_table = FORMAT_GAMEHALL_ACTIVE_LIST_TABLE memberIdList = getAgentAllMemberIds(redis,senderId) user_msg_table_list = FORMAT_USER_MESSAGE_LIST else: active_list_table = FORMAT_FISHHALL_ACTIVE_LIST_TABLE userIdKey = [] memberIds = redis.smembers(ACCOUNT4WEIXIN_SET4FISH) for memberId in memberIds: table = FORMAT_ACCOUNT2USER_TABLE%(memberId) #从账号获得账号信息,和旧系统一样 userIdKey.append(table) memberIdList = [userId.split(":")[1] for userId in redis.mget(userIdKey)] user_msg_table_list = FORMAT_USER_ACTIVE_FISH_LIST imgPath1,imgPath2,imgPath3 = redis.hmget(active_table,('imgPath1','imgPath2','imgPath3')) if not redis.exists(active_table): return {'code':1,'msg':'noticeIds not exists.'} info = { 'title' : lang.GAME_NOTIFY_DEL_TXT, } pipe = redis.pipeline() try: pipe.lrem(active_list_table,active_id) pipe.delete(active_table) for memberId in memberIdList: pipe.lrem(user_msg_table_list%(memberId),active_id) pipe.delete(FORMAT_ACT_READ_SET%(active_id)) except: return {'code':1,'msg':lang.GAME_NOTIFY_DEL_ERR_TXT} delete_img_path(imgPath1) delete_img_path(imgPath2) delete_img_path(imgPath3) pipe.execute() return {'code':0,'msg':lang.GAME_ACTIVE_DEL_SUCCESS_TXT,'jumpUrl':BACK_PRE+'/notic/active/list/{}'.format(action)}
def pushNotices(redis,session,action='hall'): """ 将消息放进玩家的信息列表 """ type2Msg = {'0':'推送','1':'取消推送'} action = action.upper() timeStr = convert_util.to_dateStr(datetime.now()) agentId = session['id'] active_id = request.GET.get('active_id','').strip() pipe = redis.pipeline() #超级管理员发的公告需要塞到所有玩家的信息盒子 active_table = FORMAT_GAMEHALL_ACTIVE_TABEL%(active_id) senderId = redis.hget(active_table,'groupId') if not senderId: senderId = 1 if action == 'HALL': memberIdList = getAgentAllMemberIds(redis,senderId) user_msg_table_list = FORMAT_USER_ACTIVE_LIST else: userIdKey = [] memberIds = redis.smembers(ACCOUNT4WEIXIN_SET4FISH) for memberId in memberIds: table = FORMAT_ACCOUNT2USER_TABLE%(memberId) #从账号获得账号信息,和旧系统一样 userIdKey.append(table) memberIdList = [userId.split(":")[1] for userId in redis.mget(userIdKey)] user_msg_table_list = FORMAT_USER_ACTIVE_FISH_LIST #推送所有公告 status = convert_util.to_int(redis.hget(active_table,'status')) log_util.debug('[try pushNotices] agentId[%s] memberIds[%s] status[%s] action[%s]'%(agentId,memberIdList,status,action)) try: if status == 0: for memberId in memberIdList: pipe.hset(FORMAT_GAMEHALL_ACTIVE_TABEL%(active_id),'time',timeStr) pipe.lpush(user_msg_table_list%(memberId),active_id) pipe.hset(active_table,'status',1) else: for memberId in memberIdList: pipe.lrem(user_msg_table_list%(memberId),active_id) pipe.srem(FORMAT_ACT_READ_SET%(active_id),memberId) pipe.hset(active_table,'status',0) except Exception,e: log_util.debug('[try pushNotices] ERROR agentId[%s] reason[%s]'%(agentId,e)) return {'code':1,'msg':type2Msg[str(status)]+'失败.'}
def push2userMsgTable(redis,agentId,noticId): """ 将消息放进玩家的信息列表 """ pipe = redis.pipeline() #超级管理员发的公告需要塞到所有玩家的信息盒子 memberIds = getAgentAllMemberIds(redis,agentId) noticeTable = FORMAT_GAMEHALL_NOTIC_TABLE%(noticId) pipe.hset(noticeTable,'status','1') log_debug('[FUNC][push2userMsgTable][info] agentId[%s] memberIds[%s]'%(agentId,memberIds)) try: for memberId in memberIds: log_debug('[FUNC][push2userMsgTable][info] agentId[%s] send to memberId[%s] noticId[%s] success'\ %(agentId,memberId,noticId)) pipe.lpush(FORMAT_USER_MESSAGE_LIST%(memberId),noticId) #pipe.set(FORMAT_USER_MESSAGE_LIST%(memberId,noticId),noticId) except Exception,e: log_debug('[FUNC][push2userMsgTable][Error] agentId[%s] reason[%s]'%(agentId,e)) return
def pushNotices(redis,session,action='hall'): """ 将消息放进玩家的信息列表 """ type2Msg = {'0':'推送','1':'取消推送'} action = action.upper() timeStr = convert_util.to_dateStr(datetime.now()) agentId = session['id'] noticId = request.GET.get('id','').strip() pipe = redis.pipeline() #超级管理员发的公告需要塞到所有玩家的信息盒子 noticeTable = FORMAT_GAMEHALL_NOTIC_TABLE%(noticId) senderId = redis.hget(noticeTable,'groupId') if not senderId: senderId = 1 memberIds = getAgentAllMemberIds(redis,senderId) if action == 'HALL': user_msg_table_list = FORMAT_USER_MESSAGE_LIST else: user_msg_table_list = FORMAT_USER_MSG_FISH_LIST #推送所有公告 status = convert_util.to_int(redis.hget(noticeTable,'status')) log_util.debug('[try pushNotices] agentId[%s] memberIds[%s] status[%s] action[%s]'%(agentId,memberIds,status,action)) try: if status == 0: for memberId in memberIds: pipe.hset(FORMAT_GAMEHALL_NOTIC_TABLE%(noticId),'time',timeStr) pipe.lpush(user_msg_table_list%(memberId),noticId) pipe.hset(noticeTable,'status','1') else: for memberId in memberIds: pipe.lrem(user_msg_table_list%(memberId),noticId) pipe.srem(FORMAT_MSG_READ_SET%(noticId),memberId) pipe.hset(noticeTable,'status','0') except Exception,e: log_util.debug('[try pushNotices] ERROR agentId[%s] reason[%s]'%(agentId,e)) return {'code':1,'msg':type2Msg[str(status)]+'失败.'}