Exemplo n.º 1
0
    def doGetPrize(cls, gameId, userId, clientId, action):
        '''
        新用户领奖接口
        '''
        conf = hallconf.getNeiTuiGuangConf(clientId)
        if not conf:
            ftlog.error('neituiguang doGetUserState conf not found gameId=',
                        gameId, 'userId=', userId, 'clientId=', clientId,
                        'action=', action)
            return
        mo = MsgPack()
        bindmobile = userdata.getAttr(userId, 'bindMobile')
        userstate = gamedata.getGameAttr(userId, gameId, cls.attrname_state)
        if cls.bindOk(bindmobile):
            prizeGet = cls.sendBothUserPrize(gameId, userId, userstate, conf)

            if prizeGet == -1:  # 用户状态错误
                NeiTuiGuangProtocolBuilder.buildBasicInfo(
                    2, action, "用户状态错误", mo)
            else:  # 发送奖励成功
                NeiTuiGuangProtocolBuilder.buildBasicInfo(
                    0, action, cls.getprize(gameId, 0, conf, prizeGet), mo)
        else:  # 未绑定手机
            NeiTuiGuangProtocolBuilder.buildBasicInfo(
                1, action, cls.getprize(gameId, 2, conf), mo)

        return mo
Exemplo n.º 2
0
    def doOldUserGetPrize(cls, gameId, userId, friendId, clientId, action):
        '''
        老用户领奖接口
        '''
        conf = hallconf.getNeiTuiGuangConf(clientId)
        if not conf:
            ftlog.error('neituiguang doGetUserState conf not found gameId=',
                        gameId, 'userId=', userId, 'clientId=', clientId,
                        'action=', action)
            return

        mo = MsgPack()
        mpush = None
        userstate = gamedata.getGameAttr(userId, gameId, cls.attrname_state)
        bindmobile = userdata.getAttr(userId, 'bindMobile')
        if userstate == 2:
            if cls.bindOk(bindmobile):
                prizeGet = cls.sendOldUserPrize(userId, friendId, gameId, conf)
                NeiTuiGuangProtocolBuilder.buildOldUserPrize(
                    0, action, cls.getprize(gameId, 0, prizeGet), friendId, mo)
                ##### 推一条用户奖励信息
                mpush = cls.doQueryPrize(gameId, userId, clientId, action)
            else:
                NeiTuiGuangProtocolBuilder.buildBindPrize(
                    1, action, cls.getprize(gameId, 2), friendId, mo)
        else:
            NeiTuiGuangProtocolBuilder.buildBasicInfo(
                2, action, 'user state error: not support', mo)

        return mo, mpush
Exemplo n.º 3
0
    def doOldUserGetPrize(cls, gameId, userId, friendId, clientId, action):
        '''
        老用户领奖接口
        '''
        conf = hallconf.getNeiTuiGuangConf(clientId)
        if not conf:
            ftlog.error('neituiguang doGetUserState conf not found gameId=', gameId, 'userId=', userId, 'clientId=',
                        clientId, 'action=', action)
            return

        mo = MsgPack()
        mpush = None
        userstate = gamedata.getGameAttr(userId, gameId, cls.attrname_state)
        bindmobile = userdata.getAttr(userId, 'bindMobile')
        if userstate == 2:
            if cls.bindOk(bindmobile):
                prizeGet = cls.sendOldUserPrize(userId, friendId, gameId, conf)
                NeiTuiGuangProtocolBuilder.buildOldUserPrize(0, action, cls.getprize(gameId, 0, prizeGet), friendId, mo)
                ##### 推一条用户奖励信息
                mpush = cls.doQueryPrize(gameId, userId, clientId, action)
            else:
                NeiTuiGuangProtocolBuilder.buildBindPrize(1, action, cls.getprize(gameId, 2), friendId, mo)
        else:
            NeiTuiGuangProtocolBuilder.buildBasicInfo(2, action, 'user state error: not support', mo)

        return mo, mpush
