@pisell/pisellos 2.2.322 → 2.2.324

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