@pisell/pisellos 2.3.20 → 2.3.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +16 -10
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
- package/dist/modules/Order/index.js +17 -7
- package/dist/modules/Order/types.d.ts +1 -0
- package/dist/modules/Order/utils.js +16 -4
- package/dist/server/index.d.ts +5 -0
- package/dist/server/index.js +428 -255
- package/dist/server/modules/order/types.d.ts +4 -0
- package/dist/server/modules/products/index.d.ts +5 -1
- package/dist/server/modules/products/index.js +383 -315
- package/dist/server/modules/products/types.d.ts +4 -0
- package/dist/solution/BaseSales/index.d.ts +10 -0
- package/dist/solution/BaseSales/index.js +503 -428
- package/dist/solution/BaseSales/types.d.ts +6 -1
- package/dist/solution/BaseSales/types.js +1 -1
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +14 -1
- package/dist/solution/BookingTicket/index.js +42 -24
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -0
- package/lib/modules/Order/index.js +22 -7
- package/lib/modules/Order/types.d.ts +1 -0
- package/lib/modules/Order/utils.js +17 -3
- package/lib/server/index.d.ts +5 -0
- package/lib/server/index.js +121 -2
- package/lib/server/modules/order/types.d.ts +4 -0
- package/lib/server/modules/products/index.d.ts +5 -1
- package/lib/server/modules/products/index.js +20 -0
- package/lib/server/modules/products/types.d.ts +4 -0
- package/lib/solution/BaseSales/index.d.ts +10 -0
- package/lib/solution/BaseSales/index.js +66 -23
- package/lib/solution/BaseSales/types.d.ts +6 -1
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +8 -0
- package/lib/solution/BookingTicket/index.js +15 -7
- package/package.json +1 -1
|
@@ -3,8 +3,6 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArra
|
|
|
3
3
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
4
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
5
5
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
6
|
-
function 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; }
|
|
7
|
-
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; }
|
|
8
6
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
9
7
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
10
8
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
@@ -20,15 +18,17 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
|
|
|
20
18
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
21
19
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
22
20
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
23
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
24
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
25
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
26
21
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
27
22
|
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."); }
|
|
28
23
|
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); }
|
|
29
24
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
30
25
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
31
26
|
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; }
|
|
27
|
+
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; }
|
|
28
|
+
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; }
|
|
29
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
30
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
31
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
32
32
|
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); }
|
|
33
33
|
import { BaseModule } from "../../modules/BaseModule";
|
|
34
34
|
import { BaseSalesHookNames } from "./types";
|
|
@@ -92,7 +92,24 @@ function getBaseSalesMetadataUid(item, metadataKey) {
|
|
|
92
92
|
if (uid === undefined || uid === null || uid === '') return null;
|
|
93
93
|
return String(uid);
|
|
94
94
|
}
|
|
95
|
-
function
|
|
95
|
+
function isBaseSalesBlankValue(value) {
|
|
96
|
+
return value === undefined || value === null || value === '';
|
|
97
|
+
}
|
|
98
|
+
function mergeBaseSalesProductSnapshotFields(currentItem, loadedItem) {
|
|
99
|
+
var _currentItem$metadata, _mergedItem$metadata, _mergedItem$metadata2;
|
|
100
|
+
var mergedItem = cloneDeep(loadedItem);
|
|
101
|
+
if (isBaseSalesBlankValue(mergedItem.product_cover) && !isBaseSalesBlankValue(currentItem === null || currentItem === void 0 ? void 0 : currentItem.product_cover)) {
|
|
102
|
+
mergedItem.product_cover = currentItem.product_cover;
|
|
103
|
+
}
|
|
104
|
+
var currentHolderConfig = currentItem === null || currentItem === void 0 || (_currentItem$metadata = currentItem.metadata) === null || _currentItem$metadata === void 0 ? void 0 : _currentItem$metadata.holder_config;
|
|
105
|
+
if ((((_mergedItem$metadata = mergedItem.metadata) === null || _mergedItem$metadata === void 0 ? void 0 : _mergedItem$metadata.holder_config) === undefined || ((_mergedItem$metadata2 = mergedItem.metadata) === null || _mergedItem$metadata2 === void 0 ? void 0 : _mergedItem$metadata2.holder_config) === null) && currentHolderConfig !== undefined && currentHolderConfig !== null) {
|
|
106
|
+
mergedItem.metadata = _objectSpread(_objectSpread({}, mergedItem.metadata || {}), {}, {
|
|
107
|
+
holder_config: currentHolderConfig
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
return mergedItem;
|
|
111
|
+
}
|
|
112
|
+
function mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey, arrayKey) {
|
|
96
113
|
var result = [];
|
|
97
114
|
var indexByUid = new Map();
|
|
98
115
|
var appendOrReplaceByUid = function appendOrReplaceByUid(item) {
|
|
@@ -104,7 +121,7 @@ function mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey) {
|
|
|
104
121
|
}
|
|
105
122
|
var existingIndex = indexByUid.get(uid);
|
|
106
123
|
if (existingIndex !== undefined) {
|
|
107
|
-
result[existingIndex] = clonedItem;
|
|
124
|
+
result[existingIndex] = arrayKey === 'products' ? mergeBaseSalesProductSnapshotFields(result[existingIndex], clonedItem) : clonedItem;
|
|
108
125
|
return;
|
|
109
126
|
}
|
|
110
127
|
indexByUid.set(uid, result.length);
|
|
@@ -120,7 +137,7 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord) {
|
|
|
120
137
|
if (Array.isArray(currentValue) && Array.isArray(loadedValue)) {
|
|
121
138
|
var metadataKey = getBaseSalesUniqueArrayMetadataKey(key);
|
|
122
139
|
if (metadataKey) {
|
|
123
|
-
return mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey);
|
|
140
|
+
return mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey, key);
|
|
124
141
|
}
|
|
125
142
|
return [].concat(_toConsumableArray(cloneDeep(currentValue)), _toConsumableArray(cloneDeep(loadedValue)));
|
|
126
143
|
}
|
|
@@ -291,22 +308,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
291
308
|
return _context2.abrupt("return");
|
|
292
309
|
case 8:
|
|
293
310
|
this.serverOrderChangeHydrateInFlight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
294
|
-
var
|
|
311
|
+
var _getTempOrder, _ref2;
|
|
312
|
+
var currentTempOrder, record, sales;
|
|
295
313
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
296
314
|
while (1) switch (_context.prev = _context.next) {
|
|
297
315
|
case 0:
|
|
298
|
-
|
|
299
|
-
|
|
316
|
+
currentTempOrder = (_getTempOrder = (_ref2 = _this2.store.order).getTempOrder) === null || _getTempOrder === void 0 ? void 0 : _getTempOrder.call(_ref2);
|
|
317
|
+
record = mergeSalesDetailRecordWithTempOrder(currentTempOrder, changedOrder);
|
|
318
|
+
_context.next = 4;
|
|
319
|
+
return _this2.store.order.hydrateTempOrderFromRecord(record, {
|
|
300
320
|
recalcOnHydrate: false
|
|
301
321
|
});
|
|
302
|
-
case
|
|
322
|
+
case 4:
|
|
303
323
|
sales = _context.sent;
|
|
304
324
|
_this2.currentSalesDetail = sales;
|
|
305
|
-
_context.next =
|
|
325
|
+
_context.next = 8;
|
|
306
326
|
return _this2.core.effects.emit("".concat(_this2.name, ":onSalesOrderLoaded"), {
|
|
307
327
|
sales: sales
|
|
308
328
|
});
|
|
309
|
-
case
|
|
329
|
+
case 8:
|
|
310
330
|
case "end":
|
|
311
331
|
return _context.stop();
|
|
312
332
|
}
|
|
@@ -411,10 +431,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
411
431
|
});
|
|
412
432
|
}
|
|
413
433
|
quotation.setScheduleResolver(function (id) {
|
|
414
|
-
var _scheduleModule$getSc, _getScheduleByIds,
|
|
434
|
+
var _scheduleModule$getSc, _getScheduleByIds, _ref3;
|
|
415
435
|
var scheduleId = String(id);
|
|
416
436
|
if (scheduleById.has(scheduleId)) return scheduleById.get(scheduleId);
|
|
417
|
-
var schedules = ((_scheduleModule$getSc = scheduleModule.getScheduleListByIds) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule, [id])) || ((_getScheduleByIds = (
|
|
437
|
+
var schedules = ((_scheduleModule$getSc = scheduleModule.getScheduleListByIds) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule, [id])) || ((_getScheduleByIds = (_ref3 = scheduleModule).getScheduleByIds) === null || _getScheduleByIds === void 0 ? void 0 : _getScheduleByIds.call(_ref3, [id])) || [];
|
|
418
438
|
if (schedules[0]) scheduleById.set(scheduleId, schedules[0]);
|
|
419
439
|
return schedules[0];
|
|
420
440
|
});
|
|
@@ -601,10 +621,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
601
621
|
return groups.flatMap(function (group) {
|
|
602
622
|
var items = Array.isArray(group === null || group === void 0 ? void 0 : group.bundle_item) ? group.bundle_item : Array.isArray(group === null || group === void 0 ? void 0 : group.bundleItem) ? group.bundleItem : [];
|
|
603
623
|
return items.map(function (item) {
|
|
604
|
-
var _item$group_id,
|
|
624
|
+
var _item$group_id, _ref4, _item$bundle_group_id;
|
|
605
625
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
606
626
|
group_id: (_item$group_id = item === null || item === void 0 ? void 0 : item.group_id) !== null && _item$group_id !== void 0 ? _item$group_id : group === null || group === void 0 ? void 0 : group.id,
|
|
607
|
-
bundle_group_id: (
|
|
627
|
+
bundle_group_id: (_ref4 = (_item$bundle_group_id = item === null || item === void 0 ? void 0 : item.bundle_group_id) !== null && _item$bundle_group_id !== void 0 ? _item$bundle_group_id : item === null || item === void 0 ? void 0 : item.group_id) !== null && _ref4 !== void 0 ? _ref4 : group === null || group === void 0 ? void 0 : group.id
|
|
608
628
|
});
|
|
609
629
|
});
|
|
610
630
|
});
|
|
@@ -635,21 +655,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
635
655
|
}, {
|
|
636
656
|
key: "getAuthoritativeBundleUnitPrice",
|
|
637
657
|
value: function getAuthoritativeBundleUnitPrice(bundle) {
|
|
638
|
-
var
|
|
639
|
-
return (
|
|
658
|
+
var _ref5, _ref6, _ref7, _bundle$price;
|
|
659
|
+
return (_ref5 = (_ref6 = (_ref7 = (_bundle$price = bundle.price) !== null && _bundle$price !== void 0 ? _bundle$price : bundle.bundle_selling_price) !== null && _ref7 !== void 0 ? _ref7 : bundle.custom_price) !== null && _ref6 !== void 0 ? _ref6 : bundle.product_price) !== null && _ref5 !== void 0 ? _ref5 : bundle.base_price;
|
|
640
660
|
}
|
|
641
661
|
}, {
|
|
642
662
|
key: "mergeProductForPriceQuery",
|
|
643
663
|
value: function mergeProductForPriceQuery(product, authoritativeProduct) {
|
|
644
664
|
var _this4 = this,
|
|
645
665
|
_product$id,
|
|
646
|
-
_ref7,
|
|
647
|
-
_product$product_id2,
|
|
648
666
|
_ref8,
|
|
649
|
-
_product$
|
|
667
|
+
_product$product_id2,
|
|
650
668
|
_ref9,
|
|
651
|
-
_product$
|
|
669
|
+
_product$product_vari,
|
|
652
670
|
_ref10,
|
|
671
|
+
_product$num,
|
|
672
|
+
_ref11,
|
|
653
673
|
_product$quantity,
|
|
654
674
|
_product$metadata4;
|
|
655
675
|
if (!authoritativeProduct) return product;
|
|
@@ -669,10 +689,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
669
689
|
});
|
|
670
690
|
return _objectSpread(_objectSpread(_objectSpread({}, product), authoritativeProduct), {}, {
|
|
671
691
|
id: (_product$id = product.id) !== null && _product$id !== void 0 ? _product$id : authoritativeProduct.id,
|
|
672
|
-
product_id: (
|
|
673
|
-
product_variant_id: (
|
|
674
|
-
num: (
|
|
675
|
-
quantity: (
|
|
692
|
+
product_id: (_ref8 = (_product$product_id2 = product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : authoritativeProduct.product_id) !== null && _ref8 !== void 0 ? _ref8 : authoritativeProduct.id,
|
|
693
|
+
product_variant_id: (_ref9 = (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : authoritativeProduct.product_variant_id) !== null && _ref9 !== void 0 ? _ref9 : 0,
|
|
694
|
+
num: (_ref10 = (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : product.quantity) !== null && _ref10 !== void 0 ? _ref10 : authoritativeProduct.num,
|
|
695
|
+
quantity: (_ref11 = (_product$quantity = product.quantity) !== null && _product$quantity !== void 0 ? _product$quantity : product.num) !== null && _ref11 !== void 0 ? _ref11 : authoritativeProduct.quantity,
|
|
676
696
|
product_sku: function () {
|
|
677
697
|
var authoritativeSku = ensureProductSku(authoritativeProduct);
|
|
678
698
|
var productSku = ensureProductSku(product);
|
|
@@ -748,24 +768,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
748
768
|
value: (function () {
|
|
749
769
|
var _syncOtherParamsToSubModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(changedParams) {
|
|
750
770
|
var _this5 = this;
|
|
751
|
-
var
|
|
752
|
-
|
|
771
|
+
var _ref12,
|
|
772
|
+
_ref12$cover,
|
|
753
773
|
cover,
|
|
754
774
|
nextSubModuleOtherParams,
|
|
755
775
|
_args7 = arguments;
|
|
756
776
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
757
777
|
while (1) switch (_context7.prev = _context7.next) {
|
|
758
778
|
case 0:
|
|
759
|
-
|
|
779
|
+
_ref12 = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : {}, _ref12$cover = _ref12.cover, cover = _ref12$cover === void 0 ? false : _ref12$cover;
|
|
760
780
|
nextSubModuleOtherParams = this.buildSubModuleOtherParams();
|
|
761
781
|
_context7.next = 4;
|
|
762
782
|
return Promise.all(Object.entries(this.store).map( /*#__PURE__*/function () {
|
|
763
|
-
var
|
|
764
|
-
var
|
|
783
|
+
var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(_ref13) {
|
|
784
|
+
var _ref15, moduleName, subModule, targetModule;
|
|
765
785
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
766
786
|
while (1) switch (_context6.prev = _context6.next) {
|
|
767
787
|
case 0:
|
|
768
|
-
|
|
788
|
+
_ref15 = _slicedToArray(_ref13, 2), moduleName = _ref15[0], subModule = _ref15[1];
|
|
769
789
|
if (!_this5.reusedSharedSubModuleNames.has(moduleName)) {
|
|
770
790
|
_context6.next = 3;
|
|
771
791
|
break;
|
|
@@ -791,7 +811,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
791
811
|
}, _callee6);
|
|
792
812
|
}));
|
|
793
813
|
return function (_x7) {
|
|
794
|
-
return
|
|
814
|
+
return _ref14.apply(this, arguments);
|
|
795
815
|
};
|
|
796
816
|
}()));
|
|
797
817
|
case 4:
|
|
@@ -1004,7 +1024,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1004
1024
|
key: "loadSalesDetail",
|
|
1005
1025
|
value: (function () {
|
|
1006
1026
|
var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(orderIdOrParams) {
|
|
1007
|
-
var
|
|
1027
|
+
var _ref16, _ref17, _ref18, _ref19, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, remoteRecord, currentTempOrder, record, sales;
|
|
1008
1028
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
1009
1029
|
while (1) switch (_context10.prev = _context10.next) {
|
|
1010
1030
|
case 0:
|
|
@@ -1021,7 +1041,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1021
1041
|
};
|
|
1022
1042
|
externalSaleNumber = params.externalSaleNumber || params.external_sale_number;
|
|
1023
1043
|
preloadedSalesDetail = params.preloadedSalesDetail;
|
|
1024
|
-
lookup = (
|
|
1044
|
+
lookup = (_ref16 = (_ref17 = (_ref18 = (_ref19 = (_params$orderId = params.orderId) !== null && _params$orderId !== void 0 ? _params$orderId : externalSaleNumber) !== null && _ref19 !== void 0 ? _ref19 : params.orderNumber) !== null && _ref18 !== void 0 ? _ref18 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_id) !== null && _ref17 !== void 0 ? _ref17 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.external_sale_number) !== null && _ref16 !== void 0 ? _ref16 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_number;
|
|
1025
1045
|
if (!(!preloadedSalesDetail && (lookup === undefined || lookup === null || lookup === ''))) {
|
|
1026
1046
|
_context10.next = 10;
|
|
1027
1047
|
break;
|
|
@@ -1613,7 +1633,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1613
1633
|
value: function () {
|
|
1614
1634
|
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(params) {
|
|
1615
1635
|
var _this$getOrderIdentit, _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _discountModule$getDi, _discountModule$getOr, _discountModule$getDi2;
|
|
1616
|
-
var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, discountConfigCacheKey, preparedDiscountList, _discountModule$setOr, nextDiscountList, shouldSkipAutoApplyFetchedDiscounts, _summary,
|
|
1636
|
+
var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, discountConfigCacheKey, preparedDiscountList, _discountModule$setOr, nextDiscountList, shouldSkipAutoApplyFetchedDiscounts, _summary, _orderStore$summary, orderTotalAmount, result, _iterator, _step, _product$metadata5, _tempOrder$_extend3, _product$metadata$sou, _product$metadata6, _product$metadata7, _product$original_pri, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice, summary;
|
|
1617
1637
|
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1618
1638
|
while (1) switch (_context17.prev = _context17.next) {
|
|
1619
1639
|
case 0:
|
|
@@ -1707,16 +1727,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1707
1727
|
});
|
|
1708
1728
|
case 40:
|
|
1709
1729
|
if (!rulesModule) {
|
|
1710
|
-
_context17.next =
|
|
1730
|
+
_context17.next = 77;
|
|
1711
1731
|
break;
|
|
1712
1732
|
}
|
|
1713
|
-
holders = ((_tempOrder$holder = tempOrder.holder) === null || _tempOrder$holder === void 0 ? void 0 : _tempOrder$holder.form_record) || [];
|
|
1714
1733
|
orderTotalAmount = Number(((_orderStore$summary = orderStore.summary) === null || _orderStore$summary === void 0 ? void 0 : _orderStore$summary.total_amount) || 0);
|
|
1715
1734
|
console.log('[BaseSales.applyDiscountConfig.calcDiscount]');
|
|
1716
1735
|
result = rulesModule.calcDiscount({
|
|
1717
1736
|
productList: tempOrder.products,
|
|
1718
1737
|
discountList: nextDiscountList,
|
|
1719
|
-
holders:
|
|
1738
|
+
holders: [],
|
|
1720
1739
|
isFormSubject: function isFormSubject(product) {
|
|
1721
1740
|
return resolveIsFormSubject(tempOrder, product);
|
|
1722
1741
|
},
|
|
@@ -1729,22 +1748,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1729
1748
|
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
1730
1749
|
}
|
|
1731
1750
|
_iterator = _createForOfIteratorHelper(tempOrder.products || []);
|
|
1732
|
-
_context17.prev =
|
|
1751
|
+
_context17.prev = 46;
|
|
1733
1752
|
_iterator.s();
|
|
1734
|
-
case
|
|
1753
|
+
case 48:
|
|
1735
1754
|
if ((_step = _iterator.n()).done) {
|
|
1736
|
-
_context17.next =
|
|
1755
|
+
_context17.next = 63;
|
|
1737
1756
|
break;
|
|
1738
1757
|
}
|
|
1739
1758
|
product = _step.value;
|
|
1740
1759
|
productUid = (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number;
|
|
1741
1760
|
runtimeOrigin = productUid ? (_tempOrder$_extend3 = tempOrder._extend) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3.productsByUid) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3[productUid]) === null || _tempOrder$_extend3 === void 0 ? void 0 : _tempOrder$_extend3.origin : undefined;
|
|
1742
1761
|
if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
|
|
1743
|
-
_context17.next =
|
|
1762
|
+
_context17.next = 54;
|
|
1744
1763
|
break;
|
|
1745
1764
|
}
|
|
1746
|
-
return _context17.abrupt("continue",
|
|
1747
|
-
case
|
|
1765
|
+
return _context17.abrupt("continue", 61);
|
|
1766
|
+
case 54:
|
|
1748
1767
|
totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
|
|
1749
1768
|
return sum + Number(pd.amount || 0);
|
|
1750
1769
|
}, 0);
|
|
@@ -1760,58 +1779,58 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1760
1779
|
mainPrice: newMainSellingPrice,
|
|
1761
1780
|
bundle: product.product_bundle
|
|
1762
1781
|
});
|
|
1763
|
-
case
|
|
1764
|
-
_context17.next =
|
|
1782
|
+
case 61:
|
|
1783
|
+
_context17.next = 48;
|
|
1765
1784
|
break;
|
|
1766
|
-
case
|
|
1767
|
-
_context17.next =
|
|
1785
|
+
case 63:
|
|
1786
|
+
_context17.next = 68;
|
|
1768
1787
|
break;
|
|
1769
|
-
case
|
|
1770
|
-
_context17.prev =
|
|
1771
|
-
_context17.t0 = _context17["catch"](
|
|
1788
|
+
case 65:
|
|
1789
|
+
_context17.prev = 65;
|
|
1790
|
+
_context17.t0 = _context17["catch"](46);
|
|
1772
1791
|
_iterator.e(_context17.t0);
|
|
1773
|
-
case
|
|
1774
|
-
_context17.prev =
|
|
1792
|
+
case 68:
|
|
1793
|
+
_context17.prev = 68;
|
|
1775
1794
|
_iterator.f();
|
|
1776
|
-
return _context17.finish(
|
|
1777
|
-
case
|
|
1795
|
+
return _context17.finish(68);
|
|
1796
|
+
case 71:
|
|
1778
1797
|
if (!result.discountList) {
|
|
1779
|
-
_context17.next =
|
|
1798
|
+
_context17.next = 77;
|
|
1780
1799
|
break;
|
|
1781
1800
|
}
|
|
1782
1801
|
nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
|
|
1783
1802
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
1784
|
-
_context17.next =
|
|
1803
|
+
_context17.next = 76;
|
|
1785
1804
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
1786
|
-
case
|
|
1805
|
+
case 76:
|
|
1787
1806
|
tempOrder.discount_list = nextDiscountList.filter(function (discount) {
|
|
1788
1807
|
return discount.isSelected;
|
|
1789
1808
|
});
|
|
1790
|
-
case
|
|
1791
|
-
_context17.next =
|
|
1809
|
+
case 77:
|
|
1810
|
+
_context17.next = 79;
|
|
1792
1811
|
return this.store.order.recalculateSummary({
|
|
1793
1812
|
createIfMissing: true
|
|
1794
1813
|
});
|
|
1795
|
-
case
|
|
1814
|
+
case 79:
|
|
1796
1815
|
summary = _context17.sent;
|
|
1797
1816
|
this.store.order.persistTempOrder();
|
|
1798
|
-
_context17.next =
|
|
1817
|
+
_context17.next = 83;
|
|
1799
1818
|
return this.effectsEmit('onDiscountApplied', {
|
|
1800
1819
|
productList: tempOrder.products || [],
|
|
1801
1820
|
discountList: nextDiscountList,
|
|
1802
1821
|
selectedDiscountList: tempOrder.discount_list || [],
|
|
1803
1822
|
tempOrder: tempOrder
|
|
1804
1823
|
});
|
|
1805
|
-
case
|
|
1824
|
+
case 83:
|
|
1806
1825
|
return _context17.abrupt("return", {
|
|
1807
1826
|
productList: tempOrder.products || [],
|
|
1808
1827
|
discountList: nextDiscountList
|
|
1809
1828
|
});
|
|
1810
|
-
case
|
|
1829
|
+
case 84:
|
|
1811
1830
|
case "end":
|
|
1812
1831
|
return _context17.stop();
|
|
1813
1832
|
}
|
|
1814
|
-
}, _callee17, this, [[
|
|
1833
|
+
}, _callee17, this, [[46, 65, 68, 71]]);
|
|
1815
1834
|
}));
|
|
1816
1835
|
function loadDiscountConfig(_x11) {
|
|
1817
1836
|
return _loadDiscountConfig.apply(this, arguments);
|
|
@@ -1823,7 +1842,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1823
1842
|
value: function () {
|
|
1824
1843
|
var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(cb) {
|
|
1825
1844
|
var _discountModule$getOr2, _discountModule$getDi3;
|
|
1826
|
-
var tempOrder, orderStore, discountModule, rulesModule, originalDiscountList, currentDiscountList, nextDiscountList, result,
|
|
1845
|
+
var tempOrder, orderStore, discountModule, rulesModule, originalDiscountList, currentDiscountList, nextDiscountList, result, _orderStore$summary2, orderTotalAmount;
|
|
1827
1846
|
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1828
1847
|
while (1) switch (_context18.prev = _context18.next) {
|
|
1829
1848
|
case 0:
|
|
@@ -1848,16 +1867,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1848
1867
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
1849
1868
|
case 12:
|
|
1850
1869
|
if (!rulesModule) {
|
|
1851
|
-
_context18.next =
|
|
1870
|
+
_context18.next = 24;
|
|
1852
1871
|
break;
|
|
1853
1872
|
}
|
|
1854
|
-
holders = ((_tempOrder$holder2 = tempOrder.holder) === null || _tempOrder$holder2 === void 0 ? void 0 : _tempOrder$holder2.form_record) || [];
|
|
1855
1873
|
orderTotalAmount = Number(((_orderStore$summary2 = orderStore.summary) === null || _orderStore$summary2 === void 0 ? void 0 : _orderStore$summary2.total_amount) || 0);
|
|
1856
1874
|
console.log('[BaseSales.bestDiscount.calcDiscount]');
|
|
1857
1875
|
result = rulesModule.calcDiscount({
|
|
1858
1876
|
productList: tempOrder.products,
|
|
1859
1877
|
discountList: nextDiscountList,
|
|
1860
|
-
holders:
|
|
1878
|
+
holders: [],
|
|
1861
1879
|
isFormSubject: function isFormSubject(product) {
|
|
1862
1880
|
return resolveIsFormSubject(tempOrder, product);
|
|
1863
1881
|
},
|
|
@@ -1867,14 +1885,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1867
1885
|
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
1868
1886
|
}
|
|
1869
1887
|
if (!result.discountList) {
|
|
1870
|
-
_context18.next =
|
|
1888
|
+
_context18.next = 24;
|
|
1871
1889
|
break;
|
|
1872
1890
|
}
|
|
1873
1891
|
nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
|
|
1874
1892
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
1875
|
-
_context18.next =
|
|
1893
|
+
_context18.next = 22;
|
|
1876
1894
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
1877
|
-
case
|
|
1895
|
+
case 22:
|
|
1878
1896
|
tempOrder.discount_list = nextDiscountList.filter(function (discount) {
|
|
1879
1897
|
return discount.isSelected;
|
|
1880
1898
|
});
|
|
@@ -1882,16 +1900,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1882
1900
|
productList: tempOrder.products,
|
|
1883
1901
|
discountList: nextDiscountList
|
|
1884
1902
|
};
|
|
1885
|
-
case
|
|
1886
|
-
_context18.next =
|
|
1903
|
+
case 24:
|
|
1904
|
+
_context18.next = 26;
|
|
1887
1905
|
return this.store.order.recalculateSummary({
|
|
1888
1906
|
createIfMissing: true
|
|
1889
1907
|
});
|
|
1890
|
-
case
|
|
1908
|
+
case 26:
|
|
1891
1909
|
this.store.order.persistTempOrder();
|
|
1892
1910
|
cb === null || cb === void 0 || cb(result);
|
|
1893
1911
|
return _context18.abrupt("return", result);
|
|
1894
|
-
case
|
|
1912
|
+
case 29:
|
|
1895
1913
|
case "end":
|
|
1896
1914
|
return _context18.stop();
|
|
1897
1915
|
}
|
|
@@ -1908,52 +1926,110 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1908
1926
|
if (!this.store.order) return [];
|
|
1909
1927
|
return this.store.order.getDiscountList();
|
|
1910
1928
|
}
|
|
1929
|
+
|
|
1930
|
+
/** 读取 Discount 模块原始券列表(未经过 bookingTime 等过滤)。 */
|
|
1931
|
+
}, {
|
|
1932
|
+
key: "getOriginalDiscountList",
|
|
1933
|
+
value: function getOriginalDiscountList() {
|
|
1934
|
+
var _store, _discountModule$getOr3;
|
|
1935
|
+
if (!this.store.order) return [];
|
|
1936
|
+
var discountModule = (_store = this.store.order.store) === null || _store === void 0 ? void 0 : _store.discount;
|
|
1937
|
+
return (discountModule === null || discountModule === void 0 || (_discountModule$getOr3 = discountModule.getOriginalDiscountList) === null || _discountModule$getOr3 === void 0 ? void 0 : _discountModule$getOr3.call(discountModule)) || [];
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1940
|
+
/**
|
|
1941
|
+
* 同步写入 Discount 模块的 discountList / originalDiscountList。
|
|
1942
|
+
* 供 Holder 补全等场景在 OS store 层更新 machinecode holder 字段。
|
|
1943
|
+
*/
|
|
1944
|
+
}, {
|
|
1945
|
+
key: "replaceDiscountStoreLists",
|
|
1946
|
+
value: (function () {
|
|
1947
|
+
var _replaceDiscountStoreLists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
|
|
1948
|
+
var _store2;
|
|
1949
|
+
var discountModule;
|
|
1950
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1951
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1952
|
+
case 0:
|
|
1953
|
+
if (this.store.order) {
|
|
1954
|
+
_context19.next = 2;
|
|
1955
|
+
break;
|
|
1956
|
+
}
|
|
1957
|
+
throw new Error('order 模块未初始化');
|
|
1958
|
+
case 2:
|
|
1959
|
+
discountModule = (_store2 = this.store.order.store) === null || _store2 === void 0 ? void 0 : _store2.discount;
|
|
1960
|
+
if (discountModule) {
|
|
1961
|
+
_context19.next = 5;
|
|
1962
|
+
break;
|
|
1963
|
+
}
|
|
1964
|
+
return _context19.abrupt("return");
|
|
1965
|
+
case 5:
|
|
1966
|
+
if (!params.originalDiscountList) {
|
|
1967
|
+
_context19.next = 8;
|
|
1968
|
+
break;
|
|
1969
|
+
}
|
|
1970
|
+
_context19.next = 8;
|
|
1971
|
+
return discountModule.setOriginalDiscountList(params.originalDiscountList);
|
|
1972
|
+
case 8:
|
|
1973
|
+
_context19.next = 10;
|
|
1974
|
+
return discountModule.setDiscountList(params.discountList);
|
|
1975
|
+
case 10:
|
|
1976
|
+
case "end":
|
|
1977
|
+
return _context19.stop();
|
|
1978
|
+
}
|
|
1979
|
+
}, _callee19, this);
|
|
1980
|
+
}));
|
|
1981
|
+
function replaceDiscountStoreLists(_x13) {
|
|
1982
|
+
return _replaceDiscountStoreLists.apply(this, arguments);
|
|
1983
|
+
}
|
|
1984
|
+
return replaceDiscountStoreLists;
|
|
1985
|
+
}())
|
|
1911
1986
|
}, {
|
|
1912
1987
|
key: "scanPromotionCode",
|
|
1913
1988
|
value: function () {
|
|
1914
|
-
var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1989
|
+
var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(code, customerId) {
|
|
1915
1990
|
var raw;
|
|
1916
|
-
return _regeneratorRuntime().wrap(function
|
|
1917
|
-
while (1) switch (
|
|
1991
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1992
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1918
1993
|
case 0:
|
|
1919
|
-
|
|
1994
|
+
_context20.prev = 0;
|
|
1920
1995
|
if (this.store.order) {
|
|
1921
|
-
|
|
1996
|
+
_context20.next = 3;
|
|
1922
1997
|
break;
|
|
1923
1998
|
}
|
|
1924
1999
|
throw new Error('order 模块未初始化');
|
|
1925
2000
|
case 3:
|
|
1926
|
-
|
|
2001
|
+
_context20.next = 5;
|
|
1927
2002
|
return this.store.order.scanCode(code, customerId);
|
|
1928
2003
|
case 5:
|
|
1929
|
-
raw =
|
|
2004
|
+
raw = _context20.sent;
|
|
1930
2005
|
if (!raw.isAvailable) {
|
|
1931
|
-
|
|
2006
|
+
_context20.next = 10;
|
|
1932
2007
|
break;
|
|
1933
2008
|
}
|
|
1934
|
-
|
|
2009
|
+
_context20.next = 9;
|
|
1935
2010
|
return this.store.order.recalculateSummary({
|
|
1936
2011
|
createIfMissing: true
|
|
1937
2012
|
});
|
|
1938
2013
|
case 9:
|
|
1939
2014
|
this.store.order.persistTempOrder();
|
|
1940
2015
|
case 10:
|
|
1941
|
-
return
|
|
2016
|
+
return _context20.abrupt("return", {
|
|
1942
2017
|
isAvailable: raw.isAvailable,
|
|
1943
2018
|
type: raw.type,
|
|
1944
|
-
unavailableReason: raw.unavailableReason
|
|
2019
|
+
unavailableReason: raw.unavailableReason,
|
|
2020
|
+
scannedDiscountList: raw.scannedDiscountList
|
|
1945
2021
|
});
|
|
1946
2022
|
case 13:
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
throw
|
|
2023
|
+
_context20.prev = 13;
|
|
2024
|
+
_context20.t0 = _context20["catch"](0);
|
|
2025
|
+
throw _context20.t0;
|
|
1950
2026
|
case 16:
|
|
1951
2027
|
case "end":
|
|
1952
|
-
return
|
|
2028
|
+
return _context20.stop();
|
|
1953
2029
|
}
|
|
1954
|
-
},
|
|
2030
|
+
}, _callee20, this, [[0, 13]]);
|
|
1955
2031
|
}));
|
|
1956
|
-
function scanPromotionCode(
|
|
2032
|
+
function scanPromotionCode(_x14, _x15) {
|
|
1957
2033
|
return _scanPromotionCode.apply(this, arguments);
|
|
1958
2034
|
}
|
|
1959
2035
|
return scanPromotionCode;
|
|
@@ -1961,14 +2037,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1961
2037
|
}, {
|
|
1962
2038
|
key: "setDiscountSelected",
|
|
1963
2039
|
value: function () {
|
|
1964
|
-
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1965
|
-
var
|
|
1966
|
-
return _regeneratorRuntime().wrap(function
|
|
1967
|
-
while (1) switch (
|
|
2040
|
+
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
|
|
2041
|
+
var list, updated, tempOrder, orderStore, discountModule, rulesModule, nextDiscountList, _orderStore$summary3, orderTotalAmount, result, beforeSelectedIds, _iterator2, _step2, d, selectedResourceIds, filterSelectedDiscountDetails, _iterator3, _step3, _product$metadata8, _tempOrder$_extend4, _product$metadata$sou2, _product$metadata9, _product$metadata10, _product$original_pri2, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
|
|
2042
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
2043
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1968
2044
|
case 0:
|
|
1969
|
-
|
|
2045
|
+
_context21.prev = 0;
|
|
1970
2046
|
if (this.store.order) {
|
|
1971
|
-
|
|
2047
|
+
_context21.next = 3;
|
|
1972
2048
|
break;
|
|
1973
2049
|
}
|
|
1974
2050
|
throw new Error('order 模块未初始化');
|
|
@@ -1985,18 +2061,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1985
2061
|
orderStore = this.store.order.store || {};
|
|
1986
2062
|
discountModule = orderStore.discount;
|
|
1987
2063
|
rulesModule = orderStore.rules;
|
|
1988
|
-
holders = ((_tempOrder$holder3 = tempOrder.holder) === null || _tempOrder$holder3 === void 0 ? void 0 : _tempOrder$holder3.form_record) || [];
|
|
1989
2064
|
nextDiscountList = updated;
|
|
1990
|
-
|
|
2065
|
+
_context21.next = 13;
|
|
1991
2066
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(updated);
|
|
1992
|
-
case
|
|
2067
|
+
case 13:
|
|
1993
2068
|
if (rulesModule) {
|
|
1994
2069
|
orderTotalAmount = Number(((_orderStore$summary3 = orderStore.summary) === null || _orderStore$summary3 === void 0 ? void 0 : _orderStore$summary3.total_amount) || 0);
|
|
1995
2070
|
console.log('[BaseSales.setDiscountSelected.calcDiscount]');
|
|
1996
2071
|
result = rulesModule.calcDiscount({
|
|
1997
2072
|
productList: tempOrder.products,
|
|
1998
2073
|
discountList: updated,
|
|
1999
|
-
holders:
|
|
2074
|
+
holders: [],
|
|
2000
2075
|
isFormSubject: function isFormSubject(product) {
|
|
2001
2076
|
return resolveIsFormSubject(tempOrder, product);
|
|
2002
2077
|
},
|
|
@@ -2050,29 +2125,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2050
2125
|
});
|
|
2051
2126
|
};
|
|
2052
2127
|
_iterator3 = _createForOfIteratorHelper(tempOrder.products);
|
|
2053
|
-
|
|
2128
|
+
_context21.prev = 17;
|
|
2054
2129
|
_iterator3.s();
|
|
2055
|
-
case
|
|
2130
|
+
case 19:
|
|
2056
2131
|
if ((_step3 = _iterator3.n()).done) {
|
|
2057
|
-
|
|
2132
|
+
_context21.next = 36;
|
|
2058
2133
|
break;
|
|
2059
2134
|
}
|
|
2060
2135
|
product = _step3.value;
|
|
2061
2136
|
productUid = (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.unique_identification_number;
|
|
2062
2137
|
runtimeOrigin = productUid ? (_tempOrder$_extend4 = tempOrder._extend) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4.productsByUid) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4[productUid]) === null || _tempOrder$_extend4 === void 0 ? void 0 : _tempOrder$_extend4.origin : undefined;
|
|
2063
2138
|
if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
|
|
2064
|
-
|
|
2139
|
+
_context21.next = 25;
|
|
2065
2140
|
break;
|
|
2066
2141
|
}
|
|
2067
|
-
return
|
|
2068
|
-
case
|
|
2142
|
+
return _context21.abrupt("continue", 34);
|
|
2143
|
+
case 25:
|
|
2069
2144
|
product.discount_list = filterSelectedDiscountDetails(product.discount_list);
|
|
2070
2145
|
if (Array.isArray(product.product_bundle)) {
|
|
2071
2146
|
product.product_bundle = product.product_bundle.map(function (bundle) {
|
|
2072
|
-
var
|
|
2147
|
+
var _ref20, _bundle$original_pric;
|
|
2073
2148
|
var nextBundleDiscountList = filterSelectedDiscountDetails(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list);
|
|
2074
2149
|
var shouldRestoreBundlePrice = nextBundleDiscountList.length === 0;
|
|
2075
|
-
var restoredBundlePrice = (
|
|
2150
|
+
var restoredBundlePrice = (_ref20 = (_bundle$original_pric = bundle === null || bundle === void 0 ? void 0 : bundle.original_price) !== null && _bundle$original_pric !== void 0 ? _bundle$original_pric : bundle === null || bundle === void 0 ? void 0 : bundle.product_price) !== null && _ref20 !== void 0 ? _ref20 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
|
|
2076
2151
|
return _objectSpread(_objectSpread(_objectSpread({}, bundle), shouldRestoreBundlePrice ? {
|
|
2077
2152
|
price: restoredBundlePrice,
|
|
2078
2153
|
bundle_selling_price: restoredBundlePrice
|
|
@@ -2099,33 +2174,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2099
2174
|
mainPrice: newMainSellingPrice,
|
|
2100
2175
|
bundle: product.product_bundle
|
|
2101
2176
|
});
|
|
2102
|
-
case
|
|
2103
|
-
|
|
2177
|
+
case 34:
|
|
2178
|
+
_context21.next = 19;
|
|
2104
2179
|
break;
|
|
2105
|
-
case
|
|
2106
|
-
|
|
2180
|
+
case 36:
|
|
2181
|
+
_context21.next = 41;
|
|
2107
2182
|
break;
|
|
2108
|
-
case
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
_iterator3.e(
|
|
2112
|
-
case
|
|
2113
|
-
|
|
2183
|
+
case 38:
|
|
2184
|
+
_context21.prev = 38;
|
|
2185
|
+
_context21.t0 = _context21["catch"](17);
|
|
2186
|
+
_iterator3.e(_context21.t0);
|
|
2187
|
+
case 41:
|
|
2188
|
+
_context21.prev = 41;
|
|
2114
2189
|
_iterator3.f();
|
|
2115
|
-
return
|
|
2116
|
-
case
|
|
2190
|
+
return _context21.finish(41);
|
|
2191
|
+
case 44:
|
|
2117
2192
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
2118
|
-
|
|
2193
|
+
_context21.next = 47;
|
|
2119
2194
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
2120
|
-
case
|
|
2195
|
+
case 47:
|
|
2121
2196
|
tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
|
|
2122
2197
|
return d.isSelected;
|
|
2123
2198
|
});
|
|
2124
|
-
|
|
2199
|
+
_context21.next = 50;
|
|
2125
2200
|
return this.store.order.recalculateSummary({
|
|
2126
2201
|
createIfMissing: true
|
|
2127
2202
|
});
|
|
2128
|
-
case
|
|
2203
|
+
case 50:
|
|
2129
2204
|
this.store.order.persistTempOrder();
|
|
2130
2205
|
this.effectsEmit('onDiscountApplied', {
|
|
2131
2206
|
productList: tempOrder.products,
|
|
@@ -2133,19 +2208,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2133
2208
|
selectedDiscountList: tempOrder.discount_list,
|
|
2134
2209
|
tempOrder: tempOrder
|
|
2135
2210
|
});
|
|
2136
|
-
|
|
2211
|
+
_context21.next = 57;
|
|
2137
2212
|
break;
|
|
2138
|
-
case
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
throw
|
|
2142
|
-
case
|
|
2213
|
+
case 54:
|
|
2214
|
+
_context21.prev = 54;
|
|
2215
|
+
_context21.t1 = _context21["catch"](0);
|
|
2216
|
+
throw _context21.t1;
|
|
2217
|
+
case 57:
|
|
2143
2218
|
case "end":
|
|
2144
|
-
return
|
|
2219
|
+
return _context21.stop();
|
|
2145
2220
|
}
|
|
2146
|
-
},
|
|
2221
|
+
}, _callee21, this, [[0, 54], [17, 38, 41, 44]]);
|
|
2147
2222
|
}));
|
|
2148
|
-
function setDiscountSelected(
|
|
2223
|
+
function setDiscountSelected(_x16) {
|
|
2149
2224
|
return _setDiscountSelected.apply(this, arguments);
|
|
2150
2225
|
}
|
|
2151
2226
|
return setDiscountSelected;
|
|
@@ -2153,23 +2228,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2153
2228
|
}, {
|
|
2154
2229
|
key: "applyDiscountCalculationResult",
|
|
2155
2230
|
value: function () {
|
|
2156
|
-
var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2231
|
+
var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(result) {
|
|
2157
2232
|
var tempOrder, orderStore, discountModule;
|
|
2158
|
-
return _regeneratorRuntime().wrap(function
|
|
2159
|
-
while (1) switch (
|
|
2233
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
2234
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
2160
2235
|
case 0:
|
|
2161
|
-
|
|
2236
|
+
_context22.prev = 0;
|
|
2162
2237
|
if (this.store.order) {
|
|
2163
|
-
|
|
2238
|
+
_context22.next = 3;
|
|
2164
2239
|
break;
|
|
2165
2240
|
}
|
|
2166
2241
|
throw new Error('order 模块未初始化');
|
|
2167
2242
|
case 3:
|
|
2168
2243
|
if (result) {
|
|
2169
|
-
|
|
2244
|
+
_context22.next = 5;
|
|
2170
2245
|
break;
|
|
2171
2246
|
}
|
|
2172
|
-
return
|
|
2247
|
+
return _context22.abrupt("return");
|
|
2173
2248
|
case 5:
|
|
2174
2249
|
tempOrder = this.store.order.ensureTempOrder();
|
|
2175
2250
|
orderStore = this.store.order.store || {};
|
|
@@ -2178,36 +2253,36 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2178
2253
|
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
2179
2254
|
}
|
|
2180
2255
|
if (!result.discountList) {
|
|
2181
|
-
|
|
2256
|
+
_context22.next = 14;
|
|
2182
2257
|
break;
|
|
2183
2258
|
}
|
|
2184
2259
|
OrderModule.populateSavedAmounts(tempOrder.products, result.discountList);
|
|
2185
|
-
|
|
2260
|
+
_context22.next = 13;
|
|
2186
2261
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(result.discountList);
|
|
2187
2262
|
case 13:
|
|
2188
2263
|
tempOrder.discount_list = result.discountList.filter(function (discount) {
|
|
2189
2264
|
return discount.isSelected;
|
|
2190
2265
|
});
|
|
2191
2266
|
case 14:
|
|
2192
|
-
|
|
2267
|
+
_context22.next = 16;
|
|
2193
2268
|
return this.store.order.recalculateSummary({
|
|
2194
2269
|
createIfMissing: true
|
|
2195
2270
|
});
|
|
2196
2271
|
case 16:
|
|
2197
2272
|
this.store.order.persistTempOrder();
|
|
2198
|
-
|
|
2273
|
+
_context22.next = 22;
|
|
2199
2274
|
break;
|
|
2200
2275
|
case 19:
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
throw
|
|
2276
|
+
_context22.prev = 19;
|
|
2277
|
+
_context22.t0 = _context22["catch"](0);
|
|
2278
|
+
throw _context22.t0;
|
|
2204
2279
|
case 22:
|
|
2205
2280
|
case "end":
|
|
2206
|
-
return
|
|
2281
|
+
return _context22.stop();
|
|
2207
2282
|
}
|
|
2208
|
-
},
|
|
2283
|
+
}, _callee22, this, [[0, 19]]);
|
|
2209
2284
|
}));
|
|
2210
|
-
function applyDiscountCalculationResult(
|
|
2285
|
+
function applyDiscountCalculationResult(_x17) {
|
|
2211
2286
|
return _applyDiscountCalculationResult.apply(this, arguments);
|
|
2212
2287
|
}
|
|
2213
2288
|
return applyDiscountCalculationResult;
|
|
@@ -2215,18 +2290,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2215
2290
|
}, {
|
|
2216
2291
|
key: "submitScanOrder",
|
|
2217
2292
|
value: function () {
|
|
2218
|
-
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2219
|
-
return _regeneratorRuntime().wrap(function
|
|
2220
|
-
while (1) switch (
|
|
2293
|
+
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
|
|
2294
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
2295
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
2221
2296
|
case 0:
|
|
2222
|
-
return
|
|
2297
|
+
return _context23.abrupt("return", this.submitSalesOrder(params));
|
|
2223
2298
|
case 1:
|
|
2224
2299
|
case "end":
|
|
2225
|
-
return
|
|
2300
|
+
return _context23.stop();
|
|
2226
2301
|
}
|
|
2227
|
-
},
|
|
2302
|
+
}, _callee23, this);
|
|
2228
2303
|
}));
|
|
2229
|
-
function submitScanOrder(
|
|
2304
|
+
function submitScanOrder(_x18) {
|
|
2230
2305
|
return _submitScanOrder.apply(this, arguments);
|
|
2231
2306
|
}
|
|
2232
2307
|
return submitScanOrder;
|
|
@@ -2240,14 +2315,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2240
2315
|
}, {
|
|
2241
2316
|
key: "submitSalesOrder",
|
|
2242
2317
|
value: (function () {
|
|
2243
|
-
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2318
|
+
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
|
|
2244
2319
|
var _this$otherParams6, _this$otherParams7, _this$otherParams8, _this$otherParams9;
|
|
2245
2320
|
var inferredPaymentStatus, submitParams;
|
|
2246
|
-
return _regeneratorRuntime().wrap(function
|
|
2247
|
-
while (1) switch (
|
|
2321
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
2322
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
2248
2323
|
case 0:
|
|
2249
2324
|
if (this.store.order) {
|
|
2250
|
-
|
|
2325
|
+
_context24.next = 2;
|
|
2251
2326
|
break;
|
|
2252
2327
|
}
|
|
2253
2328
|
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
@@ -2272,14 +2347,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2272
2347
|
} : {}), (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
|
|
2273
2348
|
enhancePayload: params.enhancePayload
|
|
2274
2349
|
} : {});
|
|
2275
|
-
return
|
|
2350
|
+
return _context24.abrupt("return", this.store.order.submitTempOrder(submitParams));
|
|
2276
2351
|
case 5:
|
|
2277
2352
|
case "end":
|
|
2278
|
-
return
|
|
2353
|
+
return _context24.stop();
|
|
2279
2354
|
}
|
|
2280
|
-
},
|
|
2355
|
+
}, _callee24, this);
|
|
2281
2356
|
}));
|
|
2282
|
-
function submitSalesOrder(
|
|
2357
|
+
function submitSalesOrder(_x19) {
|
|
2283
2358
|
return _submitSalesOrder.apply(this, arguments);
|
|
2284
2359
|
}
|
|
2285
2360
|
return submitSalesOrder;
|
|
@@ -2287,14 +2362,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2287
2362
|
}, {
|
|
2288
2363
|
key: "submitTempOrderAsync",
|
|
2289
2364
|
value: function () {
|
|
2290
|
-
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2365
|
+
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
|
|
2291
2366
|
var _this$otherParams10, _this$otherParams11, _this$otherParams12, _this$otherParams13;
|
|
2292
2367
|
var inferredPaymentStatus, submitParams;
|
|
2293
|
-
return _regeneratorRuntime().wrap(function
|
|
2294
|
-
while (1) switch (
|
|
2368
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
2369
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
2295
2370
|
case 0:
|
|
2296
2371
|
if (this.store.order) {
|
|
2297
|
-
|
|
2372
|
+
_context25.next = 2;
|
|
2298
2373
|
break;
|
|
2299
2374
|
}
|
|
2300
2375
|
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
@@ -2317,14 +2392,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2317
2392
|
} : {}), (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
|
|
2318
2393
|
enhancePayload: params.enhancePayload
|
|
2319
2394
|
} : {});
|
|
2320
|
-
return
|
|
2395
|
+
return _context25.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
|
|
2321
2396
|
case 5:
|
|
2322
2397
|
case "end":
|
|
2323
|
-
return
|
|
2398
|
+
return _context25.stop();
|
|
2324
2399
|
}
|
|
2325
|
-
},
|
|
2400
|
+
}, _callee25, this);
|
|
2326
2401
|
}));
|
|
2327
|
-
function submitTempOrderAsync(
|
|
2402
|
+
function submitTempOrderAsync(_x20) {
|
|
2328
2403
|
return _submitTempOrderAsync.apply(this, arguments);
|
|
2329
2404
|
}
|
|
2330
2405
|
return submitTempOrderAsync;
|
|
@@ -2332,14 +2407,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2332
2407
|
}, {
|
|
2333
2408
|
key: "printLocalOrderReceipt",
|
|
2334
2409
|
value: function () {
|
|
2335
|
-
var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2410
|
+
var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(lookup) {
|
|
2336
2411
|
var _this$otherParams14, _this$otherParams15, _this$otherParams16, _this$otherParams17;
|
|
2337
2412
|
var hasLookup, lookupPayload, context, payload, response, _this$store$order$app, _this$store$order4, _data;
|
|
2338
|
-
return _regeneratorRuntime().wrap(function
|
|
2339
|
-
while (1) switch (
|
|
2413
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
2414
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
2340
2415
|
case 0:
|
|
2341
2416
|
if (this.store.order) {
|
|
2342
|
-
|
|
2417
|
+
_context26.next = 2;
|
|
2343
2418
|
break;
|
|
2344
2419
|
}
|
|
2345
2420
|
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
@@ -2370,28 +2445,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2370
2445
|
channel: context.channel,
|
|
2371
2446
|
type: context.type
|
|
2372
2447
|
});
|
|
2373
|
-
|
|
2448
|
+
_context26.next = 8;
|
|
2374
2449
|
return this.request.post('/local/print-order', payload, {
|
|
2375
2450
|
osServer: true,
|
|
2376
2451
|
customToast: function customToast() {}
|
|
2377
2452
|
});
|
|
2378
2453
|
case 8:
|
|
2379
|
-
response =
|
|
2454
|
+
response = _context26.sent;
|
|
2380
2455
|
if (hasLookup) {
|
|
2381
|
-
|
|
2456
|
+
_context26.next = 12;
|
|
2382
2457
|
break;
|
|
2383
2458
|
}
|
|
2384
|
-
|
|
2459
|
+
_context26.next = 12;
|
|
2385
2460
|
return (_this$store$order$app = (_this$store$order4 = this.store.order).applyLocalPrintOrderNumbers) === null || _this$store$order$app === void 0 ? void 0 : _this$store$order$app.call(_this$store$order4, response === null || response === void 0 || (_data = response.data) === null || _data === void 0 ? void 0 : _data.order);
|
|
2386
2461
|
case 12:
|
|
2387
|
-
return
|
|
2462
|
+
return _context26.abrupt("return", response);
|
|
2388
2463
|
case 13:
|
|
2389
2464
|
case "end":
|
|
2390
|
-
return
|
|
2465
|
+
return _context26.stop();
|
|
2391
2466
|
}
|
|
2392
|
-
},
|
|
2467
|
+
}, _callee26, this);
|
|
2393
2468
|
}));
|
|
2394
|
-
function printLocalOrderReceipt(
|
|
2469
|
+
function printLocalOrderReceipt(_x21) {
|
|
2395
2470
|
return _printLocalOrderReceipt.apply(this, arguments);
|
|
2396
2471
|
}
|
|
2397
2472
|
return printLocalOrderReceipt;
|
|
@@ -2412,19 +2487,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2412
2487
|
}, {
|
|
2413
2488
|
key: "syncPaymentsToOrder",
|
|
2414
2489
|
value: function () {
|
|
2415
|
-
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2416
|
-
var
|
|
2490
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
|
|
2491
|
+
var _ref21, _params$businessCode, _this$otherParams18, _this$otherParams19, _params$channel;
|
|
2417
2492
|
var businessCode, channel, syncParams, syncState, payments, syncResult, latestPayments, amountSnapshot, orderSnapshot, syncPayload;
|
|
2418
|
-
return _regeneratorRuntime().wrap(function
|
|
2419
|
-
while (1) switch (
|
|
2493
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
2494
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
2420
2495
|
case 0:
|
|
2421
2496
|
if (this.store.order) {
|
|
2422
|
-
|
|
2497
|
+
_context27.next = 2;
|
|
2423
2498
|
break;
|
|
2424
2499
|
}
|
|
2425
2500
|
throw new Error('order 模块未初始化');
|
|
2426
2501
|
case 2:
|
|
2427
|
-
businessCode = (
|
|
2502
|
+
businessCode = (_ref21 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.businessCode) !== null && _ref21 !== void 0 ? _ref21 : (_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.business_code;
|
|
2428
2503
|
channel = (_params$channel = params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel();
|
|
2429
2504
|
syncParams = _objectSpread(_objectSpread(_objectSpread({}, params), businessCode !== undefined ? {
|
|
2430
2505
|
businessCode: businessCode
|
|
@@ -2433,14 +2508,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2433
2508
|
} : {});
|
|
2434
2509
|
syncState = this.store.order.getOrderSyncState();
|
|
2435
2510
|
if (!(params.submitWhenPaid && syncState === 'submitting')) {
|
|
2436
|
-
|
|
2511
|
+
_context27.next = 9;
|
|
2437
2512
|
break;
|
|
2438
2513
|
}
|
|
2439
2514
|
this.queueLatestAutoPaymentSync();
|
|
2440
|
-
return
|
|
2515
|
+
return _context27.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
|
|
2441
2516
|
case 9:
|
|
2442
2517
|
payments = params.payments || [];
|
|
2443
|
-
|
|
2518
|
+
_context27.next = 12;
|
|
2444
2519
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncStart, {
|
|
2445
2520
|
payments: payments,
|
|
2446
2521
|
params: syncParams,
|
|
@@ -2448,11 +2523,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2448
2523
|
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
2449
2524
|
});
|
|
2450
2525
|
case 12:
|
|
2451
|
-
|
|
2452
|
-
|
|
2526
|
+
_context27.prev = 12;
|
|
2527
|
+
_context27.next = 15;
|
|
2453
2528
|
return this.store.order.syncPaymentsToOrder(syncParams);
|
|
2454
2529
|
case 15:
|
|
2455
|
-
syncResult =
|
|
2530
|
+
syncResult = _context27.sent;
|
|
2456
2531
|
latestPayments = this.store.order.getOrderPayments();
|
|
2457
2532
|
amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
2458
2533
|
orderSnapshot = this.store.order.getOrderSnapshot();
|
|
@@ -2470,25 +2545,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2470
2545
|
depositAmount: syncResult.depositAmount,
|
|
2471
2546
|
orderExpectedAmount: syncResult.orderExpectedAmount
|
|
2472
2547
|
};
|
|
2473
|
-
|
|
2548
|
+
_context27.next = 22;
|
|
2474
2549
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, syncPayload);
|
|
2475
2550
|
case 22:
|
|
2476
2551
|
if (!(syncResult.isDepositFullyPaid && !syncResult.isOrderFullyPaid)) {
|
|
2477
|
-
|
|
2552
|
+
_context27.next = 25;
|
|
2478
2553
|
break;
|
|
2479
2554
|
}
|
|
2480
|
-
|
|
2555
|
+
_context27.next = 25;
|
|
2481
2556
|
return this.effectsEmit(BaseSalesHookNames.onDepositPaymentSyncEnd, syncPayload);
|
|
2482
2557
|
case 25:
|
|
2483
2558
|
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
2484
|
-
return
|
|
2559
|
+
return _context27.abrupt("return", syncResult);
|
|
2485
2560
|
case 29:
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2561
|
+
_context27.prev = 29;
|
|
2562
|
+
_context27.t0 = _context27["catch"](12);
|
|
2563
|
+
_context27.next = 33;
|
|
2489
2564
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
|
|
2490
2565
|
ok: false,
|
|
2491
|
-
error:
|
|
2566
|
+
error: _context27.t0,
|
|
2492
2567
|
payments: this.store.order.getOrderPayments(),
|
|
2493
2568
|
params: syncParams,
|
|
2494
2569
|
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
@@ -2496,14 +2571,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2496
2571
|
});
|
|
2497
2572
|
case 33:
|
|
2498
2573
|
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
2499
|
-
throw
|
|
2574
|
+
throw _context27.t0;
|
|
2500
2575
|
case 35:
|
|
2501
2576
|
case "end":
|
|
2502
|
-
return
|
|
2577
|
+
return _context27.stop();
|
|
2503
2578
|
}
|
|
2504
|
-
},
|
|
2579
|
+
}, _callee27, this, [[12, 29]]);
|
|
2505
2580
|
}));
|
|
2506
|
-
function syncPaymentsToOrder(
|
|
2581
|
+
function syncPaymentsToOrder(_x22) {
|
|
2507
2582
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
2508
2583
|
}
|
|
2509
2584
|
return syncPaymentsToOrder;
|
|
@@ -2552,46 +2627,46 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2552
2627
|
}, {
|
|
2553
2628
|
key: "flushQueuedAutoPaymentSync",
|
|
2554
2629
|
value: function () {
|
|
2555
|
-
var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2630
|
+
var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
|
|
2556
2631
|
var payments;
|
|
2557
|
-
return _regeneratorRuntime().wrap(function
|
|
2558
|
-
while (1) switch (
|
|
2632
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
2633
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
2559
2634
|
case 0:
|
|
2560
2635
|
if (this.store.order) {
|
|
2561
|
-
|
|
2636
|
+
_context28.next = 2;
|
|
2562
2637
|
break;
|
|
2563
2638
|
}
|
|
2564
|
-
return
|
|
2639
|
+
return _context28.abrupt("return");
|
|
2565
2640
|
case 2:
|
|
2566
2641
|
if (!(!this.queuedAutoPaymentSync || this.autoPaymentSyncFlushing)) {
|
|
2567
|
-
|
|
2642
|
+
_context28.next = 4;
|
|
2568
2643
|
break;
|
|
2569
2644
|
}
|
|
2570
|
-
return
|
|
2645
|
+
return _context28.abrupt("return");
|
|
2571
2646
|
case 4:
|
|
2572
2647
|
if (!(this.store.order.getOrderSyncState() === 'submitting')) {
|
|
2573
|
-
|
|
2648
|
+
_context28.next = 7;
|
|
2574
2649
|
break;
|
|
2575
2650
|
}
|
|
2576
2651
|
this.scheduleQueuedAutoPaymentSyncFlush();
|
|
2577
|
-
return
|
|
2652
|
+
return _context28.abrupt("return");
|
|
2578
2653
|
case 7:
|
|
2579
2654
|
this.autoPaymentSyncFlushing = true;
|
|
2580
|
-
|
|
2655
|
+
_context28.prev = 8;
|
|
2581
2656
|
case 9:
|
|
2582
2657
|
if (!this.queuedAutoPaymentSync) {
|
|
2583
|
-
|
|
2658
|
+
_context28.next = 18;
|
|
2584
2659
|
break;
|
|
2585
2660
|
}
|
|
2586
2661
|
this.queuedAutoPaymentSync = false;
|
|
2587
2662
|
payments = this.store.order.getOrderPayments();
|
|
2588
2663
|
if (payments.length) {
|
|
2589
|
-
|
|
2664
|
+
_context28.next = 14;
|
|
2590
2665
|
break;
|
|
2591
2666
|
}
|
|
2592
|
-
return
|
|
2667
|
+
return _context28.abrupt("continue", 9);
|
|
2593
2668
|
case 14:
|
|
2594
|
-
|
|
2669
|
+
_context28.next = 16;
|
|
2595
2670
|
return this.syncPaymentsToOrder({
|
|
2596
2671
|
payments: payments,
|
|
2597
2672
|
paymentStatus: this.getPaymentStatusForSync(payments),
|
|
@@ -2599,29 +2674,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2599
2674
|
smallTicketDataFlag: 1
|
|
2600
2675
|
});
|
|
2601
2676
|
case 16:
|
|
2602
|
-
|
|
2677
|
+
_context28.next = 9;
|
|
2603
2678
|
break;
|
|
2604
2679
|
case 18:
|
|
2605
|
-
|
|
2680
|
+
_context28.next = 23;
|
|
2606
2681
|
break;
|
|
2607
2682
|
case 20:
|
|
2608
|
-
|
|
2609
|
-
|
|
2683
|
+
_context28.prev = 20;
|
|
2684
|
+
_context28.t0 = _context28["catch"](8);
|
|
2610
2685
|
this.logError('queued auto sync payments failed', {
|
|
2611
|
-
error:
|
|
2686
|
+
error: _context28.t0 instanceof Error ? _context28.t0.message : String(_context28.t0)
|
|
2612
2687
|
});
|
|
2613
2688
|
case 23:
|
|
2614
|
-
|
|
2689
|
+
_context28.prev = 23;
|
|
2615
2690
|
this.autoPaymentSyncFlushing = false;
|
|
2616
2691
|
if (this.queuedAutoPaymentSync) {
|
|
2617
2692
|
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
2618
2693
|
}
|
|
2619
|
-
return
|
|
2694
|
+
return _context28.finish(23);
|
|
2620
2695
|
case 27:
|
|
2621
2696
|
case "end":
|
|
2622
|
-
return
|
|
2697
|
+
return _context28.stop();
|
|
2623
2698
|
}
|
|
2624
|
-
},
|
|
2699
|
+
}, _callee28, this, [[8, 20, 23, 27]]);
|
|
2625
2700
|
}));
|
|
2626
2701
|
function flushQueuedAutoPaymentSync() {
|
|
2627
2702
|
return _flushQueuedAutoPaymentSync.apply(this, arguments);
|
|
@@ -2634,7 +2709,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2634
2709
|
var _this$otherParams20,
|
|
2635
2710
|
_paymentRecord$paymen,
|
|
2636
2711
|
_paymentRecord$create,
|
|
2637
|
-
|
|
2712
|
+
_ref22,
|
|
2638
2713
|
_paymentRecord$origin,
|
|
2639
2714
|
_this11 = this;
|
|
2640
2715
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
@@ -2658,7 +2733,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2658
2733
|
var paymentTime = (_paymentRecord$paymen = paymentRecord.payment_time) !== null && _paymentRecord$paymen !== void 0 ? _paymentRecord$paymen : paymentTimestamp;
|
|
2659
2734
|
var createdAt = (_paymentRecord$create = paymentRecord.created_at) !== null && _paymentRecord$create !== void 0 ? _paymentRecord$create : paymentTimestamp;
|
|
2660
2735
|
var serviceCharge = paymentRecord.service_charge && _typeof(paymentRecord.service_charge) === 'object' ? paymentRecord.service_charge : null;
|
|
2661
|
-
var calculatedServiceFee = serviceCharge ? new Decimal((
|
|
2736
|
+
var calculatedServiceFee = serviceCharge ? new Decimal((_ref22 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref22 !== void 0 ? _ref22 : 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
|
|
2662
2737
|
var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread({}, paymentRecord), calculatedServiceFee !== undefined ? {
|
|
2663
2738
|
service_fee: calculatedServiceFee
|
|
2664
2739
|
} : {}), {}, {
|
|
@@ -2786,20 +2861,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2786
2861
|
}, {
|
|
2787
2862
|
key: "initWalletData",
|
|
2788
2863
|
value: function () {
|
|
2789
|
-
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2790
|
-
var _params$order_wait_pa,
|
|
2864
|
+
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
|
|
2865
|
+
var _params$order_wait_pa, _ref23, _tempOrder$is_price_i;
|
|
2791
2866
|
var snapshot, tempOrder, amount, walletBusinessData, result;
|
|
2792
|
-
return _regeneratorRuntime().wrap(function
|
|
2793
|
-
while (1) switch (
|
|
2867
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
2868
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
2794
2869
|
case 0:
|
|
2795
2870
|
if (this.store.order) {
|
|
2796
|
-
|
|
2871
|
+
_context29.next = 2;
|
|
2797
2872
|
break;
|
|
2798
2873
|
}
|
|
2799
2874
|
throw new Error('order 模块未初始化');
|
|
2800
2875
|
case 2:
|
|
2801
2876
|
if (this.store.payment) {
|
|
2802
|
-
|
|
2877
|
+
_context29.next = 4;
|
|
2803
2878
|
break;
|
|
2804
2879
|
}
|
|
2805
2880
|
throw new Error('payment 模块未初始化');
|
|
@@ -2808,10 +2883,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2808
2883
|
tempOrder = snapshot === null || snapshot === void 0 ? void 0 : snapshot.tempOrder;
|
|
2809
2884
|
amount = snapshot === null || snapshot === void 0 ? void 0 : snapshot.amount;
|
|
2810
2885
|
if (!(!tempOrder || !amount)) {
|
|
2811
|
-
|
|
2886
|
+
_context29.next = 9;
|
|
2812
2887
|
break;
|
|
2813
2888
|
}
|
|
2814
|
-
return
|
|
2889
|
+
return _context29.abrupt("return", {
|
|
2815
2890
|
walletRecommendList: [],
|
|
2816
2891
|
userIdentificationCodes: [],
|
|
2817
2892
|
transformList: [],
|
|
@@ -2830,15 +2905,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2830
2905
|
},
|
|
2831
2906
|
products: this.getWalletProductList(),
|
|
2832
2907
|
order_wait_pay_amount: (_params$order_wait_pa = params === null || params === void 0 ? void 0 : params.order_wait_pay_amount) !== null && _params$order_wait_pa !== void 0 ? _params$order_wait_pa : Number(amount.amountGap || 0),
|
|
2833
|
-
is_price_include_tax: (
|
|
2908
|
+
is_price_include_tax: (_ref23 = (_tempOrder$is_price_i = tempOrder.is_price_include_tax) !== null && _tempOrder$is_price_i !== void 0 ? _tempOrder$is_price_i : this.otherParams.is_price_include_tax) !== null && _ref23 !== void 0 ? _ref23 : 1
|
|
2834
2909
|
}, snapshot.identity.orderId ? {
|
|
2835
2910
|
payment_order_id: String(snapshot.identity.orderId)
|
|
2836
2911
|
} : {});
|
|
2837
|
-
|
|
2912
|
+
_context29.next = 12;
|
|
2838
2913
|
return this.store.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
|
|
2839
2914
|
case 12:
|
|
2840
|
-
result =
|
|
2841
|
-
|
|
2915
|
+
result = _context29.sent;
|
|
2916
|
+
_context29.next = 15;
|
|
2842
2917
|
return this.core.effects.emit("".concat(this.name, ":onWalletDataInitialized"), {
|
|
2843
2918
|
orderId: snapshot.identity.orderId,
|
|
2844
2919
|
customerId: walletBusinessData.customer_id,
|
|
@@ -2850,14 +2925,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2850
2925
|
timestamp: Date.now()
|
|
2851
2926
|
});
|
|
2852
2927
|
case 15:
|
|
2853
|
-
return
|
|
2928
|
+
return _context29.abrupt("return", result);
|
|
2854
2929
|
case 16:
|
|
2855
2930
|
case "end":
|
|
2856
|
-
return
|
|
2931
|
+
return _context29.stop();
|
|
2857
2932
|
}
|
|
2858
|
-
},
|
|
2933
|
+
}, _callee29, this);
|
|
2859
2934
|
}));
|
|
2860
|
-
function initWalletData(
|
|
2935
|
+
function initWalletData(_x23) {
|
|
2861
2936
|
return _initWalletData.apply(this, arguments);
|
|
2862
2937
|
}
|
|
2863
2938
|
return initWalletData;
|
|
@@ -2884,35 +2959,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2884
2959
|
}, {
|
|
2885
2960
|
key: "getPaymentMethodsAsync",
|
|
2886
2961
|
value: (function () {
|
|
2887
|
-
var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2962
|
+
var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
|
|
2888
2963
|
var response, paymentMethods;
|
|
2889
|
-
return _regeneratorRuntime().wrap(function
|
|
2890
|
-
while (1) switch (
|
|
2964
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
2965
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
2891
2966
|
case 0:
|
|
2892
|
-
|
|
2893
|
-
|
|
2967
|
+
_context30.prev = 0;
|
|
2968
|
+
_context30.next = 3;
|
|
2894
2969
|
return this.request.get('/pay/custom-payment/all', {
|
|
2895
2970
|
filterPaymentMethods: true
|
|
2896
2971
|
}, {
|
|
2897
2972
|
osServer: true
|
|
2898
2973
|
});
|
|
2899
2974
|
case 3:
|
|
2900
|
-
response =
|
|
2975
|
+
response = _context30.sent;
|
|
2901
2976
|
paymentMethods = (response === null || response === void 0 ? void 0 : response.data) || [];
|
|
2902
2977
|
this.paymentMethodsCache = Array.isArray(paymentMethods) ? _toConsumableArray(paymentMethods) : [];
|
|
2903
|
-
return
|
|
2978
|
+
return _context30.abrupt("return", this.getPaymentMethods());
|
|
2904
2979
|
case 9:
|
|
2905
|
-
|
|
2906
|
-
|
|
2980
|
+
_context30.prev = 9;
|
|
2981
|
+
_context30.t0 = _context30["catch"](0);
|
|
2907
2982
|
this.logWarning('getPaymentMethodsAsync: 获取支付方式列表失败,使用缓存列表', {
|
|
2908
|
-
error:
|
|
2983
|
+
error: _context30.t0 instanceof Error ? _context30.t0.message : String(_context30.t0)
|
|
2909
2984
|
});
|
|
2910
|
-
return
|
|
2985
|
+
return _context30.abrupt("return", this.getPaymentMethods());
|
|
2911
2986
|
case 13:
|
|
2912
2987
|
case "end":
|
|
2913
|
-
return
|
|
2988
|
+
return _context30.stop();
|
|
2914
2989
|
}
|
|
2915
|
-
},
|
|
2990
|
+
}, _callee30, this, [[0, 9]]);
|
|
2916
2991
|
}));
|
|
2917
2992
|
function getPaymentMethodsAsync() {
|
|
2918
2993
|
return _getPaymentMethodsAsync.apply(this, arguments);
|
|
@@ -2960,49 +3035,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2960
3035
|
}, {
|
|
2961
3036
|
key: "sendCustomerPayLink",
|
|
2962
3037
|
value: (function () {
|
|
2963
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2964
|
-
var orderIds,
|
|
2965
|
-
return _regeneratorRuntime().wrap(function
|
|
2966
|
-
while (1) switch (
|
|
3038
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
|
|
3039
|
+
var orderIds, _ref24, _ref25, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
|
|
3040
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
3041
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
2967
3042
|
case 0:
|
|
2968
3043
|
if (this.store.order) {
|
|
2969
|
-
|
|
3044
|
+
_context31.next = 2;
|
|
2970
3045
|
break;
|
|
2971
3046
|
}
|
|
2972
3047
|
throw new Error('order 模块未初始化');
|
|
2973
3048
|
case 2:
|
|
2974
3049
|
orderIds = params.order_ids || params.orderIds || [];
|
|
2975
3050
|
if (!(!orderIds.length || params.submitBeforeSend)) {
|
|
2976
|
-
|
|
3051
|
+
_context31.next = 11;
|
|
2977
3052
|
break;
|
|
2978
3053
|
}
|
|
2979
|
-
|
|
3054
|
+
_context31.next = 6;
|
|
2980
3055
|
return this.submitSalesOrder({
|
|
2981
3056
|
smallTicketDataFlag: 1
|
|
2982
3057
|
});
|
|
2983
3058
|
case 6:
|
|
2984
|
-
submitResult =
|
|
2985
|
-
orderId = (
|
|
3059
|
+
submitResult = _context31.sent;
|
|
3060
|
+
orderId = (_ref24 = (_ref25 = (_submitResult$data$or = submitResult === null || submitResult === void 0 || (_submitResult$data = submitResult.data) === null || _submitResult$data === void 0 ? void 0 : _submitResult$data.order_id) !== null && _submitResult$data$or !== void 0 ? _submitResult$data$or : submitResult === null || submitResult === void 0 ? void 0 : submitResult.order_id) !== null && _ref25 !== void 0 ? _ref25 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref24 !== void 0 ? _ref24 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
|
|
2986
3061
|
if (orderId) {
|
|
2987
|
-
|
|
3062
|
+
_context31.next = 10;
|
|
2988
3063
|
break;
|
|
2989
3064
|
}
|
|
2990
3065
|
throw new Error('本地订单提交云端失败,无法发送支付链接');
|
|
2991
3066
|
case 10:
|
|
2992
3067
|
orderIds = [orderId];
|
|
2993
3068
|
case 11:
|
|
2994
|
-
return
|
|
3069
|
+
return _context31.abrupt("return", this.store.order.sendCustomerPayLink({
|
|
2995
3070
|
emails: params.emails,
|
|
2996
3071
|
notify_action: params.notify_action,
|
|
2997
3072
|
order_ids: orderIds
|
|
2998
3073
|
}));
|
|
2999
3074
|
case 12:
|
|
3000
3075
|
case "end":
|
|
3001
|
-
return
|
|
3076
|
+
return _context31.stop();
|
|
3002
3077
|
}
|
|
3003
|
-
},
|
|
3078
|
+
}, _callee31, this);
|
|
3004
3079
|
}));
|
|
3005
|
-
function sendCustomerPayLink(
|
|
3080
|
+
function sendCustomerPayLink(_x24) {
|
|
3006
3081
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
3007
3082
|
}
|
|
3008
3083
|
return sendCustomerPayLink;
|
|
@@ -3015,27 +3090,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3015
3090
|
}, {
|
|
3016
3091
|
key: "calculateProductBookingPrice",
|
|
3017
3092
|
value: function () {
|
|
3018
|
-
var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3093
|
+
var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
|
|
3019
3094
|
var _params$customer_id;
|
|
3020
3095
|
var quotation, customerId, authoritativeProduct, product;
|
|
3021
|
-
return _regeneratorRuntime().wrap(function
|
|
3022
|
-
while (1) switch (
|
|
3096
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
3097
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
3023
3098
|
case 0:
|
|
3024
3099
|
quotation = this.store.quotation;
|
|
3025
3100
|
customerId = (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : this.getCurrentOrderCustomerId();
|
|
3026
|
-
|
|
3101
|
+
_context32.next = 4;
|
|
3027
3102
|
return this.loadProductForPriceQuery(params, customerId);
|
|
3028
3103
|
case 4:
|
|
3029
|
-
authoritativeProduct =
|
|
3104
|
+
authoritativeProduct = _context32.sent;
|
|
3030
3105
|
product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
|
|
3031
|
-
|
|
3106
|
+
_context32.next = 8;
|
|
3032
3107
|
return this.loadQuotationForPriceQuery({
|
|
3033
3108
|
quotation: quotation,
|
|
3034
3109
|
customer_id: customerId,
|
|
3035
3110
|
channel: params.channel
|
|
3036
3111
|
});
|
|
3037
3112
|
case 8:
|
|
3038
|
-
return
|
|
3113
|
+
return _context32.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
|
|
3039
3114
|
product: product,
|
|
3040
3115
|
fallback_price: authoritativeProduct ? undefined : params.fallback_price,
|
|
3041
3116
|
customer_id: customerId,
|
|
@@ -3043,11 +3118,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3043
3118
|
})));
|
|
3044
3119
|
case 9:
|
|
3045
3120
|
case "end":
|
|
3046
|
-
return
|
|
3121
|
+
return _context32.stop();
|
|
3047
3122
|
}
|
|
3048
|
-
},
|
|
3123
|
+
}, _callee32, this);
|
|
3049
3124
|
}));
|
|
3050
|
-
function calculateProductBookingPrice(
|
|
3125
|
+
function calculateProductBookingPrice(_x25) {
|
|
3051
3126
|
return _calculateProductBookingPrice.apply(this, arguments);
|
|
3052
3127
|
}
|
|
3053
3128
|
return calculateProductBookingPrice;
|
|
@@ -3117,20 +3192,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3117
3192
|
}, {
|
|
3118
3193
|
key: "calculateProductBookingPrices",
|
|
3119
3194
|
value: function () {
|
|
3120
|
-
var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3195
|
+
var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(paramsList) {
|
|
3121
3196
|
var _paramsList$0$custome,
|
|
3122
3197
|
_paramsList$,
|
|
3123
3198
|
_this13 = this,
|
|
3124
3199
|
_paramsList$2;
|
|
3125
3200
|
var quotation, customerId, productMapsByGroup, groups;
|
|
3126
|
-
return _regeneratorRuntime().wrap(function
|
|
3127
|
-
while (1) switch (
|
|
3201
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
3202
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
3128
3203
|
case 0:
|
|
3129
3204
|
if (paramsList.length) {
|
|
3130
|
-
|
|
3205
|
+
_context34.next = 2;
|
|
3131
3206
|
break;
|
|
3132
3207
|
}
|
|
3133
|
-
return
|
|
3208
|
+
return _context34.abrupt("return", []);
|
|
3134
3209
|
case 2:
|
|
3135
3210
|
quotation = this.store.quotation;
|
|
3136
3211
|
customerId = (_paramsList$0$custome = (_paramsList$ = paramsList[0]) === null || _paramsList$ === void 0 ? void 0 : _paramsList$.customer_id) !== null && _paramsList$0$custome !== void 0 ? _paramsList$0$custome : this.getCurrentOrderCustomerId();
|
|
@@ -3152,15 +3227,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3152
3227
|
group.ids.add(productId);
|
|
3153
3228
|
groups.set(groupKey, group);
|
|
3154
3229
|
});
|
|
3155
|
-
|
|
3230
|
+
_context34.next = 9;
|
|
3156
3231
|
return Promise.all(Array.from(groups.entries()).map( /*#__PURE__*/function () {
|
|
3157
|
-
var
|
|
3158
|
-
var
|
|
3159
|
-
return _regeneratorRuntime().wrap(function
|
|
3160
|
-
while (1) switch (
|
|
3232
|
+
var _ref27 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(_ref26) {
|
|
3233
|
+
var _ref28, groupKey, group, productsById;
|
|
3234
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
3235
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
3161
3236
|
case 0:
|
|
3162
|
-
|
|
3163
|
-
|
|
3237
|
+
_ref28 = _slicedToArray(_ref26, 2), groupKey = _ref28[0], group = _ref28[1];
|
|
3238
|
+
_context33.next = 3;
|
|
3164
3239
|
return _this13.loadProductsForPriceQuery({
|
|
3165
3240
|
ids: Array.from(group.ids),
|
|
3166
3241
|
schedule: group.schedule,
|
|
@@ -3168,27 +3243,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3168
3243
|
channel: group.channel
|
|
3169
3244
|
});
|
|
3170
3245
|
case 3:
|
|
3171
|
-
productsById =
|
|
3246
|
+
productsById = _context33.sent;
|
|
3172
3247
|
productMapsByGroup.set(groupKey, productsById);
|
|
3173
3248
|
case 5:
|
|
3174
3249
|
case "end":
|
|
3175
|
-
return
|
|
3250
|
+
return _context33.stop();
|
|
3176
3251
|
}
|
|
3177
|
-
},
|
|
3252
|
+
}, _callee33);
|
|
3178
3253
|
}));
|
|
3179
|
-
return function (
|
|
3180
|
-
return
|
|
3254
|
+
return function (_x27) {
|
|
3255
|
+
return _ref27.apply(this, arguments);
|
|
3181
3256
|
};
|
|
3182
3257
|
}()));
|
|
3183
3258
|
case 9:
|
|
3184
|
-
|
|
3259
|
+
_context34.next = 11;
|
|
3185
3260
|
return this.loadQuotationForPriceQuery({
|
|
3186
3261
|
quotation: quotation,
|
|
3187
3262
|
customer_id: customerId,
|
|
3188
3263
|
channel: (_paramsList$2 = paramsList[0]) === null || _paramsList$2 === void 0 ? void 0 : _paramsList$2.channel
|
|
3189
3264
|
});
|
|
3190
3265
|
case 11:
|
|
3191
|
-
return
|
|
3266
|
+
return _context34.abrupt("return", paramsList.map(function (params) {
|
|
3192
3267
|
var _this13$otherParams2, _productMapsByGroup$g;
|
|
3193
3268
|
var productInput = params.product || {};
|
|
3194
3269
|
var productId = _this13.getPriceQueryProductId(productInput);
|
|
@@ -3206,11 +3281,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3206
3281
|
}));
|
|
3207
3282
|
case 12:
|
|
3208
3283
|
case "end":
|
|
3209
|
-
return
|
|
3284
|
+
return _context34.stop();
|
|
3210
3285
|
}
|
|
3211
|
-
},
|
|
3286
|
+
}, _callee34, this);
|
|
3212
3287
|
}));
|
|
3213
|
-
function calculateProductBookingPrices(
|
|
3288
|
+
function calculateProductBookingPrices(_x26) {
|
|
3214
3289
|
return _calculateProductBookingPrices.apply(this, arguments);
|
|
3215
3290
|
}
|
|
3216
3291
|
return calculateProductBookingPrices;
|
|
@@ -3218,42 +3293,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3218
3293
|
}, {
|
|
3219
3294
|
key: "addProductToOrder",
|
|
3220
3295
|
value: function () {
|
|
3221
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3222
|
-
var products;
|
|
3223
|
-
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
3224
|
-
while (1) switch (_context34.prev = _context34.next) {
|
|
3225
|
-
case 0:
|
|
3226
|
-
_context34.prev = 0;
|
|
3227
|
-
if (this.store.order) {
|
|
3228
|
-
_context34.next = 3;
|
|
3229
|
-
break;
|
|
3230
|
-
}
|
|
3231
|
-
throw new Error('order 模块未初始化');
|
|
3232
|
-
case 3:
|
|
3233
|
-
_context34.next = 5;
|
|
3234
|
-
return this.store.order.addProductToOrder(product, booking);
|
|
3235
|
-
case 5:
|
|
3236
|
-
products = _context34.sent;
|
|
3237
|
-
return _context34.abrupt("return", products);
|
|
3238
|
-
case 9:
|
|
3239
|
-
_context34.prev = 9;
|
|
3240
|
-
_context34.t0 = _context34["catch"](0);
|
|
3241
|
-
throw _context34.t0;
|
|
3242
|
-
case 12:
|
|
3243
|
-
case "end":
|
|
3244
|
-
return _context34.stop();
|
|
3245
|
-
}
|
|
3246
|
-
}, _callee34, this, [[0, 9]]);
|
|
3247
|
-
}));
|
|
3248
|
-
function addProductToOrder(_x27, _x28) {
|
|
3249
|
-
return _addProductToOrder.apply(this, arguments);
|
|
3250
|
-
}
|
|
3251
|
-
return addProductToOrder;
|
|
3252
|
-
}()
|
|
3253
|
-
}, {
|
|
3254
|
-
key: "updateOrderProduct",
|
|
3255
|
-
value: function () {
|
|
3256
|
-
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
|
|
3296
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(product, booking) {
|
|
3257
3297
|
var products;
|
|
3258
3298
|
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
3259
3299
|
while (1) switch (_context35.prev = _context35.next) {
|
|
@@ -3266,7 +3306,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3266
3306
|
throw new Error('order 模块未初始化');
|
|
3267
3307
|
case 3:
|
|
3268
3308
|
_context35.next = 5;
|
|
3269
|
-
return this.store.order.
|
|
3309
|
+
return this.store.order.addProductToOrder(product, booking);
|
|
3270
3310
|
case 5:
|
|
3271
3311
|
products = _context35.sent;
|
|
3272
3312
|
return _context35.abrupt("return", products);
|
|
@@ -3280,15 +3320,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3280
3320
|
}
|
|
3281
3321
|
}, _callee35, this, [[0, 9]]);
|
|
3282
3322
|
}));
|
|
3283
|
-
function
|
|
3284
|
-
return
|
|
3323
|
+
function addProductToOrder(_x28, _x29) {
|
|
3324
|
+
return _addProductToOrder.apply(this, arguments);
|
|
3285
3325
|
}
|
|
3286
|
-
return
|
|
3326
|
+
return addProductToOrder;
|
|
3287
3327
|
}()
|
|
3288
3328
|
}, {
|
|
3289
|
-
key: "
|
|
3329
|
+
key: "updateOrderProduct",
|
|
3290
3330
|
value: function () {
|
|
3291
|
-
var
|
|
3331
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
|
|
3292
3332
|
var products;
|
|
3293
3333
|
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
3294
3334
|
while (1) switch (_context36.prev = _context36.next) {
|
|
@@ -3301,7 +3341,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3301
3341
|
throw new Error('order 模块未初始化');
|
|
3302
3342
|
case 3:
|
|
3303
3343
|
_context36.next = 5;
|
|
3304
|
-
return this.store.order.
|
|
3344
|
+
return this.store.order.updateOrderProduct(params);
|
|
3305
3345
|
case 5:
|
|
3306
3346
|
products = _context36.sent;
|
|
3307
3347
|
return _context36.abrupt("return", products);
|
|
@@ -3315,15 +3355,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3315
3355
|
}
|
|
3316
3356
|
}, _callee36, this, [[0, 9]]);
|
|
3317
3357
|
}));
|
|
3318
|
-
function
|
|
3319
|
-
return
|
|
3358
|
+
function updateOrderProduct(_x30) {
|
|
3359
|
+
return _updateOrderProduct.apply(this, arguments);
|
|
3320
3360
|
}
|
|
3321
|
-
return
|
|
3361
|
+
return updateOrderProduct;
|
|
3322
3362
|
}()
|
|
3323
3363
|
}, {
|
|
3324
|
-
key: "
|
|
3364
|
+
key: "updateOrderProducts",
|
|
3325
3365
|
value: function () {
|
|
3326
|
-
var
|
|
3366
|
+
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(paramsList) {
|
|
3327
3367
|
var products;
|
|
3328
3368
|
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
3329
3369
|
while (1) switch (_context37.prev = _context37.next) {
|
|
@@ -3336,7 +3376,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3336
3376
|
throw new Error('order 模块未初始化');
|
|
3337
3377
|
case 3:
|
|
3338
3378
|
_context37.next = 5;
|
|
3339
|
-
return this.store.order.
|
|
3379
|
+
return this.store.order.updateOrderProducts(paramsList);
|
|
3340
3380
|
case 5:
|
|
3341
3381
|
products = _context37.sent;
|
|
3342
3382
|
return _context37.abrupt("return", products);
|
|
@@ -3350,7 +3390,42 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3350
3390
|
}
|
|
3351
3391
|
}, _callee37, this, [[0, 9]]);
|
|
3352
3392
|
}));
|
|
3353
|
-
function
|
|
3393
|
+
function updateOrderProducts(_x31) {
|
|
3394
|
+
return _updateOrderProducts.apply(this, arguments);
|
|
3395
|
+
}
|
|
3396
|
+
return updateOrderProducts;
|
|
3397
|
+
}()
|
|
3398
|
+
}, {
|
|
3399
|
+
key: "updateOrderProductQuantity",
|
|
3400
|
+
value: function () {
|
|
3401
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
|
|
3402
|
+
var products;
|
|
3403
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
3404
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
3405
|
+
case 0:
|
|
3406
|
+
_context38.prev = 0;
|
|
3407
|
+
if (this.store.order) {
|
|
3408
|
+
_context38.next = 3;
|
|
3409
|
+
break;
|
|
3410
|
+
}
|
|
3411
|
+
throw new Error('order 模块未初始化');
|
|
3412
|
+
case 3:
|
|
3413
|
+
_context38.next = 5;
|
|
3414
|
+
return this.store.order.updateOrderProductQuantity(params);
|
|
3415
|
+
case 5:
|
|
3416
|
+
products = _context38.sent;
|
|
3417
|
+
return _context38.abrupt("return", products);
|
|
3418
|
+
case 9:
|
|
3419
|
+
_context38.prev = 9;
|
|
3420
|
+
_context38.t0 = _context38["catch"](0);
|
|
3421
|
+
throw _context38.t0;
|
|
3422
|
+
case 12:
|
|
3423
|
+
case "end":
|
|
3424
|
+
return _context38.stop();
|
|
3425
|
+
}
|
|
3426
|
+
}, _callee38, this, [[0, 9]]);
|
|
3427
|
+
}));
|
|
3428
|
+
function updateOrderProductQuantity(_x32) {
|
|
3354
3429
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
3355
3430
|
}
|
|
3356
3431
|
return updateOrderProductQuantity;
|
|
@@ -3373,12 +3448,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3373
3448
|
}, {
|
|
3374
3449
|
key: "setOrderProductLineNote",
|
|
3375
3450
|
value: (function () {
|
|
3376
|
-
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3451
|
+
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(identity, note) {
|
|
3377
3452
|
var params, products;
|
|
3378
|
-
return _regeneratorRuntime().wrap(function
|
|
3379
|
-
while (1) switch (
|
|
3453
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
3454
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
3380
3455
|
case 0:
|
|
3381
|
-
|
|
3456
|
+
_context39.prev = 0;
|
|
3382
3457
|
params = {
|
|
3383
3458
|
product_id: identity.product_id,
|
|
3384
3459
|
product_variant_id: identity.product_variant_id,
|
|
@@ -3393,22 +3468,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3393
3468
|
params.product_sku = identity.product_sku;
|
|
3394
3469
|
}
|
|
3395
3470
|
if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
|
|
3396
|
-
|
|
3471
|
+
_context39.next = 7;
|
|
3397
3472
|
return this.updateOrderProduct(params);
|
|
3398
3473
|
case 7:
|
|
3399
|
-
products =
|
|
3400
|
-
return
|
|
3474
|
+
products = _context39.sent;
|
|
3475
|
+
return _context39.abrupt("return", products);
|
|
3401
3476
|
case 11:
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
throw
|
|
3477
|
+
_context39.prev = 11;
|
|
3478
|
+
_context39.t0 = _context39["catch"](0);
|
|
3479
|
+
throw _context39.t0;
|
|
3405
3480
|
case 14:
|
|
3406
3481
|
case "end":
|
|
3407
|
-
return
|
|
3482
|
+
return _context39.stop();
|
|
3408
3483
|
}
|
|
3409
|
-
},
|
|
3484
|
+
}, _callee39, this, [[0, 11]]);
|
|
3410
3485
|
}));
|
|
3411
|
-
function setOrderProductLineNote(
|
|
3486
|
+
function setOrderProductLineNote(_x33, _x34) {
|
|
3412
3487
|
return _setOrderProductLineNote.apply(this, arguments);
|
|
3413
3488
|
}
|
|
3414
3489
|
return setOrderProductLineNote;
|
|
@@ -3423,32 +3498,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3423
3498
|
}, {
|
|
3424
3499
|
key: "removeProductsFromOrder",
|
|
3425
3500
|
value: (function () {
|
|
3426
|
-
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3427
|
-
return _regeneratorRuntime().wrap(function
|
|
3428
|
-
while (1) switch (
|
|
3501
|
+
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(identities) {
|
|
3502
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
3503
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
3429
3504
|
case 0:
|
|
3430
|
-
|
|
3505
|
+
_context40.prev = 0;
|
|
3431
3506
|
if (this.store.order) {
|
|
3432
|
-
|
|
3507
|
+
_context40.next = 3;
|
|
3433
3508
|
break;
|
|
3434
3509
|
}
|
|
3435
3510
|
throw new Error('order 模块未初始化');
|
|
3436
3511
|
case 3:
|
|
3437
|
-
|
|
3512
|
+
_context40.next = 5;
|
|
3438
3513
|
return this.store.order.removeProductsFromOrder(identities);
|
|
3439
3514
|
case 5:
|
|
3440
|
-
return
|
|
3515
|
+
return _context40.abrupt("return", _context40.sent);
|
|
3441
3516
|
case 8:
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
throw
|
|
3517
|
+
_context40.prev = 8;
|
|
3518
|
+
_context40.t0 = _context40["catch"](0);
|
|
3519
|
+
throw _context40.t0;
|
|
3445
3520
|
case 11:
|
|
3446
3521
|
case "end":
|
|
3447
|
-
return
|
|
3522
|
+
return _context40.stop();
|
|
3448
3523
|
}
|
|
3449
|
-
},
|
|
3524
|
+
}, _callee40, this, [[0, 8]]);
|
|
3450
3525
|
}));
|
|
3451
|
-
function removeProductsFromOrder(
|
|
3526
|
+
function removeProductsFromOrder(_x35) {
|
|
3452
3527
|
return _removeProductsFromOrder.apply(this, arguments);
|
|
3453
3528
|
}
|
|
3454
3529
|
return removeProductsFromOrder;
|
|
@@ -3456,18 +3531,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3456
3531
|
}, {
|
|
3457
3532
|
key: "removeProductFromOrder",
|
|
3458
3533
|
value: function () {
|
|
3459
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3460
|
-
return _regeneratorRuntime().wrap(function
|
|
3461
|
-
while (1) switch (
|
|
3534
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(identity) {
|
|
3535
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context41) {
|
|
3536
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
3462
3537
|
case 0:
|
|
3463
|
-
return
|
|
3538
|
+
return _context41.abrupt("return", this.removeProductsFromOrder([identity]));
|
|
3464
3539
|
case 1:
|
|
3465
3540
|
case "end":
|
|
3466
|
-
return
|
|
3541
|
+
return _context41.stop();
|
|
3467
3542
|
}
|
|
3468
|
-
},
|
|
3543
|
+
}, _callee41, this);
|
|
3469
3544
|
}));
|
|
3470
|
-
function removeProductFromOrder(
|
|
3545
|
+
function removeProductFromOrder(_x36) {
|
|
3471
3546
|
return _removeProductFromOrder.apply(this, arguments);
|
|
3472
3547
|
}
|
|
3473
3548
|
return removeProductFromOrder;
|
|
@@ -3517,23 +3592,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3517
3592
|
}, {
|
|
3518
3593
|
key: "applyPromotion",
|
|
3519
3594
|
value: (function () {
|
|
3520
|
-
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3521
|
-
return _regeneratorRuntime().wrap(function
|
|
3522
|
-
while (1) switch (
|
|
3595
|
+
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42() {
|
|
3596
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context42) {
|
|
3597
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
3523
3598
|
case 0:
|
|
3524
3599
|
if (this.store.order) {
|
|
3525
|
-
|
|
3600
|
+
_context42.next = 2;
|
|
3526
3601
|
break;
|
|
3527
3602
|
}
|
|
3528
3603
|
throw new Error('order 模块未初始化');
|
|
3529
3604
|
case 2:
|
|
3530
|
-
|
|
3605
|
+
_context42.next = 4;
|
|
3531
3606
|
return this.store.order.applyPromotion();
|
|
3532
3607
|
case 4:
|
|
3533
3608
|
case "end":
|
|
3534
|
-
return
|
|
3609
|
+
return _context42.stop();
|
|
3535
3610
|
}
|
|
3536
|
-
},
|
|
3611
|
+
}, _callee42, this);
|
|
3537
3612
|
}));
|
|
3538
3613
|
function applyPromotion() {
|
|
3539
3614
|
return _applyPromotion.apply(this, arguments);
|
|
@@ -3560,18 +3635,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3560
3635
|
}, {
|
|
3561
3636
|
key: "getProductList",
|
|
3562
3637
|
value: function () {
|
|
3563
|
-
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3638
|
+
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43() {
|
|
3564
3639
|
var _this$otherParams21;
|
|
3565
3640
|
var menu_list_ids, _this$store$products, res;
|
|
3566
|
-
return _regeneratorRuntime().wrap(function
|
|
3567
|
-
while (1) switch (
|
|
3641
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context43) {
|
|
3642
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
3568
3643
|
case 0:
|
|
3569
3644
|
// 可以直接通过配置里的 menu 读取
|
|
3570
3645
|
menu_list_ids = ((_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 || (_this$otherParams21 = _this$otherParams21.dineInConfig) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21['menu.associated_menus'].map(function (n) {
|
|
3571
3646
|
return Number(n.value);
|
|
3572
3647
|
})) || [];
|
|
3573
|
-
|
|
3574
|
-
|
|
3648
|
+
_context43.prev = 1;
|
|
3649
|
+
_context43.next = 4;
|
|
3575
3650
|
return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
|
|
3576
3651
|
menu_list_ids: menu_list_ids,
|
|
3577
3652
|
cacheId: this.cacheId,
|
|
@@ -3579,17 +3654,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3579
3654
|
schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
3580
3655
|
});
|
|
3581
3656
|
case 4:
|
|
3582
|
-
res =
|
|
3583
|
-
return
|
|
3657
|
+
res = _context43.sent;
|
|
3658
|
+
return _context43.abrupt("return", res);
|
|
3584
3659
|
case 8:
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
throw
|
|
3660
|
+
_context43.prev = 8;
|
|
3661
|
+
_context43.t0 = _context43["catch"](1);
|
|
3662
|
+
throw _context43.t0;
|
|
3588
3663
|
case 11:
|
|
3589
3664
|
case "end":
|
|
3590
|
-
return
|
|
3665
|
+
return _context43.stop();
|
|
3591
3666
|
}
|
|
3592
|
-
},
|
|
3667
|
+
}, _callee43, this, [[1, 8]]);
|
|
3593
3668
|
}));
|
|
3594
3669
|
function getProductList() {
|
|
3595
3670
|
return _getProductList.apply(this, arguments);
|
|
@@ -3604,33 +3679,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3604
3679
|
}, {
|
|
3605
3680
|
key: "setOtherParams",
|
|
3606
3681
|
value: function () {
|
|
3607
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3682
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(params) {
|
|
3608
3683
|
var _this$otherParams22;
|
|
3609
|
-
var
|
|
3610
|
-
|
|
3684
|
+
var _ref29,
|
|
3685
|
+
_ref29$cover,
|
|
3611
3686
|
cover,
|
|
3612
|
-
|
|
3613
|
-
return _regeneratorRuntime().wrap(function
|
|
3614
|
-
while (1) switch (
|
|
3687
|
+
_args44 = arguments;
|
|
3688
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context44) {
|
|
3689
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
3615
3690
|
case 0:
|
|
3616
|
-
|
|
3691
|
+
_ref29 = _args44.length > 1 && _args44[1] !== undefined ? _args44[1] : {}, _ref29$cover = _ref29.cover, cover = _ref29$cover === void 0 ? false : _ref29$cover;
|
|
3617
3692
|
if (cover) {
|
|
3618
3693
|
this.otherParams = _objectSpread({}, params);
|
|
3619
3694
|
} else {
|
|
3620
3695
|
this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
|
|
3621
3696
|
}
|
|
3622
3697
|
this.cacheId = (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.cacheId;
|
|
3623
|
-
|
|
3698
|
+
_context44.next = 5;
|
|
3624
3699
|
return this.syncOtherParamsToSubModules(params, {
|
|
3625
3700
|
cover: cover
|
|
3626
3701
|
});
|
|
3627
3702
|
case 5:
|
|
3628
3703
|
case "end":
|
|
3629
|
-
return
|
|
3704
|
+
return _context44.stop();
|
|
3630
3705
|
}
|
|
3631
|
-
},
|
|
3706
|
+
}, _callee44, this);
|
|
3632
3707
|
}));
|
|
3633
|
-
function setOtherParams(
|
|
3708
|
+
function setOtherParams(_x37) {
|
|
3634
3709
|
return _setOtherParams.apply(this, arguments);
|
|
3635
3710
|
}
|
|
3636
3711
|
return setOtherParams;
|