Esempio n. 1
0
    def sendRewardToUser(self, userId, mail, intActId, charged_rmb):
        ftlog.debug('GiftboxEntry.sendRewardToUser:begin',
                    'userId=', userId,
                    'mail=', mail,
                    'charged_rmb=', charged_rmb)

        # 将礼包道具消耗掉,
        ok = UserBag.consumeAssetsIfEnough(userId, self._itemId, 1, 'ACTIVITY_REWARD', DIZHU_GAMEID, intActId)
        if not ok:
            ftlog.debug('GiftboxEntry.sendRewardToUser:consumeitem',
                        'userId=', userId,
                        'ok=', ok)
            return False
        
        if mail and self._reward.get('desc'):
            desc = self._reward.get('desc')
            mail = strutil.replaceParams(mail, {'rewardContent':desc})
        else:
            mail = None
        UserBag.sendAssetsToUser(DIZHU_GAMEID, userId, self._reward, 'ACTIVITY_REWARD', mail, intActId)
        ftlog.info('GiftboxEntry:sendRewardToUser:'******'gameId=', DIZHU_GAMEID, 
                   'userId=', userId, 
                   'itemId=', self._itemId, 
                   'charged_rmb=', charged_rmb, 
                   'reward=', self._reward)
        return True
Esempio n. 2
0
 def consumeExpenses(cls, userId, food):
     '''
     消耗抽奖花费
     '''
     ftlog.info('WorshipHelper.consumeExpenses',
                'userId=', userId,
                'food=', food.toDict())
     return UserBag.consumeAssetsIfEnough(userId, 'user:chip', food.chip, 'DDZ_WORSHIP_SYSTEM')
Esempio n. 3
0
 def consumeExpenses(cls, userId, item):
     '''
     消耗抽奖花费
     '''
     expensesItemId = item.assetKindId
     expensesItemCount = item.count
     ftlog.info('FishHelper.consumeExpenses', 'userId=', userId, 'itemId=',
                expensesItemId, 'count=', expensesItemCount)
     return UserBag.consumeAssetsIfEnough(userId, expensesItemId,
                                          expensesItemCount,
                                          'DDZ_FISHING_SYSTEM')
Esempio n. 4
0
 def consumeLuckyDrawExpenses(cls, userId):
     '''
     消耗抽奖花费
     :return 费用不足返回False
     '''
     conf = getWarmupSystemConfig()
     consumeAssets = conf.get('expensesAssets', {})
     expensesItemId = consumeAssets.get('itemId')
     expensesItemCount = consumeAssets.get('count', 0)
     ftlog.debug('WarmUpSystemHelper.consumeLuckyDrawExpenses',
                 'userId=', userId,
                 'itemId=', expensesItemId,
                 'count=', expensesItemCount)
     return UserBag.consumeAssetsIfEnough(userId, expensesItemId, expensesItemCount, BIEVENT_ID)
Esempio n. 5
0
    def handleRequestPutting(self, model, userId, poolItem):
        '''
        投入资本
        :param userId:
        :return:
        '''
        clientconf = strutil.deepcopy(self._clientConf)
        serverconf = self._serverConf
        uniquekey = Utility.buildUniqueKey(serverconf)
        ftlog.debug('WishingWell.handleRequestPutting:start',
                    'userId=', userId,
                    'model=', model.dict())

        ## 判断许愿池投入按钮是否过期
        if Utility.isPutIntoButtonOutdate(clientconf):
            return Utility.buildError(Tool.dictGet(clientconf, 'config.wishingOverError'))

        ## 许愿消耗费用
        expensesConfig = poolItem.get('expenses')
        expensesItemId = expensesConfig.get('itemId', 'user:chip')
        expensesItemCount = expensesConfig.get('count', 0)
        ftlog.debug('WishingWell.handleRequestPutting:consume',
                    'userId=', userId,
                    'poolItem=', poolItem,
                    'expensesItemId=', expensesItemId,
                    'expensesItemCount=', expensesItemCount)
        if not UserBag.consumeAssetsIfEnough(userId, expensesItemId, expensesItemCount, self.EVENT_ID): ## 费用不足
            return Utility.buildError(Tool.dictGet(clientconf, 'config.expensesNotEnoughError'))

        ## 更新Model
        model.isAlreadyPutted = True
        ## 重置计时,重新开始计时
        model.resetingCounterToCurrentTimestamp()
        model.dumpsToRedis(userId, uniquekey)

        ftlog.info('WishingWell.handleRequestPutting, ',
                   'userId', userId,
                   'poolstepindex', model.poolStepIndex,
                   'model=', model.dict())

        response = self.getActivityUserStatus(userId, model)

        puttingSuccess = Tool.dictGet(clientconf, 'config.puttingSuccess')
        if puttingSuccess and len(puttingSuccess) > 0:
            response['message'] = puttingSuccess
        response['operate'] = 'putting'
        return response