@pisell/pisellos 0.0.506 → 0.0.508
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/ScanOrderLogger/providers/feishu.js +168 -60
- package/dist/modules/ScanOrderLogger/types.d.ts +6 -0
- package/dist/solution/ScanOrder/index.d.ts +21 -1
- package/dist/solution/ScanOrder/index.js +923 -485
- package/dist/solution/ScanOrder/types.d.ts +6 -0
- package/dist/solution/ScanOrder/types.js +3 -1
- package/lib/modules/ScanOrderLogger/providers/feishu.js +100 -34
- package/lib/modules/ScanOrderLogger/types.d.ts +6 -0
- package/lib/solution/ScanOrder/index.d.ts +21 -1
- package/lib/solution/ScanOrder/index.js +229 -2
- package/lib/solution/ScanOrder/types.d.ts +6 -0
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
2
1
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
2
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
5
3
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
4
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
7
|
-
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; }
|
|
8
5
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
6
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
7
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
+
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; }
|
|
9
9
|
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; }
|
|
10
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
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; }
|
|
@@ -26,6 +26,10 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
26
26
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
27
27
|
import { BaseModule } from "../../modules/BaseModule";
|
|
28
28
|
import { ScanOrderHooks } from "./types";
|
|
29
|
+
import { OrderModule } from "../../modules/Order";
|
|
30
|
+
import { AccountHooks } from "../../modules/Account/types";
|
|
31
|
+
import { RegisterAndLoginHooks } from "../RegisterAndLogin/types";
|
|
32
|
+
import Decimal from 'decimal.js';
|
|
29
33
|
import { attachItemRuleLimitsToTopLevelProducts, buildProductKey, buildItemRuleBusinessData, collectLinkProductIdsFromReservationRules, computeResourceIsFull, createEmptySummary, getProductIdentityIndex, getSafeProductNum, hasCustomCapacityProduct, pickFirstCustomCapacityPaxBounds, normalizeEnabledItemRuleIds, normalizeOrderProduct, normalizeItemRuleStrategies, pickFirstDurationMinutesFromProducts, toNonNegativeInt, toPriceString, toBoolean, toPositiveString } from "./utils";
|
|
30
34
|
import { createModule } from "../BookingByStep/types";
|
|
31
35
|
import { ProductList } from "../../modules/ProductList";
|
|
@@ -72,6 +76,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
72
76
|
_defineProperty(_assertThisInitialized(_this), "itemRuleRuntimeConfig", {});
|
|
73
77
|
/** 最近一次 checkResourceAvailable 从预约规则 link 拉取的商品快照 */
|
|
74
78
|
_defineProperty(_assertThisInitialized(_this), "enabledReservationRuleProducts", []);
|
|
79
|
+
_defineProperty(_assertThisInitialized(_this), "loginEffectDisposers", []);
|
|
80
|
+
_defineProperty(_assertThisInitialized(_this), "customerLoginRefreshInFlight", null);
|
|
81
|
+
_defineProperty(_assertThisInitialized(_this), "customerLoginRefreshIdInFlight", null);
|
|
75
82
|
return _this;
|
|
76
83
|
}
|
|
77
84
|
_createClass(ScanOrderImpl, [{
|
|
@@ -205,25 +212,199 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
205
212
|
}
|
|
206
213
|
return addLog;
|
|
207
214
|
}()
|
|
215
|
+
}, {
|
|
216
|
+
key: "normalizeCustomerId",
|
|
217
|
+
value: function normalizeCustomerId(value) {
|
|
218
|
+
var customerId = Number(value);
|
|
219
|
+
if (!Number.isFinite(customerId) || customerId <= 0) return null;
|
|
220
|
+
return customerId;
|
|
221
|
+
}
|
|
222
|
+
}, {
|
|
223
|
+
key: "resolveCustomerIdFromLoginPayload",
|
|
224
|
+
value: function resolveCustomerIdFromLoginPayload(payload) {
|
|
225
|
+
var _payload$user, _payload$user2, _payload$user3, _payload$user4, _payload$account, _payload$account2, _payload$account3, _payload$_origin;
|
|
226
|
+
var candidates = [payload === null || payload === void 0 ? void 0 : payload.customerId, payload === null || payload === void 0 ? void 0 : payload.customer_id, payload === null || payload === void 0 ? void 0 : payload.id, payload === null || payload === void 0 || (_payload$user = payload.user) === null || _payload$user === void 0 ? void 0 : _payload$user.customerId, payload === null || payload === void 0 || (_payload$user2 = payload.user) === null || _payload$user2 === void 0 ? void 0 : _payload$user2.customer_id, payload === null || payload === void 0 || (_payload$user3 = payload.user) === null || _payload$user3 === void 0 ? void 0 : _payload$user3.id, payload === null || payload === void 0 || (_payload$user4 = payload.user) === null || _payload$user4 === void 0 || (_payload$user4 = _payload$user4._origin) === null || _payload$user4 === void 0 ? void 0 : _payload$user4.customer_id, payload === null || payload === void 0 || (_payload$account = payload.account) === null || _payload$account === void 0 ? void 0 : _payload$account.customerId, payload === null || payload === void 0 || (_payload$account2 = payload.account) === null || _payload$account2 === void 0 ? void 0 : _payload$account2.customer_id, payload === null || payload === void 0 || (_payload$account3 = payload.account) === null || _payload$account3 === void 0 ? void 0 : _payload$account3.id, payload === null || payload === void 0 || (_payload$_origin = payload._origin) === null || _payload$_origin === void 0 ? void 0 : _payload$_origin.customer_id];
|
|
227
|
+
for (var _i = 0, _candidates = candidates; _i < _candidates.length; _i++) {
|
|
228
|
+
var candidate = _candidates[_i];
|
|
229
|
+
var customerId = this.normalizeCustomerId(candidate);
|
|
230
|
+
if (customerId) return customerId;
|
|
231
|
+
}
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
}, {
|
|
235
|
+
key: "clearLoginEffectListeners",
|
|
236
|
+
value: function clearLoginEffectListeners() {
|
|
237
|
+
var _iterator = _createForOfIteratorHelper(this.loginEffectDisposers),
|
|
238
|
+
_step;
|
|
239
|
+
try {
|
|
240
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
241
|
+
var dispose = _step.value;
|
|
242
|
+
dispose();
|
|
243
|
+
}
|
|
244
|
+
} catch (err) {
|
|
245
|
+
_iterator.e(err);
|
|
246
|
+
} finally {
|
|
247
|
+
_iterator.f();
|
|
248
|
+
}
|
|
249
|
+
this.loginEffectDisposers = [];
|
|
250
|
+
}
|
|
251
|
+
}, {
|
|
252
|
+
key: "registerLoginEffect",
|
|
253
|
+
value: function registerLoginEffect(event, callback) {
|
|
254
|
+
var _this$core;
|
|
255
|
+
var effects = (_this$core = this.core) === null || _this$core === void 0 ? void 0 : _this$core.effects;
|
|
256
|
+
if (!(effects !== null && effects !== void 0 && effects.on)) return;
|
|
257
|
+
effects.on(event, callback);
|
|
258
|
+
this.loginEffectDisposers.push(function () {
|
|
259
|
+
if (typeof effects.off === 'function') {
|
|
260
|
+
effects.off(event, callback);
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
}, {
|
|
265
|
+
key: "registerCustomerLoginListeners",
|
|
266
|
+
value: function registerCustomerLoginListeners() {
|
|
267
|
+
var _this2 = this;
|
|
268
|
+
this.clearLoginEffectListeners();
|
|
269
|
+
var createHandleLogin = function createHandleLogin() {
|
|
270
|
+
return /*#__PURE__*/function () {
|
|
271
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(payload) {
|
|
272
|
+
var customerId;
|
|
273
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
274
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
275
|
+
case 0:
|
|
276
|
+
customerId = _this2.resolveCustomerIdFromLoginPayload(payload);
|
|
277
|
+
if (customerId) {
|
|
278
|
+
_context3.next = 3;
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
return _context3.abrupt("return");
|
|
282
|
+
case 3:
|
|
283
|
+
_context3.next = 5;
|
|
284
|
+
return _this2.refreshOrderMarketingAfterLogin({
|
|
285
|
+
customerId: customerId
|
|
286
|
+
});
|
|
287
|
+
case 5:
|
|
288
|
+
case "end":
|
|
289
|
+
return _context3.stop();
|
|
290
|
+
}
|
|
291
|
+
}, _callee3);
|
|
292
|
+
}));
|
|
293
|
+
return function (_x3) {
|
|
294
|
+
return _ref.apply(this, arguments);
|
|
295
|
+
};
|
|
296
|
+
}();
|
|
297
|
+
};
|
|
298
|
+
this.registerLoginEffect(ScanOrderImpl.PISELL1_LOGIN_SUCCESS, createHandleLogin());
|
|
299
|
+
this.registerLoginEffect(AccountHooks.OnLogin, createHandleLogin());
|
|
300
|
+
this.registerLoginEffect(RegisterAndLoginHooks.onLoginSuccess, createHandleLogin());
|
|
301
|
+
}
|
|
302
|
+
}, {
|
|
303
|
+
key: "refreshOrderMarketingAfterLogin",
|
|
304
|
+
value: function () {
|
|
305
|
+
var _refreshOrderMarketingAfterLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(params) {
|
|
306
|
+
var _this3 = this;
|
|
307
|
+
var refreshTask;
|
|
308
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
309
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
310
|
+
case 0:
|
|
311
|
+
if (this.store.order) {
|
|
312
|
+
_context5.next = 2;
|
|
313
|
+
break;
|
|
314
|
+
}
|
|
315
|
+
throw new Error('order 模块未初始化');
|
|
316
|
+
case 2:
|
|
317
|
+
if (!this.customerLoginRefreshInFlight) {
|
|
318
|
+
_context5.next = 9;
|
|
319
|
+
break;
|
|
320
|
+
}
|
|
321
|
+
if (!(this.customerLoginRefreshIdInFlight === params.customerId)) {
|
|
322
|
+
_context5.next = 7;
|
|
323
|
+
break;
|
|
324
|
+
}
|
|
325
|
+
_context5.next = 6;
|
|
326
|
+
return this.customerLoginRefreshInFlight;
|
|
327
|
+
case 6:
|
|
328
|
+
return _context5.abrupt("return");
|
|
329
|
+
case 7:
|
|
330
|
+
_context5.next = 9;
|
|
331
|
+
return this.customerLoginRefreshInFlight;
|
|
332
|
+
case 9:
|
|
333
|
+
this.customerLoginRefreshIdInFlight = params.customerId;
|
|
334
|
+
refreshTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
335
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
336
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
337
|
+
case 0:
|
|
338
|
+
_context4.next = 2;
|
|
339
|
+
return _this3.store.order.loadDiscountConfig({
|
|
340
|
+
customerId: params.customerId
|
|
341
|
+
});
|
|
342
|
+
case 2:
|
|
343
|
+
_context4.next = 4;
|
|
344
|
+
return _this3.store.order.recalculateSummary({
|
|
345
|
+
createIfMissing: true
|
|
346
|
+
});
|
|
347
|
+
case 4:
|
|
348
|
+
_this3.store.order.persistTempOrder();
|
|
349
|
+
_context4.next = 7;
|
|
350
|
+
return _this3.refreshItemRuleQuantityLimits();
|
|
351
|
+
case 7:
|
|
352
|
+
_context4.next = 9;
|
|
353
|
+
return _this3.refreshCartValidationPassed();
|
|
354
|
+
case 9:
|
|
355
|
+
case "end":
|
|
356
|
+
return _context4.stop();
|
|
357
|
+
}
|
|
358
|
+
}, _callee4);
|
|
359
|
+
}))();
|
|
360
|
+
this.customerLoginRefreshInFlight = refreshTask;
|
|
361
|
+
_context5.prev = 12;
|
|
362
|
+
_context5.next = 15;
|
|
363
|
+
return refreshTask;
|
|
364
|
+
case 15:
|
|
365
|
+
_context5.next = 20;
|
|
366
|
+
break;
|
|
367
|
+
case 17:
|
|
368
|
+
_context5.prev = 17;
|
|
369
|
+
_context5.t0 = _context5["catch"](12);
|
|
370
|
+
throw _context5.t0;
|
|
371
|
+
case 20:
|
|
372
|
+
_context5.prev = 20;
|
|
373
|
+
if (this.customerLoginRefreshInFlight === refreshTask) {
|
|
374
|
+
this.customerLoginRefreshInFlight = null;
|
|
375
|
+
this.customerLoginRefreshIdInFlight = null;
|
|
376
|
+
}
|
|
377
|
+
return _context5.finish(20);
|
|
378
|
+
case 23:
|
|
379
|
+
case "end":
|
|
380
|
+
return _context5.stop();
|
|
381
|
+
}
|
|
382
|
+
}, _callee5, this, [[12, 17, 20, 23]]);
|
|
383
|
+
}));
|
|
384
|
+
function refreshOrderMarketingAfterLogin(_x4) {
|
|
385
|
+
return _refreshOrderMarketingAfterLogin.apply(this, arguments);
|
|
386
|
+
}
|
|
387
|
+
return refreshOrderMarketingAfterLogin;
|
|
388
|
+
}()
|
|
208
389
|
}, {
|
|
209
390
|
key: "initialize",
|
|
210
391
|
value: function () {
|
|
211
|
-
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
392
|
+
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(core) {
|
|
212
393
|
var _options$otherParams,
|
|
213
394
|
_this$otherParams,
|
|
214
395
|
_this$otherParams2,
|
|
215
396
|
_this$otherParams3,
|
|
216
|
-
|
|
397
|
+
_this4 = this;
|
|
217
398
|
var options,
|
|
218
399
|
moduleArr,
|
|
219
400
|
scheduleModule,
|
|
220
401
|
_this$store$order,
|
|
221
402
|
_this$store$order2,
|
|
222
|
-
|
|
223
|
-
return _regeneratorRuntime().wrap(function
|
|
224
|
-
while (1) switch (
|
|
403
|
+
_args6 = arguments;
|
|
404
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
405
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
225
406
|
case 0:
|
|
226
|
-
options =
|
|
407
|
+
options = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : {};
|
|
227
408
|
this.logMethodStart('initialize');
|
|
228
409
|
this.core = core;
|
|
229
410
|
this.initializeOptions = options || {};
|
|
@@ -245,14 +426,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
245
426
|
this.window = core.getPlugin('window');
|
|
246
427
|
this.request = core.getPlugin('request');
|
|
247
428
|
if (this.window) {
|
|
248
|
-
|
|
429
|
+
_context6.next = 21;
|
|
249
430
|
break;
|
|
250
431
|
}
|
|
251
432
|
this.logMethodError('initialize', 'window plugin missing');
|
|
252
433
|
throw new Error('scanOrder解决方案需要 window 插件支持');
|
|
253
434
|
case 21:
|
|
254
435
|
if (this.request) {
|
|
255
|
-
|
|
436
|
+
_context6.next = 24;
|
|
256
437
|
break;
|
|
257
438
|
}
|
|
258
439
|
this.logMethodError('initialize', 'request plugin missing');
|
|
@@ -260,33 +441,33 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
260
441
|
case 24:
|
|
261
442
|
moduleArr = ['scanOrderLogger', 'products', 'order', 'salesSummary'];
|
|
262
443
|
moduleArr.forEach(function (step) {
|
|
263
|
-
var targetModule = createModule(step,
|
|
444
|
+
var targetModule = createModule(step, _this4.name);
|
|
264
445
|
if (targetModule) {
|
|
265
|
-
var
|
|
266
|
-
|
|
446
|
+
var _this4$store$order, _this4$otherParams, _this4$otherParams2, _this4$otherParams3, _this4$otherParams4;
|
|
447
|
+
_this4.store[step] = targetModule;
|
|
267
448
|
var initialState = step === 'salesSummary' ? {
|
|
268
|
-
summary: ((
|
|
449
|
+
summary: ((_this4$store$order = _this4.store.order) === null || _this4$store$order === void 0 || (_this4$store$order = _this4$store$order.getTempOrder()) === null || _this4$store$order === void 0 ? void 0 : _this4$store$order.summary) || createEmptySummary()
|
|
269
450
|
} : {};
|
|
270
|
-
var loggerProvider = ((
|
|
271
|
-
var loggerConfig = ((
|
|
451
|
+
var loggerProvider = ((_this4$otherParams = _this4.otherParams) === null || _this4$otherParams === void 0 ? void 0 : _this4$otherParams.scanOrderLoggerProvider) || 'feishu';
|
|
452
|
+
var loggerConfig = ((_this4$otherParams2 = _this4.otherParams) === null || _this4$otherParams2 === void 0 ? void 0 : _this4$otherParams2.scanOrderLoggerConfig) || {
|
|
272
453
|
feishu: {
|
|
273
454
|
webhook: 'https://open.feishu.cn/open-apis/bot/v2/hook/216b3fe6-af98-424e-8706-f0471241a7ed'
|
|
274
455
|
}
|
|
275
456
|
};
|
|
276
|
-
|
|
457
|
+
_this4.core.registerModule(targetModule, {
|
|
277
458
|
initialState: initialState,
|
|
278
|
-
otherParams: _objectSpread(_objectSpread({},
|
|
279
|
-
fatherModule:
|
|
280
|
-
openCache: (
|
|
281
|
-
cacheId: (
|
|
282
|
-
salesSummaryModuleName: "".concat(
|
|
459
|
+
otherParams: _objectSpread(_objectSpread({}, _this4.otherParams), {}, {
|
|
460
|
+
fatherModule: _this4.name,
|
|
461
|
+
openCache: (_this4$otherParams3 = _this4.otherParams) !== null && _this4$otherParams3 !== void 0 && _this4$otherParams3.cacheId ? true : false,
|
|
462
|
+
cacheId: (_this4$otherParams4 = _this4.otherParams) === null || _this4$otherParams4 === void 0 ? void 0 : _this4$otherParams4.cacheId,
|
|
463
|
+
salesSummaryModuleName: "".concat(_this4.name, "_salesSummary"),
|
|
283
464
|
provider: loggerProvider,
|
|
284
465
|
providerConfig: loggerConfig,
|
|
285
|
-
context:
|
|
466
|
+
context: _this4.getScanOrderLoggerContext()
|
|
286
467
|
})
|
|
287
468
|
});
|
|
288
469
|
} else {
|
|
289
|
-
|
|
470
|
+
_this4.logMethodError('initialize', "module ".concat(step, " missing"));
|
|
290
471
|
throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
|
|
291
472
|
}
|
|
292
473
|
});
|
|
@@ -300,64 +481,65 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
300
481
|
fatherModule: this.name
|
|
301
482
|
})
|
|
302
483
|
});
|
|
484
|
+
this.registerCustomerLoginListeners();
|
|
303
485
|
console.log('[ScanOrder] 初始化开始');
|
|
304
|
-
|
|
305
|
-
|
|
486
|
+
_context6.prev = 32;
|
|
487
|
+
_context6.next = 35;
|
|
306
488
|
return (_this$store$order = this.store.order) === null || _this$store$order === void 0 ? void 0 : _this$store$order.recalculateSummary({
|
|
307
489
|
createIfMissing: false
|
|
308
490
|
});
|
|
309
|
-
case
|
|
491
|
+
case 35:
|
|
310
492
|
(_this$store$order2 = this.store.order) === null || _this$store$order2 === void 0 || _this$store$order2.persistTempOrder();
|
|
311
|
-
|
|
493
|
+
_context6.next = 38;
|
|
312
494
|
return this.loadRuntimeConfigs();
|
|
313
|
-
case
|
|
495
|
+
case 38:
|
|
314
496
|
if (!this.store.schedule) {
|
|
315
|
-
|
|
497
|
+
_context6.next = 47;
|
|
316
498
|
break;
|
|
317
499
|
}
|
|
318
|
-
|
|
319
|
-
|
|
500
|
+
_context6.prev = 39;
|
|
501
|
+
_context6.next = 42;
|
|
320
502
|
return this.store.schedule.loadAllSchedule();
|
|
321
|
-
case
|
|
322
|
-
|
|
503
|
+
case 42:
|
|
504
|
+
_context6.next = 47;
|
|
323
505
|
break;
|
|
324
|
-
case
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
console.warn('[ScanOrder] loadAllSchedule 失败,operating_hours 判定将跳过',
|
|
328
|
-
case
|
|
329
|
-
|
|
506
|
+
case 44:
|
|
507
|
+
_context6.prev = 44;
|
|
508
|
+
_context6.t0 = _context6["catch"](39);
|
|
509
|
+
console.warn('[ScanOrder] loadAllSchedule 失败,operating_hours 判定将跳过', _context6.t0);
|
|
510
|
+
case 47:
|
|
511
|
+
_context6.next = 49;
|
|
330
512
|
return this.refreshItemRuleQuantityLimits();
|
|
331
|
-
case
|
|
513
|
+
case 49:
|
|
332
514
|
this.store.status = 'ready';
|
|
333
515
|
console.log('[ScanOrder] 初始化完成');
|
|
334
|
-
|
|
516
|
+
_context6.next = 53;
|
|
335
517
|
return this.core.effects.emit(ScanOrderHooks.onInited, {
|
|
336
518
|
status: this.store.status
|
|
337
519
|
});
|
|
338
|
-
case
|
|
520
|
+
case 53:
|
|
339
521
|
this.logMethodSuccess('initialize', {
|
|
340
522
|
status: this.store.status
|
|
341
523
|
});
|
|
342
|
-
|
|
524
|
+
_context6.next = 63;
|
|
343
525
|
break;
|
|
344
|
-
case
|
|
345
|
-
|
|
346
|
-
|
|
526
|
+
case 56:
|
|
527
|
+
_context6.prev = 56;
|
|
528
|
+
_context6.t1 = _context6["catch"](32);
|
|
347
529
|
this.store.status = 'error';
|
|
348
|
-
this.store.error =
|
|
349
|
-
console.error('[ScanOrder] 初始化失败',
|
|
350
|
-
this.logMethodError('initialize',
|
|
530
|
+
this.store.error = _context6.t1 instanceof Error ? _context6.t1.message : '初始化失败';
|
|
531
|
+
console.error('[ScanOrder] 初始化失败', _context6.t1);
|
|
532
|
+
this.logMethodError('initialize', _context6.t1, {
|
|
351
533
|
status: this.store.status
|
|
352
534
|
});
|
|
353
|
-
throw
|
|
354
|
-
case
|
|
535
|
+
throw _context6.t1;
|
|
536
|
+
case 63:
|
|
355
537
|
case "end":
|
|
356
|
-
return
|
|
538
|
+
return _context6.stop();
|
|
357
539
|
}
|
|
358
|
-
},
|
|
540
|
+
}, _callee6, this, [[32, 56], [39, 44]]);
|
|
359
541
|
}));
|
|
360
|
-
function initialize(
|
|
542
|
+
function initialize(_x5) {
|
|
361
543
|
return _initialize.apply(this, arguments);
|
|
362
544
|
}
|
|
363
545
|
return initialize;
|
|
@@ -365,21 +547,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
365
547
|
}, {
|
|
366
548
|
key: "destroy",
|
|
367
549
|
value: function () {
|
|
368
|
-
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
369
|
-
return _regeneratorRuntime().wrap(function
|
|
370
|
-
while (1) switch (
|
|
550
|
+
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
551
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
552
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
371
553
|
case 0:
|
|
372
554
|
this.logMethodStart('destroy');
|
|
373
|
-
|
|
555
|
+
this.clearLoginEffectListeners();
|
|
556
|
+
_context7.next = 4;
|
|
374
557
|
return this.core.effects.emit(ScanOrderHooks.onDestroy, {});
|
|
375
|
-
case
|
|
558
|
+
case 4:
|
|
376
559
|
console.log('[ScanOrder] 已销毁');
|
|
377
560
|
this.logMethodSuccess('destroy');
|
|
378
|
-
case
|
|
561
|
+
case 6:
|
|
379
562
|
case "end":
|
|
380
|
-
return
|
|
563
|
+
return _context7.stop();
|
|
381
564
|
}
|
|
382
|
-
},
|
|
565
|
+
}, _callee7, this);
|
|
383
566
|
}));
|
|
384
567
|
function destroy() {
|
|
385
568
|
return _destroy.apply(this, arguments);
|
|
@@ -389,33 +572,33 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
389
572
|
}, {
|
|
390
573
|
key: "retryInit",
|
|
391
574
|
value: function () {
|
|
392
|
-
var _retryInit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
393
|
-
return _regeneratorRuntime().wrap(function
|
|
394
|
-
while (1) switch (
|
|
575
|
+
var _retryInit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
576
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
577
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
395
578
|
case 0:
|
|
396
579
|
this.logMethodStart('retryInit');
|
|
397
580
|
// TODO: 细化重试策略(指数退避、最大重试次数)后替换当前实现
|
|
398
581
|
console.log('[ScanOrder] retryInit 调用');
|
|
399
|
-
|
|
582
|
+
_context8.next = 4;
|
|
400
583
|
return this.core.effects.emit(ScanOrderHooks.onRetryInit, {});
|
|
401
584
|
case 4:
|
|
402
|
-
|
|
403
|
-
|
|
585
|
+
_context8.prev = 4;
|
|
586
|
+
_context8.next = 7;
|
|
404
587
|
return this.initialize(this.core, this.initializeOptions);
|
|
405
588
|
case 7:
|
|
406
589
|
this.logMethodSuccess('retryInit');
|
|
407
|
-
|
|
590
|
+
_context8.next = 14;
|
|
408
591
|
break;
|
|
409
592
|
case 10:
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
this.logMethodError('retryInit',
|
|
413
|
-
throw
|
|
593
|
+
_context8.prev = 10;
|
|
594
|
+
_context8.t0 = _context8["catch"](4);
|
|
595
|
+
this.logMethodError('retryInit', _context8.t0);
|
|
596
|
+
throw _context8.t0;
|
|
414
597
|
case 14:
|
|
415
598
|
case "end":
|
|
416
|
-
return
|
|
599
|
+
return _context8.stop();
|
|
417
600
|
}
|
|
418
|
-
},
|
|
601
|
+
}, _callee8, this, [[4, 10]]);
|
|
419
602
|
}));
|
|
420
603
|
function retryInit() {
|
|
421
604
|
return _retryInit.apply(this, arguments);
|
|
@@ -425,23 +608,23 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
425
608
|
}, {
|
|
426
609
|
key: "refresh",
|
|
427
610
|
value: function () {
|
|
428
|
-
var _refresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
429
|
-
return _regeneratorRuntime().wrap(function
|
|
430
|
-
while (1) switch (
|
|
611
|
+
var _refresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
612
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
613
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
431
614
|
case 0:
|
|
432
615
|
this.logMethodStart('refresh');
|
|
433
616
|
// TODO: 接入真实刷新逻辑(资源重拉取、流程重建)后替换当前实现
|
|
434
617
|
console.log('[ScanOrder] refresh 调用');
|
|
435
|
-
|
|
618
|
+
_context9.prev = 2;
|
|
436
619
|
this.store.status = 'initializing';
|
|
437
|
-
|
|
620
|
+
_context9.next = 6;
|
|
438
621
|
return this.loadRuntimeConfigs();
|
|
439
622
|
case 6:
|
|
440
|
-
|
|
623
|
+
_context9.next = 8;
|
|
441
624
|
return this.refreshItemRuleQuantityLimits();
|
|
442
625
|
case 8:
|
|
443
626
|
this.store.status = 'ready';
|
|
444
|
-
|
|
627
|
+
_context9.next = 11;
|
|
445
628
|
return this.core.effects.emit(ScanOrderHooks.onRefresh, {
|
|
446
629
|
status: this.store.status
|
|
447
630
|
});
|
|
@@ -449,18 +632,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
449
632
|
this.logMethodSuccess('refresh', {
|
|
450
633
|
status: this.store.status
|
|
451
634
|
});
|
|
452
|
-
|
|
635
|
+
_context9.next = 18;
|
|
453
636
|
break;
|
|
454
637
|
case 14:
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
this.logMethodError('refresh',
|
|
458
|
-
throw
|
|
638
|
+
_context9.prev = 14;
|
|
639
|
+
_context9.t0 = _context9["catch"](2);
|
|
640
|
+
this.logMethodError('refresh', _context9.t0);
|
|
641
|
+
throw _context9.t0;
|
|
459
642
|
case 18:
|
|
460
643
|
case "end":
|
|
461
|
-
return
|
|
644
|
+
return _context9.stop();
|
|
462
645
|
}
|
|
463
|
-
},
|
|
646
|
+
}, _callee9, this, [[2, 14]]);
|
|
464
647
|
}));
|
|
465
648
|
function refresh() {
|
|
466
649
|
return _refresh.apply(this, arguments);
|
|
@@ -624,37 +807,37 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
624
807
|
}, {
|
|
625
808
|
key: "addNewOrder",
|
|
626
809
|
value: function () {
|
|
627
|
-
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
810
|
+
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
628
811
|
var tempOrder;
|
|
629
|
-
return _regeneratorRuntime().wrap(function
|
|
630
|
-
while (1) switch (
|
|
812
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
813
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
631
814
|
case 0:
|
|
632
815
|
this.logMethodStart('addNewOrder');
|
|
633
|
-
|
|
816
|
+
_context10.prev = 1;
|
|
634
817
|
if (this.store.order) {
|
|
635
|
-
|
|
818
|
+
_context10.next = 4;
|
|
636
819
|
break;
|
|
637
820
|
}
|
|
638
821
|
throw new Error('order 模块未初始化');
|
|
639
822
|
case 4:
|
|
640
|
-
|
|
823
|
+
_context10.next = 6;
|
|
641
824
|
return this.store.order.addNewOrder();
|
|
642
825
|
case 6:
|
|
643
|
-
tempOrder =
|
|
826
|
+
tempOrder = _context10.sent;
|
|
644
827
|
this.logMethodSuccess('addNewOrder', {
|
|
645
828
|
productCount: tempOrder.products.length
|
|
646
829
|
});
|
|
647
|
-
return
|
|
830
|
+
return _context10.abrupt("return", tempOrder);
|
|
648
831
|
case 11:
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
this.logMethodError('addNewOrder',
|
|
652
|
-
throw
|
|
832
|
+
_context10.prev = 11;
|
|
833
|
+
_context10.t0 = _context10["catch"](1);
|
|
834
|
+
this.logMethodError('addNewOrder', _context10.t0);
|
|
835
|
+
throw _context10.t0;
|
|
653
836
|
case 15:
|
|
654
837
|
case "end":
|
|
655
|
-
return
|
|
838
|
+
return _context10.stop();
|
|
656
839
|
}
|
|
657
|
-
},
|
|
840
|
+
}, _callee10, this, [[1, 11]]);
|
|
658
841
|
}));
|
|
659
842
|
function addNewOrder() {
|
|
660
843
|
return _addNewOrder.apply(this, arguments);
|
|
@@ -665,15 +848,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
665
848
|
}, {
|
|
666
849
|
key: "restoreOrder",
|
|
667
850
|
value: function () {
|
|
668
|
-
var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
851
|
+
var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
669
852
|
var tempOrder;
|
|
670
|
-
return _regeneratorRuntime().wrap(function
|
|
671
|
-
while (1) switch (
|
|
853
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
854
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
672
855
|
case 0:
|
|
673
856
|
this.logMethodStart('restoreOrder');
|
|
674
|
-
|
|
857
|
+
_context11.prev = 1;
|
|
675
858
|
if (this.store.order) {
|
|
676
|
-
|
|
859
|
+
_context11.next = 4;
|
|
677
860
|
break;
|
|
678
861
|
}
|
|
679
862
|
throw new Error('scanOrder 解决方案需要 order 模块支持');
|
|
@@ -683,17 +866,17 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
683
866
|
this.enabledReservationRuleProducts = [];
|
|
684
867
|
tempOrder = this.store.order.restoreOrder();
|
|
685
868
|
this.logMethodSuccess('restoreOrder');
|
|
686
|
-
return
|
|
869
|
+
return _context11.abrupt("return", tempOrder);
|
|
687
870
|
case 12:
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
this.logMethodError('restoreOrder',
|
|
691
|
-
throw
|
|
871
|
+
_context11.prev = 12;
|
|
872
|
+
_context11.t0 = _context11["catch"](1);
|
|
873
|
+
this.logMethodError('restoreOrder', _context11.t0);
|
|
874
|
+
throw _context11.t0;
|
|
692
875
|
case 16:
|
|
693
876
|
case "end":
|
|
694
|
-
return
|
|
877
|
+
return _context11.stop();
|
|
695
878
|
}
|
|
696
|
-
},
|
|
879
|
+
}, _callee11, this, [[1, 12]]);
|
|
697
880
|
}));
|
|
698
881
|
function restoreOrder() {
|
|
699
882
|
return _restoreOrder.apply(this, arguments);
|
|
@@ -714,42 +897,296 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
714
897
|
}, {
|
|
715
898
|
key: "getSummary",
|
|
716
899
|
value: function () {
|
|
717
|
-
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
900
|
+
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
718
901
|
var summary;
|
|
719
|
-
return _regeneratorRuntime().wrap(function
|
|
720
|
-
while (1) switch (
|
|
902
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
903
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
721
904
|
case 0:
|
|
722
905
|
this.logMethodStart('getSummary');
|
|
723
|
-
|
|
906
|
+
_context12.prev = 1;
|
|
724
907
|
if (this.store.order) {
|
|
725
|
-
|
|
908
|
+
_context12.next = 4;
|
|
726
909
|
break;
|
|
727
910
|
}
|
|
728
911
|
throw new Error('order 模块未初始化');
|
|
729
912
|
case 4:
|
|
730
|
-
|
|
913
|
+
_context12.next = 6;
|
|
731
914
|
return this.store.order.getScanOrderSummary();
|
|
732
915
|
case 6:
|
|
733
|
-
summary =
|
|
916
|
+
summary = _context12.sent;
|
|
734
917
|
this.logMethodSuccess('getSummary', {
|
|
735
918
|
totalAmount: summary.total_amount
|
|
736
919
|
});
|
|
737
|
-
return
|
|
920
|
+
return _context12.abrupt("return", summary);
|
|
738
921
|
case 11:
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
this.logMethodError('getSummary',
|
|
742
|
-
throw
|
|
922
|
+
_context12.prev = 11;
|
|
923
|
+
_context12.t0 = _context12["catch"](1);
|
|
924
|
+
this.logMethodError('getSummary', _context12.t0);
|
|
925
|
+
throw _context12.t0;
|
|
743
926
|
case 15:
|
|
744
927
|
case "end":
|
|
745
|
-
return
|
|
928
|
+
return _context12.stop();
|
|
746
929
|
}
|
|
747
|
-
},
|
|
930
|
+
}, _callee12, this, [[1, 11]]);
|
|
748
931
|
}));
|
|
749
932
|
function getSummary() {
|
|
750
933
|
return _getSummary.apply(this, arguments);
|
|
751
934
|
}
|
|
752
935
|
return getSummary;
|
|
936
|
+
}()
|
|
937
|
+
}, {
|
|
938
|
+
key: "getDiscountList",
|
|
939
|
+
value: function getDiscountList() {
|
|
940
|
+
if (!this.store.order) return [];
|
|
941
|
+
return this.store.order.getDiscountList();
|
|
942
|
+
}
|
|
943
|
+
}, {
|
|
944
|
+
key: "scanCode",
|
|
945
|
+
value: function () {
|
|
946
|
+
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(code, customerId) {
|
|
947
|
+
var raw;
|
|
948
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
949
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
950
|
+
case 0:
|
|
951
|
+
this.logMethodStart('scanCode', {
|
|
952
|
+
code: code
|
|
953
|
+
});
|
|
954
|
+
_context13.prev = 1;
|
|
955
|
+
if (this.store.order) {
|
|
956
|
+
_context13.next = 4;
|
|
957
|
+
break;
|
|
958
|
+
}
|
|
959
|
+
throw new Error('order 模块未初始化');
|
|
960
|
+
case 4:
|
|
961
|
+
_context13.next = 6;
|
|
962
|
+
return this.store.order.scanCode(code, customerId);
|
|
963
|
+
case 6:
|
|
964
|
+
raw = _context13.sent;
|
|
965
|
+
if (!raw.isAvailable) {
|
|
966
|
+
_context13.next = 11;
|
|
967
|
+
break;
|
|
968
|
+
}
|
|
969
|
+
_context13.next = 10;
|
|
970
|
+
return this.store.order.recalculateSummary({
|
|
971
|
+
createIfMissing: true
|
|
972
|
+
});
|
|
973
|
+
case 10:
|
|
974
|
+
this.store.order.persistTempOrder();
|
|
975
|
+
case 11:
|
|
976
|
+
this.logMethodSuccess('scanCode', {
|
|
977
|
+
isAvailable: raw.isAvailable
|
|
978
|
+
});
|
|
979
|
+
return _context13.abrupt("return", {
|
|
980
|
+
isAvailable: raw.isAvailable,
|
|
981
|
+
type: raw.type,
|
|
982
|
+
unavailableReason: raw.unavailableReason
|
|
983
|
+
});
|
|
984
|
+
case 15:
|
|
985
|
+
_context13.prev = 15;
|
|
986
|
+
_context13.t0 = _context13["catch"](1);
|
|
987
|
+
this.logMethodError('scanCode', _context13.t0);
|
|
988
|
+
throw _context13.t0;
|
|
989
|
+
case 19:
|
|
990
|
+
case "end":
|
|
991
|
+
return _context13.stop();
|
|
992
|
+
}
|
|
993
|
+
}, _callee13, this, [[1, 15]]);
|
|
994
|
+
}));
|
|
995
|
+
function scanCode(_x6, _x7) {
|
|
996
|
+
return _scanCode.apply(this, arguments);
|
|
997
|
+
}
|
|
998
|
+
return scanCode;
|
|
999
|
+
}()
|
|
1000
|
+
}, {
|
|
1001
|
+
key: "setDiscountSelected",
|
|
1002
|
+
value: function () {
|
|
1003
|
+
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(params) {
|
|
1004
|
+
var _tempOrder$holder, list, updated, tempOrder, orderStore, discountModule, rulesModule, holders, nextDiscountList, _tempOrder$holder2, result, beforeSelectedIds, _iterator2, _step2, d, selectedResourceIds, _iterator3, _step3, _product$_origin, product, totalPerUnitDiscount, newSellingPrice;
|
|
1005
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1006
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1007
|
+
case 0:
|
|
1008
|
+
this.logMethodStart('setDiscountSelected', params);
|
|
1009
|
+
_context14.prev = 1;
|
|
1010
|
+
if (this.store.order) {
|
|
1011
|
+
_context14.next = 4;
|
|
1012
|
+
break;
|
|
1013
|
+
}
|
|
1014
|
+
throw new Error('order 模块未初始化');
|
|
1015
|
+
case 4:
|
|
1016
|
+
list = this.store.order.getDiscountList();
|
|
1017
|
+
updated = list.map(function (d) {
|
|
1018
|
+
return d.id === params.discountId ? _objectSpread(_objectSpread({}, d), {}, {
|
|
1019
|
+
isSelected: params.isSelected,
|
|
1020
|
+
isManualSelect: !params.isSelected
|
|
1021
|
+
}) : d;
|
|
1022
|
+
});
|
|
1023
|
+
tempOrder = this.store.order.ensureTempOrder();
|
|
1024
|
+
orderStore = this.store.order.store || {};
|
|
1025
|
+
discountModule = orderStore.discount;
|
|
1026
|
+
rulesModule = orderStore.rules;
|
|
1027
|
+
holders = (_tempOrder$holder = tempOrder.holder) !== null && _tempOrder$holder !== void 0 && _tempOrder$holder.form_record_id ? [{
|
|
1028
|
+
form_record_id: tempOrder.holder.form_record_id
|
|
1029
|
+
}] : [];
|
|
1030
|
+
nextDiscountList = updated;
|
|
1031
|
+
_context14.next = 14;
|
|
1032
|
+
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(updated);
|
|
1033
|
+
case 14:
|
|
1034
|
+
if (rulesModule) {
|
|
1035
|
+
result = rulesModule.calcDiscount({
|
|
1036
|
+
productList: tempOrder.products,
|
|
1037
|
+
discountList: updated,
|
|
1038
|
+
holders: holders,
|
|
1039
|
+
isFormSubject: !!((_tempOrder$holder2 = tempOrder.holder) !== null && _tempOrder$holder2 !== void 0 && _tempOrder$holder2.type) && tempOrder.holder.type === 'form'
|
|
1040
|
+
}, {
|
|
1041
|
+
discountId: params.discountId,
|
|
1042
|
+
isSelected: params.isSelected
|
|
1043
|
+
}) || {
|
|
1044
|
+
productList: tempOrder.products,
|
|
1045
|
+
discountList: updated
|
|
1046
|
+
};
|
|
1047
|
+
if (result !== null && result !== void 0 && result.productList) {
|
|
1048
|
+
tempOrder.products = result.productList;
|
|
1049
|
+
}
|
|
1050
|
+
if (result !== null && result !== void 0 && result.discountList) {
|
|
1051
|
+
nextDiscountList = result.discountList;
|
|
1052
|
+
if (!params.isSelected) {
|
|
1053
|
+
beforeSelectedIds = new Set(updated.filter(function (d) {
|
|
1054
|
+
return d.isSelected;
|
|
1055
|
+
}).map(function (d) {
|
|
1056
|
+
return d.id;
|
|
1057
|
+
}));
|
|
1058
|
+
_iterator2 = _createForOfIteratorHelper(nextDiscountList);
|
|
1059
|
+
try {
|
|
1060
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
1061
|
+
d = _step2.value;
|
|
1062
|
+
if (d.isSelected && !beforeSelectedIds.has(d.id)) {
|
|
1063
|
+
d.isSelected = false;
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
} catch (err) {
|
|
1067
|
+
_iterator2.e(err);
|
|
1068
|
+
} finally {
|
|
1069
|
+
_iterator2.f();
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
selectedResourceIds = new Set(nextDiscountList.filter(function (d) {
|
|
1075
|
+
return d.isSelected;
|
|
1076
|
+
}).map(function (d) {
|
|
1077
|
+
return d.id;
|
|
1078
|
+
}));
|
|
1079
|
+
_iterator3 = _createForOfIteratorHelper(tempOrder.products);
|
|
1080
|
+
_context14.prev = 17;
|
|
1081
|
+
_iterator3.s();
|
|
1082
|
+
case 19:
|
|
1083
|
+
if ((_step3 = _iterator3.n()).done) {
|
|
1084
|
+
_context14.next = 30;
|
|
1085
|
+
break;
|
|
1086
|
+
}
|
|
1087
|
+
product = _step3.value;
|
|
1088
|
+
if (!((_product$_origin = product._origin) !== null && _product$_origin !== void 0 && _product$_origin.isManualDiscount)) {
|
|
1089
|
+
_context14.next = 23;
|
|
1090
|
+
break;
|
|
1091
|
+
}
|
|
1092
|
+
return _context14.abrupt("continue", 28);
|
|
1093
|
+
case 23:
|
|
1094
|
+
product.discount_list = (product.discount_list || []).filter(function (pd) {
|
|
1095
|
+
var _pd$discount$resource, _pd$discount;
|
|
1096
|
+
var rid = (_pd$discount$resource = (_pd$discount = pd.discount) === null || _pd$discount === void 0 ? void 0 : _pd$discount.resource_id) !== null && _pd$discount$resource !== void 0 ? _pd$discount$resource : pd.id;
|
|
1097
|
+
return rid != null && selectedResourceIds.has(rid);
|
|
1098
|
+
});
|
|
1099
|
+
totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
|
|
1100
|
+
return sum + (pd.amount || 0);
|
|
1101
|
+
}, 0);
|
|
1102
|
+
newSellingPrice = new Decimal(product.original_price || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
1103
|
+
product.selling_price = newSellingPrice;
|
|
1104
|
+
if (product.metadata) {
|
|
1105
|
+
product.metadata.main_product_selling_price = newSellingPrice;
|
|
1106
|
+
}
|
|
1107
|
+
case 28:
|
|
1108
|
+
_context14.next = 19;
|
|
1109
|
+
break;
|
|
1110
|
+
case 30:
|
|
1111
|
+
_context14.next = 35;
|
|
1112
|
+
break;
|
|
1113
|
+
case 32:
|
|
1114
|
+
_context14.prev = 32;
|
|
1115
|
+
_context14.t0 = _context14["catch"](17);
|
|
1116
|
+
_iterator3.e(_context14.t0);
|
|
1117
|
+
case 35:
|
|
1118
|
+
_context14.prev = 35;
|
|
1119
|
+
_iterator3.f();
|
|
1120
|
+
return _context14.finish(35);
|
|
1121
|
+
case 38:
|
|
1122
|
+
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
1123
|
+
_context14.next = 41;
|
|
1124
|
+
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
1125
|
+
case 41:
|
|
1126
|
+
tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
|
|
1127
|
+
return d.isSelected;
|
|
1128
|
+
});
|
|
1129
|
+
_context14.next = 44;
|
|
1130
|
+
return this.store.order.recalculateSummary({
|
|
1131
|
+
createIfMissing: true
|
|
1132
|
+
});
|
|
1133
|
+
case 44:
|
|
1134
|
+
this.store.order.persistTempOrder();
|
|
1135
|
+
this.logMethodSuccess('setDiscountSelected', params);
|
|
1136
|
+
_context14.next = 52;
|
|
1137
|
+
break;
|
|
1138
|
+
case 48:
|
|
1139
|
+
_context14.prev = 48;
|
|
1140
|
+
_context14.t1 = _context14["catch"](1);
|
|
1141
|
+
this.logMethodError('setDiscountSelected', _context14.t1);
|
|
1142
|
+
throw _context14.t1;
|
|
1143
|
+
case 52:
|
|
1144
|
+
case "end":
|
|
1145
|
+
return _context14.stop();
|
|
1146
|
+
}
|
|
1147
|
+
}, _callee14, this, [[1, 48], [17, 32, 35, 38]]);
|
|
1148
|
+
}));
|
|
1149
|
+
function setDiscountSelected(_x8) {
|
|
1150
|
+
return _setDiscountSelected.apply(this, arguments);
|
|
1151
|
+
}
|
|
1152
|
+
return setDiscountSelected;
|
|
1153
|
+
}()
|
|
1154
|
+
}, {
|
|
1155
|
+
key: "onCustomerLogin",
|
|
1156
|
+
value: function () {
|
|
1157
|
+
var _onCustomerLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
|
|
1158
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1159
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1160
|
+
case 0:
|
|
1161
|
+
this.logMethodStart('onCustomerLogin', {
|
|
1162
|
+
customerId: params.customerId
|
|
1163
|
+
});
|
|
1164
|
+
_context15.prev = 1;
|
|
1165
|
+
_context15.next = 4;
|
|
1166
|
+
return this.refreshOrderMarketingAfterLogin({
|
|
1167
|
+
customerId: params.customerId
|
|
1168
|
+
});
|
|
1169
|
+
case 4:
|
|
1170
|
+
this.logMethodSuccess('onCustomerLogin', {
|
|
1171
|
+
customerId: params.customerId
|
|
1172
|
+
});
|
|
1173
|
+
_context15.next = 11;
|
|
1174
|
+
break;
|
|
1175
|
+
case 7:
|
|
1176
|
+
_context15.prev = 7;
|
|
1177
|
+
_context15.t0 = _context15["catch"](1);
|
|
1178
|
+
this.logMethodError('onCustomerLogin', _context15.t0);
|
|
1179
|
+
throw _context15.t0;
|
|
1180
|
+
case 11:
|
|
1181
|
+
case "end":
|
|
1182
|
+
return _context15.stop();
|
|
1183
|
+
}
|
|
1184
|
+
}, _callee15, this, [[1, 7]]);
|
|
1185
|
+
}));
|
|
1186
|
+
function onCustomerLogin(_x9) {
|
|
1187
|
+
return _onCustomerLogin.apply(this, arguments);
|
|
1188
|
+
}
|
|
1189
|
+
return onCustomerLogin;
|
|
753
1190
|
}() // ScanOrder 提交 payload enhancer:
|
|
754
1191
|
// - 给所有 booking 注入 appointment_status: 'started'(扫码点餐语义)
|
|
755
1192
|
// - 给所有 booking 的 metadata 注入 resource_select_type(来自预约规则商品的 resource.type)
|
|
@@ -773,10 +1210,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
773
1210
|
}
|
|
774
1211
|
return 1;
|
|
775
1212
|
};
|
|
776
|
-
return function (payload,
|
|
777
|
-
var _tempOrder$resource_i,
|
|
778
|
-
var bookingUuid =
|
|
779
|
-
tempOrder =
|
|
1213
|
+
return function (payload, _ref3) {
|
|
1214
|
+
var _tempOrder$resource_i, _ref4, _pickOriginal, _resourceState$table_2, _resourceState$relati;
|
|
1215
|
+
var bookingUuid = _ref3.bookingUuid,
|
|
1216
|
+
tempOrder = _ref3.tempOrder;
|
|
780
1217
|
var resourceId = (_tempOrder$resource_i = tempOrder.resource_id) !== null && _tempOrder$resource_i !== void 0 ? _tempOrder$resource_i : resourceState === null || resourceState === void 0 ? void 0 : resourceState.relationId;
|
|
781
1218
|
var pickOriginal = function pickOriginal(value) {
|
|
782
1219
|
if (value && _typeof(value) === 'object' && !Array.isArray(value)) {
|
|
@@ -785,7 +1222,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
785
1222
|
}
|
|
786
1223
|
return undefined;
|
|
787
1224
|
};
|
|
788
|
-
var mainField = (
|
|
1225
|
+
var mainField = (_ref4 = (_pickOriginal = pickOriginal(tempOrder.table_number)) !== null && _pickOriginal !== void 0 ? _pickOriginal : pickOriginal(resourceState === null || resourceState === void 0 || (_resourceState$table_2 = resourceState.table_form_record) === null || _resourceState$table_2 === void 0 ? void 0 : _resourceState$table_2.name)) !== null && _ref4 !== void 0 ? _ref4 : '';
|
|
789
1226
|
var resourceEntry = resourceState && resourceId ? {
|
|
790
1227
|
relation_type: 'form',
|
|
791
1228
|
like_status: 'common',
|
|
@@ -818,9 +1255,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
818
1255
|
});
|
|
819
1256
|
var nextProducts = _toConsumableArray(payload.products || []);
|
|
820
1257
|
if (ruleProduct && ruleProductUid) {
|
|
821
|
-
var _ruleProduct$price,
|
|
1258
|
+
var _ruleProduct$price, _ref5, _ruleProduct$original, _ruleProduct$is_gst;
|
|
822
1259
|
var sellingPrice = String((_ruleProduct$price = ruleProduct.price) !== null && _ruleProduct$price !== void 0 ? _ruleProduct$price : '0.00');
|
|
823
|
-
var originalPrice = String((
|
|
1260
|
+
var originalPrice = String((_ref5 = (_ruleProduct$original = ruleProduct.original_price) !== null && _ruleProduct$original !== void 0 ? _ruleProduct$original : ruleProduct.price) !== null && _ref5 !== void 0 ? _ref5 : '0.00');
|
|
824
1261
|
nextProducts.push({
|
|
825
1262
|
product_id: ruleProduct.id,
|
|
826
1263
|
product_variant_id: 0,
|
|
@@ -849,18 +1286,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
849
1286
|
}, {
|
|
850
1287
|
key: "submitScanOrder",
|
|
851
1288
|
value: function () {
|
|
852
|
-
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1289
|
+
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
853
1290
|
var _this$store$resource, _this$otherParams4, _this$otherParams5, _this$otherParams6, _this$otherParams7, _tempOrder$products, pax, tempOrderForSubmit, resourceTableName, enhancePayload, result, tempOrder;
|
|
854
|
-
return _regeneratorRuntime().wrap(function
|
|
855
|
-
while (1) switch (
|
|
1291
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1292
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
856
1293
|
case 0:
|
|
857
1294
|
this.logMethodStart('submitScanOrder');
|
|
858
|
-
|
|
859
|
-
|
|
1295
|
+
_context16.prev = 1;
|
|
1296
|
+
_context16.next = 4;
|
|
860
1297
|
return this.validateBeforeSubmitByItemRule();
|
|
861
1298
|
case 4:
|
|
862
1299
|
if (this.store.order) {
|
|
863
|
-
|
|
1300
|
+
_context16.next = 6;
|
|
864
1301
|
break;
|
|
865
1302
|
}
|
|
866
1303
|
throw new Error('scanOrder解决方案需要 order 模块支持');
|
|
@@ -880,7 +1317,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
880
1317
|
}
|
|
881
1318
|
this.store.order.persistTempOrder();
|
|
882
1319
|
enhancePayload = this.buildSubmitPayloadEnhancer();
|
|
883
|
-
|
|
1320
|
+
_context16.next = 17;
|
|
884
1321
|
return this.store.order.submitTempOrder({
|
|
885
1322
|
cacheId: this.cacheId,
|
|
886
1323
|
platform: (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.platform,
|
|
@@ -890,22 +1327,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
890
1327
|
enhancePayload: enhancePayload
|
|
891
1328
|
});
|
|
892
1329
|
case 17:
|
|
893
|
-
result =
|
|
1330
|
+
result = _context16.sent;
|
|
894
1331
|
tempOrder = this.store.order.getTempOrder();
|
|
895
1332
|
this.logMethodSuccess('submitScanOrder', {
|
|
896
1333
|
productCount: (tempOrder === null || tempOrder === void 0 || (_tempOrder$products = tempOrder.products) === null || _tempOrder$products === void 0 ? void 0 : _tempOrder$products.length) || 0
|
|
897
1334
|
});
|
|
898
|
-
return
|
|
1335
|
+
return _context16.abrupt("return", result);
|
|
899
1336
|
case 23:
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
this.logMethodError('submitScanOrder',
|
|
903
|
-
throw
|
|
1337
|
+
_context16.prev = 23;
|
|
1338
|
+
_context16.t0 = _context16["catch"](1);
|
|
1339
|
+
this.logMethodError('submitScanOrder', _context16.t0);
|
|
1340
|
+
throw _context16.t0;
|
|
904
1341
|
case 27:
|
|
905
1342
|
case "end":
|
|
906
|
-
return
|
|
1343
|
+
return _context16.stop();
|
|
907
1344
|
}
|
|
908
|
-
},
|
|
1345
|
+
}, _callee16, this, [[1, 23]]);
|
|
909
1346
|
}));
|
|
910
1347
|
function submitScanOrder() {
|
|
911
1348
|
return _submitScanOrder.apply(this, arguments);
|
|
@@ -915,48 +1352,48 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
915
1352
|
}, {
|
|
916
1353
|
key: "addProductToOrder",
|
|
917
1354
|
value: function () {
|
|
918
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1355
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(product) {
|
|
919
1356
|
var products;
|
|
920
|
-
return _regeneratorRuntime().wrap(function
|
|
921
|
-
while (1) switch (
|
|
1357
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1358
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
922
1359
|
case 0:
|
|
923
1360
|
this.logMethodStart('addProductToOrder', {
|
|
924
1361
|
product_id: product.product_id,
|
|
925
1362
|
product_variant_id: product.product_variant_id
|
|
926
1363
|
});
|
|
927
|
-
|
|
1364
|
+
_context17.prev = 1;
|
|
928
1365
|
if (this.store.order) {
|
|
929
|
-
|
|
1366
|
+
_context17.next = 4;
|
|
930
1367
|
break;
|
|
931
1368
|
}
|
|
932
1369
|
throw new Error('order 模块未初始化');
|
|
933
1370
|
case 4:
|
|
934
|
-
|
|
1371
|
+
_context17.next = 6;
|
|
935
1372
|
return this.store.order.addProductToOrder(product);
|
|
936
1373
|
case 6:
|
|
937
|
-
products =
|
|
938
|
-
|
|
1374
|
+
products = _context17.sent;
|
|
1375
|
+
_context17.next = 9;
|
|
939
1376
|
return this.refreshItemRuleQuantityLimits();
|
|
940
1377
|
case 9:
|
|
941
|
-
|
|
1378
|
+
_context17.next = 11;
|
|
942
1379
|
return this.refreshCartValidationPassed();
|
|
943
1380
|
case 11:
|
|
944
1381
|
this.logMethodSuccess('addProductToOrder', {
|
|
945
1382
|
productCount: products.length
|
|
946
1383
|
});
|
|
947
|
-
return
|
|
1384
|
+
return _context17.abrupt("return", products);
|
|
948
1385
|
case 15:
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
this.logMethodError('addProductToOrder',
|
|
952
|
-
throw
|
|
1386
|
+
_context17.prev = 15;
|
|
1387
|
+
_context17.t0 = _context17["catch"](1);
|
|
1388
|
+
this.logMethodError('addProductToOrder', _context17.t0);
|
|
1389
|
+
throw _context17.t0;
|
|
953
1390
|
case 19:
|
|
954
1391
|
case "end":
|
|
955
|
-
return
|
|
1392
|
+
return _context17.stop();
|
|
956
1393
|
}
|
|
957
|
-
},
|
|
1394
|
+
}, _callee17, this, [[1, 15]]);
|
|
958
1395
|
}));
|
|
959
|
-
function addProductToOrder(
|
|
1396
|
+
function addProductToOrder(_x10) {
|
|
960
1397
|
return _addProductToOrder.apply(this, arguments);
|
|
961
1398
|
}
|
|
962
1399
|
return addProductToOrder;
|
|
@@ -964,48 +1401,48 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
964
1401
|
}, {
|
|
965
1402
|
key: "updateProductInOrder",
|
|
966
1403
|
value: function () {
|
|
967
|
-
var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1404
|
+
var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(params) {
|
|
968
1405
|
var products;
|
|
969
|
-
return _regeneratorRuntime().wrap(function
|
|
970
|
-
while (1) switch (
|
|
1406
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1407
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
971
1408
|
case 0:
|
|
972
1409
|
this.logMethodStart('updateProductInOrder', {
|
|
973
1410
|
product_id: params.product_id,
|
|
974
1411
|
product_variant_id: params.product_variant_id
|
|
975
1412
|
});
|
|
976
|
-
|
|
1413
|
+
_context18.prev = 1;
|
|
977
1414
|
if (this.store.order) {
|
|
978
|
-
|
|
1415
|
+
_context18.next = 4;
|
|
979
1416
|
break;
|
|
980
1417
|
}
|
|
981
1418
|
throw new Error('order 模块未初始化');
|
|
982
1419
|
case 4:
|
|
983
|
-
|
|
1420
|
+
_context18.next = 6;
|
|
984
1421
|
return this.store.order.updateProductInOrder(params);
|
|
985
1422
|
case 6:
|
|
986
|
-
products =
|
|
987
|
-
|
|
1423
|
+
products = _context18.sent;
|
|
1424
|
+
_context18.next = 9;
|
|
988
1425
|
return this.refreshItemRuleQuantityLimits();
|
|
989
1426
|
case 9:
|
|
990
|
-
|
|
1427
|
+
_context18.next = 11;
|
|
991
1428
|
return this.refreshCartValidationPassed();
|
|
992
1429
|
case 11:
|
|
993
1430
|
this.logMethodSuccess('updateProductInOrder', {
|
|
994
1431
|
productCount: products.length
|
|
995
1432
|
});
|
|
996
|
-
return
|
|
1433
|
+
return _context18.abrupt("return", products);
|
|
997
1434
|
case 15:
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
this.logMethodError('updateProductInOrder',
|
|
1001
|
-
throw
|
|
1435
|
+
_context18.prev = 15;
|
|
1436
|
+
_context18.t0 = _context18["catch"](1);
|
|
1437
|
+
this.logMethodError('updateProductInOrder', _context18.t0);
|
|
1438
|
+
throw _context18.t0;
|
|
1002
1439
|
case 19:
|
|
1003
1440
|
case "end":
|
|
1004
|
-
return
|
|
1441
|
+
return _context18.stop();
|
|
1005
1442
|
}
|
|
1006
|
-
},
|
|
1443
|
+
}, _callee18, this, [[1, 15]]);
|
|
1007
1444
|
}));
|
|
1008
|
-
function updateProductInOrder(
|
|
1445
|
+
function updateProductInOrder(_x11) {
|
|
1009
1446
|
return _updateProductInOrder.apply(this, arguments);
|
|
1010
1447
|
}
|
|
1011
1448
|
return updateProductInOrder;
|
|
@@ -1013,48 +1450,48 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1013
1450
|
}, {
|
|
1014
1451
|
key: "removeProductFromOrder",
|
|
1015
1452
|
value: function () {
|
|
1016
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1453
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(identity) {
|
|
1017
1454
|
var products;
|
|
1018
|
-
return _regeneratorRuntime().wrap(function
|
|
1019
|
-
while (1) switch (
|
|
1455
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1456
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1020
1457
|
case 0:
|
|
1021
1458
|
this.logMethodStart('removeProductFromOrder', {
|
|
1022
1459
|
product_id: identity.product_id,
|
|
1023
1460
|
product_variant_id: identity.product_variant_id
|
|
1024
1461
|
});
|
|
1025
|
-
|
|
1462
|
+
_context19.prev = 1;
|
|
1026
1463
|
if (this.store.order) {
|
|
1027
|
-
|
|
1464
|
+
_context19.next = 4;
|
|
1028
1465
|
break;
|
|
1029
1466
|
}
|
|
1030
1467
|
throw new Error('order 模块未初始化');
|
|
1031
1468
|
case 4:
|
|
1032
|
-
|
|
1469
|
+
_context19.next = 6;
|
|
1033
1470
|
return this.store.order.removeProductFromOrder(identity);
|
|
1034
1471
|
case 6:
|
|
1035
|
-
products =
|
|
1036
|
-
|
|
1472
|
+
products = _context19.sent;
|
|
1473
|
+
_context19.next = 9;
|
|
1037
1474
|
return this.refreshItemRuleQuantityLimits();
|
|
1038
1475
|
case 9:
|
|
1039
|
-
|
|
1476
|
+
_context19.next = 11;
|
|
1040
1477
|
return this.refreshCartValidationPassed();
|
|
1041
1478
|
case 11:
|
|
1042
1479
|
this.logMethodSuccess('removeProductFromOrder', {
|
|
1043
1480
|
productCount: products.length
|
|
1044
1481
|
});
|
|
1045
|
-
return
|
|
1482
|
+
return _context19.abrupt("return", products);
|
|
1046
1483
|
case 15:
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
this.logMethodError('removeProductFromOrder',
|
|
1050
|
-
throw
|
|
1484
|
+
_context19.prev = 15;
|
|
1485
|
+
_context19.t0 = _context19["catch"](1);
|
|
1486
|
+
this.logMethodError('removeProductFromOrder', _context19.t0);
|
|
1487
|
+
throw _context19.t0;
|
|
1051
1488
|
case 19:
|
|
1052
1489
|
case "end":
|
|
1053
|
-
return
|
|
1490
|
+
return _context19.stop();
|
|
1054
1491
|
}
|
|
1055
|
-
},
|
|
1492
|
+
}, _callee19, this, [[1, 15]]);
|
|
1056
1493
|
}));
|
|
1057
|
-
function removeProductFromOrder(
|
|
1494
|
+
function removeProductFromOrder(_x12) {
|
|
1058
1495
|
return _removeProductFromOrder.apply(this, arguments);
|
|
1059
1496
|
}
|
|
1060
1497
|
return removeProductFromOrder;
|
|
@@ -1062,26 +1499,26 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1062
1499
|
}, {
|
|
1063
1500
|
key: "loadRuntimeConfigs",
|
|
1064
1501
|
value: function () {
|
|
1065
|
-
var _loadRuntimeConfigs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1502
|
+
var _loadRuntimeConfigs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
1066
1503
|
var itemRuleConfigs;
|
|
1067
|
-
return _regeneratorRuntime().wrap(function
|
|
1068
|
-
while (1) switch (
|
|
1504
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1505
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1069
1506
|
case 0:
|
|
1070
|
-
|
|
1507
|
+
_context20.next = 2;
|
|
1071
1508
|
return this.ensureItemRuleConfigsLoaded();
|
|
1072
1509
|
case 2:
|
|
1073
|
-
itemRuleConfigs =
|
|
1510
|
+
itemRuleConfigs = _context20.sent;
|
|
1074
1511
|
this.logMethodSuccess('loadRuntimeConfigs', {
|
|
1075
1512
|
itemRuleCount: itemRuleConfigs.length
|
|
1076
1513
|
});
|
|
1077
|
-
return
|
|
1514
|
+
return _context20.abrupt("return", {
|
|
1078
1515
|
itemRuleConfigs: itemRuleConfigs
|
|
1079
1516
|
});
|
|
1080
1517
|
case 5:
|
|
1081
1518
|
case "end":
|
|
1082
|
-
return
|
|
1519
|
+
return _context20.stop();
|
|
1083
1520
|
}
|
|
1084
|
-
},
|
|
1521
|
+
}, _callee20, this);
|
|
1085
1522
|
}));
|
|
1086
1523
|
function loadRuntimeConfigs() {
|
|
1087
1524
|
return _loadRuntimeConfigs.apply(this, arguments);
|
|
@@ -1091,15 +1528,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1091
1528
|
}, {
|
|
1092
1529
|
key: "syncItemRuleConfigsFromDineInConfig",
|
|
1093
1530
|
value: function () {
|
|
1094
|
-
var _syncItemRuleConfigsFromDineInConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1531
|
+
var _syncItemRuleConfigsFromDineInConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(dineInConfig) {
|
|
1095
1532
|
var enableItemRules, strategyModelIds, itemRuleConfigs;
|
|
1096
|
-
return _regeneratorRuntime().wrap(function
|
|
1097
|
-
while (1) switch (
|
|
1533
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1534
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1098
1535
|
case 0:
|
|
1099
1536
|
enableItemRules = toBoolean(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['sale.enable_item_rules']);
|
|
1100
1537
|
strategyModelIds = normalizeEnabledItemRuleIds(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['sale.enabled_item_rules']);
|
|
1101
1538
|
if (!(!enableItemRules || !strategyModelIds.length)) {
|
|
1102
|
-
|
|
1539
|
+
_context21.next = 8;
|
|
1103
1540
|
break;
|
|
1104
1541
|
}
|
|
1105
1542
|
this.itemRuleConfigs = [];
|
|
@@ -1110,12 +1547,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1110
1547
|
strategyModelIds: [],
|
|
1111
1548
|
itemRuleCount: 0
|
|
1112
1549
|
});
|
|
1113
|
-
return
|
|
1550
|
+
return _context21.abrupt("return", []);
|
|
1114
1551
|
case 8:
|
|
1115
|
-
|
|
1552
|
+
_context21.next = 10;
|
|
1116
1553
|
return this.fetchItemRuleConfigsByModelIds(strategyModelIds);
|
|
1117
1554
|
case 10:
|
|
1118
|
-
itemRuleConfigs =
|
|
1555
|
+
itemRuleConfigs = _context21.sent;
|
|
1119
1556
|
this.itemRuleConfigs = itemRuleConfigs;
|
|
1120
1557
|
this.itemRuleConfigsPromise = Promise.resolve(itemRuleConfigs);
|
|
1121
1558
|
this.itemRuleEvaluator.setStrategyConfigs(itemRuleConfigs);
|
|
@@ -1124,14 +1561,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1124
1561
|
strategyModelIds: strategyModelIds,
|
|
1125
1562
|
itemRuleCount: itemRuleConfigs.length
|
|
1126
1563
|
});
|
|
1127
|
-
return
|
|
1564
|
+
return _context21.abrupt("return", itemRuleConfigs);
|
|
1128
1565
|
case 16:
|
|
1129
1566
|
case "end":
|
|
1130
|
-
return
|
|
1567
|
+
return _context21.stop();
|
|
1131
1568
|
}
|
|
1132
|
-
},
|
|
1569
|
+
}, _callee21, this);
|
|
1133
1570
|
}));
|
|
1134
|
-
function syncItemRuleConfigsFromDineInConfig(
|
|
1571
|
+
function syncItemRuleConfigsFromDineInConfig(_x13) {
|
|
1135
1572
|
return _syncItemRuleConfigsFromDineInConfig.apply(this, arguments);
|
|
1136
1573
|
}
|
|
1137
1574
|
return syncItemRuleConfigsFromDineInConfig;
|
|
@@ -1139,22 +1576,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1139
1576
|
}, {
|
|
1140
1577
|
key: "fetchItemRuleConfigsByModelIds",
|
|
1141
1578
|
value: function () {
|
|
1142
|
-
var _fetchItemRuleConfigsByModelIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1579
|
+
var _fetchItemRuleConfigsByModelIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(strategyModelIds) {
|
|
1143
1580
|
var result, configs;
|
|
1144
|
-
return _regeneratorRuntime().wrap(function
|
|
1145
|
-
while (1) switch (
|
|
1581
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
1582
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1146
1583
|
case 0:
|
|
1147
1584
|
this.logMethodStart('fetchItemRuleConfigsByModelIds', {
|
|
1148
1585
|
strategyModelIds: strategyModelIds
|
|
1149
1586
|
});
|
|
1150
1587
|
if (strategyModelIds.length) {
|
|
1151
|
-
|
|
1588
|
+
_context22.next = 3;
|
|
1152
1589
|
break;
|
|
1153
1590
|
}
|
|
1154
|
-
return
|
|
1591
|
+
return _context22.abrupt("return", []);
|
|
1155
1592
|
case 3:
|
|
1156
|
-
|
|
1157
|
-
|
|
1593
|
+
_context22.prev = 3;
|
|
1594
|
+
_context22.next = 6;
|
|
1158
1595
|
return this.request.get('/promotion', {
|
|
1159
1596
|
skip: 1,
|
|
1160
1597
|
num: 99,
|
|
@@ -1162,7 +1599,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1162
1599
|
ids: strategyModelIds
|
|
1163
1600
|
});
|
|
1164
1601
|
case 6:
|
|
1165
|
-
result =
|
|
1602
|
+
result = _context22.sent;
|
|
1166
1603
|
configs = [];
|
|
1167
1604
|
if (result.code === 200) {
|
|
1168
1605
|
configs = result.data.list.map(function (item) {
|
|
@@ -1173,22 +1610,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1173
1610
|
strategyModelIds: strategyModelIds,
|
|
1174
1611
|
strategyCount: configs.length
|
|
1175
1612
|
});
|
|
1176
|
-
return
|
|
1613
|
+
return _context22.abrupt("return", configs);
|
|
1177
1614
|
case 13:
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
this.logMethodError('fetchItemRuleConfigsByModelIds',
|
|
1615
|
+
_context22.prev = 13;
|
|
1616
|
+
_context22.t0 = _context22["catch"](3);
|
|
1617
|
+
this.logMethodError('fetchItemRuleConfigsByModelIds', _context22.t0, {
|
|
1181
1618
|
strategyModelIds: strategyModelIds
|
|
1182
1619
|
});
|
|
1183
1620
|
// A:策略加载失败时不阻塞下单
|
|
1184
|
-
return
|
|
1621
|
+
return _context22.abrupt("return", []);
|
|
1185
1622
|
case 17:
|
|
1186
1623
|
case "end":
|
|
1187
|
-
return
|
|
1624
|
+
return _context22.stop();
|
|
1188
1625
|
}
|
|
1189
|
-
},
|
|
1626
|
+
}, _callee22, this, [[3, 13]]);
|
|
1190
1627
|
}));
|
|
1191
|
-
function fetchItemRuleConfigsByModelIds(
|
|
1628
|
+
function fetchItemRuleConfigsByModelIds(_x14) {
|
|
1192
1629
|
return _fetchItemRuleConfigsByModelIds.apply(this, arguments);
|
|
1193
1630
|
}
|
|
1194
1631
|
return fetchItemRuleConfigsByModelIds;
|
|
@@ -1196,22 +1633,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1196
1633
|
}, {
|
|
1197
1634
|
key: "buildPrefillProductSourceMap",
|
|
1198
1635
|
value: function () {
|
|
1199
|
-
var _buildPrefillProductSourceMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1636
|
+
var _buildPrefillProductSourceMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
1200
1637
|
var sourceMap, productList, visited, collectFromValue;
|
|
1201
|
-
return _regeneratorRuntime().wrap(function
|
|
1202
|
-
while (1) switch (
|
|
1638
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
1639
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1203
1640
|
case 0:
|
|
1204
1641
|
sourceMap = new Map();
|
|
1205
|
-
|
|
1206
|
-
|
|
1642
|
+
_context23.prev = 1;
|
|
1643
|
+
_context23.next = 4;
|
|
1207
1644
|
return this.getProductList();
|
|
1208
1645
|
case 4:
|
|
1209
|
-
productList =
|
|
1646
|
+
productList = _context23.sent;
|
|
1210
1647
|
if (Array.isArray(productList)) {
|
|
1211
|
-
|
|
1648
|
+
_context23.next = 7;
|
|
1212
1649
|
break;
|
|
1213
1650
|
}
|
|
1214
|
-
return
|
|
1651
|
+
return _context23.abrupt("return", sourceMap);
|
|
1215
1652
|
case 7:
|
|
1216
1653
|
visited = new Set();
|
|
1217
1654
|
collectFromValue = function collectFromValue(value) {
|
|
@@ -1220,17 +1657,17 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1220
1657
|
if (visited.has(value)) return;
|
|
1221
1658
|
visited.add(value);
|
|
1222
1659
|
if (Array.isArray(value)) {
|
|
1223
|
-
var
|
|
1224
|
-
|
|
1660
|
+
var _iterator4 = _createForOfIteratorHelper(value),
|
|
1661
|
+
_step4;
|
|
1225
1662
|
try {
|
|
1226
|
-
for (
|
|
1227
|
-
var item =
|
|
1663
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
1664
|
+
var item = _step4.value;
|
|
1228
1665
|
collectFromValue(item);
|
|
1229
1666
|
}
|
|
1230
1667
|
} catch (err) {
|
|
1231
|
-
|
|
1668
|
+
_iterator4.e(err);
|
|
1232
1669
|
} finally {
|
|
1233
|
-
|
|
1670
|
+
_iterator4.f();
|
|
1234
1671
|
}
|
|
1235
1672
|
return;
|
|
1236
1673
|
}
|
|
@@ -1238,35 +1675,35 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1238
1675
|
var rawProductId = (_node$product_id = node.product_id) !== null && _node$product_id !== void 0 ? _node$product_id : node.id;
|
|
1239
1676
|
var productId = Number(rawProductId);
|
|
1240
1677
|
if (Number.isFinite(productId) && productId > 0) {
|
|
1241
|
-
var
|
|
1242
|
-
var productVariantId = Number((
|
|
1678
|
+
var _ref6, _node$product_variant;
|
|
1679
|
+
var productVariantId = Number((_ref6 = (_node$product_variant = node.product_variant_id) !== null && _node$product_variant !== void 0 ? _node$product_variant : node.variant_id) !== null && _ref6 !== void 0 ? _ref6 : 0);
|
|
1243
1680
|
var normalizedVariantId = Number.isNaN(productVariantId) ? 0 : productVariantId;
|
|
1244
1681
|
var key = buildProductKey(productId, normalizedVariantId);
|
|
1245
1682
|
if (!sourceMap.has(key)) {
|
|
1246
1683
|
sourceMap.set(key, node);
|
|
1247
1684
|
}
|
|
1248
1685
|
}
|
|
1249
|
-
for (var
|
|
1250
|
-
var childValue = _Object$values[
|
|
1686
|
+
for (var _i2 = 0, _Object$values = Object.values(node); _i2 < _Object$values.length; _i2++) {
|
|
1687
|
+
var childValue = _Object$values[_i2];
|
|
1251
1688
|
if (childValue && _typeof(childValue) === 'object') {
|
|
1252
1689
|
collectFromValue(childValue);
|
|
1253
1690
|
}
|
|
1254
1691
|
}
|
|
1255
1692
|
};
|
|
1256
1693
|
collectFromValue(productList);
|
|
1257
|
-
|
|
1694
|
+
_context23.next = 15;
|
|
1258
1695
|
break;
|
|
1259
1696
|
case 12:
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
this.logMethodError('buildPrefillProductSourceMap',
|
|
1697
|
+
_context23.prev = 12;
|
|
1698
|
+
_context23.t0 = _context23["catch"](1);
|
|
1699
|
+
this.logMethodError('buildPrefillProductSourceMap', _context23.t0);
|
|
1263
1700
|
case 15:
|
|
1264
|
-
return
|
|
1701
|
+
return _context23.abrupt("return", sourceMap);
|
|
1265
1702
|
case 16:
|
|
1266
1703
|
case "end":
|
|
1267
|
-
return
|
|
1704
|
+
return _context23.stop();
|
|
1268
1705
|
}
|
|
1269
|
-
},
|
|
1706
|
+
}, _callee23, this, [[1, 12]]);
|
|
1270
1707
|
}));
|
|
1271
1708
|
function buildPrefillProductSourceMap() {
|
|
1272
1709
|
return _buildPrefillProductSourceMap.apply(this, arguments);
|
|
@@ -1281,58 +1718,58 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1281
1718
|
}, {
|
|
1282
1719
|
key: "ensureItemRuleConfigsLoaded",
|
|
1283
1720
|
value: function () {
|
|
1284
|
-
var _ensureItemRuleConfigsLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1285
|
-
var
|
|
1721
|
+
var _ensureItemRuleConfigsLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
|
|
1722
|
+
var _this5 = this;
|
|
1286
1723
|
var loadedConfigs;
|
|
1287
|
-
return _regeneratorRuntime().wrap(function
|
|
1288
|
-
while (1) switch (
|
|
1724
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
1725
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
1289
1726
|
case 0:
|
|
1290
1727
|
if (!(this.itemRuleConfigs.length > 0)) {
|
|
1291
|
-
|
|
1728
|
+
_context25.next = 2;
|
|
1292
1729
|
break;
|
|
1293
1730
|
}
|
|
1294
|
-
return
|
|
1731
|
+
return _context25.abrupt("return", this.itemRuleConfigs);
|
|
1295
1732
|
case 2:
|
|
1296
1733
|
if (!this.itemRuleConfigsPromise) {
|
|
1297
|
-
|
|
1734
|
+
_context25.next = 4;
|
|
1298
1735
|
break;
|
|
1299
1736
|
}
|
|
1300
|
-
return
|
|
1737
|
+
return _context25.abrupt("return", this.itemRuleConfigsPromise);
|
|
1301
1738
|
case 4:
|
|
1302
|
-
this.itemRuleConfigsPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1739
|
+
this.itemRuleConfigsPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
1303
1740
|
var runtimeConfig, staticConfigs;
|
|
1304
|
-
return _regeneratorRuntime().wrap(function
|
|
1305
|
-
while (1) switch (
|
|
1741
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
1742
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1306
1743
|
case 0:
|
|
1307
|
-
runtimeConfig =
|
|
1744
|
+
runtimeConfig = _this5.getItemRuleRuntimeConfig();
|
|
1308
1745
|
staticConfigs = normalizeItemRuleStrategies(runtimeConfig.strategyConfigs);
|
|
1309
1746
|
if (!(staticConfigs.length > 0)) {
|
|
1310
|
-
|
|
1747
|
+
_context24.next = 6;
|
|
1311
1748
|
break;
|
|
1312
1749
|
}
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
return
|
|
1750
|
+
_this5.itemRuleConfigs = staticConfigs;
|
|
1751
|
+
_this5.itemRuleEvaluator.setStrategyConfigs(staticConfigs);
|
|
1752
|
+
return _context24.abrupt("return", _this5.itemRuleConfigs);
|
|
1316
1753
|
case 6:
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
return
|
|
1754
|
+
_this5.itemRuleConfigs = [];
|
|
1755
|
+
_this5.itemRuleEvaluator.setStrategyConfigs([]);
|
|
1756
|
+
return _context24.abrupt("return", _this5.itemRuleConfigs);
|
|
1320
1757
|
case 9:
|
|
1321
1758
|
case "end":
|
|
1322
|
-
return
|
|
1759
|
+
return _context24.stop();
|
|
1323
1760
|
}
|
|
1324
|
-
},
|
|
1761
|
+
}, _callee24);
|
|
1325
1762
|
}))();
|
|
1326
|
-
|
|
1763
|
+
_context25.next = 7;
|
|
1327
1764
|
return this.itemRuleConfigsPromise;
|
|
1328
1765
|
case 7:
|
|
1329
|
-
loadedConfigs =
|
|
1330
|
-
return
|
|
1766
|
+
loadedConfigs = _context25.sent;
|
|
1767
|
+
return _context25.abrupt("return", loadedConfigs);
|
|
1331
1768
|
case 9:
|
|
1332
1769
|
case "end":
|
|
1333
|
-
return
|
|
1770
|
+
return _context25.stop();
|
|
1334
1771
|
}
|
|
1335
|
-
},
|
|
1772
|
+
}, _callee25, this);
|
|
1336
1773
|
}));
|
|
1337
1774
|
function ensureItemRuleConfigsLoaded() {
|
|
1338
1775
|
return _ensureItemRuleConfigsLoaded.apply(this, arguments);
|
|
@@ -1342,22 +1779,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1342
1779
|
}, {
|
|
1343
1780
|
key: "refreshItemRuleQuantityLimits",
|
|
1344
1781
|
value: function () {
|
|
1345
|
-
var _refreshItemRuleQuantityLimits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1782
|
+
var _refreshItemRuleQuantityLimits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
|
|
1346
1783
|
var strategyConfigs, businessData, limits;
|
|
1347
|
-
return _regeneratorRuntime().wrap(function
|
|
1348
|
-
while (1) switch (
|
|
1784
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
1785
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
1349
1786
|
case 0:
|
|
1350
|
-
|
|
1351
|
-
|
|
1787
|
+
_context26.prev = 0;
|
|
1788
|
+
_context26.next = 3;
|
|
1352
1789
|
return this.ensureItemRuleConfigsLoaded();
|
|
1353
1790
|
case 3:
|
|
1354
|
-
strategyConfigs =
|
|
1791
|
+
strategyConfigs = _context26.sent;
|
|
1355
1792
|
if (strategyConfigs.length) {
|
|
1356
|
-
|
|
1793
|
+
_context26.next = 7;
|
|
1357
1794
|
break;
|
|
1358
1795
|
}
|
|
1359
1796
|
this.store.itemRuleQuantityLimits = [];
|
|
1360
|
-
return
|
|
1797
|
+
return _context26.abrupt("return", []);
|
|
1361
1798
|
case 7:
|
|
1362
1799
|
businessData = buildItemRuleBusinessData({
|
|
1363
1800
|
tempOrder: this.ensureTempOrder(),
|
|
@@ -1369,18 +1806,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1369
1806
|
this.logMethodSuccess('refreshItemRuleQuantityLimits', {
|
|
1370
1807
|
limitCount: limits.length
|
|
1371
1808
|
});
|
|
1372
|
-
return
|
|
1809
|
+
return _context26.abrupt("return", limits);
|
|
1373
1810
|
case 14:
|
|
1374
|
-
|
|
1375
|
-
|
|
1811
|
+
_context26.prev = 14;
|
|
1812
|
+
_context26.t0 = _context26["catch"](0);
|
|
1376
1813
|
this.store.itemRuleQuantityLimits = [];
|
|
1377
|
-
this.logMethodError('refreshItemRuleQuantityLimits',
|
|
1378
|
-
return
|
|
1814
|
+
this.logMethodError('refreshItemRuleQuantityLimits', _context26.t0);
|
|
1815
|
+
return _context26.abrupt("return", []);
|
|
1379
1816
|
case 19:
|
|
1380
1817
|
case "end":
|
|
1381
|
-
return
|
|
1818
|
+
return _context26.stop();
|
|
1382
1819
|
}
|
|
1383
|
-
},
|
|
1820
|
+
}, _callee26, this, [[0, 14]]);
|
|
1384
1821
|
}));
|
|
1385
1822
|
function refreshItemRuleQuantityLimits() {
|
|
1386
1823
|
return _refreshItemRuleQuantityLimits.apply(this, arguments);
|
|
@@ -1390,32 +1827,32 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1390
1827
|
}, {
|
|
1391
1828
|
key: "applyPrefillByItemRule",
|
|
1392
1829
|
value: function () {
|
|
1393
|
-
var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1394
|
-
var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges,
|
|
1395
|
-
return _regeneratorRuntime().wrap(function
|
|
1396
|
-
while (1) switch (
|
|
1830
|
+
var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
|
|
1831
|
+
var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges, _iterator5, _step5, _prefillItem$product_, _targetProduct$_origi, _targetProduct$_origi2, _targetProduct$_origi3, prefillItem, productId, productVariantId, targetQuantity, sourceItem, productIndex, _sourceItem$price, sellingPrice, targetProduct, existedQuantity, delta, nextProduct, hasQuantityChanged, hasOriginChanged;
|
|
1832
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
1833
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
1397
1834
|
case 0:
|
|
1398
1835
|
if (!this.itemRulePrefillApplied) {
|
|
1399
|
-
|
|
1836
|
+
_context27.next = 2;
|
|
1400
1837
|
break;
|
|
1401
1838
|
}
|
|
1402
|
-
return
|
|
1839
|
+
return _context27.abrupt("return");
|
|
1403
1840
|
case 2:
|
|
1404
1841
|
if (this.store.order) {
|
|
1405
|
-
|
|
1842
|
+
_context27.next = 4;
|
|
1406
1843
|
break;
|
|
1407
1844
|
}
|
|
1408
|
-
return
|
|
1845
|
+
return _context27.abrupt("return");
|
|
1409
1846
|
case 4:
|
|
1410
|
-
|
|
1847
|
+
_context27.next = 6;
|
|
1411
1848
|
return this.ensureItemRuleConfigsLoaded();
|
|
1412
1849
|
case 6:
|
|
1413
|
-
strategyConfigs =
|
|
1850
|
+
strategyConfigs = _context27.sent;
|
|
1414
1851
|
if (strategyConfigs.length) {
|
|
1415
|
-
|
|
1852
|
+
_context27.next = 9;
|
|
1416
1853
|
break;
|
|
1417
1854
|
}
|
|
1418
|
-
return
|
|
1855
|
+
return _context27.abrupt("return");
|
|
1419
1856
|
case 9:
|
|
1420
1857
|
businessData = buildItemRuleBusinessData({
|
|
1421
1858
|
tempOrder: this.ensureTempOrder(),
|
|
@@ -1424,41 +1861,41 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1424
1861
|
});
|
|
1425
1862
|
prefillItems = this.itemRuleEvaluator.getPrefillItems(businessData);
|
|
1426
1863
|
if (prefillItems.length) {
|
|
1427
|
-
|
|
1864
|
+
_context27.next = 14;
|
|
1428
1865
|
break;
|
|
1429
1866
|
}
|
|
1430
1867
|
this.itemRulePrefillApplied = true;
|
|
1431
|
-
return
|
|
1868
|
+
return _context27.abrupt("return");
|
|
1432
1869
|
case 14:
|
|
1433
|
-
|
|
1870
|
+
_context27.next = 16;
|
|
1434
1871
|
return this.buildPrefillProductSourceMap();
|
|
1435
1872
|
case 16:
|
|
1436
|
-
productSourceMap =
|
|
1873
|
+
productSourceMap = _context27.sent;
|
|
1437
1874
|
tempOrder = this.ensureTempOrder();
|
|
1438
1875
|
hasChanges = false;
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1876
|
+
_iterator5 = _createForOfIteratorHelper(prefillItems);
|
|
1877
|
+
_context27.prev = 20;
|
|
1878
|
+
_iterator5.s();
|
|
1442
1879
|
case 22:
|
|
1443
|
-
if ((
|
|
1444
|
-
|
|
1880
|
+
if ((_step5 = _iterator5.n()).done) {
|
|
1881
|
+
_context27.next = 47;
|
|
1445
1882
|
break;
|
|
1446
1883
|
}
|
|
1447
|
-
prefillItem =
|
|
1884
|
+
prefillItem = _step5.value;
|
|
1448
1885
|
productId = Number(prefillItem.product_id);
|
|
1449
1886
|
productVariantId = Number((_prefillItem$product_ = prefillItem.product_variant_id) !== null && _prefillItem$product_ !== void 0 ? _prefillItem$product_ : 0);
|
|
1450
1887
|
targetQuantity = toNonNegativeInt(prefillItem.quantity);
|
|
1451
1888
|
if (!(!Number.isFinite(productId) || targetQuantity <= 0)) {
|
|
1452
|
-
|
|
1889
|
+
_context27.next = 29;
|
|
1453
1890
|
break;
|
|
1454
1891
|
}
|
|
1455
|
-
return
|
|
1892
|
+
return _context27.abrupt("continue", 45);
|
|
1456
1893
|
case 29:
|
|
1457
1894
|
if (!Number.isNaN(productVariantId)) {
|
|
1458
|
-
|
|
1895
|
+
_context27.next = 31;
|
|
1459
1896
|
break;
|
|
1460
1897
|
}
|
|
1461
|
-
return
|
|
1898
|
+
return _context27.abrupt("continue", 45);
|
|
1462
1899
|
case 31:
|
|
1463
1900
|
sourceItem = productSourceMap.get(buildProductKey(productId, productVariantId)) || productSourceMap.get(buildProductKey(productId, 0)) || null;
|
|
1464
1901
|
productIndex = getProductIdentityIndex(tempOrder.products, {
|
|
@@ -1466,7 +1903,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1466
1903
|
product_variant_id: productVariantId
|
|
1467
1904
|
});
|
|
1468
1905
|
if (!(productIndex === -1)) {
|
|
1469
|
-
|
|
1906
|
+
_context27.next = 38;
|
|
1470
1907
|
break;
|
|
1471
1908
|
}
|
|
1472
1909
|
sellingPrice = toPriceString((_sourceItem$price = sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.price) !== null && _sourceItem$price !== void 0 ? _sourceItem$price : sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.selling_price, '0.00');
|
|
@@ -1486,7 +1923,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1486
1923
|
})
|
|
1487
1924
|
})));
|
|
1488
1925
|
hasChanges = true;
|
|
1489
|
-
return
|
|
1926
|
+
return _context27.abrupt("continue", 45);
|
|
1490
1927
|
case 38:
|
|
1491
1928
|
targetProduct = tempOrder.products[productIndex];
|
|
1492
1929
|
existedQuantity = toNonNegativeInt(targetProduct.num);
|
|
@@ -1507,34 +1944,34 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1507
1944
|
hasChanges = true;
|
|
1508
1945
|
}
|
|
1509
1946
|
case 45:
|
|
1510
|
-
|
|
1947
|
+
_context27.next = 22;
|
|
1511
1948
|
break;
|
|
1512
1949
|
case 47:
|
|
1513
|
-
|
|
1950
|
+
_context27.next = 52;
|
|
1514
1951
|
break;
|
|
1515
1952
|
case 49:
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1953
|
+
_context27.prev = 49;
|
|
1954
|
+
_context27.t0 = _context27["catch"](20);
|
|
1955
|
+
_iterator5.e(_context27.t0);
|
|
1519
1956
|
case 52:
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
return
|
|
1957
|
+
_context27.prev = 52;
|
|
1958
|
+
_iterator5.f();
|
|
1959
|
+
return _context27.finish(52);
|
|
1523
1960
|
case 55:
|
|
1524
1961
|
if (!hasChanges) {
|
|
1525
|
-
|
|
1962
|
+
_context27.next = 60;
|
|
1526
1963
|
break;
|
|
1527
1964
|
}
|
|
1528
1965
|
// Prefill 属于 products CRUD 的一种形式:新增后让 Rules 重算,以支持自动应用可用优惠券。
|
|
1529
1966
|
this.store.order.applyDiscount();
|
|
1530
|
-
|
|
1967
|
+
_context27.next = 59;
|
|
1531
1968
|
return this.store.order.recalculateSummary({
|
|
1532
1969
|
createIfMissing: true
|
|
1533
1970
|
});
|
|
1534
1971
|
case 59:
|
|
1535
1972
|
this.store.order.persistTempOrder();
|
|
1536
1973
|
case 60:
|
|
1537
|
-
|
|
1974
|
+
_context27.next = 62;
|
|
1538
1975
|
return this.refreshItemRuleQuantityLimits();
|
|
1539
1976
|
case 62:
|
|
1540
1977
|
this.itemRulePrefillApplied = true;
|
|
@@ -1544,9 +1981,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1544
1981
|
});
|
|
1545
1982
|
case 64:
|
|
1546
1983
|
case "end":
|
|
1547
|
-
return
|
|
1984
|
+
return _context27.stop();
|
|
1548
1985
|
}
|
|
1549
|
-
},
|
|
1986
|
+
}, _callee27, this, [[20, 49, 52, 55]]);
|
|
1550
1987
|
}));
|
|
1551
1988
|
function applyPrefillByItemRule() {
|
|
1552
1989
|
return _applyPrefillByItemRule.apply(this, arguments);
|
|
@@ -1556,31 +1993,31 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1556
1993
|
}, {
|
|
1557
1994
|
key: "applyItemRulePrefill",
|
|
1558
1995
|
value: function () {
|
|
1559
|
-
var _applyItemRulePrefill = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1996
|
+
var _applyItemRulePrefill = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
|
|
1560
1997
|
var _this$store$order4, _this$store$order4$ge;
|
|
1561
|
-
return _regeneratorRuntime().wrap(function
|
|
1562
|
-
while (1) switch (
|
|
1998
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
1999
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
1563
2000
|
case 0:
|
|
1564
2001
|
if (!((_this$store$order4 = this.store.order) !== null && _this$store$order4 !== void 0 && (_this$store$order4$ge = _this$store$order4.getLastOrderInfo) !== null && _this$store$order4$ge !== void 0 && _this$store$order4$ge.call(_this$store$order4))) {
|
|
1565
|
-
|
|
2002
|
+
_context28.next = 2;
|
|
1566
2003
|
break;
|
|
1567
2004
|
}
|
|
1568
|
-
return
|
|
2005
|
+
return _context28.abrupt("return");
|
|
1569
2006
|
case 2:
|
|
1570
2007
|
this.logMethodStart('applyItemRulePrefill');
|
|
1571
|
-
|
|
2008
|
+
_context28.next = 5;
|
|
1572
2009
|
return this.applyPrefillByItemRule();
|
|
1573
2010
|
case 5:
|
|
1574
|
-
|
|
2011
|
+
_context28.next = 7;
|
|
1575
2012
|
return this.refreshItemRuleQuantityLimits();
|
|
1576
2013
|
case 7:
|
|
1577
|
-
|
|
2014
|
+
_context28.next = 9;
|
|
1578
2015
|
return this.refreshCartValidationPassed();
|
|
1579
2016
|
case 9:
|
|
1580
2017
|
case "end":
|
|
1581
|
-
return
|
|
2018
|
+
return _context28.stop();
|
|
1582
2019
|
}
|
|
1583
|
-
},
|
|
2020
|
+
}, _callee28, this);
|
|
1584
2021
|
}));
|
|
1585
2022
|
function applyItemRulePrefill() {
|
|
1586
2023
|
return _applyItemRulePrefill.apply(this, arguments);
|
|
@@ -1590,20 +2027,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1590
2027
|
}, {
|
|
1591
2028
|
key: "evaluateCartValidationByItemRule",
|
|
1592
2029
|
value: function () {
|
|
1593
|
-
var _evaluateCartValidationByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2030
|
+
var _evaluateCartValidationByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
|
|
1594
2031
|
var strategyConfigs, businessData;
|
|
1595
|
-
return _regeneratorRuntime().wrap(function
|
|
1596
|
-
while (1) switch (
|
|
2032
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
2033
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
1597
2034
|
case 0:
|
|
1598
|
-
|
|
2035
|
+
_context29.next = 2;
|
|
1599
2036
|
return this.ensureItemRuleConfigsLoaded();
|
|
1600
2037
|
case 2:
|
|
1601
|
-
strategyConfigs =
|
|
2038
|
+
strategyConfigs = _context29.sent;
|
|
1602
2039
|
if (strategyConfigs.length) {
|
|
1603
|
-
|
|
2040
|
+
_context29.next = 5;
|
|
1604
2041
|
break;
|
|
1605
2042
|
}
|
|
1606
|
-
return
|
|
2043
|
+
return _context29.abrupt("return", {
|
|
1607
2044
|
passed: true,
|
|
1608
2045
|
failures: []
|
|
1609
2046
|
});
|
|
@@ -1613,12 +2050,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1613
2050
|
runtimeConfig: this.getItemRuleRuntimeConfig(),
|
|
1614
2051
|
itemRuleConfigs: this.itemRuleConfigs
|
|
1615
2052
|
});
|
|
1616
|
-
return
|
|
2053
|
+
return _context29.abrupt("return", this.itemRuleEvaluator.validateCart(businessData));
|
|
1617
2054
|
case 7:
|
|
1618
2055
|
case "end":
|
|
1619
|
-
return
|
|
2056
|
+
return _context29.stop();
|
|
1620
2057
|
}
|
|
1621
|
-
},
|
|
2058
|
+
}, _callee29, this);
|
|
1622
2059
|
}));
|
|
1623
2060
|
function evaluateCartValidationByItemRule() {
|
|
1624
2061
|
return _evaluateCartValidationByItemRule.apply(this, arguments);
|
|
@@ -1628,20 +2065,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1628
2065
|
}, {
|
|
1629
2066
|
key: "validateBeforeSubmitByItemRule",
|
|
1630
2067
|
value: function () {
|
|
1631
|
-
var _validateBeforeSubmitByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2068
|
+
var _validateBeforeSubmitByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
|
|
1632
2069
|
var validationResult, firstFailure, errorMessage, error;
|
|
1633
|
-
return _regeneratorRuntime().wrap(function
|
|
1634
|
-
while (1) switch (
|
|
2070
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
2071
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
1635
2072
|
case 0:
|
|
1636
|
-
|
|
2073
|
+
_context30.next = 2;
|
|
1637
2074
|
return this.evaluateCartValidationByItemRule();
|
|
1638
2075
|
case 2:
|
|
1639
|
-
validationResult =
|
|
2076
|
+
validationResult = _context30.sent;
|
|
1640
2077
|
if (!validationResult.passed) {
|
|
1641
|
-
|
|
2078
|
+
_context30.next = 5;
|
|
1642
2079
|
break;
|
|
1643
2080
|
}
|
|
1644
|
-
return
|
|
2081
|
+
return _context30.abrupt("return");
|
|
1645
2082
|
case 5:
|
|
1646
2083
|
firstFailure = validationResult.failures[0];
|
|
1647
2084
|
errorMessage = (firstFailure === null || firstFailure === void 0 ? void 0 : firstFailure.validationMessage) || '当前购物车未满足商品规则,请调整后再提交';
|
|
@@ -1650,9 +2087,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1650
2087
|
throw error;
|
|
1651
2088
|
case 10:
|
|
1652
2089
|
case "end":
|
|
1653
|
-
return
|
|
2090
|
+
return _context30.stop();
|
|
1654
2091
|
}
|
|
1655
|
-
},
|
|
2092
|
+
}, _callee30, this);
|
|
1656
2093
|
}));
|
|
1657
2094
|
function validateBeforeSubmitByItemRule() {
|
|
1658
2095
|
return _validateBeforeSubmitByItemRule.apply(this, arguments);
|
|
@@ -1662,10 +2099,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1662
2099
|
}, {
|
|
1663
2100
|
key: "refreshCartValidationPassed",
|
|
1664
2101
|
value: function () {
|
|
1665
|
-
var _refreshCartValidationPassed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2102
|
+
var _refreshCartValidationPassed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
|
|
1666
2103
|
var previous, nextState, validationResult, changed;
|
|
1667
|
-
return _regeneratorRuntime().wrap(function
|
|
1668
|
-
while (1) switch (
|
|
2104
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
2105
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
1669
2106
|
case 0:
|
|
1670
2107
|
previous = this.store.cartValidation || {
|
|
1671
2108
|
passed: null,
|
|
@@ -1675,20 +2112,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1675
2112
|
passed: null,
|
|
1676
2113
|
failures: []
|
|
1677
2114
|
};
|
|
1678
|
-
|
|
1679
|
-
|
|
2115
|
+
_context31.prev = 2;
|
|
2116
|
+
_context31.next = 5;
|
|
1680
2117
|
return this.evaluateCartValidationByItemRule();
|
|
1681
2118
|
case 5:
|
|
1682
|
-
validationResult =
|
|
2119
|
+
validationResult = _context31.sent;
|
|
1683
2120
|
nextState = {
|
|
1684
2121
|
passed: validationResult.passed,
|
|
1685
2122
|
failures: validationResult.failures || []
|
|
1686
2123
|
};
|
|
1687
|
-
|
|
2124
|
+
_context31.next = 12;
|
|
1688
2125
|
break;
|
|
1689
2126
|
case 9:
|
|
1690
|
-
|
|
1691
|
-
|
|
2127
|
+
_context31.prev = 9;
|
|
2128
|
+
_context31.t0 = _context31["catch"](2);
|
|
1692
2129
|
nextState = {
|
|
1693
2130
|
passed: false,
|
|
1694
2131
|
failures: []
|
|
@@ -1697,21 +2134,21 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1697
2134
|
this.store.cartValidation = nextState;
|
|
1698
2135
|
changed = previous.passed !== nextState.passed || previous.failures !== nextState.failures;
|
|
1699
2136
|
if (!changed) {
|
|
1700
|
-
|
|
2137
|
+
_context31.next = 17;
|
|
1701
2138
|
break;
|
|
1702
2139
|
}
|
|
1703
|
-
|
|
2140
|
+
_context31.next = 17;
|
|
1704
2141
|
return this.core.effects.emit(ScanOrderHooks.onCartValidationChanged, {
|
|
1705
2142
|
cartValidation: nextState,
|
|
1706
2143
|
cartValidationPassed: nextState.passed
|
|
1707
2144
|
});
|
|
1708
2145
|
case 17:
|
|
1709
|
-
return
|
|
2146
|
+
return _context31.abrupt("return", nextState.passed);
|
|
1710
2147
|
case 18:
|
|
1711
2148
|
case "end":
|
|
1712
|
-
return
|
|
2149
|
+
return _context31.stop();
|
|
1713
2150
|
}
|
|
1714
|
-
},
|
|
2151
|
+
}, _callee31, this, [[2, 9]]);
|
|
1715
2152
|
}));
|
|
1716
2153
|
function refreshCartValidationPassed() {
|
|
1717
2154
|
return _refreshCartValidationPassed.apply(this, arguments);
|
|
@@ -1721,14 +2158,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1721
2158
|
}, {
|
|
1722
2159
|
key: "setItemRuleRuntimeConfig",
|
|
1723
2160
|
value: function () {
|
|
1724
|
-
var _setItemRuleRuntimeConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2161
|
+
var _setItemRuleRuntimeConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
|
|
1725
2162
|
var _this$itemRuleRuntime, _this$itemRuleRuntime2;
|
|
1726
2163
|
var config,
|
|
1727
|
-
|
|
1728
|
-
return _regeneratorRuntime().wrap(function
|
|
1729
|
-
while (1) switch (
|
|
2164
|
+
_args32 = arguments;
|
|
2165
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
2166
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
1730
2167
|
case 0:
|
|
1731
|
-
config =
|
|
2168
|
+
config = _args32.length > 0 && _args32[0] !== undefined ? _args32[0] : {};
|
|
1732
2169
|
this.logMethodStart('setItemRuleRuntimeConfig');
|
|
1733
2170
|
this.itemRuleRuntimeConfig = _objectSpread(_objectSpread(_objectSpread({}, this.itemRuleRuntimeConfig), config), {}, {
|
|
1734
2171
|
pax: _objectSpread(_objectSpread({}, ((_this$itemRuleRuntime = this.itemRuleRuntimeConfig) === null || _this$itemRuleRuntime === void 0 ? void 0 : _this$itemRuleRuntime.pax) || {}), (config === null || config === void 0 ? void 0 : config.pax) || {}),
|
|
@@ -1740,10 +2177,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1740
2177
|
this.itemRuleEvaluator.setStrategyConfigs([]);
|
|
1741
2178
|
}
|
|
1742
2179
|
this.itemRulePrefillApplied = false;
|
|
1743
|
-
|
|
2180
|
+
_context32.next = 7;
|
|
1744
2181
|
return this.refreshItemRuleQuantityLimits();
|
|
1745
2182
|
case 7:
|
|
1746
|
-
|
|
2183
|
+
_context32.next = 9;
|
|
1747
2184
|
return this.refreshCartValidationPassed();
|
|
1748
2185
|
case 9:
|
|
1749
2186
|
this.logMethodSuccess('setItemRuleRuntimeConfig', {
|
|
@@ -1751,9 +2188,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1751
2188
|
});
|
|
1752
2189
|
case 10:
|
|
1753
2190
|
case "end":
|
|
1754
|
-
return
|
|
2191
|
+
return _context32.stop();
|
|
1755
2192
|
}
|
|
1756
|
-
},
|
|
2193
|
+
}, _callee32, this);
|
|
1757
2194
|
}));
|
|
1758
2195
|
function setItemRuleRuntimeConfig() {
|
|
1759
2196
|
return _setItemRuleRuntimeConfig.apply(this, arguments);
|
|
@@ -1852,27 +2289,27 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1852
2289
|
}, {
|
|
1853
2290
|
key: "fetchResourceOccupyDetailByResourceId",
|
|
1854
2291
|
value: function () {
|
|
1855
|
-
var _fetchResourceOccupyDetailByResourceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2292
|
+
var _fetchResourceOccupyDetailByResourceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(resourceId) {
|
|
1856
2293
|
var _this$otherParams9, _this$otherParams9$ge, _response$data$occupy, _response$data;
|
|
1857
2294
|
var formRecordId, shopId, response;
|
|
1858
|
-
return _regeneratorRuntime().wrap(function
|
|
1859
|
-
while (1) switch (
|
|
2295
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
2296
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
1860
2297
|
case 0:
|
|
1861
2298
|
formRecordId = Number(resourceId);
|
|
1862
2299
|
if (!(!Number.isFinite(formRecordId) || formRecordId <= 0)) {
|
|
1863
|
-
|
|
2300
|
+
_context33.next = 3;
|
|
1864
2301
|
break;
|
|
1865
2302
|
}
|
|
1866
2303
|
throw new Error("[ScanOrder] \u975E\u6CD5\u684C\u53F0 resourceId: ".concat(resourceId));
|
|
1867
2304
|
case 3:
|
|
1868
2305
|
shopId = (_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 || (_this$otherParams9$ge = _this$otherParams9.getStateData) === null || _this$otherParams9$ge === void 0 ? void 0 : _this$otherParams9$ge.call(_this$otherParams9, 'shop_id');
|
|
1869
2306
|
if (shopId) {
|
|
1870
|
-
|
|
2307
|
+
_context33.next = 6;
|
|
1871
2308
|
break;
|
|
1872
2309
|
}
|
|
1873
2310
|
throw new Error('[ScanOrder] 无法获取 shop_id');
|
|
1874
2311
|
case 6:
|
|
1875
|
-
|
|
2312
|
+
_context33.next = 8;
|
|
1876
2313
|
return this.request.get('/order/resource/occupy-detail', {
|
|
1877
2314
|
shop_id: shopId,
|
|
1878
2315
|
'form_record_ids[]': formRecordId,
|
|
@@ -1881,21 +2318,21 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1881
2318
|
with_resource_form_info: 1
|
|
1882
2319
|
});
|
|
1883
2320
|
case 8:
|
|
1884
|
-
response =
|
|
2321
|
+
response = _context33.sent;
|
|
1885
2322
|
if (response !== null && response !== void 0 && response.status) {
|
|
1886
|
-
|
|
2323
|
+
_context33.next = 11;
|
|
1887
2324
|
break;
|
|
1888
2325
|
}
|
|
1889
2326
|
throw new Error((response === null || response === void 0 ? void 0 : response.message) || '获取资源占用详情失败');
|
|
1890
2327
|
case 11:
|
|
1891
|
-
return
|
|
2328
|
+
return _context33.abrupt("return", (_response$data$occupy = response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 || (_response$data = _response$data.occupy_details) === null || _response$data === void 0 ? void 0 : _response$data[0]) !== null && _response$data$occupy !== void 0 ? _response$data$occupy : null);
|
|
1892
2329
|
case 12:
|
|
1893
2330
|
case "end":
|
|
1894
|
-
return
|
|
2331
|
+
return _context33.stop();
|
|
1895
2332
|
}
|
|
1896
|
-
},
|
|
2333
|
+
}, _callee33, this);
|
|
1897
2334
|
}));
|
|
1898
|
-
function fetchResourceOccupyDetailByResourceId(
|
|
2335
|
+
function fetchResourceOccupyDetailByResourceId(_x15) {
|
|
1899
2336
|
return _fetchResourceOccupyDetailByResourceId.apply(this, arguments);
|
|
1900
2337
|
}
|
|
1901
2338
|
return fetchResourceOccupyDetailByResourceId;
|
|
@@ -1905,32 +2342,32 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1905
2342
|
}, {
|
|
1906
2343
|
key: "checkResourceAvailable",
|
|
1907
2344
|
value: function () {
|
|
1908
|
-
var _checkResourceAvailable = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2345
|
+
var _checkResourceAvailable = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(resourceId, hasOrderId) {
|
|
1909
2346
|
var _this$otherParams10, _this$otherParams10$g, _occupyDetail$form_re, _occupyDetail$form_re2, _this$otherParams11, _this$store$order5, _this$store$order7, _this$store$order7$ge, _this$otherParams12, openData, dineInConfig, closedBehaviorValue, closedMessage, basicUnavailableMessage, pauseMessage, makeShopClosed, operatingHourIds, outsideOperatingHours, scheduleList, now, tempOrder, reservationLinkIds, pendingRequestEntryPax, pendingRequestPaxMin, pendingRequestPaxMax, reservationProductList, scheduleDate, scheduleDatetime, loaded, occupancyMinutes, paxBounds, occupyDetail, resourceSelectType, resourceState, availabilityInfo, _this$store$order6, _res$data, res, entryPaxNumber, lastOrderInfo, historicalItems;
|
|
1910
|
-
return _regeneratorRuntime().wrap(function
|
|
1911
|
-
while (1) switch (
|
|
2347
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
2348
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
1912
2349
|
case 0:
|
|
1913
2350
|
this.logMethodStart('checkResourceAvailable', {
|
|
1914
2351
|
resourceId: resourceId
|
|
1915
2352
|
});
|
|
1916
|
-
|
|
1917
|
-
|
|
2353
|
+
_context34.prev = 1;
|
|
2354
|
+
_context34.next = 4;
|
|
1918
2355
|
return (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 || (_this$otherParams10$g = _this$otherParams10.getOpenData) === null || _this$otherParams10$g === void 0 ? void 0 : _this$otherParams10$g.call(_this$otherParams10, {
|
|
1919
2356
|
scope: 'board',
|
|
1920
2357
|
target: 'dine_in+scan_to_order',
|
|
1921
2358
|
section_code: ['basic', 'fulfillment', 'reservation', 'sale', 'menu', 'availability', 'workflow']
|
|
1922
2359
|
});
|
|
1923
2360
|
case 4:
|
|
1924
|
-
openData =
|
|
2361
|
+
openData = _context34.sent;
|
|
1925
2362
|
if (!((openData === null || openData === void 0 ? void 0 : openData.status) === false)) {
|
|
1926
|
-
|
|
2363
|
+
_context34.next = 7;
|
|
1927
2364
|
break;
|
|
1928
2365
|
}
|
|
1929
2366
|
throw new Error((openData === null || openData === void 0 ? void 0 : openData.message) || '获取店铺配置失败');
|
|
1930
2367
|
case 7:
|
|
1931
2368
|
dineInConfig = (openData === null || openData === void 0 ? void 0 : openData.data) || {};
|
|
1932
2369
|
this.otherParams.dineInConfig = dineInConfig;
|
|
1933
|
-
|
|
2370
|
+
_context34.next = 11;
|
|
1934
2371
|
return this.syncItemRuleConfigsFromDineInConfig(dineInConfig);
|
|
1935
2372
|
case 11:
|
|
1936
2373
|
closedBehaviorValue = dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.closed_behavior'];
|
|
@@ -1949,20 +2386,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1949
2386
|
};
|
|
1950
2387
|
}; // 1. 基础开关 basic.enable 关闭
|
|
1951
2388
|
if (!((dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['basic.enable']) === false)) {
|
|
1952
|
-
|
|
2389
|
+
_context34.next = 18;
|
|
1953
2390
|
break;
|
|
1954
2391
|
}
|
|
1955
|
-
return
|
|
2392
|
+
return _context34.abrupt("return", makeShopClosed(basicUnavailableMessage));
|
|
1956
2393
|
case 18:
|
|
1957
2394
|
if (!toBoolean(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.paused'])) {
|
|
1958
|
-
|
|
2395
|
+
_context34.next = 21;
|
|
1959
2396
|
break;
|
|
1960
2397
|
}
|
|
1961
2398
|
if (!((dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.pause_behavior']) === 'hide_all')) {
|
|
1962
|
-
|
|
2399
|
+
_context34.next = 21;
|
|
1963
2400
|
break;
|
|
1964
2401
|
}
|
|
1965
|
-
return
|
|
2402
|
+
return _context34.abrupt("return", makeShopClosed(pauseMessage));
|
|
1966
2403
|
case 21:
|
|
1967
2404
|
// 3. 营业时间 operating_hours 闸门
|
|
1968
2405
|
operatingHourIds = Array.isArray(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.operating_hours']) ? dineInConfig['availability.operating_hours'].map(function (id) {
|
|
@@ -1979,27 +2416,27 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1979
2416
|
}
|
|
1980
2417
|
}
|
|
1981
2418
|
if (!(outsideOperatingHours && closedBehaviorValue !== 'show_menu_disabled')) {
|
|
1982
|
-
|
|
2419
|
+
_context34.next = 26;
|
|
1983
2420
|
break;
|
|
1984
2421
|
}
|
|
1985
|
-
return
|
|
2422
|
+
return _context34.abrupt("return", makeShopClosed(closedMessage, closedBehaviorValue));
|
|
1986
2423
|
case 26:
|
|
1987
2424
|
// Step1: 先加载预约规则商品,拿到 enabledReservationRuleProducts 与容量附加信息
|
|
1988
2425
|
// (resourceSelectType 需要基于这些商品 + 占用接口的 form_id 计算,故必须前置)
|
|
1989
2426
|
tempOrder = this.ensureTempOrder();
|
|
1990
2427
|
reservationLinkIds = collectLinkProductIdsFromReservationRules(dineInConfig['fulfillment.enabled_resource_rules']);
|
|
1991
2428
|
if (!(reservationLinkIds.length === 0)) {
|
|
1992
|
-
|
|
2429
|
+
_context34.next = 32;
|
|
1993
2430
|
break;
|
|
1994
2431
|
}
|
|
1995
2432
|
this.enabledReservationRuleProducts = [];
|
|
1996
|
-
|
|
2433
|
+
_context34.next = 43;
|
|
1997
2434
|
break;
|
|
1998
2435
|
case 32:
|
|
1999
2436
|
tempOrder.metadata = _objectSpread({}, tempOrder.metadata || {});
|
|
2000
2437
|
delete tempOrder.metadata.table_occupancy_duration;
|
|
2001
2438
|
reservationProductList = new ProductList("".concat(this.name, "_reservationEnabledRules"), this.defaultVersion);
|
|
2002
|
-
|
|
2439
|
+
_context34.next = 37;
|
|
2003
2440
|
return reservationProductList.initialize(this.core, {
|
|
2004
2441
|
store: {
|
|
2005
2442
|
list: [],
|
|
@@ -2014,7 +2451,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2014
2451
|
case 37:
|
|
2015
2452
|
scheduleDate = dayjs().format('YYYY-MM-DD');
|
|
2016
2453
|
scheduleDatetime = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
2017
|
-
|
|
2454
|
+
_context34.next = 41;
|
|
2018
2455
|
return reservationProductList.loadProducts({
|
|
2019
2456
|
product_ids: reservationLinkIds,
|
|
2020
2457
|
schedule_date: scheduleDate,
|
|
@@ -2022,7 +2459,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2022
2459
|
cacheId: this.cacheId
|
|
2023
2460
|
});
|
|
2024
2461
|
case 41:
|
|
2025
|
-
loaded =
|
|
2462
|
+
loaded = _context34.sent;
|
|
2026
2463
|
if (Array.isArray(loaded)) {
|
|
2027
2464
|
this.enabledReservationRuleProducts = loaded;
|
|
2028
2465
|
occupancyMinutes = pickFirstDurationMinutesFromProducts(loaded);
|
|
@@ -2047,10 +2484,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2047
2484
|
});
|
|
2048
2485
|
}
|
|
2049
2486
|
case 43:
|
|
2050
|
-
|
|
2487
|
+
_context34.next = 45;
|
|
2051
2488
|
return this.fetchResourceOccupyDetailByResourceId(resourceId);
|
|
2052
2489
|
case 45:
|
|
2053
|
-
occupyDetail =
|
|
2490
|
+
occupyDetail = _context34.sent;
|
|
2054
2491
|
// Step3: 结合预约规则商品的 product_resource.resources 与占用接口返回的 form_id,
|
|
2055
2492
|
// 计算当前桌台的 resourceSelectType(single/multiple/capacity)
|
|
2056
2493
|
resourceSelectType = this.resolveResourceSelectType(toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_id)); // Step4: 用 occupyDetail + resourceSelectType 规整为 resourceState
|
|
@@ -2090,10 +2527,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2090
2527
|
|
|
2091
2528
|
// 空闲状态下自动准备本地临时订单,供后续“购物车式”商品操作使用
|
|
2092
2529
|
if (!(availabilityInfo.mode === 'idle')) {
|
|
2093
|
-
|
|
2530
|
+
_context34.next = 60;
|
|
2094
2531
|
break;
|
|
2095
2532
|
}
|
|
2096
|
-
|
|
2533
|
+
_context34.next = 60;
|
|
2097
2534
|
return this.addNewOrder();
|
|
2098
2535
|
case 60:
|
|
2099
2536
|
// 如果是加单模式,tempOrder 里 需要记录 lastOrderId,提交的时候走加单接口
|
|
@@ -2101,23 +2538,23 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2101
2538
|
tempOrder.order_id = resourceState.lastOrderId;
|
|
2102
2539
|
}
|
|
2103
2540
|
if (!tempOrder.order_id) {
|
|
2104
|
-
|
|
2541
|
+
_context34.next = 69;
|
|
2105
2542
|
break;
|
|
2106
2543
|
}
|
|
2107
|
-
|
|
2544
|
+
_context34.next = 64;
|
|
2108
2545
|
return (_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 ? void 0 : _this$store$order6.getOrderInfoByRemote(tempOrder.order_id);
|
|
2109
2546
|
case 64:
|
|
2110
|
-
res =
|
|
2547
|
+
res = _context34.sent;
|
|
2111
2548
|
// 找到下单的时候输入的 entryPaxNumber
|
|
2112
2549
|
entryPaxNumber = res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 || (_res$data = _res$data.bookings) === null || _res$data === void 0 || (_res$data = _res$data.find(function (p) {
|
|
2113
2550
|
var _p$metadata;
|
|
2114
2551
|
return (_p$metadata = p.metadata) === null || _p$metadata === void 0 ? void 0 : _p$metadata.collect_pax;
|
|
2115
2552
|
})) === null || _res$data === void 0 || (_res$data = _res$data.metadata) === null || _res$data === void 0 ? void 0 : _res$data.collect_pax;
|
|
2116
2553
|
if (!entryPaxNumber) {
|
|
2117
|
-
|
|
2554
|
+
_context34.next = 69;
|
|
2118
2555
|
break;
|
|
2119
2556
|
}
|
|
2120
|
-
|
|
2557
|
+
_context34.next = 69;
|
|
2121
2558
|
return this.setEntryPaxNumber(entryPaxNumber);
|
|
2122
2559
|
case 69:
|
|
2123
2560
|
lastOrderInfo = (_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 || (_this$store$order7$ge = _this$store$order7.getLastOrderInfo) === null || _this$store$order7$ge === void 0 ? void 0 : _this$store$order7$ge.call(_this$store$order7);
|
|
@@ -2131,7 +2568,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2131
2568
|
} : {}));
|
|
2132
2569
|
return acc;
|
|
2133
2570
|
}, []) : []; // pax 由 setEntryPaxNumber 负责写入 itemRuleRuntimeConfig.pax
|
|
2134
|
-
|
|
2571
|
+
_context34.next = 73;
|
|
2135
2572
|
return this.setItemRuleRuntimeConfig({
|
|
2136
2573
|
serviceType: (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.businessCode,
|
|
2137
2574
|
submissionIndex: hasOrderId ? 1 : 0,
|
|
@@ -2158,21 +2595,21 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2158
2595
|
isExclusive: resourceState.isExclusive,
|
|
2159
2596
|
isFull: resourceState.isFull
|
|
2160
2597
|
});
|
|
2161
|
-
return
|
|
2598
|
+
return _context34.abrupt("return", availabilityInfo);
|
|
2162
2599
|
case 78:
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
this.logMethodError('checkResourceAvailable',
|
|
2600
|
+
_context34.prev = 78;
|
|
2601
|
+
_context34.t0 = _context34["catch"](1);
|
|
2602
|
+
this.logMethodError('checkResourceAvailable', _context34.t0.message, {
|
|
2166
2603
|
resourceId: resourceId
|
|
2167
2604
|
});
|
|
2168
|
-
throw
|
|
2605
|
+
throw _context34.t0;
|
|
2169
2606
|
case 82:
|
|
2170
2607
|
case "end":
|
|
2171
|
-
return
|
|
2608
|
+
return _context34.stop();
|
|
2172
2609
|
}
|
|
2173
|
-
},
|
|
2610
|
+
}, _callee34, this, [[1, 78]]);
|
|
2174
2611
|
}));
|
|
2175
|
-
function checkResourceAvailable(
|
|
2612
|
+
function checkResourceAvailable(_x16, _x17) {
|
|
2176
2613
|
return _checkResourceAvailable.apply(this, arguments);
|
|
2177
2614
|
}
|
|
2178
2615
|
return checkResourceAvailable;
|
|
@@ -2180,10 +2617,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2180
2617
|
}, {
|
|
2181
2618
|
key: "getAdditionalOrderInfo",
|
|
2182
2619
|
value: function () {
|
|
2183
|
-
var _getAdditionalOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2620
|
+
var _getAdditionalOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {
|
|
2184
2621
|
var result;
|
|
2185
|
-
return _regeneratorRuntime().wrap(function
|
|
2186
|
-
while (1) switch (
|
|
2622
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
2623
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
2187
2624
|
case 0:
|
|
2188
2625
|
this.logMethodStart('getAdditionalOrderInfo');
|
|
2189
2626
|
result = {
|
|
@@ -2197,12 +2634,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2197
2634
|
orderId: result.orderId,
|
|
2198
2635
|
orderStatus: result.orderStatus
|
|
2199
2636
|
});
|
|
2200
|
-
return
|
|
2637
|
+
return _context35.abrupt("return", result);
|
|
2201
2638
|
case 4:
|
|
2202
2639
|
case "end":
|
|
2203
|
-
return
|
|
2640
|
+
return _context35.stop();
|
|
2204
2641
|
}
|
|
2205
|
-
},
|
|
2642
|
+
}, _callee35, this);
|
|
2206
2643
|
}));
|
|
2207
2644
|
function getAdditionalOrderInfo() {
|
|
2208
2645
|
return _getAdditionalOrderInfo.apply(this, arguments);
|
|
@@ -2212,19 +2649,19 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2212
2649
|
}, {
|
|
2213
2650
|
key: "getProductList",
|
|
2214
2651
|
value: function () {
|
|
2215
|
-
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2652
|
+
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {
|
|
2216
2653
|
var _this$otherParams13;
|
|
2217
2654
|
var menu_list_ids, _this$store$products, res, formattedRes;
|
|
2218
|
-
return _regeneratorRuntime().wrap(function
|
|
2219
|
-
while (1) switch (
|
|
2655
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
2656
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
2220
2657
|
case 0:
|
|
2221
2658
|
this.logMethodStart('getProductList');
|
|
2222
2659
|
// 可以直接通过配置里的 menu 读取
|
|
2223
2660
|
menu_list_ids = ((_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 || (_this$otherParams13 = _this$otherParams13.dineInConfig) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13['menu.associated_menus'].map(function (n) {
|
|
2224
2661
|
return Number(n.value);
|
|
2225
2662
|
})) || [];
|
|
2226
|
-
|
|
2227
|
-
|
|
2663
|
+
_context36.prev = 2;
|
|
2664
|
+
_context36.next = 5;
|
|
2228
2665
|
return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
|
|
2229
2666
|
menu_list_ids: menu_list_ids,
|
|
2230
2667
|
cacheId: this.cacheId,
|
|
@@ -2232,22 +2669,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2232
2669
|
schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
2233
2670
|
});
|
|
2234
2671
|
case 5:
|
|
2235
|
-
res =
|
|
2672
|
+
res = _context36.sent;
|
|
2236
2673
|
formattedRes = attachItemRuleLimitsToTopLevelProducts(res, this.store.itemRuleQuantityLimits || []);
|
|
2237
2674
|
this.logMethodSuccess('getProductList', {
|
|
2238
2675
|
menuCount: menu_list_ids.length
|
|
2239
2676
|
});
|
|
2240
|
-
return
|
|
2677
|
+
return _context36.abrupt("return", formattedRes);
|
|
2241
2678
|
case 11:
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
this.logMethodError('getProductList',
|
|
2245
|
-
throw
|
|
2679
|
+
_context36.prev = 11;
|
|
2680
|
+
_context36.t0 = _context36["catch"](2);
|
|
2681
|
+
this.logMethodError('getProductList', _context36.t0.message);
|
|
2682
|
+
throw _context36.t0;
|
|
2246
2683
|
case 15:
|
|
2247
2684
|
case "end":
|
|
2248
|
-
return
|
|
2685
|
+
return _context36.stop();
|
|
2249
2686
|
}
|
|
2250
|
-
},
|
|
2687
|
+
}, _callee36, this, [[2, 11]]);
|
|
2251
2688
|
}));
|
|
2252
2689
|
function getProductList() {
|
|
2253
2690
|
return _getProductList.apply(this, arguments);
|
|
@@ -2262,15 +2699,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2262
2699
|
}, {
|
|
2263
2700
|
key: "setOtherParams",
|
|
2264
2701
|
value: function () {
|
|
2265
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2266
|
-
var
|
|
2267
|
-
|
|
2702
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
|
|
2703
|
+
var _ref8,
|
|
2704
|
+
_ref8$cover,
|
|
2268
2705
|
cover,
|
|
2269
|
-
|
|
2270
|
-
return _regeneratorRuntime().wrap(function
|
|
2271
|
-
while (1) switch (
|
|
2706
|
+
_args37 = arguments;
|
|
2707
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
2708
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
2272
2709
|
case 0:
|
|
2273
|
-
|
|
2710
|
+
_ref8 = _args37.length > 1 && _args37[1] !== undefined ? _args37[1] : {}, _ref8$cover = _ref8.cover, cover = _ref8$cover === void 0 ? false : _ref8$cover;
|
|
2274
2711
|
if (cover) {
|
|
2275
2712
|
this.otherParams = params;
|
|
2276
2713
|
} else {
|
|
@@ -2278,11 +2715,11 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2278
2715
|
}
|
|
2279
2716
|
case 2:
|
|
2280
2717
|
case "end":
|
|
2281
|
-
return
|
|
2718
|
+
return _context37.stop();
|
|
2282
2719
|
}
|
|
2283
|
-
},
|
|
2720
|
+
}, _callee37, this);
|
|
2284
2721
|
}));
|
|
2285
|
-
function setOtherParams(
|
|
2722
|
+
function setOtherParams(_x18) {
|
|
2286
2723
|
return _setOtherParams.apply(this, arguments);
|
|
2287
2724
|
}
|
|
2288
2725
|
return setOtherParams;
|
|
@@ -2365,10 +2802,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2365
2802
|
}, {
|
|
2366
2803
|
key: "setEntryPaxNumber",
|
|
2367
2804
|
value: function () {
|
|
2368
|
-
var _setEntryPaxNumber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2805
|
+
var _setEntryPaxNumber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(number) {
|
|
2369
2806
|
var pax, t;
|
|
2370
|
-
return _regeneratorRuntime().wrap(function
|
|
2371
|
-
while (1) switch (
|
|
2807
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
2808
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
2372
2809
|
case 0:
|
|
2373
2810
|
pax = normalizeSubmitCollectPaxValue(number);
|
|
2374
2811
|
this.store.entryPaxNumber = pax;
|
|
@@ -2389,18 +2826,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2389
2826
|
}
|
|
2390
2827
|
});
|
|
2391
2828
|
this.itemRulePrefillApplied = false;
|
|
2392
|
-
|
|
2829
|
+
_context38.next = 7;
|
|
2393
2830
|
return this.refreshItemRuleQuantityLimits();
|
|
2394
2831
|
case 7:
|
|
2395
|
-
|
|
2832
|
+
_context38.next = 9;
|
|
2396
2833
|
return this.refreshCartValidationPassed();
|
|
2397
2834
|
case 9:
|
|
2398
2835
|
case "end":
|
|
2399
|
-
return
|
|
2836
|
+
return _context38.stop();
|
|
2400
2837
|
}
|
|
2401
|
-
},
|
|
2838
|
+
}, _callee38, this);
|
|
2402
2839
|
}));
|
|
2403
|
-
function setEntryPaxNumber(
|
|
2840
|
+
function setEntryPaxNumber(_x19) {
|
|
2404
2841
|
return _setEntryPaxNumber.apply(this, arguments);
|
|
2405
2842
|
}
|
|
2406
2843
|
return setEntryPaxNumber;
|
|
@@ -2453,4 +2890,5 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2453
2890
|
}]);
|
|
2454
2891
|
return ScanOrderImpl;
|
|
2455
2892
|
}(BaseModule);
|
|
2893
|
+
_defineProperty(ScanOrderImpl, "PISELL1_LOGIN_SUCCESS", 'pisell1.login.success');
|
|
2456
2894
|
_defineProperty(ScanOrderImpl, "UI_STATE_KEY_PREFIX", 'pisell.scanOrder.uiState:');
|