示例#1
0
 def doCancelCodeCheck(self, gameId, userId, clientId):
     '''
     取消code_check
     '''
     try:
         timestamp = pktimestamp.getCurrentTimestamp()
         status = neituiguang.loadStatus(userId, timestamp)
         neituiguang.setInviter(status, 0)
         ftlog.hinfo('neituiguang.statics eventId=',
                     'CANCEL_INPUT_PRMOTE_CODE', 'userId=', userId,
                     'clientId=', clientId, 'result=', 'ok')
         mo = MsgPack()
         mo.setCmd('promote_info')
         mo.setResult('action', 'cancel_code_check')
         mo.setResult('code', 0)
         router.sendToUser(mo, userId)
     except Exception, e:
         if not isinstance(e, TYBizException):
             ftlog.error()
         ec, info = (e.errorCode, e.message) if isinstance(
             e, TYBizException) else (-1, '系统错误')
         ftlog.hinfo('neituiguang.statics eventId=',
                     'CANCEL_INPUT_PRMOTE_CODE', 'userId=', userId,
                     'clientId=', clientId, 'result=', 'failed')
         router.sendToUser(
             self.makeErrorResponse('cancel_code_check', ec, info), userId)
示例#2
0
 def doCancelCodeCheck(self, gameId, userId, clientId):
     '''
     取消code_check
     '''
     try:
         timestamp = pktimestamp.getCurrentTimestamp()
         status = neituiguang.loadStatus(userId, timestamp)
         neituiguang.setInviter(status, 0)
         ftlog.hinfo('neituiguang.statics eventId=', 'CANCEL_INPUT_PRMOTE_CODE',
                     'userId=', userId,
                     'clientId=', clientId,
                     'result=', 'ok')
         mo = MsgPack()
         mo.setCmd('promote_info')
         mo.setResult('action', 'cancel_code_check')
         mo.setResult('code', 0)
         router.sendToUser(mo, userId)
     except Exception, e:
         if not isinstance(e, TYBizException):
             ftlog.error()
         ec, info = (e.errorCode, e.message) if isinstance(e, TYBizException) else (-1, '系统错误')
         ftlog.hinfo('neituiguang.statics eventId=', 'CANCEL_INPUT_PRMOTE_CODE',
                     'userId=', userId,
                     'clientId=', clientId,
                     'result=', 'failed')
         router.sendToUser(self.makeErrorResponse('cancel_code_check', ec, info), userId)
示例#3
0
    def doCheckCode(self, gameId, userId, clientId, promoteCode):
        '''
        确立推广关系,也就是领取红包
        校验通过
        设置推荐人
        将用户加到推荐人的推广员名单里
        '''
        try:
            timestamp = pktimestamp.getCurrentTimestamp()
            status = neituiguang.loadStatus(userId, timestamp)

            # 检查是否能成为推荐人
            # 转到promoteCode所在的UT进程中去处理
            ec, info = neituiguang_remote.canBeInviter(promoteCode, userId)
            if ec != 0:
                raise NeituiguangException(ec, info)

            # 设置推荐人
            neituiguang.setInviter(status, promoteCode)

            try:
                # 添加invitee,此处不需要处理失败的情况,前面已经检查了
                ec, info = neituiguang_remote.addInvitee(
                    promoteCode, userId, status.isBindMobile)
                if ec != 0:
                    ftlog.warn('NeiTuiGuangTcpHandler.doCheckCode gameId=',
                               gameId, 'userId=', userId, 'clientId=',
                               clientId, 'promoteCode=', promoteCode, 'call=',
                               'neituiguang_remote.addInvitee', 'ec=', ec,
                               'info=', info)
            except:
                ftlog.error('NeiTuiGuangTcpHandler.doCheckCode gameId=',
                            gameId, 'userId=', userId, 'clientId=', clientId,
                            'promoteCode=', promoteCode, 'call=',
                            'neituiguang_remote.addInvitee', 'ec=', ec,
                            'info=', info)

            ftlog.hinfo('neituiguang.statics eventId=', 'INPUT_PRMOTE_CODE',
                        'userId=', userId, 'clientId=', clientId,
                        'promoteCode=', promoteCode, 'result=', 'ok')
            mo = MsgPack()
            mo.setCmd('promote_info')
            mo.setResult('action', 'code_check')
            mo.setResult('code', 0)
            router.sendToUser(mo, userId)
        except Exception, e:
            if not isinstance(e, TYBizException):
                ftlog.error()
            ec, info = (e.errorCode, e.message) if isinstance(
                e, TYBizException) else (-1, '系统错误')
            ftlog.hinfo('neituiguang.statics eventId=', 'INPUT_PRMOTE_CODE',
                        'userId=', userId, 'clientId=', clientId,
                        'promoteCode=', promoteCode, 'result=', 'failed',
                        'ec=', ec, 'info=', info)
            router.sendToUser(self.makeErrorResponse('code_check', ec, info),
                              userId)
