@pisell/pisellos 2.1.119 → 2.1.120

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 (231) hide show
  1. package/dist/apis/picoding.d.ts +0 -0
  2. package/dist/apis/picoding.js +1 -0
  3. package/dist/model/index.d.ts +1 -0
  4. package/dist/model/index.js +1 -0
  5. package/dist/model/strategy/adapter/index.d.ts +7 -0
  6. package/dist/model/strategy/adapter/index.js +7 -0
  7. package/dist/model/strategy/adapter/itemRule/adapter.d.ts +59 -0
  8. package/dist/model/strategy/adapter/itemRule/adapter.js +439 -0
  9. package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
  10. package/dist/model/strategy/adapter/itemRule/evaluator.js +169 -0
  11. package/dist/model/strategy/adapter/itemRule/examples.d.ts +64 -0
  12. package/dist/model/strategy/adapter/itemRule/examples.js +315 -0
  13. package/dist/model/strategy/adapter/itemRule/index.d.ts +5 -0
  14. package/dist/model/strategy/adapter/itemRule/index.js +5 -0
  15. package/dist/model/strategy/adapter/itemRule/type.d.ts +206 -0
  16. package/dist/model/strategy/adapter/itemRule/type.js +101 -0
  17. package/dist/model/strategy/adapter/promotion/adapter.d.ts +66 -0
  18. package/dist/model/strategy/adapter/promotion/adapter.js +271 -0
  19. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +213 -0
  20. package/dist/model/strategy/adapter/promotion/evaluator.js +1206 -0
  21. package/dist/model/strategy/adapter/promotion/examples.d.ts +138 -0
  22. package/dist/model/strategy/adapter/promotion/examples.js +166 -0
  23. package/dist/model/strategy/adapter/promotion/index.d.ts +4 -0
  24. package/dist/model/strategy/adapter/promotion/index.js +0 -0
  25. package/dist/model/strategy/adapter/promotion/type.d.ts +447 -0
  26. package/dist/model/strategy/adapter/promotion/type.js +209 -0
  27. package/dist/model/strategy/adapter/type.d.ts +28 -0
  28. package/dist/model/strategy/adapter/type.js +1 -0
  29. package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +84 -0
  30. package/dist/model/strategy/adapter/walletPass/evaluator.js +502 -0
  31. package/dist/model/strategy/adapter/walletPass/example.d.ts +4 -0
  32. package/dist/model/strategy/adapter/walletPass/example.js +258 -0
  33. package/dist/model/strategy/adapter/walletPass/index.d.ts +32 -0
  34. package/dist/model/strategy/adapter/walletPass/index.js +182 -0
  35. package/dist/model/strategy/adapter/walletPass/locales.d.ts +1 -0
  36. package/dist/model/strategy/adapter/walletPass/locales.js +26 -0
  37. package/dist/model/strategy/adapter/walletPass/type.d.ts +187 -0
  38. package/dist/model/strategy/adapter/walletPass/type.js +1 -0
  39. package/dist/model/strategy/adapter/walletPass/utils.d.ts +50 -0
  40. package/dist/model/strategy/adapter/walletPass/utils.js +1104 -0
  41. package/dist/model/strategy/engine.d.ts +106 -0
  42. package/dist/model/strategy/engine.js +611 -0
  43. package/dist/model/strategy/index.d.ts +3 -0
  44. package/dist/model/strategy/index.js +8 -0
  45. package/dist/model/strategy/strategy-example.d.ts +5 -0
  46. package/dist/model/strategy/strategy-example.js +331 -0
  47. package/dist/model/strategy/type.d.ts +228 -0
  48. package/dist/model/strategy/type.js +94 -0
  49. package/dist/modules/Cart/utils/cartProduct.js +1 -0
  50. package/dist/modules/OpenData/index.d.ts +23 -0
  51. package/dist/modules/OpenData/index.js +167 -0
  52. package/dist/modules/OpenData/types.d.ts +73 -0
  53. package/dist/modules/OpenData/types.js +1 -0
  54. package/dist/modules/OpenData/utils.d.ts +2 -0
  55. package/dist/modules/OpenData/utils.js +75 -0
  56. package/dist/modules/Order/index.d.ts +58 -1
  57. package/dist/modules/Order/index.js +780 -29
  58. package/dist/modules/Order/types.d.ts +144 -12
  59. package/dist/modules/Order/utils.d.ts +25 -0
  60. package/dist/modules/Order/utils.js +225 -1
  61. package/dist/modules/Product/index.d.ts +1 -1
  62. package/dist/modules/Product/utils.js +2 -2
  63. package/dist/modules/ProductList/index.d.ts +1 -1
  64. package/dist/modules/ProductList/index.js +2 -1
  65. package/dist/modules/Quotation/index.d.ts +48 -0
  66. package/dist/modules/Quotation/index.js +245 -0
  67. package/dist/modules/Quotation/types.d.ts +42 -0
  68. package/dist/modules/Quotation/types.js +1 -0
  69. package/dist/modules/Rules/index.js +4 -1
  70. package/dist/modules/SalesSummary/index.d.ts +63 -0
  71. package/dist/modules/SalesSummary/index.js +174 -0
  72. package/dist/modules/SalesSummary/types.d.ts +59 -0
  73. package/dist/modules/SalesSummary/types.js +1 -0
  74. package/dist/modules/SalesSummary/utils.d.ts +30 -0
  75. package/dist/modules/SalesSummary/utils.js +513 -0
  76. package/dist/modules/ScanOrderLogger/index.d.ts +21 -0
  77. package/dist/modules/ScanOrderLogger/index.js +161 -0
  78. package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
  79. package/dist/modules/ScanOrderLogger/providers/feishu.js +95 -0
  80. package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
  81. package/dist/modules/ScanOrderLogger/providers/grafana.js +50 -0
  82. package/dist/modules/ScanOrderLogger/types.d.ts +46 -0
  83. package/dist/modules/ScanOrderLogger/types.js +1 -0
  84. package/dist/modules/Schedule/getDateIsInSchedule.js +11 -18
  85. package/dist/modules/Summary/utils.d.ts +3 -3
  86. package/dist/modules/Summary/utils.js +4 -4
  87. package/dist/modules/index.d.ts +4 -0
  88. package/dist/modules/index.js +5 -1
  89. package/dist/solution/BookingByStep/index.d.ts +1 -1
  90. package/dist/solution/BookingByStep/types.d.ts +3 -1
  91. package/dist/solution/BookingByStep/types.js +5 -1
  92. package/dist/solution/BookingTicket/index.d.ts +1 -1
  93. package/dist/solution/ScanOrder/index.d.ts +90 -0
  94. package/dist/solution/ScanOrder/index.js +1853 -0
  95. package/dist/solution/ScanOrder/types.d.ts +210 -0
  96. package/dist/solution/ScanOrder/types.js +16 -0
  97. package/dist/solution/ScanOrder/utils.d.ts +93 -0
  98. package/dist/solution/ScanOrder/utils.js +397 -0
  99. package/dist/solution/VenueBooking/index.d.ts +158 -0
  100. package/dist/solution/VenueBooking/index.js +2873 -0
  101. package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
  102. package/dist/solution/VenueBooking/types.d.ts +130 -0
  103. package/dist/solution/VenueBooking/types.js +21 -0
  104. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +10 -0
  105. package/dist/solution/VenueBooking/utils/dateSummary.js +102 -0
  106. package/dist/solution/VenueBooking/utils/resource.d.ts +4 -0
  107. package/dist/solution/VenueBooking/utils/resource.js +94 -0
  108. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +29 -0
  109. package/dist/solution/VenueBooking/utils/slotMerge.js +204 -0
  110. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
  111. package/dist/solution/VenueBooking/utils/timeSlot.js +256 -0
  112. package/dist/solution/VenueBooking/utils.d.ts +1 -0
  113. package/dist/solution/VenueBooking/utils.js +1 -0
  114. package/dist/solution/index.d.ts +2 -0
  115. package/dist/solution/index.js +3 -1
  116. package/lib/apis/picoding.d.ts +0 -0
  117. package/lib/apis/picoding.js +0 -0
  118. package/lib/model/index.d.ts +1 -0
  119. package/lib/model/index.js +23 -0
  120. package/lib/model/strategy/adapter/index.d.ts +7 -0
  121. package/lib/model/strategy/adapter/index.js +57 -0
  122. package/lib/model/strategy/adapter/itemRule/adapter.d.ts +59 -0
  123. package/lib/model/strategy/adapter/itemRule/adapter.js +338 -0
  124. package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
  125. package/lib/model/strategy/adapter/itemRule/evaluator.js +124 -0
  126. package/lib/model/strategy/adapter/itemRule/examples.d.ts +64 -0
  127. package/lib/model/strategy/adapter/itemRule/examples.js +269 -0
  128. package/lib/model/strategy/adapter/itemRule/index.d.ts +5 -0
  129. package/lib/model/strategy/adapter/itemRule/index.js +58 -0
  130. package/lib/model/strategy/adapter/itemRule/type.d.ts +206 -0
  131. package/lib/model/strategy/adapter/itemRule/type.js +46 -0
  132. package/lib/model/strategy/adapter/promotion/adapter.d.ts +66 -0
  133. package/lib/model/strategy/adapter/promotion/adapter.js +217 -0
  134. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +213 -0
  135. package/lib/model/strategy/adapter/promotion/evaluator.js +844 -0
  136. package/lib/model/strategy/adapter/promotion/examples.d.ts +138 -0
  137. package/lib/model/strategy/adapter/promotion/examples.js +192 -0
  138. package/lib/model/strategy/adapter/promotion/index.d.ts +4 -0
  139. package/lib/model/strategy/adapter/promotion/index.js +0 -0
  140. package/lib/model/strategy/adapter/promotion/type.d.ts +447 -0
  141. package/lib/model/strategy/adapter/promotion/type.js +51 -0
  142. package/lib/model/strategy/adapter/type.d.ts +28 -0
  143. package/lib/model/strategy/adapter/type.js +17 -0
  144. package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +84 -0
  145. package/lib/model/strategy/adapter/walletPass/evaluator.js +424 -0
  146. package/lib/model/strategy/adapter/walletPass/example.d.ts +4 -0
  147. package/lib/model/strategy/adapter/walletPass/example.js +207 -0
  148. package/lib/model/strategy/adapter/walletPass/index.d.ts +32 -0
  149. package/lib/model/strategy/adapter/walletPass/index.js +142 -0
  150. package/lib/model/strategy/adapter/walletPass/locales.d.ts +1 -0
  151. package/lib/model/strategy/adapter/walletPass/locales.js +54 -0
  152. package/lib/model/strategy/adapter/walletPass/type.d.ts +187 -0
  153. package/lib/model/strategy/adapter/walletPass/type.js +17 -0
  154. package/lib/model/strategy/adapter/walletPass/utils.d.ts +50 -0
  155. package/lib/model/strategy/adapter/walletPass/utils.js +791 -0
  156. package/lib/model/strategy/engine.d.ts +106 -0
  157. package/lib/model/strategy/engine.js +450 -0
  158. package/lib/model/strategy/index.d.ts +3 -0
  159. package/lib/model/strategy/index.js +38 -0
  160. package/lib/model/strategy/strategy-example.d.ts +5 -0
  161. package/lib/model/strategy/strategy-example.js +318 -0
  162. package/lib/model/strategy/type.d.ts +228 -0
  163. package/lib/model/strategy/type.js +44 -0
  164. package/lib/modules/Cart/utils/cartProduct.js +1 -0
  165. package/lib/modules/OpenData/index.d.ts +23 -0
  166. package/lib/modules/OpenData/index.js +116 -0
  167. package/lib/modules/OpenData/types.d.ts +73 -0
  168. package/lib/modules/OpenData/types.js +17 -0
  169. package/lib/modules/OpenData/utils.d.ts +2 -0
  170. package/lib/modules/OpenData/utils.js +111 -0
  171. package/lib/modules/Order/index.d.ts +58 -1
  172. package/lib/modules/Order/index.js +423 -1
  173. package/lib/modules/Order/types.d.ts +144 -12
  174. package/lib/modules/Order/utils.d.ts +25 -0
  175. package/lib/modules/Order/utils.js +229 -0
  176. package/lib/modules/Product/index.d.ts +1 -1
  177. package/lib/modules/Product/utils.js +2 -2
  178. package/lib/modules/ProductList/index.d.ts +1 -1
  179. package/lib/modules/ProductList/index.js +2 -1
  180. package/lib/modules/Quotation/index.d.ts +48 -0
  181. package/lib/modules/Quotation/index.js +149 -0
  182. package/lib/modules/Quotation/types.d.ts +42 -0
  183. package/lib/modules/Quotation/types.js +17 -0
  184. package/lib/modules/Rules/index.js +4 -1
  185. package/lib/modules/SalesSummary/index.d.ts +63 -0
  186. package/lib/modules/SalesSummary/index.js +105 -0
  187. package/lib/modules/SalesSummary/types.d.ts +59 -0
  188. package/lib/modules/SalesSummary/types.js +17 -0
  189. package/lib/modules/SalesSummary/utils.d.ts +30 -0
  190. package/lib/modules/SalesSummary/utils.js +452 -0
  191. package/lib/modules/ScanOrderLogger/index.d.ts +21 -0
  192. package/lib/modules/ScanOrderLogger/index.js +135 -0
  193. package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
  194. package/lib/modules/ScanOrderLogger/providers/feishu.js +82 -0
  195. package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
  196. package/lib/modules/ScanOrderLogger/providers/grafana.js +52 -0
  197. package/lib/modules/ScanOrderLogger/types.d.ts +46 -0
  198. package/lib/modules/ScanOrderLogger/types.js +17 -0
  199. package/lib/modules/Schedule/getDateIsInSchedule.js +9 -11
  200. package/lib/modules/Summary/utils.d.ts +3 -3
  201. package/lib/modules/Summary/utils.js +4 -4
  202. package/lib/modules/index.d.ts +4 -0
  203. package/lib/modules/index.js +9 -1
  204. package/lib/solution/BookingByStep/index.d.ts +1 -1
  205. package/lib/solution/BookingByStep/types.d.ts +3 -1
  206. package/lib/solution/BookingByStep/types.js +10 -0
  207. package/lib/solution/BookingTicket/index.d.ts +1 -1
  208. package/lib/solution/ScanOrder/index.d.ts +90 -0
  209. package/lib/solution/ScanOrder/index.js +1071 -0
  210. package/lib/solution/ScanOrder/types.d.ts +210 -0
  211. package/lib/solution/ScanOrder/types.js +36 -0
  212. package/lib/solution/ScanOrder/utils.d.ts +93 -0
  213. package/lib/solution/ScanOrder/utils.js +359 -0
  214. package/lib/solution/VenueBooking/index.d.ts +158 -0
  215. package/lib/solution/VenueBooking/index.js +1545 -0
  216. package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
  217. package/lib/solution/VenueBooking/types.d.ts +130 -0
  218. package/lib/solution/VenueBooking/types.js +44 -0
  219. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +10 -0
  220. package/lib/solution/VenueBooking/utils/dateSummary.js +101 -0
  221. package/lib/solution/VenueBooking/utils/resource.d.ts +4 -0
  222. package/lib/solution/VenueBooking/utils/resource.js +80 -0
  223. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +29 -0
  224. package/lib/solution/VenueBooking/utils/slotMerge.js +209 -0
  225. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
  226. package/lib/solution/VenueBooking/utils/timeSlot.js +200 -0
  227. package/lib/solution/VenueBooking/utils.d.ts +1 -0
  228. package/lib/solution/VenueBooking/utils.js +69 -0
  229. package/lib/solution/index.d.ts +2 -0
  230. package/lib/solution/index.js +5 -1
  231. package/package.json +1 -1
