@pisell/pisellos 2.1.150 → 2.1.151

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 (201) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +1 -0
  3. package/dist/model/strategy/adapter/promotion/evaluator.js +99 -26
  4. package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
  5. package/dist/model/strategy/adapter/walletPass/evaluator.js +61 -8
  6. package/dist/model/strategy/adapter/walletPass/locales.js +12 -3
  7. package/dist/model/strategy/engine.d.ts +18 -5
  8. package/dist/model/strategy/engine.js +145 -45
  9. package/dist/model/strategy/type.d.ts +17 -0
  10. package/dist/model/strategy/type.js +4 -0
  11. package/dist/modules/Cart/types.d.ts +2 -0
  12. package/dist/modules/Cart/utils/cartProduct.js +56 -25
  13. package/dist/modules/Discount/index.d.ts +2 -6
  14. package/dist/modules/Discount/index.js +8 -14
  15. package/dist/modules/Discount/types.d.ts +19 -1
  16. package/dist/modules/Order/index.d.ts +1 -65
  17. package/dist/modules/Order/index.js +30 -901
  18. package/dist/modules/Order/types.d.ts +12 -174
  19. package/dist/modules/Order/types.js +0 -2
  20. package/dist/modules/Order/utils.d.ts +0 -118
  21. package/dist/modules/Order/utils.js +2 -586
  22. package/dist/modules/Payment/index.d.ts +2 -1
  23. package/dist/modules/Payment/index.js +10 -7
  24. package/dist/modules/Payment/utils.js +3 -0
  25. package/dist/modules/Payment/walletpass.d.ts +23 -0
  26. package/dist/modules/Payment/walletpass.js +191 -95
  27. package/dist/modules/Product/utils.js +2 -2
  28. package/dist/modules/ProductList/index.d.ts +1 -1
  29. package/dist/modules/ProductList/index.js +3 -4
  30. package/dist/modules/Rules/index.d.ts +9 -5
  31. package/dist/modules/Rules/index.js +677 -168
  32. package/dist/modules/Rules/types.d.ts +2 -0
  33. package/dist/modules/Schedule/getDateIsInSchedule.js +18 -11
  34. package/dist/modules/Schedule/utils.d.ts +1 -1
  35. package/dist/modules/Summary/types.d.ts +2 -0
  36. package/dist/modules/Summary/utils.d.ts +9 -3
  37. package/dist/modules/Summary/utils.js +52 -41
  38. package/dist/modules/index.d.ts +0 -4
  39. package/dist/modules/index.js +1 -5
  40. package/dist/plugins/window.d.ts +2 -0
  41. package/dist/solution/BookingByStep/index.d.ts +3 -2
  42. package/dist/solution/BookingByStep/index.js +43 -46
  43. package/dist/solution/BookingByStep/types.d.ts +1 -3
  44. package/dist/solution/BookingByStep/types.js +1 -5
  45. package/dist/solution/BookingByStep/utils/timeslots.d.ts +1 -3
  46. package/dist/solution/BookingByStep/utils/timeslots.js +12 -19
  47. package/dist/solution/Checkout/index.js +2 -0
  48. package/dist/solution/ShopDiscount/index.d.ts +2 -2
  49. package/dist/solution/ShopDiscount/index.js +41 -37
  50. package/dist/solution/ShopDiscount/types.d.ts +1 -1
  51. package/dist/solution/ShopDiscount/types.js +2 -1
  52. package/dist/solution/ShopDiscount/utils.js +26 -12
  53. package/dist/solution/index.d.ts +0 -2
  54. package/dist/solution/index.js +1 -3
  55. package/lib/index.d.ts +1 -0
  56. package/lib/index.js +3 -1
  57. package/lib/model/strategy/adapter/promotion/evaluator.js +57 -8
  58. package/lib/model/strategy/adapter/promotion/index.js +49 -0
  59. package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
  60. package/lib/model/strategy/adapter/walletPass/evaluator.js +34 -3
  61. package/lib/model/strategy/adapter/walletPass/locales.js +12 -3
  62. package/lib/model/strategy/engine.d.ts +18 -5
  63. package/lib/model/strategy/engine.js +85 -21
  64. package/lib/model/strategy/type.d.ts +17 -0
  65. package/lib/modules/Cart/types.d.ts +2 -0
  66. package/lib/modules/Cart/utils/cartProduct.js +39 -12
  67. package/lib/modules/Discount/index.d.ts +2 -6
  68. package/lib/modules/Discount/index.js +1 -3
  69. package/lib/modules/Discount/types.d.ts +19 -1
  70. package/lib/modules/Order/index.d.ts +1 -65
  71. package/lib/modules/Order/index.js +1 -513
  72. package/lib/modules/Order/types.d.ts +12 -174
  73. package/lib/modules/Order/utils.d.ts +0 -118
  74. package/lib/modules/Order/utils.js +2 -483
  75. package/lib/modules/Payment/index.d.ts +2 -1
  76. package/lib/modules/Payment/index.js +1 -0
  77. package/lib/modules/Payment/utils.js +3 -0
  78. package/lib/modules/Payment/walletpass.d.ts +23 -0
  79. package/lib/modules/Payment/walletpass.js +94 -17
  80. package/lib/modules/Product/utils.js +2 -2
  81. package/lib/modules/ProductList/index.d.ts +1 -1
  82. package/lib/modules/ProductList/index.js +3 -5
  83. package/lib/modules/Rules/index.d.ts +9 -5
  84. package/lib/modules/Rules/index.js +780 -288
  85. package/lib/modules/Rules/types.d.ts +2 -0
  86. package/lib/modules/Schedule/getDateIsInSchedule.js +11 -9
  87. package/lib/modules/Schedule/utils.d.ts +1 -1
  88. package/lib/modules/Summary/types.d.ts +2 -0
  89. package/lib/modules/Summary/utils.d.ts +9 -3
  90. package/lib/modules/Summary/utils.js +31 -22
  91. package/lib/modules/index.d.ts +0 -4
  92. package/lib/modules/index.js +1 -9
  93. package/lib/plugins/window.d.ts +2 -0
  94. package/lib/solution/BookingByStep/index.d.ts +3 -2
  95. package/lib/solution/BookingByStep/index.js +4 -6
  96. package/lib/solution/BookingByStep/types.d.ts +1 -3
  97. package/lib/solution/BookingByStep/types.js +0 -10
  98. package/lib/solution/BookingByStep/utils/timeslots.d.ts +1 -3
  99. package/lib/solution/BookingByStep/utils/timeslots.js +11 -19
  100. package/lib/solution/Checkout/index.js +2 -0
  101. package/lib/solution/ShopDiscount/index.d.ts +2 -2
  102. package/lib/solution/ShopDiscount/index.js +24 -16
  103. package/lib/solution/ShopDiscount/types.d.ts +1 -1
  104. package/lib/solution/ShopDiscount/utils.js +10 -6
  105. package/lib/solution/index.d.ts +0 -2
  106. package/lib/solution/index.js +1 -5
  107. package/package.json +1 -1
  108. package/dist/apis/picoding.d.ts +0 -0
  109. package/dist/apis/picoding.js +0 -1
  110. package/dist/modules/OpenData/index.d.ts +0 -24
  111. package/dist/modules/OpenData/index.js +0 -173
  112. package/dist/modules/OpenData/types.d.ts +0 -73
  113. package/dist/modules/OpenData/types.js +0 -1
  114. package/dist/modules/OpenData/utils.d.ts +0 -2
  115. package/dist/modules/OpenData/utils.js +0 -75
  116. package/dist/modules/Quotation/index.d.ts +0 -48
  117. package/dist/modules/Quotation/index.js +0 -248
  118. package/dist/modules/Quotation/types.d.ts +0 -42
  119. package/dist/modules/Quotation/types.js +0 -1
  120. package/dist/modules/SalesSummary/index.d.ts +0 -63
  121. package/dist/modules/SalesSummary/index.js +0 -174
  122. package/dist/modules/SalesSummary/types.d.ts +0 -60
  123. package/dist/modules/SalesSummary/types.js +0 -1
  124. package/dist/modules/SalesSummary/utils.d.ts +0 -30
  125. package/dist/modules/SalesSummary/utils.js +0 -480
  126. package/dist/modules/ScanOrderLogger/index.d.ts +0 -23
  127. package/dist/modules/ScanOrderLogger/index.js +0 -174
  128. package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +0 -2
  129. package/dist/modules/ScanOrderLogger/providers/feishu.js +0 -221
  130. package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +0 -2
  131. package/dist/modules/ScanOrderLogger/providers/grafana.js +0 -50
  132. package/dist/modules/ScanOrderLogger/types.d.ts +0 -53
  133. package/dist/modules/ScanOrderLogger/types.js +0 -1
  134. package/dist/solution/ScanOrder/index.d.ts +0 -152
  135. package/dist/solution/ScanOrder/index.js +0 -3132
  136. package/dist/solution/ScanOrder/types.d.ts +0 -287
  137. package/dist/solution/ScanOrder/types.js +0 -35
  138. package/dist/solution/ScanOrder/utils.d.ts +0 -167
  139. package/dist/solution/ScanOrder/utils.js +0 -764
  140. package/dist/solution/VenueBooking/index.d.ts +0 -199
  141. package/dist/solution/VenueBooking/index.js +0 -3459
  142. package/dist/solution/VenueBooking/sales-section-4-annotated.json +0 -343
  143. package/dist/solution/VenueBooking/types.d.ts +0 -154
  144. package/dist/solution/VenueBooking/types.js +0 -21
  145. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +0 -11
  146. package/dist/solution/VenueBooking/utils/dateSummary.js +0 -104
  147. package/dist/solution/VenueBooking/utils/resource.d.ts +0 -14
  148. package/dist/solution/VenueBooking/utils/resource.js +0 -131
  149. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -38
  150. package/dist/solution/VenueBooking/utils/slotMerge.js +0 -239
  151. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -32
  152. package/dist/solution/VenueBooking/utils/timeSlot.js +0 -453
  153. package/dist/solution/VenueBooking/utils.d.ts +0 -1
  154. package/dist/solution/VenueBooking/utils.js +0 -1
  155. package/lib/apis/picoding.d.ts +0 -0
  156. package/lib/apis/picoding.js +0 -0
  157. package/lib/modules/OpenData/index.d.ts +0 -24
  158. package/lib/modules/OpenData/index.js +0 -119
  159. package/lib/modules/OpenData/types.d.ts +0 -73
  160. package/lib/modules/OpenData/types.js +0 -17
  161. package/lib/modules/OpenData/utils.d.ts +0 -2
  162. package/lib/modules/OpenData/utils.js +0 -111
  163. package/lib/modules/Quotation/index.d.ts +0 -48
  164. package/lib/modules/Quotation/index.js +0 -152
  165. package/lib/modules/Quotation/types.d.ts +0 -42
  166. package/lib/modules/Quotation/types.js +0 -17
  167. package/lib/modules/SalesSummary/index.d.ts +0 -63
  168. package/lib/modules/SalesSummary/index.js +0 -105
  169. package/lib/modules/SalesSummary/types.d.ts +0 -60
  170. package/lib/modules/SalesSummary/types.js +0 -17
  171. package/lib/modules/SalesSummary/utils.d.ts +0 -30
  172. package/lib/modules/SalesSummary/utils.js +0 -420
  173. package/lib/modules/ScanOrderLogger/index.d.ts +0 -23
  174. package/lib/modules/ScanOrderLogger/index.js +0 -147
  175. package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +0 -2
  176. package/lib/modules/ScanOrderLogger/providers/feishu.js +0 -157
  177. package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +0 -2
  178. package/lib/modules/ScanOrderLogger/providers/grafana.js +0 -52
  179. package/lib/modules/ScanOrderLogger/types.d.ts +0 -53
  180. package/lib/modules/ScanOrderLogger/types.js +0 -17
  181. package/lib/solution/ScanOrder/index.d.ts +0 -152
  182. package/lib/solution/ScanOrder/index.js +0 -1901
  183. package/lib/solution/ScanOrder/types.d.ts +0 -287
  184. package/lib/solution/ScanOrder/types.js +0 -36
  185. package/lib/solution/ScanOrder/utils.d.ts +0 -167
  186. package/lib/solution/ScanOrder/utils.js +0 -635
  187. package/lib/solution/VenueBooking/index.d.ts +0 -199
  188. package/lib/solution/VenueBooking/index.js +0 -1926
  189. package/lib/solution/VenueBooking/sales-section-4-annotated.json +0 -343
  190. package/lib/solution/VenueBooking/types.d.ts +0 -154
  191. package/lib/solution/VenueBooking/types.js +0 -44
  192. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +0 -11
  193. package/lib/solution/VenueBooking/utils/dateSummary.js +0 -110
  194. package/lib/solution/VenueBooking/utils/resource.d.ts +0 -14
  195. package/lib/solution/VenueBooking/utils/resource.js +0 -92
  196. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -38
  197. package/lib/solution/VenueBooking/utils/slotMerge.js +0 -237
  198. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -32
  199. package/lib/solution/VenueBooking/utils/timeSlot.js +0 -339
  200. package/lib/solution/VenueBooking/utils.d.ts +0 -1
  201. package/lib/solution/VenueBooking/utils.js +0 -69
