mall数据库文件
This commit is contained in:
53
services/analytics/marketTrendsService.uts
Normal file
53
services/analytics/marketTrendsService.uts
Normal file
@@ -0,0 +1,53 @@
|
||||
import { computeDateRange, toDateOnly } from './dateRange.uts'
|
||||
import { rpcOrEmptyArray } from './rpc.uts'
|
||||
|
||||
export type MarketTrendsData = {
|
||||
trendRows: Array<UTSJSONObject>
|
||||
categoryRows: Array<UTSJSONObject>
|
||||
seasonalRows: Array<UTSJSONObject>
|
||||
priceRows: Array<UTSJSONObject>
|
||||
competitionRows: Array<UTSJSONObject>
|
||||
startIso: string
|
||||
endIso: string
|
||||
}
|
||||
|
||||
export async function fetchMarketTrends(period: string): Promise<MarketTrendsData> {
|
||||
const { startIso, endIso } = computeDateRange(period)
|
||||
const startDate = toDateOnly(startIso)
|
||||
const endDate = toDateOnly(endIso)
|
||||
|
||||
const trendRows = await rpcOrEmptyArray('rpc_analytics_market_trend_daily', {
|
||||
p_start: startIso,
|
||||
p_end: endIso
|
||||
} as UTSJSONObject)
|
||||
|
||||
const categoryRows = await rpcOrEmptyArray('rpc_analytics_category_sales', {
|
||||
p_start_date: startDate,
|
||||
p_end_date: endDate
|
||||
} as UTSJSONObject)
|
||||
|
||||
const seasonalRows = await rpcOrEmptyArray('rpc_analytics_seasonal_trend', {
|
||||
p_start_date: startDate,
|
||||
p_end_date: endDate
|
||||
} as UTSJSONObject)
|
||||
|
||||
const priceRows = await rpcOrEmptyArray('rpc_analytics_price_trend', {
|
||||
p_start: startIso,
|
||||
p_end: endIso
|
||||
} as UTSJSONObject)
|
||||
|
||||
const competitionRows = await rpcOrEmptyArray('rpc_analytics_competition_share', {
|
||||
p_start_date: startDate,
|
||||
p_end_date: endDate
|
||||
} as UTSJSONObject)
|
||||
|
||||
return {
|
||||
trendRows,
|
||||
categoryRows,
|
||||
seasonalRows,
|
||||
priceRows,
|
||||
competitionRows,
|
||||
startIso,
|
||||
endIso
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user