@pisell/pisellos 2.1.171 → 2.1.172

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 (230) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.js +1 -3
  3. package/dist/model/strategy/adapter/index.d.ts +0 -4
  4. package/dist/model/strategy/adapter/index.js +1 -5
  5. package/dist/model/strategy/adapter/promotion/evaluator.js +99 -26
  6. package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
  7. package/dist/model/strategy/adapter/walletPass/evaluator.js +61 -8
  8. package/dist/model/strategy/adapter/walletPass/locales.js +12 -3
  9. package/dist/model/strategy/engine.d.ts +18 -5
  10. package/dist/model/strategy/engine.js +145 -45
  11. package/dist/model/strategy/type.d.ts +17 -0
  12. package/dist/model/strategy/type.js +4 -0
  13. package/dist/modules/Cart/types.d.ts +2 -0
  14. package/dist/modules/Cart/utils/cartProduct.js +56 -25
  15. package/dist/modules/Cart/utils/changePrice.js +9 -16
  16. package/dist/modules/Discount/index.d.ts +4 -13
  17. package/dist/modules/Discount/index.js +12 -124
  18. package/dist/modules/Discount/types.d.ts +18 -13
  19. package/dist/modules/Order/index.d.ts +1 -67
  20. package/dist/modules/Order/index.js +30 -918
  21. package/dist/modules/Order/types.d.ts +12 -176
  22. package/dist/modules/Order/types.js +0 -2
  23. package/dist/modules/Order/utils.d.ts +0 -118
  24. package/dist/modules/Order/utils.js +2 -586
  25. package/dist/modules/Payment/index.d.ts +2 -1
  26. package/dist/modules/Payment/index.js +10 -7
  27. package/dist/modules/Payment/utils.js +3 -0
  28. package/dist/modules/Payment/walletpass.d.ts +23 -0
  29. package/dist/modules/Payment/walletpass.js +191 -95
  30. package/dist/modules/Product/utils.js +2 -2
  31. package/dist/modules/ProductList/index.d.ts +2 -4
  32. package/dist/modules/ProductList/index.js +12 -24
  33. package/dist/modules/Rules/index.d.ts +9 -5
  34. package/dist/modules/Rules/index.js +669 -173
  35. package/dist/modules/Rules/types.d.ts +2 -0
  36. package/dist/modules/Schedule/getDateIsInSchedule.js +18 -16
  37. package/dist/modules/Schedule/utils.d.ts +1 -1
  38. package/dist/modules/Summary/types.d.ts +2 -0
  39. package/dist/modules/Summary/utils.d.ts +9 -3
  40. package/dist/modules/Summary/utils.js +57 -67
  41. package/dist/modules/index.d.ts +0 -4
  42. package/dist/modules/index.js +1 -5
  43. package/dist/plugins/window.d.ts +2 -0
  44. package/dist/solution/BookingByStep/index.d.ts +3 -2
  45. package/dist/solution/BookingByStep/index.js +43 -46
  46. package/dist/solution/BookingByStep/types.d.ts +1 -3
  47. package/dist/solution/BookingByStep/types.js +1 -5
  48. package/dist/solution/BookingByStep/utils/timeslots.d.ts +1 -3
  49. package/dist/solution/BookingByStep/utils/timeslots.js +12 -19
  50. package/dist/solution/Checkout/index.js +2 -0
  51. package/dist/solution/ShopDiscount/index.d.ts +2 -3
  52. package/dist/solution/ShopDiscount/index.js +60 -62
  53. package/dist/solution/ShopDiscount/types.d.ts +1 -1
  54. package/dist/solution/ShopDiscount/types.js +2 -1
  55. package/dist/solution/ShopDiscount/utils.js +26 -12
  56. package/dist/solution/index.d.ts +0 -2
  57. package/dist/solution/index.js +1 -3
  58. package/lib/index.d.ts +1 -1
  59. package/lib/index.js +3 -4
  60. package/lib/model/strategy/adapter/index.d.ts +0 -4
  61. package/lib/model/strategy/adapter/index.js +2 -13
  62. package/lib/model/strategy/adapter/promotion/evaluator.js +57 -8
  63. package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
  64. package/lib/model/strategy/adapter/walletPass/evaluator.js +34 -3
  65. package/lib/model/strategy/adapter/walletPass/locales.js +12 -3
  66. package/lib/model/strategy/engine.d.ts +18 -5
  67. package/lib/model/strategy/engine.js +85 -21
  68. package/lib/model/strategy/type.d.ts +17 -0
  69. package/lib/modules/Cart/types.d.ts +2 -0
  70. package/lib/modules/Cart/utils/cartProduct.js +39 -12
  71. package/lib/modules/Cart/utils/changePrice.js +9 -13
  72. package/lib/modules/Discount/index.d.ts +4 -13
  73. package/lib/modules/Discount/index.js +5 -76
  74. package/lib/modules/Discount/types.d.ts +18 -13
  75. package/lib/modules/Order/index.d.ts +1 -67
  76. package/lib/modules/Order/index.js +1 -525
  77. package/lib/modules/Order/types.d.ts +12 -176
  78. package/lib/modules/Order/utils.d.ts +0 -118
  79. package/lib/modules/Order/utils.js +2 -483
  80. package/lib/modules/Payment/index.d.ts +2 -1
  81. package/lib/modules/Payment/index.js +1 -0
  82. package/lib/modules/Payment/utils.js +3 -0
  83. package/lib/modules/Payment/walletpass.d.ts +23 -0
  84. package/lib/modules/Payment/walletpass.js +94 -17
  85. package/lib/modules/Product/utils.js +2 -2
  86. package/lib/modules/ProductList/index.d.ts +2 -4
  87. package/lib/modules/ProductList/index.js +39 -46
  88. package/lib/modules/Rules/index.d.ts +9 -5
  89. package/lib/modules/Rules/index.js +776 -292
  90. package/lib/modules/Rules/types.d.ts +2 -0
  91. package/lib/modules/Schedule/getDateIsInSchedule.js +11 -13
  92. package/lib/modules/Schedule/utils.d.ts +1 -1
  93. package/lib/modules/Summary/types.d.ts +2 -0
  94. package/lib/modules/Summary/utils.d.ts +9 -3
  95. package/lib/modules/Summary/utils.js +34 -45
  96. package/lib/modules/index.d.ts +0 -4
  97. package/lib/modules/index.js +1 -9
  98. package/lib/plugins/window.d.ts +2 -0
  99. package/lib/solution/BookingByStep/index.d.ts +3 -2
  100. package/lib/solution/BookingByStep/index.js +4 -6
  101. package/lib/solution/BookingByStep/types.d.ts +1 -3
  102. package/lib/solution/BookingByStep/types.js +0 -10
  103. package/lib/solution/BookingByStep/utils/timeslots.d.ts +1 -3
  104. package/lib/solution/BookingByStep/utils/timeslots.js +11 -19
  105. package/lib/solution/Checkout/index.js +2 -0
  106. package/lib/solution/ShopDiscount/index.d.ts +2 -3
  107. package/lib/solution/ShopDiscount/index.js +27 -22
  108. package/lib/solution/ShopDiscount/types.d.ts +1 -1
  109. package/lib/solution/ShopDiscount/utils.js +10 -6
  110. package/lib/solution/index.d.ts +0 -2
  111. package/lib/solution/index.js +1 -5
  112. package/package.json +2 -2
  113. package/dist/apis/picoding.d.ts +0 -0
  114. package/dist/apis/picoding.js +0 -1
  115. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
  116. package/dist/model/strategy/adapter/dataVariant/adapter.js +0 -167
  117. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
  118. package/dist/model/strategy/adapter/dataVariant/evaluator.js +0 -780
  119. package/dist/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
  120. package/dist/model/strategy/adapter/dataVariant/examples.js +0 -277
  121. package/dist/model/strategy/adapter/dataVariant/index.d.ts +0 -4
  122. package/dist/model/strategy/adapter/dataVariant/index.js +0 -4
  123. package/dist/model/strategy/adapter/dataVariant/type.d.ts +0 -148
  124. package/dist/model/strategy/adapter/dataVariant/type.js +0 -54
  125. package/dist/modules/OpenData/index.d.ts +0 -24
  126. package/dist/modules/OpenData/index.js +0 -173
  127. package/dist/modules/OpenData/types.d.ts +0 -73
  128. package/dist/modules/OpenData/types.js +0 -1
  129. package/dist/modules/OpenData/utils.d.ts +0 -2
  130. package/dist/modules/OpenData/utils.js +0 -75
  131. package/dist/modules/Quotation/index.d.ts +0 -48
  132. package/dist/modules/Quotation/index.js +0 -248
  133. package/dist/modules/Quotation/types.d.ts +0 -42
  134. package/dist/modules/Quotation/types.js +0 -1
  135. package/dist/modules/SalesSummary/index.d.ts +0 -63
  136. package/dist/modules/SalesSummary/index.js +0 -174
  137. package/dist/modules/SalesSummary/types.d.ts +0 -60
  138. package/dist/modules/SalesSummary/types.js +0 -1
  139. package/dist/modules/SalesSummary/utils.d.ts +0 -30
  140. package/dist/modules/SalesSummary/utils.js +0 -480
  141. package/dist/modules/ScanOrderLogger/index.d.ts +0 -23
  142. package/dist/modules/ScanOrderLogger/index.js +0 -174
  143. package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +0 -2
  144. package/dist/modules/ScanOrderLogger/providers/feishu.js +0 -221
  145. package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +0 -2
  146. package/dist/modules/ScanOrderLogger/providers/grafana.js +0 -50
  147. package/dist/modules/ScanOrderLogger/types.d.ts +0 -53
  148. package/dist/modules/ScanOrderLogger/types.js +0 -1
  149. package/dist/solution/ScanOrder/index.d.ts +0 -158
  150. package/dist/solution/ScanOrder/index.js +0 -3474
  151. package/dist/solution/ScanOrder/types.d.ts +0 -306
  152. package/dist/solution/ScanOrder/types.js +0 -35
  153. package/dist/solution/ScanOrder/utils.d.ts +0 -172
  154. package/dist/solution/ScanOrder/utils.js +0 -796
  155. package/dist/solution/VenueBooking/index.d.ts +0 -262
  156. package/dist/solution/VenueBooking/index.js +0 -3991
  157. package/dist/solution/VenueBooking/sales-section-4-annotated.json +0 -343
  158. package/dist/solution/VenueBooking/types.d.ts +0 -156
  159. package/dist/solution/VenueBooking/types.js +0 -22
  160. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +0 -11
  161. package/dist/solution/VenueBooking/utils/dateSummary.js +0 -91
  162. package/dist/solution/VenueBooking/utils/resource.d.ts +0 -14
  163. package/dist/solution/VenueBooking/utils/resource.js +0 -131
  164. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -32
  165. package/dist/solution/VenueBooking/utils/slotMerge.js +0 -233
  166. package/dist/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
  167. package/dist/solution/VenueBooking/utils/smartPricing.js +0 -233
  168. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -34
  169. package/dist/solution/VenueBooking/utils/timeSlot.js +0 -458
  170. package/dist/solution/VenueBooking/utils.d.ts +0 -1
  171. package/dist/solution/VenueBooking/utils.js +0 -1
  172. package/lib/apis/picoding.d.ts +0 -0
  173. package/lib/apis/picoding.js +0 -0
  174. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
  175. package/lib/model/strategy/adapter/dataVariant/adapter.js +0 -149
  176. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
  177. package/lib/model/strategy/adapter/dataVariant/evaluator.js +0 -583
  178. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
  179. package/lib/model/strategy/adapter/dataVariant/examples.js +0 -293
  180. package/lib/model/strategy/adapter/dataVariant/index.d.ts +0 -4
  181. package/lib/model/strategy/adapter/dataVariant/index.js +0 -38
  182. package/lib/model/strategy/adapter/dataVariant/type.d.ts +0 -148
  183. package/lib/model/strategy/adapter/dataVariant/type.js +0 -31
  184. package/lib/modules/OpenData/index.d.ts +0 -24
  185. package/lib/modules/OpenData/index.js +0 -119
  186. package/lib/modules/OpenData/types.d.ts +0 -73
  187. package/lib/modules/OpenData/types.js +0 -17
  188. package/lib/modules/OpenData/utils.d.ts +0 -2
  189. package/lib/modules/OpenData/utils.js +0 -111
  190. package/lib/modules/Quotation/index.d.ts +0 -48
  191. package/lib/modules/Quotation/index.js +0 -152
  192. package/lib/modules/Quotation/types.d.ts +0 -42
  193. package/lib/modules/Quotation/types.js +0 -17
  194. package/lib/modules/SalesSummary/index.d.ts +0 -63
  195. package/lib/modules/SalesSummary/index.js +0 -105
  196. package/lib/modules/SalesSummary/types.d.ts +0 -60
  197. package/lib/modules/SalesSummary/types.js +0 -17
  198. package/lib/modules/SalesSummary/utils.d.ts +0 -30
  199. package/lib/modules/SalesSummary/utils.js +0 -420
  200. package/lib/modules/ScanOrderLogger/index.d.ts +0 -23
  201. package/lib/modules/ScanOrderLogger/index.js +0 -147
  202. package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +0 -2
  203. package/lib/modules/ScanOrderLogger/providers/feishu.js +0 -157
  204. package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +0 -2
  205. package/lib/modules/ScanOrderLogger/providers/grafana.js +0 -52
  206. package/lib/modules/ScanOrderLogger/types.d.ts +0 -53
  207. package/lib/modules/ScanOrderLogger/types.js +0 -17
  208. package/lib/solution/ScanOrder/index.d.ts +0 -158
  209. package/lib/solution/ScanOrder/index.js +0 -2135
  210. package/lib/solution/ScanOrder/types.d.ts +0 -306
  211. package/lib/solution/ScanOrder/types.js +0 -36
  212. package/lib/solution/ScanOrder/utils.d.ts +0 -172
  213. package/lib/solution/ScanOrder/utils.js +0 -658
  214. package/lib/solution/VenueBooking/index.d.ts +0 -262
  215. package/lib/solution/VenueBooking/index.js +0 -2394
  216. package/lib/solution/VenueBooking/sales-section-4-annotated.json +0 -343
  217. package/lib/solution/VenueBooking/types.d.ts +0 -156
  218. package/lib/solution/VenueBooking/types.js +0 -45
  219. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +0 -11
  220. package/lib/solution/VenueBooking/utils/dateSummary.js +0 -105
  221. package/lib/solution/VenueBooking/utils/resource.d.ts +0 -14
  222. package/lib/solution/VenueBooking/utils/resource.js +0 -92
  223. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -32
  224. package/lib/solution/VenueBooking/utils/slotMerge.js +0 -236
  225. package/lib/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
  226. package/lib/solution/VenueBooking/utils/smartPricing.js +0 -180
  227. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -34
  228. package/lib/solution/VenueBooking/utils/timeSlot.js +0 -343
  229. package/lib/solution/VenueBooking/utils.d.ts +0 -1
  230. package/lib/solution/VenueBooking/utils.js +0 -69
