Пример #1
0
def getMatchHistoryCount(bigRoomId):
    #比赛开过的局数取定值
    historyCount = {
        "6605": 730,
        "6601": 16060,
        "6604": 14600,
        "6615": 15330,
        "6602": 2190,
        "6607": 730,
        "6608": 730,
        "6609": 730,
        "6610": 730,
        "6611": 730,
        "6612": 730,
        "6613": 730,
        "6998": 730
    }

    matchHistory = daobase.executeDizhuCmd('HGET', 'matchHistoryCount:6',
                                           bigRoomId)
    if not matchHistory:
        matchHistory = historyCount.get(str(bigRoomId), 1)
        daobase.executeDizhuCmd('HSET', 'matchHistoryCount:6', bigRoomId,
                                matchHistory)
    return matchHistory
Пример #2
0
 def clearPublisheFlagByIssueNumber(cls, poolId, issueNumber):
     ''' 
     清除红包发布的标记,在发送失败时调用,以便重新发布 
     '''
     if ftlog.is_debug():
         ftlog.debug('LuckyMoneyOperator.clearPublisheFlagByIssueNumber',
                     'poolId=', poolId, 'issueNumber=', issueNumber)
     rpath = LuckyMoneyOperator.buildPublishFlagKey(poolId)
     daobase.executeDizhuCmd('HDEL', rpath, issueNumber)
Пример #3
0
 def clearLuckyMoneys(cls, poolId):
     '''
     清空数据库中的红包数据
     @param poolId: 红包池key,用于区分不同红包池
     '''
     if ftlog.is_debug():
         ftlog.debug('LuckyMoneyOperator.clearLuckyMoneys', 'poolId=',
                     poolId)
     rpath = LuckyMoneyOperator.buildPoolKey(poolId)
     daobase.executeDizhuCmd('LTRIM', rpath, -1, 0)
Пример #4
0
 def updateResult(cls, activityGameId, activityId, issueNumber,
                  resultState):
     ''' 根据期号更新活动竞猜结果 '''
     if resultState != cls.RESULT_STATE_NONE and \
         resultState != cls.RESULT_STATE_LEFT and \
         resultState !=  cls.RESULT_STATE_RIGHT:
         return False
     rpath = cls.getRedisStoragePath(activityGameId, activityId,
                                     issueNumber)
     daobase.executeDizhuCmd('hset', rpath, 'resultState', resultState)
     return True
Пример #5
0
 def incrChip(self, isLeft, chip):
     ''' 奖池增加金币, 区分左右奖池 '''
     rpath = self.getRedisStoragePath(self.activityGameId, self.activityId,
                                      self.issueNumber)
     if isLeft:
         self.countChipLeft = daobase.executeDizhuCmd(
             'hincrby', rpath, 'countChipLeft', chip)
     else:
         self.countChipRight = daobase.executeDizhuCmd(
             'hincrby', rpath, 'countChipRight', chip)
     return self
Пример #6
0
def delMatchLotteryInfo(userId, matchId):
    jstr = daobase.executeRePlayCmd('hget', 'match:discount:6:', userId)

    match_discount = strutil.loads(jstr) if jstr else []
    for index in range(len(match_discount)):
        if match_discount[index]['matchId'] == matchId:
            del match_discount[index]
            daobase.executeDizhuCmd('hdel', 'match:discount:6', userId)
            daobase.executeDizhuCmd('hset', 'match:discount:6', userId, strutil.dumps(match_discount))
            break
    ftlog.debug('delMatchLotteryInfo userId=', userId, 'jstr=', match_discount)
    return match_discount
Пример #7
0
    def saveLedText(cls, text):
        """
        在地主插件中保存10条led数据 用于展示
        :param text:  要保存的led文本
        :return: 
        """
        jstr = strutil.dumps(text)
        daobase.executeDizhuCmd('lpush', 'dizhu:Led:6', jstr)
        daobase.executeDizhuCmd('ltrim', 'dizhu:Led:6', 0,
                                9)  #max TEXT count is 10

        if ftlog.is_debug():
            ftlog.debug('LedUtil.saveLed text=', text, 'jstr=', jstr)
