@pisell/pisellos 2.3.65 → 2.3.67

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 (52) hide show
  1. package/dist/core/index.d.ts +7 -0
  2. package/dist/core/index.js +109 -65
  3. package/dist/model/strategy/adapter/walletPass/evaluator.js +1 -0
  4. package/dist/model/strategy/adapter/walletPass/utils.js +2 -0
  5. package/dist/modules/Customer/index.d.ts +0 -4
  6. package/dist/modules/Customer/index.js +59 -91
  7. package/dist/modules/Customer/types.d.ts +0 -2
  8. package/dist/modules/Payment/walletpass.js +5 -4
  9. package/dist/modules/Quotation/index.d.ts +6 -0
  10. package/dist/modules/Quotation/index.js +75 -19
  11. package/dist/plugins/request.d.ts +1 -0
  12. package/dist/server/index.d.ts +8 -2
  13. package/dist/server/index.js +209 -142
  14. package/dist/server/modules/floor-plan/index.d.ts +4 -0
  15. package/dist/server/modules/floor-plan/index.js +240 -98
  16. package/dist/server/modules/menu/index.js +48 -23
  17. package/dist/server/modules/order/index.d.ts +17 -8
  18. package/dist/server/modules/order/index.js +506 -453
  19. package/dist/server/modules/products/index.d.ts +8 -2
  20. package/dist/server/modules/products/index.js +167 -75
  21. package/dist/server/modules/resource/index.js +21 -13
  22. package/dist/server/utils/small-ticket.js +1 -2
  23. package/dist/solution/BookingByStep/index.d.ts +1 -1
  24. package/dist/solution/BookingTicket/index.d.ts +0 -2
  25. package/dist/solution/BookingTicket/index.js +10 -34
  26. package/lib/core/index.d.ts +7 -0
  27. package/lib/core/index.js +20 -2
  28. package/lib/model/strategy/adapter/promotion/index.js +0 -51
  29. package/lib/model/strategy/adapter/walletPass/evaluator.js +1 -0
  30. package/lib/model/strategy/adapter/walletPass/utils.js +1 -0
  31. package/lib/modules/Customer/index.d.ts +0 -4
  32. package/lib/modules/Customer/index.js +0 -11
  33. package/lib/modules/Customer/types.d.ts +0 -2
  34. package/lib/modules/Payment/walletpass.js +1 -0
  35. package/lib/modules/Quotation/index.d.ts +6 -0
  36. package/lib/modules/Quotation/index.js +49 -5
  37. package/lib/plugins/request.d.ts +1 -0
  38. package/lib/server/index.d.ts +8 -2
  39. package/lib/server/index.js +55 -19
  40. package/lib/server/modules/floor-plan/index.d.ts +4 -0
  41. package/lib/server/modules/floor-plan/index.js +54 -6
  42. package/lib/server/modules/menu/index.js +31 -5
  43. package/lib/server/modules/order/index.d.ts +17 -8
  44. package/lib/server/modules/order/index.js +199 -106
  45. package/lib/server/modules/products/index.d.ts +8 -2
  46. package/lib/server/modules/products/index.js +97 -24
  47. package/lib/server/modules/resource/index.js +7 -2
  48. package/lib/server/utils/small-ticket.js +1 -1
  49. package/lib/solution/BookingByStep/index.d.ts +1 -1
  50. package/lib/solution/BookingTicket/index.d.ts +0 -2
  51. package/lib/solution/BookingTicket/index.js +2 -18
  52. package/package.json +1 -1
@@ -688,11 +688,11 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
688
688
  return null;
689
689
  }
