@pisell/pisellos 2.3.60 → 2.3.61
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.
- package/dist/core/index.d.ts +0 -7
- package/dist/core/index.js +66 -109
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/model/strategy/adapter/walletPass/evaluator.js +0 -1
- package/dist/model/strategy/adapter/walletPass/type.d.ts +5 -0
- package/dist/model/strategy/adapter/walletPass/utils.js +57 -24
- package/dist/modules/Payment/types.d.ts +2 -0
- package/dist/modules/Payment/utils.js +4 -1
- package/dist/modules/Payment/walletpass.d.ts +11 -0
- package/dist/modules/Payment/walletpass.js +204 -49
- package/dist/modules/ProductList/index.js +2 -1
- package/dist/modules/Quotation/index.d.ts +0 -6
- package/dist/modules/Quotation/index.js +19 -75
- package/dist/plugins/request.d.ts +0 -1
- package/dist/server/index.d.ts +2 -6
- package/dist/server/index.js +90 -130
- package/dist/server/modules/floor-plan/index.d.ts +0 -4
- package/dist/server/modules/floor-plan/index.js +98 -240
- package/dist/server/modules/menu/index.js +23 -48
- package/dist/server/modules/order/index.d.ts +7 -12
- package/dist/server/modules/order/index.js +96 -248
- package/dist/server/modules/products/index.d.ts +2 -8
- package/dist/server/modules/products/index.js +75 -167
- package/dist/server/modules/resource/index.js +13 -21
- package/dist/solution/BaseSales/index.d.ts +5 -0
- package/dist/solution/BaseSales/index.js +311 -281
- package/lib/core/index.d.ts +0 -7
- package/lib/core/index.js +3 -20
- package/lib/model/strategy/adapter/promotion/index.js +0 -51
- package/lib/model/strategy/adapter/walletPass/evaluator.js +0 -1
- package/lib/model/strategy/adapter/walletPass/type.d.ts +5 -0
- package/lib/model/strategy/adapter/walletPass/utils.js +62 -10
- package/lib/modules/Payment/types.d.ts +2 -0
- package/lib/modules/Payment/utils.js +5 -1
- package/lib/modules/Payment/walletpass.d.ts +11 -0
- package/lib/modules/Payment/walletpass.js +183 -15
- package/lib/modules/ProductList/index.js +2 -1
- package/lib/modules/Quotation/index.d.ts +0 -6
- package/lib/modules/Quotation/index.js +5 -49
- package/lib/plugins/request.d.ts +0 -1
- package/lib/server/index.d.ts +2 -6
- package/lib/server/index.js +8 -18
- package/lib/server/modules/floor-plan/index.d.ts +0 -4
- package/lib/server/modules/floor-plan/index.js +6 -54
- package/lib/server/modules/menu/index.js +5 -31
- package/lib/server/modules/order/index.d.ts +7 -12
- package/lib/server/modules/order/index.js +28 -143
- package/lib/server/modules/products/index.d.ts +2 -8
- package/lib/server/modules/products/index.js +24 -97
- package/lib/server/modules/resource/index.js +2 -7
- package/lib/solution/BaseSales/index.d.ts +5 -0
- package/lib/solution/BaseSales/index.js +11 -0
- package/package.json +1 -1
|
@@ -9,8 +9,6 @@ export declare class QuotationModule extends BaseModule implements Module {
|
|
|
9
9
|
private request;
|
|
10
10
|
private store;
|
|
11
11
|
private scheduleResolver?;
|
|
12
|
-
private app;
|
|
13
|
-
private quotationListUpdatedListener?;
|
|
14
12
|
constructor(name?: string, version?: string);
|
|
15
13
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
16
14
|
loadQuotations(params?: {
|
|
@@ -18,7 +16,6 @@ export declare class QuotationModule extends BaseModule implements Module {
|
|
|
18
16
|
customer_id?: number | string;
|
|
19
17
|
}): Promise<void>;
|
|
20
18
|
getQuotationList(): QuotationItem[];
|
|
21
|
-
setQuotationListUpdatedListener(listener?: () => void): void;
|
|
22
19
|
getQuotationCustomerScopeInfo(): QuotationCustomerScopeInfo;
|
|
23
20
|
/**
|
|
24
21
|
* Look up the quotation price for a specific product (+ optional variant) at a given datetime.
|
|
@@ -63,9 +60,6 @@ export declare class QuotationModule extends BaseModule implements Module {
|
|
|
63
60
|
customer_id?: number | string;
|
|
64
61
|
}): Map<string, string | null>;
|
|
65
62
|
setScheduleResolver(resolver: (id: number) => ScheduleItem | undefined): void;
|
|
66
|
-
private applyQuotationResponse;
|
|
67
|
-
private notifyQuotationListUpdated;
|
|
68
|
-
private getQuotationCacheKeyData;
|
|
69
63
|
private isQuotationVisibleForCustomer;
|
|
70
64
|
private hasValidCustomerId;
|
|
71
65
|
private normalizeCustomerId;
|
|
@@ -32,49 +32,32 @@ var QuotationModule = class extends import_BaseModule.BaseModule {
|
|
|
32
32
|
this.store = { list: [] };
|
|
33
33
|
}
|
|
34
34
|
async initialize(core, options) {
|
|
35
|
-
var _a, _b;
|
|
36
35
|
this.core = core;
|
|
37
36
|
this.request = core.getPlugin("request");
|
|
38
37
|
if (!this.request)
|
|
39
38
|
throw new Error("QuotationModule 需要 request 插件支持");
|
|
40
|
-
this.app = (_b = (_a = core.getPlugin("app")) == null ? void 0 : _a.getApp) == null ? void 0 : _b.call(_a);
|
|
41
39
|
this.store = { list: [] };
|
|
42
40
|
}
|
|
43
41
|
async loadQuotations(params) {
|
|
42
|
+
var _a;
|
|
44
43
|
const query = {};
|
|
45
44
|
if (params == null ? void 0 : params.channel)
|
|
46
45
|
query.channel = params.channel;
|
|
47
46
|
if ((params == null ? void 0 : params.channel) === "online_store") {
|
|
48
47
|
query.channel = "online-store";
|
|
49
48
|
}
|
|
50
|
-
let initialResultApplied = false;
|
|
51
|
-
const applyRemoteUpdate = (response) => {
|
|
52
|
-
this.applyQuotationResponse(response);
|
|
53
|
-
if (initialResultApplied) {
|
|
54
|
-
this.notifyQuotationListUpdated();
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
49
|
const res = await this.request.get(
|
|
58
50
|
"/quotation/available",
|
|
59
51
|
query,
|
|
60
|
-
{
|
|
61
|
-
cache: {
|
|
62
|
-
type: "indexDB",
|
|
63
|
-
updateCache: true,
|
|
64
|
-
cacheKeyData: this.getQuotationCacheKeyData(query)
|
|
65
|
-
},
|
|
66
|
-
cacheUpdateChange: applyRemoteUpdate
|
|
67
|
-
}
|
|
52
|
+
{ useCache: false, osServer: true }
|
|
68
53
|
);
|
|
69
|
-
|
|
70
|
-
|
|
54
|
+
const list = ((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.list) || (res == null ? void 0 : res.list) || [];
|
|
55
|
+
list.sort((a, b) => b.sort - a.sort);
|
|
56
|
+
this.store.list = list;
|
|
71
57
|
}
|
|
72
58
|
getQuotationList() {
|
|
73
59
|
return this.store.list;
|
|
74
60
|
}
|
|
75
|
-
setQuotationListUpdatedListener(listener) {
|
|
76
|
-
this.quotationListUpdatedListener = listener;
|
|
77
|
-
}
|
|
78
61
|
getQuotationCustomerScopeInfo() {
|
|
79
62
|
const customerById = /* @__PURE__ */ new Map();
|
|
80
63
|
const quotationScopes = this.store.list.filter((quotation) => Array.isArray(quotation.customer) && quotation.customer.length > 0).map((quotation) => {
|
|
@@ -173,33 +156,6 @@ var QuotationModule = class extends import_BaseModule.BaseModule {
|
|
|
173
156
|
setScheduleResolver(resolver) {
|
|
174
157
|
this.scheduleResolver = resolver;
|
|
175
158
|
}
|
|
176
|
-
applyQuotationResponse(response) {
|
|
177
|
-
var _a;
|
|
178
|
-
const source = ((_a = response == null ? void 0 : response.data) == null ? void 0 : _a.list) || (response == null ? void 0 : response.list) || [];
|
|
179
|
-
this.store.list = [...source].sort((a, b) => Number(b.sort || 0) - Number(a.sort || 0));
|
|
180
|
-
}
|
|
181
|
-
notifyQuotationListUpdated() {
|
|
182
|
-
var _a;
|
|
183
|
-
try {
|
|
184
|
-
(_a = this.quotationListUpdatedListener) == null ? void 0 : _a.call(this);
|
|
185
|
-
} catch (error) {
|
|
186
|
-
console.warn("[QuotationModule] 报价单后台更新回调失败", error);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
getQuotationCacheKeyData(query) {
|
|
190
|
-
var _a, _b, _c;
|
|
191
|
-
let shopId = "";
|
|
192
|
-
try {
|
|
193
|
-
const storedCore = (_c = (_b = (_a = this.app) == null ? void 0 : _a.storage) == null ? void 0 : _b.getStorage) == null ? void 0 : _c.call(_b, "core");
|
|
194
|
-
const coreInfo = typeof storedCore === "string" ? JSON.parse(storedCore || "{}") : storedCore || {};
|
|
195
|
-
shopId = String((coreInfo == null ? void 0 : coreInfo.id) || "");
|
|
196
|
-
} catch {
|
|
197
|
-
}
|
|
198
|
-
return {
|
|
199
|
-
...query,
|
|
200
|
-
shop_id: shopId
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
159
|
isQuotationVisibleForCustomer(quotation, customerId) {
|
|
204
160
|
const customers = quotation.customer || [];
|
|
205
161
|
if (customers.length === 0)
|
package/lib/plugins/request.d.ts
CHANGED
package/lib/server/index.d.ts
CHANGED
|
@@ -157,17 +157,13 @@ declare class Server {
|
|
|
157
157
|
* 重新拉取全量 SSE 接口,更新本地数据后触发 onProductsSyncCompleted
|
|
158
158
|
* 不影响当前界面展示,适用于切回前台、定时刷新等场景
|
|
159
159
|
*/
|
|
160
|
-
refreshProductsInBackground(
|
|
161
|
-
trigger?: string;
|
|
162
|
-
}): Promise<void>;
|
|
160
|
+
refreshProductsInBackground(): Promise<void>;
|
|
163
161
|
/**
|
|
164
162
|
* 后台静默刷新订单数据
|
|
165
163
|
* 重新拉取全量 SSE 接口,更新本地数据后触发 onOrdersSyncCompleted
|
|
166
164
|
* 不影响当前界面展示,适用于切回前台、定时刷新等场景
|
|
167
165
|
*/
|
|
168
|
-
refreshOrdersInBackground(
|
|
169
|
-
trigger?: string;
|
|
170
|
-
}): Promise<void>;
|
|
166
|
+
refreshOrdersInBackground(): Promise<void>;
|
|
171
167
|
/**
|
|
172
168
|
* 编辑正式订单时强制查询 Server 最新快照并覆盖本地缓存。
|
|
173
169
|
* 商品成员增删由 OrderModule 在 SQLite/Store 更新完成后广播,
|
package/lib/server/index.js
CHANGED
|
@@ -1761,27 +1761,22 @@ var Server = class {
|
|
|
1761
1761
|
* 重新拉取全量 SSE 接口,更新本地数据后触发 onProductsSyncCompleted
|
|
1762
1762
|
* 不影响当前界面展示,适用于切回前台、定时刷新等场景
|
|
1763
1763
|
*/
|
|
1764
|
-
async refreshProductsInBackground(
|
|
1764
|
+
async refreshProductsInBackground() {
|
|
1765
1765
|
if (!this.products) {
|
|
1766
1766
|
this.logWarning("refreshProductsInBackground: Products 模块未注册");
|
|
1767
1767
|
return;
|
|
1768
1768
|
}
|
|
1769
|
-
|
|
1770
|
-
this.logInfo("refreshProductsInBackground 开始", { trigger });
|
|
1769
|
+
this.logInfo("refreshProductsInBackground 开始");
|
|
1771
1770
|
const startTime = Date.now();
|
|
1772
1771
|
try {
|
|
1773
|
-
await this.products.silentRefresh(
|
|
1772
|
+
await this.products.silentRefresh();
|
|
1774
1773
|
const duration = Date.now() - startTime;
|
|
1775
|
-
this.logInfo("refreshProductsInBackground 完成", {
|
|
1776
|
-
trigger,
|
|
1777
|
-
duration: `${duration}ms`
|
|
1778
|
-
});
|
|
1774
|
+
this.logInfo("refreshProductsInBackground 完成", { duration: `${duration}ms` });
|
|
1779
1775
|
} catch (error) {
|
|
1780
1776
|
const duration = Date.now() - startTime;
|
|
1781
1777
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1782
1778
|
console.error("[Server] refreshProductsInBackground 失败:", error);
|
|
1783
1779
|
this.logError("refreshProductsInBackground 失败", {
|
|
1784
|
-
trigger,
|
|
1785
1780
|
duration: `${duration}ms`,
|
|
1786
1781
|
error: errorMessage
|
|
1787
1782
|
});
|
|
@@ -1792,27 +1787,22 @@ var Server = class {
|
|
|
1792
1787
|
* 重新拉取全量 SSE 接口,更新本地数据后触发 onOrdersSyncCompleted
|
|
1793
1788
|
* 不影响当前界面展示,适用于切回前台、定时刷新等场景
|
|
1794
1789
|
*/
|
|
1795
|
-
async refreshOrdersInBackground(
|
|
1790
|
+
async refreshOrdersInBackground() {
|
|
1796
1791
|
if (!this.order) {
|
|
1797
1792
|
this.logWarning("refreshOrdersInBackground: Order 模块未注册");
|
|
1798
1793
|
return;
|
|
1799
1794
|
}
|
|
1800
|
-
|
|
1801
|
-
this.logInfo("refreshOrdersInBackground 开始", { trigger });
|
|
1795
|
+
this.logInfo("refreshOrdersInBackground 开始");
|
|
1802
1796
|
const startTime = Date.now();
|
|
1803
1797
|
try {
|
|
1804
|
-
await this.order.silentRefresh(
|
|
1798
|
+
await this.order.silentRefresh();
|
|
1805
1799
|
const duration = Date.now() - startTime;
|
|
1806
|
-
this.logInfo("refreshOrdersInBackground 完成", {
|
|
1807
|
-
trigger,
|
|
1808
|
-
duration: `${duration}ms`
|
|
1809
|
-
});
|
|
1800
|
+
this.logInfo("refreshOrdersInBackground 完成", { duration: `${duration}ms` });
|
|
1810
1801
|
} catch (error) {
|
|
1811
1802
|
const duration = Date.now() - startTime;
|
|
1812
1803
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1813
1804
|
console.error("[Server] refreshOrdersInBackground 失败:", error);
|
|
1814
1805
|
this.logError("refreshOrdersInBackground 失败", {
|
|
1815
|
-
trigger,
|
|
1816
1806
|
duration: `${duration}ms`,
|
|
1817
1807
|
error: errorMessage
|
|
1818
1808
|
});
|
|
@@ -10,7 +10,6 @@ export declare class FloorPlanModule extends BaseModule implements Module {
|
|
|
10
10
|
private store;
|
|
11
11
|
private request;
|
|
12
12
|
private logger;
|
|
13
|
-
private dbManager;
|
|
14
13
|
private floorPlanDataSource;
|
|
15
14
|
private pendingSyncMessages;
|
|
16
15
|
private syncTimer?;
|
|
@@ -29,9 +28,6 @@ export declare class FloorPlanModule extends BaseModule implements Module {
|
|
|
29
28
|
private mergeItems;
|
|
30
29
|
private removeByIds;
|
|
31
30
|
private loadListFromServer;
|
|
32
|
-
private loadListFromSQLite;
|
|
33
|
-
private saveListToSQLite;
|
|
34
|
-
private refreshListFromServer;
|
|
35
31
|
fetchByIdFromServer(id: number | string): Promise<FloorPlanItem | null>;
|
|
36
32
|
fetchByCodeFromServer(code: string): Promise<FloorPlanItem | null>;
|
|
37
33
|
preload(): Promise<void>;
|
|
@@ -25,7 +25,6 @@ module.exports = __toCommonJS(floor_plan_exports);
|
|
|
25
25
|
var import_BaseModule = require("../../../modules/BaseModule");
|
|
26
26
|
var import_types = require("./types");
|
|
27
27
|
var FLOOR_PLAN_SYNC_DEBOUNCE_MS = 3e3;
|
|
28
|
-
var FLOOR_PLAN_STORE_NAME = "floor_plans";
|
|
29
28
|
var FloorPlanModule = class extends import_BaseModule.BaseModule {
|
|
30
29
|
constructor(name, version) {
|
|
31
30
|
super(name, version);
|
|
@@ -51,7 +50,6 @@ var FloorPlanModule = class extends import_BaseModule.BaseModule {
|
|
|
51
50
|
if (appPlugin) {
|
|
52
51
|
const app = appPlugin.getApp();
|
|
53
52
|
this.logger = app.logger;
|
|
54
|
-
this.dbManager = app.sqlite || app.dbManager;
|
|
55
53
|
}
|
|
56
54
|
this.initFloorPlanDataSource();
|
|
57
55
|
this.setupFloorPlanSync();
|
|
@@ -161,45 +159,6 @@ var FloorPlanModule = class extends import_BaseModule.BaseModule {
|
|
|
161
159
|
return [];
|
|
162
160
|
}
|
|
163
161
|
}
|
|
164
|
-
async loadListFromSQLite() {
|
|
165
|
-
if (!this.dbManager)
|
|
166
|
-
return [];
|
|
167
|
-
try {
|
|
168
|
-
const list = await this.dbManager.getAll(FLOOR_PLAN_STORE_NAME);
|
|
169
|
-
return Array.isArray(list) ? list : [];
|
|
170
|
-
} catch (error) {
|
|
171
|
-
this.logWarning("从 SQLite 读取平面图失败", {
|
|
172
|
-
error: error instanceof Error ? error.message : String(error)
|
|
173
|
-
});
|
|
174
|
-
return [];
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
async saveListToSQLite(list) {
|
|
178
|
-
if (!this.dbManager)
|
|
179
|
-
return;
|
|
180
|
-
try {
|
|
181
|
-
await this.dbManager.clear(FLOOR_PLAN_STORE_NAME);
|
|
182
|
-
if (list.length > 0) {
|
|
183
|
-
await this.dbManager.bulkAdd(FLOOR_PLAN_STORE_NAME, list);
|
|
184
|
-
}
|
|
185
|
-
} catch (error) {
|
|
186
|
-
this.logWarning("保存平面图到 SQLite 失败", {
|
|
187
|
-
count: list.length,
|
|
188
|
-
error: error instanceof Error ? error.message : String(error)
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
async refreshListFromServer() {
|
|
193
|
-
const list = await this.loadListFromServer();
|
|
194
|
-
if (list.length === 0) {
|
|
195
|
-
this.logWarning("远端平面图刷新完成但列表为空");
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
this.replaceStore(list);
|
|
199
|
-
await this.saveListToSQLite(list);
|
|
200
|
-
this.core.effects.emit(import_types.FloorPlanHooks.onFloorPlansChanged, this.getSortedList());
|
|
201
|
-
this.logInfo("远端平面图刷新完成", { count: list.length });
|
|
202
|
-
}
|
|
203
162
|
async fetchByIdFromServer(id) {
|
|
204
163
|
try {
|
|
205
164
|
const res = await this.request.get(
|
|
@@ -231,19 +190,14 @@ var FloorPlanModule = class extends import_BaseModule.BaseModule {
|
|
|
231
190
|
}
|
|
232
191
|
async preload() {
|
|
233
192
|
this.logInfo("开始预加载平面图列表");
|
|
234
|
-
const
|
|
235
|
-
if (
|
|
236
|
-
this.replaceStore(
|
|
193
|
+
const list = await this.loadListFromServer();
|
|
194
|
+
if (list.length > 0) {
|
|
195
|
+
this.replaceStore(list);
|
|
237
196
|
this.core.effects.emit(import_types.FloorPlanHooks.onFloorPlansChanged, this.getSortedList());
|
|
238
|
-
this.logInfo("
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
error: error instanceof Error ? error.message : String(error)
|
|
242
|
-
});
|
|
243
|
-
});
|
|
244
|
-
return;
|
|
197
|
+
this.logInfo("预加载完成", { count: list.length });
|
|
198
|
+
} else {
|
|
199
|
+
this.logWarning("预加载完成但列表为空");
|
|
245
200
|
}
|
|
246
|
-
await this.refreshListFromServer();
|
|
247
201
|
}
|
|
248
202
|
initFloorPlanDataSource() {
|
|
249
203
|
var _a, _b;
|
|
@@ -345,7 +299,6 @@ var FloorPlanModule = class extends import_BaseModule.BaseModule {
|
|
|
345
299
|
}
|
|
346
300
|
}
|
|
347
301
|
if (changed) {
|
|
348
|
-
await this.saveListToSQLite(this.store.list);
|
|
349
302
|
this.core.effects.emit(import_types.FloorPlanHooks.onFloorPlansChanged, this.getSortedList());
|
|
350
303
|
this.core.effects.emit(import_types.FloorPlanHooks.onFloorPlanSyncCompleted, null);
|
|
351
304
|
}
|
|
@@ -354,7 +307,6 @@ var FloorPlanModule = class extends import_BaseModule.BaseModule {
|
|
|
354
307
|
this.store.list = [];
|
|
355
308
|
this.store.map.clear();
|
|
356
309
|
this.store.codeMap.clear();
|
|
357
|
-
await this.saveListToSQLite([]);
|
|
358
310
|
}
|
|
359
311
|
destroy() {
|
|
360
312
|
var _a;
|
|
@@ -185,21 +185,16 @@ var MenuModule = class extends import_BaseModule.BaseModule {
|
|
|
185
185
|
this.logWarning("loadMenuFromIndexDB: dbManager 不可用");
|
|
186
186
|
return [];
|
|
187
187
|
}
|
|
188
|
-
const startedAt = performance.now();
|
|
189
188
|
try {
|
|
190
189
|
const menuList = await this.dbManager.getAll(INDEXDB_STORE_NAME);
|
|
191
190
|
this.logInfo("从 IndexDB 加载餐牌数据", {
|
|
192
|
-
menuCount: (menuList == null ? void 0 : menuList.length) ?? 0
|
|
193
|
-
durationMs: +(performance.now() - startedAt).toFixed(2)
|
|
191
|
+
menuCount: (menuList == null ? void 0 : menuList.length) ?? 0
|
|
194
192
|
});
|
|
195
193
|
return menuList || [];
|
|
196
194
|
} catch (error) {
|
|
197
195
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
198
196
|
console.error("[Menu] 从 IndexDB 读取数据失败:", error);
|
|
199
|
-
this.logError("从 IndexDB 读取数据失败", {
|
|
200
|
-
durationMs: +(performance.now() - startedAt).toFixed(2),
|
|
201
|
-
error: errorMessage
|
|
202
|
-
});
|
|
197
|
+
this.logError("从 IndexDB 读取数据失败", { error: errorMessage });
|
|
203
198
|
return [];
|
|
204
199
|
}
|
|
205
200
|
}
|
|
@@ -212,41 +207,20 @@ var MenuModule = class extends import_BaseModule.BaseModule {
|
|
|
212
207
|
this.logWarning("saveMenuToIndexDB: dbManager 不可用");
|
|
213
208
|
return;
|
|
214
209
|
}
|
|
215
|
-
const startedAt = performance.now();
|
|
216
|
-
let clearDurationMs = 0;
|
|
217
|
-
let writeDurationMs = 0;
|
|
218
210
|
this.logInfo("开始保存餐牌数据到 IndexDB", { menuCount: menuList.length });
|
|
219
211
|
try {
|
|
220
|
-
|
|
221
|
-
try {
|
|
222
|
-
await this.dbManager.clear(INDEXDB_STORE_NAME);
|
|
223
|
-
} finally {
|
|
224
|
-
clearDurationMs = +(performance.now() - clearStartedAt).toFixed(2);
|
|
225
|
-
}
|
|
226
|
-
const writeStartedAt = performance.now();
|
|
212
|
+
await this.dbManager.clear(INDEXDB_STORE_NAME);
|
|
227
213
|
const savePromises = menuList.map(
|
|
228
214
|
(menu) => this.dbManager.add(INDEXDB_STORE_NAME, menu)
|
|
229
215
|
);
|
|
230
|
-
|
|
231
|
-
await Promise.all(savePromises);
|
|
232
|
-
} finally {
|
|
233
|
-
writeDurationMs = +(performance.now() - writeStartedAt).toFixed(2);
|
|
234
|
-
}
|
|
216
|
+
await Promise.all(savePromises);
|
|
235
217
|
console.log(`[Menu] 已将 ${menuList.length} 条餐牌数据保存到 IndexDB`);
|
|
236
|
-
this.logInfo("餐牌数据已保存到 IndexDB", {
|
|
237
|
-
menuCount: menuList.length,
|
|
238
|
-
clearDurationMs,
|
|
239
|
-
writeDurationMs,
|
|
240
|
-
totalDurationMs: +(performance.now() - startedAt).toFixed(2)
|
|
241
|
-
});
|
|
218
|
+
this.logInfo("餐牌数据已保存到 IndexDB", { menuCount: menuList.length });
|
|
242
219
|
} catch (error) {
|
|
243
220
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
244
221
|
console.error("[Menu] 保存数据到 IndexDB 失败:", error);
|
|
245
222
|
this.logError("保存数据到 IndexDB 失败", {
|
|
246
223
|
menuCount: menuList.length,
|
|
247
|
-
clearDurationMs,
|
|
248
|
-
writeDurationMs,
|
|
249
|
-
totalDurationMs: +(performance.now() - startedAt).toFixed(2),
|
|
250
224
|
error: errorMessage
|
|
251
225
|
});
|
|
252
226
|
}
|
|
@@ -119,17 +119,13 @@ export declare class OrderModule extends BaseModule implements Module {
|
|
|
119
119
|
payment: Record<string, any>;
|
|
120
120
|
previousPayment: Record<string, any>;
|
|
121
121
|
} | null>;
|
|
122
|
-
loadOrdersByServer(
|
|
123
|
-
trigger?: string;
|
|
124
|
-
}): Promise<OrderData[]>;
|
|
122
|
+
loadOrdersByServer(): Promise<OrderData[]>;
|
|
125
123
|
/**
|
|
126
124
|
* 静默全量刷新:后台重新拉取全量 SSE 订单数据并更新本地
|
|
127
125
|
* 拿到完整数据后一次性替换 store,触发订单变更与同步完成事件
|
|
128
126
|
* @returns 刷新后的订单列表
|
|
129
127
|
*/
|
|
130
|
-
silentRefresh(
|
|
131
|
-
trigger?: string;
|
|
132
|
-
}): Promise<OrderData[]>;
|
|
128
|
+
silentRefresh(): Promise<OrderData[]>;
|
|
133
129
|
private normalizeOrderForMemoryList;
|
|
134
130
|
private normalizeOrdersForMemoryList;
|
|
135
131
|
private hasRealOrderId;
|
|
@@ -294,14 +290,13 @@ export declare class OrderModule extends BaseModule implements Module {
|
|
|
294
290
|
private logDuplicateOrders;
|
|
295
291
|
private compactOrderListByIdentity;
|
|
296
292
|
/**
|
|
297
|
-
*
|
|
298
|
-
*
|
|
293
|
+
* 当前订单拉取窗口:
|
|
294
|
+
* - 优先使用 createdAtQuery.sales_time_between(已按营业日边界初始化)
|
|
295
|
+
* - 无法解析时退化为自然日窗口
|
|
299
296
|
*/
|
|
300
|
-
private
|
|
297
|
+
private getCurrentPullWindow;
|
|
301
298
|
private hasPulledOrdersToday;
|
|
302
299
|
private markOrderPulledAtNow;
|
|
303
|
-
private clearOrderSnapshotMarker;
|
|
304
|
-
private getCurrentShopId;
|
|
305
300
|
private getStorageItem;
|
|
306
301
|
private setStorageItem;
|
|
307
302
|
private loadOrdersFromSQLite;
|
|
@@ -339,7 +334,7 @@ export declare class OrderModule extends BaseModule implements Module {
|
|
|
339
334
|
* 用于 SSE 全量拉取与营业日窗口裁剪。
|
|
340
335
|
*
|
|
341
336
|
* @example
|
|
342
|
-
*
|
|
337
|
+
* await this.replaceOrdersSnapshotInSQLite(orderList)
|
|
343
338
|
*/
|
|
344
339
|
private replaceOrdersSnapshotInSQLite;
|
|
345
340
|
/**
|