Пример #1
0
    def doSetUserNickName(cls, rparams, mo, needReturn=True):
        TyContext.ftlog.info(cls.__name__, 'doSetUserNickName->rparams=',
                             rparams, 'needReturn=', needReturn)
        userId = rparams.get('userId', 0)
        if userId <= 0:
            return

        nickname = rparams.get('name', '')
        sex = str(rparams.get('sex', ''))
        datas = []

        TyContext.ftlog.debug('nickname=[', nickname, ']')
        if len(nickname) > 0:
            newNameIs360Default = Account360.isDefault360Username(nickname)
            if newNameIs360Default:
                oldname = TyContext.RedisUser.execute(userId, 'HGET',
                                                      'user:'******'name')
                TyContext.ftlog.debug('nickname=[', nickname, '] oldname=[',
                                      oldname, '] sex=[', sex, ']')
                if not oldname or Account360.isDefault360Username(oldname):
                    if sex not in ('0', '1'):
                        sex = TyContext.RedisUser.execute(
                            userId, 'HGET', 'user:'******'sex')
                        TyContext.ftlog.debug('nickname=[', nickname,
                                              '] oldname=[', oldname,
                                              '] oldsex=[', sex, ']')
                    nickname = UsernameGenerator.getInstance().generate(sex)
                    # 设定
                else:
                    # 保持原名字
                    nickname = None
            else:
                # 设定
                pass

            if nickname != None:
                datas.append('name')
                datas.append(nickname)
                # 修改昵称次数
                if needReturn:
                    TyContext.RedisUser.execute(userId, 'HINCRBY',
                                                'user:'******'set_name_sum', 1)
        if len(datas) > 0:
            TyContext.RedisUser.execute(userId, 'HMSET', 'user:' + str(userId),
                                        *datas)

        if needReturn:
            cls.__set_user_info_return__(rparams, mo)
Пример #2
0
    def doSetUserInfo(cls, rparams, mo, needReturn=True):
        TyContext.ftlog.info(cls.__name__, 'doSetUserInfo->rparams=', rparams,
                             'needReturn=', needReturn)
        userId = rparams.get('userId', 0)
        if userId <= 0:
            return

        nickname = rparams.get('name', '')
        sex = str(rparams.get('sex', ''))
        headurl = rparams.get('headurl', '')
        address = rparams.get('address', '')
        idcardno = rparams.get('idcardno', '')
        truename = rparams.get('truename', '')
        phonenumber = rparams.get('phonenumber', '')
        lang = rparams.get('lang', None)
        country = rparams.get('country', None)
        signature = rparams.get('signature', None)
        agreeAddFriend = rparams.get('agreeAddFriend', None)
        email = rparams.get('email', None)

        datas = []

        if len(address) > 0:
            datas.append('address')
            datas.append(address)

        if len(idcardno) > 0:
            datas.append('idcardno')
            datas.append(idcardno)

        if len(truename) > 0:
            datas.append('truename')
            datas.append(truename)

        if len(phonenumber) > 0:
            datas.append('phonenumber')
            datas.append(phonenumber)

        if lang != None:
            datas.append('lang')
            datas.append(lang)

        if country != None:
            datas.append('country')
            datas.append(country)

        if signature != None:
            datas.append('signature')
            datas.append(TyContext.KeywordFilter.replace(signature))

        if agreeAddFriend != None:
            if agreeAddFriend == '0' or agreeAddFriend == '1':
                datas.append('agreeAddFriend')
                datas.append(int(agreeAddFriend))

        if email != None:
            datas.append('email')
            datas.append(email)

        if len(sex) > 0 and sex in ('0', '1'):
            datas.append('sex')
            datas.append(sex)
            oldSex = TyContext.RedisUser.execute(userId, 'HGET',
                                                 'user:'******'sex')
            if oldSex == None:
                oldSex = sex
            if int(oldSex) != int(sex):
                BeautyCertifyService.onUserSexChanged(userId, oldSex, sex)

        TyContext.ftlog.debug('nickname=[', nickname, ']')

        if nickname == "LikaiAndZengxinxin" and TyContext.TYGlobal.corporation(
        ) == "pineapple":
            pass
        elif len(nickname) > 0:
            newNameIs360Default = Account360.isDefault360Username(nickname)
            if newNameIs360Default:
                oldname = TyContext.RedisUser.execute(userId, 'HGET',
                                                      'user:'******'name')
                TyContext.ftlog.debug('nickname=[', nickname, '] oldname=[',
                                      oldname, '] sex=[', sex, ']')
                if not oldname or Account360.isDefault360Username(oldname):
                    if sex not in ('0', '1'):
                        sex = TyContext.RedisUser.execute(
                            userId, 'HGET', 'user:'******'sex')
                        TyContext.ftlog.debug('nickname=[', nickname,
                                              '] oldname=[', oldname,
                                              '] oldsex=[', sex, ']')
                    nickname = UsernameGenerator.getInstance().generate(sex)
                    # 设定
                else:
                    # 保持原名字
                    nickname = None
            else:
                # 设定
                pass

            if nickname != None:
                # 需要根据不同的游戏ID做屏蔽是否不再允许再次更改.(appId 1-19)appId 为 12和15仍可以通过此接口修改名称(大菠萝,海外德州)
                appId = int(rparams.get('appId', '0'))
                accessAppId = [1, 2, 3, 4, 5, 6, 7, 8, 12, 15]  # h5mod
                if appId in accessAppId:
                    datas.append('name')
                    datas.append(nickname)
                    # 修改昵称次数
                    if needReturn:
                        setTimes = TyContext.RedisUser.execute(
                            userId, 'HINCRBY', 'user:'******'set_name_sum', 1)
                        if TyContext.TYGlobal.corporation() == "pineapple":
                            if setTimes > 1:
                                mo.setResult('code', 1)
                                return
        if len(headurl) > 0:
            UserPhotoService.setUserPhoto(userId, UserPhoto.PHOTO_TYPE_AVATAR,
                                          headurl)

        TyContext.ftlog.debug('datas', datas, userId)
        if len(datas) > 0:
            TyContext.RedisUser.execute(userId, 'HMSET', 'user:'******'clientSystem', '')
            oldname = TyContext.RedisUser.execute(userId, 'HGET',
                                                  'user:'******'name')
            newname = rparams.get('name', '')
            if clientSystem == 'Winpc' and oldname != newname:
                mo.setResult('code', 2)
                mo.setError(2, '老板,昵称不能随意修改哦。')
                TyContext.ftlog.debug(cls.__name__, 'doSetUserInfo->mo', mo)
            else:
                cls.__set_user_info_return__(rparams, mo)
