示例#1
0
def sendLoginReward(HallPluginDay1st, userId, gameId, clientId):
    # _DB_KEY_GAME_TEMPLATE_GCSC = 'game5:%s:%s:tc'  # 各个游戏的业务模板数据,由console进行自动生成
    # confKey = _DB_KEY_GAME_TEMPLATE_GCSC % (gameId, 'loginreward')
    # conf = _config3._getCacheGameData(confKey, None, None, None)
    conf = HallPluginDay1st.configLoginreward.getTcConfig()
    debug('hall_login_reward.sendLoginReward userId:', userId, ' gameId:',
          gameId, ' clientId:', clientId, ' conf : ', conf)
    supplement = conf.get('supplement', None)
    if supplement != None:
        changed = []
        userAssets = itemsys.itemSystem.loadUserAssets(userId)
        items = supplement["items"]
        for item in items:
            maxCount = item["count"]
            itemId = item["itemId"]
            balance = userAssets.balance(itemId, fttime.getCurrentTimestamp())
            if (maxCount - balance) > 0:

                assetKind, _addCount, _final = userAssets.addAsset(
                    gameId, itemId, maxCount - balance,
                    fttime.getCurrentTimestamp(), 'LOGIN_REWARD', 0)
                if assetKind.keyForChangeNotify:
                    changed.append(assetKind.keyForChangeNotify)

        pluginCross.halldatanotify.sendDataChangeNotify(
            userId, tyglobal.gameId(), changed)
示例#2
0
def test2():
    tstring = "2018-03-16 14:36:43.636448"
    print tstring
    td = fttime.parseTimeMs(tstring)
    print td
    print fttime.datetime2TimestampFloat(td)
    print fttime.getCurrentTimestamp()

    print datetime_to_timestamp(strtime_to_datetime(tstring))
示例#3
0
def testRoomInfo():
    roomInfo = MatchRoomInfo()
    roomInfo.roomId = 6666
    roomInfo.playerCount = 5
    roomInfo.signinCount = 10
    roomInfo.startType = 1
    roomInfo.instId = 1001
    roomInfo.startTime = fttime.getCurrentTimestamp()
    roomInfo.signinTime = fttime.getCurrentTimestamp()
    # saveRoomInfo(6,roomInfo)
    removeRoomInfo(6, 6666)
示例#4
0
    def checkUserOrderListLimit(self, userId):
        dataLen = DaoUserOrderList.HLEN(userId)
        if dataLen <= DaoUserOrderList.MAX_DATA_LENGTH:
            return

        # 超过最大数量限制时,删除历史数据
        orderIds = DaoUserOrderList.HKEYS(userId)
        historys = []
        for orderId in orderIds:
            datas = DaoUserOrderList.HGET(userId, orderId)
            datas.append(orderId)
            historys.append(datas)

        # 按时间排序, 7天以上的或已完结的记录优先删除
        historys.sort(key=lambda x: x[0], reverse=True)
        ct = fttime.getCurrentTimestamp() - 7 * 24 * 60 * 60  # 7 天前的时间点
        for x in xrange(DaoUserOrderList.MAX_DATA_LENGTH, len(historys)):
            isTimeOut = historys[x][0] <= ct
            isFinished = historys[x][5] not in (TYOrder.STATE_CREATE,
                                                TYOrder.STATE_DELIVERYING)
            if isTimeOut or isFinished:
                orderId = historys[x][-1]
                order = DaoGameOrder.HGETALL(0, orderId)
                ftlog.info('AUTO CLEANUP STORE ORDER->', userId, orderId,
                           ftstr.dumps(order))
                DaoUserOrderList.HDEL(userId, orderId)
                DaoGameOrder.DEL(0, orderId)
