예제 #1
0
def _triggerChargeNotifyEvent(event):
    """
    充值发货事件
    """
    ftlog.info("user_system._triggerChargeNotifyEvent->",
               "userId =", event.userId,
               "gameId =", event.gameId,
               "rmbs =", event.rmbs,
               "productId =", event.productId,
               "clientId =", event.clientId,
               "isAddVipExp", getattr(event, "isAddVipExp", False))
    userId = event.userId
    productId = event.productId
    # 购买非代购券商品.
    if event.productId not in config.getPublic("notVipExpProductIds", []) and event.rmbs > 0:
        from newfish.entity import vip_system
        # # app充值
        # if util.isAppClient(userId):
        #     isAddVipExp = False
        # else: # 微信充值
        #     isAddVipExp = True
        isAddVipExp = getattr(event, "isAddVipExp", False)
        vip_system.addUserVipExp(event.gameId, userId, event.diamonds, "BUY_PRODUCT",
                                 pokerconf.productIdToNumber(productId), productId,
                                 rmbs=event.rmbs, isAddVipExp=isAddVipExp)
예제 #2
0
 def doChargeNotify(self, gameId, userId, prodId, rmbs, diamonds, clientId):
     if diamonds > 0:
         hallvip.userVipSystem.addUserVipExp(gameId, userId, diamonds, 'BUY_PRODUCT',
                                             pokerconf.productIdToNumber(prodId))
     TGHall.getEventBus().publishEvent(ChargeNotifyEvent(userId, gameId, rmbs, diamonds, prodId, clientId))
     mo = MsgPack()
     mo.setCmd('charge_notify')
     mo.setResult('userId', userId)
     mo.setResult('gameId', gameId)
     return mo
예제 #3
0
 def doChargeNotify(self, gameId, userId, prodId, rmbs, diamonds, clientId):
     if diamonds > 0:
         hallvip.userVipSystem.addUserVipExp(
             gameId, userId, diamonds, 'BUY_PRODUCT',
             pokerconf.productIdToNumber(prodId))
     TGHall.getEventBus().publishEvent(
         ChargeNotifyEvent(userId, gameId, rmbs, diamonds, prodId,
                           clientId))
     mo = MsgPack()
     mo.setCmd('charge_notify')
     mo.setResult('userId', userId)
     mo.setResult('gameId', gameId)
     return mo
예제 #4
0
    def doChargeNotify(self, gameId, userId, prodId, rmbs, diamonds, clientId):
        if diamonds > 0:
            hallvip.userVipSystem.addUserVipExp(
                gameId, userId, diamonds, 'BUY_PRODUCT',
                pokerconf.productIdToNumber(prodId))
        TGHall.getEventBus().publishEvent(
            ChargeNotifyEvent(userId, gameId, rmbs, diamonds, prodId,
                              clientId))

        try:
            # 发送全系统内的充值事件
            from tuyoo5.core import tygame
            from tuyoo5.core import typlugin
            clientId = sessiondata.getClientId(userId)
            evt = tygame.GlobalChargeEvent(userId, gameId, gameId, rmbs,
                                           diamonds, prodId, clientId, '', '')
            typlugin.asyncTrigerGlobalEvent(evt)
        except Exception, e:
            ftlog.info('freetime5 not patched GlobalChargeEvent !', str(e))