Пример #8
0
 def getLuckyMoneyNumbers(cls, poolId):
     '''
     获取剩余红包个数
     @param poolId: 红包池key,用于区分不同红包池
     '''
     rpath = LuckyMoneyOperator.buildPoolKey(poolId)
     return daobase.executeDizhuCmd('LLEN', rpath)
Пример #9
0
 def gainLuckyMoney(cls, poolId):
     '''
     领取一个红包
     @param poolId: 红包池key,用于区分不同红包池
     '''
     rpath = LuckyMoneyOperator.buildPoolKey(poolId)
     js = daobase.executeDizhuCmd('RPOP', rpath)
     if js:
         return strutil.loads(js)
     return None
Пример #10
0
 def publishLuckyMoneys(cls, poolId, prizeList):
     '''
     将红包数据发布到数据库中
     @param poolId: 红包池key,用于区分不同红包池
     '''
     if ftlog.is_debug():
         ftlog.debug('LuckyMoneyOperator.publishLuckyMoneys', 'poolId=',
                     poolId, 'prizeList.count', len(prizeList))
     try:
         rpath = LuckyMoneyOperator.buildPoolKey(poolId)
         # 分批加入到数据库中
         step = 50
         for i in range(0, len(prizeList), step):
             seg = prizeList[i:i + step]
             jslist = map(lambda v: strutil.dumps(v), seg)
             daobase.executeDizhuCmd('LPUSH', rpath, *jslist)
         return True
     except:
         ftlog.error('LuckyMoneyOperator.publishLuckyMoneys')
         return False
Пример #11
0
    def loadModel(cls, activityGameId, activityId, issueNumber):
        ''' 加载数据,返回新的数据模型 '''
        rpath = cls.getRedisStoragePath(activityGameId, activityId,
                                        issueNumber)
        value1, value2, value3 = daobase.executeDizhuCmd(
            'hmget', rpath, 'countChipLeft', 'countChipRight', 'resultState')

        model = ActivityModel(activityGameId, activityId, issueNumber)
        model.countChipLeft = value1 or 0
        model.countChipRight = value2 or 0
        model.resultState = value3 or cls.RESULT_STATE_NONE
        return model
Пример #12
0
 def setPublisheFlagByIssueNumber(cls, poolId, issueNumber):
     ''' 
     设置红包发布的标记,若成功返回True才可以发布红包,否则代表已经发布
     '''
     rpath = LuckyMoneyOperator.buildPublishFlagKey(poolId)
     isNotPublished = daobase.executeDizhuCmd('HINCRBY', rpath, issueNumber,
                                              1) == 1
     if ftlog.is_debug():
         ftlog.debug('LuckyMoneyOperator.setPublisheFlagByIssueNumber',
                     'poolId=', poolId, 'issueNumber=', issueNumber,
                     'isNotPublished=', isNotPublished)
     return isNotPublished
Пример #13
0
 def getUsers(cls, activityGameId, activityId, issueNumber):
     ''' 获得指定活动期号的所有参与用户userId '''
     rpath = cls.getRedisStoragePath(activityGameId, activityId,
                                     issueNumber)
     return daobase.executeDizhuCmd('smembers', rpath)
Пример #14
0
 def addUser(cls, userId, activityGameId, activityId, issueNumber):
     ''' 记录用户ID '''
     rpath = cls.getRedisStoragePath(activityGameId, activityId,
                                     issueNumber)
     daobase.executeDizhuCmd('sadd', rpath, userId)
Пример #15
0
def addMatchHistoryCount(bigRoomId, rank):
    if rank == 1:
        daobase.executeDizhuCmd('hincrby', 'matchHistoryCount:6', bigRoomId, 1)
Пример #16
0
 def getLedText(cls):
     jstr = daobase.executeDizhuCmd('lrange', 'dizhu:Led:6', 0, -1)
     return strutil.loads(jstr)