@pisell/pisellos 2.1.170 → 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.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -3
- package/dist/model/strategy/adapter/index.d.ts +0 -4
- package/dist/model/strategy/adapter/index.js +1 -5
- package/dist/model/strategy/adapter/promotion/evaluator.js +99 -26
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.js +61 -8
- package/dist/model/strategy/adapter/walletPass/locales.js +12 -3
- package/dist/model/strategy/engine.d.ts +18 -5
- package/dist/model/strategy/engine.js +145 -45
- package/dist/model/strategy/type.d.ts +17 -0
- package/dist/model/strategy/type.js +4 -0
- package/dist/modules/Cart/types.d.ts +2 -0
- package/dist/modules/Cart/utils/cartProduct.js +56 -25
- package/dist/modules/Cart/utils/changePrice.js +9 -16
- package/dist/modules/Discount/index.d.ts +4 -13
- package/dist/modules/Discount/index.js +12 -124
- package/dist/modules/Discount/types.d.ts +18 -13
- package/dist/modules/Order/index.d.ts +1 -67
- package/dist/modules/Order/index.js +30 -918
- package/dist/modules/Order/types.d.ts +12 -176
- package/dist/modules/Order/types.js +0 -2
- package/dist/modules/Order/utils.d.ts +0 -118
- package/dist/modules/Order/utils.js +2 -586
- package/dist/modules/Payment/index.d.ts +2 -1
- package/dist/modules/Payment/index.js +10 -7
- package/dist/modules/Payment/utils.js +3 -0
- package/dist/modules/Payment/walletpass.d.ts +23 -0
- package/dist/modules/Payment/walletpass.js +191 -95
- package/dist/modules/Product/utils.js +2 -2
- package/dist/modules/ProductList/index.d.ts +2 -4
- package/dist/modules/ProductList/index.js +12 -24
- package/dist/modules/Rules/index.d.ts +9 -5
- package/dist/modules/Rules/index.js +669 -173
- package/dist/modules/Rules/types.d.ts +2 -0
- package/dist/modules/Schedule/getDateIsInSchedule.js +18 -16
- package/dist/modules/Schedule/utils.d.ts +1 -1
- package/dist/modules/Summary/types.d.ts +2 -0
- package/dist/modules/Summary/utils.d.ts +9 -3
- package/dist/modules/Summary/utils.js +57 -67
- package/dist/modules/index.d.ts +0 -4
- package/dist/modules/index.js +1 -5
- package/dist/plugins/window.d.ts +2 -0
- package/dist/solution/BookingByStep/index.d.ts +3 -2
- package/dist/solution/BookingByStep/index.js +43 -46
- package/dist/solution/BookingByStep/types.d.ts +1 -3
- package/dist/solution/BookingByStep/types.js +1 -5
- package/dist/solution/BookingByStep/utils/timeslots.d.ts +1 -3
- package/dist/solution/BookingByStep/utils/timeslots.js +12 -19
- package/dist/solution/Checkout/index.js +2 -0
- package/dist/solution/ShopDiscount/index.d.ts +2 -3
- package/dist/solution/ShopDiscount/index.js +60 -62
- package/dist/solution/ShopDiscount/types.d.ts +1 -1
- package/dist/solution/ShopDiscount/types.js +2 -1
- package/dist/solution/ShopDiscount/utils.js +26 -12
- package/dist/solution/index.d.ts +0 -2
- package/dist/solution/index.js +1 -3
- package/lib/index.d.ts +1 -1
- package/lib/index.js +3 -4
- package/lib/model/strategy/adapter/index.d.ts +0 -4
- package/lib/model/strategy/adapter/index.js +2 -13
- package/lib/model/strategy/adapter/promotion/evaluator.js +57 -8
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.js +34 -3
- package/lib/model/strategy/adapter/walletPass/locales.js +12 -3
- package/lib/model/strategy/engine.d.ts +18 -5
- package/lib/model/strategy/engine.js +85 -21
- package/lib/model/strategy/type.d.ts +17 -0
- package/lib/modules/Cart/types.d.ts +2 -0
- package/lib/modules/Cart/utils/cartProduct.js +39 -12
- package/lib/modules/Cart/utils/changePrice.js +9 -13
- package/lib/modules/Discount/index.d.ts +4 -13
- package/lib/modules/Discount/index.js +5 -76
- package/lib/modules/Discount/types.d.ts +18 -13
- package/lib/modules/Order/index.d.ts +1 -67
- package/lib/modules/Order/index.js +1 -525
- package/lib/modules/Order/types.d.ts +12 -176
- package/lib/modules/Order/utils.d.ts +0 -118
- package/lib/modules/Order/utils.js +2 -483
- package/lib/modules/Payment/index.d.ts +2 -1
- package/lib/modules/Payment/index.js +1 -0
- package/lib/modules/Payment/utils.js +3 -0
- package/lib/modules/Payment/walletpass.d.ts +23 -0
- package/lib/modules/Payment/walletpass.js +94 -17
- package/lib/modules/Product/utils.js +2 -2
- package/lib/modules/ProductList/index.d.ts +2 -4
- package/lib/modules/ProductList/index.js +39 -46
- package/lib/modules/Rules/index.d.ts +9 -5
- package/lib/modules/Rules/index.js +776 -292
- package/lib/modules/Rules/types.d.ts +2 -0
- package/lib/modules/Schedule/getDateIsInSchedule.js +11 -13
- package/lib/modules/Schedule/utils.d.ts +1 -1
- package/lib/modules/Summary/types.d.ts +2 -0
- package/lib/modules/Summary/utils.d.ts +9 -3
- package/lib/modules/Summary/utils.js +34 -45
- package/lib/modules/index.d.ts +0 -4
- package/lib/modules/index.js +1 -9
- package/lib/plugins/window.d.ts +2 -0
- package/lib/solution/BookingByStep/index.d.ts +3 -2
- package/lib/solution/BookingByStep/index.js +4 -6
- package/lib/solution/BookingByStep/types.d.ts +1 -3
- package/lib/solution/BookingByStep/types.js +0 -10
- package/lib/solution/BookingByStep/utils/timeslots.d.ts +1 -3
- package/lib/solution/BookingByStep/utils/timeslots.js +11 -19
- package/lib/solution/Checkout/index.js +2 -0
- package/lib/solution/ShopDiscount/index.d.ts +2 -3
- package/lib/solution/ShopDiscount/index.js +27 -22
- package/lib/solution/ShopDiscount/types.d.ts +1 -1
- package/lib/solution/ShopDiscount/utils.js +10 -6
- package/lib/solution/index.d.ts +0 -2
- package/lib/solution/index.js +1 -5
- package/package.json +2 -2
- package/dist/apis/picoding.d.ts +0 -0
- package/dist/apis/picoding.js +0 -1
- package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
- package/dist/model/strategy/adapter/dataVariant/adapter.js +0 -167
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +0 -867
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
- package/dist/model/strategy/adapter/dataVariant/examples.js +0 -277
- package/dist/model/strategy/adapter/dataVariant/index.d.ts +0 -4
- package/dist/model/strategy/adapter/dataVariant/index.js +0 -4
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +0 -149
- package/dist/model/strategy/adapter/dataVariant/type.js +0 -54
- package/dist/modules/OpenData/index.d.ts +0 -24
- package/dist/modules/OpenData/index.js +0 -173
- package/dist/modules/OpenData/types.d.ts +0 -73
- package/dist/modules/OpenData/types.js +0 -1
- package/dist/modules/OpenData/utils.d.ts +0 -2
- package/dist/modules/OpenData/utils.js +0 -75
- package/dist/modules/Quotation/index.d.ts +0 -48
- package/dist/modules/Quotation/index.js +0 -248
- package/dist/modules/Quotation/types.d.ts +0 -42
- package/dist/modules/Quotation/types.js +0 -1
- package/dist/modules/SalesSummary/index.d.ts +0 -63
- package/dist/modules/SalesSummary/index.js +0 -174
- package/dist/modules/SalesSummary/types.d.ts +0 -60
- package/dist/modules/SalesSummary/types.js +0 -1
- package/dist/modules/SalesSummary/utils.d.ts +0 -30
- package/dist/modules/SalesSummary/utils.js +0 -480
- package/dist/modules/ScanOrderLogger/index.d.ts +0 -23
- package/dist/modules/ScanOrderLogger/index.js +0 -174
- package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +0 -2
- package/dist/modules/ScanOrderLogger/providers/feishu.js +0 -221
- package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +0 -2
- package/dist/modules/ScanOrderLogger/providers/grafana.js +0 -50
- package/dist/modules/ScanOrderLogger/types.d.ts +0 -53
- package/dist/modules/ScanOrderLogger/types.js +0 -1
- package/dist/solution/ScanOrder/index.d.ts +0 -158
- package/dist/solution/ScanOrder/index.js +0 -3474
- package/dist/solution/ScanOrder/types.d.ts +0 -306
- package/dist/solution/ScanOrder/types.js +0 -35
- package/dist/solution/ScanOrder/utils.d.ts +0 -172
- package/dist/solution/ScanOrder/utils.js +0 -796
- package/dist/solution/VenueBooking/index.d.ts +0 -252
- package/dist/solution/VenueBooking/index.js +0 -3769
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +0 -343
- package/dist/solution/VenueBooking/types.d.ts +0 -156
- package/dist/solution/VenueBooking/types.js +0 -22
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +0 -11
- package/dist/solution/VenueBooking/utils/dateSummary.js +0 -91
- package/dist/solution/VenueBooking/utils/resource.d.ts +0 -14
- package/dist/solution/VenueBooking/utils/resource.js +0 -131
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -32
- package/dist/solution/VenueBooking/utils/slotMerge.js +0 -233
- package/dist/solution/VenueBooking/utils/smartPricing.d.ts +0 -71
- package/dist/solution/VenueBooking/utils/smartPricing.js +0 -302
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -34
- package/dist/solution/VenueBooking/utils/timeSlot.js +0 -458
- package/dist/solution/VenueBooking/utils.d.ts +0 -1
- package/dist/solution/VenueBooking/utils.js +0 -1
- package/lib/apis/picoding.d.ts +0 -0
- package/lib/apis/picoding.js +0 -0
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
- package/lib/model/strategy/adapter/dataVariant/adapter.js +0 -149
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +0 -666
- package/lib/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
- package/lib/model/strategy/adapter/dataVariant/examples.js +0 -293
- package/lib/model/strategy/adapter/dataVariant/index.d.ts +0 -4
- package/lib/model/strategy/adapter/dataVariant/index.js +0 -38
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +0 -149
- package/lib/model/strategy/adapter/dataVariant/type.js +0 -31
- package/lib/modules/OpenData/index.d.ts +0 -24
- package/lib/modules/OpenData/index.js +0 -119
- package/lib/modules/OpenData/types.d.ts +0 -73
- package/lib/modules/OpenData/types.js +0 -17
- package/lib/modules/OpenData/utils.d.ts +0 -2
- package/lib/modules/OpenData/utils.js +0 -111
- package/lib/modules/Quotation/index.d.ts +0 -48
- package/lib/modules/Quotation/index.js +0 -152
- package/lib/modules/Quotation/types.d.ts +0 -42
- package/lib/modules/Quotation/types.js +0 -17
- package/lib/modules/SalesSummary/index.d.ts +0 -63
- package/lib/modules/SalesSummary/index.js +0 -105
- package/lib/modules/SalesSummary/types.d.ts +0 -60
- package/lib/modules/SalesSummary/types.js +0 -17
- package/lib/modules/SalesSummary/utils.d.ts +0 -30
- package/lib/modules/SalesSummary/utils.js +0 -420
- package/lib/modules/ScanOrderLogger/index.d.ts +0 -23
- package/lib/modules/ScanOrderLogger/index.js +0 -147
- package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +0 -2
- package/lib/modules/ScanOrderLogger/providers/feishu.js +0 -157
- package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +0 -2
- package/lib/modules/ScanOrderLogger/providers/grafana.js +0 -52
- package/lib/modules/ScanOrderLogger/types.d.ts +0 -53
- package/lib/modules/ScanOrderLogger/types.js +0 -17
- package/lib/solution/ScanOrder/index.d.ts +0 -158
- package/lib/solution/ScanOrder/index.js +0 -2135
- package/lib/solution/ScanOrder/types.d.ts +0 -306
- package/lib/solution/ScanOrder/types.js +0 -36
- package/lib/solution/ScanOrder/utils.d.ts +0 -172
- package/lib/solution/ScanOrder/utils.js +0 -658
- package/lib/solution/VenueBooking/index.d.ts +0 -252
- package/lib/solution/VenueBooking/index.js +0 -2204
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +0 -343
- package/lib/solution/VenueBooking/types.d.ts +0 -156
- package/lib/solution/VenueBooking/types.js +0 -45
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +0 -11
- package/lib/solution/VenueBooking/utils/dateSummary.js +0 -105
- package/lib/solution/VenueBooking/utils/resource.d.ts +0 -14
- package/lib/solution/VenueBooking/utils/resource.js +0 -92
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -32
- package/lib/solution/VenueBooking/utils/slotMerge.js +0 -236
- package/lib/solution/VenueBooking/utils/smartPricing.d.ts +0 -71
- package/lib/solution/VenueBooking/utils/smartPricing.js +0 -225
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -34
- package/lib/solution/VenueBooking/utils/timeSlot.js +0 -343
- package/lib/solution/VenueBooking/utils.d.ts +0 -1
- package/lib/solution/VenueBooking/utils.js +0 -69
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
4
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
5
|
-
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; } } }; }
|
|
6
|
-
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); }
|
|
7
|
-
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; }
|
|
8
|
-
import dayjs from 'dayjs';
|
|
9
|
-
import { isBusinessHoursCrossDay } from "./timeSlot";
|
|
10
|
-
|
|
11
|
-
/** VenueBooking 智能定价运行时上下文 */
|
|
12
|
-
|
|
13
|
-
/** 从商品上读取展示/算价用的 price 字段 */
|
|
14
|
-
export function extractProductPrice(product) {
|
|
15
|
-
var _product$price;
|
|
16
|
-
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;
|
|
17
|
-
if (price == null || price === '') return null;
|
|
18
|
-
return String(price);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/** 组装 DataVariant 评估入参,对齐 OS Server buildProductFormatterContext 语义 */
|
|
22
|
-
export function buildDataVariantBusinessData(products, context, scheduleDateTime) {
|
|
23
|
-
var _ref, _context$availableWal, _context$channel, _ref2, _context$orderType, _ref3, _context$businessCode;
|
|
24
|
-
var strategyContext = context.strategy_context || {};
|
|
25
|
-
return {
|
|
26
|
-
products: products,
|
|
27
|
-
strategyConfigs: context.strategyConfigs,
|
|
28
|
-
scheduleDateTime: scheduleDateTime,
|
|
29
|
-
scheduleList: context.scheduleList || [],
|
|
30
|
-
menuList: context.menuList || [],
|
|
31
|
-
customerId: context.customerId,
|
|
32
|
-
availableWalletIds: (_ref = (_context$availableWal = context.availableWalletIds) !== null && _context$availableWal !== void 0 ? _context$availableWal : strategyContext.available_wallet_ids) !== null && _ref !== void 0 ? _ref : strategyContext.availableWalletIds,
|
|
33
|
-
channel: (_context$channel = context.channel) !== null && _context$channel !== void 0 ? _context$channel : strategyContext.channel,
|
|
34
|
-
orderType: (_ref2 = (_context$orderType = context.orderType) !== null && _context$orderType !== void 0 ? _context$orderType : strategyContext.orderType) !== null && _ref2 !== void 0 ? _ref2 : strategyContext.order_type,
|
|
35
|
-
businessCode: (_ref3 = (_context$businessCode = context.businessCode) !== null && _context$businessCode !== void 0 ? _context$businessCode : strategyContext.business_code) !== null && _ref3 !== void 0 ? _ref3 : strategyContext.businessCode,
|
|
36
|
-
custom: strategyContext,
|
|
37
|
-
debugLog: context === null || context === void 0 ? void 0 : context.debugLog
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* 对商品列表执行一次智能定价格式化(loadProducts 后使用)。
|
|
43
|
-
* evaluator 未注入时原样返回并打 warning。
|
|
44
|
-
*/
|
|
45
|
-
export function formatProductsWithDataVariant(products, context, scheduleDateTime) {
|
|
46
|
-
var _context$debugLog, _context$debugLog2, _result$globalEffecti, _result$globalEffecti2;
|
|
47
|
-
var evaluator = context.evaluator;
|
|
48
|
-
if (!evaluator || typeof evaluator.resolveProducts !== 'function') {
|
|
49
|
-
console.warn('[VenueBooking][smartPricing] dataVariantEvaluator 未注入,跳过智能定价格式化');
|
|
50
|
-
return products;
|
|
51
|
-
}
|
|
52
|
-
var resolvedAt = scheduleDateTime || dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
53
|
-
var businessData = buildDataVariantBusinessData(products, context, resolvedAt);
|
|
54
|
-
(_context$debugLog = context.debugLog) === null || _context$debugLog === void 0 || _context$debugLog.call(context, '[VenueBooking][smartPricing] formatProducts input', {
|
|
55
|
-
scheduleDateTime: resolvedAt,
|
|
56
|
-
customerId: businessData.customerId,
|
|
57
|
-
availableWalletIds: businessData.availableWalletIds,
|
|
58
|
-
channel: businessData.channel,
|
|
59
|
-
businessCode: businessData.businessCode,
|
|
60
|
-
orderType: businessData.orderType,
|
|
61
|
-
productCount: products.length,
|
|
62
|
-
products: products.map(function (product) {
|
|
63
|
-
var _product$id;
|
|
64
|
-
return {
|
|
65
|
-
productId: (_product$id = product === null || product === void 0 ? void 0 : product.id) !== null && _product$id !== void 0 ? _product$id : product === null || product === void 0 ? void 0 : product.product_id,
|
|
66
|
-
price: product === null || product === void 0 ? void 0 : product.price,
|
|
67
|
-
sellingPrice: product === null || product === void 0 ? void 0 : product.selling_price,
|
|
68
|
-
dataVariants: Array.isArray(product === null || product === void 0 ? void 0 : product.data_variants) ? product.data_variants.map(function (variant) {
|
|
69
|
-
return {
|
|
70
|
-
dataVariantRuleId: variant === null || variant === void 0 ? void 0 : variant.data_variant_rule_id,
|
|
71
|
-
data: variant === null || variant === void 0 ? void 0 : variant.data
|
|
72
|
-
};
|
|
73
|
-
}) : []
|
|
74
|
-
};
|
|
75
|
-
})
|
|
76
|
-
});
|
|
77
|
-
var result = evaluator.resolveProducts(businessData);
|
|
78
|
-
(_context$debugLog2 = context.debugLog) === null || _context$debugLog2 === void 0 || _context$debugLog2.call(context, '[VenueBooking][smartPricing] formatProducts output', {
|
|
79
|
-
scheduleDateTime: resolvedAt,
|
|
80
|
-
effectiveRuleIds: Array.from((result === null || result === void 0 || (_result$globalEffecti = result.globalEffectiveRuleMap) === null || _result$globalEffecti === void 0 || (_result$globalEffecti2 = _result$globalEffecti.keys) === null || _result$globalEffecti2 === void 0 ? void 0 : _result$globalEffecti2.call(_result$globalEffecti)) || []),
|
|
81
|
-
resultProducts: (result === null || result === void 0 ? void 0 : result.products) || []
|
|
82
|
-
});
|
|
83
|
-
return Array.isArray(result === null || result === void 0 ? void 0 : result.products) ? result.products : products;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* 根据 schedule_time_points 与营业开始时间,构造当天需要评估的 datetime 列表(升序)。
|
|
88
|
-
* 跨日营业时,早于营业开始小时的时间点归到次日。
|
|
89
|
-
*/
|
|
90
|
-
export function buildEvaluationDatetimes(params) {
|
|
91
|
-
var date = params.date,
|
|
92
|
-
config = params.config,
|
|
93
|
-
scheduleTimePoints = params.scheduleTimePoints;
|
|
94
|
-
var crossDay = isBusinessHoursCrossDay(config);
|
|
95
|
-
var businessStartHour = Number(config.businessStartTime.split(':')[0]);
|
|
96
|
-
var evalSet = new Set();
|
|
97
|
-
evalSet.add("".concat(date, " ").concat(config.businessStartTime));
|
|
98
|
-
var _iterator = _createForOfIteratorHelper(scheduleTimePoints),
|
|
99
|
-
_step;
|
|
100
|
-
try {
|
|
101
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
102
|
-
var timePoint = _step.value;
|
|
103
|
-
var hour = Number(timePoint.split(':')[0]);
|
|
104
|
-
var pointDate = crossDay && hour < businessStartHour ? dayjs(date).add(1, 'day').format('YYYY-MM-DD') : date;
|
|
105
|
-
evalSet.add("".concat(pointDate, " ").concat(timePoint));
|
|
106
|
-
}
|
|
107
|
-
} catch (err) {
|
|
108
|
-
_iterator.e(err);
|
|
109
|
-
} finally {
|
|
110
|
-
_iterator.f();
|
|
111
|
-
}
|
|
112
|
-
return Array.from(evalSet).sort(function (a, b) {
|
|
113
|
-
var aMs = dayjs(a, ['YYYY-MM-DD HH:mm:ss', 'YYYY-MM-DD HH:mm']).valueOf();
|
|
114
|
-
var bMs = dayjs(b, ['YYYY-MM-DD HH:mm:ss', 'YYYY-MM-DD HH:mm']).valueOf();
|
|
115
|
-
return aMs - bMs;
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/** 找到 slot 时间所属分段的评估 datetime(max(evalDt <= slotDt)) */
|
|
120
|
-
export function findSegmentEvalDatetime(slotDatetime, evalDatetimes) {
|
|
121
|
-
if (!evalDatetimes.length) return slotDatetime;
|
|
122
|
-
var slotMs = dayjs(slotDatetime, ['YYYY-MM-DD HH:mm:ss', 'YYYY-MM-DD HH:mm']).valueOf();
|
|
123
|
-
var chosen = evalDatetimes[0];
|
|
124
|
-
var _iterator2 = _createForOfIteratorHelper(evalDatetimes),
|
|
125
|
-
_step2;
|
|
126
|
-
try {
|
|
127
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
128
|
-
var evalDt = _step2.value;
|
|
129
|
-
var evalMs = dayjs(evalDt, ['YYYY-MM-DD HH:mm:ss', 'YYYY-MM-DD HH:mm']).valueOf();
|
|
130
|
-
if (evalMs <= slotMs) {
|
|
131
|
-
chosen = evalDt;
|
|
132
|
-
} else {
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
} catch (err) {
|
|
137
|
-
_iterator2.e(err);
|
|
138
|
-
} finally {
|
|
139
|
-
_iterator2.f();
|
|
140
|
-
}
|
|
141
|
-
return chosen;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/** 将 slot 标签转为与 timeSlot 网格一致的 slotStart 字符串 */
|
|
145
|
-
export function buildSlotStartDatetime(date, label, config) {
|
|
146
|
-
var crossDay = isBusinessHoursCrossDay(config);
|
|
147
|
-
var businessStartHour = Number(config.businessStartTime.split(':')[0]);
|
|
148
|
-
var hour = Number(label.split(':')[0]);
|
|
149
|
-
var slotDate = crossDay && hour < businessStartHour ? dayjs(date).add(1, 'day').format('YYYY-MM-DD') : date;
|
|
150
|
-
return dayjs("".concat(slotDate, " ").concat(label)).format('YYYY-MM-DD HH:mm');
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* 按 schedule 分段批量 resolveProducts,输出与 quotation 相同 key 格式的 slot 价格 Map。
|
|
155
|
-
* key: `${productId}:${slotStart}`,value: price | null
|
|
156
|
-
*/
|
|
157
|
-
export function buildSlotPriceMapByScheduleSegments(params) {
|
|
158
|
-
var _context$debugLog3, _context$debugLog4;
|
|
159
|
-
var products = params.products,
|
|
160
|
-
productIds = params.productIds,
|
|
161
|
-
date = params.date,
|
|
162
|
-
timeLabels = params.timeLabels,
|
|
163
|
-
config = params.config,
|
|
164
|
-
context = params.context;
|
|
165
|
-
var map = new Map();
|
|
166
|
-
if (!productIds.length || !timeLabels.length) return map;
|
|
167
|
-
var evaluator = context.evaluator;
|
|
168
|
-
if (!evaluator || typeof evaluator.resolveProducts !== 'function') {
|
|
169
|
-
return map;
|
|
170
|
-
}
|
|
171
|
-
var strategyConfigs = context.strategyConfigs || (typeof evaluator.getStrategyConfigs === 'function' ? evaluator.getStrategyConfigs() : []);
|
|
172
|
-
var scheduleTimePoints = typeof evaluator.buildScheduleTimePoints === 'function' ? evaluator.buildScheduleTimePoints(strategyConfigs, context.scheduleList || []) : [];
|
|
173
|
-
var evalDatetimes = buildEvaluationDatetimes({
|
|
174
|
-
date: date,
|
|
175
|
-
config: config,
|
|
176
|
-
scheduleTimePoints: scheduleTimePoints
|
|
177
|
-
});
|
|
178
|
-
var priceCache = new Map();
|
|
179
|
-
(_context$debugLog3 = context.debugLog) === null || _context$debugLog3 === void 0 || _context$debugLog3.call(context, '[VenueBooking][smartPricing] slot price evaluation started', {
|
|
180
|
-
date: date,
|
|
181
|
-
productIds: productIds,
|
|
182
|
-
scheduleTimePoints: scheduleTimePoints,
|
|
183
|
-
evalDatetimes: evalDatetimes,
|
|
184
|
-
timeLabels: timeLabels
|
|
185
|
-
});
|
|
186
|
-
var _iterator3 = _createForOfIteratorHelper(evalDatetimes),
|
|
187
|
-
_step3;
|
|
188
|
-
try {
|
|
189
|
-
var _loop = function _loop() {
|
|
190
|
-
var _context$debugLog5;
|
|
191
|
-
var evalDt = _step3.value;
|
|
192
|
-
var resolved = formatProductsWithDataVariant(products, context, evalDt);
|
|
193
|
-
var priceByProductId = new Map();
|
|
194
|
-
var _iterator5 = _createForOfIteratorHelper(resolved),
|
|
195
|
-
_step5;
|
|
196
|
-
try {
|
|
197
|
-
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
198
|
-
var product = _step5.value;
|
|
199
|
-
var productId = Number(product.id);
|
|
200
|
-
if (!Number.isFinite(productId)) continue;
|
|
201
|
-
priceByProductId.set(productId, extractProductPrice(product));
|
|
202
|
-
}
|
|
203
|
-
} catch (err) {
|
|
204
|
-
_iterator5.e(err);
|
|
205
|
-
} finally {
|
|
206
|
-
_iterator5.f();
|
|
207
|
-
}
|
|
208
|
-
priceCache.set(evalDt, priceByProductId);
|
|
209
|
-
(_context$debugLog5 = context.debugLog) === null || _context$debugLog5 === void 0 || _context$debugLog5.call(context, '[VenueBooking][smartPricing] slot segment prices resolved', {
|
|
210
|
-
date: date,
|
|
211
|
-
evalDatetime: evalDt,
|
|
212
|
-
prices: productIds.map(function (productId) {
|
|
213
|
-
var _priceByProductId$get;
|
|
214
|
-
return {
|
|
215
|
-
productId: productId,
|
|
216
|
-
price: (_priceByProductId$get = priceByProductId.get(productId)) !== null && _priceByProductId$get !== void 0 ? _priceByProductId$get : null
|
|
217
|
-
};
|
|
218
|
-
})
|
|
219
|
-
});
|
|
220
|
-
};
|
|
221
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
222
|
-
_loop();
|
|
223
|
-
}
|
|
224
|
-
} catch (err) {
|
|
225
|
-
_iterator3.e(err);
|
|
226
|
-
} finally {
|
|
227
|
-
_iterator3.f();
|
|
228
|
-
}
|
|
229
|
-
var _iterator4 = _createForOfIteratorHelper(timeLabels),
|
|
230
|
-
_step4;
|
|
231
|
-
try {
|
|
232
|
-
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
233
|
-
var label = _step4.value;
|
|
234
|
-
var slotStart = buildSlotStartDatetime(date, label, config);
|
|
235
|
-
var segmentEvalDt = findSegmentEvalDatetime(slotStart, evalDatetimes);
|
|
236
|
-
var priceByProductId = priceCache.get(segmentEvalDt);
|
|
237
|
-
var _iterator6 = _createForOfIteratorHelper(productIds),
|
|
238
|
-
_step6;
|
|
239
|
-
try {
|
|
240
|
-
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
241
|
-
var _priceByProductId$get2;
|
|
242
|
-
var productId = _step6.value;
|
|
243
|
-
var key = "".concat(productId, ":").concat(slotStart);
|
|
244
|
-
var price = (_priceByProductId$get2 = priceByProductId === null || priceByProductId === void 0 ? void 0 : priceByProductId.get(productId)) !== null && _priceByProductId$get2 !== void 0 ? _priceByProductId$get2 : null;
|
|
245
|
-
if (price !== null) {
|
|
246
|
-
map.set(key, price);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
} catch (err) {
|
|
250
|
-
_iterator6.e(err);
|
|
251
|
-
} finally {
|
|
252
|
-
_iterator6.f();
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
} catch (err) {
|
|
256
|
-
_iterator4.e(err);
|
|
257
|
-
} finally {
|
|
258
|
-
_iterator4.f();
|
|
259
|
-
}
|
|
260
|
-
(_context$debugLog4 = context.debugLog) === null || _context$debugLog4 === void 0 || _context$debugLog4.call(context, '[VenueBooking][smartPricing] slot price map completed', {
|
|
261
|
-
date: date,
|
|
262
|
-
entries: Array.from(map.entries()).map(function (_ref4) {
|
|
263
|
-
var _ref5 = _slicedToArray(_ref4, 2),
|
|
264
|
-
key = _ref5[0],
|
|
265
|
-
price = _ref5[1];
|
|
266
|
-
return {
|
|
267
|
-
key: key,
|
|
268
|
-
price: price
|
|
269
|
-
};
|
|
270
|
-
})
|
|
271
|
-
});
|
|
272
|
-
return map;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* 指定商品在某一 datetime 的智能定价(addon / 单点重算用)。
|
|
277
|
-
*/
|
|
278
|
-
export function getPriceForProductAtDatetime(params) {
|
|
279
|
-
var _ref6, _extractProductPrice;
|
|
280
|
-
var products = params.products,
|
|
281
|
-
context = params.context,
|
|
282
|
-
productId = params.productId,
|
|
283
|
-
datetime = params.datetime,
|
|
284
|
-
fallbackPrice = params.fallbackPrice;
|
|
285
|
-
var resolved = formatProductsWithDataVariant(products, context, datetime);
|
|
286
|
-
var product = resolved.find(function (item) {
|
|
287
|
-
return Number(item.id) === Number(productId);
|
|
288
|
-
});
|
|
289
|
-
return (_ref6 = (_extractProductPrice = extractProductPrice(product || {})) !== null && _extractProductPrice !== void 0 ? _extractProductPrice : fallbackPrice) !== null && _ref6 !== void 0 ? _ref6 : '0.00';
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
/** 从 slot 价格 Map 读取单价,找不到则回退 fallback */
|
|
293
|
-
export function getSlotPriceFromMap(params) {
|
|
294
|
-
var slotPriceMap = params.slotPriceMap,
|
|
295
|
-
productId = params.productId,
|
|
296
|
-
slotStartTime = params.slotStartTime,
|
|
297
|
-
fallbackPrice = params.fallbackPrice;
|
|
298
|
-
var key = "".concat(productId, ":").concat(slotStartTime);
|
|
299
|
-
var mapped = slotPriceMap.get(key);
|
|
300
|
-
if (mapped != null) return mapped;
|
|
301
|
-
return fallbackPrice !== null && fallbackPrice !== void 0 ? fallbackPrice : '0.00';
|
|
302
|
-
}
|
|
@@ -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 {};
|