@pisell/pisellos 2.1.36 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/dist/core/index.d.ts +8 -1
  2. package/dist/core/index.js +116 -42
  3. package/dist/effects/index.d.ts +1 -0
  4. package/dist/effects/index.js +29 -6
  5. package/dist/modules/Account/index.js +2 -3
  6. package/dist/modules/BaseModule.d.ts +3 -0
  7. package/dist/modules/BaseModule.js +15 -0
  8. package/dist/modules/Customer/index.js +9 -10
  9. package/dist/modules/Customer/types.d.ts +2 -2
  10. package/dist/modules/Customer/types.js +2 -2
  11. package/dist/modules/Discount/index.js +1 -1
  12. package/dist/modules/Guests/index.js +9 -9
  13. package/dist/modules/Order/index.js +1 -1
  14. package/dist/modules/Payment/index.js +63 -73
  15. package/dist/modules/Payment/walletpass.js +4 -1
  16. package/dist/modules/Product/types.d.ts +19 -0
  17. package/dist/modules/ProductList/index.js +5 -14
  18. package/dist/modules/Resource/index.js +1 -1
  19. package/dist/modules/Rules/index.js +2 -3
  20. package/dist/modules/Schedule/types.d.ts +2 -0
  21. package/dist/plugins/request.d.ts +1 -0
  22. package/dist/server/index.d.ts +152 -0
  23. package/dist/server/index.js +946 -0
  24. package/dist/server/modules/index.d.ts +16 -0
  25. package/dist/server/modules/index.js +21 -0
  26. package/dist/server/modules/menu/index.d.ts +63 -0
  27. package/dist/server/modules/menu/index.js +476 -0
  28. package/dist/server/modules/menu/types.d.ts +68 -0
  29. package/dist/server/modules/menu/types.js +16 -0
  30. package/dist/server/modules/products/index.d.ts +141 -0
  31. package/dist/server/modules/products/index.js +768 -0
  32. package/dist/server/modules/products/types.d.ts +94 -0
  33. package/dist/server/modules/products/types.js +43 -0
  34. package/dist/server/modules/quotation/index.d.ts +47 -0
  35. package/dist/server/modules/quotation/index.js +367 -0
  36. package/dist/server/modules/quotation/types.d.ts +50 -0
  37. package/dist/server/modules/quotation/types.js +20 -0
  38. package/dist/server/modules/schedule/index.d.ts +62 -0
  39. package/dist/server/modules/schedule/index.js +431 -0
  40. package/dist/server/modules/schedule/types.d.ts +1 -0
  41. package/dist/server/modules/schedule/types.js +2 -0
  42. package/dist/server/modules/schedule/utils.d.ts +32 -0
  43. package/dist/server/modules/schedule/utils.js +747 -0
  44. package/dist/server/types.d.ts +64 -0
  45. package/dist/server/types.js +1 -0
  46. package/dist/server/utils/index.d.ts +5 -0
  47. package/dist/server/utils/index.js +6 -0
  48. package/dist/server/utils/product.d.ts +18 -0
  49. package/dist/server/utils/product.js +339 -0
  50. package/dist/server/utils/schedule.d.ts +14 -0
  51. package/dist/server/utils/schedule.js +108 -0
  52. package/dist/server/utils/time.d.ts +18 -0
  53. package/dist/server/utils/time.js +53 -0
  54. package/dist/solution/BookingByStep/index.d.ts +0 -16
  55. package/dist/solution/BookingByStep/index.js +57 -508
  56. package/dist/solution/BookingByStep/utils/capacity.d.ts +2 -7
  57. package/dist/solution/BookingByStep/utils/capacity.js +8 -24
  58. package/dist/solution/BookingTicket/index.d.ts +12 -0
  59. package/dist/solution/BookingTicket/index.js +122 -79
  60. package/dist/solution/BookingTicket/utils/scan/index.d.ts +4 -0
  61. package/dist/solution/BookingTicket/utils/scan/index.js +25 -16
  62. package/dist/solution/BuyTickets/index.js +7 -8
  63. package/dist/solution/Checkout/index.d.ts +1 -46
  64. package/dist/solution/Checkout/index.js +530 -850
  65. package/dist/solution/ShopDiscount/index.js +9 -10
  66. package/dist/types/index.d.ts +27 -0
  67. package/lib/core/index.d.ts +8 -1
  68. package/lib/core/index.js +48 -1
  69. package/lib/effects/index.d.ts +1 -0
  70. package/lib/effects/index.js +13 -0
  71. package/lib/modules/Account/index.js +2 -3
  72. package/lib/modules/BaseModule.d.ts +3 -0
  73. package/lib/modules/BaseModule.js +9 -0
  74. package/lib/modules/Customer/index.js +9 -10
  75. package/lib/modules/Customer/types.d.ts +2 -2
  76. package/lib/modules/Customer/types.js +2 -2
  77. package/lib/modules/Discount/index.js +1 -1
  78. package/lib/modules/Guests/index.js +9 -9
  79. package/lib/modules/Order/index.js +1 -1
  80. package/lib/modules/Payment/index.js +56 -43
  81. package/lib/modules/Payment/walletpass.js +3 -1
  82. package/lib/modules/Product/types.d.ts +19 -0
  83. package/lib/modules/ProductList/index.js +4 -13
  84. package/lib/modules/Resource/index.js +1 -1
  85. package/lib/modules/Rules/index.js +2 -3
  86. package/lib/modules/Schedule/types.d.ts +2 -0
  87. package/lib/plugins/request.d.ts +1 -0
  88. package/lib/server/index.d.ts +152 -0
  89. package/lib/server/index.js +555 -0
  90. package/lib/server/modules/index.d.ts +16 -0
  91. package/lib/server/modules/index.js +47 -0
  92. package/lib/server/modules/menu/index.d.ts +63 -0
  93. package/lib/server/modules/menu/index.js +234 -0
  94. package/lib/server/modules/menu/types.d.ts +68 -0
  95. package/lib/server/modules/menu/types.js +33 -0
  96. package/lib/server/modules/products/index.d.ts +141 -0
  97. package/lib/server/modules/products/index.js +434 -0
  98. package/lib/server/modules/products/types.d.ts +94 -0
  99. package/lib/server/modules/products/types.js +35 -0
  100. package/lib/server/modules/quotation/index.d.ts +47 -0
  101. package/lib/server/modules/quotation/index.js +177 -0
  102. package/lib/server/modules/quotation/types.d.ts +50 -0
  103. package/lib/server/modules/quotation/types.js +33 -0
  104. package/lib/server/modules/schedule/index.d.ts +62 -0
  105. package/lib/server/modules/schedule/index.js +231 -0
  106. package/lib/server/modules/schedule/types.d.ts +1 -0
  107. package/lib/server/modules/schedule/types.js +23 -0
  108. package/lib/server/modules/schedule/utils.d.ts +32 -0
  109. package/lib/server/modules/schedule/utils.js +451 -0
  110. package/lib/server/types.d.ts +64 -0
  111. package/lib/server/types.js +17 -0
  112. package/lib/server/utils/index.d.ts +5 -0
  113. package/lib/server/utils/index.js +25 -0
  114. package/lib/server/utils/product.d.ts +18 -0
  115. package/lib/server/utils/product.js +262 -0
  116. package/lib/server/utils/schedule.d.ts +14 -0
  117. package/lib/server/utils/schedule.js +88 -0
  118. package/lib/server/utils/time.d.ts +18 -0
  119. package/lib/server/utils/time.js +70 -0
  120. package/lib/solution/BookingByStep/index.d.ts +0 -16
  121. package/lib/solution/BookingByStep/index.js +44 -316
  122. package/lib/solution/BookingByStep/utils/capacity.d.ts +2 -7
  123. package/lib/solution/BookingByStep/utils/capacity.js +8 -21
  124. package/lib/solution/BookingTicket/index.d.ts +12 -0
  125. package/lib/solution/BookingTicket/index.js +25 -6
  126. package/lib/solution/BookingTicket/utils/scan/index.d.ts +4 -0
  127. package/lib/solution/BookingTicket/utils/scan/index.js +7 -1
  128. package/lib/solution/BuyTickets/index.js +7 -8
  129. package/lib/solution/Checkout/index.d.ts +1 -46
  130. package/lib/solution/Checkout/index.js +92 -289
  131. package/lib/solution/ShopDiscount/index.js +10 -11
  132. package/lib/types/index.d.ts +27 -0
  133. package/package.json +2 -2