예제 #5
0
def doBuyGift(userId, clientId, giftId, buyType, itemId=0):
    """
    购买礼包
    """
    if ftlog.is_debug():
        ftlog.debug("doBuyGift===>", userId, clientId, giftId, buyType)
    giftConf = config.getDailyGiftConf(clientId).get(str(giftId), {})
    continuousDay = _getContinuousDay(userId, giftId)
    dayIdx = _getGiftDayIdx(clientId, giftId, continuousDay)
    lang = util.getLanguage(userId, clientId)
    commonRewards = []
    chestRewards = []
    chestId = 0
    giftName = config.getMultiLangTextConf(giftConf["giftName"], lang=lang)
    # 使用其他货币(非direct)购买
    if giftConf.get("otherBuyType", {}).get(buyType):
        price = giftConf.get("otherBuyType", {}).get(buyType)
        # 代购券购买礼包
        if buyType == BT_VOUCHER:
            _consume = [{"name": VOUCHER_KINDID, "count": abs(price)}]
            _ret = util.consumeItems(userId,
                                     _consume,
                                     "BI_NFISH_BUY_ITEM_CONSUME",
                                     intEventParam=int(giftId),
                                     param01=int(giftId))
            if not _ret:
                code = 1
                _sendBuyGiftRet(userId, clientId, giftId, code, chestId,
                                commonRewards, chestRewards)
                return
            else:
                code = 0
                vip_system.addUserVipExp(FISH_GAMEID,
                                         userId,
                                         abs(price) * 10,
                                         "BUY_PRODUCT",
                                         pokerconf.productIdToNumber(
                                             giftConf["productId"]),
                                         giftConf["productId"],
                                         rmbs=abs(price))
                # message = u"您使用%s代购券,购买商品【%s】, 获得%s" % (price, giftConf["giftName"], giftConf["giftName"])
                message = config.getMultiLangTextConf(
                    "ID_BUY_GIFT_RET_BY_VOUCHER",
                    lang=lang).format(price, giftName, giftName)
                GameMsg.sendPrivate(FISH_GAMEID, userId, 0, message)
        else:
            code = 1
            _sendBuyGiftRet(userId, clientId, giftId, code, chestId,
                            commonRewards, chestRewards)
            return
    elif buyType == config.BT_DIAMOND:
        price = giftConf.get("price", 0)
        price, isSucc = store.getUseRebateItemPrice(userId, itemId, price,
                                                    buyType, giftId, clientId)
        code = 0
        if price > 0:
            consumeCount = 0
            if isSucc:
                store.autoConvertVoucherToDiamond(userId, price)
                consumeCount, final = userchip.incrDiamond(
                    userId,
                    FISH_GAMEID,
                    -abs(price),
                    0,
                    "BI_NFISH_BUY_ITEM_CONSUME",
                    int(giftId),
                    util.getClientId(userId),
                    param01=giftId)
            if not isSucc or abs(consumeCount) != price:
                code = 1
                _sendBuyGiftRet(userId, clientId, giftId, code, chestId,
                                commonRewards, chestRewards)
                return
    else:
        code = 0
        # message = u"您购买商品【%s】, 获得%s" % (giftConf["giftName"], giftConf["giftName"])
        message = config.getMultiLangTextConf("ID_BUY_GIFT_RET_BY_DRIECT",
                                              lang=lang).format(
                                                  giftName, giftName)
        GameMsg.sendPrivate(FISH_GAMEID, userId, 0, message)

    # 记录存档
    boughtGift = weakdata.getDayFishData(userId, WeakData.buyFishDailyGift, [])
    boughtGift.append(giftId)
    weakdata.setDayFishData(userId, WeakData.buyFishDailyGift,
                            json.dumps(boughtGift))

    # 记录每日礼包购买次数.
    buyFishDailyGiftTimes = gamedata.getGameAttrJson(
        userId, FISH_GAMEID, GameData.buyFishDailyGiftTimes, {})
    buyFishDailyGiftTimes.setdefault(str(giftId), 0)
    buyFishDailyGiftTimes[str(giftId)] += 1
    gamedata.setGameAttr(userId, FISH_GAMEID, GameData.buyFishDailyGiftTimes,
                         json.dumps(buyFishDailyGiftTimes))

    purchaseData = gamedata.getGameAttrJson(userId, FISH_GAMEID,
                                            GameData.continuousPurchase, {})
    data = purchaseData.get(str(giftId), [0, 0])
    if util.getDayStartTimestamp(
            data[0]) + 24 * 60 * 60 < util.getDayStartTimestamp(
                int(time.time())):
        data[1] = 1
    else:
        data[1] += 1
    data[0] = int(time.time())
    purchaseData[str(giftId)] = data
    gamedata.setGameAttr(userId, FISH_GAMEID, GameData.continuousPurchase,
                         json.dumps(purchaseData))
    # 发奖励
    mail_rewards = []
    giftInfo = giftConf.get("giftInfo", [])
    for gift in giftInfo:
        if gift["day_idx"] == dayIdx:
            for item in gift.get("items", []):
                if util.isChestRewardId(item["itemId"]):  # 宝箱
                    chestId = item["itemId"]
                    rewards = chest_system.getChestRewards(userId, chestId)
                    if buyType == BT_VOUCHER or buyType == config.BT_DIAMOND:
                        code = chest_system.deliveryChestRewards(
                            userId, chestId, rewards, "BI_NFISH_BUY_ITEM_GAIN")
                    else:
                        code = 0
                        gamedata.incrGameAttr(userId, FISH_GAMEID,
                                              GameData.openChestCount, 1)
                        bireport.reportGameEvent("BI_NFISH_GE_CHEST_OPEN",
                                                 userId, FISH_GAMEID, 0, 0,
                                                 int(chestId), 0, 0, 0, [],
                                                 util.getClientId(userId))
                    chestRewards.extend(rewards)
                    mail_rewards.extend([{"name": item["itemId"], "count": 1}])
                else:  # 资产/道具
                    rewards = [{
                        "name": item["itemId"],
                        "count": item["count"]
                    }]
                    if buyType == BT_VOUCHER or buyType == config.BT_DIAMOND:
                        code = util.addRewards(userId,
                                               rewards,
                                               "BI_NFISH_BUY_ITEM_GAIN",
                                               int(giftId),
                                               param01=int(giftId))
                    else:
                        code = 0
                    commonRewards.extend(rewards)
                    mail_rewards.extend(rewards)
            break
    if buyType == BT_VOUCHER or buyType == config.BT_DIAMOND:
        _sendBuyGiftRet(userId, clientId, giftId, code, chestId, commonRewards,
                        chestRewards)
    else:
        message = config.getMultiLangTextConf("ID_DO_BUY_GIFT_MSG",
                                              lang=lang) % giftName
        title = config.getMultiLangTextConf("ID_MAIL_TITLE_DAILY_GIFT",
                                            lang=lang)
        mail_system.sendSystemMail(userId,
                                   mail_system.MailRewardType.SystemReward,
                                   mail_rewards, message, title)
        doSendGift(userId, clientId)
    # 购买礼包事件
    from newfish.game import TGFish
    from newfish.entity.event import GiftBuyEvent
    event = GiftBuyEvent(userId, FISH_GAMEID, giftConf["productId"], buyType,
                         giftId)
    TGFish.getEventBus().publishEvent(event)
    util.addProductBuyEvent(userId, giftConf["productId"], clientId)