示例#5
0
def _safeAddGames(userId, intClientId, gameIds, location):
    """
    安全添加用户自定义数据.
    客户端传来的添加项,校验实际存在后再入库.
    """
    # TODO 和 _filterGameNodes 合并
    if _DEBUG:
        debug('_tygamelist5._addSafeGames IN->', userId, intClientId, gameIds)
    nodes = _getExtendGames(userId, intClientId, location)
    now = fttime.getCurrentTimestamp()
    idx = 0
    for info in nodes:
        nodeId = info.get("id", "")
        if nodeId in gameIds:
            # 节点数据真实存在才进行添加
            _dao.addUserGameListNode(userId, now + idx,
                                     nodeId)  # 制造一点时间差形成先后顺序
            idx += 1
            gameIds.remove(nodeId)

    if len(gameIds) > 0:
        # 不安全的输入数据,记录下来
        ftlog.warn(
            '_tygamemanager._addSafeGames, the node not found ! userId=',
            userId, 'clientId=', intClientId, 'gameIds=', gameIds, 'nodes',
            nodes)
    return 1
示例#6
0
 def _gdssListUserItem(self, userId):
     userBag = itemsys.itemSystem.loadUserAssets(userId).getUserBag()
     items = []
     timestamp = fttime.getCurrentTimestamp()
     for item in userBag.getAllItem():
         items.append(self._encodeItem(userBag, item, timestamp))
     return items
示例#7
0
    def buyProduct(self, gameId, realGameId, userId, clientId, orderId, productId, count):
        product = self.findProduct(productId)
        if not product:
            return None, '没有该商品'

        timestamp = fttime.getCurrentTimestamp()
        order = TYOrder(orderId,
                        '',
                        userId,
                        gameId,
                        realGameId,
                        productId,
                        count,
                        clientId,
                        timestamp,
                        timestamp,
                        TYOrder.STATE_CREATE,
                        0,
                        None)
        order.product = product
        self._orderDao.addOrder(order)
        ftlog.info('HallStoreSystem.buyProduct gameId=', gameId,
                   'realGameId=', realGameId,
                   'userId=', userId,
                   'clientId=', clientId,
                   'orderId=', orderId,
                   'productId=', productId,
                   'count=', count)
        return order, 'ok'
示例#8
0
 def _finishDelivery(self, order, errorCode):
     order.errorCode = errorCode
     order.state = TYOrder.STATE_DELIVERY
     order.updateTime = fttime.getCurrentTimestamp()
     error, oldState = self._orderDao.updateOrder(order, TYOrder.STATE_DELIVERYING)
     if error != 0:
         ftlog.info('HallStoreSystem._finishDelivery orderId=', order.orderId,
                    'platformOrderId=', order.platformOrderId,
                    'userId=', order.userId,
                    'gameId=', order.gameId,
                    'productId', order.productId,
                    'count=', order.count,
                    'chargeInfo=', order.chargeInfo,
                    'errorCode=', order.errorCode,
                    'oldState=', oldState)
     else:
         ftlog.info('HallStoreSystem._finishDelivery orderId=', order.orderId,
                    'platformOrderId=', order.platformOrderId,
                    'userId=', order.userId,
                    'gameId=', order.gameId,
                    'productId', order.productId,
                    'count=', order.count,
                    'chargeInfo=', order.chargeInfo,
                    'errorCode=', order.errorCode)
     return error, oldState
示例#9
0
文件: item.py 项目: zhaozw/freetime5
 def addAsset(self,
              userId,
              gameId,
              assetKindId,
              count,
              eventId,
              intEventParam,
              param01='',
              param02='',
              **kwargs):
     '''
     添加资产
     '''
     try:
         userAssets = itemsys.itemSystem.loadUserAssets(userId)
         assetKind, addCount, final = userAssets.addAsset(
             gameId,
             assetKindId,
             count,
             fttime.getCurrentTimestamp(),
             eventId,
             intEventParam,
             param01=param01,
             param02=param02)
         if addCount > 0 and assetKind.keyForChangeNotify:
             pluginCross.halldatanotify.sendDataChangeNotify(
                 userId, gameId, assetKind.keyForChangeNotify)
         return assetKind.kindId, addCount, final
     except:
         ftlog.error('hallitemrpc.addAsset gameId=', gameId, 'userId=',
                     userId, 'assetKindId=', assetKindId, 'count=', count,
                     'eventId=', eventId, 'intEventParam=', intEventParam)
         return 0, 0, 0