@@ -0,0 +1,234 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/server/modules/menu/index.ts
20
+ var menu_exports = {};
21
+ __export(menu_exports, {
22
+ MenuModule: () => MenuModule
23
+ });
24
+ module.exports = __toCommonJS(menu_exports);
25
+ var import_lodash_es = require("lodash-es");
26
+ var import_BaseModule = require("../../../modules/BaseModule");
27
+ var import_types = require("./types");
28
+ var INDEXDB_STORE_NAME = "menu";
29
+ var MenuModule = class extends import_BaseModule.BaseModule {
30
+ // IndexDBManager 实例
31
+ constructor(name, version) {
32
+ super(name, version);
33
+ this.defaultName = "menu";
34
+ this.defaultVersion = "1.0.0";
35
+ }
36
+ async initialize(core, options) {
37
+ var _a;
38
+ this.core = core;
39
+ this.store = options == null ? void 0 : options.store;
40
+ this.request = core.getPlugin("request");
41
+ if (!this.request) {
42
+ throw new Error("MenuModule 需要 request 插件支持");
43
+ }
44
+ if (Array.isArray((_a = options == null ? void 0 : options.initialState) == null ? void 0 : _a.menuList)) {
45
+ this.store.menuList = options == null ? void 0 : options.initialState.menuList;
46
+ this.syncMenuMap();
47
+ this.core.effects.emit(import_types.MenuHooks.onMenuChanged, this.store.menuList);
48
+ } else {
49
+ this.store.menuList = [];
50
+ this.store.map = /* @__PURE__ */ new Map();
51
+ }
52
+ const appPlugin = core.getPlugin("app");
53
+ if (appPlugin) {
54
+ const app = appPlugin.getApp();
55
+ this.dbManager = app.dbManager;
56
+ if (this.dbManager) {
57
+ console.log("[Menu] IndexDB Manager 已初始化");
58
+ } else {
59
+ console.warn("[Menu] IndexDB Manager 未找到");
60
+ }
61
+ }
62
+ }
63
+ /**
64
+ * 加载餐牌列表(从服务器)
65
+ */
66
+ async loadMenuList() {
67
+ var _a;
68
+ try {
69
+ const response = await this.request.get(
70
+ `/form/data/v1`,
71
+ {
72
+ skip: 1,
73
+ num: 999,
74
+ code: "menu_list"
75
+ },
76
+ { useCache: true }
77
+ );
78
+ const menuList = ((_a = response == null ? void 0 : response.data) == null ? void 0 : _a.list) || [];
79
+ await this.saveMenuToIndexDB(menuList);
80
+ await this.setMenuList(menuList);
81
+ return menuList;
82
+ } catch (error) {
83
+ console.error("[Menu] 加载餐牌数据失败:", error);
84
+ return [];
85
+ }
86
+ }
87
+ /**
88
+ * 设置餐牌列表
89
+ */
90
+ async setMenuList(menuList) {
91
+ this.store.menuList = menuList;
92
+ this.syncMenuMap();
93
+ await this.core.effects.emit(import_types.MenuHooks.onMenuLoaded, menuList);
94
+ }
95
+ /**
96
+ * 获取餐牌列表
97
+ */
98
+ getMenuList() {
99
+ return this.store.menuList;
100
+ }
101
+ /**
102
+ * 根据 form_record_id 数组获取餐牌详情
103
+ * 使用 Map 快速查询,时间复杂度 O(m),m 为 ids 数量
104
+ */
105
+ getMenuByIds(ids) {
106
+ if (!ids || ids.length === 0) {
107
+ return [];
108
+ }
109
+ const result = [];
110
+ for (const id of ids) {
111
+ const menu = this.store.map.get(id);
112
+ if (menu) {
113
+ result.push(menu);
114
+ }
115
+ }
116
+ return result;
117
+ }
118
+ /**
119
+ * 同步更新餐牌 Map 缓存
120
+ * 将 menuList 中的餐牌同步到 map,以 form_record_id 为 key
121
+ * @private
122
+ */
123
+ syncMenuMap() {
124
+ this.store.map.clear();
125
+ for (const menu of this.store.menuList) {
126
+ this.store.map.set(menu.form_record_id, menu);
127
+ }
128
+ console.log(`[Menu] Map 缓存已同步,共 ${this.store.map.size} 个餐牌`);
129
+ }
130
+ /**
131
+ * 清空缓存
132
+ */
133
+ async clear() {
134
+ this.store.menuList = [];
135
+ this.store.map.clear();
136
+ this.store.currentMenu = void 0;
137
+ if (this.dbManager) {
138
+ try {
139
+ await this.dbManager.clear(INDEXDB_STORE_NAME);
140
+ console.log("[Menu] IndexDB 缓存已清空");
141
+ } catch (error) {
142
+ console.error("[Menu] 清空 IndexDB 缓存失败:", error);
143
+ }
144
+ }
145
+ console.log("[Menu] 缓存已清空");
146
+ }
147
+ /**
148
+ * 从 IndexDB 加载餐牌数据
149
+ * @private
150
+ */
151
+ async loadMenuFromIndexDB() {
152
+ if (!this.dbManager) {
153
+ return [];
154
+ }
155
+ try {
156
+ const menuList = await this.dbManager.getAll(INDEXDB_STORE_NAME);
157
+ return menuList || [];
158
+ } catch (error) {
159
+ console.error("[Menu] 从 IndexDB 读取数据失败:", error);
160
+ return [];
161
+ }
162
+ }
163
+ /**
164
+ * 保存餐牌数据到 IndexDB
165
+ * @private
166
+ */
167
+ async saveMenuToIndexDB(menuList) {
168
+ if (!this.dbManager) {
169
+ return;
170
+ }
171
+ try {
172
+ await this.dbManager.clear(INDEXDB_STORE_NAME);
173
+ const savePromises = menuList.map(
174
+ (menu) => this.dbManager.add(INDEXDB_STORE_NAME, menu)
175
+ );
176
+ await Promise.all(savePromises);
177
+ console.log(`[Menu] 已将 ${menuList.length} 条餐牌数据保存到 IndexDB`);
178
+ } catch (error) {
179
+ console.error("[Menu] 保存数据到 IndexDB 失败:", error);
180
+ }
181
+ }
182
+ /**
183
+ * 预加载模块数据(统一接口)
184
+ * 在模块注册后自动调用
185
+ */
186
+ async preload() {
187
+ console.log("[Menu] 开始预加载数据...");
188
+ try {
189
+ const cachedData = await this.loadMenuFromIndexDB();
190
+ if (cachedData && cachedData.length > 0) {
191
+ console.log(`[Menu] 从 IndexDB 加载了 ${cachedData.length} 条餐牌数据`);
192
+ this.store.menuList = (0, import_lodash_es.cloneDeep)(cachedData);
193
+ this.syncMenuMap();
194
+ this.core.effects.emit(import_types.MenuHooks.onMenuChanged, this.store.menuList);
195
+ return;
196
+ }
197
+ console.log("[Menu] IndexDB 中没有缓存数据,从服务器加载...");
198
+ } catch (error) {
199
+ console.warn("[Menu] 从 IndexDB 加载数据失败:", error);
200
+ }
201
+ const menuList = await this.loadMenuList();
202
+ if (menuList && menuList.length > 0) {
203
+ await this.saveMenuToIndexDB(menuList);
204
+ this.store.menuList = (0, import_lodash_es.cloneDeep)(menuList);
205
+ this.syncMenuMap();
206
+ this.core.effects.emit(import_types.MenuHooks.onMenuChanged, this.store.menuList);
207
+ }
208
+ }
209
+ /**
210
+ * 获取模块的路由定义
211
+ * 返回该模块需要注册的 API 路由
212
+ */
213
+ getRoutes() {
214
+ return [
215
+ // GET /api/menu - 获取所有餐牌
216
+ {
217
+ method: "get",
218
+ path: "/api/menu",
219
+ handler: async () => {
220
+ const menuList = this.getMenuList();
221
+ return {
222
+ success: true,
223
+ data: menuList,
224
+ total: menuList.length
225
+ };
226
+ }
227
+ }
228
+ ];
229
+ }
230
+ };
231
+ // Annotate the CommonJS export names for ESM import in node:
232
+ 0 && (module.exports = {
233
+ MenuModule
234
+ });
@@ -0,0 +1,68 @@
1
+ /**
2
+ * 餐牌模块状态
3
+ */
4
+ export interface MenuState {
5
+ /** 餐牌列表 */
6
+ menuList: MenuData[];
7
+ /** 餐牌 Map 缓存(以 form_record_id 为 key,加速查询) */
8
+ map: Map<number, MenuData>;
9
+ /** 当前生效的餐牌 */
10
+ currentMenu?: MenuData;
11
+ }
12
+ type ProductItemType = {
13
+ /** 商品集合 ID */
14
+ product_collection_id: number;
15
+ /** 商品 ID */
16
+ product_id: number;
17
+ /** 商品规格 ID */
18
+ product_variant_id: number;
19
+ };
20
+ /**
21
+ * 餐牌数据结构
22
+ */
23
+ export interface MenuData {
24
+ /** 餐牌名称 */
25
+ name: string;
26
+ /** 副标题 */
27
+ subtitle: string;
28
+ /** 媒体资源 */
29
+ media: any[];
30
+ /** 描述 */
31
+ description: string;
32
+ /** 状态 */
33
+ status: 'valid' | 'invalid';
34
+ /** 绑定的日程 ID 列表 */
35
+ schedule: number[];
36
+ /** 商品配置 */
37
+ partyroom_package: {
38
+ /** 类型:product_all 表示所有商品,product_ids 表示指定商品,product_collection 表示商品集合 */
39
+ type: 'product_all' | 'products' | 'product_collection';
40
+ /** 指定的商品 或 商品集合 */
41
+ products: ProductItemType[];
42
+ filter?: number;
43
+ };
44
+ /** 表单标签 */
45
+ form_tag: string;
46
+ /** 商品字段 */
47
+ products: string;
48
+ /** 容量 */
49
+ capacity: number;
50
+ /** 表单记录 ID */
51
+ form_record_id: number;
52
+ /** 表单 ID */
53
+ form_id: number;
54
+ /** 主字段 */
55
+ main_field: string;
56
+ /** 过期时间 */
57
+ expired_at: string | null;
58
+ /** 创建时间 */
59
+ created_at: string;
60
+ }
61
+ /**
62
+ * 餐牌模块钩子
63
+ */
64
+ export declare enum MenuHooks {
65
+ onMenuLoaded = "menu:onMenuLoaded",
66
+ onMenuChanged = "menu:onMenuChanged"
67
+ }
68
+ export {};
@@ -0,0 +1,33 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/server/modules/menu/types.ts
20
+ var types_exports = {};
21
+ __export(types_exports, {
22
+ MenuHooks: () => MenuHooks
23
+ });
24
+ module.exports = __toCommonJS(types_exports);
25
+ var MenuHooks = /* @__PURE__ */ ((MenuHooks2) => {
26
+ MenuHooks2["onMenuLoaded"] = "menu:onMenuLoaded";
27
+ MenuHooks2["onMenuChanged"] = "menu:onMenuChanged";
28
+ return MenuHooks2;
29
+ })(MenuHooks || {});
30
+ // Annotate the CommonJS export names for ESM import in node:
31
+ 0 && (module.exports = {
32
+ MenuHooks
33
+ });
@@ -0,0 +1,141 @@
1
+ import { Module, PisellCore } from '../../../types';
2
+ import { BaseModule } from '../../../modules/BaseModule';
3
+ import { ProductData } from '../../../modules/Product/types';
4
+ import type { RouteDefinition } from '../../types';
5
+ import { ProductFormatter, ProductFormatterContext } from './types';
6
+ /**
7
+ * Products 模块 - 用于获取和管理完整的商品详细数据
8
+ * 相比 ProductList 模块,Products 会获取所有详细信息并缓存
9
+ */
10
+ export declare class ProductsModule extends BaseModule implements Module {
11
+ protected defaultName: string;
12
+ protected defaultVersion: string;
13
+ private store;
14
+ private request;
15
+ private dbManager;
16
+ private otherParams;
17
+ private productsPriceCache;
18
+ private readonly CACHE_MAX_DAYS;
19
+ private formatters;
20
+ private isPriceFormatterRegistered;
21
+ constructor(name?: string, version?: string);
22
+ initialize(core: PisellCore, options: any): Promise<void>;
23
+ /**
24
+ * 加载商品价格(原始方法,不带缓存)
25
+ * @private
26
+ */
27
+ private loadProductsPrice;
28
+ /**
29
+ * 获取应用了价格的商品列表(带缓存)
30
+ * 使用日期作为缓存 key,同一天的商品价格会被缓存
31
+ * 缓存的是已经应用了价格的完整商品列表,避免重复转换
32
+ * @param schedule_date 日期
33
+ * @param extraContext 额外的上下文数据(可选,由 Server 层传入)
34
+ * @returns 应用了价格的商品列表
35
+ */
36
+ getProductsWithPrice(schedule_date: string, extraContext?: Partial<ProductFormatterContext>): Promise<ProductData[]>;
37
+ /**
38
+ * 准备带价格的商品数据(通过格式化器流程处理)
39
+ * @param schedule_date 日期
40
+ * @param extraContext 额外的上下文数据(可选)
41
+ * @returns 完整处理后的商品列表
42
+ * @private
43
+ */
44
+ private prepareProductsWithPrice;
45
+ /**
46
+ * 应用所有已注册的格式化器
47
+ * @param products 商品列表
48
+ * @param context 上下文信息
49
+ * @returns 格式化后的商品列表
50
+ * @private
51
+ */
52
+ private applyFormatters;
53
+ /**
54
+ * 注册内置的价格格式化器
55
+ * 这个格式化器负责将价格数据应用到商品上
56
+ * @private
57
+ */
58
+ private registerBuiltinPriceFormatter;
59
+ /**
60
+ * 注册商品格式化器
61
+ * 格式化器会按注册顺序依次执行(内置价格格式化器始终是第一个)
62
+ * @param formatter 格式化函数
63
+ * @param prepend 是否插入到队列开头(默认 false,追加到末尾)
64
+ * @example
65
+ * ```ts
66
+ * productsModule.registerFormatter((products, context) => {
67
+ * return products.map(p => ({
68
+ * ...p,
69
+ * custom_field: 'custom_value'
70
+ * }));
71
+ * });
72
+ * ```
73
+ */
74
+ registerFormatter(formatter: ProductFormatter, prepend?: boolean): void;
75
+ /**
76
+ * 清空所有格式化器(包括内置价格格式化器)
77
+ * @param keepBuiltin 是否保留内置价格格式化器(默认 true)
78
+ */
79
+ clearFormatters(keepBuiltin?: boolean): void;
80
+ /**
81
+ * 清理过期的价格缓存
82
+ * 当缓存数量超过限制时,删除最老的缓存
83
+ * @private
84
+ */
85
+ private cleanExpiredPriceCache;
86
+ /**
87
+ * 清空商品价格缓存
88
+ * 可用于手动刷新价格数据
89
+ */
90
+ clearPriceCache(): void;
91
+ /**
92
+ * 加载完整商品列表通过接口(包含所有详细数据)
93
+ * @param params 查询参数
94
+ */
95
+ loadProductsByServer(params?: {
96
+ category_ids?: number[];
97
+ product_ids?: number[];
98
+ collection?: number | string[];
99
+ customer_id?: number;
100
+ cacheId?: string;
101
+ }): Promise<any>;
102
+ /**
103
+ * 获取商品列表(从缓存)
104
+ */
105
+ getProducts(): Promise<ProductData[]>;
106
+ /**
107
+ * 根据ID获取单个商品(从内存缓存)
108
+ * 使用 Map 快速查询,时间复杂度 O(1)
109
+ */
110
+ getProductById(id: number): Promise<ProductData | undefined>;
111
+ /**
112
+ * 清空缓存
113
+ */
114
+ clear(): Promise<void>;
115
+ /**
116
+ * 从 IndexDB 加载商品数据
117
+ * @private
118
+ */
119
+ private loadProductsFromIndexDB;
120
+ /**
121
+ * 保存商品数据到 IndexDB(平铺存储)
122
+ * @private
123
+ */
124
+ private saveProductsToIndexDB;
125
+ /**
126
+ * 同步更新商品 Map 缓存
127
+ * 将 list 中的商品同步到 map,以 id 为 key
128
+ * @private
129
+ */
130
+ private syncProductsMap;
131
+ /**
132
+ * 预加载模块数据(统一接口)
133
+ * 在模块注册后自动调用
134
+ */
135
+ preload(): Promise<void>;
136
+ /**
137
+ * 获取模块的路由定义
138
+ * Products 模块暂不提供路由,由 Server 层统一处理
139
+ */
140
+ getRoutes(): RouteDefinition[];
141
+ }