@pisell/pisellos 3.0.90 → 3.0.91
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/apis/picoding.d.ts +0 -0
- package/dist/apis/picoding.js +1 -0
- package/dist/model/index.d.ts +1 -0
- package/dist/model/index.js +1 -0
- package/dist/model/strategy/adapter/index.d.ts +7 -0
- package/dist/model/strategy/adapter/index.js +7 -0
- package/dist/model/strategy/adapter/itemRule/adapter.d.ts +67 -0
- package/dist/model/strategy/adapter/itemRule/adapter.js +483 -0
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
- package/dist/model/strategy/adapter/itemRule/evaluator.js +169 -0
- package/dist/model/strategy/adapter/itemRule/examples.d.ts +79 -0
- package/dist/model/strategy/adapter/itemRule/examples.js +382 -0
- package/dist/model/strategy/adapter/itemRule/index.d.ts +5 -0
- package/dist/model/strategy/adapter/itemRule/index.js +5 -0
- package/dist/model/strategy/adapter/itemRule/type.d.ts +225 -0
- package/dist/model/strategy/adapter/itemRule/type.js +101 -0
- package/dist/model/strategy/adapter/promotion/adapter.d.ts +66 -0
- package/dist/model/strategy/adapter/promotion/adapter.js +271 -0
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +213 -0
- package/dist/model/strategy/adapter/promotion/evaluator.js +1206 -0
- package/dist/model/strategy/adapter/promotion/examples.d.ts +138 -0
- package/dist/model/strategy/adapter/promotion/examples.js +166 -0
- package/dist/model/strategy/adapter/promotion/index.d.ts +4 -0
- package/dist/model/strategy/adapter/promotion/index.js +0 -0
- package/dist/model/strategy/adapter/promotion/type.d.ts +447 -0
- package/dist/model/strategy/adapter/promotion/type.js +209 -0
- package/dist/model/strategy/adapter/type.d.ts +28 -0
- package/dist/model/strategy/adapter/type.js +1 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +84 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.js +502 -0
- package/dist/model/strategy/adapter/walletPass/example.d.ts +4 -0
- package/dist/model/strategy/adapter/walletPass/example.js +258 -0
- package/dist/model/strategy/adapter/walletPass/index.d.ts +32 -0
- package/dist/model/strategy/adapter/walletPass/index.js +182 -0
- package/dist/model/strategy/adapter/walletPass/locales.d.ts +1 -0
- package/dist/model/strategy/adapter/walletPass/locales.js +26 -0
- package/dist/model/strategy/adapter/walletPass/type.d.ts +187 -0
- package/dist/model/strategy/adapter/walletPass/type.js +1 -0
- package/dist/model/strategy/adapter/walletPass/utils.d.ts +50 -0
- package/dist/model/strategy/adapter/walletPass/utils.js +1104 -0
- package/dist/model/strategy/engine.d.ts +106 -0
- package/dist/model/strategy/engine.js +611 -0
- package/dist/model/strategy/index.d.ts +3 -0
- package/dist/model/strategy/index.js +8 -0
- package/dist/model/strategy/strategy-example.d.ts +5 -0
- package/dist/model/strategy/strategy-example.js +331 -0
- package/dist/model/strategy/type.d.ts +228 -0
- package/dist/model/strategy/type.js +94 -0
- package/dist/modules/Cart/utils/cartProduct.js +1 -0
- package/dist/modules/Discount/index.d.ts +4 -2
- package/dist/modules/Discount/index.js +90 -3
- package/dist/modules/Discount/types.d.ts +6 -0
- package/dist/modules/OpenData/index.d.ts +24 -0
- package/dist/modules/OpenData/index.js +173 -0
- package/dist/modules/OpenData/types.d.ts +73 -0
- package/dist/modules/OpenData/types.js +1 -0
- package/dist/modules/OpenData/utils.d.ts +2 -0
- package/dist/modules/OpenData/utils.js +75 -0
- package/dist/modules/Order/index.d.ts +66 -1
- package/dist/modules/Order/index.js +884 -10
- package/dist/modules/Order/types.d.ts +174 -12
- package/dist/modules/Order/types.js +2 -0
- package/dist/modules/Order/utils.d.ts +118 -0
- package/dist/modules/Order/utils.js +586 -2
- package/dist/modules/Product/utils.js +2 -2
- package/dist/modules/ProductList/index.d.ts +3 -1
- package/dist/modules/ProductList/index.js +19 -11
- package/dist/modules/Quotation/index.d.ts +48 -0
- package/dist/modules/Quotation/index.js +248 -0
- package/dist/modules/Quotation/types.d.ts +42 -0
- package/dist/modules/Quotation/types.js +1 -0
- package/dist/modules/Rules/index.js +17 -18
- package/dist/modules/SalesSummary/index.d.ts +63 -0
- package/dist/modules/SalesSummary/index.js +174 -0
- package/dist/modules/SalesSummary/types.d.ts +60 -0
- package/dist/modules/SalesSummary/types.js +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +30 -0
- package/dist/modules/SalesSummary/utils.js +480 -0
- package/dist/modules/ScanOrderLogger/index.d.ts +23 -0
- package/dist/modules/ScanOrderLogger/index.js +174 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.js +221 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.js +50 -0
- package/dist/modules/ScanOrderLogger/types.d.ts +53 -0
- package/dist/modules/ScanOrderLogger/types.js +1 -0
- package/dist/modules/Schedule/getDateIsInSchedule.js +11 -18
- package/dist/modules/Schedule/utils.d.ts +1 -1
- package/dist/modules/Summary/utils.d.ts +3 -3
- package/dist/modules/Summary/utils.js +41 -31
- package/dist/modules/index.d.ts +4 -0
- package/dist/modules/index.js +5 -1
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingByStep/types.d.ts +3 -1
- package/dist/solution/BookingByStep/types.js +5 -1
- package/dist/solution/ScanOrder/index.d.ts +158 -0
- package/dist/solution/ScanOrder/index.js +3474 -0
- package/dist/solution/ScanOrder/types.d.ts +306 -0
- package/dist/solution/ScanOrder/types.js +35 -0
- package/dist/solution/ScanOrder/utils.d.ts +172 -0
- package/dist/solution/ScanOrder/utils.js +796 -0
- package/dist/solution/ShopDiscount/index.d.ts +1 -0
- package/dist/solution/ShopDiscount/index.js +23 -18
- package/dist/solution/VenueBooking/index.d.ts +201 -0
- package/dist/solution/VenueBooking/index.js +3472 -0
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/dist/solution/VenueBooking/types.d.ts +154 -0
- package/dist/solution/VenueBooking/types.js +21 -0
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +104 -0
- package/dist/solution/VenueBooking/utils/resource.d.ts +14 -0
- package/dist/solution/VenueBooking/utils/resource.js +131 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +38 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +239 -0
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/dist/solution/VenueBooking/utils/timeSlot.js +453 -0
- package/dist/solution/VenueBooking/utils.d.ts +1 -0
- package/dist/solution/VenueBooking/utils.js +1 -0
- package/dist/solution/index.d.ts +2 -0
- package/dist/solution/index.js +3 -1
- package/lib/apis/picoding.d.ts +0 -0
- package/lib/apis/picoding.js +0 -0
- package/lib/model/index.d.ts +1 -0
- package/lib/model/index.js +23 -0
- package/lib/model/strategy/adapter/index.d.ts +7 -0
- package/lib/model/strategy/adapter/index.js +57 -0
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +67 -0
- package/lib/model/strategy/adapter/itemRule/adapter.js +377 -0
- package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
- package/lib/model/strategy/adapter/itemRule/evaluator.js +124 -0
- package/lib/model/strategy/adapter/itemRule/examples.d.ts +79 -0
- package/lib/model/strategy/adapter/itemRule/examples.js +316 -0
- package/lib/model/strategy/adapter/itemRule/index.d.ts +5 -0
- package/lib/model/strategy/adapter/itemRule/index.js +60 -0
- package/lib/model/strategy/adapter/itemRule/type.d.ts +225 -0
- package/lib/model/strategy/adapter/itemRule/type.js +46 -0
- package/lib/model/strategy/adapter/promotion/adapter.d.ts +66 -0
- package/lib/model/strategy/adapter/promotion/adapter.js +217 -0
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +213 -0
- package/lib/model/strategy/adapter/promotion/evaluator.js +844 -0
- package/lib/model/strategy/adapter/promotion/examples.d.ts +138 -0
- package/lib/model/strategy/adapter/promotion/examples.js +192 -0
- package/lib/model/strategy/adapter/promotion/index.d.ts +4 -0
- package/lib/model/strategy/adapter/promotion/index.js +0 -0
- package/lib/model/strategy/adapter/promotion/type.d.ts +447 -0
- package/lib/model/strategy/adapter/promotion/type.js +51 -0
- package/lib/model/strategy/adapter/type.d.ts +28 -0
- package/lib/model/strategy/adapter/type.js +17 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +84 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.js +424 -0
- package/lib/model/strategy/adapter/walletPass/example.d.ts +4 -0
- package/lib/model/strategy/adapter/walletPass/example.js +207 -0
- package/lib/model/strategy/adapter/walletPass/index.d.ts +32 -0
- package/lib/model/strategy/adapter/walletPass/index.js +142 -0
- package/lib/model/strategy/adapter/walletPass/locales.d.ts +1 -0
- package/lib/model/strategy/adapter/walletPass/locales.js +54 -0
- package/lib/model/strategy/adapter/walletPass/type.d.ts +187 -0
- package/lib/model/strategy/adapter/walletPass/type.js +17 -0
- package/lib/model/strategy/adapter/walletPass/utils.d.ts +50 -0
- package/lib/model/strategy/adapter/walletPass/utils.js +791 -0
- package/lib/model/strategy/engine.d.ts +106 -0
- package/lib/model/strategy/engine.js +450 -0
- package/lib/model/strategy/index.d.ts +3 -0
- package/lib/model/strategy/index.js +38 -0
- package/lib/model/strategy/strategy-example.d.ts +5 -0
- package/lib/model/strategy/strategy-example.js +318 -0
- package/lib/model/strategy/type.d.ts +228 -0
- package/lib/model/strategy/type.js +44 -0
- package/lib/modules/Cart/utils/cartProduct.js +1 -0
- package/lib/modules/Discount/index.d.ts +4 -2
- package/lib/modules/Discount/index.js +60 -2
- package/lib/modules/Discount/types.d.ts +6 -0
- package/lib/modules/OpenData/index.d.ts +24 -0
- package/lib/modules/OpenData/index.js +119 -0
- package/lib/modules/OpenData/types.d.ts +73 -0
- package/lib/modules/OpenData/types.js +17 -0
- package/lib/modules/OpenData/utils.d.ts +2 -0
- package/lib/modules/OpenData/utils.js +111 -0
- package/lib/modules/Order/index.d.ts +66 -1
- package/lib/modules/Order/index.js +525 -0
- package/lib/modules/Order/types.d.ts +174 -12
- package/lib/modules/Order/utils.d.ts +118 -0
- package/lib/modules/Order/utils.js +483 -2
- package/lib/modules/Product/utils.js +2 -2
- package/lib/modules/ProductList/index.d.ts +3 -1
- package/lib/modules/ProductList/index.js +45 -34
- package/lib/modules/Quotation/index.d.ts +48 -0
- package/lib/modules/Quotation/index.js +152 -0
- package/lib/modules/Quotation/types.d.ts +42 -0
- package/lib/modules/Quotation/types.js +17 -0
- package/lib/modules/Rules/index.js +17 -18
- package/lib/modules/SalesSummary/index.d.ts +63 -0
- package/lib/modules/SalesSummary/index.js +105 -0
- package/lib/modules/SalesSummary/types.d.ts +60 -0
- package/lib/modules/SalesSummary/types.js +17 -0
- package/lib/modules/SalesSummary/utils.d.ts +30 -0
- package/lib/modules/SalesSummary/utils.js +420 -0
- package/lib/modules/ScanOrderLogger/index.d.ts +23 -0
- package/lib/modules/ScanOrderLogger/index.js +147 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.js +157 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.js +52 -0
- package/lib/modules/ScanOrderLogger/types.d.ts +53 -0
- package/lib/modules/ScanOrderLogger/types.js +17 -0
- package/lib/modules/Schedule/getDateIsInSchedule.js +9 -11
- package/lib/modules/Schedule/utils.d.ts +1 -1
- package/lib/modules/Summary/utils.d.ts +3 -3
- package/lib/modules/Summary/utils.js +22 -16
- package/lib/modules/index.d.ts +4 -0
- package/lib/modules/index.js +9 -1
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingByStep/types.d.ts +3 -1
- package/lib/solution/BookingByStep/types.js +10 -0
- package/lib/solution/ScanOrder/index.d.ts +158 -0
- package/lib/solution/ScanOrder/index.js +2135 -0
- package/lib/solution/ScanOrder/types.d.ts +306 -0
- package/lib/solution/ScanOrder/types.js +36 -0
- package/lib/solution/ScanOrder/utils.d.ts +172 -0
- package/lib/solution/ScanOrder/utils.js +658 -0
- package/lib/solution/ShopDiscount/index.d.ts +1 -0
- package/lib/solution/ShopDiscount/index.js +4 -2
- package/lib/solution/VenueBooking/index.d.ts +201 -0
- package/lib/solution/VenueBooking/index.js +1937 -0
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/lib/solution/VenueBooking/types.d.ts +154 -0
- package/lib/solution/VenueBooking/types.js +44 -0
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +110 -0
- package/lib/solution/VenueBooking/utils/resource.d.ts +14 -0
- package/lib/solution/VenueBooking/utils/resource.js +92 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +38 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +237 -0
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/lib/solution/VenueBooking/utils/timeSlot.js +339 -0
- package/lib/solution/VenueBooking/utils.d.ts +1 -0
- package/lib/solution/VenueBooking/utils.js +69 -0
- package/lib/solution/index.d.ts +2 -0
- package/lib/solution/index.js +5 -1
- package/package.json +1 -1
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _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 _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
10
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
11
|
+
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; } } }; }
|
|
12
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
13
|
+
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."); }
|
|
14
|
+
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); }
|
|
15
|
+
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; }
|
|
16
|
+
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; } }
|
|
17
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
18
|
+
import dayjs from 'dayjs';
|
|
19
|
+
import Decimal from 'decimal.js';
|
|
20
|
+
export function isBusinessHoursCrossDay(config) {
|
|
21
|
+
var _config$businessStart = config.businessStartTime.split(':').map(Number),
|
|
22
|
+
_config$businessStart2 = _slicedToArray(_config$businessStart, 2),
|
|
23
|
+
startH = _config$businessStart2[0],
|
|
24
|
+
startM = _config$businessStart2[1];
|
|
25
|
+
var _config$businessEndTi = config.businessEndTime.split(':').map(Number),
|
|
26
|
+
_config$businessEndTi2 = _slicedToArray(_config$businessEndTi, 2),
|
|
27
|
+
endH = _config$businessEndTi2[0],
|
|
28
|
+
endM = _config$businessEndTi2[1];
|
|
29
|
+
return endH < startH || endH === startH && endM <= startM;
|
|
30
|
+
}
|
|
31
|
+
export function generateTimeLabels(config) {
|
|
32
|
+
var slotDurationMinutes = config.slotDurationMinutes,
|
|
33
|
+
businessStartTime = config.businessStartTime,
|
|
34
|
+
businessEndTime = config.businessEndTime;
|
|
35
|
+
var labels = [];
|
|
36
|
+
var baseDate = '2000-01-01';
|
|
37
|
+
var cursor = dayjs("".concat(baseDate, " ").concat(businessStartTime));
|
|
38
|
+
var crossDay = isBusinessHoursCrossDay(config);
|
|
39
|
+
var endBase = crossDay ? '2000-01-02' : baseDate;
|
|
40
|
+
var end = dayjs("".concat(endBase, " ").concat(businessEndTime));
|
|
41
|
+
while (cursor.isBefore(end)) {
|
|
42
|
+
labels.push(cursor.format('HH:mm'));
|
|
43
|
+
cursor = cursor.add(slotDurationMinutes, 'minute');
|
|
44
|
+
}
|
|
45
|
+
return labels;
|
|
46
|
+
}
|
|
47
|
+
export function isSlotOccupied(slotStart, slotEnd, occupiedTimes) {
|
|
48
|
+
var _iterator = _createForOfIteratorHelper(occupiedTimes),
|
|
49
|
+
_step;
|
|
50
|
+
try {
|
|
51
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
52
|
+
var occupied = _step.value;
|
|
53
|
+
var occStart = dayjs(occupied.start_at);
|
|
54
|
+
var occEnd = dayjs(occupied.end_at);
|
|
55
|
+
if (slotStart.isBefore(occEnd) && slotEnd.isAfter(occStart)) {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
} catch (err) {
|
|
60
|
+
_iterator.e(err);
|
|
61
|
+
} finally {
|
|
62
|
+
_iterator.f();
|
|
63
|
+
}
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
function isSlotWithinResourceTimes(slotStart, slotEnd, resourceTimes) {
|
|
67
|
+
var _iterator2 = _createForOfIteratorHelper(resourceTimes),
|
|
68
|
+
_step2;
|
|
69
|
+
try {
|
|
70
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
71
|
+
var t = _step2.value;
|
|
72
|
+
var tStart = dayjs(t.start_at);
|
|
73
|
+
var tEnd = dayjs(t.end_at);
|
|
74
|
+
if (slotStart.isBefore(tEnd) && slotEnd.isAfter(tStart)) return true;
|
|
75
|
+
}
|
|
76
|
+
} catch (err) {
|
|
77
|
+
_iterator2.e(err);
|
|
78
|
+
} finally {
|
|
79
|
+
_iterator2.f();
|
|
80
|
+
}
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
function getResourceTimesForDate(resource, date, config) {
|
|
84
|
+
var crossDay = isBusinessHoursCrossDay(config);
|
|
85
|
+
var dayStart = dayjs("".concat(date, " ").concat(config.businessStartTime));
|
|
86
|
+
var dayEnd = crossDay ? dayjs("".concat(date, " ").concat(config.businessEndTime)).add(1, 'day') : dayjs("".concat(date, " ").concat(config.businessEndTime));
|
|
87
|
+
return resource.times.filter(function (t) {
|
|
88
|
+
var tStart = dayjs(t.start_at);
|
|
89
|
+
var tEnd = dayjs(t.end_at);
|
|
90
|
+
return tStart.isBefore(dayEnd) && tEnd.isAfter(dayStart);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
export function collectEventsForDate(resource, date, config) {
|
|
94
|
+
var timesForDate = getResourceTimesForDate(resource, date, config);
|
|
95
|
+
var events = [];
|
|
96
|
+
var _iterator3 = _createForOfIteratorHelper(timesForDate),
|
|
97
|
+
_step3;
|
|
98
|
+
try {
|
|
99
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
100
|
+
var t = _step3.value;
|
|
101
|
+
if (Array.isArray(t.event_list)) {
|
|
102
|
+
var _iterator4 = _createForOfIteratorHelper(t.event_list),
|
|
103
|
+
_step4;
|
|
104
|
+
try {
|
|
105
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
106
|
+
var _evt$pax;
|
|
107
|
+
var evt = _step4.value;
|
|
108
|
+
events.push({
|
|
109
|
+
start_at: evt.start_at,
|
|
110
|
+
end_at: evt.end_at,
|
|
111
|
+
pax: (_evt$pax = evt.pax) !== null && _evt$pax !== void 0 ? _evt$pax : 1
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
} catch (err) {
|
|
115
|
+
_iterator4.e(err);
|
|
116
|
+
} finally {
|
|
117
|
+
_iterator4.f();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
} catch (err) {
|
|
122
|
+
_iterator3.e(err);
|
|
123
|
+
} finally {
|
|
124
|
+
_iterator3.f();
|
|
125
|
+
}
|
|
126
|
+
return events;
|
|
127
|
+
}
|
|
128
|
+
export function computeSlotStatus(params) {
|
|
129
|
+
var slotStart = params.slotStart,
|
|
130
|
+
slotEnd = params.slotEnd,
|
|
131
|
+
events = params.events,
|
|
132
|
+
resourceType = params.resourceType,
|
|
133
|
+
capacity = params.capacity;
|
|
134
|
+
var overlapping = events.filter(function (evt) {
|
|
135
|
+
var evtStart = dayjs(evt.start_at);
|
|
136
|
+
var evtEnd = dayjs(evt.end_at);
|
|
137
|
+
return slotStart.isBefore(evtEnd) && slotEnd.isAfter(evtStart);
|
|
138
|
+
});
|
|
139
|
+
if (resourceType === 'single') {
|
|
140
|
+
if (overlapping.length > 0) return {
|
|
141
|
+
status: 'occupied',
|
|
142
|
+
remainingCapacity: 0
|
|
143
|
+
};
|
|
144
|
+
return {
|
|
145
|
+
status: 'available',
|
|
146
|
+
remainingCapacity: 1
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
var usedCapacity = overlapping.reduce(function (sum, evt) {
|
|
150
|
+
return sum + evt.pax;
|
|
151
|
+
}, 0);
|
|
152
|
+
var remaining = Math.max(0, capacity - usedCapacity);
|
|
153
|
+
if (remaining <= 0) return {
|
|
154
|
+
status: 'occupied',
|
|
155
|
+
remainingCapacity: 0
|
|
156
|
+
};
|
|
157
|
+
if (remaining < capacity) return {
|
|
158
|
+
status: 'partially_occupied',
|
|
159
|
+
remainingCapacity: remaining
|
|
160
|
+
};
|
|
161
|
+
return {
|
|
162
|
+
status: 'available',
|
|
163
|
+
remainingCapacity: remaining
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* 合并多个子商品的同一个时段为一个"外层 slot"。
|
|
169
|
+
* - status 取优先级最高的(available > partially_occupied > occupied > unavailable / past)
|
|
170
|
+
* - price 取非空子 slot 中最小的那个
|
|
171
|
+
* - 其它字段使用第一个参考子 slot(外层 slot 不带 productId)
|
|
172
|
+
*/
|
|
173
|
+
function mergeSubSlots(subSlots) {
|
|
174
|
+
var priority = {
|
|
175
|
+
available: 5,
|
|
176
|
+
partially_occupied: 4,
|
|
177
|
+
occupied: 3,
|
|
178
|
+
unavailable: 2,
|
|
179
|
+
past: 1
|
|
180
|
+
};
|
|
181
|
+
var best = subSlots[0];
|
|
182
|
+
var _iterator5 = _createForOfIteratorHelper(subSlots),
|
|
183
|
+
_step5;
|
|
184
|
+
try {
|
|
185
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
186
|
+
var _priority$slot$status, _priority$best$status;
|
|
187
|
+
var slot = _step5.value;
|
|
188
|
+
if (((_priority$slot$status = priority[slot.status]) !== null && _priority$slot$status !== void 0 ? _priority$slot$status : 0) > ((_priority$best$status = priority[best.status]) !== null && _priority$best$status !== void 0 ? _priority$best$status : 0)) best = slot;
|
|
189
|
+
}
|
|
190
|
+
} catch (err) {
|
|
191
|
+
_iterator5.e(err);
|
|
192
|
+
} finally {
|
|
193
|
+
_iterator5.f();
|
|
194
|
+
}
|
|
195
|
+
var minPrice = null;
|
|
196
|
+
var _iterator6 = _createForOfIteratorHelper(subSlots),
|
|
197
|
+
_step6;
|
|
198
|
+
try {
|
|
199
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
200
|
+
var _slot = _step6.value;
|
|
201
|
+
if (_slot.price == null) continue;
|
|
202
|
+
var decimal = new Decimal(_slot.price || '0');
|
|
203
|
+
if (!minPrice || decimal.lt(minPrice)) minPrice = decimal;
|
|
204
|
+
}
|
|
205
|
+
} catch (err) {
|
|
206
|
+
_iterator6.e(err);
|
|
207
|
+
} finally {
|
|
208
|
+
_iterator6.f();
|
|
209
|
+
}
|
|
210
|
+
return {
|
|
211
|
+
startTime: best.startTime,
|
|
212
|
+
endTime: best.endTime,
|
|
213
|
+
status: best.status,
|
|
214
|
+
price: minPrice ? minPrice.toFixed(2) : null,
|
|
215
|
+
resourceId: best.resourceId,
|
|
216
|
+
resourceFormId: best.resourceFormId,
|
|
217
|
+
capacity: best.capacity,
|
|
218
|
+
remainingCapacity: best.remainingCapacity
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
function buildProductSlots(params) {
|
|
222
|
+
var date = params.date,
|
|
223
|
+
config = params.config,
|
|
224
|
+
resource = params.resource,
|
|
225
|
+
mapping = params.mapping,
|
|
226
|
+
timeLabels = params.timeLabels,
|
|
227
|
+
timesForDate = params.timesForDate,
|
|
228
|
+
events = params.events,
|
|
229
|
+
resCapacity = params.resCapacity,
|
|
230
|
+
now = params.now,
|
|
231
|
+
crossDay = params.crossDay,
|
|
232
|
+
quotationPriceMap = params.quotationPriceMap,
|
|
233
|
+
childRawResources = params.childRawResources,
|
|
234
|
+
childTimesCache = params.childTimesCache,
|
|
235
|
+
childEventsCache = params.childEventsCache,
|
|
236
|
+
config_businessStartHour = params.config_businessStartHour;
|
|
237
|
+
var slots = [];
|
|
238
|
+
var _iterator7 = _createForOfIteratorHelper(timeLabels),
|
|
239
|
+
_step7;
|
|
240
|
+
try {
|
|
241
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
242
|
+
var _quotationPriceMap$ge;
|
|
243
|
+
var label = _step7.value;
|
|
244
|
+
var _label$split$map = label.split(':').map(Number),
|
|
245
|
+
_label$split$map2 = _slicedToArray(_label$split$map, 1),
|
|
246
|
+
h = _label$split$map2[0];
|
|
247
|
+
var isNextDay = crossDay && h < config_businessStartHour;
|
|
248
|
+
var slotDate = isNextDay ? dayjs(date).add(1, 'day').format('YYYY-MM-DD') : date;
|
|
249
|
+
var slotStart = dayjs("".concat(slotDate, " ").concat(label));
|
|
250
|
+
var slotEnd = slotStart.add(config.slotDurationMinutes, 'minute');
|
|
251
|
+
var status = void 0;
|
|
252
|
+
var remainingCapacity = null;
|
|
253
|
+
if (slotStart.isBefore(now)) {
|
|
254
|
+
status = 'past';
|
|
255
|
+
} else if (!isSlotWithinResourceTimes(slotStart, slotEnd, timesForDate)) {
|
|
256
|
+
status = 'unavailable';
|
|
257
|
+
} else {
|
|
258
|
+
var result = computeSlotStatus({
|
|
259
|
+
slotStart: slotStart,
|
|
260
|
+
slotEnd: slotEnd,
|
|
261
|
+
events: events,
|
|
262
|
+
resourceType: mapping.resourceType,
|
|
263
|
+
capacity: resCapacity
|
|
264
|
+
});
|
|
265
|
+
status = result.status;
|
|
266
|
+
remainingCapacity = result.remainingCapacity;
|
|
267
|
+
if (status !== 'occupied' && childRawResources && childRawResources.length) {
|
|
268
|
+
for (var i = 0; i < childRawResources.length; i++) {
|
|
269
|
+
var _childTimesCache$i, _childEventsCache$i, _child$capacity;
|
|
270
|
+
var child = childRawResources[i];
|
|
271
|
+
var childTimes = (_childTimesCache$i = childTimesCache === null || childTimesCache === void 0 ? void 0 : childTimesCache[i]) !== null && _childTimesCache$i !== void 0 ? _childTimesCache$i : getResourceTimesForDate(child, date, config);
|
|
272
|
+
var childEvents = (_childEventsCache$i = childEventsCache === null || childEventsCache === void 0 ? void 0 : childEventsCache[i]) !== null && _childEventsCache$i !== void 0 ? _childEventsCache$i : collectEventsForDate(child, date, config);
|
|
273
|
+
if (!isSlotWithinResourceTimes(slotStart, slotEnd, childTimes)) {
|
|
274
|
+
status = 'unavailable';
|
|
275
|
+
remainingCapacity = null;
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
var childType = child.type || 'single';
|
|
279
|
+
var childResult = computeSlotStatus({
|
|
280
|
+
slotStart: slotStart,
|
|
281
|
+
slotEnd: slotEnd,
|
|
282
|
+
events: childEvents,
|
|
283
|
+
resourceType: childType,
|
|
284
|
+
capacity: (_child$capacity = child.capacity) !== null && _child$capacity !== void 0 ? _child$capacity : 1
|
|
285
|
+
});
|
|
286
|
+
if (childResult.status === 'occupied') {
|
|
287
|
+
status = 'occupied';
|
|
288
|
+
remainingCapacity = 0;
|
|
289
|
+
break;
|
|
290
|
+
}
|
|
291
|
+
if (childResult.status === 'partially_occupied' && status === 'available') {
|
|
292
|
+
var _remainingCapacity;
|
|
293
|
+
status = 'partially_occupied';
|
|
294
|
+
remainingCapacity = Math.min((_remainingCapacity = remainingCapacity) !== null && _remainingCapacity !== void 0 ? _remainingCapacity : childResult.remainingCapacity, childResult.remainingCapacity);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
var isBookable = status === 'available' || status === 'partially_occupied';
|
|
300
|
+
var slotStartStr = slotStart.format('YYYY-MM-DD HH:mm');
|
|
301
|
+
slots.push({
|
|
302
|
+
startTime: slotStartStr,
|
|
303
|
+
endTime: slotEnd.format('YYYY-MM-DD HH:mm'),
|
|
304
|
+
status: status,
|
|
305
|
+
price: isBookable ? (_quotationPriceMap$ge = quotationPriceMap === null || quotationPriceMap === void 0 ? void 0 : quotationPriceMap.get("".concat(mapping.productId, ":").concat(slotStartStr))) !== null && _quotationPriceMap$ge !== void 0 ? _quotationPriceMap$ge : mapping.price : null,
|
|
306
|
+
resourceId: resource.resourceId,
|
|
307
|
+
resourceFormId: resource.formId,
|
|
308
|
+
capacity: status === 'past' || status === 'unavailable' ? null : resCapacity,
|
|
309
|
+
remainingCapacity: remainingCapacity,
|
|
310
|
+
productId: mapping.productId
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
} catch (err) {
|
|
314
|
+
_iterator7.e(err);
|
|
315
|
+
} finally {
|
|
316
|
+
_iterator7.f();
|
|
317
|
+
}
|
|
318
|
+
return slots;
|
|
319
|
+
}
|
|
320
|
+
export function buildTimeSlotGrid(params) {
|
|
321
|
+
var date = params.date,
|
|
322
|
+
config = params.config,
|
|
323
|
+
rawResources = params.rawResources,
|
|
324
|
+
resourceProductMap = params.resourceProductMap,
|
|
325
|
+
quotationPriceMap = params.quotationPriceMap;
|
|
326
|
+
var timeLabels = generateTimeLabels(config);
|
|
327
|
+
var now = dayjs();
|
|
328
|
+
var crossDay = isBusinessHoursCrossDay(config);
|
|
329
|
+
var config_businessStartHour = Number(config.businessStartTime.split(':')[0]);
|
|
330
|
+
var rawResourceById = new Map();
|
|
331
|
+
var _iterator8 = _createForOfIteratorHelper(rawResources),
|
|
332
|
+
_step8;
|
|
333
|
+
try {
|
|
334
|
+
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
335
|
+
var item = _step8.value;
|
|
336
|
+
rawResourceById.set(item.resourceId, item);
|
|
337
|
+
}
|
|
338
|
+
} catch (err) {
|
|
339
|
+
_iterator8.e(err);
|
|
340
|
+
} finally {
|
|
341
|
+
_iterator8.f();
|
|
342
|
+
}
|
|
343
|
+
var resources = [];
|
|
344
|
+
var _iterator9 = _createForOfIteratorHelper(rawResources),
|
|
345
|
+
_step9;
|
|
346
|
+
try {
|
|
347
|
+
var _loop = function _loop() {
|
|
348
|
+
var _resource$capacity;
|
|
349
|
+
var resource = _step9.value;
|
|
350
|
+
var mappings = resourceProductMap.get(resource.resourceId);
|
|
351
|
+
if (!mappings || !mappings.length) return 1; // continue
|
|
352
|
+
var timesForDate = getResourceTimesForDate(resource, date, config);
|
|
353
|
+
var events = collectEventsForDate(resource, date, config);
|
|
354
|
+
var resCapacity = (_resource$capacity = resource.capacity) !== null && _resource$capacity !== void 0 ? _resource$capacity : 1;
|
|
355
|
+
var combined = resource.combined_resource;
|
|
356
|
+
var isCombined = !!(combined && combined.status === 1 && Array.isArray(combined.resource_ids) && combined.resource_ids.length);
|
|
357
|
+
var childRawResources = isCombined ? combined.resource_ids.map(function (id) {
|
|
358
|
+
return rawResourceById.get(id);
|
|
359
|
+
}).filter(function (r) {
|
|
360
|
+
return !!r;
|
|
361
|
+
}) : undefined;
|
|
362
|
+
var childTimesCache = childRawResources === null || childRawResources === void 0 ? void 0 : childRawResources.map(function (child) {
|
|
363
|
+
return getResourceTimesForDate(child, date, config);
|
|
364
|
+
});
|
|
365
|
+
var childEventsCache = childRawResources === null || childRawResources === void 0 ? void 0 : childRawResources.map(function (child) {
|
|
366
|
+
return collectEventsForDate(child, date, config);
|
|
367
|
+
});
|
|
368
|
+
var subRows = mappings.map(function (mapping) {
|
|
369
|
+
var productSlots = buildProductSlots({
|
|
370
|
+
date: date,
|
|
371
|
+
config: config,
|
|
372
|
+
resource: resource,
|
|
373
|
+
mapping: mapping,
|
|
374
|
+
timeLabels: timeLabels,
|
|
375
|
+
timesForDate: timesForDate,
|
|
376
|
+
events: events,
|
|
377
|
+
resCapacity: resCapacity,
|
|
378
|
+
now: now,
|
|
379
|
+
crossDay: crossDay,
|
|
380
|
+
quotationPriceMap: quotationPriceMap,
|
|
381
|
+
childRawResources: childRawResources,
|
|
382
|
+
childTimesCache: childTimesCache,
|
|
383
|
+
childEventsCache: childEventsCache,
|
|
384
|
+
config_businessStartHour: config_businessStartHour
|
|
385
|
+
});
|
|
386
|
+
return {
|
|
387
|
+
productId: mapping.productId,
|
|
388
|
+
productTitle: mapping.productTitle,
|
|
389
|
+
price: mapping.price,
|
|
390
|
+
slots: productSlots
|
|
391
|
+
};
|
|
392
|
+
});
|
|
393
|
+
var hasMultipleProducts = subRows.length > 1;
|
|
394
|
+
var primary = mappings[0];
|
|
395
|
+
var outerSlots;
|
|
396
|
+
if (hasMultipleProducts) {
|
|
397
|
+
outerSlots = timeLabels.map(function (_label, slotIndex) {
|
|
398
|
+
var group = subRows.map(function (row) {
|
|
399
|
+
return row.slots[slotIndex];
|
|
400
|
+
});
|
|
401
|
+
return mergeSubSlots(group);
|
|
402
|
+
});
|
|
403
|
+
} else {
|
|
404
|
+
outerSlots = subRows[0].slots.map(function (slot) {
|
|
405
|
+
return _objectSpread(_objectSpread({}, slot), {}, {
|
|
406
|
+
productId: undefined
|
|
407
|
+
});
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
var row = {
|
|
411
|
+
resourceId: resource.resourceId,
|
|
412
|
+
resourceFormId: resource.formId,
|
|
413
|
+
resourceName: resource.main_field || primary.resourceName,
|
|
414
|
+
productId: primary.productId,
|
|
415
|
+
productTitle: primary.productTitle,
|
|
416
|
+
slots: outerSlots
|
|
417
|
+
};
|
|
418
|
+
if (hasMultipleProducts) {
|
|
419
|
+
row.products = subRows;
|
|
420
|
+
row.hasMultipleProducts = true;
|
|
421
|
+
}
|
|
422
|
+
if (isCombined && combined) {
|
|
423
|
+
row.combinedResource = {
|
|
424
|
+
resourceIds: _toConsumableArray(combined.resource_ids)
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
resources.push(row);
|
|
428
|
+
};
|
|
429
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
430
|
+
if (_loop()) continue;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
// 按 productId 分组排序,确保同一商品的场地连续排列
|
|
434
|
+
} catch (err) {
|
|
435
|
+
_iterator9.e(err);
|
|
436
|
+
} finally {
|
|
437
|
+
_iterator9.f();
|
|
438
|
+
}
|
|
439
|
+
var productOrder = new Map();
|
|
440
|
+
for (var _i = 0, _resources = resources; _i < _resources.length; _i++) {
|
|
441
|
+
var row = _resources[_i];
|
|
442
|
+
if (!productOrder.has(row.productId)) productOrder.set(row.productId, productOrder.size);
|
|
443
|
+
}
|
|
444
|
+
resources.sort(function (a, b) {
|
|
445
|
+
var _productOrder$get, _productOrder$get2;
|
|
446
|
+
return ((_productOrder$get = productOrder.get(a.productId)) !== null && _productOrder$get !== void 0 ? _productOrder$get : 0) - ((_productOrder$get2 = productOrder.get(b.productId)) !== null && _productOrder$get2 !== void 0 ? _productOrder$get2 : 0);
|
|
447
|
+
});
|
|
448
|
+
return {
|
|
449
|
+
date: date,
|
|
450
|
+
timeLabels: timeLabels,
|
|
451
|
+
resources: resources
|
|
452
|
+
};
|
|
453
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createEmptySummary, getSafeProductNum, toBoolean, toPositiveString, normalizeEnabledItemRuleIds, extractStrategyModelIdsFromTableConfig, normalizeItemRuleStrategies, toNonNegativeNumber, toNonNegativeInt, toPriceString, buildProductKey, getTopLevelProductId, getTopLevelVariantId, buildQuantityLimitIndex, resolveSkuMatchedQuantityLimits, aggregateItemRuleLimit, buildItemRuleBusinessData, attachItemRuleLimitsToTopLevelProducts, getProductIdentityIndex, isIdentityMatch, normalizeOrderProduct, } from '../ScanOrder/utils';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createEmptySummary, getSafeProductNum, toBoolean, toPositiveString, normalizeEnabledItemRuleIds, extractStrategyModelIdsFromTableConfig, normalizeItemRuleStrategies, toNonNegativeNumber, toNonNegativeInt, toPriceString, buildProductKey, getTopLevelProductId, getTopLevelVariantId, buildQuantityLimitIndex, resolveSkuMatchedQuantityLimits, aggregateItemRuleLimit, buildItemRuleBusinessData, attachItemRuleLimitsToTopLevelProducts, getProductIdentityIndex, isIdentityMatch, normalizeOrderProduct } from "../ScanOrder/utils";
|
package/dist/solution/index.d.ts
CHANGED
package/dist/solution/index.js
CHANGED
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './strategy';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/model/index.ts
|
|
17
|
+
var model_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(model_exports);
|
|
19
|
+
__reExport(model_exports, require("./strategy"), module.exports);
|
|
20
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
21
|
+
0 && (module.exports = {
|
|
22
|
+
...require("./strategy")
|
|
23
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './type';
|
|
2
|
+
export { default as WalletPassAdapter } from './walletPass';
|
|
3
|
+
export { WalletPassEvaluator } from './walletPass/evaluator';
|
|
4
|
+
export { PromotionEvaluator } from './promotion/evaluator';
|
|
5
|
+
export { PromotionAdapter } from './promotion/adapter';
|
|
6
|
+
export { ItemRuleEvaluator } from './itemRule/evaluator';
|
|
7
|
+
export { ItemRuleAdapter } from './itemRule/adapter';
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/model/strategy/adapter/index.ts
|
|
31
|
+
var adapter_exports = {};
|
|
32
|
+
__export(adapter_exports, {
|
|
33
|
+
ItemRuleAdapter: () => import_adapter2.ItemRuleAdapter,
|
|
34
|
+
ItemRuleEvaluator: () => import_evaluator3.ItemRuleEvaluator,
|
|
35
|
+
PromotionAdapter: () => import_adapter.PromotionAdapter,
|
|
36
|
+
PromotionEvaluator: () => import_evaluator2.PromotionEvaluator,
|
|
37
|
+
WalletPassAdapter: () => import_walletPass.default,
|
|
38
|
+
WalletPassEvaluator: () => import_evaluator.WalletPassEvaluator
|
|
39
|
+
});
|
|
40
|
+
module.exports = __toCommonJS(adapter_exports);
|
|
41
|
+
__reExport(adapter_exports, require("./type"), module.exports);
|
|
42
|
+
var import_walletPass = __toESM(require("./walletPass"));
|
|
43
|
+
var import_evaluator = require("./walletPass/evaluator");
|
|
44
|
+
var import_evaluator2 = require("./promotion/evaluator");
|
|
45
|
+
var import_adapter = require("./promotion/adapter");
|
|
46
|
+
var import_evaluator3 = require("./itemRule/evaluator");
|
|
47
|
+
var import_adapter2 = require("./itemRule/adapter");
|
|
48
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
+
0 && (module.exports = {
|
|
50
|
+
ItemRuleAdapter,
|
|
51
|
+
ItemRuleEvaluator,
|
|
52
|
+
PromotionAdapter,
|
|
53
|
+
PromotionEvaluator,
|
|
54
|
+
WalletPassAdapter,
|
|
55
|
+
WalletPassEvaluator,
|
|
56
|
+
...require("./type")
|
|
57
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { EvaluationResult, RuntimeContext, ActionEffect } from '../../type';
|
|
2
|
+
import type { BusinessAdapter } from '../type';
|
|
3
|
+
import { type ItemRuleBusinessData, type QuantityCheckResult, type PrefillItemResult, type QuantityLimitResult } from './type';
|
|
4
|
+
/**
|
|
5
|
+
* ItemRule 适配器
|
|
6
|
+
*
|
|
7
|
+
* 将堂食扫码点餐的商品规则业务数据转换为策略引擎格式,
|
|
8
|
+
* 并将引擎结果转换为数量校验和预填购物车的业务结果。
|
|
9
|
+
*/
|
|
10
|
+
export declare class ItemRuleAdapter implements BusinessAdapter {
|
|
11
|
+
name: string;
|
|
12
|
+
version: string;
|
|
13
|
+
prepareContext(businessData: ItemRuleBusinessData): RuntimeContext;
|
|
14
|
+
transformResult(result: EvaluationResult, businessData?: ItemRuleBusinessData): {
|
|
15
|
+
quantityChecks: QuantityCheckResult[];
|
|
16
|
+
prefillItems: PrefillItemResult[];
|
|
17
|
+
};
|
|
18
|
+
formatConfig(result: EvaluationResult, businessData?: ItemRuleBusinessData): {
|
|
19
|
+
result: EvaluationResult;
|
|
20
|
+
businessData?: ItemRuleBusinessData;
|
|
21
|
+
};
|
|
22
|
+
private processQuantityCheck;
|
|
23
|
+
/**
|
|
24
|
+
* 根据 scope 判断当前提交是否需要评估此规则
|
|
25
|
+
*/
|
|
26
|
+
private shouldEvaluateForScope;
|
|
27
|
+
/**
|
|
28
|
+
* 计算目标商品在购物车中的实际数量
|
|
29
|
+
*
|
|
30
|
+
* cumulative scope 时还会加上历史订单数量。
|
|
31
|
+
*/
|
|
32
|
+
private calculateActualQuantity;
|
|
33
|
+
/**
|
|
34
|
+
* 逐条评估数量规则
|
|
35
|
+
*/
|
|
36
|
+
private evaluateQuantityRules;
|
|
37
|
+
/**
|
|
38
|
+
* 根据 source 解析出数量规则的实际数值
|
|
39
|
+
*/
|
|
40
|
+
private resolveQuantityValue;
|
|
41
|
+
/**
|
|
42
|
+
* 格式化校验提示语,替换 {min} {max} 占位符
|
|
43
|
+
*/
|
|
44
|
+
private formatValidationMessage;
|
|
45
|
+
/**
|
|
46
|
+
* 从单个 QUANTITY_CHECK action 中提取数量限制配置。
|
|
47
|
+
*
|
|
48
|
+
* 根据 scope + submissionIndex 判断是否适用,
|
|
49
|
+
* 解析动态数量来源(pax)后返回 min/max/exact/mustInclude。
|
|
50
|
+
* 不适用或无配置时返回 null。
|
|
51
|
+
*/
|
|
52
|
+
extractQuantityLimits(action: ActionEffect, businessData: ItemRuleBusinessData): QuantityLimitResult | null;
|
|
53
|
+
/**
|
|
54
|
+
* 计算当前提交剩余可选的最大数量。
|
|
55
|
+
*
|
|
56
|
+
* 仅在 scope='cumulative' 且存在 requiredMax 时生效:
|
|
57
|
+
* 用 requiredMax 减去 historicalItems 中目标商品的累计数量,保底 0。
|
|
58
|
+
* 其余场景返回 undefined,保持向后兼容。
|
|
59
|
+
*/
|
|
60
|
+
private calculateRemainingMax;
|
|
61
|
+
private processPrefillCart;
|
|
62
|
+
/**
|
|
63
|
+
* 根据 quantityFrom 计算预填数量
|
|
64
|
+
*/
|
|
65
|
+
private resolvePrefillQuantity;
|
|
66
|
+
}
|
|
67
|
+
export default ItemRuleAdapter;
|