690
690
  }, {
691
- key: "resolveCustomerById",
691
+ key: "resolveCustomerByDiscountCustomerId",
692
692
  value: function () {
693
- var _resolveCustomerById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(customerId) {
693
+ var _resolveCustomerByDiscountCustomerId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(customerId) {
694
694
  var _result$list;
695
- var localCustomers, localCustomer, normalizedLocalCustomer, result, remoteCustomer, detailCustomer;
695
+ var localCustomers, localCustomer, normalizedLocalCustomer, result, remoteCustomer;
696
696
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
697
697
  while (1) switch (_context9.prev = _context9.next) {
698
698
  case 0:
@@ -714,42 +714,18 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
714
714
  case 7:
715
715
  result = _context9.sent;
716
716
  remoteCustomer = this.findCustomerById((result === null || result === void 0 ? void 0 : result.list) || [], customerId) || (result === null || result === void 0 || (_result$list = result.list) === null || _result$list === void 0 ? void 0 : _result$list[0]) || null;
717
- if (!remoteCustomer) {
718
- _context9.next = 11;
719
- break;
720
- }
721
- return _context9.abrupt("return", this.normalizeCustomer(remoteCustomer));
722
- case 11:
723
- _context9.prev = 11;
724
- _context9.next = 14;
725
- return this.store.customer.queryCustomerDetail(customerId);
726
- case 14:
727
- detailCustomer = _context9.sent;
728
- return _context9.abrupt("return", detailCustomer ? this.normalizeCustomer(detailCustomer) : null);
729
- case 18:
730
- _context9.prev = 18;
731
- _context9.t0 = _context9["catch"](11);
732
- console.warn('[BookingTicket] resolveCustomerById detail request failed', {
733
- customerId: customerId,
734
- error: _context9.t0
735
- });
736
- return _context9.abrupt("return", null);
737
- case 22:
717
+ return _context9.abrupt("return", remoteCustomer ? this.normalizeCustomer(remoteCustomer) : null);
718
+ case 10:
738
719
  case "end":
739
720
  return _context9.stop();
740
721
  }
741
- }, _callee9, this, [[11, 18]]);
722
+ }, _callee9, this);
742
723
  }));
