YiAi/YiAiQuickDeploy/dist/modules/user/user.service.js

1 line
27 KiB
JavaScript

'use strict';const _0x4a94aa=_0x4185;(function(_0x4a30d9,_0x3f95a3){const _0x3c998f=_0x4185,_0x5679df=_0x4a30d9();while(!![]){try{const _0x4ef968=parseInt(_0x3c998f(0x229))/0x1*(parseInt(_0x3c998f(0x225))/0x2)+-parseInt(_0x3c998f(0x20b))/0x3*(-parseInt(_0x3c998f(0x1d1))/0x4)+parseInt(_0x3c998f(0x213))/0x5+-parseInt(_0x3c998f(0x1d2))/0x6+-parseInt(_0x3c998f(0x248))/0x7+parseInt(_0x3c998f(0x19f))/0x8+-parseInt(_0x3c998f(0x1fb))/0x9;if(_0x4ef968===_0x3f95a3)break;else _0x5679df['push'](_0x5679df['shift']());}catch(_0x53df42){_0x5679df['push'](_0x5679df['shift']());}}}(_0xa010,0x9ee1d));var __decorate=this&&this[_0x4a94aa(0x1df)]||function(_0x257623,_0x3eda74,_0x3649cd,_0x4ae38c){const _0x309faa=_0x4a94aa;var _0xd2e044=arguments[_0x309faa(0x1b6)],_0x582e42=_0xd2e044<0x3?_0x3eda74:_0x4ae38c===null?_0x4ae38c=Object[_0x309faa(0x1e3)](_0x3eda74,_0x3649cd):_0x4ae38c,_0x2d4af4;if(typeof Reflect===_0x309faa(0x217)&&typeof Reflect[_0x309faa(0x24b)]==='function')_0x582e42=Reflect['decorate'](_0x257623,_0x3eda74,_0x3649cd,_0x4ae38c);else{for(var _0x3ceb93=_0x257623[_0x309faa(0x1b6)]-0x1;_0x3ceb93>=0x0;_0x3ceb93--)if(_0x2d4af4=_0x257623[_0x3ceb93])_0x582e42=(_0xd2e044<0x3?_0x2d4af4(_0x582e42):_0xd2e044>0x3?_0x2d4af4(_0x3eda74,_0x3649cd,_0x582e42):_0x2d4af4(_0x3eda74,_0x3649cd))||_0x582e42;}return _0xd2e044>0x3&&_0x582e42&&Object[_0x309faa(0x230)](_0x3eda74,_0x3649cd,_0x582e42),_0x582e42;},__metadata=this&&this[_0x4a94aa(0x233)]||function(_0x32ee3d,_0x48334c){const _0x148922=_0x4a94aa;if(typeof Reflect==='object'&&typeof Reflect['metadata']===_0x148922(0x228))return Reflect['metadata'](_0x32ee3d,_0x48334c);},__param=this&&this['__param']||function(_0x4168fc,_0x28c585){return function(_0x143a87,_0x1c0fe3){_0x28c585(_0x143a87,_0x1c0fe3,_0x4168fc);};};function _0x4185(_0x3e8679,_0x22b1ee){const _0xa0101e=_0xa010();return _0x4185=function(_0x41857a,_0x2e5494){_0x41857a=_0x41857a-0x19f;let _0x42d78e=_0xa0101e[_0x41857a];return _0x42d78e;},_0x4185(_0x3e8679,_0x22b1ee);}Object[_0x4a94aa(0x230)](exports,_0x4a94aa(0x1e6),{'value':!![]}),exports[_0x4a94aa(0x22c)]=void 0x0;function _0xa010(){const _0x3eeef8=['当前账户不存在!','globalConfigService','3kaDmeQ','UserStatusErrMsg','username','UserStatusEnum','超级管理员不可被操作!','getUserStatus','createUser','verifyUserRegisterByPhone','4240600LasFYZ','MailerService','phone','ACTIVE','object','findAndCount','@nestjs-modules/mailer','error:\x20','addBalanceToUser','registerIp','Connection','find','用户不存在!','hashSync','startsWith','@nestjs/typeorm','connection','ADMIN_GIFT','26sGPttj','getConfigs','lastLoginIp','function','58059uGKHvo','createUserFromOpenId','./user.entity','UserService','bcryptjs','avatar','openId','defineProperty','----,','checkUserStatus','__metadata','queryUserBalance','../../common/constants/balance.constant','hex','用户名已存在!','resetUserPass','verificationService','email\x20response\x20\x20->\x20:\x20','compareSync','reduce','getSuper','userRecharge','updateInfo','log','save','UserEntity','configEntity','绑定微信失败、请联系管理员!','已生成过邀请码、请勿重复生成','当前用户信息失效、请重新登录!','getUserById','6417852tGxMrR','role','用户名已存在、请更换用户名!','decorate','createHash','../chatgpt/whiteList.entity','inviteCode','crypto','获取邀请记录失败!','verifyUserCredentials','isVerifyEmail','forEach','registerVerifyExpir','Repository','queryOne','生成邀请码失败,请重新试一次吧!','3781480oTwgZb','该微信已绑定其他账号!','UserBalanceService','createUserAndVerifycation','split','VerificationService','status','sendMail','user','修改用户信息成功!','updateStatus','client','assign','userEntity','generateRandomString','getUserFromOpenId','修改用户信息失败!','mailerService','queryAll','DESC','updateUserStatus','../verification/verification.service','affected','length','没有变更,无需更改!','maskIpAddress','getOpenIdByUserId','用户名或者邮箱已被注册!','whiteListEntity','密码重置为[','addBalanceToNewUser','visitor','isBindWx','@nestjs/common','createVerification','digest','userBalanceService','../../common/utils','qureyUserInfoByInviteCode','$2b$','getUserInfo','HttpException','$2a$','当前密码错误!','不可将用户置为未激活状态!','configMap:\x20','VerificationEnum','Injectable','findOne','Registration','3513124ZrcDli','7054284zLiCWK','getClientIp','恭喜您绑定成功、后续可直接扫码登录了!','maskEmail','updateUserPassword','genInviteCode','verifyUserPassword','userId','formatCreateOrUpdateDate','cloneDeep','balanceInfo','../userBalance/userBalance.service','registerVerifyEmailTitle','__decorate','WhiteListEntity','consecutiveDays','LOCKED','getOwnPropertyDescriptor','../../common/constants/verification.constant','../globalConfig/config.entity','__esModule','$2y$','未激活用户不可手动变更状态!','userDefautlAvatar','registerVerifyEmailFrom','md5','UNAUTHORIZED','inviteLink','createdAt','GlobalConfigService','email','sign','getUserOpenId','Like','super','当前用户不存在!','../globalConfig/globalConfig.service','password','修改密码失败、请重新试试吧。','BAD_REQUEST','当前绑定用户不存在!','1894698LsqNxM','design:paramtypes','createRandomUid','Not','registerBaseUrl','../../common/constants/user.constant','ConfigEntity','HttpStatus','update','PENDING','bindWx',']成功!','lodash','InjectRepository'];_0xa010=function(){return _0x3eeef8;};return _0xa010();}const globalConfig_service_1=require(_0x4a94aa(0x1f6)),user_constant_1=require(_0x4a94aa(0x200)),mailer_1=require(_0x4a94aa(0x219)),verification_service_1=require(_0x4a94aa(0x1b4)),common_1=require(_0x4a94aa(0x1c0)),typeorm_1=require(_0x4a94aa(0x222)),typeorm_2=require('typeorm'),user_entity_1=require(_0x4a94aa(0x22b)),bcrypt=require(_0x4a94aa(0x22d)),crypto=require(_0x4a94aa(0x24f)),_=require(_0x4a94aa(0x207)),verification_constant_1=require(_0x4a94aa(0x1e4)),userBalance_service_1=require(_0x4a94aa(0x1dd)),utils_1=require(_0x4a94aa(0x1c4)),balance_constant_1=require(_0x4a94aa(0x235)),config_entity_1=require(_0x4a94aa(0x1e5)),whiteList_entity_1=require(_0x4a94aa(0x24d));let UserService=class UserService{constructor(_0x227e47,_0x968bae,_0x2a555d,_0x13d67f,_0x14ab66,_0x3f19d1,_0x545ad0,_0x1e2aee){const _0x184e13=_0x4a94aa;this[_0x184e13(0x1ac)]=_0x227e47,this[_0x184e13(0x1bb)]=_0x968bae,this[_0x184e13(0x223)]=_0x2a555d,this[_0x184e13(0x239)]=_0x13d67f,this[_0x184e13(0x1b0)]=_0x14ab66,this['userBalanceService']=_0x3f19d1,this[_0x184e13(0x20a)]=_0x545ad0,this[_0x184e13(0x243)]=_0x1e2aee;}async[_0x4a94aa(0x1a2)](_0x335d76,_0x26b42a){const _0x1a3c33=_0x4a94aa,{username:_0x104d04,email:_0x1245ea,password:_0x34a14b,invitedBy:_0x489800,client:client=0x0}=_0x335d76;if(_0x489800){const _0x212051=await this['userEntity'][_0x1a3c33(0x1cf)]({'where':{'inviteCode':_0x489800}});if(!_0x212051)throw new common_1[(_0x1a3c33(0x1c8))]('无效的邀请码!',common_1[_0x1a3c33(0x202)]['BAD_REQUEST']);}const _0x261c75=[{'username':_0x104d04},{'email':_0x1245ea}],_0x48f4a4=await this['userEntity'][_0x1a3c33(0x1cf)]({'where':_0x261c75});if(_0x48f4a4&&_0x48f4a4[_0x1a3c33(0x1a5)]!==user_constant_1['UserStatusEnum'][_0x1a3c33(0x204)])throw new common_1['HttpException'](_0x1a3c33(0x1ba),common_1[_0x1a3c33(0x202)][_0x1a3c33(0x1f9)]);try{const _0x39ce2e=_[_0x1a3c33(0x1db)](_0x335d76),_0x537d60=bcrypt['hashSync'](_0x34a14b,0xa),_0x523d31=(0x0,utils_1[_0x1a3c33(0x1d3)])(_0x26b42a);_0x39ce2e[_0x1a3c33(0x1f7)]=_0x537d60,_0x39ce2e[_0x1a3c33(0x21c)]=_0x523d31,_0x39ce2e[_0x1a3c33(0x1aa)]=client;let _0x5dac85;if(!_0x48f4a4){const _0x734f53=await this['globalConfigService'][_0x1a3c33(0x226)]([_0x1a3c33(0x1e9)]);_0x39ce2e[_0x1a3c33(0x22e)]=_0x734f53,_0x5dac85=await this[_0x1a3c33(0x1ac)]['save'](_0x39ce2e);}else _0x5dac85=_0x48f4a4;const _0x561ae3=await this[_0x1a3c33(0x243)][_0x1a3c33(0x21e)]({'where':{'configKey':(0x0,typeorm_2['In'])([_0x1a3c33(0x252),_0x1a3c33(0x1ff),_0x1a3c33(0x1de),'registerVerifyEmailDesc',_0x1a3c33(0x1ea),_0x1a3c33(0x254)])}}),_0x35f6c2=_0x561ae3[_0x1a3c33(0x23c)]((_0x4e64b1,_0x52dc29)=>{return _0x4e64b1[_0x52dc29['configKey']]=_0x52dc29['configVal'],_0x4e64b1;},{}),_0x91d005=_0x35f6c2['isVerifyEmail']?Number(_0x35f6c2[_0x1a3c33(0x252)]):0x1;if(_0x91d005){const _0x40be89=_0x35f6c2[_0x1a3c33(0x254)]?Number(_0x35f6c2['registerVerifyExpir']):0x1e*0x3c,_0x179bd5=await this[_0x1a3c33(0x239)][_0x1a3c33(0x1c1)](_0x5dac85,verification_constant_1[_0x1a3c33(0x1cd)][_0x1a3c33(0x1d0)],_0x40be89),{code:_0x410f1a,email:_0x51512d,id:_0x100f48}=_0x179bd5,{registerVerifyEmailFrom:_0x1bb190}=_0x35f6c2;console[_0x1a3c33(0x240)](_0x1a3c33(0x1cc),_0x35f6c2);const _0x267f8d=await this[_0x1a3c33(0x1b0)][_0x1a3c33(0x1a6)]({'to':_0x51512d,'subject':'来自'+_0x1bb190+'的账号激活','template':'register','context':Object[_0x1a3c33(0x1ab)]({'baseUrl':_0x35f6c2[_0x1a3c33(0x1ff)],'code':_0x410f1a,'id':_0x100f48},_0x35f6c2)});console['log'](_0x1a3c33(0x23a),_0x267f8d);}else{const {username:_0x12c792,email:_0x5efbee,id:_0x2728a1,invitedBy:_0x59630c}=_0x5dac85;await this[_0x1a3c33(0x1b3)](_0x2728a1,user_constant_1[_0x1a3c33(0x20e)][_0x1a3c33(0x216)]);let _0x255084;_0x59630c&&(_0x255084=await this[_0x1a3c33(0x1c5)](_0x59630c)),await this[_0x1a3c33(0x1c3)][_0x1a3c33(0x1bd)](_0x2728a1,_0x255084===null||_0x255084===void 0x0?void 0x0:_0x255084['id']);}return _0x5dac85;}catch(_0x5bcd8e){console[_0x1a3c33(0x240)](_0x1a3c33(0x21a),_0x5bcd8e);throw _0x5bcd8e;}}async[_0x4a94aa(0x23d)](){const _0x430fe2=_0x4a94aa,_0xc6c1ae=await this[_0x430fe2(0x1ac)]['findOne']({'where':{'role':_0x430fe2(0x1f4)}});return _0xc6c1ae;}async[_0x4a94aa(0x251)](_0x468601){const _0x388a10=_0x4a94aa,{username:_0x26e3fe,password:_0x558e97,uid:uid=0x0,phone:_0x3d87e1}=_0x468601;let _0x280f1f=null;if(uid>0x0){_0x280f1f=await this[_0x388a10(0x1ac)][_0x388a10(0x1cf)]({'where':{'id':uid}});if(!_0x280f1f)throw new common_1['HttpException'](_0x388a10(0x209),common_1[_0x388a10(0x202)]['BAD_REQUEST']);if(_0x280f1f[_0x388a10(0x1f7)]['startsWith']('$2a$')||_0x280f1f[_0x388a10(0x1f7)][_0x388a10(0x221)]('$2b$')||_0x280f1f[_0x388a10(0x1f7)][_0x388a10(0x221)](_0x388a10(0x1e7))){if(!bcrypt[_0x388a10(0x23b)](_0x558e97,_0x280f1f[_0x388a10(0x1f7)]))throw new common_1['HttpException'](_0x388a10(0x1ca),common_1['HttpStatus']['BAD_REQUEST']);}else{console[_0x388a10(0x240)](_0x388a10(0x231));const _0x4b5522=crypto['createHash']('md5')[_0x388a10(0x203)](_0x558e97)['digest']('hex');console[_0x388a10(0x240)](_0x388a10(0x231),_0x4b5522);if(_0x4b5522!==_0x280f1f['password'])throw new common_1['HttpException']('当前密码错误!',common_1[_0x388a10(0x202)][_0x388a10(0x1f9)]);}}if(_0x26e3fe&&_0x558e97){const _0x218757=[{'username':_0x26e3fe},{'email':_0x26e3fe}];_0x280f1f=await this[_0x388a10(0x1ac)]['findOne']({'where':_0x218757});if(!_0x280f1f)throw new common_1[(_0x388a10(0x1c8))](_0x388a10(0x209),common_1['HttpStatus'][_0x388a10(0x1f9)]);if(_0x280f1f[_0x388a10(0x1f7)][_0x388a10(0x221)](_0x388a10(0x1c9))||_0x280f1f[_0x388a10(0x1f7)][_0x388a10(0x221)](_0x388a10(0x1c6))||_0x280f1f['password'][_0x388a10(0x221)](_0x388a10(0x1e7))){if(!bcrypt[_0x388a10(0x23b)](_0x558e97,_0x280f1f['password']))throw new common_1[(_0x388a10(0x1c8))](_0x388a10(0x1ca),common_1[_0x388a10(0x202)][_0x388a10(0x1f9)]);}else{console[_0x388a10(0x240)](_0x388a10(0x231));const _0xd7e836=crypto[_0x388a10(0x24c)](_0x388a10(0x1eb))[_0x388a10(0x203)](_0x558e97)[_0x388a10(0x1c2)]('hex');console[_0x388a10(0x240)](_0x388a10(0x231),_0xd7e836);if(_0xd7e836!==_0x280f1f[_0x388a10(0x1f7)])throw new common_1['HttpException'](_0x388a10(0x1ca),common_1['HttpStatus'][_0x388a10(0x1f9)]);}}if(_0x3d87e1&&_0x558e97){const _0x242d9d=[{'phone':_0x3d87e1}];_0x280f1f=await this[_0x388a10(0x1ac)][_0x388a10(0x1cf)]({'where':_0x242d9d});if(!_0x280f1f)throw new common_1[(_0x388a10(0x1c8))](_0x388a10(0x209),common_1['HttpStatus'][_0x388a10(0x1f9)]);if(_0x280f1f['password'][_0x388a10(0x221)](_0x388a10(0x1c9))||_0x280f1f[_0x388a10(0x1f7)][_0x388a10(0x221)](_0x388a10(0x1c6))||_0x280f1f[_0x388a10(0x1f7)][_0x388a10(0x221)]('$2y$')){if(!bcrypt['compareSync'](_0x558e97,_0x280f1f['password']))throw new common_1['HttpException'](_0x388a10(0x1ca),common_1[_0x388a10(0x202)][_0x388a10(0x1f9)]);}else{console[_0x388a10(0x240)](_0x388a10(0x231));const _0x4fb1d1=crypto[_0x388a10(0x24c)](_0x388a10(0x1eb))[_0x388a10(0x203)](_0x558e97)[_0x388a10(0x1c2)](_0x388a10(0x236));console[_0x388a10(0x240)](_0x388a10(0x231),_0x4fb1d1);if(_0x4fb1d1!==_0x280f1f[_0x388a10(0x1f7)])throw new common_1[(_0x388a10(0x1c8))](_0x388a10(0x1ca),common_1[_0x388a10(0x202)]['BAD_REQUEST']);}}if(!_0x280f1f)throw new common_1[(_0x388a10(0x1c8))](_0x388a10(0x209),common_1[_0x388a10(0x202)][_0x388a10(0x1f9)]);if(_0x280f1f[_0x388a10(0x1a5)]!==user_constant_1['UserStatusEnum']['ACTIVE'])throw new common_1[(_0x388a10(0x1c8))](user_constant_1[_0x388a10(0x20c)][_0x280f1f[_0x388a10(0x1a5)]],common_1['HttpStatus'][_0x388a10(0x1f9)]);return _0x280f1f;}async[_0x4a94aa(0x1d8)](_0x3ccf7c,_0x1edf35){const _0x56a313=_0x4a94aa,_0x5379da=await this[_0x56a313(0x1ac)]['findOne']({'where':{'id':_0x3ccf7c}});if(_0x5379da['password'][_0x56a313(0x221)](_0x56a313(0x1c9))||_0x5379da[_0x56a313(0x1f7)][_0x56a313(0x221)](_0x56a313(0x1c6))||_0x5379da[_0x56a313(0x1f7)][_0x56a313(0x221)](_0x56a313(0x1e7)))return bcrypt['compareSync'](_0x1edf35,_0x5379da[_0x56a313(0x1f7)]);else{const _0x545dda=crypto[_0x56a313(0x24c)](_0x56a313(0x1eb))[_0x56a313(0x203)](_0x1edf35)[_0x56a313(0x1c2)](_0x56a313(0x236));return console[_0x56a313(0x240)](_0x56a313(0x231),_0x545dda),_0x545dda===_0x5379da[_0x56a313(0x1f7)];}}async[_0x4a94aa(0x1b3)](_0x5811b7,_0x334b48){const _0x5c93a8=_0x4a94aa,_0x1c1cb0=await this[_0x5c93a8(0x1ac)][_0x5c93a8(0x203)]({'id':_0x5811b7},{'status':_0x334b48});return _0x1c1cb0[_0x5c93a8(0x1b5)]>0x0;}async[_0x4a94aa(0x210)](_0x31180c){const _0x57fa43=_0x4a94aa,_0x731f31=await this[_0x57fa43(0x1ac)]['findOne']({'where':{'id':_0x31180c}});return _0x731f31[_0x57fa43(0x1a5)];}async['queryUserInfoById'](_0x235c7b){const _0x4fe852=_0x4a94aa;return await this['userEntity'][_0x4fe852(0x1cf)]({'where':{'id':_0x235c7b}});}async['queryOneUserInfo'](_0xd3dedb){const _0x2e86d5=_0x4a94aa;return await this[_0x2e86d5(0x1ac)][_0x2e86d5(0x1cf)]({'where':{'id':_0xd3dedb}});}async[_0x4a94aa(0x232)](_0x2063ab){const _0x5e6e56=_0x4a94aa,{id:_0x76f642,role:_0x5c22d8}=_0x2063ab;if(_0x5c22d8===_0x5e6e56(0x1be))return!![];const _0x3448b4=await this[_0x5e6e56(0x1ac)]['findOne']({'where':{'id':_0x76f642}});if(!_0x3448b4)throw new common_1[(_0x5e6e56(0x1c8))](_0x5e6e56(0x246),common_1[_0x5e6e56(0x202)][_0x5e6e56(0x1ec)]);if(_0x3448b4[_0x5e6e56(0x1a5)]===user_constant_1[_0x5e6e56(0x20e)]['BLACKLISTED'])throw new common_1[(_0x5e6e56(0x1c8))]('您的账户已被永久加入黑名单、如有疑问、请联系管理员!',common_1['HttpStatus'][_0x5e6e56(0x1f9)]);if(_0x3448b4[_0x5e6e56(0x1a5)]===user_constant_1['UserStatusEnum'][_0x5e6e56(0x1e2)])throw new common_1[(_0x5e6e56(0x1c8))]('您的账户已被封禁、如有疑问、请联系管理员!',common_1['HttpStatus'][_0x5e6e56(0x1f9)]);}async[_0x4a94aa(0x1c7)](_0x3cca20){const _0x14ab22=_0x4a94aa,_0x9298af=await this[_0x14ab22(0x1ac)][_0x14ab22(0x1cf)]({'where':{'id':_0x3cca20},'select':[_0x14ab22(0x20d),_0x14ab22(0x22e),_0x14ab22(0x249),_0x14ab22(0x1f0),'sign',_0x14ab22(0x24e),_0x14ab22(0x22f),_0x14ab22(0x1e1)]});if(!_0x9298af)throw new common_1[(_0x14ab22(0x1c8))](_0x14ab22(0x246),common_1[_0x14ab22(0x202)]['UNAUTHORIZED']);_0x9298af[_0x14ab22(0x1bf)]=!!(_0x9298af===null||_0x9298af===void 0x0?void 0x0:_0x9298af[_0x14ab22(0x22f)]),delete _0x9298af[_0x14ab22(0x22f)];const _0x277bdd=await this[_0x14ab22(0x1c3)][_0x14ab22(0x234)](_0x3cca20);return{'userInfo':_0x9298af,'userBalance':Object['assign']({},_0x277bdd)};}async[_0x4a94aa(0x247)](_0x4c68be){const _0x126db4=_0x4a94aa;return await this[_0x126db4(0x1ac)][_0x126db4(0x1cf)]({'where':{'id':_0x4c68be}});}async[_0x4a94aa(0x1f2)](_0x3e233c){const _0xbea0a3=_0x4a94aa;return await this[_0xbea0a3(0x1ac)][_0xbea0a3(0x1cf)]({'where':{'openId':_0x3e233c}});}async[_0x4a94aa(0x23f)](_0xf380fe,_0x1ff2cb){const _0xb793c7=_0x4a94aa,{id:_0x32895f}=_0x1ff2cb[_0xb793c7(0x1a7)],_0x36a42a=await this[_0xb793c7(0x1ac)][_0xb793c7(0x1cf)]({'where':{'id':_0x32895f}});if(!_0x36a42a)throw new common_1[(_0xb793c7(0x1c8))](_0xb793c7(0x1f5),common_1[_0xb793c7(0x202)][_0xb793c7(0x1f9)]);if(_0xf380fe[_0xb793c7(0x20d)]&&_0x36a42a['username']===_0xf380fe[_0xb793c7(0x20d)])throw new common_1['HttpException'](_0xb793c7(0x1b7),common_1[_0xb793c7(0x202)][_0xb793c7(0x1f9)]);if(_0xf380fe[_0xb793c7(0x20d)]){const _0x634c79=await this[_0xb793c7(0x1ac)]['findOne']({'where':{'username':_0xf380fe['username'],'id':(0x0,typeorm_2[_0xb793c7(0x1fe)])(_0x32895f)}});if(_0x634c79)throw new common_1[(_0xb793c7(0x1c8))](_0xb793c7(0x237),common_1['HttpStatus'][_0xb793c7(0x1f9)]);}const _0x1a6d93=await this[_0xb793c7(0x1ac)][_0xb793c7(0x203)]({'id':_0x32895f},_0xf380fe);if(_0x1a6d93['affected']<=0x0)throw new common_1[(_0xb793c7(0x1c8))](_0xb793c7(0x1af),common_1[_0xb793c7(0x202)]['BAD_REQUEST']);return _0xb793c7(0x1a8);}async[_0x4a94aa(0x1d6)](_0x567fdd,_0x363b32){const _0x39bd77=_0x4a94aa,_0x15b16c=bcrypt[_0x39bd77(0x220)](_0x363b32,0xa),_0x42ffe4=await this[_0x39bd77(0x1ac)][_0x39bd77(0x203)]({'id':_0x567fdd},{'password':_0x15b16c});if(_0x42ffe4['affected']<=0x0)throw new common_1[(_0x39bd77(0x1c8))](_0x39bd77(0x1f8),common_1[_0x39bd77(0x202)][_0x39bd77(0x1f9)]);}async[_0x4a94aa(0x1d7)](_0x3df635){const _0x55d07=_0x4a94aa,{id:_0x4773e1}=_0x3df635[_0x55d07(0x1a7)],_0x224de1=await this[_0x55d07(0x1ac)][_0x55d07(0x1cf)]({'where':{'id':_0x4773e1}});if(!_0x224de1||_0x224de1['inviteCode'])throw new common_1['HttpException'](_0x55d07(0x245),common_1[_0x55d07(0x202)][_0x55d07(0x1f9)]);const _0x443cc1=(0x0,utils_1[_0x55d07(0x1ad)])(),_0x17cf0c=await this[_0x55d07(0x1ac)][_0x55d07(0x1cf)]({'where':{'inviteCode':_0x443cc1}});if(_0x17cf0c)throw new common_1['HttpException'](_0x55d07(0x257),common_1[_0x55d07(0x202)][_0x55d07(0x1f9)]);const _0x5ddf71=await this[_0x55d07(0x1ac)][_0x55d07(0x203)]({'id':_0x4773e1},{'inviteCode':_0x443cc1});if(_0x5ddf71[_0x55d07(0x1b5)]<=0x0)throw new common_1[(_0x55d07(0x1c8))](_0x55d07(0x257),common_1[_0x55d07(0x202)][_0x55d07(0x1f9)]);return _0x443cc1;}async['getInviteRecord'](_0x26d459,_0x2934f5){const _0x12c497=_0x4a94aa;try{const {id:_0xcf38ff}=_0x26d459['user'],{page:page=0x1,size:size=0xa}=_0x2934f5,_0x338f77=await this[_0x12c497(0x1ac)][_0x12c497(0x1cf)]({'where':{'id':_0xcf38ff}}),{inviteCode:_0x2277d1}=_0x338f77;if(!_0x2277d1)return[];const [_0x38fa96,_0x2bea8b]=await this[_0x12c497(0x1ac)][_0x12c497(0x218)]({'where':{'inviteCode':_0x2277d1},'order':{'id':_0x12c497(0x1b2)},'select':['username',_0x12c497(0x1f0),_0x12c497(0x1ee),_0x12c497(0x1a5),'avatar'],'take':size,'skip':(page-0x1)*size});return(0x0,utils_1[_0x12c497(0x1da)])(_0x38fa96)['map'](_0x5f5092=>{const _0x28cdc0=_0x12c497;return _0x5f5092[_0x28cdc0(0x1f0)]=(0x0,utils_1[_0x28cdc0(0x1d5)])(_0x5f5092['email']),_0x5f5092;}),{'rows':_0x38fa96,'count':_0x2bea8b};}catch(_0x399e65){console[_0x12c497(0x240)]('error:\x20',_0x399e65);throw new common_1[(_0x12c497(0x1c8))](_0x12c497(0x250),common_1[_0x12c497(0x202)]['BAD_REQUEST']);}}async[_0x4a94aa(0x1ed)](_0x41497b){const _0x51254f=_0x4a94aa,_0x21f977=await this[_0x51254f(0x1ac)][_0x51254f(0x1cf)]({'where':{'inviteCode':_0x41497b}});if(!_0x21f977)return 0x1;const {inviteLinkCount:inviteLinkCount=0x0}=_0x21f977,_0x2f392c=await this[_0x51254f(0x1ac)][_0x51254f(0x203)]({'inviteCode':_0x41497b},{'inviteLinkCount':inviteLinkCount+0x1});return _0x2f392c['affected']?0x1:0x0;}async['qureyUserInfoByInviteCode'](_0x21b1db){const _0x38646c=_0x4a94aa;return await this['userEntity'][_0x38646c(0x1cf)]({'where':{'inviteCode':_0x21b1db}});}async[_0x4a94aa(0x23e)](_0x5e71d3){const _0xd9492a=_0x4a94aa,{userId:_0x29bb1d,model3Count:model3Count=0x0,model4Count:model4Count=0x0,drawMjCount:drawMjCount=0x0}=_0x5e71d3;await this[_0xd9492a(0x1c3)][_0xd9492a(0x21b)](_0x29bb1d,{'model3Count':model3Count,'model4Count':model4Count,'drawMjCount':drawMjCount});const _0x16163c=await this[_0xd9492a(0x1c3)]['saveRecordRechargeLog']({'userId':_0x29bb1d,'rechargeType':balance_constant_1['RechargeType'][_0xd9492a(0x224)],'model3Count':model3Count,'model4Count':model4Count,'drawMjCount':drawMjCount,'extent':''});return _0x16163c;}async[_0x4a94aa(0x1b1)](_0x4f8dc6,_0x2a1579){const _0xc72fde=_0x4a94aa,{page:page=0x1,size:size=0xa,username:_0x2f4cf0,email:_0xe6049c,status:_0x46b9f4,keyword:_0x469841,phone:_0x1d9895}=_0x4f8dc6;let _0x1129ad={};_0x2f4cf0&&Object['assign'](_0x1129ad,{'username':(0x0,typeorm_2[_0xc72fde(0x1f3)])('%'+_0x2f4cf0+'%')}),_0xe6049c&&Object['assign'](_0x1129ad,{'email':(0x0,typeorm_2[_0xc72fde(0x1f3)])('%'+_0xe6049c+'%')}),_0x1d9895&&Object[_0xc72fde(0x1ab)](_0x1129ad,{'phone':(0x0,typeorm_2[_0xc72fde(0x1f3)])('%'+_0x1d9895+'%')}),_0x46b9f4&&Object[_0xc72fde(0x1ab)](_0x1129ad,{'status':_0x46b9f4});_0x469841&&(_0x1129ad=[{'username':(0x0,typeorm_2[_0xc72fde(0x1f3)])('%'+_0x469841+'%')},{'email':(0x0,typeorm_2['Like'])('%'+_0x469841+'%')},{'phone':(0x0,typeorm_2[_0xc72fde(0x1f3)])('%'+_0x469841+'%')}]);const [_0x11d242,_0x4d98a3]=await this[_0xc72fde(0x1ac)][_0xc72fde(0x218)]({'skip':(page-0x1)*size,'where':_0x1129ad,'take':size,'order':{'createdAt':'DESC'},'cache':!![],'select':['username',_0xc72fde(0x22e),_0xc72fde(0x24e),_0xc72fde(0x249),_0xc72fde(0x1f1),_0xc72fde(0x1a5),'id',_0xc72fde(0x1f0),_0xc72fde(0x1ee),_0xc72fde(0x227),_0xc72fde(0x215)]}),_0x2170f4=_0x11d242['map'](_0x4ff560=>_0x4ff560['id']),_0x5eaff8=await this[_0xc72fde(0x1c3)]['queryUserBalanceByIds'](_0x2170f4);return _0x11d242[_0xc72fde(0x253)](_0x4c8cdc=>_0x4c8cdc[_0xc72fde(0x1dc)]=_0x5eaff8['find'](_0x354eed=>_0x354eed[_0xc72fde(0x1d9)]===_0x4c8cdc['id'])),_0x2a1579[_0xc72fde(0x1a7)][_0xc72fde(0x249)]!==_0xc72fde(0x1f4)&&_0x11d242['forEach'](_0x26fdc9=>_0x26fdc9[_0xc72fde(0x1f0)]=(0x0,utils_1[_0xc72fde(0x1d5)])(_0x26fdc9[_0xc72fde(0x1f0)])),_0x2a1579['user']['role']!==_0xc72fde(0x1f4)&&_0x11d242[_0xc72fde(0x253)](_0x111398=>_0x111398[_0xc72fde(0x227)]=(0x0,utils_1['maskIpAddress'])(_0x111398[_0xc72fde(0x227)])),_0x2a1579[_0xc72fde(0x1a7)][_0xc72fde(0x249)]!==_0xc72fde(0x1f4)&&_0x11d242['forEach'](_0x44b882=>_0x44b882[_0xc72fde(0x215)]=(0x0,utils_1[_0xc72fde(0x1b8)])(_0x44b882[_0xc72fde(0x215)])),{'rows':_0x11d242,'count':_0x4d98a3};}async[_0x4a94aa(0x256)]({id:_0x1971de}){const _0x59a934=_0x4a94aa;return await this[_0x59a934(0x1ac)][_0x59a934(0x1cf)]({'where':{'id':_0x1971de},'select':['username',_0x59a934(0x22e),_0x59a934(0x24e),_0x59a934(0x249),_0x59a934(0x1f1),_0x59a934(0x1a5)]});}async[_0x4a94aa(0x1a9)](_0x4189b5){const _0x46ed0e=_0x4a94aa,{id:_0x1cb60b,status:_0x28f2f7}=_0x4189b5,_0xd41158=await this[_0x46ed0e(0x1ac)][_0x46ed0e(0x1cf)]({'where':{'id':_0x1cb60b}});if(!_0xd41158)throw new common_1['HttpException'](_0x46ed0e(0x21f),common_1[_0x46ed0e(0x202)]['BAD_REQUEST']);if(_0xd41158['role']==='super')throw new common_1[(_0x46ed0e(0x1c8))](_0x46ed0e(0x20f),common_1[_0x46ed0e(0x202)]['BAD_REQUEST']);if(_0xd41158['status']===user_constant_1[_0x46ed0e(0x20e)][_0x46ed0e(0x204)])throw new common_1['HttpException'](_0x46ed0e(0x1e8),common_1[_0x46ed0e(0x202)][_0x46ed0e(0x1f9)]);if(_0xd41158['role']===_0x46ed0e(0x1f4))throw new common_1[(_0x46ed0e(0x1c8))](_0x46ed0e(0x20f),common_1[_0x46ed0e(0x202)][_0x46ed0e(0x1f9)]);if(_0x28f2f7===user_constant_1['UserStatusEnum']['PENDING'])throw new common_1['HttpException'](_0x46ed0e(0x1cb),common_1['HttpStatus'][_0x46ed0e(0x1f9)]);const _0x17d508=await this[_0x46ed0e(0x1ac)][_0x46ed0e(0x203)]({'id':_0x1cb60b},{'status':_0x28f2f7});if(_0x17d508['affected']<=0x0)throw new common_1[(_0x46ed0e(0x1c8))]('修改用户状态失败!',common_1['HttpStatus'][_0x46ed0e(0x1f9)]);return'修改用户状态成功!';}async[_0x4a94aa(0x238)](_0x799ab4){const _0x4c4a7a=_0x4a94aa,{id:_0x242850}=_0x799ab4,_0x342e56=await this[_0x4c4a7a(0x1ac)][_0x4c4a7a(0x1cf)]({'where':{'id':_0x242850}});if(!_0x342e56)throw new common_1[(_0x4c4a7a(0x1c8))](_0x4c4a7a(0x21f),common_1[_0x4c4a7a(0x202)][_0x4c4a7a(0x1f9)]);const _0x42291e='123456',_0x3c5d15=bcrypt['hashSync'](_0x42291e,0xa),_0x24e4e1=await this[_0x4c4a7a(0x1ac)]['update']({'id':_0x242850},{'password':_0x3c5d15});if(_0x24e4e1[_0x4c4a7a(0x1b5)]<=0x0)throw new common_1[(_0x4c4a7a(0x1c8))]('重置密码失败!',common_1['HttpStatus'][_0x4c4a7a(0x1f9)]);return _0x4c4a7a(0x1bc)+_0x42291e+_0x4c4a7a(0x206);}async['savaLoginIp'](_0x12243a,_0x3017be){const _0x20fe05=_0x4a94aa;return await this[_0x20fe05(0x1ac)][_0x20fe05(0x203)]({'id':_0x12243a},{'lastLoginIp':_0x3017be});}async[_0x4a94aa(0x1ae)](_0x30afe4,_0x29cf10){const _0x90d759=_0x4a94aa,_0x116de8=await this['userEntity'][_0x90d759(0x1cf)]({'where':{'openId':_0x30afe4}});if(!_0x116de8){const _0x2d07f4=_0x29cf10?_0x29cf10[_0x90d759(0x1a3)](':')[0x1]:'',_0x2e5d52=await this[_0x90d759(0x1c5)](_0x2d07f4),_0x184288=await this[_0x90d759(0x22a)](_0x30afe4,_0x2d07f4);return await this[_0x90d759(0x1c3)]['addBalanceToNewUser'](_0x184288['id'],_0x2d07f4?_0x2e5d52===null||_0x2e5d52===void 0x0?void 0x0:_0x2e5d52['id']:null),_0x184288;}return _0x116de8;}async[_0x4a94aa(0x22a)](_0x3386ec,_0x391d01){const _0x5e8c93=_0x4a94aa,_0x22d7db=await this['globalConfigService'][_0x5e8c93(0x226)](['userDefautlAvatar']),_0x2ba070={'avatar':_0x22d7db,'username':'用户'+(0x0,utils_1[_0x5e8c93(0x1fd)])(),'status':user_constant_1[_0x5e8c93(0x20e)]['ACTIVE'],'sex':0x0,'email':(0x0,utils_1['createRandomUid'])()+'@default.com','invitedBy':_0x391d01,'openId':_0x3386ec},_0xa19c1b=await this['userEntity'][_0x5e8c93(0x241)](_0x2ba070);return _0xa19c1b;}async[_0x4a94aa(0x205)](_0x18da00,_0x4f5a6d){const _0x16f39c=_0x4a94aa;try{const _0x3de3ef=await this[_0x16f39c(0x1ac)][_0x16f39c(0x1cf)]({'where':{'id':_0x4f5a6d}});if(!_0x3de3ef)return{'status':![],'msg':_0x16f39c(0x1fa)};const _0x538003=await this[_0x16f39c(0x1ac)][_0x16f39c(0x1cf)]({'where':{'openId':_0x18da00}});if(_0x538003)return{'status':![],'msg':_0x16f39c(0x1a0)};const _0x28c76e=await this[_0x16f39c(0x1ac)]['update']({'id':_0x4f5a6d},{'openId':_0x18da00});if(_0x28c76e['affected']<=0x0)return{'status':![],'msg':_0x16f39c(0x244)};return{'status':!![],'msg':_0x16f39c(0x1d4)};}catch(_0x23eecf){return{'status':![],'msg':'绑定微信失败、请联系管理员!'};}}async[_0x4a94aa(0x1b9)](_0x653a32){const _0x4052f0=_0x4a94aa,_0x557d40=await this[_0x4052f0(0x1ac)][_0x4052f0(0x1cf)]({'where':{'id':_0x653a32}});return _0x557d40===null||_0x557d40===void 0x0?void 0x0:_0x557d40[_0x4052f0(0x22f)];}async[_0x4a94aa(0x212)](_0x25edcb){const _0x336098=_0x4a94aa,{username:_0x2f06c4,password:_0x2dcdc3,phone:_0x2df9a3,phoneCode:_0x3c84b7}=_0x25edcb,_0x587260=await this[_0x336098(0x1ac)]['findOne']({'where':[{'username':_0x2f06c4},{'phone':_0x2df9a3}]});if(_0x587260&&_0x587260[_0x336098(0x20d)]===_0x2f06c4)throw new common_1[(_0x336098(0x1c8))](_0x336098(0x24a),common_1[_0x336098(0x202)]['BAD_REQUEST']);if(_0x587260&&_0x587260[_0x336098(0x215)]===_0x2df9a3)throw new common_1[(_0x336098(0x1c8))]('当前手机号已注册、请勿重复注册!',common_1[_0x336098(0x202)][_0x336098(0x1f9)]);}async[_0x4a94aa(0x211)](_0x1a60dc){const _0x4bd0db=_0x4a94aa;return await this[_0x4bd0db(0x1ac)][_0x4bd0db(0x241)](_0x1a60dc);}};UserService=__decorate([(0x0,common_1[_0x4a94aa(0x1ce)])(),__param(0x0,(0x0,typeorm_1[_0x4a94aa(0x208)])(user_entity_1[_0x4a94aa(0x242)])),__param(0x1,(0x0,typeorm_1[_0x4a94aa(0x208)])(whiteList_entity_1[_0x4a94aa(0x1e0)])),__param(0x7,(0x0,typeorm_1[_0x4a94aa(0x208)])(config_entity_1[_0x4a94aa(0x201)])),__metadata(_0x4a94aa(0x1fc),[typeorm_2['Repository'],typeorm_2[_0x4a94aa(0x255)],typeorm_2[_0x4a94aa(0x21d)],verification_service_1[_0x4a94aa(0x1a4)],mailer_1[_0x4a94aa(0x214)],userBalance_service_1[_0x4a94aa(0x1a1)],globalConfig_service_1[_0x4a94aa(0x1ef)],typeorm_2[_0x4a94aa(0x255)]])],UserService),exports[_0x4a94aa(0x22c)]=UserService;