예제 #6
0
def buyPiggyBank(userId, clientId, productId, buyType=None, itemId=0):
    """
    购买存钱罐
    """
    code = 3
    rewards = []
    product = config.getPiggyBankProduct(clientId, productId)
    if product is None:
        mo = MsgPack()
        mo.setCmd("piggyBankBuy")
        mo.setResult("gameId", config.FISH_GAMEID)
        mo.setResult("userId", userId)
        mo.setResult("productId", productId)
        mo.setResult("code", code)
        router.sendToUser(mo, userId)
        ftlog.warn("piggy_bank, userId =", userId, "productId =", productId,
                   "buyType =", buyType, "code =", code)
        return
    # if buyType:
    #     if buyType not in product.get("otherBuyType", {}):
    #         return
    # else:
    #     buyType = product.get("buyType")
    type = product.get("type")
    key = UserData.piggyBankData % (FISH_GAMEID, userId)
    piggyBankData = daobase.executeUserCmd(userId, "HGET", key, type)
    dailyMaxTimes = product.get("dailyTimes", 0)
    if piggyBankData:
        piggyBankData = json.loads(piggyBankData)
    else:
        piggyBankData = {}
    ts = int(time.time()) / 60 * 60
    if piggyBankData.get(GameData.pb_enable,
                         0) == 0 and weakdata.getDayFishData(
                             userId, "pb_buyTimes", 0) < dailyMaxTimes:
        isSucc = False
        if buyType in product.get("otherBuyType", {}):
            price = product["otherBuyType"].get(buyType, 0)
            if buyType == config.BT_VOUCHER and price > 0:
                _consume = [{
                    "name": config.VOUCHER_KINDID,
                    "count": abs(price)
                }]
                _ret = util.consumeItems(
                    userId,
                    _consume,
                    "BI_NFISH_BUY_ITEM_CONSUME",
                    pokerconf.productIdToNumber(productId),
                    param01=productId)
                vip_system.addUserVipExp(
                    config.FISH_GAMEID,
                    userId,
                    abs(price) * 10,
                    "BUY_PRODUCT",
                    pokerconf.productIdToNumber(productId),
                    productId,
                    rmbs=abs(price))
                if _ret:
                    isSucc = True
                else:
                    code = 2
            else:
                isSucc = True
        elif buyType == config.BT_DIRECT or config.isThirdBuyType(buyType):
            isSucc = True
        elif buyType == config.BT_DIAMOND:
            price = product.get("price_diamond", 0)
            price, _ret = store.getUseRebateItemPrice(userId, itemId, price,
                                                      buyType, productId,
                                                      clientId)  # 满减券之后的钻石 满减券
            if price > 0:
                consumeCount = 0
                if _ret:
                    store.autoConvertVoucherToDiamond(userId, price)  # 代购券
                    consumeCount, final = userchip.incrDiamond(
                        userId,
                        FISH_GAMEID,
                        -abs(price),
                        0,
                        "BI_NFISH_BUY_ITEM_CONSUME",
                        int(config.DIAMOND_KINDID),
                        util.getClientId(userId),
                        param01=productId)
                if not _ret or abs(consumeCount) != price:
                    code = 2
                else:
                    isSucc = True
        if isSucc:
            piggyBankData[GameData.pb_enable] = 1
            # piggyBankData[GameData.pb_saveMoneyTS] = ts
            piggyBankData[GameData.pb_getMoneyTS] = 0
            # piggyBankData[GameData.pb_moneyCount] = conf.get("initVal", 0)
            pb_buyTimes = weakdata.incrDayFishData(userId, "pb_buyTimes", 1)
            # piggyBankData[GameData.pb_buyTimes] = piggyBankData.get(GameData.pb_buyTimes, 0) + 1
            daobase.executeUserCmd(userId, "HSET", key, type,
                                   json.dumps(piggyBankData))
            code, rewards = getMoney(userId, clientId, productId)

    mo = MsgPack()
    mo.setCmd("piggyBankBuy")
    mo.setResult("gameId", config.FISH_GAMEID)
    mo.setResult("userId", userId)
    mo.setResult("productId", productId)
    mo.setResult("code", code)
    if code == 0:
        util.addProductBuyEvent(userId, productId, clientId)
        mo.setResult("reward", rewards)
    router.sendToUser(mo, userId)
    vipLevel = hallvip.userVipSystem.getVipInfo(userId).get("level", 0)
    ftlog.debug("piggy_bank, userId =", userId, "vip =", vipLevel, "type =",
                type, "code =", code, "piggyBankData =", piggyBankData,
                util.timestampToStr(ts), product)

    getPiggyBankInfo(userId, clientId)
