@pisell/pisellos 3.0.89 → 3.0.91

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (242) hide show
  1. package/dist/apis/picoding.d.ts +0 -0
  2. package/dist/apis/picoding.js +1 -0
  3. package/dist/model/index.d.ts +1 -0
  4. package/dist/model/index.js +1 -0
  5. package/dist/model/strategy/adapter/index.d.ts +7 -0
  6. package/dist/model/strategy/adapter/index.js +7 -0
  7. package/dist/model/strategy/adapter/itemRule/adapter.d.ts +67 -0
  8. package/dist/model/strategy/adapter/itemRule/adapter.js +483 -0
  9. package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
  10. package/dist/model/strategy/adapter/itemRule/evaluator.js +169 -0
  11. package/dist/model/strategy/adapter/itemRule/examples.d.ts +79 -0
  12. package/dist/model/strategy/adapter/itemRule/examples.js +382 -0
  13. package/dist/model/strategy/adapter/itemRule/index.d.ts +5 -0
  14. package/dist/model/strategy/adapter/itemRule/index.js +5 -0
  15. package/dist/model/strategy/adapter/itemRule/type.d.ts +225 -0
  16. package/dist/model/strategy/adapter/itemRule/type.js +101 -0
  17. package/dist/model/strategy/adapter/promotion/adapter.d.ts +66 -0
  18. package/dist/model/strategy/adapter/promotion/adapter.js +271 -0
  19. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +213 -0
  20. package/dist/model/strategy/adapter/promotion/evaluator.js +1206 -0
  21. package/dist/model/strategy/adapter/promotion/examples.d.ts +138 -0
  22. package/dist/model/strategy/adapter/promotion/examples.js +166 -0
  23. package/dist/model/strategy/adapter/promotion/index.d.ts +4 -0
  24. package/dist/model/strategy/adapter/promotion/index.js +0 -0
  25. package/dist/model/strategy/adapter/promotion/type.d.ts +447 -0
  26. package/dist/model/strategy/adapter/promotion/type.js +209 -0
  27. package/dist/model/strategy/adapter/type.d.ts +28 -0
  28. package/dist/model/strategy/adapter/type.js +1 -0
  29. package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +84 -0
  30. package/dist/model/strategy/adapter/walletPass/evaluator.js +502 -0
  31. package/dist/model/strategy/adapter/walletPass/example.d.ts +4 -0
  32. package/dist/model/strategy/adapter/walletPass/example.js +258 -0
  33. package/dist/model/strategy/adapter/walletPass/index.d.ts +32 -0
  34. package/dist/model/strategy/adapter/walletPass/index.js +182 -0
  35. package/dist/model/strategy/adapter/walletPass/locales.d.ts +1 -0
  36. package/dist/model/strategy/adapter/walletPass/locales.js +26 -0
  37. package/dist/model/strategy/adapter/walletPass/type.d.ts +187 -0
  38. package/dist/model/strategy/adapter/walletPass/type.js +1 -0
  39. package/dist/model/strategy/adapter/walletPass/utils.d.ts +50 -0
  40. package/dist/model/strategy/adapter/walletPass/utils.js +1104 -0
  41. package/dist/model/strategy/engine.d.ts +106 -0
  42. package/dist/model/strategy/engine.js +611 -0
  43. package/dist/model/strategy/index.d.ts +3 -0
  44. package/dist/model/strategy/index.js +8 -0
  45. package/dist/model/strategy/strategy-example.d.ts +5 -0
  46. package/dist/model/strategy/strategy-example.js +331 -0
  47. package/dist/model/strategy/type.d.ts +228 -0
  48. package/dist/model/strategy/type.js +94 -0
  49. package/dist/modules/Cart/utils/cartProduct.js +1 -0
  50. package/dist/modules/Discount/index.d.ts +4 -2
  51. package/dist/modules/Discount/index.js +90 -3
  52. package/dist/modules/Discount/types.d.ts +6 -0
  53. package/dist/modules/OpenData/index.d.ts +24 -0
  54. package/dist/modules/OpenData/index.js +173 -0
  55. package/dist/modules/OpenData/types.d.ts +73 -0
  56. package/dist/modules/OpenData/types.js +1 -0
  57. package/dist/modules/OpenData/utils.d.ts +2 -0
  58. package/dist/modules/OpenData/utils.js +75 -0
  59. package/dist/modules/Order/index.d.ts +66 -1
  60. package/dist/modules/Order/index.js +884 -10
  61. package/dist/modules/Order/types.d.ts +174 -12
  62. package/dist/modules/Order/types.js +2 -0
  63. package/dist/modules/Order/utils.d.ts +118 -0
  64. package/dist/modules/Order/utils.js +586 -2
  65. package/dist/modules/Product/utils.js +2 -2
  66. package/dist/modules/ProductList/index.d.ts +3 -1
  67. package/dist/modules/ProductList/index.js +19 -11
  68. package/dist/modules/Quotation/index.d.ts +48 -0
  69. package/dist/modules/Quotation/index.js +248 -0
  70. package/dist/modules/Quotation/types.d.ts +42 -0
  71. package/dist/modules/Quotation/types.js +1 -0
  72. package/dist/modules/Rules/index.js +17 -18
  73. package/dist/modules/SalesSummary/index.d.ts +63 -0
  74. package/dist/modules/SalesSummary/index.js +174 -0
  75. package/dist/modules/SalesSummary/types.d.ts +60 -0
  76. package/dist/modules/SalesSummary/types.js +1 -0
  77. package/dist/modules/SalesSummary/utils.d.ts +30 -0
  78. package/dist/modules/SalesSummary/utils.js +480 -0
  79. package/dist/modules/ScanOrderLogger/index.d.ts +23 -0
  80. package/dist/modules/ScanOrderLogger/index.js +174 -0
  81. package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
  82. package/dist/modules/ScanOrderLogger/providers/feishu.js +221 -0
  83. package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
  84. package/dist/modules/ScanOrderLogger/providers/grafana.js +50 -0
  85. package/dist/modules/ScanOrderLogger/types.d.ts +53 -0
  86. package/dist/modules/ScanOrderLogger/types.js +1 -0
  87. package/dist/modules/Schedule/getDateIsInSchedule.js +11 -18
  88. package/dist/modules/Schedule/utils.d.ts +1 -1
  89. package/dist/modules/Summary/utils.d.ts +3 -3
  90. package/dist/modules/Summary/utils.js +41 -31
  91. package/dist/modules/index.d.ts +4 -0
  92. package/dist/modules/index.js +5 -1
  93. package/dist/solution/BookingByStep/index.d.ts +3 -3
  94. package/dist/solution/BookingByStep/index.js +2 -1
  95. package/dist/solution/BookingByStep/types.d.ts +3 -1
  96. package/dist/solution/BookingByStep/types.js +5 -1
  97. package/dist/solution/ScanOrder/index.d.ts +158 -0
  98. package/dist/solution/ScanOrder/index.js +3474 -0
  99. package/dist/solution/ScanOrder/types.d.ts +306 -0
  100. package/dist/solution/ScanOrder/types.js +35 -0
  101. package/dist/solution/ScanOrder/utils.d.ts +172 -0
  102. package/dist/solution/ScanOrder/utils.js +796 -0
  103. package/dist/solution/ShopDiscount/index.d.ts +1 -0
  104. package/dist/solution/ShopDiscount/index.js +23 -18
  105. package/dist/solution/VenueBooking/index.d.ts +201 -0
  106. package/dist/solution/VenueBooking/index.js +3472 -0
  107. package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
  108. package/dist/solution/VenueBooking/types.d.ts +154 -0
  109. package/dist/solution/VenueBooking/types.js +21 -0
  110. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
  111. package/dist/solution/VenueBooking/utils/dateSummary.js +104 -0
  112. package/dist/solution/VenueBooking/utils/resource.d.ts +14 -0
  113. package/dist/solution/VenueBooking/utils/resource.js +131 -0
  114. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +38 -0
  115. package/dist/solution/VenueBooking/utils/slotMerge.js +239 -0
  116. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
  117. package/dist/solution/VenueBooking/utils/timeSlot.js +453 -0
  118. package/dist/solution/VenueBooking/utils.d.ts +1 -0
  119. package/dist/solution/VenueBooking/utils.js +1 -0
  120. package/dist/solution/index.d.ts +2 -0
  121. package/dist/solution/index.js +3 -1
  122. package/lib/apis/picoding.d.ts +0 -0
  123. package/lib/apis/picoding.js +0 -0
  124. package/lib/model/index.d.ts +1 -0
  125. package/lib/model/index.js +23 -0
  126. package/lib/model/strategy/adapter/index.d.ts +7 -0
  127. package/lib/model/strategy/adapter/index.js +57 -0
  128. package/lib/model/strategy/adapter/itemRule/adapter.d.ts +67 -0
  129. package/lib/model/strategy/adapter/itemRule/adapter.js +377 -0
  130. package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
  131. package/lib/model/strategy/adapter/itemRule/evaluator.js +124 -0
  132. package/lib/model/strategy/adapter/itemRule/examples.d.ts +79 -0
  133. package/lib/model/strategy/adapter/itemRule/examples.js +316 -0
  134. package/lib/model/strategy/adapter/itemRule/index.d.ts +5 -0
  135. package/lib/model/strategy/adapter/itemRule/index.js +60 -0
  136. package/lib/model/strategy/adapter/itemRule/type.d.ts +225 -0
  137. package/lib/model/strategy/adapter/itemRule/type.js +46 -0
  138. package/lib/model/strategy/adapter/promotion/adapter.d.ts +66 -0
  139. package/lib/model/strategy/adapter/promotion/adapter.js +217 -0
  140. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +213 -0
  141. package/lib/model/strategy/adapter/promotion/evaluator.js +844 -0
  142. package/lib/model/strategy/adapter/promotion/examples.d.ts +138 -0
  143. package/lib/model/strategy/adapter/promotion/examples.js +192 -0
  144. package/lib/model/strategy/adapter/promotion/index.d.ts +4 -0
  145. package/lib/model/strategy/adapter/promotion/index.js +0 -0
  146. package/lib/model/strategy/adapter/promotion/type.d.ts +447 -0
  147. package/lib/model/strategy/adapter/promotion/type.js +51 -0
  148. package/lib/model/strategy/adapter/type.d.ts +28 -0
  149. package/lib/model/strategy/adapter/type.js +17 -0
  150. package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +84 -0
  151. package/lib/model/strategy/adapter/walletPass/evaluator.js +424 -0
  152. package/lib/model/strategy/adapter/walletPass/example.d.ts +4 -0
  153. package/lib/model/strategy/adapter/walletPass/example.js +207 -0
  154. package/lib/model/strategy/adapter/walletPass/index.d.ts +32 -0
  155. package/lib/model/strategy/adapter/walletPass/index.js +142 -0
  156. package/lib/model/strategy/adapter/walletPass/locales.d.ts +1 -0
  157. package/lib/model/strategy/adapter/walletPass/locales.js +54 -0
  158. package/lib/model/strategy/adapter/walletPass/type.d.ts +187 -0
  159. package/lib/model/strategy/adapter/walletPass/type.js +17 -0
  160. package/lib/model/strategy/adapter/walletPass/utils.d.ts +50 -0
  161. package/lib/model/strategy/adapter/walletPass/utils.js +791 -0
  162. package/lib/model/strategy/engine.d.ts +106 -0
  163. package/lib/model/strategy/engine.js +450 -0
  164. package/lib/model/strategy/index.d.ts +3 -0
  165. package/lib/model/strategy/index.js +38 -0
  166. package/lib/model/strategy/strategy-example.d.ts +5 -0
  167. package/lib/model/strategy/strategy-example.js +318 -0
  168. package/lib/model/strategy/type.d.ts +228 -0
  169. package/lib/model/strategy/type.js +44 -0
  170. package/lib/modules/Cart/utils/cartProduct.js +1 -0
  171. package/lib/modules/Discount/index.d.ts +4 -2
  172. package/lib/modules/Discount/index.js +60 -2
  173. package/lib/modules/Discount/types.d.ts +6 -0
  174. package/lib/modules/OpenData/index.d.ts +24 -0
  175. package/lib/modules/OpenData/index.js +119 -0
  176. package/lib/modules/OpenData/types.d.ts +73 -0
  177. package/lib/modules/OpenData/types.js +17 -0
  178. package/lib/modules/OpenData/utils.d.ts +2 -0
  179. package/lib/modules/OpenData/utils.js +111 -0
  180. package/lib/modules/Order/index.d.ts +66 -1
  181. package/lib/modules/Order/index.js +525 -0
  182. package/lib/modules/Order/types.d.ts +174 -12
  183. package/lib/modules/Order/utils.d.ts +118 -0
  184. package/lib/modules/Order/utils.js +483 -2
  185. package/lib/modules/Product/utils.js +2 -2
  186. package/lib/modules/ProductList/index.d.ts +3 -1
  187. package/lib/modules/ProductList/index.js +45 -34
  188. package/lib/modules/Quotation/index.d.ts +48 -0
  189. package/lib/modules/Quotation/index.js +152 -0
  190. package/lib/modules/Quotation/types.d.ts +42 -0
  191. package/lib/modules/Quotation/types.js +17 -0
  192. package/lib/modules/Rules/index.js +17 -18
  193. package/lib/modules/SalesSummary/index.d.ts +63 -0
  194. package/lib/modules/SalesSummary/index.js +105 -0
  195. package/lib/modules/SalesSummary/types.d.ts +60 -0
  196. package/lib/modules/SalesSummary/types.js +17 -0
  197. package/lib/modules/SalesSummary/utils.d.ts +30 -0
  198. package/lib/modules/SalesSummary/utils.js +420 -0
  199. package/lib/modules/ScanOrderLogger/index.d.ts +23 -0
  200. package/lib/modules/ScanOrderLogger/index.js +147 -0
  201. package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
  202. package/lib/modules/ScanOrderLogger/providers/feishu.js +157 -0
  203. package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
  204. package/lib/modules/ScanOrderLogger/providers/grafana.js +52 -0
  205. package/lib/modules/ScanOrderLogger/types.d.ts +53 -0
  206. package/lib/modules/ScanOrderLogger/types.js +17 -0
  207. package/lib/modules/Schedule/getDateIsInSchedule.js +9 -11
  208. package/lib/modules/Schedule/utils.d.ts +1 -1
  209. package/lib/modules/Summary/utils.d.ts +3 -3
  210. package/lib/modules/Summary/utils.js +22 -16
  211. package/lib/modules/index.d.ts +4 -0
  212. package/lib/modules/index.js +9 -1
  213. package/lib/solution/BookingByStep/index.d.ts +3 -3
  214. package/lib/solution/BookingByStep/index.js +2 -2
  215. package/lib/solution/BookingByStep/types.d.ts +3 -1
  216. package/lib/solution/BookingByStep/types.js +10 -0
  217. package/lib/solution/ScanOrder/index.d.ts +158 -0
  218. package/lib/solution/ScanOrder/index.js +2135 -0
  219. package/lib/solution/ScanOrder/types.d.ts +306 -0
  220. package/lib/solution/ScanOrder/types.js +36 -0
  221. package/lib/solution/ScanOrder/utils.d.ts +172 -0
  222. package/lib/solution/ScanOrder/utils.js +658 -0
  223. package/lib/solution/ShopDiscount/index.d.ts +1 -0
  224. package/lib/solution/ShopDiscount/index.js +4 -2
  225. package/lib/solution/VenueBooking/index.d.ts +201 -0
  226. package/lib/solution/VenueBooking/index.js +1937 -0
  227. package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
  228. package/lib/solution/VenueBooking/types.d.ts +154 -0
  229. package/lib/solution/VenueBooking/types.js +44 -0
  230. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
  231. package/lib/solution/VenueBooking/utils/dateSummary.js +110 -0
  232. package/lib/solution/VenueBooking/utils/resource.d.ts +14 -0
  233. package/lib/solution/VenueBooking/utils/resource.js +92 -0
  234. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +38 -0
  235. package/lib/solution/VenueBooking/utils/slotMerge.js +237 -0
  236. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
  237. package/lib/solution/VenueBooking/utils/timeSlot.js +339 -0
  238. package/lib/solution/VenueBooking/utils.d.ts +1 -0
  239. package/lib/solution/VenueBooking/utils.js +69 -0
  240. package/lib/solution/index.d.ts +2 -0
  241. package/lib/solution/index.js +5 -1
  242. package/package.json +1 -1
