add product/order chart
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
import { axios } from "timi-web-api";
|
||||
import type {
|
||||
GaoCustomerOrderProductRankView,
|
||||
GaoCustomerOrderRankView,
|
||||
GaoCustomerRepeatDailyStatView,
|
||||
GaoCustomerRepeatIntervalStatView,
|
||||
GaoSalesOrderCalendarStatView,
|
||||
GaoSalesOrderChartReq,
|
||||
GaoSalesOrderConsumptionDailyStatView,
|
||||
GaoSalesOrderDailyStatView,
|
||||
GaoSalesOrderPaymentStatView,
|
||||
GaoSalesOrderReceivableStatView,
|
||||
GaoSalesOrderStatusStatView,
|
||||
GaoSalesOrderTypeStatView
|
||||
} from "@/types/GaoChart";
|
||||
import { getStoreChartCache } from "@/utils/storeChartCache";
|
||||
import { withCurrentStoreId } from "@/utils/store";
|
||||
|
||||
const BASE_URI = "/gao/sales/order/chart";
|
||||
|
||||
async function daily(req: GaoSalesOrderChartReq): Promise<GaoSalesOrderDailyStatView[]> {
|
||||
return await requestList("daily", "/daily", req);
|
||||
}
|
||||
|
||||
async function type(req: GaoSalesOrderChartReq): Promise<GaoSalesOrderTypeStatView[]> {
|
||||
return await requestList("type", "/type", req);
|
||||
}
|
||||
|
||||
async function payment(req: GaoSalesOrderChartReq): Promise<GaoSalesOrderPaymentStatView[]> {
|
||||
return await requestList("payment", "/payment", req);
|
||||
}
|
||||
|
||||
async function status(req: GaoSalesOrderChartReq): Promise<GaoSalesOrderStatusStatView[]> {
|
||||
return await requestList("status", "/status", req);
|
||||
}
|
||||
|
||||
async function receivable(req: GaoSalesOrderChartReq): Promise<GaoSalesOrderReceivableStatView> {
|
||||
const request = withCurrentStoreId(req);
|
||||
return await getStoreChartCache(`gao-order:receivable:${JSON.stringify(request)}`, async () => await axios.post(`${BASE_URI}/receivable`, request));
|
||||
}
|
||||
|
||||
async function customerRank(req: GaoSalesOrderChartReq): Promise<GaoCustomerOrderRankView[]> {
|
||||
return await requestList("customer-rank", "/customer/rank", req);
|
||||
}
|
||||
|
||||
async function customerProductRank(req: GaoSalesOrderChartReq): Promise<GaoCustomerOrderProductRankView[]> {
|
||||
return await requestList("customer-product-rank", "/customer/product/rank", req);
|
||||
}
|
||||
|
||||
async function consumptionDaily(req: GaoSalesOrderChartReq): Promise<GaoSalesOrderConsumptionDailyStatView[]> {
|
||||
return await requestList("customer-consumption-daily", "/customer/consumption/daily", req);
|
||||
}
|
||||
|
||||
async function calendar(req: GaoSalesOrderChartReq): Promise<GaoSalesOrderCalendarStatView[]> {
|
||||
return await requestList("customer-calendar", "/customer/calendar", req);
|
||||
}
|
||||
|
||||
async function repeatDaily(req: GaoSalesOrderChartReq): Promise<GaoCustomerRepeatDailyStatView[]> {
|
||||
return await requestList("customer-repeat-daily", "/customer/repeat/daily", req);
|
||||
}
|
||||
|
||||
async function repeatInterval(req: GaoSalesOrderChartReq): Promise<GaoCustomerRepeatIntervalStatView[]> {
|
||||
return await requestList("customer-repeat-interval", "/customer/repeat/interval", req);
|
||||
}
|
||||
|
||||
async function requestList<T>(name: string, path: string, req: GaoSalesOrderChartReq): Promise<T[]> {
|
||||
const request = withCurrentStoreId(req);
|
||||
return await getStoreChartCache(`gao-order:${name}:${JSON.stringify(request)}`, async () => await axios.post(`${BASE_URI}${path}`, request));
|
||||
}
|
||||
|
||||
export default {
|
||||
daily,
|
||||
type,
|
||||
payment,
|
||||
status,
|
||||
receivable,
|
||||
customerRank,
|
||||
customerProductRank,
|
||||
consumptionDaily,
|
||||
calendar,
|
||||
repeatDaily,
|
||||
repeatInterval
|
||||
};
|
||||
Reference in New Issue
Block a user