@pisell/pisellos 2.2.163 → 2.2.165

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 (124) hide show
  1. package/dist/modules/BookingContext/index.d.ts +37 -0
  2. package/dist/modules/BookingContext/index.js +436 -0
  3. package/dist/modules/BookingContext/types.d.ts +102 -0
  4. package/dist/modules/BookingContext/types.js +51 -0
  5. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
  6. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +157 -0
  7. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
  8. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +137 -0
  9. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +65 -0
  10. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +191 -0
  11. package/dist/modules/BookingContext/utils/flexible.d.ts +28 -0
  12. package/dist/modules/BookingContext/utils/flexible.js +56 -0
  13. package/dist/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  14. package/dist/modules/BookingContext/utils/formatResourceList.js +38 -0
  15. package/dist/modules/BookingContext/utils/index.d.ts +11 -0
  16. package/dist/modules/BookingContext/utils/index.js +11 -0
  17. package/dist/modules/BookingContext/utils/noResource.d.ts +13 -0
  18. package/dist/modules/BookingContext/utils/noResource.js +77 -0
  19. package/dist/modules/BookingContext/utils/productExtend.d.ts +72 -0
  20. package/dist/modules/BookingContext/utils/productExtend.js +339 -0
  21. package/dist/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  22. package/dist/modules/BookingContext/utils/resourceErrors.js +74 -0
  23. package/dist/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  24. package/dist/modules/BookingContext/utils/resourceSelection.js +24 -0
  25. package/dist/modules/BookingContext/utils/resources.d.ts +80 -0
  26. package/dist/modules/BookingContext/utils/resources.js +486 -0
  27. package/dist/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  28. package/dist/modules/BookingContext/utils/serviceTimes.js +151 -0
  29. package/dist/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  30. package/dist/modules/BookingContext/utils/timeSlices.js +100 -0
  31. package/dist/modules/Customer/index.js +23 -22
  32. package/dist/modules/Discount/index.js +4 -3
  33. package/dist/modules/Order/index.d.ts +25 -7
  34. package/dist/modules/Order/index.js +608 -291
  35. package/dist/modules/Order/types.d.ts +46 -14
  36. package/dist/modules/Order/types.js +2 -0
  37. package/dist/modules/Order/utils.d.ts +10 -0
  38. package/dist/modules/Order/utils.js +76 -23
  39. package/dist/modules/SalesSummary/index.js +4 -2
  40. package/dist/modules/index.d.ts +1 -0
  41. package/dist/modules/index.js +2 -1
  42. package/dist/solution/BaseSales/index.d.ts +46 -7
  43. package/dist/solution/BaseSales/index.js +928 -312
  44. package/dist/solution/BaseSales/types.d.ts +51 -1
  45. package/dist/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
  46. package/dist/solution/BaseSales/utils/quotationPrice.js +159 -0
  47. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +33 -14
  48. package/dist/solution/BaseSales/utils.js +36 -7
  49. package/dist/solution/BookingByStep/index.d.ts +1 -1
  50. package/dist/solution/BookingTicket/index.d.ts +124 -1
  51. package/dist/solution/BookingTicket/index.js +488 -90
  52. package/dist/solution/BookingTicket/types.d.ts +2 -0
  53. package/dist/solution/BookingTicket/types.js +3 -0
  54. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +111 -0
  55. package/dist/solution/BookingTicket/utils/addProductDecision.js +334 -0
  56. package/dist/solution/ScanOrder/index.d.ts +9 -3
  57. package/dist/solution/ScanOrder/index.js +231 -128
  58. package/dist/solution/ScanOrder/utils.js +36 -7
  59. package/dist/solution/VenueBooking/index.d.ts +4 -2
  60. package/dist/solution/VenueBooking/index.js +103 -55
  61. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
  62. package/dist/solution/VenueBooking/utils/slotMerge.js +10 -0
  63. package/lib/modules/BookingContext/index.d.ts +37 -0
  64. package/lib/modules/BookingContext/index.js +297 -0
  65. package/lib/modules/BookingContext/types.d.ts +102 -0
  66. package/lib/modules/BookingContext/types.js +34 -0
  67. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
  68. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +174 -0
  69. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
  70. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +141 -0
  71. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +65 -0
  72. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +177 -0
  73. package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
  74. package/lib/modules/BookingContext/utils/flexible.js +80 -0
  75. package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  76. package/lib/modules/BookingContext/utils/formatResourceList.js +50 -0
  77. package/lib/modules/BookingContext/utils/index.d.ts +11 -0
  78. package/lib/modules/BookingContext/utils/index.js +43 -0
  79. package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
  80. package/lib/modules/BookingContext/utils/noResource.js +90 -0
  81. package/lib/modules/BookingContext/utils/productExtend.d.ts +72 -0
  82. package/lib/modules/BookingContext/utils/productExtend.js +283 -0
  83. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  84. package/lib/modules/BookingContext/utils/resourceErrors.js +80 -0
  85. package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  86. package/lib/modules/BookingContext/utils/resourceSelection.js +46 -0
  87. package/lib/modules/BookingContext/utils/resources.d.ts +80 -0
  88. package/lib/modules/BookingContext/utils/resources.js +377 -0
  89. package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  90. package/lib/modules/BookingContext/utils/serviceTimes.js +162 -0
  91. package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  92. package/lib/modules/BookingContext/utils/timeSlices.js +124 -0
  93. package/lib/modules/Customer/index.js +8 -8
  94. package/lib/modules/Discount/index.js +5 -1
  95. package/lib/modules/Order/index.d.ts +25 -7
  96. package/lib/modules/Order/index.js +268 -72
  97. package/lib/modules/Order/types.d.ts +46 -14
  98. package/lib/modules/Order/utils.d.ts +10 -0
  99. package/lib/modules/Order/utils.js +66 -15
  100. package/lib/modules/SalesSummary/index.js +4 -2
  101. package/lib/modules/index.d.ts +1 -0
  102. package/lib/modules/index.js +3 -1
  103. package/lib/solution/BaseSales/index.d.ts +46 -7
  104. package/lib/solution/BaseSales/index.js +369 -17
  105. package/lib/solution/BaseSales/types.d.ts +51 -1
  106. package/lib/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
  107. package/lib/solution/BaseSales/utils/quotationPrice.js +201 -0
  108. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +31 -10
  109. package/lib/solution/BaseSales/utils.js +37 -5
  110. package/lib/solution/BookingByStep/index.d.ts +1 -1
  111. package/lib/solution/BookingTicket/index.d.ts +124 -1
  112. package/lib/solution/BookingTicket/index.js +255 -8
  113. package/lib/solution/BookingTicket/types.d.ts +2 -0
  114. package/lib/solution/BookingTicket/types.js +6 -0
  115. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +111 -0
  116. package/lib/solution/BookingTicket/utils/addProductDecision.js +308 -0
  117. package/lib/solution/ScanOrder/index.d.ts +9 -3
  118. package/lib/solution/ScanOrder/index.js +147 -66
  119. package/lib/solution/ScanOrder/utils.js +37 -5
  120. package/lib/solution/VenueBooking/index.d.ts +4 -2
  121. package/lib/solution/VenueBooking/index.js +50 -14
  122. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
  123. package/lib/solution/VenueBooking/utils/slotMerge.js +10 -0
  124. package/package.json +1 -1
