@pisell/pisellos 3.0.5 → 3.0.6
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/modules/Account/index.d.ts +2 -6
- package/dist/modules/Account/index.js +21 -103
- package/dist/modules/Account/types.d.ts +12 -1
- package/dist/modules/AccountList/index.d.ts +20 -1
- package/dist/modules/AccountList/index.js +243 -75
- package/dist/modules/AccountList/types.d.ts +33 -1
- package/dist/modules/AccountList/types.js +8 -0
- package/dist/modules/AccountList/utils.d.ts +9 -0
- package/dist/modules/AccountList/utils.js +25 -0
- package/dist/modules/BaseModule.d.ts +2 -2
- package/dist/modules/BaseModule.js +1 -1
- package/dist/modules/Cart/index.d.ts +8 -5
- package/dist/modules/Cart/index.js +101 -25
- package/dist/modules/Cart/types.d.ts +82 -5
- package/dist/modules/Cart/types.js +22 -0
- package/dist/modules/Cart/utils.d.ts +106 -13
- package/dist/modules/Cart/utils.js +289 -76
- package/dist/modules/Date/index.d.ts +6 -6
- package/dist/modules/Date/index.js +41 -58
- package/dist/modules/Date/types.d.ts +22 -6
- package/dist/modules/Date/utils.d.ts +4 -3
- package/dist/modules/Date/utils.js +81 -30
- package/dist/modules/Discount/index.d.ts +4 -4
- package/dist/modules/Discount/index.js +11 -11
- package/dist/modules/Order/index.d.ts +11 -5
- package/dist/modules/Order/index.js +47 -18
- package/dist/modules/Order/types.d.ts +10 -3
- package/dist/modules/Order/utils.d.ts +10 -0
- package/dist/modules/Order/utils.js +15 -0
- package/dist/modules/Product/index.d.ts +14 -1
- package/dist/modules/Product/index.js +35 -0
- package/dist/modules/Product/types.d.ts +27 -3
- package/dist/modules/ProductList/index.js +11 -5
- package/dist/modules/Resource/types.d.ts +1 -0
- package/dist/modules/Resource/utils.js +1 -1
- package/dist/modules/Rules/index.d.ts +3 -3
- package/dist/modules/Rules/index.js +121 -53
- package/dist/modules/Rules/types.d.ts +5 -1
- package/dist/modules/Schedule/index.d.ts +18 -0
- package/dist/modules/Schedule/index.js +111 -0
- package/dist/modules/Schedule/type.d.ts +157 -0
- package/dist/modules/Schedule/type.js +1 -0
- package/dist/modules/Schedule/types.d.ts +182 -0
- package/dist/modules/Schedule/types.js +1 -0
- package/dist/modules/Schedule/utils.d.ts +67 -0
- package/dist/modules/Schedule/utils.js +729 -0
- package/dist/modules/Step/index.d.ts +14 -3
- package/dist/modules/Step/index.js +54 -2
- package/dist/modules/Summary/index.d.ts +12 -5
- package/dist/modules/Summary/index.js +33 -7
- package/dist/modules/Summary/types.d.ts +23 -2
- package/dist/modules/Summary/utils.d.ts +14 -4
- package/dist/modules/Summary/utils.js +46 -4
- package/dist/modules/index.d.ts +10 -0
- package/dist/modules/index.js +11 -1
- package/dist/plugins/index.d.ts +3 -3
- package/dist/plugins/request.d.ts +3 -3
- package/dist/plugins/request.js +30 -30
- package/dist/plugins/shopStore.d.ts +1 -1
- package/dist/solution/BookingByStep/index.d.ts +97 -24
- package/dist/solution/BookingByStep/index.js +1024 -322
- package/dist/solution/BookingByStep/types.d.ts +3 -10
- package/dist/solution/BookingByStep/types.js +11 -15
- package/dist/solution/BookingByStep/utils/products.d.ts +1 -1
- package/dist/solution/BookingByStep/utils/products.js +3 -0
- package/dist/solution/BookingByStep/utils/resources.d.ts +60 -6
- package/dist/solution/BookingByStep/utils/resources.js +293 -52
- package/dist/solution/ShopDiscount/index.d.ts +4 -4
- package/dist/solution/ShopDiscount/index.js +16 -16
- package/dist/solution/ShopDiscount/types.d.ts +2 -2
- package/dist/solution/ShopDiscount/utils.js +1 -1
- package/lib/core/index.js +7 -2
- package/lib/modules/Account/index.d.ts +2 -6
- package/lib/modules/Account/index.js +15 -30
- package/lib/modules/Account/types.d.ts +12 -1
- package/lib/modules/AccountList/index.d.ts +20 -1
- package/lib/modules/AccountList/index.js +122 -13
- package/lib/modules/AccountList/types.d.ts +33 -1
- package/lib/modules/AccountList/utils.d.ts +9 -0
- package/lib/modules/AccountList/utils.js +39 -0
- package/lib/modules/BaseModule.d.ts +2 -2
- package/lib/modules/BaseModule.js +14 -3
- package/lib/modules/Cart/index.d.ts +8 -5
- package/lib/modules/Cart/index.js +81 -8
- package/lib/modules/Cart/types.d.ts +82 -5
- package/lib/modules/Cart/types.js +20 -2
- package/lib/modules/Cart/utils.d.ts +106 -13
- package/lib/modules/Cart/utils.js +188 -45
- package/lib/modules/Date/index.d.ts +6 -6
- package/lib/modules/Date/index.js +13 -28
- package/lib/modules/Date/types.d.ts +22 -6
- package/lib/modules/Date/utils.d.ts +4 -3
- package/lib/modules/Date/utils.js +47 -13
- package/lib/modules/Discount/index.d.ts +4 -4
- package/lib/modules/Discount/index.js +9 -2
- package/lib/modules/Guests/index.js +4 -1
- package/lib/modules/Order/index.d.ts +11 -5
- package/lib/modules/Order/index.js +24 -3
- package/lib/modules/Order/types.d.ts +10 -3
- package/lib/modules/Order/utils.d.ts +10 -0
- package/lib/modules/Order/utils.js +45 -0
- package/lib/modules/Payment/index.js +1 -6
- package/lib/modules/Product/index.d.ts +14 -1
- package/lib/modules/Product/index.js +19 -0
- package/lib/modules/Product/types.d.ts +27 -3
- package/lib/modules/ProductList/index.js +21 -7
- package/lib/modules/Resource/index.js +4 -1
- package/lib/modules/Resource/types.d.ts +1 -0
- package/lib/modules/Resource/utils.js +7 -4
- package/lib/modules/Rules/index.d.ts +3 -3
- package/lib/modules/Rules/index.js +118 -43
- package/lib/modules/Rules/types.d.ts +5 -1
- package/lib/modules/Schedule/index.d.ts +18 -0
- package/lib/modules/Schedule/index.js +81 -0
- package/lib/modules/Schedule/type.d.ts +157 -0
- package/lib/modules/Schedule/type.js +17 -0
- package/lib/modules/Schedule/types.d.ts +182 -0
- package/lib/modules/Schedule/types.js +17 -0
- package/lib/modules/Schedule/utils.d.ts +67 -0
- package/lib/modules/Schedule/utils.js +600 -0
- package/lib/modules/Step/index.d.ts +14 -3
- package/lib/modules/Step/index.js +38 -1
- package/lib/modules/Summary/index.d.ts +12 -5
- package/lib/modules/Summary/index.js +15 -1
- package/lib/modules/Summary/types.d.ts +23 -2
- package/lib/modules/Summary/utils.d.ts +14 -4
- package/lib/modules/Summary/utils.js +30 -1
- package/lib/modules/index.d.ts +10 -0
- package/lib/modules/index.js +21 -1
- package/lib/plugins/index.d.ts +3 -3
- package/lib/plugins/request.d.ts +3 -3
- package/lib/plugins/request.js +48 -11
- package/lib/plugins/shopStore.d.ts +1 -1
- package/lib/solution/BookingByStep/index.d.ts +97 -24
- package/lib/solution/BookingByStep/index.js +693 -145
- package/lib/solution/BookingByStep/types.d.ts +3 -10
- package/lib/solution/BookingByStep/types.js +37 -14
- package/lib/solution/BookingByStep/utils/products.d.ts +1 -1
- package/lib/solution/BookingByStep/utils/products.js +3 -0
- package/lib/solution/BookingByStep/utils/resources.d.ts +60 -6
- package/lib/solution/BookingByStep/utils/resources.js +286 -54
- package/lib/solution/BuyTickets/index.js +34 -20
- package/lib/solution/ShopDiscount/index.d.ts +4 -4
- package/lib/solution/ShopDiscount/index.js +10 -2
- package/lib/solution/ShopDiscount/types.d.ts +2 -2
- package/package.json +4 -2
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
function _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; } } }; }
|
|
3
2
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
4
3
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
|
-
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); }
|
|
6
4
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
7
5
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
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 _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
8
|
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; }
|
|
9
9
|
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; }
|
|
10
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; }
|
|
@@ -27,10 +27,12 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
27
27
|
import { BaseModule } from "../../modules/BaseModule";
|
|
28
28
|
import { BookingByStepHooks, createModule } from "./types";
|
|
29
29
|
import { getAvailableProductResources } from "./utils/products";
|
|
30
|
-
import { getResourcesByProduct, getTimeSlicesByResource, getTimeSlicesByResources, getIsUsableByTimeItem } from "./utils/resources";
|
|
31
|
-
import dayjs from
|
|
30
|
+
import { getResourcesByProduct, getTimeSlicesByResource, getTimeSlicesByResources, getIsUsableByTimeItem, getOthersSelectedResources, formatDefaultCapacitys, getSumCapacity, checkSubResourcesCapacity, getOthersCartSelectedResources } from "./utils/resources";
|
|
31
|
+
import dayjs from 'dayjs';
|
|
32
32
|
import { getResourcesMap } from "../../modules/Resource/utils";
|
|
33
|
-
import { cloneDeep } from
|
|
33
|
+
import { cloneDeep } from 'lodash-es';
|
|
34
|
+
import { calcCalendarDataByScheduleResult, calcMinTimeMaxTimeBySchedules, getAllSortedDateRanges } from "../../modules/Schedule/utils";
|
|
35
|
+
import { disableAllDates, disableDatesBeforeOneDay, generateMonthDates } from "../../modules/Date/utils";
|
|
34
36
|
export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
35
37
|
_inherits(BookingByStepImpl, _BaseModule);
|
|
36
38
|
var _super = _createSuper(BookingByStepImpl);
|
|
@@ -41,8 +43,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
41
43
|
args[_key] = arguments[_key];
|
|
42
44
|
}
|
|
43
45
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
44
|
-
_defineProperty(_assertThisInitialized(_this), "defaultName",
|
|
45
|
-
_defineProperty(_assertThisInitialized(_this), "defaultVersion",
|
|
46
|
+
_defineProperty(_assertThisInitialized(_this), "defaultName", 'bookingByStep');
|
|
47
|
+
_defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
|
|
46
48
|
_defineProperty(_assertThisInitialized(_this), "isSolution", true);
|
|
47
49
|
_defineProperty(_assertThisInitialized(_this), "request", void 0);
|
|
48
50
|
_defineProperty(_assertThisInitialized(_this), "window", void 0);
|
|
@@ -50,32 +52,34 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
50
52
|
_defineProperty(_assertThisInitialized(_this), "store", void 0);
|
|
51
53
|
_defineProperty(_assertThisInitialized(_this), "otherParams", {});
|
|
52
54
|
_defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
|
|
55
|
+
_defineProperty(_assertThisInitialized(_this), "otherData", {});
|
|
53
56
|
return _this;
|
|
54
57
|
}
|
|
55
58
|
_createClass(BookingByStepImpl, [{
|
|
56
59
|
key: "initialize",
|
|
57
|
-
value:
|
|
60
|
+
value: // 提供给 UI 层的临时数据存储,会进缓存
|
|
61
|
+
function () {
|
|
58
62
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
|
|
59
63
|
var _this$otherParams,
|
|
60
64
|
_this$otherParams2,
|
|
61
65
|
_this2 = this;
|
|
62
|
-
var targetCacheData, sessionData, data, moduleArr;
|
|
66
|
+
var targetCacheData, sessionData, _data$this$otherParam, data, moduleArr;
|
|
63
67
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
64
68
|
while (1) switch (_context.prev = _context.next) {
|
|
65
69
|
case 0:
|
|
66
70
|
this.core = core;
|
|
67
71
|
this.store = options.store || {};
|
|
68
72
|
this.otherParams = options.otherParams || {};
|
|
69
|
-
console.log(
|
|
73
|
+
console.log('[BookingByStep] 初始化完成');
|
|
70
74
|
// 获取依赖的插件
|
|
71
|
-
this.request = core.getPlugin(
|
|
72
|
-
this.window = core.getPlugin(
|
|
73
|
-
this.shopStore = core.getPlugin(
|
|
75
|
+
this.request = core.getPlugin('request');
|
|
76
|
+
this.window = core.getPlugin('window');
|
|
77
|
+
this.shopStore = core.getPlugin('shopStore');
|
|
74
78
|
if (this.request) {
|
|
75
79
|
_context.next = 9;
|
|
76
80
|
break;
|
|
77
81
|
}
|
|
78
|
-
throw new Error(
|
|
82
|
+
throw new Error('bookingByStep解决方案需要 request 插件支持');
|
|
79
83
|
case 9:
|
|
80
84
|
// 如果有传 cacheid,默认需要收集上面这些模块里用户操作选中的数据
|
|
81
85
|
// 并且在上面 registerModule 的时候,读取 sessionStroage 里的数据,塞进默认值
|
|
@@ -87,9 +91,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
87
91
|
data = JSON.parse(sessionData); // 匹配 cacheid,如果匹配不到,直接把 sessionData 清掉即可
|
|
88
92
|
// 如果匹配到了,则把 sessionData 里的数据按模块塞到 store 里去
|
|
89
93
|
targetCacheData = data[this.otherParams.cacheId];
|
|
94
|
+
this.otherData = ((_data$this$otherParam = data[this.otherParams.cacheId]) === null || _data$this$otherParam === void 0 || (_data$this$otherParam = _data$this$otherParam[this.name]) === null || _data$this$otherParam === void 0 ? void 0 : _data$this$otherParam['otherData']) || {};
|
|
90
95
|
}
|
|
91
96
|
}
|
|
92
|
-
moduleArr = [
|
|
97
|
+
moduleArr = ['accountList', 'cart', 'schedule', 'summary', 'step', 'products', 'date', 'order', 'payment'];
|
|
93
98
|
moduleArr.forEach(function (step) {
|
|
94
99
|
var targetModule = createModule(step, _this2.name);
|
|
95
100
|
if (targetModule) {
|
|
@@ -160,6 +165,23 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
160
165
|
return this.store.step.getStepList();
|
|
161
166
|
}
|
|
162
167
|
|
|
168
|
+
/**
|
|
169
|
+
* 添加step
|
|
170
|
+
*/
|
|
171
|
+
}, {
|
|
172
|
+
key: "addStep",
|
|
173
|
+
value: function addStep(step, key) {
|
|
174
|
+
this.store.step.addStep(step, key);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* 删除step
|
|
179
|
+
*/
|
|
180
|
+
}, {
|
|
181
|
+
key: "removeStep",
|
|
182
|
+
value: function removeStep(key) {
|
|
183
|
+
this.store.step.removeStep(key);
|
|
184
|
+
}
|
|
163
185
|
// 获取购物车里 temp.xxx的方法
|
|
164
186
|
// async getStoreCart(key?: string) {
|
|
165
187
|
// return this.store.cart.getTemp(key);
|
|
@@ -170,32 +192,43 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
170
192
|
key: "loadProducts",
|
|
171
193
|
value: function () {
|
|
172
194
|
var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref) {
|
|
173
|
-
var
|
|
195
|
+
var _schedule_ids;
|
|
196
|
+
var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, _ref$schedule_ids, schedule_ids, schedule_ids_data, productsData;
|
|
174
197
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
175
198
|
while (1) switch (_context2.prev = _context2.next) {
|
|
176
199
|
case 0:
|
|
177
|
-
_ref$category_ids = _ref.category_ids, category_ids = _ref$category_ids === void 0 ? [] : _ref$category_ids, _ref$product_ids = _ref.product_ids, product_ids = _ref$product_ids === void 0 ? [] : _ref$product_ids, _ref$collection = _ref.collection, collection = _ref$collection === void 0 ? [] : _ref$collection;
|
|
178
|
-
|
|
200
|
+
_ref$category_ids = _ref.category_ids, category_ids = _ref$category_ids === void 0 ? [] : _ref$category_ids, _ref$product_ids = _ref.product_ids, product_ids = _ref$product_ids === void 0 ? [] : _ref$product_ids, _ref$collection = _ref.collection, collection = _ref$collection === void 0 ? [] : _ref$collection, _ref$schedule_ids = _ref.schedule_ids, schedule_ids = _ref$schedule_ids === void 0 ? [] : _ref$schedule_ids;
|
|
201
|
+
// 如果 schedule_ids 为空,则需要尝试从 schedule 模块里获取
|
|
202
|
+
if (!((_schedule_ids = schedule_ids) !== null && _schedule_ids !== void 0 && _schedule_ids.length)) {
|
|
203
|
+
schedule_ids_data = this.store.schedule.getScheduleListByIds(schedule_ids).map(function (n) {
|
|
204
|
+
return n.id;
|
|
205
|
+
});
|
|
206
|
+
if (schedule_ids_data.length) {
|
|
207
|
+
schedule_ids = schedule_ids_data;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
_context2.next = 4;
|
|
179
211
|
return this.request.post("/product/query", {
|
|
180
212
|
open_quotation: 1,
|
|
181
213
|
open_bundle: 1,
|
|
182
|
-
extension_type: [
|
|
183
|
-
with: [
|
|
184
|
-
status:
|
|
214
|
+
extension_type: ['product_appointment', 'appointment_ticket', 'session_product', 'session_ticket'],
|
|
215
|
+
with: ['category', 'collection', 'resourceRelation'],
|
|
216
|
+
status: 'published',
|
|
185
217
|
num: 500,
|
|
186
218
|
skip: 1,
|
|
187
219
|
category_ids: category_ids,
|
|
188
220
|
ids: product_ids,
|
|
189
221
|
collection: collection,
|
|
190
|
-
front_end_cache_id: this.cacheId
|
|
222
|
+
front_end_cache_id: this.cacheId,
|
|
223
|
+
client_schedule_ids: schedule_ids
|
|
191
224
|
}, {
|
|
192
225
|
useCache: true
|
|
193
226
|
});
|
|
194
|
-
case
|
|
227
|
+
case 4:
|
|
195
228
|
productsData = _context2.sent;
|
|
196
229
|
this.store.products.addProduct(productsData.data.list);
|
|
197
230
|
return _context2.abrupt("return", productsData.data.list);
|
|
198
|
-
case
|
|
231
|
+
case 7:
|
|
199
232
|
case "end":
|
|
200
233
|
return _context2.stop();
|
|
201
234
|
}
|
|
@@ -207,81 +240,283 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
207
240
|
return loadProducts;
|
|
208
241
|
}()
|
|
209
242
|
}, {
|
|
210
|
-
key: "
|
|
243
|
+
key: "loadProductByScheduleDate",
|
|
211
244
|
value: function () {
|
|
212
|
-
var
|
|
213
|
-
var
|
|
245
|
+
var _loadProductByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref2) {
|
|
246
|
+
var date, product_ids, _ref2$category_ids, category_ids, scheduleList, scheduleIds;
|
|
214
247
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
215
248
|
while (1) switch (_context3.prev = _context3.next) {
|
|
216
249
|
case 0:
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
250
|
+
date = _ref2.date, product_ids = _ref2.product_ids, _ref2$category_ids = _ref2.category_ids, category_ids = _ref2$category_ids === void 0 ? [] : _ref2$category_ids;
|
|
251
|
+
scheduleList = this.store.schedule.getAvailabilityScheduleDateList(); // 缓存下这次选择的结果,如果是先选日期再选 duration 类商品,后面用得到
|
|
252
|
+
this.setDateRange([{
|
|
253
|
+
date: date,
|
|
254
|
+
status: 'available',
|
|
255
|
+
week: '',
|
|
256
|
+
weekNum: 0
|
|
257
|
+
}, {
|
|
258
|
+
date: date,
|
|
259
|
+
status: 'available',
|
|
260
|
+
week: '',
|
|
261
|
+
weekNum: 0
|
|
262
|
+
}]);
|
|
263
|
+
scheduleIds = scheduleList.filter(function (n) {
|
|
264
|
+
return n.date === date;
|
|
265
|
+
}).flatMap(function (n) {
|
|
266
|
+
return n.schedule_id;
|
|
267
|
+
});
|
|
268
|
+
_context3.next = 6;
|
|
269
|
+
return this.loadProducts({
|
|
270
|
+
schedule_ids: scheduleIds,
|
|
271
|
+
product_ids: product_ids,
|
|
272
|
+
category_ids: category_ids
|
|
273
|
+
});
|
|
274
|
+
case 6:
|
|
275
|
+
return _context3.abrupt("return", _context3.sent);
|
|
276
|
+
case 7:
|
|
277
|
+
case "end":
|
|
278
|
+
return _context3.stop();
|
|
279
|
+
}
|
|
280
|
+
}, _callee3, this);
|
|
281
|
+
}));
|
|
282
|
+
function loadProductByScheduleDate(_x4) {
|
|
283
|
+
return _loadProductByScheduleDate.apply(this, arguments);
|
|
284
|
+
}
|
|
285
|
+
return loadProductByScheduleDate;
|
|
286
|
+
}() // 加载当前店铺下所有 schedule
|
|
287
|
+
}, {
|
|
288
|
+
key: "loadAllSchedule",
|
|
289
|
+
value: function () {
|
|
290
|
+
var _loadAllSchedule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
291
|
+
var _scheduleList$data;
|
|
292
|
+
var scheduleList;
|
|
293
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
294
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
295
|
+
case 0:
|
|
296
|
+
_context4.next = 2;
|
|
297
|
+
return this.request.get("/schedule");
|
|
298
|
+
case 2:
|
|
299
|
+
scheduleList = _context4.sent;
|
|
300
|
+
this.store.schedule.setScheduleList(((_scheduleList$data = scheduleList.data) === null || _scheduleList$data === void 0 ? void 0 : _scheduleList$data.list) || []);
|
|
301
|
+
case 4:
|
|
302
|
+
case "end":
|
|
303
|
+
return _context4.stop();
|
|
304
|
+
}
|
|
305
|
+
}, _callee4, this);
|
|
306
|
+
}));
|
|
307
|
+
function loadAllSchedule() {
|
|
308
|
+
return _loadAllSchedule.apply(this, arguments);
|
|
309
|
+
}
|
|
310
|
+
return loadAllSchedule;
|
|
311
|
+
}() // ui 层提供日期的起始范围,返回一个起始范围内日期的可用情况
|
|
312
|
+
}, {
|
|
313
|
+
key: "loadScheduleAvailableDate",
|
|
314
|
+
value: function () {
|
|
315
|
+
var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref3) {
|
|
316
|
+
var _res$data$date_list;
|
|
317
|
+
var startDate, endDate, custom_page_id, dates, res;
|
|
318
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
319
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
320
|
+
case 0:
|
|
321
|
+
startDate = _ref3.startDate, endDate = _ref3.endDate, custom_page_id = _ref3.custom_page_id;
|
|
322
|
+
// 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天,需要把 startDate 置为今天
|
|
323
|
+
if (dayjs(startDate).isBefore(dayjs(), 'day')) {
|
|
324
|
+
startDate = dayjs().format('YYYY-MM-DD');
|
|
325
|
+
}
|
|
326
|
+
// 1.生成当前月份的所有日期,默认都不可用
|
|
327
|
+
dates = generateMonthDates(startDate, endDate);
|
|
328
|
+
dates = disableAllDates(dates);
|
|
329
|
+
// 如果 endDate 在今天之前,则不用查接口,直接返回 dates
|
|
330
|
+
if (!dayjs(endDate).isBefore(dayjs(), 'day')) {
|
|
331
|
+
_context5.next = 6;
|
|
221
332
|
break;
|
|
222
333
|
}
|
|
223
|
-
|
|
224
|
-
case
|
|
225
|
-
|
|
334
|
+
return _context5.abrupt("return", dates);
|
|
335
|
+
case 6:
|
|
336
|
+
_context5.next = 8;
|
|
337
|
+
return this.request.get("/schedule/product/availability", {
|
|
338
|
+
start_date: startDate,
|
|
339
|
+
end_date: endDate,
|
|
340
|
+
custom_page_id: custom_page_id
|
|
341
|
+
});
|
|
342
|
+
case 8:
|
|
343
|
+
res = _context5.sent;
|
|
344
|
+
this.store.schedule.setAvailabilityScheduleDateList(res.data.date_list);
|
|
345
|
+
// 如果没有schedule或者结束日期在今天之前,则所有日期均不可用
|
|
346
|
+
if (!(!((_res$data$date_list = res.data.date_list) !== null && _res$data$date_list !== void 0 && _res$data$date_list.length) || dayjs(endDate).isBefore(dayjs(), 'day'))) {
|
|
347
|
+
_context5.next = 12;
|
|
348
|
+
break;
|
|
349
|
+
}
|
|
350
|
+
return _context5.abrupt("return", dates);
|
|
351
|
+
case 12:
|
|
352
|
+
res.data.date_list.forEach(function (n) {
|
|
353
|
+
if (n.schedule_id && n.schedule_id.length) {
|
|
354
|
+
var index = dates.findIndex(function (m) {
|
|
355
|
+
return m.date === n.date;
|
|
356
|
+
});
|
|
357
|
+
if (index !== -1) {
|
|
358
|
+
dates[index].status = 'available';
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
dates = disableDatesBeforeOneDay(dates);
|
|
363
|
+
return _context5.abrupt("return", dates);
|
|
364
|
+
case 15:
|
|
365
|
+
case "end":
|
|
366
|
+
return _context5.stop();
|
|
367
|
+
}
|
|
368
|
+
}, _callee5, this);
|
|
369
|
+
}));
|
|
370
|
+
function loadScheduleAvailableDate(_x5) {
|
|
371
|
+
return _loadScheduleAvailableDate.apply(this, arguments);
|
|
372
|
+
}
|
|
373
|
+
return loadScheduleAvailableDate;
|
|
374
|
+
}()
|
|
375
|
+
}, {
|
|
376
|
+
key: "storeProduct",
|
|
377
|
+
value: function () {
|
|
378
|
+
var _storeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(productData) {
|
|
379
|
+
var activeAccount, _ref4, bundle, options, origin, product_variant_id, product, addCartItem;
|
|
380
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
381
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
382
|
+
case 0:
|
|
383
|
+
// 往购物车加商品数据的时候,默认用当前 activeAccount 填充到 product 的 account 里面
|
|
384
|
+
activeAccount = this.getActiveAccount();
|
|
385
|
+
_ref4 = productData || {}, bundle = _ref4.bundle, options = _ref4.options, origin = _ref4.origin, product_variant_id = _ref4.product_variant_id;
|
|
226
386
|
product = _objectSpread(_objectSpread({}, origin), {}, {
|
|
227
387
|
product_variant_id: product_variant_id
|
|
228
388
|
});
|
|
229
|
-
|
|
230
|
-
account: activeAccount,
|
|
389
|
+
addCartItem = {
|
|
231
390
|
product: product,
|
|
232
391
|
bundle: bundle,
|
|
233
392
|
options: options
|
|
234
|
-
}
|
|
393
|
+
};
|
|
394
|
+
if (activeAccount) {
|
|
395
|
+
addCartItem.account = activeAccount;
|
|
396
|
+
}
|
|
397
|
+
this.store.cart.addItem(addCartItem);
|
|
235
398
|
case 6:
|
|
236
399
|
case "end":
|
|
237
|
-
return
|
|
400
|
+
return _context6.stop();
|
|
238
401
|
}
|
|
239
|
-
},
|
|
402
|
+
}, _callee6, this);
|
|
240
403
|
}));
|
|
241
|
-
function storeProduct(
|
|
404
|
+
function storeProduct(_x6) {
|
|
242
405
|
return _storeProduct.apply(this, arguments);
|
|
243
406
|
}
|
|
244
407
|
return storeProduct;
|
|
245
|
-
}() //
|
|
408
|
+
}() // 添加单个账户或者 guest
|
|
246
409
|
}, {
|
|
247
410
|
key: "addAccount",
|
|
248
411
|
value: function () {
|
|
249
|
-
var _addAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
250
|
-
var
|
|
251
|
-
return _regeneratorRuntime().wrap(function
|
|
252
|
-
while (1) switch (
|
|
412
|
+
var _addAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(account, extra) {
|
|
413
|
+
var accountModules, newAccount;
|
|
414
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
415
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
253
416
|
case 0:
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
417
|
+
if (!((extra === null || extra === void 0 ? void 0 : extra.type) === 'holder')) {
|
|
418
|
+
_context7.next = 5;
|
|
419
|
+
break;
|
|
420
|
+
}
|
|
421
|
+
_context7.next = 3;
|
|
422
|
+
return this.store.accountList.addHolderAccounts([account], extra.customerId);
|
|
423
|
+
case 3:
|
|
424
|
+
accountModules = _context7.sent;
|
|
425
|
+
return _context7.abrupt("return", accountModules[0].getAccount());
|
|
426
|
+
case 5:
|
|
427
|
+
_context7.next = 7;
|
|
428
|
+
return this.store.accountList.addAccount(account);
|
|
429
|
+
case 7:
|
|
430
|
+
newAccount = _context7.sent;
|
|
431
|
+
return _context7.abrupt("return", newAccount.getAccount());
|
|
432
|
+
case 9:
|
|
258
433
|
case "end":
|
|
259
|
-
return
|
|
434
|
+
return _context7.stop();
|
|
260
435
|
}
|
|
261
|
-
},
|
|
436
|
+
}, _callee7, this);
|
|
262
437
|
}));
|
|
263
|
-
function addAccount(
|
|
438
|
+
function addAccount(_x7, _x8) {
|
|
264
439
|
return _addAccount.apply(this, arguments);
|
|
265
440
|
}
|
|
266
441
|
return addAccount;
|
|
442
|
+
}() // 添加账户或者 guest
|
|
443
|
+
}, {
|
|
444
|
+
key: "addAccounts",
|
|
445
|
+
value: function () {
|
|
446
|
+
var _addAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(accounts, extra) {
|
|
447
|
+
var res, _iterator, _step, account, accountModule, accountData;
|
|
448
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
449
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
450
|
+
case 0:
|
|
451
|
+
if (!((extra === null || extra === void 0 ? void 0 : extra.type) === 'holder')) {
|
|
452
|
+
_context8.next = 3;
|
|
453
|
+
break;
|
|
454
|
+
}
|
|
455
|
+
this.store.accountList.addHolderAccounts(accounts, extra.customerId);
|
|
456
|
+
return _context8.abrupt("return");
|
|
457
|
+
case 3:
|
|
458
|
+
res = [];
|
|
459
|
+
_iterator = _createForOfIteratorHelper(accounts);
|
|
460
|
+
_context8.prev = 5;
|
|
461
|
+
_iterator.s();
|
|
462
|
+
case 7:
|
|
463
|
+
if ((_step = _iterator.n()).done) {
|
|
464
|
+
_context8.next = 16;
|
|
465
|
+
break;
|
|
466
|
+
}
|
|
467
|
+
account = _step.value;
|
|
468
|
+
_context8.next = 11;
|
|
469
|
+
return this.store.accountList.addAccount(account);
|
|
470
|
+
case 11:
|
|
471
|
+
accountModule = _context8.sent;
|
|
472
|
+
accountData = accountModule.getAccount();
|
|
473
|
+
if (accountData) {
|
|
474
|
+
res.push(accountData);
|
|
475
|
+
}
|
|
476
|
+
case 14:
|
|
477
|
+
_context8.next = 7;
|
|
478
|
+
break;
|
|
479
|
+
case 16:
|
|
480
|
+
_context8.next = 21;
|
|
481
|
+
break;
|
|
482
|
+
case 18:
|
|
483
|
+
_context8.prev = 18;
|
|
484
|
+
_context8.t0 = _context8["catch"](5);
|
|
485
|
+
_iterator.e(_context8.t0);
|
|
486
|
+
case 21:
|
|
487
|
+
_context8.prev = 21;
|
|
488
|
+
_iterator.f();
|
|
489
|
+
return _context8.finish(21);
|
|
490
|
+
case 24:
|
|
491
|
+
return _context8.abrupt("return", res);
|
|
492
|
+
case 25:
|
|
493
|
+
case "end":
|
|
494
|
+
return _context8.stop();
|
|
495
|
+
}
|
|
496
|
+
}, _callee8, this, [[5, 18, 21, 24]]);
|
|
497
|
+
}));
|
|
498
|
+
function addAccounts(_x9, _x10) {
|
|
499
|
+
return _addAccounts.apply(this, arguments);
|
|
500
|
+
}
|
|
501
|
+
return addAccounts;
|
|
267
502
|
}() // 获取所有账户
|
|
268
503
|
}, {
|
|
269
504
|
key: "getAccounts",
|
|
270
505
|
value: function () {
|
|
271
|
-
var _getAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
506
|
+
var _getAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
272
507
|
var accounts;
|
|
273
|
-
return _regeneratorRuntime().wrap(function
|
|
274
|
-
while (1) switch (
|
|
508
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
509
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
275
510
|
case 0:
|
|
276
511
|
accounts = this.store.accountList.getAccounts();
|
|
277
|
-
return
|
|
512
|
+
return _context9.abrupt("return", accounts.map(function (account) {
|
|
278
513
|
return account.getAccount();
|
|
279
514
|
}));
|
|
280
515
|
case 2:
|
|
281
516
|
case "end":
|
|
282
|
-
return
|
|
517
|
+
return _context9.stop();
|
|
283
518
|
}
|
|
284
|
-
},
|
|
519
|
+
}, _callee9, this);
|
|
285
520
|
}));
|
|
286
521
|
function getAccounts() {
|
|
287
522
|
return _getAccounts.apply(this, arguments);
|
|
@@ -315,22 +550,45 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
315
550
|
this.clearCartByAccount(id);
|
|
316
551
|
}
|
|
317
552
|
|
|
318
|
-
|
|
553
|
+
/**
|
|
554
|
+
* 获取holder类型账户列表
|
|
555
|
+
* @param params
|
|
556
|
+
*/
|
|
557
|
+
}, {
|
|
558
|
+
key: "fetchHolderAccountsAsync",
|
|
559
|
+
value: (function () {
|
|
560
|
+
var _fetchHolderAccountsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
|
|
561
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
562
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
563
|
+
case 0:
|
|
564
|
+
return _context10.abrupt("return", this.store.accountList.fetchHolderAccounts(params));
|
|
565
|
+
case 1:
|
|
566
|
+
case "end":
|
|
567
|
+
return _context10.stop();
|
|
568
|
+
}
|
|
569
|
+
}, _callee10, this);
|
|
570
|
+
}));
|
|
571
|
+
function fetchHolderAccountsAsync(_x11) {
|
|
572
|
+
return _fetchHolderAccountsAsync.apply(this, arguments);
|
|
573
|
+
}
|
|
574
|
+
return fetchHolderAccountsAsync;
|
|
575
|
+
}() // 设置日期范围,注入到日期模块中
|
|
576
|
+
)
|
|
319
577
|
}, {
|
|
320
578
|
key: "setDateRange",
|
|
321
579
|
value: function () {
|
|
322
|
-
var _setDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
323
|
-
return _regeneratorRuntime().wrap(function
|
|
324
|
-
while (1) switch (
|
|
580
|
+
var _setDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(dateRange) {
|
|
581
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
582
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
325
583
|
case 0:
|
|
326
584
|
this.store.date.setDateRange(dateRange);
|
|
327
585
|
case 1:
|
|
328
586
|
case "end":
|
|
329
|
-
return
|
|
587
|
+
return _context11.stop();
|
|
330
588
|
}
|
|
331
|
-
},
|
|
589
|
+
}, _callee11, this);
|
|
332
590
|
}));
|
|
333
|
-
function setDateRange(
|
|
591
|
+
function setDateRange(_x12) {
|
|
334
592
|
return _setDateRange.apply(this, arguments);
|
|
335
593
|
}
|
|
336
594
|
return setDateRange;
|
|
@@ -345,16 +603,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
345
603
|
}, {
|
|
346
604
|
key: "getDateRange",
|
|
347
605
|
value: function () {
|
|
348
|
-
var _getDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
349
|
-
return _regeneratorRuntime().wrap(function
|
|
350
|
-
while (1) switch (
|
|
606
|
+
var _getDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
607
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
608
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
351
609
|
case 0:
|
|
352
|
-
return
|
|
610
|
+
return _context12.abrupt("return", this.store.date.getDateRange());
|
|
353
611
|
case 1:
|
|
354
612
|
case "end":
|
|
355
|
-
return
|
|
613
|
+
return _context12.stop();
|
|
356
614
|
}
|
|
357
|
-
},
|
|
615
|
+
}, _callee12, this);
|
|
358
616
|
}));
|
|
359
617
|
function getDateRange() {
|
|
360
618
|
return _getDateRange.apply(this, arguments);
|
|
@@ -371,59 +629,80 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
371
629
|
}, {
|
|
372
630
|
key: "getAvailableDate",
|
|
373
631
|
value: function () {
|
|
374
|
-
var _getAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
375
|
-
var
|
|
632
|
+
var _getAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
633
|
+
var _this3 = this;
|
|
376
634
|
var params,
|
|
377
635
|
products,
|
|
378
636
|
startDate,
|
|
379
637
|
endDate,
|
|
638
|
+
type,
|
|
380
639
|
tempProducts,
|
|
640
|
+
dateRange,
|
|
381
641
|
tempStartDate,
|
|
382
642
|
tempEndDate,
|
|
383
|
-
|
|
643
|
+
_ref5,
|
|
384
644
|
resourceIds,
|
|
385
645
|
rules,
|
|
386
646
|
resourcesMap,
|
|
387
647
|
res,
|
|
388
|
-
|
|
389
|
-
return _regeneratorRuntime().wrap(function
|
|
390
|
-
while (1) switch (
|
|
648
|
+
_args13 = arguments;
|
|
649
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
650
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
391
651
|
case 0:
|
|
392
|
-
params =
|
|
652
|
+
params = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : {};
|
|
393
653
|
// 开始日期如果小于今天,直接以今天当做开始日期
|
|
394
|
-
products = params.products, startDate = params.startDate, endDate = params.endDate;
|
|
654
|
+
products = params.products, startDate = params.startDate, endDate = params.endDate, type = params.type; // 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天 且 endDate 小于或等于今天,需要把 startDate 置为今天
|
|
655
|
+
if (dayjs(startDate).isBefore(dayjs(), 'day') && (dayjs(endDate).isAfter(dayjs(), 'day') || dayjs(endDate).isSame(dayjs(), 'day'))) {
|
|
656
|
+
startDate = dayjs().format('YYYY-MM-DD');
|
|
657
|
+
}
|
|
395
658
|
tempProducts = products || this.store.cart.getItems().map(function (p) {
|
|
396
659
|
return p._productOrigin;
|
|
397
660
|
});
|
|
398
|
-
tempStartDate = startDate || ((_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 || (_this$otherParams3 = _this$otherParams3.dateRange) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3[0]);
|
|
399
|
-
tempEndDate = endDate || ((_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 || (_this$otherParams4 = _this$otherParams4.dateRange) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4[1]);
|
|
400
661
|
if (tempProducts.length) {
|
|
401
|
-
|
|
662
|
+
tempProducts.forEach(function (p) {
|
|
663
|
+
if (p !== null && p !== void 0 && p['schedule.ids']) {
|
|
664
|
+
var scheduleData = _this3.getScheduleDataByIds(p['schedule.ids']);
|
|
665
|
+
p['_schedule'] = scheduleData;
|
|
666
|
+
}
|
|
667
|
+
});
|
|
668
|
+
}
|
|
669
|
+
// 如果当前打开了某个的商品详情弹窗,则应该默认用这个商品
|
|
670
|
+
if (this.store.currentProduct) {
|
|
671
|
+
tempProducts = [_objectSpread(_objectSpread({}, this.store.currentProduct.getData()), {}, {
|
|
672
|
+
_schedule: this.store.currentProduct.getOtherParams()['schedule']
|
|
673
|
+
})];
|
|
674
|
+
}
|
|
675
|
+
dateRange = this.store.date.getDateRange();
|
|
676
|
+
tempStartDate = startDate || (dateRange === null || dateRange === void 0 ? void 0 : dateRange[0].date);
|
|
677
|
+
tempEndDate = endDate || (dateRange === null || dateRange === void 0 ? void 0 : dateRange[1].date);
|
|
678
|
+
if (tempProducts.length) {
|
|
679
|
+
_context13.next = 11;
|
|
402
680
|
break;
|
|
403
681
|
}
|
|
404
|
-
return
|
|
405
|
-
case
|
|
682
|
+
return _context13.abrupt("return", []);
|
|
683
|
+
case 11:
|
|
406
684
|
// 在这里需要把能收集到的数据都收集上来,拼装好给 date 模块去查询
|
|
407
|
-
|
|
408
|
-
console.log("resourceIds", tempProducts);
|
|
685
|
+
_ref5 = getAvailableProductResources(tempProducts) || {}, resourceIds = _ref5.resourceIds, rules = _ref5.rules, resourcesMap = _ref5.resourcesMap;
|
|
409
686
|
this.otherParams.currentResourcesMap = resourcesMap;
|
|
410
|
-
|
|
411
|
-
return this.store.date.
|
|
687
|
+
_context13.next = 15;
|
|
688
|
+
return this.store.date.getResourceDates({
|
|
689
|
+
url: params.url,
|
|
412
690
|
query: {
|
|
413
691
|
start_date: tempStartDate,
|
|
414
692
|
end_date: tempEndDate,
|
|
415
693
|
resource_ids: resourceIds
|
|
416
694
|
},
|
|
417
|
-
rules: rules
|
|
695
|
+
rules: rules,
|
|
696
|
+
type: type
|
|
418
697
|
});
|
|
419
|
-
case
|
|
420
|
-
res =
|
|
421
|
-
return
|
|
422
|
-
case
|
|
698
|
+
case 15:
|
|
699
|
+
res = _context13.sent;
|
|
700
|
+
return _context13.abrupt("return", res);
|
|
701
|
+
case 17:
|
|
423
702
|
case "end":
|
|
424
|
-
return
|
|
703
|
+
return _context13.stop();
|
|
425
704
|
}
|
|
426
|
-
},
|
|
705
|
+
}, _callee13, this);
|
|
427
706
|
}));
|
|
428
707
|
function getAvailableDate() {
|
|
429
708
|
return _getAvailableDate.apply(this, arguments);
|
|
@@ -436,42 +715,65 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
436
715
|
}, {
|
|
437
716
|
key: "getSummary",
|
|
438
717
|
value: (function () {
|
|
439
|
-
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
718
|
+
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
440
719
|
var cartItems, summary;
|
|
441
|
-
return _regeneratorRuntime().wrap(function
|
|
442
|
-
while (1) switch (
|
|
720
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
721
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
443
722
|
case 0:
|
|
444
723
|
cartItems = this.store.cart.getItems();
|
|
445
|
-
|
|
724
|
+
_context14.next = 3;
|
|
446
725
|
return this.store.summary.getSummary(cartItems);
|
|
447
726
|
case 3:
|
|
448
|
-
summary =
|
|
449
|
-
return
|
|
727
|
+
summary = _context14.sent;
|
|
728
|
+
return _context14.abrupt("return", summary);
|
|
450
729
|
case 5:
|
|
451
730
|
case "end":
|
|
452
|
-
return
|
|
731
|
+
return _context14.stop();
|
|
453
732
|
}
|
|
454
|
-
},
|
|
733
|
+
}, _callee14, this);
|
|
455
734
|
}));
|
|
456
735
|
function getSummary() {
|
|
457
736
|
return _getSummary.apply(this, arguments);
|
|
458
737
|
}
|
|
459
738
|
return getSummary;
|
|
739
|
+
}()
|
|
740
|
+
/**
|
|
741
|
+
* 获取协议
|
|
742
|
+
*/
|
|
743
|
+
)
|
|
744
|
+
}, {
|
|
745
|
+
key: "getProtocol",
|
|
746
|
+
value: (function () {
|
|
747
|
+
var _getProtocol = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(protocolId) {
|
|
748
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
749
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
750
|
+
case 0:
|
|
751
|
+
return _context15.abrupt("return", this.store.summary.getProtocol(protocolId));
|
|
752
|
+
case 1:
|
|
753
|
+
case "end":
|
|
754
|
+
return _context15.stop();
|
|
755
|
+
}
|
|
756
|
+
}, _callee15, this);
|
|
757
|
+
}));
|
|
758
|
+
function getProtocol(_x13) {
|
|
759
|
+
return _getProtocol.apply(this, arguments);
|
|
760
|
+
}
|
|
761
|
+
return getProtocol;
|
|
460
762
|
}() // 获取可选择的商品、服务列表
|
|
461
763
|
)
|
|
462
764
|
}, {
|
|
463
765
|
key: "getProducts",
|
|
464
766
|
value: function () {
|
|
465
|
-
var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
466
|
-
return _regeneratorRuntime().wrap(function
|
|
467
|
-
while (1) switch (
|
|
767
|
+
var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
768
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
769
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
468
770
|
case 0:
|
|
469
|
-
return
|
|
771
|
+
return _context16.abrupt("return", this.store.products.getProducts());
|
|
470
772
|
case 1:
|
|
471
773
|
case "end":
|
|
472
|
-
return
|
|
774
|
+
return _context16.stop();
|
|
473
775
|
}
|
|
474
|
-
},
|
|
776
|
+
}, _callee16, this);
|
|
475
777
|
}));
|
|
476
778
|
function getProducts() {
|
|
477
779
|
return _getProducts.apply(this, arguments);
|
|
@@ -481,15 +783,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
481
783
|
}, {
|
|
482
784
|
key: "setLoginAccount",
|
|
483
785
|
value: function () {
|
|
484
|
-
var _setLoginAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
786
|
+
var _setLoginAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(accountId, accountInfo) {
|
|
485
787
|
var _this4 = this;
|
|
486
788
|
var account, stateAccountId, cartItems;
|
|
487
|
-
return _regeneratorRuntime().wrap(function
|
|
488
|
-
while (1) switch (
|
|
789
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
790
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
489
791
|
case 0:
|
|
490
792
|
account = this.store.accountList.getAccount(accountId);
|
|
491
793
|
if (!account) {
|
|
492
|
-
|
|
794
|
+
_context17.next = 9;
|
|
493
795
|
break;
|
|
494
796
|
}
|
|
495
797
|
stateAccountId = account.getId();
|
|
@@ -505,17 +807,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
505
807
|
}
|
|
506
808
|
});
|
|
507
809
|
this.store.accountList.updateAccountListById(stateAccountId, accountInfo);
|
|
508
|
-
|
|
810
|
+
_context17.next = 10;
|
|
509
811
|
break;
|
|
510
812
|
case 9:
|
|
511
813
|
throw new Error("\u6CA1\u6709\u627E\u5230".concat(accountId, "\u8D26\u6237"));
|
|
512
814
|
case 10:
|
|
513
815
|
case "end":
|
|
514
|
-
return
|
|
816
|
+
return _context17.stop();
|
|
515
817
|
}
|
|
516
|
-
},
|
|
818
|
+
}, _callee17, this);
|
|
517
819
|
}));
|
|
518
|
-
function setLoginAccount(
|
|
820
|
+
function setLoginAccount(_x14, _x15) {
|
|
519
821
|
return _setLoginAccount.apply(this, arguments);
|
|
520
822
|
}
|
|
521
823
|
return setLoginAccount;
|
|
@@ -523,14 +825,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
523
825
|
}, {
|
|
524
826
|
key: "generateCartData",
|
|
525
827
|
value: function () {
|
|
526
|
-
var _generateCartData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
527
|
-
return _regeneratorRuntime().wrap(function
|
|
528
|
-
while (1) switch (
|
|
828
|
+
var _generateCartData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
829
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
830
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
529
831
|
case 0:
|
|
530
832
|
case "end":
|
|
531
|
-
return
|
|
833
|
+
return _context18.stop();
|
|
532
834
|
}
|
|
533
|
-
},
|
|
835
|
+
}, _callee18);
|
|
534
836
|
}));
|
|
535
837
|
function generateCartData() {
|
|
536
838
|
return _generateCartData.apply(this, arguments);
|
|
@@ -540,38 +842,54 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
540
842
|
}, {
|
|
541
843
|
key: "getFreeProduct",
|
|
542
844
|
value: function () {
|
|
543
|
-
var _getFreeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
845
|
+
var _getFreeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(id) {
|
|
544
846
|
var res;
|
|
545
|
-
return _regeneratorRuntime().wrap(function
|
|
546
|
-
while (1) switch (
|
|
847
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
848
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
547
849
|
case 0:
|
|
548
|
-
|
|
850
|
+
_context19.next = 2;
|
|
549
851
|
return this.request.post("/pay/order/free-pay/".concat(id));
|
|
550
852
|
case 2:
|
|
551
|
-
res =
|
|
552
|
-
return
|
|
853
|
+
res = _context19.sent;
|
|
854
|
+
return _context19.abrupt("return", res);
|
|
553
855
|
case 4:
|
|
554
856
|
case "end":
|
|
555
|
-
return
|
|
857
|
+
return _context19.stop();
|
|
556
858
|
}
|
|
557
|
-
},
|
|
859
|
+
}, _callee19, this);
|
|
558
860
|
}));
|
|
559
|
-
function getFreeProduct(
|
|
861
|
+
function getFreeProduct(_x16) {
|
|
560
862
|
return _getFreeProduct.apply(this, arguments);
|
|
561
863
|
}
|
|
562
864
|
return getFreeProduct;
|
|
563
|
-
}()
|
|
865
|
+
}()
|
|
866
|
+
/**
|
|
867
|
+
* 检查购物车提交订单前是否符合条件
|
|
868
|
+
* @param type 类型 "holder" | "account"
|
|
869
|
+
* @returns boolean
|
|
870
|
+
*/
|
|
871
|
+
}, {
|
|
872
|
+
key: "checkBeforeSubmitOrder",
|
|
873
|
+
value: function checkBeforeSubmitOrder(type) {
|
|
874
|
+
return this.store.order.checkBeforeSubmitOrder({
|
|
875
|
+
type: type,
|
|
876
|
+
cartItems: this.store.cart.getItems()
|
|
877
|
+
});
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
// 购物车提交订单
|
|
564
881
|
}, {
|
|
565
882
|
key: "submitOrder",
|
|
566
883
|
value: function () {
|
|
567
|
-
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
884
|
+
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
568
885
|
var cartItems, newCartItems;
|
|
569
|
-
return _regeneratorRuntime().wrap(function
|
|
570
|
-
while (1) switch (
|
|
886
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
887
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
571
888
|
case 0:
|
|
572
889
|
cartItems = this.store.cart.getItems();
|
|
573
890
|
newCartItems = cloneDeep(cartItems); // 先整个临时的逻辑,把购物车里所有商品的资源给他格式化一下
|
|
574
891
|
newCartItems.forEach(function (item) {
|
|
892
|
+
var _item$_productOrigin, _item$_origin;
|
|
575
893
|
item._origin.resources = item._origin.resources.map(function (n) {
|
|
576
894
|
var newResourcesItem = cloneDeep(n);
|
|
577
895
|
delete newResourcesItem.id;
|
|
@@ -579,17 +897,29 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
579
897
|
delete newResourcesItem.resourceType;
|
|
580
898
|
return _objectSpread({}, newResourcesItem);
|
|
581
899
|
});
|
|
900
|
+
var formatCapacity = formatDefaultCapacitys({
|
|
901
|
+
capacity: (_item$_productOrigin = item._productOrigin) === null || _item$_productOrigin === void 0 ? void 0 : _item$_productOrigin.capacity,
|
|
902
|
+
product_bundle: item._origin.product.product_bundle
|
|
903
|
+
});
|
|
904
|
+
var currentCapacity = getSumCapacity({
|
|
905
|
+
capacity: formatCapacity
|
|
906
|
+
});
|
|
907
|
+
if (!((_item$_origin = item._origin) !== null && _item$_origin !== void 0 && _item$_origin.metadata)) {
|
|
908
|
+
item._origin.metadata = {};
|
|
909
|
+
}
|
|
910
|
+
item._origin.metadata.capacity = formatCapacity;
|
|
911
|
+
item._origin.number = currentCapacity;
|
|
582
912
|
});
|
|
583
|
-
return
|
|
913
|
+
return _context20.abrupt("return", this.store.order.submitOrder({
|
|
584
914
|
query: {
|
|
585
915
|
cartItems: newCartItems
|
|
586
916
|
}
|
|
587
917
|
}));
|
|
588
918
|
case 4:
|
|
589
919
|
case "end":
|
|
590
|
-
return
|
|
920
|
+
return _context20.stop();
|
|
591
921
|
}
|
|
592
|
-
},
|
|
922
|
+
}, _callee20, this);
|
|
593
923
|
}));
|
|
594
924
|
function submitOrder() {
|
|
595
925
|
return _submitOrder.apply(this, arguments);
|
|
@@ -599,14 +929,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
599
929
|
}, {
|
|
600
930
|
key: "pay",
|
|
601
931
|
value: function () {
|
|
602
|
-
var _pay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
603
|
-
return _regeneratorRuntime().wrap(function
|
|
604
|
-
while (1) switch (
|
|
932
|
+
var _pay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
|
933
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
934
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
605
935
|
case 0:
|
|
606
936
|
case "end":
|
|
607
|
-
return
|
|
937
|
+
return _context21.stop();
|
|
608
938
|
}
|
|
609
|
-
},
|
|
939
|
+
}, _callee21);
|
|
610
940
|
}));
|
|
611
941
|
function pay() {
|
|
612
942
|
return _pay.apply(this, arguments);
|
|
@@ -616,14 +946,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
616
946
|
}, {
|
|
617
947
|
key: "getPayInfo",
|
|
618
948
|
value: function () {
|
|
619
|
-
var _getPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
620
|
-
return _regeneratorRuntime().wrap(function
|
|
621
|
-
while (1) switch (
|
|
949
|
+
var _getPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
|
|
950
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
951
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
622
952
|
case 0:
|
|
623
953
|
case "end":
|
|
624
|
-
return
|
|
954
|
+
return _context22.stop();
|
|
625
955
|
}
|
|
626
|
-
},
|
|
956
|
+
}, _callee22);
|
|
627
957
|
}));
|
|
628
958
|
function getPayInfo() {
|
|
629
959
|
return _getPayInfo.apply(this, arguments);
|
|
@@ -633,15 +963,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
633
963
|
}, {
|
|
634
964
|
key: "setOtherParams",
|
|
635
965
|
value: function () {
|
|
636
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
637
|
-
var
|
|
638
|
-
|
|
966
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
|
|
967
|
+
var _ref6,
|
|
968
|
+
_ref6$cover,
|
|
639
969
|
cover,
|
|
640
|
-
|
|
641
|
-
return _regeneratorRuntime().wrap(function
|
|
642
|
-
while (1) switch (
|
|
970
|
+
_args23 = arguments;
|
|
971
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
972
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
643
973
|
case 0:
|
|
644
|
-
|
|
974
|
+
_ref6 = _args23.length > 1 && _args23[1] !== undefined ? _args23[1] : {}, _ref6$cover = _ref6.cover, cover = _ref6$cover === void 0 ? false : _ref6$cover;
|
|
645
975
|
if (cover) {
|
|
646
976
|
this.otherParams = params;
|
|
647
977
|
} else {
|
|
@@ -649,11 +979,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
649
979
|
}
|
|
650
980
|
case 2:
|
|
651
981
|
case "end":
|
|
652
|
-
return
|
|
982
|
+
return _context23.stop();
|
|
653
983
|
}
|
|
654
|
-
},
|
|
984
|
+
}, _callee23, this);
|
|
655
985
|
}));
|
|
656
|
-
function setOtherParams(
|
|
986
|
+
function setOtherParams(_x17) {
|
|
657
987
|
return _setOtherParams.apply(this, arguments);
|
|
658
988
|
}
|
|
659
989
|
return setOtherParams;
|
|
@@ -661,16 +991,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
661
991
|
}, {
|
|
662
992
|
key: "getOtherParams",
|
|
663
993
|
value: function () {
|
|
664
|
-
var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
665
|
-
return _regeneratorRuntime().wrap(function
|
|
666
|
-
while (1) switch (
|
|
994
|
+
var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
995
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
996
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
667
997
|
case 0:
|
|
668
|
-
return
|
|
998
|
+
return _context24.abrupt("return", this.otherParams);
|
|
669
999
|
case 1:
|
|
670
1000
|
case "end":
|
|
671
|
-
return
|
|
1001
|
+
return _context24.stop();
|
|
672
1002
|
}
|
|
673
|
-
},
|
|
1003
|
+
}, _callee24, this);
|
|
674
1004
|
}));
|
|
675
1005
|
function getOtherParams() {
|
|
676
1006
|
return _getOtherParams.apply(this, arguments);
|
|
@@ -681,25 +1011,41 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
681
1011
|
key: "updateCart",
|
|
682
1012
|
value: function updateCart(params) {
|
|
683
1013
|
var _this5 = this;
|
|
1014
|
+
var targetCartItem = this.store.cart.getItem(params._id);
|
|
1015
|
+
if (!targetCartItem) {
|
|
1016
|
+
throw new Error("\u6CA1\u6709\u627E\u5230".concat(params._id, "\u8D2D\u7269\u8F66\u5546\u54C1"));
|
|
1017
|
+
}
|
|
684
1018
|
if (params.resources) {
|
|
1019
|
+
var _targetCartItem$_prod;
|
|
1020
|
+
var formatCapacity = formatDefaultCapacitys({
|
|
1021
|
+
capacity: (_targetCartItem$_prod = targetCartItem._productOrigin) === null || _targetCartItem$_prod === void 0 ? void 0 : _targetCartItem$_prod.capacity,
|
|
1022
|
+
product_bundle: targetCartItem._origin.product.product_bundle
|
|
1023
|
+
});
|
|
1024
|
+
var currentCapacity = getSumCapacity({
|
|
1025
|
+
capacity: formatCapacity
|
|
1026
|
+
});
|
|
685
1027
|
params.resources = params.resources.map(function (n) {
|
|
686
|
-
n.capacity = 1;
|
|
1028
|
+
n.capacity = currentCapacity || 1;
|
|
1029
|
+
checkSubResourcesCapacity(n);
|
|
687
1030
|
return n;
|
|
688
1031
|
});
|
|
689
1032
|
}
|
|
690
1033
|
this.store.cart.updateItem(params);
|
|
691
|
-
var targetCartItem = this.store.cart.getItem(params._id);
|
|
692
|
-
if (!targetCartItem) {
|
|
693
|
-
throw new Error("\u6CA1\u6709\u627E\u5230".concat(params._id, "\u8D2D\u7269\u8F66\u5546\u54C1"));
|
|
694
|
-
}
|
|
695
1034
|
// 更新购物车后,需要判定购物车里是否存在多个账号选择了相同资源的情况,如果是,则要把选择了相同资源的 product._origin.resources 给去除
|
|
696
1035
|
var cartItems = this.store.cart.getItems();
|
|
697
1036
|
cartItems.forEach(function (item) {
|
|
698
1037
|
if (item.holder_id !== (targetCartItem === null || targetCartItem === void 0 ? void 0 : targetCartItem.holder_id)) {
|
|
699
1038
|
var _item$_origin$resourc;
|
|
700
1039
|
var resources = (_item$_origin$resourc = item._origin.resources) === null || _item$_origin$resourc === void 0 ? void 0 : _item$_origin$resourc.filter(function (m) {
|
|
1040
|
+
// 检查当前资源是否与目标资源的任何资源匹配
|
|
701
1041
|
return !targetCartItem._origin.resources.some(function (targetRes) {
|
|
702
|
-
|
|
1042
|
+
var _targetRes$metadata$c, _m$metadata$combined_;
|
|
1043
|
+
// 检查主资源ID是否匹配
|
|
1044
|
+
if (targetRes.id === m.id) return true;
|
|
1045
|
+
// 检查组合资源的情况
|
|
1046
|
+
if (((_targetRes$metadata$c = targetRes.metadata.combined_resource) === null || _targetRes$metadata$c === void 0 ? void 0 : _targetRes$metadata$c.status) === 1 && targetRes.metadata.combined_resource.resource_ids.includes(m.id)) return true;
|
|
1047
|
+
if (((_m$metadata$combined_ = m.metadata.combined_resource) === null || _m$metadata$combined_ === void 0 ? void 0 : _m$metadata$combined_.status) === 1 && m.metadata.combined_resource.resource_ids.includes(targetRes.id)) return true;
|
|
1048
|
+
return false;
|
|
703
1049
|
});
|
|
704
1050
|
});
|
|
705
1051
|
_this5.store.cart.updateItem({
|
|
@@ -751,8 +1097,33 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
751
1097
|
*/
|
|
752
1098
|
}, {
|
|
753
1099
|
key: "deleteCartItemInfo",
|
|
754
|
-
value: function deleteCartItemInfo(
|
|
755
|
-
this.store.cart.deleteCartItemInfo(
|
|
1100
|
+
value: function deleteCartItemInfo(type, _id) {
|
|
1101
|
+
this.store.cart.deleteCartItemInfo(type, _id);
|
|
1102
|
+
}
|
|
1103
|
+
}, {
|
|
1104
|
+
key: "checkCartItemByType",
|
|
1105
|
+
value: function checkCartItemByType(cartItem, type) {
|
|
1106
|
+
return this.store.cart.checkCartItemByType(cartItem, type);
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
/**
|
|
1110
|
+
* 检查购物车商品是否符合条件
|
|
1111
|
+
* @param type 类型
|
|
1112
|
+
* @returns 不符合条件的购物车商品ID列表
|
|
1113
|
+
*/
|
|
1114
|
+
}, {
|
|
1115
|
+
key: "checkCartItems",
|
|
1116
|
+
value: function checkCartItems(type) {
|
|
1117
|
+
var _this7 = this;
|
|
1118
|
+
var cartItems = this.store.cart.getItems();
|
|
1119
|
+
var errorCartItemIds = [];
|
|
1120
|
+
cartItems.forEach(function (cartItem) {
|
|
1121
|
+
var result = _this7.store.cart.checkCartItemByType(cartItem, type);
|
|
1122
|
+
if (!result) {
|
|
1123
|
+
errorCartItemIds.push(cartItem._id);
|
|
1124
|
+
}
|
|
1125
|
+
});
|
|
1126
|
+
return errorCartItemIds;
|
|
756
1127
|
}
|
|
757
1128
|
}, {
|
|
758
1129
|
key: "destroy",
|
|
@@ -774,14 +1145,78 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
774
1145
|
value: function getResourcesList() {
|
|
775
1146
|
var dateRange = this.store.date.getDateRange();
|
|
776
1147
|
var resources = [];
|
|
777
|
-
dateRange.
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
1148
|
+
if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
|
|
1149
|
+
dateRange.forEach(function (n) {
|
|
1150
|
+
if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
|
|
1151
|
+
});
|
|
1152
|
+
}
|
|
1153
|
+
// 如果此时 resources 为空,视作购物车里已经有了 dateRange 数据,此时 dateList 里明确就是那一天的数据
|
|
1154
|
+
if (!resources.length) {
|
|
1155
|
+
var dateList = this.store.date.getDateList();
|
|
1156
|
+
dateList.forEach(function (n) {
|
|
1157
|
+
if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
|
|
1158
|
+
});
|
|
1159
|
+
}
|
|
1160
|
+
var resourcesMap = getResourcesMap(cloneDeep(resources));
|
|
781
1161
|
var cartItems = this.store.cart.getItems();
|
|
782
1162
|
var arr = [];
|
|
1163
|
+
var capacityMap = {};
|
|
783
1164
|
cartItems.forEach(function (cartItem) {
|
|
784
|
-
var
|
|
1165
|
+
var _cartItem$_productOri, _cartItem$_productOri2;
|
|
1166
|
+
var selectedResources = [];
|
|
1167
|
+
if (cartItem.holder_id) {
|
|
1168
|
+
selectedResources = getOthersSelectedResources(cartItems, cartItem.holder_id, resourcesMap);
|
|
1169
|
+
} else {
|
|
1170
|
+
selectedResources = getOthersCartSelectedResources(cartItems, cartItem._id, resourcesMap);
|
|
1171
|
+
}
|
|
1172
|
+
var formatCapacity = formatDefaultCapacitys({
|
|
1173
|
+
capacity: (_cartItem$_productOri = cartItem._productOrigin) === null || _cartItem$_productOri === void 0 ? void 0 : _cartItem$_productOri.capacity,
|
|
1174
|
+
product_bundle: cartItem._origin.product.product_bundle
|
|
1175
|
+
});
|
|
1176
|
+
cartItem._origin.metadata.capacity = formatCapacity;
|
|
1177
|
+
var currentCapacity = getSumCapacity({
|
|
1178
|
+
capacity: formatCapacity
|
|
1179
|
+
});
|
|
1180
|
+
var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri2 = cartItem._productOrigin) === null || _cartItem$_productOri2 === void 0 || (_cartItem$_productOri2 = _cartItem$_productOri2.product_resource) === null || _cartItem$_productOri2 === void 0 ? void 0 : _cartItem$_productOri2.resources) || [], selectedResources, currentCapacity);
|
|
1181
|
+
// 如果购物车里已经有了时间片,则需要按照时间片过滤
|
|
1182
|
+
if (cartItem._origin.start_time) {
|
|
1183
|
+
var startTime = dayjs("".concat(cartItem._origin.start_date, " ").concat(cartItem._origin.start_time));
|
|
1184
|
+
var endTime = dayjs("".concat(cartItem._origin.end_date, " ").concat(cartItem._origin.end_time));
|
|
1185
|
+
var resourcesUseableMap = {};
|
|
1186
|
+
productResources.forEach(function (n) {
|
|
1187
|
+
// 资源排下序,把单个资源靠前,组合资源排在后面
|
|
1188
|
+
n.renderList = n.renderList.sort(function (a, b) {
|
|
1189
|
+
var _a$metadata, _b$metadata;
|
|
1190
|
+
var aIsCombined = ((_a$metadata = a.metadata) === null || _a$metadata === void 0 || (_a$metadata = _a$metadata.combined_resource) === null || _a$metadata === void 0 ? void 0 : _a$metadata.status) === 1;
|
|
1191
|
+
var bIsCombined = ((_b$metadata = b.metadata) === null || _b$metadata === void 0 || (_b$metadata = _b$metadata.combined_resource) === null || _b$metadata === void 0 ? void 0 : _b$metadata.status) === 1;
|
|
1192
|
+
if (aIsCombined && !bIsCombined) return 1;
|
|
1193
|
+
if (!aIsCombined && bIsCombined) return -1;
|
|
1194
|
+
return 0;
|
|
1195
|
+
});
|
|
1196
|
+
n.renderList = n.renderList.filter(function (m) {
|
|
1197
|
+
var recordCount = capacityMap[m.id] || 0;
|
|
1198
|
+
var canUseTime = m.times.find(function (item) {
|
|
1199
|
+
var res = getIsUsableByTimeItem({
|
|
1200
|
+
timeSlice: {
|
|
1201
|
+
start_time: startTime.format('HH:mm'),
|
|
1202
|
+
end_time: endTime.format('HH:mm'),
|
|
1203
|
+
start_at: startTime,
|
|
1204
|
+
end_at: endTime
|
|
1205
|
+
},
|
|
1206
|
+
time: item,
|
|
1207
|
+
resource: m,
|
|
1208
|
+
currentCount: recordCount + (currentCapacity || 0),
|
|
1209
|
+
resourcesUseableMap: resourcesUseableMap
|
|
1210
|
+
});
|
|
1211
|
+
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false) {
|
|
1212
|
+
resourcesUseableMap[m.id] = res.usable;
|
|
1213
|
+
}
|
|
1214
|
+
return res.usable;
|
|
1215
|
+
});
|
|
1216
|
+
return canUseTime;
|
|
1217
|
+
});
|
|
1218
|
+
});
|
|
1219
|
+
}
|
|
785
1220
|
arr.push({
|
|
786
1221
|
id: cartItem.id,
|
|
787
1222
|
// 这里返回的是购物车 id ,后面提交的时候要用的,用这个 id 绑定资源和时间
|
|
@@ -800,21 +1235,36 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
800
1235
|
}, {
|
|
801
1236
|
key: "getResourcesListByCartItem",
|
|
802
1237
|
value: function getResourcesListByCartItem(id) {
|
|
803
|
-
var
|
|
1238
|
+
var _targetCartItem$_prod2, _targetCartItem$_prod3;
|
|
1239
|
+
var cartItems = cloneDeep(this.store.cart.getItems());
|
|
804
1240
|
var dateRange = this.store.date.getDateRange();
|
|
805
1241
|
var resources = [];
|
|
806
1242
|
dateRange.forEach(function (n) {
|
|
807
1243
|
if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
|
|
808
1244
|
});
|
|
809
|
-
|
|
810
|
-
|
|
1245
|
+
// 这里为什么要 cloneDeep:因为 getOthersSelectedResources 和 getOthersCartSelectedResources 会修改 resourcesMap 的 capacity
|
|
1246
|
+
// 用于确保后续分配的容量不会超出
|
|
1247
|
+
var resourcesMap = getResourcesMap(cloneDeep(resources));
|
|
811
1248
|
var targetCartItem = cartItems.find(function (n) {
|
|
812
1249
|
return n._id === id;
|
|
813
1250
|
});
|
|
814
1251
|
if (!targetCartItem) {
|
|
815
1252
|
throw new Error("\u6CA1\u6709\u627E\u5230".concat(id, "\u8D2D\u7269\u8F66\u5546\u54C1"));
|
|
816
1253
|
}
|
|
817
|
-
var
|
|
1254
|
+
var selectedResources = [];
|
|
1255
|
+
if (targetCartItem.holder_id) {
|
|
1256
|
+
selectedResources = getOthersSelectedResources(cartItems, targetCartItem.holder_id, resourcesMap);
|
|
1257
|
+
} else {
|
|
1258
|
+
selectedResources = getOthersCartSelectedResources(cartItems, targetCartItem._id, resourcesMap);
|
|
1259
|
+
}
|
|
1260
|
+
var formatCapacity = formatDefaultCapacitys({
|
|
1261
|
+
capacity: (_targetCartItem$_prod2 = targetCartItem._productOrigin) === null || _targetCartItem$_prod2 === void 0 ? void 0 : _targetCartItem$_prod2.capacity,
|
|
1262
|
+
product_bundle: targetCartItem._origin.product.product_bundle
|
|
1263
|
+
});
|
|
1264
|
+
var currentCapacity = getSumCapacity({
|
|
1265
|
+
capacity: formatCapacity
|
|
1266
|
+
});
|
|
1267
|
+
var productResources = getResourcesByProduct(resourcesMap, ((_targetCartItem$_prod3 = targetCartItem._productOrigin) === null || _targetCartItem$_prod3 === void 0 || (_targetCartItem$_prod3 = _targetCartItem$_prod3.product_resource) === null || _targetCartItem$_prod3 === void 0 ? void 0 : _targetCartItem$_prod3.resources) || [], selectedResources, currentCapacity);
|
|
818
1268
|
if (productResources) {
|
|
819
1269
|
return {
|
|
820
1270
|
id: targetCartItem.id,
|
|
@@ -832,10 +1282,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
832
1282
|
// 通过资源列表和指定的资源 id,获取指定资源的时间切片
|
|
833
1283
|
}, {
|
|
834
1284
|
key: "getResourceTimeSlot",
|
|
835
|
-
value: function getResourceTimeSlot(
|
|
836
|
-
var product =
|
|
837
|
-
resources =
|
|
838
|
-
currentResourceId =
|
|
1285
|
+
value: function getResourceTimeSlot(_ref7) {
|
|
1286
|
+
var product = _ref7.product,
|
|
1287
|
+
resources = _ref7.resources,
|
|
1288
|
+
currentResourceId = _ref7.currentResourceId;
|
|
839
1289
|
var dateRange = this.store.date.getDateRange();
|
|
840
1290
|
var timeSlots = getTimeSlicesByResource({
|
|
841
1291
|
resource: resources.find(function (n) {
|
|
@@ -848,98 +1298,24 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
848
1298
|
return timeSlots;
|
|
849
1299
|
}
|
|
850
1300
|
|
|
851
|
-
// 自动分派可用的资源-单种资源类型
|
|
852
|
-
}, {
|
|
853
|
-
key: "autoSelectResource",
|
|
854
|
-
value: function autoSelectResource(_ref6) {
|
|
855
|
-
var resourceProductData = _ref6.resourceProductData,
|
|
856
|
-
resources = _ref6.resources,
|
|
857
|
-
timeSlots = _ref6.timeSlots;
|
|
858
|
-
var dateRange = this.store.date.getDateRange();
|
|
859
|
-
if (timeSlots) {
|
|
860
|
-
// 如果 start_time 存在,则直接根据 start_time 算出商品总共需要的时长,然后根据时长去匹配资源
|
|
861
|
-
// const duration = resourceProductData.product.duration.value;
|
|
862
|
-
// const start_time = timeSlots.start_at.format("YYYY-MM-DD HH:mm");
|
|
863
|
-
// const end_time = dayjs(`${dateRange[0].date} ${start_time}`)
|
|
864
|
-
// .add(duration, resourceProductData.product.duration.type)
|
|
865
|
-
// .format("HH:mm");
|
|
866
|
-
// 根据 start_time 和 end_time 去匹配资源
|
|
867
|
-
var targetResource = null;
|
|
868
|
-
var _iterator = _createForOfIteratorHelper(resources),
|
|
869
|
-
_step;
|
|
870
|
-
try {
|
|
871
|
-
var _loop = function _loop() {
|
|
872
|
-
var n = _step.value;
|
|
873
|
-
var canUseTime = n.times.find(function (item) {
|
|
874
|
-
var res = getIsUsableByTimeItem({
|
|
875
|
-
timeSlice: timeSlots,
|
|
876
|
-
time: item,
|
|
877
|
-
resource: n,
|
|
878
|
-
currentCount: 1
|
|
879
|
-
});
|
|
880
|
-
return res.usable;
|
|
881
|
-
});
|
|
882
|
-
if (canUseTime) {
|
|
883
|
-
targetResource = n;
|
|
884
|
-
return 1; // break
|
|
885
|
-
}
|
|
886
|
-
};
|
|
887
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
888
|
-
if (_loop()) break;
|
|
889
|
-
}
|
|
890
|
-
} catch (err) {
|
|
891
|
-
_iterator.e(err);
|
|
892
|
-
} finally {
|
|
893
|
-
_iterator.f();
|
|
894
|
-
}
|
|
895
|
-
return {
|
|
896
|
-
selectedResource: targetResource
|
|
897
|
-
};
|
|
898
|
-
} else {
|
|
899
|
-
// 如果没有传递 timeSlots,证明是第一个资源,则直接拿商品的 duration,到资源列表里找一个公共可用的
|
|
900
|
-
var duration = resourceProductData.product.duration.value;
|
|
901
|
-
var resourcesMap = getResourcesMap(resources);
|
|
902
|
-
var resourceIds = resources.map(function (n) {
|
|
903
|
-
return n.id;
|
|
904
|
-
});
|
|
905
|
-
var _timeSlots = getTimeSlicesByResources({
|
|
906
|
-
resourceIds: resourceIds,
|
|
907
|
-
resourcesMap: resourcesMap,
|
|
908
|
-
duration: duration,
|
|
909
|
-
currentDate: dateRange[0].date,
|
|
910
|
-
split: 10
|
|
911
|
-
});
|
|
912
|
-
// 如果timeSlots返回了 空数组,代表没有可用的资源了
|
|
913
|
-
if (!_timeSlots) {
|
|
914
|
-
return; // 给一个提示?
|
|
915
|
-
}
|
|
916
|
-
return {
|
|
917
|
-
timeSlots: _timeSlots,
|
|
918
|
-
selectedResource: resources[0]
|
|
919
|
-
};
|
|
920
|
-
}
|
|
921
|
-
}
|
|
922
|
-
|
|
923
1301
|
// 自动分派可用资源-pro 版,ui 传递某个账号,自动给某个账号下所有商品分配第一种资源
|
|
924
1302
|
}, {
|
|
925
1303
|
key: "autoSelectAccountResources",
|
|
926
|
-
value: function autoSelectAccountResources(
|
|
927
|
-
var
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
1304
|
+
value: function autoSelectAccountResources(_ref8) {
|
|
1305
|
+
var holder_id = _ref8.holder_id,
|
|
1306
|
+
resources_code = _ref8.resources_code,
|
|
1307
|
+
timeSlots = _ref8.timeSlots,
|
|
1308
|
+
countMap = _ref8.countMap,
|
|
1309
|
+
capacity = _ref8.capacity;
|
|
932
1310
|
var dateRange = this.store.date.getDateRange();
|
|
933
|
-
var cartItems = this.store.cart.getItems();
|
|
1311
|
+
var cartItems = cloneDeep(this.store.cart.getItems());
|
|
934
1312
|
// 取到账号下所有的商品,然后根据商品的 duration 和资源列表,获取所有可用的资源
|
|
935
1313
|
var accountCartItems = cartItems.filter(function (n) {
|
|
936
1314
|
return n.holder_id === holder_id;
|
|
937
1315
|
}) || [];
|
|
938
|
-
//
|
|
1316
|
+
// 账号下没商品则处理所有购物车
|
|
939
1317
|
if (!accountCartItems.length) {
|
|
940
|
-
|
|
941
|
-
selectedResource: null
|
|
942
|
-
};
|
|
1318
|
+
accountCartItems = cartItems;
|
|
943
1319
|
}
|
|
944
1320
|
// duration=所有商品时间的集合
|
|
945
1321
|
var duration = accountCartItems.reduce(function (acc, n) {
|
|
@@ -947,17 +1323,27 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
947
1323
|
return acc + ((_n$_productOrigin$dur = (_n$_productOrigin = n._productOrigin) === null || _n$_productOrigin === void 0 || (_n$_productOrigin = _n$_productOrigin.duration) === null || _n$_productOrigin === void 0 ? void 0 : _n$_productOrigin.value) !== null && _n$_productOrigin$dur !== void 0 ? _n$_productOrigin$dur : 0);
|
|
948
1324
|
}, 0);
|
|
949
1325
|
// 正常来说,能进这个业务的所有商品的 duration 类型都是一样的,所以这里取第一个商品的 duration 类型
|
|
950
|
-
|
|
1326
|
+
// let durationType = accountCartItems[0]?._productOrigin?.duration?.type ?? "minutes";
|
|
951
1327
|
// 取出账号下所对应类型的所有的可用资源
|
|
952
1328
|
var resources = [];
|
|
953
1329
|
accountCartItems.forEach(function (item) {
|
|
954
|
-
var _item$
|
|
955
|
-
(_item$
|
|
1330
|
+
var _item$_productOrigin2;
|
|
1331
|
+
(_item$_productOrigin2 = item._productOrigin) === null || _item$_productOrigin2 === void 0 || (_item$_productOrigin2 = _item$_productOrigin2.product_resource) === null || _item$_productOrigin2 === void 0 || (_item$_productOrigin2 = _item$_productOrigin2.resources) === null || _item$_productOrigin2 === void 0 || _item$_productOrigin2.forEach(function (n) {
|
|
956
1332
|
if (n.code === resources_code) {
|
|
957
1333
|
resources.push.apply(resources, _toConsumableArray(n.renderList || []));
|
|
958
1334
|
}
|
|
959
1335
|
});
|
|
960
1336
|
});
|
|
1337
|
+
// 资源排下序,把单个资源靠前,组合资源排在后面
|
|
1338
|
+
resources.sort(function (a, b) {
|
|
1339
|
+
var _a$metadata2, _b$metadata2;
|
|
1340
|
+
var aIsCombined = ((_a$metadata2 = a.metadata) === null || _a$metadata2 === void 0 || (_a$metadata2 = _a$metadata2.combined_resource) === null || _a$metadata2 === void 0 ? void 0 : _a$metadata2.status) === 1;
|
|
1341
|
+
var bIsCombined = ((_b$metadata2 = b.metadata) === null || _b$metadata2 === void 0 || (_b$metadata2 = _b$metadata2.combined_resource) === null || _b$metadata2 === void 0 ? void 0 : _b$metadata2.status) === 1;
|
|
1342
|
+
if (aIsCombined && !bIsCombined) return 1;
|
|
1343
|
+
if (!aIsCombined && bIsCombined) return -1;
|
|
1344
|
+
return 0;
|
|
1345
|
+
});
|
|
1346
|
+
var resourcesUseableMap = {};
|
|
961
1347
|
|
|
962
1348
|
// 如果有选择时间了,则代表不是第一种资源了,则需要根据开始时间去匹配
|
|
963
1349
|
// 每个商品
|
|
@@ -971,7 +1357,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
971
1357
|
var _iterator2 = _createForOfIteratorHelper(resources),
|
|
972
1358
|
_step2;
|
|
973
1359
|
try {
|
|
974
|
-
var
|
|
1360
|
+
var _loop = function _loop() {
|
|
975
1361
|
var n = _step2.value;
|
|
976
1362
|
var recordCount = countMap[n.id] || 0;
|
|
977
1363
|
var canUseTime = n.times.find(function (item) {
|
|
@@ -979,8 +1365,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
979
1365
|
timeSlice: timeSlots,
|
|
980
1366
|
time: item,
|
|
981
1367
|
resource: n,
|
|
982
|
-
currentCount: recordCount +
|
|
1368
|
+
currentCount: recordCount + (capacity || 0),
|
|
1369
|
+
resourcesUseableMap: resourcesUseableMap
|
|
983
1370
|
});
|
|
1371
|
+
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[n.id]) !== false) {
|
|
1372
|
+
resourcesUseableMap[n.id] = res.usable;
|
|
1373
|
+
}
|
|
984
1374
|
return res.usable;
|
|
985
1375
|
});
|
|
986
1376
|
if (canUseTime) {
|
|
@@ -989,7 +1379,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
989
1379
|
}
|
|
990
1380
|
};
|
|
991
1381
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
992
|
-
if (
|
|
1382
|
+
if (_loop()) break;
|
|
993
1383
|
}
|
|
994
1384
|
} catch (err) {
|
|
995
1385
|
_iterator2.e(err);
|
|
@@ -1004,19 +1394,21 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1004
1394
|
var resourceIds = resources.map(function (n) {
|
|
1005
1395
|
return n.id;
|
|
1006
1396
|
});
|
|
1007
|
-
var
|
|
1397
|
+
var _timeSlots = getTimeSlicesByResources({
|
|
1008
1398
|
resourceIds: resourceIds,
|
|
1009
1399
|
resourcesMap: resourcesMap,
|
|
1010
1400
|
duration: duration,
|
|
1011
1401
|
currentDate: dateRange[0].date,
|
|
1012
|
-
split: 10
|
|
1402
|
+
split: 10,
|
|
1403
|
+
capacity: capacity,
|
|
1404
|
+
resourcesUseableMap: resourcesUseableMap
|
|
1013
1405
|
});
|
|
1014
1406
|
// 如果timeSlots返回了 空数组,代表没有可用的资源了
|
|
1015
|
-
if (!
|
|
1407
|
+
if (!_timeSlots) {
|
|
1016
1408
|
return; // 给一个提示?
|
|
1017
1409
|
}
|
|
1018
1410
|
return {
|
|
1019
|
-
timeSlots:
|
|
1411
|
+
timeSlots: _timeSlots,
|
|
1020
1412
|
selectedResource: resources[0]
|
|
1021
1413
|
};
|
|
1022
1414
|
}
|
|
@@ -1026,44 +1418,63 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1026
1418
|
}, {
|
|
1027
1419
|
key: "autoSelectAllProductResources",
|
|
1028
1420
|
value: function autoSelectAllProductResources(resources_code, timeSlots) {
|
|
1029
|
-
var
|
|
1421
|
+
var _dateRange$,
|
|
1422
|
+
_this8 = this;
|
|
1030
1423
|
var dateRange = this.store.date.getDateRange();
|
|
1031
1424
|
var resources = [];
|
|
1032
|
-
dateRange
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1425
|
+
if (dateRange !== null && dateRange !== void 0 && (_dateRange$ = dateRange[0]) !== null && _dateRange$ !== void 0 && _dateRange$.date) {
|
|
1426
|
+
dateRange.forEach(function (n) {
|
|
1427
|
+
if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
|
|
1428
|
+
});
|
|
1429
|
+
}
|
|
1430
|
+
var resourcesMap = getResourcesMap(cloneDeep(resources));
|
|
1036
1431
|
// 一个账号一个账号处理
|
|
1037
1432
|
var errorList = [];
|
|
1038
1433
|
var selectResourcesMap = {};
|
|
1039
|
-
this.store.accountList.getAccounts()
|
|
1040
|
-
|
|
1041
|
-
// 这里必须每次循环重新读,避免前一次循环操作了购物车,导致数据变更
|
|
1042
|
-
var allCartItems = _this7.store.cart.getItems();
|
|
1434
|
+
var accountList = this.store.accountList.getAccounts();
|
|
1435
|
+
var selectForCartResources = function selectForCartResources(cartItems) {
|
|
1043
1436
|
var recordTimeSlots = cloneDeep(timeSlots);
|
|
1044
1437
|
// timeSlots 传进来的只是用户选中的时间片,但是实际上需要根据多个商品时间进行累加
|
|
1045
1438
|
// 假设 timeSlots.start_time 是15:40 duration 是 30min
|
|
1046
1439
|
// 第一个商品分配完以后,第二个商品分配的start_time应该是第一个商品的 end_time ,然后 end_time 应该是 start_time+duration
|
|
1047
1440
|
|
|
1048
1441
|
cartItems.forEach(function (item, index) {
|
|
1049
|
-
|
|
1442
|
+
var _item$_productOrigin3;
|
|
1443
|
+
var formatCapacity = formatDefaultCapacitys({
|
|
1444
|
+
capacity: (_item$_productOrigin3 = item._productOrigin) === null || _item$_productOrigin3 === void 0 ? void 0 : _item$_productOrigin3.capacity,
|
|
1445
|
+
product_bundle: item._origin.product.product_bundle
|
|
1446
|
+
});
|
|
1447
|
+
var currentCapacity = getSumCapacity({
|
|
1448
|
+
capacity: formatCapacity
|
|
1449
|
+
});
|
|
1450
|
+
// 如果商品已经有时间数据了,意味着是通过先选日期再选商品流程进来的,相当于时间切片已经选中了
|
|
1451
|
+
if (item._origin.start_time && !(timeSlots !== null && timeSlots !== void 0 && timeSlots.start_time)) {
|
|
1452
|
+
recordTimeSlots = {
|
|
1453
|
+
start_time: item._origin.start_time,
|
|
1454
|
+
end_time: item._origin.end_time,
|
|
1455
|
+
start_at: dayjs("".concat(item.start_date, " ").concat(item._origin.start_time)),
|
|
1456
|
+
end_at: dayjs("".concat(item.end_date, " ").concat(item._origin.end_time))
|
|
1457
|
+
};
|
|
1458
|
+
}
|
|
1459
|
+
if (recordTimeSlots) {
|
|
1050
1460
|
if (index !== 0 && recordTimeSlots) {
|
|
1051
|
-
var _item$_productOrigin$, _item$
|
|
1052
|
-
var start_at = dayjs(recordTimeSlots.end_time).add((_item$_productOrigin$ = (_item$
|
|
1053
|
-
var end_at = start_at.add((_item$_productOrigin$2 = (_item$
|
|
1461
|
+
var _item$_productOrigin$, _item$_productOrigin4, _ref9, _item$_productOrigin5, _item$_productOrigin$2, _item$_productOrigin6, _ref10, _item$_productOrigin7;
|
|
1462
|
+
var start_at = dayjs(recordTimeSlots.end_time).add((_item$_productOrigin$ = (_item$_productOrigin4 = item._productOrigin) === null || _item$_productOrigin4 === void 0 || (_item$_productOrigin4 = _item$_productOrigin4.duration) === null || _item$_productOrigin4 === void 0 ? void 0 : _item$_productOrigin4.value) !== null && _item$_productOrigin$ !== void 0 ? _item$_productOrigin$ : 0, (_ref9 = (_item$_productOrigin5 = item._productOrigin) === null || _item$_productOrigin5 === void 0 || (_item$_productOrigin5 = _item$_productOrigin5.duration) === null || _item$_productOrigin5 === void 0 ? void 0 : _item$_productOrigin5.type) !== null && _ref9 !== void 0 ? _ref9 : 'minutes');
|
|
1463
|
+
var end_at = start_at.add((_item$_productOrigin$2 = (_item$_productOrigin6 = item._productOrigin) === null || _item$_productOrigin6 === void 0 || (_item$_productOrigin6 = _item$_productOrigin6.duration) === null || _item$_productOrigin6 === void 0 ? void 0 : _item$_productOrigin6.value) !== null && _item$_productOrigin$2 !== void 0 ? _item$_productOrigin$2 : 0, (_ref10 = (_item$_productOrigin7 = item._productOrigin) === null || _item$_productOrigin7 === void 0 || (_item$_productOrigin7 = _item$_productOrigin7.duration) === null || _item$_productOrigin7 === void 0 ? void 0 : _item$_productOrigin7.type) !== null && _ref10 !== void 0 ? _ref10 : 'minutes');
|
|
1054
1464
|
recordTimeSlots = {
|
|
1055
|
-
start_time: start_at.format(
|
|
1056
|
-
end_time: end_at.format(
|
|
1465
|
+
start_time: start_at.format('HH:mm'),
|
|
1466
|
+
end_time: end_at.format('HH:mm'),
|
|
1057
1467
|
start_at: start_at,
|
|
1058
1468
|
end_at: end_at
|
|
1059
1469
|
};
|
|
1060
1470
|
}
|
|
1061
1471
|
// 如果传递了 timeSlots,代表是第二种资源,则直接拿 timeSlots 去匹配
|
|
1062
|
-
var res =
|
|
1472
|
+
var res = _this8.autoSelectAccountResources({
|
|
1063
1473
|
holder_id: item.holder_id,
|
|
1064
1474
|
resources_code: resources_code,
|
|
1065
1475
|
timeSlots: recordTimeSlots,
|
|
1066
|
-
countMap: selectResourcesMap
|
|
1476
|
+
countMap: selectResourcesMap,
|
|
1477
|
+
capacity: currentCapacity
|
|
1067
1478
|
});
|
|
1068
1479
|
// // 如果购物车里已经有同类型的 form_id 的资源了,则不处理
|
|
1069
1480
|
// if (item._origin.resources?.some((n: any) => n.form_id === res?.selectedResource?.form_id)) {
|
|
@@ -1071,28 +1482,44 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1071
1482
|
// }
|
|
1072
1483
|
if (res !== null && res !== void 0 && res.selectedResource) {
|
|
1073
1484
|
if (!selectResourcesMap[res.selectedResource.id]) {
|
|
1074
|
-
selectResourcesMap[res.selectedResource.id] =
|
|
1485
|
+
selectResourcesMap[res.selectedResource.id] = currentCapacity;
|
|
1075
1486
|
} else {
|
|
1076
|
-
selectResourcesMap[res.selectedResource.id]
|
|
1487
|
+
selectResourcesMap[res.selectedResource.id] += currentCapacity;
|
|
1077
1488
|
}
|
|
1078
|
-
|
|
1079
|
-
res.selectedResource
|
|
1080
|
-
|
|
1489
|
+
res.selectedResource.capacity = currentCapacity;
|
|
1490
|
+
checkSubResourcesCapacity(res.selectedResource);
|
|
1491
|
+
_this8.store.cart.updateItem({
|
|
1081
1492
|
_id: item._id,
|
|
1082
1493
|
// 这里要做去重,避免出现同样类型的资源被塞进同一个商品
|
|
1083
1494
|
resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
|
|
1084
1495
|
return existingRes.form_id !== res.selectedResource.form_id;
|
|
1085
1496
|
})), [res.selectedResource])
|
|
1086
1497
|
});
|
|
1087
|
-
console.log(_this7.store.cart.getItems());
|
|
1088
1498
|
} else {
|
|
1089
1499
|
// 如果没有可用的技师了,推到错误列表里让 UI 去提示
|
|
1090
1500
|
errorList.push(item._id);
|
|
1091
1501
|
}
|
|
1092
1502
|
} else {
|
|
1093
|
-
var _productResources$fin;
|
|
1503
|
+
var _item$_productOrigin8, _productResources$fin;
|
|
1504
|
+
// 这里必须每次循环重新读,避免前一次循环操作了购物车,导致数据变更
|
|
1505
|
+
var allCartItems = cloneDeep(_this8.store.cart.getItems());
|
|
1094
1506
|
// 如果没有传递 timeSlots,代表是第一种资源,则直接拿商品的 duration,到资源列表里找一个公共可用的
|
|
1095
|
-
var
|
|
1507
|
+
var selectedResources = [];
|
|
1508
|
+
var _resources = cloneDeep(((_item$_productOrigin8 = item._productOrigin) === null || _item$_productOrigin8 === void 0 || (_item$_productOrigin8 = _item$_productOrigin8.product_resource) === null || _item$_productOrigin8 === void 0 ? void 0 : _item$_productOrigin8.resources) || []);
|
|
1509
|
+
var currentResourcesRenderList = [];
|
|
1510
|
+
_resources.forEach(function (n) {
|
|
1511
|
+
var _n$renderList;
|
|
1512
|
+
if ((_n$renderList = n.renderList) !== null && _n$renderList !== void 0 && _n$renderList.length) {
|
|
1513
|
+
currentResourcesRenderList.push.apply(currentResourcesRenderList, _toConsumableArray(n.renderList || []));
|
|
1514
|
+
}
|
|
1515
|
+
});
|
|
1516
|
+
var _resourcesMap = getResourcesMap(currentResourcesRenderList);
|
|
1517
|
+
if (item.holder_id) {
|
|
1518
|
+
selectedResources = getOthersSelectedResources(allCartItems, item.holder_id, _resourcesMap);
|
|
1519
|
+
} else {
|
|
1520
|
+
selectedResources = getOthersCartSelectedResources(allCartItems, item._id, _resourcesMap);
|
|
1521
|
+
}
|
|
1522
|
+
var productResources = getResourcesByProduct(_resourcesMap, cloneDeep(_resources), selectedResources, currentCapacity);
|
|
1096
1523
|
// 自动选择 productResources 中对应 resources_code 的资源
|
|
1097
1524
|
var targetRenderList = (_productResources$fin = productResources.find(function (n) {
|
|
1098
1525
|
return n.code === resources_code;
|
|
@@ -1106,8 +1533,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1106
1533
|
return;
|
|
1107
1534
|
}
|
|
1108
1535
|
var targetResource = targetRenderList[0];
|
|
1109
|
-
targetResource.capacity =
|
|
1110
|
-
|
|
1536
|
+
targetResource.capacity = currentCapacity;
|
|
1537
|
+
// 在这里处理 children 的数据
|
|
1538
|
+
checkSubResourcesCapacity(targetResource);
|
|
1539
|
+
_this8.store.cart.updateItem({
|
|
1111
1540
|
_id: item._id,
|
|
1112
1541
|
resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
|
|
1113
1542
|
return existingRes.resourceType !== targetRenderList[0].resourceType;
|
|
@@ -1119,7 +1548,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1119
1548
|
}
|
|
1120
1549
|
}
|
|
1121
1550
|
});
|
|
1122
|
-
}
|
|
1551
|
+
};
|
|
1552
|
+
var cartItems = cloneDeep(this.store.cart.getItems());
|
|
1553
|
+
|
|
1554
|
+
// 如果购物车里没有 holderid数据,证明不按 holder 类流程预约走,给所有购物车一次性分派即可,不做账号下资源互斥逻辑
|
|
1555
|
+
if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
|
|
1556
|
+
accountList.forEach(function (account) {
|
|
1557
|
+
var cartItems = _this8.store.cart.getCartByAccount(account.getId());
|
|
1558
|
+
selectForCartResources(cartItems);
|
|
1559
|
+
});
|
|
1560
|
+
} else {
|
|
1561
|
+
selectForCartResources(cartItems);
|
|
1562
|
+
}
|
|
1123
1563
|
return {
|
|
1124
1564
|
errorList: errorList
|
|
1125
1565
|
};
|
|
@@ -1128,15 +1568,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1128
1568
|
}, {
|
|
1129
1569
|
key: "getTimeSlotByAllResources",
|
|
1130
1570
|
value: function getTimeSlotByAllResources(resources_code) {
|
|
1131
|
-
var
|
|
1571
|
+
var _this9 = this,
|
|
1572
|
+
_cartItems$,
|
|
1573
|
+
_cartItems$2;
|
|
1132
1574
|
var dateRange = this.store.date.getDateRange();
|
|
1133
1575
|
// 取出购物车中所有一已选择的第一步资源
|
|
1134
1576
|
var resources = [];
|
|
1135
|
-
var cartItems = this.store.cart.getItems();
|
|
1577
|
+
var cartItems = cloneDeep(this.store.cart.getItems());
|
|
1578
|
+
// if (cartItems?.[0].start_date) return [];
|
|
1136
1579
|
var resourceIds = [];
|
|
1137
1580
|
cartItems.forEach(function (item) {
|
|
1138
|
-
var _item$
|
|
1139
|
-
(_item$
|
|
1581
|
+
var _item$_productOrigin9;
|
|
1582
|
+
(_item$_productOrigin9 = item._productOrigin) === null || _item$_productOrigin9 === void 0 || (_item$_productOrigin9 = _item$_productOrigin9.product_resource) === null || _item$_productOrigin9 === void 0 || (_item$_productOrigin9 = _item$_productOrigin9.resources) === null || _item$_productOrigin9 === void 0 || _item$_productOrigin9.forEach(function (n) {
|
|
1140
1583
|
if (n.code === resources_code) {
|
|
1141
1584
|
resources.push.apply(resources, _toConsumableArray(n.renderList || []));
|
|
1142
1585
|
}
|
|
@@ -1151,23 +1594,52 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1151
1594
|
var resourcesMap = getResourcesMap(resources);
|
|
1152
1595
|
var duration = 0;
|
|
1153
1596
|
// duration = 不同账号的最长时间
|
|
1154
|
-
this.store.accountList.getAccounts()
|
|
1597
|
+
var accountList = this.store.accountList.getAccounts();
|
|
1598
|
+
var checkDuration = function checkDuration(cartItems) {
|
|
1155
1599
|
var accountDuration = 0;
|
|
1156
|
-
var cartItems = _this8.store.cart.getCartByAccount(account.getId());
|
|
1157
1600
|
cartItems.forEach(function (item) {
|
|
1158
|
-
var _item$_productOrigin$3, _item$
|
|
1159
|
-
accountDuration += (_item$_productOrigin$3 = (_item$
|
|
1601
|
+
var _item$_productOrigin$3, _item$_productOrigin10;
|
|
1602
|
+
accountDuration += (_item$_productOrigin$3 = (_item$_productOrigin10 = item._productOrigin) === null || _item$_productOrigin10 === void 0 || (_item$_productOrigin10 = _item$_productOrigin10.duration) === null || _item$_productOrigin10 === void 0 ? void 0 : _item$_productOrigin10.value) !== null && _item$_productOrigin$3 !== void 0 ? _item$_productOrigin$3 : 0;
|
|
1160
1603
|
});
|
|
1161
1604
|
if (accountDuration > duration) {
|
|
1162
1605
|
duration = accountDuration;
|
|
1163
1606
|
}
|
|
1164
|
-
}
|
|
1607
|
+
};
|
|
1608
|
+
if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
|
|
1609
|
+
accountList.forEach(function (account) {
|
|
1610
|
+
var cartItems = _this9.store.cart.getCartByAccount(account.getId());
|
|
1611
|
+
checkDuration(cartItems);
|
|
1612
|
+
});
|
|
1613
|
+
} else {
|
|
1614
|
+
checkDuration(cartItems);
|
|
1615
|
+
}
|
|
1616
|
+
// 如果 cartItem 上既没有时间,也没有资源,认为外部属于异常调用,直接丢一个空数组出去
|
|
1617
|
+
// 同时 session 类商品的流程也不应该调用这个方法
|
|
1618
|
+
if (!(cartItems !== null && cartItems !== void 0 && (_cartItems$ = cartItems[0]) !== null && _cartItems$ !== void 0 && _cartItems$.start_date) && !(cartItems !== null && cartItems !== void 0 && (_cartItems$2 = cartItems[0]) !== null && _cartItems$2 !== void 0 && _cartItems$2.resource_id) || !(cartItems !== null && cartItems !== void 0 && cartItems[0].duration)) {
|
|
1619
|
+
return [];
|
|
1620
|
+
}
|
|
1621
|
+
if (cartItems !== null && cartItems !== void 0 && cartItems[0].start_date && !dateRange) {
|
|
1622
|
+
var _cartItems$3, _cartItems$4;
|
|
1623
|
+
dateRange = [{
|
|
1624
|
+
date: cartItems === null || cartItems === void 0 ? void 0 : cartItems[0].start_date,
|
|
1625
|
+
status: 'available',
|
|
1626
|
+
week: '',
|
|
1627
|
+
weekNum: 0
|
|
1628
|
+
}, {
|
|
1629
|
+
date: (cartItems === null || cartItems === void 0 || (_cartItems$3 = cartItems[0]) === null || _cartItems$3 === void 0 ? void 0 : _cartItems$3.end_date) || (cartItems === null || cartItems === void 0 || (_cartItems$4 = cartItems[0]) === null || _cartItems$4 === void 0 ? void 0 : _cartItems$4.start_date) || '',
|
|
1630
|
+
status: 'available',
|
|
1631
|
+
week: '',
|
|
1632
|
+
weekNum: 0
|
|
1633
|
+
}];
|
|
1634
|
+
}
|
|
1635
|
+
var resourcesUseableMap = {};
|
|
1165
1636
|
var timeSlots = getTimeSlicesByResources({
|
|
1166
1637
|
resourceIds: resourceIds,
|
|
1167
1638
|
resourcesMap: resourcesMap,
|
|
1168
1639
|
duration: duration,
|
|
1169
1640
|
currentDate: dateRange[0].date,
|
|
1170
|
-
split: 10
|
|
1641
|
+
split: 10,
|
|
1642
|
+
resourcesUseableMap: resourcesUseableMap
|
|
1171
1643
|
});
|
|
1172
1644
|
return timeSlots;
|
|
1173
1645
|
}
|
|
@@ -1176,9 +1648,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1176
1648
|
}, {
|
|
1177
1649
|
key: "submitTimeSlot",
|
|
1178
1650
|
value: function submitTimeSlot(timeSlots) {
|
|
1179
|
-
var
|
|
1651
|
+
var _this10 = this;
|
|
1180
1652
|
// 以账号为维度处理数据。购物车里每一项的 startTime应该是前一个商品的 endTime,如果是第一个商品则用 timeSlots.start_at
|
|
1181
|
-
var cartItems = this.store.cart.getItems();
|
|
1653
|
+
var cartItems = cloneDeep(this.store.cart.getItems());
|
|
1182
1654
|
|
|
1183
1655
|
// 按账号分组
|
|
1184
1656
|
var itemsByAccount = cartItems.reduce(function (acc, item) {
|
|
@@ -1192,16 +1664,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1192
1664
|
|
|
1193
1665
|
// 处理每个账号的商品
|
|
1194
1666
|
Object.values(itemsByAccount).forEach(function (accountItems) {
|
|
1195
|
-
var currentStartTime = timeSlots.start_at.format(
|
|
1667
|
+
var currentStartTime = timeSlots.start_at.format('YYYY-MM-DD HH:mm');
|
|
1196
1668
|
accountItems.forEach(function (item, index) {
|
|
1197
1669
|
var newResources = cloneDeep(item._origin.resources);
|
|
1198
1670
|
newResources.forEach(function (resource) {
|
|
1199
|
-
var _item$_productOrigin$4, _item$
|
|
1671
|
+
var _item$_productOrigin$4, _item$_productOrigin11, _ref11, _item$_productOrigin12;
|
|
1200
1672
|
resource.startTime = currentStartTime;
|
|
1201
|
-
resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$4 = (_item$
|
|
1673
|
+
resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$4 = (_item$_productOrigin11 = item._productOrigin) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.duration) === null || _item$_productOrigin11 === void 0 ? void 0 : _item$_productOrigin11.value) !== null && _item$_productOrigin$4 !== void 0 ? _item$_productOrigin$4 : 0, (_ref11 = (_item$_productOrigin12 = item._productOrigin) === null || _item$_productOrigin12 === void 0 || (_item$_productOrigin12 = _item$_productOrigin12.duration) === null || _item$_productOrigin12 === void 0 ? void 0 : _item$_productOrigin12.type) !== null && _ref11 !== void 0 ? _ref11 : 'minutes').format('YYYY-MM-DD HH:mm');
|
|
1202
1674
|
delete resource.times;
|
|
1203
1675
|
});
|
|
1204
|
-
|
|
1676
|
+
_this10.store.cart.updateItem({
|
|
1205
1677
|
_id: item._id,
|
|
1206
1678
|
resources: newResources
|
|
1207
1679
|
});
|
|
@@ -1219,6 +1691,236 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1219
1691
|
}, {
|
|
1220
1692
|
key: "clearCacheByModule",
|
|
1221
1693
|
value: function clearCacheByModule(module) {}
|
|
1694
|
+
}, {
|
|
1695
|
+
key: "getScheduleDataByIds",
|
|
1696
|
+
value: function getScheduleDataByIds(scheduleIds) {
|
|
1697
|
+
var targetSchedules = this.store.schedule.getScheduleListByIds(scheduleIds);
|
|
1698
|
+
var targetSchedulesData = targetSchedules.map(function (item) {
|
|
1699
|
+
return calcCalendarDataByScheduleResult(item);
|
|
1700
|
+
});
|
|
1701
|
+
var newSchedule = {};
|
|
1702
|
+
targetSchedulesData.forEach(function (item) {
|
|
1703
|
+
item.forEach(function (n) {
|
|
1704
|
+
if (!newSchedule[n.date]) {
|
|
1705
|
+
newSchedule[n.date] = n;
|
|
1706
|
+
} else {
|
|
1707
|
+
if (!n.isExcluded) {
|
|
1708
|
+
newSchedule[n.date].isExcluded = false;
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
});
|
|
1712
|
+
});
|
|
1713
|
+
var newScheduleArr = Object.values(newSchedule);
|
|
1714
|
+
return newScheduleArr;
|
|
1715
|
+
}
|
|
1716
|
+
// 打开某个商品详情的弹窗,OS 层这边会记录当前选中的商品,适用于 session 类商品预约
|
|
1717
|
+
}, {
|
|
1718
|
+
key: "openProductDetail",
|
|
1719
|
+
value: function () {
|
|
1720
|
+
var _openProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(productId) {
|
|
1721
|
+
var targetProduct, targetProductData, newScheduleArr;
|
|
1722
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
1723
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
1724
|
+
case 0:
|
|
1725
|
+
_context25.next = 2;
|
|
1726
|
+
return this.store.products.getProduct(productId);
|
|
1727
|
+
case 2:
|
|
1728
|
+
targetProduct = _context25.sent;
|
|
1729
|
+
if (targetProduct) {
|
|
1730
|
+
targetProductData = targetProduct.getData();
|
|
1731
|
+
this.store.currentProduct = targetProduct;
|
|
1732
|
+
newScheduleArr = this.getScheduleDataByIds(targetProductData['schedule.ids']);
|
|
1733
|
+
targetProduct.setOtherParams('schedule', newScheduleArr);
|
|
1734
|
+
}
|
|
1735
|
+
case 4:
|
|
1736
|
+
case "end":
|
|
1737
|
+
return _context25.stop();
|
|
1738
|
+
}
|
|
1739
|
+
}, _callee25, this);
|
|
1740
|
+
}));
|
|
1741
|
+
function openProductDetail(_x18) {
|
|
1742
|
+
return _openProductDetail.apply(this, arguments);
|
|
1743
|
+
}
|
|
1744
|
+
return openProductDetail;
|
|
1745
|
+
}()
|
|
1746
|
+
}, {
|
|
1747
|
+
key: "closeProductDetail",
|
|
1748
|
+
value: function closeProductDetail() {
|
|
1749
|
+
var _this$store$currentPr;
|
|
1750
|
+
(_this$store$currentPr = this.store.currentProduct) === null || _this$store$currentPr === void 0 || _this$store$currentPr.setOtherParams('schedule', []);
|
|
1751
|
+
this.store.currentProduct = undefined;
|
|
1752
|
+
}
|
|
1753
|
+
}, {
|
|
1754
|
+
key: "getTimeslotBySchedule",
|
|
1755
|
+
value: function getTimeslotBySchedule(_ref12) {
|
|
1756
|
+
var _this$store$currentPr2;
|
|
1757
|
+
var date = _ref12.date,
|
|
1758
|
+
scheduleIds = _ref12.scheduleIds,
|
|
1759
|
+
resources = _ref12.resources;
|
|
1760
|
+
var targetProduct = this.store.currentProduct;
|
|
1761
|
+
var targetProductData = targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.getData();
|
|
1762
|
+
var targetSchedules = [];
|
|
1763
|
+
// 如果外面传递了 scheduleIds,优先取入参
|
|
1764
|
+
if (scheduleIds !== null && scheduleIds !== void 0 && scheduleIds.length) {
|
|
1765
|
+
targetSchedules = this.store.schedule.getScheduleListByIds(scheduleIds);
|
|
1766
|
+
} else {
|
|
1767
|
+
targetSchedules = this.store.schedule.getScheduleListByIds(targetProductData['schedule.ids']);
|
|
1768
|
+
}
|
|
1769
|
+
var resourcesDates = this.store.date.getDateList();
|
|
1770
|
+
var targetResourceDate = resourcesDates.find(function (n) {
|
|
1771
|
+
return n.date === date;
|
|
1772
|
+
});
|
|
1773
|
+
var cartItems = cloneDeep(this.store.cart.getItems());
|
|
1774
|
+
var resourcesMap = getResourcesMap((targetResourceDate === null || targetResourceDate === void 0 ? void 0 : targetResourceDate.resource) || []);
|
|
1775
|
+
var selectedResources = getOthersSelectedResources(cartItems, '', resourcesMap);
|
|
1776
|
+
var productResources = getResourcesByProduct(resourcesMap, resources || ((_this$store$currentPr2 = this.store.currentProduct) === null || _this$store$currentPr2 === void 0 || (_this$store$currentPr2 = _this$store$currentPr2.getData()) === null || _this$store$currentPr2 === void 0 || (_this$store$currentPr2 = _this$store$currentPr2.product_resource) === null || _this$store$currentPr2 === void 0 ? void 0 : _this$store$currentPr2.resources) || [], selectedResources, 1);
|
|
1777
|
+
var minTimeMaxTime = calcMinTimeMaxTimeBySchedules(targetSchedules, {}, date);
|
|
1778
|
+
var scheduleTimeSlots = getAllSortedDateRanges(minTimeMaxTime);
|
|
1779
|
+
console.log('scheduleTimeSlots:', scheduleTimeSlots, productResources);
|
|
1780
|
+
// 当前所有待选择资源的集合,先提出来,提升性能
|
|
1781
|
+
var allProductResources = productResources.flatMap(function (n) {
|
|
1782
|
+
return n.renderList;
|
|
1783
|
+
});
|
|
1784
|
+
// 资源排下序,把单个资源靠前,组合资源排在后面
|
|
1785
|
+
allProductResources.sort(function (a, b) {
|
|
1786
|
+
var _a$metadata3, _b$metadata3;
|
|
1787
|
+
var aIsCombined = ((_a$metadata3 = a.metadata) === null || _a$metadata3 === void 0 || (_a$metadata3 = _a$metadata3.combined_resource) === null || _a$metadata3 === void 0 ? void 0 : _a$metadata3.status) === 1;
|
|
1788
|
+
var bIsCombined = ((_b$metadata3 = b.metadata) === null || _b$metadata3 === void 0 || (_b$metadata3 = _b$metadata3.combined_resource) === null || _b$metadata3 === void 0 ? void 0 : _b$metadata3.status) === 1;
|
|
1789
|
+
if (aIsCombined && !bIsCombined) return 1;
|
|
1790
|
+
if (!aIsCombined && bIsCombined) return -1;
|
|
1791
|
+
return 0;
|
|
1792
|
+
});
|
|
1793
|
+
var resourcesUseableMap = {};
|
|
1794
|
+
// 计算每个日程切片下日程可用的资源的容量总和
|
|
1795
|
+
var formatScheduleTimeSlots = scheduleTimeSlots.map(function (item) {
|
|
1796
|
+
var count = 0;
|
|
1797
|
+
// 遍历所有资源
|
|
1798
|
+
allProductResources === null || allProductResources === void 0 || allProductResources.forEach(function (m) {
|
|
1799
|
+
// 遍历所有资源的上工时间片
|
|
1800
|
+
m.times.forEach(function (childTiem) {
|
|
1801
|
+
// 挨个去匹配某个工作时间段结合当前日程时间,资源能不能用,有多少容量能用
|
|
1802
|
+
var res = getIsUsableByTimeItem({
|
|
1803
|
+
timeSlice: {
|
|
1804
|
+
start_time: item.start,
|
|
1805
|
+
end_time: item.end,
|
|
1806
|
+
start_at: dayjs(item.start),
|
|
1807
|
+
end_at: dayjs(item.end)
|
|
1808
|
+
},
|
|
1809
|
+
time: childTiem,
|
|
1810
|
+
resource: m,
|
|
1811
|
+
currentCount: 1,
|
|
1812
|
+
resourcesUseableMap: resourcesUseableMap
|
|
1813
|
+
});
|
|
1814
|
+
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false) {
|
|
1815
|
+
resourcesUseableMap[m.id] = res.usable;
|
|
1816
|
+
}
|
|
1817
|
+
// 如果资源可用,且是独占资源,remainingCapacity 始终为 1
|
|
1818
|
+
if (res.usable && res.remainingCapacity >= count) {
|
|
1819
|
+
count = res.remainingCapacity;
|
|
1820
|
+
}
|
|
1821
|
+
});
|
|
1822
|
+
});
|
|
1823
|
+
var startDayJs = dayjs(item.start);
|
|
1824
|
+
var endDayJs = dayjs(item.end);
|
|
1825
|
+
return {
|
|
1826
|
+
start_time: startDayJs.format('HH:mm'),
|
|
1827
|
+
end_time: endDayJs.format('HH:mm'),
|
|
1828
|
+
start_at: startDayJs,
|
|
1829
|
+
end_at: endDayJs,
|
|
1830
|
+
count: count
|
|
1831
|
+
};
|
|
1832
|
+
});
|
|
1833
|
+
return formatScheduleTimeSlots;
|
|
1834
|
+
}
|
|
1835
|
+
}, {
|
|
1836
|
+
key: "addProductToCart",
|
|
1837
|
+
value: function addProductToCart(_ref13) {
|
|
1838
|
+
var _this11 = this;
|
|
1839
|
+
var product = _ref13.product,
|
|
1840
|
+
date = _ref13.date,
|
|
1841
|
+
account = _ref13.account;
|
|
1842
|
+
var _ref14 = product || {},
|
|
1843
|
+
bundle = _ref14.bundle,
|
|
1844
|
+
options = _ref14.options,
|
|
1845
|
+
origin = _ref14.origin,
|
|
1846
|
+
product_variant_id = _ref14.product_variant_id;
|
|
1847
|
+
var productData = _objectSpread(_objectSpread({}, origin), {}, {
|
|
1848
|
+
product_variant_id: product_variant_id
|
|
1849
|
+
});
|
|
1850
|
+
if (!account) {
|
|
1851
|
+
var activeAccount = this.getActiveAccount();
|
|
1852
|
+
if (activeAccount) {
|
|
1853
|
+
account = activeAccount;
|
|
1854
|
+
}
|
|
1855
|
+
}
|
|
1856
|
+
this.store.cart.addItem({
|
|
1857
|
+
product: productData,
|
|
1858
|
+
date: date,
|
|
1859
|
+
account: account,
|
|
1860
|
+
bundle: bundle,
|
|
1861
|
+
options: options
|
|
1862
|
+
});
|
|
1863
|
+
// 检测,有传递 date,检查购物车里其他商品的 date 是否在同一天,如果不在,清空那些不在同一天的商品
|
|
1864
|
+
if (date) {
|
|
1865
|
+
var cartItems = cloneDeep(this.store.cart.getItems());
|
|
1866
|
+
var cartItemsByDate = cartItems.filter(function (n) {
|
|
1867
|
+
return !dayjs(n.start_date).isSame(dayjs(date.startTime), 'day');
|
|
1868
|
+
});
|
|
1869
|
+
if (cartItemsByDate.length) {
|
|
1870
|
+
cartItemsByDate.forEach(function (n) {
|
|
1871
|
+
_this11.store.cart.removeItem(n._id);
|
|
1872
|
+
});
|
|
1873
|
+
}
|
|
1874
|
+
}
|
|
1875
|
+
}
|
|
1876
|
+
}, {
|
|
1877
|
+
key: "setOtherData",
|
|
1878
|
+
value: function setOtherData(key, value) {
|
|
1879
|
+
this.otherData[key] = value;
|
|
1880
|
+
this.checkSaveCache({
|
|
1881
|
+
cacheId: this.cacheId,
|
|
1882
|
+
fatherModule: this.name,
|
|
1883
|
+
store: {
|
|
1884
|
+
otherData: this.otherData
|
|
1885
|
+
},
|
|
1886
|
+
cacheKey: ['otherData']
|
|
1887
|
+
});
|
|
1888
|
+
}
|
|
1889
|
+
}, {
|
|
1890
|
+
key: "getOtherData",
|
|
1891
|
+
value: function getOtherData(key) {
|
|
1892
|
+
return this.otherData[key];
|
|
1893
|
+
}
|
|
1894
|
+
}, {
|
|
1895
|
+
key: "getProductTypeById",
|
|
1896
|
+
value: function () {
|
|
1897
|
+
var _getProductTypeById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(id) {
|
|
1898
|
+
var product;
|
|
1899
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
1900
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
1901
|
+
case 0:
|
|
1902
|
+
_context26.next = 2;
|
|
1903
|
+
return this.store.products.getProduct(id);
|
|
1904
|
+
case 2:
|
|
1905
|
+
product = _context26.sent;
|
|
1906
|
+
if (!product) {
|
|
1907
|
+
_context26.next = 5;
|
|
1908
|
+
break;
|
|
1909
|
+
}
|
|
1910
|
+
return _context26.abrupt("return", product.getProductType());
|
|
1911
|
+
case 5:
|
|
1912
|
+
return _context26.abrupt("return", 'normal');
|
|
1913
|
+
case 6:
|
|
1914
|
+
case "end":
|
|
1915
|
+
return _context26.stop();
|
|
1916
|
+
}
|
|
1917
|
+
}, _callee26, this);
|
|
1918
|
+
}));
|
|
1919
|
+
function getProductTypeById(_x19) {
|
|
1920
|
+
return _getProductTypeById.apply(this, arguments);
|
|
1921
|
+
}
|
|
1922
|
+
return getProductTypeById;
|
|
1923
|
+
}()
|
|
1222
1924
|
}]);
|
|
1223
1925
|
return BookingByStepImpl;
|
|
1224
1926
|
}(BaseModule);
|