@pisell/pisellos 2.3.39 → 2.3.41

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 (226) hide show
  1. package/dist/core/index.d.ts +2 -0
  2. package/dist/core/index.js +7 -0
  3. package/dist/model/strategy/adapter/promotion/adapter.d.ts +4 -0
  4. package/dist/model/strategy/adapter/promotion/adapter.js +23 -0
  5. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
  6. package/dist/model/strategy/adapter/promotion/evaluator.js +279 -6
  7. package/dist/model/strategy/adapter/promotion/examples.d.ts +86 -0
  8. package/dist/model/strategy/adapter/promotion/examples.js +99 -0
  9. package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
  10. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  11. package/dist/model/strategy/adapter/promotion/type.d.ts +90 -2
  12. package/dist/model/strategy/adapter/promotion/type.js +45 -0
  13. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -3
  14. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +6 -3
  15. package/dist/modules/Discount/index.d.ts +0 -1
  16. package/dist/modules/Discount/index.js +11 -40
  17. package/dist/modules/Discount/types.d.ts +0 -1
  18. package/dist/modules/OpenData/index.d.ts +2 -0
  19. package/dist/modules/OpenData/index.js +10 -2
  20. package/dist/modules/Order/index.d.ts +29 -12
  21. package/dist/modules/Order/index.js +750 -509
  22. package/dist/modules/Order/payment-utils.d.ts +26 -0
  23. package/dist/modules/Order/payment-utils.js +225 -0
  24. package/dist/modules/Order/types.d.ts +33 -10
  25. package/dist/modules/Order/utils/orderCollectionIdentity.js +7 -2
  26. package/dist/modules/Order/utils.d.ts +0 -10
  27. package/dist/modules/Order/utils.js +13 -41
  28. package/dist/modules/Payment/index.d.ts +2 -0
  29. package/dist/modules/Payment/index.js +79 -50
  30. package/dist/modules/Payment/types.d.ts +99 -28
  31. package/dist/modules/Payment/types.js +20 -3
  32. package/dist/modules/Payment/walletpass.d.ts +25 -1
  33. package/dist/modules/Payment/walletpass.js +707 -157
  34. package/dist/modules/Product/types.d.ts +0 -1
  35. package/dist/modules/ProductList/index.js +14 -33
  36. package/dist/modules/Quotation/index.d.ts +1 -1
  37. package/dist/modules/Quotation/index.js +2 -2
  38. package/dist/modules/Rules/index.d.ts +1 -0
  39. package/dist/modules/Rules/index.js +89 -96
  40. package/dist/modules/SalesSummary/index.js +13 -12
  41. package/dist/modules/ScanOrderLogger/index.d.ts +0 -2
  42. package/dist/modules/ScanOrderLogger/index.js +2 -15
  43. package/dist/modules/ScanOrderLogger/providers/feishu.js +27 -45
  44. package/dist/modules/ScanOrderLogger/types.d.ts +0 -1
  45. package/dist/modules/Schedule/index.d.ts +1 -3
  46. package/dist/modules/Schedule/index.js +16 -21
  47. package/dist/modules/Summary/utils.js +13 -38
  48. package/dist/modules/index.d.ts +0 -2
  49. package/dist/modules/index.js +1 -3
  50. package/dist/plugins/window.d.ts +0 -1
  51. package/dist/server/index.d.ts +16 -14
  52. package/dist/server/index.js +1925 -1143
  53. package/dist/server/modules/order/index.d.ts +54 -4
  54. package/dist/server/modules/order/index.js +1600 -700
  55. package/dist/server/modules/order/types.d.ts +11 -3
  56. package/dist/server/modules/order/types.js +1 -1
  57. package/dist/solution/BaseSales/index.d.ts +109 -20
  58. package/dist/solution/BaseSales/index.js +1800 -480
  59. package/dist/solution/BaseSales/types.d.ts +52 -0
  60. package/dist/solution/BaseSales/types.js +2 -1
  61. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
  62. package/dist/solution/BaseSales/utils/cartPromotion.js +90 -31
  63. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
  64. package/dist/solution/BookingByStep/index.d.ts +2 -17
  65. package/dist/solution/BookingByStep/index.js +215 -294
  66. package/dist/solution/BookingByStep/types.d.ts +1 -2
  67. package/dist/solution/BookingByStep/types.js +1 -3
  68. package/dist/solution/BookingByStep/utils/capacity.js +1 -17
  69. package/dist/solution/BookingByStep/utils/timeslots.d.ts +1 -3
  70. package/dist/solution/BookingByStep/utils/timeslots.js +12 -19
  71. package/dist/solution/BookingTicket/index.d.ts +7 -3
  72. package/dist/solution/BookingTicket/index.js +132 -49
  73. package/dist/solution/BookingTicket/utils/addProductDecision.js +6 -0
  74. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
  75. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +172 -82
  76. package/dist/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
  77. package/dist/solution/BookingTicket/utils/weighingProductSku.js +45 -0
  78. package/dist/solution/Sales/index.d.ts +1 -0
  79. package/dist/solution/Sales/index.js +10 -2
  80. package/dist/solution/ScanOrder/index.d.ts +14 -26
  81. package/dist/solution/ScanOrder/index.js +756 -1148
  82. package/dist/solution/ScanOrder/types.d.ts +1 -21
  83. package/dist/solution/ScanOrder/utils.d.ts +0 -8
  84. package/dist/solution/ScanOrder/utils.js +25 -66
  85. package/dist/solution/ShopDiscount/index.d.ts +0 -1
  86. package/dist/solution/ShopDiscount/index.js +87 -125
  87. package/dist/solution/VenueBooking/index.d.ts +11 -39
  88. package/dist/solution/VenueBooking/index.js +860 -1176
  89. package/dist/solution/VenueBooking/types.d.ts +0 -3
  90. package/dist/solution/VenueBooking/utils/resource.js +0 -1
  91. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  92. package/dist/solution/VenueBooking/utils/slotMerge.js +5 -10
  93. package/dist/solution/index.d.ts +0 -1
  94. package/dist/solution/index.js +1 -2
  95. package/dist/types/index.d.ts +1 -1
  96. package/dist/utils/payment-number.d.ts +9 -0
  97. package/dist/utils/payment-number.js +69 -0
  98. package/lib/core/index.d.ts +2 -0
  99. package/lib/core/index.js +4 -0
  100. package/lib/model/strategy/adapter/promotion/adapter.d.ts +4 -0
  101. package/lib/model/strategy/adapter/promotion/adapter.js +20 -0
  102. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
  103. package/lib/model/strategy/adapter/promotion/evaluator.js +235 -0
  104. package/lib/model/strategy/adapter/promotion/examples.d.ts +86 -0
  105. package/lib/model/strategy/adapter/promotion/examples.js +91 -0
  106. package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
  107. package/lib/model/strategy/adapter/promotion/index.js +51 -0
  108. package/lib/model/strategy/adapter/promotion/type.d.ts +90 -2
  109. package/lib/model/strategy/adapter/promotion/type.js +2 -0
  110. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +2 -1
  111. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
  112. package/lib/modules/Discount/index.d.ts +0 -1
  113. package/lib/modules/Discount/index.js +0 -9
  114. package/lib/modules/Discount/types.d.ts +0 -1
  115. package/lib/modules/OpenData/index.d.ts +2 -0
  116. package/lib/modules/OpenData/index.js +6 -1
  117. package/lib/modules/Order/index.d.ts +29 -12
  118. package/lib/modules/Order/index.js +196 -86
  119. package/lib/modules/Order/payment-utils.d.ts +26 -0
  120. package/lib/modules/Order/payment-utils.js +224 -0
  121. package/lib/modules/Order/types.d.ts +33 -10
  122. package/lib/modules/Order/utils/orderCollectionIdentity.js +3 -0
  123. package/lib/modules/Order/utils.d.ts +0 -10
  124. package/lib/modules/Order/utils.js +16 -40
  125. package/lib/modules/Payment/index.d.ts +2 -0
  126. package/lib/modules/Payment/index.js +34 -13
  127. package/lib/modules/Payment/types.d.ts +99 -28
  128. package/lib/modules/Payment/types.js +4 -3
  129. package/lib/modules/Payment/walletpass.d.ts +25 -1
  130. package/lib/modules/Payment/walletpass.js +470 -21
  131. package/lib/modules/Product/types.d.ts +0 -1
  132. package/lib/modules/ProductList/index.js +31 -40
  133. package/lib/modules/Quotation/index.d.ts +1 -1
  134. package/lib/modules/Quotation/index.js +2 -2
  135. package/lib/modules/Rules/index.d.ts +1 -0
  136. package/lib/modules/Rules/index.js +47 -40
  137. package/lib/modules/SalesSummary/index.js +7 -6
  138. package/lib/modules/ScanOrderLogger/index.d.ts +0 -2
  139. package/lib/modules/ScanOrderLogger/index.js +1 -13
  140. package/lib/modules/ScanOrderLogger/providers/feishu.js +6 -15
  141. package/lib/modules/ScanOrderLogger/types.d.ts +0 -1
  142. package/lib/modules/Schedule/index.d.ts +1 -3
  143. package/lib/modules/Schedule/index.js +8 -10
  144. package/lib/modules/Summary/utils.js +1 -21
  145. package/lib/modules/index.d.ts +0 -2
  146. package/lib/modules/index.js +1 -5
  147. package/lib/plugins/window.d.ts +0 -1
  148. package/lib/server/index.d.ts +16 -14
  149. package/lib/server/index.js +675 -83
  150. package/lib/server/modules/order/index.d.ts +54 -4
  151. package/lib/server/modules/order/index.js +679 -66
  152. package/lib/server/modules/order/types.d.ts +11 -3
  153. package/lib/solution/BaseSales/index.d.ts +109 -20
  154. package/lib/solution/BaseSales/index.js +883 -70
  155. package/lib/solution/BaseSales/types.d.ts +52 -0
  156. package/lib/solution/BaseSales/types.js +2 -1
  157. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
  158. package/lib/solution/BaseSales/utils/cartPromotion.js +63 -12
  159. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
  160. package/lib/solution/BookingByStep/index.d.ts +2 -17
  161. package/lib/solution/BookingByStep/index.js +18 -60
  162. package/lib/solution/BookingByStep/types.d.ts +1 -2
  163. package/lib/solution/BookingByStep/types.js +0 -5
  164. package/lib/solution/BookingByStep/utils/capacity.js +1 -20
  165. package/lib/solution/BookingByStep/utils/timeslots.d.ts +1 -3
  166. package/lib/solution/BookingByStep/utils/timeslots.js +11 -19
  167. package/lib/solution/BookingTicket/index.d.ts +7 -3
  168. package/lib/solution/BookingTicket/index.js +62 -9
  169. package/lib/solution/BookingTicket/utils/addProductDecision.js +4 -0
  170. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
  171. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +36 -4
  172. package/lib/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
  173. package/lib/solution/BookingTicket/utils/weighingProductSku.js +63 -0
  174. package/lib/solution/Sales/index.d.ts +1 -0
  175. package/lib/solution/Sales/index.js +5 -3
  176. package/lib/solution/ScanOrder/index.d.ts +14 -26
  177. package/lib/solution/ScanOrder/index.js +190 -449
  178. package/lib/solution/ScanOrder/types.d.ts +1 -21
  179. package/lib/solution/ScanOrder/utils.d.ts +0 -8
  180. package/lib/solution/ScanOrder/utils.js +0 -31
  181. package/lib/solution/ShopDiscount/index.d.ts +0 -1
  182. package/lib/solution/ShopDiscount/index.js +0 -14
  183. package/lib/solution/VenueBooking/index.d.ts +11 -39
  184. package/lib/solution/VenueBooking/index.js +123 -328
  185. package/lib/solution/VenueBooking/types.d.ts +0 -3
  186. package/lib/solution/VenueBooking/utils/resource.js +0 -1
  187. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  188. package/lib/solution/VenueBooking/utils/slotMerge.js +4 -6
  189. package/lib/solution/index.d.ts +0 -1
  190. package/lib/solution/index.js +1 -3
  191. package/lib/types/index.d.ts +1 -1
  192. package/lib/utils/payment-number.d.ts +9 -0
  193. package/lib/utils/payment-number.js +64 -0
  194. package/package.json +1 -1
  195. package/dist/modules/Holder/index.d.ts +0 -48
  196. package/dist/modules/Holder/index.js +0 -640
  197. package/dist/modules/Holder/types.d.ts +0 -123
  198. package/dist/modules/Holder/types.js +0 -1
  199. package/dist/modules/Holder/utils.d.ts +0 -13
  200. package/dist/modules/Holder/utils.js +0 -34
  201. package/dist/modules/ResourcePlanner/index.d.ts +0 -24
  202. package/dist/modules/ResourcePlanner/index.js +0 -181
  203. package/dist/modules/ResourcePlanner/planner.d.ts +0 -14
  204. package/dist/modules/ResourcePlanner/planner.js +0 -1069
  205. package/dist/modules/ResourcePlanner/types.d.ts +0 -227
  206. package/dist/modules/ResourcePlanner/types.js +0 -1
  207. package/dist/solution/UnifiedBookingSales/index.d.ts +0 -183
  208. package/dist/solution/UnifiedBookingSales/index.js +0 -1871
  209. package/dist/solution/UnifiedBookingSales/types.d.ts +0 -143
  210. package/dist/solution/UnifiedBookingSales/types.js +0 -11
  211. package/lib/modules/Holder/index.d.ts +0 -48
  212. package/lib/modules/Holder/index.js +0 -402
  213. package/lib/modules/Holder/types.d.ts +0 -123
  214. package/lib/modules/Holder/types.js +0 -17
  215. package/lib/modules/Holder/utils.d.ts +0 -13
  216. package/lib/modules/Holder/utils.js +0 -71
  217. package/lib/modules/ResourcePlanner/index.d.ts +0 -24
  218. package/lib/modules/ResourcePlanner/index.js +0 -148
  219. package/lib/modules/ResourcePlanner/planner.d.ts +0 -14
  220. package/lib/modules/ResourcePlanner/planner.js +0 -933
  221. package/lib/modules/ResourcePlanner/types.d.ts +0 -227
  222. package/lib/modules/ResourcePlanner/types.js +0 -17
  223. package/lib/solution/UnifiedBookingSales/index.d.ts +0 -183
  224. package/lib/solution/UnifiedBookingSales/index.js +0 -1076
  225. package/lib/solution/UnifiedBookingSales/types.d.ts +0 -143
  226. package/lib/solution/UnifiedBookingSales/types.js +0 -33
