@pisell/pisellos 2.3.126 → 2.3.127
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/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.js +4 -2
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +58 -19
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +24 -12
- package/dist/modules/Customer/index.js +6 -3
- package/dist/modules/Customer/types.d.ts +2 -0
- package/dist/modules/Discount/availability.d.ts +7 -0
- package/dist/modules/Discount/availability.js +49 -0
- 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 -2
- package/dist/modules/Discount/index.js +37 -151
- package/dist/modules/Discount/types.d.ts +36 -5
- package/dist/modules/Order/index.d.ts +7 -1
- package/dist/modules/Order/index.js +440 -232
- package/dist/modules/Order/utils/orderCollectionIdentity.js +16 -12
- package/dist/modules/Order/utils.d.ts +1 -1
- package/dist/modules/Order/utils.js +101 -60
- package/dist/modules/Payment/types.d.ts +21 -1
- package/dist/modules/Payment/types.js +2 -0
- package/dist/modules/Payment/walletpass.d.ts +1 -1
- package/dist/modules/Payment/walletpass.js +80 -47
- package/dist/modules/Rules/index.d.ts +2 -2
- package/dist/modules/Rules/index.js +480 -186
- package/dist/modules/Rules/types.d.ts +4 -0
- package/dist/server/modules/order/types.d.ts +2 -0
- package/dist/solution/BaseSales/index.d.ts +1 -0
- package/dist/solution/BaseSales/index.js +5 -2
- package/dist/solution/BaseSales/types.d.ts +2 -2
- package/dist/solution/BaseSales/utils/cartPromotion.js +141 -126
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +2 -3
- package/dist/solution/BookingTicket/index.js +60 -63
- package/dist/solution/BookingTicket/types.d.ts +5 -1
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +2 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +338 -147
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +8 -4
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +6 -0
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +19 -6
- package/dist/solution/ShopDiscount/index.d.ts +2 -0
- package/dist/solution/ShopDiscount/index.js +99 -42
- package/dist/solution/ShopDiscount/utils.d.ts +4 -2
- package/dist/solution/ShopDiscount/utils.js +43 -23
- package/dist/solution/UnifiedBookingSales/index.js +2 -2
- package/lib/model/strategy/adapter/promotion/index.js +46 -1
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.js +2 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +35 -6
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +13 -6
- package/lib/modules/Customer/index.js +5 -1
- package/lib/modules/Customer/types.d.ts +2 -0
- package/lib/modules/Discount/availability.d.ts +7 -0
- package/lib/modules/Discount/availability.js +43 -0
- 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 -2
- package/lib/modules/Discount/index.js +23 -129
- package/lib/modules/Discount/types.d.ts +36 -5
- package/lib/modules/Order/index.d.ts +7 -1
- package/lib/modules/Order/index.js +213 -40
- package/lib/modules/Order/utils/orderCollectionIdentity.js +14 -11
- package/lib/modules/Order/utils.d.ts +1 -1
- package/lib/modules/Order/utils.js +39 -3
- package/lib/modules/Payment/types.d.ts +21 -1
- package/lib/modules/Payment/types.js +1 -0
- package/lib/modules/Payment/walletpass.d.ts +1 -1
- package/lib/modules/Payment/walletpass.js +29 -9
- package/lib/modules/Rules/index.d.ts +2 -2
- package/lib/modules/Rules/index.js +357 -110
- package/lib/modules/Rules/types.d.ts +4 -0
- package/lib/server/modules/order/types.d.ts +2 -0
- package/lib/solution/BaseSales/index.d.ts +1 -0
- package/lib/solution/BaseSales/index.js +5 -2
- package/lib/solution/BaseSales/types.d.ts +2 -2
- package/lib/solution/BaseSales/utils/cartPromotion.js +12 -4
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +2 -3
- package/lib/solution/BookingTicket/index.js +36 -33
- package/lib/solution/BookingTicket/types.d.ts +5 -1
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +2 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +174 -42
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +8 -4
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +6 -0
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +11 -3
- package/lib/solution/ShopDiscount/index.d.ts +2 -0
- package/lib/solution/ShopDiscount/index.js +55 -9
- package/lib/solution/ShopDiscount/utils.d.ts +4 -2
- package/lib/solution/ShopDiscount/utils.js +42 -25
- package/lib/solution/UnifiedBookingSales/index.js +2 -2
- 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; }
|
|
@@ -35,6 +35,7 @@ import { OrderHooks } from "./types";
|
|
|
35
35
|
import { composeLinePrice, generateDuration, getAllDiscountList, mergeRelationForms, ensureCartItemOriginHolder, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, isTempOrder, normalizeOrderMetaList, normalizeBookingIsAll, normalizeBookingSubType, mapPaymentItemsToOrderPayments, normalizeOrderProductDiscountList, resolveEffectivePerUnitDiscount, ensureProductSku, getProductSkuOptions, normalizeProductSkuOptions, sumOptionUnitPrice, clearTempOrderHolderAssignments, getOrderProductLineUid, indexOrderProductsByUid, calculateOrderProductsDeposit, collectPointCardSnapshotCodeCandidates, mergePointCardSnapshotCodes as _mergePointCardSnapshotCodes, buildVirtualCurrencySnapshotFromList, mergeOrderProductDisplayFields, resolveIsFormSubject, isMarkdownBundle } from "./utils";
|
|
36
36
|
import { isNormalProduct } from "../Product/utils";
|
|
37
37
|
import dayjs from 'dayjs';
|
|
38
|
+
import { getDiscountLifecycleReason } from "../Discount/availability";
|
|
38
39
|
import { stripOsPrivatePayloadFields } from "../../utils/os-private-payload";
|
|
39
40
|
import { buildSalesNoteText, decodeSalesNotesSnapshot, getSalesNotePolicy } from "./salesNotes";
|
|
40
41
|
import { ensureOrderPaymentNumber, mergeOrderPaymentRecord, resolveOrderPaymentIdentity } from "./payment-utils";
|
|
@@ -48,6 +49,7 @@ import { consolidateDiscountFreeProductLines, ensureUniqueProductLineUids } from
|
|
|
48
49
|
import { applyTempOrderSettlementState, getSelectedSettlementSnapshot, getSettlementKey, getTempOrderSettlementKey, getTempOrderSettlementSnapshot, isVirtualSettlementOrder, normalizeVirtualSettlementOrderProduct, normalizeVirtualSettlementProducts, OrderSettlementConflictError, releaseTempOrderSettlementState, VirtualCurrencyAssetNotFoundError, VirtualCurrencyBalanceError } from "./utils/virtualSettlement";
|
|
49
50
|
import { DiscountModule } from "../Discount";
|
|
50
51
|
import { RulesModule } from "../Rules";
|
|
52
|
+
import { isEntitlementPass, isFullCoveragePass } from "../Discount/entitlementPass";
|
|
51
53
|
import { UnavailableReason } from "../Rules/types";
|
|
52
54
|
import Decimal from 'decimal.js';
|
|
53
55
|
import { cloneDeep } from 'lodash-es';
|
|
@@ -71,9 +73,26 @@ function isManualProductDiscountProduct(product) {
|
|
|
71
73
|
return (item === null || item === void 0 ? void 0 : item.type) === 'product';
|
|
72
74
|
});
|
|
73
75
|
}
|
|
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
|
+
}
|
|
74
93
|
var ORDER_PAYMENT_STATUS_PAID = 'paid';
|
|
75
94
|
var ORDER_PAYMENT_STATUS_PENDING = 'payment_pending';
|
|
76
|
-
var CUSTOMER_PROMOTION_DISCOUNT_TAGS = new Set(['good_pass', 'product_discount_card', 'discount_card']);
|
|
95
|
+
var CUSTOMER_PROMOTION_DISCOUNT_TAGS = new Set(['entitlement_pass', 'good_pass', 'product_discount_card', 'discount_card']);
|
|
77
96
|
function isCustomerPromotionDiscount(discount) {
|
|
78
97
|
return CUSTOMER_PROMOTION_DISCOUNT_TAGS.has(String((discount === null || discount === void 0 ? void 0 : discount.tag) || (discount === null || discount === void 0 ? void 0 : discount.type) || '').toLowerCase());
|
|
79
98
|
}
|
|
@@ -108,6 +127,27 @@ function getVoucherPaymentLifecycleKey(payment) {
|
|
|
108
127
|
if (!isVoucherPaymentRecord(payment)) return null;
|
|
109
128
|
return "".concat(String(payment.voucher_id), "::").concat(String(payment.status || ''));
|
|
110
129
|
}
|
|
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
|
+
}
|
|
111
151
|
export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
112
152
|
_inherits(OrderModule, _BaseModule);
|
|
113
153
|
var _super = _createSuper(OrderModule);
|
|
@@ -172,7 +212,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
172
212
|
_step2;
|
|
173
213
|
try {
|
|
174
214
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
175
|
-
var _item$type2, _ref, _ref2, _item$discount$resour, _item$discount, _item$discount$title, _item$discount2, _item$discount3, _item$discount$fixed_, _item$
|
|
215
|
+
var _item$type2, _ref, _ref2, _item$discount$resour, _item$discount, _item$discount$title, _item$discount2, _item$metadata, _item$discount3, _item$discount4, _item$discount$fixed_, _item$discount5, _item$discount6, _item$amount, _ref3, _item$discount$origin, _item$discount7, _ref4, _ref5, _item$metadata$num, _item$metadata2, _item$discount$produc, _item$discount8, _ref6, _ref7, _item$metadata$num2, _item$metadata3, _item$discount9, _ref8, _item$discount$discou, _item$discount10, _item$amount2, _item$amount3, _product$product_id, _product$is_charge_ta, _ref9, _product$original_pri, _ref10, _item$discount$discou2, _item$discount11, _item$discount$discou3, _item$discount12;
|
|
176
216
|
var item = _step2.value;
|
|
177
217
|
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;
|
|
178
218
|
if (!type || type === 'product') continue;
|
|
@@ -183,22 +223,31 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
183
223
|
var key = Number.isFinite(id) ? id : String(resourceId);
|
|
184
224
|
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 : {};
|
|
185
225
|
var amount = Number((item === null || item === void 0 ? void 0 : item.amount) || 0);
|
|
186
|
-
var
|
|
187
|
-
var
|
|
226
|
+
var encoded = (item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.encoded) || (item === null || item === void 0 ? void 0 : item.encoded) || (item === null || item === void 0 || (_item$discount3 = item.discount) === null || _item$discount3 === void 0 ? void 0 : _item$discount3.encoded) || '';
|
|
227
|
+
var discountCardType = item === null || item === void 0 || (_item$discount4 = item.discount) === null || _item$discount4 === void 0 ? void 0 : _item$discount4.discount_card_type;
|
|
228
|
+
var parValue = isDiscountCard ? discountCardType === 'fixed_amount' ? (_item$discount$fixed_ = item === null || item === void 0 || (_item$discount5 = item.discount) === null || _item$discount5 === void 0 ? void 0 : _item$discount5.fixed_amount) !== null && _item$discount$fixed_ !== void 0 ? _item$discount$fixed_ : item === null || item === void 0 ? void 0 : item.amount : item === null || item === void 0 || (_item$discount6 = item.discount) === null || _item$discount6 === void 0 ? void 0 : _item$discount6.percent : '0';
|
|
188
229
|
var detail = {
|
|
189
230
|
amount: String((_item$amount = item === null || item === void 0 ? void 0 : item.amount) !== null && _item$amount !== void 0 ? _item$amount : '0'),
|
|
190
231
|
type: type,
|
|
191
232
|
resource_id: key,
|
|
192
233
|
title: title,
|
|
193
|
-
original_amount: String((_ref3 = (_item$discount$origin = item === null || item === void 0 || (_item$
|
|
194
|
-
num: Number((_ref4 = (_ref5 = (_item$metadata$num = item === null || item === void 0 || (_item$
|
|
234
|
+
original_amount: String((_ref3 = (_item$discount$origin = item === null || item === void 0 || (_item$discount7 = item.discount) === null || _item$discount7 === void 0 ? void 0 : _item$discount7.original_amount) !== null && _item$discount$origin !== void 0 ? _item$discount$origin : item === null || item === void 0 ? void 0 : item.amount) !== null && _ref3 !== void 0 ? _ref3 : '0'),
|
|
235
|
+
num: Number((_ref4 = (_ref5 = (_item$metadata$num = item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.num) !== null && _item$metadata$num !== void 0 ? _item$metadata$num : product === null || product === void 0 ? void 0 : product.num) !== null && _ref5 !== void 0 ? _ref5 : product === null || product === void 0 ? void 0 : product.product_quantity) !== null && _ref4 !== void 0 ? _ref4 : 1) || 1,
|
|
195
236
|
metadata: item === null || item === void 0 ? void 0 : item.metadata,
|
|
196
|
-
discount: item === null || item === void 0 ? void 0 : item.discount,
|
|
197
|
-
|
|
237
|
+
discount: _objectSpread(_objectSpread({}, (item === null || item === void 0 ? void 0 : item.discount) || {}), {}, {
|
|
238
|
+
product_id: (_item$discount$produc = item === null || item === void 0 || (_item$discount8 = item.discount) === null || _item$discount8 === void 0 ? void 0 : _item$discount8.product_id) !== null && _item$discount$produc !== void 0 ? _item$discount$produc : product === null || product === void 0 ? void 0 : product.product_id
|
|
239
|
+
}),
|
|
240
|
+
_num: Number((_ref6 = (_ref7 = (_item$metadata$num2 = item === null || item === void 0 || (_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.num) !== null && _item$metadata$num2 !== void 0 ? _item$metadata$num2 : product === null || product === void 0 ? void 0 : product.num) !== null && _ref7 !== void 0 ? _ref7 : product === null || product === void 0 ? void 0 : product.product_quantity) !== null && _ref6 !== void 0 ? _ref6 : 1) || 1
|
|
198
241
|
};
|
|
199
242
|
var existed = discountMap.get(key);
|
|
200
243
|
if (existed) {
|
|
201
244
|
var _existed$limited_rela;
|
|
245
|
+
if (!existed.encoded && encoded) {
|
|
246
|
+
existed.encoded = encoded;
|
|
247
|
+
existed.metadata = _objectSpread(_objectSpread({}, existed.metadata), {}, {
|
|
248
|
+
encoded: encoded
|
|
249
|
+
});
|
|
250
|
+
}
|
|
202
251
|
existed.amount = Number(existed.amount || 0) + amount;
|
|
203
252
|
existed.used_par_value = String(Number(existed.used_par_value || 0) + amount);
|
|
204
253
|
if (!isDiscountCard) {
|
|
@@ -217,10 +266,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
217
266
|
discountMap.set(key, {
|
|
218
267
|
id: key,
|
|
219
268
|
product_name: '',
|
|
220
|
-
encoded:
|
|
221
|
-
code: '',
|
|
269
|
+
encoded: encoded,
|
|
270
|
+
code: (item === null || item === void 0 ? void 0 : item.code) || (item === null || item === void 0 || (_item$discount9 = item.discount) === null || _item$discount9 === void 0 ? void 0 : _item$discount9.code) || '',
|
|
271
|
+
metadata: {
|
|
272
|
+
encoded: encoded
|
|
273
|
+
},
|
|
222
274
|
tag: type,
|
|
223
|
-
product_id: (_ref8 = (_item$discount$discou = item === null || item === void 0 || (_item$
|
|
275
|
+
product_id: (_ref8 = (_item$discount$discou = item === null || item === void 0 || (_item$discount10 = item.discount) === null || _item$discount10 === void 0 ? void 0 : _item$discount10.discount_product_id) !== null && _item$discount$discou !== void 0 ? _item$discount$discou : product === null || product === void 0 ? void 0 : product.product_id) !== null && _ref8 !== void 0 ? _ref8 : 0,
|
|
224
276
|
relation_type: '',
|
|
225
277
|
par_value: String(parValue !== null && parValue !== void 0 ? parValue : '0'),
|
|
226
278
|
used_par_value: String((_item$amount2 = item === null || item === void 0 ? void 0 : item.amount) !== null && _item$amount2 !== void 0 ? _item$amount2 : '0'),
|
|
@@ -253,8 +305,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
253
305
|
amount: amount,
|
|
254
306
|
discount: _objectSpread(_objectSpread({}, (item === null || item === void 0 ? void 0 : item.discount) || {}), {}, {
|
|
255
307
|
resource_id: key,
|
|
256
|
-
discount_product_id: (_ref10 = (_item$discount$discou2 = item === null || item === void 0 || (_item$
|
|
257
|
-
discount_calculation_mode: (_item$discount$discou3 = item === null || item === void 0 || (_item$
|
|
308
|
+
discount_product_id: (_ref10 = (_item$discount$discou2 = item === null || item === void 0 || (_item$discount11 = item.discount) === null || _item$discount11 === void 0 ? void 0 : _item$discount11.discount_product_id) !== null && _item$discount$discou2 !== void 0 ? _item$discount$discou2 : product === null || product === void 0 ? void 0 : product.product_id) !== null && _ref10 !== void 0 ? _ref10 : 0,
|
|
309
|
+
discount_calculation_mode: (_item$discount$discou3 = item === null || item === void 0 || (_item$discount12 = item.discount) === null || _item$discount12 === void 0 ? void 0 : _item$discount12.discount_calculation_mode) !== null && _item$discount$discou3 !== void 0 ? _item$discount$discou3 : 'item_level'
|
|
258
310
|
}),
|
|
259
311
|
applicableProductDetails: [detail],
|
|
260
312
|
appliedProductDetails: [detail]
|
|
@@ -558,7 +610,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
558
610
|
}, {
|
|
559
611
|
key: "createDefaultRulesHooks",
|
|
560
612
|
value: function createDefaultRulesHooks() {
|
|
561
|
-
|
|
613
|
+
var _this2 = this;
|
|
614
|
+
return createDefaultOrderRulesHooks(function () {
|
|
615
|
+
var _this2$store$tempOrde;
|
|
616
|
+
return ((_this2$store$tempOrde = _this2.store.tempOrder) === null || _this2$store$tempOrde === void 0 ? void 0 : _this2$store$tempOrde.bookings) || [];
|
|
617
|
+
});
|
|
562
618
|
}
|
|
563
619
|
|
|
564
620
|
/**
|
|
@@ -580,9 +636,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
580
636
|
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
581
637
|
var _this$store$tempOrder,
|
|
582
638
|
_this$store$discount,
|
|
583
|
-
|
|
639
|
+
_this3 = this,
|
|
584
640
|
_this$store$tempOrder2;
|
|
585
|
-
var orderId, requestEpoch, requestOrderIdentityKey, prepareConfigResult, isCurrentRequest, discountList, _this$store$discount2, _this$store$discount3, _this$store$discount4, currentDiscountList,
|
|
641
|
+
var orderId, requestEpoch, requestOrderIdentityKey, prepareConfigResult, isCurrentRequest, discountList, _this$store$discount2, _this$store$discount3, _this$store$discount4, currentDiscountList, currentCommittedDiscounts, currentScanDiscounts, currentScanDiscountById, committedDiscountById, mergedCommittedDiscountIds, refreshedScanDiscountIds, runtimeDiscountIds, runtimeDiscounts, retainedCommittedDiscounts, retainedScanDiscounts, mergedDiscountList;
|
|
586
642
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
587
643
|
while (1) switch (_context3.prev = _context3.next) {
|
|
588
644
|
case 0:
|
|
@@ -598,6 +654,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
598
654
|
with_wallet_pass_holder: 1,
|
|
599
655
|
with_available_wallet_flag: 1,
|
|
600
656
|
with_available_wallet_pass_flag: 1,
|
|
657
|
+
with_entitlement_pass: 1,
|
|
658
|
+
filter_order_wallet_pass_usage: 0,
|
|
601
659
|
with_virtual_currency: 1,
|
|
602
660
|
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
603
661
|
}, orderId ? {
|
|
@@ -606,8 +664,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
606
664
|
case 5:
|
|
607
665
|
prepareConfigResult = _context3.sent;
|
|
608
666
|
isCurrentRequest = function isCurrentRequest() {
|
|
609
|
-
var
|
|
610
|
-
return requestEpoch ===
|
|
667
|
+
var _this3$store$tempOrde, _this3$store$tempOrde2;
|
|
668
|
+
return requestEpoch === _this3.customerWalletPrepareConfigEpoch && _this3.getDiscountConfigOrderIdentityKey(_this3.store.tempOrder) === requestOrderIdentityKey && String((_this3$store$tempOrde = (_this3$store$tempOrde2 = _this3.store.tempOrder) === null || _this3$store$tempOrde2 === void 0 ? void 0 : _this3$store$tempOrde2.customer_id) !== null && _this3$store$tempOrde !== void 0 ? _this3$store$tempOrde : '') === String(params.customerId);
|
|
611
669
|
};
|
|
612
670
|
if (isCurrentRequest()) {
|
|
613
671
|
_context3.next = 9;
|
|
@@ -625,56 +683,101 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
625
683
|
});
|
|
626
684
|
}
|
|
627
685
|
if (!discountList) {
|
|
628
|
-
_context3.next =
|
|
686
|
+
_context3.next = 32;
|
|
629
687
|
break;
|
|
630
688
|
}
|
|
631
689
|
currentDiscountList = ((_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 ? void 0 : _this$store$discount2.getDiscountList()) || [];
|
|
632
|
-
|
|
633
|
-
|
|
690
|
+
currentCommittedDiscounts = currentDiscountList.filter(function (discount) {
|
|
691
|
+
var _discount$committedAp;
|
|
692
|
+
return (discount === null || discount === void 0 ? void 0 : discount.isEditMode) || (discount === null || discount === void 0 || (_discount$committedAp = discount.committedAppliedProductDetails) === null || _discount$committedAp === void 0 ? void 0 : _discount$committedAp.length);
|
|
634
693
|
});
|
|
635
694
|
currentScanDiscounts = currentDiscountList.filter(function (discount) {
|
|
636
695
|
return discount === null || discount === void 0 ? void 0 : discount.isScan;
|
|
637
696
|
});
|
|
638
|
-
|
|
639
|
-
|
|
697
|
+
currentScanDiscountById = new Map(currentScanDiscounts.flatMap(function (discount) {
|
|
698
|
+
var id = getDiscountIdentityKey(discount);
|
|
699
|
+
return id === null ? [] : [[id, discount]];
|
|
700
|
+
}));
|
|
701
|
+
committedDiscountById = new Map(currentCommittedDiscounts.flatMap(function (discount) {
|
|
702
|
+
var id = getDiscountIdentityKey(discount);
|
|
703
|
+
return id === null ? [] : [[id, discount]];
|
|
640
704
|
}));
|
|
705
|
+
mergedCommittedDiscountIds = new Set();
|
|
706
|
+
refreshedScanDiscountIds = new Set();
|
|
641
707
|
runtimeDiscountIds = new Set();
|
|
642
|
-
runtimeDiscounts = discountList.
|
|
643
|
-
|
|
644
|
-
if (
|
|
645
|
-
runtimeDiscountIds.
|
|
646
|
-
|
|
708
|
+
runtimeDiscounts = discountList.flatMap(function (discount) {
|
|
709
|
+
var id = getDiscountIdentityKey(discount);
|
|
710
|
+
if (id === null) return [discount];
|
|
711
|
+
if (runtimeDiscountIds.has(id)) return [];
|
|
712
|
+
runtimeDiscountIds.add(id);
|
|
713
|
+
var currentScanDiscount = currentScanDiscountById.get(id);
|
|
714
|
+
if (currentScanDiscount && (!isEntitlementPass(currentScanDiscount) || !isEntitlementPass(discount))) {
|
|
715
|
+
return [];
|
|
716
|
+
}
|
|
717
|
+
var committedDiscount = committedDiscountById.get(id);
|
|
718
|
+
var nextDiscount = discount;
|
|
719
|
+
if (committedDiscount && isEntitlementPass(committedDiscount) && isEntitlementPass(discount)) {
|
|
720
|
+
mergedCommittedDiscountIds.add(id);
|
|
721
|
+
nextDiscount = mergeCommittedEntitlementWithRuntime(committedDiscount, discount);
|
|
722
|
+
}
|
|
723
|
+
if (currentScanDiscount) {
|
|
724
|
+
var _currentScanDiscount$, _currentScanDiscount$2;
|
|
725
|
+
refreshedScanDiscountIds.add(id);
|
|
726
|
+
nextDiscount = _objectSpread(_objectSpread({}, nextDiscount), {}, {
|
|
727
|
+
isScan: true,
|
|
728
|
+
isSelected: (_currentScanDiscount$ = currentScanDiscount.isSelected) !== null && _currentScanDiscount$ !== void 0 ? _currentScanDiscount$ : nextDiscount.isSelected,
|
|
729
|
+
isManualSelect: (_currentScanDiscount$2 = currentScanDiscount.isManualSelect) !== null && _currentScanDiscount$2 !== void 0 ? _currentScanDiscount$2 : nextDiscount.isManualSelect
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
return [nextDiscount];
|
|
733
|
+
});
|
|
734
|
+
retainedCommittedDiscounts = currentCommittedDiscounts.filter(function (discount) {
|
|
735
|
+
var id = getDiscountIdentityKey(discount);
|
|
736
|
+
return id === null || !mergedCommittedDiscountIds.has(id);
|
|
737
|
+
}).map(function (discount) {
|
|
738
|
+
var _discount$committedAp2;
|
|
739
|
+
return (_discount$committedAp2 = discount.committedAppliedProductDetails) !== null && _discount$committedAp2 !== void 0 && _discount$committedAp2.length ? _objectSpread(_objectSpread({}, discount), {}, {
|
|
740
|
+
isEditMode: true,
|
|
741
|
+
isDisabled: true,
|
|
742
|
+
isSelected: true,
|
|
743
|
+
isUsed: true,
|
|
744
|
+
appliedProductDetails: _toConsumableArray(discount.committedAppliedProductDetails)
|
|
745
|
+
}) : discount;
|
|
647
746
|
});
|
|
648
|
-
|
|
747
|
+
retainedScanDiscounts = currentScanDiscounts.filter(function (discount) {
|
|
748
|
+
var id = getDiscountIdentityKey(discount);
|
|
749
|
+
return id === null || !refreshedScanDiscountIds.has(id);
|
|
750
|
+
});
|
|
751
|
+
mergedDiscountList = [].concat(_toConsumableArray(retainedCommittedDiscounts), _toConsumableArray(retainedScanDiscounts), _toConsumableArray(runtimeDiscounts));
|
|
649
752
|
if (isCurrentRequest()) {
|
|
650
|
-
_context3.next =
|
|
753
|
+
_context3.next = 26;
|
|
651
754
|
break;
|
|
652
755
|
}
|
|
653
756
|
return _context3.abrupt("return", this.getDiscountList());
|
|
654
|
-
case
|
|
655
|
-
_context3.next =
|
|
757
|
+
case 26:
|
|
758
|
+
_context3.next = 28;
|
|
656
759
|
return (_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.setOriginalDiscountList(mergedDiscountList);
|
|
657
|
-
case
|
|
760
|
+
case 28:
|
|
658
761
|
if (isCurrentRequest()) {
|
|
659
|
-
_context3.next =
|
|
762
|
+
_context3.next = 30;
|
|
660
763
|
break;
|
|
661
764
|
}
|
|
662
765
|
return _context3.abrupt("return", this.getDiscountList());
|
|
663
|
-
case
|
|
664
|
-
_context3.next =
|
|
766
|
+
case 30:
|
|
767
|
+
_context3.next = 32;
|
|
665
768
|
return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.setDiscountList(mergedDiscountList);
|
|
666
|
-
case
|
|
769
|
+
case 32:
|
|
667
770
|
if (isCurrentRequest()) {
|
|
668
|
-
_context3.next =
|
|
771
|
+
_context3.next = 34;
|
|
669
772
|
break;
|
|
670
773
|
}
|
|
671
774
|
return _context3.abrupt("return", this.getDiscountList());
|
|
672
|
-
case
|
|
775
|
+
case 34:
|
|
673
776
|
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) {
|
|
674
777
|
this.applyDiscount();
|
|
675
778
|
}
|
|
676
779
|
return _context3.abrupt("return", this.getDiscountList());
|
|
677
|
-
case
|
|
780
|
+
case 36:
|
|
678
781
|
case "end":
|
|
679
782
|
return _context3.stop();
|
|
680
783
|
}
|
|
@@ -794,7 +897,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
794
897
|
value: function () {
|
|
795
898
|
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(code, customerId) {
|
|
796
899
|
var _this$store$discount11, _tempOrder$holder, _this$store$summary;
|
|
797
|
-
var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref16, isAvailable, newDiscountList, evaluatedDiscountList, unavailableReason, shouldRetainForLater, normalizedNewDiscountList,
|
|
900
|
+
var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref16, isAvailable, newDiscountList, evaluatedDiscountList, unavailableReason, scannedIds, evaluatedScannedDiscounts, shouldRetainForLater, normalizedNewDiscountList, resolvedDiscountList, _this$store$discount12, _this$store$discount13, retainedDiscounts;
|
|
798
901
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
799
902
|
while (1) switch (_context6.prev = _context6.next) {
|
|
800
903
|
case 0:
|
|
@@ -897,46 +1000,72 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
897
1000
|
isAvailable: false,
|
|
898
1001
|
discountList: this.getDiscountList()
|
|
899
1002
|
}, isAvailable = _ref16.isAvailable, newDiscountList = _ref16.discountList, evaluatedDiscountList = _ref16.evaluatedDiscountList, unavailableReason = _ref16.unavailableReason;
|
|
900
|
-
|
|
1003
|
+
scannedIds = new Set(withScanList.map(function (discount) {
|
|
1004
|
+
return String(discount.id);
|
|
1005
|
+
}));
|
|
1006
|
+
evaluatedScannedDiscounts = (evaluatedDiscountList || withScanList).filter(function (discount) {
|
|
1007
|
+
return scannedIds.has(String(discount.id)) && isCustomerPromotionDiscount(discount) && !getDiscountLifecycleReason(discount);
|
|
1008
|
+
});
|
|
1009
|
+
shouldRetainForLater = !isAvailable && evaluatedScannedDiscounts.length > 0;
|
|
901
1010
|
normalizedNewDiscountList = newDiscountList ? markScannedDiscounts(newDiscountList, withScanList) : undefined;
|
|
902
|
-
retainedDiscountList = evaluatedDiscountList ? markScannedDiscounts(evaluatedDiscountList, withScanList) : normalizedNewDiscountList;
|
|
903
1011
|
resolvedDiscountList = normalizedNewDiscountList || this.getDiscountList();
|
|
904
1012
|
if (!(isAvailable && normalizedNewDiscountList)) {
|
|
905
|
-
_context6.next =
|
|
1013
|
+
_context6.next = 37;
|
|
906
1014
|
break;
|
|
907
1015
|
}
|
|
908
|
-
_context6.next =
|
|
1016
|
+
_context6.next = 31;
|
|
909
1017
|
return (_this$store$discount12 = this.store.discount) === null || _this$store$discount12 === void 0 ? void 0 : _this$store$discount12.setDiscountList(normalizedNewDiscountList);
|
|
910
|
-
case
|
|
911
|
-
|
|
912
|
-
|
|
1018
|
+
case 31:
|
|
1019
|
+
// 实际写回商品时沿用扫码试算的优先级,避免旧商品行的选卡覆盖本次扫码。
|
|
1020
|
+
this.applyDiscount({
|
|
1021
|
+
preferredEntitlementPassIds: withScanList.filter(function (discount) {
|
|
1022
|
+
return isEntitlementPass(discount);
|
|
1023
|
+
}).map(function (discount) {
|
|
1024
|
+
return discount.id;
|
|
1025
|
+
})
|
|
1026
|
+
});
|
|
1027
|
+
_context6.next = 34;
|
|
913
1028
|
return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
914
|
-
case
|
|
1029
|
+
case 34:
|
|
915
1030
|
resolvedDiscountList = this.getDiscountList();
|
|
916
|
-
_context6.next =
|
|
1031
|
+
_context6.next = 45;
|
|
917
1032
|
break;
|
|
918
|
-
case
|
|
919
|
-
if (!
|
|
920
|
-
_context6.next =
|
|
1033
|
+
case 37:
|
|
1034
|
+
if (!shouldRetainForLater) {
|
|
1035
|
+
_context6.next = 45;
|
|
921
1036
|
break;
|
|
922
1037
|
}
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
1038
|
+
// 只合并本次识别的卡券;不把试算产生的其他选券状态写回订单。
|
|
1039
|
+
retainedDiscounts = new Map(this.getDiscountList().map(function (discount) {
|
|
1040
|
+
return [String(discount.id), discount];
|
|
1041
|
+
}));
|
|
1042
|
+
evaluatedScannedDiscounts.forEach(function (discount) {
|
|
1043
|
+
retainedDiscounts.set(String(discount.id), _objectSpread(_objectSpread({}, discount), {}, {
|
|
1044
|
+
isScan: true,
|
|
1045
|
+
isAvailable: false,
|
|
1046
|
+
isSelected: false,
|
|
1047
|
+
reasonCode: discount.reasonCode || 'product_not_applicable',
|
|
1048
|
+
appliedProductDetails: [],
|
|
1049
|
+
savedAmount: 0
|
|
1050
|
+
}));
|
|
1051
|
+
});
|
|
1052
|
+
_context6.next = 42;
|
|
1053
|
+
return (_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.setDiscountList(_toConsumableArray(retainedDiscounts.values()));
|
|
1054
|
+
case 42:
|
|
1055
|
+
_context6.next = 44;
|
|
927
1056
|
return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
928
|
-
case
|
|
1057
|
+
case 44:
|
|
929
1058
|
resolvedDiscountList = this.getDiscountList();
|
|
930
|
-
case
|
|
1059
|
+
case 45:
|
|
931
1060
|
return _context6.abrupt("return", {
|
|
932
1061
|
type: 'clientCalc',
|
|
933
1062
|
isAvailable: isAvailable || false,
|
|
934
1063
|
isAccepted: Boolean(isAvailable || shouldRetainForLater),
|
|
935
1064
|
discountList: resolvedDiscountList,
|
|
936
|
-
scannedDiscountList:
|
|
1065
|
+
scannedDiscountList: evaluatedScannedDiscounts,
|
|
937
1066
|
unavailableReason: unavailableReason
|
|
938
1067
|
});
|
|
939
|
-
case
|
|
1068
|
+
case 46:
|
|
940
1069
|
case "end":
|
|
941
1070
|
return _context6.stop();
|
|
942
1071
|
}
|
|
@@ -952,7 +1081,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
952
1081
|
value: function applyDiscount(options) {
|
|
953
1082
|
var _this$store$discount16,
|
|
954
1083
|
_this$store$summary2,
|
|
955
|
-
|
|
1084
|
+
_this4 = this;
|
|
956
1085
|
var tempOrder = this.store.tempOrder;
|
|
957
1086
|
// 任意 products CRUD 后都应当重算 discount 状态;即使 products 为空,
|
|
958
1087
|
// 也需要让 Rules.calcDiscount 把 DiscountModule 的 isSelected / isAvailable /
|
|
@@ -983,7 +1112,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
983
1112
|
},
|
|
984
1113
|
orderTotalAmount: Number(((_this$store$summary2 = this.store.summary) === null || _this$store$summary2 === void 0 ? void 0 : _this$store$summary2.total_amount) || 0)
|
|
985
1114
|
}, {
|
|
986
|
-
reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids
|
|
1115
|
+
reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids,
|
|
1116
|
+
preferredEntitlementPassIds: options === null || options === void 0 ? void 0 : options.preferredEntitlementPassIds
|
|
987
1117
|
});
|
|
988
1118
|
if (result !== null && result !== void 0 && result.productList) {
|
|
989
1119
|
var previousProductsByUid = indexOrderProductsByUid(tempOrder.products);
|
|
@@ -1008,7 +1138,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1008
1138
|
(_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 || _this$store$discount17.setDiscountList(result.discountList);
|
|
1009
1139
|
}
|
|
1010
1140
|
this.hasActiveCustomerBoundDiscount = (tempOrder.products || []).some(function (product) {
|
|
1011
|
-
return
|
|
1141
|
+
return _this4.productHasCustomerBoundDiscount(product);
|
|
1012
1142
|
});
|
|
1013
1143
|
}
|
|
1014
1144
|
|
|
@@ -1071,7 +1201,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1071
1201
|
var _evaluatePromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
1072
1202
|
var _this$promotionEvalua,
|
|
1073
1203
|
_this$promotionEvalua2,
|
|
1074
|
-
|
|
1204
|
+
_this5 = this;
|
|
1075
1205
|
var tempOrder, strategyConfigs, result, removeSet, _iterator3, _step3, reduce, _iterator6, _step6, _loop2, _iterator4, _step4, _loop, payload;
|
|
1076
1206
|
return _regeneratorRuntime().wrap(function _callee7$(_context9) {
|
|
1077
1207
|
while (1) switch (_context9.prev = _context9.next) {
|
|
@@ -1230,7 +1360,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1230
1360
|
case 6:
|
|
1231
1361
|
_context7.prev = 6;
|
|
1232
1362
|
_context7.next = 9;
|
|
1233
|
-
return
|
|
1363
|
+
return _this5.giftSelectResolver({
|
|
1234
1364
|
strategyId: addAction.strategyId,
|
|
1235
1365
|
strategyName: addAction.strategyName,
|
|
1236
1366
|
giftCount: addAction.giftCount,
|
|
@@ -1265,7 +1395,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1265
1395
|
_context7.next = 26;
|
|
1266
1396
|
break;
|
|
1267
1397
|
}
|
|
1268
|
-
linked =
|
|
1398
|
+
linked = _this5.createLinkedProductAndBooking({
|
|
1269
1399
|
product: gp,
|
|
1270
1400
|
booking: booking
|
|
1271
1401
|
});
|
|
@@ -1595,12 +1725,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1595
1725
|
}, {
|
|
1596
1726
|
key: "rememberPointCardSnapshotCodeCandidates",
|
|
1597
1727
|
value: function rememberPointCardSnapshotCodeCandidates(value) {
|
|
1598
|
-
var
|
|
1728
|
+
var _this6 = this;
|
|
1599
1729
|
collectPointCardSnapshotCodeCandidates(value).forEach(function (_ref18) {
|
|
1600
1730
|
var id = _ref18.id,
|
|
1601
1731
|
code = _ref18.code;
|
|
1602
|
-
if (!
|
|
1603
|
-
|
|
1732
|
+
if (!_this6.pointCardSnapshotCodeCandidates.has(id)) {
|
|
1733
|
+
_this6.pointCardSnapshotCodeCandidates.set(id, code);
|
|
1604
1734
|
}
|
|
1605
1735
|
});
|
|
1606
1736
|
}
|
|
@@ -1807,23 +1937,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1807
1937
|
}, {
|
|
1808
1938
|
key: "calculatePaymentTotal",
|
|
1809
1939
|
value: function calculatePaymentTotal(payments) {
|
|
1810
|
-
var
|
|
1940
|
+
var _this7 = this;
|
|
1811
1941
|
return mapPaymentItemsToOrderPayments(payments, {
|
|
1812
1942
|
includeVoided: false
|
|
1813
1943
|
}).reduce(function (sum, payment) {
|
|
1814
1944
|
if (!isPaidPaymentRecord(payment)) return sum;
|
|
1815
|
-
return sum.plus(
|
|
1945
|
+
return sum.plus(_this7.calculatePaymentEffectiveAmount(payment));
|
|
1816
1946
|
}, new Decimal(0));
|
|
1817
1947
|
}
|
|
1818
1948
|
}, {
|
|
1819
1949
|
key: "calculateOrderPaidPaymentTotal",
|
|
1820
1950
|
value: function calculateOrderPaidPaymentTotal(payments) {
|
|
1821
|
-
var
|
|
1951
|
+
var _this8 = this;
|
|
1822
1952
|
return mapPaymentItemsToOrderPayments(payments, {
|
|
1823
1953
|
includeVoided: false
|
|
1824
1954
|
}).reduce(function (sum, payment) {
|
|
1825
1955
|
if (!isPaidPaymentRecord(payment)) return sum;
|
|
1826
|
-
return sum.plus(
|
|
1956
|
+
return sum.plus(_this8.calculatePaymentGapAmount(payment));
|
|
1827
1957
|
}, new Decimal(0));
|
|
1828
1958
|
}
|
|
1829
1959
|
}, {
|
|
@@ -1959,13 +2089,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1959
2089
|
}, {
|
|
1960
2090
|
key: "calculateDepositPaidAmount",
|
|
1961
2091
|
value: function calculateDepositPaidAmount(payments) {
|
|
1962
|
-
var
|
|
2092
|
+
var _this9 = this;
|
|
1963
2093
|
return (payments || []).reduce(function (sum, payment) {
|
|
1964
2094
|
var paymentRecord = payment;
|
|
1965
2095
|
if (!isPaidPaymentRecord(paymentRecord)) return sum;
|
|
1966
2096
|
var isDepositPayment = paymentRecord.type === 'deposit' || paymentRecord.order_payment_type === 'deposit';
|
|
1967
2097
|
if (!isDepositPayment) return sum;
|
|
1968
|
-
return sum.plus(
|
|
2098
|
+
return sum.plus(_this9.calculatePaymentGapAmount(paymentRecord));
|
|
1969
2099
|
}, new Decimal(0));
|
|
1970
2100
|
}
|
|
1971
2101
|
}, {
|
|
@@ -2002,17 +2132,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2002
2132
|
}, {
|
|
2003
2133
|
key: "getPaymentNumberDevicePrefixSync",
|
|
2004
2134
|
value: function getPaymentNumberDevicePrefixSync() {
|
|
2005
|
-
var
|
|
2135
|
+
var _this10 = this;
|
|
2006
2136
|
return resolvePaymentNumberDevicePrefixFromDeviceId(function (key) {
|
|
2007
|
-
return
|
|
2137
|
+
return _this10.getPaymentNumberAppData(key);
|
|
2008
2138
|
});
|
|
2009
2139
|
}
|
|
2010
2140
|
}, {
|
|
2011
2141
|
key: "getPaymentNumberDevicePrefixAsync",
|
|
2012
2142
|
value: function getPaymentNumberDevicePrefixAsync() {
|
|
2013
|
-
var
|
|
2143
|
+
var _this11 = this;
|
|
2014
2144
|
return resolvePaymentNumberDevicePrefix(function (key) {
|
|
2015
|
-
return
|
|
2145
|
+
return _this11.getPaymentNumberAppData(key);
|
|
2016
2146
|
});
|
|
2017
2147
|
}
|
|
2018
2148
|
}, {
|
|
@@ -2142,16 +2272,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2142
2272
|
}, {
|
|
2143
2273
|
key: "calculatePaidPaymentSummary",
|
|
2144
2274
|
value: function calculatePaidPaymentSummary(payments) {
|
|
2145
|
-
var
|
|
2275
|
+
var _this12 = this;
|
|
2146
2276
|
return (payments || []).reduce(function (summary, payment) {
|
|
2147
2277
|
var paymentRecord = payment;
|
|
2148
2278
|
if (!isPaidPaymentRecord(paymentRecord)) return summary;
|
|
2149
2279
|
return {
|
|
2150
2280
|
customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
|
|
2151
|
-
orderPaidAmount: summary.orderPaidAmount.plus(
|
|
2152
|
-
gapPaidAmount: summary.gapPaidAmount.plus(
|
|
2153
|
-
payServiceChargeAmount: summary.payServiceChargeAmount.plus(
|
|
2154
|
-
roundingAmount: summary.roundingAmount.plus(
|
|
2281
|
+
orderPaidAmount: summary.orderPaidAmount.plus(_this12.calculatePaymentOrderAmount(paymentRecord)),
|
|
2282
|
+
gapPaidAmount: summary.gapPaidAmount.plus(_this12.calculatePaymentGapAmount(paymentRecord)),
|
|
2283
|
+
payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this12.calculatePaymentServiceFee(paymentRecord)),
|
|
2284
|
+
roundingAmount: summary.roundingAmount.plus(_this12.calculatePaymentRoundingAmount(paymentRecord))
|
|
2155
2285
|
};
|
|
2156
2286
|
}, {
|
|
2157
2287
|
customerPaidAmount: new Decimal(0),
|
|
@@ -2358,15 +2488,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2358
2488
|
}, {
|
|
2359
2489
|
key: "normalizeFingerprintValue",
|
|
2360
2490
|
value: function normalizeFingerprintValue(value) {
|
|
2361
|
-
var
|
|
2491
|
+
var _this13 = this;
|
|
2362
2492
|
if (Array.isArray(value)) {
|
|
2363
2493
|
return value.map(function (item) {
|
|
2364
|
-
return
|
|
2494
|
+
return _this13.normalizeFingerprintValue(item);
|
|
2365
2495
|
});
|
|
2366
2496
|
}
|
|
2367
2497
|
if (!value || _typeof(value) !== 'object') return value !== null && value !== void 0 ? value : '';
|
|
2368
2498
|
return Object.keys(value).sort().reduce(function (result, key) {
|
|
2369
|
-
result[key] =
|
|
2499
|
+
result[key] = _this13.normalizeFingerprintValue(value[key]);
|
|
2370
2500
|
return result;
|
|
2371
2501
|
}, {});
|
|
2372
2502
|
}
|
|
@@ -2381,14 +2511,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2381
2511
|
_sku$barcode,
|
|
2382
2512
|
_ref26,
|
|
2383
2513
|
_sku$variant_id,
|
|
2384
|
-
|
|
2514
|
+
_this14 = this;
|
|
2385
2515
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
2386
2516
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
2387
2517
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
2388
2518
|
var _discount$type;
|
|
2389
2519
|
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;
|
|
2390
2520
|
});
|
|
2391
|
-
var
|
|
2521
|
+
var fullCoveragePassType = discountTypes.find(function (type) {
|
|
2522
|
+
return ['entitlement_pass', 'good_pass'].includes(type);
|
|
2523
|
+
});
|
|
2524
|
+
var extensionType = (product === null || product === void 0 ? void 0 : product.extension_type) || fullCoveragePassType || 'normal';
|
|
2392
2525
|
return {
|
|
2393
2526
|
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,
|
|
2394
2527
|
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,
|
|
@@ -2415,7 +2548,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2415
2548
|
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,
|
|
2416
2549
|
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,
|
|
2417
2550
|
num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
|
|
2418
|
-
add_price:
|
|
2551
|
+
add_price: _this14.normalizeFingerprintMoney((_option$add_price = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price !== void 0 ? _option$add_price : option === null || option === void 0 ? void 0 : option.price)
|
|
2419
2552
|
};
|
|
2420
2553
|
})
|
|
2421
2554
|
}),
|
|
@@ -2425,8 +2558,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2425
2558
|
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
2559
|
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,
|
|
2427
2560
|
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),
|
|
2428
|
-
price:
|
|
2429
|
-
bundle_selling_price:
|
|
2561
|
+
price: _this14.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
|
|
2562
|
+
bundle_selling_price: _this14.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
|
|
2430
2563
|
price_type: (_bundle$price_type = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type !== void 0 ? _bundle$price_type : '',
|
|
2431
2564
|
price_type_ext: (_bundle$price_type_ex = bundle === null || bundle === void 0 ? void 0 : bundle.price_type_ext) !== null && _bundle$price_type_ex !== void 0 ? _bundle$price_type_ex : ''
|
|
2432
2565
|
};
|
|
@@ -2436,7 +2569,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2436
2569
|
return {
|
|
2437
2570
|
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
2571
|
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,
|
|
2439
|
-
amount:
|
|
2572
|
+
amount: _this14.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
2440
2573
|
};
|
|
2441
2574
|
}))
|
|
2442
2575
|
};
|
|
@@ -2444,9 +2577,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2444
2577
|
}, {
|
|
2445
2578
|
key: "buildOrderProductsFingerprint",
|
|
2446
2579
|
value: function buildOrderProductsFingerprint(products) {
|
|
2447
|
-
var
|
|
2580
|
+
var _this15 = this;
|
|
2448
2581
|
var items = (products || []).map(function (product) {
|
|
2449
|
-
return
|
|
2582
|
+
return _this15.buildProductFingerprintItem(product);
|
|
2450
2583
|
});
|
|
2451
2584
|
items.sort(function (left, right) {
|
|
2452
2585
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -2468,14 +2601,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2468
2601
|
_sku$barcode2,
|
|
2469
2602
|
_ref36,
|
|
2470
2603
|
_sku$variant_id2,
|
|
2471
|
-
|
|
2604
|
+
_this16 = this;
|
|
2472
2605
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
2473
2606
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
2474
2607
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
2475
2608
|
var _discount$type3;
|
|
2476
2609
|
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;
|
|
2477
2610
|
});
|
|
2478
|
-
var
|
|
2611
|
+
var fullCoveragePassType = discountTypes.find(function (type) {
|
|
2612
|
+
return ['entitlement_pass', 'good_pass'].includes(type);
|
|
2613
|
+
});
|
|
2614
|
+
var extensionType = (product === null || product === void 0 ? void 0 : product.extension_type) || fullCoveragePassType || 'normal';
|
|
2479
2615
|
return {
|
|
2480
2616
|
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,
|
|
2481
2617
|
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,
|
|
@@ -2499,7 +2635,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2499
2635
|
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,
|
|
2500
2636
|
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,
|
|
2501
2637
|
num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
|
|
2502
|
-
add_price:
|
|
2638
|
+
add_price: _this16.normalizeFingerprintMoney((_option$add_price2 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price2 !== void 0 ? _option$add_price2 : option === null || option === void 0 ? void 0 : option.price)
|
|
2503
2639
|
};
|
|
2504
2640
|
})
|
|
2505
2641
|
}),
|
|
@@ -2513,14 +2649,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2513
2649
|
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),
|
|
2514
2650
|
price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
|
|
2515
2651
|
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 : '',
|
|
2516
|
-
option:
|
|
2652
|
+
option: _this16.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
|
|
2517
2653
|
var _ref44, _option$id3, _option$option_group_5, _ref45, _option$option_group_6, _option$num3, _option$add_price3;
|
|
2518
2654
|
return {
|
|
2519
2655
|
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,
|
|
2520
2656
|
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,
|
|
2521
2657
|
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,
|
|
2522
2658
|
num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
|
|
2523
|
-
add_price:
|
|
2659
|
+
add_price: _this16.normalizeFingerprintMoney((_option$add_price3 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price3 !== void 0 ? _option$add_price3 : option === null || option === void 0 ? void 0 : option.price)
|
|
2524
2660
|
};
|
|
2525
2661
|
}))
|
|
2526
2662
|
};
|
|
@@ -2530,7 +2666,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2530
2666
|
return {
|
|
2531
2667
|
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
2668
|
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,
|
|
2533
|
-
amount:
|
|
2669
|
+
amount: _this16.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
2534
2670
|
};
|
|
2535
2671
|
}))
|
|
2536
2672
|
};
|
|
@@ -2538,9 +2674,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2538
2674
|
}, {
|
|
2539
2675
|
key: "buildOrderProductsStructuralFingerprint",
|
|
2540
2676
|
value: function buildOrderProductsStructuralFingerprint(products) {
|
|
2541
|
-
var
|
|
2677
|
+
var _this17 = this;
|
|
2542
2678
|
var items = (products || []).map(function (product) {
|
|
2543
|
-
return
|
|
2679
|
+
return _this17.buildProductStructuralFingerprintItem(product);
|
|
2544
2680
|
});
|
|
2545
2681
|
items.sort(function (left, right) {
|
|
2546
2682
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -2992,9 +3128,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2992
3128
|
}, {
|
|
2993
3129
|
key: "sanitizeTempOrderProducts",
|
|
2994
3130
|
value: function sanitizeTempOrderProducts(tempOrder) {
|
|
2995
|
-
var
|
|
3131
|
+
var _this18 = this;
|
|
2996
3132
|
tempOrder.products = (tempOrder.products || []).map(function (product) {
|
|
2997
|
-
return
|
|
3133
|
+
return _this18.sanitizeOrderProductForTempOrder(_this18.normalizeVirtualSettlementProductIfEnabled(product));
|
|
2998
3134
|
});
|
|
2999
3135
|
this.syncTempOrderSettlementState(tempOrder);
|
|
3000
3136
|
ensureUniqueProductLineUids(tempOrder);
|
|
@@ -3114,7 +3250,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3114
3250
|
}, {
|
|
3115
3251
|
key: "syncLinkedBookingHoldersToProducts",
|
|
3116
3252
|
value: function syncLinkedBookingHoldersToProducts(tempOrder) {
|
|
3117
|
-
var
|
|
3253
|
+
var _this19 = this;
|
|
3118
3254
|
var bookings = tempOrder.bookings || [];
|
|
3119
3255
|
var products = tempOrder.products || [];
|
|
3120
3256
|
if (!bookings.length || !products.length) return;
|
|
@@ -3139,7 +3275,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3139
3275
|
var bookingUid = product.booking_uid || ((_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.booking_uid);
|
|
3140
3276
|
var linkedBooking = (productUid !== undefined && productUid !== null && String(productUid) !== '' ? bookingByProductUid.get(String(productUid)) : undefined) || (bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '' ? bookingByBookingUid.get(String(bookingUid)) : undefined);
|
|
3141
3277
|
if (linkedBooking) {
|
|
3142
|
-
|
|
3278
|
+
_this19.setProductHolderFromBooking(product, linkedBooking);
|
|
3143
3279
|
}
|
|
3144
3280
|
});
|
|
3145
3281
|
}
|
|
@@ -3267,9 +3403,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3267
3403
|
}, {
|
|
3268
3404
|
key: "findBookingIndexByUniqueIdentificationNumber",
|
|
3269
3405
|
value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
|
|
3270
|
-
var
|
|
3406
|
+
var _this20 = this;
|
|
3271
3407
|
return (tempOrder.bookings || []).findIndex(function (booking) {
|
|
3272
|
-
return
|
|
3408
|
+
return _this20.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
|
|
3273
3409
|
});
|
|
3274
3410
|
}
|
|
3275
3411
|
}, {
|
|
@@ -3277,12 +3413,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3277
3413
|
value: function removeLinkedBookingsForProduct(tempOrder, product) {
|
|
3278
3414
|
var _product$metadata5,
|
|
3279
3415
|
_product$metadata6,
|
|
3280
|
-
|
|
3416
|
+
_this21 = this;
|
|
3281
3417
|
var productUid = (product === null || product === void 0 || (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
3282
3418
|
var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.booking_uid);
|
|
3283
3419
|
if (!productUid && !bookingUid) return;
|
|
3284
3420
|
tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
|
|
3285
|
-
var currentBookingUid =
|
|
3421
|
+
var currentBookingUid = _this21.getBookingUniqueIdentificationNumber(booking);
|
|
3286
3422
|
if (bookingUid && currentBookingUid === String(bookingUid)) return false;
|
|
3287
3423
|
if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
|
|
3288
3424
|
return true;
|
|
@@ -3584,7 +3720,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3584
3720
|
}, {
|
|
3585
3721
|
key: "removeSalesNotesForMissingProductLines",
|
|
3586
3722
|
value: function removeSalesNotesForMissingProductLines(tempOrder) {
|
|
3587
|
-
var
|
|
3723
|
+
var _this22 = this;
|
|
3588
3724
|
var state = this.ensureSalesNotesRuntimeState(tempOrder);
|
|
3589
3725
|
if (!state.loaded || !Array.isArray(tempOrder.notes) || tempOrder.notes.length === 0) {
|
|
3590
3726
|
return;
|
|
@@ -3596,7 +3732,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3596
3732
|
return typeof uid === 'string' && uid.length > 0;
|
|
3597
3733
|
}));
|
|
3598
3734
|
var nextNotes = tempOrder.notes.filter(function (note) {
|
|
3599
|
-
var primary =
|
|
3735
|
+
var primary = _this22.getSalesNotePrimaryRelation(note);
|
|
3600
3736
|
if (!primary || primary.target_type !== 'order_detail') return true;
|
|
3601
3737
|
return remainingProductUids.has(primary.target_uuid);
|
|
3602
3738
|
});
|
|
@@ -3608,7 +3744,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3608
3744
|
key: "setSalesNoteOnTempOrder",
|
|
3609
3745
|
value: function setSalesNoteOnTempOrder(tempOrder, input) {
|
|
3610
3746
|
var _input$target,
|
|
3611
|
-
|
|
3747
|
+
_this23 = this,
|
|
3612
3748
|
_tempOrder$shop_order;
|
|
3613
3749
|
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
3614
3750
|
var note_type = String(input.note_type || '').trim();
|
|
@@ -3632,7 +3768,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3632
3768
|
var notes = tempOrder.notes || [];
|
|
3633
3769
|
// 当前 allergy policy 固定同一商品行只保留一条;业务调用方不参与去重规则。
|
|
3634
3770
|
var existingIndex = policy.uniquePerPrimaryTarget ? notes.findIndex(function (note) {
|
|
3635
|
-
var primary =
|
|
3771
|
+
var primary = _this23.getSalesNotePrimaryRelation(note);
|
|
3636
3772
|
return note.note_type === note_type && (primary === null || primary === void 0 ? void 0 : primary.target_type) === 'order_detail' && primary.target_uuid === target_uuid;
|
|
3637
3773
|
}) : -1;
|
|
3638
3774
|
var existing = existingIndex >= 0 ? notes[existingIndex] : null;
|
|
@@ -3904,7 +4040,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3904
4040
|
value: function isCustomerBoundDiscount(discount) {
|
|
3905
4041
|
var _discount$type5;
|
|
3906
4042
|
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;
|
|
3907
|
-
return type === 'good_pass' || type === 'discount_card' || type === 'product_discount_card';
|
|
4043
|
+
return type === 'entitlement_pass' || type === 'good_pass' || type === 'discount_card' || type === 'product_discount_card';
|
|
3908
4044
|
}
|
|
3909
4045
|
}, {
|
|
3910
4046
|
key: "shouldKeepCustomerBoundDiscountAfterCustomerChange",
|
|
@@ -3914,15 +4050,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3914
4050
|
}, {
|
|
3915
4051
|
key: "productHasCustomerBoundDiscount",
|
|
3916
4052
|
value: function productHasCustomerBoundDiscount(product) {
|
|
3917
|
-
var
|
|
4053
|
+
var _this24 = this;
|
|
3918
4054
|
if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
|
|
3919
|
-
return
|
|
4055
|
+
return _this24.isCustomerBoundDiscount(discount);
|
|
3920
4056
|
})) {
|
|
3921
4057
|
return true;
|
|
3922
4058
|
}
|
|
3923
4059
|
return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
|
|
3924
4060
|
return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
|
|
3925
|
-
return
|
|
4061
|
+
return _this24.isCustomerBoundDiscount(discount);
|
|
3926
4062
|
});
|
|
3927
4063
|
});
|
|
3928
4064
|
}
|
|
@@ -3931,18 +4067,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3931
4067
|
value: function shouldSkipDiscountCalculation(tempOrder) {
|
|
3932
4068
|
var _this$store$discount20,
|
|
3933
4069
|
_this$store$discount21,
|
|
3934
|
-
|
|
4070
|
+
_this25 = this;
|
|
3935
4071
|
if (this.hasActiveCustomerBoundDiscount) return false;
|
|
3936
4072
|
var discountList = ((_this$store$discount20 = this.store.discount) === null || _this$store$discount20 === void 0 || (_this$store$discount21 = _this$store$discount20.getDiscountList) === null || _this$store$discount21 === void 0 ? void 0 : _this$store$discount21.call(_this$store$discount20)) || [];
|
|
3937
4073
|
if (discountList.length > 0) return false;
|
|
3938
4074
|
return !(tempOrder.products || []).some(function (product) {
|
|
3939
|
-
return
|
|
4075
|
+
return _this25.productHasCustomerBoundDiscount(product);
|
|
3940
4076
|
});
|
|
3941
4077
|
}
|
|
3942
4078
|
}, {
|
|
3943
4079
|
key: "clearCustomerBoundDiscounts",
|
|
3944
4080
|
value: function clearCustomerBoundDiscounts(tempOrder) {
|
|
3945
|
-
var
|
|
4081
|
+
var _this26 = this,
|
|
3946
4082
|
_discountModule$getDi,
|
|
3947
4083
|
_discountModule$getOr,
|
|
3948
4084
|
_discountModule$setDi,
|
|
@@ -3951,7 +4087,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3951
4087
|
var filterDiscountList = function filterDiscountList(discountList) {
|
|
3952
4088
|
if (!Array.isArray(discountList)) return [];
|
|
3953
4089
|
return discountList.filter(function (discount) {
|
|
3954
|
-
var shouldRemove =
|
|
4090
|
+
var shouldRemove = _this26.isCustomerBoundDiscount(discount);
|
|
3955
4091
|
if (shouldRemove) didRemoveCustomerBoundDiscount = true;
|
|
3956
4092
|
return !shouldRemove;
|
|
3957
4093
|
});
|
|
@@ -3978,12 +4114,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3978
4114
|
var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
|
|
3979
4115
|
var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
|
|
3980
4116
|
var nextDiscounts = currentDiscounts.filter(function (discount) {
|
|
3981
|
-
if (
|
|
3982
|
-
return !
|
|
4117
|
+
if (_this26.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
4118
|
+
return !_this26.isCustomerBoundDiscount(discount);
|
|
3983
4119
|
});
|
|
3984
4120
|
var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
|
|
3985
|
-
if (
|
|
3986
|
-
return !
|
|
4121
|
+
if (_this26.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
4122
|
+
return !_this26.isCustomerBoundDiscount(discount);
|
|
3987
4123
|
});
|
|
3988
4124
|
void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
|
|
3989
4125
|
void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
|
|
@@ -4147,10 +4283,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4147
4283
|
}, {
|
|
4148
4284
|
key: "setOrderPayments",
|
|
4149
4285
|
value: function setOrderPayments(payments) {
|
|
4150
|
-
var
|
|
4286
|
+
var _this27 = this;
|
|
4151
4287
|
var tempOrder = this.ensureTempOrder();
|
|
4152
4288
|
tempOrder.payments = mapPaymentItemsToOrderPayments((payments || []).map(function (payment) {
|
|
4153
|
-
return
|
|
4289
|
+
return _this27.normalizePaymentSource(payment, {
|
|
4154
4290
|
defaultPaid: false
|
|
4155
4291
|
});
|
|
4156
4292
|
}));
|
|
@@ -4205,7 +4341,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4205
4341
|
}, {
|
|
4206
4342
|
key: "addOrderPaymentWithDevicePrefix",
|
|
4207
4343
|
value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
|
|
4208
|
-
var
|
|
4344
|
+
var _this28 = this;
|
|
4209
4345
|
this.logInfo('addOrderPayment', {
|
|
4210
4346
|
payment: payment
|
|
4211
4347
|
});
|
|
@@ -4223,7 +4359,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4223
4359
|
void this.recalculateSummary({
|
|
4224
4360
|
createIfMissing: true
|
|
4225
4361
|
}).catch(function (error) {
|
|
4226
|
-
|
|
4362
|
+
_this28.logError('recalculate summary after addOrderPayment failed', {
|
|
4227
4363
|
error: error instanceof Error ? error.message : String(error)
|
|
4228
4364
|
});
|
|
4229
4365
|
});
|
|
@@ -4336,7 +4472,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4336
4472
|
}, {
|
|
4337
4473
|
key: "applyPaymentLifecycleChange",
|
|
4338
4474
|
value: function applyPaymentLifecycleChange(tempOrder, options) {
|
|
4339
|
-
var
|
|
4475
|
+
var _this29 = this;
|
|
4340
4476
|
this.updateTempOrderPaymentStatus(tempOrder);
|
|
4341
4477
|
if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
|
|
4342
4478
|
this.persistTempOrder();
|
|
@@ -4346,7 +4482,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4346
4482
|
void this.recalculateSummary({
|
|
4347
4483
|
createIfMissing: true
|
|
4348
4484
|
}).catch(function (error) {
|
|
4349
|
-
|
|
4485
|
+
_this29.logError("recalculate summary after ".concat(logContext, " failed"), {
|
|
4350
4486
|
error: error instanceof Error ? error.message : String(error)
|
|
4351
4487
|
});
|
|
4352
4488
|
});
|
|
@@ -4390,7 +4526,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4390
4526
|
}, {
|
|
4391
4527
|
key: "updateVoucherOrderPayments",
|
|
4392
4528
|
value: function updateVoucherOrderPayments(payments, options) {
|
|
4393
|
-
var
|
|
4529
|
+
var _this30 = this;
|
|
4394
4530
|
var tempOrder = this.ensureTempOrder();
|
|
4395
4531
|
var isOrderPaymentType = function isOrderPaymentType(value) {
|
|
4396
4532
|
return value === 'normal' || value === 'deposit';
|
|
@@ -4425,7 +4561,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4425
4561
|
});
|
|
4426
4562
|
};
|
|
4427
4563
|
var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
|
|
4428
|
-
return
|
|
4564
|
+
return _this30.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
|
|
4429
4565
|
defaultPaid: false,
|
|
4430
4566
|
devicePrefix: options === null || options === void 0 ? void 0 : options.devicePrefix
|
|
4431
4567
|
});
|
|
@@ -4478,7 +4614,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4478
4614
|
void this.recalculateSummary({
|
|
4479
4615
|
createIfMissing: true
|
|
4480
4616
|
}).catch(function (error) {
|
|
4481
|
-
|
|
4617
|
+
_this30.logError('recalculate summary after updateVoucherOrderPayments failed', {
|
|
4482
4618
|
error: error instanceof Error ? error.message : String(error)
|
|
4483
4619
|
});
|
|
4484
4620
|
});
|
|
@@ -4536,7 +4672,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4536
4672
|
key: "shouldMergeProductToOrder",
|
|
4537
4673
|
value: function shouldMergeProductToOrder(params) {
|
|
4538
4674
|
var _this$orderHooks,
|
|
4539
|
-
|
|
4675
|
+
_this31 = this;
|
|
4540
4676
|
var onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
|
|
4541
4677
|
if (!onBeforeMergeProductToOrder) return true;
|
|
4542
4678
|
var result = onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
@@ -4544,7 +4680,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4544
4680
|
}));
|
|
4545
4681
|
if (result && _typeof(result) === 'object' && typeof result.then === 'function') {
|
|
4546
4682
|
return Promise.resolve(result).then(function (resolved) {
|
|
4547
|
-
return
|
|
4683
|
+
return _this31.normalizeShouldMergeProductResult(resolved);
|
|
4548
4684
|
});
|
|
4549
4685
|
}
|
|
4550
4686
|
return this.normalizeShouldMergeProductResult(result);
|
|
@@ -4745,7 +4881,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4745
4881
|
_metadata,
|
|
4746
4882
|
_productToAdd$metadat,
|
|
4747
4883
|
_origin,
|
|
4748
|
-
|
|
4884
|
+
_this32 = this;
|
|
4749
4885
|
var linked = booking ? this.createLinkedProductAndBooking({
|
|
4750
4886
|
product: product,
|
|
4751
4887
|
booking: booking
|
|
@@ -4772,18 +4908,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4772
4908
|
}
|
|
4773
4909
|
normalizedIncoming.discount_list = normalizeOrderProductDiscountList(normalizedIncoming.discount_list);
|
|
4774
4910
|
var hasIncomingGoodPass = this.hasGoodPassDiscount(normalizedIncoming);
|
|
4911
|
+
var hasIncomingEntitlementPass = this.hasEntitlementPassDiscount(normalizedIncoming);
|
|
4912
|
+
var isIncomingEntitlementAppend = this.isRuntimeEntitlementAppend(productToAdd, tempOrder);
|
|
4913
|
+
var isIncomingPersistedEntitlementPass = hasIncomingEntitlementPass && this.isPersistedProductLine(normalizedIncoming);
|
|
4775
4914
|
var hasIncomingProductNote = this.hasOrderProductLineNote(normalizedIncoming);
|
|
4776
4915
|
var hasIncomingManualProductDiscount = isManualProductDiscountProduct(normalizedIncoming);
|
|
4777
4916
|
var hasIncomingBookingUid = this.hasLinkedBookingUid(productToAdd) || this.hasLinkedBookingUid(normalizedIncoming);
|
|
4778
4917
|
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;
|
|
4779
|
-
var shouldForceNewLine = disableMerge || !!booking ||
|
|
4780
|
-
var matchedIndex =
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
if (
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
if (
|
|
4918
|
+
var shouldForceNewLine = disableMerge || !!booking || hasIncomingGoodPass || isIncomingPersistedEntitlementPass || hasIncomingBookingUid || isIncomingCustomItem || isWeighingProduct;
|
|
4919
|
+
var matchedIndex = shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
4920
|
+
if (_this32.hasGoodPassDiscount(item)) return false;
|
|
4921
|
+
var isRuntimeEntitlementPass = _this32.isRuntimeEntitlementAppend(item, tempOrder);
|
|
4922
|
+
if (isIncomingEntitlementAppend !== isRuntimeEntitlementPass) {
|
|
4923
|
+
return false;
|
|
4924
|
+
}
|
|
4925
|
+
if (isIncomingEntitlementAppend && _this32.isPersistedProductLine(item)) {
|
|
4926
|
+
return false;
|
|
4927
|
+
}
|
|
4928
|
+
var hasExistingProductNote = _this32.hasOrderProductLineNote(item);
|
|
4929
|
+
if ((hasIncomingProductNote || hasExistingProductNote) && (!isRuntimeEntitlementPass || String(normalizedIncoming.note || '').trim() !== String(item.note || '').trim())) {
|
|
4930
|
+
return false;
|
|
4931
|
+
}
|
|
4932
|
+
var hasExistingManualProductDiscount = isManualProductDiscountProduct(item);
|
|
4933
|
+
if (isRuntimeEntitlementPass && !_this32.hasSameEntitlementMergePriceConfig(normalizedIncoming, item)) {
|
|
4934
|
+
return false;
|
|
4935
|
+
}
|
|
4936
|
+
if ((hasIncomingManualProductDiscount || hasExistingManualProductDiscount) && !isRuntimeEntitlementPass) {
|
|
4937
|
+
return false;
|
|
4938
|
+
}
|
|
4939
|
+
if (_this32.isPersistedProductLine(item)) return false;
|
|
4787
4940
|
if (item.product_id !== productToAdd.product_id) return false;
|
|
4788
4941
|
if (item.product_variant_id !== productToAdd.product_variant_id) return false;
|
|
4789
4942
|
var existedFingerprint = buildProductLineFingerprint(getProductSkuOptions(item), item.product_bundle);
|
|
@@ -4794,7 +4947,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4794
4947
|
var commitProductLine = function commitProductLine(shouldMerge) {
|
|
4795
4948
|
var committedProduct;
|
|
4796
4949
|
if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
|
|
4797
|
-
|
|
4950
|
+
_this32.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
|
|
4798
4951
|
if (linked) {
|
|
4799
4952
|
normalizedIncoming.booking_uid = linked.bookingUid;
|
|
4800
4953
|
normalizedIncoming.metadata = _objectSpread(_objectSpread({}, normalizedIncoming.metadata || {}), {}, {
|
|
@@ -4812,7 +4965,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4812
4965
|
var _targetProduct$metada;
|
|
4813
4966
|
var targetProduct = matchedProduct;
|
|
4814
4967
|
var targetUid = (_targetProduct$metada = targetProduct.metadata) === null || _targetProduct$metada === void 0 ? void 0 : _targetProduct$metada.unique_identification_number;
|
|
4815
|
-
var normalizedProduct =
|
|
4968
|
+
var normalizedProduct = _this32.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(targetProduct, normalizeOrderProduct(_objectSpread(_objectSpread({}, productToAdd), {}, {
|
|
4816
4969
|
metadata: _objectSpread(_objectSpread({}, productToAdd.metadata || {}), {}, {
|
|
4817
4970
|
unique_identification_number: targetUid
|
|
4818
4971
|
})
|
|
@@ -4835,7 +4988,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4835
4988
|
order_detail_id: targetProduct.order_detail_id,
|
|
4836
4989
|
num: nextNum
|
|
4837
4990
|
});
|
|
4838
|
-
|
|
4991
|
+
_this32.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
|
|
4839
4992
|
committedProduct = tempOrder.products[matchedIndex];
|
|
4840
4993
|
if (matchedIndex !== tempOrder.products.length - 1) {
|
|
4841
4994
|
var mergedProduct = tempOrder.products[matchedIndex];
|
|
@@ -4945,7 +5098,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4945
5098
|
key: "addProductToOrder",
|
|
4946
5099
|
value: (function () {
|
|
4947
5100
|
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(product, booking, options) {
|
|
4948
|
-
var
|
|
5101
|
+
var _this33 = this;
|
|
4949
5102
|
var tempOrder, salesNoteDrafts, mutationSnapshot, attachSalesNoteDrafts, rollbackProductAndNotesMutation, insertAfterProductUid, anchorIndex, insertAtIndex, _ref71, _productRecord$num, productRecord, splitCount, i, splitLine, committedProduct, _committedProduct, _committedProduct2;
|
|
4950
5103
|
return _regeneratorRuntime().wrap(function _callee23$(_context25) {
|
|
4951
5104
|
while (1) switch (_context25.prev = _context25.next) {
|
|
@@ -4974,7 +5127,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4974
5127
|
throw new Error('[Order Notes] 商品行缺少 unique_identification_number');
|
|
4975
5128
|
}
|
|
4976
5129
|
salesNoteDrafts.forEach(function (draft) {
|
|
4977
|
-
|
|
5130
|
+
_this33.setSalesNoteOnTempOrder(tempOrder, {
|
|
4978
5131
|
note_type: draft.note_type,
|
|
4979
5132
|
target: {
|
|
4980
5133
|
target_type: 'order_detail',
|
|
@@ -5208,45 +5361,99 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5208
5361
|
return addProductsToOrder;
|
|
5209
5362
|
}())
|
|
5210
5363
|
}, {
|
|
5211
|
-
key: "
|
|
5212
|
-
value: function
|
|
5364
|
+
key: "getFullCoveragePassDiscounts",
|
|
5365
|
+
value: function getFullCoveragePassDiscounts(product) {
|
|
5213
5366
|
var _product$_extend;
|
|
5214
|
-
var
|
|
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 = [];
|
|
5367
|
+
var discountList = _toConsumableArray(product.discount_list || []);
|
|
5219
5368
|
(product.product_bundle || []).forEach(function (item) {
|
|
5220
|
-
|
|
5369
|
+
discountList.push.apply(discountList, _toConsumableArray((item === null || item === void 0 ? void 0 : item.discount_list) || []));
|
|
5221
5370
|
});
|
|
5222
5371
|
((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) {
|
|
5223
|
-
|
|
5372
|
+
discountList.push.apply(discountList, _toConsumableArray((item === null || item === void 0 ? void 0 : item.discount_list) || []));
|
|
5224
5373
|
});
|
|
5225
|
-
return
|
|
5226
|
-
return (item
|
|
5374
|
+
return discountList.filter(function (item) {
|
|
5375
|
+
return isFullCoveragePass(item);
|
|
5376
|
+
});
|
|
5377
|
+
}
|
|
5378
|
+
}, {
|
|
5379
|
+
key: "hasEntitlementPassDiscount",
|
|
5380
|
+
value: function hasEntitlementPassDiscount(product) {
|
|
5381
|
+
return this.getFullCoveragePassDiscounts(product).some(function (item) {
|
|
5382
|
+
return isEntitlementPass(item);
|
|
5227
5383
|
});
|
|
5228
5384
|
}
|
|
5385
|
+
}, {
|
|
5386
|
+
key: "hasGoodPassDiscount",
|
|
5387
|
+
value: function hasGoodPassDiscount(product) {
|
|
5388
|
+
return this.getFullCoveragePassDiscounts(product).some(function (item) {
|
|
5389
|
+
return !isEntitlementPass(item);
|
|
5390
|
+
});
|
|
5391
|
+
}
|
|
5392
|
+
}, {
|
|
5393
|
+
key: "isPersistedProductLine",
|
|
5394
|
+
value: function isPersistedProductLine(product) {
|
|
5395
|
+
var _product$metadata11;
|
|
5396
|
+
return product.order_detail_id !== undefined && product.order_detail_id !== null && product.order_detail_id !== '' || ((_product$metadata11 = product.metadata) === null || _product$metadata11 === void 0 ? void 0 : _product$metadata11.is_edit_for_runtime) === true;
|
|
5397
|
+
}
|
|
5398
|
+
}, {
|
|
5399
|
+
key: "isRuntimeEntitlementAppend",
|
|
5400
|
+
value: function isRuntimeEntitlementAppend(product, tempOrder) {
|
|
5401
|
+
var _product$metadata$uni, _product$metadata12, _tempOrder$_extend10, _product$_origin;
|
|
5402
|
+
if (this.isPersistedProductLine(product)) return false;
|
|
5403
|
+
var uid = (_product$metadata$uni = (_product$metadata12 = product.metadata) === null || _product$metadata12 === void 0 ? void 0 : _product$metadata12.unique_identification_number) !== null && _product$metadata$uni !== void 0 ? _product$metadata$uni : product.unique_identification_number;
|
|
5404
|
+
var storedOrigin = uid !== undefined && uid !== null && uid !== '' ? (_tempOrder$_extend10 = tempOrder._extend) === null || _tempOrder$_extend10 === void 0 || (_tempOrder$_extend10 = _tempOrder$_extend10.productsByUid) === null || _tempOrder$_extend10 === void 0 || (_tempOrder$_extend10 = _tempOrder$_extend10[String(uid)]) === null || _tempOrder$_extend10 === void 0 ? void 0 : _tempOrder$_extend10.origin : undefined;
|
|
5405
|
+
return Boolean((product === null || product === void 0 || (_product$_origin = product._origin) === null || _product$_origin === void 0 ? void 0 : _product$_origin.__entitlementPassRuntimeAppend) === true || (storedOrigin === null || storedOrigin === void 0 ? void 0 : storedOrigin.__entitlementPassRuntimeAppend) === true);
|
|
5406
|
+
}
|
|
5407
|
+
}, {
|
|
5408
|
+
key: "hasSameEntitlementMergePriceConfig",
|
|
5409
|
+
value: function hasSameEntitlementMergePriceConfig(incoming, existing) {
|
|
5410
|
+
var _this34 = this;
|
|
5411
|
+
var buildPriceConfig = function buildPriceConfig(product) {
|
|
5412
|
+
var metadata = product.metadata || {};
|
|
5413
|
+
var bundle = (product.product_bundle || []).map(function (item) {
|
|
5414
|
+
var _ref73, _item$bundle_id, _ref74, _ref75, _item$bundle_product_, _ref76, _item$bundle_variant_, _ref77, _item$price_type, _ref78, _item$price_type_ext;
|
|
5415
|
+
return {
|
|
5416
|
+
bundle_id: (_ref73 = (_item$bundle_id = item.bundle_id) !== null && _item$bundle_id !== void 0 ? _item$bundle_id : item.id) !== null && _ref73 !== void 0 ? _ref73 : null,
|
|
5417
|
+
bundle_product_id: (_ref74 = (_ref75 = (_item$bundle_product_ = item.bundle_product_id) !== null && _item$bundle_product_ !== void 0 ? _item$bundle_product_ : item._bundle_product_id) !== null && _ref75 !== void 0 ? _ref75 : item.product_id) !== null && _ref74 !== void 0 ? _ref74 : null,
|
|
5418
|
+
bundle_variant_id: (_ref76 = (_item$bundle_variant_ = item.bundle_variant_id) !== null && _item$bundle_variant_ !== void 0 ? _item$bundle_variant_ : item.product_variant_id) !== null && _ref76 !== void 0 ? _ref76 : 0,
|
|
5419
|
+
price_type: (_ref77 = (_item$price_type = item.price_type) !== null && _item$price_type !== void 0 ? _item$price_type : item.custom_price_type) !== null && _ref77 !== void 0 ? _ref77 : '',
|
|
5420
|
+
price_type_ext: (_ref78 = (_item$price_type_ext = item.price_type_ext) !== null && _item$price_type_ext !== void 0 ? _item$price_type_ext : item.custom_price_type_ext) !== null && _ref78 !== void 0 ? _ref78 : ''
|
|
5421
|
+
};
|
|
5422
|
+
}).sort(function (left, right) {
|
|
5423
|
+
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
5424
|
+
});
|
|
5425
|
+
return JSON.stringify({
|
|
5426
|
+
original_price: _this34.normalizeFingerprintMoney(product.original_price),
|
|
5427
|
+
source_product_price: _this34.normalizeFingerprintMoney(metadata.source_product_price),
|
|
5428
|
+
main_product_original_price: _this34.normalizeFingerprintMoney(metadata.main_product_original_price),
|
|
5429
|
+
price_override: _this34.normalizeFingerprintMoney(metadata.price_override),
|
|
5430
|
+
is_manual_discount: Boolean(metadata.is_manual_discount),
|
|
5431
|
+
bundle: bundle
|
|
5432
|
+
});
|
|
5433
|
+
};
|
|
5434
|
+
return buildPriceConfig(incoming) === buildPriceConfig(existing);
|
|
5435
|
+
}
|
|
5229
5436
|
}, {
|
|
5230
5437
|
key: "getBundleRuntimeIdentity",
|
|
5231
5438
|
value: function getBundleRuntimeIdentity(bundle) {
|
|
5232
|
-
var
|
|
5439
|
+
var _ref79, _bundle$bundle_id2, _ref80, _bundle$bundle_group_2, _ref81, _ref82, _bundle$bundle_produc3, _ref83, _bundle$bundle_varian3;
|
|
5233
5440
|
if (!bundle || _typeof(bundle) !== 'object') return '';
|
|
5234
|
-
return [(
|
|
5441
|
+
return [(_ref79 = (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id) !== null && _ref79 !== void 0 ? _ref79 : '', (_ref80 = (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id) !== null && _ref80 !== void 0 ? _ref80 : '', (_ref81 = (_ref82 = (_bundle$bundle_produc3 = bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle._bundle_product_id) !== null && _ref82 !== void 0 ? _ref82 : bundle.product_id) !== null && _ref81 !== void 0 ? _ref81 : '', (_ref83 = (_bundle$bundle_varian3 = bundle.bundle_variant_id) !== null && _bundle$bundle_varian3 !== void 0 ? _bundle$bundle_varian3 : bundle.product_variant_id) !== null && _ref83 !== void 0 ? _ref83 : 0].join('|');
|
|
5235
5442
|
}
|
|
5236
5443
|
}, {
|
|
5237
5444
|
key: "preservePersistedBundlePriceFields",
|
|
5238
5445
|
value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
|
|
5239
|
-
var
|
|
5446
|
+
var _this35 = this;
|
|
5240
5447
|
if (!Array.isArray(nextBundles)) return nextBundles;
|
|
5241
5448
|
if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
|
|
5242
5449
|
var previousByIdentity = new Map();
|
|
5243
5450
|
previousBundles.forEach(function (bundle) {
|
|
5244
|
-
var identity =
|
|
5451
|
+
var identity = _this35.getBundleRuntimeIdentity(bundle);
|
|
5245
5452
|
if (identity) previousByIdentity.set(identity, bundle);
|
|
5246
5453
|
});
|
|
5247
5454
|
return nextBundles.map(function (bundle, index) {
|
|
5248
5455
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
5249
|
-
var previous = previousByIdentity.get(
|
|
5456
|
+
var previous = previousByIdentity.get(_this35.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
|
|
5250
5457
|
if (!previous || _typeof(previous) !== 'object') return bundle;
|
|
5251
5458
|
return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
|
|
5252
5459
|
cover: previous.cover
|
|
@@ -5382,13 +5589,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5382
5589
|
delete nextProduct.metadata.main_product_original_price;
|
|
5383
5590
|
delete nextProduct.metadata.price_schema_version;
|
|
5384
5591
|
} else if (callerChangesLineConfiguration && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
5385
|
-
var
|
|
5592
|
+
var _ref84, _targetProduct$metada10, _targetProduct$metada11, _ref85, _targetProduct$metada12, _targetProduct$metada13, _targetProduct$metada14;
|
|
5386
5593
|
// 仅 option / bundle 变化时,保留历史 source 和主商品折扣金额,
|
|
5387
5594
|
// 但必须让 original 与 selling 一起随新的 option 金额移动。
|
|
5388
5595
|
var previousOptionSum = sumOptionUnitPrice(getProductSkuOptions(targetProduct));
|
|
5389
5596
|
var nextOptionSum = sumOptionUnitPrice(getProductSkuOptions(nextProduct));
|
|
5390
|
-
var _previousMainOriginal = new Decimal(Number((
|
|
5391
|
-
var _previousMainSelling = new Decimal(Number((
|
|
5597
|
+
var _previousMainOriginal = new Decimal(Number((_ref84 = (_targetProduct$metada10 = (_targetProduct$metada11 = targetProduct.metadata) === null || _targetProduct$metada11 === void 0 ? void 0 : _targetProduct$metada11.main_product_original_price) !== null && _targetProduct$metada10 !== void 0 ? _targetProduct$metada10 : targetProduct.original_price) !== null && _ref84 !== void 0 ? _ref84 : 0) || 0);
|
|
5598
|
+
var _previousMainSelling = new Decimal(Number((_ref85 = (_targetProduct$metada12 = (_targetProduct$metada13 = targetProduct.metadata) === null || _targetProduct$metada13 === void 0 ? void 0 : _targetProduct$metada13.main_product_selling_price) !== null && _targetProduct$metada12 !== void 0 ? _targetProduct$metada12 : targetProduct.selling_price) !== null && _ref85 !== void 0 ? _ref85 : _previousMainOriginal.toNumber()) || 0);
|
|
5392
5599
|
var _preservedDiscount = _previousMainOriginal.minus(_previousMainSelling);
|
|
5393
5600
|
var previousSource = ((_targetProduct$metada14 = targetProduct.metadata) === null || _targetProduct$metada14 === void 0 ? void 0 : _targetProduct$metada14.source_product_price) != null ? new Decimal(Number(targetProduct.metadata.source_product_price) || 0) : _previousMainOriginal.minus(previousOptionSum);
|
|
5394
5601
|
var _nextMainOriginal = previousSource.plus(nextOptionSum);
|
|
@@ -5409,7 +5616,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5409
5616
|
// normalizeOrderProduct 幂等:v2 metadata 存在 → 保留 main_product_* 折扣重算 composite;
|
|
5410
5617
|
// 否则 → 把顶层 selling_price 视作 source,派生 main_product_* 并写 price_schema_version: 2。
|
|
5411
5618
|
var normalizedProduct = this.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(nextProduct, normalizeOrderProduct(nextProduct)));
|
|
5412
|
-
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
5619
|
+
normalizedProduct.discount_list = normalizeOrderProductDiscountList(isPersistedOrderLine ? syncReducedEntitlementPassUsageCount(normalizedProduct.discount_list, targetProduct.num, normalizedProduct.num) : normalizedProduct.discount_list);
|
|
5413
5620
|
var preservedBookingUid = nextProduct.booking_uid || ((_nextProduct$metadata = nextProduct.metadata) === null || _nextProduct$metadata === void 0 ? void 0 : _nextProduct$metadata.booking_uid) || targetProduct.booking_uid || ((_targetProduct$metada15 = targetProduct.metadata) === null || _targetProduct$metada15 === void 0 ? void 0 : _targetProduct$metada15.booking_uid);
|
|
5414
5621
|
if (!booking && preservedBookingUid) {
|
|
5415
5622
|
normalizedProduct.booking_uid = preservedBookingUid;
|
|
@@ -5488,7 +5695,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5488
5695
|
key: "updateOrderProducts",
|
|
5489
5696
|
value: function () {
|
|
5490
5697
|
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(paramsList) {
|
|
5491
|
-
var
|
|
5698
|
+
var _this36 = this;
|
|
5492
5699
|
var tempOrder, reapplyBookingDiscountProductUids;
|
|
5493
5700
|
return _regeneratorRuntime().wrap(function _callee26$(_context28) {
|
|
5494
5701
|
while (1) switch (_context28.prev = _context28.next) {
|
|
@@ -5501,7 +5708,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5501
5708
|
return _context28.abrupt("return", tempOrder.products);
|
|
5502
5709
|
case 3:
|
|
5503
5710
|
reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
|
|
5504
|
-
var updatedProductUid =
|
|
5711
|
+
var updatedProductUid = _this36.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
5505
5712
|
// 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
|
|
5506
5713
|
if (params.allow_booking_discount_reapply && updatedProductUid) {
|
|
5507
5714
|
acc.push(String(updatedProductUid));
|
|
@@ -5533,7 +5740,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5533
5740
|
value: function () {
|
|
5534
5741
|
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
|
|
5535
5742
|
var _targetProduct$metada17;
|
|
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;
|
|
5743
|
+
var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, isPersistedOrderLine, normalizedProduct, settlementSnapshot, currencyProductId, asset, requiredAmount, balance, isVirtualSettlement, promotionPayload;
|
|
5537
5744
|
return _regeneratorRuntime().wrap(function _callee27$(_context29) {
|
|
5538
5745
|
while (1) switch (_context29.prev = _context29.next) {
|
|
5539
5746
|
case 0:
|
|
@@ -5571,16 +5778,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5571
5778
|
throw new Error('[Order] 目标商品不存在,无法更新数量');
|
|
5572
5779
|
case 13:
|
|
5573
5780
|
targetProduct = tempOrder.products[productIndex];
|
|
5781
|
+
isPersistedOrderLine = targetProduct.order_detail_id !== undefined && targetProduct.order_detail_id !== null;
|
|
5574
5782
|
normalizedProduct = this.normalizeVirtualSettlementProductIfEnabled(normalizeOrderProduct(_objectSpread(_objectSpread({}, targetProduct), {}, {
|
|
5575
5783
|
num: getSafeProductNum(num),
|
|
5576
5784
|
metadata: _objectSpread(_objectSpread({}, targetProduct.metadata || {}), {}, {
|
|
5577
5785
|
unique_identification_number: ((_targetProduct$metada17 = targetProduct.metadata) === null || _targetProduct$metada17 === void 0 ? void 0 : _targetProduct$metada17.unique_identification_number) || unique_identification_number
|
|
5578
5786
|
})
|
|
5579
5787
|
})));
|
|
5580
|
-
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
5788
|
+
normalizedProduct.discount_list = normalizeOrderProductDiscountList(isPersistedOrderLine ? syncReducedEntitlementPassUsageCount(normalizedProduct.discount_list, targetProduct.num, normalizedProduct.num) : normalizedProduct.discount_list);
|
|
5581
5789
|
settlementSnapshot = getSelectedSettlementSnapshot(normalizedProduct);
|
|
5582
5790
|
if (!(this.isMultiCurrencySettlementEnabled() && (settlementSnapshot === null || settlementSnapshot === void 0 ? void 0 : settlementSnapshot.settlement_type) === 'virtual_currency' && tempOrder.customer_id && Number(tempOrder.customer_id) !== 1)) {
|
|
5583
|
-
_context29.next =
|
|
5791
|
+
_context29.next = 27;
|
|
5584
5792
|
break;
|
|
5585
5793
|
}
|
|
5586
5794
|
currencyProductId = Number(settlementSnapshot.currency_product_id);
|
|
@@ -5588,11 +5796,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5588
5796
|
return Number(item === null || item === void 0 ? void 0 : item.product_id) === currencyProductId;
|
|
5589
5797
|
});
|
|
5590
5798
|
if (asset) {
|
|
5591
|
-
_context29.next =
|
|
5799
|
+
_context29.next = 23;
|
|
5592
5800
|
break;
|
|
5593
5801
|
}
|
|
5594
5802
|
throw new VirtualCurrencyAssetNotFoundError(currencyProductId);
|
|
5595
|
-
case
|
|
5803
|
+
case 23:
|
|
5596
5804
|
requiredAmount = tempOrder.products.reduce(function (sum, item, index) {
|
|
5597
5805
|
var current = index === productIndex ? normalizedProduct : item;
|
|
5598
5806
|
var currentSnapshot = getSelectedSettlementSnapshot(current);
|
|
@@ -5600,44 +5808,44 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5600
5808
|
}, new Decimal(0));
|
|
5601
5809
|
balance = new Decimal(asset.balance || 0);
|
|
5602
5810
|
if (!balance.lt(requiredAmount)) {
|
|
5603
|
-
_context29.next =
|
|
5811
|
+
_context29.next = 27;
|
|
5604
5812
|
break;
|
|
5605
5813
|
}
|
|
5606
5814
|
throw new VirtualCurrencyBalanceError(balance.toFixed(2), requiredAmount.toFixed(2));
|
|
5607
|
-
case
|
|
5815
|
+
case 27:
|
|
5608
5816
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
5609
5817
|
this.prepareVirtualSettlementTempOrder(tempOrder);
|
|
5610
5818
|
isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder);
|
|
5611
5819
|
if (isVirtualSettlement) {
|
|
5612
|
-
_context29.next =
|
|
5820
|
+
_context29.next = 36;
|
|
5613
5821
|
break;
|
|
5614
5822
|
}
|
|
5615
|
-
_context29.next =
|
|
5823
|
+
_context29.next = 33;
|
|
5616
5824
|
return this.evaluatePromotion();
|
|
5617
|
-
case
|
|
5825
|
+
case 33:
|
|
5618
5826
|
_context29.t0 = _context29.sent;
|
|
5619
|
-
_context29.next =
|
|
5827
|
+
_context29.next = 37;
|
|
5620
5828
|
break;
|
|
5621
|
-
case 35:
|
|
5622
|
-
_context29.t0 = null;
|
|
5623
5829
|
case 36:
|
|
5830
|
+
_context29.t0 = null;
|
|
5831
|
+
case 37:
|
|
5624
5832
|
promotionPayload = _context29.t0;
|
|
5625
5833
|
if (!isVirtualSettlement) {
|
|
5626
5834
|
this.applyDiscount();
|
|
5627
5835
|
}
|
|
5628
5836
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
5629
|
-
_context29.next =
|
|
5837
|
+
_context29.next = 42;
|
|
5630
5838
|
return this.recalculateSummary({
|
|
5631
5839
|
createIfMissing: true
|
|
5632
5840
|
});
|
|
5633
|
-
case
|
|
5841
|
+
case 42:
|
|
5634
5842
|
this.persistTempOrder();
|
|
5635
5843
|
this.emitPromotionApplied(promotionPayload);
|
|
5636
5844
|
this.logInfo('updateOrderProductQuantity success', {
|
|
5637
5845
|
params: params
|
|
5638
5846
|
});
|
|
5639
5847
|
return _context29.abrupt("return", tempOrder.products);
|
|
5640
|
-
case
|
|
5848
|
+
case 46:
|
|
5641
5849
|
case "end":
|
|
5642
5850
|
return _context29.stop();
|
|
5643
5851
|
}
|
|
@@ -5727,7 +5935,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5727
5935
|
key: "removeProductsFromOrder",
|
|
5728
5936
|
value: (function () {
|
|
5729
5937
|
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(identities, options) {
|
|
5730
|
-
var
|
|
5938
|
+
var _this37 = this;
|
|
5731
5939
|
var tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
|
|
5732
5940
|
return _regeneratorRuntime().wrap(function _callee29$(_context32) {
|
|
5733
5941
|
while (1) switch (_context32.prev = _context32.next) {
|
|
@@ -5792,7 +6000,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5792
6000
|
}
|
|
5793
6001
|
if (productUid !== undefined && productUid !== null && productUid !== '') {
|
|
5794
6002
|
bookingsBeforeRemove.forEach(function (booking) {
|
|
5795
|
-
var bookingUid =
|
|
6003
|
+
var bookingUid = _this37.getBookingUniqueIdentificationNumber(booking);
|
|
5796
6004
|
if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
|
|
5797
6005
|
linkedBookingUidsToRemove.add(bookingUid);
|
|
5798
6006
|
}
|
|
@@ -6007,23 +6215,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6007
6215
|
}, {
|
|
6008
6216
|
key: "buildCurrentSubmitPayloadForLocalPrint",
|
|
6009
6217
|
value: function buildCurrentSubmitPayloadForLocalPrint(params) {
|
|
6010
|
-
var _params$cacheId, _this$otherParams5,
|
|
6218
|
+
var _params$cacheId, _this$otherParams5, _ref86, _params$businessCode, _this$otherParams6, _this$otherParams7;
|
|
6011
6219
|
var tempOrder = this.ensureTempOrder();
|
|
6012
6220
|
this.persistTempOrder();
|
|
6013
6221
|
var payload = buildSubmitPayload({
|
|
6014
6222
|
tempOrder: tempOrder,
|
|
6015
6223
|
cacheId: (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId,
|
|
6016
6224
|
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.platform),
|
|
6017
|
-
businessCode: (
|
|
6225
|
+
businessCode: (_ref86 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.businessCode) !== null && _ref86 !== void 0 ? _ref86 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.business_code,
|
|
6018
6226
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
6019
6227
|
type: params === null || params === void 0 ? void 0 : params.type,
|
|
6020
6228
|
summary: this.store.summary || createEmptySummary(),
|
|
6021
6229
|
enhance: function enhance(nextPayload) {
|
|
6022
|
-
var
|
|
6230
|
+
var _ref87, _tempOrder$order_numb, _ref88, _tempOrder$shop_order2, _ref89, _tempOrder$shop_full_;
|
|
6023
6231
|
return _objectSpread(_objectSpread({}, nextPayload), {}, {
|
|
6024
|
-
order_number: (
|
|
6025
|
-
shop_order_number: (
|
|
6026
|
-
shop_full_order_number: (
|
|
6232
|
+
order_number: (_ref87 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref87 !== void 0 ? _ref87 : null,
|
|
6233
|
+
shop_order_number: (_ref88 = (_tempOrder$shop_order2 = tempOrder.shop_order_number) !== null && _tempOrder$shop_order2 !== void 0 ? _tempOrder$shop_order2 : nextPayload.shop_order_number) !== null && _ref88 !== void 0 ? _ref88 : null,
|
|
6234
|
+
shop_full_order_number: (_ref89 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref89 !== void 0 ? _ref89 : null,
|
|
6027
6235
|
small_ticket_data_flag: 1
|
|
6028
6236
|
});
|
|
6029
6237
|
}
|
|
@@ -6187,7 +6395,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6187
6395
|
key: "runSubmitTempOrder",
|
|
6188
6396
|
value: function () {
|
|
6189
6397
|
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
|
|
6190
|
-
var _params$cacheId3, _this$otherParams12,
|
|
6398
|
+
var _params$cacheId3, _this$otherParams12, _ref90, _ref91, _submitSnapshot$busin, _this$otherParams13, _this$otherParams14, _submitSnapshot$type;
|
|
6191
6399
|
var tempOrder, isOnlineStorePlatform, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, shouldOverridePaymentStatus, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, isLocalPendingSubmit, salesNotesState, submittedOrderId, resultRecord;
|
|
6192
6400
|
return _regeneratorRuntime().wrap(function _callee37$(_context40) {
|
|
6193
6401
|
while (1) switch (_context40.prev = _context40.next) {
|
|
@@ -6254,7 +6462,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6254
6462
|
tempOrder: tempOrder,
|
|
6255
6463
|
cacheId: effectiveCacheId,
|
|
6256
6464
|
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.platform),
|
|
6257
|
-
businessCode: (
|
|
6465
|
+
businessCode: (_ref90 = (_ref91 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref91 !== void 0 ? _ref91 : (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.businessCode) !== null && _ref90 !== void 0 ? _ref90 : (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.business_code,
|
|
6258
6466
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
6259
6467
|
type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
|
|
6260
6468
|
summary: latestSummary,
|
|
@@ -6424,10 +6632,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6424
6632
|
value: function extractSubmitErrorResponse(error) {
|
|
6425
6633
|
var _error$response,
|
|
6426
6634
|
_error$response2,
|
|
6427
|
-
|
|
6635
|
+
_this38 = this;
|
|
6428
6636
|
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];
|
|
6429
6637
|
return candidates.find(function (candidate) {
|
|
6430
|
-
return
|
|
6638
|
+
return _this38.isSubmitErrorResponse(candidate);
|
|
6431
6639
|
}) || null;
|
|
6432
6640
|
}
|
|
6433
6641
|
}, {
|
|
@@ -6455,7 +6663,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6455
6663
|
key: "syncPaymentsToOrder",
|
|
6456
6664
|
value: function () {
|
|
6457
6665
|
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
|
|
6458
|
-
var
|
|
6666
|
+
var _this39 = this,
|
|
6459
6667
|
_params$confirmPendin;
|
|
6460
6668
|
var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, enhancePayload, submitParams, submitResult;
|
|
6461
6669
|
return _regeneratorRuntime().wrap(function _callee39$(_context42) {
|
|
@@ -6480,7 +6688,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6480
6688
|
case 9:
|
|
6481
6689
|
devicePrefix = _context42.t0;
|
|
6482
6690
|
mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
|
|
6483
|
-
return
|
|
6691
|
+
return _this39.normalizePaymentSource(payment, {
|
|
6484
6692
|
defaultPaid: false,
|
|
6485
6693
|
devicePrefix: devicePrefix
|
|
6486
6694
|
});
|
|
@@ -6559,7 +6767,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6559
6767
|
}, {
|
|
6560
6768
|
key: "createOrder",
|
|
6561
6769
|
value: function createOrder(params) {
|
|
6562
|
-
var
|
|
6770
|
+
var _this40 = this;
|
|
6563
6771
|
var order = _objectSpread({
|
|
6564
6772
|
type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
|
|
6565
6773
|
// 要从外面拿,virtual
|
|
@@ -6591,7 +6799,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6591
6799
|
|
|
6592
6800
|
// 为预约补齐 holder 信息
|
|
6593
6801
|
if (params !== null && params !== void 0 && (_params$extraData = params.extraData) !== null && _params$extraData !== void 0 && _params$extraData.is_add_holder_info) {
|
|
6594
|
-
ensureCartItemOriginHolder(item,
|
|
6802
|
+
ensureCartItemOriginHolder(item, _this40.window);
|
|
6595
6803
|
}
|
|
6596
6804
|
|
|
6597
6805
|
// 购物车是否为普通商品
|
|
@@ -7233,10 +7441,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7233
7441
|
_step22;
|
|
7234
7442
|
try {
|
|
7235
7443
|
for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
|
|
7236
|
-
var _product$
|
|
7444
|
+
var _product$metadata13;
|
|
7237
7445
|
var product = _step22.value;
|
|
7238
7446
|
var productUid = getOrderCollectionUid('product', product);
|
|
7239
|
-
var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$
|
|
7447
|
+
var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata13 = product.metadata) === null || _product$metadata13 === void 0 ? void 0 : _product$metadata13.booking_uid);
|
|
7240
7448
|
if (!productUid || bookingUid === undefined || bookingUid === null || bookingUid === '') {
|
|
7241
7449
|
continue;
|
|
7242
7450
|
}
|
|
@@ -7294,7 +7502,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7294
7502
|
}, {
|
|
7295
7503
|
key: "normalizeTempOrderForRuntime",
|
|
7296
7504
|
value: function normalizeTempOrderForRuntime(raw, options) {
|
|
7297
|
-
var
|
|
7505
|
+
var _this41 = this,
|
|
7298
7506
|
_raw$_extend;
|
|
7299
7507
|
var runtimeRaw = this.withoutSyntheticDraftOrderIdForRuntime(raw);
|
|
7300
7508
|
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
|
|
@@ -7319,12 +7527,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7319
7527
|
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
7320
7528
|
var rawProducts = Array.isArray(raw.products) ? raw.products : [];
|
|
7321
7529
|
nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
|
|
7322
|
-
return
|
|
7530
|
+
return _this41.normalizeHydratedOrderProduct(p, {
|
|
7323
7531
|
makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
|
|
7324
7532
|
});
|
|
7325
7533
|
}) : [];
|
|
7326
7534
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
7327
|
-
var booking =
|
|
7535
|
+
var booking = _this41.normalizeHydratedBookingHolder(b || {});
|
|
7328
7536
|
return _objectSpread(_objectSpread({}, booking), {}, {
|
|
7329
7537
|
is_all: normalizeBookingIsAll(booking),
|
|
7330
7538
|
sub_type: normalizeBookingSubType(booking)
|
|
@@ -7374,15 +7582,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7374
7582
|
_step24;
|
|
7375
7583
|
try {
|
|
7376
7584
|
for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
|
|
7377
|
-
var _product$
|
|
7585
|
+
var _product$metadata14, _ref92, _ref93, _existed$origin, _rawProduct$metadata;
|
|
7378
7586
|
var _step24$value = _slicedToArray(_step24.value, 2),
|
|
7379
7587
|
index = _step24$value[0],
|
|
7380
7588
|
product = _step24$value[1];
|
|
7381
|
-
var uid = (_product$
|
|
7589
|
+
var uid = (_product$metadata14 = product.metadata) === null || _product$metadata14 === void 0 ? void 0 : _product$metadata14.unique_identification_number;
|
|
7382
7590
|
if (!uid) continue;
|
|
7383
7591
|
var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
|
|
7384
7592
|
var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
|
|
7385
|
-
var origin = (
|
|
7593
|
+
var origin = (_ref92 = (_ref93 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref93 !== void 0 ? _ref93 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref92 !== void 0 ? _ref92 : rawProduct;
|
|
7386
7594
|
var originSnapshot = cloneDeep(origin);
|
|
7387
7595
|
var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
|
|
7388
7596
|
if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
|
|
@@ -7433,8 +7641,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7433
7641
|
var bookingUidByProductUid = new Map();
|
|
7434
7642
|
var productByUid = new Map();
|
|
7435
7643
|
(tempOrder.products || []).forEach(function (product) {
|
|
7436
|
-
var _product$
|
|
7437
|
-
var productUid = (product === null || product === void 0 || (_product$
|
|
7644
|
+
var _product$metadata15;
|
|
7645
|
+
var productUid = (product === null || product === void 0 || (_product$metadata15 = product.metadata) === null || _product$metadata15 === void 0 ? void 0 : _product$metadata15.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
7438
7646
|
if (productUid !== undefined && productUid !== null && String(productUid) !== '') {
|
|
7439
7647
|
productByUid.set(String(productUid), product);
|
|
7440
7648
|
}
|
|
@@ -7455,8 +7663,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7455
7663
|
bookingUidByProductUid.set(String(productUid), bookingUid);
|
|
7456
7664
|
});
|
|
7457
7665
|
(tempOrder.products || []).forEach(function (product) {
|
|
7458
|
-
var _product$
|
|
7459
|
-
var productUid = (product === null || product === void 0 || (_product$
|
|
7666
|
+
var _product$metadata16;
|
|
7667
|
+
var productUid = (product === null || product === void 0 || (_product$metadata16 = product.metadata) === null || _product$metadata16 === void 0 ? void 0 : _product$metadata16.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
7460
7668
|
if (productUid === undefined || productUid === null || String(productUid) === '') return;
|
|
7461
7669
|
var bookingUid = bookingUidByProductUid.get(String(productUid));
|
|
7462
7670
|
if (!bookingUid) return;
|
|
@@ -7511,10 +7719,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7511
7719
|
}, {
|
|
7512
7720
|
key: "normalizeHydratedProductOptionItem",
|
|
7513
7721
|
value: function normalizeHydratedProductOptionItem(optionItem) {
|
|
7514
|
-
var
|
|
7515
|
-
var rawNum = (
|
|
7722
|
+
var _ref94, _optionItem$num, _ref95, _optionItem$add_price;
|
|
7723
|
+
var rawNum = (_ref94 = (_optionItem$num = optionItem === null || optionItem === void 0 ? void 0 : optionItem.num) !== null && _optionItem$num !== void 0 ? _optionItem$num : optionItem === null || optionItem === void 0 ? void 0 : optionItem.quantity) !== null && _ref94 !== void 0 ? _ref94 : 1;
|
|
7516
7724
|
var parsedNum = Number(rawNum);
|
|
7517
|
-
var rawPrice = (
|
|
7725
|
+
var rawPrice = (_ref95 = (_optionItem$add_price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _optionItem$add_price !== void 0 ? _optionItem$add_price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _ref95 !== void 0 ? _ref95 : 0;
|
|
7518
7726
|
var parsedPrice = Number(rawPrice);
|
|
7519
7727
|
var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
|
|
7520
7728
|
option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
|
|
@@ -7531,7 +7739,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7531
7739
|
}, {
|
|
7532
7740
|
key: "normalizeHydratedOrderProduct",
|
|
7533
7741
|
value: function normalizeHydratedOrderProduct(product, options) {
|
|
7534
|
-
var
|
|
7742
|
+
var _this42 = this;
|
|
7535
7743
|
var row = _objectSpread({}, product || {});
|
|
7536
7744
|
if (row.num === undefined && row.product_quantity !== undefined) {
|
|
7537
7745
|
row.num = row.product_quantity;
|
|
@@ -7539,7 +7747,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7539
7747
|
var productSku = ensureProductSku(row);
|
|
7540
7748
|
row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
|
|
7541
7749
|
option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
|
|
7542
|
-
return
|
|
7750
|
+
return _this42.normalizeHydratedProductOptionItem(optionItem || {});
|
|
7543
7751
|
}))
|
|
7544
7752
|
});
|
|
7545
7753
|
delete row["product_".concat('option', "_item")];
|
|
@@ -7647,11 +7855,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7647
7855
|
targetMap.set(discountKey, (targetMap.get(discountKey) || new Decimal(0)).plus(amount));
|
|
7648
7856
|
};
|
|
7649
7857
|
var addProductDiscountAmount = function addProductDiscountAmount(discount, quantity, isPersistedProduct) {
|
|
7650
|
-
var _discount$discount3, _discount$
|
|
7858
|
+
var _discount$discount3, _discount$metadata2;
|
|
7651
7859
|
var discountKey = ((_discount$discount3 = discount.discount) === null || _discount$discount3 === void 0 ? void 0 : _discount$discount3.resource_id) || discount.id;
|
|
7652
7860
|
if (discountKey == null) return;
|
|
7653
7861
|
var qty = Number(quantity) || 1;
|
|
7654
|
-
var amount = new Decimal(discount.amount || 0).times(qty).plus(((_discount$
|
|
7862
|
+
var amount = new Decimal(discount.amount || 0).times(qty).plus(((_discount$metadata2 = discount.metadata) === null || _discount$metadata2 === void 0 ? void 0 : _discount$metadata2.product_discount_difference) || 0);
|
|
7655
7863
|
addDiscountAmount(savedMap, discountKey, amount);
|
|
7656
7864
|
addDiscountAmount(isPersistedProduct || discount.order_discount_id != null ? editModeSavedMap : runtimeSavedMap, discountKey, amount);
|
|
7657
7865
|
};
|