import { get, post } from '@/utils/request' /** 绑定类型:0未绑定 1系统商品 2组合商品 */ export const BIND_TYPES = { none: 0, product: 1, combo: 2 } as const export interface ShopProductItem { id: number principal_id: number shop_id: number outer_item_id: string outer_sku_id: string | null title: string | null outer_code: string | null spec: string | null image: string | null price: number | string | null stock: number status: number /** 外部平台类型:TouTiao/Taobao/Pinduoduo 等(外部平台采集时有值) */ platform_type?: string | null /** 外部平台的店铺ID(如店管家 ShopId) */ external_shop_id?: string | null /** 引用该商品但未绑定系统商品的订单数(列表接口回填) */ unbound_order_count?: number bind_type: number product_id: number | null combo_product_id: number | null synced_at: string | null created_at?: string /** 列表接口 include 带回的关联对象 */ shop?: { id: number; name: string; platform: string | null } | null product?: { id: number; item_code: string; item_name: string } | null comboProduct?: { id: number; code: string; name: string } | null } export interface BindPayload { bind_type: number product_id?: number | null combo_product_id?: number | null } /** 当前主体下的店铺商品列表(principal_id 由请求拦截器自动注入) */ export function getShopProducts(params?: object) { return get<{ list: ShopProductItem[]; total: number; page: number; pageSize: number }>( '/shop-products', params, ) } /** 绑定系统商品 / 组合商品,bind_type=0 为解绑 */ export function bindShopProduct(id: number, data: BindPayload) { return post<{ id: number }>(`/shop-products/${id}/bind`, data) }