@@ -33,7 +33,7 @@ __export(VenueBooking_exports, {
33
33
  VenueBookingImpl: () => VenueBookingImpl
34
34
  });
35
35
  module.exports = __toCommonJS(VenueBooking_exports);
36
- var import_BaseSales = require("../BaseSales");
36
+ var import_BaseModule = require("../../modules/BaseModule");
37
37
  var import_types = require("./types");
38
38
  var import_utils = require("./utils");
39
39
  var import_types2 = require("../BookingByStep/types");
@@ -54,8 +54,6 @@ 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");
59
57
  __reExport(VenueBooking_exports, require("./types"), module.exports);
60
58
  var OPEN_DATA_SECTION_CODES = [
61
59
  "basic",
@@ -67,6 +65,10 @@ var OPEN_DATA_SECTION_CODES = [
67
65
  "workflow",
68
66
  "checkout"
69
67
  ];
68
+ function isItemRewardProductDiscount(discount) {
69
+ var _a, _b;
70
+ return (discount == null ? void 0 : discount.type) === "product" && ((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.source) === "promotion" && ((_b = discount == null ? void 0 : discount.metadata) == null ? void 0 : _b.actionType) === "ITEM_REWARD";
71
+ }
70
72
  function cloneCustomDepositData(customDepositData) {
71
73
  if (!customDepositData || typeof customDepositData !== "object")
72
74
  return void 0;
@@ -77,7 +79,7 @@ function cloneCustomDepositData(customDepositData) {
77
79
  deposit_policy_data: Array.isArray(customDepositData.deposit_policy_data) ? [...customDepositData.deposit_policy_data] : []
78
80
  };
79
81
  }
80
- var _VenueBookingImpl = class extends import_BaseSales.BaseSalesImpl {
82
+ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
81
83
  constructor(name, version) {
82
84
  super(name, version);
83
85
  this.defaultName = "venueBooking";
@@ -227,79 +229,6 @@ var _VenueBookingImpl = class extends import_BaseSales.BaseSalesImpl {
227
229
  }
228
230
  });
229
231
  }
230
- getRegisteredModuleNames() {
231
- return [
232
- "scanOrderLogger",
233
- "products",
234
- "order",
235
- "salesSummary",
236
- "venueProducts",
237
- "addonProducts",
238
- "date",
239
- "schedule",
240
- "quotation",
241
- "openData"
242
- ];
243
- }
244
- createSubModule(moduleName) {
245
- switch (moduleName) {
246
- case "scanOrderLogger":
247
- return (0, import_types2.createModule)("scanOrderLogger", this.name);
248
- case "venueProducts":
249
- return new import_ProductList.ProductList(`${this.name}_venueProducts`);
250
- case "addonProducts":
251
- return new import_ProductList.ProductList(`${this.name}_addonProducts`);
252
- case "date":
253
- return new import_Date.DateModule(`${this.name}_date`);
254
- case "openData":
255
- return new import_OpenData.OpenDataModule(`${this.name}_openData`);
256
- default:
257
- return super.createSubModule(moduleName);
258
- }
259
- }
260
- attachProductOriginToTempOrder(tempOrder, productUid, origin) {
261
- var _a, _b, _c;
262
- if (!productUid || !origin)
263
- return;
264
- tempOrder._extend = {
265
- ...tempOrder._extend || {},
266
- productsByUid: {
267
- ...((_a = tempOrder._extend) == null ? void 0 : _a.productsByUid) || {},
268
- [productUid]: {
269
- ...((_c = (_b = tempOrder._extend) == null ? void 0 : _b.productsByUid) == null ? void 0 : _c[productUid]) || {},
270
- origin
271
- }
272
- }
273
- };
274
- }
275
- readProductOriginFromTempOrder(tempOrder, product) {
276
- var _a, _b, _c, _d;
277
- const uid = ((_a = product.metadata) == null ? void 0 : _a.unique_identification_number) || product.identity_key;
278
- if (uid && ((_d = (_c = (_b = tempOrder._extend) == null ? void 0 : _b.productsByUid) == null ? void 0 : _c[uid]) == null ? void 0 : _d.origin)) {
279
- return tempOrder._extend.productsByUid[uid].origin;
280
- }
281
- return product._origin;
282
- }
283
- normalizeVenueProductTitle(value) {
284
- if (typeof value === "string") {
285
- const text = value.trim();
286
- return text ? { auto: text } : void 0;
287
- }
288
- if (!value || typeof value !== "object" || Array.isArray(value))
289
- return void 0;
290
- const source = value;
291
- const normalized = {};
292
- Object.entries(source).forEach(([key, text]) => {
293
- if (typeof text === "string")
294
- normalized[key] = text;
295
- });
296
- if (!normalized.auto) {
297
- const fallback = normalized.original || normalized.en || normalized["zh-CN"] || normalized["zh-HK"];
298
- if (fallback)
299
- normalized.auto = fallback;
300
- }
301
- return Object.values(normalized).some((text) => String(text || "").trim()) ? normalized : void 0;
302
- }
303
232
  normalizeCustomerId(value) {
304
233
  const customerId = Number(value);
305
234
  if (!Number.isFinite(customerId) || customerId <= 0)
@@ -328,42 +257,6 @@ var _VenueBookingImpl = class extends import_BaseSales.BaseSalesImpl {
328
257
  }
329
258
  return null;
330
259
  }
331
- resolveHolderCustomerId() {
332
- var _a, _b;
333
- const customer = JSON.parse(((_b = (_a = this.window) == null ? void 0 : _a.getLocalStorage) == null ? void 0 : _b.call(_a, "customer")) || "{}");
334
- if (customer == null ? void 0 : customer.id)
335
- return Number(customer.id);
336
- return void 0;
337
- }
338
- /**
339
- * 按商品 holder_config 预加载表单数据到 holderMap。
340
- * appointment_booking 在加购时触发;venueBooking 在商品加载后预加载,避免 getHolderFormMap 为空。
341
- */
342
- async preloadHolderForms(products) {
343
- var _a, _b, _c, _d;
344
- if (!this.store.holder || !products.length)
345
- return;
346
- const seenFormIds = /* @__PURE__ */ new Set();
347
- for (const item of products) {
348
- const holderConfig = (0, import_utils4.getProductHolderConfig)((_a = item == null ? void 0 : item._origin) == null ? void 0 : _a.product);
349
- if (!holderConfig)
350
- continue;
351
- const formId = (0, import_utils4.getFormIdFromHolderConfig)(holderConfig);
352
- if (seenFormIds.has(formId))
353
- continue;
354
- seenFormIds.add(formId);
355
- try {
356
- await this.store.holder.ensureFormByProduct({
357
- product: ((_b = item == null ? void 0 : item._origin) == null ? void 0 : _b.product) || {},
358
- customer_id: this.resolveHolderCustomerId(),
359
- shop_id: (_d = (_c = item == null ? void 0 : item._origin) == null ? void 0 : _c.product) == null ? void 0 : _d.shop_id,
360
- useCache: true
361
- });
362
- } catch (error) {
363
- console.error("[VenueBooking] 预加载 holder 表单失败", { formId, error });
364
- }
365
- }
366
- }
367
260
  clearLoginEffectListeners() {
368
261
  for (const dispose of this.loginEffectDisposers) {
369
262
  dispose();
@@ -410,12 +303,6 @@ var _VenueBookingImpl = class extends import_BaseSales.BaseSalesImpl {
410
303
  this.customerLoginRefreshIdInFlight = params.customerId;
411
304
  const refreshTask = (async () => {
412
305
  var _a;
413
- if (this.store.holder) {
414
- await this.store.holder.refreshAllFormRecords({
415
- customer_id: params.customerId,
416
- useCache: false
417
- });
418
- }
419
306
  if (this.store.quotation) {
420
307
  await this.store.quotation.loadQuotations({
421
308
  channel: (_a = this.otherParams) == null ? void 0 : _a.channel
@@ -443,8 +330,10 @@ var _VenueBookingImpl = class extends import_BaseSales.BaseSalesImpl {
443
330
  }
444
331
  }
445
332
  async initialize(core, options = {}) {
446
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
333
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
447
334
  this.logMethodStart("initialize");
335
+ this.core = core;
336
+ this.initializeOptions = options || {};
448
337
  this.store = { ...this.store, ...options.store };
449
338
  this.store.entryContext = ((_a = options.otherParams) == null ? void 0 : _a.entryContext) || this.store.entryContext;
450
339
  this.store.status = "initializing";
@@ -466,20 +355,15 @@ var _VenueBookingImpl = class extends import_BaseSales.BaseSalesImpl {
466
355
  passed: null,
467
356
  failures: []
468
357
  };
469
- await super.initialize(core, options);
470
- if (this.store.scanOrderLogger) {
471
- this.store.scanOrderLogger.setProvider(
472
- ((_f = this.otherParams) == null ? void 0 : _f.loggerProvider) || "feishu"
473
- );
474
- this.store.scanOrderLogger.setProviderConfig(
475
- ((_g = this.otherParams) == null ? void 0 : _g.loggerConfig) || {
476
- feishu: {
477
- webhook: "https://open.feishu.cn/open-apis/bot/v2/hook/8f069b14-9d39-4728-8f78-b56f393bfde8",
478
- errorHook: "https://open.feishu.cn/open-apis/bot/v2/hook/bdefae5e-f233-4705-8688-946887d9543d"
479
- }
480
- }
481
- );
482
- this.store.scanOrderLogger.setContext(this.getLoggerContext());
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 插件支持");
483
367
  }
484
368
  const baseModules = [
485
369
  "scanOrderLogger",
@@ -497,10 +381,10 @@ var _VenueBookingImpl = class extends import_BaseSales.BaseSalesImpl {
497
381
  } : {};
498
382
  const loggerProvider = ((_c2 = this.otherParams) == null ? void 0 : _c2.loggerProvider) || "feishu";
499
383
  const loggerConfig = ((_d2 = this.otherParams) == null ? void 0 : _d2.loggerConfig) || {
500
- // feishu: {
501
- // webhook: 'https://open.feishu.cn/open-apis/bot/v2/hook/8f069b14-9d39-4728-8f78-b56f393bfde8',
502
- // errorHook: 'https://open.feishu.cn/open-apis/bot/v2/hook/bdefae5e-f233-4705-8688-946887d9543d',
503
- // },
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
388
  };
505
389
  this.core.registerModule(targetModule, {
506
390
  initialState,
@@ -567,43 +451,24 @@ var _VenueBookingImpl = class extends import_BaseSales.BaseSalesImpl {
567
451
  otherParams: {
568
452
  ...this.otherParams,
569
453
  fatherModule: this.name,
570
- openCache: !!((_h = this.otherParams) == null ? void 0 : _h.cacheId),
571
- cacheId: (_i = this.otherParams) == null ? void 0 : _i.cacheId
454
+ openCache: !!((_f = this.otherParams) == null ? void 0 : _f.cacheId),
455
+ cacheId: (_g = this.otherParams) == null ? void 0 : _g.cacheId
572
456
  }
573
457
  });
574
- let holderCacheState;
575
- if ((_j = this.otherParams) == null ? void 0 : _j.cacheId) {
576
- const sessionData = this.window.sessionStorage.getItem(this.name);
577
- if (sessionData) {
578
- try {
579
- const data = JSON.parse(sessionData);
580
- holderCacheState = (_k = data[this.otherParams.cacheId]) == null ? void 0 : _k[`${this.name}_holder`];
581
- } catch {
582
- }
583
- }
458
+ if (this.store.scanOrderLogger) {
459
+ this.store.scanOrderLogger.setContext(this.getLoggerContext());
584
460
  }
585
- const holderModule = new import_Holder.HolderModule(`${this.name}_holder`);
586
- this.store.holder = holderModule;
587
- this.core.registerModule(holderModule, {
588
- initialState: holderCacheState,
589
- otherParams: {
590
- ...this.otherParams,
591
- fatherModule: this.name,
592
- openCache: !!((_l = this.otherParams) == null ? void 0 : _l.cacheId),
593
- cacheId: (_m = this.otherParams) == null ? void 0 : _m.cacheId
594
- }
595
- });
596
461
  this.registerCustomerLoginListeners();
597
462
  console.log("[VenueBooking] 初始化开始");
598
463
  try {
599
- await ((_n = this.store.order) == null ? void 0 : _n.recalculateSummary({ createIfMissing: false }));
600
- (_o = this.store.order) == null ? void 0 : _o.persistTempOrder();
464
+ await ((_h = this.store.order) == null ? void 0 : _h.recalculateSummary({ createIfMissing: false }));
465
+ (_i = this.store.order) == null ? void 0 : _i.persistTempOrder();
601
466
  await this.loadRuntimeConfigs();
602
467
  if (this.store.schedule) {
603
468
  await this.store.schedule.loadAllSchedule();
604
469
  this.injectScheduleResolverToQuotation();
605
- (_q = this.store.quotation) == null ? void 0 : _q.loadQuotations({
606
- channel: (_p = this.otherParams) == null ? void 0 : _p.channel
470
+ (_k = this.store.quotation) == null ? void 0 : _k.loadQuotations({
471
+ channel: (_j = this.otherParams) == null ? void 0 : _j.channel
607
472
  });
608
473
  }
609
474
  await this.refreshItemRuleQuantityLimits();
@@ -690,7 +555,7 @@ var _VenueBookingImpl = class extends import_BaseSales.BaseSalesImpl {
690
555
  return this.loadAllProductsInFlight;
691
556
  }
692
557
  async _doLoadAllProducts() {
693
- var _a, _b, _c, _d, _e;
558
+ var _a, _b, _c;
694
559
  this.logMethodStart("loadAllProducts");
695
560
  try {
696
561
  if (!this.store.venueProducts)
@@ -719,10 +584,6 @@ var _VenueBookingImpl = class extends import_BaseSales.BaseSalesImpl {
719
584
  }
720
585
  this.store.addonProducts.addProduct(addonList);
721
586
  this.resourceProductMap = (0, import_resource.buildResourceProductMap)(venueList);
722
- if (this.store.order) {
723
- const products = ((_e = (_d = this.store.order) == null ? void 0 : _d.getOrderProducts) == null ? void 0 : _e.call(_d)) || [];
724
- await this.preloadHolderForms(products);
725
- }
726
587
  this.productsLoaded = true;
727
588
  this.logMethodSuccess("loadAllProducts", {
728
589
  total: list.length,
@@ -1115,7 +976,6 @@ var _VenueBookingImpl = class extends import_BaseSales.BaseSalesImpl {
1115
976
  * 同一场地下不同商品互不干扰,各自单独 reconcile。
1116
977
  */
1117
978
  async reconcileOrderForResourceProduct(resourceId, productId, slots) {
1118
- var _a, _b;
1119
979
  const mappings = this.resourceProductMap.get(resourceId);
1120
980
  if (!mappings || !mappings.length || !this.store.order)
1121
981
  return;
@@ -1129,10 +989,10 @@ var _VenueBookingImpl = class extends import_BaseSales.BaseSalesImpl {
1129
989
  );
1130
990
  tempOrder.bookings = (tempOrder.bookings || []).filter(
1131
991
  (b) => {
1132
- var _a2, _b2, _c, _d;
1133
- if (!((_a2 = b.metadata) == null ? void 0 : _a2.venue_booking))
992
+ var _a, _b, _c, _d;
993
+ if (!((_a = b.metadata) == null ? void 0 : _a.venue_booking))
1134
994
  return true;
1135
- if (String((_b2 = b.metadata) == null ? void 0 : _b2.resource_id) !== String(resourceId))
995
+ if (String((_b = b.metadata) == null ? void 0 : _b.resource_id) !== String(resourceId))
1136
996
  return true;
1137
997
  const bookingProductId = ((_c = b.metadata) == null ? void 0 : _c.product_id) ?? ((_d = b == null ? void 0 : b.product) == null ? void 0 : _d.product_id);
1138
998
  if (bookingProductId == null)
@@ -1161,7 +1021,6 @@ var _VenueBookingImpl = class extends import_BaseSales.BaseSalesImpl {
1161
1021
  const endMoment = (0, import_dayjs.default)(group.endTime, "YYYY-MM-DD HH:mm");
1162
1022
  const duration = endMoment.diff(startMoment, "minute");
1163
1023
  const customDepositData = cloneCustomDepositData(venueProduct == null ? void 0 : venueProduct.custom_deposit_data);
1164
- const productTitle = this.normalizeVenueProductTitle(venueProduct == null ? void 0 : venueProduct.product_title) || this.normalizeVenueProductTitle(venueProduct == null ? void 0 : venueProduct.title) || this.normalizeVenueProductTitle(mapping.productTitle);
1165
1024
  const resourceEntry = {
1166
1025
  relation_type: "form",
1167
1026
  like_status: "common",
@@ -1184,71 +1043,67 @@ var _VenueBookingImpl = class extends import_BaseSales.BaseSalesImpl {
1184
1043
  metadata: {}
1185
1044
  }));
1186
1045
  }
1187
- const venueProductOrigin = {
1188
- name: mapping.productTitle,
1189
- product_title: productTitle,
1190
- cover: (venueProduct == null ? void 0 : venueProduct.cover) || "",
1191
- custom_deposit_data: customDepositData,
1192
- id: 0,
1193
- number: 1,
1194
- registration_type: "all",
1195
- relation_products: [],
1196
- is_all: false,
1197
- product: {
1046
+ tempOrder.products.push(
1047
+ (0, import_utils.normalizeOrderProduct)({
1198
1048
  product_id: mapping.productId,
1199
1049
  product_variant_id: 0,
1050
+ identity_key: identityKey,
1200
1051
  num: 1,
1201
- product_bundle: [],
1202
- product_sku: { option: [] },
1203
- discount_list: [],
1204
- custom_deposit_data: customDepositData,
1205
- metadata: {}
1206
- },
1207
- sub_type: "minutes",
1208
- duration,
1209
- like_status: "common",
1210
- resources: [resourceEntry],
1211
- schedule_id: 0,
1212
- select_date: startMoment.format("YYYY-MM-DD"),
1213
- start_date: startMoment.format("YYYY-MM-DD"),
1214
- start_time: startMoment.format("HH:mm"),
1215
- end_date: endMoment.format("YYYY-MM-DD"),
1216
- end_time: endMoment.format("HH:mm"),
1217
- metadata: {
1218
- venue_booking: true,
1219
- slot_count: group.slotCount
1220
- },
1221
- holder: null
1222
- };
1223
- const normalizedVenueOrderProduct = (0, import_utils.normalizeOrderProduct)({
1224
- product_id: mapping.productId,
1225
- product_variant_id: 0,
1226
- identity_key: identityKey,
1227
- num: 1,
1228
- selling_price: group.totalPrice,
1229
- original_price: group.totalPrice,
1230
- is_charge_tax: (venueProduct == null ? void 0 : venueProduct.is_charge_tax) ?? 0,
1231
- metadata: {
1232
- venue_booking: true,
1233
- ...productTitle ? { product_title: productTitle } : {},
1234
- resource_id: resourceId,
1235
- resource_form_id: mapping.formId,
1236
- resource_name: mapping.resourceName,
1237
- start_time: group.startTime,
1238
- end_time: group.endTime,
1239
- slot_count: group.slotCount,
1240
- booking_uid: bookingUuid,
1241
- price_breakdown: (0, import_slotMerge.buildPriceBreakdown)({
1242
- group,
1243
- productId: mapping.productId,
1244
- quotation: this.store.quotation
1245
- })
1246
- },
1247
- _origin: venueProductOrigin
1248
- });
1249
- const venueOrderProduct = productTitle ? { ...normalizedVenueOrderProduct, product_title: productTitle } : normalizedVenueOrderProduct;
1250
- this.attachProductOriginToTempOrder(tempOrder, identityKey, venueProductOrigin);
1251
- tempOrder.products.push(venueOrderProduct);
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
+ );
1252
1107
  const booking = (0, import_slotMerge.buildVenueBookingEntry)({
1253
1108
  group,
1254
1109
  resourceId,
@@ -1260,8 +1115,6 @@ var _VenueBookingImpl = class extends import_BaseSales.BaseSalesImpl {
1260
1115
  });
1261
1116
  tempOrder.bookings.push(booking);
1262
1117
  }
1263
- const products = ((_b = (_a = this.store.order) == null ? void 0 : _a.getOrderProducts) == null ? void 0 : _b.call(_a)) || [];
1264
- await this.preloadHolderForms(products);
1265
1118
  this.store.order.applyDiscount();
1266
1119
  await this.store.order.recalculateSummary({ createIfMissing: true });
1267
1120
  this.store.order.persistTempOrder();
@@ -1329,17 +1182,17 @@ var _VenueBookingImpl = class extends import_BaseSales.BaseSalesImpl {
1329
1182
  const result = ((_a = this.store.order) == null ? void 0 : _a.getTempOrder()) || null;
1330
1183
  return result;
1331
1184
  }
1332
- updateTempOrderNote(note, sync = false) {
1185
+ updateTempOrderNote(note) {
1333
1186
  if (!this.store.order)
1334
1187
  throw new Error("order 模块未初始化");
1335
- return this.store.order.updateTempOrderNote(note, sync);
1188
+ return this.store.order.updateTempOrderNote(note);
1336
1189
  }
1337
1190
  updateTempOrderContactsInfo(contactsInfo) {
1338
1191
  if (!this.store.order)
1339
1192
  throw new Error("order 模块未初始化");
1340
1193
  return this.store.order.updateTempOrderContactsInfo(contactsInfo);
1341
1194
  }
1342
- ensureVenueTempOrder() {
1195
+ ensureTempOrder() {
1343
1196
  if (!this.store.order)
1344
1197
  throw new Error("order 模块未初始化");
1345
1198
  return this.store.order.ensureTempOrder();
@@ -1432,7 +1285,7 @@ var _VenueBookingImpl = class extends import_BaseSales.BaseSalesImpl {
1432
1285
  }
1433
1286
  /** 勾选/取消勾选某张折扣券,重新计算折扣并持久化 */
1434
1287
  async setDiscountSelected(params) {
1435
- var _a, _b, _c, _d, _e, _f, _g;
1288
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1436
1289
  this.logMethodStart("setDiscountSelected", params);
1437
1290
  try {
1438
1291
  if (!this.store.order)
@@ -1488,9 +1341,12 @@ var _VenueBookingImpl = class extends import_BaseSales.BaseSalesImpl {
1488
1341
  nextDiscountList.filter((d) => d.isSelected).map((d) => d.id)
1489
1342
  );
1490
1343
  for (const product of tempOrder.products) {
1491
- const origin = this.readProductOriginFromTempOrder(tempOrder, product);
1492
- if (origin == null ? void 0 : origin.isManualDiscount)
1344
+ if ((_c = product._origin) == null ? void 0 : _c.isManualDiscount)
1345
+ continue;
1346
+ if ((product.discount_list || []).some(isItemRewardProductDiscount)) {
1347
+ product.discount_list = (product.discount_list || []).filter(isItemRewardProductDiscount);
1493
1348
  continue;
1349
+ }
1494
1350
  product.discount_list = (product.discount_list || []).filter((pd) => {
1495
1351
  var _a2;
1496
1352
  const rid = ((_a2 = pd.discount) == null ? void 0 : _a2.resource_id) ?? pd.id;
@@ -1501,7 +1357,7 @@ var _VenueBookingImpl = class extends import_BaseSales.BaseSalesImpl {
1501
1357
  0
1502
1358
  );
1503
1359
  const optionSum = (0, import_utils3.sumOptionUnitPrice)((0, import_utils3.getProductSkuOptions)(product));
1504
- const sourcePrice = ((_c = product.metadata) == null ? void 0 : _c.source_product_price) ?? (((_d = product.metadata) == null ? void 0 : _d.main_product_original_price) != null ? new import_decimal.default(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : product.original_price ?? "0");
1360
+ const sourcePrice = ((_d = product.metadata) == null ? void 0 : _d.source_product_price) ?? (((_e = product.metadata) == null ? void 0 : _e.main_product_original_price) != null ? new import_decimal.default(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : product.original_price ?? "0");
1505
1361
  const newSourceSellingPrice = new import_decimal.default(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
1506
1362
  const newMainSellingPrice = new import_decimal.default(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
1507
1363
  if (product.metadata) {
@@ -1519,8 +1375,8 @@ var _VenueBookingImpl = class extends import_BaseSales.BaseSalesImpl {
1519
1375
  const afterApplyTarget = this.store.order.getDiscountList().find((d) => d.id === params.discountId) || null;
1520
1376
  await this.store.order.recalculateSummary({ createIfMissing: true });
1521
1377
  this.store.order.persistTempOrder();
1522
- const finalSummary = ((_e = this.store.order.getTempOrder()) == null ? void 0 : _e.summary) || null;
1523
- const finalProduct = ((_g = (_f = this.store.order.getTempOrder()) == null ? void 0 : _f.products) == null ? void 0 : _g[0]) || null;
1378
+ const finalSummary = ((_f = this.store.order.getTempOrder()) == null ? void 0 : _f.summary) || null;
1379
+ const finalProduct = ((_h = (_g = this.store.order.getTempOrder()) == null ? void 0 : _g.products) == null ? void 0 : _h[0]) || null;
1524
1380
  this.logMethodSuccess("setDiscountSelected", params);
1525
1381
  const finalTarget = this.store.order.getDiscountList().find((d) => d.id === params.discountId) || null;
1526
1382
  return this.store.order.getDiscountList();
@@ -1835,7 +1691,7 @@ var _VenueBookingImpl = class extends import_BaseSales.BaseSalesImpl {
1835
1691
  return [];
1836
1692
  }
1837
1693
  const businessData = (0, import_utils.buildItemRuleBusinessData)({
1838
- tempOrder: this.ensureVenueTempOrder(),
1694
+ tempOrder: this.ensureTempOrder(),
1839
1695
  runtimeConfig: this.getItemRuleRuntimeConfig(),
1840
1696
  itemRuleConfigs: this.itemRuleConfigs
1841
1697
  });
@@ -1850,7 +1706,7 @@ var _VenueBookingImpl = class extends import_BaseSales.BaseSalesImpl {
1850
1706
  }
1851
1707
  }
1852
1708
  async applyPrefillByItemRule() {
1853
- var _a, _b;
1709
+ var _a;
1854
1710
  if (this.itemRulePrefillApplied)
1855
1711
  return;
1856
1712
  if (!this.store.order)
@@ -1859,7 +1715,7 @@ var _VenueBookingImpl = class extends import_BaseSales.BaseSalesImpl {
1859
1715
  if (!strategyConfigs.length)
1860
1716
  return;
1861
1717
  const businessData = (0, import_utils.buildItemRuleBusinessData)({
1862
- tempOrder: this.ensureVenueTempOrder(),
1718
+ tempOrder: this.ensureTempOrder(),
1863
1719
  runtimeConfig: this.getItemRuleRuntimeConfig(),
1864
1720
  itemRuleConfigs: this.itemRuleConfigs
1865
1721
  });
@@ -1869,7 +1725,7 @@ var _VenueBookingImpl = class extends import_BaseSales.BaseSalesImpl {
1869
1725
  return;
1870
1726
  }
1871
1727
  const productSourceMap = await this.buildPrefillProductSourceMap();
1872
- const tempOrder = this.ensureVenueTempOrder();
1728
+ const tempOrder = this.ensureTempOrder();
1873
1729
  let hasChanges = false;
1874
1730
  for (const prefillItem of prefillItems) {
1875
1731
  const productId = Number(prefillItem.product_id);
@@ -1886,39 +1742,32 @@ var _VenueBookingImpl = class extends import_BaseSales.BaseSalesImpl {
1886
1742
  });
1887
1743
  if (productIndex === -1) {
1888
1744
  const sellingPrice = (0, import_utils.toPriceString)((sourceItem == null ? void 0 : sourceItem.price) ?? (sourceItem == null ? void 0 : sourceItem.selling_price), "0.00");
1889
- const origin = { ...sourceItem || {}, item_rule_prefill: true, item_rule_id: prefillItem.ruleId };
1890
- const product = (0, import_utils.normalizeOrderProduct)({
1891
- product_id: productId,
1892
- product_variant_id: productVariantId,
1893
- num: targetQuantity,
1894
- selling_price: sellingPrice,
1895
- original_price: sellingPrice,
1896
- metadata: { item_rule_prefill: true, item_rule_id: prefillItem.ruleId },
1897
- _origin: origin
1898
- });
1899
- const productUid = String(((_a = product.metadata) == null ? void 0 : _a.unique_identification_number) || "");
1900
- this.attachProductOriginToTempOrder(tempOrder, productUid, origin);
1901
- tempOrder.products.push(product);
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
+ );
1902
1756
  hasChanges = true;
1903
1757
  continue;
1904
1758
  }
1905
1759
  const targetProduct = tempOrder.products[productIndex];
1906
- const previousOrigin = this.readProductOriginFromTempOrder(tempOrder, targetProduct);
1907
- const nextOrigin = sourceItem ? { ...previousOrigin || {}, ...sourceItem } : previousOrigin;
1908
1760
  const existedQuantity = (0, import_utils.toNonNegativeInt)(targetProduct.num);
1909
1761
  const delta = targetQuantity - existedQuantity;
1910
1762
  const nextProduct = {
1911
1763
  ...targetProduct,
1912
1764
  ...delta > 0 ? { num: (0, import_utils.getSafeProductNum)(existedQuantity + delta) } : {},
1913
- metadata: { ...targetProduct.metadata || {}, item_rule_prefill: true, item_rule_id: prefillItem.ruleId }
1765
+ metadata: { ...targetProduct.metadata || {}, item_rule_prefill: true, item_rule_id: prefillItem.ruleId },
1766
+ _origin: sourceItem ? { ...targetProduct._origin || {}, ...sourceItem } : targetProduct._origin
1914
1767
  };
1915
1768
  if (delta > 0 || Boolean(
1916
- sourceItem && (!previousOrigin || (previousOrigin == null ? void 0 : previousOrigin.price) !== (sourceItem == null ? void 0 : sourceItem.price))
1769
+ sourceItem && (!targetProduct._origin || ((_a = targetProduct._origin) == null ? void 0 : _a.price) !== (sourceItem == null ? void 0 : sourceItem.price))
1917
1770
  )) {
1918
- const productUid = String(
1919
- ((_b = nextProduct.metadata) == null ? void 0 : _b.unique_identification_number) || ""
1920
- );
1921
- this.attachProductOriginToTempOrder(tempOrder, productUid, nextOrigin);
1922
1771
  tempOrder.products[productIndex] = nextProduct;
1923
1772
  hasChanges = true;
1924
1773
  }
@@ -1946,7 +1795,7 @@ var _VenueBookingImpl = class extends import_BaseSales.BaseSalesImpl {
1946
1795
  if (!strategyConfigs.length)
1947
1796
  return { passed: true, failures: [] };
1948
1797
  const businessData = (0, import_utils.buildItemRuleBusinessData)({
1949
- tempOrder: this.ensureVenueTempOrder(),
1798
+ tempOrder: this.ensureTempOrder(),
1950
1799
  runtimeConfig: this.getItemRuleRuntimeConfig(),
1951
1800
  itemRuleConfigs: this.itemRuleConfigs
1952
1801
  });
@@ -2058,60 +1907,6 @@ var _VenueBookingImpl = class extends import_BaseSales.BaseSalesImpl {
2058
1907
  this.writeUIStateBucket(bucket);
2059
1908
  }
2060
1909
  }
2061
- setBookingHolder(bookingUid, holder) {
2062
- var _a, _b, _c, _d;
2063
- if (!this.store.order)
2064
- return;
2065
- const tempOrder = this.store.order.ensureTempOrder();
2066
- const booking = (_a = tempOrder.bookings) == null ? void 0 : _a.find(
2067
- (b) => {
2068
- var _a2;
2069
- return ((_a2 = b.metadata) == null ? void 0 : _a2.unique_identification_number) === bookingUid;
2070
- }
2071
- );
2072
- if (booking) {
2073
- booking.holder = holder;
2074
- }
2075
- for (const product of tempOrder.products) {
2076
- const runtimeProduct = product;
2077
- 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);
2078
- if (String(productBookingUid) !== String(bookingUid))
2079
- continue;
2080
- const origin = runtimeProduct._origin && typeof runtimeProduct._origin === "object" ? runtimeProduct._origin : {};
2081
- origin.holder = holder;
2082
- runtimeProduct._origin = origin;
2083
- }
2084
- this.store.order.notifyTempOrderChanged();
2085
- }
2086
- /**
2087
- * 获取 holder 表单 map
2088
- */
2089
- getHolderFormMap() {
2090
- if (!this.store.holder)
2091
- throw new Error("[VenueBooking] holder 模块未初始化");
2092
- return this.store.holder.getHolderFormMap();
2093
- }
2094
- /**
2095
- * UI 层触发:按当前 holderMap 批量刷新所有表单的 records
2096
- */
2097
- async refreshAllHolderFormRecords(params) {
2098
- if (!this.store.holder)
2099
- throw new Error("[VenueBooking] holder 模块未初始化");
2100
- const customer_id = (params == null ? void 0 : params.customer_id) ?? this.resolveHolderCustomerId();
2101
- return this.store.holder.refreshAllFormRecords({
2102
- ...params,
2103
- customer_id,
2104
- useCache: (params == null ? void 0 : params.useCache) ?? false
2105
- });
2106
- }
2107
- /**
2108
- * 添加表单记录
2109
- */
2110
- appendFormRecord(params) {
2111
- if (!this.store.holder)
2112
- throw new Error("[VenueBooking] holder 模块未初始化");
2113
- return this.store.holder.appendFormRecord(params);
2114
- }
2115
1910
  // ─── OpenData 可用性 ───
2116
1911
  async checkOpenDataAvailability() {
2117
1912
  if (!this.store.openData)