mirror of
https://github.com/xiaoyiweb/YiAi.git
synced 2025-09-25 12:46:39 +08:00
1 line
27 KiB
JavaScript
1 line
27 KiB
JavaScript
'use strict';const _0x50c011=_0x32e2;(function(_0x3be8a6,_0x26abea){const _0xacf592=_0x32e2,_0x7115eb=_0x3be8a6();while(!![]){try{const _0x316fc6=-parseInt(_0xacf592(0x1e1))/0x1*(parseInt(_0xacf592(0x17f))/0x2)+-parseInt(_0xacf592(0x1af))/0x3*(parseInt(_0xacf592(0x1a3))/0x4)+parseInt(_0xacf592(0x167))/0x5+-parseInt(_0xacf592(0x181))/0x6+parseInt(_0xacf592(0x1d6))/0x7+parseInt(_0xacf592(0x15e))/0x8+parseInt(_0xacf592(0x195))/0x9;if(_0x316fc6===_0x26abea)break;else _0x7115eb['push'](_0x7115eb['shift']());}catch(_0x5de658){_0x7115eb['push'](_0x7115eb['shift']());}}}(_0x3199,0xd49e2));function _0x32e2(_0x38c65c,_0x441fb0){const _0x31995e=_0x3199();return _0x32e2=function(_0x32e2cc,_0x75a42d){_0x32e2cc=_0x32e2cc-0x13d;let _0x23fcae=_0x31995e[_0x32e2cc];return _0x23fcae;},_0x32e2(_0x38c65c,_0x441fb0);}function _0x3199(){const _0x35bee5=['configMap:\x20','../globalConfig/config.entity','获取邀请记录失败!','user','hex','Not','createUserAndVerifycation','decorate','queryUserBalance','10810864zdPtTn','UNAUTHORIZED','@nestjs/typeorm','addBalanceToNewUser','__metadata','globalConfigService','reduce','getUserInfo','__param','1244670sQtzCB','consecutiveDays','绑定微信失败、请联系管理员!','avatar','crypto','queryOne','qureyUserInfoByInviteCode','getOwnPropertyDescriptor','metadata','getUserFromOpenId','$2a$','getOpenIdByUserId','registerBaseUrl','getUserById','register','无效的邀请码!','修改密码失败、请重新试试吧。','verificationService','formatCreateOrUpdateDate','没有变更,无需更改!','userDefautlAvatar','email\x20response\x20\x20->\x20:\x20','getUserOpenId','../../common/constants/balance.constant','1868822GzlEan','save','50994jJUxxR','forEach','userRecharge','hashSync','updateStatus','bindWx','createRandomUid','----,','role','__esModule','email','find','error:\x20','password','compareSync','DESC','当前密码错误!','maskIpAddress','verifyUserPassword','当前手机号已注册、请勿重复注册!','2600730lbhkjH','verifyUserCredentials','createUserFromOpenId','LOCKED','object','RechargeType','log','ConfigEntity','connection','getInviteRecord','重置密码失败!','queryAll','修改用户状态失败!','md5','316GmGbiU','VerificationEnum','registerIp','Repository','__decorate','Injectable','UserStatusErrMsg','saveRecordRechargeLog','visitor','digest','@nestjs/common','lastLoginIp','36342ToZDWi','inviteCode','updateUserPassword','userBalanceService','isBindWx','./user.entity','openId','UserStatusEnum','checkUserStatus','findAndCount','assign','PENDING','GlobalConfigService','genInviteCode','super','maskEmail','whiteListEntity','../../common/constants/user.constant','queryUserInfoById','../globalConfig/globalConfig.service','../verification/verification.service','configKey','createHash','../../common/utils','BAD_REQUEST','$2y$','findOne','configEntity','当前用户信息失效、请重新登录!','用户名或者邮箱已被注册!','resetUserPass','../userBalance/userBalance.service','的账号激活','cloneDeep','registerVerifyEmailDesc','ACTIVE','mailerService','用户名已存在、请更换用户名!','registerVerifyExpir','6170752DVXwCD','用户名已存在!','status','该微信已绑定其他账号!','defineProperty','sign','username','../chatgpt/whiteList.entity','修改用户信息失败!','Like','用户不存在!','1SUgLSB','function','$2b$','update','不可将用户置为未激活状态!','HttpStatus','您的账户已被永久加入黑名单、如有疑问、请联系管理员!','startsWith','affected','当前账户不存在!','balanceInfo','map','phone','您的账户已被封禁、如有疑问、请联系管理员!','sendMail','design:paramtypes','Registration','HttpException','createdAt','getClientIp','生成邀请码失败,请重新试一次吧!','getConfigs','isVerifyEmail','registerVerifyEmailTitle','queryOneUserInfo','typeorm','@default.com','userEntity','createUser','InjectRepository','WhiteListEntity','当前用户不存在!','123456','length'];_0x3199=function(){return _0x35bee5;};return _0x3199();}var __decorate=this&&this[_0x50c011(0x1a7)]||function(_0x1f628d,_0x3ea084,_0x1bdbcf,_0x44228f){const _0x10f2cf=_0x50c011;var _0x2399bc=arguments[_0x10f2cf(0x154)],_0xb208b9=_0x2399bc<0x3?_0x3ea084:_0x44228f===null?_0x44228f=Object[_0x10f2cf(0x16e)](_0x3ea084,_0x1bdbcf):_0x44228f,_0x9dd54e;if(typeof Reflect===_0x10f2cf(0x199)&&typeof Reflect[_0x10f2cf(0x15c)]===_0x10f2cf(0x1e2))_0xb208b9=Reflect[_0x10f2cf(0x15c)](_0x1f628d,_0x3ea084,_0x1bdbcf,_0x44228f);else{for(var _0x2595fb=_0x1f628d[_0x10f2cf(0x154)]-0x1;_0x2595fb>=0x0;_0x2595fb--)if(_0x9dd54e=_0x1f628d[_0x2595fb])_0xb208b9=(_0x2399bc<0x3?_0x9dd54e(_0xb208b9):_0x2399bc>0x3?_0x9dd54e(_0x3ea084,_0x1bdbcf,_0xb208b9):_0x9dd54e(_0x3ea084,_0x1bdbcf))||_0xb208b9;}return _0x2399bc>0x3&&_0xb208b9&&Object[_0x10f2cf(0x1da)](_0x3ea084,_0x1bdbcf,_0xb208b9),_0xb208b9;},__metadata=this&&this[_0x50c011(0x162)]||function(_0x5cdac1,_0x741082){const _0x44c0d2=_0x50c011;if(typeof Reflect==='object'&&typeof Reflect[_0x44c0d2(0x16f)]===_0x44c0d2(0x1e2))return Reflect[_0x44c0d2(0x16f)](_0x5cdac1,_0x741082);},__param=this&&this[_0x50c011(0x166)]||function(_0x2f6d7b,_0x147b5f){return function(_0x4842f0,_0x56c3a0){_0x147b5f(_0x4842f0,_0x56c3a0,_0x2f6d7b);};};Object[_0x50c011(0x1da)](exports,_0x50c011(0x18a),{'value':!![]}),exports['UserService']=void 0x0;const globalConfig_service_1=require(_0x50c011(0x1c2)),user_constant_1=require(_0x50c011(0x1c0)),mailer_1=require('@nestjs-modules/mailer'),verification_service_1=require(_0x50c011(0x1c3)),common_1=require(_0x50c011(0x1ad)),typeorm_1=require(_0x50c011(0x160)),typeorm_2=require(_0x50c011(0x14c)),user_entity_1=require(_0x50c011(0x1b4)),bcrypt=require('bcryptjs'),crypto=require(_0x50c011(0x16b)),_=require('lodash'),verification_constant_1=require('../../common/constants/verification.constant'),userBalance_service_1=require(_0x50c011(0x1ce)),utils_1=require(_0x50c011(0x1c6)),balance_constant_1=require(_0x50c011(0x17e)),config_entity_1=require(_0x50c011(0x156)),whiteList_entity_1=require(_0x50c011(0x1dd));let UserService=class UserService{constructor(_0x46cf61,_0x5297d9,_0x2f5c21,_0x59337f,_0x1467a6,_0x20c90e,_0x204773,_0x1e5c1b){const _0x552c56=_0x50c011;this['userEntity']=_0x46cf61,this[_0x552c56(0x1bf)]=_0x5297d9,this[_0x552c56(0x19d)]=_0x2f5c21,this[_0x552c56(0x178)]=_0x59337f,this[_0x552c56(0x1d3)]=_0x1467a6,this['userBalanceService']=_0x20c90e,this[_0x552c56(0x163)]=_0x204773,this[_0x552c56(0x1ca)]=_0x1e5c1b;}async[_0x50c011(0x15b)](_0x4b6bad,_0x3ee7a9){const _0x40f236=_0x50c011,{username:_0x1b40b2,email:_0x2b7f6e,password:_0x165d28,invitedBy:_0x5a84b6,client:client=0x0}=_0x4b6bad;if(_0x5a84b6){const _0x921976=await this['userEntity'][_0x40f236(0x1c9)]({'where':{'inviteCode':_0x5a84b6}});if(!_0x921976)throw new common_1[(_0x40f236(0x144))](_0x40f236(0x176),common_1[_0x40f236(0x1e6)][_0x40f236(0x1c7)]);}const _0xef508c=[{'username':_0x1b40b2},{'email':_0x2b7f6e}],_0x1f3221=await this[_0x40f236(0x14e)][_0x40f236(0x1c9)]({'where':_0xef508c});if(_0x1f3221&&_0x1f3221[_0x40f236(0x1d8)]!==user_constant_1[_0x40f236(0x1b6)][_0x40f236(0x1ba)])throw new common_1[(_0x40f236(0x144))](_0x40f236(0x1cc),common_1[_0x40f236(0x1e6)][_0x40f236(0x1c7)]);try{const _0x47fe37=_[_0x40f236(0x1d0)](_0x4b6bad),_0x22b2ee=bcrypt[_0x40f236(0x184)](_0x165d28,0xa),_0x1b1316=(0x0,utils_1[_0x40f236(0x146)])(_0x3ee7a9);_0x47fe37[_0x40f236(0x18e)]=_0x22b2ee,_0x47fe37[_0x40f236(0x1a5)]=_0x1b1316,_0x47fe37['client']=client;let _0x4a8467;if(!_0x1f3221){const _0x1856b9=await this[_0x40f236(0x163)][_0x40f236(0x148)]([_0x40f236(0x17b)]);_0x47fe37[_0x40f236(0x16a)]=_0x1856b9,_0x4a8467=await this[_0x40f236(0x14e)][_0x40f236(0x180)](_0x47fe37);}else _0x4a8467=_0x1f3221;const _0x5d03ac=await this[_0x40f236(0x1ca)][_0x40f236(0x18c)]({'where':{'configKey':(0x0,typeorm_2['In'])([_0x40f236(0x149),_0x40f236(0x173),_0x40f236(0x14a),_0x40f236(0x1d1),'registerVerifyEmailFrom','registerVerifyExpir'])}}),_0x228ea2=_0x5d03ac[_0x40f236(0x164)]((_0x41963b,_0x502d94)=>{const _0x42d80e=_0x40f236;return _0x41963b[_0x502d94[_0x42d80e(0x1c4)]]=_0x502d94['configVal'],_0x41963b;},{}),_0x18f72d=_0x228ea2['isVerifyEmail']?Number(_0x228ea2['isVerifyEmail']):0x1;if(_0x18f72d){const _0x482974=_0x228ea2[_0x40f236(0x1d5)]?Number(_0x228ea2['registerVerifyExpir']):0x1e*0x3c,_0x24cc47=await this[_0x40f236(0x178)]['createVerification'](_0x4a8467,verification_constant_1[_0x40f236(0x1a4)][_0x40f236(0x143)],_0x482974),{code:_0x11a44e,email:_0x485eae,id:_0x471f7f}=_0x24cc47,{registerVerifyEmailFrom:_0x394244}=_0x228ea2;console[_0x40f236(0x19b)](_0x40f236(0x155),_0x228ea2);const _0x484553=await this[_0x40f236(0x1d3)][_0x40f236(0x141)]({'to':_0x485eae,'subject':'来自'+_0x394244+_0x40f236(0x1cf),'template':_0x40f236(0x175),'context':Object[_0x40f236(0x1b9)]({'baseUrl':_0x228ea2[_0x40f236(0x173)],'code':_0x11a44e,'id':_0x471f7f},_0x228ea2)});console[_0x40f236(0x19b)](_0x40f236(0x17c),_0x484553);}else{const {username:_0x3295f8,email:_0x276e45,id:_0x5e6bde,invitedBy:_0x388052}=_0x4a8467;await this['updateUserStatus'](_0x5e6bde,user_constant_1[_0x40f236(0x1b6)][_0x40f236(0x1d2)]);let _0x1435f0;_0x388052&&(_0x1435f0=await this[_0x40f236(0x16d)](_0x388052)),await this[_0x40f236(0x1b2)][_0x40f236(0x161)](_0x5e6bde,_0x1435f0===null||_0x1435f0===void 0x0?void 0x0:_0x1435f0['id']);}return _0x4a8467;}catch(_0x17242b){console[_0x40f236(0x19b)](_0x40f236(0x18d),_0x17242b);throw _0x17242b;}}async['getSuper'](){const _0x51033a=_0x50c011,_0xd24aaa=await this['userEntity'][_0x51033a(0x1c9)]({'where':{'role':'super'}});return _0xd24aaa;}async[_0x50c011(0x196)](_0x30a86c){const _0x5b051a=_0x50c011,{username:_0x5b0f47,password:_0x19fbb3,uid:uid=0x0,phone:_0x36d50d}=_0x30a86c;let _0x5a3410=null;if(uid>0x0){_0x5a3410=await this[_0x5b051a(0x14e)][_0x5b051a(0x1c9)]({'where':{'id':uid}});if(!_0x5a3410)throw new common_1[(_0x5b051a(0x144))](_0x5b051a(0x1ea),common_1[_0x5b051a(0x1e6)][_0x5b051a(0x1c7)]);if(_0x5a3410[_0x5b051a(0x18e)]['startsWith'](_0x5b051a(0x171))||_0x5a3410[_0x5b051a(0x18e)]['startsWith'](_0x5b051a(0x1e3))||_0x5a3410[_0x5b051a(0x18e)]['startsWith'](_0x5b051a(0x1c8))){if(!bcrypt[_0x5b051a(0x18f)](_0x19fbb3,_0x5a3410[_0x5b051a(0x18e)]))throw new common_1[(_0x5b051a(0x144))](_0x5b051a(0x191),common_1[_0x5b051a(0x1e6)][_0x5b051a(0x1c7)]);}else{console[_0x5b051a(0x19b)]('----,');const _0x392c64=crypto['createHash'](_0x5b051a(0x1a2))[_0x5b051a(0x1e4)](_0x19fbb3)[_0x5b051a(0x1ac)](_0x5b051a(0x159));console['log']('----,',_0x392c64);if(_0x392c64!==_0x5a3410[_0x5b051a(0x18e)])throw new common_1['HttpException'](_0x5b051a(0x191),common_1['HttpStatus'][_0x5b051a(0x1c7)]);}}if(_0x5b0f47&&_0x19fbb3){const _0x1544ce=[{'username':_0x5b0f47},{'email':_0x5b0f47}];_0x5a3410=await this[_0x5b051a(0x14e)][_0x5b051a(0x1c9)]({'where':_0x1544ce});if(!_0x5a3410)throw new common_1['HttpException']('当前账户不存在!',common_1[_0x5b051a(0x1e6)][_0x5b051a(0x1c7)]);if(_0x5a3410[_0x5b051a(0x18e)][_0x5b051a(0x1e8)](_0x5b051a(0x171))||_0x5a3410[_0x5b051a(0x18e)][_0x5b051a(0x1e8)](_0x5b051a(0x1e3))||_0x5a3410['password'][_0x5b051a(0x1e8)](_0x5b051a(0x1c8))){if(!bcrypt[_0x5b051a(0x18f)](_0x19fbb3,_0x5a3410[_0x5b051a(0x18e)]))throw new common_1['HttpException'](_0x5b051a(0x191),common_1[_0x5b051a(0x1e6)][_0x5b051a(0x1c7)]);}else{console[_0x5b051a(0x19b)](_0x5b051a(0x188));const _0x36b06f=crypto[_0x5b051a(0x1c5)]('md5')[_0x5b051a(0x1e4)](_0x19fbb3)['digest'](_0x5b051a(0x159));console[_0x5b051a(0x19b)](_0x5b051a(0x188),_0x36b06f);if(_0x36b06f!==_0x5a3410['password'])throw new common_1[(_0x5b051a(0x144))](_0x5b051a(0x191),common_1[_0x5b051a(0x1e6)][_0x5b051a(0x1c7)]);}}if(_0x36d50d&&_0x19fbb3){const _0x46fadd=[{'phone':_0x36d50d}];_0x5a3410=await this[_0x5b051a(0x14e)]['findOne']({'where':_0x46fadd});if(!_0x5a3410)throw new common_1[(_0x5b051a(0x144))](_0x5b051a(0x1ea),common_1['HttpStatus']['BAD_REQUEST']);if(_0x5a3410[_0x5b051a(0x18e)][_0x5b051a(0x1e8)]('$2a$')||_0x5a3410['password']['startsWith'](_0x5b051a(0x1e3))||_0x5a3410[_0x5b051a(0x18e)][_0x5b051a(0x1e8)](_0x5b051a(0x1c8))){if(!bcrypt[_0x5b051a(0x18f)](_0x19fbb3,_0x5a3410['password']))throw new common_1[(_0x5b051a(0x144))](_0x5b051a(0x191),common_1[_0x5b051a(0x1e6)]['BAD_REQUEST']);}else{console['log']('----,');const _0x2c5370=crypto['createHash']('md5')['update'](_0x19fbb3)[_0x5b051a(0x1ac)](_0x5b051a(0x159));console['log'](_0x5b051a(0x188),_0x2c5370);if(_0x2c5370!==_0x5a3410[_0x5b051a(0x18e)])throw new common_1[(_0x5b051a(0x144))](_0x5b051a(0x191),common_1[_0x5b051a(0x1e6)][_0x5b051a(0x1c7)]);}}if(!_0x5a3410)throw new common_1[(_0x5b051a(0x144))]('当前账户不存在!',common_1[_0x5b051a(0x1e6)][_0x5b051a(0x1c7)]);if(_0x5a3410[_0x5b051a(0x1d8)]!==user_constant_1[_0x5b051a(0x1b6)][_0x5b051a(0x1d2)])throw new common_1[(_0x5b051a(0x144))](user_constant_1[_0x5b051a(0x1a9)][_0x5a3410['status']],common_1[_0x5b051a(0x1e6)][_0x5b051a(0x1c7)]);return _0x5a3410;}async[_0x50c011(0x193)](_0x4cdd64,_0x453954){const _0x57129f=_0x50c011,_0x38343a=await this[_0x57129f(0x14e)][_0x57129f(0x1c9)]({'where':{'id':_0x4cdd64}});if(_0x38343a[_0x57129f(0x18e)][_0x57129f(0x1e8)](_0x57129f(0x171))||_0x38343a[_0x57129f(0x18e)][_0x57129f(0x1e8)](_0x57129f(0x1e3))||_0x38343a[_0x57129f(0x18e)][_0x57129f(0x1e8)](_0x57129f(0x1c8)))return bcrypt[_0x57129f(0x18f)](_0x453954,_0x38343a[_0x57129f(0x18e)]);else{const _0x1ea832=crypto['createHash'](_0x57129f(0x1a2))[_0x57129f(0x1e4)](_0x453954)[_0x57129f(0x1ac)](_0x57129f(0x159));return console[_0x57129f(0x19b)]('----,',_0x1ea832),_0x1ea832===_0x38343a[_0x57129f(0x18e)];}}async['updateUserStatus'](_0x53b363,_0x58c735){const _0x3356c5=_0x50c011,_0x219a23=await this['userEntity'][_0x3356c5(0x1e4)]({'id':_0x53b363},{'status':_0x58c735});return _0x219a23[_0x3356c5(0x1e9)]>0x0;}async['getUserStatus'](_0x42570a){const _0x4d0c34=_0x50c011,_0x2d3f5d=await this[_0x4d0c34(0x14e)]['findOne']({'where':{'id':_0x42570a}});return _0x2d3f5d[_0x4d0c34(0x1d8)];}async[_0x50c011(0x1c1)](_0x43d510){const _0x564d71=_0x50c011;return await this[_0x564d71(0x14e)][_0x564d71(0x1c9)]({'where':{'id':_0x43d510}});}async[_0x50c011(0x14b)](_0x363375){const _0x1ab0d5=_0x50c011;return await this[_0x1ab0d5(0x14e)][_0x1ab0d5(0x1c9)]({'where':{'id':_0x363375}});}async[_0x50c011(0x1b7)](_0x41a9c8){const _0x56d43c=_0x50c011,{id:_0x47b88c,role:_0x12cd1e}=_0x41a9c8;if(_0x12cd1e===_0x56d43c(0x1ab))return!![];const _0xb598b8=await this[_0x56d43c(0x14e)]['findOne']({'where':{'id':_0x47b88c}});if(!_0xb598b8)throw new common_1[(_0x56d43c(0x144))](_0x56d43c(0x1cb),common_1[_0x56d43c(0x1e6)]['UNAUTHORIZED']);if(_0xb598b8[_0x56d43c(0x1d8)]===user_constant_1[_0x56d43c(0x1b6)]['BLACKLISTED'])throw new common_1[(_0x56d43c(0x144))](_0x56d43c(0x1e7),common_1[_0x56d43c(0x1e6)][_0x56d43c(0x1c7)]);if(_0xb598b8[_0x56d43c(0x1d8)]===user_constant_1[_0x56d43c(0x1b6)][_0x56d43c(0x198)])throw new common_1[(_0x56d43c(0x144))](_0x56d43c(0x140),common_1[_0x56d43c(0x1e6)][_0x56d43c(0x1c7)]);}async[_0x50c011(0x165)](_0x59163c){const _0x11afbe=_0x50c011,_0x5cceb7=await this[_0x11afbe(0x14e)][_0x11afbe(0x1c9)]({'where':{'id':_0x59163c},'select':[_0x11afbe(0x1dc),_0x11afbe(0x16a),'role','email','sign','inviteCode',_0x11afbe(0x1b5),_0x11afbe(0x168)]});if(!_0x5cceb7)throw new common_1[(_0x11afbe(0x144))](_0x11afbe(0x1cb),common_1[_0x11afbe(0x1e6)][_0x11afbe(0x15f)]);_0x5cceb7[_0x11afbe(0x1b3)]=!!(_0x5cceb7===null||_0x5cceb7===void 0x0?void 0x0:_0x5cceb7[_0x11afbe(0x1b5)]),delete _0x5cceb7[_0x11afbe(0x1b5)];const _0x1ee4d2=await this['userBalanceService'][_0x11afbe(0x15d)](_0x59163c);return{'userInfo':_0x5cceb7,'userBalance':Object[_0x11afbe(0x1b9)]({},_0x1ee4d2)};}async[_0x50c011(0x174)](_0x15da42){return await this['userEntity']['findOne']({'where':{'id':_0x15da42}});}async[_0x50c011(0x17d)](_0x3f58d1){const _0x709f25=_0x50c011;return await this[_0x709f25(0x14e)][_0x709f25(0x1c9)]({'where':{'openId':_0x3f58d1}});}async['updateInfo'](_0x3279d2,_0x40ea46){const _0xe077=_0x50c011,{id:_0x3ff839}=_0x40ea46['user'],_0x382ae7=await this[_0xe077(0x14e)][_0xe077(0x1c9)]({'where':{'id':_0x3ff839}});if(!_0x382ae7)throw new common_1['HttpException'](_0xe077(0x152),common_1[_0xe077(0x1e6)]['BAD_REQUEST']);if(_0x3279d2[_0xe077(0x1dc)]&&_0x382ae7[_0xe077(0x1dc)]===_0x3279d2[_0xe077(0x1dc)])throw new common_1[(_0xe077(0x144))](_0xe077(0x17a),common_1['HttpStatus'][_0xe077(0x1c7)]);if(_0x3279d2[_0xe077(0x1dc)]){const _0x45c81a=await this['userEntity'][_0xe077(0x1c9)]({'where':{'username':_0x3279d2['username'],'id':(0x0,typeorm_2[_0xe077(0x15a)])(_0x3ff839)}});if(_0x45c81a)throw new common_1[(_0xe077(0x144))](_0xe077(0x1d7),common_1[_0xe077(0x1e6)][_0xe077(0x1c7)]);}const _0x46a292=await this[_0xe077(0x14e)][_0xe077(0x1e4)]({'id':_0x3ff839},_0x3279d2);if(_0x46a292[_0xe077(0x1e9)]<=0x0)throw new common_1['HttpException'](_0xe077(0x1de),common_1[_0xe077(0x1e6)]['BAD_REQUEST']);return'修改用户信息成功!';}async[_0x50c011(0x1b1)](_0x184cae,_0x2e6fa7){const _0x47e12a=_0x50c011,_0x509339=bcrypt[_0x47e12a(0x184)](_0x2e6fa7,0xa),_0x40ba81=await this[_0x47e12a(0x14e)][_0x47e12a(0x1e4)]({'id':_0x184cae},{'password':_0x509339});if(_0x40ba81[_0x47e12a(0x1e9)]<=0x0)throw new common_1['HttpException'](_0x47e12a(0x177),common_1[_0x47e12a(0x1e6)][_0x47e12a(0x1c7)]);}async[_0x50c011(0x1bc)](_0x5a1f18){const _0x4b6156=_0x50c011,{id:_0xb82ae0}=_0x5a1f18[_0x4b6156(0x158)],_0x243f07=await this[_0x4b6156(0x14e)]['findOne']({'where':{'id':_0xb82ae0}});if(!_0x243f07||_0x243f07[_0x4b6156(0x1b0)])throw new common_1[(_0x4b6156(0x144))]('已生成过邀请码、请勿重复生成',common_1[_0x4b6156(0x1e6)][_0x4b6156(0x1c7)]);const _0x3a4d89=(0x0,utils_1['generateRandomString'])(),_0x3d1d8a=await this['userEntity'][_0x4b6156(0x1c9)]({'where':{'inviteCode':_0x3a4d89}});if(_0x3d1d8a)throw new common_1['HttpException'](_0x4b6156(0x147),common_1['HttpStatus']['BAD_REQUEST']);const _0x52e5c1=await this['userEntity']['update']({'id':_0xb82ae0},{'inviteCode':_0x3a4d89});if(_0x52e5c1['affected']<=0x0)throw new common_1[(_0x4b6156(0x144))]('生成邀请码失败,请重新试一次吧!',common_1['HttpStatus'][_0x4b6156(0x1c7)]);return _0x3a4d89;}async[_0x50c011(0x19e)](_0x21bdf4,_0x2eeaf3){const _0x3d18f7=_0x50c011;try{const {id:_0x43b380}=_0x21bdf4[_0x3d18f7(0x158)],{page:page=0x1,size:size=0xa}=_0x2eeaf3,_0x285339=await this['userEntity'][_0x3d18f7(0x1c9)]({'where':{'id':_0x43b380}}),{inviteCode:_0x75f013}=_0x285339;if(!_0x75f013)return[];const [_0x403e2c,_0x47383c]=await this[_0x3d18f7(0x14e)][_0x3d18f7(0x1b8)]({'where':{'inviteCode':_0x75f013},'order':{'id':'DESC'},'select':[_0x3d18f7(0x1dc),_0x3d18f7(0x18b),_0x3d18f7(0x145),_0x3d18f7(0x1d8),'avatar'],'take':size,'skip':(page-0x1)*size});return(0x0,utils_1[_0x3d18f7(0x179)])(_0x403e2c)[_0x3d18f7(0x13e)](_0x2f7803=>{const _0x164df4=_0x3d18f7;return _0x2f7803[_0x164df4(0x18b)]=(0x0,utils_1[_0x164df4(0x1be)])(_0x2f7803['email']),_0x2f7803;}),{'rows':_0x403e2c,'count':_0x47383c};}catch(_0x584f42){console[_0x3d18f7(0x19b)](_0x3d18f7(0x18d),_0x584f42);throw new common_1[(_0x3d18f7(0x144))](_0x3d18f7(0x157),common_1[_0x3d18f7(0x1e6)][_0x3d18f7(0x1c7)]);}}async['inviteLink'](_0x52dad4){const _0x2e7ae0=_0x50c011,_0x26b0b0=await this['userEntity'][_0x2e7ae0(0x1c9)]({'where':{'inviteCode':_0x52dad4}});if(!_0x26b0b0)return 0x1;const {inviteLinkCount:inviteLinkCount=0x0}=_0x26b0b0,_0x19d572=await this[_0x2e7ae0(0x14e)][_0x2e7ae0(0x1e4)]({'inviteCode':_0x52dad4},{'inviteLinkCount':inviteLinkCount+0x1});return _0x19d572[_0x2e7ae0(0x1e9)]?0x1:0x0;}async[_0x50c011(0x16d)](_0x53315d){const _0x3be96b=_0x50c011;return await this[_0x3be96b(0x14e)][_0x3be96b(0x1c9)]({'where':{'inviteCode':_0x53315d}});}async[_0x50c011(0x183)](_0x2e504c){const _0x2867f0=_0x50c011,{userId:_0x2d65cc,model3Count:model3Count=0x0,model4Count:model4Count=0x0,drawMjCount:drawMjCount=0x0}=_0x2e504c;await this[_0x2867f0(0x1b2)]['addBalanceToUser'](_0x2d65cc,{'model3Count':model3Count,'model4Count':model4Count,'drawMjCount':drawMjCount});const _0x2e58fa=await this[_0x2867f0(0x1b2)][_0x2867f0(0x1aa)]({'userId':_0x2d65cc,'rechargeType':balance_constant_1[_0x2867f0(0x19a)]['ADMIN_GIFT'],'model3Count':model3Count,'model4Count':model4Count,'drawMjCount':drawMjCount,'extent':''});return _0x2e58fa;}async[_0x50c011(0x1a0)](_0x3393d0,_0x307b56){const _0x580950=_0x50c011,{page:page=0x1,size:size=0xa,username:_0x1b71c5,email:_0x47aab5,status:_0x402d75,keyword:_0x5a2570,phone:_0x46b40e}=_0x3393d0;let _0x5a4bee={};_0x1b71c5&&Object[_0x580950(0x1b9)](_0x5a4bee,{'username':(0x0,typeorm_2[_0x580950(0x1df)])('%'+_0x1b71c5+'%')}),_0x47aab5&&Object[_0x580950(0x1b9)](_0x5a4bee,{'email':(0x0,typeorm_2['Like'])('%'+_0x47aab5+'%')}),_0x46b40e&&Object[_0x580950(0x1b9)](_0x5a4bee,{'phone':(0x0,typeorm_2[_0x580950(0x1df)])('%'+_0x46b40e+'%')}),_0x402d75&&Object[_0x580950(0x1b9)](_0x5a4bee,{'status':_0x402d75});_0x5a2570&&(_0x5a4bee=[{'username':(0x0,typeorm_2[_0x580950(0x1df)])('%'+_0x5a2570+'%')},{'email':(0x0,typeorm_2[_0x580950(0x1df)])('%'+_0x5a2570+'%')},{'phone':(0x0,typeorm_2[_0x580950(0x1df)])('%'+_0x5a2570+'%')}]);const [_0xf4e63f,_0x32d985]=await this[_0x580950(0x14e)][_0x580950(0x1b8)]({'skip':(page-0x1)*size,'where':_0x5a4bee,'take':size,'order':{'createdAt':_0x580950(0x190)},'cache':!![],'select':[_0x580950(0x1dc),_0x580950(0x16a),_0x580950(0x1b0),'role',_0x580950(0x1db),_0x580950(0x1d8),'id',_0x580950(0x18b),'createdAt',_0x580950(0x1ae),_0x580950(0x13f)]}),_0x23a3a9=_0xf4e63f[_0x580950(0x13e)](_0x973afa=>_0x973afa['id']),_0x53ac31=await this[_0x580950(0x1b2)]['queryUserBalanceByIds'](_0x23a3a9);return _0xf4e63f[_0x580950(0x182)](_0x49eb7d=>_0x49eb7d[_0x580950(0x13d)]=_0x53ac31[_0x580950(0x18c)](_0x16697b=>_0x16697b['userId']===_0x49eb7d['id'])),_0x307b56['user']['role']!==_0x580950(0x1bd)&&_0xf4e63f['forEach'](_0x2e13a7=>_0x2e13a7[_0x580950(0x18b)]=(0x0,utils_1['maskEmail'])(_0x2e13a7[_0x580950(0x18b)])),_0x307b56[_0x580950(0x158)]['role']!==_0x580950(0x1bd)&&_0xf4e63f[_0x580950(0x182)](_0x4a580a=>_0x4a580a[_0x580950(0x1ae)]=(0x0,utils_1[_0x580950(0x192)])(_0x4a580a['lastLoginIp'])),_0x307b56['user'][_0x580950(0x189)]!=='super'&&_0xf4e63f[_0x580950(0x182)](_0x5e897b=>_0x5e897b[_0x580950(0x13f)]=(0x0,utils_1[_0x580950(0x192)])(_0x5e897b[_0x580950(0x13f)])),{'rows':_0xf4e63f,'count':_0x32d985};}async[_0x50c011(0x16c)]({id:_0x42f764}){const _0x55f1ee=_0x50c011;return await this[_0x55f1ee(0x14e)][_0x55f1ee(0x1c9)]({'where':{'id':_0x42f764},'select':['username',_0x55f1ee(0x16a),_0x55f1ee(0x1b0),_0x55f1ee(0x189),'sign',_0x55f1ee(0x1d8)]});}async[_0x50c011(0x185)](_0x3774ed){const _0xe9469=_0x50c011,{id:_0x1249a7,status:_0x3bd9df}=_0x3774ed,_0x33c46f=await this[_0xe9469(0x14e)]['findOne']({'where':{'id':_0x1249a7}});if(!_0x33c46f)throw new common_1[(_0xe9469(0x144))](_0xe9469(0x1e0),common_1[_0xe9469(0x1e6)][_0xe9469(0x1c7)]);if(_0x33c46f[_0xe9469(0x189)]===_0xe9469(0x1bd))throw new common_1[(_0xe9469(0x144))]('超级管理员不可被操作!',common_1[_0xe9469(0x1e6)]['BAD_REQUEST']);if(_0x33c46f['status']===user_constant_1['UserStatusEnum'][_0xe9469(0x1ba)])throw new common_1[(_0xe9469(0x144))]('未激活用户不可手动变更状态!',common_1[_0xe9469(0x1e6)][_0xe9469(0x1c7)]);if(_0x33c46f['role']===_0xe9469(0x1bd))throw new common_1[(_0xe9469(0x144))]('超级管理员不可被操作!',common_1[_0xe9469(0x1e6)][_0xe9469(0x1c7)]);if(_0x3bd9df===user_constant_1['UserStatusEnum'][_0xe9469(0x1ba)])throw new common_1[(_0xe9469(0x144))](_0xe9469(0x1e5),common_1[_0xe9469(0x1e6)][_0xe9469(0x1c7)]);const _0x482299=await this[_0xe9469(0x14e)][_0xe9469(0x1e4)]({'id':_0x1249a7},{'status':_0x3bd9df});if(_0x482299[_0xe9469(0x1e9)]<=0x0)throw new common_1[(_0xe9469(0x144))](_0xe9469(0x1a1),common_1['HttpStatus']['BAD_REQUEST']);return'修改用户状态成功!';}async[_0x50c011(0x1cd)](_0x19464a){const _0x438ea8=_0x50c011,{id:_0x4920ff}=_0x19464a,_0x4a5a7e=await this[_0x438ea8(0x14e)]['findOne']({'where':{'id':_0x4920ff}});if(!_0x4a5a7e)throw new common_1[(_0x438ea8(0x144))]('用户不存在!',common_1[_0x438ea8(0x1e6)]['BAD_REQUEST']);const _0x23e254=_0x438ea8(0x153),_0x15c352=bcrypt[_0x438ea8(0x184)](_0x23e254,0xa),_0x2ee0b3=await this[_0x438ea8(0x14e)][_0x438ea8(0x1e4)]({'id':_0x4920ff},{'password':_0x15c352});if(_0x2ee0b3[_0x438ea8(0x1e9)]<=0x0)throw new common_1[(_0x438ea8(0x144))](_0x438ea8(0x19f),common_1[_0x438ea8(0x1e6)][_0x438ea8(0x1c7)]);return'密码重置为['+_0x23e254+']成功!';}async['savaLoginIp'](_0x49cbf5,_0x50da32){return await this['userEntity']['update']({'id':_0x49cbf5},{'lastLoginIp':_0x50da32});}async[_0x50c011(0x170)](_0x183ddd,_0x2f885b){const _0x2656e5=_0x50c011,_0xe37b55=await this[_0x2656e5(0x14e)][_0x2656e5(0x1c9)]({'where':{'openId':_0x183ddd}});if(!_0xe37b55){const _0x53486f=_0x2f885b?_0x2f885b['split'](':')[0x1]:'',_0x326444=await this['qureyUserInfoByInviteCode'](_0x53486f),_0x48638e=await this[_0x2656e5(0x197)](_0x183ddd,_0x53486f);return await this[_0x2656e5(0x1b2)][_0x2656e5(0x161)](_0x48638e['id'],_0x53486f?_0x326444===null||_0x326444===void 0x0?void 0x0:_0x326444['id']:null),_0x48638e;}return _0xe37b55;}async[_0x50c011(0x197)](_0x517997,_0x5b62f6){const _0x3e41ac=_0x50c011,_0x36e59f=await this['globalConfigService']['getConfigs']([_0x3e41ac(0x17b)]),_0x19d103={'avatar':_0x36e59f,'username':'用户'+(0x0,utils_1[_0x3e41ac(0x187)])(),'status':user_constant_1[_0x3e41ac(0x1b6)]['ACTIVE'],'sex':0x0,'email':(0x0,utils_1[_0x3e41ac(0x187)])()+_0x3e41ac(0x14d),'invitedBy':_0x5b62f6,'openId':_0x517997},_0x5bef13=await this['userEntity'][_0x3e41ac(0x180)](_0x19d103);return _0x5bef13;}async[_0x50c011(0x186)](_0x18f947,_0x7c1e5a){const _0x205643=_0x50c011;try{const _0x15a1c1=await this['userEntity']['findOne']({'where':{'id':_0x7c1e5a}});if(!_0x15a1c1)return{'status':![],'msg':'当前绑定用户不存在!'};const _0x4ba214=await this[_0x205643(0x14e)][_0x205643(0x1c9)]({'where':{'openId':_0x18f947}});if(_0x4ba214)return{'status':![],'msg':_0x205643(0x1d9)};const _0x2e827e=await this[_0x205643(0x14e)][_0x205643(0x1e4)]({'id':_0x7c1e5a},{'openId':_0x18f947});if(_0x2e827e[_0x205643(0x1e9)]<=0x0)return{'status':![],'msg':_0x205643(0x169)};return{'status':!![],'msg':'恭喜您绑定成功、后续可直接扫码登录了!'};}catch(_0x5906dd){return{'status':![],'msg':_0x205643(0x169)};}}async[_0x50c011(0x172)](_0x3bc526){const _0x43353e=_0x50c011,_0x225395=await this[_0x43353e(0x14e)][_0x43353e(0x1c9)]({'where':{'id':_0x3bc526}});return _0x225395===null||_0x225395===void 0x0?void 0x0:_0x225395[_0x43353e(0x1b5)];}async['verifyUserRegisterByPhone'](_0x248a15){const _0x58874a=_0x50c011,{username:_0x2a5032,password:_0xf74818,phone:_0x55a8c1,phoneCode:_0x41e1e1}=_0x248a15,_0x3cf9f4=await this[_0x58874a(0x14e)][_0x58874a(0x1c9)]({'where':[{'username':_0x2a5032},{'phone':_0x55a8c1}]});if(_0x3cf9f4&&_0x3cf9f4[_0x58874a(0x1dc)]===_0x2a5032)throw new common_1[(_0x58874a(0x144))](_0x58874a(0x1d4),common_1[_0x58874a(0x1e6)][_0x58874a(0x1c7)]);if(_0x3cf9f4&&_0x3cf9f4[_0x58874a(0x13f)]===_0x55a8c1)throw new common_1[(_0x58874a(0x144))](_0x58874a(0x194),common_1['HttpStatus'][_0x58874a(0x1c7)]);}async[_0x50c011(0x14f)](_0x30976e){const _0x169551=_0x50c011;return await this[_0x169551(0x14e)][_0x169551(0x180)](_0x30976e);}};UserService=__decorate([(0x0,common_1[_0x50c011(0x1a8)])(),__param(0x0,(0x0,typeorm_1[_0x50c011(0x150)])(user_entity_1['UserEntity'])),__param(0x1,(0x0,typeorm_1[_0x50c011(0x150)])(whiteList_entity_1[_0x50c011(0x151)])),__param(0x7,(0x0,typeorm_1[_0x50c011(0x150)])(config_entity_1[_0x50c011(0x19c)])),__metadata(_0x50c011(0x142),[typeorm_2[_0x50c011(0x1a6)],typeorm_2['Repository'],typeorm_2['Connection'],verification_service_1['VerificationService'],mailer_1['MailerService'],userBalance_service_1['UserBalanceService'],globalConfig_service_1[_0x50c011(0x1bb)],typeorm_2[_0x50c011(0x1a6)]])],UserService),exports['UserService']=UserService; |