@pisell/pisellos 2.3.132 → 2.3.134

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 (27) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  2. package/dist/modules/Order/index.d.ts +1 -1
  3. package/dist/solution/BookingByStep/index.d.ts +1 -1
  4. package/dist/solution/VenueBooking/index.d.ts +15 -2
  5. package/dist/solution/VenueBooking/index.js +1036 -760
  6. package/dist/solution/VenueBooking/types.d.ts +2 -1
  7. package/dist/solution/VenueBooking/types.js +1 -0
  8. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
  9. package/dist/solution/VenueBooking/utils/dateSummary.js +7 -4
  10. package/dist/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
  11. package/dist/solution/VenueBooking/utils/smartPricing.js +273 -0
  12. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +1 -0
  13. package/dist/solution/VenueBooking/utils/timeSlot.js +6 -3
  14. package/lib/model/strategy/adapter/promotion/index.js +46 -1
  15. package/lib/modules/Order/index.d.ts +1 -1
  16. package/lib/solution/BookingByStep/index.d.ts +1 -1
  17. package/lib/solution/VenueBooking/index.d.ts +15 -2
  18. package/lib/solution/VenueBooking/index.js +234 -88
  19. package/lib/solution/VenueBooking/types.d.ts +2 -1
  20. package/lib/solution/VenueBooking/types.js +1 -0
  21. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
  22. package/lib/solution/VenueBooking/utils/dateSummary.js +7 -4
  23. package/lib/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
  24. package/lib/solution/VenueBooking/utils/smartPricing.js +224 -0
  25. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +1 -0
  26. package/lib/solution/VenueBooking/utils/timeSlot.js +5 -2
  27. package/package.json +1 -1
@@ -7,7 +7,8 @@ export declare enum VenueBookingHooks {
7
7
  onDestroy = "venueBooking:onDestroy",
8
8
  onRetryInit = "venueBooking:onRetryInit",
9
9
  onRefresh = "venueBooking:onRefresh",
10
- onCartValidationChanged = "venueBooking:onCartValidationChanged"
10
+ onCartValidationChanged = "venueBooking:onCartValidationChanged",
11
+ onSmartPricingUpdated = "venueBooking:onSmartPricingUpdated"
11
12
  }
12
13
  export type VenueBookingStatus = 'idle' | 'initializing' | 'ready' | 'error';