743
- function resolveCustomerById(_x6) {
744
- return _resolveCustomerById.apply(this, arguments);
724
+ function resolveCustomerByDiscountCustomerId(_x6) {
725
+ return _resolveCustomerByDiscountCustomerId.apply(this, arguments);
745
726
  }
746
- return resolveCustomerById;
747
- }() /** 兼容既有优惠码扫码逻辑。 */
748
- }, {
749
- key: "resolveCustomerByDiscountCustomerId",
750
- value: function resolveCustomerByDiscountCustomerId(customerId) {
751
- return this.resolveCustomerById(customerId);
752
- }
727
+ return resolveCustomerByDiscountCustomerId;
728
+ }()
753
729
  }, {
754
730
  key: "findCustomerById",
755
731
  value: function findCustomerById() {
@@ -12,8 +12,15 @@ declare class PisellOSCore implements PisellCore {
12
12
  context: BusinessContext;
13
13
  server: any;
14
14
  serverOptions?: ServerOptions;
15
+ private serverModulePromise?;
15
16
  constructor(options?: PisellOSOptions);
16
17
  private initialize;
18
+ /**
19
+ * 仅预加载 Server 模块代码,不创建实例、不注册模块、不请求业务数据。
20
+ * 导入失败会清空 Promise,正式 initializeServer 时仍可重新尝试。
21
+ */
22
+ preloadServerModule(): Promise<void>;
23
+ private loadServerModule;
17
24
  /**
18
25
  * 初始化 Server(公开方法,需要外部显式调用并等待)
19
26
  * Server 配置从构造函数传入的 options.server 中获取
package/lib/core/index.js CHANGED
@@ -36,7 +36,6 @@ module.exports = __toCommonJS(core_exports);
36
36
  var import_createStore = require("../store/createStore");
37
37
  var import_effects = require("../effects");
38
38
  var PisellOSCore = class {
39
- // 保存 Server 配置
40
39
  constructor(options) {
41
40
  this.plugins = /* @__PURE__ */ new Map();
42
41
  this.modules = /* @__PURE__ */ new Map();
@@ -50,6 +49,7 @@ var PisellOSCore = class {
50
49
  this.serverOptions = options.server;
51
50
  }
52
51
  this.initialize(options);
52
+ console.log("constructor123456");
53
53
  }
54
54
  initialize(options) {
55
55
  if (options == null ? void 0 : options.plugins) {
@@ -64,6 +64,24 @@ var PisellOSCore = class {
64
64
  }
65
65
  this.log("[PisellOS] 核心初始化完成");
66
66
  }
67
+ /**
68
+ * 仅预加载 Server 模块代码,不创建实例、不注册模块、不请求业务数据。
69
+ * 导入失败会清空 Promise,正式 initializeServer 时仍可重新尝试。
70
+ */
71
+ async preloadServerModule() {
72
+ if (this.server || !this.serverOptions)
73
+ return;
74
+ await this.loadServerModule();
75
+ }
76
+ loadServerModule() {
77
+ if (!this.serverModulePromise) {
78
+ this.serverModulePromise = import("../server").catch((error) => {
79
+ this.serverModulePromise = void 0;
80
+ throw error;
81
+ });
82
+ }
83
+ return this.serverModulePromise;
84
+ }
67
85
  /**
68
86
  * 初始化 Server(公开方法,需要外部显式调用并等待)
69
87
  * Server 配置从构造函数传入的 options.server 中获取
@@ -78,7 +96,7 @@ var PisellOSCore = class {
78
96
  return;
79
97
  }
80
98
  try {
81
- const ServerModule = await import("../server");
99
+ const ServerModule = await this.loadServerModule();
82
100
  const Server = ServerModule.default;
83
101
  this.server = new Server(this);
84
102
  this.log("Server 实例已创建");
@@ -1,51 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // src/model/strategy/adapter/promotion/index.ts
30
- var promotion_exports = {};
31
- __export(promotion_exports, {
32
- BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
33
- ITEM_REWARD_STRATEGY: () => import_examples.ITEM_REWARD_STRATEGY,
34
- PromotionAdapter: () => import_adapter.PromotionAdapter,
35
- PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
36
- X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
37
- default: () => import_adapter2.default
38
- });
39
- module.exports = __toCommonJS(promotion_exports);
40
- var import_evaluator = require("./evaluator");
41
- var import_adapter = require("./adapter");
42
- var import_adapter2 = __toESM(require("./adapter"));
43
- var import_examples = require("./examples");
44
- // Annotate the CommonJS export names for ESM import in node:
45
- 0 && (module.exports = {
46
- BUY_X_GET_Y_FREE_STRATEGY,
47
- ITEM_REWARD_STRATEGY,
48
- PromotionAdapter,
49
- PromotionEvaluator,
50
- X_ITEMS_FOR_Y_PRICE_STRATEGY
51
- });
@@ -415,6 +415,7 @@ var WalletPassEvaluator = class {
415
415
  * 计算适用商品的总金额和数量
416
416
  */
417
417
  calculateApplicableProducts(products, applicableProductIds, deductTaxAndFee) {
418
+ console.log(products, "products1234");
418
419
  let total = 0;
419
420
  let count = 0;
420
421
  if (applicableProductIds !== null && applicableProductIds.length === 0) {
@@ -166,6 +166,7 @@ var getApplicableProducts = (voucher, productsData) => {
166
166
  return productsData.filter((p) => applicableProductIds.includes(p.product_id));
167
167
  };
168
168
  function processVouchers(applicableVouchers, orderTotalAmount, products) {
169
+ console.log(products, "products123");
169
170
  const productsCopy = expandProductsWithBundleItems(products, true);
170
171
  let remainingOrderAmount = new import_decimal.default(orderTotalAmount);
171
172
  const getItemPassUsage = (usageMap, walletPassProductId, lineKey) => {
@@ -44,10 +44,6 @@ export declare class CustomerModule extends BaseModule implements Module, Custom
44
44
  * 用于按 ID 补齐客户等内部查询,避免把临时的 num/searchParams 污染到滚动列表。
45
45
  */
46
46
  queryCustomerList(params?: ShopGetCustomerListParams): Promise<ICustomerListResponse>;
47
- /**
48
- * 查询单个客户详情,不写入 customerList / pagination 状态。
49
- */
50
- queryCustomerDetail(id: string | number): Promise<ShopCustomer | null>;
51
47
  /**
52
48
  * 获取客户列表
53
49
  * @param params 查询参数
@@ -201,17 +201,6 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
201
201
  pageSize
202
202
  };
203
203
  }
204
- /**
205
- * 查询单个客户详情,不写入 customerList / pagination 状态。
206
- */
207
- async queryCustomerDetail(id) {
208
- var _a;
209
- const result = await this.request.get(`/customer/info/${id}`, {
210
- with_trashed: 1
211
- });
212
- const customer = ((_a = result == null ? void 0 : result.data) == null ? void 0 : _a.customer) || (result == null ? void 0 : result.data) || (result == null ? void 0 : result.customer) || null;
213
- return customer && typeof customer === "object" ? customer : null;
214
- }
215
204
  /**
216
205
  * 获取客户列表
217
206
  * @param params 查询参数
@@ -112,8 +112,6 @@ export interface CustomerModuleAPI {
112
112
  getCustomerList: (params?: ShopGetCustomerListParams) => Promise<ICustomerListResponse>;
113
113
  /** 查询客户列表但不更新列表分页状态 */
114
114
  queryCustomerList: (params?: ShopGetCustomerListParams) => Promise<ICustomerListResponse>;
115
- /** 查询单个客户详情但不修改客户列表状态 */
116
- queryCustomerDetail: (id: string | number) => Promise<ShopCustomer | null>;
117
115
  /** 设置客户列表 */
118
116
  setCustomerList: (customers: ShopCustomer[], total?: number) => void;
119
117
  /** 设置当前选择的客户 */
@@ -543,6 +543,7 @@ var WalletPassPaymentImpl = class {
543
543
  vouchers: allList
544
544
  });
545
545
  const { recommended, transformList, noApplicableVoucher, recommendedAmount } = res;
546
+ console.log(res, "resres12");
546
547
  this.walletRecommendList = recommended;
547
548
  this.walletInitData = {
548
549
  transformList,
@@ -9,6 +9,8 @@ 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?;
12
14
  constructor(name?: string, version?: string);
13
15
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
14
16
  loadQuotations(params?: {
@@ -16,6 +18,7 @@ export declare class QuotationModule extends BaseModule implements Module {
16
18
  customer_id?: number | string;
17
19
  }): Promise<void>;
18
20
  getQuotationList(): QuotationItem[];
21
+ setQuotationListUpdatedListener(listener?: () => void): void;
19
22
  getQuotationCustomerScopeInfo(): QuotationCustomerScopeInfo;
20
23
  /**
21
24
  * Look up the quotation price for a specific product (+ optional variant) at a given datetime.
@@ -60,6 +63,9 @@ export declare class QuotationModule extends BaseModule implements Module {
60
63
  customer_id?: number | string;
61
64
  }): Map<string, string | null>;
62
65
  setScheduleResolver(resolver: (id: number) => ScheduleItem | undefined): void;
66
+ private applyQuotationResponse;
67
+ private notifyQuotationListUpdated;
68
+ private getQuotationCacheKeyData;
63
69
  private isQuotationVisibleForCustomer;
64
70
  private hasValidCustomerId;
65
71
  private normalizeCustomerId;
@@ -32,32 +32,49 @@ var QuotationModule = class extends import_BaseModule.BaseModule {
32
32
  this.store = { list: [] };
33
33
  }
34
34
  async initialize(core, options) {
35
+ var _a, _b;
35
36
  this.core = core;
36
37
  this.request = core.getPlugin("request");
37
38
  if (!this.request)
38
39
  throw new Error("QuotationModule 需要 request 插件支持");
40
+ this.app = (_b = (_a = core.getPlugin("app")) == null ? void 0 : _a.getApp) == null ? void 0 : _b.call(_a);
39
41
  this.store = { list: [] };
40
42
  }
41
43
  async loadQuotations(params) {
42
- var _a;
43
44
  const query = {};
44
45
  if (params == null ? void 0 : params.channel)
45
46
  query.channel = params.channel;
46
47
  if ((params == null ? void 0 : params.channel) === "online_store") {
47
48
  query.channel = "online-store";
48
49
  }
50
+ let initialResultApplied = false;
51
+ const applyRemoteUpdate = (response) => {
52
+ this.applyQuotationResponse(response);
53
+ if (initialResultApplied) {
54
+ this.notifyQuotationListUpdated();
55
+ }
56
+ };
49
57
  const res = await this.request.get(
50
58
  "/quotation/available",
51
59
  query,
52
- { useCache: false, osServer: true }
60
+ {
61
+ cache: {
62
+ type: "indexDB",
63
+ updateCache: true,
64
+ cacheKeyData: this.getQuotationCacheKeyData(query)
65
+ },
66
+ cacheUpdateChange: applyRemoteUpdate
67
+ }
53
68
  );
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;
69
+ this.applyQuotationResponse(res);
70
+ initialResultApplied = true;
57
71
  }
58
72
  getQuotationList() {
59
73
  return this.store.list;
60
74
  }
75
+ setQuotationListUpdatedListener(listener) {
76
+ this.quotationListUpdatedListener = listener;
77
+ }
61
78
  getQuotationCustomerScopeInfo() {
62
79
  const customerById = /* @__PURE__ */ new Map();
63
80
  const quotationScopes = this.store.list.filter((quotation) => Array.isArray(quotation.customer) && quotation.customer.length > 0).map((quotation) => {
@@ -156,6 +173,33 @@ var QuotationModule = class extends import_BaseModule.BaseModule {
156
173
  setScheduleResolver(resolver) {
157
174
  this.scheduleResolver = resolver;
158
175
  }
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
+ }
159
203
  isQuotationVisibleForCustomer(quotation, customerId) {
160
204
  const customers = quotation.customer || [];
161
205
  if (customers.length === 0)
@@ -68,6 +68,7 @@ export interface RequestOptions {
68
68
  useCache?: boolean;
69
69
  customToast?: () => void;
70
70
  cache?: CacheProps;
71
+ cacheUpdateChange?: (data: any) => void;
71
72
  osServer?: boolean;
72
73
  prefix?: boolean;
73
74
  callback?: (res: any) => void;
@@ -51,6 +51,8 @@ declare class Server {
51
51
  private productQueryScheduleTimers;
52
52
  /** 餐牌筛选为空时才触发的菜单/日程缓存自愈,避免每次商品查询都请求远端。 */
53
53
  private menuScheduleRefreshInFlight;
54
+ /** 启动阶段模块预加载任务;预渲染商品查询复用该任务,避免缓存尚未 ready 时误触发远端自愈。 */
55
+ private startupModulePreloadInFlight;
54
56
  private lastMenuScheduleRefreshAt;
55
57
  private readonly MENU_SCHEDULE_REFRESH_COOLDOWN_MS;
56
58
  private orderQuerySubscribers;
@@ -157,13 +159,17 @@ declare class Server {
157
159
  * 重新拉取全量 SSE 接口,更新本地数据后触发 onProductsSyncCompleted
158
160
  * 不影响当前界面展示,适用于切回前台、定时刷新等场景
159
161
  */
160
- refreshProductsInBackground(): Promise<void>;
162
+ refreshProductsInBackground(options?: {
163
+ trigger?: string;
164
+ }): Promise<void>;
161
165
  /**
162
166
  * 后台静默刷新订单数据
163
167
  * 重新拉取全量 SSE 接口,更新本地数据后触发 onOrdersSyncCompleted
164
168
  * 不影响当前界面展示,适用于切回前台、定时刷新等场景
165
169
  */
166
- refreshOrdersInBackground(): Promise<void>;
170
+ refreshOrdersInBackground(options?: {
171
+ trigger?: string;
172
+ }): Promise<void>;
167
173
  /**
168
174
  * 编辑正式订单时强制查询 Server 最新快照并覆盖本地缓存。
169
175
  * 商品成员增删由 OrderModule 在 SQLite/Store 更新完成后广播,
@@ -86,6 +86,8 @@ var Server = class {
86
86
  this.productQueryScheduleTimers = /* @__PURE__ */ new Map();
87
87
  /** 餐牌筛选为空时才触发的菜单/日程缓存自愈,避免每次商品查询都请求远端。 */
88
88
  this.menuScheduleRefreshInFlight = null;
89
+ /** 启动阶段模块预加载任务;预渲染商品查询复用该任务,避免缓存尚未 ready 时误触发远端自愈。 */
90
+ this.startupModulePreloadInFlight = null;
89
91
  this.lastMenuScheduleRefreshAt = 0;
90
92
  this.MENU_SCHEDULE_REFRESH_COOLDOWN_MS = 30 * 1e3;
91
93
  // ---- 订单 / 预约列表查询订阅者 ----
@@ -1383,7 +1385,15 @@ var Server = class {
1383
1385
  this.registerDeviceTaskActions();
1384
1386
  const registeredModules = await this.registerModules(moduleConfigs);
1385
1387
  if (autoPreload) {
1386
- await this.preloadModulesData(registeredModules, options);
1388
+ const preloadTask = this.preloadModulesData(registeredModules, options);
1389
+ this.startupModulePreloadInFlight = preloadTask;
1390
+ try {
1391
+ await preloadTask;
1392
+ } finally {
1393
+ if (this.startupModulePreloadInFlight === preloadTask) {
1394
+ this.startupModulePreloadInFlight = null;
1395
+ }
1396
+ }
1387
1397
  } else {
1388
1398
  this.logInfo("跳过自动预加载", { autoPreload });
1389
1399
  }
@@ -1688,11 +1698,22 @@ var Server = class {
1688
1698
  return;
1689
1699
  }
1690
1700
  try {
1691
- await this.schedule.loadAllSchedule();
1692
1701
  this.products.clearPriceCache();
1693
1702
  await this.products.setupQuotationPriceBridge({
1694
1703
  scheduleModule: this.schedule,
1695
- channel: (_a = this.core.context) == null ? void 0 : _a.channel
1704
+ channel: (_a = this.core.context) == null ? void 0 : _a.channel,
1705
+ onQuotationUpdated: () => {
1706
+ void this.recomputeAndNotifyProductQuery();
1707
+ }
1708
+ });
1709
+ void this.schedule.loadAllSchedule().then(() => {
1710
+ var _a2;
1711
+ (_a2 = this.products) == null ? void 0 : _a2.clearPriceCache();
1712
+ void this.recomputeAndNotifyProductQuery();
1713
+ }).catch((error) => {
1714
+ this.logWarning("Products 报价单价格桥接后台刷新 Schedule 失败,继续使用本地数据", {
1715
+ error: error instanceof Error ? error.message : String(error)
1716
+ });
1696
1717
  });
1697
1718
  this.logInfo("Products 报价单价格桥接初始化完成");
1698
1719
  } catch (error) {
@@ -1750,22 +1771,27 @@ var Server = class {
1750
1771
  * 重新拉取全量 SSE 接口,更新本地数据后触发 onProductsSyncCompleted
1751
1772
  * 不影响当前界面展示,适用于切回前台、定时刷新等场景
1752
1773
  */
1753
- async refreshProductsInBackground() {
1774
+ async refreshProductsInBackground(options = {}) {
1754
1775
  if (!this.products) {
1755
1776
  this.logWarning("refreshProductsInBackground: Products 模块未注册");
1756
1777
  return;
1757
1778
  }
1758
- this.logInfo("refreshProductsInBackground 开始");
1779
+ const trigger = options.trigger || "background";
1780
+ this.logInfo("refreshProductsInBackground 开始", { trigger });
1759
1781
  const startTime = Date.now();
1760
1782
  try {
1761
- await this.products.silentRefresh();
1783
+ await this.products.silentRefresh({ trigger });
1762
1784
  const duration = Date.now() - startTime;
1763
- this.logInfo("refreshProductsInBackground 完成", { duration: `${duration}ms` });
1785
+ this.logInfo("refreshProductsInBackground 完成", {
1786
+ trigger,
1787
+ duration: `${duration}ms`
1788
+ });
1764
1789
  } catch (error) {
1765
1790
  const duration = Date.now() - startTime;
1766
1791
  const errorMessage = error instanceof Error ? error.message : String(error);
1767
1792
  console.error("[Server] refreshProductsInBackground 失败:", error);
1768
1793
  this.logError("refreshProductsInBackground 失败", {
1794
+ trigger,
1769
1795
  duration: `${duration}ms`,
1770
1796
  error: errorMessage
1771
1797
  });
@@ -1776,22 +1802,27 @@ var Server = class {
1776
1802
  * 重新拉取全量 SSE 接口,更新本地数据后触发 onOrdersSyncCompleted
1777
1803
  * 不影响当前界面展示,适用于切回前台、定时刷新等场景
1778
1804
  */
1779
- async refreshOrdersInBackground() {
1805
+ async refreshOrdersInBackground(options = {}) {
1780
1806
  if (!this.order) {
1781
1807
  this.logWarning("refreshOrdersInBackground: Order 模块未注册");
1782
1808
  return;
1783
1809
  }
1784
- this.logInfo("refreshOrdersInBackground 开始");
1810
+ const trigger = options.trigger || "background";
1811
+ this.logInfo("refreshOrdersInBackground 开始", { trigger });
1785
1812
  const startTime = Date.now();
1786
1813
  try {
1787
- await this.order.silentRefresh();
1814
+ await this.order.silentRefresh({ trigger });
1788
1815
  const duration = Date.now() - startTime;
1789
- this.logInfo("refreshOrdersInBackground 完成", { duration: `${duration}ms` });
1816
+ this.logInfo("refreshOrdersInBackground 完成", {
1817
+ trigger,
1818
+ duration: `${duration}ms`
1819
+ });
1790
1820
  } catch (error) {
1791
1821
  const duration = Date.now() - startTime;
1792
1822
  const errorMessage = error instanceof Error ? error.message : String(error);
1793
1823
  console.error("[Server] refreshOrdersInBackground 失败:", error);
1794
1824
  this.logError("refreshOrdersInBackground 失败", {
1825
+ trigger,
1795
1826
  duration: `${duration}ms`,
1796
1827
  error: errorMessage
1797
1828
  });
@@ -3916,8 +3947,9 @@ var Server = class {
3916
3947
  checkoutData: syncResult.checkoutData,
3917
3948
  order: syncedOrder,
3918
3949
  response: syncResult.normalizedResponse,
3919
- requireFullyPaid: true
3950
+ requireFullyPaid: true,
3920
3951
  // print_all 的 type=0 是收据打印;不要沿用同步成功后的券/手环打印 type=99。
3952
+ isManualPrint: true
3921
3953
  });
3922
3954
  }
3923
3955
  return response;
@@ -4094,7 +4126,7 @@ var Server = class {
4094
4126
  var _a, _b, _c, _d, _e;
4095
4127
  if (((_b = (_a = this.core.context) == null ? void 0 : _a.getPlatform) == null ? void 0 : _b.call(_a)) !== "android")
4096
4128
  return true;
4097
- return ((_e = (_d = (_c = this.app) == null ? void 0 : _c.storage) == null ? void 0 : _d.getStorage) == null ? void 0 : _e.call(_d, AUTO_PRINT_STORAGE_KEY)) !== "false";
4129
+ return ((_e = (_d = (_c = this.app) == null ? void 0 : _c.storage) == null ? void 0 : _d.getStorage) == null ? void 0 : _e.call(_d, AUTO_PRINT_STORAGE_KEY)) === "true";
4098
4130
  }
4099
4131
  shouldBuildSmallTicketData(order) {
4100
4132
  if (!order || typeof order !== "object")
@@ -5080,12 +5112,6 @@ var Server = class {
5080
5112
  const tTotal = performance.now();
5081
5113
  const { menu_list_ids, ids, schedule_date, schedule_datetime, customer_id, extension_type, product_id, strategy_context } = context;
5082
5114
  const queryIds = Array.isArray(ids) ? ids.map((id) => Number(id)).filter((id) => Number.isFinite(id)) : [];
5083
- const formatterContext = this.buildProductFormatterContext({
5084
- schedule_date,
5085
- schedule_datetime,
5086
- customer_id,
5087
- strategy_context
5088
- });
5089
5115
  this.logInfo("computeProductQueryResult 开始", {
5090
5116
  menuListIdsCount: (menu_list_ids == null ? void 0 : menu_list_ids.length) ?? 0,
5091
5117
  ids: queryIds,
@@ -5097,6 +5123,16 @@ var Server = class {
5097
5123
  strategyContextKeys: strategy_context ? Object.keys(strategy_context) : [],
5098
5124
  changedIds: options == null ? void 0 : options.changedIds
5099
5125
  });
5126
+ const startupPreloadTask = this.startupModulePreloadInFlight;
5127
+ if (startupPreloadTask) {
5128
+ await startupPreloadTask;
5129
+ }
5130
+ const formatterContext = this.buildProductFormatterContext({
5131
+ schedule_date,
5132
+ schedule_datetime,
5133
+ customer_id,
5134
+ strategy_context
5135
+ });
5100
5136
  if (!this.products) {
5101
5137
  this.logError("computeProductQueryResult: Products 模块未注册");
5102
5138
  return { message: "Products 模块未注册", data: this.buildProductQueryResultPayload([], 0) };
@@ -10,6 +10,7 @@ export declare class FloorPlanModule extends BaseModule implements Module {
10
10
  private store;
11
11
  private request;
12
12
  private logger;
13
+ private dbManager;
13
14
  private floorPlanDataSource;
14
15
  private pendingSyncMessages;
15
16
  private syncTimer?;
@@ -28,6 +29,9 @@ export declare class FloorPlanModule extends BaseModule implements Module {
28
29
  private mergeItems;
29
30
  private removeByIds;
30
31
  private loadListFromServer;
32
+ private loadListFromSQLite;
33
+ private saveListToSQLite;
34
+ private refreshListFromServer;
31
35
  fetchByIdFromServer(id: number | string): Promise<FloorPlanItem | null>;
32
36
  fetchByCodeFromServer(code: string): Promise<FloorPlanItem | null>;
33
37
  preload(): Promise<void>;