@@ -35,12 +35,16 @@ __export(BookingTicket_exports, {
35
35
  });
36
36
  module.exports = __toCommonJS(BookingTicket_exports);
37
37
  var import_types = require("./types");
38
+ var import_BookingContext = require("../../modules/BookingContext");
38
39
  var import_BaseSales = require("../BaseSales");
39
40
  var import_scan = __toESM(require("./utils/scan"));
40
41
  var import_orderCustomer = require("./utils/orderCustomer");
41
42
  var import_handleScan = require("./utils/scan/handleScan");
42
43
  var import_scanCache = __toESM(require("./utils/scan/scanCache"));
43
44
  var import_cartView = require("./utils/cartView");
45
+ var import_addProductDecision = require("./utils/addProductDecision");
46
+ var import_buildCacheItemFromOrderLine = require("../../modules/BookingContext/utils/buildCacheItemFromOrderLine");
47
+ var import_buildNormalProductCacheItemFromOrderLine = require("../../modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine");
44
48
  var import_bookingStatus = require("./utils/bookingStatus");
45
49
  __reExport(BookingTicket_exports, require("./types"), module.exports);
46
50
  var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
@@ -54,12 +58,18 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
54
58
  */
55
59
  this.store = {};
56
60
  this.productCatalog = [];
