@pisell/pisellos 2.3.127 → 2.3.128

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 (103) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  2. package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +0 -2
  3. package/dist/model/strategy/adapter/walletPass/evaluator.js +2 -4
  4. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +19 -58
  5. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +12 -24
  6. package/dist/modules/Customer/index.js +3 -6
  7. package/dist/modules/Customer/types.d.ts +0 -2
  8. package/dist/modules/Discount/index.d.ts +2 -2
  9. package/dist/modules/Discount/index.js +151 -37
  10. package/dist/modules/Discount/types.d.ts +5 -36
  11. package/dist/modules/Order/index.d.ts +2 -7
  12. package/dist/modules/Order/index.js +331 -480
  13. package/dist/modules/Order/utils/orderCollectionIdentity.js +12 -16
  14. package/dist/modules/Order/utils/weighedProduct.d.ts +12 -0
  15. package/dist/modules/Order/utils/weighedProduct.js +94 -0
  16. package/dist/modules/Order/utils.d.ts +1 -1
  17. package/dist/modules/Order/utils.js +65 -104
  18. package/dist/modules/Payment/types.d.ts +1 -21
  19. package/dist/modules/Payment/types.js +0 -2
  20. package/dist/modules/Payment/walletpass.d.ts +1 -1
  21. package/dist/modules/Payment/walletpass.js +47 -80
  22. package/dist/modules/Rules/index.d.ts +2 -2
  23. package/dist/modules/Rules/index.js +190 -482
  24. package/dist/modules/Rules/types.d.ts +2 -4
  25. package/dist/server/modules/order/types.d.ts +0 -2
  26. package/dist/server/utils/small-ticket.js +1 -1
  27. package/dist/solution/BaseSales/index.d.ts +2 -3
  28. package/dist/solution/BaseSales/index.js +77 -44
  29. package/dist/solution/BaseSales/types.d.ts +7 -3
  30. package/dist/solution/BaseSales/utils/cartPromotion.js +126 -141
  31. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +40 -25
  32. package/dist/solution/BaseSales/utils.js +3 -2
  33. package/dist/solution/BookingByStep/index.d.ts +1 -1
  34. package/dist/solution/BookingTicket/index.d.ts +3 -2
  35. package/dist/solution/BookingTicket/index.js +63 -60
  36. package/dist/solution/BookingTicket/types.d.ts +1 -5
  37. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -2
  38. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +147 -338
  39. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +4 -8
  40. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +0 -6
  41. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +6 -19
  42. package/dist/solution/ScanOrder/utils.js +3 -2
  43. package/dist/solution/ShopDiscount/index.d.ts +0 -2
  44. package/dist/solution/ShopDiscount/index.js +42 -99
  45. package/dist/solution/ShopDiscount/utils.d.ts +2 -4
  46. package/dist/solution/ShopDiscount/utils.js +23 -43
  47. package/dist/solution/UnifiedBookingSales/index.js +2 -2
  48. package/lib/model/strategy/adapter/promotion/index.js +1 -46
  49. package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +0 -2
  50. package/lib/model/strategy/adapter/walletPass/evaluator.js +0 -2
  51. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +6 -35
  52. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +6 -13
  53. package/lib/modules/Customer/index.js +1 -5
  54. package/lib/modules/Customer/types.d.ts +0 -2
  55. package/lib/modules/Discount/index.d.ts +2 -2
  56. package/lib/modules/Discount/index.js +129 -23
  57. package/lib/modules/Discount/types.d.ts +5 -36
  58. package/lib/modules/Order/index.d.ts +2 -7
  59. package/lib/modules/Order/index.js +109 -222
  60. package/lib/modules/Order/utils/orderCollectionIdentity.js +11 -14
  61. package/lib/modules/Order/utils/weighedProduct.d.ts +12 -0
  62. package/lib/modules/Order/utils/weighedProduct.js +89 -0
  63. package/lib/modules/Order/utils.d.ts +1 -1
  64. package/lib/modules/Order/utils.js +6 -41
  65. package/lib/modules/Payment/types.d.ts +1 -21
  66. package/lib/modules/Payment/types.js +0 -1
  67. package/lib/modules/Payment/walletpass.d.ts +1 -1
  68. package/lib/modules/Payment/walletpass.js +9 -29
  69. package/lib/modules/Rules/index.d.ts +2 -2
  70. package/lib/modules/Rules/index.js +114 -359
  71. package/lib/modules/Rules/types.d.ts +2 -4
  72. package/lib/server/modules/order/types.d.ts +0 -2
  73. package/lib/server/utils/small-ticket.js +1 -1
  74. package/lib/solution/BaseSales/index.d.ts +2 -3
  75. package/lib/solution/BaseSales/index.js +17 -11
  76. package/lib/solution/BaseSales/types.d.ts +7 -3
  77. package/lib/solution/BaseSales/utils/cartPromotion.js +4 -12
  78. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +24 -9
  79. package/lib/solution/BaseSales/utils.js +2 -1
  80. package/lib/solution/BookingByStep/index.d.ts +1 -1
  81. package/lib/solution/BookingTicket/index.d.ts +3 -2
  82. package/lib/solution/BookingTicket/index.js +33 -36
  83. package/lib/solution/BookingTicket/types.d.ts +1 -5
  84. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -2
  85. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +42 -174
  86. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +4 -8
  87. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +0 -6
  88. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +3 -11
  89. package/lib/solution/ScanOrder/utils.js +2 -1
  90. package/lib/solution/ShopDiscount/index.d.ts +0 -2
  91. package/lib/solution/ShopDiscount/index.js +9 -55
  92. package/lib/solution/ShopDiscount/utils.d.ts +2 -4
  93. package/lib/solution/ShopDiscount/utils.js +25 -42
  94. package/lib/solution/UnifiedBookingSales/index.js +2 -2
  95. package/package.json +1 -1
  96. package/dist/modules/Discount/availability.d.ts +0 -7
  97. package/dist/modules/Discount/availability.js +0 -49
  98. package/dist/modules/Discount/entitlementPass.d.ts +0 -34
  99. package/dist/modules/Discount/entitlementPass.js +0 -147
  100. package/lib/modules/Discount/availability.d.ts +0 -7
  101. package/lib/modules/Discount/availability.js +0 -43
  102. package/lib/modules/Discount/entitlementPass.d.ts +0 -34
  103. package/lib/modules/Discount/entitlementPass.js +0 -141
@@ -6,7 +6,13 @@ 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); }
9
13
  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; }
10
16
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
11
17
  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); } }
12
18
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
@@ -19,12 +25,6 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
19
25
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
20
26
  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; } }
21
27
  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; }
@@ -34,22 +34,21 @@ import { BaseModule } from "../BaseModule";
34
34
  import { OrderHooks } from "./types";
35
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
+ import { getWeighedProductPriceFingerprint, resolveWeighedSourcePrice, withOriginalBundleOptionPrices } from "./utils/weighedProduct";
37
38
  import dayjs from 'dayjs';
38
- import { getDiscountLifecycleReason } from "../Discount/availability";
39
39
  import { stripOsPrivatePayloadFields } from "../../utils/os-private-payload";
40
40
  import { buildSalesNoteText, decodeSalesNotesSnapshot, getSalesNotePolicy } from "./salesNotes";
41
41
  import { ensureOrderPaymentNumber, mergeOrderPaymentRecord, resolveOrderPaymentIdentity } from "./payment-utils";
42
42
  import { resolvePaymentNumberDevicePrefix, resolvePaymentNumberDevicePrefixFromDeviceId } from "../../utils/payment-number";
43
43
  import { processCartPromotion, appendPromotionTags as _appendPromotionTags, getOrderProductUid as getPromotionUid, PRODUCT_LINE_MERGE_DISABLED_METADATA_KEY } from "../../solution/BaseSales/utils/cartPromotion";
44
44
  import { buildProductLineFingerprint, getProductIdentityIndex, getSafeProductNum, isIdentityMatch, normalizeOrderProduct } from "../../solution/ScanOrder/utils";
45
- import { hasManualProductDiscountFlag, syncManualProductDiscountProductNum } from "./utils/manualProductDiscount";
45
+ import { hasManualProductDiscountFlag, syncManualProductDiscountProductNum, buildManualProductDiscountItem, findManualProductDiscountItem, mergeManualProductDiscountIntoList } from "./utils/manualProductDiscount";
46
46
  import { expandHydratedProductsForDiscountCollection, restoreHydratedBundleDiscounts } from "./utils/bundleDiscountHydration";
47
47
  import { getOrderCollectionPersistentId, getOrderCollectionUid, normalizeOrderCollections, repairDuplicateProductLineIdentities as repairDuplicateOrderProductLineIdentities, setOrderCollectionUid } from "./utils/orderCollectionIdentity";
48
48
  import { consolidateDiscountFreeProductLines, ensureUniqueProductLineUids } from "./utils/discountProductLineIdentity";
49
49
  import { applyTempOrderSettlementState, getSelectedSettlementSnapshot, getSettlementKey, getTempOrderSettlementKey, getTempOrderSettlementSnapshot, isVirtualSettlementOrder, normalizeVirtualSettlementOrderProduct, normalizeVirtualSettlementProducts, OrderSettlementConflictError, releaseTempOrderSettlementState, VirtualCurrencyAssetNotFoundError, VirtualCurrencyBalanceError } from "./utils/virtualSettlement";
50
50
  import { DiscountModule } from "../Discount";
51
51
  import { RulesModule } from "../Rules";
52
- import { isEntitlementPass, isFullCoveragePass } from "../Discount/entitlementPass";
53
52
  import { UnavailableReason } from "../Rules/types";
54
53
  import Decimal from 'decimal.js';
55
54
  import { cloneDeep } from 'lodash-es';
@@ -73,26 +72,9 @@ function isManualProductDiscountProduct(product) {
73
72
  return (item === null || item === void 0 ? void 0 : item.type) === 'product';
74
73
  });
75
74
  }
76
- function syncReducedEntitlementPassUsageCount(discountList, previousQuantity, nextQuantity) {
77
- if (!Array.isArray(discountList)) return discountList;
78
- var previousCount = getSafeProductNum(previousQuantity);
79
- var nextCount = getSafeProductNum(nextQuantity);
80
- if (nextCount >= previousCount) return discountList;
81
- return discountList.map(function (discount) {
82
- var _discount$metadata$nu, _discount$metadata;
83
- if (!isEntitlementPass(discount)) return discount;
84
- 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);
85
- var usageCount = Number.isFinite(rawUsageCount) ? Math.max(Math.floor(rawUsageCount), 0) : previousCount;
86
- return _objectSpread(_objectSpread({}, discount), {}, {
87
- metadata: _objectSpread(_objectSpread({}, (discount === null || discount === void 0 ? void 0 : discount.metadata) || {}), {}, {
88
- num: Math.min(usageCount, nextCount)
89
- })
90
- });
91
- });
92
- }
93
75
  var ORDER_PAYMENT_STATUS_PAID = 'paid';
94
76
  var ORDER_PAYMENT_STATUS_PENDING = 'payment_pending';
95
- var CUSTOMER_PROMOTION_DISCOUNT_TAGS = new Set(['entitlement_pass', 'good_pass', 'product_discount_card', 'discount_card']);
77
+ var CUSTOMER_PROMOTION_DISCOUNT_TAGS = new Set(['good_pass', 'product_discount_card', 'discount_card']);
96
78
  function isCustomerPromotionDiscount(discount) {
97
79
  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());
98
80
  }
@@ -127,27 +109,6 @@ function getVoucherPaymentLifecycleKey(payment) {
127
109
  if (!isVoucherPaymentRecord(payment)) return null;
128
110
  return "".concat(String(payment.voucher_id), "::").concat(String(payment.status || ''));
129
111
  }