示例#4
0
def set_inviter(userId, inviter):
    """
    @param userId:
    @param inviter:
    @return: 设置userId的上线为inviter
    """
    try:
        timestamp = pktimestamp.getCurrentTimestamp()
        status = neituiguang.loadStatus(userId, timestamp)

        # 检查是否能成为推荐人
        # 转到promoteCode所在的UT进程中去处理
        ec, info = canBeInviter(inviter, userId)
        if ec != 0:
            raise NeituiguangException(ec, info)

        # 设置推荐人
        neituiguang.setInviter(status, inviter)
        # 添加invitee,此处不需要处理失败的情况,前面已经检查了
        return addInvitee(inviter, userId, status.isBindMobile)
    except NeituiguangException, e:
        return e.errorCode, e.message
示例#5
0
def set_inviter(userId, inviter):
    """
    @param userId:
    @param inviter:
    @return: 设置userId的上线为inviter
    """
    try:
        timestamp = pktimestamp.getCurrentTimestamp()
        status = neituiguang.loadStatus(userId, timestamp)

        # 检查是否能成为推荐人
        # 转到promoteCode所在的UT进程中去处理
        ec, info = canBeInviter(inviter, userId)
        if ec != 0:
            raise NeituiguangException(ec, info)

        # 设置推荐人
        neituiguang.setInviter(status, inviter)
        # 添加invitee,此处不需要处理失败的情况,前面已经检查了
        return addInvitee(inviter, userId, status.isBindMobile)
    except NeituiguangException, e:
        return e.errorCode, e.message
示例#6
0
    def doCheckCode(self, gameId, userId, clientId, promoteCode):
        '''
        确立推广关系,也就是领取红包
        校验通过
        设置推荐人
        将用户加到推荐人的推广员名单里
        '''
        try:
            timestamp = pktimestamp.getCurrentTimestamp()
            status = neituiguang.loadStatus(userId, timestamp)

            # 检查是否能成为推荐人
            # 转到promoteCode所在的UT进程中去处理
            ec, info = neituiguang_remote.canBeInviter(promoteCode, userId)
            if ec != 0:
                raise NeituiguangException(ec, info)

            # 设置推荐人
            neituiguang.setInviter(status, promoteCode)

            try:
                # 添加invitee,此处不需要处理失败的情况,前面已经检查了
                ec, info = neituiguang_remote.addInvitee(promoteCode, userId, status.isBindMobile)
                if ec != 0:
                    ftlog.warn('NeiTuiGuangTcpHandler.doCheckCode gameId=', gameId,
                               'userId=', userId,
                               'clientId=', clientId,
                               'promoteCode=', promoteCode,
                               'call=', 'neituiguang_remote.addInvitee',
                               'ec=', ec,
                               'info=', info)
            except:
                ftlog.error('NeiTuiGuangTcpHandler.doCheckCode gameId=', gameId,
                            'userId=', userId,
                            'clientId=', clientId,
                            'promoteCode=', promoteCode,
                            'call=', 'neituiguang_remote.addInvitee',
                            'ec=', ec,
                            'info=', info)

            ftlog.hinfo('neituiguang.statics eventId=', 'INPUT_PRMOTE_CODE',
                        'userId=', userId,
                        'clientId=', clientId,
                        'promoteCode=', promoteCode,
                        'result=', 'ok')
            mo = MsgPack()
            mo.setCmd('promote_info')
            mo.setResult('action', 'code_check')
            mo.setResult('code', 0)
            router.sendToUser(mo, userId)
        except Exception, e:
            if not isinstance(e, TYBizException):
                ftlog.error()
            ec, info = (e.errorCode, e.message) if isinstance(e, TYBizException) else (-1, '系统错误')
            ftlog.hinfo('neituiguang.statics eventId=', 'INPUT_PRMOTE_CODE',
                        'userId=', userId,
                        'clientId=', clientId,
                        'promoteCode=', promoteCode,
                        'result=', 'failed',
                        'ec=', ec,
                        'info=', info)
            router.sendToUser(self.makeErrorResponse('code_check', ec, info), userId)