mirror of
https://github.com/xiaoyiweb/YiAi.git
synced 2025-09-26 13:16:39 +08:00
1 line
15 KiB
JavaScript
1 line
15 KiB
JavaScript
'use strict';const _0x378c0b=_0x4a3a;(function(_0x3800f7,_0x194294){const _0xa7e137=_0x4a3a,_0x213555=_0x3800f7();while(!![]){try{const _0x4c90c1=-parseInt(_0xa7e137(0xc8))/0x1*(-parseInt(_0xa7e137(0x8e))/0x2)+parseInt(_0xa7e137(0xc0))/0x3*(parseInt(_0xa7e137(0xaf))/0x4)+-parseInt(_0xa7e137(0xf4))/0x5*(parseInt(_0xa7e137(0xcc))/0x6)+parseInt(_0xa7e137(0xd4))/0x7+parseInt(_0xa7e137(0xcf))/0x8+-parseInt(_0xa7e137(0xb8))/0x9*(-parseInt(_0xa7e137(0x97))/0xa)+-parseInt(_0xa7e137(0x88))/0xb*(parseInt(_0xa7e137(0x8d))/0xc);if(_0x4c90c1===_0x194294)break;else _0x213555['push'](_0x213555['shift']());}catch(_0x554054){_0x213555['push'](_0x213555['shift']());}}}(_0x4855,0x4af81));function _0x4855(){const _0x5bf0d7=['countChats','countNewMidhourneysToday','map','order.createdAt\x20>=\x20:today','chatLogEntity','countOrders','where','midjourney.status\x20=\x20:status','overview/getTimeTrendRpt','andWhere','../order/order.entity','https://openapi.baidu.com/rest/2.0/tongji/report/getData?access_token=','getCount','configKey','formatDate','groupBy','design:paramtypes','midjourney','HttpStatus','StatisticService','../user/user.entity','baiduToken','data','getDate','DATE(chatlog.createdAt)\x20as\x20date,\x20COUNT(*)\x20as\x20count','object','InjectRepository','642185SaEfmg','CHAT_TYPE','DeductionKey','MidjourneyEntity','getBaiduStatistics','chatLog.createdAt\x20<\x20:tomorrow','midjourneyEntity','typeorm','Repository','getBaseStatistic','__decorate','11suWboe','HttpException','getTime','__param','__esModule','15116496DjtfNH','2uyVXSU','countUsers','../../common/constants/midjourney.constant','setHours','&metrics=','select','@nestjs/typeorm','length','countNewOrdersToday','35800zERQgK','请先配置百度统计accessToken','countDraws','countNewChatsToday','YYYYMMDD','countMjDrawsByTimeRange','user.createdAt\x20>=\x20:today','user','&site_id=','../chatLog/chatLog.entity','now','chatLog.type\x20=\x20:type','find','user.createdAt\x20<\x20:tomorrow','../globalConfig/config.entity','百度授权码过期','Injectable','order','BAD_REQUEST','setDate','countNewUsersToday','../../common/constants/balance.constant','axios','function','4300CmmRgF','MidjourneyStatusEnum','M.DD','DATE(midjourney.createdAt)\x20as\x20date,\x20COUNT(*)\x20as\x20count','../../common/utils/date','countDrawsByTimeRange','push','get','chatlog.createdAt\x20>=\x20:startDate','1098bONhfT','&end_date=','&method=','createQueryBuilder','orderEntity','ConfigEntity','metadata','chatLog.createdAt\x20>=\x20:today','993ETMcpy','请先配置百度统计siteId','chatLog','userEntity','PAINT_TYPE','defineProperty','midjourney.createdAt\x20>=\x20:today','chatlog.type\x20=\x20:type','574493WHpSrT','__metadata','decorate','count','12sSzOXy','pv_count,visitor_count,ip_count,bounce_ratio,avg_visit_time','getRawMany','1141368rLNAus','configVal','@nestjs/common','value','configEntity','2197342zSMvlr','date','orderBy','baiduSiteId','../midjourney/midjourney.entity'];_0x4855=function(){return _0x5bf0d7;};return _0x4855();}function _0x4a3a(_0x56de7e,_0x32eb0b){const _0x4855ab=_0x4855();return _0x4a3a=function(_0x4a3ac2,_0x1fa5c0){_0x4a3ac2=_0x4a3ac2-0x80;let _0x1a67d1=_0x4855ab[_0x4a3ac2];return _0x1a67d1;},_0x4a3a(_0x56de7e,_0x32eb0b);}var __decorate=this&&this[_0x378c0b(0x87)]||function(_0xaf9a3a,_0x4814d7,_0x143081,_0x1ecac3){const _0x5321ed=_0x378c0b;var _0x181001=arguments[_0x5321ed(0x95)],_0x563b13=_0x181001<0x3?_0x4814d7:_0x1ecac3===null?_0x1ecac3=Object['getOwnPropertyDescriptor'](_0x4814d7,_0x143081):_0x1ecac3,_0x41fe33;if(typeof Reflect===_0x5321ed(0xf2)&&typeof Reflect['decorate']===_0x5321ed(0xae))_0x563b13=Reflect[_0x5321ed(0xca)](_0xaf9a3a,_0x4814d7,_0x143081,_0x1ecac3);else{for(var _0x43f9f1=_0xaf9a3a[_0x5321ed(0x95)]-0x1;_0x43f9f1>=0x0;_0x43f9f1--)if(_0x41fe33=_0xaf9a3a[_0x43f9f1])_0x563b13=(_0x181001<0x3?_0x41fe33(_0x563b13):_0x181001>0x3?_0x41fe33(_0x4814d7,_0x143081,_0x563b13):_0x41fe33(_0x4814d7,_0x143081))||_0x563b13;}return _0x181001>0x3&&_0x563b13&&Object['defineProperty'](_0x4814d7,_0x143081,_0x563b13),_0x563b13;},__metadata=this&&this[_0x378c0b(0xc9)]||function(_0x1c9fcf,_0x245333){const _0x3efc7e=_0x378c0b;if(typeof Reflect===_0x3efc7e(0xf2)&&typeof Reflect['metadata']===_0x3efc7e(0xae))return Reflect[_0x3efc7e(0xbe)](_0x1c9fcf,_0x245333);},__param=this&&this[_0x378c0b(0x8b)]||function(_0x5cf86b,_0x4373ae){return function(_0x49b20d,_0x1bee05){_0x4373ae(_0x49b20d,_0x1bee05,_0x5cf86b);};};Object[_0x378c0b(0xc5)](exports,_0x378c0b(0x8c),{'value':!![]}),exports[_0x378c0b(0xec)]=void 0x0;const common_1=require(_0x378c0b(0xd1)),typeorm_1=require(_0x378c0b(0x94)),user_entity_1=require(_0x378c0b(0xed)),typeorm_2=require(_0x378c0b(0x84)),chatLog_entity_1=require(_0x378c0b(0xa0)),balance_constant_1=require(_0x378c0b(0xac)),date_1=require(_0x378c0b(0xb3)),axios_1=require(_0x378c0b(0xad)),config_entity_1=require(_0x378c0b(0xa5)),order_entity_1=require(_0x378c0b(0xe3)),midjourney_entity_1=require(_0x378c0b(0xd8)),midjourney_constant_1=require(_0x378c0b(0x90));let StatisticService=class StatisticService{constructor(_0x23076a,_0x44e689,_0x10e3de,_0x5a5b18,_0x4665cd){const _0x41491=_0x378c0b;this['userEntity']=_0x23076a,this['chatLogEntity']=_0x44e689,this['configEntity']=_0x10e3de,this[_0x41491(0xbc)]=_0x5a5b18,this[_0x41491(0x83)]=_0x4665cd;}async[_0x378c0b(0x86)](){const _0x22ec82=_0x378c0b,_0x31fc16=await this['countUsers'](),_0x28eb09=await this[_0x22ec82(0xab)](),_0x4ad27e=await this[_0x22ec82(0xd9)](),_0x52b7e9=await this[_0x22ec82(0x9a)](),_0x273f00=await this[_0x22ec82(0x99)](),_0x175ec3=await this['countNewDrawsToday'](),_0x490303=await this['countNewMidhourneysToday'](),_0x54a64b=await this['countOrders'](),_0x2ff290=await this[_0x22ec82(0x96)]();return{'userCount':_0x31fc16,'newUserCount':_0x28eb09,'chatCount':_0x4ad27e,'newChatCount':_0x52b7e9,'drawCount':_0x273f00,'newDrawCount':_0x490303+_0x175ec3,'orderCount':_0x54a64b,'newOrderCount':_0x2ff290};}async['getChatStatistic']({days:days=0x7}){const _0x48b250=_0x378c0b,_0x1895ec=await this['countChatsByTimeRange'](days),_0x5951e5=await this[_0x48b250(0xb4)](days),_0x10b156=await this[_0x48b250(0x9c)](days);return{'date':_0x1895ec[_0x48b250(0xdb)](_0x24eda3=>_0x24eda3['date']),'chat':_0x1895ec['map'](_0x1109bf=>_0x1109bf[_0x48b250(0xd2)]),'draw':_0x5951e5[_0x48b250(0xdb)]((_0x17072d,_0x55e861)=>{const _0x5cde22=_0x48b250;return _0x17072d[_0x5cde22(0xd2)]+_0x10b156[_0x55e861][_0x5cde22(0xd2)];})};}async['getBaiduVisit']({days:days=0x7}){const _0x21540c=_0x378c0b,_0x3efc29=await this[_0x21540c(0x81)](days);return _0x3efc29;}async[_0x378c0b(0x8f)](){const _0x205a59=_0x378c0b,_0x58391a=await this['userEntity'][_0x205a59(0xcb)]();return _0x58391a;}async['countNewUsersToday'](){const _0x28cf9a=_0x378c0b,_0x3be5f3=new Date();_0x3be5f3['setHours'](0x0,0x0,0x0,0x0);const _0x14453b=new Date(_0x3be5f3['getTime']()+0x18*0x3c*0x3c*0x3e8),_0x147785=this[_0x28cf9a(0xc3)]['createQueryBuilder'](_0x28cf9a(0x9e)),_0x4afd69=await _0x147785[_0x28cf9a(0xdf)](_0x28cf9a(0x9d),{'today':_0x3be5f3})['andWhere'](_0x28cf9a(0xa4),{'tomorrow':_0x14453b})['getCount']();return _0x4afd69;}async[_0x378c0b(0xd9)](){const _0x3fa9e9=_0x378c0b,_0xa5f2c5=await this[_0x3fa9e9(0xdd)]['count']({'where':{'type':balance_constant_1['DeductionKey'][_0x3fa9e9(0xf5)]}});return _0xa5f2c5;}async[_0x378c0b(0x9a)](){const _0x5f35b4=_0x378c0b,_0x5727e8=new Date();_0x5727e8[_0x5f35b4(0x91)](0x0,0x0,0x0,0x0);const _0x29536c=new Date(_0x5727e8[_0x5f35b4(0x8a)]()+0x18*0x3c*0x3c*0x3e8),_0x4d7aba=this[_0x5f35b4(0xdd)][_0x5f35b4(0xbb)](_0x5f35b4(0xc2)),_0x339105=await _0x4d7aba['where'](_0x5f35b4(0xa2),{'type':balance_constant_1[_0x5f35b4(0xf6)][_0x5f35b4(0xf5)]})[_0x5f35b4(0xe2)]('chatLog.createdAt\x20>=\x20:today',{'today':_0x5727e8})['andWhere'](_0x5f35b4(0x82),{'tomorrow':_0x29536c})['getCount']();return _0x339105;}async['countDraws'](){const _0x497524=_0x378c0b,_0x5565d5=await this['chatLogEntity'][_0x497524(0xcb)]({'where':{'type':balance_constant_1[_0x497524(0xf6)]['PAINT_TYPE']}});return _0x5565d5;}async['countNewDrawsToday'](){const _0x14cb82=_0x378c0b,_0x324e03=new Date();_0x324e03['setHours'](0x0,0x0,0x0,0x0);const _0x467775=new Date(_0x324e03[_0x14cb82(0x8a)]()+0x18*0x3c*0x3c*0x3e8),_0x5317c1=this[_0x14cb82(0xdd)][_0x14cb82(0xbb)](_0x14cb82(0xc2)),_0x305199=await _0x5317c1[_0x14cb82(0xdf)](_0x14cb82(0xa2),{'type':balance_constant_1[_0x14cb82(0xf6)][_0x14cb82(0xc4)]})[_0x14cb82(0xe2)](_0x14cb82(0xbf),{'today':_0x324e03})[_0x14cb82(0xe2)]('chatLog.createdAt\x20<\x20:tomorrow',{'tomorrow':_0x467775})['getCount']();return _0x305199;}async[_0x378c0b(0xda)](){const _0x307aec=_0x378c0b,_0x3a410c=new Date();_0x3a410c[_0x307aec(0x91)](0x0,0x0,0x0,0x0);const _0x9165f3=new Date(_0x3a410c[_0x307aec(0x8a)]()+0x18*0x3c*0x3c*0x3e8),_0x33d5c2=this[_0x307aec(0x83)]['createQueryBuilder'](_0x307aec(0xea)),_0x21ee86=await _0x33d5c2['where'](_0x307aec(0xc6),{'today':_0x3a410c})[_0x307aec(0xe2)]('midjourney.createdAt\x20<\x20:tomorrow',{'tomorrow':_0x9165f3})[_0x307aec(0xe5)]();return _0x21ee86;}async['countChatsByTimeRange'](_0x3c1457){const _0x11e915=_0x378c0b;var _0x5acf75,_0x2e045b;const _0xc8f69c=new Date();_0xc8f69c[_0x11e915(0x91)](0x0,0x0,0x0,0x0);const _0x49db1f=new Date(_0xc8f69c[_0x11e915(0x8a)]()-(_0x3c1457-0x1)*0x18*0x3c*0x3c*0x3e8),_0x4bfc7e=this[_0x11e915(0xdd)]['createQueryBuilder']('chatlog'),_0x392dcc=await _0x4bfc7e[_0x11e915(0x93)](_0x11e915(0xf1))[_0x11e915(0xdf)](_0x11e915(0xc7),{'type':balance_constant_1[_0x11e915(0xf6)][_0x11e915(0xf5)]})[_0x11e915(0xe2)](_0x11e915(0xb7),{'startDate':_0x49db1f})[_0x11e915(0xe8)](_0x11e915(0xd5))[_0x11e915(0xd6)](_0x11e915(0xd5))[_0x11e915(0xce)](),_0x2e5507=[],_0x30ee63=_0x49db1f;for(let _0x3e1bf8=0x0;_0x3e1bf8<_0x3c1457;_0x3e1bf8++){const _0x5307f1=(0x0,date_1[_0x11e915(0xe7)])(new Date(_0x30ee63),'M.DD'),_0x3d1050=(_0x2e045b=(_0x5acf75=_0x392dcc[_0x11e915(0xa3)](_0x202727=>(0x0,date_1[_0x11e915(0xe7)])(new Date(_0x202727[_0x11e915(0xd5)]),'M.DD')===_0x5307f1))===null||_0x5acf75===void 0x0?void 0x0:_0x5acf75[_0x11e915(0xcb)])!==null&&_0x2e045b!==void 0x0?_0x2e045b:0x0;_0x3d1050>0x0?_0x2e5507[_0x11e915(0xb5)]({'date':_0x5307f1,'value':Number(_0x3d1050)}):_0x2e5507[_0x11e915(0xb5)]({'date':_0x5307f1,'value':0x0}),_0x30ee63[_0x11e915(0xaa)](_0x30ee63[_0x11e915(0xf0)]()+0x1);}return _0x2e5507;}async[_0x378c0b(0xb4)](_0x5bcae1){const _0x44e477=_0x378c0b;var _0x3c05da,_0x601bcd;const _0x1ad15b=new Date();_0x1ad15b[_0x44e477(0x91)](0x0,0x0,0x0,0x0);const _0x1fe960=new Date(_0x1ad15b[_0x44e477(0x8a)]()-(_0x5bcae1-0x1)*0x18*0x3c*0x3c*0x3e8),_0x2ba179=this[_0x44e477(0xdd)]['createQueryBuilder']('chatlog'),_0x4cb9dc=await _0x2ba179[_0x44e477(0x93)](_0x44e477(0xf1))[_0x44e477(0xdf)]('chatlog.type\x20=\x20:type',{'type':balance_constant_1['DeductionKey']['PAINT_TYPE']})['andWhere']('chatlog.createdAt\x20>=\x20:startDate',{'startDate':_0x1fe960})['groupBy'](_0x44e477(0xd5))[_0x44e477(0xd6)]('date')[_0x44e477(0xce)](),_0xd7bec8=[],_0x4d6dc0=_0x1fe960;for(let _0x460102=0x0;_0x460102<_0x5bcae1;_0x460102++){const _0x4078ca=(0x0,date_1['formatDate'])(new Date(_0x4d6dc0),_0x44e477(0xb1)),_0x28a564=(_0x601bcd=(_0x3c05da=_0x4cb9dc[_0x44e477(0xa3)](_0x379096=>(0x0,date_1[_0x44e477(0xe7)])(new Date(_0x379096[_0x44e477(0xd5)]),_0x44e477(0xb1))===_0x4078ca))===null||_0x3c05da===void 0x0?void 0x0:_0x3c05da[_0x44e477(0xcb)])!==null&&_0x601bcd!==void 0x0?_0x601bcd:0x0;_0x28a564>0x0?_0xd7bec8[_0x44e477(0xb5)]({'date':_0x4078ca,'value':Number(_0x28a564)}):_0xd7bec8[_0x44e477(0xb5)]({'date':_0x4078ca,'value':0x0}),_0x4d6dc0['setDate'](_0x4d6dc0[_0x44e477(0xf0)]()+0x1);}return _0xd7bec8;}async[_0x378c0b(0x9c)](_0x4e6d76){const _0x14e211=_0x378c0b;var _0x354426,_0x12c0d7;const _0x28e3d8=new Date();_0x28e3d8[_0x14e211(0x91)](0x0,0x0,0x0,0x0);const _0x1025b9=new Date(_0x28e3d8[_0x14e211(0x8a)]()-(_0x4e6d76-0x1)*0x18*0x3c*0x3c*0x3e8),_0x109cde=this[_0x14e211(0x83)][_0x14e211(0xbb)](_0x14e211(0xea)),_0x5cc271=await _0x109cde['select'](_0x14e211(0xb2))[_0x14e211(0xdf)](_0x14e211(0xe0),{'status':midjourney_constant_1[_0x14e211(0xb0)]['DRAWED']})[_0x14e211(0xe2)]('midjourney.createdAt\x20>=\x20:startDate',{'startDate':_0x1025b9})['groupBy'](_0x14e211(0xd5))[_0x14e211(0xd6)](_0x14e211(0xd5))[_0x14e211(0xce)](),_0x4b2d94=[],_0x508a1e=_0x1025b9;for(let _0x5dc1bc=0x0;_0x5dc1bc<_0x4e6d76;_0x5dc1bc++){const _0x51d325=(0x0,date_1['formatDate'])(new Date(_0x508a1e),_0x14e211(0xb1)),_0x4875c0=(_0x12c0d7=(_0x354426=_0x5cc271[_0x14e211(0xa3)](_0x5ded29=>(0x0,date_1[_0x14e211(0xe7)])(new Date(_0x5ded29[_0x14e211(0xd5)]),'M.DD')===_0x51d325))===null||_0x354426===void 0x0?void 0x0:_0x354426[_0x14e211(0xcb)])!==null&&_0x12c0d7!==void 0x0?_0x12c0d7:0x0;_0x4875c0>0x0?_0x4b2d94[_0x14e211(0xb5)]({'date':_0x51d325,'value':Number(_0x4875c0)}):_0x4b2d94['push']({'date':_0x51d325,'value':0x0}),_0x508a1e['setDate'](_0x508a1e['getDate']()+0x1);}return _0x4b2d94;}async['getBaiduStatistics'](_0x2fd201){const _0x6a40a8=_0x378c0b;var _0x5c31e5,_0x23aba0;const _0x46f44d=(0x0,date_1[_0x6a40a8(0xe7)])(new Date(),'YYYYMMDD'),_0x8a7546=(0x0,date_1['formatDate'])(new Date(Date[_0x6a40a8(0xa1)]()-Number(_0x2fd201-0x1)*0x18*0x3c*0x3c*0x3e8),_0x6a40a8(0x9b)),_0x1b39d5=_0x6a40a8(0xcd),_0x2bbce7=_0x6a40a8(0xe1),_0x53eecc=await this[_0x6a40a8(0xd3)][_0x6a40a8(0xa3)]({'where':{'configKey':(0x0,typeorm_2['In'])([_0x6a40a8(0xee),_0x6a40a8(0xd7)])}}),_0x2cbec0=(_0x5c31e5=_0x53eecc[_0x6a40a8(0xa3)](_0x2bd5bf=>_0x2bd5bf[_0x6a40a8(0xe6)]===_0x6a40a8(0xd7)))===null||_0x5c31e5===void 0x0?void 0x0:_0x5c31e5[_0x6a40a8(0xd0)],_0x32be7a=(_0x23aba0=_0x53eecc[_0x6a40a8(0xa3)](_0x35445b=>_0x35445b[_0x6a40a8(0xe6)]===_0x6a40a8(0xee)))===null||_0x23aba0===void 0x0?void 0x0:_0x23aba0['configVal'];if(!_0x2cbec0||!_0x32be7a)return[];if(!_0x2cbec0)throw new common_1[(_0x6a40a8(0x89))](_0x6a40a8(0xc1),common_1[_0x6a40a8(0xeb)][_0x6a40a8(0xa9)]);if(!_0x32be7a)throw new common_1[(_0x6a40a8(0x89))](_0x6a40a8(0x98),common_1[_0x6a40a8(0xeb)][_0x6a40a8(0xa9)]);const _0x36d1ff=_0x6a40a8(0xe4)+_0x32be7a+_0x6a40a8(0x9f)+_0x2cbec0+_0x6a40a8(0xba)+_0x2bbce7+'&start_date='+_0x8a7546+_0x6a40a8(0xb9)+_0x46f44d+_0x6a40a8(0x92)+_0x1b39d5,_0x128f79=await axios_1['default'][_0x6a40a8(0xb6)](_0x36d1ff),{error_code:_0xd1217b,message:_0x47b0f4}=_0x128f79['data'];if(_0xd1217b===0x6f)throw new common_1[(_0x6a40a8(0x89))](_0x47b0f4||_0x6a40a8(0xa6),common_1[_0x6a40a8(0xeb)]['BAD_REQUEST']);if(_0xd1217b&&_0xd1217b!==0xc8)throw new common_1[(_0x6a40a8(0x89))](_0x47b0f4||'获取百度统计数据失败',common_1['HttpStatus']['BAD_REQUEST']);return _0x128f79[_0x6a40a8(0xef)]['result'];}async[_0x378c0b(0xde)](){const _0x4a3c64=_0x378c0b,_0xa4701d=await this['orderEntity'][_0x4a3c64(0xcb)]();return _0xa4701d;}async[_0x378c0b(0x96)](){const _0x6a962b=_0x378c0b,_0x53bef8=new Date();_0x53bef8[_0x6a962b(0x91)](0x0,0x0,0x0,0x0);const _0x20459d=new Date(_0x53bef8[_0x6a962b(0x8a)]()+0x18*0x3c*0x3c*0x3e8),_0x225678=this[_0x6a962b(0xbc)][_0x6a962b(0xbb)](_0x6a962b(0xa8)),_0x3f2a4b=await _0x225678[_0x6a962b(0xdf)](_0x6a962b(0xdc),{'today':_0x53bef8})[_0x6a962b(0xe2)]('order.createdAt\x20<\x20:tomorrow',{'tomorrow':_0x20459d})[_0x6a962b(0xe5)]();return _0x3f2a4b;}};StatisticService=__decorate([(0x0,common_1[_0x378c0b(0xa7)])(),__param(0x0,(0x0,typeorm_1[_0x378c0b(0xf3)])(user_entity_1['UserEntity'])),__param(0x1,(0x0,typeorm_1[_0x378c0b(0xf3)])(chatLog_entity_1['ChatLogEntity'])),__param(0x2,(0x0,typeorm_1[_0x378c0b(0xf3)])(config_entity_1[_0x378c0b(0xbd)])),__param(0x3,(0x0,typeorm_1[_0x378c0b(0xf3)])(order_entity_1['OrderEntity'])),__param(0x4,(0x0,typeorm_1['InjectRepository'])(midjourney_entity_1[_0x378c0b(0x80)])),__metadata(_0x378c0b(0xe9),[typeorm_2[_0x378c0b(0x85)],typeorm_2[_0x378c0b(0x85)],typeorm_2[_0x378c0b(0x85)],typeorm_2[_0x378c0b(0x85)],typeorm_2['Repository']])],StatisticService),exports[_0x378c0b(0xec)]=StatisticService; |