示例#10
0
    def _checkTaskStatus(self, userTask):
        newStatus = -1
        if _DEBUG:
            debug('HallTaskKindDialy._checkTaskStatus->',
                  userTask.userTaskUnit.userId, userTask.taskId,
                  userTask.kindId)
        if userTask.status == tytask.TYUserTask.STATUS_GOTREWARD:
            # 如果已经领取,那么判定是否需要进行重置任务
            if _DEBUG:
                debug('HallTaskKindDialy._checkTaskStatus->',
                      userTask.userTaskUnit.userId, userTask.taskId,
                      userTask.kindId, 'totalLimit=',
                      userTask.taskKind.totalLimit, 'finishCount=',
                      userTask.finishCount)
            if userTask.taskKind.totalLimit <= 0 or userTask.taskKind.totalLimit > userTask.finishCount:
                # 再最大次数内进行状态转换
                isToday = fttime.is_same_day(userTask.updateTime,
                                             fttime.getCurrentTimestamp())
                if _DEBUG:
                    debug('HallTaskKindDialy._checkTaskStatus->',
                          userTask.userTaskUnit.userId, userTask.taskId,
                          userTask.kindId, 'isToday=', isToday)
                if not isToday:
                    # 最后更新为 领取 时间,已经跨天,重置任务 (并且要在最大次数以内)
                    newStatus = tytask.TYUserTask.STATUS_NORMAL
                    userTask.progress = 0

        if newStatus != -1 and newStatus != userTask.status:
            # 状态发生改变,更新任务
            userTask.status = newStatus
            userTask.userTaskUnit.updateTask(userTask)
示例#11
0
def _canEnterGame(userId, gameId):
    """是否可进入游戏"""
    gameTime = gamedata.getGameAttrInt(userId, gameId, 'createTableTime')
    nowTime = fttime.getCurrentTimestamp()
    ftlog.debug('Majiang2 game_handler _canEnterGame gameTime:', gameTime,
                ' nowTime:', nowTime)
    return (nowTime - gameTime) >= 5
示例#12
0
 def create_friend(self, user_id, target_user_id):
     debug("create_friend: ", user_id, target_user_id)
     now = fttime.getCurrentTimestamp()
     info = {"time": now, "last_msg": "hi", "remark": ""}
     self.friend_dao.create_friend(user_id, target_user_id,
                                   ftstr.dumps(info))
     system_chat(user_id, target_user_id, 2)
示例#13
0
def _addGames(userId, gameIds):
    if _DEBUG:
        debug('_tygamelist5.addGames IN->', userId, gameIds)

    now = fttime.getCurrentTimestamp()
    for idx, node in enumerate(gameIds):
        _dao.addUserGameListNode(userId, now + idx, node)  # 制造一点时间差形成先后顺序
    return 1
示例#14
0
文件: item.py 项目: zhaozw/freetime5
 def removeUserItem(self, userId, gameId, itemId, eventId, intEventParam):
     userBag = itemsys.itemSystem.loadUserAssets(userId).getUserBag()
     item = userBag.findItem(itemId)
     if not item:
         return -1, '道具不存在: %s' % itemId
     timestamp = fttime.getCurrentTimestamp()
     userBag.removeItem(gameId, item, timestamp, eventId, intEventParam)
     pluginCross.halldatanotify.sendDataChangeNotify(userId, gameId, 'item')
     return 0, ""
示例#15
0
 def calcNextStartTime(self, timestamp=None):
     timestamp = timestamp or fttime.getCurrentTimestamp()
     ntime = datetime.fromtimestamp(int(timestamp))
     nexttime = None
     if self._cron:
         nexttime = self._cron.getNextTime(ntime)
     if nexttime is not None:
         return int(time.mktime(nexttime.timetuple()))
     return None
