@pisell/pisellos 0.10.41 → 0.10.43
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.
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +58 -19
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +24 -12
- package/dist/modules/Discount/entitlementPass.d.ts +34 -0
- package/dist/modules/Discount/entitlementPass.js +147 -0
- package/dist/modules/Discount/index.d.ts +2 -0
- package/dist/modules/Discount/index.js +39 -13
- package/dist/modules/Discount/types.d.ts +26 -5
- package/dist/modules/Order/index.d.ts +5 -0
- package/dist/modules/Order/index.js +283 -118
- package/dist/modules/Order/utils/orderCollectionIdentity.js +16 -12
- package/dist/modules/Order/utils.js +17 -1
- package/dist/modules/ResourcePlanner/planner.d.ts +2 -2
- package/dist/modules/ResourcePlanner/planner.js +163 -46
- package/dist/modules/ResourcePlanner/types.d.ts +17 -0
- package/dist/modules/Rules/index.js +312 -135
- package/dist/solution/BaseSales/index.d.ts +2 -0
- package/dist/solution/BaseSales/index.js +9 -1
- package/dist/solution/BaseSales/utils/cartPromotion.js +141 -126
- package/dist/solution/BookingTicket/types.d.ts +5 -1
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +171 -96
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +3 -1
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +2 -0
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +12 -3
- package/dist/solution/ShopDiscount/index.d.ts +1 -0
- package/dist/solution/ShopDiscount/index.js +41 -21
- package/dist/solution/ShopDiscount/utils.js +3 -2
- package/dist/solution/UnifiedBookingSales/index.js +94 -21
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +35 -6
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +13 -6
- package/lib/modules/Discount/entitlementPass.d.ts +34 -0
- package/lib/modules/Discount/entitlementPass.js +141 -0
- package/lib/modules/Discount/index.d.ts +2 -0
- package/lib/modules/Discount/index.js +25 -9
- package/lib/modules/Discount/types.d.ts +26 -5
- package/lib/modules/Order/index.d.ts +5 -0
- package/lib/modules/Order/index.js +172 -28
- package/lib/modules/Order/utils/orderCollectionIdentity.js +14 -11
- package/lib/modules/Order/utils.js +19 -1
- package/lib/modules/ResourcePlanner/planner.d.ts +2 -2
- package/lib/modules/ResourcePlanner/planner.js +137 -35
- package/lib/modules/ResourcePlanner/types.d.ts +17 -0
- package/lib/modules/Rules/index.js +232 -97
- package/lib/solution/BaseSales/index.d.ts +2 -0
- package/lib/solution/BaseSales/index.js +7 -1
- package/lib/solution/BaseSales/utils/cartPromotion.js +12 -4
- package/lib/solution/BookingTicket/types.d.ts +5 -1
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +65 -18
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +3 -1
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +2 -0
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +5 -1
- package/lib/solution/ShopDiscount/index.d.ts +1 -0
- package/lib/solution/ShopDiscount/index.js +26 -6
- package/lib/solution/ShopDiscount/utils.js +3 -2
- package/lib/solution/UnifiedBookingSales/index.js +86 -22
- package/package.json +1 -1
|
@@ -6,13 +6,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
6
6
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
7
7
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
8
8
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
9
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
10
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
11
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
12
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
13
9
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
14
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
15
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
16
10
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
17
11
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
18
12
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
@@ -25,6 +19,12 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
|
|
|
25
19
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
26
20
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
27
21
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
22
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
23
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
24
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
25
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
26
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
27
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
28
28
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
29
29
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
30
30
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -47,6 +47,7 @@ import { consolidateDiscountFreeProductLines, ensureUniqueProductLineUids } from
|
|
|
47
47
|
import { applyTempOrderSettlementState, getSelectedSettlementSnapshot, getSettlementKey, getTempOrderSettlementKey, getTempOrderSettlementSnapshot, isVirtualSettlementOrder, normalizeVirtualSettlementOrderProduct, normalizeVirtualSettlementProducts, OrderSettlementConflictError, releaseTempOrderSettlementState, VirtualCurrencyAssetNotFoundError, VirtualCurrencyBalanceError } from "./utils/virtualSettlement";
|
|
48
48
|
import { DiscountModule } from "../Discount";
|
|
49
49
|
import { RulesModule } from "../Rules";
|
|
50
|
+
import { isEntitlementPass, isFullCoveragePass } from "../Discount/entitlementPass";
|
|
50
51
|
import { UnavailableReason } from "../Rules/types";
|
|
51
52
|
import Decimal from 'decimal.js';
|
|
52
53
|
import { cloneDeep } from 'lodash-es';
|
|
@@ -70,9 +71,26 @@ function isManualProductDiscountProduct(product) {
|
|
|
70
71
|
return (item === null || item === void 0 ? void 0 : item.type) === 'product';
|
|
71
72
|
});
|
|
72
73
|
}
|
|
74
|
+
function syncReducedEntitlementPassUsageCount(discountList, previousQuantity, nextQuantity) {
|
|
75
|
+
if (!Array.isArray(discountList)) return discountList;
|
|
76
|
+
var previousCount = getSafeProductNum(previousQuantity);
|
|
77
|
+
var nextCount = getSafeProductNum(nextQuantity);
|
|
78
|
+
if (nextCount >= previousCount) return discountList;
|
|
79
|
+
return discountList.map(function (discount) {
|
|
80
|
+
var _discount$metadata$nu, _discount$metadata;
|
|
81
|
+
if (!isEntitlementPass(discount)) return discount;
|
|
82
|
+
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);
|
|
83
|
+
var usageCount = Number.isFinite(rawUsageCount) ? Math.max(Math.floor(rawUsageCount), 0) : previousCount;
|
|
84
|
+
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
85
|
+
metadata: _objectSpread(_objectSpread({}, (discount === null || discount === void 0 ? void 0 : discount.metadata) || {}), {}, {
|
|
86
|
+
num: Math.min(usageCount, nextCount)
|
|
87
|
+
})
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
}
|
|
73
91
|
var ORDER_PAYMENT_STATUS_PAID = 'paid';
|
|
74
92
|
var ORDER_PAYMENT_STATUS_PENDING = 'payment_pending';
|
|
75
|
-
var CUSTOMER_PROMOTION_DISCOUNT_TAGS = new Set(['good_pass', 'product_discount_card', 'discount_card']);
|
|
93
|
+
var CUSTOMER_PROMOTION_DISCOUNT_TAGS = new Set(['entitlement_pass', 'good_pass', 'product_discount_card', 'discount_card']);
|
|
76
94
|
function isCustomerPromotionDiscount(discount) {
|
|
77
95
|
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());
|
|
78
96
|
}
|
|
@@ -107,6 +125,27 @@ function getVoucherPaymentLifecycleKey(payment) {
|
|
|
107
125
|
if (!isVoucherPaymentRecord(payment)) return null;
|
|
108
126
|
return "".concat(String(payment.voucher_id), "::").concat(String(payment.status || ''));
|
|
109
127
|
}
|
|
128
|
+
function getDiscountIdentityKey(discount) {
|
|
129
|
+
var id = discount === null || discount === void 0 ? void 0 : discount.id;
|
|
130
|
+
if (id === undefined || id === null || id === '') return null;
|
|
131
|
+
return String(id);
|
|
132
|
+
}
|
|
133
|
+
function mergeCommittedEntitlementWithRuntime(committed, runtime) {
|
|
134
|
+
var _committed$committedA, _runtime$id, _runtime$isDisabled, _runtime$isSelected;
|
|
135
|
+
var committedAppliedProductDetails = (_committed$committedA = committed.committedAppliedProductDetails) !== null && _committed$committedA !== void 0 && _committed$committedA.length ? committed.committedAppliedProductDetails : committed.appliedProductDetails || [];
|
|
136
|
+
return _objectSpread(_objectSpread(_objectSpread({}, committed), runtime), {}, {
|
|
137
|
+
id: (_runtime$id = runtime.id) !== null && _runtime$id !== void 0 ? _runtime$id : committed.id,
|
|
138
|
+
tag: runtime.tag || committed.tag,
|
|
139
|
+
type: runtime.type || committed.type,
|
|
140
|
+
isEditMode: false,
|
|
141
|
+
isDisabled: (_runtime$isDisabled = runtime.isDisabled) !== null && _runtime$isDisabled !== void 0 ? _runtime$isDisabled : false,
|
|
142
|
+
isSelected: (_runtime$isSelected = runtime.isSelected) !== null && _runtime$isSelected !== void 0 ? _runtime$isSelected : committed.isSelected,
|
|
143
|
+
isUsed: committed.isUsed || runtime.isUsed,
|
|
144
|
+
committedAppliedProductDetails: _toConsumableArray(committedAppliedProductDetails),
|
|
145
|
+
applicableProductDetails: [].concat(_toConsumableArray(committed.applicableProductDetails || []), _toConsumableArray(runtime.applicableProductDetails || [])),
|
|
146
|
+
appliedProductDetails: [].concat(_toConsumableArray(committedAppliedProductDetails), _toConsumableArray(runtime.appliedProductDetails || []))
|
|
147
|
+
});
|
|
148
|
+
}
|
|
110
149
|
export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
111
150
|
_inherits(OrderModule, _BaseModule);
|
|
112
151
|
var _super = _createSuper(OrderModule);
|
|
@@ -165,7 +204,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
165
204
|
_step2;
|
|
166
205
|
try {
|
|
167
206
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
168
|
-
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$
|
|
207
|
+
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, _item$discount$produc, _item$discount7, _ref6, _ref7, _item$metadata$num2, _item$metadata2, _ref8, _item$discount$discou, _item$discount8, _item$amount2, _item$amount3, _product$product_id, _product$is_charge_ta, _ref9, _product$original_pri, _ref10, _item$discount$discou2, _item$discount9, _item$discount$discou3, _item$discount10;
|
|
169
208
|
var item = _step2.value;
|
|
170
209
|
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;
|
|
171
210
|
if (!type || type === 'product') continue;
|
|
@@ -186,7 +225,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
186
225
|
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'),
|
|
187
226
|
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,
|
|
188
227
|
metadata: item === null || item === void 0 ? void 0 : item.metadata,
|
|
189
|
-
discount: item === null || item === void 0 ? void 0 : item.discount,
|
|
228
|
+
discount: _objectSpread(_objectSpread({}, (item === null || item === void 0 ? void 0 : item.discount) || {}), {}, {
|
|
229
|
+
product_id: (_item$discount$produc = item === null || item === void 0 || (_item$discount7 = item.discount) === null || _item$discount7 === void 0 ? void 0 : _item$discount7.product_id) !== null && _item$discount$produc !== void 0 ? _item$discount$produc : product === null || product === void 0 ? void 0 : product.product_id
|
|
230
|
+
}),
|
|
190
231
|
_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
|
|
191
232
|
};
|
|
192
233
|
var existed = discountMap.get(key);
|
|
@@ -213,7 +254,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
213
254
|
encoded: '',
|
|
214
255
|
code: '',
|
|
215
256
|
tag: type,
|
|
216
|
-
product_id: (_ref8 = (_item$discount$discou = item === null || item === void 0 || (_item$
|
|
257
|
+
product_id: (_ref8 = (_item$discount$discou = item === null || item === void 0 || (_item$discount8 = item.discount) === null || _item$discount8 === void 0 ? void 0 : _item$discount8.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,
|
|
217
258
|
relation_type: '',
|
|
218
259
|
par_value: String(parValue !== null && parValue !== void 0 ? parValue : '0'),
|
|
219
260
|
used_par_value: String((_item$amount2 = item === null || item === void 0 ? void 0 : item.amount) !== null && _item$amount2 !== void 0 ? _item$amount2 : '0'),
|
|
@@ -246,8 +287,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
246
287
|
amount: amount,
|
|
247
288
|
discount: _objectSpread(_objectSpread({}, (item === null || item === void 0 ? void 0 : item.discount) || {}), {}, {
|
|
248
289
|
resource_id: key,
|
|
249
|
-
discount_product_id: (_ref10 = (_item$discount$discou2 = item === null || item === void 0 || (_item$
|
|
250
|
-
discount_calculation_mode: (_item$discount$discou3 = item === null || item === void 0 || (_item$
|
|
290
|
+
discount_product_id: (_ref10 = (_item$discount$discou2 = item === null || item === void 0 || (_item$discount9 = item.discount) === null || _item$discount9 === void 0 ? void 0 : _item$discount9.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,
|
|
291
|
+
discount_calculation_mode: (_item$discount$discou3 = item === null || item === void 0 || (_item$discount10 = item.discount) === null || _item$discount10 === void 0 ? void 0 : _item$discount10.discount_calculation_mode) !== null && _item$discount$discou3 !== void 0 ? _item$discount$discou3 : 'item_level'
|
|
251
292
|
}),
|
|
252
293
|
applicableProductDetails: [detail],
|
|
253
294
|
appliedProductDetails: [detail]
|
|
@@ -560,7 +601,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
560
601
|
value: function () {
|
|
561
602
|
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
562
603
|
var _this$store$tempOrder, _this$store$discount, _this$store$tempOrder2;
|
|
563
|
-
var orderId, prepareConfigResult, discountList, _this$store$discount2, _this$store$discount3, _this$store$discount4, currentDiscountList,
|
|
604
|
+
var orderId, prepareConfigResult, discountList, _this$store$discount2, _this$store$discount3, _this$store$discount4, currentDiscountList, currentCommittedDiscounts, currentScanDiscounts, currentScanDiscountById, committedDiscountById, mergedCommittedDiscountIds, refreshedScanDiscountIds, runtimeDiscountIds, runtimeDiscounts, retainedCommittedDiscounts, retainedScanDiscounts, mergedDiscountList;
|
|
564
605
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
565
606
|
while (1) switch (_context3.prev = _context3.next) {
|
|
566
607
|
case 0:
|
|
@@ -575,6 +616,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
575
616
|
with_available_wallet_flag: 1,
|
|
576
617
|
with_available_wallet_pass_flag: 1,
|
|
577
618
|
with_virtual_currency: 1,
|
|
619
|
+
with_entitlement_pass: 1,
|
|
578
620
|
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
579
621
|
}, orderId ? {
|
|
580
622
|
order_id: orderId
|
|
@@ -591,38 +633,83 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
591
633
|
});
|
|
592
634
|
}
|
|
593
635
|
if (!discountList) {
|
|
594
|
-
_context3.next =
|
|
636
|
+
_context3.next = 25;
|
|
595
637
|
break;
|
|
596
638
|
}
|
|
597
639
|
currentDiscountList = ((_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 ? void 0 : _this$store$discount2.getDiscountList()) || [];
|
|
598
|
-
|
|
599
|
-
|
|
640
|
+
currentCommittedDiscounts = currentDiscountList.filter(function (discount) {
|
|
641
|
+
var _discount$committedAp;
|
|
642
|
+
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);
|
|
600
643
|
});
|
|
601
644
|
currentScanDiscounts = currentDiscountList.filter(function (discount) {
|
|
602
645
|
return discount === null || discount === void 0 ? void 0 : discount.isScan;
|
|
603
646
|
});
|
|
604
|
-
|
|
605
|
-
|
|
647
|
+
currentScanDiscountById = new Map(currentScanDiscounts.flatMap(function (discount) {
|
|
648
|
+
var id = getDiscountIdentityKey(discount);
|
|
649
|
+
return id === null ? [] : [[id, discount]];
|
|
606
650
|
}));
|
|
651
|
+
committedDiscountById = new Map(currentCommittedDiscounts.flatMap(function (discount) {
|
|
652
|
+
var id = getDiscountIdentityKey(discount);
|
|
653
|
+
return id === null ? [] : [[id, discount]];
|
|
654
|
+
}));
|
|
655
|
+
mergedCommittedDiscountIds = new Set();
|
|
656
|
+
refreshedScanDiscountIds = new Set();
|
|
607
657
|
runtimeDiscountIds = new Set();
|
|
608
|
-
runtimeDiscounts = discountList.
|
|
609
|
-
|
|
610
|
-
if (
|
|
611
|
-
runtimeDiscountIds.
|
|
612
|
-
|
|
658
|
+
runtimeDiscounts = discountList.flatMap(function (discount) {
|
|
659
|
+
var id = getDiscountIdentityKey(discount);
|
|
660
|
+
if (id === null) return [discount];
|
|
661
|
+
if (runtimeDiscountIds.has(id)) return [];
|
|
662
|
+
runtimeDiscountIds.add(id);
|
|
663
|
+
var currentScanDiscount = currentScanDiscountById.get(id);
|
|
664
|
+
if (currentScanDiscount && (!isEntitlementPass(currentScanDiscount) || !isEntitlementPass(discount))) {
|
|
665
|
+
return [];
|
|
666
|
+
}
|
|
667
|
+
var committedDiscount = committedDiscountById.get(id);
|
|
668
|
+
var nextDiscount = discount;
|
|
669
|
+
if (committedDiscount && isEntitlementPass(committedDiscount) && isEntitlementPass(discount)) {
|
|
670
|
+
mergedCommittedDiscountIds.add(id);
|
|
671
|
+
nextDiscount = mergeCommittedEntitlementWithRuntime(committedDiscount, discount);
|
|
672
|
+
}
|
|
673
|
+
if (currentScanDiscount) {
|
|
674
|
+
var _currentScanDiscount$, _currentScanDiscount$2;
|
|
675
|
+
refreshedScanDiscountIds.add(id);
|
|
676
|
+
nextDiscount = _objectSpread(_objectSpread({}, nextDiscount), {}, {
|
|
677
|
+
isScan: true,
|
|
678
|
+
isSelected: (_currentScanDiscount$ = currentScanDiscount.isSelected) !== null && _currentScanDiscount$ !== void 0 ? _currentScanDiscount$ : nextDiscount.isSelected,
|
|
679
|
+
isManualSelect: (_currentScanDiscount$2 = currentScanDiscount.isManualSelect) !== null && _currentScanDiscount$2 !== void 0 ? _currentScanDiscount$2 : nextDiscount.isManualSelect
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
return [nextDiscount];
|
|
683
|
+
});
|
|
684
|
+
retainedCommittedDiscounts = currentCommittedDiscounts.filter(function (discount) {
|
|
685
|
+
var id = getDiscountIdentityKey(discount);
|
|
686
|
+
return id === null || !mergedCommittedDiscountIds.has(id);
|
|
687
|
+
}).map(function (discount) {
|
|
688
|
+
var _discount$committedAp2;
|
|
689
|
+
return (_discount$committedAp2 = discount.committedAppliedProductDetails) !== null && _discount$committedAp2 !== void 0 && _discount$committedAp2.length ? _objectSpread(_objectSpread({}, discount), {}, {
|
|
690
|
+
isEditMode: true,
|
|
691
|
+
isDisabled: true,
|
|
692
|
+
isSelected: true,
|
|
693
|
+
isUsed: true,
|
|
694
|
+
appliedProductDetails: _toConsumableArray(discount.committedAppliedProductDetails)
|
|
695
|
+
}) : discount;
|
|
696
|
+
});
|
|
697
|
+
retainedScanDiscounts = currentScanDiscounts.filter(function (discount) {
|
|
698
|
+
var id = getDiscountIdentityKey(discount);
|
|
699
|
+
return id === null || !refreshedScanDiscountIds.has(id);
|
|
613
700
|
});
|
|
614
|
-
mergedDiscountList = [].concat(_toConsumableArray(
|
|
615
|
-
_context3.next =
|
|
701
|
+
mergedDiscountList = [].concat(_toConsumableArray(retainedCommittedDiscounts), _toConsumableArray(retainedScanDiscounts), _toConsumableArray(runtimeDiscounts));
|
|
702
|
+
_context3.next = 23;
|
|
616
703
|
return (_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.setOriginalDiscountList(mergedDiscountList);
|
|
617
|
-
case
|
|
618
|
-
_context3.next =
|
|
704
|
+
case 23:
|
|
705
|
+
_context3.next = 25;
|
|
619
706
|
return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.setDiscountList(mergedDiscountList);
|
|
620
|
-
case
|
|
707
|
+
case 25:
|
|
621
708
|
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) {
|
|
622
709
|
this.applyDiscount();
|
|
623
710
|
}
|
|
624
711
|
return _context3.abrupt("return", this.getDiscountList());
|
|
625
|
-
case
|
|
712
|
+
case 27:
|
|
626
713
|
case "end":
|
|
627
714
|
return _context3.stop();
|
|
628
715
|
}
|
|
@@ -2168,7 +2255,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2168
2255
|
var _discount$type;
|
|
2169
2256
|
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;
|
|
2170
2257
|
});
|
|
2171
|
-
var
|
|
2258
|
+
var fullCoveragePassType = discountTypes.find(function (type) {
|
|
2259
|
+
return ['entitlement_pass', 'good_pass'].includes(type);
|
|
2260
|
+
});
|
|
2261
|
+
var extensionType = (product === null || product === void 0 ? void 0 : product.extension_type) || fullCoveragePassType || 'normal';
|
|
2172
2262
|
return {
|
|
2173
2263
|
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,
|
|
2174
2264
|
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,
|
|
@@ -2255,7 +2345,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2255
2345
|
var _discount$type3;
|
|
2256
2346
|
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;
|
|
2257
2347
|
});
|
|
2258
|
-
var
|
|
2348
|
+
var fullCoveragePassType = discountTypes.find(function (type) {
|
|
2349
|
+
return ['entitlement_pass', 'good_pass'].includes(type);
|
|
2350
|
+
});
|
|
2351
|
+
var extensionType = (product === null || product === void 0 ? void 0 : product.extension_type) || fullCoveragePassType || 'normal';
|
|
2259
2352
|
return {
|
|
2260
2353
|
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,
|
|
2261
2354
|
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,
|
|
@@ -3384,7 +3477,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3384
3477
|
value: function isCustomerBoundDiscount(discount) {
|
|
3385
3478
|
var _discount$type5;
|
|
3386
3479
|
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;
|
|
3387
|
-
return type === 'good_pass' || type === 'discount_card' || type === 'product_discount_card';
|
|
3480
|
+
return type === 'entitlement_pass' || type === 'good_pass' || type === 'discount_card' || type === 'product_discount_card';
|
|
3388
3481
|
}
|
|
3389
3482
|
}, {
|
|
3390
3483
|
key: "shouldKeepCustomerBoundDiscountAfterCustomerChange",
|
|
@@ -4249,18 +4342,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4249
4342
|
}
|
|
4250
4343
|
normalizedIncoming.discount_list = normalizeOrderProductDiscountList(normalizedIncoming.discount_list);
|
|
4251
4344
|
var hasIncomingGoodPass = this.hasGoodPassDiscount(normalizedIncoming);
|
|
4345
|
+
var hasIncomingEntitlementPass = this.hasEntitlementPassDiscount(normalizedIncoming);
|
|
4346
|
+
var isIncomingEntitlementAppend = this.isRuntimeEntitlementAppend(productToAdd, tempOrder);
|
|
4347
|
+
var isIncomingPersistedEntitlementPass = hasIncomingEntitlementPass && this.isPersistedProductLine(normalizedIncoming);
|
|
4252
4348
|
var hasIncomingProductNote = this.hasOrderProductLineNote(normalizedIncoming);
|
|
4253
4349
|
var hasIncomingManualProductDiscount = isManualProductDiscountProduct(normalizedIncoming);
|
|
4254
4350
|
var hasIncomingBookingUid = this.hasLinkedBookingUid(productToAdd) || this.hasLinkedBookingUid(normalizedIncoming);
|
|
4255
4351
|
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;
|
|
4256
|
-
var shouldForceNewLine = disableMerge || !!booking ||
|
|
4257
|
-
var matchedIndex =
|
|
4258
|
-
var _item$metadata3;
|
|
4352
|
+
var shouldForceNewLine = disableMerge || !!booking || hasIncomingGoodPass || isIncomingPersistedEntitlementPass || hasIncomingBookingUid || isIncomingCustomItem || isWeighingProduct;
|
|
4353
|
+
var matchedIndex = shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
4259
4354
|
if (_this27.hasGoodPassDiscount(item)) return false;
|
|
4260
|
-
|
|
4261
|
-
if (
|
|
4262
|
-
|
|
4263
|
-
|
|
4355
|
+
var isRuntimeEntitlementPass = _this27.isRuntimeEntitlementAppend(item, tempOrder);
|
|
4356
|
+
if (isIncomingEntitlementAppend !== isRuntimeEntitlementPass) {
|
|
4357
|
+
return false;
|
|
4358
|
+
}
|
|
4359
|
+
if (isIncomingEntitlementAppend && _this27.isPersistedProductLine(item)) {
|
|
4360
|
+
return false;
|
|
4361
|
+
}
|
|
4362
|
+
var hasExistingProductNote = _this27.hasOrderProductLineNote(item);
|
|
4363
|
+
if ((hasIncomingProductNote || hasExistingProductNote) && (!isRuntimeEntitlementPass || String(normalizedIncoming.note || '').trim() !== String(item.note || '').trim())) {
|
|
4364
|
+
return false;
|
|
4365
|
+
}
|
|
4366
|
+
var hasExistingManualProductDiscount = isManualProductDiscountProduct(item);
|
|
4367
|
+
if (isRuntimeEntitlementPass && !_this27.hasSameEntitlementMergePriceConfig(normalizedIncoming, item)) {
|
|
4368
|
+
return false;
|
|
4369
|
+
}
|
|
4370
|
+
if ((hasIncomingManualProductDiscount || hasExistingManualProductDiscount) && !isRuntimeEntitlementPass) {
|
|
4371
|
+
return false;
|
|
4372
|
+
}
|
|
4373
|
+
if (_this27.isPersistedProductLine(item)) return false;
|
|
4264
4374
|
if (item.product_id !== productToAdd.product_id) return false;
|
|
4265
4375
|
if (item.product_variant_id !== productToAdd.product_variant_id) return false;
|
|
4266
4376
|
var existedFingerprint = buildProductLineFingerprint(getProductSkuOptions(item), item.product_bundle);
|
|
@@ -4613,45 +4723,99 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4613
4723
|
return addProductsToOrder;
|
|
4614
4724
|
}())
|
|
4615
4725
|
}, {
|
|
4616
|
-
key: "
|
|
4617
|
-
value: function
|
|
4726
|
+
key: "getFullCoveragePassDiscounts",
|
|
4727
|
+
value: function getFullCoveragePassDiscounts(product) {
|
|
4618
4728
|
var _product$_extend;
|
|
4619
|
-
var
|
|
4620
|
-
return (item === null || item === void 0 ? void 0 : item.type) === 'good_pass' || (item === null || item === void 0 ? void 0 : item.tag) === 'good_pass';
|
|
4621
|
-
});
|
|
4622
|
-
if (hasMainGoodPass) return true;
|
|
4623
|
-
var bundleDiscountList = [];
|
|
4729
|
+
var discountList = _toConsumableArray(product.discount_list || []);
|
|
4624
4730
|
(product.product_bundle || []).forEach(function (item) {
|
|
4625
|
-
|
|
4731
|
+
discountList.push.apply(discountList, _toConsumableArray((item === null || item === void 0 ? void 0 : item.discount_list) || []));
|
|
4626
4732
|
});
|
|
4627
4733
|
((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) {
|
|
4628
|
-
|
|
4734
|
+
discountList.push.apply(discountList, _toConsumableArray((item === null || item === void 0 ? void 0 : item.discount_list) || []));
|
|
4735
|
+
});
|
|
4736
|
+
return discountList.filter(function (item) {
|
|
4737
|
+
return isFullCoveragePass(item);
|
|
4629
4738
|
});
|
|
4630
|
-
|
|
4631
|
-
|
|
4739
|
+
}
|
|
4740
|
+
}, {
|
|
4741
|
+
key: "hasEntitlementPassDiscount",
|
|
4742
|
+
value: function hasEntitlementPassDiscount(product) {
|
|
4743
|
+
return this.getFullCoveragePassDiscounts(product).some(function (item) {
|
|
4744
|
+
return isEntitlementPass(item);
|
|
4745
|
+
});
|
|
4746
|
+
}
|
|
4747
|
+
}, {
|
|
4748
|
+
key: "hasGoodPassDiscount",
|
|
4749
|
+
value: function hasGoodPassDiscount(product) {
|
|
4750
|
+
return this.getFullCoveragePassDiscounts(product).some(function (item) {
|
|
4751
|
+
return !isEntitlementPass(item);
|
|
4632
4752
|
});
|
|
4633
4753
|
}
|
|
4754
|
+
}, {
|
|
4755
|
+
key: "isPersistedProductLine",
|
|
4756
|
+
value: function isPersistedProductLine(product) {
|
|
4757
|
+
var _product$metadata9;
|
|
4758
|
+
return product.order_detail_id !== undefined && product.order_detail_id !== null && product.order_detail_id !== '' || ((_product$metadata9 = product.metadata) === null || _product$metadata9 === void 0 ? void 0 : _product$metadata9.is_edit_for_runtime) === true;
|
|
4759
|
+
}
|
|
4760
|
+
}, {
|
|
4761
|
+
key: "isRuntimeEntitlementAppend",
|
|
4762
|
+
value: function isRuntimeEntitlementAppend(product, tempOrder) {
|
|
4763
|
+
var _product$metadata$uni, _product$metadata10, _tempOrder$_extend9, _product$_origin;
|
|
4764
|
+
if (this.isPersistedProductLine(product)) return false;
|
|
4765
|
+
var uid = (_product$metadata$uni = (_product$metadata10 = product.metadata) === null || _product$metadata10 === void 0 ? void 0 : _product$metadata10.unique_identification_number) !== null && _product$metadata$uni !== void 0 ? _product$metadata$uni : product.unique_identification_number;
|
|
4766
|
+
var storedOrigin = uid !== undefined && uid !== null && uid !== '' ? (_tempOrder$_extend9 = tempOrder._extend) === null || _tempOrder$_extend9 === void 0 || (_tempOrder$_extend9 = _tempOrder$_extend9.productsByUid) === null || _tempOrder$_extend9 === void 0 || (_tempOrder$_extend9 = _tempOrder$_extend9[String(uid)]) === null || _tempOrder$_extend9 === void 0 ? void 0 : _tempOrder$_extend9.origin : undefined;
|
|
4767
|
+
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);
|
|
4768
|
+
}
|
|
4769
|
+
}, {
|
|
4770
|
+
key: "hasSameEntitlementMergePriceConfig",
|
|
4771
|
+
value: function hasSameEntitlementMergePriceConfig(incoming, existing) {
|
|
4772
|
+
var _this28 = this;
|
|
4773
|
+
var buildPriceConfig = function buildPriceConfig(product) {
|
|
4774
|
+
var metadata = product.metadata || {};
|
|
4775
|
+
var bundle = (product.product_bundle || []).map(function (item) {
|
|
4776
|
+
var _ref66, _item$bundle_id, _ref67, _ref68, _item$bundle_product_, _ref69, _item$bundle_variant_, _ref70, _item$price_type, _ref71, _item$price_type_ext;
|
|
4777
|
+
return {
|
|
4778
|
+
bundle_id: (_ref66 = (_item$bundle_id = item.bundle_id) !== null && _item$bundle_id !== void 0 ? _item$bundle_id : item.id) !== null && _ref66 !== void 0 ? _ref66 : null,
|
|
4779
|
+
bundle_product_id: (_ref67 = (_ref68 = (_item$bundle_product_ = item.bundle_product_id) !== null && _item$bundle_product_ !== void 0 ? _item$bundle_product_ : item._bundle_product_id) !== null && _ref68 !== void 0 ? _ref68 : item.product_id) !== null && _ref67 !== void 0 ? _ref67 : null,
|
|
4780
|
+
bundle_variant_id: (_ref69 = (_item$bundle_variant_ = item.bundle_variant_id) !== null && _item$bundle_variant_ !== void 0 ? _item$bundle_variant_ : item.product_variant_id) !== null && _ref69 !== void 0 ? _ref69 : 0,
|
|
4781
|
+
price_type: (_ref70 = (_item$price_type = item.price_type) !== null && _item$price_type !== void 0 ? _item$price_type : item.custom_price_type) !== null && _ref70 !== void 0 ? _ref70 : '',
|
|
4782
|
+
price_type_ext: (_ref71 = (_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 && _ref71 !== void 0 ? _ref71 : ''
|
|
4783
|
+
};
|
|
4784
|
+
}).sort(function (left, right) {
|
|
4785
|
+
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
4786
|
+
});
|
|
4787
|
+
return JSON.stringify({
|
|
4788
|
+
original_price: _this28.normalizeFingerprintMoney(product.original_price),
|
|
4789
|
+
source_product_price: _this28.normalizeFingerprintMoney(metadata.source_product_price),
|
|
4790
|
+
main_product_original_price: _this28.normalizeFingerprintMoney(metadata.main_product_original_price),
|
|
4791
|
+
price_override: _this28.normalizeFingerprintMoney(metadata.price_override),
|
|
4792
|
+
is_manual_discount: Boolean(metadata.is_manual_discount),
|
|
4793
|
+
bundle: bundle
|
|
4794
|
+
});
|
|
4795
|
+
};
|
|
4796
|
+
return buildPriceConfig(incoming) === buildPriceConfig(existing);
|
|
4797
|
+
}
|
|
4634
4798
|
}, {
|
|
4635
4799
|
key: "getBundleRuntimeIdentity",
|
|
4636
4800
|
value: function getBundleRuntimeIdentity(bundle) {
|
|
4637
|
-
var
|
|
4801
|
+
var _ref72, _bundle$bundle_id2, _ref73, _bundle$bundle_group_2, _ref74, _ref75, _bundle$bundle_produc3, _ref76, _bundle$bundle_varian3;
|
|
4638
4802
|
if (!bundle || _typeof(bundle) !== 'object') return '';
|
|
4639
|
-
return [(
|
|
4803
|
+
return [(_ref72 = (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id) !== null && _ref72 !== void 0 ? _ref72 : '', (_ref73 = (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id) !== null && _ref73 !== void 0 ? _ref73 : '', (_ref74 = (_ref75 = (_bundle$bundle_produc3 = bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle._bundle_product_id) !== null && _ref75 !== void 0 ? _ref75 : bundle.product_id) !== null && _ref74 !== void 0 ? _ref74 : '', (_ref76 = (_bundle$bundle_varian3 = bundle.bundle_variant_id) !== null && _bundle$bundle_varian3 !== void 0 ? _bundle$bundle_varian3 : bundle.product_variant_id) !== null && _ref76 !== void 0 ? _ref76 : 0].join('|');
|
|
4640
4804
|
}
|
|
4641
4805
|
}, {
|
|
4642
4806
|
key: "preservePersistedBundlePriceFields",
|
|
4643
4807
|
value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
|
|
4644
|
-
var
|
|
4808
|
+
var _this29 = this;
|
|
4645
4809
|
if (!Array.isArray(nextBundles)) return nextBundles;
|
|
4646
4810
|
if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
|
|
4647
4811
|
var previousByIdentity = new Map();
|
|
4648
4812
|
previousBundles.forEach(function (bundle) {
|
|
4649
|
-
var identity =
|
|
4813
|
+
var identity = _this29.getBundleRuntimeIdentity(bundle);
|
|
4650
4814
|
if (identity) previousByIdentity.set(identity, bundle);
|
|
4651
4815
|
});
|
|
4652
4816
|
return nextBundles.map(function (bundle, index) {
|
|
4653
4817
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
4654
|
-
var previous = previousByIdentity.get(
|
|
4818
|
+
var previous = previousByIdentity.get(_this29.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
|
|
4655
4819
|
if (!previous || _typeof(previous) !== 'object') return bundle;
|
|
4656
4820
|
return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
|
|
4657
4821
|
cover: previous.cover
|
|
@@ -4696,8 +4860,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4696
4860
|
if (unique_identification_number !== undefined) {
|
|
4697
4861
|
var targetUid = String(unique_identification_number);
|
|
4698
4862
|
productIndex = tempOrder.products.findIndex(function (item) {
|
|
4699
|
-
var _item$
|
|
4700
|
-
return String(((_item$
|
|
4863
|
+
var _item$metadata3;
|
|
4864
|
+
return String(((_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.unique_identification_number) || item.unique_identification_number || '') === targetUid;
|
|
4701
4865
|
});
|
|
4702
4866
|
}
|
|
4703
4867
|
if (productIndex === -1) {
|
|
@@ -4787,13 +4951,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4787
4951
|
delete nextProduct.metadata.main_product_original_price;
|
|
4788
4952
|
delete nextProduct.metadata.price_schema_version;
|
|
4789
4953
|
} else if (callerChangesLineConfiguration && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
4790
|
-
var
|
|
4954
|
+
var _ref77, _targetProduct$metada10, _targetProduct$metada11, _ref78, _targetProduct$metada12, _targetProduct$metada13, _targetProduct$metada14;
|
|
4791
4955
|
// 仅 option / bundle 变化时,保留历史 source 和主商品折扣金额,
|
|
4792
4956
|
// 但必须让 original 与 selling 一起随新的 option 金额移动。
|
|
4793
4957
|
var previousOptionSum = sumOptionUnitPrice(getProductSkuOptions(targetProduct));
|
|
4794
4958
|
var nextOptionSum = sumOptionUnitPrice(getProductSkuOptions(nextProduct));
|
|
4795
|
-
var _previousMainOriginal = new Decimal(Number((
|
|
4796
|
-
var _previousMainSelling = new Decimal(Number((
|
|
4959
|
+
var _previousMainOriginal = new Decimal(Number((_ref77 = (_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 && _ref77 !== void 0 ? _ref77 : 0) || 0);
|
|
4960
|
+
var _previousMainSelling = new Decimal(Number((_ref78 = (_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 && _ref78 !== void 0 ? _ref78 : _previousMainOriginal.toNumber()) || 0);
|
|
4797
4961
|
var _preservedDiscount = _previousMainOriginal.minus(_previousMainSelling);
|
|
4798
4962
|
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);
|
|
4799
4963
|
var _nextMainOriginal = previousSource.plus(nextOptionSum);
|
|
@@ -4814,7 +4978,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4814
4978
|
// normalizeOrderProduct 幂等:v2 metadata 存在 → 保留 main_product_* 折扣重算 composite;
|
|
4815
4979
|
// 否则 → 把顶层 selling_price 视作 source,派生 main_product_* 并写 price_schema_version: 2。
|
|
4816
4980
|
var normalizedProduct = this.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(nextProduct, normalizeOrderProduct(nextProduct)));
|
|
4817
|
-
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
4981
|
+
normalizedProduct.discount_list = normalizeOrderProductDiscountList(isPersistedOrderLine ? syncReducedEntitlementPassUsageCount(normalizedProduct.discount_list, targetProduct.num, normalizedProduct.num) : normalizedProduct.discount_list);
|
|
4818
4982
|
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);
|
|
4819
4983
|
if (!booking && preservedBookingUid) {
|
|
4820
4984
|
normalizedProduct.booking_uid = preservedBookingUid;
|
|
@@ -4891,7 +5055,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4891
5055
|
key: "updateOrderProducts",
|
|
4892
5056
|
value: function () {
|
|
4893
5057
|
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(paramsList) {
|
|
4894
|
-
var
|
|
5058
|
+
var _this30 = this;
|
|
4895
5059
|
var tempOrder, reapplyBookingDiscountProductUids;
|
|
4896
5060
|
return _regeneratorRuntime().wrap(function _callee22$(_context24) {
|
|
4897
5061
|
while (1) switch (_context24.prev = _context24.next) {
|
|
@@ -4904,7 +5068,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4904
5068
|
return _context24.abrupt("return", tempOrder.products);
|
|
4905
5069
|
case 3:
|
|
4906
5070
|
reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
|
|
4907
|
-
var updatedProductUid =
|
|
5071
|
+
var updatedProductUid = _this30.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
4908
5072
|
// 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
|
|
4909
5073
|
if (params.allow_booking_discount_reapply && updatedProductUid) {
|
|
4910
5074
|
acc.push(String(updatedProductUid));
|
|
@@ -4936,7 +5100,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4936
5100
|
value: function () {
|
|
4937
5101
|
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
|
|
4938
5102
|
var _targetProduct$metada17;
|
|
4939
|
-
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;
|
|
5103
|
+
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;
|
|
4940
5104
|
return _regeneratorRuntime().wrap(function _callee23$(_context25) {
|
|
4941
5105
|
while (1) switch (_context25.prev = _context25.next) {
|
|
4942
5106
|
case 0:
|
|
@@ -4960,8 +5124,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4960
5124
|
if (unique_identification_number !== undefined) {
|
|
4961
5125
|
targetUid = String(unique_identification_number);
|
|
4962
5126
|
productIndex = tempOrder.products.findIndex(function (item) {
|
|
4963
|
-
var _item$
|
|
4964
|
-
return String(((_item$
|
|
5127
|
+
var _item$metadata4;
|
|
5128
|
+
return String(((_item$metadata4 = item.metadata) === null || _item$metadata4 === void 0 ? void 0 : _item$metadata4.unique_identification_number) || item.unique_identification_number || '') === targetUid;
|
|
4965
5129
|
});
|
|
4966
5130
|
}
|
|
4967
5131
|
if (productIndex === -1) {
|
|
@@ -4974,16 +5138,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4974
5138
|
throw new Error('[Order] 目标商品不存在,无法更新数量');
|
|
4975
5139
|
case 13:
|
|
4976
5140
|
targetProduct = tempOrder.products[productIndex];
|
|
5141
|
+
isPersistedOrderLine = targetProduct.order_detail_id !== undefined && targetProduct.order_detail_id !== null;
|
|
4977
5142
|
normalizedProduct = this.normalizeVirtualSettlementProductIfEnabled(normalizeOrderProduct(_objectSpread(_objectSpread({}, targetProduct), {}, {
|
|
4978
5143
|
num: getSafeProductNum(num),
|
|
4979
5144
|
metadata: _objectSpread(_objectSpread({}, targetProduct.metadata || {}), {}, {
|
|
4980
5145
|
unique_identification_number: ((_targetProduct$metada17 = targetProduct.metadata) === null || _targetProduct$metada17 === void 0 ? void 0 : _targetProduct$metada17.unique_identification_number) || unique_identification_number
|
|
4981
5146
|
})
|
|
4982
5147
|
})));
|
|
4983
|
-
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
5148
|
+
normalizedProduct.discount_list = normalizeOrderProductDiscountList(isPersistedOrderLine ? syncReducedEntitlementPassUsageCount(normalizedProduct.discount_list, targetProduct.num, normalizedProduct.num) : normalizedProduct.discount_list);
|
|
4984
5149
|
settlementSnapshot = getSelectedSettlementSnapshot(normalizedProduct);
|
|
4985
5150
|
if (!(this.isMultiCurrencySettlementEnabled() && (settlementSnapshot === null || settlementSnapshot === void 0 ? void 0 : settlementSnapshot.settlement_type) === 'virtual_currency' && tempOrder.customer_id && Number(tempOrder.customer_id) !== 1)) {
|
|
4986
|
-
_context25.next =
|
|
5151
|
+
_context25.next = 27;
|
|
4987
5152
|
break;
|
|
4988
5153
|
}
|
|
4989
5154
|
currencyProductId = Number(settlementSnapshot.currency_product_id);
|
|
@@ -4991,11 +5156,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4991
5156
|
return Number(item === null || item === void 0 ? void 0 : item.product_id) === currencyProductId;
|
|
4992
5157
|
});
|
|
4993
5158
|
if (asset) {
|
|
4994
|
-
_context25.next =
|
|
5159
|
+
_context25.next = 23;
|
|
4995
5160
|
break;
|
|
4996
5161
|
}
|
|
4997
5162
|
throw new VirtualCurrencyAssetNotFoundError(currencyProductId);
|
|
4998
|
-
case
|
|
5163
|
+
case 23:
|
|
4999
5164
|
requiredAmount = tempOrder.products.reduce(function (sum, item, index) {
|
|
5000
5165
|
var current = index === productIndex ? normalizedProduct : item;
|
|
5001
5166
|
var currentSnapshot = getSelectedSettlementSnapshot(current);
|
|
@@ -5003,34 +5168,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5003
5168
|
}, new Decimal(0));
|
|
5004
5169
|
balance = new Decimal(asset.balance || 0);
|
|
5005
5170
|
if (!balance.lt(requiredAmount)) {
|
|
5006
|
-
_context25.next =
|
|
5171
|
+
_context25.next = 27;
|
|
5007
5172
|
break;
|
|
5008
5173
|
}
|
|
5009
5174
|
throw new VirtualCurrencyBalanceError(balance.toFixed(2), requiredAmount.toFixed(2));
|
|
5010
|
-
case
|
|
5175
|
+
case 27:
|
|
5011
5176
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
5012
5177
|
this.prepareVirtualSettlementTempOrder(tempOrder);
|
|
5013
5178
|
if (this.isActiveVirtualSettlementOrder(tempOrder)) {
|
|
5014
|
-
_context25.next =
|
|
5179
|
+
_context25.next = 33;
|
|
5015
5180
|
break;
|
|
5016
5181
|
}
|
|
5017
|
-
_context25.next =
|
|
5182
|
+
_context25.next = 32;
|
|
5018
5183
|
return this.applyPromotion();
|
|
5019
|
-
case 31:
|
|
5020
|
-
this.applyDiscount();
|
|
5021
5184
|
case 32:
|
|
5185
|
+
this.applyDiscount();
|
|
5186
|
+
case 33:
|
|
5022
5187
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
5023
|
-
_context25.next =
|
|
5188
|
+
_context25.next = 36;
|
|
5024
5189
|
return this.recalculateSummary({
|
|
5025
5190
|
createIfMissing: true
|
|
5026
5191
|
});
|
|
5027
|
-
case
|
|
5192
|
+
case 36:
|
|
5028
5193
|
this.persistTempOrder();
|
|
5029
5194
|
this.logInfo('updateOrderProductQuantity success', {
|
|
5030
5195
|
params: params
|
|
5031
5196
|
});
|
|
5032
5197
|
return _context25.abrupt("return", tempOrder.products);
|
|
5033
|
-
case
|
|
5198
|
+
case 39:
|
|
5034
5199
|
case "end":
|
|
5035
5200
|
return _context25.stop();
|
|
5036
5201
|
}
|
|
@@ -5117,7 +5282,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5117
5282
|
key: "removeProductsFromOrder",
|
|
5118
5283
|
value: (function () {
|
|
5119
5284
|
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(identities, options) {
|
|
5120
|
-
var
|
|
5285
|
+
var _this31 = this;
|
|
5121
5286
|
var tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
|
|
5122
5287
|
return _regeneratorRuntime().wrap(function _callee25$(_context28) {
|
|
5123
5288
|
while (1) switch (_context28.prev = _context28.next) {
|
|
@@ -5134,8 +5299,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5134
5299
|
bookingsBeforeRemove = tempOrder.bookings || [];
|
|
5135
5300
|
preserveDisplayPosition = options === null || options === void 0 ? void 0 : options.preserveDisplayPosition;
|
|
5136
5301
|
anchorIndex = preserveDisplayPosition ? productsBeforeRemove.findIndex(function (item) {
|
|
5137
|
-
var _item$
|
|
5138
|
-
var uid = ((_item$
|
|
5302
|
+
var _item$metadata5;
|
|
5303
|
+
var uid = ((_item$metadata5 = item.metadata) === null || _item$metadata5 === void 0 ? void 0 : _item$metadata5.unique_identification_number) || item.unique_identification_number;
|
|
5139
5304
|
return uid !== undefined && uid !== null && String(uid) === String(preserveDisplayPosition.anchorProductUid);
|
|
5140
5305
|
}) : -1;
|
|
5141
5306
|
productsAfterAnchor = anchorIndex >= 0 ? productsBeforeRemove.slice(anchorIndex + 1) : [];
|
|
@@ -5180,7 +5345,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5180
5345
|
}
|
|
5181
5346
|
if (productUid !== undefined && productUid !== null && productUid !== '') {
|
|
5182
5347
|
bookingsBeforeRemove.forEach(function (booking) {
|
|
5183
|
-
var bookingUid =
|
|
5348
|
+
var bookingUid = _this31.getBookingUniqueIdentificationNumber(booking);
|
|
5184
5349
|
if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
|
|
5185
5350
|
linkedBookingUidsToRemove.add(bookingUid);
|
|
5186
5351
|
}
|
|
@@ -5231,8 +5396,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5231
5396
|
}
|
|
5232
5397
|
if (preserveDisplayPosition && anchorIndex >= 0) {
|
|
5233
5398
|
remainingProductIndex = tempOrder.products.findIndex(function (item) {
|
|
5234
|
-
var _item$
|
|
5235
|
-
var uid = ((_item$
|
|
5399
|
+
var _item$metadata6;
|
|
5400
|
+
var uid = ((_item$metadata6 = item.metadata) === null || _item$metadata6 === void 0 ? void 0 : _item$metadata6.unique_identification_number) || item.unique_identification_number;
|
|
5236
5401
|
return uid !== undefined && uid !== null && String(uid) === String(preserveDisplayPosition.remainingProductUid);
|
|
5237
5402
|
});
|
|
5238
5403
|
if (remainingProductIndex >= 0) {
|
|
@@ -5388,23 +5553,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5388
5553
|
}, {
|
|
5389
5554
|
key: "buildCurrentSubmitPayloadForLocalPrint",
|
|
5390
5555
|
value: function buildCurrentSubmitPayloadForLocalPrint(params) {
|
|
5391
|
-
var _params$cacheId, _this$otherParams5,
|
|
5556
|
+
var _params$cacheId, _this$otherParams5, _ref79, _params$businessCode, _this$otherParams6, _this$otherParams7;
|
|
5392
5557
|
var tempOrder = this.ensureTempOrder();
|
|
5393
5558
|
this.persistTempOrder();
|
|
5394
5559
|
var payload = buildSubmitPayload({
|
|
5395
5560
|
tempOrder: tempOrder,
|
|
5396
5561
|
cacheId: (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId,
|
|
5397
5562
|
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.platform),
|
|
5398
|
-
businessCode: (
|
|
5563
|
+
businessCode: (_ref79 = (_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 && _ref79 !== void 0 ? _ref79 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.business_code,
|
|
5399
5564
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
5400
5565
|
type: params === null || params === void 0 ? void 0 : params.type,
|
|
5401
5566
|
summary: this.store.summary || createEmptySummary(),
|
|
5402
5567
|
enhance: function enhance(nextPayload) {
|
|
5403
|
-
var
|
|
5568
|
+
var _ref80, _tempOrder$order_numb, _ref81, _tempOrder$shop_order, _ref82, _tempOrder$shop_full_;
|
|
5404
5569
|
return _objectSpread(_objectSpread({}, nextPayload), {}, {
|
|
5405
|
-
order_number: (
|
|
5406
|
-
shop_order_number: (
|
|
5407
|
-
shop_full_order_number: (
|
|
5570
|
+
order_number: (_ref80 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref80 !== void 0 ? _ref80 : null,
|
|
5571
|
+
shop_order_number: (_ref81 = (_tempOrder$shop_order = tempOrder.shop_order_number) !== null && _tempOrder$shop_order !== void 0 ? _tempOrder$shop_order : nextPayload.shop_order_number) !== null && _ref81 !== void 0 ? _ref81 : null,
|
|
5572
|
+
shop_full_order_number: (_ref82 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref82 !== void 0 ? _ref82 : null,
|
|
5408
5573
|
small_ticket_data_flag: 1
|
|
5409
5574
|
});
|
|
5410
5575
|
}
|
|
@@ -5568,7 +5733,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5568
5733
|
key: "runSubmitTempOrder",
|
|
5569
5734
|
value: function () {
|
|
5570
5735
|
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
|
|
5571
|
-
var _params$cacheId3, _this$otherParams12,
|
|
5736
|
+
var _params$cacheId3, _this$otherParams12, _ref83, _ref84, _submitSnapshot$busin, _this$otherParams13, _this$otherParams14, _submitSnapshot$type;
|
|
5572
5737
|
var tempOrder, isOnlineStorePlatform, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
|
|
5573
5738
|
return _regeneratorRuntime().wrap(function _callee33$(_context36) {
|
|
5574
5739
|
while (1) switch (_context36.prev = _context36.next) {
|
|
@@ -5634,7 +5799,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5634
5799
|
tempOrder: tempOrder,
|
|
5635
5800
|
cacheId: effectiveCacheId,
|
|
5636
5801
|
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.platform),
|
|
5637
|
-
businessCode: (
|
|
5802
|
+
businessCode: (_ref83 = (_ref84 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref84 !== void 0 ? _ref84 : (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.businessCode) !== null && _ref83 !== void 0 ? _ref83 : (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.business_code,
|
|
5638
5803
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
5639
5804
|
type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
|
|
5640
5805
|
summary: latestSummary,
|
|
@@ -5803,10 +5968,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5803
5968
|
value: function extractSubmitErrorResponse(error) {
|
|
5804
5969
|
var _error$response,
|
|
5805
5970
|
_error$response2,
|
|
5806
|
-
|
|
5971
|
+
_this32 = this;
|
|
5807
5972
|
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];
|
|
5808
5973
|
return candidates.find(function (candidate) {
|
|
5809
|
-
return
|
|
5974
|
+
return _this32.isSubmitErrorResponse(candidate);
|
|
5810
5975
|
}) || null;
|
|
5811
5976
|
}
|
|
5812
5977
|
}, {
|
|
@@ -5834,7 +5999,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5834
5999
|
key: "syncPaymentsToOrder",
|
|
5835
6000
|
value: function () {
|
|
5836
6001
|
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
|
|
5837
|
-
var
|
|
6002
|
+
var _this33 = this,
|
|
5838
6003
|
_params$confirmPendin;
|
|
5839
6004
|
var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, enhancePayload, submitParams, submitResult;
|
|
5840
6005
|
return _regeneratorRuntime().wrap(function _callee35$(_context38) {
|
|
@@ -5859,7 +6024,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5859
6024
|
case 9:
|
|
5860
6025
|
devicePrefix = _context38.t0;
|
|
5861
6026
|
mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
|
|
5862
|
-
return
|
|
6027
|
+
return _this33.normalizePaymentSource(payment, {
|
|
5863
6028
|
defaultPaid: false,
|
|
5864
6029
|
devicePrefix: devicePrefix
|
|
5865
6030
|
});
|
|
@@ -5938,7 +6103,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5938
6103
|
}, {
|
|
5939
6104
|
key: "createOrder",
|
|
5940
6105
|
value: function createOrder(params) {
|
|
5941
|
-
var
|
|
6106
|
+
var _this34 = this;
|
|
5942
6107
|
var order = _objectSpread({
|
|
5943
6108
|
type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
|
|
5944
6109
|
// 要从外面拿,virtual
|
|
@@ -5970,7 +6135,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5970
6135
|
|
|
5971
6136
|
// 为预约补齐 holder 信息
|
|
5972
6137
|
if (params !== null && params !== void 0 && (_params$extraData = params.extraData) !== null && _params$extraData !== void 0 && _params$extraData.is_add_holder_info) {
|
|
5973
|
-
ensureCartItemOriginHolder(item,
|
|
6138
|
+
ensureCartItemOriginHolder(item, _this34.window);
|
|
5974
6139
|
}
|
|
5975
6140
|
|
|
5976
6141
|
// 购物车是否为普通商品
|
|
@@ -6610,10 +6775,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6610
6775
|
_step22;
|
|
6611
6776
|
try {
|
|
6612
6777
|
for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
|
|
6613
|
-
var _product$
|
|
6778
|
+
var _product$metadata11;
|
|
6614
6779
|
var product = _step22.value;
|
|
6615
6780
|
var productUid = getOrderCollectionUid('product', product);
|
|
6616
|
-
var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$
|
|
6781
|
+
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);
|
|
6617
6782
|
if (!productUid || bookingUid === undefined || bookingUid === null || bookingUid === '') {
|
|
6618
6783
|
continue;
|
|
6619
6784
|
}
|
|
@@ -6671,7 +6836,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6671
6836
|
}, {
|
|
6672
6837
|
key: "normalizeTempOrderForRuntime",
|
|
6673
6838
|
value: function normalizeTempOrderForRuntime(raw, options) {
|
|
6674
|
-
var
|
|
6839
|
+
var _this35 = this;
|
|
6675
6840
|
var runtimeRaw = this.withoutSyntheticDraftOrderIdForRuntime(raw);
|
|
6676
6841
|
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
|
|
6677
6842
|
// ES 列表详情使用 id 表示订单主键;OS 详情态统一依赖 order_id 驱动操作按钮。
|
|
@@ -6695,12 +6860,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6695
6860
|
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
6696
6861
|
var rawProducts = Array.isArray(raw.products) ? raw.products : [];
|
|
6697
6862
|
nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
|
|
6698
|
-
return
|
|
6863
|
+
return _this35.normalizeHydratedOrderProduct(p, {
|
|
6699
6864
|
makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
|
|
6700
6865
|
});
|
|
6701
6866
|
}) : [];
|
|
6702
6867
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
6703
|
-
var booking =
|
|
6868
|
+
var booking = _this35.normalizeHydratedBookingHolder(b || {});
|
|
6704
6869
|
return _objectSpread(_objectSpread({}, booking), {}, {
|
|
6705
6870
|
is_all: normalizeBookingIsAll(booking),
|
|
6706
6871
|
sub_type: normalizeBookingSubType(booking)
|
|
@@ -6731,15 +6896,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6731
6896
|
_step24;
|
|
6732
6897
|
try {
|
|
6733
6898
|
for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
|
|
6734
|
-
var _product$
|
|
6899
|
+
var _product$metadata12, _ref85, _ref86, _existed$origin, _rawProduct$metadata;
|
|
6735
6900
|
var _step24$value = _slicedToArray(_step24.value, 2),
|
|
6736
6901
|
index = _step24$value[0],
|
|
6737
6902
|
product = _step24$value[1];
|
|
6738
|
-
var uid = (_product$
|
|
6903
|
+
var uid = (_product$metadata12 = product.metadata) === null || _product$metadata12 === void 0 ? void 0 : _product$metadata12.unique_identification_number;
|
|
6739
6904
|
if (!uid) continue;
|
|
6740
6905
|
var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
|
|
6741
6906
|
var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
|
|
6742
|
-
var origin = (
|
|
6907
|
+
var origin = (_ref85 = (_ref86 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref86 !== void 0 ? _ref86 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref85 !== void 0 ? _ref85 : rawProduct;
|
|
6743
6908
|
var originSnapshot = cloneDeep(origin);
|
|
6744
6909
|
var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
|
|
6745
6910
|
if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
|
|
@@ -6790,8 +6955,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6790
6955
|
var bookingUidByProductUid = new Map();
|
|
6791
6956
|
var productByUid = new Map();
|
|
6792
6957
|
(tempOrder.products || []).forEach(function (product) {
|
|
6793
|
-
var _product$
|
|
6794
|
-
var productUid = (product === null || product === void 0 || (_product$
|
|
6958
|
+
var _product$metadata13;
|
|
6959
|
+
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);
|
|
6795
6960
|
if (productUid !== undefined && productUid !== null && String(productUid) !== '') {
|
|
6796
6961
|
productByUid.set(String(productUid), product);
|
|
6797
6962
|
}
|
|
@@ -6812,8 +6977,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6812
6977
|
bookingUidByProductUid.set(String(productUid), bookingUid);
|
|
6813
6978
|
});
|
|
6814
6979
|
(tempOrder.products || []).forEach(function (product) {
|
|
6815
|
-
var _product$
|
|
6816
|
-
var productUid = (product === null || product === void 0 || (_product$
|
|
6980
|
+
var _product$metadata14;
|
|
6981
|
+
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);
|
|
6817
6982
|
if (productUid === undefined || productUid === null || String(productUid) === '') return;
|
|
6818
6983
|
var bookingUid = bookingUidByProductUid.get(String(productUid));
|
|
6819
6984
|
if (!bookingUid) return;
|
|
@@ -6868,10 +7033,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6868
7033
|
}, {
|
|
6869
7034
|
key: "normalizeHydratedProductOptionItem",
|
|
6870
7035
|
value: function normalizeHydratedProductOptionItem(optionItem) {
|
|
6871
|
-
var
|
|
6872
|
-
var rawNum = (
|
|
7036
|
+
var _ref87, _optionItem$num, _ref88, _optionItem$add_price;
|
|
7037
|
+
var rawNum = (_ref87 = (_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 && _ref87 !== void 0 ? _ref87 : 1;
|
|
6873
7038
|
var parsedNum = Number(rawNum);
|
|
6874
|
-
var rawPrice = (
|
|
7039
|
+
var rawPrice = (_ref88 = (_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 && _ref88 !== void 0 ? _ref88 : 0;
|
|
6875
7040
|
var parsedPrice = Number(rawPrice);
|
|
6876
7041
|
var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
|
|
6877
7042
|
option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
|
|
@@ -6888,7 +7053,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6888
7053
|
}, {
|
|
6889
7054
|
key: "normalizeHydratedOrderProduct",
|
|
6890
7055
|
value: function normalizeHydratedOrderProduct(product, options) {
|
|
6891
|
-
var
|
|
7056
|
+
var _this36 = this;
|
|
6892
7057
|
var row = _objectSpread({}, product || {});
|
|
6893
7058
|
if (row.num === undefined && row.product_quantity !== undefined) {
|
|
6894
7059
|
row.num = row.product_quantity;
|
|
@@ -6896,7 +7061,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6896
7061
|
var productSku = ensureProductSku(row);
|
|
6897
7062
|
row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
|
|
6898
7063
|
option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
|
|
6899
|
-
return
|
|
7064
|
+
return _this36.normalizeHydratedProductOptionItem(optionItem || {});
|
|
6900
7065
|
}))
|
|
6901
7066
|
});
|
|
6902
7067
|
delete row["product_".concat('option', "_item")];
|
|
@@ -7004,11 +7169,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7004
7169
|
targetMap.set(discountKey, (targetMap.get(discountKey) || new Decimal(0)).plus(amount));
|
|
7005
7170
|
};
|
|
7006
7171
|
var addProductDiscountAmount = function addProductDiscountAmount(discount, quantity, isPersistedProduct) {
|
|
7007
|
-
var _discount$discount3, _discount$
|
|
7172
|
+
var _discount$discount3, _discount$metadata2;
|
|
7008
7173
|
var discountKey = ((_discount$discount3 = discount.discount) === null || _discount$discount3 === void 0 ? void 0 : _discount$discount3.resource_id) || discount.id;
|
|
7009
7174
|
if (discountKey == null) return;
|
|
7010
7175
|
var qty = Number(quantity) || 1;
|
|
7011
|
-
var amount = new Decimal(discount.amount || 0).times(qty).plus(((_discount$
|
|
7176
|
+
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);
|
|
7012
7177
|
addDiscountAmount(savedMap, discountKey, amount);
|
|
7013
7178
|
addDiscountAmount(isPersistedProduct || discount.order_discount_id != null ? editModeSavedMap : runtimeSavedMap, discountKey, amount);
|
|
7014
7179
|
};
|