@pisell/pisellos 2.2.162 → 2.2.164

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 (116) 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 +107 -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 +17 -6
  34. package/dist/modules/Order/index.js +474 -287
  35. package/dist/modules/Order/types.d.ts +32 -12
  36. package/dist/modules/Order/utils.js +9 -8
  37. package/dist/modules/SalesSummary/index.js +4 -2
  38. package/dist/modules/index.d.ts +1 -0
  39. package/dist/modules/index.js +2 -1
  40. package/dist/solution/BaseSales/index.d.ts +38 -7
  41. package/dist/solution/BaseSales/index.js +797 -310
  42. package/dist/solution/BaseSales/types.d.ts +48 -1
  43. package/dist/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
  44. package/dist/solution/BaseSales/utils/quotationPrice.js +159 -0
  45. package/dist/solution/BookingByStep/index.d.ts +2 -2
  46. package/dist/solution/BookingTicket/index.d.ts +121 -1
  47. package/dist/solution/BookingTicket/index.js +401 -72
  48. package/dist/solution/BookingTicket/types.d.ts +2 -0
  49. package/dist/solution/BookingTicket/types.js +3 -0
  50. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +111 -0
  51. package/dist/solution/BookingTicket/utils/addProductDecision.js +326 -0
  52. package/dist/solution/ScanOrder/index.d.ts +9 -3
  53. package/dist/solution/ScanOrder/index.js +231 -128
  54. package/dist/solution/VenueBooking/index.d.ts +4 -2
  55. package/dist/solution/VenueBooking/index.js +103 -55
  56. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
  57. package/dist/solution/VenueBooking/utils/slotMerge.js +10 -0
  58. package/lib/model/strategy/adapter/promotion/index.js +0 -49
  59. package/lib/modules/BookingContext/index.d.ts +37 -0
  60. package/lib/modules/BookingContext/index.js +297 -0
  61. package/lib/modules/BookingContext/types.d.ts +102 -0
  62. package/lib/modules/BookingContext/types.js +34 -0
  63. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
  64. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +174 -0
  65. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
  66. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +115 -0
  67. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +65 -0
  68. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +177 -0
  69. package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
  70. package/lib/modules/BookingContext/utils/flexible.js +80 -0
  71. package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  72. package/lib/modules/BookingContext/utils/formatResourceList.js +50 -0
  73. package/lib/modules/BookingContext/utils/index.d.ts +11 -0
  74. package/lib/modules/BookingContext/utils/index.js +43 -0
  75. package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
  76. package/lib/modules/BookingContext/utils/noResource.js +90 -0
  77. package/lib/modules/BookingContext/utils/productExtend.d.ts +72 -0
  78. package/lib/modules/BookingContext/utils/productExtend.js +283 -0
  79. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  80. package/lib/modules/BookingContext/utils/resourceErrors.js +80 -0
  81. package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  82. package/lib/modules/BookingContext/utils/resourceSelection.js +46 -0
  83. package/lib/modules/BookingContext/utils/resources.d.ts +80 -0
  84. package/lib/modules/BookingContext/utils/resources.js +377 -0
  85. package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  86. package/lib/modules/BookingContext/utils/serviceTimes.js +162 -0
  87. package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  88. package/lib/modules/BookingContext/utils/timeSlices.js +124 -0
  89. package/lib/modules/Customer/index.js +8 -8
  90. package/lib/modules/Discount/index.js +5 -1
  91. package/lib/modules/Order/index.d.ts +17 -6
  92. package/lib/modules/Order/index.js +164 -68
  93. package/lib/modules/Order/types.d.ts +32 -12
  94. package/lib/modules/Order/utils.js +8 -6
  95. package/lib/modules/SalesSummary/index.js +4 -2
  96. package/lib/modules/index.d.ts +1 -0
  97. package/lib/modules/index.js +3 -1
  98. package/lib/solution/BaseSales/index.d.ts +38 -7
  99. package/lib/solution/BaseSales/index.js +304 -14
  100. package/lib/solution/BaseSales/types.d.ts +48 -1
  101. package/lib/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
  102. package/lib/solution/BaseSales/utils/quotationPrice.js +201 -0
  103. package/lib/solution/BookingByStep/index.d.ts +2 -2
  104. package/lib/solution/BookingTicket/index.d.ts +121 -1
  105. package/lib/solution/BookingTicket/index.js +207 -2
  106. package/lib/solution/BookingTicket/types.d.ts +2 -0
  107. package/lib/solution/BookingTicket/types.js +6 -0
  108. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +111 -0
  109. package/lib/solution/BookingTicket/utils/addProductDecision.js +300 -0
  110. package/lib/solution/ScanOrder/index.d.ts +9 -3
  111. package/lib/solution/ScanOrder/index.js +147 -66
  112. package/lib/solution/VenueBooking/index.d.ts +4 -2
  113. package/lib/solution/VenueBooking/index.js +50 -14
  114. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
  115. package/lib/solution/VenueBooking/utils/slotMerge.js +10 -0
  116. package/package.json +1 -1
