def isOutdate(cls): ''' 获得是否过期,使用game/6/activity/0.json中的配置判断 ''' dizhuconf = cls.getDdzActivityConf() ftlog.debug("DdzMatchScore.onMatchWinlose: dizhuconf=", dizhuconf) return not Tool.checkNow(dizhuconf.get('start_date', '2016-01-01 00:00:00'), dizhuconf.get('end_date', '2016-01-01 00:00:00'))
def isOutdate(cls): ''' 获得是否过期,使用game/6/activity/0.json中的配置判断 ''' dizhuconf = cls.getActivityConfig() return not Tool.checkNow( dizhuconf.get('datetime_start', '2016-01-01 00:00:00'), dizhuconf.get('datetime_end', '2016-01-01 00:00:00'))
def getFieldKey(cls): ''' 获得redis,gamedata的hashmap中存储的key ''' dizhuconf = cls.getActivityConfig() datetime_start = dizhuconf.get('datetime_start', '') return 'act.bingphone.issend.' + datetime_start
def getRedisKey(cls): ''' 获得存在记录RMB累计和起始大师分的redis key ''' dizhuconf = cls.getDdzActivityConf() rediskey = "dumplings" + dizhuconf.get('datetime_start', "2016") return rediskey
def getActivityConf(cls): ''' 获得game/9999/activity/0.json中的具体活动ID的配置 ''' dizhuconf = cls.getDdzActivityConf() activityId = dizhuconf.get('activityId') return Activity.getConfigById(activityId)
def onUserLogin(cls, event): ftlog.debug("ItemSender.onUserLogin: event=", event) userId = event.userId dizhuconf = cls.getDdzActivityConf() if not Tool.isGameDdz(userId): return if cls.isOutdate(): ftlog.debug("ItemSender.onUserLogin: userId=", userId, "isOutdate=", True) return # 若clientId不支持,则返回 isSupport = cls.isClientIdSupport( userId, dizhuconf.get('supportContainClientIdOr', [])) ftlog.debug("ItemSender.onUserLogin: userId=", userId, "isSupport=", isSupport) if not isSupport: return isFirst = Redis.isFirst(userId, cls.getUniqueKey()) ftlog.debug("ItemSender.onUserLogin: userId=", userId, "isFirst=", isFirst) if not isFirst: return # 发放道具 ftlog.debug("ItemSender.onUserLogin: userId=", userId, "ddzconf=", dizhuconf) mail = dizhuconf.get("mail") assets = dizhuconf.get("assets") if not assets: return UserBag.sendAssetsToUser(DIZHU_GAMEID, userId, assets, 'DDZ_ATC_ITEM_SENDER', mail) ftlog.debug("ItemSender.onUserLogin: userId=", userId, "send assets=", assets, "mail=", mail)
def sendingRewardOnceIfNeed(cls, userId): ftlog.debug('BindingPhoneHandler.sendingRewardOnceIfNeed:start', 'userId=', userId, 'isOutdate=', cls.isOutdate()) if cls.isOutdate(): return None ## 是否在clientId集合中 dizhuconf = cls.getActivityConfig() clientIdList = dizhuconf.get('clientIdList', []) clientId = sessiondata.getClientId(userId) ftlog.debug('BindingPhoneHandler.sendingRewardOnceIfNeed:clientId', 'userId=', userId, 'clientId=', clientId, 'ok=', clientId in clientIdList) if clientId not in clientIdList: return None ## 是否是第一次领取 isFirst = Redis.isFirst(userId, cls.getFieldKey()) ftlog.debug('BindingPhoneHandler.sendingRewardOnceIfNeed:isFirst', 'userId=', userId, 'isFirst=', isFirst) if not isFirst: return None ## 发放奖励 mail = dizhuconf.get('mail') assetsList = dizhuconf.get('assets') ftlog.debug('BindingPhoneHandler.sendingRewardOnceIfNeed:send', 'userId=', userId, 'dizhuconf=', dizhuconf) if not assetsList: return None UserBag.sendAssetsListToUser(DIZHU_GAMEID, userId, assetsList, cls.EVENT_ID, mail, cls.ACTIVITY_ID) ftlog.debug('BindingPhoneHandler.sendingRewardOnceIfNeed:end', 'userId=', userId, 'assetsList=', assetsList, 'mail=', mail) return None