import type { GlobalSearchMode } from '../types'; /** * 万能搜索接口(ES 模块)service 层。 * * 对应文档:`packages/private-materials/src/plus/pisellGlobalSearch/api/search-api.md` * Base Path:`/shop/es` * * 说明: * - 请求沿用仓库现有约定(`request.getRequest().post(url, body, { fullResult, isShopApi })`, * 响应解构 `data`),request 客户端由壳层(FullPage / Modal)通过 * `request.setRequest(engine.utils.request)` 注入; * - `search_mode` 决定匹配方式:业务模式 = 'identifier'(按标识符精确匹配), * 管理模式 = 'fuzzy'(模糊匹配)。 */ /** 搜索匹配方式;对应接口 search_mode */ export declare type SearchMode = 'identifier' | 'fuzzy'; /** * 搜索结果需要展开的关联字段(与 search_mode 同层传 `with`)。 * 保证命中项与实时推送都带上这些关联数据。 */ export declare const SALES_SEARCH_WITH: readonly ["bookings", "products", "payments", "vouchers", "surcharges", "discount_list", "relation_forms", "contacts_info", "holder", "summary", "customer"]; /** * 全局搜索 mode → 接口 search_mode 映射。 * - 业务模式(business)→ search_mode 'identifier'(按标识符精确匹配) * - 管理模式(admin)→ search_mode 'fuzzy'(模糊匹配) */ export declare const searchModeFromMode: (mode: GlobalSearchMode) => SearchMode; /** * sales 模块命中项:**扁平的统一 Sales 协议结构**(见文档 §3.5)。 * * 接口 `list[]` 已不再包裹 `fields`,订单 id 为顶层 `order_id`;关联字段(products / * payments / contacts_info / summary 等)按 select / with 返回,不传时为默认全量。 * 这里仅声明常用字段,其余用索引签名透传,列按需取值、缺失回退。 */ export interface SalesSearchItem { order_id: number; order_number?: string; shop_order_number?: string; shop_full_order_number?: string; type?: string; status?: string; payment_status?: string; shipping_status?: string; customer_id?: number; customer_name?: string; country_calling_code?: string; phone?: string; email?: string; currency_code?: string; created_at?: string; updated_at?: string; products?: any[]; bookings?: any[]; payments?: any[]; contacts_info?: any; summary?: { total_amount?: number; paid_amount?: number; total_refund_amount?: number; [key: string]: unknown; }; [key: string]: unknown; } /** 归一化后的单模块搜索结果 */ export interface SalesSearchResult { items: SalesSearchItem[]; total: number; page: number; perPage: number; hasMore: boolean; } /** ES 排序项 */ export interface SalesSearchSort { field: string; direction: 'asc' | 'desc'; } export interface SearchSalesParams { /** 关键词(搜索框输入文本) */ keyword: string; /** 搜索匹配方式:业务 = 'identifier'(精确),管理 = 'fuzzy'(模糊) */ searchMode: SearchMode; /** 筛选条件,对应接口 filters(见文档 §4 Body 参数) */ filters?: Record; /** 排序,对应接口 sort */ sort?: SalesSearchSort[]; page?: number; perPage?: number; /** 透传给请求层;由 useProviderSearch 注入用于取消过期请求 */ signal?: AbortSignal; /** OS Server 搜索订阅 id;同一查询滚动追加时复用 */ subscriberId?: string; /** OS Server 订单变更 delta callback,仅返回当前已加载集合中的变更订单 */ callback?: (res: any) => void; /** 参数重查/首屏加载时重置 OS 侧 visibleOrderIds,滚动追加时保持 false */ resetVisibleOrderIds?: boolean; } /** * 单模块搜索:sales(订单)。用于「订单」单 tab、管理模式表格分页加载。 * * 对应:`POST /shop/es/search/sales`(文档 §5),响应 `data.{ list, count, skip, size }`。 */ export declare function searchSalesModule(params: SearchSalesParams): Promise; /** * 聚合搜索:用于「全部」作用域。一次请求查多个模块,按 `module` 分组返回。 * * 对应:`POST /shop/es/search`(文档 §4),响应 `data.results[]`(每项 `{ module, list, count, skip, size }`)。 * 当前前端只接订单一个域,这里显式只查 `sales`,并从 `results` 里取出 sales 分组归一化。 */ export declare function searchAggregateSales(params: SearchSalesParams): Promise; /** * 取消单模块 sales 搜索订阅(仅 WebPOS 真正发请求,见 unsubscribeOsQuery)。 * * @example * await unsubscribeSalesSearch('global-search-order-business') */ export declare function unsubscribeSalesSearch(subscriberId?: string): Promise; /** * 取消聚合 sales 搜索订阅(仅 WebPOS 真正发请求,见 unsubscribeOsQuery)。 * * @example * await unsubscribeAggregateSalesSearch('global-search-order-all') */ export declare function unsubscribeAggregateSalesSearch(subscriberId?: string): Promise; /** * 从命中项里取订单 id(驱动 SaleDetail / 行 rowKey)。 * 文档 §5:sales 命中项为扁平 Sales 协议,订单 id 即顶层 `order_id`。 */ export declare const getSalesOrderId: (item: SalesSearchItem) => number | undefined; /** * 排序 key(表格的 `field:direction` 字符串)→ ES sort 数组。 * * @example parseSortKey('created_at:desc') => [{ field: 'created_at', direction: 'desc' }] */ export declare const parseSortKey: (sort?: string) => SalesSearchSort[] | undefined; /** * 表格筛选 values → ES filters(**1:1 透传** + 少量形状适配)。 * * 适配项(其余键名/值原样透传,空值跳过): * - `orderDate`(快筛日期范围 `[start, end]`)→ `created_at: { from, to }`(文档 §3.6 range); * - `total_amount`(`{ min, max }`)→ `{ gte, lte }`(文档 range 语法,不认 min/max)。 * * ⚠️ 1:1 透传前提:后端 ES `sales` 接受这些同名筛选字段(按用户确认采用透传策略)。 * 若某字段 ES 未支持,后端会忽略;需要精确字段名时再按白名单调整本函数。 */ export declare const mapGridFiltersToEs: (values?: Record) => Record;