def do_get_task_reward(self, gameId, userId, clientId, taskid): curtime = pktimestamp.getCurrentTimestamp() task_kind = halltask._taskSystem.findTaskKind(taskid) if not task_kind: return subsys = task_kind.taskUnit.subTaskSystem if not isinstance(subsys, (HallNewUserSubTaskSystem, HallChargeSubTaskSystem)): # 目前只有这俩走这里 return try: taskmodel = subsys.loadTaskModel(userId, curtime, clientId) if not taskmodel: raise TYTaskException(-1, "未知的任务:%s" % taskid) task = taskmodel.userTaskUnit.findTask(taskid) if not task: raise TYTaskException(-2, "未知的任务:%s" % taskid) asset_list = subsys.getTaskReward(task, curtime, 'FREE_TASK', taskid) router.sendToUser(self._build_task_info(gameId, userId, clientId), userId) rewardstr = TYAssetUtils.buildContentsString(asset_list) mo = MsgPack() mo.setCmd('game') mo.setResult('action', 'get_task_reward') mo.setResult('code', 0) mo.setResult('info', '恭喜您获得了%s' % rewardstr) router.sendToUser(mo, userId) except TYTaskException, e: mo = MsgPack() mo.setCmd('game') mo.setResult('action', 'get_task_reward') mo.setResult('code', e.errorCode) mo.setResult('info', e.message) router.sendToUser(mo, userId)
def sendReward(userId, rewardConf, mailstr, eventId, eventParam): """ 通用发货 param: rewardConf 奖励配置 格式: { 'typeId': 'FixedContent', 'items': [{'itemId': 'user:chip', 'count': 100}] } param: mailstr 邮件内容文本字符串,其中包含子串\\${rewardContent} eventId: 哪个事件触发的 eventParam: 事件参数 return: list<(TYAssetKind, consumeCount, final)> """ rewardContent = TYContentRegister.decodeFromDict(rewardConf) userAssets = hallitem.itemSystem.loadUserAssets(userId) assetList = userAssets.sendContent(DIZHU_GAMEID, rewardContent, 1, True, pktimestamp.getCurrentTimestamp(), eventId, eventParam) changeNames = TYAssetUtils.getChangeDataNames(assetList) contents = TYAssetUtils.buildContentsString(assetList) if mailstr: mailstr = strutil.replaceParams(mailstr, {'rewardContent': contents}) message.send(DIZHU_GAMEID, message.MESSAGE_TYPE_SYSTEM, userId, mailstr) changeNames.add('message') datachangenotify.sendDataChangeNotify(DIZHU_GAMEID, userId, changeNames) return assetList
def _exchange(self, gameid, userid, actkey, exchangeid): info = self._exchanges.get(exchangeid) if not info: return {'result': 'fail', 'tip': "unknown productId"} buynum = self.get_exchange_buynum(userid, actkey, info) if buynum >= info['limitTimes']: return {'result': 'fail', 'tip': '兑换次数已满'} if not self.alter_user_credit(userid, actkey, -info['price']): return {'result': 'fail', 'tip': '您的积分不足'} daobase.executeUserCmd(userid, 'HINCRBY', actkey, self.FIELD_EXCHANGE_NUM.format(exchangeid), 1) userAssets = hallitem.itemSystem.loadUserAssets(userid) assetList = userAssets.sendContent(gameid, info['content'], 1, True, timestamp.getCurrentTimestamp(), "ACTIVITY_CREDIT_EXCHANGE", exchangeid) response = self._query(userid, actkey) ftlog.debug('TYActCreditExchange._exchange gameId=', gameid, 'userId=', userid, 'activityId=', self.getid(), 'reward=', TYAssetUtils.buildContents(assetList), 'buynum=', buynum + 1, 'credit=', response['credit']) changeNames = TYAssetUtils.getChangeDataNames(assetList) datachangenotify.sendDataChangeNotify(gameid, userid, changeNames) response['result'] = 'ok' response['tip'] = '兑换成功,您获得' + TYAssetUtils.buildContentsString(assetList) return response
def doGetTaskReward(self, gameId, userId, taskId): ''' 获取活动奖励 ''' try: timestamp = pktimestamp.getCurrentTimestamp() taskModel = neituiguangtask.newUserTaskSystem.loadTaskModel(userId, timestamp) task = taskModel.userTaskUnit.findTask(taskId) if not task: raise TYBizException(-1, '未知的任务:%s' % (taskId)) expiresTime = self.calcTaskExpires(userId) if timestamp >= expiresTime: raise TYBizException(-1, '任务已经过期') if not userdata.getAttr(userId, 'bindMobile'): conf = neituiguang.getConf() TodoTaskHelper.sendTodoTask(gameId, userId, TodoTaskBindPhone(conf.pleaseBindPhone, '')) return assetList = neituiguangtask.newUserTaskSystem.getTaskReward(task, timestamp, 'PROMOTE_TASK', taskId) router.sendToUser(self.buildTaskInfoResponse(userId), userId) rewardStr = TYAssetUtils.buildContentsString(assetList) mo = MsgPack() mo.setCmd('promote_info') mo.setResult('action', 'get_task_reward') mo.setResult('code', 0) mo.setResult('info', '恭喜您获得了%s' % rewardStr) router.sendToUser(mo, userId) except TYBizException, e: router.sendToUser(self.makeErrorResponse('get_task_reward', e.errorCode, e.message), userId)
def _sendRewards(self, status, task, timestamp): from hall.game import TGHall userAssets = hallitem.itemSystem.loadUserAssets(status.userId) assetList = userAssets.sendContent(self.gameId, task.taskKind.rewardContent, 1, True, timestamp, 'HALL_RP_TASK_REWARD', task.kindId) ftlog.info('RPTaskSystem._sendRewards', 'gameId=', self.gameId, 'userId=', status.userId, 'kindId=', task.kindId, 'assets=', [(atup[0].kindId, atup[1]) for atup in assetList]) changed = TYAssetUtils.getChangeDataNames(assetList) datachangenotify.sendDataChangeNotify(self.gameId, status.userId, changed) if task.taskKind.rewardMail: contents = TYAssetUtils.buildContentsString(assetList) mail = strutil.replaceParams(task.taskKind.rewardMail, {'rewardContent': contents}) pkmessage.sendPrivate(HALL_GAMEID, status.userId, 0, mail) TGHall.getEventBus().publishEvent( UserRedPacketTaskRewardEvent(status.userId, HALL_GAMEID, task.taskKind, assetList)) couponCount = TYAssetUtils.getAssetCount(assetList, hallitem.ASSET_COUPON_KIND_ID) if couponCount > 0: TGHall.getEventBus().publishEvent( UserReceivedCouponEvent( HALL_GAMEID, status.userId, couponCount, hall_red_packet_const.RP_SOURCE_RP_TASK))
def sendRewards(self, userId, timestamp): if ftlog.is_debug(): ftlog.debug('FTTableFinishRecorder.sendRewards', 'userId=', userId, 'rewardContent=', self.rewardContent) if not self.rewardContent: return userAssets = hallitem.itemSystem.loadUserAssets(userId) assetList = userAssets.sendContent(DIZHU_GAMEID, self.rewardContent, 1, True, timestamp, 'ACTIVITY_REWARD', self.intActId) changed = None if assetList: changed = TYAssetUtils.getChangeDataNames(assetList) if self.mail: mail = strutil.replaceParams( self.mail, {'rewardContent': TYAssetUtils.buildContentsString(assetList)}) pkmessage.sendPrivate(HALL_GAMEID, userId, 0, mail) if not changed: changed = set(['message']) if changed: datachangenotify.sendDataChangeNotify(DIZHU_GAMEID, userId, changed) ftlog.info('FTTableFinishRecorder.sendRewards', 'userId=', userId, 'rewards=', [(at[0].kindId, at[1]) for at in assetList])
def _exchange(self, gameid, userid, actkey, exchangeid): info = self._exchanges.get(exchangeid) if not info: return {'result': 'fail', 'tip': "unknown productId"} buynum = self.get_exchange_buynum(userid, actkey, info) if buynum >= info['limitTimes']: return {'result': 'fail', 'tip': '兑换次数已满'} if not self.alter_user_credit(userid, actkey, -info['price']): return {'result': 'fail', 'tip': '您的积分不足'} daobase.executeUserCmd(userid, 'HINCRBY', actkey, self.FIELD_EXCHANGE_NUM.format(exchangeid), 1) userAssets = hallitem.itemSystem.loadUserAssets(userid) assetList = userAssets.sendContent(gameid, info['content'], 1, True, timestamp.getCurrentTimestamp(), "ACTIVITY_CREDIT_EXCHANGE", exchangeid) response = self._query(userid, actkey) ftlog.debug('TYActCreditExchange._exchange gameId=', gameid, 'userId=', userid, 'activityId=', self.getid(), 'reward=', TYAssetUtils.buildContents(assetList), 'buynum=', buynum + 1, 'credit=', response['credit']) changeNames = TYAssetUtils.getChangeDataNames(assetList) datachangenotify.sendDataChangeNotify(gameid, userid, changeNames) response['result'] = 'ok' response['tip'] = '兑换成功,您获得' + TYAssetUtils.buildContentsString( assetList) return response
def doGetTaskReward(self, gameId, userId, taskId): ''' 获取活动奖励 ''' try: timestamp = pktimestamp.getCurrentTimestamp() taskModel = neituiguangtask.newUserTaskSystem.loadTaskModel( userId, timestamp) task = taskModel.userTaskUnit.findTask(taskId) if not task: raise TYBizException(-1, '未知的任务:%s' % (taskId)) expiresTime = self.calcTaskExpires(userId) if timestamp >= expiresTime: raise TYBizException(-1, '任务已经过期') if not userdata.getAttr(userId, 'bindMobile'): conf = neituiguang.getConf() TodoTaskHelper.sendTodoTask( gameId, userId, TodoTaskBindPhone(conf.pleaseBindPhone, '')) return assetList = neituiguangtask.newUserTaskSystem.getTaskReward( task, timestamp, 'PROMOTE_TASK', taskId) router.sendToUser(self.buildTaskInfoResponse(userId), userId) rewardStr = TYAssetUtils.buildContentsString(assetList) mo = MsgPack() mo.setCmd('promote_info') mo.setResult('action', 'get_task_reward') mo.setResult('code', 0) mo.setResult('info', '恭喜您获得了%s' % rewardStr) router.sendToUser(mo, userId) except TYBizException, e: router.sendToUser( self.makeErrorResponse('get_task_reward', e.errorCode, e.message), userId)
def doGetPrize(self, gameId, userId, clientId): try: timestamp = pktimestamp.getCurrentTimestamp() status = neituiguang.loadStatus(userId, timestamp) if not status.isBindMobile: conf = neituiguang.getConf() TodoTaskHelper.sendTodoTask( gameId, userId, TodoTaskBindPhone(conf.pleaseBindPhone, '')) return count, assetList = neituiguang.getAllReward(status) if count > 0: conf = neituiguang.getConf() prizeRewardTips = strutil.replaceParams( conf.prizeRewardTips, { 'rewardContent': TYAssetUtils.buildContentsString(assetList) }) TodoTaskHelper.sendTodoTask(gameId, userId, TodoTaskGoldRain(prizeRewardTips)) mo = self.buildQueryPrizeResponse(gameId, userId, clientId) router.sendToUser(mo, userId) else: TodoTaskHelper.sendTodoTask(gameId, userId, TodoTaskShowInfo('奖励已经领取', True)) datachangenotify.sendDataChangeNotify(gameId, userId, ['free', 'promotion_loc']) except TYBizException, e: TodoTaskHelper.sendTodoTask(gameId, userId, TodoTaskShowInfo(e.message, True))
def _exchange(self, gameid, userid, actkey, exchangeid): info = self._exchanges.get(exchangeid) if not info: return {'result': 'fail', 'tip': "unknown productId"} buynum = self.get_exchange_buynum(userid, actkey, info) if buynum >= info['limitTimes']: return {'result': 'fail', 'tip': '兑换次数已满'} curtime = timestamp.getCurrentTimestamp() userAssets = hallitem.itemSystem.loadUserAssets(userid) try: userAssets.consumeContentItemList(gameid, info['costs'], False, curtime, "ACT_ITEM_EXCHANGE_COST", exchangeid) except: return {'result': 'fail', 'tip': '您的道具不足,快去获取道具吧'} daobase.executeUserCmd(userid, 'HINCRBY', actkey, self.FIELD_EXCHANGE_NUM.format(exchangeid), 1) assetList = userAssets.sendContent(gameid, info['content'], 1, True, timestamp.getCurrentTimestamp(), "ACT_ITEM_EXCHANGE_GAIN", exchangeid) response = self._query(userid, actkey) ftlog.info('TYActItemExchange._exchange gameId=', gameid, 'userId=', userid, 'activityId=', self.getid(), 'reward=', TYAssetUtils.buildContents(assetList), 'buynum=', buynum + 1, 'credit=', response['credit']) changeNames = TYAssetUtils.getChangeDataNames(assetList) datachangenotify.sendDataChangeNotify(gameid, userid, changeNames) response['result'] = 'ok' response['tip'] = '兑换成功,您获得' + TYAssetUtils.buildContentsString(assetList) return response
def buildGotGiftDesc(self, gotVipGiftResult): desc = hallvip.vipSystem.getGotGiftDesc() if desc: contents = TYAssetUtils.buildContentsString( gotVipGiftResult.giftItemList) desc = strutil.replaceParams(desc, {'rewardContent': contents}) return desc
def getTableTaskReward(gameId, userId, taskId): timestamp = pktimestamp.getCurrentTimestamp() taskModel = dizhutask.tableTaskSystem.loadTaskModel(userId, timestamp) task = taskModel.userTaskUnit.findTask(taskId) if not task: raise TYTaskException(-1, 'Not found task: %s' % (taskId)) assetList = dizhutask.tableTaskSystem.getTaskReward( task, timestamp, 'TASK_REWARD', taskId) return TYAssetUtils.buildContentsString(assetList)
def sendRewardItems(userId, items, mail, eventId, eventParam, **kwargs): userAssets = hallitem.itemSystem.loadUserAssets(userId) assetList = userAssets.sendContentItemList( DIZHU_GAMEID, items, 1, True, pktimestamp.getCurrentTimestamp(), eventId, eventParam) changeNames = TYAssetUtils.getChangeDataNames(assetList) contents = TYAssetUtils.buildContentsString(assetList) if mail: replaceDict = {'rewardContent': contents} replaceDict.update(kwargs) mailstr = strutil.replaceParams(mail, replaceDict) mailstr = mailstr.replace('红包券', '元红包') message.send(DIZHU_GAMEID, message.MESSAGE_TYPE_SYSTEM, userId, mailstr) changeNames.add('message') datachangenotify.sendDataChangeNotify(DIZHU_GAMEID, userId, changeNames) return assetList
def _sendRewards(self, status, task, timestamp): userAssets = hallitem.itemSystem.loadUserAssets(status.userId) assetList = userAssets.sendContent(self.gameId, task.taskKind.rewardContent, 1, True, timestamp, 'ACTIVITY_REWARD', self.intActId) ftlog.debug('QuweiTaskActivity._sendRewards', 'gameId=', self.gameId, 'actId=', self.actId, 'userId=', status.userId, 'assets=', [(atup[0].kindId, atup[1]) for atup in assetList]) changed = TYAssetUtils.getChangeDataNames(assetList) datachangenotify.sendDataChangeNotify(self.gameId, status.userId, changed) if task.taskKind.rewardMail: contents = TYAssetUtils.buildContentsString(assetList) mail = strutil.replaceParams(task.taskKind.rewardMail, {'rewardContent': contents}) pkmessage.sendPrivate(HALL_GAMEID, status.userId, 0, mail)
def gainCheckinReward(self, gameId, userId, timestamp=None, actionType=0): if timestamp is None: timestamp = pktimestamp.getCurrentTimestamp() checkinOk, checkinDays = self.checkin(gameId, userId, timestamp) if ftlog.is_debug(): ftlog.debug( 'TYDailyCheckin.gainCheckinReward gameId=', gameId, 'userId=', userId, 'timestamp=', datetime.fromtimestamp(timestamp).strftime( '%Y-%m-%d %H:%M:%S'), 'checkinOk=', checkinOk, 'checkinDays=', checkinDays) if not checkinOk: return checkinOk, [], checkinDays # 发送奖励 rewardContent = self.getRewardContent(checkinDays) ebus = TGHall.getEventBus() ebus.publishEvent( TYDailyCheckinRewardEvent(gameId, userId, rewardContent, actionType)) if not rewardContent: return checkinOk, [], checkinDays userAssets = hallitem.itemSystem.loadUserAssets(userId) assetList = userAssets.sendContent(gameId, rewardContent, 1, True, timestamp, 'NSLOGIN_REWARD2', checkinDays) contents = TYAssetUtils.buildContentsString(assetList) if self._mail: mail = strutil.replaceParams(self._mail, {'rewardContent': contents}) pkmessage.send(gameId, pkmessage.MESSAGE_TYPE_SYSTEM, userId, mail) datachangenotify.sendDataChangeNotify(gameId, userId, 'message') ftlog.debug( 'TYDailyCheckin.gainCheckinReward gameId=', gameId, 'userId=', userId, 'timestamp=', datetime.fromtimestamp(timestamp).strftime('%Y-%m-%d %H:%M:%S'), 'reward=', contents) return checkinOk, assetList, checkinDays
def doGetPrize(self, gameId, userId, clientId): try: timestamp = pktimestamp.getCurrentTimestamp() status = neituiguang.loadStatus(userId, timestamp) if not status.isBindMobile: conf = neituiguang.getConf() TodoTaskHelper.sendTodoTask(gameId, userId, TodoTaskBindPhone(conf.pleaseBindPhone, '')) return count, assetList = neituiguang.getAllReward(status) if count > 0: conf = neituiguang.getConf() prizeRewardTips = strutil.replaceParams(conf.prizeRewardTips, {'rewardContent': TYAssetUtils.buildContentsString(assetList)}) TodoTaskHelper.sendTodoTask(gameId, userId, TodoTaskGoldRain(prizeRewardTips)) mo = self.buildQueryPrizeResponse(gameId, userId, clientId) router.sendToUser(mo, userId) else: TodoTaskHelper.sendTodoTask(gameId, userId, TodoTaskShowInfo('奖励已经领取', True)) datachangenotify.sendDataChangeNotify(gameId, userId, ['free', 'promotion_loc']) except TYBizException, e: TodoTaskHelper.sendTodoTask(gameId, userId, TodoTaskShowInfo(e.message, True))
def _send_rewards(cls, uid, task_id, task_kind, multi_award): reward_content = task_kind.reward_content if multi_award: reward_content = task_kind.multi_reward_content userAssets = hallitem.itemSystem.loadUserAssets(uid) assetList = userAssets.sendContent(DIZHU_GAMEID, reward_content, 1, True, int(time.time()), 'TASK_REWARD', int(task_id)) ftlog.debug('UserTaskData._send_rewards', 'task_id=', task_id, 'userId=', uid, 'assets=', [(atup[0].kindId, atup[1]) for atup in assetList]) changed = TYAssetUtils.getChangeDataNames(assetList) datachangenotify.sendDataChangeNotify(DIZHU_GAMEID, uid, changed) if task_kind.reward_mail: contents = TYAssetUtils.buildContentsString(assetList) mail = strutil.replaceParams(task_kind.reward_mail, {'rewardContent': contents}) pkmessage.sendPrivate(HALL_GAMEID, uid, 0, mail) return reward_content
def _sendPrizeIfNeed(self, gameId, userId, clientId, product, prizeContent, timestamp): # 加载活动数据 status = self.loadStatus(userId, timestamp) if self._isOverLimit(status, timestamp, 1): if ftlog.is_debug(): ftlog.debug('BuySendPrize._sendPrizeIfNeed OverLimit gameId=', gameId, 'userId=', userId, 'clientId=', clientId, 'productId=', product.productId, 'count=', status.limitRecord.count, 'limitCount=', self._limitCount) return status.limitRecord.count += 1 status.limitRecord.lastSendTimestamp = timestamp self.saveStatus(status) # 检查是否已经发过奖励 userAssets = hallitem.itemSystem.loadUserAssets(userId) assetList = userAssets.sendContent(gameId, prizeContent, 1, True, timestamp, 'ACTIVITY_REWARD', self.intActId) changed = TYAssetUtils.getChangeDataNames(assetList) changed.add('promotion_loc') datachangenotify.sendDataChangeNotify(gameId, userId, changed) if self._mail: contents = TYAssetUtils.buildContentsString(assetList) mail = strutil.replaceParams(self._mail, {'rewardContent': contents}) pkmessage.sendPrivate(HALL_GAMEID, userId, 0, mail) ftlog.info('BuySendPrize._sendPrizeIfNeed gameId=', gameId, 'userId=', userId, 'clientId=', clientId, 'productId=', product.productId, 'buyType=', product.buyType, 'actId=', self.actId, 'intActId=', self.intActId, 'sendAssets=', [(at[0].kindId, at[1]) for at in assetList], 'timestamp=', timestamp, 'count=', status.limitRecord.count)
def __getReward(self, rdskey, userId, gameId, actId, excode): config_ = daobase.executeMixCmd('HGET', 'excodeinfo:' + rdskey, 'rewards') try: config_ = json.loads(config_) except: return {} if not isinstance(config_, list): return {} rewards = {} items_ = config_ ftlog.debug('ExchangeCode.__getReward', 'items=', items_) from hall.entity.hallitem import itemSystem userAssets = itemSystem.loadUserAssets(userId) assetTupleList = [] for itemDict in items_: for assetKindId, count in itemDict.iteritems(): count = int(count) if assetKindId in self._rewardMap: assetKindId = self._rewardMap[assetKindId]['itemId'] assetTuple = userAssets.addAsset(gameId, assetKindId, count, int(time.time()), 'ACTIVITY_EXCHANGE', 0) rewards[assetKindId] = count assetTupleList.append(assetTuple) datachangenotify.sendDataChangeNotify(gameId, userId, TYAssetUtils.getChangeDataNames(assetTupleList)) ftlog.info('ExchangeCode->__statistics userid=', userId, 'excode=', excode, 'rewards=', rewards) msg = '兑换码兑换礼品成功,已自动加入到您的背包中,请查收。' message.send(9999, message.MESSAGE_TYPE_SYSTEM, userId, msg) result = TYAssetUtils.buildContentsString(assetTupleList) ftlog.debug('the last msg is result', result) return result
def gainCheckinReward(self, gameId, userId, timestamp=None, actionType=0): if timestamp is None: timestamp = pktimestamp.getCurrentTimestamp() checkinOk, checkinDays = self.checkin(gameId, userId, timestamp) if ftlog.is_debug(): ftlog.debug('TYDailyCheckin.gainCheckinReward gameId=', gameId, 'userId=', userId, 'timestamp=', datetime.fromtimestamp(timestamp).strftime('%Y-%m-%d %H:%M:%S'), 'checkinOk=', checkinOk, 'checkinDays=', checkinDays) if not checkinOk: return checkinOk, [], checkinDays # 发送奖励 rewardContent = self.getRewardContent(checkinDays) ebus = TGHall.getEventBus() ebus.publishEvent(TYDailyCheckinRewardEvent(gameId, userId, rewardContent, actionType)) if not rewardContent: return checkinOk, [], checkinDays userAssets = hallitem.itemSystem.loadUserAssets(userId) assetList = userAssets.sendContent(gameId, rewardContent, 1, True, timestamp, 'NSLOGIN_REWARD2', checkinDays) contents = TYAssetUtils.buildContentsString(assetList) if self._mail: mail = strutil.replaceParams(self._mail, {'rewardContent': contents}) pkmessage.send(gameId, pkmessage.MESSAGE_TYPE_SYSTEM, userId, mail) datachangenotify.sendDataChangeNotify(gameId, userId, 'message') ftlog.debug('TYDailyCheckin.gainCheckinReward gameId=', gameId, 'userId=', userId, 'timestamp=', datetime.fromtimestamp(timestamp).strftime('%Y-%m-%d %H:%M:%S'), 'reward=', contents) return checkinOk, assetList, checkinDays
def _sendTaskReward(self, task, timestamp, eventId, intEventParam): if task.taskKind.rewardContent: userAssets = hallitem.itemSystem.loadUserAssets( task.userTaskUnit.userId) assetList = userAssets.sendContent(self.gameId, task.taskKind.rewardContent, 1, True, timestamp, eventId, intEventParam) changeNames = TYAssetUtils.getChangeDataNames(assetList) rewardMail = task.taskKind.rewardMail if rewardMail: contents = TYAssetUtils.buildContentsString(assetList) rewardMail = strutil.replaceParams( rewardMail, { 'rewardContent': contents, 'taskName': task.taskKind.name }) message.send(self.gameId, message.MESSAGE_TYPE_SYSTEM, task.userId, rewardMail) changeNames.add('message') datachangenotify.sendDataChangeNotify(self.gameId, task.userId, changeNames) return assetList return []
def buildGotGiftDesc(self, gotVipGiftResult): desc = hallvip.vipSystem.getGotGiftDesc() if desc: contents = TYAssetUtils.buildContentsString(gotVipGiftResult.giftItemList) desc = strutil.replaceParams(desc, {'rewardContent': contents}) return desc
def doTreasureBox(userId, bigRoomId): ftlog.debug('doTreasureBox userId=', userId, 'bigRoomId=', bigRoomId) # 判定房间配置 tbconfiger = dizhuconf.getTreasureBoxInfo(bigRoomId) if not tbconfiger or not tbconfiger.get('reward', None): ftlog.debug('doTreasureBox->userIds=', userId, 'bigRoomId=', bigRoomId, 'not tbox room !') return {'ok': 0, 'info': '本房间不支持宝箱,请进入高倍房再使用'} # 判定是否可以领取 tbplaytimes, tblasttime, datas = getUserTbInfo(userId, bigRoomId) tbplaycount = tbconfiger['playCount'] if tblasttime <= 0 or tbplaytimes < tbplaycount: ftlog.debug('doTreasureBox->userIds=', userId, 'bigRoomId=', bigRoomId, 'can not tbox !') return { 'ok': 0, 'tbt': min(tbplaytimes, tbplaycount), 'tbc': tbplaycount, 'info': tbconfiger['desc'] } # 更新宝箱状态 datas['tblasttime'] = int(time.time()) datas['tbplaytimes'] = 0 _setTbData(userId, datas) rewards = tbconfiger['reward'] content = TYContentRegister.decodeFromDict(rewards) sitems = content.getItems() # 活动加成 ditems = _getDoubleInfos(bigRoomId) if ditems: for si in sitems: kindId = si.assetKindId mutil = ditems.get(kindId, 0) if mutil and mutil > 0: si.count = int(si.count * mutil) # 发送道具 # ua = hallitem.itemSystem.loadUserAssets(userId) # aslist = ua.sendContentItemList(DIZHU_GAMEID, sitems, 1, True, # timestamp.getCurrentTimestamp(), 'TASK_OPEN_TBOX_REWARD', bigRoomId) aslist = dizhu_util.sendRewardItems(userId, sitems, '', 'TASK_OPEN_TBOX_REWARD', bigRoomId) addmsg = TYAssetUtils.buildContentsString(aslist) items = [] for x in aslist: kindId = hallconf.translateAssetKindIdToOld(x[0].kindId) items.append({'item': kindId, 'count': x[1], 'total': x[2]}) if kindId in ['user:coupon', 'COUPON']: # 广播事件 from hall.game import TGHall TGHall.getEventBus().publishEvent( UserCouponReceiveEvent( HALL_GAMEID, userId, x[1], user_coupon_details.USER_COUPON_TABLE_TBBOX)) from dizhu.game import TGDizhu TGDizhu.getEventBus().publishEvent( UserTBoxLotteryEvent(DIZHU_GAMEID, userId)) datas = { 'ok': 1, 'tbt': 0, 'tbc': tbplaycount, 'info': '开启宝箱,获得' + addmsg, 'items': items } ftlog.debug('doTreasureBox->userIds=', userId, 'bigRoomId=', bigRoomId, datas) return datas
def _exchange(self, userId, gameId, clientId, activityId, exchangeId): key = "TYActivity:%d:%d:%s" % (gameId, userId, activityId) ftlog.debug("getGifts key:", key) ftlog.debug("getGifts key!!!exchangeId:", exchangeId) num = daobase.executeUserCmd(userId, 'hget', key, 'giftNum') if not num: num = 0 giftsNum = num exConfig = self._getExchangeConfig(exchangeId) if not exConfig: return {"errorInfo": "config not exist", "errorCode": 2} needCount = exConfig["consumeCount"] limit = exConfig["limitTimes"] nowDateStr = time.strftime("%Y-%m-%d", time.localtime(time.time())) exTimesField = "exTimes:%d:%s" % (exchangeId, nowDateStr) key = "TYActivity:%d:%d:%s" % (gameId, userId, activityId) ftlog.debug("_exchange key:", key) exchangeResult = daobase.executeUserLua(userId, self.EXCHANGE_SCRIPT, 4, key, needCount, limit, exTimesField) if exchangeResult == 1: ftlog.info("exceed limit,", "userId", userId, "gameId", gameId, "activityId", activityId, "exchangeId", exchangeId, clientId) return {"exchangeResult": [], "reason": u"今日兑换次数已满!", "list": [], "giftsNum": giftsNum} if exchangeResult == 2: ftlog.info("no enough gifts,", "userId", userId, "gameId", gameId, "activityId", activityId, "exchangeId", exchangeId, clientId) ftlog.debug("self._clientConf:", self._clientConf) giftName = self._clientConf["config"]["gift"]["name"] info = u"您的%s不足!" % giftName ftlog.debug("_exchange key123:", key) ftlog.debug("_exchange key123:", giftsNum) return {"exchangeResult": [], "reason": info, "list": [], "giftsNum": giftsNum} result = {} result["exchangeResult"] = [] from hall.entity.hallitem import itemSystem userAssets = itemSystem.loadUserAssets(userId) assetList = [] for item in exConfig["items"]: asset = userAssets.addAsset(gameId, item['productId'], item['count'], int(time.time()), 'ACTIVITY_GETSCORE', 0) assetList.append(asset) result["exchangeResult"].append({"name": item["name"], "count": item["count"], "productId": item["productId"], "unit": item["unit"]}) info = '兑换成功,您获得%s' % (TYAssetUtils.buildContentsString(assetList, True)) ftlog.info('exchangeCode userId=', userId, 'gameId=', gameId, 'clientId=', clientId, 'activityId=', activityId, 'assetList=', [(atup[0].kindId, atup[1]) for atup in assetList]) changeNames = TYAssetUtils.getChangeDataNames(assetList) datachangenotify.sendDataChangeNotify(gameId, userId, changeNames) result["reason"] = info result["list"] = [] ''' 拿到当前剩余的积分,并返回 ''' ftlog.debug("_exchange key123:", key) result["giftsNum"] = giftsNum ftlog.debug("_exchange key123456:", giftsNum) ftlog.info("exchangeResult,", "userId", userId, "gameId", gameId, "activityId", activityId, "exchangeId", exchangeId, clientId, result) return result
def _onOrderDelivery(event): from hall.entity import hallitem nowDT = datetime.now() order = event.orderDeliveryResult.order if ((_conf.startDT and nowDT < _conf.startDT) or (_conf.endDT and nowDT >= _conf.endDT)): if ftlog.is_debug(): ftlog.debug('buy_send_gift._onOrderDelivery outofTime userId=', event.userId, 'orderId=', order.orderId, 'productId=', order.productId, 'nowDT=', nowDT.strftime('%Y-%m-%d %H:%M:%S'), 'startDT=', _conf.startDT.strftime('%Y-%m-%d %H:%M:%S'), 'endDT=', _conf.endDT.strftime('%Y-%m-%d %H:%M:%S')) return giftConf = _conf.findGiftConf(order.productId) if not giftConf: if ftlog.is_debug(): ftlog.debug('buy_send_gift._onOrderDelivery noGiftConf userId=', event.userId, 'orderId=', order.orderId, 'productId=', order.productId, 'orderClientId=', order.clientId) return hallGameId = strutil.getGameIdFromHallClientId(order.clientId) if hallGameId not in giftConf.gameIds: if ftlog.is_debug(): ftlog.debug('buy_send_gift._onOrderDelivery notInGameIds userId=', event.userId, 'orderId=', order.orderId, 'productId=', order.productId, 'giftConf=', giftConf.conf, 'orderClientId=', order.clientId, 'hallGameId=', hallGameId, 'gameIds=', giftConf.gameIds) return count = 0 if giftConf.maxCount >= 0: limitD = gamedata.getGameAttrJson(order.userId, hallGameId, 'act.buy_send_gift', {}) count = limitD.get(order.productId, 0) if count + 1 > giftConf.maxCount: ftlog.info('buy_send_gift._onOrderDelivery overLimit userId=', event.userId, 'orderId=', order.orderId, 'productId=', order.productId, 'giftConf=', giftConf.conf if giftConf else None, 'orderClientId=', order.clientId, 'count=', count, 'maxCount=', giftConf.maxCount) return count += 1 limitD[order.productId] = count gamedata.setGameAttr(order.userId, hallGameId, 'act.buy_send_gift', strutil.dumps(limitD)) assetList = None if giftConf.giftContent: userAssets = hallitem.itemSystem.loadUserAssets(order.userId) # def sendContent(self, gameId, content, count, ignoreUnknown, timestamp, eventId, intEventParam): assetList = userAssets.sendContent(hallGameId, giftConf.giftContent, 1, True, pktimestamp.getCurrentTimestamp(), 'ACTIVITY_REWARD', 10043) changedDataNames = TYAssetUtils.getChangeDataNames(assetList) if assetList else set() contentStr = TYAssetUtils.buildContentsString(assetList) if assetList else '' if giftConf.mail: mail = strutil.replaceParams(giftConf.mail, {'gotContent': contentStr, 'price': order.product.price}) message.send(hallGameId, message.MESSAGE_TYPE_SYSTEM, order.userId, mail) changedDataNames.add('message') if changedDataNames: datachangenotify.sendDataChangeNotify(HALL_GAMEID, order.userId, changedDataNames) ftlog.info('buy_send_gift._onOrderDelivery sendGift userId=', event.userId, 'orderId=', order.orderId, 'productId=', order.productId, 'giftConf=', giftConf.conf if giftConf else None, 'orderClientId=', order.clientId, 'count=', count, 'maxCount=', giftConf.maxCount, 'assetList=', [(a[0].kindId, a[1]) for a in assetList] if assetList else None)
def openRedEnvelope(self, userId, itemId=''): ''' 打开红包 ''' global _redEnvelopeConfig # 是否领取过 receivers = daobase.executeMixCmd('LRANGE', self.dbPrefix + self.id + self.RECEIVER, 0, -1) if receivers: if ftlog.is_debug(): ftlog.debug('TYRedEnvelope.openRedEnvelope receivers:', receivers) for receiverJson in receivers: receiver = json.loads(receiverJson) if ftlog.is_debug(): ftlog.debug('TYRedEnvelope.openRedEnvelope receiver:', receiver) if userId == receiver['userId']: return False, _redEnvelopeConfig['tips']['opened'] # 构造添加给获取红包用户的奖励清单 contentItemList = [] prizesJson = self._getPrize(itemId) # prizesJson = daobase.executeMixCmd('LPOP', self.dbPrefix + self.id + self.PACKAGES) daobase.executeMixCmd('expire', self.dbPrefix + self.id + self.PACKAGES, self.expiredTime) if prizesJson: prizes = json.loads(prizesJson) if ftlog.is_debug(): ftlog.debug('TYRedEnvelope.openRedEnvelope prizes:', prizes) for prize in prizes: if ftlog.is_debug(): ftlog.debug('TYRedEnvelope.openRedEnvelope prize:', prize) result, _itemId = self.getAssetID(prize) if result == False: ftlog.debug('TYRedEnvelope.openRedEnvelope prize err1: ', prize, ' left: ', self.contents); continue result, value = self.getItemValue(prize) if result == False: ftlog.debug('TYRedEnvelope.openRedEnvelope prize err2: ', prize, ' left: ', self.contents); continue if ftlog.is_debug(): ftlog.debug('TYRedEnvelope.openRedEnvelope itemId:', _itemId) ftlog.debug('TYRedEnvelope.openRedEnvelope count:', prizes[prize] * value) contentItemList.append( TYContentItem.decodeFromDict({'itemId': _itemId, 'count': prizes[prize] * value})) if ftlog.is_debug(): ftlog.debug('contentItemList:', contentItemList) userAssets = hallitem.itemSystem.loadUserAssets(userId) # 添加奖励 results = userAssets.sendContentItemList(HALL_GAMEID, contentItemList, 1, True, pktimestamp.getCurrentTimestamp(), self.EVENTID, 0) # notify datachangenotify.sendDataChangeNotify(HALL_GAMEID, userId, TYAssetUtils.getChangeDataNames(results)) # 构造奖励字符串 prizeString = TYAssetUtils.buildContentsString(results) if ftlog.is_debug(): ftlog.debug('TYRedEnvelope.openRedEnvelope prizeString:', prizeString) # add receiver re = {} re['userId'] = userId re['prize'] = prizes re['prizeStr'] = prizeString re['time'] = pktimestamp.formatTimeMs() if ftlog.is_debug(): ftlog.debug('TYRedEnvelope.openRedEnvelope add receiver re: ', re) daobase.executeMixCmd('LPUSH', self.dbPrefix + self.id + self.RECEIVER, json.dumps(re)) daobase.executeMixCmd('expire', self.dbPrefix + self.id + self.RECEIVER, self.expiredTime) # make response response = {} response['envelopeId'] = self.id response['prizes'] = prizes response['prizeStr'] = prizeString if ftlog.is_debug(): ftlog.debug('TYRedEnvelope.openRedEnvelope response: ', response) return True, response else: if self.state != self.STATE_FINISH: self.state = self.STATE_FINISH self.save2DB() return False, _redEnvelopeConfig['tips']['finished']
def _onOrderDelivery(event): from hall.entity import hallitem nowDT = datetime.now() order = event.orderDeliveryResult.order if ((_conf.startDT and nowDT < _conf.startDT) or (_conf.endDT and nowDT >= _conf.endDT)): if ftlog.is_debug(): ftlog.debug('buy_send_gift._onOrderDelivery outofTime userId=', event.userId, 'orderId=', order.orderId, 'productId=', order.productId, 'nowDT=', nowDT.strftime('%Y-%m-%d %H:%M:%S'), 'startDT=', _conf.startDT.strftime('%Y-%m-%d %H:%M:%S'), 'endDT=', _conf.endDT.strftime('%Y-%m-%d %H:%M:%S')) return giftConf = _conf.findGiftConf(order.productId) if not giftConf: if ftlog.is_debug(): ftlog.debug('buy_send_gift._onOrderDelivery noGiftConf userId=', event.userId, 'orderId=', order.orderId, 'productId=', order.productId, 'orderClientId=', order.clientId) return hallGameId = strutil.getGameIdFromHallClientId(order.clientId) if hallGameId not in giftConf.gameIds: if ftlog.is_debug(): ftlog.debug('buy_send_gift._onOrderDelivery notInGameIds userId=', event.userId, 'orderId=', order.orderId, 'productId=', order.productId, 'giftConf=', giftConf.conf, 'orderClientId=', order.clientId, 'hallGameId=', hallGameId, 'gameIds=', giftConf.gameIds) return count = 0 if giftConf.maxCount >= 0: limitD = gamedata.getGameAttrJson(order.userId, hallGameId, 'act.buy_send_gift', {}) count = limitD.get(order.productId, 0) if count + 1 > giftConf.maxCount: ftlog.info('buy_send_gift._onOrderDelivery overLimit userId=', event.userId, 'orderId=', order.orderId, 'productId=', order.productId, 'giftConf=', giftConf.conf if giftConf else None, 'orderClientId=', order.clientId, 'count=', count, 'maxCount=', giftConf.maxCount) return count += 1 limitD[order.productId] = count gamedata.setGameAttr(order.userId, hallGameId, 'act.buy_send_gift', strutil.dumps(limitD)) assetList = None if giftConf.giftContent: userAssets = hallitem.itemSystem.loadUserAssets(order.userId) #def sendContent(self, gameId, content, count, ignoreUnknown, timestamp, eventId, intEventParam): assetList = userAssets.sendContent(hallGameId, giftConf.giftContent, 1, True, pktimestamp.getCurrentTimestamp(), 'ACTIVITY_REWARD', 10043) changedDataNames = TYAssetUtils.getChangeDataNames( assetList) if assetList else set() contentStr = TYAssetUtils.buildContentsString( assetList) if assetList else '' if giftConf.mail: mail = strutil.replaceParams(giftConf.mail, { 'gotContent': contentStr, 'price': order.product.price }) message.send(hallGameId, message.MESSAGE_TYPE_SYSTEM, order.userId, mail) changedDataNames.add('message') if changedDataNames: datachangenotify.sendDataChangeNotify(HALL_GAMEID, order.userId, changedDataNames) ftlog.info('buy_send_gift._onOrderDelivery sendGift userId=', event.userId, 'orderId=', order.orderId, 'productId=', order.productId, 'giftConf=', giftConf.conf if giftConf else None, 'orderClientId=', order.clientId, 'count=', count, 'maxCount=', giftConf.maxCount, 'assetList=', [(a[0].kindId, a[1]) for a in assetList] if assetList else None)
def openRedEnvelope(self, userId, itemId=''): ''' 打开红包 ''' global _redEnvelopeConfig # 是否领取过 receivers = daobase.executeMixCmd( 'LRANGE', self.dbPrefix + self.id + self.RECEIVER, 0, -1) if receivers: if ftlog.is_debug(): ftlog.debug('TYRedEnvelope.openRedEnvelope receivers:', receivers) for receiverJson in receivers: receiver = json.loads(receiverJson) if ftlog.is_debug(): ftlog.debug('TYRedEnvelope.openRedEnvelope receiver:', receiver) if userId == receiver['userId']: return False, _redEnvelopeConfig['tips']['opened'] # 构造添加给获取红包用户的奖励清单 contentItemList = [] prizesJson = self._getPrize(itemId) # prizesJson = daobase.executeMixCmd('LPOP', self.dbPrefix + self.id + self.PACKAGES) daobase.executeMixCmd('expire', self.dbPrefix + self.id + self.PACKAGES, self.expiredTime) if prizesJson: prizes = json.loads(prizesJson) if ftlog.is_debug(): ftlog.debug('TYRedEnvelope.openRedEnvelope prizes:', prizes) for prize in prizes: if ftlog.is_debug(): ftlog.debug('TYRedEnvelope.openRedEnvelope prize:', prize) result, _itemId = self.getAssetID(prize) if result == False: ftlog.debug('TYRedEnvelope.openRedEnvelope prize err1: ', prize, ' left: ', self.contents) continue result, value = self.getItemValue(prize) if result == False: ftlog.debug('TYRedEnvelope.openRedEnvelope prize err2: ', prize, ' left: ', self.contents) continue if ftlog.is_debug(): ftlog.debug('TYRedEnvelope.openRedEnvelope itemId:', _itemId) ftlog.debug('TYRedEnvelope.openRedEnvelope count:', prizes[prize] * value) contentItemList.append( TYContentItem.decodeFromDict({ 'itemId': _itemId, 'count': prizes[prize] * value })) if ftlog.is_debug(): ftlog.debug('contentItemList:', contentItemList) userAssets = hallitem.itemSystem.loadUserAssets(userId) # 添加奖励 results = userAssets.sendContentItemList( HALL_GAMEID, contentItemList, 1, True, pktimestamp.getCurrentTimestamp(), self.EVENTID, 0) # notify datachangenotify.sendDataChangeNotify( HALL_GAMEID, userId, TYAssetUtils.getChangeDataNames(results)) # 构造奖励字符串 prizeString = TYAssetUtils.buildContentsString(results) if ftlog.is_debug(): ftlog.debug('TYRedEnvelope.openRedEnvelope prizeString:', prizeString) # add receiver re = {} re['userId'] = userId re['prize'] = prizes re['prizeStr'] = prizeString re['time'] = pktimestamp.formatTimeMs() if ftlog.is_debug(): ftlog.debug('TYRedEnvelope.openRedEnvelope add receiver re: ', re) daobase.executeMixCmd('LPUSH', self.dbPrefix + self.id + self.RECEIVER, json.dumps(re)) daobase.executeMixCmd('expire', self.dbPrefix + self.id + self.RECEIVER, self.expiredTime) # make response response = {} response['envelopeId'] = self.id response['prizes'] = prizes response['prizeStr'] = prizeString if ftlog.is_debug(): ftlog.debug('TYRedEnvelope.openRedEnvelope response: ', response) return True, response else: if self.state != self.STATE_FINISH: self.state = self.STATE_FINISH self.save2DB() return False, _redEnvelopeConfig['tips']['finished']
def handleEvent(cls, event): conf = dizhuconf.getActivityConf('month_checkin_gift') monthDayCount = calendar.monthrange(event.checkinDate.year, event.checkinDate.month)[1] giftDayCount = conf.get('giftDayCount', -1) if giftDayCount <= 0: giftDayCount = monthDayCount giftDayCount = min(giftDayCount, monthDayCount) clientId = sessiondata.getClientId(event.userId) hallGameId = strutil.getGameIdFromHallClientId(clientId) if hallGameId != DIZHU_GAMEID: return if ftlog.is_debug(): ftlog.debug('MonthCheckinGift.handleEvent userId=', event.userId, 'gameId=', event.gameId, 'eventType=', type(event), 'checkinDate=', event.checkinDate, 'allCheckinCount=', event.status.allCheckinCount, 'giftDayCount=', giftDayCount, 'monthDayCount=', monthDayCount) giftContent = None try: if not Tool.checkNow(conf.get('datetime_start'), conf.get('datetime_end')): ftlog.debug('MonthCheckinGift.handleEvent outOfDate userId=', event.userId, 'gameId=', event.gameId, 'eventType=', type(event), 'checkinDate=', event.checkinDate, 'allCheckinCount=', event.status.allCheckinCount, 'giftDayCount=', giftDayCount, 'monthDayCount=', monthDayCount) return giftContent = TYContentRegister.decodeFromDict( conf.get('giftContent')) except: ftlog.error('MonthCheckinGift.handleEvent userId=', event.userId, 'gameId=', event.gameId, 'eventType=', type(event), 'checkinDate=', event.checkinDate, 'allCheckinCount=', event.status.allCheckinCount, 'giftDayCount=', giftDayCount, 'monthDayCount=', monthDayCount) return if event.status.allCheckinCount >= giftDayCount: assetList = None if giftContent: userAssets = hallitem.itemSystem.loadUserAssets(event.userId) assetList = userAssets.sendContent( DIZHU_GAMEID, giftContent, 1, True, pktimestamp.getCurrentTimestamp(), 'ACTIVITY_REWARD', cls.ACTIVITY_ID) changed = TYAssetUtils.getChangeDataNames(assetList) mail = conf.get('mail', '') if mail: gotContent = giftContent.desc if giftContent.desc else TYAssetUtils.buildContentsString( assetList) mail = strutil.replaceParams(mail, {'gotContent': gotContent}) message.sendPrivate(HALL_GAMEID, event.userId, 0, mail) changed.add('message') datachangenotify.sendDataChangeNotify(HALL_GAMEID, event.userId, changed) ftlog.info('MonthCheckinGift.statics sendGift userId=', event.userId, 'gameId=', event.gameId, 'eventType=', type(event), 'checkinDate=', event.checkinDate, 'allCheckinCount=', event.status.allCheckinCount, 'giftDayCount=', giftDayCount, 'monthDayCount=', monthDayCount, 'rewards=', [(a[0].kindId, a[1]) for a in assetList] if assetList else None)
def doTreasureBox(gameId, userId, bigRoomId): data = _getTbData(gameId, userId) bigRoomId = data['tbroomid'] if ftlog.is_debug(): ftlog.debug('treasurebox.doTreasureBox', 'gameId=', gameId, 'userId=', userId, 'bigRoomId=', bigRoomId) # 判定房间配置 tbconfiger = getTreasureBoxConf(gameId, bigRoomId) if not tbconfiger or not tbconfiger.get('reward', None): if ftlog.is_debug(): ftlog.debug('treasurebox.doTreasureBox', 'gameId=', gameId, 'userId=', userId, 'err=', 'NotTBoxRoom') return {'ok': 0, 'info': '本房间不支持宝箱,请进入高倍房再使用'} # 判定是否可以领取 tbplaytimes, tblasttime, datas = getUserTbInfo(gameId, userId, bigRoomId) tbplaycount = tbconfiger['playCount'] if tblasttime <= 0 or tbplaytimes < tbplaycount: if ftlog.is_debug(): ftlog.debug('treasurebox.doTreasureBox', 'gameId=', gameId, 'userId=', userId, 'err=', 'CanNotTBox') return { 'ok': 0, 'tbt': min(tbplaytimes, tbplaycount), 'tbc': tbplaycount, 'info': tbconfiger['desc'] } # 更新宝箱状态 datas['tblasttime'] = int(time.time()) datas['tbplaytimes'] = 0 _setTbData(gameId, userId, datas) rewards = tbconfiger['reward'] content = TYContentRegister.decodeFromDict(rewards) sitems = content.getItems() # 活动加成 ditems = _getDoubleInfos(gameId, bigRoomId) if ditems: for si in sitems: kindId = si.assetKindId mutil = ditems.get(kindId, 0) if mutil and mutil > 0: si.count = int(si.count * mutil) # 发送道具 ua = hallitem.itemSystem.loadUserAssets(userId) aslist = ua.sendContentItemList(gameId, sitems, 1, True, timestamp.getCurrentTimestamp(), 'TASK_OPEN_TBOX_REWARD', bigRoomId) addmsg = TYAssetUtils.buildContentsString(aslist) items = [] for x in aslist: kindId = hallconf.translateAssetKindIdToOld(x[0].kindId) items.append({'item': kindId, 'count': x[1], 'total': x[2]}) TYGame(gameId).getEventBus().publishEvent( UserTBoxLotteryEvent(gameId, userId)) data = { 'ok': 1, 'tbt': 0, 'tbc': tbplaycount, 'info': '开启宝箱,获得' + addmsg, 'items': items } if ftlog.is_debug(): ftlog.debug('treasurebox.doTreasureBox', 'gameId=', gameId, 'userId=', userId, 'data=', data) return data