@pisell/pisellos 2.2.261 → 2.2.263

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 (134) hide show
  1. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
  2. package/dist/model/strategy/adapter/dataVariant/adapter.js +167 -0
  3. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
  4. package/dist/model/strategy/adapter/dataVariant/evaluator.js +780 -0
  5. package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  6. package/dist/model/strategy/adapter/dataVariant/examples.js +277 -0
  7. package/dist/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  8. package/dist/model/strategy/adapter/dataVariant/index.js +4 -0
  9. package/dist/model/strategy/adapter/dataVariant/type.d.ts +148 -0
  10. package/dist/model/strategy/adapter/dataVariant/type.js +54 -0
  11. package/dist/model/strategy/adapter/index.d.ts +4 -0
  12. package/dist/model/strategy/adapter/index.js +5 -1
  13. package/dist/model/strategy/adapter/promotion/adapter.d.ts +0 -4
  14. package/dist/model/strategy/adapter/promotion/adapter.js +0 -23
  15. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
  16. package/dist/model/strategy/adapter/promotion/evaluator.js +6 -279
  17. package/dist/model/strategy/adapter/promotion/examples.d.ts +0 -86
  18. package/dist/model/strategy/adapter/promotion/examples.js +0 -99
  19. package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
  20. package/dist/model/strategy/adapter/promotion/index.js +1 -1
  21. package/dist/model/strategy/adapter/promotion/type.d.ts +2 -90
  22. package/dist/model/strategy/adapter/promotion/type.js +0 -45
  23. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +16 -10
  24. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
  25. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
  26. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +32 -1
  27. package/dist/modules/Discount/index.d.ts +5 -2
  28. package/dist/modules/Discount/index.js +30 -7
  29. package/dist/modules/Discount/types.d.ts +4 -0
  30. package/dist/modules/Order/index.d.ts +14 -2
  31. package/dist/modules/Order/index.js +1035 -736
  32. package/dist/modules/Order/types.d.ts +16 -0
  33. package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
  34. package/dist/modules/Order/utils/orderCollectionIdentity.js +405 -0
  35. package/dist/modules/Order/utils.d.ts +4 -3
  36. package/dist/modules/Order/utils.js +54 -61
  37. package/dist/modules/Product/types.d.ts +22 -0
  38. package/dist/modules/ProductList/index.d.ts +1 -1
  39. package/dist/modules/ProductList/index.js +4 -2
  40. package/dist/modules/ProductList/types.d.ts +2 -0
  41. package/dist/modules/Rules/index.d.ts +2 -9
  42. package/dist/modules/Rules/index.js +69 -43
  43. package/dist/modules/Rules/types.d.ts +10 -1
  44. package/dist/server/index.d.ts +55 -0
  45. package/dist/server/index.js +1173 -753
  46. package/dist/server/modules/order/index.d.ts +10 -4
  47. package/dist/server/modules/order/index.js +404 -399
  48. package/dist/server/modules/order/types.d.ts +4 -0
  49. package/dist/server/modules/products/index.d.ts +31 -8
  50. package/dist/server/modules/products/index.js +549 -390
  51. package/dist/server/modules/products/types.d.ts +18 -0
  52. package/dist/solution/BaseSales/index.d.ts +21 -1
  53. package/dist/solution/BaseSales/index.js +1136 -789
  54. package/dist/solution/BaseSales/types.d.ts +6 -1
  55. package/dist/solution/BaseSales/types.js +1 -1
  56. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
  57. package/dist/solution/BaseSales/utils/cartPromotion.js +48 -81
  58. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
  59. package/dist/solution/BaseSales/utils/parseSalesResponse.js +6 -8
  60. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +14 -1
  61. package/dist/solution/BookingByStep/index.d.ts +1 -1
  62. package/dist/solution/BookingTicket/index.d.ts +1 -1
  63. package/dist/solution/BookingTicket/index.js +59 -25
  64. package/dist/solution/BookingTicket/types.d.ts +2 -0
  65. package/dist/solution/ScanOrder/index.js +20 -31
  66. package/dist/solution/ShopDiscount/index.js +15 -14
  67. package/dist/solution/VenueBooking/index.js +19 -30
  68. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
  69. package/lib/model/strategy/adapter/dataVariant/adapter.js +149 -0
  70. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
  71. package/lib/model/strategy/adapter/dataVariant/evaluator.js +583 -0
  72. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  73. package/lib/model/strategy/adapter/dataVariant/examples.js +293 -0
  74. package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  75. package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
  76. package/lib/model/strategy/adapter/dataVariant/type.d.ts +148 -0
  77. package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
  78. package/lib/model/strategy/adapter/index.d.ts +4 -0
  79. package/lib/model/strategy/adapter/index.js +13 -2
  80. package/lib/model/strategy/adapter/promotion/adapter.d.ts +0 -4
  81. package/lib/model/strategy/adapter/promotion/adapter.js +0 -20
  82. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
  83. package/lib/model/strategy/adapter/promotion/evaluator.js +0 -235
  84. package/lib/model/strategy/adapter/promotion/examples.d.ts +0 -86
  85. package/lib/model/strategy/adapter/promotion/examples.js +0 -91
  86. package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
  87. package/lib/model/strategy/adapter/promotion/index.js +0 -51
  88. package/lib/model/strategy/adapter/promotion/type.d.ts +2 -90
  89. package/lib/model/strategy/adapter/promotion/type.js +0 -2
  90. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -0
  91. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -0
  92. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
  93. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +23 -2
  94. package/lib/modules/Discount/index.d.ts +5 -2
  95. package/lib/modules/Discount/index.js +23 -3
  96. package/lib/modules/Discount/types.d.ts +4 -0
  97. package/lib/modules/Order/index.d.ts +14 -2
  98. package/lib/modules/Order/index.js +326 -60
  99. package/lib/modules/Order/types.d.ts +16 -0
  100. package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
  101. package/lib/modules/Order/utils/orderCollectionIdentity.js +415 -0
  102. package/lib/modules/Order/utils.d.ts +4 -3
  103. package/lib/modules/Order/utils.js +22 -23
  104. package/lib/modules/Product/types.d.ts +22 -0
  105. package/lib/modules/ProductList/index.d.ts +1 -1
  106. package/lib/modules/ProductList/index.js +4 -2
  107. package/lib/modules/ProductList/types.d.ts +2 -0
  108. package/lib/modules/Rules/index.d.ts +2 -9
  109. package/lib/modules/Rules/index.js +61 -29
  110. package/lib/modules/Rules/types.d.ts +10 -1
  111. package/lib/server/index.d.ts +55 -0
  112. package/lib/server/index.js +332 -34
  113. package/lib/server/modules/order/index.d.ts +10 -4
  114. package/lib/server/modules/order/index.js +198 -139
  115. package/lib/server/modules/order/types.d.ts +4 -0
  116. package/lib/server/modules/products/index.d.ts +31 -8
  117. package/lib/server/modules/products/index.js +134 -35
  118. package/lib/server/modules/products/types.d.ts +18 -0
  119. package/lib/solution/BaseSales/index.d.ts +21 -1
  120. package/lib/solution/BaseSales/index.js +313 -72
  121. package/lib/solution/BaseSales/types.d.ts +6 -1
  122. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
  123. package/lib/solution/BaseSales/utils/cartPromotion.js +29 -60
  124. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
  125. package/lib/solution/BaseSales/utils/parseSalesResponse.js +4 -5
  126. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +8 -0
  127. package/lib/solution/BookingByStep/index.d.ts +1 -1
  128. package/lib/solution/BookingTicket/index.d.ts +1 -1
  129. package/lib/solution/BookingTicket/index.js +33 -8
  130. package/lib/solution/BookingTicket/types.d.ts +2 -0
  131. package/lib/solution/ScanOrder/index.js +0 -8
  132. package/lib/solution/ShopDiscount/index.js +2 -1
  133. package/lib/solution/VenueBooking/index.js +0 -8
  134. package/package.json +1 -1
@@ -6,12 +6,12 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
6
6
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
7
7
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
8
8
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
9
- function 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
- 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
9
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
12
10
  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."); }
13
11
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
14
12
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
13
+ 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; }
14
+ 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; }
15
15
  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; } } }; }
16
16
  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); }
17
17
  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; }
@@ -39,6 +39,7 @@ import { processCartPromotion, appendPromotionTags as _appendPromotionTags, getO
39
39
  import { buildProductLineFingerprint, getProductIdentityIndex, getSafeProductNum, isIdentityMatch, normalizeOrderProduct } from "../../solution/ScanOrder/utils";
40
40
  import { syncManualProductDiscountProductNum } from "./utils/manualProductDiscount";
41
41
  import { expandHydratedProductsForDiscountCollection, restoreHydratedBundleDiscounts } from "./utils/bundleDiscountHydration";
42
+ import { getOrderCollectionPersistentId, getOrderCollectionUid, normalizeOrderCollections, setOrderCollectionUid } from "./utils/orderCollectionIdentity";
42
43
  import { DiscountModule } from "../Discount";
43
44
  import { RulesModule } from "../Rules";
44
45
  import { UnavailableReason } from "../Rules/types";
@@ -158,9 +159,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
158
159
  };
159
160
  var existed = discountMap.get(key);
160
161
  if (existed) {
162
+ var _existed$limited_rela;
161
163
  existed.amount = Number(existed.amount || 0) + amount;
162
164
  existed.used_par_value = String(Number(existed.used_par_value || 0) + amount);
163
165
  existed.balance = String(Number(existed.balance || 0) + amount);
166
+ var productIds = Array.isArray((_existed$limited_rela = existed.limited_relation_product_data) === null || _existed$limited_rela === void 0 ? void 0 : _existed$limited_rela.product_ids) ? existed.limited_relation_product_data.product_ids : [];
167
+ if ((product === null || product === void 0 ? void 0 : product.product_id) !== undefined && (product === null || product === void 0 ? void 0 : product.product_id) !== null && !productIds.includes(product.product_id)) {
168
+ existed.limited_relation_product_data = _objectSpread(_objectSpread({}, existed.limited_relation_product_data || {}), {}, {
169
+ product_ids: [].concat(_toConsumableArray(productIds), [product.product_id])
170
+ });
171
+ }
164
172
  existed.applicableProductDetails = [].concat(_toConsumableArray(existed.applicableProductDetails || []), [detail]);
165
173
  existed.appliedProductDetails = [].concat(_toConsumableArray(existed.appliedProductDetails || []), [detail]);
166
174
  continue;
@@ -288,14 +296,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
288
296
  if (!this.store.summary) {
289
297
  this.store.summary = createEmptySummary();
290
298
  }
299
+ if (!Array.isArray(this.store.availableWalletIds)) {
300
+ this.store.availableWalletIds = [];
301
+ }
291
302
  this.request = this.core.getPlugin('request');
292
303
  appPlugin = this.core.getPlugin('app');
293
304
  if (appPlugin) {
294
- _context.next = 8;
305
+ _context.next = 9;
295
306
  break;
296
307
  }
297
308
  throw new Error('Order 模块需要 app 插件支持');
298
- case 8:
309
+ case 9:
299
310
  app = appPlugin.getApp();
300
311
  this.logger = app.logger;
301
312
  this.window = this.core.getPlugin('window');
@@ -308,7 +319,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
308
319
  this.otherParams = otherParams;
309
320
  this.registerDiscountModules(options);
310
321
  this.logInfo('OrderModule initialized successfully');
311
- case 20:
322
+ case 21:
312
323
  case "end":
313
324
  return _context.stop();
314
325
  }
@@ -485,7 +496,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
485
496
  value: function () {
486
497
  var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
487
498
  var _this$store$tempOrder, _this$store$discount, _this$store$tempOrder2;
488
- var orderId, discountList, _this$store$discount2, _this$store$discount3, _this$store$discount4, currentEditDiscounts, runtimeDiscountIds, runtimeDiscounts, mergedDiscountList;
499
+ var orderId, prepareConfigResult, discountList, _this$store$discount2, _this$store$discount3, _this$store$discount4, currentDiscountList, currentEditDiscounts, currentScanDiscounts, currentScanDiscountIds, runtimeDiscountIds, runtimeDiscounts, mergedDiscountList;
489
500
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
490
501
  while (1) switch (_context3.prev = _context3.next) {
491
502
  case 0:
@@ -497,37 +508,49 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
497
508
  with_good_pass: 1,
498
509
  with_discount_card: 1,
499
510
  with_wallet_pass_holder: 1,
511
+ with_available_wallet_flag: 1,
512
+ with_available_wallet_pass_flag: 1,
500
513
  request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
501
514
  }, orderId ? {
502
515
  order_id: orderId
503
516
  } : {}));
504
517
  case 3:
505
- discountList = _context3.sent;
518
+ prepareConfigResult = _context3.sent;
519
+ discountList = prepareConfigResult === null || prepareConfigResult === void 0 ? void 0 : prepareConfigResult.discountList;
520
+ this.store.availableWalletIds = (prepareConfigResult === null || prepareConfigResult === void 0 ? void 0 : prepareConfigResult.availableWalletIds) || [];
506
521
  if (!discountList) {
507
- _context3.next = 13;
522
+ _context3.next = 18;
508
523
  break;
509
524
  }
510
- currentEditDiscounts = (((_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 ? void 0 : _this$store$discount2.getDiscountList()) || []).filter(function (discount) {
525
+ currentDiscountList = ((_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 ? void 0 : _this$store$discount2.getDiscountList()) || [];
526
+ currentEditDiscounts = currentDiscountList.filter(function (discount) {
511
527
  return discount === null || discount === void 0 ? void 0 : discount.isEditMode;
512
528
  });
529
+ currentScanDiscounts = currentDiscountList.filter(function (discount) {
530
+ return discount === null || discount === void 0 ? void 0 : discount.isScan;
531
+ });
532
+ currentScanDiscountIds = new Set(currentScanDiscounts.map(function (discount) {
533
+ return discount === null || discount === void 0 ? void 0 : discount.id;
534
+ }));
513
535
  runtimeDiscountIds = new Set();
514
536
  runtimeDiscounts = discountList.filter(function (discount) {
537
+ if (currentScanDiscountIds.has(discount === null || discount === void 0 ? void 0 : discount.id)) return false;
515
538
  if (runtimeDiscountIds.has(discount === null || discount === void 0 ? void 0 : discount.id)) return false;
516
539
  runtimeDiscountIds.add(discount === null || discount === void 0 ? void 0 : discount.id);
517
540
  return true;
518
541
  });
519
- mergedDiscountList = [].concat(_toConsumableArray(currentEditDiscounts), _toConsumableArray(runtimeDiscounts));
520
- _context3.next = 11;
542
+ mergedDiscountList = [].concat(_toConsumableArray(currentEditDiscounts), _toConsumableArray(currentScanDiscounts), _toConsumableArray(runtimeDiscounts));
543
+ _context3.next = 16;
521
544
  return (_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.setOriginalDiscountList(mergedDiscountList);
522
- case 11:
523
- _context3.next = 13;
545
+ case 16:
546
+ _context3.next = 18;
524
547
  return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.setDiscountList(mergedDiscountList);
525
- case 13:
548
+ case 18:
526
549
  if (params.apply !== false && (_this$store$tempOrder2 = this.store.tempOrder) !== null && _this$store$tempOrder2 !== void 0 && (_this$store$tempOrder2 = _this$store$tempOrder2.products) !== null && _this$store$tempOrder2 !== void 0 && _this$store$tempOrder2.length) {
527
550
  this.applyDiscount();
528
551
  }
529
552
  return _context3.abrupt("return", this.getDiscountList());
530
- case 15:
553
+ case 20:
531
554
  case "end":
532
555
  return _context3.stop();
533
556
  }
@@ -545,33 +568,76 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
545
568
  return ((_this$store$discount5 = this.store.discount) === null || _this$store$discount5 === void 0 ? void 0 : _this$store$discount5.getDiscountList()) || [];
546
569
  }
547
570
  }, {
548
- key: "ensureEditDiscountConfigForProductChange",
571
+ key: "getAvailableWalletIds",
572
+ value: function getAvailableWalletIds() {
573
+ return Array.isArray(this.store.availableWalletIds) ? _toConsumableArray(this.store.availableWalletIds) : [];
574
+ }
575
+ }, {
576
+ key: "syncScannedDiscountsToOriginalDiscountList",
549
577
  value: function () {
550
- var _ensureEditDiscountConfigForProductChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(tempOrder) {
551
- var _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _this$store$discount6;
552
- var orderId, customerId, currentDiscountList, hasRuntimeDiscounts;
578
+ var _syncScannedDiscountsToOriginalDiscountList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(discountList) {
579
+ var _this$store$discount6, _this$store$discount7, _this$store$discount8, _this$store$discount9;
580
+ var scanDiscounts, scanDiscountIds, originalDiscounts, nextOriginalDiscounts;
553
581
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
554
582
  while (1) switch (_context4.prev = _context4.next) {
583
+ case 0:
584
+ scanDiscounts = (discountList || []).filter(function (discount) {
585
+ return discount === null || discount === void 0 ? void 0 : discount.isScan;
586
+ });
587
+ if (scanDiscounts.length) {
588
+ _context4.next = 3;
589
+ break;
590
+ }
591
+ return _context4.abrupt("return");
592
+ case 3:
593
+ scanDiscountIds = new Set(scanDiscounts.map(function (discount) {
594
+ return discount === null || discount === void 0 ? void 0 : discount.id;
595
+ }));
596
+ originalDiscounts = ((_this$store$discount6 = this.store.discount) === null || _this$store$discount6 === void 0 || (_this$store$discount7 = _this$store$discount6.getOriginalDiscountList) === null || _this$store$discount7 === void 0 ? void 0 : _this$store$discount7.call(_this$store$discount6)) || [];
597
+ nextOriginalDiscounts = [].concat(_toConsumableArray(scanDiscounts), _toConsumableArray(originalDiscounts.filter(function (discount) {
598
+ return !scanDiscountIds.has(discount === null || discount === void 0 ? void 0 : discount.id);
599
+ })));
600
+ _context4.next = 8;
601
+ return (_this$store$discount8 = this.store.discount) === null || _this$store$discount8 === void 0 || (_this$store$discount9 = _this$store$discount8.setOriginalDiscountList) === null || _this$store$discount9 === void 0 ? void 0 : _this$store$discount9.call(_this$store$discount8, nextOriginalDiscounts);
602
+ case 8:
603
+ case "end":
604
+ return _context4.stop();
605
+ }
606
+ }, _callee4, this);
607
+ }));
608
+ function syncScannedDiscountsToOriginalDiscountList(_x4) {
609
+ return _syncScannedDiscountsToOriginalDiscountList.apply(this, arguments);
610
+ }
611
+ return syncScannedDiscountsToOriginalDiscountList;
612
+ }()
613
+ }, {
614
+ key: "ensureEditDiscountConfigForProductChange",
615
+ value: function () {
616
+ var _ensureEditDiscountConfigForProductChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(tempOrder) {
617
+ var _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _this$store$discount10;
618
+ var orderId, customerId, currentDiscountList, hasRuntimeDiscounts;
619
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
620
+ while (1) switch (_context5.prev = _context5.next) {
555
621
  case 0:
556
622
  orderId = tempOrder.order_id;
557
623
  customerId = Number(tempOrder.customer_id || ((_tempOrder$customer = tempOrder.customer) === null || _tempOrder$customer === void 0 ? void 0 : _tempOrder$customer.id) || ((_tempOrder$_extend = tempOrder._extend) === null || _tempOrder$_extend === void 0 || (_tempOrder$_extend = _tempOrder$_extend.customerSnapshot) === null || _tempOrder$_extend === void 0 ? void 0 : _tempOrder$_extend.id) || ((_tempOrder$_extend2 = tempOrder._extend) === null || _tempOrder$_extend2 === void 0 || (_tempOrder$_extend2 = _tempOrder$_extend2.customerSnapshot) === null || _tempOrder$_extend2 === void 0 ? void 0 : _tempOrder$_extend2.customer_id) || 0);
558
624
  if (!(!orderId || !customerId || customerId === 1)) {
559
- _context4.next = 4;
625
+ _context5.next = 4;
560
626
  break;
561
627
  }
562
- return _context4.abrupt("return");
628
+ return _context5.abrupt("return");
563
629
  case 4:
564
- currentDiscountList = ((_this$store$discount6 = this.store.discount) === null || _this$store$discount6 === void 0 ? void 0 : _this$store$discount6.getDiscountList()) || [];
630
+ currentDiscountList = ((_this$store$discount10 = this.store.discount) === null || _this$store$discount10 === void 0 ? void 0 : _this$store$discount10.getDiscountList()) || [];
565
631
  hasRuntimeDiscounts = currentDiscountList.some(function (discount) {
566
632
  return !(discount !== null && discount !== void 0 && discount.isEditMode);
567
633
  });
568
634
  if (!hasRuntimeDiscounts) {
569
- _context4.next = 8;
635
+ _context5.next = 8;
570
636
  break;
571
637
  }
572
- return _context4.abrupt("return");
638
+ return _context5.abrupt("return");
573
639
  case 8:
574
- _context4.next = 10;
640
+ _context5.next = 10;
575
641
  return this.loadDiscountConfig({
576
642
  customerId: customerId,
577
643
  action: 'edit',
@@ -580,11 +646,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
580
646
  });
581
647
  case 10:
582
648
  case "end":
583
- return _context4.stop();
649
+ return _context5.stop();
584
650
  }
585
- }, _callee4, this);
651
+ }, _callee5, this);
586
652
  }));