示例#16
0
    def finishOrder(self, orderId, userId, finishState):
        order = self._loadOrder(orderId)
        if not order:
            ftlog.error('HallStoreSystem.finishOrder userId=', userId,
                        'orderId=', orderId,
                        'err=', 'OrderNotFound')
            return '没有找到该订单'

        if order.userId != userId:
            ftlog.error('HallStoreSystem.finishOrder userId=', userId,
                        'orderId=', orderId,
                        'productId=', order.productId,
                        'chargeInfo=', order.chargeInfo,
                        'orderUserId=', order.userId,
                        'orderProductId=', order.productId,
                        'realGameId=', order.realGameId,
                        'err=', 'DiffUser')
            return '订单用户不匹配'

        if order.state == TYOrder.STATE_DELIVERY:
            # 有可能是直购金币的单子,已经投递完毕后的,再次砖石变化通知
            ftlog.info('HallStoreSystem.finishOrder orderId=', order.orderId,
                       'platformOrderId=', order.platformOrderId,
                       'userId=', order.userId,
                       'gameId=', order.gameId,
                       'productId', order.productId,
                       'count=', order.count,
                       'chargeInfo=', order.chargeInfo,
                       'errorCode=', order.errorCode,
                       'chip product already deliver ok')
            return 'ok'

        order.state = finishState
        order.updateTime = fttime.getCurrentTimestamp()
        error, oldState = self._orderDao.updateOrder(order, TYOrder.STATE_CREATE)
        if error != 0:
            ftlog.info('HallStoreSystem.finishOrder orderId=', order.orderId,
                       'platformOrderId=', order.platformOrderId,
                       'userId=', order.userId,
                       'gameId=', order.gameId,
                       'productId', order.productId,
                       'count=', order.count,
                       'chargeInfo=', order.chargeInfo,
                       'errorCode=', order.errorCode,
                       'oldState=', oldState)
            return '变更订单状态错误'
        else:
            ftlog.info('HallStoreSystem.finishOrder orderId=', order.orderId,
                       'platformOrderId=', order.platformOrderId,
                       'userId=', order.userId,
                       'gameId=', order.gameId,
                       'productId', order.productId,
                       'count=', order.count,
                       'chargeInfo=', order.chargeInfo,
                       'errorCode=', order.errorCode)
            return 'ok'
示例#17
0
def _initUserBag(gameId, userId, clientId, userBag):
    initItems = _getInitItemsByClientId(clientId) or []
    timestamp = fttime.getCurrentTimestamp()
    for itemKind, count in initItems:
        userBag.addItemUnitsByKind(gameId, itemKind, count, timestamp, 0,
                                   'USER_CREATE', 0)
    ftlog.info('hallitem._initUserBag addItemUnitsByKind gameId=', gameId,
               'userId=', userId, 'initItems=',
               [(k.kindId, c) for k, c in initItems])
    return userBag
示例#18
0
def doGameTimestemp(userId):
    if _DEBUG:
        debug('doGameTimestemp->', userId)
    mo = MsgPack()
    mo.setCmd('user')
    mo.setResult('action', 'mj_timestamp')
    mo.setResult('gameId', tyglobal.gameId())
    mo.setResult('userId', userId)
    mo.setResult('current_ts', fttime.getCurrentTimestamp())
    tyrpcconn.sendToUser(userId, mo)
示例#19
0
 def _resetHallItemRed(cls, userId, kindGameId=0):
     timestamp = fttime.getCurrentTimestamp()
     userBag = itemsys.itemSystem.loadUserAssets(userId).getUserBag()
     itemList = userBag.getAllItem()
     itemIds = []
     for item in itemList:
         if kindGameId == 0 or item.itemKind.gameId == kindGameId:
             if item.itemKind.visibleInBag and item.visibleInBag(timestamp):
                 itemIds.append(item.itemId)
     # 刷新小红点数据
     pluginSafeCross.hallredpoint.resetItemIds(userId, 'item5', itemIds)
