mirror of
https://github.com/xiaoyiweb/YiAi.git
synced 2025-09-27 05:36:40 +08:00
1 line
27 KiB
JavaScript
1 line
27 KiB
JavaScript
'use strict';function _0xcca8(_0x39bec7,_0x2a2325){const _0x4f6ad5=_0x4f6a();return _0xcca8=function(_0xcca8ce,_0x32bbcf){_0xcca8ce=_0xcca8ce-0x1b2;let _0x13acf8=_0x4f6ad5[_0xcca8ce];return _0x13acf8;},_0xcca8(_0x39bec7,_0x2a2325);}const _0x3d346a=_0xcca8;(function(_0x2c79b2,_0x3d0bb7){const _0x90c4c2=_0xcca8,_0x47c464=_0x2c79b2();while(!![]){try{const _0x1435e3=-parseInt(_0x90c4c2(0x235))/0x1+-parseInt(_0x90c4c2(0x1bb))/0x2*(-parseInt(_0x90c4c2(0x223))/0x3)+-parseInt(_0x90c4c2(0x265))/0x4+parseInt(_0x90c4c2(0x1d8))/0x5*(-parseInt(_0x90c4c2(0x1f8))/0x6)+parseInt(_0x90c4c2(0x230))/0x7+-parseInt(_0x90c4c2(0x1e1))/0x8*(parseInt(_0x90c4c2(0x1e0))/0x9)+-parseInt(_0x90c4c2(0x1dd))/0xa*(-parseInt(_0x90c4c2(0x1be))/0xb);if(_0x1435e3===_0x3d0bb7)break;else _0x47c464['push'](_0x47c464['shift']());}catch(_0x3c4348){_0x47c464['push'](_0x47c464['shift']());}}}(_0x4f6a,0x4a5ba));var __decorate=this&&this[_0x3d346a(0x228)]||function(_0xd704fe,_0x57a7c3,_0x5d942d,_0x1dfb73){const _0x58d9fd=_0x3d346a;var _0x1eb0dc=arguments[_0x58d9fd(0x20e)],_0x1ebef8=_0x1eb0dc<0x3?_0x57a7c3:_0x1dfb73===null?_0x1dfb73=Object[_0x58d9fd(0x208)](_0x57a7c3,_0x5d942d):_0x1dfb73,_0xe76df5;if(typeof Reflect==='object'&&typeof Reflect[_0x58d9fd(0x214)]===_0x58d9fd(0x211))_0x1ebef8=Reflect[_0x58d9fd(0x214)](_0xd704fe,_0x57a7c3,_0x5d942d,_0x1dfb73);else{for(var _0x5c9033=_0xd704fe[_0x58d9fd(0x20e)]-0x1;_0x5c9033>=0x0;_0x5c9033--)if(_0xe76df5=_0xd704fe[_0x5c9033])_0x1ebef8=(_0x1eb0dc<0x3?_0xe76df5(_0x1ebef8):_0x1eb0dc>0x3?_0xe76df5(_0x57a7c3,_0x5d942d,_0x1ebef8):_0xe76df5(_0x57a7c3,_0x5d942d))||_0x1ebef8;}return _0x1eb0dc>0x3&&_0x1ebef8&&Object[_0x58d9fd(0x241)](_0x57a7c3,_0x5d942d,_0x1ebef8),_0x1ebef8;},__metadata=this&&this[_0x3d346a(0x1c0)]||function(_0x12c256,_0xde6ce5){const _0x1957cc=_0x3d346a;if(typeof Reflect===_0x1957cc(0x24e)&&typeof Reflect[_0x1957cc(0x1fb)]==='function')return Reflect[_0x1957cc(0x1fb)](_0x12c256,_0xde6ce5);},__param=this&&this['__param']||function(_0x49beaa,_0x4b0009){return function(_0x447967,_0x1110a1){_0x4b0009(_0x447967,_0x1110a1,_0x49beaa);};};Object[_0x3d346a(0x241)](exports,'__esModule',{'value':!![]}),exports['UserService']=void 0x0;function _0x4f6a(){const _0x4afee3=['update','registerVerifyEmailFrom','lastLoginIp','updateUserStatus','typeorm','Registration','map','UserBalanceService','../../common/constants/user.constant','inviteCode','123456','您的账户已被永久加入黑名单、如有疑问、请联系管理员!','object','status','当前绑定用户不存在!','userEntity','hashSync',']成功!','MailerService','maskEmail','visitor','save','@default.com','修改用户信息失败!','../verification/verification.service','getUserById','生成邀请码失败,请重新试一次吧!','addBalanceToNewUser','当前账户不存在!','forEach','的账号激活','获取邀请记录失败!','Not','../../common/constants/balance.constant','findOne','1154616BPuTAT','find','Like','configKey','createHash','queryUserBalance','verificationService','whiteListEntity','username','Connection','修改密码失败、请重新试试吧。','crypto','172682NodjMJ','connection','getConfigs','33WAphRN','registerIp','__metadata','getUserInfo','affected','userBalanceService','getOpenIdByUserId','configEntity','bindWx','password','qureyUserInfoByInviteCode','configMap:\x20','user','已生成过邀请码、请勿重复生成','client','../../common/constants/verification.constant','userRecharge','createRandomUid','UserService','HttpStatus','generateRandomString','mailerService','当前用户信息失效、请重新登录!','DESC','GlobalConfigService','phone','384035gSeusA','formatCreateOrUpdateDate','Repository','createVerification','queryOne','2762570aZWKRB','getUserFromOpenId','ADMIN_GIFT','27tLXxsR','1444368XzIeRa','./user.entity','../userBalance/userBalance.service','修改用户信息成功!','assign','----,','$2a$','超级管理员不可被操作!','BAD_REQUEST','BLACKLISTED','role','registerVerifyEmailTitle','$2b$','@nestjs/common','compareSync','LOCKED','不可将用户置为未激活状态!','openId','该微信已绑定其他账号!','queryAll','Injectable','VerificationEnum','../../common/utils','6GDvmeT','createUser','VerificationService','metadata','avatar','当前密码错误!','verifyUserRegisterByPhone','email\x20response\x20\x20->\x20:\x20','resetUserPass','hex','super','修改用户状态成功!','error:\x20','registerBaseUrl','cloneDeep','用户不存在!','getOwnPropertyDescriptor','startsWith','verifyUserPassword','getInviteRecord','当前用户不存在!','queryUserBalanceByIds','length','重置密码失败!','isBindWx','function','UserStatusErrMsg','digest','decorate','ACTIVE','../globalConfig/config.entity','ConfigEntity','userId','绑定微信失败、请联系管理员!','RechargeType','balanceInfo','用户名已存在!','修改用户状态失败!','split','恭喜您绑定成功、后续可直接扫码登录了!','UserStatusEnum','email','sign','3MeJRTI','HttpException','无效的邀请码!','registerVerifyExpir','$2y$','__decorate','registerVerifyEmailDesc','getUserStatus','addBalanceToUser','md5','getSuper','userDefautlAvatar','UNAUTHORIZED','2247700sLEaNB','log','globalConfigService','checkUserStatus','InjectRepository','24543xMdLIm','PENDING','findAndCount','未激活用户不可手动变更状态!','lodash','getClientIp','maskIpAddress','genInviteCode','createUserFromOpenId','WhiteListEntity','design:paramtypes','createdAt','defineProperty'];_0x4f6a=function(){return _0x4afee3;};return _0x4f6a();}const globalConfig_service_1=require('../globalConfig/globalConfig.service'),user_constant_1=require(_0x3d346a(0x24a)),mailer_1=require('@nestjs-modules/mailer'),verification_service_1=require(_0x3d346a(0x25a)),common_1=require(_0x3d346a(0x1ee)),typeorm_1=require('@nestjs/typeorm'),typeorm_2=require(_0x3d346a(0x246)),user_entity_1=require(_0x3d346a(0x1e2)),bcrypt=require('bcryptjs'),crypto=require(_0x3d346a(0x1ba)),_=require(_0x3d346a(0x239)),verification_constant_1=require(_0x3d346a(0x1cd)),userBalance_service_1=require(_0x3d346a(0x1e3)),utils_1=require(_0x3d346a(0x1f7)),balance_constant_1=require(_0x3d346a(0x263)),config_entity_1=require(_0x3d346a(0x216)),whiteList_entity_1=require('../chatgpt/whiteList.entity');let UserService=class UserService{constructor(_0x26bd88,_0x194dcd,_0x9534be,_0x429f72,_0xb749b0,_0x46744e,_0xebd229,_0x4c3177){const _0x4a27e8=_0x3d346a;this[_0x4a27e8(0x251)]=_0x26bd88,this[_0x4a27e8(0x1b6)]=_0x194dcd,this[_0x4a27e8(0x1bc)]=_0x9534be,this[_0x4a27e8(0x1b5)]=_0x429f72,this[_0x4a27e8(0x1d3)]=_0xb749b0,this['userBalanceService']=_0x46744e,this[_0x4a27e8(0x232)]=_0xebd229,this['configEntity']=_0x4c3177;}async['createUserAndVerifycation'](_0x14c71b,_0x262894){const _0x2751eb=_0x3d346a,{username:_0x2fe059,email:_0x145de7,password:_0x222abb,invitedBy:_0x189477,client:client=0x0}=_0x14c71b;if(_0x189477){const _0x557657=await this[_0x2751eb(0x251)][_0x2751eb(0x264)]({'where':{'inviteCode':_0x189477}});if(!_0x557657)throw new common_1[(_0x2751eb(0x224))](_0x2751eb(0x225),common_1[_0x2751eb(0x1d1)]['BAD_REQUEST']);}const _0xdb9902=[{'username':_0x2fe059},{'email':_0x145de7}],_0x20fde3=await this[_0x2751eb(0x251)]['findOne']({'where':_0xdb9902});if(_0x20fde3&&_0x20fde3[_0x2751eb(0x24f)]!==user_constant_1['UserStatusEnum'][_0x2751eb(0x236)])throw new common_1[(_0x2751eb(0x224))]('用户名或者邮箱已被注册!',common_1[_0x2751eb(0x1d1)][_0x2751eb(0x1e9)]);try{const _0x3c1efb=_[_0x2751eb(0x206)](_0x14c71b),_0x448ccf=bcrypt[_0x2751eb(0x252)](_0x222abb,0xa),_0x1c7090=(0x0,utils_1[_0x2751eb(0x23a)])(_0x262894);_0x3c1efb[_0x2751eb(0x1c7)]=_0x448ccf,_0x3c1efb[_0x2751eb(0x1bf)]=_0x1c7090,_0x3c1efb[_0x2751eb(0x1cc)]=client;let _0x21bcbf;if(!_0x20fde3){const _0x9957ea=await this[_0x2751eb(0x232)][_0x2751eb(0x1bd)]([_0x2751eb(0x22e)]);_0x3c1efb[_0x2751eb(0x1fc)]=_0x9957ea,_0x21bcbf=await this['userEntity'][_0x2751eb(0x257)](_0x3c1efb);}else _0x21bcbf=_0x20fde3;const _0xf26261=await this[_0x2751eb(0x1c5)]['find']({'where':{'configKey':(0x0,typeorm_2['In'])(['isVerifyEmail','registerBaseUrl',_0x2751eb(0x1ec),_0x2751eb(0x229),_0x2751eb(0x243),_0x2751eb(0x226)])}}),_0x277c5d=_0xf26261['reduce']((_0x4ff888,_0x275cc3)=>{const _0x3c491d=_0x2751eb;return _0x4ff888[_0x275cc3[_0x3c491d(0x1b2)]]=_0x275cc3['configVal'],_0x4ff888;},{}),_0x4d6f9a=_0x277c5d['isVerifyEmail']?Number(_0x277c5d['isVerifyEmail']):0x1;if(_0x4d6f9a){const _0x39a6db=_0x277c5d['registerVerifyExpir']?Number(_0x277c5d[_0x2751eb(0x226)]):0x1e*0x3c,_0x3cb5c6=await this['verificationService'][_0x2751eb(0x1db)](_0x21bcbf,verification_constant_1[_0x2751eb(0x1f6)][_0x2751eb(0x247)],_0x39a6db),{code:_0x59fb4f,email:_0xf7e3ca,id:_0x15d86e}=_0x3cb5c6,{registerVerifyEmailFrom:_0x30ef66}=_0x277c5d;console[_0x2751eb(0x231)](_0x2751eb(0x1c9),_0x277c5d);const _0x3dd2c9=await this[_0x2751eb(0x1d3)]['sendMail']({'to':_0xf7e3ca,'subject':'来自'+_0x30ef66+_0x2751eb(0x260),'template':'register','context':Object[_0x2751eb(0x1e5)]({'baseUrl':_0x277c5d[_0x2751eb(0x205)],'code':_0x59fb4f,'id':_0x15d86e},_0x277c5d)});console[_0x2751eb(0x231)](_0x2751eb(0x1ff),_0x3dd2c9);}else{const {username:_0x234442,email:_0x461b67,id:_0x162bfa,invitedBy:_0x4c890c}=_0x21bcbf;await this[_0x2751eb(0x245)](_0x162bfa,user_constant_1[_0x2751eb(0x220)][_0x2751eb(0x215)]);let _0x10acbb;_0x4c890c&&(_0x10acbb=await this[_0x2751eb(0x1c8)](_0x4c890c)),await this[_0x2751eb(0x1c3)][_0x2751eb(0x25d)](_0x162bfa,_0x10acbb===null||_0x10acbb===void 0x0?void 0x0:_0x10acbb['id']);}return _0x21bcbf;}catch(_0x35ce27){console[_0x2751eb(0x231)]('error:\x20',_0x35ce27);throw _0x35ce27;}}async[_0x3d346a(0x22d)](){const _0x19c08d=_0x3d346a,_0x2bc6ad=await this[_0x19c08d(0x251)][_0x19c08d(0x264)]({'where':{'role':'super'}});return _0x2bc6ad;}async['verifyUserCredentials'](_0x3b27fd){const _0x363f88=_0x3d346a,{username:_0x35ad23,password:_0x291997,uid:uid=0x0,phone:_0xb091ce}=_0x3b27fd;let _0x1ef6b8=null;if(uid>0x0){_0x1ef6b8=await this[_0x363f88(0x251)][_0x363f88(0x264)]({'where':{'id':uid}});if(!_0x1ef6b8)throw new common_1['HttpException']('当前账户不存在!',common_1['HttpStatus'][_0x363f88(0x1e9)]);if(_0x1ef6b8[_0x363f88(0x1c7)][_0x363f88(0x209)](_0x363f88(0x1e7))||_0x1ef6b8['password'][_0x363f88(0x209)](_0x363f88(0x1ed))||_0x1ef6b8[_0x363f88(0x1c7)][_0x363f88(0x209)](_0x363f88(0x227))){if(!bcrypt[_0x363f88(0x1ef)](_0x291997,_0x1ef6b8[_0x363f88(0x1c7)]))throw new common_1[(_0x363f88(0x224))]('当前密码错误!',common_1[_0x363f88(0x1d1)]['BAD_REQUEST']);}else{console[_0x363f88(0x231)](_0x363f88(0x1e6));const _0x19ffbb=crypto['createHash'](_0x363f88(0x22c))[_0x363f88(0x242)](_0x291997)[_0x363f88(0x213)](_0x363f88(0x201));console[_0x363f88(0x231)](_0x363f88(0x1e6),_0x19ffbb);if(_0x19ffbb!==_0x1ef6b8[_0x363f88(0x1c7)])throw new common_1['HttpException']('当前密码错误!',common_1[_0x363f88(0x1d1)][_0x363f88(0x1e9)]);}}if(_0x35ad23&&_0x291997){const _0x9987f2=[{'username':_0x35ad23},{'email':_0x35ad23}];_0x1ef6b8=await this[_0x363f88(0x251)]['findOne']({'where':_0x9987f2});if(!_0x1ef6b8)throw new common_1['HttpException']('当前账户不存在!',common_1[_0x363f88(0x1d1)][_0x363f88(0x1e9)]);if(_0x1ef6b8[_0x363f88(0x1c7)][_0x363f88(0x209)](_0x363f88(0x1e7))||_0x1ef6b8[_0x363f88(0x1c7)][_0x363f88(0x209)]('$2b$')||_0x1ef6b8[_0x363f88(0x1c7)][_0x363f88(0x209)]('$2y$')){if(!bcrypt[_0x363f88(0x1ef)](_0x291997,_0x1ef6b8[_0x363f88(0x1c7)]))throw new common_1[(_0x363f88(0x224))](_0x363f88(0x1fd),common_1[_0x363f88(0x1d1)][_0x363f88(0x1e9)]);}else{console[_0x363f88(0x231)](_0x363f88(0x1e6));const _0x4101eb=crypto[_0x363f88(0x1b3)]('md5')[_0x363f88(0x242)](_0x291997)['digest'](_0x363f88(0x201));console[_0x363f88(0x231)](_0x363f88(0x1e6),_0x4101eb);if(_0x4101eb!==_0x1ef6b8[_0x363f88(0x1c7)])throw new common_1['HttpException']('当前密码错误!',common_1['HttpStatus'][_0x363f88(0x1e9)]);}}if(_0xb091ce&&_0x291997){const _0x498267=[{'phone':_0xb091ce}];_0x1ef6b8=await this[_0x363f88(0x251)][_0x363f88(0x264)]({'where':_0x498267});if(!_0x1ef6b8)throw new common_1[(_0x363f88(0x224))](_0x363f88(0x25e),common_1['HttpStatus']['BAD_REQUEST']);if(_0x1ef6b8['password']['startsWith'](_0x363f88(0x1e7))||_0x1ef6b8['password'][_0x363f88(0x209)](_0x363f88(0x1ed))||_0x1ef6b8[_0x363f88(0x1c7)][_0x363f88(0x209)]('$2y$')){if(!bcrypt[_0x363f88(0x1ef)](_0x291997,_0x1ef6b8['password']))throw new common_1[(_0x363f88(0x224))]('当前密码错误!',common_1[_0x363f88(0x1d1)][_0x363f88(0x1e9)]);}else{console['log'](_0x363f88(0x1e6));const _0x103cd0=crypto[_0x363f88(0x1b3)](_0x363f88(0x22c))['update'](_0x291997)[_0x363f88(0x213)](_0x363f88(0x201));console[_0x363f88(0x231)](_0x363f88(0x1e6),_0x103cd0);if(_0x103cd0!==_0x1ef6b8['password'])throw new common_1[(_0x363f88(0x224))](_0x363f88(0x1fd),common_1[_0x363f88(0x1d1)]['BAD_REQUEST']);}}if(!_0x1ef6b8)throw new common_1['HttpException'](_0x363f88(0x25e),common_1[_0x363f88(0x1d1)][_0x363f88(0x1e9)]);if(_0x1ef6b8[_0x363f88(0x24f)]!==user_constant_1[_0x363f88(0x220)][_0x363f88(0x215)])throw new common_1['HttpException'](user_constant_1[_0x363f88(0x212)][_0x1ef6b8[_0x363f88(0x24f)]],common_1[_0x363f88(0x1d1)][_0x363f88(0x1e9)]);return _0x1ef6b8;}async[_0x3d346a(0x20a)](_0x5b8162,_0x421981){const _0x7f5c48=_0x3d346a,_0x5d422d=await this[_0x7f5c48(0x251)][_0x7f5c48(0x264)]({'where':{'id':_0x5b8162}});if(_0x5d422d[_0x7f5c48(0x1c7)][_0x7f5c48(0x209)](_0x7f5c48(0x1e7))||_0x5d422d['password'][_0x7f5c48(0x209)]('$2b$')||_0x5d422d[_0x7f5c48(0x1c7)]['startsWith'](_0x7f5c48(0x227)))return bcrypt[_0x7f5c48(0x1ef)](_0x421981,_0x5d422d[_0x7f5c48(0x1c7)]);else{const _0x38d920=crypto[_0x7f5c48(0x1b3)](_0x7f5c48(0x22c))[_0x7f5c48(0x242)](_0x421981)['digest']('hex');return console[_0x7f5c48(0x231)](_0x7f5c48(0x1e6),_0x38d920),_0x38d920===_0x5d422d[_0x7f5c48(0x1c7)];}}async[_0x3d346a(0x245)](_0x393f59,_0x15a4bf){const _0xe1ce29=_0x3d346a,_0x119b04=await this[_0xe1ce29(0x251)][_0xe1ce29(0x242)]({'id':_0x393f59},{'status':_0x15a4bf});return _0x119b04[_0xe1ce29(0x1c2)]>0x0;}async[_0x3d346a(0x22a)](_0x55c8df){const _0x1e4f3e=_0x3d346a,_0x242770=await this['userEntity']['findOne']({'where':{'id':_0x55c8df}});return _0x242770[_0x1e4f3e(0x24f)];}async['queryUserInfoById'](_0x10681e){const _0x100b06=_0x3d346a;return await this[_0x100b06(0x251)][_0x100b06(0x264)]({'where':{'id':_0x10681e}});}async['queryOneUserInfo'](_0x3edb6e){const _0x190d05=_0x3d346a;return await this[_0x190d05(0x251)][_0x190d05(0x264)]({'where':{'id':_0x3edb6e}});}async[_0x3d346a(0x233)](_0x1e4a82){const _0x322b49=_0x3d346a,{id:_0x2b178c,role:_0x228895}=_0x1e4a82;if(_0x228895===_0x322b49(0x256))return!![];const _0x21139d=await this[_0x322b49(0x251)]['findOne']({'where':{'id':_0x2b178c}});if(!_0x21139d)throw new common_1[(_0x322b49(0x224))](_0x322b49(0x1d4),common_1[_0x322b49(0x1d1)][_0x322b49(0x22f)]);if(_0x21139d[_0x322b49(0x24f)]===user_constant_1[_0x322b49(0x220)][_0x322b49(0x1ea)])throw new common_1['HttpException'](_0x322b49(0x24d),common_1[_0x322b49(0x1d1)][_0x322b49(0x1e9)]);if(_0x21139d[_0x322b49(0x24f)]===user_constant_1[_0x322b49(0x220)][_0x322b49(0x1f0)])throw new common_1[(_0x322b49(0x224))]('您的账户已被封禁、如有疑问、请联系管理员!',common_1[_0x322b49(0x1d1)][_0x322b49(0x1e9)]);}async[_0x3d346a(0x1c1)](_0x3bae66){const _0x16ee02=_0x3d346a,_0x1c10de=await this[_0x16ee02(0x251)][_0x16ee02(0x264)]({'where':{'id':_0x3bae66},'select':[_0x16ee02(0x1b7),'avatar',_0x16ee02(0x1eb),_0x16ee02(0x221),_0x16ee02(0x222),'inviteCode',_0x16ee02(0x1f2),'consecutiveDays']});if(!_0x1c10de)throw new common_1[(_0x16ee02(0x224))](_0x16ee02(0x1d4),common_1[_0x16ee02(0x1d1)][_0x16ee02(0x22f)]);_0x1c10de[_0x16ee02(0x210)]=!!(_0x1c10de===null||_0x1c10de===void 0x0?void 0x0:_0x1c10de[_0x16ee02(0x1f2)]),delete _0x1c10de[_0x16ee02(0x1f2)];const _0x1358ca=await this['userBalanceService'][_0x16ee02(0x1b4)](_0x3bae66);return{'userInfo':_0x1c10de,'userBalance':Object[_0x16ee02(0x1e5)]({},_0x1358ca)};}async[_0x3d346a(0x25b)](_0x274a12){return await this['userEntity']['findOne']({'where':{'id':_0x274a12}});}async['getUserOpenId'](_0x177b04){const _0x4587f8=_0x3d346a;return await this[_0x4587f8(0x251)][_0x4587f8(0x264)]({'where':{'openId':_0x177b04}});}async['updateInfo'](_0x414225,_0x3bf5dd){const _0x323c0b=_0x3d346a,{id:_0x13a34a}=_0x3bf5dd['user'],_0x173104=await this[_0x323c0b(0x251)][_0x323c0b(0x264)]({'where':{'id':_0x13a34a}});if(!_0x173104)throw new common_1['HttpException'](_0x323c0b(0x20c),common_1['HttpStatus']['BAD_REQUEST']);if(_0x414225[_0x323c0b(0x1b7)]&&_0x173104['username']===_0x414225[_0x323c0b(0x1b7)])throw new common_1[(_0x323c0b(0x224))]('没有变更,无需更改!',common_1['HttpStatus'][_0x323c0b(0x1e9)]);if(_0x414225[_0x323c0b(0x1b7)]){const _0x424ff8=await this[_0x323c0b(0x251)]['findOne']({'where':{'username':_0x414225[_0x323c0b(0x1b7)],'id':(0x0,typeorm_2[_0x323c0b(0x262)])(_0x13a34a)}});if(_0x424ff8)throw new common_1[(_0x323c0b(0x224))](_0x323c0b(0x21c),common_1[_0x323c0b(0x1d1)][_0x323c0b(0x1e9)]);}const _0xe21fed=await this[_0x323c0b(0x251)][_0x323c0b(0x242)]({'id':_0x13a34a},_0x414225);if(_0xe21fed['affected']<=0x0)throw new common_1[(_0x323c0b(0x224))](_0x323c0b(0x259),common_1['HttpStatus'][_0x323c0b(0x1e9)]);return _0x323c0b(0x1e4);}async['updateUserPassword'](_0x576b32,_0x19c996){const _0x3329b4=_0x3d346a,_0x12a333=bcrypt[_0x3329b4(0x252)](_0x19c996,0xa),_0x4d214f=await this[_0x3329b4(0x251)]['update']({'id':_0x576b32},{'password':_0x12a333});if(_0x4d214f[_0x3329b4(0x1c2)]<=0x0)throw new common_1[(_0x3329b4(0x224))](_0x3329b4(0x1b9),common_1[_0x3329b4(0x1d1)][_0x3329b4(0x1e9)]);}async[_0x3d346a(0x23c)](_0x5aae65){const _0x920043=_0x3d346a,{id:_0xe8c7d3}=_0x5aae65['user'],_0x22f9af=await this[_0x920043(0x251)][_0x920043(0x264)]({'where':{'id':_0xe8c7d3}});if(!_0x22f9af||_0x22f9af[_0x920043(0x24b)])throw new common_1[(_0x920043(0x224))](_0x920043(0x1cb),common_1[_0x920043(0x1d1)][_0x920043(0x1e9)]);const _0x1138d1=(0x0,utils_1[_0x920043(0x1d2)])(),_0x1f0635=await this[_0x920043(0x251)][_0x920043(0x264)]({'where':{'inviteCode':_0x1138d1}});if(_0x1f0635)throw new common_1['HttpException'](_0x920043(0x25c),common_1[_0x920043(0x1d1)][_0x920043(0x1e9)]);const _0x59c59b=await this[_0x920043(0x251)]['update']({'id':_0xe8c7d3},{'inviteCode':_0x1138d1});if(_0x59c59b['affected']<=0x0)throw new common_1[(_0x920043(0x224))](_0x920043(0x25c),common_1['HttpStatus'][_0x920043(0x1e9)]);return _0x1138d1;}async[_0x3d346a(0x20b)](_0x387a79,_0x2b2181){const _0x9ef7e=_0x3d346a;try{const {id:_0x21cd6e}=_0x387a79[_0x9ef7e(0x1ca)],{page:page=0x1,size:size=0xa}=_0x2b2181,_0xadb2b0=await this[_0x9ef7e(0x251)][_0x9ef7e(0x264)]({'where':{'id':_0x21cd6e}}),{inviteCode:_0x3480b8}=_0xadb2b0;if(!_0x3480b8)return[];const [_0x1dbdd4,_0x2d7cca]=await this[_0x9ef7e(0x251)][_0x9ef7e(0x237)]({'where':{'inviteCode':_0x3480b8},'order':{'id':_0x9ef7e(0x1d5)},'select':[_0x9ef7e(0x1b7),_0x9ef7e(0x221),_0x9ef7e(0x240),_0x9ef7e(0x24f),_0x9ef7e(0x1fc)],'take':size,'skip':(page-0x1)*size});return(0x0,utils_1[_0x9ef7e(0x1d9)])(_0x1dbdd4)[_0x9ef7e(0x248)](_0x35b984=>{const _0x240e32=_0x9ef7e;return _0x35b984[_0x240e32(0x221)]=(0x0,utils_1['maskEmail'])(_0x35b984[_0x240e32(0x221)]),_0x35b984;}),{'rows':_0x1dbdd4,'count':_0x2d7cca};}catch(_0x5c8537){console[_0x9ef7e(0x231)](_0x9ef7e(0x204),_0x5c8537);throw new common_1['HttpException'](_0x9ef7e(0x261),common_1[_0x9ef7e(0x1d1)][_0x9ef7e(0x1e9)]);}}async['inviteLink'](_0x504a23){const _0x335b77=_0x3d346a,_0x2a3135=await this[_0x335b77(0x251)][_0x335b77(0x264)]({'where':{'inviteCode':_0x504a23}});if(!_0x2a3135)return 0x1;const {inviteLinkCount:inviteLinkCount=0x0}=_0x2a3135,_0x272838=await this[_0x335b77(0x251)][_0x335b77(0x242)]({'inviteCode':_0x504a23},{'inviteLinkCount':inviteLinkCount+0x1});return _0x272838['affected']?0x1:0x0;}async[_0x3d346a(0x1c8)](_0x2d077d){const _0x362a0a=_0x3d346a;return await this[_0x362a0a(0x251)]['findOne']({'where':{'inviteCode':_0x2d077d}});}async[_0x3d346a(0x1ce)](_0x42cc18){const _0x3f89b6=_0x3d346a,{userId:_0x1f8ada,model3Count:model3Count=0x0,model4Count:model4Count=0x0,drawMjCount:drawMjCount=0x0}=_0x42cc18;await this[_0x3f89b6(0x1c3)][_0x3f89b6(0x22b)](_0x1f8ada,{'model3Count':model3Count,'model4Count':model4Count,'drawMjCount':drawMjCount});const _0x27802e=await this[_0x3f89b6(0x1c3)]['saveRecordRechargeLog']({'userId':_0x1f8ada,'rechargeType':balance_constant_1[_0x3f89b6(0x21a)][_0x3f89b6(0x1df)],'model3Count':model3Count,'model4Count':model4Count,'drawMjCount':drawMjCount,'extent':''});return _0x27802e;}async[_0x3d346a(0x1f4)](_0x2ed196,_0x305baa){const _0x11e1d6=_0x3d346a,{page:page=0x1,size:size=0xa,username:_0x38f50e,email:_0x3e33e0,status:_0x3ff217,keyword:_0x39cd4e,phone:_0xfe63b}=_0x2ed196;let _0x115ceb={};_0x38f50e&&Object[_0x11e1d6(0x1e5)](_0x115ceb,{'username':(0x0,typeorm_2[_0x11e1d6(0x267)])('%'+_0x38f50e+'%')}),_0x3e33e0&&Object[_0x11e1d6(0x1e5)](_0x115ceb,{'email':(0x0,typeorm_2[_0x11e1d6(0x267)])('%'+_0x3e33e0+'%')}),_0xfe63b&&Object[_0x11e1d6(0x1e5)](_0x115ceb,{'phone':(0x0,typeorm_2[_0x11e1d6(0x267)])('%'+_0xfe63b+'%')}),_0x3ff217&&Object[_0x11e1d6(0x1e5)](_0x115ceb,{'status':_0x3ff217});_0x39cd4e&&(_0x115ceb=[{'username':(0x0,typeorm_2[_0x11e1d6(0x267)])('%'+_0x39cd4e+'%')},{'email':(0x0,typeorm_2[_0x11e1d6(0x267)])('%'+_0x39cd4e+'%')},{'phone':(0x0,typeorm_2[_0x11e1d6(0x267)])('%'+_0x39cd4e+'%')}]);const [_0x575a32,_0x99c72b]=await this[_0x11e1d6(0x251)][_0x11e1d6(0x237)]({'skip':(page-0x1)*size,'where':_0x115ceb,'take':size,'order':{'createdAt':'DESC'},'cache':!![],'select':['username',_0x11e1d6(0x1fc),_0x11e1d6(0x24b),'role','sign','status','id',_0x11e1d6(0x221),_0x11e1d6(0x240),'lastLoginIp',_0x11e1d6(0x1d7)]}),_0x46997a=_0x575a32[_0x11e1d6(0x248)](_0x20ee67=>_0x20ee67['id']),_0x12e4a7=await this[_0x11e1d6(0x1c3)][_0x11e1d6(0x20d)](_0x46997a);return _0x575a32[_0x11e1d6(0x25f)](_0x6be31c=>_0x6be31c[_0x11e1d6(0x21b)]=_0x12e4a7[_0x11e1d6(0x266)](_0x588449=>_0x588449[_0x11e1d6(0x218)]===_0x6be31c['id'])),_0x305baa[_0x11e1d6(0x1ca)]['role']!==_0x11e1d6(0x202)&&_0x575a32['forEach'](_0x620709=>_0x620709[_0x11e1d6(0x221)]=(0x0,utils_1[_0x11e1d6(0x255)])(_0x620709['email'])),_0x305baa[_0x11e1d6(0x1ca)][_0x11e1d6(0x1eb)]!==_0x11e1d6(0x202)&&_0x575a32['forEach'](_0x27917a=>_0x27917a[_0x11e1d6(0x244)]=(0x0,utils_1[_0x11e1d6(0x23b)])(_0x27917a[_0x11e1d6(0x244)])),_0x305baa[_0x11e1d6(0x1ca)]['role']!==_0x11e1d6(0x202)&&_0x575a32['forEach'](_0x1ab97a=>_0x1ab97a[_0x11e1d6(0x1d7)]=(0x0,utils_1[_0x11e1d6(0x23b)])(_0x1ab97a[_0x11e1d6(0x1d7)])),{'rows':_0x575a32,'count':_0x99c72b};}async[_0x3d346a(0x1dc)]({id:_0xe1821d}){const _0x35f780=_0x3d346a;return await this[_0x35f780(0x251)][_0x35f780(0x264)]({'where':{'id':_0xe1821d},'select':['username','avatar',_0x35f780(0x24b),'role',_0x35f780(0x222),'status']});}async['updateStatus'](_0x3b4718){const _0x4ef112=_0x3d346a,{id:_0x5346b2,status:_0xa59483}=_0x3b4718,_0x40a438=await this[_0x4ef112(0x251)]['findOne']({'where':{'id':_0x5346b2}});if(!_0x40a438)throw new common_1[(_0x4ef112(0x224))](_0x4ef112(0x207),common_1[_0x4ef112(0x1d1)][_0x4ef112(0x1e9)]);if(_0x40a438['role']===_0x4ef112(0x202))throw new common_1['HttpException'](_0x4ef112(0x1e8),common_1[_0x4ef112(0x1d1)][_0x4ef112(0x1e9)]);if(_0x40a438['status']===user_constant_1['UserStatusEnum']['PENDING'])throw new common_1[(_0x4ef112(0x224))](_0x4ef112(0x238),common_1[_0x4ef112(0x1d1)]['BAD_REQUEST']);if(_0x40a438['role']===_0x4ef112(0x202))throw new common_1[(_0x4ef112(0x224))](_0x4ef112(0x1e8),common_1[_0x4ef112(0x1d1)][_0x4ef112(0x1e9)]);if(_0xa59483===user_constant_1['UserStatusEnum'][_0x4ef112(0x236)])throw new common_1['HttpException'](_0x4ef112(0x1f1),common_1[_0x4ef112(0x1d1)][_0x4ef112(0x1e9)]);const _0x239003=await this[_0x4ef112(0x251)][_0x4ef112(0x242)]({'id':_0x5346b2},{'status':_0xa59483});if(_0x239003[_0x4ef112(0x1c2)]<=0x0)throw new common_1['HttpException'](_0x4ef112(0x21d),common_1[_0x4ef112(0x1d1)][_0x4ef112(0x1e9)]);return _0x4ef112(0x203);}async[_0x3d346a(0x200)](_0x2ac378){const _0x508aa0=_0x3d346a,{id:_0x279179}=_0x2ac378,_0x3348c9=await this[_0x508aa0(0x251)][_0x508aa0(0x264)]({'where':{'id':_0x279179}});if(!_0x3348c9)throw new common_1[(_0x508aa0(0x224))](_0x508aa0(0x207),common_1['HttpStatus'][_0x508aa0(0x1e9)]);const _0x458730=_0x508aa0(0x24c),_0x4cc6f5=bcrypt[_0x508aa0(0x252)](_0x458730,0xa),_0x16fd36=await this[_0x508aa0(0x251)][_0x508aa0(0x242)]({'id':_0x279179},{'password':_0x4cc6f5});if(_0x16fd36['affected']<=0x0)throw new common_1['HttpException'](_0x508aa0(0x20f),common_1[_0x508aa0(0x1d1)]['BAD_REQUEST']);return'密码重置为['+_0x458730+_0x508aa0(0x253);}async['savaLoginIp'](_0x68f4a2,_0x501685){const _0x56334c=_0x3d346a;return await this[_0x56334c(0x251)][_0x56334c(0x242)]({'id':_0x68f4a2},{'lastLoginIp':_0x501685});}async[_0x3d346a(0x1de)](_0x3d53d0,_0x1a8382){const _0x4d45ba=_0x3d346a,_0x200e37=await this[_0x4d45ba(0x251)]['findOne']({'where':{'openId':_0x3d53d0}});if(!_0x200e37){const _0xd6b4c8=_0x1a8382?_0x1a8382[_0x4d45ba(0x21e)](':')[0x1]:'',_0x2f3ab9=await this[_0x4d45ba(0x1c8)](_0xd6b4c8),_0x2aed4d=await this[_0x4d45ba(0x23d)](_0x3d53d0,_0xd6b4c8);return await this[_0x4d45ba(0x1c3)][_0x4d45ba(0x25d)](_0x2aed4d['id'],_0xd6b4c8?_0x2f3ab9===null||_0x2f3ab9===void 0x0?void 0x0:_0x2f3ab9['id']:null),_0x2aed4d;}return _0x200e37;}async[_0x3d346a(0x23d)](_0x184cde,_0x3da798){const _0x54b90b=_0x3d346a,_0xa68bcc=await this[_0x54b90b(0x232)]['getConfigs'](['userDefautlAvatar']),_0x25cf9b={'avatar':_0xa68bcc,'username':'用户'+(0x0,utils_1[_0x54b90b(0x1cf)])(),'status':user_constant_1[_0x54b90b(0x220)]['ACTIVE'],'sex':0x0,'email':(0x0,utils_1[_0x54b90b(0x1cf)])()+_0x54b90b(0x258),'invitedBy':_0x3da798,'openId':_0x184cde},_0x549cf0=await this[_0x54b90b(0x251)][_0x54b90b(0x257)](_0x25cf9b);return _0x549cf0;}async[_0x3d346a(0x1c6)](_0x341824,_0x184050){const _0x24c6c0=_0x3d346a;try{const _0x39ee6d=await this['userEntity'][_0x24c6c0(0x264)]({'where':{'id':_0x184050}});if(!_0x39ee6d)return{'status':![],'msg':_0x24c6c0(0x250)};const _0x3a3c03=await this['userEntity']['findOne']({'where':{'openId':_0x341824}});if(_0x3a3c03)return{'status':![],'msg':_0x24c6c0(0x1f3)};const _0xd3719b=await this[_0x24c6c0(0x251)]['update']({'id':_0x184050},{'openId':_0x341824});if(_0xd3719b['affected']<=0x0)return{'status':![],'msg':_0x24c6c0(0x219)};return{'status':!![],'msg':_0x24c6c0(0x21f)};}catch(_0x33726c){return{'status':![],'msg':_0x24c6c0(0x219)};}}async[_0x3d346a(0x1c4)](_0x222eb5){const _0x4f2205=_0x3d346a,_0x380202=await this[_0x4f2205(0x251)][_0x4f2205(0x264)]({'where':{'id':_0x222eb5}});return _0x380202===null||_0x380202===void 0x0?void 0x0:_0x380202[_0x4f2205(0x1f2)];}async[_0x3d346a(0x1fe)](_0x2f7d5){const _0x553af5=_0x3d346a,{username:_0x22160,password:_0x1b14ec,phone:_0x121640,phoneCode:_0x5f2de4}=_0x2f7d5,_0x296f5b=await this[_0x553af5(0x251)][_0x553af5(0x264)]({'where':[{'username':_0x22160},{'phone':_0x121640}]});if(_0x296f5b&&_0x296f5b['username']===_0x22160)throw new common_1[(_0x553af5(0x224))]('用户名已存在、请更换用户名!',common_1[_0x553af5(0x1d1)][_0x553af5(0x1e9)]);if(_0x296f5b&&_0x296f5b[_0x553af5(0x1d7)]===_0x121640)throw new common_1[(_0x553af5(0x224))]('当前手机号已注册、请勿重复注册!',common_1['HttpStatus'][_0x553af5(0x1e9)]);}async[_0x3d346a(0x1f9)](_0x39ae7a){const _0x31342f=_0x3d346a;return await this[_0x31342f(0x251)][_0x31342f(0x257)](_0x39ae7a);}};UserService=__decorate([(0x0,common_1[_0x3d346a(0x1f5)])(),__param(0x0,(0x0,typeorm_1[_0x3d346a(0x234)])(user_entity_1['UserEntity'])),__param(0x1,(0x0,typeorm_1[_0x3d346a(0x234)])(whiteList_entity_1[_0x3d346a(0x23e)])),__param(0x7,(0x0,typeorm_1[_0x3d346a(0x234)])(config_entity_1[_0x3d346a(0x217)])),__metadata(_0x3d346a(0x23f),[typeorm_2[_0x3d346a(0x1da)],typeorm_2[_0x3d346a(0x1da)],typeorm_2[_0x3d346a(0x1b8)],verification_service_1[_0x3d346a(0x1fa)],mailer_1[_0x3d346a(0x254)],userBalance_service_1[_0x3d346a(0x249)],globalConfig_service_1[_0x3d346a(0x1d6)],typeorm_2[_0x3d346a(0x1da)]])],UserService),exports[_0x3d346a(0x1d0)]=UserService; |