@@ -0,0 +1,2873 @@
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 { QuotationModule } from "../../modules/Quotation";
39
+ import { OpenDataModule } from "../../modules/OpenData";
40
+ import { AccountHooks } from "../../modules/Account/types";
41
+ import dayjs from 'dayjs';
42
+ import { ItemRuleEvaluator } from "../../model/strategy/adapter/itemRule";
43
+ import { extractResourceIds, buildResourceProductMap } from "./utils/resource";
44
+ import { buildTimeSlotGrid, isBusinessHoursCrossDay, generateTimeLabels } from "./utils/timeSlot";
45
+ import { buildDateRangeSummary } from "./utils/dateSummary";
46
+ import { mergeConsecutiveSlots, expandMergedSlotToIndividual, buildVenueIdentityKey, buildVenueBookingEntry, buildPriceBreakdown } from "./utils/slotMerge";
47
+ import { createUuidV4 } from "../../modules/Order/utils";
48
+ import { OrderModule } from "../../modules/Order";
49
+ import { RegisterAndLoginHooks } from "../RegisterAndLogin/types";
50
+ import Decimal from 'decimal.js';
51
+ export * from "./types";
52
+ var OPEN_DATA_SECTION_CODES = ['basic', 'fulfillment', 'reservation', 'sale', 'menu', 'availability', 'workflow', 'checkout'];
53
+ function cloneCustomDepositData(customDepositData) {
54
+ if (!customDepositData || _typeof(customDepositData) !== 'object') return undefined;
55
+ return _objectSpread(_objectSpread({}, customDepositData), {}, {
56
+ self_deposit_policy_ids: Array.isArray(customDepositData.self_deposit_policy_ids) ? _toConsumableArray(customDepositData.self_deposit_policy_ids) : [],
57
+ deposit_policy_ids: Array.isArray(customDepositData.deposit_policy_ids) ? _toConsumableArray(customDepositData.deposit_policy_ids) : [],
58
+ deposit_policy_data: Array.isArray(customDepositData.deposit_policy_data) ? _toConsumableArray(customDepositData.deposit_policy_data) : []
59
+ });
60
+ }
61
+ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
62
+ _inherits(VenueBookingImpl, _BaseModule);
63
+ var _super = _createSuper(VenueBookingImpl);
64
+ function VenueBookingImpl(name, version) {
65
+ var _this;
66
+ _classCallCheck(this, VenueBookingImpl);
67
+ _this = _super.call(this, name, version);
68
+ _defineProperty(_assertThisInitialized(_this), "defaultName", 'venueBooking');
69
+ _defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
70
+ _defineProperty(_assertThisInitialized(_this), "isSolution", true);
71
+ _defineProperty(_assertThisInitialized(_this), "initializeOptions", {});
72
+ _defineProperty(_assertThisInitialized(_this), "store", {
73
+ entryContext: null,
74
+ status: 'idle',
75
+ flow: {},
76
+ error: null,
77
+ products: undefined,
78
+ rawResourceData: [],
79
+ slotConfig: _objectSpread({}, DEFAULT_SLOT_CONFIG),
80
+ itemRuleQuantityLimits: [],
81
+ cartValidation: {
82
+ passed: null,
83
+ failures: []
84
+ }
85
+ });
86
+ _defineProperty(_assertThisInitialized(_this), "otherParams", {});
87
+ _defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
88
+ _defineProperty(_assertThisInitialized(_this), "window", void 0);
89
+ _defineProperty(_assertThisInitialized(_this), "request", void 0);
90
+ _defineProperty(_assertThisInitialized(_this), "itemRuleEvaluator", new ItemRuleEvaluator());
91
+ _defineProperty(_assertThisInitialized(_this), "itemRuleConfigs", []);
92
+ _defineProperty(_assertThisInitialized(_this), "itemRuleConfigsPromise", null);
93
+ _defineProperty(_assertThisInitialized(_this), "itemRulePrefillApplied", false);
94
+ _defineProperty(_assertThisInitialized(_this), "itemRuleRuntimeConfig", {});
95
+ _defineProperty(_assertThisInitialized(_this), "resourceProductMap", new Map());
96
+ _defineProperty(_assertThisInitialized(_this), "loginEffectDisposers", []);
97
+ _defineProperty(_assertThisInitialized(_this), "customerLoginRefreshInFlight", null);
98
+ _defineProperty(_assertThisInitialized(_this), "customerLoginRefreshIdInFlight", null);
99
+ return _this;
100
+ }
101
+ _createClass(VenueBookingImpl, [{
102
+ key: "getLoggerContext",
103
+ value: function getLoggerContext() {
104
+ return {
105
+ cacheId: this.cacheId,
106
+ solutionName: this.name,
107
+ moduleName: 'venueBooking'
108
+ };
109
+ }
110
+ }, {
111
+ key: "serializeError",
112
+ value: function serializeError(error) {
113
+ if (error instanceof Error) {
114
+ return {
115
+ name: error.name,
116
+ message: error.message,
117
+ stack: error.stack
118
+ };
119
+ }
120
+ return {
121
+ message: String(error)
122
+ };
123
+ }
124
+ }, {
125
+ key: "addVenueBookingLog",
126
+ value: function () {
127
+ var _addVenueBookingLog = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
128
+ var payload, extra, logger;
129
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
130
+ while (1) switch (_context.prev = _context.next) {
131
+ case 0:
132
+ payload = _objectSpread({
133
+ cacheId: this.cacheId
134
+ }, params.payload || {});
135
+ extra = _objectSpread({}, params.extra || {});
136
+ logger = this.store.scanOrderLogger;
137
+ if (logger) {
138
+ _context.next = 6;
139
+ break;
140
+ }
141
+ if ((params.level || 'info') === 'error') {
142
+ console.error('[VenueBooking][log-fallback]', params.title, {
143
+ payload: payload,
144
+ extra: extra
145
+ });
146
+ } else {
147
+ console.log('[VenueBooking][log-fallback]', params.title, {
148
+ payload: payload,
149
+ extra: extra
150
+ });
151
+ }
152
+ return _context.abrupt("return");
153
+ case 6:
154
+ _context.next = 8;
155
+ return logger.addLog(_objectSpread(_objectSpread({}, params), {}, {
156
+ payload: payload,
157
+ extra: extra
158
+ }));
159
+ case 8:
160
+ case "end":
161
+ return _context.stop();
162
+ }
163
+ }, _callee, this);
164
+ }));
165
+ function addVenueBookingLog(_x) {
166
+ return _addVenueBookingLog.apply(this, arguments);
167
+ }
168
+ return addVenueBookingLog;
169
+ }()
170
+ }, {
171
+ key: "logMethodStart",
172
+ value: function logMethodStart(method) {
173
+ var payload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
174
+ void this.addVenueBookingLog({
175
+ level: 'info',
176
+ title: "[VenueBooking] ".concat(method, " start"),
177
+ payload: _objectSpread({
178
+ method: method
179
+ }, payload)
180
+ });
181
+ }
182
+ }, {
183
+ key: "logMethodSuccess",
184
+ value: function logMethodSuccess(method) {
185
+ var payload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
186
+ void this.addVenueBookingLog({
187
+ level: 'info',
188
+ title: "[VenueBooking] ".concat(method, " success"),
189
+ payload: _objectSpread({
190
+ method: method
191
+ }, payload)
192
+ });
193
+ }
194
+ }, {
195
+ key: "logMethodError",
196
+ value: function logMethodError(method, error) {
197
+ var payload = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
198
+ void this.addVenueBookingLog({
199
+ level: 'error',
200
+ title: "[VenueBooking] ".concat(method, " failed"),
201
+ payload: _objectSpread(_objectSpread({
202
+ method: method
203
+ }, payload), {}, {
204
+ error: this.serializeError(error)
205
+ })
206
+ });
207
+ }
208
+ }, {
209
+ key: "addLog",
210
+ value: function () {
211
+ var _addLog = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
212
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
213
+ while (1) switch (_context2.prev = _context2.next) {
214
+ case 0:
215
+ _context2.next = 2;
216
+ return this.addVenueBookingLog(_objectSpread(_objectSpread({}, params), {}, {
217
+ payload: _objectSpread({
218
+ source: 'ui-bridge'
219
+ }, params.payload || {})
220
+ }));
221
+ case 2:
222
+ case "end":
223
+ return _context2.stop();
224
+ }
225
+ }, _callee2, this);
226
+ }));
227
+ function addLog(_x2) {
228
+ return _addLog.apply(this, arguments);
229
+ }
230
+ return addLog;
231
+ }()
232
+ }, {
233
+ key: "normalizeCustomerId",
234
+ value: function normalizeCustomerId(value) {
235
+ var customerId = Number(value);
236
+ if (!Number.isFinite(customerId) || customerId <= 0) return null;
237
+ return customerId;
238
+ }
239
+ }, {
240
+ key: "resolveCustomerIdFromLoginPayload",
241
+ value: function resolveCustomerIdFromLoginPayload(payload) {
242
+ var _payload$user, _payload$user2, _payload$user3, _payload$user4, _payload$account, _payload$account2, _payload$account3, _payload$_origin;
243
+ 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];
244
+ for (var _i = 0, _candidates = candidates; _i < _candidates.length; _i++) {
245
+ var candidate = _candidates[_i];
246
+ var customerId = this.normalizeCustomerId(candidate);
247
+ if (customerId) return customerId;
248
+ }
249
+ return null;
250
+ }
251
+ }, {
252
+ key: "clearLoginEffectListeners",
253
+ value: function clearLoginEffectListeners() {
254
+ var _iterator = _createForOfIteratorHelper(this.loginEffectDisposers),
255
+ _step;
256
+ try {
257
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
258
+ var dispose = _step.value;
259
+ dispose();
260
+ }
261
+ } catch (err) {
262
+ _iterator.e(err);
263
+ } finally {
264
+ _iterator.f();
265
+ }
266
+ this.loginEffectDisposers = [];
267
+ }
268
+ }, {
269
+ key: "registerLoginEffect",
270
+ value: function registerLoginEffect(event, callback) {
271
+ var _this$core;
272
+ var effects = (_this$core = this.core) === null || _this$core === void 0 ? void 0 : _this$core.effects;
273
+ if (!(effects !== null && effects !== void 0 && effects.on)) return;
274
+ effects.on(event, callback);
275
+ this.loginEffectDisposers.push(function () {
276
+ if (typeof effects.off === 'function') {
277
+ effects.off(event, callback);
278
+ }
279
+ });
280
+ }
281
+ }, {
282
+ key: "registerCustomerLoginListeners",
283
+ value: function registerCustomerLoginListeners() {
284
+ var _this$core2,
285
+ _this$core3,
286
+ _accountModule$getCur,
287
+ _accountModule$getAcc,
288
+ _this2 = this;
289
+ this.clearLoginEffectListeners();
290
+ var accountModule = (_this$core2 = this.core) === null || _this$core2 === void 0 ? void 0 : _this$core2.getModule('account');
291
+ var registerAndLoginModule = (_this$core3 = this.core) === null || _this$core3 === void 0 ? void 0 : _this$core3.getModule('registerAndLogin');
292
+ 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;
293
+ var createHandleLogin = function createHandleLogin(eventName) {
294
+ return /*#__PURE__*/function () {
295
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(payload) {
296
+ var customerId;
297
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
298
+ while (1) switch (_context3.prev = _context3.next) {
299
+ case 0:
300
+ customerId = _this2.resolveCustomerIdFromLoginPayload(payload);
301
+ if (customerId) {
302
+ _context3.next = 3;
303
+ break;
304
+ }
305
+ return _context3.abrupt("return");
306
+ case 3:
307
+ _context3.next = 5;
308
+ return _this2.refreshOrderMarketingAfterLogin({
309
+ customerId: customerId
310
+ });
311
+ case 5:
312
+ case "end":
313
+ return _context3.stop();
314
+ }
315
+ }, _callee3);
316
+ }));
317
+ return function (_x3) {
318
+ return _ref.apply(this, arguments);
319
+ };
320
+ }();
321
+ };
322
+ this.registerLoginEffect(AccountHooks.OnLogin, createHandleLogin(AccountHooks.OnLogin));
323
+ this.registerLoginEffect(RegisterAndLoginHooks.onLoginSuccess, createHandleLogin(RegisterAndLoginHooks.onLoginSuccess));
324
+ }
325
+ }, {
326
+ key: "refreshOrderMarketingAfterLogin",
327
+ value: function () {
328
+ var _refreshOrderMarketingAfterLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(params) {
329
+ var _this3 = this;
330
+ var refreshTask;
331
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
332
+ while (1) switch (_context5.prev = _context5.next) {
333
+ case 0:
334
+ if (this.store.order) {
335
+ _context5.next = 2;
336
+ break;
337
+ }
338
+ throw new Error('order 模块未初始化');
339
+ case 2:
340
+ if (!this.customerLoginRefreshInFlight) {
341
+ _context5.next = 9;
342
+ break;
343
+ }
344
+ if (!(this.customerLoginRefreshIdInFlight === params.customerId)) {
345
+ _context5.next = 7;
346
+ break;
347
+ }
348
+ _context5.next = 6;
349
+ return this.customerLoginRefreshInFlight;
350
+ case 6:
351
+ return _context5.abrupt("return");
352
+ case 7:
353
+ _context5.next = 9;
354
+ return this.customerLoginRefreshInFlight;
355
+ case 9:
356
+ this.customerLoginRefreshIdInFlight = params.customerId;
357
+ refreshTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
358
+ var _this3$otherParams;
359
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
360
+ while (1) switch (_context4.prev = _context4.next) {
361
+ case 0:
362
+ if (!_this3.store.quotation) {
363
+ _context4.next = 3;
364
+ break;
365
+ }
366
+ _context4.next = 3;
367
+ return _this3.store.quotation.loadQuotations({
368
+ channel: (_this3$otherParams = _this3.otherParams) === null || _this3$otherParams === void 0 ? void 0 : _this3$otherParams.channel
369
+ });
370
+ case 3:
371
+ _this3.recalculateOrderPricesFromQuotation();
372
+ _context4.next = 6;
373
+ return _this3.store.order.loadDiscountConfig({
374
+ customerId: params.customerId
375
+ });
376
+ case 6:
377
+ _context4.next = 8;
378
+ return _this3.store.order.recalculateSummary({
379
+ createIfMissing: true
380
+ });
381
+ case 8:
382
+ _this3.store.order.persistTempOrder();
383
+ _context4.next = 11;
384
+ return _this3.refreshItemRuleQuantityLimits();
385
+ case 11:
386
+ _context4.next = 13;
387
+ return _this3.refreshCartValidationPassed();
388
+ case 13:
389
+ case "end":
390
+ return _context4.stop();
391
+ }
392
+ }, _callee4);
393
+ }))();
394
+ this.customerLoginRefreshInFlight = refreshTask;
395
+ _context5.prev = 12;
396
+ _context5.next = 15;
397
+ return refreshTask;
398
+ case 15:
399
+ _context5.next = 20;
400
+ break;
401
+ case 17:
402
+ _context5.prev = 17;
403
+ _context5.t0 = _context5["catch"](12);
404
+ throw _context5.t0;
405
+ case 20:
406
+ _context5.prev = 20;
407
+ if (this.customerLoginRefreshInFlight === refreshTask) {
408
+ this.customerLoginRefreshInFlight = null;
409
+ this.customerLoginRefreshIdInFlight = null;
410
+ }
411
+ return _context5.finish(20);
412
+ case 23:
413
+ case "end":
414
+ return _context5.stop();
415
+ }
416
+ }, _callee5, this, [[12, 17, 20, 23]]);
417
+ }));
418
+ function refreshOrderMarketingAfterLogin(_x4) {
419
+ return _refreshOrderMarketingAfterLogin.apply(this, arguments);
420
+ }
421
+ return refreshOrderMarketingAfterLogin;
422
+ }()
423
+ }, {
424
+ key: "initialize",
425
+ value: function () {
426
+ var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(core) {
427
+ var _options$otherParams,
428
+ _options$otherParams2,
429
+ _this$otherParams,
430
+ _this$otherParams2,
431
+ _this$otherParams3,
432
+ _this4 = this,
433
+ _this$otherParams4,
434
+ _this$otherParams5;
435
+ var options,
436
+ baseModules,
437
+ venueProductsModule,
438
+ addonProductsModule,
439
+ dateModule,
440
+ scheduleModule,
441
+ quotationModule,
442
+ openDataModule,
443
+ _this$store$order,
444
+ _this$store$order2,
445
+ _args6 = arguments;
446
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
447
+ while (1) switch (_context6.prev = _context6.next) {
448
+ case 0:
449
+ options = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : {};
450
+ this.logMethodStart('initialize');
451
+ this.core = core;
452
+ this.initializeOptions = options || {};
453
+ this.store = _objectSpread(_objectSpread({}, this.store), options.store);
454
+ this.store.entryContext = ((_options$otherParams = options.otherParams) === null || _options$otherParams === void 0 ? void 0 : _options$otherParams.entryContext) || this.store.entryContext;
455
+ this.store.status = 'initializing';
456
+ this.store.error = null;
457
+ this.store.rawResourceData = [];
458
+ this.store.slotConfig = _objectSpread(_objectSpread({}, DEFAULT_SLOT_CONFIG), ((_options$otherParams2 = options.otherParams) === null || _options$otherParams2 === void 0 ? void 0 : _options$otherParams2.slotConfig) || {});
459
+ this.otherParams = options.otherParams || {};
460
+ this.cacheId = (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.cacheId;
461
+ 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) || {};
462
+ this.itemRuleConfigs = [];
463
+ this.itemRuleConfigsPromise = null;
464
+ this.itemRulePrefillApplied = false;
465
+ this.store.itemRuleQuantityLimits = [];
466
+ this.store.cartValidation = {
467
+ passed: null,
468
+ failures: []
469
+ };
470
+ this.window = core.getPlugin('window');
471
+ this.request = core.getPlugin('request');
472
+ if (this.window) {
473
+ _context6.next = 23;
474
+ break;
475
+ }
476
+ this.logMethodError('initialize', 'window plugin missing');
477
+ throw new Error('venueBooking解决方案需要 window 插件支持');
478
+ case 23:
479
+ if (this.request) {
480
+ _context6.next = 26;
481
+ break;
482
+ }
483
+ this.logMethodError('initialize', 'request plugin missing');
484
+ throw new Error('venueBooking解决方案需要 request 插件支持');
485
+ case 26:
486
+ // 注册基础模块(order, salesSummary, products, logger)
487
+ baseModules = ['scanOrderLogger', 'products', 'order', 'salesSummary'];
488
+ baseModules.forEach(function (step) {
489
+ var targetModule = createModule(step, _this4.name);
490
+ if (targetModule) {
491
+ var _this4$store$order, _this4$otherParams, _this4$otherParams2, _this4$otherParams3, _this4$otherParams4;
492
+ _this4.store[step] = targetModule;
493
+ var initialState = step === 'salesSummary' ? {
494
+ 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()
495
+ } : {};
496
+ var loggerProvider = ((_this4$otherParams = _this4.otherParams) === null || _this4$otherParams === void 0 ? void 0 : _this4$otherParams.loggerProvider) || 'feishu';
497
+ var loggerConfig = ((_this4$otherParams2 = _this4.otherParams) === null || _this4$otherParams2 === void 0 ? void 0 : _this4$otherParams2.loggerConfig) || {
498
+ feishu: {}
499
+ };
500
+ _this4.core.registerModule(targetModule, {
501
+ initialState: initialState,
502
+ otherParams: _objectSpread(_objectSpread({}, _this4.otherParams), {}, {
503
+ fatherModule: _this4.name,
504
+ openCache: (_this4$otherParams3 = _this4.otherParams) !== null && _this4$otherParams3 !== void 0 && _this4$otherParams3.cacheId ? true : false,
505
+ cacheId: (_this4$otherParams4 = _this4.otherParams) === null || _this4$otherParams4 === void 0 ? void 0 : _this4$otherParams4.cacheId,
506
+ salesSummaryModuleName: "".concat(_this4.name, "_salesSummary"),
507
+ provider: loggerProvider,
508
+ providerConfig: loggerConfig,
509
+ context: _this4.getLoggerContext()
510
+ })
511
+ });
512
+ } else {
513
+ _this4.logMethodError('initialize', "module ".concat(step, " missing"));
514
+ throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
515
+ }
516
+ });
517
+
518
+ // 注册场地商品列表模块
519
+ venueProductsModule = new ProductList("".concat(this.name, "_venueProducts"));
520
+ this.store.venueProducts = venueProductsModule;
521
+ this.core.registerModule(venueProductsModule, {
522
+ otherParams: _objectSpread(_objectSpread({}, this.otherParams), {}, {
523
+ fatherModule: this.name
524
+ })
525
+ });
526
+
527
+ // 注册附加商品列表模块
528
+ addonProductsModule = new ProductList("".concat(this.name, "_addonProducts"));
529
+ this.store.addonProducts = addonProductsModule;
530
+ this.core.registerModule(addonProductsModule, {
531
+ otherParams: _objectSpread(_objectSpread({}, this.otherParams), {}, {
532
+ fatherModule: this.name
533
+ })
534
+ });
535
+
536
+ // 注册日期模块
537
+ dateModule = new DateModule("".concat(this.name, "_date"));
538
+ this.store.date = dateModule;
539
+ this.core.registerModule(dateModule, {
540
+ otherParams: _objectSpread(_objectSpread({}, this.otherParams), {}, {
541
+ fatherModule: this.name,
542
+ cacheId: this.cacheId
543
+ })
544
+ });
545
+
546
+ // 注册日程模块
547
+ scheduleModule = new ScheduleModule("".concat(this.name, "_schedule"));
548
+ this.store.schedule = scheduleModule;
549
+ this.core.registerModule(scheduleModule, {
550
+ otherParams: _objectSpread(_objectSpread({}, this.otherParams), {}, {
551
+ fatherModule: this.name
552
+ })
553
+ });
554
+
555
+ // 注册报价单模块
556
+ quotationModule = new QuotationModule("".concat(this.name, "_quotation"));
557
+ this.store.quotation = quotationModule;
558
+ this.core.registerModule(quotationModule, {
559
+ otherParams: _objectSpread(_objectSpread({}, this.otherParams), {}, {
560
+ fatherModule: this.name
561
+ })
562
+ });
563
+
564
+ // 注册 OpenData 配置模块
565
+ openDataModule = new OpenDataModule("".concat(this.name, "_openData"));
566
+ this.store.openData = openDataModule;
567
+ this.core.registerModule(openDataModule, {
568
+ otherParams: _objectSpread(_objectSpread({}, this.otherParams), {}, {
569
+ fatherModule: this.name,
570
+ openCache: !!((_this$otherParams4 = this.otherParams) !== null && _this$otherParams4 !== void 0 && _this$otherParams4.cacheId),
571
+ cacheId: (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.cacheId
572
+ })
573
+ });
574
+ if (this.store.scanOrderLogger) {
575
+ this.store.scanOrderLogger.setContext(this.getLoggerContext());
576
+ }
577
+ this.registerCustomerLoginListeners();
578
+ console.log('[VenueBooking] 初始化开始');
579
+ _context6.prev = 49;
580
+ _context6.next = 52;
581
+ return (_this$store$order = this.store.order) === null || _this$store$order === void 0 ? void 0 : _this$store$order.recalculateSummary({
582
+ createIfMissing: false
583
+ });
584
+ case 52:
585
+ (_this$store$order2 = this.store.order) === null || _this$store$order2 === void 0 || _this$store$order2.persistTempOrder();
586
+ _context6.next = 55;
587
+ return this.loadRuntimeConfigs();
588
+ case 55:
589
+ if (!this.store.schedule) {
590
+ _context6.next = 59;
591
+ break;
592
+ }
593
+ _context6.next = 58;
594
+ return this.store.schedule.loadAllSchedule();
595
+ case 58:
596
+ this.injectScheduleResolverToQuotation();
597
+ case 59:
598
+ _context6.next = 61;
599
+ return this.refreshItemRuleQuantityLimits();
600
+ case 61:
601
+ this.store.status = 'ready';
602
+ console.log('[VenueBooking] 初始化完成');
603
+ _context6.next = 65;
604
+ return this.core.effects.emit(VenueBookingHooks.onInited, {
605
+ status: this.store.status
606
+ });
607
+ case 65:
608
+ this.logMethodSuccess('initialize', {
609
+ status: this.store.status
610
+ });
611
+ _context6.next = 75;
612
+ break;
613
+ case 68:
614
+ _context6.prev = 68;
615
+ _context6.t0 = _context6["catch"](49);
616
+ this.store.status = 'error';
617
+ this.store.error = _context6.t0 instanceof Error ? _context6.t0.message : '初始化失败';
618
+ console.error('[VenueBooking] 初始化失败', _context6.t0);
619
+ this.logMethodError('initialize', _context6.t0, {
620
+ status: this.store.status
621
+ });
622
+ throw _context6.t0;
623
+ case 75:
624
+ case "end":
625
+ return _context6.stop();
626
+ }
627
+ }, _callee6, this, [[49, 68]]);
628
+ }));
629
+ function initialize(_x5) {
630
+ return _initialize.apply(this, arguments);
631
+ }
632
+ return initialize;
633
+ }()
634
+ }, {
635
+ key: "destroy",
636
+ value: function () {
637
+ var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
638
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
639
+ while (1) switch (_context7.prev = _context7.next) {
640
+ case 0:
641
+ this.logMethodStart('destroy');
642
+ this.clearLoginEffectListeners();
643
+ _context7.next = 4;
644
+ return this.core.effects.emit(VenueBookingHooks.onDestroy, {});
645
+ case 4:
646
+ console.log('[VenueBooking] 已销毁');
647
+ this.logMethodSuccess('destroy');
648
+ case 6:
649
+ case "end":
650
+ return _context7.stop();
651
+ }
652
+ }, _callee7, this);
653
+ }));
654
+ function destroy() {
655
+ return _destroy.apply(this, arguments);
656
+ }
657
+ return destroy;
658
+ }()
659
+ }, {
660
+ key: "retryInit",
661
+ value: function () {
662
+ var _retryInit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
663
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
664
+ while (1) switch (_context8.prev = _context8.next) {
665
+ case 0:
666
+ this.logMethodStart('retryInit');
667
+ console.log('[VenueBooking] retryInit 调用');
668
+ _context8.next = 4;
669
+ return this.core.effects.emit(VenueBookingHooks.onRetryInit, {});
670
+ case 4:
671
+ _context8.prev = 4;
672
+ _context8.next = 7;
673
+ return this.initialize(this.core, this.initializeOptions);
674
+ case 7:
675
+ this.logMethodSuccess('retryInit');
676
+ _context8.next = 14;
677
+ break;
678
+ case 10:
679
+ _context8.prev = 10;
680
+ _context8.t0 = _context8["catch"](4);
681
+ this.logMethodError('retryInit', _context8.t0);
682
+ throw _context8.t0;
683
+ case 14:
684
+ case "end":
685
+ return _context8.stop();
686
+ }
687
+ }, _callee8, this, [[4, 10]]);
688
+ }));
689
+ function retryInit() {
690
+ return _retryInit.apply(this, arguments);
691
+ }
692
+ return retryInit;
693
+ }()
694
+ }, {
695
+ key: "refresh",
696
+ value: function () {
697
+ var _refresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
698
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
699
+ while (1) switch (_context9.prev = _context9.next) {
700
+ case 0:
701
+ this.logMethodStart('refresh');
702
+ console.log('[VenueBooking] refresh 调用');
703
+ _context9.prev = 2;
704
+ this.store.status = 'initializing';
705
+ _context9.next = 6;
706
+ return this.loadRuntimeConfigs();
707
+ case 6:
708
+ _context9.next = 8;
709
+ return this.refreshItemRuleQuantityLimits();
710
+ case 8:
711
+ this.store.status = 'ready';
712
+ _context9.next = 11;
713
+ return this.core.effects.emit(VenueBookingHooks.onRefresh, {
714
+ status: this.store.status
715
+ });
716
+ case 11:
717
+ this.logMethodSuccess('refresh', {
718
+ status: this.store.status
719
+ });
720
+ _context9.next = 18;
721
+ break;
722
+ case 14:
723
+ _context9.prev = 14;
724
+ _context9.t0 = _context9["catch"](2);
725
+ this.logMethodError('refresh', _context9.t0);
726
+ throw _context9.t0;
727
+ case 18:
728
+ case "end":
729
+ return _context9.stop();
730
+ }
731
+ }, _callee9, this, [[2, 14]]);
732
+ }));
733
+ function refresh() {
734
+ return _refresh.apply(this, arguments);
735
+ }
736
+ return refresh;
737
+ }() // ─── 状态查询 ───
738
+ }, {
739
+ key: "getStatus",
740
+ value: function getStatus() {
741
+ return this.store.status;
742
+ }
743
+ }, {
744
+ key: "getEntryContext",
745
+ value: function getEntryContext() {
746
+ return this.store.entryContext;
747
+ }
748
+ }, {
749
+ key: "getItemRuleQuantityLimits",
750
+ value: function getItemRuleQuantityLimits() {
751
+ return this.store.itemRuleQuantityLimits || [];
752
+ }
753
+ }, {
754
+ key: "getCartValidationPassed",
755
+ value: function getCartValidationPassed() {
756
+ var _this$store$cartValid, _this$store$cartValid2;
757
+ 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;
758
+ }
759
+ }, {
760
+ key: "getCartValidation",
761
+ value: function getCartValidation() {
762
+ return this.store.cartValidation || {
763
+ passed: null,
764
+ failures: []
765
+ };
766
+ }
767
+
768
+ // ─── 场地商品 & 附加商品 ───
769
+ }, {
770
+ key: "loadAllProducts",
771
+ value: function () {
772
+ var _loadAllProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
773
+ var _this$otherParams6, _this$store$venueProd, associatedMenus, menuListIds, allProducts, list, venueList, addonList, venueStore;
774
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
775
+ while (1) switch (_context10.prev = _context10.next) {
776
+ case 0:
777
+ this.logMethodStart('loadAllProducts');
778
+ _context10.prev = 1;
779
+ if (this.store.venueProducts) {
780
+ _context10.next = 4;
781
+ break;
782
+ }
783
+ throw new Error('venueProducts 模块未初始化');
784
+ case 4:
785
+ if (this.store.addonProducts) {
786
+ _context10.next = 6;
787
+ break;
788
+ }
789
+ throw new Error('addonProducts 模块未初始化');
790
+ case 6:
791
+ associatedMenus = ((_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 || (_this$otherParams6 = _this$otherParams6.openData) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6['menu.associated_menus']) || [];
792
+ if (associatedMenus.length) {
793
+ _context10.next = 9;
794
+ break;
795
+ }
796
+ throw new Error('未获取到餐牌配置(menu.associated_menus),请检查 OpenData 配置');
797
+ case 9:
798
+ menuListIds = associatedMenus.map(function (n) {
799
+ return Number(n.value);
800
+ });
801
+ _context10.next = 12;
802
+ return this.store.venueProducts.loadProducts({
803
+ menu_list_ids: menuListIds,
804
+ cacheId: this.cacheId,
805
+ schedule_date: dayjs().format('YYYY-MM-DD'),
806
+ schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
807
+ });
808
+ case 12:
809
+ allProducts = _context10.sent;
810
+ list = Array.isArray(allProducts) ? allProducts : [];
811
+ venueList = list.filter(function (p) {
812
+ return p.duration != null;
813
+ });
814
+ addonList = list.filter(function (p) {
815
+ return p.duration == null;
816
+ });
817
+ venueStore = (_this$store$venueProd = this.store.venueProducts) === null || _this$store$venueProd === void 0 ? void 0 : _this$store$venueProd.store;
818
+ if (venueStore) {
819
+ venueStore.list = venueList.slice().sort(function (a, b) {
820
+ return Number(b.sort) - Number(a.sort);
821
+ });
822
+ }
823
+ this.store.addonProducts.addProduct(addonList);
824
+ this.resourceProductMap = buildResourceProductMap(venueList);
825
+ this.logMethodSuccess('loadAllProducts', {
826
+ total: list.length,
827
+ venueCount: venueList.length,
828
+ addonCount: addonList.length,
829
+ resourceCount: this.resourceProductMap.size
830
+ });
831
+ return _context10.abrupt("return", {
832
+ venueProducts: venueList,
833
+ addonProducts: addonList
834
+ });
835
+ case 24:
836
+ _context10.prev = 24;
837
+ _context10.t0 = _context10["catch"](1);
838
+ this.logMethodError('loadAllProducts', _context10.t0);
839
+ throw _context10.t0;
840
+ case 28:
841
+ case "end":
842
+ return _context10.stop();
843
+ }
844
+ }, _callee10, this, [[1, 24]]);
845
+ }));
846
+ function loadAllProducts() {
847
+ return _loadAllProducts.apply(this, arguments);
848
+ }
849
+ return loadAllProducts;
850
+ }()
851
+ }, {
852
+ key: "loadVenueProducts",
853
+ value: function () {
854
+ var _loadVenueProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
855
+ var result;
856
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
857
+ while (1) switch (_context11.prev = _context11.next) {
858
+ case 0:
859
+ _context11.next = 2;
860
+ return this.loadAllProducts();
861
+ case 2:
862
+ result = _context11.sent;
863
+ return _context11.abrupt("return", result.venueProducts);
864
+ case 4:
865
+ case "end":
866
+ return _context11.stop();
867
+ }
868
+ }, _callee11, this);
869
+ }));
870
+ function loadVenueProducts() {
871
+ return _loadVenueProducts.apply(this, arguments);
872
+ }
873
+ return loadVenueProducts;
874
+ }()
875
+ }, {
876
+ key: "loadAddonProducts",
877
+ value: function () {
878
+ var _loadAddonProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
879
+ var result;
880
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
881
+ while (1) switch (_context12.prev = _context12.next) {
882
+ case 0:
883
+ _context12.next = 2;
884
+ return this.loadAllProducts();
885
+ case 2:
886
+ result = _context12.sent;
887
+ return _context12.abrupt("return", result.addonProducts);
888
+ case 4:
889
+ case "end":
890
+ return _context12.stop();
891
+ }
892
+ }, _callee12, this);
893
+ }));
894
+ function loadAddonProducts() {
895
+ return _loadAddonProducts.apply(this, arguments);
896
+ }
897
+ return loadAddonProducts;
898
+ }()
899
+ }, {
900
+ key: "getVenueProducts",
901
+ value: function getVenueProducts() {
902
+ var _this$store$venueProd2;
903
+ 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) || [];
904
+ }
905
+ }, {
906
+ key: "getAddonProductsList",
907
+ value: function getAddonProductsList() {
908
+ var _this$store$addonProd;
909
+ 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) || [];
910
+ }
911
+
912
+ // ─── 报价单 ───
913
+ }, {
914
+ key: "loadQuotations",
915
+ value: function () {
916
+ var _loadQuotations = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(params) {
917
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
918
+ while (1) switch (_context13.prev = _context13.next) {
919
+ case 0:
920
+ this.logMethodStart('loadQuotations');
921
+ _context13.prev = 1;
922
+ if (this.store.quotation) {
923
+ _context13.next = 4;
924
+ break;
925
+ }
926
+ throw new Error('quotation 模块未初始化');
927
+ case 4:
928
+ _context13.next = 6;
929
+ return this.store.quotation.loadQuotations(params);
930
+ case 6:
931
+ this.logMethodSuccess('loadQuotations', {
932
+ count: this.store.quotation.getQuotationList().length
933
+ });
934
+ _context13.next = 13;
935
+ break;
936
+ case 9:
937
+ _context13.prev = 9;
938
+ _context13.t0 = _context13["catch"](1);
939
+ this.logMethodError('loadQuotations', _context13.t0);
940
+ throw _context13.t0;
941
+ case 13:
942
+ case "end":
943
+ return _context13.stop();
944
+ }
945
+ }, _callee13, this, [[1, 9]]);
946
+ }));
947
+ function loadQuotations(_x6) {
948
+ return _loadQuotations.apply(this, arguments);
949
+ }
950
+ return loadQuotations;
951
+ }() // ─── 资源可用性 ───
952
+ }, {
953
+ key: "fetchResourceAvailability",
954
+ value: function () {
955
+ var _fetchResourceAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(params) {
956
+ var venueProducts, resourceIds, config, crossDay, effectiveEndDate, res, rawData, _iterator2, _step2, item, _i2, _rawData, _item, mapping;
957
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
958
+ while (1) switch (_context14.prev = _context14.next) {
959
+ case 0:
960
+ this.logMethodStart('fetchResourceAvailability', params);
961
+ _context14.prev = 1;
962
+ venueProducts = this.getVenueProducts();
963
+ if (venueProducts.length) {
964
+ _context14.next = 7;
965
+ break;
966
+ }
967
+ this.store.rawResourceData = [];
968
+ this.logMethodSuccess('fetchResourceAvailability', {
969
+ resourceCount: 0
970
+ });
971
+ return _context14.abrupt("return");
972
+ case 7:
973
+ resourceIds = extractResourceIds(venueProducts);
974
+ if (resourceIds.length) {
975
+ _context14.next = 12;
976
+ break;
977
+ }
978
+ this.store.rawResourceData = [];
979
+ this.logMethodSuccess('fetchResourceAvailability', {
980
+ resourceIds: []
981
+ });
982
+ return _context14.abrupt("return");
983
+ case 12:
984
+ // 跨天营业时,endDate 扩展一天以覆盖次日凌晨时段
985
+ config = this.store.slotConfig;
986
+ crossDay = isBusinessHoursCrossDay(config);
987
+ effectiveEndDate = crossDay ? dayjs(params.endDate).add(1, 'day').format('YYYY-MM-DD') : params.endDate;
988
+ if (this.store.date) {
989
+ _context14.next = 17;
990
+ break;
991
+ }
992
+ throw new Error('date 模块未初始化');
993
+ case 17:
994
+ _context14.next = 19;
995
+ return this.store.date.fetchResourceDates({
996
+ query: {
997
+ start_date: params.startDate,
998
+ end_date: effectiveEndDate,
999
+ resource_ids: resourceIds
1000
+ },
1001
+ useCache: false
1002
+ });
1003
+ case 19:
1004
+ res = _context14.sent;
1005
+ rawData = [];
1006
+ if (res !== null && res !== void 0 && res.data && Array.isArray(res.data)) {
1007
+ _iterator2 = _createForOfIteratorHelper(res.data);
1008
+ try {
1009
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
1010
+ item = _step2.value;
1011
+ rawData.push(_objectSpread({
1012
+ resourceId: item.id,
1013
+ formId: item.form_id,
1014
+ times: Array.isArray(item.times) ? item.times : []
1015
+ }, item));
1016
+ }
1017
+ } catch (err) {
1018
+ _iterator2.e(err);
1019
+ } finally {
1020
+ _iterator2.f();
1021
+ }
1022
+ }
1023
+ this.store.rawResourceData = rawData;
1024
+ for (_i2 = 0, _rawData = rawData; _i2 < _rawData.length; _i2++) {
1025
+ _item = _rawData[_i2];
1026
+ mapping = this.resourceProductMap.get(_item.resourceId);
1027
+ if (mapping && _item.main_field) {
1028
+ mapping.resourceName = _item.main_field;
1029
+ }
1030
+ if (mapping && _item.resource_form_id) {
1031
+ mapping.formId = _item.resource_form_id;
1032
+ }
1033
+ }
1034
+ this.logMethodSuccess('fetchResourceAvailability', {
1035
+ resourceCount: rawData.length,
1036
+ totalTimes: rawData.reduce(function (sum, r) {
1037
+ return sum + r.times.length;
1038
+ }, 0)
1039
+ });
1040
+ _context14.next = 32;
1041
+ break;
1042
+ case 27:
1043
+ _context14.prev = 27;
1044
+ _context14.t0 = _context14["catch"](1);
1045
+ this.store.rawResourceData = [];
1046
+ this.logMethodError('fetchResourceAvailability', _context14.t0);
1047
+ throw _context14.t0;
1048
+ case 32:
1049
+ case "end":
1050
+ return _context14.stop();
1051
+ }
1052
+ }, _callee14, this, [[1, 27]]);
1053
+ }));
1054
+ function fetchResourceAvailability(_x7) {
1055
+ return _fetchResourceAvailability.apply(this, arguments);
1056
+ }
1057
+ return fetchResourceAvailability;
1058
+ }() // ─── 日期概览 & 时间槽矩阵(纯计算,不发请求) ───
1059
+ }, {
1060
+ key: "getDateRangeSummary",
1061
+ value: function getDateRangeSummary(params) {
1062
+ return buildDateRangeSummary({
1063
+ startDate: params.startDate,
1064
+ endDate: params.endDate,
1065
+ config: this.store.slotConfig,
1066
+ rawResources: this.store.rawResourceData,
1067
+ resourceProductMap: this.resourceProductMap,
1068
+ quotationModule: this.store.quotation
1069
+ });
1070
+ }
1071
+ }, {
1072
+ key: "getTimeSlotGrid",
1073
+ value: function getTimeSlotGrid(date) {
1074
+ var quotationPriceMap;
1075
+ if (this.store.quotation) {
1076
+ var productIds = _toConsumableArray(new Set(_toConsumableArray(this.resourceProductMap.values()).map(function (m) {
1077
+ return m.productId;
1078
+ })));
1079
+ var timeLabels = generateTimeLabels(this.store.slotConfig);
1080
+ var timePoints = timeLabels.map(function (label) {
1081
+ return "".concat(date, " ").concat(label);
1082
+ });
1083
+ quotationPriceMap = this.store.quotation.buildProductPriceMap({
1084
+ productIds: productIds,
1085
+ timePoints: timePoints
1086
+ });
1087
+ }
1088
+ return buildTimeSlotGrid({
1089
+ date: date,
1090
+ config: this.store.slotConfig,
1091
+ rawResources: this.store.rawResourceData,
1092
+ resourceProductMap: this.resourceProductMap,
1093
+ quotationPriceMap: quotationPriceMap
1094
+ });
1095
+ }
1096
+
1097
+ // ─── 时间槽订单操作 ───
1098
+
1099
+ /**
1100
+ * 切换单个时段的选中状态(选中/取消)。
1101
+ * 内部自动处理连续时段的合并与拆分,订单是唯一真相源。
1102
+ */
1103
+ }, {
1104
+ key: "toggleSlot",
1105
+ value: function () {
1106
+ var _toggleSlot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(slot) {
1107
+ var mapping, currentSlots, existIndex, nextSlots, products;
1108
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1109
+ while (1) switch (_context15.prev = _context15.next) {
1110
+ case 0:
1111
+ this.logMethodStart('toggleSlot', {
1112
+ resourceId: slot.resourceId,
1113
+ startTime: slot.startTime
1114
+ });
1115
+ _context15.prev = 1;
1116
+ mapping = this.resourceProductMap.get(slot.resourceId);
1117
+ if (mapping) {
1118
+ _context15.next = 5;
1119
+ break;
1120
+ }
1121
+ throw new Error("\u672A\u627E\u5230\u8D44\u6E90 ".concat(slot.resourceId, " \u7684\u5546\u54C1\u6620\u5C04"));
1122
+ case 5:
1123
+ if (this.store.order) {
1124
+ _context15.next = 7;
1125
+ break;
1126
+ }
1127
+ throw new Error('order 模块未初始化');
1128
+ case 7:
1129
+ currentSlots = this.getSelectedSlotsForResource(slot.resourceId);
1130
+ existIndex = currentSlots.findIndex(function (s) {
1131
+ return s.startTime === slot.startTime;
1132
+ });
1133
+ if (existIndex !== -1) {
1134
+ nextSlots = currentSlots.filter(function (_, i) {
1135
+ return i !== existIndex;
1136
+ });
1137
+ } else {
1138
+ nextSlots = [].concat(_toConsumableArray(currentSlots), [slot]);
1139
+ }
1140
+ _context15.next = 12;
1141
+ return this.reconcileOrderForResource(slot.resourceId, nextSlots);
1142
+ case 12:
1143
+ products = this.store.order.getOrderProducts();
1144
+ _context15.next = 15;
1145
+ return this.refreshItemRuleQuantityLimits();
1146
+ case 15:
1147
+ _context15.next = 17;
1148
+ return this.refreshCartValidationPassed();
1149
+ case 17:
1150
+ this.logMethodSuccess('toggleSlot', {
1151
+ action: existIndex !== -1 ? 'remove' : 'add',
1152
+ resourceId: slot.resourceId,
1153
+ slotCount: nextSlots.length
1154
+ });
1155
+ return _context15.abrupt("return", products);
1156
+ case 21:
1157
+ _context15.prev = 21;
1158
+ _context15.t0 = _context15["catch"](1);
1159
+ this.logMethodError('toggleSlot', _context15.t0);
1160
+ throw _context15.t0;
1161
+ case 25:
1162
+ case "end":
1163
+ return _context15.stop();
1164
+ }
1165
+ }, _callee15, this, [[1, 21]]);
1166
+ }));
1167
+ function toggleSlot(_x8) {
1168
+ return _toggleSlot.apply(this, arguments);
1169
+ }
1170
+ return toggleSlot;
1171
+ }()
1172
+ /**
1173
+ * 获取某资源当前选中的所有独立时段(从订单中解析)。
1174
+ */
1175
+ }, {
1176
+ key: "getSelectedSlotsForResource",
1177
+ value: function getSelectedSlotsForResource(resourceId) {
1178
+ var _this$store$order3;
1179
+ var tempOrder = (_this$store$order3 = this.store.order) === null || _this$store$order3 === void 0 ? void 0 : _this$store$order3.getTempOrder();
1180
+ if (!tempOrder) return [];
1181
+ var venueProducts = tempOrder.products.filter(function (p) {
1182
+ var _p$metadata, _p$metadata2;
1183
+ return ((_p$metadata = p.metadata) === null || _p$metadata === void 0 ? void 0 : _p$metadata.venue_booking) && String((_p$metadata2 = p.metadata) === null || _p$metadata2 === void 0 ? void 0 : _p$metadata2.resource_id) === String(resourceId);
1184
+ });
1185
+ var slotDuration = this.store.slotConfig.slotDurationMinutes;
1186
+ var slots = [];
1187
+ var _iterator3 = _createForOfIteratorHelper(venueProducts),
1188
+ _step3;
1189
+ try {
1190
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
1191
+ var product = _step3.value;
1192
+ slots.push.apply(slots, _toConsumableArray(expandMergedSlotToIndividual(product, slotDuration)));
1193
+ }
1194
+ } catch (err) {
1195
+ _iterator3.e(err);
1196
+ } finally {
1197
+ _iterator3.f();
1198
+ }
1199
+ return slots.sort(function (a, b) {
1200
+ return a.startTime.localeCompare(b.startTime);
1201
+ });
1202
+ }
1203
+
1204
+ /**
1205
+ * 判断某个时段是否已选中。
1206
+ */
1207
+ }, {
1208
+ key: "isSlotSelected",
1209
+ value: function isSlotSelected(resourceId, startTime) {
1210
+ return this.getSelectedSlotsForResource(resourceId).some(function (s) {
1211
+ return s.startTime === startTime;
1212
+ });
1213
+ }
1214
+
1215
+ /**
1216
+ * 获取所有已选时段(按资源分组)。
1217
+ */
1218
+ }, {
1219
+ key: "getAllSelectedSlots",
1220
+ value: function getAllSelectedSlots() {
1221
+ var _this$store$order4;
1222
+ var result = new Map();
1223
+ var tempOrder = (_this$store$order4 = this.store.order) === null || _this$store$order4 === void 0 ? void 0 : _this$store$order4.getTempOrder();
1224
+ if (!tempOrder) return result;
1225
+ var venueProducts = tempOrder.products.filter(function (p) {
1226
+ var _p$metadata3;
1227
+ return (_p$metadata3 = p.metadata) === null || _p$metadata3 === void 0 ? void 0 : _p$metadata3.venue_booking;
1228
+ });
1229
+ var slotDuration = this.store.slotConfig.slotDurationMinutes;
1230
+ var _iterator4 = _createForOfIteratorHelper(venueProducts),
1231
+ _step4;
1232
+ try {
1233
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
1234
+ var _product$metadata;
1235
+ var product = _step4.value;
1236
+ var resourceId = (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.resource_id;
1237
+ if (resourceId == null) continue;
1238
+ var existing = result.get(resourceId) || [];
1239
+ existing.push.apply(existing, _toConsumableArray(expandMergedSlotToIndividual(product, slotDuration)));
1240
+ result.set(resourceId, existing);
1241
+ }
1242
+ } catch (err) {
1243
+ _iterator4.e(err);
1244
+ } finally {
1245
+ _iterator4.f();
1246
+ }
1247
+ var _iterator5 = _createForOfIteratorHelper(result),
1248
+ _step5;
1249
+ try {
1250
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
1251
+ var _step5$value = _slicedToArray(_step5.value, 2),
1252
+ key = _step5$value[0],
1253
+ slots = _step5$value[1];
1254
+ result.set(key, slots.sort(function (a, b) {
1255
+ return a.startTime.localeCompare(b.startTime);
1256
+ }));
1257
+ }
1258
+ } catch (err) {
1259
+ _iterator5.e(err);
1260
+ } finally {
1261
+ _iterator5.f();
1262
+ }
1263
+ return result;
1264
+ }
1265
+
1266
+ /**
1267
+ * 对指定资源的订单商品进行 reconcile:
1268
+ * 清除旧商品 → 合并连续时段 → 重新写入。
1269
+ */
1270
+ }, {
1271
+ key: "reconcileOrderForResource",
1272
+ value: (function () {
1273
+ var _reconcileOrderForResource = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(resourceId, slots) {
1274
+ var mapping, tempOrder, merged, rawResource, venueProduct, i, _venueProduct$is_char, _rawResource$form_id, group, identityKey, bookingUuid, startMoment, endMoment, duration, customDepositData, booking;
1275
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1276
+ while (1) switch (_context16.prev = _context16.next) {
1277
+ case 0:
1278
+ mapping = this.resourceProductMap.get(resourceId);
1279
+ if (!(!mapping || !this.store.order)) {
1280
+ _context16.next = 3;
1281
+ break;
1282
+ }
1283
+ return _context16.abrupt("return");
1284
+ case 3:
1285
+ tempOrder = this.store.order.ensureTempOrder();
1286
+ tempOrder.products = tempOrder.products.filter(function (p) {
1287
+ var _p$metadata4, _p$metadata5;
1288
+ return !((_p$metadata4 = p.metadata) !== null && _p$metadata4 !== void 0 && _p$metadata4.venue_booking && String((_p$metadata5 = p.metadata) === null || _p$metadata5 === void 0 ? void 0 : _p$metadata5.resource_id) === String(resourceId));
1289
+ });
1290
+ tempOrder.bookings = (tempOrder.bookings || []).filter(function (b) {
1291
+ var _b$metadata, _b$metadata2;
1292
+ return !((_b$metadata = b.metadata) !== null && _b$metadata !== void 0 && _b$metadata.venue_booking && String((_b$metadata2 = b.metadata) === null || _b$metadata2 === void 0 ? void 0 : _b$metadata2.resource_id) === String(resourceId));
1293
+ });
1294
+ if (slots.length) {
1295
+ _context16.next = 12;
1296
+ break;
1297
+ }
1298
+ this.store.order.applyDiscount();
1299
+ _context16.next = 10;
1300
+ return this.store.order.recalculateSummary({
1301
+ createIfMissing: true
1302
+ });
1303
+ case 10:
1304
+ this.store.order.persistTempOrder();
1305
+ return _context16.abrupt("return");
1306
+ case 12:
1307
+ merged = mergeConsecutiveSlots(slots);
1308
+ rawResource = this.store.rawResourceData.find(function (r) {
1309
+ return String(r.resourceId) === String(resourceId);
1310
+ });
1311
+ venueProduct = this.getVenueProducts().find(function (p) {
1312
+ return p.id === mapping.productId;
1313
+ });
1314
+ tempOrder.bookings = tempOrder.bookings || [];
1315
+ for (i = 0; i < merged.length; i++) {
1316
+ group = merged[i];
1317
+ identityKey = buildVenueIdentityKey(resourceId, i);
1318
+ bookingUuid = createUuidV4();
1319
+ startMoment = dayjs(group.startTime, 'YYYY-MM-DD HH:mm');
1320
+ endMoment = dayjs(group.endTime, 'YYYY-MM-DD HH:mm');
1321
+ duration = endMoment.diff(startMoment, 'minute');
1322
+ customDepositData = cloneCustomDepositData(venueProduct === null || venueProduct === void 0 ? void 0 : venueProduct.custom_deposit_data);
1323
+ tempOrder.products.push(normalizeOrderProduct({
1324
+ product_id: mapping.productId,
1325
+ product_variant_id: 0,
1326
+ identity_key: identityKey,
1327
+ num: 1,
1328
+ selling_price: group.totalPrice,
1329
+ original_price: group.totalPrice,
1330
+ payment_price: group.totalPrice,
1331
+ 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,
1332
+ metadata: {
1333
+ venue_booking: true,
1334
+ resource_id: resourceId,
1335
+ resource_form_id: mapping.formId,
1336
+ resource_name: mapping.resourceName,
1337
+ start_time: group.startTime,
1338
+ end_time: group.endTime,
1339
+ slot_count: group.slotCount,
1340
+ booking_uid: bookingUuid,
1341
+ price_breakdown: buildPriceBreakdown({
1342
+ group: group,
1343
+ productId: mapping.productId,
1344
+ quotation: this.store.quotation
1345
+ })
1346
+ },
1347
+ _origin: {
1348
+ name: mapping.productTitle,
1349
+ cover: (venueProduct === null || venueProduct === void 0 ? void 0 : venueProduct.cover) || '',
1350
+ custom_deposit_data: customDepositData,
1351
+ id: 0,
1352
+ number: 1,
1353
+ registration_type: 'all',
1354
+ relation_products: [],
1355
+ is_all: false,
1356
+ product: {
1357
+ product_id: mapping.productId,
1358
+ product_variant_id: 0,
1359
+ num: 1,
1360
+ product_bundle: [],
1361
+ product_option_item: [],
1362
+ discount_list: [],
1363
+ custom_deposit_data: customDepositData,
1364
+ metadata: {}
1365
+ },
1366
+ sub_type: 'minutes',
1367
+ duration: duration,
1368
+ like_status: 'common',
1369
+ resources: [{
1370
+ relation_type: 'form',
1371
+ like_status: 'common',
1372
+ id: resourceId,
1373
+ main_field: mapping.resourceName,
1374
+ 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,
1375
+ relation_id: resourceId,
1376
+ capacity: 1,
1377
+ metadata: {}
1378
+ }],
1379
+ schedule_id: 0,
1380
+ select_date: startMoment.format('YYYY-MM-DD'),
1381
+ start_date: startMoment.format('YYYY-MM-DD'),
1382
+ start_time: startMoment.format('HH:mm'),
1383
+ end_date: endMoment.format('YYYY-MM-DD'),
1384
+ end_time: endMoment.format('HH:mm'),
1385
+ metadata: {
1386
+ venue_booking: true,
1387
+ slot_count: group.slotCount
1388
+ },
1389
+ holder: null
1390
+ }
1391
+ }));
1392
+ booking = buildVenueBookingEntry({
1393
+ group: group,
1394
+ resourceId: resourceId,
1395
+ mapping: mapping,
1396
+ rawResource: rawResource,
1397
+ bookingUuid: bookingUuid,
1398
+ productUid: identityKey
1399
+ });
1400
+ tempOrder.bookings.push(booking);
1401
+ }
1402
+ this.store.order.applyDiscount();
1403
+ _context16.next = 20;
1404
+ return this.store.order.recalculateSummary({
1405
+ createIfMissing: true
1406
+ });
1407
+ case 20:
1408
+ this.store.order.persistTempOrder();
1409
+ case 21:
1410
+ case "end":
1411
+ return _context16.stop();
1412
+ }
1413
+ }, _callee16, this);
1414
+ }));
1415
+ function reconcileOrderForResource(_x9, _x10) {
1416
+ return _reconcileOrderForResource.apply(this, arguments);
1417
+ }
1418
+ return reconcileOrderForResource;
1419
+ }() // ─── 配置 ───
1420
+ )
1421
+ }, {
1422
+ key: "setSlotConfig",
1423
+ value: function setSlotConfig(config) {
1424
+ this.store.slotConfig = _objectSpread(_objectSpread({}, this.store.slotConfig), config);
1425
+ }
1426
+ }, {
1427
+ key: "getSlotConfig",
1428
+ value: function getSlotConfig() {
1429
+ return _objectSpread({}, this.store.slotConfig);
1430
+ }
1431
+
1432
+ // ─── 日程 ───
1433
+ }, {
1434
+ key: "loadSchedules",
1435
+ value: function () {
1436
+ var _loadSchedules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1437
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1438
+ while (1) switch (_context17.prev = _context17.next) {
1439
+ case 0:
1440
+ this.logMethodStart('loadSchedules');
1441
+ _context17.prev = 1;
1442
+ if (this.store.schedule) {
1443
+ _context17.next = 4;
1444
+ break;
1445
+ }
1446
+ throw new Error('schedule 模块未初始化');
1447
+ case 4:
1448
+ _context17.next = 6;
1449
+ return this.store.schedule.loadAllSchedule();
1450
+ case 6:
1451
+ this.injectScheduleResolverToQuotation();
1452
+ this.logMethodSuccess('loadSchedules');
1453
+ _context17.next = 14;
1454
+ break;
1455
+ case 10:
1456
+ _context17.prev = 10;
1457
+ _context17.t0 = _context17["catch"](1);
1458
+ this.logMethodError('loadSchedules', _context17.t0);
1459
+ throw _context17.t0;
1460
+ case 14:
1461
+ case "end":
1462
+ return _context17.stop();
1463
+ }
1464
+ }, _callee17, this, [[1, 10]]);
1465
+ }));
1466
+ function loadSchedules() {
1467
+ return _loadSchedules.apply(this, arguments);
1468
+ }
1469
+ return loadSchedules;
1470
+ }()
1471
+ }, {
1472
+ key: "injectScheduleResolverToQuotation",
1473
+ value: function injectScheduleResolverToQuotation() {
1474
+ var _this5 = this;
1475
+ if (this.store.quotation && this.store.schedule) {
1476
+ this.store.quotation.setScheduleResolver(function (id) {
1477
+ return _this5.store.schedule.getScheduleListByIds([id])[0];
1478
+ });
1479
+ }
1480
+ }
1481
+ }, {
1482
+ key: "getScheduleListByIds",
1483
+ value: function getScheduleListByIds(ids) {
1484
+ if (!this.store.schedule) return [];
1485
+ return this.store.schedule.getScheduleListByIds(ids);
1486
+ }
1487
+
1488
+ // ─── 临时订单操作(保留原有能力) ───
1489
+ }, {
1490
+ key: "getTempOrder",
1491
+ value: function getTempOrder() {
1492
+ var _this$store$order5;
1493
+ var result = ((_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 ? void 0 : _this$store$order5.getTempOrder()) || null;
1494
+ return result;
1495
+ }
1496
+ }, {
1497
+ key: "updateTempOrderNote",
1498
+ value: function updateTempOrderNote(note) {
1499
+ if (!this.store.order) throw new Error('order 模块未初始化');
1500
+ return this.store.order.updateTempOrderNote(note);
1501
+ }
1502
+ }, {
1503
+ key: "updateTempOrderContactsInfo",
1504
+ value: function updateTempOrderContactsInfo(contactsInfo) {
1505
+ if (!this.store.order) throw new Error('order 模块未初始化');
1506
+ return this.store.order.updateTempOrderContactsInfo(contactsInfo);
1507
+ }
1508
+ }, {
1509
+ key: "ensureTempOrder",
1510
+ value: function ensureTempOrder() {
1511
+ if (!this.store.order) throw new Error('order 模块未初始化');
1512
+ return this.store.order.ensureTempOrder();
1513
+ }
1514
+ }, {
1515
+ key: "onCustomerLogin",
1516
+ value: function () {
1517
+ var _onCustomerLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(params) {
1518
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1519
+ while (1) switch (_context18.prev = _context18.next) {
1520
+ case 0:
1521
+ this.logMethodStart('onCustomerLogin', {
1522
+ customerId: params.customerId
1523
+ });
1524
+ _context18.prev = 1;
1525
+ _context18.next = 4;
1526
+ return this.refreshOrderMarketingAfterLogin({
1527
+ customerId: params.customerId
1528
+ });
1529
+ case 4:
1530
+ this.logMethodSuccess('onCustomerLogin', {
1531
+ customerId: params.customerId
1532
+ });
1533
+ _context18.next = 11;
1534
+ break;
1535
+ case 7:
1536
+ _context18.prev = 7;
1537
+ _context18.t0 = _context18["catch"](1);
1538
+ this.logMethodError('onCustomerLogin', _context18.t0);
1539
+ throw _context18.t0;
1540
+ case 11:
1541
+ case "end":
1542
+ return _context18.stop();
1543
+ }
1544
+ }, _callee18, this, [[1, 7]]);
1545
+ }));
1546
+ function onCustomerLogin(_x11) {
1547
+ return _onCustomerLogin.apply(this, arguments);
1548
+ }
1549
+ return onCustomerLogin;
1550
+ }()
1551
+ }, {
1552
+ key: "recalculateOrderPricesFromQuotation",
1553
+ value: function recalculateOrderPricesFromQuotation() {
1554
+ var _tempOrder$products,
1555
+ _this6 = this;
1556
+ if (!this.store.order || !this.store.quotation) return;
1557
+ var tempOrder = this.store.order.getTempOrder();
1558
+ if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$products = tempOrder.products) !== null && _tempOrder$products !== void 0 && _tempOrder$products.length)) return;
1559
+ var now = dayjs().format('YYYY-MM-DD HH:mm:ss');
1560
+ var _iterator6 = _createForOfIteratorHelper(tempOrder.products),
1561
+ _step6;
1562
+ try {
1563
+ var _loop = function _loop() {
1564
+ var _product$metadata2;
1565
+ var product = _step6.value;
1566
+ if ((_product$metadata2 = product.metadata) !== null && _product$metadata2 !== void 0 && _product$metadata2.venue_booking) {
1567
+ var mapping = _this6.resourceProductMap.get(product.metadata.resource_id);
1568
+ if (!mapping) return 1; // continue
1569
+ var slots = expandMergedSlotToIndividual(product, _this6.store.slotConfig.slotDurationMinutes);
1570
+ var updatedSlots = slots.map(function (slot) {
1571
+ var _getPriceForProduct;
1572
+ return _objectSpread(_objectSpread({}, slot), {}, {
1573
+ price: (_getPriceForProduct = _this6.store.quotation.getPriceForProduct({
1574
+ productId: mapping.productId,
1575
+ datetime: slot.startTime
1576
+ })) !== null && _getPriceForProduct !== void 0 ? _getPriceForProduct : mapping.price
1577
+ });
1578
+ });
1579
+ var merged = mergeConsecutiveSlots(updatedSlots);
1580
+ if (merged.length === 1) {
1581
+ product.selling_price = merged[0].totalPrice;
1582
+ product.payment_price = merged[0].totalPrice;
1583
+ product.metadata.price_breakdown = buildPriceBreakdown({
1584
+ group: merged[0],
1585
+ productId: mapping.productId,
1586
+ quotation: _this6.store.quotation
1587
+ });
1588
+ }
1589
+ } else if (product.product_id != null) {
1590
+ var _product$product_vari;
1591
+ var quotationPrice = _this6.store.quotation.getPriceForProduct({
1592
+ productId: product.product_id,
1593
+ variantId: (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : undefined,
1594
+ datetime: now
1595
+ });
1596
+ if (quotationPrice !== null) {
1597
+ product.selling_price = quotationPrice;
1598
+ product.payment_price = quotationPrice;
1599
+ }
1600
+ }
1601
+ };
1602
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
1603
+ if (_loop()) continue;
1604
+ }
1605
+ } catch (err) {
1606
+ _iterator6.e(err);
1607
+ } finally {
1608
+ _iterator6.f();
1609
+ }
1610
+ }
1611
+ }, {
1612
+ key: "scanCode",
1613
+ value: function () {
1614
+ var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(code, customerId) {
1615
+ var result;
1616
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1617
+ while (1) switch (_context19.prev = _context19.next) {
1618
+ case 0:
1619
+ this.logMethodStart('scanCode', {
1620
+ code: code
1621
+ });
1622
+ _context19.prev = 1;
1623
+ if (this.store.order) {
1624
+ _context19.next = 4;
1625
+ break;
1626
+ }
1627
+ throw new Error('order 模块未初始化');
1628
+ case 4:
1629
+ _context19.next = 6;
1630
+ return this.store.order.scanCode(code, customerId);
1631
+ case 6:
1632
+ result = _context19.sent;
1633
+ if (!result.isAvailable) {
1634
+ _context19.next = 11;
1635
+ break;
1636
+ }
1637
+ _context19.next = 10;
1638
+ return this.store.order.recalculateSummary({
1639
+ createIfMissing: true
1640
+ });
1641
+ case 10:
1642
+ this.store.order.persistTempOrder();
1643
+ case 11:
1644
+ this.logMethodSuccess('scanCode', {
1645
+ isAvailable: result.isAvailable
1646
+ });
1647
+ return _context19.abrupt("return", result);
1648
+ case 15:
1649
+ _context19.prev = 15;
1650
+ _context19.t0 = _context19["catch"](1);
1651
+ this.logMethodError('scanCode', _context19.t0);
1652
+ throw _context19.t0;
1653
+ case 19:
1654
+ case "end":
1655
+ return _context19.stop();
1656
+ }
1657
+ }, _callee19, this, [[1, 15]]);
1658
+ }));
1659
+ function scanCode(_x12, _x13) {
1660
+ return _scanCode.apply(this, arguments);
1661
+ }
1662
+ return scanCode;
1663
+ }() /** 获取当前折扣列表(包装 order.getDiscountList) */
1664
+ }, {
1665
+ key: "getDiscountList",
1666
+ value: function getDiscountList() {
1667
+ if (!this.store.order) return [];
1668
+ return this.store.order.getDiscountList();
1669
+ }
1670
+
1671
+ /** 勾选/取消勾选某张折扣券,重新计算折扣并持久化 */
1672
+ }, {
1673
+ key: "setDiscountSelected",
1674
+ value: (function () {
1675
+ var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
1676
+ 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, _iterator7, _step7, d, selectedResourceIds, _iterator8, _step8, _product$discount_lis, product, before, totalDiscountAmount, newPaymentPrice, paymentStr, afterApplyTarget, finalSummary, finalProduct, finalTarget;
1677
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1678
+ while (1) switch (_context20.prev = _context20.next) {
1679
+ case 0:
1680
+ this.logMethodStart('setDiscountSelected', params);
1681
+ _context20.prev = 1;
1682
+ if (this.store.order) {
1683
+ _context20.next = 4;
1684
+ break;
1685
+ }
1686
+ throw new Error('order 模块未初始化');
1687
+ case 4:
1688
+ list = this.store.order.getDiscountList();
1689
+ beforeTarget = list.find(function (d) {
1690
+ return d.id === params.discountId;
1691
+ }) || null;
1692
+ updated = list.map(function (d) {
1693
+ return d.id === params.discountId ? _objectSpread(_objectSpread({}, d), {}, {
1694
+ isSelected: params.isSelected,
1695
+ isManualSelect: !params.isSelected
1696
+ }) : d;
1697
+ });
1698
+ updatedTarget = updated.find(function (d) {
1699
+ return d.id === params.discountId;
1700
+ }) || null;
1701
+ tempOrder = this.store.order.ensureTempOrder();
1702
+ orderStore = this.store.order.store || {};
1703
+ discountModule = orderStore.discount;
1704
+ rulesModule = orderStore.rules;
1705
+ holders = (_tempOrder$holder = tempOrder.holder) !== null && _tempOrder$holder !== void 0 && _tempOrder$holder.form_record_id ? [{
1706
+ form_record_id: tempOrder.holder.form_record_id
1707
+ }] : [];
1708
+ nextDiscountList = updated;
1709
+ _context20.next = 16;
1710
+ return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(updated);
1711
+ case 16:
1712
+ if (rulesModule) {
1713
+ result = rulesModule.calcDiscount({
1714
+ productList: tempOrder.products,
1715
+ discountList: updated,
1716
+ holders: holders,
1717
+ isFormSubject: !!((_tempOrder$holder2 = tempOrder.holder) !== null && _tempOrder$holder2 !== void 0 && _tempOrder$holder2.type) && tempOrder.holder.type === 'form'
1718
+ }, {
1719
+ discountId: params.discountId,
1720
+ isSelected: params.isSelected
1721
+ }) || {
1722
+ productList: tempOrder.products,
1723
+ discountList: updated
1724
+ };
1725
+ if (result !== null && result !== void 0 && result.productList) {
1726
+ tempOrder.products = result.productList;
1727
+ }
1728
+ if (result !== null && result !== void 0 && result.discountList) {
1729
+ nextDiscountList = result.discountList;
1730
+ if (!params.isSelected) {
1731
+ beforeSelectedIds = new Set(updated.filter(function (d) {
1732
+ return d.isSelected;
1733
+ }).map(function (d) {
1734
+ return d.id;
1735
+ }));
1736
+ _iterator7 = _createForOfIteratorHelper(nextDiscountList);
1737
+ try {
1738
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
1739
+ d = _step7.value;
1740
+ if (d.isSelected && !beforeSelectedIds.has(d.id)) {
1741
+ d.isSelected = false;
1742
+ }
1743
+ }
1744
+ } catch (err) {
1745
+ _iterator7.e(err);
1746
+ } finally {
1747
+ _iterator7.f();
1748
+ }
1749
+ }
1750
+ }
1751
+ }
1752
+ selectedResourceIds = new Set(nextDiscountList.filter(function (d) {
1753
+ return d.isSelected;
1754
+ }).map(function (d) {
1755
+ return d.id;
1756
+ }));
1757
+ _iterator8 = _createForOfIteratorHelper(tempOrder.products);
1758
+ _context20.prev = 19;
1759
+ _iterator8.s();
1760
+ case 21:
1761
+ if ((_step8 = _iterator8.n()).done) {
1762
+ _context20.next = 30;
1763
+ break;
1764
+ }
1765
+ product = _step8.value;
1766
+ if ((_product$discount_lis = product.discount_list) !== null && _product$discount_lis !== void 0 && _product$discount_lis.length) {
1767
+ _context20.next = 25;
1768
+ break;
1769
+ }
1770
+ return _context20.abrupt("continue", 28);
1771
+ case 25:
1772
+ before = product.discount_list.length;
1773
+ product.discount_list = product.discount_list.filter(function (pd) {
1774
+ var _pd$discount$resource, _pd$discount;
1775
+ 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;
1776
+ return rid != null && selectedResourceIds.has(rid);
1777
+ });
1778
+ if (product.discount_list.length < before) {
1779
+ totalDiscountAmount = product.discount_list.reduce(function (sum, pd) {
1780
+ return sum + (pd.amount || 0);
1781
+ }, 0);
1782
+ newPaymentPrice = new Decimal(product.selling_price || 0).minus(totalDiscountAmount).toNumber();
1783
+ paymentStr = toPriceString(newPaymentPrice);
1784
+ product.payment_price = paymentStr;
1785
+ if (product.metadata) {
1786
+ product.metadata.main_product_selling_price = paymentStr;
1787
+ }
1788
+ }
1789
+ case 28:
1790
+ _context20.next = 21;
1791
+ break;
1792
+ case 30:
1793
+ _context20.next = 35;
1794
+ break;
1795
+ case 32:
1796
+ _context20.prev = 32;
1797
+ _context20.t0 = _context20["catch"](19);
1798
+ _iterator8.e(_context20.t0);
1799
+ case 35:
1800
+ _context20.prev = 35;
1801
+ _iterator8.f();
1802
+ return _context20.finish(35);
1803
+ case 38:
1804
+ OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
1805
+ _context20.next = 41;
1806
+ return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
1807
+ case 41:
1808
+ tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
1809
+ return d.isSelected;
1810
+ });
1811
+ afterApplyTarget = this.store.order.getDiscountList().find(function (d) {
1812
+ return d.id === params.discountId;
1813
+ }) || null;
1814
+ _context20.next = 45;
1815
+ return this.store.order.recalculateSummary({
1816
+ createIfMissing: true
1817
+ });
1818
+ case 45:
1819
+ this.store.order.persistTempOrder();
1820
+ finalSummary = ((_this$store$order$get = this.store.order.getTempOrder()) === null || _this$store$order$get === void 0 ? void 0 : _this$store$order$get.summary) || null;
1821
+ 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;
1822
+ this.logMethodSuccess('setDiscountSelected', params);
1823
+ finalTarget = this.store.order.getDiscountList().find(function (d) {
1824
+ return d.id === params.discountId;
1825
+ }) || null;
1826
+ return _context20.abrupt("return", this.store.order.getDiscountList());
1827
+ case 53:
1828
+ _context20.prev = 53;
1829
+ _context20.t1 = _context20["catch"](1);
1830
+ this.logMethodError('setDiscountSelected', _context20.t1);
1831
+ throw _context20.t1;
1832
+ case 57:
1833
+ case "end":
1834
+ return _context20.stop();
1835
+ }
1836
+ }, _callee20, this, [[1, 53], [19, 32, 35, 38]]);
1837
+ }));
1838
+ function setDiscountSelected(_x14) {
1839
+ return _setDiscountSelected.apply(this, arguments);
1840
+ }
1841
+ return setDiscountSelected;
1842
+ }())
1843
+ }, {
1844
+ key: "addNewOrder",
1845
+ value: function () {
1846
+ var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
1847
+ var tempOrder;
1848
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1849
+ while (1) switch (_context21.prev = _context21.next) {
1850
+ case 0:
1851
+ this.logMethodStart('addNewOrder');
1852
+ _context21.prev = 1;
1853
+ if (this.store.order) {
1854
+ _context21.next = 4;
1855
+ break;
1856
+ }
1857
+ throw new Error('order 模块未初始化');
1858
+ case 4:
1859
+ _context21.next = 6;
1860
+ return this.store.order.addNewOrder();
1861
+ case 6:
1862
+ tempOrder = _context21.sent;
1863
+ this.logMethodSuccess('addNewOrder', {
1864
+ productCount: tempOrder.products.length
1865
+ });
1866
+ return _context21.abrupt("return", tempOrder);
1867
+ case 11:
1868
+ _context21.prev = 11;
1869
+ _context21.t0 = _context21["catch"](1);
1870
+ this.logMethodError('addNewOrder', _context21.t0);
1871
+ throw _context21.t0;
1872
+ case 15:
1873
+ case "end":
1874
+ return _context21.stop();
1875
+ }
1876
+ }, _callee21, this, [[1, 11]]);
1877
+ }));
1878
+ function addNewOrder() {
1879
+ return _addNewOrder.apply(this, arguments);
1880
+ }
1881
+ return addNewOrder;
1882
+ }()
1883
+ }, {
1884
+ key: "getOrderProducts",
1885
+ value: function getOrderProducts() {
1886
+ if (!this.store.order) throw new Error('order 模块未初始化');
1887
+ return this.store.order.getOrderProducts();
1888
+ }
1889
+ }, {
1890
+ key: "getSummary",
1891
+ value: function () {
1892
+ var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
1893
+ var summary;
1894
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1895
+ while (1) switch (_context22.prev = _context22.next) {
1896
+ case 0:
1897
+ this.logMethodStart('getSummary');
1898
+ _context22.prev = 1;
1899
+ if (this.store.order) {
1900
+ _context22.next = 4;
1901
+ break;
1902
+ }
1903
+ throw new Error('order 模块未初始化');
1904
+ case 4:
1905
+ _context22.next = 6;
1906
+ return this.store.order.getScanOrderSummary();
1907
+ case 6:
1908
+ summary = _context22.sent;
1909
+ this.logMethodSuccess('getSummary', {
1910
+ totalAmount: summary.total_amount
1911
+ });
1912
+ return _context22.abrupt("return", summary);
1913
+ case 11:
1914
+ _context22.prev = 11;
1915
+ _context22.t0 = _context22["catch"](1);
1916
+ this.logMethodError('getSummary', _context22.t0);
1917
+ throw _context22.t0;
1918
+ case 15:
1919
+ case "end":
1920
+ return _context22.stop();
1921
+ }
1922
+ }, _callee22, this, [[1, 11]]);
1923
+ }));
1924
+ function getSummary() {
1925
+ return _getSummary.apply(this, arguments);
1926
+ }
1927
+ return getSummary;
1928
+ }()
1929
+ }, {
1930
+ key: "submitOrder",
1931
+ value: function () {
1932
+ var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
1933
+ var _tempOrder$products2, result, tempOrder;
1934
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1935
+ while (1) switch (_context23.prev = _context23.next) {
1936
+ case 0:
1937
+ this.logMethodStart('submitOrder');
1938
+ _context23.prev = 1;
1939
+ _context23.next = 4;
1940
+ return this.validateBeforeSubmitByItemRule();
1941
+ case 4:
1942
+ if (this.store.order) {
1943
+ _context23.next = 6;
1944
+ break;
1945
+ }
1946
+ throw new Error('venueBooking解决方案需要 order 模块支持');
1947
+ case 6:
1948
+ _context23.next = 8;
1949
+ return this.store.order.submitTempOrder({
1950
+ cacheId: this.cacheId
1951
+ });
1952
+ case 8:
1953
+ result = _context23.sent;
1954
+ tempOrder = this.store.order.getTempOrder();
1955
+ this.logMethodSuccess('submitOrder', {
1956
+ productCount: (tempOrder === null || tempOrder === void 0 || (_tempOrder$products2 = tempOrder.products) === null || _tempOrder$products2 === void 0 ? void 0 : _tempOrder$products2.length) || 0
1957
+ });
1958
+ return _context23.abrupt("return", result);
1959
+ case 14:
1960
+ _context23.prev = 14;
1961
+ _context23.t0 = _context23["catch"](1);
1962
+ this.logMethodError('submitOrder', _context23.t0);
1963
+ throw _context23.t0;
1964
+ case 18:
1965
+ case "end":
1966
+ return _context23.stop();
1967
+ }
1968
+ }, _callee23, this, [[1, 14]]);
1969
+ }));
1970
+ function submitOrder() {
1971
+ return _submitOrder.apply(this, arguments);
1972
+ }
1973
+ return submitOrder;
1974
+ }()
1975
+ }, {
1976
+ key: "addProductToOrder",
1977
+ value: function () {
1978
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(product) {
1979
+ var _product$metadata3, _product$product_vari2, quotationPrice, products;
1980
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1981
+ while (1) switch (_context24.prev = _context24.next) {
1982
+ case 0:
1983
+ this.logMethodStart('addProductToOrder', {
1984
+ product_id: product.product_id,
1985
+ product_variant_id: product.product_variant_id
1986
+ });
1987
+ _context24.prev = 1;
1988
+ if (this.store.order) {
1989
+ _context24.next = 4;
1990
+ break;
1991
+ }
1992
+ throw new Error('order 模块未初始化');
1993
+ case 4:
1994
+ if (!((_product$metadata3 = product.metadata) !== null && _product$metadata3 !== void 0 && _product$metadata3.venue_booking) && this.store.quotation && product.product_id != null) {
1995
+ quotationPrice = this.store.quotation.getPriceForProduct({
1996
+ productId: product.product_id,
1997
+ variantId: (_product$product_vari2 = product.product_variant_id) !== null && _product$product_vari2 !== void 0 ? _product$product_vari2 : undefined,
1998
+ datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
1999
+ });
2000
+ if (quotationPrice !== null) {
2001
+ product.selling_price = quotationPrice;
2002
+ if (product.original_price == null) {
2003
+ product.original_price = quotationPrice;
2004
+ }
2005
+ product.payment_price = quotationPrice;
2006
+ }
2007
+ }
2008
+ _context24.next = 7;
2009
+ return this.store.order.addProductToOrder(product);
2010
+ case 7:
2011
+ products = _context24.sent;
2012
+ _context24.next = 10;
2013
+ return this.refreshItemRuleQuantityLimits();
2014
+ case 10:
2015
+ _context24.next = 12;
2016
+ return this.refreshCartValidationPassed();
2017
+ case 12:
2018
+ this.logMethodSuccess('addProductToOrder', {
2019
+ productCount: products.length
2020
+ });
2021
+ return _context24.abrupt("return", products);
2022
+ case 16:
2023
+ _context24.prev = 16;
2024
+ _context24.t0 = _context24["catch"](1);
2025
+ this.logMethodError('addProductToOrder', _context24.t0);
2026
+ throw _context24.t0;
2027
+ case 20:
2028
+ case "end":
2029
+ return _context24.stop();
2030
+ }
2031
+ }, _callee24, this, [[1, 16]]);
2032
+ }));
2033
+ function addProductToOrder(_x15) {
2034
+ return _addProductToOrder.apply(this, arguments);
2035
+ }
2036
+ return addProductToOrder;
2037
+ }()
2038
+ }, {
2039
+ key: "updateProductInOrder",
2040
+ value: function () {
2041
+ var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
2042
+ var products;
2043
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
2044
+ while (1) switch (_context25.prev = _context25.next) {
2045
+ case 0:
2046
+ this.logMethodStart('updateProductInOrder', {
2047
+ product_id: params.product_id,
2048
+ product_variant_id: params.product_variant_id
2049
+ });
2050
+ _context25.prev = 1;
2051
+ if (this.store.order) {
2052
+ _context25.next = 4;
2053
+ break;
2054
+ }
2055
+ throw new Error('order 模块未初始化');
2056
+ case 4:
2057
+ _context25.next = 6;
2058
+ return this.store.order.updateProductInOrder(params);
2059
+ case 6:
2060
+ products = _context25.sent;
2061
+ _context25.next = 9;
2062
+ return this.refreshItemRuleQuantityLimits();
2063
+ case 9:
2064
+ _context25.next = 11;
2065
+ return this.refreshCartValidationPassed();
2066
+ case 11:
2067
+ this.logMethodSuccess('updateProductInOrder', {
2068
+ productCount: products.length
2069
+ });
2070
+ return _context25.abrupt("return", products);
2071
+ case 15:
2072
+ _context25.prev = 15;
2073
+ _context25.t0 = _context25["catch"](1);
2074
+ this.logMethodError('updateProductInOrder', _context25.t0);
2075
+ throw _context25.t0;
2076
+ case 19:
2077
+ case "end":
2078
+ return _context25.stop();
2079
+ }
2080
+ }, _callee25, this, [[1, 15]]);
2081
+ }));
2082
+ function updateProductInOrder(_x16) {
2083
+ return _updateProductInOrder.apply(this, arguments);
2084
+ }
2085
+ return updateProductInOrder;
2086
+ }()
2087
+ }, {
2088
+ key: "removeProductFromOrder",
2089
+ value: function () {
2090
+ var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(identity) {
2091
+ var products;
2092
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2093
+ while (1) switch (_context26.prev = _context26.next) {
2094
+ case 0:
2095
+ this.logMethodStart('removeProductFromOrder', {
2096
+ product_id: identity.product_id,
2097
+ product_variant_id: identity.product_variant_id
2098
+ });
2099
+ _context26.prev = 1;
2100
+ if (this.store.order) {
2101
+ _context26.next = 4;
2102
+ break;
2103
+ }
2104
+ throw new Error('order 模块未初始化');
2105
+ case 4:
2106
+ _context26.next = 6;
2107
+ return this.store.order.removeProductFromOrder(identity);
2108
+ case 6:
2109
+ products = _context26.sent;
2110
+ _context26.next = 9;
2111
+ return this.refreshItemRuleQuantityLimits();
2112
+ case 9:
2113
+ _context26.next = 11;
2114
+ return this.refreshCartValidationPassed();
2115
+ case 11:
2116
+ this.logMethodSuccess('removeProductFromOrder', {
2117
+ productCount: products.length
2118
+ });
2119
+ return _context26.abrupt("return", products);
2120
+ case 15:
2121
+ _context26.prev = 15;
2122
+ _context26.t0 = _context26["catch"](1);
2123
+ this.logMethodError('removeProductFromOrder', _context26.t0);
2124
+ throw _context26.t0;
2125
+ case 19:
2126
+ case "end":
2127
+ return _context26.stop();
2128
+ }
2129
+ }, _callee26, this, [[1, 15]]);
2130
+ }));
2131
+ function removeProductFromOrder(_x17) {
2132
+ return _removeProductFromOrder.apply(this, arguments);
2133
+ }
2134
+ return removeProductFromOrder;
2135
+ }()
2136
+ }, {
2137
+ key: "getProductList",
2138
+ value: function () {
2139
+ var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
2140
+ var result;
2141
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2142
+ while (1) switch (_context27.prev = _context27.next) {
2143
+ case 0:
2144
+ _context27.next = 2;
2145
+ return this.loadAllProducts();
2146
+ case 2:
2147
+ result = _context27.sent;
2148
+ return _context27.abrupt("return", attachItemRuleLimitsToTopLevelProducts(result.addonProducts, this.store.itemRuleQuantityLimits || []));
2149
+ case 4:
2150
+ case "end":
2151
+ return _context27.stop();
2152
+ }
2153
+ }, _callee27, this);
2154
+ }));
2155
+ function getProductList() {
2156
+ return _getProductList.apply(this, arguments);
2157
+ }
2158
+ return getProductList;
2159
+ }() // ─── ItemRule 引擎 ───
2160
+ }, {
2161
+ key: "loadOpenDataConfig",
2162
+ value: function () {
2163
+ var _loadOpenDataConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
2164
+ var openDataConfig;
2165
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2166
+ while (1) switch (_context28.prev = _context28.next) {
2167
+ case 0:
2168
+ if (this.store.openData) {
2169
+ _context28.next = 2;
2170
+ break;
2171
+ }
2172
+ throw new Error('openData 模块未初始化');
2173
+ case 2:
2174
+ _context28.next = 4;
2175
+ return this.store.openData.fetchOpenData({
2176
+ scope: 'board',
2177
+ target: 'venue_booking+online_store',
2178
+ section_code: [].concat(OPEN_DATA_SECTION_CODES)
2179
+ });
2180
+ case 4:
2181
+ openDataConfig = _context28.sent;
2182
+ this.otherParams.openData = openDataConfig;
2183
+ return _context28.abrupt("return", openDataConfig);
2184
+ case 7:
2185
+ case "end":
2186
+ return _context28.stop();
2187
+ }
2188
+ }, _callee28, this);
2189
+ }));
2190
+ function loadOpenDataConfig() {
2191
+ return _loadOpenDataConfig.apply(this, arguments);
2192
+ }
2193
+ return loadOpenDataConfig;
2194
+ }()
2195
+ }, {
2196
+ key: "loadRuntimeConfigs",
2197
+ value: function () {
2198
+ var _loadRuntimeConfigs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
2199
+ var itemRuleConfigs;
2200
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2201
+ while (1) switch (_context29.prev = _context29.next) {
2202
+ case 0:
2203
+ _context29.next = 2;
2204
+ return this.loadOpenDataConfig();
2205
+ case 2:
2206
+ _context29.next = 4;
2207
+ return this.ensureItemRuleConfigsLoaded();
2208
+ case 4:
2209
+ itemRuleConfigs = _context29.sent;
2210
+ this.logMethodSuccess('loadRuntimeConfigs', {
2211
+ itemRuleCount: itemRuleConfigs.length
2212
+ });
2213
+ return _context29.abrupt("return", {
2214
+ itemRuleConfigs: itemRuleConfigs
2215
+ });
2216
+ case 7:
2217
+ case "end":
2218
+ return _context29.stop();
2219
+ }
2220
+ }, _callee29, this);
2221
+ }));
2222
+ function loadRuntimeConfigs() {
2223
+ return _loadRuntimeConfigs.apply(this, arguments);
2224
+ }
2225
+ return loadRuntimeConfigs;
2226
+ }()
2227
+ }, {
2228
+ key: "fetchItemRuleConfigsByModelIds",
2229
+ value: function () {
2230
+ var _fetchItemRuleConfigsByModelIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(strategyModelIds) {
2231
+ var result, configs;
2232
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2233
+ while (1) switch (_context30.prev = _context30.next) {
2234
+ case 0:
2235
+ this.logMethodStart('fetchItemRuleConfigsByModelIds', {
2236
+ strategyModelIds: strategyModelIds
2237
+ });
2238
+ if (strategyModelIds.length) {
2239
+ _context30.next = 3;
2240
+ break;
2241
+ }
2242
+ return _context30.abrupt("return", []);
2243
+ case 3:
2244
+ _context30.prev = 3;
2245
+ _context30.next = 6;
2246
+ return this.request.get('/promotion', {
2247
+ skip: 1,
2248
+ num: 99,
2249
+ status: 'active',
2250
+ ids: strategyModelIds
2251
+ });
2252
+ case 6:
2253
+ result = _context30.sent;
2254
+ configs = [];
2255
+ if (result.code === 200) {
2256
+ configs = result.data.list.map(function (item) {
2257
+ return item.metadata;
2258
+ });
2259
+ }
2260
+ this.logMethodSuccess('fetchItemRuleConfigsByModelIds', {
2261
+ strategyModelIds: strategyModelIds,
2262
+ strategyCount: configs.length
2263
+ });
2264
+ return _context30.abrupt("return", configs);
2265
+ case 13:
2266
+ _context30.prev = 13;
2267
+ _context30.t0 = _context30["catch"](3);
2268
+ this.logMethodError('fetchItemRuleConfigsByModelIds', _context30.t0, {
2269
+ strategyModelIds: strategyModelIds
2270
+ });
2271
+ return _context30.abrupt("return", []);
2272
+ case 17:
2273
+ case "end":
2274
+ return _context30.stop();
2275
+ }
2276
+ }, _callee30, this, [[3, 13]]);
2277
+ }));
2278
+ function fetchItemRuleConfigsByModelIds(_x18) {
2279
+ return _fetchItemRuleConfigsByModelIds.apply(this, arguments);
2280
+ }
2281
+ return fetchItemRuleConfigsByModelIds;
2282
+ }()
2283
+ }, {
2284
+ key: "buildPrefillProductSourceMap",
2285
+ value: function () {
2286
+ var _buildPrefillProductSourceMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
2287
+ var sourceMap, productList, visited, collectFromValue;
2288
+ return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2289
+ while (1) switch (_context31.prev = _context31.next) {
2290
+ case 0:
2291
+ sourceMap = new Map();
2292
+ _context31.prev = 1;
2293
+ _context31.next = 4;
2294
+ return this.getProductList();
2295
+ case 4:
2296
+ productList = _context31.sent;
2297
+ if (Array.isArray(productList)) {
2298
+ _context31.next = 7;
2299
+ break;
2300
+ }
2301
+ return _context31.abrupt("return", sourceMap);
2302
+ case 7:
2303
+ visited = new Set();
2304
+ collectFromValue = function collectFromValue(value) {
2305
+ var _node$product_id;
2306
+ if (!value || _typeof(value) !== 'object') return;
2307
+ if (visited.has(value)) return;
2308
+ visited.add(value);
2309
+ if (Array.isArray(value)) {
2310
+ var _iterator9 = _createForOfIteratorHelper(value),
2311
+ _step9;
2312
+ try {
2313
+ for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
2314
+ var item = _step9.value;
2315
+ collectFromValue(item);
2316
+ }
2317
+ } catch (err) {
2318
+ _iterator9.e(err);
2319
+ } finally {
2320
+ _iterator9.f();
2321
+ }
2322
+ return;
2323
+ }
2324
+ var node = value;
2325
+ var rawProductId = (_node$product_id = node.product_id) !== null && _node$product_id !== void 0 ? _node$product_id : node.id;
2326
+ var productId = Number(rawProductId);
2327
+ if (Number.isFinite(productId) && productId > 0) {
2328
+ var _ref3, _node$product_variant;
2329
+ 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);
2330
+ var normalizedVariantId = Number.isNaN(productVariantId) ? 0 : productVariantId;
2331
+ var key = buildProductKey(productId, normalizedVariantId);
2332
+ if (!sourceMap.has(key)) sourceMap.set(key, node);
2333
+ }
2334
+ for (var _i3 = 0, _Object$values = Object.values(node); _i3 < _Object$values.length; _i3++) {
2335
+ var childValue = _Object$values[_i3];
2336
+ if (childValue && _typeof(childValue) === 'object') collectFromValue(childValue);
2337
+ }
2338
+ };
2339
+ collectFromValue(productList);
2340
+ _context31.next = 15;
2341
+ break;
2342
+ case 12:
2343
+ _context31.prev = 12;
2344
+ _context31.t0 = _context31["catch"](1);
2345
+ this.logMethodError('buildPrefillProductSourceMap', _context31.t0);
2346
+ case 15:
2347
+ return _context31.abrupt("return", sourceMap);
2348
+ case 16:
2349
+ case "end":
2350
+ return _context31.stop();
2351
+ }
2352
+ }, _callee31, this, [[1, 12]]);
2353
+ }));
2354
+ function buildPrefillProductSourceMap() {
2355
+ return _buildPrefillProductSourceMap.apply(this, arguments);
2356
+ }
2357
+ return buildPrefillProductSourceMap;
2358
+ }()
2359
+ }, {
2360
+ key: "getItemRuleRuntimeConfig",
2361
+ value: function getItemRuleRuntimeConfig() {
2362
+ return this.itemRuleRuntimeConfig || {};
2363
+ }
2364
+ }, {
2365
+ key: "ensureItemRuleConfigsLoaded",
2366
+ value: function () {
2367
+ var _ensureItemRuleConfigsLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
2368
+ var _this7 = this;
2369
+ return _regeneratorRuntime().wrap(function _callee33$(_context33) {
2370
+ while (1) switch (_context33.prev = _context33.next) {
2371
+ case 0:
2372
+ if (!(this.itemRuleConfigs.length > 0)) {
2373
+ _context33.next = 2;
2374
+ break;
2375
+ }
2376
+ return _context33.abrupt("return", this.itemRuleConfigs);
2377
+ case 2:
2378
+ if (!this.itemRuleConfigsPromise) {
2379
+ _context33.next = 4;
2380
+ break;
2381
+ }
2382
+ return _context33.abrupt("return", this.itemRuleConfigsPromise);
2383
+ case 4:
2384
+ this.itemRuleConfigsPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
2385
+ var runtimeConfig, staticConfigs;
2386
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2387
+ while (1) switch (_context32.prev = _context32.next) {
2388
+ case 0:
2389
+ runtimeConfig = _this7.getItemRuleRuntimeConfig();
2390
+ staticConfigs = normalizeItemRuleStrategies(runtimeConfig.strategyConfigs);
2391
+ if (!(staticConfigs.length > 0)) {
2392
+ _context32.next = 6;
2393
+ break;
2394
+ }
2395
+ _this7.itemRuleConfigs = staticConfigs;
2396
+ _this7.itemRuleEvaluator.setStrategyConfigs(staticConfigs);
2397
+ return _context32.abrupt("return", _this7.itemRuleConfigs);
2398
+ case 6:
2399
+ _this7.itemRuleConfigs = [];
2400
+ _this7.itemRuleEvaluator.setStrategyConfigs([]);
2401
+ return _context32.abrupt("return", _this7.itemRuleConfigs);
2402
+ case 9:
2403
+ case "end":
2404
+ return _context32.stop();
2405
+ }
2406
+ }, _callee32);
2407
+ }))();
2408
+ _context33.next = 7;
2409
+ return this.itemRuleConfigsPromise;
2410
+ case 7:
2411
+ return _context33.abrupt("return", _context33.sent);
2412
+ case 8:
2413
+ case "end":
2414
+ return _context33.stop();
2415
+ }
2416
+ }, _callee33, this);
2417
+ }));
2418
+ function ensureItemRuleConfigsLoaded() {
2419
+ return _ensureItemRuleConfigsLoaded.apply(this, arguments);
2420
+ }
2421
+ return ensureItemRuleConfigsLoaded;
2422
+ }()
2423
+ }, {
2424
+ key: "refreshItemRuleQuantityLimits",
2425
+ value: function () {
2426
+ var _refreshItemRuleQuantityLimits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
2427
+ var strategyConfigs, businessData, limits;
2428
+ return _regeneratorRuntime().wrap(function _callee34$(_context34) {
2429
+ while (1) switch (_context34.prev = _context34.next) {
2430
+ case 0:
2431
+ _context34.prev = 0;
2432
+ _context34.next = 3;
2433
+ return this.ensureItemRuleConfigsLoaded();
2434
+ case 3:
2435
+ strategyConfigs = _context34.sent;
2436
+ if (strategyConfigs.length) {
2437
+ _context34.next = 7;
2438
+ break;
2439
+ }
2440
+ this.store.itemRuleQuantityLimits = [];
2441
+ return _context34.abrupt("return", []);
2442
+ case 7:
2443
+ businessData = buildItemRuleBusinessData({
2444
+ tempOrder: this.ensureTempOrder(),
2445
+ runtimeConfig: this.getItemRuleRuntimeConfig(),
2446
+ itemRuleConfigs: this.itemRuleConfigs
2447
+ });
2448
+ limits = this.itemRuleEvaluator.getQuantityLimits(businessData);
2449
+ this.store.itemRuleQuantityLimits = limits;
2450
+ this.logMethodSuccess('refreshItemRuleQuantityLimits', {
2451
+ limitCount: limits.length
2452
+ });
2453
+ return _context34.abrupt("return", limits);
2454
+ case 14:
2455
+ _context34.prev = 14;
2456
+ _context34.t0 = _context34["catch"](0);
2457
+ this.store.itemRuleQuantityLimits = [];
2458
+ this.logMethodError('refreshItemRuleQuantityLimits', _context34.t0);
2459
+ return _context34.abrupt("return", []);
2460
+ case 19:
2461
+ case "end":
2462
+ return _context34.stop();
2463
+ }
2464
+ }, _callee34, this, [[0, 14]]);
2465
+ }));
2466
+ function refreshItemRuleQuantityLimits() {
2467
+ return _refreshItemRuleQuantityLimits.apply(this, arguments);
2468
+ }
2469
+ return refreshItemRuleQuantityLimits;
2470
+ }()
2471
+ }, {
2472
+ key: "applyPrefillByItemRule",
2473
+ value: function () {
2474
+ var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {
2475
+ var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges, _iterator10, _step10, _prefillItem$product_, _targetProduct$_origi, prefillItem, productId, productVariantId, targetQuantity, sourceItem, productIndex, _sourceItem$price, _ref5, _sourceItem$original_, _ref6, _sourceItem$payment_p, sellingPrice, originalPrice, paymentPrice, targetProduct, existedQuantity, delta, nextProduct;
2476
+ return _regeneratorRuntime().wrap(function _callee35$(_context35) {
2477
+ while (1) switch (_context35.prev = _context35.next) {
2478
+ case 0:
2479
+ if (!this.itemRulePrefillApplied) {
2480
+ _context35.next = 2;
2481
+ break;
2482
+ }
2483
+ return _context35.abrupt("return");
2484
+ case 2:
2485
+ if (this.store.order) {
2486
+ _context35.next = 4;
2487
+ break;
2488
+ }
2489
+ return _context35.abrupt("return");
2490
+ case 4:
2491
+ _context35.next = 6;
2492
+ return this.ensureItemRuleConfigsLoaded();
2493
+ case 6:
2494
+ strategyConfigs = _context35.sent;
2495
+ if (strategyConfigs.length) {
2496
+ _context35.next = 9;
2497
+ break;
2498
+ }
2499
+ return _context35.abrupt("return");
2500
+ case 9:
2501
+ businessData = buildItemRuleBusinessData({
2502
+ tempOrder: this.ensureTempOrder(),
2503
+ runtimeConfig: this.getItemRuleRuntimeConfig(),
2504
+ itemRuleConfigs: this.itemRuleConfigs
2505
+ });
2506
+ prefillItems = this.itemRuleEvaluator.getPrefillItems(businessData);
2507
+ if (prefillItems.length) {
2508
+ _context35.next = 14;
2509
+ break;
2510
+ }
2511
+ this.itemRulePrefillApplied = true;
2512
+ return _context35.abrupt("return");
2513
+ case 14:
2514
+ _context35.next = 16;
2515
+ return this.buildPrefillProductSourceMap();
2516
+ case 16:
2517
+ productSourceMap = _context35.sent;
2518
+ tempOrder = this.ensureTempOrder();
2519
+ hasChanges = false;
2520
+ _iterator10 = _createForOfIteratorHelper(prefillItems);
2521
+ _context35.prev = 20;
2522
+ _iterator10.s();
2523
+ case 22:
2524
+ if ((_step10 = _iterator10.n()).done) {
2525
+ _context35.next = 47;
2526
+ break;
2527
+ }
2528
+ prefillItem = _step10.value;
2529
+ productId = Number(prefillItem.product_id);
2530
+ productVariantId = Number((_prefillItem$product_ = prefillItem.product_variant_id) !== null && _prefillItem$product_ !== void 0 ? _prefillItem$product_ : 0);
2531
+ targetQuantity = toNonNegativeInt(prefillItem.quantity);
2532
+ if (!(!Number.isFinite(productId) || targetQuantity <= 0)) {
2533
+ _context35.next = 29;
2534
+ break;
2535
+ }
2536
+ return _context35.abrupt("continue", 45);
2537
+ case 29:
2538
+ if (!Number.isNaN(productVariantId)) {
2539
+ _context35.next = 31;
2540
+ break;
2541
+ }
2542
+ return _context35.abrupt("continue", 45);
2543
+ case 31:
2544
+ sourceItem = productSourceMap.get(buildProductKey(productId, productVariantId)) || productSourceMap.get(buildProductKey(productId, 0)) || null;
2545
+ productIndex = getProductIdentityIndex(tempOrder.products, {
2546
+ product_id: productId,
2547
+ product_variant_id: productVariantId
2548
+ });
2549
+ if (!(productIndex === -1)) {
2550
+ _context35.next = 40;
2551
+ break;
2552
+ }
2553
+ 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');
2554
+ originalPrice = toPriceString((_ref5 = (_sourceItem$original_ = sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.original_price) !== null && _sourceItem$original_ !== void 0 ? _sourceItem$original_ : sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.price) !== null && _ref5 !== void 0 ? _ref5 : sellingPrice, sellingPrice);
2555
+ paymentPrice = toPriceString((_ref6 = (_sourceItem$payment_p = sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.payment_price) !== null && _sourceItem$payment_p !== void 0 ? _sourceItem$payment_p : sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.price) !== null && _ref6 !== void 0 ? _ref6 : sellingPrice, sellingPrice);
2556
+ tempOrder.products.push(normalizeOrderProduct({
2557
+ product_id: productId,
2558
+ product_variant_id: productVariantId,
2559
+ num: targetQuantity,
2560
+ selling_price: sellingPrice,
2561
+ original_price: originalPrice,
2562
+ payment_price: paymentPrice,
2563
+ metadata: {
2564
+ item_rule_prefill: true,
2565
+ item_rule_id: prefillItem.ruleId
2566
+ },
2567
+ _origin: _objectSpread(_objectSpread({}, sourceItem || {}), {}, {
2568
+ item_rule_prefill: true,
2569
+ item_rule_id: prefillItem.ruleId
2570
+ })
2571
+ }));
2572
+ hasChanges = true;
2573
+ return _context35.abrupt("continue", 45);
2574
+ case 40:
2575
+ targetProduct = tempOrder.products[productIndex];
2576
+ existedQuantity = toNonNegativeInt(targetProduct.num);
2577
+ delta = targetQuantity - existedQuantity;
2578
+ nextProduct = _objectSpread(_objectSpread(_objectSpread({}, targetProduct), delta > 0 ? {
2579
+ num: getSafeProductNum(existedQuantity + delta)
2580
+ } : {}), {}, {
2581
+ metadata: _objectSpread(_objectSpread({}, targetProduct.metadata || {}), {}, {
2582
+ item_rule_prefill: true,
2583
+ item_rule_id: prefillItem.ruleId
2584
+ }),
2585
+ _origin: sourceItem ? _objectSpread(_objectSpread({}, targetProduct._origin || {}), sourceItem) : targetProduct._origin
2586
+ });
2587
+ 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)))) {
2588
+ tempOrder.products[productIndex] = nextProduct;
2589
+ hasChanges = true;
2590
+ }
2591
+ case 45:
2592
+ _context35.next = 22;
2593
+ break;
2594
+ case 47:
2595
+ _context35.next = 52;
2596
+ break;
2597
+ case 49:
2598
+ _context35.prev = 49;
2599
+ _context35.t0 = _context35["catch"](20);
2600
+ _iterator10.e(_context35.t0);
2601
+ case 52:
2602
+ _context35.prev = 52;
2603
+ _iterator10.f();
2604
+ return _context35.finish(52);
2605
+ case 55:
2606
+ if (!hasChanges) {
2607
+ _context35.next = 59;
2608
+ break;
2609
+ }
2610
+ _context35.next = 58;
2611
+ return this.store.order.recalculateSummary({
2612
+ createIfMissing: true
2613
+ });
2614
+ case 58:
2615
+ this.store.order.persistTempOrder();
2616
+ case 59:
2617
+ _context35.next = 61;
2618
+ return this.refreshItemRuleQuantityLimits();
2619
+ case 61:
2620
+ this.itemRulePrefillApplied = true;
2621
+ this.logMethodSuccess('applyPrefillByItemRule', {
2622
+ prefillCount: prefillItems.length,
2623
+ hasChanges: hasChanges
2624
+ });
2625
+ case 63:
2626
+ case "end":
2627
+ return _context35.stop();
2628
+ }
2629
+ }, _callee35, this, [[20, 49, 52, 55]]);
2630
+ }));
2631
+ function applyPrefillByItemRule() {
2632
+ return _applyPrefillByItemRule.apply(this, arguments);
2633
+ }
2634
+ return applyPrefillByItemRule;
2635
+ }()
2636
+ }, {
2637
+ key: "applyItemRulePrefill",
2638
+ value: function () {
2639
+ var _applyItemRulePrefill = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {
2640
+ return _regeneratorRuntime().wrap(function _callee36$(_context36) {
2641
+ while (1) switch (_context36.prev = _context36.next) {
2642
+ case 0:
2643
+ this.logMethodStart('applyItemRulePrefill');
2644
+ _context36.next = 3;
2645
+ return this.applyPrefillByItemRule();
2646
+ case 3:
2647
+ _context36.next = 5;
2648
+ return this.refreshItemRuleQuantityLimits();
2649
+ case 5:
2650
+ _context36.next = 7;
2651
+ return this.refreshCartValidationPassed();
2652
+ case 7:
2653
+ case "end":
2654
+ return _context36.stop();
2655
+ }
2656
+ }, _callee36, this);
2657
+ }));
2658
+ function applyItemRulePrefill() {
2659
+ return _applyItemRulePrefill.apply(this, arguments);
2660
+ }
2661
+ return applyItemRulePrefill;
2662
+ }()
2663
+ }, {
2664
+ key: "evaluateCartValidationByItemRule",
2665
+ value: function () {
2666
+ var _evaluateCartValidationByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {
2667
+ var strategyConfigs, businessData;
2668
+ return _regeneratorRuntime().wrap(function _callee37$(_context37) {
2669
+ while (1) switch (_context37.prev = _context37.next) {
2670
+ case 0:
2671
+ _context37.next = 2;
2672
+ return this.ensureItemRuleConfigsLoaded();
2673
+ case 2:
2674
+ strategyConfigs = _context37.sent;
2675
+ if (strategyConfigs.length) {
2676
+ _context37.next = 5;
2677
+ break;
2678
+ }
2679
+ return _context37.abrupt("return", {
2680
+ passed: true,
2681
+ failures: []
2682
+ });
2683
+ case 5:
2684
+ businessData = buildItemRuleBusinessData({
2685
+ tempOrder: this.ensureTempOrder(),
2686
+ runtimeConfig: this.getItemRuleRuntimeConfig(),
2687
+ itemRuleConfigs: this.itemRuleConfigs
2688
+ });
2689
+ return _context37.abrupt("return", this.itemRuleEvaluator.validateCart(businessData));
2690
+ case 7:
2691
+ case "end":
2692
+ return _context37.stop();
2693
+ }
2694
+ }, _callee37, this);
2695
+ }));
2696
+ function evaluateCartValidationByItemRule() {
2697
+ return _evaluateCartValidationByItemRule.apply(this, arguments);
2698
+ }
2699
+ return evaluateCartValidationByItemRule;
2700
+ }()
2701
+ }, {
2702
+ key: "validateBeforeSubmitByItemRule",
2703
+ value: function () {
2704
+ var _validateBeforeSubmitByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
2705
+ var validationResult, firstFailure, errorMessage, error;
2706
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
2707
+ while (1) switch (_context38.prev = _context38.next) {
2708
+ case 0:
2709
+ _context38.next = 2;
2710
+ return this.evaluateCartValidationByItemRule();
2711
+ case 2:
2712
+ validationResult = _context38.sent;
2713
+ if (!validationResult.passed) {
2714
+ _context38.next = 5;
2715
+ break;
2716
+ }
2717
+ return _context38.abrupt("return");
2718
+ case 5:
2719
+ firstFailure = validationResult.failures[0];
2720
+ errorMessage = (firstFailure === null || firstFailure === void 0 ? void 0 : firstFailure.validationMessage) || '当前购物车未满足商品规则,请调整后再提交';
2721
+ error = new Error(String(errorMessage));
2722
+ error.failures = validationResult.failures;
2723
+ throw error;
2724
+ case 10:
2725
+ case "end":
2726
+ return _context38.stop();
2727
+ }
2728
+ }, _callee38, this);
2729
+ }));
2730
+ function validateBeforeSubmitByItemRule() {
2731
+ return _validateBeforeSubmitByItemRule.apply(this, arguments);
2732
+ }
2733
+ return validateBeforeSubmitByItemRule;
2734
+ }()
2735
+ }, {
2736
+ key: "refreshCartValidationPassed",
2737
+ value: function () {
2738
+ var _refreshCartValidationPassed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
2739
+ var previous, nextState, validationResult, changed;
2740
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
2741
+ while (1) switch (_context39.prev = _context39.next) {
2742
+ case 0:
2743
+ previous = this.store.cartValidation || {
2744
+ passed: null,
2745
+ failures: []
2746
+ };
2747
+ nextState = {
2748
+ passed: null,
2749
+ failures: []
2750
+ };
2751
+ _context39.prev = 2;
2752
+ _context39.next = 5;
2753
+ return this.evaluateCartValidationByItemRule();
2754
+ case 5:
2755
+ validationResult = _context39.sent;
2756
+ nextState = {
2757
+ passed: validationResult.passed,
2758
+ failures: validationResult.failures || []
2759
+ };
2760
+ _context39.next = 12;
2761
+ break;
2762
+ case 9:
2763
+ _context39.prev = 9;
2764
+ _context39.t0 = _context39["catch"](2);
2765
+ nextState = {
2766
+ passed: false,
2767
+ failures: []
2768
+ };
2769
+ case 12:
2770
+ this.store.cartValidation = nextState;
2771
+ changed = previous.passed !== nextState.passed || previous.failures !== nextState.failures;
2772
+ if (!changed) {
2773
+ _context39.next = 17;
2774
+ break;
2775
+ }
2776
+ _context39.next = 17;
2777
+ return this.core.effects.emit(VenueBookingHooks.onCartValidationChanged, {
2778
+ cartValidation: nextState,
2779
+ cartValidationPassed: nextState.passed
2780
+ });
2781
+ case 17:
2782
+ return _context39.abrupt("return", nextState.passed);
2783
+ case 18:
2784
+ case "end":
2785
+ return _context39.stop();
2786
+ }
2787
+ }, _callee39, this, [[2, 9]]);
2788
+ }));
2789
+ function refreshCartValidationPassed() {
2790
+ return _refreshCartValidationPassed.apply(this, arguments);
2791
+ }
2792
+ return refreshCartValidationPassed;
2793
+ }()
2794
+ }, {
2795
+ key: "setItemRuleRuntimeConfig",
2796
+ value: function () {
2797
+ var _setItemRuleRuntimeConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40() {
2798
+ var _this$itemRuleRuntime, _this$itemRuleRuntime2;
2799
+ var config,
2800
+ _args40 = arguments;
2801
+ return _regeneratorRuntime().wrap(function _callee40$(_context40) {
2802
+ while (1) switch (_context40.prev = _context40.next) {
2803
+ case 0:
2804
+ config = _args40.length > 0 && _args40[0] !== undefined ? _args40[0] : {};
2805
+ this.logMethodStart('setItemRuleRuntimeConfig');
2806
+ this.itemRuleRuntimeConfig = _objectSpread(_objectSpread(_objectSpread({}, this.itemRuleRuntimeConfig), config), {}, {
2807
+ 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) || {}),
2808
+ 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) || {})
2809
+ });
2810
+ if ('strategyConfigs' in config) {
2811
+ this.itemRuleConfigs = [];
2812
+ this.itemRuleConfigsPromise = null;
2813
+ this.itemRuleEvaluator.setStrategyConfigs([]);
2814
+ }
2815
+ this.itemRulePrefillApplied = false;
2816
+ _context40.next = 7;
2817
+ return this.refreshItemRuleQuantityLimits();
2818
+ case 7:
2819
+ _context40.next = 9;
2820
+ return this.refreshCartValidationPassed();
2821
+ case 9:
2822
+ this.logMethodSuccess('setItemRuleRuntimeConfig', {
2823
+ strategyCount: Array.isArray(this.itemRuleRuntimeConfig.strategyConfigs) ? this.itemRuleRuntimeConfig.strategyConfigs.length : 0
2824
+ });
2825
+ case 10:
2826
+ case "end":
2827
+ return _context40.stop();
2828
+ }
2829
+ }, _callee40, this);
2830
+ }));
2831
+ function setItemRuleRuntimeConfig() {
2832
+ return _setItemRuleRuntimeConfig.apply(this, arguments);
2833
+ }
2834
+ return setItemRuleRuntimeConfig;
2835
+ }()
2836
+ }, {
2837
+ key: "getOtherParams",
2838
+ value: function getOtherParams() {
2839
+ return this.otherParams;
2840
+ }
2841
+
2842
+ // ─── OpenData 可用性 ───
2843
+ }, {
2844
+ key: "checkOpenDataAvailability",
2845
+ value: function () {
2846
+ var _checkOpenDataAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41() {
2847
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
2848
+ while (1) switch (_context41.prev = _context41.next) {
2849
+ case 0:
2850
+ if (this.store.openData) {
2851
+ _context41.next = 2;
2852
+ break;
2853
+ }
2854
+ throw new Error('openData 模块未初始化');
2855
+ case 2:
2856
+ _context41.next = 4;
2857
+ return this.loadOpenDataConfig();
2858
+ case 4:
2859
+ return _context41.abrupt("return", this.store.openData.checkAvailability(this.store.schedule));
2860
+ case 5:
2861
+ case "end":
2862
+ return _context41.stop();
2863
+ }
2864
+ }, _callee41, this);
2865
+ }));
2866
+ function checkOpenDataAvailability() {
2867
+ return _checkOpenDataAvailability.apply(this, arguments);
2868
+ }
2869
+ return checkOpenDataAvailability;
2870
+ }()
2871
+ }]);
2872
+ return VenueBookingImpl;
2873
+ }(BaseModule);