YiAi/YiAiQuickDeploy/dist/modules/crami/crami.service.js
2024-02-06 13:43:30 +08:00

1 line
13 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 _0x48795e=_0x399a;(function(_0x5b2fe7,_0x152582){const _0x1afbfb=_0x399a,_0x5b0ec=_0x5b2fe7();while(!![]){try{const _0x479ddb=parseInt(_0x1afbfb(0x170))/0x1+-parseInt(_0x1afbfb(0x14d))/0x2*(parseInt(_0x1afbfb(0x135))/0x3)+parseInt(_0x1afbfb(0x14a))/0x4*(parseInt(_0x1afbfb(0x17e))/0x5)+parseInt(_0x1afbfb(0x17a))/0x6*(-parseInt(_0x1afbfb(0x154))/0x7)+parseInt(_0x1afbfb(0x136))/0x8+parseInt(_0x1afbfb(0x16d))/0x9+parseInt(_0x1afbfb(0x175))/0xa*(-parseInt(_0x1afbfb(0x149))/0xb);if(_0x479ddb===_0x152582)break;else _0x5b0ec['push'](_0x5b0ec['shift']());}catch(_0x4f7bde){_0x5b0ec['push'](_0x5b0ec['shift']());}}}(_0x36ed,0x77f4a));function _0x399a(_0x183d60,_0x4478c8){const _0x36ed6b=_0x36ed();return _0x399a=function(_0x399a43,_0x1e988e){_0x399a43=_0x399a43-0x11f;let _0x287b32=_0x36ed6b[_0x399a43];return _0x287b32;},_0x399a(_0x183d60,_0x4478c8);}var __decorate=this&&this[_0x48795e(0x160)]||function(_0x3b95bc,_0x191193,_0x5dc2ed,_0x13a869){const _0x416cbe=_0x48795e;var _0x58a059=arguments['length'],_0x107b31=_0x58a059<0x3?_0x191193:_0x13a869===null?_0x13a869=Object[_0x416cbe(0x146)](_0x191193,_0x5dc2ed):_0x13a869,_0xb7e90c;if(typeof Reflect==='object'&&typeof Reflect[_0x416cbe(0x17c)]===_0x416cbe(0x141))_0x107b31=Reflect[_0x416cbe(0x17c)](_0x3b95bc,_0x191193,_0x5dc2ed,_0x13a869);else{for(var _0x1bdbf2=_0x3b95bc[_0x416cbe(0x120)]-0x1;_0x1bdbf2>=0x0;_0x1bdbf2--)if(_0xb7e90c=_0x3b95bc[_0x1bdbf2])_0x107b31=(_0x58a059<0x3?_0xb7e90c(_0x107b31):_0x58a059>0x3?_0xb7e90c(_0x191193,_0x5dc2ed,_0x107b31):_0xb7e90c(_0x191193,_0x5dc2ed))||_0x107b31;}return _0x58a059>0x3&&_0x107b31&&Object[_0x416cbe(0x16c)](_0x191193,_0x5dc2ed,_0x107b31),_0x107b31;},__metadata=this&&this[_0x48795e(0x145)]||function(_0x22770b,_0x463e00){const _0x42d81a=_0x48795e;if(typeof Reflect===_0x42d81a(0x12c)&&typeof Reflect[_0x42d81a(0x179)]===_0x42d81a(0x141))return Reflect[_0x42d81a(0x179)](_0x22770b,_0x463e00);},__param=this&&this[_0x48795e(0x122)]||function(_0x27609c,_0x227594){return function(_0x20c3e9,_0x3cfb51){_0x227594(_0x20c3e9,_0x3cfb51,_0x27609c);};};Object[_0x48795e(0x16c)](exports,_0x48795e(0x12a),{'value':!![]}),exports[_0x48795e(0x144)]=void 0x0;const common_1=require(_0x48795e(0x164)),crami_entity_1=require(_0x48795e(0x147)),typeorm_1=require(_0x48795e(0x152)),typeorm_2=require('typeorm'),cramiPackage_entity_1=require(_0x48795e(0x13a)),utils_1=require('../../common/utils'),user_entity_1=require(_0x48795e(0x168)),userBalance_service_1=require('../userBalance/userBalance.service'),balance_constant_1=require(_0x48795e(0x159));function _0x36ed(){const _0x21374b=['maskEmail','super','packageId','metadata','18ulUMPV','RechargeType','decorate','delete','746180mFDMnR','useCrami','length','findOne','__param','findAndCount','userBalanceService','PACKAGE_GIFT','affected','更新套餐成功!','saveRecordRechargeLog','forEach','__esModule','generateCrami','object','当前卡密已被使用、请确认您输入的卡密是否正确!','Not','create','DESC','自定义卡密必须至少一项余额不为0','当前套餐不存在、请检查你的输入参数!','UserBalanceService','UserEntity','276873YXKRZU','6127576vVqepB','status','email','error:\x20','./cramiPackage.entity','generateCramiCode','update','当前套餐下存在卡密、请先删除卡密后才可删除套餐!','assign','map','createPackage','function','cramiEntity','当前卡密已被使用、已使用的卡密禁止删除!','CramiService','__metadata','getOwnPropertyDescriptor','./crami.entity','Repository','33NAgrjJ','16mAktRe','删除卡密失败、请重试!','code','4ywLfGA','updatePackage','user','使用卡密成功','design:paramtypes','@nestjs/typeorm','CramiEntity','1462328fkAaOp','InjectRepository','count','createCrami','username','../../common/constants/balance.constant','find','cramiPackageEntity','当前套餐不存在、请确认您选择的套餐是否存在!','every','CramiPackageEntity','MoreThan','__decorate','maskCrami','useId','userEntity','@nestjs/common','name','当前卡密不存在、请确认您要删除的卡密是否存在!','log','../user/user.entity','Injectable','save','delCrami','defineProperty','1645659dEdBpU','BAD_REQUEST','HttpException','751375fgGfQL','HttpStatus','queryAllPackage','queryAllCrami','queryOnePackage','3314950sIQfIO'];_0x36ed=function(){return _0x21374b;};return _0x36ed();}let CramiService=class CramiService{constructor(_0xdfaef1,_0x31c929,_0x2e9552,_0x789a85){const _0x10b519=_0x48795e;this[_0x10b519(0x142)]=_0xdfaef1,this[_0x10b519(0x15b)]=_0x31c929,this['userEntity']=_0x2e9552,this[_0x10b519(0x124)]=_0x789a85;}async[_0x48795e(0x174)](_0x2a3266){const _0x3abf0d=_0x48795e;return await this[_0x3abf0d(0x15b)][_0x3abf0d(0x121)]({'where':{'id':_0x2a3266}});}async[_0x48795e(0x172)](_0x2b0da2){const _0x4b9a4f=_0x48795e;try{const {page:page=0x1,size:size=0xa,name:_0x16ba1d,status:_0x529320,type:_0x8c2158}=_0x2b0da2,_0x56d248={};_0x16ba1d&&Object[_0x4b9a4f(0x13e)](_0x56d248,{'name':(0x0,typeorm_2['Like'])('%'+_0x16ba1d+'%')}),_0x529320&&Object['assign'](_0x56d248,{'status':_0x529320});_0x8c2158&&(_0x8c2158>0x0?Object[_0x4b9a4f(0x13e)](_0x56d248,{'days':(0x0,typeorm_2[_0x4b9a4f(0x15f)])(0x0)}):Object[_0x4b9a4f(0x13e)](_0x56d248,{'days':(0x0,typeorm_2['LessThanOrEqual'])(0x0)}));const [_0x1ec427,_0x52a4ca]=await this[_0x4b9a4f(0x15b)][_0x4b9a4f(0x123)]({'skip':(page-0x1)*size,'take':size,'where':_0x56d248,'order':{'order':_0x4b9a4f(0x130)}});return{'rows':_0x1ec427,'count':_0x52a4ca};}catch(_0x3fc430){console[_0x4b9a4f(0x167)](_0x4b9a4f(0x139),_0x3fc430);}}async[_0x48795e(0x140)](_0x1d372f){const _0x3123ae=_0x48795e,{name:_0x2b8927,weight:_0x239760}=_0x1d372f,_0x262ffa=await this[_0x3123ae(0x15b)][_0x3123ae(0x121)]({'where':[{'name':_0x2b8927},{'weight':_0x239760}]});if(_0x262ffa)throw new common_1[(_0x3123ae(0x16f))]('套餐名称或套餐等级重复、请检查!',common_1[_0x3123ae(0x171)][_0x3123ae(0x16e)]);try{return await this[_0x3123ae(0x15b)][_0x3123ae(0x16a)](_0x1d372f);}catch(_0x265e7e){console['log'](_0x3123ae(0x139),_0x265e7e);throw new common_1['HttpException'](_0x265e7e,common_1['HttpStatus']['BAD_REQUEST']);}}async[_0x48795e(0x14e)](_0x13363e){const _0x10cf1f=_0x48795e,{id:_0x3ebdc1,name:_0x196c8b,weight:_0x41fee9}=_0x13363e,_0xc6e5ab=await this[_0x10cf1f(0x15b)]['findOne']({'where':{'id':_0x3ebdc1}});if(!_0xc6e5ab)throw new common_1[(_0x10cf1f(0x16f))](_0x10cf1f(0x132),common_1['HttpStatus'][_0x10cf1f(0x16e)]);const _0x474da6=await this['cramiPackageEntity']['count']({'where':[{'name':_0x196c8b,'id':(0x0,typeorm_2[_0x10cf1f(0x12e)])(_0x3ebdc1)},{'weight':_0x41fee9,'id':(0x0,typeorm_2[_0x10cf1f(0x12e)])(_0x3ebdc1)}]});if(_0x474da6)throw new common_1[(_0x10cf1f(0x16f))]('套餐名称或套餐等级重复、请检查!',common_1[_0x10cf1f(0x171)][_0x10cf1f(0x16e)]);const _0x2637f5=await this[_0x10cf1f(0x15b)][_0x10cf1f(0x13c)]({'id':_0x3ebdc1},_0x13363e);if(_0x2637f5['affected']>0x0)return _0x10cf1f(0x127);else throw new common_1[(_0x10cf1f(0x16f))]('更新套餐失败、请重试!',common_1[_0x10cf1f(0x171)][_0x10cf1f(0x16e)]);}async['delPackage'](_0x234131){const _0x5c0e2b=_0x48795e,{id:_0x19eee5}=_0x234131,_0x1e061c=await this[_0x5c0e2b(0x142)][_0x5c0e2b(0x156)]({'where':{'packageId':_0x19eee5}});if(_0x1e061c)throw new common_1[(_0x5c0e2b(0x16f))](_0x5c0e2b(0x13d),common_1['HttpStatus'][_0x5c0e2b(0x16e)]);return await this['cramiPackageEntity'][_0x5c0e2b(0x17d)]({'id':_0x19eee5});}async[_0x48795e(0x157)](_0x3b78e7){const _0x10e6c1=_0x48795e,{packageId:_0x111c83,count:count=0x1}=_0x3b78e7;if(_0x111c83){const _0x140b1d=await this[_0x10e6c1(0x15b)]['findOne']({'where':{'id':_0x111c83}});if(!_0x140b1d)throw new common_1['HttpException'](_0x10e6c1(0x15c),common_1['HttpStatus'][_0x10e6c1(0x16e)]);const {days:days=-0x1,model3Count:model3Count=0x0,model4Count:model4Count=0x0,drawMjCount:drawMjCount=0x0}=_0x140b1d,_0x2016e0={'packageId':_0x111c83,'days':days,'model3Count':model3Count,'model4Count':model4Count,'drawMjCount':drawMjCount};return await this[_0x10e6c1(0x12b)](_0x2016e0,count);}if(!_0x111c83){const {model3Count:model3Count=0x0,model4Count:model4Count=0x0,drawMjCount:drawMjCount=0x0}=_0x3b78e7;if([model3Count,model4Count,drawMjCount][_0x10e6c1(0x15d)](_0x1041da=>!_0x1041da))throw new common_1['HttpException'](_0x10e6c1(0x131),common_1[_0x10e6c1(0x171)]['BAD_REQUEST']);const _0x2f9de8={'days':-0x1,'model3Count':model3Count,'model4Count':model4Count,'drawMjCount':drawMjCount};return await this['generateCrami'](_0x2f9de8,count);}}async[_0x48795e(0x12b)](_0x2f6ee5,_0x597e4c){const _0x52ed76=_0x48795e,_0x355ea6=[];for(let _0x2e2248=0x0;_0x2e2248<_0x597e4c;_0x2e2248++){const _0x3b9044=(0x0,utils_1[_0x52ed76(0x13b)])(),_0x1ff6b4=this[_0x52ed76(0x142)][_0x52ed76(0x12f)](Object[_0x52ed76(0x13e)](Object[_0x52ed76(0x13e)]({},_0x2f6ee5),{'code':_0x3b9044}));_0x355ea6['push'](_0x1ff6b4);}return await this['cramiEntity'][_0x52ed76(0x16a)](_0x355ea6);}async[_0x48795e(0x11f)](_0x22d677,_0x2c5523){const _0x1c5ed2=_0x48795e,{id:_0x36b5b1}=_0x22d677[_0x1c5ed2(0x14f)],_0x17718a=await this[_0x1c5ed2(0x142)][_0x1c5ed2(0x121)]({'where':{'code':_0x2c5523[_0x1c5ed2(0x14c)]}});if(!_0x17718a)throw new common_1[(_0x1c5ed2(0x16f))]('当前卡密不存在、请确认您输入的卡密是否正确!',common_1['HttpStatus'][_0x1c5ed2(0x16e)]);const {status:_0x442abd,days:days=-0x1,model3Count:model3Count=0x0,model4Count:model4Count=0x0,drawMjCount:drawMjCount=0x0,packageId:_0x311a1b}=_0x17718a;if(_0x442abd===0x1)throw new common_1['HttpException'](_0x1c5ed2(0x12d),common_1['HttpStatus'][_0x1c5ed2(0x16e)]);const _0xff5228={'model3Count':model3Count,'model4Count':model4Count,'drawMjCount':drawMjCount,'packageId':_0x311a1b};return await this[_0x1c5ed2(0x124)]['addBalanceToUser'](_0x36b5b1,Object['assign']({},_0xff5228),days),await this['userBalanceService'][_0x1c5ed2(0x128)]({'userId':_0x36b5b1,'rechargeType':balance_constant_1[_0x1c5ed2(0x17b)][_0x1c5ed2(0x125)],'model3Count':model3Count,'model4Count':model4Count,'drawMjCount':drawMjCount,'days':days}),await this[_0x1c5ed2(0x142)][_0x1c5ed2(0x13c)]({'code':_0x2c5523[_0x1c5ed2(0x14c)]},{'useId':_0x36b5b1,'status':0x1}),_0x1c5ed2(0x150);}async[_0x48795e(0x173)](_0xac9abd,_0x2322a3){const _0x505387=_0x48795e,{page:page=0x1,size:size=0xa,status:_0x1526a1,useId:_0x15c4b4}=_0xac9abd,_0x59f829={};_0x1526a1&&Object['assign'](_0x59f829,{'status':_0x1526a1}),_0x15c4b4&&Object['assign'](_0x59f829,{'useId':_0x15c4b4});const [_0x49f672,_0x5e2d21]=await this[_0x505387(0x142)][_0x505387(0x123)]({'skip':(page-0x1)*size,'take':size,'order':{'createdAt':_0x505387(0x130)},'where':_0x59f829}),_0x351f02=_0x49f672[_0x505387(0x13f)](_0x468bde=>_0x468bde[_0x505387(0x162)]),_0x267ac6=_0x49f672[_0x505387(0x13f)](_0x5f1cd2=>_0x5f1cd2[_0x505387(0x178)]),_0x262397=await this[_0x505387(0x163)][_0x505387(0x15a)]({'where':{'id':(0x0,typeorm_2['In'])(_0x351f02)}}),_0x567308=await this[_0x505387(0x15b)][_0x505387(0x15a)]({'where':{'id':(0x0,typeorm_2['In'])(_0x267ac6)}});return _0x49f672[_0x505387(0x129)](_0x3518b5=>{const _0x25dc30=_0x505387;var _0x38b164,_0x1f7d0e,_0x426fb6;_0x3518b5[_0x25dc30(0x158)]=(_0x38b164=_0x262397[_0x25dc30(0x15a)](_0x3f9382=>_0x3f9382['id']===_0x3518b5['useId']))===null||_0x38b164===void 0x0?void 0x0:_0x38b164[_0x25dc30(0x158)],_0x3518b5['email']=(_0x1f7d0e=_0x262397[_0x25dc30(0x15a)](_0x5a2d1a=>_0x5a2d1a['id']===_0x3518b5[_0x25dc30(0x162)]))===null||_0x1f7d0e===void 0x0?void 0x0:_0x1f7d0e['email'],_0x3518b5['packageName']=(_0x426fb6=_0x567308[_0x25dc30(0x15a)](_0x1a6231=>_0x1a6231['id']===_0x3518b5[_0x25dc30(0x178)]))===null||_0x426fb6===void 0x0?void 0x0:_0x426fb6[_0x25dc30(0x165)];}),_0x2322a3[_0x505387(0x14f)]['role']!==_0x505387(0x177)&&_0x49f672['forEach'](_0x30b5ca=>_0x30b5ca[_0x505387(0x138)]=(0x0,utils_1[_0x505387(0x176)])(_0x30b5ca['email'])),_0x2322a3[_0x505387(0x14f)]['role']!==_0x505387(0x177)&&_0x49f672[_0x505387(0x129)](_0xb9b28f=>_0xb9b28f['code']=(0x0,utils_1[_0x505387(0x161)])(_0xb9b28f[_0x505387(0x14c)])),{'rows':_0x49f672,'count':_0x5e2d21};}async[_0x48795e(0x16b)](_0x2157b6){const _0x5cb90f=_0x48795e,_0x1cddb3=await this['cramiEntity'][_0x5cb90f(0x121)]({'where':{'id':_0x2157b6}});if(!_0x1cddb3)throw new common_1[(_0x5cb90f(0x16f))](_0x5cb90f(0x166),common_1[_0x5cb90f(0x171)]['BAD_REQUEST']);if(_0x1cddb3[_0x5cb90f(0x137)]===0x1)throw new common_1[(_0x5cb90f(0x16f))](_0x5cb90f(0x143),common_1[_0x5cb90f(0x171)][_0x5cb90f(0x16e)]);return await this[_0x5cb90f(0x142)]['delete']({'id':_0x2157b6});}async['batchDelCrami'](_0x4e34ee){const _0x9103e3=_0x48795e,{ids:_0x45fe64}=_0x4e34ee,_0x47d6e9=await this[_0x9103e3(0x142)]['delete'](_0x45fe64);if(_0x47d6e9[_0x9103e3(0x126)]>0x0)return'删除卡密成功!';else throw new common_1[(_0x9103e3(0x16f))](_0x9103e3(0x14b),common_1[_0x9103e3(0x171)][_0x9103e3(0x16e)]);}};CramiService=__decorate([(0x0,common_1[_0x48795e(0x169)])(),__param(0x0,(0x0,typeorm_1[_0x48795e(0x155)])(crami_entity_1[_0x48795e(0x153)])),__param(0x1,(0x0,typeorm_1[_0x48795e(0x155)])(cramiPackage_entity_1[_0x48795e(0x15e)])),__param(0x2,(0x0,typeorm_1[_0x48795e(0x155)])(user_entity_1[_0x48795e(0x134)])),__metadata(_0x48795e(0x151),[typeorm_2['Repository'],typeorm_2[_0x48795e(0x148)],typeorm_2[_0x48795e(0x148)],userBalance_service_1[_0x48795e(0x133)]])],CramiService),exports[_0x48795e(0x144)]=CramiService;