@pisell/pisellos 0.10.88 → 0.10.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/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
- package/dist/model/strategy/adapter/itemRule/adapter.js +74 -7
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
- package/dist/model/strategy/adapter/itemRule/evaluator.js +13 -0
- package/dist/model/strategy/adapter/itemRule/type.d.ts +40 -1
- package/dist/model/strategy/adapter/itemRule/type.js +10 -0
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +2 -1
- package/dist/model/strategy/adapter/promotion/evaluator.js +103 -112
- package/dist/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
- package/dist/modules/BookingContext/utils/calendarBooking.js +207 -0
- package/dist/modules/BookingContext/utils/index.d.ts +1 -0
- package/dist/modules/BookingContext/utils/index.js +1 -0
- package/dist/modules/BookingContext/utils/productExtend.d.ts +21 -0
- package/dist/modules/BookingContext/utils/productExtend.js +132 -33
- package/dist/modules/BookingContext/utils/resources.js +1 -1
- package/dist/modules/Cart/index.js +4 -3
- package/dist/modules/Cart/types.d.ts +2 -0
- package/dist/modules/Cart/utils/cartProduct.d.ts +3 -1
- package/dist/modules/Cart/utils/cartProduct.js +59 -32
- package/dist/modules/Date/index.d.ts +1 -1
- package/dist/modules/Date/index.js +60 -14
- package/dist/modules/Date/types.d.ts +5 -0
- package/dist/modules/OpenData/salesSettings.js +1 -1
- package/dist/modules/OpenData/types.d.ts +9 -0
- package/dist/modules/OpenData/utils.d.ts +1 -1
- package/dist/modules/OpenData/utils.js +3 -2
- package/dist/modules/Order/index.d.ts +22 -7
- package/dist/modules/Order/index.js +1565 -1161
- package/dist/modules/Order/localEftposState.d.ts +13 -0
- package/dist/modules/Order/localEftposState.js +39 -0
- package/dist/modules/Order/types.d.ts +33 -11
- package/dist/modules/Order/types.js +2 -2
- package/dist/modules/Order/unpaidAmountGap.d.ts +6 -0
- package/dist/modules/Order/unpaidAmountGap.js +72 -0
- package/dist/modules/Order/utils.d.ts +4 -1
- package/dist/modules/Order/utils.js +185 -129
- package/dist/modules/Payment/walletpass.js +32 -6
- package/dist/modules/Product/types.d.ts +16 -0
- package/dist/modules/ProductList/index.js +1 -1
- package/dist/modules/ResourcePlanner/planner.d.ts +2 -0
- package/dist/modules/ResourcePlanner/planner.js +383 -24
- package/dist/modules/ResourcePlanner/types.d.ts +42 -0
- package/dist/modules/Rules/index.js +86 -54
- package/dist/modules/Schedule/index.d.ts +7 -1
- package/dist/modules/Schedule/index.js +155 -39
- package/dist/modules/Schedule/types.d.ts +2 -0
- package/dist/modules/bookingReadValidation.d.ts +6 -0
- package/dist/modules/bookingReadValidation.js +72 -0
- package/dist/plugins/request.d.ts +2 -0
- package/dist/server/index.d.ts +9 -0
- package/dist/server/index.js +1928 -1462
- package/dist/server/modules/form/index.d.ts +19 -0
- package/dist/server/modules/form/index.js +205 -0
- package/dist/server/modules/form/types.d.ts +13 -0
- package/dist/server/modules/form/types.js +3 -0
- package/dist/server/modules/index.d.ts +3 -0
- package/dist/server/modules/index.js +4 -0
- package/dist/server/modules/order/index.d.ts +21 -0
- package/dist/server/modules/order/index.js +1399 -831
- package/dist/server/modules/order/types.d.ts +3 -0
- package/dist/server/modules/order/utils/filterOrders.js +20 -0
- package/dist/server/modules/products/index.d.ts +28 -7
- package/dist/server/modules/products/index.js +1295 -769
- package/dist/server/modules/products/replication.d.ts +8 -0
- package/dist/server/modules/products/replication.js +69 -0
- package/dist/server/modules/products/types.d.ts +12 -1
- package/dist/server/modules/products/types.js +4 -0
- package/dist/shared/receipt/customerInvoiceLanguages.d.ts +1 -1
- package/dist/shared/receipt/customerInvoiceLanguages.js +5 -3
- package/dist/shared/receipt/small-ticket.d.ts +1 -0
- package/dist/shared/receipt/small-ticket.js +58 -26
- package/dist/shared/receipt/templateVisibility.d.ts +3 -0
- package/dist/shared/receipt/templateVisibility.js +6 -2
- package/dist/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
- package/dist/solution/BaseSales/fulfillmentItemRules.js +750 -0
- package/dist/solution/BaseSales/index.d.ts +22 -6
- package/dist/solution/BaseSales/index.js +1881 -1347
- package/dist/solution/BaseSales/pickupTiming.d.ts +4 -0
- package/dist/solution/BaseSales/pickupTiming.js +35 -8
- package/dist/solution/BaseSales/types.d.ts +4 -0
- package/dist/solution/BaseSales/types.js +1 -0
- package/dist/solution/BaseSales/utils/posDurationPricing.d.ts +21 -0
- package/dist/solution/BaseSales/utils/posDurationPricing.js +174 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +2 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +8 -8
- package/dist/solution/BookingByStep/index.d.ts +19 -3
- package/dist/solution/BookingByStep/index.js +681 -361
- package/dist/solution/BookingByStep/utils/resources.d.ts +10 -0
- package/dist/solution/BookingByStep/utils/resources.js +117 -76
- package/dist/solution/BookingTicket/index.d.ts +6 -0
- package/dist/solution/BookingTicket/index.js +666 -593
- package/dist/solution/BookingTicket/types.d.ts +1 -1
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
- package/dist/solution/BookingTicket/utils/addProductDecision.js +35 -8
- package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +7 -7
- package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
- package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.js +188 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +58 -94
- package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +1 -3
- package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +33 -62
- package/dist/solution/OrderInvoicePreview/index.js +4 -3
- package/dist/solution/Sales/index.js +1 -1
- package/dist/solution/ScanOrder/index.d.ts +2 -0
- package/dist/solution/ScanOrder/index.js +230 -97
- package/dist/solution/ScanOrder/menuAvailability.d.ts +24 -0
- package/dist/solution/ScanOrder/menuAvailability.js +363 -0
- package/dist/solution/ScanOrder/types.d.ts +3 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +42 -10
- package/dist/solution/UnifiedBookingSales/index.js +2493 -1496
- package/dist/solution/UnifiedBookingSales/salesSettings.js +1 -1
- package/dist/solution/UnifiedBookingSales/types.d.ts +20 -5
- package/dist/utils/pos-receipt-auto-print.d.ts +4 -0
- package/dist/utils/pos-receipt-auto-print.js +14 -0
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
- package/lib/model/strategy/adapter/itemRule/adapter.js +54 -4
- package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
- package/lib/model/strategy/adapter/itemRule/evaluator.js +9 -0
- package/lib/model/strategy/adapter/itemRule/type.d.ts +40 -1
- package/lib/model/strategy/adapter/itemRule/type.js +10 -0
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +2 -1
- package/lib/model/strategy/adapter/promotion/evaluator.js +22 -21
- package/lib/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
- package/lib/modules/BookingContext/utils/calendarBooking.js +156 -0
- package/lib/modules/BookingContext/utils/index.d.ts +1 -0
- package/lib/modules/BookingContext/utils/index.js +11 -0
- package/lib/modules/BookingContext/utils/productExtend.d.ts +21 -0
- package/lib/modules/BookingContext/utils/productExtend.js +104 -5
- package/lib/modules/BookingContext/utils/resources.js +1 -1
- package/lib/modules/Cart/index.js +4 -2
- package/lib/modules/Cart/types.d.ts +2 -0
- package/lib/modules/Cart/utils/cartProduct.d.ts +3 -1
- package/lib/modules/Cart/utils/cartProduct.js +39 -20
- package/lib/modules/Date/index.d.ts +1 -1
- package/lib/modules/Date/index.js +28 -5
- package/lib/modules/Date/types.d.ts +5 -0
- package/lib/modules/OpenData/salesSettings.js +1 -1
- package/lib/modules/OpenData/types.d.ts +9 -0
- package/lib/modules/OpenData/utils.d.ts +1 -1
- package/lib/modules/OpenData/utils.js +3 -2
- package/lib/modules/Order/index.d.ts +22 -7
- package/lib/modules/Order/index.js +457 -174
- package/lib/modules/Order/localEftposState.d.ts +13 -0
- package/lib/modules/Order/localEftposState.js +44 -0
- package/lib/modules/Order/types.d.ts +33 -11
- package/lib/modules/Order/types.js +2 -2
- package/lib/modules/Order/unpaidAmountGap.d.ts +6 -0
- package/lib/modules/Order/unpaidAmountGap.js +60 -0
- package/lib/modules/Order/utils.d.ts +4 -1
- package/lib/modules/Order/utils.js +51 -3
- package/lib/modules/Payment/walletpass.js +23 -1
- package/lib/modules/Product/types.d.ts +16 -0
- package/lib/modules/ProductList/index.js +1 -1
- package/lib/modules/ResourcePlanner/planner.d.ts +2 -0
- package/lib/modules/ResourcePlanner/planner.js +299 -9
- package/lib/modules/ResourcePlanner/types.d.ts +42 -0
- package/lib/modules/Rules/index.js +32 -3
- package/lib/modules/Schedule/index.d.ts +7 -1
- package/lib/modules/Schedule/index.js +68 -4
- package/lib/modules/Schedule/types.d.ts +2 -0
- package/lib/modules/bookingReadValidation.d.ts +6 -0
- package/lib/modules/bookingReadValidation.js +56 -0
- package/lib/plugins/request.d.ts +2 -0
- package/lib/server/index.d.ts +9 -0
- package/lib/server/index.js +279 -30
- package/lib/server/modules/form/index.d.ts +19 -0
- package/lib/server/modules/form/index.js +73 -0
- package/lib/server/modules/form/types.d.ts +13 -0
- package/lib/server/modules/form/types.js +9 -0
- package/lib/server/modules/index.d.ts +3 -0
- package/lib/server/modules/index.js +15 -1
- package/lib/server/modules/order/index.d.ts +21 -0
- package/lib/server/modules/order/index.js +344 -35
- package/lib/server/modules/order/types.d.ts +3 -0
- package/lib/server/modules/order/utils/filterOrders.js +18 -0
- package/lib/server/modules/products/index.d.ts +28 -7
- package/lib/server/modules/products/index.js +224 -62
- package/lib/server/modules/products/replication.d.ts +8 -0
- package/lib/server/modules/products/replication.js +30 -0
- package/lib/server/modules/products/types.d.ts +12 -1
- package/lib/server/modules/products/types.js +3 -0
- package/lib/shared/receipt/customerInvoiceLanguages.d.ts +1 -1
- package/lib/shared/receipt/customerInvoiceLanguages.js +5 -3
- package/lib/shared/receipt/small-ticket.d.ts +1 -0
- package/lib/shared/receipt/small-ticket.js +53 -25
- package/lib/shared/receipt/templateVisibility.d.ts +3 -0
- package/lib/shared/receipt/templateVisibility.js +6 -2
- package/lib/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
- package/lib/solution/BaseSales/fulfillmentItemRules.js +259 -0
- package/lib/solution/BaseSales/index.d.ts +22 -6
- package/lib/solution/BaseSales/index.js +347 -59
- package/lib/solution/BaseSales/pickupTiming.d.ts +4 -0
- package/lib/solution/BaseSales/pickupTiming.js +24 -3
- package/lib/solution/BaseSales/types.d.ts +4 -0
- package/lib/solution/BaseSales/types.js +1 -0
- package/lib/solution/BaseSales/utils/posDurationPricing.d.ts +21 -0
- package/lib/solution/BaseSales/utils/posDurationPricing.js +133 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +2 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -1
- package/lib/solution/BookingByStep/index.d.ts +19 -3
- package/lib/solution/BookingByStep/index.js +229 -17
- package/lib/solution/BookingByStep/utils/resources.d.ts +10 -0
- package/lib/solution/BookingByStep/utils/resources.js +25 -15
- package/lib/solution/BookingTicket/index.d.ts +6 -0
- package/lib/solution/BookingTicket/index.js +40 -5
- package/lib/solution/BookingTicket/types.d.ts +1 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.js +34 -4
- package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +7 -7
- package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
- package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.js +136 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +2 -14
- package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +1 -3
- package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +17 -34
- package/lib/solution/OrderInvoicePreview/index.js +1 -0
- package/lib/solution/Sales/index.js +1 -1
- package/lib/solution/ScanOrder/index.d.ts +2 -0
- package/lib/solution/ScanOrder/index.js +131 -22
- package/lib/solution/ScanOrder/menuAvailability.d.ts +24 -0
- package/lib/solution/ScanOrder/menuAvailability.js +203 -0
- package/lib/solution/ScanOrder/types.d.ts +3 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +42 -10
- package/lib/solution/UnifiedBookingSales/index.js +717 -144
- package/lib/solution/UnifiedBookingSales/salesSettings.js +1 -1
- package/lib/solution/UnifiedBookingSales/types.d.ts +20 -5
- package/lib/utils/pos-receipt-auto-print.d.ts +4 -0
- package/lib/utils/pos-receipt-auto-print.js +13 -0
- package/package.json +1 -1
|
@@ -4,17 +4,17 @@ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructur
|
|
|
4
4
|
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; } }
|
|
5
5
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
6
6
|
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; } } }; }
|
|
7
|
+
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
|
+
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); } }
|
|
9
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
10
|
+
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; }
|
|
11
|
+
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; }
|
|
7
12
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
8
13
|
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."); }
|
|
9
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); }
|
|
10
15
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
11
16
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
12
17
|
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; }
|
|
13
|
-
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; }
|
|
14
|
-
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; }
|
|
15
|
-
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; }
|
|
16
|
-
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); } }
|
|
17
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
18
18
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
19
19
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
20
20
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
@@ -32,7 +32,7 @@ import { BaseModule } from "../../modules/BaseModule";
|
|
|
32
32
|
import { createModule } from "./types";
|
|
33
33
|
import { formatProductToCartItem, createCartItemOrigin, getUniqueId, handleVariantProduct, formatDateToCartItem, formatAccountToCartItem } from "../../modules/Cart/utils";
|
|
34
34
|
import { getAvailableProductResources, isSessionProduct } from "./utils/products";
|
|
35
|
-
import { getResourcesByProduct, getTimeSlicesByResource, getTimeSlicesByResources, getIsUsableByTimeItem, getOthersSelectedResources, getOthersCartSelectedResources, filterScheduleByDateRange, checkSessionProductLeadTime, sortCombinedResources, filterResourcesByFormItem, checkTwoResourcesIntersection, isConflict } from "./utils/resources";
|
|
35
|
+
import { getResourcesByProduct, getTimeSlicesByResource, getTimeSlicesByResources, getIsUsableByTimeItem, getPeakConcurrentPax, getOthersSelectedResources, getOthersCartSelectedResources, filterScheduleByDateRange, checkSessionProductLeadTime, sortCombinedResources, filterResourcesByFormItem, checkTwoResourcesIntersection, isConflict } from "./utils/resources";
|
|
36
36
|
import dayjs from 'dayjs';
|
|
37
37
|
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
|
|
38
38
|
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
|
|
@@ -65,16 +65,107 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
65
65
|
_defineProperty(_assertThisInitialized(_this), "shopStore", void 0);
|
|
66
66
|
_defineProperty(_assertThisInitialized(_this), "store", void 0);
|
|
67
67
|
_defineProperty(_assertThisInitialized(_this), "otherParams", {});
|
|
68
|
+
_defineProperty(_assertThisInitialized(_this), "scheduleRuntimeParams", {});
|
|
68
69
|
_defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
|
|
69
70
|
_defineProperty(_assertThisInitialized(_this), "otherData", {});
|
|
70
71
|
// 提供给 UI 层的临时数据存储,会进缓存
|
|
71
72
|
_defineProperty(_assertThisInitialized(_this), "platform", void 0);
|
|
73
|
+
// 平台类型,用于判断是 PC / H5
|
|
74
|
+
_defineProperty(_assertThisInitialized(_this), "productDetailGeneration", 0);
|
|
75
|
+
_defineProperty(_assertThisInitialized(_this), "sessionAvailabilityRequestVersion", 0);
|
|
76
|
+
_defineProperty(_assertThisInitialized(_this), "lifecycleGeneration", 0);
|
|
77
|
+
_defineProperty(_assertThisInitialized(_this), "disposed", false);
|
|
78
|
+
_defineProperty(_assertThisInitialized(_this), "resourcePreparation", void 0);
|
|
72
79
|
return _this;
|
|
73
80
|
}
|
|
74
81
|
_createClass(BookingByStepImpl, [{
|
|
82
|
+
key: "staleSelection",
|
|
83
|
+
value: function staleSelection() {
|
|
84
|
+
return Object.assign(new Error('Booking selection changed'), {
|
|
85
|
+
name: 'AbortError'
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}, {
|
|
89
|
+
key: "resourceSelectionKey",
|
|
90
|
+
value: function resourceSelectionKey() {
|
|
91
|
+
var items = this.store.cart.getItems();
|
|
92
|
+
var sessionDates = items.filter(function (item) {
|
|
93
|
+
return isSessionProduct(item._productOrigin);
|
|
94
|
+
}).flatMap(function (item) {
|
|
95
|
+
return [item.start_date, item.end_date];
|
|
96
|
+
}).filter(Boolean);
|
|
97
|
+
return JSON.stringify({
|
|
98
|
+
lifecycle: this.lifecycleGeneration,
|
|
99
|
+
dates: sessionDates.length ? _toConsumableArray(new Set(sessionDates)).sort() : (this.store.date.getDateRange() || []).map(function (date) {
|
|
100
|
+
return date.date;
|
|
101
|
+
}).sort(),
|
|
102
|
+
cart: items.map(function (item) {
|
|
103
|
+
var _item$_origin, _item$_productOrigin, _item$_productOrigin2, _item$_productOrigin3, _item$_productOrigin4, _item$_productOrigin5;
|
|
104
|
+
return {
|
|
105
|
+
id: item._id,
|
|
106
|
+
num: item.num,
|
|
107
|
+
holder: item.holder_id,
|
|
108
|
+
start: [item.start_date, item.start_time],
|
|
109
|
+
end: [item.end_date, item.end_time],
|
|
110
|
+
resources: (_item$_origin = item._origin) === null || _item$_origin === void 0 ? void 0 : _item$_origin.resources,
|
|
111
|
+
capacity: getCapacityInfoByCartItem(item).currentCapacity,
|
|
112
|
+
product: {
|
|
113
|
+
id: (_item$_productOrigin = item._productOrigin) === null || _item$_productOrigin === void 0 ? void 0 : _item$_productOrigin.id,
|
|
114
|
+
schedules: (_item$_productOrigin2 = item._productOrigin) === null || _item$_productOrigin2 === void 0 ? void 0 : _item$_productOrigin2['schedule.ids'],
|
|
115
|
+
resources: (_item$_productOrigin3 = item._productOrigin) === null || _item$_productOrigin3 === void 0 || (_item$_productOrigin3 = _item$_productOrigin3.product_resource) === null || _item$_productOrigin3 === void 0 || (_item$_productOrigin3 = _item$_productOrigin3.resources) === null || _item$_productOrigin3 === void 0 ? void 0 : _item$_productOrigin3.map(function (resource) {
|
|
116
|
+
return {
|
|
117
|
+
id: resource.id,
|
|
118
|
+
resource_type_id: resource.resource_type_id,
|
|
119
|
+
status: resource.status,
|
|
120
|
+
code: resource.code,
|
|
121
|
+
type: resource.type,
|
|
122
|
+
default_resource: resource.default_resource || [],
|
|
123
|
+
// Resource rendering removes required IDs from the optional list in place.
|
|
124
|
+
// Compare the same effective inputs before and after that normalization.
|
|
125
|
+
optional_resource: (resource.optional_resource || []).filter(function (id) {
|
|
126
|
+
return !(resource.default_resource || []).includes(id);
|
|
127
|
+
}),
|
|
128
|
+
select_type: resource.select_type && {
|
|
129
|
+
type: resource.select_type.type,
|
|
130
|
+
min: resource.select_type.min,
|
|
131
|
+
max: resource.select_type.max
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}),
|
|
135
|
+
duration: (_item$_productOrigin4 = item._productOrigin) === null || _item$_productOrigin4 === void 0 ? void 0 : _item$_productOrigin4.duration,
|
|
136
|
+
cutoff: (_item$_productOrigin5 = item._productOrigin) === null || _item$_productOrigin5 === void 0 ? void 0 : _item$_productOrigin5.cut_off_time
|
|
137
|
+
},
|
|
138
|
+
bundle: item._bundleOrigin,
|
|
139
|
+
options: item._optionsOrigin
|
|
140
|
+
};
|
|
141
|
+
})
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Semantic selection token for async UI transitions. */
|
|
146
|
+
}, {
|
|
147
|
+
key: "getBookingSelectionKey",
|
|
148
|
+
value: function getBookingSelectionKey() {
|
|
149
|
+
return this.resourceSelectionKey();
|
|
150
|
+
}
|
|
151
|
+
}, {
|
|
152
|
+
key: "refreshCurrentProductSchedule",
|
|
153
|
+
value: function refreshCurrentProductSchedule() {
|
|
154
|
+
var product = this.store.currentProduct;
|
|
155
|
+
if (!(product !== null && product !== void 0 && product['schedule.ids']) || !this.store.schedule.isScheduleListLoaded()) return;
|
|
156
|
+
var version = this.store.schedule.getScheduleCatalogVersion();
|
|
157
|
+
var meta = this.store.currentProductMeta || {};
|
|
158
|
+
if (meta.scheduleCatalogVersion !== version) {
|
|
159
|
+
this.store.currentProductMeta = _objectSpread(_objectSpread({}, meta), {}, {
|
|
160
|
+
schedule: this.getScheduleDataByIds(product['schedule.ids']),
|
|
161
|
+
scheduleCatalogVersion: version,
|
|
162
|
+
timeSlotBySchedule: undefined
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}, {
|
|
75
167
|
key: "initialize",
|
|
76
|
-
value:
|
|
77
|
-
function () {
|
|
168
|
+
value: function () {
|
|
78
169
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
|
|
79
170
|
var _this$otherParams,
|
|
80
171
|
_this$otherParams2,
|
|
@@ -84,25 +175,29 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
84
175
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
85
176
|
while (1) switch (_context.prev = _context.next) {
|
|
86
177
|
case 0:
|
|
178
|
+
this.disposed = false;
|
|
179
|
+
this.lifecycleGeneration += 1;
|
|
180
|
+
this.productDetailGeneration += 1;
|
|
87
181
|
this.core = core;
|
|
88
182
|
this.store = options.store || {};
|
|
89
183
|
this.otherParams = options.otherParams || {};
|
|
184
|
+
this.scheduleRuntimeParams = _objectSpread({}, this.otherParams);
|
|
90
185
|
// 获取依赖的插件
|
|
91
186
|
this.request = core.getPlugin('request');
|
|
92
187
|
this.window = core.getPlugin('window');
|
|
93
188
|
this.shopStore = core.getPlugin('shopStore');
|
|
94
189
|
if (this.request) {
|
|
95
|
-
_context.next =
|
|
190
|
+
_context.next = 12;
|
|
96
191
|
break;
|
|
97
192
|
}
|
|
98
193
|
throw new Error('bookingByStep解决方案需要 request 插件支持');
|
|
99
|
-
case
|
|
194
|
+
case 12:
|
|
100
195
|
if (this.shopStore) {
|
|
101
|
-
_context.next =
|
|
196
|
+
_context.next = 14;
|
|
102
197
|
break;
|
|
103
198
|
}
|
|
104
199
|
throw new Error('SummaryModule 需要 shopStore 插件支持');
|
|
105
|
-
case
|
|
200
|
+
case 14:
|
|
106
201
|
// 如果有传 cacheid,默认需要收集上面这些模块里用户操作选中的数据
|
|
107
202
|
// 并且在上面 registerModule 的时候,读取 sessionStroage 里的数据,塞进默认值
|
|
108
203
|
targetCacheData = {};
|
|
@@ -129,15 +224,20 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
129
224
|
fatherModule: _this2.name,
|
|
130
225
|
openCache: (_this2$otherParams = _this2.otherParams) !== null && _this2$otherParams !== void 0 && _this2$otherParams.cacheId ? true : false,
|
|
131
226
|
cacheId: (_this2$otherParams2 = _this2.otherParams) === null || _this2$otherParams2 === void 0 ? void 0 : _this2$otherParams2.cacheId
|
|
132
|
-
}
|
|
227
|
+
}, step === 'schedule' ? {
|
|
228
|
+
scheduleCatalogCache: 'memory',
|
|
229
|
+
bookingRead: true
|
|
230
|
+
} : {})
|
|
133
231
|
});
|
|
134
232
|
} else {
|
|
135
233
|
throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
|
|
136
234
|
}
|
|
137
235
|
});
|
|
138
|
-
this.store.schedule.
|
|
236
|
+
this.store.schedule.ensureScheduleReady().catch(function (error) {
|
|
237
|
+
if ((error === null || error === void 0 ? void 0 : error.name) !== 'AbortError') console.error('[BookingByStep] Schedule preload failed', error);
|
|
238
|
+
});
|
|
139
239
|
this.core.effects.emit("".concat(this.name, ":onInited"), {});
|
|
140
|
-
case
|
|
240
|
+
case 22:
|
|
141
241
|
case "end":
|
|
142
242
|
return _context.stop();
|
|
143
243
|
}
|
|
@@ -257,6 +357,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
257
357
|
startDate: schedule_date || dayjs().format('YYYY-MM-DD'),
|
|
258
358
|
endDate: schedule_date || dayjs().format('YYYY-MM-DD'),
|
|
259
359
|
products: _toConsumableArray(res)
|
|
360
|
+
}).catch(function (error) {
|
|
361
|
+
if ((error === null || error === void 0 ? void 0 : error.name) !== 'AbortError') console.error('[BookingByStep] Resource preload failed', error);
|
|
260
362
|
});
|
|
261
363
|
return _context2.abrupt("return", res);
|
|
262
364
|
case 6:
|
|
@@ -428,17 +530,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
428
530
|
key: "loadScheduleAvailableDate",
|
|
429
531
|
value: (function () {
|
|
430
532
|
var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref3) {
|
|
431
|
-
var startDate, endDate, custom_page_id, channel;
|
|
533
|
+
var startDate, endDate, custom_page_id, channel, assertCurrent;
|
|
432
534
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
433
535
|
while (1) switch (_context5.prev = _context5.next) {
|
|
434
536
|
case 0:
|
|
435
|
-
startDate = _ref3.startDate, endDate = _ref3.endDate, custom_page_id = _ref3.custom_page_id, channel = _ref3.channel;
|
|
537
|
+
startDate = _ref3.startDate, endDate = _ref3.endDate, custom_page_id = _ref3.custom_page_id, channel = _ref3.channel, assertCurrent = _ref3.assertCurrent;
|
|
436
538
|
_context5.next = 3;
|
|
437
539
|
return this.store.schedule.loadScheduleAvailableDate({
|
|
438
540
|
startDate: startDate,
|
|
439
541
|
endDate: endDate,
|
|
440
542
|
custom_page_id: custom_page_id,
|
|
441
|
-
channel: channel
|
|
543
|
+
channel: channel,
|
|
544
|
+
assertCurrent: assertCurrent
|
|
442
545
|
});
|
|
443
546
|
case 3:
|
|
444
547
|
return _context5.abrupt("return", _context5.sent);
|
|
@@ -751,6 +854,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
751
854
|
value: function () {
|
|
752
855
|
var _getAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
753
856
|
var _this4 = this,
|
|
857
|
+
_this$store$currentPr,
|
|
754
858
|
_dateRange$,
|
|
755
859
|
_dateRange$2,
|
|
756
860
|
_dateRange$3;
|
|
@@ -762,7 +866,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
762
866
|
_params$useCache,
|
|
763
867
|
useCache,
|
|
764
868
|
tempProducts,
|
|
765
|
-
|
|
869
|
+
generation,
|
|
870
|
+
lifecycle,
|
|
871
|
+
selectionKey,
|
|
872
|
+
_assertCurrent,
|
|
873
|
+
requiresSchedule,
|
|
874
|
+
_this$store$currentPr2,
|
|
766
875
|
dateRange,
|
|
767
876
|
tempStartDate,
|
|
768
877
|
tempEndDate,
|
|
@@ -770,6 +879,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
770
879
|
resourceIds,
|
|
771
880
|
rules,
|
|
772
881
|
resourcesMap,
|
|
882
|
+
catalogVersion,
|
|
773
883
|
res,
|
|
774
884
|
_args13 = arguments;
|
|
775
885
|
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
@@ -784,6 +894,37 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
784
894
|
tempProducts = products || this.store.cart.getItems().map(function (p) {
|
|
785
895
|
return p._productOrigin;
|
|
786
896
|
});
|
|
897
|
+
generation = this.productDetailGeneration;
|
|
898
|
+
lifecycle = this.lifecycleGeneration;
|
|
899
|
+
selectionKey = products ? undefined : this.resourceSelectionKey();
|
|
900
|
+
_assertCurrent = function assertCurrent() {
|
|
901
|
+
var _params$assertCurrent;
|
|
902
|
+
if (_this4.disposed || lifecycle !== _this4.lifecycleGeneration || (!products || !params.assertCurrent) && generation !== _this4.productDetailGeneration || selectionKey !== undefined && selectionKey !== _this4.resourceSelectionKey()) throw _this4.staleSelection();
|
|
903
|
+
(_params$assertCurrent = params.assertCurrent) === null || _params$assertCurrent === void 0 || _params$assertCurrent.call(params);
|
|
904
|
+
};
|
|
905
|
+
requiresSchedule = tempProducts.some(function (product) {
|
|
906
|
+
var _product$scheduleIds;
|
|
907
|
+
return product === null || product === void 0 || (_product$scheduleIds = product['schedule.ids']) === null || _product$scheduleIds === void 0 ? void 0 : _product$scheduleIds.length;
|
|
908
|
+
}) || !products && !!((_this$store$currentPr = this.store.currentProduct) !== null && _this$store$currentPr !== void 0 && (_this$store$currentPr = _this$store$currentPr['schedule.ids']) !== null && _this$store$currentPr !== void 0 && _this$store$currentPr.length);
|
|
909
|
+
if (!requiresSchedule) {
|
|
910
|
+
_context13.next = 21;
|
|
911
|
+
break;
|
|
912
|
+
}
|
|
913
|
+
_context13.prev = 10;
|
|
914
|
+
_context13.next = 13;
|
|
915
|
+
return this.store.schedule.ensureScheduleReady();
|
|
916
|
+
case 13:
|
|
917
|
+
_context13.next = 19;
|
|
918
|
+
break;
|
|
919
|
+
case 15:
|
|
920
|
+
_context13.prev = 15;
|
|
921
|
+
_context13.t0 = _context13["catch"](10);
|
|
922
|
+
_assertCurrent();
|
|
923
|
+
throw _context13.t0;
|
|
924
|
+
case 19:
|
|
925
|
+
_assertCurrent();
|
|
926
|
+
this.refreshCurrentProductSchedule();
|
|
927
|
+
case 21:
|
|
787
928
|
if (tempProducts.length) {
|
|
788
929
|
tempProducts.forEach(function (p) {
|
|
789
930
|
if (p !== null && p !== void 0 && p['schedule.ids']) {
|
|
@@ -793,24 +934,25 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
793
934
|
});
|
|
794
935
|
}
|
|
795
936
|
// 如果当前打开了某个的商品详情弹窗,则应该默认用这个商品
|
|
796
|
-
if (this.store.currentProduct) {
|
|
937
|
+
if (!products && this.store.currentProduct) {
|
|
797
938
|
tempProducts = [_objectSpread(_objectSpread({}, this.store.currentProduct), {}, {
|
|
798
|
-
_schedule: (_this$store$
|
|
939
|
+
_schedule: (_this$store$currentPr2 = this.store.currentProductMeta) === null || _this$store$currentPr2 === void 0 ? void 0 : _this$store$currentPr2['schedule']
|
|
799
940
|
})];
|
|
800
941
|
}
|
|
801
942
|
dateRange = this.store.date.getDateRange();
|
|
802
943
|
tempStartDate = startDate || (dateRange === null || dateRange === void 0 || (_dateRange$ = dateRange[0]) === null || _dateRange$ === void 0 ? void 0 : _dateRange$.date);
|
|
803
944
|
tempEndDate = endDate || (dateRange === null || dateRange === void 0 || (_dateRange$2 = dateRange[1]) === null || _dateRange$2 === void 0 ? void 0 : _dateRange$2.date) || (dateRange === null || dateRange === void 0 || (_dateRange$3 = dateRange[0]) === null || _dateRange$3 === void 0 ? void 0 : _dateRange$3.date);
|
|
804
945
|
if (tempProducts.length) {
|
|
805
|
-
_context13.next =
|
|
946
|
+
_context13.next = 28;
|
|
806
947
|
break;
|
|
807
948
|
}
|
|
808
949
|
return _context13.abrupt("return", []);
|
|
809
|
-
case
|
|
950
|
+
case 28:
|
|
810
951
|
// 在这里需要把能收集到的数据都收集上来,拼装好给 date 模块去查询
|
|
811
952
|
_ref4 = getAvailableProductResources(tempProducts) || {}, resourceIds = _ref4.resourceIds, rules = _ref4.rules, resourcesMap = _ref4.resourcesMap;
|
|
812
953
|
this.otherParams.currentResourcesMap = resourcesMap;
|
|
813
|
-
|
|
954
|
+
catalogVersion = this.store.schedule.getScheduleCatalogVersion();
|
|
955
|
+
_context13.next = 33;
|
|
814
956
|
return this.store.date.getResourceDates({
|
|
815
957
|
url: params.url,
|
|
816
958
|
query: {
|
|
@@ -820,44 +962,119 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
820
962
|
},
|
|
821
963
|
rules: rules,
|
|
822
964
|
type: type,
|
|
823
|
-
useCache: useCache
|
|
965
|
+
useCache: useCache,
|
|
966
|
+
bookingRead: true,
|
|
967
|
+
errorMode: 'throw',
|
|
968
|
+
assertCurrent: function assertCurrent() {
|
|
969
|
+
_assertCurrent();
|
|
970
|
+
if (requiresSchedule && catalogVersion !== _this4.store.schedule.getScheduleCatalogVersion()) throw _this4.staleSelection();
|
|
971
|
+
}
|
|
824
972
|
});
|
|
825
|
-
case
|
|
973
|
+
case 33:
|
|
826
974
|
res = _context13.sent;
|
|
827
975
|
return _context13.abrupt("return", res);
|
|
828
|
-
case
|
|
976
|
+
case 35:
|
|
829
977
|
case "end":
|
|
830
978
|
return _context13.stop();
|
|
831
979
|
}
|
|
832
|
-
}, _callee13, this);
|
|
980
|
+
}, _callee13, this, [[10, 15]]);
|
|
833
981
|
}));
|
|
834
982
|
function getAvailableDate() {
|
|
835
983
|
return _getAvailableDate.apply(this, arguments);
|
|
836
984
|
}
|
|
837
985
|
return getAvailableDate;
|
|
838
|
-
}()
|
|
986
|
+
}() /** Prepare the exact cart/date selection before synchronous resource checks. */
|
|
987
|
+
}, {
|
|
988
|
+
key: "prepareResourcesForCurrentSelection",
|
|
989
|
+
value: function prepareResourcesForCurrentSelection() {
|
|
990
|
+
var _this$resourcePrepara,
|
|
991
|
+
_this5 = this;
|
|
992
|
+
var key = this.resourceSelectionKey();
|
|
993
|
+
if (((_this$resourcePrepara = this.resourcePreparation) === null || _this$resourcePrepara === void 0 ? void 0 : _this$resourcePrepara.key) === key) return this.resourcePreparation.promise;
|
|
994
|
+
var selected = cloneDeep(this.store.date.getDateRange() || []);
|
|
995
|
+
var cart = this.store.cart.getItems().filter(function (item) {
|
|
996
|
+
return !isNormalProduct(item._productOrigin);
|
|
997
|
+
});
|
|
998
|
+
var sessionDates = cart.filter(function (item) {
|
|
999
|
+
return isSessionProduct(item._productOrigin);
|
|
1000
|
+
}).flatMap(function (item) {
|
|
1001
|
+
return [item.start_date, item.end_date];
|
|
1002
|
+
}).filter(Boolean);
|
|
1003
|
+
var selectedDates = sessionDates.length ? _toConsumableArray(new Set(sessionDates)).sort() : selected.map(function (date) {
|
|
1004
|
+
return date.date;
|
|
1005
|
+
}).sort();
|
|
1006
|
+
var dates = selectedDates;
|
|
1007
|
+
if (!cart.length || !dates.length) return Promise.resolve();
|
|
1008
|
+
var assertCurrent = function assertCurrent() {
|
|
1009
|
+
if (_this5.disposed || key !== _this5.resourceSelectionKey()) throw _this5.staleSelection();
|
|
1010
|
+
};
|
|
1011
|
+
var promise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
1012
|
+
var available;
|
|
1013
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1014
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1015
|
+
case 0:
|
|
1016
|
+
_context14.next = 2;
|
|
1017
|
+
return _this5.getAvailableDate({
|
|
1018
|
+
startDate: dates[0],
|
|
1019
|
+
endDate: dates[dates.length - 1],
|
|
1020
|
+
products: cart.map(function (item) {
|
|
1021
|
+
return item._productOrigin;
|
|
1022
|
+
}),
|
|
1023
|
+
assertCurrent: assertCurrent
|
|
1024
|
+
});
|
|
1025
|
+
case 2:
|
|
1026
|
+
available = _context14.sent;
|
|
1027
|
+
assertCurrent();
|
|
1028
|
+
_this5.store.date.setDateRange(selectedDates.map(function (date) {
|
|
1029
|
+
return available.find(function (item) {
|
|
1030
|
+
return item.date === date;
|
|
1031
|
+
}) || {
|
|
1032
|
+
date: date,
|
|
1033
|
+
week: dayjs(date).format('ddd'),
|
|
1034
|
+
weekNum: dayjs(date).day(),
|
|
1035
|
+
status: 'unavailable',
|
|
1036
|
+
resource: []
|
|
1037
|
+
};
|
|
1038
|
+
}));
|
|
1039
|
+
case 5:
|
|
1040
|
+
case "end":
|
|
1041
|
+
return _context14.stop();
|
|
1042
|
+
}
|
|
1043
|
+
}, _callee14);
|
|
1044
|
+
}))();
|
|
1045
|
+
this.resourcePreparation = {
|
|
1046
|
+
key: key,
|
|
1047
|
+
promise: promise
|
|
1048
|
+
};
|
|
1049
|
+
void promise.finally(function () {
|
|
1050
|
+
var _this5$resourcePrepar;
|
|
1051
|
+
if (((_this5$resourcePrepar = _this5.resourcePreparation) === null || _this5$resourcePrepar === void 0 ? void 0 : _this5$resourcePrepar.promise) === promise) _this5.resourcePreparation = undefined;
|
|
1052
|
+
}).catch(function () {});
|
|
1053
|
+
return promise;
|
|
1054
|
+
}
|
|
1055
|
+
|
|
839
1056
|
/**
|
|
840
1057
|
* 获取购物车汇总信息
|
|
841
1058
|
*/
|
|
842
1059
|
}, {
|
|
843
1060
|
key: "getSummary",
|
|
844
1061
|
value: (function () {
|
|
845
|
-
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1062
|
+
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
846
1063
|
var cartItems, summary;
|
|
847
|
-
return _regeneratorRuntime().wrap(function
|
|
848
|
-
while (1) switch (
|
|
1064
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1065
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
849
1066
|
case 0:
|
|
850
1067
|
cartItems = this.store.cart.getItems();
|
|
851
|
-
|
|
1068
|
+
_context15.next = 3;
|
|
852
1069
|
return this.store.summary.getSummary(cartItems);
|
|
853
1070
|
case 3:
|
|
854
|
-
summary =
|
|
855
|
-
return
|
|
1071
|
+
summary = _context15.sent;
|
|
1072
|
+
return _context15.abrupt("return", summary);
|
|
856
1073
|
case 5:
|
|
857
1074
|
case "end":
|
|
858
|
-
return
|
|
1075
|
+
return _context15.stop();
|
|
859
1076
|
}
|
|
860
|
-
},
|
|
1077
|
+
}, _callee15, this);
|
|
861
1078
|
}));
|
|
862
1079
|
function getSummary() {
|
|
863
1080
|
return _getSummary.apply(this, arguments);
|
|
@@ -871,16 +1088,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
871
1088
|
}, {
|
|
872
1089
|
key: "getProtocol",
|
|
873
1090
|
value: (function () {
|
|
874
|
-
var _getProtocol = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
875
|
-
return _regeneratorRuntime().wrap(function
|
|
876
|
-
while (1) switch (
|
|
1091
|
+
var _getProtocol = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(protocolId) {
|
|
1092
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1093
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
877
1094
|
case 0:
|
|
878
|
-
return
|
|
1095
|
+
return _context16.abrupt("return", this.store.summary.getProtocol(protocolId));
|
|
879
1096
|
case 1:
|
|
880
1097
|
case "end":
|
|
881
|
-
return
|
|
1098
|
+
return _context16.stop();
|
|
882
1099
|
}
|
|
883
|
-
},
|
|
1100
|
+
}, _callee16, this);
|
|
884
1101
|
}));
|
|
885
1102
|
function getProtocol(_x14) {
|
|
886
1103
|
return _getProtocol.apply(this, arguments);
|
|
@@ -891,16 +1108,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
891
1108
|
}, {
|
|
892
1109
|
key: "getProducts",
|
|
893
1110
|
value: function () {
|
|
894
|
-
var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
895
|
-
return _regeneratorRuntime().wrap(function
|
|
896
|
-
while (1) switch (
|
|
1111
|
+
var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
1112
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1113
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
897
1114
|
case 0:
|
|
898
|
-
return
|
|
1115
|
+
return _context17.abrupt("return", this.store.products.getProducts());
|
|
899
1116
|
case 1:
|
|
900
1117
|
case "end":
|
|
901
|
-
return
|
|
1118
|
+
return _context17.stop();
|
|
902
1119
|
}
|
|
903
|
-
},
|
|
1120
|
+
}, _callee17, this);
|
|
904
1121
|
}));
|
|
905
1122
|
function getProducts() {
|
|
906
1123
|
return _getProducts.apply(this, arguments);
|
|
@@ -910,15 +1127,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
910
1127
|
}, {
|
|
911
1128
|
key: "setLoginAccount",
|
|
912
1129
|
value: function () {
|
|
913
|
-
var _setLoginAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
914
|
-
var
|
|
1130
|
+
var _setLoginAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(accountId, accountInfo) {
|
|
1131
|
+
var _this6 = this;
|
|
915
1132
|
var account, stateAccountId, cartItems, _this$store$date$getD2, date, normalProductCartItem, customerId;
|
|
916
|
-
return _regeneratorRuntime().wrap(function
|
|
917
|
-
while (1) switch (
|
|
1133
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1134
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
918
1135
|
case 0:
|
|
919
1136
|
account = this.store.accountList.getAccount(accountId);
|
|
920
1137
|
if (!account) {
|
|
921
|
-
|
|
1138
|
+
_context18.next = 23;
|
|
922
1139
|
break;
|
|
923
1140
|
}
|
|
924
1141
|
stateAccountId = account.getId();
|
|
@@ -928,7 +1145,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
928
1145
|
cartItems = this.store.cart.getItems();
|
|
929
1146
|
cartItems.forEach(function (item) {
|
|
930
1147
|
if (item.holder_id === accountId) {
|
|
931
|
-
|
|
1148
|
+
_this6.store.cart.updateItem({
|
|
932
1149
|
_id: item._id,
|
|
933
1150
|
account: accountInfo
|
|
934
1151
|
});
|
|
@@ -936,7 +1153,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
936
1153
|
});
|
|
937
1154
|
this.store.accountList.updateAccountListById(stateAccountId, accountInfo);
|
|
938
1155
|
if (!cartItems.length) {
|
|
939
|
-
|
|
1156
|
+
_context18.next = 21;
|
|
940
1157
|
break;
|
|
941
1158
|
}
|
|
942
1159
|
date = (_this$store$date$getD2 = this.store.date.getDateRange()) === null || _this$store$date$getD2 === void 0 || (_this$store$date$getD2 = _this$store$date$getD2[0]) === null || _this$store$date$getD2 === void 0 ? void 0 : _this$store$date$getD2.date;
|
|
@@ -951,29 +1168,29 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
951
1168
|
this.updateQuotationPriceAndCart(date);
|
|
952
1169
|
|
|
953
1170
|
// 登录后刷新 holder 表单
|
|
954
|
-
|
|
1171
|
+
_context18.prev = 12;
|
|
955
1172
|
customerId = Number(accountInfo.id);
|
|
956
|
-
|
|
1173
|
+
_context18.next = 16;
|
|
957
1174
|
return this.refreshAllHolderFormRecords({
|
|
958
1175
|
customer_id: customerId
|
|
959
1176
|
});
|
|
960
1177
|
case 16:
|
|
961
|
-
|
|
1178
|
+
_context18.next = 21;
|
|
962
1179
|
break;
|
|
963
1180
|
case 18:
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
console.error('[BookingByStep] 登录后刷新 holder 表单失败',
|
|
1181
|
+
_context18.prev = 18;
|
|
1182
|
+
_context18.t0 = _context18["catch"](12);
|
|
1183
|
+
console.error('[BookingByStep] 登录后刷新 holder 表单失败', _context18.t0);
|
|
967
1184
|
case 21:
|
|
968
|
-
|
|
1185
|
+
_context18.next = 24;
|
|
969
1186
|
break;
|
|
970
1187
|
case 23:
|
|
971
1188
|
throw new Error("\u6CA1\u6709\u627E\u5230".concat(accountId, "\u8D26\u6237"));
|
|
972
1189
|
case 24:
|
|
973
1190
|
case "end":
|
|
974
|
-
return
|
|
1191
|
+
return _context18.stop();
|
|
975
1192
|
}
|
|
976
|
-
},
|
|
1193
|
+
}, _callee18, this, [[12, 18]]);
|
|
977
1194
|
}));
|
|
978
1195
|
function setLoginAccount(_x15, _x16) {
|
|
979
1196
|
return _setLoginAccount.apply(this, arguments);
|
|
@@ -983,14 +1200,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
983
1200
|
}, {
|
|
984
1201
|
key: "generateCartData",
|
|
985
1202
|
value: function () {
|
|
986
|
-
var _generateCartData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
987
|
-
return _regeneratorRuntime().wrap(function
|
|
988
|
-
while (1) switch (
|
|
1203
|
+
var _generateCartData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
|
|
1204
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1205
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
989
1206
|
case 0:
|
|
990
1207
|
case "end":
|
|
991
|
-
return
|
|
1208
|
+
return _context19.stop();
|
|
992
1209
|
}
|
|
993
|
-
},
|
|
1210
|
+
}, _callee19);
|
|
994
1211
|
}));
|
|
995
1212
|
function generateCartData() {
|
|
996
1213
|
return _generateCartData.apply(this, arguments);
|
|
@@ -1000,21 +1217,21 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1000
1217
|
}, {
|
|
1001
1218
|
key: "getFreeProduct",
|
|
1002
1219
|
value: function () {
|
|
1003
|
-
var _getFreeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1220
|
+
var _getFreeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(id) {
|
|
1004
1221
|
var res;
|
|
1005
|
-
return _regeneratorRuntime().wrap(function
|
|
1006
|
-
while (1) switch (
|
|
1222
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1223
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1007
1224
|
case 0:
|
|
1008
|
-
|
|
1225
|
+
_context20.next = 2;
|
|
1009
1226
|
return this.request.post("/pay/order/free-pay/".concat(id));
|
|
1010
1227
|
case 2:
|
|
1011
|
-
res =
|
|
1012
|
-
return
|
|
1228
|
+
res = _context20.sent;
|
|
1229
|
+
return _context20.abrupt("return", res);
|
|
1013
1230
|
case 4:
|
|
1014
1231
|
case "end":
|
|
1015
|
-
return
|
|
1232
|
+
return _context20.stop();
|
|
1016
1233
|
}
|
|
1017
|
-
},
|
|
1234
|
+
}, _callee20, this);
|
|
1018
1235
|
}));
|
|
1019
1236
|
function getFreeProduct(_x17) {
|
|
1020
1237
|
return _getFreeProduct.apply(this, arguments);
|
|
@@ -1039,17 +1256,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1039
1256
|
}, {
|
|
1040
1257
|
key: "submitOrder",
|
|
1041
1258
|
value: function () {
|
|
1042
|
-
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1259
|
+
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(extraData) {
|
|
1043
1260
|
var _this$otherParams4;
|
|
1044
1261
|
var cartItems, newCartItems, type;
|
|
1045
|
-
return _regeneratorRuntime().wrap(function
|
|
1046
|
-
while (1) switch (
|
|
1262
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1263
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1047
1264
|
case 0:
|
|
1048
1265
|
cartItems = this.store.cart.getItems();
|
|
1049
1266
|
newCartItems = cloneDeep(cartItems); // 先整个临时的逻辑,把购物车里所有商品的资源给他格式化一下
|
|
1050
1267
|
newCartItems.forEach(function (item) {
|
|
1051
1268
|
if (item._origin.resources && item._origin.resources.length) {
|
|
1052
|
-
var _item$
|
|
1269
|
+
var _item$_origin2;
|
|
1053
1270
|
item._origin.resources = item._origin.resources.map(function (n) {
|
|
1054
1271
|
var newResourcesItem = cloneDeep(n);
|
|
1055
1272
|
delete newResourcesItem.id;
|
|
@@ -1060,7 +1277,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1060
1277
|
var _getCapacityInfoByCar = getCapacityInfoByCartItem(item),
|
|
1061
1278
|
currentCapacity = _getCapacityInfoByCar.currentCapacity,
|
|
1062
1279
|
formatCapacity = _getCapacityInfoByCar.formatCapacity;
|
|
1063
|
-
if (!((_item$
|
|
1280
|
+
if (!((_item$_origin2 = item._origin) !== null && _item$_origin2 !== void 0 && _item$_origin2.metadata)) {
|
|
1064
1281
|
item._origin.metadata = {};
|
|
1065
1282
|
}
|
|
1066
1283
|
item._origin.metadata.capacity = formatCapacity;
|
|
@@ -1073,7 +1290,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1073
1290
|
}))) {
|
|
1074
1291
|
type = 'virtual';
|
|
1075
1292
|
}
|
|
1076
|
-
return
|
|
1293
|
+
return _context21.abrupt("return", this.store.order.submitOrder({
|
|
1077
1294
|
query: {
|
|
1078
1295
|
cartItems: newCartItems,
|
|
1079
1296
|
type: type,
|
|
@@ -1084,9 +1301,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1084
1301
|
}));
|
|
1085
1302
|
case 6:
|
|
1086
1303
|
case "end":
|
|
1087
|
-
return
|
|
1304
|
+
return _context21.stop();
|
|
1088
1305
|
}
|
|
1089
|
-
},
|
|
1306
|
+
}, _callee21, this);
|
|
1090
1307
|
}));
|
|
1091
1308
|
function submitOrder(_x18) {
|
|
1092
1309
|
return _submitOrder.apply(this, arguments);
|
|
@@ -1096,14 +1313,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1096
1313
|
}, {
|
|
1097
1314
|
key: "pay",
|
|
1098
1315
|
value: function () {
|
|
1099
|
-
var _pay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1100
|
-
return _regeneratorRuntime().wrap(function
|
|
1101
|
-
while (1) switch (
|
|
1316
|
+
var _pay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
|
|
1317
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
1318
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1102
1319
|
case 0:
|
|
1103
1320
|
case "end":
|
|
1104
|
-
return
|
|
1321
|
+
return _context22.stop();
|
|
1105
1322
|
}
|
|
1106
|
-
},
|
|
1323
|
+
}, _callee22);
|
|
1107
1324
|
}));
|
|
1108
1325
|
function pay() {
|
|
1109
1326
|
return _pay.apply(this, arguments);
|
|
@@ -1113,14 +1330,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1113
1330
|
}, {
|
|
1114
1331
|
key: "getPayInfo",
|
|
1115
1332
|
value: function () {
|
|
1116
|
-
var _getPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1117
|
-
return _regeneratorRuntime().wrap(function
|
|
1118
|
-
while (1) switch (
|
|
1333
|
+
var _getPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
1334
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
1335
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1119
1336
|
case 0:
|
|
1120
1337
|
case "end":
|
|
1121
|
-
return
|
|
1338
|
+
return _context23.stop();
|
|
1122
1339
|
}
|
|
1123
|
-
},
|
|
1340
|
+
}, _callee23);
|
|
1124
1341
|
}));
|
|
1125
1342
|
function getPayInfo() {
|
|
1126
1343
|
return _getPayInfo.apply(this, arguments);
|
|
@@ -1130,25 +1347,33 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1130
1347
|
}, {
|
|
1131
1348
|
key: "setOtherParams",
|
|
1132
1349
|
value: function () {
|
|
1133
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1134
|
-
var
|
|
1135
|
-
|
|
1350
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
|
|
1351
|
+
var _this$store$schedule;
|
|
1352
|
+
var _ref6,
|
|
1353
|
+
_ref6$cover,
|
|
1136
1354
|
cover,
|
|
1137
|
-
|
|
1138
|
-
return _regeneratorRuntime().wrap(function
|
|
1139
|
-
while (1) switch (
|
|
1355
|
+
_args24 = arguments;
|
|
1356
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
1357
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1140
1358
|
case 0:
|
|
1141
|
-
|
|
1359
|
+
_ref6 = _args24.length > 1 && _args24[1] !== undefined ? _args24[1] : {}, _ref6$cover = _ref6.cover, cover = _ref6$cover === void 0 ? false : _ref6$cover;
|
|
1360
|
+
this.scheduleRuntimeParams = _objectSpread(_objectSpread({}, this.scheduleRuntimeParams), params);
|
|
1142
1361
|
if (cover) {
|
|
1143
1362
|
this.otherParams = params;
|
|
1144
1363
|
} else {
|
|
1145
1364
|
this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
|
|
1146
1365
|
}
|
|
1147
|
-
|
|
1366
|
+
(_this$store$schedule = this.store.schedule) === null || _this$store$schedule === void 0 || _this$store$schedule.updateOtherParams(_objectSpread(_objectSpread({}, this.scheduleRuntimeParams), {}, {
|
|
1367
|
+
fatherModule: this.name,
|
|
1368
|
+
openCache: !!this.scheduleRuntimeParams.cacheId,
|
|
1369
|
+
scheduleCatalogCache: 'memory',
|
|
1370
|
+
bookingRead: true
|
|
1371
|
+
}));
|
|
1372
|
+
case 4:
|
|
1148
1373
|
case "end":
|
|
1149
|
-
return
|
|
1374
|
+
return _context24.stop();
|
|
1150
1375
|
}
|
|
1151
|
-
},
|
|
1376
|
+
}, _callee24, this);
|
|
1152
1377
|
}));
|
|
1153
1378
|
function setOtherParams(_x19) {
|
|
1154
1379
|
return _setOtherParams.apply(this, arguments);
|
|
@@ -1158,16 +1383,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1158
1383
|
}, {
|
|
1159
1384
|
key: "getOtherParams",
|
|
1160
1385
|
value: function () {
|
|
1161
|
-
var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1162
|
-
return _regeneratorRuntime().wrap(function
|
|
1163
|
-
while (1) switch (
|
|
1386
|
+
var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
|
|
1387
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
1388
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
1164
1389
|
case 0:
|
|
1165
|
-
return
|
|
1390
|
+
return _context25.abrupt("return", this.otherParams);
|
|
1166
1391
|
case 1:
|
|
1167
1392
|
case "end":
|
|
1168
|
-
return
|
|
1393
|
+
return _context25.stop();
|
|
1169
1394
|
}
|
|
1170
|
-
},
|
|
1395
|
+
}, _callee25, this);
|
|
1171
1396
|
}));
|
|
1172
1397
|
function getOtherParams() {
|
|
1173
1398
|
return _getOtherParams.apply(this, arguments);
|
|
@@ -1189,7 +1414,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1189
1414
|
// 直接调用 addProductToCart,不传递 date 参数以避免日期检查逻辑
|
|
1190
1415
|
return this.addProductToCart({
|
|
1191
1416
|
product: productData,
|
|
1192
|
-
account: activeAccount
|
|
1417
|
+
account: activeAccount,
|
|
1418
|
+
isLegacyOrder: true
|
|
1193
1419
|
});
|
|
1194
1420
|
}
|
|
1195
1421
|
|
|
@@ -1200,6 +1426,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1200
1426
|
* product: ProductData;
|
|
1201
1427
|
* date?: { startTime: string; endTime: string } | null;
|
|
1202
1428
|
* account?: Account | null;
|
|
1429
|
+
* isLegacyOrder?: boolean;
|
|
1203
1430
|
* })} {
|
|
1204
1431
|
* product,
|
|
1205
1432
|
* date,
|
|
@@ -1210,18 +1437,20 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1210
1437
|
*/
|
|
1211
1438
|
}, {
|
|
1212
1439
|
key: "addProductToCart",
|
|
1213
|
-
value: function addProductToCart(
|
|
1214
|
-
var product =
|
|
1215
|
-
date =
|
|
1216
|
-
account =
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1440
|
+
value: function addProductToCart(_ref7) {
|
|
1441
|
+
var product = _ref7.product,
|
|
1442
|
+
date = _ref7.date,
|
|
1443
|
+
account = _ref7.account,
|
|
1444
|
+
_ref7$isLegacyOrder = _ref7.isLegacyOrder,
|
|
1445
|
+
isLegacyOrder = _ref7$isLegacyOrder === void 0 ? false : _ref7$isLegacyOrder;
|
|
1446
|
+
var _ref8 = product || {},
|
|
1447
|
+
bundle = _ref8.bundle,
|
|
1448
|
+
options = _ref8.options,
|
|
1449
|
+
origin = _ref8.origin,
|
|
1450
|
+
product_variant_id = _ref8.product_variant_id,
|
|
1451
|
+
rowKey = _ref8.rowKey,
|
|
1452
|
+
_ref8$quantity = _ref8.quantity,
|
|
1453
|
+
quantity = _ref8$quantity === void 0 ? 1 : _ref8$quantity;
|
|
1225
1454
|
var productData = _objectSpread(_objectSpread({}, origin), {}, {
|
|
1226
1455
|
product_variant_id: product_variant_id
|
|
1227
1456
|
});
|
|
@@ -1278,7 +1507,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1278
1507
|
product: productData,
|
|
1279
1508
|
bundle: bundle,
|
|
1280
1509
|
options: options,
|
|
1281
|
-
quantity: quantity
|
|
1510
|
+
quantity: quantity,
|
|
1511
|
+
isLegacyOrder: isLegacyOrder
|
|
1282
1512
|
};
|
|
1283
1513
|
if (date) {
|
|
1284
1514
|
addItemParams.date = date;
|
|
@@ -1312,9 +1542,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1312
1542
|
*/
|
|
1313
1543
|
}, {
|
|
1314
1544
|
key: "addProductCheck",
|
|
1315
|
-
value: function addProductCheck(
|
|
1316
|
-
var
|
|
1317
|
-
var date =
|
|
1545
|
+
value: function addProductCheck(_ref9) {
|
|
1546
|
+
var _this7 = this;
|
|
1547
|
+
var date = _ref9.date;
|
|
1318
1548
|
// 检测,有传递 date,检查购物车里其他商品的 date 是否在同一天,如果不在,清空那些不在同一天的商品
|
|
1319
1549
|
if (date) {
|
|
1320
1550
|
var cartItems = this.store.cart.getItems().filter(function (n) {
|
|
@@ -1325,7 +1555,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1325
1555
|
});
|
|
1326
1556
|
if (cartItemsByDate.length) {
|
|
1327
1557
|
cartItemsByDate.forEach(function (n) {
|
|
1328
|
-
|
|
1558
|
+
_this7.store.cart.removeItem(n._id);
|
|
1329
1559
|
});
|
|
1330
1560
|
}
|
|
1331
1561
|
// // 如果 date.startTime 和 dateRange 里的 startTime 不一样,需要修正 dateRange
|
|
@@ -1377,7 +1607,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1377
1607
|
key: "updateCartCheck",
|
|
1378
1608
|
value: function updateCartCheck(params, targetCartItem) {
|
|
1379
1609
|
var _params$resources,
|
|
1380
|
-
|
|
1610
|
+
_this8 = this;
|
|
1381
1611
|
// 零售模板不需要检测
|
|
1382
1612
|
if (this.otherParams.isRetailTemplate) {
|
|
1383
1613
|
return;
|
|
@@ -1438,7 +1668,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1438
1668
|
var end_time = item.end_time;
|
|
1439
1669
|
var start_date = item.start_date;
|
|
1440
1670
|
var end_date = item.end_date;
|
|
1441
|
-
|
|
1671
|
+
_this8.store.cart.updateItem({
|
|
1442
1672
|
_id: item._id,
|
|
1443
1673
|
resources: resources,
|
|
1444
1674
|
date: {
|
|
@@ -1447,7 +1677,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1447
1677
|
}
|
|
1448
1678
|
});
|
|
1449
1679
|
} else {
|
|
1450
|
-
|
|
1680
|
+
_this8.store.cart.updateItem({
|
|
1451
1681
|
_id: item._id,
|
|
1452
1682
|
resources: resources
|
|
1453
1683
|
});
|
|
@@ -1484,10 +1714,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1484
1714
|
}, {
|
|
1485
1715
|
key: "batchUpdateCart",
|
|
1486
1716
|
value: function batchUpdateCart(paramsList) {
|
|
1487
|
-
var
|
|
1717
|
+
var _this9 = this;
|
|
1488
1718
|
var cartItems = [];
|
|
1489
1719
|
paramsList.forEach(function (params) {
|
|
1490
|
-
var cartItem =
|
|
1720
|
+
var cartItem = _this9.store.cart.formatCartItem(params);
|
|
1491
1721
|
cartItems.push(cartItem);
|
|
1492
1722
|
});
|
|
1493
1723
|
this.store.cart.batchSetItems(cartItems);
|
|
@@ -1515,14 +1745,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1515
1745
|
}, {
|
|
1516
1746
|
key: "checkCartItems",
|
|
1517
1747
|
value: function checkCartItems(type) {
|
|
1518
|
-
var
|
|
1748
|
+
var _this10 = this;
|
|
1519
1749
|
// 预约流程中普通商品无需检测这些东西
|
|
1520
1750
|
var cartItems = this.store.cart.getItems().filter(function (n) {
|
|
1521
1751
|
return !isNormalProduct(n._productOrigin);
|
|
1522
1752
|
});
|
|
1523
1753
|
var errorCartItemIds = [];
|
|
1524
1754
|
cartItems.forEach(function (cartItem) {
|
|
1525
|
-
var result =
|
|
1755
|
+
var result = _this10.store.cart.checkCartItemByType(cartItem, type);
|
|
1526
1756
|
if (!result) {
|
|
1527
1757
|
errorCartItemIds.push(cartItem._id);
|
|
1528
1758
|
}
|
|
@@ -1532,7 +1762,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1532
1762
|
}, {
|
|
1533
1763
|
key: "destroy",
|
|
1534
1764
|
value: function destroy() {
|
|
1535
|
-
var _this$store$cart, _this$store$step, _this$store$products, _this$store$guests, _this$store$date, _this$store$accountLi;
|
|
1765
|
+
var _this$store$schedule2, _this$store$cart, _this$store$step, _this$store$products, _this$store$guests, _this$store$date, _this$store$accountLi;
|
|
1766
|
+
this.disposed = true;
|
|
1767
|
+
this.lifecycleGeneration += 1;
|
|
1768
|
+
this.productDetailGeneration += 1;
|
|
1769
|
+
this.resourcePreparation = undefined;
|
|
1770
|
+
(_this$store$schedule2 = this.store.schedule) === null || _this$store$schedule2 === void 0 || _this$store$schedule2.destroy();
|
|
1536
1771
|
(_this$store$cart = this.store.cart) === null || _this$store$cart === void 0 || _this$store$cart.destroy();
|
|
1537
1772
|
(_this$store$step = this.store.step) === null || _this$store$step === void 0 || _this$store$step.destroy();
|
|
1538
1773
|
(_this$store$products = this.store.products) === null || _this$store$products === void 0 || _this$store$products.destroy();
|
|
@@ -1547,7 +1782,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1547
1782
|
}, {
|
|
1548
1783
|
key: "getResourcesList",
|
|
1549
1784
|
value: function getResourcesList() {
|
|
1550
|
-
var
|
|
1785
|
+
var _this11 = this;
|
|
1551
1786
|
var dateRange = this.store.date.getDateRange();
|
|
1552
1787
|
var resources = [];
|
|
1553
1788
|
if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
|
|
@@ -1637,9 +1872,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1637
1872
|
});
|
|
1638
1873
|
});
|
|
1639
1874
|
} else {
|
|
1640
|
-
var _cartItem$_productOri3,
|
|
1875
|
+
var _cartItem$_productOri3, _this11$shopStore$get, _cartItem$_productOri4, _cartItem$_productOri5;
|
|
1641
1876
|
var hasFlexibleDuration = ((_cartItem$_productOri3 = cartItem._productOrigin) === null || _cartItem$_productOri3 === void 0 || (_cartItem$_productOri3 = _cartItem$_productOri3.duration) === null || _cartItem$_productOri3 === void 0 ? void 0 : _cartItem$_productOri3.type) === 'flexible';
|
|
1642
|
-
var operating_day_boundary = (
|
|
1877
|
+
var operating_day_boundary = (_this11$shopStore$get = _this11.shopStore.get('core')) === null || _this11$shopStore$get === void 0 || (_this11$shopStore$get = _this11$shopStore$get.core) === null || _this11$shopStore$get === void 0 ? void 0 : _this11$shopStore$get.operating_day_boundary;
|
|
1643
1878
|
var maxBlockThreshold = (_cartItem$_productOri4 = cartItem._productOrigin) !== null && _cartItem$_productOri4 !== void 0 && (_cartItem$_productOri4 = _cartItem$_productOri4.duration) !== null && _cartItem$_productOri4 !== void 0 && (_cartItem$_productOri4 = _cartItem$_productOri4.flexible_config) !== null && _cartItem$_productOri4 !== void 0 && _cartItem$_productOri4.is_enable_minimum_duration ? ((_cartItem$_productOri5 = cartItem._productOrigin) === null || _cartItem$_productOri5 === void 0 || (_cartItem$_productOri5 = _cartItem$_productOri5.duration) === null || _cartItem$_productOri5 === void 0 || (_cartItem$_productOri5 = _cartItem$_productOri5.flexible_config) === null || _cartItem$_productOri5 === void 0 ? void 0 : _cartItem$_productOri5.block_threshold) || 0 : 0;
|
|
1644
1879
|
productResources.forEach(function (item) {
|
|
1645
1880
|
// 如果资源的 capacity 已经小于了当前需要的 capacity ,则需要把资源给过滤掉
|
|
@@ -1757,14 +1992,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1757
1992
|
// 自动分派可用资源-pro 版,ui 传递某个账号,自动给某个账号下所有商品分配第一种资源
|
|
1758
1993
|
}, {
|
|
1759
1994
|
key: "autoSelectAccountResources",
|
|
1760
|
-
value: function autoSelectAccountResources(
|
|
1995
|
+
value: function autoSelectAccountResources(_ref10) {
|
|
1761
1996
|
var _cartItem$_productOri8, _allProductResources$;
|
|
1762
|
-
var cartItem =
|
|
1763
|
-
holder_id =
|
|
1764
|
-
resources_code =
|
|
1765
|
-
timeSlots =
|
|
1766
|
-
countMap =
|
|
1767
|
-
capacity =
|
|
1997
|
+
var cartItem = _ref10.cartItem,
|
|
1998
|
+
holder_id = _ref10.holder_id,
|
|
1999
|
+
resources_code = _ref10.resources_code,
|
|
2000
|
+
timeSlots = _ref10.timeSlots,
|
|
2001
|
+
countMap = _ref10.countMap,
|
|
2002
|
+
capacity = _ref10.capacity;
|
|
1768
2003
|
if (isNormalProduct(cartItem._productOrigin)) {
|
|
1769
2004
|
return {};
|
|
1770
2005
|
}
|
|
@@ -1938,7 +2173,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1938
2173
|
key: "autoSelectAllProductResources",
|
|
1939
2174
|
value: function autoSelectAllProductResources(resources_code, timeSlots) {
|
|
1940
2175
|
var _dateRange$4,
|
|
1941
|
-
|
|
2176
|
+
_this12 = this;
|
|
1942
2177
|
var dateRange = this.store.date.getDateRange();
|
|
1943
2178
|
var resources = [];
|
|
1944
2179
|
if (dateRange !== null && dateRange !== void 0 && (_dateRange$4 = dateRange[0]) !== null && _dateRange$4 !== void 0 && _dateRange$4.date) {
|
|
@@ -1960,8 +2195,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1960
2195
|
// 第一个商品分配完以后,第二个商品分配的start_time应该是第一个商品的 end_time ,然后 end_time 应该是 start_time+duration
|
|
1961
2196
|
// 判断购物车里是否有 flexible 类型的商品,如果有则不累加时间
|
|
1962
2197
|
var hasFlexibleProduct = cartItems.some(function (item) {
|
|
1963
|
-
var _item$
|
|
1964
|
-
return ((_item$
|
|
2198
|
+
var _item$_productOrigin6;
|
|
2199
|
+
return ((_item$_productOrigin6 = item._productOrigin) === null || _item$_productOrigin6 === void 0 || (_item$_productOrigin6 = _item$_productOrigin6.duration) === null || _item$_productOrigin6 === void 0 ? void 0 : _item$_productOrigin6.type) === 'flexible';
|
|
1965
2200
|
});
|
|
1966
2201
|
cartItems.forEach(function (item, index) {
|
|
1967
2202
|
var _getCapacityInfoByCar6 = getCapacityInfoByCartItem(item),
|
|
@@ -1977,18 +2212,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1977
2212
|
};
|
|
1978
2213
|
}
|
|
1979
2214
|
if (recordTimeSlots) {
|
|
1980
|
-
var _item$
|
|
2215
|
+
var _item$_productOrigin7, _item$_productOrigin8;
|
|
1981
2216
|
// 同一账号下,如果当前商品不是第一个,则需要根据上一个商品的 end_time 和 duration 计算出当前商品的 start_time 和 end_time
|
|
1982
2217
|
// 前提:当前资源是单个预约才需要这么做
|
|
1983
|
-
var currentResourceConfig = (_item$
|
|
2218
|
+
var currentResourceConfig = (_item$_productOrigin7 = item._productOrigin) === null || _item$_productOrigin7 === void 0 || (_item$_productOrigin7 = _item$_productOrigin7.product_resource) === null || _item$_productOrigin7 === void 0 || (_item$_productOrigin7 = _item$_productOrigin7.resources) === null || _item$_productOrigin7 === void 0 ? void 0 : _item$_productOrigin7.find(function (n) {
|
|
1984
2219
|
return n.code === resources_code;
|
|
1985
2220
|
});
|
|
1986
2221
|
// 只有 duration 类商品且不含有灵活时间的商品需要这个操作
|
|
1987
|
-
if (index !== 0 && recordTimeSlots && (currentResourceConfig === null || currentResourceConfig === void 0 ? void 0 : currentResourceConfig.type) === 'single' && (_item$
|
|
1988
|
-
var _item$
|
|
2222
|
+
if (index !== 0 && recordTimeSlots && (currentResourceConfig === null || currentResourceConfig === void 0 ? void 0 : currentResourceConfig.type) === 'single' && (_item$_productOrigin8 = item._productOrigin) !== null && _item$_productOrigin8 !== void 0 && _item$_productOrigin8.duration && !hasFlexibleProduct && !hasOriginTimeSlot) {
|
|
2223
|
+
var _item$_productOrigin9;
|
|
1989
2224
|
var recordEndAt = recordTimeSlots.end_at ? dayjs(recordTimeSlots.end_at) : dayjs("".concat(item.start_date, " ").concat(recordTimeSlots.end_time));
|
|
1990
2225
|
var start_at = recordEndAt;
|
|
1991
|
-
var end_at = start_at.add(((_item$
|
|
2226
|
+
var end_at = start_at.add(((_item$_productOrigin9 = item._productOrigin) === null || _item$_productOrigin9 === void 0 || (_item$_productOrigin9 = _item$_productOrigin9.duration) === null || _item$_productOrigin9 === void 0 ? void 0 : _item$_productOrigin9.value) || 10, 'minutes');
|
|
1992
2227
|
recordTimeSlots = {
|
|
1993
2228
|
start_time: start_at.format('HH:mm'),
|
|
1994
2229
|
end_time: end_at.format('HH:mm'),
|
|
@@ -1997,7 +2232,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1997
2232
|
};
|
|
1998
2233
|
}
|
|
1999
2234
|
// 如果传递了 timeSlots,代表是第二种资源,则直接拿 timeSlots 去匹配
|
|
2000
|
-
var res =
|
|
2235
|
+
var res = _this12.autoSelectAccountResources({
|
|
2001
2236
|
cartItem: item,
|
|
2002
2237
|
holder_id: item.holder_id,
|
|
2003
2238
|
resources_code: resources_code,
|
|
@@ -2019,7 +2254,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2019
2254
|
}
|
|
2020
2255
|
res.selectedResource.capacity = currentCapacity;
|
|
2021
2256
|
checkSubResourcesCapacity(res.selectedResource);
|
|
2022
|
-
|
|
2257
|
+
_this12.store.cart.updateItem({
|
|
2023
2258
|
_id: item._id,
|
|
2024
2259
|
// 这里要做去重,避免出现同样类型的资源被塞进同一个商品
|
|
2025
2260
|
resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
|
|
@@ -2032,13 +2267,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2032
2267
|
errorList.push(item._id);
|
|
2033
2268
|
}
|
|
2034
2269
|
} else {
|
|
2035
|
-
var _item$
|
|
2270
|
+
var _item$_productOrigin10, _productResources$fin;
|
|
2036
2271
|
// 这里必须每次循环重新读,避免前一次循环操作了购物车,导致数据变更
|
|
2037
2272
|
// 能进到这种逻辑,说明是 duration 类商品或者灵活时长商品,且是第一种资源,还没有确定时间
|
|
2038
|
-
var allCartItems = cloneDeep(
|
|
2273
|
+
var allCartItems = cloneDeep(_this12.store.cart.getItems());
|
|
2039
2274
|
// 如果没有传递 timeSlots,代表是第一种资源,则直接拿商品的 duration,到资源列表里找一个公共可用的
|
|
2040
2275
|
var selectedResources = [];
|
|
2041
|
-
var _resources = cloneDeep(((_item$
|
|
2276
|
+
var _resources = cloneDeep(((_item$_productOrigin10 = item._productOrigin) === null || _item$_productOrigin10 === void 0 || (_item$_productOrigin10 = _item$_productOrigin10.product_resource) === null || _item$_productOrigin10 === void 0 ? void 0 : _item$_productOrigin10.resources) || []);
|
|
2042
2277
|
var currentResourcesRenderList = [];
|
|
2043
2278
|
_resources.forEach(function (n) {
|
|
2044
2279
|
var _n$renderList;
|
|
@@ -2078,7 +2313,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2078
2313
|
return n.code === resources_code;
|
|
2079
2314
|
})) === null || _productResources$fin === void 0 ? void 0 : _productResources$fin.renderList;
|
|
2080
2315
|
if (targetRenderList && targetRenderList.length > 0) {
|
|
2081
|
-
var _item$_origin$resourc2, _dateRange$5, _item$duration2, _item$
|
|
2316
|
+
var _item$_origin$resourc2, _dateRange$5, _item$duration2, _item$_productOrigin11;
|
|
2082
2317
|
// 如果购物车里已经有同类型的 form_id 的资源了,则不处理
|
|
2083
2318
|
if ((_item$_origin$resourc2 = item._origin.resources) !== null && _item$_origin$resourc2 !== void 0 && _item$_origin$resourc2.some(function (n) {
|
|
2084
2319
|
return n.form_id === targetRenderList[0].form_id;
|
|
@@ -2090,7 +2325,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2090
2325
|
currentCapacity: currentCapacity,
|
|
2091
2326
|
countMap: selectResourcesMap,
|
|
2092
2327
|
targetDate: dateRange === null || dateRange === void 0 || (_dateRange$5 = dateRange[0]) === null || _dateRange$5 === void 0 ? void 0 : _dateRange$5.date,
|
|
2093
|
-
durationMinutes: (item === null || item === void 0 || (_item$duration2 = item.duration) === null || _item$duration2 === void 0 ? void 0 : _item$duration2.value) || (item === null || item === void 0 || (_item$
|
|
2328
|
+
durationMinutes: (item === null || item === void 0 || (_item$duration2 = item.duration) === null || _item$duration2 === void 0 ? void 0 : _item$duration2.value) || (item === null || item === void 0 || (_item$_productOrigin11 = item._productOrigin) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.duration) === null || _item$_productOrigin11 === void 0 ? void 0 : _item$_productOrigin11.value) || 10
|
|
2094
2329
|
});
|
|
2095
2330
|
var targetResource = fastestResource || targetRenderList[0];
|
|
2096
2331
|
targetResource.capacity = currentCapacity;
|
|
@@ -2101,7 +2336,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2101
2336
|
} else {
|
|
2102
2337
|
selectResourcesMap[targetResource.id] += currentCapacity;
|
|
2103
2338
|
}
|
|
2104
|
-
|
|
2339
|
+
_this12.store.cart.updateItem({
|
|
2105
2340
|
_id: item._id,
|
|
2106
2341
|
resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
|
|
2107
2342
|
return existingRes.resourceType !== targetRenderList[0].resourceType;
|
|
@@ -2121,7 +2356,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2121
2356
|
// 如果购物车里没有 holderid数据,证明不按 holder 类流程预约走,给所有购物车一次性分派即可,不做账号下资源互斥逻辑
|
|
2122
2357
|
if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
|
|
2123
2358
|
accountList.forEach(function (account) {
|
|
2124
|
-
var cartItems =
|
|
2359
|
+
var cartItems = _this12.store.cart.getCartByAccount(account.getId());
|
|
2125
2360
|
selectForCartResources(cartItems);
|
|
2126
2361
|
});
|
|
2127
2362
|
} else {
|
|
@@ -2137,7 +2372,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2137
2372
|
value: function getTimeSlotByAllResources(resources_code) {
|
|
2138
2373
|
var _dateRange,
|
|
2139
2374
|
_dateRange2,
|
|
2140
|
-
|
|
2375
|
+
_this13 = this,
|
|
2141
2376
|
_cartItems$,
|
|
2142
2377
|
_cartItems$2,
|
|
2143
2378
|
_this$shopStore$get;
|
|
@@ -2157,8 +2392,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2157
2392
|
var maxCutOffTime = undefined;
|
|
2158
2393
|
var maxCutOffTimeValue = dayjs();
|
|
2159
2394
|
cartItems.forEach(function (item) {
|
|
2160
|
-
var _item$
|
|
2161
|
-
(_item$
|
|
2395
|
+
var _item$_productOrigin12, _item$_productOrigin13, _item$_productOrigin14, _item$_productOrigin15;
|
|
2396
|
+
(_item$_productOrigin12 = item._productOrigin) === null || _item$_productOrigin12 === void 0 || (_item$_productOrigin12 = _item$_productOrigin12.product_resource) === null || _item$_productOrigin12 === void 0 || (_item$_productOrigin12 = _item$_productOrigin12.resources) === null || _item$_productOrigin12 === void 0 || _item$_productOrigin12.forEach(function (n) {
|
|
2162
2397
|
// TODO: 少了个 status 的判断
|
|
2163
2398
|
if (n.code === resources_code) {
|
|
2164
2399
|
resources.push.apply(resources, _toConsumableArray(n.renderList || []));
|
|
@@ -2171,10 +2406,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2171
2406
|
if (item.resource_id && !resourceIds.includes(item.resource_id)) {
|
|
2172
2407
|
resourceIds.push(item.resource_id);
|
|
2173
2408
|
}
|
|
2174
|
-
resourcesTypeId = item === null || item === void 0 || (_item$
|
|
2409
|
+
resourcesTypeId = item === null || item === void 0 || (_item$_productOrigin13 = item._productOrigin) === null || _item$_productOrigin13 === void 0 || (_item$_productOrigin13 = _item$_productOrigin13.product_resource) === null || _item$_productOrigin13 === void 0 || (_item$_productOrigin13 = _item$_productOrigin13.resources) === null || _item$_productOrigin13 === void 0 || (_item$_productOrigin13 = _item$_productOrigin13.find(function (n) {
|
|
2175
2410
|
return n.code === resources_code;
|
|
2176
|
-
})) === null || _item$
|
|
2177
|
-
if ((_item$
|
|
2411
|
+
})) === null || _item$_productOrigin13 === void 0 ? void 0 : _item$_productOrigin13.id;
|
|
2412
|
+
if ((_item$_productOrigin14 = item._productOrigin) !== null && _item$_productOrigin14 !== void 0 && _item$_productOrigin14.cut_off_time && ((_item$_productOrigin15 = item._productOrigin) === null || _item$_productOrigin15 === void 0 ? void 0 : _item$_productOrigin15.cut_off_time.type) === 'advance') {
|
|
2178
2413
|
var currentCutOffTime = dayjs().add(item._productOrigin.cut_off_time.unit, item._productOrigin.cut_off_time.unit_type);
|
|
2179
2414
|
if (currentCutOffTime.isAfter(maxCutOffTimeValue, 'minute')) {
|
|
2180
2415
|
maxCutOffTimeValue = currentCutOffTime;
|
|
@@ -2224,13 +2459,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2224
2459
|
cartItems.forEach(function (item) {
|
|
2225
2460
|
// 单个预约累加账号 多个预约取最大值
|
|
2226
2461
|
if (isSingleResource) {
|
|
2227
|
-
var _item$
|
|
2228
|
-
accountDuration += ((_item$
|
|
2462
|
+
var _item$_productOrigin16;
|
|
2463
|
+
accountDuration += ((_item$_productOrigin16 = item._productOrigin) === null || _item$_productOrigin16 === void 0 || (_item$_productOrigin16 = _item$_productOrigin16.duration) === null || _item$_productOrigin16 === void 0 ? void 0 : _item$_productOrigin16.value) || 10;
|
|
2229
2464
|
} else {
|
|
2230
|
-
var _item$
|
|
2231
|
-
if (accountDuration < (((_item$
|
|
2232
|
-
var _item$
|
|
2233
|
-
accountDuration = ((_item$
|
|
2465
|
+
var _item$_productOrigin17;
|
|
2466
|
+
if (accountDuration < (((_item$_productOrigin17 = item._productOrigin) === null || _item$_productOrigin17 === void 0 || (_item$_productOrigin17 = _item$_productOrigin17.duration) === null || _item$_productOrigin17 === void 0 ? void 0 : _item$_productOrigin17.value) || 10)) {
|
|
2467
|
+
var _item$_productOrigin18;
|
|
2468
|
+
accountDuration = ((_item$_productOrigin18 = item._productOrigin) === null || _item$_productOrigin18 === void 0 || (_item$_productOrigin18 = _item$_productOrigin18.duration) === null || _item$_productOrigin18 === void 0 ? void 0 : _item$_productOrigin18.value) || 10;
|
|
2234
2469
|
}
|
|
2235
2470
|
}
|
|
2236
2471
|
});
|
|
@@ -2240,7 +2475,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2240
2475
|
};
|
|
2241
2476
|
if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
|
|
2242
2477
|
accountList.forEach(function (account) {
|
|
2243
|
-
var cartItems =
|
|
2478
|
+
var cartItems = _this13.store.cart.getCartByAccount(account.getId());
|
|
2244
2479
|
checkDuration(cartItems);
|
|
2245
2480
|
});
|
|
2246
2481
|
} else {
|
|
@@ -2267,8 +2502,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2267
2502
|
}
|
|
2268
2503
|
var resourcesUseableMap = {};
|
|
2269
2504
|
var hasFlexibleDuration = cartItems.some(function (item) {
|
|
2270
|
-
var _item$
|
|
2271
|
-
return ((_item$
|
|
2505
|
+
var _item$_productOrigin19;
|
|
2506
|
+
return ((_item$_productOrigin19 = item._productOrigin) === null || _item$_productOrigin19 === void 0 || (_item$_productOrigin19 = _item$_productOrigin19.duration) === null || _item$_productOrigin19 === void 0 ? void 0 : _item$_productOrigin19.type) === 'flexible';
|
|
2272
2507
|
});
|
|
2273
2508
|
var operating_day_boundary = (_this$shopStore$get = this.shopStore.get('core')) === null || _this$shopStore$get === void 0 || (_this$shopStore$get = _this$shopStore$get.core) === null || _this$shopStore$get === void 0 ? void 0 : _this$shopStore$get.operating_day_boundary;
|
|
2274
2509
|
|
|
@@ -2276,11 +2511,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2276
2511
|
var maxBlockThreshold = 0;
|
|
2277
2512
|
if (hasFlexibleDuration) {
|
|
2278
2513
|
maxBlockThreshold = cartItems.reduce(function (max, item) {
|
|
2279
|
-
var _item$
|
|
2514
|
+
var _item$_productOrigin20;
|
|
2280
2515
|
// 如果开启了灵活时长商品配置,则取 block_threshold 的值
|
|
2281
|
-
if ((_item$
|
|
2282
|
-
var _item$
|
|
2283
|
-
return Math.max(max, ((_item$
|
|
2516
|
+
if ((_item$_productOrigin20 = item._productOrigin) !== null && _item$_productOrigin20 !== void 0 && (_item$_productOrigin20 = _item$_productOrigin20.duration) !== null && _item$_productOrigin20 !== void 0 && (_item$_productOrigin20 = _item$_productOrigin20.flexible_config) !== null && _item$_productOrigin20 !== void 0 && _item$_productOrigin20.is_enable_minimum_duration) {
|
|
2517
|
+
var _item$_productOrigin21;
|
|
2518
|
+
return Math.max(max, ((_item$_productOrigin21 = item._productOrigin) === null || _item$_productOrigin21 === void 0 || (_item$_productOrigin21 = _item$_productOrigin21.duration) === null || _item$_productOrigin21 === void 0 || (_item$_productOrigin21 = _item$_productOrigin21.flexible_config) === null || _item$_productOrigin21 === void 0 ? void 0 : _item$_productOrigin21.block_threshold) || 0);
|
|
2284
2519
|
}
|
|
2285
2520
|
return 0;
|
|
2286
2521
|
}, 0);
|
|
@@ -2311,7 +2546,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2311
2546
|
var maxCapacity = 1;
|
|
2312
2547
|
if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
|
|
2313
2548
|
accountList.forEach(function (account) {
|
|
2314
|
-
var accountCartItems =
|
|
2549
|
+
var accountCartItems = _this13.store.cart.getCartByAccount(account.getId());
|
|
2315
2550
|
var currentCapacity = calculateCapacityFromCartItems(accountCartItems);
|
|
2316
2551
|
if (currentCapacity > maxCapacity) {
|
|
2317
2552
|
maxCapacity = currentCapacity;
|
|
@@ -2339,22 +2574,22 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2339
2574
|
}, {
|
|
2340
2575
|
key: "getTimeSlotByAllResourcesForDate",
|
|
2341
2576
|
value: function () {
|
|
2342
|
-
var _getTimeSlotByAllResourcesForDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2343
|
-
var
|
|
2577
|
+
var _getTimeSlotByAllResourcesForDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(_ref11) {
|
|
2578
|
+
var _this14 = this,
|
|
2344
2579
|
_cartItems$5,
|
|
2345
2580
|
_cartItems$6,
|
|
2346
2581
|
_this$shopStore$get2;
|
|
2347
2582
|
var resources_code, startDate, endDate, resources, cartItems, resourceIds, resourcesTypeId, isSingleResource, maxCutOffTime, maxCutOffTimeValue, duration, accountList, checkDuration, resourcesUseableMap, hasFlexibleDuration, operating_day_boundary, maxBlockThreshold, calculateCapacityFromCartItems, maxCapacity, arr, today, _loop2, i;
|
|
2348
|
-
return _regeneratorRuntime().wrap(function
|
|
2349
|
-
while (1) switch (
|
|
2583
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context27) {
|
|
2584
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
2350
2585
|
case 0:
|
|
2351
|
-
resources_code =
|
|
2586
|
+
resources_code = _ref11.resources_code, startDate = _ref11.startDate, endDate = _ref11.endDate;
|
|
2352
2587
|
// 如果 end_date 距离start_date小于 30 天,自动追加 end_date 为今天往后的 30 天
|
|
2353
2588
|
if (dayjs(endDate).diff(dayjs(startDate), 'day') < 30) {
|
|
2354
2589
|
endDate = dayjs(startDate).add(30, 'day').format('YYYY-MM-DD');
|
|
2355
2590
|
}
|
|
2356
2591
|
// 预请求资源数据,防止日期超过之前选择的范围
|
|
2357
|
-
|
|
2592
|
+
_context27.next = 4;
|
|
2358
2593
|
return this.getAvailableDate({
|
|
2359
2594
|
startDate: startDate,
|
|
2360
2595
|
endDate: endDate,
|
|
@@ -2372,8 +2607,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2372
2607
|
maxCutOffTime = undefined;
|
|
2373
2608
|
maxCutOffTimeValue = dayjs();
|
|
2374
2609
|
cartItems.forEach(function (item) {
|
|
2375
|
-
var _item$
|
|
2376
|
-
(_item$
|
|
2610
|
+
var _item$_productOrigin22, _item$_productOrigin23, _item$_productOrigin24, _item$_productOrigin25;
|
|
2611
|
+
(_item$_productOrigin22 = item._productOrigin) === null || _item$_productOrigin22 === void 0 || (_item$_productOrigin22 = _item$_productOrigin22.product_resource) === null || _item$_productOrigin22 === void 0 || (_item$_productOrigin22 = _item$_productOrigin22.resources) === null || _item$_productOrigin22 === void 0 || _item$_productOrigin22.forEach(function (n) {
|
|
2377
2612
|
// TODO: 少了个 status 的判断
|
|
2378
2613
|
if (n.code === resources_code) {
|
|
2379
2614
|
resources.push.apply(resources, _toConsumableArray(n.renderList || []));
|
|
@@ -2386,10 +2621,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2386
2621
|
if (item.resource_id && !resourceIds.includes(item.resource_id)) {
|
|
2387
2622
|
resourceIds.push(item.resource_id);
|
|
2388
2623
|
}
|
|
2389
|
-
resourcesTypeId = item === null || item === void 0 || (_item$
|
|
2624
|
+
resourcesTypeId = item === null || item === void 0 || (_item$_productOrigin23 = item._productOrigin) === null || _item$_productOrigin23 === void 0 || (_item$_productOrigin23 = _item$_productOrigin23.product_resource) === null || _item$_productOrigin23 === void 0 || (_item$_productOrigin23 = _item$_productOrigin23.resources) === null || _item$_productOrigin23 === void 0 || (_item$_productOrigin23 = _item$_productOrigin23.find(function (n) {
|
|
2390
2625
|
return n.code === resources_code;
|
|
2391
|
-
})) === null || _item$
|
|
2392
|
-
if ((_item$
|
|
2626
|
+
})) === null || _item$_productOrigin23 === void 0 ? void 0 : _item$_productOrigin23.id;
|
|
2627
|
+
if ((_item$_productOrigin24 = item._productOrigin) !== null && _item$_productOrigin24 !== void 0 && _item$_productOrigin24.cut_off_time && ((_item$_productOrigin25 = item._productOrigin) === null || _item$_productOrigin25 === void 0 ? void 0 : _item$_productOrigin25.cut_off_time.type) === 'advance') {
|
|
2393
2628
|
var currentCutOffTime = dayjs().add(item._productOrigin.cut_off_time.unit, item._productOrigin.cut_off_time.unit_type);
|
|
2394
2629
|
if (currentCutOffTime.isAfter(maxCutOffTimeValue, 'minute')) {
|
|
2395
2630
|
maxCutOffTimeValue = currentCutOffTime;
|
|
@@ -2400,10 +2635,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2400
2635
|
|
|
2401
2636
|
// 保护: 如果 resources 为空则直接 return
|
|
2402
2637
|
if (resources.length) {
|
|
2403
|
-
|
|
2638
|
+
_context27.next = 14;
|
|
2404
2639
|
break;
|
|
2405
2640
|
}
|
|
2406
|
-
return
|
|
2641
|
+
return _context27.abrupt("return", []);
|
|
2407
2642
|
case 14:
|
|
2408
2643
|
duration = 0; // duration = 不同账号的最长时间
|
|
2409
2644
|
accountList = this.store.accountList.getAccounts();
|
|
@@ -2412,13 +2647,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2412
2647
|
cartItems.forEach(function (item) {
|
|
2413
2648
|
// 单个预约累加账号 多个预约取最大值
|
|
2414
2649
|
if (isSingleResource) {
|
|
2415
|
-
var _item$
|
|
2416
|
-
accountDuration += ((_item$
|
|
2650
|
+
var _item$_productOrigin26;
|
|
2651
|
+
accountDuration += ((_item$_productOrigin26 = item._productOrigin) === null || _item$_productOrigin26 === void 0 || (_item$_productOrigin26 = _item$_productOrigin26.duration) === null || _item$_productOrigin26 === void 0 ? void 0 : _item$_productOrigin26.value) || 10;
|
|
2417
2652
|
} else {
|
|
2418
|
-
var _item$
|
|
2419
|
-
if (accountDuration < (((_item$
|
|
2420
|
-
var _item$
|
|
2421
|
-
accountDuration = ((_item$
|
|
2653
|
+
var _item$_productOrigin27;
|
|
2654
|
+
if (accountDuration < (((_item$_productOrigin27 = item._productOrigin) === null || _item$_productOrigin27 === void 0 || (_item$_productOrigin27 = _item$_productOrigin27.duration) === null || _item$_productOrigin27 === void 0 ? void 0 : _item$_productOrigin27.value) || 10)) {
|
|
2655
|
+
var _item$_productOrigin28;
|
|
2656
|
+
accountDuration = ((_item$_productOrigin28 = item._productOrigin) === null || _item$_productOrigin28 === void 0 || (_item$_productOrigin28 = _item$_productOrigin28.duration) === null || _item$_productOrigin28 === void 0 ? void 0 : _item$_productOrigin28.value) || 10;
|
|
2422
2657
|
}
|
|
2423
2658
|
}
|
|
2424
2659
|
});
|
|
@@ -2428,7 +2663,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2428
2663
|
};
|
|
2429
2664
|
if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
|
|
2430
2665
|
accountList.forEach(function (account) {
|
|
2431
|
-
var cartItems =
|
|
2666
|
+
var cartItems = _this14.store.cart.getCartByAccount(account.getId());
|
|
2432
2667
|
checkDuration(cartItems);
|
|
2433
2668
|
});
|
|
2434
2669
|
} else {
|
|
@@ -2437,25 +2672,25 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2437
2672
|
// 如果 cartItem 上既没有时间,也没有资源,认为外部属于异常调用,直接丢一个空数组出去
|
|
2438
2673
|
// 同时 session 类商品的流程也不应该调用这个方法
|
|
2439
2674
|
if (!(!(cartItems !== null && cartItems !== void 0 && (_cartItems$5 = cartItems[0]) !== null && _cartItems$5 !== void 0 && _cartItems$5.start_date) && !(cartItems !== null && cartItems !== void 0 && (_cartItems$6 = cartItems[0]) !== null && _cartItems$6 !== void 0 && _cartItems$6.resource_id) || !(cartItems !== null && cartItems !== void 0 && cartItems[0].duration))) {
|
|
2440
|
-
|
|
2675
|
+
_context27.next = 20;
|
|
2441
2676
|
break;
|
|
2442
2677
|
}
|
|
2443
|
-
return
|
|
2678
|
+
return _context27.abrupt("return", []);
|
|
2444
2679
|
case 20:
|
|
2445
2680
|
resourcesUseableMap = {};
|
|
2446
2681
|
hasFlexibleDuration = cartItems.some(function (item) {
|
|
2447
|
-
var _item$
|
|
2448
|
-
return ((_item$
|
|
2682
|
+
var _item$_productOrigin29;
|
|
2683
|
+
return ((_item$_productOrigin29 = item._productOrigin) === null || _item$_productOrigin29 === void 0 || (_item$_productOrigin29 = _item$_productOrigin29.duration) === null || _item$_productOrigin29 === void 0 ? void 0 : _item$_productOrigin29.type) === 'flexible';
|
|
2449
2684
|
});
|
|
2450
2685
|
operating_day_boundary = (_this$shopStore$get2 = this.shopStore.get('core')) === null || _this$shopStore$get2 === void 0 || (_this$shopStore$get2 = _this$shopStore$get2.core) === null || _this$shopStore$get2 === void 0 ? void 0 : _this$shopStore$get2.operating_day_boundary; // 如果有 hasFlexibleDuration,需要把动态时长商品(可能是多个,取最长的那个最低禁止购买时长)的最低禁止购买时长作为 split 的值
|
|
2451
2686
|
maxBlockThreshold = 0;
|
|
2452
2687
|
if (hasFlexibleDuration) {
|
|
2453
2688
|
maxBlockThreshold = cartItems.reduce(function (max, item) {
|
|
2454
|
-
var _item$
|
|
2689
|
+
var _item$_productOrigin30;
|
|
2455
2690
|
// 如果开启了灵活时长商品配置,则取 block_threshold 的值
|
|
2456
|
-
if ((_item$
|
|
2457
|
-
var _item$
|
|
2458
|
-
return Math.max(max, ((_item$
|
|
2691
|
+
if ((_item$_productOrigin30 = item._productOrigin) !== null && _item$_productOrigin30 !== void 0 && (_item$_productOrigin30 = _item$_productOrigin30.duration) !== null && _item$_productOrigin30 !== void 0 && (_item$_productOrigin30 = _item$_productOrigin30.flexible_config) !== null && _item$_productOrigin30 !== void 0 && _item$_productOrigin30.is_enable_minimum_duration) {
|
|
2692
|
+
var _item$_productOrigin31;
|
|
2693
|
+
return Math.max(max, ((_item$_productOrigin31 = item._productOrigin) === null || _item$_productOrigin31 === void 0 || (_item$_productOrigin31 = _item$_productOrigin31.duration) === null || _item$_productOrigin31 === void 0 || (_item$_productOrigin31 = _item$_productOrigin31.flexible_config) === null || _item$_productOrigin31 === void 0 ? void 0 : _item$_productOrigin31.block_threshold) || 0);
|
|
2459
2694
|
}
|
|
2460
2695
|
return 0;
|
|
2461
2696
|
}, 0);
|
|
@@ -2481,7 +2716,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2481
2716
|
maxCapacity = 1;
|
|
2482
2717
|
if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
|
|
2483
2718
|
accountList.forEach(function (account) {
|
|
2484
|
-
var accountCartItems =
|
|
2719
|
+
var accountCartItems = _this14.store.cart.getCartByAccount(account.getId());
|
|
2485
2720
|
var currentCapacity = calculateCapacityFromCartItems(accountCartItems);
|
|
2486
2721
|
if (currentCapacity > maxCapacity) {
|
|
2487
2722
|
maxCapacity = currentCapacity;
|
|
@@ -2494,11 +2729,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2494
2729
|
today = dayjs().startOf('day'); // 计算 start_date 到 end_date 之间的所有日期,遍历他们并且计算每一天的可用
|
|
2495
2730
|
_loop2 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop2() {
|
|
2496
2731
|
var currentDate, theDateResources, resourcesMap, timeSlots;
|
|
2497
|
-
return _regeneratorRuntime().wrap(function _loop2$(
|
|
2498
|
-
while (1) switch (
|
|
2732
|
+
return _regeneratorRuntime().wrap(function _loop2$(_context26) {
|
|
2733
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
2499
2734
|
case 0:
|
|
2500
2735
|
currentDate = i.format('YYYY-MM-DD');
|
|
2501
|
-
theDateResources =
|
|
2736
|
+
theDateResources = _this14.store.date.getResourcesListByDate(currentDate);
|
|
2502
2737
|
resources.forEach(function (item) {
|
|
2503
2738
|
var _theDateResources$fin2;
|
|
2504
2739
|
item.times = (theDateResources === null || theDateResources === void 0 || (_theDateResources$fin2 = theDateResources.find(function (n) {
|
|
@@ -2507,7 +2742,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2507
2742
|
});
|
|
2508
2743
|
resourcesMap = getResourcesMap(resources); // 如果日期已经过期则直接标记为不可用
|
|
2509
2744
|
if (!i.isBefore(today)) {
|
|
2510
|
-
|
|
2745
|
+
_context26.next = 7;
|
|
2511
2746
|
break;
|
|
2512
2747
|
}
|
|
2513
2748
|
arr.push({
|
|
@@ -2516,7 +2751,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2516
2751
|
week: i.format('ddd'),
|
|
2517
2752
|
weekNum: i.day()
|
|
2518
2753
|
});
|
|
2519
|
-
return
|
|
2754
|
+
return _context26.abrupt("return", 1);
|
|
2520
2755
|
case 7:
|
|
2521
2756
|
timeSlots = getTimeSlicesByResources({
|
|
2522
2757
|
resourceIds: resourceIds,
|
|
@@ -2548,34 +2783,34 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2548
2783
|
}
|
|
2549
2784
|
case 9:
|
|
2550
2785
|
case "end":
|
|
2551
|
-
return
|
|
2786
|
+
return _context26.stop();
|
|
2552
2787
|
}
|
|
2553
2788
|
}, _loop2);
|
|
2554
2789
|
});
|
|
2555
2790
|
i = dayjs(startDate);
|
|
2556
2791
|
case 32:
|
|
2557
2792
|
if (!i.isBefore(dayjs(endDate))) {
|
|
2558
|
-
|
|
2793
|
+
_context27.next = 39;
|
|
2559
2794
|
break;
|
|
2560
2795
|
}
|
|
2561
|
-
return
|
|
2796
|
+
return _context27.delegateYield(_loop2(), "t0", 34);
|
|
2562
2797
|
case 34:
|
|
2563
|
-
if (!
|
|
2564
|
-
|
|
2798
|
+
if (!_context27.t0) {
|
|
2799
|
+
_context27.next = 36;
|
|
2565
2800
|
break;
|
|
2566
2801
|
}
|
|
2567
|
-
return
|
|
2802
|
+
return _context27.abrupt("continue", 36);
|
|
2568
2803
|
case 36:
|
|
2569
2804
|
i = i.add(1, 'day');
|
|
2570
|
-
|
|
2805
|
+
_context27.next = 32;
|
|
2571
2806
|
break;
|
|
2572
2807
|
case 39:
|
|
2573
|
-
return
|
|
2808
|
+
return _context27.abrupt("return", arr);
|
|
2574
2809
|
case 40:
|
|
2575
2810
|
case "end":
|
|
2576
|
-
return
|
|
2811
|
+
return _context27.stop();
|
|
2577
2812
|
}
|
|
2578
|
-
},
|
|
2813
|
+
}, _callee26, this);
|
|
2579
2814
|
}));
|
|
2580
2815
|
function getTimeSlotByAllResourcesForDate(_x20) {
|
|
2581
2816
|
return _getTimeSlotByAllResourcesForDate.apply(this, arguments);
|
|
@@ -2586,7 +2821,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2586
2821
|
key: "submitTimeSlot",
|
|
2587
2822
|
value: function submitTimeSlot(timeSlots) {
|
|
2588
2823
|
var _this$shopStore$get3,
|
|
2589
|
-
|
|
2824
|
+
_this15 = this;
|
|
2590
2825
|
// 以账号为维度处理数据。购物车里每一项的 startTime应该是前一个商品的 endTime,如果是第一个商品则用 timeSlots.start_at
|
|
2591
2826
|
var cartItems = this.store.cart.getItems().filter(function (n) {
|
|
2592
2827
|
return !isNormalProduct(n._productOrigin);
|
|
@@ -2616,10 +2851,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2616
2851
|
var osWarnTips = [];
|
|
2617
2852
|
var newResources = cloneDeep(item._origin.resources);
|
|
2618
2853
|
newResources.forEach(function (resource) {
|
|
2619
|
-
var _item$
|
|
2854
|
+
var _item$_productOrigin32;
|
|
2620
2855
|
// 如果商品配置的是灵活时长,开始时间设置为提交的时间,结束时间从资源的可用最晚时间和店铺营业结束时间里取一个最早的
|
|
2621
|
-
if (((_item$
|
|
2622
|
-
var _allResources$find, _item$
|
|
2856
|
+
if (((_item$_productOrigin32 = item._productOrigin) === null || _item$_productOrigin32 === void 0 || (_item$_productOrigin32 = _item$_productOrigin32.duration) === null || _item$_productOrigin32 === void 0 ? void 0 : _item$_productOrigin32.type) === 'flexible') {
|
|
2857
|
+
var _allResources$find, _item$_productOrigin33, _item$_productOrigin34;
|
|
2623
2858
|
item.duration = {
|
|
2624
2859
|
type: 'minutes',
|
|
2625
2860
|
value: 10
|
|
@@ -2631,10 +2866,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2631
2866
|
})) === null || _allResources$find === void 0 ? void 0 : _allResources$find.times;
|
|
2632
2867
|
// 找到最晚的 end_at 还没用,因为可能存在资源工作时间是 10:00-19:00,但是资源的 times 里有 16:30-19:00 被 block 的情况
|
|
2633
2868
|
// 所以还需要排除掉 block 时间
|
|
2634
|
-
function getEarliestBlockedStartTime(
|
|
2869
|
+
function getEarliestBlockedStartTime(_ref12) {
|
|
2635
2870
|
var _earliestBlockStart;
|
|
2636
|
-
var currentStartTime =
|
|
2637
|
-
times =
|
|
2871
|
+
var currentStartTime = _ref12.currentStartTime,
|
|
2872
|
+
times = _ref12.times;
|
|
2638
2873
|
var currentStart = dayjs(currentStartTime);
|
|
2639
2874
|
var earliestBlockStart;
|
|
2640
2875
|
var _iterator3 = _createForOfIteratorHelper(times || []),
|
|
@@ -2702,19 +2937,19 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2702
2937
|
resource.endTime = formattedEndTime.format('YYYY-MM-DD HH:mm');
|
|
2703
2938
|
// 如果是动态时长商品,并且当前选择的时间的结束时间小于了最低提示时长(warningThreshold),则追加一个提示
|
|
2704
2939
|
// 如果currentStartTime + warningThreshold 大于 currentEndTime,且 osWarnTips 没有pisell2.product.card.closing-soon.warning 这一项,则加入这一项
|
|
2705
|
-
if ((_item$
|
|
2940
|
+
if ((_item$_productOrigin33 = item._productOrigin) !== null && _item$_productOrigin33 !== void 0 && (_item$_productOrigin33 = _item$_productOrigin33.duration) !== null && _item$_productOrigin33 !== void 0 && (_item$_productOrigin33 = _item$_productOrigin33.flexible_config) !== null && _item$_productOrigin33 !== void 0 && _item$_productOrigin33.is_enable_minimum_duration && dayjs(currentStartTime).add(((_item$_productOrigin34 = item._productOrigin) === null || _item$_productOrigin34 === void 0 || (_item$_productOrigin34 = _item$_productOrigin34.duration) === null || _item$_productOrigin34 === void 0 || (_item$_productOrigin34 = _item$_productOrigin34.flexible_config) === null || _item$_productOrigin34 === void 0 ? void 0 : _item$_productOrigin34.warning_threshold) || 0, 'minutes').isAfter(dayjs(formattedEndTime))) {
|
|
2706
2941
|
if (!osWarnTips.includes('pisell2.product.card.closing-soon.warning')) {
|
|
2707
2942
|
osWarnTips.push('pisell2.product.card.closing-soon.warning');
|
|
2708
2943
|
}
|
|
2709
2944
|
}
|
|
2710
2945
|
} else {
|
|
2711
|
-
var _item$
|
|
2946
|
+
var _item$_productOrigin35;
|
|
2712
2947
|
resource.startTime = currentStartTime;
|
|
2713
|
-
resource.endTime = dayjs(currentStartTime).add(((_item$
|
|
2948
|
+
resource.endTime = dayjs(currentStartTime).add(((_item$_productOrigin35 = item._productOrigin) === null || _item$_productOrigin35 === void 0 || (_item$_productOrigin35 = _item$_productOrigin35.duration) === null || _item$_productOrigin35 === void 0 ? void 0 : _item$_productOrigin35.value) || 10, 'minutes').format('YYYY-MM-DD HH:mm');
|
|
2714
2949
|
}
|
|
2715
2950
|
// delete resource.times;
|
|
2716
2951
|
});
|
|
2717
|
-
|
|
2952
|
+
_this15.store.cart.updateItem({
|
|
2718
2953
|
_id: item._id,
|
|
2719
2954
|
resources: newResources,
|
|
2720
2955
|
osWarnTips: osWarnTips
|
|
@@ -2758,43 +2993,78 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2758
2993
|
}, {
|
|
2759
2994
|
key: "openProductDetail",
|
|
2760
2995
|
value: function () {
|
|
2761
|
-
var _openProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2762
|
-
var targetProductData, newScheduleArr, dateRange;
|
|
2763
|
-
return _regeneratorRuntime().wrap(function
|
|
2764
|
-
while (1) switch (
|
|
2996
|
+
var _openProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(productId) {
|
|
2997
|
+
var generation, targetProductData, _targetProductData, newScheduleArr, dateRange;
|
|
2998
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context28) {
|
|
2999
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
2765
3000
|
case 0:
|
|
2766
|
-
|
|
3001
|
+
generation = ++this.productDetailGeneration;
|
|
3002
|
+
_context28.prev = 1;
|
|
3003
|
+
_context28.next = 4;
|
|
2767
3004
|
return this.store.products.getProduct(productId);
|
|
2768
|
-
case
|
|
2769
|
-
targetProductData =
|
|
3005
|
+
case 4:
|
|
3006
|
+
targetProductData = _context28.sent;
|
|
3007
|
+
if (!((_targetProductData = targetProductData) !== null && _targetProductData !== void 0 && (_targetProductData = _targetProductData['schedule.ids']) !== null && _targetProductData !== void 0 && _targetProductData.length)) {
|
|
3008
|
+
_context28.next = 8;
|
|
3009
|
+
break;
|
|
3010
|
+
}
|
|
3011
|
+
_context28.next = 8;
|
|
3012
|
+
return this.store.schedule.ensureScheduleReady();
|
|
3013
|
+
case 8:
|
|
3014
|
+
_context28.next = 15;
|
|
3015
|
+
break;
|
|
3016
|
+
case 10:
|
|
3017
|
+
_context28.prev = 10;
|
|
3018
|
+
_context28.t0 = _context28["catch"](1);
|
|
3019
|
+
if (!(this.disposed || generation !== this.productDetailGeneration)) {
|
|
3020
|
+
_context28.next = 14;
|
|
3021
|
+
break;
|
|
3022
|
+
}
|
|
3023
|
+
throw this.staleSelection();
|
|
3024
|
+
case 14:
|
|
3025
|
+
throw _context28.t0;
|
|
3026
|
+
case 15:
|
|
3027
|
+
if (!(this.disposed || generation !== this.productDetailGeneration)) {
|
|
3028
|
+
_context28.next = 17;
|
|
3029
|
+
break;
|
|
3030
|
+
}
|
|
3031
|
+
throw this.staleSelection();
|
|
3032
|
+
case 17:
|
|
3033
|
+
if (targetProductData) {
|
|
3034
|
+
_context28.next = 19;
|
|
3035
|
+
break;
|
|
3036
|
+
}
|
|
3037
|
+
throw new Error('Booking product is unavailable');
|
|
3038
|
+
case 19:
|
|
2770
3039
|
if (!targetProductData) {
|
|
2771
|
-
|
|
3040
|
+
_context28.next = 34;
|
|
2772
3041
|
break;
|
|
2773
3042
|
}
|
|
2774
3043
|
this.store.currentProduct = targetProductData;
|
|
2775
3044
|
this.store.currentProductMeta = {};
|
|
2776
3045
|
// 资源预加载,如果是 duration 类型的商品,且是先选日期的流程,在这里预拉取资源数据
|
|
2777
3046
|
if (!targetProductData['schedule.ids']) {
|
|
2778
|
-
|
|
3047
|
+
_context28.next = 29;
|
|
2779
3048
|
break;
|
|
2780
3049
|
}
|
|
2781
3050
|
newScheduleArr = this.getScheduleDataByIds(targetProductData['schedule.ids']);
|
|
2782
3051
|
if (!this.store.currentProductMeta) this.store.currentProductMeta = {};
|
|
2783
3052
|
this.store.currentProductMeta.schedule = newScheduleArr;
|
|
2784
|
-
|
|
3053
|
+
this.store.currentProductMeta.scheduleCatalogVersion = this.store.schedule.getScheduleCatalogVersion();
|
|
3054
|
+
_context28.next = 34;
|
|
2785
3055
|
break;
|
|
2786
|
-
case
|
|
3056
|
+
case 29:
|
|
2787
3057
|
if (!targetProductData.duration) {
|
|
2788
|
-
|
|
3058
|
+
_context28.next = 34;
|
|
2789
3059
|
break;
|
|
2790
3060
|
}
|
|
2791
3061
|
dateRange = this.store.date.getDateRange(); // 如果不是先选日期的流程 duration 商品就啥也不做
|
|
2792
3062
|
if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
|
|
2793
|
-
|
|
3063
|
+
_context28.next = 33;
|
|
2794
3064
|
break;
|
|
2795
3065
|
}
|
|
2796
|
-
return
|
|
2797
|
-
case
|
|
3066
|
+
return _context28.abrupt("return");
|
|
3067
|
+
case 33:
|
|
2798
3068
|
// this.store.date.getResourceDates({
|
|
2799
3069
|
// query: {
|
|
2800
3070
|
// start_date: dateRange[0].date,
|
|
@@ -2806,12 +3076,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2806
3076
|
startDate: dateRange[0].date,
|
|
2807
3077
|
endDate: dateRange[dateRange.length - 1].date,
|
|
2808
3078
|
products: [targetProductData]
|
|
3079
|
+
}).catch(function (error) {
|
|
3080
|
+
if ((error === null || error === void 0 ? void 0 : error.name) !== 'AbortError') console.error('[BookingByStep] Product resource preload failed', error);
|
|
2809
3081
|
});
|
|
2810
|
-
case
|
|
3082
|
+
case 34:
|
|
2811
3083
|
case "end":
|
|
2812
|
-
return
|
|
3084
|
+
return _context28.stop();
|
|
2813
3085
|
}
|
|
2814
|
-
},
|
|
3086
|
+
}, _callee27, this, [[1, 10]]);
|
|
2815
3087
|
}));
|
|
2816
3088
|
function openProductDetail(_x21) {
|
|
2817
3089
|
return _openProductDetail.apply(this, arguments);
|
|
@@ -2821,23 +3093,22 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2821
3093
|
}, {
|
|
2822
3094
|
key: "closeProductDetail",
|
|
2823
3095
|
value: function closeProductDetail() {
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
}
|
|
3096
|
+
this.productDetailGeneration += 1;
|
|
3097
|
+
this.store.currentProductMeta = {};
|
|
2827
3098
|
this.store.currentProduct = undefined;
|
|
2828
3099
|
}
|
|
2829
3100
|
|
|
2830
3101
|
// 通过商品和 schedule 来获取视频可用的时间片、时间片内资源可用的数据
|
|
2831
3102
|
}, {
|
|
2832
3103
|
key: "getTimeslotBySchedule",
|
|
2833
|
-
value: function getTimeslotBySchedule(
|
|
2834
|
-
var _this$store$
|
|
3104
|
+
value: function getTimeslotBySchedule(_ref13) {
|
|
3105
|
+
var _this$store$currentPr3,
|
|
2835
3106
|
_targetProductData$pr,
|
|
2836
|
-
|
|
2837
|
-
var date =
|
|
2838
|
-
scheduleIds =
|
|
2839
|
-
resources =
|
|
2840
|
-
product =
|
|
3107
|
+
_this16 = this;
|
|
3108
|
+
var date = _ref13.date,
|
|
3109
|
+
scheduleIds = _ref13.scheduleIds,
|
|
3110
|
+
resources = _ref13.resources,
|
|
3111
|
+
product = _ref13.product;
|
|
2841
3112
|
var targetProduct = this.store.currentProduct;
|
|
2842
3113
|
// 如果外面传递了product 优先用外面的
|
|
2843
3114
|
var targetProductData = product || targetProduct;
|
|
@@ -2855,7 +3126,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2855
3126
|
var cartItems = cloneDeep(this.store.cart.getItems());
|
|
2856
3127
|
var resourcesMap = getResourcesMap((targetResourceDate === null || targetResourceDate === void 0 ? void 0 : targetResourceDate.resource) || []);
|
|
2857
3128
|
var selectedResources = getOthersSelectedResources(cartItems, '', resourcesMap);
|
|
2858
|
-
var productResources = getResourcesByProduct(resourcesMap, resources || ((_this$store$
|
|
3129
|
+
var productResources = getResourcesByProduct(resourcesMap, resources || ((_this$store$currentPr3 = this.store.currentProduct) === null || _this$store$currentPr3 === void 0 || (_this$store$currentPr3 = _this$store$currentPr3.product_resource) === null || _this$store$currentPr3 === void 0 ? void 0 : _this$store$currentPr3.resources) || [], selectedResources, 1);
|
|
2859
3130
|
var minTimeMaxTime = calcMinTimeMaxTimeBySchedules(targetSchedules, {}, date);
|
|
2860
3131
|
var scheduleTimeSlots = getAllSortedDateRanges(minTimeMaxTime);
|
|
2861
3132
|
// 当前所有待选择资源的集合,先提出来,提升性能
|
|
@@ -2973,7 +3244,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2973
3244
|
statsByResourceType[m.form_id] = currentStats;
|
|
2974
3245
|
});
|
|
2975
3246
|
// 容量检测
|
|
2976
|
-
var cartItems =
|
|
3247
|
+
var cartItems = _this16.store.cart.getItems();
|
|
2977
3248
|
productResources.forEach(function (n) {
|
|
2978
3249
|
var currentResourceTypeConfig = resourceTypeConfigById.get(n.id);
|
|
2979
3250
|
if (!currentResourceTypeConfig) return;
|
|
@@ -3019,7 +3290,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3019
3290
|
});
|
|
3020
3291
|
});
|
|
3021
3292
|
// 先确定是否每一个currentResourcesSet在这个时间点的 event_list 都是空的,如果不是空的还需要把他踢出currentResourcesSet
|
|
3022
|
-
var currentDataResources =
|
|
3293
|
+
var currentDataResources = _this16.store.date.getResourcesListByDate(dayjs(item.start).format('YYYY-MM-DD'));
|
|
3023
3294
|
currentDataResources === null || currentDataResources === void 0 || currentDataResources.forEach(function (m) {
|
|
3024
3295
|
if (currentResourcesSet.has(m.id)) {
|
|
3025
3296
|
var mTimes = m.times.filter(function (n) {
|
|
@@ -3104,13 +3375,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3104
3375
|
end_at: dayjs(item.end)
|
|
3105
3376
|
})) {
|
|
3106
3377
|
var _m$pax;
|
|
3107
|
-
mSet.set(m.id, (
|
|
3378
|
+
mSet.set(m.id, _objectSpread(_objectSpread({}, m), {}, {
|
|
3379
|
+
pax: (_m$pax = m.pax) !== null && _m$pax !== void 0 ? _m$pax : 1
|
|
3380
|
+
}));
|
|
3108
3381
|
}
|
|
3109
3382
|
});
|
|
3110
3383
|
});
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3384
|
+
var peakUsedCapacity = getPeakConcurrentPax(Array.from(mSet.values()), {
|
|
3385
|
+
start_at: dayjs(item.start),
|
|
3386
|
+
end_at: dayjs(item.end)
|
|
3387
|
+
});
|
|
3388
|
+
// 单个资源的超额占用不能扣减其他资源的可用容量。
|
|
3389
|
+
acc += Math.min(curr.capacity, peakUsedCapacity);
|
|
3114
3390
|
return acc;
|
|
3115
3391
|
}, 0);
|
|
3116
3392
|
// 如果已使用容量超过了当前类型资源的容量,则不可用
|
|
@@ -3238,7 +3514,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3238
3514
|
}, {
|
|
3239
3515
|
key: "checkMaxDurationCapacity",
|
|
3240
3516
|
value: function checkMaxDurationCapacity() {
|
|
3241
|
-
var
|
|
3517
|
+
var _this17 = this;
|
|
3242
3518
|
var cartItems = this.store.cart.getItems().filter(function (item) {
|
|
3243
3519
|
return !isNormalProduct(item._productOrigin);
|
|
3244
3520
|
});
|
|
@@ -3439,7 +3715,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3439
3715
|
// 为通过检测的商品分配一个公共可用时间段
|
|
3440
3716
|
|
|
3441
3717
|
// 找到所有资源都可用的时间段
|
|
3442
|
-
var commonTimeSlots =
|
|
3718
|
+
var commonTimeSlots = _this17.findCommonAvailableTimeSlots(resourcesOfThisType);
|
|
3443
3719
|
if (commonTimeSlots.length === 0) {
|
|
3444
3720
|
return {
|
|
3445
3721
|
v: {
|
|
@@ -3529,8 +3805,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3529
3805
|
var resourcesIdSet = new Set();
|
|
3530
3806
|
|
|
3531
3807
|
// 获取资源数据
|
|
3532
|
-
var dateRange =
|
|
3533
|
-
var resourcesDates =
|
|
3808
|
+
var dateRange = _this17.store.date.getDateRange();
|
|
3809
|
+
var resourcesDates = _this17.store.date.getDateList();
|
|
3534
3810
|
var targetResourceDate = resourcesDates.find(function (n) {
|
|
3535
3811
|
return n.date === startDate;
|
|
3536
3812
|
});
|
|
@@ -3586,17 +3862,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3586
3862
|
*/
|
|
3587
3863
|
}, {
|
|
3588
3864
|
key: "convertProductToCartItem",
|
|
3589
|
-
value: function convertProductToCartItem(
|
|
3590
|
-
var product =
|
|
3591
|
-
date =
|
|
3592
|
-
account =
|
|
3593
|
-
var
|
|
3594
|
-
bundle =
|
|
3595
|
-
options =
|
|
3596
|
-
origin =
|
|
3597
|
-
product_variant_id =
|
|
3598
|
-
|
|
3599
|
-
quantity =
|
|
3865
|
+
value: function convertProductToCartItem(_ref14) {
|
|
3866
|
+
var product = _ref14.product,
|
|
3867
|
+
date = _ref14.date,
|
|
3868
|
+
account = _ref14.account;
|
|
3869
|
+
var _ref15 = product || {},
|
|
3870
|
+
bundle = _ref15.bundle,
|
|
3871
|
+
options = _ref15.options,
|
|
3872
|
+
origin = _ref15.origin,
|
|
3873
|
+
product_variant_id = _ref15.product_variant_id,
|
|
3874
|
+
_ref15$quantity = _ref15.quantity,
|
|
3875
|
+
quantity = _ref15$quantity === void 0 ? 1 : _ref15$quantity;
|
|
3600
3876
|
|
|
3601
3877
|
// 处理商品数据,类似 addProductToCart 中的逻辑
|
|
3602
3878
|
var productData = _objectSpread(_objectSpread({}, origin), {}, {
|
|
@@ -3651,11 +3927,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3651
3927
|
}
|
|
3652
3928
|
}, {
|
|
3653
3929
|
key: "checkMaxDurationCapacityForDetailNums",
|
|
3654
|
-
value: function checkMaxDurationCapacityForDetailNums(
|
|
3655
|
-
var
|
|
3656
|
-
var product =
|
|
3657
|
-
date =
|
|
3658
|
-
account =
|
|
3930
|
+
value: function checkMaxDurationCapacityForDetailNums(_ref16) {
|
|
3931
|
+
var _this18 = this;
|
|
3932
|
+
var product = _ref16.product,
|
|
3933
|
+
date = _ref16.date,
|
|
3934
|
+
account = _ref16.account;
|
|
3659
3935
|
var cartItems = this.store.cart.getItems().filter(function (item) {
|
|
3660
3936
|
return !isNormalProduct(item._productOrigin);
|
|
3661
3937
|
});
|
|
@@ -3858,7 +4134,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3858
4134
|
// 为通过检测的商品分配一个公共可用时间段
|
|
3859
4135
|
|
|
3860
4136
|
// 找到所有资源都可用的时间段
|
|
3861
|
-
var commonTimeSlots =
|
|
4137
|
+
var commonTimeSlots = _this18.findCommonAvailableTimeSlots(resourcesOfThisType);
|
|
3862
4138
|
if (commonTimeSlots.length === 0) {
|
|
3863
4139
|
return {
|
|
3864
4140
|
v: {
|
|
@@ -3949,7 +4225,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3949
4225
|
|
|
3950
4226
|
// 获取资源数据
|
|
3951
4227
|
// const dateRange = this.store.date.getDateRange();
|
|
3952
|
-
var resourcesDates =
|
|
4228
|
+
var resourcesDates = _this18.store.date.getDateList();
|
|
3953
4229
|
var targetResourceDate = resourcesDates.find(function (n) {
|
|
3954
4230
|
return n.date === startDate;
|
|
3955
4231
|
});
|
|
@@ -4019,39 +4295,39 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4019
4295
|
}, {
|
|
4020
4296
|
key: "getProductTypeById",
|
|
4021
4297
|
value: function () {
|
|
4022
|
-
var _getProductTypeById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4298
|
+
var _getProductTypeById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(id) {
|
|
4023
4299
|
var productData, _productData$schedule;
|
|
4024
|
-
return _regeneratorRuntime().wrap(function
|
|
4025
|
-
while (1) switch (
|
|
4300
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context29) {
|
|
4301
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
4026
4302
|
case 0:
|
|
4027
|
-
|
|
4303
|
+
_context29.next = 2;
|
|
4028
4304
|
return this.store.products.getProduct(id);
|
|
4029
4305
|
case 2:
|
|
4030
|
-
productData =
|
|
4306
|
+
productData = _context29.sent;
|
|
4031
4307
|
if (!productData) {
|
|
4032
|
-
|
|
4308
|
+
_context29.next = 9;
|
|
4033
4309
|
break;
|
|
4034
4310
|
}
|
|
4035
4311
|
if (!productData.duration) {
|
|
4036
|
-
|
|
4312
|
+
_context29.next = 6;
|
|
4037
4313
|
break;
|
|
4038
4314
|
}
|
|
4039
|
-
return
|
|
4315
|
+
return _context29.abrupt("return", 'duration');
|
|
4040
4316
|
case 6:
|
|
4041
4317
|
if (!((_productData$schedule = productData['schedule.ids']) !== null && _productData$schedule !== void 0 && _productData$schedule.length)) {
|
|
4042
|
-
|
|
4318
|
+
_context29.next = 8;
|
|
4043
4319
|
break;
|
|
4044
4320
|
}
|
|
4045
|
-
return
|
|
4321
|
+
return _context29.abrupt("return", 'session');
|
|
4046
4322
|
case 8:
|
|
4047
|
-
return
|
|
4323
|
+
return _context29.abrupt("return", 'normal');
|
|
4048
4324
|
case 9:
|
|
4049
|
-
return
|
|
4325
|
+
return _context29.abrupt("return", 'normal');
|
|
4050
4326
|
case 10:
|
|
4051
4327
|
case "end":
|
|
4052
|
-
return
|
|
4328
|
+
return _context29.stop();
|
|
4053
4329
|
}
|
|
4054
|
-
},
|
|
4330
|
+
}, _callee28, this);
|
|
4055
4331
|
}));
|
|
4056
4332
|
function getProductTypeById(_x22) {
|
|
4057
4333
|
return _getProductTypeById.apply(this, arguments);
|
|
@@ -4173,12 +4449,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4173
4449
|
}, {
|
|
4174
4450
|
key: "getTimeslotsScheduleByDateRange",
|
|
4175
4451
|
value: (function () {
|
|
4176
|
-
var _getTimeslotsScheduleByDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4452
|
+
var _getTimeslotsScheduleByDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(_ref17) {
|
|
4177
4453
|
var startDate, endDate, scheduleIds, resources, dates, currentDate, end, results, _i5, _dates, date;
|
|
4178
|
-
return _regeneratorRuntime().wrap(function
|
|
4179
|
-
while (1) switch (
|
|
4454
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context30) {
|
|
4455
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
4180
4456
|
case 0:
|
|
4181
|
-
startDate =
|
|
4457
|
+
startDate = _ref17.startDate, endDate = _ref17.endDate, scheduleIds = _ref17.scheduleIds, resources = _ref17.resources;
|
|
4182
4458
|
// 生成日期范围内的所有日期
|
|
4183
4459
|
dates = [];
|
|
4184
4460
|
currentDate = dayjs(startDate);
|
|
@@ -4197,12 +4473,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4197
4473
|
resources: resources
|
|
4198
4474
|
});
|
|
4199
4475
|
}
|
|
4200
|
-
return
|
|
4476
|
+
return _context30.abrupt("return", results);
|
|
4201
4477
|
case 8:
|
|
4202
4478
|
case "end":
|
|
4203
|
-
return
|
|
4479
|
+
return _context30.stop();
|
|
4204
4480
|
}
|
|
4205
|
-
},
|
|
4481
|
+
}, _callee29, this);
|
|
4206
4482
|
}));
|
|
4207
4483
|
function getTimeslotsScheduleByDateRange(_x23) {
|
|
4208
4484
|
return _getTimeslotsScheduleByDateRange.apply(this, arguments);
|
|
@@ -4212,9 +4488,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4212
4488
|
}, {
|
|
4213
4489
|
key: "getAvailableDateForSessionOptimize",
|
|
4214
4490
|
value: function () {
|
|
4215
|
-
var _getAvailableDateForSessionOptimize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4216
|
-
var
|
|
4491
|
+
var _getAvailableDateForSessionOptimize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
|
|
4492
|
+
var _this19 = this,
|
|
4493
|
+
_this$store$currentPr4,
|
|
4494
|
+
_this$store$currentPr5,
|
|
4495
|
+
_tempProducts;
|
|
4217
4496
|
var params,
|
|
4497
|
+
requestVersion,
|
|
4498
|
+
generation,
|
|
4499
|
+
catalogVersion,
|
|
4500
|
+
assertCurrent,
|
|
4218
4501
|
startDate,
|
|
4219
4502
|
endDate,
|
|
4220
4503
|
endDateAfterMonth,
|
|
@@ -4232,12 +4515,41 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4232
4515
|
allProductResources,
|
|
4233
4516
|
targetSchedules,
|
|
4234
4517
|
_loop8,
|
|
4235
|
-
|
|
4236
|
-
return _regeneratorRuntime().wrap(function
|
|
4237
|
-
while (1) switch (
|
|
4518
|
+
_args32 = arguments;
|
|
4519
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context32) {
|
|
4520
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
4238
4521
|
case 0:
|
|
4239
|
-
params =
|
|
4240
|
-
|
|
4522
|
+
params = _args32.length > 0 && _args32[0] !== undefined ? _args32[0] : {};
|
|
4523
|
+
requestVersion = ++this.sessionAvailabilityRequestVersion;
|
|
4524
|
+
generation = this.productDetailGeneration;
|
|
4525
|
+
_context32.prev = 3;
|
|
4526
|
+
_context32.next = 6;
|
|
4527
|
+
return this.store.schedule.ensureScheduleReady();
|
|
4528
|
+
case 6:
|
|
4529
|
+
_context32.next = 13;
|
|
4530
|
+
break;
|
|
4531
|
+
case 8:
|
|
4532
|
+
_context32.prev = 8;
|
|
4533
|
+
_context32.t0 = _context32["catch"](3);
|
|
4534
|
+
if (!(this.disposed || generation !== this.productDetailGeneration || requestVersion !== this.sessionAvailabilityRequestVersion)) {
|
|
4535
|
+
_context32.next = 12;
|
|
4536
|
+
break;
|
|
4537
|
+
}
|
|
4538
|
+
throw this.staleSelection();
|
|
4539
|
+
case 12:
|
|
4540
|
+
throw _context32.t0;
|
|
4541
|
+
case 13:
|
|
4542
|
+
if (!(this.disposed || generation !== this.productDetailGeneration || requestVersion !== this.sessionAvailabilityRequestVersion || !this.store.currentProduct)) {
|
|
4543
|
+
_context32.next = 15;
|
|
4544
|
+
break;
|
|
4545
|
+
}
|
|
4546
|
+
throw this.staleSelection();
|
|
4547
|
+
case 15:
|
|
4548
|
+
this.refreshCurrentProductSchedule();
|
|
4549
|
+
catalogVersion = this.store.schedule.getScheduleCatalogVersion();
|
|
4550
|
+
assertCurrent = function assertCurrent() {
|
|
4551
|
+
if (_this19.disposed || generation !== _this19.productDetailGeneration || requestVersion !== _this19.sessionAvailabilityRequestVersion || catalogVersion !== _this19.store.schedule.getScheduleCatalogVersion()) throw _this19.staleSelection();
|
|
4552
|
+
}; // 开始日期如果小于今天,直接以今天当做开始日期
|
|
4241
4553
|
startDate = params.startDate, endDate = params.endDate; // 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天 且 endDate 小于或等于今天,需要把 startDate 置为今天
|
|
4242
4554
|
if (dayjs(startDate).isBefore(dayjs(), 'day') && (dayjs(endDate).isAfter(dayjs(), 'day') || dayjs(endDate).isSame(dayjs(), 'day'))) {
|
|
4243
4555
|
startDate = dayjs().format('YYYY-MM-DD');
|
|
@@ -4259,36 +4571,43 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4259
4571
|
endDate = tempEndDate;
|
|
4260
4572
|
|
|
4261
4573
|
// 先去读缓存结果,因为正常 UI 调用的是 7 天,而下面我会直接计算 30 天(最少也是 14 天),所以先去读缓存结果,如果缓存结果存在,则直接返回
|
|
4262
|
-
cache = (_this$store$
|
|
4574
|
+
cache = (_this$store$currentPr4 = this.store.currentProductMeta) === null || _this$store$currentPr4 === void 0 ? void 0 : _this$store$currentPr4['timeSlotBySchedule'];
|
|
4263
4575
|
if (!cache) {
|
|
4264
|
-
|
|
4576
|
+
_context32.next = 31;
|
|
4265
4577
|
break;
|
|
4266
4578
|
}
|
|
4267
4579
|
if (!(dayjs(params.startDate).isSameOrAfter(dayjs(cache.startDate), 'day') && dayjs(params.endDate).isSameOrBefore(dayjs(cache.endDate), 'day'))) {
|
|
4268
|
-
|
|
4580
|
+
_context32.next = 31;
|
|
4269
4581
|
break;
|
|
4270
4582
|
}
|
|
4271
|
-
|
|
4272
|
-
|
|
4583
|
+
assertCurrent();
|
|
4584
|
+
this.store.date.setDateList(cache.dateList, true);
|
|
4585
|
+
return _context32.abrupt("return", {
|
|
4273
4586
|
dateList: cache.dateList,
|
|
4274
4587
|
firstAvailableDate: cache.firstAvailableDate
|
|
4275
4588
|
});
|
|
4276
|
-
case
|
|
4589
|
+
case 31:
|
|
4277
4590
|
// 如果当前打开了某个的商品详情弹窗,则应该默认用这个商品
|
|
4278
4591
|
tempProducts = this.store.currentProduct;
|
|
4279
|
-
schedule = (_this$store$
|
|
4592
|
+
schedule = (_this$store$currentPr5 = this.store.currentProductMeta) === null || _this$store$currentPr5 === void 0 ? void 0 : _this$store$currentPr5['schedule'];
|
|
4280
4593
|
filteredSchedule = filterScheduleByDateRange(schedule, startDate || '', endDate || ''); // 1.后端返回的数据,确定资源在每一天的可用和使用情况
|
|
4281
4594
|
tempResourceIds = getResourcesIdsByProduct(tempProducts);
|
|
4282
|
-
|
|
4595
|
+
_context32.next = 37;
|
|
4283
4596
|
return this.store.date.fetchResourceDates({
|
|
4597
|
+
errorMode: 'throw',
|
|
4598
|
+
bookingRead: true,
|
|
4284
4599
|
query: {
|
|
4285
4600
|
start_date: startDate || '',
|
|
4286
4601
|
end_date: endDate || '',
|
|
4287
4602
|
resource_ids: tempResourceIds
|
|
4288
4603
|
}
|
|
4604
|
+
}).catch(function (error) {
|
|
4605
|
+
assertCurrent();
|
|
4606
|
+
throw error;
|
|
4289
4607
|
});
|
|
4290
|
-
case
|
|
4291
|
-
res =
|
|
4608
|
+
case 37:
|
|
4609
|
+
res = _context32.sent;
|
|
4610
|
+
assertCurrent();
|
|
4292
4611
|
// 2. 商品 schedule 数据,确定日程在每一天的时间片
|
|
4293
4612
|
// 3. 把后端返回的和 schedule 的数据进行合并,确定每一天的可用和使用情况
|
|
4294
4613
|
dates = [];
|
|
@@ -4310,8 +4629,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4310
4629
|
targetSchedules = this.store.schedule.getScheduleListByIds(tempProducts['schedule.ids']);
|
|
4311
4630
|
_loop8 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop8() {
|
|
4312
4631
|
var currentDateStr, status, summaryCount, availableCount, _checkSessionProductL, latestStartDate, earliestEndDate, scheduleByDate, minTimeMaxTime, scheduleTimeSlots, timesSlotCanUse, dateStatus, usageRatio;
|
|
4313
|
-
return _regeneratorRuntime().wrap(function _loop8$(
|
|
4314
|
-
while (1) switch (
|
|
4632
|
+
return _regeneratorRuntime().wrap(function _loop8$(_context31) {
|
|
4633
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
4315
4634
|
case 0:
|
|
4316
4635
|
currentDateStr = currentDate.format('YYYY-MM-DD');
|
|
4317
4636
|
status = 'available';
|
|
@@ -4470,37 +4789,38 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4470
4789
|
|
|
4471
4790
|
// 如果 firstAvailableDate 距离 startDate 大于 14 天了,则后面就不需要再找了,也是一种性能保护
|
|
4472
4791
|
if (!(firstAvailableDate && dayjs(currentDate).diff(dayjs(startDate), 'day') > 31)) {
|
|
4473
|
-
|
|
4792
|
+
_context31.next = 12;
|
|
4474
4793
|
break;
|
|
4475
4794
|
}
|
|
4476
|
-
return
|
|
4795
|
+
return _context31.abrupt("return", 1);
|
|
4477
4796
|
case 12:
|
|
4478
4797
|
currentDate = dayjs(currentDate).add(1, 'day');
|
|
4479
4798
|
case 13:
|
|
4480
4799
|
case "end":
|
|
4481
|
-
return
|
|
4800
|
+
return _context31.stop();
|
|
4482
4801
|
}
|
|
4483
4802
|
}, _loop8);
|
|
4484
4803
|
});
|
|
4485
|
-
case
|
|
4804
|
+
case 47:
|
|
4486
4805
|
if (!(dayjs(currentDate).isBefore(dayjs(endDate), 'day') || dayjs(currentDate).isSame(dayjs(endDate), 'day'))) {
|
|
4487
|
-
|
|
4806
|
+
_context32.next = 53;
|
|
4488
4807
|
break;
|
|
4489
4808
|
}
|
|
4490
|
-
return
|
|
4491
|
-
case
|
|
4492
|
-
if (!
|
|
4493
|
-
|
|
4809
|
+
return _context32.delegateYield(_loop8(), "t1", 49);
|
|
4810
|
+
case 49:
|
|
4811
|
+
if (!_context32.t1) {
|
|
4812
|
+
_context32.next = 51;
|
|
4494
4813
|
break;
|
|
4495
4814
|
}
|
|
4496
|
-
return
|
|
4497
|
-
case
|
|
4498
|
-
|
|
4815
|
+
return _context32.abrupt("break", 53);
|
|
4816
|
+
case 51:
|
|
4817
|
+
_context32.next = 47;
|
|
4499
4818
|
break;
|
|
4500
|
-
case
|
|
4819
|
+
case 53:
|
|
4501
4820
|
// 最终把资源数据也加到日期内
|
|
4502
4821
|
dates = handleAvailableDateByResource(res.data, dates);
|
|
4503
|
-
|
|
4822
|
+
assertCurrent();
|
|
4823
|
+
this.store.date.setDateList(dates, true);
|
|
4504
4824
|
|
|
4505
4825
|
// 缓存这次结果,以防后面他小幅度范围内去修改天数
|
|
4506
4826
|
if (!this.store.currentProductMeta) this.store.currentProductMeta = {};
|
|
@@ -4510,15 +4830,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4510
4830
|
startDate: startDate,
|
|
4511
4831
|
endDate: dayjs(currentDate).format('YYYY-MM-DD')
|
|
4512
4832
|
};
|
|
4513
|
-
return
|
|
4833
|
+
return _context32.abrupt("return", {
|
|
4514
4834
|
dateList: dates,
|
|
4515
4835
|
firstAvailableDate: firstAvailableDate
|
|
4516
4836
|
});
|
|
4517
|
-
case
|
|
4837
|
+
case 59:
|
|
4518
4838
|
case "end":
|
|
4519
|
-
return
|
|
4839
|
+
return _context32.stop();
|
|
4520
4840
|
}
|
|
4521
|
-
},
|
|
4841
|
+
}, _callee30, this, [[3, 8]]);
|
|
4522
4842
|
}));
|
|
4523
4843
|
function getAvailableDateForSessionOptimize() {
|
|
4524
4844
|
return _getAvailableDateForSessionOptimize.apply(this, arguments);
|
|
@@ -4565,16 +4885,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4565
4885
|
}, {
|
|
4566
4886
|
key: "getContactInfo",
|
|
4567
4887
|
value: (function () {
|
|
4568
|
-
var _getContactInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4569
|
-
return _regeneratorRuntime().wrap(function
|
|
4570
|
-
while (1) switch (
|
|
4888
|
+
var _getContactInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
|
|
4889
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context33) {
|
|
4890
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
4571
4891
|
case 0:
|
|
4572
|
-
return
|
|
4892
|
+
return _context33.abrupt("return", this.request.get('/customer/metadata', params));
|
|
4573
4893
|
case 1:
|
|
4574
4894
|
case "end":
|
|
4575
|
-
return
|
|
4895
|
+
return _context33.stop();
|
|
4576
4896
|
}
|
|
4577
|
-
},
|
|
4897
|
+
}, _callee31, this);
|
|
4578
4898
|
}));
|
|
4579
4899
|
function getContactInfo(_x24) {
|
|
4580
4900
|
return _getContactInfo.apply(this, arguments);
|