예제 #7
0
파일: hallstore.py 프로젝트: zhaozw/hall37
def exchangeProduct(gameId, userId, clientId, orderId, productId, count):
    product = storeSystem.findProduct(productId)
    if not product:
        raise TYBuyProductUnknownException(productId)

    if product.buyType != 'exchange':
        raise TYProductNotSupportExchangeException(productId)

    timestamp = pktimestamp.getCurrentTimestamp()

    # 限购系统锁定
    periodId = hallstocklimit.productBuyLimitSystem.lockProduct(gameId, userId, productId, count, timestamp)

    # 创建订单
    try:
        storeSystem.buyProduct(gameId, userId, clientId, orderId, productId, count)
    except:
        if periodId:
            hallstocklimit.productBuyLimitSystem.unlockProduct(gameId, userId, periodId, productId,
                                                               count, 1, timestamp)
        raise

    # 
    ftlog.info('hallstore.exchangeProduct gameId=', gameId,
               'userId=', userId,
               'clientId=', clientId,
               'orderId=', orderId,
               'productId=', productId,
               'count=', count)

    try:
        # 消耗兑换的东西
        userAssets = hallitem.itemSystem.loadUserAssets(userId)
        assetTuple = userAssets.consumeAsset(gameId, product.exchangeFeeContentItem.assetKindId,
                                             product.exchangeFeeContentItem.count * count,
                                             timestamp,
                                             'BUY_PRODUCT', pokerconf.productIdToNumber(productId))
        if assetTuple[1] < product.exchangeFeeContentItem.count * count:
            ftlog.warn('hallstore.exchangeProduct gameId=', gameId,
                       'userId=', userId,
                       'clientId=', clientId,
                       'orderId=', orderId,
                       'productId=', productId,
                       'count=', count,
                       'consumedCount=', assetTuple[1],
                       'needConsumeCount=', product.exchangeFeeContentItem.count * count,
                       'err=', 'ConsumeNotEnough')
            msg = strutil.replaceParams(product.exchangeFeeNotEnoughText, {'feeName': assetTuple[0].displayName})
            raise TYProductExchangeNotEnoughException(productId, msg)

        datachangenotify.sendDataChangeNotify(gameId, userId, TYAssetUtils.getChangeDataNames([assetTuple]))
        consumeMap = {assetTuple[0].kindId: assetTuple[1]}
        ret = storeSystem.deliveryOrder(userId, orderId, productId, TYChargeInfo('', {}, consumeMap))

        # 分享提示
        shareId = hallshare.getShareId('exchangeShare', userId, gameId)
        if ftlog.is_debug():
            ftlog.debug('handleExchangeAuditResult shareId: ', shareId)

        share = hallshare.findShare(shareId)
        if share:
            desc = share.getDesc(gameId, userId, True)
            newDesc = strutil.replaceParams(desc, {'exchangeDesc': product.displayName})
            share.setDesc(newDesc)
            task = share.buildTodotask(HALL_GAMEID, userId, 'exchange')
            TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, task)

        if periodId:
            hallstocklimit.productBuyLimitSystem.deliveryProduct(gameId, userId, periodId, productId, count, timestamp)
        return ret
    except:
        if periodId:
            hallstocklimit.productBuyLimitSystem.unlockProduct(gameId, userId, periodId, productId, count, 2, timestamp)
        raise
