@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,131 +0,0 @@
|
|
|
1
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
4
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(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
|
-
/**
|
|
9
|
-
* 从商品列表里抽取所有 resource_id:
|
|
10
|
-
* - 商品绑定的 default_resource / optional_resource
|
|
11
|
-
* - 以及这些资源上声明的 combined_resource.resource_ids(若可从 product_resource 读取)
|
|
12
|
-
* 用于一次性拉到子资源数据,判定组合资源的可用性。
|
|
13
|
-
*/
|
|
14
|
-
export function extractResourceIds(products) {
|
|
15
|
-
var ids = new Set();
|
|
16
|
-
var _iterator = _createForOfIteratorHelper(products),
|
|
17
|
-
_step;
|
|
18
|
-
try {
|
|
19
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
20
|
-
var _product$product_reso;
|
|
21
|
-
var product = _step.value;
|
|
22
|
-
var resources = (_product$product_reso = product.product_resource) === null || _product$product_reso === void 0 ? void 0 : _product$product_reso.resources;
|
|
23
|
-
if (!Array.isArray(resources)) continue;
|
|
24
|
-
var _iterator2 = _createForOfIteratorHelper(resources),
|
|
25
|
-
_step2;
|
|
26
|
-
try {
|
|
27
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
28
|
-
var resource = _step2.value;
|
|
29
|
-
if (resource.status !== 1) continue;
|
|
30
|
-
var defaultRes = resource.default_resource || [];
|
|
31
|
-
var optionalRes = resource.optional_resource || [];
|
|
32
|
-
for (var _i = 0, _arr = [].concat(_toConsumableArray(defaultRes), _toConsumableArray(optionalRes)); _i < _arr.length; _i++) {
|
|
33
|
-
var id = _arr[_i];
|
|
34
|
-
if (typeof id === 'number' && id > 0) ids.add(id);
|
|
35
|
-
}
|
|
36
|
-
var combined = resource.combined_resource;
|
|
37
|
-
if (combined && combined.status === 1 && Array.isArray(combined.resource_ids)) {
|
|
38
|
-
var _iterator3 = _createForOfIteratorHelper(combined.resource_ids),
|
|
39
|
-
_step3;
|
|
40
|
-
try {
|
|
41
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
42
|
-
var _id = _step3.value;
|
|
43
|
-
if (typeof _id === 'number' && _id > 0) ids.add(_id);
|
|
44
|
-
}
|
|
45
|
-
} catch (err) {
|
|
46
|
-
_iterator3.e(err);
|
|
47
|
-
} finally {
|
|
48
|
-
_iterator3.f();
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
} catch (err) {
|
|
53
|
-
_iterator2.e(err);
|
|
54
|
-
} finally {
|
|
55
|
-
_iterator2.f();
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
} catch (err) {
|
|
59
|
-
_iterator.e(err);
|
|
60
|
-
} finally {
|
|
61
|
-
_iterator.f();
|
|
62
|
-
}
|
|
63
|
-
return Array.from(ids);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* 每个 resourceId 可以被多个商品共享(同一场地关联多种运动商品)。
|
|
68
|
-
* Map 的 value 改为 ResourceProductMapping[],按商品出现顺序保留。
|
|
69
|
-
*/
|
|
70
|
-
export function buildResourceProductMap(products) {
|
|
71
|
-
var map = new Map();
|
|
72
|
-
var _iterator4 = _createForOfIteratorHelper(products),
|
|
73
|
-
_step4;
|
|
74
|
-
try {
|
|
75
|
-
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
76
|
-
var _product$product_reso2;
|
|
77
|
-
var product = _step4.value;
|
|
78
|
-
var resources = (_product$product_reso2 = product.product_resource) === null || _product$product_reso2 === void 0 ? void 0 : _product$product_reso2.resources;
|
|
79
|
-
if (!Array.isArray(resources)) continue;
|
|
80
|
-
var _iterator5 = _createForOfIteratorHelper(resources),
|
|
81
|
-
_step5;
|
|
82
|
-
try {
|
|
83
|
-
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
84
|
-
var resource = _step5.value;
|
|
85
|
-
if (resource.status !== 1) continue;
|
|
86
|
-
var allResourceIds = [].concat(_toConsumableArray(resource.default_resource || []), _toConsumableArray(resource.optional_resource || []));
|
|
87
|
-
var _iterator6 = _createForOfIteratorHelper(allResourceIds),
|
|
88
|
-
_step6;
|
|
89
|
-
try {
|
|
90
|
-
var _loop = function _loop() {
|
|
91
|
-
var resId = _step6.value;
|
|
92
|
-
var existing = map.get(resId);
|
|
93
|
-
var mapping = {
|
|
94
|
-
productId: product.id,
|
|
95
|
-
productTitle: product.title,
|
|
96
|
-
formName: resource.title,
|
|
97
|
-
resourceName: resource.title,
|
|
98
|
-
formId: resource.id,
|
|
99
|
-
price: product.price || '0.00',
|
|
100
|
-
resourceType: resource.type || 'single'
|
|
101
|
-
};
|
|
102
|
-
if (!existing) {
|
|
103
|
-
map.set(resId, [mapping]);
|
|
104
|
-
} else if (!existing.some(function (m) {
|
|
105
|
-
return m.productId === mapping.productId;
|
|
106
|
-
})) {
|
|
107
|
-
existing.push(mapping);
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
111
|
-
_loop();
|
|
112
|
-
}
|
|
113
|
-
} catch (err) {
|
|
114
|
-
_iterator6.e(err);
|
|
115
|
-
} finally {
|
|
116
|
-
_iterator6.f();
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
} catch (err) {
|
|
120
|
-
_iterator5.e(err);
|
|
121
|
-
} finally {
|
|
122
|
-
_iterator5.f();
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
} catch (err) {
|
|
126
|
-
_iterator4.e(err);
|
|
127
|
-
} finally {
|
|
128
|
-
_iterator4.f();
|
|
129
|
-
}
|
|
130
|
-
return map;
|
|
131
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { VenueSlotSelection, MergedSlotGroup, PriceBreakdownEntry, ResourceProductMapping, VenueResourceRawData } from '../types';
|
|
2
|
-
import type { ScanOrderOrderProduct } from '../../ScanOrder/types';
|
|
3
|
-
export declare function buildVenueIdentityKey(resourceId: number | string, groupIndex: number): string;
|
|
4
|
-
export declare function mergeConsecutiveSlots(slots: VenueSlotSelection[]): MergedSlotGroup[];
|
|
5
|
-
export declare function buildPriceBreakdown(params: {
|
|
6
|
-
group: MergedSlotGroup;
|
|
7
|
-
productId: number;
|
|
8
|
-
}): PriceBreakdownEntry[];
|
|
9
|
-
export interface BuildVenueBookingParams {
|
|
10
|
-
group: MergedSlotGroup;
|
|
11
|
-
resourceId: number | string;
|
|
12
|
-
mapping: ResourceProductMapping;
|
|
13
|
-
rawResource: VenueResourceRawData | undefined;
|
|
14
|
-
bookingUuid: string;
|
|
15
|
-
productUid: string;
|
|
16
|
-
/**
|
|
17
|
-
* 若当前 resource 是组合资源(combined_resource.status === 1),传入其子资源的原始数据,
|
|
18
|
-
* 将作为 resources[0].children 写入 booking,结构与父 resource 保持一致。
|
|
19
|
-
*/
|
|
20
|
-
childResources?: VenueResourceRawData[];
|
|
21
|
-
}
|
|
22
|
-
export declare function buildVenueResourceMetadata(params: {
|
|
23
|
-
mapping: ResourceProductMapping;
|
|
24
|
-
rawResource: VenueResourceRawData | undefined;
|
|
25
|
-
}): Record<string, any>;
|
|
26
|
-
export declare function buildVenueBookingEntry(params: BuildVenueBookingParams): Record<string, any>;
|
|
27
|
-
/**
|
|
28
|
-
* 从一条已合并的订单商品还原出独立的时段列表。
|
|
29
|
-
* 优先使用 metadata.price_breakdown 还原每个时段的精确价格,
|
|
30
|
-
* 回退到按 selling_price / slot_count 均分。
|
|
31
|
-
*/
|
|
32
|
-
export declare function expandMergedSlotToIndividual(product: ScanOrderOrderProduct, slotDurationMinutes: number): VenueSlotSelection[];
|
|
@@ -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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
-
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); }
|
|
5
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
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 Decimal from 'decimal.js';
|
|
9
|
-
import dayjs from 'dayjs';
|
|
10
|
-
import { createUuidV4 } from "../../../modules/Order/utils";
|
|
11
|
-
export function buildVenueIdentityKey(resourceId, groupIndex) {
|
|
12
|
-
return "venue:".concat(resourceId, ":").concat(groupIndex, ":").concat(createUuidV4());
|
|
13
|
-
}
|
|
14
|
-
export function mergeConsecutiveSlots(slots) {
|
|
15
|
-
if (!slots.length) return [];
|
|
16
|
-
var sorted = _toConsumableArray(slots).sort(function (a, b) {
|
|
17
|
-
return a.startTime.localeCompare(b.startTime);
|
|
18
|
-
});
|
|
19
|
-
var groups = [];
|
|
20
|
-
var currentSlots = [sorted[0]];
|
|
21
|
-
var currentStart = sorted[0].startTime;
|
|
22
|
-
var currentEnd = sorted[0].endTime;
|
|
23
|
-
var totalPrice = new Decimal(sorted[0].price || '0');
|
|
24
|
-
for (var i = 1; i < sorted.length; i++) {
|
|
25
|
-
var slot = sorted[i];
|
|
26
|
-
if (slot.startTime === currentEnd) {
|
|
27
|
-
currentEnd = slot.endTime;
|
|
28
|
-
totalPrice = totalPrice.add(new Decimal(slot.price || '0'));
|
|
29
|
-
currentSlots.push(slot);
|
|
30
|
-
} else {
|
|
31
|
-
groups.push({
|
|
32
|
-
startTime: currentStart,
|
|
33
|
-
endTime: currentEnd,
|
|
34
|
-
totalPrice: totalPrice.toFixed(2),
|
|
35
|
-
slotCount: currentSlots.length,
|
|
36
|
-
slots: currentSlots
|
|
37
|
-
});
|
|
38
|
-
currentSlots = [slot];
|
|
39
|
-
currentStart = slot.startTime;
|
|
40
|
-
currentEnd = slot.endTime;
|
|
41
|
-
totalPrice = new Decimal(slot.price || '0');
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
groups.push({
|
|
45
|
-
startTime: currentStart,
|
|
46
|
-
endTime: currentEnd,
|
|
47
|
-
totalPrice: totalPrice.toFixed(2),
|
|
48
|
-
slotCount: currentSlots.length,
|
|
49
|
-
slots: currentSlots
|
|
50
|
-
});
|
|
51
|
-
return groups;
|
|
52
|
-
}
|
|
53
|
-
export function buildPriceBreakdown(params) {
|
|
54
|
-
var group = params.group;
|
|
55
|
-
if (!group.slots.length) return [];
|
|
56
|
-
var entries = [];
|
|
57
|
-
var _iterator = _createForOfIteratorHelper(group.slots),
|
|
58
|
-
_step;
|
|
59
|
-
try {
|
|
60
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
61
|
-
var slot = _step.value;
|
|
62
|
-
var unitPrice = Number(slot.price || '0');
|
|
63
|
-
var startHm = dayjs(slot.startTime, 'YYYY-MM-DD HH:mm').format('YYYY-MM-DD HH:mm');
|
|
64
|
-
var endHm = dayjs(slot.endTime, 'YYYY-MM-DD HH:mm').format('YYYY-MM-DD HH:mm');
|
|
65
|
-
var last = entries[entries.length - 1];
|
|
66
|
-
if (last && last.unit_price === unitPrice && last.quotation_shelf_id === 0 && last.end_time === startHm) {
|
|
67
|
-
last.end_time = endHm;
|
|
68
|
-
last.quantity += 1;
|
|
69
|
-
} else {
|
|
70
|
-
entries.push({
|
|
71
|
-
start_time: startHm,
|
|
72
|
-
end_time: endHm,
|
|
73
|
-
unit_price: unitPrice,
|
|
74
|
-
quotation_shelf_id: 0,
|
|
75
|
-
quantity: 1
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
} catch (err) {
|
|
80
|
-
_iterator.e(err);
|
|
81
|
-
} finally {
|
|
82
|
-
_iterator.f();
|
|
83
|
-
}
|
|
84
|
-
return entries;
|
|
85
|
-
}
|
|
86
|
-
export function buildVenueResourceMetadata(params) {
|
|
87
|
-
var _mapping$formName, _rawResource$main_fie;
|
|
88
|
-
var mapping = params.mapping,
|
|
89
|
-
rawResource = params.rawResource;
|
|
90
|
-
var combined = rawResource === null || rawResource === void 0 ? void 0 : rawResource.combined_resource;
|
|
91
|
-
var isCombined = !!(combined && combined.status === 1 && Array.isArray(combined.resource_ids));
|
|
92
|
-
return {
|
|
93
|
-
form_name: (_mapping$formName = mapping.formName) !== null && _mapping$formName !== void 0 ? _mapping$formName : mapping.resourceName,
|
|
94
|
-
resource_name: (_rawResource$main_fie = rawResource === null || rawResource === void 0 ? void 0 : rawResource.main_field) !== null && _rawResource$main_fie !== void 0 ? _rawResource$main_fie : mapping.resourceName,
|
|
95
|
-
combined_resource: isCombined ? combined : null
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
export function buildVenueBookingEntry(params) {
|
|
99
|
-
var _rawResource$form_id;
|
|
100
|
-
var group = params.group,
|
|
101
|
-
resourceId = params.resourceId,
|
|
102
|
-
mapping = params.mapping,
|
|
103
|
-
rawResource = params.rawResource,
|
|
104
|
-
bookingUuid = params.bookingUuid,
|
|
105
|
-
productUid = params.productUid,
|
|
106
|
-
childResources = params.childResources;
|
|
107
|
-
var startMoment = dayjs(group.startTime, 'YYYY-MM-DD HH:mm');
|
|
108
|
-
var endMoment = dayjs(group.endTime, 'YYYY-MM-DD HH:mm');
|
|
109
|
-
var duration = endMoment.diff(startMoment, 'minute');
|
|
110
|
-
var resourceEntry = {
|
|
111
|
-
relation_type: 'form',
|
|
112
|
-
like_status: 'common',
|
|
113
|
-
id: resourceId,
|
|
114
|
-
main_field: mapping.resourceName,
|
|
115
|
-
form_id: (_rawResource$form_id = rawResource === null || rawResource === void 0 ? void 0 : rawResource.form_id) !== null && _rawResource$form_id !== void 0 ? _rawResource$form_id : mapping.formId,
|
|
116
|
-
relation_id: resourceId,
|
|
117
|
-
capacity: 1,
|
|
118
|
-
metadata: buildVenueResourceMetadata({
|
|
119
|
-
mapping: mapping,
|
|
120
|
-
rawResource: rawResource
|
|
121
|
-
})
|
|
122
|
-
};
|
|
123
|
-
if (childResources && childResources.length) {
|
|
124
|
-
resourceEntry.children = childResources.map(function (child) {
|
|
125
|
-
var _child$form_id, _child$capacity;
|
|
126
|
-
return {
|
|
127
|
-
relation_type: 'form',
|
|
128
|
-
like_status: 'common',
|
|
129
|
-
id: child.resourceId,
|
|
130
|
-
main_field: child.main_field || '',
|
|
131
|
-
form_id: (_child$form_id = child.form_id) !== null && _child$form_id !== void 0 ? _child$form_id : child.formId,
|
|
132
|
-
relation_id: child.resourceId,
|
|
133
|
-
capacity: (_child$capacity = child.capacity) !== null && _child$capacity !== void 0 ? _child$capacity : 1,
|
|
134
|
-
metadata: {}
|
|
135
|
-
};
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
return {
|
|
139
|
-
schedule_event_id: null,
|
|
140
|
-
appointment_status: 'new',
|
|
141
|
-
start_date: startMoment.format('YYYY-MM-DD'),
|
|
142
|
-
start_time: startMoment.format('HH:mm'),
|
|
143
|
-
end_date: endMoment.format('YYYY-MM-DD'),
|
|
144
|
-
end_time: endMoment.format('HH:mm'),
|
|
145
|
-
select_date: startMoment.format('YYYY-MM-DD'),
|
|
146
|
-
duration: duration,
|
|
147
|
-
sub_type: 'minutes',
|
|
148
|
-
like_status: 'common',
|
|
149
|
-
number: 1,
|
|
150
|
-
is_all: false,
|
|
151
|
-
schedule_id: 0,
|
|
152
|
-
product_uid: productUid,
|
|
153
|
-
resources: [resourceEntry],
|
|
154
|
-
relation_products: [],
|
|
155
|
-
relation_forms: [],
|
|
156
|
-
holder: null,
|
|
157
|
-
metadata: {
|
|
158
|
-
unique_identification_number: bookingUuid,
|
|
159
|
-
venue_booking: true,
|
|
160
|
-
resource_id: resourceId,
|
|
161
|
-
product_id: mapping.productId
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* 从一条已合并的订单商品还原出独立的时段列表。
|
|
168
|
-
* 优先使用 metadata.price_breakdown 还原每个时段的精确价格,
|
|
169
|
-
* 回退到按 selling_price / slot_count 均分。
|
|
170
|
-
*/
|
|
171
|
-
export function expandMergedSlotToIndividual(product, slotDurationMinutes) {
|
|
172
|
-
var meta = product.metadata || {};
|
|
173
|
-
var resourceId = meta.resource_id;
|
|
174
|
-
if (resourceId == null) return [];
|
|
175
|
-
var startTime = meta.start_time;
|
|
176
|
-
var endTime = meta.end_time;
|
|
177
|
-
if (!startTime || !endTime) return [];
|
|
178
|
-
var productId = Number(product.product_id);
|
|
179
|
-
var breakdown = meta.price_breakdown;
|
|
180
|
-
var result = [];
|
|
181
|
-
var cursor = dayjs(startTime, 'YYYY-MM-DD HH:mm');
|
|
182
|
-
var end = dayjs(endTime, 'YYYY-MM-DD HH:mm');
|
|
183
|
-
if (breakdown !== null && breakdown !== void 0 && breakdown.length) {
|
|
184
|
-
var priceMap = new Map();
|
|
185
|
-
var _iterator2 = _createForOfIteratorHelper(breakdown),
|
|
186
|
-
_step2;
|
|
187
|
-
try {
|
|
188
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
189
|
-
var entry = _step2.value;
|
|
190
|
-
var entryCursor = dayjs(entry.start_time, 'YYYY-MM-DD HH:mm');
|
|
191
|
-
var entryEnd = dayjs(entry.end_time, 'YYYY-MM-DD HH:mm');
|
|
192
|
-
while (entryCursor.isBefore(entryEnd)) {
|
|
193
|
-
priceMap.set(entryCursor.format('HH:mm'), entry.unit_price);
|
|
194
|
-
entryCursor = entryCursor.add(slotDurationMinutes, 'minute');
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
} catch (err) {
|
|
198
|
-
_iterator2.e(err);
|
|
199
|
-
} finally {
|
|
200
|
-
_iterator2.f();
|
|
201
|
-
}
|
|
202
|
-
while (cursor.isBefore(end)) {
|
|
203
|
-
var _priceMap$get;
|
|
204
|
-
var slotEnd = cursor.add(slotDurationMinutes, 'minute');
|
|
205
|
-
var hm = cursor.format('HH:mm');
|
|
206
|
-
var price = (_priceMap$get = priceMap.get(hm)) !== null && _priceMap$get !== void 0 ? _priceMap$get : 0;
|
|
207
|
-
result.push({
|
|
208
|
-
resourceId: resourceId,
|
|
209
|
-
productId: productId,
|
|
210
|
-
startTime: cursor.format('YYYY-MM-DD HH:mm'),
|
|
211
|
-
endTime: slotEnd.format('YYYY-MM-DD HH:mm'),
|
|
212
|
-
price: new Decimal(price).toFixed(2)
|
|
213
|
-
});
|
|
214
|
-
cursor = slotEnd;
|
|
215
|
-
}
|
|
216
|
-
} else {
|
|
217
|
-
var slotCount = meta.slot_count || 1;
|
|
218
|
-
var totalPrice = new Decimal(product.selling_price || '0');
|
|
219
|
-
var perSlotPrice = slotCount > 0 ? totalPrice.div(slotCount).toFixed(2) : totalPrice.toFixed(2);
|
|
220
|
-
while (cursor.isBefore(end)) {
|
|
221
|
-
var _slotEnd = cursor.add(slotDurationMinutes, 'minute');
|
|
222
|
-
result.push({
|
|
223
|
-
resourceId: resourceId,
|
|
224
|
-
productId: productId,
|
|
225
|
-
startTime: cursor.format('YYYY-MM-DD HH:mm'),
|
|
226
|
-
endTime: _slotEnd.format('YYYY-MM-DD HH:mm'),
|
|
227
|
-
price: perSlotPrice
|
|
228
|
-
});
|
|
229
|
-
cursor = _slotEnd;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
return result;
|
|
233
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
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
|
-
debugLog?: (title: string, payload?: Record<string, any>) => void;
|
|
20
|
-
}
|
|
21
|
-
/** 从商品上读取展示/算价用的 price 字段 */
|
|
22
|
-
export declare function extractProductPrice(product: DataVariantProduct): string | null;
|
|
23
|
-
/** 组装 DataVariant 评估入参,对齐 OS Server buildProductFormatterContext 语义 */
|
|
24
|
-
export declare function buildDataVariantBusinessData(products: ProductData[], context: VenueBookingSmartPricingContext, scheduleDateTime: string): DataVariantBusinessData;
|
|
25
|
-
/**
|
|
26
|
-
* 对商品列表执行一次智能定价格式化(loadProducts 后使用)。
|
|
27
|
-
* evaluator 未注入时原样返回并打 warning。
|
|
28
|
-
*/
|
|
29
|
-
export declare function formatProductsWithDataVariant(products: ProductData[], context: VenueBookingSmartPricingContext, scheduleDateTime?: string): ProductData[];
|
|
30
|
-
/**
|
|
31
|
-
* 根据 schedule_time_points 与营业开始时间,构造当天需要评估的 datetime 列表(升序)。
|
|
32
|
-
* 跨日营业时,早于营业开始小时的时间点归到次日。
|
|
33
|
-
*/
|
|
34
|
-
export declare function buildEvaluationDatetimes(params: {
|
|
35
|
-
date: string;
|
|
36
|
-
config: VenueBookingSlotConfig;
|
|
37
|
-
scheduleTimePoints: string[];
|
|
38
|
-
}): string[];
|
|
39
|
-
/** 找到 slot 时间所属分段的评估 datetime(max(evalDt <= slotDt)) */
|
|
40
|
-
export declare function findSegmentEvalDatetime(slotDatetime: string, evalDatetimes: string[]): string;
|
|
41
|
-
/** 将 slot 标签转为与 timeSlot 网格一致的 slotStart 字符串 */
|
|
42
|
-
export declare function buildSlotStartDatetime(date: string, label: string, config: VenueBookingSlotConfig): string;
|
|
43
|
-
/**
|
|
44
|
-
* 按 schedule 分段批量 resolveProducts,输出与 quotation 相同 key 格式的 slot 价格 Map。
|
|
45
|
-
* key: `${productId}:${slotStart}`,value: price | null
|
|
46
|
-
*/
|
|
47
|
-
export declare function buildSlotPriceMapByScheduleSegments(params: {
|
|
48
|
-
products: ProductData[];
|
|
49
|
-
productIds: number[];
|
|
50
|
-
date: string;
|
|
51
|
-
timeLabels: string[];
|
|
52
|
-
config: VenueBookingSlotConfig;
|
|
53
|
-
context: VenueBookingSmartPricingContext;
|
|
54
|
-
}): Map<string, string | null>;
|
|
55
|
-
/**
|
|
56
|
-
* 指定商品在某一 datetime 的智能定价(addon / 单点重算用)。
|
|
57
|
-
*/
|
|
58
|
-
export declare function getPriceForProductAtDatetime(params: {
|
|
59
|
-
products: ProductData[];
|
|
60
|
-
context: VenueBookingSmartPricingContext;
|
|
61
|
-
productId: 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;
|