@@ -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
+ };
@@ -0,0 +1,300 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/solution/BookingTicket/utils/addProductDecision.ts
30
+ var addProductDecision_exports = {};
31
+ __export(addProductDecision_exports, {
32
+ buildCacheItemFromCartDetail: () => buildCacheItemFromCartDetail,
33
+ buildCacheItemFromDetail: () => buildCacheItemFromDetail,
34
+ buildRequiresDetailPayload: () => buildRequiresDetailPayload,
35
+ decideAddProduct: () => decideAddProduct,
36
+ decideAfterDetail: () => decideAfterDetail,
37
+ decideAutoClose: () => decideAutoClose,
38
+ getIsEject: () => getIsEject,
39
+ getIsOnlySession: () => getIsOnlySession,
40
+ prepareBookingCacheItem: () => prepareBookingCacheItem,
41
+ transformDetailToProductAndBooking: () => transformDetailToProductAndBooking
42
+ });
43
+ module.exports = __toCommonJS(addProductDecision_exports);
44
+ var import_dayjs = __toESM(require("dayjs"));
45
+ var import_BookingContext = require("../../../modules/BookingContext");
46
+ var import_transformBaseProductToOrderProduct = require("../../BaseSales/utils/transformBaseProductToOrderProduct");
47
+ function needsSpecDetailModal(item) {
48
+ if (item == null ? void 0 : item.open_sold_weight)
49
+ return true;
50
+ if (item == null ? void 0 : item.isOpenDetailModal)
51
+ return true;
52
+ if (!(item == null ? void 0 : item.cartDetailValue))
53
+ return true;
54
+ return false;
55
+ }
56
+ function needsBookingEdit(cacheItem, ctx) {
57
+ if (isNormalBookingProduct(cacheItem))
58
+ return false;
59
+ const isAutoAllocationOn = (ctx == null ? void 0 : ctx.isAutoAllocationOn) || (() => true);
60
+ return !(0, import_BookingContext.getIsAutoClose)(cacheItem, isAutoAllocationOn);
61
+ }
62
+ function buildRequiresBookingEditPayload(cacheItem, ctx) {
63
+ return {
64
+ cacheItem,
65
+ customerId: ctx == null ? void 0 : ctx.customerId,
66
+ date: typeof (ctx == null ? void 0 : ctx.date) === "string" ? ctx.date : null
67
+ };
68
+ }
69
+ function decideAddProduct(item, ctx) {
70
+ const derivedCtx = withDerivedBookingCtx(ctx);
71
+ if (needsSpecDetailModal(item)) {
72
+ return {
73
+ action: "requiresDetail",
74
+ payload: buildRequiresDetailPayload(item, derivedCtx)
75
+ };
76
+ }
77
+ const cacheItem = prepareBookingCacheItem(
78
+ buildCacheItemFromCartDetail(item, derivedCtx),
79
+ derivedCtx
80
+ );
81
+ if (needsBookingEdit(cacheItem, derivedCtx)) {
82
+ return {
83
+ action: "requiresBookingEdit",
84
+ cacheItem,
85
+ payload: buildRequiresBookingEditPayload(cacheItem, derivedCtx)
86
+ };
87
+ }
88
+ return { action: "add", cacheItem };
89
+ }
90
+ function decideAfterDetail(cacheItem, ctx) {
91
+ const derivedCtx = withDerivedBookingCtx(ctx);
92
+ const extended = prepareBookingCacheItem(cacheItem, derivedCtx);
93
+ if (needsBookingEdit(extended, derivedCtx)) {
94
+ return {
95
+ action: "requiresBookingEdit",
96
+ cacheItem: extended,
97
+ payload: buildRequiresBookingEditPayload(extended, derivedCtx)
98
+ };
99
+ }
100
+ return { action: "add", cacheItem: extended };
101
+ }
102
+ function isNormalBookingProduct(item) {
103
+ return !(0, import_BookingContext.isBookingProduct)(item);
104
+ }
105
+ function hasPreparedBookingExtend(cacheItem) {
106
+ var _a;
107
+ if ((0, import_BookingContext.productNeedsResourceExtend)(cacheItem) && !(0, import_BookingContext.hasActualResourceSelection)(cacheItem)) {
108
+ return false;
109
+ }
110
+ const ext = (cacheItem == null ? void 0 : cacheItem._extend) || {};
111
+ const hasResourceState = Boolean(
112
+ (0, import_BookingContext.hasActualResourceSelection)(cacheItem) && ext.capacity && (ext.endDate || ext.end_date)
113
+ );
114
+ const hasSessionState = Boolean(
115
+ (0, import_BookingContext.isSessionProduct)(cacheItem) && ((_a = ext.other) == null ? void 0 : _a.session) && ext.start_time && (ext.end_time || ext.endDate)
116
+ );
117
+ const hasMultiDayState = Boolean(isNormalBookingProduct(cacheItem) === false && isMultiDayLike(cacheItem));
118
+ const hasExplicitTimeState = Boolean(
119
+ ext.duration && (ext.start_date || ext.startDate) && ext.start_time && (ext.end_date && ext.end_time || ext.endDate)
120
+ );
121
+ return hasResourceState || hasSessionState || hasMultiDayState || hasExplicitTimeState;
122
+ }
123
+ function formatBookingDateForUI(date) {
124
+ if (date == null || date === "")
125
+ return null;
126
+ const parsed = (0, import_dayjs.default)(date);
127
+ return parsed.isValid() ? parsed.format("YYYY-MM-DD") : null;
128
+ }
129
+ function withDerivedBookingCtx(ctx) {
130
+ if (!ctx)
131
+ return {};
132
+ return {
133
+ ...ctx,
134
+ presetStartTime: ctx.presetStartTime ?? (0, import_BookingContext.derivePresetStartTimeFromDate)(ctx.date)
135
+ };
136
+ }
137
+ function isMultiDayLike(cacheItem) {
138
+ var _a;
139
+ const ext = (cacheItem == null ? void 0 : cacheItem._extend) || {};
140
+ return Boolean(
141
+ ((_a = cacheItem == null ? void 0 : cacheItem.duration) == null ? void 0 : _a.type) === "days" && ext.duration && ext.start_date && ext.end_date
142
+ );
143
+ }
144
+ function prepareBookingCacheItem(cacheItem, ctx) {
145
+ if (isNormalBookingProduct(cacheItem) || hasPreparedBookingExtend(cacheItem)) {
146
+ return cacheItem;
147
+ }
148
+ return (0, import_BookingContext.getProductExtend)({
149
+ cacheItem,
150
+ ctx: withDerivedBookingCtx(ctx),
151
+ isDisabledTime: true
152
+ });
153
+ }
154
+ function decideAutoClose(item, ctx) {
155
+ const decision = decideAddProduct(item, ctx);
156
+ if (decision.action === "add") {
157
+ return { autoClose: true, cacheItem: decision.cacheItem };
158
+ }
159
+ if (decision.action === "requiresBookingEdit") {
160
+ return { autoClose: false, cacheItem: decision.cacheItem };
161
+ }
162
+ return { autoClose: false };
163
+ }
164
+ function getIsEject(item, type = "select") {
165
+ const isSession = (0, import_BookingContext.isSessionProduct)(item);
166
+ const isSoldByWeight = Boolean(item == null ? void 0 : item.open_sold_weight);
167
+ const need = type === "detail" || ((item == null ? void 0 : item.bundle_group_count) || 0) > 0 || ((item == null ? void 0 : item.option_group_count) || 0) > 0 || ((item == null ? void 0 : item.is_variant) || 0) > 0 || isSession || isSoldByWeight;
168
+ return need ? 1 : 0;
169
+ }
170
+ function getIsOnlySession(item) {
171
+ const isSession = (0, import_BookingContext.isSessionProduct)(item);
172
+ return !(((item == null ? void 0 : item.bundle_group_count) || 0) > 0 || ((item == null ? void 0 : item.option_group_count) || 0) > 0 || ((item == null ? void 0 : item.is_variant) || 0) > 0) && isSession;
173
+ }
174
+ function buildRequiresDetailPayload(item, ctx) {
175
+ const isOnlySession = getIsOnlySession(item);
176
+ const isEject = getIsEject(item, (ctx == null ? void 0 : ctx.type) || "select");
177
+ return {
178
+ item,
179
+ showConfig: {
180
+ option: ((item == null ? void 0 : item.option_group_count) || 0) > 0,
181
+ session: (0, import_BookingContext.isSessionProduct)(item),
182
+ variant: ((item == null ? void 0 : item.is_variant) || 0) > 0,
183
+ package: ((item == null ? void 0 : item.bundle_group_count) || 0) > 0,
184
+ number: Boolean(item == null ? void 0 : item.open_sold_weight)
185
+ },
186
+ isOnlySession,
187
+ isEject,
188
+ customerId: ctx == null ? void 0 : ctx.customerId,
189
+ date: formatBookingDateForUI(ctx == null ? void 0 : ctx.date),
190
+ productData: item
191
+ };
192
+ }
193
+ function buildCacheItemFromCartDetail(item, ctx) {
194
+ var _a;
195
+ const cartDetailValue = item.cartDetailValue || {};
196
+ const other = JSON.parse(JSON.stringify(cartDetailValue || {}));
197
+ other.session = cartDetailValue.session;
198
+ const resolvedId = item.id ?? item.product_id;
199
+ let extend = (0, import_BookingContext.applySessionTimesToExtend)(
200
+ item,
201
+ {
202
+ start_date: (ctx == null ? void 0 : ctx.date) || void 0,
203
+ quantity: (cartDetailValue == null ? void 0 : cartDetailValue.quantity) || (ctx == null ? void 0 : ctx.quantity) || 1,
204
+ product_name: item.title,
205
+ other,
206
+ isNormalProduct: !(0, import_BookingContext.isBookingProduct)(item),
207
+ price: ((_a = item == null ? void 0 : item._extend) == null ? void 0 : _a.price) ?? (item == null ? void 0 : item.price)
208
+ },
209
+ { date: ctx == null ? void 0 : ctx.date }
210
+ );
211
+ return {
212
+ ...item,
213
+ id: resolvedId,
214
+ product_id: resolvedId,
215
+ _key: cartDetailValue.key,
216
+ _extend: extend,
217
+ new: 1
218
+ };
219
+ }
220
+ function buildCacheItemFromDetail(item, detailResult, ctx) {
221
+ var _a, _b, _c;
222
+ const _currentItem = detailResult.detail || item;
223
+ const _detail = _currentItem;
224
+ const other = JSON.parse(JSON.stringify(detailResult.e || {}));
225
+ other.session = (_a = detailResult.e) == null ? void 0 : _a.session;
226
+ const resolvedId = _currentItem.id ?? _currentItem.product_id;
227
+ const mergedItem = { ...item, ..._detail, extension_type: _detail.extension_type ?? item.extension_type };
228
+ const extend = (0, import_BookingContext.applySessionTimesToExtend)(
229
+ mergedItem,
230
+ {
231
+ start_date: (ctx == null ? void 0 : ctx.date) || void 0,
232
+ quantity: ((_b = detailResult.e) == null ? void 0 : _b.quantity) || (ctx == null ? void 0 : ctx.quantity) || 1,
233
+ price: _detail == null ? void 0 : _detail.price,
234
+ product_name: _currentItem.title,
235
+ other,
236
+ isNormalProduct: !(0, import_BookingContext.isBookingProduct)(mergedItem)
237
+ },
238
+ { date: ctx == null ? void 0 : ctx.date }
239
+ );
240
+ return {
241
+ ..._detail,
242
+ id: resolvedId,
243
+ product_id: resolvedId,
244
+ extension_type: mergedItem.extension_type,
245
+ _key: (_c = detailResult.e) == null ? void 0 : _c.key,
246
+ _extend: extend,
247
+ new: 1
248
+ };
249
+ }
250
+ function transformDetailToProductAndBooking(cacheItem, ctx) {
251
+ const preparedCacheItem = prepareBookingCacheItem(cacheItem, withDerivedBookingCtx(ctx));
252
+ const payload = buildBasePayloadFromCacheItem(preparedCacheItem, ctx);
253
+ const productInput = (0, import_transformBaseProductToOrderProduct.transformBaseProductToOrderProduct)({
254
+ payload,
255
+ sourceProduct: preparedCacheItem
256
+ });
257
+ if (!productInput) {
258
+ throw new Error(
259
+ "[BookingTicket] transformDetailToProductAndBooking: product transform failed (missing numeric item.id / item.product_id)"
260
+ );
261
+ }
262
+ const isNormalProduct = isNormalBookingProduct(preparedCacheItem);
263
+ let booking;
264
+ if (!isNormalProduct) {
265
+ booking = (0, import_BookingContext.cacheItemToBookingInput)(preparedCacheItem, { bookingConfig: ctx == null ? void 0 : ctx.bookingConfig });
266
+ }
267
+ return { product: productInput, booking, cacheItem: preparedCacheItem };
268
+ }
269
+ function buildBasePayloadFromCacheItem(cacheItem, ctx) {
270
+ var _a, _b, _c, _d, _e;
271
+ const other = ((_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.other) || {};
272
+ const quantity = ((_b = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _b.quantity) ?? (ctx == null ? void 0 : ctx.quantity) ?? 1;
273
+ const resolvedPid = (cacheItem == null ? void 0 : cacheItem.product_id) ?? (cacheItem == null ? void 0 : cacheItem.id);
274
+ return {
275
+ id: (cacheItem == null ? void 0 : cacheItem.id) ?? (cacheItem == null ? void 0 : cacheItem.product_id),
276
+ product_id: resolvedPid,
277
+ variant_id: (other == null ? void 0 : other.product_variant_id) ?? (other == null ? void 0 : other.variant_id) ?? 0,
278
+ quantity,
279
+ option: (other == null ? void 0 : other.option) || [],
280
+ bundle: (other == null ? void 0 : other.bundle) || [],
281
+ unique: other == null ? void 0 : other.unique,
282
+ session: other == null ? void 0 : other.session,
283
+ note: (_c = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _c.note,
284
+ price: ((_d = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _d.price) ?? (cacheItem == null ? void 0 : cacheItem.price),
285
+ selling_price: ((_e = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _e.price) ?? (cacheItem == null ? void 0 : cacheItem.price)
286
+ };
287
+ }
288
+ // Annotate the CommonJS export names for ESM import in node:
289
+ 0 && (module.exports = {
290
+ buildCacheItemFromCartDetail,
291
+ buildCacheItemFromDetail,
292
+ buildRequiresDetailPayload,
293
+ decideAddProduct,
294
+ decideAfterDetail,
295
+ decideAutoClose,
296
+ getIsEject,
297
+ getIsOnlySession,
298
+ prepareBookingCacheItem,
299
+ transformDetailToProductAndBooking
300
+ });
@@ -1,10 +1,11 @@
1
1
  import { Module, ModuleOptions, PisellCore } from '../../types';
2
2
  import { BaseModule } from '../../modules/BaseModule';
3
3
  import { ScanOrderAddLogParams, ScanOrderAvailabilityInfo, ScanOrderOrderProduct, ScanOrderOrderProductIdentity, ScanOrderScanCodeResult } from './types';
4
- import type { UpdateProductInOrderParams } from '../../modules/Order/types';
4
+ import type { UpdateOrderProductParams } from '../../modules/Order/types';
5
5
  import type { Discount } from '../../modules/Discount/types';
6
6
  import { type CartItemSummary, type PaxInfo, type QuantityCheckResult, type QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
7
7
  import type { StrategyConfig } from '../../model/strategy/type';
8
+ import type { ProductData } from '../../modules/Product/types';
8
9
  export * from './types';
9
10
  interface ScanOrderItemRuleRuntimeConfig {
10
11
  strategyConfigs?: StrategyConfig[];
@@ -36,11 +37,14 @@ export declare class ScanOrderImpl extends BaseModule implements Module {
36
37
  private customerLoginRefreshIdInFlight;
37
38
  private static readonly PISELL1_LOGIN_SUCCESS;
38
39
  private getScanOrderLoggerContext;
40
+ private safeStringify;
41
+ private pickErrorMessage;
39
42
  private serializeError;
40
43
  private addScanOrderLog;
41
44
  private logMethodStart;
42
45
  private logMethodSuccess;
43
46
  private logMethodError;
47
+ private assertProductListLoaded;
44
48
  addLog(params: ScanOrderAddLogParams): Promise<void>;
45
49
  private normalizeCustomerId;
46
50
  private resolveCustomerIdFromLoginPayload;
@@ -86,10 +90,12 @@ export declare class ScanOrderImpl extends BaseModule implements Module {
86
90
  onCustomerLogin(params: {
87
91
  customerId: number;
88
92
  }): Promise<void>;
93
+ private findReservationRuleResource;
94
+ private buildScanOrderResourceMetadata;
89
95
  private buildSubmitPayloadEnhancer;
90
96
  submitScanOrder<T = any>(): Promise<T>;
91
97
  addProductToOrder(product: Partial<ScanOrderOrderProduct> & ScanOrderOrderProductIdentity): Promise<import("../../modules/Order/types").OrderProduct[]>;
92
- updateProductInOrder(params: UpdateProductInOrderParams): Promise<import("../../modules/Order/types").OrderProduct[]>;
98
+ updateOrderProduct(params: UpdateOrderProductParams): Promise<import("../../modules/Order/types").OrderProduct[]>;
93
99
  /**
94
100
  * 设置单行商品备注(与整单 `updateTempOrderNote` 区分)。
95
101
  * 多行同 SKU 时必须传入与删除/更新一致的 identity(如 `identity_key`)。
@@ -120,7 +126,7 @@ export declare class ScanOrderImpl extends BaseModule implements Module {
120
126
  orderAmount: number;
121
127
  orderItems: any[];
122
128
  }>;
123
- getProductList(): Promise<any>;
129
+ getProductList(): Promise<ProductData[]>;
124
130
  getOtherParams(): Record<string, any>;
125
131
  setOtherParams(params: Record<string, any>, { cover }?: {
126
132
  cover?: boolean;