import { http } from "@/utils/http"; type Result = { code: number; message: string; data?: any; }; type ResultTable = { code: number; message: string; data?: { list: Array; total: number; pageSize: number; currentPage: number; }; }; export const getProductList = (params: { page?: number; pageSize?: number; name?: string; barcode?: string; category?: string; syncStatus?: number; }) => { return http.request("get", "/products/list", { params }); }; export const getProductById = (id: number) => { return http.request("get", `/products/${id}`); }; export const getProductStatistics = () => { return http.request("get", "/products/statistics"); }; export const addProduct = (data: any) => { return http.request("post", "/products", { data }); }; export const updateProduct = (id: number, data: any) => { return http.request("put", `/products/${id}`, { data }); }; export const deleteProduct = (id: number) => { return http.request("delete", `/products/${id}`); }; export const syncProduct = (id: number) => { return http.request("post", `/products/${id}/sync`); }; // 商品总库 export const getMasterProductList = (params: { page?: number; pageSize?: number; barcode?: string; code?: string; productName?: string; deviceAdapt?: string; }) => { return http.request("get", "/products/master/list", { params }); }; export const addToMerchantProducts = (data: { codeList: string }) => { return http.request("post", "/products/master/add-to-merchant", { data }); }; // 商品上下架控制 export const setProductShelfStatus = (data: { deviceId: string; goodsCode: string; salesType: string; callType?: string; }) => { return http.request("post", "/products/shelf-status", { data }); }; // 获取指定设备可售卖商品列表 export const getDeviceProducts = (deviceId: string) => { return http.request("get", `/products/device/${deviceId}`); }; // 查询商品ID对应关系 export const getIdMapping = (codeList?: string) => { const params = codeList ? { codeList } : {}; return http.request("get", "/products/id-mapping", { params }); };