@pisell/pisellos 2.3.49 → 2.3.50

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 (162) hide show
  1. package/dist/modules/Discount/index.d.ts +1 -0
  2. package/dist/modules/Discount/index.js +40 -11
  3. package/dist/modules/Discount/types.d.ts +1 -0
  4. package/dist/modules/Holder/index.d.ts +48 -0
  5. package/dist/modules/Holder/index.js +640 -0
  6. package/dist/modules/Holder/types.d.ts +123 -0
  7. package/dist/modules/Holder/types.js +1 -0
  8. package/dist/modules/Holder/utils.d.ts +13 -0
  9. package/dist/modules/Holder/utils.js +34 -0
  10. package/dist/modules/OpenData/index.js +2 -2
  11. package/dist/modules/Order/index.d.ts +3 -1
  12. package/dist/modules/Order/index.js +54 -25
  13. package/dist/modules/Order/types.d.ts +9 -0
  14. package/dist/modules/Order/utils.d.ts +10 -0
  15. package/dist/modules/Order/utils.js +35 -3
  16. package/dist/modules/Payment/types.d.ts +0 -8
  17. package/dist/modules/Payment/walletpass.d.ts +1 -7
  18. package/dist/modules/Payment/walletpass.js +45 -155
  19. package/dist/modules/Product/types.d.ts +1 -0
  20. package/dist/modules/ProductList/index.js +33 -14
  21. package/dist/modules/Quotation/index.d.ts +1 -1
  22. package/dist/modules/Quotation/index.js +2 -2
  23. package/dist/modules/ResourcePlanner/index.d.ts +24 -0
  24. package/dist/modules/ResourcePlanner/index.js +181 -0
  25. package/dist/modules/ResourcePlanner/planner.d.ts +14 -0
  26. package/dist/modules/ResourcePlanner/planner.js +1069 -0
  27. package/dist/modules/ResourcePlanner/types.d.ts +227 -0
  28. package/dist/modules/ResourcePlanner/types.js +1 -0
  29. package/dist/modules/Rules/index.js +47 -13
  30. package/dist/modules/SalesSummary/index.js +12 -13
  31. package/dist/modules/ScanOrderLogger/index.d.ts +2 -0
  32. package/dist/modules/ScanOrderLogger/index.js +15 -2
  33. package/dist/modules/ScanOrderLogger/providers/feishu.js +45 -27
  34. package/dist/modules/ScanOrderLogger/types.d.ts +1 -0
  35. package/dist/modules/Schedule/index.d.ts +3 -1
  36. package/dist/modules/Schedule/index.js +21 -16
  37. package/dist/modules/Summary/utils.js +38 -13
  38. package/dist/modules/index.d.ts +2 -0
  39. package/dist/modules/index.js +3 -1
  40. package/dist/plugins/window.d.ts +1 -0
  41. package/dist/server/index.d.ts +14 -0
  42. package/dist/server/index.js +907 -793
  43. package/dist/server/modules/index.d.ts +1 -1
  44. package/dist/server/modules/order/index.d.ts +0 -16
  45. package/dist/server/modules/order/index.js +776 -964
  46. package/dist/server/modules/order/types.d.ts +0 -14
  47. package/dist/server/modules/order/types.js +0 -6
  48. package/dist/solution/BaseSales/index.d.ts +8 -3
  49. package/dist/solution/BaseSales/index.js +64 -50
  50. package/dist/solution/BookingByStep/index.d.ts +17 -2
  51. package/dist/solution/BookingByStep/index.js +294 -215
  52. package/dist/solution/BookingByStep/types.d.ts +2 -1
  53. package/dist/solution/BookingByStep/types.js +3 -1
  54. package/dist/solution/BookingByStep/utils/capacity.js +17 -1
  55. package/dist/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  56. package/dist/solution/BookingByStep/utils/timeslots.js +19 -12
  57. package/dist/solution/BookingTicket/index.d.ts +1 -1
  58. package/dist/solution/BookingTicket/index.js +2 -2
  59. package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
  60. package/dist/solution/BookingTicket/utils/scan/handleScan.js +10 -2
  61. package/dist/solution/ScanOrder/index.d.ts +26 -14
  62. package/dist/solution/ScanOrder/index.js +1142 -739
  63. package/dist/solution/ScanOrder/types.d.ts +21 -1
  64. package/dist/solution/ScanOrder/utils.d.ts +8 -0
  65. package/dist/solution/ScanOrder/utils.js +66 -25
  66. package/dist/solution/ShopDiscount/index.d.ts +1 -0
  67. package/dist/solution/ShopDiscount/index.js +125 -87
  68. package/dist/solution/UnifiedBookingSales/index.d.ts +183 -0
  69. package/dist/solution/UnifiedBookingSales/index.js +1891 -0
  70. package/dist/solution/UnifiedBookingSales/types.d.ts +143 -0
  71. package/dist/solution/UnifiedBookingSales/types.js +11 -0
  72. package/dist/solution/VenueBooking/index.d.ts +39 -11
  73. package/dist/solution/VenueBooking/index.js +1167 -841
  74. package/dist/solution/VenueBooking/types.d.ts +3 -0
  75. package/dist/solution/VenueBooking/utils/resource.js +1 -0
  76. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  77. package/dist/solution/VenueBooking/utils/slotMerge.js +10 -5
  78. package/dist/solution/index.d.ts +1 -0
  79. package/dist/solution/index.js +2 -1
  80. package/dist/types/index.d.ts +1 -0
  81. package/lib/model/strategy/adapter/promotion/index.js +51 -0
  82. package/lib/modules/Discount/index.d.ts +1 -0
  83. package/lib/modules/Discount/index.js +9 -0
  84. package/lib/modules/Discount/types.d.ts +1 -0
  85. package/lib/modules/Holder/index.d.ts +48 -0
  86. package/lib/modules/Holder/index.js +402 -0
  87. package/lib/modules/Holder/types.d.ts +123 -0
  88. package/lib/modules/Holder/types.js +17 -0
  89. package/lib/modules/Holder/utils.d.ts +13 -0
  90. package/lib/modules/Holder/utils.js +71 -0
  91. package/lib/modules/OpenData/index.js +1 -1
  92. package/lib/modules/Order/index.d.ts +3 -1
  93. package/lib/modules/Order/index.js +26 -10
  94. package/lib/modules/Order/types.d.ts +9 -0
  95. package/lib/modules/Order/utils.d.ts +10 -0
  96. package/lib/modules/Order/utils.js +36 -5
  97. package/lib/modules/Payment/types.d.ts +0 -8
  98. package/lib/modules/Payment/walletpass.d.ts +1 -7
  99. package/lib/modules/Payment/walletpass.js +9 -107
  100. package/lib/modules/Product/types.d.ts +1 -0
  101. package/lib/modules/ProductList/index.js +40 -31
  102. package/lib/modules/Quotation/index.d.ts +1 -1
  103. package/lib/modules/Quotation/index.js +2 -2
  104. package/lib/modules/ResourcePlanner/index.d.ts +24 -0
  105. package/lib/modules/ResourcePlanner/index.js +148 -0
  106. package/lib/modules/ResourcePlanner/planner.d.ts +14 -0
  107. package/lib/modules/ResourcePlanner/planner.js +933 -0
  108. package/lib/modules/ResourcePlanner/types.d.ts +227 -0
  109. package/lib/modules/ResourcePlanner/types.js +17 -0
  110. package/lib/modules/Rules/index.js +33 -16
  111. package/lib/modules/SalesSummary/index.js +6 -7
  112. package/lib/modules/ScanOrderLogger/index.d.ts +2 -0
  113. package/lib/modules/ScanOrderLogger/index.js +13 -1
  114. package/lib/modules/ScanOrderLogger/providers/feishu.js +15 -6
  115. package/lib/modules/ScanOrderLogger/types.d.ts +1 -0
  116. package/lib/modules/Schedule/index.d.ts +3 -1
  117. package/lib/modules/Schedule/index.js +10 -8
  118. package/lib/modules/Summary/utils.js +21 -1
  119. package/lib/modules/index.d.ts +2 -0
  120. package/lib/modules/index.js +5 -1
  121. package/lib/plugins/window.d.ts +1 -0
  122. package/lib/server/index.d.ts +14 -0
  123. package/lib/server/index.js +72 -15
  124. package/lib/server/modules/index.d.ts +1 -1
  125. package/lib/server/modules/order/index.d.ts +0 -16
  126. package/lib/server/modules/order/index.js +4 -140
  127. package/lib/server/modules/order/types.d.ts +0 -14
  128. package/lib/server/modules/order/types.js +0 -1
  129. package/lib/solution/BaseSales/index.d.ts +8 -3
  130. package/lib/solution/BaseSales/index.js +24 -14
  131. package/lib/solution/BookingByStep/index.d.ts +17 -2
  132. package/lib/solution/BookingByStep/index.js +60 -18
  133. package/lib/solution/BookingByStep/types.d.ts +2 -1
  134. package/lib/solution/BookingByStep/types.js +5 -0
  135. package/lib/solution/BookingByStep/utils/capacity.js +20 -1
  136. package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  137. package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
  138. package/lib/solution/BookingTicket/index.d.ts +1 -1
  139. package/lib/solution/BookingTicket/index.js +10 -2
  140. package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
  141. package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -2
  142. package/lib/solution/ScanOrder/index.d.ts +26 -14
  143. package/lib/solution/ScanOrder/index.js +449 -182
  144. package/lib/solution/ScanOrder/types.d.ts +21 -1
  145. package/lib/solution/ScanOrder/utils.d.ts +8 -0
  146. package/lib/solution/ScanOrder/utils.js +31 -0
  147. package/lib/solution/ShopDiscount/index.d.ts +1 -0
  148. package/lib/solution/ShopDiscount/index.js +14 -0
  149. package/lib/solution/UnifiedBookingSales/index.d.ts +183 -0
  150. package/lib/solution/UnifiedBookingSales/index.js +1084 -0
  151. package/lib/solution/UnifiedBookingSales/types.d.ts +143 -0
  152. package/lib/solution/UnifiedBookingSales/types.js +33 -0
  153. package/lib/solution/VenueBooking/index.d.ts +39 -11
  154. package/lib/solution/VenueBooking/index.js +322 -110
  155. package/lib/solution/VenueBooking/types.d.ts +3 -0
  156. package/lib/solution/VenueBooking/utils/resource.js +1 -0
  157. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  158. package/lib/solution/VenueBooking/utils/slotMerge.js +6 -4
  159. package/lib/solution/index.d.ts +1 -0
  160. package/lib/solution/index.js +3 -1
  161. package/lib/types/index.d.ts +1 -0
  162. package/package.json +1 -1
