'use strict';const _0x3e01a9=_0x4848;(function(_0x1d8740,_0x2b1ecb){const _0x53b3fa=_0x4848,_0x2cdb7d=_0x1d8740();while(!![]){try{const _0x177d13=-parseInt(_0x53b3fa(0x11c))/0x1+-parseInt(_0x53b3fa(0xfa))/0x2+parseInt(_0x53b3fa(0xee))/0x3*(parseInt(_0x53b3fa(0x11e))/0x4)+-parseInt(_0x53b3fa(0xdb))/0x5+-parseInt(_0x53b3fa(0x118))/0x6+-parseInt(_0x53b3fa(0xec))/0x7+parseInt(_0x53b3fa(0x115))/0x8;if(_0x177d13===_0x2b1ecb)break;else _0x2cdb7d['push'](_0x2cdb7d['shift']());}catch(_0x5ff7a8){_0x2cdb7d['push'](_0x2cdb7d['shift']());}}}(_0x2538,0x24c30));function _0x2538(){const _0x4c5fc6=['baiduSiteId','&metrics=','../midjourney/midjourney.entity','__param','974071SNeIXZ','Injectable','745278ByVDpw','chatLog.createdAt\x20>=\x20:today','getCount','axios','chatLogEntity','formatDate','midjourneyEntity','MidjourneyEntity','../../common/utils/date','get','getRawMany','countMjDrawsByTimeRange','328096pYHNmm','configKey','&site_id=','countChats','result','date','PAINT_TYPE','user.createdAt\x20>=\x20:today','HttpException','countChatsByTimeRange','../order/order.entity','user.createdAt\x20<\x20:tomorrow','DATE(chatlog.createdAt)\x20as\x20date,\x20COUNT(*)\x20as\x20count','../../common/constants/balance.constant','__decorate','DeductionKey','now','OrderEntity','../../common/constants/midjourney.constant','请先配置百度统计siteId','DATE(midjourney.createdAt)\x20as\x20date,\x20COUNT(*)\x20as\x20count','ConfigEntity','countNewUsersToday','countNewOrdersToday','M.DD','HttpStatus','typeorm','6209360VzVGix','InjectRepository','countDraws','699378jYJhmv','getBaiduStatistics','countNewChatsToday','find','247625HoZvBm','chatLog.createdAt\x20<\x20:tomorrow','4HhPlOP','function','orderEntity','midjourney.status\x20=\x20:status','countNewDrawsToday','userEntity','Repository','map','../user/user.entity','CHAT_TYPE','data','getOwnPropertyDescriptor','createQueryBuilder','user','chatlog.type\x20=\x20:type','countDrawsByTimeRange','getTime','chatLog.type\x20=\x20:type','object','getDate','请先配置百度统计accessToken','chatlog.createdAt\x20>=\x20:startDate','length','__metadata','configVal','configEntity','select','getBaiduVisit','defineProperty','where','countUsers','midjourney','@nestjs/typeorm','value','__esModule','groupBy','count','order.createdAt\x20<\x20:tomorrow','countNewMidhourneysToday','chatlog','decorate','getChatStatistic','setDate','BAD_REQUEST','metadata','StatisticService','1033155TdmmqD','UserEntity','setHours','ChatLogEntity','push','YYYYMMDD','andWhere','@nestjs/common','&method=','https://openapi.baidu.com/rest/2.0/tongji/report/getData?access_token=','orderBy','design:paramtypes','chatLog'];_0x2538=function(){return _0x4c5fc6;};return _0x2538();}var __decorate=this&&this[_0x3e01a9(0x108)]||function(_0x541956,_0x40c79f,_0xafaffe,_0x5e2edd){const _0x2c225f=_0x3e01a9;var _0x46b513=arguments[_0x2c225f(0x134)],_0x5c74b5=_0x46b513<0x3?_0x40c79f:_0x5e2edd===null?_0x5e2edd=Object[_0x2c225f(0x129)](_0x40c79f,_0xafaffe):_0x5e2edd,_0x17e8c1;if(typeof Reflect===_0x2c225f(0x130)&&typeof Reflect[_0x2c225f(0xd5)]===_0x2c225f(0x11f))_0x5c74b5=Reflect[_0x2c225f(0xd5)](_0x541956,_0x40c79f,_0xafaffe,_0x5e2edd);else{for(var _0x225cf8=_0x541956[_0x2c225f(0x134)]-0x1;_0x225cf8>=0x0;_0x225cf8--)if(_0x17e8c1=_0x541956[_0x225cf8])_0x5c74b5=(_0x46b513<0x3?_0x17e8c1(_0x5c74b5):_0x46b513>0x3?_0x17e8c1(_0x40c79f,_0xafaffe,_0x5c74b5):_0x17e8c1(_0x40c79f,_0xafaffe))||_0x5c74b5;}return _0x46b513>0x3&&_0x5c74b5&&Object[_0x2c225f(0x13a)](_0x40c79f,_0xafaffe,_0x5c74b5),_0x5c74b5;},__metadata=this&&this[_0x3e01a9(0x135)]||function(_0x6e1f3f,_0x4eb48a){const _0x4c3164=_0x3e01a9;if(typeof Reflect===_0x4c3164(0x130)&&typeof Reflect[_0x4c3164(0xd9)]===_0x4c3164(0x11f))return Reflect[_0x4c3164(0xd9)](_0x6e1f3f,_0x4eb48a);},__param=this&&this[_0x3e01a9(0xeb)]||function(_0x1fb3e4,_0x473106){return function(_0x49da8b,_0x447d7f){_0x473106(_0x49da8b,_0x447d7f,_0x1fb3e4);};};Object['defineProperty'](exports,_0x3e01a9(0x140),{'value':!![]}),exports[_0x3e01a9(0xda)]=void 0x0;function _0x4848(_0x12b23f,_0x8c2e57){const _0x2538e6=_0x2538();return _0x4848=function(_0x484832,_0x23e14b){_0x484832=_0x484832-0xd0;let _0x136d94=_0x2538e6[_0x484832];return _0x136d94;},_0x4848(_0x12b23f,_0x8c2e57);}const common_1=require(_0x3e01a9(0xe2)),typeorm_1=require(_0x3e01a9(0x13e)),user_entity_1=require(_0x3e01a9(0x126)),typeorm_2=require(_0x3e01a9(0x114)),chatLog_entity_1=require('../chatLog/chatLog.entity'),balance_constant_1=require(_0x3e01a9(0x107)),date_1=require(_0x3e01a9(0xf6)),axios_1=require(_0x3e01a9(0xf1)),config_entity_1=require('../globalConfig/config.entity'),order_entity_1=require(_0x3e01a9(0x104)),midjourney_entity_1=require(_0x3e01a9(0xea)),midjourney_constant_1=require(_0x3e01a9(0x10c));let StatisticService=class StatisticService{constructor(_0x3a6e10,_0x5ffeee,_0x1e426c,_0x3c8a3d,_0x4e5c2c){const _0x5e6c09=_0x3e01a9;this[_0x5e6c09(0x123)]=_0x3a6e10,this[_0x5e6c09(0xf2)]=_0x5ffeee,this[_0x5e6c09(0x137)]=_0x1e426c,this[_0x5e6c09(0x120)]=_0x3c8a3d,this['midjourneyEntity']=_0x4e5c2c;}async['getBaseStatistic'](){const _0xcda510=_0x3e01a9,_0x3ed2ff=await this[_0xcda510(0x13c)](),_0x11691b=await this[_0xcda510(0x110)](),_0x53d1d8=await this[_0xcda510(0xfd)](),_0x34bb12=await this[_0xcda510(0x11a)](),_0x2374a5=await this['countDraws'](),_0x15eeee=await this[_0xcda510(0x122)](),_0x285250=await this['countNewMidhourneysToday'](),_0x1004ee=await this['countOrders'](),_0x4bbaf4=await this[_0xcda510(0x111)]();return{'userCount':_0x3ed2ff,'newUserCount':_0x11691b,'chatCount':_0x53d1d8,'newChatCount':_0x34bb12,'drawCount':_0x2374a5,'newDrawCount':_0x285250+_0x15eeee,'orderCount':_0x1004ee,'newOrderCount':_0x4bbaf4};}async[_0x3e01a9(0xd6)]({days:days=0x7}){const _0x599029=_0x3e01a9,_0x1b01f1=await this['countChatsByTimeRange'](days),_0x4dc7c1=await this[_0x599029(0x12d)](days),_0x31711=await this[_0x599029(0xf9)](days);return{'date':_0x1b01f1[_0x599029(0x125)](_0x671785=>_0x671785['date']),'chat':_0x1b01f1[_0x599029(0x125)](_0xbc1d35=>_0xbc1d35[_0x599029(0x13f)]),'draw':_0x4dc7c1[_0x599029(0x125)]((_0x1d3936,_0xb1a819)=>{const _0xb9089=_0x599029;return _0x1d3936[_0xb9089(0x13f)]+_0x31711[_0xb1a819][_0xb9089(0x13f)];})};}async[_0x3e01a9(0x139)]({days:days=0x7}){const _0x47db59=await this['getBaiduStatistics'](days);return _0x47db59;}async['countUsers'](){const _0x459b91=_0x3e01a9,_0x29065c=await this[_0x459b91(0x123)][_0x459b91(0xd1)]();return _0x29065c;}async[_0x3e01a9(0x110)](){const _0x4f6a46=_0x3e01a9,_0x42cff3=new Date();_0x42cff3['setHours'](0x0,0x0,0x0,0x0);const _0x5defd3=new Date(_0x42cff3[_0x4f6a46(0x12e)]()+0x18*0x3c*0x3c*0x3e8),_0x4fbf1b=this[_0x4f6a46(0x123)][_0x4f6a46(0x12a)](_0x4f6a46(0x12b)),_0x4dbb85=await _0x4fbf1b[_0x4f6a46(0x13b)](_0x4f6a46(0x101),{'today':_0x42cff3})['andWhere'](_0x4f6a46(0x105),{'tomorrow':_0x5defd3})[_0x4f6a46(0xf0)]();return _0x4dbb85;}async[_0x3e01a9(0xfd)](){const _0x163dfb=_0x3e01a9,_0x4c687e=await this[_0x163dfb(0xf2)][_0x163dfb(0xd1)]({'where':{'type':balance_constant_1[_0x163dfb(0x109)][_0x163dfb(0x127)]}});return _0x4c687e;}async[_0x3e01a9(0x11a)](){const _0x38b56d=_0x3e01a9,_0x1d6d84=new Date();_0x1d6d84[_0x38b56d(0xdd)](0x0,0x0,0x0,0x0);const _0x925123=new Date(_0x1d6d84[_0x38b56d(0x12e)]()+0x18*0x3c*0x3c*0x3e8),_0xaecf69=this['chatLogEntity'][_0x38b56d(0x12a)](_0x38b56d(0xe7)),_0x39674d=await _0xaecf69[_0x38b56d(0x13b)](_0x38b56d(0x12f),{'type':balance_constant_1[_0x38b56d(0x109)]['CHAT_TYPE']})['andWhere'](_0x38b56d(0xef),{'today':_0x1d6d84})['andWhere'](_0x38b56d(0x11d),{'tomorrow':_0x925123})[_0x38b56d(0xf0)]();return _0x39674d;}async[_0x3e01a9(0x117)](){const _0x1d241c=_0x3e01a9,_0x3a48b5=await this[_0x1d241c(0xf2)][_0x1d241c(0xd1)]({'where':{'type':balance_constant_1[_0x1d241c(0x109)][_0x1d241c(0x100)]}});return _0x3a48b5;}async[_0x3e01a9(0x122)](){const _0x3a7fcc=_0x3e01a9,_0x2db686=new Date();_0x2db686[_0x3a7fcc(0xdd)](0x0,0x0,0x0,0x0);const _0x372428=new Date(_0x2db686[_0x3a7fcc(0x12e)]()+0x18*0x3c*0x3c*0x3e8),_0x544861=this[_0x3a7fcc(0xf2)][_0x3a7fcc(0x12a)](_0x3a7fcc(0xe7)),_0x1c5158=await _0x544861[_0x3a7fcc(0x13b)](_0x3a7fcc(0x12f),{'type':balance_constant_1[_0x3a7fcc(0x109)]['PAINT_TYPE']})[_0x3a7fcc(0xe1)](_0x3a7fcc(0xef),{'today':_0x2db686})[_0x3a7fcc(0xe1)](_0x3a7fcc(0x11d),{'tomorrow':_0x372428})[_0x3a7fcc(0xf0)]();return _0x1c5158;}async[_0x3e01a9(0xd3)](){const _0x4b4053=_0x3e01a9,_0x8cdfc2=new Date();_0x8cdfc2['setHours'](0x0,0x0,0x0,0x0);const _0x8332a5=new Date(_0x8cdfc2[_0x4b4053(0x12e)]()+0x18*0x3c*0x3c*0x3e8),_0x29bc76=this['midjourneyEntity'][_0x4b4053(0x12a)](_0x4b4053(0x13d)),_0x557c56=await _0x29bc76[_0x4b4053(0x13b)]('midjourney.createdAt\x20>=\x20:today',{'today':_0x8cdfc2})[_0x4b4053(0xe1)]('midjourney.createdAt\x20<\x20:tomorrow',{'tomorrow':_0x8332a5})[_0x4b4053(0xf0)]();return _0x557c56;}async[_0x3e01a9(0x103)](_0x28d292){const _0x88aed7=_0x3e01a9;var _0x4a1611,_0x38f0e9;const _0x2205c3=new Date();_0x2205c3['setHours'](0x0,0x0,0x0,0x0);const _0x363158=new Date(_0x2205c3['getTime']()-(_0x28d292-0x1)*0x18*0x3c*0x3c*0x3e8),_0xfed21b=this[_0x88aed7(0xf2)]['createQueryBuilder'](_0x88aed7(0xd4)),_0xb8fac3=await _0xfed21b[_0x88aed7(0x138)]('DATE(chatlog.createdAt)\x20as\x20date,\x20COUNT(*)\x20as\x20count')[_0x88aed7(0x13b)](_0x88aed7(0x12c),{'type':balance_constant_1[_0x88aed7(0x109)][_0x88aed7(0x127)]})[_0x88aed7(0xe1)](_0x88aed7(0x133),{'startDate':_0x363158})[_0x88aed7(0xd0)](_0x88aed7(0xff))['orderBy'](_0x88aed7(0xff))['getRawMany'](),_0x587653=[],_0xd98215=_0x363158;for(let _0x40cf18=0x0;_0x40cf18<_0x28d292;_0x40cf18++){const _0x726191=(0x0,date_1[_0x88aed7(0xf3)])(new Date(_0xd98215),_0x88aed7(0x112)),_0x23941b=(_0x38f0e9=(_0x4a1611=_0xb8fac3[_0x88aed7(0x11b)](_0x4e1173=>(0x0,date_1['formatDate'])(new Date(_0x4e1173[_0x88aed7(0xff)]),_0x88aed7(0x112))===_0x726191))===null||_0x4a1611===void 0x0?void 0x0:_0x4a1611[_0x88aed7(0xd1)])!==null&&_0x38f0e9!==void 0x0?_0x38f0e9:0x0;_0x23941b>0x0?_0x587653[_0x88aed7(0xdf)]({'date':_0x726191,'value':Number(_0x23941b)}):_0x587653[_0x88aed7(0xdf)]({'date':_0x726191,'value':0x0}),_0xd98215[_0x88aed7(0xd7)](_0xd98215[_0x88aed7(0x131)]()+0x1);}return _0x587653;}async['countDrawsByTimeRange'](_0xc9d1ec){const _0x1db44f=_0x3e01a9;var _0x5be11b,_0x3c7c72;const _0x3a5a68=new Date();_0x3a5a68[_0x1db44f(0xdd)](0x0,0x0,0x0,0x0);const _0x279e34=new Date(_0x3a5a68[_0x1db44f(0x12e)]()-(_0xc9d1ec-0x1)*0x18*0x3c*0x3c*0x3e8),_0x516618=this[_0x1db44f(0xf2)]['createQueryBuilder']('chatlog'),_0x3d7733=await _0x516618[_0x1db44f(0x138)](_0x1db44f(0x106))[_0x1db44f(0x13b)]('chatlog.type\x20=\x20:type',{'type':balance_constant_1[_0x1db44f(0x109)][_0x1db44f(0x100)]})[_0x1db44f(0xe1)](_0x1db44f(0x133),{'startDate':_0x279e34})[_0x1db44f(0xd0)](_0x1db44f(0xff))[_0x1db44f(0xe5)](_0x1db44f(0xff))['getRawMany'](),_0x1a9505=[],_0x4548ca=_0x279e34;for(let _0x12c556=0x0;_0x12c556<_0xc9d1ec;_0x12c556++){const _0x4e5e4a=(0x0,date_1[_0x1db44f(0xf3)])(new Date(_0x4548ca),_0x1db44f(0x112)),_0x37557a=(_0x3c7c72=(_0x5be11b=_0x3d7733[_0x1db44f(0x11b)](_0x521cd4=>(0x0,date_1[_0x1db44f(0xf3)])(new Date(_0x521cd4[_0x1db44f(0xff)]),'M.DD')===_0x4e5e4a))===null||_0x5be11b===void 0x0?void 0x0:_0x5be11b[_0x1db44f(0xd1)])!==null&&_0x3c7c72!==void 0x0?_0x3c7c72:0x0;_0x37557a>0x0?_0x1a9505[_0x1db44f(0xdf)]({'date':_0x4e5e4a,'value':Number(_0x37557a)}):_0x1a9505[_0x1db44f(0xdf)]({'date':_0x4e5e4a,'value':0x0}),_0x4548ca[_0x1db44f(0xd7)](_0x4548ca[_0x1db44f(0x131)]()+0x1);}return _0x1a9505;}async[_0x3e01a9(0xf9)](_0x325ac4){const _0x21312d=_0x3e01a9;var _0x6e5751,_0x2ca5f7;const _0x2d2bb3=new Date();_0x2d2bb3['setHours'](0x0,0x0,0x0,0x0);const _0x82d5c5=new Date(_0x2d2bb3[_0x21312d(0x12e)]()-(_0x325ac4-0x1)*0x18*0x3c*0x3c*0x3e8),_0x21a3ea=this[_0x21312d(0xf4)]['createQueryBuilder'](_0x21312d(0x13d)),_0x15b305=await _0x21a3ea[_0x21312d(0x138)](_0x21312d(0x10e))['where'](_0x21312d(0x121),{'status':midjourney_constant_1['MidjourneyStatusEnum']['DRAWED']})[_0x21312d(0xe1)]('midjourney.createdAt\x20>=\x20:startDate',{'startDate':_0x82d5c5})[_0x21312d(0xd0)](_0x21312d(0xff))[_0x21312d(0xe5)]('date')[_0x21312d(0xf8)](),_0x301047=[],_0x395782=_0x82d5c5;for(let _0x361e98=0x0;_0x361e98<_0x325ac4;_0x361e98++){const _0x5370bf=(0x0,date_1[_0x21312d(0xf3)])(new Date(_0x395782),_0x21312d(0x112)),_0x328762=(_0x2ca5f7=(_0x6e5751=_0x15b305[_0x21312d(0x11b)](_0x54f096=>(0x0,date_1[_0x21312d(0xf3)])(new Date(_0x54f096[_0x21312d(0xff)]),_0x21312d(0x112))===_0x5370bf))===null||_0x6e5751===void 0x0?void 0x0:_0x6e5751[_0x21312d(0xd1)])!==null&&_0x2ca5f7!==void 0x0?_0x2ca5f7:0x0;_0x328762>0x0?_0x301047[_0x21312d(0xdf)]({'date':_0x5370bf,'value':Number(_0x328762)}):_0x301047['push']({'date':_0x5370bf,'value':0x0}),_0x395782['setDate'](_0x395782['getDate']()+0x1);}return _0x301047;}async[_0x3e01a9(0x119)](_0x154042){const _0x53bda7=_0x3e01a9;var _0x55c41c,_0x505b9f;const _0x8783f=(0x0,date_1[_0x53bda7(0xf3)])(new Date(),_0x53bda7(0xe0)),_0xc90fdc=(0x0,date_1[_0x53bda7(0xf3)])(new Date(Date[_0x53bda7(0x10a)]()-Number(_0x154042-0x1)*0x18*0x3c*0x3c*0x3e8),'YYYYMMDD'),_0x4df218='pv_count,visitor_count,ip_count,bounce_ratio,avg_visit_time',_0x52a0d4='overview/getTimeTrendRpt',_0x49af84=await this[_0x53bda7(0x137)][_0x53bda7(0x11b)]({'where':{'configKey':(0x0,typeorm_2['In'])(['baiduToken',_0x53bda7(0xe8)])}}),_0x16cf34=(_0x55c41c=_0x49af84[_0x53bda7(0x11b)](_0xa90068=>_0xa90068[_0x53bda7(0xfb)]===_0x53bda7(0xe8)))===null||_0x55c41c===void 0x0?void 0x0:_0x55c41c[_0x53bda7(0x136)],_0x4f785b=(_0x505b9f=_0x49af84[_0x53bda7(0x11b)](_0x1259de=>_0x1259de[_0x53bda7(0xfb)]==='baiduToken'))===null||_0x505b9f===void 0x0?void 0x0:_0x505b9f[_0x53bda7(0x136)];if(!_0x16cf34||!_0x4f785b)return[];if(!_0x16cf34)throw new common_1[(_0x53bda7(0x102))](_0x53bda7(0x10d),common_1[_0x53bda7(0x113)]['BAD_REQUEST']);if(!_0x4f785b)throw new common_1[(_0x53bda7(0x102))](_0x53bda7(0x132),common_1[_0x53bda7(0x113)][_0x53bda7(0xd8)]);const _0x4197dc=_0x53bda7(0xe4)+_0x4f785b+_0x53bda7(0xfc)+_0x16cf34+_0x53bda7(0xe3)+_0x52a0d4+'&start_date='+_0xc90fdc+'&end_date='+_0x8783f+_0x53bda7(0xe9)+_0x4df218,_0x390656=await axios_1['default'][_0x53bda7(0xf7)](_0x4197dc),{error_code:_0x21328e,message:_0x46c1f7}=_0x390656['data'];if(_0x21328e===0x6f)throw new common_1[(_0x53bda7(0x102))](_0x46c1f7||'百度授权码过期',common_1[_0x53bda7(0x113)][_0x53bda7(0xd8)]);if(_0x21328e&&_0x21328e!==0xc8)throw new common_1[(_0x53bda7(0x102))](_0x46c1f7||'获取百度统计数据失败',common_1[_0x53bda7(0x113)][_0x53bda7(0xd8)]);return _0x390656[_0x53bda7(0x128)][_0x53bda7(0xfe)];}async['countOrders'](){const _0x4615d3=_0x3e01a9,_0x19338a=await this[_0x4615d3(0x120)]['count']();return _0x19338a;}async['countNewOrdersToday'](){const _0x43aa2c=_0x3e01a9,_0x4c60c7=new Date();_0x4c60c7[_0x43aa2c(0xdd)](0x0,0x0,0x0,0x0);const _0xbad64b=new Date(_0x4c60c7[_0x43aa2c(0x12e)]()+0x18*0x3c*0x3c*0x3e8),_0x234d49=this[_0x43aa2c(0x120)][_0x43aa2c(0x12a)]('order'),_0x3ee4b3=await _0x234d49[_0x43aa2c(0x13b)]('order.createdAt\x20>=\x20:today',{'today':_0x4c60c7})[_0x43aa2c(0xe1)](_0x43aa2c(0xd2),{'tomorrow':_0xbad64b})[_0x43aa2c(0xf0)]();return _0x3ee4b3;}};StatisticService=__decorate([(0x0,common_1[_0x3e01a9(0xed)])(),__param(0x0,(0x0,typeorm_1[_0x3e01a9(0x116)])(user_entity_1[_0x3e01a9(0xdc)])),__param(0x1,(0x0,typeorm_1[_0x3e01a9(0x116)])(chatLog_entity_1[_0x3e01a9(0xde)])),__param(0x2,(0x0,typeorm_1[_0x3e01a9(0x116)])(config_entity_1[_0x3e01a9(0x10f)])),__param(0x3,(0x0,typeorm_1[_0x3e01a9(0x116)])(order_entity_1[_0x3e01a9(0x10b)])),__param(0x4,(0x0,typeorm_1[_0x3e01a9(0x116)])(midjourney_entity_1[_0x3e01a9(0xf5)])),__metadata(_0x3e01a9(0xe6),[typeorm_2[_0x3e01a9(0x124)],typeorm_2[_0x3e01a9(0x124)],typeorm_2['Repository'],typeorm_2[_0x3e01a9(0x124)],typeorm_2[_0x3e01a9(0x124)]])],StatisticService),exports['StatisticService']=StatisticService;