130
- function getDiscountIdentityKey(discount) {
131
- var id = discount === null || discount === void 0 ? void 0 : discount.id;
132
- if (id === undefined || id === null || id === '') return null;
133
- return String(id);
134
- }
135
- function mergeCommittedEntitlementWithRuntime(committed, runtime) {
136
- var _committed$committedA, _runtime$id, _runtime$isDisabled, _runtime$isSelected;
137
- var committedAppliedProductDetails = (_committed$committedA = committed.committedAppliedProductDetails) !== null && _committed$committedA !== void 0 && _committed$committedA.length ? committed.committedAppliedProductDetails : committed.appliedProductDetails || [];
138
- return _objectSpread(_objectSpread(_objectSpread({}, committed), runtime), {}, {
139
- id: (_runtime$id = runtime.id) !== null && _runtime$id !== void 0 ? _runtime$id : committed.id,
140
- tag: runtime.tag || committed.tag,
141
- type: runtime.type || committed.type,
142
- isEditMode: false,
143
- isDisabled: (_runtime$isDisabled = runtime.isDisabled) !== null && _runtime$isDisabled !== void 0 ? _runtime$isDisabled : false,
144
- isSelected: (_runtime$isSelected = runtime.isSelected) !== null && _runtime$isSelected !== void 0 ? _runtime$isSelected : committed.isSelected,
145
- isUsed: committed.isUsed || runtime.isUsed,
146
- committedAppliedProductDetails: _toConsumableArray(committedAppliedProductDetails),
147
- applicableProductDetails: [].concat(_toConsumableArray(committed.applicableProductDetails || []), _toConsumableArray(runtime.applicableProductDetails || [])),
148
- appliedProductDetails: [].concat(_toConsumableArray(committedAppliedProductDetails), _toConsumableArray(runtime.appliedProductDetails || []))
149
- });
150
- }
151
112
  export var OrderModule = /*#__PURE__*/function (_BaseModule) {
152
113
  _inherits(OrderModule, _BaseModule);
153
114
  var _super = _createSuper(OrderModule);
@@ -212,7 +173,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
212
173
  _step2;
213
174
  try {
214
175
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
215
- 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;
176
+ 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
177
  var item = _step2.value;
217
178
  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;
218
179
  if (!type || type === 'product') continue;
@@ -223,31 +184,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
223
184
  var key = Number.isFinite(id) ? id : String(resourceId);
224
185
  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 : {};
225
186
  var amount = Number((item === null || item === void 0 ? void 0 : item.amount) || 0);
226
- 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) || '';
227
- var discountCardType = item === null || item === void 0 || (_item$discount4 = item.discount) === null || _item$discount4 === void 0 ? void 0 : _item$discount4.discount_card_type;
228
- 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';
187
+ var discountCardType = item === null || item === void 0 || (_item$discount3 = item.discount) === null || _item$discount3 === void 0 ? void 0 : _item$discount3.discount_card_type;
188
+ 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';
229
189
  var detail = {
230
190
  amount: String((_item$amount = item === null || item === void 0 ? void 0 : item.amount) !== null && _item$amount !== void 0 ? _item$amount : '0'),
231
191
  type: type,
232
192
  resource_id: key,
233
193
  title: title,
234
- 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'),
235
- 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,
194
+ 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'),
195
+ 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,
236
196
  metadata: item === null || item === void 0 ? void 0 : item.metadata,
237
- discount: _objectSpread(_objectSpread({}, (item === null || item === void 0 ? void 0 : item.discount) || {}), {}, {
238
- 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
239
- }),
240
- _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
197
+ discount: item === null || item === void 0 ? void 0 : item.discount,
198
+ _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
241
199
  };
242
200
  var existed = discountMap.get(key);
243
201
  if (existed) {
244
202
  var _existed$limited_rela;
245
- if (!existed.encoded && encoded) {
246
- existed.encoded = encoded;
247
- existed.metadata = _objectSpread(_objectSpread({}, existed.metadata), {}, {
248
- encoded: encoded
249
- });
250
- }
251
203
  existed.amount = Number(existed.amount || 0) + amount;
252
204
  existed.used_par_value = String(Number(existed.used_par_value || 0) + amount);
253
205
  if (!isDiscountCard) {
@@ -266,13 +218,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
266
218
  discountMap.set(key, {
267
219
  id: key,
268
220
  product_name: '',
269
- encoded: encoded,
270
- 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) || '',
271
- metadata: {
272
- encoded: encoded
273
- },
221
+ encoded: '',
222
+ code: '',
274
223
  tag: type,
275
- 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,
224
+ 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
225
  relation_type: '',
277
226
  par_value: String(parValue !== null && parValue !== void 0 ? parValue : '0'),
278
227
  used_par_value: String((_item$amount2 = item === null || item === void 0 ? void 0 : item.amount) !== null && _item$amount2 !== void 0 ? _item$amount2 : '0'),
@@ -305,8 +254,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
305
254
  amount: amount,
306
255
  discount: _objectSpread(_objectSpread({}, (item === null || item === void 0 ? void 0 : item.discount) || {}), {}, {
307
256
  resource_id: key,
308
- 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,
309
- 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'
257
+ 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,
258
+ 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'
310
259
  }),
311
260
  applicableProductDetails: [detail],
312
261
  appliedProductDetails: [detail]
@@ -610,11 +559,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
610
559
  }, {
611
560
  key: "createDefaultRulesHooks",
612
561
  value: function createDefaultRulesHooks() {
613
- var _this2 = this;
614
- return createDefaultOrderRulesHooks(function () {
615
- var _this2$store$tempOrde;
616
- return ((_this2$store$tempOrde = _this2.store.tempOrder) === null || _this2$store$tempOrde === void 0 ? void 0 : _this2$store$tempOrde.bookings) || [];
617
- });
562
+ return createDefaultOrderRulesHooks();
618
563
  }
619
564
 
620
565
  /**
@@ -636,9 +581,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
636
581
  var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
637
582
  var _this$store$tempOrder,
638
583
  _this$store$discount,
639
- _this3 = this,
584
+ _this2 = this,
640
585
  _this$store$tempOrder2;
641
- 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;
586
+ var orderId, requestEpoch, requestOrderIdentityKey, prepareConfigResult, isCurrentRequest, discountList, _this$store$discount2, _this$store$discount3, _this$store$discount4, currentDiscountList, currentEditDiscounts, currentScanDiscounts, currentScanDiscountIds, runtimeDiscountIds, runtimeDiscounts, mergedDiscountList;
642
587
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
643
588
  while (1) switch (_context3.prev = _context3.next) {
644
589
  case 0:
@@ -654,8 +599,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
654
599
  with_wallet_pass_holder: 1,
655
600
  with_available_wallet_flag: 1,
656
601
  with_available_wallet_pass_flag: 1,
657
- with_entitlement_pass: 1,
658
- filter_order_wallet_pass_usage: 0,
659
602
  with_virtual_currency: 1,
660
603
  request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
661
604
  }, orderId ? {
@@ -664,8 +607,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
664
607
  case 5:
665
608
  prepareConfigResult = _context3.sent;
666
609
  isCurrentRequest = function isCurrentRequest() {
667
- var _this3$store$tempOrde, _this3$store$tempOrde2;
668
- 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);
610
+ var _this2$store$tempOrde, _this2$store$tempOrde2;
611
+ return requestEpoch === _this2.customerWalletPrepareConfigEpoch && _this2.getDiscountConfigOrderIdentityKey(_this2.store.tempOrder) === requestOrderIdentityKey && String((_this2$store$tempOrde = (_this2$store$tempOrde2 = _this2.store.tempOrder) === null || _this2$store$tempOrde2 === void 0 ? void 0 : _this2$store$tempOrde2.customer_id) !== null && _this2$store$tempOrde !== void 0 ? _this2$store$tempOrde : '') === String(params.customerId);
669
612
  };
670
613
  if (isCurrentRequest()) {
671
614
  _context3.next = 9;
@@ -683,101 +626,56 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
683
626
  });
684
627
  }
685
628
  if (!discountList) {
686
- _context3.next = 32;
629
+ _context3.next = 27;
687
630
  break;
688
631
  }
689
632
  currentDiscountList = ((_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 ? void 0 : _this$store$discount2.getDiscountList()) || [];
690
- currentCommittedDiscounts = currentDiscountList.filter(function (discount) {
691
- var _discount$committedAp;
692
- 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);
633
+ currentEditDiscounts = currentDiscountList.filter(function (discount) {
634
+ return discount === null || discount === void 0 ? void 0 : discount.isEditMode;
693
635
  });
694
636
  currentScanDiscounts = currentDiscountList.filter(function (discount) {
695
637
  return discount === null || discount === void 0 ? void 0 : discount.isScan;
696
638
  });
697
- currentScanDiscountById = new Map(currentScanDiscounts.flatMap(function (discount) {
698
- var id = getDiscountIdentityKey(discount);
699
- return id === null ? [] : [[id, discount]];
700
- }));
701
- committedDiscountById = new Map(currentCommittedDiscounts.flatMap(function (discount) {
702
- var id = getDiscountIdentityKey(discount);
703
- return id === null ? [] : [[id, discount]];
639
+ currentScanDiscountIds = new Set(currentScanDiscounts.map(function (discount) {
640
+ return discount === null || discount === void 0 ? void 0 : discount.id;
704
641
  }));
705
- mergedCommittedDiscountIds = new Set();
706
- refreshedScanDiscountIds = new Set();
707
642
  runtimeDiscountIds = new Set();
708
- runtimeDiscounts = discountList.flatMap(function (discount) {
709
- var id = getDiscountIdentityKey(discount);
710
- if (id === null) return [discount];
711
- if (runtimeDiscountIds.has(id)) return [];
712
- runtimeDiscountIds.add(id);
713
- var currentScanDiscount = currentScanDiscountById.get(id);
714
- if (currentScanDiscount && (!isEntitlementPass(currentScanDiscount) || !isEntitlementPass(discount))) {
715
- return [];
716
- }
717
- var committedDiscount = committedDiscountById.get(id);
718
- var nextDiscount = discount;
719
- if (committedDiscount && isEntitlementPass(committedDiscount) && isEntitlementPass(discount)) {
720
- mergedCommittedDiscountIds.add(id);
721
- nextDiscount = mergeCommittedEntitlementWithRuntime(committedDiscount, discount);
722
- }
723
- if (currentScanDiscount) {
724
- var _currentScanDiscount$, _currentScanDiscount$2;
725
- refreshedScanDiscountIds.add(id);
726
- nextDiscount = _objectSpread(_objectSpread({}, nextDiscount), {}, {
727
- isScan: true,
728
- isSelected: (_currentScanDiscount$ = currentScanDiscount.isSelected) !== null && _currentScanDiscount$ !== void 0 ? _currentScanDiscount$ : nextDiscount.isSelected,
729
- isManualSelect: (_currentScanDiscount$2 = currentScanDiscount.isManualSelect) !== null && _currentScanDiscount$2 !== void 0 ? _currentScanDiscount$2 : nextDiscount.isManualSelect
730
- });
731
- }
732
- return [nextDiscount];
733
- });
734
- retainedCommittedDiscounts = currentCommittedDiscounts.filter(function (discount) {
735
- var id = getDiscountIdentityKey(discount);
736
- return id === null || !mergedCommittedDiscountIds.has(id);
737
- }).map(function (discount) {
738
- var _discount$committedAp2;
739
- return (_discount$committedAp2 = discount.committedAppliedProductDetails) !== null && _discount$committedAp2 !== void 0 && _discount$committedAp2.length ? _objectSpread(_objectSpread({}, discount), {}, {
740
- isEditMode: true,
741
- isDisabled: true,
742
- isSelected: true,
743
- isUsed: true,
744
- appliedProductDetails: _toConsumableArray(discount.committedAppliedProductDetails)
745
- }) : discount;
746
- });
747
- retainedScanDiscounts = currentScanDiscounts.filter(function (discount) {
748
- var id = getDiscountIdentityKey(discount);
749
- return id === null || !refreshedScanDiscountIds.has(id);
643
+ runtimeDiscounts = discountList.filter(function (discount) {
644
+ if (currentScanDiscountIds.has(discount === null || discount === void 0 ? void 0 : discount.id)) return false;
645
+ if (runtimeDiscountIds.has(discount === null || discount === void 0 ? void 0 : discount.id)) return false;
646
+ runtimeDiscountIds.add(discount === null || discount === void 0 ? void 0 : discount.id);
647
+ return true;
750
648
  });
751
- mergedDiscountList = [].concat(_toConsumableArray(retainedCommittedDiscounts), _toConsumableArray(retainedScanDiscounts), _toConsumableArray(runtimeDiscounts));
649
+ mergedDiscountList = [].concat(_toConsumableArray(currentEditDiscounts), _toConsumableArray(currentScanDiscounts), _toConsumableArray(runtimeDiscounts));
752
650
  if (isCurrentRequest()) {
753
- _context3.next = 26;
651
+ _context3.next = 21;
754
652
  break;
755
653
  }
756
654
  return _context3.abrupt("return", this.getDiscountList());
757
- case 26:
758
- _context3.next = 28;
655
+ case 21:
656
+ _context3.next = 23;
759
657
  return (_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.setOriginalDiscountList(mergedDiscountList);
760
- case 28:
658
+ case 23:
761
659
  if (isCurrentRequest()) {
762
- _context3.next = 30;
660
+ _context3.next = 25;
763
661
  break;
764
662
  }
765
663
  return _context3.abrupt("return", this.getDiscountList());
766
- case 30:
767
- _context3.next = 32;
664
+ case 25:
665
+ _context3.next = 27;
768
666
  return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.setDiscountList(mergedDiscountList);
769
- case 32:
667
+ case 27:
770
668
  if (isCurrentRequest()) {
771
- _context3.next = 34;
669
+ _context3.next = 29;
772
670
  break;
773
671
  }
774
672
  return _context3.abrupt("return", this.getDiscountList());
775
- case 34:
673
+ case 29:
776
674
  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) {
777
675
  this.applyDiscount();
778
676
  }
779
677
  return _context3.abrupt("return", this.getDiscountList());
780
- case 36:
678
+ case 31:
781
679
  case "end":
782
680
  return _context3.stop();
783
681
  }
@@ -897,7 +795,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
897
795
  value: function () {
898
796
  var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(code, customerId) {
899
797
  var _this$store$discount11, _tempOrder$holder, _this$store$summary;
900
- 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;
798
+ var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref16, isAvailable, newDiscountList, evaluatedDiscountList, unavailableReason, shouldRetainForLater, normalizedNewDiscountList, retainedDiscountList, resolvedDiscountList, _this$store$discount12, _this$store$discount13;
901
799
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
902
800
  while (1) switch (_context6.prev = _context6.next) {
903
801
  case 0:
@@ -1000,72 +898,46 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1000
898
  isAvailable: false,
1001
899
  discountList: this.getDiscountList()
1002
900
  }, isAvailable = _ref16.isAvailable, newDiscountList = _ref16.discountList, evaluatedDiscountList = _ref16.evaluatedDiscountList, unavailableReason = _ref16.unavailableReason;
1003
- scannedIds = new Set(withScanList.map(function (discount) {
1004
- return String(discount.id);
1005
- }));
1006
- evaluatedScannedDiscounts = (evaluatedDiscountList || withScanList).filter(function (discount) {
1007
- return scannedIds.has(String(discount.id)) && isCustomerPromotionDiscount(discount) && !getDiscountLifecycleReason(discount);
1008
- });
1009
- shouldRetainForLater = !isAvailable && evaluatedScannedDiscounts.length > 0;
901
+ shouldRetainForLater = !isAvailable && unavailableReason === UnavailableReason.ProductNotApplicable && withScanList.some(isCustomerPromotionDiscount);
1010
902
  normalizedNewDiscountList = newDiscountList ? markScannedDiscounts(newDiscountList, withScanList) : undefined;
903
+ retainedDiscountList = evaluatedDiscountList ? markScannedDiscounts(evaluatedDiscountList, withScanList) : normalizedNewDiscountList;
1011
904
  resolvedDiscountList = normalizedNewDiscountList || this.getDiscountList();
1012
905
  if (!(isAvailable && normalizedNewDiscountList)) {
1013
- _context6.next = 37;
906
+ _context6.next = 36;
1014
907
  break;
1015
908
  }
1016
- _context6.next = 31;
909
+ _context6.next = 30;
1017
910
  return (_this$store$discount12 = this.store.discount) === null || _this$store$discount12 === void 0 ? void 0 : _this$store$discount12.setDiscountList(normalizedNewDiscountList);
1018
- case 31:
1019
- // 实际写回商品时沿用扫码试算的优先级,避免旧商品行的选卡覆盖本次扫码。
1020
- this.applyDiscount({
1021
- preferredEntitlementPassIds: withScanList.filter(function (discount) {
1022
- return isEntitlementPass(discount);
1023
- }).map(function (discount) {
1024
- return discount.id;
1025
- })
1026
- });
1027
- _context6.next = 34;
911
+ case 30:
912
+ this.applyDiscount();
913
+ _context6.next = 33;
1028
914
  return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
1029
- case 34:
915
+ case 33:
1030
916
  resolvedDiscountList = this.getDiscountList();
1031
- _context6.next = 45;
917
+ _context6.next = 42;
1032
918
  break;
1033
- case 37:
1034
- if (!shouldRetainForLater) {
1035
- _context6.next = 45;
919
+ case 36:
920
+ if (!(shouldRetainForLater && retainedDiscountList)) {
921
+ _context6.next = 42;
1036
922
  break;
1037
923
  }
1038
- // 只合并本次识别的卡券;不把试算产生的其他选券状态写回订单。
1039
- retainedDiscounts = new Map(this.getDiscountList().map(function (discount) {
1040
- return [String(discount.id), discount];
1041
- }));
1042
- evaluatedScannedDiscounts.forEach(function (discount) {
1043
- retainedDiscounts.set(String(discount.id), _objectSpread(_objectSpread({}, discount), {}, {
1044
- isScan: true,
1045
- isAvailable: false,
1046
- isSelected: false,
1047
- reasonCode: discount.reasonCode || 'product_not_applicable',
1048
- appliedProductDetails: [],
1049
- savedAmount: 0
1050
- }));
1051
- });
1052
- _context6.next = 42;
1053
- return (_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.setDiscountList(_toConsumableArray(retainedDiscounts.values()));
1054
- case 42:
1055
- _context6.next = 44;
924
+ _context6.next = 39;
925
+ return (_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.setDiscountList(retainedDiscountList);
926
+ case 39:
927
+ _context6.next = 41;
1056
928
  return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
1057
- case 44:
929
+ case 41:
1058
930
  resolvedDiscountList = this.getDiscountList();
1059
- case 45:
931
+ case 42:
1060
932
  return _context6.abrupt("return", {
1061
933
  type: 'clientCalc',
1062
934
  isAvailable: isAvailable || false,
1063
935
  isAccepted: Boolean(isAvailable || shouldRetainForLater),
1064
936
  discountList: resolvedDiscountList,
1065
- scannedDiscountList: evaluatedScannedDiscounts,
937
+ scannedDiscountList: resultDiscountList,
1066
938
  unavailableReason: unavailableReason
1067
939
  });
1068
- case 46:
940
+ case 43:
1069
941
  case "end":
1070
942
  return _context6.stop();
1071
943
  }
@@ -1081,7 +953,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1081
953
  value: function applyDiscount(options) {
1082
954
  var _this$store$discount16,
1083
955
  _this$store$summary2,
1084
- _this4 = this;
956
+ _this3 = this;
1085
957
  var tempOrder = this.store.tempOrder;
1086
958
  // 任意 products CRUD 后都应当重算 discount 状态;即使 products 为空,
1087
959
  // 也需要让 Rules.calcDiscount 把 DiscountModule 的 isSelected / isAvailable /
@@ -1113,7 +985,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1113
985
  orderTotalAmount: Number(((_this$store$summary2 = this.store.summary) === null || _this$store$summary2 === void 0 ? void 0 : _this$store$summary2.total_amount) || 0)
1114
986
  }, {
1115
987
  reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids,
1116
- preferredEntitlementPassIds: options === null || options === void 0 ? void 0 : options.preferredEntitlementPassIds
988
+ reapplyWeighedDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyWeighedDiscountProductUids
1117
989
  });
1118
990
  if (result !== null && result !== void 0 && result.productList) {
1119
991
  var previousProductsByUid = indexOrderProductsByUid(tempOrder.products);
@@ -1138,7 +1010,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1138
1010
  (_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 || _this$store$discount17.setDiscountList(result.discountList);
1139
1011
  }
1140
1012
  this.hasActiveCustomerBoundDiscount = (tempOrder.products || []).some(function (product) {
1141
- return _this4.productHasCustomerBoundDiscount(product);
1013
+ return _this3.productHasCustomerBoundDiscount(product);
1142
1014
  });
1143
1015
  }
1144
1016
 
@@ -1201,7 +1073,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1201
1073
  var _evaluatePromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
1202
1074
  var _this$promotionEvalua,
1203
1075
  _this$promotionEvalua2,
1204
- _this5 = this;
1076
+ _this4 = this;
1205
1077
  var tempOrder, strategyConfigs, result, removeSet, _iterator3, _step3, reduce, _iterator6, _step6, _loop2, _iterator4, _step4, _loop, payload;
1206
1078
  return _regeneratorRuntime().wrap(function _callee7$(_context9) {
1207
1079
  while (1) switch (_context9.prev = _context9.next) {
@@ -1360,7 +1232,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1360
1232
  case 6:
1361
1233
  _context7.prev = 6;
1362
1234
  _context7.next = 9;
1363
- return _this5.giftSelectResolver({
1235
+ return _this4.giftSelectResolver({
1364
1236
  strategyId: addAction.strategyId,
1365
1237
  strategyName: addAction.strategyName,
1366
1238
  giftCount: addAction.giftCount,
@@ -1395,7 +1267,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1395
1267
  _context7.next = 26;
1396
1268
  break;
1397
1269
  }
1398
- linked = _this5.createLinkedProductAndBooking({
1270
+ linked = _this4.createLinkedProductAndBooking({
1399
1271
  product: gp,
1400
1272
  booking: booking
1401
1273
  });
@@ -1725,12 +1597,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1725
1597
  }, {
1726
1598
  key: "rememberPointCardSnapshotCodeCandidates",
1727
1599
  value: function rememberPointCardSnapshotCodeCandidates(value) {
1728
- var _this6 = this;
1600
+ var _this5 = this;
1729
1601
  collectPointCardSnapshotCodeCandidates(value).forEach(function (_ref18) {
1730
1602
  var id = _ref18.id,
1731
1603
  code = _ref18.code;
1732
- if (!_this6.pointCardSnapshotCodeCandidates.has(id)) {
1733
- _this6.pointCardSnapshotCodeCandidates.set(id, code);
1604
+ if (!_this5.pointCardSnapshotCodeCandidates.has(id)) {
1605
+ _this5.pointCardSnapshotCodeCandidates.set(id, code);
1734
1606
  }
1735
1607
  });
1736
1608
  }
@@ -1937,23 +1809,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1937
1809
  }, {
1938
1810
  key: "calculatePaymentTotal",
1939
1811
  value: function calculatePaymentTotal(payments) {
1940
- var _this7 = this;
1812
+ var _this6 = this;
1941
1813
  return mapPaymentItemsToOrderPayments(payments, {
1942
1814
  includeVoided: false
1943
1815
  }).reduce(function (sum, payment) {
1944
1816
  if (!isPaidPaymentRecord(payment)) return sum;
1945
- return sum.plus(_this7.calculatePaymentEffectiveAmount(payment));
1817
+ return sum.plus(_this6.calculatePaymentEffectiveAmount(payment));
1946
1818
  }, new Decimal(0));
1947
1819
  }
1948
1820
  }, {
1949
1821
  key: "calculateOrderPaidPaymentTotal",
1950
1822
  value: function calculateOrderPaidPaymentTotal(payments) {
1951
- var _this8 = this;
1823
+ var _this7 = this;
1952
1824
  return mapPaymentItemsToOrderPayments(payments, {
1953
1825
  includeVoided: false
1954
1826
  }).reduce(function (sum, payment) {
1955
1827
  if (!isPaidPaymentRecord(payment)) return sum;
1956
- return sum.plus(_this8.calculatePaymentGapAmount(payment));
1828
+ return sum.plus(_this7.calculatePaymentGapAmount(payment));
1957
1829
  }, new Decimal(0));
1958
1830
  }
1959
1831
  }, {
@@ -2089,13 +1961,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2089
1961
  }, {
2090
1962
  key: "calculateDepositPaidAmount",
2091
1963
  value: function calculateDepositPaidAmount(payments) {
2092
- var _this9 = this;
1964
+ var _this8 = this;
2093
1965
  return (payments || []).reduce(function (sum, payment) {
2094
1966
  var paymentRecord = payment;
2095
1967
  if (!isPaidPaymentRecord(paymentRecord)) return sum;
2096
1968
  var isDepositPayment = paymentRecord.type === 'deposit' || paymentRecord.order_payment_type === 'deposit';
2097
1969
  if (!isDepositPayment) return sum;
2098
- return sum.plus(_this9.calculatePaymentGapAmount(paymentRecord));
1970
+ return sum.plus(_this8.calculatePaymentGapAmount(paymentRecord));
2099
1971
  }, new Decimal(0));
2100
1972
  }
2101
1973
  }, {
@@ -2132,17 +2004,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2132
2004
  }, {
2133
2005
  key: "getPaymentNumberDevicePrefixSync",
2134
2006
  value: function getPaymentNumberDevicePrefixSync() {
2135
- var _this10 = this;
2007
+ var _this9 = this;
2136
2008
  return resolvePaymentNumberDevicePrefixFromDeviceId(function (key) {
2137
- return _this10.getPaymentNumberAppData(key);
2009
+ return _this9.getPaymentNumberAppData(key);
2138
2010
  });
2139
2011
  }
2140
2012
  }, {
2141
2013
  key: "getPaymentNumberDevicePrefixAsync",
2142
2014
  value: function getPaymentNumberDevicePrefixAsync() {
2143
- var _this11 = this;
2015
+ var _this10 = this;
2144
2016
  return resolvePaymentNumberDevicePrefix(function (key) {
2145
- return _this11.getPaymentNumberAppData(key);
2017
+ return _this10.getPaymentNumberAppData(key);
2146
2018
  });
2147
2019
  }
2148
2020
  }, {
@@ -2272,16 +2144,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2272
2144
  }, {
2273
2145
  key: "calculatePaidPaymentSummary",
2274
2146
  value: function calculatePaidPaymentSummary(payments) {
2275
- var _this12 = this;
2147
+ var _this11 = this;
2276
2148
  return (payments || []).reduce(function (summary, payment) {
2277
2149
  var paymentRecord = payment;
2278
2150
  if (!isPaidPaymentRecord(paymentRecord)) return summary;
2279
2151
  return {
2280
2152
  customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
2281
- orderPaidAmount: summary.orderPaidAmount.plus(_this12.calculatePaymentOrderAmount(paymentRecord)),
2282
- gapPaidAmount: summary.gapPaidAmount.plus(_this12.calculatePaymentGapAmount(paymentRecord)),
2283
- payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this12.calculatePaymentServiceFee(paymentRecord)),
2284
- roundingAmount: summary.roundingAmount.plus(_this12.calculatePaymentRoundingAmount(paymentRecord))
2153
+ orderPaidAmount: summary.orderPaidAmount.plus(_this11.calculatePaymentOrderAmount(paymentRecord)),
2154
+ gapPaidAmount: summary.gapPaidAmount.plus(_this11.calculatePaymentGapAmount(paymentRecord)),
2155
+ payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this11.calculatePaymentServiceFee(paymentRecord)),
2156
+ roundingAmount: summary.roundingAmount.plus(_this11.calculatePaymentRoundingAmount(paymentRecord))
2285
2157
  };
2286
2158
  }, {
2287
2159
  customerPaidAmount: new Decimal(0),
@@ -2488,15 +2360,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2488
2360
  }, {
2489
2361
  key: "normalizeFingerprintValue",
2490
2362
  value: function normalizeFingerprintValue(value) {
2491
- var _this13 = this;
2363
+ var _this12 = this;
2492
2364
  if (Array.isArray(value)) {
2493
2365
  return value.map(function (item) {
2494
- return _this13.normalizeFingerprintValue(item);
2366
+ return _this12.normalizeFingerprintValue(item);
2495
2367
  });
2496
2368
  }
2497
2369
  if (!value || _typeof(value) !== 'object') return value !== null && value !== void 0 ? value : '';
2498
2370
  return Object.keys(value).sort().reduce(function (result, key) {
2499
- result[key] = _this13.normalizeFingerprintValue(value[key]);
2371
+ result[key] = _this12.normalizeFingerprintValue(value[key]);
2500
2372
  return result;
2501
2373
  }, {});
2502
2374
  }
@@ -2511,17 +2383,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2511
2383
  _sku$barcode,
2512
2384
  _ref26,
2513
2385
  _sku$variant_id,
2514
- _this14 = this;
2386
+ _this13 = this;
2515
2387
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
2516
2388
  var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
2517
2389
  var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
2518
2390
  var _discount$type;
2519
2391
  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;
2520
2392
  });
2521
- var fullCoveragePassType = discountTypes.find(function (type) {
2522
- return ['entitlement_pass', 'good_pass'].includes(type);
2523
- });
2524
- var extensionType = (product === null || product === void 0 ? void 0 : product.extension_type) || fullCoveragePassType || 'normal';
2393
+ var extensionType = (product === null || product === void 0 ? void 0 : product.extension_type) || (discountTypes.includes('good_pass') ? 'good_pass' : 'normal');
2525
2394
  return {
2526
2395
  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,
2527
2396
  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,
@@ -2548,7 +2417,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2548
2417
  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,
2549
2418
  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,
2550
2419
  num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
2551
- 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)
2420
+ add_price: _this13.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)
2552
2421
  };
2553
2422
  })
2554
2423
  }),
@@ -2558,8 +2427,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2558
2427
  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,
2559
2428
  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,
2560
2429
  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),
2561
- price: _this14.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
2562
- bundle_selling_price: _this14.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
2430
+ price: _this13.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
2431
+ bundle_selling_price: _this13.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
2563
2432
  price_type: (_bundle$price_type = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type !== void 0 ? _bundle$price_type : '',
2564
2433
  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 : ''
2565
2434
  };
@@ -2569,7 +2438,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2569
2438
  return {
2570
2439
  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 : '',
2571
2440
  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,
2572
- amount: _this14.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2441
+ amount: _this13.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2573
2442
  };
2574
2443
  }))
2575
2444
  };
@@ -2577,9 +2446,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2577
2446
  }, {
2578
2447
  key: "buildOrderProductsFingerprint",
2579
2448
  value: function buildOrderProductsFingerprint(products) {
2580
- var _this15 = this;
2449
+ var _this14 = this;
2581
2450
  var items = (products || []).map(function (product) {
2582
- return _this15.buildProductFingerprintItem(product);
2451
+ return _this14.buildProductFingerprintItem(product);
2583
2452
  });
2584
2453
  items.sort(function (left, right) {
2585
2454
  return JSON.stringify(left).localeCompare(JSON.stringify(right));
@@ -2601,17 +2470,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2601
2470
  _sku$barcode2,
2602
2471
  _ref36,
2603
2472
  _sku$variant_id2,
2604
- _this16 = this;
2473
+ _this15 = this;
2605
2474
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
2606
2475
  var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
2607
2476
  var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
2608
2477
  var _discount$type3;
2609
2478
  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;
2610
2479
  });
2611
- var fullCoveragePassType = discountTypes.find(function (type) {
2612
- return ['entitlement_pass', 'good_pass'].includes(type);
2613
- });
2614
- var extensionType = (product === null || product === void 0 ? void 0 : product.extension_type) || fullCoveragePassType || 'normal';
2480
+ var extensionType = (product === null || product === void 0 ? void 0 : product.extension_type) || (discountTypes.includes('good_pass') ? 'good_pass' : 'normal');
2615
2481
  return {
2616
2482
  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,
2617
2483
  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,
@@ -2635,7 +2501,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2635
2501
  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,
2636
2502
  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,
2637
2503
  num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
2638
- 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)
2504
+ add_price: _this15.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)
2639
2505
  };
2640
2506
  })
2641
2507
  }),
@@ -2649,14 +2515,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2649
2515
  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),
2650
2516
  price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
2651
2517
  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 : '',
2652
- option: _this16.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
2518
+ option: _this15.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
2653
2519
  var _ref44, _option$id3, _option$option_group_5, _ref45, _option$option_group_6, _option$num3, _option$add_price3;
2654
2520
  return {
2655
2521
  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,
2656
2522
  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,
2657
2523
  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,
2658
2524
  num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
2659
- 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)
2525
+ add_price: _this15.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)
2660
2526
  };
2661
2527
  }))
2662
2528
  };
@@ -2666,7 +2532,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2666
2532
  return {
2667
2533
  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 : '',
2668
2534
  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,
2669
- amount: _this16.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2535
+ amount: _this15.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2670
2536
  };
2671
2537
  }))
2672
2538
  };
@@ -2674,9 +2540,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2674
2540
  }, {
2675
2541
  key: "buildOrderProductsStructuralFingerprint",
2676
2542
  value: function buildOrderProductsStructuralFingerprint(products) {
2677
- var _this17 = this;
2543
+ var _this16 = this;
2678
2544
  var items = (products || []).map(function (product) {
2679
- return _this17.buildProductStructuralFingerprintItem(product);
2545
+ return _this16.buildProductStructuralFingerprintItem(product);
2680
2546
  });
2681
2547
  items.sort(function (left, right) {
2682
2548
  return JSON.stringify(left).localeCompare(JSON.stringify(right));
@@ -3128,9 +2994,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3128
2994
  }, {
3129
2995
  key: "sanitizeTempOrderProducts",
3130
2996
  value: function sanitizeTempOrderProducts(tempOrder) {
3131
- var _this18 = this;
2997
+ var _this17 = this;
3132
2998
  tempOrder.products = (tempOrder.products || []).map(function (product) {
3133
- return _this18.sanitizeOrderProductForTempOrder(_this18.normalizeVirtualSettlementProductIfEnabled(product));
2999
+ return _this17.sanitizeOrderProductForTempOrder(_this17.normalizeVirtualSettlementProductIfEnabled(product));
3134
3000
  });
3135
3001
  this.syncTempOrderSettlementState(tempOrder);
3136
3002
  ensureUniqueProductLineUids(tempOrder);
@@ -3250,7 +3116,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3250
3116
  }, {
3251
3117
  key: "syncLinkedBookingHoldersToProducts",
3252
3118
  value: function syncLinkedBookingHoldersToProducts(tempOrder) {
3253
- var _this19 = this;
3119
+ var _this18 = this;
3254
3120
  var bookings = tempOrder.bookings || [];
3255
3121
  var products = tempOrder.products || [];
3256
3122
  if (!bookings.length || !products.length) return;
@@ -3275,7 +3141,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3275
3141
  var bookingUid = product.booking_uid || ((_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.booking_uid);
3276
3142
  var linkedBooking = (productUid !== undefined && productUid !== null && String(productUid) !== '' ? bookingByProductUid.get(String(productUid)) : undefined) || (bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '' ? bookingByBookingUid.get(String(bookingUid)) : undefined);
3277
3143
  if (linkedBooking) {
3278
- _this19.setProductHolderFromBooking(product, linkedBooking);
3144
+ _this18.setProductHolderFromBooking(product, linkedBooking);
3279
3145
  }
3280
3146
  });
3281
3147
  }
@@ -3403,9 +3269,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3403
3269
  }, {
3404
3270
  key: "findBookingIndexByUniqueIdentificationNumber",
3405
3271
  value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
3406
- var _this20 = this;
3272
+ var _this19 = this;
3407
3273
  return (tempOrder.bookings || []).findIndex(function (booking) {
3408
- return _this20.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
3274
+ return _this19.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
3409
3275
  });
3410
3276
  }
3411
3277
  }, {
@@ -3413,12 +3279,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3413
3279
  value: function removeLinkedBookingsForProduct(tempOrder, product) {
3414
3280
  var _product$metadata5,
3415
3281
  _product$metadata6,
3416
- _this21 = this;
3282
+ _this20 = this;
3417
3283
  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);
3418
3284
  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);
3419
3285
  if (!productUid && !bookingUid) return;
3420
3286
  tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
3421
- var currentBookingUid = _this21.getBookingUniqueIdentificationNumber(booking);
3287
+ var currentBookingUid = _this20.getBookingUniqueIdentificationNumber(booking);
3422
3288
  if (bookingUid && currentBookingUid === String(bookingUid)) return false;
3423
3289
  if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
3424
3290
  return true;
@@ -3720,7 +3586,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3720
3586
  }, {
3721
3587
  key: "removeSalesNotesForMissingProductLines",
3722
3588
  value: function removeSalesNotesForMissingProductLines(tempOrder) {
3723
- var _this22 = this;
3589
+ var _this21 = this;
3724
3590
  var state = this.ensureSalesNotesRuntimeState(tempOrder);
3725
3591
  if (!state.loaded || !Array.isArray(tempOrder.notes) || tempOrder.notes.length === 0) {
3726
3592
  return;
@@ -3732,7 +3598,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3732
3598
  return typeof uid === 'string' && uid.length > 0;
3733
3599
  }));
3734
3600
  var nextNotes = tempOrder.notes.filter(function (note) {
3735
- var primary = _this22.getSalesNotePrimaryRelation(note);
3601
+ var primary = _this21.getSalesNotePrimaryRelation(note);
3736
3602
  if (!primary || primary.target_type !== 'order_detail') return true;
3737
3603
  return remainingProductUids.has(primary.target_uuid);
3738
3604
  });
@@ -3744,7 +3610,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3744
3610
  key: "setSalesNoteOnTempOrder",
3745
3611
  value: function setSalesNoteOnTempOrder(tempOrder, input) {
3746
3612
  var _input$target,
3747
- _this23 = this,
3613
+ _this22 = this,
3748
3614
  _tempOrder$shop_order;
3749
3615
  this.ensureSalesNotesLoadedForMutation(tempOrder);
3750
3616
  var note_type = String(input.note_type || '').trim();
@@ -3768,7 +3634,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3768
3634
  var notes = tempOrder.notes || [];
3769
3635
  // 当前 allergy policy 固定同一商品行只保留一条;业务调用方不参与去重规则。
3770
3636
  var existingIndex = policy.uniquePerPrimaryTarget ? notes.findIndex(function (note) {
3771
- var primary = _this23.getSalesNotePrimaryRelation(note);
3637
+ var primary = _this22.getSalesNotePrimaryRelation(note);
3772
3638
  return note.note_type === note_type && (primary === null || primary === void 0 ? void 0 : primary.target_type) === 'order_detail' && primary.target_uuid === target_uuid;
3773
3639
  }) : -1;
3774
3640
  var existing = existingIndex >= 0 ? notes[existingIndex] : null;
@@ -4040,7 +3906,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4040
3906
  value: function isCustomerBoundDiscount(discount) {
4041
3907
  var _discount$type5;
4042
3908
  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;
4043
- return type === 'entitlement_pass' || type === 'good_pass' || type === 'discount_card' || type === 'product_discount_card';
3909
+ return type === 'good_pass' || type === 'discount_card' || type === 'product_discount_card';
4044
3910
  }
4045
3911
  }, {
4046
3912
  key: "shouldKeepCustomerBoundDiscountAfterCustomerChange",
@@ -4050,15 +3916,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4050
3916
  }, {
4051
3917
  key: "productHasCustomerBoundDiscount",
4052
3918
  value: function productHasCustomerBoundDiscount(product) {
4053
- var _this24 = this;
3919
+ var _this23 = this;
4054
3920
  if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
4055
- return _this24.isCustomerBoundDiscount(discount);
3921
+ return _this23.isCustomerBoundDiscount(discount);
4056
3922
  })) {
4057
3923
  return true;
4058
3924
  }
4059
3925
  return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
4060
3926
  return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
4061
- return _this24.isCustomerBoundDiscount(discount);
3927
+ return _this23.isCustomerBoundDiscount(discount);
4062
3928
  });
4063
3929
  });
4064
3930
  }
@@ -4067,18 +3933,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4067
3933
  value: function shouldSkipDiscountCalculation(tempOrder) {
4068
3934
  var _this$store$discount20,
4069
3935
  _this$store$discount21,
4070
- _this25 = this;
3936
+ _this24 = this;
4071
3937
  if (this.hasActiveCustomerBoundDiscount) return false;
4072
3938
  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)) || [];
4073
3939
  if (discountList.length > 0) return false;
4074
3940
  return !(tempOrder.products || []).some(function (product) {
4075
- return _this25.productHasCustomerBoundDiscount(product);
3941
+ return _this24.productHasCustomerBoundDiscount(product);
4076
3942
  });
4077
3943
  }
4078
3944
  }, {
4079
3945
  key: "clearCustomerBoundDiscounts",
4080
3946
  value: function clearCustomerBoundDiscounts(tempOrder) {
4081
- var _this26 = this,
3947
+ var _this25 = this,
4082
3948
  _discountModule$getDi,
4083
3949
  _discountModule$getOr,
4084
3950
  _discountModule$setDi,
@@ -4087,7 +3953,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4087
3953
  var filterDiscountList = function filterDiscountList(discountList) {
4088
3954
  if (!Array.isArray(discountList)) return [];
4089
3955
  return discountList.filter(function (discount) {
4090
- var shouldRemove = _this26.isCustomerBoundDiscount(discount);
3956
+ var shouldRemove = _this25.isCustomerBoundDiscount(discount);
4091
3957
  if (shouldRemove) didRemoveCustomerBoundDiscount = true;
4092
3958
  return !shouldRemove;
4093
3959
  });
@@ -4114,12 +3980,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4114
3980
  var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
4115
3981
  var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
4116
3982
  var nextDiscounts = currentDiscounts.filter(function (discount) {
4117
- if (_this26.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
4118
- return !_this26.isCustomerBoundDiscount(discount);
3983
+ if (_this25.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3984
+ return !_this25.isCustomerBoundDiscount(discount);
4119
3985
  });
4120
3986
  var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
4121
- if (_this26.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
4122
- return !_this26.isCustomerBoundDiscount(discount);
3987
+ if (_this25.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3988
+ return !_this25.isCustomerBoundDiscount(discount);
4123
3989
  });
4124
3990
  void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
4125
3991
  void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
@@ -4283,10 +4149,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4283
4149
  }, {
4284
4150
  key: "setOrderPayments",
4285
4151
  value: function setOrderPayments(payments) {
4286
- var _this27 = this;
4152
+ var _this26 = this;
4287
4153
  var tempOrder = this.ensureTempOrder();
4288
4154
  tempOrder.payments = mapPaymentItemsToOrderPayments((payments || []).map(function (payment) {
4289
- return _this27.normalizePaymentSource(payment, {
4155
+ return _this26.normalizePaymentSource(payment, {
4290
4156
  defaultPaid: false
4291
4157
  });
4292
4158
  }));
@@ -4341,7 +4207,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4341
4207
  }, {
4342
4208
  key: "addOrderPaymentWithDevicePrefix",
4343
4209
  value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
4344
- var _this28 = this;
4210
+ var _this27 = this;
4345
4211
  this.logInfo('addOrderPayment', {
4346
4212
  payment: payment
4347
4213
  });
@@ -4359,7 +4225,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4359
4225
  void this.recalculateSummary({
4360
4226
  createIfMissing: true
4361
4227
  }).catch(function (error) {
4362
- _this28.logError('recalculate summary after addOrderPayment failed', {
4228
+ _this27.logError('recalculate summary after addOrderPayment failed', {
4363
4229
  error: error instanceof Error ? error.message : String(error)
4364
4230
  });
4365
4231
  });
@@ -4472,7 +4338,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4472
4338
  }, {
4473
4339
  key: "applyPaymentLifecycleChange",
4474
4340
  value: function applyPaymentLifecycleChange(tempOrder, options) {
4475
- var _this29 = this;
4341
+ var _this28 = this;
4476
4342
  this.updateTempOrderPaymentStatus(tempOrder);
4477
4343
  if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
4478
4344
  this.persistTempOrder();
@@ -4482,7 +4348,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4482
4348
  void this.recalculateSummary({
4483
4349
  createIfMissing: true
4484
4350
  }).catch(function (error) {
4485
- _this29.logError("recalculate summary after ".concat(logContext, " failed"), {
4351
+ _this28.logError("recalculate summary after ".concat(logContext, " failed"), {
4486
4352
  error: error instanceof Error ? error.message : String(error)
4487
4353
  });
4488
4354
  });
@@ -4526,7 +4392,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4526
4392
  }, {
4527
4393
  key: "updateVoucherOrderPayments",
4528
4394
  value: function updateVoucherOrderPayments(payments, options) {
4529
- var _this30 = this;
4395
+ var _this29 = this;
4530
4396
  var tempOrder = this.ensureTempOrder();
4531
4397
  var isOrderPaymentType = function isOrderPaymentType(value) {
4532
4398
  return value === 'normal' || value === 'deposit';
@@ -4561,7 +4427,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4561
4427
  });
4562
4428
  };
4563
4429
  var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
4564
- return _this30.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
4430
+ return _this29.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
4565
4431
  defaultPaid: false,
4566
4432
  devicePrefix: options === null || options === void 0 ? void 0 : options.devicePrefix
4567
4433
  });
@@ -4614,7 +4480,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4614
4480
  void this.recalculateSummary({
4615
4481
  createIfMissing: true
4616
4482
  }).catch(function (error) {
4617
- _this30.logError('recalculate summary after updateVoucherOrderPayments failed', {
4483
+ _this29.logError('recalculate summary after updateVoucherOrderPayments failed', {
4618
4484
  error: error instanceof Error ? error.message : String(error)
4619
4485
  });
4620
4486
  });
@@ -4672,7 +4538,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4672
4538
  key: "shouldMergeProductToOrder",
4673
4539
  value: function shouldMergeProductToOrder(params) {
4674
4540
  var _this$orderHooks,
4675
- _this31 = this;
4541
+ _this30 = this;
4676
4542
  var onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
4677
4543
  if (!onBeforeMergeProductToOrder) return true;
4678
4544
  var result = onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
@@ -4680,7 +4546,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4680
4546
  }));
4681
4547
  if (result && _typeof(result) === 'object' && typeof result.then === 'function') {
4682
4548
  return Promise.resolve(result).then(function (resolved) {
4683
- return _this31.normalizeShouldMergeProductResult(resolved);
4549
+ return _this30.normalizeShouldMergeProductResult(resolved);
4684
4550
  });
4685
4551
  }
4686
4552
  return this.normalizeShouldMergeProductResult(result);
@@ -4881,7 +4747,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4881
4747
  _metadata,
4882
4748
  _productToAdd$metadat,
4883
4749
  _origin,
4884
- _this32 = this;
4750
+ _this31 = this;
4885
4751
  var linked = booking ? this.createLinkedProductAndBooking({
4886
4752
  product: product,
4887
4753
  booking: booking
@@ -4908,35 +4774,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4908
4774
  }
4909
4775
  normalizedIncoming.discount_list = normalizeOrderProductDiscountList(normalizedIncoming.discount_list);
4910
4776
  var hasIncomingGoodPass = this.hasGoodPassDiscount(normalizedIncoming);
4911
- var hasIncomingEntitlementPass = this.hasEntitlementPassDiscount(normalizedIncoming);
4912
- var isIncomingEntitlementAppend = this.isRuntimeEntitlementAppend(productToAdd, tempOrder);
4913
- var isIncomingPersistedEntitlementPass = hasIncomingEntitlementPass && this.isPersistedProductLine(normalizedIncoming);
4914
4777
  var hasIncomingProductNote = this.hasOrderProductLineNote(normalizedIncoming);
4915
4778
  var hasIncomingManualProductDiscount = isManualProductDiscountProduct(normalizedIncoming);
4916
4779
  var hasIncomingBookingUid = this.hasLinkedBookingUid(productToAdd) || this.hasLinkedBookingUid(normalizedIncoming);
4917
4780
  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;
4918
- var shouldForceNewLine = disableMerge || !!booking || hasIncomingGoodPass || isIncomingPersistedEntitlementPass || hasIncomingBookingUid || isIncomingCustomItem || isWeighingProduct;
4919
- var matchedIndex = shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
4920
- if (_this32.hasGoodPassDiscount(item)) return false;
4921
- var isRuntimeEntitlementPass = _this32.isRuntimeEntitlementAppend(item, tempOrder);
4922
- if (isIncomingEntitlementAppend !== isRuntimeEntitlementPass) {
4923
- return false;
4924
- }
4925
- if (isIncomingEntitlementAppend && _this32.isPersistedProductLine(item)) {
4926
- return false;
4927
- }
4928
- var hasExistingProductNote = _this32.hasOrderProductLineNote(item);
4929
- if ((hasIncomingProductNote || hasExistingProductNote) && (!isRuntimeEntitlementPass || String(normalizedIncoming.note || '').trim() !== String(item.note || '').trim())) {
4930
- return false;
4931
- }
4932
- var hasExistingManualProductDiscount = isManualProductDiscountProduct(item);
4933
- if (isRuntimeEntitlementPass && !_this32.hasSameEntitlementMergePriceConfig(normalizedIncoming, item)) {
4934
- return false;
4935
- }
4936
- if ((hasIncomingManualProductDiscount || hasExistingManualProductDiscount) && !isRuntimeEntitlementPass) {
4937
- return false;
4938
- }
4939
- if (_this32.isPersistedProductLine(item)) return false;
4781
+ var shouldForceNewLine = disableMerge || !!booking || hasIncomingProductNote || hasIncomingManualProductDiscount || hasIncomingBookingUid || isIncomingCustomItem || isWeighingProduct;
4782
+ var matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
4783
+ var _item$metadata3;
4784
+ if (_this31.hasGoodPassDiscount(item)) return false;
4785
+ if (_this31.hasOrderProductLineNote(item)) return false;
4786
+ if (isManualProductDiscountProduct(item)) return false;
4787
+ if (item.order_detail_id !== undefined && item.order_detail_id !== null) return false;
4788
+ if ((_item$metadata3 = item.metadata) !== null && _item$metadata3 !== void 0 && _item$metadata3.is_edit_for_runtime) return false;
4940
4789
  if (item.product_id !== productToAdd.product_id) return false;
4941
4790
  if (item.product_variant_id !== productToAdd.product_variant_id) return false;
4942
4791
  var existedFingerprint = buildProductLineFingerprint(getProductSkuOptions(item), item.product_bundle);
@@ -4947,7 +4796,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4947
4796
  var commitProductLine = function commitProductLine(shouldMerge) {
4948
4797
  var committedProduct;
4949
4798
  if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
4950
- _this32.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
4799
+ _this31.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
4951
4800
  if (linked) {
4952
4801
  normalizedIncoming.booking_uid = linked.bookingUid;
4953
4802
  normalizedIncoming.metadata = _objectSpread(_objectSpread({}, normalizedIncoming.metadata || {}), {}, {
@@ -4965,7 +4814,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4965
4814
  var _targetProduct$metada;
4966
4815
  var targetProduct = matchedProduct;
4967
4816
  var targetUid = (_targetProduct$metada = targetProduct.metadata) === null || _targetProduct$metada === void 0 ? void 0 : _targetProduct$metada.unique_identification_number;
4968
- var normalizedProduct = _this32.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(targetProduct, normalizeOrderProduct(_objectSpread(_objectSpread({}, productToAdd), {}, {
4817
+ var normalizedProduct = _this31.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(targetProduct, normalizeOrderProduct(_objectSpread(_objectSpread({}, productToAdd), {}, {
4969
4818
  metadata: _objectSpread(_objectSpread({}, productToAdd.metadata || {}), {}, {
4970
4819
  unique_identification_number: targetUid
4971
4820
  })
@@ -4988,7 +4837,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4988
4837
  order_detail_id: targetProduct.order_detail_id,
4989
4838
  num: nextNum
4990
4839
  });
4991
- _this32.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
4840
+ _this31.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
4992
4841
  committedProduct = tempOrder.products[matchedIndex];
4993
4842
  if (matchedIndex !== tempOrder.products.length - 1) {
4994
4843
  var mergedProduct = tempOrder.products[matchedIndex];
@@ -5098,7 +4947,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5098
4947
  key: "addProductToOrder",
5099
4948
  value: (function () {
5100
4949
  var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(product, booking, options) {
5101
- var _this33 = this;
4950
+ var _this32 = this;
5102
4951
  var tempOrder, salesNoteDrafts, mutationSnapshot, attachSalesNoteDrafts, rollbackProductAndNotesMutation, insertAfterProductUid, anchorIndex, insertAtIndex, _ref71, _productRecord$num, productRecord, splitCount, i, splitLine, committedProduct, _committedProduct, _committedProduct2;
5103
4952
  return _regeneratorRuntime().wrap(function _callee23$(_context25) {
5104
4953
  while (1) switch (_context25.prev = _context25.next) {
@@ -5127,7 +4976,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5127
4976
  throw new Error('[Order Notes] 商品行缺少 unique_identification_number');
5128
4977
  }
5129
4978
  salesNoteDrafts.forEach(function (draft) {
5130
- _this33.setSalesNoteOnTempOrder(tempOrder, {
4979
+ _this32.setSalesNoteOnTempOrder(tempOrder, {
5131
4980
  note_type: draft.note_type,
5132
4981
  target: {
5133
4982
  target_type: 'order_detail',
@@ -5361,99 +5210,45 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5361
5210
  return addProductsToOrder;
5362
5211
  }())
5363
5212
  }, {
5364
- key: "getFullCoveragePassDiscounts",
5365
- value: function getFullCoveragePassDiscounts(product) {
5213
+ key: "hasGoodPassDiscount",
5214
+ value: function hasGoodPassDiscount(product) {
5366
5215
  var _product$_extend;
5367
- var discountList = _toConsumableArray(product.discount_list || []);
5216
+ var hasMainGoodPass = (product.discount_list || []).some(function (item) {
5217
+ return (item === null || item === void 0 ? void 0 : item.type) === 'good_pass' || (item === null || item === void 0 ? void 0 : item.tag) === 'good_pass';
5218
+ });
5219
+ if (hasMainGoodPass) return true;
5220
+ var bundleDiscountList = [];
5368
5221
  (product.product_bundle || []).forEach(function (item) {
5369
- discountList.push.apply(discountList, _toConsumableArray((item === null || item === void 0 ? void 0 : item.discount_list) || []));
5222
+ bundleDiscountList.push.apply(bundleDiscountList, _toConsumableArray((item === null || item === void 0 ? void 0 : item.discount_list) || []));
5370
5223
  });
5371
5224
  ((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) {
5372
- discountList.push.apply(discountList, _toConsumableArray((item === null || item === void 0 ? void 0 : item.discount_list) || []));
5225
+ bundleDiscountList.push.apply(bundleDiscountList, _toConsumableArray((item === null || item === void 0 ? void 0 : item.discount_list) || []));
5373
5226
  });
5374
- return discountList.filter(function (item) {
5375
- return isFullCoveragePass(item);
5227
+ return bundleDiscountList.some(function (item) {
5228
+ return (item === null || item === void 0 ? void 0 : item.type) === 'good_pass' || (item === null || item === void 0 ? void 0 : item.tag) === 'good_pass';
5376
5229
  });
5377
5230
  }
5378
- }, {
5379
- key: "hasEntitlementPassDiscount",
5380
- value: function hasEntitlementPassDiscount(product) {
5381
- return this.getFullCoveragePassDiscounts(product).some(function (item) {
5382
- return isEntitlementPass(item);
5383
- });
5384
- }
5385
- }, {
5386
- key: "hasGoodPassDiscount",
5387
- value: function hasGoodPassDiscount(product) {
5388
- return this.getFullCoveragePassDiscounts(product).some(function (item) {
5389
- return !isEntitlementPass(item);
5390
- });
5391
- }
5392
- }, {
5393
- key: "isPersistedProductLine",
5394
- value: function isPersistedProductLine(product) {
5395
- var _product$metadata11;
5396
- 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;
5397
- }
5398
- }, {
5399
- key: "isRuntimeEntitlementAppend",
5400
- value: function isRuntimeEntitlementAppend(product, tempOrder) {
5401
- var _product$metadata$uni, _product$metadata12, _tempOrder$_extend10, _product$_origin;
5402
- if (this.isPersistedProductLine(product)) return false;
5403
- 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;
5404
- 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;
5405
- 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);
5406
- }
5407
- }, {
5408
- key: "hasSameEntitlementMergePriceConfig",
5409
- value: function hasSameEntitlementMergePriceConfig(incoming, existing) {
5410
- var _this34 = this;
5411
- var buildPriceConfig = function buildPriceConfig(product) {
5412
- var metadata = product.metadata || {};
5413
- var bundle = (product.product_bundle || []).map(function (item) {
5414
- var _ref73, _item$bundle_id, _ref74, _ref75, _item$bundle_product_, _ref76, _item$bundle_variant_, _ref77, _item$price_type, _ref78, _item$price_type_ext;
5415
- return {
5416
- 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,
5417
- 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,
5418
- 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,
5419
- 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 : '',
5420
- 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 : ''
5421
- };
5422
- }).sort(function (left, right) {
5423
- return JSON.stringify(left).localeCompare(JSON.stringify(right));
5424
- });
5425
- return JSON.stringify({
5426
- original_price: _this34.normalizeFingerprintMoney(product.original_price),
5427
- source_product_price: _this34.normalizeFingerprintMoney(metadata.source_product_price),
5428
- main_product_original_price: _this34.normalizeFingerprintMoney(metadata.main_product_original_price),
5429
- price_override: _this34.normalizeFingerprintMoney(metadata.price_override),
5430
- is_manual_discount: Boolean(metadata.is_manual_discount),
5431
- bundle: bundle
5432
- });
5433
- };
5434
- return buildPriceConfig(incoming) === buildPriceConfig(existing);
5435
- }
5436
5231
  }, {
5437
5232
  key: "getBundleRuntimeIdentity",
5438
5233
  value: function getBundleRuntimeIdentity(bundle) {
5439
- var _ref79, _bundle$bundle_id2, _ref80, _bundle$bundle_group_2, _ref81, _ref82, _bundle$bundle_produc3, _ref83, _bundle$bundle_varian3;
5234
+ var _ref73, _bundle$bundle_id2, _ref74, _bundle$bundle_group_2, _ref75, _ref76, _bundle$bundle_produc3, _ref77, _bundle$bundle_varian3;
5440
5235
  if (!bundle || _typeof(bundle) !== 'object') return '';
5441
- 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('|');
5236
+ return [(_ref73 = (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id) !== null && _ref73 !== void 0 ? _ref73 : '', (_ref74 = (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id) !== null && _ref74 !== void 0 ? _ref74 : '', (_ref75 = (_ref76 = (_bundle$bundle_produc3 = bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle._bundle_product_id) !== null && _ref76 !== void 0 ? _ref76 : bundle.product_id) !== null && _ref75 !== void 0 ? _ref75 : '', (_ref77 = (_bundle$bundle_varian3 = bundle.bundle_variant_id) !== null && _bundle$bundle_varian3 !== void 0 ? _bundle$bundle_varian3 : bundle.product_variant_id) !== null && _ref77 !== void 0 ? _ref77 : 0].join('|');
5442
5237
  }
5443
5238
  }, {
5444
5239
  key: "preservePersistedBundlePriceFields",
5445
5240
  value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
5446
- var _this35 = this;
5241
+ var _this33 = this;
5447
5242
  if (!Array.isArray(nextBundles)) return nextBundles;
5448
5243
  if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
5449
5244
  var previousByIdentity = new Map();
5450
5245
  previousBundles.forEach(function (bundle) {
5451
- var identity = _this35.getBundleRuntimeIdentity(bundle);
5246
+ var identity = _this33.getBundleRuntimeIdentity(bundle);
5452
5247
  if (identity) previousByIdentity.set(identity, bundle);
5453
5248
  });
5454
5249
  return nextBundles.map(function (bundle, index) {
5455
5250
  if (!bundle || _typeof(bundle) !== 'object') return bundle;
5456
- var previous = previousByIdentity.get(_this35.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
5251
+ var previous = previousByIdentity.get(_this33.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
5457
5252
  if (!previous || _typeof(previous) !== 'object') return bundle;
5458
5253
  return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
5459
5254
  cover: previous.cover
@@ -5469,8 +5264,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5469
5264
  }
5470
5265
  }, {
5471
5266
  key: "applyOrderProductUpdateToTempOrder",
5472
- value: function applyOrderProductUpdateToTempOrder(tempOrder, params) {
5473
- var _targetProduct$metada2, _product_sku, _metadata2, _metadata3, _metadata4, _metadata5, _metadata6, _metadata7, _metadata8, _metadata9, _metadata10, _nextProduct$metadata, _targetProduct$metada15, _tempOrder$products$p, _tempOrder$products$p2;
5267
+ value: function applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids) {
5268
+ var _targetProduct$metada2, _product_sku, _metadata2, _metadata3, _metadata4, _metadata5, _metadata6, _metadata7, _metadata8, _metadata9, _metadata10, _nextProduct$metadata2, _targetProduct$metada20, _tempOrder$products$p, _tempOrder$products$p2;
5474
5269
  var product_id = params.product_id,
5475
5270
  product_variant_id = params.product_variant_id,
5476
5271
  updates = params.updates,
@@ -5536,7 +5331,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5536
5331
  var previousLineFingerprint = buildProductLineFingerprint(getProductSkuOptions(targetProduct), targetProduct.product_bundle);
5537
5332
  var nextLineFingerprint = buildProductLineFingerprint(getProductSkuOptions(nextProduct), nextProduct.product_bundle);
5538
5333
  var callerChangesVariant = Number(product_variant_id || 0) !== Number(targetProduct.product_variant_id || 0);
5539
- var callerChangesLineConfiguration = callerChangesVariant || previousLineFingerprint !== nextLineFingerprint;
5334
+ var callerChangesWeighing = getWeighedProductPriceFingerprint(targetProduct.product_sku) !== getWeighedProductPriceFingerprint(nextProduct.product_sku);
5335
+ var callerChangesLineConfiguration = callerChangesVariant || callerChangesWeighing || previousLineFingerprint !== nextLineFingerprint;
5540
5336
  var isPersistedOrderLine = targetProduct.order_detail_id !== undefined && targetProduct.order_detail_id !== null;
5541
5337
  var callerChangesDiscountList = Array.isArray(updates === null || updates === void 0 ? void 0 : updates.discount_list) && updates.discount_list.length > 0 && !isSameDiscountList(updates.discount_list, targetProduct.discount_list);
5542
5338
  var callerUpdatesManualPrice = (updates === null || updates === void 0 || (_metadata8 = updates.metadata) === null || _metadata8 === void 0 ? void 0 : _metadata8.price_override) !== undefined || (updates === null || updates === void 0 || (_metadata9 = updates.metadata) === null || _metadata9 === void 0 ? void 0 : _metadata9.is_manual_discount) !== undefined || (updates === null || updates === void 0 || (_metadata10 = updates.metadata) === null || _metadata10 === void 0 ? void 0 : _metadata10.product_discount_reason) !== undefined || callerChangesDiscountList;
@@ -5552,33 +5348,50 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5552
5348
  };
5553
5349
  return hasChangedPrice(updates.selling_price, targetProduct.selling_price) || hasChangedPrice(updates.original_price, targetProduct.original_price);
5554
5350
  }();
5351
+ var weighedSourcePrice = callerChangesWeighing ? resolveWeighedSourcePrice(nextProduct.product_sku) : undefined;
5352
+ var hasResolvedWeighedPrice = weighedSourcePrice !== undefined;
5353
+ if (hasResolvedWeighedPrice && !callerUpdatesSourcePrice) {
5354
+ var _ref78, _targetProduct$metada3, _targetProduct$metada4, _ref79, _targetProduct$metada5, _targetProduct$metada6;
5355
+ var nextMainOriginal = new Decimal(weighedSourcePrice).plus(sumOptionUnitPrice(getProductSkuOptions(nextProduct)));
5356
+ var previousMainOriginal = new Decimal((_ref78 = (_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 && _ref78 !== void 0 ? _ref78 : 0);
5357
+ var previousMainSelling = new Decimal((_ref79 = (_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 && _ref79 !== void 0 ? _ref79 : 0);
5358
+ // A manual final price remains fixed; other legacy discounts keep their amount
5359
+ // until Rules reapplies the currently selected wallet discount below.
5360
+ var nextMainSelling = isManualProductDiscountProduct(nextProduct) ? previousMainSelling : nextMainOriginal.minus(previousMainOriginal.minus(previousMainSelling));
5361
+ nextProduct.metadata = _objectSpread(_objectSpread({}, nextProduct.metadata), {}, {
5362
+ source_product_price: weighedSourcePrice,
5363
+ main_product_original_price: callerUpdatesMainOriginalPrice ? nextProduct.metadata.main_product_original_price : nextMainOriginal.toFixed(2),
5364
+ main_product_selling_price: callerUpdatesMainSellingPrice ? nextProduct.metadata.main_product_selling_price : Decimal.max(0, nextMainSelling).toFixed(2),
5365
+ price_schema_version: 2
5366
+ });
5367
+ }
5555
5368
  if (isPersistedOrderLine && !callerChangesLineConfiguration && !callerUpdatesManualPrice && !callerAllowsBookingReprice) {
5556
- var _targetProduct$metada3, _targetProduct$metada4, _targetProduct$metada5, _targetProduct$metada6, _targetProduct$metada7;
5369
+ var _targetProduct$metada7, _targetProduct$metada8, _targetProduct$metada9, _targetProduct$metada10, _targetProduct$metada11;
5557
5370
  nextProduct.selling_price = targetProduct.selling_price;
5558
5371
  nextProduct.original_price = targetProduct.original_price;
5559
5372
  nextProduct.payment_price = targetProduct.payment_price;
5560
5373
  nextProduct.metadata = _objectSpread(_objectSpread({}, nextProduct.metadata || {}), {}, {
5561
- source_product_price: (_targetProduct$metada3 = targetProduct.metadata) === null || _targetProduct$metada3 === void 0 ? void 0 : _targetProduct$metada3.source_product_price,
5562
- main_product_selling_price: (_targetProduct$metada4 = targetProduct.metadata) === null || _targetProduct$metada4 === void 0 ? void 0 : _targetProduct$metada4.main_product_selling_price,
5563
- main_product_original_price: (_targetProduct$metada5 = targetProduct.metadata) === null || _targetProduct$metada5 === void 0 ? void 0 : _targetProduct$metada5.main_product_original_price,
5564
- price_schema_version: (_targetProduct$metada6 = (_targetProduct$metada7 = targetProduct.metadata) === null || _targetProduct$metada7 === void 0 ? void 0 : _targetProduct$metada7.price_schema_version) !== null && _targetProduct$metada6 !== void 0 ? _targetProduct$metada6 : 2
5374
+ source_product_price: (_targetProduct$metada7 = targetProduct.metadata) === null || _targetProduct$metada7 === void 0 ? void 0 : _targetProduct$metada7.source_product_price,
5375
+ main_product_selling_price: (_targetProduct$metada8 = targetProduct.metadata) === null || _targetProduct$metada8 === void 0 ? void 0 : _targetProduct$metada8.main_product_selling_price,
5376
+ main_product_original_price: (_targetProduct$metada9 = targetProduct.metadata) === null || _targetProduct$metada9 === void 0 ? void 0 : _targetProduct$metada9.main_product_original_price,
5377
+ price_schema_version: (_targetProduct$metada10 = (_targetProduct$metada11 = targetProduct.metadata) === null || _targetProduct$metada11 === void 0 ? void 0 : _targetProduct$metada11.price_schema_version) !== null && _targetProduct$metada10 !== void 0 ? _targetProduct$metada10 : 2
5565
5378
  });
5566
5379
  nextProduct.product_bundle = this.preservePersistedBundlePriceFields(targetProduct.product_bundle, nextProduct.product_bundle);
5567
5380
  } else if (callerChangesLineConfiguration && callerUpdatesSourcePrice && (!callerUpdatesMainSellingPrice || !callerUpdatesMainOriginalPrice)) {
5568
- var _targetProduct$metada8, _targetProduct$metada9;
5381
+ var _targetProduct$metada12, _targetProduct$metada13, _targetProduct$metada14;
5569
5382
  // 新配置只传了 source 时,不能把未传的 main_product_* 从旧行继承下来。
5570
5383
  // 以新 source + 新 option 重建券前价;券后价未显式提供时保留旧主商品折扣额。
5571
- var previousMainOriginal = new Decimal(Number((_targetProduct$metada8 = targetProduct.metadata) === null || _targetProduct$metada8 === void 0 ? void 0 : _targetProduct$metada8.main_product_original_price) || 0);
5572
- var previousMainSelling = new Decimal(Number((_targetProduct$metada9 = targetProduct.metadata) === null || _targetProduct$metada9 === void 0 ? void 0 : _targetProduct$metada9.main_product_selling_price) || previousMainOriginal.toNumber());
5573
- var preservedDiscount = previousMainOriginal.minus(previousMainSelling);
5574
- var nextMainOriginal = new Decimal(Number(updates.metadata.source_product_price) || 0).plus(sumOptionUnitPrice(getProductSkuOptions(nextProduct)));
5384
+ var _previousMainOriginal = new Decimal(Number((_targetProduct$metada12 = targetProduct.metadata) === null || _targetProduct$metada12 === void 0 ? void 0 : _targetProduct$metada12.main_product_original_price) || 0);
5385
+ var _previousMainSelling = new Decimal(Number((_targetProduct$metada13 = (_targetProduct$metada14 = targetProduct.metadata) === null || _targetProduct$metada14 === void 0 ? void 0 : _targetProduct$metada14.main_product_selling_price) !== null && _targetProduct$metada13 !== void 0 ? _targetProduct$metada13 : _previousMainOriginal.toNumber()));
5386
+ var preservedDiscount = _previousMainOriginal.minus(_previousMainSelling);
5387
+ var _nextMainOriginal = new Decimal(Number(updates.metadata.source_product_price) || 0).plus(sumOptionUnitPrice(getProductSkuOptions(nextProduct)));
5575
5388
  nextProduct.metadata = _objectSpread(_objectSpread({}, nextProduct.metadata || {}), {}, {
5576
5389
  source_product_price: String(updates.metadata.source_product_price),
5577
- main_product_original_price: callerUpdatesMainOriginalPrice ? String(updates.metadata.main_product_original_price) : nextMainOriginal.toDecimalPlaces(2).toFixed(2),
5578
- main_product_selling_price: callerUpdatesMainSellingPrice ? String(updates.metadata.main_product_selling_price) : nextMainOriginal.minus(preservedDiscount).toDecimalPlaces(2).toFixed(2),
5390
+ main_product_original_price: callerUpdatesMainOriginalPrice ? String(updates.metadata.main_product_original_price) : _nextMainOriginal.toDecimalPlaces(2).toFixed(2),
5391
+ main_product_selling_price: callerUpdatesMainSellingPrice ? String(updates.metadata.main_product_selling_price) : hasResolvedWeighedPrice && isManualProductDiscountProduct(nextProduct) ? _previousMainSelling.toFixed(2) : _nextMainOriginal.minus(preservedDiscount).toDecimalPlaces(2).toFixed(2),
5579
5392
  price_schema_version: 2
5580
5393
  });
5581
- } else if (callerChangesVariant && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
5394
+ } else if (callerChangesVariant && !hasResolvedWeighedPrice && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
5582
5395
  // variant 已变化但 caller 没有显式报价时,旧 v2 metadata 不能继续充当权威价格源。
5583
5396
  // 清理后由 normalize 优先读取 metadata.origin.variant 中新 variant 的目录价;
5584
5397
  // 顶层 original/selling 的旧差额仍会作为 legacy discount 迁移到新价格。
@@ -5588,24 +5401,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5588
5401
  delete nextProduct.metadata.main_product_selling_price;
5589
5402
  delete nextProduct.metadata.main_product_original_price;
5590
5403
  delete nextProduct.metadata.price_schema_version;
5591
- } else if (callerChangesLineConfiguration && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
5592
- var _ref84, _targetProduct$metada10, _targetProduct$metada11, _ref85, _targetProduct$metada12, _targetProduct$metada13, _targetProduct$metada14;
5404
+ } else if (callerChangesLineConfiguration && !hasResolvedWeighedPrice && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
5405
+ var _ref80, _targetProduct$metada15, _targetProduct$metada16, _ref81, _targetProduct$metada17, _targetProduct$metada18, _targetProduct$metada19;
5593
5406
  // 仅 option / bundle 变化时,保留历史 source 和主商品折扣金额,
5594
5407
  // 但必须让 original 与 selling 一起随新的 option 金额移动。
5595
5408
  var previousOptionSum = sumOptionUnitPrice(getProductSkuOptions(targetProduct));
5596
5409
  var nextOptionSum = sumOptionUnitPrice(getProductSkuOptions(nextProduct));
5597
- var _previousMainOriginal = new Decimal(Number((_ref84 = (_targetProduct$metada10 = (_targetProduct$metada11 = targetProduct.metadata) === null || _targetProduct$metada11 === void 0 ? void 0 : _targetProduct$metada11.main_product_original_price) !== null && _targetProduct$metada10 !== void 0 ? _targetProduct$metada10 : targetProduct.original_price) !== null && _ref84 !== void 0 ? _ref84 : 0) || 0);
5598
- var _previousMainSelling = new Decimal(Number((_ref85 = (_targetProduct$metada12 = (_targetProduct$metada13 = targetProduct.metadata) === null || _targetProduct$metada13 === void 0 ? void 0 : _targetProduct$metada13.main_product_selling_price) !== null && _targetProduct$metada12 !== void 0 ? _targetProduct$metada12 : targetProduct.selling_price) !== null && _ref85 !== void 0 ? _ref85 : _previousMainOriginal.toNumber()) || 0);
5599
- var _preservedDiscount = _previousMainOriginal.minus(_previousMainSelling);
5600
- var previousSource = ((_targetProduct$metada14 = targetProduct.metadata) === null || _targetProduct$metada14 === void 0 ? void 0 : _targetProduct$metada14.source_product_price) != null ? new Decimal(Number(targetProduct.metadata.source_product_price) || 0) : _previousMainOriginal.minus(previousOptionSum);
5601
- var _nextMainOriginal = previousSource.plus(nextOptionSum);
5410
+ var _previousMainOriginal2 = new Decimal(Number((_ref80 = (_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 && _ref80 !== void 0 ? _ref80 : 0) || 0);
5411
+ var _previousMainSelling2 = new Decimal(Number((_ref81 = (_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 && _ref81 !== void 0 ? _ref81 : _previousMainOriginal2.toNumber()) || 0);
5412
+ var _preservedDiscount = _previousMainOriginal2.minus(_previousMainSelling2);
5413
+ 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);
5414
+ var _nextMainOriginal2 = previousSource.plus(nextOptionSum);
5602
5415
  nextProduct.metadata = _objectSpread(_objectSpread({}, nextProduct.metadata || {}), {}, {
5603
5416
  source_product_price: previousSource.toDecimalPlaces(2).toFixed(2),
5604
- main_product_original_price: _nextMainOriginal.toDecimalPlaces(2).toFixed(2),
5605
- main_product_selling_price: _nextMainOriginal.minus(_preservedDiscount).toDecimalPlaces(2).toFixed(2),
5417
+ main_product_original_price: _nextMainOriginal2.toDecimalPlaces(2).toFixed(2),
5418
+ main_product_selling_price: _nextMainOriginal2.minus(_preservedDiscount).toDecimalPlaces(2).toFixed(2),
5606
5419
  price_schema_version: 2
5607
5420
  });
5608
- } else if (callerUpdatesTopPrice && !callerUpdatesMainMeta) {
5421
+ } else if (callerUpdatesTopPrice && !callerUpdatesMainMeta && !hasResolvedWeighedPrice) {
5609
5422
  var _existedMeta = nextProduct.metadata || {};
5610
5423
  nextProduct.metadata = _objectSpread({}, _existedMeta);
5611
5424
  delete nextProduct.metadata.source_product_price;
@@ -5613,11 +5426,40 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5613
5426
  delete nextProduct.metadata.main_product_original_price;
5614
5427
  delete nextProduct.metadata.price_schema_version;
5615
5428
  }
5429
+ if (callerChangesLineConfiguration && resolveWeighedSourcePrice(nextProduct.product_sku) !== undefined && nextProduct.metadata.main_product_original_price != null && nextProduct.metadata.main_product_selling_price != null && isManualProductDiscountProduct(nextProduct)) {
5430
+ var _nextProduct$metadata;
5431
+ var originalPrice = composeLinePrice({
5432
+ mainPrice: nextProduct.metadata.main_product_original_price,
5433
+ bundle: withOriginalBundleOptionPrices(nextProduct.product_bundle),
5434
+ useOriginalBundle: true
5435
+ });
5436
+ var sellingPrice = composeLinePrice({
5437
+ mainPrice: nextProduct.metadata.main_product_selling_price,
5438
+ bundle: nextProduct.product_bundle
5439
+ });
5440
+ var previousManualDiscount = findManualProductDiscountItem(nextProduct.discount_list);
5441
+ nextProduct.original_price = originalPrice;
5442
+ nextProduct.metadata = _objectSpread(_objectSpread({}, nextProduct.metadata), {}, {
5443
+ origin: _objectSpread(_objectSpread({}, nextProduct.metadata.origin), {}, {
5444
+ _extend: _objectSpread(_objectSpread({}, (_nextProduct$metadata = nextProduct.metadata.origin) === null || _nextProduct$metadata === void 0 ? void 0 : _nextProduct$metadata._extend), {}, {
5445
+ origin_total: Number(originalPrice)
5446
+ })
5447
+ })
5448
+ });
5449
+ nextProduct.discount_list = mergeManualProductDiscountIntoList(nextProduct.discount_list, buildManualProductDiscountItem({
5450
+ originTotal: Number(originalPrice),
5451
+ sellingTotal: Number(sellingPrice),
5452
+ quantity: nextProduct.num,
5453
+ message: previousManualDiscount === null || previousManualDiscount === void 0 ? void 0 : previousManualDiscount.discount.message,
5454
+ discountway: previousManualDiscount === null || previousManualDiscount === void 0 ? void 0 : previousManualDiscount.discount.discountway,
5455
+ discount_per: previousManualDiscount === null || previousManualDiscount === void 0 ? void 0 : previousManualDiscount.discount.discount_per
5456
+ }));
5457
+ }
5616
5458
  // normalizeOrderProduct 幂等:v2 metadata 存在 → 保留 main_product_* 折扣重算 composite;
5617
5459
  // 否则 → 把顶层 selling_price 视作 source,派生 main_product_* 并写 price_schema_version: 2。
5618
5460
  var normalizedProduct = this.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(nextProduct, normalizeOrderProduct(nextProduct)));
5619
- normalizedProduct.discount_list = normalizeOrderProductDiscountList(isPersistedOrderLine ? syncReducedEntitlementPassUsageCount(normalizedProduct.discount_list, targetProduct.num, normalizedProduct.num) : normalizedProduct.discount_list);
5620
- var preservedBookingUid = nextProduct.booking_uid || ((_nextProduct$metadata = nextProduct.metadata) === null || _nextProduct$metadata === void 0 ? void 0 : _nextProduct$metadata.booking_uid) || targetProduct.booking_uid || ((_targetProduct$metada15 = targetProduct.metadata) === null || _targetProduct$metada15 === void 0 ? void 0 : _targetProduct$metada15.booking_uid);
5461
+ normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
5462
+ 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);
5621
5463
  if (!booking && preservedBookingUid) {
5622
5464
  normalizedProduct.booking_uid = preservedBookingUid;
5623
5465
  normalizedProduct.metadata = _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
@@ -5625,8 +5467,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5625
5467
  });
5626
5468
  }
5627
5469
  if (booking) {
5628
- var _normalizedProduct$me, _targetProduct$metada16;
5629
- var productUid = String(((_normalizedProduct$me = normalizedProduct.metadata) === null || _normalizedProduct$me === void 0 ? void 0 : _normalizedProduct$me.unique_identification_number) || ((_targetProduct$metada16 = targetProduct.metadata) === null || _targetProduct$metada16 === void 0 ? void 0 : _targetProduct$metada16.unique_identification_number) || unique_identification_number || createUuidV4());
5470
+ var _normalizedProduct$me, _targetProduct$metada21;
5471
+ var productUid = String(((_normalizedProduct$me = normalizedProduct.metadata) === null || _normalizedProduct$me === void 0 ? void 0 : _normalizedProduct$me.unique_identification_number) || ((_targetProduct$metada21 = targetProduct.metadata) === null || _targetProduct$metada21 === void 0 ? void 0 : _targetProduct$metada21.unique_identification_number) || unique_identification_number || createUuidV4());
5630
5472
  normalizedProduct.metadata = _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
5631
5473
  unique_identification_number: productUid
5632
5474
  });
@@ -5646,6 +5488,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5646
5488
  });
5647
5489
  tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
5648
5490
  }
5491
+ if (callerChangesWeighing && !isManualProductDiscountProduct(normalizedProduct)) {
5492
+ var _normalizedProduct$me2;
5493
+ var uid = (_normalizedProduct$me2 = normalizedProduct.metadata) === null || _normalizedProduct$me2 === void 0 ? void 0 : _normalizedProduct$me2.unique_identification_number;
5494
+ if (uid) reapplyWeighedDiscountProductUids === null || reapplyWeighedDiscountProductUids === void 0 || reapplyWeighedDiscountProductUids.push(String(uid));
5495
+ }
5649
5496
  tempOrder.products[productIndex] = normalizedProduct;
5650
5497
  this.syncTempOrderHolderFromBookings(tempOrder);
5651
5498
  this.captureProductRuntime(tempOrder, updates, tempOrder.products[productIndex], (_tempOrder$products$p = tempOrder.products[productIndex].metadata) === null || _tempOrder$products$p === void 0 ? void 0 : _tempOrder$products$p.unique_identification_number);
@@ -5655,32 +5502,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5655
5502
  key: "updateOrderProduct",
5656
5503
  value: function () {
5657
5504
  var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
5658
- var tempOrder, updatedProductUid, promotionPayload;
5505
+ var tempOrder, reapplyWeighedDiscountProductUids, updatedProductUid, promotionPayload;
5659
5506
  return _regeneratorRuntime().wrap(function _callee25$(_context27) {
5660
5507
  while (1) switch (_context27.prev = _context27.next) {
5661
5508
  case 0:
5662
5509
  tempOrder = this.ensureTempOrder();
5663
- updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params);
5664
- _context27.next = 4;
5510
+ reapplyWeighedDiscountProductUids = [];
5511
+ updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
5512
+ _context27.next = 5;
5665
5513
  return this.evaluatePromotion();
5666
- case 4:
5514
+ case 5:
5667
5515
  promotionPayload = _context27.sent;
5668
5516
  this.applyDiscount({
5517
+ reapplyWeighedDiscountProductUids: reapplyWeighedDiscountProductUids,
5669
5518
  reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
5670
5519
  });
5671
5520
  this.sanitizeTempOrderProducts(tempOrder);
5672
- _context27.next = 9;
5521
+ _context27.next = 10;
5673
5522
  return this.recalculateSummary({
5674
5523
  createIfMissing: true
5675
5524
  });
5676
- case 9:
5525
+ case 10:
5677
5526
  this.persistTempOrder();
5678
5527
  this.emitPromotionApplied(promotionPayload);
5679
5528
  this.logInfo('updateOrderProduct success', {
5680
5529
  params: params
5681
5530
  });
5682
5531
  return _context27.abrupt("return", tempOrder.products);
5683
- case 13:
5532
+ case 14:
5684
5533
  case "end":
5685
5534
  return _context27.stop();
5686
5535
  }
@@ -5695,8 +5544,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5695
5544
  key: "updateOrderProducts",
5696
5545
  value: function () {
5697
5546
  var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(paramsList) {
5698
- var _this36 = this;
5699
- var tempOrder, reapplyBookingDiscountProductUids;
5547
+ var _this34 = this;
5548
+ var tempOrder, reapplyWeighedDiscountProductUids, reapplyBookingDiscountProductUids;
5700
5549
  return _regeneratorRuntime().wrap(function _callee26$(_context28) {
5701
5550
  while (1) switch (_context28.prev = _context28.next) {
5702
5551
  case 0:
@@ -5707,24 +5556,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5707
5556
  }
5708
5557
  return _context28.abrupt("return", tempOrder.products);
5709
5558
  case 3:
5559
+ reapplyWeighedDiscountProductUids = [];
5710
5560
  reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
5711
- var updatedProductUid = _this36.applyOrderProductUpdateToTempOrder(tempOrder, params);
5561
+ var updatedProductUid = _this34.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
5712
5562
  // 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
5713
5563
  if (params.allow_booking_discount_reapply && updatedProductUid) {
5714
5564
  acc.push(String(updatedProductUid));
5715
5565
  }
5716
5566
  return acc;
5717
5567
  }, []);
5718
- _context28.next = 6;
5568
+ _context28.next = 7;
5719
5569
  return this.finalizeAfterProductsMutation(tempOrder, {
5570
+ reapplyWeighedDiscountProductUids: reapplyWeighedDiscountProductUids,
5720
5571
  reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
5721
5572
  });
5722
- case 6:
5573
+ case 7:
5723
5574
  this.logInfo('updateOrderProduct success', {
5724
5575
  paramsList: paramsList
5725
5576
  });
5726
5577
  return _context28.abrupt("return", tempOrder.products);
5727
- case 8:
5578
+ case 9:
5728
5579
  case "end":
5729
5580
  return _context28.stop();
5730
5581
  }
@@ -5739,8 +5590,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5739
5590
  key: "updateOrderProductQuantity",
5740
5591
  value: function () {
5741
5592
  var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
5742
- var _targetProduct$metada17;
5743
- 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;
5593
+ var _targetProduct$metada22;
5594
+ 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;
5744
5595
  return _regeneratorRuntime().wrap(function _callee27$(_context29) {
5745
5596
  while (1) switch (_context29.prev = _context29.next) {
5746
5597
  case 0:
@@ -5778,17 +5629,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5778
5629
  throw new Error('[Order] 目标商品不存在,无法更新数量');
5779
5630
  case 13:
5780
5631
  targetProduct = tempOrder.products[productIndex];
5781
- isPersistedOrderLine = targetProduct.order_detail_id !== undefined && targetProduct.order_detail_id !== null;
5782
5632
  normalizedProduct = this.normalizeVirtualSettlementProductIfEnabled(normalizeOrderProduct(_objectSpread(_objectSpread({}, targetProduct), {}, {
5783
5633
  num: getSafeProductNum(num),
5784
5634
  metadata: _objectSpread(_objectSpread({}, targetProduct.metadata || {}), {}, {
5785
- unique_identification_number: ((_targetProduct$metada17 = targetProduct.metadata) === null || _targetProduct$metada17 === void 0 ? void 0 : _targetProduct$metada17.unique_identification_number) || unique_identification_number
5635
+ unique_identification_number: ((_targetProduct$metada22 = targetProduct.metadata) === null || _targetProduct$metada22 === void 0 ? void 0 : _targetProduct$metada22.unique_identification_number) || unique_identification_number
5786
5636
  })
5787
5637
  })));
5788
- normalizedProduct.discount_list = normalizeOrderProductDiscountList(isPersistedOrderLine ? syncReducedEntitlementPassUsageCount(normalizedProduct.discount_list, targetProduct.num, normalizedProduct.num) : normalizedProduct.discount_list);
5638
+ normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
5789
5639
  settlementSnapshot = getSelectedSettlementSnapshot(normalizedProduct);
5790
5640
  if (!(this.isMultiCurrencySettlementEnabled() && (settlementSnapshot === null || settlementSnapshot === void 0 ? void 0 : settlementSnapshot.settlement_type) === 'virtual_currency' && tempOrder.customer_id && Number(tempOrder.customer_id) !== 1)) {
5791
- _context29.next = 27;
5641
+ _context29.next = 26;
5792
5642
  break;
5793
5643
  }
5794
5644
  currencyProductId = Number(settlementSnapshot.currency_product_id);
@@ -5796,11 +5646,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5796
5646
  return Number(item === null || item === void 0 ? void 0 : item.product_id) === currencyProductId;
5797
5647
  });
5798
5648
  if (asset) {
5799
- _context29.next = 23;
5649
+ _context29.next = 22;
5800
5650
  break;
5801
5651
  }
5802
5652
  throw new VirtualCurrencyAssetNotFoundError(currencyProductId);
5803
- case 23:
5653
+ case 22:
5804
5654
  requiredAmount = tempOrder.products.reduce(function (sum, item, index) {
5805
5655
  var current = index === productIndex ? normalizedProduct : item;
5806
5656
  var currentSnapshot = getSelectedSettlementSnapshot(current);
@@ -5808,44 +5658,44 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5808
5658
  }, new Decimal(0));
5809
5659
  balance = new Decimal(asset.balance || 0);
5810
5660
  if (!balance.lt(requiredAmount)) {
5811
- _context29.next = 27;
5661
+ _context29.next = 26;
5812
5662
  break;
5813
5663
  }
5814
5664
  throw new VirtualCurrencyBalanceError(balance.toFixed(2), requiredAmount.toFixed(2));
5815
- case 27:
5665
+ case 26:
5816
5666
  tempOrder.products[productIndex] = normalizedProduct;
5817
5667
  this.prepareVirtualSettlementTempOrder(tempOrder);
5818
5668
  isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder);
5819
5669
  if (isVirtualSettlement) {
5820
- _context29.next = 36;
5670
+ _context29.next = 35;
5821
5671
  break;
5822
5672
  }
5823
- _context29.next = 33;
5673
+ _context29.next = 32;
5824
5674
  return this.evaluatePromotion();
5825
- case 33:
5675
+ case 32:
5826
5676
  _context29.t0 = _context29.sent;
5827
- _context29.next = 37;
5677
+ _context29.next = 36;
5828
5678
  break;
5829
- case 36:
5679
+ case 35:
5830
5680
  _context29.t0 = null;
5831
- case 37:
5681
+ case 36:
5832
5682
  promotionPayload = _context29.t0;
5833
5683
  if (!isVirtualSettlement) {
5834
5684
  this.applyDiscount();
5835
5685
  }
5836
5686
  this.sanitizeTempOrderProducts(tempOrder);
5837
- _context29.next = 42;
5687
+ _context29.next = 41;
5838
5688
  return this.recalculateSummary({
5839
5689
  createIfMissing: true
5840
5690
  });
5841
- case 42:
5691
+ case 41:
5842
5692
  this.persistTempOrder();
5843
5693
  this.emitPromotionApplied(promotionPayload);
5844
5694
  this.logInfo('updateOrderProductQuantity success', {
5845
5695
  params: params
5846
5696
  });
5847
5697
  return _context29.abrupt("return", tempOrder.products);
5848
- case 46:
5698
+ case 45:
5849
5699
  case "end":
5850
5700
  return _context29.stop();
5851
5701
  }
@@ -5903,7 +5753,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5903
5753
  case 3:
5904
5754
  promotionPayload = _context30.sent;
5905
5755
  this.applyDiscount({
5906
- reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids
5756
+ reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids,
5757
+ reapplyWeighedDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyWeighedDiscountProductUids
5907
5758
  });
5908
5759
  this.sanitizeTempOrderProducts(tempOrder);
5909
5760
  _context30.next = 8;
@@ -5935,7 +5786,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5935
5786
  key: "removeProductsFromOrder",
5936
5787
  value: (function () {
5937
5788
  var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(identities, options) {
5938
- var _this37 = this;
5789
+ var _this35 = this;
5939
5790
  var tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
5940
5791
  return _regeneratorRuntime().wrap(function _callee29$(_context32) {
5941
5792
  while (1) switch (_context32.prev = _context32.next) {
@@ -6000,7 +5851,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6000
5851
  }
6001
5852
  if (productUid !== undefined && productUid !== null && productUid !== '') {
6002
5853
  bookingsBeforeRemove.forEach(function (booking) {
6003
- var bookingUid = _this37.getBookingUniqueIdentificationNumber(booking);
5854
+ var bookingUid = _this35.getBookingUniqueIdentificationNumber(booking);
6004
5855
  if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
6005
5856
  linkedBookingUidsToRemove.add(bookingUid);
6006
5857
  }
@@ -6215,23 +6066,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6215
6066
  }, {
6216
6067
  key: "buildCurrentSubmitPayloadForLocalPrint",
6217
6068
  value: function buildCurrentSubmitPayloadForLocalPrint(params) {
6218
- var _params$cacheId, _this$otherParams5, _ref86, _params$businessCode, _this$otherParams6, _this$otherParams7;
6069
+ var _params$cacheId, _this$otherParams5, _ref82, _params$businessCode, _this$otherParams6, _this$otherParams7;
6219
6070
  var tempOrder = this.ensureTempOrder();
6220
6071
  this.persistTempOrder();
6221
6072
  var payload = buildSubmitPayload({
6222
6073
  tempOrder: tempOrder,
6223
6074
  cacheId: (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId,
6224
6075
  platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.platform),
6225
- businessCode: (_ref86 = (_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 && _ref86 !== void 0 ? _ref86 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.business_code,
6076
+ businessCode: (_ref82 = (_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 && _ref82 !== void 0 ? _ref82 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.business_code,
6226
6077
  channel: params === null || params === void 0 ? void 0 : params.channel,
6227
6078
  type: params === null || params === void 0 ? void 0 : params.type,
6228
6079
  summary: this.store.summary || createEmptySummary(),
6229
6080
  enhance: function enhance(nextPayload) {
6230
- var _ref87, _tempOrder$order_numb, _ref88, _tempOrder$shop_order2, _ref89, _tempOrder$shop_full_;
6081
+ var _ref83, _tempOrder$order_numb, _ref84, _tempOrder$shop_order2, _ref85, _tempOrder$shop_full_;
6231
6082
  return _objectSpread(_objectSpread({}, nextPayload), {}, {
6232
- order_number: (_ref87 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref87 !== void 0 ? _ref87 : null,
6233
- shop_order_number: (_ref88 = (_tempOrder$shop_order2 = tempOrder.shop_order_number) !== null && _tempOrder$shop_order2 !== void 0 ? _tempOrder$shop_order2 : nextPayload.shop_order_number) !== null && _ref88 !== void 0 ? _ref88 : null,
6234
- shop_full_order_number: (_ref89 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref89 !== void 0 ? _ref89 : null,
6083
+ order_number: (_ref83 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref83 !== void 0 ? _ref83 : null,
6084
+ shop_order_number: (_ref84 = (_tempOrder$shop_order2 = tempOrder.shop_order_number) !== null && _tempOrder$shop_order2 !== void 0 ? _tempOrder$shop_order2 : nextPayload.shop_order_number) !== null && _ref84 !== void 0 ? _ref84 : null,
6085
+ shop_full_order_number: (_ref85 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref85 !== void 0 ? _ref85 : null,
6235
6086
  small_ticket_data_flag: 1
6236
6087
  });
6237
6088
  }
@@ -6395,7 +6246,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6395
6246
  key: "runSubmitTempOrder",
6396
6247
  value: function () {
6397
6248
  var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
6398
- var _params$cacheId3, _this$otherParams12, _ref90, _ref91, _submitSnapshot$busin, _this$otherParams13, _this$otherParams14, _submitSnapshot$type;
6249
+ var _params$cacheId3, _this$otherParams12, _ref86, _ref87, _submitSnapshot$busin, _this$otherParams13, _this$otherParams14, _submitSnapshot$type;
6399
6250
  var tempOrder, isOnlineStorePlatform, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, shouldOverridePaymentStatus, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, isLocalPendingSubmit, salesNotesState, submittedOrderId, resultRecord;
6400
6251
  return _regeneratorRuntime().wrap(function _callee37$(_context40) {
6401
6252
  while (1) switch (_context40.prev = _context40.next) {
@@ -6462,7 +6313,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6462
6313
  tempOrder: tempOrder,
6463
6314
  cacheId: effectiveCacheId,
6464
6315
  platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.platform),
6465
- businessCode: (_ref90 = (_ref91 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref91 !== void 0 ? _ref91 : (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.businessCode) !== null && _ref90 !== void 0 ? _ref90 : (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.business_code,
6316
+ businessCode: (_ref86 = (_ref87 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref87 !== void 0 ? _ref87 : (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.businessCode) !== null && _ref86 !== void 0 ? _ref86 : (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.business_code,
6466
6317
  channel: params === null || params === void 0 ? void 0 : params.channel,
6467
6318
  type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
6468
6319
  summary: latestSummary,
@@ -6632,10 +6483,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6632
6483
  value: function extractSubmitErrorResponse(error) {
6633
6484
  var _error$response,
6634
6485
  _error$response2,
6635
- _this38 = this;
6486
+ _this36 = this;
6636
6487
  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];
6637
6488
  return candidates.find(function (candidate) {
6638
- return _this38.isSubmitErrorResponse(candidate);
6489
+ return _this36.isSubmitErrorResponse(candidate);
6639
6490
  }) || null;
6640
6491
  }
6641
6492
  }, {
@@ -6663,7 +6514,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6663
6514
  key: "syncPaymentsToOrder",
6664
6515
  value: function () {
6665
6516
  var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
6666
- var _this39 = this,
6517
+ var _this37 = this,
6667
6518
  _params$confirmPendin;
6668
6519
  var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, enhancePayload, submitParams, submitResult;
6669
6520
  return _regeneratorRuntime().wrap(function _callee39$(_context42) {
@@ -6688,7 +6539,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6688
6539
  case 9:
6689
6540
  devicePrefix = _context42.t0;
6690
6541
  mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
6691
- return _this39.normalizePaymentSource(payment, {
6542
+ return _this37.normalizePaymentSource(payment, {
6692
6543
  defaultPaid: false,
6693
6544
  devicePrefix: devicePrefix
6694
6545
  });
@@ -6767,7 +6618,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6767
6618
  }, {
6768
6619
  key: "createOrder",
6769
6620
  value: function createOrder(params) {
6770
- var _this40 = this;
6621
+ var _this38 = this;
6771
6622
  var order = _objectSpread({
6772
6623
  type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
6773
6624
  // 要从外面拿,virtual
@@ -6799,7 +6650,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6799
6650
 
6800
6651
  // 为预约补齐 holder 信息
6801
6652
  if (params !== null && params !== void 0 && (_params$extraData = params.extraData) !== null && _params$extraData !== void 0 && _params$extraData.is_add_holder_info) {
6802
- ensureCartItemOriginHolder(item, _this40.window);
6653
+ ensureCartItemOriginHolder(item, _this38.window);
6803
6654
  }
6804
6655
 
6805
6656
  // 购物车是否为普通商品
@@ -7441,10 +7292,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7441
7292
  _step22;
7442
7293
  try {
7443
7294
  for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
7444
- var _product$metadata13;
7295
+ var _product$metadata11;
7445
7296
  var product = _step22.value;
7446
7297
  var productUid = getOrderCollectionUid('product', product);
7447
- 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);
7298
+ 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);
7448
7299
  if (!productUid || bookingUid === undefined || bookingUid === null || bookingUid === '') {
7449
7300
  continue;
7450
7301
  }
@@ -7502,7 +7353,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7502
7353
  }, {
7503
7354
  key: "normalizeTempOrderForRuntime",
7504
7355
  value: function normalizeTempOrderForRuntime(raw, options) {
7505
- var _this41 = this,
7356
+ var _this39 = this,
7506
7357
  _raw$_extend;
7507
7358
  var runtimeRaw = this.withoutSyntheticDraftOrderIdForRuntime(raw);
7508
7359
  var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
@@ -7527,12 +7378,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7527
7378
  nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
7528
7379
  var rawProducts = Array.isArray(raw.products) ? raw.products : [];
7529
7380
  nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
7530
- return _this41.normalizeHydratedOrderProduct(p, {
7381
+ return _this39.normalizeHydratedOrderProduct(p, {
7531
7382
  makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
7532
7383
  });
7533
7384
  }) : [];
7534
7385
  nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
7535
- var booking = _this41.normalizeHydratedBookingHolder(b || {});
7386
+ var booking = _this39.normalizeHydratedBookingHolder(b || {});
7536
7387
  return _objectSpread(_objectSpread({}, booking), {}, {
7537
7388
  is_all: normalizeBookingIsAll(booking),
7538
7389
  sub_type: normalizeBookingSubType(booking)
@@ -7582,15 +7433,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7582
7433
  _step24;
7583
7434
  try {
7584
7435
  for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
7585
- var _product$metadata14, _ref92, _ref93, _existed$origin, _rawProduct$metadata;
7436
+ var _product$metadata12, _ref88, _ref89, _existed$origin, _rawProduct$metadata;
7586
7437
  var _step24$value = _slicedToArray(_step24.value, 2),
7587
7438
  index = _step24$value[0],
7588
7439
  product = _step24$value[1];
7589
- var uid = (_product$metadata14 = product.metadata) === null || _product$metadata14 === void 0 ? void 0 : _product$metadata14.unique_identification_number;
7440
+ var uid = (_product$metadata12 = product.metadata) === null || _product$metadata12 === void 0 ? void 0 : _product$metadata12.unique_identification_number;
7590
7441
  if (!uid) continue;
7591
7442
  var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
7592
7443
  var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
7593
- var origin = (_ref92 = (_ref93 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref93 !== void 0 ? _ref93 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref92 !== void 0 ? _ref92 : rawProduct;
7444
+ var origin = (_ref88 = (_ref89 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref89 !== void 0 ? _ref89 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref88 !== void 0 ? _ref88 : rawProduct;
7594
7445
  var originSnapshot = cloneDeep(origin);
7595
7446
  var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
7596
7447
  if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
@@ -7641,8 +7492,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7641
7492
  var bookingUidByProductUid = new Map();
7642
7493
  var productByUid = new Map();
7643
7494
  (tempOrder.products || []).forEach(function (product) {
7644
- var _product$metadata15;
7645
- 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);
7495
+ var _product$metadata13;
7496
+ 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);
7646
7497
  if (productUid !== undefined && productUid !== null && String(productUid) !== '') {
7647
7498
  productByUid.set(String(productUid), product);
7648
7499
  }
@@ -7663,8 +7514,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7663
7514
  bookingUidByProductUid.set(String(productUid), bookingUid);
7664
7515
  });
7665
7516
  (tempOrder.products || []).forEach(function (product) {
7666
- var _product$metadata16;
7667
- 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);
7517
+ var _product$metadata14;
7518
+ 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);
7668
7519
  if (productUid === undefined || productUid === null || String(productUid) === '') return;
7669
7520
  var bookingUid = bookingUidByProductUid.get(String(productUid));
7670
7521
  if (!bookingUid) return;
@@ -7719,10 +7570,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7719
7570
  }, {
7720
7571
  key: "normalizeHydratedProductOptionItem",
7721
7572
  value: function normalizeHydratedProductOptionItem(optionItem) {
7722
- var _ref94, _optionItem$num, _ref95, _optionItem$add_price;
7723
- var rawNum = (_ref94 = (_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 && _ref94 !== void 0 ? _ref94 : 1;
7573
+ var _ref90, _optionItem$num, _ref91, _optionItem$add_price;
7574
+ var rawNum = (_ref90 = (_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 && _ref90 !== void 0 ? _ref90 : 1;
7724
7575
  var parsedNum = Number(rawNum);
7725
- var rawPrice = (_ref95 = (_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 && _ref95 !== void 0 ? _ref95 : 0;
7576
+ var rawPrice = (_ref91 = (_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 && _ref91 !== void 0 ? _ref91 : 0;
7726
7577
  var parsedPrice = Number(rawPrice);
7727
7578
  var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
7728
7579
  option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
@@ -7739,7 +7590,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7739
7590
  }, {
7740
7591
  key: "normalizeHydratedOrderProduct",
7741
7592
  value: function normalizeHydratedOrderProduct(product, options) {
7742
- var _this42 = this;
7593
+ var _this40 = this;
7743
7594
  var row = _objectSpread({}, product || {});
7744
7595
  if (row.num === undefined && row.product_quantity !== undefined) {
7745
7596
  row.num = row.product_quantity;
@@ -7747,7 +7598,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7747
7598
  var productSku = ensureProductSku(row);
7748
7599
  row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
7749
7600
  option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
7750
- return _this42.normalizeHydratedProductOptionItem(optionItem || {});
7601
+ return _this40.normalizeHydratedProductOptionItem(optionItem || {});
7751
7602
  }))
7752
7603
  });
7753
7604
  delete row["product_".concat('option', "_item")];
@@ -7855,11 +7706,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7855
7706
  targetMap.set(discountKey, (targetMap.get(discountKey) || new Decimal(0)).plus(amount));
7856
7707
  };
7857
7708
  var addProductDiscountAmount = function addProductDiscountAmount(discount, quantity, isPersistedProduct) {
7858
- var _discount$discount3, _discount$metadata2;
7709
+ var _discount$discount3, _discount$metadata;
7859
7710
  var discountKey = ((_discount$discount3 = discount.discount) === null || _discount$discount3 === void 0 ? void 0 : _discount$discount3.resource_id) || discount.id;
7860
7711
  if (discountKey == null) return;
7861
7712
  var qty = Number(quantity) || 1;
7862
- 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);
7713
+ 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);
7863
7714
  addDiscountAmount(savedMap, discountKey, amount);
7864
7715
  addDiscountAmount(isPersistedProduct || discount.order_discount_id != null ? editModeSavedMap : runtimeSavedMap, discountKey, amount);
7865
7716
  };