@@ -33,7 +33,7 @@ __export(VenueBooking_exports, {
33
33
  VenueBookingImpl: () => VenueBookingImpl
34
34
  });
35
35
  module.exports = __toCommonJS(VenueBooking_exports);
36
- var import_BaseModule = require("../../modules/BaseModule");
36
+ var import_BaseSales = require("../BaseSales");
37
37
  var import_types = require("./types");
38
38
  var import_utils = require("./utils");
39
39
  var import_types2 = require("../BookingByStep/types");
@@ -54,6 +54,8 @@ var import_utils3 = require("../../modules/Order/utils");
54
54
  var import_Order = require("../../modules/Order");
55
55
  var import_types4 = require("../RegisterAndLogin/types");
56
56
  var import_decimal = __toESM(require("decimal.js"));
57
+ var import_Holder = require("../../modules/Holder");
58
+ var import_utils4 = require("../../modules/Holder/utils");
57
59
  __reExport(VenueBooking_exports, require("./types"), module.exports);
58
60
  var OPEN_DATA_SECTION_CODES = [
59
61
  "basic",
@@ -79,7 +81,7 @@ function cloneCustomDepositData(customDepositData) {
79
81
  deposit_policy_data: Array.isArray(customDepositData.deposit_policy_data) ? [...customDepositData.deposit_policy_data] : []
80
82
  };
81
83
  }