示例#20
0
文件: item.py 项目: zhaozw/freetime5
 def addAllItem(self, userId, gameId, eventId, intEventParam=0):
     userBag = itemsys.itemSystem.loadUserAssets(userId).getUserBag()
     timestamp = fttime.getCurrentTimestamp()
     userBag._isSendToUser = False
     try:
         for itemKind in itemsys.itemSystem.getAllItemKind():
             userBag.addItemUnitsByKind(gameId, itemKind, 1, timestamp, 0,
                                        eventId, intEventParam)
     finally:
         userBag._isSendToUser = True
     pluginCross.halldatanotify.sendDataChangeNotify(userId, gameId, 'item')
     return True
示例#21
0
def _onUserLogin(gameId, userId, clientId, isCreate, isDayfirst):
    if _DEBUG:
        debug('item.onUserLogin->', gameId, userId, clientId, isCreate,
              isDayfirst)
    timestamp = fttime.getCurrentTimestamp()
    userAssets = itemsys.itemSystem.loadUserAssets(userId)
    userBag = userAssets.getUserBag()
    if isCreate:
        _initUserBag(gameId, userId, clientId, userBag)
    userBag.processWhenUserLogin(gameId, clientId, isDayfirst, timestamp)

    ItemHelper.resetHallItemRed(userId)
示例#22
0
文件: item.py 项目: zhaozw/freetime5
 def removeAllItem(self, userId, gameId, eventId, intEventParam=0):
     userBag = itemsys.itemSystem.loadUserAssets(userId).getUserBag()
     timestamp = fttime.getCurrentTimestamp()
     userBag._isSendToUser = False
     try:
         for item in userBag.getAllItem():
             userBag.removeItem(gameId, item, timestamp, eventId,
                                intEventParam)
     finally:
         userBag._isSendToUser = True
     pluginCross.halldatanotify.sendDataChangeNotify(userId, gameId, 'item')
     return True
示例#23
0
 def doHttpUserItemAction(self, request):
     mo = MsgPack()
     mi = self.checkHttpDoAction.check(request)
     if mi.error:
         mo.setError(1, mi.error)
     else:
         params = request.getDict()
         result = hallRpcOne.hallitem.doActionByItemId(
             mi.userId, mi.gameId, mi.itemId, mi.action,
             fttime.getCurrentTimestamp(), params).getResult()
         mo.setKey('result', result)
     return mo
示例#24
0
 def do_follow_launch(self, user_id, target_user_id, hello, origin=""):
     # userId|targetUserId|(hello,origin)
     now = fttime.getCurrentTimestamp()
     info = {
         "time": now,
         "hello": hello,
         "sponsor": user_id,
         "origin": origin,
         "status": self.ST_FOLLOW
     }
     # 存库 --> 判断目标用户是否在线 -->推送消息到目标用户 -->返回结果
     self.follow_dao.do_follow_launch(user_id, target_user_id, info)
     system_chat(user_id, target_user_id, 1)
