@pisell/pisellos 2.3.124 → 2.3.126

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 (93) 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 +12 -7
  12. package/dist/modules/Order/index.js +307 -432
  13. package/dist/modules/Order/types.d.ts +5 -0
  14. package/dist/modules/Order/utils/orderCollectionIdentity.js +12 -16
  15. package/dist/modules/Order/utils.d.ts +11 -1
  16. package/dist/modules/Order/utils.js +127 -122
  17. package/dist/modules/Payment/types.d.ts +1 -21
  18. package/dist/modules/Payment/types.js +0 -2
  19. package/dist/modules/Payment/walletpass.d.ts +1 -1
  20. package/dist/modules/Payment/walletpass.js +47 -80
  21. package/dist/modules/Rules/index.d.ts +2 -2
  22. package/dist/modules/Rules/index.js +186 -480
  23. package/dist/modules/Rules/types.d.ts +0 -4
  24. package/dist/server/modules/order/types.d.ts +0 -2
  25. package/dist/solution/BaseSales/index.d.ts +0 -1
  26. package/dist/solution/BaseSales/index.js +59 -51
  27. package/dist/solution/BaseSales/types.d.ts +2 -2
  28. package/dist/solution/BaseSales/utils/cartPromotion.js +126 -141
  29. package/dist/solution/BookingByStep/index.d.ts +1 -1
  30. package/dist/solution/BookingTicket/index.d.ts +2 -1
  31. package/dist/solution/BookingTicket/index.js +63 -60
  32. package/dist/solution/BookingTicket/types.d.ts +1 -5
  33. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -2
  34. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +147 -338
  35. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +4 -8
  36. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +0 -6
  37. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +6 -19
  38. package/dist/solution/ShopDiscount/index.d.ts +0 -2
  39. package/dist/solution/ShopDiscount/index.js +42 -99
  40. package/dist/solution/ShopDiscount/utils.d.ts +2 -4
  41. package/dist/solution/ShopDiscount/utils.js +23 -43
  42. package/dist/solution/UnifiedBookingSales/index.js +2 -2
  43. package/lib/model/strategy/adapter/promotion/index.js +1 -46
  44. package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +0 -2
  45. package/lib/model/strategy/adapter/walletPass/evaluator.js +0 -2
  46. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +6 -35
  47. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +6 -13
  48. package/lib/modules/Customer/index.js +1 -5
  49. package/lib/modules/Customer/types.d.ts +0 -2
  50. package/lib/modules/Discount/index.d.ts +2 -2
  51. package/lib/modules/Discount/index.js +129 -23
  52. package/lib/modules/Discount/types.d.ts +5 -36
  53. package/lib/modules/Order/index.d.ts +12 -7
  54. package/lib/modules/Order/index.js +107 -215
  55. package/lib/modules/Order/types.d.ts +5 -0
  56. package/lib/modules/Order/utils/orderCollectionIdentity.js +11 -14
  57. package/lib/modules/Order/utils.d.ts +11 -1
  58. package/lib/modules/Order/utils.js +45 -39
  59. package/lib/modules/Payment/types.d.ts +1 -21
  60. package/lib/modules/Payment/types.js +0 -1
  61. package/lib/modules/Payment/walletpass.d.ts +1 -1
  62. package/lib/modules/Payment/walletpass.js +9 -29
  63. package/lib/modules/Rules/index.d.ts +2 -2
  64. package/lib/modules/Rules/index.js +110 -357
  65. package/lib/modules/Rules/types.d.ts +0 -4
  66. package/lib/server/modules/order/types.d.ts +0 -2
  67. package/lib/solution/BaseSales/index.d.ts +0 -1
  68. package/lib/solution/BaseSales/index.js +12 -5
  69. package/lib/solution/BaseSales/types.d.ts +2 -2
  70. package/lib/solution/BaseSales/utils/cartPromotion.js +4 -12
  71. package/lib/solution/BookingByStep/index.d.ts +1 -1
  72. package/lib/solution/BookingTicket/index.d.ts +2 -1
  73. package/lib/solution/BookingTicket/index.js +33 -36
  74. package/lib/solution/BookingTicket/types.d.ts +1 -5
  75. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -2
  76. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +42 -174
  77. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +4 -8
  78. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +0 -6
  79. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +3 -11
  80. package/lib/solution/ShopDiscount/index.d.ts +0 -2
  81. package/lib/solution/ShopDiscount/index.js +9 -55
  82. package/lib/solution/ShopDiscount/utils.d.ts +2 -4
  83. package/lib/solution/ShopDiscount/utils.js +25 -42
  84. package/lib/solution/UnifiedBookingSales/index.js +2 -2
  85. package/package.json +1 -1
  86. package/dist/modules/Discount/availability.d.ts +0 -7
  87. package/dist/modules/Discount/availability.js +0 -49
  88. package/dist/modules/Discount/entitlementPass.d.ts +0 -34
  89. package/dist/modules/Discount/entitlementPass.js +0 -147
  90. package/lib/modules/Discount/availability.d.ts +0 -7
  91. package/lib/modules/Discount/availability.js +0 -43
  92. package/lib/modules/Discount/entitlementPass.d.ts +0 -34
  93. 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; }
@@ -32,10 +32,9 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
32
32
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
33
33
  import { BaseModule } from "../BaseModule";
34
34
  import { OrderHooks } from "./types";
35
- import { composeLinePrice, generateDuration, getAllDiscountList, mergeRelationForms, ensureCartItemOriginHolder, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, isTempOrder, normalizeOrderMetaList, normalizeBookingIsAll, normalizeBookingSubType, mapPaymentItemsToOrderPayments, normalizeOrderProductDiscountList, resolveEffectivePerUnitDiscount, ensureProductSku, getProductSkuOptions, normalizeProductSkuOptions, sumOptionUnitPrice, clearTempOrderHolderAssignments, getOrderProductLineUid, indexOrderProductsByUid, calculateOrderProductsDeposit, buildPointCardSnapshotFromWalletPassList, buildVirtualCurrencySnapshotFromList, mergeOrderProductDisplayFields, resolveIsFormSubject, isMarkdownBundle } from "./utils";
35
+ import { composeLinePrice, generateDuration, getAllDiscountList, mergeRelationForms, ensureCartItemOriginHolder, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, isTempOrder, normalizeOrderMetaList, normalizeBookingIsAll, normalizeBookingSubType, mapPaymentItemsToOrderPayments, normalizeOrderProductDiscountList, resolveEffectivePerUnitDiscount, ensureProductSku, getProductSkuOptions, normalizeProductSkuOptions, sumOptionUnitPrice, clearTempOrderHolderAssignments, getOrderProductLineUid, indexOrderProductsByUid, calculateOrderProductsDeposit, collectPointCardSnapshotCodeCandidates, mergePointCardSnapshotCodes as _mergePointCardSnapshotCodes, buildVirtualCurrencySnapshotFromList, mergeOrderProductDisplayFields, resolveIsFormSubject, isMarkdownBundle } from "./utils";
36
36
  import { isNormalProduct } from "../Product/utils";
37
37
  import dayjs from 'dayjs';
38
- import { getDiscountLifecycleReason } from "../Discount/availability";
39
38
  import { stripOsPrivatePayloadFields } from "../../utils/os-private-payload";
40
39
  import { buildSalesNoteText, decodeSalesNotesSnapshot, getSalesNotePolicy } from "./salesNotes";
41
40
  import { ensureOrderPaymentNumber, mergeOrderPaymentRecord, resolveOrderPaymentIdentity } from "./payment-utils";
@@ -49,7 +48,6 @@ import { consolidateDiscountFreeProductLines, ensureUniqueProductLineUids } from
49
48
  import { applyTempOrderSettlementState, getSelectedSettlementSnapshot, getSettlementKey, getTempOrderSettlementKey, getTempOrderSettlementSnapshot, isVirtualSettlementOrder, normalizeVirtualSettlementOrderProduct, normalizeVirtualSettlementProducts, OrderSettlementConflictError, releaseTempOrderSettlementState, VirtualCurrencyAssetNotFoundError, VirtualCurrencyBalanceError } from "./utils/virtualSettlement";
50
49
  import { DiscountModule } from "../Discount";
51
50
  import { RulesModule } from "../Rules";
52
- import { isEntitlementPass, isFullCoveragePass } from "../Discount/entitlementPass";
53
51
  import { UnavailableReason } from "../Rules/types";
54
52
  import Decimal from 'decimal.js';
55
53
  import { cloneDeep } from 'lodash-es';
@@ -73,26 +71,9 @@ function isManualProductDiscountProduct(product) {
73
71
  return (item === null || item === void 0 ? void 0 : item.type) === 'product';
74
72
  });
75
73
  }
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
74
  var ORDER_PAYMENT_STATUS_PAID = 'paid';
94
75
  var ORDER_PAYMENT_STATUS_PENDING = 'payment_pending';
95
- var CUSTOMER_PROMOTION_DISCOUNT_TAGS = new Set(['entitlement_pass', 'good_pass', 'product_discount_card', 'discount_card']);
76
+ var CUSTOMER_PROMOTION_DISCOUNT_TAGS = new Set(['good_pass', 'product_discount_card', 'discount_card']);
96
77
  function isCustomerPromotionDiscount(discount) {
97
78
  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
79
  }