Exemplo n.º 4
0
 def doPromoteCodeCheck(cls, gameId, userId, clientId, action, promoteCode):
     '''
     验证兑换码ID,有效则获取用户手机绑定信息,若绑定手机,则发送奖励,并更新用户状态。若未绑定手机,则更新用户状态,返回未绑定手机code
     '''
     conf = hallconf.getNeiTuiGuangConf(clientId)
     if not conf:
         ftlog.error('neituiguang doGetUserState conf not found gameId=', gameId, 'userId=', userId, 'clientId=',
                     clientId, 'action=', action)
         return
     mo = MsgPack()
     userstate = gamedata.getGameAttr(userId, gameId, cls.attrname_state)
     if userstate == 2:
         NeiTuiGuangProtocolBuilder.buildBasicInfo(0, action, '已经领奖成功', mo)
     else:
         promoteCode = cls.intPromoteCode(promoteCode)
         if promoteCode == -1 or userId == promoteCode:
             NeiTuiGuangProtocolBuilder.buildBasicInfo(1, action, cls.getprize(gameId, 1, conf), mo)
         else:
             userdata.checkUserData(promoteCode)
             createTime = userdata.getAttr(promoteCode, 'createTime')
             if createTime == None:
                 NeiTuiGuangProtocolBuilder.buildBasicInfo(1, action, cls.getprize(gameId, 1, conf), mo)
             else:
                 olduser = cls.isOldUser(promoteCode, gameId, createTime, conf)
                 if not olduser:
                     NeiTuiGuangProtocolBuilder.buildBasicInfo(1, action, cls.getprize(gameId, 1, conf), mo)
                 else:
                     gamedata.setGameAttr(userId, gameId, cls.attrname_promotecode, promoteCode)  # 记录兑换码
                     gamedata.setGameAttr(userId, gameId, cls.attrname_state, 1)  # 已输入兑换码
                     bindmobile = userdata.getAttr(userId, 'bindMobile')
                     if cls.bindOk(bindmobile):
                         NeiTuiGuangProtocolBuilder.buildBasicInfo(0, action, '验证成功', mo)
                     else:
                         NeiTuiGuangProtocolBuilder.buildBasicInfo(2, action, cls.getprize(gameId, 2, conf), mo)
         return mo
Exemplo n.º 5
0
 def doQueryPrize(cls, gameId, userId, clientId, action):
     conf = hallconf.getNeiTuiGuangConf(clientId)
     if not conf:
         ftlog.error('neituiguang doQueryPrize conf not found gameId=', gameId, 'userId=', userId, 'clientId=',
                     clientId, 'action=', action)
         return
     mo = MsgPack()
     prize = conf.get('prize', {})
     getedPrize = cls.getUserSuccPrize(gameId, userId)
     prizeAvailable = cls.getUserFailPrize(gameId, userId)
     friends = cls.getFriendList(gameId, userId, clientId, prize)
     NeiTuiGuangProtocolBuilder.buildQueryPrize(action, getedPrize, prizeAvailable, friends, mo)
     return mo
Exemplo n.º 6
0
 def doQueryPrize(cls, gameId, userId, clientId, action):
     conf = hallconf.getNeiTuiGuangConf(clientId)
     if not conf:
         ftlog.error('neituiguang doQueryPrize conf not found gameId=',
                     gameId, 'userId=', userId, 'clientId=', clientId,
                     'action=', action)
         return
     mo = MsgPack()
     prize = conf.get('prize', {})
     getedPrize = cls.getUserSuccPrize(gameId, userId)
     prizeAvailable = cls.getUserFailPrize(gameId, userId)
     friends = cls.getFriendList(gameId, userId, clientId, prize)
     NeiTuiGuangProtocolBuilder.buildQueryPrize(action, getedPrize,
                                                prizeAvailable, friends, mo)
     return mo
