@pisell/pisellos 0.10.21 → 0.10.22
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/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/BookingContext/index.d.ts +3 -0
- package/dist/modules/BookingContext/index.js +42 -13
- package/dist/modules/BookingContext/types.d.ts +4 -4
- package/dist/modules/BookingContext/types.js +3 -3
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +10 -7
- package/dist/modules/Order/index.d.ts +5 -0
- package/dist/modules/Order/index.js +148 -84
- package/dist/modules/ProductList/clientDataVariants.d.ts +50 -0
- package/dist/modules/ProductList/clientDataVariants.js +216 -0
- package/dist/modules/ProductList/index.d.ts +14 -13
- package/dist/modules/ProductList/index.js +105 -77
- package/dist/modules/Quotation/index.d.ts +16 -0
- package/dist/modules/Quotation/index.js +240 -27
- package/dist/modules/ResourcePlanner/planner.d.ts +2 -2
- package/dist/modules/ResourcePlanner/planner.js +88 -21
- package/dist/modules/ResourcePlanner/types.d.ts +12 -0
- package/dist/modules/Rules/index.d.ts +5 -0
- package/dist/modules/Rules/index.js +27 -12
- package/dist/solution/BaseSales/index.d.ts +16 -1
- package/dist/solution/BaseSales/index.js +667 -349
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/UnifiedBookingSales/index.d.ts +1 -1
- package/dist/solution/UnifiedBookingSales/index.js +290 -81
- package/dist/solution/UnifiedBookingSales/types.d.ts +4 -0
- package/dist/solution/VenueBooking/index.d.ts +2 -0
- package/dist/solution/VenueBooking/index.js +542 -494
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +3 -1
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +2 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +3 -1
- package/dist/utils/platform.d.ts +8 -0
- package/dist/utils/platform.js +15 -0
- package/lib/model/strategy/adapter/promotion/index.js +46 -1
- package/lib/modules/BookingContext/index.d.ts +3 -0
- package/lib/modules/BookingContext/index.js +35 -8
- package/lib/modules/BookingContext/types.d.ts +4 -4
- package/lib/modules/BookingContext/types.js +3 -3
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +4 -0
- package/lib/modules/Order/index.d.ts +5 -0
- package/lib/modules/Order/index.js +65 -8
- package/lib/modules/ProductList/clientDataVariants.d.ts +50 -0
- package/lib/modules/ProductList/clientDataVariants.js +204 -0
- package/lib/modules/ProductList/index.d.ts +14 -13
- package/lib/modules/ProductList/index.js +77 -58
- package/lib/modules/Quotation/index.d.ts +16 -0
- package/lib/modules/Quotation/index.js +112 -9
- package/lib/modules/ResourcePlanner/planner.d.ts +2 -2
- package/lib/modules/ResourcePlanner/planner.js +80 -20
- package/lib/modules/ResourcePlanner/types.d.ts +12 -0
- package/lib/modules/Rules/index.d.ts +5 -0
- package/lib/modules/Rules/index.js +20 -11
- package/lib/solution/BaseSales/index.d.ts +16 -1
- package/lib/solution/BaseSales/index.js +293 -66
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/UnifiedBookingSales/index.d.ts +1 -1
- package/lib/solution/UnifiedBookingSales/index.js +225 -20
- package/lib/solution/UnifiedBookingSales/types.d.ts +4 -0
- package/lib/solution/VenueBooking/index.d.ts +2 -0
- package/lib/solution/VenueBooking/index.js +28 -8
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +3 -1
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +2 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +3 -1
- package/lib/utils/platform.d.ts +8 -0
- package/lib/utils/platform.js +22 -0
- package/package.json +1 -1
|
@@ -2,7 +2,11 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
2
2
|
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; }
|
|
3
3
|
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; }
|
|
4
4
|
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; } } }; }
|
|
5
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
6
|
+
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."); }
|
|
5
7
|
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); }
|
|
8
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
9
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
10
|
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; }
|
|
7
11
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
8
12
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
@@ -36,6 +40,11 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
36
40
|
list: []
|
|
37
41
|
});
|
|
38
42
|
_defineProperty(_assertThisInitialized(_this), "scheduleResolver", void 0);
|
|
43
|
+
_defineProperty(_assertThisInitialized(_this), "quotationCache", new Map());
|
|
44
|
+
_defineProperty(_assertThisInitialized(_this), "quotationLoadPromises", new Map());
|
|
45
|
+
_defineProperty(_assertThisInitialized(_this), "quotationCacheVersions", new Map());
|
|
46
|
+
_defineProperty(_assertThisInitialized(_this), "lifecycleGeneration", 0);
|
|
47
|
+
_defineProperty(_assertThisInitialized(_this), "activeChannelKey", '');
|
|
39
48
|
return _this;
|
|
40
49
|
}
|
|
41
50
|
_createClass(QuotationModule, [{
|
|
@@ -56,7 +65,12 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
56
65
|
this.store = {
|
|
57
66
|
list: []
|
|
58
67
|
};
|
|
59
|
-
|
|
68
|
+
this.quotationCache.clear();
|
|
69
|
+
this.quotationLoadPromises.clear();
|
|
70
|
+
this.quotationCacheVersions.clear();
|
|
71
|
+
this.activeChannelKey = '';
|
|
72
|
+
this.lifecycleGeneration += 1;
|
|
73
|
+
case 10:
|
|
60
74
|
case "end":
|
|
61
75
|
return _context.stop();
|
|
62
76
|
}
|
|
@@ -71,38 +85,210 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
71
85
|
key: "loadQuotations",
|
|
72
86
|
value: function () {
|
|
73
87
|
var _loadQuotations = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
|
|
74
|
-
var
|
|
75
|
-
var query, res, list;
|
|
88
|
+
var channelKey, cacheVersion, lifecycleGeneration, loadPromise;
|
|
76
89
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
77
90
|
while (1) switch (_context2.prev = _context2.next) {
|
|
78
91
|
case 0:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
92
|
+
channelKey = this.normalizeChannel(params === null || params === void 0 ? void 0 : params.channel);
|
|
93
|
+
cacheVersion = this.bumpQuotationCacheVersion(channelKey);
|
|
94
|
+
lifecycleGeneration = this.lifecycleGeneration;
|
|
95
|
+
this.activateChannel(channelKey);
|
|
96
|
+
loadPromise = this.fetchQuotations({
|
|
97
|
+
channelKey: channelKey,
|
|
98
|
+
cacheVersion: cacheVersion,
|
|
99
|
+
lifecycleGeneration: lifecycleGeneration
|
|
100
|
+
});
|
|
101
|
+
this.quotationLoadPromises.set(channelKey, loadPromise);
|
|
102
|
+
_context2.prev = 6;
|
|
103
|
+
_context2.next = 9;
|
|
104
|
+
return loadPromise;
|
|
105
|
+
case 9:
|
|
106
|
+
_context2.prev = 9;
|
|
107
|
+
if (this.quotationLoadPromises.get(channelKey) === loadPromise) {
|
|
108
|
+
this.quotationLoadPromises.delete(channelKey);
|
|
109
|
+
}
|
|
110
|
+
return _context2.finish(9);
|
|
111
|
+
case 12:
|
|
112
|
+
case "end":
|
|
113
|
+
return _context2.stop();
|
|
114
|
+
}
|
|
115
|
+
}, _callee2, this, [[6,, 9, 12]]);
|
|
116
|
+
}));
|
|
117
|
+
function loadQuotations(_x3) {
|
|
118
|
+
return _loadQuotations.apply(this, arguments);
|
|
119
|
+
}
|
|
120
|
+
return loadQuotations;
|
|
121
|
+
}()
|
|
122
|
+
}, {
|
|
123
|
+
key: "ensureQuotations",
|
|
124
|
+
value: function () {
|
|
125
|
+
var _ensureQuotations = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
126
|
+
var channelKey, lifecycleGeneration, pending, cacheVersion, _latestPending, latestPending;
|
|
127
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
128
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
129
|
+
case 0:
|
|
130
|
+
channelKey = this.normalizeChannel(params === null || params === void 0 ? void 0 : params.channel);
|
|
131
|
+
lifecycleGeneration = this.lifecycleGeneration;
|
|
132
|
+
case 2:
|
|
133
|
+
if (!true) {
|
|
134
|
+
_context3.next = 46;
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
if (!(this.lifecycleGeneration !== lifecycleGeneration)) {
|
|
138
|
+
_context3.next = 5;
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
return _context3.abrupt("return");
|
|
142
|
+
case 5:
|
|
143
|
+
if (!this.quotationCache.has(channelKey)) {
|
|
144
|
+
_context3.next = 8;
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
this.activateChannel(channelKey);
|
|
148
|
+
return _context3.abrupt("return");
|
|
149
|
+
case 8:
|
|
150
|
+
pending = this.quotationLoadPromises.get(channelKey);
|
|
151
|
+
if (pending) {
|
|
152
|
+
_context3.next = 24;
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
_context3.prev = 10;
|
|
156
|
+
_context3.next = 13;
|
|
157
|
+
return this.loadQuotations(params);
|
|
158
|
+
case 13:
|
|
159
|
+
_context3.next = 23;
|
|
160
|
+
break;
|
|
161
|
+
case 15:
|
|
162
|
+
_context3.prev = 15;
|
|
163
|
+
_context3.t0 = _context3["catch"](10);
|
|
164
|
+
if (!this.quotationCache.has(channelKey)) {
|
|
165
|
+
_context3.next = 20;
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
this.activateChannel(channelKey);
|
|
169
|
+
return _context3.abrupt("return");
|
|
170
|
+
case 20:
|
|
171
|
+
if (!this.quotationLoadPromises.has(channelKey)) {
|
|
172
|
+
_context3.next = 22;
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
return _context3.abrupt("continue", 2);
|
|
176
|
+
case 22:
|
|
177
|
+
throw _context3.t0;
|
|
178
|
+
case 23:
|
|
179
|
+
return _context3.abrupt("continue", 2);
|
|
180
|
+
case 24:
|
|
181
|
+
cacheVersion = this.getQuotationCacheVersion(channelKey);
|
|
182
|
+
_context3.prev = 25;
|
|
183
|
+
_context3.next = 28;
|
|
184
|
+
return pending;
|
|
185
|
+
case 28:
|
|
186
|
+
_context3.next = 38;
|
|
187
|
+
break;
|
|
188
|
+
case 30:
|
|
189
|
+
_context3.prev = 30;
|
|
190
|
+
_context3.t1 = _context3["catch"](25);
|
|
191
|
+
_latestPending = this.quotationLoadPromises.get(channelKey);
|
|
192
|
+
if (!(_latestPending && _latestPending !== pending)) {
|
|
193
|
+
_context3.next = 35;
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
return _context3.abrupt("continue", 2);
|
|
197
|
+
case 35:
|
|
198
|
+
if (!(this.getQuotationCacheVersion(channelKey) !== cacheVersion)) {
|
|
199
|
+
_context3.next = 37;
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
return _context3.abrupt("continue", 2);
|
|
203
|
+
case 37:
|
|
204
|
+
throw _context3.t1;
|
|
205
|
+
case 38:
|
|
206
|
+
if (!this.quotationCache.has(channelKey)) {
|
|
207
|
+
_context3.next = 41;
|
|
208
|
+
break;
|
|
83
209
|
}
|
|
84
|
-
|
|
210
|
+
this.activateChannel(channelKey);
|
|
211
|
+
return _context3.abrupt("return");
|
|
212
|
+
case 41:
|
|
213
|
+
latestPending = this.quotationLoadPromises.get(channelKey);
|
|
214
|
+
if (!(latestPending && latestPending !== pending)) {
|
|
215
|
+
_context3.next = 44;
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
return _context3.abrupt("continue", 2);
|
|
219
|
+
case 44:
|
|
220
|
+
_context3.next = 2;
|
|
221
|
+
break;
|
|
222
|
+
case 46:
|
|
223
|
+
case "end":
|
|
224
|
+
return _context3.stop();
|
|
225
|
+
}
|
|
226
|
+
}, _callee3, this, [[10, 15], [25, 30]]);
|
|
227
|
+
}));
|
|
228
|
+
function ensureQuotations(_x4) {
|
|
229
|
+
return _ensureQuotations.apply(this, arguments);
|
|
230
|
+
}
|
|
231
|
+
return ensureQuotations;
|
|
232
|
+
}()
|
|
233
|
+
}, {
|
|
234
|
+
key: "invalidateQuotationCache",
|
|
235
|
+
value: function invalidateQuotationCache(channel) {
|
|
236
|
+
var _this2 = this;
|
|
237
|
+
if (channel !== undefined) {
|
|
238
|
+
var channelKey = this.normalizeChannel(channel);
|
|
239
|
+
this.bumpQuotationCacheVersion(channelKey);
|
|
240
|
+
this.quotationCache.delete(channelKey);
|
|
241
|
+
this.quotationLoadPromises.delete(channelKey);
|
|
242
|
+
if (this.activeChannelKey === channelKey) this.store.list = [];
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
var channelKeys = new Set([].concat(_toConsumableArray(this.quotationCache.keys()), _toConsumableArray(this.quotationLoadPromises.keys()), _toConsumableArray(this.quotationCacheVersions.keys()), [this.activeChannelKey]));
|
|
246
|
+
channelKeys.forEach(function (channelKey) {
|
|
247
|
+
return _this2.bumpQuotationCacheVersion(channelKey);
|
|
248
|
+
});
|
|
249
|
+
this.quotationCache.clear();
|
|
250
|
+
this.quotationLoadPromises.clear();
|
|
251
|
+
this.store.list = [];
|
|
252
|
+
}
|
|
253
|
+
}, {
|
|
254
|
+
key: "fetchQuotations",
|
|
255
|
+
value: function () {
|
|
256
|
+
var _fetchQuotations = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
|
|
257
|
+
var _data;
|
|
258
|
+
var query, res, list;
|
|
259
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
260
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
261
|
+
case 0:
|
|
262
|
+
query = {};
|
|
263
|
+
if (params.channelKey) query.channel = params.channelKey;
|
|
264
|
+
_context4.next = 4;
|
|
85
265
|
return this.request.get('/quotation/available', query, {
|
|
86
266
|
useCache: false,
|
|
87
267
|
osServer: true
|
|
88
268
|
});
|
|
89
|
-
case
|
|
90
|
-
res =
|
|
91
|
-
list = (res === null || res === void 0 || (_data = res.data) === null || _data === void 0 ? void 0 : _data.list) || (res === null || res === void 0 ? void 0 : res.list) || []
|
|
92
|
-
list.sort(function (a, b) {
|
|
269
|
+
case 4:
|
|
270
|
+
res = _context4.sent;
|
|
271
|
+
list = _toConsumableArray((res === null || res === void 0 || (_data = res.data) === null || _data === void 0 ? void 0 : _data.list) || (res === null || res === void 0 ? void 0 : res.list) || []).sort(function (a, b) {
|
|
93
272
|
return b.sort - a.sort;
|
|
94
273
|
});
|
|
95
|
-
this.
|
|
96
|
-
|
|
274
|
+
if (!(this.lifecycleGeneration !== params.lifecycleGeneration || this.getQuotationCacheVersion(params.channelKey) !== params.cacheVersion)) {
|
|
275
|
+
_context4.next = 8;
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
return _context4.abrupt("return");
|
|
279
|
+
case 8:
|
|
280
|
+
this.quotationCache.set(params.channelKey, list);
|
|
281
|
+
if (this.activeChannelKey === params.channelKey) this.store.list = list;
|
|
282
|
+
case 10:
|
|
97
283
|
case "end":
|
|
98
|
-
return
|
|
284
|
+
return _context4.stop();
|
|
99
285
|
}
|
|
100
|
-
},
|
|
286
|
+
}, _callee4, this);
|
|
101
287
|
}));
|
|
102
|
-
function
|
|
103
|
-
return
|
|
288
|
+
function fetchQuotations(_x5) {
|
|
289
|
+
return _fetchQuotations.apply(this, arguments);
|
|
104
290
|
}
|
|
105
|
-
return
|
|
291
|
+
return fetchQuotations;
|
|
106
292
|
}()
|
|
107
293
|
}, {
|
|
108
294
|
key: "getQuotationList",
|
|
@@ -112,7 +298,7 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
112
298
|
}, {
|
|
113
299
|
key: "getQuotationCustomerScopeInfo",
|
|
114
300
|
value: function getQuotationCustomerScopeInfo() {
|
|
115
|
-
var
|
|
301
|
+
var _this3 = this;
|
|
116
302
|
var customerById = new Map();
|
|
117
303
|
var quotationScopes = this.store.list.filter(function (quotation) {
|
|
118
304
|
return Array.isArray(quotation.customer) && quotation.customer.length > 0;
|
|
@@ -122,7 +308,7 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
122
308
|
var localSeen = new Set();
|
|
123
309
|
var quotationCustomers = quotation.customer || [];
|
|
124
310
|
quotationCustomers.forEach(function (customer) {
|
|
125
|
-
var customerId =
|
|
311
|
+
var customerId = _this3.normalizeCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
|
|
126
312
|
if (!customerId || localSeen.has(customerId)) return;
|
|
127
313
|
localSeen.add(customerId);
|
|
128
314
|
customerIds.push(customerId);
|
|
@@ -168,7 +354,8 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
168
354
|
variantId = params.variantId,
|
|
169
355
|
datetime = params.datetime,
|
|
170
356
|
customer_id = params.customer_id;
|
|
171
|
-
var
|
|
357
|
+
var quotations = params.channel === undefined ? this.store.list : this.quotationCache.get(this.normalizeChannel(params.channel)) || [];
|
|
358
|
+
var _iterator = _createForOfIteratorHelper(quotations),
|
|
172
359
|
_step;
|
|
173
360
|
try {
|
|
174
361
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
@@ -208,7 +395,8 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
208
395
|
key: "buildProductPriceMap",
|
|
209
396
|
value: function buildProductPriceMap(params) {
|
|
210
397
|
var map = new Map();
|
|
211
|
-
|
|
398
|
+
var quotations = params.channel === undefined ? this.store.list : this.quotationCache.get(this.normalizeChannel(params.channel)) || [];
|
|
399
|
+
if (!quotations.length) return map;
|
|
212
400
|
var _iterator2 = _createForOfIteratorHelper(params.productIds),
|
|
213
401
|
_step2;
|
|
214
402
|
try {
|
|
@@ -223,6 +411,7 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
223
411
|
var price = this.getPriceForProduct({
|
|
224
412
|
productId: productId,
|
|
225
413
|
datetime: timePoint,
|
|
414
|
+
channel: params.channel,
|
|
226
415
|
customer_id: params.customer_id
|
|
227
416
|
});
|
|
228
417
|
if (price !== null) {
|
|
@@ -247,6 +436,30 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
247
436
|
value: function setScheduleResolver(resolver) {
|
|
248
437
|
this.scheduleResolver = resolver;
|
|
249
438
|
}
|
|
439
|
+
}, {
|
|
440
|
+
key: "normalizeChannel",
|
|
441
|
+
value: function normalizeChannel(channel) {
|
|
442
|
+
var normalized = (channel === null || channel === void 0 ? void 0 : channel.trim().toLowerCase()) || '';
|
|
443
|
+
return normalized === 'online_store' ? 'online-store' : normalized;
|
|
444
|
+
}
|
|
445
|
+
}, {
|
|
446
|
+
key: "activateChannel",
|
|
447
|
+
value: function activateChannel(channelKey) {
|
|
448
|
+
this.activeChannelKey = channelKey;
|
|
449
|
+
this.store.list = this.quotationCache.get(channelKey) || [];
|
|
450
|
+
}
|
|
451
|
+
}, {
|
|
452
|
+
key: "getQuotationCacheVersion",
|
|
453
|
+
value: function getQuotationCacheVersion(channelKey) {
|
|
454
|
+
return this.quotationCacheVersions.get(channelKey) || 0;
|
|
455
|
+
}
|
|
456
|
+
}, {
|
|
457
|
+
key: "bumpQuotationCacheVersion",
|
|
458
|
+
value: function bumpQuotationCacheVersion(channelKey) {
|
|
459
|
+
var nextVersion = this.getQuotationCacheVersion(channelKey) + 1;
|
|
460
|
+
this.quotationCacheVersions.set(channelKey, nextVersion);
|
|
461
|
+
return nextVersion;
|
|
462
|
+
}
|
|
250
463
|
}, {
|
|
251
464
|
key: "isQuotationVisibleForCustomer",
|
|
252
465
|
value: function isQuotationVisibleForCustomer(quotation, customerId) {
|
|
@@ -273,17 +486,17 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
273
486
|
key: "isQuotationActiveAt",
|
|
274
487
|
value: function isQuotationActiveAt(quotation, datetime) {
|
|
275
488
|
var _quotation$schedule,
|
|
276
|
-
|
|
489
|
+
_this4 = this;
|
|
277
490
|
if (!((_quotation$schedule = quotation.schedule) !== null && _quotation$schedule !== void 0 && _quotation$schedule.length)) return false;
|
|
278
491
|
var scheduleItems = [];
|
|
279
492
|
quotation.schedule.forEach(function (s) {
|
|
280
|
-
var
|
|
281
|
-
var full = (
|
|
493
|
+
var _this4$scheduleResolv;
|
|
494
|
+
var full = (_this4$scheduleResolv = _this4.scheduleResolver) === null || _this4$scheduleResolv === void 0 ? void 0 : _this4$scheduleResolv.call(_this4, s.id);
|
|
282
495
|
if (full) {
|
|
283
496
|
scheduleItems.push(full);
|
|
284
497
|
return;
|
|
285
498
|
}
|
|
286
|
-
if (
|
|
499
|
+
if (_this4.scheduleResolver) {
|
|
287
500
|
return;
|
|
288
501
|
}
|
|
289
502
|
var fallbackSchedule = _objectSpread(_objectSpread({}, s), {}, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AvailabilityProjection, AvailabilityProjectionInput, AvailabilityQuery, AvailabilityQueryResult, AvailabilitySelectionValidationParams, AvailabilitySelectionValidationResult, GetProductTimeRangesRequest, ProductTimeRangeGroup } from './types';
|
|
1
|
+
import type { AvailabilityProjection, AvailabilityProjectionInput, AvailabilityQuery, AvailabilityQueryResult, AvailabilitySelectionValidationParams, AvailabilitySelectionValidationResult, GetProductTimeRangesRequest, GetProductTimeRangesRuntimeOptions, ProductTimeRangeGroup } from './types';
|
|
2
2
|
export declare function createAvailabilityProjection(input: AvailabilityProjectionInput): AvailabilityProjection;
|
|
3
|
-
export declare function getProductTimeRanges(projection: AvailabilityProjection, request?: GetProductTimeRangesRequest): ProductTimeRangeGroup[];
|
|
3
|
+
export declare function getProductTimeRanges(projection: AvailabilityProjection, request?: GetProductTimeRangesRequest, runtimeOptions?: GetProductTimeRangesRuntimeOptions): ProductTimeRangeGroup[];
|
|
4
4
|
export declare function queryAvailabilityProjection(projection: AvailabilityProjection, request: AvailabilityQuery): AvailabilityQueryResult;
|
|
5
5
|
export declare function validateAvailabilitySelection(projection: AvailabilityProjection, params: AvailabilitySelectionValidationParams): AvailabilitySelectionValidationResult;
|
|
@@ -14,8 +14,8 @@ import { AvailabilityError } from "./types";
|
|
|
14
14
|
import { addLocalCalendarDays, addLocalHours, addLocalMinutes, captureRuntimeOffsetMinutes, ceilLocalScalarToTenMinutes, dateOrdinalFromLocalDate, extractFixedOffsetMinutes, formatLocalDate, formatLocalDateTime, formatLocalTime, localDateTimeToScalar, localDateToScalar, localDateToScalarStart, nextDate as getNextLocalDate, parseLocalDate, parseLocalDateTime, weekdayFromLocalDate } from "./localClock";
|
|
15
15
|
var DEFAULT_SLOT_STEP_MINUTES = 30;
|
|
16
16
|
var DEFAULT_BUSINESS_HOURS = {
|
|
17
|
-
startTime: '
|
|
18
|
-
endTime: '
|
|
17
|
+
startTime: '00:00',
|
|
18
|
+
endTime: '00:00'
|
|
19
19
|
};
|
|
20
20
|
function availabilityError(code, message, details) {
|
|
21
21
|
return new AvailabilityError(code, message, details);
|
|
@@ -52,6 +52,23 @@ function normalizeBookingCount(bookingCount) {
|
|
|
52
52
|
}
|
|
53
53
|
return normalized;
|
|
54
54
|
}
|
|
55
|
+
function resolveRequestedDurationMinutes(product, request) {
|
|
56
|
+
var _request$durationMinu;
|
|
57
|
+
var configured = Math.max(1, Number(product.durationMinutes || 30) || 30);
|
|
58
|
+
if (product.kind !== 'duration') return configured;
|
|
59
|
+
var override = (_request$durationMinu = request.durationMinutesByProductId) === null || _request$durationMinu === void 0 ? void 0 : _request$durationMinu[String(product.id)];
|
|
60
|
+
var normalized = Number(override);
|
|
61
|
+
return Number.isInteger(normalized) && normalized > 0 ? normalized : configured;
|
|
62
|
+
}
|
|
63
|
+
function resolveRequestedDurationStartTimes(product, request) {
|
|
64
|
+
var _request$durationStar;
|
|
65
|
+
if (product.kind !== 'duration') return [];
|
|
66
|
+
var values = (_request$durationStar = request.durationStartTimesByProductId) === null || _request$durationStar === void 0 ? void 0 : _request$durationStar[String(product.id)];
|
|
67
|
+
if (!Array.isArray(values)) return [];
|
|
68
|
+
return Array.from(new Set(values.filter(function (value) {
|
|
69
|
+
return typeof value === 'string' && /^([01]\d|2[0-3]):[0-5]\d$/.test(value);
|
|
70
|
+
})));
|
|
71
|
+
}
|
|
55
72
|
function toDateTime(value, _timezoneName) {
|
|
56
73
|
try {
|
|
57
74
|
return localDateTimeToScalar(parseLocalDateTime(value));
|
|
@@ -79,6 +96,9 @@ function addMinutesZoned(value, minutes, _timezoneName) {
|
|
|
79
96
|
function ceilToTenMinutes(value, _timezoneName) {
|
|
80
97
|
return ceilLocalScalarToTenMinutes(value);
|
|
81
98
|
}
|
|
99
|
+
function floorToMinute(value) {
|
|
100
|
+
return Math.floor(value / 60000) * 60000;
|
|
101
|
+
}
|
|
82
102
|
function nextDate(value, _timezoneName) {
|
|
83
103
|
return getNextLocalDate(value);
|
|
84
104
|
}
|
|
@@ -962,11 +982,33 @@ function dedupeProductRanges(ranges) {
|
|
|
962
982
|
return left.startAt.localeCompare(right.startAt);
|
|
963
983
|
});
|
|
964
984
|
}
|
|
985
|
+
function createDurationTimeRange(product, start, durationMinutes, projection, fixedOffsetMinutes) {
|
|
986
|
+
var bookingEnd = addMinutesZoned(start, durationMinutes, projection.meta.timezone);
|
|
987
|
+
return createDurationTimeRangeWithEnd(product, start, bookingEnd, projection, fixedOffsetMinutes);
|
|
988
|
+
}
|
|
989
|
+
function createDurationTimeRangeWithEnd(product, start, bookingEnd, projection, fixedOffsetMinutes) {
|
|
990
|
+
return {
|
|
991
|
+
key: "".concat(String(product.id), ":").concat(start, ":").concat(bookingEnd),
|
|
992
|
+
productId: product.id,
|
|
993
|
+
source: 'duration_window',
|
|
994
|
+
startAt: formatDateTime(start, projection.meta.timezone, fixedOffsetMinutes),
|
|
995
|
+
endAt: formatDateTime(bookingEnd, projection.meta.timezone, fixedOffsetMinutes),
|
|
996
|
+
bookingStartAt: formatDateTime(start, projection.meta.timezone, fixedOffsetMinutes),
|
|
997
|
+
bookingEndAt: formatDateTime(bookingEnd, projection.meta.timezone, fixedOffsetMinutes),
|
|
998
|
+
date: formatDate(start, projection.meta.timezone),
|
|
999
|
+
startTime: formatTime(start, projection.meta.timezone),
|
|
1000
|
+
endTime: formatTime(bookingEnd, projection.meta.timezone),
|
|
1001
|
+
timezone: projection.meta.timezone,
|
|
1002
|
+
scheduleRefs: []
|
|
1003
|
+
};
|
|
1004
|
+
}
|
|
965
1005
|
export function getProductTimeRanges(projection) {
|
|
966
1006
|
var _extractFixedOffsetMi3, _request$productIds;
|
|
967
1007
|
var request = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1008
|
+
var runtimeOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
968
1009
|
var normalizedPartySize = normalizePartySize(request.partySize);
|
|
969
1010
|
var dateRange = resolveProjectionDateRange(projection, request.dateRange);
|
|
1011
|
+
var slotStepMinutes = projection.meta.defaults.slotStepMinutes;
|
|
970
1012
|
var fixedOffsetMinutes = (_extractFixedOffsetMi3 = extractFixedOffsetMinutes(projection.meta.now)) !== null && _extractFixedOffsetMi3 !== void 0 ? _extractFixedOffsetMi3 : captureRuntimeOffsetMinutes();
|
|
971
1013
|
var resourceWindowIndex = buildResourceWindowIndex(projection);
|
|
972
1014
|
var filteredProductIdSet = (_request$productIds = request.productIds) !== null && _request$productIds !== void 0 && _request$productIds.length ? new Set(request.productIds.map(String)) : null;
|
|
@@ -978,6 +1020,7 @@ export function getProductTimeRanges(projection) {
|
|
|
978
1020
|
productId: product.id,
|
|
979
1021
|
title: product.title,
|
|
980
1022
|
kind: product.kind,
|
|
1023
|
+
slotStepMinutes: slotStepMinutes,
|
|
981
1024
|
ranges: []
|
|
982
1025
|
};
|
|
983
1026
|
}
|
|
@@ -986,6 +1029,7 @@ export function getProductTimeRanges(projection) {
|
|
|
986
1029
|
productId: product.id,
|
|
987
1030
|
title: product.title,
|
|
988
1031
|
kind: product.kind,
|
|
1032
|
+
slotStepMinutes: slotStepMinutes,
|
|
989
1033
|
ranges: getSessionRangesForProduct(projection, product, dateRange)
|
|
990
1034
|
};
|
|
991
1035
|
}
|
|
@@ -1007,11 +1051,30 @@ export function getProductTimeRanges(projection) {
|
|
|
1007
1051
|
return current === null ? ranges : intersectRangeLists(current, ranges);
|
|
1008
1052
|
}, null) || [] : null;
|
|
1009
1053
|
var baseRanges = resourceRanges === null ? operatingRanges : intersectRangeLists(resourceRanges, operatingRanges);
|
|
1010
|
-
var durationMinutes =
|
|
1011
|
-
var
|
|
1054
|
+
var durationMinutes = resolveRequestedDurationMinutes(product, request);
|
|
1055
|
+
var flexibleStartAt = function () {
|
|
1056
|
+
if (!product.isFlexibleDuration) return undefined;
|
|
1057
|
+
var evaluatedAt = toDateTime(runtimeOptions.evaluatedAt || projection.meta.durationCandidateAnchorAt, projection.meta.timezone);
|
|
1058
|
+
if (!Number.isFinite(evaluatedAt)) {
|
|
1059
|
+
throw availabilityError('INVALID_TARGET_FILTER', 'runtimeOptions.evaluatedAt 必须是有效时间', {
|
|
1060
|
+
evaluatedAt: runtimeOptions.evaluatedAt
|
|
1061
|
+
});
|
|
1062
|
+
}
|
|
1063
|
+
return floorToMinute(evaluatedAt);
|
|
1064
|
+
}();
|
|
1012
1065
|
var durationAnchor = ceilToTenMinutes(toDateTime(projection.meta.durationCandidateAnchorAt, projection.meta.timezone), projection.meta.timezone);
|
|
1066
|
+
var requestedStartTimes = resolveRequestedDurationStartTimes(product, request);
|
|
1013
1067
|
var ranges = [];
|
|
1014
1068
|
baseRanges.forEach(function (range) {
|
|
1069
|
+
if (product.isFlexibleDuration && flexibleStartAt !== undefined) {
|
|
1070
|
+
var start = Math.max(range.start, flexibleStartAt);
|
|
1071
|
+
if (start >= range.end) return;
|
|
1072
|
+
var bookingDate = formatDate(start);
|
|
1073
|
+
if (bookingDate >= dateRange.startDate && bookingDate <= dateRange.endDate) {
|
|
1074
|
+
ranges.push(createDurationTimeRangeWithEnd(product, start, range.end, projection, fixedOffsetMinutes));
|
|
1075
|
+
}
|
|
1076
|
+
return;
|
|
1077
|
+
}
|
|
1015
1078
|
if (range.end <= durationAnchor) return;
|
|
1016
1079
|
var cursor = range.start;
|
|
1017
1080
|
if (cursor < durationAnchor) {
|
|
@@ -1020,30 +1083,32 @@ export function getProductTimeRanges(projection) {
|
|
|
1020
1083
|
while (true) {
|
|
1021
1084
|
var bookingEnd = addMinutesZoned(cursor, durationMinutes, projection.meta.timezone);
|
|
1022
1085
|
if (bookingEnd > range.end) break;
|
|
1023
|
-
var
|
|
1024
|
-
if (
|
|
1025
|
-
ranges.push(
|
|
1026
|
-
key: "".concat(String(product.id), ":").concat(cursor, ":").concat(bookingEnd),
|
|
1027
|
-
productId: product.id,
|
|
1028
|
-
source: 'duration_window',
|
|
1029
|
-
startAt: formatDateTime(cursor, projection.meta.timezone, fixedOffsetMinutes),
|
|
1030
|
-
endAt: formatDateTime(bookingEnd, projection.meta.timezone, fixedOffsetMinutes),
|
|
1031
|
-
bookingStartAt: formatDateTime(cursor, projection.meta.timezone, fixedOffsetMinutes),
|
|
1032
|
-
bookingEndAt: formatDateTime(bookingEnd, projection.meta.timezone, fixedOffsetMinutes),
|
|
1033
|
-
date: formatDate(cursor, projection.meta.timezone),
|
|
1034
|
-
startTime: formatTime(cursor, projection.meta.timezone),
|
|
1035
|
-
endTime: formatTime(bookingEnd, projection.meta.timezone),
|
|
1036
|
-
timezone: projection.meta.timezone,
|
|
1037
|
-
scheduleRefs: []
|
|
1038
|
-
});
|
|
1086
|
+
var _bookingDate = formatDate(cursor);
|
|
1087
|
+
if (_bookingDate >= dateRange.startDate && _bookingDate <= dateRange.endDate) {
|
|
1088
|
+
ranges.push(createDurationTimeRange(product, cursor, durationMinutes, projection, fixedOffsetMinutes));
|
|
1039
1089
|
}
|
|
1040
|
-
cursor = addMinutesZoned(cursor,
|
|
1090
|
+
cursor = addMinutesZoned(cursor, slotStepMinutes, projection.meta.timezone);
|
|
1041
1091
|
}
|
|
1042
1092
|
});
|
|
1093
|
+
if (dateRange.startDate === dateRange.endDate && requestedStartTimes.length > 0) {
|
|
1094
|
+
requestedStartTimes.forEach(function (startTime) {
|
|
1095
|
+
var start = toDateTimeInDate(dateRange.startDate, startTime, projection.meta.timezone);
|
|
1096
|
+
if (!Number.isFinite(start)) return;
|
|
1097
|
+
var end = addMinutesZoned(start, durationMinutes, projection.meta.timezone);
|
|
1098
|
+
var startsInOperatingRange = operatingRanges.some(function (range) {
|
|
1099
|
+
return range.start <= start && start < range.end;
|
|
1100
|
+
});
|
|
1101
|
+
if (!startsInOperatingRange && !request.allowOutsideOperatingHoursForRequestedStartTimes) {
|
|
1102
|
+
return;
|
|
1103
|
+
}
|
|
1104
|
+
ranges.push(createDurationTimeRange(product, start, durationMinutes, projection, fixedOffsetMinutes));
|
|
1105
|
+
});
|
|
1106
|
+
}
|
|
1043
1107
|
return {
|
|
1044
1108
|
productId: product.id,
|
|
1045
1109
|
title: product.title,
|
|
1046
1110
|
kind: product.kind,
|
|
1111
|
+
slotStepMinutes: slotStepMinutes,
|
|
1047
1112
|
ranges: dedupeProductRanges(ranges)
|
|
1048
1113
|
};
|
|
1049
1114
|
});
|
|
@@ -1819,6 +1884,8 @@ export function queryAvailabilityProjection(projection, request) {
|
|
|
1819
1884
|
dateRange: dateRange,
|
|
1820
1885
|
resourceIds: request.resourceIds,
|
|
1821
1886
|
partySize: normalizedPartySize
|
|
1887
|
+
}, {
|
|
1888
|
+
evaluatedAt: evaluatedAt
|
|
1822
1889
|
});
|
|
1823
1890
|
var candidateGroupMap = new Map(candidateGroups.map(function (group) {
|
|
1824
1891
|
return [String(group.productId), group];
|
|
@@ -81,6 +81,7 @@ export interface AvailabilityProduct {
|
|
|
81
81
|
id: AvailabilityId;
|
|
82
82
|
title?: string;
|
|
83
83
|
kind: AvailabilityProductKind;
|
|
84
|
+
isFlexibleDuration?: boolean;
|
|
84
85
|
durationMinutes?: number;
|
|
85
86
|
quantity?: number;
|
|
86
87
|
capacityRequired?: number;
|
|
@@ -211,6 +212,7 @@ export interface ProductTimeRangeGroup {
|
|
|
211
212
|
productId: AvailabilityId;
|
|
212
213
|
title?: string;
|
|
213
214
|
kind: AvailabilityProductKind;
|
|
215
|
+
slotStepMinutes?: number;
|
|
214
216
|
ranges: ProductTimeRange[];
|
|
215
217
|
}
|
|
216
218
|
export interface AvailabilityAssignment extends AvailabilityAbsoluteRange {
|
|
@@ -231,6 +233,16 @@ export interface GetProductTimeRangesRequest {
|
|
|
231
233
|
dateRange?: Partial<AvailabilityDateRange>;
|
|
232
234
|
resourceIds?: AvailabilityId[];
|
|
233
235
|
partySize?: number;
|
|
236
|
+
durationMinutesByProductId?: Record<string, number>;
|
|
237
|
+
durationStartTimesByProductId?: Record<string, string[]>;
|
|
238
|
+
/**
|
|
239
|
+
* POS 手工输入时间的兼容开关:只为明确请求的 start time 补候选,
|
|
240
|
+
* 不改变常规候选列表仍按营业时间生成的规则。
|
|
241
|
+
*/
|
|
242
|
+
allowOutsideOperatingHoursForRequestedStartTimes?: boolean;
|
|
243
|
+
}
|
|
244
|
+
export interface GetProductTimeRangesRuntimeOptions {
|
|
245
|
+
evaluatedAt?: string;
|
|
234
246
|
}
|
|
235
247
|
export interface QueryAvailabilityBaseRequest {
|
|
236
248
|
productIds?: AvailabilityId[];
|
|
@@ -14,6 +14,11 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
|
|
|
14
14
|
setRulesList(rulesList: Rules[]): Promise<void>;
|
|
15
15
|
getRulesList(): Rules[];
|
|
16
16
|
getWalletPassEvaluator(): import("../..").WalletPassEvaluator | undefined;
|
|
17
|
+
private normalizeHolderRecordIds;
|
|
18
|
+
/**
|
|
19
|
+
* 特定 form Holder 卡只授权给绑定同一 Holder Record 的商品行。
|
|
20
|
+
* required/isNeedHolder 仅控制是否强制选择 Holder,不参与优惠资格。
|
|
21
|
+
*/
|
|
17
22
|
private checkHolderMatch;
|
|
18
23
|
isDiscountListAvailable({ oldDiscountList, newDiscountList, productList, orderTotalAmount, holders, isFormSubject, }: {
|
|
19
24
|
oldDiscountList: Discount[];
|