@pisell/pisellos 2.1.172 → 2.1.174

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