82
- var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
84
+ var _VenueBookingImpl = class extends import_BaseSales.BaseSalesImpl {
83
85
  constructor(name, version) {
84
86
  super(name, version);
85
87
  this.defaultName = "venueBooking";
@@ -229,6 +231,79 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
229
231
  }
230
232
  });
231
233
  }
234
+ getRegisteredModuleNames() {
235
+ return [
236
+ "scanOrderLogger",
237
+ "products",
238
+ "order",
239
+ "salesSummary",
240
+ "venueProducts",
241
+ "addonProducts",
242
+ "date",
243
+ "schedule",
244
+ "quotation",
245
+ "openData"
246
+ ];
247
+ }
248
+ createSubModule(moduleName) {
249
+ switch (moduleName) {
250
+ case "scanOrderLogger":
251
+ return (0, import_types2.createModule)("scanOrderLogger", this.name);
252
+ case "venueProducts":
253
+ return new import_ProductList.ProductList(`${this.name}_venueProducts`);
254
+ case "addonProducts":
255
+ return new import_ProductList.ProductList(`${this.name}_addonProducts`);
256
+ case "date":
257
+ return new import_Date.DateModule(`${this.name}_date`);
258
+ case "openData":
259
+ return new import_OpenData.OpenDataModule(`${this.name}_openData`);
260
+ default:
261
+ return super.createSubModule(moduleName);
262
+ }
263
+ }
264
+ attachProductOriginToTempOrder(tempOrder, productUid, origin) {
265
+ var _a, _b, _c;
266
+ if (!productUid || !origin)
267
+ return;
268
+ tempOrder._extend = {
269
+ ...tempOrder._extend || {},
270
+ productsByUid: {
271
+ ...((_a = tempOrder._extend) == null ? void 0 : _a.productsByUid) || {},
272
+ [productUid]: {
273
+ ...((_c = (_b = tempOrder._extend) == null ? void 0 : _b.productsByUid) == null ? void 0 : _c[productUid]) || {},
274
+ origin
275
+ }
276
+ }
277
+ };
278
+ }
279
+ readProductOriginFromTempOrder(tempOrder, product) {
280
+ var _a, _b, _c, _d;
281
+ const uid = ((_a = product.metadata) == null ? void 0 : _a.unique_identification_number) || product.identity_key;
282
+ if (uid && ((_d = (_c = (_b = tempOrder._extend) == null ? void 0 : _b.productsByUid) == null ? void 0 : _c[uid]) == null ? void 0 : _d.origin)) {
283
+ return tempOrder._extend.productsByUid[uid].origin;
284
+ }
285
+ return product._origin;
286
+ }
287
+ normalizeVenueProductTitle(value) {
288
+ if (typeof value === "string") {
289
+ const text = value.trim();
290
+ return text ? { auto: text } : void 0;
291
+ }
292
+ if (!value || typeof value !== "object" || Array.isArray(value))
293
+ return void 0;
294
+ const source = value;
295
+ const normalized = {};
296
+ Object.entries(source).forEach(([key, text]) => {
297
+ if (typeof text === "string")
298
+ normalized[key] = text;
299
+ });
300
+ if (!normalized.auto) {
301
+ const fallback = normalized.original || normalized.en || normalized["zh-CN"] || normalized["zh-HK"];
302
+ if (fallback)
303
+ normalized.auto = fallback;
304
+ }
305
+ return Object.values(normalized).some((text) => String(text || "").trim()) ? normalized : void 0;
306
+ }
232
307
  normalizeCustomerId(value) {
233
308
  const customerId = Number(value);
234
309
  if (!Number.isFinite(customerId) || customerId <= 0)
@@ -257,6 +332,42 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
257
332
  }
258
333
  return null;
259
334
  }
