@pisell/pisellos 2.1.119 → 2.1.121

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