add product sku
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
import { axios } from "timi-web-api";
|
||||
import type {
|
||||
GaoProductChartReq,
|
||||
GaoProductSkuFulfillmentDailyStatView,
|
||||
GaoProductSkuFulfillmentRankView,
|
||||
GaoProductSkuSalesDailyStatView,
|
||||
GaoProductSkuSalesRankView,
|
||||
GaoProductSkuStockHealthView,
|
||||
GaoProductSkuStockMovementDailyStatView,
|
||||
GaoProductSkuUnitSalesRankView
|
||||
} from "@/types/GaoChart";
|
||||
import { getStoreChartCache } from "@/utils/storeChartCache";
|
||||
import { withCurrentStoreId } from "@/utils/store";
|
||||
|
||||
const BASE_URI = "/gao/product/sku/chart";
|
||||
|
||||
async function salesDaily(req: GaoProductChartReq): Promise<GaoProductSkuSalesDailyStatView[]> {
|
||||
return await requestList("sales-daily", "/sales/daily", req);
|
||||
}
|
||||
|
||||
async function salesRank(req: GaoProductChartReq): Promise<GaoProductSkuSalesRankView[]> {
|
||||
return await requestList("sales-rank", "/sales/rank", req);
|
||||
}
|
||||
|
||||
async function unitSalesRank(req: GaoProductChartReq): Promise<GaoProductSkuUnitSalesRankView[]> {
|
||||
return await requestList("sales-unit-rank", "/sales/unit/rank", req);
|
||||
}
|
||||
|
||||
async function fulfillmentDaily(req: GaoProductChartReq): Promise<GaoProductSkuFulfillmentDailyStatView[]> {
|
||||
return await requestList("fulfillment-daily", "/fulfillment/daily", req);
|
||||
}
|
||||
|
||||
async function fulfillmentRank(req: GaoProductChartReq): Promise<GaoProductSkuFulfillmentRankView[]> {
|
||||
return await requestList("fulfillment-rank", "/fulfillment/rank", req);
|
||||
}
|
||||
|
||||
async function stockMovementDaily(req: GaoProductChartReq): Promise<GaoProductSkuStockMovementDailyStatView[]> {
|
||||
return await requestList("stock-movement-daily", "/stock/movement/daily", req);
|
||||
}
|
||||
|
||||
async function stockHealth(req: GaoProductChartReq): Promise<GaoProductSkuStockHealthView[]> {
|
||||
return await requestList("stock-health", "/stock/health", req);
|
||||
}
|
||||
|
||||
async function requestList<T>(name: string, path: string, req: GaoProductChartReq): Promise<T[]> {
|
||||
const request = withCurrentStoreId(req);
|
||||
return await getStoreChartCache(`gao-product-sku:${name}:${JSON.stringify(request)}`, async () => await axios.post(`${BASE_URI}${path}`, request));
|
||||
}
|
||||
|
||||
export default {
|
||||
salesDaily,
|
||||
salesRank,
|
||||
unitSalesRank,
|
||||
fulfillmentDaily,
|
||||
fulfillmentRank,
|
||||
stockMovementDaily,
|
||||
stockHealth
|
||||
};
|
||||
Reference in New Issue
Block a user