335
+ resolveHolderCustomerId() {
336
+ var _a, _b;
337
+ const customer = JSON.parse(((_b = (_a = this.window) == null ? void 0 : _a.getLocalStorage) == null ? void 0 : _b.call(_a, "customer")) || "{}");
338
+ if (customer == null ? void 0 : customer.id)
339
+ return Number(customer.id);
340
+ return void 0;
341
+ }
342
+ /**
343
+ * 按商品 holder_config 预加载表单数据到 holderMap。
344
+ * appointment_booking 在加购时触发;venueBooking 在商品加载后预加载,避免 getHolderFormMap 为空。
345
+ */
346
+ async preloadHolderForms(products) {
347
+ var _a, _b, _c, _d;
348
+ if (!this.store.holder || !products.length)
349
+ return;
350
+ const seenFormIds = /* @__PURE__ */ new Set();
351
+ for (const item of products) {
352
+ const holderConfig = (0, import_utils4.getProductHolderConfig)((_a = item == null ? void 0 : item._origin) == null ? void 0 : _a.product);
353
+ if (!holderConfig)
354
+ continue;
355
+ const formId = (0, import_utils4.getFormIdFromHolderConfig)(holderConfig);
356
+ if (seenFormIds.has(formId))
357
+ continue;
358
+ seenFormIds.add(formId);
359
+ try {
360
+ await this.store.holder.ensureFormByProduct({
361
+ product: ((_b = item == null ? void 0 : item._origin) == null ? void 0 : _b.product) || {},
362
+ customer_id: this.resolveHolderCustomerId(),
363
+ shop_id: (_d = (_c = item == null ? void 0 : item._origin) == null ? void 0 : _c.product) == null ? void 0 : _d.shop_id,
364
+ useCache: true
365
+ });
366
+ } catch (error) {
367
+ console.error("[VenueBooking] 预加载 holder 表单失败", { formId, error });
368
+ }
369
+ }
370
+ }
260
371
  clearLoginEffectListeners() {
261
372
  for (const dispose of this.loginEffectDisposers) {
262
373
  dispose();
@@ -303,6 +414,12 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
303
414
  this.customerLoginRefreshIdInFlight = params.customerId;
304
415
  const refreshTask = (async () => {
305
416
  var _a;
417
+ if (this.store.holder) {
418
+ await this.store.holder.refreshAllFormRecords({
419
+ customer_id: params.customerId,
420
+ useCache: false
421
+ });
422
+ }
306
423
  if (this.store.quotation) {
307
424
  await this.store.quotation.loadQuotations({
308
425
  channel: (_a = this.otherParams) == null ? void 0 : _a.channel
@@ -330,10 +447,8 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
330
447
  }
331
448
  }
332
449
  async initialize(core, options = {}) {
333
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
450
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
334
451
  this.logMethodStart("initialize");
335
- this.core = core;
336
- this.initializeOptions = options || {};
337
452
  this.store = { ...this.store, ...options.store };
338
453
  this.store.entryContext = ((_a = options.otherParams) == null ? void 0 : _a.entryContext) || this.store.entryContext;
339
454
  this.store.status = "initializing";
@@ -355,15 +470,20 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
355
470
  passed: null,
356
471
  failures: []
357
472
  };
358
- this.window = core.getPlugin("window");
359
- this.request = core.getPlugin("request");
360
- if (!this.window) {
361
- this.logMethodError("initialize", "window plugin missing");
362
- throw new Error("venueBooking解决方案需要 window 插件支持");
363
- }
364
- if (!this.request) {
365
- this.logMethodError("initialize", "request plugin missing");
366
- throw new Error("venueBooking解决方案需要 request 插件支持");
473
+ await super.initialize(core, options);
474
+ if (this.store.scanOrderLogger) {
475
+ this.store.scanOrderLogger.setProvider(
476
+ ((_f = this.otherParams) == null ? void 0 : _f.loggerProvider) || "feishu"
477
+ );
478
+ this.store.scanOrderLogger.setProviderConfig(
479
+ ((_g = this.otherParams) == null ? void 0 : _g.loggerConfig) || {
480
+ feishu: {
481
+ webhook: "https://open.feishu.cn/open-apis/bot/v2/hook/8f069b14-9d39-4728-8f78-b56f393bfde8",
482
+ errorHook: "https://open.feishu.cn/open-apis/bot/v2/hook/bdefae5e-f233-4705-8688-946887d9543d"
483
+ }
484
+ }
485
+ );
486
+ this.store.scanOrderLogger.setContext(this.getLoggerContext());
367
487
  }
368
488
  const baseModules = [
369
489
  "scanOrderLogger",
@@ -381,10 +501,10 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
381
501
  } : {};
382
502
  const loggerProvider = ((_c2 = this.otherParams) == null ? void 0 : _c2.loggerProvider) || "feishu";
383
503
  const loggerConfig = ((_d2 = this.otherParams) == null ? void 0 : _d2.loggerConfig) || {
384
- feishu: {
385
- webhook: "https://open.feishu.cn/open-apis/bot/v2/hook/8f069b14-9d39-4728-8f78-b56f393bfde8",
386
- errorHook: "https://open.feishu.cn/open-apis/bot/v2/hook/bdefae5e-f233-4705-8688-946887d9543d"
387
- }
504
+ // feishu: {
505
+ // webhook: 'https://open.feishu.cn/open-apis/bot/v2/hook/8f069b14-9d39-4728-8f78-b56f393bfde8',
506
+ // errorHook: 'https://open.feishu.cn/open-apis/bot/v2/hook/bdefae5e-f233-4705-8688-946887d9543d',
507
+ // },
388
508
  };
389
509
  this.core.registerModule(targetModule, {
390
510
  initialState,
@@ -451,24 +571,43 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
451
571
  otherParams: {
452
572
  ...this.otherParams,
453
573
  fatherModule: this.name,
454
- openCache: !!((_f = this.otherParams) == null ? void 0 : _f.cacheId),
455
- cacheId: (_g = this.otherParams) == null ? void 0 : _g.cacheId
574
+ openCache: !!((_h = this.otherParams) == null ? void 0 : _h.cacheId),
575
+ cacheId: (_i = this.otherParams) == null ? void 0 : _i.cacheId
456
576
  }
457
577
  });
458
- if (this.store.scanOrderLogger) {
459
- this.store.scanOrderLogger.setContext(this.getLoggerContext());
578
+ let holderCacheState;
579
+ if ((_j = this.otherParams) == null ? void 0 : _j.cacheId) {
580
+ const sessionData = this.window.sessionStorage.getItem(this.name);
581
+ if (sessionData) {
582
+ try {
583
+ const data = JSON.parse(sessionData);
584
+ holderCacheState = (_k = data[this.otherParams.cacheId]) == null ? void 0 : _k[`${this.name}_holder`];
585
+ } catch {
586
+ }
587
+ }
460
588
  }
589
+ const holderModule = new import_Holder.HolderModule(`${this.name}_holder`);
590
+ this.store.holder = holderModule;
591
+ this.core.registerModule(holderModule, {
592
+ initialState: holderCacheState,
593
+ otherParams: {
594
+ ...this.otherParams,
595
+ fatherModule: this.name,
596
+ openCache: !!((_l = this.otherParams) == null ? void 0 : _l.cacheId),
597
+ cacheId: (_m = this.otherParams) == null ? void 0 : _m.cacheId
598
+ }
599
+ });
461
600
  this.registerCustomerLoginListeners();
462
601
  console.log("[VenueBooking] 初始化开始");
463
602
  try {
464
- await ((_h = this.store.order) == null ? void 0 : _h.recalculateSummary({ createIfMissing: false }));
465
- (_i = this.store.order) == null ? void 0 : _i.persistTempOrder();
603
+ await ((_n = this.store.order) == null ? void 0 : _n.recalculateSummary({ createIfMissing: false }));
604
+ (_o = this.store.order) == null ? void 0 : _o.persistTempOrder();
466
605
  await this.loadRuntimeConfigs();
467
606
  if (this.store.schedule) {
468
607
  await this.store.schedule.loadAllSchedule();
469
608
  this.injectScheduleResolverToQuotation();
470
- (_k = this.store.quotation) == null ? void 0 : _k.loadQuotations({
471
- channel: (_j = this.otherParams) == null ? void 0 : _j.channel
609
+ (_q = this.store.quotation) == null ? void 0 : _q.loadQuotations({
610
+ channel: (_p = this.otherParams) == null ? void 0 : _p.channel
472
611
  });
473
612
  }
474
613
  await this.refreshItemRuleQuantityLimits();
@@ -555,7 +694,7 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
555
694
  return this.loadAllProductsInFlight;
556
695
  }
557
696
  async _doLoadAllProducts() {
558
- var _a, _b, _c;
697
+ var _a, _b, _c, _d, _e;
559
698
  this.logMethodStart("loadAllProducts");
560
699
  try {
561
700
  if (!this.store.venueProducts)
@@ -584,6 +723,10 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
584
723
  }
585
724
  this.store.addonProducts.addProduct(addonList);
586
725
  this.resourceProductMap = (0, import_resource.buildResourceProductMap)(venueList);
726
+ if (this.store.order) {
727
+ const products = ((_e = (_d = this.store.order) == null ? void 0 : _d.getOrderProducts) == null ? void 0 : _e.call(_d)) || [];
728
+ await this.preloadHolderForms(products);
729
+ }
587
730
  this.productsLoaded = true;
588
731
  this.logMethodSuccess("loadAllProducts", {
589
732
  total: list.length,
@@ -976,6 +1119,7 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
976
1119
  * 同一场地下不同商品互不干扰,各自单独 reconcile。
977
1120
  */
978
1121
  async reconcileOrderForResourceProduct(resourceId, productId, slots) {
1122
+ var _a, _b;
979
1123
  const mappings = this.resourceProductMap.get(resourceId);
980
1124
  if (!mappings || !mappings.length || !this.store.order)
981
1125
  return;
@@ -989,10 +1133,10 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
989
1133
  );
990
1134
  tempOrder.bookings = (tempOrder.bookings || []).filter(
991
1135
  (b) => {
992
- var _a, _b, _c, _d;
993
- if (!((_a = b.metadata) == null ? void 0 : _a.venue_booking))
1136
+ var _a2, _b2, _c, _d;
1137
+ if (!((_a2 = b.metadata) == null ? void 0 : _a2.venue_booking))
994
1138
  return true;
995
- if (String((_b = b.metadata) == null ? void 0 : _b.resource_id) !== String(resourceId))
1139
+ if (String((_b2 = b.metadata) == null ? void 0 : _b2.resource_id) !== String(resourceId))
996
1140
  return true;
997
1141
  const bookingProductId = ((_c = b.metadata) == null ? void 0 : _c.product_id) ?? ((_d = b == null ? void 0 : b.product) == null ? void 0 : _d.product_id);
998
1142
  if (bookingProductId == null)
@@ -1021,6 +1165,7 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
1021
1165
  const endMoment = (0, import_dayjs.default)(group.endTime, "YYYY-MM-DD HH:mm");
1022
1166
  const duration = endMoment.diff(startMoment, "minute");
1023
1167
  const customDepositData = cloneCustomDepositData(venueProduct == null ? void 0 : venueProduct.custom_deposit_data);
1168
+ const productTitle = this.normalizeVenueProductTitle(venueProduct == null ? void 0 : venueProduct.product_title) || this.normalizeVenueProductTitle(venueProduct == null ? void 0 : venueProduct.title) || this.normalizeVenueProductTitle(mapping.productTitle);
1024
1169
  const resourceEntry = {
1025
1170
  relation_type: "form",
1026
1171
  like_status: "common",
@@ -1043,67 +1188,71 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
1043
1188
  metadata: {}
1044
1189
  }));
1045
1190
  }
1046
- tempOrder.products.push(
1047
- (0, import_utils.normalizeOrderProduct)({
1191
+ const venueProductOrigin = {
1192
+ name: mapping.productTitle,
1193
+ product_title: productTitle,
1194
+ cover: (venueProduct == null ? void 0 : venueProduct.cover) || "",
1195
+ custom_deposit_data: customDepositData,
1196
+ id: 0,
1197
+ number: 1,
1198
+ registration_type: "all",
1199
+ relation_products: [],
1200
+ is_all: false,
1201
+ product: {
1048
1202
  product_id: mapping.productId,
1049
1203
  product_variant_id: 0,
1050
- identity_key: identityKey,
1051
1204
  num: 1,
1052
- selling_price: group.totalPrice,
1053
- original_price: group.totalPrice,
1054
- is_charge_tax: (venueProduct == null ? void 0 : venueProduct.is_charge_tax) ?? 0,
1055
- metadata: {
1056
- venue_booking: true,
1057
- resource_id: resourceId,
1058
- resource_form_id: mapping.formId,
1059
- resource_name: mapping.resourceName,
1060
- start_time: group.startTime,
1061
- end_time: group.endTime,
1062
- slot_count: group.slotCount,
1063
- booking_uid: bookingUuid,
1064
- price_breakdown: (0, import_slotMerge.buildPriceBreakdown)({
1065
- group,
1066
- productId: mapping.productId,
1067
- quotation: this.store.quotation
1068
- })
1069
- },
1070
- _origin: {
1071
- name: mapping.productTitle,
1072
- cover: (venueProduct == null ? void 0 : venueProduct.cover) || "",
1073
- custom_deposit_data: customDepositData,
1074
- id: 0,
1075
- number: 1,
1076
- registration_type: "all",
1077
- relation_products: [],
1078
- is_all: false,
1079
- product: {
1080
- product_id: mapping.productId,
1081
- product_variant_id: 0,
1082
- num: 1,
1083
- product_bundle: [],
1084
- product_sku: { option: [] },
1085
- discount_list: [],
1086
- custom_deposit_data: customDepositData,
1087
- metadata: {}
1088
- },
1089
- sub_type: "minutes",
1090
- duration,
1091
- like_status: "common",
1092
- resources: [resourceEntry],
1093
- schedule_id: 0,
1094
- select_date: startMoment.format("YYYY-MM-DD"),
1095
- start_date: startMoment.format("YYYY-MM-DD"),
1096
- start_time: startMoment.format("HH:mm"),
1097
- end_date: endMoment.format("YYYY-MM-DD"),
1098
- end_time: endMoment.format("HH:mm"),
1099
- metadata: {
1100
- venue_booking: true,
1101
- slot_count: group.slotCount
1102
- },
1103
- holder: null
1104
- }
1105
- })
1106
- );
1205
+ product_bundle: [],
1206
+ product_sku: { option: [] },
1207
+ discount_list: [],
1208
+ custom_deposit_data: customDepositData,
1209
+ metadata: {}
1210
+ },
1211
+ sub_type: "minutes",
1212
+ duration,
1213
+ like_status: "common",
1214
+ resources: [resourceEntry],
1215
+ schedule_id: 0,
1216
+ select_date: startMoment.format("YYYY-MM-DD"),
1217
+ start_date: startMoment.format("YYYY-MM-DD"),
1218
+ start_time: startMoment.format("HH:mm"),
1219
+ end_date: endMoment.format("YYYY-MM-DD"),
1220
+ end_time: endMoment.format("HH:mm"),
1221
+ metadata: {
1222
+ venue_booking: true,
1223
+ slot_count: group.slotCount
1224
+ },
1225
+ holder: null
1226
+ };
1227
+ const normalizedVenueOrderProduct = (0, import_utils.normalizeOrderProduct)({
1228
+ product_id: mapping.productId,
1229
+ product_variant_id: 0,
1230
+ identity_key: identityKey,
1231
+ num: 1,
1232
+ selling_price: group.totalPrice,
1233
+ original_price: group.totalPrice,
1234
+ is_charge_tax: (venueProduct == null ? void 0 : venueProduct.is_charge_tax) ?? 0,
1235
+ metadata: {
1236
+ venue_booking: true,
1237
+ ...productTitle ? { product_title: productTitle } : {},
1238
+ resource_id: resourceId,
1239
+ resource_form_id: mapping.formId,
1240
+ resource_name: mapping.resourceName,
1241
+ start_time: group.startTime,
1242
+ end_time: group.endTime,
1243
+ slot_count: group.slotCount,
1244
+ booking_uid: bookingUuid,
1245
+ price_breakdown: (0, import_slotMerge.buildPriceBreakdown)({
1246
+ group,
1247
+ productId: mapping.productId,
1248
+ quotation: this.store.quotation
1249
+ })
1250
+ },
1251
+ _origin: venueProductOrigin
1252
+ });
1253
+ const venueOrderProduct = productTitle ? { ...normalizedVenueOrderProduct, product_title: productTitle } : normalizedVenueOrderProduct;
1254
+ this.attachProductOriginToTempOrder(tempOrder, identityKey, venueProductOrigin);
1255
+ tempOrder.products.push(venueOrderProduct);
1107
1256
  const booking = (0, import_slotMerge.buildVenueBookingEntry)({
1108
1257
  group,
1109
1258
  resourceId,
@@ -1115,6 +1264,8 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
1115
1264
  });
1116
1265
  tempOrder.bookings.push(booking);
1117
1266
  }
1267
+ const products = ((_b = (_a = this.store.order) == null ? void 0 : _a.getOrderProducts) == null ? void 0 : _b.call(_a)) || [];
1268
+ await this.preloadHolderForms(products);
1118
1269
  this.store.order.applyDiscount();
1119
1270
  await this.store.order.recalculateSummary({ createIfMissing: true });
1120
1271
  this.store.order.persistTempOrder();
@@ -1182,17 +1333,17 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
1182
1333
  const result = ((_a = this.store.order) == null ? void 0 : _a.getTempOrder()) || null;
1183
1334
  return result;
1184
1335
  }
1185
- updateTempOrderNote(note) {
1336
+ updateTempOrderNote(note, sync = false) {
1186
1337
  if (!this.store.order)
1187
1338
  throw new Error("order 模块未初始化");
1188
- return this.store.order.updateTempOrderNote(note);
1339
+ return this.store.order.updateTempOrderNote(note, sync);
1189
1340
  }
1190
1341
  updateTempOrderContactsInfo(contactsInfo) {
1191
1342
  if (!this.store.order)
1192
1343
  throw new Error("order 模块未初始化");
1193
1344
  return this.store.order.updateTempOrderContactsInfo(contactsInfo);
1194
1345
  }
1195
- ensureTempOrder() {
1346
+ ensureVenueTempOrder() {
1196
1347
  if (!this.store.order)
1197
1348
  throw new Error("order 模块未初始化");
1198
1349
  return this.store.order.ensureTempOrder();
@@ -1691,7 +1842,7 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
1691
1842
  return [];
1692
1843
  }
1693
1844
  const businessData = (0, import_utils.buildItemRuleBusinessData)({
1694
- tempOrder: this.ensureTempOrder(),
1845
+ tempOrder: this.ensureVenueTempOrder(),
1695
1846
  runtimeConfig: this.getItemRuleRuntimeConfig(),
1696
1847
  itemRuleConfigs: this.itemRuleConfigs
1697
1848
  });
@@ -1706,7 +1857,7 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
1706
1857
  }
1707
1858
  }
1708
1859
  async applyPrefillByItemRule() {
1709
- var _a;
1860
+ var _a, _b;
1710
1861
  if (this.itemRulePrefillApplied)
1711
1862
  return;
1712
1863
  if (!this.store.order)
@@ -1715,7 +1866,7 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
1715
1866
  if (!strategyConfigs.length)
1716
1867
  return;
1717
1868
  const businessData = (0, import_utils.buildItemRuleBusinessData)({
1718
- tempOrder: this.ensureTempOrder(),
1869
+ tempOrder: this.ensureVenueTempOrder(),
1719
1870
  runtimeConfig: this.getItemRuleRuntimeConfig(),
1720
1871
  itemRuleConfigs: this.itemRuleConfigs
1721
1872
  });
@@ -1725,7 +1876,7 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
1725
1876
  return;
1726
1877
  }
1727
1878
  const productSourceMap = await this.buildPrefillProductSourceMap();
1728
- const tempOrder = this.ensureTempOrder();
1879
+ const tempOrder = this.ensureVenueTempOrder();
1729
1880
  let hasChanges = false;
1730
1881
  for (const prefillItem of prefillItems) {
1731
1882
  const productId = Number(prefillItem.product_id);
@@ -1742,32 +1893,39 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
1742
1893
  });
1743
1894
  if (productIndex === -1) {
1744
1895
  const sellingPrice = (0, import_utils.toPriceString)((sourceItem == null ? void 0 : sourceItem.price) ?? (sourceItem == null ? void 0 : sourceItem.selling_price), "0.00");
1745
- tempOrder.products.push(
1746
- (0, import_utils.normalizeOrderProduct)({
1747
- product_id: productId,
1748
- product_variant_id: productVariantId,
1749
- num: targetQuantity,
1750
- selling_price: sellingPrice,
1751
- original_price: sellingPrice,
1752
- metadata: { item_rule_prefill: true, item_rule_id: prefillItem.ruleId },
1753
- _origin: { ...sourceItem || {}, item_rule_prefill: true, item_rule_id: prefillItem.ruleId }
1754
- })
1755
- );
1896
+ const origin = { ...sourceItem || {}, item_rule_prefill: true, item_rule_id: prefillItem.ruleId };
1897
+ const product = (0, import_utils.normalizeOrderProduct)({
1898
+ product_id: productId,
1899
+ product_variant_id: productVariantId,
1900
+ num: targetQuantity,
1901
+ selling_price: sellingPrice,
1902
+ original_price: sellingPrice,
1903
+ metadata: { item_rule_prefill: true, item_rule_id: prefillItem.ruleId },
1904
+ _origin: origin
1905
+ });
1906
+ const productUid = String(((_a = product.metadata) == null ? void 0 : _a.unique_identification_number) || "");
1907
+ this.attachProductOriginToTempOrder(tempOrder, productUid, origin);
1908
+ tempOrder.products.push(product);
1756
1909
  hasChanges = true;
1757
1910
  continue;
1758
1911
  }
1759
1912
  const targetProduct = tempOrder.products[productIndex];
1913
+ const previousOrigin = this.readProductOriginFromTempOrder(tempOrder, targetProduct);
1914
+ const nextOrigin = sourceItem ? { ...previousOrigin || {}, ...sourceItem } : previousOrigin;
1760
1915
  const existedQuantity = (0, import_utils.toNonNegativeInt)(targetProduct.num);
1761
1916
  const delta = targetQuantity - existedQuantity;
1762
1917
  const nextProduct = {
1763
1918
  ...targetProduct,
1764
1919
  ...delta > 0 ? { num: (0, import_utils.getSafeProductNum)(existedQuantity + delta) } : {},
1765
- metadata: { ...targetProduct.metadata || {}, item_rule_prefill: true, item_rule_id: prefillItem.ruleId },
1766
- _origin: sourceItem ? { ...targetProduct._origin || {}, ...sourceItem } : targetProduct._origin
1920
+ metadata: { ...targetProduct.metadata || {}, item_rule_prefill: true, item_rule_id: prefillItem.ruleId }
1767
1921
  };
1768
1922
  if (delta > 0 || Boolean(
1769
- sourceItem && (!targetProduct._origin || ((_a = targetProduct._origin) == null ? void 0 : _a.price) !== (sourceItem == null ? void 0 : sourceItem.price))
1923
+ sourceItem && (!previousOrigin || (previousOrigin == null ? void 0 : previousOrigin.price) !== (sourceItem == null ? void 0 : sourceItem.price))
1770
1924
  )) {
1925
+ const productUid = String(
1926
+ ((_b = nextProduct.metadata) == null ? void 0 : _b.unique_identification_number) || ""
1927
+ );
1928
+ this.attachProductOriginToTempOrder(tempOrder, productUid, nextOrigin);
1771
1929
  tempOrder.products[productIndex] = nextProduct;
1772
1930
  hasChanges = true;
1773
1931
  }
@@ -1795,7 +1953,7 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
1795
1953
  if (!strategyConfigs.length)
1796
1954
  return { passed: true, failures: [] };
1797
1955
  const businessData = (0, import_utils.buildItemRuleBusinessData)({
1798
- tempOrder: this.ensureTempOrder(),
1956
+ tempOrder: this.ensureVenueTempOrder(),
1799
1957
  runtimeConfig: this.getItemRuleRuntimeConfig(),
1800
1958
  itemRuleConfigs: this.itemRuleConfigs
1801
1959
  });
@@ -1907,6 +2065,60 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
1907
2065
  this.writeUIStateBucket(bucket);
1908
2066
  }
1909
2067
  }
2068
+ setBookingHolder(bookingUid, holder) {
2069
+ var _a, _b, _c, _d;
2070
+ if (!this.store.order)
2071
+ return;
2072
+ const tempOrder = this.store.order.ensureTempOrder();
2073
+ const booking = (_a = tempOrder.bookings) == null ? void 0 : _a.find(
2074
+ (b) => {
2075
+ var _a2;
2076
+ return ((_a2 = b.metadata) == null ? void 0 : _a2.unique_identification_number) === bookingUid;
2077
+ }
2078
+ );
2079
+ if (booking) {
2080
+ booking.holder = holder;
2081
+ }
2082
+ for (const product of tempOrder.products) {
2083
+ const runtimeProduct = product;
2084
+ const productBookingUid = ((_b = runtimeProduct.metadata) == null ? void 0 : _b.booking_uid) ?? ((_d = (_c = runtimeProduct._origin) == null ? void 0 : _c.product) == null ? void 0 : _d.bookingUuid);
2085
+ if (String(productBookingUid) !== String(bookingUid))
2086
+ continue;
2087
+ const origin = runtimeProduct._origin && typeof runtimeProduct._origin === "object" ? runtimeProduct._origin : {};
2088
+ origin.holder = holder;
2089
+ runtimeProduct._origin = origin;
2090
+ }
2091
+ this.store.order.notifyTempOrderChanged();
2092
+ }
2093
+ /**
2094
+ * 获取 holder 表单 map
2095
+ */
2096
+ getHolderFormMap() {
2097
+ if (!this.store.holder)
2098
+ throw new Error("[VenueBooking] holder 模块未初始化");
2099
+ return this.store.holder.getHolderFormMap();
2100
+ }
2101
+ /**
2102
+ * UI 层触发:按当前 holderMap 批量刷新所有表单的 records
2103
+ */
2104
+ async refreshAllHolderFormRecords(params) {
2105
+ if (!this.store.holder)
2106
+ throw new Error("[VenueBooking] holder 模块未初始化");
2107
+ const customer_id = (params == null ? void 0 : params.customer_id) ?? this.resolveHolderCustomerId();
2108
+ return this.store.holder.refreshAllFormRecords({
2109
+ ...params,
2110
+ customer_id,
2111
+ useCache: (params == null ? void 0 : params.useCache) ?? false
2112
+ });
2113
+ }
2114
+ /**
2115
+ * 添加表单记录
2116
+ */
2117
+ appendFormRecord(params) {
2118
+ if (!this.store.holder)
2119
+ throw new Error("[VenueBooking] holder 模块未初始化");
2120
+ return this.store.holder.appendFormRecord(params);
2121
+ }
1910
2122
  // ─── OpenData 可用性 ───
1911
2123
  async checkOpenDataAvailability() {
1912
2124
  if (!this.store.openData)
@@ -1,5 +1,6 @@
1
1
  import { OrderModule, ProductList, SalesSummaryModule, ScanOrderLogInput, ScanOrderLoggerModule, ScanOrderLoggerProviderConfig, ScanOrderLoggerProviderType, DateModule, ScheduleModule, QuotationModule, OpenDataModule } from '../../modules';
2
2
  import type { QuantityCheckResult, QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
3
+ import { HolderModule } from '../../modules/Holder';
3
4
  export type { ScanOrderOrderProductIdentity, ScanOrderOrderProduct, ScanOrderSubmitProduct, ScanOrderSummary, ScanOrderTempOrder, ScanOrderSubmitPayload, } from '../ScanOrder/types';
4
5
  export declare enum VenueBookingHooks {
5
6
  onInited = "venueBooking:onInited",
@@ -96,6 +97,7 @@ export interface VenueResourceRawData {
96
97
  export interface ResourceProductMapping {
97
98
  productId: number;
98
99
  productTitle: string;
100
+ formName?: string;
99
101
  resourceName: string;
100
102
  formId: number | string;
101
103
  price: string;
@@ -144,6 +146,7 @@ export interface VenueBookingState {
144
146
  passed: boolean | null;
145
147
  failures: QuantityCheckResult[];
146
148
  };
149
+ holder?: HolderModule;
147
150
  }
148
151
  export interface VenueBookingLoggerRuntimeConfig {
149
152
  provider?: ScanOrderLoggerProviderType;
@@ -69,6 +69,7 @@ function buildResourceProductMap(products) {
69
69
  const mapping = {
70
70
  productId: product.id,
71
71
  productTitle: product.title,
72
+ formName: resource.title,
72
73
  resourceName: resource.title,
73
74
  formId: resource.id,
74
75
  price: product.price || "0.00",