예제 #8
0
def exchangeProduct(gameId, userId, clientId, orderId, productId, count):
    product = storeSystem.findProduct(productId)
    if not product:
        raise TYBuyProductUnknownException(productId)

    if product.buyType != 'exchange':
        raise TYProductNotSupportExchangeException(productId)

    timestamp = pktimestamp.getCurrentTimestamp()

    # 限购系统锁定
    periodId = hallstocklimit.productBuyLimitSystem.lockProduct(
        gameId, userId, productId, count, timestamp)

    # 创建订单
    try:
        storeSystem.buyProduct(gameId, userId, clientId, orderId, productId,
                               count)
    except:
        if periodId:
            hallstocklimit.productBuyLimitSystem.unlockProduct(
                gameId, userId, periodId, productId, count, 1, timestamp)
        raise

    #
    ftlog.info('hallstore.exchangeProduct gameId=', gameId, 'userId=', userId,
               'clientId=', clientId, 'orderId=', orderId, 'productId=',
               productId, 'count=', count)

    try:
        # 消耗兑换的东西
        userAssets = hallitem.itemSystem.loadUserAssets(userId)
        assetTuple = userAssets.consumeAsset(
            gameId, product.exchangeFeeContentItem.assetKindId,
            product.exchangeFeeContentItem.count * count, timestamp,
            'BUY_PRODUCT', pokerconf.productIdToNumber(productId))
        if assetTuple[1] < product.exchangeFeeContentItem.count * count:
            ftlog.warn('hallstore.exchangeProduct gameId=', gameId, 'userId=',
                       userId, 'clientId=', clientId, 'orderId=', orderId,
                       'productId=', productId, 'count=', count,
                       'consumedCount=', assetTuple[1], 'needConsumeCount=',
                       product.exchangeFeeContentItem.count * count, 'err=',
                       'ConsumeNotEnough')
            msg = strutil.replaceParams(product.exchangeFeeNotEnoughText,
                                        {'feeName': assetTuple[0].displayName})
            raise TYProductExchangeNotEnoughException(productId, msg)

        datachangenotify.sendDataChangeNotify(
            gameId, userId, TYAssetUtils.getChangeDataNames([assetTuple]))
        consumeMap = {assetTuple[0].kindId: assetTuple[1]}
        ret = storeSystem.deliveryOrder(userId, orderId, productId,
                                        TYChargeInfo('', {}, consumeMap))

        # 分享提示
        shareId = hallshare.getShareId('exchangeShare', userId, gameId)
        if ftlog.is_debug():
            ftlog.debug('handleExchangeAuditResult shareId: ', shareId)

        share = hallshare.findShare(shareId)
        if share:
            desc = share.getDesc(gameId, userId, True)
            newDesc = strutil.replaceParams(
                desc, {'exchangeDesc': product.displayName})
            share.setDesc(newDesc)
            task = share.buildTodotask(HALL_GAMEID, userId, 'exchange')
            TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, task)

        if periodId:
            hallstocklimit.productBuyLimitSystem.deliveryProduct(
                gameId, userId, periodId, productId, count, timestamp)
        return ret
    except:
        if periodId:
            hallstocklimit.productBuyLimitSystem.unlockProduct(
                gameId, userId, periodId, productId, count, 2, timestamp)
        raise