@@ -0,0 +1,3472 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ 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; } }
4
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
5
+ 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; } } }; }
6
+ 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; }
7
+ 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); } }
8
+ 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); }); }; }
9
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10
+ 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); } }
11
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
12
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
13
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
14
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
15
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
16
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
17
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
18
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
19
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
20
+ 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."); }
21
+ 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); }
22
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
23
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
24
+ 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; }
25
+ 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; }
26
+ 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; }
27
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
28
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
29
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
30
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
31
+ import { BaseModule } from "../../modules/BaseModule";
32
+ import { DEFAULT_SLOT_CONFIG, VenueBookingHooks } from "./types";
33
+ import { attachItemRuleLimitsToTopLevelProducts, buildProductKey, buildItemRuleBusinessData, createEmptySummary, getProductIdentityIndex, getSafeProductNum, normalizeOrderProduct, normalizeItemRuleStrategies, toNonNegativeInt, toPriceString } from "./utils";
34
+ import { createModule } from "../BookingByStep/types";
35
+ import { ProductList } from "../../modules/ProductList";
36
+ import { DateModule } from "../../modules/Date";
37
+ import { ScheduleModule } from "../../modules/Schedule";
38
+ import { calcMinTimeMaxTimeBySchedules } from "../../modules/Schedule/utils";
39
+ import { QuotationModule } from "../../modules/Quotation";
40
+ import { OpenDataModule } from "../../modules/OpenData";
41
+ import { AccountHooks } from "../../modules/Account/types";
42
+ import dayjs from 'dayjs';
43
+ import { ItemRuleEvaluator } from "../../model/strategy/adapter/itemRule";
44
+ import { extractResourceIds, buildResourceProductMap } from "./utils/resource";
45
+ import { buildTimeSlotGrid, isBusinessHoursCrossDay, generateTimeLabels } from "./utils/timeSlot";
46
+ import { buildDateRangeSummary } from "./utils/dateSummary";
47
+ import { mergeConsecutiveSlots, expandMergedSlotToIndividual, buildVenueIdentityKey, buildVenueBookingEntry, buildVenueResourceMetadata, buildPriceBreakdown } from "./utils/slotMerge";
48
+ import { composeLinePrice, createUuidV4, sumOptionUnitPrice } from "../../modules/Order/utils";
49
+ import { OrderModule } from "../../modules/Order";
50
+ import { RegisterAndLoginHooks } from "../RegisterAndLogin/types";
51
+ import Decimal from 'decimal.js';
52
+ export * from "./types";
53
+ var OPEN_DATA_SECTION_CODES = ['basic', 'fulfillment', 'reservation', 'sale', 'menu', 'availability', 'workflow', 'checkout'];
54
+ function cloneCustomDepositData(customDepositData) {
55
+ if (!customDepositData || _typeof(customDepositData) !== 'object') return undefined;
56
+ return _objectSpread(_objectSpread({}, customDepositData), {}, {
57
+ self_deposit_policy_ids: Array.isArray(customDepositData.self_deposit_policy_ids) ? _toConsumableArray(customDepositData.self_deposit_policy_ids) : [],
58
+ deposit_policy_ids: Array.isArray(customDepositData.deposit_policy_ids) ? _toConsumableArray(customDepositData.deposit_policy_ids) : [],
59
+ deposit_policy_data: Array.isArray(customDepositData.deposit_policy_data) ? _toConsumableArray(customDepositData.deposit_policy_data) : []
60
+ });
61
+ }
62
+ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
63
+ _inherits(VenueBookingImpl, _BaseModule);
64
+ var _super = _createSuper(VenueBookingImpl);
65
+ function VenueBookingImpl(name, version) {
66
+ var _this;
67
+ _classCallCheck(this, VenueBookingImpl);
68
+ _this = _super.call(this, name, version);
69
+ _defineProperty(_assertThisInitialized(_this), "defaultName", 'venueBooking');
70
+ _defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
71
+ _defineProperty(_assertThisInitialized(_this), "isSolution", true);
72
+ _defineProperty(_assertThisInitialized(_this), "initializeOptions", {});
73
+ _defineProperty(_assertThisInitialized(_this), "store", {
74
+ entryContext: null,
75
+ status: 'idle',
76
+ flow: {},
77
+ error: null,
78
+ products: undefined,
79
+ rawResourceData: [],
80
+ slotConfig: _objectSpread({}, DEFAULT_SLOT_CONFIG),
81
+ itemRuleQuantityLimits: [],
82
+ cartValidation: {
83
+ passed: null,
84
+ failures: []
85
+ }
86
+ });
87
+ _defineProperty(_assertThisInitialized(_this), "otherParams", {});
88
+ _defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
89
+ _defineProperty(_assertThisInitialized(_this), "window", void 0);
90
+ _defineProperty(_assertThisInitialized(_this), "request", void 0);
91
+ _defineProperty(_assertThisInitialized(_this), "baseSlotConfig", _objectSpread({}, DEFAULT_SLOT_CONFIG));
92
+ _defineProperty(_assertThisInitialized(_this), "itemRuleEvaluator", new ItemRuleEvaluator());
93
+ _defineProperty(_assertThisInitialized(_this), "itemRuleConfigs", []);
94
+ _defineProperty(_assertThisInitialized(_this), "itemRuleConfigsPromise", null);
95
+ _defineProperty(_assertThisInitialized(_this), "itemRulePrefillApplied", false);
96
+ _defineProperty(_assertThisInitialized(_this), "itemRuleRuntimeConfig", {});
97
+ _defineProperty(_assertThisInitialized(_this), "resourceProductMap", new Map());
98
+ _defineProperty(_assertThisInitialized(_this), "loginEffectDisposers", []);
99
+ _defineProperty(_assertThisInitialized(_this), "customerLoginRefreshInFlight", null);
100
+ _defineProperty(_assertThisInitialized(_this), "customerLoginRefreshIdInFlight", null);
101
+ _defineProperty(_assertThisInitialized(_this), "loadAllProductsInFlight", null);
102
+ _defineProperty(_assertThisInitialized(_this), "productsLoaded", false);
103
+ _defineProperty(_assertThisInitialized(_this), "loadOpenDataConfigInFlight", null);
104
+ return _this;
105
+ }
106
+ _createClass(VenueBookingImpl, [{
107
+ key: "getLoggerContext",
108
+ value: function getLoggerContext() {
109
+ return {
110
+ cacheId: this.cacheId,
111
+ solutionName: this.name,
112
+ moduleName: 'venueBooking'
113
+ };
114
+ }
115
+ }, {
116
+ key: "safeStringify",
117
+ value: function safeStringify(value) {
118
+ try {
119
+ return JSON.stringify(value);
120
+ } catch (_unused) {
121
+ return undefined;
122
+ }
123
+ }
124
+ }, {
125
+ key: "pickErrorMessage",
126
+ value: function pickErrorMessage(error) {
127
+ var _error$data, _error$response, _error$error;
128
+ var candidates = [error.message, (_error$data = error.data) === null || _error$data === void 0 ? void 0 : _error$data.message, (_error$response = error.response) === null || _error$response === void 0 || (_error$response = _error$response.data) === null || _error$response === void 0 ? void 0 : _error$response.message, (_error$error = error.error) === null || _error$error === void 0 ? void 0 : _error$error.message];
129
+ for (var _i = 0, _candidates = candidates; _i < _candidates.length; _i++) {
130
+ var candidate = _candidates[_i];
131
+ if (typeof candidate === 'string' && candidate.trim()) return candidate;
132
+ }
133
+ return undefined;
134
+ }
135
+ }, {
136
+ key: "serializeError",
137
+ value: function serializeError(error) {
138
+ if (error instanceof Error) {
139
+ return {
140
+ name: error.name,
141
+ message: error.message,
142
+ stack: error.stack
143
+ };
144
+ }
145
+ if (error && _typeof(error) === 'object') {
146
+ var raw = error;
147
+ var message = this.pickErrorMessage(raw) || this.safeStringify(raw) || String(error);
148
+ return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, typeof raw.name === 'string' ? {
149
+ name: raw.name
150
+ } : {}), {}, {
151
+ message: message
152
+ }, 'code' in raw ? {
153
+ code: raw.code
154
+ } : {}), 'status' in raw ? {
155
+ status: raw.status
156
+ } : {}), this.safeStringify(raw) ? {
157
+ raw: this.safeStringify(raw)
158
+ } : {});
159
+ }
160
+ return {
161
+ message: String(error)
162
+ };
163
+ }
164
+ }, {
165
+ key: "addVenueBookingLog",
166
+ value: function () {
167
+ var _addVenueBookingLog = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
168
+ var payload, extra, logger;
169
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
170
+ while (1) switch (_context.prev = _context.next) {
171
+ case 0:
172
+ payload = _objectSpread({
173
+ cacheId: this.cacheId
174
+ }, params.payload || {});
175
+ extra = _objectSpread({}, params.extra || {});
176
+ logger = this.store.scanOrderLogger;
177
+ if (logger) {
178
+ _context.next = 6;
179
+ break;
180
+ }
181
+ if ((params.level || 'info') === 'error') {
182
+ console.error('[VenueBooking][log-fallback]', params.title, {
183
+ payload: payload,
184
+ extra: extra
185
+ });
186
+ } else {
187
+ console.log('[VenueBooking][log-fallback]', params.title, {
188
+ payload: payload,
189
+ extra: extra
190
+ });
191
+ }
192
+ return _context.abrupt("return");
193
+ case 6:
194
+ _context.next = 8;
195
+ return logger.addLog(_objectSpread(_objectSpread({}, params), {}, {
196
+ payload: payload,
197
+ extra: extra
198
+ }));
199
+ case 8:
200
+ case "end":
201
+ return _context.stop();
202
+ }
203
+ }, _callee, this);
204
+ }));
205
+ function addVenueBookingLog(_x) {
206
+ return _addVenueBookingLog.apply(this, arguments);
207
+ }
208
+ return addVenueBookingLog;
209
+ }()
210
+ }, {
211
+ key: "logMethodStart",
212
+ value: function logMethodStart(method) {
213
+ var payload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
214
+ void this.addVenueBookingLog({
215
+ level: 'info',
216
+ title: "[VenueBooking] ".concat(method, " start"),
217
+ payload: _objectSpread({
218
+ method: method
219
+ }, payload)
220
+ });
221
+ }
222
+ }, {
223
+ key: "logMethodSuccess",
224
+ value: function logMethodSuccess(method) {
225
+ var payload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
226
+ void this.addVenueBookingLog({
227
+ level: 'info',
228
+ title: "[VenueBooking] ".concat(method, " success"),
229
+ payload: _objectSpread({
230
+ method: method
231
+ }, payload)
232
+ });
233
+ }
234
+ }, {
235
+ key: "logMethodError",
236
+ value: function logMethodError(method, error) {
237
+ var payload = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
238
+ void this.addVenueBookingLog({
239
+ level: 'error',
240
+ title: "[VenueBooking] ".concat(method, " failed"),
241
+ payload: _objectSpread(_objectSpread({
242
+ method: method
243
+ }, payload), {}, {
244
+ error: this.serializeError(error)
245
+ })
246
+ });
247
+ }
248
+ }, {
249
+ key: "addLog",
250
+ value: function () {
251
+ var _addLog = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
252
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
253
+ while (1) switch (_context2.prev = _context2.next) {
254
+ case 0:
255
+ _context2.next = 2;
256
+ return this.addVenueBookingLog(_objectSpread(_objectSpread({}, params), {}, {
257
+ payload: _objectSpread({
258
+ source: 'ui-bridge'
259
+ }, params.payload || {})
260
+ }));
261
+ case 2:
262
+ case "end":
263
+ return _context2.stop();
264
+ }
265
+ }, _callee2, this);
266
+ }));
267
+ function addLog(_x2) {
268
+ return _addLog.apply(this, arguments);
269
+ }
270
+ return addLog;
271
+ }()
272
+ }, {
273
+ key: "normalizeCustomerId",
274
+ value: function normalizeCustomerId(value) {
275
+ var customerId = Number(value);
276
+ if (!Number.isFinite(customerId) || customerId <= 0) return null;
277
+ return customerId;
278
+ }
279
+ }, {
280
+ key: "resolveCustomerIdFromLoginPayload",
281
+ value: function resolveCustomerIdFromLoginPayload(payload) {
282
+ var _payload$user, _payload$user2, _payload$user3, _payload$user4, _payload$account, _payload$account2, _payload$account3, _payload$_origin;
283
+ var candidates = [payload === null || payload === void 0 ? void 0 : payload.customerId, payload === null || payload === void 0 ? void 0 : payload.customer_id, payload === null || payload === void 0 ? void 0 : payload.id, payload === null || payload === void 0 || (_payload$user = payload.user) === null || _payload$user === void 0 ? void 0 : _payload$user.customerId, payload === null || payload === void 0 || (_payload$user2 = payload.user) === null || _payload$user2 === void 0 ? void 0 : _payload$user2.customer_id, payload === null || payload === void 0 || (_payload$user3 = payload.user) === null || _payload$user3 === void 0 ? void 0 : _payload$user3.id, payload === null || payload === void 0 || (_payload$user4 = payload.user) === null || _payload$user4 === void 0 || (_payload$user4 = _payload$user4._origin) === null || _payload$user4 === void 0 ? void 0 : _payload$user4.customer_id, payload === null || payload === void 0 || (_payload$account = payload.account) === null || _payload$account === void 0 ? void 0 : _payload$account.customerId, payload === null || payload === void 0 || (_payload$account2 = payload.account) === null || _payload$account2 === void 0 ? void 0 : _payload$account2.customer_id, payload === null || payload === void 0 || (_payload$account3 = payload.account) === null || _payload$account3 === void 0 ? void 0 : _payload$account3.id, payload === null || payload === void 0 || (_payload$_origin = payload._origin) === null || _payload$_origin === void 0 ? void 0 : _payload$_origin.customer_id];
284
+ for (var _i2 = 0, _candidates2 = candidates; _i2 < _candidates2.length; _i2++) {
285
+ var candidate = _candidates2[_i2];
286
+ var customerId = this.normalizeCustomerId(candidate);
287
+ if (customerId) return customerId;
288
+ }
289
+ return null;
290
+ }
291
+ }, {
292
+ key: "clearLoginEffectListeners",
293
+ value: function clearLoginEffectListeners() {
294
+ var _iterator = _createForOfIteratorHelper(this.loginEffectDisposers),
295
+ _step;
296
+ try {
297
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
298
+ var dispose = _step.value;
299
+ dispose();
300
+ }
301
+ } catch (err) {
302
+ _iterator.e(err);
303
+ } finally {
304
+ _iterator.f();
305
+ }
306
+ this.loginEffectDisposers = [];
307
+ }
308
+ }, {
309
+ key: "registerLoginEffect",
310
+ value: function registerLoginEffect(event, callback) {
311
+ var _this$core;
312
+ var effects = (_this$core = this.core) === null || _this$core === void 0 ? void 0 : _this$core.effects;
313
+ if (!(effects !== null && effects !== void 0 && effects.on)) return;
314
+ effects.on(event, callback);
315
+ this.loginEffectDisposers.push(function () {
316
+ if (typeof effects.off === 'function') {
317
+ effects.off(event, callback);
318
+ }
319
+ });
320
+ }
321
+ }, {
322
+ key: "registerCustomerLoginListeners",
323
+ value: function registerCustomerLoginListeners() {
324
+ var _this$core2,
325
+ _this$core3,
326
+ _accountModule$getCur,
327
+ _accountModule$getAcc,
328
+ _this2 = this;
329
+ this.clearLoginEffectListeners();
330
+ var accountModule = (_this$core2 = this.core) === null || _this$core2 === void 0 ? void 0 : _this$core2.getModule('account');
331
+ var registerAndLoginModule = (_this$core3 = this.core) === null || _this$core3 === void 0 ? void 0 : _this$core3.getModule('registerAndLogin');
332
+ var currentAccount = (accountModule === null || accountModule === void 0 || (_accountModule$getCur = accountModule.getCurrentAccount) === null || _accountModule$getCur === void 0 ? void 0 : _accountModule$getCur.call(accountModule)) || (accountModule === null || accountModule === void 0 || (_accountModule$getAcc = accountModule.getAccount) === null || _accountModule$getAcc === void 0 ? void 0 : _accountModule$getAcc.call(accountModule)) || null;
333
+ var createHandleLogin = function createHandleLogin(eventName) {
334
+ return /*#__PURE__*/function () {
335
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(payload) {
336
+ var customerId;
337
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
338
+ while (1) switch (_context3.prev = _context3.next) {
339
+ case 0:
340
+ customerId = _this2.resolveCustomerIdFromLoginPayload(payload);
341
+ if (customerId) {
342
+ _context3.next = 3;
343
+ break;
344
+ }
345
+ return _context3.abrupt("return");
346
+ case 3:
347
+ _context3.next = 5;
348
+ return _this2.refreshOrderMarketingAfterLogin({
349
+ customerId: customerId
350
+ });
351
+ case 5:
352
+ case "end":
353
+ return _context3.stop();
354
+ }
355
+ }, _callee3);
356
+ }));
357
+ return function (_x3) {
358
+ return _ref.apply(this, arguments);
359
+ };
360
+ }();
361
+ };
362
+ this.registerLoginEffect(AccountHooks.OnLogin, createHandleLogin(AccountHooks.OnLogin));
363
+ this.registerLoginEffect(RegisterAndLoginHooks.onLoginSuccess, createHandleLogin(RegisterAndLoginHooks.onLoginSuccess));
364
+ }
365
+ }, {
366
+ key: "refreshOrderMarketingAfterLogin",
367
+ value: function () {
368
+ var _refreshOrderMarketingAfterLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(params) {
369
+ var _this3 = this;
370
+ var refreshTask;
371
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
372
+ while (1) switch (_context5.prev = _context5.next) {
373
+ case 0:
374
+ if (this.store.order) {
375
+ _context5.next = 2;
376
+ break;
377
+ }
378
+ throw new Error('order 模块未初始化');
379
+ case 2:
380
+ if (!this.customerLoginRefreshInFlight) {
381
+ _context5.next = 9;
382
+ break;
383
+ }
384
+ if (!(this.customerLoginRefreshIdInFlight === params.customerId)) {
385
+ _context5.next = 7;
386
+ break;
387
+ }
388
+ _context5.next = 6;
389
+ return this.customerLoginRefreshInFlight;
390
+ case 6:
391
+ return _context5.abrupt("return");
392
+ case 7:
393
+ _context5.next = 9;
394
+ return this.customerLoginRefreshInFlight;
395
+ case 9:
396
+ this.customerLoginRefreshIdInFlight = params.customerId;
397
+ refreshTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
398
+ var _this3$otherParams;
399
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
400
+ while (1) switch (_context4.prev = _context4.next) {
401
+ case 0:
402
+ if (!_this3.store.quotation) {
403
+ _context4.next = 3;
404
+ break;
405
+ }
406
+ _context4.next = 3;
407
+ return _this3.store.quotation.loadQuotations({
408
+ channel: (_this3$otherParams = _this3.otherParams) === null || _this3$otherParams === void 0 ? void 0 : _this3$otherParams.channel
409
+ });
410
+ case 3:
411
+ _this3.recalculateOrderPricesFromQuotation();
412
+ _context4.next = 6;
413
+ return _this3.store.order.loadDiscountConfig({
414
+ customerId: params.customerId
415
+ });
416
+ case 6:
417
+ _context4.next = 8;
418
+ return _this3.store.order.recalculateSummary({
419
+ createIfMissing: true
420
+ });
421
+ case 8:
422
+ _this3.store.order.persistTempOrder();
423
+ _context4.next = 11;
424
+ return _this3.refreshItemRuleQuantityLimits();
425
+ case 11:
426
+ _context4.next = 13;
427
+ return _this3.refreshCartValidationPassed();
428
+ case 13:
429
+ case "end":
430
+ return _context4.stop();
431
+ }
432
+ }, _callee4);
433
+ }))();
434
+ this.customerLoginRefreshInFlight = refreshTask;
435
+ _context5.prev = 12;
436
+ _context5.next = 15;
437
+ return refreshTask;
438
+ case 15:
439
+ _context5.next = 20;
440
+ break;
441
+ case 17:
442
+ _context5.prev = 17;
443
+ _context5.t0 = _context5["catch"](12);
444
+ throw _context5.t0;
445
+ case 20:
446
+ _context5.prev = 20;
447
+ if (this.customerLoginRefreshInFlight === refreshTask) {
448
+ this.customerLoginRefreshInFlight = null;
449
+ this.customerLoginRefreshIdInFlight = null;
450
+ }
451
+ return _context5.finish(20);
452
+ case 23:
453
+ case "end":
454
+ return _context5.stop();
455
+ }
456
+ }, _callee5, this, [[12, 17, 20, 23]]);
457
+ }));
458
+ function refreshOrderMarketingAfterLogin(_x4) {
459
+ return _refreshOrderMarketingAfterLogin.apply(this, arguments);
460
+ }
461
+ return refreshOrderMarketingAfterLogin;
462
+ }()
463
+ }, {
464
+ key: "initialize",
465
+ value: function () {
466
+ var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(core) {
467
+ var _options$otherParams,
468
+ _options$otherParams2,
469
+ _this$otherParams,
470
+ _this$otherParams2,
471
+ _this$otherParams3,
472
+ _this4 = this,
473
+ _this$otherParams4,
474
+ _this$otherParams5;
475
+ var options,
476
+ baseModules,
477
+ venueProductsModule,
478
+ addonProductsModule,
479
+ dateModule,
480
+ scheduleModule,
481
+ quotationModule,
482
+ openDataModule,
483
+ _this$store$order,
484
+ _this$store$order2,
485
+ _this$store$quotation,
486
+ _this$otherParams6,
487
+ _args6 = arguments;
488
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
489
+ while (1) switch (_context6.prev = _context6.next) {
490
+ case 0:
491
+ options = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : {};
492
+ this.logMethodStart('initialize');
493
+ this.core = core;
494
+ this.initializeOptions = options || {};
495
+ this.store = _objectSpread(_objectSpread({}, this.store), options.store);
496
+ this.store.entryContext = ((_options$otherParams = options.otherParams) === null || _options$otherParams === void 0 ? void 0 : _options$otherParams.entryContext) || this.store.entryContext;
497
+ this.store.status = 'initializing';
498
+ this.store.error = null;
499
+ this.store.rawResourceData = [];
500
+ this.baseSlotConfig = _objectSpread(_objectSpread({}, DEFAULT_SLOT_CONFIG), ((_options$otherParams2 = options.otherParams) === null || _options$otherParams2 === void 0 ? void 0 : _options$otherParams2.slotConfig) || {});
501
+ this.store.slotConfig = _objectSpread({}, this.baseSlotConfig);
502
+ this.otherParams = options.otherParams || {};
503
+ this.cacheId = (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.cacheId;
504
+ this.itemRuleRuntimeConfig = ((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.venueBookingItemRule) || ((_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.itemRule) || {};
505
+ this.itemRuleConfigs = [];
506
+ this.itemRuleConfigsPromise = null;
507
+ this.itemRulePrefillApplied = false;
508
+ this.store.itemRuleQuantityLimits = [];
509
+ this.store.cartValidation = {
510
+ passed: null,
511
+ failures: []
512
+ };
513
+ this.window = core.getPlugin('window');
514
+ this.request = core.getPlugin('request');
515
+ if (this.window) {
516
+ _context6.next = 24;
517
+ break;
518
+ }
519
+ this.logMethodError('initialize', 'window plugin missing');
520
+ throw new Error('venueBooking解决方案需要 window 插件支持');
521
+ case 24:
522
+ if (this.request) {
523
+ _context6.next = 27;
524
+ break;
525
+ }
526
+ this.logMethodError('initialize', 'request plugin missing');
527
+ throw new Error('venueBooking解决方案需要 request 插件支持');
528
+ case 27:
529
+ // 注册基础模块(order, salesSummary, products, logger)
530
+ baseModules = ['scanOrderLogger', 'products', 'order', 'salesSummary'];
531
+ baseModules.forEach(function (step) {
532
+ var targetModule = createModule(step, _this4.name);
533
+ if (targetModule) {
534
+ var _this4$store$order, _this4$otherParams, _this4$otherParams2, _this4$otherParams3, _this4$otherParams4;
535
+ _this4.store[step] = targetModule;
536
+ var initialState = step === 'salesSummary' ? {
537
+ summary: ((_this4$store$order = _this4.store.order) === null || _this4$store$order === void 0 || (_this4$store$order = _this4$store$order.getTempOrder()) === null || _this4$store$order === void 0 ? void 0 : _this4$store$order.summary) || createEmptySummary()
538
+ } : {};
539
+ var loggerProvider = ((_this4$otherParams = _this4.otherParams) === null || _this4$otherParams === void 0 ? void 0 : _this4$otherParams.loggerProvider) || 'feishu';
540
+ var loggerConfig = ((_this4$otherParams2 = _this4.otherParams) === null || _this4$otherParams2 === void 0 ? void 0 : _this4$otherParams2.loggerConfig) || {
541
+ feishu: {
542
+ webhook: 'https://open.feishu.cn/open-apis/bot/v2/hook/8f069b14-9d39-4728-8f78-b56f393bfde8',
543
+ errorHook: 'https://open.feishu.cn/open-apis/bot/v2/hook/bdefae5e-f233-4705-8688-946887d9543d'
544
+ }
545
+ };
546
+ _this4.core.registerModule(targetModule, {
547
+ initialState: initialState,
548
+ otherParams: _objectSpread(_objectSpread({}, _this4.otherParams), {}, {
549
+ fatherModule: _this4.name,
550
+ openCache: (_this4$otherParams3 = _this4.otherParams) !== null && _this4$otherParams3 !== void 0 && _this4$otherParams3.cacheId ? true : false,
551
+ cacheId: (_this4$otherParams4 = _this4.otherParams) === null || _this4$otherParams4 === void 0 ? void 0 : _this4$otherParams4.cacheId,
552
+ salesSummaryModuleName: "".concat(_this4.name, "_salesSummary"),
553
+ provider: loggerProvider,
554
+ providerConfig: loggerConfig,
555
+ context: _this4.getLoggerContext()
556
+ })
557
+ });
558
+ } else {
559
+ _this4.logMethodError('initialize', "module ".concat(step, " missing"));
560
+ throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
561
+ }
562
+ });
563
+
564
+ // 注册场地商品列表模块
565
+ venueProductsModule = new ProductList("".concat(this.name, "_venueProducts"));
566
+ this.store.venueProducts = venueProductsModule;
567
+ this.core.registerModule(venueProductsModule, {
568
+ otherParams: _objectSpread(_objectSpread({}, this.otherParams), {}, {
569
+ fatherModule: this.name
570
+ })
571
+ });
572
+
573
+ // 注册附加商品列表模块
574
+ addonProductsModule = new ProductList("".concat(this.name, "_addonProducts"));
575
+ this.store.addonProducts = addonProductsModule;
576
+ this.core.registerModule(addonProductsModule, {
577
+ otherParams: _objectSpread(_objectSpread({}, this.otherParams), {}, {
578
+ fatherModule: this.name
579
+ })
580
+ });
581
+
582
+ // 注册日期模块
583
+ dateModule = new DateModule("".concat(this.name, "_date"));
584
+ this.store.date = dateModule;
585
+ this.core.registerModule(dateModule, {
586
+ otherParams: _objectSpread(_objectSpread({}, this.otherParams), {}, {
587
+ fatherModule: this.name,
588
+ cacheId: this.cacheId
589
+ })
590
+ });
591
+
592
+ // 注册日程模块
593
+ scheduleModule = new ScheduleModule("".concat(this.name, "_schedule"));
594
+ this.store.schedule = scheduleModule;
595
+ this.core.registerModule(scheduleModule, {
596
+ otherParams: _objectSpread(_objectSpread({}, this.otherParams), {}, {
597
+ fatherModule: this.name
598
+ })
599
+ });
600
+
601
+ // 注册报价单模块
602
+ quotationModule = new QuotationModule("".concat(this.name, "_quotation"));
603
+ this.store.quotation = quotationModule;
604
+ this.core.registerModule(quotationModule, {
605
+ otherParams: _objectSpread(_objectSpread({}, this.otherParams), {}, {
606
+ fatherModule: this.name
607
+ })
608
+ });
609
+
610
+ // 注册 OpenData 配置模块
611
+ openDataModule = new OpenDataModule("".concat(this.name, "_openData"));
612
+ this.store.openData = openDataModule;
613
+ this.core.registerModule(openDataModule, {
614
+ otherParams: _objectSpread(_objectSpread({}, this.otherParams), {}, {
615
+ fatherModule: this.name,
616
+ openCache: !!((_this$otherParams4 = this.otherParams) !== null && _this$otherParams4 !== void 0 && _this$otherParams4.cacheId),
617
+ cacheId: (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.cacheId
618
+ })
619
+ });
620
+ if (this.store.scanOrderLogger) {
621
+ this.store.scanOrderLogger.setContext(this.getLoggerContext());
622
+ }
623
+ this.registerCustomerLoginListeners();
624
+ console.log('[VenueBooking] 初始化开始');
625
+ _context6.prev = 50;
626
+ _context6.next = 53;
627
+ return (_this$store$order = this.store.order) === null || _this$store$order === void 0 ? void 0 : _this$store$order.recalculateSummary({
628
+ createIfMissing: false
629
+ });
630
+ case 53:
631
+ (_this$store$order2 = this.store.order) === null || _this$store$order2 === void 0 || _this$store$order2.persistTempOrder();
632
+ _context6.next = 56;
633
+ return this.loadRuntimeConfigs();
634
+ case 56:
635
+ if (!this.store.schedule) {
636
+ _context6.next = 61;
637
+ break;
638
+ }
639
+ _context6.next = 59;
640
+ return this.store.schedule.loadAllSchedule();
641
+ case 59:
642
+ this.injectScheduleResolverToQuotation();
643
+ (_this$store$quotation = this.store.quotation) === null || _this$store$quotation === void 0 || _this$store$quotation.loadQuotations({
644
+ channel: (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.channel
645
+ });
646
+ case 61:
647
+ _context6.next = 63;
648
+ return this.refreshItemRuleQuantityLimits();
649
+ case 63:
650
+ this.store.status = 'ready';
651
+ console.log('[VenueBooking] 初始化完成');
652
+ _context6.next = 67;
653
+ return this.core.effects.emit(VenueBookingHooks.onInited, {
654
+ status: this.store.status
655
+ });
656
+ case 67:
657
+ this.logMethodSuccess('initialize', {
658
+ status: this.store.status
659
+ });
660
+ _context6.next = 77;
661
+ break;
662
+ case 70:
663
+ _context6.prev = 70;
664
+ _context6.t0 = _context6["catch"](50);
665
+ this.store.status = 'error';
666
+ this.store.error = _context6.t0 instanceof Error ? _context6.t0.message : '初始化失败';
667
+ console.error('[VenueBooking] 初始化失败', _context6.t0);
668
+ this.logMethodError('initialize', _context6.t0, {
669
+ status: this.store.status
670
+ });
671
+ throw _context6.t0;
672
+ case 77:
673
+ case "end":
674
+ return _context6.stop();
675
+ }
676
+ }, _callee6, this, [[50, 70]]);
677
+ }));
678
+ function initialize(_x5) {
679
+ return _initialize.apply(this, arguments);
680
+ }
681
+ return initialize;
682
+ }()
683
+ }, {
684
+ key: "destroy",
685
+ value: function () {
686
+ var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
687
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
688
+ while (1) switch (_context7.prev = _context7.next) {
689
+ case 0:
690
+ this.logMethodStart('destroy');
691
+ this.clearLoginEffectListeners();
692
+ _context7.next = 4;
693
+ return this.core.effects.emit(VenueBookingHooks.onDestroy, {});
694
+ case 4:
695
+ console.log('[VenueBooking] 已销毁');
696
+ this.logMethodSuccess('destroy');
697
+ case 6:
698
+ case "end":
699
+ return _context7.stop();
700
+ }
701
+ }, _callee7, this);
702
+ }));
703
+ function destroy() {
704
+ return _destroy.apply(this, arguments);
705
+ }
706
+ return destroy;
707
+ }()
708
+ }, {
709
+ key: "retryInit",
710
+ value: function () {
711
+ var _retryInit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
712
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
713
+ while (1) switch (_context8.prev = _context8.next) {
714
+ case 0:
715
+ this.logMethodStart('retryInit');
716
+ console.log('[VenueBooking] retryInit 调用');
717
+ _context8.next = 4;
718
+ return this.core.effects.emit(VenueBookingHooks.onRetryInit, {});
719
+ case 4:
720
+ _context8.prev = 4;
721
+ _context8.next = 7;
722
+ return this.initialize(this.core, this.initializeOptions);
723
+ case 7:
724
+ this.logMethodSuccess('retryInit');
725
+ _context8.next = 14;
726
+ break;
727
+ case 10:
728
+ _context8.prev = 10;
729
+ _context8.t0 = _context8["catch"](4);
730
+ this.logMethodError('retryInit', _context8.t0);
731
+ throw _context8.t0;
732
+ case 14:
733
+ case "end":
734
+ return _context8.stop();
735
+ }
736
+ }, _callee8, this, [[4, 10]]);
737
+ }));
738
+ function retryInit() {
739
+ return _retryInit.apply(this, arguments);
740
+ }
741
+ return retryInit;
742
+ }()
743
+ }, {
744
+ key: "refresh",
745
+ value: function () {
746
+ var _refresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
747
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
748
+ while (1) switch (_context9.prev = _context9.next) {
749
+ case 0:
750
+ this.logMethodStart('refresh');
751
+ console.log('[VenueBooking] refresh 调用');
752
+ _context9.prev = 2;
753
+ this.store.status = 'initializing';
754
+ _context9.next = 6;
755
+ return this.loadRuntimeConfigs();
756
+ case 6:
757
+ _context9.next = 8;
758
+ return this.refreshItemRuleQuantityLimits();
759
+ case 8:
760
+ this.store.status = 'ready';
761
+ _context9.next = 11;
762
+ return this.core.effects.emit(VenueBookingHooks.onRefresh, {
763
+ status: this.store.status
764
+ });
765
+ case 11:
766
+ this.logMethodSuccess('refresh', {
767
+ status: this.store.status
768
+ });
769
+ _context9.next = 18;
770
+ break;
771
+ case 14:
772
+ _context9.prev = 14;
773
+ _context9.t0 = _context9["catch"](2);
774
+ this.logMethodError('refresh', _context9.t0);
775
+ throw _context9.t0;
776
+ case 18:
777
+ case "end":
778
+ return _context9.stop();
779
+ }
780
+ }, _callee9, this, [[2, 14]]);
781
+ }));
782
+ function refresh() {
783
+ return _refresh.apply(this, arguments);
784
+ }
785
+ return refresh;
786
+ }() // ─── 状态查询 ───
787
+ }, {
788
+ key: "getStatus",
789
+ value: function getStatus() {
790
+ return this.store.status;
791
+ }
792
+ }, {
793
+ key: "getEntryContext",
794
+ value: function getEntryContext() {
795
+ return this.store.entryContext;
796
+ }
797
+ }, {
798
+ key: "getItemRuleQuantityLimits",
799
+ value: function getItemRuleQuantityLimits() {
800
+ return this.store.itemRuleQuantityLimits || [];
801
+ }
802
+ }, {
803
+ key: "getCartValidationPassed",
804
+ value: function getCartValidationPassed() {
805
+ var _this$store$cartValid, _this$store$cartValid2;
806
+ return (_this$store$cartValid = (_this$store$cartValid2 = this.store.cartValidation) === null || _this$store$cartValid2 === void 0 ? void 0 : _this$store$cartValid2.passed) !== null && _this$store$cartValid !== void 0 ? _this$store$cartValid : null;
807
+ }
808
+ }, {
809
+ key: "getCartValidation",
810
+ value: function getCartValidation() {
811
+ return this.store.cartValidation || {
812
+ passed: null,
813
+ failures: []
814
+ };
815
+ }
816
+
817
+ // ─── 场地商品 & 附加商品 ───
818
+ }, {
819
+ key: "loadAllProducts",
820
+ value: function () {
821
+ var _loadAllProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
822
+ var _this5 = this;
823
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
824
+ while (1) switch (_context10.prev = _context10.next) {
825
+ case 0:
826
+ if (!this.loadAllProductsInFlight) {
827
+ _context10.next = 2;
828
+ break;
829
+ }
830
+ return _context10.abrupt("return", this.loadAllProductsInFlight);
831
+ case 2:
832
+ this.loadAllProductsInFlight = this._doLoadAllProducts().finally(function () {
833
+ _this5.loadAllProductsInFlight = null;
834
+ });
835
+ return _context10.abrupt("return", this.loadAllProductsInFlight);
836
+ case 4:
837
+ case "end":
838
+ return _context10.stop();
839
+ }
840
+ }, _callee10, this);
841
+ }));
842
+ function loadAllProducts() {
843
+ return _loadAllProducts.apply(this, arguments);
844
+ }
845
+ return loadAllProducts;
846
+ }()
847
+ }, {
848
+ key: "_doLoadAllProducts",
849
+ value: function () {
850
+ var _doLoadAllProducts2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
851
+ var _this$otherParams7, _this$store$venueProd, associatedMenus, menuListIds, allProducts, list, venueList, addonList, venueStore;
852
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
853
+ while (1) switch (_context11.prev = _context11.next) {
854
+ case 0:
855
+ this.logMethodStart('loadAllProducts');
856
+ _context11.prev = 1;
857
+ if (this.store.venueProducts) {
858
+ _context11.next = 4;
859
+ break;
860
+ }
861
+ throw new Error('venueProducts 模块未初始化');
862
+ case 4:
863
+ if (this.store.addonProducts) {
864
+ _context11.next = 6;
865
+ break;
866
+ }
867
+ throw new Error('addonProducts 模块未初始化');
868
+ case 6:
869
+ _context11.next = 8;
870
+ return this.loadOpenDataConfig();
871
+ case 8:
872
+ associatedMenus = ((_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 || (_this$otherParams7 = _this$otherParams7.openData) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7['menu.associated_menus']) || [];
873
+ if (associatedMenus.length) {
874
+ _context11.next = 12;
875
+ break;
876
+ }
877
+ this.logMethodError('loadAllProducts', new Error('未获取到餐牌配置(menu.associated_menus),请检查 OpenData 配置'));
878
+ throw new Error('未获取到餐牌配置(menu.associated_menus),请检查 OpenData 配置');
879
+ case 12:
880
+ menuListIds = associatedMenus.map(function (n) {
881
+ return Number(n.value);
882
+ });
883
+ _context11.next = 15;
884
+ return this.store.venueProducts.loadProducts({
885
+ menu_list_ids: menuListIds,
886
+ cacheId: this.cacheId,
887
+ schedule_date: dayjs().format('YYYY-MM-DD'),
888
+ schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
889
+ });
890
+ case 15:
891
+ allProducts = _context11.sent;
892
+ list = Array.isArray(allProducts) ? allProducts : [];
893
+ venueList = list.filter(function (p) {
894
+ return p.duration != null;
895
+ });
896
+ addonList = list.filter(function (p) {
897
+ return p.duration == null;
898
+ });
899
+ venueStore = (_this$store$venueProd = this.store.venueProducts) === null || _this$store$venueProd === void 0 ? void 0 : _this$store$venueProd.store;
900
+ if (venueStore) {
901
+ venueStore.list = venueList.slice().sort(function (a, b) {
902
+ return Number(b.sort) - Number(a.sort);
903
+ });
904
+ }
905
+ this.store.addonProducts.addProduct(addonList);
906
+ this.resourceProductMap = buildResourceProductMap(venueList);
907
+ this.productsLoaded = true;
908
+ this.logMethodSuccess('loadAllProducts', {
909
+ total: list.length,
910
+ venueCount: venueList.length,
911
+ addonCount: addonList.length,
912
+ resourceCount: this.resourceProductMap.size
913
+ });
914
+ return _context11.abrupt("return", {
915
+ venueProducts: venueList,
916
+ addonProducts: addonList
917
+ });
918
+ case 28:
919
+ _context11.prev = 28;
920
+ _context11.t0 = _context11["catch"](1);
921
+ this.logMethodError('loadAllProducts', _context11.t0);
922
+ throw _context11.t0;
923
+ case 32:
924
+ case "end":
925
+ return _context11.stop();
926
+ }
927
+ }, _callee11, this, [[1, 28]]);
928
+ }));
929
+ function _doLoadAllProducts() {
930
+ return _doLoadAllProducts2.apply(this, arguments);
931
+ }
932
+ return _doLoadAllProducts;
933
+ }()
934
+ }, {
935
+ key: "loadVenueProducts",
936
+ value: function () {
937
+ var _loadVenueProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
938
+ var result;
939
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
940
+ while (1) switch (_context12.prev = _context12.next) {
941
+ case 0:
942
+ _context12.next = 2;
943
+ return this.loadAllProducts();
944
+ case 2:
945
+ result = _context12.sent;
946
+ return _context12.abrupt("return", result.venueProducts);
947
+ case 4:
948
+ case "end":
949
+ return _context12.stop();
950
+ }
951
+ }, _callee12, this);
952
+ }));
953
+ function loadVenueProducts() {
954
+ return _loadVenueProducts.apply(this, arguments);
955
+ }
956
+ return loadVenueProducts;
957
+ }()
958
+ }, {
959
+ key: "loadAddonProducts",
960
+ value: function () {
961
+ var _loadAddonProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
962
+ var result;
963
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
964
+ while (1) switch (_context13.prev = _context13.next) {
965
+ case 0:
966
+ _context13.next = 2;
967
+ return this.loadAllProducts();
968
+ case 2:
969
+ result = _context13.sent;
970
+ return _context13.abrupt("return", result.addonProducts);
971
+ case 4:
972
+ case "end":
973
+ return _context13.stop();
974
+ }
975
+ }, _callee13, this);
976
+ }));
977
+ function loadAddonProducts() {
978
+ return _loadAddonProducts.apply(this, arguments);
979
+ }
980
+ return loadAddonProducts;
981
+ }()
982
+ }, {
983
+ key: "getVenueProducts",
984
+ value: function getVenueProducts() {
985
+ var _this$store$venueProd2;
986
+ return ((_this$store$venueProd2 = this.store.venueProducts) === null || _this$store$venueProd2 === void 0 || (_this$store$venueProd2 = _this$store$venueProd2.store) === null || _this$store$venueProd2 === void 0 ? void 0 : _this$store$venueProd2.list) || [];
987
+ }
988
+ }, {
989
+ key: "getAddonProductsList",
990
+ value: function getAddonProductsList() {
991
+ var _this$store$addonProd;
992
+ return ((_this$store$addonProd = this.store.addonProducts) === null || _this$store$addonProd === void 0 || (_this$store$addonProd = _this$store$addonProd.store) === null || _this$store$addonProd === void 0 ? void 0 : _this$store$addonProd.list) || [];
993
+ }
994
+
995
+ // ─── 报价单 ───
996
+ }, {
997
+ key: "loadQuotations",
998
+ value: function () {
999
+ var _loadQuotations = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(params) {
1000
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1001
+ while (1) switch (_context14.prev = _context14.next) {
1002
+ case 0:
1003
+ this.logMethodStart('loadQuotations');
1004
+ _context14.prev = 1;
1005
+ if (this.store.quotation) {
1006
+ _context14.next = 4;
1007
+ break;
1008
+ }
1009
+ throw new Error('quotation 模块未初始化');
1010
+ case 4:
1011
+ _context14.next = 6;
1012
+ return this.store.quotation.loadQuotations(params);
1013
+ case 6:
1014
+ this.logMethodSuccess('loadQuotations', {
1015
+ count: this.store.quotation.getQuotationList().length
1016
+ });
1017
+ _context14.next = 13;
1018
+ break;
1019
+ case 9:
1020
+ _context14.prev = 9;
1021
+ _context14.t0 = _context14["catch"](1);
1022
+ this.logMethodError('loadQuotations', _context14.t0);
1023
+ throw _context14.t0;
1024
+ case 13:
1025
+ case "end":
1026
+ return _context14.stop();
1027
+ }
1028
+ }, _callee14, this, [[1, 9]]);
1029
+ }));
1030
+ function loadQuotations(_x6) {
1031
+ return _loadQuotations.apply(this, arguments);
1032
+ }
1033
+ return loadQuotations;
1034
+ }() // ─── 资源可用性 ───
1035
+ }, {
1036
+ key: "fetchResourceAvailability",
1037
+ value: function () {
1038
+ var _fetchResourceAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
1039
+ var venueProducts, resourceIds, config, crossDay, effectiveEndDate, res, rawData, _iterator2, _step2, item, _i3, _rawData, _item, mappings, _iterator3, _step3, mapping;
1040
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1041
+ while (1) switch (_context15.prev = _context15.next) {
1042
+ case 0:
1043
+ this.logMethodStart('fetchResourceAvailability', params);
1044
+ _context15.prev = 1;
1045
+ venueProducts = this.getVenueProducts();
1046
+ if (venueProducts.length) {
1047
+ _context15.next = 7;
1048
+ break;
1049
+ }
1050
+ this.store.rawResourceData = [];
1051
+ this.logMethodSuccess('fetchResourceAvailability', {
1052
+ resourceCount: 0
1053
+ });
1054
+ return _context15.abrupt("return");
1055
+ case 7:
1056
+ resourceIds = extractResourceIds(venueProducts);
1057
+ if (resourceIds.length) {
1058
+ _context15.next = 12;
1059
+ break;
1060
+ }
1061
+ this.store.rawResourceData = [];
1062
+ this.logMethodSuccess('fetchResourceAvailability', {
1063
+ resourceIds: []
1064
+ });
1065
+ return _context15.abrupt("return");
1066
+ case 12:
1067
+ // 跨天营业时,endDate 扩展一天以覆盖次日凌晨时段
1068
+ config = this.store.slotConfig;
1069
+ crossDay = isBusinessHoursCrossDay(config);
1070
+ effectiveEndDate = crossDay ? dayjs(params.endDate).add(1, 'day').format('YYYY-MM-DD') : params.endDate;
1071
+ if (this.store.date) {
1072
+ _context15.next = 17;
1073
+ break;
1074
+ }
1075
+ throw new Error('date 模块未初始化');
1076
+ case 17:
1077
+ _context15.next = 19;
1078
+ return this.store.date.fetchResourceDates({
1079
+ query: {
1080
+ start_date: params.startDate,
1081
+ end_date: effectiveEndDate,
1082
+ resource_ids: resourceIds
1083
+ },
1084
+ useCache: false
1085
+ });
1086
+ case 19:
1087
+ res = _context15.sent;
1088
+ rawData = [];
1089
+ if (res !== null && res !== void 0 && res.data && Array.isArray(res.data)) {
1090
+ _iterator2 = _createForOfIteratorHelper(res.data);
1091
+ try {
1092
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
1093
+ item = _step2.value;
1094
+ rawData.push(_objectSpread({
1095
+ resourceId: item.id,
1096
+ formId: item.form_id,
1097
+ times: Array.isArray(item.times) ? item.times : []
1098
+ }, item));
1099
+ }
1100
+ } catch (err) {
1101
+ _iterator2.e(err);
1102
+ } finally {
1103
+ _iterator2.f();
1104
+ }
1105
+ }
1106
+ this.store.rawResourceData = rawData;
1107
+ _i3 = 0, _rawData = rawData;
1108
+ case 24:
1109
+ if (!(_i3 < _rawData.length)) {
1110
+ _context15.next = 34;
1111
+ break;
1112
+ }
1113
+ _item = _rawData[_i3];
1114
+ mappings = this.resourceProductMap.get(_item.resourceId);
1115
+ if (mappings) {
1116
+ _context15.next = 29;
1117
+ break;
1118
+ }
1119
+ return _context15.abrupt("continue", 31);
1120
+ case 29:
1121
+ _iterator3 = _createForOfIteratorHelper(mappings);
1122
+ try {
1123
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
1124
+ mapping = _step3.value;
1125
+ if (_item.main_field) mapping.resourceName = _item.main_field;
1126
+ if (_item.resource_form_id) mapping.formId = _item.resource_form_id;
1127
+ }
1128
+ } catch (err) {
1129
+ _iterator3.e(err);
1130
+ } finally {
1131
+ _iterator3.f();
1132
+ }
1133
+ case 31:
1134
+ _i3++;
1135
+ _context15.next = 24;
1136
+ break;
1137
+ case 34:
1138
+ this.logMethodSuccess('fetchResourceAvailability', {
1139
+ resourceCount: rawData.length,
1140
+ totalTimes: rawData.reduce(function (sum, r) {
1141
+ return sum + r.times.length;
1142
+ }, 0)
1143
+ });
1144
+ _context15.next = 42;
1145
+ break;
1146
+ case 37:
1147
+ _context15.prev = 37;
1148
+ _context15.t0 = _context15["catch"](1);
1149
+ this.store.rawResourceData = [];
1150
+ this.logMethodError('fetchResourceAvailability', _context15.t0);
1151
+ throw _context15.t0;
1152
+ case 42:
1153
+ case "end":
1154
+ return _context15.stop();
1155
+ }
1156
+ }, _callee15, this, [[1, 37]]);
1157
+ }));
1158
+ function fetchResourceAvailability(_x7) {
1159
+ return _fetchResourceAvailability.apply(this, arguments);
1160
+ }
1161
+ return fetchResourceAvailability;
1162
+ }() // ─── 日期概览 & 时间槽矩阵(纯计算,不发请求) ───
1163
+ }, {
1164
+ key: "getOperatingHoursScheduleIds",
1165
+ value: function getOperatingHoursScheduleIds() {
1166
+ var _this$store$openData, _this$store$openData$;
1167
+ var openData = this.otherParams.openData || ((_this$store$openData = this.store.openData) === null || _this$store$openData === void 0 || (_this$store$openData$ = _this$store$openData.getOpenData) === null || _this$store$openData$ === void 0 ? void 0 : _this$store$openData$.call(_this$store$openData)) || null;
1168
+ var rawIds = openData === null || openData === void 0 ? void 0 : openData['availability.operating_hours'];
1169
+ if (!Array.isArray(rawIds)) return [];
1170
+ return _toConsumableArray(new Set(rawIds.map(function (id) {
1171
+ return Number(id);
1172
+ }).filter(function (id) {
1173
+ return Number.isFinite(id) && id > 0;
1174
+ }).map(function (id) {
1175
+ return Math.floor(id);
1176
+ })));
1177
+ }
1178
+ }, {
1179
+ key: "resolveSlotConfigForDate",
1180
+ value: function resolveSlotConfigForDate(date) {
1181
+ var nextSlotConfig = _objectSpread({}, this.baseSlotConfig);
1182
+ if (!date || !this.store.schedule) return nextSlotConfig;
1183
+ var operatingHoursScheduleIds = this.getOperatingHoursScheduleIds();
1184
+ if (!operatingHoursScheduleIds.length) return nextSlotConfig;
1185
+ var scheduleList = this.store.schedule.getScheduleListByIds(operatingHoursScheduleIds);
1186
+ if (!scheduleList.length) return nextSlotConfig;
1187
+ var timeRangeMap = calcMinTimeMaxTimeBySchedules(scheduleList, undefined, date);
1188
+ var earliestStart = null;
1189
+ var latestEnd = null;
1190
+ var _iterator4 = _createForOfIteratorHelper(scheduleList),
1191
+ _step4;
1192
+ try {
1193
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
1194
+ var _timeRangeMap$schedul;
1195
+ var schedule = _step4.value;
1196
+ var dateRangeList = (timeRangeMap === null || timeRangeMap === void 0 || (_timeRangeMap$schedul = timeRangeMap[schedule.id]) === null || _timeRangeMap$schedul === void 0 ? void 0 : _timeRangeMap$schedul.dateRangeFormat) || [];
1197
+ var _iterator5 = _createForOfIteratorHelper(dateRangeList),
1198
+ _step5;
1199
+ try {
1200
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
1201
+ var range = _step5.value;
1202
+ var start = dayjs(range === null || range === void 0 ? void 0 : range.start);
1203
+ var end = dayjs(range === null || range === void 0 ? void 0 : range.end);
1204
+ if (!start.isValid() || !end.isValid()) continue;
1205
+ if (!earliestStart || start.isBefore(earliestStart)) {
1206
+ earliestStart = start;
1207
+ }
1208
+ if (!latestEnd || end.isAfter(latestEnd)) {
1209
+ latestEnd = end;
1210
+ }
1211
+ }
1212
+ } catch (err) {
1213
+ _iterator5.e(err);
1214
+ } finally {
1215
+ _iterator5.f();
1216
+ }
1217
+ }
1218
+ } catch (err) {
1219
+ _iterator4.e(err);
1220
+ } finally {
1221
+ _iterator4.f();
1222
+ }
1223
+ if (!earliestStart || !latestEnd) return nextSlotConfig;
1224
+ return _objectSpread(_objectSpread({}, nextSlotConfig), {}, {
1225
+ businessStartTime: earliestStart.format('HH:mm'),
1226
+ businessEndTime: latestEnd.format('HH:mm')
1227
+ });
1228
+ }
1229
+ }, {
1230
+ key: "syncOperatingHoursToSlotConfig",
1231
+ value: function syncOperatingHoursToSlotConfig(date) {
1232
+ var resolvedSlotConfig = this.resolveSlotConfigForDate(date);
1233
+ this.store.slotConfig = resolvedSlotConfig;
1234
+ return resolvedSlotConfig;
1235
+ }
1236
+ }, {
1237
+ key: "getDateRangeSummary",
1238
+ value: function getDateRangeSummary(params) {
1239
+ var _this6 = this;
1240
+ return buildDateRangeSummary({
1241
+ startDate: params.startDate,
1242
+ endDate: params.endDate,
1243
+ config: this.baseSlotConfig,
1244
+ rawResources: this.store.rawResourceData,
1245
+ resourceProductMap: this.resourceProductMap,
1246
+ quotationModule: this.store.quotation,
1247
+ resolveConfig: function resolveConfig(date) {
1248
+ return _this6.resolveSlotConfigForDate(date);
1249
+ }
1250
+ });
1251
+ }
1252
+ }, {
1253
+ key: "getTimeSlotGrid",
1254
+ value: function getTimeSlotGrid(date) {
1255
+ var resolvedSlotConfig = this.syncOperatingHoursToSlotConfig(date);
1256
+ var quotationPriceMap;
1257
+ if (this.store.quotation) {
1258
+ var productIds = _toConsumableArray(new Set(_toConsumableArray(this.resourceProductMap.values()).flat().map(function (m) {
1259
+ return m.productId;
1260
+ })));
1261
+ var timeLabels = generateTimeLabels(resolvedSlotConfig);
1262
+ var timePoints = timeLabels.map(function (label) {
1263
+ return "".concat(date, " ").concat(label);
1264
+ });
1265
+ quotationPriceMap = this.store.quotation.buildProductPriceMap({
1266
+ productIds: productIds,
1267
+ timePoints: timePoints
1268
+ });
1269
+ }
1270
+ return buildTimeSlotGrid({
1271
+ date: date,
1272
+ config: resolvedSlotConfig,
1273
+ rawResources: this.store.rawResourceData,
1274
+ resourceProductMap: this.resourceProductMap,
1275
+ quotationPriceMap: quotationPriceMap
1276
+ });
1277
+ }
1278
+
1279
+ // ─── 时间槽订单操作 ───
1280
+
1281
+ /**
1282
+ * 切换单个时段的选中状态(选中/取消)。
1283
+ * 内部自动处理连续时段的合并与拆分,订单是唯一真相源。
1284
+ *
1285
+ * slot.productId 指定当前操作针对的是该 resourceId 下的哪一个商品。
1286
+ * 同一资源下不同 productId 之间互相隔离,不会相互合并。
1287
+ */
1288
+ }, {
1289
+ key: "toggleSlot",
1290
+ value: function () {
1291
+ var _toggleSlot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(slot) {
1292
+ var mappings, mapping, currentSlots, existIndex, nextSlots, products;
1293
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1294
+ while (1) switch (_context16.prev = _context16.next) {
1295
+ case 0:
1296
+ this.logMethodStart('toggleSlot', {
1297
+ resourceId: slot.resourceId,
1298
+ productId: slot.productId,
1299
+ startTime: slot.startTime
1300
+ });
1301
+ _context16.prev = 1;
1302
+ mappings = this.resourceProductMap.get(slot.resourceId);
1303
+ if (!(!mappings || !mappings.length)) {
1304
+ _context16.next = 5;
1305
+ break;
1306
+ }
1307
+ throw new Error("\u672A\u627E\u5230\u8D44\u6E90 ".concat(slot.resourceId, " \u7684\u5546\u54C1\u6620\u5C04"));
1308
+ case 5:
1309
+ mapping = mappings.find(function (m) {
1310
+ return m.productId === slot.productId;
1311
+ });
1312
+ if (mapping) {
1313
+ _context16.next = 8;
1314
+ break;
1315
+ }
1316
+ throw new Error("\u8D44\u6E90 ".concat(slot.resourceId, " \u672A\u5173\u8054\u5546\u54C1 ").concat(slot.productId));
1317
+ case 8:
1318
+ if (this.store.order) {
1319
+ _context16.next = 10;
1320
+ break;
1321
+ }
1322
+ throw new Error('order 模块未初始化');
1323
+ case 10:
1324
+ currentSlots = this.getSelectedSlotsForResourceProduct(slot.resourceId, slot.productId);
1325
+ existIndex = currentSlots.findIndex(function (s) {
1326
+ return s.startTime === slot.startTime;
1327
+ });
1328
+ if (existIndex !== -1) {
1329
+ nextSlots = currentSlots.filter(function (_, i) {
1330
+ return i !== existIndex;
1331
+ });
1332
+ } else {
1333
+ nextSlots = [].concat(_toConsumableArray(currentSlots), [slot]);
1334
+ }
1335
+ _context16.next = 15;
1336
+ return this.reconcileOrderForResourceProduct(slot.resourceId, slot.productId, nextSlots);
1337
+ case 15:
1338
+ products = this.store.order.getOrderProducts();
1339
+ _context16.next = 18;
1340
+ return this.refreshItemRuleQuantityLimits();
1341
+ case 18:
1342
+ _context16.next = 20;
1343
+ return this.refreshCartValidationPassed();
1344
+ case 20:
1345
+ this.logMethodSuccess('toggleSlot', {
1346
+ action: existIndex !== -1 ? 'remove' : 'add',
1347
+ resourceId: slot.resourceId,
1348
+ productId: slot.productId,
1349
+ slotCount: nextSlots.length
1350
+ });
1351
+ return _context16.abrupt("return", products);
1352
+ case 24:
1353
+ _context16.prev = 24;
1354
+ _context16.t0 = _context16["catch"](1);
1355
+ this.logMethodError('toggleSlot', _context16.t0);
1356
+ throw _context16.t0;
1357
+ case 28:
1358
+ case "end":
1359
+ return _context16.stop();
1360
+ }
1361
+ }, _callee16, this, [[1, 24]]);
1362
+ }));
1363
+ function toggleSlot(_x8) {
1364
+ return _toggleSlot.apply(this, arguments);
1365
+ }
1366
+ return toggleSlot;
1367
+ }()
1368
+ /**
1369
+ * 获取某资源当前选中的所有独立时段(从订单中解析)。
1370
+ * 不传 productId 时返回该资源下所有商品的选中时段;传了则精确匹配。
1371
+ */
1372
+ }, {
1373
+ key: "getSelectedSlotsForResource",
1374
+ value: function getSelectedSlotsForResource(resourceId, productId) {
1375
+ var _this$store$order3;
1376
+ var tempOrder = (_this$store$order3 = this.store.order) === null || _this$store$order3 === void 0 ? void 0 : _this$store$order3.getTempOrder();
1377
+ if (!tempOrder) return [];
1378
+ var venueProducts = tempOrder.products.filter(function (p) {
1379
+ var _p$metadata, _p$metadata2;
1380
+ if (!((_p$metadata = p.metadata) !== null && _p$metadata !== void 0 && _p$metadata.venue_booking)) return false;
1381
+ if (String((_p$metadata2 = p.metadata) === null || _p$metadata2 === void 0 ? void 0 : _p$metadata2.resource_id) !== String(resourceId)) return false;
1382
+ if (productId != null && Number(p.product_id) !== Number(productId)) return false;
1383
+ return true;
1384
+ });
1385
+ var slotDuration = this.store.slotConfig.slotDurationMinutes;
1386
+ var slots = [];
1387
+ var _iterator6 = _createForOfIteratorHelper(venueProducts),
1388
+ _step6;
1389
+ try {
1390
+ var _loop = function _loop() {
1391
+ var product = _step6.value;
1392
+ slots.push.apply(slots, _toConsumableArray(expandMergedSlotToIndividual(product, slotDuration).map(function (s) {
1393
+ return _objectSpread(_objectSpread({}, s), {}, {
1394
+ productId: Number(product.product_id)
1395
+ });
1396
+ })));
1397
+ };
1398
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
1399
+ _loop();
1400
+ }
1401
+ } catch (err) {
1402
+ _iterator6.e(err);
1403
+ } finally {
1404
+ _iterator6.f();
1405
+ }
1406
+ return slots.sort(function (a, b) {
1407
+ return a.startTime.localeCompare(b.startTime);
1408
+ });
1409
+ }
1410
+
1411
+ /** getSelectedSlotsForResource 的 (resourceId, productId) 精确版,内部使用。 */
1412
+ }, {
1413
+ key: "getSelectedSlotsForResourceProduct",
1414
+ value: function getSelectedSlotsForResourceProduct(resourceId, productId) {
1415
+ return this.getSelectedSlotsForResource(resourceId, productId);
1416
+ }
1417
+
1418
+ /**
1419
+ * 判断某个时段是否已选中。
1420
+ * 不传 productId 时:只要该资源下任一商品在 startTime 被选中即返回 true;传了则精确匹配。
1421
+ */
1422
+ }, {
1423
+ key: "isSlotSelected",
1424
+ value: function isSlotSelected(resourceId, startTime, productId) {
1425
+ return this.getSelectedSlotsForResource(resourceId, productId).some(function (s) {
1426
+ return s.startTime === startTime;
1427
+ });
1428
+ }
1429
+
1430
+ /**
1431
+ * 判断指定 (resourceId, productId, startTime) 格子是否应因其它已选项而被禁用。
1432
+ * 规则:
1433
+ * 1) 同一 resourceId 下若已选了另一个 productId 的同 startTime → 禁用
1434
+ * 2) 当前 resource 是组合资源:若其任一 child resource 在 startTime 被选中 → 禁用
1435
+ * 3) 当前 resource 是某些组合资源的 child:若该组合资源在 startTime 被选中 → 禁用
1436
+ * 4) 两个组合资源的 child 集合有交集,且对方在该 startTime 被选中 → 禁用
1437
+ */
1438
+ }, {
1439
+ key: "isSlotDisabledBySelection",
1440
+ value: function isSlotDisabledBySelection(params) {
1441
+ var _this7 = this;
1442
+ var resourceId = params.resourceId,
1443
+ productId = params.productId,
1444
+ startTime = params.startTime;
1445
+ var allSelected = this.getAllSelectedSlots();
1446
+ var getSelectedAt = function getSelectedAt(resId) {
1447
+ var list = allSelected.get(resId) || [];
1448
+ return list.filter(function (s) {
1449
+ return s.startTime === startTime;
1450
+ });
1451
+ };
1452
+
1453
+ // 规则 1:同场地、不同 productId 的已选
1454
+ var sameResourceSelections = getSelectedAt(resourceId);
1455
+ if (sameResourceSelections.some(function (s) {
1456
+ return Number(s.productId) !== Number(productId);
1457
+ })) {
1458
+ return true;
1459
+ }
1460
+
1461
+ // 组合资源字段缓存
1462
+ var getCombinedChildIds = function getCombinedChildIds(resId) {
1463
+ var raw = _this7.store.rawResourceData.find(function (r) {
1464
+ return String(r.resourceId) === String(resId);
1465
+ });
1466
+ var combined = raw === null || raw === void 0 ? void 0 : raw.combined_resource;
1467
+ if (combined && combined.status === 1 && Array.isArray(combined.resource_ids)) {
1468
+ return combined.resource_ids;
1469
+ }
1470
+ return [];
1471
+ };
1472
+ var currentChildIds = getCombinedChildIds(resourceId);
1473
+ var currentIsCombined = currentChildIds.length > 0;
1474
+
1475
+ // 规则 2:当前是组合资源,任一子资源被选 → 禁用
1476
+ if (currentIsCombined) {
1477
+ var _iterator7 = _createForOfIteratorHelper(currentChildIds),
1478
+ _step7;
1479
+ try {
1480
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
1481
+ var childId = _step7.value;
1482
+ if (getSelectedAt(childId).length > 0) return true;
1483
+ }
1484
+ } catch (err) {
1485
+ _iterator7.e(err);
1486
+ } finally {
1487
+ _iterator7.f();
1488
+ }
1489
+ }
1490
+
1491
+ // 规则 3 & 4:扫描所有已选的 (resId),若是组合资源,检查其 children 是否包含当前 resourceId 或与当前 child 集合有交集
1492
+ var _iterator8 = _createForOfIteratorHelper(allSelected),
1493
+ _step8;
1494
+ try {
1495
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
1496
+ var _step8$value = _slicedToArray(_step8.value, 2),
1497
+ selectedResId = _step8$value[0],
1498
+ slots = _step8$value[1];
1499
+ if (!slots.some(function (s) {
1500
+ return s.startTime === startTime;
1501
+ })) continue;
1502
+ if (String(selectedResId) === String(resourceId)) continue;
1503
+ var selectedChildIds = getCombinedChildIds(selectedResId);
1504
+ if (selectedChildIds.length === 0) continue;
1505
+
1506
+ // 对方是组合资源,其 children 包含当前 resourceId(规则 3)
1507
+ if (selectedChildIds.some(function (id) {
1508
+ return String(id) === String(resourceId);
1509
+ })) {
1510
+ return true;
1511
+ }
1512
+
1513
+ // 双方都是组合资源,child 集合有交集(规则 4)
1514
+ if (currentIsCombined) {
1515
+ var intersect = selectedChildIds.some(function (id) {
1516
+ return currentChildIds.some(function (cid) {
1517
+ return String(cid) === String(id);
1518
+ });
1519
+ });
1520
+ if (intersect) return true;
1521
+ }
1522
+ }
1523
+ } catch (err) {
1524
+ _iterator8.e(err);
1525
+ } finally {
1526
+ _iterator8.f();
1527
+ }
1528
+ return false;
1529
+ }
1530
+
1531
+ /**
1532
+ * 获取所有已选时段(按资源分组)。每个 slot 上带 productId,便于 UI 做 per-product 判定。
1533
+ */
1534
+ }, {
1535
+ key: "getAllSelectedSlots",
1536
+ value: function getAllSelectedSlots() {
1537
+ var _this$store$order4;
1538
+ var result = new Map();
1539
+ var tempOrder = (_this$store$order4 = this.store.order) === null || _this$store$order4 === void 0 ? void 0 : _this$store$order4.getTempOrder();
1540
+ if (!tempOrder) return result;
1541
+ var venueProducts = tempOrder.products.filter(function (p) {
1542
+ var _p$metadata3;
1543
+ return (_p$metadata3 = p.metadata) === null || _p$metadata3 === void 0 ? void 0 : _p$metadata3.venue_booking;
1544
+ });
1545
+ var slotDuration = this.store.slotConfig.slotDurationMinutes;
1546
+ var _iterator9 = _createForOfIteratorHelper(venueProducts),
1547
+ _step9;
1548
+ try {
1549
+ var _loop2 = function _loop2() {
1550
+ var _product$metadata;
1551
+ var product = _step9.value;
1552
+ var resourceId = (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.resource_id;
1553
+ if (resourceId == null) return 1; // continue
1554
+ var productId = Number(product.product_id);
1555
+ var existing = result.get(resourceId) || [];
1556
+ existing.push.apply(existing, _toConsumableArray(expandMergedSlotToIndividual(product, slotDuration).map(function (s) {
1557
+ return _objectSpread(_objectSpread({}, s), {}, {
1558
+ productId: productId
1559
+ });
1560
+ })));
1561
+ result.set(resourceId, existing);
1562
+ };
1563
+ for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
1564
+ if (_loop2()) continue;
1565
+ }
1566
+ } catch (err) {
1567
+ _iterator9.e(err);
1568
+ } finally {
1569
+ _iterator9.f();
1570
+ }
1571
+ var _iterator10 = _createForOfIteratorHelper(result),
1572
+ _step10;
1573
+ try {
1574
+ for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
1575
+ var _step10$value = _slicedToArray(_step10.value, 2),
1576
+ key = _step10$value[0],
1577
+ slots = _step10$value[1];
1578
+ result.set(key, slots.sort(function (a, b) {
1579
+ return a.startTime.localeCompare(b.startTime);
1580
+ }));
1581
+ }
1582
+ } catch (err) {
1583
+ _iterator10.e(err);
1584
+ } finally {
1585
+ _iterator10.f();
1586
+ }
1587
+ return result;
1588
+ }
1589
+
1590
+ /**
1591
+ * 对指定 (resourceId, productId) 的订单商品进行 reconcile:
1592
+ * 清除旧商品 → 合并连续时段 → 重新写入。
1593
+ * 同一场地下不同商品互不干扰,各自单独 reconcile。
1594
+ */
1595
+ }, {
1596
+ key: "reconcileOrderForResourceProduct",
1597
+ value: (function () {
1598
+ var _reconcileOrderForResourceProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(resourceId, productId, slots) {
1599
+ var mappings, mapping, tempOrder, matchesCurrent, merged, rawResource, childRawResources, venueProduct, i, _rawResource$form_id, _venueProduct$is_char, group, identityKey, bookingUuid, startMoment, endMoment, duration, customDepositData, resourceEntry, booking;
1600
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1601
+ while (1) switch (_context17.prev = _context17.next) {
1602
+ case 0:
1603
+ mappings = this.resourceProductMap.get(resourceId);
1604
+ if (!(!mappings || !mappings.length || !this.store.order)) {
1605
+ _context17.next = 3;
1606
+ break;
1607
+ }
1608
+ return _context17.abrupt("return");
1609
+ case 3:
1610
+ mapping = mappings.find(function (m) {
1611
+ return m.productId === productId;
1612
+ });
1613
+ if (mapping) {
1614
+ _context17.next = 6;
1615
+ break;
1616
+ }
1617
+ return _context17.abrupt("return");
1618
+ case 6:
1619
+ tempOrder = this.store.order.ensureTempOrder();
1620
+ matchesCurrent = function matchesCurrent(meta, pid) {
1621
+ return !!(meta !== null && meta !== void 0 && meta.venue_booking) && String(meta === null || meta === void 0 ? void 0 : meta.resource_id) === String(resourceId) && Number(pid) === Number(productId);
1622
+ };
1623
+ tempOrder.products = tempOrder.products.filter(function (p) {
1624
+ return !matchesCurrent(p.metadata, p.product_id);
1625
+ });
1626
+ tempOrder.bookings = (tempOrder.bookings || []).filter(function (b) {
1627
+ var _b$metadata, _b$metadata2, _b$metadata$product_i, _b$metadata3, _b$product;
1628
+ if (!((_b$metadata = b.metadata) !== null && _b$metadata !== void 0 && _b$metadata.venue_booking)) return true;
1629
+ if (String((_b$metadata2 = b.metadata) === null || _b$metadata2 === void 0 ? void 0 : _b$metadata2.resource_id) !== String(resourceId)) return true;
1630
+ var bookingProductId = (_b$metadata$product_i = (_b$metadata3 = b.metadata) === null || _b$metadata3 === void 0 ? void 0 : _b$metadata3.product_id) !== null && _b$metadata$product_i !== void 0 ? _b$metadata$product_i : b === null || b === void 0 || (_b$product = b.product) === null || _b$product === void 0 ? void 0 : _b$product.product_id;
1631
+ if (bookingProductId == null) return false;
1632
+ return Number(bookingProductId) !== Number(productId);
1633
+ });
1634
+ if (slots.length) {
1635
+ _context17.next = 16;
1636
+ break;
1637
+ }
1638
+ this.store.order.applyDiscount();
1639
+ _context17.next = 14;
1640
+ return this.store.order.recalculateSummary({
1641
+ createIfMissing: true
1642
+ });
1643
+ case 14:
1644
+ this.store.order.persistTempOrder();
1645
+ return _context17.abrupt("return");
1646
+ case 16:
1647
+ merged = mergeConsecutiveSlots(slots);
1648
+ rawResource = this.store.rawResourceData.find(function (r) {
1649
+ return String(r.resourceId) === String(resourceId);
1650
+ });
1651
+ childRawResources = this.getCombinedChildRawResources(rawResource);
1652
+ venueProduct = this.getVenueProducts().find(function (p) {
1653
+ return p.id === mapping.productId;
1654
+ });
1655
+ tempOrder.bookings = tempOrder.bookings || [];
1656
+ for (i = 0; i < merged.length; i++) {
1657
+ group = merged[i];
1658
+ identityKey = buildVenueIdentityKey(resourceId, i);
1659
+ bookingUuid = createUuidV4();
1660
+ startMoment = dayjs(group.startTime, 'YYYY-MM-DD HH:mm');
1661
+ endMoment = dayjs(group.endTime, 'YYYY-MM-DD HH:mm');
1662
+ duration = endMoment.diff(startMoment, 'minute');
1663
+ customDepositData = cloneCustomDepositData(venueProduct === null || venueProduct === void 0 ? void 0 : venueProduct.custom_deposit_data);
1664
+ resourceEntry = {
1665
+ relation_type: 'form',
1666
+ like_status: 'common',
1667
+ id: resourceId,
1668
+ main_field: mapping.resourceName,
1669
+ form_id: (_rawResource$form_id = rawResource === null || rawResource === void 0 ? void 0 : rawResource.form_id) !== null && _rawResource$form_id !== void 0 ? _rawResource$form_id : mapping.formId,
1670
+ relation_id: resourceId,
1671
+ capacity: 1,
1672
+ metadata: buildVenueResourceMetadata({
1673
+ mapping: mapping,
1674
+ rawResource: rawResource
1675
+ })
1676
+ };
1677
+ if (childRawResources && childRawResources.length) {
1678
+ resourceEntry.children = childRawResources.map(function (child) {
1679
+ var _child$form_id, _child$capacity;
1680
+ return {
1681
+ relation_type: 'form',
1682
+ like_status: 'common',
1683
+ id: child.resourceId,
1684
+ main_field: child.main_field || '',
1685
+ form_id: (_child$form_id = child.form_id) !== null && _child$form_id !== void 0 ? _child$form_id : child.formId,
1686
+ relation_id: child.resourceId,
1687
+ capacity: (_child$capacity = child.capacity) !== null && _child$capacity !== void 0 ? _child$capacity : 1,
1688
+ metadata: {}
1689
+ };
1690
+ });
1691
+ }
1692
+ tempOrder.products.push(normalizeOrderProduct({
1693
+ product_id: mapping.productId,
1694
+ product_variant_id: 0,
1695
+ identity_key: identityKey,
1696
+ num: 1,
1697
+ selling_price: group.totalPrice,
1698
+ original_price: group.totalPrice,
1699
+ is_charge_tax: (_venueProduct$is_char = venueProduct === null || venueProduct === void 0 ? void 0 : venueProduct.is_charge_tax) !== null && _venueProduct$is_char !== void 0 ? _venueProduct$is_char : 0,
1700
+ metadata: {
1701
+ venue_booking: true,
1702
+ resource_id: resourceId,
1703
+ resource_form_id: mapping.formId,
1704
+ resource_name: mapping.resourceName,
1705
+ start_time: group.startTime,
1706
+ end_time: group.endTime,
1707
+ slot_count: group.slotCount,
1708
+ booking_uid: bookingUuid,
1709
+ price_breakdown: buildPriceBreakdown({
1710
+ group: group,
1711
+ productId: mapping.productId,
1712
+ quotation: this.store.quotation
1713
+ })
1714
+ },
1715
+ _origin: {
1716
+ name: mapping.productTitle,
1717
+ cover: (venueProduct === null || venueProduct === void 0 ? void 0 : venueProduct.cover) || '',
1718
+ custom_deposit_data: customDepositData,
1719
+ id: 0,
1720
+ number: 1,
1721
+ registration_type: 'all',
1722
+ relation_products: [],
1723
+ is_all: false,
1724
+ product: {
1725
+ product_id: mapping.productId,
1726
+ product_variant_id: 0,
1727
+ num: 1,
1728
+ product_bundle: [],
1729
+ product_option_item: [],
1730
+ discount_list: [],
1731
+ custom_deposit_data: customDepositData,
1732
+ metadata: {}
1733
+ },
1734
+ sub_type: 'minutes',
1735
+ duration: duration,
1736
+ like_status: 'common',
1737
+ resources: [resourceEntry],
1738
+ schedule_id: 0,
1739
+ select_date: startMoment.format('YYYY-MM-DD'),
1740
+ start_date: startMoment.format('YYYY-MM-DD'),
1741
+ start_time: startMoment.format('HH:mm'),
1742
+ end_date: endMoment.format('YYYY-MM-DD'),
1743
+ end_time: endMoment.format('HH:mm'),
1744
+ metadata: {
1745
+ venue_booking: true,
1746
+ slot_count: group.slotCount
1747
+ },
1748
+ holder: null
1749
+ }
1750
+ }));
1751
+ booking = buildVenueBookingEntry({
1752
+ group: group,
1753
+ resourceId: resourceId,
1754
+ mapping: mapping,
1755
+ rawResource: rawResource,
1756
+ bookingUuid: bookingUuid,
1757
+ productUid: identityKey,
1758
+ childResources: childRawResources
1759
+ });
1760
+ tempOrder.bookings.push(booking);
1761
+ }
1762
+ this.store.order.applyDiscount();
1763
+ _context17.next = 25;
1764
+ return this.store.order.recalculateSummary({
1765
+ createIfMissing: true
1766
+ });
1767
+ case 25:
1768
+ this.store.order.persistTempOrder();
1769
+ case 26:
1770
+ case "end":
1771
+ return _context17.stop();
1772
+ }
1773
+ }, _callee17, this);
1774
+ }));
1775
+ function reconcileOrderForResourceProduct(_x9, _x10, _x11) {
1776
+ return _reconcileOrderForResourceProduct.apply(this, arguments);
1777
+ }
1778
+ return reconcileOrderForResourceProduct;
1779
+ }() /** 给定一个父 rawResource,返回其 combined_resource.resource_ids 对应的子 rawResource 列表。 */)
1780
+ }, {
1781
+ key: "getCombinedChildRawResources",
1782
+ value: function getCombinedChildRawResources(rawResource) {
1783
+ var _this8 = this;
1784
+ if (!rawResource) return undefined;
1785
+ var combined = rawResource.combined_resource;
1786
+ if (!combined || combined.status !== 1 || !Array.isArray(combined.resource_ids) || !combined.resource_ids.length) {
1787
+ return undefined;
1788
+ }
1789
+ var children = [];
1790
+ var _iterator11 = _createForOfIteratorHelper(combined.resource_ids),
1791
+ _step11;
1792
+ try {
1793
+ var _loop3 = function _loop3() {
1794
+ var id = _step11.value;
1795
+ var child = _this8.store.rawResourceData.find(function (r) {
1796
+ return String(r.resourceId) === String(id);
1797
+ });
1798
+ if (child) children.push(child);
1799
+ };
1800
+ for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
1801
+ _loop3();
1802
+ }
1803
+ } catch (err) {
1804
+ _iterator11.e(err);
1805
+ } finally {
1806
+ _iterator11.f();
1807
+ }
1808
+ return children.length ? children : undefined;
1809
+ }
1810
+
1811
+ // ─── 配置 ───
1812
+ }, {
1813
+ key: "setSlotConfig",
1814
+ value: function setSlotConfig(config) {
1815
+ this.baseSlotConfig = _objectSpread(_objectSpread({}, this.baseSlotConfig), config);
1816
+ this.store.slotConfig = _objectSpread({}, this.baseSlotConfig);
1817
+ }
1818
+ }, {
1819
+ key: "getSlotConfig",
1820
+ value: function getSlotConfig() {
1821
+ return _objectSpread({}, this.store.slotConfig);
1822
+ }
1823
+
1824
+ // ─── 日程 ───
1825
+ }, {
1826
+ key: "loadSchedules",
1827
+ value: function () {
1828
+ var _loadSchedules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
1829
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1830
+ while (1) switch (_context18.prev = _context18.next) {
1831
+ case 0:
1832
+ this.logMethodStart('loadSchedules');
1833
+ _context18.prev = 1;
1834
+ if (this.store.schedule) {
1835
+ _context18.next = 4;
1836
+ break;
1837
+ }
1838
+ throw new Error('schedule 模块未初始化');
1839
+ case 4:
1840
+ _context18.next = 6;
1841
+ return this.store.schedule.loadAllSchedule();
1842
+ case 6:
1843
+ this.injectScheduleResolverToQuotation();
1844
+ this.logMethodSuccess('loadSchedules');
1845
+ _context18.next = 14;
1846
+ break;
1847
+ case 10:
1848
+ _context18.prev = 10;
1849
+ _context18.t0 = _context18["catch"](1);
1850
+ this.logMethodError('loadSchedules', _context18.t0);
1851
+ throw _context18.t0;
1852
+ case 14:
1853
+ case "end":
1854
+ return _context18.stop();
1855
+ }
1856
+ }, _callee18, this, [[1, 10]]);
1857
+ }));
1858
+ function loadSchedules() {
1859
+ return _loadSchedules.apply(this, arguments);
1860
+ }
1861
+ return loadSchedules;
1862
+ }()
1863
+ }, {
1864
+ key: "injectScheduleResolverToQuotation",
1865
+ value: function injectScheduleResolverToQuotation() {
1866
+ var _this9 = this;
1867
+ if (this.store.quotation && this.store.schedule) {
1868
+ this.store.quotation.setScheduleResolver(function (id) {
1869
+ return _this9.store.schedule.getScheduleListByIds([id])[0];
1870
+ });
1871
+ }
1872
+ }
1873
+ }, {
1874
+ key: "getScheduleListByIds",
1875
+ value: function getScheduleListByIds(ids) {
1876
+ if (!this.store.schedule) return [];
1877
+ return this.store.schedule.getScheduleListByIds(ids);
1878
+ }
1879
+
1880
+ // ─── 临时订单操作(保留原有能力) ───
1881
+ }, {
1882
+ key: "getTempOrder",
1883
+ value: function getTempOrder() {
1884
+ var _this$store$order5;
1885
+ var result = ((_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 ? void 0 : _this$store$order5.getTempOrder()) || null;
1886
+ return result;
1887
+ }
1888
+ }, {
1889
+ key: "updateTempOrderNote",
1890
+ value: function updateTempOrderNote(note) {
1891
+ if (!this.store.order) throw new Error('order 模块未初始化');
1892
+ return this.store.order.updateTempOrderNote(note);
1893
+ }
1894
+ }, {
1895
+ key: "updateTempOrderContactsInfo",
1896
+ value: function updateTempOrderContactsInfo(contactsInfo) {
1897
+ if (!this.store.order) throw new Error('order 模块未初始化');
1898
+ return this.store.order.updateTempOrderContactsInfo(contactsInfo);
1899
+ }
1900
+ }, {
1901
+ key: "ensureTempOrder",
1902
+ value: function ensureTempOrder() {
1903
+ if (!this.store.order) throw new Error('order 模块未初始化');
1904
+ return this.store.order.ensureTempOrder();
1905
+ }
1906
+ }, {
1907
+ key: "onCustomerLogin",
1908
+ value: function () {
1909
+ var _onCustomerLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
1910
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1911
+ while (1) switch (_context19.prev = _context19.next) {
1912
+ case 0:
1913
+ this.logMethodStart('onCustomerLogin', {
1914
+ customerId: params.customerId
1915
+ });
1916
+ _context19.prev = 1;
1917
+ _context19.next = 4;
1918
+ return this.refreshOrderMarketingAfterLogin({
1919
+ customerId: params.customerId
1920
+ });
1921
+ case 4:
1922
+ this.logMethodSuccess('onCustomerLogin', {
1923
+ customerId: params.customerId
1924
+ });
1925
+ _context19.next = 11;
1926
+ break;
1927
+ case 7:
1928
+ _context19.prev = 7;
1929
+ _context19.t0 = _context19["catch"](1);
1930
+ this.logMethodError('onCustomerLogin', _context19.t0);
1931
+ throw _context19.t0;
1932
+ case 11:
1933
+ case "end":
1934
+ return _context19.stop();
1935
+ }
1936
+ }, _callee19, this, [[1, 7]]);
1937
+ }));
1938
+ function onCustomerLogin(_x12) {
1939
+ return _onCustomerLogin.apply(this, arguments);
1940
+ }
1941
+ return onCustomerLogin;
1942
+ }()
1943
+ }, {
1944
+ key: "recalculateOrderPricesFromQuotation",
1945
+ value: function recalculateOrderPricesFromQuotation() {
1946
+ var _tempOrder$products,
1947
+ _this10 = this;
1948
+ if (!this.store.order || !this.store.quotation) return;
1949
+ var tempOrder = this.store.order.getTempOrder();
1950
+ if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$products = tempOrder.products) !== null && _tempOrder$products !== void 0 && _tempOrder$products.length)) return;
1951
+ var now = dayjs().format('YYYY-MM-DD HH:mm:ss');
1952
+ var _iterator12 = _createForOfIteratorHelper(tempOrder.products),
1953
+ _step12;
1954
+ try {
1955
+ var _loop4 = function _loop4() {
1956
+ var _product$metadata2;
1957
+ var product = _step12.value;
1958
+ if ((_product$metadata2 = product.metadata) !== null && _product$metadata2 !== void 0 && _product$metadata2.venue_booking) {
1959
+ var mappings = _this10.resourceProductMap.get(product.metadata.resource_id);
1960
+ if (!mappings || !mappings.length) return 0; // continue
1961
+ var mapping = mappings.find(function (m) {
1962
+ return Number(m.productId) === Number(product.product_id);
1963
+ }) || mappings[0];
1964
+ if (!mapping) return 0; // continue
1965
+ var slots = expandMergedSlotToIndividual(product, _this10.store.slotConfig.slotDurationMinutes);
1966
+ var updatedSlots = slots.map(function (slot) {
1967
+ var _getPriceForProduct;
1968
+ return _objectSpread(_objectSpread({}, slot), {}, {
1969
+ productId: mapping.productId,
1970
+ price: (_getPriceForProduct = _this10.store.quotation.getPriceForProduct({
1971
+ productId: mapping.productId,
1972
+ datetime: slot.startTime
1973
+ })) !== null && _getPriceForProduct !== void 0 ? _getPriceForProduct : mapping.price
1974
+ });
1975
+ });
1976
+ var merged = mergeConsecutiveSlots(updatedSlots);
1977
+ if (merged.length === 1) {
1978
+ product.selling_price = merged[0].totalPrice;
1979
+ product.original_price = merged[0].totalPrice;
1980
+ product.metadata.price_breakdown = buildPriceBreakdown({
1981
+ group: merged[0],
1982
+ productId: mapping.productId,
1983
+ quotation: _this10.store.quotation
1984
+ });
1985
+ }
1986
+ } else if (product.product_id != null) {
1987
+ var _product$product_vari;
1988
+ var quotationPrice = _this10.store.quotation.getPriceForProduct({
1989
+ productId: product.product_id,
1990
+ variantId: (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : undefined,
1991
+ datetime: now
1992
+ });
1993
+ if (quotationPrice !== null) {
1994
+ product.selling_price = quotationPrice;
1995
+ product.original_price = quotationPrice;
1996
+ }
1997
+ }
1998
+ },
1999
+ _ret;
2000
+ for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
2001
+ _ret = _loop4();
2002
+ if (_ret === 0) continue;
2003
+ }
2004
+ } catch (err) {
2005
+ _iterator12.e(err);
2006
+ } finally {
2007
+ _iterator12.f();
2008
+ }
2009
+ }
2010
+ }, {
2011
+ key: "scanCode",
2012
+ value: function () {
2013
+ var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(code, customerId) {
2014
+ var result;
2015
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
2016
+ while (1) switch (_context20.prev = _context20.next) {
2017
+ case 0:
2018
+ this.logMethodStart('scanCode', {
2019
+ code: code
2020
+ });
2021
+ _context20.prev = 1;
2022
+ if (this.store.order) {
2023
+ _context20.next = 4;
2024
+ break;
2025
+ }
2026
+ throw new Error('order 模块未初始化');
2027
+ case 4:
2028
+ _context20.next = 6;
2029
+ return this.store.order.scanCode(code, customerId);
2030
+ case 6:
2031
+ result = _context20.sent;
2032
+ if (!result.isAvailable) {
2033
+ _context20.next = 11;
2034
+ break;
2035
+ }
2036
+ _context20.next = 10;
2037
+ return this.store.order.recalculateSummary({
2038
+ createIfMissing: true
2039
+ });
2040
+ case 10:
2041
+ this.store.order.persistTempOrder();
2042
+ case 11:
2043
+ this.logMethodSuccess('scanCode', {
2044
+ isAvailable: result.isAvailable
2045
+ });
2046
+ return _context20.abrupt("return", result);
2047
+ case 15:
2048
+ _context20.prev = 15;
2049
+ _context20.t0 = _context20["catch"](1);
2050
+ this.logMethodError('scanCode', _context20.t0);
2051
+ throw _context20.t0;
2052
+ case 19:
2053
+ case "end":
2054
+ return _context20.stop();
2055
+ }
2056
+ }, _callee20, this, [[1, 15]]);
2057
+ }));
2058
+ function scanCode(_x13, _x14) {
2059
+ return _scanCode.apply(this, arguments);
2060
+ }
2061
+ return scanCode;
2062
+ }() /** 获取当前折扣列表(包装 order.getDiscountList) */
2063
+ }, {
2064
+ key: "getDiscountList",
2065
+ value: function getDiscountList() {
2066
+ if (!this.store.order) return [];
2067
+ return this.store.order.getDiscountList();
2068
+ }
2069
+
2070
+ /** 勾选/取消勾选某张折扣券,重新计算折扣并持久化 */
2071
+ }, {
2072
+ key: "setDiscountSelected",
2073
+ value: (function () {
2074
+ var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
2075
+ var _tempOrder$holder, _this$store$order$get, _this$store$order$get2, list, beforeTarget, updated, updatedTarget, tempOrder, orderStore, discountModule, rulesModule, holders, nextDiscountList, _tempOrder$holder2, result, beforeSelectedIds, _iterator13, _step13, d, selectedResourceIds, _iterator14, _step14, _product$_origin, _product$metadata$sou, _product$metadata3, _product$metadata4, _product$original_pri, product, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice, afterApplyTarget, finalSummary, finalProduct, finalTarget;
2076
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
2077
+ while (1) switch (_context21.prev = _context21.next) {
2078
+ case 0:
2079
+ this.logMethodStart('setDiscountSelected', params);
2080
+ _context21.prev = 1;
2081
+ if (this.store.order) {
2082
+ _context21.next = 4;
2083
+ break;
2084
+ }
2085
+ throw new Error('order 模块未初始化');
2086
+ case 4:
2087
+ list = this.store.order.getDiscountList();
2088
+ beforeTarget = list.find(function (d) {
2089
+ return d.id === params.discountId;
2090
+ }) || null;
2091
+ updated = list.map(function (d) {
2092
+ return d.id === params.discountId ? _objectSpread(_objectSpread({}, d), {}, {
2093
+ isSelected: params.isSelected,
2094
+ isManualSelect: !params.isSelected
2095
+ }) : d;
2096
+ });
2097
+ updatedTarget = updated.find(function (d) {
2098
+ return d.id === params.discountId;
2099
+ }) || null;
2100
+ tempOrder = this.store.order.ensureTempOrder();
2101
+ orderStore = this.store.order.store || {};
2102
+ discountModule = orderStore.discount;
2103
+ rulesModule = orderStore.rules;
2104
+ holders = (_tempOrder$holder = tempOrder.holder) !== null && _tempOrder$holder !== void 0 && _tempOrder$holder.form_record_id ? [{
2105
+ form_record_id: tempOrder.holder.form_record_id
2106
+ }] : [];
2107
+ nextDiscountList = updated;
2108
+ _context21.next = 16;
2109
+ return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(updated);
2110
+ case 16:
2111
+ if (rulesModule) {
2112
+ result = rulesModule.calcDiscount({
2113
+ productList: tempOrder.products,
2114
+ discountList: updated,
2115
+ holders: holders,
2116
+ isFormSubject: !!((_tempOrder$holder2 = tempOrder.holder) !== null && _tempOrder$holder2 !== void 0 && _tempOrder$holder2.type) && tempOrder.holder.type === 'form'
2117
+ }, {
2118
+ discountId: params.discountId,
2119
+ isSelected: params.isSelected
2120
+ }) || {
2121
+ productList: tempOrder.products,
2122
+ discountList: updated
2123
+ };
2124
+ if (result !== null && result !== void 0 && result.productList) {
2125
+ tempOrder.products = result.productList;
2126
+ }
2127
+ if (result !== null && result !== void 0 && result.discountList) {
2128
+ nextDiscountList = result.discountList;
2129
+ if (!params.isSelected) {
2130
+ beforeSelectedIds = new Set(updated.filter(function (d) {
2131
+ return d.isSelected;
2132
+ }).map(function (d) {
2133
+ return d.id;
2134
+ }));
2135
+ _iterator13 = _createForOfIteratorHelper(nextDiscountList);
2136
+ try {
2137
+ for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
2138
+ d = _step13.value;
2139
+ if (d.isSelected && !beforeSelectedIds.has(d.id)) {
2140
+ d.isSelected = false;
2141
+ }
2142
+ }
2143
+ } catch (err) {
2144
+ _iterator13.e(err);
2145
+ } finally {
2146
+ _iterator13.f();
2147
+ }
2148
+ }
2149
+ }
2150
+ }
2151
+ selectedResourceIds = new Set(nextDiscountList.filter(function (d) {
2152
+ return d.isSelected;
2153
+ }).map(function (d) {
2154
+ return d.id;
2155
+ })); // 无条件归一化:不论 Rules 是否清空 discount_list、长度是否变化,
2156
+ // 都以 original_price - Σ (当前选中 discount_list.amount) 重算 selling_price。
2157
+ // 目的:避免 unselect 后 selling_price 残留、reselect 时把残留价带进下一轮 Rules 造成双折扣。
2158
+ // 手动改价商品(_origin.isManualDiscount=true)不参与券流程归一化,保留手工价。
2159
+ _iterator14 = _createForOfIteratorHelper(tempOrder.products);
2160
+ _context21.prev = 19;
2161
+ _iterator14.s();
2162
+ case 21:
2163
+ if ((_step14 = _iterator14.n()).done) {
2164
+ _context21.next = 35;
2165
+ break;
2166
+ }
2167
+ product = _step14.value;
2168
+ if (!((_product$_origin = product._origin) !== null && _product$_origin !== void 0 && _product$_origin.isManualDiscount)) {
2169
+ _context21.next = 25;
2170
+ break;
2171
+ }
2172
+ return _context21.abrupt("continue", 33);
2173
+ case 25:
2174
+ // 1. 把 product.discount_list 和当前选中的 discount 对齐(剔除已取消的券)
2175
+ product.discount_list = (product.discount_list || []).filter(function (pd) {
2176
+ var _pd$discount$resource, _pd$discount;
2177
+ var rid = (_pd$discount$resource = (_pd$discount = pd.discount) === null || _pd$discount === void 0 ? void 0 : _pd$discount.resource_id) !== null && _pd$discount$resource !== void 0 ? _pd$discount$resource : pd.id;
2178
+ return rid != null && selectedResourceIds.has(rid);
2179
+ });
2180
+
2181
+ // 2. 以 source_product_price 为券作用基准:券作用于 source(不含 option),
2182
+ // 再把 option 加回得到含 option 的 main_product_selling_price,最后合成 composite。
2183
+ totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
2184
+ return sum + (pd.amount || 0);
2185
+ }, 0);
2186
+ optionSum = sumOptionUnitPrice(product.product_option_item);
2187
+ sourcePrice = (_product$metadata$sou = (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.source_product_price) !== null && _product$metadata$sou !== void 0 ? _product$metadata$sou : ((_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.main_product_original_price) != null ? new Decimal(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : (_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : '0';
2188
+ newSourceSellingPrice = new Decimal(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
2189
+ newMainSellingPrice = new Decimal(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
2190
+ if (product.metadata) {
2191
+ product.metadata.main_product_selling_price = newMainSellingPrice;
2192
+ product.metadata.price_schema_version = 2;
2193
+ }
2194
+ product.selling_price = composeLinePrice({
2195
+ mainPrice: newMainSellingPrice,
2196
+ bundle: product.product_bundle
2197
+ });
2198
+ case 33:
2199
+ _context21.next = 21;
2200
+ break;
2201
+ case 35:
2202
+ _context21.next = 40;
2203
+ break;
2204
+ case 37:
2205
+ _context21.prev = 37;
2206
+ _context21.t0 = _context21["catch"](19);
2207
+ _iterator14.e(_context21.t0);
2208
+ case 40:
2209
+ _context21.prev = 40;
2210
+ _iterator14.f();
2211
+ return _context21.finish(40);
2212
+ case 43:
2213
+ OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
2214
+ _context21.next = 46;
2215
+ return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
2216
+ case 46:
2217
+ tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
2218
+ return d.isSelected;
2219
+ });
2220
+ afterApplyTarget = this.store.order.getDiscountList().find(function (d) {
2221
+ return d.id === params.discountId;
2222
+ }) || null;
2223
+ _context21.next = 50;
2224
+ return this.store.order.recalculateSummary({
2225
+ createIfMissing: true
2226
+ });
2227
+ case 50:
2228
+ this.store.order.persistTempOrder();
2229
+ finalSummary = ((_this$store$order$get = this.store.order.getTempOrder()) === null || _this$store$order$get === void 0 ? void 0 : _this$store$order$get.summary) || null;
2230
+ finalProduct = ((_this$store$order$get2 = this.store.order.getTempOrder()) === null || _this$store$order$get2 === void 0 || (_this$store$order$get2 = _this$store$order$get2.products) === null || _this$store$order$get2 === void 0 ? void 0 : _this$store$order$get2[0]) || null;
2231
+ this.logMethodSuccess('setDiscountSelected', params);
2232
+ finalTarget = this.store.order.getDiscountList().find(function (d) {
2233
+ return d.id === params.discountId;
2234
+ }) || null;
2235
+ return _context21.abrupt("return", this.store.order.getDiscountList());
2236
+ case 58:
2237
+ _context21.prev = 58;
2238
+ _context21.t1 = _context21["catch"](1);
2239
+ this.logMethodError('setDiscountSelected', _context21.t1);
2240
+ throw _context21.t1;
2241
+ case 62:
2242
+ case "end":
2243
+ return _context21.stop();
2244
+ }
2245
+ }, _callee21, this, [[1, 58], [19, 37, 40, 43]]);
2246
+ }));
2247
+ function setDiscountSelected(_x15) {
2248
+ return _setDiscountSelected.apply(this, arguments);
2249
+ }
2250
+ return setDiscountSelected;
2251
+ }())
2252
+ }, {
2253
+ key: "addNewOrder",
2254
+ value: function () {
2255
+ var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
2256
+ var tempOrder;
2257
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
2258
+ while (1) switch (_context22.prev = _context22.next) {
2259
+ case 0:
2260
+ this.logMethodStart('addNewOrder');
2261
+ _context22.prev = 1;
2262
+ if (this.store.order) {
2263
+ _context22.next = 4;
2264
+ break;
2265
+ }
2266
+ throw new Error('order 模块未初始化');
2267
+ case 4:
2268
+ _context22.next = 6;
2269
+ return this.store.order.addNewOrder();
2270
+ case 6:
2271
+ tempOrder = _context22.sent;
2272
+ this.logMethodSuccess('addNewOrder', {
2273
+ productCount: tempOrder.products.length
2274
+ });
2275
+ return _context22.abrupt("return", tempOrder);
2276
+ case 11:
2277
+ _context22.prev = 11;
2278
+ _context22.t0 = _context22["catch"](1);
2279
+ this.logMethodError('addNewOrder', _context22.t0);
2280
+ throw _context22.t0;
2281
+ case 15:
2282
+ case "end":
2283
+ return _context22.stop();
2284
+ }
2285
+ }, _callee22, this, [[1, 11]]);
2286
+ }));
2287
+ function addNewOrder() {
2288
+ return _addNewOrder.apply(this, arguments);
2289
+ }
2290
+ return addNewOrder;
2291
+ }()
2292
+ }, {
2293
+ key: "getOrderProducts",
2294
+ value: function getOrderProducts() {
2295
+ if (!this.store.order) throw new Error('order 模块未初始化');
2296
+ return this.store.order.getOrderProducts();
2297
+ }
2298
+ }, {
2299
+ key: "getSummary",
2300
+ value: function () {
2301
+ var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
2302
+ var summary;
2303
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
2304
+ while (1) switch (_context23.prev = _context23.next) {
2305
+ case 0:
2306
+ this.logMethodStart('getSummary');
2307
+ _context23.prev = 1;
2308
+ if (this.store.order) {
2309
+ _context23.next = 4;
2310
+ break;
2311
+ }
2312
+ throw new Error('order 模块未初始化');
2313
+ case 4:
2314
+ _context23.next = 6;
2315
+ return this.store.order.getScanOrderSummary();
2316
+ case 6:
2317
+ summary = _context23.sent;
2318
+ this.logMethodSuccess('getSummary', {
2319
+ totalAmount: summary.total_amount
2320
+ });
2321
+ return _context23.abrupt("return", summary);
2322
+ case 11:
2323
+ _context23.prev = 11;
2324
+ _context23.t0 = _context23["catch"](1);
2325
+ this.logMethodError('getSummary', _context23.t0);
2326
+ throw _context23.t0;
2327
+ case 15:
2328
+ case "end":
2329
+ return _context23.stop();
2330
+ }
2331
+ }, _callee23, this, [[1, 11]]);
2332
+ }));
2333
+ function getSummary() {
2334
+ return _getSummary.apply(this, arguments);
2335
+ }
2336
+ return getSummary;
2337
+ }()
2338
+ }, {
2339
+ key: "submitOrder",
2340
+ value: function () {
2341
+ var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
2342
+ var _this$otherParams8, _this$otherParams9, _this$otherParams10, _this$otherParams11, _tempOrder$products2, result, tempOrder;
2343
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2344
+ while (1) switch (_context24.prev = _context24.next) {
2345
+ case 0:
2346
+ this.logMethodStart('submitOrder');
2347
+ _context24.prev = 1;
2348
+ _context24.next = 4;
2349
+ return this.validateBeforeSubmitByItemRule();
2350
+ case 4:
2351
+ if (this.store.order) {
2352
+ _context24.next = 6;
2353
+ break;
2354
+ }
2355
+ throw new Error('venueBooking解决方案需要 order 模块支持');
2356
+ case 6:
2357
+ _context24.next = 8;
2358
+ return this.store.order.submitTempOrder({
2359
+ cacheId: this.cacheId,
2360
+ platform: (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.platform,
2361
+ businessCode: (_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.businessCode,
2362
+ channel: (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.channel,
2363
+ type: (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.type
2364
+ });
2365
+ case 8:
2366
+ result = _context24.sent;
2367
+ tempOrder = this.store.order.getTempOrder();
2368
+ this.logMethodSuccess('submitOrder', {
2369
+ productCount: (tempOrder === null || tempOrder === void 0 || (_tempOrder$products2 = tempOrder.products) === null || _tempOrder$products2 === void 0 ? void 0 : _tempOrder$products2.length) || 0
2370
+ });
2371
+ return _context24.abrupt("return", result);
2372
+ case 14:
2373
+ _context24.prev = 14;
2374
+ _context24.t0 = _context24["catch"](1);
2375
+ this.logMethodError('submitOrder', _context24.t0);
2376
+ throw _context24.t0;
2377
+ case 18:
2378
+ case "end":
2379
+ return _context24.stop();
2380
+ }
2381
+ }, _callee24, this, [[1, 14]]);
2382
+ }));
2383
+ function submitOrder() {
2384
+ return _submitOrder.apply(this, arguments);
2385
+ }
2386
+ return submitOrder;
2387
+ }()
2388
+ }, {
2389
+ key: "addProductToOrder",
2390
+ value: function () {
2391
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(product) {
2392
+ var _product$metadata5, _product$product_vari2, quotationPrice, products;
2393
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
2394
+ while (1) switch (_context25.prev = _context25.next) {
2395
+ case 0:
2396
+ this.logMethodStart('addProductToOrder', {
2397
+ product_id: product.product_id,
2398
+ product_variant_id: product.product_variant_id
2399
+ });
2400
+ _context25.prev = 1;
2401
+ if (this.store.order) {
2402
+ _context25.next = 4;
2403
+ break;
2404
+ }
2405
+ throw new Error('order 模块未初始化');
2406
+ case 4:
2407
+ if (!((_product$metadata5 = product.metadata) !== null && _product$metadata5 !== void 0 && _product$metadata5.venue_booking) && this.store.quotation && product.product_id != null) {
2408
+ quotationPrice = this.store.quotation.getPriceForProduct({
2409
+ productId: product.product_id,
2410
+ variantId: (_product$product_vari2 = product.product_variant_id) !== null && _product$product_vari2 !== void 0 ? _product$product_vari2 : undefined,
2411
+ datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
2412
+ });
2413
+ if (quotationPrice !== null) {
2414
+ product.selling_price = quotationPrice;
2415
+ product.original_price = quotationPrice;
2416
+ } else if (product.selling_price != null) {
2417
+ product.original_price = product.selling_price;
2418
+ }
2419
+ }
2420
+ _context25.next = 7;
2421
+ return this.store.order.addProductToOrder(product);
2422
+ case 7:
2423
+ products = _context25.sent;
2424
+ _context25.next = 10;
2425
+ return this.refreshItemRuleQuantityLimits();
2426
+ case 10:
2427
+ _context25.next = 12;
2428
+ return this.refreshCartValidationPassed();
2429
+ case 12:
2430
+ this.logMethodSuccess('addProductToOrder', {
2431
+ productCount: products.length
2432
+ });
2433
+ return _context25.abrupt("return", products);
2434
+ case 16:
2435
+ _context25.prev = 16;
2436
+ _context25.t0 = _context25["catch"](1);
2437
+ this.logMethodError('addProductToOrder', _context25.t0);
2438
+ throw _context25.t0;
2439
+ case 20:
2440
+ case "end":
2441
+ return _context25.stop();
2442
+ }
2443
+ }, _callee25, this, [[1, 16]]);
2444
+ }));
2445
+ function addProductToOrder(_x16) {
2446
+ return _addProductToOrder.apply(this, arguments);
2447
+ }
2448
+ return addProductToOrder;
2449
+ }()
2450
+ }, {
2451
+ key: "updateProductInOrder",
2452
+ value: function () {
2453
+ var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
2454
+ var products;
2455
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2456
+ while (1) switch (_context26.prev = _context26.next) {
2457
+ case 0:
2458
+ this.logMethodStart('updateProductInOrder', {
2459
+ product_id: params.product_id,
2460
+ product_variant_id: params.product_variant_id
2461
+ });
2462
+ _context26.prev = 1;
2463
+ if (this.store.order) {
2464
+ _context26.next = 4;
2465
+ break;
2466
+ }
2467
+ throw new Error('order 模块未初始化');
2468
+ case 4:
2469
+ _context26.next = 6;
2470
+ return this.store.order.updateProductInOrder(params);
2471
+ case 6:
2472
+ products = _context26.sent;
2473
+ _context26.next = 9;
2474
+ return this.refreshItemRuleQuantityLimits();
2475
+ case 9:
2476
+ _context26.next = 11;
2477
+ return this.refreshCartValidationPassed();
2478
+ case 11:
2479
+ this.logMethodSuccess('updateProductInOrder', {
2480
+ productCount: products.length
2481
+ });
2482
+ return _context26.abrupt("return", products);
2483
+ case 15:
2484
+ _context26.prev = 15;
2485
+ _context26.t0 = _context26["catch"](1);
2486
+ this.logMethodError('updateProductInOrder', _context26.t0);
2487
+ throw _context26.t0;
2488
+ case 19:
2489
+ case "end":
2490
+ return _context26.stop();
2491
+ }
2492
+ }, _callee26, this, [[1, 15]]);
2493
+ }));
2494
+ function updateProductInOrder(_x17) {
2495
+ return _updateProductInOrder.apply(this, arguments);
2496
+ }
2497
+ return updateProductInOrder;
2498
+ }()
2499
+ }, {
2500
+ key: "removeProductFromOrder",
2501
+ value: function () {
2502
+ var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(identity) {
2503
+ var _this$store$order$get3, _this$store$order6, _this$store$order$ens, _this$store$order7, _tempOrder$bookings, tempOrder, products, _tempOrder$bookings2, _tempOrder$bookings3, venueProductUids, venueBookingUids, _iterator15, _step15, _product$metadata6, _product$metadata7, product, beforeBookingCount, _this$store$order$per, _this$store$order8;
2504
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2505
+ while (1) switch (_context27.prev = _context27.next) {
2506
+ case 0:
2507
+ this.logMethodStart('removeProductFromOrder', {
2508
+ product_id: identity.product_id,
2509
+ product_variant_id: identity.product_variant_id
2510
+ });
2511
+ _context27.prev = 1;
2512
+ if (this.store.order) {
2513
+ _context27.next = 4;
2514
+ break;
2515
+ }
2516
+ throw new Error('order 模块未初始化');
2517
+ case 4:
2518
+ tempOrder = ((_this$store$order$get3 = (_this$store$order6 = this.store.order).getTempOrder) === null || _this$store$order$get3 === void 0 ? void 0 : _this$store$order$get3.call(_this$store$order6)) || ((_this$store$order$ens = (_this$store$order7 = this.store.order).ensureTempOrder) === null || _this$store$order$ens === void 0 ? void 0 : _this$store$order$ens.call(_this$store$order7));
2519
+ _context27.next = 7;
2520
+ return this.store.order.removeProductFromOrder(identity);
2521
+ case 7:
2522
+ products = _context27.sent;
2523
+ if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$bookings = tempOrder.bookings) !== null && _tempOrder$bookings !== void 0 && _tempOrder$bookings.length)) {
2524
+ _context27.next = 33;
2525
+ break;
2526
+ }
2527
+ venueProductUids = new Set();
2528
+ venueBookingUids = new Set();
2529
+ _iterator15 = _createForOfIteratorHelper(tempOrder.products || []);
2530
+ _context27.prev = 12;
2531
+ _iterator15.s();
2532
+ case 14:
2533
+ if ((_step15 = _iterator15.n()).done) {
2534
+ _context27.next = 22;
2535
+ break;
2536
+ }
2537
+ product = _step15.value;
2538
+ if (product !== null && product !== void 0 && (_product$metadata6 = product.metadata) !== null && _product$metadata6 !== void 0 && _product$metadata6.venue_booking) {
2539
+ _context27.next = 18;
2540
+ break;
2541
+ }
2542
+ return _context27.abrupt("continue", 20);
2543
+ case 18:
2544
+ if (product.identity_key) venueProductUids.add(String(product.identity_key));
2545
+ if ((_product$metadata7 = product.metadata) !== null && _product$metadata7 !== void 0 && _product$metadata7.booking_uid) {
2546
+ venueBookingUids.add(String(product.metadata.booking_uid));
2547
+ }
2548
+ case 20:
2549
+ _context27.next = 14;
2550
+ break;
2551
+ case 22:
2552
+ _context27.next = 27;
2553
+ break;
2554
+ case 24:
2555
+ _context27.prev = 24;
2556
+ _context27.t0 = _context27["catch"](12);
2557
+ _iterator15.e(_context27.t0);
2558
+ case 27:
2559
+ _context27.prev = 27;
2560
+ _iterator15.f();
2561
+ return _context27.finish(27);
2562
+ case 30:
2563
+ beforeBookingCount = ((_tempOrder$bookings2 = tempOrder.bookings) === null || _tempOrder$bookings2 === void 0 ? void 0 : _tempOrder$bookings2.length) || 0;
2564
+ tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
2565
+ var _booking$metadata, _booking$metadata2;
2566
+ if (!(booking !== null && booking !== void 0 && (_booking$metadata = booking.metadata) !== null && _booking$metadata !== void 0 && _booking$metadata.venue_booking)) return true;
2567
+ if (booking.product_uid) {
2568
+ return venueProductUids.has(String(booking.product_uid));
2569
+ }
2570
+ var bookingUid = (_booking$metadata2 = booking.metadata) === null || _booking$metadata2 === void 0 ? void 0 : _booking$metadata2.unique_identification_number;
2571
+ if (bookingUid) return venueBookingUids.has(String(bookingUid));
2572
+ return true;
2573
+ });
2574
+ if ((((_tempOrder$bookings3 = tempOrder.bookings) === null || _tempOrder$bookings3 === void 0 ? void 0 : _tempOrder$bookings3.length) || 0) !== beforeBookingCount) {
2575
+ (_this$store$order$per = (_this$store$order8 = this.store.order).persistTempOrder) === null || _this$store$order$per === void 0 || _this$store$order$per.call(_this$store$order8);
2576
+ }
2577
+ case 33:
2578
+ _context27.next = 35;
2579
+ return this.refreshItemRuleQuantityLimits();
2580
+ case 35:
2581
+ _context27.next = 37;
2582
+ return this.refreshCartValidationPassed();
2583
+ case 37:
2584
+ this.logMethodSuccess('removeProductFromOrder', {
2585
+ productCount: products.length
2586
+ });
2587
+ return _context27.abrupt("return", products);
2588
+ case 41:
2589
+ _context27.prev = 41;
2590
+ _context27.t1 = _context27["catch"](1);
2591
+ this.logMethodError('removeProductFromOrder', _context27.t1);
2592
+ throw _context27.t1;
2593
+ case 45:
2594
+ case "end":
2595
+ return _context27.stop();
2596
+ }
2597
+ }, _callee27, this, [[1, 41], [12, 24, 27, 30]]);
2598
+ }));
2599
+ function removeProductFromOrder(_x18) {
2600
+ return _removeProductFromOrder.apply(this, arguments);
2601
+ }
2602
+ return removeProductFromOrder;
2603
+ }()
2604
+ }, {
2605
+ key: "getProductList",
2606
+ value: function () {
2607
+ var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
2608
+ var result;
2609
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2610
+ while (1) switch (_context28.prev = _context28.next) {
2611
+ case 0:
2612
+ if (!this.productsLoaded) {
2613
+ _context28.next = 2;
2614
+ break;
2615
+ }
2616
+ return _context28.abrupt("return", attachItemRuleLimitsToTopLevelProducts(this.getAddonProductsList(), this.store.itemRuleQuantityLimits || []));
2617
+ case 2:
2618
+ _context28.next = 4;
2619
+ return this.loadAllProducts();
2620
+ case 4:
2621
+ result = _context28.sent;
2622
+ return _context28.abrupt("return", attachItemRuleLimitsToTopLevelProducts(result.addonProducts, this.store.itemRuleQuantityLimits || []));
2623
+ case 6:
2624
+ case "end":
2625
+ return _context28.stop();
2626
+ }
2627
+ }, _callee28, this);
2628
+ }));
2629
+ function getProductList() {
2630
+ return _getProductList.apply(this, arguments);
2631
+ }
2632
+ return getProductList;
2633
+ }() // ─── ItemRule 引擎 ───
2634
+ }, {
2635
+ key: "loadOpenDataConfig",
2636
+ value: function () {
2637
+ var _loadOpenDataConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
2638
+ var lastFetchedAt, cachedData, openDataConfig;
2639
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2640
+ while (1) switch (_context29.prev = _context29.next) {
2641
+ case 0:
2642
+ if (this.store.openData) {
2643
+ _context29.next = 2;
2644
+ break;
2645
+ }
2646
+ throw new Error('openData 模块未初始化');
2647
+ case 2:
2648
+ lastFetchedAt = this.store.openData.getLastFetchedAt();
2649
+ cachedData = this.store.openData.getOpenData();
2650
+ if (!(cachedData && lastFetchedAt && Date.now() - lastFetchedAt < VenueBookingImpl.OPEN_DATA_CACHE_TTL)) {
2651
+ _context29.next = 7;
2652
+ break;
2653
+ }
2654
+ this.otherParams.openData = cachedData;
2655
+ return _context29.abrupt("return", cachedData);
2656
+ case 7:
2657
+ if (!this.loadOpenDataConfigInFlight) {
2658
+ _context29.next = 11;
2659
+ break;
2660
+ }
2661
+ _context29.next = 10;
2662
+ return this.loadOpenDataConfigInFlight;
2663
+ case 10:
2664
+ return _context29.abrupt("return", _context29.sent);
2665
+ case 11:
2666
+ this.loadOpenDataConfigInFlight = this.store.openData.fetchOpenData({
2667
+ scope: 'board',
2668
+ target: 'venue_booking+online_store',
2669
+ section_code: [].concat(OPEN_DATA_SECTION_CODES)
2670
+ });
2671
+ _context29.prev = 12;
2672
+ _context29.next = 15;
2673
+ return this.loadOpenDataConfigInFlight;
2674
+ case 15:
2675
+ openDataConfig = _context29.sent;
2676
+ this.otherParams.openData = openDataConfig;
2677
+ return _context29.abrupt("return", openDataConfig);
2678
+ case 18:
2679
+ _context29.prev = 18;
2680
+ this.loadOpenDataConfigInFlight = null;
2681
+ return _context29.finish(18);
2682
+ case 21:
2683
+ case "end":
2684
+ return _context29.stop();
2685
+ }
2686
+ }, _callee29, this, [[12,, 18, 21]]);
2687
+ }));
2688
+ function loadOpenDataConfig() {
2689
+ return _loadOpenDataConfig.apply(this, arguments);
2690
+ }
2691
+ return loadOpenDataConfig;
2692
+ }()
2693
+ }, {
2694
+ key: "loadRuntimeConfigs",
2695
+ value: function () {
2696
+ var _loadRuntimeConfigs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
2697
+ var itemRuleConfigs;
2698
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2699
+ while (1) switch (_context30.prev = _context30.next) {
2700
+ case 0:
2701
+ _context30.next = 2;
2702
+ return this.loadOpenDataConfig();
2703
+ case 2:
2704
+ _context30.next = 4;
2705
+ return this.ensureItemRuleConfigsLoaded();
2706
+ case 4:
2707
+ itemRuleConfigs = _context30.sent;
2708
+ this.logMethodSuccess('loadRuntimeConfigs', {
2709
+ itemRuleCount: itemRuleConfigs.length
2710
+ });
2711
+ return _context30.abrupt("return", {
2712
+ itemRuleConfigs: itemRuleConfigs
2713
+ });
2714
+ case 7:
2715
+ case "end":
2716
+ return _context30.stop();
2717
+ }
2718
+ }, _callee30, this);
2719
+ }));
2720
+ function loadRuntimeConfigs() {
2721
+ return _loadRuntimeConfigs.apply(this, arguments);
2722
+ }
2723
+ return loadRuntimeConfigs;
2724
+ }()
2725
+ }, {
2726
+ key: "fetchItemRuleConfigsByModelIds",
2727
+ value: function () {
2728
+ var _fetchItemRuleConfigsByModelIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(strategyModelIds) {
2729
+ var result, configs;
2730
+ return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2731
+ while (1) switch (_context31.prev = _context31.next) {
2732
+ case 0:
2733
+ this.logMethodStart('fetchItemRuleConfigsByModelIds', {
2734
+ strategyModelIds: strategyModelIds
2735
+ });
2736
+ if (strategyModelIds.length) {
2737
+ _context31.next = 3;
2738
+ break;
2739
+ }
2740
+ return _context31.abrupt("return", []);
2741
+ case 3:
2742
+ _context31.prev = 3;
2743
+ _context31.next = 6;
2744
+ return this.request.get('/promotion', {
2745
+ skip: 1,
2746
+ num: 99,
2747
+ status: 'active',
2748
+ ids: strategyModelIds
2749
+ });
2750
+ case 6:
2751
+ result = _context31.sent;
2752
+ configs = [];
2753
+ if (result.code === 200) {
2754
+ configs = result.data.list.map(function (item) {
2755
+ return item.metadata;
2756
+ });
2757
+ }
2758
+ this.logMethodSuccess('fetchItemRuleConfigsByModelIds', {
2759
+ strategyModelIds: strategyModelIds,
2760
+ strategyCount: configs.length
2761
+ });
2762
+ return _context31.abrupt("return", configs);
2763
+ case 13:
2764
+ _context31.prev = 13;
2765
+ _context31.t0 = _context31["catch"](3);
2766
+ this.logMethodError('fetchItemRuleConfigsByModelIds', _context31.t0, {
2767
+ strategyModelIds: strategyModelIds
2768
+ });
2769
+ return _context31.abrupt("return", []);
2770
+ case 17:
2771
+ case "end":
2772
+ return _context31.stop();
2773
+ }
2774
+ }, _callee31, this, [[3, 13]]);
2775
+ }));
2776
+ function fetchItemRuleConfigsByModelIds(_x19) {
2777
+ return _fetchItemRuleConfigsByModelIds.apply(this, arguments);
2778
+ }
2779
+ return fetchItemRuleConfigsByModelIds;
2780
+ }()
2781
+ }, {
2782
+ key: "buildPrefillProductSourceMap",
2783
+ value: function () {
2784
+ var _buildPrefillProductSourceMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
2785
+ var sourceMap, productList, visited, collectFromValue;
2786
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2787
+ while (1) switch (_context32.prev = _context32.next) {
2788
+ case 0:
2789
+ sourceMap = new Map();
2790
+ _context32.prev = 1;
2791
+ _context32.next = 4;
2792
+ return this.getProductList();
2793
+ case 4:
2794
+ productList = _context32.sent;
2795
+ if (Array.isArray(productList)) {
2796
+ _context32.next = 7;
2797
+ break;
2798
+ }
2799
+ return _context32.abrupt("return", sourceMap);
2800
+ case 7:
2801
+ visited = new Set();
2802
+ collectFromValue = function collectFromValue(value) {
2803
+ var _node$product_id;
2804
+ if (!value || _typeof(value) !== 'object') return;
2805
+ if (visited.has(value)) return;
2806
+ visited.add(value);
2807
+ if (Array.isArray(value)) {
2808
+ var _iterator16 = _createForOfIteratorHelper(value),
2809
+ _step16;
2810
+ try {
2811
+ for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
2812
+ var item = _step16.value;
2813
+ collectFromValue(item);
2814
+ }
2815
+ } catch (err) {
2816
+ _iterator16.e(err);
2817
+ } finally {
2818
+ _iterator16.f();
2819
+ }
2820
+ return;
2821
+ }
2822
+ var node = value;
2823
+ var rawProductId = (_node$product_id = node.product_id) !== null && _node$product_id !== void 0 ? _node$product_id : node.id;
2824
+ var productId = Number(rawProductId);
2825
+ if (Number.isFinite(productId) && productId > 0) {
2826
+ var _ref3, _node$product_variant;
2827
+ var productVariantId = Number((_ref3 = (_node$product_variant = node.product_variant_id) !== null && _node$product_variant !== void 0 ? _node$product_variant : node.variant_id) !== null && _ref3 !== void 0 ? _ref3 : 0);
2828
+ var normalizedVariantId = Number.isNaN(productVariantId) ? 0 : productVariantId;
2829
+ var key = buildProductKey(productId, normalizedVariantId);
2830
+ if (!sourceMap.has(key)) sourceMap.set(key, node);
2831
+ }
2832
+ for (var _i4 = 0, _Object$values = Object.values(node); _i4 < _Object$values.length; _i4++) {
2833
+ var childValue = _Object$values[_i4];
2834
+ if (childValue && _typeof(childValue) === 'object') collectFromValue(childValue);
2835
+ }
2836
+ };
2837
+ collectFromValue(productList);
2838
+ _context32.next = 15;
2839
+ break;
2840
+ case 12:
2841
+ _context32.prev = 12;
2842
+ _context32.t0 = _context32["catch"](1);
2843
+ this.logMethodError('buildPrefillProductSourceMap', _context32.t0);
2844
+ case 15:
2845
+ return _context32.abrupt("return", sourceMap);
2846
+ case 16:
2847
+ case "end":
2848
+ return _context32.stop();
2849
+ }
2850
+ }, _callee32, this, [[1, 12]]);
2851
+ }));
2852
+ function buildPrefillProductSourceMap() {
2853
+ return _buildPrefillProductSourceMap.apply(this, arguments);
2854
+ }
2855
+ return buildPrefillProductSourceMap;
2856
+ }()
2857
+ }, {
2858
+ key: "getItemRuleRuntimeConfig",
2859
+ value: function getItemRuleRuntimeConfig() {
2860
+ return this.itemRuleRuntimeConfig || {};
2861
+ }
2862
+ }, {
2863
+ key: "ensureItemRuleConfigsLoaded",
2864
+ value: function () {
2865
+ var _ensureItemRuleConfigsLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
2866
+ var _this11 = this;
2867
+ return _regeneratorRuntime().wrap(function _callee34$(_context34) {
2868
+ while (1) switch (_context34.prev = _context34.next) {
2869
+ case 0:
2870
+ if (!(this.itemRuleConfigs.length > 0)) {
2871
+ _context34.next = 2;
2872
+ break;
2873
+ }
2874
+ return _context34.abrupt("return", this.itemRuleConfigs);
2875
+ case 2:
2876
+ if (!this.itemRuleConfigsPromise) {
2877
+ _context34.next = 4;
2878
+ break;
2879
+ }
2880
+ return _context34.abrupt("return", this.itemRuleConfigsPromise);
2881
+ case 4:
2882
+ this.itemRuleConfigsPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
2883
+ var runtimeConfig, staticConfigs;
2884
+ return _regeneratorRuntime().wrap(function _callee33$(_context33) {
2885
+ while (1) switch (_context33.prev = _context33.next) {
2886
+ case 0:
2887
+ runtimeConfig = _this11.getItemRuleRuntimeConfig();
2888
+ staticConfigs = normalizeItemRuleStrategies(runtimeConfig.strategyConfigs);
2889
+ if (!(staticConfigs.length > 0)) {
2890
+ _context33.next = 6;
2891
+ break;
2892
+ }
2893
+ _this11.itemRuleConfigs = staticConfigs;
2894
+ _this11.itemRuleEvaluator.setStrategyConfigs(staticConfigs);
2895
+ return _context33.abrupt("return", _this11.itemRuleConfigs);
2896
+ case 6:
2897
+ _this11.itemRuleConfigs = [];
2898
+ _this11.itemRuleEvaluator.setStrategyConfigs([]);
2899
+ return _context33.abrupt("return", _this11.itemRuleConfigs);
2900
+ case 9:
2901
+ case "end":
2902
+ return _context33.stop();
2903
+ }
2904
+ }, _callee33);
2905
+ }))();
2906
+ _context34.next = 7;
2907
+ return this.itemRuleConfigsPromise;
2908
+ case 7:
2909
+ return _context34.abrupt("return", _context34.sent);
2910
+ case 8:
2911
+ case "end":
2912
+ return _context34.stop();
2913
+ }
2914
+ }, _callee34, this);
2915
+ }));
2916
+ function ensureItemRuleConfigsLoaded() {
2917
+ return _ensureItemRuleConfigsLoaded.apply(this, arguments);
2918
+ }
2919
+ return ensureItemRuleConfigsLoaded;
2920
+ }()
2921
+ }, {
2922
+ key: "refreshItemRuleQuantityLimits",
2923
+ value: function () {
2924
+ var _refreshItemRuleQuantityLimits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {
2925
+ var strategyConfigs, businessData, limits;
2926
+ return _regeneratorRuntime().wrap(function _callee35$(_context35) {
2927
+ while (1) switch (_context35.prev = _context35.next) {
2928
+ case 0:
2929
+ _context35.prev = 0;
2930
+ _context35.next = 3;
2931
+ return this.ensureItemRuleConfigsLoaded();
2932
+ case 3:
2933
+ strategyConfigs = _context35.sent;
2934
+ if (strategyConfigs.length) {
2935
+ _context35.next = 7;
2936
+ break;
2937
+ }
2938
+ this.store.itemRuleQuantityLimits = [];
2939
+ return _context35.abrupt("return", []);
2940
+ case 7:
2941
+ businessData = buildItemRuleBusinessData({
2942
+ tempOrder: this.ensureTempOrder(),
2943
+ runtimeConfig: this.getItemRuleRuntimeConfig(),
2944
+ itemRuleConfigs: this.itemRuleConfigs
2945
+ });
2946
+ limits = this.itemRuleEvaluator.getQuantityLimits(businessData);
2947
+ this.store.itemRuleQuantityLimits = limits;
2948
+ this.logMethodSuccess('refreshItemRuleQuantityLimits', {
2949
+ limitCount: limits.length
2950
+ });
2951
+ return _context35.abrupt("return", limits);
2952
+ case 14:
2953
+ _context35.prev = 14;
2954
+ _context35.t0 = _context35["catch"](0);
2955
+ this.store.itemRuleQuantityLimits = [];
2956
+ this.logMethodError('refreshItemRuleQuantityLimits', _context35.t0);
2957
+ return _context35.abrupt("return", []);
2958
+ case 19:
2959
+ case "end":
2960
+ return _context35.stop();
2961
+ }
2962
+ }, _callee35, this, [[0, 14]]);
2963
+ }));
2964
+ function refreshItemRuleQuantityLimits() {
2965
+ return _refreshItemRuleQuantityLimits.apply(this, arguments);
2966
+ }
2967
+ return refreshItemRuleQuantityLimits;
2968
+ }()
2969
+ }, {
2970
+ key: "applyPrefillByItemRule",
2971
+ value: function () {
2972
+ var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {
2973
+ var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges, _iterator17, _step17, _prefillItem$product_, _targetProduct$_origi, prefillItem, productId, productVariantId, targetQuantity, sourceItem, productIndex, _sourceItem$price, sellingPrice, targetProduct, existedQuantity, delta, nextProduct;
2974
+ return _regeneratorRuntime().wrap(function _callee36$(_context36) {
2975
+ while (1) switch (_context36.prev = _context36.next) {
2976
+ case 0:
2977
+ if (!this.itemRulePrefillApplied) {
2978
+ _context36.next = 2;
2979
+ break;
2980
+ }
2981
+ return _context36.abrupt("return");
2982
+ case 2:
2983
+ if (this.store.order) {
2984
+ _context36.next = 4;
2985
+ break;
2986
+ }
2987
+ return _context36.abrupt("return");
2988
+ case 4:
2989
+ _context36.next = 6;
2990
+ return this.ensureItemRuleConfigsLoaded();
2991
+ case 6:
2992
+ strategyConfigs = _context36.sent;
2993
+ if (strategyConfigs.length) {
2994
+ _context36.next = 9;
2995
+ break;
2996
+ }
2997
+ return _context36.abrupt("return");
2998
+ case 9:
2999
+ businessData = buildItemRuleBusinessData({
3000
+ tempOrder: this.ensureTempOrder(),
3001
+ runtimeConfig: this.getItemRuleRuntimeConfig(),
3002
+ itemRuleConfigs: this.itemRuleConfigs
3003
+ });
3004
+ prefillItems = this.itemRuleEvaluator.getPrefillItems(businessData);
3005
+ if (prefillItems.length) {
3006
+ _context36.next = 14;
3007
+ break;
3008
+ }
3009
+ this.itemRulePrefillApplied = true;
3010
+ return _context36.abrupt("return");
3011
+ case 14:
3012
+ _context36.next = 16;
3013
+ return this.buildPrefillProductSourceMap();
3014
+ case 16:
3015
+ productSourceMap = _context36.sent;
3016
+ tempOrder = this.ensureTempOrder();
3017
+ hasChanges = false;
3018
+ _iterator17 = _createForOfIteratorHelper(prefillItems);
3019
+ _context36.prev = 20;
3020
+ _iterator17.s();
3021
+ case 22:
3022
+ if ((_step17 = _iterator17.n()).done) {
3023
+ _context36.next = 45;
3024
+ break;
3025
+ }
3026
+ prefillItem = _step17.value;
3027
+ productId = Number(prefillItem.product_id);
3028
+ productVariantId = Number((_prefillItem$product_ = prefillItem.product_variant_id) !== null && _prefillItem$product_ !== void 0 ? _prefillItem$product_ : 0);
3029
+ targetQuantity = toNonNegativeInt(prefillItem.quantity);
3030
+ if (!(!Number.isFinite(productId) || targetQuantity <= 0)) {
3031
+ _context36.next = 29;
3032
+ break;
3033
+ }
3034
+ return _context36.abrupt("continue", 43);
3035
+ case 29:
3036
+ if (!Number.isNaN(productVariantId)) {
3037
+ _context36.next = 31;
3038
+ break;
3039
+ }
3040
+ return _context36.abrupt("continue", 43);
3041
+ case 31:
3042
+ sourceItem = productSourceMap.get(buildProductKey(productId, productVariantId)) || productSourceMap.get(buildProductKey(productId, 0)) || null;
3043
+ productIndex = getProductIdentityIndex(tempOrder.products, {
3044
+ product_id: productId,
3045
+ product_variant_id: productVariantId
3046
+ });
3047
+ if (!(productIndex === -1)) {
3048
+ _context36.next = 38;
3049
+ break;
3050
+ }
3051
+ sellingPrice = toPriceString((_sourceItem$price = sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.price) !== null && _sourceItem$price !== void 0 ? _sourceItem$price : sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.selling_price, '0.00');
3052
+ tempOrder.products.push(normalizeOrderProduct({
3053
+ product_id: productId,
3054
+ product_variant_id: productVariantId,
3055
+ num: targetQuantity,
3056
+ selling_price: sellingPrice,
3057
+ original_price: sellingPrice,
3058
+ metadata: {
3059
+ item_rule_prefill: true,
3060
+ item_rule_id: prefillItem.ruleId
3061
+ },
3062
+ _origin: _objectSpread(_objectSpread({}, sourceItem || {}), {}, {
3063
+ item_rule_prefill: true,
3064
+ item_rule_id: prefillItem.ruleId
3065
+ })
3066
+ }));
3067
+ hasChanges = true;
3068
+ return _context36.abrupt("continue", 43);
3069
+ case 38:
3070
+ targetProduct = tempOrder.products[productIndex];
3071
+ existedQuantity = toNonNegativeInt(targetProduct.num);
3072
+ delta = targetQuantity - existedQuantity;
3073
+ nextProduct = _objectSpread(_objectSpread(_objectSpread({}, targetProduct), delta > 0 ? {
3074
+ num: getSafeProductNum(existedQuantity + delta)
3075
+ } : {}), {}, {
3076
+ metadata: _objectSpread(_objectSpread({}, targetProduct.metadata || {}), {}, {
3077
+ item_rule_prefill: true,
3078
+ item_rule_id: prefillItem.ruleId
3079
+ }),
3080
+ _origin: sourceItem ? _objectSpread(_objectSpread({}, targetProduct._origin || {}), sourceItem) : targetProduct._origin
3081
+ });
3082
+ if (delta > 0 || Boolean(sourceItem && (!targetProduct._origin || ((_targetProduct$_origi = targetProduct._origin) === null || _targetProduct$_origi === void 0 ? void 0 : _targetProduct$_origi.price) !== (sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.price)))) {
3083
+ tempOrder.products[productIndex] = nextProduct;
3084
+ hasChanges = true;
3085
+ }
3086
+ case 43:
3087
+ _context36.next = 22;
3088
+ break;
3089
+ case 45:
3090
+ _context36.next = 50;
3091
+ break;
3092
+ case 47:
3093
+ _context36.prev = 47;
3094
+ _context36.t0 = _context36["catch"](20);
3095
+ _iterator17.e(_context36.t0);
3096
+ case 50:
3097
+ _context36.prev = 50;
3098
+ _iterator17.f();
3099
+ return _context36.finish(50);
3100
+ case 53:
3101
+ if (!hasChanges) {
3102
+ _context36.next = 58;
3103
+ break;
3104
+ }
3105
+ // Prefill 属于 products CRUD 的一种形式:新增后让 Rules 重算,以支持自动应用可用优惠券。
3106
+ this.store.order.applyDiscount();
3107
+ _context36.next = 57;
3108
+ return this.store.order.recalculateSummary({
3109
+ createIfMissing: true
3110
+ });
3111
+ case 57:
3112
+ this.store.order.persistTempOrder();
3113
+ case 58:
3114
+ _context36.next = 60;
3115
+ return this.refreshItemRuleQuantityLimits();
3116
+ case 60:
3117
+ this.itemRulePrefillApplied = true;
3118
+ this.logMethodSuccess('applyPrefillByItemRule', {
3119
+ prefillCount: prefillItems.length,
3120
+ hasChanges: hasChanges
3121
+ });
3122
+ case 62:
3123
+ case "end":
3124
+ return _context36.stop();
3125
+ }
3126
+ }, _callee36, this, [[20, 47, 50, 53]]);
3127
+ }));
3128
+ function applyPrefillByItemRule() {
3129
+ return _applyPrefillByItemRule.apply(this, arguments);
3130
+ }
3131
+ return applyPrefillByItemRule;
3132
+ }()
3133
+ }, {
3134
+ key: "applyItemRulePrefill",
3135
+ value: function () {
3136
+ var _applyItemRulePrefill = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {
3137
+ return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3138
+ while (1) switch (_context37.prev = _context37.next) {
3139
+ case 0:
3140
+ this.logMethodStart('applyItemRulePrefill');
3141
+ _context37.next = 3;
3142
+ return this.applyPrefillByItemRule();
3143
+ case 3:
3144
+ _context37.next = 5;
3145
+ return this.refreshItemRuleQuantityLimits();
3146
+ case 5:
3147
+ _context37.next = 7;
3148
+ return this.refreshCartValidationPassed();
3149
+ case 7:
3150
+ case "end":
3151
+ return _context37.stop();
3152
+ }
3153
+ }, _callee37, this);
3154
+ }));
3155
+ function applyItemRulePrefill() {
3156
+ return _applyItemRulePrefill.apply(this, arguments);
3157
+ }
3158
+ return applyItemRulePrefill;
3159
+ }()
3160
+ }, {
3161
+ key: "evaluateCartValidationByItemRule",
3162
+ value: function () {
3163
+ var _evaluateCartValidationByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
3164
+ var strategyConfigs, businessData;
3165
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3166
+ while (1) switch (_context38.prev = _context38.next) {
3167
+ case 0:
3168
+ _context38.next = 2;
3169
+ return this.ensureItemRuleConfigsLoaded();
3170
+ case 2:
3171
+ strategyConfigs = _context38.sent;
3172
+ if (strategyConfigs.length) {
3173
+ _context38.next = 5;
3174
+ break;
3175
+ }
3176
+ return _context38.abrupt("return", {
3177
+ passed: true,
3178
+ failures: []
3179
+ });
3180
+ case 5:
3181
+ businessData = buildItemRuleBusinessData({
3182
+ tempOrder: this.ensureTempOrder(),
3183
+ runtimeConfig: this.getItemRuleRuntimeConfig(),
3184
+ itemRuleConfigs: this.itemRuleConfigs
3185
+ });
3186
+ return _context38.abrupt("return", this.itemRuleEvaluator.validateCart(businessData));
3187
+ case 7:
3188
+ case "end":
3189
+ return _context38.stop();
3190
+ }
3191
+ }, _callee38, this);
3192
+ }));
3193
+ function evaluateCartValidationByItemRule() {
3194
+ return _evaluateCartValidationByItemRule.apply(this, arguments);
3195
+ }
3196
+ return evaluateCartValidationByItemRule;
3197
+ }()
3198
+ }, {
3199
+ key: "validateBeforeSubmitByItemRule",
3200
+ value: function () {
3201
+ var _validateBeforeSubmitByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
3202
+ var validationResult, firstFailure, errorMessage, error;
3203
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3204
+ while (1) switch (_context39.prev = _context39.next) {
3205
+ case 0:
3206
+ _context39.next = 2;
3207
+ return this.evaluateCartValidationByItemRule();
3208
+ case 2:
3209
+ validationResult = _context39.sent;
3210
+ if (!validationResult.passed) {
3211
+ _context39.next = 5;
3212
+ break;
3213
+ }
3214
+ return _context39.abrupt("return");
3215
+ case 5:
3216
+ firstFailure = validationResult.failures[0];
3217
+ errorMessage = (firstFailure === null || firstFailure === void 0 ? void 0 : firstFailure.validationMessage) || '当前购物车未满足商品规则,请调整后再提交';
3218
+ error = new Error(String(errorMessage));
3219
+ error.failures = validationResult.failures;
3220
+ throw error;
3221
+ case 10:
3222
+ case "end":
3223
+ return _context39.stop();
3224
+ }
3225
+ }, _callee39, this);
3226
+ }));
3227
+ function validateBeforeSubmitByItemRule() {
3228
+ return _validateBeforeSubmitByItemRule.apply(this, arguments);
3229
+ }
3230
+ return validateBeforeSubmitByItemRule;
3231
+ }()
3232
+ }, {
3233
+ key: "refreshCartValidationPassed",
3234
+ value: function () {
3235
+ var _refreshCartValidationPassed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40() {
3236
+ var previous, nextState, validationResult, changed;
3237
+ return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3238
+ while (1) switch (_context40.prev = _context40.next) {
3239
+ case 0:
3240
+ previous = this.store.cartValidation || {
3241
+ passed: null,
3242
+ failures: []
3243
+ };
3244
+ nextState = {
3245
+ passed: null,
3246
+ failures: []
3247
+ };
3248
+ _context40.prev = 2;
3249
+ _context40.next = 5;
3250
+ return this.evaluateCartValidationByItemRule();
3251
+ case 5:
3252
+ validationResult = _context40.sent;
3253
+ nextState = {
3254
+ passed: validationResult.passed,
3255
+ failures: validationResult.failures || []
3256
+ };
3257
+ _context40.next = 12;
3258
+ break;
3259
+ case 9:
3260
+ _context40.prev = 9;
3261
+ _context40.t0 = _context40["catch"](2);
3262
+ nextState = {
3263
+ passed: false,
3264
+ failures: []
3265
+ };
3266
+ case 12:
3267
+ this.store.cartValidation = nextState;
3268
+ changed = previous.passed !== nextState.passed || previous.failures !== nextState.failures;
3269
+ if (!changed) {
3270
+ _context40.next = 17;
3271
+ break;
3272
+ }
3273
+ _context40.next = 17;
3274
+ return this.core.effects.emit(VenueBookingHooks.onCartValidationChanged, {
3275
+ cartValidation: nextState,
3276
+ cartValidationPassed: nextState.passed
3277
+ });
3278
+ case 17:
3279
+ return _context40.abrupt("return", nextState.passed);
3280
+ case 18:
3281
+ case "end":
3282
+ return _context40.stop();
3283
+ }
3284
+ }, _callee40, this, [[2, 9]]);
3285
+ }));
3286
+ function refreshCartValidationPassed() {
3287
+ return _refreshCartValidationPassed.apply(this, arguments);
3288
+ }
3289
+ return refreshCartValidationPassed;
3290
+ }()
3291
+ }, {
3292
+ key: "setItemRuleRuntimeConfig",
3293
+ value: function () {
3294
+ var _setItemRuleRuntimeConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41() {
3295
+ var _this$itemRuleRuntime, _this$itemRuleRuntime2;
3296
+ var config,
3297
+ _args41 = arguments;
3298
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3299
+ while (1) switch (_context41.prev = _context41.next) {
3300
+ case 0:
3301
+ config = _args41.length > 0 && _args41[0] !== undefined ? _args41[0] : {};
3302
+ this.logMethodStart('setItemRuleRuntimeConfig');
3303
+ this.itemRuleRuntimeConfig = _objectSpread(_objectSpread(_objectSpread({}, this.itemRuleRuntimeConfig), config), {}, {
3304
+ pax: _objectSpread(_objectSpread({}, ((_this$itemRuleRuntime = this.itemRuleRuntimeConfig) === null || _this$itemRuleRuntime === void 0 ? void 0 : _this$itemRuleRuntime.pax) || {}), (config === null || config === void 0 ? void 0 : config.pax) || {}),
3305
+ custom: _objectSpread(_objectSpread({}, ((_this$itemRuleRuntime2 = this.itemRuleRuntimeConfig) === null || _this$itemRuleRuntime2 === void 0 ? void 0 : _this$itemRuleRuntime2.custom) || {}), (config === null || config === void 0 ? void 0 : config.custom) || {})
3306
+ });
3307
+ if ('strategyConfigs' in config) {
3308
+ this.itemRuleConfigs = [];
3309
+ this.itemRuleConfigsPromise = null;
3310
+ this.itemRuleEvaluator.setStrategyConfigs([]);
3311
+ }
3312
+ this.itemRulePrefillApplied = false;
3313
+ _context41.next = 7;
3314
+ return this.refreshItemRuleQuantityLimits();
3315
+ case 7:
3316
+ _context41.next = 9;
3317
+ return this.refreshCartValidationPassed();
3318
+ case 9:
3319
+ this.logMethodSuccess('setItemRuleRuntimeConfig', {
3320
+ strategyCount: Array.isArray(this.itemRuleRuntimeConfig.strategyConfigs) ? this.itemRuleRuntimeConfig.strategyConfigs.length : 0
3321
+ });
3322
+ case 10:
3323
+ case "end":
3324
+ return _context41.stop();
3325
+ }
3326
+ }, _callee41, this);
3327
+ }));
3328
+ function setItemRuleRuntimeConfig() {
3329
+ return _setItemRuleRuntimeConfig.apply(this, arguments);
3330
+ }
3331
+ return setItemRuleRuntimeConfig;
3332
+ }()
3333
+ }, {
3334
+ key: "getOtherParams",
3335
+ value: function getOtherParams() {
3336
+ return this.otherParams;
3337
+ }
3338
+
3339
+ // ─── UI 状态缓存(按 cacheId 分桶,sessionStorage) ───
3340
+ //
3341
+ // 用于物料层持久化 UI 层面的轻量状态(如当前步骤、登录回跳意图等)。
3342
+ // 桶键:pisell.venueBooking.uiState:<cacheId>;内部以 JSON object 形式存储多个字段。
3343
+ // 无 cacheId 时所有方法自动降级为 no-op,上层不用判空。
3344
+ }, {
3345
+ key: "getUIStateBucketKey",
3346
+ value: function getUIStateBucketKey() {
3347
+ if (!this.cacheId) return null;
3348
+ return "".concat(VenueBookingImpl.UI_STATE_KEY_PREFIX).concat(this.cacheId);
3349
+ }
3350
+ }, {
3351
+ key: "readUIStateBucket",
3352
+ value: function readUIStateBucket() {
3353
+ var _this$window;
3354
+ var key = this.getUIStateBucketKey();
3355
+ if (!key || !((_this$window = this.window) !== null && _this$window !== void 0 && _this$window.sessionStorage)) return {};
3356
+ try {
3357
+ var raw = this.window.sessionStorage.getItem(key) || '{}';
3358
+ var parsed = JSON.parse(raw);
3359
+ return parsed && _typeof(parsed) === 'object' ? parsed : {};
3360
+ } catch (_unused3) {
3361
+ return {};
3362
+ }
3363
+ }
3364
+ }, {
3365
+ key: "writeUIStateBucket",
3366
+ value: function writeUIStateBucket(bucket) {
3367
+ var _this$window2;
3368
+ var key = this.getUIStateBucketKey();
3369
+ if (!key || !((_this$window2 = this.window) !== null && _this$window2 !== void 0 && _this$window2.sessionStorage)) return;
3370
+ this.window.sessionStorage.setItem(key, JSON.stringify(bucket));
3371
+ }
3372
+ }, {
3373
+ key: "setUIState",
3374
+ value: function setUIState(key, value) {
3375
+ if (!this.getUIStateBucketKey()) return;
3376
+ var bucket = this.readUIStateBucket();
3377
+ bucket[key] = value;
3378
+ this.writeUIStateBucket(bucket);
3379
+ }
3380
+ }, {
3381
+ key: "getUIState",
3382
+ value: function getUIState(key) {
3383
+ if (!this.getUIStateBucketKey()) return undefined;
3384
+ var bucket = this.readUIStateBucket();
3385
+ return bucket[key];
3386
+ }
3387
+ }, {
3388
+ key: "deleteUIState",
3389
+ value: function deleteUIState(key) {
3390
+ if (!this.getUIStateBucketKey()) return;
3391
+ var bucket = this.readUIStateBucket();
3392
+ if (key in bucket) {
3393
+ delete bucket[key];
3394
+ this.writeUIStateBucket(bucket);
3395
+ }
3396
+ }
3397
+ }, {
3398
+ key: "setBookingHolder",
3399
+ value: function setBookingHolder(bookingUid, holder) {
3400
+ var _order$bookings;
3401
+ var order = this.getTempOrder();
3402
+ var booking = order === null || order === void 0 || (_order$bookings = order.bookings) === null || _order$bookings === void 0 ? void 0 : _order$bookings.find(function (b) {
3403
+ var _b$metadata4;
3404
+ return ((_b$metadata4 = b.metadata) === null || _b$metadata4 === void 0 ? void 0 : _b$metadata4.unique_identification_number) === bookingUid;
3405
+ });
3406
+ if (booking) {
3407
+ booking.holder = holder;
3408
+ }
3409
+ }
3410
+
3411
+ // ─── OpenData 可用性 ───
3412
+ }, {
3413
+ key: "checkOpenDataAvailability",
3414
+ value: function () {
3415
+ var _checkOpenDataAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42() {
3416
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3417
+ while (1) switch (_context42.prev = _context42.next) {
3418
+ case 0:
3419
+ if (this.store.openData) {
3420
+ _context42.next = 2;
3421
+ break;
3422
+ }
3423
+ throw new Error('openData 模块未初始化');
3424
+ case 2:
3425
+ _context42.next = 4;
3426
+ return this.loadOpenDataConfig();
3427
+ case 4:
3428
+ return _context42.abrupt("return", this.store.openData.checkAvailability(this.store.schedule));
3429
+ case 5:
3430
+ case "end":
3431
+ return _context42.stop();
3432
+ }
3433
+ }, _callee42, this);
3434
+ }));
3435
+ function checkOpenDataAvailability() {
3436
+ return _checkOpenDataAvailability.apply(this, arguments);
3437
+ }
3438
+ return checkOpenDataAvailability;
3439
+ }()
3440
+ }, {
3441
+ key: "setOtherParams",
3442
+ value: function () {
3443
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
3444
+ var _ref5,
3445
+ _ref5$cover,
3446
+ cover,
3447
+ _args43 = arguments;
3448
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3449
+ while (1) switch (_context43.prev = _context43.next) {
3450
+ case 0:
3451
+ _ref5 = _args43.length > 1 && _args43[1] !== undefined ? _args43[1] : {}, _ref5$cover = _ref5.cover, cover = _ref5$cover === void 0 ? false : _ref5$cover;
3452
+ if (cover) {
3453
+ this.otherParams = params;
3454
+ } else {
3455
+ this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
3456
+ }
3457
+ case 2:
3458
+ case "end":
3459
+ return _context43.stop();
3460
+ }
3461
+ }, _callee43, this);
3462
+ }));
3463
+ function setOtherParams(_x20) {
3464
+ return _setOtherParams.apply(this, arguments);
3465
+ }
3466
+ return setOtherParams;
3467
+ }()
3468
+ }]);
3469
+ return VenueBookingImpl;
3470
+ }(BaseModule);
3471
+ _defineProperty(VenueBookingImpl, "OPEN_DATA_CACHE_TTL", 5 * 60 * 1000);
3472
+ _defineProperty(VenueBookingImpl, "UI_STATE_KEY_PREFIX", 'pisell.venueBooking.uiState:');