Exemplo n.º 7
0
    def doGetUserState(cls, gameId, userId, clientId, action):
        '''
        获取用户信息,不存在则,验证用户状态,写入用户活动状态表,并返回用户状态
        '''
        conf = hallconf.getNeiTuiGuangConf(clientId)
        mo = MsgPack()
        if not conf:
            ftlog.error('neituiguang doGetUserState conf not found gameId=',
                        gameId, 'userId=', userId, 'clientId=', clientId,
                        'action=', action)
            return mo
        state = gamedata.getGameAttr(userId, gameId, cls.attrname_state)
        createTime = userdata.getAttr(userId, 'createTime')
        if state == None:
            state = cls.initUserState(userId, gameId, createTime, conf)
            userdata.setAttr(userId, cls.attrname_state, state)
            inviteetip = cls.inviteeTip(userId, gameId, createTime, conf)
        else:
            if cls.isOldUser(userId, gameId, createTime, conf):
                state = 2
                userdata.setAttr(userId, cls.attrname_state, state)  # 老用户状态

        if state == 0:
            NeiTuiGuangProtocolBuilder.buildNewUserState(
                gameId, userId, action, state, inviteetip, mo)
        elif state == 1:
            bindmobile = userdata.getAttr(userId, 'bindMobile')
            bindok = cls.bindOk(bindmobile)
            NeiTuiGuangProtocolBuilder.buildBindUserState(
                gameId, userId, action, state, bindok, mo)
        elif state == 2:
            bindmobile = userdata.getAttr(userId, 'bindMobile')
            bindok = cls.bindOk(bindmobile)
            shareId = conf.get('shareId', -1)
            prizeinfo = conf.get('prize_info', [])
            weixintip = cls.getWeiXinTip(userId, conf)
            url = cls.getDownUrl(userId, conf)
            smstip = cls.getSMSTip(gameId, userId, conf)
            rules = conf.get('rules', [])
            NeiTuiGuangProtocolBuilder.buildOldUserState(
                gameId, userId, action, state, bindok, shareId, prizeinfo,
                weixintip, url, smstip, rules, mo)
        else:
            pass

        return mo
Exemplo n.º 8
0
 def doPromoteCodeCheck(cls, gameId, userId, clientId, action, promoteCode):
     '''
     验证兑换码ID,有效则获取用户手机绑定信息,若绑定手机,则发送奖励,并更新用户状态。若未绑定手机,则更新用户状态,返回未绑定手机code
     '''
     conf = hallconf.getNeiTuiGuangConf(clientId)
     if not conf:
         ftlog.error('neituiguang doGetUserState conf not found gameId=',
                     gameId, 'userId=', userId, 'clientId=', clientId,
                     'action=', action)
         return
     mo = MsgPack()
     userstate = gamedata.getGameAttr(userId, gameId, cls.attrname_state)
     if userstate == 2:
         NeiTuiGuangProtocolBuilder.buildBasicInfo(0, action, '已经领奖成功', mo)
     else:
         promoteCode = cls.intPromoteCode(promoteCode)
         if promoteCode == -1 or userId == promoteCode:
             NeiTuiGuangProtocolBuilder.buildBasicInfo(
                 1, action, cls.getprize(gameId, 1, conf), mo)
         else:
             userdata.checkUserData(promoteCode)
             createTime = userdata.getAttr(promoteCode, 'createTime')
             if createTime == None:
                 NeiTuiGuangProtocolBuilder.buildBasicInfo(
                     1, action, cls.getprize(gameId, 1, conf), mo)
             else:
                 olduser = cls.isOldUser(promoteCode, gameId, createTime,
                                         conf)
                 if not olduser:
                     NeiTuiGuangProtocolBuilder.buildBasicInfo(
                         1, action, cls.getprize(gameId, 1, conf), mo)
                 else:
                     gamedata.setGameAttr(userId, gameId,
                                          cls.attrname_promotecode,
                                          promoteCode)  # 记录兑换码
                     gamedata.setGameAttr(userId, gameId,
                                          cls.attrname_state, 1)  # 已输入兑换码
                     bindmobile = userdata.getAttr(userId, 'bindMobile')
                     if cls.bindOk(bindmobile):
                         NeiTuiGuangProtocolBuilder.buildBasicInfo(
                             0, action, '验证成功', mo)
                     else:
                         NeiTuiGuangProtocolBuilder.buildBasicInfo(
                             2, action, cls.getprize(gameId, 2, conf), mo)
         return mo
