@pisell/pisellos 2.1.151 → 2.1.152

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