YiAi/YiAiQuickDeploy/dist/modules/userBalance/userBalance.service.js
2024-07-02 16:38:26 +08:00

1 line
29 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';const _0x29bf1f=_0x5e79;(function(_0x2eb789,_0x263840){const _0x30c3e4=_0x5e79,_0x1cd3bd=_0x2eb789();while(!![]){try{const _0x376d8d=-parseInt(_0x30c3e4(0x224))/0x1+-parseInt(_0x30c3e4(0x214))/0x2*(parseInt(_0x30c3e4(0x24a))/0x3)+parseInt(_0x30c3e4(0x210))/0x4*(-parseInt(_0x30c3e4(0x220))/0x5)+parseInt(_0x30c3e4(0x202))/0x6*(parseInt(_0x30c3e4(0x1e4))/0x7)+parseInt(_0x30c3e4(0x1ad))/0x8+parseInt(_0x30c3e4(0x1d9))/0x9+-parseInt(_0x30c3e4(0x265))/0xa;if(_0x376d8d===_0x263840)break;else _0x1cd3bd['push'](_0x1cd3bd['shift']());}catch(_0x22d7dc){_0x1cd3bd['push'](_0x1cd3bd['shift']());}}}(_0x2f47,0x3f4d4));function _0x5e79(_0x5de5af,_0x2650db){const _0x2f4711=_0x2f47();return _0x5e79=function(_0x5e793f,_0x56df12){_0x5e793f=_0x5e793f-0x1aa;let _0x126874=_0x2f4711[_0x5e793f];return _0x126874;},_0x5e79(_0x5de5af,_0x2650db);}var __decorate=this&&this[_0x29bf1f(0x1dc)]||function(_0x69b5db,_0x22ede7,_0x4c2b40,_0x4df4bd){const _0x211c96=_0x29bf1f;var _0x5c4d5f=arguments[_0x211c96(0x1e2)],_0x3d3027=_0x5c4d5f<0x3?_0x22ede7:_0x4df4bd===null?_0x4df4bd=Object[_0x211c96(0x1c2)](_0x22ede7,_0x4c2b40):_0x4df4bd,_0x2b33e0;if(typeof Reflect===_0x211c96(0x246)&&typeof Reflect[_0x211c96(0x204)]===_0x211c96(0x1ee))_0x3d3027=Reflect['decorate'](_0x69b5db,_0x22ede7,_0x4c2b40,_0x4df4bd);else{for(var _0x108714=_0x69b5db[_0x211c96(0x1e2)]-0x1;_0x108714>=0x0;_0x108714--)if(_0x2b33e0=_0x69b5db[_0x108714])_0x3d3027=(_0x5c4d5f<0x3?_0x2b33e0(_0x3d3027):_0x5c4d5f>0x3?_0x2b33e0(_0x22ede7,_0x4c2b40,_0x3d3027):_0x2b33e0(_0x22ede7,_0x4c2b40))||_0x3d3027;}return _0x5c4d5f>0x3&&_0x3d3027&&Object['defineProperty'](_0x22ede7,_0x4c2b40,_0x3d3027),_0x3d3027;},__metadata=this&&this[_0x29bf1f(0x1af)]||function(_0x7bfee4,_0x7e10ca){const _0x56654e=_0x29bf1f;if(typeof Reflect===_0x56654e(0x246)&&typeof Reflect[_0x56654e(0x1c8)]===_0x56654e(0x1ee))return Reflect['metadata'](_0x7bfee4,_0x7e10ca);},__param=this&&this[_0x29bf1f(0x22e)]||function(_0x1423de,_0x482748){return function(_0x322f98,_0x5e33b6){_0x482748(_0x322f98,_0x5e33b6,_0x1423de);};};function _0x2f47(){const _0x1e56db=['firstRegisterSendRank','isInteger','BAD_REQUEST','>\x20或购买专属套餐\x20','sumModel3Count','./accountLog.entity','../../common/utils/date','firstRregisterSendModel4Count','UserBalanceService','66425MVJbES','cramiPackageEntity','充值失败','chatGroupEntity','168317woWzwZ','odel4','当前用户无需创建账户信息!','../chatGroup/chatGroup.entity','packageId','getDate','userEntity','avatar','weight','getConfigs','__param','queryUserBalance','phone','user','default','count','HttpStatus','registerSendStatus','BalanceEntity','find','../../common/constants/balance.constant','hideString','充值失败!','您的账户余额不足,如果想继续体验服务,请联系管理员\x20<VX:\x20','useModel3Token','invitedGuestSendModel3Count','salesUsersEntity','whiteListEntity','accountLogEntity','MjCount','Logger','memberModel4Count','当前套餐不存在!','typeorm','object','invitedGuestSendModel4Count','commissionAmount','visitorModel4Num','114UvGwWo','PAYMENT_REQUIRED','查询用户账户失败!','refundMjBalance','getFullYear','forEach','username','ChatLogEntity','affected','super','useModel3Count','save','InjectRepository','configEntity','UserEntity','sumDrawMjCount','configVal','deductFromBalance','LessThan','旧账户信息迁移失败','inheritVisitorData','debug','查询用户账户信息失败!','day','getRechargeLog','今日当前类型免费额度已经使用完毕、建议您注册账户体验更加完整的服务内容!','headers','479680DxueAk','注册赠送失败,请联系管理员!','RechargeType','validateBalance','useModel4Token','total','CramiPackageEntity','旧账户信息迁移成功','inviteGiveSendDrawMjCount','addBalanceToOrder','335848GzxaOW','validateVisitorBalance','__metadata','toFixed','INVITE_GIFT','../crami/cramiPackage.entity','../globalConfig/config.entity','registerSendDrawMjCount','firstRegisterSendStatus','reduce','salesService','Injectable','expirationTime','createSalesRecords','Repository','update','model4','../globalConfig/globalConfig.service','./fingerprint.entity','useDrawMjToken','midjourneyEntity','getOwnPropertyDescriptor','model3','visitorMJNum','---','userBalanceEntity','balanceEntity','metadata','findAndCount','sumModel4Count','error:\x20','chatLogEntity','saveCommissionAmount','includes','DESC','用户充值失败!','then','当前用户不存在,记录充值日志异常','saveRecordRechargeLog','getVisitorCount','充值的工单信息:','../chatgpt/whiteList.entity','fingerprintLogEntity','BalanceService','3975417dnbgmW','expireDateCn','writeOldBalanceToNewTable','__decorate','../chatLog/chatLog.entity','registerSendModel3Count','MidjourneyEntity','createBaseUserBalance','model4Count','length','email','2611fPgOMN','odel3','visitor','inviteSendStatus','isUpdatedToday','drawMjCount','UserBalanceEntity','inviteGiveSendModel4Count','findOne','缺失当前套餐ID、充值失败','function','add','您已经升级过了、请勿重复操作!','queryUserBalanceByIds','memberModel3Count','账户信息已经存在、迁移无效','model3Count','YYYY-MM-DD\x20HH:mm:ss','../sales/sales.service','design:paramtypes','goodsId','days','inviteGiveSendModel3Count','消费余额失败!','firstRregisterSendDrawMjCount','log','vxNumber','catch','getAccountLog','invitedGuestSendDrawMjCount','6564fPvqAH','firstRregisterSendModel3Count','decorate','userId','YYYY-MM-DD','WhiteListEntity','./balance.entity','visitorModel3Num','globalConfigService','非法操作、当前充值套餐暂不存在!','setConfig','addBalanceToUser','mjDraw','HttpException','68BClxMO','查询当前用户余额失败!','upgradeStatus','memberDrawMjCount','10018nrEPDH','SalesService','getMonth'];_0x2f47=function(){return _0x1e56db;};return _0x2f47();}Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports['UserBalanceService']=void 0x0;const globalConfig_service_1=require(_0x29bf1f(0x1be)),typeorm_1=require('@nestjs/typeorm'),balance_entity_1=require(_0x29bf1f(0x208)),common_1=require('@nestjs/common'),typeorm_2=require(_0x29bf1f(0x245)),balance_constant_1=require(_0x29bf1f(0x238)),accountLog_entity_1=require(_0x29bf1f(0x21c)),utils_1=require('../../common/utils'),config_entity_1=require(_0x29bf1f(0x1b3)),cramiPackage_entity_1=require(_0x29bf1f(0x1b2)),userBalance_entity_1=require('./userBalance.entity'),date_1=require(_0x29bf1f(0x21d)),user_entity_1=require('../user/user.entity'),salesUsers_entity_1=require('../sales/salesUsers.entity'),sales_service_1=require(_0x29bf1f(0x1f6)),whiteList_entity_1=require(_0x29bf1f(0x1d6)),fingerprint_entity_1=require(_0x29bf1f(0x1bf)),chatLog_entity_1=require(_0x29bf1f(0x1dd)),chatGroup_entity_1=require(_0x29bf1f(0x227)),midjourney_entity_1=require('../midjourney/midjourney.entity');let UserBalanceService=class UserBalanceService{constructor(_0x4a9273,_0x22bebe,_0x396ae0,_0x4fe182,_0x22cdd0,_0x1a3520,_0x14cc49,_0x349e9e,_0x502e03,_0x2e4713,_0x4d00b4,_0x33e274,_0x5f40fe,_0x1d745d){const _0x1b6c5d=_0x29bf1f;this[_0x1b6c5d(0x1c7)]=_0x4a9273,this['userBalanceEntity']=_0x22bebe,this[_0x1b6c5d(0x240)]=_0x396ae0,this['cramiPackageEntity']=_0x4fe182,this[_0x1b6c5d(0x257)]=_0x22cdd0,this['userEntity']=_0x1a3520,this[_0x1b6c5d(0x23e)]=_0x14cc49,this[_0x1b6c5d(0x23f)]=_0x349e9e,this['fingerprintLogEntity']=_0x502e03,this[_0x1b6c5d(0x223)]=_0x2e4713,this[_0x1b6c5d(0x1cc)]=_0x4d00b4,this[_0x1b6c5d(0x1c1)]=_0x33e274,this['salesService']=_0x5f40fe,this[_0x1b6c5d(0x20a)]=_0x1d745d;}async['addBalanceToNewUser'](_0x27b7b3,_0x42b364){const _0x52e9dd=_0x29bf1f;try{const _0x3adab5=await this['configEntity'][_0x52e9dd(0x237)]({'where':{'configKey':(0x0,typeorm_2['In'])(['registerSendStatus',_0x52e9dd(0x1de),'registerSendModel4Count',_0x52e9dd(0x1b4),_0x52e9dd(0x1b5),_0x52e9dd(0x217),_0x52e9dd(0x203),_0x52e9dd(0x21e),_0x52e9dd(0x1fc),_0x52e9dd(0x1e7),_0x52e9dd(0x1fa),_0x52e9dd(0x1eb),_0x52e9dd(0x1ab),'invitedGuestSendModel3Count',_0x52e9dd(0x201),_0x52e9dd(0x247)])}}),_0x2dacb2=_0x3adab5[_0x52e9dd(0x1b6)]((_0x30fbaf,_0x32b522)=>{const _0x410ecb=_0x52e9dd,_0x316900=Number(_0x32b522[_0x410ecb(0x25a)]),_0x478964=Number[_0x410ecb(0x218)](_0x316900)&&_0x316900>0x0?_0x316900:0x0;return _0x30fbaf[_0x32b522['configKey']]=_0x478964,_0x30fbaf;},{});let _0x3b152d=0x0,_0x53f58e=0x0,_0x36cc2f=0x0;_0x2dacb2[_0x52e9dd(0x235)]===0x1&&(_0x3b152d=_0x3b152d+_0x2dacb2[_0x52e9dd(0x1de)],_0x53f58e=_0x53f58e+_0x2dacb2['registerSendModel4Count'],_0x36cc2f=_0x36cc2f+_0x2dacb2[_0x52e9dd(0x1b4)]),_0x2dacb2[_0x52e9dd(0x235)]===0x1&&_0x2dacb2[_0x52e9dd(0x1b5)]===0x1&&_0x27b7b3<=_0x2dacb2[_0x52e9dd(0x217)]&&(_0x3b152d=_0x3b152d+_0x2dacb2['firstRregisterSendModel3Count'],_0x53f58e=_0x53f58e+_0x2dacb2[_0x52e9dd(0x21e)],_0x36cc2f=_0x36cc2f+_0x2dacb2[_0x52e9dd(0x1fc)]),await this[_0x52e9dd(0x1d3)]({'userId':_0x27b7b3,'rechargeType':balance_constant_1[_0x52e9dd(0x267)]['REG_GIFT'],'model3Count':_0x3b152d,'drawMjCount':_0x36cc2f,'model4Count':_0x53f58e}),_0x42b364&&(Number(_0x2dacb2['inviteSendStatus'])===0x1&&(_0x3b152d=_0x3b152d+Number(_0x2dacb2['invitedGuestSendModel3Count']),_0x53f58e=_0x53f58e+Number(_0x2dacb2[_0x52e9dd(0x247)]),_0x36cc2f=_0x36cc2f+Number(_0x2dacb2[_0x52e9dd(0x201)]),await this[_0x52e9dd(0x1d3)]({'userId':_0x27b7b3,'rechargeType':balance_constant_1[_0x52e9dd(0x267)][_0x52e9dd(0x1b1)],'model3Count':_0x2dacb2[_0x52e9dd(0x23d)],'model4Count':_0x2dacb2[_0x52e9dd(0x247)],'drawMjCount':_0x2dacb2[_0x52e9dd(0x201)]}),await this[_0x52e9dd(0x20d)](_0x42b364,{'model3Count':_0x2dacb2[_0x52e9dd(0x1fa)],'model4Count':_0x2dacb2['inviteGiveSendModel4Count'],'drawMjCount':_0x2dacb2[_0x52e9dd(0x1ab)]}),await this[_0x52e9dd(0x1d3)]({'userId':_0x42b364,'rechargeType':balance_constant_1['RechargeType']['REFER_GIFT'],'model3Count':_0x2dacb2['inviteGiveSendModel3Count'],'model4Count':_0x2dacb2[_0x52e9dd(0x1eb)],'drawMjCount':_0x2dacb2[_0x52e9dd(0x1ab)]}))),await this[_0x52e9dd(0x1c6)][_0x52e9dd(0x255)]({'userId':_0x27b7b3,'model3Count':_0x3b152d,'model4Count':_0x53f58e,'drawMjCount':_0x36cc2f,'useTokens':0x0});}catch(_0x454454){console[_0x52e9dd(0x1fd)](_0x52e9dd(0x1cb),_0x454454);throw new common_1[(_0x52e9dd(0x20f))](_0x52e9dd(0x266),common_1[_0x52e9dd(0x234)][_0x52e9dd(0x219)]);}}async[_0x29bf1f(0x268)](_0xbd14b7,_0x3f744a,_0x1f989e){const _0x17cf68=_0x29bf1f,{id:_0x31548b,role:_0x5df3fe}=_0xbd14b7[_0x17cf68(0x231)];let _0x1d51fb=await this[_0x17cf68(0x1c6)][_0x17cf68(0x1ec)]({'where':{'userId':_0x31548b}});!_0x1d51fb&&(_0x1d51fb=await this[_0x17cf68(0x1e0)](_0x31548b));if(_0x5df3fe===_0x17cf68(0x1e6))return this[_0x17cf68(0x1ae)](_0xbd14b7,_0x3f744a,_0x1f989e);const _0x2a5aed=await this['configEntity'][_0x17cf68(0x1ec)]({'where':{'configKey':_0x17cf68(0x1fe)}}),_0x25e1a8=_0x2a5aed?_0x2a5aed[_0x17cf68(0x25a)]:_0x17cf68(0x1c5),_0x2e75e8=_0x3f744a===_0x17cf68(0x1c3)?'memberModel3Count':_0x3f744a===_0x17cf68(0x1bd)?_0x17cf68(0x243):_0x3f744a===_0x17cf68(0x20e)?_0x17cf68(0x213):null,_0x1fe573=_0x3f744a===_0x17cf68(0x1c3)?_0x17cf68(0x1f4):_0x3f744a==='model4'?_0x17cf68(0x1e1):_0x3f744a===_0x17cf68(0x20e)?'drawMjCount':null;if(_0x1d51fb[_0x17cf68(0x228)]&&_0x1d51fb[_0x2e75e8]<_0x1f989e){if(_0x1d51fb[_0x1fe573]<_0x1f989e)throw new common_1[(_0x17cf68(0x20f))](_0x17cf68(0x23b)+_0x25e1a8+'>\x20或购买专属套餐\x20',common_1[_0x17cf68(0x234)]['PAYMENT_REQUIRED']);}if(!_0x1d51fb['packageId']&&_0x1d51fb[_0x1fe573]<_0x1f989e)throw new common_1['HttpException']('您的账户余额不足,如果想继续体验服务,请联系管理员\x20<VX:\x20'+_0x25e1a8+_0x17cf68(0x21a),common_1[_0x17cf68(0x234)]['PAYMENT_REQUIRED']);return _0x1d51fb;}async[_0x29bf1f(0x1ae)](_0x2f5c2e,_0x9620ff,_0x3b170c){const _0x199f39=_0x29bf1f,{id:_0x220bf5}=_0x2f5c2e[_0x199f39(0x231)],_0x5cf5f0=_0x9620ff==='model3'?_0x199f39(0x1f4):_0x9620ff===_0x199f39(0x1bd)?_0x199f39(0x1e1):_0x9620ff===_0x199f39(0x20e)?_0x199f39(0x1e9):null,_0x106dc2=new Date(),_0x46cb58=await this[_0x199f39(0x1d7)][_0x199f39(0x1ec)]({'where':{'fingerprint':_0x220bf5}}),{visitorModel3Num:_0x2ef0a4,visitorModel4Num:_0x44cacd,visitorMJNum:_0x245099}=await this['globalConfigService'][_0x199f39(0x22d)]([_0x199f39(0x209),_0x199f39(0x249),_0x199f39(0x1c4)]),_0x226743={'model3Count':_0x2ef0a4?Number(_0x2ef0a4):0x0,'model4Count':_0x44cacd?Number(_0x44cacd):0x0,'drawMjCount':_0x245099?Number(_0x245099):0x0};if(!_0x46cb58){const _0x1bc4fc={'fingerprint':_0x220bf5,'model3Count':0x0,'model4Count':0x0,'drawMjCount':0x0};_0x1bc4fc[_0x5cf5f0]=_0x1bc4fc[_0x5cf5f0]+_0x3b170c;if(_0x1bc4fc[_0x5cf5f0]>_0x226743[_0x5cf5f0])throw new common_1['HttpException'](_0x199f39(0x263),common_1[_0x199f39(0x234)][_0x199f39(0x24b)]);else return await this[_0x199f39(0x1d7)]['save'](_0x1bc4fc),!![];}else{const {model3Count:_0x2316e9,model4Count:_0x413d24,drawMjCount:_0x423294}=_0x46cb58;let _0x5890d0={'model3Count':_0x2316e9,'model4Count':_0x413d24,'drawMjCount':_0x423294};const _0x28f9b9=Number(new Date(_0x46cb58['updatedAt'])),_0x3151a5=this['isUpdatedToday'](_0x28f9b9);_0x3151a5?_0x5890d0[_0x5cf5f0]=_0x5890d0[_0x5cf5f0]+_0x3b170c:(_0x5890d0={'model3Count':0x0,'model4Count':0x0,'drawMjCount':0x0},_0x5890d0[_0x5cf5f0]=_0x5890d0[_0x5cf5f0]+_0x3b170c);if(_0x5890d0[_0x5cf5f0]>_0x226743[_0x5cf5f0])throw new common_1['HttpException']('今日当前类型免费额度已经使用完毕、建议您注册账户体验更加完整的服务内容!',common_1[_0x199f39(0x234)]['PAYMENT_REQUIRED']);else return await this[_0x199f39(0x1d7)]['update']({'fingerprint':_0x220bf5},_0x5890d0),!![];}}[_0x29bf1f(0x1e8)](_0x5956ed){const _0x47ee76=_0x29bf1f,_0x31dd90=new Date(),_0x50185e=new Date(_0x31dd90[_0x47ee76(0x24e)](),_0x31dd90[_0x47ee76(0x216)](),_0x31dd90[_0x47ee76(0x229)]());return _0x5956ed>=_0x50185e;}async[_0x29bf1f(0x25b)](_0x145d85,_0xce74f0,_0x565061,_0xd56554=0x0){const _0x25148a=_0x29bf1f,_0x4e8530=await this[_0x25148a(0x1c6)][_0x25148a(0x1ec)]({'where':{'userId':_0x145d85}});if(!_0x4e8530)throw new common_1[(_0x25148a(0x20f))]('缺失当前用户账户记录!',common_1['HttpStatus'][_0x25148a(0x219)]);const _0x5c15af=_0xce74f0===_0x25148a(0x1c3)?_0x25148a(0x1f2):_0xce74f0===_0x25148a(0x1bd)?'memberModel4Count':_0xce74f0==='mjDraw'?_0x25148a(0x213):null,_0x481194=_0xce74f0===_0x25148a(0x1c3)?_0x25148a(0x1f4):_0xce74f0===_0x25148a(0x1bd)?_0x25148a(0x1e1):_0xce74f0===_0x25148a(0x20e)?'drawMjCount':null,_0x53f151=_0x4e8530['packageId']&&_0x4e8530[_0x5c15af]<_0x565061?_0x481194:_0x4e8530[_0x25148a(0x228)]?_0x5c15af:_0x481194;let _0x489af6=null;_0x53f151['includes'](_0x25148a(0x1e5))&&(_0x489af6=_0x25148a(0x23c));_0x53f151['includes'](_0x25148a(0x225))&&(_0x489af6='useModel4Token');_0x53f151[_0x25148a(0x1ce)](_0x25148a(0x241))&&(_0x489af6=_0x25148a(0x1c0));const _0xeda30={[_0x53f151]:_0x4e8530[_0x53f151]-_0x565061<0x0?0x0:_0x4e8530[_0x53f151]-_0x565061,[_0x489af6]:_0x4e8530[_0x489af6]+_0xd56554};_0x489af6==='useModel3Token'&&(_0xeda30[_0x25148a(0x254)]=_0x4e8530[_0x25148a(0x254)]+_0x565061),_0x489af6===_0x25148a(0x269)&&(_0xeda30['useModel4Count']=_0x4e8530['useModel4Count']+_0x565061);const _0x4a7f96=await this[_0x25148a(0x1c6)][_0x25148a(0x1bc)]({'userId':_0x145d85},_0xeda30);if(_0x4a7f96[_0x25148a(0x252)]===0x0)throw new common_1[(_0x25148a(0x20f))](_0x25148a(0x1fb),common_1[_0x25148a(0x234)][_0x25148a(0x219)]);}async['queryUserBalance'](_0xd6e3d8){const _0x33742d=_0x29bf1f;try{const _0x328d9b=await this[_0x33742d(0x1c6)][_0x33742d(0x1ec)]({'where':{'userId':_0xd6e3d8},'select':[_0x33742d(0x228),_0x33742d(0x1f4),_0x33742d(0x1e1),_0x33742d(0x1e9),_0x33742d(0x1f2),_0x33742d(0x243),_0x33742d(0x213),_0x33742d(0x254),'useModel4Count',_0x33742d(0x23c),_0x33742d(0x269),'useDrawMjToken','expirationTime']});if(!_0x328d9b){const _0x4d3666=await this[_0x33742d(0x1e0)](_0xd6e3d8);if(_0x4d3666)return await this[_0x33742d(0x22f)](_0xd6e3d8);else throw new common_1[(_0x33742d(0x20f))](_0x33742d(0x211),common_1[_0x33742d(0x234)][_0x33742d(0x219)]);}return _0x328d9b[_0x33742d(0x21b)]=_0x328d9b['packageId']?_0x328d9b[_0x33742d(0x1f4)]+_0x328d9b['memberModel3Count']:_0x328d9b[_0x33742d(0x1f4)],_0x328d9b[_0x33742d(0x1ca)]=_0x328d9b['packageId']?_0x328d9b[_0x33742d(0x1e1)]+_0x328d9b['memberModel4Count']:_0x328d9b[_0x33742d(0x1e1)],_0x328d9b[_0x33742d(0x259)]=_0x328d9b[_0x33742d(0x228)]?_0x328d9b['drawMjCount']+_0x328d9b[_0x33742d(0x213)]:_0x328d9b['drawMjCount'],_0x328d9b[_0x33742d(0x1b9)]=_0x328d9b[_0x33742d(0x1b9)]?(0x0,date_1['formatDate'])(_0x328d9b['expirationTime'],_0x33742d(0x206)):null,_0x328d9b;}catch(_0x1174d3){console[_0x33742d(0x1fd)](_0x33742d(0x1cb),_0x1174d3);}}async[_0x29bf1f(0x1d3)](_0x454be5){const _0x3c1922=_0x29bf1f,{userId:_0x3359e8,rechargeType:_0x27fd8e,model3Count:_0x2bfb55,model4Count:_0x4a1b1c,drawMjCount:_0x50eb91,days:days=-0x1,pkgName:pkgName='',extent:extent=''}=_0x454be5;if(!_0x3359e8)throw new common_1[(_0x3c1922(0x20f))](_0x3c1922(0x1d2),common_1['HttpStatus'][_0x3c1922(0x219)]);const _0x4433d5=(0x0,utils_1['createRandomUid'])();return await this[_0x3c1922(0x240)][_0x3c1922(0x255)]({'userId':_0x3359e8,'rechargeType':_0x27fd8e,'model3Count':_0x2bfb55,'model4Count':_0x4a1b1c,'drawMjCount':_0x50eb91,'days':days,'extent':extent,'uid':_0x4433d5,'pkgName':pkgName});}async[_0x29bf1f(0x1e0)](_0x9e864b,_0x98cb50={}){const _0x1f37b6=_0x29bf1f,{model3Count:model3Count=0x0,model4Count:model4Count=0x0,drawMjCount:drawMjCount=0x0}=_0x98cb50,_0x20debb=await this[_0x1f37b6(0x1c6)][_0x1f37b6(0x1ec)]({'where':{'userId':_0x9e864b}});if(_0x20debb)throw new common_1[(_0x1f37b6(0x20f))](_0x1f37b6(0x226),common_1[_0x1f37b6(0x234)][_0x1f37b6(0x219)]);return await this[_0x1f37b6(0x1c6)][_0x1f37b6(0x255)]({'userId':_0x9e864b,'model3Count':model3Count,'model4Count':model4Count,'drawMjCount':drawMjCount});}async[_0x29bf1f(0x20d)](_0x1c412b,_0x1450fc,_0x5e5d66=-0x1){const _0x4a0cc8=_0x29bf1f;try{const _0x3c812f=await this[_0x4a0cc8(0x1c6)]['findOne']({'where':{'userId':_0x1c412b}})||await this[_0x4a0cc8(0x1e0)](_0x1c412b);if(!_0x3c812f)throw new common_1[(_0x4a0cc8(0x20f))](_0x4a0cc8(0x260),common_1['HttpStatus'][_0x4a0cc8(0x219)]);const {model3Count:_0x5efdfd,model4Count:_0x2e8492,drawMjCount:_0x364573,memberModel3Count:_0x5b3156,memberModel4Count:_0x11f5f2,memberDrawMjCount:_0x2cd9ad}=_0x3c812f;let _0x18dcc0={};if(_0x5e5d66>0x0){const {packageId:_0x203886}=_0x1450fc;if(!_0x203886)throw new common_1[(_0x4a0cc8(0x20f))](_0x4a0cc8(0x1ed),common_1[_0x4a0cc8(0x234)]['BAD_REQUEST']);const _0x24ab95=await this[_0x4a0cc8(0x221)][_0x4a0cc8(0x1ec)]({'where':{'id':_0x203886}});if(!_0x24ab95)throw new common_1['HttpException'](_0x4a0cc8(0x244),common_1[_0x4a0cc8(0x234)]['BAD_REQUEST']);const {weight:_0xd5e922}=_0x24ab95;if(!_0x3c812f[_0x4a0cc8(0x228)])_0x18dcc0={'memberModel3Count':_0x5efdfd+_0x1450fc['model3Count'],'memberModel4Count':_0x2e8492+_0x1450fc['model4Count'],'memberDrawMjCount':_0x364573+_0x1450fc[_0x4a0cc8(0x1e9)],'expirationTime':(0x0,date_1['default'])()[_0x4a0cc8(0x1ef)](_0x5e5d66>0x0?_0x5e5d66:0x0,_0x4a0cc8(0x261))['format'](_0x4a0cc8(0x1f5)),'packageId':_0x203886};else{const _0x2098bc=await this[_0x4a0cc8(0x221)][_0x4a0cc8(0x1ec)]({'where':{'id':_0x3c812f[_0x4a0cc8(0x228)]}});_0xd5e922>=_0x2098bc['weight']&&(_0x18dcc0={'memberModel3Count':_0x5b3156+_0x1450fc[_0x4a0cc8(0x1f4)],'memberModel4Count':_0x11f5f2+_0x1450fc['model4Count'],'memberDrawMjCount':_0x2cd9ad+_0x1450fc['drawMjCount'],'expirationTime':(0x0,date_1[_0x4a0cc8(0x232)])(_0x3c812f['expirationTime'])[_0x4a0cc8(0x1ef)](_0x5e5d66>0x0?_0x5e5d66:0x0,'day')['format'](_0x4a0cc8(0x1f5)),'packageId':_0x203886}),_0xd5e922<_0x2098bc[_0x4a0cc8(0x22c)]&&(_0x18dcc0={'memberModel3Count':_0x5b3156+_0x1450fc['model3Count'],'memberModel4Count':_0x11f5f2+_0x1450fc[_0x4a0cc8(0x1e1)],'memberDrawMjCount':_0x2cd9ad+_0x1450fc[_0x4a0cc8(0x1e9)]});}}_0x5e5d66<=0x0&&(_0x18dcc0={'model3Count':_0x5efdfd+_0x1450fc['model3Count'],'model4Count':_0x2e8492+_0x1450fc[_0x4a0cc8(0x1e1)],'drawMjCount':_0x364573+_0x1450fc[_0x4a0cc8(0x1e9)]});const _0x2b8781=await this[_0x4a0cc8(0x1c6)][_0x4a0cc8(0x1bc)]({'userId':_0x1c412b},_0x18dcc0);if(_0x2b8781['affected']===0x0)throw new common_1['HttpException'](_0x1c412b+_0x4a0cc8(0x222),common_1[_0x4a0cc8(0x234)][_0x4a0cc8(0x219)]);}catch(_0x38f140){console['log'](_0x4a0cc8(0x1cb),_0x38f140);throw new common_1[(_0x4a0cc8(0x20f))](_0x4a0cc8(0x1d0),common_1[_0x4a0cc8(0x234)][_0x4a0cc8(0x219)]);}}async[_0x29bf1f(0x1ac)](_0x2d6d6b){const _0x6be29f=_0x29bf1f;console[_0x6be29f(0x1fd)](_0x6be29f(0x1d5),_0x2d6d6b);try{const {userId:_0x228fdd,goodsId:_0x199fa1}=_0x2d6d6b,_0x3aa049=await this[_0x6be29f(0x221)][_0x6be29f(0x1ec)]({'where':{'id':_0x2d6d6b[_0x6be29f(0x1f8)],'status':0x1}});if(!_0x3aa049)throw new common_1[(_0x6be29f(0x20f))](_0x6be29f(0x20b),common_1[_0x6be29f(0x234)][_0x6be29f(0x219)]);const {model3Count:_0x24d5a9,model4Count:_0x167b9a,drawMjCount:_0x4ebb94,days:_0x586f3b,name:_0x309063}=_0x3aa049,_0x1ef1e8={'model3Count':_0x24d5a9,'model4Count':_0x167b9a,'drawMjCount':_0x4ebb94,'days':_0x586f3b,'packageId':_0x2d6d6b[_0x6be29f(0x1f8)]};await this[_0x6be29f(0x20d)](_0x228fdd,_0x1ef1e8,_0x586f3b),await this[_0x6be29f(0x1d3)]({'userId':_0x228fdd,'rechargeType':balance_constant_1[_0x6be29f(0x267)]['SCAN_PAY'],'model3Count':_0x24d5a9,'model4Count':_0x167b9a,'drawMjCount':_0x4ebb94,'pkgName':_0x309063,'days':_0x586f3b});const _0xc2eedd=await this[_0x6be29f(0x22a)][_0x6be29f(0x1ec)]({'where':{'id':_0x228fdd}}),{invitedBy:_0x2302da}=_0xc2eedd;if(_0x2302da){const _0x4b79b1=await this[_0x6be29f(0x22a)][_0x6be29f(0x1ec)]({'where':{'inviteCode':_0x2302da}}),_0x4530ac=await this[_0x6be29f(0x23e)]['findOne']({'where':{'userId':_0x4b79b1['id']}});if(!_0x4b79b1)return;const {id:_0x3ff05c}=_0x4b79b1,{performanceRatio:_0x402a60}=_0x4530ac,_0x28a8c6={'inviterUserId':_0x3ff05c,'inviteeUserId':_0x228fdd,'orderId':_0x2d6d6b['id'],'orderPrice':_0x2d6d6b[_0x6be29f(0x26a)],'commissionPercentage':_0x402a60,'commissionAmount':(_0x2d6d6b[_0x6be29f(0x26a)]*_0x402a60/0x64)[_0x6be29f(0x1b0)](0x2)};await this[_0x6be29f(0x1b7)][_0x6be29f(0x1ba)](_0x28a8c6),await this['salesService'][_0x6be29f(0x1cd)](_0x3ff05c,_0x28a8c6[_0x6be29f(0x248)]);}}catch(_0x13904f){console[_0x6be29f(0x1fd)](_0x6be29f(0x1cb),_0x13904f);throw new common_1[(_0x6be29f(0x20f))](_0x6be29f(0x23a),common_1[_0x6be29f(0x234)][_0x6be29f(0x219)]);}}async[_0x29bf1f(0x262)](_0x4f7720,_0x5075b1){const _0x1c40c0=_0x29bf1f,{page:page=0x1,size:size=0x14}=_0x5075b1,{id:_0x1a25bc}=_0x4f7720['user'],[_0x1d9cdc,_0x4254ff]=await this[_0x1c40c0(0x240)][_0x1c40c0(0x1c9)]({'where':{'userId':_0x1a25bc},'order':{'id':_0x1c40c0(0x1cf)},'skip':(page-0x1)*size,'take':size});return _0x1d9cdc[_0x1c40c0(0x24f)](_0x466941=>{const _0x428de0=_0x1c40c0;_0x466941[_0x428de0(0x1da)]=_0x466941[_0x428de0(0x1f9)]>0x0?_0x466941[_0x428de0(0x1f9)]+'天':'永久';}),{'rows':(0x0,date_1['formatCreateOrUpdateDate'])(_0x1d9cdc),'count':_0x4254ff};}async[_0x29bf1f(0x200)](_0x7c037c,_0x2fcbf9){const _0x318932=_0x29bf1f;try{const {page:page=0x1,size:size=0xa,userId:_0x473f6c,rechargeType:_0x4708a4,packageId:_0x4e3232}=_0x2fcbf9,{role:_0x5209c9}=_0x7c037c[_0x318932(0x231)],_0x1f664a={};_0x4708a4&&(_0x1f664a['rechargeType']=_0x4708a4),_0x1f664a[_0x318932(0x205)]=_0x473f6c||(0x0,typeorm_2[_0x318932(0x25c)])(0x186a0),_0x4e3232&&(_0x1f664a[_0x318932(0x228)]={'$like':'%'+_0x4e3232+'%'});const [_0x376451,_0x2d5384]=await this[_0x318932(0x240)][_0x318932(0x1c9)]({'where':_0x1f664a,'order':{'id':_0x318932(0x1cf)},'skip':(page-0x1)*size,'take':size}),_0xd955b=_0x376451['map'](_0x3cafb9=>_0x3cafb9[_0x318932(0x205)]),_0x5919fb=await this['userEntity']['find']({'where':{'id':(0x0,typeorm_2['In'])(_0xd955b)}});return _0x376451[_0x318932(0x24f)](_0x9fb884=>{const _0x9f7d69=_0x318932,_0x532982=_0x5919fb[_0x9f7d69(0x237)](_0x32fd41=>_0x32fd41['id']===_0x9fb884[_0x9f7d69(0x205)]);_0x9fb884[_0x9f7d69(0x250)]=_0x532982===null||_0x532982===void 0x0?void 0x0:_0x532982[_0x9f7d69(0x250)],_0x9fb884['email']=_0x532982===null||_0x532982===void 0x0?void 0x0:_0x532982['email'],_0x9fb884[_0x9f7d69(0x230)]=_0x532982===null||_0x532982===void 0x0?void 0x0:_0x532982[_0x9f7d69(0x230)],_0x9fb884['status']=_0x532982===null||_0x532982===void 0x0?void 0x0:_0x532982['status'],_0x9fb884[_0x9f7d69(0x22b)]=_0x532982===null||_0x532982===void 0x0?void 0x0:_0x532982[_0x9f7d69(0x22b)];}),_0x5209c9!==_0x318932(0x253)&&_0x376451['forEach'](_0x5a5449=>{const _0x1c46e7=_0x318932;_0x5a5449[_0x1c46e7(0x1e3)]=_0x5a5449['email']?(0x0,utils_1[_0x1c46e7(0x239)])(_0x5a5449[_0x1c46e7(0x1e3)]):'',_0x5a5449[_0x1c46e7(0x230)]=_0x5a5449[_0x1c46e7(0x230)]?(0x0,utils_1[_0x1c46e7(0x239)])(_0x5a5449[_0x1c46e7(0x230)]):'';}),{'rows':_0x376451,'count':_0x2d5384};}catch(_0x2c63e6){console[_0x318932(0x1fd)]('error:\x20',_0x2c63e6);throw new common_1['HttpException'](_0x318932(0x24c),common_1[_0x318932(0x234)]['BAD_REQUEST']);}}async[_0x29bf1f(0x1f1)](_0x6ab004){const _0x4f50b6=_0x29bf1f;return await this[_0x4f50b6(0x1c6)][_0x4f50b6(0x237)]({'where':{'userId':(0x0,typeorm_2['In'])(_0x6ab004)}});}async[_0x29bf1f(0x24d)](_0x3f616c,_0x56fecf){const _0x41a3e7=_0x29bf1f;return await this[_0x41a3e7(0x25b)](_0x3f616c,_0x41a3e7(0x20e),-_0x56fecf);}async['upgradeBalance'](){const _0x3190d6=_0x29bf1f,_0x4d37e0=await this['userEntity']['find']();if(!_0x4d37e0[_0x3190d6(0x1e2)])return;const _0x40166d=await this['globalConfigService'][_0x3190d6(0x22d)]([_0x3190d6(0x212)]);if(!_0x40166d)await this[_0x3190d6(0x20a)][_0x3190d6(0x20c)]({'settings':[{'configKey':_0x3190d6(0x212),'configVal':'1'}]});else throw new common_1[(_0x3190d6(0x20f))](_0x3190d6(0x1f0),common_1['HttpStatus']['BAD_REQUEST']);_0x4d37e0[_0x3190d6(0x24f)](_0x1b00a7=>{const _0x496971=_0x3190d6,{id:_0x3fdb5e}=_0x1b00a7;this['balanceEntity']['findOne']({'where':{'userId':_0x3fdb5e}})[_0x496971(0x1d1)](_0x25a77b=>{const _0x2c09d8=_0x496971;if(!_0x25a77b)return;this[_0x2c09d8(0x1db)](_0x3fdb5e,_0x25a77b);});});}async[_0x29bf1f(0x1db)](_0x3b0291,_0x53de0f){const _0x426fe3=_0x29bf1f,{balance:balance=0x0,usesLeft:usesLeft=0x0,paintCount:paintCount=0x0,useTokens:useTokens=0x0,useChats:useChats=0x0,usePaints:usePaints=0x0}=_0x53de0f,_0xbc33f4=await this[_0x426fe3(0x23f)][_0x426fe3(0x1ec)]({'where':{'userId':_0x3b0291}}),_0x283a4d={'userId':_0x3b0291,'model3Count':Number(usesLeft),'model4Count':(_0xbc33f4===null||_0xbc33f4===void 0x0?void 0x0:_0xbc33f4['count'])||0x0,'drawMjCount':Number(balance),'useModel3Count':Number(useChats),'useModel4Count':(_0xbc33f4===null||_0xbc33f4===void 0x0?void 0x0:_0xbc33f4['useCount'])||0x0,'useDrawMjCount':Number(usePaints),'useModel3Token':Number(useTokens),'useModel4Token':0x0,'useDrawMjToken':0x0},_0x39afa9=await this[_0x426fe3(0x1c6)]['findOne']({'where':{'userId':_0x3b0291}});_0x39afa9?common_1[_0x426fe3(0x242)][_0x426fe3(0x25f)]('用户'+_0x3b0291+_0x426fe3(0x1f3),_0x426fe3(0x1d8)):this['userBalanceEntity'][_0x426fe3(0x255)](_0x283a4d)[_0x426fe3(0x1d1)](_0x15edf1=>{const _0xf1e8e6=_0x426fe3;common_1[_0xf1e8e6(0x242)][_0xf1e8e6(0x25f)]('用户'+_0x3b0291+_0xf1e8e6(0x1aa),_0xf1e8e6(0x1d8));})[_0x426fe3(0x1ff)](_0x359b9a=>{const _0x461752=_0x426fe3;console[_0x461752(0x1fd)](_0x461752(0x1cb),_0x359b9a),common_1[_0x461752(0x242)]['debug']('用户'+_0x3b0291+_0x461752(0x25d),_0x461752(0x1d8));});}async[_0x29bf1f(0x25e)](_0xbfe4e2){const _0xbfe14c=_0x29bf1f,{fingerprint:_0x23d7ed}=_0xbfe4e2[_0xbfe14c(0x264)],{id:_0x2bf778}=_0xbfe4e2[_0xbfe14c(0x231)];return await this[_0xbfe14c(0x1cc)]['update']({'userId':Number(_0x23d7ed)},{'userId':_0x2bf778}),await this[_0xbfe14c(0x223)][_0xbfe14c(0x1bc)]({'userId':Number(_0x23d7ed)},{'userId':_0x2bf778}),await this['midjourneyEntity']['update']({'userId':Number(_0x23d7ed)},{'userId':_0x2bf778}),0x1;}async[_0x29bf1f(0x1d4)](_0x2859be){const _0xf4c98e=_0x29bf1f,{fingerprint:_0x5afc80}=_0x2859be['headers'],_0x728597=await this[_0xf4c98e(0x1cc)][_0xf4c98e(0x233)]({'where':{'userId':_0x5afc80}}),_0x4ad26e=await this['chatGroupEntity'][_0xf4c98e(0x233)]({'where':{'userId':_0x5afc80}}),_0x35d361=await this['midjourneyEntity'][_0xf4c98e(0x233)]({'where':{'userId':_0x5afc80}});return _0x728597||_0x4ad26e||_0x35d361||0x0;}};UserBalanceService=__decorate([(0x0,common_1[_0x29bf1f(0x1b8)])(),__param(0x0,(0x0,typeorm_1[_0x29bf1f(0x256)])(balance_entity_1[_0x29bf1f(0x236)])),__param(0x1,(0x0,typeorm_1[_0x29bf1f(0x256)])(userBalance_entity_1[_0x29bf1f(0x1ea)])),__param(0x2,(0x0,typeorm_1[_0x29bf1f(0x256)])(accountLog_entity_1['AccountLogEntity'])),__param(0x3,(0x0,typeorm_1[_0x29bf1f(0x256)])(cramiPackage_entity_1[_0x29bf1f(0x26b)])),__param(0x4,(0x0,typeorm_1[_0x29bf1f(0x256)])(config_entity_1['ConfigEntity'])),__param(0x5,(0x0,typeorm_1[_0x29bf1f(0x256)])(user_entity_1[_0x29bf1f(0x258)])),__param(0x6,(0x0,typeorm_1[_0x29bf1f(0x256)])(salesUsers_entity_1['SalesUsersEntity'])),__param(0x7,(0x0,typeorm_1[_0x29bf1f(0x256)])(whiteList_entity_1[_0x29bf1f(0x207)])),__param(0x8,(0x0,typeorm_1['InjectRepository'])(fingerprint_entity_1['FingerprintLogEntity'])),__param(0x9,(0x0,typeorm_1[_0x29bf1f(0x256)])(chatGroup_entity_1['ChatGroupEntity'])),__param(0xa,(0x0,typeorm_1[_0x29bf1f(0x256)])(chatLog_entity_1[_0x29bf1f(0x251)])),__param(0xb,(0x0,typeorm_1[_0x29bf1f(0x256)])(midjourney_entity_1[_0x29bf1f(0x1df)])),__metadata(_0x29bf1f(0x1f7),[typeorm_2[_0x29bf1f(0x1bb)],typeorm_2['Repository'],typeorm_2['Repository'],typeorm_2[_0x29bf1f(0x1bb)],typeorm_2[_0x29bf1f(0x1bb)],typeorm_2[_0x29bf1f(0x1bb)],typeorm_2[_0x29bf1f(0x1bb)],typeorm_2['Repository'],typeorm_2[_0x29bf1f(0x1bb)],typeorm_2[_0x29bf1f(0x1bb)],typeorm_2[_0x29bf1f(0x1bb)],typeorm_2[_0x29bf1f(0x1bb)],sales_service_1[_0x29bf1f(0x215)],globalConfig_service_1['GlobalConfigService']])],UserBalanceService),exports[_0x29bf1f(0x21f)]=UserBalanceService;