@pisell/pisellos 2.2.314 → 2.2.315

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 (214) hide show
  1. package/dist/index.d.ts +2 -0
  2. package/dist/index.js +3 -1
  3. package/dist/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
  4. package/dist/model/strategy/adapter/itemRule/adapter.js +74 -7
  5. package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
  6. package/dist/model/strategy/adapter/itemRule/evaluator.js +13 -0
  7. package/dist/model/strategy/adapter/itemRule/type.d.ts +40 -1
  8. package/dist/model/strategy/adapter/itemRule/type.js +10 -0
  9. package/dist/modules/BookingContext/utils/productExtend.d.ts +7 -0
  10. package/dist/modules/BookingContext/utils/productExtend.js +62 -18
  11. package/dist/modules/BookingContext/utils/resources.js +1 -1
  12. package/dist/modules/BusinessAvailability/index.d.ts +30 -0
  13. package/dist/modules/BusinessAvailability/index.js +204 -0
  14. package/dist/modules/Cart/index.js +4 -3
  15. package/dist/modules/Cart/types.d.ts +2 -0
  16. package/dist/modules/Cart/utils/cartProduct.d.ts +3 -1
  17. package/dist/modules/Cart/utils/cartProduct.js +59 -32
  18. package/dist/modules/FulfillmentTiming/index.d.ts +11 -0
  19. package/dist/modules/FulfillmentTiming/index.js +407 -0
  20. package/dist/modules/FulfillmentTiming/types.d.ts +67 -0
  21. package/dist/modules/FulfillmentTiming/types.js +1 -0
  22. package/dist/modules/OpenData/types.d.ts +14 -0
  23. package/dist/modules/Order/index.d.ts +14 -2
  24. package/dist/modules/Order/index.js +856 -486
  25. package/dist/modules/Order/localEftposState.d.ts +13 -0
  26. package/dist/modules/Order/localEftposState.js +39 -0
  27. package/dist/modules/Order/pickupTiming.d.ts +46 -0
  28. package/dist/modules/Order/pickupTiming.js +53 -0
  29. package/dist/modules/Order/types.d.ts +30 -2
  30. package/dist/modules/Order/utils.js +25 -7
  31. package/dist/modules/Payment/index.js +9 -10
  32. package/dist/modules/Product/types.d.ts +11 -0
  33. package/dist/modules/ProductList/index.js +1 -1
  34. package/dist/modules/ResourcePlanner/planner.d.ts +2 -0
  35. package/dist/modules/ResourcePlanner/planner.js +332 -23
  36. package/dist/modules/ResourcePlanner/types.d.ts +29 -0
  37. package/dist/modules/Schedule/index.d.ts +8 -0
  38. package/dist/modules/Schedule/index.js +141 -39
  39. package/dist/modules/index.d.ts +1 -0
  40. package/dist/modules/index.js +1 -0
  41. package/dist/plugins/request.d.ts +7 -0
  42. package/dist/server/index.d.ts +1 -0
  43. package/dist/server/index.js +1536 -1309
  44. package/dist/server/modules/form/index.d.ts +19 -0
  45. package/dist/server/modules/form/index.js +205 -0
  46. package/dist/server/modules/form/types.d.ts +13 -0
  47. package/dist/server/modules/form/types.js +3 -0
  48. package/dist/server/modules/index.d.ts +3 -0
  49. package/dist/server/modules/index.js +4 -0
  50. package/dist/server/modules/order/index.d.ts +15 -0
  51. package/dist/server/modules/order/index.js +920 -688
  52. package/dist/server/modules/order/types.d.ts +1 -0
  53. package/dist/server/test.json +1 -1
  54. package/dist/server/utils/small-ticket.d.ts +1 -85
  55. package/dist/server/utils/small-ticket.js +2 -2542
  56. package/dist/shared/payment/loadPaymentMethods.d.ts +9 -0
  57. package/dist/shared/payment/loadPaymentMethods.js +66 -0
  58. package/dist/shared/receipt/customerInvoiceLanguages.d.ts +8 -0
  59. package/dist/shared/receipt/customerInvoiceLanguages.js +60 -0
  60. package/dist/shared/receipt/loadCustomerInvoiceLayout.d.ts +27 -0
  61. package/dist/shared/receipt/loadCustomerInvoiceLayout.js +184 -0
  62. package/dist/shared/receipt/small-ticket.d.ts +96 -0
  63. package/dist/shared/receipt/small-ticket.js +2751 -0
  64. package/dist/shared/receipt/templateVisibility.d.ts +23 -0
  65. package/dist/shared/receipt/templateVisibility.js +64 -0
  66. package/dist/shared/sales/loadSalesOrderSnapshot.d.ts +9 -0
  67. package/dist/shared/sales/loadSalesOrderSnapshot.js +21 -0
  68. package/dist/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
  69. package/dist/solution/BaseSales/fulfillmentItemRules.js +750 -0
  70. package/dist/solution/BaseSales/index.d.ts +39 -16
  71. package/dist/solution/BaseSales/index.js +1754 -1154
  72. package/dist/solution/BaseSales/pickupTiming.d.ts +47 -0
  73. package/dist/solution/BaseSales/pickupTiming.js +616 -0
  74. package/dist/solution/BaseSales/types.d.ts +11 -0
  75. package/dist/solution/BaseSales/utils/parseSalesResponse.js +3 -0
  76. package/dist/solution/BookingByStep/index.d.ts +3 -1
  77. package/dist/solution/BookingByStep/index.js +8 -3
  78. package/dist/solution/BookingTicket/index.d.ts +8 -2
  79. package/dist/solution/BookingTicket/index.js +513 -436
  80. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -1
  81. package/dist/solution/BookingTicket/utils/addProductDecision.js +1 -1
  82. package/dist/solution/BookingTicket/utils/cartView.js +3 -1
  83. package/dist/solution/OrderInvoicePreview/index.d.ts +66 -0
  84. package/dist/solution/OrderInvoicePreview/index.js +340 -0
  85. package/dist/solution/RegisterAndLogin/config.js +54 -11
  86. package/dist/solution/RegisterAndLogin/index.d.ts +2 -0
  87. package/dist/solution/RegisterAndLogin/index.js +1 -1
  88. package/dist/solution/RegisterAndLogin/utils.d.ts +12 -4
  89. package/dist/solution/RegisterAndLogin/utils.js +36 -16
  90. package/dist/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
  91. package/dist/solution/UnifiedBookingSales/businessAvailability.js +292 -0
  92. package/dist/solution/UnifiedBookingSales/index.d.ts +36 -4
  93. package/dist/solution/UnifiedBookingSales/index.js +1714 -905
  94. package/dist/solution/UnifiedBookingSales/types.d.ts +16 -2
  95. package/dist/solution/VenueBooking/index.d.ts +15 -2
  96. package/dist/solution/VenueBooking/index.js +1062 -785
  97. package/dist/solution/VenueBooking/types.d.ts +2 -1
  98. package/dist/solution/VenueBooking/types.js +1 -0
  99. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
  100. package/dist/solution/VenueBooking/utils/dateSummary.js +7 -4
  101. package/dist/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
  102. package/dist/solution/VenueBooking/utils/smartPricing.js +273 -0
  103. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +1 -0
  104. package/dist/solution/VenueBooking/utils/timeSlot.js +6 -3
  105. package/dist/solution/index.d.ts +1 -0
  106. package/dist/solution/index.js +2 -1
  107. package/lib/index.d.ts +2 -0
  108. package/lib/index.js +21 -1
  109. package/lib/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
  110. package/lib/model/strategy/adapter/itemRule/adapter.js +54 -4
  111. package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
  112. package/lib/model/strategy/adapter/itemRule/evaluator.js +9 -0
  113. package/lib/model/strategy/adapter/itemRule/type.d.ts +40 -1
  114. package/lib/model/strategy/adapter/itemRule/type.js +10 -0
  115. package/lib/model/strategy/adapter/promotion/index.js +46 -1
  116. package/lib/modules/BookingContext/utils/productExtend.d.ts +7 -0
  117. package/lib/modules/BookingContext/utils/productExtend.js +45 -2
  118. package/lib/modules/BookingContext/utils/resources.js +1 -1
  119. package/lib/modules/BusinessAvailability/index.d.ts +30 -0
  120. package/lib/modules/BusinessAvailability/index.js +146 -0
  121. package/lib/modules/Cart/index.js +4 -2
  122. package/lib/modules/Cart/types.d.ts +2 -0
  123. package/lib/modules/Cart/utils/cartProduct.d.ts +3 -1
  124. package/lib/modules/Cart/utils/cartProduct.js +39 -20
  125. package/lib/modules/FulfillmentTiming/index.d.ts +11 -0
  126. package/lib/modules/FulfillmentTiming/index.js +359 -0
  127. package/lib/modules/FulfillmentTiming/types.d.ts +67 -0
  128. package/lib/modules/FulfillmentTiming/types.js +5 -0
  129. package/lib/modules/OpenData/types.d.ts +14 -0
  130. package/lib/modules/Order/index.d.ts +14 -2
  131. package/lib/modules/Order/index.js +240 -38
  132. package/lib/modules/Order/localEftposState.d.ts +13 -0
  133. package/lib/modules/Order/localEftposState.js +44 -0
  134. package/lib/modules/Order/pickupTiming.d.ts +46 -0
  135. package/lib/modules/Order/pickupTiming.js +61 -0
  136. package/lib/modules/Order/types.d.ts +30 -2
  137. package/lib/modules/Order/utils.js +21 -5
  138. package/lib/modules/Payment/index.js +3 -4
  139. package/lib/modules/Product/types.d.ts +11 -0
  140. package/lib/modules/ProductList/index.js +1 -1
  141. package/lib/modules/ResourcePlanner/planner.d.ts +2 -0
  142. package/lib/modules/ResourcePlanner/planner.js +252 -8
  143. package/lib/modules/ResourcePlanner/types.d.ts +29 -0
  144. package/lib/modules/Schedule/index.d.ts +8 -0
  145. package/lib/modules/Schedule/index.js +68 -12
  146. package/lib/modules/index.d.ts +1 -0
  147. package/lib/modules/index.js +11 -0
  148. package/lib/plugins/request.d.ts +7 -0
  149. package/lib/server/index.d.ts +1 -0
  150. package/lib/server/index.js +158 -37
  151. package/lib/server/modules/form/index.d.ts +19 -0
  152. package/lib/server/modules/form/index.js +73 -0
  153. package/lib/server/modules/form/types.d.ts +13 -0
  154. package/lib/server/modules/form/types.js +9 -0
  155. package/lib/server/modules/index.d.ts +3 -0
  156. package/lib/server/modules/index.js +15 -1
  157. package/lib/server/modules/order/index.d.ts +15 -0
  158. package/lib/server/modules/order/index.js +114 -3
  159. package/lib/server/modules/order/types.d.ts +1 -0
  160. package/lib/server/test.json +1 -1
  161. package/lib/server/utils/small-ticket.d.ts +1 -85
  162. package/lib/server/utils/small-ticket.js +9 -2305
  163. package/lib/shared/payment/loadPaymentMethods.d.ts +9 -0
  164. package/lib/shared/payment/loadPaymentMethods.js +40 -0
  165. package/lib/shared/receipt/customerInvoiceLanguages.d.ts +8 -0
  166. package/lib/shared/receipt/customerInvoiceLanguages.js +58 -0
  167. package/lib/shared/receipt/loadCustomerInvoiceLayout.d.ts +27 -0
  168. package/lib/shared/receipt/loadCustomerInvoiceLayout.js +124 -0
  169. package/lib/shared/receipt/small-ticket.d.ts +96 -0
  170. package/lib/shared/receipt/small-ticket.js +2546 -0
  171. package/lib/shared/receipt/templateVisibility.d.ts +23 -0
  172. package/lib/shared/receipt/templateVisibility.js +63 -0
  173. package/lib/shared/sales/loadSalesOrderSnapshot.d.ts +9 -0
  174. package/lib/shared/sales/loadSalesOrderSnapshot.js +22 -0
  175. package/lib/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
  176. package/lib/solution/BaseSales/fulfillmentItemRules.js +259 -0
  177. package/lib/solution/BaseSales/index.d.ts +39 -16
  178. package/lib/solution/BaseSales/index.js +333 -31
  179. package/lib/solution/BaseSales/pickupTiming.d.ts +47 -0
  180. package/lib/solution/BaseSales/pickupTiming.js +290 -0
  181. package/lib/solution/BaseSales/types.d.ts +11 -0
  182. package/lib/solution/BaseSales/utils/parseSalesResponse.js +3 -0
  183. package/lib/solution/BookingByStep/index.d.ts +3 -1
  184. package/lib/solution/BookingByStep/index.js +7 -3
  185. package/lib/solution/BookingTicket/index.d.ts +8 -2
  186. package/lib/solution/BookingTicket/index.js +65 -6
  187. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -1
  188. package/lib/solution/BookingTicket/utils/addProductDecision.js +1 -1
  189. package/lib/solution/BookingTicket/utils/cartView.js +3 -1
  190. package/lib/solution/OrderInvoicePreview/index.d.ts +66 -0
  191. package/lib/solution/OrderInvoicePreview/index.js +246 -0
  192. package/lib/solution/RegisterAndLogin/config.js +57 -11
  193. package/lib/solution/RegisterAndLogin/index.d.ts +2 -0
  194. package/lib/solution/RegisterAndLogin/index.js +9 -1
  195. package/lib/solution/RegisterAndLogin/utils.d.ts +12 -4
  196. package/lib/solution/RegisterAndLogin/utils.js +24 -17
  197. package/lib/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
  198. package/lib/solution/UnifiedBookingSales/businessAvailability.js +138 -0
  199. package/lib/solution/UnifiedBookingSales/index.d.ts +36 -4
  200. package/lib/solution/UnifiedBookingSales/index.js +561 -74
  201. package/lib/solution/UnifiedBookingSales/types.d.ts +16 -2
  202. package/lib/solution/VenueBooking/index.d.ts +15 -2
  203. package/lib/solution/VenueBooking/index.js +243 -96
  204. package/lib/solution/VenueBooking/types.d.ts +2 -1
  205. package/lib/solution/VenueBooking/types.js +1 -0
  206. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
  207. package/lib/solution/VenueBooking/utils/dateSummary.js +7 -4
  208. package/lib/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
  209. package/lib/solution/VenueBooking/utils/smartPricing.js +224 -0
  210. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +1 -0
  211. package/lib/solution/VenueBooking/utils/timeSlot.js +5 -2
  212. package/lib/solution/index.d.ts +1 -0
  213. package/lib/solution/index.js +11 -0
  214. 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 {
@@ -10,6 +10,7 @@ let VenueBookingHooks = exports.VenueBookingHooks = /*#__PURE__*/function (Venue
10
10
  VenueBookingHooks["onRetryInit"] = "venueBooking:onRetryInit";
11
11
  VenueBookingHooks["onRefresh"] = "venueBooking:onRefresh";
12
12
  VenueBookingHooks["onCartValidationChanged"] = "venueBooking:onCartValidationChanged";
13
+ VenueBookingHooks["onSmartPricingUpdated"] = "venueBooking:onSmartPricingUpdated";
13
14
  return VenueBookingHooks;
14
15
  }({}); // ─── 场地预定核心类型 ───
15
16
  const DEFAULT_SLOT_CONFIG = exports.DEFAULT_SLOT_CONFIG = {
@@ -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[];
@@ -16,17 +16,19 @@ function buildDateRangeSummary(params) {
16
16
  resourceProductMap,
17
17
  quotationModule,
18
18
  channel,
19
- resolveConfig
19
+ resolveConfig,
20
+ buildSlotPriceMap
20
21
  } = params;
21
22
  const result = [];
22
- const productIds = quotationModule ? [...new Set([...resourceProductMap.values()].flat().map(m => m.productId))] : [];
23
+ const productIds = buildSlotPriceMap || quotationModule ? [...new Set([...resourceProductMap.values()].flat().map(m => m.productId))] : [];
23
24
  let cursor = (0, _dayjs.default)(startDate);
24
25
  const end = (0, _dayjs.default)(endDate);
25
26
  while (!cursor.isAfter(end)) {
26
27
  const date = cursor.format('YYYY-MM-DD');
27
28
  const effectiveConfig = resolveConfig?.(date) || config;
28
29
  let quotationPriceMap;
29
- if (quotationModule && productIds.length) {
30
+ const slotPriceMap = buildSlotPriceMap?.(date, effectiveConfig, productIds);
31
+ if (!slotPriceMap && quotationModule && productIds.length) {
30
32
  const timeLabels = (0, _timeSlot.generateTimeLabels)(effectiveConfig);
31
33
  const timePoints = timeLabels.map(label => `${date} ${label}`);
32
34
  quotationPriceMap = quotationModule.buildProductPriceMap({
@@ -40,7 +42,8 @@ function buildDateRangeSummary(params) {
40
42
  config: effectiveConfig,
41
43
  rawResources,
42
44
  resourceProductMap,
43
- quotationPriceMap
45
+ quotationPriceMap,
46
+ slotPriceMap
44
47
  });
45
48
  let totalSlots = 0;
46
49
  let 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,224 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.buildDataVariantBusinessData = buildDataVariantBusinessData;
7
+ exports.buildEvaluationDatetimes = buildEvaluationDatetimes;
8
+ exports.buildSlotPriceMapByScheduleSegments = buildSlotPriceMapByScheduleSegments;
9
+ exports.buildSlotStartDatetime = buildSlotStartDatetime;
10
+ exports.extractProductPrice = extractProductPrice;
11
+ exports.findSegmentEvalDatetime = findSegmentEvalDatetime;
12
+ exports.formatProductsWithDataVariant = formatProductsWithDataVariant;
13
+ exports.getPriceForProductAtDatetime = getPriceForProductAtDatetime;
14
+ exports.getSlotPriceFromMap = getSlotPriceFromMap;
15
+ var _dayjs = _interopRequireDefault(require("dayjs"));
16
+ var _timeSlot = require("./timeSlot");
17
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
+ /** VenueBooking 智能定价运行时上下文 */
19
+
20
+ /** 从商品上读取展示/算价用的 price 字段 */
21
+ function extractProductPrice(product) {
22
+ const price = product?.price ?? product?.selling_price;
23
+ if (price == null || price === '') return null;
24
+ return String(price);
25
+ }
26
+
27
+ /** 组装 DataVariant 评估入参,对齐 OS Server buildProductFormatterContext 语义 */
28
+ function buildDataVariantBusinessData(products, context, scheduleDateTime) {
29
+ const strategyContext = context.strategy_context || {};
30
+ return {
31
+ products: products,
32
+ strategyConfigs: context.strategyConfigs,
33
+ scheduleDateTime,
34
+ scheduleList: context.scheduleList || [],
35
+ menuList: context.menuList || [],
36
+ customerId: context.customerId,
37
+ availableWalletIds: context.availableWalletIds ?? strategyContext.available_wallet_ids ?? strategyContext.availableWalletIds,
38
+ channel: context.channel ?? strategyContext.channel,
39
+ orderType: context.orderType ?? strategyContext.orderType ?? strategyContext.order_type,
40
+ businessCode: context.businessCode ?? strategyContext.business_code ?? strategyContext.businessCode,
41
+ custom: strategyContext
42
+ };
43
+ }
44
+
45
+ /**
46
+ * 对商品列表执行一次智能定价格式化(loadProducts 后使用)。
47
+ * evaluator 未注入时原样返回并打 warning。
48
+ */
49
+ function formatProductsWithDataVariant(products, context, scheduleDateTime) {
50
+ const evaluator = context.evaluator;
51
+ if (!evaluator || typeof evaluator.resolveProducts !== 'function') {
52
+ console.warn('[VenueBooking][smartPricing] dataVariantEvaluator 未注入,跳过智能定价格式化');
53
+ return products;
54
+ }
55
+
56
+ // 日程包含结束边界,向后偏移一秒评估,避免前一时段的定价规则覆盖当前时段。
57
+ // 仅调整规则匹配时间,预约时间和分段缓存 key 仍保留原值。
58
+ const resolvedAt = (0, _dayjs.default)(scheduleDateTime || undefined).add(1, 'second').format('YYYY-MM-DD HH:mm:ss');
59
+ // 接口的命中 ID 对应商品查询时刻,不能用于另一个预约时段/客户。
60
+ // 仅处理本次评估副本,保留目录中的原始数据。
61
+ const pricingProducts = products.map(product => {
62
+ const metadata = {
63
+ ...product.metadata
64
+ };
65
+ const hasResolvedVariants = Array.isArray(metadata.data_variant_ids);
66
+ delete metadata.data_variant_ids;
67
+ return {
68
+ ...product,
69
+ price: hasResolvedVariants ? product.base_price ?? product.price : product.price,
70
+ metadata
71
+ };
72
+ });
73
+ const businessData = buildDataVariantBusinessData(pricingProducts, context, resolvedAt);
74
+ const result = evaluator.resolveProducts(businessData);
75
+ return Array.isArray(result?.products) ? result.products : products;
76
+ }
77
+
78
+ /**
79
+ * 根据 schedule_time_points 与营业开始时间,构造当天需要评估的 datetime 列表(升序)。
80
+ * 跨日营业时,早于营业开始小时的时间点归到次日。
81
+ */
82
+ function buildEvaluationDatetimes(params) {
83
+ const {
84
+ date,
85
+ config,
86
+ scheduleTimePoints
87
+ } = params;
88
+ const crossDay = (0, _timeSlot.isBusinessHoursCrossDay)(config);
89
+ const businessStartHour = Number(config.businessStartTime.split(':')[0]);
90
+ const evalSet = new Set();
91
+ evalSet.add(`${date} ${config.businessStartTime}`);
92
+ if (crossDay) {
93
+ // 即使规则没有显式 00:00 时间点,日期/星期变化也可能切换适用规则。
94
+ evalSet.add(`${(0, _dayjs.default)(date).add(1, 'day').format('YYYY-MM-DD')} 00:00`);
95
+ }
96
+ for (const timePoint of scheduleTimePoints) {
97
+ const hour = Number(timePoint.split(':')[0]);
98
+ const pointDate = crossDay && hour < businessStartHour ? (0, _dayjs.default)(date).add(1, 'day').format('YYYY-MM-DD') : date;
99
+ evalSet.add(`${pointDate} ${timePoint}`);
100
+ }
101
+ return Array.from(evalSet).sort((a, b) => {
102
+ const aMs = (0, _dayjs.default)(a, ['YYYY-MM-DD HH:mm:ss', 'YYYY-MM-DD HH:mm']).valueOf();
103
+ const bMs = (0, _dayjs.default)(b, ['YYYY-MM-DD HH:mm:ss', 'YYYY-MM-DD HH:mm']).valueOf();
104
+ return aMs - bMs;
105
+ });
106
+ }
107
+
108
+ /** 找到 slot 时间所属分段的评估 datetime(max(evalDt <= slotDt)) */
109
+ function findSegmentEvalDatetime(slotDatetime, evalDatetimes) {
110
+ if (!evalDatetimes.length) return slotDatetime;
111
+ const slotMs = (0, _dayjs.default)(slotDatetime, ['YYYY-MM-DD HH:mm:ss', 'YYYY-MM-DD HH:mm']).valueOf();
112
+ let chosen = evalDatetimes[0];
113
+ for (const evalDt of evalDatetimes) {
114
+ const evalMs = (0, _dayjs.default)(evalDt, ['YYYY-MM-DD HH:mm:ss', 'YYYY-MM-DD HH:mm']).valueOf();
115
+ if (evalMs <= slotMs) {
116
+ chosen = evalDt;
117
+ } else {
118
+ break;
119
+ }
120
+ }
121
+ return chosen;
122
+ }
123
+
124
+ /** 将 slot 标签转为与 timeSlot 网格一致的 slotStart 字符串 */
125
+ function buildSlotStartDatetime(date, label, config) {
126
+ const crossDay = (0, _timeSlot.isBusinessHoursCrossDay)(config);
127
+ const businessStartHour = Number(config.businessStartTime.split(':')[0]);
128
+ const hour = Number(label.split(':')[0]);
129
+ const slotDate = crossDay && hour < businessStartHour ? (0, _dayjs.default)(date).add(1, 'day').format('YYYY-MM-DD') : date;
130
+ return (0, _dayjs.default)(`${slotDate} ${label}`).format('YYYY-MM-DD HH:mm');
131
+ }
132
+
133
+ /**
134
+ * 按 schedule 分段批量 resolveProducts,输出与 quotation 相同 key 格式的 slot 价格 Map。
135
+ * key: `${productId}:${slotStart}`,value: price | null
136
+ */
137
+ function buildSlotPriceMapByScheduleSegments(params) {
138
+ const {
139
+ products,
140
+ productIds,
141
+ date,
142
+ timeLabels,
143
+ config,
144
+ context
145
+ } = params;
146
+ const map = new Map();
147
+ if (!productIds.length || !timeLabels.length) return map;
148
+ const evaluator = context.evaluator;
149
+ if (!evaluator || typeof evaluator.resolveProducts !== 'function') return map;
150
+ const strategyConfigs = context.strategyConfigs || (typeof evaluator.getStrategyConfigs === 'function' ? evaluator.getStrategyConfigs() : []);
151
+ const scheduleTimePoints = typeof evaluator.buildScheduleTimePoints === 'function' ? evaluator.buildScheduleTimePoints(strategyConfigs, context.scheduleList || []) : [];
152
+ const evalDatetimes = buildEvaluationDatetimes({
153
+ date,
154
+ config,
155
+ scheduleTimePoints
156
+ });
157
+ const priceCache = new Map();
158
+ for (const evalDt of evalDatetimes) {
159
+ const resolved = formatProductsWithDataVariant(products, context, evalDt);
160
+ const priceByProductId = new Map();
161
+ for (const product of resolved) {
162
+ const productId = Number(product.id);
163
+ if (!Number.isFinite(productId)) continue;
164
+ priceByProductId.set(productId, extractProductPrice(product));
165
+ }
166
+ priceCache.set(evalDt, priceByProductId);
167
+ }
168
+ for (const label of timeLabels) {
169
+ const slotStart = buildSlotStartDatetime(date, label, config);
170
+ const segmentEvalDt = findSegmentEvalDatetime(slotStart, evalDatetimes);
171
+ const priceByProductId = priceCache.get(segmentEvalDt);
172
+ for (const productId of productIds) {
173
+ const key = `${productId}:${slotStart}`;
174
+ const price = priceByProductId?.get(productId) ?? null;
175
+ if (price !== null) {
176
+ map.set(key, price);
177
+ }
178
+ }
179
+ }
180
+ return map;
181
+ }
182
+
183
+ /**
184
+ * 指定商品在某一 datetime 的智能定价(addon / 单点重算用)。
185
+ */
186
+ function getPriceForProductAtDatetime(params) {
187
+ const {
188
+ products,
189
+ context,
190
+ productId,
191
+ variantId,
192
+ datetime,
193
+ fallbackPrice
194
+ } = params;
195
+ const selectedProducts = products.filter(product => Number(product.id) === Number(productId)).map(product => {
196
+ if (!variantId) return product;
197
+ const variant = product.variant?.find(item => Number(item.id) === Number(variantId));
198
+ if (!variant) return product;
199
+ return {
200
+ ...product,
201
+ product_variant_id: variantId,
202
+ variant_id: variantId,
203
+ price: variant.price ?? variant.base_price ?? product.price,
204
+ base_price: variant.base_price ?? variant.price ?? product.base_price
205
+ };
206
+ });
207
+ const resolved = formatProductsWithDataVariant(selectedProducts, context, datetime);
208
+ const product = resolved.find(item => Number(item.id) === Number(productId));
209
+ return extractProductPrice(product || {}) ?? fallbackPrice ?? '0.00';
210
+ }
211
+
212
+ /** 从 slot 价格 Map 读取单价,找不到则回退 fallback */
213
+ function getSlotPriceFromMap(params) {
214
+ const {
215
+ slotPriceMap,
216
+ productId,
217
+ slotStartTime,
218
+ fallbackPrice
219
+ } = params;
220
+ const key = `${productId}:${slotStartTime}`;
221
+ const mapped = slotPriceMap.get(key);
222
+ if (mapped != null) return mapped;
223
+ return fallbackPrice ?? '0.00';
224
+ }
@@ -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 {};
@@ -166,6 +166,7 @@ function buildProductSlots(params) {
166
166
  now,
167
167
  crossDay,
168
168
  quotationPriceMap,
169
+ slotPriceMap,
169
170
  childRawResources,
170
171
  childTimesCache,
171
172
  childEventsCache,
@@ -230,7 +231,7 @@ function buildProductSlots(params) {
230
231
  startTime: slotStartStr,
231
232
  endTime: slotEnd.format('YYYY-MM-DD HH:mm'),
232
233
  status,
233
- price: isBookable ? quotationPriceMap?.get(`${mapping.productId}:${slotStartStr}`) ?? mapping.price : null,
234
+ price: isBookable ? (slotPriceMap ?? quotationPriceMap)?.get(`${mapping.productId}:${slotStartStr}`) ?? mapping.price : null,
234
235
  resourceId: resource.resourceId,
235
236
  resourceFormId: resource.formId,
236
237
  capacity: status === 'past' || status === 'unavailable' ? null : resCapacity,
@@ -246,7 +247,8 @@ function buildTimeSlotGrid(params) {
246
247
  config,
247
248
  rawResources,
248
249
  resourceProductMap,
249
- quotationPriceMap
250
+ quotationPriceMap,
251
+ slotPriceMap
250
252
  } = params;
251
253
  const timeLabels = generateTimeLabels(config);
252
254
  const now = (0, _dayjs.default)();
@@ -279,6 +281,7 @@ function buildTimeSlotGrid(params) {
279
281
  now,
280
282
  crossDay,
281
283
  quotationPriceMap,
284
+ slotPriceMap,
282
285
  childRawResources,
283
286
  childTimesCache,
284
287
  childEventsCache,
@@ -9,3 +9,4 @@ export * from './ScanOrder';
9
9
  export * from './BaseSales';
10
10
  export * from './VenueBooking';
11
11
  export * from './UnifiedBookingSales';
12
+ export * from './OrderInvoicePreview';
@@ -123,4 +123,15 @@ Object.keys(_UnifiedBookingSales).forEach(function (key) {
123
123
  return _UnifiedBookingSales[key];
124
124
  }
125
125
  });
126
+ });
127
+ var _OrderInvoicePreview = require("./OrderInvoicePreview");
128
+ Object.keys(_OrderInvoicePreview).forEach(function (key) {
129
+ if (key === "default" || key === "__esModule") return;
130
+ if (key in exports && exports[key] === _OrderInvoicePreview[key]) return;
131
+ Object.defineProperty(exports, key, {
132
+ enumerable: true,
133
+ get: function () {
134
+ return _OrderInvoicePreview[key];
135
+ }
136
+ });
126
137
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.314",
4
+ "version": "2.2.315",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",