@@ -1,233 +0,0 @@
1
- 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; } } }; }
2
- 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); }
3
- 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; }
4
- import dayjs from 'dayjs';
5
- import { isBusinessHoursCrossDay } from "./timeSlot";
6
-
7
- /** VenueBooking 智能定价运行时上下文 */
8
-
9
- /** 从商品上读取展示/算价用的 price 字段 */
10
- export function extractProductPrice(product) {
11
- var _product$price;
12
- 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;
13
- if (price == null || price === '') return null;
14
- return String(price);
15
- }
16
-
17
- /** 组装 DataVariant 评估入参,对齐 OS Server buildProductFormatterContext 语义 */
18
- export function buildDataVariantBusinessData(products, context, scheduleDateTime) {
19
- var _ref, _context$availableWal, _context$channel, _ref2, _context$orderType, _ref3, _context$businessCode;
20
- var strategyContext = context.strategy_context || {};
21
- return {
22
- products: products,
23
- strategyConfigs: context.strategyConfigs,
24
- scheduleDateTime: scheduleDateTime,
25
- scheduleList: context.scheduleList || [],
26
- menuList: context.menuList || [],
27
- customerId: context.customerId,
28
- availableWalletIds: (_ref = (_context$availableWal = context.availableWalletIds) !== null && _context$availableWal !== void 0 ? _context$availableWal : strategyContext.available_wallet_ids) !== null && _ref !== void 0 ? _ref : strategyContext.availableWalletIds,
29
- channel: (_context$channel = context.channel) !== null && _context$channel !== void 0 ? _context$channel : strategyContext.channel,
30
- orderType: (_ref2 = (_context$orderType = context.orderType) !== null && _context$orderType !== void 0 ? _context$orderType : strategyContext.orderType) !== null && _ref2 !== void 0 ? _ref2 : strategyContext.order_type,
31
- businessCode: (_ref3 = (_context$businessCode = context.businessCode) !== null && _context$businessCode !== void 0 ? _context$businessCode : strategyContext.business_code) !== null && _ref3 !== void 0 ? _ref3 : strategyContext.businessCode,
32
- custom: strategyContext
33
- };
34
- }
35
-
36
- /**
37
- * 对商品列表执行一次智能定价格式化(loadProducts 后使用)。
38
- * evaluator 未注入时原样返回并打 warning。
39
- */
40
- export function formatProductsWithDataVariant(products, context, scheduleDateTime) {
41
- var evaluator = context.evaluator;
42
- if (!evaluator || typeof evaluator.resolveProducts !== 'function') {
43
- console.warn('[VenueBooking][smartPricing] dataVariantEvaluator 未注入,跳过智能定价格式化');
44
- return products;
45
- }
46
- var resolvedAt = scheduleDateTime || dayjs().format('YYYY-MM-DD HH:mm:ss');
47
- var businessData = buildDataVariantBusinessData(products, context, resolvedAt);
48
- var result = evaluator.resolveProducts(businessData);
49
- return Array.isArray(result === null || result === void 0 ? void 0 : result.products) ? result.products : products;
50
- }
51
-
52
- /**
53
- * 根据 schedule_time_points 与营业开始时间,构造当天需要评估的 datetime 列表(升序)。
54
- * 跨日营业时,早于营业开始小时的时间点归到次日。
55
- */
56
- export function buildEvaluationDatetimes(params) {
57
- var date = params.date,
58
- config = params.config,
59
- scheduleTimePoints = params.scheduleTimePoints;
60
- var crossDay = isBusinessHoursCrossDay(config);
61
- var businessStartHour = Number(config.businessStartTime.split(':')[0]);
62
- var evalSet = new Set();
63
- evalSet.add("".concat(date, " ").concat(config.businessStartTime));
64
- var _iterator = _createForOfIteratorHelper(scheduleTimePoints),
65
- _step;
66
- try {
67
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
68
- var timePoint = _step.value;
69
- var hour = Number(timePoint.split(':')[0]);
70
- var pointDate = crossDay && hour < businessStartHour ? dayjs(date).add(1, 'day').format('YYYY-MM-DD') : date;
71
- evalSet.add("".concat(pointDate, " ").concat(timePoint));
72
- }
73
- } catch (err) {
74
- _iterator.e(err);
75
- } finally {
76
- _iterator.f();
77
- }
78
- return Array.from(evalSet).sort(function (a, b) {
79
- var aMs = dayjs(a, ['YYYY-MM-DD HH:mm:ss', 'YYYY-MM-DD HH:mm']).valueOf();
80
- var bMs = dayjs(b, ['YYYY-MM-DD HH:mm:ss', 'YYYY-MM-DD HH:mm']).valueOf();
81
- return aMs - bMs;
82
- });
83
- }
84
-
85
- /** 找到 slot 时间所属分段的评估 datetime(max(evalDt <= slotDt)) */
86
- export function findSegmentEvalDatetime(slotDatetime, evalDatetimes) {
87
- if (!evalDatetimes.length) return slotDatetime;
88
- var slotMs = dayjs(slotDatetime, ['YYYY-MM-DD HH:mm:ss', 'YYYY-MM-DD HH:mm']).valueOf();
89
- var chosen = evalDatetimes[0];
90
- var _iterator2 = _createForOfIteratorHelper(evalDatetimes),
91
- _step2;
92
- try {
93
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
94
- var evalDt = _step2.value;
95
- var evalMs = dayjs(evalDt, ['YYYY-MM-DD HH:mm:ss', 'YYYY-MM-DD HH:mm']).valueOf();
96
- if (evalMs <= slotMs) {
97
- chosen = evalDt;
98
- } else {
99
- break;
100
- }
101
- }
102
- } catch (err) {
103
- _iterator2.e(err);
104
- } finally {
105
- _iterator2.f();
106
- }
107
- return chosen;
108
- }
109
-
110
- /** 将 slot 标签转为与 timeSlot 网格一致的 slotStart 字符串 */
111
- export function buildSlotStartDatetime(date, label, config) {
112
- var crossDay = isBusinessHoursCrossDay(config);
113
- var businessStartHour = Number(config.businessStartTime.split(':')[0]);
114
- var hour = Number(label.split(':')[0]);
115
- var slotDate = crossDay && hour < businessStartHour ? dayjs(date).add(1, 'day').format('YYYY-MM-DD') : date;
116
- return dayjs("".concat(slotDate, " ").concat(label)).format('YYYY-MM-DD HH:mm');
117
- }
118
-
119
- /**
120
- * 按 schedule 分段批量 resolveProducts,输出与 quotation 相同 key 格式的 slot 价格 Map。
121
- * key: `${productId}:${slotStart}`,value: price | null
122
- */
123
- export function buildSlotPriceMapByScheduleSegments(params) {
124
- var products = params.products,
125
- productIds = params.productIds,
126
- date = params.date,
127
- timeLabels = params.timeLabels,
128
- config = params.config,
129
- context = params.context;
130
- var map = new Map();
131
- if (!productIds.length || !timeLabels.length) return map;
132
- var evaluator = context.evaluator;
133
- if (!evaluator || typeof evaluator.resolveProducts !== 'function') {
134
- return map;
135
- }
136
- var strategyConfigs = context.strategyConfigs || (typeof evaluator.getStrategyConfigs === 'function' ? evaluator.getStrategyConfigs() : []);
137
- var scheduleTimePoints = typeof evaluator.buildScheduleTimePoints === 'function' ? evaluator.buildScheduleTimePoints(strategyConfigs, context.scheduleList || []) : [];
138
- var evalDatetimes = buildEvaluationDatetimes({
139
- date: date,
140
- config: config,
141
- scheduleTimePoints: scheduleTimePoints
142
- });
143
- var priceCache = new Map();
144
- var _iterator3 = _createForOfIteratorHelper(evalDatetimes),
145
- _step3;
146
- try {
147
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
148
- var evalDt = _step3.value;
149
- var resolved = formatProductsWithDataVariant(products, context, evalDt);
150
- var priceByProductId = new Map();
151
- var _iterator5 = _createForOfIteratorHelper(resolved),
152
- _step5;
153
- try {
154
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
155
- var product = _step5.value;
156
- var productId = Number(product.id);
157
- if (!Number.isFinite(productId)) continue;
158
- priceByProductId.set(productId, extractProductPrice(product));
159
- }
160
- } catch (err) {
161
- _iterator5.e(err);
162
- } finally {
163
- _iterator5.f();
164
- }
165
- priceCache.set(evalDt, priceByProductId);
166
- }
167
- } catch (err) {
168
- _iterator3.e(err);
169
- } finally {
170
- _iterator3.f();
171
- }
172
- var _iterator4 = _createForOfIteratorHelper(timeLabels),
173
- _step4;
174
- try {
175
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
176
- var label = _step4.value;
177
- var slotStart = buildSlotStartDatetime(date, label, config);
178
- var segmentEvalDt = findSegmentEvalDatetime(slotStart, evalDatetimes);
179
- var _priceByProductId = priceCache.get(segmentEvalDt);
180
- var _iterator6 = _createForOfIteratorHelper(productIds),
181
- _step6;
182
- try {
183
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
184
- var _priceByProductId$get;
185
- var _productId = _step6.value;
186
- var key = "".concat(_productId, ":").concat(slotStart);
187
- var price = (_priceByProductId$get = _priceByProductId === null || _priceByProductId === void 0 ? void 0 : _priceByProductId.get(_productId)) !== null && _priceByProductId$get !== void 0 ? _priceByProductId$get : null;
188
- if (price !== null) {
189
- map.set(key, price);
190
- }
191
- }
192
- } catch (err) {
193
- _iterator6.e(err);
194
- } finally {
195
- _iterator6.f();
196
- }
197
- }
198
- } catch (err) {
199
- _iterator4.e(err);
200
- } finally {
201
- _iterator4.f();
202
- }
203
- return map;
204
- }
205
-
206
- /**
207
- * 指定商品在某一 datetime 的智能定价(addon / 单点重算用)。
208
- */
209
- export function getPriceForProductAtDatetime(params) {
210
- var _ref4, _extractProductPrice;
211
- var products = params.products,
212
- context = params.context,
213
- productId = params.productId,
214
- datetime = params.datetime,
215
- fallbackPrice = params.fallbackPrice;
216
- var resolved = formatProductsWithDataVariant(products, context, datetime);
217
- var product = resolved.find(function (item) {
218
- return Number(item.id) === Number(productId);
219
- });
220
- return (_ref4 = (_extractProductPrice = extractProductPrice(product || {})) !== null && _extractProductPrice !== void 0 ? _extractProductPrice : fallbackPrice) !== null && _ref4 !== void 0 ? _ref4 : '0.00';
221
- }
222
-
223
- /** 从 slot 价格 Map 读取单价,找不到则回退 fallback */
224
- export function getSlotPriceFromMap(params) {
225
- var slotPriceMap = params.slotPriceMap,
226
- productId = params.productId,
227
- slotStartTime = params.slotStartTime,
228
- fallbackPrice = params.fallbackPrice;
229
- var key = "".concat(productId, ":").concat(slotStartTime);
230
- var mapped = slotPriceMap.get(key);
231
- if (mapped != null) return mapped;
232
- return fallbackPrice !== null && fallbackPrice !== void 0 ? fallbackPrice : '0.00';
233
- }
@@ -1,34 +0,0 @@
1
- import dayjs from 'dayjs';
2
- import type { VenueBookingSlotConfig, VenueResourceRawData, VenueTimeSlotGrid, ResourceProductMapping } from '../types';
3
- export declare function isBusinessHoursCrossDay(config: VenueBookingSlotConfig): boolean;
4
- export declare function generateTimeLabels(config: VenueBookingSlotConfig): string[];
5
- export declare function isSlotOccupied(slotStart: dayjs.Dayjs, slotEnd: dayjs.Dayjs, occupiedTimes: Array<{
6
- start_at: string;
7
- end_at: string;
8
- }>): boolean;
9
- interface SlotEvent {
10
- start_at: string;
11
- end_at: string;
12
- pax: number;
13
- }
14
- export declare function collectEventsForDate(resource: VenueResourceRawData, date: string, config: VenueBookingSlotConfig): SlotEvent[];
15
- export declare function computeSlotStatus(params: {
16
- slotStart: dayjs.Dayjs;
17
- slotEnd: dayjs.Dayjs;
18
- events: SlotEvent[];
19
- resourceType: 'single' | 'multiple' | 'capacity';
20
- capacity: number;
21
- }): {
22
- status: 'available' | 'occupied' | 'partially_occupied';
23
- remainingCapacity: number;
24
- };
25
- export declare function buildTimeSlotGrid(params: {
26
- date: string;
27
- config: VenueBookingSlotConfig;
28
- rawResources: VenueResourceRawData[];
29
- resourceProductMap: Map<number | string, ResourceProductMapping[]>;
30
- /** @deprecated 使用 slotPriceMap */
31
- quotationPriceMap?: Map<string, string | null>;
32
- slotPriceMap?: Map<string, string | null>;
33
- }): VenueTimeSlotGrid;
34
- export {};