Пример #3
0
    def createNewUser(cls, params, userType, setDevMap=True):
        TyContext.ftlog.info(cls.__name__, 'createNewUser start: userType=',
                             userType, 'params=', params)
        appId = cls.__get_param__(params, 'appId')
        deviceId = cls.__get_param__(params, 'deviceId')
        mail = cls.__get_param__(params, 'email')
        snsId = cls.__get_param__(params, 'snsId')
        userAccount = cls.__get_param__(params, 'userAccount')
        mobile = str(cls.__get_param__(params, 'mobile'))
        clientId = cls.__get_param__(params, 'clientId')

        if clientId.startswith('robot'):
            uid = TyContext.RedisMix.execute('INCR', 'global.robotid')
            if uid > 9999:
                TyContext.ftlog.error('ERROR toomuch robot users !!!!')
                uid = 0
            uid = str(uid)
        else:
            fromip = TyContext.RunHttp.get_client_ip()
            if cls._is_networkip_restricted(clientId, fromip):
                return -1
            if cls._is_clientip_restricted(clientId, fromip):
                TyContext.ftlog.info('createNewUser clientid', clientId, 'ip',
                                     fromip, 'restricted')
                return -1

            uid = str(TyContext.RedisMix.execute('INCR', 'global.userid'))
        if int(uid) <= 0:
            #            TyContext.BiReport.report_bi_sdk_login(
            #                AccountConst.CREATE_FAIL_EVENTIDS[userType], 0, appId, clientId,
            #                ['', mail, snsId, mobile][userType],
            #                AccountConst.CODE_USER_NEW_UID_ERROR, devId=deviceId)
            return 0

        datas = {
            'password': cls.__get_param__(params, 'passwd'),
            'mdevid': deviceId,
            'isbind': 1 if userType else 0,
            'snsId': snsId,
            'name': cls.__get_param__(params, ['name', 'deviceName']),
            'source': cls.__get_param__(params, 'source'),
            'purl': cls.__get_param__(params, 'purl'),
            'address': cls.__get_param__(params, 'address'),
            'sex': cls.__get_param__(params, 'sex', '0'),
            'state': 0,
            'payCount': 0,
            'snsinfo': cls.__get_param__(params, 'snsinfo'),
            'vip': 0,
            'dayang': 0,
            'idcardno': cls.__get_param__(params, 'idcardno'),
            'phonenumber': cls.__get_param__(params, 'phonenumber'),
            'truename': cls.__get_param__(params, 'truename'),
            'detect_phonenumber': cls.__get_param__(params,
                                                    'detect_phonenumber'),
            'email': mail,
            'createTime':
            datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f'),
            'userAccount': userAccount,
            'clientId': clientId,
            'appId': appId,
            'bindMobile': mobile,
            'mac': cls.__get_param__(params, 'mac'),
            'idfa': cls.__get_param__(params, 'idfa'),
            'imei': cls.__get_param__(params, 'imei'),
            'imsi': cls.__get_param__(params, 'imsi', ''),
            'androidId': cls.__get_param__(params, 'androidId'),
            'uuid': cls.__get_param__(params, 'uuid'),
            'userId': uid,
            'sendMeGift': 1,
            "lang": cls.__get_param__(params, 'lang'),
            "country": "",
            "signature": "",
            "agreeAddFriend": 1,
            "email": "",
        }
        if datas['sex'] == '':
            datas['sex'] = '0'

        if datas['purl'] == '':
            datas['purl'] = UserPhotoService.getDefaultUserAvatar(
                int(uid), clientId)

        is_winpc = cls.__get_param__(params, 'clientSystem').lower() == 'winpc'
        name = datas['name']
        if not name or Account360.isDefault360Username(name) or is_winpc:
            genUsername = UsernameGenerator.getInstance().generate(
                datas['sex'])
            if genUsername:
                datas['name'] = genUsername

        # 设置用户数据
        udkv = []
        for k, v in datas.items():
            udkv.append(k)
            udkv.append(v)
        #         TyContext.ftlog.debug('createNewUser->values=', udkv)
        TyContext.RedisUser.execute(uid, 'HMSET', 'user:'******'SET', 'snsidmap:' + snsId, uid)

        # 设置反查索引, MAIL
        if len(mail) > 0:
            TyContext.RedisUserKeys.execute('SET', 'mailmap:' + mail, uid)

        # 设置反查索引, userName
        if len(userAccount) > 0:
            TyContext.RedisUserKeys.execute('SET', 'accountmap:' + userAccount,
                                            uid)

        # 设置反查索引, mobile
        if len(mobile) > 0:
            TyContext.RedisUserKeys.execute('SET', 'mobilemap:' + mobile, uid)

        # 设置反查索引, DevId
        if setDevMap and len(
                deviceId
        ) > 0 and deviceId != '528c8e6cd4a3c6598999a0e9df15ad32':
            TyContext.RedisUserKeys.execute('SET', 'devidmap3:' + deviceId,
                                            uid)

        cls.updateUserSessionInfo(appId, uid, params)
        TyContext.BiReport.user_register(
            appId,
            uid,
            userType,
            clientId,
            TyContext.RunHttp.get_client_ip(),
            deviceId,
            params=TyContext.RunHttp.convertArgsToDict(),
            rpath=TyContext.RunHttp.get_request_path())
        TyContext.BiReport.report_bi_sdk_login(
            AccountConst.CREATE_SUCC_EVENTIDS[userType],
            uid,
            appId,
            clientId, ['', mail, snsId, mobile][userType],
            0,
            devId=deviceId)
        #         Report.recoderUserNew( appId, uid, userType)
        TyContext.UserProps.check_data_update_hall(int(uid), appId, True)
        AdvertiseService.on_user_created(int(uid))
        return int(uid)