61
+ this.orderCustomerDiscountRefreshInFlight = null;
62
+ this.orderCustomerDiscountRefreshCustomerId = null;
57
63
  }
58
64
  /**
59
- * 在 BaseSales 默认模块清单(products/order/salesSummary/schedule)基础上追加 customer。
65
+ * 在 BaseSales 默认模块清单(products/order/salesSummary/schedule)基础上追加 customer + bookingContext
66
+ * bookingContext 是 SalesSdk 加车下沉所需的「预约 UI 上下文」(bookingConfig / resourcesOrigin / date)。
60
67
  */
61
68
  getRegisteredModuleNames() {
62
- return [...super.getRegisteredModuleNames(), "customer"];
69
+ return [...super.getRegisteredModuleNames(), "customer", "bookingContext"];
70
+ }
71
+ getSubmitOrderSalesChannel() {
72
+ return "pos";
63
73
  }
64
74
  /**
65
75
  * 业务侧子模块工厂:BookingTicket 自带的 createBookingTicketModule 优先匹配;
@@ -96,19 +106,30 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
96
106
  console.log(sales, "1234sales");
97
107
  const customerModule = this.store.customer;
98
108
  const detailCustomer = sales == null ? void 0 : sales.customer;
99
- if (customerModule && detailCustomer) {
100
- const { id: detailCustomerId, ...detailCustomerRest } = detailCustomer ?? {};
109
+ const orderCustomerSnapshot = this.store.order.getOrderCustomerSnapshot();
110
+ const protocolCustomerId = sales == null ? void 0 : sales.customer_id;
111
+ const protocolCustomer = protocolCustomerId !== void 0 && protocolCustomerId !== null ? {
112
+ id: protocolCustomerId,
113
+ name: String((sales == null ? void 0 : sales.customer_name) || ""),
114
+ phone: sales == null ? void 0 : sales.phone,
115
+ email: sales == null ? void 0 : sales.email,
116
+ country_calling_code: sales == null ? void 0 : sales.country_calling_code
117
+ } : null;
118
+ const selectedCustomer = detailCustomer ?? orderCustomerSnapshot ?? protocolCustomer;
119
+ if (customerModule && selectedCustomer) {
120
+ const { id: detailCustomerId, ...detailCustomerRest } = selectedCustomer ?? {};
101
121
  const rawId = detailCustomerId ?? "";
102
122
  const customer = {
103
123
  ...detailCustomerRest,
104
124
  id: rawId == null ? "" : rawId,
105
- name: (detailCustomer == null ? void 0 : detailCustomer.name) ?? "",
106
- phone: detailCustomer == null ? void 0 : detailCustomer.phone,
107
- email: detailCustomer == null ? void 0 : detailCustomer.email,
108
- country_calling_code: detailCustomer == null ? void 0 : detailCustomer.country_calling_code
125
+ name: (selectedCustomer == null ? void 0 : selectedCustomer.name) ?? "",
126
+ phone: selectedCustomer == null ? void 0 : selectedCustomer.phone,
127
+ email: selectedCustomer == null ? void 0 : selectedCustomer.email,
128
+ country_calling_code: selectedCustomer == null ? void 0 : selectedCustomer.country_calling_code
109
129
  };
110
130
  customerModule.setSelectedCustomer(customer);
111
131
  this.setOrderCustomer(customer);
132
+ await this.store.order.saveDraft();
112
133
  }
113
134
  return sales;
114
135
  }
@@ -192,6 +213,10 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
192
213
  */
