@pisell/pisellos 2.3.18 → 2.3.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/Order/index.d.ts +4 -2
- package/dist/modules/Order/index.js +53 -32
- package/dist/modules/Order/types.d.ts +13 -0
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Rules/index.d.ts +2 -8
- package/dist/modules/Rules/index.js +55 -9
- package/dist/modules/Rules/types.d.ts +10 -1
- package/dist/server/modules/order/index.js +1 -2
- package/dist/solution/BaseSales/index.d.ts +6 -0
- package/dist/solution/BaseSales/index.js +772 -651
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +13 -1
- package/lib/modules/Order/index.d.ts +4 -2
- package/lib/modules/Order/index.js +34 -14
- package/lib/modules/Order/types.d.ts +13 -0
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Rules/index.d.ts +2 -8
- package/lib/modules/Rules/index.js +57 -6
- package/lib/modules/Rules/types.d.ts +10 -1
- package/lib/server/modules/order/index.js +1 -2
- package/lib/solution/BaseSales/index.d.ts +6 -0
- package/lib/solution/BaseSales/index.js +96 -24
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +13 -1
- package/package.json +1 -1
|
@@ -3,12 +3,11 @@ 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
|
|
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; }
|
|
7
8
|
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; }
|
|
8
9
|
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); } }
|
|
9
10
|
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); }); }; }
|
|
10
|
-
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; }
|
|
11
|
-
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; }
|
|
12
11
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
13
12
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
14
13
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
@@ -30,6 +29,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
30
29
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
31
30
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
32
31
|
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; }
|
|
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";
|
|
35
35
|
import { OrderModule } from "../../modules/Order";
|
|
@@ -42,6 +42,7 @@ export * from "./types";
|
|
|
42
42
|
import { QuotationModule } from "../../modules/Quotation";
|
|
43
43
|
import { transformBaseProductToOrderProduct as _transformBaseProductToOrderProduct } from "./utils/transformBaseProductToOrderProduct";
|
|
44
44
|
import { calculateBaseSalesProductBookingPrice } from "./utils/quotationPrice";
|
|
45
|
+
var SERVER_ORDER_CHANGED_EVENT = 'order:onOrdersChanged';
|
|
45
46
|
function isBaseSalesManualProductDiscountProduct(product) {
|
|
46
47
|
var _product$metadata, _product$metadata2;
|
|
47
48
|
return (product === null || product === void 0 || (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.is_manual_discount) === true || (product === null || product === void 0 || (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.is_manual_discount) === 1 || ((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (item) {
|
|
@@ -75,6 +76,16 @@ function getBaseSalesUniqueArrayMetadataKey(key) {
|
|
|
75
76
|
if (key === 'payments' || key === 'payment') return 'unique_payment_number';
|
|
76
77
|
return null;
|
|
77
78
|
}
|
|
79
|
+
function isSameBaseSalesOrderRecord(left, right) {
|
|
80
|
+
if (!left || !right || _typeof(left) !== 'object' || _typeof(right) !== 'object') return false;
|
|
81
|
+
var leftIdentities = new Set([left.order_id, left.id, left.external_sale_number, left.order_number].filter(function (value) {
|
|
82
|
+
return value !== undefined && value !== null && value !== '';
|
|
83
|
+
}).map(String));
|
|
84
|
+
if (leftIdentities.size === 0) return false;
|
|
85
|
+
return [right.order_id, right.id, right.external_sale_number, right.order_number].some(function (value) {
|
|
86
|
+
return value !== undefined && value !== null && value !== '' && leftIdentities.has(String(value));
|
|
87
|
+
});
|
|
88
|
+
}
|
|
78
89
|
function getBaseSalesMetadataUid(item, metadataKey) {
|
|
79
90
|
var _item$metadata$metada, _item$metadata;
|
|
80
91
|
var uid = (_item$metadata$metada = item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata[metadataKey]) !== null && _item$metadata$metada !== void 0 ? _item$metadata$metada : item === null || item === void 0 ? void 0 : item[metadataKey];
|
|
@@ -156,6 +167,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
156
167
|
_defineProperty(_assertThisInitialized(_this), "queuedAutoPaymentSync", false);
|
|
157
168
|
_defineProperty(_assertThisInitialized(_this), "autoPaymentSyncFlushing", false);
|
|
158
169
|
_defineProperty(_assertThisInitialized(_this), "autoPaymentSyncTimer", null);
|
|
170
|
+
_defineProperty(_assertThisInitialized(_this), "salesDetailLoadInFlight", false);
|
|
171
|
+
_defineProperty(_assertThisInitialized(_this), "serverOrderChangeUnsubscribe", null);
|
|
172
|
+
_defineProperty(_assertThisInitialized(_this), "serverOrderChangeHydrateInFlight", null);
|
|
159
173
|
return _this;
|
|
160
174
|
}
|
|
161
175
|
|
|
@@ -235,6 +249,104 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
235
249
|
});
|
|
236
250
|
}
|
|
237
251
|
}
|
|
252
|
+
}, {
|
|
253
|
+
key: "isCurrentSalesOrderRecord",
|
|
254
|
+
value: function isCurrentSalesOrderRecord(order) {
|
|
255
|
+
var _this$store$order, _this$store$order$get;
|
|
256
|
+
var currentTempOrder = (_this$store$order = this.store.order) === null || _this$store$order === void 0 || (_this$store$order$get = _this$store$order.getTempOrder) === null || _this$store$order$get === void 0 ? void 0 : _this$store$order$get.call(_this$store$order);
|
|
257
|
+
var currentRecords = [currentTempOrder, this.currentSalesDetail].filter(Boolean);
|
|
258
|
+
return currentRecords.some(function (record) {
|
|
259
|
+
return isSameBaseSalesOrderRecord(record, order);
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
}, {
|
|
263
|
+
key: "syncCurrentSalesDetailFromServerOrderChange",
|
|
264
|
+
value: function () {
|
|
265
|
+
var _syncCurrentSalesDetailFromServerOrderChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(payload) {
|
|
266
|
+
var _this2 = this;
|
|
267
|
+
var changedOrders, changedOrder;
|
|
268
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
269
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
270
|
+
case 0:
|
|
271
|
+
changedOrders = Array.isArray(payload) ? payload : Array.isArray(payload === null || payload === void 0 ? void 0 : payload.changedOrders) ? payload.changedOrders : payload !== null && payload !== void 0 && payload.data && _typeof(payload.data) === 'object' ? [payload.data] : [];
|
|
272
|
+
if (!(this.salesDetailLoadInFlight || this.serverOrderChangeHydrateInFlight)) {
|
|
273
|
+
_context2.next = 3;
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
return _context2.abrupt("return");
|
|
277
|
+
case 3:
|
|
278
|
+
changedOrder = changedOrders.find(function (order) {
|
|
279
|
+
return _this2.isCurrentSalesOrderRecord(order);
|
|
280
|
+
});
|
|
281
|
+
if (changedOrder) {
|
|
282
|
+
_context2.next = 6;
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
return _context2.abrupt("return");
|
|
286
|
+
case 6:
|
|
287
|
+
if (this.store.order) {
|
|
288
|
+
_context2.next = 8;
|
|
289
|
+
break;
|
|
290
|
+
}
|
|
291
|
+
return _context2.abrupt("return");
|
|
292
|
+
case 8:
|
|
293
|
+
this.serverOrderChangeHydrateInFlight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
294
|
+
var sales;
|
|
295
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
296
|
+
while (1) switch (_context.prev = _context.next) {
|
|
297
|
+
case 0:
|
|
298
|
+
_context.next = 2;
|
|
299
|
+
return _this2.store.order.hydrateTempOrderFromRecord(changedOrder, {
|
|
300
|
+
recalcOnHydrate: false
|
|
301
|
+
});
|
|
302
|
+
case 2:
|
|
303
|
+
sales = _context.sent;
|
|
304
|
+
_this2.currentSalesDetail = sales;
|
|
305
|
+
_context.next = 6;
|
|
306
|
+
return _this2.core.effects.emit("".concat(_this2.name, ":onSalesOrderLoaded"), {
|
|
307
|
+
sales: sales
|
|
308
|
+
});
|
|
309
|
+
case 6:
|
|
310
|
+
case "end":
|
|
311
|
+
return _context.stop();
|
|
312
|
+
}
|
|
313
|
+
}, _callee);
|
|
314
|
+
}))();
|
|
315
|
+
_context2.prev = 9;
|
|
316
|
+
_context2.next = 12;
|
|
317
|
+
return this.serverOrderChangeHydrateInFlight;
|
|
318
|
+
case 12:
|
|
319
|
+
_context2.prev = 12;
|
|
320
|
+
this.serverOrderChangeHydrateInFlight = null;
|
|
321
|
+
return _context2.finish(12);
|
|
322
|
+
case 15:
|
|
323
|
+
case "end":
|
|
324
|
+
return _context2.stop();
|
|
325
|
+
}
|
|
326
|
+
}, _callee2, this, [[9,, 12, 15]]);
|
|
327
|
+
}));
|
|
328
|
+
function syncCurrentSalesDetailFromServerOrderChange(_x) {
|
|
329
|
+
return _syncCurrentSalesDetailFromServerOrderChange.apply(this, arguments);
|
|
330
|
+
}
|
|
331
|
+
return syncCurrentSalesDetailFromServerOrderChange;
|
|
332
|
+
}()
|
|
333
|
+
}, {
|
|
334
|
+
key: "registerServerOrderChangeSync",
|
|
335
|
+
value: function registerServerOrderChangeSync() {
|
|
336
|
+
var _this$serverOrderChan,
|
|
337
|
+
_this$core2,
|
|
338
|
+
_this3 = this;
|
|
339
|
+
(_this$serverOrderChan = this.serverOrderChangeUnsubscribe) === null || _this$serverOrderChan === void 0 || _this$serverOrderChan.call(this);
|
|
340
|
+
var effects = (_this$core2 = this.core) === null || _this$core2 === void 0 ? void 0 : _this$core2.effects;
|
|
341
|
+
if (!effects || typeof effects.on !== 'function') return;
|
|
342
|
+
this.serverOrderChangeUnsubscribe = effects.on(SERVER_ORDER_CHANGED_EVENT, function (payload) {
|
|
343
|
+
void _this3.syncCurrentSalesDetailFromServerOrderChange(payload).catch(function (error) {
|
|
344
|
+
_this3.logError('sync sales detail from server order change failed', {
|
|
345
|
+
error: error instanceof Error ? error.message : String(error)
|
|
346
|
+
});
|
|
347
|
+
});
|
|
348
|
+
});
|
|
349
|
+
}
|
|
238
350
|
}, {
|
|
239
351
|
key: "hydrateOrderPaymentNames",
|
|
240
352
|
value: function hydrateOrderPaymentNames(payments) {
|
|
@@ -272,8 +384,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
272
384
|
}, {
|
|
273
385
|
key: "getCurrentOrderCustomerId",
|
|
274
386
|
value: function getCurrentOrderCustomerId() {
|
|
275
|
-
var _this$store$
|
|
276
|
-
var tempOrder = (_this$store$
|
|
387
|
+
var _this$store$order2, _this$store$order2$ge;
|
|
388
|
+
var tempOrder = (_this$store$order2 = this.store.order) === null || _this$store$order2 === void 0 || (_this$store$order2$ge = _this$store$order2.getTempOrder) === null || _this$store$order2$ge === void 0 ? void 0 : _this$store$order2$ge.call(_this$store$order2);
|
|
277
389
|
var customerId = tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.customer_id;
|
|
278
390
|
if (customerId === null || customerId === undefined) return undefined;
|
|
279
391
|
return customerId;
|
|
@@ -299,10 +411,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
299
411
|
});
|
|
300
412
|
}
|
|
301
413
|
quotation.setScheduleResolver(function (id) {
|
|
302
|
-
var _scheduleModule$getSc, _getScheduleByIds,
|
|
414
|
+
var _scheduleModule$getSc, _getScheduleByIds, _ref2;
|
|
303
415
|
var scheduleId = String(id);
|
|
304
416
|
if (scheduleById.has(scheduleId)) return scheduleById.get(scheduleId);
|
|
305
|
-
var schedules = ((_scheduleModule$getSc = scheduleModule.getScheduleListByIds) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule, [id])) || ((_getScheduleByIds = (
|
|
417
|
+
var schedules = ((_scheduleModule$getSc = scheduleModule.getScheduleListByIds) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule, [id])) || ((_getScheduleByIds = (_ref2 = scheduleModule).getScheduleByIds) === null || _getScheduleByIds === void 0 ? void 0 : _getScheduleByIds.call(_ref2, [id])) || [];
|
|
306
418
|
if (schedules[0]) scheduleById.set(scheduleId, schedules[0]);
|
|
307
419
|
return schedules[0];
|
|
308
420
|
});
|
|
@@ -310,30 +422,30 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
310
422
|
}, {
|
|
311
423
|
key: "loadQuotationForPriceQuery",
|
|
312
424
|
value: function () {
|
|
313
|
-
var _loadQuotationForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
425
|
+
var _loadQuotationForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
314
426
|
var _this$otherParams;
|
|
315
|
-
return _regeneratorRuntime().wrap(function
|
|
316
|
-
while (1) switch (
|
|
427
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
428
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
317
429
|
case 0:
|
|
318
430
|
if (params.quotation) {
|
|
319
|
-
|
|
431
|
+
_context3.next = 2;
|
|
320
432
|
break;
|
|
321
433
|
}
|
|
322
|
-
return
|
|
434
|
+
return _context3.abrupt("return");
|
|
323
435
|
case 2:
|
|
324
436
|
this.applyQuotationScheduleResolver(params.quotation);
|
|
325
|
-
|
|
437
|
+
_context3.next = 5;
|
|
326
438
|
return params.quotation.loadQuotations({
|
|
327
439
|
channel: params.channel || ((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.channel),
|
|
328
440
|
customer_id: params.customer_id
|
|
329
441
|
});
|
|
330
442
|
case 5:
|
|
331
443
|
case "end":
|
|
332
|
-
return
|
|
444
|
+
return _context3.stop();
|
|
333
445
|
}
|
|
334
|
-
},
|
|
446
|
+
}, _callee3, this);
|
|
335
447
|
}));
|
|
336
|
-
function loadQuotationForPriceQuery(
|
|
448
|
+
function loadQuotationForPriceQuery(_x2) {
|
|
337
449
|
return _loadQuotationForPriceQuery.apply(this, arguments);
|
|
338
450
|
}
|
|
339
451
|
return loadQuotationForPriceQuery;
|
|
@@ -377,23 +489,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
377
489
|
}, {
|
|
378
490
|
key: "loadProductsForPriceQuery",
|
|
379
491
|
value: function () {
|
|
380
|
-
var _loadProductsForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
492
|
+
var _loadProductsForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
|
|
381
493
|
var ids, productsById, _this$otherParams2, _response$data, response, list;
|
|
382
|
-
return _regeneratorRuntime().wrap(function
|
|
383
|
-
while (1) switch (
|
|
494
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
495
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
384
496
|
case 0:
|
|
385
497
|
ids = Array.from(new Set(params.ids.filter(function (id) {
|
|
386
498
|
return Number.isFinite(id);
|
|
387
499
|
})));
|
|
388
500
|
productsById = new Map();
|
|
389
501
|
if (!(!ids.length || !this.request)) {
|
|
390
|
-
|
|
502
|
+
_context4.next = 4;
|
|
391
503
|
break;
|
|
392
504
|
}
|
|
393
|
-
return
|
|
505
|
+
return _context4.abrupt("return", productsById);
|
|
394
506
|
case 4:
|
|
395
|
-
|
|
396
|
-
|
|
507
|
+
_context4.prev = 4;
|
|
508
|
+
_context4.next = 7;
|
|
397
509
|
return this.request.post('/product/query', {
|
|
398
510
|
ids: ids,
|
|
399
511
|
open_quotation: 1,
|
|
@@ -410,35 +522,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
410
522
|
customToast: function customToast() {}
|
|
411
523
|
});
|
|
412
524
|
case 7:
|
|
413
|
-
response =
|
|
525
|
+
response = _context4.sent;
|
|
414
526
|
list = (response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.list) || (response === null || response === void 0 ? void 0 : response.list) || [];
|
|
415
527
|
if (Array.isArray(list)) {
|
|
416
|
-
|
|
528
|
+
_context4.next = 11;
|
|
417
529
|
break;
|
|
418
530
|
}
|
|
419
|
-
return
|
|
531
|
+
return _context4.abrupt("return", productsById);
|
|
420
532
|
case 11:
|
|
421
533
|
list.forEach(function (item) {
|
|
422
534
|
var _item$id;
|
|
423
535
|
var productId = Number((_item$id = item === null || item === void 0 ? void 0 : item.id) !== null && _item$id !== void 0 ? _item$id : item === null || item === void 0 ? void 0 : item.product_id);
|
|
424
536
|
if (Number.isFinite(productId)) productsById.set(productId, item);
|
|
425
537
|
});
|
|
426
|
-
return
|
|
538
|
+
return _context4.abrupt("return", productsById);
|
|
427
539
|
case 15:
|
|
428
|
-
|
|
429
|
-
|
|
540
|
+
_context4.prev = 15;
|
|
541
|
+
_context4.t0 = _context4["catch"](4);
|
|
430
542
|
this.logWarning('loadProductsForPriceQuery: 商品批量重查失败,使用入参 fallback', {
|
|
431
543
|
ids: ids,
|
|
432
|
-
error:
|
|
544
|
+
error: _context4.t0 instanceof Error ? _context4.t0.message : String(_context4.t0)
|
|
433
545
|
});
|
|
434
|
-
return
|
|
546
|
+
return _context4.abrupt("return", productsById);
|
|
435
547
|
case 19:
|
|
436
548
|
case "end":
|
|
437
|
-
return
|
|
549
|
+
return _context4.stop();
|
|
438
550
|
}
|
|
439
|
-
},
|
|
551
|
+
}, _callee4, this, [[4, 15]]);
|
|
440
552
|
}));
|
|
441
|
-
function loadProductsForPriceQuery(
|
|
553
|
+
function loadProductsForPriceQuery(_x3) {
|
|
442
554
|
return _loadProductsForPriceQuery.apply(this, arguments);
|
|
443
555
|
}
|
|
444
556
|
return loadProductsForPriceQuery;
|
|
@@ -446,21 +558,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
446
558
|
}, {
|
|
447
559
|
key: "loadProductForPriceQuery",
|
|
448
560
|
value: function () {
|
|
449
|
-
var _loadProductForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
561
|
+
var _loadProductForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(params, customerId) {
|
|
450
562
|
var product, productId, schedule, productsById;
|
|
451
|
-
return _regeneratorRuntime().wrap(function
|
|
452
|
-
while (1) switch (
|
|
563
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
564
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
453
565
|
case 0:
|
|
454
566
|
product = params.product || {};
|
|
455
567
|
productId = this.getPriceQueryProductId(product);
|
|
456
568
|
if (!(productId === null || !this.request)) {
|
|
457
|
-
|
|
569
|
+
_context5.next = 4;
|
|
458
570
|
break;
|
|
459
571
|
}
|
|
460
|
-
return
|
|
572
|
+
return _context5.abrupt("return", null);
|
|
461
573
|
case 4:
|
|
462
574
|
schedule = this.getPriceQuerySchedule(params);
|
|
463
|
-
|
|
575
|
+
_context5.next = 7;
|
|
464
576
|
return this.loadProductsForPriceQuery({
|
|
465
577
|
ids: [productId],
|
|
466
578
|
schedule: schedule,
|
|
@@ -468,15 +580,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
468
580
|
channel: params.channel
|
|
469
581
|
});
|
|
470
582
|
case 7:
|
|
471
|
-
productsById =
|
|
472
|
-
return
|
|
583
|
+
productsById = _context5.sent;
|
|
584
|
+
return _context5.abrupt("return", productsById.get(productId) || null);
|
|
473
585
|
case 9:
|
|
474
586
|
case "end":
|
|
475
|
-
return
|
|
587
|
+
return _context5.stop();
|
|
476
588
|
}
|
|
477
|
-
},
|
|
589
|
+
}, _callee5, this);
|
|
478
590
|
}));
|
|
479
|
-
function loadProductForPriceQuery(
|
|
591
|
+
function loadProductForPriceQuery(_x4, _x5) {
|
|
480
592
|
return _loadProductForPriceQuery.apply(this, arguments);
|
|
481
593
|
}
|
|
482
594
|
return loadProductForPriceQuery;
|
|
@@ -489,10 +601,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
489
601
|
return groups.flatMap(function (group) {
|
|
490
602
|
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 : [];
|
|
491
603
|
return items.map(function (item) {
|
|
492
|
-
var _item$group_id,
|
|
604
|
+
var _item$group_id, _ref3, _item$bundle_group_id;
|
|
493
605
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
494
606
|
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,
|
|
495
|
-
bundle_group_id: (
|
|
607
|
+
bundle_group_id: (_ref3 = (_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 && _ref3 !== void 0 ? _ref3 : group === null || group === void 0 ? void 0 : group.id
|
|
496
608
|
});
|
|
497
609
|
});
|
|
498
610
|
});
|
|
@@ -523,21 +635,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
523
635
|
}, {
|
|
524
636
|
key: "getAuthoritativeBundleUnitPrice",
|
|
525
637
|
value: function getAuthoritativeBundleUnitPrice(bundle) {
|
|
526
|
-
var
|
|
527
|
-
return (
|
|
638
|
+
var _ref4, _ref5, _ref6, _bundle$price;
|
|
639
|
+
return (_ref4 = (_ref5 = (_ref6 = (_bundle$price = bundle.price) !== null && _bundle$price !== void 0 ? _bundle$price : bundle.bundle_selling_price) !== null && _ref6 !== void 0 ? _ref6 : bundle.custom_price) !== null && _ref5 !== void 0 ? _ref5 : bundle.product_price) !== null && _ref4 !== void 0 ? _ref4 : bundle.base_price;
|
|
528
640
|
}
|
|
529
641
|
}, {
|
|
530
642
|
key: "mergeProductForPriceQuery",
|
|
531
643
|
value: function mergeProductForPriceQuery(product, authoritativeProduct) {
|
|
532
|
-
var
|
|
644
|
+
var _this4 = this,
|
|
533
645
|
_product$id,
|
|
534
|
-
_ref6,
|
|
535
|
-
_product$product_id2,
|
|
536
646
|
_ref7,
|
|
537
|
-
_product$
|
|
647
|
+
_product$product_id2,
|
|
538
648
|
_ref8,
|
|
539
|
-
_product$
|
|
649
|
+
_product$product_vari,
|
|
540
650
|
_ref9,
|
|
651
|
+
_product$num,
|
|
652
|
+
_ref10,
|
|
541
653
|
_product$quantity,
|
|
542
654
|
_product$metadata4;
|
|
543
655
|
if (!authoritativeProduct) return product;
|
|
@@ -545,8 +657,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
545
657
|
var authoritativeBundles = this.getAuthoritativeBundleItems(authoritativeProduct);
|
|
546
658
|
var productBundle = selectedBundles.map(function (bundle) {
|
|
547
659
|
var _authoritativeBundle$, _authoritativeBundle$2;
|
|
548
|
-
var authoritativeBundle =
|
|
549
|
-
var unitPrice = authoritativeBundle ?
|
|
660
|
+
var authoritativeBundle = _this4.findAuthoritativeBundleItem(bundle, authoritativeBundles);
|
|
661
|
+
var unitPrice = authoritativeBundle ? _this4.getAuthoritativeBundleUnitPrice(authoritativeBundle) : undefined;
|
|
550
662
|
if (unitPrice === undefined || unitPrice === null || unitPrice === '') return bundle;
|
|
551
663
|
return _objectSpread(_objectSpread({}, bundle), {}, {
|
|
552
664
|
price: unitPrice,
|
|
@@ -557,10 +669,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
557
669
|
});
|
|
558
670
|
return _objectSpread(_objectSpread(_objectSpread({}, product), authoritativeProduct), {}, {
|
|
559
671
|
id: (_product$id = product.id) !== null && _product$id !== void 0 ? _product$id : authoritativeProduct.id,
|
|
560
|
-
product_id: (
|
|
561
|
-
product_variant_id: (
|
|
562
|
-
num: (
|
|
563
|
-
quantity: (
|
|
672
|
+
product_id: (_ref7 = (_product$product_id2 = product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : authoritativeProduct.product_id) !== null && _ref7 !== void 0 ? _ref7 : authoritativeProduct.id,
|
|
673
|
+
product_variant_id: (_ref8 = (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : authoritativeProduct.product_variant_id) !== null && _ref8 !== void 0 ? _ref8 : 0,
|
|
674
|
+
num: (_ref9 = (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : product.quantity) !== null && _ref9 !== void 0 ? _ref9 : authoritativeProduct.num,
|
|
675
|
+
quantity: (_ref10 = (_product$quantity = product.quantity) !== null && _product$quantity !== void 0 ? _product$quantity : product.num) !== null && _ref10 !== void 0 ? _ref10 : authoritativeProduct.quantity,
|
|
564
676
|
product_sku: function () {
|
|
565
677
|
var authoritativeSku = ensureProductSku(authoritativeProduct);
|
|
566
678
|
var productSku = ensureProductSku(product);
|
|
@@ -634,61 +746,61 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
634
746
|
}, {
|
|
635
747
|
key: "syncOtherParamsToSubModules",
|
|
636
748
|
value: (function () {
|
|
637
|
-
var _syncOtherParamsToSubModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
638
|
-
var
|
|
639
|
-
var
|
|
640
|
-
|
|
749
|
+
var _syncOtherParamsToSubModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(changedParams) {
|
|
750
|
+
var _this5 = this;
|
|
751
|
+
var _ref11,
|
|
752
|
+
_ref11$cover,
|
|
641
753
|
cover,
|
|
642
754
|
nextSubModuleOtherParams,
|
|
643
|
-
|
|
644
|
-
return _regeneratorRuntime().wrap(function
|
|
645
|
-
while (1) switch (
|
|
755
|
+
_args7 = arguments;
|
|
756
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
757
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
646
758
|
case 0:
|
|
647
|
-
|
|
759
|
+
_ref11 = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : {}, _ref11$cover = _ref11.cover, cover = _ref11$cover === void 0 ? false : _ref11$cover;
|
|
648
760
|
nextSubModuleOtherParams = this.buildSubModuleOtherParams();
|
|
649
|
-
|
|
761
|
+
_context7.next = 4;
|
|
650
762
|
return Promise.all(Object.entries(this.store).map( /*#__PURE__*/function () {
|
|
651
|
-
var
|
|
652
|
-
var
|
|
653
|
-
return _regeneratorRuntime().wrap(function
|
|
654
|
-
while (1) switch (
|
|
763
|
+
var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(_ref12) {
|
|
764
|
+
var _ref14, moduleName, subModule, targetModule;
|
|
765
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
766
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
655
767
|
case 0:
|
|
656
|
-
|
|
657
|
-
if (!
|
|
658
|
-
|
|
768
|
+
_ref14 = _slicedToArray(_ref12, 2), moduleName = _ref14[0], subModule = _ref14[1];
|
|
769
|
+
if (!_this5.reusedSharedSubModuleNames.has(moduleName)) {
|
|
770
|
+
_context6.next = 3;
|
|
659
771
|
break;
|
|
660
772
|
}
|
|
661
|
-
return
|
|
773
|
+
return _context6.abrupt("return");
|
|
662
774
|
case 3:
|
|
663
775
|
targetModule = subModule;
|
|
664
776
|
if (!(!targetModule || typeof targetModule.updateOtherParams !== 'function')) {
|
|
665
|
-
|
|
777
|
+
_context6.next = 6;
|
|
666
778
|
break;
|
|
667
779
|
}
|
|
668
|
-
return
|
|
780
|
+
return _context6.abrupt("return");
|
|
669
781
|
case 6:
|
|
670
|
-
|
|
782
|
+
_context6.next = 8;
|
|
671
783
|
return targetModule.updateOtherParams(nextSubModuleOtherParams, {
|
|
672
784
|
changedParams: changedParams,
|
|
673
785
|
cover: cover
|
|
674
786
|
});
|
|
675
787
|
case 8:
|
|
676
788
|
case "end":
|
|
677
|
-
return
|
|
789
|
+
return _context6.stop();
|
|
678
790
|
}
|
|
679
|
-
},
|
|
791
|
+
}, _callee6);
|
|
680
792
|
}));
|
|
681
|
-
return function (
|
|
682
|
-
return
|
|
793
|
+
return function (_x7) {
|
|
794
|
+
return _ref13.apply(this, arguments);
|
|
683
795
|
};
|
|
684
796
|
}()));
|
|
685
797
|
case 4:
|
|
686
798
|
case "end":
|
|
687
|
-
return
|
|
799
|
+
return _context7.stop();
|
|
688
800
|
}
|
|
689
|
-
},
|
|
801
|
+
}, _callee7, this);
|
|
690
802
|
}));
|
|
691
|
-
function syncOtherParamsToSubModules(
|
|
803
|
+
function syncOtherParamsToSubModules(_x6) {
|
|
692
804
|
return _syncOtherParamsToSubModules.apply(this, arguments);
|
|
693
805
|
}
|
|
694
806
|
return syncOtherParamsToSubModules;
|
|
@@ -762,19 +874,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
762
874
|
}, {
|
|
763
875
|
key: "initialize",
|
|
764
876
|
value: function () {
|
|
765
|
-
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
877
|
+
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(core) {
|
|
766
878
|
var _this$otherParams4,
|
|
767
|
-
|
|
879
|
+
_this6 = this,
|
|
768
880
|
_this$otherParams5;
|
|
769
881
|
var options,
|
|
770
882
|
app,
|
|
771
883
|
targetCacheData,
|
|
772
884
|
moduleNames,
|
|
773
|
-
|
|
774
|
-
return _regeneratorRuntime().wrap(function
|
|
775
|
-
while (1) switch (
|
|
885
|
+
_args8 = arguments;
|
|
886
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
887
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
776
888
|
case 0:
|
|
777
|
-
options =
|
|
889
|
+
options = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : {};
|
|
778
890
|
this.core = core;
|
|
779
891
|
this.initializeOptions = options || {};
|
|
780
892
|
// this.store = { ...this.store, ...(options.store as Partial<BaseSalesState>) };
|
|
@@ -787,7 +899,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
787
899
|
// 获取 logger 实例
|
|
788
900
|
this.appPlugin = core.getPlugin('app');
|
|
789
901
|
if (this.appPlugin) {
|
|
790
|
-
|
|
902
|
+
_context8.next = 11;
|
|
791
903
|
break;
|
|
792
904
|
}
|
|
793
905
|
throw new Error('Checkout 解决方案需要 app 插件支持');
|
|
@@ -797,47 +909,48 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
797
909
|
targetCacheData = this.readSessionCacheData();
|
|
798
910
|
moduleNames = this.getRegisteredModuleNames();
|
|
799
911
|
moduleNames.forEach(function (step) {
|
|
800
|
-
var reusedModule =
|
|
912
|
+
var reusedModule = _this6.getReusableSharedSubModule(step);
|
|
801
913
|
if (reusedModule) {
|
|
802
|
-
|
|
803
|
-
|
|
914
|
+
_this6.store[step] = reusedModule;
|
|
915
|
+
_this6.reusedSharedSubModuleNames.add(step);
|
|
804
916
|
return;
|
|
805
917
|
}
|
|
806
|
-
var targetModule =
|
|
918
|
+
var targetModule = _this6.createSubModule(step);
|
|
807
919
|
if (!targetModule) {
|
|
808
920
|
throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
|
|
809
921
|
}
|
|
810
|
-
var hooks =
|
|
811
|
-
|
|
812
|
-
|
|
922
|
+
var hooks = _this6.getSubModuleHooks(step);
|
|
923
|
+
_this6.store[step] = targetModule;
|
|
924
|
+
_this6.core.registerModule(targetModule, _objectSpread(_objectSpread({
|
|
813
925
|
initialState: (targetCacheData === null || targetCacheData === void 0 ? void 0 : targetCacheData[targetModule.name]) || {}
|
|
814
926
|
}, hooks ? {
|
|
815
927
|
hooks: hooks
|
|
816
928
|
} : {}), {}, {
|
|
817
|
-
otherParams:
|
|
929
|
+
otherParams: _this6.buildSubModuleOtherParams()
|
|
818
930
|
}));
|
|
819
931
|
});
|
|
820
932
|
if (!(this.store.schedule && !this.isScheduleListLoaded(this.store.schedule))) {
|
|
821
|
-
|
|
933
|
+
_context8.next = 19;
|
|
822
934
|
break;
|
|
823
935
|
}
|
|
824
|
-
|
|
936
|
+
_context8.next = 19;
|
|
825
937
|
return this.store.schedule.loadAllSchedule();
|
|
826
938
|
case 19:
|
|
827
939
|
if (this.store.order && typeof ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.enableTempOrderPersist) === 'boolean') {
|
|
828
940
|
this.store.order.setEnableTempOrderPersist(this.otherParams.enableTempOrderPersist);
|
|
829
941
|
}
|
|
830
|
-
|
|
942
|
+
_context8.next = 22;
|
|
831
943
|
return this.getPaymentMethodsAsync();
|
|
832
944
|
case 22:
|
|
945
|
+
this.registerServerOrderChangeSync();
|
|
833
946
|
this.core.effects.emit("".concat(this.name, ":onInited"), {});
|
|
834
|
-
case
|
|
947
|
+
case 24:
|
|
835
948
|
case "end":
|
|
836
|
-
return
|
|
949
|
+
return _context8.stop();
|
|
837
950
|
}
|
|
838
|
-
},
|
|
951
|
+
}, _callee8, this);
|
|
839
952
|
}));
|
|
840
|
-
function initialize(
|
|
953
|
+
function initialize(_x8) {
|
|
841
954
|
return _initialize.apply(this, arguments);
|
|
842
955
|
}
|
|
843
956
|
return initialize;
|
|
@@ -845,14 +958,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
845
958
|
}, {
|
|
846
959
|
key: "destroy",
|
|
847
960
|
value: function () {
|
|
848
|
-
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
849
|
-
var
|
|
850
|
-
|
|
851
|
-
|
|
961
|
+
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
962
|
+
var _this$serverOrderChan2,
|
|
963
|
+
_this7 = this;
|
|
964
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
965
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
852
966
|
case 0:
|
|
967
|
+
(_this$serverOrderChan2 = this.serverOrderChangeUnsubscribe) === null || _this$serverOrderChan2 === void 0 || _this$serverOrderChan2.call(this);
|
|
968
|
+
this.serverOrderChangeUnsubscribe = null;
|
|
853
969
|
Object.keys(this.store).forEach(function (key) {
|
|
854
|
-
if (
|
|
855
|
-
var sub =
|
|
970
|
+
if (_this7.reusedSharedSubModuleNames.has(key)) return;
|
|
971
|
+
var sub = _this7.store[key];
|
|
856
972
|
if (sub && typeof sub.destroy === 'function') {
|
|
857
973
|
try {
|
|
858
974
|
sub.destroy();
|
|
@@ -862,15 +978,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
862
978
|
}
|
|
863
979
|
});
|
|
864
980
|
this.currentSalesDetail = null;
|
|
865
|
-
|
|
981
|
+
_context9.next = 6;
|
|
866
982
|
return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
|
|
867
|
-
case
|
|
983
|
+
case 6:
|
|
868
984
|
_get(_getPrototypeOf(BaseSalesImpl.prototype), "destroy", this).call(this);
|
|
869
|
-
case
|
|
985
|
+
case 7:
|
|
870
986
|
case "end":
|
|
871
|
-
return
|
|
987
|
+
return _context9.stop();
|
|
872
988
|
}
|
|
873
|
-
},
|
|
989
|
+
}, _callee9, this);
|
|
874
990
|
}));
|
|
875
991
|
function destroy() {
|
|
876
992
|
return _destroy.apply(this, arguments);
|
|
@@ -887,77 +1003,82 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
887
1003
|
}, {
|
|
888
1004
|
key: "loadSalesDetail",
|
|
889
1005
|
value: (function () {
|
|
890
|
-
var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
891
|
-
var
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
while (1) switch (_context8.prev = _context8.next) {
|
|
1006
|
+
var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(orderIdOrParams) {
|
|
1007
|
+
var _ref15, _ref16, _ref17, _ref18, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, remoteRecord, currentTempOrder, record, sales;
|
|
1008
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
1009
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
895
1010
|
case 0:
|
|
896
1011
|
if (this.store.order) {
|
|
897
|
-
|
|
1012
|
+
_context10.next = 2;
|
|
898
1013
|
break;
|
|
899
1014
|
}
|
|
900
1015
|
throw new Error('order 模块未初始化');
|
|
901
1016
|
case 2:
|
|
1017
|
+
this.salesDetailLoadInFlight = true;
|
|
1018
|
+
_context10.prev = 3;
|
|
902
1019
|
params = _typeof(orderIdOrParams) === 'object' ? orderIdOrParams : {
|
|
903
1020
|
orderId: orderIdOrParams
|
|
904
1021
|
};
|
|
905
1022
|
externalSaleNumber = params.externalSaleNumber || params.external_sale_number;
|
|
906
1023
|
preloadedSalesDetail = params.preloadedSalesDetail;
|
|
907
|
-
lookup = (
|
|
1024
|
+
lookup = (_ref15 = (_ref16 = (_ref17 = (_ref18 = (_params$orderId = params.orderId) !== null && _params$orderId !== void 0 ? _params$orderId : externalSaleNumber) !== null && _ref18 !== void 0 ? _ref18 : params.orderNumber) !== null && _ref17 !== void 0 ? _ref17 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_id) !== null && _ref16 !== void 0 ? _ref16 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.external_sale_number) !== null && _ref15 !== void 0 ? _ref15 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_number;
|
|
908
1025
|
if (!(!preloadedSalesDetail && (lookup === undefined || lookup === null || lookup === ''))) {
|
|
909
|
-
|
|
1026
|
+
_context10.next = 10;
|
|
910
1027
|
break;
|
|
911
1028
|
}
|
|
912
1029
|
throw new Error('加载销售详情需要 orderId、externalSaleNumber 或 orderNumber');
|
|
913
|
-
case
|
|
1030
|
+
case 10:
|
|
914
1031
|
if (!(preloadedSalesDetail !== null && preloadedSalesDetail !== void 0)) {
|
|
915
|
-
|
|
1032
|
+
_context10.next = 14;
|
|
916
1033
|
break;
|
|
917
1034
|
}
|
|
918
|
-
|
|
919
|
-
|
|
1035
|
+
_context10.t0 = preloadedSalesDetail;
|
|
1036
|
+
_context10.next = 17;
|
|
920
1037
|
break;
|
|
921
|
-
case
|
|
922
|
-
|
|
1038
|
+
case 14:
|
|
1039
|
+
_context10.next = 16;
|
|
923
1040
|
return this.store.order.getSalesOrderByLookup({
|
|
924
1041
|
lookup: lookup,
|
|
925
1042
|
forceRemote: params.forceRemote
|
|
926
1043
|
});
|
|
927
|
-
case
|
|
928
|
-
|
|
929
|
-
case
|
|
930
|
-
loadedRecord =
|
|
1044
|
+
case 16:
|
|
1045
|
+
_context10.t0 = _context10.sent;
|
|
1046
|
+
case 17:
|
|
1047
|
+
loadedRecord = _context10.t0;
|
|
931
1048
|
if (!(!preloadedSalesDetail && (!loadedRecord || loadedRecord.code !== 200))) {
|
|
932
|
-
|
|
1049
|
+
_context10.next = 21;
|
|
933
1050
|
break;
|
|
934
1051
|
}
|
|
935
1052
|
message = loadedRecord && (loadedRecord.message || loadedRecord.msg) || "\u52A0\u8F7D\u9500\u552E\u8BE6\u60C5\u5931\u8D25: ".concat(lookup);
|
|
936
1053
|
throw new Error(message);
|
|
937
|
-
case
|
|
1054
|
+
case 21:
|
|
938
1055
|
remoteRecord = preloadedSalesDetail !== null && preloadedSalesDetail !== void 0 ? preloadedSalesDetail : loadedRecord.data;
|
|
939
1056
|
currentTempOrder = params.merge ? this.store.order.getTempOrder() : null;
|
|
940
1057
|
record = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder, remoteRecord) : remoteRecord;
|
|
941
|
-
|
|
1058
|
+
_context10.next = 26;
|
|
942
1059
|
return this.store.order.hydrateTempOrderFromRecord(record, {
|
|
943
1060
|
recalcOnHydrate: false
|
|
944
1061
|
});
|
|
945
|
-
case
|
|
946
|
-
sales =
|
|
1062
|
+
case 26:
|
|
1063
|
+
sales = _context10.sent;
|
|
947
1064
|
this.currentSalesDetail = sales;
|
|
948
|
-
|
|
1065
|
+
_context10.next = 30;
|
|
949
1066
|
return this.core.effects.emit("".concat(this.name, ":onSalesOrderLoaded"), {
|
|
950
1067
|
sales: sales
|
|
951
1068
|
});
|
|
952
|
-
case
|
|
953
|
-
return
|
|
954
|
-
case
|
|
1069
|
+
case 30:
|
|
1070
|
+
return _context10.abrupt("return", sales);
|
|
1071
|
+
case 31:
|
|
1072
|
+
_context10.prev = 31;
|
|
1073
|
+
this.salesDetailLoadInFlight = false;
|
|
1074
|
+
return _context10.finish(31);
|
|
1075
|
+
case 34:
|
|
955
1076
|
case "end":
|
|
956
|
-
return
|
|
1077
|
+
return _context10.stop();
|
|
957
1078
|
}
|
|
958
|
-
},
|
|
1079
|
+
}, _callee10, this, [[3,, 31, 34]]);
|
|
959
1080
|
}));
|
|
960
|
-
function loadSalesDetail(
|
|
1081
|
+
function loadSalesDetail(_x9) {
|
|
961
1082
|
return _loadSalesDetail.apply(this, arguments);
|
|
962
1083
|
}
|
|
963
1084
|
return loadSalesDetail;
|
|
@@ -1030,41 +1151,41 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1030
1151
|
}, {
|
|
1031
1152
|
key: "getTempOrder",
|
|
1032
1153
|
value: function getTempOrder() {
|
|
1033
|
-
var _this$store$
|
|
1034
|
-
var result = ((_this$store$
|
|
1154
|
+
var _this$store$order3;
|
|
1155
|
+
var result = ((_this$store$order3 = this.store.order) === null || _this$store$order3 === void 0 ? void 0 : _this$store$order3.getTempOrder()) || null;
|
|
1035
1156
|
return result;
|
|
1036
1157
|
}
|
|
1037
1158
|
}, {
|
|
1038
1159
|
key: "replaceTempOrder",
|
|
1039
1160
|
value: function () {
|
|
1040
|
-
var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1161
|
+
var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(tempOrder) {
|
|
1041
1162
|
var nextTempOrder;
|
|
1042
|
-
return _regeneratorRuntime().wrap(function
|
|
1043
|
-
while (1) switch (
|
|
1163
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
1164
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
1044
1165
|
case 0:
|
|
1045
1166
|
if (this.store.order) {
|
|
1046
|
-
|
|
1167
|
+
_context11.next = 2;
|
|
1047
1168
|
break;
|
|
1048
1169
|
}
|
|
1049
1170
|
throw new Error('order 模块未初始化');
|
|
1050
1171
|
case 2:
|
|
1051
|
-
|
|
1172
|
+
_context11.next = 4;
|
|
1052
1173
|
return this.store.order.replaceTempOrder(tempOrder);
|
|
1053
1174
|
case 4:
|
|
1054
|
-
nextTempOrder =
|
|
1055
|
-
|
|
1175
|
+
nextTempOrder = _context11.sent;
|
|
1176
|
+
_context11.next = 7;
|
|
1056
1177
|
return this.effectsEmit('onTempOrderReplaced', {
|
|
1057
1178
|
tempOrder: nextTempOrder
|
|
1058
1179
|
});
|
|
1059
1180
|
case 7:
|
|
1060
|
-
return
|
|
1181
|
+
return _context11.abrupt("return", nextTempOrder);
|
|
1061
1182
|
case 8:
|
|
1062
1183
|
case "end":
|
|
1063
|
-
return
|
|
1184
|
+
return _context11.stop();
|
|
1064
1185
|
}
|
|
1065
|
-
},
|
|
1186
|
+
}, _callee11, this);
|
|
1066
1187
|
}));
|
|
1067
|
-
function replaceTempOrder(
|
|
1188
|
+
function replaceTempOrder(_x10) {
|
|
1068
1189
|
return _replaceTempOrder.apply(this, arguments);
|
|
1069
1190
|
}
|
|
1070
1191
|
return replaceTempOrder;
|
|
@@ -1162,40 +1283,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1162
1283
|
}, {
|
|
1163
1284
|
key: "addNewOrder",
|
|
1164
1285
|
value: function () {
|
|
1165
|
-
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1286
|
+
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
1166
1287
|
var tempOrder;
|
|
1167
|
-
return _regeneratorRuntime().wrap(function
|
|
1168
|
-
while (1) switch (
|
|
1288
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
1289
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1169
1290
|
case 0:
|
|
1170
|
-
|
|
1291
|
+
_context12.prev = 0;
|
|
1171
1292
|
if (this.store.order) {
|
|
1172
|
-
|
|
1293
|
+
_context12.next = 3;
|
|
1173
1294
|
break;
|
|
1174
1295
|
}
|
|
1175
1296
|
throw new Error('order 模块未初始化');
|
|
1176
1297
|
case 3:
|
|
1177
|
-
|
|
1298
|
+
_context12.next = 5;
|
|
1178
1299
|
return this.store.order.addNewOrder();
|
|
1179
1300
|
case 5:
|
|
1180
|
-
tempOrder =
|
|
1301
|
+
tempOrder = _context12.sent;
|
|
1181
1302
|
if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
|
|
1182
|
-
|
|
1303
|
+
_context12.next = 10;
|
|
1183
1304
|
break;
|
|
1184
1305
|
}
|
|
1185
1306
|
this.store.order.persistTempOrder();
|
|
1186
|
-
|
|
1307
|
+
_context12.next = 10;
|
|
1187
1308
|
return this.store.order.saveDraft();
|
|
1188
1309
|
case 10:
|
|
1189
|
-
return
|
|
1310
|
+
return _context12.abrupt("return", tempOrder);
|
|
1190
1311
|
case 13:
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
throw
|
|
1312
|
+
_context12.prev = 13;
|
|
1313
|
+
_context12.t0 = _context12["catch"](0);
|
|
1314
|
+
throw _context12.t0;
|
|
1194
1315
|
case 16:
|
|
1195
1316
|
case "end":
|
|
1196
|
-
return
|
|
1317
|
+
return _context12.stop();
|
|
1197
1318
|
}
|
|
1198
|
-
},
|
|
1319
|
+
}, _callee12, this, [[0, 13]]);
|
|
1199
1320
|
}));
|
|
1200
1321
|
function addNewOrder() {
|
|
1201
1322
|
return _addNewOrder.apply(this, arguments);
|
|
@@ -1205,22 +1326,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1205
1326
|
}, {
|
|
1206
1327
|
key: "saveDraft",
|
|
1207
1328
|
value: function () {
|
|
1208
|
-
var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1209
|
-
return _regeneratorRuntime().wrap(function
|
|
1210
|
-
while (1) switch (
|
|
1329
|
+
var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
1330
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
1331
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1211
1332
|
case 0:
|
|
1212
1333
|
if (this.store.order) {
|
|
1213
|
-
|
|
1334
|
+
_context13.next = 2;
|
|
1214
1335
|
break;
|
|
1215
1336
|
}
|
|
1216
1337
|
throw new Error('order 模块未初始化');
|
|
1217
1338
|
case 2:
|
|
1218
|
-
return
|
|
1339
|
+
return _context13.abrupt("return", this.store.order.saveDraft());
|
|
1219
1340
|
case 3:
|
|
1220
1341
|
case "end":
|
|
1221
|
-
return
|
|
1342
|
+
return _context13.stop();
|
|
1222
1343
|
}
|
|
1223
|
-
},
|
|
1344
|
+
}, _callee13, this);
|
|
1224
1345
|
}));
|
|
1225
1346
|
function saveDraft() {
|
|
1226
1347
|
return _saveDraft.apply(this, arguments);
|
|
@@ -1231,14 +1352,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1231
1352
|
}, {
|
|
1232
1353
|
key: "restoreOrder",
|
|
1233
1354
|
value: function () {
|
|
1234
|
-
var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1355
|
+
var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
1235
1356
|
var tempOrder;
|
|
1236
|
-
return _regeneratorRuntime().wrap(function
|
|
1237
|
-
while (1) switch (
|
|
1357
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1358
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1238
1359
|
case 0:
|
|
1239
|
-
|
|
1360
|
+
_context14.prev = 0;
|
|
1240
1361
|
if (this.store.order) {
|
|
1241
|
-
|
|
1362
|
+
_context14.next = 3;
|
|
1242
1363
|
break;
|
|
1243
1364
|
}
|
|
1244
1365
|
throw new Error('scanOrder 解决方案需要 order 模块支持');
|
|
@@ -1248,29 +1369,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1248
1369
|
this.currentSalesDetail = null;
|
|
1249
1370
|
this.discountConfigCacheKey = null;
|
|
1250
1371
|
this.hasManualDiscountSelection = false;
|
|
1251
|
-
|
|
1372
|
+
_context14.next = 9;
|
|
1252
1373
|
return this.effectsEmit('onTempOrderReplaced', {
|
|
1253
1374
|
tempOrder: tempOrder
|
|
1254
1375
|
});
|
|
1255
1376
|
case 9:
|
|
1256
1377
|
if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
|
|
1257
|
-
|
|
1378
|
+
_context14.next = 13;
|
|
1258
1379
|
break;
|
|
1259
1380
|
}
|
|
1260
1381
|
this.store.order.persistTempOrder();
|
|
1261
|
-
|
|
1382
|
+
_context14.next = 13;
|
|
1262
1383
|
return this.store.order.saveDraft();
|
|
1263
1384
|
case 13:
|
|
1264
|
-
return
|
|
1385
|
+
return _context14.abrupt("return", tempOrder);
|
|
1265
1386
|
case 16:
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
throw
|
|
1387
|
+
_context14.prev = 16;
|
|
1388
|
+
_context14.t0 = _context14["catch"](0);
|
|
1389
|
+
throw _context14.t0;
|
|
1269
1390
|
case 19:
|
|
1270
1391
|
case "end":
|
|
1271
|
-
return
|
|
1392
|
+
return _context14.stop();
|
|
1272
1393
|
}
|
|
1273
|
-
},
|
|
1394
|
+
}, _callee14, this, [[0, 16]]);
|
|
1274
1395
|
}));
|
|
1275
1396
|
function restoreOrder() {
|
|
1276
1397
|
return _restoreOrder.apply(this, arguments);
|
|
@@ -1284,22 +1405,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1284
1405
|
}, {
|
|
1285
1406
|
key: "clearOrderCartLines",
|
|
1286
1407
|
value: (function () {
|
|
1287
|
-
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1408
|
+
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
1288
1409
|
var tempOrder;
|
|
1289
|
-
return _regeneratorRuntime().wrap(function
|
|
1290
|
-
while (1) switch (
|
|
1410
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1411
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1291
1412
|
case 0:
|
|
1292
|
-
|
|
1413
|
+
_context15.prev = 0;
|
|
1293
1414
|
if (this.store.order) {
|
|
1294
|
-
|
|
1415
|
+
_context15.next = 3;
|
|
1295
1416
|
break;
|
|
1296
1417
|
}
|
|
1297
1418
|
throw new Error('order 模块未初始化');
|
|
1298
1419
|
case 3:
|
|
1299
|
-
|
|
1420
|
+
_context15.next = 5;
|
|
1300
1421
|
return this.store.order.clearOrderCartLines();
|
|
1301
1422
|
case 5:
|
|
1302
|
-
tempOrder =
|
|
1423
|
+
tempOrder = _context15.sent;
|
|
1303
1424
|
if (this.currentSalesDetail) {
|
|
1304
1425
|
this.currentSalesDetail = _objectSpread(_objectSpread({}, this.currentSalesDetail), {}, {
|
|
1305
1426
|
products: [],
|
|
@@ -1309,29 +1430,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1309
1430
|
discount_list: []
|
|
1310
1431
|
});
|
|
1311
1432
|
}
|
|
1312
|
-
|
|
1433
|
+
_context15.next = 9;
|
|
1313
1434
|
return this.effectsEmit('onTempOrderReplaced', {
|
|
1314
1435
|
tempOrder: tempOrder
|
|
1315
1436
|
});
|
|
1316
1437
|
case 9:
|
|
1317
1438
|
if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
|
|
1318
|
-
|
|
1439
|
+
_context15.next = 13;
|
|
1319
1440
|
break;
|
|
1320
1441
|
}
|
|
1321
1442
|
this.store.order.persistTempOrder();
|
|
1322
|
-
|
|
1443
|
+
_context15.next = 13;
|
|
1323
1444
|
return this.store.order.saveDraft();
|
|
1324
1445
|
case 13:
|
|
1325
|
-
return
|
|
1446
|
+
return _context15.abrupt("return", tempOrder);
|
|
1326
1447
|
case 16:
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
throw
|
|
1448
|
+
_context15.prev = 16;
|
|
1449
|
+
_context15.t0 = _context15["catch"](0);
|
|
1450
|
+
throw _context15.t0;
|
|
1330
1451
|
case 19:
|
|
1331
1452
|
case "end":
|
|
1332
|
-
return
|
|
1453
|
+
return _context15.stop();
|
|
1333
1454
|
}
|
|
1334
|
-
},
|
|
1455
|
+
}, _callee15, this, [[0, 16]]);
|
|
1335
1456
|
}));
|
|
1336
1457
|
function clearOrderCartLines() {
|
|
1337
1458
|
return _clearOrderCartLines.apply(this, arguments);
|
|
@@ -1348,32 +1469,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1348
1469
|
}, {
|
|
1349
1470
|
key: "getSummary",
|
|
1350
1471
|
value: function () {
|
|
1351
|
-
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1472
|
+
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
1352
1473
|
var summary;
|
|
1353
|
-
return _regeneratorRuntime().wrap(function
|
|
1354
|
-
while (1) switch (
|
|
1474
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1475
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1355
1476
|
case 0:
|
|
1356
|
-
|
|
1477
|
+
_context16.prev = 0;
|
|
1357
1478
|
if (this.store.order) {
|
|
1358
|
-
|
|
1479
|
+
_context16.next = 3;
|
|
1359
1480
|
break;
|
|
1360
1481
|
}
|
|
1361
1482
|
throw new Error('order 模块未初始化');
|
|
1362
1483
|
case 3:
|
|
1363
|
-
|
|
1484
|
+
_context16.next = 5;
|
|
1364
1485
|
return this.store.order.getOrderSummary();
|
|
1365
1486
|
case 5:
|
|
1366
|
-
summary =
|
|
1367
|
-
return
|
|
1487
|
+
summary = _context16.sent;
|
|
1488
|
+
return _context16.abrupt("return", summary);
|
|
1368
1489
|
case 9:
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
throw
|
|
1490
|
+
_context16.prev = 9;
|
|
1491
|
+
_context16.t0 = _context16["catch"](0);
|
|
1492
|
+
throw _context16.t0;
|
|
1372
1493
|
case 12:
|
|
1373
1494
|
case "end":
|
|
1374
|
-
return
|
|
1495
|
+
return _context16.stop();
|
|
1375
1496
|
}
|
|
1376
|
-
},
|
|
1497
|
+
}, _callee16, this, [[0, 9]]);
|
|
1377
1498
|
}));
|
|
1378
1499
|
function getSummary() {
|
|
1379
1500
|
return _getSummary.apply(this, arguments);
|
|
@@ -1383,10 +1504,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1383
1504
|
}, {
|
|
1384
1505
|
key: "getHistoricalProductDiscountList",
|
|
1385
1506
|
value: function getHistoricalProductDiscountList(products) {
|
|
1386
|
-
var
|
|
1507
|
+
var _this8 = this;
|
|
1387
1508
|
var historyDiscountList = [];
|
|
1388
1509
|
products.forEach(function (item) {
|
|
1389
|
-
if (!
|
|
1510
|
+
if (!_this8.isPersistedOrderProduct(item)) return;
|
|
1390
1511
|
(item.discount_list || []).forEach(function (discount) {
|
|
1391
1512
|
var _discount$discount, _discount$metadata, _discount$discount2, _discount$discount3, _discount$discount4;
|
|
1392
1513
|
var discountId = ((_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) || discount.id;
|
|
@@ -1446,11 +1567,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1446
1567
|
}, {
|
|
1447
1568
|
key: "shouldSkipAutoApplyFetchedDiscountsInEditMode",
|
|
1448
1569
|
value: function shouldSkipAutoApplyFetchedDiscountsInEditMode(params) {
|
|
1449
|
-
var
|
|
1570
|
+
var _this9 = this;
|
|
1450
1571
|
if (params.discountAction !== 'edit') return false;
|
|
1451
1572
|
if (!params.products.length) return false;
|
|
1452
1573
|
var hasDraftProduct = params.products.some(function (product) {
|
|
1453
|
-
return !
|
|
1574
|
+
return !_this9.isPersistedOrderProduct(product);
|
|
1454
1575
|
});
|
|
1455
1576
|
if (hasDraftProduct) return false;
|
|
1456
1577
|
var hasSelectedDiscount = params.currentDiscountList.some(function (discount) {
|
|
@@ -1490,14 +1611,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1490
1611
|
}, {
|
|
1491
1612
|
key: "loadDiscountConfig",
|
|
1492
1613
|
value: function () {
|
|
1493
|
-
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1614
|
+
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(params) {
|
|
1494
1615
|
var _this$getOrderIdentit, _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _discountModule$getDi, _discountModule$getOr, _discountModule$getDi2;
|
|
1495
1616
|
var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, discountConfigCacheKey, preparedDiscountList, _discountModule$setOr, nextDiscountList, shouldSkipAutoApplyFetchedDiscounts, _summary, _tempOrder$holder, _orderStore$summary, holders, 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;
|
|
1496
|
-
return _regeneratorRuntime().wrap(function
|
|
1497
|
-
while (1) switch (
|
|
1617
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1618
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1498
1619
|
case 0:
|
|
1499
1620
|
if (this.store.order) {
|
|
1500
|
-
|
|
1621
|
+
_context17.next = 2;
|
|
1501
1622
|
break;
|
|
1502
1623
|
}
|
|
1503
1624
|
throw new Error('order 模块未初始化');
|
|
@@ -1517,18 +1638,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1517
1638
|
discountConfigCacheKey = [customerId, discountAction, Number(orderId) || 0].join(':');
|
|
1518
1639
|
preparedDiscountList = [];
|
|
1519
1640
|
if (!(customerId && customerId !== 1)) {
|
|
1520
|
-
|
|
1641
|
+
_context17.next = 25;
|
|
1521
1642
|
break;
|
|
1522
1643
|
}
|
|
1523
1644
|
if (!(this.discountConfigCacheKey === discountConfigCacheKey)) {
|
|
1524
|
-
|
|
1645
|
+
_context17.next = 19;
|
|
1525
1646
|
break;
|
|
1526
1647
|
}
|
|
1527
1648
|
preparedDiscountList = originalDiscountList;
|
|
1528
|
-
|
|
1649
|
+
_context17.next = 25;
|
|
1529
1650
|
break;
|
|
1530
1651
|
case 19:
|
|
1531
|
-
|
|
1652
|
+
_context17.next = 21;
|
|
1532
1653
|
return this.store.order.loadDiscountConfig({
|
|
1533
1654
|
customerId: customerId,
|
|
1534
1655
|
action: discountAction,
|
|
@@ -1536,23 +1657,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1536
1657
|
apply: false
|
|
1537
1658
|
});
|
|
1538
1659
|
case 21:
|
|
1539
|
-
preparedDiscountList =
|
|
1660
|
+
preparedDiscountList = _context17.sent;
|
|
1540
1661
|
this.discountConfigCacheKey = discountConfigCacheKey;
|
|
1541
|
-
|
|
1662
|
+
_context17.next = 25;
|
|
1542
1663
|
return discountModule === null || discountModule === void 0 || (_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, preparedDiscountList);
|
|
1543
1664
|
case 25:
|
|
1544
1665
|
if (!(hasManualDiscountSelection && currentDiscountList.length)) {
|
|
1545
|
-
|
|
1666
|
+
_context17.next = 27;
|
|
1546
1667
|
break;
|
|
1547
1668
|
}
|
|
1548
|
-
return
|
|
1669
|
+
return _context17.abrupt("return", {
|
|
1549
1670
|
productList: tempOrder.products || [],
|
|
1550
1671
|
discountList: currentDiscountList
|
|
1551
1672
|
});
|
|
1552
1673
|
case 27:
|
|
1553
1674
|
nextDiscountList = this.mergeHistoricalDiscountList(preparedDiscountList || (discountModule === null || discountModule === void 0 || (_discountModule$getDi2 = discountModule.getDiscountList) === null || _discountModule$getDi2 === void 0 ? void 0 : _discountModule$getDi2.call(discountModule)) || [], tempOrder.products || []);
|
|
1554
1675
|
nextDiscountList = this.mergeCurrentDiscountSelectionState(nextDiscountList, currentDiscountList);
|
|
1555
|
-
|
|
1676
|
+
_context17.next = 31;
|
|
1556
1677
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
1557
1678
|
case 31:
|
|
1558
1679
|
shouldSkipAutoApplyFetchedDiscounts = this.shouldSkipAutoApplyFetchedDiscountsInEditMode({
|
|
@@ -1562,17 +1683,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1562
1683
|
nextDiscountList: nextDiscountList
|
|
1563
1684
|
});
|
|
1564
1685
|
if (!shouldSkipAutoApplyFetchedDiscounts) {
|
|
1565
|
-
|
|
1686
|
+
_context17.next = 40;
|
|
1566
1687
|
break;
|
|
1567
1688
|
}
|
|
1568
|
-
|
|
1689
|
+
_context17.next = 35;
|
|
1569
1690
|
return this.store.order.recalculateSummary({
|
|
1570
1691
|
createIfMissing: true
|
|
1571
1692
|
});
|
|
1572
1693
|
case 35:
|
|
1573
|
-
_summary =
|
|
1694
|
+
_summary = _context17.sent;
|
|
1574
1695
|
this.store.order.persistTempOrder();
|
|
1575
|
-
|
|
1696
|
+
_context17.next = 39;
|
|
1576
1697
|
return this.effectsEmit('onDiscountApplied', {
|
|
1577
1698
|
productList: tempOrder.products || [],
|
|
1578
1699
|
discountList: nextDiscountList,
|
|
@@ -1580,13 +1701,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1580
1701
|
tempOrder: tempOrder
|
|
1581
1702
|
});
|
|
1582
1703
|
case 39:
|
|
1583
|
-
return
|
|
1704
|
+
return _context17.abrupt("return", {
|
|
1584
1705
|
productList: tempOrder.products || [],
|
|
1585
1706
|
discountList: nextDiscountList
|
|
1586
1707
|
});
|
|
1587
1708
|
case 40:
|
|
1588
1709
|
if (!rulesModule) {
|
|
1589
|
-
|
|
1710
|
+
_context17.next = 78;
|
|
1590
1711
|
break;
|
|
1591
1712
|
}
|
|
1592
1713
|
holders = ((_tempOrder$holder = tempOrder.holder) === null || _tempOrder$holder === void 0 ? void 0 : _tempOrder$holder.form_record) || [];
|
|
@@ -1608,21 +1729,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1608
1729
|
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
1609
1730
|
}
|
|
1610
1731
|
_iterator = _createForOfIteratorHelper(tempOrder.products || []);
|
|
1611
|
-
|
|
1732
|
+
_context17.prev = 47;
|
|
1612
1733
|
_iterator.s();
|
|
1613
1734
|
case 49:
|
|
1614
1735
|
if ((_step = _iterator.n()).done) {
|
|
1615
|
-
|
|
1736
|
+
_context17.next = 64;
|
|
1616
1737
|
break;
|
|
1617
1738
|
}
|
|
1618
1739
|
product = _step.value;
|
|
1619
1740
|
productUid = (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number;
|
|
1620
1741
|
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;
|
|
1621
1742
|
if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
|
|
1622
|
-
|
|
1743
|
+
_context17.next = 55;
|
|
1623
1744
|
break;
|
|
1624
1745
|
}
|
|
1625
|
-
return
|
|
1746
|
+
return _context17.abrupt("continue", 62);
|
|
1626
1747
|
case 55:
|
|
1627
1748
|
totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
|
|
1628
1749
|
return sum + Number(pd.amount || 0);
|
|
@@ -1640,41 +1761,41 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1640
1761
|
bundle: product.product_bundle
|
|
1641
1762
|
});
|
|
1642
1763
|
case 62:
|
|
1643
|
-
|
|
1764
|
+
_context17.next = 49;
|
|
1644
1765
|
break;
|
|
1645
1766
|
case 64:
|
|
1646
|
-
|
|
1767
|
+
_context17.next = 69;
|
|
1647
1768
|
break;
|
|
1648
1769
|
case 66:
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
_iterator.e(
|
|
1770
|
+
_context17.prev = 66;
|
|
1771
|
+
_context17.t0 = _context17["catch"](47);
|
|
1772
|
+
_iterator.e(_context17.t0);
|
|
1652
1773
|
case 69:
|
|
1653
|
-
|
|
1774
|
+
_context17.prev = 69;
|
|
1654
1775
|
_iterator.f();
|
|
1655
|
-
return
|
|
1776
|
+
return _context17.finish(69);
|
|
1656
1777
|
case 72:
|
|
1657
1778
|
if (!result.discountList) {
|
|
1658
|
-
|
|
1779
|
+
_context17.next = 78;
|
|
1659
1780
|
break;
|
|
1660
1781
|
}
|
|
1661
1782
|
nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
|
|
1662
1783
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
1663
|
-
|
|
1784
|
+
_context17.next = 77;
|
|
1664
1785
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
1665
1786
|
case 77:
|
|
1666
1787
|
tempOrder.discount_list = nextDiscountList.filter(function (discount) {
|
|
1667
1788
|
return discount.isSelected;
|
|
1668
1789
|
});
|
|
1669
1790
|
case 78:
|
|
1670
|
-
|
|
1791
|
+
_context17.next = 80;
|
|
1671
1792
|
return this.store.order.recalculateSummary({
|
|
1672
1793
|
createIfMissing: true
|
|
1673
1794
|
});
|
|
1674
1795
|
case 80:
|
|
1675
|
-
summary =
|
|
1796
|
+
summary = _context17.sent;
|
|
1676
1797
|
this.store.order.persistTempOrder();
|
|
1677
|
-
|
|
1798
|
+
_context17.next = 84;
|
|
1678
1799
|
return this.effectsEmit('onDiscountApplied', {
|
|
1679
1800
|
productList: tempOrder.products || [],
|
|
1680
1801
|
discountList: nextDiscountList,
|
|
@@ -1682,17 +1803,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1682
1803
|
tempOrder: tempOrder
|
|
1683
1804
|
});
|
|
1684
1805
|
case 84:
|
|
1685
|
-
return
|
|
1806
|
+
return _context17.abrupt("return", {
|
|
1686
1807
|
productList: tempOrder.products || [],
|
|
1687
1808
|
discountList: nextDiscountList
|
|
1688
1809
|
});
|
|
1689
1810
|
case 85:
|
|
1690
1811
|
case "end":
|
|
1691
|
-
return
|
|
1812
|
+
return _context17.stop();
|
|
1692
1813
|
}
|
|
1693
|
-
},
|
|
1814
|
+
}, _callee17, this, [[47, 66, 69, 72]]);
|
|
1694
1815
|
}));
|
|
1695
|
-
function loadDiscountConfig(
|
|
1816
|
+
function loadDiscountConfig(_x11) {
|
|
1696
1817
|
return _loadDiscountConfig.apply(this, arguments);
|
|
1697
1818
|
}
|
|
1698
1819
|
return loadDiscountConfig;
|
|
@@ -1700,14 +1821,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1700
1821
|
}, {
|
|
1701
1822
|
key: "bestDiscount",
|
|
1702
1823
|
value: function () {
|
|
1703
|
-
var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1824
|
+
var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(cb) {
|
|
1704
1825
|
var _discountModule$getOr2, _discountModule$getDi3;
|
|
1705
1826
|
var tempOrder, orderStore, discountModule, rulesModule, originalDiscountList, currentDiscountList, nextDiscountList, result, _tempOrder$holder2, _orderStore$summary2, holders, orderTotalAmount;
|
|
1706
|
-
return _regeneratorRuntime().wrap(function
|
|
1707
|
-
while (1) switch (
|
|
1827
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1828
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1708
1829
|
case 0:
|
|
1709
1830
|
if (this.store.order) {
|
|
1710
|
-
|
|
1831
|
+
_context18.next = 2;
|
|
1711
1832
|
break;
|
|
1712
1833
|
}
|
|
1713
1834
|
throw new Error('order 模块未初始化');
|
|
@@ -1723,11 +1844,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1723
1844
|
productList: tempOrder.products || [],
|
|
1724
1845
|
discountList: nextDiscountList
|
|
1725
1846
|
};
|
|
1726
|
-
|
|
1847
|
+
_context18.next = 12;
|
|
1727
1848
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
1728
1849
|
case 12:
|
|
1729
1850
|
if (!rulesModule) {
|
|
1730
|
-
|
|
1851
|
+
_context18.next = 25;
|
|
1731
1852
|
break;
|
|
1732
1853
|
}
|
|
1733
1854
|
holders = ((_tempOrder$holder2 = tempOrder.holder) === null || _tempOrder$holder2 === void 0 ? void 0 : _tempOrder$holder2.form_record) || [];
|
|
@@ -1746,12 +1867,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1746
1867
|
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
1747
1868
|
}
|
|
1748
1869
|
if (!result.discountList) {
|
|
1749
|
-
|
|
1870
|
+
_context18.next = 25;
|
|
1750
1871
|
break;
|
|
1751
1872
|
}
|
|
1752
1873
|
nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
|
|
1753
1874
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
1754
|
-
|
|
1875
|
+
_context18.next = 23;
|
|
1755
1876
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
1756
1877
|
case 23:
|
|
1757
1878
|
tempOrder.discount_list = nextDiscountList.filter(function (discount) {
|
|
@@ -1762,21 +1883,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1762
1883
|
discountList: nextDiscountList
|
|
1763
1884
|
};
|
|
1764
1885
|
case 25:
|
|
1765
|
-
|
|
1886
|
+
_context18.next = 27;
|
|
1766
1887
|
return this.store.order.recalculateSummary({
|
|
1767
1888
|
createIfMissing: true
|
|
1768
1889
|
});
|
|
1769
1890
|
case 27:
|
|
1770
1891
|
this.store.order.persistTempOrder();
|
|
1771
1892
|
cb === null || cb === void 0 || cb(result);
|
|
1772
|
-
return
|
|
1893
|
+
return _context18.abrupt("return", result);
|
|
1773
1894
|
case 30:
|
|
1774
1895
|
case "end":
|
|
1775
|
-
return
|
|
1896
|
+
return _context18.stop();
|
|
1776
1897
|
}
|
|
1777
|
-
},
|
|
1898
|
+
}, _callee18, this);
|
|
1778
1899
|
}));
|
|
1779
|
-
function bestDiscount(
|
|
1900
|
+
function bestDiscount(_x12) {
|
|
1780
1901
|
return _bestDiscount.apply(this, arguments);
|
|
1781
1902
|
}
|
|
1782
1903
|
return bestDiscount;
|
|
@@ -1790,49 +1911,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1790
1911
|
}, {
|
|
1791
1912
|
key: "scanPromotionCode",
|
|
1792
1913
|
value: function () {
|
|
1793
|
-
var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1914
|
+
var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(code, customerId) {
|
|
1794
1915
|
var raw;
|
|
1795
|
-
return _regeneratorRuntime().wrap(function
|
|
1796
|
-
while (1) switch (
|
|
1916
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1917
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1797
1918
|
case 0:
|
|
1798
|
-
|
|
1919
|
+
_context19.prev = 0;
|
|
1799
1920
|
if (this.store.order) {
|
|
1800
|
-
|
|
1921
|
+
_context19.next = 3;
|
|
1801
1922
|
break;
|
|
1802
1923
|
}
|
|
1803
1924
|
throw new Error('order 模块未初始化');
|
|
1804
1925
|
case 3:
|
|
1805
|
-
|
|
1926
|
+
_context19.next = 5;
|
|
1806
1927
|
return this.store.order.scanCode(code, customerId);
|
|
1807
1928
|
case 5:
|
|
1808
|
-
raw =
|
|
1929
|
+
raw = _context19.sent;
|
|
1809
1930
|
if (!raw.isAvailable) {
|
|
1810
|
-
|
|
1931
|
+
_context19.next = 10;
|
|
1811
1932
|
break;
|
|
1812
1933
|
}
|
|
1813
|
-
|
|
1934
|
+
_context19.next = 9;
|
|
1814
1935
|
return this.store.order.recalculateSummary({
|
|
1815
1936
|
createIfMissing: true
|
|
1816
1937
|
});
|
|
1817
1938
|
case 9:
|
|
1818
1939
|
this.store.order.persistTempOrder();
|
|
1819
1940
|
case 10:
|
|
1820
|
-
return
|
|
1941
|
+
return _context19.abrupt("return", {
|
|
1821
1942
|
isAvailable: raw.isAvailable,
|
|
1822
1943
|
type: raw.type,
|
|
1823
1944
|
unavailableReason: raw.unavailableReason
|
|
1824
1945
|
});
|
|
1825
1946
|
case 13:
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
throw
|
|
1947
|
+
_context19.prev = 13;
|
|
1948
|
+
_context19.t0 = _context19["catch"](0);
|
|
1949
|
+
throw _context19.t0;
|
|
1829
1950
|
case 16:
|
|
1830
1951
|
case "end":
|
|
1831
|
-
return
|
|
1952
|
+
return _context19.stop();
|
|
1832
1953
|
}
|
|
1833
|
-
},
|
|
1954
|
+
}, _callee19, this, [[0, 13]]);
|
|
1834
1955
|
}));
|
|
1835
|
-
function scanPromotionCode(
|
|
1956
|
+
function scanPromotionCode(_x13, _x14) {
|
|
1836
1957
|
return _scanPromotionCode.apply(this, arguments);
|
|
1837
1958
|
}
|
|
1838
1959
|
return scanPromotionCode;
|
|
@@ -1840,14 +1961,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1840
1961
|
}, {
|
|
1841
1962
|
key: "setDiscountSelected",
|
|
1842
1963
|
value: function () {
|
|
1843
|
-
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1964
|
+
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
|
|
1844
1965
|
var _tempOrder$holder3, list, updated, tempOrder, orderStore, discountModule, rulesModule, holders, 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;
|
|
1845
|
-
return _regeneratorRuntime().wrap(function
|
|
1846
|
-
while (1) switch (
|
|
1966
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1967
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1847
1968
|
case 0:
|
|
1848
|
-
|
|
1969
|
+
_context20.prev = 0;
|
|
1849
1970
|
if (this.store.order) {
|
|
1850
|
-
|
|
1971
|
+
_context20.next = 3;
|
|
1851
1972
|
break;
|
|
1852
1973
|
}
|
|
1853
1974
|
throw new Error('order 模块未初始化');
|
|
@@ -1866,7 +1987,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1866
1987
|
rulesModule = orderStore.rules;
|
|
1867
1988
|
holders = ((_tempOrder$holder3 = tempOrder.holder) === null || _tempOrder$holder3 === void 0 ? void 0 : _tempOrder$holder3.form_record) || [];
|
|
1868
1989
|
nextDiscountList = updated;
|
|
1869
|
-
|
|
1990
|
+
_context20.next = 14;
|
|
1870
1991
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(updated);
|
|
1871
1992
|
case 14:
|
|
1872
1993
|
if (rulesModule) {
|
|
@@ -1929,29 +2050,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1929
2050
|
});
|
|
1930
2051
|
};
|
|
1931
2052
|
_iterator3 = _createForOfIteratorHelper(tempOrder.products);
|
|
1932
|
-
|
|
2053
|
+
_context20.prev = 18;
|
|
1933
2054
|
_iterator3.s();
|
|
1934
2055
|
case 20:
|
|
1935
2056
|
if ((_step3 = _iterator3.n()).done) {
|
|
1936
|
-
|
|
2057
|
+
_context20.next = 37;
|
|
1937
2058
|
break;
|
|
1938
2059
|
}
|
|
1939
2060
|
product = _step3.value;
|
|
1940
2061
|
productUid = (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.unique_identification_number;
|
|
1941
2062
|
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;
|
|
1942
2063
|
if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
|
|
1943
|
-
|
|
2064
|
+
_context20.next = 26;
|
|
1944
2065
|
break;
|
|
1945
2066
|
}
|
|
1946
|
-
return
|
|
2067
|
+
return _context20.abrupt("continue", 35);
|
|
1947
2068
|
case 26:
|
|
1948
2069
|
product.discount_list = filterSelectedDiscountDetails(product.discount_list);
|
|
1949
2070
|
if (Array.isArray(product.product_bundle)) {
|
|
1950
2071
|
product.product_bundle = product.product_bundle.map(function (bundle) {
|
|
1951
|
-
var
|
|
2072
|
+
var _ref19, _bundle$original_pric;
|
|
1952
2073
|
var nextBundleDiscountList = filterSelectedDiscountDetails(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list);
|
|
1953
2074
|
var shouldRestoreBundlePrice = nextBundleDiscountList.length === 0;
|
|
1954
|
-
var restoredBundlePrice = (
|
|
2075
|
+
var restoredBundlePrice = (_ref19 = (_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 && _ref19 !== void 0 ? _ref19 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
|
|
1955
2076
|
return _objectSpread(_objectSpread(_objectSpread({}, bundle), shouldRestoreBundlePrice ? {
|
|
1956
2077
|
price: restoredBundlePrice,
|
|
1957
2078
|
bundle_selling_price: restoredBundlePrice
|
|
@@ -1979,28 +2100,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1979
2100
|
bundle: product.product_bundle
|
|
1980
2101
|
});
|
|
1981
2102
|
case 35:
|
|
1982
|
-
|
|
2103
|
+
_context20.next = 20;
|
|
1983
2104
|
break;
|
|
1984
2105
|
case 37:
|
|
1985
|
-
|
|
2106
|
+
_context20.next = 42;
|
|
1986
2107
|
break;
|
|
1987
2108
|
case 39:
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
_iterator3.e(
|
|
2109
|
+
_context20.prev = 39;
|
|
2110
|
+
_context20.t0 = _context20["catch"](18);
|
|
2111
|
+
_iterator3.e(_context20.t0);
|
|
1991
2112
|
case 42:
|
|
1992
|
-
|
|
2113
|
+
_context20.prev = 42;
|
|
1993
2114
|
_iterator3.f();
|
|
1994
|
-
return
|
|
2115
|
+
return _context20.finish(42);
|
|
1995
2116
|
case 45:
|
|
1996
2117
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
1997
|
-
|
|
2118
|
+
_context20.next = 48;
|
|
1998
2119
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
1999
2120
|
case 48:
|
|
2000
2121
|
tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
|
|
2001
2122
|
return d.isSelected;
|
|
2002
2123
|
});
|
|
2003
|
-
|
|
2124
|
+
_context20.next = 51;
|
|
2004
2125
|
return this.store.order.recalculateSummary({
|
|
2005
2126
|
createIfMissing: true
|
|
2006
2127
|
});
|
|
@@ -2012,19 +2133,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2012
2133
|
selectedDiscountList: tempOrder.discount_list,
|
|
2013
2134
|
tempOrder: tempOrder
|
|
2014
2135
|
});
|
|
2015
|
-
|
|
2136
|
+
_context20.next = 58;
|
|
2016
2137
|
break;
|
|
2017
2138
|
case 55:
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
throw
|
|
2139
|
+
_context20.prev = 55;
|
|
2140
|
+
_context20.t1 = _context20["catch"](0);
|
|
2141
|
+
throw _context20.t1;
|
|
2021
2142
|
case 58:
|
|
2022
2143
|
case "end":
|
|
2023
|
-
return
|
|
2144
|
+
return _context20.stop();
|
|
2024
2145
|
}
|
|
2025
|
-
},
|
|
2146
|
+
}, _callee20, this, [[0, 55], [18, 39, 42, 45]]);
|
|
2026
2147
|
}));
|
|
2027
|
-
function setDiscountSelected(
|
|
2148
|
+
function setDiscountSelected(_x15) {
|
|
2028
2149
|
return _setDiscountSelected.apply(this, arguments);
|
|
2029
2150
|
}
|
|
2030
2151
|
return setDiscountSelected;
|
|
@@ -2032,23 +2153,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2032
2153
|
}, {
|
|
2033
2154
|
key: "applyDiscountCalculationResult",
|
|
2034
2155
|
value: function () {
|
|
2035
|
-
var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2156
|
+
var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(result) {
|
|
2036
2157
|
var tempOrder, orderStore, discountModule;
|
|
2037
|
-
return _regeneratorRuntime().wrap(function
|
|
2038
|
-
while (1) switch (
|
|
2158
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
2159
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
2039
2160
|
case 0:
|
|
2040
|
-
|
|
2161
|
+
_context21.prev = 0;
|
|
2041
2162
|
if (this.store.order) {
|
|
2042
|
-
|
|
2163
|
+
_context21.next = 3;
|
|
2043
2164
|
break;
|
|
2044
2165
|
}
|
|
2045
2166
|
throw new Error('order 模块未初始化');
|
|
2046
2167
|
case 3:
|
|
2047
2168
|
if (result) {
|
|
2048
|
-
|
|
2169
|
+
_context21.next = 5;
|
|
2049
2170
|
break;
|
|
2050
2171
|
}
|
|
2051
|
-
return
|
|
2172
|
+
return _context21.abrupt("return");
|
|
2052
2173
|
case 5:
|
|
2053
2174
|
tempOrder = this.store.order.ensureTempOrder();
|
|
2054
2175
|
orderStore = this.store.order.store || {};
|
|
@@ -2057,36 +2178,36 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2057
2178
|
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
2058
2179
|
}
|
|
2059
2180
|
if (!result.discountList) {
|
|
2060
|
-
|
|
2181
|
+
_context21.next = 14;
|
|
2061
2182
|
break;
|
|
2062
2183
|
}
|
|
2063
2184
|
OrderModule.populateSavedAmounts(tempOrder.products, result.discountList);
|
|
2064
|
-
|
|
2185
|
+
_context21.next = 13;
|
|
2065
2186
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(result.discountList);
|
|
2066
2187
|
case 13:
|
|
2067
2188
|
tempOrder.discount_list = result.discountList.filter(function (discount) {
|
|
2068
2189
|
return discount.isSelected;
|
|
2069
2190
|
});
|
|
2070
2191
|
case 14:
|
|
2071
|
-
|
|
2192
|
+
_context21.next = 16;
|
|
2072
2193
|
return this.store.order.recalculateSummary({
|
|
2073
2194
|
createIfMissing: true
|
|
2074
2195
|
});
|
|
2075
2196
|
case 16:
|
|
2076
2197
|
this.store.order.persistTempOrder();
|
|
2077
|
-
|
|
2198
|
+
_context21.next = 22;
|
|
2078
2199
|
break;
|
|
2079
2200
|
case 19:
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
throw
|
|
2201
|
+
_context21.prev = 19;
|
|
2202
|
+
_context21.t0 = _context21["catch"](0);
|
|
2203
|
+
throw _context21.t0;
|
|
2083
2204
|
case 22:
|
|
2084
2205
|
case "end":
|
|
2085
|
-
return
|
|
2206
|
+
return _context21.stop();
|
|
2086
2207
|
}
|
|
2087
|
-
},
|
|
2208
|
+
}, _callee21, this, [[0, 19]]);
|
|
2088
2209
|
}));
|
|
2089
|
-
function applyDiscountCalculationResult(
|
|
2210
|
+
function applyDiscountCalculationResult(_x16) {
|
|
2090
2211
|
return _applyDiscountCalculationResult.apply(this, arguments);
|
|
2091
2212
|
}
|
|
2092
2213
|
return applyDiscountCalculationResult;
|
|
@@ -2094,18 +2215,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2094
2215
|
}, {
|
|
2095
2216
|
key: "submitScanOrder",
|
|
2096
2217
|
value: function () {
|
|
2097
|
-
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2098
|
-
return _regeneratorRuntime().wrap(function
|
|
2099
|
-
while (1) switch (
|
|
2218
|
+
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
|
|
2219
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
2220
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
2100
2221
|
case 0:
|
|
2101
|
-
return
|
|
2222
|
+
return _context22.abrupt("return", this.submitSalesOrder(params));
|
|
2102
2223
|
case 1:
|
|
2103
2224
|
case "end":
|
|
2104
|
-
return
|
|
2225
|
+
return _context22.stop();
|
|
2105
2226
|
}
|
|
2106
|
-
},
|
|
2227
|
+
}, _callee22, this);
|
|
2107
2228
|
}));
|
|
2108
|
-
function submitScanOrder(
|
|
2229
|
+
function submitScanOrder(_x17) {
|
|
2109
2230
|
return _submitScanOrder.apply(this, arguments);
|
|
2110
2231
|
}
|
|
2111
2232
|
return submitScanOrder;
|
|
@@ -2119,14 +2240,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2119
2240
|
}, {
|
|
2120
2241
|
key: "submitSalesOrder",
|
|
2121
2242
|
value: (function () {
|
|
2122
|
-
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2243
|
+
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
|
|
2123
2244
|
var _this$otherParams6, _this$otherParams7, _this$otherParams8, _this$otherParams9;
|
|
2124
2245
|
var inferredPaymentStatus, submitParams;
|
|
2125
|
-
return _regeneratorRuntime().wrap(function
|
|
2126
|
-
while (1) switch (
|
|
2246
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
2247
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
2127
2248
|
case 0:
|
|
2128
2249
|
if (this.store.order) {
|
|
2129
|
-
|
|
2250
|
+
_context23.next = 2;
|
|
2130
2251
|
break;
|
|
2131
2252
|
}
|
|
2132
2253
|
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
@@ -2151,14 +2272,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2151
2272
|
} : {}), (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
|
|
2152
2273
|
enhancePayload: params.enhancePayload
|
|
2153
2274
|
} : {});
|
|
2154
|
-
return
|
|
2275
|
+
return _context23.abrupt("return", this.store.order.submitTempOrder(submitParams));
|
|
2155
2276
|
case 5:
|
|
2156
2277
|
case "end":
|
|
2157
|
-
return
|
|
2278
|
+
return _context23.stop();
|
|
2158
2279
|
}
|
|
2159
|
-
},
|
|
2280
|
+
}, _callee23, this);
|
|
2160
2281
|
}));
|
|
2161
|
-
function submitSalesOrder(
|
|
2282
|
+
function submitSalesOrder(_x18) {
|
|
2162
2283
|
return _submitSalesOrder.apply(this, arguments);
|
|
2163
2284
|
}
|
|
2164
2285
|
return submitSalesOrder;
|
|
@@ -2166,14 +2287,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2166
2287
|
}, {
|
|
2167
2288
|
key: "submitTempOrderAsync",
|
|
2168
2289
|
value: function () {
|
|
2169
|
-
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2290
|
+
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
|
|
2170
2291
|
var _this$otherParams10, _this$otherParams11, _this$otherParams12, _this$otherParams13;
|
|
2171
2292
|
var inferredPaymentStatus, submitParams;
|
|
2172
|
-
return _regeneratorRuntime().wrap(function
|
|
2173
|
-
while (1) switch (
|
|
2293
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
2294
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
2174
2295
|
case 0:
|
|
2175
2296
|
if (this.store.order) {
|
|
2176
|
-
|
|
2297
|
+
_context24.next = 2;
|
|
2177
2298
|
break;
|
|
2178
2299
|
}
|
|
2179
2300
|
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
@@ -2196,14 +2317,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2196
2317
|
} : {}), (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
|
|
2197
2318
|
enhancePayload: params.enhancePayload
|
|
2198
2319
|
} : {});
|
|
2199
|
-
return
|
|
2320
|
+
return _context24.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
|
|
2200
2321
|
case 5:
|
|
2201
2322
|
case "end":
|
|
2202
|
-
return
|
|
2323
|
+
return _context24.stop();
|
|
2203
2324
|
}
|
|
2204
|
-
},
|
|
2325
|
+
}, _callee24, this);
|
|
2205
2326
|
}));
|
|
2206
|
-
function submitTempOrderAsync(
|
|
2327
|
+
function submitTempOrderAsync(_x19) {
|
|
2207
2328
|
return _submitTempOrderAsync.apply(this, arguments);
|
|
2208
2329
|
}
|
|
2209
2330
|
return submitTempOrderAsync;
|
|
@@ -2211,14 +2332,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2211
2332
|
}, {
|
|
2212
2333
|
key: "printLocalOrderReceipt",
|
|
2213
2334
|
value: function () {
|
|
2214
|
-
var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2335
|
+
var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(lookup) {
|
|
2215
2336
|
var _this$otherParams14, _this$otherParams15, _this$otherParams16, _this$otherParams17;
|
|
2216
|
-
var hasLookup, lookupPayload, context, payload, response, _this$store$order$app, _this$store$
|
|
2217
|
-
return _regeneratorRuntime().wrap(function
|
|
2218
|
-
while (1) switch (
|
|
2337
|
+
var hasLookup, lookupPayload, context, payload, response, _this$store$order$app, _this$store$order4, _data;
|
|
2338
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
2339
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
2219
2340
|
case 0:
|
|
2220
2341
|
if (this.store.order) {
|
|
2221
|
-
|
|
2342
|
+
_context25.next = 2;
|
|
2222
2343
|
break;
|
|
2223
2344
|
}
|
|
2224
2345
|
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
@@ -2249,28 +2370,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2249
2370
|
channel: context.channel,
|
|
2250
2371
|
type: context.type
|
|
2251
2372
|
});
|
|
2252
|
-
|
|
2373
|
+
_context25.next = 8;
|
|
2253
2374
|
return this.request.post('/local/print-order', payload, {
|
|
2254
2375
|
osServer: true,
|
|
2255
2376
|
customToast: function customToast() {}
|
|
2256
2377
|
});
|
|
2257
2378
|
case 8:
|
|
2258
|
-
response =
|
|
2379
|
+
response = _context25.sent;
|
|
2259
2380
|
if (hasLookup) {
|
|
2260
|
-
|
|
2381
|
+
_context25.next = 12;
|
|
2261
2382
|
break;
|
|
2262
2383
|
}
|
|
2263
|
-
|
|
2264
|
-
return (_this$store$order$app = (_this$store$
|
|
2384
|
+
_context25.next = 12;
|
|
2385
|
+
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);
|
|
2265
2386
|
case 12:
|
|
2266
|
-
return
|
|
2387
|
+
return _context25.abrupt("return", response);
|
|
2267
2388
|
case 13:
|
|
2268
2389
|
case "end":
|
|
2269
|
-
return
|
|
2390
|
+
return _context25.stop();
|
|
2270
2391
|
}
|
|
2271
|
-
},
|
|
2392
|
+
}, _callee25, this);
|
|
2272
2393
|
}));
|
|
2273
|
-
function printLocalOrderReceipt(
|
|
2394
|
+
function printLocalOrderReceipt(_x20) {
|
|
2274
2395
|
return _printLocalOrderReceipt.apply(this, arguments);
|
|
2275
2396
|
}
|
|
2276
2397
|
return printLocalOrderReceipt;
|
|
@@ -2278,9 +2399,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2278
2399
|
}, {
|
|
2279
2400
|
key: "getSubmitPaymentStatus",
|
|
2280
2401
|
value: function getSubmitPaymentStatus(paymentStatus) {
|
|
2281
|
-
var _this$store$
|
|
2402
|
+
var _this$store$order5, _this$store$order5$ge;
|
|
2282
2403
|
if (paymentStatus !== undefined) return paymentStatus;
|
|
2283
|
-
var amountSnapshot = (_this$store$
|
|
2404
|
+
var amountSnapshot = (_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 || (_this$store$order5$ge = _this$store$order5.getOrderAmountSnapshot) === null || _this$store$order5$ge === void 0 ? void 0 : _this$store$order5$ge.call(_this$store$order5);
|
|
2284
2405
|
if (!amountSnapshot) return undefined;
|
|
2285
2406
|
try {
|
|
2286
2407
|
return new Decimal(amountSnapshot.amountGap || 0).lte(0) ? 'paid' : undefined;
|
|
@@ -2291,19 +2412,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2291
2412
|
}, {
|
|
2292
2413
|
key: "syncPaymentsToOrder",
|
|
2293
2414
|
value: function () {
|
|
2294
|
-
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2295
|
-
var
|
|
2415
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
|
|
2416
|
+
var _ref20, _params$businessCode, _this$otherParams18, _this$otherParams19, _params$channel;
|
|
2296
2417
|
var businessCode, channel, syncParams, syncState, payments, syncResult, latestPayments, amountSnapshot, orderSnapshot, syncPayload;
|
|
2297
|
-
return _regeneratorRuntime().wrap(function
|
|
2298
|
-
while (1) switch (
|
|
2418
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
2419
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
2299
2420
|
case 0:
|
|
2300
2421
|
if (this.store.order) {
|
|
2301
|
-
|
|
2422
|
+
_context26.next = 2;
|
|
2302
2423
|
break;
|
|
2303
2424
|
}
|
|
2304
2425
|
throw new Error('order 模块未初始化');
|
|
2305
2426
|
case 2:
|
|
2306
|
-
businessCode = (
|
|
2427
|
+
businessCode = (_ref20 = (_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 && _ref20 !== void 0 ? _ref20 : (_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.business_code;
|
|
2307
2428
|
channel = (_params$channel = params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel();
|
|
2308
2429
|
syncParams = _objectSpread(_objectSpread(_objectSpread({}, params), businessCode !== undefined ? {
|
|
2309
2430
|
businessCode: businessCode
|
|
@@ -2312,14 +2433,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2312
2433
|
} : {});
|
|
2313
2434
|
syncState = this.store.order.getOrderSyncState();
|
|
2314
2435
|
if (!(params.submitWhenPaid && syncState === 'submitting')) {
|
|
2315
|
-
|
|
2436
|
+
_context26.next = 9;
|
|
2316
2437
|
break;
|
|
2317
2438
|
}
|
|
2318
2439
|
this.queueLatestAutoPaymentSync();
|
|
2319
|
-
return
|
|
2440
|
+
return _context26.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
|
|
2320
2441
|
case 9:
|
|
2321
2442
|
payments = params.payments || [];
|
|
2322
|
-
|
|
2443
|
+
_context26.next = 12;
|
|
2323
2444
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncStart, {
|
|
2324
2445
|
payments: payments,
|
|
2325
2446
|
params: syncParams,
|
|
@@ -2327,11 +2448,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2327
2448
|
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
2328
2449
|
});
|
|
2329
2450
|
case 12:
|
|
2330
|
-
|
|
2331
|
-
|
|
2451
|
+
_context26.prev = 12;
|
|
2452
|
+
_context26.next = 15;
|
|
2332
2453
|
return this.store.order.syncPaymentsToOrder(syncParams);
|
|
2333
2454
|
case 15:
|
|
2334
|
-
syncResult =
|
|
2455
|
+
syncResult = _context26.sent;
|
|
2335
2456
|
latestPayments = this.store.order.getOrderPayments();
|
|
2336
2457
|
amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
2337
2458
|
orderSnapshot = this.store.order.getOrderSnapshot();
|
|
@@ -2349,25 +2470,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2349
2470
|
depositAmount: syncResult.depositAmount,
|
|
2350
2471
|
orderExpectedAmount: syncResult.orderExpectedAmount
|
|
2351
2472
|
};
|
|
2352
|
-
|
|
2473
|
+
_context26.next = 22;
|
|
2353
2474
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, syncPayload);
|
|
2354
2475
|
case 22:
|
|
2355
2476
|
if (!(syncResult.isDepositFullyPaid && !syncResult.isOrderFullyPaid)) {
|
|
2356
|
-
|
|
2477
|
+
_context26.next = 25;
|
|
2357
2478
|
break;
|
|
2358
2479
|
}
|
|
2359
|
-
|
|
2480
|
+
_context26.next = 25;
|
|
2360
2481
|
return this.effectsEmit(BaseSalesHookNames.onDepositPaymentSyncEnd, syncPayload);
|
|
2361
2482
|
case 25:
|
|
2362
2483
|
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
2363
|
-
return
|
|
2484
|
+
return _context26.abrupt("return", syncResult);
|
|
2364
2485
|
case 29:
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2486
|
+
_context26.prev = 29;
|
|
2487
|
+
_context26.t0 = _context26["catch"](12);
|
|
2488
|
+
_context26.next = 33;
|
|
2368
2489
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
|
|
2369
2490
|
ok: false,
|
|
2370
|
-
error:
|
|
2491
|
+
error: _context26.t0,
|
|
2371
2492
|
payments: this.store.order.getOrderPayments(),
|
|
2372
2493
|
params: syncParams,
|
|
2373
2494
|
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
@@ -2375,14 +2496,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2375
2496
|
});
|
|
2376
2497
|
case 33:
|
|
2377
2498
|
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
2378
|
-
throw
|
|
2499
|
+
throw _context26.t0;
|
|
2379
2500
|
case 35:
|
|
2380
2501
|
case "end":
|
|
2381
|
-
return
|
|
2502
|
+
return _context26.stop();
|
|
2382
2503
|
}
|
|
2383
|
-
},
|
|
2504
|
+
}, _callee26, this, [[12, 29]]);
|
|
2384
2505
|
}));
|
|
2385
|
-
function syncPaymentsToOrder(
|
|
2506
|
+
function syncPaymentsToOrder(_x21) {
|
|
2386
2507
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
2387
2508
|
}
|
|
2388
2509
|
return syncPaymentsToOrder;
|
|
@@ -2419,58 +2540,58 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2419
2540
|
}, {
|
|
2420
2541
|
key: "scheduleQueuedAutoPaymentSyncFlush",
|
|
2421
2542
|
value: function scheduleQueuedAutoPaymentSyncFlush() {
|
|
2422
|
-
var
|
|
2543
|
+
var _this10 = this;
|
|
2423
2544
|
var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;
|
|
2424
2545
|
if (!this.queuedAutoPaymentSync) return;
|
|
2425
2546
|
if (this.autoPaymentSyncTimer) return;
|
|
2426
2547
|
this.autoPaymentSyncTimer = setTimeout(function () {
|
|
2427
|
-
|
|
2428
|
-
void
|
|
2548
|
+
_this10.autoPaymentSyncTimer = null;
|
|
2549
|
+
void _this10.flushQueuedAutoPaymentSync();
|
|
2429
2550
|
}, delay);
|
|
2430
2551
|
}
|
|
2431
2552
|
}, {
|
|
2432
2553
|
key: "flushQueuedAutoPaymentSync",
|
|
2433
2554
|
value: function () {
|
|
2434
|
-
var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2555
|
+
var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
|
|
2435
2556
|
var payments;
|
|
2436
|
-
return _regeneratorRuntime().wrap(function
|
|
2437
|
-
while (1) switch (
|
|
2557
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
2558
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
2438
2559
|
case 0:
|
|
2439
2560
|
if (this.store.order) {
|
|
2440
|
-
|
|
2561
|
+
_context27.next = 2;
|
|
2441
2562
|
break;
|
|
2442
2563
|
}
|
|
2443
|
-
return
|
|
2564
|
+
return _context27.abrupt("return");
|
|
2444
2565
|
case 2:
|
|
2445
2566
|
if (!(!this.queuedAutoPaymentSync || this.autoPaymentSyncFlushing)) {
|
|
2446
|
-
|
|
2567
|
+
_context27.next = 4;
|
|
2447
2568
|
break;
|
|
2448
2569
|
}
|
|
2449
|
-
return
|
|
2570
|
+
return _context27.abrupt("return");
|
|
2450
2571
|
case 4:
|
|
2451
2572
|
if (!(this.store.order.getOrderSyncState() === 'submitting')) {
|
|
2452
|
-
|
|
2573
|
+
_context27.next = 7;
|
|
2453
2574
|
break;
|
|
2454
2575
|
}
|
|
2455
2576
|
this.scheduleQueuedAutoPaymentSyncFlush();
|
|
2456
|
-
return
|
|
2577
|
+
return _context27.abrupt("return");
|
|
2457
2578
|
case 7:
|
|
2458
2579
|
this.autoPaymentSyncFlushing = true;
|
|
2459
|
-
|
|
2580
|
+
_context27.prev = 8;
|
|
2460
2581
|
case 9:
|
|
2461
2582
|
if (!this.queuedAutoPaymentSync) {
|
|
2462
|
-
|
|
2583
|
+
_context27.next = 18;
|
|
2463
2584
|
break;
|
|
2464
2585
|
}
|
|
2465
2586
|
this.queuedAutoPaymentSync = false;
|
|
2466
2587
|
payments = this.store.order.getOrderPayments();
|
|
2467
2588
|
if (payments.length) {
|
|
2468
|
-
|
|
2589
|
+
_context27.next = 14;
|
|
2469
2590
|
break;
|
|
2470
2591
|
}
|
|
2471
|
-
return
|
|
2592
|
+
return _context27.abrupt("continue", 9);
|
|
2472
2593
|
case 14:
|
|
2473
|
-
|
|
2594
|
+
_context27.next = 16;
|
|
2474
2595
|
return this.syncPaymentsToOrder({
|
|
2475
2596
|
payments: payments,
|
|
2476
2597
|
paymentStatus: this.getPaymentStatusForSync(payments),
|
|
@@ -2478,29 +2599,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2478
2599
|
smallTicketDataFlag: 1
|
|
2479
2600
|
});
|
|
2480
2601
|
case 16:
|
|
2481
|
-
|
|
2602
|
+
_context27.next = 9;
|
|
2482
2603
|
break;
|
|
2483
2604
|
case 18:
|
|
2484
|
-
|
|
2605
|
+
_context27.next = 23;
|
|
2485
2606
|
break;
|
|
2486
2607
|
case 20:
|
|
2487
|
-
|
|
2488
|
-
|
|
2608
|
+
_context27.prev = 20;
|
|
2609
|
+
_context27.t0 = _context27["catch"](8);
|
|
2489
2610
|
this.logError('queued auto sync payments failed', {
|
|
2490
|
-
error:
|
|
2611
|
+
error: _context27.t0 instanceof Error ? _context27.t0.message : String(_context27.t0)
|
|
2491
2612
|
});
|
|
2492
2613
|
case 23:
|
|
2493
|
-
|
|
2614
|
+
_context27.prev = 23;
|
|
2494
2615
|
this.autoPaymentSyncFlushing = false;
|
|
2495
2616
|
if (this.queuedAutoPaymentSync) {
|
|
2496
2617
|
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
2497
2618
|
}
|
|
2498
|
-
return
|
|
2619
|
+
return _context27.finish(23);
|
|
2499
2620
|
case 27:
|
|
2500
2621
|
case "end":
|
|
2501
|
-
return
|
|
2622
|
+
return _context27.stop();
|
|
2502
2623
|
}
|
|
2503
|
-
},
|
|
2624
|
+
}, _callee27, this, [[8, 20, 23, 27]]);
|
|
2504
2625
|
}));
|
|
2505
2626
|
function flushQueuedAutoPaymentSync() {
|
|
2506
2627
|
return _flushQueuedAutoPaymentSync.apply(this, arguments);
|
|
@@ -2513,9 +2634,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2513
2634
|
var _this$otherParams20,
|
|
2514
2635
|
_paymentRecord$paymen,
|
|
2515
2636
|
_paymentRecord$create,
|
|
2516
|
-
|
|
2637
|
+
_ref21,
|
|
2517
2638
|
_paymentRecord$origin,
|
|
2518
|
-
|
|
2639
|
+
_this11 = this;
|
|
2519
2640
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
2520
2641
|
var paymentRecord = payment;
|
|
2521
2642
|
var paymentAmount = new Decimal(paymentRecord.amount || 0);
|
|
@@ -2537,7 +2658,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2537
2658
|
var paymentTime = (_paymentRecord$paymen = paymentRecord.payment_time) !== null && _paymentRecord$paymen !== void 0 ? _paymentRecord$paymen : paymentTimestamp;
|
|
2538
2659
|
var createdAt = (_paymentRecord$create = paymentRecord.created_at) !== null && _paymentRecord$create !== void 0 ? _paymentRecord$create : paymentTimestamp;
|
|
2539
2660
|
var serviceCharge = paymentRecord.service_charge && _typeof(paymentRecord.service_charge) === 'object' ? paymentRecord.service_charge : null;
|
|
2540
|
-
var calculatedServiceFee = serviceCharge ? new Decimal((
|
|
2661
|
+
var calculatedServiceFee = serviceCharge ? new Decimal((_ref21 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref21 !== void 0 ? _ref21 : 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
|
|
2541
2662
|
var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread({}, paymentRecord), calculatedServiceFee !== undefined ? {
|
|
2542
2663
|
service_fee: calculatedServiceFee
|
|
2543
2664
|
} : {}), {}, {
|
|
@@ -2558,7 +2679,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2558
2679
|
submitWhenPaid: true,
|
|
2559
2680
|
smallTicketDataFlag: 1
|
|
2560
2681
|
}).catch(function (error) {
|
|
2561
|
-
|
|
2682
|
+
_this11.logError('auto sync payments failed', {
|
|
2562
2683
|
error: error instanceof Error ? error.message : String(error)
|
|
2563
2684
|
});
|
|
2564
2685
|
});
|
|
@@ -2604,8 +2725,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2604
2725
|
}, {
|
|
2605
2726
|
key: "getWalletProductList",
|
|
2606
2727
|
value: function getWalletProductList() {
|
|
2607
|
-
var _this$store$
|
|
2608
|
-
var tempOrder = (_this$store$
|
|
2728
|
+
var _this$store$order6, _tempOrder$products;
|
|
2729
|
+
var tempOrder = (_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 ? void 0 : _this$store$order6.getTempOrder();
|
|
2609
2730
|
if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$products = tempOrder.products) !== null && _tempOrder$products !== void 0 && _tempOrder$products.length)) return [];
|
|
2610
2731
|
// 过滤出有 product_id的商品来,如果没有代表他是自定义商品,不需要参与 wallet
|
|
2611
2732
|
// debugger
|
|
@@ -2665,20 +2786,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2665
2786
|
}, {
|
|
2666
2787
|
key: "initWalletData",
|
|
2667
2788
|
value: function () {
|
|
2668
|
-
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2669
|
-
var _params$order_wait_pa,
|
|
2789
|
+
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
|
|
2790
|
+
var _params$order_wait_pa, _ref22, _tempOrder$is_price_i;
|
|
2670
2791
|
var snapshot, tempOrder, amount, walletBusinessData, result;
|
|
2671
|
-
return _regeneratorRuntime().wrap(function
|
|
2672
|
-
while (1) switch (
|
|
2792
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
2793
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
2673
2794
|
case 0:
|
|
2674
2795
|
if (this.store.order) {
|
|
2675
|
-
|
|
2796
|
+
_context28.next = 2;
|
|
2676
2797
|
break;
|
|
2677
2798
|
}
|
|
2678
2799
|
throw new Error('order 模块未初始化');
|
|
2679
2800
|
case 2:
|
|
2680
2801
|
if (this.store.payment) {
|
|
2681
|
-
|
|
2802
|
+
_context28.next = 4;
|
|
2682
2803
|
break;
|
|
2683
2804
|
}
|
|
2684
2805
|
throw new Error('payment 模块未初始化');
|
|
@@ -2687,10 +2808,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2687
2808
|
tempOrder = snapshot === null || snapshot === void 0 ? void 0 : snapshot.tempOrder;
|
|
2688
2809
|
amount = snapshot === null || snapshot === void 0 ? void 0 : snapshot.amount;
|
|
2689
2810
|
if (!(!tempOrder || !amount)) {
|
|
2690
|
-
|
|
2811
|
+
_context28.next = 9;
|
|
2691
2812
|
break;
|
|
2692
2813
|
}
|
|
2693
|
-
return
|
|
2814
|
+
return _context28.abrupt("return", {
|
|
2694
2815
|
walletRecommendList: [],
|
|
2695
2816
|
userIdentificationCodes: [],
|
|
2696
2817
|
transformList: [],
|
|
@@ -2709,15 +2830,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2709
2830
|
},
|
|
2710
2831
|
products: this.getWalletProductList(),
|
|
2711
2832
|
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),
|
|
2712
|
-
is_price_include_tax: (
|
|
2833
|
+
is_price_include_tax: (_ref22 = (_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 && _ref22 !== void 0 ? _ref22 : 1
|
|
2713
2834
|
}, snapshot.identity.orderId ? {
|
|
2714
2835
|
payment_order_id: String(snapshot.identity.orderId)
|
|
2715
2836
|
} : {});
|
|
2716
|
-
|
|
2837
|
+
_context28.next = 12;
|
|
2717
2838
|
return this.store.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
|
|
2718
2839
|
case 12:
|
|
2719
|
-
result =
|
|
2720
|
-
|
|
2840
|
+
result = _context28.sent;
|
|
2841
|
+
_context28.next = 15;
|
|
2721
2842
|
return this.core.effects.emit("".concat(this.name, ":onWalletDataInitialized"), {
|
|
2722
2843
|
orderId: snapshot.identity.orderId,
|
|
2723
2844
|
customerId: walletBusinessData.customer_id,
|
|
@@ -2729,14 +2850,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2729
2850
|
timestamp: Date.now()
|
|
2730
2851
|
});
|
|
2731
2852
|
case 15:
|
|
2732
|
-
return
|
|
2853
|
+
return _context28.abrupt("return", result);
|
|
2733
2854
|
case 16:
|
|
2734
2855
|
case "end":
|
|
2735
|
-
return
|
|
2856
|
+
return _context28.stop();
|
|
2736
2857
|
}
|
|
2737
|
-
},
|
|
2858
|
+
}, _callee28, this);
|
|
2738
2859
|
}));
|
|
2739
|
-
function initWalletData(
|
|
2860
|
+
function initWalletData(_x22) {
|
|
2740
2861
|
return _initWalletData.apply(this, arguments);
|
|
2741
2862
|
}
|
|
2742
2863
|
return initWalletData;
|
|
@@ -2763,35 +2884,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2763
2884
|
}, {
|
|
2764
2885
|
key: "getPaymentMethodsAsync",
|
|
2765
2886
|
value: (function () {
|
|
2766
|
-
var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2887
|
+
var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
|
|
2767
2888
|
var response, paymentMethods;
|
|
2768
|
-
return _regeneratorRuntime().wrap(function
|
|
2769
|
-
while (1) switch (
|
|
2889
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
2890
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
2770
2891
|
case 0:
|
|
2771
|
-
|
|
2772
|
-
|
|
2892
|
+
_context29.prev = 0;
|
|
2893
|
+
_context29.next = 3;
|
|
2773
2894
|
return this.request.get('/pay/custom-payment/all', {
|
|
2774
2895
|
filterPaymentMethods: true
|
|
2775
2896
|
}, {
|
|
2776
2897
|
osServer: true
|
|
2777
2898
|
});
|
|
2778
2899
|
case 3:
|
|
2779
|
-
response =
|
|
2900
|
+
response = _context29.sent;
|
|
2780
2901
|
paymentMethods = (response === null || response === void 0 ? void 0 : response.data) || [];
|
|
2781
2902
|
this.paymentMethodsCache = Array.isArray(paymentMethods) ? _toConsumableArray(paymentMethods) : [];
|
|
2782
|
-
return
|
|
2903
|
+
return _context29.abrupt("return", this.getPaymentMethods());
|
|
2783
2904
|
case 9:
|
|
2784
|
-
|
|
2785
|
-
|
|
2905
|
+
_context29.prev = 9;
|
|
2906
|
+
_context29.t0 = _context29["catch"](0);
|
|
2786
2907
|
this.logWarning('getPaymentMethodsAsync: 获取支付方式列表失败,使用缓存列表', {
|
|
2787
|
-
error:
|
|
2908
|
+
error: _context29.t0 instanceof Error ? _context29.t0.message : String(_context29.t0)
|
|
2788
2909
|
});
|
|
2789
|
-
return
|
|
2910
|
+
return _context29.abrupt("return", this.getPaymentMethods());
|
|
2790
2911
|
case 13:
|
|
2791
2912
|
case "end":
|
|
2792
|
-
return
|
|
2913
|
+
return _context29.stop();
|
|
2793
2914
|
}
|
|
2794
|
-
},
|
|
2915
|
+
}, _callee29, this, [[0, 9]]);
|
|
2795
2916
|
}));
|
|
2796
2917
|
function getPaymentMethodsAsync() {
|
|
2797
2918
|
return _getPaymentMethodsAsync.apply(this, arguments);
|
|
@@ -2839,49 +2960,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2839
2960
|
}, {
|
|
2840
2961
|
key: "sendCustomerPayLink",
|
|
2841
2962
|
value: (function () {
|
|
2842
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2843
|
-
var orderIds,
|
|
2844
|
-
return _regeneratorRuntime().wrap(function
|
|
2845
|
-
while (1) switch (
|
|
2963
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
|
|
2964
|
+
var orderIds, _ref23, _ref24, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
|
|
2965
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
2966
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
2846
2967
|
case 0:
|
|
2847
2968
|
if (this.store.order) {
|
|
2848
|
-
|
|
2969
|
+
_context30.next = 2;
|
|
2849
2970
|
break;
|
|
2850
2971
|
}
|
|
2851
2972
|
throw new Error('order 模块未初始化');
|
|
2852
2973
|
case 2:
|
|
2853
2974
|
orderIds = params.order_ids || params.orderIds || [];
|
|
2854
2975
|
if (!(!orderIds.length || params.submitBeforeSend)) {
|
|
2855
|
-
|
|
2976
|
+
_context30.next = 11;
|
|
2856
2977
|
break;
|
|
2857
2978
|
}
|
|
2858
|
-
|
|
2979
|
+
_context30.next = 6;
|
|
2859
2980
|
return this.submitSalesOrder({
|
|
2860
2981
|
smallTicketDataFlag: 1
|
|
2861
2982
|
});
|
|
2862
2983
|
case 6:
|
|
2863
|
-
submitResult =
|
|
2864
|
-
orderId = (
|
|
2984
|
+
submitResult = _context30.sent;
|
|
2985
|
+
orderId = (_ref23 = (_ref24 = (_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 && _ref24 !== void 0 ? _ref24 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref23 !== void 0 ? _ref23 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
|
|
2865
2986
|
if (orderId) {
|
|
2866
|
-
|
|
2987
|
+
_context30.next = 10;
|
|
2867
2988
|
break;
|
|
2868
2989
|
}
|
|
2869
2990
|
throw new Error('本地订单提交云端失败,无法发送支付链接');
|
|
2870
2991
|
case 10:
|
|
2871
2992
|
orderIds = [orderId];
|
|
2872
2993
|
case 11:
|
|
2873
|
-
return
|
|
2994
|
+
return _context30.abrupt("return", this.store.order.sendCustomerPayLink({
|
|
2874
2995
|
emails: params.emails,
|
|
2875
2996
|
notify_action: params.notify_action,
|
|
2876
2997
|
order_ids: orderIds
|
|
2877
2998
|
}));
|
|
2878
2999
|
case 12:
|
|
2879
3000
|
case "end":
|
|
2880
|
-
return
|
|
3001
|
+
return _context30.stop();
|
|
2881
3002
|
}
|
|
2882
|
-
},
|
|
3003
|
+
}, _callee30, this);
|
|
2883
3004
|
}));
|
|
2884
|
-
function sendCustomerPayLink(
|
|
3005
|
+
function sendCustomerPayLink(_x23) {
|
|
2885
3006
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
2886
3007
|
}
|
|
2887
3008
|
return sendCustomerPayLink;
|
|
@@ -2894,27 +3015,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2894
3015
|
}, {
|
|
2895
3016
|
key: "calculateProductBookingPrice",
|
|
2896
3017
|
value: function () {
|
|
2897
|
-
var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3018
|
+
var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
|
|
2898
3019
|
var _params$customer_id;
|
|
2899
3020
|
var quotation, customerId, authoritativeProduct, product;
|
|
2900
|
-
return _regeneratorRuntime().wrap(function
|
|
2901
|
-
while (1) switch (
|
|
3021
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
3022
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
2902
3023
|
case 0:
|
|
2903
3024
|
quotation = this.store.quotation;
|
|
2904
3025
|
customerId = (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : this.getCurrentOrderCustomerId();
|
|
2905
|
-
|
|
3026
|
+
_context31.next = 4;
|
|
2906
3027
|
return this.loadProductForPriceQuery(params, customerId);
|
|
2907
3028
|
case 4:
|
|
2908
|
-
authoritativeProduct =
|
|
3029
|
+
authoritativeProduct = _context31.sent;
|
|
2909
3030
|
product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
|
|
2910
|
-
|
|
3031
|
+
_context31.next = 8;
|
|
2911
3032
|
return this.loadQuotationForPriceQuery({
|
|
2912
3033
|
quotation: quotation,
|
|
2913
3034
|
customer_id: customerId,
|
|
2914
3035
|
channel: params.channel
|
|
2915
3036
|
});
|
|
2916
3037
|
case 8:
|
|
2917
|
-
return
|
|
3038
|
+
return _context31.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
|
|
2918
3039
|
product: product,
|
|
2919
3040
|
fallback_price: authoritativeProduct ? undefined : params.fallback_price,
|
|
2920
3041
|
customer_id: customerId,
|
|
@@ -2922,11 +3043,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2922
3043
|
})));
|
|
2923
3044
|
case 9:
|
|
2924
3045
|
case "end":
|
|
2925
|
-
return
|
|
3046
|
+
return _context31.stop();
|
|
2926
3047
|
}
|
|
2927
|
-
},
|
|
3048
|
+
}, _callee31, this);
|
|
2928
3049
|
}));
|
|
2929
|
-
function calculateProductBookingPrice(
|
|
3050
|
+
function calculateProductBookingPrice(_x24) {
|
|
2930
3051
|
return _calculateProductBookingPrice.apply(this, arguments);
|
|
2931
3052
|
}
|
|
2932
3053
|
return calculateProductBookingPrice;
|
|
@@ -2934,7 +3055,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2934
3055
|
}, {
|
|
2935
3056
|
key: "getQuotationCustomerScopeInfo",
|
|
2936
3057
|
value: function getQuotationCustomerScopeInfo() {
|
|
2937
|
-
var
|
|
3058
|
+
var _this12 = this;
|
|
2938
3059
|
var quotation = this.store.quotation;
|
|
2939
3060
|
if (quotation && typeof quotation.getQuotationCustomerScopeInfo === 'function') {
|
|
2940
3061
|
return quotation.getQuotationCustomerScopeInfo();
|
|
@@ -2946,7 +3067,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2946
3067
|
}).map(function (item) {
|
|
2947
3068
|
var localSeen = new Set();
|
|
2948
3069
|
var customers = item.customer.filter(function (customer) {
|
|
2949
|
-
var customerId =
|
|
3070
|
+
var customerId = _this12.normalizePriceContextCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
|
|
2950
3071
|
if (!customerId || localSeen.has(customerId)) return false;
|
|
2951
3072
|
localSeen.add(customerId);
|
|
2952
3073
|
if (!customerById.has(customerId)) customerById.set(customerId, customer);
|
|
@@ -2996,32 +3117,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2996
3117
|
}, {
|
|
2997
3118
|
key: "calculateProductBookingPrices",
|
|
2998
3119
|
value: function () {
|
|
2999
|
-
var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3120
|
+
var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(paramsList) {
|
|
3000
3121
|
var _paramsList$0$custome,
|
|
3001
3122
|
_paramsList$,
|
|
3002
|
-
|
|
3123
|
+
_this13 = this,
|
|
3003
3124
|
_paramsList$2;
|
|
3004
3125
|
var quotation, customerId, productMapsByGroup, groups;
|
|
3005
|
-
return _regeneratorRuntime().wrap(function
|
|
3006
|
-
while (1) switch (
|
|
3126
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
3127
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
3007
3128
|
case 0:
|
|
3008
3129
|
if (paramsList.length) {
|
|
3009
|
-
|
|
3130
|
+
_context33.next = 2;
|
|
3010
3131
|
break;
|
|
3011
3132
|
}
|
|
3012
|
-
return
|
|
3133
|
+
return _context33.abrupt("return", []);
|
|
3013
3134
|
case 2:
|
|
3014
3135
|
quotation = this.store.quotation;
|
|
3015
3136
|
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();
|
|
3016
3137
|
productMapsByGroup = new Map();
|
|
3017
3138
|
groups = new Map();
|
|
3018
3139
|
paramsList.forEach(function (params) {
|
|
3019
|
-
var
|
|
3140
|
+
var _this13$otherParams;
|
|
3020
3141
|
var product = params.product || {};
|
|
3021
|
-
var productId =
|
|
3142
|
+
var productId = _this13.getPriceQueryProductId(product);
|
|
3022
3143
|
if (productId === null) return;
|
|
3023
|
-
var schedule =
|
|
3024
|
-
var channel = params.channel || ((
|
|
3144
|
+
var schedule = _this13.getPriceQuerySchedule(params);
|
|
3145
|
+
var channel = params.channel || ((_this13$otherParams = _this13.otherParams) === null || _this13$otherParams === void 0 ? void 0 : _this13$otherParams.channel);
|
|
3025
3146
|
var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || ''].join('|');
|
|
3026
3147
|
var group = groups.get(groupKey) || {
|
|
3027
3148
|
ids: new Set(),
|
|
@@ -3031,51 +3152,51 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3031
3152
|
group.ids.add(productId);
|
|
3032
3153
|
groups.set(groupKey, group);
|
|
3033
3154
|
});
|
|
3034
|
-
|
|
3155
|
+
_context33.next = 9;
|
|
3035
3156
|
return Promise.all(Array.from(groups.entries()).map( /*#__PURE__*/function () {
|
|
3036
|
-
var
|
|
3037
|
-
var
|
|
3038
|
-
return _regeneratorRuntime().wrap(function
|
|
3039
|
-
while (1) switch (
|
|
3157
|
+
var _ref26 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(_ref25) {
|
|
3158
|
+
var _ref27, groupKey, group, productsById;
|
|
3159
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
3160
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
3040
3161
|
case 0:
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
return
|
|
3162
|
+
_ref27 = _slicedToArray(_ref25, 2), groupKey = _ref27[0], group = _ref27[1];
|
|
3163
|
+
_context32.next = 3;
|
|
3164
|
+
return _this13.loadProductsForPriceQuery({
|
|
3044
3165
|
ids: Array.from(group.ids),
|
|
3045
3166
|
schedule: group.schedule,
|
|
3046
3167
|
customerId: customerId,
|
|
3047
3168
|
channel: group.channel
|
|
3048
3169
|
});
|
|
3049
3170
|
case 3:
|
|
3050
|
-
productsById =
|
|
3171
|
+
productsById = _context32.sent;
|
|
3051
3172
|
productMapsByGroup.set(groupKey, productsById);
|
|
3052
3173
|
case 5:
|
|
3053
3174
|
case "end":
|
|
3054
|
-
return
|
|
3175
|
+
return _context32.stop();
|
|
3055
3176
|
}
|
|
3056
|
-
},
|
|
3177
|
+
}, _callee32);
|
|
3057
3178
|
}));
|
|
3058
|
-
return function (
|
|
3059
|
-
return
|
|
3179
|
+
return function (_x26) {
|
|
3180
|
+
return _ref26.apply(this, arguments);
|
|
3060
3181
|
};
|
|
3061
3182
|
}()));
|
|
3062
3183
|
case 9:
|
|
3063
|
-
|
|
3184
|
+
_context33.next = 11;
|
|
3064
3185
|
return this.loadQuotationForPriceQuery({
|
|
3065
3186
|
quotation: quotation,
|
|
3066
3187
|
customer_id: customerId,
|
|
3067
3188
|
channel: (_paramsList$2 = paramsList[0]) === null || _paramsList$2 === void 0 ? void 0 : _paramsList$2.channel
|
|
3068
3189
|
});
|
|
3069
3190
|
case 11:
|
|
3070
|
-
return
|
|
3071
|
-
var
|
|
3191
|
+
return _context33.abrupt("return", paramsList.map(function (params) {
|
|
3192
|
+
var _this13$otherParams2, _productMapsByGroup$g;
|
|
3072
3193
|
var productInput = params.product || {};
|
|
3073
|
-
var productId =
|
|
3074
|
-
var schedule =
|
|
3075
|
-
var channel = params.channel || ((
|
|
3194
|
+
var productId = _this13.getPriceQueryProductId(productInput);
|
|
3195
|
+
var schedule = _this13.getPriceQuerySchedule(params);
|
|
3196
|
+
var channel = params.channel || ((_this13$otherParams2 = _this13.otherParams) === null || _this13$otherParams2 === void 0 ? void 0 : _this13$otherParams2.channel);
|
|
3076
3197
|
var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || ''].join('|');
|
|
3077
3198
|
var authoritativeProduct = productId === null ? null : ((_productMapsByGroup$g = productMapsByGroup.get(groupKey)) === null || _productMapsByGroup$g === void 0 ? void 0 : _productMapsByGroup$g.get(productId)) || null;
|
|
3078
|
-
var product =
|
|
3199
|
+
var product = _this13.mergeProductForPriceQuery(productInput, authoritativeProduct);
|
|
3079
3200
|
return calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
|
|
3080
3201
|
product: product,
|
|
3081
3202
|
fallback_price: authoritativeProduct ? undefined : params.fallback_price,
|
|
@@ -3085,11 +3206,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3085
3206
|
}));
|
|
3086
3207
|
case 12:
|
|
3087
3208
|
case "end":
|
|
3088
|
-
return
|
|
3209
|
+
return _context33.stop();
|
|
3089
3210
|
}
|
|
3090
|
-
},
|
|
3211
|
+
}, _callee33, this);
|
|
3091
3212
|
}));
|
|
3092
|
-
function calculateProductBookingPrices(
|
|
3213
|
+
function calculateProductBookingPrices(_x25) {
|
|
3093
3214
|
return _calculateProductBookingPrices.apply(this, arguments);
|
|
3094
3215
|
}
|
|
3095
3216
|
return calculateProductBookingPrices;
|
|
@@ -3097,34 +3218,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3097
3218
|
}, {
|
|
3098
3219
|
key: "addProductToOrder",
|
|
3099
3220
|
value: function () {
|
|
3100
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3221
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(product, booking) {
|
|
3101
3222
|
var products;
|
|
3102
|
-
return _regeneratorRuntime().wrap(function
|
|
3103
|
-
while (1) switch (
|
|
3223
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
3224
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
3104
3225
|
case 0:
|
|
3105
|
-
|
|
3226
|
+
_context34.prev = 0;
|
|
3106
3227
|
if (this.store.order) {
|
|
3107
|
-
|
|
3228
|
+
_context34.next = 3;
|
|
3108
3229
|
break;
|
|
3109
3230
|
}
|
|
3110
3231
|
throw new Error('order 模块未初始化');
|
|
3111
3232
|
case 3:
|
|
3112
|
-
|
|
3233
|
+
_context34.next = 5;
|
|
3113
3234
|
return this.store.order.addProductToOrder(product, booking);
|
|
3114
3235
|
case 5:
|
|
3115
|
-
products =
|
|
3116
|
-
return
|
|
3236
|
+
products = _context34.sent;
|
|
3237
|
+
return _context34.abrupt("return", products);
|
|
3117
3238
|
case 9:
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
throw
|
|
3239
|
+
_context34.prev = 9;
|
|
3240
|
+
_context34.t0 = _context34["catch"](0);
|
|
3241
|
+
throw _context34.t0;
|
|
3121
3242
|
case 12:
|
|
3122
3243
|
case "end":
|
|
3123
|
-
return
|
|
3244
|
+
return _context34.stop();
|
|
3124
3245
|
}
|
|
3125
|
-
},
|
|
3246
|
+
}, _callee34, this, [[0, 9]]);
|
|
3126
3247
|
}));
|
|
3127
|
-
function addProductToOrder(
|
|
3248
|
+
function addProductToOrder(_x27, _x28) {
|
|
3128
3249
|
return _addProductToOrder.apply(this, arguments);
|
|
3129
3250
|
}
|
|
3130
3251
|
return addProductToOrder;
|
|
@@ -3132,34 +3253,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3132
3253
|
}, {
|
|
3133
3254
|
key: "updateOrderProduct",
|
|
3134
3255
|
value: function () {
|
|
3135
|
-
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3256
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
|
|
3136
3257
|
var products;
|
|
3137
|
-
return _regeneratorRuntime().wrap(function
|
|
3138
|
-
while (1) switch (
|
|
3258
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
3259
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
3139
3260
|
case 0:
|
|
3140
|
-
|
|
3261
|
+
_context35.prev = 0;
|
|
3141
3262
|
if (this.store.order) {
|
|
3142
|
-
|
|
3263
|
+
_context35.next = 3;
|
|
3143
3264
|
break;
|
|
3144
3265
|
}
|
|
3145
3266
|
throw new Error('order 模块未初始化');
|
|
3146
3267
|
case 3:
|
|
3147
|
-
|
|
3268
|
+
_context35.next = 5;
|
|
3148
3269
|
return this.store.order.updateOrderProduct(params);
|
|
3149
3270
|
case 5:
|
|
3150
|
-
products =
|
|
3151
|
-
return
|
|
3271
|
+
products = _context35.sent;
|
|
3272
|
+
return _context35.abrupt("return", products);
|
|
3152
3273
|
case 9:
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
throw
|
|
3274
|
+
_context35.prev = 9;
|
|
3275
|
+
_context35.t0 = _context35["catch"](0);
|
|
3276
|
+
throw _context35.t0;
|
|
3156
3277
|
case 12:
|
|
3157
3278
|
case "end":
|
|
3158
|
-
return
|
|
3279
|
+
return _context35.stop();
|
|
3159
3280
|
}
|
|
3160
|
-
},
|
|
3281
|
+
}, _callee35, this, [[0, 9]]);
|
|
3161
3282
|
}));
|
|
3162
|
-
function updateOrderProduct(
|
|
3283
|
+
function updateOrderProduct(_x29) {
|
|
3163
3284
|
return _updateOrderProduct.apply(this, arguments);
|
|
3164
3285
|
}
|
|
3165
3286
|
return updateOrderProduct;
|
|
@@ -3167,34 +3288,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3167
3288
|
}, {
|
|
3168
3289
|
key: "updateOrderProducts",
|
|
3169
3290
|
value: function () {
|
|
3170
|
-
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3291
|
+
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(paramsList) {
|
|
3171
3292
|
var products;
|
|
3172
|
-
return _regeneratorRuntime().wrap(function
|
|
3173
|
-
while (1) switch (
|
|
3293
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
3294
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
3174
3295
|
case 0:
|
|
3175
|
-
|
|
3296
|
+
_context36.prev = 0;
|
|
3176
3297
|
if (this.store.order) {
|
|
3177
|
-
|
|
3298
|
+
_context36.next = 3;
|
|
3178
3299
|
break;
|
|
3179
3300
|
}
|
|
3180
3301
|
throw new Error('order 模块未初始化');
|
|
3181
3302
|
case 3:
|
|
3182
|
-
|
|
3303
|
+
_context36.next = 5;
|
|
3183
3304
|
return this.store.order.updateOrderProducts(paramsList);
|
|
3184
3305
|
case 5:
|
|
3185
|
-
products =
|
|
3186
|
-
return
|
|
3306
|
+
products = _context36.sent;
|
|
3307
|
+
return _context36.abrupt("return", products);
|
|
3187
3308
|
case 9:
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
throw
|
|
3309
|
+
_context36.prev = 9;
|
|
3310
|
+
_context36.t0 = _context36["catch"](0);
|
|
3311
|
+
throw _context36.t0;
|
|
3191
3312
|
case 12:
|
|
3192
3313
|
case "end":
|
|
3193
|
-
return
|
|
3314
|
+
return _context36.stop();
|
|
3194
3315
|
}
|
|
3195
|
-
},
|
|
3316
|
+
}, _callee36, this, [[0, 9]]);
|
|
3196
3317
|
}));
|
|
3197
|
-
function updateOrderProducts(
|
|
3318
|
+
function updateOrderProducts(_x30) {
|
|
3198
3319
|
return _updateOrderProducts.apply(this, arguments);
|
|
3199
3320
|
}
|
|
3200
3321
|
return updateOrderProducts;
|
|
@@ -3202,34 +3323,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3202
3323
|
}, {
|
|
3203
3324
|
key: "updateOrderProductQuantity",
|
|
3204
3325
|
value: function () {
|
|
3205
|
-
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3326
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
|
|
3206
3327
|
var products;
|
|
3207
|
-
return _regeneratorRuntime().wrap(function
|
|
3208
|
-
while (1) switch (
|
|
3328
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
3329
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
3209
3330
|
case 0:
|
|
3210
|
-
|
|
3331
|
+
_context37.prev = 0;
|
|
3211
3332
|
if (this.store.order) {
|
|
3212
|
-
|
|
3333
|
+
_context37.next = 3;
|
|
3213
3334
|
break;
|
|
3214
3335
|
}
|
|
3215
3336
|
throw new Error('order 模块未初始化');
|
|
3216
3337
|
case 3:
|
|
3217
|
-
|
|
3338
|
+
_context37.next = 5;
|
|
3218
3339
|
return this.store.order.updateOrderProductQuantity(params);
|
|
3219
3340
|
case 5:
|
|
3220
|
-
products =
|
|
3221
|
-
return
|
|
3341
|
+
products = _context37.sent;
|
|
3342
|
+
return _context37.abrupt("return", products);
|
|
3222
3343
|
case 9:
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
throw
|
|
3344
|
+
_context37.prev = 9;
|
|
3345
|
+
_context37.t0 = _context37["catch"](0);
|
|
3346
|
+
throw _context37.t0;
|
|
3226
3347
|
case 12:
|
|
3227
3348
|
case "end":
|
|
3228
|
-
return
|
|
3349
|
+
return _context37.stop();
|
|
3229
3350
|
}
|
|
3230
|
-
},
|
|
3351
|
+
}, _callee37, this, [[0, 9]]);
|
|
3231
3352
|
}));
|
|
3232
|
-
function updateOrderProductQuantity(
|
|
3353
|
+
function updateOrderProductQuantity(_x31) {
|
|
3233
3354
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
3234
3355
|
}
|
|
3235
3356
|
return updateOrderProductQuantity;
|
|
@@ -3252,12 +3373,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3252
3373
|
}, {
|
|
3253
3374
|
key: "setOrderProductLineNote",
|
|
3254
3375
|
value: (function () {
|
|
3255
|
-
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3376
|
+
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(identity, note) {
|
|
3256
3377
|
var params, products;
|
|
3257
|
-
return _regeneratorRuntime().wrap(function
|
|
3258
|
-
while (1) switch (
|
|
3378
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
3379
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
3259
3380
|
case 0:
|
|
3260
|
-
|
|
3381
|
+
_context38.prev = 0;
|
|
3261
3382
|
params = {
|
|
3262
3383
|
product_id: identity.product_id,
|
|
3263
3384
|
product_variant_id: identity.product_variant_id,
|
|
@@ -3272,22 +3393,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3272
3393
|
params.product_sku = identity.product_sku;
|
|
3273
3394
|
}
|
|
3274
3395
|
if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
|
|
3275
|
-
|
|
3396
|
+
_context38.next = 7;
|
|
3276
3397
|
return this.updateOrderProduct(params);
|
|
3277
3398
|
case 7:
|
|
3278
|
-
products =
|
|
3279
|
-
return
|
|
3399
|
+
products = _context38.sent;
|
|
3400
|
+
return _context38.abrupt("return", products);
|
|
3280
3401
|
case 11:
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
throw
|
|
3402
|
+
_context38.prev = 11;
|
|
3403
|
+
_context38.t0 = _context38["catch"](0);
|
|
3404
|
+
throw _context38.t0;
|
|
3284
3405
|
case 14:
|
|
3285
3406
|
case "end":
|
|
3286
|
-
return
|
|
3407
|
+
return _context38.stop();
|
|
3287
3408
|
}
|
|
3288
|
-
},
|
|
3409
|
+
}, _callee38, this, [[0, 11]]);
|
|
3289
3410
|
}));
|
|
3290
|
-
function setOrderProductLineNote(
|
|
3411
|
+
function setOrderProductLineNote(_x32, _x33) {
|
|
3291
3412
|
return _setOrderProductLineNote.apply(this, arguments);
|
|
3292
3413
|
}
|
|
3293
3414
|
return setOrderProductLineNote;
|
|
@@ -3302,32 +3423,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3302
3423
|
}, {
|
|
3303
3424
|
key: "removeProductsFromOrder",
|
|
3304
3425
|
value: (function () {
|
|
3305
|
-
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3306
|
-
return _regeneratorRuntime().wrap(function
|
|
3307
|
-
while (1) switch (
|
|
3426
|
+
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(identities) {
|
|
3427
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
3428
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
3308
3429
|
case 0:
|
|
3309
|
-
|
|
3430
|
+
_context39.prev = 0;
|
|
3310
3431
|
if (this.store.order) {
|
|
3311
|
-
|
|
3432
|
+
_context39.next = 3;
|
|
3312
3433
|
break;
|
|
3313
3434
|
}
|
|
3314
3435
|
throw new Error('order 模块未初始化');
|
|
3315
3436
|
case 3:
|
|
3316
|
-
|
|
3437
|
+
_context39.next = 5;
|
|
3317
3438
|
return this.store.order.removeProductsFromOrder(identities);
|
|
3318
3439
|
case 5:
|
|
3319
|
-
return
|
|
3440
|
+
return _context39.abrupt("return", _context39.sent);
|
|
3320
3441
|
case 8:
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
throw
|
|
3442
|
+
_context39.prev = 8;
|
|
3443
|
+
_context39.t0 = _context39["catch"](0);
|
|
3444
|
+
throw _context39.t0;
|
|
3324
3445
|
case 11:
|
|
3325
3446
|
case "end":
|
|
3326
|
-
return
|
|
3447
|
+
return _context39.stop();
|
|
3327
3448
|
}
|
|
3328
|
-
},
|
|
3449
|
+
}, _callee39, this, [[0, 8]]);
|
|
3329
3450
|
}));
|
|
3330
|
-
function removeProductsFromOrder(
|
|
3451
|
+
function removeProductsFromOrder(_x34) {
|
|
3331
3452
|
return _removeProductsFromOrder.apply(this, arguments);
|
|
3332
3453
|
}
|
|
3333
3454
|
return removeProductsFromOrder;
|
|
@@ -3335,18 +3456,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3335
3456
|
}, {
|
|
3336
3457
|
key: "removeProductFromOrder",
|
|
3337
3458
|
value: function () {
|
|
3338
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3339
|
-
return _regeneratorRuntime().wrap(function
|
|
3340
|
-
while (1) switch (
|
|
3459
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(identity) {
|
|
3460
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
3461
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
3341
3462
|
case 0:
|
|
3342
|
-
return
|
|
3463
|
+
return _context40.abrupt("return", this.removeProductsFromOrder([identity]));
|
|
3343
3464
|
case 1:
|
|
3344
3465
|
case "end":
|
|
3345
|
-
return
|
|
3466
|
+
return _context40.stop();
|
|
3346
3467
|
}
|
|
3347
|
-
},
|
|
3468
|
+
}, _callee40, this);
|
|
3348
3469
|
}));
|
|
3349
|
-
function removeProductFromOrder(
|
|
3470
|
+
function removeProductFromOrder(_x35) {
|
|
3350
3471
|
return _removeProductFromOrder.apply(this, arguments);
|
|
3351
3472
|
}
|
|
3352
3473
|
return removeProductFromOrder;
|
|
@@ -3396,23 +3517,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3396
3517
|
}, {
|
|
3397
3518
|
key: "applyPromotion",
|
|
3398
3519
|
value: (function () {
|
|
3399
|
-
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3400
|
-
return _regeneratorRuntime().wrap(function
|
|
3401
|
-
while (1) switch (
|
|
3520
|
+
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41() {
|
|
3521
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context41) {
|
|
3522
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
3402
3523
|
case 0:
|
|
3403
3524
|
if (this.store.order) {
|
|
3404
|
-
|
|
3525
|
+
_context41.next = 2;
|
|
3405
3526
|
break;
|
|
3406
3527
|
}
|
|
3407
3528
|
throw new Error('order 模块未初始化');
|
|
3408
3529
|
case 2:
|
|
3409
|
-
|
|
3530
|
+
_context41.next = 4;
|
|
3410
3531
|
return this.store.order.applyPromotion();
|
|
3411
3532
|
case 4:
|
|
3412
3533
|
case "end":
|
|
3413
|
-
return
|
|
3534
|
+
return _context41.stop();
|
|
3414
3535
|
}
|
|
3415
|
-
},
|
|
3536
|
+
}, _callee41, this);
|
|
3416
3537
|
}));
|
|
3417
3538
|
function applyPromotion() {
|
|
3418
3539
|
return _applyPromotion.apply(this, arguments);
|
|
@@ -3422,16 +3543,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3422
3543
|
}, {
|
|
3423
3544
|
key: "getUnfulfilledPromotions",
|
|
3424
3545
|
value: function getUnfulfilledPromotions() {
|
|
3425
|
-
var _this$store$
|
|
3426
|
-
return ((_this$store$
|
|
3546
|
+
var _this$store$order7;
|
|
3547
|
+
return ((_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 ? void 0 : _this$store$order7.getUnfulfilledPromotions()) || [];
|
|
3427
3548
|
}
|
|
3428
3549
|
|
|
3429
3550
|
/** 最近一次促销计算输出的赠品操作 diff。 */
|
|
3430
3551
|
}, {
|
|
3431
3552
|
key: "getLastGiftActions",
|
|
3432
3553
|
value: function getLastGiftActions() {
|
|
3433
|
-
var _this$store$
|
|
3434
|
-
return ((_this$store$
|
|
3554
|
+
var _this$store$order8;
|
|
3555
|
+
return ((_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 ? void 0 : _this$store$order8.getLastGiftActions()) || null;
|
|
3435
3556
|
}
|
|
3436
3557
|
|
|
3437
3558
|
// 获取商品列表
|
|
@@ -3439,18 +3560,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3439
3560
|
}, {
|
|
3440
3561
|
key: "getProductList",
|
|
3441
3562
|
value: function () {
|
|
3442
|
-
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3563
|
+
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42() {
|
|
3443
3564
|
var _this$otherParams21;
|
|
3444
3565
|
var menu_list_ids, _this$store$products, res;
|
|
3445
|
-
return _regeneratorRuntime().wrap(function
|
|
3446
|
-
while (1) switch (
|
|
3566
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context42) {
|
|
3567
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
3447
3568
|
case 0:
|
|
3448
3569
|
// 可以直接通过配置里的 menu 读取
|
|
3449
3570
|
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) {
|
|
3450
3571
|
return Number(n.value);
|
|
3451
3572
|
})) || [];
|
|
3452
|
-
|
|
3453
|
-
|
|
3573
|
+
_context42.prev = 1;
|
|
3574
|
+
_context42.next = 4;
|
|
3454
3575
|
return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
|
|
3455
3576
|
menu_list_ids: menu_list_ids,
|
|
3456
3577
|
cacheId: this.cacheId,
|
|
@@ -3458,17 +3579,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3458
3579
|
schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
3459
3580
|
});
|
|
3460
3581
|
case 4:
|
|
3461
|
-
res =
|
|
3462
|
-
return
|
|
3582
|
+
res = _context42.sent;
|
|
3583
|
+
return _context42.abrupt("return", res);
|
|
3463
3584
|
case 8:
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
throw
|
|
3585
|
+
_context42.prev = 8;
|
|
3586
|
+
_context42.t0 = _context42["catch"](1);
|
|
3587
|
+
throw _context42.t0;
|
|
3467
3588
|
case 11:
|
|
3468
3589
|
case "end":
|
|
3469
|
-
return
|
|
3590
|
+
return _context42.stop();
|
|
3470
3591
|
}
|
|
3471
|
-
},
|
|
3592
|
+
}, _callee42, this, [[1, 8]]);
|
|
3472
3593
|
}));
|
|
3473
3594
|
function getProductList() {
|
|
3474
3595
|
return _getProductList.apply(this, arguments);
|
|
@@ -3483,33 +3604,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3483
3604
|
}, {
|
|
3484
3605
|
key: "setOtherParams",
|
|
3485
3606
|
value: function () {
|
|
3486
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3607
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
|
|
3487
3608
|
var _this$otherParams22;
|
|
3488
|
-
var
|
|
3489
|
-
|
|
3609
|
+
var _ref28,
|
|
3610
|
+
_ref28$cover,
|
|
3490
3611
|
cover,
|
|
3491
|
-
|
|
3492
|
-
return _regeneratorRuntime().wrap(function
|
|
3493
|
-
while (1) switch (
|
|
3612
|
+
_args43 = arguments;
|
|
3613
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context43) {
|
|
3614
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
3494
3615
|
case 0:
|
|
3495
|
-
|
|
3616
|
+
_ref28 = _args43.length > 1 && _args43[1] !== undefined ? _args43[1] : {}, _ref28$cover = _ref28.cover, cover = _ref28$cover === void 0 ? false : _ref28$cover;
|
|
3496
3617
|
if (cover) {
|
|
3497
3618
|
this.otherParams = _objectSpread({}, params);
|
|
3498
3619
|
} else {
|
|
3499
3620
|
this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
|
|
3500
3621
|
}
|
|
3501
3622
|
this.cacheId = (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.cacheId;
|
|
3502
|
-
|
|
3623
|
+
_context43.next = 5;
|
|
3503
3624
|
return this.syncOtherParamsToSubModules(params, {
|
|
3504
3625
|
cover: cover
|
|
3505
3626
|
});
|
|
3506
3627
|
case 5:
|
|
3507
3628
|
case "end":
|
|
3508
|
-
return
|
|
3629
|
+
return _context43.stop();
|
|
3509
3630
|
}
|
|
3510
|
-
},
|
|
3631
|
+
}, _callee43, this);
|
|
3511
3632
|
}));
|
|
3512
|
-
function setOtherParams(
|
|
3633
|
+
function setOtherParams(_x36) {
|
|
3513
3634
|
return _setOtherParams.apply(this, arguments);
|
|
3514
3635
|
}
|
|
3515
3636
|
return setOtherParams;
|