예제 #9
0
def doBuyLevelFunds(userId, clientId, buyType, productId, rebateItemId=0):
    """
    购买成长基金
    """
    # 根据商品Id确定游戏模式.
    mode = config.CLASSIC_MODE
    for _m in [config.CLASSIC_MODE, config.MULTIPLE_MODE]:
        fundsConf = config.getLevelFundsConf(clientId, _m)
        for val in fundsConf.get("funds"):
            if val.get("productId") == productId:
                mode = _m
                break
    fundsConf = config.getLevelFundsConf(clientId, mode)
    funds = fundsConf.get("funds")
    productConf = None
    canBuyIdxs = fundsConf.get("canBuyIdx")
    for val in funds:
        if val.get("idx") in canBuyIdxs and val.get("productId") == productId:
            productConf = val
            break
    if not productConf:
        sendBuyLevelFundsRet(userId, clientId, productId, 0, 5, mode)
        return
    buyType = buyType or productConf.get("buyType")
    lf_funds = daobase.executeUserCmd(userId, "HGET", _getRdKey(userId, mode), GameData.lf_funds) or "[]"
    lf_funds = json.loads(lf_funds)
    lf_types = [val.get("type") for val in funds if val.get("idx") in lf_funds]
    if productConf.get("idx") in lf_funds or productConf.get("type") in lf_types:       # 重复购买同一商品或是同一类型的商品.
        sendBuyLevelFundsRet(userId, clientId, productId, 0, 6, mode)
        return
    lang = util.getLanguage(userId, clientId)
    productName = config.getMultiLangTextConf(productConf["name"], lang=lang)
    if buyType == BT_DIRECT or config.isThirdBuyType(buyType):                          # 直充购买或者三方渠道支付
        message = config.getMultiLangTextConf("ID_BUY_GIFT_RET_BY_DRIECT", lang=lang).format(productName, productName)
        GameMsg.sendPrivate(FISH_GAMEID, userId, 0, message)
        code = 0
    else:
        # 使用代购券购买
        if productConf.get("otherBuyType", {}).get(buyType):
            price = productConf.get("otherBuyType", {}).get(buyType)
            if buyType == BT_VOUCHER:
                _consume = [{"name": VOUCHER_KINDID, "count": abs(price)}]
                _ret = util.consumeItems(userId, _consume, "BI_NFISH_BUY_ITEM_CONSUME", param01=productId)
                if not _ret:
                    code = 2
                else:
                    vip_system.addUserVipExp(FISH_GAMEID, userId, abs(price) * 10, "BUY_PRODUCT", pokerconf.productIdToNumber(productId), productId, rmbs=abs(price))
                    message = config.getMultiLangTextConf("ID_BUY_GIFT_RET_BY_VOUCHER", lang=lang).format(price, productName, productName)
                    GameMsg.sendPrivate(FISH_GAMEID, userId, 0, message)
                    code = 0
            else:
                code = 3
        # 使用钻石购买
        elif buyType == config.BT_DIAMOND:                                              # 钻石购买
            price = productConf["price_diamond"]
            price, isSucc = store.getUseRebateItemPrice(userId, rebateItemId, price, buyType, productId, clientId)
            # 不能出现使用满减券后不需要花钱的情况!!!
            if price > 0 and isSucc:
                store.autoConvertVoucherToDiamond(userId, price)                        # 钻石足够优先使用钻石、在使用代购券
                consumeCount, final = userchip.incrDiamond(userId, FISH_GAMEID, -abs(price), 0, "BI_NFISH_BUY_LEVEL_FUNDS_CONSUME", int(config.DIAMOND_KINDID), clientId, param01=productId)
                if abs(consumeCount) != price:
                    code = 4
                else:
                    code = 0
            else:
                code = 5
        else:
            code = 6
    if code == 0:
        util.addProductBuyEvent(userId, productId, clientId)
        lf_funds.append(productConf.get("idx"))
        daobase.executeUserCmd(userId, "HSET", _getRdKey(userId, mode), GameData.lf_funds, json.dumps(lf_funds))
    sendBuyLevelFundsRet(userId, clientId, productId, productConf.get("idx"), code, mode)