@pisell/pisellos 2.2.309 → 2.2.310

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 (121) hide show
  1. package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
  2. package/dist/model/strategy/adapter/walletPass/evaluator.js +4 -2
  3. package/dist/modules/BookingContext/index.js +4 -4
  4. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +58 -19
  5. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +24 -12
  6. package/dist/modules/Customer/index.js +6 -3
  7. package/dist/modules/Customer/types.d.ts +2 -0
  8. package/dist/modules/Discount/availability.d.ts +7 -0
  9. package/dist/modules/Discount/availability.js +49 -0
  10. package/dist/modules/Discount/entitlementPass.d.ts +34 -0
  11. package/dist/modules/Discount/entitlementPass.js +147 -0
  12. package/dist/modules/Discount/index.d.ts +2 -2
  13. package/dist/modules/Discount/index.js +37 -151
  14. package/dist/modules/Discount/types.d.ts +36 -5
  15. package/dist/modules/OpenData/index.d.ts +1 -1
  16. package/dist/modules/OpenData/index.js +21 -12
  17. package/dist/modules/Order/index.d.ts +32 -4
  18. package/dist/modules/Order/index.js +733 -373
  19. package/dist/modules/Order/types.d.ts +17 -0
  20. package/dist/modules/Order/utils/orderCollectionIdentity.js +16 -12
  21. package/dist/modules/Order/utils.d.ts +14 -2
  22. package/dist/modules/Order/utils.js +275 -76
  23. package/dist/modules/Payment/index.d.ts +0 -5
  24. package/dist/modules/Payment/index.js +35 -85
  25. package/dist/modules/Payment/types.d.ts +21 -1
  26. package/dist/modules/Payment/types.js +2 -0
  27. package/dist/modules/Payment/walletpass.d.ts +1 -1
  28. package/dist/modules/Payment/walletpass.js +80 -47
  29. package/dist/modules/ProductList/index.js +18 -5
  30. package/dist/modules/Rules/index.d.ts +2 -2
  31. package/dist/modules/Rules/index.js +480 -186
  32. package/dist/modules/Rules/types.d.ts +4 -0
  33. package/dist/server/index.js +8 -5
  34. package/dist/server/modules/order/index.js +6 -0
  35. package/dist/server/modules/order/types.d.ts +12 -0
  36. package/dist/server/modules/payment/index.d.ts +25 -6
  37. package/dist/server/modules/payment/index.js +660 -133
  38. package/dist/server/utils/small-ticket.d.ts +8 -5
  39. package/dist/server/utils/small-ticket.js +1269 -199
  40. package/dist/solution/BaseSales/index.d.ts +11 -2
  41. package/dist/solution/BaseSales/index.js +1463 -1173
  42. package/dist/solution/BaseSales/types.d.ts +7 -3
  43. package/dist/solution/BaseSales/utils/cartPromotion.js +141 -126
  44. package/dist/solution/BookingByStep/index.d.ts +1 -1
  45. package/dist/solution/BookingTicket/index.d.ts +12 -3
  46. package/dist/solution/BookingTicket/index.js +663 -542
  47. package/dist/solution/BookingTicket/types.d.ts +5 -1
  48. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +2 -0
  49. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +338 -147
  50. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +8 -4
  51. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +6 -0
  52. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +19 -6
  53. package/dist/solution/ShopDiscount/index.d.ts +2 -0
  54. package/dist/solution/ShopDiscount/index.js +99 -42
  55. package/dist/solution/ShopDiscount/utils.d.ts +4 -2
  56. package/dist/solution/ShopDiscount/utils.js +43 -23
  57. package/dist/solution/UnifiedBookingSales/index.d.ts +2 -2
  58. package/dist/solution/UnifiedBookingSales/index.js +5 -5
  59. package/dist/utils/os-private-payload.d.ts +5 -0
  60. package/dist/utils/os-private-payload.js +17 -0
  61. package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
  62. package/lib/model/strategy/adapter/walletPass/evaluator.js +2 -0
  63. package/lib/modules/BookingContext/index.js +3 -3
  64. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +35 -6
  65. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +13 -6
  66. package/lib/modules/Customer/index.js +5 -1
  67. package/lib/modules/Customer/types.d.ts +2 -0
  68. package/lib/modules/Discount/availability.d.ts +7 -0
  69. package/lib/modules/Discount/availability.js +43 -0
  70. package/lib/modules/Discount/entitlementPass.d.ts +34 -0
  71. package/lib/modules/Discount/entitlementPass.js +141 -0
  72. package/lib/modules/Discount/index.d.ts +2 -2
  73. package/lib/modules/Discount/index.js +23 -129
  74. package/lib/modules/Discount/types.d.ts +36 -5
  75. package/lib/modules/OpenData/index.d.ts +1 -1
  76. package/lib/modules/OpenData/index.js +11 -2
  77. package/lib/modules/Order/index.d.ts +32 -4
  78. package/lib/modules/Order/index.js +341 -71
  79. package/lib/modules/Order/types.d.ts +17 -0
  80. package/lib/modules/Order/utils/orderCollectionIdentity.js +14 -11
  81. package/lib/modules/Order/utils.d.ts +14 -2
  82. package/lib/modules/Order/utils.js +186 -3
  83. package/lib/modules/Payment/index.d.ts +0 -5
  84. package/lib/modules/Payment/index.js +3 -28
  85. package/lib/modules/Payment/types.d.ts +21 -1
  86. package/lib/modules/Payment/types.js +1 -0
  87. package/lib/modules/Payment/walletpass.d.ts +1 -1
  88. package/lib/modules/Payment/walletpass.js +29 -9
  89. package/lib/modules/ProductList/index.js +14 -1
  90. package/lib/modules/Rules/index.d.ts +2 -2
  91. package/lib/modules/Rules/index.js +357 -110
  92. package/lib/modules/Rules/types.d.ts +4 -0
  93. package/lib/server/index.js +8 -5
  94. package/lib/server/modules/order/index.js +6 -0
  95. package/lib/server/modules/order/types.d.ts +12 -0
  96. package/lib/server/modules/payment/index.d.ts +25 -6
  97. package/lib/server/modules/payment/index.js +350 -78
  98. package/lib/server/utils/small-ticket.d.ts +8 -5
  99. package/lib/server/utils/small-ticket.js +1009 -121
  100. package/lib/solution/BaseSales/index.d.ts +11 -2
  101. package/lib/solution/BaseSales/index.js +164 -30
  102. package/lib/solution/BaseSales/types.d.ts +7 -3
  103. package/lib/solution/BaseSales/utils/cartPromotion.js +12 -4
  104. package/lib/solution/BookingByStep/index.d.ts +1 -1
  105. package/lib/solution/BookingTicket/index.d.ts +12 -3
  106. package/lib/solution/BookingTicket/index.js +103 -41
  107. package/lib/solution/BookingTicket/types.d.ts +5 -1
  108. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +2 -0
  109. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +174 -42
  110. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +8 -4
  111. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +6 -0
  112. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +11 -3
  113. package/lib/solution/ShopDiscount/index.d.ts +2 -0
  114. package/lib/solution/ShopDiscount/index.js +55 -9
  115. package/lib/solution/ShopDiscount/utils.d.ts +4 -2
  116. package/lib/solution/ShopDiscount/utils.js +42 -25
  117. package/lib/solution/UnifiedBookingSales/index.d.ts +2 -2
  118. package/lib/solution/UnifiedBookingSales/index.js +5 -5
  119. package/lib/utils/os-private-payload.d.ts +5 -0
  120. package/lib/utils/os-private-payload.js +22 -0
  121. package/package.json +1 -1
@@ -6,13 +6,7 @@ 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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
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."); }
11
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
12
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
13
9
  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; } } }; }
14
- 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); }
15
- 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; }
16
10
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
17
11
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
18
12
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
@@ -25,6 +19,12 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
25
19
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
26
20
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
27
21
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
22
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
23
+ 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."); }
24
+ 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); }
25
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
26
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
27
+ 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; }
28
28
  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; }
29
29
  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; }
30
30
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -32,10 +32,12 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
32
32
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
33
33
  import { BaseModule } from "../BaseModule";
34
34
  import { OrderHooks } from "./types";
35
- import { composeLinePrice, generateDuration, getAllDiscountList, mergeRelationForms, ensureCartItemOriginHolder, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, isTempOrder, normalizeOrderMetaList, normalizeBookingIsAll, normalizeBookingSubType, mapPaymentItemsToOrderPayments, normalizeOrderProductDiscountList, resolveEffectivePerUnitDiscount, ensureProductSku, getProductSkuOptions, normalizeProductSkuOptions, sumOptionUnitPrice, clearTempOrderHolderAssignments, getOrderProductLineUid, indexOrderProductsByUid, calculateOrderProductsDeposit, buildPointCardSnapshotFromWalletPassList, mergeOrderProductDisplayFields, resolveIsFormSubject, isMarkdownBundle } from "./utils";
35
+ import { composeLinePrice, generateDuration, getAllDiscountList, mergeRelationForms, ensureCartItemOriginHolder, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, isTempOrder, normalizeOrderMetaList, normalizeBookingIsAll, normalizeBookingSubType, mapPaymentItemsToOrderPayments, normalizeOrderProductDiscountList, resolveEffectivePerUnitDiscount, ensureProductSku, getProductSkuOptions, normalizeProductSkuOptions, sumOptionUnitPrice, clearTempOrderHolderAssignments, getOrderProductLineUid, indexOrderProductsByUid, calculateOrderProductsDeposit, collectPointCardSnapshotCodeCandidates, mergePointCardSnapshotCodes as _mergePointCardSnapshotCodes, buildVirtualCurrencySnapshotFromList, mergeOrderProductDisplayFields, resolveIsFormSubject, isMarkdownBundle } from "./utils";
36
36
  import { isNormalProduct } from "../Product/utils";
37
37
  import { getWeighedProductPriceFingerprint, resolveWeighedSourcePrice, withOriginalBundleOptionPrices } from "./utils/weighedProduct";
38
38
  import dayjs from 'dayjs';
39
+ import { getDiscountLifecycleReason } from "../Discount/availability";
40
+ import { stripOsPrivatePayloadFields } from "../../utils/os-private-payload";
39
41
  import { buildSalesNoteText, decodeSalesNotesSnapshot, getSalesNotePolicy } from "./salesNotes";
40
42
  import { ensureOrderPaymentNumber, mergeOrderPaymentRecord, resolveOrderPaymentIdentity } from "./payment-utils";
41
43
  import { resolvePaymentNumberDevicePrefix, resolvePaymentNumberDevicePrefixFromDeviceId } from "../../utils/payment-number";
@@ -48,6 +50,7 @@ import { consolidateDiscountFreeProductLines, ensureUniqueProductLineUids } from
48
50
  import { applyTempOrderSettlementState, getSelectedSettlementSnapshot, getSettlementKey, getTempOrderSettlementKey, getTempOrderSettlementSnapshot, isVirtualSettlementOrder, normalizeVirtualSettlementOrderProduct, normalizeVirtualSettlementProducts, OrderSettlementConflictError, releaseTempOrderSettlementState, VirtualCurrencyAssetNotFoundError, VirtualCurrencyBalanceError } from "./utils/virtualSettlement";
49
51
  import { DiscountModule } from "../Discount";
50
52
  import { RulesModule } from "../Rules";
53
+ import { isEntitlementPass, isFullCoveragePass } from "../Discount/entitlementPass";
51
54
  import { UnavailableReason } from "../Rules/types";
52
55
  import Decimal from 'decimal.js';
53
56
  import { cloneDeep } from 'lodash-es';
@@ -71,9 +74,26 @@ function isManualProductDiscountProduct(product) {
71
74
  return (item === null || item === void 0 ? void 0 : item.type) === 'product';
72
75
  });
73
76
  }