@@ -127,27 +108,6 @@ function getVoucherPaymentLifecycleKey(payment) {
127
108
  if (!isVoucherPaymentRecord(payment)) return null;
128
109
  return "".concat(String(payment.voucher_id), "::").concat(String(payment.status || ''));
129
110
  }
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
111
  export var OrderModule = /*#__PURE__*/function (_BaseModule) {
152
112
  _inherits(OrderModule, _BaseModule);
153
113
  var _super = _createSuper(OrderModule);
@@ -170,6 +130,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
170
130
  _defineProperty(_assertThisInitialized(_this), "sessionStorageRestoreRecord", null);
171
131
  /** 只允许当前订单最新的 prepare/config 请求回写客户资产态。 */
172
132
  _defineProperty(_assertThisInitialized(_this), "customerWalletPrepareConfigEpoch", 0);
133
+ /** Payment 可能早于 prepare/config 返回;先按实例 ID 暂存卡号等待 Snapshot。 */
134
+ _defineProperty(_assertThisInitialized(_this), "pointCardSnapshotCodeCandidates", new Map());
173
135
  _defineProperty(_assertThisInitialized(_this), "salesSummaryModuleName", void 0);
174
136
  _defineProperty(_assertThisInitialized(_this), "rulesHooksOverride", void 0);
175
137
  _defineProperty(_assertThisInitialized(_this), "moduleHooksOverride", void 0);
@@ -210,7 +172,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
210
172
  _step2;
211
173
  try {
212
174
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
213
- 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;
175
+ 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;
214
176
  var item = _step2.value;
215
177
  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;
216
178
  if (!type || type === 'product') continue;
@@ -221,31 +183,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
221
183
  var key = Number.isFinite(id) ? id : String(resourceId);
222
184
  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 : {};
223
185
  var amount = Number((item === null || item === void 0 ? void 0 : item.amount) || 0);
224
- 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) || '';
225
- var discountCardType = item === null || item === void 0 || (_item$discount4 = item.discount) === null || _item$discount4 === void 0 ? void 0 : _item$discount4.discount_card_type;
226
- 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';
186
+ var discountCardType = item === null || item === void 0 || (_item$discount3 = item.discount) === null || _item$discount3 === void 0 ? void 0 : _item$discount3.discount_card_type;
187
+ var parValue = isDiscountCard ? discountCardType === 'fixed_amount' ? (_item$discount$fixed_ = item === null || item === void 0 || (_item$discount4 = item.discount) === null || _item$discount4 === void 0 ? void 0 : _item$discount4.fixed_amount) !== null && _item$discount$fixed_ !== void 0 ? _item$discount$fixed_ : item === null || item === void 0 ? void 0 : item.amount : item === null || item === void 0 || (_item$discount5 = item.discount) === null || _item$discount5 === void 0 ? void 0 : _item$discount5.percent : '0';
227
188
  var detail = {
228
189
  amount: String((_item$amount = item === null || item === void 0 ? void 0 : item.amount) !== null && _item$amount !== void 0 ? _item$amount : '0'),
229
190
  type: type,
230
191
  resource_id: key,
231
192
  title: title,
232
- 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'),
233
- 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,
193
+ 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'),
194
+ 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,
234
195
  metadata: item === null || item === void 0 ? void 0 : item.metadata,
235
- discount: _objectSpread(_objectSpread({}, (item === null || item === void 0 ? void 0 : item.discount) || {}), {}, {
236
- 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
237
- }),
238
- _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
196
+ discount: item === null || item === void 0 ? void 0 : item.discount,
197
+ _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
239
198
  };
240
199
  var existed = discountMap.get(key);
241
200
  if (existed) {
242
201
  var _existed$limited_rela;
243
- if (!existed.encoded && encoded) {
244
- existed.encoded = encoded;
245
- existed.metadata = _objectSpread(_objectSpread({}, existed.metadata), {}, {
246
- encoded: encoded
247
- });
248
- }
249
202
  existed.amount = Number(existed.amount || 0) + amount;
250
203
  existed.used_par_value = String(Number(existed.used_par_value || 0) + amount);
251
204
  if (!isDiscountCard) {
@@ -264,13 +217,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
264
217
  discountMap.set(key, {
265
218
  id: key,
266
219
  product_name: '',
267
- encoded: encoded,
268
- 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) || '',
269
- metadata: {
270
- encoded: encoded
271
- },
220
+ encoded: '',
221
+ code: '',
272
222
  tag: type,
273
- 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,
223
+ 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,
274
224
  relation_type: '',
275
225
  par_value: String(parValue !== null && parValue !== void 0 ? parValue : '0'),
276
226
  used_par_value: String((_item$amount2 = item === null || item === void 0 ? void 0 : item.amount) !== null && _item$amount2 !== void 0 ? _item$amount2 : '0'),
@@ -303,8 +253,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
303
253
  amount: amount,
304
254
  discount: _objectSpread(_objectSpread({}, (item === null || item === void 0 ? void 0 : item.discount) || {}), {}, {
305
255
  resource_id: key,
306
- 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,
307
- 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'
256
+ 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,
257
+ 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'
308
258
  }),
309
259
  applicableProductDetails: [detail],
310
260
  appliedProductDetails: [detail]
@@ -608,11 +558,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
608
558
  }, {
609
559
  key: "createDefaultRulesHooks",
610
560
  value: function createDefaultRulesHooks() {
611
- var _this2 = this;
612
- return createDefaultOrderRulesHooks(function () {
613
- var _this2$store$tempOrde;
614
- return ((_this2$store$tempOrde = _this2.store.tempOrder) === null || _this2$store$tempOrde === void 0 ? void 0 : _this2$store$tempOrde.bookings) || [];
615
- });
561
+ return createDefaultOrderRulesHooks();
616
562
  }
617
563
 
618
564
  /**
@@ -634,9 +580,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
634
580
  var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
635
581
  var _this$store$tempOrder,
636
582
  _this$store$discount,
637
- _this3 = this,
583
+ _this2 = this,
638
584
  _this$store$tempOrder2;
639
- 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;
585
+ var orderId, requestEpoch, requestOrderIdentityKey, prepareConfigResult, isCurrentRequest, discountList, _this$store$discount2, _this$store$discount3, _this$store$discount4, currentDiscountList, currentEditDiscounts, currentScanDiscounts, currentScanDiscountIds, runtimeDiscountIds, runtimeDiscounts, mergedDiscountList;
640
586
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
641
587
  while (1) switch (_context3.prev = _context3.next) {
642
588
  case 0:
@@ -652,8 +598,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
652
598
  with_wallet_pass_holder: 1,
653
599
  with_available_wallet_flag: 1,
654
600
  with_available_wallet_pass_flag: 1,
655
- with_entitlement_pass: 1,
656
- filter_order_wallet_pass_usage: 0,
657
601
  with_virtual_currency: 1,
658
602
  request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
659
603
  }, orderId ? {
@@ -662,8 +606,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
662
606
  case 5:
663
607
  prepareConfigResult = _context3.sent;
664
608
  isCurrentRequest = function isCurrentRequest() {
665
- var _this3$store$tempOrde, _this3$store$tempOrde2;
666
- 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);
609
+ var _this2$store$tempOrde, _this2$store$tempOrde2;
610
+ 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);
667
611
  };
668
612
  if (isCurrentRequest()) {
669
613
  _context3.next = 9;
@@ -681,101 +625,56 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
681
625
  });
682
626
  }
683
627
  if (!discountList) {
684
- _context3.next = 32;
628
+ _context3.next = 27;
685
629
  break;
686
630
  }
687
631
  currentDiscountList = ((_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 ? void 0 : _this$store$discount2.getDiscountList()) || [];
688
- currentCommittedDiscounts = currentDiscountList.filter(function (discount) {
689
- var _discount$committedAp;
690
- 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);
632
+ currentEditDiscounts = currentDiscountList.filter(function (discount) {
633
+ return discount === null || discount === void 0 ? void 0 : discount.isEditMode;
691
634
  });
692
635
  currentScanDiscounts = currentDiscountList.filter(function (discount) {
693
636
  return discount === null || discount === void 0 ? void 0 : discount.isScan;
694
637
  });
695
- currentScanDiscountById = new Map(currentScanDiscounts.flatMap(function (discount) {
696
- var id = getDiscountIdentityKey(discount);
697
- return id === null ? [] : [[id, discount]];
698
- }));
699
- committedDiscountById = new Map(currentCommittedDiscounts.flatMap(function (discount) {
700
- var id = getDiscountIdentityKey(discount);
701
- return id === null ? [] : [[id, discount]];
638
+ currentScanDiscountIds = new Set(currentScanDiscounts.map(function (discount) {
639
+ return discount === null || discount === void 0 ? void 0 : discount.id;
702
640
  }));
703
- mergedCommittedDiscountIds = new Set();
704
- refreshedScanDiscountIds = new Set();
705
641
  runtimeDiscountIds = new Set();
706
- runtimeDiscounts = discountList.flatMap(function (discount) {
707
- var id = getDiscountIdentityKey(discount);
708
- if (id === null) return [discount];
709
- if (runtimeDiscountIds.has(id)) return [];
710
- runtimeDiscountIds.add(id);
711
- var currentScanDiscount = currentScanDiscountById.get(id);
712
- if (currentScanDiscount && (!isEntitlementPass(currentScanDiscount) || !isEntitlementPass(discount))) {
713
- return [];
714
- }
715
- var committedDiscount = committedDiscountById.get(id);
716
- var nextDiscount = discount;
717
- if (committedDiscount && isEntitlementPass(committedDiscount) && isEntitlementPass(discount)) {
718
- mergedCommittedDiscountIds.add(id);
719
- nextDiscount = mergeCommittedEntitlementWithRuntime(committedDiscount, discount);
720
- }
721
- if (currentScanDiscount) {
722
- var _currentScanDiscount$, _currentScanDiscount$2;
723
- refreshedScanDiscountIds.add(id);
724
- nextDiscount = _objectSpread(_objectSpread({}, nextDiscount), {}, {
725
- isScan: true,
726
- isSelected: (_currentScanDiscount$ = currentScanDiscount.isSelected) !== null && _currentScanDiscount$ !== void 0 ? _currentScanDiscount$ : nextDiscount.isSelected,
727
- isManualSelect: (_currentScanDiscount$2 = currentScanDiscount.isManualSelect) !== null && _currentScanDiscount$2 !== void 0 ? _currentScanDiscount$2 : nextDiscount.isManualSelect
728
- });
729
- }
730
- return [nextDiscount];
731
- });
732
- retainedCommittedDiscounts = currentCommittedDiscounts.filter(function (discount) {
733
- var id = getDiscountIdentityKey(discount);
734
- return id === null || !mergedCommittedDiscountIds.has(id);
735
- }).map(function (discount) {
736
- var _discount$committedAp2;
737
- return (_discount$committedAp2 = discount.committedAppliedProductDetails) !== null && _discount$committedAp2 !== void 0 && _discount$committedAp2.length ? _objectSpread(_objectSpread({}, discount), {}, {
738
- isEditMode: true,
739
- isDisabled: true,
740
- isSelected: true,
741
- isUsed: true,
742
- appliedProductDetails: _toConsumableArray(discount.committedAppliedProductDetails)
743
- }) : discount;
642
+ runtimeDiscounts = discountList.filter(function (discount) {
643
+ if (currentScanDiscountIds.has(discount === null || discount === void 0 ? void 0 : discount.id)) return false;
644
+ if (runtimeDiscountIds.has(discount === null || discount === void 0 ? void 0 : discount.id)) return false;
645
+ runtimeDiscountIds.add(discount === null || discount === void 0 ? void 0 : discount.id);
646
+ return true;
744
647
  });
745
- retainedScanDiscounts = currentScanDiscounts.filter(function (discount) {
746
- var id = getDiscountIdentityKey(discount);
747
- return id === null || !refreshedScanDiscountIds.has(id);
748
- });
749
- mergedDiscountList = [].concat(_toConsumableArray(retainedCommittedDiscounts), _toConsumableArray(retainedScanDiscounts), _toConsumableArray(runtimeDiscounts));
648
+ mergedDiscountList = [].concat(_toConsumableArray(currentEditDiscounts), _toConsumableArray(currentScanDiscounts), _toConsumableArray(runtimeDiscounts));
750
649
  if (isCurrentRequest()) {
751
- _context3.next = 26;
650
+ _context3.next = 21;
752
651
  break;
753
652
  }
754
653
  return _context3.abrupt("return", this.getDiscountList());
755
- case 26:
756
- _context3.next = 28;
654
+ case 21:
655
+ _context3.next = 23;
757
656
  return (_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.setOriginalDiscountList(mergedDiscountList);
758
- case 28:
657
+ case 23:
759
658
  if (isCurrentRequest()) {
760
- _context3.next = 30;
659
+ _context3.next = 25;
761
660
  break;
762
661
  }
763
662
  return _context3.abrupt("return", this.getDiscountList());
764
- case 30:
765
- _context3.next = 32;
663
+ case 25:
664
+ _context3.next = 27;
766
665
  return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.setDiscountList(mergedDiscountList);
767
- case 32:
666
+ case 27:
768
667
  if (isCurrentRequest()) {
769
- _context3.next = 34;
668
+ _context3.next = 29;
770
669
  break;
771
670
  }
772
671
  return _context3.abrupt("return", this.getDiscountList());
773
- case 34:
672
+ case 29:
774
673
  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) {
775
674
  this.applyDiscount();
776
675
  }
777
676
  return _context3.abrupt("return", this.getDiscountList());
778
- case 36:
677
+ case 31:
779
678
  case "end":
780
679
  return _context3.stop();
781
680
  }
@@ -895,7 +794,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
895
794
  value: function () {
896
795
  var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(code, customerId) {
897
796
  var _this$store$discount11, _tempOrder$holder, _this$store$summary;
898
- 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;
797
+ var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref16, isAvailable, newDiscountList, evaluatedDiscountList, unavailableReason, shouldRetainForLater, normalizedNewDiscountList, retainedDiscountList, resolvedDiscountList, _this$store$discount12, _this$store$discount13;
899
798
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
900
799
  while (1) switch (_context6.prev = _context6.next) {
901
800
  case 0:
@@ -998,72 +897,46 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
998
897
  isAvailable: false,
999
898
  discountList: this.getDiscountList()
1000
899
  }, isAvailable = _ref16.isAvailable, newDiscountList = _ref16.discountList, evaluatedDiscountList = _ref16.evaluatedDiscountList, unavailableReason = _ref16.unavailableReason;
1001
- scannedIds = new Set(withScanList.map(function (discount) {
1002
- return String(discount.id);
1003
- }));
1004
- evaluatedScannedDiscounts = (evaluatedDiscountList || withScanList).filter(function (discount) {
1005
- return scannedIds.has(String(discount.id)) && isCustomerPromotionDiscount(discount) && !getDiscountLifecycleReason(discount);
1006
- });
1007
- shouldRetainForLater = !isAvailable && evaluatedScannedDiscounts.length > 0;
900
+ shouldRetainForLater = !isAvailable && unavailableReason === UnavailableReason.ProductNotApplicable && withScanList.some(isCustomerPromotionDiscount);
1008
901
  normalizedNewDiscountList = newDiscountList ? markScannedDiscounts(newDiscountList, withScanList) : undefined;
902
+ retainedDiscountList = evaluatedDiscountList ? markScannedDiscounts(evaluatedDiscountList, withScanList) : normalizedNewDiscountList;
1009
903
  resolvedDiscountList = normalizedNewDiscountList || this.getDiscountList();
1010
904
  if (!(isAvailable && normalizedNewDiscountList)) {
1011
- _context6.next = 37;
905
+ _context6.next = 36;
1012
906
  break;
1013
907
  }
1014
- _context6.next = 31;
908
+ _context6.next = 30;
1015
909
  return (_this$store$discount12 = this.store.discount) === null || _this$store$discount12 === void 0 ? void 0 : _this$store$discount12.setDiscountList(normalizedNewDiscountList);
1016
- case 31:
1017
- // 实际写回商品时沿用扫码试算的优先级,避免旧商品行的选卡覆盖本次扫码。
1018
- this.applyDiscount({
1019
- preferredEntitlementPassIds: withScanList.filter(function (discount) {
1020
- return isEntitlementPass(discount);
1021
- }).map(function (discount) {
1022
- return discount.id;
1023
- })
1024
- });
1025
- _context6.next = 34;
910
+ case 30:
911
+ this.applyDiscount();
912
+ _context6.next = 33;
1026
913
  return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
1027
- case 34:
914
+ case 33:
1028
915
  resolvedDiscountList = this.getDiscountList();
1029
- _context6.next = 45;
916
+ _context6.next = 42;
1030
917
  break;
1031
- case 37:
1032
- if (!shouldRetainForLater) {
1033
- _context6.next = 45;
918
+ case 36:
919
+ if (!(shouldRetainForLater && retainedDiscountList)) {
920
+ _context6.next = 42;
1034
921
  break;
1035
922
  }
1036
- // 只合并本次识别的卡券;不把试算产生的其他选券状态写回订单。
1037
- retainedDiscounts = new Map(this.getDiscountList().map(function (discount) {
1038
- return [String(discount.id), discount];
1039
- }));
1040
- evaluatedScannedDiscounts.forEach(function (discount) {
1041
- retainedDiscounts.set(String(discount.id), _objectSpread(_objectSpread({}, discount), {}, {
1042
- isScan: true,
1043
- isAvailable: false,
1044
- isSelected: false,
1045
- reasonCode: discount.reasonCode || 'product_not_applicable',
1046
- appliedProductDetails: [],
1047
- savedAmount: 0
1048
- }));
1049
- });
1050
- _context6.next = 42;
1051
- return (_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.setDiscountList(_toConsumableArray(retainedDiscounts.values()));
1052
- case 42:
1053
- _context6.next = 44;
923
+ _context6.next = 39;
924
+ return (_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.setDiscountList(retainedDiscountList);
925
+ case 39:
926
+ _context6.next = 41;
1054
927
  return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
1055
- case 44:
928
+ case 41:
1056
929
  resolvedDiscountList = this.getDiscountList();
1057
- case 45:
930
+ case 42:
1058
931
  return _context6.abrupt("return", {
1059
932
  type: 'clientCalc',
1060
933
  isAvailable: isAvailable || false,
1061
934
  isAccepted: Boolean(isAvailable || shouldRetainForLater),
1062
935
  discountList: resolvedDiscountList,
1063
- scannedDiscountList: evaluatedScannedDiscounts,
936
+ scannedDiscountList: resultDiscountList,
1064
937
  unavailableReason: unavailableReason
1065
938
  });
1066
- case 46:
939
+ case 43:
1067
940
  case "end":
1068
941
  return _context6.stop();
1069
942
  }
@@ -1079,7 +952,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1079
952
  value: function applyDiscount(options) {
1080
953
  var _this$store$discount16,
1081
954
  _this$store$summary2,
1082
- _this4 = this;
955
+ _this3 = this;
1083
956
  var tempOrder = this.store.tempOrder;
1084
957
  // 任意 products CRUD 后都应当重算 discount 状态;即使 products 为空,
1085
958
  // 也需要让 Rules.calcDiscount 把 DiscountModule 的 isSelected / isAvailable /
@@ -1110,8 +983,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1110
983
  },
1111
984
  orderTotalAmount: Number(((_this$store$summary2 = this.store.summary) === null || _this$store$summary2 === void 0 ? void 0 : _this$store$summary2.total_amount) || 0)
1112
985
  }, {
1113
- reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids,
1114
- preferredEntitlementPassIds: options === null || options === void 0 ? void 0 : options.preferredEntitlementPassIds
986
+ reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids
1115
987
  });
1116
988
  if (result !== null && result !== void 0 && result.productList) {
1117
989
  var previousProductsByUid = indexOrderProductsByUid(tempOrder.products);
@@ -1136,7 +1008,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1136
1008
  (_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 || _this$store$discount17.setDiscountList(result.discountList);
1137
1009
  }
1138
1010
  this.hasActiveCustomerBoundDiscount = (tempOrder.products || []).some(function (product) {
1139
- return _this4.productHasCustomerBoundDiscount(product);
1011
+ return _this3.productHasCustomerBoundDiscount(product);
1140
1012
  });
1141
1013
  }
1142
1014
 
@@ -1199,7 +1071,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1199
1071
  var _evaluatePromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
1200
1072
  var _this$promotionEvalua,
1201
1073
  _this$promotionEvalua2,
1202
- _this5 = this;
1074
+ _this4 = this;
1203
1075
  var tempOrder, strategyConfigs, result, removeSet, _iterator3, _step3, reduce, _iterator6, _step6, _loop2, _iterator4, _step4, _loop, payload;
1204
1076
  return _regeneratorRuntime().wrap(function _callee7$(_context9) {
1205
1077
  while (1) switch (_context9.prev = _context9.next) {
@@ -1358,7 +1230,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1358
1230
  case 6:
1359
1231
  _context7.prev = 6;
1360
1232
  _context7.next = 9;
1361
- return _this5.giftSelectResolver({
1233
+ return _this4.giftSelectResolver({
1362
1234
  strategyId: addAction.strategyId,
1363
1235
  strategyName: addAction.strategyName,
1364
1236
  giftCount: addAction.giftCount,
@@ -1393,7 +1265,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1393
1265
  _context7.next = 26;
1394
1266
  break;
1395
1267
  }
1396
- linked = _this5.createLinkedProductAndBooking({
1268
+ linked = _this4.createLinkedProductAndBooking({
1397
1269
  product: gp,
1398
1270
  booking: booking
1399
1271
  });
@@ -1716,9 +1588,59 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1716
1588
  key: "clearCustomerWalletRuntimeState",
1717
1589
  value: function clearCustomerWalletRuntimeState() {
1718
1590
  this.customerWalletPrepareConfigEpoch += 1;
1591
+ this.pointCardSnapshotCodeCandidates.clear();
1719
1592
  this.store.availableWalletIds = [];
1720
1593
  this.store.virtualCurrencyList = [];
1721
1594
  }
1595
+ }, {
1596
+ key: "rememberPointCardSnapshotCodeCandidates",
1597
+ value: function rememberPointCardSnapshotCodeCandidates(value) {
1598
+ var _this5 = this;
1599
+ collectPointCardSnapshotCodeCandidates(value).forEach(function (_ref18) {
1600
+ var id = _ref18.id,
1601
+ code = _ref18.code;
1602
+ if (!_this5.pointCardSnapshotCodeCandidates.has(id)) {
1603
+ _this5.pointCardSnapshotCodeCandidates.set(id, code);
1604
+ }
1605
+ });
1606
+ }
1607
+ }, {
1608
+ key: "getRememberedPointCardSnapshotCodeCandidates",
1609
+ value: function getRememberedPointCardSnapshotCodeCandidates() {
1610
+ return _toConsumableArray(this.pointCardSnapshotCodeCandidates).map(function (_ref19) {
1611
+ var _ref20 = _slicedToArray(_ref19, 2),
1612
+ id = _ref20[0],
1613
+ code = _ref20[1];
1614
+ return {
1615
+ id: id,
1616
+ code: code
1617
+ };
1618
+ });
1619
+ }
1620
+ }, {
1621
+ key: "getPointCardSnapshotOrderIdentityKey",
1622
+ value: function getPointCardSnapshotOrderIdentityKey(identity) {
1623
+ if (identity !== null && identity !== void 0 && identity.externalSaleNumber) {
1624
+ return "external:".concat(identity.externalSaleNumber);
1625
+ }
1626
+ if ((identity === null || identity === void 0 ? void 0 : identity.orderId) !== undefined && identity.orderId !== null) {
1627
+ return "order:".concat(identity.orderId);
1628
+ }
1629
+ if (identity !== null && identity !== void 0 && identity.localId) return "local:".concat(identity.localId);
1630
+ if (identity !== null && identity !== void 0 && identity.orderNumber) return "number:".concat(identity.orderNumber);
1631
+ return '';
1632
+ }
1633
+ }, {
1634
+ key: "isPointCardSnapshotMergeContextCurrent",
1635
+ value: function isPointCardSnapshotMergeContextCurrent(context) {
1636
+ var _context$customerId, _this$store$tempOrder4, _this$store$tempOrder5;
1637
+ if (!context) return true;
1638
+ if (context.customerId !== undefined && String((_context$customerId = context.customerId) !== null && _context$customerId !== void 0 ? _context$customerId : '') !== String((_this$store$tempOrder4 = (_this$store$tempOrder5 = this.store.tempOrder) === null || _this$store$tempOrder5 === void 0 ? void 0 : _this$store$tempOrder5.customer_id) !== null && _this$store$tempOrder4 !== void 0 ? _this$store$tempOrder4 : '')) {
1639
+ return false;
1640
+ }
1641
+ var expectedOrderKey = this.getPointCardSnapshotOrderIdentityKey(context.orderIdentity);
1642
+ return !expectedOrderKey || expectedOrderKey === this.getPointCardSnapshotOrderIdentityKey(this.getOrderIdentity());
1643
+ }
1722
1644
  }, {
1723
1645
  key: "writeCustomerWalletSnapshotsFromPrepareConfig",
1724
1646
  value: function writeCustomerWalletSnapshotsFromPrepareConfig(params) {
@@ -1726,9 +1648,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1726
1648
  var tempOrder = this.store.tempOrder;
1727
1649
  if (!tempOrder) return;
1728
1650
  if (String((_tempOrder$customer_i = tempOrder.customer_id) !== null && _tempOrder$customer_i !== void 0 ? _tempOrder$customer_i : '') !== String(params.customerId)) return;
1651
+ var currentOrderMetaList = normalizeOrderMetaList(tempOrder.order_meta_list);
1729
1652
  var virtualCurrencyList = Array.isArray(params.virtualCurrencyList) ? params.virtualCurrencyList : [];
1730
- tempOrder.order_meta_list = _objectSpread(_objectSpread({}, normalizeOrderMetaList(tempOrder.order_meta_list) || {}), {}, {
1731
- point_cards_snapshot: buildPointCardSnapshotFromWalletPassList(params.availableWalletPassList),
1653
+ var snapshotsWithExistingCodes = _mergePointCardSnapshotCodes(params.availableWalletPassList, currentOrderMetaList === null || currentOrderMetaList === void 0 ? void 0 : currentOrderMetaList.point_cards_snapshot);
1654
+ tempOrder.order_meta_list = _objectSpread(_objectSpread({}, currentOrderMetaList || {}), {}, {
1655
+ point_cards_snapshot: _mergePointCardSnapshotCodes(snapshotsWithExistingCodes, this.getRememberedPointCardSnapshotCodeCandidates()),
1732
1656
  virtual_currency_snapshot: buildVirtualCurrencySnapshotFromList(virtualCurrencyList)
1733
1657
  });
1734
1658
  this.store.availableWalletIds = _toConsumableArray(params.availableWalletIds);
@@ -1736,6 +1660,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1736
1660
  this.persistTempOrder();
1737
1661
  this.saveDraftInBackground();
1738
1662
  }
1663
+
1664
+ /**
1665
+ * 将 Payment WalletPass 返回的实例 code 回填到当前订单 Snapshot。
1666
+ * 这里只按资产 ID 补空值,不新增卡、不覆盖 prepare/config 冻结的余额。
1667
+ */
1668
+ }, {
1669
+ key: "mergePointCardSnapshotCodes",
1670
+ value: function mergePointCardSnapshotCodes(walletPassList, context) {
1671
+ var tempOrder = this.store.tempOrder;
1672
+ var currentOrderMetaList = normalizeOrderMetaList(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.order_meta_list);
1673
+ var currentSnapshots = (currentOrderMetaList === null || currentOrderMetaList === void 0 ? void 0 : currentOrderMetaList.point_cards_snapshot) || [];
1674
+ if (!tempOrder || !this.isPointCardSnapshotMergeContextCurrent(context)) {
1675
+ return currentSnapshots;
1676
+ }
1677
+ this.rememberPointCardSnapshotCodeCandidates(walletPassList);
1678
+ if (!currentSnapshots.length) return currentSnapshots;
1679
+ var nextSnapshots = _mergePointCardSnapshotCodes(currentSnapshots, this.getRememberedPointCardSnapshotCodeCandidates());
1680
+ var hasChanged = nextSnapshots.some(function (snapshot, index) {
1681
+ var _currentSnapshots$ind;
1682
+ return snapshot.code !== ((_currentSnapshots$ind = currentSnapshots[index]) === null || _currentSnapshots$ind === void 0 ? void 0 : _currentSnapshots$ind.code);
1683
+ });
1684
+ if (!hasChanged) return currentSnapshots;
1685
+ tempOrder.order_meta_list = _objectSpread(_objectSpread({}, currentOrderMetaList || {}), {}, {
1686
+ point_cards_snapshot: nextSnapshots
1687
+ });
1688
+ this.persistTempOrder();
1689
+ this.saveDraftInBackground();
1690
+ return nextSnapshots;
1691
+ }
1739
1692
  }, {
1740
1693
  key: "createExternalSaleNumber",
1741
1694
  value: function createExternalSaleNumber() {
@@ -1836,15 +1789,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1836
1789
  }, {
1837
1790
  key: "extractOrderIdFromSubmitResult",
1838
1791
  value: function extractOrderIdFromSubmitResult(result) {
1839
- var _ref18, _ref19, _ref20, _result$data$order_id, _result$data, _result$data2;
1840
- return (_ref18 = (_ref19 = (_ref20 = (_result$data$order_id = result === null || result === void 0 || (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.order_id) !== null && _result$data$order_id !== void 0 ? _result$data$order_id : result === null || result === void 0 ? void 0 : result.order_id) !== null && _ref20 !== void 0 ? _ref20 : result === null || result === void 0 || (_result$data2 = result.data) === null || _result$data2 === void 0 ? void 0 : _result$data2.id) !== null && _ref19 !== void 0 ? _ref19 : result === null || result === void 0 ? void 0 : result.id) !== null && _ref18 !== void 0 ? _ref18 : null;
1792
+ var _ref21, _ref22, _ref23, _result$data$order_id, _result$data, _result$data2;
1793
+ return (_ref21 = (_ref22 = (_ref23 = (_result$data$order_id = result === null || result === void 0 || (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.order_id) !== null && _result$data$order_id !== void 0 ? _result$data$order_id : result === null || result === void 0 ? void 0 : result.order_id) !== null && _ref23 !== void 0 ? _ref23 : result === null || result === void 0 || (_result$data2 = result.data) === null || _result$data2 === void 0 ? void 0 : _result$data2.id) !== null && _ref22 !== void 0 ? _ref22 : result === null || result === void 0 ? void 0 : result.id) !== null && _ref21 !== void 0 ? _ref21 : null;
1841
1794
  }
1842
1795
  }, {
1843
1796
  key: "calculatePaymentEffectiveAmount",
1844
1797
  value: function calculatePaymentEffectiveAmount(payment) {
1845
- var _ref21, _payment$origin_amoun;
1798
+ var _ref24, _payment$origin_amoun;
1846
1799
  var amount = new Decimal(payment.amount || 0);
1847
- var originAmount = new Decimal((_ref21 = (_payment$origin_amoun = payment.origin_amount) !== null && _payment$origin_amoun !== void 0 ? _payment$origin_amoun : payment.amount) !== null && _ref21 !== void 0 ? _ref21 : 0);
1800
+ var originAmount = new Decimal((_ref24 = (_payment$origin_amoun = payment.origin_amount) !== null && _payment$origin_amoun !== void 0 ? _payment$origin_amoun : payment.amount) !== null && _ref24 !== void 0 ? _ref24 : 0);
1848
1801
  var serviceFee = new Decimal(payment.service_fee || 0);
1849
1802
  // TODO: 后端允许 amount 表示顾客实际支付总额后,移除这个兼容分支。
1850
1803
  var effectiveAmount = serviceFee.gt(0) && amount.eq(originAmount) ? amount.plus(serviceFee) : amount;
@@ -2065,12 +2018,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2065
2018
  }, {
2066
2019
  key: "normalizePaymentSource",
2067
2020
  value: function normalizePaymentSource(payment, options) {
2068
- var _ref22, _paymentRecord$origin;
2021
+ var _ref25, _paymentRecord$origin;
2069
2022
  var paymentRecord = payment;
2070
2023
  var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
2071
2024
  var normalized = ensureOrderPaymentNumber(_objectSpread(_objectSpread({}, paymentRecord), {}, {
2072
2025
  metadata: metadata,
2073
- origin_amount: (_ref22 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref22 !== void 0 ? _ref22 : '0.00'
2026
+ origin_amount: (_ref25 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref25 !== void 0 ? _ref25 : '0.00'
2074
2027
  }), (options === null || options === void 0 ? void 0 : options.devicePrefix) || this.getPaymentNumberDevicePrefixSync(), createUuidV4);
2075
2028
  if (paymentRecord.status !== undefined) {
2076
2029
  normalized.status = paymentRecord.status;
@@ -2426,7 +2379,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2426
2379
  _product$payment_pric,
2427
2380
  _sku$code,
2428
2381
  _sku$barcode,
2429
- _ref23,
2382
+ _ref26,
2430
2383
  _sku$variant_id,
2431
2384
  _this13 = this;
2432
2385
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
@@ -2435,10 +2388,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2435
2388
  var _discount$type;
2436
2389
  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;
2437
2390
  });
2438
- var fullCoveragePassType = discountTypes.find(function (type) {
2439
- return ['entitlement_pass', 'good_pass'].includes(type);
2440
- });
2441
- var extensionType = (product === null || product === void 0 ? void 0 : product.extension_type) || fullCoveragePassType || 'normal';
2391
+ var extensionType = (product === null || product === void 0 ? void 0 : product.extension_type) || (discountTypes.includes('good_pass') ? 'good_pass' : 'normal');
2442
2392
  return {
2443
2393
  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,
2444
2394
  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,
@@ -2456,24 +2406,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2456
2406
  product_sku: this.normalizeFingerprintValue({
2457
2407
  code: (_sku$code = sku.code) !== null && _sku$code !== void 0 ? _sku$code : '',
2458
2408
  barcode: (_sku$barcode = sku.barcode) !== null && _sku$barcode !== void 0 ? _sku$barcode : '',
2459
- variant_id: (_ref23 = (_sku$variant_id = sku.variant_id) !== null && _sku$variant_id !== void 0 ? _sku$variant_id : product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _ref23 !== void 0 ? _ref23 : 0,
2409
+ variant_id: (_ref26 = (_sku$variant_id = sku.variant_id) !== null && _sku$variant_id !== void 0 ? _sku$variant_id : product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _ref26 !== void 0 ? _ref26 : 0,
2460
2410
  variant: sku.variant || [],
2461
2411
  option: getProductSkuOptions(product || {}).map(function (option) {
2462
- var _ref24, _option$id, _option$option_group_, _ref25, _option$option_group_2, _option$num, _option$add_price;
2412
+ var _ref27, _option$id, _option$option_group_, _ref28, _option$option_group_2, _option$num, _option$add_price;
2463
2413
  return {
2464
- id: (_ref24 = (_option$id = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id !== void 0 ? _option$id : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref24 !== void 0 ? _ref24 : null,
2414
+ id: (_ref27 = (_option$id = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id !== void 0 ? _option$id : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref27 !== void 0 ? _ref27 : null,
2465
2415
  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,
2466
- option_group_item_id: (_ref25 = (_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 && _ref25 !== void 0 ? _ref25 : null,
2416
+ 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,
2467
2417
  num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
2468
2418
  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)
2469
2419
  };
2470
2420
  })
2471
2421
  }),
2472
2422
  product_bundle: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.product_bundle) || []).map(function (bundle) {
2473
- var _ref26, _ref27, _bundle$bundle_produc, _ref28, _bundle$bundle_varian, _bundle$num, _bundle$price_type, _bundle$price_type_ex;
2423
+ var _ref29, _ref30, _bundle$bundle_produc, _ref31, _bundle$bundle_varian, _bundle$num, _bundle$price_type, _bundle$price_type_ex;
2474
2424
  return {
2475
- bundle_product_id: (_ref26 = (_ref27 = (_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 && _ref27 !== void 0 ? _ref27 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref26 !== void 0 ? _ref26 : null,
2476
- bundle_variant_id: (_ref28 = (_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 && _ref28 !== void 0 ? _ref28 : 0,
2425
+ 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,
2426
+ 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,
2477
2427
  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),
2478
2428
  price: _this13.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
2479
2429
  bundle_selling_price: _this13.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
@@ -2482,10 +2432,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2482
2432
  };
2483
2433
  })),
2484
2434
  discount_list: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
2485
- var _ref29, _discount$type2, _ref30, _ref31, _discount$discount_id, _discount$discount;
2435
+ var _ref32, _discount$type2, _ref33, _ref34, _discount$discount_id, _discount$discount;
2486
2436
  return {
2487
- type: (_ref29 = (_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 && _ref29 !== void 0 ? _ref29 : '',
2488
- discount_id: (_ref30 = (_ref31 = (_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 && _ref31 !== void 0 ? _ref31 : discount === null || discount === void 0 || (_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) !== null && _ref30 !== void 0 ? _ref30 : null,
2437
+ 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 : '',
2438
+ 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,
2489
2439
  amount: _this13.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2490
2440
  };
2491
2441
  }))
@@ -2509,14 +2459,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2509
2459
  var _product$product_id3,
2510
2460
  _product$product_vari2,
2511
2461
  _product$num2,
2512
- _ref32,
2462
+ _ref35,
2513
2463
  _metadata$unique_iden,
2514
2464
  _metadata$price_overr,
2515
2465
  _metadata$is_manual_d,
2516
2466
  _metadata$product_dis,
2517
2467
  _sku$code2,
2518
2468
  _sku$barcode2,
2519
- _ref33,
2469
+ _ref36,
2520
2470
  _sku$variant_id2,
2521
2471
  _this15 = this;
2522
2472
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
@@ -2525,17 +2475,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2525
2475
  var _discount$type3;
2526
2476
  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;
2527
2477
  });
2528
- var fullCoveragePassType = discountTypes.find(function (type) {
2529
- return ['entitlement_pass', 'good_pass'].includes(type);
2530
- });
2531
- var extensionType = (product === null || product === void 0 ? void 0 : product.extension_type) || fullCoveragePassType || 'normal';
2478
+ var extensionType = (product === null || product === void 0 ? void 0 : product.extension_type) || (discountTypes.includes('good_pass') ? 'good_pass' : 'normal');
2532
2479
  return {
2533
2480
  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,
2534
2481
  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,
2535
2482
  extension_type: extensionType,
2536
2483
  num: getSafeProductNum((_product$num2 = product === null || product === void 0 ? void 0 : product.num) !== null && _product$num2 !== void 0 ? _product$num2 : product === null || product === void 0 ? void 0 : product.product_quantity),
2537
2484
  metadata: {
2538
- unique_identification_number: (_ref32 = (_metadata$unique_iden = metadata.unique_identification_number) !== null && _metadata$unique_iden !== void 0 ? _metadata$unique_iden : product === null || product === void 0 ? void 0 : product.unique_identification_number) !== null && _ref32 !== void 0 ? _ref32 : '',
2485
+ unique_identification_number: (_ref35 = (_metadata$unique_iden = metadata.unique_identification_number) !== null && _metadata$unique_iden !== void 0 ? _metadata$unique_iden : product === null || product === void 0 ? void 0 : product.unique_identification_number) !== null && _ref35 !== void 0 ? _ref35 : '',
2539
2486
  price_override: (_metadata$price_overr = metadata.price_override) !== null && _metadata$price_overr !== void 0 ? _metadata$price_overr : '',
2540
2487
  is_manual_discount: (_metadata$is_manual_d = metadata.is_manual_discount) !== null && _metadata$is_manual_d !== void 0 ? _metadata$is_manual_d : '',
2541
2488
  product_discount_reason: (_metadata$product_dis = metadata.product_discount_reason) !== null && _metadata$product_dis !== void 0 ? _metadata$product_dis : ''
@@ -2543,35 +2490,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2543
2490
  product_sku: this.normalizeFingerprintValue({
2544
2491
  code: (_sku$code2 = sku.code) !== null && _sku$code2 !== void 0 ? _sku$code2 : '',
2545
2492
  barcode: (_sku$barcode2 = sku.barcode) !== null && _sku$barcode2 !== void 0 ? _sku$barcode2 : '',
2546
- variant_id: (_ref33 = (_sku$variant_id2 = sku.variant_id) !== null && _sku$variant_id2 !== void 0 ? _sku$variant_id2 : product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _ref33 !== void 0 ? _ref33 : 0,
2493
+ variant_id: (_ref36 = (_sku$variant_id2 = sku.variant_id) !== null && _sku$variant_id2 !== void 0 ? _sku$variant_id2 : product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _ref36 !== void 0 ? _ref36 : 0,
2547
2494
  variant: sku.variant || [],
2548
2495
  option: getProductSkuOptions(product || {}).map(function (option) {
2549
- var _ref34, _option$id2, _option$option_group_3, _ref35, _option$option_group_4, _option$num2, _option$add_price2;
2496
+ var _ref37, _option$id2, _option$option_group_3, _ref38, _option$option_group_4, _option$num2, _option$add_price2;
2550
2497
  return {
2551
- id: (_ref34 = (_option$id2 = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id2 !== void 0 ? _option$id2 : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref34 !== void 0 ? _ref34 : null,
2498
+ id: (_ref37 = (_option$id2 = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id2 !== void 0 ? _option$id2 : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref37 !== void 0 ? _ref37 : null,
2552
2499
  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,
2553
- option_group_item_id: (_ref35 = (_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 && _ref35 !== void 0 ? _ref35 : null,
2500
+ 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,
2554
2501
  num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
2555
2502
  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)
2556
2503
  };
2557
2504
  })
2558
2505
  }),
2559
2506
  product_bundle: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.product_bundle) || []).map(function (bundle) {
2560
- var _ref36, _bundle$bundle_id, _ref37, _bundle$bundle_group_, _ref38, _ref39, _bundle$bundle_produc2, _ref40, _bundle$bundle_varian2, _bundle$num2, _bundle$price_type2, _bundle$price_type_ex2;
2507
+ var _ref39, _bundle$bundle_id, _ref40, _bundle$bundle_group_, _ref41, _ref42, _bundle$bundle_produc2, _ref43, _bundle$bundle_varian2, _bundle$num2, _bundle$price_type2, _bundle$price_type_ex2;
2561
2508
  return {
2562
- bundle_id: (_ref36 = (_bundle$bundle_id = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_id) !== null && _bundle$bundle_id !== void 0 ? _bundle$bundle_id : bundle === null || bundle === void 0 ? void 0 : bundle.id) !== null && _ref36 !== void 0 ? _ref36 : null,
2563
- bundle_group_id: (_ref37 = (_bundle$bundle_group_ = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_group_id) !== null && _bundle$bundle_group_ !== void 0 ? _bundle$bundle_group_ : bundle === null || bundle === void 0 ? void 0 : bundle.group_id) !== null && _ref37 !== void 0 ? _ref37 : null,
2564
- bundle_product_id: (_ref38 = (_ref39 = (_bundle$bundle_produc2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref39 !== void 0 ? _ref39 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref38 !== void 0 ? _ref38 : null,
2565
- bundle_variant_id: (_ref40 = (_bundle$bundle_varian2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_variant_id) !== null && _bundle$bundle_varian2 !== void 0 ? _bundle$bundle_varian2 : bundle === null || bundle === void 0 ? void 0 : bundle.product_variant_id) !== null && _ref40 !== void 0 ? _ref40 : 0,
2509
+ bundle_id: (_ref39 = (_bundle$bundle_id = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_id) !== null && _bundle$bundle_id !== void 0 ? _bundle$bundle_id : bundle === null || bundle === void 0 ? void 0 : bundle.id) !== null && _ref39 !== void 0 ? _ref39 : null,
2510
+ bundle_group_id: (_ref40 = (_bundle$bundle_group_ = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_group_id) !== null && _bundle$bundle_group_ !== void 0 ? _bundle$bundle_group_ : bundle === null || bundle === void 0 ? void 0 : bundle.group_id) !== null && _ref40 !== void 0 ? _ref40 : null,
2511
+ bundle_product_id: (_ref41 = (_ref42 = (_bundle$bundle_produc2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref42 !== void 0 ? _ref42 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref41 !== void 0 ? _ref41 : null,
2512
+ bundle_variant_id: (_ref43 = (_bundle$bundle_varian2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_variant_id) !== null && _bundle$bundle_varian2 !== void 0 ? _bundle$bundle_varian2 : bundle === null || bundle === void 0 ? void 0 : bundle.product_variant_id) !== null && _ref43 !== void 0 ? _ref43 : 0,
2566
2513
  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),
2567
2514
  price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
2568
2515
  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 : '',
2569
2516
  option: _this15.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
2570
- var _ref41, _option$id3, _option$option_group_5, _ref42, _option$option_group_6, _option$num3, _option$add_price3;
2517
+ var _ref44, _option$id3, _option$option_group_5, _ref45, _option$option_group_6, _option$num3, _option$add_price3;
2571
2518
  return {
2572
- id: (_ref41 = (_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 && _ref41 !== void 0 ? _ref41 : null,
2519
+ 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,
2573
2520
  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,
2574
- option_group_item_id: (_ref42 = (_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 && _ref42 !== void 0 ? _ref42 : null,
2521
+ 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,
2575
2522
  num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
2576
2523
  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)
2577
2524
  };
@@ -2579,10 +2526,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2579
2526
  };
2580
2527
  })),
2581
2528
  discount_list: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
2582
- var _ref43, _discount$type4, _ref44, _ref45, _discount$discount_id2, _discount$discount2;
2529
+ var _ref46, _discount$type4, _ref47, _ref48, _discount$discount_id2, _discount$discount2;
2583
2530
  return {
2584
- type: (_ref43 = (_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 && _ref43 !== void 0 ? _ref43 : '',
2585
- discount_id: (_ref44 = (_ref45 = (_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 && _ref45 !== void 0 ? _ref45 : discount === null || discount === void 0 || (_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) !== null && _ref44 !== void 0 ? _ref44 : null,
2531
+ 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 : '',
2532
+ 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,
2586
2533
  amount: _this15.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2587
2534
  };
2588
2535
  }))
@@ -2909,11 +2856,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2909
2856
  }, {
2910
2857
  key: "getOrderIdentity",
2911
2858
  value: function getOrderIdentity() {
2912
- var _ref46, _ref47, _tempOrder$order_id, _tempOrder$_extend7;
2859
+ var _ref49, _ref50, _tempOrder$order_id, _tempOrder$_extend7;
2913
2860
  var tempOrder = this.store.tempOrder;
2914
2861
  if (!tempOrder) return null;
2915
2862
  var lastOrderInfo = this.store.lastOrderInfo || {};
2916
- var orderId = (_ref46 = (_ref47 = (_tempOrder$order_id = tempOrder.order_id) !== null && _tempOrder$order_id !== void 0 ? _tempOrder$order_id : lastOrderInfo.order_id) !== null && _ref47 !== void 0 ? _ref47 : lastOrderInfo.id) !== null && _ref46 !== void 0 ? _ref46 : null;
2863
+ var orderId = (_ref49 = (_ref50 = (_tempOrder$order_id = tempOrder.order_id) !== null && _tempOrder$order_id !== void 0 ? _tempOrder$order_id : lastOrderInfo.order_id) !== null && _ref50 !== void 0 ? _ref50 : lastOrderInfo.id) !== null && _ref49 !== void 0 ? _ref49 : null;
2917
2864
  return {
2918
2865
  localId: this.cacheId || ((_tempOrder$_extend7 = tempOrder._extend) === null || _tempOrder$_extend7 === void 0 ? void 0 : _tempOrder$_extend7.localId),
2919
2866
  orderId: orderId,
@@ -3083,11 +3030,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3083
3030
  }, {
3084
3031
  key: "captureProductRuntime",
3085
3032
  value: function captureProductRuntime(tempOrder, rawProduct, normalizedProduct, existedUid) {
3086
- var _extend$productsByUid, _ref48, _rawProduct$_origin;
3033
+ var _extend$productsByUid, _ref51, _rawProduct$_origin;
3087
3034
  var uid = existedUid || this.getProductUid(normalizedProduct);
3088
3035
  var extend = this.ensureExtend(tempOrder);
3089
3036
  var existed = ((_extend$productsByUid = extend.productsByUid) === null || _extend$productsByUid === void 0 ? void 0 : _extend$productsByUid[uid]) || {};
3090
- var origin = (_ref48 = (_rawProduct$_origin = rawProduct._origin) !== null && _rawProduct$_origin !== void 0 ? _rawProduct$_origin : normalizedProduct._origin) !== null && _ref48 !== void 0 ? _ref48 : existed.origin;
3037
+ var origin = (_ref51 = (_rawProduct$_origin = rawProduct._origin) !== null && _rawProduct$_origin !== void 0 ? _rawProduct$_origin : normalizedProduct._origin) !== null && _ref51 !== void 0 ? _ref51 : existed.origin;
3091
3038
  extend.productsByUid[uid] = _objectSpread(_objectSpread({}, existed), origin !== undefined ? {
3092
3039
  origin: origin
3093
3040
  } : {});
@@ -3230,7 +3177,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3230
3177
  }, {
3231
3178
  key: "buildTempOrderHolderFromBookings",
3232
3179
  value: function buildTempOrderHolderFromBookings(tempOrder) {
3233
- var _baseHolder$customer_, _baseHolder, _ref49, _baseHolder$form_id, _baseHolder2, _tempOrder$holder2, _baseHolder3, _this$otherParams2;
3180
+ var _baseHolder$customer_, _baseHolder, _ref52, _baseHolder$form_id, _baseHolder2, _tempOrder$holder2, _baseHolder3, _this$otherParams2;
3234
3181
  var holderRecords = [];
3235
3182
  var holderNames = [];
3236
3183
  var baseHolder = null;
@@ -3277,7 +3224,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3277
3224
  }
3278
3225
  var nextHolder = {
3279
3226
  customer_id: (_baseHolder$customer_ = (_baseHolder = baseHolder) === null || _baseHolder === void 0 ? void 0 : _baseHolder.customer_id) !== null && _baseHolder$customer_ !== void 0 ? _baseHolder$customer_ : tempOrder.customer_id,
3280
- form_id: (_ref49 = (_baseHolder$form_id = (_baseHolder2 = baseHolder) === null || _baseHolder2 === void 0 ? void 0 : _baseHolder2.form_id) !== null && _baseHolder$form_id !== void 0 ? _baseHolder$form_id : (_tempOrder$holder2 = tempOrder.holder) === null || _tempOrder$holder2 === void 0 ? void 0 : _tempOrder$holder2.form_id) !== null && _ref49 !== void 0 ? _ref49 : 0,
3227
+ form_id: (_ref52 = (_baseHolder$form_id = (_baseHolder2 = baseHolder) === null || _baseHolder2 === void 0 ? void 0 : _baseHolder2.form_id) !== null && _baseHolder$form_id !== void 0 ? _baseHolder$form_id : (_tempOrder$holder2 = tempOrder.holder) === null || _tempOrder$holder2 === void 0 ? void 0 : _tempOrder$holder2.form_id) !== null && _ref52 !== void 0 ? _ref52 : 0,
3281
3228
  form_record: holderRecords
3282
3229
  };
3283
3230
  if (holderNames.length) {
@@ -3382,7 +3329,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3382
3329
  key: "recalculateSummary",
3383
3330
  value: function () {
3384
3331
  var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(options) {
3385
- var _this$otherParams3, _ref50, _salesSummaryResult$e;
3332
+ var _this$otherParams3, _ref53, _salesSummaryResult$e;
3386
3333
  var tempOrder, originalSnapshot, hasShopDiscountChanged, shouldReuseOriginalSnapshot, snapshotSummary, shouldFullRecalculateFromSnapshot, summaryProducts, salesSummary, existedSummary, totalRefundAmount, paidPaymentSummary, emptyBaseSummary, emptySummaryBase, emptySummaryWithDeposit, emptySummary, salesSummaryResult, roundingAmount, payServiceChargeAmount, hasSalesSummaryAmount, expectAmount, amountPaymentPatch, normalizedExpectAmountPatch, summaryForGap, summary;
3387
3334
  return _regeneratorRuntime().wrap(function _callee13$(_context15) {
3388
3335
  while (1) switch (_context15.prev = _context15.next) {
@@ -3461,7 +3408,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3461
3408
  roundingAmount = paidPaymentSummary.roundingAmount;
3462
3409
  payServiceChargeAmount = paidPaymentSummary.payServiceChargeAmount;
3463
3410
  hasSalesSummaryAmount = salesSummaryResult.expect_amount !== undefined || salesSummaryResult.total_amount !== undefined;
3464
- expectAmount = hasSalesSummaryAmount ? new Decimal((_ref50 = (_salesSummaryResult$e = salesSummaryResult.expect_amount) !== null && _salesSummaryResult$e !== void 0 ? _salesSummaryResult$e : salesSummaryResult.total_amount) !== null && _ref50 !== void 0 ? _ref50 : 0) : null;
3411
+ expectAmount = hasSalesSummaryAmount ? new Decimal((_ref53 = (_salesSummaryResult$e = salesSummaryResult.expect_amount) !== null && _salesSummaryResult$e !== void 0 ? _salesSummaryResult$e : salesSummaryResult.total_amount) !== null && _ref53 !== void 0 ? _ref53 : 0) : null;
3465
3412
  amountPaymentPatch = hasSalesSummaryAmount || !roundingAmount.eq(0) || !payServiceChargeAmount.eq(0) ? _objectSpread({
3466
3413
  rounding_amount: roundingAmount.toFixed(2)
3467
3414
  }, expectAmount ? {
@@ -3584,8 +3531,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3584
3531
  }, {
3585
3532
  key: "getTempOrderNote",
3586
3533
  value: function getTempOrderNote() {
3587
- var _this$store$tempOrder4;
3588
- return ((_this$store$tempOrder4 = this.store.tempOrder) === null || _this$store$tempOrder4 === void 0 ? void 0 : _this$store$tempOrder4.note) || '';
3534
+ var _this$store$tempOrder6;
3535
+ return ((_this$store$tempOrder6 = this.store.tempOrder) === null || _this$store$tempOrder6 === void 0 ? void 0 : _this$store$tempOrder6.note) || '';
3589
3536
  }
3590
3537
  }, {
3591
3538
  key: "ensureSalesNotesRuntimeState",
@@ -3937,17 +3884,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3937
3884
  }, {
3938
3885
  key: "buildTempOrderCustomer",
3939
3886
  value: function buildTempOrderCustomer(params) {
3940
- var _ref51, _ref52, _ref53, _source$name, _ref54, _ref55, _ref56, _source$customer_name, _source$id, _source$customer_id, _ref57, _source$country_calli, _source$phone, _source$email;
3887
+ var _ref54, _ref55, _ref56, _source$name, _ref57, _ref58, _ref59, _source$customer_name, _source$id, _source$customer_id, _ref60, _source$country_calli, _source$phone, _source$email;
3941
3888
  if (!params.customerId) return null;
3942
3889
  var source = params.source ? cloneDeep(params.source) : {};
3943
- var name = (_ref51 = (_ref52 = (_ref53 = (_source$name = source.name) !== null && _source$name !== void 0 ? _source$name : source.display_name) !== null && _ref53 !== void 0 ? _ref53 : source.customerName) !== null && _ref52 !== void 0 ? _ref52 : source.customer_name) !== null && _ref51 !== void 0 ? _ref51 : params.customerName;
3944
- var customerName = (_ref54 = (_ref55 = (_ref56 = (_source$customer_name = source.customer_name) !== null && _source$customer_name !== void 0 ? _source$customer_name : source.customerName) !== null && _ref56 !== void 0 ? _ref56 : source.display_name) !== null && _ref55 !== void 0 ? _ref55 : source.name) !== null && _ref54 !== void 0 ? _ref54 : params.customerName;
3890
+ var name = (_ref54 = (_ref55 = (_ref56 = (_source$name = source.name) !== null && _source$name !== void 0 ? _source$name : source.display_name) !== null && _ref56 !== void 0 ? _ref56 : source.customerName) !== null && _ref55 !== void 0 ? _ref55 : source.customer_name) !== null && _ref54 !== void 0 ? _ref54 : params.customerName;
3891
+ var customerName = (_ref57 = (_ref58 = (_ref59 = (_source$customer_name = source.customer_name) !== null && _source$customer_name !== void 0 ? _source$customer_name : source.customerName) !== null && _ref59 !== void 0 ? _ref59 : source.display_name) !== null && _ref58 !== void 0 ? _ref58 : source.name) !== null && _ref57 !== void 0 ? _ref57 : params.customerName;
3945
3892
  return _objectSpread(_objectSpread({}, source), {}, {
3946
3893
  id: (_source$id = source.id) !== null && _source$id !== void 0 ? _source$id : params.customerId,
3947
3894
  customer_id: (_source$customer_id = source.customer_id) !== null && _source$customer_id !== void 0 ? _source$customer_id : params.customerId,
3948
3895
  name: String(name || ''),
3949
3896
  customer_name: String(customerName || ''),
3950
- country_calling_code: String((_ref57 = (_source$country_calli = source.country_calling_code) !== null && _source$country_calli !== void 0 ? _source$country_calli : source.countryCallingCode) !== null && _ref57 !== void 0 ? _ref57 : params.countryCallingCode),
3897
+ country_calling_code: String((_ref60 = (_source$country_calli = source.country_calling_code) !== null && _source$country_calli !== void 0 ? _source$country_calli : source.countryCallingCode) !== null && _ref60 !== void 0 ? _ref60 : params.countryCallingCode),
3951
3898
  phone: String((_source$phone = source.phone) !== null && _source$phone !== void 0 ? _source$phone : params.phone),
3952
3899
  email: String((_source$email = source.email) !== null && _source$email !== void 0 ? _source$email : params.email)
3953
3900
  });
@@ -3957,7 +3904,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3957
3904
  value: function isCustomerBoundDiscount(discount) {
3958
3905
  var _discount$type5;
3959
3906
  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;
3960
- return type === 'entitlement_pass' || type === 'good_pass' || type === 'discount_card' || type === 'product_discount_card';
3907
+ return type === 'good_pass' || type === 'discount_card' || type === 'product_discount_card';
3961
3908
  }
3962
3909
  }, {
3963
3910
  key: "shouldKeepCustomerBoundDiscountAfterCustomerChange",
@@ -4051,14 +3998,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4051
3998
  }, {
4052
3999
  key: "updateTempOrderCustomer",
4053
4000
  value: function updateTempOrderCustomer(customer) {
4054
- var _tempOrder$customer_i3, _ref58, _ref59, _customer$customer_id, _ref60, _ref61, _ref62, _customer$customer_na, _ref63, _customer$country_cal, _tempOrder$customer_i4;
4001
+ var _tempOrder$customer_i3, _ref61, _ref62, _customer$customer_id, _ref63, _ref64, _ref65, _customer$customer_na, _ref66, _customer$country_cal, _tempOrder$customer_i4;
4055
4002
  var tempOrder = this.ensureTempOrder();
4056
4003
  var previousCustomerId = (_tempOrder$customer_i3 = tempOrder.customer_id) !== null && _tempOrder$customer_i3 !== void 0 ? _tempOrder$customer_i3 : null;
4057
- var customerId = (_ref58 = (_ref59 = (_customer$customer_id = customer.customer_id) !== null && _customer$customer_id !== void 0 ? _customer$customer_id : customer.customerId) !== null && _ref59 !== void 0 ? _ref59 : customer.id) !== null && _ref58 !== void 0 ? _ref58 : null;
4058
- var customerName = (_ref60 = (_ref61 = (_ref62 = (_customer$customer_na = customer.customer_name) !== null && _customer$customer_na !== void 0 ? _customer$customer_na : customer.customerName) !== null && _ref62 !== void 0 ? _ref62 : customer.display_name) !== null && _ref61 !== void 0 ? _ref61 : customer.name) !== null && _ref60 !== void 0 ? _ref60 : '';
4004
+ var customerId = (_ref61 = (_ref62 = (_customer$customer_id = customer.customer_id) !== null && _customer$customer_id !== void 0 ? _customer$customer_id : customer.customerId) !== null && _ref62 !== void 0 ? _ref62 : customer.id) !== null && _ref61 !== void 0 ? _ref61 : null;
4005
+ var customerName = (_ref63 = (_ref64 = (_ref65 = (_customer$customer_na = customer.customer_name) !== null && _customer$customer_na !== void 0 ? _customer$customer_na : customer.customerName) !== null && _ref65 !== void 0 ? _ref65 : customer.display_name) !== null && _ref64 !== void 0 ? _ref64 : customer.name) !== null && _ref63 !== void 0 ? _ref63 : '';
4059
4006
  tempOrder.customer_id = customerId === null || customerId === undefined || customerId === '' ? null : Number(customerId);
4060
4007
  tempOrder.customer_name = String(customerName || '');
4061
- tempOrder.country_calling_code = String((_ref63 = (_customer$country_cal = customer.country_calling_code) !== null && _customer$country_cal !== void 0 ? _customer$country_cal : customer.countryCallingCode) !== null && _ref63 !== void 0 ? _ref63 : '');
4008
+ tempOrder.country_calling_code = String((_ref66 = (_customer$country_cal = customer.country_calling_code) !== null && _customer$country_cal !== void 0 ? _customer$country_cal : customer.countryCallingCode) !== null && _ref66 !== void 0 ? _ref66 : '');
4062
4009
  tempOrder.phone = String(customer.phone || '');
4063
4010
  tempOrder.email = String(customer.email || '');
4064
4011
  tempOrder.customer = this.buildTempOrderCustomer({
@@ -4139,8 +4086,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4139
4086
  }, {
4140
4087
  key: "getOrderCustomerSnapshot",
4141
4088
  value: function getOrderCustomerSnapshot() {
4142
- var _this$store$tempOrder5;
4143
- var snapshot = (_this$store$tempOrder5 = this.store.tempOrder) === null || _this$store$tempOrder5 === void 0 || (_this$store$tempOrder5 = _this$store$tempOrder5._extend) === null || _this$store$tempOrder5 === void 0 ? void 0 : _this$store$tempOrder5.customerSnapshot;
4089
+ var _this$store$tempOrder7;
4090
+ var snapshot = (_this$store$tempOrder7 = this.store.tempOrder) === null || _this$store$tempOrder7 === void 0 || (_this$store$tempOrder7 = _this$store$tempOrder7._extend) === null || _this$store$tempOrder7 === void 0 ? void 0 : _this$store$tempOrder7.customerSnapshot;
4144
4091
  return snapshot ? cloneDeep(snapshot) : null;
4145
4092
  }
4146
4093
  }, {
@@ -4646,7 +4593,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4646
4593
  }, {
4647
4594
  key: "assertAndLockProductSettlement",
4648
4595
  value: function assertAndLockProductSettlement(tempOrder, product) {
4649
- var _ref64, _ref65, _product$selling_pric;
4596
+ var _ref67, _ref68, _product$selling_pric;
4650
4597
  if (!this.isMultiCurrencySettlementEnabled()) return;
4651
4598
  var currentKey = getTempOrderSettlementKey(tempOrder);
4652
4599
  var incomingKey = getSettlementKey(getSelectedSettlementSnapshot(product)) || 'legal_currency';
@@ -4673,7 +4620,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4673
4620
  }
4674
4621
  applyTempOrderSettlementState(tempOrder, snapshot || {
4675
4622
  settlement_type: 'legal_currency',
4676
- price: (_ref64 = (_ref65 = (_product$selling_pric = product.selling_price) !== null && _product$selling_pric !== void 0 ? _product$selling_pric : product.original_price) !== null && _ref65 !== void 0 ? _ref65 : product.payment_price) !== null && _ref64 !== void 0 ? _ref64 : 0,
4623
+ price: (_ref67 = (_ref68 = (_product$selling_pric = product.selling_price) !== null && _product$selling_pric !== void 0 ? _product$selling_pric : product.original_price) !== null && _ref68 !== void 0 ? _ref68 : product.payment_price) !== null && _ref67 !== void 0 ? _ref67 : 0,
4677
4624
  unit_label: tempOrder.currency_code,
4678
4625
  symbol: tempOrder.currency_symbol,
4679
4626
  amount_format: tempOrder.currency_format
@@ -4825,35 +4772,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4825
4772
  }
4826
4773
  normalizedIncoming.discount_list = normalizeOrderProductDiscountList(normalizedIncoming.discount_list);
4827
4774
  var hasIncomingGoodPass = this.hasGoodPassDiscount(normalizedIncoming);
4828
- var hasIncomingEntitlementPass = this.hasEntitlementPassDiscount(normalizedIncoming);
4829
- var isIncomingEntitlementAppend = this.isRuntimeEntitlementAppend(productToAdd, tempOrder);
4830
- var isIncomingPersistedEntitlementPass = hasIncomingEntitlementPass && this.isPersistedProductLine(normalizedIncoming);
4831
4775
  var hasIncomingProductNote = this.hasOrderProductLineNote(normalizedIncoming);
4832
4776
  var hasIncomingManualProductDiscount = isManualProductDiscountProduct(normalizedIncoming);
4833
4777
  var hasIncomingBookingUid = this.hasLinkedBookingUid(productToAdd) || this.hasLinkedBookingUid(normalizedIncoming);
4834
4778
  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;
4835
- var shouldForceNewLine = disableMerge || !!booking || hasIncomingGoodPass || isIncomingPersistedEntitlementPass || hasIncomingBookingUid || isIncomingCustomItem || isWeighingProduct;
4836
- var matchedIndex = shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
4779
+ var shouldForceNewLine = disableMerge || !!booking || hasIncomingProductNote || hasIncomingManualProductDiscount || hasIncomingBookingUid || isIncomingCustomItem || isWeighingProduct;
4780
+ var matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
4781
+ var _item$metadata3;
4837
4782
  if (_this31.hasGoodPassDiscount(item)) return false;
4838
- var isRuntimeEntitlementPass = _this31.isRuntimeEntitlementAppend(item, tempOrder);
4839
- if (isIncomingEntitlementAppend !== isRuntimeEntitlementPass) {
4840
- return false;
4841
- }
4842
- if (isIncomingEntitlementAppend && _this31.isPersistedProductLine(item)) {
4843
- return false;
4844
- }
4845
- var hasExistingProductNote = _this31.hasOrderProductLineNote(item);
4846
- if ((hasIncomingProductNote || hasExistingProductNote) && (!isRuntimeEntitlementPass || String(normalizedIncoming.note || '').trim() !== String(item.note || '').trim())) {
4847
- return false;
4848
- }
4849
- var hasExistingManualProductDiscount = isManualProductDiscountProduct(item);
4850
- if (isRuntimeEntitlementPass && !_this31.hasSameEntitlementMergePriceConfig(normalizedIncoming, item)) {
4851
- return false;
4852
- }
4853
- if ((hasIncomingManualProductDiscount || hasExistingManualProductDiscount) && !isRuntimeEntitlementPass) {
4854
- return false;
4855
- }
4856
- if (_this31.isPersistedProductLine(item)) return false;
4783
+ if (_this31.hasOrderProductLineNote(item)) return false;
4784
+ if (isManualProductDiscountProduct(item)) return false;
4785
+ if (item.order_detail_id !== undefined && item.order_detail_id !== null) return false;
4786
+ if ((_item$metadata3 = item.metadata) !== null && _item$metadata3 !== void 0 && _item$metadata3.is_edit_for_runtime) return false;
4857
4787
  if (item.product_id !== productToAdd.product_id) return false;
4858
4788
  if (item.product_variant_id !== productToAdd.product_variant_id) return false;
4859
4789
  var existedFingerprint = buildProductLineFingerprint(getProductSkuOptions(item), item.product_bundle);
@@ -4943,14 +4873,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4943
4873
  }, {
4944
4874
  key: "createSplitBookingLine",
4945
4875
  value: function createSplitBookingLine(product, booking, index, splitCount) {
4946
- var _booking$metadata6, _ref66, _ref67, _bookingHolder$form_r, _booking$metadata7, _product$metadata10, _bookingHolder$name, _singleBooking$metada;
4876
+ var _booking$metadata6, _ref69, _ref70, _bookingHolder$form_r, _booking$metadata7, _product$metadata10, _bookingHolder$name, _singleBooking$metada;
4947
4877
  var singleLine = cloneDeep(product);
4948
4878
  singleLine.num = 1;
4949
4879
  delete singleLine.product_quantity;
4950
4880
  var singleBooking = cloneDeep(booking);
4951
4881
  var bookingHolder = booking !== null && booking !== void 0 && booking.holder && _typeof(booking.holder) === 'object' ? booking.holder : null;
4952
4882
  var metadataHolder = booking !== null && booking !== void 0 && (_booking$metadata6 = booking.metadata) !== null && _booking$metadata6 !== void 0 && _booking$metadata6.holder && _typeof(booking.metadata.holder) === 'object' ? booking.metadata.holder : null;
4953
- var rawHolderIds = (_ref66 = (_ref67 = (_bookingHolder$form_r = bookingHolder === null || bookingHolder === void 0 ? void 0 : bookingHolder.form_record) !== null && _bookingHolder$form_r !== void 0 ? _bookingHolder$form_r : booking === null || booking === void 0 || (_booking$metadata7 = booking.metadata) === null || _booking$metadata7 === void 0 ? void 0 : _booking$metadata7.holder_id) !== null && _ref67 !== void 0 ? _ref67 : metadataHolder === null || metadataHolder === void 0 ? void 0 : metadataHolder.form_record) !== null && _ref66 !== void 0 ? _ref66 : product === null || product === void 0 || (_product$metadata10 = product.metadata) === null || _product$metadata10 === void 0 ? void 0 : _product$metadata10.holder_id;
4883
+ var rawHolderIds = (_ref69 = (_ref70 = (_bookingHolder$form_r = bookingHolder === null || bookingHolder === void 0 ? void 0 : bookingHolder.form_record) !== null && _bookingHolder$form_r !== void 0 ? _bookingHolder$form_r : booking === null || booking === void 0 || (_booking$metadata7 = booking.metadata) === null || _booking$metadata7 === void 0 ? void 0 : _booking$metadata7.holder_id) !== null && _ref70 !== void 0 ? _ref70 : metadataHolder === null || metadataHolder === void 0 ? void 0 : metadataHolder.form_record) !== null && _ref69 !== void 0 ? _ref69 : product === null || product === void 0 || (_product$metadata10 = product.metadata) === null || _product$metadata10 === void 0 ? void 0 : _product$metadata10.holder_id;
4954
4884
  var holderIds = (Array.isArray(rawHolderIds) ? rawHolderIds : [rawHolderIds]).map(function (holderId) {
4955
4885
  return holderId && _typeof(holderId) === 'object' ? holderId.form_record_id : holderId;
4956
4886
  }).filter(function (holderId) {
@@ -5016,7 +4946,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5016
4946
  value: (function () {
5017
4947
  var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(product, booking, options) {
5018
4948
  var _this32 = this;
5019
- var tempOrder, salesNoteDrafts, mutationSnapshot, attachSalesNoteDrafts, rollbackProductAndNotesMutation, insertAfterProductUid, anchorIndex, insertAtIndex, _ref68, _productRecord$num, productRecord, splitCount, i, splitLine, committedProduct, _committedProduct, _committedProduct2;
4949
+ var tempOrder, salesNoteDrafts, mutationSnapshot, attachSalesNoteDrafts, rollbackProductAndNotesMutation, insertAfterProductUid, anchorIndex, insertAtIndex, _ref71, _productRecord$num, productRecord, splitCount, i, splitLine, committedProduct, _committedProduct, _committedProduct2;
5020
4950
  return _regeneratorRuntime().wrap(function _callee23$(_context25) {
5021
4951
  while (1) switch (_context25.prev = _context25.next) {
5022
4952
  case 0:
@@ -5074,7 +5004,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5074
5004
  break;
5075
5005
  }
5076
5006
  productRecord = product;
5077
- splitCount = getSafeProductNum((_ref68 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref68 !== void 0 ? _ref68 : 1);
5007
+ splitCount = getSafeProductNum((_ref71 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref71 !== void 0 ? _ref71 : 1);
5078
5008
  if (!(splitCount > 1)) {
5079
5009
  _context25.next = 27;
5080
5010
  break;
@@ -5179,7 +5109,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5179
5109
  key: "addProductsToOrder",
5180
5110
  value: (function () {
5181
5111
  var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(items, options) {
5182
- var tempOrder, _iterator20, _step20, item, product, booking, _ref69, _productRecord$num2, productRecord, splitCount, i, splitLine, _appendResult, appendResult;
5112
+ var tempOrder, _iterator20, _step20, item, product, booking, _ref72, _productRecord$num2, productRecord, splitCount, i, splitLine, _appendResult, appendResult;
5183
5113
  return _regeneratorRuntime().wrap(function _callee24$(_context26) {
5184
5114
  while (1) switch (_context26.prev = _context26.next) {
5185
5115
  case 0:
@@ -5211,7 +5141,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5211
5141
  break;
5212
5142
  }
5213
5143
  productRecord = product;
5214
- splitCount = getSafeProductNum((_ref69 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref69 !== void 0 ? _ref69 : 1);
5144
+ splitCount = getSafeProductNum((_ref72 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref72 !== void 0 ? _ref72 : 1);
5215
5145
  if (!(splitCount > 1)) {
5216
5146
  _context26.next = 26;
5217
5147
  break;
@@ -5278,99 +5208,45 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5278
5208
  return addProductsToOrder;
5279
5209
  }())
5280
5210
  }, {
5281
- key: "getFullCoveragePassDiscounts",
5282
- value: function getFullCoveragePassDiscounts(product) {
5211
+ key: "hasGoodPassDiscount",
5212
+ value: function hasGoodPassDiscount(product) {
5283
5213
  var _product$_extend;
5284
- var discountList = _toConsumableArray(product.discount_list || []);
5214
+ var hasMainGoodPass = (product.discount_list || []).some(function (item) {
5215
+ return (item === null || item === void 0 ? void 0 : item.type) === 'good_pass' || (item === null || item === void 0 ? void 0 : item.tag) === 'good_pass';
5216
+ });
5217
+ if (hasMainGoodPass) return true;
5218
+ var bundleDiscountList = [];
5285
5219
  (product.product_bundle || []).forEach(function (item) {
5286
- discountList.push.apply(discountList, _toConsumableArray((item === null || item === void 0 ? void 0 : item.discount_list) || []));
5220
+ bundleDiscountList.push.apply(bundleDiscountList, _toConsumableArray((item === null || item === void 0 ? void 0 : item.discount_list) || []));
5287
5221
  });
5288
5222
  ((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) {
5289
- discountList.push.apply(discountList, _toConsumableArray((item === null || item === void 0 ? void 0 : item.discount_list) || []));
5223
+ bundleDiscountList.push.apply(bundleDiscountList, _toConsumableArray((item === null || item === void 0 ? void 0 : item.discount_list) || []));
5290
5224
  });
5291
- return discountList.filter(function (item) {
5292
- return isFullCoveragePass(item);
5225
+ return bundleDiscountList.some(function (item) {
5226
+ return (item === null || item === void 0 ? void 0 : item.type) === 'good_pass' || (item === null || item === void 0 ? void 0 : item.tag) === 'good_pass';
5293
5227
  });
5294
5228
  }
5295
- }, {
5296
- key: "hasEntitlementPassDiscount",
5297
- value: function hasEntitlementPassDiscount(product) {
5298
- return this.getFullCoveragePassDiscounts(product).some(function (item) {
5299
- return isEntitlementPass(item);
5300
- });
5301
- }
5302
- }, {
5303
- key: "hasGoodPassDiscount",
5304
- value: function hasGoodPassDiscount(product) {
5305
- return this.getFullCoveragePassDiscounts(product).some(function (item) {
5306
- return !isEntitlementPass(item);
5307
- });
5308
- }
5309
- }, {
5310
- key: "isPersistedProductLine",
5311
- value: function isPersistedProductLine(product) {
5312
- var _product$metadata11;
5313
- 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;
5314
- }
5315
- }, {
5316
- key: "isRuntimeEntitlementAppend",
5317
- value: function isRuntimeEntitlementAppend(product, tempOrder) {
5318
- var _product$metadata$uni, _product$metadata12, _tempOrder$_extend10, _product$_origin;
5319
- if (this.isPersistedProductLine(product)) return false;
5320
- 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;
5321
- 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;
5322
- 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);
5323
- }
5324
- }, {
5325
- key: "hasSameEntitlementMergePriceConfig",
5326
- value: function hasSameEntitlementMergePriceConfig(incoming, existing) {
5327
- var _this33 = this;
5328
- var buildPriceConfig = function buildPriceConfig(product) {
5329
- var metadata = product.metadata || {};
5330
- var bundle = (product.product_bundle || []).map(function (item) {
5331
- var _ref70, _item$bundle_id, _ref71, _ref72, _item$bundle_product_, _ref73, _item$bundle_variant_, _ref74, _item$price_type, _ref75, _item$price_type_ext;
5332
- return {
5333
- bundle_id: (_ref70 = (_item$bundle_id = item.bundle_id) !== null && _item$bundle_id !== void 0 ? _item$bundle_id : item.id) !== null && _ref70 !== void 0 ? _ref70 : null,
5334
- bundle_product_id: (_ref71 = (_ref72 = (_item$bundle_product_ = item.bundle_product_id) !== null && _item$bundle_product_ !== void 0 ? _item$bundle_product_ : item._bundle_product_id) !== null && _ref72 !== void 0 ? _ref72 : item.product_id) !== null && _ref71 !== void 0 ? _ref71 : null,
5335
- bundle_variant_id: (_ref73 = (_item$bundle_variant_ = item.bundle_variant_id) !== null && _item$bundle_variant_ !== void 0 ? _item$bundle_variant_ : item.product_variant_id) !== null && _ref73 !== void 0 ? _ref73 : 0,
5336
- price_type: (_ref74 = (_item$price_type = item.price_type) !== null && _item$price_type !== void 0 ? _item$price_type : item.custom_price_type) !== null && _ref74 !== void 0 ? _ref74 : '',
5337
- price_type_ext: (_ref75 = (_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 && _ref75 !== void 0 ? _ref75 : ''
5338
- };
5339
- }).sort(function (left, right) {
5340
- return JSON.stringify(left).localeCompare(JSON.stringify(right));
5341
- });
5342
- return JSON.stringify({
5343
- original_price: _this33.normalizeFingerprintMoney(product.original_price),
5344
- source_product_price: _this33.normalizeFingerprintMoney(metadata.source_product_price),
5345
- main_product_original_price: _this33.normalizeFingerprintMoney(metadata.main_product_original_price),
5346
- price_override: _this33.normalizeFingerprintMoney(metadata.price_override),
5347
- is_manual_discount: Boolean(metadata.is_manual_discount),
5348
- bundle: bundle
5349
- });
5350
- };
5351
- return buildPriceConfig(incoming) === buildPriceConfig(existing);
5352
- }
5353
5229
  }, {
5354
5230
  key: "getBundleRuntimeIdentity",
5355
5231
  value: function getBundleRuntimeIdentity(bundle) {
5356
- var _ref76, _bundle$bundle_id2, _ref77, _bundle$bundle_group_2, _ref78, _ref79, _bundle$bundle_produc3, _ref80, _bundle$bundle_varian3;
5232
+ var _ref73, _bundle$bundle_id2, _ref74, _bundle$bundle_group_2, _ref75, _ref76, _bundle$bundle_produc3, _ref77, _bundle$bundle_varian3;
5357
5233
  if (!bundle || _typeof(bundle) !== 'object') return '';
5358
- return [(_ref76 = (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id) !== null && _ref76 !== void 0 ? _ref76 : '', (_ref77 = (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id) !== null && _ref77 !== void 0 ? _ref77 : '', (_ref78 = (_ref79 = (_bundle$bundle_produc3 = bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle._bundle_product_id) !== null && _ref79 !== void 0 ? _ref79 : bundle.product_id) !== null && _ref78 !== void 0 ? _ref78 : '', (_ref80 = (_bundle$bundle_varian3 = bundle.bundle_variant_id) !== null && _bundle$bundle_varian3 !== void 0 ? _bundle$bundle_varian3 : bundle.product_variant_id) !== null && _ref80 !== void 0 ? _ref80 : 0].join('|');
5234
+ 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('|');
5359
5235
  }
5360
5236
  }, {
5361
5237
  key: "preservePersistedBundlePriceFields",
5362
5238
  value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
5363
- var _this34 = this;
5239
+ var _this33 = this;
5364
5240
  if (!Array.isArray(nextBundles)) return nextBundles;
5365
5241
  if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
5366
5242
  var previousByIdentity = new Map();
5367
5243
  previousBundles.forEach(function (bundle) {
5368
- var identity = _this34.getBundleRuntimeIdentity(bundle);
5244
+ var identity = _this33.getBundleRuntimeIdentity(bundle);
5369
5245
  if (identity) previousByIdentity.set(identity, bundle);
5370
5246
  });
5371
5247
  return nextBundles.map(function (bundle, index) {
5372
5248
  if (!bundle || _typeof(bundle) !== 'object') return bundle;
5373
- var previous = previousByIdentity.get(_this34.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
5249
+ var previous = previousByIdentity.get(_this33.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
5374
5250
  if (!previous || _typeof(previous) !== 'object') return bundle;
5375
5251
  return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
5376
5252
  cover: previous.cover
@@ -5506,13 +5382,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5506
5382
  delete nextProduct.metadata.main_product_original_price;
5507
5383
  delete nextProduct.metadata.price_schema_version;
5508
5384
  } else if (callerChangesLineConfiguration && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
5509
- var _ref81, _targetProduct$metada10, _targetProduct$metada11, _ref82, _targetProduct$metada12, _targetProduct$metada13, _targetProduct$metada14;
5385
+ var _ref78, _targetProduct$metada10, _targetProduct$metada11, _ref79, _targetProduct$metada12, _targetProduct$metada13, _targetProduct$metada14;
5510
5386
  // 仅 option / bundle 变化时,保留历史 source 和主商品折扣金额,
5511
5387
  // 但必须让 original 与 selling 一起随新的 option 金额移动。
5512
5388
  var previousOptionSum = sumOptionUnitPrice(getProductSkuOptions(targetProduct));
5513
5389
  var nextOptionSum = sumOptionUnitPrice(getProductSkuOptions(nextProduct));
5514
- var _previousMainOriginal = new Decimal(Number((_ref81 = (_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 && _ref81 !== void 0 ? _ref81 : 0) || 0);
5515
- var _previousMainSelling = new Decimal(Number((_ref82 = (_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 && _ref82 !== void 0 ? _ref82 : _previousMainOriginal.toNumber()) || 0);
5390
+ var _previousMainOriginal = new Decimal(Number((_ref78 = (_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 && _ref78 !== void 0 ? _ref78 : 0) || 0);
5391
+ var _previousMainSelling = new Decimal(Number((_ref79 = (_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 && _ref79 !== void 0 ? _ref79 : _previousMainOriginal.toNumber()) || 0);
5516
5392
  var _preservedDiscount = _previousMainOriginal.minus(_previousMainSelling);
5517
5393
  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);
5518
5394
  var _nextMainOriginal = previousSource.plus(nextOptionSum);
@@ -5533,7 +5409,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5533
5409
  // normalizeOrderProduct 幂等:v2 metadata 存在 → 保留 main_product_* 折扣重算 composite;
5534
5410
  // 否则 → 把顶层 selling_price 视作 source,派生 main_product_* 并写 price_schema_version: 2。
5535
5411
  var normalizedProduct = this.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(nextProduct, normalizeOrderProduct(nextProduct)));
5536
- normalizedProduct.discount_list = normalizeOrderProductDiscountList(isPersistedOrderLine ? syncReducedEntitlementPassUsageCount(normalizedProduct.discount_list, targetProduct.num, normalizedProduct.num) : normalizedProduct.discount_list);
5412
+ normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
5537
5413
  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);
5538
5414
  if (!booking && preservedBookingUid) {
5539
5415
  normalizedProduct.booking_uid = preservedBookingUid;
@@ -5612,7 +5488,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5612
5488
  key: "updateOrderProducts",
5613
5489
  value: function () {
5614
5490
  var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(paramsList) {
5615
- var _this35 = this;
5491
+ var _this34 = this;
5616
5492
  var tempOrder, reapplyBookingDiscountProductUids;
5617
5493
  return _regeneratorRuntime().wrap(function _callee26$(_context28) {
5618
5494
  while (1) switch (_context28.prev = _context28.next) {
@@ -5625,7 +5501,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5625
5501
  return _context28.abrupt("return", tempOrder.products);
5626
5502
  case 3:
5627
5503
  reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
5628
- var updatedProductUid = _this35.applyOrderProductUpdateToTempOrder(tempOrder, params);
5504
+ var updatedProductUid = _this34.applyOrderProductUpdateToTempOrder(tempOrder, params);
5629
5505
  // 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
5630
5506
  if (params.allow_booking_discount_reapply && updatedProductUid) {
5631
5507
  acc.push(String(updatedProductUid));
@@ -5657,7 +5533,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5657
5533
  value: function () {
5658
5534
  var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
5659
5535
  var _targetProduct$metada17;
5660
- 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;
5536
+ 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;
5661
5537
  return _regeneratorRuntime().wrap(function _callee27$(_context29) {
5662
5538
  while (1) switch (_context29.prev = _context29.next) {
5663
5539
  case 0:
@@ -5695,17 +5571,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5695
5571
  throw new Error('[Order] 目标商品不存在,无法更新数量');
5696
5572
  case 13:
5697
5573
  targetProduct = tempOrder.products[productIndex];
5698
- isPersistedOrderLine = targetProduct.order_detail_id !== undefined && targetProduct.order_detail_id !== null;
5699
5574
  normalizedProduct = this.normalizeVirtualSettlementProductIfEnabled(normalizeOrderProduct(_objectSpread(_objectSpread({}, targetProduct), {}, {
5700
5575
  num: getSafeProductNum(num),
5701
5576
  metadata: _objectSpread(_objectSpread({}, targetProduct.metadata || {}), {}, {
5702
5577
  unique_identification_number: ((_targetProduct$metada17 = targetProduct.metadata) === null || _targetProduct$metada17 === void 0 ? void 0 : _targetProduct$metada17.unique_identification_number) || unique_identification_number
5703
5578
  })
5704
5579
  })));
5705
- normalizedProduct.discount_list = normalizeOrderProductDiscountList(isPersistedOrderLine ? syncReducedEntitlementPassUsageCount(normalizedProduct.discount_list, targetProduct.num, normalizedProduct.num) : normalizedProduct.discount_list);
5580
+ normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
5706
5581
  settlementSnapshot = getSelectedSettlementSnapshot(normalizedProduct);
5707
5582
  if (!(this.isMultiCurrencySettlementEnabled() && (settlementSnapshot === null || settlementSnapshot === void 0 ? void 0 : settlementSnapshot.settlement_type) === 'virtual_currency' && tempOrder.customer_id && Number(tempOrder.customer_id) !== 1)) {
5708
- _context29.next = 27;
5583
+ _context29.next = 26;
5709
5584
  break;
5710
5585
  }
5711
5586
  currencyProductId = Number(settlementSnapshot.currency_product_id);
@@ -5713,11 +5588,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5713
5588
  return Number(item === null || item === void 0 ? void 0 : item.product_id) === currencyProductId;
5714
5589
  });
5715
5590
  if (asset) {
5716
- _context29.next = 23;
5591
+ _context29.next = 22;
5717
5592
  break;
5718
5593
  }
5719
5594
  throw new VirtualCurrencyAssetNotFoundError(currencyProductId);
5720
- case 23:
5595
+ case 22:
5721
5596
  requiredAmount = tempOrder.products.reduce(function (sum, item, index) {
5722
5597
  var current = index === productIndex ? normalizedProduct : item;
5723
5598
  var currentSnapshot = getSelectedSettlementSnapshot(current);
@@ -5725,44 +5600,44 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5725
5600
  }, new Decimal(0));
5726
5601
  balance = new Decimal(asset.balance || 0);
5727
5602
  if (!balance.lt(requiredAmount)) {
5728
- _context29.next = 27;
5603
+ _context29.next = 26;
5729
5604
  break;
5730
5605
  }
5731
5606
  throw new VirtualCurrencyBalanceError(balance.toFixed(2), requiredAmount.toFixed(2));
5732
- case 27:
5607
+ case 26:
5733
5608
  tempOrder.products[productIndex] = normalizedProduct;
5734
5609
  this.prepareVirtualSettlementTempOrder(tempOrder);
5735
5610
  isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder);
5736
5611
  if (isVirtualSettlement) {
5737
- _context29.next = 36;
5612
+ _context29.next = 35;
5738
5613
  break;
5739
5614
  }
5740
- _context29.next = 33;
5615
+ _context29.next = 32;
5741
5616
  return this.evaluatePromotion();
5742
- case 33:
5617
+ case 32:
5743
5618
  _context29.t0 = _context29.sent;
5744
- _context29.next = 37;
5619
+ _context29.next = 36;
5745
5620
  break;
5746
- case 36:
5621
+ case 35:
5747
5622
  _context29.t0 = null;
5748
- case 37:
5623
+ case 36:
5749
5624
  promotionPayload = _context29.t0;
5750
5625
  if (!isVirtualSettlement) {
5751
5626
  this.applyDiscount();
5752
5627
  }
5753
5628
  this.sanitizeTempOrderProducts(tempOrder);
5754
- _context29.next = 42;
5629
+ _context29.next = 41;
5755
5630
  return this.recalculateSummary({
5756
5631
  createIfMissing: true
5757
5632
  });
5758
- case 42:
5633
+ case 41:
5759
5634
  this.persistTempOrder();
5760
5635
  this.emitPromotionApplied(promotionPayload);
5761
5636
  this.logInfo('updateOrderProductQuantity success', {
5762
5637
  params: params
5763
5638
  });
5764
5639
  return _context29.abrupt("return", tempOrder.products);
5765
- case 46:
5640
+ case 45:
5766
5641
  case "end":
5767
5642
  return _context29.stop();
5768
5643
  }
@@ -5852,7 +5727,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5852
5727
  key: "removeProductsFromOrder",
5853
5728
  value: (function () {
5854
5729
  var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(identities, options) {
5855
- var _this36 = this;
5730
+ var _this35 = this;
5856
5731
  var tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
5857
5732
  return _regeneratorRuntime().wrap(function _callee29$(_context32) {
5858
5733
  while (1) switch (_context32.prev = _context32.next) {
@@ -5917,7 +5792,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5917
5792
  }
5918
5793
  if (productUid !== undefined && productUid !== null && productUid !== '') {
5919
5794
  bookingsBeforeRemove.forEach(function (booking) {
5920
- var bookingUid = _this36.getBookingUniqueIdentificationNumber(booking);
5795
+ var bookingUid = _this35.getBookingUniqueIdentificationNumber(booking);
5921
5796
  if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
5922
5797
  linkedBookingUidsToRemove.add(bookingUid);
5923
5798
  }
@@ -6132,23 +6007,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6132
6007
  }, {
6133
6008
  key: "buildCurrentSubmitPayloadForLocalPrint",
6134
6009
  value: function buildCurrentSubmitPayloadForLocalPrint(params) {
6135
- var _params$cacheId, _this$otherParams5, _ref83, _params$businessCode, _this$otherParams6, _this$otherParams7;
6010
+ var _params$cacheId, _this$otherParams5, _ref80, _params$businessCode, _this$otherParams6, _this$otherParams7;
6136
6011
  var tempOrder = this.ensureTempOrder();
6137
6012
  this.persistTempOrder();
6138
6013
  var payload = buildSubmitPayload({
6139
6014
  tempOrder: tempOrder,
6140
6015
  cacheId: (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId,
6141
6016
  platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.platform),
6142
- businessCode: (_ref83 = (_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 && _ref83 !== void 0 ? _ref83 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.business_code,
6017
+ businessCode: (_ref80 = (_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 && _ref80 !== void 0 ? _ref80 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.business_code,
6143
6018
  channel: params === null || params === void 0 ? void 0 : params.channel,
6144
6019
  type: params === null || params === void 0 ? void 0 : params.type,
6145
6020
  summary: this.store.summary || createEmptySummary(),
6146
6021
  enhance: function enhance(nextPayload) {
6147
- var _ref84, _tempOrder$order_numb, _ref85, _tempOrder$shop_order2, _ref86, _tempOrder$shop_full_;
6022
+ var _ref81, _tempOrder$order_numb, _ref82, _tempOrder$shop_order2, _ref83, _tempOrder$shop_full_;
6148
6023
  return _objectSpread(_objectSpread({}, nextPayload), {}, {
6149
- order_number: (_ref84 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref84 !== void 0 ? _ref84 : null,
6150
- shop_order_number: (_ref85 = (_tempOrder$shop_order2 = tempOrder.shop_order_number) !== null && _tempOrder$shop_order2 !== void 0 ? _tempOrder$shop_order2 : nextPayload.shop_order_number) !== null && _ref85 !== void 0 ? _ref85 : null,
6151
- shop_full_order_number: (_ref86 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref86 !== void 0 ? _ref86 : null,
6024
+ order_number: (_ref81 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref81 !== void 0 ? _ref81 : null,
6025
+ shop_order_number: (_ref82 = (_tempOrder$shop_order2 = tempOrder.shop_order_number) !== null && _tempOrder$shop_order2 !== void 0 ? _tempOrder$shop_order2 : nextPayload.shop_order_number) !== null && _ref82 !== void 0 ? _ref82 : null,
6026
+ shop_full_order_number: (_ref83 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref83 !== void 0 ? _ref83 : null,
6152
6027
  small_ticket_data_flag: 1
6153
6028
  });
6154
6029
  }
@@ -6312,7 +6187,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6312
6187
  key: "runSubmitTempOrder",
6313
6188
  value: function () {
6314
6189
  var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
6315
- var _params$cacheId3, _this$otherParams12, _ref87, _ref88, _submitSnapshot$busin, _this$otherParams13, _this$otherParams14, _submitSnapshot$type;
6190
+ var _params$cacheId3, _this$otherParams12, _ref84, _ref85, _submitSnapshot$busin, _this$otherParams13, _this$otherParams14, _submitSnapshot$type;
6316
6191
  var tempOrder, isOnlineStorePlatform, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, shouldOverridePaymentStatus, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, isLocalPendingSubmit, salesNotesState, submittedOrderId, resultRecord;
6317
6192
  return _regeneratorRuntime().wrap(function _callee37$(_context40) {
6318
6193
  while (1) switch (_context40.prev = _context40.next) {
@@ -6379,7 +6254,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6379
6254
  tempOrder: tempOrder,
6380
6255
  cacheId: effectiveCacheId,
6381
6256
  platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.platform),
6382
- businessCode: (_ref87 = (_ref88 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref88 !== void 0 ? _ref88 : (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.businessCode) !== null && _ref87 !== void 0 ? _ref87 : (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.business_code,
6257
+ businessCode: (_ref84 = (_ref85 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref85 !== void 0 ? _ref85 : (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.businessCode) !== null && _ref84 !== void 0 ? _ref84 : (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.business_code,
6383
6258
  channel: params === null || params === void 0 ? void 0 : params.channel,
6384
6259
  type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
6385
6260
  summary: latestSummary,
@@ -6549,10 +6424,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6549
6424
  value: function extractSubmitErrorResponse(error) {
6550
6425
  var _error$response,
6551
6426
  _error$response2,
6552
- _this37 = this;
6427
+ _this36 = this;
6553
6428
  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];
6554
6429
  return candidates.find(function (candidate) {
6555
- return _this37.isSubmitErrorResponse(candidate);
6430
+ return _this36.isSubmitErrorResponse(candidate);
6556
6431
  }) || null;
6557
6432
  }
6558
6433
  }, {
@@ -6580,7 +6455,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6580
6455
  key: "syncPaymentsToOrder",
6581
6456
  value: function () {
6582
6457
  var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
6583
- var _this38 = this,
6458
+ var _this37 = this,
6584
6459
  _params$confirmPendin;
6585
6460
  var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, enhancePayload, submitParams, submitResult;
6586
6461
  return _regeneratorRuntime().wrap(function _callee39$(_context42) {
@@ -6605,7 +6480,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6605
6480
  case 9:
6606
6481
  devicePrefix = _context42.t0;
6607
6482
  mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
6608
- return _this38.normalizePaymentSource(payment, {
6483
+ return _this37.normalizePaymentSource(payment, {
6609
6484
  defaultPaid: false,
6610
6485
  devicePrefix: devicePrefix
6611
6486
  });
@@ -6684,7 +6559,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6684
6559
  }, {
6685
6560
  key: "createOrder",
6686
6561
  value: function createOrder(params) {
6687
- var _this39 = this;
6562
+ var _this38 = this;
6688
6563
  var order = _objectSpread({
6689
6564
  type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
6690
6565
  // 要从外面拿,virtual
@@ -6716,7 +6591,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6716
6591
 
6717
6592
  // 为预约补齐 holder 信息
6718
6593
  if (params !== null && params !== void 0 && (_params$extraData = params.extraData) !== null && _params$extraData !== void 0 && _params$extraData.is_add_holder_info) {
6719
- ensureCartItemOriginHolder(item, _this39.window);
6594
+ ensureCartItemOriginHolder(item, _this38.window);
6720
6595
  }
6721
6596
 
6722
6597
  // 购物车是否为普通商品
@@ -7358,10 +7233,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7358
7233
  _step22;
7359
7234
  try {
7360
7235
  for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
7361
- var _product$metadata13;
7236
+ var _product$metadata11;
7362
7237
  var product = _step22.value;
7363
7238
  var productUid = getOrderCollectionUid('product', product);
7364
- 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);
7239
+ 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);
7365
7240
  if (!productUid || bookingUid === undefined || bookingUid === null || bookingUid === '') {
7366
7241
  continue;
7367
7242
  }
@@ -7419,7 +7294,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7419
7294
  }, {
7420
7295
  key: "normalizeTempOrderForRuntime",
7421
7296
  value: function normalizeTempOrderForRuntime(raw, options) {
7422
- var _this40 = this,
7297
+ var _this39 = this,
7423
7298
  _raw$_extend;
7424
7299
  var runtimeRaw = this.withoutSyntheticDraftOrderIdForRuntime(raw);
7425
7300
  var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
@@ -7444,12 +7319,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7444
7319
  nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
7445
7320
  var rawProducts = Array.isArray(raw.products) ? raw.products : [];
7446
7321
  nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
7447
- return _this40.normalizeHydratedOrderProduct(p, {
7322
+ return _this39.normalizeHydratedOrderProduct(p, {
7448
7323
  makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
7449
7324
  });
7450
7325
  }) : [];
7451
7326
  nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
7452
- var booking = _this40.normalizeHydratedBookingHolder(b || {});
7327
+ var booking = _this39.normalizeHydratedBookingHolder(b || {});
7453
7328
  return _objectSpread(_objectSpread({}, booking), {}, {
7454
7329
  is_all: normalizeBookingIsAll(booking),
7455
7330
  sub_type: normalizeBookingSubType(booking)
@@ -7499,15 +7374,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7499
7374
  _step24;
7500
7375
  try {
7501
7376
  for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
7502
- var _product$metadata14, _ref89, _ref90, _existed$origin, _rawProduct$metadata;
7377
+ var _product$metadata12, _ref86, _ref87, _existed$origin, _rawProduct$metadata;
7503
7378
  var _step24$value = _slicedToArray(_step24.value, 2),
7504
7379
  index = _step24$value[0],
7505
7380
  product = _step24$value[1];
7506
- var uid = (_product$metadata14 = product.metadata) === null || _product$metadata14 === void 0 ? void 0 : _product$metadata14.unique_identification_number;
7381
+ var uid = (_product$metadata12 = product.metadata) === null || _product$metadata12 === void 0 ? void 0 : _product$metadata12.unique_identification_number;
7507
7382
  if (!uid) continue;
7508
7383
  var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
7509
7384
  var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
7510
- var origin = (_ref89 = (_ref90 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref90 !== void 0 ? _ref90 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref89 !== void 0 ? _ref89 : rawProduct;
7385
+ var origin = (_ref86 = (_ref87 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref87 !== void 0 ? _ref87 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref86 !== void 0 ? _ref86 : rawProduct;
7511
7386
  var originSnapshot = cloneDeep(origin);
7512
7387
  var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
7513
7388
  if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
@@ -7558,8 +7433,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7558
7433
  var bookingUidByProductUid = new Map();
7559
7434
  var productByUid = new Map();
7560
7435
  (tempOrder.products || []).forEach(function (product) {
7561
- var _product$metadata15;
7562
- 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);
7436
+ var _product$metadata13;
7437
+ 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);
7563
7438
  if (productUid !== undefined && productUid !== null && String(productUid) !== '') {
7564
7439
  productByUid.set(String(productUid), product);
7565
7440
  }
@@ -7580,8 +7455,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7580
7455
  bookingUidByProductUid.set(String(productUid), bookingUid);
7581
7456
  });
7582
7457
  (tempOrder.products || []).forEach(function (product) {
7583
- var _product$metadata16;
7584
- 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);
7458
+ var _product$metadata14;
7459
+ 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);
7585
7460
  if (productUid === undefined || productUid === null || String(productUid) === '') return;
7586
7461
  var bookingUid = bookingUidByProductUid.get(String(productUid));
7587
7462
  if (!bookingUid) return;
@@ -7636,10 +7511,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7636
7511
  }, {
7637
7512
  key: "normalizeHydratedProductOptionItem",
7638
7513
  value: function normalizeHydratedProductOptionItem(optionItem) {
7639
- var _ref91, _optionItem$num, _ref92, _optionItem$add_price;
7640
- var rawNum = (_ref91 = (_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 && _ref91 !== void 0 ? _ref91 : 1;
7514
+ var _ref88, _optionItem$num, _ref89, _optionItem$add_price;
7515
+ var rawNum = (_ref88 = (_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 && _ref88 !== void 0 ? _ref88 : 1;
7641
7516
  var parsedNum = Number(rawNum);
7642
- var rawPrice = (_ref92 = (_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 && _ref92 !== void 0 ? _ref92 : 0;
7517
+ var rawPrice = (_ref89 = (_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 && _ref89 !== void 0 ? _ref89 : 0;
7643
7518
  var parsedPrice = Number(rawPrice);
7644
7519
  var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
7645
7520
  option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
@@ -7656,7 +7531,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7656
7531
  }, {
7657
7532
  key: "normalizeHydratedOrderProduct",
7658
7533
  value: function normalizeHydratedOrderProduct(product, options) {
7659
- var _this41 = this;
7534
+ var _this40 = this;
7660
7535
  var row = _objectSpread({}, product || {});
7661
7536
  if (row.num === undefined && row.product_quantity !== undefined) {
7662
7537
  row.num = row.product_quantity;
@@ -7664,7 +7539,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7664
7539
  var productSku = ensureProductSku(row);
7665
7540
  row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
7666
7541
  option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
7667
- return _this41.normalizeHydratedProductOptionItem(optionItem || {});
7542
+ return _this40.normalizeHydratedProductOptionItem(optionItem || {});
7668
7543
  }))
7669
7544
  });
7670
7545
  delete row["product_".concat('option', "_item")];
@@ -7752,8 +7627,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7752
7627
  }, {
7753
7628
  key: "getVouchers",
7754
7629
  value: function getVouchers() {
7755
- var _this$store$tempOrder6;
7756
- return ((_this$store$tempOrder6 = this.store.tempOrder) === null || _this$store$tempOrder6 === void 0 ? void 0 : _this$store$tempOrder6.vouchers) || [];
7630
+ var _this$store$tempOrder8;
7631
+ return ((_this$store$tempOrder8 = this.store.tempOrder) === null || _this$store$tempOrder8 === void 0 ? void 0 : _this$store$tempOrder8.vouchers) || [];
7757
7632
  }
7758
7633
  }], [{
7759
7634
  key: "populateSavedAmounts",
@@ -7772,11 +7647,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7772
7647
  targetMap.set(discountKey, (targetMap.get(discountKey) || new Decimal(0)).plus(amount));
7773
7648
  };
7774
7649
  var addProductDiscountAmount = function addProductDiscountAmount(discount, quantity, isPersistedProduct) {
7775
- var _discount$discount3, _discount$metadata2;
7650
+ var _discount$discount3, _discount$metadata;
7776
7651
  var discountKey = ((_discount$discount3 = discount.discount) === null || _discount$discount3 === void 0 ? void 0 : _discount$discount3.resource_id) || discount.id;
7777
7652
  if (discountKey == null) return;
7778
7653
  var qty = Number(quantity) || 1;
7779
- 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);
7654
+ 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);
7780
7655
  addDiscountAmount(savedMap, discountKey, amount);
7781
7656
  addDiscountAmount(isPersistedProduct || discount.order_discount_id != null ? editModeSavedMap : runtimeSavedMap, discountKey, amount);
7782
7657
  };