Exemplo n.º 9
0
    def doGetUserState(cls, gameId, userId, clientId, action):
        '''
        获取用户信息,不存在则,验证用户状态,写入用户活动状态表,并返回用户状态
        '''
        conf = hallconf.getNeiTuiGuangConf(clientId)
        mo = MsgPack()
        if not conf:
            ftlog.error('neituiguang doGetUserState conf not found gameId=', gameId, 'userId=', userId, 'clientId=',
                        clientId, 'action=', action)
            return mo
        state = gamedata.getGameAttr(userId, gameId, cls.attrname_state)
        createTime = userdata.getAttr(userId, 'createTime')
        if state == None:
            state = cls.initUserState(userId, gameId, createTime, conf)
            userdata.setAttr(userId, cls.attrname_state, state)
            inviteetip = cls.inviteeTip(userId, gameId, createTime, conf)
        else:
            if cls.isOldUser(userId, gameId, createTime, conf):
                state = 2
                userdata.setAttr(userId, cls.attrname_state, state)  # 老用户状态

        if state == 0:
            NeiTuiGuangProtocolBuilder.buildNewUserState(gameId, userId, action, state, inviteetip, mo)
        elif state == 1:
            bindmobile = userdata.getAttr(userId, 'bindMobile')
            bindok = cls.bindOk(bindmobile)
            NeiTuiGuangProtocolBuilder.buildBindUserState(gameId, userId, action, state, bindok, mo)
        elif state == 2:
            bindmobile = userdata.getAttr(userId, 'bindMobile')
            bindok = cls.bindOk(bindmobile)
            shareId = conf.get('shareId', -1)
            prizeinfo = conf.get('prize_info', [])
            weixintip = cls.getWeiXinTip(userId, conf)
            url = cls.getDownUrl(userId, conf)
            smstip = cls.getSMSTip(gameId, userId, conf)
            rules = conf.get('rules', [])
            NeiTuiGuangProtocolBuilder.buildOldUserState(gameId, userId, action, state, bindok, shareId, prizeinfo,
                                                         weixintip, url, smstip, rules, mo)
        else:
            pass

        return mo
Exemplo n.º 10
0
    def doGetPrize(cls, gameId, userId, clientId, action):
        '''
        新用户领奖接口
        '''
        conf = hallconf.getNeiTuiGuangConf(clientId)
        if not conf:
            ftlog.error('neituiguang doGetUserState conf not found gameId=', gameId, 'userId=', userId, 'clientId=',
                        clientId, 'action=', action)
            return
        mo = MsgPack()
        bindmobile = userdata.getAttr(userId, 'bindMobile')
        userstate = gamedata.getGameAttr(userId, gameId, cls.attrname_state)
        if cls.bindOk(bindmobile):
            prizeGet = cls.sendBothUserPrize(gameId, userId, userstate, conf)

            if prizeGet == -1:  # 用户状态错误
                NeiTuiGuangProtocolBuilder.buildBasicInfo(2, action, "用户状态错误", mo)
            else:  # 发送奖励成功
                NeiTuiGuangProtocolBuilder.buildBasicInfo(0, action, cls.getprize(gameId, 0, conf, prizeGet), mo)
        else:  # 未绑定手机
            NeiTuiGuangProtocolBuilder.buildBasicInfo(1, action, cls.getprize(gameId, 2, conf), mo)

        return mo