@@ -1,11 +1,10 @@
1
- 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; } } }; }
1
+ 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); }
2
2
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
3
  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."); }
4
4
  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); }
5
5
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
6
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
7
7
  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; }
8
- 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); }
9
8
  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; }
10
9
  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; }
11
10
  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; }
@@ -25,17 +24,14 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
25
24
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
26
25
  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); }
27
26
  import { BaseModule } from "../BaseModule";
28
- import { generateDuration, getAllDiscountList, mergeRelationForms, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, filterProductsForScanOrderMore, isTempOrder } from "./utils";
27
+ import { generateDuration, getAllDiscountList, mergeRelationForms } from "./utils";
29
28
  import { isNormalProduct } from "../Product/utils";
30
29
  import dayjs from 'dayjs';
31
- import { buildProductLineFingerprint, getProductIdentityIndex, getSafeProductNum, isIdentityMatch, normalizeOrderProduct } from "../../solution/ScanOrder/utils";
32
- import { DiscountModule } from "../Discount";
33
- import { RulesModule } from "../Rules";
34
- import { UnavailableReason } from "../Rules/types";
35
- import Decimal from 'decimal.js';
36
30
  export var OrderModule = /*#__PURE__*/function (_BaseModule) {
37
31
  _inherits(OrderModule, _BaseModule);
38
32
  var _super = _createSuper(OrderModule);
33
+ // LoggerManager 实例
34
+
39
35
  function OrderModule(name, version) {
40
36
  var _this;
41
37
  _classCallCheck(this, OrderModule);
@@ -45,46 +41,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
45
41
  _defineProperty(_assertThisInitialized(_this), "store", void 0);
46
42
  _defineProperty(_assertThisInitialized(_this), "request", void 0);
47
43
  _defineProperty(_assertThisInitialized(_this), "logger", void 0);
48
- // LoggerManager 实例
49
- _defineProperty(_assertThisInitialized(_this), "window", void 0);
50
- _defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
51
- _defineProperty(_assertThisInitialized(_this), "salesSummaryModuleName", void 0);
52
- _defineProperty(_assertThisInitialized(_this), "rulesHooksOverride", void 0);
53
44
  return _this;
54
45
  }
55
46
  _createClass(OrderModule, [{
56
47
  key: "initialize",
57
48
  value: function () {
58
49
  var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
59
- var _otherParams$rules;
60
- var otherParams, appPlugin, app;
50
+ var appPlugin, app;
61
51
  return _regeneratorRuntime().wrap(function _callee$(_context) {
62
52
  while (1) switch (_context.prev = _context.next) {
63
53
  case 0:
64
54
  this.core = core;
65
55
  this.store = options.store;
66
- if (!this.store.tempOrder) {
67
- this.store.tempOrder = null;
68
- }
69
56
  this.request = this.core.getPlugin('request');
70
- this.window = this.core.getPlugin('window');
71
- otherParams = options.otherParams || {};
72
- this.cacheId = otherParams.cacheId;
73
- this.salesSummaryModuleName = otherParams.salesSummaryModuleName;
74
- this.rulesHooksOverride = (_otherParams$rules = otherParams.rules) === null || _otherParams$rules === void 0 ? void 0 : _otherParams$rules.hooks;
75
- this.registerDiscountModules(options);
76
- this.restoreTempOrderFromStorage();
77
57
  appPlugin = this.core.getPlugin('app');
78
58
  if (appPlugin) {
79
- _context.next = 14;
59
+ _context.next = 6;
80
60
  break;
81
61
  }
82
62
  throw new Error('Order 模块需要 app 插件支持');
83
- case 14:
63
+ case 6:
84
64
  app = appPlugin.getApp();
85
65
  this.logger = app.logger;
86
66
  this.logInfo('OrderModule initialized successfully');
87
- case 17:
67
+ case 9:
88
68
  case "end":
89
69
  return _context.stop();
90
70
  }
@@ -139,719 +119,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
139
119
  });
140
120
  }
141
121
  }
142
-
143
- // ─── Discount: 子模块注册 ───
144
- }, {
145
- key: "registerDiscountModules",
146
- value: function registerDiscountModules(options) {
147
- var _targetCacheData;
148
- var targetCacheData = {};
149
- if (this.cacheId && this.window) {
150
- var sessionData = this.window.sessionStorage.getItem(this.name);
151
- if (sessionData) {
152
- try {
153
- var data = JSON.parse(sessionData);
154
- targetCacheData = (data === null || data === void 0 ? void 0 : data[this.cacheId]) || {};
155
- } catch (_unused) {
156
- // sessionStorage 损坏则忽略,按空 initialState 走
157
- }
158
- }
159
- }
160
- var discount = new DiscountModule("".concat(this.name, "_discount"));
161
- this.core.registerModule(discount, {
162
- initialState: (_targetCacheData = targetCacheData) === null || _targetCacheData === void 0 ? void 0 : _targetCacheData[discount.name],
163
- otherParams: {
164
- fatherModule: this.name,
165
- openCache: !!this.cacheId,
166
- cacheId: this.cacheId
167
- }
168
- });
169
- this.store.discount = discount;
170
- var rules = new RulesModule("".concat(this.name, "_rules"));
171
- this.core.registerModule(rules, {
172
- hooks: this.rulesHooksOverride || this.createDefaultRulesHooks()
173
- });
174
- this.store.rules = rules;
175
- }
176
- }, {
177
- key: "createDefaultRulesHooks",
178
- value: function createDefaultRulesHooks() {
179
- return createDefaultOrderRulesHooks();
180
- }
181
-
182
- // ─── Discount: 公共 API ───
183
- }, {
184
- key: "loadDiscountConfig",
185
- value: function () {
186
- var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
187
- var _this$store$discount, _this$store$tempOrder;
188
- var discountList, _this$store$discount2;
189
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
190
- while (1) switch (_context2.prev = _context2.next) {
191
- case 0:
192
- _context2.next = 2;
193
- return (_this$store$discount = this.store.discount) === null || _this$store$discount === void 0 ? void 0 : _this$store$discount.loadPrepareConfig({
194
- customer_id: params.customerId,
195
- action: params.action || 'create',
196
- with_good_pass: 1,
197
- with_discount_card: 1,
198
- with_wallet_pass_holder: 1,
199
- request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
200
- });
201
- case 2:
202
- discountList = _context2.sent;
203
- if (discountList) {
204
- (_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 || _this$store$discount2.setDiscountList(discountList);
205
- }
206
- if ((_this$store$tempOrder = this.store.tempOrder) !== null && _this$store$tempOrder !== void 0 && (_this$store$tempOrder = _this$store$tempOrder.products) !== null && _this$store$tempOrder !== void 0 && _this$store$tempOrder.length) {
207
- this.applyDiscount();
208
- }
209
- case 5:
210
- case "end":
211
- return _context2.stop();
212
- }
213
- }, _callee2, this);
214
- }));
215
- function loadDiscountConfig(_x3) {
216
- return _loadDiscountConfig.apply(this, arguments);
217
- }
218
- return loadDiscountConfig;
219
- }()
220
- }, {
221
- key: "getDiscountList",
222
- value: function getDiscountList() {
223
- var _this$store$discount3;
224
- return ((_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.getDiscountList()) || [];
225
- }
226
- }, {
227
- key: "scanCode",
228
- value: function () {
229
- var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(code, customerId) {
230
- var _this$store$discount4, _tempOrder$holder, _tempOrder$holder2;
231
- var resultDiscountList, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref, isAvailable, newDiscountList, unavailableReason, _this$store$discount5;
232
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
233
- while (1) switch (_context3.prev = _context3.next) {
234
- case 0:
235
- _context3.next = 2;
236
- return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.batchSearch(code, {
237
- customerId: customerId
238
- });
239
- case 2:
240
- _context3.t0 = _context3.sent;
241
- if (_context3.t0) {
242
- _context3.next = 5;
243
- break;
244
- }
245
- _context3.t0 = [];
246
- case 5:
247
- resultDiscountList = _context3.t0;
248
- rulesModule = this.store.rules;
249
- if (rulesModule) {
250
- _context3.next = 9;
251
- break;
252
- }
253
- return _context3.abrupt("return", {
254
- type: 'clientCalc',
255
- isAvailable: false,
256
- discountList: this.getDiscountList(),
257
- unavailableReason: UnavailableReason.Unknown
258
- });
259
- case 9:
260
- if (resultDiscountList.length) {
261
- _context3.next = 11;
262
- break;
263
- }
264
- return _context3.abrupt("return", {
265
- type: 'server',
266
- isAvailable: false,
267
- discountList: this.getDiscountList()
268
- });
269
- case 11:
270
- withScanList = resultDiscountList.map(function (item) {
271
- return _objectSpread(_objectSpread({}, item), {}, {
272
- isScan: true
273
- });
274
- });
275
- currentSelected = this.getDiscountList().filter(function (n) {
276
- return n.isSelected;
277
- });
278
- if (!(currentSelected.length && currentSelected.some(function (n) {
279
- return withScanList.some(function (m) {
280
- return m.id === n.id;
281
- });
282
- }))) {
283
- _context3.next = 15;
284
- break;
285
- }
286
- return _context3.abrupt("return", {
287
- type: 'clientCalc',
288
- isAvailable: true,
289
- discountList: this.getDiscountList()
290
- });
291
- case 15:
292
- tempOrder = this.store.tempOrder;
293
- holders = tempOrder !== null && tempOrder !== void 0 && (_tempOrder$holder = tempOrder.holder) !== null && _tempOrder$holder !== void 0 && _tempOrder$holder.form_record_id ? [{
294
- form_record_id: tempOrder.holder.form_record_id
295
- }] : [];
296
- _ref = rulesModule.isDiscountListAvailable({
297
- productList: (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || [],
298
- oldDiscountList: this.getDiscountList(),
299
- newDiscountList: withScanList,
300
- holders: holders,
301
- isFormSubject: !!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$holder2 = tempOrder.holder) !== null && _tempOrder$holder2 !== void 0 && _tempOrder$holder2.type) && tempOrder.holder.type === 'form'
302
- }) || {
303
- isAvailable: false,
304
- discountList: this.getDiscountList()
305
- }, isAvailable = _ref.isAvailable, newDiscountList = _ref.discountList, unavailableReason = _ref.unavailableReason;
306
- if (isAvailable && newDiscountList) {
307
- (_this$store$discount5 = this.store.discount) === null || _this$store$discount5 === void 0 || _this$store$discount5.setDiscountList(newDiscountList);
308
- this.applyDiscount();
309
- }
310
- return _context3.abrupt("return", {
311
- type: 'clientCalc',
312
- isAvailable: isAvailable || false,
313
- discountList: newDiscountList || this.getDiscountList(),
314
- unavailableReason: unavailableReason
315
- });
316
- case 20:
317
- case "end":
318
- return _context3.stop();
319
- }
320
- }, _callee3, this);
321
- }));
322
- function scanCode(_x4, _x5) {
323
- return _scanCode.apply(this, arguments);
324
- }
325
- return scanCode;
326
- }()
327
- }, {
328
- key: "applyDiscount",
329
- value: function applyDiscount() {
330
- var _this$store$discount6, _tempOrder$holder3, _tempOrder$holder4;
331
- var tempOrder = this.store.tempOrder;
332
- // 任意 products CRUD 后都应当重算 discount 状态;即使 products 为空,
333
- // 也需要让 Rules.calcDiscount 把 DiscountModule 的 isSelected / isAvailable /
334
- // appliedProductDetails / savedAmount 以及 tempOrder.discount_list 复位。
335
- if (!tempOrder) return;
336
- var rulesModule = this.store.rules;
337
- if (!rulesModule) return;
338
- var discountList = ((_this$store$discount6 = this.store.discount) === null || _this$store$discount6 === void 0 ? void 0 : _this$store$discount6.getDiscountList()) || [];
339
- var holders = (_tempOrder$holder3 = tempOrder.holder) !== null && _tempOrder$holder3 !== void 0 && _tempOrder$holder3.form_record_id ? [{
340
- form_record_id: tempOrder.holder.form_record_id
341
- }] : [];
342
- var result = rulesModule.calcDiscount({
343
- productList: tempOrder.products,
344
- discountList: discountList,
345
- holders: holders,
346
- isFormSubject: !!((_tempOrder$holder4 = tempOrder.holder) !== null && _tempOrder$holder4 !== void 0 && _tempOrder$holder4.type) && tempOrder.holder.type === 'form'
347
- });
348
- if (result !== null && result !== void 0 && result.productList) {
349
- tempOrder.products = result.productList;
350
- }
351
- if (result !== null && result !== void 0 && result.discountList) {
352
- var _this$store$discount7;
353
- OrderModule.populateSavedAmounts(result.productList || tempOrder.products, result.discountList);
354
- (_this$store$discount7 = this.store.discount) === null || _this$store$discount7 === void 0 || _this$store$discount7.setDiscountList(result.discountList);
355
- tempOrder.discount_list = result.discountList.filter(function (d) {
356
- return d.isSelected;
357
- });
358
- }
359
- }
360
-
361
- // ─── TempOrder: 初始化入口 ───
362
- }, {
363
- key: "initTempOrder",
364
- value: function initTempOrder(params) {
365
- if (params.cacheId !== undefined) this.cacheId = params.cacheId;
366
- if (params.salesSummaryModuleName !== undefined) this.salesSummaryModuleName = params.salesSummaryModuleName;
367
- this.restoreTempOrderFromStorage();
368
- }
369
-
370
- // ─── TempOrder: localStorage 持久化 ───
371
- }, {
372
- key: "getTempOrderStorageKey",
373
- value: function getTempOrderStorageKey() {
374
- if (!this.cacheId) return null;
375
- return "scanOrder:tempOrder:".concat(this.cacheId);
376
- }
377
- }, {
378
- key: "restoreTempOrderFromStorage",
379
- value: function restoreTempOrderFromStorage() {
380
- var key = this.getTempOrderStorageKey();
381
- if (!key) return;
382
- if (!this.window) return;
383
- var cachedData = this.window.localStorage.getItem(key);
384
- if (!cachedData) return;
385
- try {
386
- var parsedData = JSON.parse(cachedData);
387
- if (!isTempOrder(parsedData)) {
388
- this.window.localStorage.removeItem(key);
389
- return;
390
- }
391
- if (Array.isArray(parsedData.products)) {
392
- for (var i = 0; i < parsedData.products.length; i++) {
393
- var p = parsedData.products[i];
394
- if (!p || _typeof(p) !== 'object') continue;
395
- if (!Array.isArray(p.product_option_item)) {
396
- p.product_option_item = [];
397
- }
398
- if (!Array.isArray(p.product_bundle)) {
399
- p.product_bundle = [];
400
- }
401
- // 不透明 identity 契约:旧缓存里可能没有 identity_key,
402
- // 此处统一回填 UUID 并同步 metadata.unique_identification_number,
403
- // 避免升级后 UI 侧持有的 rowKey 找不到对应行。
404
- var row = p;
405
- if (typeof row.identity_key !== 'string' || row.identity_key.length === 0) {
406
- var newKey = createUuidV4();
407
- row.identity_key = newKey;
408
- if (!row.metadata || _typeof(row.metadata) !== 'object') {
409
- row.metadata = {};
410
- }
411
- if (!row.metadata.unique_identification_number) {
412
- row.metadata.unique_identification_number = newKey;
413
- }
414
- }
415
- // 价格 schema 迁移:重跑 normalizeOrderProduct。
416
- // `metadata.price_schema_version === 2` → 已是新语义,保留现有 main_product_* 折扣;
417
- // 否则(v1 或无 metadata)→ 走 legacyDiscount 反推分支,基于新的 source + options
418
- // 重算出含 option 的 main_product_*,并打上 price_schema_version: 2。
419
- // 幂等:多次 restore 不会重复叠加 option/bundle。
420
- parsedData.products[i] = normalizeOrderProduct(row);
421
- }
422
- }
423
- this.store.tempOrder = parsedData;
424
- } catch (_unused2) {
425
- var _this$window;
426
- (_this$window = this.window) === null || _this$window === void 0 || (_this$window = _this$window.localStorage) === null || _this$window === void 0 || _this$window.removeItem(key);
427
- }
428
- }
429
- }, {
430
- key: "persistTempOrder",
431
- value: function persistTempOrder() {
432
- var key = this.getTempOrderStorageKey();
433
- if (!key || !this.store.tempOrder) return;
434
- if (!this.window) return;
435
- this.window.localStorage.setItem(key, JSON.stringify(this.store.tempOrder));
436
- }
437
-
438
- // ─── TempOrder: 创建 & 获取 ───
439
- }, {
440
- key: "createDefaultTempOrderInstance",
441
- value: function createDefaultTempOrderInstance() {
442
- return createDefaultTempOrder({
443
- now: formatDateTime(new Date()),
444
- summary: createEmptySummary()
445
- });
446
- }
447
- }, {
448
- key: "ensureTempOrder",
449
- value: function ensureTempOrder() {
450
- if (this.store.tempOrder) return this.store.tempOrder;
451
- var newOrder = this.createDefaultTempOrderInstance();
452
- this.store.tempOrder = newOrder;
453
- this.persistTempOrder();
454
- return newOrder;
455
- }
456
- }, {
457
- key: "restoreOrder",
458
- value: function restoreOrder() {
459
- var freshTempOrder = this.createDefaultTempOrderInstance();
460
- this.store.tempOrder = freshTempOrder;
461
- this.persistTempOrder();
462
- return freshTempOrder;
463
- }
464
- }, {
465
- key: "getTempOrder",
466
- value: function getTempOrder() {
467
- return this.store.tempOrder;
468
- }
469
- }, {
470
- key: "addNewOrder",
471
- value: function () {
472
- var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
473
- var tempOrder;
474
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
475
- while (1) switch (_context4.prev = _context4.next) {
476
- case 0:
477
- tempOrder = this.ensureTempOrder();
478
- _context4.next = 3;
479
- return this.recalculateSummary({
480
- createIfMissing: true
481
- });
482
- case 3:
483
- this.persistTempOrder();
484
- return _context4.abrupt("return", tempOrder);
485
- case 5:
486
- case "end":
487
- return _context4.stop();
488
- }
489
- }, _callee4, this);
490
- }));
491
- function addNewOrder() {
492
- return _addNewOrder.apply(this, arguments);
493
- }
494
- return addNewOrder;
495
- }()
496
- }, {
497
- key: "getOrderProducts",
498
- value: function getOrderProducts() {
499
- var tempOrder = this.ensureTempOrder();
500
- return tempOrder.products;
501
- }
502
-
503
- // ─── TempOrder: 金额汇总 ───
504
- }, {
505
- key: "getSalesSummary",
506
- value: function getSalesSummary() {
507
- if (!this.salesSummaryModuleName) return null;
508
- return this.core.getModule(this.salesSummaryModuleName);
509
- }
510
- }, {
511
- key: "recalculateSummary",
512
- value: function () {
513
- var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(options) {
514
- var tempOrder, salesSummary, summary;
515
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
516
- while (1) switch (_context5.prev = _context5.next) {
517
- case 0:
518
- tempOrder = options !== null && options !== void 0 && options.createIfMissing ? this.ensureTempOrder() : this.store.tempOrder;
519
- if (tempOrder) {
520
- _context5.next = 3;
521
- break;
522
- }
523
- return _context5.abrupt("return", null);
524
- case 3:
525
- salesSummary = this.getSalesSummary();
526
- if (salesSummary) {
527
- _context5.next = 8;
528
- break;
529
- }
530
- tempOrder.summary = createEmptySummary();
531
- tempOrder.surcharge_fee = tempOrder.summary.surcharge_fee;
532
- return _context5.abrupt("return", tempOrder.summary);
533
- case 8:
534
- _context5.next = 10;
535
- return salesSummary.getSummary({
536
- products: tempOrder.products
537
- });
538
- case 10:
539
- summary = _context5.sent;
540
- tempOrder.summary = summary;
541
- if (summary.is_price_include_tax !== undefined) {
542
- tempOrder.is_price_include_tax = summary.is_price_include_tax;
543
- }
544
- if (typeof summary.tax_title === 'string') {
545
- tempOrder.tax_title = summary.tax_title;
546
- }
547
- tempOrder.surcharge_fee = summary.surcharge_fee;
548
- tempOrder.surcharges = summary.surcharges || [];
549
- tempOrder.deposit_amount = summary.deposit_amount || '0.00';
550
- tempOrder.is_deposit = summary.deposit_amount !== '0.00' ? 1 : 0;
551
- tempOrder.shop_discount = summary.discount_amount || '0.00';
552
- return _context5.abrupt("return", tempOrder.summary);
553
- case 20:
554
- case "end":
555
- return _context5.stop();
556
- }
557
- }, _callee5, this);
558
- }));
559
- function recalculateSummary(_x6) {
560
- return _recalculateSummary.apply(this, arguments);
561
- }
562
- return recalculateSummary;
563
- }()
564
- }, {
565
- key: "getScanOrderSummary",
566
- value: function () {
567
- var _getScanOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
568
- var summary;
569
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
570
- while (1) switch (_context6.prev = _context6.next) {
571
- case 0:
572
- _context6.next = 2;
573
- return this.recalculateSummary({
574
- createIfMissing: true
575
- });
576
- case 2:
577
- summary = _context6.sent;
578
- if (summary) {
579
- _context6.next = 5;
580
- break;
581
- }
582
- return _context6.abrupt("return", createEmptySummary());
583
- case 5:
584
- this.persistTempOrder();
585
- return _context6.abrupt("return", summary);
586
- case 7:
587
- case "end":
588
- return _context6.stop();
589
- }
590
- }, _callee6, this);
591
- }));
592
- function getScanOrderSummary() {
593
- return _getScanOrderSummary.apply(this, arguments);
594
- }
595
- return getScanOrderSummary;
596
- }() // ─── TempOrder: 备注 ───
597
- }, {
598
- key: "updateTempOrderNote",
599
- value: function updateTempOrderNote(note) {
600
- var tempOrder = this.ensureTempOrder();
601
- tempOrder.note = String(note || '');
602
- this.persistTempOrder();
603
- return tempOrder.note;
604
- }
605
- }, {
606
- key: "updateTempOrderBuzzer",
607
- value: function updateTempOrderBuzzer(buzzer) {
608
- var tempOrder = this.ensureTempOrder();
609
- tempOrder.buzzer = String(buzzer || '');
610
- this.persistTempOrder();
611
- return tempOrder.buzzer;
612
- }
613
- }, {
614
- key: "updateTempOrderContactsInfo",
615
- value: function updateTempOrderContactsInfo(contactsInfo) {
616
- var tempOrder = this.ensureTempOrder();
617
- tempOrder.contacts_info = Array.isArray(contactsInfo) ? contactsInfo : [];
618
- this.persistTempOrder();
619
- return tempOrder.contacts_info;
620
- }
621
-
622
- // ─── TempOrder: 商品 CRUD ───
623
- }, {
624
- key: "addProductToOrder",
625
- value: function () {
626
- var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(product) {
627
- var tempOrder, hasExplicitIdentityKey, normalizedProduct, productIndex, targetProduct, incomingFingerprint, matchedIndex, _normalizedProduct, _targetProduct, _normalizedProduct2;
628
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
629
- while (1) switch (_context7.prev = _context7.next) {
630
- case 0:
631
- tempOrder = this.ensureTempOrder();
632
- hasExplicitIdentityKey = typeof product.identity_key === 'string' && product.identity_key.length > 0;
633
- if (hasExplicitIdentityKey) {
634
- // 调用方自持 identity_key(如 VenueBooking 外部生成)→ 走严格 identity 合并。
635
- normalizedProduct = normalizeOrderProduct(product);
636
- productIndex = getProductIdentityIndex(tempOrder.products, normalizedProduct);
637
- if (productIndex === -1) {
638
- tempOrder.products.push(normalizedProduct);
639
- } else {
640
- targetProduct = tempOrder.products[productIndex];
641
- tempOrder.products[productIndex] = _objectSpread(_objectSpread(_objectSpread({}, targetProduct), normalizedProduct), {}, {
642
- num: getSafeProductNum(targetProduct.num + normalizedProduct.num),
643
- _origin: normalizedProduct._origin || targetProduct._origin
644
- });
645
- }
646
- } else {
647
- // 无 identity_key:按 SKU + 内容指纹(options + bundle)匹配既有行以累加数量;
648
- // 命中时保留已有 identity_key,未命中才由 normalizeOrderProduct 自动生成 UUID。
649
- incomingFingerprint = buildProductLineFingerprint(product.product_option_item, product.product_bundle);
650
- matchedIndex = tempOrder.products.findIndex(function (item) {
651
- if (item.product_id !== product.product_id) return false;
652
- if (item.product_variant_id !== product.product_variant_id) return false;
653
- var existedFingerprint = buildProductLineFingerprint(item.product_option_item, item.product_bundle);
654
- return existedFingerprint === incomingFingerprint;
655
- });
656
- if (matchedIndex === -1) {
657
- _normalizedProduct = normalizeOrderProduct(product);
658
- tempOrder.products.push(_normalizedProduct);
659
- } else {
660
- _targetProduct = tempOrder.products[matchedIndex];
661
- _normalizedProduct2 = normalizeOrderProduct(_objectSpread(_objectSpread({}, product), {}, {
662
- identity_key: _targetProduct.identity_key
663
- }));
664
- tempOrder.products[matchedIndex] = _objectSpread(_objectSpread(_objectSpread({}, _targetProduct), _normalizedProduct2), {}, {
665
- identity_key: _targetProduct.identity_key,
666
- num: getSafeProductNum(_targetProduct.num + _normalizedProduct2.num),
667
- _origin: _normalizedProduct2._origin || _targetProduct._origin
668
- });
669
- }
670
- }
671
- this.applyDiscount();
672
- _context7.next = 6;
673
- return this.recalculateSummary({
674
- createIfMissing: true
675
- });
676
- case 6:
677
- this.persistTempOrder();
678
- return _context7.abrupt("return", tempOrder.products);
679
- case 8:
680
- case "end":
681
- return _context7.stop();
682
- }
683
- }, _callee7, this);
684
- }));
685
- function addProductToOrder(_x7) {
686
- return _addProductToOrder.apply(this, arguments);
687
- }
688
- return addProductToOrder;
689
- }()
690
- }, {
691
- key: "updateProductInOrder",
692
- value: function () {
693
- var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params) {
694
- var _metadata, _metadata2, _metadata3;
695
- var product_id, product_variant_id, updates, identity_key, product_option_item, product_bundle, tempOrder, identityLookup, productIndex, targetProduct, nextProduct, callerUpdatesTopPrice, callerUpdatesMainMeta, existedMeta;
696
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
697
- while (1) switch (_context8.prev = _context8.next) {
698
- case 0:
699
- product_id = params.product_id, product_variant_id = params.product_variant_id, updates = params.updates, identity_key = params.identity_key, product_option_item = params.product_option_item, product_bundle = params.product_bundle;
700
- tempOrder = this.ensureTempOrder();
701
- identityLookup = {
702
- product_id: product_id,
703
- product_variant_id: product_variant_id
704
- };
705
- if (identity_key !== undefined) identityLookup.identity_key = identity_key;
706
- if (product_option_item !== undefined) identityLookup.product_option_item = product_option_item;
707
- if (product_bundle !== undefined) identityLookup.product_bundle = product_bundle;
708
- productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
709
- if (!(productIndex === -1)) {
710
- _context8.next = 9;
711
- break;
712
- }
713
- throw new Error('[Order] 目标商品不存在,无法更新');
714
- case 9:
715
- targetProduct = tempOrder.products[productIndex];
716
- nextProduct = _objectSpread(_objectSpread(_objectSpread({}, targetProduct), updates), {}, {
717
- product_id: product_id,
718
- product_variant_id: product_variant_id
719
- });
720
- nextProduct.num = getSafeProductNum(nextProduct.num);
721
- // 兜底:caller 通过 updates 直接改了 selling_price / original_price 时,
722
- // 视为 "重新给 source-level 主价"(caller 侧旧约定仍是 main-only 单价)。
723
- // 清掉 metadata 里的 source_product_price / main_product_* / price_schema_version,
724
- // 让 normalize 把顶层 selling_price 当作 source 来重算 main_original(=source+options) /
725
- // main_selling / composite;否则旧 metadata 会反压顶层新值,触发口径不一致。
726
- // 如果 caller 走推荐路径(updates.metadata.* 显式指定主价),保留 metadata 由 normalize 认它。
727
- callerUpdatesTopPrice = Object.prototype.hasOwnProperty.call(updates || {}, 'selling_price') || Object.prototype.hasOwnProperty.call(updates || {}, 'original_price');
728
- callerUpdatesMainMeta = (updates === null || updates === void 0 || (_metadata = updates.metadata) === null || _metadata === void 0 ? void 0 : _metadata.main_product_selling_price) !== undefined || (updates === null || updates === void 0 || (_metadata2 = updates.metadata) === null || _metadata2 === void 0 ? void 0 : _metadata2.main_product_original_price) !== undefined || (updates === null || updates === void 0 || (_metadata3 = updates.metadata) === null || _metadata3 === void 0 ? void 0 : _metadata3.source_product_price) !== undefined;
729
- if (callerUpdatesTopPrice && !callerUpdatesMainMeta) {
730
- existedMeta = nextProduct.metadata || {};
731
- nextProduct.metadata = _objectSpread({}, existedMeta);
732
- delete nextProduct.metadata.source_product_price;
733
- delete nextProduct.metadata.main_product_selling_price;
734
- delete nextProduct.metadata.main_product_original_price;
735
- delete nextProduct.metadata.price_schema_version;
736
- }
737
- // normalizeOrderProduct 幂等:v2 metadata 存在 → 保留 main_product_* 折扣重算 composite;
738
- // 否则 → 把顶层 selling_price 视作 source,派生 main_product_* 并写 price_schema_version: 2。
739
- tempOrder.products[productIndex] = normalizeOrderProduct(nextProduct);
740
- this.applyDiscount();
741
- _context8.next = 19;
742
- return this.recalculateSummary({
743
- createIfMissing: true
744
- });
745
- case 19:
746
- this.persistTempOrder();
747
- return _context8.abrupt("return", tempOrder.products);
748
- case 21:
749
- case "end":
750
- return _context8.stop();
751
- }
752
- }, _callee8, this);
753
- }));
754
- function updateProductInOrder(_x8) {
755
- return _updateProductInOrder.apply(this, arguments);
756
- }
757
- return updateProductInOrder;
758
- }()
759
- }, {
760
- key: "removeProductFromOrder",
761
- value: function () {
762
- var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(identity) {
763
- var tempOrder;
764
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
765
- while (1) switch (_context9.prev = _context9.next) {
766
- case 0:
767
- tempOrder = this.ensureTempOrder();
768
- tempOrder.products = tempOrder.products.filter(function (item) {
769
- return !isIdentityMatch(item, identity);
770
- });
771
- this.applyDiscount();
772
- _context9.next = 5;
773
- return this.recalculateSummary({
774
- createIfMissing: true
775
- });
776
- case 5:
777
- this.persistTempOrder();
778
- return _context9.abrupt("return", tempOrder.products);
779
- case 7:
780
- case "end":
781
- return _context9.stop();
782
- }
783
- }, _callee9, this);
784
- }));
785
- function removeProductFromOrder(_x9) {
786
- return _removeProductFromOrder.apply(this, arguments);
787
- }
788
- return removeProductFromOrder;
789
- }() // ─── TempOrder: 提交 ───
790
- }, {
791
- key: "submitTempOrder",
792
- value: function () {
793
- var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
794
- var _params$cacheId;
795
- var tempOrder, effectiveCacheId, payload, result, products, moreResult;
796
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
797
- while (1) switch (_context10.prev = _context10.next) {
798
- case 0:
799
- tempOrder = this.ensureTempOrder();
800
- this.persistTempOrder();
801
- effectiveCacheId = (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId;
802
- payload = buildSubmitPayload({
803
- tempOrder: tempOrder,
804
- cacheId: effectiveCacheId,
805
- platform: params === null || params === void 0 ? void 0 : params.platform,
806
- businessCode: params === null || params === void 0 ? void 0 : params.businessCode,
807
- channel: params === null || params === void 0 ? void 0 : params.channel,
808
- type: params === null || params === void 0 ? void 0 : params.type,
809
- enhance: params === null || params === void 0 ? void 0 : params.enhancePayload
810
- });
811
- if (!tempOrder.order_id) {
812
- _context10.next = 12;
813
- break;
814
- }
815
- products = filterProductsForScanOrderMore(payload.products);
816
- _context10.next = 8;
817
- return this.scanOrderMore({
818
- query: {
819
- order_id: tempOrder.order_id,
820
- products: products,
821
- request_unique_idempotency_token: payload.request_unique_idempotency_token
822
- }
823
- });
824
- case 8:
825
- moreResult = _context10.sent;
826
- if (moreResult.code === 200) {
827
- result = {
828
- data: {
829
- order_id: tempOrder.order_id
830
- }
831
- };
832
- }
833
- _context10.next = 15;
834
- break;
835
- case 12:
836
- _context10.next = 14;
837
- return this.submitScanOrder({
838
- query: payload
839
- });
840
- case 14:
841
- result = _context10.sent;
842
- case 15:
843
- return _context10.abrupt("return", result);
844
- case 16:
845
- case "end":
846
- return _context10.stop();
847
- }
848
- }, _callee10, this);
849
- }));
850
- function submitTempOrder(_x10) {
851
- return _submitTempOrder.apply(this, arguments);
852
- }
853
- return submitTempOrder;
854
- }()
855
122
  }, {
856
123
  key: "createOrder",
857
124
  value: function createOrder(params) {
@@ -936,11 +203,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
936
203
  }, {
937
204
  key: "submitOrder",
938
205
  value: function () {
939
- var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(order) {
206
+ var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(order) {
940
207
  var _order$query$cartItem, _params$bookings, _params$relation_prod;
941
208
  var url, query, fetchUrl, params;
942
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
943
- while (1) switch (_context11.prev = _context11.next) {
209
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
210
+ while (1) switch (_context2.prev = _context2.next) {
944
211
  case 0:
945
212
  this.logInfo('submitOrder called', {
946
213
  url: order.url,
@@ -960,14 +227,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
960
227
  relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
961
228
  scheduleDate: params.schedule_date
962
229
  });
963
- return _context11.abrupt("return", this.request.post(fetchUrl, params));
230
+ return _context2.abrupt("return", this.request.post(fetchUrl, params));
964
231
  case 6:
965
232
  case "end":
966
- return _context11.stop();
233
+ return _context2.stop();
967
234
  }
968
- }, _callee11, this);
235
+ }, _callee2, this);
969
236
  }));