13
14
  export interface VenueBookingEntryContext {
@@ -4,6 +4,7 @@ export var VenueBookingHooks = /*#__PURE__*/function (VenueBookingHooks) {
4
4
  VenueBookingHooks["onRetryInit"] = "venueBooking:onRetryInit";
5
5
  VenueBookingHooks["onRefresh"] = "venueBooking:onRefresh";
6
6
  VenueBookingHooks["onCartValidationChanged"] = "venueBooking:onCartValidationChanged";
7
+ VenueBookingHooks["onSmartPricingUpdated"] = "venueBooking:onSmartPricingUpdated";
7
8
  return VenueBookingHooks;
8
9
  }({});
9
10
 
@@ -9,4 +9,5 @@ export declare function buildDateRangeSummary(params: {
9
9
  quotationModule?: QuotationModule;
10
10
  channel?: string;
11
11
  resolveConfig?: (date: string) => VenueBookingSlotConfig;
12
+ buildSlotPriceMap?: (date: string, config: VenueBookingSlotConfig, productIds: number[]) => Map<string, string | null>;
12
13
  }): VenueDateSummaryItem[];
@@ -15,9 +15,10 @@ export function buildDateRangeSummary(params) {
15
15
  resourceProductMap = params.resourceProductMap,
16
16
  quotationModule = params.quotationModule,
17
17
  channel = params.channel,
18
- resolveConfig = params.resolveConfig;
18
+ resolveConfig = params.resolveConfig,
19
+ buildSlotPriceMap = params.buildSlotPriceMap;
19
20
  var result = [];
20
- var productIds = quotationModule ? _toConsumableArray(new Set(_toConsumableArray(resourceProductMap.values()).flat().map(function (m) {
21
+ var productIds = buildSlotPriceMap || quotationModule ? _toConsumableArray(new Set(_toConsumableArray(resourceProductMap.values()).flat().map(function (m) {
21
22
  return m.productId;
22
23
  }))) : [];
23
24
  var cursor = dayjs(startDate);
@@ -26,7 +27,8 @@ export function buildDateRangeSummary(params) {
26
27
  var date = cursor.format('YYYY-MM-DD');
27
28
  var effectiveConfig = (resolveConfig === null || resolveConfig === void 0 ? void 0 : resolveConfig(date)) || config;
28
29
  var quotationPriceMap;
29
- if (quotationModule && productIds.length) {
30
+ var slotPriceMap = buildSlotPriceMap === null || buildSlotPriceMap === void 0 ? void 0 : buildSlotPriceMap(date, effectiveConfig, productIds);
31
+ if (!slotPriceMap && quotationModule && productIds.length) {
30
32
  var timeLabels = generateTimeLabels(effectiveConfig);
31
33
  var timePoints = timeLabels.map(function (label) {
32
34
  return "".concat(date, " ").concat(label);
@@ -42,7 +44,8 @@ export function buildDateRangeSummary(params) {
42
44
  config: effectiveConfig,
43
45
  rawResources: rawResources,
44
46
  resourceProductMap: resourceProductMap,
45
- quotationPriceMap: quotationPriceMap
47
+ quotationPriceMap: quotationPriceMap,
48
+ slotPriceMap: slotPriceMap
46
49
  });
47
50
  var totalSlots = 0;
48
51
  var availableSlots = 0;
@@ -0,0 +1,71 @@
1
+ import type { ProductData } from '../../../modules/Product/types';
2
+ import type { ScheduleItem } from '../../../modules/Schedule/types';
3
+ import type { DataVariantBusinessData, DataVariantMenu, DataVariantProduct } from '../../../model/strategy/adapter/dataVariant/type';
4
+ import type { DataVariantEvaluator } from '../../../model/strategy/adapter/dataVariant/evaluator';
5
+ import type { StrategyConfig } from '../../../model/strategy/type';
6
+ import type { VenueBookingSlotConfig } from '../types';
7
+ /** VenueBooking 智能定价运行时上下文 */
8
+ export interface VenueBookingSmartPricingContext {
9
+ evaluator?: DataVariantEvaluator | null;
10
+ scheduleList?: ScheduleItem[];
11
+ menuList?: DataVariantMenu[];
12
+ customerId?: number | string;
13
+ availableWalletIds?: Array<number | string>;
14
+ channel?: string;
15
+ businessCode?: string;
16
+ orderType?: string;
17
+ strategy_context?: Record<string, any>;
18
+ strategyConfigs?: StrategyConfig[];
19
+ }
20
+ /** 从商品上读取展示/算价用的 price 字段 */
21
+ export declare function extractProductPrice(product: DataVariantProduct): string | null;
22
+ /** 组装 DataVariant 评估入参,对齐 OS Server buildProductFormatterContext 语义 */
23
+ export declare function buildDataVariantBusinessData(products: ProductData[], context: VenueBookingSmartPricingContext, scheduleDateTime: string): DataVariantBusinessData;
24
+ /**
25
+ * 对商品列表执行一次智能定价格式化(loadProducts 后使用)。
26
+ * evaluator 未注入时原样返回并打 warning。
27
+ */
28
+ export declare function formatProductsWithDataVariant(products: ProductData[], context: VenueBookingSmartPricingContext, scheduleDateTime?: string): ProductData[];
29
+ /**
30
+ * 根据 schedule_time_points 与营业开始时间,构造当天需要评估的 datetime 列表(升序)。
31
+ * 跨日营业时,早于营业开始小时的时间点归到次日。
32
+ */
33
+ export declare function buildEvaluationDatetimes(params: {
34
+ date: string;
35
+ config: VenueBookingSlotConfig;
36
+ scheduleTimePoints: string[];
37
+ }): string[];
38
+ /** 找到 slot 时间所属分段的评估 datetime(max(evalDt <= slotDt)) */
39
+ export declare function findSegmentEvalDatetime(slotDatetime: string, evalDatetimes: string[]): string;
40
+ /** 将 slot 标签转为与 timeSlot 网格一致的 slotStart 字符串 */
41
+ export declare function buildSlotStartDatetime(date: string, label: string, config: VenueBookingSlotConfig): string;
42
+ /**
43
+ * 按 schedule 分段批量 resolveProducts,输出与 quotation 相同 key 格式的 slot 价格 Map。
44
+ * key: `${productId}:${slotStart}`,value: price | null
45
+ */
46
+ export declare function buildSlotPriceMapByScheduleSegments(params: {
47
+ products: ProductData[];
48
+ productIds: number[];
49
+ date: string;
50
+ timeLabels: string[];
51
+ config: VenueBookingSlotConfig;
52
+ context: VenueBookingSmartPricingContext;
53
+ }): Map<string, string | null>;
54
+ /**
55
+ * 指定商品在某一 datetime 的智能定价(addon / 单点重算用)。
56
+ */
57
+ export declare function getPriceForProductAtDatetime(params: {
58
+ products: ProductData[];
59
+ context: VenueBookingSmartPricingContext;
60
+ productId: number;
61
+ variantId?: number;
62
+ datetime: string;
63
+ fallbackPrice?: string;
64
+ }): string;
65
+ /** 从 slot 价格 Map 读取单价,找不到则回退 fallback */
66
+ export declare function getSlotPriceFromMap(params: {
67
+ slotPriceMap: Map<string, string | null>;
68
+ productId: number;
69
+ slotStartTime: string;
70
+ fallbackPrice?: string;
71
+ }): string;
@@ -0,0 +1,273 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
9
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
+ import dayjs from 'dayjs';
11
+ import { isBusinessHoursCrossDay } from "./timeSlot";
12
+
13
+ /** VenueBooking 智能定价运行时上下文 */
14
+
15
+ /** 从商品上读取展示/算价用的 price 字段 */
16
+ export function extractProductPrice(product) {
17
+ var _product$price;
18
+ var price = (_product$price = product === null || product === void 0 ? void 0 : product.price) !== null && _product$price !== void 0 ? _product$price : product === null || product === void 0 ? void 0 : product.selling_price;
19
+ if (price == null || price === '') return null;
20
+ return String(price);
21
+ }
22
+
23
+ /** 组装 DataVariant 评估入参,对齐 OS Server buildProductFormatterContext 语义 */
24
+ export function buildDataVariantBusinessData(products, context, scheduleDateTime) {
25
+ var _ref, _context$availableWal, _context$channel, _ref2, _context$orderType, _ref3, _context$businessCode;
26
+ var strategyContext = context.strategy_context || {};
27
+ return {
28
+ products: products,
29
+ strategyConfigs: context.strategyConfigs,
30
+ scheduleDateTime: scheduleDateTime,
31
+ scheduleList: context.scheduleList || [],
32
+ menuList: context.menuList || [],
33
+ customerId: context.customerId,
34
+ availableWalletIds: (_ref = (_context$availableWal = context.availableWalletIds) !== null && _context$availableWal !== void 0 ? _context$availableWal : strategyContext.available_wallet_ids) !== null && _ref !== void 0 ? _ref : strategyContext.availableWalletIds,
35
+ channel: (_context$channel = context.channel) !== null && _context$channel !== void 0 ? _context$channel : strategyContext.channel,
36
+ orderType: (_ref2 = (_context$orderType = context.orderType) !== null && _context$orderType !== void 0 ? _context$orderType : strategyContext.orderType) !== null && _ref2 !== void 0 ? _ref2 : strategyContext.order_type,
37
+ businessCode: (_ref3 = (_context$businessCode = context.businessCode) !== null && _context$businessCode !== void 0 ? _context$businessCode : strategyContext.business_code) !== null && _ref3 !== void 0 ? _ref3 : strategyContext.businessCode,
38
+ custom: strategyContext
39
+ };
40
+ }
41
+
42
+ /**
43
+ * 对商品列表执行一次智能定价格式化(loadProducts 后使用)。
44
+ * evaluator 未注入时原样返回并打 warning。
45
+ */
46
+ export function formatProductsWithDataVariant(products, context, scheduleDateTime) {
47
+ var evaluator = context.evaluator;
48
+ if (!evaluator || typeof evaluator.resolveProducts !== 'function') {
49
+ console.warn('[VenueBooking][smartPricing] dataVariantEvaluator 未注入,跳过智能定价格式化');
50
+ return products;
51
+ }
52
+
53
+ // 日程包含结束边界,向后偏移一秒评估,避免前一时段的定价规则覆盖当前时段。
54
+ // 仅调整规则匹配时间,预约时间和分段缓存 key 仍保留原值。
55
+ var resolvedAt = dayjs(scheduleDateTime || undefined).add(1, 'second').format('YYYY-MM-DD HH:mm:ss');
56
+ // 接口的命中 ID 对应商品查询时刻,不能用于另一个预约时段/客户。
57
+ // 仅处理本次评估副本,保留目录中的原始数据。
58
+ var pricingProducts = products.map(function (product) {
59
+ var _product$base_price;
60
+ var metadata = _objectSpread({}, product.metadata);
61
+ var hasResolvedVariants = Array.isArray(metadata.data_variant_ids);
62
+ delete metadata.data_variant_ids;
63
+ return _objectSpread(_objectSpread({}, product), {}, {
64
+ price: hasResolvedVariants ? (_product$base_price = product.base_price) !== null && _product$base_price !== void 0 ? _product$base_price : product.price : product.price,
65
+ metadata: metadata
66
+ });
67
+ });
68
+ var businessData = buildDataVariantBusinessData(pricingProducts, context, resolvedAt);
69
+ var result = evaluator.resolveProducts(businessData);
70
+ return Array.isArray(result === null || result === void 0 ? void 0 : result.products) ? result.products : products;
71
+ }
72
+
73
+ /**
74
+ * 根据 schedule_time_points 与营业开始时间,构造当天需要评估的 datetime 列表(升序)。
75
+ * 跨日营业时,早于营业开始小时的时间点归到次日。
76
+ */
77
+ export function buildEvaluationDatetimes(params) {
78
+ var date = params.date,
79
+ config = params.config,
80
+ scheduleTimePoints = params.scheduleTimePoints;
81
+ var crossDay = isBusinessHoursCrossDay(config);
82
+ var businessStartHour = Number(config.businessStartTime.split(':')[0]);
83
+ var evalSet = new Set();
84
+ evalSet.add("".concat(date, " ").concat(config.businessStartTime));
85
+ if (crossDay) {
86
+ // 即使规则没有显式 00:00 时间点,日期/星期变化也可能切换适用规则。
87
+ evalSet.add("".concat(dayjs(date).add(1, 'day').format('YYYY-MM-DD'), " 00:00"));
88
+ }
89
+ var _iterator = _createForOfIteratorHelper(scheduleTimePoints),
90
+ _step;
91
+ try {
92
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
93
+ var timePoint = _step.value;
94
+ var hour = Number(timePoint.split(':')[0]);
95
+ var pointDate = crossDay && hour < businessStartHour ? dayjs(date).add(1, 'day').format('YYYY-MM-DD') : date;
96
+ evalSet.add("".concat(pointDate, " ").concat(timePoint));
97
+ }
98
+ } catch (err) {
99
+ _iterator.e(err);
100
+ } finally {
101
+ _iterator.f();
102
+ }
103
+ return Array.from(evalSet).sort(function (a, b) {
104
+ var aMs = dayjs(a, ['YYYY-MM-DD HH:mm:ss', 'YYYY-MM-DD HH:mm']).valueOf();
105
+ var bMs = dayjs(b, ['YYYY-MM-DD HH:mm:ss', 'YYYY-MM-DD HH:mm']).valueOf();
106
+ return aMs - bMs;
107
+ });
108
+ }
109
+
110
+ /** 找到 slot 时间所属分段的评估 datetime(max(evalDt <= slotDt)) */
111
+ export function findSegmentEvalDatetime(slotDatetime, evalDatetimes) {
112
+ if (!evalDatetimes.length) return slotDatetime;
113
+ var slotMs = dayjs(slotDatetime, ['YYYY-MM-DD HH:mm:ss', 'YYYY-MM-DD HH:mm']).valueOf();
114
+ var chosen = evalDatetimes[0];
115
+ var _iterator2 = _createForOfIteratorHelper(evalDatetimes),
116
+ _step2;
117
+ try {
118
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
119
+ var evalDt = _step2.value;
120
+ var evalMs = dayjs(evalDt, ['YYYY-MM-DD HH:mm:ss', 'YYYY-MM-DD HH:mm']).valueOf();
121
+ if (evalMs <= slotMs) {
122
+ chosen = evalDt;
123
+ } else {
124
+ break;
125
+ }
126
+ }
127
+ } catch (err) {
128
+ _iterator2.e(err);
129
+ } finally {
130
+ _iterator2.f();
131
+ }
132
+ return chosen;
133
+ }
134
+
135
+ /** 将 slot 标签转为与 timeSlot 网格一致的 slotStart 字符串 */
136
+ export function buildSlotStartDatetime(date, label, config) {
137
+ var crossDay = isBusinessHoursCrossDay(config);
138
+ var businessStartHour = Number(config.businessStartTime.split(':')[0]);
139
+ var hour = Number(label.split(':')[0]);
140
+ var slotDate = crossDay && hour < businessStartHour ? dayjs(date).add(1, 'day').format('YYYY-MM-DD') : date;
141
+ return dayjs("".concat(slotDate, " ").concat(label)).format('YYYY-MM-DD HH:mm');
142
+ }
143
+
144
+ /**
145
+ * 按 schedule 分段批量 resolveProducts,输出与 quotation 相同 key 格式的 slot 价格 Map。
146
+ * key: `${productId}:${slotStart}`,value: price | null
147
+ */
148
+ export function buildSlotPriceMapByScheduleSegments(params) {
149
+ var products = params.products,
150
+ productIds = params.productIds,
151
+ date = params.date,
152
+ timeLabels = params.timeLabels,
153
+ config = params.config,
154
+ context = params.context;
155
+ var map = new Map();
156
+ if (!productIds.length || !timeLabels.length) return map;
157
+ var evaluator = context.evaluator;
158
+ if (!evaluator || typeof evaluator.resolveProducts !== 'function') return map;
159
+ var strategyConfigs = context.strategyConfigs || (typeof evaluator.getStrategyConfigs === 'function' ? evaluator.getStrategyConfigs() : []);
160
+ var scheduleTimePoints = typeof evaluator.buildScheduleTimePoints === 'function' ? evaluator.buildScheduleTimePoints(strategyConfigs, context.scheduleList || []) : [];
161
+ var evalDatetimes = buildEvaluationDatetimes({
162
+ date: date,
163
+ config: config,
164
+ scheduleTimePoints: scheduleTimePoints
165
+ });
166
+ var priceCache = new Map();
167
+ var _iterator3 = _createForOfIteratorHelper(evalDatetimes),
168
+ _step3;
169
+ try {
170
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
171
+ var evalDt = _step3.value;
172
+ var resolved = formatProductsWithDataVariant(products, context, evalDt);
173
+ var priceByProductId = new Map();
174
+ var _iterator5 = _createForOfIteratorHelper(resolved),
175
+ _step5;
176
+ try {
177
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
178
+ var product = _step5.value;
179
+ var productId = Number(product.id);
180
+ if (!Number.isFinite(productId)) continue;
181
+ priceByProductId.set(productId, extractProductPrice(product));
182
+ }
183
+ } catch (err) {
184
+ _iterator5.e(err);
185
+ } finally {
186
+ _iterator5.f();
187
+ }
188
+ priceCache.set(evalDt, priceByProductId);
189
+ }
190
+ } catch (err) {
191
+ _iterator3.e(err);
192
+ } finally {
193
+ _iterator3.f();
194
+ }
195
+ var _iterator4 = _createForOfIteratorHelper(timeLabels),
196
+ _step4;
197
+ try {
198
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
199
+ var label = _step4.value;
200
+ var slotStart = buildSlotStartDatetime(date, label, config);
201
+ var segmentEvalDt = findSegmentEvalDatetime(slotStart, evalDatetimes);
202
+ var _priceByProductId = priceCache.get(segmentEvalDt);
203
+ var _iterator6 = _createForOfIteratorHelper(productIds),
204
+ _step6;
205
+ try {
206
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
207
+ var _priceByProductId$get;
208
+ var _productId = _step6.value;
209
+ var key = "".concat(_productId, ":").concat(slotStart);
210
+ var price = (_priceByProductId$get = _priceByProductId === null || _priceByProductId === void 0 ? void 0 : _priceByProductId.get(_productId)) !== null && _priceByProductId$get !== void 0 ? _priceByProductId$get : null;
211
+ if (price !== null) {
212
+ map.set(key, price);
213
+ }
214
+ }
215
+ } catch (err) {
216
+ _iterator6.e(err);
217
+ } finally {
218
+ _iterator6.f();
219
+ }
220
+ }
221
+ } catch (err) {
222
+ _iterator4.e(err);
223
+ } finally {
224
+ _iterator4.f();
225
+ }
226
+ return map;
227
+ }
228
+
229
+ /**
230
+ * 指定商品在某一 datetime 的智能定价(addon / 单点重算用)。
231
+ */
232
+ export function getPriceForProductAtDatetime(params) {
233
+ var _ref6, _extractProductPrice;
234
+ var products = params.products,
235
+ context = params.context,
236
+ productId = params.productId,
237
+ variantId = params.variantId,
238
+ datetime = params.datetime,
239
+ fallbackPrice = params.fallbackPrice;
240
+ var selectedProducts = products.filter(function (product) {
241
+ return Number(product.id) === Number(productId);
242
+ }).map(function (product) {
243
+ var _product$variant, _ref4, _variant$price, _ref5, _variant$base_price;
244
+ if (!variantId) return product;
245
+ var variant = (_product$variant = product.variant) === null || _product$variant === void 0 ? void 0 : _product$variant.find(function (item) {
246
+ return Number(item.id) === Number(variantId);
247
+ });
248
+ if (!variant) return product;
249
+ return _objectSpread(_objectSpread({}, product), {}, {
250
+ product_variant_id: variantId,
251
+ variant_id: variantId,
252
+ price: (_ref4 = (_variant$price = variant.price) !== null && _variant$price !== void 0 ? _variant$price : variant.base_price) !== null && _ref4 !== void 0 ? _ref4 : product.price,
253
+ base_price: (_ref5 = (_variant$base_price = variant.base_price) !== null && _variant$base_price !== void 0 ? _variant$base_price : variant.price) !== null && _ref5 !== void 0 ? _ref5 : product.base_price
254
+ });
255
+ });
256
+ var resolved = formatProductsWithDataVariant(selectedProducts, context, datetime);
257
+ var product = resolved.find(function (item) {
258
+ return Number(item.id) === Number(productId);
259
+ });
260
+ return (_ref6 = (_extractProductPrice = extractProductPrice(product || {})) !== null && _extractProductPrice !== void 0 ? _extractProductPrice : fallbackPrice) !== null && _ref6 !== void 0 ? _ref6 : '0.00';
261
+ }
262
+
263
+ /** 从 slot 价格 Map 读取单价,找不到则回退 fallback */
264
+ export function getSlotPriceFromMap(params) {
265
+ var slotPriceMap = params.slotPriceMap,
266
+ productId = params.productId,
267
+ slotStartTime = params.slotStartTime,
268
+ fallbackPrice = params.fallbackPrice;
269
+ var key = "".concat(productId, ":").concat(slotStartTime);
270
+ var mapped = slotPriceMap.get(key);
271
+ if (mapped != null) return mapped;
272
+ return fallbackPrice !== null && fallbackPrice !== void 0 ? fallbackPrice : '0.00';
273
+ }
@@ -28,5 +28,6 @@ export declare function buildTimeSlotGrid(params: {
28
28
  rawResources: VenueResourceRawData[];
29
29
  resourceProductMap: Map<number | string, ResourceProductMapping[]>;
30
30
  quotationPriceMap?: Map<string, string | null>;
31
+ slotPriceMap?: Map<string, string | null>;
31
32
  }): VenueTimeSlotGrid;
32
33
  export {};
@@ -230,6 +230,7 @@ function buildProductSlots(params) {
230
230
  now = params.now,
231
231
  crossDay = params.crossDay,
232
232
  quotationPriceMap = params.quotationPriceMap,
233
+ slotPriceMap = params.slotPriceMap,
233
234
  childRawResources = params.childRawResources,
234
235
  childTimesCache = params.childTimesCache,
235
236
  childEventsCache = params.childEventsCache,
@@ -239,7 +240,7 @@ function buildProductSlots(params) {
239
240
  _step7;
240
241
  try {
241
242
  for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
242
- var _quotationPriceMap$ge;
243
+ var _get, _ref;
243
244
  var label = _step7.value;
244
245
  var _label$split$map = label.split(':').map(Number),
245
246
  _label$split$map2 = _slicedToArray(_label$split$map, 1),
@@ -302,7 +303,7 @@ function buildProductSlots(params) {
302
303
  startTime: slotStartStr,
303
304
  endTime: slotEnd.format('YYYY-MM-DD HH:mm'),
304
305
  status: status,
305
- price: isBookable ? (_quotationPriceMap$ge = quotationPriceMap === null || quotationPriceMap === void 0 ? void 0 : quotationPriceMap.get("".concat(mapping.productId, ":").concat(slotStartStr))) !== null && _quotationPriceMap$ge !== void 0 ? _quotationPriceMap$ge : mapping.price : null,
306
+ price: isBookable ? (_get = (_ref = slotPriceMap !== null && slotPriceMap !== void 0 ? slotPriceMap : quotationPriceMap) === null || _ref === void 0 ? void 0 : _ref.get("".concat(mapping.productId, ":").concat(slotStartStr))) !== null && _get !== void 0 ? _get : mapping.price : null,
306
307
  resourceId: resource.resourceId,
307
308
  resourceFormId: resource.formId,
308
309
  capacity: status === 'past' || status === 'unavailable' ? null : resCapacity,
@@ -322,7 +323,8 @@ export function buildTimeSlotGrid(params) {
322
323
  config = params.config,
323
324
  rawResources = params.rawResources,
324
325
  resourceProductMap = params.resourceProductMap,
325
- quotationPriceMap = params.quotationPriceMap;
326
+ quotationPriceMap = params.quotationPriceMap,
327
+ slotPriceMap = params.slotPriceMap;
326
328
  var timeLabels = generateTimeLabels(config);
327
329
  var now = dayjs();
328
330
  var crossDay = isBusinessHoursCrossDay(config);
@@ -378,6 +380,7 @@ export function buildTimeSlotGrid(params) {
378
380
  now: now,
379
381
  crossDay: crossDay,
380
382
  quotationPriceMap: quotationPriceMap,
383
+ slotPriceMap: slotPriceMap,
381
384
  childRawResources: childRawResources,
382
385
  childTimesCache: childTimesCache,
383
386
  childEventsCache: childEventsCache,
@@ -1 +1,46 @@
1
- "use strict";
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "BUY_X_GET_Y_FREE_STRATEGY", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _examples.BUY_X_GET_Y_FREE_STRATEGY;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "ITEM_REWARD_STRATEGY", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _examples.ITEM_REWARD_STRATEGY;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "PromotionAdapter", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _adapter.PromotionAdapter;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "PromotionEvaluator", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _evaluator.PromotionEvaluator;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "X_ITEMS_FOR_Y_PRICE_STRATEGY", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _examples.X_ITEMS_FOR_Y_PRICE_STRATEGY;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "default", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _adapter.default;
40
+ }
41
+ });
42
+ var _evaluator = require("./evaluator");
43
+ var _adapter = _interopRequireWildcard(require("./adapter"));
44
+ var _examples = require("./examples");
45
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
46
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -592,7 +592,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
592
592
  generateIdempotencyToken(): string;
593
593
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
594
594
  createOrder(params: CommitOrderParams['query']): {
595
- type: "virtual" | "appointment_booking";
595
+ type: "appointment_booking" | "virtual";
596
596
  platform: string;
597
597
  sales_channel: string;
598
598
  order_sales_channel: string;
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  date: string;
327
327
  status: string;
328
328
  week: string;
329
- weekNum: 0 | 1 | 2 | 3 | 5 | 4 | 6;
329
+ weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -41,6 +41,11 @@ export declare class VenueBookingImpl extends BaseSalesImpl implements Module {
41
41
  private customerLoginRefreshIdInFlight;
42
42
  private loadAllProductsInFlight;
43
43
  private productsLoaded;
44
+ private smartPricingCustomerId;
45
+ private smartPricingProductCatalog;
46
+ private slotPriceMapCache;
47
+ private slotPriceStrategyConfigs;
48
+ private slotPriceScheduleList;
44
49
  private loadOpenDataConfigInFlight;
45
50
  private static readonly OPEN_DATA_CACHE_TTL;
46
51
  private getLoggerContext;
@@ -69,7 +74,7 @@ export declare class VenueBookingImpl extends BaseSalesImpl implements Module {
69
74
  private clearLoginEffectListeners;
70
75
  private registerLoginEffect;
71
76
  private registerCustomerLoginListeners;
72
- private refreshOrderMarketingAfterLogin;
77
+ private refreshOrderMarketingForCustomer;
73
78
  initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
74
79
  destroy(): Promise<void>;
75
80
  retryInit(): Promise<void>;
@@ -82,6 +87,11 @@ export declare class VenueBookingImpl extends BaseSalesImpl implements Module {
82
87
  passed: boolean | null;
83
88
  failures: QuantityCheckResult[];
84
89
  };
90
+ private resolveCustomerIdForSmartPricing;
91
+ private buildSmartPricingContext;
92
+ private buildSlotPriceMapForDate;
93
+ /** 规则或客户上下文更新后,同步商品展示、已选时段和订单汇总。 */
94
+ refreshSmartPricing(): Promise<void>;
85
95
  loadAllProducts(): Promise<{
86
96
  venueProducts: ProductData[];
87
97
  addonProducts: ProductData[];
@@ -167,7 +177,10 @@ export declare class VenueBookingImpl extends BaseSalesImpl implements Module {
167
177
  onCustomerLogin(params: {
168
178
  customerId: number;
169
179
  }): Promise<void>;
170
- private recalculateOrderPricesFromQuotation;
180
+ /** 宿主退出登录或以匿名身份重新进入时,清理客户资产并恢复匿名价格。 */
181
+ onCustomerLogout(): Promise<void>;
182
+ private recalculateOrderPricesFromSmartPricing;
183
+ private resetProductPriceForSmartPricing;
171
184
  scanCode(code: string, customerId?: number): Promise<{
172
185
  isAvailable: boolean;
173
186
  isAccepted?: boolean | undefined;