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
|
||||
};
|
||||
@@ -2,6 +2,7 @@ import { axios } from "timi-web-api";
|
||||
import type {
|
||||
GaoCustomerOrderProductRankView,
|
||||
GaoCustomerOrderRankView,
|
||||
GaoCustomerOrderSkuRankView,
|
||||
GaoCustomerRepeatDailyStatView,
|
||||
GaoCustomerRepeatIntervalStatView,
|
||||
GaoSalesOrderCalendarStatView,
|
||||
@@ -47,6 +48,10 @@ async function customerProductRank(req: GaoSalesOrderChartReq): Promise<GaoCusto
|
||||
return await requestList("customer-product-rank", "/customer/product/rank", req);
|
||||
}
|
||||
|
||||
async function customerSkuRank(req: GaoSalesOrderChartReq): Promise<GaoCustomerOrderSkuRankView[]> {
|
||||
return await requestList("customer-sku-rank", "/customer/sku/rank", req);
|
||||
}
|
||||
|
||||
async function consumptionDaily(req: GaoSalesOrderChartReq): Promise<GaoSalesOrderConsumptionDailyStatView[]> {
|
||||
return await requestList("customer-consumption-daily", "/customer/consumption/daily", req);
|
||||
}
|
||||
@@ -76,6 +81,7 @@ export default {
|
||||
receivable,
|
||||
customerRank,
|
||||
customerProductRank,
|
||||
customerSkuRank,
|
||||
consumptionDaily,
|
||||
calendar,
|
||||
repeatDaily,
|
||||
|
||||
+46
-2
@@ -5,7 +5,11 @@ import type {
|
||||
ProductCategoryPage,
|
||||
ProductPage,
|
||||
ProductPageResult,
|
||||
ProductSku,
|
||||
ProductSpec,
|
||||
ProductSpecValue,
|
||||
ProductStock,
|
||||
ProductStockProduct,
|
||||
ProductStockChangeRequest,
|
||||
ProductStockManualRevokeRequest,
|
||||
ProductStockPage,
|
||||
@@ -57,6 +61,34 @@ async function disable(id: string): Promise<void> {
|
||||
await axios.post(`${PRODUCT_URI}/disable`, undefined, { params: { id } });
|
||||
}
|
||||
|
||||
async function skuDetail(id: string): Promise<ProductSku> {
|
||||
return await axios.post(`${PRODUCT_URI}/sku/detail`, undefined, { params: { id } });
|
||||
}
|
||||
|
||||
async function skuCreate(sku: ProductSku): Promise<string> {
|
||||
return await axios.post(`${PRODUCT_URI}/sku/create`, withCurrentStoreId(sku));
|
||||
}
|
||||
|
||||
async function skuUpdate(sku: ProductSku): Promise<void> {
|
||||
await axios.post(`${PRODUCT_URI}/sku/update`, withCurrentStoreId(sku));
|
||||
}
|
||||
|
||||
async function skuDisable(id: string): Promise<void> {
|
||||
await axios.post(`${PRODUCT_URI}/sku/disable`, undefined, { params: { id } });
|
||||
}
|
||||
|
||||
async function specList(productId: string): Promise<ProductSpec[]> {
|
||||
return await axios.post(`${PRODUCT_URI}/spec/list`, undefined, { params: { productId } });
|
||||
}
|
||||
|
||||
async function specCreate(spec: ProductSpec): Promise<string> {
|
||||
return await axios.post(`${PRODUCT_URI}/spec/create`, spec);
|
||||
}
|
||||
|
||||
async function specValueCreate(value: ProductSpecValue): Promise<string> {
|
||||
return await axios.post(`${PRODUCT_URI}/spec/value/create`, value);
|
||||
}
|
||||
|
||||
async function sellableList(page: ProductPage): Promise<Product[]> {
|
||||
return await axios.post(`${PRODUCT_URI}/sellable/list`, withCurrentStoreId(page));
|
||||
}
|
||||
@@ -65,9 +97,13 @@ async function stockList(page: ProductStockPage): Promise<ProductPageResult<Prod
|
||||
return await axios.post(`${STOCK_URI}/list`, withCurrentStoreId(page));
|
||||
}
|
||||
|
||||
async function stockDetail(productId: string, storeId?: string): Promise<ProductStock> {
|
||||
async function stockProductList(page: ProductStockPage): Promise<ProductPageResult<ProductStockProduct>> {
|
||||
return await axios.post(`${STOCK_URI}/product-list`, withCurrentStoreId(page));
|
||||
}
|
||||
|
||||
async function stockDetail(skuId: string, storeId?: string): Promise<ProductStock> {
|
||||
return await axios.post(`${STOCK_URI}/detail`, undefined, {
|
||||
params: { productId, storeId: storeId || getCurrentStoreId() }
|
||||
params: { skuId, storeId: storeId || getCurrentStoreId() }
|
||||
});
|
||||
}
|
||||
|
||||
@@ -114,8 +150,16 @@ export default {
|
||||
create,
|
||||
update,
|
||||
disable,
|
||||
skuDetail,
|
||||
skuCreate,
|
||||
skuUpdate,
|
||||
skuDisable,
|
||||
specList,
|
||||
specCreate,
|
||||
specValueCreate,
|
||||
sellableList,
|
||||
stockList,
|
||||
stockProductList,
|
||||
stockDetail,
|
||||
initialIn,
|
||||
manualIn,
|
||||
|
||||
Reference in New Issue
Block a user