import { axios } from "timi-web-api"; import { getCurrentStoreId, withCurrentStoreId } from "@/utils/store"; import type { GaoCustomerPackage, GaoPackageConfig, PackageConfigPage, PackagePageResult, PackagePurchaseRequest } from "@/types/Package"; const CONFIG_URI = "/gao/package/config"; const CUSTOMER_PACKAGE_URI = "/gao/customer/package"; async function configList(page: PackageConfigPage): Promise> { return await axios.post(`${CONFIG_URI}/list`, withCurrentStoreId(page)); } async function configListValid(storeId?: string): Promise { return await axios.post(`${CONFIG_URI}/list/valid`, undefined, { params: { storeId: storeId || getCurrentStoreId() } }); } async function configDetail(id: string): Promise { return await axios.post(`${CONFIG_URI}/detail`, undefined, { params: { id } }); } async function configCreate(config: GaoPackageConfig): Promise { return await axios.post(`${CONFIG_URI}/create`, withCurrentStoreId(config)); } async function configUpdate(config: GaoPackageConfig): Promise { await axios.post(`${CONFIG_URI}/update`, withCurrentStoreId(config)); } async function configRemove(id: string): Promise { await axios.post(`${CONFIG_URI}/delete`, undefined, { params: { id } }); } async function purchase(request: PackagePurchaseRequest): Promise { return await axios.post(`${CUSTOMER_PACKAGE_URI}/purchase`, request); } export default { configList, configListValid, configDetail, configCreate, configUpdate, configRemove, purchase };