193
214
  async loadProducts(params = {}, options) {
194
215
  const { schedule_date, customer_id, menu_list_ids, schedule_datetime } = params;
216
+ const bookingDate = schedule_date || (schedule_datetime ? String(schedule_datetime).slice(0, 10) : "");
217
+ if (bookingDate) {
218
+ this.setBookingDate(bookingDate);
219
+ }
195
220
  try {
196
221
  const result = await this.store.products.loadProducts({
197
222
  with_count: ["bundleGroup", "optionGroup"],
@@ -388,6 +413,7 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
388
413
  this.store.order.setOrderCustomer(patch, customer);
389
414
  const next = this.buildOrderCustomerPayload();
390
415
  this.core.effects.emit(`${this.name}:onOrderCustomerChange`, next);
416
+ this.refreshDiscountConfigAfterOrderCustomerChange(patch.customer_id);
391
417
  }
392
418
  /**
393
419
  * 读取 tempOrder 上的下单客户协议字段;customer_id 缺失时返回 null。
@@ -408,6 +434,22 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
408
434
  this.store.order.clearOrderCustomer();
409
435
  this.core.effects.emit(`${this.name}:onOrderCustomerChange`, null);
410
436
  }
437
+ /**
438
+ * 重置 tempOrder,并同步清空下单客户运行态。
439
+ *
440
+ * OrderModule.restoreOrder 会重建空单(customer_id 已为 null),但不会:
441
+ * - emit BookingTicket `onOrderCustomerChange`
442
+ * - 重置 CustomerModule.selectedCustomer(老路 getActiveCustomer)
443
+ *
444
+ * 因此在 super.restoreOrder 之后显式清客户,保证 SalesSdk / ticketBooking 订阅方与 tempOrder 一致。
445
+ */
446
+ async restoreOrder() {
447
+ var _a;
448
+ const tempOrder = await super.restoreOrder();
449
+ this.clearOrderCustomer();
450
+ (_a = this.store.customer) == null ? void 0 : _a.setSelectedCustomer(null);
451
+ return tempOrder;
452
+ }
411
453
  /** 内部:基于 OrderModule 当前状态构造一份 OrderCustomerChangePayload。 */
412
454
  buildOrderCustomerPayload() {
413
455
  const patch = this.store.order.getOrderCustomer();
@@ -418,6 +460,34 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
418
460
  snapshot: this.store.order.getOrderCustomerSnapshot()
419
461
  };
420
462
  }
463
+ refreshDiscountConfigAfterOrderCustomerChange(customerId) {
464
+ if (!customerId || customerId === 1)
465
+ return;
466
+ if (this.orderCustomerDiscountRefreshInFlight && this.orderCustomerDiscountRefreshCustomerId === customerId) {
467
+ return;
468
+ }
469
+ const previousRefresh = this.orderCustomerDiscountRefreshInFlight;
470
+ const refreshTask = (async () => {
471
+ if (previousRefresh) {
472
+ await previousRefresh.catch(() => void 0);
473
+ }
474
+ const currentCustomer = this.store.order.getOrderCustomer();
475
+ if (!currentCustomer || Number(currentCustomer.customer_id) !== customerId) {
476
+ return;
477
+ }
478
+ await this.loadDiscountConfig({ customerId });
479
+ })();
480
+ this.orderCustomerDiscountRefreshInFlight = refreshTask;
481
+ this.orderCustomerDiscountRefreshCustomerId = customerId;
482
+ refreshTask.catch((error) => {
483
+ console.error("Failed to load discount config after customer change:", error);
484
+ }).finally(() => {
485
+ if (this.orderCustomerDiscountRefreshInFlight !== refreshTask)
486
+ return;
487
+ this.orderCustomerDiscountRefreshInFlight = null;
488
+ this.orderCustomerDiscountRefreshCustomerId = null;
489
+ });
490
+ }
421
491
  /**
422
492
  * 获取客户分页信息
423
493
  * @returns 分页信息
@@ -613,6 +683,183 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
613
683
  async getOtherParams() {
614
684
  return this.otherParams;
615
685
  }
686
+ // ─── BookingContext API(透传给 BookingContextModule) ──────────────────────
687
+ // SalesSdkProvider 挂载时默认调 initBookingContext;也可由 UI 显式 set* 灌入已有数据。
688
+ /** 拉取 board config 并写入 BookingContext。 */
689
+ loadBookingConfig(params) {
690
+ return this.store.bookingContext.loadBookingConfig(params);
691
+ }
692
+ /** 拉取资源全集并写入 BookingContext。 */
693
+ loadBookingResources(params) {
694
+ return this.store.bookingContext.loadResources(params);
695
+ }
696
+ /** 初始化 BookingContext(date + config + resources)。 */
697
+ initBookingContext(params) {
698
+ return this.store.bookingContext.initBookingContext(params);
699
+ }
700
+ /** 当前 store 是否已具备与入参等价的 config / resources(无需再请求接口)。 */
701
+ isBookingContextReady(params) {
702
+ return this.store.bookingContext.isBookingContextReady(params);
703
+ }
704
+ /** 写入 booking config(来源:`/core/board/management/config`)。 */
705
+ setBookingConfig(config) {
706
+ this.store.bookingContext.setBookingConfig(config);
707
+ }
708
+ /** 读取当前 booking config。 */
709
+ getBookingConfig() {
710
+ return this.store.bookingContext.getBookingConfig();
711
+ }
712
+ /** 写入资源全集(来源:`/form/schedule`),同步派生 resourcesOriginMap。 */
713
+ setResources(resources) {
714
+ this.store.bookingContext.setResources(resources);
715
+ }
716
+ /** 读取资源全集(浅克隆)。 */
717
+ getResourcesOrigin() {
718
+ return this.store.bookingContext.getResourcesOrigin();
719
+ }
720
+ /** 读取资源全集 map(id → resource)。 */
721
+ getResourcesOriginMap() {
722
+ return this.store.bookingContext.getResourcesOriginMap();
723
+ }
724
+ /** 写入当前选择的日期;支持 dayjs / Date / string。 */
725
+ setBookingDate(date) {
726
+ this.store.bookingContext.setDate(date);
727
+ }
728
+ /** 读取当前选择的日期(统一 string)。 */
729
+ getBookingDate() {
730
+ return this.store.bookingContext.getDate();
731
+ }
732
+ /** 读取 BookingContext 完整 store(调试 / 测试 / 透传给 SDK 使用)。 */
733
+ getBookingContextState() {
734
+ return this.store.bookingContext.getState();
735
+ }
736
+ /** 清空 BookingContext(切租户 / destroy 场景)。 */
737
+ clearBookingContext() {
738
+ this.store.bookingContext.clear();
739
+ }
740
+ /**
741
+ * 构造 BookingContext 计算上下文(供 getProductExtend / getResourceByIds 等读 API 复用)。
742
+ */
743
+ buildBookingCalcContext(extra) {
744
+ const state = this.store.bookingContext.getState();
745
+ const date = (extra == null ? void 0 : extra.date) ?? state.date;
746
+ return {
747
+ bookingConfig: state.bookingConfig,
748
+ resourcesOrigin: state.resourcesOrigin,
749
+ resourcesOriginMap: state.resourcesOriginMap,
750
+ date,
751
+ presetStartTime: (extra == null ? void 0 : extra.presetStartTime) ?? (0, import_BookingContext.derivePresetStartTimeFromDate)(date),
752
+ ...extra || {}
753
+ };
754
+ }
755
+ /**
756
+ * 取商品当前可选资源列表(透传 OS BookingContext utils#getResourceByIds)。
757
+ * `extraResources` 用于把拖入未绑定的资源也展示出来。
758
+ */
759
+ getResourcesForProduct(product, options) {
760
+ var _a, _b;
761
+ const ctx = this.buildBookingCalcContext();
762
+ return (0, import_BookingContext.getResourceByIds)(ctx.resourcesOriginMap || {}, product, {
763
+ resourceTab: (_b = (_a = ctx.bookingConfig) == null ? void 0 : _a.config) == null ? void 0 : _b.resource_tab,
764
+ resourcesOrigin: ctx.resourcesOrigin,
765
+ extraResources: (options == null ? void 0 : options.extraResources) || []
766
+ });
767
+ }
768
+ /**
769
+ * 拼装 cacheItem 的 _extend / _data(资源 / 容量 / timeObj),与 info2 `getProductExtend` 等价。
770
+ */
771
+ getProductExtend(cacheItem, extra) {
772
+ return (0, import_BookingContext.getProductExtend)({
773
+ cacheItem,
774
+ ctx: this.buildBookingCalcContext(extra)
775
+ });
776
+ }
777
+ /**
778
+ * 取资源不可用原因列表(结构化 enum + params,i18n 文案由 UI 渲染)。
779
+ */
780
+ getResourceErrors(resource, cacheItem) {
781
+ return (0, import_BookingContext.getResourceErrors)(resource, cacheItem);
782
+ }
783
+ // ─── addProduct 决策 / 转换 API(SDK 加车下沉所需) ─────────────────────────
784
+ // 这一组方法是 SalesSdkCartContext.addProduct / confirmDetail 的 OS 后端。
785
+ // 调用方传入 ProductData,OS 自取 bookingContext / customer / date 等上下文,
786
+ // 输出 (a) autoClose 决策结果或 (b) `{ product, booking }` 协议入参。
787
+ /**
788
+ * 拼装 addProductDecision 通用上下文(从 store 自取)。
789
+ */
790
+ buildAddProductCtx(extra) {
791
+ var _a, _b;
792
+ const bookingContextState = this.store.bookingContext.getState();
793
+ const date = (extra == null ? void 0 : extra.date) ?? bookingContextState.date;
794
+ const orderCustomerId = ((_a = this.getOrderCustomerSnapshot()) == null ? void 0 : _a.id) ?? ((_b = this.store.order.getTempOrder()) == null ? void 0 : _b.customer_id) ?? void 0;
795
+ return {
796
+ bookingConfig: bookingContextState.bookingConfig,
797
+ resourcesOrigin: bookingContextState.resourcesOrigin,
798
+ resourcesOriginMap: bookingContextState.resourcesOriginMap,
799
+ date,
800
+ presetStartTime: (extra == null ? void 0 : extra.presetStartTime) ?? (0, import_BookingContext.derivePresetStartTimeFromDate)(date),
801
+ customerId: orderCustomerId,
802
+ ...extra || {}
803
+ };
804
+ }
805
+ /**
806
+ * 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
807
+ * 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
808
+ */
809
+ decideAddProduct(item, options) {
810
+ return (0, import_addProductDecision.decideAddProduct)(item, this.buildAddProductCtx(options));
811
+ }
812
+ /** 规格弹窗 callback 后的第二段决策。 */
813
+ decideAfterDetail(cacheItem, options) {
814
+ return (0, import_addProductDecision.decideAfterDetail)(cacheItem, this.buildAddProductCtx(options));
815
+ }
816
+ /**
817
+ * @deprecated 请用 `decideAddProduct`;`autoClose=true` 仅当 action=add。
818
+ */
819
+ decideAutoClose(item, options) {
820
+ return (0, import_addProductDecision.decideAutoClose)(item, this.buildAddProductCtx(options));
821
+ }
822
+ /** 替代 info2 `getIsEject`:商品是否需要弹窗(0/1)。 */
823
+ getIsEject(item, type = "select") {
824
+ return (0, import_addProductDecision.getIsEject)(item, type);
825
+ }
826
+ /** 仅 session 商品(无 variant/option/package)→ true。 */
827
+ getIsOnlySession(item) {
828
+ return (0, import_addProductDecision.getIsOnlySession)(item);
829
+ }
830
+ /**
831
+ * 拼装 requiresDetail payload(给 SDK 直接 return 给 UI 用)。
832
+ */
833
+ buildRequiresDetailPayload(item, options) {
834
+ return (0, import_addProductDecision.buildRequiresDetailPayload)(item, this.buildAddProductCtx(options));
835
+ }
836
+ /**
837
+ * 把 detail 弹窗回调结果(e, extension_type, detail)转换为 `(product, booking)` 入参。
838
+ * 内部会先拼 cacheItem,再走 cacheItemToBookingInput 严格协议对齐。
839
+ */
840
+ transformDetailToProductAndBooking(input) {
841
+ const { item, cacheItem: preparedCacheItem, detailResult, options } = input;
842
+ const ctx = this.buildAddProductCtx(options);
843
+ const cacheItem = preparedCacheItem || (detailResult ? (0, import_addProductDecision.buildCacheItemFromDetail)(item, detailResult, ctx) : (0, import_addProductDecision.buildCacheItemFromCartDetail)(item, ctx));
844
+ return (0, import_addProductDecision.transformDetailToProductAndBooking)(cacheItem, ctx);
845
+ }
846
+ /**
847
+ * 从已加车的 order line + booking 反查资源编辑抽屉所需的 cacheItem。
848
+ * 供 SalesSdk「编辑资源」等场景使用;字段语义与 buildCacheItemFromDetail 产出对齐。
849
+ */
850
+ buildCacheItemFromOrderLine(input) {
851
+ return (0, import_buildCacheItemFromOrderLine.buildCacheItemFromOrderLine)(input);
852
+ }
853
+ /**
854
+ * 从已加车的普通商品 order line 反查 SkuDetailModal edit 所需的 cacheItem。
855
+ */
856
+ buildNormalProductCacheItemFromOrderLine(input) {
857
+ return (0, import_buildNormalProductCacheItemFromOrderLine.buildNormalProductCacheItemFromOrderLine)(input);
858
+ }
859
+ /** 文档别名:与 OrderModule.updateOrderProduct 一致。 */
860
+ async updateProductInOrder(params) {
861
+ return this.updateOrderProduct(params);
862
+ }
616
863
  /**
617
864
  * 销毁模块:先调用父类(销毁所有 store 内子模块 + emit destroy + super.destroy()),
618
865
  * 再清理 BookingTicket 自有资源(scan 监听 + scan 内存缓存)。
@@ -1,4 +1,5 @@
1
1
  import { ProductList, OrderModule } from '../../modules';
2
+ import { BookingContextModule } from '../../modules/BookingContext';
2
3
  import { CustomerModule } from '../../modules/Customer';
3
4
  import { SalesSummaryModule } from '../../modules/SalesSummary';
4
5
  import { ScheduleModule } from '../../modules/Schedule';
@@ -16,6 +17,7 @@ export interface BookingTicketState extends BaseSalesState {
16
17
  salesSummary: SalesSummaryModule;
17
18
  schedule: ScheduleModule;
18
19
  customer: CustomerModule;
20
+ bookingContext: BookingContextModule;
19
21
  }
20
22
  export declare function createBookingTicketModule<T extends keyof BookingTicketState>(moduleName: T, solutionName: string, name?: string, version?: string): BookingTicketState[T] | null;
21
23
  export declare enum BookingTicketHooks {
@@ -24,6 +24,7 @@ __export(types_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(types_exports);
26
26
  var import_modules = require("../../modules");
27
+ var import_BookingContext = require("../../modules/BookingContext");
27
28
  var import_Customer = require("../../modules/Customer");
28
29
  var import_SalesSummary = require("../../modules/SalesSummary");
29
30
  var import_Schedule = require("../../modules/Schedule");
@@ -54,6 +55,11 @@ function createBookingTicketModule(moduleName, solutionName, name, version) {
54
55
  `${solutionName}_${name || moduleName}`,
55
56
  version
56
57
  );
58
+ case "bookingContext":
59
+ return new import_BookingContext.BookingContextModule(
60
+ `${solutionName}_${name || moduleName}`,
61
+ version
62
+ );
57
63
  default:
58
64
  return null;
59
65
  }
@@ -0,0 +1,111 @@
1
+ import { BookingCalcContext } from '../../../modules/BookingContext';
2
+ import type { ProductData } from '../../../modules/Product/types';
3
+ import type { OrderProduct, OrderProductIdentity, AddProductBookingInput } from '../../../modules/Order/types';
4
+ /**
5
+ * cart.addProduct 两阶段决策(与 ticketBooking `handleSelectProduct` 对齐):
6
+ *
7
+ * 1. `requiresDetail`:规格 / SKU / 套餐 / Session / 称重弹窗(门禁:`isOpenDetailModal` / `cartDetailValue` / `open_sold_weight`)
8
+ * 2. `requiresBookingEdit`:资源 / 时间编辑抽屉(门禁:`getIsAutoClose` on prepared cacheItem)
9
+ * 3. `add`:两关均通过,直接 transform + 加车
10
+ */
11
+ export type AddProductDecision = {
12
+ action: 'add';
13
+ cacheItem: any;
14
+ } | {
15
+ action: 'requiresDetail';
16
+ payload: AddProductRequiresDetailPayload;
17
+ } | {
18
+ action: 'requiresBookingEdit';
19
+ cacheItem: any;
20
+ payload: AddProductRequiresBookingEditPayload;
21
+ };
22
+ /** 资源 / 时间编辑抽屉所需的最小 payload。 */
23
+ export interface AddProductRequiresBookingEditPayload {
24
+ cacheItem: any;
25
+ customerId?: number | string;
26
+ date: string | null;
27
+ }
28
+ /**
29
+ * 加车主决策:对齐 `handleSelectProduct` 两段分支。
30
+ */
31
+ export declare function decideAddProduct(item: any, ctx?: AddProductDecideContext): AddProductDecision;
32
+ /**
33
+ * 规格弹窗 callback 后的第二段决策(对齐 `handleBooking4Service` 内 `cacheItem.autoClose` 分支)。
34
+ */
35
+ export declare function decideAfterDetail(cacheItem: any, ctx?: AddProductDecideContext): AddProductDecision;
36
+ /**
37
+ * @deprecated 请用 `decideAddProduct`;保留兼容:autoClose=true 仅表示可直接加车(action=add)。
38
+ */
39
+ export interface AddProductRequiresDetailPayload {
40
+ item: ProductData | Record<string, any>;
41
+ /** UI 需展示的子弹窗开关。 */
42
+ showConfig: {
43
+ option: boolean;
44
+ session: boolean;
45
+ variant: boolean;
46
+ package: boolean;
47
+ number: boolean;
48
+ };
49
+ /** 仅 session 商品(且无 variant/option/package)→ true,UI 可只渲染 session 选择。 */
50
+ isOnlySession: boolean;
51
+ /** 0/1,与 info2 `getIsEject` 等价含义。 */
52
+ isEject: 0 | 1;
53
+ /** 当前选中客户 id(透传给 detail 弹窗用)。 */
54
+ customerId?: number | string;
55
+ /** 当前选择的日期。 */
56
+ date: string | null;
57
+ /** 透传完整商品数据,UI 渲染时直接用。 */
58
+ productData: ProductData | Record<string, any>;
59
+ }
60
+ export interface AddProductDecideContext extends BookingCalcContext {
61
+ type?: 'select' | 'detail';
62
+ quantity?: number;
63
+ customerId?: number | string;
64
+ }
65
+ /**
66
+ * 统一补齐预约商品的运行态字段。
67
+ *
68
+ * 新链路不再让决策和提交各自重建 cacheItem;这里作为唯一入口补齐
69
+ * `_extend.resource / capacity / startDate / endDate` 等后续 booking mapper 需要的字段。
70
+ */
71
+ export declare function prepareBookingCacheItem(cacheItem: any, ctx?: AddProductDecideContext): any;
72
+ export declare function decideAutoClose(item: any, ctx?: AddProductDecideContext): {
73
+ autoClose: boolean;
74
+ cacheItem?: any;
75
+ };
76
+ /**
77
+ * 替代 info2 `getIsEject`:商品是否需要弹窗(含 type='detail' / option_group / bundle_group / variant / session / sold_by_weight)。
78
+ */
79
+ export declare function getIsEject(item: any, type?: 'select' | 'detail'): 0 | 1;
80
+ /** 仅 session 商品(且没有 variant/option/package)。 */
81
+ export declare function getIsOnlySession(item: any): boolean;
82
+ /**
83
+ * 拼装 requiresDetail payload;showConfig 与 info2 弹窗内部判断一致。
84
+ */
85
+ export declare function buildRequiresDetailPayload(item: any, ctx?: AddProductDecideContext): AddProductRequiresDetailPayload;
86
+ /**
87
+ * 用 item.cartDetailValue 拼装一个 cacheItem 雏形(与 info2 `handleDirectAddService` 等价路径)。
88
+ * 这里只补 `_extend.start_date / quantity / other` 等运行态字段;后续走 getProductExtend 才会补齐资源 / 时间。
89
+ */
90
+ export declare function buildCacheItemFromCartDetail(item: any, ctx?: AddProductDecideContext): any;
91
+ /**
92
+ * 用 Info2 callback 的 (e, extension_type, detail) 拼装一个 cacheItem。
93
+ * 与 info2 `addService.tsx#handleSelectProduct.callback` 内的拼装等价(剥 pricing)。
94
+ */
95
+ export declare function buildCacheItemFromDetail(item: any, detailResult: {
96
+ e: any;
97
+ extension_type?: any;
98
+ detail?: any;
99
+ }, ctx?: AddProductDecideContext): any;
100
+ /**
101
+ * `transformDetailToProductAndBooking`:把 cacheItem 拆成 OS `addProductToOrder` 所需的 `(product, booking)`。
102
+ *
103
+ * - `product` 走 `transformBaseProductToOrderProduct`(沿用 BaseSales 现有 mapper)。
104
+ * - `booking` 走 `cacheItemToBookingInput`(严格按 TEMP_ORDER_FIELDS_SUMMARY.md 协议)。
105
+ * - 普通商品(无 duration / 无 schedules)不产 booking,与 info2 一致。
106
+ */
107
+ export declare function transformDetailToProductAndBooking(cacheItem: any, ctx?: AddProductDecideContext): {
108
+ product: Partial<OrderProduct> & OrderProductIdentity;
109
+ booking?: AddProductBookingInput;
110
+ cacheItem: any;
111
+ };