@pisell/pisellos 2.3.7 → 2.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/Order/index.d.ts +17 -1
- package/dist/modules/Order/index.js +282 -121
- package/dist/modules/Order/types.d.ts +15 -2
- package/dist/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
- package/dist/modules/Order/utils/bundleDiscountHydration.js +144 -0
- package/dist/modules/Order/utils.js +83 -28
- package/dist/solution/BaseSales/index.d.ts +15 -1
- package/dist/solution/BaseSales/index.js +405 -260
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/Order/index.d.ts +17 -1
- package/lib/modules/Order/index.js +205 -36
- package/lib/modules/Order/types.d.ts +15 -2
- package/lib/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
- package/lib/modules/Order/utils/bundleDiscountHydration.js +139 -0
- package/lib/modules/Order/utils.js +45 -2
- package/lib/solution/BaseSales/index.d.ts +15 -1
- package/lib/solution/BaseSales/index.js +105 -14
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -3,15 +3,15 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArra
|
|
|
3
3
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
4
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
5
5
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
6
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
7
|
-
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."); }
|
|
8
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
9
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
10
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; }
|
|
11
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); } }
|
|
12
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); }); }; }
|
|
13
9
|
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; }
|
|
14
10
|
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; }
|
|
11
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
12
|
+
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."); }
|
|
13
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
14
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
15
15
|
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; } } }; }
|
|
16
16
|
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); }
|
|
17
17
|
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; }
|
|
@@ -38,6 +38,7 @@ import dayjs from 'dayjs';
|
|
|
38
38
|
import { processCartPromotion, appendPromotionTags as _appendPromotionTags, getOrderProductUid as getPromotionUid } from "../../solution/BaseSales/utils/cartPromotion";
|
|
39
39
|
import { buildProductLineFingerprint, getProductIdentityIndex, getSafeProductNum, isIdentityMatch, normalizeOrderProduct } from "../../solution/ScanOrder/utils";
|
|
40
40
|
import { syncManualProductDiscountProductNum } from "./utils/manualProductDiscount";
|
|
41
|
+
import { expandHydratedProductsForDiscountCollection, restoreHydratedBundleDiscounts } from "./utils/bundleDiscountHydration";
|
|
41
42
|
import { DiscountModule } from "../Discount";
|
|
42
43
|
import { RulesModule } from "../Rules";
|
|
43
44
|
import { UnavailableReason } from "../Rules/types";
|
|
@@ -64,6 +65,23 @@ function isManualProductDiscountProduct(product) {
|
|
|
64
65
|
return (item === null || item === void 0 ? void 0 : item.type) === 'product';
|
|
65
66
|
});
|
|
66
67
|
}
|
|
68
|
+
var ORDER_PAYMENT_STATUS_PAID = 'paid';
|
|
69
|
+
var ORDER_PAYMENT_STATUS_PENDING = 'payment_pending';
|
|
70
|
+
function isVoucherPaymentRecord(payment) {
|
|
71
|
+
return (payment === null || payment === void 0 ? void 0 : payment.voucher_id) !== undefined && Number(payment.voucher_id) !== 0;
|
|
72
|
+
}
|
|
73
|
+
function hasSyncedOrderPaymentRecord(payment) {
|
|
74
|
+
return (payment === null || payment === void 0 ? void 0 : payment.order_payment_id) !== undefined && payment.order_payment_id !== null;
|
|
75
|
+
}
|
|
76
|
+
function isPendingVoucherPaymentRecord(payment) {
|
|
77
|
+
return isVoucherPaymentRecord(payment) && (payment === null || payment === void 0 ? void 0 : payment.status) === ORDER_PAYMENT_STATUS_PENDING;
|
|
78
|
+
}
|
|
79
|
+
function isPaidPaymentRecord(payment) {
|
|
80
|
+
return (payment === null || payment === void 0 ? void 0 : payment.status) === ORDER_PAYMENT_STATUS_PAID;
|
|
81
|
+
}
|
|
82
|
+
function isCommittedVoucherPaymentRecord(payment) {
|
|
83
|
+
return isVoucherPaymentRecord(payment) && (payment === null || payment === void 0 ? void 0 : payment.status) !== 'voided' && (hasSyncedOrderPaymentRecord(payment) || isPaidPaymentRecord(payment));
|
|
84
|
+
}
|
|
67
85
|
export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
68
86
|
_inherits(OrderModule, _BaseModule);
|
|
69
87
|
var _super = _createSuper(OrderModule);
|
|
@@ -108,7 +126,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
108
126
|
key: "collectHydratedEditDiscounts",
|
|
109
127
|
value: function collectHydratedEditDiscounts(products) {
|
|
110
128
|
var discountMap = new Map();
|
|
111
|
-
var _iterator = _createForOfIteratorHelper(products
|
|
129
|
+
var _iterator = _createForOfIteratorHelper(expandHydratedProductsForDiscountCollection(products)),
|
|
112
130
|
_step;
|
|
113
131
|
try {
|
|
114
132
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
@@ -138,6 +156,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
138
156
|
discount: item === null || item === void 0 ? void 0 : item.discount,
|
|
139
157
|
_num: Number((_ref6 = (_ref7 = (_item$metadata$num2 = item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.num) !== null && _item$metadata$num2 !== void 0 ? _item$metadata$num2 : product === null || product === void 0 ? void 0 : product.num) !== null && _ref7 !== void 0 ? _ref7 : product === null || product === void 0 ? void 0 : product.product_quantity) !== null && _ref6 !== void 0 ? _ref6 : 1) || 1
|
|
140
158
|
};
|
|
159
|
+
var existed = discountMap.get(key);
|
|
160
|
+
if (existed) {
|
|
161
|
+
existed.amount = Number(existed.amount || 0) + amount;
|
|
162
|
+
existed.used_par_value = String(Number(existed.used_par_value || 0) + amount);
|
|
163
|
+
existed.balance = String(Number(existed.balance || 0) + amount);
|
|
164
|
+
existed.applicableProductDetails = [].concat(_toConsumableArray(existed.applicableProductDetails || []), [detail]);
|
|
165
|
+
existed.appliedProductDetails = [].concat(_toConsumableArray(existed.appliedProductDetails || []), [detail]);
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
141
168
|
discountMap.set(key, {
|
|
142
169
|
id: key,
|
|
143
170
|
product_name: '',
|
|
@@ -1253,6 +1280,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1253
1280
|
return mapPaymentItemsToOrderPayments(payments, {
|
|
1254
1281
|
includeVoided: false
|
|
1255
1282
|
}).reduce(function (sum, payment) {
|
|
1283
|
+
if (!isPaidPaymentRecord(payment)) return sum;
|
|
1256
1284
|
return sum.plus(_this4.calculatePaymentEffectiveAmount(payment));
|
|
1257
1285
|
}, new Decimal(0));
|
|
1258
1286
|
}
|
|
@@ -1381,7 +1409,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1381
1409
|
var _this5 = this;
|
|
1382
1410
|
return (payments || []).reduce(function (sum, payment) {
|
|
1383
1411
|
var paymentRecord = payment;
|
|
1384
|
-
if ((paymentRecord
|
|
1412
|
+
if (!isPaidPaymentRecord(paymentRecord)) return sum;
|
|
1385
1413
|
var isDepositPayment = paymentRecord.type === 'deposit' || paymentRecord.order_payment_type === 'deposit';
|
|
1386
1414
|
if (!isDepositPayment) return sum;
|
|
1387
1415
|
if (paymentRecord.origin_amount !== undefined && paymentRecord.origin_amount !== null && paymentRecord.origin_amount !== '') {
|
|
@@ -1532,7 +1560,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1532
1560
|
var _this6 = this;
|
|
1533
1561
|
return (payments || []).reduce(function (summary, payment) {
|
|
1534
1562
|
var paymentRecord = payment;
|
|
1535
|
-
if ((paymentRecord
|
|
1563
|
+
if (!isPaidPaymentRecord(paymentRecord)) return summary;
|
|
1536
1564
|
return {
|
|
1537
1565
|
customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
|
|
1538
1566
|
orderPaidAmount: summary.orderPaidAmount.plus(paymentRecord.origin_amount || 0),
|
|
@@ -2101,6 +2129,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2101
2129
|
key: "restoreOrder",
|
|
2102
2130
|
value: function restoreOrder() {
|
|
2103
2131
|
var _this$store$discount11, _this$store$discount12;
|
|
2132
|
+
this.logInfo('restoreOrder start', {});
|
|
2104
2133
|
var freshTempOrder = this.createDefaultTempOrderInstance();
|
|
2105
2134
|
this.ensureExternalSaleNumber(freshTempOrder);
|
|
2106
2135
|
this.store.tempOrder = freshTempOrder;
|
|
@@ -3172,6 +3201,77 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3172
3201
|
this.persistTempOrder();
|
|
3173
3202
|
return tempOrder.payments;
|
|
3174
3203
|
}
|
|
3204
|
+
}, {
|
|
3205
|
+
key: "confirmPendingVoucherPaymentsInList",
|
|
3206
|
+
value: function confirmPendingVoucherPaymentsInList(payments) {
|
|
3207
|
+
return (payments || []).map(function (payment) {
|
|
3208
|
+
if (!isPendingVoucherPaymentRecord(payment)) return payment;
|
|
3209
|
+
return _objectSpread(_objectSpread({}, payment), {}, {
|
|
3210
|
+
status: ORDER_PAYMENT_STATUS_PAID
|
|
3211
|
+
});
|
|
3212
|
+
});
|
|
3213
|
+
}
|
|
3214
|
+
}, {
|
|
3215
|
+
key: "discardPendingVoucherPaymentsFromList",
|
|
3216
|
+
value: function discardPendingVoucherPaymentsFromList(payments) {
|
|
3217
|
+
return (payments || []).filter(function (payment) {
|
|
3218
|
+
return !isPendingVoucherPaymentRecord(payment);
|
|
3219
|
+
});
|
|
3220
|
+
}
|
|
3221
|
+
}, {
|
|
3222
|
+
key: "prepareVoucherPaymentsForSubmit",
|
|
3223
|
+
value: function prepareVoucherPaymentsForSubmit(payments) {
|
|
3224
|
+
var confirmPendingVoucherPayments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
3225
|
+
var mappedPayments = mapPaymentItemsToOrderPayments(payments || []);
|
|
3226
|
+
return confirmPendingVoucherPayments ? this.confirmPendingVoucherPaymentsInList(mappedPayments) : this.discardPendingVoucherPaymentsFromList(mappedPayments);
|
|
3227
|
+
}
|
|
3228
|
+
}, {
|
|
3229
|
+
key: "applyPaymentLifecycleChange",
|
|
3230
|
+
value: function applyPaymentLifecycleChange(tempOrder, options) {
|
|
3231
|
+
var _this19 = this;
|
|
3232
|
+
this.updateTempOrderPaymentStatus(tempOrder);
|
|
3233
|
+
if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
|
|
3234
|
+
this.persistTempOrder();
|
|
3235
|
+
}
|
|
3236
|
+
if ((options === null || options === void 0 ? void 0 : options.recalculateSummary) === false) return;
|
|
3237
|
+
var logContext = (options === null || options === void 0 ? void 0 : options.logContext) || 'payment lifecycle change';
|
|
3238
|
+
void this.recalculateSummary({
|
|
3239
|
+
createIfMissing: true
|
|
3240
|
+
}).catch(function (error) {
|
|
3241
|
+
_this19.logError("recalculate summary after ".concat(logContext, " failed"), {
|
|
3242
|
+
error: error instanceof Error ? error.message : String(error)
|
|
3243
|
+
});
|
|
3244
|
+
});
|
|
3245
|
+
}
|
|
3246
|
+
}, {
|
|
3247
|
+
key: "confirmPendingVoucherPayments",
|
|
3248
|
+
value: function confirmPendingVoucherPayments(options) {
|
|
3249
|
+
var tempOrder = this.ensureTempOrder();
|
|
3250
|
+
var payments = tempOrder.payments || [];
|
|
3251
|
+
var hasPendingVoucher = payments.some(function (payment) {
|
|
3252
|
+
return isPendingVoucherPaymentRecord(payment);
|
|
3253
|
+
});
|
|
3254
|
+
if (!hasPendingVoucher) return payments;
|
|
3255
|
+
tempOrder.payments = this.confirmPendingVoucherPaymentsInList(payments);
|
|
3256
|
+
this.applyPaymentLifecycleChange(tempOrder, _objectSpread(_objectSpread({}, options), {}, {
|
|
3257
|
+
logContext: 'confirmPendingVoucherPayments'
|
|
3258
|
+
}));
|
|
3259
|
+
// this.recalculateSummary();
|
|
3260
|
+
return tempOrder.payments;
|
|
3261
|
+
}
|
|
3262
|
+
}, {
|
|
3263
|
+
key: "discardPendingVoucherPayments",
|
|
3264
|
+
value: function discardPendingVoucherPayments(options) {
|
|
3265
|
+
var tempOrder = this.ensureTempOrder();
|
|
3266
|
+
var payments = tempOrder.payments || [];
|
|
3267
|
+
var nextPayments = this.discardPendingVoucherPaymentsFromList(payments);
|
|
3268
|
+
if (nextPayments.length === payments.length) return payments;
|
|
3269
|
+
tempOrder.payments = nextPayments;
|
|
3270
|
+
this.applyPaymentLifecycleChange(tempOrder, _objectSpread(_objectSpread({}, options), {}, {
|
|
3271
|
+
logContext: 'discardPendingVoucherPayments'
|
|
3272
|
+
}));
|
|
3273
|
+
return tempOrder.payments;
|
|
3274
|
+
}
|
|
3175
3275
|
|
|
3176
3276
|
/**
|
|
3177
3277
|
* 覆盖当前订单中的 wallet pass 支付项。
|
|
@@ -3181,22 +3281,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3181
3281
|
*/
|
|
3182
3282
|
}, {
|
|
3183
3283
|
key: "updateVoucherOrderPayments",
|
|
3184
|
-
value: function updateVoucherOrderPayments(payments) {
|
|
3185
|
-
var
|
|
3284
|
+
value: function updateVoucherOrderPayments(payments, options) {
|
|
3285
|
+
var _this20 = this;
|
|
3186
3286
|
var tempOrder = this.ensureTempOrder();
|
|
3187
|
-
var isVoucherPayment = function isVoucherPayment(payment) {
|
|
3188
|
-
return payment.voucher_id !== undefined && Number(payment.voucher_id) !== 0;
|
|
3189
|
-
};
|
|
3190
|
-
var hasSyncedOrderPayment = function hasSyncedOrderPayment(payment) {
|
|
3191
|
-
return payment.order_payment_id !== undefined && payment.order_payment_id !== null;
|
|
3192
|
-
};
|
|
3193
3287
|
var isOrderPaymentType = function isOrderPaymentType(value) {
|
|
3194
3288
|
return value === 'normal' || value === 'deposit';
|
|
3195
3289
|
};
|
|
3196
3290
|
var voucherOrderPaymentType = this.resolveNextOrderPaymentType(tempOrder);
|
|
3197
3291
|
var withVoucherPaymentType = function withVoucherPaymentType(payment) {
|
|
3198
3292
|
var paymentRecord = payment;
|
|
3199
|
-
if (!
|
|
3293
|
+
if (!isVoucherPaymentRecord(paymentRecord)) return payment;
|
|
3200
3294
|
var explicitPaymentType = isOrderPaymentType(paymentRecord.order_payment_type) ? paymentRecord.order_payment_type : isOrderPaymentType(paymentRecord.type) ? paymentRecord.type : undefined;
|
|
3201
3295
|
var nextPaymentType = explicitPaymentType || voucherOrderPaymentType;
|
|
3202
3296
|
var shouldPreserveCustomPaymentType = paymentRecord.custom_payment_type === undefined && paymentRecord.type !== undefined && !isOrderPaymentType(paymentRecord.type);
|
|
@@ -3207,49 +3301,72 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3207
3301
|
order_payment_type: nextPaymentType
|
|
3208
3302
|
});
|
|
3209
3303
|
};
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3304
|
+
var normalizeVoucherPaymentStatus = function normalizeVoucherPaymentStatus(payment) {
|
|
3305
|
+
var paymentRecord = payment;
|
|
3306
|
+
if (!isVoucherPaymentRecord(paymentRecord)) return payment;
|
|
3307
|
+
if (hasSyncedOrderPaymentRecord(paymentRecord) && (paymentRecord.status === undefined || paymentRecord.status === 'active')) {
|
|
3308
|
+
return _objectSpread(_objectSpread({}, paymentRecord), {}, {
|
|
3309
|
+
status: ORDER_PAYMENT_STATUS_PAID
|
|
3310
|
+
});
|
|
3311
|
+
}
|
|
3312
|
+
if (paymentRecord.status !== undefined && paymentRecord.status !== 'active') {
|
|
3313
|
+
return payment;
|
|
3314
|
+
}
|
|
3315
|
+
return _objectSpread(_objectSpread({}, paymentRecord), {}, {
|
|
3316
|
+
status: (options === null || options === void 0 ? void 0 : options.status) || ORDER_PAYMENT_STATUS_PENDING
|
|
3317
|
+
});
|
|
3318
|
+
};
|
|
3222
3319
|
var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
|
|
3223
|
-
return
|
|
3224
|
-
defaultPaid:
|
|
3320
|
+
return _this20.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
|
|
3321
|
+
defaultPaid: false
|
|
3225
3322
|
});
|
|
3226
3323
|
})).filter(function (payment) {
|
|
3227
|
-
return
|
|
3324
|
+
return isVoucherPaymentRecord(payment);
|
|
3228
3325
|
});
|
|
3229
3326
|
var nonVoucherPayments = (tempOrder.payments || []).filter(function (payment) {
|
|
3230
|
-
return !
|
|
3327
|
+
return !isVoucherPaymentRecord(payment);
|
|
3231
3328
|
});
|
|
3232
|
-
var
|
|
3233
|
-
|
|
3329
|
+
var normalizeCommittedVoucherPayment = function normalizeCommittedVoucherPayment(payment) {
|
|
3330
|
+
if (hasSyncedOrderPaymentRecord(payment) && (payment.status === undefined || payment.status === 'active')) {
|
|
3331
|
+
return _objectSpread(_objectSpread({}, payment), {}, {
|
|
3332
|
+
status: ORDER_PAYMENT_STATUS_PAID
|
|
3333
|
+
});
|
|
3334
|
+
}
|
|
3335
|
+
return payment;
|
|
3336
|
+
};
|
|
3337
|
+
var committedVoucherPayments = (tempOrder.payments || []).filter(function (payment) {
|
|
3338
|
+
return isCommittedVoucherPaymentRecord(payment);
|
|
3339
|
+
}).map(function (payment) {
|
|
3340
|
+
return normalizeCommittedVoucherPayment(payment);
|
|
3234
3341
|
});
|
|
3235
|
-
var
|
|
3342
|
+
var committedVoucherPaymentIds = new Set(committedVoucherPayments.filter(function (payment) {
|
|
3343
|
+
return hasSyncedOrderPaymentRecord(payment);
|
|
3344
|
+
}).map(function (payment) {
|
|
3236
3345
|
return String(payment.order_payment_id);
|
|
3237
3346
|
}));
|
|
3347
|
+
var committedVoucherIds = new Set(committedVoucherPayments.map(function (payment) {
|
|
3348
|
+
return String(payment.voucher_id);
|
|
3349
|
+
}));
|
|
3238
3350
|
var replaceableVouchers = mappedVouchers.filter(function (payment) {
|
|
3239
|
-
if (
|
|
3240
|
-
|
|
3351
|
+
if (hasSyncedOrderPaymentRecord(payment) && committedVoucherPaymentIds.has(String(payment.order_payment_id))) {
|
|
3352
|
+
return false;
|
|
3353
|
+
}
|
|
3354
|
+
if (payment.voucher_id !== undefined && committedVoucherIds.has(String(payment.voucher_id))) {
|
|
3355
|
+
return false;
|
|
3356
|
+
}
|
|
3357
|
+
return true;
|
|
3241
3358
|
});
|
|
3242
3359
|
var cappedVouchers = this.capVoucherPaymentsByRemainingAmount({
|
|
3243
3360
|
vouchers: replaceableVouchers,
|
|
3244
|
-
nonVoucherPayments: [].concat(_toConsumableArray(nonVoucherPayments), _toConsumableArray(
|
|
3361
|
+
nonVoucherPayments: [].concat(_toConsumableArray(nonVoucherPayments), _toConsumableArray(committedVoucherPayments))
|
|
3245
3362
|
});
|
|
3246
|
-
tempOrder.payments = [].concat(_toConsumableArray(nonVoucherPayments), _toConsumableArray(
|
|
3363
|
+
tempOrder.payments = [].concat(_toConsumableArray(nonVoucherPayments), _toConsumableArray(committedVoucherPayments), _toConsumableArray(cappedVouchers));
|
|
3247
3364
|
this.updateTempOrderPaymentStatus(tempOrder);
|
|
3248
3365
|
this.persistTempOrder();
|
|
3249
3366
|
void this.recalculateSummary({
|
|
3250
3367
|
createIfMissing: true
|
|
3251
3368
|
}).catch(function (error) {
|
|
3252
|
-
|
|
3369
|
+
_this20.logError('recalculate summary after updateVoucherOrderPayments failed', {
|
|
3253
3370
|
error: error instanceof Error ? error.message : String(error)
|
|
3254
3371
|
});
|
|
3255
3372
|
});
|
|
@@ -3385,7 +3502,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3385
3502
|
var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(tempOrder, product, booking) {
|
|
3386
3503
|
var _booking_uid,
|
|
3387
3504
|
_metadata,
|
|
3388
|
-
|
|
3505
|
+
_this21 = this;
|
|
3389
3506
|
var linked, productToAdd, incomingFingerprint, normalizedIncoming, incomingBookingUid, hasIncomingGoodPass, hasIncomingProductNote, hasIncomingBookingUid, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList;
|
|
3390
3507
|
return _regeneratorRuntime().wrap(function _callee16$(_context18) {
|
|
3391
3508
|
while (1) switch (_context18.prev = _context18.next) {
|
|
@@ -3410,8 +3527,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3410
3527
|
hasIncomingBookingUid = this.hasLinkedBookingUid(productToAdd) || this.hasLinkedBookingUid(normalizedIncoming);
|
|
3411
3528
|
shouldForceNewLine = !!booking || hasIncomingProductNote || hasIncomingBookingUid;
|
|
3412
3529
|
matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
3413
|
-
if (
|
|
3414
|
-
if (
|
|
3530
|
+
if (_this21.hasGoodPassDiscount(item)) return false;
|
|
3531
|
+
if (_this21.hasOrderProductLineNote(item)) return false;
|
|
3415
3532
|
if (item.order_detail_id !== undefined && item.order_detail_id !== null) return false;
|
|
3416
3533
|
if (item.product_id !== productToAdd.product_id) return false;
|
|
3417
3534
|
if (item.product_variant_id !== productToAdd.product_variant_id) return false;
|
|
@@ -3559,8 +3676,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3559
3676
|
_context19.next = 22;
|
|
3560
3677
|
return this.finalizeProductOrderMutation(tempOrder);
|
|
3561
3678
|
case 22:
|
|
3679
|
+
this.logInfo('addProductToOrder success', {
|
|
3680
|
+
product_id: product.product_id,
|
|
3681
|
+
with_booking: !!booking
|
|
3682
|
+
});
|
|
3562
3683
|
return _context19.abrupt("return", tempOrder.products);
|
|
3563
|
-
case
|
|
3684
|
+
case 24:
|
|
3564
3685
|
case "end":
|
|
3565
3686
|
return _context19.stop();
|
|
3566
3687
|
}
|
|
@@ -3660,8 +3781,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3660
3781
|
_context20.next = 40;
|
|
3661
3782
|
return this.finalizeProductOrderMutation(tempOrder, options);
|
|
3662
3783
|
case 40:
|
|
3784
|
+
this.logInfo('addProductsToOrder success', {
|
|
3785
|
+
itemsCount: items.length
|
|
3786
|
+
});
|
|
3663
3787
|
return _context20.abrupt("return", tempOrder.products);
|
|
3664
|
-
case
|
|
3788
|
+
case 42:
|
|
3665
3789
|
case "end":
|
|
3666
3790
|
return _context20.stop();
|
|
3667
3791
|
}
|
|
@@ -3701,17 +3825,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3701
3825
|
}, {
|
|
3702
3826
|
key: "preservePersistedBundlePriceFields",
|
|
3703
3827
|
value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
|
|
3704
|
-
var
|
|
3828
|
+
var _this22 = this;
|
|
3705
3829
|
if (!Array.isArray(nextBundles)) return nextBundles;
|
|
3706
3830
|
if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
|
|
3707
3831
|
var previousByIdentity = new Map();
|
|
3708
3832
|
previousBundles.forEach(function (bundle) {
|
|
3709
|
-
var identity =
|
|
3833
|
+
var identity = _this22.getBundleRuntimeIdentity(bundle);
|
|
3710
3834
|
if (identity) previousByIdentity.set(identity, bundle);
|
|
3711
3835
|
});
|
|
3712
3836
|
return nextBundles.map(function (bundle, index) {
|
|
3713
3837
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
3714
|
-
var previous = previousByIdentity.get(
|
|
3838
|
+
var previous = previousByIdentity.get(_this22.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
|
|
3715
3839
|
if (!previous || _typeof(previous) !== 'object') return bundle;
|
|
3716
3840
|
return _objectSpread(_objectSpread({}, bundle), {}, {
|
|
3717
3841
|
price: previous.price,
|
|
@@ -3879,8 +4003,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3879
4003
|
});
|
|
3880
4004
|
case 8:
|
|
3881
4005
|
this.persistTempOrder();
|
|
4006
|
+
this.logInfo('updateOrderProduct success', {
|
|
4007
|
+
params: params
|
|
4008
|
+
});
|
|
3882
4009
|
return _context21.abrupt("return", tempOrder.products);
|
|
3883
|
-
case
|
|
4010
|
+
case 11:
|
|
3884
4011
|
case "end":
|
|
3885
4012
|
return _context21.stop();
|
|
3886
4013
|
}
|
|
@@ -3895,7 +4022,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3895
4022
|
key: "updateOrderProducts",
|
|
3896
4023
|
value: function () {
|
|
3897
4024
|
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(paramsList) {
|
|
3898
|
-
var
|
|
4025
|
+
var _this23 = this;
|
|
3899
4026
|
var tempOrder;
|
|
3900
4027
|
return _regeneratorRuntime().wrap(function _callee20$(_context22) {
|
|
3901
4028
|
while (1) switch (_context22.prev = _context22.next) {
|
|
@@ -3908,13 +4035,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3908
4035
|
return _context22.abrupt("return", tempOrder.products);
|
|
3909
4036
|
case 3:
|
|
3910
4037
|
paramsList.forEach(function (params) {
|
|
3911
|
-
|
|
4038
|
+
_this23.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
3912
4039
|
});
|
|
3913
4040
|
_context22.next = 6;
|
|
3914
4041
|
return this.finalizeAfterProductsMutation(tempOrder);
|
|
3915
4042
|
case 6:
|
|
4043
|
+
this.logInfo('updateOrderProduct success', {
|
|
4044
|
+
paramsList: paramsList
|
|
4045
|
+
});
|
|
3916
4046
|
return _context22.abrupt("return", tempOrder.products);
|
|
3917
|
-
case
|
|
4047
|
+
case 8:
|
|
3918
4048
|
case "end":
|
|
3919
4049
|
return _context22.stop();
|
|
3920
4050
|
}
|
|
@@ -3986,8 +4116,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3986
4116
|
});
|
|
3987
4117
|
case 22:
|
|
3988
4118
|
this.persistTempOrder();
|
|
4119
|
+
this.logInfo('updateOrderProductQuantity success', {
|
|
4120
|
+
params: params
|
|
4121
|
+
});
|
|
3989
4122
|
return _context23.abrupt("return", tempOrder.products);
|
|
3990
|
-
case
|
|
4123
|
+
case 25:
|
|
3991
4124
|
case "end":
|
|
3992
4125
|
return _context23.stop();
|
|
3993
4126
|
}
|
|
@@ -4072,7 +4205,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4072
4205
|
key: "removeProductsFromOrder",
|
|
4073
4206
|
value: (function () {
|
|
4074
4207
|
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(identities) {
|
|
4075
|
-
var
|
|
4208
|
+
var _this24 = this;
|
|
4076
4209
|
var tempOrder, productsBeforeRemove, bookingsBeforeRemove, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3;
|
|
4077
4210
|
return _regeneratorRuntime().wrap(function _callee23$(_context26) {
|
|
4078
4211
|
while (1) switch (_context26.prev = _context26.next) {
|
|
@@ -4127,7 +4260,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4127
4260
|
}
|
|
4128
4261
|
if (productUid !== undefined && productUid !== null && productUid !== '') {
|
|
4129
4262
|
bookingsBeforeRemove.forEach(function (booking) {
|
|
4130
|
-
var bookingUid =
|
|
4263
|
+
var bookingUid = _this24.getBookingUniqueIdentificationNumber(booking);
|
|
4131
4264
|
if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
|
|
4132
4265
|
linkedBookingUidsToRemove.add(bookingUid);
|
|
4133
4266
|
}
|
|
@@ -4179,8 +4312,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4179
4312
|
_context26.next = 31;
|
|
4180
4313
|
return this.finalizeAfterProductsMutation(tempOrder);
|
|
4181
4314
|
case 31:
|
|
4315
|
+
this.logInfo('removeProductsFromOrder success', {
|
|
4316
|
+
identities: identities
|
|
4317
|
+
});
|
|
4182
4318
|
return _context26.abrupt("return", tempOrder.products);
|
|
4183
|
-
case
|
|
4319
|
+
case 33:
|
|
4184
4320
|
case "end":
|
|
4185
4321
|
return _context26.stop();
|
|
4186
4322
|
}
|
|
@@ -4242,8 +4378,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4242
4378
|
});
|
|
4243
4379
|
case 11:
|
|
4244
4380
|
this.persistTempOrder();
|
|
4381
|
+
this.logInfo('clearOrderCartLines success', {});
|
|
4245
4382
|
return _context28.abrupt("return", tempOrder);
|
|
4246
|
-
case
|
|
4383
|
+
case 14:
|
|
4247
4384
|
case "end":
|
|
4248
4385
|
return _context28.stop();
|
|
4249
4386
|
}
|
|
@@ -4372,40 +4509,55 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4372
4509
|
value: function () {
|
|
4373
4510
|
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
|
|
4374
4511
|
var _params$cacheId2, _this$otherParams5, _ref72, _ref73, _submitSnapshot$busin, _this$otherParams6, _this$otherParams7, _submitSnapshot$type;
|
|
4375
|
-
var tempOrder, latestSummary, effectiveCacheId,
|
|
4512
|
+
var tempOrder, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
|
|
4376
4513
|
return _regeneratorRuntime().wrap(function _callee29$(_context32) {
|
|
4377
4514
|
while (1) switch (_context32.prev = _context32.next) {
|
|
4378
4515
|
case 0:
|
|
4379
4516
|
tempOrder = this.ensureTempOrder();
|
|
4517
|
+
shouldConfirmPendingVoucherPayments = (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== false;
|
|
4518
|
+
hasPaymentOverride = (params === null || params === void 0 ? void 0 : params.payments) !== undefined;
|
|
4519
|
+
preparedPaymentOverride = hasPaymentOverride ? this.prepareVoucherPaymentsForSubmit((params === null || params === void 0 ? void 0 : params.payments) || [], shouldConfirmPendingVoucherPayments) : undefined;
|
|
4520
|
+
if (!hasPaymentOverride) {
|
|
4521
|
+
if (shouldConfirmPendingVoucherPayments) {
|
|
4522
|
+
this.confirmPendingVoucherPayments({
|
|
4523
|
+
persist: false,
|
|
4524
|
+
recalculateSummary: false
|
|
4525
|
+
});
|
|
4526
|
+
} else {
|
|
4527
|
+
this.discardPendingVoucherPayments({
|
|
4528
|
+
persist: false,
|
|
4529
|
+
recalculateSummary: false
|
|
4530
|
+
});
|
|
4531
|
+
}
|
|
4532
|
+
}
|
|
4380
4533
|
this.persistTempOrder();
|
|
4381
|
-
_context32.next =
|
|
4534
|
+
_context32.next = 8;
|
|
4382
4535
|
return this.recalculateSummary({
|
|
4383
4536
|
createIfMissing: true
|
|
4384
4537
|
});
|
|
4385
|
-
case
|
|
4538
|
+
case 8:
|
|
4386
4539
|
_context32.t1 = _context32.sent;
|
|
4387
4540
|
if (_context32.t1) {
|
|
4388
|
-
_context32.next =
|
|
4541
|
+
_context32.next = 11;
|
|
4389
4542
|
break;
|
|
4390
4543
|
}
|
|
4391
4544
|
_context32.t1 = this.store.summary;
|
|
4392
|
-
case
|
|
4545
|
+
case 11:
|
|
4393
4546
|
_context32.t0 = _context32.t1;
|
|
4394
4547
|
if (_context32.t0) {
|
|
4395
|
-
_context32.next =
|
|
4548
|
+
_context32.next = 14;
|
|
4396
4549
|
break;
|
|
4397
4550
|
}
|
|
4398
4551
|
_context32.t0 = createEmptySummary();
|
|
4399
|
-
case
|
|
4552
|
+
case 14:
|
|
4400
4553
|
latestSummary = _context32.t0;
|
|
4401
4554
|
effectiveCacheId = (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId;
|
|
4402
|
-
hasPaymentOverride = (params === null || params === void 0 ? void 0 : params.payments) !== undefined;
|
|
4403
4555
|
hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
|
|
4404
4556
|
hasSmallTicketDataFlagOverride = (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined;
|
|
4405
4557
|
enhancePayload = hasPaymentOverride || hasPaymentStatusOverride || hasSmallTicketDataFlagOverride || params !== null && params !== void 0 && params.enhancePayload ? function (payload, ctx) {
|
|
4406
4558
|
var nextPayload = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, payload), hasPaymentOverride ? {
|
|
4407
|
-
payments:
|
|
4408
|
-
} : {}), hasPaymentStatusOverride ? {
|
|
4559
|
+
payments: preparedPaymentOverride || []
|
|
4560
|
+
} : {}), hasPaymentStatusOverride && !shouldConfirmPendingVoucherPayments ? {
|
|
4409
4561
|
payment_status: params === null || params === void 0 ? void 0 : params.paymentStatus
|
|
4410
4562
|
} : {}), hasSmallTicketDataFlagOverride ? {
|
|
4411
4563
|
small_ticket_data_flag: params === null || params === void 0 ? void 0 : params.smallTicketDataFlag
|
|
@@ -4425,6 +4577,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4425
4577
|
request_unique_idempotency_token: params === null || params === void 0 ? void 0 : params.request_unique_idempotency_token,
|
|
4426
4578
|
enhance: enhancePayload
|
|
4427
4579
|
});
|
|
4580
|
+
console.log('[Order.runSubmitTempOrder.payload]', payload);
|
|
4428
4581
|
if (params !== null && params !== void 0 && params.syncMode) {
|
|
4429
4582
|
payload.sync_mode = true;
|
|
4430
4583
|
}
|
|
@@ -4432,10 +4585,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4432
4585
|
if (!payload.created_at) {
|
|
4433
4586
|
payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
4434
4587
|
}
|
|
4435
|
-
_context32.next =
|
|
4588
|
+
_context32.next = 26;
|
|
4436
4589
|
return this.saveDraft();
|
|
4437
|
-
case
|
|
4438
|
-
_context32.prev =
|
|
4590
|
+
case 26:
|
|
4591
|
+
_context32.prev = 26;
|
|
4439
4592
|
this.logInfo('submitTempOrder calling sales checkout', {
|
|
4440
4593
|
orderId: payload.order_id,
|
|
4441
4594
|
externalSaleNumber: payload.external_sale_number,
|
|
@@ -4445,26 +4598,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4445
4598
|
smallTicketDataFlag: payload.small_ticket_data_flag,
|
|
4446
4599
|
syncMode: payload.sync_mode
|
|
4447
4600
|
});
|
|
4448
|
-
_context32.next =
|
|
4601
|
+
_context32.next = 30;
|
|
4449
4602
|
return this.submitSalesOrder({
|
|
4450
4603
|
query: payload
|
|
4451
4604
|
});
|
|
4452
|
-
case
|
|
4605
|
+
case 30:
|
|
4453
4606
|
result = _context32.sent;
|
|
4454
|
-
_context32.next =
|
|
4607
|
+
_context32.next = 43;
|
|
4455
4608
|
break;
|
|
4456
|
-
case
|
|
4457
|
-
_context32.prev =
|
|
4458
|
-
_context32.t2 = _context32["catch"](
|
|
4609
|
+
case 33:
|
|
4610
|
+
_context32.prev = 33;
|
|
4611
|
+
_context32.t2 = _context32["catch"](26);
|
|
4459
4612
|
backendErrorResponse = this.extractSubmitErrorResponse(_context32.t2);
|
|
4460
4613
|
if (!backendErrorResponse) {
|
|
4461
|
-
_context32.next =
|
|
4614
|
+
_context32.next = 40;
|
|
4462
4615
|
break;
|
|
4463
4616
|
}
|
|
4464
4617
|
this.store.syncState = 'failed';
|
|
4465
4618
|
this.logSubmitBackendRejected(backendErrorResponse, payload);
|
|
4466
4619
|
return _context32.abrupt("return", backendErrorResponse);
|
|
4467
|
-
case
|
|
4620
|
+
case 40:
|
|
4468
4621
|
this.store.syncState = 'failed';
|
|
4469
4622
|
this.logError('submitTempOrder failed', {
|
|
4470
4623
|
error: _context32.t2 instanceof Error ? _context32.t2.message : String(_context32.t2),
|
|
@@ -4474,15 +4627,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4474
4627
|
paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
|
|
4475
4628
|
});
|
|
4476
4629
|
throw _context32.t2;
|
|
4477
|
-
case
|
|
4630
|
+
case 43:
|
|
4478
4631
|
if (!this.isSubmitResponseRejected(result)) {
|
|
4479
|
-
_context32.next =
|
|
4632
|
+
_context32.next = 47;
|
|
4480
4633
|
break;
|
|
4481
4634
|
}
|
|
4482
4635
|
this.store.syncState = 'failed';
|
|
4483
4636
|
this.logSubmitBackendRejected(result, payload);
|
|
4484
4637
|
return _context32.abrupt("return", result);
|
|
4485
|
-
case
|
|
4638
|
+
case 47:
|
|
4486
4639
|
submittedOrderId = this.extractOrderIdFromSubmitResult(result);
|
|
4487
4640
|
this.logInfo('runSubmitTempOrder: 提交成功', {
|
|
4488
4641
|
submittedOrderId: submittedOrderId,
|
|
@@ -4490,29 +4643,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4490
4643
|
tempOrder: tempOrder
|
|
4491
4644
|
});
|
|
4492
4645
|
if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
|
|
4493
|
-
_context32.next =
|
|
4646
|
+
_context32.next = 56;
|
|
4494
4647
|
break;
|
|
4495
4648
|
}
|
|
4496
4649
|
tempOrder.order_id = submittedOrderId;
|
|
4497
4650
|
resultRecord = result;
|
|
4498
|
-
_context32.next =
|
|
4651
|
+
_context32.next = 54;
|
|
4499
4652
|
return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
|
|
4500
|
-
case
|
|
4501
|
-
_context32.next =
|
|
4653
|
+
case 54:
|
|
4654
|
+
_context32.next = 57;
|
|
4502
4655
|
break;
|
|
4503
|
-
case
|
|
4656
|
+
case 56:
|
|
4504
4657
|
if (this.isLocalPendingSubmitResult(result)) {
|
|
4505
4658
|
this.store.syncState = 'local';
|
|
4506
4659
|
} else {
|
|
4507
4660
|
this.store.syncState = 'submitted';
|
|
4508
4661
|
}
|
|
4509
|
-
case
|
|
4662
|
+
case 57:
|
|
4510
4663
|
return _context32.abrupt("return", result);
|
|
4511
|
-
case
|
|
4664
|
+
case 58:
|
|
4512
4665
|
case "end":
|
|
4513
4666
|
return _context32.stop();
|
|
4514
4667
|
}
|
|
4515
|
-
}, _callee29, this, [[
|
|
4668
|
+
}, _callee29, this, [[26, 33]]);
|
|
4516
4669
|
}));
|
|
4517
4670
|
function runSubmitTempOrder(_x32) {
|
|
4518
4671
|
return _runSubmitTempOrder.apply(this, arguments);
|
|
@@ -4584,10 +4737,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4584
4737
|
value: function extractSubmitErrorResponse(error) {
|
|
4585
4738
|
var _error$response,
|
|
4586
4739
|
_error$response2,
|
|
4587
|
-
|
|
4740
|
+
_this25 = this;
|
|
4588
4741
|
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];
|
|
4589
4742
|
return candidates.find(function (candidate) {
|
|
4590
|
-
return
|
|
4743
|
+
return _this25.isSubmitErrorResponse(candidate);
|
|
4591
4744
|
}) || null;
|
|
4592
4745
|
}
|
|
4593
4746
|
}, {
|
|
@@ -4615,41 +4768,46 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4615
4768
|
key: "syncPaymentsToOrder",
|
|
4616
4769
|
value: function () {
|
|
4617
4770
|
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
|
|
4618
|
-
var
|
|
4771
|
+
var _params$confirmPendin;
|
|
4772
|
+
var tempOrder, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, paidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, submitResult;
|
|
4619
4773
|
return _regeneratorRuntime().wrap(function _callee31$(_context34) {
|
|
4620
4774
|
while (1) switch (_context34.prev = _context34.next) {
|
|
4621
4775
|
case 0:
|
|
4622
4776
|
tempOrder = this.ensureTempOrder();
|
|
4623
4777
|
mappedPayments = mapPaymentItemsToOrderPayments(params.payments || []);
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4778
|
+
shouldConfirmPendingVoucherPayments = (_params$confirmPendin = params.confirmPendingVoucherPayments) !== null && _params$confirmPendin !== void 0 ? _params$confirmPendin : params.submitWhenPaid === true;
|
|
4779
|
+
effectivePayments = shouldConfirmPendingVoucherPayments ? this.confirmPendingVoucherPaymentsInList(mappedPayments) : params.confirmPendingVoucherPayments === false ? this.discardPendingVoucherPaymentsFromList(mappedPayments) : mappedPayments;
|
|
4780
|
+
completion = this.getPaymentCompletion(effectivePayments);
|
|
4781
|
+
paidPaymentTotal = this.calculatePaymentTotal(effectivePayments);
|
|
4782
|
+
paymentStatus = completion.isOrderFullyPaid ? params.paymentStatus || 'paid' : paidPaymentTotal.gt(0) ? 'partially_paid' : 'payment_processing';
|
|
4783
|
+
tempOrder.payments = effectivePayments;
|
|
4627
4784
|
tempOrder.payment_status = paymentStatus;
|
|
4628
4785
|
this.persistTempOrder();
|
|
4629
|
-
_context34.next =
|
|
4786
|
+
_context34.next = 12;
|
|
4630
4787
|
return this.saveDraft();
|
|
4631
|
-
case
|
|
4788
|
+
case 12:
|
|
4632
4789
|
if (params.submitWhenPaid) {
|
|
4633
|
-
_context34.next =
|
|
4790
|
+
_context34.next = 14;
|
|
4634
4791
|
break;
|
|
4635
4792
|
}
|
|
4636
4793
|
return _context34.abrupt("return", completion);
|
|
4637
|
-
case
|
|
4794
|
+
case 14:
|
|
4638
4795
|
if (!(this.store.syncState === 'submitting')) {
|
|
4639
|
-
_context34.next =
|
|
4796
|
+
_context34.next = 16;
|
|
4640
4797
|
break;
|
|
4641
4798
|
}
|
|
4642
4799
|
return _context34.abrupt("return", completion);
|
|
4643
|
-
case
|
|
4800
|
+
case 16:
|
|
4644
4801
|
this.store.syncState = 'submitting';
|
|
4645
|
-
paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder,
|
|
4646
|
-
_context34.next =
|
|
4802
|
+
paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, effectivePayments);
|
|
4803
|
+
_context34.next = 20;
|
|
4647
4804
|
return this.submitTempOrder({
|
|
4648
|
-
payments:
|
|
4805
|
+
payments: effectivePayments,
|
|
4649
4806
|
paymentStatus: paymentStatus,
|
|
4650
4807
|
smallTicketDataFlag: params.smallTicketDataFlag,
|
|
4651
4808
|
businessCode: params.businessCode,
|
|
4652
4809
|
channel: params.channel,
|
|
4810
|
+
confirmPendingVoucherPayments: true,
|
|
4653
4811
|
enhancePayload: function enhancePayload(payload) {
|
|
4654
4812
|
var nextPayload = _objectSpread(_objectSpread({}, payload), {}, {
|
|
4655
4813
|
request_unique_idempotency_token: paymentSyncIdempotencyToken
|
|
@@ -4657,12 +4815,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4657
4815
|
return nextPayload;
|
|
4658
4816
|
}
|
|
4659
4817
|
});
|
|
4660
|
-
case
|
|
4818
|
+
case 20:
|
|
4661
4819
|
submitResult = _context34.sent;
|
|
4662
4820
|
return _context34.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
|
|
4663
4821
|
submitResult: submitResult
|
|
4664
4822
|
}));
|
|
4665
|
-
case
|
|
4823
|
+
case 22:
|
|
4666
4824
|
case "end":
|
|
4667
4825
|
return _context34.stop();
|
|
4668
4826
|
}
|
|
@@ -5175,27 +5333,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5175
5333
|
currentDiscounts = typeof ((_this$store$discount15 = this.store.discount) === null || _this$store$discount15 === void 0 ? void 0 : _this$store$discount15.getDiscountList) === 'function' ? this.store.discount.getDiscountList() || [] : [];
|
|
5176
5334
|
shouldSkipEmptyDiscountSync = hydratedEditDiscounts.length === 0 && currentDiscounts.length === 0;
|
|
5177
5335
|
if (shouldSkipEmptyDiscountSync) {
|
|
5178
|
-
_context42.next =
|
|
5336
|
+
_context42.next = 17;
|
|
5179
5337
|
break;
|
|
5180
5338
|
}
|
|
5181
|
-
|
|
5339
|
+
OrderModule.populateSavedAmounts(nextTempOrder.products, hydratedEditDiscounts);
|
|
5340
|
+
_context42.next = 15;
|
|
5182
5341
|
return (_this$store$discount16 = this.store.discount) === null || _this$store$discount16 === void 0 ? void 0 : _this$store$discount16.setOriginalDiscountList(hydratedEditDiscounts);
|
|
5183
|
-
case
|
|
5184
|
-
_context42.next =
|
|
5342
|
+
case 15:
|
|
5343
|
+
_context42.next = 17;
|
|
5185
5344
|
return (_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 ? void 0 : _this$store$discount17.setDiscountList(hydratedEditDiscounts);
|
|
5186
|
-
case
|
|
5345
|
+
case 17:
|
|
5187
5346
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
5188
|
-
_context42.next =
|
|
5347
|
+
_context42.next = 20;
|
|
5189
5348
|
break;
|
|
5190
5349
|
}
|
|
5191
|
-
_context42.next =
|
|
5350
|
+
_context42.next = 20;
|
|
5192
5351
|
return this.recalculateSummary({
|
|
5193
5352
|
createIfMissing: false
|
|
5194
5353
|
});
|
|
5195
|
-
case
|
|
5354
|
+
case 20:
|
|
5196
5355
|
this.persistTempOrder();
|
|
5197
5356
|
return _context42.abrupt("return", nextTempOrder);
|
|
5198
|
-
case
|
|
5357
|
+
case 22:
|
|
5199
5358
|
case "end":
|
|
5200
5359
|
return _context42.stop();
|
|
5201
5360
|
}
|
|
@@ -5242,7 +5401,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5242
5401
|
}, {
|
|
5243
5402
|
key: "normalizeTempOrderForRuntime",
|
|
5244
5403
|
value: function normalizeTempOrderForRuntime(raw, options) {
|
|
5245
|
-
var
|
|
5404
|
+
var _this26 = this;
|
|
5246
5405
|
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), raw || {});
|
|
5247
5406
|
// ES 列表详情使用 id 表示订单主键;OS 详情态统一依赖 order_id 驱动操作按钮。
|
|
5248
5407
|
if ((nextTempOrder.order_id === undefined || nextTempOrder.order_id === null) && (raw === null || raw === void 0 ? void 0 : raw.id) !== undefined && (raw === null || raw === void 0 ? void 0 : raw.id) !== null) {
|
|
@@ -5265,10 +5424,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5265
5424
|
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
5266
5425
|
var rawProducts = Array.isArray(raw.products) ? raw.products : [];
|
|
5267
5426
|
nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
|
|
5268
|
-
return
|
|
5427
|
+
return _this26.normalizeHydratedOrderProduct(p);
|
|
5269
5428
|
}) : [];
|
|
5270
5429
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
5271
|
-
var booking =
|
|
5430
|
+
var booking = _this26.normalizeHydratedBookingHolder(b || {});
|
|
5272
5431
|
return _objectSpread(_objectSpread({}, booking), {}, {
|
|
5273
5432
|
is_all: normalizeBookingIsAll(booking),
|
|
5274
5433
|
sub_type: normalizeBookingSubType(booking)
|
|
@@ -5436,7 +5595,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5436
5595
|
}, {
|
|
5437
5596
|
key: "normalizeHydratedOrderProduct",
|
|
5438
5597
|
value: function normalizeHydratedOrderProduct(product) {
|
|
5439
|
-
var
|
|
5598
|
+
var _this27 = this;
|
|
5440
5599
|
var row = _objectSpread({}, product || {});
|
|
5441
5600
|
if (row.num === undefined && row.product_quantity !== undefined) {
|
|
5442
5601
|
row.num = row.product_quantity;
|
|
@@ -5444,7 +5603,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5444
5603
|
var productSku = ensureProductSku(row);
|
|
5445
5604
|
row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
|
|
5446
5605
|
option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
|
|
5447
|
-
return
|
|
5606
|
+
return _this27.normalizeHydratedProductOptionItem(optionItem || {});
|
|
5448
5607
|
}))
|
|
5449
5608
|
});
|
|
5450
5609
|
delete row["product_".concat('option', "_item")];
|
|
@@ -5453,6 +5612,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5453
5612
|
if (row.booking_uid && !row.metadata.booking_uid) {
|
|
5454
5613
|
row.metadata.booking_uid = row.booking_uid;
|
|
5455
5614
|
}
|
|
5615
|
+
row = restoreHydratedBundleDiscounts(row, normalizeOrderProductDiscountList);
|
|
5456
5616
|
var existingIdentity = row.metadata.unique_identification_number || row.unique_identification_number;
|
|
5457
5617
|
if (!existingIdentity) {
|
|
5458
5618
|
row.metadata.unique_identification_number = createUuidV4();
|
|
@@ -5464,7 +5624,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5464
5624
|
metadata: _objectSpread(_objectSpread({}, row.metadata), normalized.metadata)
|
|
5465
5625
|
});
|
|
5466
5626
|
if (result.metadata) delete result.metadata.price_schema_version;
|
|
5467
|
-
|
|
5627
|
+
var restored = restoreHydratedBundleDiscounts(result, normalizeOrderProductDiscountList);
|
|
5628
|
+
return this.sanitizeOrderProductForTempOrder(restored);
|
|
5468
5629
|
}
|
|
5469
5630
|
}, {
|
|
5470
5631
|
key: "getLastOrderInfo",
|