示例#25
0
def createNewTable(userId_A, userId_B):
    for roomId, roomIns in tyglobal.rooms().items():
        if _DEBUG:
            debug("In createNewTable @@@@ roomId = ", roomId, " roomIns = ",
                  roomIns, " userId_A = ", userId_A, " userId_B = ", userId_B)
        global tableId
        if not roomIns.maptable:
            baseid = roomId * 10000 + 1
            tableId = baseid
        if tableId >= roomId * 10000 + 9999:
            tableId = roomId * 10000 + 1
        tableId += 1
        tblIns = TYTable(roomIns, tableId)
        roomIns.maptable[tableId] = tblIns
        table_Info = {}
        for userId in [userId_A, userId_B]:
            name, purl, sex, addr, citycode = _rpc_user_info.getUserBaseInfo(
                userId)
            table_Info[userId] = (name, purl, sex, addr, citycode)

        tblIns.playersInfo = table_Info

        time_seed = fttime.getCurrentTimestamp()

        mo = MsgPack()
        mo.setCmd('start_game')
        mo.setResult('gameId', tyglobal.gameId())
        mo.setResult('roomId', tblIns.roomId)
        mo.setResult('tableId', tblIns.tableId)
        mo.setResult('seatId', 1)
        mo.setResult('time_seed', time_seed)
        mo.setResult('table_info', table_Info)
        if _DEBUG:
            debug("OUT createNewTable  @@@ table_info = ", table_Info)
        tyrpcconn.sendToUser(userId_A, mo)

        mo = MsgPack()
        mo.setCmd('start_game')
        mo.setResult('gameId', tyglobal.gameId())
        mo.setResult('roomId', tblIns.roomId)
        mo.setResult('tableId', tblIns.tableId)
        mo.setResult('seatId', 2)
        mo.setResult('time_seed', time_seed)
        mo.setResult('table_info', table_Info)
        if _DEBUG:
            debug("OUT createNewTable  @@@ table_info = ", table_Info)
        tyrpcconn.sendToUser(userId_B, mo)
        break
示例#26
0
文件: item.py 项目: zhaozw/freetime5
 def getAssets(self, userId, assetKindIds):
     """
     获取资产数量
     :param userId: 用户id
     :param assetKindIds: 财富id 或者 财富id的序列
     :return:
     """
     userAssets = itemsys.itemSystem.loadUserAssets(userId)
     timestamp = fttime.getCurrentTimestamp()
     if isinstance(assetKindIds, (str, unicode)):
         return userAssets.balance(assetKindIds, timestamp)
     elif isinstance(assetKindIds, (list, tuple, set)):
         ret = {}
         for assetKindId in assetKindIds:
             ret[assetKindId] = userAssets.balance(assetKindId, timestamp)
         return ret
示例#27
0
文件: item.py 项目: zhaozw/freetime5
 def addAssets(self, userId, gameId, contentItems, eventId, intEventParam,
               **kwargs):
     '''
     添加一组资产
     '''
     try:
         contentItems = self._decodeContentItems(contentItems)
         assetList = self.sendContentItemList(gameId, userId, contentItems,
                                              1, True,
                                              fttime.getCurrentTimestamp(),
                                              eventId, intEventParam,
                                              **kwargs)
         return [(assetKind.kindId, addCount, final)
                 for (assetKind, addCount, final) in assetList]
     except:
         ftlog.error()
示例#28
0
 def _setProgress(self, userId, taskId, progress):
     userTaskUnit = self._loadUserTaskUnitCache(userId, None)
     if userTaskUnit:
         task = userTaskUnit.findTaskByTaskId(taskId)
         if task:
             timestamp = fttime.getCurrentTimestamp()
             if progress >= task.taskKind.progressMax or progress < 0:
                 progress = task.taskKind.progressMax
             task.setProgress(progress, timestamp)
             userTaskUnit.updateTask(task)
             userTaskUnit.taskUnit._onTaskUpdated(task)
             if task.status == tytask.TYUserTask.STATUS_FINISHED:
                 userTaskUnit.taskUnit._onTaskFinished(task, timestamp)
             self._checkUserTasksAfterEvent(userTaskUnit)
             userTaskUnit.flushDao()
     return 'ok'