970
- function submitOrder(_x11) {
237
+ function submitOrder(_x3) {
971
238
  return _submitOrder.apply(this, arguments);
972
239
  }
973
240
  return submitOrder;
@@ -985,11 +252,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
985
252
  }, {
986
253
  key: "createOrderByCheckout",
987
254
  value: (function () {
988
- var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(params) {
255
+ var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
989
256
  var _params$bookings2, _params$relation_prod2, _params$payments, _params$payments2, _params$bookings3, _params$relation_prod3, _params$payments3;
990
257
  var _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, _orderData$bookings2, _orderData$relation_p2, _orderData$payments4, _orderData$payments5, _response$data, orderData, response;
991
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
992
- while (1) switch (_context12.prev = _context12.next) {
258
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
259
+ while (1) switch (_context3.prev = _context3.next) {
993
260
  case 0:
994
261
  this.logInfo('createOrderByCheckout called', {
995
262
  type: params.type,
@@ -1018,7 +285,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1018
285
  relationProductsCount: ((_params$relation_prod3 = params.relation_products) === null || _params$relation_prod3 === void 0 ? void 0 : _params$relation_prod3.length) || 0,
1019
286
  paymentsCount: ((_params$payments3 = params.payments) === null || _params$payments3 === void 0 ? void 0 : _params$payments3.length) || 0
1020
287
  });
1021
- _context12.prev = 2;
288
+ _context3.prev = 2;
1022
289
  // 构建订单数据,设置默认值并允许 params 覆盖
1023
290
  orderData = _objectSpread({
1024
291
  sales_channel: 'my_pisel',
@@ -1082,10 +349,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1082
349
  });
1083
350
 
1084
351
  // 调用后端接口
1085
- _context12.next = 10;
352
+ _context3.next = 10;
1086
353
  return this.request.post('/order/checkout', orderData);
1087
354
  case 10:
1088
- response = _context12.sent;
355
+ response = _context3.sent;
1089
356
  this.logInfo('Order API called successfully', {
1090
357
  response: response
1091
358
  });
@@ -1093,164 +360,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1093
360
  success: !!response,
1094
361
  hasOrderId: !!(response !== null && response !== void 0 && (_response$data = response.data) !== null && _response$data !== void 0 && _response$data.order_id || response !== null && response !== void 0 && response.order_id)
1095
362
  });
1096
- return _context12.abrupt("return", response);
363
+ return _context3.abrupt("return", response);
1097
364
  case 16:
1098
- _context12.prev = 16;
1099
- _context12.t0 = _context12["catch"](2);
1100
- console.error('[Order] createOrderByCheckout 创建订单失败:', _context12.t0);
365
+ _context3.prev = 16;
366
+ _context3.t0 = _context3["catch"](2);
367
+ console.error('[Order] createOrderByCheckout 创建订单失败:', _context3.t0);
1101
368
  this.logInfo('Order API called failed', {
1102
- error: _context12.t0 instanceof Error ? _context12.t0.message : String(_context12.t0)
369
+ error: _context3.t0 instanceof Error ? _context3.t0.message : String(_context3.t0)
1103
370
  });
1104
- throw _context12.t0;
371
+ throw _context3.t0;
1105
372
  case 21:
1106
373
  case "end":
1107
- return _context12.stop();
374
+ return _context3.stop();
1108
375
  }
1109
- }, _callee12, this, [[2, 16]]);
376
+ }, _callee3, this, [[2, 16]]);
1110
377
  }));