Пример #4
0
    def doSetUserInfo(cls, rparams, mo, needReturn=True):
        TyContext.ftlog.info(cls.__name__, 'doSetUserInfo->rparams=', rparams,
                             'needReturn=', needReturn)
        userId = rparams.get('userId', 0)
        if userId <= 0:
            return

        nickname = rparams.get('name', '')
        sex = str(rparams.get('sex', ''))
        headurl = rparams.get('headurl', '')
        address = rparams.get('address', '')
        idcardno = rparams.get('idcardno', '')
        truename = rparams.get('truename', '')
        phonenumber = rparams.get('phonenumber', '')
        lang = rparams.get('lang', None)
        country = rparams.get('country', None)
        signature = rparams.get('signature', None)
        agreeAddFriend = rparams.get('agreeAddFriend', None)
        email = rparams.get('email', None)
        snsinfo = rparams.get('snsinfo', None)

        datas = []

        if len(address) > 0:
            datas.append('address')
            datas.append(address)

        if len(idcardno) > 0:
            datas.append('idcardno')
            datas.append(idcardno)

        if len(truename) > 0:
            datas.append('truename')
            datas.append(truename)

        if len(phonenumber) > 0:
            datas.append('phonenumber')
            datas.append(phonenumber)

        if lang != None:
            datas.append('lang')
            datas.append(lang)

        if country != None:
            datas.append('country')
            datas.append(country)

        if signature != None:
            datas.append('signature')
            datas.append(TyContext.KeywordFilter.replace(signature))

        if agreeAddFriend != None:
            if agreeAddFriend == '0' or agreeAddFriend == '1':
                datas.append('agreeAddFriend')
                datas.append(int(agreeAddFriend))

        if email != None:
            datas.append('email')
            datas.append(email)

        if snsinfo != None:
            datas.append('snsinfo')
            datas.append(snsinfo)

        if len(sex) > 0 and sex in ('0', '1'):
            datas.append('sex')
            datas.append(sex)
            oldSex = TyContext.RedisUser.execute(userId, 'HGET',
                                                 'user:'******'sex')
            if oldSex == None:
                oldSex = sex
            if int(oldSex) != int(sex):
                BeautyCertifyService.onUserSexChanged(userId, oldSex, sex)

        TyContext.ftlog.debug('nickname=[', nickname, ']')
        oldname = TyContext.RedisUser.execute(userId, 'HGET',
                                              'user:'******'name')
        '''
        if nickname == "LikaiAndZengxinxin" and TyContext.TYGlobal.corporation() == "pineapple":
            pass
        '''
        if len(nickname) > 0:
            newNameIs360Default = Account360.isDefault360Username(nickname)
            if newNameIs360Default:
                TyContext.ftlog.debug('nickname=[', nickname, '] oldname=[',
                                      oldname, '] sex=[', sex, ']')
                if not oldname or Account360.isDefault360Username(oldname):
                    if sex not in ('0', '1'):
                        sex = TyContext.RedisUser.execute(
                            userId, 'HGET', 'user:'******'sex')
                        TyContext.ftlog.debug('nickname=[', nickname,
                                              '] oldname=[', oldname,
                                              '] oldsex=[', sex, ']')
                    nickname = UsernameGenerator.getInstance().generate(sex)
                    # 设定
                else:
                    # 保持原名字
                    nickname = None
            else:
                # 设定
                pass

            if nickname != None:
                # todo for 104 test add by tcz
                mo_tmp = TyContext.MsgPack()
                UsernameGenerator.change_old_user_name(nickname, userId,
                                                       mo_tmp)
                if str(mo_tmp.getResult('code')) != '0':
                    mo.setResult('code', mo_tmp.getResult('code'))
                    mo.setResult('info', mo_tmp.getResult(('info')))
                    return
                datas.append('name')
                datas.append(nickname)
                # 需要根据不同的游戏ID做屏蔽是否不再允许再次更改.(appId 1-19)appId 为 12和15仍可以通过此接口修改名称(大菠萝,海外德州)
                accessAppId = TyContext.Configure.get_global_item_json(
                    'change_nickname_appId', [12, 15])
                appId = int(rparams.get('appId', '0'))
                if not appId in accessAppId and oldname != nickname and needReturn:
                    TyContext.RedisUser.execute(userId, 'HINCRBY',
                                                'user:'******'set_name_sum', 1)

        if len(headurl) > 0:
            UserPhotoService.setUserPhoto(userId, UserPhoto.PHOTO_TYPE_AVATAR,
                                          headurl)

        if len(datas) > 0:
            TyContext.RedisUser.execute(userId, 'HMSET', 'user:' + str(userId),
                                        *datas)

        if needReturn:
            cls.__set_user_info_return__(rparams, mo)