示例#29
0
    def doActionGdssCallBack(userId, record, result):
        if _DEBUG:
            debug('doActionGdssCallBack->', userId, record, result,
                  record.params)

        from tuyoo5.plugins.item import itemsys
        userAssets = itemsys.itemSystem.loadUserAssets(userId)
        if not userAssets:
            return -1, 'ExchangeItem userAssets error, userId=%s' % (userId)
        userBag = userAssets.getUserBag()
        if not userBag:
            return -2, 'ExchangeItem userBag error, userId=%s' % (userId)
        item = userBag.findItem(int(record.params['itemId']))
        if not item:
            return -3, 'ExchangeItem userItem error, userId=%s' % (userId)

        timestamp = fttime.getCurrentTimestamp()
        if item.state == TYExchangeItem.STATE_AUDIT:
            if result == 1:  # 审核被拒绝,无需返还奖券
                userBag.removeItem(HALL_GAMEID, item, timestamp,
                                   'EXCHANGE5_REDUCE_ITEM', item.kindId)
            elif result == 2:  # 审核被拒绝,需要返还奖券
                item.state = TYExchangeItem.STATE_NORMAL
                userBag.updateItem(item, timestamp)
            elif result == 3:  # 审核通过,等待发货
                item.state = TYExchangeItem.STATE_SHIPPING
                userBag.updateItem(item, timestamp)
            else:
                return -4, 'ExchangeItem.state ErrorAudit state=%s result=%s' % (
                    item.state, result)
        elif item.state == TYExchangeItem.STATE_SHIPPING:
            if result == 0:  # 发货成功
                userBag.removeItem(HALL_GAMEID, item, timestamp,
                                   'EXCHANGE5_REDUCE_ITEM', item.kindId)
            elif result == 4:  # 发货失败,无需返回奖券
                userBag.removeItem(HALL_GAMEID, item, timestamp,
                                   'EXCHANGE5_REDUCE_ITEM', item.kindId)
            elif result == 5:  # 发货失败,需要返回奖券
                item.state = TYExchangeItem.STATE_NORMAL
                userBag.updateItem(item, timestamp)
            else:
                return -5, 'ExchangeItem.state ErrorAccept state=%s result=%s' % (
                    item.state, result)
        else:
            return -6, 'ExchangeItem.state Error state=%s result=%s' % (
                item.state, result)
        return 0, 'ok'
示例#30
0
def _checkIfNeedAddNewTask(userTaskUnit):
    '''
    检查配置中有,而用户身上没有的task,并添加
    '''
    if userTaskUnit:
        taskKindPool = userTaskUnit.taskKindPool
        # 检查配置中没有有的,而用户身有的task,并删除
        delIds = []
        # 增加对小红点检测
        unreadTaskIds = []
        readTaskIds = []
        for taskId in userTaskUnit.taskIdMap:
            if not taskId in taskKindPool.taskIdList:
                delIds.append(taskId)

        for taskId in delIds:
            userTaskUnit.removeTask(userTaskUnit.taskIdMap[taskId])

        # 检查配置中有,而用户身上没有的task,并添加
        timestamp = 0
        for taskId in taskKindPool.taskIdList:
            if not userTaskUnit.findTaskByTaskId(taskId):
                taskKind = userTaskUnit.taskUnit.findTaskKindByTaskId(taskId)
                if not taskKind or taskKind.deprecated == 1:  # 不推荐或过时的任务不进行分配
                    continue
                if timestamp <= 0:
                    timestamp = fttime.getCurrentTimestamp()
                userTask = taskKind.newTask(taskId)
                userTaskUnit.addTask(userTask)

                # 检测红点设置情况
                task = userTaskUnit.findTaskByTaskId(taskId)
                task.taskKind._checkTaskStatus(task)
                # 检测对已经完成任务的小红点的显示
                if task.status == TYUserTask.STATUS_FINISHED:
                    unreadTaskIds.append(taskId)
                else:
                    readTaskIds.append(taskId)
        # 初始化的任务默认已读,后续有变化才添加红点
        # if len(readTaskIds) > 0:
        #     pluginSafeCross.hallredpoint.resetItemIds(userTaskUnit.userId, 'happybag5', readTaskIds, 0)
        # 对小红点的状态做设置: 1 未读  0 已读
        if len(unreadTaskIds) > 0:
            pluginSafeCross.hallredpoint.resetItemIds(userTaskUnit.userId,
                                                      'happybag5',
                                                      unreadTaskIds, 1)
    return userTaskUnit