1111
- function createOrderByCheckout(_x12) {
378
+ function createOrderByCheckout(_x4) {
1112
379
  return _createOrderByCheckout.apply(this, arguments);
1113
380
  }
1114
381
  return createOrderByCheckout;
1115
382
  }())
1116
- }, {
1117
- key: "submitScanOrder",
1118
- value: function () {
1119
- var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(params) {
1120
- var url, query, fetchUrl;
1121
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1122
- while (1) switch (_context13.prev = _context13.next) {
1123
- case 0:
1124
- url = params.url, query = params.query;
1125
- fetchUrl = url || '/order/sales/checkout';
1126
- return _context13.abrupt("return", this.request.post(fetchUrl, query, {
1127
- customToast: function customToast() {}
1128
- }));
1129
- case 3:
1130
- case "end":
1131
- return _context13.stop();
1132
- }
1133
- }, _callee13, this);
1134
- }));
1135
- function submitScanOrder(_x13) {
1136
- return _submitScanOrder.apply(this, arguments);
1137
- }
1138
- return submitScanOrder;
1139
- }()
1140
- }, {
1141
- key: "scanOrderMore",
1142
- value: function () {
1143
- var _scanOrderMore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(params) {
1144
- var url, query, fetchUrl, requestBody;
1145
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1146
- while (1) switch (_context14.prev = _context14.next) {
1147
- case 0:
1148
- url = params.url, query = params.query;
1149
- fetchUrl = url || "/order/order/product/".concat(query.order_id);
1150
- requestBody = {
1151
- products: query.products,
1152
- request_unique_idempotency_token: query.request_unique_idempotency_token
1153
- };
1154
- return _context14.abrupt("return", this.request.put(fetchUrl, requestBody, {
1155
- customToast: function customToast() {}
1156
- }));
1157
- case 4:
1158
- case "end":
1159
- return _context14.stop();
1160
- }
1161
- }, _callee14, this);
1162
- }));
1163
- function scanOrderMore(_x14) {
1164
- return _scanOrderMore.apply(this, arguments);
1165
- }
1166
- return scanOrderMore;
1167
- }() // TODO 获取详情的接口
1168
- }, {
1169
- key: "getOrderInfoByRemote",
1170
- value: function () {
1171
- var _getOrderInfoByRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(order_id) {
1172
- var res;
1173
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1174
- while (1) switch (_context15.prev = _context15.next) {
1175
- case 0:
1176
- _context15.next = 2;
1177
- return this.request.get("/order/sales/".concat(order_id), {
1178
- with: ['products', 'scheduleEvents']
1179
- });
1180
- case 2:
1181
- res = _context15.sent;
1182
- if (res.code === 200 && this.store.tempOrder) {
1183
- this.store.tempOrder.lastOrderInfo = res.data;
1184
- }
1185
- return _context15.abrupt("return", res);
1186
- case 5:
1187
- case "end":
1188
- return _context15.stop();
1189
- }
1190
- }, _callee15, this);
1191
- }));
1192
- function getOrderInfoByRemote(_x15) {
1193
- return _getOrderInfoByRemote.apply(this, arguments);
1194
- }
1195
- return getOrderInfoByRemote;
1196
- }()
1197
- }, {
1198
- key: "getLastOrderInfo",
1199
- value: function getLastOrderInfo() {
1200
- var _this$store;
1201
- return (_this$store = this.store) === null || _this$store === void 0 || (_this$store = _this$store.tempOrder) === null || _this$store === void 0 ? void 0 : _this$store.lastOrderInfo;
1202
- }
1203
- }], [{
1204
- key: "populateSavedAmounts",
1205
- value:
1206
- /**
1207
- * Populate `savedAmount` on each discount based on product-level discount details.
1208
- * Only selected discounts get a non-zero value.
1209
- */
1210
- function populateSavedAmounts(productList, discountList) {
1211
- var savedMap = new Map();
1212
- var _iterator = _createForOfIteratorHelper(productList),
1213
- _step;
1214
- try {
1215
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
1216
- var product = _step.value;
1217
- var qty = product.num || 1;
1218
- var _iterator3 = _createForOfIteratorHelper(product.discount_list || []),
1219
- _step3;
1220
- try {
1221
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
1222
- var _pd$discount, _pd$metadata;
1223
- var pd = _step3.value;
1224
- var discountKey = ((_pd$discount = pd.discount) === null || _pd$discount === void 0 ? void 0 : _pd$discount.resource_id) || pd.id;
1225
- if (discountKey == null) continue;
1226
- var amount = new Decimal(pd.amount || 0).times(qty).plus(((_pd$metadata = pd.metadata) === null || _pd$metadata === void 0 ? void 0 : _pd$metadata.product_discount_difference) || 0);
1227
- savedMap.set(discountKey, (savedMap.get(discountKey) || new Decimal(0)).plus(amount));
1228
- }
1229
- } catch (err) {
1230
- _iterator3.e(err);
1231
- } finally {
1232
- _iterator3.f();
1233
- }
1234
- }
1235
- } catch (err) {
1236
- _iterator.e(err);
1237
- } finally {
1238
- _iterator.f();
1239
- }
1240
- var _iterator2 = _createForOfIteratorHelper(discountList),
1241
- _step2;
1242
- try {
1243
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
1244
- var d = _step2.value;
1245
- var key = d.id;
1246
- d.savedAmount = d.isSelected && key != null && savedMap.has(key) ? savedMap.get(key).toNumber() : 0;
1247
- }
1248
- } catch (err) {
1249
- _iterator2.e(err);
1250
- } finally {
1251
- _iterator2.f();
1252
- }
1253
- }
1254
383
  }]);
1255
384
  return OrderModule;
1256
385
  }(BaseModule);