@pisell/pisellos 2.2.197 → 2.2.199
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +7 -3
- package/dist/modules/Cart/utils/cartProduct.js +11 -1
- package/dist/modules/Cart/utils/changePrice.js +11 -11
- package/dist/modules/Order/index.d.ts +16 -0
- package/dist/modules/Order/index.js +1232 -568
- package/dist/modules/Order/types.d.ts +1 -0
- package/dist/modules/Order/utils.d.ts +33 -2
- package/dist/modules/Order/utils.js +112 -55
- package/dist/modules/Payment/walletpass.js +14 -7
- package/dist/modules/SalesSummary/utils.js +394 -149
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.js +294 -190
- package/dist/server/modules/order/index.d.ts +8 -0
- package/dist/server/modules/order/index.js +536 -317
- package/dist/server/modules/order/types.d.ts +2 -0
- package/dist/solution/BaseSales/index.js +2 -1
- package/dist/solution/BaseSales/types.d.ts +1 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +19 -4
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/ScanOrder/types.d.ts +1 -0
- package/dist/solution/ScanOrder/utils.js +26 -9
- package/dist/solution/VenueBooking/index.js +2 -1
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +4 -1
- package/lib/modules/Cart/utils/cartProduct.js +11 -1
- package/lib/modules/Cart/utils/changePrice.js +12 -20
- package/lib/modules/Order/index.d.ts +16 -0
- package/lib/modules/Order/index.js +525 -18
- package/lib/modules/Order/types.d.ts +1 -0
- package/lib/modules/Order/utils.d.ts +33 -2
- package/lib/modules/Order/utils.js +44 -9
- package/lib/modules/Payment/walletpass.js +7 -3
- package/lib/modules/SalesSummary/utils.js +256 -46
- package/lib/server/index.d.ts +3 -0
- package/lib/server/index.js +82 -3
- package/lib/server/modules/order/index.d.ts +8 -0
- package/lib/server/modules/order/index.js +106 -4
- package/lib/server/modules/order/types.d.ts +2 -0
- package/lib/solution/BaseSales/index.js +2 -1
- package/lib/solution/BaseSales/types.d.ts +1 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +15 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/ScanOrder/types.d.ts +1 -0
- package/lib/solution/ScanOrder/utils.js +28 -10
- package/lib/solution/VenueBooking/index.js +2 -1
- package/package.json +1 -1
|
@@ -2,19 +2,19 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArra
|
|
|
2
2
|
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."); }
|
|
3
3
|
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; } }
|
|
4
4
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
5
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
5
6
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
6
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."); }
|
|
7
8
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
8
9
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
9
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
10
|
-
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; } } }; }
|
|
11
|
-
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); }
|
|
12
|
-
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; }
|
|
13
|
-
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
|
-
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; }
|
|
15
10
|
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; }
|
|
16
11
|
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); } }
|
|
17
12
|
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
|
+
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
|
+
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; }
|
|
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
|
+
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
|
+
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; }
|
|
18
18
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
19
19
|
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); } }
|
|
20
20
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
@@ -100,10 +100,108 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
100
100
|
return _this;
|
|
101
101
|
}
|
|
102
102
|
_createClass(OrderModule, [{
|
|
103
|
+
key: "collectHydratedEditDiscounts",
|
|
104
|
+
value: function collectHydratedEditDiscounts(products) {
|
|
105
|
+
var discountMap = new Map();
|
|
106
|
+
var _iterator = _createForOfIteratorHelper(products || []),
|
|
107
|
+
_step;
|
|
108
|
+
try {
|
|
109
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
110
|
+
var product = _step.value;
|
|
111
|
+
var _iterator2 = _createForOfIteratorHelper((product === null || product === void 0 ? void 0 : product.discount_list) || []),
|
|
112
|
+
_step2;
|
|
113
|
+
try {
|
|
114
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
115
|
+
var _item$type2, _ref, _ref2, _item$discount$resour, _item$discount, _item$discount$title, _item$discount2, _item$amount, _ref3, _item$discount$origin, _item$discount3, _ref4, _ref5, _item$metadata$num, _item$metadata, _ref6, _ref7, _item$metadata$num2, _item$metadata2, _ref8, _item$discount$discou, _item$discount4, _ref9, _item$discount$origin2, _item$discount5, _item$amount2, _item$amount3, _product$product_id, _product$is_charge_ta, _ref10, _product$original_pri, _ref11, _item$discount$discou2, _item$discount6, _item$discount$discou3, _item$discount7;
|
|
116
|
+
var item = _step2.value;
|
|
117
|
+
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;
|
|
118
|
+
if (!type || type === 'product') continue;
|
|
119
|
+
var resourceId = (_ref = (_ref2 = (_item$discount$resour = item === null || item === void 0 || (_item$discount = item.discount) === null || _item$discount === void 0 ? void 0 : _item$discount.resource_id) !== null && _item$discount$resour !== void 0 ? _item$discount$resour : item === null || item === void 0 ? void 0 : item.resource_id) !== null && _ref2 !== void 0 ? _ref2 : item === null || item === void 0 ? void 0 : item.discount_id) !== null && _ref !== void 0 ? _ref : item === null || item === void 0 ? void 0 : item.order_discount_id;
|
|
120
|
+
if (resourceId === undefined || resourceId === null || resourceId === '') continue;
|
|
121
|
+
var id = Number(resourceId);
|
|
122
|
+
var key = Number.isFinite(id) ? id : String(resourceId);
|
|
123
|
+
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 : {};
|
|
124
|
+
var amount = Number((item === null || item === void 0 ? void 0 : item.amount) || 0);
|
|
125
|
+
var detail = {
|
|
126
|
+
amount: String((_item$amount = item === null || item === void 0 ? void 0 : item.amount) !== null && _item$amount !== void 0 ? _item$amount : '0'),
|
|
127
|
+
type: type,
|
|
128
|
+
resource_id: key,
|
|
129
|
+
title: title,
|
|
130
|
+
original_amount: String((_ref3 = (_item$discount$origin = item === null || item === void 0 || (_item$discount3 = item.discount) === null || _item$discount3 === void 0 ? void 0 : _item$discount3.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'),
|
|
131
|
+
num: Number((_ref4 = (_ref5 = (_item$metadata$num = item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.num) !== null && _item$metadata$num !== void 0 ? _item$metadata$num : product === null || product === void 0 ? void 0 : product.num) !== null && _ref5 !== void 0 ? _ref5 : product === null || product === void 0 ? void 0 : product.product_quantity) !== null && _ref4 !== void 0 ? _ref4 : 1) || 1,
|
|
132
|
+
metadata: item === null || item === void 0 ? void 0 : item.metadata,
|
|
133
|
+
discount: item === null || item === void 0 ? void 0 : item.discount,
|
|
134
|
+
_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
|
|
135
|
+
};
|
|
136
|
+
discountMap.set(key, {
|
|
137
|
+
id: key,
|
|
138
|
+
product_name: '',
|
|
139
|
+
encoded: '',
|
|
140
|
+
code: '',
|
|
141
|
+
tag: type,
|
|
142
|
+
product_id: (_ref8 = (_item$discount$discou = item === null || item === void 0 || (_item$discount4 = item.discount) === null || _item$discount4 === void 0 ? void 0 : _item$discount4.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,
|
|
143
|
+
relation_type: '',
|
|
144
|
+
par_value: String((_ref9 = (_item$discount$origin2 = item === null || item === void 0 || (_item$discount5 = item.discount) === null || _item$discount5 === void 0 ? void 0 : _item$discount5.original_amount) !== null && _item$discount$origin2 !== void 0 ? _item$discount$origin2 : item === null || item === void 0 ? void 0 : item.amount) !== null && _ref9 !== void 0 ? _ref9 : '0'),
|
|
145
|
+
used_par_value: String((_item$amount2 = item === null || item === void 0 ? void 0 : item.amount) !== null && _item$amount2 !== void 0 ? _item$amount2 : '0'),
|
|
146
|
+
limit_status: 'enable',
|
|
147
|
+
limited_relation_product_data: {
|
|
148
|
+
id: 0,
|
|
149
|
+
type: 'products',
|
|
150
|
+
product_ids: [product === null || product === void 0 ? void 0 : product.product_id].filter(function (value) {
|
|
151
|
+
return value !== undefined && value !== null;
|
|
152
|
+
}),
|
|
153
|
+
product_collection_id: [],
|
|
154
|
+
filter: 0,
|
|
155
|
+
exclude_product_ids: []
|
|
156
|
+
},
|
|
157
|
+
balance: String((_item$amount3 = item === null || item === void 0 ? void 0 : item.amount) !== null && _item$amount3 !== void 0 ? _item$amount3 : '0'),
|
|
158
|
+
format_title: title,
|
|
159
|
+
product: {
|
|
160
|
+
id: (_product$product_id = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : 0,
|
|
161
|
+
title: '',
|
|
162
|
+
is_charge_tax: (_product$is_charge_ta = product === null || product === void 0 ? void 0 : product.is_charge_tax) !== null && _product$is_charge_ta !== void 0 ? _product$is_charge_ta : 0,
|
|
163
|
+
base_price: String((_ref10 = (_product$original_pri = product === null || product === void 0 ? void 0 : product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : product === null || product === void 0 ? void 0 : product.selling_price) !== null && _ref10 !== void 0 ? _ref10 : '0')
|
|
164
|
+
},
|
|
165
|
+
type: type,
|
|
166
|
+
resource_id: key,
|
|
167
|
+
isEditMode: true,
|
|
168
|
+
isSelected: true,
|
|
169
|
+
isAvailable: true,
|
|
170
|
+
isUsed: true,
|
|
171
|
+
isDisabled: true,
|
|
172
|
+
amount: amount,
|
|
173
|
+
discount: _objectSpread(_objectSpread({}, (item === null || item === void 0 ? void 0 : item.discount) || {}), {}, {
|
|
174
|
+
resource_id: key,
|
|
175
|
+
discount_product_id: (_ref11 = (_item$discount$discou2 = item === null || item === void 0 || (_item$discount6 = item.discount) === null || _item$discount6 === void 0 ? void 0 : _item$discount6.discount_product_id) !== null && _item$discount$discou2 !== void 0 ? _item$discount$discou2 : product === null || product === void 0 ? void 0 : product.product_id) !== null && _ref11 !== void 0 ? _ref11 : 0,
|
|
176
|
+
discount_calculation_mode: (_item$discount$discou3 = item === null || item === void 0 || (_item$discount7 = item.discount) === null || _item$discount7 === void 0 ? void 0 : _item$discount7.discount_calculation_mode) !== null && _item$discount$discou3 !== void 0 ? _item$discount$discou3 : 'item_level'
|
|
177
|
+
}),
|
|
178
|
+
applicableProductDetails: [detail],
|
|
179
|
+
appliedProductDetails: [detail]
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
} catch (err) {
|
|
183
|
+
_iterator2.e(err);
|
|
184
|
+
} finally {
|
|
185
|
+
_iterator2.f();
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
} catch (err) {
|
|
189
|
+
_iterator.e(err);
|
|
190
|
+
} finally {
|
|
191
|
+
_iterator.f();
|
|
192
|
+
}
|
|
193
|
+
return Array.from(discountMap.values());
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Populate `savedAmount` on each discount based on product-level discount details.
|
|
198
|
+
* Only selected discounts get a non-zero value.
|
|
199
|
+
*/
|
|
200
|
+
}, {
|
|
103
201
|
key: "applyProductDiscountPrices",
|
|
104
202
|
value: function applyProductDiscountPrices(products) {
|
|
105
203
|
return (products || []).map(function (product) {
|
|
106
|
-
var _product$metadata$sou, _product$metadata3, _product$metadata4, _product$
|
|
204
|
+
var _product$metadata$sou, _product$metadata3, _product$metadata4, _product$original_pri2;
|
|
107
205
|
if (isManualProductDiscountProduct(product)) return product;
|
|
108
206
|
var discountItems = Array.isArray(product.discount_list) ? product.discount_list : [];
|
|
109
207
|
var hasOnlyPersistedDiscountSnapshots = product.order_detail_id !== undefined && product.order_detail_id !== null && discountItems.length > 0 && discountItems.every(function (discount) {
|
|
@@ -114,7 +212,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
114
212
|
}
|
|
115
213
|
var totalPerUnitDiscount = resolveEffectivePerUnitDiscount(product);
|
|
116
214
|
var optionSum = sumOptionUnitPrice(getProductSkuOptions(product));
|
|
117
|
-
var sourcePrice = (_product$metadata$sou = (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.source_product_price) !== null && _product$metadata$sou !== void 0 ? _product$metadata$sou : ((_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.main_product_original_price) != null ? new Decimal(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : (_product$
|
|
215
|
+
var sourcePrice = (_product$metadata$sou = (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.source_product_price) !== null && _product$metadata$sou !== void 0 ? _product$metadata$sou : ((_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.main_product_original_price) != null ? new Decimal(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : (_product$original_pri2 = product.original_price) !== null && _product$original_pri2 !== void 0 ? _product$original_pri2 : '0';
|
|
118
216
|
var newSourceSellingPrice = new Decimal(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
119
217
|
var newMainSellingPrice = new Decimal(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
120
218
|
if (product.metadata) {
|
|
@@ -265,7 +363,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
265
363
|
value: function () {
|
|
266
364
|
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
|
|
267
365
|
var _this$store$tempOrder, _this$store$discount, _this$store$tempOrder2;
|
|
268
|
-
var orderId, discountList, _this$store$discount2, _this$store$discount3;
|
|
366
|
+
var orderId, discountList, _this$store$discount2, _this$store$discount3, _this$store$discount4, currentEditDiscounts, currentEditDiscountIds, mergedDiscountList;
|
|
269
367
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
270
368
|
while (1) switch (_context2.prev = _context2.next) {
|
|
271
369
|
case 0:
|
|
@@ -284,20 +382,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
284
382
|
case 3:
|
|
285
383
|
discountList = _context2.sent;
|
|
286
384
|
if (!discountList) {
|
|
287
|
-
_context2.next =
|
|
385
|
+
_context2.next = 12;
|
|
288
386
|
break;
|
|
289
387
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
388
|
+
currentEditDiscounts = (((_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 ? void 0 : _this$store$discount2.getDiscountList()) || []).filter(function (discount) {
|
|
389
|
+
return discount === null || discount === void 0 ? void 0 : discount.isEditMode;
|
|
390
|
+
});
|
|
391
|
+
currentEditDiscountIds = new Set(currentEditDiscounts.map(function (discount) {
|
|
392
|
+
return discount === null || discount === void 0 ? void 0 : discount.id;
|
|
393
|
+
}));
|
|
394
|
+
mergedDiscountList = [].concat(_toConsumableArray(currentEditDiscounts), _toConsumableArray(discountList.filter(function (discount) {
|
|
395
|
+
return !currentEditDiscountIds.has(discount === null || discount === void 0 ? void 0 : discount.id);
|
|
396
|
+
})));
|
|
397
|
+
_context2.next = 10;
|
|
398
|
+
return (_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.setOriginalDiscountList(mergedDiscountList);
|
|
399
|
+
case 10:
|
|
400
|
+
_context2.next = 12;
|
|
401
|
+
return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.setDiscountList(mergedDiscountList);
|
|
402
|
+
case 12:
|
|
296
403
|
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) {
|
|
297
404
|
this.applyDiscount();
|
|
298
405
|
}
|
|
299
406
|
return _context2.abrupt("return", this.getDiscountList());
|
|
300
|
-
case
|
|
407
|
+
case 14:
|
|
301
408
|
case "end":
|
|
302
409
|
return _context2.stop();
|
|
303
410
|
}
|
|
@@ -311,41 +418,86 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
311
418
|
}, {
|
|
312
419
|
key: "getDiscountList",
|
|
313
420
|
value: function getDiscountList() {
|
|
314
|
-
var _this$store$
|
|
315
|
-
return ((_this$store$
|
|
421
|
+
var _this$store$discount5;
|
|
422
|
+
return ((_this$store$discount5 = this.store.discount) === null || _this$store$discount5 === void 0 ? void 0 : _this$store$discount5.getDiscountList()) || [];
|
|
316
423
|
}
|
|
317
424
|
}, {
|
|
318
|
-
key: "
|
|
425
|
+
key: "ensureEditDiscountConfigForProductChange",
|
|
319
426
|
value: function () {
|
|
320
|
-
var
|
|
321
|
-
var
|
|
322
|
-
var
|
|
427
|
+
var _ensureEditDiscountConfigForProductChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(tempOrder) {
|
|
428
|
+
var _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _this$store$discount6;
|
|
429
|
+
var orderId, customerId, currentDiscountList, hasRuntimeDiscounts;
|
|
323
430
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
324
431
|
while (1) switch (_context3.prev = _context3.next) {
|
|
325
432
|
case 0:
|
|
326
|
-
|
|
327
|
-
|
|
433
|
+
orderId = tempOrder.order_id;
|
|
434
|
+
customerId = Number(tempOrder.customer_id || ((_tempOrder$customer = tempOrder.customer) === null || _tempOrder$customer === void 0 ? void 0 : _tempOrder$customer.id) || ((_tempOrder$_extend = tempOrder._extend) === null || _tempOrder$_extend === void 0 || (_tempOrder$_extend = _tempOrder$_extend.customerSnapshot) === null || _tempOrder$_extend === void 0 ? void 0 : _tempOrder$_extend.id) || ((_tempOrder$_extend2 = tempOrder._extend) === null || _tempOrder$_extend2 === void 0 || (_tempOrder$_extend2 = _tempOrder$_extend2.customerSnapshot) === null || _tempOrder$_extend2 === void 0 ? void 0 : _tempOrder$_extend2.customer_id) || 0);
|
|
435
|
+
if (!(!orderId || !customerId || customerId === 1)) {
|
|
436
|
+
_context3.next = 4;
|
|
437
|
+
break;
|
|
438
|
+
}
|
|
439
|
+
return _context3.abrupt("return");
|
|
440
|
+
case 4:
|
|
441
|
+
currentDiscountList = ((_this$store$discount6 = this.store.discount) === null || _this$store$discount6 === void 0 ? void 0 : _this$store$discount6.getDiscountList()) || [];
|
|
442
|
+
hasRuntimeDiscounts = currentDiscountList.some(function (discount) {
|
|
443
|
+
return !(discount !== null && discount !== void 0 && discount.isEditMode);
|
|
444
|
+
});
|
|
445
|
+
if (!hasRuntimeDiscounts) {
|
|
446
|
+
_context3.next = 8;
|
|
447
|
+
break;
|
|
448
|
+
}
|
|
449
|
+
return _context3.abrupt("return");
|
|
450
|
+
case 8:
|
|
451
|
+
_context3.next = 10;
|
|
452
|
+
return this.loadDiscountConfig({
|
|
453
|
+
customerId: customerId,
|
|
454
|
+
action: 'edit',
|
|
455
|
+
orderId: Number(orderId),
|
|
456
|
+
apply: false
|
|
457
|
+
});
|
|
458
|
+
case 10:
|
|
459
|
+
case "end":
|
|
460
|
+
return _context3.stop();
|
|
461
|
+
}
|
|
462
|
+
}, _callee3, this);
|
|
463
|
+
}));
|
|
464
|
+
function ensureEditDiscountConfigForProductChange(_x4) {
|
|
465
|
+
return _ensureEditDiscountConfigForProductChange.apply(this, arguments);
|
|
466
|
+
}
|
|
467
|
+
return ensureEditDiscountConfigForProductChange;
|
|
468
|
+
}()
|
|
469
|
+
}, {
|
|
470
|
+
key: "scanCode",
|
|
471
|
+
value: function () {
|
|
472
|
+
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(code, customerId) {
|
|
473
|
+
var _this$store$discount7, _tempOrder$holder, _this$store$summary, _tempOrder$holder2;
|
|
474
|
+
var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref12, isAvailable, newDiscountList, unavailableReason, _this$store$discount8;
|
|
475
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
476
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
477
|
+
case 0:
|
|
478
|
+
_context4.next = 2;
|
|
479
|
+
return (_this$store$discount7 = this.store.discount) === null || _this$store$discount7 === void 0 ? void 0 : _this$store$discount7.batchSearch(code, {
|
|
328
480
|
customerId: customerId
|
|
329
481
|
});
|
|
330
482
|
case 2:
|
|
331
|
-
|
|
332
|
-
if (
|
|
333
|
-
|
|
483
|
+
_context4.t0 = _context4.sent;
|
|
484
|
+
if (_context4.t0) {
|
|
485
|
+
_context4.next = 5;
|
|
334
486
|
break;
|
|
335
487
|
}
|
|
336
|
-
|
|
488
|
+
_context4.t0 = {
|
|
337
489
|
discountList: [],
|
|
338
490
|
unavailableReasonKey: null
|
|
339
491
|
};
|
|
340
492
|
case 5:
|
|
341
|
-
resultDiscountWithReason =
|
|
493
|
+
resultDiscountWithReason = _context4.t0;
|
|
342
494
|
resultDiscountList = resultDiscountWithReason.discountList, unavailableReasonKey = resultDiscountWithReason.unavailableReasonKey;
|
|
343
495
|
rulesModule = this.store.rules;
|
|
344
496
|
if (rulesModule) {
|
|
345
|
-
|
|
497
|
+
_context4.next = 10;
|
|
346
498
|
break;
|
|
347
499
|
}
|
|
348
|
-
return
|
|
500
|
+
return _context4.abrupt("return", {
|
|
349
501
|
type: 'clientCalc',
|
|
350
502
|
isAvailable: false,
|
|
351
503
|
discountList: this.getDiscountList(),
|
|
@@ -354,10 +506,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
354
506
|
});
|
|
355
507
|
case 10:
|
|
356
508
|
if (resultDiscountList.length) {
|
|
357
|
-
|
|
509
|
+
_context4.next = 12;
|
|
358
510
|
break;
|
|
359
511
|
}
|
|
360
|
-
return
|
|
512
|
+
return _context4.abrupt("return", {
|
|
361
513
|
type: 'server',
|
|
362
514
|
isAvailable: false,
|
|
363
515
|
discountList: this.getDiscountList(),
|
|
@@ -378,10 +530,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
378
530
|
return m.id === n.id;
|
|
379
531
|
});
|
|
380
532
|
}))) {
|
|
381
|
-
|
|
533
|
+
_context4.next = 16;
|
|
382
534
|
break;
|
|
383
535
|
}
|
|
384
|
-
return
|
|
536
|
+
return _context4.abrupt("return", {
|
|
385
537
|
type: 'clientCalc',
|
|
386
538
|
isAvailable: true,
|
|
387
539
|
discountList: this.getDiscountList(),
|
|
@@ -392,7 +544,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
392
544
|
holders = tempOrder !== null && tempOrder !== void 0 && (_tempOrder$holder = tempOrder.holder) !== null && _tempOrder$holder !== void 0 && _tempOrder$holder.form_record_id ? [{
|
|
393
545
|
form_record_id: tempOrder.holder.form_record_id
|
|
394
546
|
}] : [];
|
|
395
|
-
|
|
547
|
+
_ref12 = rulesModule.isDiscountListAvailable({
|
|
396
548
|
productList: (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || [],
|
|
397
549
|
oldDiscountList: this.getDiscountList(),
|
|
398
550
|
newDiscountList: withScanList,
|
|
@@ -402,12 +554,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
402
554
|
}) || {
|
|
403
555
|
isAvailable: false,
|
|
404
556
|
discountList: this.getDiscountList()
|
|
405
|
-
}, isAvailable =
|
|
557
|
+
}, isAvailable = _ref12.isAvailable, newDiscountList = _ref12.discountList, unavailableReason = _ref12.unavailableReason;
|
|
406
558
|
if (isAvailable && newDiscountList) {
|
|
407
|
-
(_this$store$
|
|
559
|
+
(_this$store$discount8 = this.store.discount) === null || _this$store$discount8 === void 0 || _this$store$discount8.setDiscountList(newDiscountList);
|
|
408
560
|
this.applyDiscount();
|
|
409
561
|
}
|
|
410
|
-
return
|
|
562
|
+
return _context4.abrupt("return", {
|
|
411
563
|
type: 'clientCalc',
|
|
412
564
|
isAvailable: isAvailable || false,
|
|
413
565
|
discountList: newDiscountList || this.getDiscountList(),
|
|
@@ -416,11 +568,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
416
568
|
});
|
|
417
569
|
case 21:
|
|
418
570
|
case "end":
|
|
419
|
-
return
|
|
571
|
+
return _context4.stop();
|
|
420
572
|
}
|
|
421
|
-
},
|
|
573
|
+
}, _callee4, this);
|
|
422
574
|
}));
|
|
423
|
-
function scanCode(
|
|
575
|
+
function scanCode(_x5, _x6) {
|
|
424
576
|
return _scanCode.apply(this, arguments);
|
|
425
577
|
}
|
|
426
578
|
return scanCode;
|
|
@@ -428,7 +580,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
428
580
|
}, {
|
|
429
581
|
key: "applyDiscount",
|
|
430
582
|
value: function applyDiscount() {
|
|
431
|
-
var _this$store$
|
|
583
|
+
var _this$store$discount9, _tempOrder$holder3, _tempOrder$holder4, _this$store$summary2;
|
|
432
584
|
var tempOrder = this.store.tempOrder;
|
|
433
585
|
// 任意 products CRUD 后都应当重算 discount 状态;即使 products 为空,
|
|
434
586
|
// 也需要让 Rules.calcDiscount 把 DiscountModule 的 isSelected / isAvailable /
|
|
@@ -437,7 +589,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
437
589
|
delete tempOrder.discount_list;
|
|
438
590
|
var rulesModule = this.store.rules;
|
|
439
591
|
if (!rulesModule) return;
|
|
440
|
-
var discountList = ((_this$store$
|
|
592
|
+
var discountList = ((_this$store$discount9 = this.store.discount) === null || _this$store$discount9 === void 0 ? void 0 : _this$store$discount9.getDiscountList()) || [];
|
|
441
593
|
var holders = (_tempOrder$holder3 = tempOrder.holder) !== null && _tempOrder$holder3 !== void 0 && _tempOrder$holder3.form_record_id ? [{
|
|
442
594
|
form_record_id: tempOrder.holder.form_record_id
|
|
443
595
|
}] : [];
|
|
@@ -451,9 +603,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
451
603
|
if (result !== null && result !== void 0 && result.productList) {
|
|
452
604
|
var previousProductsByUid = indexOrderProductsByUid(tempOrder.products);
|
|
453
605
|
tempOrder.products = this.applyProductDiscountPrices((result.productList || []).map(function (product, index) {
|
|
454
|
-
var
|
|
606
|
+
var _ref13;
|
|
455
607
|
var uid = getOrderProductLineUid(product);
|
|
456
|
-
var previous = (
|
|
608
|
+
var previous = (_ref13 = uid ? previousProductsByUid.get(uid) : undefined) !== null && _ref13 !== void 0 ? _ref13 : previousProductsByUid.get("__index__:".concat(index));
|
|
457
609
|
if (isManualProductDiscountProduct(previous)) {
|
|
458
610
|
return previous;
|
|
459
611
|
}
|
|
@@ -464,9 +616,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
464
616
|
}));
|
|
465
617
|
}
|
|
466
618
|
if (result !== null && result !== void 0 && result.discountList) {
|
|
467
|
-
var _this$store$
|
|
619
|
+
var _this$store$discount10;
|
|
468
620
|
OrderModule.populateSavedAmounts(result.productList || tempOrder.products, result.discountList);
|
|
469
|
-
(_this$store$
|
|
621
|
+
(_this$store$discount10 = this.store.discount) === null || _this$store$discount10 === void 0 || _this$store$discount10.setDiscountList(result.discountList);
|
|
470
622
|
}
|
|
471
623
|
}
|
|
472
624
|
|
|
@@ -525,33 +677,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
525
677
|
}, {
|
|
526
678
|
key: "applyPromotion",
|
|
527
679
|
value: (function () {
|
|
528
|
-
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
680
|
+
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
529
681
|
var _this2 = this;
|
|
530
|
-
var tempOrder, result, removeSet,
|
|
531
|
-
return _regeneratorRuntime().wrap(function
|
|
532
|
-
while (1) switch (
|
|
682
|
+
var tempOrder, result, removeSet, _iterator3, _step3, reduce, _iterator6, _step6, _loop2, _iterator4, _step4, _loop, payload;
|
|
683
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context7) {
|
|
684
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
533
685
|
case 0:
|
|
534
686
|
if (!this.isApplyingPromotion) {
|
|
535
|
-
|
|
687
|
+
_context7.next = 2;
|
|
536
688
|
break;
|
|
537
689
|
}
|
|
538
|
-
return
|
|
690
|
+
return _context7.abrupt("return");
|
|
539
691
|
case 2:
|
|
540
692
|
if (this.promotionEvaluator) {
|
|
541
|
-
|
|
693
|
+
_context7.next = 4;
|
|
542
694
|
break;
|
|
543
695
|
}
|
|
544
|
-
return
|
|
696
|
+
return _context7.abrupt("return");
|
|
545
697
|
case 4:
|
|
546
698
|
tempOrder = this.store.tempOrder;
|
|
547
699
|
if (tempOrder) {
|
|
548
|
-
|
|
700
|
+
_context7.next = 7;
|
|
549
701
|
break;
|
|
550
702
|
}
|
|
551
|
-
return
|
|
703
|
+
return _context7.abrupt("return");
|
|
552
704
|
case 7:
|
|
553
705
|
this.isApplyingPromotion = true;
|
|
554
|
-
|
|
706
|
+
_context7.prev = 8;
|
|
555
707
|
result = processCartPromotion(tempOrder.products, this.promotionEvaluator); // step 1: toRemove —— 直接过滤
|
|
556
708
|
if (result.giftActions.toRemove.length > 0) {
|
|
557
709
|
removeSet = new Set(result.giftActions.toRemove.map(String));
|
|
@@ -562,23 +714,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
562
714
|
}
|
|
563
715
|
|
|
564
716
|
// step 2: toReduce —— 调整数量
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
717
|
+
_iterator3 = _createForOfIteratorHelper(result.giftActions.toReduce);
|
|
718
|
+
_context7.prev = 12;
|
|
719
|
+
_iterator3.s();
|
|
568
720
|
case 14:
|
|
569
|
-
if ((
|
|
570
|
-
|
|
721
|
+
if ((_step3 = _iterator3.n()).done) {
|
|
722
|
+
_context7.next = 34;
|
|
571
723
|
break;
|
|
572
724
|
}
|
|
573
|
-
reduce =
|
|
574
|
-
|
|
575
|
-
|
|
725
|
+
reduce = _step3.value;
|
|
726
|
+
_iterator6 = _createForOfIteratorHelper(reduce.items);
|
|
727
|
+
_context7.prev = 17;
|
|
576
728
|
_loop2 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop2() {
|
|
577
729
|
var item, product;
|
|
578
|
-
return _regeneratorRuntime().wrap(function _loop2$(
|
|
579
|
-
while (1) switch (
|
|
730
|
+
return _regeneratorRuntime().wrap(function _loop2$(_context6) {
|
|
731
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
580
732
|
case 0:
|
|
581
|
-
item =
|
|
733
|
+
item = _step6.value;
|
|
582
734
|
product = result.products.find(function (p) {
|
|
583
735
|
return getPromotionUid(p) === item.uid;
|
|
584
736
|
});
|
|
@@ -587,52 +739,52 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
587
739
|
}
|
|
588
740
|
case 3:
|
|
589
741
|
case "end":
|
|
590
|
-
return
|
|
742
|
+
return _context6.stop();
|
|
591
743
|
}
|
|
592
744
|
}, _loop2);
|
|
593
745
|
});
|
|
594
|
-
|
|
746
|
+
_iterator6.s();
|
|
595
747
|
case 20:
|
|
596
|
-
if ((
|
|
597
|
-
|
|
748
|
+
if ((_step6 = _iterator6.n()).done) {
|
|
749
|
+
_context7.next = 24;
|
|
598
750
|
break;
|
|
599
751
|
}
|
|
600
|
-
return
|
|
752
|
+
return _context7.delegateYield(_loop2(), "t0", 22);
|
|
601
753
|
case 22:
|
|
602
|
-
|
|
754
|
+
_context7.next = 20;
|
|
603
755
|
break;
|
|
604
756
|
case 24:
|
|
605
|
-
|
|
757
|
+
_context7.next = 29;
|
|
606
758
|
break;
|
|
607
759
|
case 26:
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
760
|
+
_context7.prev = 26;
|
|
761
|
+
_context7.t1 = _context7["catch"](17);
|
|
762
|
+
_iterator6.e(_context7.t1);
|
|
611
763
|
case 29:
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
return
|
|
764
|
+
_context7.prev = 29;
|
|
765
|
+
_iterator6.f();
|
|
766
|
+
return _context7.finish(29);
|
|
615
767
|
case 32:
|
|
616
|
-
|
|
768
|
+
_context7.next = 14;
|
|
617
769
|
break;
|
|
618
770
|
case 34:
|
|
619
|
-
|
|
771
|
+
_context7.next = 39;
|
|
620
772
|
break;
|
|
621
773
|
case 36:
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
774
|
+
_context7.prev = 36;
|
|
775
|
+
_context7.t2 = _context7["catch"](12);
|
|
776
|
+
_iterator3.e(_context7.t2);
|
|
625
777
|
case 39:
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
return
|
|
778
|
+
_context7.prev = 39;
|
|
779
|
+
_iterator3.f();
|
|
780
|
+
return _context7.finish(39);
|
|
629
781
|
case 42:
|
|
630
782
|
if (!(result.giftActions.toAdd.length > 0)) {
|
|
631
|
-
|
|
783
|
+
_context7.next = 65;
|
|
632
784
|
break;
|
|
633
785
|
}
|
|
634
786
|
if (this.giftSelectResolver) {
|
|
635
|
-
|
|
787
|
+
_context7.next = 47;
|
|
636
788
|
break;
|
|
637
789
|
}
|
|
638
790
|
if (result.giftActions.toAdd.some(function (g) {
|
|
@@ -643,19 +795,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
643
795
|
} else {
|
|
644
796
|
console.warn('[OrderModule] giftSelectResolver not set, skip applying single-option gifts', result.giftActions.toAdd);
|
|
645
797
|
}
|
|
646
|
-
|
|
798
|
+
_context7.next = 65;
|
|
647
799
|
break;
|
|
648
800
|
case 47:
|
|
649
|
-
|
|
650
|
-
|
|
801
|
+
_iterator4 = _createForOfIteratorHelper(result.giftActions.toAdd);
|
|
802
|
+
_context7.prev = 48;
|
|
651
803
|
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
652
|
-
var addAction, sameStrategy, giftProducts,
|
|
653
|
-
return _regeneratorRuntime().wrap(function _loop$(
|
|
654
|
-
while (1) switch (
|
|
804
|
+
var addAction, sameStrategy, giftProducts, _iterator5, _step5, gp;
|
|
805
|
+
return _regeneratorRuntime().wrap(function _loop$(_context5) {
|
|
806
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
655
807
|
case 0:
|
|
656
|
-
addAction =
|
|
808
|
+
addAction = _step4.value;
|
|
657
809
|
if (!(addAction.giftOptions.length === 1)) {
|
|
658
|
-
|
|
810
|
+
_context5.next = 6;
|
|
659
811
|
break;
|
|
660
812
|
}
|
|
661
813
|
sameStrategy = result.products.find(function (p) {
|
|
@@ -663,14 +815,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
663
815
|
return ((_p$metadata = p.metadata) === null || _p$metadata === void 0 || (_p$metadata = _p$metadata._giftInfo) === null || _p$metadata === void 0 ? void 0 : _p$metadata.strategyId) === addAction.strategyId;
|
|
664
816
|
});
|
|
665
817
|
if (!sameStrategy) {
|
|
666
|
-
|
|
818
|
+
_context5.next = 6;
|
|
667
819
|
break;
|
|
668
820
|
}
|
|
669
821
|
sameStrategy.num = (Number(sameStrategy.num) || 0) + (addAction.giftCount || 1);
|
|
670
|
-
return
|
|
822
|
+
return _context5.abrupt("return", 1);
|
|
671
823
|
case 6:
|
|
672
|
-
|
|
673
|
-
|
|
824
|
+
_context5.prev = 6;
|
|
825
|
+
_context5.next = 9;
|
|
674
826
|
return _this2.giftSelectResolver({
|
|
675
827
|
strategyId: addAction.strategyId,
|
|
676
828
|
strategyName: addAction.strategyName,
|
|
@@ -679,83 +831,83 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
679
831
|
sourceProductIds: addAction.sourceProductIds
|
|
680
832
|
});
|
|
681
833
|
case 9:
|
|
682
|
-
giftProducts =
|
|
834
|
+
giftProducts = _context5.sent;
|
|
683
835
|
if (!(Array.isArray(giftProducts) && giftProducts.length > 0)) {
|
|
684
|
-
|
|
836
|
+
_context5.next = 29;
|
|
685
837
|
break;
|
|
686
838
|
}
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
839
|
+
_iterator5 = _createForOfIteratorHelper(giftProducts);
|
|
840
|
+
_context5.prev = 12;
|
|
841
|
+
_iterator5.s();
|
|
690
842
|
case 14:
|
|
691
|
-
if ((
|
|
692
|
-
|
|
843
|
+
if ((_step5 = _iterator5.n()).done) {
|
|
844
|
+
_context5.next = 21;
|
|
693
845
|
break;
|
|
694
846
|
}
|
|
695
|
-
gp =
|
|
847
|
+
gp = _step5.value;
|
|
696
848
|
if (gp) {
|
|
697
|
-
|
|
849
|
+
_context5.next = 18;
|
|
698
850
|
break;
|
|
699
851
|
}
|
|
700
|
-
return
|
|
852
|
+
return _context5.abrupt("continue", 19);
|
|
701
853
|
case 18:
|
|
702
854
|
// normalize 略过:调用方应保证返回完整 OrderProduct
|
|
703
855
|
result.products.push(gp);
|
|
704
856
|
case 19:
|
|
705
|
-
|
|
857
|
+
_context5.next = 14;
|
|
706
858
|
break;
|
|
707
859
|
case 21:
|
|
708
|
-
|
|
860
|
+
_context5.next = 26;
|
|
709
861
|
break;
|
|
710
862
|
case 23:
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
863
|
+
_context5.prev = 23;
|
|
864
|
+
_context5.t0 = _context5["catch"](12);
|
|
865
|
+
_iterator5.e(_context5.t0);
|
|
714
866
|
case 26:
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
return
|
|
867
|
+
_context5.prev = 26;
|
|
868
|
+
_iterator5.f();
|
|
869
|
+
return _context5.finish(26);
|
|
718
870
|
case 29:
|
|
719
|
-
|
|
871
|
+
_context5.next = 34;
|
|
720
872
|
break;
|
|
721
873
|
case 31:
|
|
722
|
-
|
|
723
|
-
|
|
874
|
+
_context5.prev = 31;
|
|
875
|
+
_context5.t1 = _context5["catch"](6);
|
|
724
876
|
// 用户取消 / 选择失败 → 视为放弃本次新增
|
|
725
|
-
console.warn('[OrderModule] giftSelectResolver rejected, skip add gift', addAction.strategyId,
|
|
877
|
+
console.warn('[OrderModule] giftSelectResolver rejected, skip add gift', addAction.strategyId, _context5.t1);
|
|
726
878
|
case 34:
|
|
727
879
|
case "end":
|
|
728
|
-
return
|
|
880
|
+
return _context5.stop();
|
|
729
881
|
}
|
|
730
882
|
}, _loop, null, [[6, 31], [12, 23, 26, 29]]);
|
|
731
883
|
});
|
|
732
|
-
|
|
884
|
+
_iterator4.s();
|
|
733
885
|
case 51:
|
|
734
|
-
if ((
|
|
735
|
-
|
|
886
|
+
if ((_step4 = _iterator4.n()).done) {
|
|
887
|
+
_context7.next = 57;
|
|
736
888
|
break;
|
|
737
889
|
}
|
|
738
|
-
return
|
|
890
|
+
return _context7.delegateYield(_loop(), "t3", 53);
|
|
739
891
|
case 53:
|
|
740
|
-
if (!
|
|
741
|
-
|
|
892
|
+
if (!_context7.t3) {
|
|
893
|
+
_context7.next = 55;
|
|
742
894
|
break;
|
|
743
895
|
}
|
|
744
|
-
return
|
|
896
|
+
return _context7.abrupt("continue", 55);
|
|
745
897
|
case 55:
|
|
746
|
-
|
|
898
|
+
_context7.next = 51;
|
|
747
899
|
break;
|
|
748
900
|
case 57:
|
|
749
|
-
|
|
901
|
+
_context7.next = 62;
|
|
750
902
|
break;
|
|
751
903
|
case 59:
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
904
|
+
_context7.prev = 59;
|
|
905
|
+
_context7.t4 = _context7["catch"](48);
|
|
906
|
+
_iterator4.e(_context7.t4);
|
|
755
907
|
case 62:
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
return
|
|
908
|
+
_context7.prev = 62;
|
|
909
|
+
_iterator4.f();
|
|
910
|
+
return _context7.finish(62);
|
|
759
911
|
case 65:
|
|
760
912
|
tempOrder.products = result.products;
|
|
761
913
|
this.lastUnfulfilledPromotions = result.unfulfilledPromotions;
|
|
@@ -774,21 +926,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
774
926
|
products: tempOrder.products
|
|
775
927
|
};
|
|
776
928
|
this.effectsEmit('onPromotionApplied', payload);
|
|
777
|
-
|
|
929
|
+
_context7.next = 75;
|
|
778
930
|
break;
|
|
779
931
|
case 72:
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
console.error('[OrderModule] applyPromotion failed',
|
|
932
|
+
_context7.prev = 72;
|
|
933
|
+
_context7.t5 = _context7["catch"](8);
|
|
934
|
+
console.error('[OrderModule] applyPromotion failed', _context7.t5);
|
|
783
935
|
case 75:
|
|
784
|
-
|
|
936
|
+
_context7.prev = 75;
|
|
785
937
|
this.isApplyingPromotion = false;
|
|
786
|
-
return
|
|
938
|
+
return _context7.finish(75);
|
|
787
939
|
case 78:
|
|
788
940
|
case "end":
|
|
789
|
-
return
|
|
941
|
+
return _context7.stop();
|
|
790
942
|
}
|
|
791
|
-
},
|
|
943
|
+
}, _callee5, this, [[8, 72, 75, 78], [12, 36, 39, 42], [17, 26, 29, 32], [48, 59, 62, 65]]);
|
|
792
944
|
}));
|
|
793
945
|
function applyPromotion() {
|
|
794
946
|
return _applyPromotion.apply(this, arguments);
|
|
@@ -910,14 +1062,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
910
1062
|
}, {
|
|
911
1063
|
key: "saveDraft",
|
|
912
1064
|
value: function () {
|
|
913
|
-
var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
914
|
-
return _regeneratorRuntime().wrap(function
|
|
915
|
-
while (1) switch (
|
|
1065
|
+
var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
1066
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context8) {
|
|
1067
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
916
1068
|
case 0:
|
|
917
1069
|
case "end":
|
|
918
|
-
return
|
|
1070
|
+
return _context8.stop();
|
|
919
1071
|
}
|
|
920
|
-
},
|
|
1072
|
+
}, _callee6);
|
|
921
1073
|
}));
|
|
922
1074
|
function saveDraft() {
|
|
923
1075
|
return _saveDraft.apply(this, arguments);
|
|
@@ -932,18 +1084,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
932
1084
|
}, {
|
|
933
1085
|
key: "hydrateTempOrderFromLocalRecord",
|
|
934
1086
|
value: function () {
|
|
935
|
-
var _hydrateTempOrderFromLocalRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
936
|
-
return _regeneratorRuntime().wrap(function
|
|
937
|
-
while (1) switch (
|
|
1087
|
+
var _hydrateTempOrderFromLocalRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(record) {
|
|
1088
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context9) {
|
|
1089
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
938
1090
|
case 0:
|
|
939
|
-
return
|
|
1091
|
+
return _context9.abrupt("return", this.hydrateTempOrderFromRecord(record));
|
|
940
1092
|
case 1:
|
|
941
1093
|
case "end":
|
|
942
|
-
return
|
|
1094
|
+
return _context9.stop();
|
|
943
1095
|
}
|
|
944
|
-
},
|
|
1096
|
+
}, _callee7, this);
|
|
945
1097
|
}));
|
|
946
|
-
function hydrateTempOrderFromLocalRecord(
|
|
1098
|
+
function hydrateTempOrderFromLocalRecord(_x7) {
|
|
947
1099
|
return _hydrateTempOrderFromLocalRecord.apply(this, arguments);
|
|
948
1100
|
}
|
|
949
1101
|
return hydrateTempOrderFromLocalRecord;
|
|
@@ -951,8 +1103,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
951
1103
|
}, {
|
|
952
1104
|
key: "extractOrderIdFromSubmitResult",
|
|
953
1105
|
value: function extractOrderIdFromSubmitResult(result) {
|
|
954
|
-
var
|
|
955
|
-
return (
|
|
1106
|
+
var _ref14, _ref15, _ref16, _result$data$order_id, _result$data, _result$data2;
|
|
1107
|
+
return (_ref14 = (_ref15 = (_ref16 = (_result$data$order_id = result === null || result === void 0 || (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.order_id) !== null && _result$data$order_id !== void 0 ? _result$data$order_id : result === null || result === void 0 ? void 0 : result.order_id) !== null && _ref16 !== void 0 ? _ref16 : result === null || result === void 0 || (_result$data2 = result.data) === null || _result$data2 === void 0 ? void 0 : _result$data2.id) !== null && _ref15 !== void 0 ? _ref15 : result === null || result === void 0 ? void 0 : result.id) !== null && _ref14 !== void 0 ? _ref14 : null;
|
|
956
1108
|
}
|
|
957
1109
|
}, {
|
|
958
1110
|
key: "calculatePaymentEffectiveAmount",
|
|
@@ -974,7 +1126,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
974
1126
|
}, {
|
|
975
1127
|
key: "normalizePaymentSource",
|
|
976
1128
|
value: function normalizePaymentSource(payment, options) {
|
|
977
|
-
var
|
|
1129
|
+
var _ref17, _paymentRecord$origin;
|
|
978
1130
|
var paymentRecord = payment;
|
|
979
1131
|
var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
|
|
980
1132
|
if (!metadata.unique_identification_number) {
|
|
@@ -982,7 +1134,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
982
1134
|
}
|
|
983
1135
|
var normalized = _objectSpread(_objectSpread({}, paymentRecord), {}, {
|
|
984
1136
|
metadata: metadata,
|
|
985
|
-
origin_amount: (
|
|
1137
|
+
origin_amount: (_ref17 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref17 !== void 0 ? _ref17 : '0.00'
|
|
986
1138
|
});
|
|
987
1139
|
if (paymentRecord.status !== undefined) {
|
|
988
1140
|
normalized.status = paymentRecord.status;
|
|
@@ -1054,11 +1206,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1054
1206
|
if (targetAmount.lte(0)) return [];
|
|
1055
1207
|
var remainingAmount = Decimal.max(targetAmount.minus(nonVoucherTotal), 0);
|
|
1056
1208
|
var cappedVouchers = [];
|
|
1057
|
-
var
|
|
1058
|
-
|
|
1209
|
+
var _iterator7 = _createForOfIteratorHelper(params.vouchers),
|
|
1210
|
+
_step7;
|
|
1059
1211
|
try {
|
|
1060
|
-
for (
|
|
1061
|
-
var voucher =
|
|
1212
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
1213
|
+
var voucher = _step7.value;
|
|
1062
1214
|
if (remainingAmount.lte(0)) break;
|
|
1063
1215
|
var voucherAmount = Decimal.max(new Decimal(voucher.amount || 0), 0);
|
|
1064
1216
|
if (voucherAmount.lte(0)) continue;
|
|
@@ -1072,9 +1224,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1072
1224
|
remainingAmount = remainingAmount.minus(cappedAmount);
|
|
1073
1225
|
}
|
|
1074
1226
|
} catch (err) {
|
|
1075
|
-
|
|
1227
|
+
_iterator7.e(err);
|
|
1076
1228
|
} finally {
|
|
1077
|
-
|
|
1229
|
+
_iterator7.f();
|
|
1078
1230
|
}
|
|
1079
1231
|
return cappedVouchers;
|
|
1080
1232
|
}
|
|
@@ -1089,13 +1241,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1089
1241
|
customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
|
|
1090
1242
|
orderPaidAmount: summary.orderPaidAmount.plus(paymentRecord.origin_amount || 0),
|
|
1091
1243
|
gapPaidAmount: summary.gapPaidAmount.plus(_this4.calculatePaymentGapAmount(paymentRecord)),
|
|
1092
|
-
payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this4.calculatePaymentServiceFee(paymentRecord))
|
|
1244
|
+
payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this4.calculatePaymentServiceFee(paymentRecord)),
|
|
1245
|
+
roundingAmount: summary.roundingAmount.plus(_this4.calculatePaymentRoundingAmount(paymentRecord))
|
|
1093
1246
|
};
|
|
1094
1247
|
}, {
|
|
1095
1248
|
customerPaidAmount: new Decimal(0),
|
|
1096
1249
|
orderPaidAmount: new Decimal(0),
|
|
1097
1250
|
gapPaidAmount: new Decimal(0),
|
|
1098
|
-
payServiceChargeAmount: new Decimal(0)
|
|
1251
|
+
payServiceChargeAmount: new Decimal(0),
|
|
1252
|
+
roundingAmount: new Decimal(0)
|
|
1099
1253
|
});
|
|
1100
1254
|
}
|
|
1101
1255
|
}, {
|
|
@@ -1118,6 +1272,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1118
1272
|
var rounding = new Decimal(payment.rounding_amount || 0);
|
|
1119
1273
|
return new Decimal(payment.origin_amount || 0).minus(rounding);
|
|
1120
1274
|
}
|
|
1275
|
+
}, {
|
|
1276
|
+
key: "calculatePaymentRoundingAmount",
|
|
1277
|
+
value: function calculatePaymentRoundingAmount(payment) {
|
|
1278
|
+
if (payment.rounding_amount === undefined || payment.rounding_amount === null || payment.rounding_amount === '') {
|
|
1279
|
+
return new Decimal(0);
|
|
1280
|
+
}
|
|
1281
|
+
return new Decimal(payment.rounding_amount || 0);
|
|
1282
|
+
}
|
|
1121
1283
|
}, {
|
|
1122
1284
|
key: "formatSummaryMetadataMoney",
|
|
1123
1285
|
value: function formatSummaryMetadataMoney(value) {
|
|
@@ -1129,40 +1291,65 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1129
1291
|
key: "syncSummaryProductMetadata",
|
|
1130
1292
|
value: function syncSummaryProductMetadata(products) {
|
|
1131
1293
|
var moneyKeys = ['main_product_attached_bundle_surcharge_fee', 'main_product_attached_bundle_tax_fee', 'surcharge_rounding_remainder', 'tax_fee_rounding_remainder'];
|
|
1132
|
-
|
|
1133
|
-
|
|
1294
|
+
// 整单折扣均摊层产出的 payment 维度字段,直接由计算层写入 metadata,
|
|
1295
|
+
// 这里需把它们一并回写到商品 metadata 以便持久化/出站。
|
|
1296
|
+
var metadataMoneyKeys = ['main_product_attached_bundle_selling_price', 'main_product_attached_bundle_payment_price'];
|
|
1297
|
+
var _iterator8 = _createForOfIteratorHelper(products || []),
|
|
1298
|
+
_step8;
|
|
1134
1299
|
try {
|
|
1135
|
-
for (
|
|
1136
|
-
var product =
|
|
1300
|
+
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
1301
|
+
var product = _step8.value;
|
|
1137
1302
|
var productRecord = product;
|
|
1138
1303
|
var metadata = productRecord.metadata && _typeof(productRecord.metadata) === 'object' ? _objectSpread({}, productRecord.metadata) : {};
|
|
1139
1304
|
var hasMetadataPatch = false;
|
|
1140
|
-
var
|
|
1141
|
-
|
|
1305
|
+
var _iterator9 = _createForOfIteratorHelper(moneyKeys),
|
|
1306
|
+
_step9;
|
|
1142
1307
|
try {
|
|
1143
|
-
for (
|
|
1144
|
-
var key =
|
|
1308
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
1309
|
+
var key = _step9.value;
|
|
1145
1310
|
var value = this.formatSummaryMetadataMoney(productRecord[key]);
|
|
1146
1311
|
if (value === undefined) continue;
|
|
1147
1312
|
metadata[key] = value;
|
|
1148
1313
|
hasMetadataPatch = true;
|
|
1149
1314
|
}
|
|
1150
1315
|
} catch (err) {
|
|
1151
|
-
|
|
1316
|
+
_iterator9.e(err);
|
|
1317
|
+
} finally {
|
|
1318
|
+
_iterator9.f();
|
|
1319
|
+
}
|
|
1320
|
+
var _iterator10 = _createForOfIteratorHelper(metadataMoneyKeys),
|
|
1321
|
+
_step10;
|
|
1322
|
+
try {
|
|
1323
|
+
for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
|
|
1324
|
+
var _key = _step10.value;
|
|
1325
|
+
var _value = this.formatSummaryMetadataMoney(metadata[_key]);
|
|
1326
|
+
if (_value === undefined) continue;
|
|
1327
|
+
metadata[_key] = _value;
|
|
1328
|
+
hasMetadataPatch = true;
|
|
1329
|
+
}
|
|
1330
|
+
} catch (err) {
|
|
1331
|
+
_iterator10.e(err);
|
|
1152
1332
|
} finally {
|
|
1153
|
-
|
|
1333
|
+
_iterator10.f();
|
|
1334
|
+
}
|
|
1335
|
+
if (metadata.average_discount_amount_rate !== undefined) {
|
|
1336
|
+
hasMetadataPatch = true;
|
|
1154
1337
|
}
|
|
1155
1338
|
if (Array.isArray(productRecord.relation_surcharge_ids)) {
|
|
1156
1339
|
metadata.relation_surcharge_ids = productRecord.relation_surcharge_ids;
|
|
1157
1340
|
hasMetadataPatch = true;
|
|
1158
1341
|
}
|
|
1342
|
+
var productPaymentPrice = this.formatSummaryMetadataMoney(productRecord.payment_price);
|
|
1343
|
+
if (productPaymentPrice !== undefined) {
|
|
1344
|
+
productRecord.payment_price = productPaymentPrice;
|
|
1345
|
+
}
|
|
1159
1346
|
if (hasMetadataPatch) productRecord.metadata = metadata;
|
|
1160
1347
|
if (!Array.isArray(productRecord.product_bundle)) continue;
|
|
1161
|
-
var
|
|
1162
|
-
|
|
1348
|
+
var _iterator11 = _createForOfIteratorHelper(productRecord.product_bundle),
|
|
1349
|
+
_step11;
|
|
1163
1350
|
try {
|
|
1164
|
-
for (
|
|
1165
|
-
var bundle =
|
|
1351
|
+
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
|
1352
|
+
var bundle = _step11.value;
|
|
1166
1353
|
var bundleRecord = bundle;
|
|
1167
1354
|
var bundleMetadata = bundleRecord.metadata && _typeof(bundleRecord.metadata) === 'object' ? _objectSpread({}, bundleRecord.metadata) : {};
|
|
1168
1355
|
var hasBundleMetadataPatch = false;
|
|
@@ -1171,6 +1358,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1171
1358
|
bundleMetadata.surcharge_fee = bundleSurchargeFee;
|
|
1172
1359
|
hasBundleMetadataPatch = true;
|
|
1173
1360
|
}
|
|
1361
|
+
var bundlePaymentPrice = this.formatSummaryMetadataMoney(bundleRecord.bundle_payment_price);
|
|
1362
|
+
if (bundlePaymentPrice !== undefined) {
|
|
1363
|
+
bundleRecord.bundle_payment_price = bundlePaymentPrice;
|
|
1364
|
+
}
|
|
1174
1365
|
if (Array.isArray(bundleRecord.relation_surcharge_ids)) {
|
|
1175
1366
|
bundleMetadata.relation_surcharge_ids = bundleRecord.relation_surcharge_ids;
|
|
1176
1367
|
hasBundleMetadataPatch = true;
|
|
@@ -1178,15 +1369,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1178
1369
|
if (hasBundleMetadataPatch) bundleRecord.metadata = bundleMetadata;
|
|
1179
1370
|
}
|
|
1180
1371
|
} catch (err) {
|
|
1181
|
-
|
|
1372
|
+
_iterator11.e(err);
|
|
1182
1373
|
} finally {
|
|
1183
|
-
|
|
1374
|
+
_iterator11.f();
|
|
1184
1375
|
}
|
|
1185
1376
|
}
|
|
1186
1377
|
} catch (err) {
|
|
1187
|
-
|
|
1378
|
+
_iterator8.e(err);
|
|
1188
1379
|
} finally {
|
|
1189
|
-
|
|
1380
|
+
_iterator8.f();
|
|
1190
1381
|
}
|
|
1191
1382
|
}
|
|
1192
1383
|
}, {
|
|
@@ -1210,7 +1401,326 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1210
1401
|
value: function calculatePaymentTargetAmount(tempOrder, summary) {
|
|
1211
1402
|
var depositAmount = summary.deposit_amount || tempOrder.deposit_amount || '0.00';
|
|
1212
1403
|
var isDeposit = tempOrder.is_deposit === 1 || new Decimal(depositAmount || 0).gt(0);
|
|
1213
|
-
return isDeposit ? new Decimal(depositAmount || 0) : new Decimal(summary.
|
|
1404
|
+
return isDeposit ? new Decimal(depositAmount || 0) : new Decimal(summary.expect_amount || summary.total_amount || 0);
|
|
1405
|
+
}
|
|
1406
|
+
}, {
|
|
1407
|
+
key: "normalizeFingerprintMoney",
|
|
1408
|
+
value: function normalizeFingerprintMoney(value) {
|
|
1409
|
+
if (value === undefined || value === null || value === '') return '';
|
|
1410
|
+
try {
|
|
1411
|
+
var parsed = new Decimal(String(value || 0));
|
|
1412
|
+
return parsed.toFixed(4);
|
|
1413
|
+
} catch (_unused2) {
|
|
1414
|
+
return String(value);
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
}, {
|
|
1418
|
+
key: "normalizeFingerprintValue",
|
|
1419
|
+
value: function normalizeFingerprintValue(value) {
|
|
1420
|
+
var _this5 = this;
|
|
1421
|
+
if (Array.isArray(value)) {
|
|
1422
|
+
return value.map(function (item) {
|
|
1423
|
+
return _this5.normalizeFingerprintValue(item);
|
|
1424
|
+
});
|
|
1425
|
+
}
|
|
1426
|
+
if (!value || _typeof(value) !== 'object') return value !== null && value !== void 0 ? value : '';
|
|
1427
|
+
return Object.keys(value).sort().reduce(function (result, key) {
|
|
1428
|
+
result[key] = _this5.normalizeFingerprintValue(value[key]);
|
|
1429
|
+
return result;
|
|
1430
|
+
}, {});
|
|
1431
|
+
}
|
|
1432
|
+
}, {
|
|
1433
|
+
key: "buildProductFingerprintItem",
|
|
1434
|
+
value: function buildProductFingerprintItem(product) {
|
|
1435
|
+
var _product$product_id2,
|
|
1436
|
+
_product$product_vari,
|
|
1437
|
+
_product$num,
|
|
1438
|
+
_product$payment_pric,
|
|
1439
|
+
_sku$code,
|
|
1440
|
+
_sku$barcode,
|
|
1441
|
+
_ref18,
|
|
1442
|
+
_sku$variant_id,
|
|
1443
|
+
_this6 = this;
|
|
1444
|
+
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
1445
|
+
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
1446
|
+
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
1447
|
+
var _discount$type;
|
|
1448
|
+
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;
|
|
1449
|
+
});
|
|
1450
|
+
var extensionType = (product === null || product === void 0 ? void 0 : product.extension_type) || (discountTypes.includes('good_pass') ? 'good_pass' : 'normal');
|
|
1451
|
+
return {
|
|
1452
|
+
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,
|
|
1453
|
+
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,
|
|
1454
|
+
extension_type: extensionType,
|
|
1455
|
+
num: getSafeProductNum((_product$num = product === null || product === void 0 ? void 0 : product.num) !== null && _product$num !== void 0 ? _product$num : product === null || product === void 0 ? void 0 : product.product_quantity),
|
|
1456
|
+
selling_price: this.normalizeFingerprintMoney(product === null || product === void 0 ? void 0 : product.selling_price),
|
|
1457
|
+
original_price: this.normalizeFingerprintMoney(product === null || product === void 0 ? void 0 : product.original_price),
|
|
1458
|
+
payment_price: this.normalizeFingerprintMoney((_product$payment_pric = product === null || product === void 0 ? void 0 : product.payment_price) !== null && _product$payment_pric !== void 0 ? _product$payment_pric : product === null || product === void 0 ? void 0 : product.selling_price),
|
|
1459
|
+
metadata: {
|
|
1460
|
+
source_product_price: this.normalizeFingerprintMoney(metadata.source_product_price),
|
|
1461
|
+
main_product_selling_price: this.normalizeFingerprintMoney(metadata.main_product_selling_price),
|
|
1462
|
+
main_product_original_price: this.normalizeFingerprintMoney(metadata.main_product_original_price),
|
|
1463
|
+
product_discount_difference: this.normalizeFingerprintMoney(metadata.product_discount_difference)
|
|
1464
|
+
},
|
|
1465
|
+
product_sku: this.normalizeFingerprintValue({
|
|
1466
|
+
code: (_sku$code = sku.code) !== null && _sku$code !== void 0 ? _sku$code : '',
|
|
1467
|
+
barcode: (_sku$barcode = sku.barcode) !== null && _sku$barcode !== void 0 ? _sku$barcode : '',
|
|
1468
|
+
variant_id: (_ref18 = (_sku$variant_id = sku.variant_id) !== null && _sku$variant_id !== void 0 ? _sku$variant_id : product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _ref18 !== void 0 ? _ref18 : 0,
|
|
1469
|
+
variant: sku.variant || [],
|
|
1470
|
+
option: getProductSkuOptions(product || {}).map(function (option) {
|
|
1471
|
+
var _ref19, _option$id, _option$option_group_, _ref20, _option$option_group_2, _option$num, _option$add_price;
|
|
1472
|
+
return {
|
|
1473
|
+
id: (_ref19 = (_option$id = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id !== void 0 ? _option$id : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref19 !== void 0 ? _ref19 : null,
|
|
1474
|
+
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,
|
|
1475
|
+
option_group_item_id: (_ref20 = (_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 && _ref20 !== void 0 ? _ref20 : null,
|
|
1476
|
+
num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
|
|
1477
|
+
add_price: _this6.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)
|
|
1478
|
+
};
|
|
1479
|
+
})
|
|
1480
|
+
}),
|
|
1481
|
+
product_bundle: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.product_bundle) || []).map(function (bundle) {
|
|
1482
|
+
var _ref21, _ref22, _bundle$bundle_produc, _ref23, _bundle$bundle_varian, _bundle$num, _bundle$price_type, _bundle$price_type_ex;
|
|
1483
|
+
return {
|
|
1484
|
+
bundle_product_id: (_ref21 = (_ref22 = (_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 && _ref22 !== void 0 ? _ref22 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref21 !== void 0 ? _ref21 : null,
|
|
1485
|
+
bundle_variant_id: (_ref23 = (_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 && _ref23 !== void 0 ? _ref23 : 0,
|
|
1486
|
+
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),
|
|
1487
|
+
price: _this6.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
|
|
1488
|
+
bundle_selling_price: _this6.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
|
|
1489
|
+
price_type: (_bundle$price_type = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type !== void 0 ? _bundle$price_type : '',
|
|
1490
|
+
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 : ''
|
|
1491
|
+
};
|
|
1492
|
+
})),
|
|
1493
|
+
discount_list: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
1494
|
+
var _ref24, _discount$type2, _ref25, _ref26, _discount$discount_id, _discount$discount;
|
|
1495
|
+
return {
|
|
1496
|
+
type: (_ref24 = (_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 && _ref24 !== void 0 ? _ref24 : '',
|
|
1497
|
+
discount_id: (_ref25 = (_ref26 = (_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 && _ref26 !== void 0 ? _ref26 : discount === null || discount === void 0 || (_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) !== null && _ref25 !== void 0 ? _ref25 : null,
|
|
1498
|
+
amount: _this6.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
1499
|
+
};
|
|
1500
|
+
}))
|
|
1501
|
+
};
|
|
1502
|
+
}
|
|
1503
|
+
}, {
|
|
1504
|
+
key: "buildOrderProductsFingerprint",
|
|
1505
|
+
value: function buildOrderProductsFingerprint(products) {
|
|
1506
|
+
var _this7 = this;
|
|
1507
|
+
var items = (products || []).map(function (product) {
|
|
1508
|
+
return _this7.buildProductFingerprintItem(product);
|
|
1509
|
+
});
|
|
1510
|
+
items.sort(function (left, right) {
|
|
1511
|
+
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
1512
|
+
});
|
|
1513
|
+
return JSON.stringify(items);
|
|
1514
|
+
}
|
|
1515
|
+
}, {
|
|
1516
|
+
key: "buildProductStructuralFingerprintItem",
|
|
1517
|
+
value: function buildProductStructuralFingerprintItem(product) {
|
|
1518
|
+
var _product$product_id3,
|
|
1519
|
+
_product$product_vari2,
|
|
1520
|
+
_product$num2,
|
|
1521
|
+
_ref27,
|
|
1522
|
+
_metadata$unique_iden,
|
|
1523
|
+
_metadata$price_overr,
|
|
1524
|
+
_metadata$is_manual_d,
|
|
1525
|
+
_metadata$product_dis,
|
|
1526
|
+
_sku$code2,
|
|
1527
|
+
_sku$barcode2,
|
|
1528
|
+
_ref28,
|
|
1529
|
+
_sku$variant_id2,
|
|
1530
|
+
_this8 = this;
|
|
1531
|
+
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
1532
|
+
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
1533
|
+
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
1534
|
+
var _discount$type3;
|
|
1535
|
+
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;
|
|
1536
|
+
});
|
|
1537
|
+
var extensionType = (product === null || product === void 0 ? void 0 : product.extension_type) || (discountTypes.includes('good_pass') ? 'good_pass' : 'normal');
|
|
1538
|
+
return {
|
|
1539
|
+
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,
|
|
1540
|
+
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,
|
|
1541
|
+
extension_type: extensionType,
|
|
1542
|
+
num: getSafeProductNum((_product$num2 = product === null || product === void 0 ? void 0 : product.num) !== null && _product$num2 !== void 0 ? _product$num2 : product === null || product === void 0 ? void 0 : product.product_quantity),
|
|
1543
|
+
metadata: {
|
|
1544
|
+
unique_identification_number: (_ref27 = (_metadata$unique_iden = metadata.unique_identification_number) !== null && _metadata$unique_iden !== void 0 ? _metadata$unique_iden : product === null || product === void 0 ? void 0 : product.unique_identification_number) !== null && _ref27 !== void 0 ? _ref27 : '',
|
|
1545
|
+
price_override: (_metadata$price_overr = metadata.price_override) !== null && _metadata$price_overr !== void 0 ? _metadata$price_overr : '',
|
|
1546
|
+
is_manual_discount: (_metadata$is_manual_d = metadata.is_manual_discount) !== null && _metadata$is_manual_d !== void 0 ? _metadata$is_manual_d : '',
|
|
1547
|
+
product_discount_reason: (_metadata$product_dis = metadata.product_discount_reason) !== null && _metadata$product_dis !== void 0 ? _metadata$product_dis : ''
|
|
1548
|
+
},
|
|
1549
|
+
product_sku: this.normalizeFingerprintValue({
|
|
1550
|
+
code: (_sku$code2 = sku.code) !== null && _sku$code2 !== void 0 ? _sku$code2 : '',
|
|
1551
|
+
barcode: (_sku$barcode2 = sku.barcode) !== null && _sku$barcode2 !== void 0 ? _sku$barcode2 : '',
|
|
1552
|
+
variant_id: (_ref28 = (_sku$variant_id2 = sku.variant_id) !== null && _sku$variant_id2 !== void 0 ? _sku$variant_id2 : product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _ref28 !== void 0 ? _ref28 : 0,
|
|
1553
|
+
variant: sku.variant || [],
|
|
1554
|
+
option: getProductSkuOptions(product || {}).map(function (option) {
|
|
1555
|
+
var _ref29, _option$id2, _option$option_group_3, _ref30, _option$option_group_4, _option$num2, _option$add_price2;
|
|
1556
|
+
return {
|
|
1557
|
+
id: (_ref29 = (_option$id2 = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id2 !== void 0 ? _option$id2 : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref29 !== void 0 ? _ref29 : null,
|
|
1558
|
+
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,
|
|
1559
|
+
option_group_item_id: (_ref30 = (_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 && _ref30 !== void 0 ? _ref30 : null,
|
|
1560
|
+
num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
|
|
1561
|
+
add_price: _this8.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)
|
|
1562
|
+
};
|
|
1563
|
+
})
|
|
1564
|
+
}),
|
|
1565
|
+
product_bundle: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.product_bundle) || []).map(function (bundle) {
|
|
1566
|
+
var _ref31, _bundle$bundle_id, _ref32, _bundle$bundle_group_, _ref33, _ref34, _bundle$bundle_produc2, _ref35, _bundle$bundle_varian2, _bundle$num2, _bundle$price_type2, _bundle$price_type_ex2;
|
|
1567
|
+
return {
|
|
1568
|
+
bundle_id: (_ref31 = (_bundle$bundle_id = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_id) !== null && _bundle$bundle_id !== void 0 ? _bundle$bundle_id : bundle === null || bundle === void 0 ? void 0 : bundle.id) !== null && _ref31 !== void 0 ? _ref31 : null,
|
|
1569
|
+
bundle_group_id: (_ref32 = (_bundle$bundle_group_ = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_group_id) !== null && _bundle$bundle_group_ !== void 0 ? _bundle$bundle_group_ : bundle === null || bundle === void 0 ? void 0 : bundle.group_id) !== null && _ref32 !== void 0 ? _ref32 : null,
|
|
1570
|
+
bundle_product_id: (_ref33 = (_ref34 = (_bundle$bundle_produc2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref34 !== void 0 ? _ref34 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref33 !== void 0 ? _ref33 : null,
|
|
1571
|
+
bundle_variant_id: (_ref35 = (_bundle$bundle_varian2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_variant_id) !== null && _bundle$bundle_varian2 !== void 0 ? _bundle$bundle_varian2 : bundle === null || bundle === void 0 ? void 0 : bundle.product_variant_id) !== null && _ref35 !== void 0 ? _ref35 : 0,
|
|
1572
|
+
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),
|
|
1573
|
+
price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
|
|
1574
|
+
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 : '',
|
|
1575
|
+
option: _this8.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
|
|
1576
|
+
var _ref36, _option$id3, _option$option_group_5, _ref37, _option$option_group_6, _option$num3, _option$add_price3;
|
|
1577
|
+
return {
|
|
1578
|
+
id: (_ref36 = (_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 && _ref36 !== void 0 ? _ref36 : null,
|
|
1579
|
+
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,
|
|
1580
|
+
option_group_item_id: (_ref37 = (_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 && _ref37 !== void 0 ? _ref37 : null,
|
|
1581
|
+
num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
|
|
1582
|
+
add_price: _this8.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)
|
|
1583
|
+
};
|
|
1584
|
+
}))
|
|
1585
|
+
};
|
|
1586
|
+
})),
|
|
1587
|
+
discount_list: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
1588
|
+
var _ref38, _discount$type4, _ref39, _ref40, _discount$discount_id2, _discount$discount2;
|
|
1589
|
+
return {
|
|
1590
|
+
type: (_ref38 = (_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 && _ref38 !== void 0 ? _ref38 : '',
|
|
1591
|
+
discount_id: (_ref39 = (_ref40 = (_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 && _ref40 !== void 0 ? _ref40 : discount === null || discount === void 0 || (_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) !== null && _ref39 !== void 0 ? _ref39 : null,
|
|
1592
|
+
amount: _this8.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
1593
|
+
};
|
|
1594
|
+
}))
|
|
1595
|
+
};
|
|
1596
|
+
}
|
|
1597
|
+
}, {
|
|
1598
|
+
key: "buildOrderProductsStructuralFingerprint",
|
|
1599
|
+
value: function buildOrderProductsStructuralFingerprint(products) {
|
|
1600
|
+
var _this9 = this;
|
|
1601
|
+
var items = (products || []).map(function (product) {
|
|
1602
|
+
return _this9.buildProductStructuralFingerprintItem(product);
|
|
1603
|
+
});
|
|
1604
|
+
items.sort(function (left, right) {
|
|
1605
|
+
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
1606
|
+
});
|
|
1607
|
+
return JSON.stringify(items);
|
|
1608
|
+
}
|
|
1609
|
+
}, {
|
|
1610
|
+
key: "getOriginalSalesSnapshot",
|
|
1611
|
+
value: function getOriginalSalesSnapshot(tempOrder) {
|
|
1612
|
+
var _tempOrder$_extend3;
|
|
1613
|
+
var snapshot = (_tempOrder$_extend3 = tempOrder._extend) === null || _tempOrder$_extend3 === void 0 ? void 0 : _tempOrder$_extend3.originalSalesSnapshot;
|
|
1614
|
+
if (!snapshot || _typeof(snapshot) !== 'object') return null;
|
|
1615
|
+
if (typeof snapshot.productFingerprint !== 'string') return null;
|
|
1616
|
+
return snapshot;
|
|
1617
|
+
}
|
|
1618
|
+
}, {
|
|
1619
|
+
key: "restoreOriginalSnapshotIfProductsUnchanged",
|
|
1620
|
+
value: function restoreOriginalSnapshotIfProductsUnchanged(tempOrder) {
|
|
1621
|
+
var snapshot = this.getOriginalSalesSnapshot(tempOrder);
|
|
1622
|
+
if (!snapshot) return null;
|
|
1623
|
+
var currentFingerprint = this.buildOrderProductsFingerprint(tempOrder.products);
|
|
1624
|
+
if (currentFingerprint !== snapshot.productFingerprint) {
|
|
1625
|
+
var currentStructuralFingerprint = this.buildOrderProductsStructuralFingerprint(tempOrder.products);
|
|
1626
|
+
var snapshotStructuralFingerprint = this.buildOrderProductsStructuralFingerprint(Array.isArray(snapshot.products) ? snapshot.products : []);
|
|
1627
|
+
if (currentStructuralFingerprint !== snapshotStructuralFingerprint) return null;
|
|
1628
|
+
}
|
|
1629
|
+
var summary = _objectSpread(_objectSpread({}, createEmptySummary()), cloneDeep(snapshot.summary || {}));
|
|
1630
|
+
if (Array.isArray(snapshot.products)) {
|
|
1631
|
+
tempOrder.products = cloneDeep(snapshot.products);
|
|
1632
|
+
}
|
|
1633
|
+
if (Array.isArray(snapshot.surcharges)) {
|
|
1634
|
+
tempOrder.surcharges = cloneDeep(snapshot.surcharges);
|
|
1635
|
+
}
|
|
1636
|
+
tempOrder.surcharge_fee = summary.surcharge_fee || tempOrder.surcharge_fee;
|
|
1637
|
+
tempOrder.deposit_amount = summary.deposit_amount || '0.00';
|
|
1638
|
+
tempOrder.is_deposit = summary.deposit_amount !== '0.00' ? 1 : 0;
|
|
1639
|
+
this.store.summary = summary;
|
|
1640
|
+
return summary;
|
|
1641
|
+
}
|
|
1642
|
+
}, {
|
|
1643
|
+
key: "clearPersistedAmountFieldsForFullRecalc",
|
|
1644
|
+
value: function clearPersistedAmountFieldsForFullRecalc(products) {
|
|
1645
|
+
var moneyKeys = ['surcharge_fee', 'main_product_attached_bundle_surcharge_fee', 'surcharge_rounding_remainder', 'main_product_attached_bundle_tax_fee', 'tax_fee', 'original_tax_fee', 'tax_fee_rounding_remainder', 'original_tax_fee_rounding_remainder'];
|
|
1646
|
+
var metadataMoneyKeys = ['main_product_attached_bundle_surcharge_fee', 'surcharge_rounding_remainder', 'main_product_attached_bundle_tax_fee', 'tax_fee_rounding_remainder'];
|
|
1647
|
+
var _iterator12 = _createForOfIteratorHelper(products || []),
|
|
1648
|
+
_step12;
|
|
1649
|
+
try {
|
|
1650
|
+
for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
|
|
1651
|
+
var product = _step12.value;
|
|
1652
|
+
var record = product;
|
|
1653
|
+
var _iterator13 = _createForOfIteratorHelper(moneyKeys),
|
|
1654
|
+
_step13;
|
|
1655
|
+
try {
|
|
1656
|
+
for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
|
|
1657
|
+
var _key2 = _step13.value;
|
|
1658
|
+
delete record[_key2];
|
|
1659
|
+
}
|
|
1660
|
+
} catch (err) {
|
|
1661
|
+
_iterator13.e(err);
|
|
1662
|
+
} finally {
|
|
1663
|
+
_iterator13.f();
|
|
1664
|
+
}
|
|
1665
|
+
if (record.metadata && _typeof(record.metadata) === 'object') {
|
|
1666
|
+
record.metadata = _objectSpread({}, record.metadata);
|
|
1667
|
+
var _iterator14 = _createForOfIteratorHelper(metadataMoneyKeys),
|
|
1668
|
+
_step14;
|
|
1669
|
+
try {
|
|
1670
|
+
for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
|
|
1671
|
+
var key = _step14.value;
|
|
1672
|
+
delete record.metadata[key];
|
|
1673
|
+
}
|
|
1674
|
+
} catch (err) {
|
|
1675
|
+
_iterator14.e(err);
|
|
1676
|
+
} finally {
|
|
1677
|
+
_iterator14.f();
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
var _iterator15 = _createForOfIteratorHelper(record.product_bundle || []),
|
|
1681
|
+
_step15;
|
|
1682
|
+
try {
|
|
1683
|
+
for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
|
|
1684
|
+
var bundle = _step15.value;
|
|
1685
|
+
var _iterator16 = _createForOfIteratorHelper(moneyKeys),
|
|
1686
|
+
_step16;
|
|
1687
|
+
try {
|
|
1688
|
+
for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
|
|
1689
|
+
var _key4 = _step16.value;
|
|
1690
|
+
delete bundle[_key4];
|
|
1691
|
+
}
|
|
1692
|
+
} catch (err) {
|
|
1693
|
+
_iterator16.e(err);
|
|
1694
|
+
} finally {
|
|
1695
|
+
_iterator16.f();
|
|
1696
|
+
}
|
|
1697
|
+
if (bundle.metadata && _typeof(bundle.metadata) === 'object') {
|
|
1698
|
+
bundle.metadata = _objectSpread({}, bundle.metadata);
|
|
1699
|
+
var _iterator17 = _createForOfIteratorHelper(metadataMoneyKeys),
|
|
1700
|
+
_step17;
|
|
1701
|
+
try {
|
|
1702
|
+
for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
|
|
1703
|
+
var _key3 = _step17.value;
|
|
1704
|
+
delete bundle.metadata[_key3];
|
|
1705
|
+
}
|
|
1706
|
+
} catch (err) {
|
|
1707
|
+
_iterator17.e(err);
|
|
1708
|
+
} finally {
|
|
1709
|
+
_iterator17.f();
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
} catch (err) {
|
|
1714
|
+
_iterator15.e(err);
|
|
1715
|
+
} finally {
|
|
1716
|
+
_iterator15.f();
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
} catch (err) {
|
|
1720
|
+
_iterator12.e(err);
|
|
1721
|
+
} finally {
|
|
1722
|
+
_iterator12.f();
|
|
1723
|
+
}
|
|
1214
1724
|
}
|
|
1215
1725
|
}, {
|
|
1216
1726
|
key: "getPaymentTargetAmount",
|
|
@@ -1235,15 +1745,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1235
1745
|
}, {
|
|
1236
1746
|
key: "restoreOrder",
|
|
1237
1747
|
value: function restoreOrder() {
|
|
1238
|
-
var _this$store$
|
|
1748
|
+
var _this$store$discount11, _this$store$discount12;
|
|
1239
1749
|
var freshTempOrder = this.createDefaultTempOrderInstance();
|
|
1240
1750
|
this.ensureExternalSaleNumber(freshTempOrder);
|
|
1241
1751
|
this.store.tempOrder = freshTempOrder;
|
|
1242
1752
|
this.store.summary = createEmptySummary();
|
|
1243
1753
|
this.store.lastOrderInfo = undefined;
|
|
1244
1754
|
this.store.syncState = undefined;
|
|
1245
|
-
void ((_this$store$
|
|
1246
|
-
void ((_this$store$
|
|
1755
|
+
void ((_this$store$discount11 = this.store.discount) === null || _this$store$discount11 === void 0 ? void 0 : _this$store$discount11.setOriginalDiscountList([]));
|
|
1756
|
+
void ((_this$store$discount12 = this.store.discount) === null || _this$store$discount12 === void 0 ? void 0 : _this$store$discount12.setDiscountList([]));
|
|
1247
1757
|
this.persistTempOrder();
|
|
1248
1758
|
return freshTempOrder;
|
|
1249
1759
|
}
|
|
@@ -1255,13 +1765,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1255
1765
|
}, {
|
|
1256
1766
|
key: "replaceTempOrder",
|
|
1257
1767
|
value: function () {
|
|
1258
|
-
var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1768
|
+
var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(tempOrder, options) {
|
|
1259
1769
|
var nextTempOrder;
|
|
1260
|
-
return _regeneratorRuntime().wrap(function
|
|
1261
|
-
while (1) switch (
|
|
1770
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context10) {
|
|
1771
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
1262
1772
|
case 0:
|
|
1263
1773
|
if (isTempOrder(tempOrder)) {
|
|
1264
|
-
|
|
1774
|
+
_context10.next = 2;
|
|
1265
1775
|
break;
|
|
1266
1776
|
}
|
|
1267
1777
|
throw new Error('无效的 tempOrder 数据');
|
|
@@ -1271,15 +1781,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1271
1781
|
});
|
|
1272
1782
|
this.store.tempOrder = nextTempOrder;
|
|
1273
1783
|
if (!((options === null || options === void 0 ? void 0 : options.recalculateSummary) !== false)) {
|
|
1274
|
-
|
|
1784
|
+
_context10.next = 9;
|
|
1275
1785
|
break;
|
|
1276
1786
|
}
|
|
1277
|
-
|
|
1787
|
+
_context10.next = 7;
|
|
1278
1788
|
return this.recalculateSummary({
|
|
1279
1789
|
createIfMissing: false
|
|
1280
1790
|
});
|
|
1281
1791
|
case 7:
|
|
1282
|
-
|
|
1792
|
+
_context10.next = 10;
|
|
1283
1793
|
break;
|
|
1284
1794
|
case 9:
|
|
1285
1795
|
this.store.summary = createEmptySummary();
|
|
@@ -1288,20 +1798,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1288
1798
|
this.persistTempOrder();
|
|
1289
1799
|
}
|
|
1290
1800
|
if (!(options !== null && options !== void 0 && options.saveDraft)) {
|
|
1291
|
-
|
|
1801
|
+
_context10.next = 14;
|
|
1292
1802
|
break;
|
|
1293
1803
|
}
|
|
1294
|
-
|
|
1804
|
+
_context10.next = 14;
|
|
1295
1805
|
return this.saveDraft();
|
|
1296
1806
|
case 14:
|
|
1297
|
-
return
|
|
1807
|
+
return _context10.abrupt("return", nextTempOrder);
|
|
1298
1808
|
case 15:
|
|
1299
1809
|
case "end":
|
|
1300
|
-
return
|
|
1810
|
+
return _context10.stop();
|
|
1301
1811
|
}
|
|
1302
|
-
},
|
|
1812
|
+
}, _callee8, this);
|
|
1303
1813
|
}));
|
|
1304
|
-
function replaceTempOrder(
|
|
1814
|
+
function replaceTempOrder(_x8, _x9) {
|
|
1305
1815
|
return _replaceTempOrder.apply(this, arguments);
|
|
1306
1816
|
}
|
|
1307
1817
|
return replaceTempOrder;
|
|
@@ -1309,13 +1819,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1309
1819
|
}, {
|
|
1310
1820
|
key: "getOrderIdentity",
|
|
1311
1821
|
value: function getOrderIdentity() {
|
|
1312
|
-
var
|
|
1822
|
+
var _ref41, _ref42, _tempOrder$order_id, _tempOrder$_extend4;
|
|
1313
1823
|
var tempOrder = this.store.tempOrder;
|
|
1314
1824
|
if (!tempOrder) return null;
|
|
1315
1825
|
var lastOrderInfo = this.store.lastOrderInfo || {};
|
|
1316
|
-
var orderId = (
|
|
1826
|
+
var orderId = (_ref41 = (_ref42 = (_tempOrder$order_id = tempOrder.order_id) !== null && _tempOrder$order_id !== void 0 ? _tempOrder$order_id : lastOrderInfo.order_id) !== null && _ref42 !== void 0 ? _ref42 : lastOrderInfo.id) !== null && _ref41 !== void 0 ? _ref41 : null;
|
|
1317
1827
|
return {
|
|
1318
|
-
localId: this.cacheId || ((_tempOrder$
|
|
1828
|
+
localId: this.cacheId || ((_tempOrder$_extend4 = tempOrder._extend) === null || _tempOrder$_extend4 === void 0 ? void 0 : _tempOrder$_extend4.localId),
|
|
1319
1829
|
orderId: orderId,
|
|
1320
1830
|
externalSaleNumber: tempOrder.external_sale_number || lastOrderInfo.external_sale_number || '',
|
|
1321
1831
|
orderNumber: tempOrder.order_number || lastOrderInfo.order_number || '',
|
|
@@ -1387,32 +1897,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1387
1897
|
}, {
|
|
1388
1898
|
key: "addNewOrder",
|
|
1389
1899
|
value: function () {
|
|
1390
|
-
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1900
|
+
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
1391
1901
|
var tempOrder;
|
|
1392
|
-
return _regeneratorRuntime().wrap(function
|
|
1393
|
-
while (1) switch (
|
|
1902
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context11) {
|
|
1903
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
1394
1904
|
case 0:
|
|
1395
1905
|
tempOrder = this.ensureTempOrder();
|
|
1396
1906
|
this.ensureExternalSaleNumber(tempOrder);
|
|
1397
|
-
|
|
1907
|
+
_context11.next = 4;
|
|
1398
1908
|
return this.recalculateSummary({
|
|
1399
1909
|
createIfMissing: true
|
|
1400
1910
|
});
|
|
1401
1911
|
case 4:
|
|
1402
1912
|
this.persistTempOrder();
|
|
1403
1913
|
if (!this.draftPersistEnabled) {
|
|
1404
|
-
|
|
1914
|
+
_context11.next = 8;
|
|
1405
1915
|
break;
|
|
1406
1916
|
}
|
|
1407
|
-
|
|
1917
|
+
_context11.next = 8;
|
|
1408
1918
|
return this.saveDraft();
|
|
1409
1919
|
case 8:
|
|
1410
|
-
return
|
|
1920
|
+
return _context11.abrupt("return", tempOrder);
|
|
1411
1921
|
case 9:
|
|
1412
1922
|
case "end":
|
|
1413
|
-
return
|
|
1923
|
+
return _context11.stop();
|
|
1414
1924
|
}
|
|
1415
|
-
},
|
|
1925
|
+
}, _callee9, this);
|
|
1416
1926
|
}));
|
|
1417
1927
|
function addNewOrder() {
|
|
1418
1928
|
return _addNewOrder.apply(this, arguments);
|
|
@@ -1445,9 +1955,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1445
1955
|
}, {
|
|
1446
1956
|
key: "sanitizeTempOrderProducts",
|
|
1447
1957
|
value: function sanitizeTempOrderProducts(tempOrder) {
|
|
1448
|
-
var
|
|
1958
|
+
var _this10 = this;
|
|
1449
1959
|
tempOrder.products = (tempOrder.products || []).map(function (product) {
|
|
1450
|
-
return
|
|
1960
|
+
return _this10.sanitizeOrderProductForTempOrder(product);
|
|
1451
1961
|
});
|
|
1452
1962
|
}
|
|
1453
1963
|
}, {
|
|
@@ -1466,11 +1976,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1466
1976
|
}, {
|
|
1467
1977
|
key: "captureProductRuntime",
|
|
1468
1978
|
value: function captureProductRuntime(tempOrder, rawProduct, normalizedProduct, existedUid) {
|
|
1469
|
-
var _extend$productsByUid,
|
|
1979
|
+
var _extend$productsByUid, _ref43, _rawProduct$_origin;
|
|
1470
1980
|
var uid = existedUid || this.getProductUid(normalizedProduct);
|
|
1471
1981
|
var extend = this.ensureExtend(tempOrder);
|
|
1472
1982
|
var existed = ((_extend$productsByUid = extend.productsByUid) === null || _extend$productsByUid === void 0 ? void 0 : _extend$productsByUid[uid]) || {};
|
|
1473
|
-
var origin = (
|
|
1983
|
+
var origin = (_ref43 = (_rawProduct$_origin = rawProduct._origin) !== null && _rawProduct$_origin !== void 0 ? _rawProduct$_origin : normalizedProduct._origin) !== null && _ref43 !== void 0 ? _ref43 : existed.origin;
|
|
1474
1984
|
extend.productsByUid[uid] = _objectSpread(_objectSpread({}, existed), origin !== undefined ? {
|
|
1475
1985
|
origin: origin
|
|
1476
1986
|
} : {});
|
|
@@ -1515,9 +2025,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1515
2025
|
}, {
|
|
1516
2026
|
key: "findBookingIndexByUniqueIdentificationNumber",
|
|
1517
2027
|
value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
|
|
1518
|
-
var
|
|
2028
|
+
var _this11 = this;
|
|
1519
2029
|
return (tempOrder.bookings || []).findIndex(function (booking) {
|
|
1520
|
-
return
|
|
2030
|
+
return _this11.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
|
|
1521
2031
|
});
|
|
1522
2032
|
}
|
|
1523
2033
|
}, {
|
|
@@ -1525,12 +2035,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1525
2035
|
value: function removeLinkedBookingsForProduct(tempOrder, product) {
|
|
1526
2036
|
var _product$metadata5,
|
|
1527
2037
|
_product$metadata6,
|
|
1528
|
-
|
|
2038
|
+
_this12 = this;
|
|
1529
2039
|
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);
|
|
1530
2040
|
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);
|
|
1531
2041
|
if (!productUid && !bookingUid) return;
|
|
1532
2042
|
tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
|
|
1533
|
-
var currentBookingUid =
|
|
2043
|
+
var currentBookingUid = _this12.getBookingUniqueIdentificationNumber(booking);
|
|
1534
2044
|
if (bookingUid && currentBookingUid === String(bookingUid)) return false;
|
|
1535
2045
|
if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
|
|
1536
2046
|
return true;
|
|
@@ -1547,25 +2057,38 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1547
2057
|
}, {
|
|
1548
2058
|
key: "recalculateSummary",
|
|
1549
2059
|
value: function () {
|
|
1550
|
-
var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1551
|
-
var
|
|
1552
|
-
|
|
1553
|
-
|
|
2060
|
+
var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(options) {
|
|
2061
|
+
var _ref44, _salesSummaryResult$e;
|
|
2062
|
+
var tempOrder, snapshotSummary, shouldFullRecalculateFromSnapshot, summaryProducts, salesSummary, existedSummary, totalRefundAmount, paidPaymentSummary, emptyBaseSummary, emptySummary, salesSummaryResult, roundingAmount, payServiceChargeAmount, hasSalesSummaryAmount, expectAmount, amountPaymentPatch, normalizedExpectAmountPatch, summaryForGap, summary;
|
|
2063
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context12) {
|
|
2064
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1554
2065
|
case 0:
|
|
1555
2066
|
tempOrder = options !== null && options !== void 0 && options.createIfMissing ? this.ensureTempOrder() : this.store.tempOrder;
|
|
1556
2067
|
if (tempOrder) {
|
|
1557
|
-
|
|
2068
|
+
_context12.next = 3;
|
|
1558
2069
|
break;
|
|
1559
2070
|
}
|
|
1560
|
-
return
|
|
2071
|
+
return _context12.abrupt("return", null);
|
|
1561
2072
|
case 3:
|
|
1562
2073
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
2074
|
+
snapshotSummary = this.restoreOriginalSnapshotIfProductsUnchanged(tempOrder);
|
|
2075
|
+
if (!snapshotSummary) {
|
|
2076
|
+
_context12.next = 7;
|
|
2077
|
+
break;
|
|
2078
|
+
}
|
|
2079
|
+
return _context12.abrupt("return", snapshotSummary);
|
|
2080
|
+
case 7:
|
|
2081
|
+
shouldFullRecalculateFromSnapshot = Boolean(this.getOriginalSalesSnapshot(tempOrder));
|
|
2082
|
+
summaryProducts = shouldFullRecalculateFromSnapshot ? cloneDeep(tempOrder.products || []) : tempOrder.products;
|
|
2083
|
+
if (shouldFullRecalculateFromSnapshot) {
|
|
2084
|
+
this.clearPersistedAmountFieldsForFullRecalc(summaryProducts || []);
|
|
2085
|
+
}
|
|
1563
2086
|
salesSummary = this.getSalesSummary();
|
|
1564
2087
|
existedSummary = this.store.summary || createEmptySummary();
|
|
1565
2088
|
totalRefundAmount = existedSummary.total_refund_amount || '0.00';
|
|
1566
2089
|
paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
|
|
1567
2090
|
if (salesSummary) {
|
|
1568
|
-
|
|
2091
|
+
_context12.next = 21;
|
|
1569
2092
|
break;
|
|
1570
2093
|
}
|
|
1571
2094
|
emptyBaseSummary = _objectSpread(_objectSpread({}, createEmptySummary()), {}, {
|
|
@@ -1579,7 +2102,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1579
2102
|
summary: emptyBaseSummary,
|
|
1580
2103
|
orderPaidAmount: paidPaymentSummary.gapPaidAmount
|
|
1581
2104
|
}),
|
|
1582
|
-
pay_service_charge_amount: paidPaymentSummary.payServiceChargeAmount.toFixed(2)
|
|
2105
|
+
pay_service_charge_amount: paidPaymentSummary.payServiceChargeAmount.toFixed(2),
|
|
2106
|
+
rounding_amount: paidPaymentSummary.roundingAmount.toFixed(2)
|
|
1583
2107
|
});
|
|
1584
2108
|
tempOrder.surcharge_fee = emptySummary.surcharge_fee;
|
|
1585
2109
|
this.store.summary = emptySummary;
|
|
@@ -1587,30 +2111,46 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1587
2111
|
previousSummary: existedSummary,
|
|
1588
2112
|
summary: emptySummary
|
|
1589
2113
|
});
|
|
1590
|
-
return
|
|
1591
|
-
case
|
|
1592
|
-
|
|
2114
|
+
return _context12.abrupt("return", this.store.summary);
|
|
2115
|
+
case 21:
|
|
2116
|
+
_context12.next = 23;
|
|
1593
2117
|
return salesSummary.getSummary({
|
|
1594
|
-
products:
|
|
2118
|
+
products: summaryProducts,
|
|
1595
2119
|
isPriceIncludeTax: tempOrder.is_price_include_tax,
|
|
1596
2120
|
shopDiscount: tempOrder.shop_discount
|
|
1597
2121
|
});
|
|
1598
|
-
case
|
|
1599
|
-
salesSummaryResult =
|
|
2122
|
+
case 23:
|
|
2123
|
+
salesSummaryResult = _context12.sent;
|
|
2124
|
+
if (shouldFullRecalculateFromSnapshot) {
|
|
2125
|
+
tempOrder.products = summaryProducts;
|
|
2126
|
+
}
|
|
1600
2127
|
this.syncSummaryProductMetadata(tempOrder.products || []);
|
|
1601
|
-
|
|
2128
|
+
roundingAmount = paidPaymentSummary.roundingAmount;
|
|
2129
|
+
payServiceChargeAmount = paidPaymentSummary.payServiceChargeAmount;
|
|
2130
|
+
hasSalesSummaryAmount = salesSummaryResult.expect_amount !== undefined || salesSummaryResult.total_amount !== undefined;
|
|
2131
|
+
expectAmount = hasSalesSummaryAmount ? new Decimal((_ref44 = (_salesSummaryResult$e = salesSummaryResult.expect_amount) !== null && _salesSummaryResult$e !== void 0 ? _salesSummaryResult$e : salesSummaryResult.total_amount) !== null && _ref44 !== void 0 ? _ref44 : 0) : null;
|
|
2132
|
+
amountPaymentPatch = hasSalesSummaryAmount || !roundingAmount.eq(0) || !payServiceChargeAmount.eq(0) ? _objectSpread({
|
|
2133
|
+
rounding_amount: roundingAmount.toFixed(2)
|
|
2134
|
+
}, expectAmount ? {
|
|
2135
|
+
total_amount: Decimal.max(0, expectAmount.plus(roundingAmount).plus(payServiceChargeAmount)).toFixed(2)
|
|
2136
|
+
} : {}) : {};
|
|
2137
|
+
normalizedExpectAmountPatch = expectAmount && salesSummaryResult.expect_amount === undefined ? {
|
|
2138
|
+
expect_amount: expectAmount.toFixed(2)
|
|
2139
|
+
} : {};
|
|
2140
|
+
summaryForGap = _objectSpread(_objectSpread(_objectSpread({}, salesSummaryResult), {}, {
|
|
1602
2141
|
total_refund_amount: totalRefundAmount
|
|
1603
|
-
});
|
|
1604
|
-
summary = _objectSpread(_objectSpread({}, salesSummaryResult), {}, {
|
|
2142
|
+
}, amountPaymentPatch), normalizedExpectAmountPatch);
|
|
2143
|
+
summary = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, salesSummaryResult), {}, {
|
|
1605
2144
|
total_refund_amount: totalRefundAmount,
|
|
1606
2145
|
customer_paid_amount: paidPaymentSummary.customerPaidAmount.toFixed(2),
|
|
1607
|
-
order_paid_amount: paidPaymentSummary.orderPaidAmount.toFixed(2)
|
|
2146
|
+
order_paid_amount: paidPaymentSummary.orderPaidAmount.toFixed(2)
|
|
2147
|
+
}, amountPaymentPatch), normalizedExpectAmountPatch), {}, {
|
|
1608
2148
|
amount_gap: this.calculateSummaryAmountGap({
|
|
1609
2149
|
tempOrder: tempOrder,
|
|
1610
2150
|
summary: summaryForGap,
|
|
1611
2151
|
orderPaidAmount: paidPaymentSummary.gapPaidAmount
|
|
1612
2152
|
}),
|
|
1613
|
-
pay_service_charge_amount:
|
|
2153
|
+
pay_service_charge_amount: payServiceChargeAmount.toFixed(2)
|
|
1614
2154
|
});
|
|
1615
2155
|
this.store.summary = summary;
|
|
1616
2156
|
if (summary.is_price_include_tax !== undefined) {
|
|
@@ -1627,14 +2167,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1627
2167
|
previousSummary: existedSummary,
|
|
1628
2168
|
summary: summary
|
|
1629
2169
|
});
|
|
1630
|
-
return
|
|
1631
|
-
case
|
|
2170
|
+
return _context12.abrupt("return", this.store.summary);
|
|
2171
|
+
case 43:
|
|
1632
2172
|
case "end":
|
|
1633
|
-
return
|
|
2173
|
+
return _context12.stop();
|
|
1634
2174
|
}
|
|
1635
|
-
},
|
|
2175
|
+
}, _callee10, this);
|
|
1636
2176
|
}));
|
|
1637
|
-
function recalculateSummary(
|
|
2177
|
+
function recalculateSummary(_x10) {
|
|
1638
2178
|
return _recalculateSummary.apply(this, arguments);
|
|
1639
2179
|
}
|
|
1640
2180
|
return recalculateSummary;
|
|
@@ -1642,30 +2182,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1642
2182
|
}, {
|
|
1643
2183
|
key: "getOrderSummary",
|
|
1644
2184
|
value: function () {
|
|
1645
|
-
var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2185
|
+
var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
1646
2186
|
var summary;
|
|
1647
|
-
return _regeneratorRuntime().wrap(function
|
|
1648
|
-
while (1) switch (
|
|
2187
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context13) {
|
|
2188
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1649
2189
|
case 0:
|
|
1650
|
-
|
|
2190
|
+
_context13.next = 2;
|
|
1651
2191
|
return this.recalculateSummary({
|
|
1652
2192
|
createIfMissing: true
|
|
1653
2193
|
});
|
|
1654
2194
|
case 2:
|
|
1655
|
-
summary =
|
|
2195
|
+
summary = _context13.sent;
|
|
1656
2196
|
if (summary) {
|
|
1657
|
-
|
|
2197
|
+
_context13.next = 5;
|
|
1658
2198
|
break;
|
|
1659
2199
|
}
|
|
1660
|
-
return
|
|
2200
|
+
return _context13.abrupt("return", createEmptySummary());
|
|
1661
2201
|
case 5:
|
|
1662
2202
|
this.persistTempOrder();
|
|
1663
|
-
return
|
|
2203
|
+
return _context13.abrupt("return", summary);
|
|
1664
2204
|
case 7:
|
|
1665
2205
|
case "end":
|
|
1666
|
-
return
|
|
2206
|
+
return _context13.stop();
|
|
1667
2207
|
}
|
|
1668
|
-
},
|
|
2208
|
+
}, _callee11, this);
|
|
1669
2209
|
}));
|
|
1670
2210
|
function getOrderSummary() {
|
|
1671
2211
|
return _getOrderSummary.apply(this, arguments);
|
|
@@ -1689,23 +2229,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1689
2229
|
}, {
|
|
1690
2230
|
key: "syncTempOrderNoteToRemote",
|
|
1691
2231
|
value: function () {
|
|
1692
|
-
var _syncTempOrderNoteToRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1693
|
-
return _regeneratorRuntime().wrap(function
|
|
1694
|
-
while (1) switch (
|
|
2232
|
+
var _syncTempOrderNoteToRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(orderId, note) {
|
|
2233
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context14) {
|
|
2234
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1695
2235
|
case 0:
|
|
1696
|
-
|
|
2236
|
+
_context14.next = 2;
|
|
1697
2237
|
return this.request.put("/order/order/".concat(orderId, "/note"), {
|
|
1698
2238
|
note: note
|
|
1699
2239
|
});
|
|
1700
2240
|
case 2:
|
|
1701
|
-
return
|
|
2241
|
+
return _context14.abrupt("return", note);
|
|
1702
2242
|
case 3:
|
|
1703
2243
|
case "end":
|
|
1704
|
-
return
|
|
2244
|
+
return _context14.stop();
|
|
1705
2245
|
}
|
|
1706
|
-
},
|
|
2246
|
+
}, _callee12, this);
|
|
1707
2247
|
}));
|
|
1708
|
-
function syncTempOrderNoteToRemote(
|
|
2248
|
+
function syncTempOrderNoteToRemote(_x11, _x12) {
|
|
1709
2249
|
return _syncTempOrderNoteToRemote.apply(this, arguments);
|
|
1710
2250
|
}
|
|
1711
2251
|
return syncTempOrderNoteToRemote;
|
|
@@ -1744,21 +2284,71 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1744
2284
|
}, {
|
|
1745
2285
|
key: "buildTempOrderCustomer",
|
|
1746
2286
|
value: function buildTempOrderCustomer(params) {
|
|
1747
|
-
var
|
|
2287
|
+
var _ref45, _ref46, _ref47, _source$name, _ref48, _ref49, _ref50, _source$customer_name, _source$id, _source$customer_id, _ref51, _source$country_calli, _source$phone, _source$email;
|
|
1748
2288
|
if (!params.customerId) return null;
|
|
1749
2289
|
var source = params.source ? cloneDeep(params.source) : {};
|
|
1750
|
-
var name = (
|
|
1751
|
-
var customerName = (
|
|
2290
|
+
var name = (_ref45 = (_ref46 = (_ref47 = (_source$name = source.name) !== null && _source$name !== void 0 ? _source$name : source.display_name) !== null && _ref47 !== void 0 ? _ref47 : source.customerName) !== null && _ref46 !== void 0 ? _ref46 : source.customer_name) !== null && _ref45 !== void 0 ? _ref45 : params.customerName;
|
|
2291
|
+
var customerName = (_ref48 = (_ref49 = (_ref50 = (_source$customer_name = source.customer_name) !== null && _source$customer_name !== void 0 ? _source$customer_name : source.customerName) !== null && _ref50 !== void 0 ? _ref50 : source.display_name) !== null && _ref49 !== void 0 ? _ref49 : source.name) !== null && _ref48 !== void 0 ? _ref48 : params.customerName;
|
|
1752
2292
|
return _objectSpread(_objectSpread({}, source), {}, {
|
|
1753
2293
|
id: (_source$id = source.id) !== null && _source$id !== void 0 ? _source$id : params.customerId,
|
|
1754
2294
|
customer_id: (_source$customer_id = source.customer_id) !== null && _source$customer_id !== void 0 ? _source$customer_id : params.customerId,
|
|
1755
2295
|
name: String(name || ''),
|
|
1756
2296
|
customer_name: String(customerName || ''),
|
|
1757
|
-
country_calling_code: String((
|
|
2297
|
+
country_calling_code: String((_ref51 = (_source$country_calli = source.country_calling_code) !== null && _source$country_calli !== void 0 ? _source$country_calli : source.countryCallingCode) !== null && _ref51 !== void 0 ? _ref51 : params.countryCallingCode),
|
|
1758
2298
|
phone: String((_source$phone = source.phone) !== null && _source$phone !== void 0 ? _source$phone : params.phone),
|
|
1759
2299
|
email: String((_source$email = source.email) !== null && _source$email !== void 0 ? _source$email : params.email)
|
|
1760
2300
|
});
|
|
1761
2301
|
}
|
|
2302
|
+
}, {
|
|
2303
|
+
key: "isCustomerBoundDiscount",
|
|
2304
|
+
value: function isCustomerBoundDiscount(discount) {
|
|
2305
|
+
var _discount$type5;
|
|
2306
|
+
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;
|
|
2307
|
+
return type === 'good_pass' || type === 'discount_card' || type === 'product_discount_card';
|
|
2308
|
+
}
|
|
2309
|
+
}, {
|
|
2310
|
+
key: "clearCustomerBoundDiscounts",
|
|
2311
|
+
value: function clearCustomerBoundDiscounts(tempOrder) {
|
|
2312
|
+
var _this13 = this,
|
|
2313
|
+
_discountModule$getDi,
|
|
2314
|
+
_discountModule$getOr,
|
|
2315
|
+
_discountModule$setDi,
|
|
2316
|
+
_discountModule$setOr;
|
|
2317
|
+
var filterDiscountList = function filterDiscountList(discountList) {
|
|
2318
|
+
if (!Array.isArray(discountList)) return [];
|
|
2319
|
+
return discountList.filter(function (discount) {
|
|
2320
|
+
return !_this13.isCustomerBoundDiscount(discount);
|
|
2321
|
+
});
|
|
2322
|
+
};
|
|
2323
|
+
tempOrder.products = (tempOrder.products || []).map(function (product) {
|
|
2324
|
+
var nextProduct = _objectSpread(_objectSpread({}, product), {}, {
|
|
2325
|
+
discount_list: filterDiscountList(product.discount_list)
|
|
2326
|
+
});
|
|
2327
|
+
if (Array.isArray(nextProduct.product_bundle)) {
|
|
2328
|
+
nextProduct.product_bundle = nextProduct.product_bundle.map(function (bundle) {
|
|
2329
|
+
return _objectSpread(_objectSpread({}, bundle), {}, {
|
|
2330
|
+
discount_list: filterDiscountList(bundle.discount_list)
|
|
2331
|
+
});
|
|
2332
|
+
});
|
|
2333
|
+
}
|
|
2334
|
+
return nextProduct;
|
|
2335
|
+
});
|
|
2336
|
+
delete tempOrder.discount_list;
|
|
2337
|
+
var discountModule = this.store.discount;
|
|
2338
|
+
if (!discountModule) return;
|
|
2339
|
+
var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
|
|
2340
|
+
var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
|
|
2341
|
+
var nextDiscounts = currentDiscounts.filter(function (discount) {
|
|
2342
|
+
if (discount !== null && discount !== void 0 && discount.isEditMode) return true;
|
|
2343
|
+
return !_this13.isCustomerBoundDiscount(discount);
|
|
2344
|
+
});
|
|
2345
|
+
var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
|
|
2346
|
+
if (discount !== null && discount !== void 0 && discount.isEditMode) return true;
|
|
2347
|
+
return !_this13.isCustomerBoundDiscount(discount);
|
|
2348
|
+
});
|
|
2349
|
+
void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
|
|
2350
|
+
void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
|
|
2351
|
+
}
|
|
1762
2352
|
|
|
1763
2353
|
/**
|
|
1764
2354
|
* 更新当前 tempOrder 的客户协议字段。
|
|
@@ -1769,13 +2359,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1769
2359
|
}, {
|
|
1770
2360
|
key: "updateTempOrderCustomer",
|
|
1771
2361
|
value: function updateTempOrderCustomer(customer) {
|
|
1772
|
-
var
|
|
2362
|
+
var _tempOrder$customer_i2, _ref52, _ref53, _customer$customer_id, _ref54, _ref55, _ref56, _customer$customer_na, _ref57, _customer$country_cal, _tempOrder$customer_i3;
|
|
1773
2363
|
var tempOrder = this.ensureTempOrder();
|
|
1774
|
-
var
|
|
1775
|
-
var
|
|
2364
|
+
var previousCustomerId = (_tempOrder$customer_i2 = tempOrder.customer_id) !== null && _tempOrder$customer_i2 !== void 0 ? _tempOrder$customer_i2 : null;
|
|
2365
|
+
var customerId = (_ref52 = (_ref53 = (_customer$customer_id = customer.customer_id) !== null && _customer$customer_id !== void 0 ? _customer$customer_id : customer.customerId) !== null && _ref53 !== void 0 ? _ref53 : customer.id) !== null && _ref52 !== void 0 ? _ref52 : null;
|
|
2366
|
+
var customerName = (_ref54 = (_ref55 = (_ref56 = (_customer$customer_na = customer.customer_name) !== null && _customer$customer_na !== void 0 ? _customer$customer_na : customer.customerName) !== null && _ref56 !== void 0 ? _ref56 : customer.display_name) !== null && _ref55 !== void 0 ? _ref55 : customer.name) !== null && _ref54 !== void 0 ? _ref54 : '';
|
|
1776
2367
|
tempOrder.customer_id = customerId === null || customerId === undefined || customerId === '' ? null : Number(customerId);
|
|
1777
2368
|
tempOrder.customer_name = String(customerName || '');
|
|
1778
|
-
tempOrder.country_calling_code = String((
|
|
2369
|
+
tempOrder.country_calling_code = String((_ref57 = (_customer$country_cal = customer.country_calling_code) !== null && _customer$country_cal !== void 0 ? _customer$country_cal : customer.countryCallingCode) !== null && _ref57 !== void 0 ? _ref57 : '');
|
|
1779
2370
|
tempOrder.phone = String(customer.phone || '');
|
|
1780
2371
|
tempOrder.email = String(customer.email || '');
|
|
1781
2372
|
tempOrder.customer = this.buildTempOrderCustomer({
|
|
@@ -1786,6 +2377,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1786
2377
|
phone: tempOrder.phone,
|
|
1787
2378
|
email: tempOrder.email
|
|
1788
2379
|
});
|
|
2380
|
+
var nextCustomerId = (_tempOrder$customer_i3 = tempOrder.customer_id) !== null && _tempOrder$customer_i3 !== void 0 ? _tempOrder$customer_i3 : null;
|
|
1789
2381
|
this.persistTempOrder();
|
|
1790
2382
|
return {
|
|
1791
2383
|
customerId: tempOrder.customer_id,
|
|
@@ -1797,13 +2389,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1797
2389
|
}, {
|
|
1798
2390
|
key: "setOrderCustomer",
|
|
1799
2391
|
value: function setOrderCustomer(patch, snapshot) {
|
|
1800
|
-
var _tempOrder$
|
|
2392
|
+
var _tempOrder$customer_i4, _tempOrder$customer_i5;
|
|
1801
2393
|
if (!patch) {
|
|
1802
2394
|
this.clearOrderCustomer();
|
|
1803
2395
|
return;
|
|
1804
2396
|
}
|
|
1805
2397
|
var tempOrder = this.ensureTempOrder();
|
|
1806
|
-
var previousCustomerId = (_tempOrder$
|
|
2398
|
+
var previousCustomerId = (_tempOrder$customer_i4 = tempOrder.customer_id) !== null && _tempOrder$customer_i4 !== void 0 ? _tempOrder$customer_i4 : null;
|
|
1807
2399
|
tempOrder.customer_id = patch.customer_id || patch.id || null;
|
|
1808
2400
|
tempOrder.customer_name = String(patch.customer_name || '');
|
|
1809
2401
|
tempOrder.country_calling_code = String(patch.country_calling_code || '');
|
|
@@ -1821,9 +2413,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1821
2413
|
var extend = this.ensureExtend(tempOrder);
|
|
1822
2414
|
if (snapshot === null) delete extend.customerSnapshot;else extend.customerSnapshot = cloneDeep(snapshot);
|
|
1823
2415
|
}
|
|
1824
|
-
var nextCustomerId = (_tempOrder$
|
|
2416
|
+
var nextCustomerId = (_tempOrder$customer_i5 = tempOrder.customer_id) !== null && _tempOrder$customer_i5 !== void 0 ? _tempOrder$customer_i5 : null;
|
|
1825
2417
|
if (String(previousCustomerId !== null && previousCustomerId !== void 0 ? previousCustomerId : '') !== String(nextCustomerId !== null && nextCustomerId !== void 0 ? nextCustomerId : '')) {
|
|
1826
2418
|
clearTempOrderHolderAssignments(tempOrder);
|
|
2419
|
+
this.clearCustomerBoundDiscounts(tempOrder);
|
|
1827
2420
|
}
|
|
1828
2421
|
this.persistTempOrder();
|
|
1829
2422
|
this.saveDraftInBackground();
|
|
@@ -1865,6 +2458,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1865
2458
|
tempOrder.email = '';
|
|
1866
2459
|
tempOrder.customer = null;
|
|
1867
2460
|
if (tempOrder._extend) delete tempOrder._extend.customerSnapshot;
|
|
2461
|
+
this.clearCustomerBoundDiscounts(tempOrder);
|
|
1868
2462
|
this.persistTempOrder();
|
|
1869
2463
|
this.saveDraftInBackground();
|
|
1870
2464
|
this.core.effects.emit(OrderHooks.OnOrderCustomerChange, null);
|
|
@@ -1917,7 +2511,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1917
2511
|
}, {
|
|
1918
2512
|
key: "addOrderPayment",
|
|
1919
2513
|
value: function addOrderPayment(payment) {
|
|
1920
|
-
var
|
|
2514
|
+
var _this14 = this;
|
|
1921
2515
|
this.logInfo('addOrderPayment', {
|
|
1922
2516
|
payment: payment
|
|
1923
2517
|
});
|
|
@@ -1930,7 +2524,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1930
2524
|
void this.recalculateSummary({
|
|
1931
2525
|
createIfMissing: true
|
|
1932
2526
|
}).catch(function (error) {
|
|
1933
|
-
|
|
2527
|
+
_this14.logError('recalculate summary after addOrderPayment failed', {
|
|
1934
2528
|
error: error instanceof Error ? error.message : String(error)
|
|
1935
2529
|
});
|
|
1936
2530
|
});
|
|
@@ -1995,29 +2589,45 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1995
2589
|
}, {
|
|
1996
2590
|
key: "updateVoucherOrderPayments",
|
|
1997
2591
|
value: function updateVoucherOrderPayments(payments) {
|
|
1998
|
-
var
|
|
2592
|
+
var _this15 = this;
|
|
1999
2593
|
var tempOrder = this.ensureTempOrder();
|
|
2594
|
+
var isVoucherPayment = function isVoucherPayment(payment) {
|
|
2595
|
+
return payment.voucher_id !== undefined && Number(payment.voucher_id) !== 0;
|
|
2596
|
+
};
|
|
2597
|
+
var hasSyncedOrderPayment = function hasSyncedOrderPayment(payment) {
|
|
2598
|
+
return payment.order_payment_id !== undefined && payment.order_payment_id !== null;
|
|
2599
|
+
};
|
|
2000
2600
|
var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
|
|
2001
|
-
return
|
|
2601
|
+
return _this15.normalizePaymentSource(payment, {
|
|
2002
2602
|
defaultPaid: true
|
|
2003
2603
|
});
|
|
2004
2604
|
})).filter(function (payment) {
|
|
2005
|
-
return
|
|
2605
|
+
return isVoucherPayment(payment);
|
|
2006
2606
|
});
|
|
2007
2607
|
var nonVoucherPayments = (tempOrder.payments || []).filter(function (payment) {
|
|
2008
|
-
return
|
|
2608
|
+
return !isVoucherPayment(payment);
|
|
2609
|
+
});
|
|
2610
|
+
var syncedVoucherPayments = (tempOrder.payments || []).filter(function (payment) {
|
|
2611
|
+
return isVoucherPayment(payment) && hasSyncedOrderPayment(payment);
|
|
2612
|
+
});
|
|
2613
|
+
var syncedVoucherPaymentIds = new Set(syncedVoucherPayments.map(function (payment) {
|
|
2614
|
+
return String(payment.order_payment_id);
|
|
2615
|
+
}));
|
|
2616
|
+
var replaceableVouchers = mappedVouchers.filter(function (payment) {
|
|
2617
|
+
if (!hasSyncedOrderPayment(payment)) return true;
|
|
2618
|
+
return !syncedVoucherPaymentIds.has(String(payment.order_payment_id));
|
|
2009
2619
|
});
|
|
2010
2620
|
var cappedVouchers = this.capVoucherPaymentsByRemainingAmount({
|
|
2011
|
-
vouchers:
|
|
2012
|
-
nonVoucherPayments: nonVoucherPayments
|
|
2621
|
+
vouchers: replaceableVouchers,
|
|
2622
|
+
nonVoucherPayments: [].concat(_toConsumableArray(nonVoucherPayments), _toConsumableArray(syncedVoucherPayments))
|
|
2013
2623
|
});
|
|
2014
|
-
tempOrder.payments = [].concat(_toConsumableArray(nonVoucherPayments), _toConsumableArray(cappedVouchers));
|
|
2624
|
+
tempOrder.payments = [].concat(_toConsumableArray(nonVoucherPayments), _toConsumableArray(syncedVoucherPayments), _toConsumableArray(cappedVouchers));
|
|
2015
2625
|
this.updateTempOrderPaymentStatus(tempOrder);
|
|
2016
2626
|
this.persistTempOrder();
|
|
2017
2627
|
void this.recalculateSummary({
|
|
2018
2628
|
createIfMissing: true
|
|
2019
2629
|
}).catch(function (error) {
|
|
2020
|
-
|
|
2630
|
+
_this15.logError('recalculate summary after updateVoucherOrderPayments failed', {
|
|
2021
2631
|
error: error instanceof Error ? error.message : String(error)
|
|
2022
2632
|
});
|
|
2023
2633
|
});
|
|
@@ -2026,45 +2636,45 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2026
2636
|
}, {
|
|
2027
2637
|
key: "shouldMergeProductToOrder",
|
|
2028
2638
|
value: function () {
|
|
2029
|
-
var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2639
|
+
var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(params) {
|
|
2030
2640
|
var _this$orderHooks;
|
|
2031
2641
|
var onBeforeMergeProductToOrder, result;
|
|
2032
|
-
return _regeneratorRuntime().wrap(function
|
|
2033
|
-
while (1) switch (
|
|
2642
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context15) {
|
|
2643
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
2034
2644
|
case 0:
|
|
2035
2645
|
onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
|
|
2036
2646
|
if (onBeforeMergeProductToOrder) {
|
|
2037
|
-
|
|
2647
|
+
_context15.next = 3;
|
|
2038
2648
|
break;
|
|
2039
2649
|
}
|
|
2040
|
-
return
|
|
2650
|
+
return _context15.abrupt("return", true);
|
|
2041
2651
|
case 3:
|
|
2042
|
-
|
|
2652
|
+
_context15.next = 5;
|
|
2043
2653
|
return onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
2044
2654
|
defaultShouldMerge: true
|
|
2045
2655
|
}));
|
|
2046
2656
|
case 5:
|
|
2047
|
-
result =
|
|
2657
|
+
result = _context15.sent;
|
|
2048
2658
|
if (!(typeof result === 'boolean')) {
|
|
2049
|
-
|
|
2659
|
+
_context15.next = 8;
|
|
2050
2660
|
break;
|
|
2051
2661
|
}
|
|
2052
|
-
return
|
|
2662
|
+
return _context15.abrupt("return", result);
|
|
2053
2663
|
case 8:
|
|
2054
2664
|
if (!(result && _typeof(result) === 'object' && typeof result.shouldMerge === 'boolean')) {
|
|
2055
|
-
|
|
2665
|
+
_context15.next = 10;
|
|
2056
2666
|
break;
|
|
2057
2667
|
}
|
|
2058
|
-
return
|
|
2668
|
+
return _context15.abrupt("return", result.shouldMerge);
|
|
2059
2669
|
case 10:
|
|
2060
|
-
return
|
|
2670
|
+
return _context15.abrupt("return", true);
|
|
2061
2671
|
case 11:
|
|
2062
2672
|
case "end":
|
|
2063
|
-
return
|
|
2673
|
+
return _context15.stop();
|
|
2064
2674
|
}
|
|
2065
|
-
},
|
|
2675
|
+
}, _callee13, this);
|
|
2066
2676
|
}));
|
|
2067
|
-
function shouldMergeProductToOrder(
|
|
2677
|
+
function shouldMergeProductToOrder(_x13) {
|
|
2068
2678
|
return _shouldMergeProductToOrder.apply(this, arguments);
|
|
2069
2679
|
}
|
|
2070
2680
|
return shouldMergeProductToOrder;
|
|
@@ -2072,11 +2682,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2072
2682
|
}, {
|
|
2073
2683
|
key: "addProductToOrder",
|
|
2074
2684
|
value: function () {
|
|
2075
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2076
|
-
var
|
|
2685
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(product, booking) {
|
|
2686
|
+
var _this16 = this;
|
|
2077
2687
|
var tempOrder, linked, productToAdd, incomingFingerprint, normalizedIncoming, hasIncomingGoodPass, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList;
|
|
2078
|
-
return _regeneratorRuntime().wrap(function
|
|
2079
|
-
while (1) switch (
|
|
2688
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context16) {
|
|
2689
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
2080
2690
|
case 0:
|
|
2081
2691
|
tempOrder = this.ensureTempOrder();
|
|
2082
2692
|
linked = booking ? this.createLinkedProductAndBooking({
|
|
@@ -2090,7 +2700,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2090
2700
|
hasIncomingGoodPass = this.hasGoodPassDiscount(normalizedIncoming);
|
|
2091
2701
|
shouldForceNewLine = !!booking;
|
|
2092
2702
|
matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
2093
|
-
if (
|
|
2703
|
+
if (_this16.hasGoodPassDiscount(item)) return false;
|
|
2094
2704
|
if (item.product_id !== productToAdd.product_id) return false;
|
|
2095
2705
|
if (item.product_variant_id !== productToAdd.product_variant_id) return false;
|
|
2096
2706
|
var existedFingerprint = buildProductLineFingerprint(getProductSkuOptions(item), item.product_bundle);
|
|
@@ -2099,10 +2709,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2099
2709
|
matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
|
|
2100
2710
|
existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
|
|
2101
2711
|
if (!matchedProduct) {
|
|
2102
|
-
|
|
2712
|
+
_context16.next = 17;
|
|
2103
2713
|
break;
|
|
2104
2714
|
}
|
|
2105
|
-
|
|
2715
|
+
_context16.next = 14;
|
|
2106
2716
|
return this.shouldMergeProductToOrder({
|
|
2107
2717
|
incomingProduct: productToAdd,
|
|
2108
2718
|
normalizedIncoming: normalizedIncoming,
|
|
@@ -2114,13 +2724,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2114
2724
|
booking: booking
|
|
2115
2725
|
});
|
|
2116
2726
|
case 14:
|
|
2117
|
-
|
|
2118
|
-
|
|
2727
|
+
_context16.t0 = _context16.sent;
|
|
2728
|
+
_context16.next = 18;
|
|
2119
2729
|
break;
|
|
2120
2730
|
case 17:
|
|
2121
|
-
|
|
2731
|
+
_context16.t0 = false;
|
|
2122
2732
|
case 18:
|
|
2123
|
-
shouldMerge =
|
|
2733
|
+
shouldMerge = _context16.t0;
|
|
2124
2734
|
if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
|
|
2125
2735
|
this.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
|
|
2126
2736
|
if (linked) {
|
|
@@ -2171,25 +2781,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2171
2781
|
if (linked) {
|
|
2172
2782
|
tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
|
|
2173
2783
|
}
|
|
2174
|
-
|
|
2175
|
-
return this.
|
|
2784
|
+
_context16.next = 23;
|
|
2785
|
+
return this.ensureEditDiscountConfigForProductChange(tempOrder);
|
|
2176
2786
|
case 23:
|
|
2787
|
+
_context16.next = 25;
|
|
2788
|
+
return this.applyPromotion();
|
|
2789
|
+
case 25:
|
|
2177
2790
|
this.applyDiscount();
|
|
2178
2791
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
2179
|
-
|
|
2792
|
+
_context16.next = 29;
|
|
2180
2793
|
return this.recalculateSummary({
|
|
2181
2794
|
createIfMissing: true
|
|
2182
2795
|
});
|
|
2183
|
-
case 27:
|
|
2184
|
-
this.persistTempOrder();
|
|
2185
|
-
return _context15.abrupt("return", tempOrder.products);
|
|
2186
2796
|
case 29:
|
|
2797
|
+
this.persistTempOrder();
|
|
2798
|
+
return _context16.abrupt("return", tempOrder.products);
|
|
2799
|
+
case 31:
|
|
2187
2800
|
case "end":
|
|
2188
|
-
return
|
|
2801
|
+
return _context16.stop();
|
|
2189
2802
|
}
|
|
2190
|
-
},
|
|
2803
|
+
}, _callee14, this);
|
|
2191
2804
|
}));
|
|
2192
|
-
function addProductToOrder(
|
|
2805
|
+
function addProductToOrder(_x14, _x15) {
|
|
2193
2806
|
return _addProductToOrder.apply(this, arguments);
|
|
2194
2807
|
}
|
|
2195
2808
|
return addProductToOrder;
|
|
@@ -2213,14 +2826,46 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2213
2826
|
return (item === null || item === void 0 ? void 0 : item.type) === 'good_pass' || (item === null || item === void 0 ? void 0 : item.tag) === 'good_pass';
|
|
2214
2827
|
});
|
|
2215
2828
|
}
|
|
2829
|
+
}, {
|
|
2830
|
+
key: "getBundleRuntimeIdentity",
|
|
2831
|
+
value: function getBundleRuntimeIdentity(bundle) {
|
|
2832
|
+
var _ref58, _bundle$bundle_id2, _ref59, _bundle$bundle_group_2, _ref60, _ref61, _bundle$bundle_produc3, _ref62, _bundle$bundle_varian3;
|
|
2833
|
+
if (!bundle || _typeof(bundle) !== 'object') return '';
|
|
2834
|
+
return [(_ref58 = (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id) !== null && _ref58 !== void 0 ? _ref58 : '', (_ref59 = (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id) !== null && _ref59 !== void 0 ? _ref59 : '', (_ref60 = (_ref61 = (_bundle$bundle_produc3 = bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle._bundle_product_id) !== null && _ref61 !== void 0 ? _ref61 : bundle.product_id) !== null && _ref60 !== void 0 ? _ref60 : '', (_ref62 = (_bundle$bundle_varian3 = bundle.bundle_variant_id) !== null && _bundle$bundle_varian3 !== void 0 ? _bundle$bundle_varian3 : bundle.product_variant_id) !== null && _ref62 !== void 0 ? _ref62 : 0].join('|');
|
|
2835
|
+
}
|
|
2836
|
+
}, {
|
|
2837
|
+
key: "preservePersistedBundlePriceFields",
|
|
2838
|
+
value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
|
|
2839
|
+
var _this17 = this;
|
|
2840
|
+
if (!Array.isArray(nextBundles)) return nextBundles;
|
|
2841
|
+
if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
|
|
2842
|
+
var previousByIdentity = new Map();
|
|
2843
|
+
previousBundles.forEach(function (bundle) {
|
|
2844
|
+
var identity = _this17.getBundleRuntimeIdentity(bundle);
|
|
2845
|
+
if (identity) previousByIdentity.set(identity, bundle);
|
|
2846
|
+
});
|
|
2847
|
+
return nextBundles.map(function (bundle, index) {
|
|
2848
|
+
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
2849
|
+
var previous = previousByIdentity.get(_this17.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
|
|
2850
|
+
if (!previous || _typeof(previous) !== 'object') return bundle;
|
|
2851
|
+
return _objectSpread(_objectSpread({}, bundle), {}, {
|
|
2852
|
+
price: previous.price,
|
|
2853
|
+
custom_price: previous.custom_price,
|
|
2854
|
+
bundle_payment_price: previous.bundle_payment_price,
|
|
2855
|
+
bundle_selling_price: previous.bundle_selling_price,
|
|
2856
|
+
original_price: previous.original_price,
|
|
2857
|
+
product_price: previous.product_price
|
|
2858
|
+
});
|
|
2859
|
+
});
|
|
2860
|
+
}
|
|
2216
2861
|
}, {
|
|
2217
2862
|
key: "updateOrderProduct",
|
|
2218
2863
|
value: function () {
|
|
2219
|
-
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2864
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
|
|
2220
2865
|
var _targetProduct$metada2, _product_sku, _metadata, _metadata2, _metadata3, _metadata4, _metadata5, _metadata6, _nextProduct$metadata, _targetProduct$metada8, _tempOrder$products$p;
|
|
2221
2866
|
var product_id, product_variant_id, updates, unique_identification_number, identity_key, product_sku, product_bundle, booking, tempOrder, identityLookup, productIndex, targetUid, targetProduct, nextProduct, callerUpdatesTopPrice, callerUpdatesMainMeta, isPersistedOrderLine, callerChangesDiscountList, callerUpdatesManualPrice, _targetProduct$metada3, _targetProduct$metada4, _targetProduct$metada5, _targetProduct$metada6, _targetProduct$metada7, existedMeta, normalizedProduct, preservedBookingUid, _normalizedProduct$me, _targetProduct$metada9, productUid, linked;
|
|
2222
|
-
return _regeneratorRuntime().wrap(function
|
|
2223
|
-
while (1) switch (
|
|
2867
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context17) {
|
|
2868
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
2224
2869
|
case 0:
|
|
2225
2870
|
product_id = params.product_id, product_variant_id = params.product_variant_id, updates = params.updates, unique_identification_number = params.unique_identification_number, identity_key = params.identity_key, product_sku = params.product_sku, product_bundle = params.product_bundle, booking = params.booking;
|
|
2226
2871
|
tempOrder = this.ensureTempOrder();
|
|
@@ -2243,15 +2888,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2243
2888
|
if (unique_identification_number !== undefined) {
|
|
2244
2889
|
targetUid = String(unique_identification_number);
|
|
2245
2890
|
productIndex = tempOrder.products.findIndex(function (item) {
|
|
2246
|
-
var _item$
|
|
2247
|
-
return String(((_item$
|
|
2891
|
+
var _item$metadata3;
|
|
2892
|
+
return String(((_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.unique_identification_number) || item.unique_identification_number || '') === targetUid;
|
|
2248
2893
|
});
|
|
2249
2894
|
}
|
|
2250
2895
|
if (productIndex === -1) {
|
|
2251
2896
|
productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
|
|
2252
2897
|
}
|
|
2253
2898
|
if (!(productIndex === -1)) {
|
|
2254
|
-
|
|
2899
|
+
_context17.next = 12;
|
|
2255
2900
|
break;
|
|
2256
2901
|
}
|
|
2257
2902
|
throw new Error('[Order] 目标商品不存在,无法更新');
|
|
@@ -2291,6 +2936,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2291
2936
|
main_product_original_price: (_targetProduct$metada5 = targetProduct.metadata) === null || _targetProduct$metada5 === void 0 ? void 0 : _targetProduct$metada5.main_product_original_price,
|
|
2292
2937
|
price_schema_version: (_targetProduct$metada6 = (_targetProduct$metada7 = targetProduct.metadata) === null || _targetProduct$metada7 === void 0 ? void 0 : _targetProduct$metada7.price_schema_version) !== null && _targetProduct$metada6 !== void 0 ? _targetProduct$metada6 : 2
|
|
2293
2938
|
});
|
|
2939
|
+
nextProduct.product_bundle = this.preservePersistedBundlePriceFields(targetProduct.product_bundle, nextProduct.product_bundle);
|
|
2294
2940
|
} else if (callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
2295
2941
|
existedMeta = nextProduct.metadata || {};
|
|
2296
2942
|
nextProduct.metadata = _objectSpread({}, existedMeta);
|
|
@@ -2333,25 +2979,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2333
2979
|
}
|
|
2334
2980
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
2335
2981
|
this.captureProductRuntime(tempOrder, updates, tempOrder.products[productIndex], (_tempOrder$products$p = tempOrder.products[productIndex].metadata) === null || _tempOrder$products$p === void 0 ? void 0 : _tempOrder$products$p.unique_identification_number);
|
|
2336
|
-
|
|
2982
|
+
_context17.next = 30;
|
|
2337
2983
|
return this.applyPromotion();
|
|
2338
2984
|
case 30:
|
|
2339
2985
|
this.applyDiscount();
|
|
2340
2986
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
2341
|
-
|
|
2987
|
+
_context17.next = 34;
|
|
2342
2988
|
return this.recalculateSummary({
|
|
2343
2989
|
createIfMissing: true
|
|
2344
2990
|
});
|
|
2345
2991
|
case 34:
|
|
2346
2992
|
this.persistTempOrder();
|
|
2347
|
-
return
|
|
2993
|
+
return _context17.abrupt("return", tempOrder.products);
|
|
2348
2994
|
case 36:
|
|
2349
2995
|
case "end":
|
|
2350
|
-
return
|
|
2996
|
+
return _context17.stop();
|
|
2351
2997
|
}
|
|
2352
|
-
},
|
|
2998
|
+
}, _callee15, this);
|
|
2353
2999
|
}));
|
|
2354
|
-
function updateOrderProduct(
|
|
3000
|
+
function updateOrderProduct(_x16) {
|
|
2355
3001
|
return _updateOrderProduct.apply(this, arguments);
|
|
2356
3002
|
}
|
|
2357
3003
|
return updateOrderProduct;
|
|
@@ -2359,11 +3005,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2359
3005
|
}, {
|
|
2360
3006
|
key: "updateOrderProductQuantity",
|
|
2361
3007
|
value: function () {
|
|
2362
|
-
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3008
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(params) {
|
|
2363
3009
|
var _targetProduct$metada10;
|
|
2364
3010
|
var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct;
|
|
2365
|
-
return _regeneratorRuntime().wrap(function
|
|
2366
|
-
while (1) switch (
|
|
3011
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context18) {
|
|
3012
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
2367
3013
|
case 0:
|
|
2368
3014
|
product_id = params.product_id, product_variant_id = params.product_variant_id, num = params.num, unique_identification_number = params.unique_identification_number, identity_key = params.identity_key, product_sku = params.product_sku, product_bundle = params.product_bundle;
|
|
2369
3015
|
tempOrder = this.ensureTempOrder();
|
|
@@ -2384,15 +3030,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2384
3030
|
if (unique_identification_number !== undefined) {
|
|
2385
3031
|
targetUid = String(unique_identification_number);
|
|
2386
3032
|
productIndex = tempOrder.products.findIndex(function (item) {
|
|
2387
|
-
var _item$
|
|
2388
|
-
return String(((_item$
|
|
3033
|
+
var _item$metadata4;
|
|
3034
|
+
return String(((_item$metadata4 = item.metadata) === null || _item$metadata4 === void 0 ? void 0 : _item$metadata4.unique_identification_number) || item.unique_identification_number || '') === targetUid;
|
|
2389
3035
|
});
|
|
2390
3036
|
}
|
|
2391
3037
|
if (productIndex === -1) {
|
|
2392
3038
|
productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
|
|
2393
3039
|
}
|
|
2394
3040
|
if (!(productIndex === -1)) {
|
|
2395
|
-
|
|
3041
|
+
_context18.next = 12;
|
|
2396
3042
|
break;
|
|
2397
3043
|
}
|
|
2398
3044
|
throw new Error('[Order] 目标商品不存在,无法更新数量');
|
|
@@ -2406,25 +3052,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2406
3052
|
}));
|
|
2407
3053
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
2408
3054
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
2409
|
-
|
|
3055
|
+
_context18.next = 18;
|
|
2410
3056
|
return this.applyPromotion();
|
|
2411
3057
|
case 18:
|
|
2412
3058
|
this.applyDiscount();
|
|
2413
3059
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
2414
|
-
|
|
3060
|
+
_context18.next = 22;
|
|
2415
3061
|
return this.recalculateSummary({
|
|
2416
3062
|
createIfMissing: true
|
|
2417
3063
|
});
|
|
2418
3064
|
case 22:
|
|
2419
3065
|
this.persistTempOrder();
|
|
2420
|
-
return
|
|
3066
|
+
return _context18.abrupt("return", tempOrder.products);
|
|
2421
3067
|
case 24:
|
|
2422
3068
|
case "end":
|
|
2423
|
-
return
|
|
3069
|
+
return _context18.stop();
|
|
2424
3070
|
}
|
|
2425
|
-
},
|
|
3071
|
+
}, _callee16, this);
|
|
2426
3072
|
}));
|
|
2427
|
-
function updateOrderProductQuantity(
|
|
3073
|
+
function updateOrderProductQuantity(_x17) {
|
|
2428
3074
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
2429
3075
|
}
|
|
2430
3076
|
return updateOrderProductQuantity;
|
|
@@ -2455,10 +3101,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2455
3101
|
}, {
|
|
2456
3102
|
key: "removeProductFromOrder",
|
|
2457
3103
|
value: function () {
|
|
2458
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3104
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(identity) {
|
|
2459
3105
|
var tempOrder, removedProducts, _i, _removedProducts, product;
|
|
2460
|
-
return _regeneratorRuntime().wrap(function
|
|
2461
|
-
while (1) switch (
|
|
3106
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context19) {
|
|
3107
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
2462
3108
|
case 0:
|
|
2463
3109
|
tempOrder = this.ensureTempOrder();
|
|
2464
3110
|
removedProducts = [];
|
|
@@ -2471,25 +3117,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2471
3117
|
product = _removedProducts[_i];
|
|
2472
3118
|
this.removeLinkedBookingsForProduct(tempOrder, product);
|
|
2473
3119
|
}
|
|
2474
|
-
|
|
3120
|
+
_context19.next = 6;
|
|
2475
3121
|
return this.applyPromotion();
|
|
2476
3122
|
case 6:
|
|
2477
3123
|
this.applyDiscount();
|
|
2478
3124
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
2479
|
-
|
|
3125
|
+
_context19.next = 10;
|
|
2480
3126
|
return this.recalculateSummary({
|
|
2481
3127
|
createIfMissing: true
|
|
2482
3128
|
});
|
|
2483
3129
|
case 10:
|
|
2484
3130
|
this.persistTempOrder();
|
|
2485
|
-
return
|
|
3131
|
+
return _context19.abrupt("return", tempOrder.products);
|
|
2486
3132
|
case 12:
|
|
2487
3133
|
case "end":
|
|
2488
|
-
return
|
|
3134
|
+
return _context19.stop();
|
|
2489
3135
|
}
|
|
2490
|
-
},
|
|
3136
|
+
}, _callee17, this);
|
|
2491
3137
|
}));
|
|
2492
|
-
function removeProductFromOrder(
|
|
3138
|
+
function removeProductFromOrder(_x18) {
|
|
2493
3139
|
return _removeProductFromOrder.apply(this, arguments);
|
|
2494
3140
|
}
|
|
2495
3141
|
return removeProductFromOrder;
|
|
@@ -2501,10 +3147,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2501
3147
|
}, {
|
|
2502
3148
|
key: "clearOrderCartLines",
|
|
2503
3149
|
value: (function () {
|
|
2504
|
-
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3150
|
+
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
2505
3151
|
var tempOrder;
|
|
2506
|
-
return _regeneratorRuntime().wrap(function
|
|
2507
|
-
while (1) switch (
|
|
3152
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context20) {
|
|
3153
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
2508
3154
|
case 0:
|
|
2509
3155
|
tempOrder = this.ensureTempOrder();
|
|
2510
3156
|
tempOrder.products = [];
|
|
@@ -2514,23 +3160,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2514
3160
|
productsByUid: {}
|
|
2515
3161
|
});
|
|
2516
3162
|
}
|
|
2517
|
-
|
|
3163
|
+
_context20.next = 6;
|
|
2518
3164
|
return this.applyPromotion();
|
|
2519
3165
|
case 6:
|
|
2520
3166
|
this.applyDiscount();
|
|
2521
3167
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
2522
|
-
|
|
3168
|
+
_context20.next = 10;
|
|
2523
3169
|
return this.recalculateSummary({
|
|
2524
3170
|
createIfMissing: true
|
|
2525
3171
|
});
|
|
2526
3172
|
case 10:
|
|
2527
3173
|
this.persistTempOrder();
|
|
2528
|
-
return
|
|
3174
|
+
return _context20.abrupt("return", tempOrder);
|
|
2529
3175
|
case 12:
|
|
2530
3176
|
case "end":
|
|
2531
|
-
return
|
|
3177
|
+
return _context20.stop();
|
|
2532
3178
|
}
|
|
2533
|
-
},
|
|
3179
|
+
}, _callee18, this);
|
|
2534
3180
|
}));
|
|
2535
3181
|
function clearOrderCartLines() {
|
|
2536
3182
|
return _clearOrderCartLines.apply(this, arguments);
|
|
@@ -2547,11 +3193,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2547
3193
|
}, {
|
|
2548
3194
|
key: "submitTempOrder",
|
|
2549
3195
|
value: function () {
|
|
2550
|
-
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2551
|
-
var _params$cacheId, _this$otherParams,
|
|
3196
|
+
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
|
|
3197
|
+
var _params$cacheId, _this$otherParams, _ref63, _params$businessCode, _this$otherParams2, _this$otherParams3;
|
|
2552
3198
|
var tempOrder, effectiveCacheId, hasPaymentOverride, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
|
|
2553
|
-
return _regeneratorRuntime().wrap(function
|
|
2554
|
-
while (1) switch (
|
|
3199
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context21) {
|
|
3200
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
2555
3201
|
case 0:
|
|
2556
3202
|
tempOrder = this.ensureTempOrder();
|
|
2557
3203
|
this.persistTempOrder();
|
|
@@ -2574,16 +3220,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2574
3220
|
tempOrder: tempOrder,
|
|
2575
3221
|
cacheId: effectiveCacheId,
|
|
2576
3222
|
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.platform),
|
|
2577
|
-
businessCode: (
|
|
3223
|
+
businessCode: (_ref63 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.businessCode) !== null && _ref63 !== void 0 ? _ref63 : (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.business_code,
|
|
2578
3224
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
2579
3225
|
type: params === null || params === void 0 ? void 0 : params.type,
|
|
2580
3226
|
enhance: enhancePayload
|
|
2581
3227
|
}); // TODO: 前端生成的时间现在是有问题的,后面要统一优化
|
|
2582
3228
|
payload.created_at = undefined;
|
|
2583
|
-
|
|
3229
|
+
_context21.next = 11;
|
|
2584
3230
|
return this.saveDraft();
|
|
2585
3231
|
case 11:
|
|
2586
|
-
|
|
3232
|
+
_context21.prev = 11;
|
|
2587
3233
|
this.logInfo('submitTempOrder calling sales checkout', {
|
|
2588
3234
|
orderId: payload.order_id,
|
|
2589
3235
|
externalSaleNumber: payload.external_sale_number,
|
|
@@ -2592,62 +3238,62 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2592
3238
|
paymentsCount: ((_payload$payments = payload.payments) === null || _payload$payments === void 0 ? void 0 : _payload$payments.length) || 0,
|
|
2593
3239
|
smallTicketDataFlag: payload.small_ticket_data_flag
|
|
2594
3240
|
});
|
|
2595
|
-
|
|
3241
|
+
_context21.next = 15;
|
|
2596
3242
|
return this.submitSalesOrder({
|
|
2597
3243
|
query: payload
|
|
2598
3244
|
});
|
|
2599
3245
|
case 15:
|
|
2600
|
-
result =
|
|
2601
|
-
|
|
3246
|
+
result = _context21.sent;
|
|
3247
|
+
_context21.next = 28;
|
|
2602
3248
|
break;
|
|
2603
3249
|
case 18:
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
backendErrorResponse = this.extractSubmitErrorResponse(
|
|
3250
|
+
_context21.prev = 18;
|
|
3251
|
+
_context21.t0 = _context21["catch"](11);
|
|
3252
|
+
backendErrorResponse = this.extractSubmitErrorResponse(_context21.t0);
|
|
2607
3253
|
if (!backendErrorResponse) {
|
|
2608
|
-
|
|
3254
|
+
_context21.next = 25;
|
|
2609
3255
|
break;
|
|
2610
3256
|
}
|
|
2611
3257
|
this.store.syncState = 'failed';
|
|
2612
3258
|
this.logSubmitBackendRejected(backendErrorResponse, payload);
|
|
2613
|
-
return
|
|
3259
|
+
return _context21.abrupt("return", backendErrorResponse);
|
|
2614
3260
|
case 25:
|
|
2615
3261
|
this.store.syncState = 'failed';
|
|
2616
3262
|
this.logError('submitTempOrder failed', {
|
|
2617
|
-
error:
|
|
3263
|
+
error: _context21.t0 instanceof Error ? _context21.t0.message : String(_context21.t0),
|
|
2618
3264
|
orderId: payload.order_id,
|
|
2619
3265
|
externalSaleNumber: payload.external_sale_number,
|
|
2620
3266
|
paymentStatus: payload.payment_status,
|
|
2621
3267
|
paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
|
|
2622
3268
|
});
|
|
2623
|
-
throw
|
|
3269
|
+
throw _context21.t0;
|
|
2624
3270
|
case 28:
|
|
2625
3271
|
if (!this.isSubmitResponseRejected(result)) {
|
|
2626
|
-
|
|
3272
|
+
_context21.next = 32;
|
|
2627
3273
|
break;
|
|
2628
3274
|
}
|
|
2629
3275
|
this.store.syncState = 'failed';
|
|
2630
3276
|
this.logSubmitBackendRejected(result, payload);
|
|
2631
|
-
return
|
|
3277
|
+
return _context21.abrupt("return", result);
|
|
2632
3278
|
case 32:
|
|
2633
3279
|
submittedOrderId = this.extractOrderIdFromSubmitResult(result);
|
|
2634
3280
|
if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
|
|
2635
|
-
|
|
3281
|
+
_context21.next = 38;
|
|
2636
3282
|
break;
|
|
2637
3283
|
}
|
|
2638
3284
|
tempOrder.order_id = submittedOrderId;
|
|
2639
3285
|
resultRecord = result;
|
|
2640
|
-
|
|
3286
|
+
_context21.next = 38;
|
|
2641
3287
|
return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
|
|
2642
3288
|
case 38:
|
|
2643
|
-
return
|
|
3289
|
+
return _context21.abrupt("return", result);
|
|
2644
3290
|
case 39:
|
|
2645
3291
|
case "end":
|
|
2646
|
-
return
|
|
3292
|
+
return _context21.stop();
|
|
2647
3293
|
}
|
|
2648
|
-
},
|
|
3294
|
+
}, _callee19, this, [[11, 18]]);
|
|
2649
3295
|
}));
|
|
2650
|
-
function submitTempOrder(
|
|
3296
|
+
function submitTempOrder(_x19) {
|
|
2651
3297
|
return _submitTempOrder.apply(this, arguments);
|
|
2652
3298
|
}
|
|
2653
3299
|
return submitTempOrder;
|
|
@@ -2655,25 +3301,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2655
3301
|
}, {
|
|
2656
3302
|
key: "markLocalOrderSynced",
|
|
2657
3303
|
value: function () {
|
|
2658
|
-
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3304
|
+
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(orderId, remoteOrder) {
|
|
2659
3305
|
var tempOrder;
|
|
2660
|
-
return _regeneratorRuntime().wrap(function
|
|
2661
|
-
while (1) switch (
|
|
3306
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context22) {
|
|
3307
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
2662
3308
|
case 0:
|
|
2663
3309
|
tempOrder = this.ensureTempOrder();
|
|
2664
3310
|
tempOrder.order_id = orderId;
|
|
2665
3311
|
this.store.lastOrderInfo = remoteOrder;
|
|
2666
3312
|
this.store.syncState = 'submitted';
|
|
2667
3313
|
this.persistTempOrder();
|
|
2668
|
-
|
|
3314
|
+
_context22.next = 7;
|
|
2669
3315
|
return this.saveDraft();
|
|
2670
3316
|
case 7:
|
|
2671
3317
|
case "end":
|
|
2672
|
-
return
|
|
3318
|
+
return _context22.stop();
|
|
2673
3319
|
}
|
|
2674
|
-
},
|
|
3320
|
+
}, _callee20, this);
|
|
2675
3321
|
}));
|
|
2676
|
-
function markLocalOrderSynced(
|
|
3322
|
+
function markLocalOrderSynced(_x20, _x21) {
|
|
2677
3323
|
return _markLocalOrderSynced.apply(this, arguments);
|
|
2678
3324
|
}
|
|
2679
3325
|
return markLocalOrderSynced;
|
|
@@ -2697,10 +3343,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2697
3343
|
value: function extractSubmitErrorResponse(error) {
|
|
2698
3344
|
var _error$response,
|
|
2699
3345
|
_error$response2,
|
|
2700
|
-
|
|
3346
|
+
_this18 = this;
|
|
2701
3347
|
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];
|
|
2702
3348
|
return candidates.find(function (candidate) {
|
|
2703
|
-
return
|
|
3349
|
+
return _this18.isSubmitErrorResponse(candidate);
|
|
2704
3350
|
}) || null;
|
|
2705
3351
|
}
|
|
2706
3352
|
}, {
|
|
@@ -2720,10 +3366,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2720
3366
|
}, {
|
|
2721
3367
|
key: "syncPaymentsToOrder",
|
|
2722
3368
|
value: function () {
|
|
2723
|
-
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3369
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
|
|
2724
3370
|
var tempOrder, mappedPayments, paymentTotal, targetAmount, isFullyPaid, paymentStatus, paymentSyncIdempotencyToken, submitResult;
|
|
2725
|
-
return _regeneratorRuntime().wrap(function
|
|
2726
|
-
while (1) switch (
|
|
3371
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context23) {
|
|
3372
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
2727
3373
|
case 0:
|
|
2728
3374
|
tempOrder = this.ensureTempOrder();
|
|
2729
3375
|
mappedPayments = mapPaymentItemsToOrderPayments(params.payments || []);
|
|
@@ -2734,28 +3380,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2734
3380
|
tempOrder.payments = mappedPayments;
|
|
2735
3381
|
tempOrder.payment_status = paymentStatus;
|
|
2736
3382
|
this.persistTempOrder();
|
|
2737
|
-
|
|
3383
|
+
_context23.next = 11;
|
|
2738
3384
|
return this.saveDraft();
|
|
2739
3385
|
case 11:
|
|
2740
3386
|
if (params.submitWhenPaid) {
|
|
2741
|
-
|
|
3387
|
+
_context23.next = 13;
|
|
2742
3388
|
break;
|
|
2743
3389
|
}
|
|
2744
|
-
return
|
|
3390
|
+
return _context23.abrupt("return", {
|
|
2745
3391
|
isFullyPaid: isFullyPaid
|
|
2746
3392
|
});
|
|
2747
3393
|
case 13:
|
|
2748
3394
|
if (!(this.store.syncState === 'submitting')) {
|
|
2749
|
-
|
|
3395
|
+
_context23.next = 15;
|
|
2750
3396
|
break;
|
|
2751
3397
|
}
|
|
2752
|
-
return
|
|
3398
|
+
return _context23.abrupt("return", {
|
|
2753
3399
|
isFullyPaid: isFullyPaid
|
|
2754
3400
|
});
|
|
2755
3401
|
case 15:
|
|
2756
3402
|
this.store.syncState = 'submitting';
|
|
2757
3403
|
paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, mappedPayments);
|
|
2758
|
-
|
|
3404
|
+
_context23.next = 19;
|
|
2759
3405
|
return this.submitTempOrder({
|
|
2760
3406
|
payments: mappedPayments,
|
|
2761
3407
|
paymentStatus: paymentStatus,
|
|
@@ -2770,18 +3416,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2770
3416
|
}
|
|
2771
3417
|
});
|
|
2772
3418
|
case 19:
|
|
2773
|
-
submitResult =
|
|
2774
|
-
return
|
|
3419
|
+
submitResult = _context23.sent;
|
|
3420
|
+
return _context23.abrupt("return", {
|
|
2775
3421
|
isFullyPaid: isFullyPaid,
|
|
2776
3422
|
submitResult: submitResult
|
|
2777
3423
|
});
|
|
2778
3424
|
case 21:
|
|
2779
3425
|
case "end":
|
|
2780
|
-
return
|
|
3426
|
+
return _context23.stop();
|
|
2781
3427
|
}
|
|
2782
|
-
},
|
|
3428
|
+
}, _callee21, this);
|
|
2783
3429
|
}));
|
|
2784
|
-
function syncPaymentsToOrder(
|
|
3430
|
+
function syncPaymentsToOrder(_x22) {
|
|
2785
3431
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
2786
3432
|
}
|
|
2787
3433
|
return syncPaymentsToOrder;
|
|
@@ -2870,11 +3516,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2870
3516
|
}, {
|
|
2871
3517
|
key: "submitOrder",
|
|
2872
3518
|
value: function () {
|
|
2873
|
-
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3519
|
+
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(order) {
|
|
2874
3520
|
var _order$query$cartItem, _params$bookings, _params$relation_prod;
|
|
2875
3521
|
var url, query, fetchUrl, params;
|
|
2876
|
-
return _regeneratorRuntime().wrap(function
|
|
2877
|
-
while (1) switch (
|
|
3522
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context24) {
|
|
3523
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
2878
3524
|
case 0:
|
|
2879
3525
|
this.logInfo('submitOrder called', {
|
|
2880
3526
|
url: order.url,
|
|
@@ -2894,14 +3540,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2894
3540
|
relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
|
|
2895
3541
|
scheduleDate: params.schedule_date
|
|
2896
3542
|
});
|
|
2897
|
-
return
|
|
3543
|
+
return _context24.abrupt("return", this.request.post(fetchUrl, params));
|
|
2898
3544
|
case 6:
|
|
2899
3545
|
case "end":
|
|
2900
|
-
return
|
|
3546
|
+
return _context24.stop();
|
|
2901
3547
|
}
|
|
2902
|
-
},
|
|
3548
|
+
}, _callee22, this);
|
|
2903
3549
|
}));
|
|
2904
|
-
function submitOrder(
|
|
3550
|
+
function submitOrder(_x23) {
|
|
2905
3551
|
return _submitOrder.apply(this, arguments);
|
|
2906
3552
|
}
|
|
2907
3553
|
return submitOrder;
|
|
@@ -2909,13 +3555,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2909
3555
|
}, {
|
|
2910
3556
|
key: "cancelOrder",
|
|
2911
3557
|
value: function () {
|
|
2912
|
-
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3558
|
+
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
|
|
2913
3559
|
var payload;
|
|
2914
|
-
return _regeneratorRuntime().wrap(function
|
|
2915
|
-
while (1) switch (
|
|
3560
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context25) {
|
|
3561
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
2916
3562
|
case 0:
|
|
2917
3563
|
if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
|
|
2918
|
-
|
|
3564
|
+
_context25.next = 2;
|
|
2919
3565
|
break;
|
|
2920
3566
|
}
|
|
2921
3567
|
throw new Error('取消订单失败:order_ids 不能为空');
|
|
@@ -2931,16 +3577,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2931
3577
|
method: 'PUT',
|
|
2932
3578
|
orderIdsCount: params.order_ids.length
|
|
2933
3579
|
});
|
|
2934
|
-
return
|
|
3580
|
+
return _context25.abrupt("return", this.request.put('/order/update-status', payload, {
|
|
2935
3581
|
isShopApi: true
|
|
2936
3582
|
}));
|
|
2937
3583
|
case 5:
|
|
2938
3584
|
case "end":
|
|
2939
|
-
return
|
|
3585
|
+
return _context25.stop();
|
|
2940
3586
|
}
|
|
2941
|
-
},
|
|
3587
|
+
}, _callee23, this);
|
|
2942
3588
|
}));
|
|
2943
|
-
function cancelOrder(
|
|
3589
|
+
function cancelOrder(_x24) {
|
|
2944
3590
|
return _cancelOrder.apply(this, arguments);
|
|
2945
3591
|
}
|
|
2946
3592
|
return cancelOrder;
|
|
@@ -2948,19 +3594,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2948
3594
|
}, {
|
|
2949
3595
|
key: "changeBookingStatus",
|
|
2950
3596
|
value: function () {
|
|
2951
|
-
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3597
|
+
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
|
|
2952
3598
|
var url, payload;
|
|
2953
|
-
return _regeneratorRuntime().wrap(function
|
|
2954
|
-
while (1) switch (
|
|
3599
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context26) {
|
|
3600
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
2955
3601
|
case 0:
|
|
2956
3602
|
if (params.booking_id) {
|
|
2957
|
-
|
|
3603
|
+
_context26.next = 2;
|
|
2958
3604
|
break;
|
|
2959
3605
|
}
|
|
2960
3606
|
throw new Error('变更预约状态失败:booking_id 不能为空');
|
|
2961
3607
|
case 2:
|
|
2962
3608
|
if (params.appointment_status) {
|
|
2963
|
-
|
|
3609
|
+
_context26.next = 4;
|
|
2964
3610
|
break;
|
|
2965
3611
|
}
|
|
2966
3612
|
throw new Error('变更预约状态失败:appointment_status 不能为空');
|
|
@@ -2975,16 +3621,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2975
3621
|
bookingId: params.booking_id,
|
|
2976
3622
|
appointmentStatus: params.appointment_status
|
|
2977
3623
|
});
|
|
2978
|
-
return
|
|
3624
|
+
return _context26.abrupt("return", this.request.put(url, payload, {
|
|
2979
3625
|
isShopApi: true
|
|
2980
3626
|
}));
|
|
2981
3627
|
case 8:
|
|
2982
3628
|
case "end":
|
|
2983
|
-
return
|
|
3629
|
+
return _context26.stop();
|
|
2984
3630
|
}
|
|
2985
|
-
},
|
|
3631
|
+
}, _callee24, this);
|
|
2986
3632
|
}));
|
|
2987
|
-
function changeBookingStatus(
|
|
3633
|
+
function changeBookingStatus(_x25) {
|
|
2988
3634
|
return _changeBookingStatus.apply(this, arguments);
|
|
2989
3635
|
}
|
|
2990
3636
|
return changeBookingStatus;
|
|
@@ -3002,11 +3648,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3002
3648
|
}, {
|
|
3003
3649
|
key: "createOrderByCheckout",
|
|
3004
3650
|
value: (function () {
|
|
3005
|
-
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3651
|
+
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
|
|
3006
3652
|
var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3, _params$bookings3, _params$relation_prod3, _params$payments4;
|
|
3007
3653
|
var onlineStorePaymentCodeList, _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, _orderData$bookings2, _orderData$relation_p2, _orderData$payments4, _orderData$payments5, _response$data, orderData, response;
|
|
3008
|
-
return _regeneratorRuntime().wrap(function
|
|
3009
|
-
while (1) switch (
|
|
3654
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context27) {
|
|
3655
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
3010
3656
|
case 0:
|
|
3011
3657
|
// 过滤掉由在线店铺下单的 payment 支付数据
|
|
3012
3658
|
onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
|
|
@@ -3040,7 +3686,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3040
3686
|
relationProductsCount: ((_params$relation_prod3 = params.relation_products) === null || _params$relation_prod3 === void 0 ? void 0 : _params$relation_prod3.length) || 0,
|
|
3041
3687
|
paymentsCount: ((_params$payments4 = params.payments) === null || _params$payments4 === void 0 ? void 0 : _params$payments4.length) || 0
|
|
3042
3688
|
});
|
|
3043
|
-
|
|
3689
|
+
_context27.prev = 4;
|
|
3044
3690
|
// 构建订单数据,设置默认值并允许 params 覆盖
|
|
3045
3691
|
orderData = _objectSpread({
|
|
3046
3692
|
sales_channel: 'my_pisel',
|
|
@@ -3102,13 +3748,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3102
3748
|
hasOrderId: !!orderData.order_id,
|
|
3103
3749
|
smallTicketDataFlag: orderData.small_ticket_data_flag
|
|
3104
3750
|
});
|
|
3105
|
-
|
|
3751
|
+
_context27.next = 12;
|
|
3106
3752
|
return this.request.post('/shop/order/checkout', orderData, {
|
|
3107
3753
|
osServer: true,
|
|
3108
3754
|
customToast: function customToast() {}
|
|
3109
3755
|
});
|
|
3110
3756
|
case 12:
|
|
3111
|
-
response =
|
|
3757
|
+
response = _context27.sent;
|
|
3112
3758
|
this.logInfo('Order API called successfully', {
|
|
3113
3759
|
response: response
|
|
3114
3760
|
});
|
|
@@ -3116,22 +3762,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3116
3762
|
success: !!response,
|
|
3117
3763
|
hasOrderId: !!(response !== null && response !== void 0 && (_response$data = response.data) !== null && _response$data !== void 0 && _response$data.order_id || response !== null && response !== void 0 && response.order_id)
|
|
3118
3764
|
});
|
|
3119
|
-
return
|
|
3765
|
+
return _context27.abrupt("return", response);
|
|
3120
3766
|
case 18:
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
console.error('[Order] createOrderByCheckout 创建订单失败:',
|
|
3767
|
+
_context27.prev = 18;
|
|
3768
|
+
_context27.t0 = _context27["catch"](4);
|
|
3769
|
+
console.error('[Order] createOrderByCheckout 创建订单失败:', _context27.t0);
|
|
3124
3770
|
this.logInfo('Order API called failed', {
|
|
3125
|
-
error:
|
|
3771
|
+
error: _context27.t0 instanceof Error ? _context27.t0.message : String(_context27.t0)
|
|
3126
3772
|
});
|
|
3127
|
-
throw
|
|
3773
|
+
throw _context27.t0;
|
|
3128
3774
|
case 23:
|
|
3129
3775
|
case "end":
|
|
3130
|
-
return
|
|
3776
|
+
return _context27.stop();
|
|
3131
3777
|
}
|
|
3132
|
-
},
|
|
3778
|
+
}, _callee25, this, [[4, 18]]);
|
|
3133
3779
|
}));
|
|
3134
|
-
function createOrderByCheckout(
|
|
3780
|
+
function createOrderByCheckout(_x26) {
|
|
3135
3781
|
return _createOrderByCheckout.apply(this, arguments);
|
|
3136
3782
|
}
|
|
3137
3783
|
return createOrderByCheckout;
|
|
@@ -3139,24 +3785,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3139
3785
|
}, {
|
|
3140
3786
|
key: "submitSalesOrder",
|
|
3141
3787
|
value: function () {
|
|
3142
|
-
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3788
|
+
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
|
|
3143
3789
|
var url, query, fetchUrl;
|
|
3144
|
-
return _regeneratorRuntime().wrap(function
|
|
3145
|
-
while (1) switch (
|
|
3790
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context28) {
|
|
3791
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
3146
3792
|
case 0:
|
|
3147
3793
|
url = params.url, query = params.query;
|
|
3148
3794
|
fetchUrl = url || '/order/sales/checkout';
|
|
3149
|
-
return
|
|
3795
|
+
return _context28.abrupt("return", this.request.post(fetchUrl, query, {
|
|
3150
3796
|
osServer: true,
|
|
3151
3797
|
customToast: function customToast() {}
|
|
3152
3798
|
}));
|
|
3153
3799
|
case 3:
|
|
3154
3800
|
case "end":
|
|
3155
|
-
return
|
|
3801
|
+
return _context28.stop();
|
|
3156
3802
|
}
|
|
3157
|
-
},
|
|
3803
|
+
}, _callee26, this);
|
|
3158
3804
|
}));
|
|
3159
|
-
function submitSalesOrder(
|
|
3805
|
+
function submitSalesOrder(_x27) {
|
|
3160
3806
|
return _submitSalesOrder.apply(this, arguments);
|
|
3161
3807
|
}
|
|
3162
3808
|
return submitSalesOrder;
|
|
@@ -3170,37 +3816,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3170
3816
|
}, {
|
|
3171
3817
|
key: "sendCustomerPayLink",
|
|
3172
3818
|
value: (function () {
|
|
3173
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3819
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
|
|
3174
3820
|
var _params$emails;
|
|
3175
3821
|
var orderIds;
|
|
3176
|
-
return _regeneratorRuntime().wrap(function
|
|
3177
|
-
while (1) switch (
|
|
3822
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context29) {
|
|
3823
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
3178
3824
|
case 0:
|
|
3179
3825
|
orderIds = params.order_ids || params.orderIds || [];
|
|
3180
3826
|
if (orderIds.length) {
|
|
3181
|
-
|
|
3827
|
+
_context29.next = 3;
|
|
3182
3828
|
break;
|
|
3183
3829
|
}
|
|
3184
3830
|
throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
|
|
3185
3831
|
case 3:
|
|
3186
3832
|
if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
|
|
3187
|
-
|
|
3833
|
+
_context29.next = 5;
|
|
3188
3834
|
break;
|
|
3189
3835
|
}
|
|
3190
3836
|
throw new Error('发送支付链接需要至少一个邮箱');
|
|
3191
3837
|
case 5:
|
|
3192
|
-
return
|
|
3838
|
+
return _context29.abrupt("return", this.request.post('/order/batch-email', {
|
|
3193
3839
|
order_ids: orderIds,
|
|
3194
3840
|
notify_action: params.notify_action || 'order_payment_reminder',
|
|
3195
3841
|
emails: params.emails
|
|
3196
3842
|
}));
|
|
3197
3843
|
case 6:
|
|
3198
3844
|
case "end":
|
|
3199
|
-
return
|
|
3845
|
+
return _context29.stop();
|
|
3200
3846
|
}
|
|
3201
|
-
},
|
|
3847
|
+
}, _callee27, this);
|
|
3202
3848
|
}));
|
|
3203
|
-
function sendCustomerPayLink(
|
|
3849
|
+
function sendCustomerPayLink(_x28) {
|
|
3204
3850
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
3205
3851
|
}
|
|
3206
3852
|
return sendCustomerPayLink;
|
|
@@ -3208,19 +3854,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3208
3854
|
}, {
|
|
3209
3855
|
key: "getSalesOrderByLookup",
|
|
3210
3856
|
value: function () {
|
|
3211
|
-
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3857
|
+
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
|
|
3212
3858
|
var lookup, res;
|
|
3213
|
-
return _regeneratorRuntime().wrap(function
|
|
3214
|
-
while (1) switch (
|
|
3859
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context30) {
|
|
3860
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
3215
3861
|
case 0:
|
|
3216
3862
|
lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
|
|
3217
3863
|
if (lookup) {
|
|
3218
|
-
|
|
3864
|
+
_context30.next = 3;
|
|
3219
3865
|
break;
|
|
3220
3866
|
}
|
|
3221
3867
|
throw new Error('加载销售详情需要 lookup');
|
|
3222
3868
|
case 3:
|
|
3223
|
-
|
|
3869
|
+
_context30.next = 5;
|
|
3224
3870
|
return this.request.get("/order/sales/".concat(encodeURIComponent(lookup)), _objectSpread({
|
|
3225
3871
|
with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info']
|
|
3226
3872
|
}, params.forceRemote ? {
|
|
@@ -3229,18 +3875,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3229
3875
|
osServer: true
|
|
3230
3876
|
});
|
|
3231
3877
|
case 5:
|
|
3232
|
-
res =
|
|
3878
|
+
res = _context30.sent;
|
|
3233
3879
|
if (res.code === 200) {
|
|
3234
3880
|
this.store.lastOrderInfo = res.data;
|
|
3235
3881
|
}
|
|
3236
|
-
return
|
|
3882
|
+
return _context30.abrupt("return", res);
|
|
3237
3883
|
case 8:
|
|
3238
3884
|
case "end":
|
|
3239
|
-
return
|
|
3885
|
+
return _context30.stop();
|
|
3240
3886
|
}
|
|
3241
|
-
},
|
|
3887
|
+
}, _callee28, this);
|
|
3242
3888
|
}));
|
|
3243
|
-
function getSalesOrderByLookup(
|
|
3889
|
+
function getSalesOrderByLookup(_x29) {
|
|
3244
3890
|
return _getSalesOrderByLookup.apply(this, arguments);
|
|
3245
3891
|
}
|
|
3246
3892
|
return getSalesOrderByLookup;
|
|
@@ -3254,34 +3900,57 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3254
3900
|
}, {
|
|
3255
3901
|
key: "hydrateTempOrderFromRecord",
|
|
3256
3902
|
value: (function () {
|
|
3257
|
-
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3258
|
-
var
|
|
3259
|
-
|
|
3260
|
-
|
|
3903
|
+
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(record, options) {
|
|
3904
|
+
var _this$store$discount13, _this$store$discount14;
|
|
3905
|
+
var raw, nextTempOrder, rawSummary, summarySurcharges, hydratedEditDiscounts;
|
|
3906
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context31) {
|
|
3907
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
3261
3908
|
case 0:
|
|
3262
3909
|
raw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
|
|
3263
3910
|
nextTempOrder = this.normalizeTempOrderForRuntime(raw);
|
|
3911
|
+
rawSummary = raw.summary && _typeof(raw.summary) === 'object' ? raw.summary : {};
|
|
3912
|
+
summarySurcharges = Array.isArray(rawSummary.surcharges) ? rawSummary.surcharges.map(function (s) {
|
|
3913
|
+
return _objectSpread({}, s || {});
|
|
3914
|
+
}) : cloneDeep(nextTempOrder.surcharges || []);
|
|
3264
3915
|
this.store.tempOrder = nextTempOrder;
|
|
3265
|
-
this.store.summary =
|
|
3916
|
+
this.store.summary = _objectSpread(_objectSpread(_objectSpread({}, createEmptySummary()), rawSummary), {}, {
|
|
3917
|
+
surcharges: summarySurcharges
|
|
3918
|
+
});
|
|
3919
|
+
nextTempOrder._extend = _objectSpread(_objectSpread({}, nextTempOrder._extend || {}), {}, {
|
|
3920
|
+
originalSalesSnapshot: {
|
|
3921
|
+
summary: cloneDeep(this.store.summary),
|
|
3922
|
+
products: cloneDeep(nextTempOrder.products || []),
|
|
3923
|
+
payments: cloneDeep(nextTempOrder.payments || []),
|
|
3924
|
+
surcharges: cloneDeep(nextTempOrder.surcharges || []),
|
|
3925
|
+
productFingerprint: this.buildOrderProductsFingerprint(nextTempOrder.products || [])
|
|
3926
|
+
}
|
|
3927
|
+
});
|
|
3266
3928
|
this.store.lastOrderInfo = raw.lastOrderInfo || raw;
|
|
3929
|
+
hydratedEditDiscounts = this.collectHydratedEditDiscounts(nextTempOrder.products);
|
|
3930
|
+
_context31.next = 11;
|
|
3931
|
+
return (_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.setOriginalDiscountList(hydratedEditDiscounts);
|
|
3932
|
+
case 11:
|
|
3933
|
+
_context31.next = 13;
|
|
3934
|
+
return (_this$store$discount14 = this.store.discount) === null || _this$store$discount14 === void 0 ? void 0 : _this$store$discount14.setDiscountList(hydratedEditDiscounts);
|
|
3935
|
+
case 13:
|
|
3267
3936
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
3268
|
-
|
|
3937
|
+
_context31.next = 16;
|
|
3269
3938
|
break;
|
|
3270
3939
|
}
|
|
3271
|
-
|
|
3940
|
+
_context31.next = 16;
|
|
3272
3941
|
return this.recalculateSummary({
|
|
3273
3942
|
createIfMissing: false
|
|
3274
3943
|
});
|
|
3275
|
-
case
|
|
3944
|
+
case 16:
|
|
3276
3945
|
this.persistTempOrder();
|
|
3277
|
-
return
|
|
3278
|
-
case
|
|
3946
|
+
return _context31.abrupt("return", nextTempOrder);
|
|
3947
|
+
case 18:
|
|
3279
3948
|
case "end":
|
|
3280
|
-
return
|
|
3949
|
+
return _context31.stop();
|
|
3281
3950
|
}
|
|
3282
|
-
},
|
|
3951
|
+
}, _callee29, this);
|
|
3283
3952
|
}));
|
|
3284
|
-
function hydrateTempOrderFromRecord(
|
|
3953
|
+
function hydrateTempOrderFromRecord(_x30, _x31) {
|
|
3285
3954
|
return _hydrateTempOrderFromRecord.apply(this, arguments);
|
|
3286
3955
|
}
|
|
3287
3956
|
return hydrateTempOrderFromRecord;
|
|
@@ -3289,7 +3958,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3289
3958
|
}, {
|
|
3290
3959
|
key: "normalizeTempOrderForRuntime",
|
|
3291
3960
|
value: function normalizeTempOrderForRuntime(raw, options) {
|
|
3292
|
-
var
|
|
3961
|
+
var _this19 = this;
|
|
3293
3962
|
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), raw || {});
|
|
3294
3963
|
delete nextTempOrder.summary;
|
|
3295
3964
|
delete nextTempOrder.lastOrderInfo;
|
|
@@ -3308,7 +3977,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3308
3977
|
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
3309
3978
|
var rawProducts = Array.isArray(raw.products) ? raw.products : [];
|
|
3310
3979
|
nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
|
|
3311
|
-
return
|
|
3980
|
+
return _this19.normalizeHydratedOrderProduct(p);
|
|
3312
3981
|
}) : [];
|
|
3313
3982
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
3314
3983
|
return _objectSpread(_objectSpread({}, b || {}), {}, {
|
|
@@ -3336,19 +4005,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3336
4005
|
};
|
|
3337
4006
|
var tempOrderExtend = nextTempOrder._extend;
|
|
3338
4007
|
var productsByUid = tempOrderExtend.productsByUid || {};
|
|
3339
|
-
var
|
|
3340
|
-
|
|
4008
|
+
var _iterator18 = _createForOfIteratorHelper(nextTempOrder.products.entries()),
|
|
4009
|
+
_step18;
|
|
3341
4010
|
try {
|
|
3342
|
-
for (
|
|
3343
|
-
var _product$metadata7,
|
|
3344
|
-
var
|
|
3345
|
-
index =
|
|
3346
|
-
product =
|
|
4011
|
+
for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
|
|
4012
|
+
var _product$metadata7, _ref64, _ref65, _existed$origin, _rawProduct$metadata;
|
|
4013
|
+
var _step18$value = _slicedToArray(_step18.value, 2),
|
|
4014
|
+
index = _step18$value[0],
|
|
4015
|
+
product = _step18$value[1];
|
|
3347
4016
|
var uid = (_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.unique_identification_number;
|
|
3348
4017
|
if (!uid) continue;
|
|
3349
4018
|
var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
|
|
3350
4019
|
var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
|
|
3351
|
-
var origin = (
|
|
4020
|
+
var origin = (_ref64 = (_ref65 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref65 !== void 0 ? _ref65 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref64 !== void 0 ? _ref64 : rawProduct;
|
|
3352
4021
|
var originSnapshot = cloneDeep(origin);
|
|
3353
4022
|
var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
|
|
3354
4023
|
if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
|
|
@@ -3364,9 +4033,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3364
4033
|
});
|
|
3365
4034
|
}
|
|
3366
4035
|
} catch (err) {
|
|
3367
|
-
|
|
4036
|
+
_iterator18.e(err);
|
|
3368
4037
|
} finally {
|
|
3369
|
-
|
|
4038
|
+
_iterator18.f();
|
|
3370
4039
|
}
|
|
3371
4040
|
tempOrderExtend.productsByUid = productsByUid;
|
|
3372
4041
|
if ((options === null || options === void 0 ? void 0 : options.ensureIdentity) !== false) {
|
|
@@ -3397,18 +4066,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3397
4066
|
var segments = [];
|
|
3398
4067
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
3399
4068
|
if (Array.isArray(sku.variant)) {
|
|
3400
|
-
var
|
|
3401
|
-
|
|
4069
|
+
var _iterator19 = _createForOfIteratorHelper(sku.variant),
|
|
4070
|
+
_step19;
|
|
3402
4071
|
try {
|
|
3403
|
-
for (
|
|
3404
|
-
var variant =
|
|
4072
|
+
for (_iterator19.s(); !(_step19 = _iterator19.n()).done;) {
|
|
4073
|
+
var variant = _step19.value;
|
|
3405
4074
|
var segment = this.formatHydratedNamePair(variant === null || variant === void 0 ? void 0 : variant.group, variant === null || variant === void 0 ? void 0 : variant.item);
|
|
3406
4075
|
if (segment) segments.push(segment);
|
|
3407
4076
|
}
|
|
3408
4077
|
} catch (err) {
|
|
3409
|
-
|
|
4078
|
+
_iterator19.e(err);
|
|
3410
4079
|
} finally {
|
|
3411
|
-
|
|
4080
|
+
_iterator19.f();
|
|
3412
4081
|
}
|
|
3413
4082
|
}
|
|
3414
4083
|
return segments.join(', ');
|
|
@@ -3416,10 +4085,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3416
4085
|
}, {
|
|
3417
4086
|
key: "normalizeHydratedProductOptionItem",
|
|
3418
4087
|
value: function normalizeHydratedProductOptionItem(optionItem) {
|
|
3419
|
-
var
|
|
3420
|
-
var rawNum = (
|
|
4088
|
+
var _ref66, _optionItem$num, _ref67, _optionItem$add_price;
|
|
4089
|
+
var rawNum = (_ref66 = (_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 && _ref66 !== void 0 ? _ref66 : 1;
|
|
3421
4090
|
var parsedNum = Number(rawNum);
|
|
3422
|
-
var rawPrice = (
|
|
4091
|
+
var rawPrice = (_ref67 = (_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 && _ref67 !== void 0 ? _ref67 : 0;
|
|
3423
4092
|
var parsedPrice = Number(rawPrice);
|
|
3424
4093
|
var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
|
|
3425
4094
|
option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
|
|
@@ -3436,7 +4105,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3436
4105
|
}, {
|
|
3437
4106
|
key: "normalizeHydratedOrderProduct",
|
|
3438
4107
|
value: function normalizeHydratedOrderProduct(product) {
|
|
3439
|
-
var
|
|
4108
|
+
var _this20 = this;
|
|
3440
4109
|
var row = _objectSpread({}, product || {});
|
|
3441
4110
|
if (row.num === undefined && row.product_quantity !== undefined) {
|
|
3442
4111
|
row.num = row.product_quantity;
|
|
@@ -3444,7 +4113,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3444
4113
|
var productSku = ensureProductSku(row);
|
|
3445
4114
|
row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
|
|
3446
4115
|
option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
|
|
3447
|
-
return
|
|
4116
|
+
return _this20.normalizeHydratedProductOptionItem(optionItem || {});
|
|
3448
4117
|
}))
|
|
3449
4118
|
});
|
|
3450
4119
|
delete row["product_".concat('option', "_item")];
|
|
@@ -3475,107 +4144,102 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3475
4144
|
}, {
|
|
3476
4145
|
key: "getOrderInfo",
|
|
3477
4146
|
value: function () {
|
|
3478
|
-
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4147
|
+
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(order_id) {
|
|
3479
4148
|
var res;
|
|
3480
|
-
return _regeneratorRuntime().wrap(function
|
|
3481
|
-
while (1) switch (
|
|
4149
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context32) {
|
|
4150
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
3482
4151
|
case 0:
|
|
3483
|
-
|
|
4152
|
+
_context32.next = 2;
|
|
3484
4153
|
return this.request.get("/order/sales/".concat(order_id), {
|
|
3485
4154
|
with: ['products', 'bookings']
|
|
3486
4155
|
});
|
|
3487
4156
|
case 2:
|
|
3488
|
-
res =
|
|
3489
|
-
return
|
|
4157
|
+
res = _context32.sent;
|
|
4158
|
+
return _context32.abrupt("return", res);
|
|
3490
4159
|
case 4:
|
|
3491
4160
|
case "end":
|
|
3492
|
-
return
|
|
4161
|
+
return _context32.stop();
|
|
3493
4162
|
}
|
|
3494
|
-
},
|
|
4163
|
+
}, _callee30, this);
|
|
3495
4164
|
}));
|
|
3496
|
-
function getOrderInfo(
|
|
4165
|
+
function getOrderInfo(_x32) {
|
|
3497
4166
|
return _getOrderInfo.apply(this, arguments);
|
|
3498
4167
|
}
|
|
3499
4168
|
return getOrderInfo;
|
|
3500
4169
|
}()
|
|
3501
4170
|
}], [{
|
|
3502
4171
|
key: "populateSavedAmounts",
|
|
3503
|
-
value:
|
|
3504
|
-
/**
|
|
3505
|
-
* Populate `savedAmount` on each discount based on product-level discount details.
|
|
3506
|
-
* Only selected discounts get a non-zero value.
|
|
3507
|
-
*/
|
|
3508
|
-
function populateSavedAmounts(productList, discountList) {
|
|
4172
|
+
value: function populateSavedAmounts(productList, discountList) {
|
|
3509
4173
|
var savedMap = new Map();
|
|
3510
4174
|
var addDiscountAmount = function addDiscountAmount(discount, quantity) {
|
|
3511
|
-
var _discount$
|
|
3512
|
-
var discountKey = ((_discount$
|
|
4175
|
+
var _discount$discount3, _discount$metadata;
|
|
4176
|
+
var discountKey = ((_discount$discount3 = discount.discount) === null || _discount$discount3 === void 0 ? void 0 : _discount$discount3.resource_id) || discount.id;
|
|
3513
4177
|
if (discountKey == null) return;
|
|
3514
4178
|
var qty = Number(quantity) || 1;
|
|
3515
4179
|
var amount = new Decimal(discount.amount || 0).times(qty).plus(((_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.product_discount_difference) || 0);
|
|
3516
4180
|
savedMap.set(discountKey, (savedMap.get(discountKey) || new Decimal(0)).plus(amount));
|
|
3517
4181
|
};
|
|
3518
|
-
var
|
|
3519
|
-
|
|
4182
|
+
var _iterator20 = _createForOfIteratorHelper(productList),
|
|
4183
|
+
_step20;
|
|
3520
4184
|
try {
|
|
3521
|
-
for (
|
|
3522
|
-
var product =
|
|
4185
|
+
for (_iterator20.s(); !(_step20 = _iterator20.n()).done;) {
|
|
4186
|
+
var product = _step20.value;
|
|
3523
4187
|
var qty = product.num || 1;
|
|
3524
|
-
var
|
|
3525
|
-
|
|
4188
|
+
var _iterator22 = _createForOfIteratorHelper(product.discount_list || []),
|
|
4189
|
+
_step22;
|
|
3526
4190
|
try {
|
|
3527
|
-
for (
|
|
3528
|
-
var pd =
|
|
4191
|
+
for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
|
|
4192
|
+
var pd = _step22.value;
|
|
3529
4193
|
addDiscountAmount(pd, qty);
|
|
3530
4194
|
}
|
|
3531
4195
|
} catch (err) {
|
|
3532
|
-
|
|
4196
|
+
_iterator22.e(err);
|
|
3533
4197
|
} finally {
|
|
3534
|
-
|
|
4198
|
+
_iterator22.f();
|
|
3535
4199
|
}
|
|
3536
|
-
var
|
|
3537
|
-
|
|
4200
|
+
var _iterator23 = _createForOfIteratorHelper(product.product_bundle || []),
|
|
4201
|
+
_step23;
|
|
3538
4202
|
try {
|
|
3539
|
-
for (
|
|
3540
|
-
var
|
|
3541
|
-
var bundle =
|
|
3542
|
-
var bundleQty = new Decimal(Number(qty) || 1).times(Number((
|
|
3543
|
-
var
|
|
3544
|
-
|
|
4203
|
+
for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {
|
|
4204
|
+
var _ref68, _bundle$num3;
|
|
4205
|
+
var bundle = _step23.value;
|
|
4206
|
+
var bundleQty = new Decimal(Number(qty) || 1).times(Number((_ref68 = (_bundle$num3 = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num3 !== void 0 ? _bundle$num3 : bundle === null || bundle === void 0 ? void 0 : bundle.quantity) !== null && _ref68 !== void 0 ? _ref68 : 1) || 1).toNumber();
|
|
4207
|
+
var _iterator24 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
|
|
4208
|
+
_step24;
|
|
3545
4209
|
try {
|
|
3546
|
-
for (
|
|
3547
|
-
var _pd =
|
|
4210
|
+
for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
|
|
4211
|
+
var _pd = _step24.value;
|
|
3548
4212
|
addDiscountAmount(_pd, bundleQty);
|
|
3549
4213
|
}
|
|
3550
4214
|
} catch (err) {
|
|
3551
|
-
|
|
4215
|
+
_iterator24.e(err);
|
|
3552
4216
|
} finally {
|
|
3553
|
-
|
|
4217
|
+
_iterator24.f();
|
|
3554
4218
|
}
|
|
3555
4219
|
}
|
|
3556
4220
|
} catch (err) {
|
|
3557
|
-
|
|
4221
|
+
_iterator23.e(err);
|
|
3558
4222
|
} finally {
|
|
3559
|
-
|
|
4223
|
+
_iterator23.f();
|
|
3560
4224
|
}
|
|
3561
4225
|
}
|
|
3562
4226
|
} catch (err) {
|
|
3563
|
-
|
|
4227
|
+
_iterator20.e(err);
|
|
3564
4228
|
} finally {
|
|
3565
|
-
|
|
4229
|
+
_iterator20.f();
|
|
3566
4230
|
}
|
|
3567
|
-
var
|
|
3568
|
-
|
|
4231
|
+
var _iterator21 = _createForOfIteratorHelper(discountList),
|
|
4232
|
+
_step21;
|
|
3569
4233
|
try {
|
|
3570
|
-
for (
|
|
3571
|
-
var d =
|
|
4234
|
+
for (_iterator21.s(); !(_step21 = _iterator21.n()).done;) {
|
|
4235
|
+
var d = _step21.value;
|
|
3572
4236
|
var key = d.id;
|
|
3573
4237
|
d.savedAmount = d.isSelected && key != null && savedMap.has(key) ? savedMap.get(key).toNumber() : 0;
|
|
3574
4238
|
}
|
|
3575
4239
|
} catch (err) {
|
|
3576
|
-
|
|
4240
|
+
_iterator21.e(err);
|
|
3577
4241
|
} finally {
|
|
3578
|
-
|
|
4242
|
+
_iterator21.f();
|
|
3579
4243
|
}
|
|
3580
4244
|
}
|
|
3581
4245
|
}]);
|