587
- function ensureEditDiscountConfigForProductChange(_x4) {
653
+ function ensureEditDiscountConfigForProductChange(_x5) {
588
654
  return _ensureEditDiscountConfigForProductChange.apply(this, arguments);
589
655
  }
590
656
  return ensureEditDiscountConfigForProductChange;
@@ -592,35 +658,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
592
658
  }, {
593
659
  key: "scanCode",
594
660
  value: function () {
595
- var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code, customerId) {
596
- var _this$store$discount7, _tempOrder$holder, _this$store$summary;
597
- var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref13, isAvailable, newDiscountList, unavailableReason, _this$store$discount8;
598
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
599
- while (1) switch (_context5.prev = _context5.next) {
661
+ var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(code, customerId) {
662
+ var _this$store$discount11, _tempOrder$holder, _this$store$summary;
663
+ var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref13, isAvailable, newDiscountList, unavailableReason, _this$store$discount12;
664
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
665
+ while (1) switch (_context6.prev = _context6.next) {
600
666
  case 0:
601
- _context5.next = 2;
602
- return (_this$store$discount7 = this.store.discount) === null || _this$store$discount7 === void 0 ? void 0 : _this$store$discount7.batchSearch(code, {
667
+ _context6.next = 2;
668
+ return (_this$store$discount11 = this.store.discount) === null || _this$store$discount11 === void 0 ? void 0 : _this$store$discount11.batchSearch(code, {
603
669
  customerId: customerId
604
670
  });
605
671
  case 2:
606
- _context5.t0 = _context5.sent;
607
- if (_context5.t0) {
608
- _context5.next = 5;
672
+ _context6.t0 = _context6.sent;
673
+ if (_context6.t0) {
674
+ _context6.next = 5;
609
675
  break;
610
676
  }
611
- _context5.t0 = {
677
+ _context6.t0 = {
612
678
  discountList: [],
613
679
  unavailableReasonKey: null
614
680
  };
615
681
  case 5:
616
- resultDiscountWithReason = _context5.t0;
682
+ resultDiscountWithReason = _context6.t0;
617
683
  resultDiscountList = resultDiscountWithReason.discountList, unavailableReasonKey = resultDiscountWithReason.unavailableReasonKey;
618
684
  rulesModule = this.store.rules;
619
685
  if (rulesModule) {
620
- _context5.next = 10;
686
+ _context6.next = 10;
621
687
  break;
622
688
  }
623
- return _context5.abrupt("return", {
689
+ return _context6.abrupt("return", {
624
690
  type: 'clientCalc',
625
691
  isAvailable: false,
626
692
  discountList: this.getDiscountList(),
@@ -629,10 +695,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
629
695
  });
630
696
  case 10:
631
697
  if (resultDiscountList.length) {
632
- _context5.next = 12;
698
+ _context6.next = 12;
633
699
  break;
634
700
  }
635
- return _context5.abrupt("return", {
701
+ return _context6.abrupt("return", {
636
702
  type: 'server',
637
703
  isAvailable: false,
638
704
  discountList: this.getDiscountList(),
@@ -653,16 +719,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
653
719
  return m.id === n.id;
654
720
  });
655
721
  }))) {
656
- _context5.next = 16;
722
+ _context6.next = 18;
657
723
  break;
658
724
  }
659
- return _context5.abrupt("return", {
725
+ _context6.next = 17;
726
+ return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
727
+ case 17:
728
+ return _context6.abrupt("return", {
660
729
  type: 'clientCalc',
661
730
  isAvailable: true,
662
731
  discountList: this.getDiscountList(),
663
732
  scannedDiscountList: resultDiscountList
664
733
  });
665
- case 16:
734
+ case 18:
666
735
  tempOrder = this.store.tempOrder;
667
736
  holders = (tempOrder === null || tempOrder === void 0 || (_tempOrder$holder = tempOrder.holder) === null || _tempOrder$holder === void 0 ? void 0 : _tempOrder$holder.form_record) || [];
668
737
  _ref13 = rulesModule.isDiscountListAvailable({
@@ -678,33 +747,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
678
747
  isAvailable: false,
679
748
  discountList: this.getDiscountList()
680
749
  }, isAvailable = _ref13.isAvailable, newDiscountList = _ref13.discountList, unavailableReason = _ref13.unavailableReason;
681
- if (isAvailable && newDiscountList) {
682
- (_this$store$discount8 = this.store.discount) === null || _this$store$discount8 === void 0 || _this$store$discount8.setDiscountList(newDiscountList);
683
- this.applyDiscount();
750
+ if (!(isAvailable && newDiscountList)) {
751
+ _context6.next = 26;
752
+ break;
684
753
  }
685
- return _context5.abrupt("return", {
754
+ (_this$store$discount12 = this.store.discount) === null || _this$store$discount12 === void 0 || _this$store$discount12.setDiscountList(newDiscountList);
755
+ this.applyDiscount();
756
+ _context6.next = 26;
757
+ return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
758
+ case 26:
759
+ return _context6.abrupt("return", {
686
760
  type: 'clientCalc',
687
761
  isAvailable: isAvailable || false,
688
762
  discountList: newDiscountList || this.getDiscountList(),
689
763
  scannedDiscountList: resultDiscountList,
690
764
  unavailableReason: unavailableReason
691
765
  });
692
- case 21:
766
+ case 27:
693
767
  case "end":
694
- return _context5.stop();
768
+ return _context6.stop();
695
769
  }
696
- }, _callee5, this);
770
+ }, _callee6, this);
697
771
  }));
698
- function scanCode(_x5, _x6) {
772
+ function scanCode(_x6, _x7) {
699
773
  return _scanCode.apply(this, arguments);
700
774
  }
701
775
  return scanCode;
702
776
  }()
703
777
  }, {
704
778
  key: "applyDiscount",
705
- value: function applyDiscount() {
706
- var _this$store$discount9,
707
- _tempOrder$holder2,
779
+ value: function applyDiscount(options) {
780
+ var _this$store$discount13,
708
781
  _this$store$summary2,
709
782
  _this2 = this;
710
783
  var tempOrder = this.store.tempOrder;
@@ -714,20 +787,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
714
787
  if (!tempOrder) return;
715
788
  this.syncLinkedBookingHoldersToProducts(tempOrder);
716
789
  delete tempOrder.discount_list;
717
- var discountList = ((_this$store$discount9 = this.store.discount) === null || _this$store$discount9 === void 0 ? void 0 : _this$store$discount9.getDiscountList()) || [];
790
+ var discountList = ((_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.getDiscountList()) || [];
718
791
  var shouldSkipDiscountCalculation = this.shouldSkipDiscountCalculation(tempOrder);
719
792
  if (shouldSkipDiscountCalculation) return;
720
793
  var rulesModule = this.store.rules;
721
794
  if (!rulesModule) return;
722
- var holders = ((_tempOrder$holder2 = tempOrder.holder) === null || _tempOrder$holder2 === void 0 ? void 0 : _tempOrder$holder2.form_record) || [];
723
795
  var result = rulesModule.calcDiscount({
724
796
  productList: tempOrder.products,
725
797
  discountList: discountList,
726
- holders: holders,
798
+ holders: [],
727
799
  isFormSubject: function isFormSubject(product) {
728
800
  return resolveIsFormSubject(tempOrder, product);
729
801
  },
730
802
  orderTotalAmount: Number(((_this$store$summary2 = this.store.summary) === null || _this$store$summary2 === void 0 ? void 0 : _this$store$summary2.total_amount) || 0)
803
+ }, {
804
+ reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids
731
805
  });
732
806
  if (result !== null && result !== void 0 && result.productList) {
733
807
  var previousProductsByUid = indexOrderProductsByUid(tempOrder.products);
@@ -745,9 +819,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
745
819
  }));
746
820
  }
747
821
  if (result !== null && result !== void 0 && result.discountList) {
748
- var _this$store$discount10;
822
+ var _this$store$discount14;
749
823
  OrderModule.populateSavedAmounts(result.productList || tempOrder.products, result.discountList);
750
- (_this$store$discount10 = this.store.discount) === null || _this$store$discount10 === void 0 || _this$store$discount10.setDiscountList(result.discountList);
824
+ (_this$store$discount14 = this.store.discount) === null || _this$store$discount14 === void 0 || _this$store$discount14.setDiscountList(result.discountList);
751
825
  }
752
826
  this.hasActiveCustomerBoundDiscount = (tempOrder.products || []).some(function (product) {
753
827
  return _this2.productHasCustomerBoundDiscount(product);
@@ -809,42 +883,42 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
809
883
  }, {
810
884
  key: "applyPromotion",
811
885
  value: (function () {
812
- var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
886
+ var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
813
887
  var _this$promotionEvalua,
814
888
  _this$promotionEvalua2,
815
889
  _this3 = this;
816
890
  var tempOrder, strategyConfigs, result, removeSet, _iterator3, _step3, reduce, _iterator6, _step6, _loop2, _iterator4, _step4, _loop, payload;
817
- return _regeneratorRuntime().wrap(function _callee6$(_context8) {
818
- while (1) switch (_context8.prev = _context8.next) {
891
+ return _regeneratorRuntime().wrap(function _callee7$(_context9) {
892
+ while (1) switch (_context9.prev = _context9.next) {
819
893
  case 0:
820
894
  if (!this.isApplyingPromotion) {
821
- _context8.next = 2;
895
+ _context9.next = 2;
822
896
  break;
823
897
  }
824
- return _context8.abrupt("return");
898
+ return _context9.abrupt("return");
825
899
  case 2:
826
900
  if (this.promotionEvaluator) {
827
- _context8.next = 4;
901
+ _context9.next = 4;
828
902
  break;
829
903
  }
830
- return _context8.abrupt("return");
904
+ return _context9.abrupt("return");
831
905
  case 4:
832
906
  tempOrder = this.store.tempOrder;
833
907
  if (tempOrder) {
834
- _context8.next = 7;
908
+ _context9.next = 7;
835
909
  break;
836
910
  }
837
- return _context8.abrupt("return");
911
+ return _context9.abrupt("return");
838
912
  case 7:
839
913
  strategyConfigs = (_this$promotionEvalua = (_this$promotionEvalua2 = this.promotionEvaluator).getStrategyConfigs) === null || _this$promotionEvalua === void 0 ? void 0 : _this$promotionEvalua.call(_this$promotionEvalua2);
840
914
  if (!(Array.isArray(strategyConfigs) && strategyConfigs.length === 0)) {
841
- _context8.next = 10;
915
+ _context9.next = 10;
842
916
  break;
843
917
  }
844
- return _context8.abrupt("return");
918
+ return _context9.abrupt("return");
845
919
  case 10:
846
920
  this.isApplyingPromotion = true;
847
- _context8.prev = 11;
921
+ _context9.prev = 11;
848
922
  result = processCartPromotion(tempOrder.products, this.promotionEvaluator); // step 1: toRemove —— 直接过滤
849
923
  if (result.giftActions.toRemove.length > 0) {
850
924
  removeSet = new Set(result.giftActions.toRemove.map(String));
@@ -856,20 +930,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
856
930
 
857
931
  // step 2: toReduce —— 调整数量
858
932
  _iterator3 = _createForOfIteratorHelper(result.giftActions.toReduce);
859
- _context8.prev = 15;
933
+ _context9.prev = 15;
860
934
  _iterator3.s();
861
935
  case 17:
862
936
  if ((_step3 = _iterator3.n()).done) {
863
- _context8.next = 37;
937
+ _context9.next = 37;
864
938
  break;
865
939
  }
866
940
  reduce = _step3.value;
867
941
  _iterator6 = _createForOfIteratorHelper(reduce.items);
868
- _context8.prev = 20;
942
+ _context9.prev = 20;
869
943
  _loop2 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop2() {
870
944
  var item, product;
871
- return _regeneratorRuntime().wrap(function _loop2$(_context7) {
872
- while (1) switch (_context7.prev = _context7.next) {
945
+ return _regeneratorRuntime().wrap(function _loop2$(_context8) {
946
+ while (1) switch (_context8.prev = _context8.next) {
873
947
  case 0:
874
948
  item = _step6.value;
875
949
  product = result.products.find(function (p) {
@@ -880,52 +954,52 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
880
954
  }
881
955
  case 3:
882
956
  case "end":
883
- return _context7.stop();
957
+ return _context8.stop();
884
958
  }
885
959
  }, _loop2);
886
960
  });
887
961
  _iterator6.s();
888
962
  case 23:
889
963
  if ((_step6 = _iterator6.n()).done) {
890
- _context8.next = 27;
964
+ _context9.next = 27;
891
965
  break;
892
966
  }
893
- return _context8.delegateYield(_loop2(), "t0", 25);
967
+ return _context9.delegateYield(_loop2(), "t0", 25);
894
968
  case 25:
895
- _context8.next = 23;
969
+ _context9.next = 23;
896
970
  break;
897
971
  case 27:
898
- _context8.next = 32;
972
+ _context9.next = 32;
899
973
  break;
900
974
  case 29:
901
- _context8.prev = 29;
902
- _context8.t1 = _context8["catch"](20);
903
- _iterator6.e(_context8.t1);
975
+ _context9.prev = 29;
976
+ _context9.t1 = _context9["catch"](20);
977
+ _iterator6.e(_context9.t1);
904
978
  case 32:
905
- _context8.prev = 32;
979
+ _context9.prev = 32;
906
980
  _iterator6.f();
907
- return _context8.finish(32);
981
+ return _context9.finish(32);
908
982
  case 35:
909
- _context8.next = 17;
983
+ _context9.next = 17;
910
984
  break;
911
985
  case 37:
912
- _context8.next = 42;
986
+ _context9.next = 42;
913
987
  break;
914
988
  case 39:
915
- _context8.prev = 39;
916
- _context8.t2 = _context8["catch"](15);
917
- _iterator3.e(_context8.t2);
989
+ _context9.prev = 39;
990
+ _context9.t2 = _context9["catch"](15);
991
+ _iterator3.e(_context9.t2);
918
992
  case 42:
919
- _context8.prev = 42;
993
+ _context9.prev = 42;
920
994
  _iterator3.f();
921
- return _context8.finish(42);
995
+ return _context9.finish(42);
922
996
  case 45:
923
997
  if (!(result.giftActions.toAdd.length > 0)) {
924
- _context8.next = 68;
998
+ _context9.next = 68;
925
999
  break;
926
1000
  }
927
1001
  if (this.giftSelectResolver) {
928
- _context8.next = 50;
1002
+ _context9.next = 50;
929
1003
  break;
930
1004
  }
931
1005
  if (result.giftActions.toAdd.some(function (g) {
@@ -936,19 +1010,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
936
1010
  } else {
937
1011
  console.warn('[OrderModule] giftSelectResolver not set, skip applying single-option gifts', result.giftActions.toAdd);
938
1012
  }
939
- _context8.next = 68;
1013
+ _context9.next = 68;
940
1014
  break;
941
1015
  case 50:
942
1016
  _iterator4 = _createForOfIteratorHelper(result.giftActions.toAdd);
943
- _context8.prev = 51;
1017
+ _context9.prev = 51;
944
1018
  _loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
945
1019
  var addAction, _sameStrategy$metadat, sameStrategy, giftResult, giftProducts, giftBookings, _iterator5, _step5, _step5$value, index, gp, booking, linked;
946
- return _regeneratorRuntime().wrap(function _loop$(_context6) {
947
- while (1) switch (_context6.prev = _context6.next) {
1020
+ return _regeneratorRuntime().wrap(function _loop$(_context7) {
1021
+ while (1) switch (_context7.prev = _context7.next) {
948
1022
  case 0:
949
1023
  addAction = _step4.value;
950
1024
  if (!(addAction.giftOptions.length === 1)) {
951
- _context6.next = 6;
1025
+ _context7.next = 6;
952
1026
  break;
953
1027
  }
954
1028
  sameStrategy = result.products.find(function (p) {
@@ -956,14 +1030,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
956
1030
  return ((_p$metadata = p.metadata) === null || _p$metadata === void 0 || (_p$metadata = _p$metadata._giftInfo) === null || _p$metadata === void 0 ? void 0 : _p$metadata.strategyId) === addAction.strategyId;
957
1031
  });
958
1032
  if (!(sameStrategy && !sameStrategy.booking_uid && !((_sameStrategy$metadat = sameStrategy.metadata) !== null && _sameStrategy$metadat !== void 0 && _sameStrategy$metadat.booking_uid))) {
959
- _context6.next = 6;
1033
+ _context7.next = 6;
960
1034
  break;
961
1035
  }
962
1036
  sameStrategy.num = (Number(sameStrategy.num) || 0) + (addAction.giftCount || 1);
963
- return _context6.abrupt("return", 1);
1037
+ return _context7.abrupt("return", 1);
964
1038
  case 6:
965
- _context6.prev = 6;
966
- _context6.next = 9;
1039
+ _context7.prev = 6;
1040
+ _context7.next = 9;
967
1041
  return _this3.giftSelectResolver({
968
1042
  strategyId: addAction.strategyId,
969
1043
  strategyName: addAction.strategyName,
@@ -972,31 +1046,31 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
972
1046
  sourceProductIds: addAction.sourceProductIds
973
1047
  });
974
1048
  case 9:
975
- giftResult = _context6.sent;
1049
+ giftResult = _context7.sent;
976
1050
  giftProducts = Array.isArray(giftResult) ? giftResult : giftResult === null || giftResult === void 0 ? void 0 : giftResult.products;
977
1051
  giftBookings = Array.isArray(giftResult) ? [] : (giftResult === null || giftResult === void 0 ? void 0 : giftResult.bookings) || [];
978
1052
  if (!(Array.isArray(giftProducts) && giftProducts.length > 0)) {
979
- _context6.next = 37;
1053
+ _context7.next = 37;
980
1054
  break;
981
1055
  }
982
1056
  _iterator5 = _createForOfIteratorHelper(giftProducts.entries());
983
- _context6.prev = 14;
1057
+ _context7.prev = 14;
984
1058
  _iterator5.s();
985
1059
  case 16:
986
1060
  if ((_step5 = _iterator5.n()).done) {
987
- _context6.next = 29;
1061
+ _context7.next = 29;
988
1062
  break;
989
1063
  }
990
1064
  _step5$value = _slicedToArray(_step5.value, 2), index = _step5$value[0], gp = _step5$value[1];
991
1065
  if (gp) {
992
- _context6.next = 20;
1066
+ _context7.next = 20;
993
1067
  break;
994
1068
  }
995
- return _context6.abrupt("continue", 27);
1069
+ return _context7.abrupt("continue", 27);
996
1070
  case 20:
997
1071
  booking = giftBookings[index];
998
1072
  if (!booking) {
999
- _context6.next = 26;
1073
+ _context7.next = 26;
1000
1074
  break;
1001
1075
  }
1002
1076
  linked = _this3.createLinkedProductAndBooking({
@@ -1005,65 +1079,65 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1005
1079
  });
1006
1080
  result.products.push(linked.product);
1007
1081
  tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
1008
- return _context6.abrupt("continue", 27);
1082
+ return _context7.abrupt("continue", 27);
1009
1083
  case 26:
1010
1084
  // normalize 略过:调用方应保证返回完整 OrderProduct。
1011
1085
  result.products.push(gp);
1012
1086
  case 27:
1013
- _context6.next = 16;
1087
+ _context7.next = 16;
1014
1088
  break;
1015
1089
  case 29:
1016
- _context6.next = 34;
1090
+ _context7.next = 34;
1017
1091
  break;
1018
1092
  case 31:
1019
- _context6.prev = 31;
1020
- _context6.t0 = _context6["catch"](14);
1021
- _iterator5.e(_context6.t0);
1093
+ _context7.prev = 31;
1094
+ _context7.t0 = _context7["catch"](14);
1095
+ _iterator5.e(_context7.t0);
1022
1096
  case 34:
1023
- _context6.prev = 34;
1097
+ _context7.prev = 34;
1024
1098
  _iterator5.f();
1025
- return _context6.finish(34);
1099
+ return _context7.finish(34);
1026
1100
  case 37:
1027
- _context6.next = 42;
1101
+ _context7.next = 42;
1028
1102
  break;
1029
1103
  case 39:
1030
- _context6.prev = 39;
1031
- _context6.t1 = _context6["catch"](6);
1104
+ _context7.prev = 39;
1105
+ _context7.t1 = _context7["catch"](6);
1032
1106
  // 用户取消 / 选择失败 → 视为放弃本次新增
1033
- console.warn('[OrderModule] giftSelectResolver rejected, skip add gift', addAction.strategyId, _context6.t1);
1107
+ console.warn('[OrderModule] giftSelectResolver rejected, skip add gift', addAction.strategyId, _context7.t1);
1034
1108
  case 42:
1035
1109
  case "end":
1036
- return _context6.stop();
1110
+ return _context7.stop();
1037
1111
  }
1038
1112
  }, _loop, null, [[6, 39], [14, 31, 34, 37]]);
1039
1113
  });
1040
1114
  _iterator4.s();
1041
1115
  case 54:
1042
1116
  if ((_step4 = _iterator4.n()).done) {
1043
- _context8.next = 60;
1117
+ _context9.next = 60;
1044
1118
  break;
1045
1119
  }
1046
- return _context8.delegateYield(_loop(), "t3", 56);
1120
+ return _context9.delegateYield(_loop(), "t3", 56);
1047
1121
  case 56:
1048
- if (!_context8.t3) {
1049
- _context8.next = 58;
1122
+ if (!_context9.t3) {
1123
+ _context9.next = 58;
1050
1124
  break;
1051
1125
  }
1052
- return _context8.abrupt("continue", 58);
1126
+ return _context9.abrupt("continue", 58);
1053
1127
  case 58:
1054
- _context8.next = 54;
1128
+ _context9.next = 54;
1055
1129
  break;
1056
1130
  case 60:
1057
- _context8.next = 65;
1131
+ _context9.next = 65;
1058
1132
  break;
1059
1133
  case 62:
1060
- _context8.prev = 62;
1061
- _context8.t4 = _context8["catch"](51);
1062
- _iterator4.e(_context8.t4);
1134
+ _context9.prev = 62;
1135
+ _context9.t4 = _context9["catch"](51);
1136
+ _iterator4.e(_context9.t4);
1063
1137
  case 65:
1064
- _context8.prev = 65;
1138
+ _context9.prev = 65;
1065
1139
  _iterator4.f();
1066
- return _context8.finish(65);
1140
+ return _context9.finish(65);
1067
1141
  case 68:
1068
1142
  tempOrder.products = result.products;
1069
1143
  this.lastUnfulfilledPromotions = result.unfulfilledPromotions;
@@ -1082,21 +1156,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1082
1156
  products: tempOrder.products
1083
1157
  };
1084
1158
  this.effectsEmit('onPromotionApplied', payload);
1085
- _context8.next = 78;
1159
+ _context9.next = 78;
1086
1160
  break;
1087
1161
  case 75:
1088
- _context8.prev = 75;
1089
- _context8.t5 = _context8["catch"](11);
1090
- console.error('[OrderModule] applyPromotion failed', _context8.t5);
1162
+ _context9.prev = 75;
1163
+ _context9.t5 = _context9["catch"](11);
1164
+ console.error('[OrderModule] applyPromotion failed', _context9.t5);
1091
1165
  case 78:
1092
- _context8.prev = 78;
1166
+ _context9.prev = 78;
1093
1167
  this.isApplyingPromotion = false;
1094
- return _context8.finish(78);
1168
+ return _context9.finish(78);
1095
1169
  case 81:
1096
1170
  case "end":
1097
- return _context8.stop();
1171
+ return _context9.stop();
1098
1172
  }
1099
- }, _callee6, this, [[11, 75, 78, 81], [15, 39, 42, 45], [20, 29, 32, 35], [51, 62, 65, 68]]);
1173
+ }, _callee7, this, [[11, 75, 78, 81], [15, 39, 42, 45], [20, 29, 32, 35], [51, 62, 65, 68]]);
1100
1174
  }));
1101
1175
  function applyPromotion() {
1102
1176
  return _applyPromotion.apply(this, arguments);
@@ -1218,14 +1292,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1218
1292
  }, {
1219
1293
  key: "saveDraft",
1220
1294
  value: function () {
1221
- var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
1222
- return _regeneratorRuntime().wrap(function _callee7$(_context9) {
1223
- while (1) switch (_context9.prev = _context9.next) {
1295
+ var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
1296
+ return _regeneratorRuntime().wrap(function _callee8$(_context10) {
1297
+ while (1) switch (_context10.prev = _context10.next) {
1224
1298
  case 0:
1225
1299
  case "end":
1226
- return _context9.stop();
1300
+ return _context10.stop();
1227
1301
  }
1228
- }, _callee7);
1302
+ }, _callee8);
1229
1303
  }));
1230
1304
  function saveDraft() {
1231
1305
  return _saveDraft.apply(this, arguments);
@@ -1240,18 +1314,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1240
1314
  }, {
1241
1315
  key: "hydrateTempOrderFromLocalRecord",
1242
1316
  value: function () {
1243
- var _hydrateTempOrderFromLocalRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(record) {
1244
- return _regeneratorRuntime().wrap(function _callee8$(_context10) {
1245
- while (1) switch (_context10.prev = _context10.next) {
1317
+ var _hydrateTempOrderFromLocalRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(record) {
1318
+ return _regeneratorRuntime().wrap(function _callee9$(_context11) {
1319
+ while (1) switch (_context11.prev = _context11.next) {
1246
1320
  case 0:
1247
- return _context10.abrupt("return", this.hydrateTempOrderFromRecord(record));
1321
+ return _context11.abrupt("return", this.hydrateTempOrderFromRecord(record));
1248
1322
  case 1:
1249
1323
  case "end":
1250
- return _context10.stop();
1324
+ return _context11.stop();
1251
1325
  }
1252
- }, _callee8, this);
1326
+ }, _callee9, this);
1253
1327
  }));
1254
- function hydrateTempOrderFromLocalRecord(_x7) {
1328
+ function hydrateTempOrderFromLocalRecord(_x8) {
1255
1329
  return _hydrateTempOrderFromLocalRecord.apply(this, arguments);
1256
1330
  }
1257
1331
  return hydrateTempOrderFromLocalRecord;
@@ -1285,6 +1359,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1285
1359
  return sum.plus(_this4.calculatePaymentEffectiveAmount(payment));
1286
1360
  }, new Decimal(0));
1287
1361
  }
1362
+ }, {
1363
+ key: "calculateOrderPaidPaymentTotal",
1364
+ value: function calculateOrderPaidPaymentTotal(payments) {
1365
+ var _this5 = this;
1366
+ return mapPaymentItemsToOrderPayments(payments, {
1367
+ includeVoided: false
1368
+ }).reduce(function (sum, payment) {
1369
+ if (!isPaidPaymentRecord(payment)) return sum;
1370
+ return sum.plus(_this5.calculatePaymentGapAmount(payment));
1371
+ }, new Decimal(0));
1372
+ }
1288
1373
  }, {
1289
1374
  key: "getDepositAmount",
1290
1375
  value: function getDepositAmount(tempOrder, summary) {
@@ -1385,7 +1470,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1385
1470
  var summary = this.store.summary || createEmptySummary();
1386
1471
  var paymentList = payments || tempOrder.payments || [];
1387
1472
  var refundAmount = this.getSummaryRefundAmount(summary);
1388
- var netPaidAmount = Decimal.max(this.calculatePaymentTotal(paymentList).minus(refundAmount), 0);
1473
+ var netPaidAmount = Decimal.max(this.calculateOrderPaidPaymentTotal(paymentList).minus(refundAmount), 0);
1389
1474
  var depositAmount = this.getDepositAmount(tempOrder, summary);
1390
1475
  var orderExpectedAmount = this.getOrderExpectedAmount(summary);
1391
1476
  var isDepositFullyPaid = this.isDepositCovered({
@@ -1407,17 +1492,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1407
1492
  }, {
1408
1493
  key: "calculateDepositPaidAmount",
1409
1494
  value: function calculateDepositPaidAmount(payments) {
1410
- var _this5 = this;
1495
+ var _this6 = this;
1411
1496
  return (payments || []).reduce(function (sum, payment) {
1412
1497
  var paymentRecord = payment;
1413
1498
  if (!isPaidPaymentRecord(paymentRecord)) return sum;
1414
1499
  var isDepositPayment = paymentRecord.type === 'deposit' || paymentRecord.order_payment_type === 'deposit';
1415
1500
  if (!isDepositPayment) return sum;
1416
- if (paymentRecord.origin_amount !== undefined && paymentRecord.origin_amount !== null && paymentRecord.origin_amount !== '') {
1417
- return sum.plus(_this5.calculatePaymentGapAmount(paymentRecord));
1418
- }
1419
- var rounding = new Decimal(paymentRecord.rounding_amount || 0);
1420
- return sum.plus(new Decimal(paymentRecord.amount || 0).minus(rounding));
1501
+ return sum.plus(_this6.calculatePaymentGapAmount(paymentRecord));
1421
1502
  }, new Decimal(0));
1422
1503
  }
1423
1504
  }, {
@@ -1454,8 +1535,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1454
1535
  value: function updateTempOrderPaymentStatus(tempOrder, options) {
1455
1536
  var summary = (options === null || options === void 0 ? void 0 : options.summary) || this.store.summary || createEmptySummary();
1456
1537
  var paymentTotal = this.calculatePaymentTotal(tempOrder.payments || []);
1538
+ var orderPaymentTotal = this.calculateOrderPaidPaymentTotal(tempOrder.payments || []);
1457
1539
  var refundAmount = this.getSummaryRefundAmount(summary);
1458
- var netPaymentTotal = Decimal.max(paymentTotal.minus(refundAmount), 0);
1540
+ var netPaymentTotal = Decimal.max(orderPaymentTotal.minus(refundAmount), 0);
1459
1541
  var targetAmount = this.calculatePaymentTargetAmount(tempOrder, summary, netPaymentTotal);
1460
1542
  if (this.shouldKeepPaymentStatusAfterAmountRecalc(tempOrder.payment_status, {
1461
1543
  netPaymentTotal: netPaymentTotal,
@@ -1521,7 +1603,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1521
1603
  key: "capVoucherPaymentsByRemainingAmount",
1522
1604
  value: function capVoucherPaymentsByRemainingAmount(params) {
1523
1605
  var targetAmount = this.getPaymentTargetAmount();
1524
- var nonVoucherTotal = this.calculatePaymentTotal(params.nonVoucherPayments);
1606
+ var nonVoucherTotal = this.calculateOrderPaidPaymentTotal(params.nonVoucherPayments);
1525
1607
  if (targetAmount.lte(0)) return [];
1526
1608
  var remainingAmount = Decimal.max(targetAmount.minus(nonVoucherTotal), 0);
1527
1609
  var cappedVouchers = [];
@@ -1558,16 +1640,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1558
1640
  }, {
1559
1641
  key: "calculatePaidPaymentSummary",
1560
1642
  value: function calculatePaidPaymentSummary(payments) {
1561
- var _this6 = this;
1643
+ var _this7 = this;
1562
1644
  return (payments || []).reduce(function (summary, payment) {
1563
1645
  var paymentRecord = payment;
1564
1646
  if (!isPaidPaymentRecord(paymentRecord)) return summary;
1565
1647
  return {
1566
1648
  customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
1567
- orderPaidAmount: summary.orderPaidAmount.plus(paymentRecord.origin_amount || 0),
1568
- gapPaidAmount: summary.gapPaidAmount.plus(_this6.calculatePaymentGapAmount(paymentRecord)),
1569
- payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this6.calculatePaymentServiceFee(paymentRecord)),
1570
- roundingAmount: summary.roundingAmount.plus(_this6.calculatePaymentRoundingAmount(paymentRecord))
1649
+ orderPaidAmount: summary.orderPaidAmount.plus(_this7.calculatePaymentOrderAmount(paymentRecord)),
1650
+ gapPaidAmount: summary.gapPaidAmount.plus(_this7.calculatePaymentGapAmount(paymentRecord)),
1651
+ payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this7.calculatePaymentServiceFee(paymentRecord)),
1652
+ roundingAmount: summary.roundingAmount.plus(_this7.calculatePaymentRoundingAmount(paymentRecord))
1571
1653
  };
1572
1654
  }, {
1573
1655
  customerPaidAmount: new Decimal(0),
@@ -1591,11 +1673,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1591
1673
  }, {
1592
1674
  key: "calculatePaymentGapAmount",
1593
1675
  value: function calculatePaymentGapAmount(payment) {
1594
- if (payment.origin_amount === undefined || payment.origin_amount === null || payment.origin_amount === '') {
1595
- return new Decimal(0);
1676
+ if (payment.origin_amount !== undefined && payment.origin_amount !== null && payment.origin_amount !== '') {
1677
+ var _rounding = new Decimal(payment.rounding_amount || 0);
1678
+ return new Decimal(payment.origin_amount || 0).minus(_rounding);
1596
1679
  }
1597
1680
  var rounding = new Decimal(payment.rounding_amount || 0);
1598
- return new Decimal(payment.origin_amount || 0).minus(rounding);
1681
+ var amount = new Decimal(payment.amount || 0);
1682
+ var serviceFee = this.calculatePaymentServiceFee(payment);
1683
+ if (serviceFee.lte(0)) return amount.minus(rounding);
1684
+ if (!hasSyncedOrderPaymentRecord(payment)) return new Decimal(0);
1685
+ return Decimal.max(amount.minus(serviceFee), 0).minus(rounding);
1686
+ }
1687
+ }, {
1688
+ key: "calculatePaymentOrderAmount",
1689
+ value: function calculatePaymentOrderAmount(payment) {
1690
+ if (payment.origin_amount !== undefined && payment.origin_amount !== null && payment.origin_amount !== '') {
1691
+ return new Decimal(payment.origin_amount || 0);
1692
+ }
1693
+ var amount = new Decimal(payment.amount || 0);
1694
+ var serviceFee = this.calculatePaymentServiceFee(payment);
1695
+ if (serviceFee.lte(0)) return amount;
1696
+ if (!hasSyncedOrderPaymentRecord(payment)) return new Decimal(0);
1697
+ return Decimal.max(amount.minus(serviceFee), 0);
1599
1698
  }
1600
1699
  }, {
1601
1700
  key: "calculatePaymentRoundingAmount",
@@ -1752,15 +1851,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1752
1851
  }, {
1753
1852
  key: "normalizeFingerprintValue",
1754
1853
  value: function normalizeFingerprintValue(value) {
1755
- var _this7 = this;
1854
+ var _this8 = this;
1756
1855
  if (Array.isArray(value)) {
1757
1856
  return value.map(function (item) {
1758
- return _this7.normalizeFingerprintValue(item);
1857
+ return _this8.normalizeFingerprintValue(item);
1759
1858
  });
1760
1859
  }
1761
1860
  if (!value || _typeof(value) !== 'object') return value !== null && value !== void 0 ? value : '';
1762
1861
  return Object.keys(value).sort().reduce(function (result, key) {
1763
- result[key] = _this7.normalizeFingerprintValue(value[key]);
1862
+ result[key] = _this8.normalizeFingerprintValue(value[key]);
1764
1863
  return result;
1765
1864
  }, {});
1766
1865
  }
@@ -1775,7 +1874,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1775
1874
  _sku$barcode,
1776
1875
  _ref20,
1777
1876
  _sku$variant_id,
1778
- _this8 = this;
1877
+ _this9 = this;
1779
1878
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
1780
1879
  var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
1781
1880
  var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
@@ -1809,7 +1908,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1809
1908
  option_group_id: (_option$option_group_ = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_ !== void 0 ? _option$option_group_ : null,
1810
1909
  option_group_item_id: (_ref22 = (_option$option_group_2 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_2 !== void 0 ? _option$option_group_2 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref22 !== void 0 ? _ref22 : null,
1811
1910
  num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
1812
- add_price: _this8.normalizeFingerprintMoney((_option$add_price = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price !== void 0 ? _option$add_price : option === null || option === void 0 ? void 0 : option.price)
1911
+ add_price: _this9.normalizeFingerprintMoney((_option$add_price = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price !== void 0 ? _option$add_price : option === null || option === void 0 ? void 0 : option.price)
1813
1912
  };
1814
1913
  })
1815
1914
  }),
@@ -1819,8 +1918,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1819
1918
  bundle_product_id: (_ref23 = (_ref24 = (_bundle$bundle_produc = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref24 !== void 0 ? _ref24 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref23 !== void 0 ? _ref23 : null,
1820
1919
  bundle_variant_id: (_ref25 = (_bundle$bundle_varian = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle === null || bundle === void 0 ? void 0 : bundle.product_variant_id) !== null && _ref25 !== void 0 ? _ref25 : 0,
1821
1920
  num: getSafeProductNum((_bundle$num = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num !== void 0 ? _bundle$num : bundle === null || bundle === void 0 ? void 0 : bundle.quantity),
1822
- price: _this8.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
1823
- bundle_selling_price: _this8.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
1921
+ price: _this9.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
1922
+ bundle_selling_price: _this9.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
1824
1923
  price_type: (_bundle$price_type = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type !== void 0 ? _bundle$price_type : '',
1825
1924
  price_type_ext: (_bundle$price_type_ex = bundle === null || bundle === void 0 ? void 0 : bundle.price_type_ext) !== null && _bundle$price_type_ex !== void 0 ? _bundle$price_type_ex : ''
1826
1925
  };
@@ -1830,7 +1929,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1830
1929
  return {
1831
1930
  type: (_ref26 = (_discount$type2 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type2 !== void 0 ? _discount$type2 : discount === null || discount === void 0 ? void 0 : discount.tag) !== null && _ref26 !== void 0 ? _ref26 : '',
1832
1931
  discount_id: (_ref27 = (_ref28 = (_discount$discount_id = discount === null || discount === void 0 ? void 0 : discount.discount_id) !== null && _discount$discount_id !== void 0 ? _discount$discount_id : discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== null && _ref28 !== void 0 ? _ref28 : discount === null || discount === void 0 || (_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) !== null && _ref27 !== void 0 ? _ref27 : null,
1833
- amount: _this8.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
1932
+ amount: _this9.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
1834
1933
  };
1835
1934
  }))
1836
1935
  };
@@ -1838,9 +1937,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1838
1937
  }, {
1839
1938
  key: "buildOrderProductsFingerprint",
1840
1939
  value: function buildOrderProductsFingerprint(products) {
1841
- var _this9 = this;
1940
+ var _this10 = this;
1842
1941
  var items = (products || []).map(function (product) {
1843
- return _this9.buildProductFingerprintItem(product);
1942
+ return _this10.buildProductFingerprintItem(product);
1844
1943
  });
1845
1944
  items.sort(function (left, right) {
1846
1945
  return JSON.stringify(left).localeCompare(JSON.stringify(right));
@@ -1862,7 +1961,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1862
1961
  _sku$barcode2,
1863
1962
  _ref30,
1864
1963
  _sku$variant_id2,
1865
- _this10 = this;
1964
+ _this11 = this;
1866
1965
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
1867
1966
  var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
1868
1967
  var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
@@ -1893,7 +1992,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1893
1992
  option_group_id: (_option$option_group_3 = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_3 !== void 0 ? _option$option_group_3 : null,
1894
1993
  option_group_item_id: (_ref32 = (_option$option_group_4 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_4 !== void 0 ? _option$option_group_4 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref32 !== void 0 ? _ref32 : null,
1895
1994
  num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
1896
- add_price: _this10.normalizeFingerprintMoney((_option$add_price2 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price2 !== void 0 ? _option$add_price2 : option === null || option === void 0 ? void 0 : option.price)
1995
+ add_price: _this11.normalizeFingerprintMoney((_option$add_price2 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price2 !== void 0 ? _option$add_price2 : option === null || option === void 0 ? void 0 : option.price)
1897
1996
  };
1898
1997
  })
1899
1998
  }),
@@ -1907,14 +2006,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1907
2006
  num: getSafeProductNum((_bundle$num2 = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num2 !== void 0 ? _bundle$num2 : bundle === null || bundle === void 0 ? void 0 : bundle.quantity),
1908
2007
  price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
1909
2008
  price_type_ext: (_bundle$price_type_ex2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type_ext) !== null && _bundle$price_type_ex2 !== void 0 ? _bundle$price_type_ex2 : '',
1910
- option: _this10.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
2009
+ option: _this11.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
1911
2010
  var _ref38, _option$id3, _option$option_group_5, _ref39, _option$option_group_6, _option$num3, _option$add_price3;
1912
2011
  return {
1913
2012
  id: (_ref38 = (_option$id3 = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id3 !== void 0 ? _option$id3 : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref38 !== void 0 ? _ref38 : null,
1914
2013
  option_group_id: (_option$option_group_5 = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_5 !== void 0 ? _option$option_group_5 : null,
1915
2014
  option_group_item_id: (_ref39 = (_option$option_group_6 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_6 !== void 0 ? _option$option_group_6 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref39 !== void 0 ? _ref39 : null,
1916
2015
  num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
1917
- add_price: _this10.normalizeFingerprintMoney((_option$add_price3 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price3 !== void 0 ? _option$add_price3 : option === null || option === void 0 ? void 0 : option.price)
2016
+ add_price: _this11.normalizeFingerprintMoney((_option$add_price3 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price3 !== void 0 ? _option$add_price3 : option === null || option === void 0 ? void 0 : option.price)
1918
2017
  };
1919
2018
  }))
1920
2019
  };
@@ -1924,7 +2023,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1924
2023
  return {
1925
2024
  type: (_ref40 = (_discount$type4 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type4 !== void 0 ? _discount$type4 : discount === null || discount === void 0 ? void 0 : discount.tag) !== null && _ref40 !== void 0 ? _ref40 : '',
1926
2025
  discount_id: (_ref41 = (_ref42 = (_discount$discount_id2 = discount === null || discount === void 0 ? void 0 : discount.discount_id) !== null && _discount$discount_id2 !== void 0 ? _discount$discount_id2 : discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== null && _ref42 !== void 0 ? _ref42 : discount === null || discount === void 0 || (_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) !== null && _ref41 !== void 0 ? _ref41 : null,
1927
- amount: _this10.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2026
+ amount: _this11.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
1928
2027
  };
1929
2028
  }))
1930
2029
  };
@@ -1932,9 +2031,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1932
2031
  }, {
1933
2032
  key: "buildOrderProductsStructuralFingerprint",
1934
2033
  value: function buildOrderProductsStructuralFingerprint(products) {
1935
- var _this11 = this;
2034
+ var _this12 = this;
1936
2035
  var items = (products || []).map(function (product) {
1937
- return _this11.buildProductStructuralFingerprintItem(product);
2036
+ return _this12.buildProductStructuralFingerprintItem(product);
1938
2037
  });
1939
2038
  items.sort(function (left, right) {
1940
2039
  return JSON.stringify(left).localeCompare(JSON.stringify(right));
@@ -2010,13 +2109,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2010
2109
  key: "restoreOriginalSnapshotIfProductsUnchanged",
2011
2110
  value: function restoreOriginalSnapshotIfProductsUnchanged(tempOrder, snapshot) {
2012
2111
  var currentFingerprint = this.buildOrderProductsFingerprint(tempOrder.products);
2112
+ var manualDepositOverride = this.getManualDepositOverride(tempOrder);
2013
2113
  if (currentFingerprint !== snapshot.productFingerprint) {
2014
2114
  var currentStructuralFingerprint = this.buildOrderProductsStructuralFingerprint(tempOrder.products);
2015
2115
  var snapshotStructuralFingerprint = this.buildOrderProductsStructuralFingerprint(Array.isArray(snapshot.products) ? snapshot.products : []);
2016
2116
  if (currentStructuralFingerprint !== snapshotStructuralFingerprint) return null;
2017
2117
  }
2018
2118
  var summary = _objectSpread(_objectSpread({}, createEmptySummary()), cloneDeep(snapshot.summary || {}));
2019
- if (!this.isSnapshotPayableAmountUnchanged(tempOrder, snapshot, summary)) return null;
2119
+ var shouldUseManualDepositOverride = Boolean(manualDepositOverride && manualDepositOverride.productStructuralFingerprint === this.buildOrderProductsStructuralFingerprint(tempOrder.products));
2120
+ if (shouldUseManualDepositOverride) {
2121
+ summary = this.applyDepositAmountToSummary(tempOrder, summary, manualDepositOverride.amount);
2122
+ } else if (manualDepositOverride) {
2123
+ this.clearManualDepositOverride(tempOrder);
2124
+ }
2125
+ var isPayableAmountUnchanged = this.isSnapshotPayableAmountUnchanged(tempOrder, snapshot, summary);
2126
+ if (!isPayableAmountUnchanged) return null;
2020
2127
  if (Array.isArray(snapshot.products)) {
2021
2128
  tempOrder.products = cloneDeep(snapshot.products);
2022
2129
  }
@@ -2026,7 +2133,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2026
2133
  tempOrder.surcharge_fee = summary.surcharge_fee || tempOrder.surcharge_fee;
2027
2134
  tempOrder.deposit_amount = summary.deposit_amount || '0.00';
2028
2135
  tempOrder.is_deposit = summary.deposit_amount !== '0.00' ? 1 : 0;
2136
+ var previousSummary = this.store.summary;
2029
2137
  this.store.summary = summary;
2138
+ this.updateTempOrderPaymentStatus(tempOrder, {
2139
+ previousSummary: previousSummary,
2140
+ summary: summary
2141
+ });
2030
2142
  return summary;
2031
2143
  }
2032
2144
  }, {
@@ -2138,7 +2250,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2138
2250
  }, {
2139
2251
  key: "restoreOrder",
2140
2252
  value: function restoreOrder() {
2141
- var _this$store$discount11, _this$store$discount12;
2253
+ var _this$store$discount15, _this$store$discount16;
2142
2254
  this.logInfo('restoreOrder start', {});
2143
2255
  var freshTempOrder = this.createDefaultTempOrderInstance();
2144
2256
  this.ensureExternalSaleNumber(freshTempOrder);
@@ -2146,8 +2258,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2146
2258
  this.store.summary = createEmptySummary();
2147
2259
  this.store.lastOrderInfo = undefined;
2148
2260
  this.store.syncState = undefined;
2149
- void ((_this$store$discount11 = this.store.discount) === null || _this$store$discount11 === void 0 ? void 0 : _this$store$discount11.setOriginalDiscountList([]));
2150
- void ((_this$store$discount12 = this.store.discount) === null || _this$store$discount12 === void 0 ? void 0 : _this$store$discount12.setDiscountList([]));
2261
+ void ((_this$store$discount15 = this.store.discount) === null || _this$store$discount15 === void 0 ? void 0 : _this$store$discount15.setOriginalDiscountList([]));
2262
+ void ((_this$store$discount16 = this.store.discount) === null || _this$store$discount16 === void 0 ? void 0 : _this$store$discount16.setDiscountList([]));
2151
2263
  this.persistTempOrder();
2152
2264
  return freshTempOrder;
2153
2265
  }
@@ -2159,13 +2271,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2159
2271
  }, {
2160
2272
  key: "replaceTempOrder",
2161
2273
  value: function () {
2162
- var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(tempOrder, options) {
2274
+ var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(tempOrder, options) {
2163
2275
  var nextTempOrder;
2164
- return _regeneratorRuntime().wrap(function _callee9$(_context11) {
2165
- while (1) switch (_context11.prev = _context11.next) {
2276
+ return _regeneratorRuntime().wrap(function _callee10$(_context12) {
2277
+ while (1) switch (_context12.prev = _context12.next) {
2166
2278
  case 0:
2167
2279
  if (isTempOrder(tempOrder)) {
2168
- _context11.next = 2;
2280
+ _context12.next = 2;
2169
2281
  break;
2170
2282
  }
2171
2283
  throw new Error('无效的 tempOrder 数据');
@@ -2175,15 +2287,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2175
2287
  });
2176
2288
  this.store.tempOrder = nextTempOrder;
2177
2289
  if (!((options === null || options === void 0 ? void 0 : options.recalculateSummary) !== false)) {
2178
- _context11.next = 9;
2290
+ _context12.next = 9;
2179
2291
  break;
2180
2292
  }
2181
- _context11.next = 7;
2293
+ _context12.next = 7;
2182
2294
  return this.recalculateSummary({
2183
2295
  createIfMissing: false
2184
2296
  });
2185
2297
  case 7:
2186
- _context11.next = 10;
2298
+ _context12.next = 10;
2187
2299
  break;
2188
2300
  case 9:
2189
2301
  this.store.summary = createEmptySummary();
@@ -2192,20 +2304,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2192
2304
  this.persistTempOrder();
2193
2305
  }
2194
2306
  if (!(options !== null && options !== void 0 && options.saveDraft)) {
2195
- _context11.next = 14;
2307
+ _context12.next = 14;
2196
2308
  break;
2197
2309
  }
2198
- _context11.next = 14;
2310
+ _context12.next = 14;
2199
2311
  return this.saveDraft();
2200
2312
  case 14:
2201
- return _context11.abrupt("return", nextTempOrder);
2313
+ return _context12.abrupt("return", nextTempOrder);
2202
2314
  case 15:
2203
2315
  case "end":
2204
- return _context11.stop();
2316
+ return _context12.stop();
2205
2317
  }
2206
- }, _callee9, this);
2318
+ }, _callee10, this);
2207
2319
  }));
2208
- function replaceTempOrder(_x8, _x9) {
2320
+ function replaceTempOrder(_x9, _x10) {
2209
2321
  return _replaceTempOrder.apply(this, arguments);
2210
2322
  }
2211
2323
  return replaceTempOrder;
@@ -2291,32 +2403,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2291
2403
  }, {
2292
2404
  key: "addNewOrder",
2293
2405
  value: function () {
2294
- var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
2406
+ var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
2295
2407
  var tempOrder;
2296
- return _regeneratorRuntime().wrap(function _callee10$(_context12) {
2297
- while (1) switch (_context12.prev = _context12.next) {
2408
+ return _regeneratorRuntime().wrap(function _callee11$(_context13) {
2409
+ while (1) switch (_context13.prev = _context13.next) {
2298
2410
  case 0:
2299
2411
  tempOrder = this.ensureTempOrder();
2300
2412
  this.ensureExternalSaleNumber(tempOrder);
2301
- _context12.next = 4;
2413
+ _context13.next = 4;
2302
2414
  return this.recalculateSummary({
2303
2415
  createIfMissing: true
2304
2416
  });
2305
2417
  case 4:
2306
2418
  this.persistTempOrder();
2307
2419
  if (!this.draftPersistEnabled) {
2308
- _context12.next = 8;
2420
+ _context13.next = 8;
2309
2421
  break;
2310
2422
  }
2311
- _context12.next = 8;
2423
+ _context13.next = 8;
2312
2424
  return this.saveDraft();
2313
2425
  case 8:
2314
- return _context12.abrupt("return", tempOrder);
2426
+ return _context13.abrupt("return", tempOrder);
2315
2427
  case 9:
2316
2428
  case "end":
2317
- return _context12.stop();
2429
+ return _context13.stop();
2318
2430
  }
2319
- }, _callee10, this);
2431
+ }, _callee11, this);
2320
2432
  }));
2321
2433
  function addNewOrder() {
2322
2434
  return _addNewOrder.apply(this, arguments);
@@ -2349,9 +2461,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2349
2461
  }, {
2350
2462
  key: "sanitizeTempOrderProducts",
2351
2463
  value: function sanitizeTempOrderProducts(tempOrder) {
2352
- var _this12 = this;
2464
+ var _this13 = this;
2353
2465
  tempOrder.products = (tempOrder.products || []).map(function (product) {
2354
- return _this12.sanitizeOrderProductForTempOrder(product);
2466
+ return _this13.sanitizeOrderProductForTempOrder(product);
2355
2467
  });
2356
2468
  }
2357
2469
  }, {
@@ -2454,7 +2566,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2454
2566
  }, {
2455
2567
  key: "syncLinkedBookingHoldersToProducts",
2456
2568
  value: function syncLinkedBookingHoldersToProducts(tempOrder) {
2457
- var _this13 = this;
2569
+ var _this14 = this;
2458
2570
  var bookings = tempOrder.bookings || [];
2459
2571
  var products = tempOrder.products || [];
2460
2572
  if (!bookings.length || !products.length) return;
@@ -2479,7 +2591,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2479
2591
  var bookingUid = product.booking_uid || ((_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.booking_uid);
2480
2592
  var linkedBooking = (productUid !== undefined && productUid !== null && String(productUid) !== '' ? bookingByProductUid.get(String(productUid)) : undefined) || (bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '' ? bookingByBookingUid.get(String(bookingUid)) : undefined);
2481
2593
  if (linkedBooking) {
2482
- _this13.setProductHolderFromBooking(product, linkedBooking);
2594
+ _this14.setProductHolderFromBooking(product, linkedBooking);
2483
2595
  }
2484
2596
  });
2485
2597
  }
@@ -2517,7 +2629,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2517
2629
  }, {
2518
2630
  key: "buildTempOrderHolderFromBookings",
2519
2631
  value: function buildTempOrderHolderFromBookings(tempOrder) {
2520
- var _baseHolder$customer_, _baseHolder, _ref46, _baseHolder$form_id, _baseHolder2, _tempOrder$holder3, _baseHolder3, _this$otherParams;
2632
+ var _baseHolder$customer_, _baseHolder, _ref46, _baseHolder$form_id, _baseHolder2, _tempOrder$holder2, _baseHolder3, _this$otherParams;
2521
2633
  var holderRecords = [];
2522
2634
  var holderNames = [];
2523
2635
  var baseHolder = null;
@@ -2564,7 +2676,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2564
2676
  }
2565
2677
  var nextHolder = {
2566
2678
  customer_id: (_baseHolder$customer_ = (_baseHolder = baseHolder) === null || _baseHolder === void 0 ? void 0 : _baseHolder.customer_id) !== null && _baseHolder$customer_ !== void 0 ? _baseHolder$customer_ : tempOrder.customer_id,
2567
- form_id: (_ref46 = (_baseHolder$form_id = (_baseHolder2 = baseHolder) === null || _baseHolder2 === void 0 ? void 0 : _baseHolder2.form_id) !== null && _baseHolder$form_id !== void 0 ? _baseHolder$form_id : (_tempOrder$holder3 = tempOrder.holder) === null || _tempOrder$holder3 === void 0 ? void 0 : _tempOrder$holder3.form_id) !== null && _ref46 !== void 0 ? _ref46 : 0,
2679
+ form_id: (_ref46 = (_baseHolder$form_id = (_baseHolder2 = baseHolder) === null || _baseHolder2 === void 0 ? void 0 : _baseHolder2.form_id) !== null && _baseHolder$form_id !== void 0 ? _baseHolder$form_id : (_tempOrder$holder2 = tempOrder.holder) === null || _tempOrder$holder2 === void 0 ? void 0 : _tempOrder$holder2.form_id) !== null && _ref46 !== void 0 ? _ref46 : 0,
2568
2680
  form_record: holderRecords
2569
2681
  };
2570
2682
  if (holderNames.length) {
@@ -2607,9 +2719,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2607
2719
  }, {
2608
2720
  key: "findBookingIndexByUniqueIdentificationNumber",
2609
2721
  value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
2610
- var _this14 = this;
2722
+ var _this15 = this;
2611
2723
  return (tempOrder.bookings || []).findIndex(function (booking) {
2612
- return _this14.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
2724
+ return _this15.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
2613
2725
  });
2614
2726
  }
2615
2727
  }, {
@@ -2617,12 +2729,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2617
2729
  value: function removeLinkedBookingsForProduct(tempOrder, product) {
2618
2730
  var _product$metadata7,
2619
2731
  _product$metadata8,
2620
- _this15 = this;
2732
+ _this16 = this;
2621
2733
  var productUid = (product === null || product === void 0 || (_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
2622
2734
  var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.booking_uid);
2623
2735
  if (!productUid && !bookingUid) return;
2624
2736
  tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
2625
- var currentBookingUid = _this15.getBookingUniqueIdentificationNumber(booking);
2737
+ var currentBookingUid = _this16.getBookingUniqueIdentificationNumber(booking);
2626
2738
  if (bookingUid && currentBookingUid === String(bookingUid)) return false;
2627
2739
  if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
2628
2740
  return true;
@@ -2668,18 +2780,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2668
2780
  }, {
2669
2781
  key: "recalculateSummary",
2670
2782
  value: function () {
2671
- var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(options) {
2783
+ var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(options) {
2672
2784
  var _this$otherParams2, _ref47, _salesSummaryResult$e;
2673
2785
  var tempOrder, originalSnapshot, hasShopDiscountChanged, shouldReuseOriginalSnapshot, snapshotSummary, shouldFullRecalculateFromSnapshot, summaryProducts, salesSummary, existedSummary, totalRefundAmount, paidPaymentSummary, emptyBaseSummary, emptySummaryBase, emptySummaryWithDeposit, emptySummary, salesSummaryResult, roundingAmount, payServiceChargeAmount, hasSalesSummaryAmount, expectAmount, amountPaymentPatch, normalizedExpectAmountPatch, summaryForGap, summary;
2674
- return _regeneratorRuntime().wrap(function _callee11$(_context13) {
2675
- while (1) switch (_context13.prev = _context13.next) {
2786
+ return _regeneratorRuntime().wrap(function _callee12$(_context14) {
2787
+ while (1) switch (_context14.prev = _context14.next) {
2676
2788
  case 0:
2677
2789
  tempOrder = options !== null && options !== void 0 && options.createIfMissing ? this.ensureTempOrder() : this.store.tempOrder;
2678
2790
  if (tempOrder) {
2679
- _context13.next = 3;
2791
+ _context14.next = 3;
2680
2792
  break;
2681
2793
  }
2682
- return _context13.abrupt("return", null);
2794
+ return _context14.abrupt("return", null);
2683
2795
  case 3:
2684
2796
  this.sanitizeTempOrderProducts(tempOrder);
2685
2797
  originalSnapshot = this.getOriginalSalesSnapshot(tempOrder);
@@ -2687,10 +2799,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2687
2799
  shouldReuseOriginalSnapshot = originalSnapshot && !hasShopDiscountChanged;
2688
2800
  snapshotSummary = shouldReuseOriginalSnapshot ? this.restoreOriginalSnapshotIfProductsUnchanged(tempOrder, originalSnapshot) : null;
2689
2801
  if (!snapshotSummary) {
2690
- _context13.next = 10;
2802
+ _context14.next = 10;
2691
2803
  break;
2692
2804
  }
2693
- return _context13.abrupt("return", snapshotSummary);
2805
+ return _context14.abrupt("return", snapshotSummary);
2694
2806
  case 10:
2695
2807
  shouldFullRecalculateFromSnapshot = Boolean(originalSnapshot);
2696
2808
  summaryProducts = shouldFullRecalculateFromSnapshot ? cloneDeep(tempOrder.products || []) : tempOrder.products;
@@ -2702,7 +2814,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2702
2814
  totalRefundAmount = existedSummary.total_refund_amount || '0.00';
2703
2815
  paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
2704
2816
  if (salesSummary) {
2705
- _context13.next = 26;
2817
+ _context14.next = 26;
2706
2818
  break;
2707
2819
  }
2708
2820
  emptyBaseSummary = _objectSpread(_objectSpread(_objectSpread({}, createEmptySummary()), existedSummary), {}, {
@@ -2728,9 +2840,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2728
2840
  previousSummary: existedSummary,
2729
2841
  summary: emptySummary
2730
2842
  });
2731
- return _context13.abrupt("return", this.store.summary);
2843
+ return _context14.abrupt("return", this.store.summary);
2732
2844
  case 26:
2733
- _context13.next = 28;
2845
+ _context14.next = 28;
2734
2846
  return salesSummary.getSummary(_objectSpread({
2735
2847
  products: summaryProducts,
2736
2848
  isPriceIncludeTax: tempOrder.is_price_include_tax,
@@ -2739,7 +2851,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2739
2851
  channel: this.otherParams.channel
2740
2852
  } : {}));
2741
2853
  case 28:
2742
- salesSummaryResult = _context13.sent;
2854
+ salesSummaryResult = _context14.sent;
2743
2855
  if (shouldFullRecalculateFromSnapshot) {
2744
2856
  tempOrder.products = summaryProducts;
2745
2857
  }
@@ -2784,14 +2896,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2784
2896
  previousSummary: existedSummary,
2785
2897
  summary: summary
2786
2898
  });
2787
- return _context13.abrupt("return", this.store.summary);
2899
+ return _context14.abrupt("return", this.store.summary);
2788
2900
  case 46:
2789
2901
  case "end":
2790
- return _context13.stop();
2902
+ return _context14.stop();
2791
2903
  }
2792
- }, _callee11, this);
2904
+ }, _callee12, this);
2793
2905
  }));
2794
- function recalculateSummary(_x10) {
2906
+ function recalculateSummary(_x11) {
2795
2907
  return _recalculateSummary.apply(this, arguments);
2796
2908
  }
2797
2909
  return recalculateSummary;
@@ -2799,30 +2911,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2799
2911
  }, {
2800
2912
  key: "getOrderSummary",
2801
2913
  value: function () {
2802
- var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
2914
+ var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
2803
2915
  var summary;
2804
- return _regeneratorRuntime().wrap(function _callee12$(_context14) {
2805
- while (1) switch (_context14.prev = _context14.next) {
2916
+ return _regeneratorRuntime().wrap(function _callee13$(_context15) {
2917
+ while (1) switch (_context15.prev = _context15.next) {
2806
2918
  case 0:
2807
- _context14.next = 2;
2919
+ _context15.next = 2;
2808
2920
  return this.recalculateSummary({
2809
2921
  createIfMissing: true
2810
2922
  });
2811
2923
  case 2:
2812
- summary = _context14.sent;
2924
+ summary = _context15.sent;
2813
2925
  if (summary) {
2814
- _context14.next = 5;
2926
+ _context15.next = 5;
2815
2927
  break;
2816
2928
  }
2817
- return _context14.abrupt("return", createEmptySummary());
2929
+ return _context15.abrupt("return", createEmptySummary());
2818
2930
  case 5:
2819
2931
  this.persistTempOrder();
2820
- return _context14.abrupt("return", summary);
2932
+ return _context15.abrupt("return", summary);
2821
2933
  case 7:
2822
2934
  case "end":
2823
- return _context14.stop();
2935
+ return _context15.stop();
2824
2936
  }
2825
- }, _callee12, this);
2937
+ }, _callee13, this);
2826
2938
  }));
2827
2939
  function getOrderSummary() {
2828
2940
  return _getOrderSummary.apply(this, arguments);
@@ -2846,23 +2958,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2846
2958
  }, {
2847
2959
  key: "syncTempOrderNoteToRemote",
2848
2960
  value: function () {
2849
- var _syncTempOrderNoteToRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderId, note) {
2850
- return _regeneratorRuntime().wrap(function _callee13$(_context15) {
2851
- while (1) switch (_context15.prev = _context15.next) {
2961
+ var _syncTempOrderNoteToRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(orderId, note) {
2962
+ return _regeneratorRuntime().wrap(function _callee14$(_context16) {
2963
+ while (1) switch (_context16.prev = _context16.next) {
2852
2964
  case 0:
2853
- _context15.next = 2;
2965
+ _context16.next = 2;
2854
2966
  return this.request.put("/order/order/".concat(orderId, "/note"), {
2855
2967
  note: note
2856
2968
  });
2857
2969
  case 2:
2858
- return _context15.abrupt("return", note);
2970
+ return _context16.abrupt("return", note);
2859
2971
  case 3:
2860
2972
  case "end":
2861
- return _context15.stop();
2973
+ return _context16.stop();
2862
2974
  }
2863
- }, _callee13, this);
2975
+ }, _callee14, this);
2864
2976
  }));
2865
- function syncTempOrderNoteToRemote(_x11, _x12) {
2977
+ function syncTempOrderNoteToRemote(_x12, _x13) {
2866
2978
  return _syncTempOrderNoteToRemote.apply(this, arguments);
2867
2979
  }
2868
2980
  return syncTempOrderNoteToRemote;
@@ -2947,38 +3059,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2947
3059
  var type = (_discount$type5 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type5 !== void 0 ? _discount$type5 : discount === null || discount === void 0 ? void 0 : discount.tag;
2948
3060
  return type === 'good_pass' || type === 'discount_card' || type === 'product_discount_card';
2949
3061
  }
3062
+ }, {
3063
+ key: "shouldKeepCustomerBoundDiscountAfterCustomerChange",
3064
+ value: function shouldKeepCustomerBoundDiscountAfterCustomerChange(discount) {
3065
+ return Boolean((discount === null || discount === void 0 ? void 0 : discount.isScan) || (discount === null || discount === void 0 ? void 0 : discount.isEditMode));
3066
+ }
2950
3067
  }, {
2951
3068
  key: "productHasCustomerBoundDiscount",
2952
3069
  value: function productHasCustomerBoundDiscount(product) {
2953
- var _this16 = this;
3070
+ var _this17 = this;
2954
3071
  if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
2955
- return _this16.isCustomerBoundDiscount(discount);
3072
+ return _this17.isCustomerBoundDiscount(discount);
2956
3073
  })) {
2957
3074
  return true;
2958
3075
  }
2959
3076
  return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
2960
3077
  return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
2961
- return _this16.isCustomerBoundDiscount(discount);
3078
+ return _this17.isCustomerBoundDiscount(discount);
2962
3079
  });
2963
3080
  });
2964
3081
  }
2965
3082
  }, {
2966
3083
  key: "shouldSkipDiscountCalculation",
2967
3084
  value: function shouldSkipDiscountCalculation(tempOrder) {
2968
- var _this$store$discount13,
2969
- _this$store$discount14,
2970
- _this17 = this;
3085
+ var _this$store$discount17,
3086
+ _this$store$discount18,
3087
+ _this18 = this;
2971
3088
  if (this.hasActiveCustomerBoundDiscount) return false;
2972
- var discountList = ((_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 || (_this$store$discount14 = _this$store$discount13.getDiscountList) === null || _this$store$discount14 === void 0 ? void 0 : _this$store$discount14.call(_this$store$discount13)) || [];
3089
+ var discountList = ((_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 || (_this$store$discount18 = _this$store$discount17.getDiscountList) === null || _this$store$discount18 === void 0 ? void 0 : _this$store$discount18.call(_this$store$discount17)) || [];
2973
3090
  if (discountList.length > 0) return false;
2974
3091
  return !(tempOrder.products || []).some(function (product) {
2975
- return _this17.productHasCustomerBoundDiscount(product);
3092
+ return _this18.productHasCustomerBoundDiscount(product);
2976
3093
  });
2977
3094
  }
2978
3095
  }, {
2979
3096
  key: "clearCustomerBoundDiscounts",
2980
3097
  value: function clearCustomerBoundDiscounts(tempOrder) {
2981
- var _this18 = this,
3098
+ var _this19 = this,
2982
3099
  _discountModule$getDi,
2983
3100
  _discountModule$getOr,
2984
3101
  _discountModule$setDi,
@@ -2987,7 +3104,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2987
3104
  var filterDiscountList = function filterDiscountList(discountList) {
2988
3105
  if (!Array.isArray(discountList)) return [];
2989
3106
  return discountList.filter(function (discount) {
2990
- var shouldRemove = _this18.isCustomerBoundDiscount(discount);
3107
+ var shouldRemove = _this19.isCustomerBoundDiscount(discount);
2991
3108
  if (shouldRemove) didRemoveCustomerBoundDiscount = true;
2992
3109
  return !shouldRemove;
2993
3110
  });
@@ -3014,12 +3131,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3014
3131
  var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
3015
3132
  var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
3016
3133
  var nextDiscounts = currentDiscounts.filter(function (discount) {
3017
- if (discount !== null && discount !== void 0 && discount.isEditMode) return true;
3018
- return !_this18.isCustomerBoundDiscount(discount);
3134
+ if (_this19.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3135
+ return !_this19.isCustomerBoundDiscount(discount);
3019
3136
  });
3020
3137
  var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
3021
- if (discount !== null && discount !== void 0 && discount.isEditMode) return true;
3022
- return !_this18.isCustomerBoundDiscount(discount);
3138
+ if (_this19.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3139
+ return !_this19.isCustomerBoundDiscount(discount);
3023
3140
  });
3024
3141
  void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
3025
3142
  void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
@@ -3090,6 +3207,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3090
3207
  }
3091
3208
  var nextCustomerId = (_tempOrder$customer_i5 = tempOrder.customer_id) !== null && _tempOrder$customer_i5 !== void 0 ? _tempOrder$customer_i5 : null;
3092
3209
  if (String(previousCustomerId !== null && previousCustomerId !== void 0 ? previousCustomerId : '') !== String(nextCustomerId !== null && nextCustomerId !== void 0 ? nextCustomerId : '')) {
3210
+ this.store.availableWalletIds = [];
3093
3211
  clearTempOrderHolderAssignments(tempOrder);
3094
3212
  this.clearCustomerBoundDiscounts(tempOrder);
3095
3213
  this.applyDiscount();
@@ -3134,6 +3252,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3134
3252
  tempOrder.email = '';
3135
3253
  tempOrder.customer = null;
3136
3254
  if (tempOrder._extend) delete tempOrder._extend.customerSnapshot;
3255
+ this.store.availableWalletIds = [];
3137
3256
  this.clearCustomerBoundDiscounts(tempOrder);
3138
3257
  this.persistTempOrder();
3139
3258
  this.saveDraftInBackground();
@@ -3187,7 +3306,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3187
3306
  }, {
3188
3307
  key: "addOrderPayment",
3189
3308
  value: function addOrderPayment(payment) {
3190
- var _this19 = this;
3309
+ var _this20 = this;
3191
3310
  this.logInfo('addOrderPayment', {
3192
3311
  payment: payment
3193
3312
  });
@@ -3204,7 +3323,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3204
3323
  void this.recalculateSummary({
3205
3324
  createIfMissing: true
3206
3325
  }).catch(function (error) {
3207
- _this19.logError('recalculate summary after addOrderPayment failed', {
3326
+ _this20.logError('recalculate summary after addOrderPayment failed', {
3208
3327
  error: error instanceof Error ? error.message : String(error)
3209
3328
  });
3210
3329
  });
@@ -3286,7 +3405,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3286
3405
  }, {
3287
3406
  key: "applyPaymentLifecycleChange",
3288
3407
  value: function applyPaymentLifecycleChange(tempOrder, options) {
3289
- var _this20 = this;
3408
+ var _this21 = this;
3290
3409
  this.updateTempOrderPaymentStatus(tempOrder);
3291
3410
  if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
3292
3411
  this.persistTempOrder();
@@ -3296,7 +3415,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3296
3415
  void this.recalculateSummary({
3297
3416
  createIfMissing: true
3298
3417
  }).catch(function (error) {
3299
- _this20.logError("recalculate summary after ".concat(logContext, " failed"), {
3418
+ _this21.logError("recalculate summary after ".concat(logContext, " failed"), {
3300
3419
  error: error instanceof Error ? error.message : String(error)
3301
3420
  });
3302
3421
  });
@@ -3340,7 +3459,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3340
3459
  }, {
3341
3460
  key: "updateVoucherOrderPayments",
3342
3461
  value: function updateVoucherOrderPayments(payments, options) {
3343
- var _this21 = this;
3462
+ var _this22 = this;
3344
3463
  var tempOrder = this.ensureTempOrder();
3345
3464
  var isOrderPaymentType = function isOrderPaymentType(value) {
3346
3465
  return value === 'normal' || value === 'deposit';
@@ -3375,7 +3494,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3375
3494
  });
3376
3495
  };
3377
3496
  var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
3378
- return _this21.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
3497
+ return _this22.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
3379
3498
  defaultPaid: false
3380
3499
  });
3381
3500
  })).filter(function (payment) {
@@ -3424,7 +3543,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3424
3543
  void this.recalculateSummary({
3425
3544
  createIfMissing: true
3426
3545
  }).catch(function (error) {
3427
- _this21.logError('recalculate summary after updateVoucherOrderPayments failed', {
3546
+ _this22.logError('recalculate summary after updateVoucherOrderPayments failed', {
3428
3547
  error: error instanceof Error ? error.message : String(error)
3429
3548
  });
3430
3549
  });
@@ -3433,45 +3552,45 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3433
3552
  }, {
3434
3553
  key: "shouldMergeProductToOrder",
3435
3554
  value: function () {
3436
- var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(params) {
3555
+ var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
3437
3556
  var _this$orderHooks;
3438
3557
  var onBeforeMergeProductToOrder, result;
3439
- return _regeneratorRuntime().wrap(function _callee14$(_context16) {
3440
- while (1) switch (_context16.prev = _context16.next) {
3558
+ return _regeneratorRuntime().wrap(function _callee15$(_context17) {
3559
+ while (1) switch (_context17.prev = _context17.next) {
3441
3560
  case 0:
3442
3561
  onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
3443
3562
  if (onBeforeMergeProductToOrder) {
3444
- _context16.next = 3;
3563
+ _context17.next = 3;
3445
3564
  break;
3446
3565
  }
3447
- return _context16.abrupt("return", true);
3566
+ return _context17.abrupt("return", true);
3448
3567
  case 3:
3449
- _context16.next = 5;
3568
+ _context17.next = 5;
3450
3569
  return onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
3451
3570
  defaultShouldMerge: true
3452
3571
  }));
3453
3572
  case 5:
3454
- result = _context16.sent;
3573
+ result = _context17.sent;
3455
3574
  if (!(typeof result === 'boolean')) {
3456
- _context16.next = 8;
3575
+ _context17.next = 8;
3457
3576
  break;
3458
3577
  }
3459
- return _context16.abrupt("return", result);
3578
+ return _context17.abrupt("return", result);
3460
3579
  case 8:
3461
3580
  if (!(result && _typeof(result) === 'object' && typeof result.shouldMerge === 'boolean')) {
3462
- _context16.next = 10;
3581
+ _context17.next = 10;
3463
3582
  break;
3464
3583
  }
3465
- return _context16.abrupt("return", result.shouldMerge);
3584
+ return _context17.abrupt("return", result.shouldMerge);
3466
3585
  case 10:
3467
- return _context16.abrupt("return", true);
3586
+ return _context17.abrupt("return", true);
3468
3587
  case 11:
3469
3588
  case "end":
3470
- return _context16.stop();
3589
+ return _context17.stop();
3471
3590
  }
3472
- }, _callee14, this);
3591
+ }, _callee15, this);
3473
3592
  }));
3474
- function shouldMergeProductToOrder(_x13) {
3593
+ function shouldMergeProductToOrder(_x14) {
3475
3594
  return _shouldMergeProductToOrder.apply(this, arguments);
3476
3595
  }
3477
3596
  return shouldMergeProductToOrder;
@@ -3507,30 +3626,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3507
3626
  }, {
3508
3627
  key: "finalizeProductOrderMutation",
3509
3628
  value: function () {
3510
- var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(tempOrder, options) {
3511
- return _regeneratorRuntime().wrap(function _callee15$(_context17) {
3512
- while (1) switch (_context17.prev = _context17.next) {
3629
+ var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(tempOrder, options) {
3630
+ return _regeneratorRuntime().wrap(function _callee16$(_context18) {
3631
+ while (1) switch (_context18.prev = _context18.next) {
3513
3632
  case 0:
3514
3633
  this.syncTempOrderHolderFromBookings(tempOrder);
3515
3634
  if (options !== null && options !== void 0 && options.skipEditDiscountConfigRefresh) {
3516
- _context17.next = 4;
3635
+ _context18.next = 4;
3517
3636
  break;
3518
3637
  }
3519
- _context17.next = 4;
3638
+ _context18.next = 4;
3520
3639
  return this.ensureEditDiscountConfigForProductChange(tempOrder);
3521
3640
  case 4:
3522
3641
  if (options !== null && options !== void 0 && options.skipDiscountRecalculation) {
3523
- _context17.next = 7;
3642
+ _context18.next = 7;
3524
3643
  break;
3525
3644
  }
3526
- _context17.next = 7;
3645
+ _context18.next = 7;
3527
3646
  return this.applyPromotion();
3528
3647
  case 7:
3529
3648
  if (!(options !== null && options !== void 0 && options.skipDiscountRecalculation)) {
3530
3649
  this.applyDiscount();
3531
3650
  }
3532
3651
  this.sanitizeTempOrderProducts(tempOrder);
3533
- _context17.next = 11;
3652
+ _context18.next = 11;
3534
3653
  return this.recalculateSummary({
3535
3654
  createIfMissing: true
3536
3655
  });
@@ -3538,11 +3657,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3538
3657
  this.persistTempOrder();
3539
3658
  case 12:
3540
3659
  case "end":
3541
- return _context17.stop();
3660
+ return _context18.stop();
3542
3661
  }
3543
- }, _callee15, this);
3662
+ }, _callee16, this);
3544
3663
  }));
3545
- function finalizeProductOrderMutation(_x14, _x15) {
3664
+ function finalizeProductOrderMutation(_x15, _x16) {
3546
3665
  return _finalizeProductOrderMutation.apply(this, arguments);
3547
3666
  }
3548
3667
  return finalizeProductOrderMutation;
@@ -3557,13 +3676,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3557
3676
  }, {
3558
3677
  key: "appendProductLineToTempOrder",
3559
3678
  value: (function () {
3560
- var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(tempOrder, product, booking) {
3679
+ var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(tempOrder, product, booking) {
3561
3680
  var _booking_uid,
3562
3681
  _metadata,
3563
- _this22 = this;
3682
+ _this23 = this;
3564
3683
  var linked, productToAdd, incomingFingerprint, normalizedIncoming, incomingBookingUid, hasIncomingGoodPass, hasIncomingProductNote, hasIncomingBookingUid, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList;
3565
- return _regeneratorRuntime().wrap(function _callee16$(_context18) {
3566
- while (1) switch (_context18.prev = _context18.next) {
3684
+ return _regeneratorRuntime().wrap(function _callee17$(_context19) {
3685
+ while (1) switch (_context19.prev = _context19.next) {
3567
3686
  case 0:
3568
3687
  linked = booking ? this.createLinkedProductAndBooking({
3569
3688
  product: product,
@@ -3585,9 +3704,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3585
3704
  hasIncomingBookingUid = this.hasLinkedBookingUid(productToAdd) || this.hasLinkedBookingUid(normalizedIncoming);
3586
3705
  shouldForceNewLine = !!booking || hasIncomingProductNote || hasIncomingBookingUid;
3587
3706
  matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
3588
- if (_this22.hasGoodPassDiscount(item)) return false;
3589
- if (_this22.hasOrderProductLineNote(item)) return false;
3707
+ var _item$metadata3;
3708
+ if (_this23.hasGoodPassDiscount(item)) return false;
3709
+ if (_this23.hasOrderProductLineNote(item)) return false;
3590
3710
  if (item.order_detail_id !== undefined && item.order_detail_id !== null) return false;
3711
+ if ((_item$metadata3 = item.metadata) !== null && _item$metadata3 !== void 0 && _item$metadata3.is_edit_for_runtime) return false;
3591
3712
  if (item.product_id !== productToAdd.product_id) return false;
3592
3713
  if (item.product_variant_id !== productToAdd.product_variant_id) return false;
3593
3714
  var existedFingerprint = buildProductLineFingerprint(getProductSkuOptions(item), item.product_bundle);
@@ -3596,10 +3717,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3596
3717
  matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
3597
3718
  existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
3598
3719
  if (!matchedProduct) {
3599
- _context18.next = 20;
3720
+ _context19.next = 20;
3600
3721
  break;
3601
3722
  }
3602
- _context18.next = 17;
3723
+ _context19.next = 17;
3603
3724
  return this.shouldMergeProductToOrder({
3604
3725
  incomingProduct: productToAdd,
3605
3726
  normalizedIncoming: normalizedIncoming,
@@ -3611,13 +3732,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3611
3732
  booking: booking
3612
3733
  });
3613
3734
  case 17:
3614
- _context18.t0 = _context18.sent;
3615
- _context18.next = 21;
3735
+ _context19.t0 = _context19.sent;
3736
+ _context19.next = 21;
3616
3737
  break;
3617
3738
  case 20:
3618
- _context18.t0 = false;
3739
+ _context19.t0 = false;
3619
3740
  case 21:
3620
- shouldMerge = _context18.t0;
3741
+ shouldMerge = _context19.t0;
3621
3742
  if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
3622
3743
  this.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
3623
3744
  if (linked) {
@@ -3671,11 +3792,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3671
3792
  }
3672
3793
  case 24:
3673
3794
  case "end":
3674
- return _context18.stop();
3795
+ return _context19.stop();
3675
3796
  }
3676
- }, _callee16, this);
3797
+ }, _callee17, this);
3677
3798
  }));
3678
- function appendProductLineToTempOrder(_x16, _x17, _x18) {
3799
+ function appendProductLineToTempOrder(_x17, _x18, _x19) {
3679
3800
  return _appendProductLineToTempOrder.apply(this, arguments);
3680
3801
  }
3681
3802
  return appendProductLineToTempOrder;
@@ -3691,61 +3812,61 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3691
3812
  }, {
3692
3813
  key: "addProductToOrder",
3693
3814
  value: (function () {
3694
- var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(product, booking) {
3815
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(product, booking) {
3695
3816
  var tempOrder, _ref61, _productRecord$num, productRecord, splitCount, i, singleLine;
3696
- return _regeneratorRuntime().wrap(function _callee17$(_context19) {
3697
- while (1) switch (_context19.prev = _context19.next) {
3817
+ return _regeneratorRuntime().wrap(function _callee18$(_context20) {
3818
+ while (1) switch (_context20.prev = _context20.next) {
3698
3819
  case 0:
3699
3820
  tempOrder = this.ensureTempOrder();
3700
3821
  if (!booking) {
3701
- _context19.next = 18;
3822
+ _context20.next = 18;
3702
3823
  break;
3703
3824
  }
3704
3825
  productRecord = product;
3705
3826
  splitCount = getSafeProductNum((_ref61 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref61 !== void 0 ? _ref61 : 1);
3706
3827
  if (!(splitCount > 1)) {
3707
- _context19.next = 18;
3828
+ _context20.next = 18;
3708
3829
  break;
3709
3830
  }
3710
3831
  i = 0;
3711
3832
  case 6:
3712
3833
  if (!(i < splitCount)) {
3713
- _context19.next = 15;
3834
+ _context20.next = 15;
3714
3835
  break;
3715
3836
  }
3716
3837
  singleLine = cloneDeep(productRecord);
3717
3838
  singleLine.num = 1;
3718
3839
  delete singleLine.product_quantity;
3719
- _context19.next = 12;
3840
+ _context20.next = 12;
3720
3841
  return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
3721
3842
  case 12:
3722
3843
  i += 1;
3723
- _context19.next = 6;
3844
+ _context20.next = 6;
3724
3845
  break;
3725
3846
  case 15:
3726
- _context19.next = 17;
3847
+ _context20.next = 17;
3727
3848
  return this.finalizeProductOrderMutation(tempOrder);
3728
3849
  case 17:
3729
- return _context19.abrupt("return", tempOrder.products);
3850
+ return _context20.abrupt("return", tempOrder.products);
3730
3851
  case 18:
3731
- _context19.next = 20;
3852
+ _context20.next = 20;
3732
3853
  return this.appendProductLineToTempOrder(tempOrder, product, booking);
3733
3854
  case 20:
3734
- _context19.next = 22;
3855
+ _context20.next = 22;
3735
3856
  return this.finalizeProductOrderMutation(tempOrder);
3736
3857
  case 22:
3737
3858
  this.logInfo('addProductToOrder success', {
3738
3859
  product_id: product.product_id,
3739
3860
  with_booking: !!booking
3740
3861
  });
3741
- return _context19.abrupt("return", tempOrder.products);
3862
+ return _context20.abrupt("return", tempOrder.products);
3742
3863
  case 24:
3743
3864
  case "end":
3744
- return _context19.stop();
3865
+ return _context20.stop();
3745
3866
  }
3746
- }, _callee17, this);
3867
+ }, _callee18, this);
3747
3868
  }));
3748
- function addProductToOrder(_x19, _x20) {
3869
+ function addProductToOrder(_x20, _x21) {
3749
3870
  return _addProductToOrder.apply(this, arguments);
3750
3871
  }
3751
3872
  return addProductToOrder;
@@ -3763,93 +3884,93 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3763
3884
  }, {
3764
3885
  key: "addProductsToOrder",
3765
3886
  value: (function () {
3766
- var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(items, options) {
3887
+ var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(items, options) {
3767
3888
  var tempOrder, _iterator20, _step20, item, product, booking, _ref62, _productRecord$num2, productRecord, splitCount, i, singleLine;
3768
- return _regeneratorRuntime().wrap(function _callee18$(_context20) {
3769
- while (1) switch (_context20.prev = _context20.next) {
3889
+ return _regeneratorRuntime().wrap(function _callee19$(_context21) {
3890
+ while (1) switch (_context21.prev = _context21.next) {
3770
3891
  case 0:
3771
3892
  tempOrder = this.ensureTempOrder();
3772
3893
  if (!(!Array.isArray(items) || items.length === 0)) {
3773
- _context20.next = 3;
3894
+ _context21.next = 3;
3774
3895
  break;
3775
3896
  }
3776
- return _context20.abrupt("return", tempOrder.products);
3897
+ return _context21.abrupt("return", tempOrder.products);
3777
3898
  case 3:
3778
3899
  _iterator20 = _createForOfIteratorHelper(items || []);
3779
- _context20.prev = 4;
3900
+ _context21.prev = 4;
3780
3901
  _iterator20.s();
3781
3902
  case 6:
3782
3903
  if ((_step20 = _iterator20.n()).done) {
3783
- _context20.next = 30;
3904
+ _context21.next = 30;
3784
3905
  break;
3785
3906
  }
3786
3907
  item = _step20.value;
3787
3908
  product = item.product, booking = item.booking;
3788
3909
  if (product) {
3789
- _context20.next = 11;
3910
+ _context21.next = 11;
3790
3911
  break;
3791
3912
  }
3792
- return _context20.abrupt("continue", 28);
3913
+ return _context21.abrupt("continue", 28);
3793
3914
  case 11:
3794
3915
  if (!booking) {
3795
- _context20.next = 26;
3916
+ _context21.next = 26;
3796
3917
  break;
3797
3918
  }
3798
3919
  productRecord = product;
3799
3920
  splitCount = getSafeProductNum((_ref62 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref62 !== void 0 ? _ref62 : 1);
3800
3921
  if (!(splitCount > 1)) {
3801
- _context20.next = 26;
3922
+ _context21.next = 26;
3802
3923
  break;
3803
3924
  }
3804
3925
  i = 0;
3805
3926
  case 16:
3806
3927
  if (!(i < splitCount)) {
3807
- _context20.next = 25;
3928
+ _context21.next = 25;
3808
3929
  break;
3809
3930
  }
3810
3931
  singleLine = cloneDeep(productRecord);
3811
3932
  singleLine.num = 1;
3812
3933
  delete singleLine.product_quantity;
3813
- _context20.next = 22;
3934
+ _context21.next = 22;
3814
3935
  return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
3815
3936
  case 22:
3816
3937
  i += 1;
3817
- _context20.next = 16;
3938
+ _context21.next = 16;
3818
3939
  break;
3819
3940
  case 25:
3820
- return _context20.abrupt("continue", 28);
3941
+ return _context21.abrupt("continue", 28);
3821
3942
  case 26:
3822
- _context20.next = 28;
3943
+ _context21.next = 28;
3823
3944
  return this.appendProductLineToTempOrder(tempOrder, product, booking);
3824
3945
  case 28:
3825
- _context20.next = 6;
3946
+ _context21.next = 6;
3826
3947
  break;
3827
3948
  case 30:
3828
- _context20.next = 35;
3949
+ _context21.next = 35;
3829
3950
  break;
3830
3951
  case 32:
3831
- _context20.prev = 32;
3832
- _context20.t0 = _context20["catch"](4);
3833
- _iterator20.e(_context20.t0);
3952
+ _context21.prev = 32;
3953
+ _context21.t0 = _context21["catch"](4);
3954
+ _iterator20.e(_context21.t0);
3834
3955
  case 35:
3835
- _context20.prev = 35;
3956
+ _context21.prev = 35;
3836
3957
  _iterator20.f();
3837
- return _context20.finish(35);
3958
+ return _context21.finish(35);
3838
3959
  case 38:
3839
- _context20.next = 40;
3960
+ _context21.next = 40;
3840
3961
  return this.finalizeProductOrderMutation(tempOrder, options);
3841
3962
  case 40:
3842
3963
  this.logInfo('addProductsToOrder success', {
3843
3964
  itemsCount: items.length
3844
3965
  });
3845
- return _context20.abrupt("return", tempOrder.products);
3966
+ return _context21.abrupt("return", tempOrder.products);
3846
3967
  case 42:
3847
3968
  case "end":
3848
- return _context20.stop();
3969
+ return _context21.stop();
3849
3970
  }
3850
- }, _callee18, this, [[4, 32, 35, 38]]);
3971
+ }, _callee19, this, [[4, 32, 35, 38]]);
3851
3972
  }));
3852
- function addProductsToOrder(_x21, _x22) {
3973
+ function addProductsToOrder(_x22, _x23) {
3853
3974
  return _addProductsToOrder.apply(this, arguments);
3854
3975
  }
3855
3976
  return addProductsToOrder;
@@ -3883,19 +4004,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3883
4004
  }, {
3884
4005
  key: "preservePersistedBundlePriceFields",
3885
4006
  value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
3886
- var _this23 = this;
4007
+ var _this24 = this;
3887
4008
  if (!Array.isArray(nextBundles)) return nextBundles;
3888
4009
  if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
3889
4010
  var previousByIdentity = new Map();
3890
4011
  previousBundles.forEach(function (bundle) {
3891
- var identity = _this23.getBundleRuntimeIdentity(bundle);
4012
+ var identity = _this24.getBundleRuntimeIdentity(bundle);
3892
4013
  if (identity) previousByIdentity.set(identity, bundle);
3893
4014
  });
3894
4015
  return nextBundles.map(function (bundle, index) {
3895
4016
  if (!bundle || _typeof(bundle) !== 'object') return bundle;
3896
- var previous = previousByIdentity.get(_this23.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
4017
+ var previous = previousByIdentity.get(_this24.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
3897
4018
  if (!previous || _typeof(previous) !== 'object') return bundle;
3898
- return _objectSpread(_objectSpread({}, bundle), {}, {
4019
+ return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
4020
+ cover: previous.cover
4021
+ } : {}), {}, {
3899
4022
  price: previous.price,
3900
4023
  custom_price: previous.custom_price,
3901
4024
  bundle_payment_price: previous.bundle_payment_price,
@@ -3908,7 +4031,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3908
4031
  }, {
3909
4032
  key: "applyOrderProductUpdateToTempOrder",
3910
4033
  value: function applyOrderProductUpdateToTempOrder(tempOrder, params) {
3911
- var _targetProduct$metada2, _product_sku, _metadata2, _metadata3, _metadata4, _metadata5, _metadata6, _metadata7, _nextProduct$metadata, _targetProduct$metada8, _tempOrder$products$p;
4034
+ var _targetProduct$metada2, _product_sku, _metadata2, _metadata3, _metadata4, _metadata5, _metadata6, _metadata7, _metadata8, _metadata9, _metadata10, _nextProduct$metadata, _targetProduct$metada15, _tempOrder$products$p, _tempOrder$products$p2;
3912
4035
  var product_id = params.product_id,
3913
4036
  product_variant_id = params.product_variant_id,
3914
4037
  updates = params.updates,
@@ -3936,8 +4059,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3936
4059
  if (unique_identification_number !== undefined) {
3937
4060
  var targetUid = String(unique_identification_number);
3938
4061
  productIndex = tempOrder.products.findIndex(function (item) {
3939
- var _item$metadata3;
3940
- return String(((_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.unique_identification_number) || item.unique_identification_number || '') === targetUid;
4062
+ var _item$metadata4;
4063
+ return String(((_item$metadata4 = item.metadata) === null || _item$metadata4 === void 0 ? void 0 : _item$metadata4.unique_identification_number) || item.unique_identification_number || '') === targetUid;
3941
4064
  });
3942
4065
  }
3943
4066
  if (productIndex === -1) {
@@ -3968,9 +4091,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3968
4091
  // 如果 caller 走推荐路径(updates.metadata.* 显式指定主价),保留 metadata 由 normalize 认它。
3969
4092
  var callerUpdatesTopPrice = Object.prototype.hasOwnProperty.call(updates || {}, 'selling_price') || Object.prototype.hasOwnProperty.call(updates || {}, 'original_price');
3970
4093
  var callerUpdatesMainMeta = (updates === null || updates === void 0 || (_metadata2 = updates.metadata) === null || _metadata2 === void 0 ? void 0 : _metadata2.main_product_selling_price) !== undefined || (updates === null || updates === void 0 || (_metadata3 = updates.metadata) === null || _metadata3 === void 0 ? void 0 : _metadata3.main_product_original_price) !== undefined || (updates === null || updates === void 0 || (_metadata4 = updates.metadata) === null || _metadata4 === void 0 ? void 0 : _metadata4.source_product_price) !== undefined;
4094
+ var callerUpdatesSourcePrice = (updates === null || updates === void 0 || (_metadata5 = updates.metadata) === null || _metadata5 === void 0 ? void 0 : _metadata5.source_product_price) !== undefined;
4095
+ var callerUpdatesMainSellingPrice = (updates === null || updates === void 0 || (_metadata6 = updates.metadata) === null || _metadata6 === void 0 ? void 0 : _metadata6.main_product_selling_price) !== undefined;
4096
+ var callerUpdatesMainOriginalPrice = (updates === null || updates === void 0 || (_metadata7 = updates.metadata) === null || _metadata7 === void 0 ? void 0 : _metadata7.main_product_original_price) !== undefined;
4097
+ var previousLineFingerprint = buildProductLineFingerprint(getProductSkuOptions(targetProduct), targetProduct.product_bundle);
4098
+ var nextLineFingerprint = buildProductLineFingerprint(getProductSkuOptions(nextProduct), nextProduct.product_bundle);
4099
+ var callerChangesVariant = Number(product_variant_id || 0) !== Number(targetProduct.product_variant_id || 0);
4100
+ var callerChangesLineConfiguration = callerChangesVariant || previousLineFingerprint !== nextLineFingerprint;
3971
4101
  var isPersistedOrderLine = targetProduct.order_detail_id !== undefined && targetProduct.order_detail_id !== null;
3972
4102
  var callerChangesDiscountList = Array.isArray(updates === null || updates === void 0 ? void 0 : updates.discount_list) && updates.discount_list.length > 0 && !isSameDiscountList(updates.discount_list, targetProduct.discount_list);
3973
- var callerUpdatesManualPrice = (updates === null || updates === void 0 || (_metadata5 = updates.metadata) === null || _metadata5 === void 0 ? void 0 : _metadata5.price_override) !== undefined || (updates === null || updates === void 0 || (_metadata6 = updates.metadata) === null || _metadata6 === void 0 ? void 0 : _metadata6.is_manual_discount) !== undefined || (updates === null || updates === void 0 || (_metadata7 = updates.metadata) === null || _metadata7 === void 0 ? void 0 : _metadata7.product_discount_reason) !== undefined || callerChangesDiscountList;
4103
+ var callerUpdatesManualPrice = (updates === null || updates === void 0 || (_metadata8 = updates.metadata) === null || _metadata8 === void 0 ? void 0 : _metadata8.price_override) !== undefined || (updates === null || updates === void 0 || (_metadata9 = updates.metadata) === null || _metadata9 === void 0 ? void 0 : _metadata9.is_manual_discount) !== undefined || (updates === null || updates === void 0 || (_metadata10 = updates.metadata) === null || _metadata10 === void 0 ? void 0 : _metadata10.product_discount_reason) !== undefined || callerChangesDiscountList;
3974
4104
  var callerAllowsBookingReprice = function () {
3975
4105
  if (params.allow_booking_reprice !== true || !booking || !callerUpdatesTopPrice || !callerUpdatesMainMeta) {
3976
4106
  return false;
@@ -3983,7 +4113,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3983
4113
  };
3984
4114
  return hasChangedPrice(updates.selling_price, targetProduct.selling_price) || hasChangedPrice(updates.original_price, targetProduct.original_price);
3985
4115
  }();
3986
- if (isPersistedOrderLine && !callerUpdatesManualPrice && !callerAllowsBookingReprice) {
4116
+ if (isPersistedOrderLine && !callerChangesLineConfiguration && !callerUpdatesManualPrice && !callerAllowsBookingReprice) {
3987
4117
  var _targetProduct$metada3, _targetProduct$metada4, _targetProduct$metada5, _targetProduct$metada6, _targetProduct$metada7;
3988
4118
  nextProduct.selling_price = targetProduct.selling_price;
3989
4119
  nextProduct.original_price = targetProduct.original_price;
@@ -3995,19 +4125,60 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3995
4125
  price_schema_version: (_targetProduct$metada6 = (_targetProduct$metada7 = targetProduct.metadata) === null || _targetProduct$metada7 === void 0 ? void 0 : _targetProduct$metada7.price_schema_version) !== null && _targetProduct$metada6 !== void 0 ? _targetProduct$metada6 : 2
3996
4126
  });
3997
4127
  nextProduct.product_bundle = this.preservePersistedBundlePriceFields(targetProduct.product_bundle, nextProduct.product_bundle);
3998
- } else if (callerUpdatesTopPrice && !callerUpdatesMainMeta) {
4128
+ } else if (callerChangesLineConfiguration && callerUpdatesSourcePrice && (!callerUpdatesMainSellingPrice || !callerUpdatesMainOriginalPrice)) {
4129
+ var _targetProduct$metada8, _targetProduct$metada9;
4130
+ // 新配置只传了 source 时,不能把未传的 main_product_* 从旧行继承下来。
4131
+ // 以新 source + 新 option 重建券前价;券后价未显式提供时保留旧主商品折扣额。
4132
+ var previousMainOriginal = new Decimal(Number((_targetProduct$metada8 = targetProduct.metadata) === null || _targetProduct$metada8 === void 0 ? void 0 : _targetProduct$metada8.main_product_original_price) || 0);
4133
+ var previousMainSelling = new Decimal(Number((_targetProduct$metada9 = targetProduct.metadata) === null || _targetProduct$metada9 === void 0 ? void 0 : _targetProduct$metada9.main_product_selling_price) || previousMainOriginal.toNumber());
4134
+ var preservedDiscount = previousMainOriginal.minus(previousMainSelling);
4135
+ var nextMainOriginal = new Decimal(Number(updates.metadata.source_product_price) || 0).plus(sumOptionUnitPrice(getProductSkuOptions(nextProduct)));
4136
+ nextProduct.metadata = _objectSpread(_objectSpread({}, nextProduct.metadata || {}), {}, {
4137
+ source_product_price: String(updates.metadata.source_product_price),
4138
+ main_product_original_price: callerUpdatesMainOriginalPrice ? String(updates.metadata.main_product_original_price) : nextMainOriginal.toDecimalPlaces(2).toFixed(2),
4139
+ main_product_selling_price: callerUpdatesMainSellingPrice ? String(updates.metadata.main_product_selling_price) : nextMainOriginal.minus(preservedDiscount).toDecimalPlaces(2).toFixed(2),
4140
+ price_schema_version: 2
4141
+ });
4142
+ } else if (callerChangesVariant && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
4143
+ // variant 已变化但 caller 没有显式报价时,旧 v2 metadata 不能继续充当权威价格源。
4144
+ // 清理后由 normalize 优先读取 metadata.origin.variant 中新 variant 的目录价;
4145
+ // 顶层 original/selling 的旧差额仍会作为 legacy discount 迁移到新价格。
3999
4146
  var existedMeta = nextProduct.metadata || {};
4000
4147
  nextProduct.metadata = _objectSpread({}, existedMeta);
4001
4148
  delete nextProduct.metadata.source_product_price;
4002
4149
  delete nextProduct.metadata.main_product_selling_price;
4003
4150
  delete nextProduct.metadata.main_product_original_price;
4004
4151
  delete nextProduct.metadata.price_schema_version;
4152
+ } else if (callerChangesLineConfiguration && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
4153
+ var _ref68, _targetProduct$metada10, _targetProduct$metada11, _ref69, _targetProduct$metada12, _targetProduct$metada13, _targetProduct$metada14;
4154
+ // 仅 option / bundle 变化时,保留历史 source 和主商品折扣金额,
4155
+ // 但必须让 original 与 selling 一起随新的 option 金额移动。
4156
+ var previousOptionSum = sumOptionUnitPrice(getProductSkuOptions(targetProduct));
4157
+ var nextOptionSum = sumOptionUnitPrice(getProductSkuOptions(nextProduct));
4158
+ var _previousMainOriginal = new Decimal(Number((_ref68 = (_targetProduct$metada10 = (_targetProduct$metada11 = targetProduct.metadata) === null || _targetProduct$metada11 === void 0 ? void 0 : _targetProduct$metada11.main_product_original_price) !== null && _targetProduct$metada10 !== void 0 ? _targetProduct$metada10 : targetProduct.original_price) !== null && _ref68 !== void 0 ? _ref68 : 0) || 0);
4159
+ var _previousMainSelling = new Decimal(Number((_ref69 = (_targetProduct$metada12 = (_targetProduct$metada13 = targetProduct.metadata) === null || _targetProduct$metada13 === void 0 ? void 0 : _targetProduct$metada13.main_product_selling_price) !== null && _targetProduct$metada12 !== void 0 ? _targetProduct$metada12 : targetProduct.selling_price) !== null && _ref69 !== void 0 ? _ref69 : _previousMainOriginal.toNumber()) || 0);
4160
+ var _preservedDiscount = _previousMainOriginal.minus(_previousMainSelling);
4161
+ var previousSource = ((_targetProduct$metada14 = targetProduct.metadata) === null || _targetProduct$metada14 === void 0 ? void 0 : _targetProduct$metada14.source_product_price) != null ? new Decimal(Number(targetProduct.metadata.source_product_price) || 0) : _previousMainOriginal.minus(previousOptionSum);
4162
+ var _nextMainOriginal = previousSource.plus(nextOptionSum);
4163
+ nextProduct.metadata = _objectSpread(_objectSpread({}, nextProduct.metadata || {}), {}, {
4164
+ source_product_price: previousSource.toDecimalPlaces(2).toFixed(2),
4165
+ main_product_original_price: _nextMainOriginal.toDecimalPlaces(2).toFixed(2),
4166
+ main_product_selling_price: _nextMainOriginal.minus(_preservedDiscount).toDecimalPlaces(2).toFixed(2),
4167
+ price_schema_version: 2
4168
+ });
4169
+ } else if (callerUpdatesTopPrice && !callerUpdatesMainMeta) {
4170
+ var _existedMeta = nextProduct.metadata || {};
4171
+ nextProduct.metadata = _objectSpread({}, _existedMeta);
4172
+ delete nextProduct.metadata.source_product_price;
4173
+ delete nextProduct.metadata.main_product_selling_price;
4174
+ delete nextProduct.metadata.main_product_original_price;
4175
+ delete nextProduct.metadata.price_schema_version;
4005
4176
  }
4006
4177
  // normalizeOrderProduct 幂等:v2 metadata 存在 → 保留 main_product_* 折扣重算 composite;
4007
4178
  // 否则 → 把顶层 selling_price 视作 source,派生 main_product_* 并写 price_schema_version: 2。
4008
4179
  var normalizedProduct = mergeOrderProductDisplayFields(nextProduct, normalizeOrderProduct(nextProduct));
4009
4180
  normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
4010
- var preservedBookingUid = nextProduct.booking_uid || ((_nextProduct$metadata = nextProduct.metadata) === null || _nextProduct$metadata === void 0 ? void 0 : _nextProduct$metadata.booking_uid) || targetProduct.booking_uid || ((_targetProduct$metada8 = targetProduct.metadata) === null || _targetProduct$metada8 === void 0 ? void 0 : _targetProduct$metada8.booking_uid);
4181
+ var preservedBookingUid = nextProduct.booking_uid || ((_nextProduct$metadata = nextProduct.metadata) === null || _nextProduct$metadata === void 0 ? void 0 : _nextProduct$metadata.booking_uid) || targetProduct.booking_uid || ((_targetProduct$metada15 = targetProduct.metadata) === null || _targetProduct$metada15 === void 0 ? void 0 : _targetProduct$metada15.booking_uid);
4011
4182
  if (!booking && preservedBookingUid) {
4012
4183
  normalizedProduct.booking_uid = preservedBookingUid;
4013
4184
  normalizedProduct.metadata = _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
@@ -4015,8 +4186,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4015
4186
  });
4016
4187
  }
4017
4188
  if (booking) {
4018
- var _normalizedProduct$me, _targetProduct$metada9;
4019
- var productUid = String(((_normalizedProduct$me = normalizedProduct.metadata) === null || _normalizedProduct$me === void 0 ? void 0 : _normalizedProduct$me.unique_identification_number) || ((_targetProduct$metada9 = targetProduct.metadata) === null || _targetProduct$metada9 === void 0 ? void 0 : _targetProduct$metada9.unique_identification_number) || unique_identification_number || createUuidV4());
4189
+ var _normalizedProduct$me, _targetProduct$metada16;
4190
+ var productUid = String(((_normalizedProduct$me = normalizedProduct.metadata) === null || _normalizedProduct$me === void 0 ? void 0 : _normalizedProduct$me.unique_identification_number) || ((_targetProduct$metada16 = targetProduct.metadata) === null || _targetProduct$metada16 === void 0 ? void 0 : _targetProduct$metada16.unique_identification_number) || unique_identification_number || createUuidV4());
4020
4191
  normalizedProduct.metadata = _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
4021
4192
  unique_identification_number: productUid
4022
4193
  });
@@ -4039,23 +4210,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4039
4210
  tempOrder.products[productIndex] = normalizedProduct;
4040
4211
  this.syncTempOrderHolderFromBookings(tempOrder);
4041
4212
  this.captureProductRuntime(tempOrder, updates, tempOrder.products[productIndex], (_tempOrder$products$p = tempOrder.products[productIndex].metadata) === null || _tempOrder$products$p === void 0 ? void 0 : _tempOrder$products$p.unique_identification_number);
4213
+ return (_tempOrder$products$p2 = tempOrder.products[productIndex].metadata) === null || _tempOrder$products$p2 === void 0 ? void 0 : _tempOrder$products$p2.unique_identification_number;
4042
4214
  }
4043
4215
  }, {
4044
4216
  key: "updateOrderProduct",
4045
4217
  value: function () {
4046
- var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
4047
- var tempOrder;
4048
- return _regeneratorRuntime().wrap(function _callee19$(_context21) {
4049
- while (1) switch (_context21.prev = _context21.next) {
4218
+ var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
4219
+ var tempOrder, updatedProductUid;
4220
+ return _regeneratorRuntime().wrap(function _callee20$(_context22) {
4221
+ while (1) switch (_context22.prev = _context22.next) {
4050
4222
  case 0:
4051
4223
  tempOrder = this.ensureTempOrder();
4052
- this.applyOrderProductUpdateToTempOrder(tempOrder, params);
4053
- _context21.next = 4;
4224
+ updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params);
4225
+ _context22.next = 4;
4054
4226
  return this.applyPromotion();
4055
4227
  case 4:
4056
- this.applyDiscount();
4228
+ this.applyDiscount({
4229
+ reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
4230
+ });
4057
4231
  this.sanitizeTempOrderProducts(tempOrder);
4058
- _context21.next = 8;
4232
+ _context22.next = 8;
4059
4233
  return this.recalculateSummary({
4060
4234
  createIfMissing: true
4061
4235
  });
@@ -4064,14 +4238,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4064
4238
  this.logInfo('updateOrderProduct success', {
4065
4239
  params: params
4066
4240
  });
4067
- return _context21.abrupt("return", tempOrder.products);
4241
+ return _context22.abrupt("return", tempOrder.products);
4068
4242
  case 11:
4069
4243
  case "end":
4070
- return _context21.stop();
4244
+ return _context22.stop();
4071
4245
  }
4072
- }, _callee19, this);
4246
+ }, _callee20, this);
4073
4247
  }));
4074
- function updateOrderProduct(_x23) {
4248
+ function updateOrderProduct(_x24) {
4075
4249
  return _updateOrderProduct.apply(this, arguments);
4076
4250
  }
4077
4251
  return updateOrderProduct;
@@ -4079,36 +4253,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4079
4253
  }, {
4080
4254
  key: "updateOrderProducts",
4081
4255
  value: function () {
4082
- var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(paramsList) {
4083
- var _this24 = this;
4084
- var tempOrder;
4085
- return _regeneratorRuntime().wrap(function _callee20$(_context22) {
4086
- while (1) switch (_context22.prev = _context22.next) {
4256
+ var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(paramsList) {
4257
+ var _this25 = this;
4258
+ var tempOrder, reapplyBookingDiscountProductUids;
4259
+ return _regeneratorRuntime().wrap(function _callee21$(_context23) {
4260
+ while (1) switch (_context23.prev = _context23.next) {
4087
4261
  case 0:
4088
4262
  tempOrder = this.ensureTempOrder();
4089
4263
  if (paramsList.length) {
4090
- _context22.next = 3;
4264
+ _context23.next = 3;
4091
4265
  break;
4092
4266
  }
4093
- return _context22.abrupt("return", tempOrder.products);
4267
+ return _context23.abrupt("return", tempOrder.products);
4094
4268
  case 3:
4095
- paramsList.forEach(function (params) {
4096
- _this24.applyOrderProductUpdateToTempOrder(tempOrder, params);
4269
+ reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
4270
+ var updatedProductUid = _this25.applyOrderProductUpdateToTempOrder(tempOrder, params);
4271
+ // 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
4272
+ if (params.allow_booking_discount_reapply && updatedProductUid) {
4273
+ acc.push(String(updatedProductUid));
4274
+ }
4275
+ return acc;
4276
+ }, []);
4277
+ _context23.next = 6;
4278
+ return this.finalizeAfterProductsMutation(tempOrder, {
4279
+ reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
4097
4280
  });
4098
- _context22.next = 6;
4099
- return this.finalizeAfterProductsMutation(tempOrder);
4100
4281
  case 6:
4101
4282
  this.logInfo('updateOrderProduct success', {
4102
4283
  paramsList: paramsList
4103
4284
  });
4104
- return _context22.abrupt("return", tempOrder.products);
4285
+ return _context23.abrupt("return", tempOrder.products);
4105
4286
  case 8:
4106
4287
  case "end":
4107
- return _context22.stop();
4288
+ return _context23.stop();
4108
4289
  }
4109
- }, _callee20, this);
4290
+ }, _callee21, this);
4110
4291
  }));
4111
- function updateOrderProducts(_x24) {
4292
+ function updateOrderProducts(_x25) {
4112
4293
  return _updateOrderProducts.apply(this, arguments);
4113
4294
  }
4114
4295
  return updateOrderProducts;
@@ -4116,11 +4297,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4116
4297
  }, {
4117
4298
  key: "updateOrderProductQuantity",
4118
4299
  value: function () {
4119
- var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
4120
- var _targetProduct$metada10;
4300
+ var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
4301
+ var _targetProduct$metada17;
4121
4302
  var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct;
4122
- return _regeneratorRuntime().wrap(function _callee21$(_context23) {
4123
- while (1) switch (_context23.prev = _context23.next) {
4303
+ return _regeneratorRuntime().wrap(function _callee22$(_context24) {
4304
+ while (1) switch (_context24.prev = _context24.next) {
4124
4305
  case 0:
4125
4306
  product_id = params.product_id, product_variant_id = params.product_variant_id, num = params.num, unique_identification_number = params.unique_identification_number, identity_key = params.identity_key, product_sku = params.product_sku, product_bundle = params.product_bundle;
4126
4307
  tempOrder = this.ensureTempOrder();
@@ -4141,15 +4322,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4141
4322
  if (unique_identification_number !== undefined) {
4142
4323
  targetUid = String(unique_identification_number);
4143
4324
  productIndex = tempOrder.products.findIndex(function (item) {
4144
- var _item$metadata4;
4145
- return String(((_item$metadata4 = item.metadata) === null || _item$metadata4 === void 0 ? void 0 : _item$metadata4.unique_identification_number) || item.unique_identification_number || '') === targetUid;
4325
+ var _item$metadata5;
4326
+ return String(((_item$metadata5 = item.metadata) === null || _item$metadata5 === void 0 ? void 0 : _item$metadata5.unique_identification_number) || item.unique_identification_number || '') === targetUid;
4146
4327
  });
4147
4328
  }
4148
4329
  if (productIndex === -1) {
4149
4330
  productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
4150
4331
  }
4151
4332
  if (!(productIndex === -1)) {
4152
- _context23.next = 12;
4333
+ _context24.next = 12;
4153
4334
  break;
4154
4335
  }
4155
4336
  throw new Error('[Order] 目标商品不存在,无法更新数量');
@@ -4158,17 +4339,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4158
4339
  normalizedProduct = normalizeOrderProduct(_objectSpread(_objectSpread({}, targetProduct), {}, {
4159
4340
  num: getSafeProductNum(num),
4160
4341
  metadata: _objectSpread(_objectSpread({}, targetProduct.metadata || {}), {}, {
4161
- unique_identification_number: ((_targetProduct$metada10 = targetProduct.metadata) === null || _targetProduct$metada10 === void 0 ? void 0 : _targetProduct$metada10.unique_identification_number) || unique_identification_number
4342
+ unique_identification_number: ((_targetProduct$metada17 = targetProduct.metadata) === null || _targetProduct$metada17 === void 0 ? void 0 : _targetProduct$metada17.unique_identification_number) || unique_identification_number
4162
4343
  })
4163
4344
  }));
4164
4345
  normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
4165
4346
  tempOrder.products[productIndex] = normalizedProduct;
4166
- _context23.next = 18;
4347
+ _context24.next = 18;
4167
4348
  return this.applyPromotion();
4168
4349
  case 18:
4169
4350
  this.applyDiscount();
4170
4351
  this.sanitizeTempOrderProducts(tempOrder);
4171
- _context23.next = 22;
4352
+ _context24.next = 22;
4172
4353
  return this.recalculateSummary({
4173
4354
  createIfMissing: true
4174
4355
  });
@@ -4177,14 +4358,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4177
4358
  this.logInfo('updateOrderProductQuantity success', {
4178
4359
  params: params
4179
4360
  });
4180
- return _context23.abrupt("return", tempOrder.products);
4361
+ return _context24.abrupt("return", tempOrder.products);
4181
4362
  case 25:
4182
4363
  case "end":
4183
- return _context23.stop();
4364
+ return _context24.stop();
4184
4365
  }
4185
- }, _callee21, this);
4366
+ }, _callee22, this);
4186
4367
  }));
4187
- function updateOrderProductQuantity(_x25) {
4368
+ function updateOrderProductQuantity(_x26) {
4188
4369
  return _updateOrderProductQuantity.apply(this, arguments);
4189
4370
  }
4190
4371
  return updateOrderProductQuantity;
@@ -4225,17 +4406,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4225
4406
  }, {
4226
4407
  key: "finalizeAfterProductsMutation",
4227
4408
  value: (function () {
4228
- var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(tempOrder) {
4229
- return _regeneratorRuntime().wrap(function _callee22$(_context24) {
4230
- while (1) switch (_context24.prev = _context24.next) {
4409
+ var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(tempOrder, options) {
4410
+ return _regeneratorRuntime().wrap(function _callee23$(_context25) {
4411
+ while (1) switch (_context25.prev = _context25.next) {
4231
4412
  case 0:
4232
4413
  this.syncTempOrderHolderFromBookings(tempOrder);
4233
- _context24.next = 3;
4414
+ _context25.next = 3;
4234
4415
  return this.applyPromotion();
4235
4416
  case 3:
4236
- this.applyDiscount();
4417
+ this.applyDiscount({
4418
+ reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids
4419
+ });
4237
4420
  this.sanitizeTempOrderProducts(tempOrder);
4238
- _context24.next = 7;
4421
+ _context25.next = 7;
4239
4422
  return this.recalculateSummary({
4240
4423
  createIfMissing: true
4241
4424
  });
@@ -4243,11 +4426,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4243
4426
  this.persistTempOrder();
4244
4427
  case 8:
4245
4428
  case "end":
4246
- return _context24.stop();
4429
+ return _context25.stop();
4247
4430
  }
4248
- }, _callee22, this);
4431
+ }, _callee23, this);
4249
4432
  }));
4250
- function finalizeAfterProductsMutation(_x26) {
4433
+ function finalizeAfterProductsMutation(_x27, _x28) {
4251
4434
  return _finalizeAfterProductsMutation.apply(this, arguments);
4252
4435
  }
4253
4436
  return finalizeAfterProductsMutation;
@@ -4262,18 +4445,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4262
4445
  }, {
4263
4446
  key: "removeProductsFromOrder",
4264
4447
  value: (function () {
4265
- var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(identities) {
4266
- var _this25 = this;
4448
+ var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(identities) {
4449
+ var _this26 = this;
4267
4450
  var tempOrder, productsBeforeRemove, bookingsBeforeRemove, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3;
4268
- return _regeneratorRuntime().wrap(function _callee23$(_context26) {
4269
- while (1) switch (_context26.prev = _context26.next) {
4451
+ return _regeneratorRuntime().wrap(function _callee24$(_context27) {
4452
+ while (1) switch (_context27.prev = _context27.next) {
4270
4453
  case 0:
4271
4454
  tempOrder = this.ensureTempOrder();
4272
4455
  if (identities.length) {
4273
- _context26.next = 3;
4456
+ _context27.next = 3;
4274
4457
  break;
4275
4458
  }
4276
- return _context26.abrupt("return", tempOrder.products);
4459
+ return _context27.abrupt("return", tempOrder.products);
4277
4460
  case 3:
4278
4461
  productsBeforeRemove = tempOrder.products || [];
4279
4462
  bookingsBeforeRemove = tempOrder.bookings || [];
@@ -4296,29 +4479,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4296
4479
  }
4297
4480
  linkedBookingUidsToRemove = new Set();
4298
4481
  _iterator21 = _createForOfIteratorHelper(matchedProducts);
4299
- _context26.prev = 11;
4482
+ _context27.prev = 11;
4300
4483
  _loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
4301
- var _metadata8, _metadata9, _metadata10, _metadata11;
4484
+ var _metadata11, _metadata12, _metadata13, _metadata14;
4302
4485
  var product, productUid, productBookingUid, isAddTimeProduct;
4303
- return _regeneratorRuntime().wrap(function _loop3$(_context25) {
4304
- while (1) switch (_context25.prev = _context25.next) {
4486
+ return _regeneratorRuntime().wrap(function _loop3$(_context26) {
4487
+ while (1) switch (_context26.prev = _context26.next) {
4305
4488
  case 0:
4306
4489
  product = _step21.value;
4307
- productUid = (product === null || product === void 0 || (_metadata8 = product.metadata) === null || _metadata8 === void 0 ? void 0 : _metadata8.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
4308
- productBookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_metadata9 = product.metadata) === null || _metadata9 === void 0 ? void 0 : _metadata9.booking_uid);
4309
- isAddTimeProduct = (product === null || product === void 0 || (_metadata10 = product.metadata) === null || _metadata10 === void 0 ? void 0 : _metadata10.product_add_schedule_time) !== undefined && (product === null || product === void 0 || (_metadata11 = product.metadata) === null || _metadata11 === void 0 ? void 0 : _metadata11.product_add_schedule_time) !== null;
4490
+ productUid = (product === null || product === void 0 || (_metadata11 = product.metadata) === null || _metadata11 === void 0 ? void 0 : _metadata11.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
4491
+ productBookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_metadata12 = product.metadata) === null || _metadata12 === void 0 ? void 0 : _metadata12.booking_uid);
4492
+ isAddTimeProduct = (product === null || product === void 0 || (_metadata13 = product.metadata) === null || _metadata13 === void 0 ? void 0 : _metadata13.product_add_schedule_time) !== undefined && (product === null || product === void 0 || (_metadata14 = product.metadata) === null || _metadata14 === void 0 ? void 0 : _metadata14.product_add_schedule_time) !== null;
4310
4493
  if (!isAddTimeProduct) {
4311
- _context25.next = 6;
4494
+ _context26.next = 6;
4312
4495
  break;
4313
4496
  }
4314
- return _context25.abrupt("return", 1);
4497
+ return _context26.abrupt("return", 1);
4315
4498
  case 6:
4316
4499
  if (productBookingUid !== undefined && productBookingUid !== null && productBookingUid !== '') {
4317
4500
  linkedBookingUidsToRemove.add(String(productBookingUid));
4318
4501
  }
4319
4502
  if (productUid !== undefined && productUid !== null && productUid !== '') {
4320
4503
  bookingsBeforeRemove.forEach(function (booking) {
4321
- var bookingUid = _this25.getBookingUniqueIdentificationNumber(booking);
4504
+ var bookingUid = _this26.getBookingUniqueIdentificationNumber(booking);
4322
4505
  if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
4323
4506
  linkedBookingUidsToRemove.add(bookingUid);
4324
4507
  }
@@ -4326,37 +4509,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4326
4509
  }
4327
4510
  case 8:
4328
4511
  case "end":
4329
- return _context25.stop();
4512
+ return _context26.stop();
4330
4513
  }
4331
4514
  }, _loop3);
4332
4515
  });
4333
4516
  _iterator21.s();
4334
4517
  case 14:
4335
4518
  if ((_step21 = _iterator21.n()).done) {
4336
- _context26.next = 20;
4519
+ _context27.next = 20;
4337
4520
  break;
4338
4521
  }
4339
- return _context26.delegateYield(_loop3(), "t0", 16);
4522
+ return _context27.delegateYield(_loop3(), "t0", 16);
4340
4523
  case 16:
4341
- if (!_context26.t0) {
4342
- _context26.next = 18;
4524
+ if (!_context27.t0) {
4525
+ _context27.next = 18;
4343
4526
  break;
4344
4527
  }
4345
- return _context26.abrupt("continue", 18);
4528
+ return _context27.abrupt("continue", 18);
4346
4529
  case 18:
4347
- _context26.next = 14;
4530
+ _context27.next = 14;
4348
4531
  break;
4349
4532
  case 20:
4350
- _context26.next = 25;
4533
+ _context27.next = 25;
4351
4534
  break;
4352
4535
  case 22:
4353
- _context26.prev = 22;
4354
- _context26.t1 = _context26["catch"](11);
4355
- _iterator21.e(_context26.t1);
4536
+ _context27.prev = 22;
4537
+ _context27.t1 = _context27["catch"](11);
4538
+ _iterator21.e(_context27.t1);
4356
4539
  case 25:
4357
- _context26.prev = 25;
4540
+ _context27.prev = 25;
4358
4541
  _iterator21.f();
4359
- return _context26.finish(25);
4542
+ return _context27.finish(25);
4360
4543
  case 28:
4361
4544
  if (linkedBookingUidsToRemove.size > 0) {
4362
4545
  // 删除主预约商品时,同步移除挂在同一 booking_uid 下的加时商品,避免残留孤儿行。
@@ -4367,20 +4550,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4367
4550
  return !(isAddTimeProduct && lineBookingUid !== undefined && lineBookingUid !== null && linkedBookingUidsToRemove.has(String(lineBookingUid)));
4368
4551
  });
4369
4552
  }
4370
- _context26.next = 31;
4553
+ _context27.next = 31;
4371
4554
  return this.finalizeAfterProductsMutation(tempOrder);
4372
4555
  case 31:
4373
4556
  this.logInfo('removeProductsFromOrder success', {
4374
4557
  identities: identities
4375
4558
  });
4376
- return _context26.abrupt("return", tempOrder.products);
4559
+ return _context27.abrupt("return", tempOrder.products);
4377
4560
  case 33:
4378
4561
  case "end":
4379
- return _context26.stop();
4562
+ return _context27.stop();
4380
4563
  }
4381
- }, _callee23, this, [[11, 22, 25, 28]]);
4564
+ }, _callee24, this, [[11, 22, 25, 28]]);
4382
4565
  }));
4383
- function removeProductsFromOrder(_x27) {
4566
+ function removeProductsFromOrder(_x29) {
4384
4567
  return _removeProductsFromOrder.apply(this, arguments);
4385
4568
  }
4386
4569
  return removeProductsFromOrder;
@@ -4388,18 +4571,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4388
4571
  }, {
4389
4572
  key: "removeProductFromOrder",
4390
4573
  value: function () {
4391
- var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(identity) {
4392
- return _regeneratorRuntime().wrap(function _callee24$(_context27) {
4393
- while (1) switch (_context27.prev = _context27.next) {
4574
+ var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(identity) {
4575
+ return _regeneratorRuntime().wrap(function _callee25$(_context28) {
4576
+ while (1) switch (_context28.prev = _context28.next) {
4394
4577
  case 0:
4395
- return _context27.abrupt("return", this.removeProductsFromOrder([identity]));
4578
+ return _context28.abrupt("return", this.removeProductsFromOrder([identity]));
4396
4579
  case 1:
4397
4580
  case "end":
4398
- return _context27.stop();
4581
+ return _context28.stop();
4399
4582
  }
4400
- }, _callee24, this);
4583
+ }, _callee25, this);
4401
4584
  }));
4402
- function removeProductFromOrder(_x28) {
4585
+ function removeProductFromOrder(_x30) {
4403
4586
  return _removeProductFromOrder.apply(this, arguments);
4404
4587
  }
4405
4588
  return removeProductFromOrder;
@@ -4411,10 +4594,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4411
4594
  }, {
4412
4595
  key: "clearOrderCartLines",
4413
4596
  value: (function () {
4414
- var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
4597
+ var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
4415
4598
  var tempOrder;
4416
- return _regeneratorRuntime().wrap(function _callee25$(_context28) {
4417
- while (1) switch (_context28.prev = _context28.next) {
4599
+ return _regeneratorRuntime().wrap(function _callee26$(_context29) {
4600
+ while (1) switch (_context29.prev = _context29.next) {
4418
4601
  case 0:
4419
4602
  tempOrder = this.ensureTempOrder();
4420
4603
  tempOrder.products = [];
@@ -4425,24 +4608,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4425
4608
  productsByUid: {}
4426
4609
  });
4427
4610
  }
4428
- _context28.next = 7;
4611
+ _context29.next = 7;
4429
4612
  return this.applyPromotion();
4430
4613
  case 7:
4431
4614
  this.applyDiscount();
4432
4615
  this.sanitizeTempOrderProducts(tempOrder);
4433
- _context28.next = 11;
4616
+ _context29.next = 11;
4434
4617
  return this.recalculateSummary({
4435
4618
  createIfMissing: true
4436
4619
  });
4437
4620
  case 11:
4438
4621
  this.persistTempOrder();
4439
4622
  this.logInfo('clearOrderCartLines success', {});
4440
- return _context28.abrupt("return", tempOrder);
4623
+ return _context29.abrupt("return", tempOrder);
4441
4624
  case 14:
4442
4625
  case "end":
4443
- return _context28.stop();
4626
+ return _context29.stop();
4444
4627
  }
4445
- }, _callee25, this);
4628
+ }, _callee26, this);
4446
4629
  }));
4447
4630
  function clearOrderCartLines() {
4448
4631
  return _clearOrderCartLines.apply(this, arguments);
@@ -4453,23 +4636,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4453
4636
  }, {
4454
4637
  key: "buildCurrentSubmitPayloadForLocalPrint",
4455
4638
  value: function buildCurrentSubmitPayloadForLocalPrint(params) {
4456
- var _params$cacheId, _this$otherParams3, _ref68, _params$businessCode, _this$otherParams4, _this$otherParams5;
4639
+ var _params$cacheId, _this$otherParams3, _ref70, _params$businessCode, _this$otherParams4, _this$otherParams5;
4457
4640
  var tempOrder = this.ensureTempOrder();
4458
4641
  this.persistTempOrder();
4459
4642
  var payload = buildSubmitPayload({
4460
4643
  tempOrder: tempOrder,
4461
4644
  cacheId: (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId,
4462
4645
  platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.platform),
4463
- businessCode: (_ref68 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.businessCode) !== null && _ref68 !== void 0 ? _ref68 : (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.business_code,
4646
+ businessCode: (_ref70 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.businessCode) !== null && _ref70 !== void 0 ? _ref70 : (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.business_code,
4464
4647
  channel: params === null || params === void 0 ? void 0 : params.channel,
4465
4648
  type: params === null || params === void 0 ? void 0 : params.type,
4466
4649
  summary: this.store.summary || createEmptySummary(),
4467
4650
  enhance: function enhance(nextPayload) {
4468
- var _ref69, _tempOrder$order_numb, _ref70, _tempOrder$shop_order, _ref71, _tempOrder$shop_full_;
4651
+ var _ref71, _tempOrder$order_numb, _ref72, _tempOrder$shop_order, _ref73, _tempOrder$shop_full_;
4469
4652
  return _objectSpread(_objectSpread({}, nextPayload), {}, {
4470
- order_number: (_ref69 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref69 !== void 0 ? _ref69 : null,
4471
- shop_order_number: (_ref70 = (_tempOrder$shop_order = tempOrder.shop_order_number) !== null && _tempOrder$shop_order !== void 0 ? _tempOrder$shop_order : nextPayload.shop_order_number) !== null && _ref70 !== void 0 ? _ref70 : null,
4472
- shop_full_order_number: (_ref71 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref71 !== void 0 ? _ref71 : null,
4653
+ order_number: (_ref71 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref71 !== void 0 ? _ref71 : null,
4654
+ shop_order_number: (_ref72 = (_tempOrder$shop_order = tempOrder.shop_order_number) !== null && _tempOrder$shop_order !== void 0 ? _tempOrder$shop_order : nextPayload.shop_order_number) !== null && _ref72 !== void 0 ? _ref72 : null,
4655
+ shop_full_order_number: (_ref73 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref73 !== void 0 ? _ref73 : null,
4473
4656
  small_ticket_data_flag: 1
4474
4657
  });
4475
4658
  }
@@ -4480,17 +4663,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4480
4663
  }, {
4481
4664
  key: "applyLocalPrintOrderNumbers",
4482
4665
  value: function () {
4483
- var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(order) {
4666
+ var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(order) {
4484
4667
  var tempOrder, shopOrderNumber, shopFullOrderNumber;
4485
- return _regeneratorRuntime().wrap(function _callee26$(_context29) {
4486
- while (1) switch (_context29.prev = _context29.next) {
4668
+ return _regeneratorRuntime().wrap(function _callee27$(_context30) {
4669
+ while (1) switch (_context30.prev = _context30.next) {
4487
4670
  case 0:
4488
4671
  tempOrder = this.ensureTempOrder();
4489
4672
  if (!(!order || _typeof(order) !== 'object')) {
4490
- _context29.next = 3;
4673
+ _context30.next = 3;
4491
4674
  break;
4492
4675
  }
4493
- return _context29.abrupt("return", tempOrder);
4676
+ return _context30.abrupt("return", tempOrder);
4494
4677
  case 3:
4495
4678
  shopOrderNumber = order.shop_order_number;
4496
4679
  shopFullOrderNumber = order.shop_full_order_number;
@@ -4501,17 +4684,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4501
4684
  tempOrder.shop_full_order_number = String(shopFullOrderNumber);
4502
4685
  }
4503
4686
  this.persistTempOrder();
4504
- _context29.next = 10;
4687
+ _context30.next = 10;
4505
4688
  return this.saveDraft();
4506
4689
  case 10:
4507
- return _context29.abrupt("return", tempOrder);
4690
+ return _context30.abrupt("return", tempOrder);
4508
4691
  case 11:
4509
4692
  case "end":
4510
- return _context29.stop();
4693
+ return _context30.stop();
4511
4694
  }
4512
- }, _callee26, this);
4695
+ }, _callee27, this);
4513
4696
  }));
4514
- function applyLocalPrintOrderNumbers(_x29) {
4697
+ function applyLocalPrintOrderNumbers(_x31) {
4515
4698
  return _applyLocalPrintOrderNumbers.apply(this, arguments);
4516
4699
  }
4517
4700
  return applyLocalPrintOrderNumbers;
@@ -4525,18 +4708,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4525
4708
  }, {
4526
4709
  key: "submitTempOrder",
4527
4710
  value: (function () {
4528
- var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
4529
- return _regeneratorRuntime().wrap(function _callee27$(_context30) {
4530
- while (1) switch (_context30.prev = _context30.next) {
4711
+ var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
4712
+ return _regeneratorRuntime().wrap(function _callee28$(_context31) {
4713
+ while (1) switch (_context31.prev = _context31.next) {
4531
4714
  case 0:
4532
- return _context30.abrupt("return", this.runSubmitTempOrder(params));
4715
+ return _context31.abrupt("return", this.runSubmitTempOrder(params));
4533
4716
  case 1:
4534
4717
  case "end":
4535
- return _context30.stop();
4718
+ return _context31.stop();
4536
4719
  }
4537
- }, _callee27, this);
4720
+ }, _callee28, this);
4538
4721
  }));
4539
- function submitTempOrder(_x30) {
4722
+ function submitTempOrder(_x32) {
4540
4723
  return _submitTempOrder.apply(this, arguments);
4541
4724
  }
4542
4725
  return submitTempOrder;
@@ -4544,20 +4727,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4544
4727
  }, {
4545
4728
  key: "submitTempOrderAsync",
4546
4729
  value: function () {
4547
- var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
4548
- return _regeneratorRuntime().wrap(function _callee28$(_context31) {
4549
- while (1) switch (_context31.prev = _context31.next) {
4730
+ var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
4731
+ return _regeneratorRuntime().wrap(function _callee29$(_context32) {
4732
+ while (1) switch (_context32.prev = _context32.next) {
4550
4733
  case 0:
4551
- return _context31.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
4734
+ return _context32.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
4552
4735
  syncMode: true
4553
4736
  })));
4554
4737
  case 1:
4555
4738
  case "end":
4556
- return _context31.stop();
4739
+ return _context32.stop();
4557
4740
  }
4558
- }, _callee28, this);
4741
+ }, _callee29, this);
4559
4742
  }));
4560
- function submitTempOrderAsync(_x31) {
4743
+ function submitTempOrderAsync(_x33) {
4561
4744
  return _submitTempOrderAsync.apply(this, arguments);
4562
4745
  }
4563
4746
  return submitTempOrderAsync;
@@ -4565,11 +4748,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4565
4748
  }, {
4566
4749
  key: "runSubmitTempOrder",
4567
4750
  value: function () {
4568
- var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
4569
- var _params$cacheId2, _this$otherParams6, _ref72, _ref73, _submitSnapshot$busin, _this$otherParams7, _this$otherParams8, _submitSnapshot$type;
4751
+ var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
4752
+ var _params$cacheId2, _this$otherParams6, _ref74, _ref75, _submitSnapshot$busin, _this$otherParams7, _this$otherParams8, _submitSnapshot$type;
4570
4753
  var tempOrder, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
4571
- return _regeneratorRuntime().wrap(function _callee29$(_context32) {
4572
- while (1) switch (_context32.prev = _context32.next) {
4754
+ return _regeneratorRuntime().wrap(function _callee30$(_context33) {
4755
+ while (1) switch (_context33.prev = _context33.next) {
4573
4756
  case 0:
4574
4757
  tempOrder = this.ensureTempOrder();
4575
4758
  shouldConfirmPendingVoucherPayments = (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== false;
@@ -4589,26 +4772,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4589
4772
  }
4590
4773
  }
4591
4774
  this.persistTempOrder();
4592
- _context32.next = 8;
4775
+ _context33.next = 8;
4593
4776
  return this.recalculateSummary({
4594
4777
  createIfMissing: true
4595
4778
  });
4596
4779
  case 8:
4597
- _context32.t1 = _context32.sent;
4598
- if (_context32.t1) {
4599
- _context32.next = 11;
4780
+ _context33.t1 = _context33.sent;
4781
+ if (_context33.t1) {
4782
+ _context33.next = 11;
4600
4783
  break;
4601
4784
  }
4602
- _context32.t1 = this.store.summary;
4785
+ _context33.t1 = this.store.summary;
4603
4786
  case 11:
4604
- _context32.t0 = _context32.t1;
4605
- if (_context32.t0) {
4606
- _context32.next = 14;
4787
+ _context33.t0 = _context33.t1;
4788
+ if (_context33.t0) {
4789
+ _context33.next = 14;
4607
4790
  break;
4608
4791
  }
4609
- _context32.t0 = createEmptySummary();
4792
+ _context33.t0 = createEmptySummary();
4610
4793
  case 14:
4611
- latestSummary = _context32.t0;
4794
+ latestSummary = _context33.t0;
4612
4795
  effectiveCacheId = (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId;
4613
4796
  hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
4614
4797
  hasSmallTicketDataFlagOverride = (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined;
@@ -4628,7 +4811,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4628
4811
  tempOrder: tempOrder,
4629
4812
  cacheId: effectiveCacheId,
4630
4813
  platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform),
4631
- businessCode: (_ref72 = (_ref73 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref73 !== void 0 ? _ref73 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.businessCode) !== null && _ref72 !== void 0 ? _ref72 : (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.business_code,
4814
+ businessCode: (_ref74 = (_ref75 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref75 !== void 0 ? _ref75 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.businessCode) !== null && _ref74 !== void 0 ? _ref74 : (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.business_code,
4632
4815
  channel: params === null || params === void 0 ? void 0 : params.channel,
4633
4816
  type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
4634
4817
  summary: latestSummary,
@@ -4643,10 +4826,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4643
4826
  if (!payload.created_at) {
4644
4827
  payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
4645
4828
  }
4646
- _context32.next = 26;
4829
+ _context33.next = 26;
4647
4830
  return this.saveDraft();
4648
4831
  case 26:
4649
- _context32.prev = 26;
4832
+ _context33.prev = 26;
4650
4833
  this.logInfo('submitTempOrder calling sales checkout', {
4651
4834
  orderId: payload.order_id,
4652
4835
  externalSaleNumber: payload.external_sale_number,
@@ -4656,43 +4839,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4656
4839
  smallTicketDataFlag: payload.small_ticket_data_flag,
4657
4840
  syncMode: payload.sync_mode
4658
4841
  });
4659
- _context32.next = 30;
4842
+ _context33.next = 30;
4660
4843
  return this.submitSalesOrder({
4661
4844
  query: payload
4662
4845
  });
4663
4846
  case 30:
4664
- result = _context32.sent;
4665
- _context32.next = 43;
4847
+ result = _context33.sent;
4848
+ _context33.next = 43;
4666
4849
  break;
4667
4850
  case 33:
4668
- _context32.prev = 33;
4669
- _context32.t2 = _context32["catch"](26);
4670
- backendErrorResponse = this.extractSubmitErrorResponse(_context32.t2);
4851
+ _context33.prev = 33;
4852
+ _context33.t2 = _context33["catch"](26);
4853
+ backendErrorResponse = this.extractSubmitErrorResponse(_context33.t2);
4671
4854
  if (!backendErrorResponse) {
4672
- _context32.next = 40;
4855
+ _context33.next = 40;
4673
4856
  break;
4674
4857
  }
4675
4858
  this.store.syncState = 'failed';
4676
4859
  this.logSubmitBackendRejected(backendErrorResponse, payload);
4677
- return _context32.abrupt("return", backendErrorResponse);
4860
+ return _context33.abrupt("return", backendErrorResponse);
4678
4861
  case 40:
4679
4862
  this.store.syncState = 'failed';
4680
4863
  this.logError('submitTempOrder failed', {
4681
- error: _context32.t2 instanceof Error ? _context32.t2.message : String(_context32.t2),
4864
+ error: _context33.t2 instanceof Error ? _context33.t2.message : String(_context33.t2),
4682
4865
  orderId: payload.order_id,
4683
4866
  externalSaleNumber: payload.external_sale_number,
4684
4867
  paymentStatus: payload.payment_status,
4685
4868
  paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
4686
4869
  });
4687
- throw _context32.t2;
4870
+ throw _context33.t2;
4688
4871
  case 43:
4689
4872
  if (!this.isSubmitResponseRejected(result)) {
4690
- _context32.next = 47;
4873
+ _context33.next = 47;
4691
4874
  break;
4692
4875
  }
4693
4876
  this.store.syncState = 'failed';
4694
4877
  this.logSubmitBackendRejected(result, payload);
4695
- return _context32.abrupt("return", result);
4878
+ return _context33.abrupt("return", result);
4696
4879
  case 47:
4697
4880
  submittedOrderId = this.extractOrderIdFromSubmitResult(result);
4698
4881
  this.logInfo('runSubmitTempOrder: 提交成功', {
@@ -4703,15 +4886,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4703
4886
  })
4704
4887
  });
4705
4888
  if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
4706
- _context32.next = 56;
4889
+ _context33.next = 56;
4707
4890
  break;
4708
4891
  }
4709
4892
  tempOrder.order_id = submittedOrderId;
4710
4893
  resultRecord = result;
4711
- _context32.next = 54;
4894
+ _context33.next = 54;
4712
4895
  return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
4713
4896
  case 54:
4714
- _context32.next = 57;
4897
+ _context33.next = 57;
4715
4898
  break;
4716
4899
  case 56:
4717
4900
  if (this.isLocalPendingSubmitResult(result)) {
@@ -4720,14 +4903,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4720
4903
  this.store.syncState = 'submitted';
4721
4904
  }
4722
4905
  case 57:
4723
- return _context32.abrupt("return", result);
4906
+ return _context33.abrupt("return", result);
4724
4907
  case 58:
4725
4908
  case "end":
4726
- return _context32.stop();
4909
+ return _context33.stop();
4727
4910
  }
4728
- }, _callee29, this, [[26, 33]]);
4911
+ }, _callee30, this, [[26, 33]]);
4729
4912
  }));
4730
- function runSubmitTempOrder(_x32) {
4913
+ function runSubmitTempOrder(_x34) {
4731
4914
  return _runSubmitTempOrder.apply(this, arguments);
4732
4915
  }
4733
4916
  return runSubmitTempOrder;
@@ -4735,10 +4918,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4735
4918
  }, {
4736
4919
  key: "markLocalOrderSynced",
4737
4920
  value: function () {
4738
- var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(orderId, remoteOrder) {
4921
+ var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(orderId, remoteOrder) {
4739
4922
  var tempOrder;
4740
- return _regeneratorRuntime().wrap(function _callee30$(_context33) {
4741
- while (1) switch (_context33.prev = _context33.next) {
4923
+ return _regeneratorRuntime().wrap(function _callee31$(_context34) {
4924
+ while (1) switch (_context34.prev = _context34.next) {
4742
4925
  case 0:
4743
4926
  tempOrder = this.ensureTempOrder();
4744
4927
  tempOrder.order_id = orderId;
@@ -4746,15 +4929,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4746
4929
  this.store.lastOrderInfo = remoteOrder;
4747
4930
  this.store.syncState = 'submitted';
4748
4931
  this.persistTempOrder();
4749
- _context33.next = 8;
4932
+ _context34.next = 8;
4750
4933
  return this.saveDraft();
4751
4934
  case 8:
4752
4935
  case "end":
4753
- return _context33.stop();
4936
+ return _context34.stop();
4754
4937
  }
4755
- }, _callee30, this);
4938
+ }, _callee31, this);
4756
4939
  }));
4757
- function markLocalOrderSynced(_x33, _x34) {
4940
+ function markLocalOrderSynced(_x35, _x36) {
4758
4941
  return _markLocalOrderSynced.apply(this, arguments);
4759
4942
  }
4760
4943
  return markLocalOrderSynced;
@@ -4797,10 +4980,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4797
4980
  value: function extractSubmitErrorResponse(error) {
4798
4981
  var _error$response,
4799
4982
  _error$response2,
4800
- _this26 = this;
4983
+ _this27 = this;
4801
4984
  var candidates = [error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data, error === null || error === void 0 ? void 0 : error.data, error === null || error === void 0 || (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.body, error === null || error === void 0 ? void 0 : error.body];
4802
4985
  return candidates.find(function (candidate) {
4803
- return _this26.isSubmitErrorResponse(candidate);
4986
+ return _this27.isSubmitErrorResponse(candidate);
4804
4987
  }) || null;
4805
4988
  }
4806
4989
  }, {
@@ -4827,40 +5010,40 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4827
5010
  }, {
4828
5011
  key: "syncPaymentsToOrder",
4829
5012
  value: function () {
4830
- var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
5013
+ var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
4831
5014
  var _params$confirmPendin;
4832
- var tempOrder, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, paidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, submitResult;
4833
- return _regeneratorRuntime().wrap(function _callee31$(_context34) {
4834
- while (1) switch (_context34.prev = _context34.next) {
5015
+ var tempOrder, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, submitResult;
5016
+ return _regeneratorRuntime().wrap(function _callee32$(_context35) {
5017
+ while (1) switch (_context35.prev = _context35.next) {
4835
5018
  case 0:
4836
5019
  tempOrder = this.ensureTempOrder();
4837
5020
  mappedPayments = mapPaymentItemsToOrderPayments(params.payments || []);
4838
5021
  shouldConfirmPendingVoucherPayments = (_params$confirmPendin = params.confirmPendingVoucherPayments) !== null && _params$confirmPendin !== void 0 ? _params$confirmPendin : params.submitWhenPaid === true;
4839
5022
  effectivePayments = shouldConfirmPendingVoucherPayments ? this.confirmPendingVoucherPaymentsInList(mappedPayments) : params.confirmPendingVoucherPayments === false ? this.discardPendingVoucherPaymentsFromList(mappedPayments) : mappedPayments;
4840
5023
  completion = this.getPaymentCompletion(effectivePayments);
4841
- paidPaymentTotal = this.calculatePaymentTotal(effectivePayments);
4842
- paymentStatus = completion.isOrderFullyPaid ? params.paymentStatus || 'paid' : paidPaymentTotal.gt(0) ? 'partially_paid' : 'payment_processing';
5024
+ orderPaidPaymentTotal = this.calculateOrderPaidPaymentTotal(effectivePayments);
5025
+ paymentStatus = completion.isOrderFullyPaid ? params.paymentStatus || 'paid' : orderPaidPaymentTotal.gt(0) ? 'partially_paid' : 'payment_processing';
4843
5026
  tempOrder.payments = effectivePayments;
4844
5027
  tempOrder.payment_status = paymentStatus;
4845
5028
  this.persistTempOrder();
4846
- _context34.next = 12;
5029
+ _context35.next = 12;
4847
5030
  return this.saveDraft();
4848
5031
  case 12:
4849
5032
  if (params.submitWhenPaid) {
4850
- _context34.next = 14;
5033
+ _context35.next = 14;
4851
5034
  break;
4852
5035
  }
4853
- return _context34.abrupt("return", completion);
5036
+ return _context35.abrupt("return", completion);
4854
5037
  case 14:
4855
5038
  if (!(this.store.syncState === 'submitting')) {
4856
- _context34.next = 16;
5039
+ _context35.next = 16;
4857
5040
  break;
4858
5041
  }
4859
- return _context34.abrupt("return", completion);
5042
+ return _context35.abrupt("return", completion);
4860
5043
  case 16:
4861
5044
  this.store.syncState = 'submitting';
4862
5045
  paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, effectivePayments);
4863
- _context34.next = 20;
5046
+ _context35.next = 20;
4864
5047
  return this.submitTempOrder({
4865
5048
  payments: effectivePayments,
4866
5049
  paymentStatus: paymentStatus,
@@ -4876,17 +5059,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4876
5059
  }
4877
5060
  });
4878
5061
  case 20:
4879
- submitResult = _context34.sent;
4880
- return _context34.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
5062
+ submitResult = _context35.sent;
5063
+ return _context35.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
4881
5064
  submitResult: submitResult
4882
5065
  }));
4883
5066
  case 22:
4884
5067
  case "end":
4885
- return _context34.stop();
5068
+ return _context35.stop();
4886
5069
  }
4887
- }, _callee31, this);
5070
+ }, _callee32, this);
4888
5071
  }));
4889
- function syncPaymentsToOrder(_x35) {
5072
+ function syncPaymentsToOrder(_x37) {
4890
5073
  return _syncPaymentsToOrder.apply(this, arguments);
4891
5074
  }
4892
5075
  return syncPaymentsToOrder;
@@ -4975,11 +5158,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4975
5158
  }, {
4976
5159
  key: "submitOrder",
4977
5160
  value: function () {
4978
- var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(order) {
5161
+ var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(order) {
4979
5162
  var _order$query$cartItem, _params$bookings, _params$relation_prod;
4980
5163
  var url, query, fetchUrl, params;
4981
- return _regeneratorRuntime().wrap(function _callee32$(_context35) {
4982
- while (1) switch (_context35.prev = _context35.next) {
5164
+ return _regeneratorRuntime().wrap(function _callee33$(_context36) {
5165
+ while (1) switch (_context36.prev = _context36.next) {
4983
5166
  case 0:
4984
5167
  this.logInfo('submitOrder called', {
4985
5168
  url: order.url,
@@ -4999,14 +5182,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4999
5182
  relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
5000
5183
  scheduleDate: params.schedule_date
5001
5184
  });
5002
- return _context35.abrupt("return", this.request.post(fetchUrl, params));
5185
+ return _context36.abrupt("return", this.request.post(fetchUrl, params));
5003
5186
  case 6:
5004
5187
  case "end":
5005
- return _context35.stop();
5188
+ return _context36.stop();
5006
5189
  }
5007
- }, _callee32, this);
5190
+ }, _callee33, this);
5008
5191
  }));
5009
- function submitOrder(_x36) {
5192
+ function submitOrder(_x38) {
5010
5193
  return _submitOrder.apply(this, arguments);
5011
5194
  }
5012
5195
  return submitOrder;
@@ -5014,13 +5197,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5014
5197
  }, {
5015
5198
  key: "cancelOrder",
5016
5199
  value: function () {
5017
- var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
5200
+ var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
5018
5201
  var payload;
5019
- return _regeneratorRuntime().wrap(function _callee33$(_context36) {
5020
- while (1) switch (_context36.prev = _context36.next) {
5202
+ return _regeneratorRuntime().wrap(function _callee34$(_context37) {
5203
+ while (1) switch (_context37.prev = _context37.next) {
5021
5204
  case 0:
5022
5205
  if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
5023
- _context36.next = 2;
5206
+ _context37.next = 2;
5024
5207
  break;
5025
5208
  }
5026
5209
  throw new Error('取消订单失败:order_ids 不能为空');
@@ -5036,16 +5219,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5036
5219
  method: 'PUT',
5037
5220
  orderIdsCount: params.order_ids.length
5038
5221
  });
5039
- return _context36.abrupt("return", this.request.put('/order/update-status', payload, {
5222
+ return _context37.abrupt("return", this.request.put('/order/update-status', payload, {
5040
5223
  isShopApi: true
5041
5224
  }));
5042
5225
  case 5:
5043
5226
  case "end":
5044
- return _context36.stop();
5227
+ return _context37.stop();
5045
5228
  }
5046
- }, _callee33, this);
5229
+ }, _callee34, this);
5047
5230
  }));
5048
- function cancelOrder(_x37) {
5231
+ function cancelOrder(_x39) {
5049
5232
  return _cancelOrder.apply(this, arguments);
5050
5233
  }
5051
5234
  return cancelOrder;
@@ -5053,19 +5236,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5053
5236
  }, {
5054
5237
  key: "changeBookingStatus",
5055
5238
  value: function () {
5056
- var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
5239
+ var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
5057
5240
  var url, payload;
5058
- return _regeneratorRuntime().wrap(function _callee34$(_context37) {
5059
- while (1) switch (_context37.prev = _context37.next) {
5241
+ return _regeneratorRuntime().wrap(function _callee35$(_context38) {
5242
+ while (1) switch (_context38.prev = _context38.next) {
5060
5243
  case 0:
5061
5244
  if (params.booking_id) {
5062
- _context37.next = 2;
5245
+ _context38.next = 2;
5063
5246
  break;
5064
5247
  }
5065
5248
  throw new Error('变更预约状态失败:booking_id 不能为空');
5066
5249
  case 2:
5067
5250
  if (params.appointment_status) {
5068
- _context37.next = 4;
5251
+ _context38.next = 4;
5069
5252
  break;
5070
5253
  }
5071
5254
  throw new Error('变更预约状态失败:appointment_status 不能为空');
@@ -5080,16 +5263,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5080
5263
  bookingId: params.booking_id,
5081
5264
  appointmentStatus: params.appointment_status
5082
5265
  });
5083
- return _context37.abrupt("return", this.request.put(url, payload, {
5266
+ return _context38.abrupt("return", this.request.put(url, payload, {
5084
5267
  isShopApi: true
5085
5268
  }));
5086
5269
  case 8:
5087
5270
  case "end":
5088
- return _context37.stop();
5271
+ return _context38.stop();
5089
5272
  }
5090
- }, _callee34, this);
5273
+ }, _callee35, this);
5091
5274
  }));
5092
- function changeBookingStatus(_x38) {
5275
+ function changeBookingStatus(_x40) {
5093
5276
  return _changeBookingStatus.apply(this, arguments);
5094
5277
  }
5095
5278
  return changeBookingStatus;
@@ -5107,11 +5290,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5107
5290
  }, {
5108
5291
  key: "createOrderByCheckout",
5109
5292
  value: (function () {
5110
- var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
5293
+ var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
5111
5294
  var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3, _params$bookings3, _params$relation_prod3, _params$payments4;
5112
5295
  var onlineStorePaymentCodeList, _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, _orderData$bookings2, _orderData$relation_p2, _orderData$payments4, _orderData$payments5, _response$data, orderData, response;
5113
- return _regeneratorRuntime().wrap(function _callee35$(_context38) {
5114
- while (1) switch (_context38.prev = _context38.next) {
5296
+ return _regeneratorRuntime().wrap(function _callee36$(_context39) {
5297
+ while (1) switch (_context39.prev = _context39.next) {
5115
5298
  case 0:
5116
5299
  // 过滤掉由在线店铺下单的 payment 支付数据
5117
5300
  onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
@@ -5145,7 +5328,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5145
5328
  relationProductsCount: ((_params$relation_prod3 = params.relation_products) === null || _params$relation_prod3 === void 0 ? void 0 : _params$relation_prod3.length) || 0,
5146
5329
  paymentsCount: ((_params$payments4 = params.payments) === null || _params$payments4 === void 0 ? void 0 : _params$payments4.length) || 0
5147
5330
  });
5148
- _context38.prev = 4;
5331
+ _context39.prev = 4;
5149
5332
  // 构建订单数据,设置默认值并允许 params 覆盖
5150
5333
  orderData = _objectSpread({
5151
5334
  sales_channel: 'my_pisel',
@@ -5207,13 +5390,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5207
5390
  hasOrderId: !!orderData.order_id,
5208
5391
  smallTicketDataFlag: orderData.small_ticket_data_flag
5209
5392
  });
5210
- _context38.next = 12;
5393
+ _context39.next = 12;
5211
5394
  return this.request.post('/order/checkout', orderData, {
5212
5395
  osServer: true,
5213
5396
  customToast: function customToast() {}
5214
5397
  });
5215
5398
  case 12:
5216
- response = _context38.sent;
5399
+ response = _context39.sent;
5217
5400
  this.logInfo('Order API called successfully', {
5218
5401
  response: response
5219
5402
  });
@@ -5221,22 +5404,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5221
5404
  success: !!response,
5222
5405
  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)
5223
5406
  });
5224
- return _context38.abrupt("return", response);
5407
+ return _context39.abrupt("return", response);
5225
5408
  case 18:
5226
- _context38.prev = 18;
5227
- _context38.t0 = _context38["catch"](4);
5228
- console.error('[Order] createOrderByCheckout 创建订单失败:', _context38.t0);
5409
+ _context39.prev = 18;
5410
+ _context39.t0 = _context39["catch"](4);
5411
+ console.error('[Order] createOrderByCheckout 创建订单失败:', _context39.t0);
5229
5412
  this.logInfo('Order API called failed', {
5230
- error: _context38.t0 instanceof Error ? _context38.t0.message : String(_context38.t0)
5413
+ error: _context39.t0 instanceof Error ? _context39.t0.message : String(_context39.t0)
5231
5414
  });
5232
- throw _context38.t0;
5415
+ throw _context39.t0;
5233
5416
  case 23:
5234
5417
  case "end":
5235
- return _context38.stop();
5418
+ return _context39.stop();
5236
5419
  }
5237
- }, _callee35, this, [[4, 18]]);
5420
+ }, _callee36, this, [[4, 18]]);
5238
5421
  }));
5239
- function createOrderByCheckout(_x39) {
5422
+ function createOrderByCheckout(_x41) {
5240
5423
  return _createOrderByCheckout.apply(this, arguments);
5241
5424
  }
5242
5425
  return createOrderByCheckout;
@@ -5244,24 +5427,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5244
5427
  }, {
5245
5428
  key: "submitSalesOrder",
5246
5429
  value: function () {
5247
- var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
5430
+ var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
5248
5431
  var url, query, fetchUrl;
5249
- return _regeneratorRuntime().wrap(function _callee36$(_context39) {
5250
- while (1) switch (_context39.prev = _context39.next) {
5432
+ return _regeneratorRuntime().wrap(function _callee37$(_context40) {
5433
+ while (1) switch (_context40.prev = _context40.next) {
5251
5434
  case 0:
5252
5435
  url = params.url, query = params.query;
5253
5436
  fetchUrl = url || '/order/sales/checkout';
5254
- return _context39.abrupt("return", this.request.post(fetchUrl, query, {
5437
+ return _context40.abrupt("return", this.request.post(fetchUrl, query, {
5255
5438
  osServer: true,
5256
5439
  customToast: function customToast() {}
5257
5440
  }));
5258
5441
  case 3:
5259
5442
  case "end":
5260
- return _context39.stop();
5443
+ return _context40.stop();
5261
5444
  }
5262
- }, _callee36, this);
5445
+ }, _callee37, this);
5263
5446
  }));
5264
- function submitSalesOrder(_x40) {
5447
+ function submitSalesOrder(_x42) {
5265
5448
  return _submitSalesOrder.apply(this, arguments);
5266
5449
  }
5267
5450
  return submitSalesOrder;
@@ -5275,37 +5458,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5275
5458
  }, {
5276
5459
  key: "sendCustomerPayLink",
5277
5460
  value: (function () {
5278
- var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
5461
+ var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
5279
5462
  var _params$emails;
5280
5463
  var orderIds;
5281
- return _regeneratorRuntime().wrap(function _callee37$(_context40) {
5282
- while (1) switch (_context40.prev = _context40.next) {
5464
+ return _regeneratorRuntime().wrap(function _callee38$(_context41) {
5465
+ while (1) switch (_context41.prev = _context41.next) {
5283
5466
  case 0:
5284
5467
  orderIds = params.order_ids || params.orderIds || [];
5285
5468
  if (orderIds.length) {
5286
- _context40.next = 3;
5469
+ _context41.next = 3;
5287
5470
  break;
5288
5471
  }
5289
5472
  throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
5290
5473
  case 3:
5291
5474
  if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
5292
- _context40.next = 5;
5475
+ _context41.next = 5;
5293
5476
  break;
5294
5477
  }
5295
5478
  throw new Error('发送支付链接需要至少一个邮箱');
5296
5479
  case 5:
5297
- return _context40.abrupt("return", this.request.post('/order/batch-email', {
5480
+ return _context41.abrupt("return", this.request.post('/order/batch-email', {
5298
5481
  order_ids: orderIds,
5299
5482
  notify_action: params.notify_action || 'order_payment_reminder',
5300
5483
  emails: params.emails
5301
5484
  }));
5302
5485
  case 6:
5303
5486
  case "end":
5304
- return _context40.stop();
5487
+ return _context41.stop();
5305
5488
  }
5306
- }, _callee37, this);
5489
+ }, _callee38, this);
5307
5490
  }));
5308
- function sendCustomerPayLink(_x41) {
5491
+ function sendCustomerPayLink(_x43) {
5309
5492
  return _sendCustomerPayLink.apply(this, arguments);
5310
5493
  }
5311
5494
  return sendCustomerPayLink;
@@ -5313,14 +5496,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5313
5496
  }, {
5314
5497
  key: "getSalesOrderByLookup",
5315
5498
  value: function () {
5316
- var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
5499
+ var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
5317
5500
  var lookup, res;
5318
- return _regeneratorRuntime().wrap(function _callee38$(_context41) {
5319
- while (1) switch (_context41.prev = _context41.next) {
5501
+ return _regeneratorRuntime().wrap(function _callee39$(_context42) {
5502
+ while (1) switch (_context42.prev = _context42.next) {
5320
5503
  case 0:
5321
5504
  lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
5322
5505
  if (lookup) {
5323
- _context41.next = 3;
5506
+ _context42.next = 3;
5324
5507
  break;
5325
5508
  }
5326
5509
  throw new Error('加载销售详情需要 lookup');
@@ -5329,7 +5512,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5329
5512
  if (lookup.startsWith('LOCAL_')) {
5330
5513
  params.forceRemote = false;
5331
5514
  }
5332
- _context41.next = 6;
5515
+ _context42.next = 6;
5333
5516
  return this.request.get("/order/sales/".concat(encodeURIComponent(lookup)), _objectSpread({
5334
5517
  with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info']
5335
5518
  }, params.forceRemote ? {
@@ -5338,18 +5521,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5338
5521
  osServer: true
5339
5522
  });
5340
5523
  case 6:
5341
- res = _context41.sent;
5524
+ res = _context42.sent;
5342
5525
  if (res.code === 200) {
5343
5526
  this.store.lastOrderInfo = res.data;
5344
5527
  }
5345
- return _context41.abrupt("return", res);
5528
+ return _context42.abrupt("return", res);
5346
5529
  case 9:
5347
5530
  case "end":
5348
- return _context41.stop();
5531
+ return _context42.stop();
5349
5532
  }
5350
- }, _callee38, this);
5533
+ }, _callee39, this);
5351
5534
  }));
5352
- function getSalesOrderByLookup(_x42) {
5535
+ function getSalesOrderByLookup(_x44) {
5353
5536
  return _getSalesOrderByLookup.apply(this, arguments);
5354
5537
  }
5355
5538
  return getSalesOrderByLookup;
@@ -5363,14 +5546,36 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5363
5546
  }, {
5364
5547
  key: "hydrateTempOrderFromRecord",
5365
5548
  value: (function () {
5366
- var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(record, options) {
5367
- var _this$store$discount15;
5368
- var raw, nextTempOrder, rawSummary, summarySurcharges, hydratedEditDiscounts, currentDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount16, _this$store$discount17;
5369
- return _regeneratorRuntime().wrap(function _callee39$(_context42) {
5370
- while (1) switch (_context42.prev = _context42.next) {
5549
+ var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(record, options) {
5550
+ var _this$store$discount19;
5551
+ var sourceRaw, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, nextTempOrder, rawSummary, summarySurcharges, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount20, _this$store$discount21;
5552
+ return _regeneratorRuntime().wrap(function _callee40$(_context43) {
5553
+ while (1) switch (_context43.prev = _context43.next) {
5371
5554
  case 0:
5372
- raw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
5373
- nextTempOrder = this.normalizeTempOrderForRuntime(raw);
5555
+ sourceRaw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
5556
+ identityReadySource = this.seedAnonymousBookingUidsFromProducts(sourceRaw);
5557
+ normalizedCollections = normalizeOrderCollections(identityReadySource);
5558
+ raw = normalizedCollections.order;
5559
+ hasIdentityChanges = Object.values(normalizedCollections.stats).some(function (stats) {
5560
+ return stats.backfilledUidCount > 0 || stats.collapsedDuplicateCount > 0 || stats.uidConflictCount > 0 || stats.anonymousRowCount > 0;
5561
+ });
5562
+ if (hasIdentityChanges) {
5563
+ identityLogMetadata = {
5564
+ collections: normalizedCollections.stats,
5565
+ uidRemapCount: normalizedCollections.uidRemaps.length
5566
+ };
5567
+ hasIdentityWarnings = Object.values(normalizedCollections.stats).some(function (stats) {
5568
+ return stats.uidConflictCount > 0 || stats.anonymousRowCount > 0;
5569
+ });
5570
+ if (hasIdentityWarnings) {
5571
+ this.logWarning('Normalized hydrated order collection identities', identityLogMetadata);
5572
+ } else {
5573
+ this.logInfo('Normalized hydrated order collection identities', identityLogMetadata);
5574
+ }
5575
+ }
5576
+ nextTempOrder = this.normalizeTempOrderForRuntime(raw, {
5577
+ makeEditMark: true
5578
+ });
5374
5579
  rawSummary = raw.summary && _typeof(raw.summary) === 'object' ? raw.summary : {};
5375
5580
  summarySurcharges = Array.isArray(rawSummary.surcharges) ? rawSummary.surcharges.map(function (s) {
5376
5581
  return _objectSpread({}, s || {});
@@ -5383,45 +5588,59 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5383
5588
  originalSalesSnapshot: {
5384
5589
  summary: cloneDeep(this.store.summary),
5385
5590
  products: cloneDeep(nextTempOrder.products || []),
5591
+ bookings: cloneDeep(nextTempOrder.bookings || []),
5386
5592
  payments: cloneDeep(nextTempOrder.payments || []),
5387
5593
  surcharges: cloneDeep(nextTempOrder.surcharges || []),
5388
5594
  shop_discount: nextTempOrder.shop_discount || '0.00',
5389
5595
  productFingerprint: this.buildOrderProductsFingerprint(nextTempOrder.products || [])
5390
5596
  }
5391
5597
  });
5392
- this.store.lastOrderInfo = raw.lastOrderInfo || raw;
5598
+ // lastOrderInfo carries the exact backend snapshot used by deposit/type recovery.
5599
+ // Runtime collection repair lives in tempOrder/originalSalesSnapshot and must not
5600
+ // rewrite this protocol snapshot as a side effect of hydration.
5601
+ this.store.lastOrderInfo = sourceRaw.lastOrderInfo || sourceRaw;
5393
5602
  hydratedEditDiscounts = this.collectHydratedEditDiscounts(nextTempOrder.products);
5394
- currentDiscounts = typeof ((_this$store$discount15 = this.store.discount) === null || _this$store$discount15 === void 0 ? void 0 : _this$store$discount15.getDiscountList) === 'function' ? this.store.discount.getDiscountList() || [] : [];
5395
- shouldSkipEmptyDiscountSync = hydratedEditDiscounts.length === 0 && currentDiscounts.length === 0;
5603
+ currentDiscounts = typeof ((_this$store$discount19 = this.store.discount) === null || _this$store$discount19 === void 0 ? void 0 : _this$store$discount19.getDiscountList) === 'function' ? this.store.discount.getDiscountList() || [] : [];
5604
+ currentScanDiscounts = currentDiscounts.filter(function (discount) {
5605
+ return discount === null || discount === void 0 ? void 0 : discount.isScan;
5606
+ });
5607
+ hydratedDiscountIds = new Set(hydratedEditDiscounts.map(function (discount) {
5608
+ return discount === null || discount === void 0 ? void 0 : discount.id;
5609
+ }));
5610
+ retainedScanDiscounts = currentScanDiscounts.filter(function (discount) {
5611
+ return !hydratedDiscountIds.has(discount === null || discount === void 0 ? void 0 : discount.id);
5612
+ });
5613
+ nextDiscounts = [].concat(_toConsumableArray(hydratedEditDiscounts), _toConsumableArray(retainedScanDiscounts));
5614
+ shouldSkipEmptyDiscountSync = nextDiscounts.length === 0 && currentDiscounts.length === 0;
5396
5615
  if (shouldSkipEmptyDiscountSync) {
5397
- _context42.next = 17;
5616
+ _context43.next = 26;
5398
5617
  break;
5399
5618
  }
5400
- OrderModule.populateSavedAmounts(nextTempOrder.products, hydratedEditDiscounts);
5401
- _context42.next = 15;
5402
- return (_this$store$discount16 = this.store.discount) === null || _this$store$discount16 === void 0 ? void 0 : _this$store$discount16.setOriginalDiscountList(hydratedEditDiscounts);
5403
- case 15:
5404
- _context42.next = 17;
5405
- return (_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 ? void 0 : _this$store$discount17.setDiscountList(hydratedEditDiscounts);
5406
- case 17:
5619
+ OrderModule.populateSavedAmounts(nextTempOrder.products, nextDiscounts);
5620
+ _context43.next = 24;
5621
+ return (_this$store$discount20 = this.store.discount) === null || _this$store$discount20 === void 0 ? void 0 : _this$store$discount20.setOriginalDiscountList(nextDiscounts);
5622
+ case 24:
5623
+ _context43.next = 26;
5624
+ return (_this$store$discount21 = this.store.discount) === null || _this$store$discount21 === void 0 ? void 0 : _this$store$discount21.setDiscountList(nextDiscounts);
5625
+ case 26:
5407
5626
  if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
5408
- _context42.next = 20;
5627
+ _context43.next = 29;
5409
5628
  break;
5410
5629
  }
5411
- _context42.next = 20;
5630
+ _context43.next = 29;
5412
5631
  return this.recalculateSummary({
5413
5632
  createIfMissing: false
5414
5633
  });
5415
- case 20:
5634
+ case 29:
5416
5635
  this.persistTempOrder();
5417
- return _context42.abrupt("return", nextTempOrder);
5418
- case 22:
5636
+ return _context43.abrupt("return", nextTempOrder);
5637
+ case 31:
5419
5638
  case "end":
5420
- return _context42.stop();
5639
+ return _context43.stop();
5421
5640
  }
5422
- }, _callee39, this);
5641
+ }, _callee40, this);
5423
5642
  }));
5424
- function hydrateTempOrderFromRecord(_x43, _x44) {
5643
+ function hydrateTempOrderFromRecord(_x45, _x46) {
5425
5644
  return _hydrateTempOrderFromRecord.apply(this, arguments);
5426
5645
  }
5427
5646
  return hydrateTempOrderFromRecord;
@@ -5459,10 +5678,83 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5459
5678
  }
5460
5679
  return next;
5461
5680
  }
5681
+
5682
+ /**
5683
+ * 匿名 booking 没有服务端行 ID 时,商品侧已有的 booking_uid 就是唯一可用的强引用。
5684
+ * 在统一规范化生成 UUID 前先复用它;已落库 booking 仍按 schedule_event_id 派生稳定 UID。
5685
+ */
5686
+ }, {
5687
+ key: "seedAnonymousBookingUidsFromProducts",
5688
+ value: function seedAnonymousBookingUidsFromProducts(raw) {
5689
+ if (!raw || _typeof(raw) !== 'object') return {};
5690
+ if (!Array.isArray(raw.bookings) || !Array.isArray(raw.products)) return raw;
5691
+ var bookingUidsByProductUid = new Map();
5692
+ var _iterator22 = _createForOfIteratorHelper(raw.products),
5693
+ _step22;
5694
+ try {
5695
+ for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
5696
+ var _product$metadata10;
5697
+ var product = _step22.value;
5698
+ var productUid = getOrderCollectionUid('product', product);
5699
+ var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata10 = product.metadata) === null || _product$metadata10 === void 0 ? void 0 : _product$metadata10.booking_uid);
5700
+ if (!productUid || bookingUid === undefined || bookingUid === null || bookingUid === '') {
5701
+ continue;
5702
+ }
5703
+ var candidates = bookingUidsByProductUid.get(productUid) || new Set();
5704
+ candidates.add(String(bookingUid));
5705
+ bookingUidsByProductUid.set(productUid, candidates);
5706
+ }
5707
+ } catch (err) {
5708
+ _iterator22.e(err);
5709
+ } finally {
5710
+ _iterator22.f();
5711
+ }
5712
+ if (bookingUidsByProductUid.size === 0) return raw;
5713
+ var anonymousBookingCountByProductUid = new Map();
5714
+ var _iterator23 = _createForOfIteratorHelper(raw.bookings),
5715
+ _step23;
5716
+ try {
5717
+ for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {
5718
+ var _booking$metadata7;
5719
+ var booking = _step23.value;
5720
+ if (getOrderCollectionPersistentId('booking', booking) || getOrderCollectionUid('booking', booking)) {
5721
+ continue;
5722
+ }
5723
+ var _productUid = (booking === null || booking === void 0 ? void 0 : booking.product_uid) || (booking === null || booking === void 0 || (_booking$metadata7 = booking.metadata) === null || _booking$metadata7 === void 0 ? void 0 : _booking$metadata7.product_uid);
5724
+ if (_productUid === undefined || _productUid === null || _productUid === '') continue;
5725
+ var key = String(_productUid);
5726
+ anonymousBookingCountByProductUid.set(key, (anonymousBookingCountByProductUid.get(key) || 0) + 1);
5727
+ }
5728
+ } catch (err) {
5729
+ _iterator23.e(err);
5730
+ } finally {
5731
+ _iterator23.f();
5732
+ }
5733
+ return _objectSpread(_objectSpread({}, raw), {}, {
5734
+ bookings: raw.bookings.map(function (booking) {
5735
+ var _booking$metadata6;
5736
+ if (getOrderCollectionPersistentId('booking', booking) || getOrderCollectionUid('booking', booking)) {
5737
+ return booking;
5738
+ }
5739
+ var productUid = (booking === null || booking === void 0 ? void 0 : booking.product_uid) || (booking === null || booking === void 0 || (_booking$metadata6 = booking.metadata) === null || _booking$metadata6 === void 0 ? void 0 : _booking$metadata6.product_uid);
5740
+ if (productUid === undefined || productUid === null || productUid === '') {
5741
+ return booking;
5742
+ }
5743
+ var productUidKey = String(productUid);
5744
+ // 多条匿名 booking 共用同一商品引用时身份仍然不明确,不能借商品字段猜测合并。
5745
+ if (anonymousBookingCountByProductUid.get(productUidKey) !== 1) {
5746
+ return booking;
5747
+ }
5748
+ var bookingUidCandidates = bookingUidsByProductUid.get(productUidKey);
5749
+ var bookingUid = (bookingUidCandidates === null || bookingUidCandidates === void 0 ? void 0 : bookingUidCandidates.size) === 1 ? _toConsumableArray(bookingUidCandidates)[0] : null;
5750
+ return bookingUid ? setOrderCollectionUid('booking', booking, bookingUid) : booking;
5751
+ })
5752
+ });
5753
+ }
5462
5754
  }, {
5463
5755
  key: "normalizeTempOrderForRuntime",
5464
5756
  value: function normalizeTempOrderForRuntime(raw, options) {
5465
- var _this27 = this;
5757
+ var _this28 = this;
5466
5758
  var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), raw || {});
5467
5759
  // ES 列表详情使用 id 表示订单主键;OS 详情态统一依赖 order_id 驱动操作按钮。
5468
5760
  if ((nextTempOrder.order_id === undefined || nextTempOrder.order_id === null) && (raw === null || raw === void 0 ? void 0 : raw.id) !== undefined && (raw === null || raw === void 0 ? void 0 : raw.id) !== null) {
@@ -5485,10 +5777,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5485
5777
  nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
5486
5778
  var rawProducts = Array.isArray(raw.products) ? raw.products : [];
5487
5779
  nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
5488
- return _this27.normalizeHydratedOrderProduct(p);
5780
+ return _this28.normalizeHydratedOrderProduct(p, {
5781
+ makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
5782
+ });
5489
5783
  }) : [];
5490
5784
  nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
5491
- var booking = _this27.normalizeHydratedBookingHolder(b || {});
5785
+ var booking = _this28.normalizeHydratedBookingHolder(b || {});
5492
5786
  return _objectSpread(_objectSpread({}, booking), {}, {
5493
5787
  is_all: normalizeBookingIsAll(booking),
5494
5788
  sub_type: normalizeBookingSubType(booking)
@@ -5514,19 +5808,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5514
5808
  };
5515
5809
  var tempOrderExtend = nextTempOrder._extend;
5516
5810
  var productsByUid = tempOrderExtend.productsByUid || {};
5517
- var _iterator22 = _createForOfIteratorHelper(nextTempOrder.products.entries()),
5518
- _step22;
5811
+ var _iterator24 = _createForOfIteratorHelper(nextTempOrder.products.entries()),
5812
+ _step24;
5519
5813
  try {
5520
- for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
5521
- var _product$metadata10, _ref74, _ref75, _existed$origin, _rawProduct$metadata;
5522
- var _step22$value = _slicedToArray(_step22.value, 2),
5523
- index = _step22$value[0],
5524
- product = _step22$value[1];
5525
- var uid = (_product$metadata10 = product.metadata) === null || _product$metadata10 === void 0 ? void 0 : _product$metadata10.unique_identification_number;
5814
+ for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
5815
+ var _product$metadata11, _ref76, _ref77, _existed$origin, _rawProduct$metadata;
5816
+ var _step24$value = _slicedToArray(_step24.value, 2),
5817
+ index = _step24$value[0],
5818
+ product = _step24$value[1];
5819
+ var uid = (_product$metadata11 = product.metadata) === null || _product$metadata11 === void 0 ? void 0 : _product$metadata11.unique_identification_number;
5526
5820
  if (!uid) continue;
5527
5821
  var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
5528
5822
  var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
5529
- var origin = (_ref74 = (_ref75 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref75 !== void 0 ? _ref75 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref74 !== void 0 ? _ref74 : rawProduct;
5823
+ var origin = (_ref76 = (_ref77 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref77 !== void 0 ? _ref77 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref76 !== void 0 ? _ref76 : rawProduct;
5530
5824
  var originSnapshot = cloneDeep(origin);
5531
5825
  var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
5532
5826
  if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
@@ -5542,9 +5836,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5542
5836
  });
5543
5837
  }
5544
5838
  } catch (err) {
5545
- _iterator22.e(err);
5839
+ _iterator24.e(err);
5546
5840
  } finally {
5547
- _iterator22.f();
5841
+ _iterator24.f();
5548
5842
  }
5549
5843
  tempOrderExtend.productsByUid = productsByUid;
5550
5844
  this.hydrateLinkedBookingIdentity(nextTempOrder);
@@ -5560,8 +5854,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5560
5854
  var bookingUidByProductUid = new Map();
5561
5855
  var productByUid = new Map();
5562
5856
  (tempOrder.products || []).forEach(function (product) {
5563
- var _product$metadata11;
5564
- var productUid = (product === null || product === void 0 || (_product$metadata11 = product.metadata) === null || _product$metadata11 === void 0 ? void 0 : _product$metadata11.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
5857
+ var _product$metadata12;
5858
+ var productUid = (product === null || product === void 0 || (_product$metadata12 = product.metadata) === null || _product$metadata12 === void 0 ? void 0 : _product$metadata12.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
5565
5859
  if (productUid !== undefined && productUid !== null && String(productUid) !== '') {
5566
5860
  productByUid.set(String(productUid), product);
5567
5861
  }
@@ -5582,15 +5876,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5582
5876
  bookingUidByProductUid.set(String(productUid), bookingUid);
5583
5877
  });
5584
5878
  (tempOrder.products || []).forEach(function (product) {
5585
- var _product$metadata12;
5586
- var productUid = (product === null || product === void 0 || (_product$metadata12 = product.metadata) === null || _product$metadata12 === void 0 ? void 0 : _product$metadata12.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
5879
+ var _product$metadata13;
5880
+ var productUid = (product === null || product === void 0 || (_product$metadata13 = product.metadata) === null || _product$metadata13 === void 0 ? void 0 : _product$metadata13.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
5587
5881
  if (productUid === undefined || productUid === null || String(productUid) === '') return;
5588
5882
  var bookingUid = bookingUidByProductUid.get(String(productUid));
5589
5883
  if (!bookingUid) return;
5590
5884
  if (!product.metadata || _typeof(product.metadata) !== 'object') {
5591
5885
  product.metadata = {};
5592
5886
  }
5593
- var linkedBookingUid = String(product.booking_uid || product.metadata.booking_uid || bookingUid);
5887
+ // booking 已经过统一身份规范化;以它为准同步商品侧旧引用,避免两侧 UID 断链。
5888
+ var linkedBookingUid = String(bookingUid);
5594
5889
  product.booking_uid = linkedBookingUid;
5595
5890
  product.metadata.booking_uid = linkedBookingUid;
5596
5891
  });
@@ -5618,18 +5913,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5618
5913
  var segments = [];
5619
5914
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
5620
5915
  if (Array.isArray(sku.variant)) {
5621
- var _iterator23 = _createForOfIteratorHelper(sku.variant),
5622
- _step23;
5916
+ var _iterator25 = _createForOfIteratorHelper(sku.variant),
5917
+ _step25;
5623
5918
  try {
5624
- for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {
5625
- var variant = _step23.value;
5919
+ for (_iterator25.s(); !(_step25 = _iterator25.n()).done;) {
5920
+ var variant = _step25.value;
5626
5921
  var segment = this.formatHydratedNamePair(variant === null || variant === void 0 ? void 0 : variant.group, variant === null || variant === void 0 ? void 0 : variant.item);
5627
5922
  if (segment) segments.push(segment);
5628
5923
  }
5629
5924
  } catch (err) {
5630
- _iterator23.e(err);
5925
+ _iterator25.e(err);
5631
5926
  } finally {
5632
- _iterator23.f();
5927
+ _iterator25.f();
5633
5928
  }
5634
5929
  }
5635
5930
  return segments.join(', ');
@@ -5637,10 +5932,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5637
5932
  }, {
5638
5933
  key: "normalizeHydratedProductOptionItem",
5639
5934
  value: function normalizeHydratedProductOptionItem(optionItem) {
5640
- var _ref76, _optionItem$num, _ref77, _optionItem$add_price;
5641
- var rawNum = (_ref76 = (_optionItem$num = optionItem === null || optionItem === void 0 ? void 0 : optionItem.num) !== null && _optionItem$num !== void 0 ? _optionItem$num : optionItem === null || optionItem === void 0 ? void 0 : optionItem.quantity) !== null && _ref76 !== void 0 ? _ref76 : 1;
5935
+ var _ref78, _optionItem$num, _ref79, _optionItem$add_price;
5936
+ var rawNum = (_ref78 = (_optionItem$num = optionItem === null || optionItem === void 0 ? void 0 : optionItem.num) !== null && _optionItem$num !== void 0 ? _optionItem$num : optionItem === null || optionItem === void 0 ? void 0 : optionItem.quantity) !== null && _ref78 !== void 0 ? _ref78 : 1;
5642
5937
  var parsedNum = Number(rawNum);
5643
- var rawPrice = (_ref77 = (_optionItem$add_price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _optionItem$add_price !== void 0 ? _optionItem$add_price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _ref77 !== void 0 ? _ref77 : 0;
5938
+ var rawPrice = (_ref79 = (_optionItem$add_price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _optionItem$add_price !== void 0 ? _optionItem$add_price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _ref79 !== void 0 ? _ref79 : 0;
5644
5939
  var parsedPrice = Number(rawPrice);
5645
5940
  var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
5646
5941
  option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
@@ -5656,8 +5951,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5656
5951
  }
5657
5952
  }, {
5658
5953
  key: "normalizeHydratedOrderProduct",
5659
- value: function normalizeHydratedOrderProduct(product) {
5660
- var _this28 = this;
5954
+ value: function normalizeHydratedOrderProduct(product, options) {
5955
+ var _this29 = this;
5661
5956
  var row = _objectSpread({}, product || {});
5662
5957
  if (row.num === undefined && row.product_quantity !== undefined) {
5663
5958
  row.num = row.product_quantity;
@@ -5665,7 +5960,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5665
5960
  var productSku = ensureProductSku(row);
5666
5961
  row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
5667
5962
  option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
5668
- return _this28.normalizeHydratedProductOptionItem(optionItem || {});
5963
+ return _this29.normalizeHydratedProductOptionItem(optionItem || {});
5669
5964
  }))
5670
5965
  });
5671
5966
  delete row["product_".concat('option', "_item")];
@@ -5679,6 +5974,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5679
5974
  if (!existingIdentity) {
5680
5975
  row.metadata.unique_identification_number = createUuidV4();
5681
5976
  }
5977
+ // 从云端、本地数据库中获取到的商品数据,先打上 runtime 标记,提供给 UI 做 saved items.
5978
+ if (options !== null && options !== void 0 && options.makeEditMark) {
5979
+ row.metadata.is_edit_for_runtime = true;
5980
+ }
5682
5981
  var normalized = normalizeOrderProduct(row);
5683
5982
  normalized.discount_list = normalizeOrderProductDiscountList(normalized.discount_list);
5684
5983
  var result = _objectSpread(_objectSpread(_objectSpread({}, row), normalized), {}, {
@@ -5698,27 +5997,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5698
5997
  }, {
5699
5998
  key: "getOrderInfo",
5700
5999
  value: function () {
5701
- var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(order_id) {
6000
+ var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(order_id) {
5702
6001
  var res;
5703
- return _regeneratorRuntime().wrap(function _callee40$(_context43) {
5704
- while (1) switch (_context43.prev = _context43.next) {
6002
+ return _regeneratorRuntime().wrap(function _callee41$(_context44) {
6003
+ while (1) switch (_context44.prev = _context44.next) {
5705
6004
  case 0:
5706
- _context43.next = 2;
6005
+ _context44.next = 2;
5707
6006
  return this.request.get("/order/sales/".concat(order_id), {
5708
6007
  with: ['products', 'bookings']
5709
6008
  }, {
5710
6009
  osServer: true
5711
6010
  });
5712
6011
  case 2:
5713
- res = _context43.sent;
5714
- return _context43.abrupt("return", res);
6012
+ res = _context44.sent;
6013
+ return _context44.abrupt("return", res);
5715
6014
  case 4:
5716
6015
  case "end":
5717
- return _context43.stop();
6016
+ return _context44.stop();
5718
6017
  }
5719
- }, _callee40, this);
6018
+ }, _callee41, this);
5720
6019
  }));
5721
- function getOrderInfo(_x45) {
6020
+ function getOrderInfo(_x47) {
5722
6021
  return _getOrderInfo.apply(this, arguments);
5723
6022
  }
5724
6023
  return getOrderInfo;
@@ -5754,70 +6053,70 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5754
6053
  addDiscountAmount(savedMap, discountKey, amount);
5755
6054
  addDiscountAmount(isPersistedProduct || discount.order_discount_id != null ? editModeSavedMap : runtimeSavedMap, discountKey, amount);
5756
6055
  };
5757
- var _iterator24 = _createForOfIteratorHelper(productList),
5758
- _step24;
6056
+ var _iterator26 = _createForOfIteratorHelper(productList),
6057
+ _step26;
5759
6058
  try {
5760
- for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
5761
- var product = _step24.value;
6059
+ for (_iterator26.s(); !(_step26 = _iterator26.n()).done;) {
6060
+ var product = _step26.value;
5762
6061
  var qty = product.num || 1;
5763
6062
  var isPersistedProduct = Boolean(product.order_detail_id || product.orderDetailId || product.booking_id);
5764
- var _iterator26 = _createForOfIteratorHelper(product.discount_list || []),
5765
- _step26;
6063
+ var _iterator28 = _createForOfIteratorHelper(product.discount_list || []),
6064
+ _step28;
5766
6065
  try {
5767
- for (_iterator26.s(); !(_step26 = _iterator26.n()).done;) {
5768
- var pd = _step26.value;
6066
+ for (_iterator28.s(); !(_step28 = _iterator28.n()).done;) {
6067
+ var pd = _step28.value;
5769
6068
  addProductDiscountAmount(pd, qty, isPersistedProduct);
5770
6069
  }
5771
6070
  } catch (err) {
5772
- _iterator26.e(err);
6071
+ _iterator28.e(err);
5773
6072
  } finally {
5774
- _iterator26.f();
6073
+ _iterator28.f();
5775
6074
  }
5776
- var _iterator27 = _createForOfIteratorHelper(product.product_bundle || []),
5777
- _step27;
6075
+ var _iterator29 = _createForOfIteratorHelper(product.product_bundle || []),
6076
+ _step29;
5778
6077
  try {
5779
- for (_iterator27.s(); !(_step27 = _iterator27.n()).done;) {
5780
- var _ref78, _bundle$num3;
5781
- var bundle = _step27.value;
6078
+ for (_iterator29.s(); !(_step29 = _iterator29.n()).done;) {
6079
+ var _ref80, _bundle$num3;
6080
+ var bundle = _step29.value;
5782
6081
  var isPersistedBundleProduct = isPersistedProduct || Boolean((bundle === null || bundle === void 0 ? void 0 : bundle.order_detail_id) || (bundle === null || bundle === void 0 ? void 0 : bundle.orderDetailId) || (bundle === null || bundle === void 0 ? void 0 : bundle.booking_id));
5783
- var bundleQty = new Decimal(Number(qty) || 1).times(Number((_ref78 = (_bundle$num3 = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num3 !== void 0 ? _bundle$num3 : bundle === null || bundle === void 0 ? void 0 : bundle.quantity) !== null && _ref78 !== void 0 ? _ref78 : 1) || 1).toNumber();
5784
- var _iterator28 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
5785
- _step28;
6082
+ var bundleQty = new Decimal(Number(qty) || 1).times(Number((_ref80 = (_bundle$num3 = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num3 !== void 0 ? _bundle$num3 : bundle === null || bundle === void 0 ? void 0 : bundle.quantity) !== null && _ref80 !== void 0 ? _ref80 : 1) || 1).toNumber();
6083
+ var _iterator30 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
6084
+ _step30;
5786
6085
  try {
5787
- for (_iterator28.s(); !(_step28 = _iterator28.n()).done;) {
5788
- var _pd = _step28.value;
6086
+ for (_iterator30.s(); !(_step30 = _iterator30.n()).done;) {
6087
+ var _pd = _step30.value;
5789
6088
  addProductDiscountAmount(_pd, bundleQty, isPersistedBundleProduct);
5790
6089
  }
5791
6090
  } catch (err) {
5792
- _iterator28.e(err);
6091
+ _iterator30.e(err);
5793
6092
  } finally {
5794
- _iterator28.f();
6093
+ _iterator30.f();
5795
6094
  }
5796
6095
  }
5797
6096
  } catch (err) {
5798
- _iterator27.e(err);
6097
+ _iterator29.e(err);
5799
6098
  } finally {
5800
- _iterator27.f();
6099
+ _iterator29.f();
5801
6100
  }
5802
6101
  }
5803
6102
  } catch (err) {
5804
- _iterator24.e(err);
6103
+ _iterator26.e(err);
5805
6104
  } finally {
5806
- _iterator24.f();
6105
+ _iterator26.f();
5807
6106
  }
5808
- var _iterator25 = _createForOfIteratorHelper(discountList),
5809
- _step25;
6107
+ var _iterator27 = _createForOfIteratorHelper(discountList),
6108
+ _step27;
5810
6109
  try {
5811
- for (_iterator25.s(); !(_step25 = _iterator25.n()).done;) {
5812
- var d = _step25.value;
6110
+ for (_iterator27.s(); !(_step27 = _iterator27.n()).done;) {
6111
+ var d = _step27.value;
5813
6112
  var key = d.id;
5814
6113
  var sourceMap = d.isEditMode ? editModeSavedMap : editModeDiscountKeys.has(key) ? runtimeSavedMap : savedMap;
5815
6114
  d.savedAmount = d.isSelected && key != null && sourceMap.has(key) ? sourceMap.get(key).toNumber() : 0;
5816
6115
  }
5817
6116
  } catch (err) {
5818
- _iterator25.e(err);
6117
+ _iterator27.e(err);
5819
6118
  } finally {
5820
- _iterator25.f();
6119
+ _iterator27.f();
5821
6120
  }
5822
6121
  }
5823
6122
  }]);