77
+ function syncReducedEntitlementPassUsageCount(discountList, previousQuantity, nextQuantity) {
78
+ if (!Array.isArray(discountList)) return discountList;
79
+ var previousCount = getSafeProductNum(previousQuantity);
80
+ var nextCount = getSafeProductNum(nextQuantity);
81
+ if (nextCount >= previousCount) return discountList;
82
+ return discountList.map(function (discount) {
83
+ var _discount$metadata$nu, _discount$metadata;
84
+ if (!isEntitlementPass(discount)) return discount;
85
+ var rawUsageCount = Number((_discount$metadata$nu = discount === null || discount === void 0 || (_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.num) !== null && _discount$metadata$nu !== void 0 ? _discount$metadata$nu : previousCount);
86
+ var usageCount = Number.isFinite(rawUsageCount) ? Math.max(Math.floor(rawUsageCount), 0) : previousCount;
87
+ return _objectSpread(_objectSpread({}, discount), {}, {
88
+ metadata: _objectSpread(_objectSpread({}, (discount === null || discount === void 0 ? void 0 : discount.metadata) || {}), {}, {
89
+ num: Math.min(usageCount, nextCount)
90
+ })
91
+ });
92
+ });
93
+ }
74
94
  var ORDER_PAYMENT_STATUS_PAID = 'paid';
75
95
  var ORDER_PAYMENT_STATUS_PENDING = 'payment_pending';
76
- var CUSTOMER_PROMOTION_DISCOUNT_TAGS = new Set(['good_pass', 'product_discount_card', 'discount_card']);
96
+ var CUSTOMER_PROMOTION_DISCOUNT_TAGS = new Set(['entitlement_pass', 'good_pass', 'product_discount_card', 'discount_card']);
77
97
  function isCustomerPromotionDiscount(discount) {
78
98
  return CUSTOMER_PROMOTION_DISCOUNT_TAGS.has(String((discount === null || discount === void 0 ? void 0 : discount.tag) || (discount === null || discount === void 0 ? void 0 : discount.type) || '').toLowerCase());
79
99
  }
@@ -108,12 +128,26 @@ function getVoucherPaymentLifecycleKey(payment) {
108
128
  if (!isVoucherPaymentRecord(payment)) return null;
109
129
  return "".concat(String(payment.voucher_id), "::").concat(String(payment.status || ''));
110
130
  }
111
- function hasPersistedOrderId(orderId) {
112
- if (orderId === undefined || orderId === null || orderId === '') return false;
113
- if (typeof orderId === 'string' && orderId.startsWith('LOCAL_')) return false;
114
- var normalizedOrderId = Number(orderId);
115
- if (Number.isFinite(normalizedOrderId)) return normalizedOrderId > 0;
116
- return String(orderId).trim() !== '';
131
+ function getDiscountIdentityKey(discount) {
132
+ var id = discount === null || discount === void 0 ? void 0 : discount.id;
133
+ if (id === undefined || id === null || id === '') return null;
134
+ return String(id);
135
+ }
136
+ function mergeCommittedEntitlementWithRuntime(committed, runtime) {
137
+ var _committed$committedA, _runtime$id, _runtime$isDisabled, _runtime$isSelected;
138
+ var committedAppliedProductDetails = (_committed$committedA = committed.committedAppliedProductDetails) !== null && _committed$committedA !== void 0 && _committed$committedA.length ? committed.committedAppliedProductDetails : committed.appliedProductDetails || [];
139
+ return _objectSpread(_objectSpread(_objectSpread({}, committed), runtime), {}, {
140
+ id: (_runtime$id = runtime.id) !== null && _runtime$id !== void 0 ? _runtime$id : committed.id,
141
+ tag: runtime.tag || committed.tag,
142
+ type: runtime.type || committed.type,
143
+ isEditMode: false,
144
+ isDisabled: (_runtime$isDisabled = runtime.isDisabled) !== null && _runtime$isDisabled !== void 0 ? _runtime$isDisabled : false,
145
+ isSelected: (_runtime$isSelected = runtime.isSelected) !== null && _runtime$isSelected !== void 0 ? _runtime$isSelected : committed.isSelected,
146
+ isUsed: committed.isUsed || runtime.isUsed,
147
+ committedAppliedProductDetails: _toConsumableArray(committedAppliedProductDetails),
148
+ applicableProductDetails: [].concat(_toConsumableArray(committed.applicableProductDetails || []), _toConsumableArray(runtime.applicableProductDetails || [])),
149
+ appliedProductDetails: [].concat(_toConsumableArray(committedAppliedProductDetails), _toConsumableArray(runtime.appliedProductDetails || []))
150
+ });
117
151
  }
118
152
  export var OrderModule = /*#__PURE__*/function (_BaseModule) {
119
153
  _inherits(OrderModule, _BaseModule);
@@ -135,6 +169,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
135
169
  _defineProperty(_assertThisInitialized(_this), "openCache", false);
136
170
  _defineProperty(_assertThisInitialized(_this), "sessionStoragePersistEnabled", false);
137
171
  _defineProperty(_assertThisInitialized(_this), "sessionStorageRestoreRecord", null);
172
+ /** 只允许当前订单最新的 prepare/config 请求回写客户资产态。 */
173
+ _defineProperty(_assertThisInitialized(_this), "customerWalletPrepareConfigEpoch", 0);
174
+ /** Payment 可能早于 prepare/config 返回;先按实例 ID 暂存卡号等待 Snapshot。 */
175
+ _defineProperty(_assertThisInitialized(_this), "pointCardSnapshotCodeCandidates", new Map());
138
176
  _defineProperty(_assertThisInitialized(_this), "salesSummaryModuleName", void 0);
139
177
  _defineProperty(_assertThisInitialized(_this), "rulesHooksOverride", void 0);
140
178
  _defineProperty(_assertThisInitialized(_this), "moduleHooksOverride", void 0);
@@ -175,7 +213,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
175
213
  _step2;
176
214
  try {
177
215
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
178
- var _item$type2, _ref, _ref2, _item$discount$resour, _item$discount, _item$discount$title, _item$discount2, _item$discount3, _item$discount$fixed_, _item$discount4, _item$discount5, _item$amount, _ref3, _item$discount$origin, _item$discount6, _ref4, _ref5, _item$metadata$num, _item$metadata, _ref6, _ref7, _item$metadata$num2, _item$metadata2, _ref8, _item$discount$discou, _item$discount7, _item$amount2, _item$amount3, _product$product_id, _product$is_charge_ta, _ref9, _product$original_pri, _ref10, _item$discount$discou2, _item$discount8, _item$discount$discou3, _item$discount9;
216
+ var _item$type2, _ref, _ref2, _item$discount$resour, _item$discount, _item$discount$title, _item$discount2, _item$metadata, _item$discount3, _item$discount4, _item$discount$fixed_, _item$discount5, _item$discount6, _item$amount, _ref3, _item$discount$origin, _item$discount7, _ref4, _ref5, _item$metadata$num, _item$metadata2, _item$discount$produc, _item$discount8, _ref6, _ref7, _item$metadata$num2, _item$metadata3, _item$discount9, _ref8, _item$discount$discou, _item$discount10, _item$amount2, _item$amount3, _product$product_id, _product$is_charge_ta, _ref9, _product$original_pri, _ref10, _item$discount$discou2, _item$discount11, _item$discount$discou3, _item$discount12;
179
217
  var item = _step2.value;
180
218
  var type = (_item$type2 = item === null || item === void 0 ? void 0 : item.type) !== null && _item$type2 !== void 0 ? _item$type2 : item === null || item === void 0 ? void 0 : item.tag;
181
219
  if (!type || type === 'product') continue;
@@ -186,22 +224,31 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
186
224
  var key = Number.isFinite(id) ? id : String(resourceId);
187
225
  var title = (_item$discount$title = item === null || item === void 0 || (_item$discount2 = item.discount) === null || _item$discount2 === void 0 ? void 0 : _item$discount2.title) !== null && _item$discount$title !== void 0 ? _item$discount$title : {};
188
226
  var amount = Number((item === null || item === void 0 ? void 0 : item.amount) || 0);
189
- var discountCardType = item === null || item === void 0 || (_item$discount3 = item.discount) === null || _item$discount3 === void 0 ? void 0 : _item$discount3.discount_card_type;
190
- var parValue = isDiscountCard ? discountCardType === 'fixed_amount' ? (_item$discount$fixed_ = item === null || item === void 0 || (_item$discount4 = item.discount) === null || _item$discount4 === void 0 ? void 0 : _item$discount4.fixed_amount) !== null && _item$discount$fixed_ !== void 0 ? _item$discount$fixed_ : item === null || item === void 0 ? void 0 : item.amount : item === null || item === void 0 || (_item$discount5 = item.discount) === null || _item$discount5 === void 0 ? void 0 : _item$discount5.percent : '0';
227
+ var encoded = (item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.encoded) || (item === null || item === void 0 ? void 0 : item.encoded) || (item === null || item === void 0 || (_item$discount3 = item.discount) === null || _item$discount3 === void 0 ? void 0 : _item$discount3.encoded) || '';
228
+ var discountCardType = item === null || item === void 0 || (_item$discount4 = item.discount) === null || _item$discount4 === void 0 ? void 0 : _item$discount4.discount_card_type;
229
+ var parValue = isDiscountCard ? discountCardType === 'fixed_amount' ? (_item$discount$fixed_ = item === null || item === void 0 || (_item$discount5 = item.discount) === null || _item$discount5 === void 0 ? void 0 : _item$discount5.fixed_amount) !== null && _item$discount$fixed_ !== void 0 ? _item$discount$fixed_ : item === null || item === void 0 ? void 0 : item.amount : item === null || item === void 0 || (_item$discount6 = item.discount) === null || _item$discount6 === void 0 ? void 0 : _item$discount6.percent : '0';
191
230
  var detail = {
192
231
  amount: String((_item$amount = item === null || item === void 0 ? void 0 : item.amount) !== null && _item$amount !== void 0 ? _item$amount : '0'),
193
232
  type: type,
194
233
  resource_id: key,
195
234
  title: title,
196
- original_amount: String((_ref3 = (_item$discount$origin = item === null || item === void 0 || (_item$discount6 = item.discount) === null || _item$discount6 === void 0 ? void 0 : _item$discount6.original_amount) !== null && _item$discount$origin !== void 0 ? _item$discount$origin : item === null || item === void 0 ? void 0 : item.amount) !== null && _ref3 !== void 0 ? _ref3 : '0'),
197
- num: Number((_ref4 = (_ref5 = (_item$metadata$num = item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.num) !== null && _item$metadata$num !== void 0 ? _item$metadata$num : product === null || product === void 0 ? void 0 : product.num) !== null && _ref5 !== void 0 ? _ref5 : product === null || product === void 0 ? void 0 : product.product_quantity) !== null && _ref4 !== void 0 ? _ref4 : 1) || 1,
235
+ original_amount: String((_ref3 = (_item$discount$origin = item === null || item === void 0 || (_item$discount7 = item.discount) === null || _item$discount7 === void 0 ? void 0 : _item$discount7.original_amount) !== null && _item$discount$origin !== void 0 ? _item$discount$origin : item === null || item === void 0 ? void 0 : item.amount) !== null && _ref3 !== void 0 ? _ref3 : '0'),
236
+ num: Number((_ref4 = (_ref5 = (_item$metadata$num = item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.num) !== null && _item$metadata$num !== void 0 ? _item$metadata$num : product === null || product === void 0 ? void 0 : product.num) !== null && _ref5 !== void 0 ? _ref5 : product === null || product === void 0 ? void 0 : product.product_quantity) !== null && _ref4 !== void 0 ? _ref4 : 1) || 1,
198
237
  metadata: item === null || item === void 0 ? void 0 : item.metadata,
199
- discount: item === null || item === void 0 ? void 0 : item.discount,
200
- _num: Number((_ref6 = (_ref7 = (_item$metadata$num2 = item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.num) !== null && _item$metadata$num2 !== void 0 ? _item$metadata$num2 : product === null || product === void 0 ? void 0 : product.num) !== null && _ref7 !== void 0 ? _ref7 : product === null || product === void 0 ? void 0 : product.product_quantity) !== null && _ref6 !== void 0 ? _ref6 : 1) || 1
238
+ discount: _objectSpread(_objectSpread({}, (item === null || item === void 0 ? void 0 : item.discount) || {}), {}, {
239
+ product_id: (_item$discount$produc = item === null || item === void 0 || (_item$discount8 = item.discount) === null || _item$discount8 === void 0 ? void 0 : _item$discount8.product_id) !== null && _item$discount$produc !== void 0 ? _item$discount$produc : product === null || product === void 0 ? void 0 : product.product_id
240
+ }),
241
+ _num: Number((_ref6 = (_ref7 = (_item$metadata$num2 = item === null || item === void 0 || (_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.num) !== null && _item$metadata$num2 !== void 0 ? _item$metadata$num2 : product === null || product === void 0 ? void 0 : product.num) !== null && _ref7 !== void 0 ? _ref7 : product === null || product === void 0 ? void 0 : product.product_quantity) !== null && _ref6 !== void 0 ? _ref6 : 1) || 1
201
242
  };
202
243
  var existed = discountMap.get(key);
203
244
  if (existed) {
204
245
  var _existed$limited_rela;
246
+ if (!existed.encoded && encoded) {
247
+ existed.encoded = encoded;
248
+ existed.metadata = _objectSpread(_objectSpread({}, existed.metadata), {}, {
249
+ encoded: encoded
250
+ });
251
+ }
205
252
  existed.amount = Number(existed.amount || 0) + amount;
206
253
  existed.used_par_value = String(Number(existed.used_par_value || 0) + amount);
207
254
  if (!isDiscountCard) {
@@ -220,10 +267,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
220
267
  discountMap.set(key, {
221
268
  id: key,
222
269
  product_name: '',
223
- encoded: '',
224
- code: '',
270
+ encoded: encoded,
271
+ code: (item === null || item === void 0 ? void 0 : item.code) || (item === null || item === void 0 || (_item$discount9 = item.discount) === null || _item$discount9 === void 0 ? void 0 : _item$discount9.code) || '',
272
+ metadata: {
273
+ encoded: encoded
274
+ },
225
275
  tag: type,
226
- product_id: (_ref8 = (_item$discount$discou = item === null || item === void 0 || (_item$discount7 = item.discount) === null || _item$discount7 === void 0 ? void 0 : _item$discount7.discount_product_id) !== null && _item$discount$discou !== void 0 ? _item$discount$discou : product === null || product === void 0 ? void 0 : product.product_id) !== null && _ref8 !== void 0 ? _ref8 : 0,
276
+ product_id: (_ref8 = (_item$discount$discou = item === null || item === void 0 || (_item$discount10 = item.discount) === null || _item$discount10 === void 0 ? void 0 : _item$discount10.discount_product_id) !== null && _item$discount$discou !== void 0 ? _item$discount$discou : product === null || product === void 0 ? void 0 : product.product_id) !== null && _ref8 !== void 0 ? _ref8 : 0,
227
277
  relation_type: '',
228
278
  par_value: String(parValue !== null && parValue !== void 0 ? parValue : '0'),
229
279
  used_par_value: String((_item$amount2 = item === null || item === void 0 ? void 0 : item.amount) !== null && _item$amount2 !== void 0 ? _item$amount2 : '0'),
@@ -256,8 +306,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
256
306
  amount: amount,
257
307
  discount: _objectSpread(_objectSpread({}, (item === null || item === void 0 ? void 0 : item.discount) || {}), {}, {
258
308
  resource_id: key,
259
- discount_product_id: (_ref10 = (_item$discount$discou2 = item === null || item === void 0 || (_item$discount8 = item.discount) === null || _item$discount8 === void 0 ? void 0 : _item$discount8.discount_product_id) !== null && _item$discount$discou2 !== void 0 ? _item$discount$discou2 : product === null || product === void 0 ? void 0 : product.product_id) !== null && _ref10 !== void 0 ? _ref10 : 0,
260
- discount_calculation_mode: (_item$discount$discou3 = item === null || item === void 0 || (_item$discount9 = item.discount) === null || _item$discount9 === void 0 ? void 0 : _item$discount9.discount_calculation_mode) !== null && _item$discount$discou3 !== void 0 ? _item$discount$discou3 : 'item_level'
309
+ discount_product_id: (_ref10 = (_item$discount$discou2 = item === null || item === void 0 || (_item$discount11 = item.discount) === null || _item$discount11 === void 0 ? void 0 : _item$discount11.discount_product_id) !== null && _item$discount$discou2 !== void 0 ? _item$discount$discou2 : product === null || product === void 0 ? void 0 : product.product_id) !== null && _ref10 !== void 0 ? _ref10 : 0,
310
+ discount_calculation_mode: (_item$discount$discou3 = item === null || item === void 0 || (_item$discount12 = item.discount) === null || _item$discount12 === void 0 ? void 0 : _item$discount12.discount_calculation_mode) !== null && _item$discount$discou3 !== void 0 ? _item$discount$discou3 : 'item_level'
261
311
  }),
262
312
  applicableProductDetails: [detail],
263
313
  appliedProductDetails: [detail]
@@ -561,7 +611,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
561
611
  }, {
562
612
  key: "createDefaultRulesHooks",
563
613
  value: function createDefaultRulesHooks() {
564
- return createDefaultOrderRulesHooks();
614
+ var _this2 = this;
615
+ return createDefaultOrderRulesHooks(function () {
616
+ var _this2$store$tempOrde;
617
+ return ((_this2$store$tempOrde = _this2.store.tempOrder) === null || _this2$store$tempOrde === void 0 ? void 0 : _this2$store$tempOrde.bookings) || [];
618
+ });
619
+ }
620
+
621
+ /**
622
+ * Stable across notifyTempOrderChanged's immutable copy, but changes when a
623
+ * different local/server order becomes current.
624
+ */
625
+ }, {
626
+ key: "getDiscountConfigOrderIdentityKey",
627
+ value: function getDiscountConfigOrderIdentityKey(tempOrder) {
628
+ var _ref12, _identity$orderId, _tempOrder$request_un, _ref13, _identity$externalSal, _ref14, _ref15, _identity$localId, _tempOrder$_extend;
629
+ var identity = this.getOrderIdentity();
630
+ return JSON.stringify([(_ref12 = (_identity$orderId = identity === null || identity === void 0 ? void 0 : identity.orderId) !== null && _identity$orderId !== void 0 ? _identity$orderId : tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.order_id) !== null && _ref12 !== void 0 ? _ref12 : '', (_tempOrder$request_un = tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.request_unique_idempotency_token) !== null && _tempOrder$request_un !== void 0 ? _tempOrder$request_un : '', (_ref13 = (_identity$externalSal = identity === null || identity === void 0 ? void 0 : identity.externalSaleNumber) !== null && _identity$externalSal !== void 0 ? _identity$externalSal : tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.external_sale_number) !== null && _ref13 !== void 0 ? _ref13 : '', (_ref14 = (_ref15 = (_identity$localId = identity === null || identity === void 0 ? void 0 : identity.localId) !== null && _identity$localId !== void 0 ? _identity$localId : tempOrder === null || tempOrder === void 0 || (_tempOrder$_extend = tempOrder._extend) === null || _tempOrder$_extend === void 0 ? void 0 : _tempOrder$_extend.localId) !== null && _ref15 !== void 0 ? _ref15 : this.cacheId) !== null && _ref14 !== void 0 ? _ref14 : '']);
565
631
  }
566
632
 
567
633
  // ─── Discount: 公共 API ───
@@ -569,13 +635,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
569
635
  key: "loadDiscountConfig",
570
636
  value: function () {
571
637
  var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
572
- var _this$store$tempOrder, _this$store$discount, _this$store$tempOrder2;
573
- var orderId, prepareConfigResult, discountList, _this$store$discount2, _this$store$discount3, _this$store$discount4, currentDiscountList, currentEditDiscounts, currentScanDiscounts, currentScanDiscountIds, runtimeDiscountIds, runtimeDiscounts, mergedDiscountList;
638
+ var _this$store$tempOrder,
639
+ _this$store$discount,
640
+ _this3 = this,
641
+ _this$store$tempOrder2;
642
+ var orderId, requestEpoch, requestOrderIdentityKey, prepareConfigResult, isCurrentRequest, discountList, _this$store$discount2, _this$store$discount3, _this$store$discount4, currentDiscountList, currentCommittedDiscounts, currentScanDiscounts, currentScanDiscountById, committedDiscountById, mergedCommittedDiscountIds, refreshedScanDiscountIds, runtimeDiscountIds, runtimeDiscounts, retainedCommittedDiscounts, retainedScanDiscounts, mergedDiscountList;
574
643
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
575
644
  while (1) switch (_context3.prev = _context3.next) {
576
645
  case 0:
577
646
  orderId = params.orderId || ((_this$store$tempOrder = this.store.tempOrder) === null || _this$store$tempOrder === void 0 ? void 0 : _this$store$tempOrder.order_id) || undefined;
578
- _context3.next = 3;
647
+ requestEpoch = ++this.customerWalletPrepareConfigEpoch;
648
+ requestOrderIdentityKey = this.getDiscountConfigOrderIdentityKey(this.store.tempOrder);
649
+ _context3.next = 5;
579
650
  return (_this$store$discount = this.store.discount) === null || _this$store$discount === void 0 ? void 0 : _this$store$discount.loadPrepareConfig(_objectSpread({
580
651
  customer_id: params.customerId,
581
652
  action: params.action || (orderId ? 'edit' : 'create'),
@@ -584,56 +655,130 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
584
655
  with_wallet_pass_holder: 1,
585
656
  with_available_wallet_flag: 1,
586
657
  with_available_wallet_pass_flag: 1,
658
+ with_entitlement_pass: 1,
659
+ filter_order_wallet_pass_usage: 0,
587
660
  with_virtual_currency: 1,
588
661
  request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
589
662
  }, orderId ? {
590
663
  order_id: orderId
591
664
  } : {}));
592
- case 3:
665
+ case 5:
593
666
  prepareConfigResult = _context3.sent;
667
+ isCurrentRequest = function isCurrentRequest() {
668
+ var _this3$store$tempOrde, _this3$store$tempOrde2;
669
+ return requestEpoch === _this3.customerWalletPrepareConfigEpoch && _this3.getDiscountConfigOrderIdentityKey(_this3.store.tempOrder) === requestOrderIdentityKey && String((_this3$store$tempOrde = (_this3$store$tempOrde2 = _this3.store.tempOrder) === null || _this3$store$tempOrde2 === void 0 ? void 0 : _this3$store$tempOrde2.customer_id) !== null && _this3$store$tempOrde !== void 0 ? _this3$store$tempOrde : '') === String(params.customerId);
670
+ };
671
+ if (isCurrentRequest()) {
672
+ _context3.next = 9;
673
+ break;
674
+ }
675
+ return _context3.abrupt("return", this.getDiscountList());
676
+ case 9:
594
677
  discountList = prepareConfigResult === null || prepareConfigResult === void 0 ? void 0 : prepareConfigResult.discountList;
595
- this.store.availableWalletIds = (prepareConfigResult === null || prepareConfigResult === void 0 ? void 0 : prepareConfigResult.availableWalletIds) || [];
596
- this.store.virtualCurrencyList = (prepareConfigResult === null || prepareConfigResult === void 0 ? void 0 : prepareConfigResult.virtualCurrencyList) || [];
597
678
  if (prepareConfigResult) {
598
- this.writePointCardSnapshotFromPrepareConfig({
599
- orderId: orderId,
679
+ this.writeCustomerWalletSnapshotsFromPrepareConfig({
600
680
  customerId: params.customerId,
601
- availableWalletPassList: prepareConfigResult.availableWalletPassList || []
681
+ availableWalletIds: prepareConfigResult.availableWalletIds || [],
682
+ availableWalletPassList: prepareConfigResult.availableWalletPassList || [],
683
+ virtualCurrencyList: prepareConfigResult.virtualCurrencyList || []
602
684
  });
603
685
  }
604
686
  if (!discountList) {
605
- _context3.next = 20;
687
+ _context3.next = 32;
606
688
  break;
607
689
  }
608
690
  currentDiscountList = ((_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 ? void 0 : _this$store$discount2.getDiscountList()) || [];
609
- currentEditDiscounts = currentDiscountList.filter(function (discount) {
610
- return discount === null || discount === void 0 ? void 0 : discount.isEditMode;
691
+ currentCommittedDiscounts = currentDiscountList.filter(function (discount) {
692
+ var _discount$committedAp;
693
+ return (discount === null || discount === void 0 ? void 0 : discount.isEditMode) || (discount === null || discount === void 0 || (_discount$committedAp = discount.committedAppliedProductDetails) === null || _discount$committedAp === void 0 ? void 0 : _discount$committedAp.length);
611
694
  });
612
695
  currentScanDiscounts = currentDiscountList.filter(function (discount) {
613
696
  return discount === null || discount === void 0 ? void 0 : discount.isScan;
614
697
  });
615
- currentScanDiscountIds = new Set(currentScanDiscounts.map(function (discount) {
616
- return discount === null || discount === void 0 ? void 0 : discount.id;
698
+ currentScanDiscountById = new Map(currentScanDiscounts.flatMap(function (discount) {
699
+ var id = getDiscountIdentityKey(discount);
700
+ return id === null ? [] : [[id, discount]];
701
+ }));
702
+ committedDiscountById = new Map(currentCommittedDiscounts.flatMap(function (discount) {
703
+ var id = getDiscountIdentityKey(discount);
704
+ return id === null ? [] : [[id, discount]];
617
705
  }));
706
+ mergedCommittedDiscountIds = new Set();
707
+ refreshedScanDiscountIds = new Set();
618
708
  runtimeDiscountIds = new Set();
619
- runtimeDiscounts = discountList.filter(function (discount) {
620
- if (currentScanDiscountIds.has(discount === null || discount === void 0 ? void 0 : discount.id)) return false;
621
- if (runtimeDiscountIds.has(discount === null || discount === void 0 ? void 0 : discount.id)) return false;
622
- runtimeDiscountIds.add(discount === null || discount === void 0 ? void 0 : discount.id);
623
- return true;
709
+ runtimeDiscounts = discountList.flatMap(function (discount) {
710
+ var id = getDiscountIdentityKey(discount);
711
+ if (id === null) return [discount];
712
+ if (runtimeDiscountIds.has(id)) return [];
713
+ runtimeDiscountIds.add(id);
714
+ var currentScanDiscount = currentScanDiscountById.get(id);
715
+ if (currentScanDiscount && (!isEntitlementPass(currentScanDiscount) || !isEntitlementPass(discount))) {
716
+ return [];
717
+ }
718
+ var committedDiscount = committedDiscountById.get(id);
719
+ var nextDiscount = discount;
720
+ if (committedDiscount && isEntitlementPass(committedDiscount) && isEntitlementPass(discount)) {
721
+ mergedCommittedDiscountIds.add(id);
722
+ nextDiscount = mergeCommittedEntitlementWithRuntime(committedDiscount, discount);
723
+ }
724
+ if (currentScanDiscount) {
725
+ var _currentScanDiscount$, _currentScanDiscount$2;
726
+ refreshedScanDiscountIds.add(id);
727
+ nextDiscount = _objectSpread(_objectSpread({}, nextDiscount), {}, {
728
+ isScan: true,
729
+ isSelected: (_currentScanDiscount$ = currentScanDiscount.isSelected) !== null && _currentScanDiscount$ !== void 0 ? _currentScanDiscount$ : nextDiscount.isSelected,
730
+ isManualSelect: (_currentScanDiscount$2 = currentScanDiscount.isManualSelect) !== null && _currentScanDiscount$2 !== void 0 ? _currentScanDiscount$2 : nextDiscount.isManualSelect
731
+ });
732
+ }
733
+ return [nextDiscount];
734
+ });
735
+ retainedCommittedDiscounts = currentCommittedDiscounts.filter(function (discount) {
736
+ var id = getDiscountIdentityKey(discount);
737
+ return id === null || !mergedCommittedDiscountIds.has(id);
738
+ }).map(function (discount) {
739
+ var _discount$committedAp2;
740
+ return (_discount$committedAp2 = discount.committedAppliedProductDetails) !== null && _discount$committedAp2 !== void 0 && _discount$committedAp2.length ? _objectSpread(_objectSpread({}, discount), {}, {
741
+ isEditMode: true,
742
+ isDisabled: true,
743
+ isSelected: true,
744
+ isUsed: true,
745
+ appliedProductDetails: _toConsumableArray(discount.committedAppliedProductDetails)
746
+ }) : discount;
747
+ });
748
+ retainedScanDiscounts = currentScanDiscounts.filter(function (discount) {
749
+ var id = getDiscountIdentityKey(discount);
750
+ return id === null || !refreshedScanDiscountIds.has(id);
624
751
  });
625
- mergedDiscountList = [].concat(_toConsumableArray(currentEditDiscounts), _toConsumableArray(currentScanDiscounts), _toConsumableArray(runtimeDiscounts));
626
- _context3.next = 18;
752
+ mergedDiscountList = [].concat(_toConsumableArray(retainedCommittedDiscounts), _toConsumableArray(retainedScanDiscounts), _toConsumableArray(runtimeDiscounts));
753
+ if (isCurrentRequest()) {
754
+ _context3.next = 26;
755
+ break;
756
+ }
757
+ return _context3.abrupt("return", this.getDiscountList());
758
+ case 26:
759
+ _context3.next = 28;
627
760
  return (_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.setOriginalDiscountList(mergedDiscountList);
628
- case 18:
629
- _context3.next = 20;
761
+ case 28:
762
+ if (isCurrentRequest()) {
763
+ _context3.next = 30;
764
+ break;
765
+ }
766
+ return _context3.abrupt("return", this.getDiscountList());
767
+ case 30:
768
+ _context3.next = 32;
630
769
  return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.setDiscountList(mergedDiscountList);
631
- case 20:
770
+ case 32:
771
+ if (isCurrentRequest()) {
772
+ _context3.next = 34;
773
+ break;
774
+ }
775
+ return _context3.abrupt("return", this.getDiscountList());
776
+ case 34:
632
777
  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) {
633
778
  this.applyDiscount();
634
779
  }
635
780
  return _context3.abrupt("return", this.getDiscountList());
636
- case 22:
781
+ case 36:
637
782
  case "end":
638
783
  return _context3.stop();
639
784
  }
@@ -660,6 +805,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
660
805
  value: function getVirtualCurrencyList() {
661
806
  return cloneDeep(this.store.virtualCurrencyList || []);
662
807
  }
808
+ }, {
809
+ key: "getCustomerWalletPrepareConfigEpoch",
810
+ value: function getCustomerWalletPrepareConfigEpoch() {
811
+ return this.customerWalletPrepareConfigEpoch;
812
+ }
663
813
  }, {
664
814
  key: "syncScannedDiscountsToOriginalDiscountList",
665
815
  value: function () {
@@ -702,13 +852,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
702
852
  key: "ensureEditDiscountConfigForProductChange",
703
853
  value: function () {
704
854
  var _ensureEditDiscountConfigForProductChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(tempOrder) {
705
- var _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _this$store$discount10;
855
+ var _tempOrder$customer, _tempOrder$_extend2, _tempOrder$_extend3, _this$store$discount10;
706
856
  var orderId, customerId, currentDiscountList, hasRuntimeDiscounts;
707
857
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
708
858
  while (1) switch (_context5.prev = _context5.next) {
709
859
  case 0:
710
860
  orderId = tempOrder.order_id;
711
- 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);
861
+ customerId = Number(tempOrder.customer_id || ((_tempOrder$customer = tempOrder.customer) === null || _tempOrder$customer === void 0 ? void 0 : _tempOrder$customer.id) || ((_tempOrder$_extend2 = tempOrder._extend) === null || _tempOrder$_extend2 === void 0 || (_tempOrder$_extend2 = _tempOrder$_extend2.customerSnapshot) === null || _tempOrder$_extend2 === void 0 ? void 0 : _tempOrder$_extend2.id) || ((_tempOrder$_extend3 = tempOrder._extend) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3.customerSnapshot) === null || _tempOrder$_extend3 === void 0 ? void 0 : _tempOrder$_extend3.customer_id) || 0);
712
862
  if (!(!orderId || !customerId || customerId === 1)) {
713
863
  _context5.next = 4;
714
864
  break;
@@ -748,7 +898,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
748
898
  value: function () {
749
899
  var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(code, customerId) {
750
900
  var _this$store$discount11, _tempOrder$holder, _this$store$summary;
751
- var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref12, isAvailable, newDiscountList, evaluatedDiscountList, unavailableReason, shouldRetainForLater, normalizedNewDiscountList, retainedDiscountList, resolvedDiscountList, _this$store$discount12, _this$store$discount13;
901
+ var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref16, isAvailable, newDiscountList, evaluatedDiscountList, unavailableReason, scannedIds, evaluatedScannedDiscounts, shouldRetainForLater, normalizedNewDiscountList, resolvedDiscountList, _this$store$discount12, _this$store$discount13, retainedDiscounts;
752
902
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
753
903
  while (1) switch (_context6.prev = _context6.next) {
754
904
  case 0:
@@ -838,7 +988,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
838
988
  case 20:
839
989
  tempOrder = this.store.tempOrder;
840
990
  holders = (tempOrder === null || tempOrder === void 0 || (_tempOrder$holder = tempOrder.holder) === null || _tempOrder$holder === void 0 ? void 0 : _tempOrder$holder.form_record) || [];
841
- _ref12 = rulesModule.isDiscountListAvailable({
991
+ _ref16 = rulesModule.isDiscountListAvailable({
842
992
  productList: (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || [],
843
993
  oldDiscountList: this.getDiscountList(),
844
994
  newDiscountList: withScanList,
@@ -850,47 +1000,73 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
850
1000
  }) || {
851
1001
  isAvailable: false,
852
1002
  discountList: this.getDiscountList()
853
- }, isAvailable = _ref12.isAvailable, newDiscountList = _ref12.discountList, evaluatedDiscountList = _ref12.evaluatedDiscountList, unavailableReason = _ref12.unavailableReason;
854
- shouldRetainForLater = !isAvailable && unavailableReason === UnavailableReason.ProductNotApplicable && withScanList.some(isCustomerPromotionDiscount);
1003
+ }, isAvailable = _ref16.isAvailable, newDiscountList = _ref16.discountList, evaluatedDiscountList = _ref16.evaluatedDiscountList, unavailableReason = _ref16.unavailableReason;
1004
+ scannedIds = new Set(withScanList.map(function (discount) {
1005
+ return String(discount.id);
1006
+ }));
1007
+ evaluatedScannedDiscounts = (evaluatedDiscountList || withScanList).filter(function (discount) {
1008
+ return scannedIds.has(String(discount.id)) && isCustomerPromotionDiscount(discount) && !getDiscountLifecycleReason(discount);
1009
+ });
1010
+ shouldRetainForLater = !isAvailable && evaluatedScannedDiscounts.length > 0;
855
1011
  normalizedNewDiscountList = newDiscountList ? markScannedDiscounts(newDiscountList, withScanList) : undefined;
856
- retainedDiscountList = evaluatedDiscountList ? markScannedDiscounts(evaluatedDiscountList, withScanList) : normalizedNewDiscountList;
857
1012
  resolvedDiscountList = normalizedNewDiscountList || this.getDiscountList();
858
1013
  if (!(isAvailable && normalizedNewDiscountList)) {
859
- _context6.next = 36;
1014
+ _context6.next = 37;
860
1015
  break;
861
1016
  }
862
- _context6.next = 30;
1017
+ _context6.next = 31;
863
1018
  return (_this$store$discount12 = this.store.discount) === null || _this$store$discount12 === void 0 ? void 0 : _this$store$discount12.setDiscountList(normalizedNewDiscountList);
864
- case 30:
865
- this.applyDiscount();
866
- _context6.next = 33;
1019
+ case 31:
1020
+ // 实际写回商品时沿用扫码试算的优先级,避免旧商品行的选卡覆盖本次扫码。
1021
+ this.applyDiscount({
1022
+ preferredEntitlementPassIds: withScanList.filter(function (discount) {
1023
+ return isEntitlementPass(discount);
1024
+ }).map(function (discount) {
1025
+ return discount.id;
1026
+ })
1027
+ });
1028
+ _context6.next = 34;
867
1029
  return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
868
- case 33:
1030
+ case 34:
869
1031
  resolvedDiscountList = this.getDiscountList();
870
- _context6.next = 42;
1032
+ _context6.next = 45;
871
1033
  break;
872
- case 36:
873
- if (!(shouldRetainForLater && retainedDiscountList)) {
874
- _context6.next = 42;
1034
+ case 37:
1035
+ if (!shouldRetainForLater) {
1036
+ _context6.next = 45;
875
1037
  break;
876
1038
  }
877
- _context6.next = 39;
878
- return (_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.setDiscountList(retainedDiscountList);
879
- case 39:
880
- _context6.next = 41;
1039
+ // 只合并本次识别的卡券;不把试算产生的其他选券状态写回订单。
1040
+ retainedDiscounts = new Map(this.getDiscountList().map(function (discount) {
1041
+ return [String(discount.id), discount];
1042
+ }));
1043
+ evaluatedScannedDiscounts.forEach(function (discount) {
1044
+ retainedDiscounts.set(String(discount.id), _objectSpread(_objectSpread({}, discount), {}, {
1045
+ isScan: true,
1046
+ isAvailable: false,
1047
+ isSelected: false,
1048
+ reasonCode: discount.reasonCode || 'product_not_applicable',
1049
+ appliedProductDetails: [],
1050
+ savedAmount: 0
1051
+ }));
1052
+ });
1053
+ _context6.next = 42;
1054
+ return (_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.setDiscountList(_toConsumableArray(retainedDiscounts.values()));
1055
+ case 42:
1056
+ _context6.next = 44;
881
1057
  return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
882
- case 41:
1058
+ case 44:
883
1059
  resolvedDiscountList = this.getDiscountList();
884
- case 42:
1060
+ case 45:
885
1061
  return _context6.abrupt("return", {
886
1062
  type: 'clientCalc',
887
1063
  isAvailable: isAvailable || false,
888
1064
  isAccepted: Boolean(isAvailable || shouldRetainForLater),
889
1065
  discountList: resolvedDiscountList,
890
- scannedDiscountList: resultDiscountList,
1066
+ scannedDiscountList: evaluatedScannedDiscounts,
891
1067
  unavailableReason: unavailableReason
892
1068
  });
893
- case 43:
1069
+ case 46:
894
1070
  case "end":
895
1071
  return _context6.stop();
896
1072
  }
@@ -906,7 +1082,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
906
1082
  value: function applyDiscount(options) {
907
1083
  var _this$store$discount16,
908
1084
  _this$store$summary2,
909
- _this2 = this;
1085
+ _this4 = this;
910
1086
  var tempOrder = this.store.tempOrder;
911
1087
  // 任意 products CRUD 后都应当重算 discount 状态;即使 products 为空,
912
1088
  // 也需要让 Rules.calcDiscount 把 DiscountModule 的 isSelected / isAvailable /
@@ -938,14 +1114,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
938
1114
  orderTotalAmount: Number(((_this$store$summary2 = this.store.summary) === null || _this$store$summary2 === void 0 ? void 0 : _this$store$summary2.total_amount) || 0)
939
1115
  }, {
940
1116
  reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids,
941
- reapplyWeighedDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyWeighedDiscountProductUids
1117
+ reapplyWeighedDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyWeighedDiscountProductUids,
1118
+ preferredEntitlementPassIds: options === null || options === void 0 ? void 0 : options.preferredEntitlementPassIds
942
1119
  });
943
1120
  if (result !== null && result !== void 0 && result.productList) {
944
1121
  var previousProductsByUid = indexOrderProductsByUid(tempOrder.products);
945
1122
  tempOrder.products = this.applyProductDiscountPrices((result.productList || []).map(function (product, index) {
946
- var _ref13;
1123
+ var _ref17;
947
1124
  var uid = getOrderProductLineUid(product);
948
- var previous = (_ref13 = uid ? previousProductsByUid.get(uid) : undefined) !== null && _ref13 !== void 0 ? _ref13 : previousProductsByUid.get("__index__:".concat(index));
1125
+ var previous = (_ref17 = uid ? previousProductsByUid.get(uid) : undefined) !== null && _ref17 !== void 0 ? _ref17 : previousProductsByUid.get("__index__:".concat(index));
949
1126
  if (isManualProductDiscountProduct(previous)) {
950
1127
  return previous;
951
1128
  }
@@ -963,7 +1140,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
963
1140
  (_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 || _this$store$discount17.setDiscountList(result.discountList);
964
1141
  }
965
1142
  this.hasActiveCustomerBoundDiscount = (tempOrder.products || []).some(function (product) {
966
- return _this2.productHasCustomerBoundDiscount(product);
1143
+ return _this4.productHasCustomerBoundDiscount(product);
967
1144
  });
968
1145
  }
969
1146
 
@@ -1026,7 +1203,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1026
1203
  var _evaluatePromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
1027
1204
  var _this$promotionEvalua,
1028
1205
  _this$promotionEvalua2,
1029
- _this3 = this;
1206
+ _this5 = this;
1030
1207
  var tempOrder, strategyConfigs, result, removeSet, _iterator3, _step3, reduce, _iterator6, _step6, _loop2, _iterator4, _step4, _loop, payload;
1031
1208
  return _regeneratorRuntime().wrap(function _callee7$(_context9) {
1032
1209
  while (1) switch (_context9.prev = _context9.next) {
@@ -1185,7 +1362,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1185
1362
  case 6:
1186
1363
  _context7.prev = 6;
1187
1364
  _context7.next = 9;
1188
- return _this3.giftSelectResolver({
1365
+ return _this5.giftSelectResolver({
1189
1366
  strategyId: addAction.strategyId,
1190
1367
  strategyName: addAction.strategyName,
1191
1368
  giftCount: addAction.giftCount,
@@ -1220,7 +1397,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1220
1397
  _context7.next = 26;
1221
1398
  break;
1222
1399
  }
1223
- linked = _this3.createLinkedProductAndBooking({
1400
+ linked = _this5.createLinkedProductAndBooking({
1224
1401
  product: gp,
1225
1402
  booking: booking
1226
1403
  });
@@ -1520,12 +1697,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1520
1697
  });
1521
1698
  }
1522
1699
  }, {
1523
- key: "clearTempOrderPointCardSnapshot",
1524
- value: function clearTempOrderPointCardSnapshot(tempOrder) {
1700
+ key: "clearTempOrderCustomerWalletSnapshots",
1701
+ value: function clearTempOrderCustomerWalletSnapshots(tempOrder) {
1525
1702
  var orderMetaList = normalizeOrderMetaList(tempOrder.order_meta_list);
1526
1703
  if (!orderMetaList) return;
1527
1704
  var nextOrderMetaList = _objectSpread({}, orderMetaList);
1528
1705
  delete nextOrderMetaList.point_cards_snapshot;
1706
+ delete nextOrderMetaList.virtual_currency_snapshot;
1529
1707
  if (Object.keys(nextOrderMetaList).length === 0) {
1530
1708
  delete tempOrder.order_meta_list;
1531
1709
  return;
@@ -1533,19 +1711,115 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1533
1711
  tempOrder.order_meta_list = nextOrderMetaList;
1534
1712
  }
1535
1713
  }, {
1536
- key: "writePointCardSnapshotFromPrepareConfig",
1537
- value: function writePointCardSnapshotFromPrepareConfig(params) {
1538
- var _tempOrder$customer_i, _params$orderId;
1714
+ key: "clearCustomerWalletState",
1715
+ value: function clearCustomerWalletState(tempOrder) {
1716
+ this.clearCustomerWalletRuntimeState();
1717
+ this.clearTempOrderCustomerWalletSnapshots(tempOrder);
1718
+ }
1719
+ }, {
1720
+ key: "clearCustomerWalletRuntimeState",
1721
+ value: function clearCustomerWalletRuntimeState() {
1722
+ this.customerWalletPrepareConfigEpoch += 1;
1723
+ this.pointCardSnapshotCodeCandidates.clear();
1724
+ this.store.availableWalletIds = [];
1725
+ this.store.virtualCurrencyList = [];
1726
+ }
1727
+ }, {
1728
+ key: "rememberPointCardSnapshotCodeCandidates",
1729
+ value: function rememberPointCardSnapshotCodeCandidates(value) {
1730
+ var _this6 = this;
1731
+ collectPointCardSnapshotCodeCandidates(value).forEach(function (_ref18) {
1732
+ var id = _ref18.id,
1733
+ code = _ref18.code;
1734
+ if (!_this6.pointCardSnapshotCodeCandidates.has(id)) {
1735
+ _this6.pointCardSnapshotCodeCandidates.set(id, code);
1736
+ }
1737
+ });
1738
+ }
1739
+ }, {
1740
+ key: "getRememberedPointCardSnapshotCodeCandidates",
1741
+ value: function getRememberedPointCardSnapshotCodeCandidates() {
1742
+ return _toConsumableArray(this.pointCardSnapshotCodeCandidates).map(function (_ref19) {
1743
+ var _ref20 = _slicedToArray(_ref19, 2),
1744
+ id = _ref20[0],
1745
+ code = _ref20[1];
1746
+ return {
1747
+ id: id,
1748
+ code: code
1749
+ };
1750
+ });
1751
+ }
1752
+ }, {
1753
+ key: "getPointCardSnapshotOrderIdentityKey",
1754
+ value: function getPointCardSnapshotOrderIdentityKey(identity) {
1755
+ if (identity !== null && identity !== void 0 && identity.externalSaleNumber) {
1756
+ return "external:".concat(identity.externalSaleNumber);
1757
+ }
1758
+ if ((identity === null || identity === void 0 ? void 0 : identity.orderId) !== undefined && identity.orderId !== null) {
1759
+ return "order:".concat(identity.orderId);
1760
+ }
1761
+ if (identity !== null && identity !== void 0 && identity.localId) return "local:".concat(identity.localId);
1762
+ if (identity !== null && identity !== void 0 && identity.orderNumber) return "number:".concat(identity.orderNumber);
1763
+ return '';
1764
+ }
1765
+ }, {
1766
+ key: "isPointCardSnapshotMergeContextCurrent",
1767
+ value: function isPointCardSnapshotMergeContextCurrent(context) {
1768
+ var _context$customerId, _this$store$tempOrder4, _this$store$tempOrder5;
1769
+ if (!context) return true;
1770
+ if (context.customerId !== undefined && String((_context$customerId = context.customerId) !== null && _context$customerId !== void 0 ? _context$customerId : '') !== String((_this$store$tempOrder4 = (_this$store$tempOrder5 = this.store.tempOrder) === null || _this$store$tempOrder5 === void 0 ? void 0 : _this$store$tempOrder5.customer_id) !== null && _this$store$tempOrder4 !== void 0 ? _this$store$tempOrder4 : '')) {
1771
+ return false;
1772
+ }
1773
+ var expectedOrderKey = this.getPointCardSnapshotOrderIdentityKey(context.orderIdentity);
1774
+ return !expectedOrderKey || expectedOrderKey === this.getPointCardSnapshotOrderIdentityKey(this.getOrderIdentity());
1775
+ }
1776
+ }, {
1777
+ key: "writeCustomerWalletSnapshotsFromPrepareConfig",
1778
+ value: function writeCustomerWalletSnapshotsFromPrepareConfig(params) {
1779
+ var _tempOrder$customer_i;
1539
1780
  var tempOrder = this.store.tempOrder;
1540
1781
  if (!tempOrder) return;
1541
1782
  if (String((_tempOrder$customer_i = tempOrder.customer_id) !== null && _tempOrder$customer_i !== void 0 ? _tempOrder$customer_i : '') !== String(params.customerId)) return;
1542
- var effectiveOrderId = (_params$orderId = params.orderId) !== null && _params$orderId !== void 0 ? _params$orderId : tempOrder.order_id;
1543
- if (hasPersistedOrderId(effectiveOrderId)) return;
1544
- tempOrder.order_meta_list = _objectSpread(_objectSpread({}, normalizeOrderMetaList(tempOrder.order_meta_list) || {}), {}, {
1545
- point_cards_snapshot: buildPointCardSnapshotFromWalletPassList(params.availableWalletPassList)
1783
+ var currentOrderMetaList = normalizeOrderMetaList(tempOrder.order_meta_list);
1784
+ var virtualCurrencyList = Array.isArray(params.virtualCurrencyList) ? params.virtualCurrencyList : [];
1785
+ var snapshotsWithExistingCodes = _mergePointCardSnapshotCodes(params.availableWalletPassList, currentOrderMetaList === null || currentOrderMetaList === void 0 ? void 0 : currentOrderMetaList.point_cards_snapshot);
1786
+ tempOrder.order_meta_list = _objectSpread(_objectSpread({}, currentOrderMetaList || {}), {}, {
1787
+ point_cards_snapshot: _mergePointCardSnapshotCodes(snapshotsWithExistingCodes, this.getRememberedPointCardSnapshotCodeCandidates()),
1788
+ virtual_currency_snapshot: buildVirtualCurrencySnapshotFromList(virtualCurrencyList)
1789
+ });
1790
+ this.store.availableWalletIds = _toConsumableArray(params.availableWalletIds);
1791
+ this.store.virtualCurrencyList = cloneDeep(virtualCurrencyList);
1792
+ this.persistTempOrder();
1793
+ this.saveDraftInBackground();
1794
+ }
1795
+
1796
+ /**
1797
+ * 将 Payment WalletPass 返回的实例 code 回填到当前订单 Snapshot。
1798
+ * 这里只按资产 ID 补空值,不新增卡、不覆盖 prepare/config 冻结的余额。
1799
+ */
1800
+ }, {
1801
+ key: "mergePointCardSnapshotCodes",
1802
+ value: function mergePointCardSnapshotCodes(walletPassList, context) {
1803
+ var tempOrder = this.store.tempOrder;
1804
+ var currentOrderMetaList = normalizeOrderMetaList(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.order_meta_list);
1805
+ var currentSnapshots = (currentOrderMetaList === null || currentOrderMetaList === void 0 ? void 0 : currentOrderMetaList.point_cards_snapshot) || [];
1806
+ if (!tempOrder || !this.isPointCardSnapshotMergeContextCurrent(context)) {
1807
+ return currentSnapshots;
1808
+ }
1809
+ this.rememberPointCardSnapshotCodeCandidates(walletPassList);
1810
+ if (!currentSnapshots.length) return currentSnapshots;
1811
+ var nextSnapshots = _mergePointCardSnapshotCodes(currentSnapshots, this.getRememberedPointCardSnapshotCodeCandidates());
1812
+ var hasChanged = nextSnapshots.some(function (snapshot, index) {
1813
+ var _currentSnapshots$ind;
1814
+ return snapshot.code !== ((_currentSnapshots$ind = currentSnapshots[index]) === null || _currentSnapshots$ind === void 0 ? void 0 : _currentSnapshots$ind.code);
1815
+ });
1816
+ if (!hasChanged) return currentSnapshots;
1817
+ tempOrder.order_meta_list = _objectSpread(_objectSpread({}, currentOrderMetaList || {}), {}, {
1818
+ point_cards_snapshot: nextSnapshots
1546
1819
  });
1547
1820
  this.persistTempOrder();
1548
1821
  this.saveDraftInBackground();
1822
+ return nextSnapshots;
1549
1823
  }
1550
1824
  }, {
1551
1825
  key: "createExternalSaleNumber",
@@ -1647,15 +1921,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1647
1921
  }, {
1648
1922
  key: "extractOrderIdFromSubmitResult",
1649
1923
  value: function extractOrderIdFromSubmitResult(result) {
1650
- var _ref14, _ref15, _ref16, _result$data$order_id, _result$data, _result$data2;
1651
- return (_ref14 = (_ref15 = (_ref16 = (_result$data$order_id = result === null || result === void 0 || (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.order_id) !== null && _result$data$order_id !== void 0 ? _result$data$order_id : result === null || result === void 0 ? void 0 : result.order_id) !== null && _ref16 !== void 0 ? _ref16 : result === null || result === void 0 || (_result$data2 = result.data) === null || _result$data2 === void 0 ? void 0 : _result$data2.id) !== null && _ref15 !== void 0 ? _ref15 : result === null || result === void 0 ? void 0 : result.id) !== null && _ref14 !== void 0 ? _ref14 : null;
1924
+ var _ref21, _ref22, _ref23, _result$data$order_id, _result$data, _result$data2;
1925
+ return (_ref21 = (_ref22 = (_ref23 = (_result$data$order_id = result === null || result === void 0 || (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.order_id) !== null && _result$data$order_id !== void 0 ? _result$data$order_id : result === null || result === void 0 ? void 0 : result.order_id) !== null && _ref23 !== void 0 ? _ref23 : result === null || result === void 0 || (_result$data2 = result.data) === null || _result$data2 === void 0 ? void 0 : _result$data2.id) !== null && _ref22 !== void 0 ? _ref22 : result === null || result === void 0 ? void 0 : result.id) !== null && _ref21 !== void 0 ? _ref21 : null;
1652
1926
  }
1653
1927
  }, {
1654
1928
  key: "calculatePaymentEffectiveAmount",
1655
1929
  value: function calculatePaymentEffectiveAmount(payment) {
1656
- var _ref17, _payment$origin_amoun;
1930
+ var _ref24, _payment$origin_amoun;
1657
1931
  var amount = new Decimal(payment.amount || 0);
1658
- var originAmount = new Decimal((_ref17 = (_payment$origin_amoun = payment.origin_amount) !== null && _payment$origin_amoun !== void 0 ? _payment$origin_amoun : payment.amount) !== null && _ref17 !== void 0 ? _ref17 : 0);
1932
+ var originAmount = new Decimal((_ref24 = (_payment$origin_amoun = payment.origin_amount) !== null && _payment$origin_amoun !== void 0 ? _payment$origin_amoun : payment.amount) !== null && _ref24 !== void 0 ? _ref24 : 0);
1659
1933
  var serviceFee = new Decimal(payment.service_fee || 0);
1660
1934
  // TODO: 后端允许 amount 表示顾客实际支付总额后,移除这个兼容分支。
1661
1935
  var effectiveAmount = serviceFee.gt(0) && amount.eq(originAmount) ? amount.plus(serviceFee) : amount;
@@ -1665,23 +1939,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1665
1939
  }, {
1666
1940
  key: "calculatePaymentTotal",
1667
1941
  value: function calculatePaymentTotal(payments) {
1668
- var _this4 = this;
1942
+ var _this7 = this;
1669
1943
  return mapPaymentItemsToOrderPayments(payments, {
1670
1944
  includeVoided: false
1671
1945
  }).reduce(function (sum, payment) {
1672
1946
  if (!isPaidPaymentRecord(payment)) return sum;
1673
- return sum.plus(_this4.calculatePaymentEffectiveAmount(payment));
1947
+ return sum.plus(_this7.calculatePaymentEffectiveAmount(payment));
1674
1948
  }, new Decimal(0));
1675
1949
  }
1676
1950
  }, {
1677
1951
  key: "calculateOrderPaidPaymentTotal",
1678
1952
  value: function calculateOrderPaidPaymentTotal(payments) {
1679
- var _this5 = this;
1953
+ var _this8 = this;
1680
1954
  return mapPaymentItemsToOrderPayments(payments, {
1681
1955
  includeVoided: false
1682
1956
  }).reduce(function (sum, payment) {
1683
1957
  if (!isPaidPaymentRecord(payment)) return sum;
1684
- return sum.plus(_this5.calculatePaymentGapAmount(payment));
1958
+ return sum.plus(_this8.calculatePaymentGapAmount(payment));
1685
1959
  }, new Decimal(0));
1686
1960
  }
1687
1961
  }, {
@@ -1817,13 +2091,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1817
2091
  }, {
1818
2092
  key: "calculateDepositPaidAmount",
1819
2093
  value: function calculateDepositPaidAmount(payments) {
1820
- var _this6 = this;
2094
+ var _this9 = this;
1821
2095
  return (payments || []).reduce(function (sum, payment) {
1822
2096
  var paymentRecord = payment;
1823
2097
  if (!isPaidPaymentRecord(paymentRecord)) return sum;
1824
2098
  var isDepositPayment = paymentRecord.type === 'deposit' || paymentRecord.order_payment_type === 'deposit';
1825
2099
  if (!isDepositPayment) return sum;
1826
- return sum.plus(_this6.calculatePaymentGapAmount(paymentRecord));
2100
+ return sum.plus(_this9.calculatePaymentGapAmount(paymentRecord));
1827
2101
  }, new Decimal(0));
1828
2102
  }
1829
2103
  }, {
@@ -1860,28 +2134,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1860
2134
  }, {
1861
2135
  key: "getPaymentNumberDevicePrefixSync",
1862
2136
  value: function getPaymentNumberDevicePrefixSync() {
1863
- var _this7 = this;
2137
+ var _this10 = this;
1864
2138
  return resolvePaymentNumberDevicePrefixFromDeviceId(function (key) {
1865
- return _this7.getPaymentNumberAppData(key);
2139
+ return _this10.getPaymentNumberAppData(key);
1866
2140
  });
1867
2141
  }
1868
2142
  }, {
1869
2143
  key: "getPaymentNumberDevicePrefixAsync",
1870
2144
  value: function getPaymentNumberDevicePrefixAsync() {
1871
- var _this8 = this;
2145
+ var _this11 = this;
1872
2146
  return resolvePaymentNumberDevicePrefix(function (key) {
1873
- return _this8.getPaymentNumberAppData(key);
2147
+ return _this11.getPaymentNumberAppData(key);
1874
2148
  });
1875
2149
  }
1876
2150
  }, {
1877
2151
  key: "normalizePaymentSource",
1878
2152
  value: function normalizePaymentSource(payment, options) {
1879
- var _ref18, _paymentRecord$origin;
2153
+ var _ref25, _paymentRecord$origin;
1880
2154
  var paymentRecord = payment;
1881
2155
  var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
1882
2156
  var normalized = ensureOrderPaymentNumber(_objectSpread(_objectSpread({}, paymentRecord), {}, {
1883
2157
  metadata: metadata,
1884
- origin_amount: (_ref18 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref18 !== void 0 ? _ref18 : '0.00'
2158
+ origin_amount: (_ref25 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref25 !== void 0 ? _ref25 : '0.00'
1885
2159
  }), (options === null || options === void 0 ? void 0 : options.devicePrefix) || this.getPaymentNumberDevicePrefixSync(), createUuidV4);
1886
2160
  if (paymentRecord.status !== undefined) {
1887
2161
  normalized.status = paymentRecord.status;
@@ -2000,16 +2274,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2000
2274
  }, {
2001
2275
  key: "calculatePaidPaymentSummary",
2002
2276
  value: function calculatePaidPaymentSummary(payments) {
2003
- var _this9 = this;
2277
+ var _this12 = this;
2004
2278
  return (payments || []).reduce(function (summary, payment) {
2005
2279
  var paymentRecord = payment;
2006
2280
  if (!isPaidPaymentRecord(paymentRecord)) return summary;
2007
2281
  return {
2008
2282
  customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
2009
- orderPaidAmount: summary.orderPaidAmount.plus(_this9.calculatePaymentOrderAmount(paymentRecord)),
2010
- gapPaidAmount: summary.gapPaidAmount.plus(_this9.calculatePaymentGapAmount(paymentRecord)),
2011
- payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this9.calculatePaymentServiceFee(paymentRecord)),
2012
- roundingAmount: summary.roundingAmount.plus(_this9.calculatePaymentRoundingAmount(paymentRecord))
2283
+ orderPaidAmount: summary.orderPaidAmount.plus(_this12.calculatePaymentOrderAmount(paymentRecord)),
2284
+ gapPaidAmount: summary.gapPaidAmount.plus(_this12.calculatePaymentGapAmount(paymentRecord)),
2285
+ payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this12.calculatePaymentServiceFee(paymentRecord)),
2286
+ roundingAmount: summary.roundingAmount.plus(_this12.calculatePaymentRoundingAmount(paymentRecord))
2013
2287
  };
2014
2288
  }, {
2015
2289
  customerPaidAmount: new Decimal(0),
@@ -2216,15 +2490,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2216
2490
  }, {
2217
2491
  key: "normalizeFingerprintValue",
2218
2492
  value: function normalizeFingerprintValue(value) {
2219
- var _this10 = this;
2493
+ var _this13 = this;
2220
2494
  if (Array.isArray(value)) {
2221
2495
  return value.map(function (item) {
2222
- return _this10.normalizeFingerprintValue(item);
2496
+ return _this13.normalizeFingerprintValue(item);
2223
2497
  });
2224
2498
  }
2225
2499
  if (!value || _typeof(value) !== 'object') return value !== null && value !== void 0 ? value : '';
2226
2500
  return Object.keys(value).sort().reduce(function (result, key) {
2227
- result[key] = _this10.normalizeFingerprintValue(value[key]);
2501
+ result[key] = _this13.normalizeFingerprintValue(value[key]);
2228
2502
  return result;
2229
2503
  }, {});
2230
2504
  }
@@ -2237,16 +2511,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2237
2511
  _product$payment_pric,
2238
2512
  _sku$code,
2239
2513
  _sku$barcode,
2240
- _ref19,
2514
+ _ref26,
2241
2515
  _sku$variant_id,
2242
- _this11 = this;
2516
+ _this14 = this;
2243
2517
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
2244
2518
  var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
2245
2519
  var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
2246
2520
  var _discount$type;
2247
2521
  return (_discount$type = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type !== void 0 ? _discount$type : discount === null || discount === void 0 ? void 0 : discount.tag;
2248
2522
  });
2249
- var extensionType = (product === null || product === void 0 ? void 0 : product.extension_type) || (discountTypes.includes('good_pass') ? 'good_pass' : 'normal');
2523
+ var fullCoveragePassType = discountTypes.find(function (type) {
2524
+ return ['entitlement_pass', 'good_pass'].includes(type);
2525
+ });
2526
+ var extensionType = (product === null || product === void 0 ? void 0 : product.extension_type) || fullCoveragePassType || 'normal';
2250
2527
  return {
2251
2528
  product_id: (_product$product_id2 = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : null,
2252
2529
  product_variant_id: (_product$product_vari = product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : null,
@@ -2264,37 +2541,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2264
2541
  product_sku: this.normalizeFingerprintValue({
2265
2542
  code: (_sku$code = sku.code) !== null && _sku$code !== void 0 ? _sku$code : '',
2266
2543
  barcode: (_sku$barcode = sku.barcode) !== null && _sku$barcode !== void 0 ? _sku$barcode : '',
2267
- variant_id: (_ref19 = (_sku$variant_id = sku.variant_id) !== null && _sku$variant_id !== void 0 ? _sku$variant_id : product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _ref19 !== void 0 ? _ref19 : 0,
2544
+ variant_id: (_ref26 = (_sku$variant_id = sku.variant_id) !== null && _sku$variant_id !== void 0 ? _sku$variant_id : product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _ref26 !== void 0 ? _ref26 : 0,
2268
2545
  variant: sku.variant || [],
2269
2546
  option: getProductSkuOptions(product || {}).map(function (option) {
2270
- var _ref20, _option$id, _option$option_group_, _ref21, _option$option_group_2, _option$num, _option$add_price;
2547
+ var _ref27, _option$id, _option$option_group_, _ref28, _option$option_group_2, _option$num, _option$add_price;
2271
2548
  return {
2272
- id: (_ref20 = (_option$id = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id !== void 0 ? _option$id : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref20 !== void 0 ? _ref20 : null,
2549
+ id: (_ref27 = (_option$id = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id !== void 0 ? _option$id : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref27 !== void 0 ? _ref27 : null,
2273
2550
  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,
2274
- option_group_item_id: (_ref21 = (_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 && _ref21 !== void 0 ? _ref21 : null,
2551
+ option_group_item_id: (_ref28 = (_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 && _ref28 !== void 0 ? _ref28 : null,
2275
2552
  num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
2276
- add_price: _this11.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)
2553
+ add_price: _this14.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)
2277
2554
  };
2278
2555
  })
2279
2556
  }),
2280
2557
  product_bundle: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.product_bundle) || []).map(function (bundle) {
2281
- var _ref22, _ref23, _bundle$bundle_produc, _ref24, _bundle$bundle_varian, _bundle$num, _bundle$price_type, _bundle$price_type_ex;
2558
+ var _ref29, _ref30, _bundle$bundle_produc, _ref31, _bundle$bundle_varian, _bundle$num, _bundle$price_type, _bundle$price_type_ex;
2282
2559
  return {
2283
- bundle_product_id: (_ref22 = (_ref23 = (_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 && _ref23 !== void 0 ? _ref23 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref22 !== void 0 ? _ref22 : null,
2284
- bundle_variant_id: (_ref24 = (_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 && _ref24 !== void 0 ? _ref24 : 0,
2560
+ bundle_product_id: (_ref29 = (_ref30 = (_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 && _ref30 !== void 0 ? _ref30 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref29 !== void 0 ? _ref29 : null,
2561
+ bundle_variant_id: (_ref31 = (_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 && _ref31 !== void 0 ? _ref31 : 0,
2285
2562
  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),
2286
- price: _this11.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
2287
- bundle_selling_price: _this11.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
2563
+ price: _this14.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
2564
+ bundle_selling_price: _this14.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
2288
2565
  price_type: (_bundle$price_type = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type !== void 0 ? _bundle$price_type : '',
2289
2566
  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 : ''
2290
2567
  };
2291
2568
  })),
2292
2569
  discount_list: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
2293
- var _ref25, _discount$type2, _ref26, _ref27, _discount$discount_id, _discount$discount;
2570
+ var _ref32, _discount$type2, _ref33, _ref34, _discount$discount_id, _discount$discount;
2294
2571
  return {
2295
- type: (_ref25 = (_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 && _ref25 !== void 0 ? _ref25 : '',
2296
- discount_id: (_ref26 = (_ref27 = (_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 && _ref27 !== void 0 ? _ref27 : discount === null || discount === void 0 || (_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) !== null && _ref26 !== void 0 ? _ref26 : null,
2297
- amount: _this11.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2572
+ type: (_ref32 = (_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 && _ref32 !== void 0 ? _ref32 : '',
2573
+ discount_id: (_ref33 = (_ref34 = (_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 && _ref34 !== void 0 ? _ref34 : discount === null || discount === void 0 || (_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) !== null && _ref33 !== void 0 ? _ref33 : null,
2574
+ amount: _this14.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2298
2575
  };
2299
2576
  }))
2300
2577
  };
@@ -2302,9 +2579,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2302
2579
  }, {
2303
2580
  key: "buildOrderProductsFingerprint",
2304
2581
  value: function buildOrderProductsFingerprint(products) {
2305
- var _this12 = this;
2582
+ var _this15 = this;
2306
2583
  var items = (products || []).map(function (product) {
2307
- return _this12.buildProductFingerprintItem(product);
2584
+ return _this15.buildProductFingerprintItem(product);
2308
2585
  });
2309
2586
  items.sort(function (left, right) {
2310
2587
  return JSON.stringify(left).localeCompare(JSON.stringify(right));
@@ -2317,30 +2594,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2317
2594
  var _product$product_id3,
2318
2595
  _product$product_vari2,
2319
2596
  _product$num2,
2320
- _ref28,
2597
+ _ref35,
2321
2598
  _metadata$unique_iden,
2322
2599
  _metadata$price_overr,
2323
2600
  _metadata$is_manual_d,
2324
2601
  _metadata$product_dis,
2325
2602
  _sku$code2,
2326
2603
  _sku$barcode2,
2327
- _ref29,
2604
+ _ref36,
2328
2605
  _sku$variant_id2,
2329
- _this13 = this;
2606
+ _this16 = this;
2330
2607
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
2331
2608
  var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
2332
2609
  var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
2333
2610
  var _discount$type3;
2334
2611
  return (_discount$type3 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type3 !== void 0 ? _discount$type3 : discount === null || discount === void 0 ? void 0 : discount.tag;
2335
2612
  });
2336
- var extensionType = (product === null || product === void 0 ? void 0 : product.extension_type) || (discountTypes.includes('good_pass') ? 'good_pass' : 'normal');
2613
+ var fullCoveragePassType = discountTypes.find(function (type) {
2614
+ return ['entitlement_pass', 'good_pass'].includes(type);
2615
+ });
2616
+ var extensionType = (product === null || product === void 0 ? void 0 : product.extension_type) || fullCoveragePassType || 'normal';
2337
2617
  return {
2338
2618
  product_id: (_product$product_id3 = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id3 !== void 0 ? _product$product_id3 : null,
2339
2619
  product_variant_id: (_product$product_vari2 = product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _product$product_vari2 !== void 0 ? _product$product_vari2 : null,
2340
2620
  extension_type: extensionType,
2341
2621
  num: getSafeProductNum((_product$num2 = product === null || product === void 0 ? void 0 : product.num) !== null && _product$num2 !== void 0 ? _product$num2 : product === null || product === void 0 ? void 0 : product.product_quantity),
2342
2622
  metadata: {
2343
- unique_identification_number: (_ref28 = (_metadata$unique_iden = metadata.unique_identification_number) !== null && _metadata$unique_iden !== void 0 ? _metadata$unique_iden : product === null || product === void 0 ? void 0 : product.unique_identification_number) !== null && _ref28 !== void 0 ? _ref28 : '',
2623
+ unique_identification_number: (_ref35 = (_metadata$unique_iden = metadata.unique_identification_number) !== null && _metadata$unique_iden !== void 0 ? _metadata$unique_iden : product === null || product === void 0 ? void 0 : product.unique_identification_number) !== null && _ref35 !== void 0 ? _ref35 : '',
2344
2624
  price_override: (_metadata$price_overr = metadata.price_override) !== null && _metadata$price_overr !== void 0 ? _metadata$price_overr : '',
2345
2625
  is_manual_discount: (_metadata$is_manual_d = metadata.is_manual_discount) !== null && _metadata$is_manual_d !== void 0 ? _metadata$is_manual_d : '',
2346
2626
  product_discount_reason: (_metadata$product_dis = metadata.product_discount_reason) !== null && _metadata$product_dis !== void 0 ? _metadata$product_dis : ''
@@ -2348,47 +2628,47 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2348
2628
  product_sku: this.normalizeFingerprintValue({
2349
2629
  code: (_sku$code2 = sku.code) !== null && _sku$code2 !== void 0 ? _sku$code2 : '',
2350
2630
  barcode: (_sku$barcode2 = sku.barcode) !== null && _sku$barcode2 !== void 0 ? _sku$barcode2 : '',
2351
- variant_id: (_ref29 = (_sku$variant_id2 = sku.variant_id) !== null && _sku$variant_id2 !== void 0 ? _sku$variant_id2 : product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _ref29 !== void 0 ? _ref29 : 0,
2631
+ variant_id: (_ref36 = (_sku$variant_id2 = sku.variant_id) !== null && _sku$variant_id2 !== void 0 ? _sku$variant_id2 : product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _ref36 !== void 0 ? _ref36 : 0,
2352
2632
  variant: sku.variant || [],
2353
2633
  option: getProductSkuOptions(product || {}).map(function (option) {
2354
- var _ref30, _option$id2, _option$option_group_3, _ref31, _option$option_group_4, _option$num2, _option$add_price2;
2634
+ var _ref37, _option$id2, _option$option_group_3, _ref38, _option$option_group_4, _option$num2, _option$add_price2;
2355
2635
  return {
2356
- id: (_ref30 = (_option$id2 = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id2 !== void 0 ? _option$id2 : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref30 !== void 0 ? _ref30 : null,
2636
+ id: (_ref37 = (_option$id2 = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id2 !== void 0 ? _option$id2 : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref37 !== void 0 ? _ref37 : null,
2357
2637
  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,
2358
- option_group_item_id: (_ref31 = (_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 && _ref31 !== void 0 ? _ref31 : null,
2638
+ option_group_item_id: (_ref38 = (_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 && _ref38 !== void 0 ? _ref38 : null,
2359
2639
  num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
2360
- add_price: _this13.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)
2640
+ add_price: _this16.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)
2361
2641
  };
2362
2642
  })
2363
2643
  }),
2364
2644
  product_bundle: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.product_bundle) || []).map(function (bundle) {
2365
- var _ref32, _bundle$bundle_id, _ref33, _bundle$bundle_group_, _ref34, _ref35, _bundle$bundle_produc2, _ref36, _bundle$bundle_varian2, _bundle$num2, _bundle$price_type2, _bundle$price_type_ex2;
2645
+ var _ref39, _bundle$bundle_id, _ref40, _bundle$bundle_group_, _ref41, _ref42, _bundle$bundle_produc2, _ref43, _bundle$bundle_varian2, _bundle$num2, _bundle$price_type2, _bundle$price_type_ex2;
2366
2646
  return {
2367
- bundle_id: (_ref32 = (_bundle$bundle_id = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_id) !== null && _bundle$bundle_id !== void 0 ? _bundle$bundle_id : bundle === null || bundle === void 0 ? void 0 : bundle.id) !== null && _ref32 !== void 0 ? _ref32 : null,
2368
- bundle_group_id: (_ref33 = (_bundle$bundle_group_ = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_group_id) !== null && _bundle$bundle_group_ !== void 0 ? _bundle$bundle_group_ : bundle === null || bundle === void 0 ? void 0 : bundle.group_id) !== null && _ref33 !== void 0 ? _ref33 : null,
2369
- bundle_product_id: (_ref34 = (_ref35 = (_bundle$bundle_produc2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref35 !== void 0 ? _ref35 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref34 !== void 0 ? _ref34 : null,
2370
- bundle_variant_id: (_ref36 = (_bundle$bundle_varian2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_variant_id) !== null && _bundle$bundle_varian2 !== void 0 ? _bundle$bundle_varian2 : bundle === null || bundle === void 0 ? void 0 : bundle.product_variant_id) !== null && _ref36 !== void 0 ? _ref36 : 0,
2647
+ bundle_id: (_ref39 = (_bundle$bundle_id = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_id) !== null && _bundle$bundle_id !== void 0 ? _bundle$bundle_id : bundle === null || bundle === void 0 ? void 0 : bundle.id) !== null && _ref39 !== void 0 ? _ref39 : null,
2648
+ bundle_group_id: (_ref40 = (_bundle$bundle_group_ = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_group_id) !== null && _bundle$bundle_group_ !== void 0 ? _bundle$bundle_group_ : bundle === null || bundle === void 0 ? void 0 : bundle.group_id) !== null && _ref40 !== void 0 ? _ref40 : null,
2649
+ bundle_product_id: (_ref41 = (_ref42 = (_bundle$bundle_produc2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref42 !== void 0 ? _ref42 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref41 !== void 0 ? _ref41 : null,
2650
+ bundle_variant_id: (_ref43 = (_bundle$bundle_varian2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_variant_id) !== null && _bundle$bundle_varian2 !== void 0 ? _bundle$bundle_varian2 : bundle === null || bundle === void 0 ? void 0 : bundle.product_variant_id) !== null && _ref43 !== void 0 ? _ref43 : 0,
2371
2651
  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),
2372
2652
  price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
2373
2653
  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 : '',
2374
- option: _this13.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
2375
- var _ref37, _option$id3, _option$option_group_5, _ref38, _option$option_group_6, _option$num3, _option$add_price3;
2654
+ option: _this16.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
2655
+ var _ref44, _option$id3, _option$option_group_5, _ref45, _option$option_group_6, _option$num3, _option$add_price3;
2376
2656
  return {
2377
- id: (_ref37 = (_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 && _ref37 !== void 0 ? _ref37 : null,
2657
+ id: (_ref44 = (_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 && _ref44 !== void 0 ? _ref44 : null,
2378
2658
  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,
2379
- option_group_item_id: (_ref38 = (_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 && _ref38 !== void 0 ? _ref38 : null,
2659
+ option_group_item_id: (_ref45 = (_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 && _ref45 !== void 0 ? _ref45 : null,
2380
2660
  num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
2381
- add_price: _this13.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)
2661
+ add_price: _this16.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)
2382
2662
  };
2383
2663
  }))
2384
2664
  };
2385
2665
  })),
2386
2666
  discount_list: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
2387
- var _ref39, _discount$type4, _ref40, _ref41, _discount$discount_id2, _discount$discount2;
2667
+ var _ref46, _discount$type4, _ref47, _ref48, _discount$discount_id2, _discount$discount2;
2388
2668
  return {
2389
- type: (_ref39 = (_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 && _ref39 !== void 0 ? _ref39 : '',
2390
- discount_id: (_ref40 = (_ref41 = (_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 && _ref41 !== void 0 ? _ref41 : discount === null || discount === void 0 || (_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) !== null && _ref40 !== void 0 ? _ref40 : null,
2391
- amount: _this13.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2669
+ type: (_ref46 = (_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 && _ref46 !== void 0 ? _ref46 : '',
2670
+ discount_id: (_ref47 = (_ref48 = (_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 && _ref48 !== void 0 ? _ref48 : discount === null || discount === void 0 || (_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) !== null && _ref47 !== void 0 ? _ref47 : null,
2671
+ amount: _this16.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2392
2672
  };
2393
2673
  }))
2394
2674
  };
@@ -2396,9 +2676,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2396
2676
  }, {
2397
2677
  key: "buildOrderProductsStructuralFingerprint",
2398
2678
  value: function buildOrderProductsStructuralFingerprint(products) {
2399
- var _this14 = this;
2679
+ var _this17 = this;
2400
2680
  var items = (products || []).map(function (product) {
2401
- return _this14.buildProductStructuralFingerprintItem(product);
2681
+ return _this17.buildProductStructuralFingerprintItem(product);
2402
2682
  });
2403
2683
  items.sort(function (left, right) {
2404
2684
  return JSON.stringify(left).localeCompare(JSON.stringify(right));
@@ -2408,8 +2688,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2408
2688
  }, {
2409
2689
  key: "getManualDepositOverride",
2410
2690
  value: function getManualDepositOverride(tempOrder) {
2411
- var _tempOrder$_extend3;
2412
- var override = (_tempOrder$_extend3 = tempOrder._extend) === null || _tempOrder$_extend3 === void 0 ? void 0 : _tempOrder$_extend3.manualDepositOverride;
2691
+ var _tempOrder$_extend4;
2692
+ var override = (_tempOrder$_extend4 = tempOrder._extend) === null || _tempOrder$_extend4 === void 0 ? void 0 : _tempOrder$_extend4.manualDepositOverride;
2413
2693
  if (!override || _typeof(override) !== 'object') return null;
2414
2694
  if (typeof override.amount !== 'string') return null;
2415
2695
  if (typeof override.productStructuralFingerprint !== 'string') return null;
@@ -2428,16 +2708,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2428
2708
  }, {
2429
2709
  key: "clearManualDepositOverride",
2430
2710
  value: function clearManualDepositOverride(tempOrder) {
2431
- var _tempOrder$_extend4;
2432
- if (!((_tempOrder$_extend4 = tempOrder._extend) !== null && _tempOrder$_extend4 !== void 0 && _tempOrder$_extend4.manualDepositOverride)) return;
2711
+ var _tempOrder$_extend5;
2712
+ if (!((_tempOrder$_extend5 = tempOrder._extend) !== null && _tempOrder$_extend5 !== void 0 && _tempOrder$_extend5.manualDepositOverride)) return;
2433
2713
  tempOrder._extend = _objectSpread({}, tempOrder._extend);
2434
2714
  delete tempOrder._extend.manualDepositOverride;
2435
2715
  }
2436
2716
  }, {
2437
2717
  key: "getOriginalSalesSnapshot",
2438
2718
  value: function getOriginalSalesSnapshot(tempOrder) {
2439
- var _tempOrder$_extend5;
2440
- var snapshot = (_tempOrder$_extend5 = tempOrder._extend) === null || _tempOrder$_extend5 === void 0 ? void 0 : _tempOrder$_extend5.originalSalesSnapshot;
2719
+ var _tempOrder$_extend6;
2720
+ var snapshot = (_tempOrder$_extend6 = tempOrder._extend) === null || _tempOrder$_extend6 === void 0 ? void 0 : _tempOrder$_extend6.originalSalesSnapshot;
2441
2721
  if (!snapshot || _typeof(snapshot) !== 'object') return null;
2442
2722
  if (typeof snapshot.productFingerprint !== 'string') return null;
2443
2723
  return snapshot;
@@ -2641,6 +2921,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2641
2921
  var freshTempOrder = this.createDefaultTempOrderInstance();
2642
2922
  this.ensureExternalSaleNumber(freshTempOrder);
2643
2923
  this.store.tempOrder = freshTempOrder;
2924
+ this.clearCustomerWalletRuntimeState();
2644
2925
  this.store.summary = createEmptySummary();
2645
2926
  this.store.lastOrderInfo = undefined;
2646
2927
  this.store.syncState = undefined;
@@ -2673,32 +2954,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2673
2954
  ensureIdentity: false
2674
2955
  });
2675
2956
  this.store.tempOrder = nextTempOrder;
2957
+ this.clearCustomerWalletRuntimeState();
2676
2958
  if (!((options === null || options === void 0 ? void 0 : options.recalculateSummary) !== false)) {
2677
- _context13.next = 10;
2959
+ _context13.next = 11;
2678
2960
  break;
2679
2961
  }
2680
- _context13.next = 8;
2962
+ _context13.next = 9;
2681
2963
  return this.recalculateSummary({
2682
2964
  createIfMissing: false
2683
2965
  });
2684
- case 8:
2685
- _context13.next = 11;
2966
+ case 9:
2967
+ _context13.next = 12;
2686
2968
  break;
2687
- case 10:
2688
- this.store.summary = createEmptySummary();
2689
2969
  case 11:
2970
+ this.store.summary = createEmptySummary();
2971
+ case 12:
2690
2972
  if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
2691
2973
  this.persistTempOrder();
2692
2974
  }
2693
2975
  if (!(options !== null && options !== void 0 && options.saveDraft)) {
2694
- _context13.next = 15;
2976
+ _context13.next = 16;
2695
2977
  break;
2696
2978
  }
2697
- _context13.next = 15;
2979
+ _context13.next = 16;
2698
2980
  return this.saveDraft();
2699
- case 15:
2700
- return _context13.abrupt("return", nextTempOrder);
2701
2981
  case 16:
2982
+ return _context13.abrupt("return", nextTempOrder);
2983
+ case 17:
2702
2984
  case "end":
2703
2985
  return _context13.stop();
2704
2986
  }
@@ -2712,13 +2994,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2712
2994
  }, {
2713
2995
  key: "getOrderIdentity",
2714
2996
  value: function getOrderIdentity() {
2715
- var _ref42, _ref43, _tempOrder$order_id, _tempOrder$_extend6;
2997
+ var _ref49, _ref50, _tempOrder$order_id, _tempOrder$_extend7;
2716
2998
  var tempOrder = this.store.tempOrder;
2717
2999
  if (!tempOrder) return null;
2718
3000
  var lastOrderInfo = this.store.lastOrderInfo || {};
2719
- var orderId = (_ref42 = (_ref43 = (_tempOrder$order_id = tempOrder.order_id) !== null && _tempOrder$order_id !== void 0 ? _tempOrder$order_id : lastOrderInfo.order_id) !== null && _ref43 !== void 0 ? _ref43 : lastOrderInfo.id) !== null && _ref42 !== void 0 ? _ref42 : null;
3001
+ var orderId = (_ref49 = (_ref50 = (_tempOrder$order_id = tempOrder.order_id) !== null && _tempOrder$order_id !== void 0 ? _tempOrder$order_id : lastOrderInfo.order_id) !== null && _ref50 !== void 0 ? _ref50 : lastOrderInfo.id) !== null && _ref49 !== void 0 ? _ref49 : null;
2720
3002
  return {
2721
- localId: this.cacheId || ((_tempOrder$_extend6 = tempOrder._extend) === null || _tempOrder$_extend6 === void 0 ? void 0 : _tempOrder$_extend6.localId),
3003
+ localId: this.cacheId || ((_tempOrder$_extend7 = tempOrder._extend) === null || _tempOrder$_extend7 === void 0 ? void 0 : _tempOrder$_extend7.localId),
2722
3004
  orderId: orderId,
2723
3005
  externalSaleNumber: tempOrder.external_sale_number || lastOrderInfo.external_sale_number || '',
2724
3006
  orderNumber: tempOrder.order_number || lastOrderInfo.order_number || '',
@@ -2848,9 +3130,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2848
3130
  }, {
2849
3131
  key: "sanitizeTempOrderProducts",
2850
3132
  value: function sanitizeTempOrderProducts(tempOrder) {
2851
- var _this15 = this;
3133
+ var _this18 = this;
2852
3134
  tempOrder.products = (tempOrder.products || []).map(function (product) {
2853
- return _this15.sanitizeOrderProductForTempOrder(_this15.normalizeVirtualSettlementProductIfEnabled(product));
3135
+ return _this18.sanitizeOrderProductForTempOrder(_this18.normalizeVirtualSettlementProductIfEnabled(product));
2854
3136
  });
2855
3137
  this.syncTempOrderSettlementState(tempOrder);
2856
3138
  ensureUniqueProductLineUids(tempOrder);
@@ -2871,8 +3153,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2871
3153
  }, {
2872
3154
  key: "repairDuplicateProductLineIdentities",
2873
3155
  value: function repairDuplicateProductLineIdentities(tempOrder) {
2874
- var _tempOrder$_extend7;
2875
- var result = repairDuplicateOrderProductLineIdentities(tempOrder.products, (_tempOrder$_extend7 = tempOrder._extend) === null || _tempOrder$_extend7 === void 0 ? void 0 : _tempOrder$_extend7.productsByUid);
3156
+ var _tempOrder$_extend8;
3157
+ var result = repairDuplicateOrderProductLineIdentities(tempOrder.products, (_tempOrder$_extend8 = tempOrder._extend) === null || _tempOrder$_extend8 === void 0 ? void 0 : _tempOrder$_extend8.productsByUid);
2876
3158
  if (!result.repairs.length) return;
2877
3159
  tempOrder.products = result.products;
2878
3160
  if (result.productsByUid) {
@@ -2886,11 +3168,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2886
3168
  }, {
2887
3169
  key: "captureProductRuntime",
2888
3170
  value: function captureProductRuntime(tempOrder, rawProduct, normalizedProduct, existedUid) {
2889
- var _extend$productsByUid, _ref44, _rawProduct$_origin;
3171
+ var _extend$productsByUid, _ref51, _rawProduct$_origin;
2890
3172
  var uid = existedUid || this.getProductUid(normalizedProduct);
2891
3173
  var extend = this.ensureExtend(tempOrder);
2892
3174
  var existed = ((_extend$productsByUid = extend.productsByUid) === null || _extend$productsByUid === void 0 ? void 0 : _extend$productsByUid[uid]) || {};
2893
- var origin = (_ref44 = (_rawProduct$_origin = rawProduct._origin) !== null && _rawProduct$_origin !== void 0 ? _rawProduct$_origin : normalizedProduct._origin) !== null && _ref44 !== void 0 ? _ref44 : existed.origin;
3175
+ var origin = (_ref51 = (_rawProduct$_origin = rawProduct._origin) !== null && _rawProduct$_origin !== void 0 ? _rawProduct$_origin : normalizedProduct._origin) !== null && _ref51 !== void 0 ? _ref51 : existed.origin;
2894
3176
  extend.productsByUid[uid] = _objectSpread(_objectSpread({}, existed), origin !== undefined ? {
2895
3177
  origin: origin
2896
3178
  } : {});
@@ -2970,7 +3252,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2970
3252
  }, {
2971
3253
  key: "syncLinkedBookingHoldersToProducts",
2972
3254
  value: function syncLinkedBookingHoldersToProducts(tempOrder) {
2973
- var _this16 = this;
3255
+ var _this19 = this;
2974
3256
  var bookings = tempOrder.bookings || [];
2975
3257
  var products = tempOrder.products || [];
2976
3258
  if (!bookings.length || !products.length) return;
@@ -2995,7 +3277,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2995
3277
  var bookingUid = product.booking_uid || ((_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.booking_uid);
2996
3278
  var linkedBooking = (productUid !== undefined && productUid !== null && String(productUid) !== '' ? bookingByProductUid.get(String(productUid)) : undefined) || (bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '' ? bookingByBookingUid.get(String(bookingUid)) : undefined);
2997
3279
  if (linkedBooking) {
2998
- _this16.setProductHolderFromBooking(product, linkedBooking);
3280
+ _this19.setProductHolderFromBooking(product, linkedBooking);
2999
3281
  }
3000
3282
  });
3001
3283
  }
@@ -3033,7 +3315,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3033
3315
  }, {
3034
3316
  key: "buildTempOrderHolderFromBookings",
3035
3317
  value: function buildTempOrderHolderFromBookings(tempOrder) {
3036
- var _baseHolder$customer_, _baseHolder, _ref45, _baseHolder$form_id, _baseHolder2, _tempOrder$holder2, _baseHolder3, _this$otherParams2;
3318
+ var _baseHolder$customer_, _baseHolder, _ref52, _baseHolder$form_id, _baseHolder2, _tempOrder$holder2, _baseHolder3, _this$otherParams2;
3037
3319
  var holderRecords = [];
3038
3320
  var holderNames = [];
3039
3321
  var baseHolder = null;
@@ -3080,7 +3362,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3080
3362
  }
3081
3363
  var nextHolder = {
3082
3364
  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,
3083
- form_id: (_ref45 = (_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 && _ref45 !== void 0 ? _ref45 : 0,
3365
+ form_id: (_ref52 = (_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 && _ref52 !== void 0 ? _ref52 : 0,
3084
3366
  form_record: holderRecords
3085
3367
  };
3086
3368
  if (holderNames.length) {
@@ -3123,9 +3405,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3123
3405
  }, {
3124
3406
  key: "findBookingIndexByUniqueIdentificationNumber",
3125
3407
  value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
3126
- var _this17 = this;
3408
+ var _this20 = this;
3127
3409
  return (tempOrder.bookings || []).findIndex(function (booking) {
3128
- return _this17.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
3410
+ return _this20.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
3129
3411
  });
3130
3412
  }
3131
3413
  }, {
@@ -3133,12 +3415,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3133
3415
  value: function removeLinkedBookingsForProduct(tempOrder, product) {
3134
3416
  var _product$metadata5,
3135
3417
  _product$metadata6,
3136
- _this18 = this;
3418
+ _this21 = this;
3137
3419
  var productUid = (product === null || product === void 0 || (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
3138
3420
  var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.booking_uid);
3139
3421
  if (!productUid && !bookingUid) return;
3140
3422
  tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
3141
- var currentBookingUid = _this18.getBookingUniqueIdentificationNumber(booking);
3423
+ var currentBookingUid = _this21.getBookingUniqueIdentificationNumber(booking);
3142
3424
  if (bookingUid && currentBookingUid === String(bookingUid)) return false;
3143
3425
  if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
3144
3426
  return true;
@@ -3155,9 +3437,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3155
3437
  }, {
3156
3438
  key: "applyOrderProductsDepositSummary",
3157
3439
  value: function applyOrderProductsDepositSummary(tempOrder, summary) {
3158
- var _tempOrder$_extend8;
3440
+ var _tempOrder$_extend9;
3159
3441
  var depositSummary = calculateOrderProductsDeposit(tempOrder.products || [], {
3160
- productsByUid: (_tempOrder$_extend8 = tempOrder._extend) === null || _tempOrder$_extend8 === void 0 ? void 0 : _tempOrder$_extend8.productsByUid
3442
+ productsByUid: (_tempOrder$_extend9 = tempOrder._extend) === null || _tempOrder$_extend9 === void 0 ? void 0 : _tempOrder$_extend9.productsByUid
3161
3443
  });
3162
3444
  var manualDepositOverride = this.getManualDepositOverride(tempOrder);
3163
3445
  var currentStructuralFingerprint = manualDepositOverride ? this.buildOrderProductsStructuralFingerprint(tempOrder.products) : '';
@@ -3185,7 +3467,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3185
3467
  key: "recalculateSummary",
3186
3468
  value: function () {
3187
3469
  var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(options) {
3188
- var _this$otherParams3, _ref46, _salesSummaryResult$e;
3470
+ var _this$otherParams3, _ref53, _salesSummaryResult$e;
3189
3471
  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;
3190
3472
  return _regeneratorRuntime().wrap(function _callee13$(_context15) {
3191
3473
  while (1) switch (_context15.prev = _context15.next) {
@@ -3264,7 +3546,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3264
3546
  roundingAmount = paidPaymentSummary.roundingAmount;
3265
3547
  payServiceChargeAmount = paidPaymentSummary.payServiceChargeAmount;
3266
3548
  hasSalesSummaryAmount = salesSummaryResult.expect_amount !== undefined || salesSummaryResult.total_amount !== undefined;
3267
- expectAmount = hasSalesSummaryAmount ? new Decimal((_ref46 = (_salesSummaryResult$e = salesSummaryResult.expect_amount) !== null && _salesSummaryResult$e !== void 0 ? _salesSummaryResult$e : salesSummaryResult.total_amount) !== null && _ref46 !== void 0 ? _ref46 : 0) : null;
3549
+ expectAmount = hasSalesSummaryAmount ? new Decimal((_ref53 = (_salesSummaryResult$e = salesSummaryResult.expect_amount) !== null && _salesSummaryResult$e !== void 0 ? _salesSummaryResult$e : salesSummaryResult.total_amount) !== null && _ref53 !== void 0 ? _ref53 : 0) : null;
3268
3550
  amountPaymentPatch = hasSalesSummaryAmount || !roundingAmount.eq(0) || !payServiceChargeAmount.eq(0) ? _objectSpread({
3269
3551
  rounding_amount: roundingAmount.toFixed(2)
3270
3552
  }, expectAmount ? {
@@ -3387,8 +3669,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3387
3669
  }, {
3388
3670
  key: "getTempOrderNote",
3389
3671
  value: function getTempOrderNote() {
3390
- var _this$store$tempOrder4;
3391
- return ((_this$store$tempOrder4 = this.store.tempOrder) === null || _this$store$tempOrder4 === void 0 ? void 0 : _this$store$tempOrder4.note) || '';
3672
+ var _this$store$tempOrder6;
3673
+ return ((_this$store$tempOrder6 = this.store.tempOrder) === null || _this$store$tempOrder6 === void 0 ? void 0 : _this$store$tempOrder6.note) || '';
3392
3674
  }
3393
3675
  }, {
3394
3676
  key: "ensureSalesNotesRuntimeState",
@@ -3440,7 +3722,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3440
3722
  }, {
3441
3723
  key: "removeSalesNotesForMissingProductLines",
3442
3724
  value: function removeSalesNotesForMissingProductLines(tempOrder) {
3443
- var _this19 = this;
3725
+ var _this22 = this;
3444
3726
  var state = this.ensureSalesNotesRuntimeState(tempOrder);
3445
3727
  if (!state.loaded || !Array.isArray(tempOrder.notes) || tempOrder.notes.length === 0) {
3446
3728
  return;
@@ -3452,7 +3734,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3452
3734
  return typeof uid === 'string' && uid.length > 0;
3453
3735
  }));
3454
3736
  var nextNotes = tempOrder.notes.filter(function (note) {
3455
- var primary = _this19.getSalesNotePrimaryRelation(note);
3737
+ var primary = _this22.getSalesNotePrimaryRelation(note);
3456
3738
  if (!primary || primary.target_type !== 'order_detail') return true;
3457
3739
  return remainingProductUids.has(primary.target_uuid);
3458
3740
  });
@@ -3464,7 +3746,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3464
3746
  key: "setSalesNoteOnTempOrder",
3465
3747
  value: function setSalesNoteOnTempOrder(tempOrder, input) {
3466
3748
  var _input$target,
3467
- _this20 = this,
3749
+ _this23 = this,
3468
3750
  _tempOrder$shop_order;
3469
3751
  this.ensureSalesNotesLoadedForMutation(tempOrder);
3470
3752
  var note_type = String(input.note_type || '').trim();
@@ -3488,7 +3770,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3488
3770
  var notes = tempOrder.notes || [];
3489
3771
  // 当前 allergy policy 固定同一商品行只保留一条;业务调用方不参与去重规则。
3490
3772
  var existingIndex = policy.uniquePerPrimaryTarget ? notes.findIndex(function (note) {
3491
- var primary = _this20.getSalesNotePrimaryRelation(note);
3773
+ var primary = _this23.getSalesNotePrimaryRelation(note);
3492
3774
  return note.note_type === note_type && (primary === null || primary === void 0 ? void 0 : primary.target_type) === 'order_detail' && primary.target_uuid === target_uuid;
3493
3775
  }) : -1;
3494
3776
  var existing = existingIndex >= 0 ? notes[existingIndex] : null;
@@ -3740,17 +4022,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3740
4022
  }, {
3741
4023
  key: "buildTempOrderCustomer",
3742
4024
  value: function buildTempOrderCustomer(params) {
3743
- var _ref47, _ref48, _ref49, _source$name, _ref50, _ref51, _ref52, _source$customer_name, _source$id, _source$customer_id, _ref53, _source$country_calli, _source$phone, _source$email;
4025
+ var _ref54, _ref55, _ref56, _source$name, _ref57, _ref58, _ref59, _source$customer_name, _source$id, _source$customer_id, _ref60, _source$country_calli, _source$phone, _source$email;
3744
4026
  if (!params.customerId) return null;
3745
4027
  var source = params.source ? cloneDeep(params.source) : {};
3746
- var name = (_ref47 = (_ref48 = (_ref49 = (_source$name = source.name) !== null && _source$name !== void 0 ? _source$name : source.display_name) !== null && _ref49 !== void 0 ? _ref49 : source.customerName) !== null && _ref48 !== void 0 ? _ref48 : source.customer_name) !== null && _ref47 !== void 0 ? _ref47 : params.customerName;
3747
- var customerName = (_ref50 = (_ref51 = (_ref52 = (_source$customer_name = source.customer_name) !== null && _source$customer_name !== void 0 ? _source$customer_name : source.customerName) !== null && _ref52 !== void 0 ? _ref52 : source.display_name) !== null && _ref51 !== void 0 ? _ref51 : source.name) !== null && _ref50 !== void 0 ? _ref50 : params.customerName;
4028
+ var name = (_ref54 = (_ref55 = (_ref56 = (_source$name = source.name) !== null && _source$name !== void 0 ? _source$name : source.display_name) !== null && _ref56 !== void 0 ? _ref56 : source.customerName) !== null && _ref55 !== void 0 ? _ref55 : source.customer_name) !== null && _ref54 !== void 0 ? _ref54 : params.customerName;
4029
+ var customerName = (_ref57 = (_ref58 = (_ref59 = (_source$customer_name = source.customer_name) !== null && _source$customer_name !== void 0 ? _source$customer_name : source.customerName) !== null && _ref59 !== void 0 ? _ref59 : source.display_name) !== null && _ref58 !== void 0 ? _ref58 : source.name) !== null && _ref57 !== void 0 ? _ref57 : params.customerName;
3748
4030
  return _objectSpread(_objectSpread({}, source), {}, {
3749
4031
  id: (_source$id = source.id) !== null && _source$id !== void 0 ? _source$id : params.customerId,
3750
4032
  customer_id: (_source$customer_id = source.customer_id) !== null && _source$customer_id !== void 0 ? _source$customer_id : params.customerId,
3751
4033
  name: String(name || ''),
3752
4034
  customer_name: String(customerName || ''),
3753
- country_calling_code: String((_ref53 = (_source$country_calli = source.country_calling_code) !== null && _source$country_calli !== void 0 ? _source$country_calli : source.countryCallingCode) !== null && _ref53 !== void 0 ? _ref53 : params.countryCallingCode),
4035
+ country_calling_code: String((_ref60 = (_source$country_calli = source.country_calling_code) !== null && _source$country_calli !== void 0 ? _source$country_calli : source.countryCallingCode) !== null && _ref60 !== void 0 ? _ref60 : params.countryCallingCode),
3754
4036
  phone: String((_source$phone = source.phone) !== null && _source$phone !== void 0 ? _source$phone : params.phone),
3755
4037
  email: String((_source$email = source.email) !== null && _source$email !== void 0 ? _source$email : params.email)
3756
4038
  });
@@ -3760,7 +4042,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3760
4042
  value: function isCustomerBoundDiscount(discount) {
3761
4043
  var _discount$type5;
3762
4044
  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;
3763
- return type === 'good_pass' || type === 'discount_card' || type === 'product_discount_card';
4045
+ return type === 'entitlement_pass' || type === 'good_pass' || type === 'discount_card' || type === 'product_discount_card';
3764
4046
  }
3765
4047
  }, {
3766
4048
  key: "shouldKeepCustomerBoundDiscountAfterCustomerChange",
@@ -3770,15 +4052,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3770
4052
  }, {
3771
4053
  key: "productHasCustomerBoundDiscount",
3772
4054
  value: function productHasCustomerBoundDiscount(product) {
3773
- var _this21 = this;
4055
+ var _this24 = this;
3774
4056
  if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
3775
- return _this21.isCustomerBoundDiscount(discount);
4057
+ return _this24.isCustomerBoundDiscount(discount);
3776
4058
  })) {
3777
4059
  return true;
3778
4060
  }
3779
4061
  return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
3780
4062
  return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
3781
- return _this21.isCustomerBoundDiscount(discount);
4063
+ return _this24.isCustomerBoundDiscount(discount);
3782
4064
  });
3783
4065
  });
3784
4066
  }
@@ -3787,18 +4069,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3787
4069
  value: function shouldSkipDiscountCalculation(tempOrder) {
3788
4070
  var _this$store$discount20,
3789
4071
  _this$store$discount21,
3790
- _this22 = this;
4072
+ _this25 = this;
3791
4073
  if (this.hasActiveCustomerBoundDiscount) return false;
3792
4074
  var discountList = ((_this$store$discount20 = this.store.discount) === null || _this$store$discount20 === void 0 || (_this$store$discount21 = _this$store$discount20.getDiscountList) === null || _this$store$discount21 === void 0 ? void 0 : _this$store$discount21.call(_this$store$discount20)) || [];
3793
4075
  if (discountList.length > 0) return false;
3794
4076
  return !(tempOrder.products || []).some(function (product) {
3795
- return _this22.productHasCustomerBoundDiscount(product);
4077
+ return _this25.productHasCustomerBoundDiscount(product);
3796
4078
  });
3797
4079
  }
3798
4080
  }, {
3799
4081
  key: "clearCustomerBoundDiscounts",
3800
4082
  value: function clearCustomerBoundDiscounts(tempOrder) {
3801
- var _this23 = this,
4083
+ var _this26 = this,
3802
4084
  _discountModule$getDi,
3803
4085
  _discountModule$getOr,
3804
4086
  _discountModule$setDi,
@@ -3807,7 +4089,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3807
4089
  var filterDiscountList = function filterDiscountList(discountList) {
3808
4090
  if (!Array.isArray(discountList)) return [];
3809
4091
  return discountList.filter(function (discount) {
3810
- var shouldRemove = _this23.isCustomerBoundDiscount(discount);
4092
+ var shouldRemove = _this26.isCustomerBoundDiscount(discount);
3811
4093
  if (shouldRemove) didRemoveCustomerBoundDiscount = true;
3812
4094
  return !shouldRemove;
3813
4095
  });
@@ -3834,12 +4116,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3834
4116
  var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
3835
4117
  var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
3836
4118
  var nextDiscounts = currentDiscounts.filter(function (discount) {
3837
- if (_this23.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3838
- return !_this23.isCustomerBoundDiscount(discount);
4119
+ if (_this26.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
4120
+ return !_this26.isCustomerBoundDiscount(discount);
3839
4121
  });
3840
4122
  var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
3841
- if (_this23.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3842
- return !_this23.isCustomerBoundDiscount(discount);
4123
+ if (_this26.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
4124
+ return !_this26.isCustomerBoundDiscount(discount);
3843
4125
  });
3844
4126
  void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
3845
4127
  void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
@@ -3854,14 +4136,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3854
4136
  }, {
3855
4137
  key: "updateTempOrderCustomer",
3856
4138
  value: function updateTempOrderCustomer(customer) {
3857
- var _tempOrder$customer_i3, _ref54, _ref55, _customer$customer_id, _ref56, _ref57, _ref58, _customer$customer_na, _ref59, _customer$country_cal, _tempOrder$customer_i4;
4139
+ var _tempOrder$customer_i3, _ref61, _ref62, _customer$customer_id, _ref63, _ref64, _ref65, _customer$customer_na, _ref66, _customer$country_cal, _tempOrder$customer_i4;
3858
4140
  var tempOrder = this.ensureTempOrder();
3859
4141
  var previousCustomerId = (_tempOrder$customer_i3 = tempOrder.customer_id) !== null && _tempOrder$customer_i3 !== void 0 ? _tempOrder$customer_i3 : null;
3860
- var customerId = (_ref54 = (_ref55 = (_customer$customer_id = customer.customer_id) !== null && _customer$customer_id !== void 0 ? _customer$customer_id : customer.customerId) !== null && _ref55 !== void 0 ? _ref55 : customer.id) !== null && _ref54 !== void 0 ? _ref54 : null;
3861
- var customerName = (_ref56 = (_ref57 = (_ref58 = (_customer$customer_na = customer.customer_name) !== null && _customer$customer_na !== void 0 ? _customer$customer_na : customer.customerName) !== null && _ref58 !== void 0 ? _ref58 : customer.display_name) !== null && _ref57 !== void 0 ? _ref57 : customer.name) !== null && _ref56 !== void 0 ? _ref56 : '';
4142
+ var customerId = (_ref61 = (_ref62 = (_customer$customer_id = customer.customer_id) !== null && _customer$customer_id !== void 0 ? _customer$customer_id : customer.customerId) !== null && _ref62 !== void 0 ? _ref62 : customer.id) !== null && _ref61 !== void 0 ? _ref61 : null;
4143
+ var customerName = (_ref63 = (_ref64 = (_ref65 = (_customer$customer_na = customer.customer_name) !== null && _customer$customer_na !== void 0 ? _customer$customer_na : customer.customerName) !== null && _ref65 !== void 0 ? _ref65 : customer.display_name) !== null && _ref64 !== void 0 ? _ref64 : customer.name) !== null && _ref63 !== void 0 ? _ref63 : '';
3862
4144
  tempOrder.customer_id = customerId === null || customerId === undefined || customerId === '' ? null : Number(customerId);
3863
4145
  tempOrder.customer_name = String(customerName || '');
3864
- tempOrder.country_calling_code = String((_ref59 = (_customer$country_cal = customer.country_calling_code) !== null && _customer$country_cal !== void 0 ? _customer$country_cal : customer.countryCallingCode) !== null && _ref59 !== void 0 ? _ref59 : '');
4146
+ tempOrder.country_calling_code = String((_ref66 = (_customer$country_cal = customer.country_calling_code) !== null && _customer$country_cal !== void 0 ? _customer$country_cal : customer.countryCallingCode) !== null && _ref66 !== void 0 ? _ref66 : '');
3865
4147
  tempOrder.phone = String(customer.phone || '');
3866
4148
  tempOrder.email = String(customer.email || '');
3867
4149
  tempOrder.customer = this.buildTempOrderCustomer({
@@ -3873,9 +4155,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3873
4155
  email: tempOrder.email
3874
4156
  });
3875
4157
  var nextCustomerId = (_tempOrder$customer_i4 = tempOrder.customer_id) !== null && _tempOrder$customer_i4 !== void 0 ? _tempOrder$customer_i4 : null;
3876
- if (String(previousCustomerId !== null && previousCustomerId !== void 0 ? previousCustomerId : '') !== String(nextCustomerId !== null && nextCustomerId !== void 0 ? nextCustomerId : '') && !hasPersistedOrderId(tempOrder.order_id)) {
3877
- this.store.availableWalletIds = [];
3878
- this.clearTempOrderPointCardSnapshot(tempOrder);
4158
+ if (String(previousCustomerId !== null && previousCustomerId !== void 0 ? previousCustomerId : '') !== String(nextCustomerId !== null && nextCustomerId !== void 0 ? nextCustomerId : '')) {
4159
+ this.clearCustomerWalletState(tempOrder);
3879
4160
  }
3880
4161
  this.persistTempOrder();
3881
4162
  return {
@@ -3914,11 +4195,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3914
4195
  }
3915
4196
  var nextCustomerId = (_tempOrder$customer_i6 = tempOrder.customer_id) !== null && _tempOrder$customer_i6 !== void 0 ? _tempOrder$customer_i6 : null;
3916
4197
  if (String(previousCustomerId !== null && previousCustomerId !== void 0 ? previousCustomerId : '') !== String(nextCustomerId !== null && nextCustomerId !== void 0 ? nextCustomerId : '')) {
3917
- this.store.availableWalletIds = [];
3918
- this.store.virtualCurrencyList = [];
3919
- if (!hasPersistedOrderId(tempOrder.order_id)) {
3920
- this.clearTempOrderPointCardSnapshot(tempOrder);
3921
- }
4198
+ this.clearCustomerWalletState(tempOrder);
3922
4199
  clearTempOrderHolderAssignments(tempOrder);
3923
4200
  this.clearCustomerBoundDiscounts(tempOrder);
3924
4201
  this.applyDiscount();
@@ -3947,8 +4224,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3947
4224
  }, {
3948
4225
  key: "getOrderCustomerSnapshot",
3949
4226
  value: function getOrderCustomerSnapshot() {
3950
- var _this$store$tempOrder5;
3951
- var snapshot = (_this$store$tempOrder5 = this.store.tempOrder) === null || _this$store$tempOrder5 === void 0 || (_this$store$tempOrder5 = _this$store$tempOrder5._extend) === null || _this$store$tempOrder5 === void 0 ? void 0 : _this$store$tempOrder5.customerSnapshot;
4227
+ var _this$store$tempOrder7;
4228
+ var snapshot = (_this$store$tempOrder7 = this.store.tempOrder) === null || _this$store$tempOrder7 === void 0 || (_this$store$tempOrder7 = _this$store$tempOrder7._extend) === null || _this$store$tempOrder7 === void 0 ? void 0 : _this$store$tempOrder7.customerSnapshot;
3952
4229
  return snapshot ? cloneDeep(snapshot) : null;
3953
4230
  }
3954
4231
  }, {
@@ -3963,11 +4240,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3963
4240
  tempOrder.email = '';
3964
4241
  tempOrder.customer = null;
3965
4242
  if (tempOrder._extend) delete tempOrder._extend.customerSnapshot;
3966
- this.store.availableWalletIds = [];
3967
- this.store.virtualCurrencyList = [];
3968
- if (!hasPersistedOrderId(tempOrder.order_id)) {
3969
- this.clearTempOrderPointCardSnapshot(tempOrder);
3970
- }
4243
+ this.clearCustomerWalletState(tempOrder);
3971
4244
  this.clearCustomerBoundDiscounts(tempOrder);
3972
4245
  this.applyDiscount();
3973
4246
  this.persistTempOrder();
@@ -4012,10 +4285,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4012
4285
  }, {
4013
4286
  key: "setOrderPayments",
4014
4287
  value: function setOrderPayments(payments) {
4015
- var _this24 = this;
4288
+ var _this27 = this;
4016
4289
  var tempOrder = this.ensureTempOrder();
4017
4290
  tempOrder.payments = mapPaymentItemsToOrderPayments((payments || []).map(function (payment) {
4018
- return _this24.normalizePaymentSource(payment, {
4291
+ return _this27.normalizePaymentSource(payment, {
4019
4292
  defaultPaid: false
4020
4293
  });
4021
4294
  }));
@@ -4070,7 +4343,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4070
4343
  }, {
4071
4344
  key: "addOrderPaymentWithDevicePrefix",
4072
4345
  value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
4073
- var _this25 = this;
4346
+ var _this28 = this;
4074
4347
  this.logInfo('addOrderPayment', {
4075
4348
  payment: payment
4076
4349
  });
@@ -4088,7 +4361,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4088
4361
  void this.recalculateSummary({
4089
4362
  createIfMissing: true
4090
4363
  }).catch(function (error) {
4091
- _this25.logError('recalculate summary after addOrderPayment failed', {
4364
+ _this28.logError('recalculate summary after addOrderPayment failed', {
4092
4365
  error: error instanceof Error ? error.message : String(error)
4093
4366
  });
4094
4367
  });
@@ -4201,7 +4474,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4201
4474
  }, {
4202
4475
  key: "applyPaymentLifecycleChange",
4203
4476
  value: function applyPaymentLifecycleChange(tempOrder, options) {
4204
- var _this26 = this;
4477
+ var _this29 = this;
4205
4478
  this.updateTempOrderPaymentStatus(tempOrder);
4206
4479
  if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
4207
4480
  this.persistTempOrder();
@@ -4211,7 +4484,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4211
4484
  void this.recalculateSummary({
4212
4485
  createIfMissing: true
4213
4486
  }).catch(function (error) {
4214
- _this26.logError("recalculate summary after ".concat(logContext, " failed"), {
4487
+ _this29.logError("recalculate summary after ".concat(logContext, " failed"), {
4215
4488
  error: error instanceof Error ? error.message : String(error)
4216
4489
  });
4217
4490
  });
@@ -4255,7 +4528,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4255
4528
  }, {
4256
4529
  key: "updateVoucherOrderPayments",
4257
4530
  value: function updateVoucherOrderPayments(payments, options) {
4258
- var _this27 = this;
4531
+ var _this30 = this;
4259
4532
  var tempOrder = this.ensureTempOrder();
4260
4533
  var isOrderPaymentType = function isOrderPaymentType(value) {
4261
4534
  return value === 'normal' || value === 'deposit';
@@ -4290,7 +4563,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4290
4563
  });
4291
4564
  };
4292
4565
  var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
4293
- return _this27.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
4566
+ return _this30.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
4294
4567
  defaultPaid: false,
4295
4568
  devicePrefix: options === null || options === void 0 ? void 0 : options.devicePrefix
4296
4569
  });
@@ -4343,7 +4616,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4343
4616
  void this.recalculateSummary({
4344
4617
  createIfMissing: true
4345
4618
  }).catch(function (error) {
4346
- _this27.logError('recalculate summary after updateVoucherOrderPayments failed', {
4619
+ _this30.logError('recalculate summary after updateVoucherOrderPayments failed', {
4347
4620
  error: error instanceof Error ? error.message : String(error)
4348
4621
  });
4349
4622
  });
@@ -4401,7 +4674,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4401
4674
  key: "shouldMergeProductToOrder",
4402
4675
  value: function shouldMergeProductToOrder(params) {
4403
4676
  var _this$orderHooks,
4404
- _this28 = this;
4677
+ _this31 = this;
4405
4678
  var onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
4406
4679
  if (!onBeforeMergeProductToOrder) return true;
4407
4680
  var result = onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
@@ -4409,7 +4682,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4409
4682
  }));
4410
4683
  if (result && _typeof(result) === 'object' && typeof result.then === 'function') {
4411
4684
  return Promise.resolve(result).then(function (resolved) {
4412
- return _this28.normalizeShouldMergeProductResult(resolved);
4685
+ return _this31.normalizeShouldMergeProductResult(resolved);
4413
4686
  });
4414
4687
  }
4415
4688
  return this.normalizeShouldMergeProductResult(result);
@@ -4458,7 +4731,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4458
4731
  }, {
4459
4732
  key: "assertAndLockProductSettlement",
4460
4733
  value: function assertAndLockProductSettlement(tempOrder, product) {
4461
- var _ref60, _ref61, _product$selling_pric;
4734
+ var _ref67, _ref68, _product$selling_pric;
4462
4735
  if (!this.isMultiCurrencySettlementEnabled()) return;
4463
4736
  var currentKey = getTempOrderSettlementKey(tempOrder);
4464
4737
  var incomingKey = getSettlementKey(getSelectedSettlementSnapshot(product)) || 'legal_currency';
@@ -4485,7 +4758,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4485
4758
  }
4486
4759
  applyTempOrderSettlementState(tempOrder, snapshot || {
4487
4760
  settlement_type: 'legal_currency',
4488
- price: (_ref60 = (_ref61 = (_product$selling_pric = product.selling_price) !== null && _product$selling_pric !== void 0 ? _product$selling_pric : product.original_price) !== null && _ref61 !== void 0 ? _ref61 : product.payment_price) !== null && _ref60 !== void 0 ? _ref60 : 0,
4761
+ price: (_ref67 = (_ref68 = (_product$selling_pric = product.selling_price) !== null && _product$selling_pric !== void 0 ? _product$selling_pric : product.original_price) !== null && _ref68 !== void 0 ? _ref68 : product.payment_price) !== null && _ref67 !== void 0 ? _ref67 : 0,
4489
4762
  unit_label: tempOrder.currency_code,
4490
4763
  symbol: tempOrder.currency_symbol,
4491
4764
  amount_format: tempOrder.currency_format
@@ -4610,7 +4883,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4610
4883
  _metadata,
4611
4884
  _productToAdd$metadat,
4612
4885
  _origin,
4613
- _this29 = this;
4886
+ _this32 = this;
4614
4887
  var linked = booking ? this.createLinkedProductAndBooking({
4615
4888
  product: product,
4616
4889
  booking: booking
@@ -4637,18 +4910,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4637
4910
  }
4638
4911
  normalizedIncoming.discount_list = normalizeOrderProductDiscountList(normalizedIncoming.discount_list);
4639
4912
  var hasIncomingGoodPass = this.hasGoodPassDiscount(normalizedIncoming);
4913
+ var hasIncomingEntitlementPass = this.hasEntitlementPassDiscount(normalizedIncoming);
4914
+ var isIncomingEntitlementAppend = this.isRuntimeEntitlementAppend(productToAdd, tempOrder);
4915
+ var isIncomingPersistedEntitlementPass = hasIncomingEntitlementPass && this.isPersistedProductLine(normalizedIncoming);
4640
4916
  var hasIncomingProductNote = this.hasOrderProductLineNote(normalizedIncoming);
4641
4917
  var hasIncomingManualProductDiscount = isManualProductDiscountProduct(normalizedIncoming);
4642
4918
  var hasIncomingBookingUid = this.hasLinkedBookingUid(productToAdd) || this.hasLinkedBookingUid(normalizedIncoming);
4643
4919
  var isIncomingCustomItem = ((_productToAdd$metadat = productToAdd.metadata) === null || _productToAdd$metadat === void 0 || (_productToAdd$metadat = _productToAdd$metadat.origin) === null || _productToAdd$metadat === void 0 ? void 0 : _productToAdd$metadat.isCustomItem) === true || ((_origin = productToAdd._origin) === null || _origin === void 0 ? void 0 : _origin.isCustomItem) === true;
4644
- var shouldForceNewLine = disableMerge || !!booking || hasIncomingProductNote || hasIncomingManualProductDiscount || hasIncomingBookingUid || isIncomingCustomItem || isWeighingProduct;
4645
- var matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
4646
- var _item$metadata3;
4647
- if (_this29.hasGoodPassDiscount(item)) return false;
4648
- if (_this29.hasOrderProductLineNote(item)) return false;
4649
- if (isManualProductDiscountProduct(item)) return false;
4650
- if (item.order_detail_id !== undefined && item.order_detail_id !== null) return false;
4651
- if ((_item$metadata3 = item.metadata) !== null && _item$metadata3 !== void 0 && _item$metadata3.is_edit_for_runtime) return false;
4920
+ var shouldForceNewLine = disableMerge || !!booking || hasIncomingGoodPass || isIncomingPersistedEntitlementPass || hasIncomingBookingUid || isIncomingCustomItem || isWeighingProduct;
4921
+ var matchedIndex = shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
4922
+ if (_this32.hasGoodPassDiscount(item)) return false;
4923
+ var isRuntimeEntitlementPass = _this32.isRuntimeEntitlementAppend(item, tempOrder);
4924
+ if (isIncomingEntitlementAppend !== isRuntimeEntitlementPass) {
4925
+ return false;
4926
+ }
4927
+ if (isIncomingEntitlementAppend && _this32.isPersistedProductLine(item)) {
4928
+ return false;
4929
+ }
4930
+ var hasExistingProductNote = _this32.hasOrderProductLineNote(item);
4931
+ if ((hasIncomingProductNote || hasExistingProductNote) && (!isRuntimeEntitlementPass || String(normalizedIncoming.note || '').trim() !== String(item.note || '').trim())) {
4932
+ return false;
4933
+ }
4934
+ var hasExistingManualProductDiscount = isManualProductDiscountProduct(item);
4935
+ if (isRuntimeEntitlementPass && !_this32.hasSameEntitlementMergePriceConfig(normalizedIncoming, item)) {
4936
+ return false;
4937
+ }
4938
+ if ((hasIncomingManualProductDiscount || hasExistingManualProductDiscount) && !isRuntimeEntitlementPass) {
4939
+ return false;
4940
+ }
4941
+ if (_this32.isPersistedProductLine(item)) return false;
4652
4942
  if (item.product_id !== productToAdd.product_id) return false;
4653
4943
  if (item.product_variant_id !== productToAdd.product_variant_id) return false;
4654
4944
  var existedFingerprint = buildProductLineFingerprint(getProductSkuOptions(item), item.product_bundle);
@@ -4659,7 +4949,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4659
4949
  var commitProductLine = function commitProductLine(shouldMerge) {
4660
4950
  var committedProduct;
4661
4951
  if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
4662
- _this29.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
4952
+ _this32.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
4663
4953
  if (linked) {
4664
4954
  normalizedIncoming.booking_uid = linked.bookingUid;
4665
4955
  normalizedIncoming.metadata = _objectSpread(_objectSpread({}, normalizedIncoming.metadata || {}), {}, {
@@ -4677,7 +4967,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4677
4967
  var _targetProduct$metada;
4678
4968
  var targetProduct = matchedProduct;
4679
4969
  var targetUid = (_targetProduct$metada = targetProduct.metadata) === null || _targetProduct$metada === void 0 ? void 0 : _targetProduct$metada.unique_identification_number;
4680
- var normalizedProduct = _this29.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(targetProduct, normalizeOrderProduct(_objectSpread(_objectSpread({}, productToAdd), {}, {
4970
+ var normalizedProduct = _this32.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(targetProduct, normalizeOrderProduct(_objectSpread(_objectSpread({}, productToAdd), {}, {
4681
4971
  metadata: _objectSpread(_objectSpread({}, productToAdd.metadata || {}), {}, {
4682
4972
  unique_identification_number: targetUid
4683
4973
  })
@@ -4700,7 +4990,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4700
4990
  order_detail_id: targetProduct.order_detail_id,
4701
4991
  num: nextNum
4702
4992
  });
4703
- _this29.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
4993
+ _this32.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
4704
4994
  committedProduct = tempOrder.products[matchedIndex];
4705
4995
  if (matchedIndex !== tempOrder.products.length - 1) {
4706
4996
  var mergedProduct = tempOrder.products[matchedIndex];
@@ -4738,14 +5028,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4738
5028
  }, {
4739
5029
  key: "createSplitBookingLine",
4740
5030
  value: function createSplitBookingLine(product, booking, index, splitCount) {
4741
- var _booking$metadata6, _ref62, _ref63, _bookingHolder$form_r, _booking$metadata7, _product$metadata10, _bookingHolder$name, _singleBooking$metada;
5031
+ var _booking$metadata6, _ref69, _ref70, _bookingHolder$form_r, _booking$metadata7, _product$metadata10, _bookingHolder$name, _singleBooking$metada;
4742
5032
  var singleLine = cloneDeep(product);
4743
5033
  singleLine.num = 1;
4744
5034
  delete singleLine.product_quantity;
4745
5035
  var singleBooking = cloneDeep(booking);
4746
5036
  var bookingHolder = booking !== null && booking !== void 0 && booking.holder && _typeof(booking.holder) === 'object' ? booking.holder : null;
4747
5037
  var metadataHolder = booking !== null && booking !== void 0 && (_booking$metadata6 = booking.metadata) !== null && _booking$metadata6 !== void 0 && _booking$metadata6.holder && _typeof(booking.metadata.holder) === 'object' ? booking.metadata.holder : null;
4748
- var rawHolderIds = (_ref62 = (_ref63 = (_bookingHolder$form_r = bookingHolder === null || bookingHolder === void 0 ? void 0 : bookingHolder.form_record) !== null && _bookingHolder$form_r !== void 0 ? _bookingHolder$form_r : booking === null || booking === void 0 || (_booking$metadata7 = booking.metadata) === null || _booking$metadata7 === void 0 ? void 0 : _booking$metadata7.holder_id) !== null && _ref63 !== void 0 ? _ref63 : metadataHolder === null || metadataHolder === void 0 ? void 0 : metadataHolder.form_record) !== null && _ref62 !== void 0 ? _ref62 : product === null || product === void 0 || (_product$metadata10 = product.metadata) === null || _product$metadata10 === void 0 ? void 0 : _product$metadata10.holder_id;
5038
+ var rawHolderIds = (_ref69 = (_ref70 = (_bookingHolder$form_r = bookingHolder === null || bookingHolder === void 0 ? void 0 : bookingHolder.form_record) !== null && _bookingHolder$form_r !== void 0 ? _bookingHolder$form_r : booking === null || booking === void 0 || (_booking$metadata7 = booking.metadata) === null || _booking$metadata7 === void 0 ? void 0 : _booking$metadata7.holder_id) !== null && _ref70 !== void 0 ? _ref70 : metadataHolder === null || metadataHolder === void 0 ? void 0 : metadataHolder.form_record) !== null && _ref69 !== void 0 ? _ref69 : product === null || product === void 0 || (_product$metadata10 = product.metadata) === null || _product$metadata10 === void 0 ? void 0 : _product$metadata10.holder_id;
4749
5039
  var holderIds = (Array.isArray(rawHolderIds) ? rawHolderIds : [rawHolderIds]).map(function (holderId) {
4750
5040
  return holderId && _typeof(holderId) === 'object' ? holderId.form_record_id : holderId;
4751
5041
  }).filter(function (holderId) {
@@ -4810,8 +5100,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4810
5100
  key: "addProductToOrder",
4811
5101
  value: (function () {
4812
5102
  var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(product, booking, options) {
4813
- var _this30 = this;
4814
- var tempOrder, salesNoteDrafts, mutationSnapshot, attachSalesNoteDrafts, rollbackProductAndNotesMutation, insertAfterProductUid, anchorIndex, insertAtIndex, _ref64, _productRecord$num, productRecord, splitCount, i, splitLine, committedProduct, _committedProduct, _committedProduct2;
5103
+ var _this33 = this;
5104
+ var tempOrder, salesNoteDrafts, mutationSnapshot, attachSalesNoteDrafts, rollbackProductAndNotesMutation, insertAfterProductUid, anchorIndex, insertAtIndex, _ref71, _productRecord$num, productRecord, splitCount, i, splitLine, committedProduct, _committedProduct, _committedProduct2;
4815
5105
  return _regeneratorRuntime().wrap(function _callee23$(_context25) {
4816
5106
  while (1) switch (_context25.prev = _context25.next) {
4817
5107
  case 0:
@@ -4839,7 +5129,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4839
5129
  throw new Error('[Order Notes] 商品行缺少 unique_identification_number');
4840
5130
  }
4841
5131
  salesNoteDrafts.forEach(function (draft) {
4842
- _this30.setSalesNoteOnTempOrder(tempOrder, {
5132
+ _this33.setSalesNoteOnTempOrder(tempOrder, {
4843
5133
  note_type: draft.note_type,
4844
5134
  target: {
4845
5135
  target_type: 'order_detail',
@@ -4869,7 +5159,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4869
5159
  break;
4870
5160
  }
4871
5161
  productRecord = product;
4872
- splitCount = getSafeProductNum((_ref64 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref64 !== void 0 ? _ref64 : 1);
5162
+ splitCount = getSafeProductNum((_ref71 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref71 !== void 0 ? _ref71 : 1);
4873
5163
  if (!(splitCount > 1)) {
4874
5164
  _context25.next = 27;
4875
5165
  break;
@@ -4974,7 +5264,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4974
5264
  key: "addProductsToOrder",
4975
5265
  value: (function () {
4976
5266
  var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(items, options) {
4977
- var tempOrder, _iterator20, _step20, item, product, booking, _ref65, _productRecord$num2, productRecord, splitCount, i, splitLine, _appendResult, appendResult;
5267
+ var tempOrder, _iterator20, _step20, item, product, booking, _ref72, _productRecord$num2, productRecord, splitCount, i, splitLine, _appendResult, appendResult;
4978
5268
  return _regeneratorRuntime().wrap(function _callee24$(_context26) {
4979
5269
  while (1) switch (_context26.prev = _context26.next) {
4980
5270
  case 0:
@@ -5006,7 +5296,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5006
5296
  break;
5007
5297
  }
5008
5298
  productRecord = product;
5009
- splitCount = getSafeProductNum((_ref65 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref65 !== void 0 ? _ref65 : 1);
5299
+ splitCount = getSafeProductNum((_ref72 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref72 !== void 0 ? _ref72 : 1);
5010
5300
  if (!(splitCount > 1)) {
5011
5301
  _context26.next = 26;
5012
5302
  break;
@@ -5073,45 +5363,99 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5073
5363
  return addProductsToOrder;
5074
5364
  }())
5075
5365
  }, {
5076
- key: "hasGoodPassDiscount",
5077
- value: function hasGoodPassDiscount(product) {
5366
+ key: "getFullCoveragePassDiscounts",
5367
+ value: function getFullCoveragePassDiscounts(product) {
5078
5368
  var _product$_extend;
5079
- var hasMainGoodPass = (product.discount_list || []).some(function (item) {
5080
- return (item === null || item === void 0 ? void 0 : item.type) === 'good_pass' || (item === null || item === void 0 ? void 0 : item.tag) === 'good_pass';
5081
- });
5082
- if (hasMainGoodPass) return true;
5083
- var bundleDiscountList = [];
5369
+ var discountList = _toConsumableArray(product.discount_list || []);
5084
5370
  (product.product_bundle || []).forEach(function (item) {
5085
- bundleDiscountList.push.apply(bundleDiscountList, _toConsumableArray((item === null || item === void 0 ? void 0 : item.discount_list) || []));
5371
+ discountList.push.apply(discountList, _toConsumableArray((item === null || item === void 0 ? void 0 : item.discount_list) || []));
5086
5372
  });
5087
5373
  ((product === null || product === void 0 || (_product$_extend = product._extend) === null || _product$_extend === void 0 || (_product$_extend = _product$_extend.other) === null || _product$_extend === void 0 ? void 0 : _product$_extend.bundle) || []).forEach(function (item) {
5088
- bundleDiscountList.push.apply(bundleDiscountList, _toConsumableArray((item === null || item === void 0 ? void 0 : item.discount_list) || []));
5374
+ discountList.push.apply(discountList, _toConsumableArray((item === null || item === void 0 ? void 0 : item.discount_list) || []));
5375
+ });
5376
+ return discountList.filter(function (item) {
5377
+ return isFullCoveragePass(item);
5089
5378
  });
5090
- return bundleDiscountList.some(function (item) {
5091
- return (item === null || item === void 0 ? void 0 : item.type) === 'good_pass' || (item === null || item === void 0 ? void 0 : item.tag) === 'good_pass';
5379
+ }
5380
+ }, {
5381
+ key: "hasEntitlementPassDiscount",
5382
+ value: function hasEntitlementPassDiscount(product) {
5383
+ return this.getFullCoveragePassDiscounts(product).some(function (item) {
5384
+ return isEntitlementPass(item);
5385
+ });
5386
+ }
5387
+ }, {
5388
+ key: "hasGoodPassDiscount",
5389
+ value: function hasGoodPassDiscount(product) {
5390
+ return this.getFullCoveragePassDiscounts(product).some(function (item) {
5391
+ return !isEntitlementPass(item);
5092
5392
  });
5093
5393
  }
5394
+ }, {
5395
+ key: "isPersistedProductLine",
5396
+ value: function isPersistedProductLine(product) {
5397
+ var _product$metadata11;
5398
+ return product.order_detail_id !== undefined && product.order_detail_id !== null && product.order_detail_id !== '' || ((_product$metadata11 = product.metadata) === null || _product$metadata11 === void 0 ? void 0 : _product$metadata11.is_edit_for_runtime) === true;
5399
+ }
5400
+ }, {
5401
+ key: "isRuntimeEntitlementAppend",
5402
+ value: function isRuntimeEntitlementAppend(product, tempOrder) {
5403
+ var _product$metadata$uni, _product$metadata12, _tempOrder$_extend10, _product$_origin;
5404
+ if (this.isPersistedProductLine(product)) return false;
5405
+ var uid = (_product$metadata$uni = (_product$metadata12 = product.metadata) === null || _product$metadata12 === void 0 ? void 0 : _product$metadata12.unique_identification_number) !== null && _product$metadata$uni !== void 0 ? _product$metadata$uni : product.unique_identification_number;
5406
+ var storedOrigin = uid !== undefined && uid !== null && uid !== '' ? (_tempOrder$_extend10 = tempOrder._extend) === null || _tempOrder$_extend10 === void 0 || (_tempOrder$_extend10 = _tempOrder$_extend10.productsByUid) === null || _tempOrder$_extend10 === void 0 || (_tempOrder$_extend10 = _tempOrder$_extend10[String(uid)]) === null || _tempOrder$_extend10 === void 0 ? void 0 : _tempOrder$_extend10.origin : undefined;
5407
+ return Boolean((product === null || product === void 0 || (_product$_origin = product._origin) === null || _product$_origin === void 0 ? void 0 : _product$_origin.__entitlementPassRuntimeAppend) === true || (storedOrigin === null || storedOrigin === void 0 ? void 0 : storedOrigin.__entitlementPassRuntimeAppend) === true);
5408
+ }
5409
+ }, {
5410
+ key: "hasSameEntitlementMergePriceConfig",
5411
+ value: function hasSameEntitlementMergePriceConfig(incoming, existing) {
5412
+ var _this34 = this;
5413
+ var buildPriceConfig = function buildPriceConfig(product) {
5414
+ var metadata = product.metadata || {};
5415
+ var bundle = (product.product_bundle || []).map(function (item) {
5416
+ var _ref73, _item$bundle_id, _ref74, _ref75, _item$bundle_product_, _ref76, _item$bundle_variant_, _ref77, _item$price_type, _ref78, _item$price_type_ext;
5417
+ return {
5418
+ bundle_id: (_ref73 = (_item$bundle_id = item.bundle_id) !== null && _item$bundle_id !== void 0 ? _item$bundle_id : item.id) !== null && _ref73 !== void 0 ? _ref73 : null,
5419
+ bundle_product_id: (_ref74 = (_ref75 = (_item$bundle_product_ = item.bundle_product_id) !== null && _item$bundle_product_ !== void 0 ? _item$bundle_product_ : item._bundle_product_id) !== null && _ref75 !== void 0 ? _ref75 : item.product_id) !== null && _ref74 !== void 0 ? _ref74 : null,
5420
+ bundle_variant_id: (_ref76 = (_item$bundle_variant_ = item.bundle_variant_id) !== null && _item$bundle_variant_ !== void 0 ? _item$bundle_variant_ : item.product_variant_id) !== null && _ref76 !== void 0 ? _ref76 : 0,
5421
+ price_type: (_ref77 = (_item$price_type = item.price_type) !== null && _item$price_type !== void 0 ? _item$price_type : item.custom_price_type) !== null && _ref77 !== void 0 ? _ref77 : '',
5422
+ price_type_ext: (_ref78 = (_item$price_type_ext = item.price_type_ext) !== null && _item$price_type_ext !== void 0 ? _item$price_type_ext : item.custom_price_type_ext) !== null && _ref78 !== void 0 ? _ref78 : ''
5423
+ };
5424
+ }).sort(function (left, right) {
5425
+ return JSON.stringify(left).localeCompare(JSON.stringify(right));
5426
+ });
5427
+ return JSON.stringify({
5428
+ original_price: _this34.normalizeFingerprintMoney(product.original_price),
5429
+ source_product_price: _this34.normalizeFingerprintMoney(metadata.source_product_price),
5430
+ main_product_original_price: _this34.normalizeFingerprintMoney(metadata.main_product_original_price),
5431
+ price_override: _this34.normalizeFingerprintMoney(metadata.price_override),
5432
+ is_manual_discount: Boolean(metadata.is_manual_discount),
5433
+ bundle: bundle
5434
+ });
5435
+ };
5436
+ return buildPriceConfig(incoming) === buildPriceConfig(existing);
5437
+ }
5094
5438
  }, {
5095
5439
  key: "getBundleRuntimeIdentity",
5096
5440
  value: function getBundleRuntimeIdentity(bundle) {
5097
- var _ref66, _bundle$bundle_id2, _ref67, _bundle$bundle_group_2, _ref68, _ref69, _bundle$bundle_produc3, _ref70, _bundle$bundle_varian3;
5441
+ var _ref79, _bundle$bundle_id2, _ref80, _bundle$bundle_group_2, _ref81, _ref82, _bundle$bundle_produc3, _ref83, _bundle$bundle_varian3;
5098
5442
  if (!bundle || _typeof(bundle) !== 'object') return '';
5099
- return [(_ref66 = (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id) !== null && _ref66 !== void 0 ? _ref66 : '', (_ref67 = (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id) !== null && _ref67 !== void 0 ? _ref67 : '', (_ref68 = (_ref69 = (_bundle$bundle_produc3 = bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle._bundle_product_id) !== null && _ref69 !== void 0 ? _ref69 : bundle.product_id) !== null && _ref68 !== void 0 ? _ref68 : '', (_ref70 = (_bundle$bundle_varian3 = bundle.bundle_variant_id) !== null && _bundle$bundle_varian3 !== void 0 ? _bundle$bundle_varian3 : bundle.product_variant_id) !== null && _ref70 !== void 0 ? _ref70 : 0].join('|');
5443
+ return [(_ref79 = (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id) !== null && _ref79 !== void 0 ? _ref79 : '', (_ref80 = (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id) !== null && _ref80 !== void 0 ? _ref80 : '', (_ref81 = (_ref82 = (_bundle$bundle_produc3 = bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle._bundle_product_id) !== null && _ref82 !== void 0 ? _ref82 : bundle.product_id) !== null && _ref81 !== void 0 ? _ref81 : '', (_ref83 = (_bundle$bundle_varian3 = bundle.bundle_variant_id) !== null && _bundle$bundle_varian3 !== void 0 ? _bundle$bundle_varian3 : bundle.product_variant_id) !== null && _ref83 !== void 0 ? _ref83 : 0].join('|');
5100
5444
  }
5101
5445
  }, {
5102
5446
  key: "preservePersistedBundlePriceFields",
5103
5447
  value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
5104
- var _this31 = this;
5448
+ var _this35 = this;
5105
5449
  if (!Array.isArray(nextBundles)) return nextBundles;
5106
5450
  if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
5107
5451
  var previousByIdentity = new Map();
5108
5452
  previousBundles.forEach(function (bundle) {
5109
- var identity = _this31.getBundleRuntimeIdentity(bundle);
5453
+ var identity = _this35.getBundleRuntimeIdentity(bundle);
5110
5454
  if (identity) previousByIdentity.set(identity, bundle);
5111
5455
  });
5112
5456
  return nextBundles.map(function (bundle, index) {
5113
5457
  if (!bundle || _typeof(bundle) !== 'object') return bundle;
5114
- var previous = previousByIdentity.get(_this31.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
5458
+ var previous = previousByIdentity.get(_this35.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
5115
5459
  if (!previous || _typeof(previous) !== 'object') return bundle;
5116
5460
  return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
5117
5461
  cover: previous.cover
@@ -5214,10 +5558,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5214
5558
  var weighedSourcePrice = callerChangesWeighing ? resolveWeighedSourcePrice(nextProduct.product_sku) : undefined;
5215
5559
  var hasResolvedWeighedPrice = weighedSourcePrice !== undefined;
5216
5560
  if (hasResolvedWeighedPrice && !callerUpdatesSourcePrice) {
5217
- var _ref71, _targetProduct$metada3, _targetProduct$metada4, _ref72, _targetProduct$metada5, _targetProduct$metada6;
5561
+ var _ref84, _targetProduct$metada3, _targetProduct$metada4, _ref85, _targetProduct$metada5, _targetProduct$metada6;
5218
5562
  var nextMainOriginal = new Decimal(weighedSourcePrice).plus(sumOptionUnitPrice(getProductSkuOptions(nextProduct)));
5219
- var previousMainOriginal = new Decimal((_ref71 = (_targetProduct$metada3 = (_targetProduct$metada4 = targetProduct.metadata) === null || _targetProduct$metada4 === void 0 ? void 0 : _targetProduct$metada4.main_product_original_price) !== null && _targetProduct$metada3 !== void 0 ? _targetProduct$metada3 : targetProduct.original_price) !== null && _ref71 !== void 0 ? _ref71 : 0);
5220
- var previousMainSelling = new Decimal((_ref72 = (_targetProduct$metada5 = (_targetProduct$metada6 = targetProduct.metadata) === null || _targetProduct$metada6 === void 0 ? void 0 : _targetProduct$metada6.main_product_selling_price) !== null && _targetProduct$metada5 !== void 0 ? _targetProduct$metada5 : targetProduct.selling_price) !== null && _ref72 !== void 0 ? _ref72 : 0);
5563
+ var previousMainOriginal = new Decimal((_ref84 = (_targetProduct$metada3 = (_targetProduct$metada4 = targetProduct.metadata) === null || _targetProduct$metada4 === void 0 ? void 0 : _targetProduct$metada4.main_product_original_price) !== null && _targetProduct$metada3 !== void 0 ? _targetProduct$metada3 : targetProduct.original_price) !== null && _ref84 !== void 0 ? _ref84 : 0);
5564
+ var previousMainSelling = new Decimal((_ref85 = (_targetProduct$metada5 = (_targetProduct$metada6 = targetProduct.metadata) === null || _targetProduct$metada6 === void 0 ? void 0 : _targetProduct$metada6.main_product_selling_price) !== null && _targetProduct$metada5 !== void 0 ? _targetProduct$metada5 : targetProduct.selling_price) !== null && _ref85 !== void 0 ? _ref85 : 0);
5221
5565
  // A manual final price remains fixed; other legacy discounts keep their amount
5222
5566
  // until Rules reapplies the currently selected wallet discount below.
5223
5567
  var nextMainSelling = isManualProductDiscountProduct(nextProduct) ? previousMainSelling : nextMainOriginal.minus(previousMainOriginal.minus(previousMainSelling));
@@ -5265,13 +5609,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5265
5609
  delete nextProduct.metadata.main_product_original_price;
5266
5610
  delete nextProduct.metadata.price_schema_version;
5267
5611
  } else if (callerChangesLineConfiguration && !hasResolvedWeighedPrice && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
5268
- var _ref73, _targetProduct$metada15, _targetProduct$metada16, _ref74, _targetProduct$metada17, _targetProduct$metada18, _targetProduct$metada19;
5612
+ var _ref86, _targetProduct$metada15, _targetProduct$metada16, _ref87, _targetProduct$metada17, _targetProduct$metada18, _targetProduct$metada19;
5269
5613
  // 仅 option / bundle 变化时,保留历史 source 和主商品折扣金额,
5270
5614
  // 但必须让 original 与 selling 一起随新的 option 金额移动。
5271
5615
  var previousOptionSum = sumOptionUnitPrice(getProductSkuOptions(targetProduct));
5272
5616
  var nextOptionSum = sumOptionUnitPrice(getProductSkuOptions(nextProduct));
5273
- var _previousMainOriginal2 = new Decimal(Number((_ref73 = (_targetProduct$metada15 = (_targetProduct$metada16 = targetProduct.metadata) === null || _targetProduct$metada16 === void 0 ? void 0 : _targetProduct$metada16.main_product_original_price) !== null && _targetProduct$metada15 !== void 0 ? _targetProduct$metada15 : targetProduct.original_price) !== null && _ref73 !== void 0 ? _ref73 : 0) || 0);
5274
- var _previousMainSelling2 = new Decimal(Number((_ref74 = (_targetProduct$metada17 = (_targetProduct$metada18 = targetProduct.metadata) === null || _targetProduct$metada18 === void 0 ? void 0 : _targetProduct$metada18.main_product_selling_price) !== null && _targetProduct$metada17 !== void 0 ? _targetProduct$metada17 : targetProduct.selling_price) !== null && _ref74 !== void 0 ? _ref74 : _previousMainOriginal2.toNumber()) || 0);
5617
+ var _previousMainOriginal2 = new Decimal(Number((_ref86 = (_targetProduct$metada15 = (_targetProduct$metada16 = targetProduct.metadata) === null || _targetProduct$metada16 === void 0 ? void 0 : _targetProduct$metada16.main_product_original_price) !== null && _targetProduct$metada15 !== void 0 ? _targetProduct$metada15 : targetProduct.original_price) !== null && _ref86 !== void 0 ? _ref86 : 0) || 0);
5618
+ var _previousMainSelling2 = new Decimal(Number((_ref87 = (_targetProduct$metada17 = (_targetProduct$metada18 = targetProduct.metadata) === null || _targetProduct$metada18 === void 0 ? void 0 : _targetProduct$metada18.main_product_selling_price) !== null && _targetProduct$metada17 !== void 0 ? _targetProduct$metada17 : targetProduct.selling_price) !== null && _ref87 !== void 0 ? _ref87 : _previousMainOriginal2.toNumber()) || 0);
5275
5619
  var _preservedDiscount = _previousMainOriginal2.minus(_previousMainSelling2);
5276
5620
  var previousSource = ((_targetProduct$metada19 = targetProduct.metadata) === null || _targetProduct$metada19 === void 0 ? void 0 : _targetProduct$metada19.source_product_price) != null ? new Decimal(Number(targetProduct.metadata.source_product_price) || 0) : _previousMainOriginal2.minus(previousOptionSum);
5277
5621
  var _nextMainOriginal2 = previousSource.plus(nextOptionSum);
@@ -5321,7 +5665,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5321
5665
  // normalizeOrderProduct 幂等:v2 metadata 存在 → 保留 main_product_* 折扣重算 composite;
5322
5666
  // 否则 → 把顶层 selling_price 视作 source,派生 main_product_* 并写 price_schema_version: 2。
5323
5667
  var normalizedProduct = this.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(nextProduct, normalizeOrderProduct(nextProduct)));
5324
- normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
5668
+ normalizedProduct.discount_list = normalizeOrderProductDiscountList(isPersistedOrderLine ? syncReducedEntitlementPassUsageCount(normalizedProduct.discount_list, targetProduct.num, normalizedProduct.num) : normalizedProduct.discount_list);
5325
5669
  var preservedBookingUid = nextProduct.booking_uid || ((_nextProduct$metadata2 = nextProduct.metadata) === null || _nextProduct$metadata2 === void 0 ? void 0 : _nextProduct$metadata2.booking_uid) || targetProduct.booking_uid || ((_targetProduct$metada20 = targetProduct.metadata) === null || _targetProduct$metada20 === void 0 ? void 0 : _targetProduct$metada20.booking_uid);
5326
5670
  if (!booking && preservedBookingUid) {
5327
5671
  normalizedProduct.booking_uid = preservedBookingUid;
@@ -5407,7 +5751,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5407
5751
  key: "updateOrderProducts",
5408
5752
  value: function () {
5409
5753
  var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(paramsList) {
5410
- var _this32 = this;
5754
+ var _this36 = this;
5411
5755
  var tempOrder, reapplyWeighedDiscountProductUids, reapplyBookingDiscountProductUids;
5412
5756
  return _regeneratorRuntime().wrap(function _callee26$(_context28) {
5413
5757
  while (1) switch (_context28.prev = _context28.next) {
@@ -5421,7 +5765,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5421
5765
  case 3:
5422
5766
  reapplyWeighedDiscountProductUids = [];
5423
5767
  reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
5424
- var updatedProductUid = _this32.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
5768
+ var updatedProductUid = _this36.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
5425
5769
  // 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
5426
5770
  if (params.allow_booking_discount_reapply && updatedProductUid) {
5427
5771
  acc.push(String(updatedProductUid));
@@ -5454,7 +5798,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5454
5798
  value: function () {
5455
5799
  var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
5456
5800
  var _targetProduct$metada22;
5457
- var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct, settlementSnapshot, currencyProductId, asset, requiredAmount, balance, isVirtualSettlement, promotionPayload;
5801
+ var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, isPersistedOrderLine, normalizedProduct, settlementSnapshot, currencyProductId, asset, requiredAmount, balance, isVirtualSettlement, promotionPayload;
5458
5802
  return _regeneratorRuntime().wrap(function _callee27$(_context29) {
5459
5803
  while (1) switch (_context29.prev = _context29.next) {
5460
5804
  case 0:
@@ -5492,16 +5836,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5492
5836
  throw new Error('[Order] 目标商品不存在,无法更新数量');
5493
5837
  case 13:
5494
5838
  targetProduct = tempOrder.products[productIndex];
5839
+ isPersistedOrderLine = targetProduct.order_detail_id !== undefined && targetProduct.order_detail_id !== null;
5495
5840
  normalizedProduct = this.normalizeVirtualSettlementProductIfEnabled(normalizeOrderProduct(_objectSpread(_objectSpread({}, targetProduct), {}, {
5496
5841
  num: getSafeProductNum(num),
5497
5842
  metadata: _objectSpread(_objectSpread({}, targetProduct.metadata || {}), {}, {
5498
5843
  unique_identification_number: ((_targetProduct$metada22 = targetProduct.metadata) === null || _targetProduct$metada22 === void 0 ? void 0 : _targetProduct$metada22.unique_identification_number) || unique_identification_number
5499
5844
  })
5500
5845
  })));
5501
- normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
5846
+ normalizedProduct.discount_list = normalizeOrderProductDiscountList(isPersistedOrderLine ? syncReducedEntitlementPassUsageCount(normalizedProduct.discount_list, targetProduct.num, normalizedProduct.num) : normalizedProduct.discount_list);
5502
5847
  settlementSnapshot = getSelectedSettlementSnapshot(normalizedProduct);
5503
5848
  if (!(this.isMultiCurrencySettlementEnabled() && (settlementSnapshot === null || settlementSnapshot === void 0 ? void 0 : settlementSnapshot.settlement_type) === 'virtual_currency' && tempOrder.customer_id && Number(tempOrder.customer_id) !== 1)) {
5504
- _context29.next = 26;
5849
+ _context29.next = 27;
5505
5850
  break;
5506
5851
  }
5507
5852
  currencyProductId = Number(settlementSnapshot.currency_product_id);
@@ -5509,11 +5854,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5509
5854
  return Number(item === null || item === void 0 ? void 0 : item.product_id) === currencyProductId;
5510
5855
  });
5511
5856
  if (asset) {
5512
- _context29.next = 22;
5857
+ _context29.next = 23;
5513
5858
  break;
5514
5859
  }
5515
5860
  throw new VirtualCurrencyAssetNotFoundError(currencyProductId);
5516
- case 22:
5861
+ case 23:
5517
5862
  requiredAmount = tempOrder.products.reduce(function (sum, item, index) {
5518
5863
  var current = index === productIndex ? normalizedProduct : item;
5519
5864
  var currentSnapshot = getSelectedSettlementSnapshot(current);
@@ -5521,44 +5866,44 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5521
5866
  }, new Decimal(0));
5522
5867
  balance = new Decimal(asset.balance || 0);
5523
5868
  if (!balance.lt(requiredAmount)) {
5524
- _context29.next = 26;
5869
+ _context29.next = 27;
5525
5870
  break;
5526
5871
  }
5527
5872
  throw new VirtualCurrencyBalanceError(balance.toFixed(2), requiredAmount.toFixed(2));
5528
- case 26:
5873
+ case 27:
5529
5874
  tempOrder.products[productIndex] = normalizedProduct;
5530
5875
  this.prepareVirtualSettlementTempOrder(tempOrder);
5531
5876
  isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder);
5532
5877
  if (isVirtualSettlement) {
5533
- _context29.next = 35;
5878
+ _context29.next = 36;
5534
5879
  break;
5535
5880
  }
5536
- _context29.next = 32;
5881
+ _context29.next = 33;
5537
5882
  return this.evaluatePromotion();
5538
- case 32:
5883
+ case 33:
5539
5884
  _context29.t0 = _context29.sent;
5540
- _context29.next = 36;
5885
+ _context29.next = 37;
5541
5886
  break;
5542
- case 35:
5543
- _context29.t0 = null;
5544
5887
  case 36:
5888
+ _context29.t0 = null;
5889
+ case 37:
5545
5890
  promotionPayload = _context29.t0;
5546
5891
  if (!isVirtualSettlement) {
5547
5892
  this.applyDiscount();
5548
5893
  }
5549
5894
  this.sanitizeTempOrderProducts(tempOrder);
5550
- _context29.next = 41;
5895
+ _context29.next = 42;
5551
5896
  return this.recalculateSummary({
5552
5897
  createIfMissing: true
5553
5898
  });
5554
- case 41:
5899
+ case 42:
5555
5900
  this.persistTempOrder();
5556
5901
  this.emitPromotionApplied(promotionPayload);
5557
5902
  this.logInfo('updateOrderProductQuantity success', {
5558
5903
  params: params
5559
5904
  });
5560
5905
  return _context29.abrupt("return", tempOrder.products);
5561
- case 45:
5906
+ case 46:
5562
5907
  case "end":
5563
5908
  return _context29.stop();
5564
5909
  }
@@ -5649,7 +5994,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5649
5994
  key: "removeProductsFromOrder",
5650
5995
  value: (function () {
5651
5996
  var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(identities, options) {
5652
- var _this33 = this;
5997
+ var _this37 = this;
5653
5998
  var tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
5654
5999
  return _regeneratorRuntime().wrap(function _callee29$(_context32) {
5655
6000
  while (1) switch (_context32.prev = _context32.next) {
@@ -5714,7 +6059,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5714
6059
  }
5715
6060
  if (productUid !== undefined && productUid !== null && productUid !== '') {
5716
6061
  bookingsBeforeRemove.forEach(function (booking) {
5717
- var bookingUid = _this33.getBookingUniqueIdentificationNumber(booking);
6062
+ var bookingUid = _this37.getBookingUniqueIdentificationNumber(booking);
5718
6063
  if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
5719
6064
  linkedBookingUidsToRemove.add(bookingUid);
5720
6065
  }
@@ -5929,23 +6274,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5929
6274
  }, {
5930
6275
  key: "buildCurrentSubmitPayloadForLocalPrint",
5931
6276
  value: function buildCurrentSubmitPayloadForLocalPrint(params) {
5932
- var _params$cacheId, _this$otherParams5, _ref75, _params$businessCode, _this$otherParams6, _this$otherParams7;
6277
+ var _params$cacheId, _this$otherParams5, _ref88, _params$businessCode, _this$otherParams6, _this$otherParams7;
5933
6278
  var tempOrder = this.ensureTempOrder();
5934
6279
  this.persistTempOrder();
5935
6280
  var payload = buildSubmitPayload({
5936
6281
  tempOrder: tempOrder,
5937
6282
  cacheId: (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId,
5938
6283
  platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.platform),
5939
- businessCode: (_ref75 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.businessCode) !== null && _ref75 !== void 0 ? _ref75 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.business_code,
6284
+ businessCode: (_ref88 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.businessCode) !== null && _ref88 !== void 0 ? _ref88 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.business_code,
5940
6285
  channel: params === null || params === void 0 ? void 0 : params.channel,
5941
6286
  type: params === null || params === void 0 ? void 0 : params.type,
5942
6287
  summary: this.store.summary || createEmptySummary(),
5943
6288
  enhance: function enhance(nextPayload) {
5944
- var _ref76, _tempOrder$order_numb, _ref77, _tempOrder$shop_order2, _ref78, _tempOrder$shop_full_;
6289
+ var _ref89, _tempOrder$order_numb, _ref90, _tempOrder$shop_order2, _ref91, _tempOrder$shop_full_;
5945
6290
  return _objectSpread(_objectSpread({}, nextPayload), {}, {
5946
- order_number: (_ref76 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref76 !== void 0 ? _ref76 : null,
5947
- shop_order_number: (_ref77 = (_tempOrder$shop_order2 = tempOrder.shop_order_number) !== null && _tempOrder$shop_order2 !== void 0 ? _tempOrder$shop_order2 : nextPayload.shop_order_number) !== null && _ref77 !== void 0 ? _ref77 : null,
5948
- shop_full_order_number: (_ref78 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref78 !== void 0 ? _ref78 : null,
6291
+ order_number: (_ref89 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref89 !== void 0 ? _ref89 : null,
6292
+ shop_order_number: (_ref90 = (_tempOrder$shop_order2 = tempOrder.shop_order_number) !== null && _tempOrder$shop_order2 !== void 0 ? _tempOrder$shop_order2 : nextPayload.shop_order_number) !== null && _ref90 !== void 0 ? _ref90 : null,
6293
+ shop_full_order_number: (_ref91 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref91 !== void 0 ? _ref91 : null,
5949
6294
  small_ticket_data_flag: 1
5950
6295
  });
5951
6296
  }
@@ -6109,7 +6454,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6109
6454
  key: "runSubmitTempOrder",
6110
6455
  value: function () {
6111
6456
  var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
6112
- var _params$cacheId3, _this$otherParams12, _ref79, _ref80, _submitSnapshot$busin, _this$otherParams13, _this$otherParams14, _submitSnapshot$type;
6457
+ var _params$cacheId3, _this$otherParams12, _ref92, _ref93, _submitSnapshot$busin, _this$otherParams13, _this$otherParams14, _submitSnapshot$type;
6113
6458
  var tempOrder, isOnlineStorePlatform, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, shouldOverridePaymentStatus, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, isLocalPendingSubmit, salesNotesState, submittedOrderId, resultRecord;
6114
6459
  return _regeneratorRuntime().wrap(function _callee37$(_context40) {
6115
6460
  while (1) switch (_context40.prev = _context40.next) {
@@ -6176,7 +6521,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6176
6521
  tempOrder: tempOrder,
6177
6522
  cacheId: effectiveCacheId,
6178
6523
  platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.platform),
6179
- businessCode: (_ref79 = (_ref80 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref80 !== void 0 ? _ref80 : (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.businessCode) !== null && _ref79 !== void 0 ? _ref79 : (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.business_code,
6524
+ businessCode: (_ref92 = (_ref93 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref93 !== void 0 ? _ref93 : (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.businessCode) !== null && _ref92 !== void 0 ? _ref92 : (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.business_code,
6180
6525
  channel: params === null || params === void 0 ? void 0 : params.channel,
6181
6526
  type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
6182
6527
  summary: latestSummary,
@@ -6346,10 +6691,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6346
6691
  value: function extractSubmitErrorResponse(error) {
6347
6692
  var _error$response,
6348
6693
  _error$response2,
6349
- _this34 = this;
6694
+ _this38 = this;
6350
6695
  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];
6351
6696
  return candidates.find(function (candidate) {
6352
- return _this34.isSubmitErrorResponse(candidate);
6697
+ return _this38.isSubmitErrorResponse(candidate);
6353
6698
  }) || null;
6354
6699
  }
6355
6700
  }, {
@@ -6377,7 +6722,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6377
6722
  key: "syncPaymentsToOrder",
6378
6723
  value: function () {
6379
6724
  var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
6380
- var _this35 = this,
6725
+ var _this39 = this,
6381
6726
  _params$confirmPendin;
6382
6727
  var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, enhancePayload, submitParams, submitResult;
6383
6728
  return _regeneratorRuntime().wrap(function _callee39$(_context42) {
@@ -6402,7 +6747,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6402
6747
  case 9:
6403
6748
  devicePrefix = _context42.t0;
6404
6749
  mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
6405
- return _this35.normalizePaymentSource(payment, {
6750
+ return _this39.normalizePaymentSource(payment, {
6406
6751
  defaultPaid: false,
6407
6752
  devicePrefix: devicePrefix
6408
6753
  });
@@ -6481,7 +6826,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6481
6826
  }, {
6482
6827
  key: "createOrder",
6483
6828
  value: function createOrder(params) {
6484
- var _this36 = this;
6829
+ var _this40 = this;
6485
6830
  var order = _objectSpread({
6486
6831
  type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
6487
6832
  // 要从外面拿,virtual
@@ -6513,7 +6858,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6513
6858
 
6514
6859
  // 为预约补齐 holder 信息
6515
6860
  if (params !== null && params !== void 0 && (_params$extraData = params.extraData) !== null && _params$extraData !== void 0 && _params$extraData.is_add_holder_info) {
6516
- ensureCartItemOriginHolder(item, _this36.window);
6861
+ ensureCartItemOriginHolder(item, _this40.window);
6517
6862
  }
6518
6863
 
6519
6864
  // 购物车是否为普通商品
@@ -6813,17 +7158,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6813
7158
  key: "submitSalesOrder",
6814
7159
  value: function () {
6815
7160
  var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(params) {
6816
- var url, query, fetchUrl;
7161
+ var url, query, fetchUrl, requestQuery;
6817
7162
  return _regeneratorRuntime().wrap(function _callee44$(_context47) {
6818
7163
  while (1) switch (_context47.prev = _context47.next) {
6819
7164
  case 0:
6820
7165
  url = params.url, query = params.query;
6821
7166
  fetchUrl = url || '/order/sales/checkout';
6822
- return _context47.abrupt("return", this.request.post(fetchUrl, query, {
7167
+ requestQuery = this.isSalesCheckoutHandledByOsServer(fetchUrl) ? query : stripOsPrivatePayloadFields(query);
7168
+ return _context47.abrupt("return", this.request.post(fetchUrl, requestQuery, {
6823
7169
  osServer: true,
6824
7170
  customToast: function customToast() {}
6825
7171
  }));
6826
- case 3:
7172
+ case 4:
6827
7173
  case "end":
6828
7174
  return _context47.stop();
6829
7175
  }
@@ -6834,6 +7180,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6834
7180
  }
6835
7181
  return submitSalesOrder;
6836
7182
  }()
7183
+ }, {
7184
+ key: "isSalesCheckoutHandledByOsServer",
7185
+ value: function isSalesCheckoutHandledByOsServer(fetchUrl) {
7186
+ var _this$core2, _this$request;
7187
+ var server = (_this$core2 = this.core) === null || _this$core2 === void 0 ? void 0 : _this$core2.server;
7188
+ if (!server || typeof server.hasRoute !== 'function') return false;
7189
+ var requestBaseUrl = String(((_this$request = this.request) === null || _this$request === void 0 ? void 0 : _this$request.baseUrl) || '/shop').replace(/\/+$/, '');
7190
+ if (!requestBaseUrl.startsWith('/')) return false;
7191
+ var normalizedFetchUrl = fetchUrl.startsWith('/') ? fetchUrl : "/".concat(fetchUrl);
7192
+ var routePath = normalizedFetchUrl === requestBaseUrl || normalizedFetchUrl.startsWith("".concat(requestBaseUrl, "/")) ? normalizedFetchUrl : "".concat(requestBaseUrl).concat(normalizedFetchUrl);
7193
+ return server.hasRoute('post', routePath) === true;
7194
+ }
7195
+
6837
7196
  /**
6838
7197
  * 发送支付链接邮件。
6839
7198
  *
@@ -6975,8 +7334,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6975
7334
  allowUnresolvedSalesNotes: isSessionStorageHydrate
6976
7335
  });
6977
7336
  this.store.tempOrder = nextTempOrder;
7337
+ this.clearCustomerWalletRuntimeState();
6978
7338
  if (!isSessionStorageHydrate) {
6979
- _context50.next = 30;
7339
+ _context50.next = 31;
6980
7340
  break;
6981
7341
  }
6982
7342
  // 会话快照是未提交购物车,不应获得编辑订单的 saved/edit 标记与服务端基线。
@@ -6992,24 +7352,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6992
7352
  nextTempOrder.discount_list = restoredSessionDiscounts;
6993
7353
  this.store.summary = createEmptySummary();
6994
7354
  this.store.lastOrderInfo = undefined;
6995
- _context50.next = 23;
7355
+ _context50.next = 24;
6996
7356
  return (_this$store$discount24 = this.store.discount) === null || _this$store$discount24 === void 0 ? void 0 : _this$store$discount24.setOriginalDiscountList(cloneDeep(restoredSessionDiscounts));
6997
- case 23:
6998
- _context50.next = 25;
7357
+ case 24:
7358
+ _context50.next = 26;
6999
7359
  return (_this$store$discount25 = this.store.discount) === null || _this$store$discount25 === void 0 ? void 0 : _this$store$discount25.setDiscountList(cloneDeep(restoredSessionDiscounts));
7000
- case 25:
7360
+ case 26:
7001
7361
  if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
7002
- _context50.next = 28;
7362
+ _context50.next = 29;
7003
7363
  break;
7004
7364
  }
7005
- _context50.next = 28;
7365
+ _context50.next = 29;
7006
7366
  return this.recalculateSummary({
7007
7367
  createIfMissing: false
7008
7368
  });
7009
- case 28:
7369
+ case 29:
7010
7370
  this.persistTempOrder();
7011
7371
  return _context50.abrupt("return", nextTempOrder);
7012
- case 30:
7372
+ case 31:
7013
7373
  // Server list compatibility may synthesize order_id from external_sale_number; tempOrder must not.
7014
7374
  sourceLastOrderInfo = sourceRaw.lastOrderInfo || sourceRaw;
7015
7375
  isDraftOrder = Number(nextTempOrder.is_draft_order || 0) === 1;
@@ -7060,28 +7420,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7060
7420
  nextDiscounts = [].concat(_toConsumableArray(hydratedEditDiscounts), _toConsumableArray(retainedScanDiscounts));
7061
7421
  shouldSkipEmptyDiscountSync = nextDiscounts.length === 0 && currentDiscounts.length === 0;
7062
7422
  if (shouldSkipEmptyDiscountSync) {
7063
- _context50.next = 54;
7423
+ _context50.next = 55;
7064
7424
  break;
7065
7425
  }
7066
7426
  OrderModule.populateSavedAmounts(nextTempOrder.products, nextDiscounts);
7067
- _context50.next = 52;
7427
+ _context50.next = 53;
7068
7428
  return (_this$store$discount27 = this.store.discount) === null || _this$store$discount27 === void 0 ? void 0 : _this$store$discount27.setOriginalDiscountList(nextDiscounts);
7069
- case 52:
7070
- _context50.next = 54;
7429
+ case 53:
7430
+ _context50.next = 55;
7071
7431
  return (_this$store$discount28 = this.store.discount) === null || _this$store$discount28 === void 0 ? void 0 : _this$store$discount28.setDiscountList(nextDiscounts);
7072
- case 54:
7432
+ case 55:
7073
7433
  if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
7074
- _context50.next = 57;
7434
+ _context50.next = 58;
7075
7435
  break;
7076
7436
  }
7077
- _context50.next = 57;
7437
+ _context50.next = 58;
7078
7438
  return this.recalculateSummary({
7079
7439
  createIfMissing: false
7080
7440
  });
7081
- case 57:
7441
+ case 58:
7082
7442
  this.persistTempOrder();
7083
7443
  return _context50.abrupt("return", nextTempOrder);
7084
- case 59:
7444
+ case 60:
7085
7445
  case "end":
7086
7446
  return _context50.stop();
7087
7447
  }
@@ -7140,10 +7500,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7140
7500
  _step22;
7141
7501
  try {
7142
7502
  for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
7143
- var _product$metadata11;
7503
+ var _product$metadata13;
7144
7504
  var product = _step22.value;
7145
7505
  var productUid = getOrderCollectionUid('product', product);
7146
- var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata11 = product.metadata) === null || _product$metadata11 === void 0 ? void 0 : _product$metadata11.booking_uid);
7506
+ var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata13 = product.metadata) === null || _product$metadata13 === void 0 ? void 0 : _product$metadata13.booking_uid);
7147
7507
  if (!productUid || bookingUid === undefined || bookingUid === null || bookingUid === '') {
7148
7508
  continue;
7149
7509
  }
@@ -7201,7 +7561,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7201
7561
  }, {
7202
7562
  key: "normalizeTempOrderForRuntime",
7203
7563
  value: function normalizeTempOrderForRuntime(raw, options) {
7204
- var _this37 = this,
7564
+ var _this41 = this,
7205
7565
  _raw$_extend;
7206
7566
  var runtimeRaw = this.withoutSyntheticDraftOrderIdForRuntime(raw);
7207
7567
  var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
@@ -7226,12 +7586,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7226
7586
  nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
7227
7587
  var rawProducts = Array.isArray(raw.products) ? raw.products : [];
7228
7588
  nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
7229
- return _this37.normalizeHydratedOrderProduct(p, {
7589
+ return _this41.normalizeHydratedOrderProduct(p, {
7230
7590
  makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
7231
7591
  });
7232
7592
  }) : [];
7233
7593
  nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
7234
- var booking = _this37.normalizeHydratedBookingHolder(b || {});
7594
+ var booking = _this41.normalizeHydratedBookingHolder(b || {});
7235
7595
  return _objectSpread(_objectSpread({}, booking), {}, {
7236
7596
  is_all: normalizeBookingIsAll(booking),
7237
7597
  sub_type: normalizeBookingSubType(booking)
@@ -7281,15 +7641,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7281
7641
  _step24;
7282
7642
  try {
7283
7643
  for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
7284
- var _product$metadata12, _ref81, _ref82, _existed$origin, _rawProduct$metadata;
7644
+ var _product$metadata14, _ref94, _ref95, _existed$origin, _rawProduct$metadata;
7285
7645
  var _step24$value = _slicedToArray(_step24.value, 2),
7286
7646
  index = _step24$value[0],
7287
7647
  product = _step24$value[1];
7288
- var uid = (_product$metadata12 = product.metadata) === null || _product$metadata12 === void 0 ? void 0 : _product$metadata12.unique_identification_number;
7648
+ var uid = (_product$metadata14 = product.metadata) === null || _product$metadata14 === void 0 ? void 0 : _product$metadata14.unique_identification_number;
7289
7649
  if (!uid) continue;
7290
7650
  var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
7291
7651
  var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
7292
- var origin = (_ref81 = (_ref82 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref82 !== void 0 ? _ref82 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref81 !== void 0 ? _ref81 : rawProduct;
7652
+ var origin = (_ref94 = (_ref95 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref95 !== void 0 ? _ref95 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref94 !== void 0 ? _ref94 : rawProduct;
7293
7653
  var originSnapshot = cloneDeep(origin);
7294
7654
  var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
7295
7655
  if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
@@ -7340,8 +7700,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7340
7700
  var bookingUidByProductUid = new Map();
7341
7701
  var productByUid = new Map();
7342
7702
  (tempOrder.products || []).forEach(function (product) {
7343
- var _product$metadata13;
7344
- 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);
7703
+ var _product$metadata15;
7704
+ var productUid = (product === null || product === void 0 || (_product$metadata15 = product.metadata) === null || _product$metadata15 === void 0 ? void 0 : _product$metadata15.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
7345
7705
  if (productUid !== undefined && productUid !== null && String(productUid) !== '') {
7346
7706
  productByUid.set(String(productUid), product);
7347
7707
  }
@@ -7362,8 +7722,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7362
7722
  bookingUidByProductUid.set(String(productUid), bookingUid);
7363
7723
  });
7364
7724
  (tempOrder.products || []).forEach(function (product) {
7365
- var _product$metadata14;
7366
- var productUid = (product === null || product === void 0 || (_product$metadata14 = product.metadata) === null || _product$metadata14 === void 0 ? void 0 : _product$metadata14.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
7725
+ var _product$metadata16;
7726
+ var productUid = (product === null || product === void 0 || (_product$metadata16 = product.metadata) === null || _product$metadata16 === void 0 ? void 0 : _product$metadata16.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
7367
7727
  if (productUid === undefined || productUid === null || String(productUid) === '') return;
7368
7728
  var bookingUid = bookingUidByProductUid.get(String(productUid));
7369
7729
  if (!bookingUid) return;
@@ -7418,10 +7778,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7418
7778
  }, {
7419
7779
  key: "normalizeHydratedProductOptionItem",
7420
7780
  value: function normalizeHydratedProductOptionItem(optionItem) {
7421
- var _ref83, _optionItem$num, _ref84, _optionItem$add_price;
7422
- var rawNum = (_ref83 = (_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 && _ref83 !== void 0 ? _ref83 : 1;
7781
+ var _ref96, _optionItem$num, _ref97, _optionItem$add_price;
7782
+ var rawNum = (_ref96 = (_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 && _ref96 !== void 0 ? _ref96 : 1;
7423
7783
  var parsedNum = Number(rawNum);
7424
- var rawPrice = (_ref84 = (_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 && _ref84 !== void 0 ? _ref84 : 0;
7784
+ var rawPrice = (_ref97 = (_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 && _ref97 !== void 0 ? _ref97 : 0;
7425
7785
  var parsedPrice = Number(rawPrice);
7426
7786
  var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
7427
7787
  option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
@@ -7438,7 +7798,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7438
7798
  }, {
7439
7799
  key: "normalizeHydratedOrderProduct",
7440
7800
  value: function normalizeHydratedOrderProduct(product, options) {
7441
- var _this38 = this;
7801
+ var _this42 = this;
7442
7802
  var row = _objectSpread({}, product || {});
7443
7803
  if (row.num === undefined && row.product_quantity !== undefined) {
7444
7804
  row.num = row.product_quantity;
@@ -7446,7 +7806,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7446
7806
  var productSku = ensureProductSku(row);
7447
7807
  row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
7448
7808
  option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
7449
- return _this38.normalizeHydratedProductOptionItem(optionItem || {});
7809
+ return _this42.normalizeHydratedProductOptionItem(optionItem || {});
7450
7810
  }))
7451
7811
  });
7452
7812
  delete row["product_".concat('option', "_item")];
@@ -7534,8 +7894,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7534
7894
  }, {
7535
7895
  key: "getVouchers",
7536
7896
  value: function getVouchers() {
7537
- var _this$store$tempOrder6;
7538
- return ((_this$store$tempOrder6 = this.store.tempOrder) === null || _this$store$tempOrder6 === void 0 ? void 0 : _this$store$tempOrder6.vouchers) || [];
7897
+ var _this$store$tempOrder8;
7898
+ return ((_this$store$tempOrder8 = this.store.tempOrder) === null || _this$store$tempOrder8 === void 0 ? void 0 : _this$store$tempOrder8.vouchers) || [];
7539
7899
  }
7540
7900
  }], [{
7541
7901
  key: "populateSavedAmounts",
@@ -7554,11 +7914,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7554
7914
  targetMap.set(discountKey, (targetMap.get(discountKey) || new Decimal(0)).plus(amount));
7555
7915
  };
7556
7916
  var addProductDiscountAmount = function addProductDiscountAmount(discount, quantity, isPersistedProduct) {
7557
- var _discount$discount3, _discount$metadata;
7917
+ var _discount$discount3, _discount$metadata2;
7558
7918
  var discountKey = ((_discount$discount3 = discount.discount) === null || _discount$discount3 === void 0 ? void 0 : _discount$discount3.resource_id) || discount.id;
7559
7919
  if (discountKey == null) return;
7560
7920
  var qty = Number(quantity) || 1;
7561
- var amount = new Decimal(discount.amount || 0).times(qty).plus(((_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.product_discount_difference) || 0);
7921
+ var amount = new Decimal(discount.amount || 0).times(qty).plus(((_discount$metadata2 = discount.metadata) === null || _discount$metadata2 === void 0 ? void 0 : _discount$metadata2.product_discount_difference) || 0);
7562
7922
  addDiscountAmount(savedMap, discountKey, amount);
7563
7923
  addDiscountAmount(isPersistedProduct || discount.order_discount_id != null ? editModeSavedMap : runtimeSavedMap, discountKey, amount);
7564
7924
  };