@pisell/pisellos 2.1.129 → 2.1.131
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/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/Order/index.d.ts +7 -6
- package/dist/modules/Order/index.js +137 -42
- package/dist/modules/Order/types.d.ts +32 -6
- package/dist/modules/Order/types.js +2 -0
- package/dist/modules/Order/utils.d.ts +73 -11
- package/dist/modules/Order/utils.js +304 -52
- package/dist/modules/SalesSummary/utils.js +33 -68
- package/dist/modules/ScanOrderLogger/providers/feishu.js +168 -60
- package/dist/modules/ScanOrderLogger/types.d.ts +6 -0
- package/dist/modules/Summary/utils.js +6 -21
- package/dist/solution/ScanOrder/index.d.ts +57 -8
- package/dist/solution/ScanOrder/index.js +1531 -583
- package/dist/solution/ScanOrder/types.d.ts +86 -26
- package/dist/solution/ScanOrder/types.js +20 -1
- package/dist/solution/ScanOrder/utils.d.ts +53 -5
- package/dist/solution/ScanOrder/utils.js +257 -37
- package/dist/solution/VenueBooking/index.d.ts +30 -10
- package/dist/solution/VenueBooking/index.js +460 -217
- package/dist/solution/VenueBooking/types.d.ts +23 -0
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +1 -1
- package/dist/solution/VenueBooking/utils/dateSummary.js +1 -1
- package/dist/solution/VenueBooking/utils/resource.d.ts +11 -1
- package/dist/solution/VenueBooking/utils/resource.js +57 -21
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +5 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +33 -12
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +1 -1
- package/dist/solution/VenueBooking/utils/timeSlot.js +259 -62
- package/lib/modules/Order/index.d.ts +7 -6
- package/lib/modules/Order/index.js +123 -31
- package/lib/modules/Order/types.d.ts +32 -6
- package/lib/modules/Order/utils.d.ts +73 -11
- package/lib/modules/Order/utils.js +203 -28
- package/lib/modules/SalesSummary/utils.js +13 -47
- package/lib/modules/ScanOrderLogger/providers/feishu.js +100 -34
- package/lib/modules/ScanOrderLogger/types.d.ts +6 -0
- package/lib/modules/Summary/utils.js +4 -18
- package/lib/solution/ScanOrder/index.d.ts +57 -8
- package/lib/solution/ScanOrder/index.js +713 -117
- package/lib/solution/ScanOrder/types.d.ts +86 -26
- package/lib/solution/ScanOrder/utils.d.ts +53 -5
- package/lib/solution/ScanOrder/utils.js +186 -19
- package/lib/solution/VenueBooking/index.d.ts +30 -10
- package/lib/solution/VenueBooking/index.js +206 -51
- package/lib/solution/VenueBooking/types.d.ts +23 -0
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +1 -1
- package/lib/solution/VenueBooking/utils/dateSummary.js +1 -1
- package/lib/solution/VenueBooking/utils/resource.d.ts +11 -1
- package/lib/solution/VenueBooking/utils/resource.js +15 -4
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +5 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +29 -12
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +1 -1
- package/lib/solution/VenueBooking/utils/timeSlot.js +182 -43
- package/package.json +1 -1
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
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."); }
|
|
3
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
4
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
5
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
1
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; } } }; }
|
|
2
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); }
|
|
3
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; }
|
|
4
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
5
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; }
|
|
6
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; }
|
|
7
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; }
|
|
@@ -10,6 +14,8 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
|
|
|
10
14
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
11
15
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
12
16
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
17
|
+
function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
|
|
18
|
+
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
13
19
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
14
20
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
15
21
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
@@ -22,10 +28,16 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
22
28
|
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); }
|
|
23
29
|
import { BaseModule } from "../../modules/BaseModule";
|
|
24
30
|
import { ScanOrderHooks } from "./types";
|
|
25
|
-
import {
|
|
31
|
+
import { OrderModule } from "../../modules/Order";
|
|
32
|
+
import { AccountHooks } from "../../modules/Account/types";
|
|
33
|
+
import { RegisterAndLoginHooks } from "../RegisterAndLogin/types";
|
|
34
|
+
import Decimal from 'decimal.js';
|
|
35
|
+
import { attachItemRuleLimitsToTopLevelProducts, buildProductKey, buildItemRuleBusinessData, collectLinkProductIdsFromReservationRules, computeResourceIsFull, createEmptySummary, getProductIdentityIndex, getSafeProductNum, hasCustomCapacityProduct, pickFirstCustomCapacityDimensionId, pickFirstCustomCapacityPaxBounds, normalizeEnabledItemRuleIds, normalizeOrderProduct, normalizeItemRuleStrategies, pickFirstDurationMinutesFromProducts, toNonNegativeInt, toPriceString, toBoolean, toPositiveString } from "./utils";
|
|
26
36
|
import { createModule } from "../BookingByStep/types";
|
|
27
37
|
import { ProductList } from "../../modules/ProductList";
|
|
28
|
-
import {
|
|
38
|
+
import { ScheduleModule } from "../../modules/Schedule";
|
|
39
|
+
import { getDateIsInSchedule } from "../../modules/Schedule/getDateIsInSchedule";
|
|
40
|
+
import { composeLinePrice, createUuidV4, normalizeSubmitCollectPaxValue, sumOptionUnitPrice } from "../../modules/Order/utils";
|
|
29
41
|
import dayjs from 'dayjs';
|
|
30
42
|
import { ItemRuleEvaluator } from "../../model/strategy/adapter/itemRule";
|
|
31
43
|
export * from "./types";
|
|
@@ -66,8 +78,13 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
66
78
|
_defineProperty(_assertThisInitialized(_this), "itemRuleRuntimeConfig", {});
|
|
67
79
|
/** 最近一次 checkResourceAvailable 从预约规则 link 拉取的商品快照 */
|
|
68
80
|
_defineProperty(_assertThisInitialized(_this), "enabledReservationRuleProducts", []);
|
|
81
|
+
_defineProperty(_assertThisInitialized(_this), "loginEffectDisposers", []);
|
|
82
|
+
_defineProperty(_assertThisInitialized(_this), "customerLoginRefreshInFlight", null);
|
|
83
|
+
_defineProperty(_assertThisInitialized(_this), "customerLoginRefreshIdInFlight", null);
|
|
69
84
|
return _this;
|
|
70
85
|
}
|
|
86
|
+
|
|
87
|
+
/** 与 `otherParams.cacheId` 一致,供宿主在 URL 变化时判断是否需要重新注册模块 */
|
|
71
88
|
_createClass(ScanOrderImpl, [{
|
|
72
89
|
key: "getScanOrderLoggerContext",
|
|
73
90
|
value: function getScanOrderLoggerContext() {
|
|
@@ -81,11 +98,11 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
81
98
|
key: "serializeError",
|
|
82
99
|
value: function serializeError(error) {
|
|
83
100
|
if (error instanceof Error) {
|
|
84
|
-
return {
|
|
101
|
+
return JSON.stringify({
|
|
85
102
|
name: error.name,
|
|
86
103
|
message: error.message,
|
|
87
104
|
stack: error.stack
|
|
88
|
-
};
|
|
105
|
+
});
|
|
89
106
|
}
|
|
90
107
|
return {
|
|
91
108
|
message: String(error)
|
|
@@ -199,24 +216,241 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
199
216
|
}
|
|
200
217
|
return addLog;
|
|
201
218
|
}()
|
|
219
|
+
}, {
|
|
220
|
+
key: "normalizeCustomerId",
|
|
221
|
+
value: function normalizeCustomerId(value) {
|
|
222
|
+
var customerId = Number(value);
|
|
223
|
+
if (!Number.isFinite(customerId) || customerId <= 0) return null;
|
|
224
|
+
return customerId;
|
|
225
|
+
}
|
|
226
|
+
}, {
|
|
227
|
+
key: "resolveCustomerIdFromLoginPayload",
|
|
228
|
+
value: function resolveCustomerIdFromLoginPayload(payload) {
|
|
229
|
+
var _payload$user, _payload$user2, _payload$user3, _payload$user4, _payload$account, _payload$account2, _payload$account3, _payload$_origin;
|
|
230
|
+
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];
|
|
231
|
+
for (var _i = 0, _candidates = candidates; _i < _candidates.length; _i++) {
|
|
232
|
+
var candidate = _candidates[_i];
|
|
233
|
+
var customerId = this.normalizeCustomerId(candidate);
|
|
234
|
+
if (customerId) return customerId;
|
|
235
|
+
}
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
}, {
|
|
239
|
+
key: "clearLoginEffectListeners",
|
|
240
|
+
value: function clearLoginEffectListeners() {
|
|
241
|
+
var _iterator = _createForOfIteratorHelper(this.loginEffectDisposers),
|
|
242
|
+
_step;
|
|
243
|
+
try {
|
|
244
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
245
|
+
var dispose = _step.value;
|
|
246
|
+
dispose();
|
|
247
|
+
}
|
|
248
|
+
} catch (err) {
|
|
249
|
+
_iterator.e(err);
|
|
250
|
+
} finally {
|
|
251
|
+
_iterator.f();
|
|
252
|
+
}
|
|
253
|
+
this.loginEffectDisposers = [];
|
|
254
|
+
}
|
|
255
|
+
}, {
|
|
256
|
+
key: "registerLoginEffect",
|
|
257
|
+
value: function registerLoginEffect(event, callback) {
|
|
258
|
+
var _this$core;
|
|
259
|
+
var effects = (_this$core = this.core) === null || _this$core === void 0 ? void 0 : _this$core.effects;
|
|
260
|
+
if (!(effects !== null && effects !== void 0 && effects.on)) return;
|
|
261
|
+
effects.on(event, callback);
|
|
262
|
+
this.loginEffectDisposers.push(function () {
|
|
263
|
+
if (typeof effects.off === 'function') {
|
|
264
|
+
effects.off(event, callback);
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
}, {
|
|
269
|
+
key: "registerCustomerLoginListeners",
|
|
270
|
+
value: function registerCustomerLoginListeners() {
|
|
271
|
+
var _this2 = this;
|
|
272
|
+
this.clearLoginEffectListeners();
|
|
273
|
+
var createHandleLogin = function createHandleLogin() {
|
|
274
|
+
return /*#__PURE__*/function () {
|
|
275
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(payload) {
|
|
276
|
+
var customerId;
|
|
277
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
278
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
279
|
+
case 0:
|
|
280
|
+
customerId = _this2.resolveCustomerIdFromLoginPayload(payload);
|
|
281
|
+
if (customerId) {
|
|
282
|
+
_context3.next = 3;
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
return _context3.abrupt("return");
|
|
286
|
+
case 3:
|
|
287
|
+
_context3.next = 5;
|
|
288
|
+
return _this2.refreshOrderMarketingAfterLogin({
|
|
289
|
+
customerId: customerId
|
|
290
|
+
});
|
|
291
|
+
case 5:
|
|
292
|
+
case "end":
|
|
293
|
+
return _context3.stop();
|
|
294
|
+
}
|
|
295
|
+
}, _callee3);
|
|
296
|
+
}));
|
|
297
|
+
return function (_x3) {
|
|
298
|
+
return _ref.apply(this, arguments);
|
|
299
|
+
};
|
|
300
|
+
}();
|
|
301
|
+
};
|
|
302
|
+
this.registerLoginEffect(ScanOrderImpl.PISELL1_LOGIN_SUCCESS, createHandleLogin());
|
|
303
|
+
this.registerLoginEffect(AccountHooks.OnLogin, createHandleLogin());
|
|
304
|
+
this.registerLoginEffect(RegisterAndLoginHooks.onLoginSuccess, createHandleLogin());
|
|
305
|
+
}
|
|
306
|
+
}, {
|
|
307
|
+
key: "refreshOrderMarketingAfterLogin",
|
|
308
|
+
value: function () {
|
|
309
|
+
var _refreshOrderMarketingAfterLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(params) {
|
|
310
|
+
var _this3 = this;
|
|
311
|
+
var refreshTask;
|
|
312
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
313
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
314
|
+
case 0:
|
|
315
|
+
if (this.store.order) {
|
|
316
|
+
_context5.next = 2;
|
|
317
|
+
break;
|
|
318
|
+
}
|
|
319
|
+
throw new Error('order 模块未初始化');
|
|
320
|
+
case 2:
|
|
321
|
+
if (!this.customerLoginRefreshInFlight) {
|
|
322
|
+
_context5.next = 9;
|
|
323
|
+
break;
|
|
324
|
+
}
|
|
325
|
+
if (!(this.customerLoginRefreshIdInFlight === params.customerId)) {
|
|
326
|
+
_context5.next = 7;
|
|
327
|
+
break;
|
|
328
|
+
}
|
|
329
|
+
_context5.next = 6;
|
|
330
|
+
return this.customerLoginRefreshInFlight;
|
|
331
|
+
case 6:
|
|
332
|
+
return _context5.abrupt("return");
|
|
333
|
+
case 7:
|
|
334
|
+
_context5.next = 9;
|
|
335
|
+
return this.customerLoginRefreshInFlight;
|
|
336
|
+
case 9:
|
|
337
|
+
this.customerLoginRefreshIdInFlight = params.customerId;
|
|
338
|
+
refreshTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
339
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
340
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
341
|
+
case 0:
|
|
342
|
+
_context4.next = 2;
|
|
343
|
+
return _this3.store.order.loadDiscountConfig({
|
|
344
|
+
customerId: params.customerId
|
|
345
|
+
});
|
|
346
|
+
case 2:
|
|
347
|
+
_context4.next = 4;
|
|
348
|
+
return _this3.store.order.recalculateSummary({
|
|
349
|
+
createIfMissing: true
|
|
350
|
+
});
|
|
351
|
+
case 4:
|
|
352
|
+
_this3.store.order.persistTempOrder();
|
|
353
|
+
_context4.next = 7;
|
|
354
|
+
return _this3.refreshItemRuleQuantityLimits();
|
|
355
|
+
case 7:
|
|
356
|
+
_context4.next = 9;
|
|
357
|
+
return _this3.refreshCartValidationPassed();
|
|
358
|
+
case 9:
|
|
359
|
+
case "end":
|
|
360
|
+
return _context4.stop();
|
|
361
|
+
}
|
|
362
|
+
}, _callee4);
|
|
363
|
+
}))();
|
|
364
|
+
this.customerLoginRefreshInFlight = refreshTask;
|
|
365
|
+
_context5.prev = 12;
|
|
366
|
+
_context5.next = 15;
|
|
367
|
+
return refreshTask;
|
|
368
|
+
case 15:
|
|
369
|
+
_context5.next = 20;
|
|
370
|
+
break;
|
|
371
|
+
case 17:
|
|
372
|
+
_context5.prev = 17;
|
|
373
|
+
_context5.t0 = _context5["catch"](12);
|
|
374
|
+
throw _context5.t0;
|
|
375
|
+
case 20:
|
|
376
|
+
_context5.prev = 20;
|
|
377
|
+
if (this.customerLoginRefreshInFlight === refreshTask) {
|
|
378
|
+
this.customerLoginRefreshInFlight = null;
|
|
379
|
+
this.customerLoginRefreshIdInFlight = null;
|
|
380
|
+
}
|
|
381
|
+
return _context5.finish(20);
|
|
382
|
+
case 23:
|
|
383
|
+
case "end":
|
|
384
|
+
return _context5.stop();
|
|
385
|
+
}
|
|
386
|
+
}, _callee5, this, [[12, 17, 20, 23]]);
|
|
387
|
+
}));
|
|
388
|
+
function refreshOrderMarketingAfterLogin(_x4) {
|
|
389
|
+
return _refreshOrderMarketingAfterLogin.apply(this, arguments);
|
|
390
|
+
}
|
|
391
|
+
return refreshOrderMarketingAfterLogin;
|
|
392
|
+
}()
|
|
393
|
+
}, {
|
|
394
|
+
key: "getCacheId",
|
|
395
|
+
value: function getCacheId() {
|
|
396
|
+
return this.cacheId;
|
|
397
|
+
}
|
|
398
|
+
}, {
|
|
399
|
+
key: "destroyRegisteredChildModules",
|
|
400
|
+
value: function () {
|
|
401
|
+
var _destroyRegisteredChildModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
402
|
+
var modules, _i2, _modules, mod;
|
|
403
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
404
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
405
|
+
case 0:
|
|
406
|
+
modules = [this.store.schedule, this.store.salesSummary, this.store.order, this.store.products, this.store.scanOrderLogger];
|
|
407
|
+
_i2 = 0, _modules = modules;
|
|
408
|
+
case 2:
|
|
409
|
+
if (!(_i2 < _modules.length)) {
|
|
410
|
+
_context6.next = 10;
|
|
411
|
+
break;
|
|
412
|
+
}
|
|
413
|
+
mod = _modules[_i2];
|
|
414
|
+
if (!(mod && typeof mod.destroy === 'function')) {
|
|
415
|
+
_context6.next = 7;
|
|
416
|
+
break;
|
|
417
|
+
}
|
|
418
|
+
_context6.next = 7;
|
|
419
|
+
return Promise.resolve(mod.destroy());
|
|
420
|
+
case 7:
|
|
421
|
+
_i2++;
|
|
422
|
+
_context6.next = 2;
|
|
423
|
+
break;
|
|
424
|
+
case 10:
|
|
425
|
+
case "end":
|
|
426
|
+
return _context6.stop();
|
|
427
|
+
}
|
|
428
|
+
}, _callee6, this);
|
|
429
|
+
}));
|
|
430
|
+
function destroyRegisteredChildModules() {
|
|
431
|
+
return _destroyRegisteredChildModules.apply(this, arguments);
|
|
432
|
+
}
|
|
433
|
+
return destroyRegisteredChildModules;
|
|
434
|
+
}()
|
|
202
435
|
}, {
|
|
203
436
|
key: "initialize",
|
|
204
437
|
value: function () {
|
|
205
|
-
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
438
|
+
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(core) {
|
|
206
439
|
var _options$otherParams,
|
|
207
440
|
_this$otherParams,
|
|
208
441
|
_this$otherParams2,
|
|
209
442
|
_this$otherParams3,
|
|
210
|
-
|
|
443
|
+
_this4 = this;
|
|
211
444
|
var options,
|
|
212
445
|
moduleArr,
|
|
446
|
+
scheduleModule,
|
|
213
447
|
_this$store$order,
|
|
214
448
|
_this$store$order2,
|
|
215
|
-
|
|
216
|
-
return _regeneratorRuntime().wrap(function
|
|
217
|
-
while (1) switch (
|
|
449
|
+
_args7 = arguments;
|
|
450
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
451
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
218
452
|
case 0:
|
|
219
|
-
options =
|
|
453
|
+
options = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : {};
|
|
220
454
|
this.logMethodStart('initialize');
|
|
221
455
|
this.core = core;
|
|
222
456
|
this.initializeOptions = options || {};
|
|
@@ -238,14 +472,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
238
472
|
this.window = core.getPlugin('window');
|
|
239
473
|
this.request = core.getPlugin('request');
|
|
240
474
|
if (this.window) {
|
|
241
|
-
|
|
475
|
+
_context7.next = 21;
|
|
242
476
|
break;
|
|
243
477
|
}
|
|
244
478
|
this.logMethodError('initialize', 'window plugin missing');
|
|
245
479
|
throw new Error('scanOrder解决方案需要 window 插件支持');
|
|
246
480
|
case 21:
|
|
247
481
|
if (this.request) {
|
|
248
|
-
|
|
482
|
+
_context7.next = 24;
|
|
249
483
|
break;
|
|
250
484
|
}
|
|
251
485
|
this.logMethodError('initialize', 'request plugin missing');
|
|
@@ -253,82 +487,105 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
253
487
|
case 24:
|
|
254
488
|
moduleArr = ['scanOrderLogger', 'products', 'order', 'salesSummary'];
|
|
255
489
|
moduleArr.forEach(function (step) {
|
|
256
|
-
var targetModule = createModule(step,
|
|
490
|
+
var targetModule = createModule(step, _this4.name);
|
|
257
491
|
if (targetModule) {
|
|
258
|
-
var
|
|
259
|
-
|
|
492
|
+
var _this4$store$order, _this4$otherParams, _this4$otherParams2, _this4$otherParams3, _this4$otherParams4;
|
|
493
|
+
_this4.store[step] = targetModule;
|
|
260
494
|
var initialState = step === 'salesSummary' ? {
|
|
261
|
-
summary: ((
|
|
495
|
+
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()
|
|
262
496
|
} : {};
|
|
263
|
-
var loggerProvider = ((
|
|
264
|
-
var loggerConfig = ((
|
|
497
|
+
var loggerProvider = ((_this4$otherParams = _this4.otherParams) === null || _this4$otherParams === void 0 ? void 0 : _this4$otherParams.scanOrderLoggerProvider) || 'feishu';
|
|
498
|
+
var loggerConfig = ((_this4$otherParams2 = _this4.otherParams) === null || _this4$otherParams2 === void 0 ? void 0 : _this4$otherParams2.scanOrderLoggerConfig) || {
|
|
265
499
|
feishu: {
|
|
266
|
-
|
|
500
|
+
webhook: 'https://open.feishu.cn/open-apis/bot/v2/hook/216b3fe6-af98-424e-8706-f0471241a7ed'
|
|
267
501
|
}
|
|
268
502
|
};
|
|
269
|
-
|
|
503
|
+
_this4.core.registerModule(targetModule, {
|
|
270
504
|
initialState: initialState,
|
|
271
|
-
otherParams: _objectSpread(_objectSpread({},
|
|
272
|
-
fatherModule:
|
|
273
|
-
openCache: (
|
|
274
|
-
cacheId: (
|
|
275
|
-
salesSummaryModuleName: "".concat(
|
|
505
|
+
otherParams: _objectSpread(_objectSpread({}, _this4.otherParams), {}, {
|
|
506
|
+
fatherModule: _this4.name,
|
|
507
|
+
openCache: (_this4$otherParams3 = _this4.otherParams) !== null && _this4$otherParams3 !== void 0 && _this4$otherParams3.cacheId ? true : false,
|
|
508
|
+
cacheId: (_this4$otherParams4 = _this4.otherParams) === null || _this4$otherParams4 === void 0 ? void 0 : _this4$otherParams4.cacheId,
|
|
509
|
+
salesSummaryModuleName: "".concat(_this4.name, "_salesSummary"),
|
|
276
510
|
provider: loggerProvider,
|
|
277
511
|
providerConfig: loggerConfig,
|
|
278
|
-
context:
|
|
512
|
+
context: _this4.getScanOrderLoggerContext()
|
|
279
513
|
})
|
|
280
514
|
});
|
|
281
515
|
} else {
|
|
282
|
-
|
|
516
|
+
_this4.logMethodError('initialize', "module ".concat(step, " missing"));
|
|
283
517
|
throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
|
|
284
518
|
}
|
|
285
519
|
});
|
|
286
520
|
if (this.store.scanOrderLogger) {
|
|
287
521
|
this.store.scanOrderLogger.setContext(this.getScanOrderLoggerContext());
|
|
288
522
|
}
|
|
523
|
+
scheduleModule = new ScheduleModule("".concat(this.name, "_schedule"));
|
|
524
|
+
this.store.schedule = scheduleModule;
|
|
525
|
+
this.core.registerModule(scheduleModule, {
|
|
526
|
+
otherParams: _objectSpread(_objectSpread({}, this.otherParams), {}, {
|
|
527
|
+
fatherModule: this.name
|
|
528
|
+
})
|
|
529
|
+
});
|
|
530
|
+
this.registerCustomerLoginListeners();
|
|
289
531
|
console.log('[ScanOrder] 初始化开始');
|
|
290
|
-
|
|
291
|
-
|
|
532
|
+
_context7.prev = 32;
|
|
533
|
+
_context7.next = 35;
|
|
292
534
|
return (_this$store$order = this.store.order) === null || _this$store$order === void 0 ? void 0 : _this$store$order.recalculateSummary({
|
|
293
535
|
createIfMissing: false
|
|
294
536
|
});
|
|
295
|
-
case
|
|
537
|
+
case 35:
|
|
296
538
|
(_this$store$order2 = this.store.order) === null || _this$store$order2 === void 0 || _this$store$order2.persistTempOrder();
|
|
297
|
-
|
|
539
|
+
_context7.next = 38;
|
|
298
540
|
return this.loadRuntimeConfigs();
|
|
299
|
-
case
|
|
300
|
-
|
|
541
|
+
case 38:
|
|
542
|
+
if (!this.store.schedule) {
|
|
543
|
+
_context7.next = 47;
|
|
544
|
+
break;
|
|
545
|
+
}
|
|
546
|
+
_context7.prev = 39;
|
|
547
|
+
_context7.next = 42;
|
|
548
|
+
return this.store.schedule.loadAllSchedule();
|
|
549
|
+
case 42:
|
|
550
|
+
_context7.next = 47;
|
|
551
|
+
break;
|
|
552
|
+
case 44:
|
|
553
|
+
_context7.prev = 44;
|
|
554
|
+
_context7.t0 = _context7["catch"](39);
|
|
555
|
+
console.warn('[ScanOrder] loadAllSchedule 失败,operating_hours 判定将跳过', _context7.t0);
|
|
556
|
+
case 47:
|
|
557
|
+
_context7.next = 49;
|
|
301
558
|
return this.refreshItemRuleQuantityLimits();
|
|
302
|
-
case
|
|
559
|
+
case 49:
|
|
303
560
|
this.store.status = 'ready';
|
|
304
561
|
console.log('[ScanOrder] 初始化完成');
|
|
305
|
-
|
|
562
|
+
_context7.next = 53;
|
|
306
563
|
return this.core.effects.emit(ScanOrderHooks.onInited, {
|
|
307
564
|
status: this.store.status
|
|
308
565
|
});
|
|
309
|
-
case
|
|
566
|
+
case 53:
|
|
310
567
|
this.logMethodSuccess('initialize', {
|
|
311
568
|
status: this.store.status
|
|
312
569
|
});
|
|
313
|
-
|
|
570
|
+
_context7.next = 63;
|
|
314
571
|
break;
|
|
315
|
-
case
|
|
316
|
-
|
|
317
|
-
|
|
572
|
+
case 56:
|
|
573
|
+
_context7.prev = 56;
|
|
574
|
+
_context7.t1 = _context7["catch"](32);
|
|
318
575
|
this.store.status = 'error';
|
|
319
|
-
this.store.error =
|
|
320
|
-
console.error('[ScanOrder] 初始化失败',
|
|
321
|
-
this.logMethodError('initialize',
|
|
576
|
+
this.store.error = _context7.t1 instanceof Error ? _context7.t1.message : '初始化失败';
|
|
577
|
+
console.error('[ScanOrder] 初始化失败', _context7.t1);
|
|
578
|
+
this.logMethodError('initialize', _context7.t1, {
|
|
322
579
|
status: this.store.status
|
|
323
580
|
});
|
|
324
|
-
throw
|
|
325
|
-
case
|
|
581
|
+
throw _context7.t1;
|
|
582
|
+
case 63:
|
|
326
583
|
case "end":
|
|
327
|
-
return
|
|
584
|
+
return _context7.stop();
|
|
328
585
|
}
|
|
329
|
-
},
|
|
586
|
+
}, _callee7, this, [[32, 56], [39, 44]]);
|
|
330
587
|
}));
|
|
331
|
-
function initialize(
|
|
588
|
+
function initialize(_x5) {
|
|
332
589
|
return _initialize.apply(this, arguments);
|
|
333
590
|
}
|
|
334
591
|
return initialize;
|
|
@@ -336,21 +593,26 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
336
593
|
}, {
|
|
337
594
|
key: "destroy",
|
|
338
595
|
value: function () {
|
|
339
|
-
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
340
|
-
return _regeneratorRuntime().wrap(function
|
|
341
|
-
while (1) switch (
|
|
596
|
+
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
597
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
598
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
342
599
|
case 0:
|
|
343
600
|
this.logMethodStart('destroy');
|
|
344
|
-
|
|
601
|
+
this.clearLoginEffectListeners();
|
|
602
|
+
_context8.next = 4;
|
|
345
603
|
return this.core.effects.emit(ScanOrderHooks.onDestroy, {});
|
|
346
|
-
case
|
|
604
|
+
case 4:
|
|
605
|
+
_context8.next = 6;
|
|
606
|
+
return this.destroyRegisteredChildModules();
|
|
607
|
+
case 6:
|
|
608
|
+
_get(_getPrototypeOf(ScanOrderImpl.prototype), "destroy", this).call(this);
|
|
347
609
|
console.log('[ScanOrder] 已销毁');
|
|
348
610
|
this.logMethodSuccess('destroy');
|
|
349
|
-
case
|
|
611
|
+
case 9:
|
|
350
612
|
case "end":
|
|
351
|
-
return
|
|
613
|
+
return _context8.stop();
|
|
352
614
|
}
|
|
353
|
-
},
|
|
615
|
+
}, _callee8, this);
|
|
354
616
|
}));
|
|
355
617
|
function destroy() {
|
|
356
618
|
return _destroy.apply(this, arguments);
|
|
@@ -360,33 +622,33 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
360
622
|
}, {
|
|
361
623
|
key: "retryInit",
|
|
362
624
|
value: function () {
|
|
363
|
-
var _retryInit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
364
|
-
return _regeneratorRuntime().wrap(function
|
|
365
|
-
while (1) switch (
|
|
625
|
+
var _retryInit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
626
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
627
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
366
628
|
case 0:
|
|
367
629
|
this.logMethodStart('retryInit');
|
|
368
630
|
// TODO: 细化重试策略(指数退避、最大重试次数)后替换当前实现
|
|
369
631
|
console.log('[ScanOrder] retryInit 调用');
|
|
370
|
-
|
|
632
|
+
_context9.next = 4;
|
|
371
633
|
return this.core.effects.emit(ScanOrderHooks.onRetryInit, {});
|
|
372
634
|
case 4:
|
|
373
|
-
|
|
374
|
-
|
|
635
|
+
_context9.prev = 4;
|
|
636
|
+
_context9.next = 7;
|
|
375
637
|
return this.initialize(this.core, this.initializeOptions);
|
|
376
638
|
case 7:
|
|
377
639
|
this.logMethodSuccess('retryInit');
|
|
378
|
-
|
|
640
|
+
_context9.next = 14;
|
|
379
641
|
break;
|
|
380
642
|
case 10:
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
this.logMethodError('retryInit',
|
|
384
|
-
throw
|
|
643
|
+
_context9.prev = 10;
|
|
644
|
+
_context9.t0 = _context9["catch"](4);
|
|
645
|
+
this.logMethodError('retryInit', _context9.t0);
|
|
646
|
+
throw _context9.t0;
|
|
385
647
|
case 14:
|
|
386
648
|
case "end":
|
|
387
|
-
return
|
|
649
|
+
return _context9.stop();
|
|
388
650
|
}
|
|
389
|
-
},
|
|
651
|
+
}, _callee9, this, [[4, 10]]);
|
|
390
652
|
}));
|
|
391
653
|
function retryInit() {
|
|
392
654
|
return _retryInit.apply(this, arguments);
|
|
@@ -396,23 +658,23 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
396
658
|
}, {
|
|
397
659
|
key: "refresh",
|
|
398
660
|
value: function () {
|
|
399
|
-
var _refresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
400
|
-
return _regeneratorRuntime().wrap(function
|
|
401
|
-
while (1) switch (
|
|
661
|
+
var _refresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
662
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
663
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
402
664
|
case 0:
|
|
403
665
|
this.logMethodStart('refresh');
|
|
404
666
|
// TODO: 接入真实刷新逻辑(资源重拉取、流程重建)后替换当前实现
|
|
405
667
|
console.log('[ScanOrder] refresh 调用');
|
|
406
|
-
|
|
668
|
+
_context10.prev = 2;
|
|
407
669
|
this.store.status = 'initializing';
|
|
408
|
-
|
|
670
|
+
_context10.next = 6;
|
|
409
671
|
return this.loadRuntimeConfigs();
|
|
410
672
|
case 6:
|
|
411
|
-
|
|
673
|
+
_context10.next = 8;
|
|
412
674
|
return this.refreshItemRuleQuantityLimits();
|
|
413
675
|
case 8:
|
|
414
676
|
this.store.status = 'ready';
|
|
415
|
-
|
|
677
|
+
_context10.next = 11;
|
|
416
678
|
return this.core.effects.emit(ScanOrderHooks.onRefresh, {
|
|
417
679
|
status: this.store.status
|
|
418
680
|
});
|
|
@@ -420,18 +682,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
420
682
|
this.logMethodSuccess('refresh', {
|
|
421
683
|
status: this.store.status
|
|
422
684
|
});
|
|
423
|
-
|
|
685
|
+
_context10.next = 18;
|
|
424
686
|
break;
|
|
425
687
|
case 14:
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
this.logMethodError('refresh',
|
|
429
|
-
throw
|
|
688
|
+
_context10.prev = 14;
|
|
689
|
+
_context10.t0 = _context10["catch"](2);
|
|
690
|
+
this.logMethodError('refresh', _context10.t0);
|
|
691
|
+
throw _context10.t0;
|
|
430
692
|
case 18:
|
|
431
693
|
case "end":
|
|
432
|
-
return
|
|
694
|
+
return _context10.stop();
|
|
433
695
|
}
|
|
434
|
-
},
|
|
696
|
+
}, _callee10, this, [[2, 14]]);
|
|
435
697
|
}));
|
|
436
698
|
function refresh() {
|
|
437
699
|
return _refresh.apply(this, arguments);
|
|
@@ -534,6 +796,56 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
534
796
|
throw error;
|
|
535
797
|
}
|
|
536
798
|
}
|
|
799
|
+
|
|
800
|
+
// 存储 UI 层选择的取餐方式到 tempOrder.metadata.shop_service_data
|
|
801
|
+
// service_type 在扫码点餐场景固定为 dine_in
|
|
802
|
+
}, {
|
|
803
|
+
key: "setPickupReferenceMode",
|
|
804
|
+
value: function setPickupReferenceMode(mode) {
|
|
805
|
+
this.logMethodStart('setPickupReferenceMode', {
|
|
806
|
+
mode: mode
|
|
807
|
+
});
|
|
808
|
+
try {
|
|
809
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
810
|
+
var tempOrder = this.store.order.ensureTempOrder();
|
|
811
|
+
tempOrder.metadata = _objectSpread(_objectSpread({}, tempOrder.metadata || {}), {}, {
|
|
812
|
+
shop_service_data: _objectSpread(_objectSpread({}, (tempOrder.metadata || {}).shop_service_data || {}), {}, {
|
|
813
|
+
service_type: 'dine_in',
|
|
814
|
+
pickup_reference_mode: mode
|
|
815
|
+
})
|
|
816
|
+
});
|
|
817
|
+
this.store.order.persistTempOrder();
|
|
818
|
+
this.logMethodSuccess('setPickupReferenceMode', {
|
|
819
|
+
mode: mode
|
|
820
|
+
});
|
|
821
|
+
return tempOrder.metadata.shop_service_data;
|
|
822
|
+
} catch (error) {
|
|
823
|
+
this.logMethodError('setPickupReferenceMode', error, {
|
|
824
|
+
mode: mode
|
|
825
|
+
});
|
|
826
|
+
throw error;
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
// 存储用户自定义取餐标识到 tempOrder.buzzer
|
|
831
|
+
}, {
|
|
832
|
+
key: "setPickupRef",
|
|
833
|
+
value: function setPickupRef(buzzer) {
|
|
834
|
+
this.logMethodStart('setPickupRef', {
|
|
835
|
+
buzzerLength: String(buzzer || '').length
|
|
836
|
+
});
|
|
837
|
+
try {
|
|
838
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
839
|
+
var result = this.store.order.updateTempOrderBuzzer(buzzer);
|
|
840
|
+
this.logMethodSuccess('setPickupRef', {
|
|
841
|
+
buzzerLength: result.length
|
|
842
|
+
});
|
|
843
|
+
return result;
|
|
844
|
+
} catch (error) {
|
|
845
|
+
this.logMethodError('setPickupRef', error);
|
|
846
|
+
throw error;
|
|
847
|
+
}
|
|
848
|
+
}
|
|
537
849
|
}, {
|
|
538
850
|
key: "ensureTempOrder",
|
|
539
851
|
value: function ensureTempOrder() {
|
|
@@ -545,42 +857,81 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
545
857
|
}, {
|
|
546
858
|
key: "addNewOrder",
|
|
547
859
|
value: function () {
|
|
548
|
-
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
860
|
+
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
549
861
|
var tempOrder;
|
|
550
|
-
return _regeneratorRuntime().wrap(function
|
|
551
|
-
while (1) switch (
|
|
862
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
863
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
552
864
|
case 0:
|
|
553
865
|
this.logMethodStart('addNewOrder');
|
|
554
|
-
|
|
866
|
+
_context11.prev = 1;
|
|
555
867
|
if (this.store.order) {
|
|
556
|
-
|
|
868
|
+
_context11.next = 4;
|
|
557
869
|
break;
|
|
558
870
|
}
|
|
559
871
|
throw new Error('order 模块未初始化');
|
|
560
872
|
case 4:
|
|
561
|
-
|
|
873
|
+
_context11.next = 6;
|
|
562
874
|
return this.store.order.addNewOrder();
|
|
563
875
|
case 6:
|
|
564
|
-
tempOrder =
|
|
876
|
+
tempOrder = _context11.sent;
|
|
565
877
|
this.logMethodSuccess('addNewOrder', {
|
|
566
878
|
productCount: tempOrder.products.length
|
|
567
879
|
});
|
|
568
|
-
return
|
|
880
|
+
return _context11.abrupt("return", tempOrder);
|
|
569
881
|
case 11:
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
this.logMethodError('addNewOrder',
|
|
573
|
-
throw
|
|
882
|
+
_context11.prev = 11;
|
|
883
|
+
_context11.t0 = _context11["catch"](1);
|
|
884
|
+
this.logMethodError('addNewOrder', _context11.t0);
|
|
885
|
+
throw _context11.t0;
|
|
574
886
|
case 15:
|
|
575
887
|
case "end":
|
|
576
|
-
return
|
|
888
|
+
return _context11.stop();
|
|
577
889
|
}
|
|
578
|
-
},
|
|
890
|
+
}, _callee11, this, [[1, 11]]);
|
|
579
891
|
}));
|
|
580
892
|
function addNewOrder() {
|
|
581
893
|
return _addNewOrder.apply(this, arguments);
|
|
582
894
|
}
|
|
583
895
|
return addNewOrder;
|
|
896
|
+
}() // 重置 tempOrder 与与上一单强相关的运行态(resource/entryPaxNumber/enabledReservationRuleProducts),
|
|
897
|
+
// 适用于从支付页通过 react-router 跳回继续下单时清理残留数据
|
|
898
|
+
}, {
|
|
899
|
+
key: "restoreOrder",
|
|
900
|
+
value: function () {
|
|
901
|
+
var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
902
|
+
var tempOrder;
|
|
903
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
904
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
905
|
+
case 0:
|
|
906
|
+
this.logMethodStart('restoreOrder');
|
|
907
|
+
_context12.prev = 1;
|
|
908
|
+
if (this.store.order) {
|
|
909
|
+
_context12.next = 4;
|
|
910
|
+
break;
|
|
911
|
+
}
|
|
912
|
+
throw new Error('scanOrder 解决方案需要 order 模块支持');
|
|
913
|
+
case 4:
|
|
914
|
+
this.store.resource = null;
|
|
915
|
+
this.store.entryPaxNumber = 1;
|
|
916
|
+
this.enabledReservationRuleProducts = [];
|
|
917
|
+
tempOrder = this.store.order.restoreOrder();
|
|
918
|
+
this.logMethodSuccess('restoreOrder');
|
|
919
|
+
return _context12.abrupt("return", tempOrder);
|
|
920
|
+
case 12:
|
|
921
|
+
_context12.prev = 12;
|
|
922
|
+
_context12.t0 = _context12["catch"](1);
|
|
923
|
+
this.logMethodError('restoreOrder', _context12.t0);
|
|
924
|
+
throw _context12.t0;
|
|
925
|
+
case 16:
|
|
926
|
+
case "end":
|
|
927
|
+
return _context12.stop();
|
|
928
|
+
}
|
|
929
|
+
}, _callee12, this, [[1, 12]]);
|
|
930
|
+
}));
|
|
931
|
+
function restoreOrder() {
|
|
932
|
+
return _restoreOrder.apply(this, arguments);
|
|
933
|
+
}
|
|
934
|
+
return restoreOrder;
|
|
584
935
|
}()
|
|
585
936
|
}, {
|
|
586
937
|
key: "getOrderProducts",
|
|
@@ -596,58 +947,423 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
596
947
|
}, {
|
|
597
948
|
key: "getSummary",
|
|
598
949
|
value: function () {
|
|
599
|
-
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
950
|
+
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
600
951
|
var summary;
|
|
601
|
-
return _regeneratorRuntime().wrap(function
|
|
602
|
-
while (1) switch (
|
|
952
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
953
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
603
954
|
case 0:
|
|
604
955
|
this.logMethodStart('getSummary');
|
|
605
|
-
|
|
956
|
+
_context13.prev = 1;
|
|
606
957
|
if (this.store.order) {
|
|
607
|
-
|
|
958
|
+
_context13.next = 4;
|
|
608
959
|
break;
|
|
609
960
|
}
|
|
610
961
|
throw new Error('order 模块未初始化');
|
|
611
962
|
case 4:
|
|
612
|
-
|
|
963
|
+
_context13.next = 6;
|
|
613
964
|
return this.store.order.getScanOrderSummary();
|
|
614
965
|
case 6:
|
|
615
|
-
summary =
|
|
966
|
+
summary = _context13.sent;
|
|
616
967
|
this.logMethodSuccess('getSummary', {
|
|
617
968
|
totalAmount: summary.total_amount
|
|
618
969
|
});
|
|
619
|
-
return
|
|
970
|
+
return _context13.abrupt("return", summary);
|
|
620
971
|
case 11:
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
this.logMethodError('getSummary',
|
|
624
|
-
throw
|
|
972
|
+
_context13.prev = 11;
|
|
973
|
+
_context13.t0 = _context13["catch"](1);
|
|
974
|
+
this.logMethodError('getSummary', _context13.t0);
|
|
975
|
+
throw _context13.t0;
|
|
625
976
|
case 15:
|
|
626
977
|
case "end":
|
|
627
|
-
return
|
|
978
|
+
return _context13.stop();
|
|
628
979
|
}
|
|
629
|
-
},
|
|
980
|
+
}, _callee13, this, [[1, 11]]);
|
|
630
981
|
}));
|
|
631
982
|
function getSummary() {
|
|
632
983
|
return _getSummary.apply(this, arguments);
|
|
633
984
|
}
|
|
634
985
|
return getSummary;
|
|
635
986
|
}()
|
|
987
|
+
}, {
|
|
988
|
+
key: "getDiscountList",
|
|
989
|
+
value: function getDiscountList() {
|
|
990
|
+
if (!this.store.order) return [];
|
|
991
|
+
return this.store.order.getDiscountList();
|
|
992
|
+
}
|
|
993
|
+
}, {
|
|
994
|
+
key: "scanCode",
|
|
995
|
+
value: function () {
|
|
996
|
+
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(code, customerId) {
|
|
997
|
+
var raw;
|
|
998
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
999
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1000
|
+
case 0:
|
|
1001
|
+
this.logMethodStart('scanCode', {
|
|
1002
|
+
code: code
|
|
1003
|
+
});
|
|
1004
|
+
_context14.prev = 1;
|
|
1005
|
+
if (this.store.order) {
|
|
1006
|
+
_context14.next = 4;
|
|
1007
|
+
break;
|
|
1008
|
+
}
|
|
1009
|
+
throw new Error('order 模块未初始化');
|
|
1010
|
+
case 4:
|
|
1011
|
+
_context14.next = 6;
|
|
1012
|
+
return this.store.order.scanCode(code, customerId);
|
|
1013
|
+
case 6:
|
|
1014
|
+
raw = _context14.sent;
|
|
1015
|
+
if (!raw.isAvailable) {
|
|
1016
|
+
_context14.next = 11;
|
|
1017
|
+
break;
|
|
1018
|
+
}
|
|
1019
|
+
_context14.next = 10;
|
|
1020
|
+
return this.store.order.recalculateSummary({
|
|
1021
|
+
createIfMissing: true
|
|
1022
|
+
});
|
|
1023
|
+
case 10:
|
|
1024
|
+
this.store.order.persistTempOrder();
|
|
1025
|
+
case 11:
|
|
1026
|
+
this.logMethodSuccess('scanCode', {
|
|
1027
|
+
isAvailable: raw.isAvailable
|
|
1028
|
+
});
|
|
1029
|
+
return _context14.abrupt("return", {
|
|
1030
|
+
isAvailable: raw.isAvailable,
|
|
1031
|
+
type: raw.type,
|
|
1032
|
+
unavailableReason: raw.unavailableReason
|
|
1033
|
+
});
|
|
1034
|
+
case 15:
|
|
1035
|
+
_context14.prev = 15;
|
|
1036
|
+
_context14.t0 = _context14["catch"](1);
|
|
1037
|
+
this.logMethodError('scanCode', _context14.t0);
|
|
1038
|
+
throw _context14.t0;
|
|
1039
|
+
case 19:
|
|
1040
|
+
case "end":
|
|
1041
|
+
return _context14.stop();
|
|
1042
|
+
}
|
|
1043
|
+
}, _callee14, this, [[1, 15]]);
|
|
1044
|
+
}));
|
|
1045
|
+
function scanCode(_x6, _x7) {
|
|
1046
|
+
return _scanCode.apply(this, arguments);
|
|
1047
|
+
}
|
|
1048
|
+
return scanCode;
|
|
1049
|
+
}()
|
|
1050
|
+
}, {
|
|
1051
|
+
key: "setDiscountSelected",
|
|
1052
|
+
value: function () {
|
|
1053
|
+
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
|
|
1054
|
+
var _tempOrder$holder, list, updated, tempOrder, orderStore, discountModule, rulesModule, holders, nextDiscountList, _tempOrder$holder2, result, beforeSelectedIds, _iterator2, _step2, d, selectedResourceIds, _iterator3, _step3, _product$_origin, _product$metadata$sou, _product$metadata, _product$metadata2, _product$original_pri, product, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
|
|
1055
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1056
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1057
|
+
case 0:
|
|
1058
|
+
this.logMethodStart('setDiscountSelected', params);
|
|
1059
|
+
_context15.prev = 1;
|
|
1060
|
+
if (this.store.order) {
|
|
1061
|
+
_context15.next = 4;
|
|
1062
|
+
break;
|
|
1063
|
+
}
|
|
1064
|
+
throw new Error('order 模块未初始化');
|
|
1065
|
+
case 4:
|
|
1066
|
+
list = this.store.order.getDiscountList();
|
|
1067
|
+
updated = list.map(function (d) {
|
|
1068
|
+
return d.id === params.discountId ? _objectSpread(_objectSpread({}, d), {}, {
|
|
1069
|
+
isSelected: params.isSelected,
|
|
1070
|
+
isManualSelect: !params.isSelected
|
|
1071
|
+
}) : d;
|
|
1072
|
+
});
|
|
1073
|
+
tempOrder = this.store.order.ensureTempOrder();
|
|
1074
|
+
orderStore = this.store.order.store || {};
|
|
1075
|
+
discountModule = orderStore.discount;
|
|
1076
|
+
rulesModule = orderStore.rules;
|
|
1077
|
+
holders = (_tempOrder$holder = tempOrder.holder) !== null && _tempOrder$holder !== void 0 && _tempOrder$holder.form_record_id ? [{
|
|
1078
|
+
form_record_id: tempOrder.holder.form_record_id
|
|
1079
|
+
}] : [];
|
|
1080
|
+
nextDiscountList = updated;
|
|
1081
|
+
_context15.next = 14;
|
|
1082
|
+
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(updated);
|
|
1083
|
+
case 14:
|
|
1084
|
+
if (rulesModule) {
|
|
1085
|
+
result = rulesModule.calcDiscount({
|
|
1086
|
+
productList: tempOrder.products,
|
|
1087
|
+
discountList: updated,
|
|
1088
|
+
holders: holders,
|
|
1089
|
+
isFormSubject: !!((_tempOrder$holder2 = tempOrder.holder) !== null && _tempOrder$holder2 !== void 0 && _tempOrder$holder2.type) && tempOrder.holder.type === 'form'
|
|
1090
|
+
}, {
|
|
1091
|
+
discountId: params.discountId,
|
|
1092
|
+
isSelected: params.isSelected
|
|
1093
|
+
}) || {
|
|
1094
|
+
productList: tempOrder.products,
|
|
1095
|
+
discountList: updated
|
|
1096
|
+
};
|
|
1097
|
+
if (result !== null && result !== void 0 && result.productList) {
|
|
1098
|
+
tempOrder.products = result.productList;
|
|
1099
|
+
}
|
|
1100
|
+
if (result !== null && result !== void 0 && result.discountList) {
|
|
1101
|
+
nextDiscountList = result.discountList;
|
|
1102
|
+
if (!params.isSelected) {
|
|
1103
|
+
beforeSelectedIds = new Set(updated.filter(function (d) {
|
|
1104
|
+
return d.isSelected;
|
|
1105
|
+
}).map(function (d) {
|
|
1106
|
+
return d.id;
|
|
1107
|
+
}));
|
|
1108
|
+
_iterator2 = _createForOfIteratorHelper(nextDiscountList);
|
|
1109
|
+
try {
|
|
1110
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
1111
|
+
d = _step2.value;
|
|
1112
|
+
if (d.isSelected && !beforeSelectedIds.has(d.id)) {
|
|
1113
|
+
d.isSelected = false;
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
} catch (err) {
|
|
1117
|
+
_iterator2.e(err);
|
|
1118
|
+
} finally {
|
|
1119
|
+
_iterator2.f();
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
selectedResourceIds = new Set(nextDiscountList.filter(function (d) {
|
|
1125
|
+
return d.isSelected;
|
|
1126
|
+
}).map(function (d) {
|
|
1127
|
+
return d.id;
|
|
1128
|
+
}));
|
|
1129
|
+
_iterator3 = _createForOfIteratorHelper(tempOrder.products);
|
|
1130
|
+
_context15.prev = 17;
|
|
1131
|
+
_iterator3.s();
|
|
1132
|
+
case 19:
|
|
1133
|
+
if ((_step3 = _iterator3.n()).done) {
|
|
1134
|
+
_context15.next = 33;
|
|
1135
|
+
break;
|
|
1136
|
+
}
|
|
1137
|
+
product = _step3.value;
|
|
1138
|
+
if (!((_product$_origin = product._origin) !== null && _product$_origin !== void 0 && _product$_origin.isManualDiscount)) {
|
|
1139
|
+
_context15.next = 23;
|
|
1140
|
+
break;
|
|
1141
|
+
}
|
|
1142
|
+
return _context15.abrupt("continue", 31);
|
|
1143
|
+
case 23:
|
|
1144
|
+
product.discount_list = (product.discount_list || []).filter(function (pd) {
|
|
1145
|
+
var _pd$discount$resource, _pd$discount;
|
|
1146
|
+
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;
|
|
1147
|
+
return rid != null && selectedResourceIds.has(rid);
|
|
1148
|
+
});
|
|
1149
|
+
|
|
1150
|
+
// 券作用于 source(不含 option、不含 bundle);算出新 source 折后价后补回 options
|
|
1151
|
+
// 写入含 option 的 main_product_selling_price,再合成 composite 回写 selling_price。
|
|
1152
|
+
totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
|
|
1153
|
+
return sum + (pd.amount || 0);
|
|
1154
|
+
}, 0);
|
|
1155
|
+
optionSum = sumOptionUnitPrice(product.product_option_item);
|
|
1156
|
+
sourcePrice = (_product$metadata$sou = (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.source_product_price) !== null && _product$metadata$sou !== void 0 ? _product$metadata$sou : ((_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.main_product_original_price) != null ? new Decimal(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : (_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : '0';
|
|
1157
|
+
newSourceSellingPrice = new Decimal(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
1158
|
+
newMainSellingPrice = new Decimal(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
1159
|
+
if (product.metadata) {
|
|
1160
|
+
product.metadata.main_product_selling_price = newMainSellingPrice;
|
|
1161
|
+
product.metadata.price_schema_version = 2;
|
|
1162
|
+
}
|
|
1163
|
+
product.selling_price = composeLinePrice({
|
|
1164
|
+
mainPrice: newMainSellingPrice,
|
|
1165
|
+
bundle: product.product_bundle
|
|
1166
|
+
});
|
|
1167
|
+
case 31:
|
|
1168
|
+
_context15.next = 19;
|
|
1169
|
+
break;
|
|
1170
|
+
case 33:
|
|
1171
|
+
_context15.next = 38;
|
|
1172
|
+
break;
|
|
1173
|
+
case 35:
|
|
1174
|
+
_context15.prev = 35;
|
|
1175
|
+
_context15.t0 = _context15["catch"](17);
|
|
1176
|
+
_iterator3.e(_context15.t0);
|
|
1177
|
+
case 38:
|
|
1178
|
+
_context15.prev = 38;
|
|
1179
|
+
_iterator3.f();
|
|
1180
|
+
return _context15.finish(38);
|
|
1181
|
+
case 41:
|
|
1182
|
+
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
1183
|
+
_context15.next = 44;
|
|
1184
|
+
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
1185
|
+
case 44:
|
|
1186
|
+
tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
|
|
1187
|
+
return d.isSelected;
|
|
1188
|
+
});
|
|
1189
|
+
_context15.next = 47;
|
|
1190
|
+
return this.store.order.recalculateSummary({
|
|
1191
|
+
createIfMissing: true
|
|
1192
|
+
});
|
|
1193
|
+
case 47:
|
|
1194
|
+
this.store.order.persistTempOrder();
|
|
1195
|
+
this.logMethodSuccess('setDiscountSelected', params);
|
|
1196
|
+
_context15.next = 55;
|
|
1197
|
+
break;
|
|
1198
|
+
case 51:
|
|
1199
|
+
_context15.prev = 51;
|
|
1200
|
+
_context15.t1 = _context15["catch"](1);
|
|
1201
|
+
this.logMethodError('setDiscountSelected', _context15.t1);
|
|
1202
|
+
throw _context15.t1;
|
|
1203
|
+
case 55:
|
|
1204
|
+
case "end":
|
|
1205
|
+
return _context15.stop();
|
|
1206
|
+
}
|
|
1207
|
+
}, _callee15, this, [[1, 51], [17, 35, 38, 41]]);
|
|
1208
|
+
}));
|
|
1209
|
+
function setDiscountSelected(_x8) {
|
|
1210
|
+
return _setDiscountSelected.apply(this, arguments);
|
|
1211
|
+
}
|
|
1212
|
+
return setDiscountSelected;
|
|
1213
|
+
}()
|
|
1214
|
+
}, {
|
|
1215
|
+
key: "onCustomerLogin",
|
|
1216
|
+
value: function () {
|
|
1217
|
+
var _onCustomerLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(params) {
|
|
1218
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1219
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1220
|
+
case 0:
|
|
1221
|
+
this.logMethodStart('onCustomerLogin', {
|
|
1222
|
+
customerId: params.customerId
|
|
1223
|
+
});
|
|
1224
|
+
_context16.prev = 1;
|
|
1225
|
+
_context16.next = 4;
|
|
1226
|
+
return this.refreshOrderMarketingAfterLogin({
|
|
1227
|
+
customerId: params.customerId
|
|
1228
|
+
});
|
|
1229
|
+
case 4:
|
|
1230
|
+
this.logMethodSuccess('onCustomerLogin', {
|
|
1231
|
+
customerId: params.customerId
|
|
1232
|
+
});
|
|
1233
|
+
_context16.next = 11;
|
|
1234
|
+
break;
|
|
1235
|
+
case 7:
|
|
1236
|
+
_context16.prev = 7;
|
|
1237
|
+
_context16.t0 = _context16["catch"](1);
|
|
1238
|
+
this.logMethodError('onCustomerLogin', _context16.t0);
|
|
1239
|
+
throw _context16.t0;
|
|
1240
|
+
case 11:
|
|
1241
|
+
case "end":
|
|
1242
|
+
return _context16.stop();
|
|
1243
|
+
}
|
|
1244
|
+
}, _callee16, this, [[1, 7]]);
|
|
1245
|
+
}));
|
|
1246
|
+
function onCustomerLogin(_x9) {
|
|
1247
|
+
return _onCustomerLogin.apply(this, arguments);
|
|
1248
|
+
}
|
|
1249
|
+
return onCustomerLogin;
|
|
1250
|
+
}() // ScanOrder 提交 payload enhancer:
|
|
1251
|
+
// - 给所有 booking 注入 appointment_status: 'started'(扫码点餐语义)
|
|
1252
|
+
// - 给所有 booking 的 metadata 注入 resource_select_type(来自预约规则商品的 resource.type)
|
|
1253
|
+
// - 给第一条 booking 补 resources 与 product_uid(仅当存在 resource / rule product)
|
|
1254
|
+
// - 追加一条 is_rule=true 的 rule product,与 booking 互相关联
|
|
1255
|
+
}, {
|
|
1256
|
+
key: "buildSubmitPayloadEnhancer",
|
|
1257
|
+
value: function buildSubmitPayloadEnhancer() {
|
|
1258
|
+
var _this5 = this;
|
|
1259
|
+
var ruleProduct = this.enabledReservationRuleProducts[0];
|
|
1260
|
+
var resourceState = this.store.resource;
|
|
1261
|
+
var resourceSelectType = resourceState === null || resourceState === void 0 ? void 0 : resourceState.resourceSelectType;
|
|
1262
|
+
|
|
1263
|
+
// single 预约独占整张桌台,capacity 取 form_record.capacity;其他情况(multiple / capacity / undefined)占 1 个容量位
|
|
1264
|
+
var resolveResourceCapacity = function resolveResourceCapacity() {
|
|
1265
|
+
if (resourceSelectType === 'single') {
|
|
1266
|
+
var _resourceState$table_;
|
|
1267
|
+
var raw = resourceState === null || resourceState === void 0 || (_resourceState$table_ = resourceState.table_form_record) === null || _resourceState$table_ === void 0 ? void 0 : _resourceState$table_.capacity;
|
|
1268
|
+
var num = Number(raw);
|
|
1269
|
+
if (Number.isFinite(num) && num > 0) return num;
|
|
1270
|
+
return 1;
|
|
1271
|
+
}
|
|
1272
|
+
return 1;
|
|
1273
|
+
};
|
|
1274
|
+
return function (payload, _ref3) {
|
|
1275
|
+
var _tempOrder$resource_i, _ref4, _pickOriginal, _resourceState$table_2, _resourceState$relati, _tempOrder$metadata, _pickFirstCustomCapac;
|
|
1276
|
+
var bookingUuid = _ref3.bookingUuid,
|
|
1277
|
+
tempOrder = _ref3.tempOrder;
|
|
1278
|
+
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;
|
|
1279
|
+
var pickOriginal = function pickOriginal(value) {
|
|
1280
|
+
if (value && _typeof(value) === 'object' && !Array.isArray(value)) {
|
|
1281
|
+
var original = value.original;
|
|
1282
|
+
return typeof original === 'string' && original.length > 0 ? original : undefined;
|
|
1283
|
+
}
|
|
1284
|
+
return undefined;
|
|
1285
|
+
};
|
|
1286
|
+
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 : '';
|
|
1287
|
+
var resourceEntry = resourceState && resourceId ? {
|
|
1288
|
+
relation_type: 'form',
|
|
1289
|
+
like_status: 'common',
|
|
1290
|
+
id: Number(resourceId),
|
|
1291
|
+
main_field: mainField,
|
|
1292
|
+
form_id: resourceState.tableFormId,
|
|
1293
|
+
relation_id: (_resourceState$relati = resourceState.relationId) !== null && _resourceState$relati !== void 0 ? _resourceState$relati : resourceId,
|
|
1294
|
+
capacity: resolveResourceCapacity(),
|
|
1295
|
+
metadata: {}
|
|
1296
|
+
} : undefined;
|
|
1297
|
+
var ruleProductUid = ruleProduct ? createUuidV4() : undefined;
|
|
1298
|
+
// 默认 resolveResourceCapacity(single 为桌台容量,其余多为 1);有 collect_pax 时 value 优先用人数
|
|
1299
|
+
var rawCollectPax = (_tempOrder$metadata = tempOrder.metadata) === null || _tempOrder$metadata === void 0 ? void 0 : _tempOrder$metadata.collect_pax;
|
|
1300
|
+
var hasCollectPaxForCapacity = rawCollectPax !== null && rawCollectPax !== undefined && rawCollectPax !== '';
|
|
1301
|
+
var bookingCapacityValue = hasCollectPaxForCapacity ? normalizeSubmitCollectPaxValue(rawCollectPax) : resolveResourceCapacity();
|
|
1302
|
+
var bookingCapacityDimensionId = (_pickFirstCustomCapac = pickFirstCustomCapacityDimensionId(_this5.enabledReservationRuleProducts)) !== null && _pickFirstCustomCapac !== void 0 ? _pickFirstCustomCapac : 0;
|
|
1303
|
+
var nextBookings = (payload.bookings || []).map(function (booking, idx) {
|
|
1304
|
+
return _objectSpread(_objectSpread(_objectSpread({}, booking), {}, {
|
|
1305
|
+
appointment_status: 'started',
|
|
1306
|
+
metadata: _objectSpread(_objectSpread(_objectSpread({}, booking.metadata || {}), resourceSelectType ? {
|
|
1307
|
+
resource_select_type: resourceSelectType
|
|
1308
|
+
} : {}), resourceSelectType ? {
|
|
1309
|
+
capacity: [{
|
|
1310
|
+
id: bookingCapacityDimensionId,
|
|
1311
|
+
value: bookingCapacityValue,
|
|
1312
|
+
name: ''
|
|
1313
|
+
}]
|
|
1314
|
+
} : {})
|
|
1315
|
+
}, idx === 0 && resourceEntry ? {
|
|
1316
|
+
resources: [resourceEntry]
|
|
1317
|
+
} : {}), idx === 0 && ruleProductUid ? {
|
|
1318
|
+
product_uid: ruleProductUid
|
|
1319
|
+
} : {});
|
|
1320
|
+
});
|
|
1321
|
+
var nextProducts = _toConsumableArray(payload.products || []);
|
|
1322
|
+
// 加餐(已有 order_id)走 scanOrderMore,原单已含 booking 规则行,勿再追加虚拟规则商品
|
|
1323
|
+
if (ruleProduct && ruleProductUid && !tempOrder.order_id) {
|
|
1324
|
+
var _ruleProduct$price, _ref5, _ruleProduct$original, _ruleProduct$is_gst;
|
|
1325
|
+
var sellingPrice = String((_ruleProduct$price = ruleProduct.price) !== null && _ruleProduct$price !== void 0 ? _ruleProduct$price : '0.00');
|
|
1326
|
+
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');
|
|
1327
|
+
nextProducts.push({
|
|
1328
|
+
product_id: ruleProduct.id,
|
|
1329
|
+
product_variant_id: 0,
|
|
1330
|
+
num: 1,
|
|
1331
|
+
selling_price: sellingPrice,
|
|
1332
|
+
original_price: originalPrice,
|
|
1333
|
+
payment_price: sellingPrice,
|
|
1334
|
+
is_charge_tax: (_ruleProduct$is_gst = ruleProduct.is_gst) !== null && _ruleProduct$is_gst !== void 0 ? _ruleProduct$is_gst : 0,
|
|
1335
|
+
product_option_item: [],
|
|
1336
|
+
discount_list: [],
|
|
1337
|
+
product_bundle: [],
|
|
1338
|
+
booking_uid: bookingUuid,
|
|
1339
|
+
metadata: {
|
|
1340
|
+
is_rule: true,
|
|
1341
|
+
unique_identification_number: ruleProductUid,
|
|
1342
|
+
booking_uid: bookingUuid
|
|
1343
|
+
}
|
|
1344
|
+
});
|
|
1345
|
+
}
|
|
1346
|
+
return _objectSpread(_objectSpread({}, payload), {}, {
|
|
1347
|
+
bookings: nextBookings,
|
|
1348
|
+
products: nextProducts
|
|
1349
|
+
});
|
|
1350
|
+
};
|
|
1351
|
+
}
|
|
636
1352
|
}, {
|
|
637
1353
|
key: "submitScanOrder",
|
|
638
1354
|
value: function () {
|
|
639
|
-
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
640
|
-
var _this$otherParams4, _this$otherParams5, _this$otherParams6, _this$otherParams7, _tempOrder$products, pax, tempOrderForSubmit, result, tempOrder;
|
|
641
|
-
return _regeneratorRuntime().wrap(function
|
|
642
|
-
while (1) switch (
|
|
1355
|
+
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
1356
|
+
var _this$store$resource, _this$otherParams4, _this$otherParams5, _this$otherParams6, _this$otherParams7, _tempOrder$products, pax, tempOrderForSubmit, resourceTableName, enhancePayload, result, tempOrder;
|
|
1357
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1358
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
643
1359
|
case 0:
|
|
644
1360
|
this.logMethodStart('submitScanOrder');
|
|
645
|
-
|
|
646
|
-
|
|
1361
|
+
_context17.prev = 1;
|
|
1362
|
+
_context17.next = 4;
|
|
647
1363
|
return this.validateBeforeSubmitByItemRule();
|
|
648
1364
|
case 4:
|
|
649
1365
|
if (this.store.order) {
|
|
650
|
-
|
|
1366
|
+
_context17.next = 6;
|
|
651
1367
|
break;
|
|
652
1368
|
}
|
|
653
1369
|
throw new Error('scanOrder解决方案需要 order 模块支持');
|
|
@@ -658,32 +1374,41 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
658
1374
|
tempOrderForSubmit.metadata = _objectSpread(_objectSpread({}, tempOrderForSubmit.metadata), {}, {
|
|
659
1375
|
collect_pax: pax
|
|
660
1376
|
});
|
|
1377
|
+
tempOrderForSubmit.delivery_type = 'shop_service';
|
|
1378
|
+
resourceTableName = (_this$store$resource = this.store.resource) === null || _this$store$resource === void 0 || (_this$store$resource = _this$store$resource.table_form_record) === null || _this$store$resource === void 0 ? void 0 : _this$store$resource.name;
|
|
1379
|
+
if (resourceTableName && _typeof(resourceTableName) === 'object') {
|
|
1380
|
+
tempOrderForSubmit.table_number = resourceTableName;
|
|
1381
|
+
} else {
|
|
1382
|
+
delete tempOrderForSubmit.table_number;
|
|
1383
|
+
}
|
|
661
1384
|
this.store.order.persistTempOrder();
|
|
662
|
-
|
|
1385
|
+
enhancePayload = this.buildSubmitPayloadEnhancer();
|
|
1386
|
+
_context17.next = 17;
|
|
663
1387
|
return this.store.order.submitTempOrder({
|
|
664
1388
|
cacheId: this.cacheId,
|
|
665
1389
|
platform: (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.platform,
|
|
666
1390
|
businessCode: (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.businessCode,
|
|
667
1391
|
channel: (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.channel,
|
|
668
|
-
type: (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.type
|
|
1392
|
+
type: (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.type,
|
|
1393
|
+
enhancePayload: enhancePayload
|
|
669
1394
|
});
|
|
670
|
-
case
|
|
671
|
-
result =
|
|
1395
|
+
case 17:
|
|
1396
|
+
result = _context17.sent;
|
|
672
1397
|
tempOrder = this.store.order.getTempOrder();
|
|
673
1398
|
this.logMethodSuccess('submitScanOrder', {
|
|
674
1399
|
productCount: (tempOrder === null || tempOrder === void 0 || (_tempOrder$products = tempOrder.products) === null || _tempOrder$products === void 0 ? void 0 : _tempOrder$products.length) || 0
|
|
675
1400
|
});
|
|
676
|
-
return
|
|
677
|
-
case 19:
|
|
678
|
-
_context9.prev = 19;
|
|
679
|
-
_context9.t0 = _context9["catch"](1);
|
|
680
|
-
this.logMethodError('submitScanOrder', _context9.t0);
|
|
681
|
-
throw _context9.t0;
|
|
1401
|
+
return _context17.abrupt("return", result);
|
|
682
1402
|
case 23:
|
|
1403
|
+
_context17.prev = 23;
|
|
1404
|
+
_context17.t0 = _context17["catch"](1);
|
|
1405
|
+
this.logMethodError('submitScanOrder', _context17.t0);
|
|
1406
|
+
throw _context17.t0;
|
|
1407
|
+
case 27:
|
|
683
1408
|
case "end":
|
|
684
|
-
return
|
|
1409
|
+
return _context17.stop();
|
|
685
1410
|
}
|
|
686
|
-
},
|
|
1411
|
+
}, _callee17, this, [[1, 23]]);
|
|
687
1412
|
}));
|
|
688
1413
|
function submitScanOrder() {
|
|
689
1414
|
return _submitScanOrder.apply(this, arguments);
|
|
@@ -693,48 +1418,48 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
693
1418
|
}, {
|
|
694
1419
|
key: "addProductToOrder",
|
|
695
1420
|
value: function () {
|
|
696
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1421
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(product) {
|
|
697
1422
|
var products;
|
|
698
|
-
return _regeneratorRuntime().wrap(function
|
|
699
|
-
while (1) switch (
|
|
1423
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1424
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
700
1425
|
case 0:
|
|
701
1426
|
this.logMethodStart('addProductToOrder', {
|
|
702
1427
|
product_id: product.product_id,
|
|
703
1428
|
product_variant_id: product.product_variant_id
|
|
704
1429
|
});
|
|
705
|
-
|
|
1430
|
+
_context18.prev = 1;
|
|
706
1431
|
if (this.store.order) {
|
|
707
|
-
|
|
1432
|
+
_context18.next = 4;
|
|
708
1433
|
break;
|
|
709
1434
|
}
|
|
710
1435
|
throw new Error('order 模块未初始化');
|
|
711
1436
|
case 4:
|
|
712
|
-
|
|
1437
|
+
_context18.next = 6;
|
|
713
1438
|
return this.store.order.addProductToOrder(product);
|
|
714
1439
|
case 6:
|
|
715
|
-
products =
|
|
716
|
-
|
|
1440
|
+
products = _context18.sent;
|
|
1441
|
+
_context18.next = 9;
|
|
717
1442
|
return this.refreshItemRuleQuantityLimits();
|
|
718
1443
|
case 9:
|
|
719
|
-
|
|
1444
|
+
_context18.next = 11;
|
|
720
1445
|
return this.refreshCartValidationPassed();
|
|
721
1446
|
case 11:
|
|
722
1447
|
this.logMethodSuccess('addProductToOrder', {
|
|
723
1448
|
productCount: products.length
|
|
724
1449
|
});
|
|
725
|
-
return
|
|
1450
|
+
return _context18.abrupt("return", products);
|
|
726
1451
|
case 15:
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
this.logMethodError('addProductToOrder',
|
|
730
|
-
throw
|
|
1452
|
+
_context18.prev = 15;
|
|
1453
|
+
_context18.t0 = _context18["catch"](1);
|
|
1454
|
+
this.logMethodError('addProductToOrder', _context18.t0);
|
|
1455
|
+
throw _context18.t0;
|
|
731
1456
|
case 19:
|
|
732
1457
|
case "end":
|
|
733
|
-
return
|
|
1458
|
+
return _context18.stop();
|
|
734
1459
|
}
|
|
735
|
-
},
|
|
1460
|
+
}, _callee18, this, [[1, 15]]);
|
|
736
1461
|
}));
|
|
737
|
-
function addProductToOrder(
|
|
1462
|
+
function addProductToOrder(_x10) {
|
|
738
1463
|
return _addProductToOrder.apply(this, arguments);
|
|
739
1464
|
}
|
|
740
1465
|
return addProductToOrder;
|
|
@@ -742,97 +1467,150 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
742
1467
|
}, {
|
|
743
1468
|
key: "updateProductInOrder",
|
|
744
1469
|
value: function () {
|
|
745
|
-
var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1470
|
+
var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
|
|
746
1471
|
var products;
|
|
747
|
-
return _regeneratorRuntime().wrap(function
|
|
748
|
-
while (1) switch (
|
|
1472
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1473
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
749
1474
|
case 0:
|
|
750
1475
|
this.logMethodStart('updateProductInOrder', {
|
|
751
1476
|
product_id: params.product_id,
|
|
752
1477
|
product_variant_id: params.product_variant_id
|
|
753
1478
|
});
|
|
754
|
-
|
|
1479
|
+
_context19.prev = 1;
|
|
755
1480
|
if (this.store.order) {
|
|
756
|
-
|
|
1481
|
+
_context19.next = 4;
|
|
757
1482
|
break;
|
|
758
1483
|
}
|
|
759
1484
|
throw new Error('order 模块未初始化');
|
|
760
1485
|
case 4:
|
|
761
|
-
|
|
1486
|
+
_context19.next = 6;
|
|
762
1487
|
return this.store.order.updateProductInOrder(params);
|
|
763
1488
|
case 6:
|
|
764
|
-
products =
|
|
765
|
-
|
|
1489
|
+
products = _context19.sent;
|
|
1490
|
+
_context19.next = 9;
|
|
766
1491
|
return this.refreshItemRuleQuantityLimits();
|
|
767
1492
|
case 9:
|
|
768
|
-
|
|
1493
|
+
_context19.next = 11;
|
|
769
1494
|
return this.refreshCartValidationPassed();
|
|
770
1495
|
case 11:
|
|
771
1496
|
this.logMethodSuccess('updateProductInOrder', {
|
|
772
1497
|
productCount: products.length
|
|
773
1498
|
});
|
|
774
|
-
return
|
|
1499
|
+
return _context19.abrupt("return", products);
|
|
775
1500
|
case 15:
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
this.logMethodError('updateProductInOrder',
|
|
779
|
-
throw
|
|
1501
|
+
_context19.prev = 15;
|
|
1502
|
+
_context19.t0 = _context19["catch"](1);
|
|
1503
|
+
this.logMethodError('updateProductInOrder', _context19.t0);
|
|
1504
|
+
throw _context19.t0;
|
|
780
1505
|
case 19:
|
|
781
1506
|
case "end":
|
|
782
|
-
return
|
|
1507
|
+
return _context19.stop();
|
|
783
1508
|
}
|
|
784
|
-
},
|
|
1509
|
+
}, _callee19, this, [[1, 15]]);
|
|
785
1510
|
}));
|
|
786
|
-
function updateProductInOrder(
|
|
1511
|
+
function updateProductInOrder(_x11) {
|
|
787
1512
|
return _updateProductInOrder.apply(this, arguments);
|
|
788
1513
|
}
|
|
789
1514
|
return updateProductInOrder;
|
|
790
1515
|
}()
|
|
1516
|
+
/**
|
|
1517
|
+
* 设置单行商品备注(与整单 `updateTempOrderNote` 区分)。
|
|
1518
|
+
* 多行同 SKU 时必须传入与删除/更新一致的 identity(如 `identity_key`)。
|
|
1519
|
+
*/
|
|
1520
|
+
}, {
|
|
1521
|
+
key: "setOrderProductLineNote",
|
|
1522
|
+
value: (function () {
|
|
1523
|
+
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(identity, note) {
|
|
1524
|
+
var params, products;
|
|
1525
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1526
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1527
|
+
case 0:
|
|
1528
|
+
this.logMethodStart('setOrderProductLineNote', {
|
|
1529
|
+
product_id: identity.product_id,
|
|
1530
|
+
product_variant_id: identity.product_variant_id
|
|
1531
|
+
});
|
|
1532
|
+
_context20.prev = 1;
|
|
1533
|
+
params = {
|
|
1534
|
+
product_id: identity.product_id,
|
|
1535
|
+
product_variant_id: identity.product_variant_id,
|
|
1536
|
+
updates: {
|
|
1537
|
+
note: String(note || '')
|
|
1538
|
+
}
|
|
1539
|
+
};
|
|
1540
|
+
if (identity.identity_key !== undefined) params.identity_key = identity.identity_key;
|
|
1541
|
+
if (identity.product_option_item !== undefined) {
|
|
1542
|
+
params.product_option_item = identity.product_option_item;
|
|
1543
|
+
}
|
|
1544
|
+
if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
|
|
1545
|
+
_context20.next = 8;
|
|
1546
|
+
return this.updateProductInOrder(params);
|
|
1547
|
+
case 8:
|
|
1548
|
+
products = _context20.sent;
|
|
1549
|
+
this.logMethodSuccess('setOrderProductLineNote', {
|
|
1550
|
+
productCount: products.length
|
|
1551
|
+
});
|
|
1552
|
+
return _context20.abrupt("return", products);
|
|
1553
|
+
case 13:
|
|
1554
|
+
_context20.prev = 13;
|
|
1555
|
+
_context20.t0 = _context20["catch"](1);
|
|
1556
|
+
this.logMethodError('setOrderProductLineNote', _context20.t0);
|
|
1557
|
+
throw _context20.t0;
|
|
1558
|
+
case 17:
|
|
1559
|
+
case "end":
|
|
1560
|
+
return _context20.stop();
|
|
1561
|
+
}
|
|
1562
|
+
}, _callee20, this, [[1, 13]]);
|
|
1563
|
+
}));
|
|
1564
|
+
function setOrderProductLineNote(_x12, _x13) {
|
|
1565
|
+
return _setOrderProductLineNote.apply(this, arguments);
|
|
1566
|
+
}
|
|
1567
|
+
return setOrderProductLineNote;
|
|
1568
|
+
}())
|
|
791
1569
|
}, {
|
|
792
1570
|
key: "removeProductFromOrder",
|
|
793
1571
|
value: function () {
|
|
794
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1572
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(identity) {
|
|
795
1573
|
var products;
|
|
796
|
-
return _regeneratorRuntime().wrap(function
|
|
797
|
-
while (1) switch (
|
|
1574
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1575
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
798
1576
|
case 0:
|
|
799
1577
|
this.logMethodStart('removeProductFromOrder', {
|
|
800
1578
|
product_id: identity.product_id,
|
|
801
1579
|
product_variant_id: identity.product_variant_id
|
|
802
1580
|
});
|
|
803
|
-
|
|
1581
|
+
_context21.prev = 1;
|
|
804
1582
|
if (this.store.order) {
|
|
805
|
-
|
|
1583
|
+
_context21.next = 4;
|
|
806
1584
|
break;
|
|
807
1585
|
}
|
|
808
1586
|
throw new Error('order 模块未初始化');
|
|
809
1587
|
case 4:
|
|
810
|
-
|
|
1588
|
+
_context21.next = 6;
|
|
811
1589
|
return this.store.order.removeProductFromOrder(identity);
|
|
812
1590
|
case 6:
|
|
813
|
-
products =
|
|
814
|
-
|
|
1591
|
+
products = _context21.sent;
|
|
1592
|
+
_context21.next = 9;
|
|
815
1593
|
return this.refreshItemRuleQuantityLimits();
|
|
816
1594
|
case 9:
|
|
817
|
-
|
|
1595
|
+
_context21.next = 11;
|
|
818
1596
|
return this.refreshCartValidationPassed();
|
|
819
1597
|
case 11:
|
|
820
1598
|
this.logMethodSuccess('removeProductFromOrder', {
|
|
821
1599
|
productCount: products.length
|
|
822
1600
|
});
|
|
823
|
-
return
|
|
1601
|
+
return _context21.abrupt("return", products);
|
|
824
1602
|
case 15:
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
this.logMethodError('removeProductFromOrder',
|
|
828
|
-
throw
|
|
1603
|
+
_context21.prev = 15;
|
|
1604
|
+
_context21.t0 = _context21["catch"](1);
|
|
1605
|
+
this.logMethodError('removeProductFromOrder', _context21.t0);
|
|
1606
|
+
throw _context21.t0;
|
|
829
1607
|
case 19:
|
|
830
1608
|
case "end":
|
|
831
|
-
return
|
|
1609
|
+
return _context21.stop();
|
|
832
1610
|
}
|
|
833
|
-
},
|
|
1611
|
+
}, _callee21, this, [[1, 15]]);
|
|
834
1612
|
}));
|
|
835
|
-
function removeProductFromOrder(
|
|
1613
|
+
function removeProductFromOrder(_x14) {
|
|
836
1614
|
return _removeProductFromOrder.apply(this, arguments);
|
|
837
1615
|
}
|
|
838
1616
|
return removeProductFromOrder;
|
|
@@ -840,26 +1618,26 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
840
1618
|
}, {
|
|
841
1619
|
key: "loadRuntimeConfigs",
|
|
842
1620
|
value: function () {
|
|
843
|
-
var _loadRuntimeConfigs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1621
|
+
var _loadRuntimeConfigs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
|
|
844
1622
|
var itemRuleConfigs;
|
|
845
|
-
return _regeneratorRuntime().wrap(function
|
|
846
|
-
while (1) switch (
|
|
1623
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
1624
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
847
1625
|
case 0:
|
|
848
|
-
|
|
1626
|
+
_context22.next = 2;
|
|
849
1627
|
return this.ensureItemRuleConfigsLoaded();
|
|
850
1628
|
case 2:
|
|
851
|
-
itemRuleConfigs =
|
|
1629
|
+
itemRuleConfigs = _context22.sent;
|
|
852
1630
|
this.logMethodSuccess('loadRuntimeConfigs', {
|
|
853
1631
|
itemRuleCount: itemRuleConfigs.length
|
|
854
1632
|
});
|
|
855
|
-
return
|
|
1633
|
+
return _context22.abrupt("return", {
|
|
856
1634
|
itemRuleConfigs: itemRuleConfigs
|
|
857
1635
|
});
|
|
858
1636
|
case 5:
|
|
859
1637
|
case "end":
|
|
860
|
-
return
|
|
1638
|
+
return _context22.stop();
|
|
861
1639
|
}
|
|
862
|
-
},
|
|
1640
|
+
}, _callee22, this);
|
|
863
1641
|
}));
|
|
864
1642
|
function loadRuntimeConfigs() {
|
|
865
1643
|
return _loadRuntimeConfigs.apply(this, arguments);
|
|
@@ -869,15 +1647,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
869
1647
|
}, {
|
|
870
1648
|
key: "syncItemRuleConfigsFromDineInConfig",
|
|
871
1649
|
value: function () {
|
|
872
|
-
var _syncItemRuleConfigsFromDineInConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1650
|
+
var _syncItemRuleConfigsFromDineInConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(dineInConfig) {
|
|
873
1651
|
var enableItemRules, strategyModelIds, itemRuleConfigs;
|
|
874
|
-
return _regeneratorRuntime().wrap(function
|
|
875
|
-
while (1) switch (
|
|
1652
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
1653
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
876
1654
|
case 0:
|
|
877
1655
|
enableItemRules = toBoolean(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['sale.enable_item_rules']);
|
|
878
1656
|
strategyModelIds = normalizeEnabledItemRuleIds(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['sale.enabled_item_rules']);
|
|
879
1657
|
if (!(!enableItemRules || !strategyModelIds.length)) {
|
|
880
|
-
|
|
1658
|
+
_context23.next = 8;
|
|
881
1659
|
break;
|
|
882
1660
|
}
|
|
883
1661
|
this.itemRuleConfigs = [];
|
|
@@ -888,12 +1666,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
888
1666
|
strategyModelIds: [],
|
|
889
1667
|
itemRuleCount: 0
|
|
890
1668
|
});
|
|
891
|
-
return
|
|
1669
|
+
return _context23.abrupt("return", []);
|
|
892
1670
|
case 8:
|
|
893
|
-
|
|
1671
|
+
_context23.next = 10;
|
|
894
1672
|
return this.fetchItemRuleConfigsByModelIds(strategyModelIds);
|
|
895
1673
|
case 10:
|
|
896
|
-
itemRuleConfigs =
|
|
1674
|
+
itemRuleConfigs = _context23.sent;
|
|
897
1675
|
this.itemRuleConfigs = itemRuleConfigs;
|
|
898
1676
|
this.itemRuleConfigsPromise = Promise.resolve(itemRuleConfigs);
|
|
899
1677
|
this.itemRuleEvaluator.setStrategyConfigs(itemRuleConfigs);
|
|
@@ -902,14 +1680,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
902
1680
|
strategyModelIds: strategyModelIds,
|
|
903
1681
|
itemRuleCount: itemRuleConfigs.length
|
|
904
1682
|
});
|
|
905
|
-
return
|
|
1683
|
+
return _context23.abrupt("return", itemRuleConfigs);
|
|
906
1684
|
case 16:
|
|
907
1685
|
case "end":
|
|
908
|
-
return
|
|
1686
|
+
return _context23.stop();
|
|
909
1687
|
}
|
|
910
|
-
},
|
|
1688
|
+
}, _callee23, this);
|
|
911
1689
|
}));
|
|
912
|
-
function syncItemRuleConfigsFromDineInConfig(
|
|
1690
|
+
function syncItemRuleConfigsFromDineInConfig(_x15) {
|
|
913
1691
|
return _syncItemRuleConfigsFromDineInConfig.apply(this, arguments);
|
|
914
1692
|
}
|
|
915
1693
|
return syncItemRuleConfigsFromDineInConfig;
|
|
@@ -917,22 +1695,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
917
1695
|
}, {
|
|
918
1696
|
key: "fetchItemRuleConfigsByModelIds",
|
|
919
1697
|
value: function () {
|
|
920
|
-
var _fetchItemRuleConfigsByModelIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1698
|
+
var _fetchItemRuleConfigsByModelIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(strategyModelIds) {
|
|
921
1699
|
var result, configs;
|
|
922
|
-
return _regeneratorRuntime().wrap(function
|
|
923
|
-
while (1) switch (
|
|
1700
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
1701
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
924
1702
|
case 0:
|
|
925
1703
|
this.logMethodStart('fetchItemRuleConfigsByModelIds', {
|
|
926
1704
|
strategyModelIds: strategyModelIds
|
|
927
1705
|
});
|
|
928
1706
|
if (strategyModelIds.length) {
|
|
929
|
-
|
|
1707
|
+
_context24.next = 3;
|
|
930
1708
|
break;
|
|
931
1709
|
}
|
|
932
|
-
return
|
|
1710
|
+
return _context24.abrupt("return", []);
|
|
933
1711
|
case 3:
|
|
934
|
-
|
|
935
|
-
|
|
1712
|
+
_context24.prev = 3;
|
|
1713
|
+
_context24.next = 6;
|
|
936
1714
|
return this.request.get('/promotion', {
|
|
937
1715
|
skip: 1,
|
|
938
1716
|
num: 99,
|
|
@@ -940,7 +1718,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
940
1718
|
ids: strategyModelIds
|
|
941
1719
|
});
|
|
942
1720
|
case 6:
|
|
943
|
-
result =
|
|
1721
|
+
result = _context24.sent;
|
|
944
1722
|
configs = [];
|
|
945
1723
|
if (result.code === 200) {
|
|
946
1724
|
configs = result.data.list.map(function (item) {
|
|
@@ -951,22 +1729,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
951
1729
|
strategyModelIds: strategyModelIds,
|
|
952
1730
|
strategyCount: configs.length
|
|
953
1731
|
});
|
|
954
|
-
return
|
|
1732
|
+
return _context24.abrupt("return", configs);
|
|
955
1733
|
case 13:
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
this.logMethodError('fetchItemRuleConfigsByModelIds',
|
|
1734
|
+
_context24.prev = 13;
|
|
1735
|
+
_context24.t0 = _context24["catch"](3);
|
|
1736
|
+
this.logMethodError('fetchItemRuleConfigsByModelIds', _context24.t0, {
|
|
959
1737
|
strategyModelIds: strategyModelIds
|
|
960
1738
|
});
|
|
961
1739
|
// A:策略加载失败时不阻塞下单
|
|
962
|
-
return
|
|
1740
|
+
return _context24.abrupt("return", []);
|
|
963
1741
|
case 17:
|
|
964
1742
|
case "end":
|
|
965
|
-
return
|
|
1743
|
+
return _context24.stop();
|
|
966
1744
|
}
|
|
967
|
-
},
|
|
1745
|
+
}, _callee24, this, [[3, 13]]);
|
|
968
1746
|
}));
|
|
969
|
-
function fetchItemRuleConfigsByModelIds(
|
|
1747
|
+
function fetchItemRuleConfigsByModelIds(_x16) {
|
|
970
1748
|
return _fetchItemRuleConfigsByModelIds.apply(this, arguments);
|
|
971
1749
|
}
|
|
972
1750
|
return fetchItemRuleConfigsByModelIds;
|
|
@@ -974,22 +1752,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
974
1752
|
}, {
|
|
975
1753
|
key: "buildPrefillProductSourceMap",
|
|
976
1754
|
value: function () {
|
|
977
|
-
var _buildPrefillProductSourceMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1755
|
+
var _buildPrefillProductSourceMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
|
|
978
1756
|
var sourceMap, productList, visited, collectFromValue;
|
|
979
|
-
return _regeneratorRuntime().wrap(function
|
|
980
|
-
while (1) switch (
|
|
1757
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
1758
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
981
1759
|
case 0:
|
|
982
1760
|
sourceMap = new Map();
|
|
983
|
-
|
|
984
|
-
|
|
1761
|
+
_context25.prev = 1;
|
|
1762
|
+
_context25.next = 4;
|
|
985
1763
|
return this.getProductList();
|
|
986
1764
|
case 4:
|
|
987
|
-
productList =
|
|
1765
|
+
productList = _context25.sent;
|
|
988
1766
|
if (Array.isArray(productList)) {
|
|
989
|
-
|
|
1767
|
+
_context25.next = 7;
|
|
990
1768
|
break;
|
|
991
1769
|
}
|
|
992
|
-
return
|
|
1770
|
+
return _context25.abrupt("return", sourceMap);
|
|
993
1771
|
case 7:
|
|
994
1772
|
visited = new Set();
|
|
995
1773
|
collectFromValue = function collectFromValue(value) {
|
|
@@ -998,17 +1776,17 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
998
1776
|
if (visited.has(value)) return;
|
|
999
1777
|
visited.add(value);
|
|
1000
1778
|
if (Array.isArray(value)) {
|
|
1001
|
-
var
|
|
1002
|
-
|
|
1779
|
+
var _iterator4 = _createForOfIteratorHelper(value),
|
|
1780
|
+
_step4;
|
|
1003
1781
|
try {
|
|
1004
|
-
for (
|
|
1005
|
-
var item =
|
|
1782
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
1783
|
+
var item = _step4.value;
|
|
1006
1784
|
collectFromValue(item);
|
|
1007
1785
|
}
|
|
1008
1786
|
} catch (err) {
|
|
1009
|
-
|
|
1787
|
+
_iterator4.e(err);
|
|
1010
1788
|
} finally {
|
|
1011
|
-
|
|
1789
|
+
_iterator4.f();
|
|
1012
1790
|
}
|
|
1013
1791
|
return;
|
|
1014
1792
|
}
|
|
@@ -1016,35 +1794,35 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1016
1794
|
var rawProductId = (_node$product_id = node.product_id) !== null && _node$product_id !== void 0 ? _node$product_id : node.id;
|
|
1017
1795
|
var productId = Number(rawProductId);
|
|
1018
1796
|
if (Number.isFinite(productId) && productId > 0) {
|
|
1019
|
-
var
|
|
1020
|
-
var productVariantId = Number((
|
|
1797
|
+
var _ref6, _node$product_variant;
|
|
1798
|
+
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);
|
|
1021
1799
|
var normalizedVariantId = Number.isNaN(productVariantId) ? 0 : productVariantId;
|
|
1022
1800
|
var key = buildProductKey(productId, normalizedVariantId);
|
|
1023
1801
|
if (!sourceMap.has(key)) {
|
|
1024
1802
|
sourceMap.set(key, node);
|
|
1025
1803
|
}
|
|
1026
1804
|
}
|
|
1027
|
-
for (var
|
|
1028
|
-
var childValue = _Object$values[
|
|
1805
|
+
for (var _i3 = 0, _Object$values = Object.values(node); _i3 < _Object$values.length; _i3++) {
|
|
1806
|
+
var childValue = _Object$values[_i3];
|
|
1029
1807
|
if (childValue && _typeof(childValue) === 'object') {
|
|
1030
1808
|
collectFromValue(childValue);
|
|
1031
1809
|
}
|
|
1032
1810
|
}
|
|
1033
1811
|
};
|
|
1034
1812
|
collectFromValue(productList);
|
|
1035
|
-
|
|
1813
|
+
_context25.next = 15;
|
|
1036
1814
|
break;
|
|
1037
1815
|
case 12:
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
this.logMethodError('buildPrefillProductSourceMap',
|
|
1816
|
+
_context25.prev = 12;
|
|
1817
|
+
_context25.t0 = _context25["catch"](1);
|
|
1818
|
+
this.logMethodError('buildPrefillProductSourceMap', _context25.t0);
|
|
1041
1819
|
case 15:
|
|
1042
|
-
return
|
|
1820
|
+
return _context25.abrupt("return", sourceMap);
|
|
1043
1821
|
case 16:
|
|
1044
1822
|
case "end":
|
|
1045
|
-
return
|
|
1823
|
+
return _context25.stop();
|
|
1046
1824
|
}
|
|
1047
|
-
},
|
|
1825
|
+
}, _callee25, this, [[1, 12]]);
|
|
1048
1826
|
}));
|
|
1049
1827
|
function buildPrefillProductSourceMap() {
|
|
1050
1828
|
return _buildPrefillProductSourceMap.apply(this, arguments);
|
|
@@ -1059,58 +1837,58 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1059
1837
|
}, {
|
|
1060
1838
|
key: "ensureItemRuleConfigsLoaded",
|
|
1061
1839
|
value: function () {
|
|
1062
|
-
var _ensureItemRuleConfigsLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1063
|
-
var
|
|
1840
|
+
var _ensureItemRuleConfigsLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
|
|
1841
|
+
var _this6 = this;
|
|
1064
1842
|
var loadedConfigs;
|
|
1065
|
-
return _regeneratorRuntime().wrap(function
|
|
1066
|
-
while (1) switch (
|
|
1843
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
1844
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
1067
1845
|
case 0:
|
|
1068
1846
|
if (!(this.itemRuleConfigs.length > 0)) {
|
|
1069
|
-
|
|
1847
|
+
_context27.next = 2;
|
|
1070
1848
|
break;
|
|
1071
1849
|
}
|
|
1072
|
-
return
|
|
1850
|
+
return _context27.abrupt("return", this.itemRuleConfigs);
|
|
1073
1851
|
case 2:
|
|
1074
1852
|
if (!this.itemRuleConfigsPromise) {
|
|
1075
|
-
|
|
1853
|
+
_context27.next = 4;
|
|
1076
1854
|
break;
|
|
1077
1855
|
}
|
|
1078
|
-
return
|
|
1856
|
+
return _context27.abrupt("return", this.itemRuleConfigsPromise);
|
|
1079
1857
|
case 4:
|
|
1080
|
-
this.itemRuleConfigsPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1858
|
+
this.itemRuleConfigsPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
|
|
1081
1859
|
var runtimeConfig, staticConfigs;
|
|
1082
|
-
return _regeneratorRuntime().wrap(function
|
|
1083
|
-
while (1) switch (
|
|
1860
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
1861
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
1084
1862
|
case 0:
|
|
1085
|
-
runtimeConfig =
|
|
1863
|
+
runtimeConfig = _this6.getItemRuleRuntimeConfig();
|
|
1086
1864
|
staticConfigs = normalizeItemRuleStrategies(runtimeConfig.strategyConfigs);
|
|
1087
1865
|
if (!(staticConfigs.length > 0)) {
|
|
1088
|
-
|
|
1866
|
+
_context26.next = 6;
|
|
1089
1867
|
break;
|
|
1090
1868
|
}
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
return
|
|
1869
|
+
_this6.itemRuleConfigs = staticConfigs;
|
|
1870
|
+
_this6.itemRuleEvaluator.setStrategyConfigs(staticConfigs);
|
|
1871
|
+
return _context26.abrupt("return", _this6.itemRuleConfigs);
|
|
1094
1872
|
case 6:
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
return
|
|
1873
|
+
_this6.itemRuleConfigs = [];
|
|
1874
|
+
_this6.itemRuleEvaluator.setStrategyConfigs([]);
|
|
1875
|
+
return _context26.abrupt("return", _this6.itemRuleConfigs);
|
|
1098
1876
|
case 9:
|
|
1099
1877
|
case "end":
|
|
1100
|
-
return
|
|
1878
|
+
return _context26.stop();
|
|
1101
1879
|
}
|
|
1102
|
-
},
|
|
1880
|
+
}, _callee26);
|
|
1103
1881
|
}))();
|
|
1104
|
-
|
|
1882
|
+
_context27.next = 7;
|
|
1105
1883
|
return this.itemRuleConfigsPromise;
|
|
1106
1884
|
case 7:
|
|
1107
|
-
loadedConfigs =
|
|
1108
|
-
return
|
|
1885
|
+
loadedConfigs = _context27.sent;
|
|
1886
|
+
return _context27.abrupt("return", loadedConfigs);
|
|
1109
1887
|
case 9:
|
|
1110
1888
|
case "end":
|
|
1111
|
-
return
|
|
1889
|
+
return _context27.stop();
|
|
1112
1890
|
}
|
|
1113
|
-
},
|
|
1891
|
+
}, _callee27, this);
|
|
1114
1892
|
}));
|
|
1115
1893
|
function ensureItemRuleConfigsLoaded() {
|
|
1116
1894
|
return _ensureItemRuleConfigsLoaded.apply(this, arguments);
|
|
@@ -1120,22 +1898,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1120
1898
|
}, {
|
|
1121
1899
|
key: "refreshItemRuleQuantityLimits",
|
|
1122
1900
|
value: function () {
|
|
1123
|
-
var _refreshItemRuleQuantityLimits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1901
|
+
var _refreshItemRuleQuantityLimits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
|
|
1124
1902
|
var strategyConfigs, businessData, limits;
|
|
1125
|
-
return _regeneratorRuntime().wrap(function
|
|
1126
|
-
while (1) switch (
|
|
1903
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
1904
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
1127
1905
|
case 0:
|
|
1128
|
-
|
|
1129
|
-
|
|
1906
|
+
_context28.prev = 0;
|
|
1907
|
+
_context28.next = 3;
|
|
1130
1908
|
return this.ensureItemRuleConfigsLoaded();
|
|
1131
1909
|
case 3:
|
|
1132
|
-
strategyConfigs =
|
|
1910
|
+
strategyConfigs = _context28.sent;
|
|
1133
1911
|
if (strategyConfigs.length) {
|
|
1134
|
-
|
|
1912
|
+
_context28.next = 7;
|
|
1135
1913
|
break;
|
|
1136
1914
|
}
|
|
1137
1915
|
this.store.itemRuleQuantityLimits = [];
|
|
1138
|
-
return
|
|
1916
|
+
return _context28.abrupt("return", []);
|
|
1139
1917
|
case 7:
|
|
1140
1918
|
businessData = buildItemRuleBusinessData({
|
|
1141
1919
|
tempOrder: this.ensureTempOrder(),
|
|
@@ -1147,18 +1925,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1147
1925
|
this.logMethodSuccess('refreshItemRuleQuantityLimits', {
|
|
1148
1926
|
limitCount: limits.length
|
|
1149
1927
|
});
|
|
1150
|
-
return
|
|
1928
|
+
return _context28.abrupt("return", limits);
|
|
1151
1929
|
case 14:
|
|
1152
|
-
|
|
1153
|
-
|
|
1930
|
+
_context28.prev = 14;
|
|
1931
|
+
_context28.t0 = _context28["catch"](0);
|
|
1154
1932
|
this.store.itemRuleQuantityLimits = [];
|
|
1155
|
-
this.logMethodError('refreshItemRuleQuantityLimits',
|
|
1156
|
-
return
|
|
1933
|
+
this.logMethodError('refreshItemRuleQuantityLimits', _context28.t0);
|
|
1934
|
+
return _context28.abrupt("return", []);
|
|
1157
1935
|
case 19:
|
|
1158
1936
|
case "end":
|
|
1159
|
-
return
|
|
1937
|
+
return _context28.stop();
|
|
1160
1938
|
}
|
|
1161
|
-
},
|
|
1939
|
+
}, _callee28, this, [[0, 14]]);
|
|
1162
1940
|
}));
|
|
1163
1941
|
function refreshItemRuleQuantityLimits() {
|
|
1164
1942
|
return _refreshItemRuleQuantityLimits.apply(this, arguments);
|
|
@@ -1168,32 +1946,32 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1168
1946
|
}, {
|
|
1169
1947
|
key: "applyPrefillByItemRule",
|
|
1170
1948
|
value: function () {
|
|
1171
|
-
var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1172
|
-
var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges,
|
|
1173
|
-
return _regeneratorRuntime().wrap(function
|
|
1174
|
-
while (1) switch (
|
|
1949
|
+
var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
|
|
1950
|
+
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;
|
|
1951
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
1952
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
1175
1953
|
case 0:
|
|
1176
1954
|
if (!this.itemRulePrefillApplied) {
|
|
1177
|
-
|
|
1955
|
+
_context29.next = 2;
|
|
1178
1956
|
break;
|
|
1179
1957
|
}
|
|
1180
|
-
return
|
|
1958
|
+
return _context29.abrupt("return");
|
|
1181
1959
|
case 2:
|
|
1182
1960
|
if (this.store.order) {
|
|
1183
|
-
|
|
1961
|
+
_context29.next = 4;
|
|
1184
1962
|
break;
|
|
1185
1963
|
}
|
|
1186
|
-
return
|
|
1964
|
+
return _context29.abrupt("return");
|
|
1187
1965
|
case 4:
|
|
1188
|
-
|
|
1966
|
+
_context29.next = 6;
|
|
1189
1967
|
return this.ensureItemRuleConfigsLoaded();
|
|
1190
1968
|
case 6:
|
|
1191
|
-
strategyConfigs =
|
|
1969
|
+
strategyConfigs = _context29.sent;
|
|
1192
1970
|
if (strategyConfigs.length) {
|
|
1193
|
-
|
|
1971
|
+
_context29.next = 9;
|
|
1194
1972
|
break;
|
|
1195
1973
|
}
|
|
1196
|
-
return
|
|
1974
|
+
return _context29.abrupt("return");
|
|
1197
1975
|
case 9:
|
|
1198
1976
|
businessData = buildItemRuleBusinessData({
|
|
1199
1977
|
tempOrder: this.ensureTempOrder(),
|
|
@@ -1202,41 +1980,41 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1202
1980
|
});
|
|
1203
1981
|
prefillItems = this.itemRuleEvaluator.getPrefillItems(businessData);
|
|
1204
1982
|
if (prefillItems.length) {
|
|
1205
|
-
|
|
1983
|
+
_context29.next = 14;
|
|
1206
1984
|
break;
|
|
1207
1985
|
}
|
|
1208
1986
|
this.itemRulePrefillApplied = true;
|
|
1209
|
-
return
|
|
1987
|
+
return _context29.abrupt("return");
|
|
1210
1988
|
case 14:
|
|
1211
|
-
|
|
1989
|
+
_context29.next = 16;
|
|
1212
1990
|
return this.buildPrefillProductSourceMap();
|
|
1213
1991
|
case 16:
|
|
1214
|
-
productSourceMap =
|
|
1992
|
+
productSourceMap = _context29.sent;
|
|
1215
1993
|
tempOrder = this.ensureTempOrder();
|
|
1216
1994
|
hasChanges = false;
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1995
|
+
_iterator5 = _createForOfIteratorHelper(prefillItems);
|
|
1996
|
+
_context29.prev = 20;
|
|
1997
|
+
_iterator5.s();
|
|
1220
1998
|
case 22:
|
|
1221
|
-
if ((
|
|
1222
|
-
|
|
1999
|
+
if ((_step5 = _iterator5.n()).done) {
|
|
2000
|
+
_context29.next = 47;
|
|
1223
2001
|
break;
|
|
1224
2002
|
}
|
|
1225
|
-
prefillItem =
|
|
2003
|
+
prefillItem = _step5.value;
|
|
1226
2004
|
productId = Number(prefillItem.product_id);
|
|
1227
2005
|
productVariantId = Number((_prefillItem$product_ = prefillItem.product_variant_id) !== null && _prefillItem$product_ !== void 0 ? _prefillItem$product_ : 0);
|
|
1228
2006
|
targetQuantity = toNonNegativeInt(prefillItem.quantity);
|
|
1229
2007
|
if (!(!Number.isFinite(productId) || targetQuantity <= 0)) {
|
|
1230
|
-
|
|
2008
|
+
_context29.next = 29;
|
|
1231
2009
|
break;
|
|
1232
2010
|
}
|
|
1233
|
-
return
|
|
2011
|
+
return _context29.abrupt("continue", 45);
|
|
1234
2012
|
case 29:
|
|
1235
2013
|
if (!Number.isNaN(productVariantId)) {
|
|
1236
|
-
|
|
2014
|
+
_context29.next = 31;
|
|
1237
2015
|
break;
|
|
1238
2016
|
}
|
|
1239
|
-
return
|
|
2017
|
+
return _context29.abrupt("continue", 45);
|
|
1240
2018
|
case 31:
|
|
1241
2019
|
sourceItem = productSourceMap.get(buildProductKey(productId, productVariantId)) || productSourceMap.get(buildProductKey(productId, 0)) || null;
|
|
1242
2020
|
productIndex = getProductIdentityIndex(tempOrder.products, {
|
|
@@ -1244,7 +2022,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1244
2022
|
product_variant_id: productVariantId
|
|
1245
2023
|
});
|
|
1246
2024
|
if (!(productIndex === -1)) {
|
|
1247
|
-
|
|
2025
|
+
_context29.next = 38;
|
|
1248
2026
|
break;
|
|
1249
2027
|
}
|
|
1250
2028
|
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');
|
|
@@ -1264,7 +2042,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1264
2042
|
})
|
|
1265
2043
|
})));
|
|
1266
2044
|
hasChanges = true;
|
|
1267
|
-
return
|
|
2045
|
+
return _context29.abrupt("continue", 45);
|
|
1268
2046
|
case 38:
|
|
1269
2047
|
targetProduct = tempOrder.products[productIndex];
|
|
1270
2048
|
existedQuantity = toNonNegativeInt(targetProduct.num);
|
|
@@ -1285,34 +2063,34 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1285
2063
|
hasChanges = true;
|
|
1286
2064
|
}
|
|
1287
2065
|
case 45:
|
|
1288
|
-
|
|
2066
|
+
_context29.next = 22;
|
|
1289
2067
|
break;
|
|
1290
2068
|
case 47:
|
|
1291
|
-
|
|
2069
|
+
_context29.next = 52;
|
|
1292
2070
|
break;
|
|
1293
2071
|
case 49:
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
2072
|
+
_context29.prev = 49;
|
|
2073
|
+
_context29.t0 = _context29["catch"](20);
|
|
2074
|
+
_iterator5.e(_context29.t0);
|
|
1297
2075
|
case 52:
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
return
|
|
2076
|
+
_context29.prev = 52;
|
|
2077
|
+
_iterator5.f();
|
|
2078
|
+
return _context29.finish(52);
|
|
1301
2079
|
case 55:
|
|
1302
2080
|
if (!hasChanges) {
|
|
1303
|
-
|
|
2081
|
+
_context29.next = 60;
|
|
1304
2082
|
break;
|
|
1305
2083
|
}
|
|
1306
2084
|
// Prefill 属于 products CRUD 的一种形式:新增后让 Rules 重算,以支持自动应用可用优惠券。
|
|
1307
2085
|
this.store.order.applyDiscount();
|
|
1308
|
-
|
|
2086
|
+
_context29.next = 59;
|
|
1309
2087
|
return this.store.order.recalculateSummary({
|
|
1310
2088
|
createIfMissing: true
|
|
1311
2089
|
});
|
|
1312
2090
|
case 59:
|
|
1313
2091
|
this.store.order.persistTempOrder();
|
|
1314
2092
|
case 60:
|
|
1315
|
-
|
|
2093
|
+
_context29.next = 62;
|
|
1316
2094
|
return this.refreshItemRuleQuantityLimits();
|
|
1317
2095
|
case 62:
|
|
1318
2096
|
this.itemRulePrefillApplied = true;
|
|
@@ -1322,9 +2100,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1322
2100
|
});
|
|
1323
2101
|
case 64:
|
|
1324
2102
|
case "end":
|
|
1325
|
-
return
|
|
2103
|
+
return _context29.stop();
|
|
1326
2104
|
}
|
|
1327
|
-
},
|
|
2105
|
+
}, _callee29, this, [[20, 49, 52, 55]]);
|
|
1328
2106
|
}));
|
|
1329
2107
|
function applyPrefillByItemRule() {
|
|
1330
2108
|
return _applyPrefillByItemRule.apply(this, arguments);
|
|
@@ -1334,31 +2112,31 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1334
2112
|
}, {
|
|
1335
2113
|
key: "applyItemRulePrefill",
|
|
1336
2114
|
value: function () {
|
|
1337
|
-
var _applyItemRulePrefill = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2115
|
+
var _applyItemRulePrefill = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
|
|
1338
2116
|
var _this$store$order4, _this$store$order4$ge;
|
|
1339
|
-
return _regeneratorRuntime().wrap(function
|
|
1340
|
-
while (1) switch (
|
|
2117
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
2118
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
1341
2119
|
case 0:
|
|
1342
2120
|
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))) {
|
|
1343
|
-
|
|
2121
|
+
_context30.next = 2;
|
|
1344
2122
|
break;
|
|
1345
2123
|
}
|
|
1346
|
-
return
|
|
2124
|
+
return _context30.abrupt("return");
|
|
1347
2125
|
case 2:
|
|
1348
2126
|
this.logMethodStart('applyItemRulePrefill');
|
|
1349
|
-
|
|
2127
|
+
_context30.next = 5;
|
|
1350
2128
|
return this.applyPrefillByItemRule();
|
|
1351
2129
|
case 5:
|
|
1352
|
-
|
|
2130
|
+
_context30.next = 7;
|
|
1353
2131
|
return this.refreshItemRuleQuantityLimits();
|
|
1354
2132
|
case 7:
|
|
1355
|
-
|
|
2133
|
+
_context30.next = 9;
|
|
1356
2134
|
return this.refreshCartValidationPassed();
|
|
1357
2135
|
case 9:
|
|
1358
2136
|
case "end":
|
|
1359
|
-
return
|
|
2137
|
+
return _context30.stop();
|
|
1360
2138
|
}
|
|
1361
|
-
},
|
|
2139
|
+
}, _callee30, this);
|
|
1362
2140
|
}));
|
|
1363
2141
|
function applyItemRulePrefill() {
|
|
1364
2142
|
return _applyItemRulePrefill.apply(this, arguments);
|
|
@@ -1368,20 +2146,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1368
2146
|
}, {
|
|
1369
2147
|
key: "evaluateCartValidationByItemRule",
|
|
1370
2148
|
value: function () {
|
|
1371
|
-
var _evaluateCartValidationByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2149
|
+
var _evaluateCartValidationByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
|
|
1372
2150
|
var strategyConfigs, businessData;
|
|
1373
|
-
return _regeneratorRuntime().wrap(function
|
|
1374
|
-
while (1) switch (
|
|
2151
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
2152
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
1375
2153
|
case 0:
|
|
1376
|
-
|
|
2154
|
+
_context31.next = 2;
|
|
1377
2155
|
return this.ensureItemRuleConfigsLoaded();
|
|
1378
2156
|
case 2:
|
|
1379
|
-
strategyConfigs =
|
|
2157
|
+
strategyConfigs = _context31.sent;
|
|
1380
2158
|
if (strategyConfigs.length) {
|
|
1381
|
-
|
|
2159
|
+
_context31.next = 5;
|
|
1382
2160
|
break;
|
|
1383
2161
|
}
|
|
1384
|
-
return
|
|
2162
|
+
return _context31.abrupt("return", {
|
|
1385
2163
|
passed: true,
|
|
1386
2164
|
failures: []
|
|
1387
2165
|
});
|
|
@@ -1391,12 +2169,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1391
2169
|
runtimeConfig: this.getItemRuleRuntimeConfig(),
|
|
1392
2170
|
itemRuleConfigs: this.itemRuleConfigs
|
|
1393
2171
|
});
|
|
1394
|
-
return
|
|
2172
|
+
return _context31.abrupt("return", this.itemRuleEvaluator.validateCart(businessData));
|
|
1395
2173
|
case 7:
|
|
1396
2174
|
case "end":
|
|
1397
|
-
return
|
|
2175
|
+
return _context31.stop();
|
|
1398
2176
|
}
|
|
1399
|
-
},
|
|
2177
|
+
}, _callee31, this);
|
|
1400
2178
|
}));
|
|
1401
2179
|
function evaluateCartValidationByItemRule() {
|
|
1402
2180
|
return _evaluateCartValidationByItemRule.apply(this, arguments);
|
|
@@ -1406,20 +2184,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1406
2184
|
}, {
|
|
1407
2185
|
key: "validateBeforeSubmitByItemRule",
|
|
1408
2186
|
value: function () {
|
|
1409
|
-
var _validateBeforeSubmitByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2187
|
+
var _validateBeforeSubmitByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
|
|
1410
2188
|
var validationResult, firstFailure, errorMessage, error;
|
|
1411
|
-
return _regeneratorRuntime().wrap(function
|
|
1412
|
-
while (1) switch (
|
|
2189
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
2190
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
1413
2191
|
case 0:
|
|
1414
|
-
|
|
2192
|
+
_context32.next = 2;
|
|
1415
2193
|
return this.evaluateCartValidationByItemRule();
|
|
1416
2194
|
case 2:
|
|
1417
|
-
validationResult =
|
|
2195
|
+
validationResult = _context32.sent;
|
|
1418
2196
|
if (!validationResult.passed) {
|
|
1419
|
-
|
|
2197
|
+
_context32.next = 5;
|
|
1420
2198
|
break;
|
|
1421
2199
|
}
|
|
1422
|
-
return
|
|
2200
|
+
return _context32.abrupt("return");
|
|
1423
2201
|
case 5:
|
|
1424
2202
|
firstFailure = validationResult.failures[0];
|
|
1425
2203
|
errorMessage = (firstFailure === null || firstFailure === void 0 ? void 0 : firstFailure.validationMessage) || '当前购物车未满足商品规则,请调整后再提交';
|
|
@@ -1428,9 +2206,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1428
2206
|
throw error;
|
|
1429
2207
|
case 10:
|
|
1430
2208
|
case "end":
|
|
1431
|
-
return
|
|
2209
|
+
return _context32.stop();
|
|
1432
2210
|
}
|
|
1433
|
-
},
|
|
2211
|
+
}, _callee32, this);
|
|
1434
2212
|
}));
|
|
1435
2213
|
function validateBeforeSubmitByItemRule() {
|
|
1436
2214
|
return _validateBeforeSubmitByItemRule.apply(this, arguments);
|
|
@@ -1440,10 +2218,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1440
2218
|
}, {
|
|
1441
2219
|
key: "refreshCartValidationPassed",
|
|
1442
2220
|
value: function () {
|
|
1443
|
-
var _refreshCartValidationPassed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2221
|
+
var _refreshCartValidationPassed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
|
|
1444
2222
|
var previous, nextState, validationResult, changed;
|
|
1445
|
-
return _regeneratorRuntime().wrap(function
|
|
1446
|
-
while (1) switch (
|
|
2223
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
2224
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
1447
2225
|
case 0:
|
|
1448
2226
|
previous = this.store.cartValidation || {
|
|
1449
2227
|
passed: null,
|
|
@@ -1453,20 +2231,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1453
2231
|
passed: null,
|
|
1454
2232
|
failures: []
|
|
1455
2233
|
};
|
|
1456
|
-
|
|
1457
|
-
|
|
2234
|
+
_context33.prev = 2;
|
|
2235
|
+
_context33.next = 5;
|
|
1458
2236
|
return this.evaluateCartValidationByItemRule();
|
|
1459
2237
|
case 5:
|
|
1460
|
-
validationResult =
|
|
2238
|
+
validationResult = _context33.sent;
|
|
1461
2239
|
nextState = {
|
|
1462
2240
|
passed: validationResult.passed,
|
|
1463
2241
|
failures: validationResult.failures || []
|
|
1464
2242
|
};
|
|
1465
|
-
|
|
2243
|
+
_context33.next = 12;
|
|
1466
2244
|
break;
|
|
1467
2245
|
case 9:
|
|
1468
|
-
|
|
1469
|
-
|
|
2246
|
+
_context33.prev = 9;
|
|
2247
|
+
_context33.t0 = _context33["catch"](2);
|
|
1470
2248
|
nextState = {
|
|
1471
2249
|
passed: false,
|
|
1472
2250
|
failures: []
|
|
@@ -1475,21 +2253,21 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1475
2253
|
this.store.cartValidation = nextState;
|
|
1476
2254
|
changed = previous.passed !== nextState.passed || previous.failures !== nextState.failures;
|
|
1477
2255
|
if (!changed) {
|
|
1478
|
-
|
|
2256
|
+
_context33.next = 17;
|
|
1479
2257
|
break;
|
|
1480
2258
|
}
|
|
1481
|
-
|
|
2259
|
+
_context33.next = 17;
|
|
1482
2260
|
return this.core.effects.emit(ScanOrderHooks.onCartValidationChanged, {
|
|
1483
2261
|
cartValidation: nextState,
|
|
1484
2262
|
cartValidationPassed: nextState.passed
|
|
1485
2263
|
});
|
|
1486
2264
|
case 17:
|
|
1487
|
-
return
|
|
2265
|
+
return _context33.abrupt("return", nextState.passed);
|
|
1488
2266
|
case 18:
|
|
1489
2267
|
case "end":
|
|
1490
|
-
return
|
|
2268
|
+
return _context33.stop();
|
|
1491
2269
|
}
|
|
1492
|
-
},
|
|
2270
|
+
}, _callee33, this, [[2, 9]]);
|
|
1493
2271
|
}));
|
|
1494
2272
|
function refreshCartValidationPassed() {
|
|
1495
2273
|
return _refreshCartValidationPassed.apply(this, arguments);
|
|
@@ -1499,14 +2277,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1499
2277
|
}, {
|
|
1500
2278
|
key: "setItemRuleRuntimeConfig",
|
|
1501
2279
|
value: function () {
|
|
1502
|
-
var _setItemRuleRuntimeConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2280
|
+
var _setItemRuleRuntimeConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
|
|
1503
2281
|
var _this$itemRuleRuntime, _this$itemRuleRuntime2;
|
|
1504
2282
|
var config,
|
|
1505
|
-
|
|
1506
|
-
return _regeneratorRuntime().wrap(function
|
|
1507
|
-
while (1) switch (
|
|
2283
|
+
_args34 = arguments;
|
|
2284
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
2285
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
1508
2286
|
case 0:
|
|
1509
|
-
config =
|
|
2287
|
+
config = _args34.length > 0 && _args34[0] !== undefined ? _args34[0] : {};
|
|
1510
2288
|
this.logMethodStart('setItemRuleRuntimeConfig');
|
|
1511
2289
|
this.itemRuleRuntimeConfig = _objectSpread(_objectSpread(_objectSpread({}, this.itemRuleRuntimeConfig), config), {}, {
|
|
1512
2290
|
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) || {}),
|
|
@@ -1518,10 +2296,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1518
2296
|
this.itemRuleEvaluator.setStrategyConfigs([]);
|
|
1519
2297
|
}
|
|
1520
2298
|
this.itemRulePrefillApplied = false;
|
|
1521
|
-
|
|
2299
|
+
_context34.next = 7;
|
|
1522
2300
|
return this.refreshItemRuleQuantityLimits();
|
|
1523
2301
|
case 7:
|
|
1524
|
-
|
|
2302
|
+
_context34.next = 9;
|
|
1525
2303
|
return this.refreshCartValidationPassed();
|
|
1526
2304
|
case 9:
|
|
1527
2305
|
this.logMethodSuccess('setItemRuleRuntimeConfig', {
|
|
@@ -1529,9 +2307,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1529
2307
|
});
|
|
1530
2308
|
case 10:
|
|
1531
2309
|
case "end":
|
|
1532
|
-
return
|
|
2310
|
+
return _context34.stop();
|
|
1533
2311
|
}
|
|
1534
|
-
},
|
|
2312
|
+
}, _callee34, this);
|
|
1535
2313
|
}));
|
|
1536
2314
|
function setItemRuleRuntimeConfig() {
|
|
1537
2315
|
return _setItemRuleRuntimeConfig.apply(this, arguments);
|
|
@@ -1540,22 +2318,24 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1540
2318
|
}()
|
|
1541
2319
|
}, {
|
|
1542
2320
|
key: "normalizeResourceState",
|
|
1543
|
-
value: function normalizeResourceState(
|
|
1544
|
-
var _this$otherParams8,
|
|
1545
|
-
var
|
|
1546
|
-
var
|
|
1547
|
-
var
|
|
1548
|
-
var
|
|
1549
|
-
var
|
|
1550
|
-
var relationId = toPositiveString(config === null || config === void 0 ? void 0 : config.relation_id);
|
|
1551
|
-
var tableFormId = toPositiveString(config === null || config === void 0 ? void 0 : config.table_form_id);
|
|
2321
|
+
value: function normalizeResourceState(detail, resourceSelectType, hasOrderId) {
|
|
2322
|
+
var _detail$form_record, _this$otherParams8, _detail$resource_capa, _detail$resource_capa2;
|
|
2323
|
+
var currentOrderId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.order_id);
|
|
2324
|
+
var lastOrderId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.last_order_id);
|
|
2325
|
+
var relationId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.form_record_id);
|
|
2326
|
+
var tableFormId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.form_id);
|
|
2327
|
+
var formRecord = (_detail$form_record = detail === null || detail === void 0 ? void 0 : detail.form_record) !== null && _detail$form_record !== void 0 ? _detail$form_record : null;
|
|
1552
2328
|
// 是否允许加餐
|
|
1553
|
-
var allowSnack = ((_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 || (_this$otherParams8 = _this$otherParams8.dineInConfig) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8['
|
|
2329
|
+
var allowSnack = ((_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 || (_this$otherParams8 = _this$otherParams8.dineInConfig) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8['sale.allow_add_items']) || false;
|
|
1554
2330
|
// 开启同桌验证 - 本期没有这个配置,默认关掉
|
|
1555
2331
|
var deskmateValid = false;
|
|
1556
|
-
var isExclusive =
|
|
1557
|
-
var isFull =
|
|
1558
|
-
|
|
2332
|
+
var isExclusive = resourceSelectType === 'single';
|
|
2333
|
+
var isFull = computeResourceIsFull({
|
|
2334
|
+
resourceSelectType: resourceSelectType,
|
|
2335
|
+
lastOrderId: lastOrderId,
|
|
2336
|
+
capacityList: (_detail$resource_capa = detail === null || detail === void 0 || (_detail$resource_capa2 = detail.resource_capacity) === null || _detail$resource_capa2 === void 0 || (_detail$resource_capa2 = _detail$resource_capa2[0]) === null || _detail$resource_capa2 === void 0 ? void 0 : _detail$resource_capa2.capacity_list) !== null && _detail$resource_capa !== void 0 ? _detail$resource_capa : [],
|
|
2337
|
+
capacity: formRecord === null || formRecord === void 0 ? void 0 : formRecord.capacity
|
|
2338
|
+
});
|
|
1559
2339
|
var availabilityInfo = {
|
|
1560
2340
|
mode: 'idle',
|
|
1561
2341
|
deskmate_valid: deskmateValid
|
|
@@ -1584,33 +2364,19 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1584
2364
|
}
|
|
1585
2365
|
} else if (lastOrderId) {
|
|
1586
2366
|
// 如果有其他人点的单
|
|
1587
|
-
//
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
table_form_id: tableFormId,
|
|
1599
|
-
deskmate_valid: deskmateValid
|
|
1600
|
-
};
|
|
1601
|
-
}
|
|
1602
|
-
if (isBlock) {
|
|
1603
|
-
availabilityInfo = {
|
|
1604
|
-
mode: 'resource_block',
|
|
1605
|
-
order_id: lastOrderId,
|
|
1606
|
-
relation_id: relationId,
|
|
1607
|
-
table_form_id: tableFormId,
|
|
1608
|
-
deskmate_valid: deskmateValid
|
|
1609
|
-
};
|
|
2367
|
+
// multiple 预约且容量仍有剩余时,其他人的单不影响当前用户下单,保持 idle 走正常下单流程
|
|
2368
|
+
var canFallthroughToIdle = resourceSelectType === 'multiple' && !isFull;
|
|
2369
|
+
if (!canFallthroughToIdle) {
|
|
2370
|
+
availabilityInfo = {
|
|
2371
|
+
mode: 'resource_busy',
|
|
2372
|
+
order_id: '0',
|
|
2373
|
+
relation_id: relationId,
|
|
2374
|
+
table_form_id: tableFormId,
|
|
2375
|
+
deskmate_valid: deskmateValid
|
|
2376
|
+
};
|
|
2377
|
+
}
|
|
1610
2378
|
}
|
|
1611
2379
|
return _objectSpread(_objectSpread({}, availabilityInfo), {}, {
|
|
1612
|
-
tableMaxNumber: tableMaxNumber,
|
|
1613
|
-
orderCount: orderCount,
|
|
1614
2380
|
currentOrderId: currentOrderId,
|
|
1615
2381
|
lastOrderId: lastOrderId,
|
|
1616
2382
|
relationId: relationId,
|
|
@@ -1619,142 +2385,177 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1619
2385
|
deskmateValid: deskmateValid,
|
|
1620
2386
|
isExclusive: isExclusive,
|
|
1621
2387
|
isFull: isFull,
|
|
1622
|
-
|
|
1623
|
-
raw:
|
|
1624
|
-
table_form_record:
|
|
2388
|
+
resourceSelectType: resourceSelectType,
|
|
2389
|
+
raw: detail,
|
|
2390
|
+
table_form_record: formRecord
|
|
2391
|
+
});
|
|
2392
|
+
}
|
|
2393
|
+
|
|
2394
|
+
// 从首个预约规则商品的 product_resource.resources 中,按 form_id 匹配返回 type
|
|
2395
|
+
}, {
|
|
2396
|
+
key: "resolveResourceSelectType",
|
|
2397
|
+
value: function resolveResourceSelectType(formId) {
|
|
2398
|
+
var _firstProduct$product;
|
|
2399
|
+
var firstProduct = this.enabledReservationRuleProducts[0];
|
|
2400
|
+
var resources = (firstProduct === null || firstProduct === void 0 || (_firstProduct$product = firstProduct.product_resource) === null || _firstProduct$product === void 0 ? void 0 : _firstProduct$product.resources) || [];
|
|
2401
|
+
var numericFormId = Number(formId);
|
|
2402
|
+
if (!Number.isFinite(numericFormId) || numericFormId <= 0) return undefined;
|
|
2403
|
+
var matched = resources.find(function (r) {
|
|
2404
|
+
return Number(r === null || r === void 0 ? void 0 : r.id) === numericFormId;
|
|
1625
2405
|
});
|
|
2406
|
+
return matched === null || matched === void 0 ? void 0 : matched.type;
|
|
1626
2407
|
}
|
|
1627
2408
|
}, {
|
|
1628
|
-
key: "
|
|
2409
|
+
key: "fetchResourceOccupyDetailByResourceId",
|
|
1629
2410
|
value: function () {
|
|
1630
|
-
var
|
|
1631
|
-
var
|
|
1632
|
-
|
|
1633
|
-
|
|
2411
|
+
var _fetchResourceOccupyDetailByResourceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(resourceId) {
|
|
2412
|
+
var _this$otherParams9, _this$otherParams9$ge, _response$data$occupy, _response$data;
|
|
2413
|
+
var formRecordId, shopId, response;
|
|
2414
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
2415
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
1634
2416
|
case 0:
|
|
1635
|
-
|
|
1636
|
-
if (!(!Number.isFinite(
|
|
1637
|
-
|
|
2417
|
+
formRecordId = Number(resourceId);
|
|
2418
|
+
if (!(!Number.isFinite(formRecordId) || formRecordId <= 0)) {
|
|
2419
|
+
_context35.next = 3;
|
|
1638
2420
|
break;
|
|
1639
2421
|
}
|
|
1640
2422
|
throw new Error("[ScanOrder] \u975E\u6CD5\u684C\u53F0 resourceId: ".concat(resourceId));
|
|
1641
2423
|
case 3:
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
2424
|
+
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');
|
|
2425
|
+
if (shopId) {
|
|
2426
|
+
_context35.next = 6;
|
|
2427
|
+
break;
|
|
2428
|
+
}
|
|
2429
|
+
throw new Error('[ScanOrder] 无法获取 shop_id');
|
|
2430
|
+
case 6:
|
|
2431
|
+
_context35.next = 8;
|
|
2432
|
+
return this.request.get('/order/resource/occupy-detail', {
|
|
2433
|
+
shop_id: shopId,
|
|
2434
|
+
'form_record_ids[]': formRecordId,
|
|
2435
|
+
with_resource_capacity_info: 1,
|
|
2436
|
+
with_resource_order_info: 1,
|
|
2437
|
+
with_resource_form_info: 1
|
|
1646
2438
|
});
|
|
1647
|
-
case
|
|
1648
|
-
response =
|
|
2439
|
+
case 8:
|
|
2440
|
+
response = _context35.sent;
|
|
1649
2441
|
if (response !== null && response !== void 0 && response.status) {
|
|
1650
|
-
|
|
2442
|
+
_context35.next = 11;
|
|
1651
2443
|
break;
|
|
1652
2444
|
}
|
|
1653
|
-
throw new Error((response === null || response === void 0 ? void 0 : response.message) || '
|
|
1654
|
-
case
|
|
1655
|
-
return
|
|
1656
|
-
case
|
|
2445
|
+
throw new Error((response === null || response === void 0 ? void 0 : response.message) || '获取资源占用详情失败');
|
|
2446
|
+
case 11:
|
|
2447
|
+
return _context35.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);
|
|
2448
|
+
case 12:
|
|
1657
2449
|
case "end":
|
|
1658
|
-
return
|
|
2450
|
+
return _context35.stop();
|
|
1659
2451
|
}
|
|
1660
|
-
},
|
|
2452
|
+
}, _callee35, this);
|
|
1661
2453
|
}));
|
|
1662
|
-
function
|
|
1663
|
-
return
|
|
2454
|
+
function fetchResourceOccupyDetailByResourceId(_x17) {
|
|
2455
|
+
return _fetchResourceOccupyDetailByResourceId.apply(this, arguments);
|
|
1664
2456
|
}
|
|
1665
|
-
return
|
|
2457
|
+
return fetchResourceOccupyDetailByResourceId;
|
|
1666
2458
|
}() // 检测当前链接是否可用
|
|
1667
2459
|
// 通过 resource_id + 店铺配置
|
|
1668
2460
|
// hasOrderId 表示 url 上是否有 orderid,如果是的话,后续的流程会走加单
|
|
1669
2461
|
}, {
|
|
1670
2462
|
key: "checkResourceAvailable",
|
|
1671
2463
|
value: function () {
|
|
1672
|
-
var _checkResourceAvailable = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1673
|
-
var _this$
|
|
1674
|
-
return _regeneratorRuntime().wrap(function
|
|
1675
|
-
while (1) switch (
|
|
2464
|
+
var _checkResourceAvailable = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(resourceId, hasOrderId) {
|
|
2465
|
+
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;
|
|
2466
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
2467
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
1676
2468
|
case 0:
|
|
1677
2469
|
this.logMethodStart('checkResourceAvailable', {
|
|
1678
2470
|
resourceId: resourceId
|
|
1679
2471
|
});
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
return (_this$
|
|
2472
|
+
_context36.prev = 1;
|
|
2473
|
+
_context36.next = 4;
|
|
2474
|
+
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, {
|
|
1683
2475
|
scope: 'board',
|
|
1684
2476
|
target: 'dine_in+scan_to_order',
|
|
1685
2477
|
section_code: ['basic', 'fulfillment', 'reservation', 'sale', 'menu', 'availability', 'workflow']
|
|
1686
2478
|
});
|
|
1687
2479
|
case 4:
|
|
1688
|
-
openData =
|
|
2480
|
+
openData = _context36.sent;
|
|
1689
2481
|
if (!((openData === null || openData === void 0 ? void 0 : openData.status) === false)) {
|
|
1690
|
-
|
|
2482
|
+
_context36.next = 7;
|
|
1691
2483
|
break;
|
|
1692
2484
|
}
|
|
1693
2485
|
throw new Error((openData === null || openData === void 0 ? void 0 : openData.message) || '获取店铺配置失败');
|
|
1694
2486
|
case 7:
|
|
1695
2487
|
dineInConfig = (openData === null || openData === void 0 ? void 0 : openData.data) || {};
|
|
1696
2488
|
this.otherParams.dineInConfig = dineInConfig;
|
|
1697
|
-
|
|
2489
|
+
_context36.next = 11;
|
|
1698
2490
|
return this.syncItemRuleConfigsFromDineInConfig(dineInConfig);
|
|
1699
2491
|
case 11:
|
|
1700
|
-
|
|
2492
|
+
closedBehaviorValue = dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.closed_behavior'];
|
|
2493
|
+
closedMessage = (dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.closed_message']) || (dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.message']) || (dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['basic.closed_message']);
|
|
2494
|
+
basicUnavailableMessage = (dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['basic.unavailable_message']) || closedMessage;
|
|
2495
|
+
pauseMessage = (dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.pause_message']) || closedMessage;
|
|
2496
|
+
makeShopClosed = function makeShopClosed(errorTips, closed_behavior) {
|
|
1701
2497
|
return {
|
|
1702
2498
|
mode: 'shop_closed',
|
|
1703
2499
|
order_id: undefined,
|
|
1704
2500
|
relation_id: undefined,
|
|
1705
2501
|
table_form_id: undefined,
|
|
1706
2502
|
deskmate_valid: false,
|
|
1707
|
-
errorTips:
|
|
2503
|
+
errorTips: errorTips,
|
|
2504
|
+
closed_behavior: closed_behavior
|
|
1708
2505
|
};
|
|
1709
|
-
}; //
|
|
2506
|
+
}; // 1. 基础开关 basic.enable 关闭
|
|
2507
|
+
if (!((dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['basic.enable']) === false)) {
|
|
2508
|
+
_context36.next = 18;
|
|
2509
|
+
break;
|
|
2510
|
+
}
|
|
2511
|
+
return _context36.abrupt("return", makeShopClosed(basicUnavailableMessage));
|
|
2512
|
+
case 18:
|
|
1710
2513
|
if (!toBoolean(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.paused'])) {
|
|
1711
|
-
|
|
2514
|
+
_context36.next = 21;
|
|
1712
2515
|
break;
|
|
1713
2516
|
}
|
|
1714
2517
|
if (!((dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.pause_behavior']) === 'hide_all')) {
|
|
1715
|
-
|
|
2518
|
+
_context36.next = 21;
|
|
1716
2519
|
break;
|
|
1717
2520
|
}
|
|
1718
|
-
return
|
|
1719
|
-
case
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
2521
|
+
return _context36.abrupt("return", makeShopClosed(pauseMessage));
|
|
2522
|
+
case 21:
|
|
2523
|
+
// 3. 营业时间 operating_hours 闸门
|
|
2524
|
+
operatingHourIds = Array.isArray(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.operating_hours']) ? dineInConfig['availability.operating_hours'].map(function (id) {
|
|
2525
|
+
return Number(id);
|
|
2526
|
+
}).filter(function (id) {
|
|
2527
|
+
return Number.isFinite(id) && id > 0;
|
|
2528
|
+
}) : [];
|
|
2529
|
+
outsideOperatingHours = false;
|
|
2530
|
+
if (operatingHourIds.length && this.store.schedule) {
|
|
2531
|
+
scheduleList = this.store.schedule.getScheduleListByIds(operatingHourIds);
|
|
2532
|
+
if (scheduleList.length) {
|
|
2533
|
+
now = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
2534
|
+
outsideOperatingHours = !getDateIsInSchedule(now, scheduleList);
|
|
2535
|
+
}
|
|
2536
|
+
}
|
|
2537
|
+
if (!(outsideOperatingHours && closedBehaviorValue !== 'show_menu_disabled')) {
|
|
2538
|
+
_context36.next = 26;
|
|
2539
|
+
break;
|
|
2540
|
+
}
|
|
2541
|
+
return _context36.abrupt("return", makeShopClosed(closedMessage, closedBehaviorValue));
|
|
2542
|
+
case 26:
|
|
2543
|
+
// Step1: 先加载预约规则商品,拿到 enabledReservationRuleProducts 与容量附加信息
|
|
2544
|
+
// (resourceSelectType 需要基于这些商品 + 占用接口的 form_id 计算,故必须前置)
|
|
1736
2545
|
tempOrder = this.ensureTempOrder();
|
|
1737
|
-
|
|
1738
|
-
tempOrder.table_form_id = resourceState.tableFormId;
|
|
1739
|
-
tempOrder.resource_id = resourceId;
|
|
1740
|
-
reservationLinkIds = collectLinkProductIdsFromReservationRules(dineInConfig['reservation.enabled_reservation_rules']);
|
|
2546
|
+
reservationLinkIds = collectLinkProductIdsFromReservationRules(dineInConfig['fulfillment.enabled_resource_rules']);
|
|
1741
2547
|
if (!(reservationLinkIds.length === 0)) {
|
|
1742
|
-
|
|
2548
|
+
_context36.next = 32;
|
|
1743
2549
|
break;
|
|
1744
2550
|
}
|
|
1745
2551
|
this.enabledReservationRuleProducts = [];
|
|
1746
|
-
|
|
1747
|
-
delete this.store.resource.requestEntryPax;
|
|
1748
|
-
delete this.store.resource.requestPaxMin;
|
|
1749
|
-
delete this.store.resource.requestPaxMax;
|
|
1750
|
-
}
|
|
1751
|
-
_context27.next = 42;
|
|
2552
|
+
_context36.next = 43;
|
|
1752
2553
|
break;
|
|
1753
|
-
case
|
|
2554
|
+
case 32:
|
|
1754
2555
|
tempOrder.metadata = _objectSpread({}, tempOrder.metadata || {});
|
|
1755
2556
|
delete tempOrder.metadata.table_occupancy_duration;
|
|
1756
2557
|
reservationProductList = new ProductList("".concat(this.name, "_reservationEnabledRules"), this.defaultVersion);
|
|
1757
|
-
|
|
2558
|
+
_context36.next = 37;
|
|
1758
2559
|
return reservationProductList.initialize(this.core, {
|
|
1759
2560
|
store: {
|
|
1760
2561
|
list: [],
|
|
@@ -1766,18 +2567,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1766
2567
|
cacheId: this.cacheId
|
|
1767
2568
|
})
|
|
1768
2569
|
});
|
|
1769
|
-
case
|
|
2570
|
+
case 37:
|
|
1770
2571
|
scheduleDate = dayjs().format('YYYY-MM-DD');
|
|
1771
2572
|
scheduleDatetime = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
1772
|
-
|
|
2573
|
+
_context36.next = 41;
|
|
1773
2574
|
return reservationProductList.loadProducts({
|
|
1774
2575
|
product_ids: reservationLinkIds,
|
|
1775
2576
|
schedule_date: scheduleDate,
|
|
1776
2577
|
schedule_datetime: scheduleDatetime,
|
|
1777
2578
|
cacheId: this.cacheId
|
|
1778
2579
|
});
|
|
1779
|
-
case
|
|
1780
|
-
loaded =
|
|
2580
|
+
case 41:
|
|
2581
|
+
loaded = _context36.sent;
|
|
1781
2582
|
if (Array.isArray(loaded)) {
|
|
1782
2583
|
this.enabledReservationRuleProducts = loaded;
|
|
1783
2584
|
occupancyMinutes = pickFirstDurationMinutesFromProducts(loaded);
|
|
@@ -1785,35 +2586,13 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1785
2586
|
tempOrder.metadata.table_occupancy_duration = occupancyMinutes;
|
|
1786
2587
|
}
|
|
1787
2588
|
if (hasCustomCapacityProduct(loaded)) {
|
|
1788
|
-
|
|
1789
|
-
if (this.store.resource) this.store.resource.requestEntryPax = 1;
|
|
1790
|
-
delete availabilityInfo.requestPaxMin;
|
|
1791
|
-
delete availabilityInfo.requestPaxMax;
|
|
1792
|
-
if (this.store.resource) {
|
|
1793
|
-
delete this.store.resource.requestPaxMin;
|
|
1794
|
-
delete this.store.resource.requestPaxMax;
|
|
1795
|
-
}
|
|
2589
|
+
pendingRequestEntryPax = 1;
|
|
1796
2590
|
paxBounds = pickFirstCustomCapacityPaxBounds(loaded);
|
|
1797
|
-
if ((paxBounds === null || paxBounds === void 0 ? void 0 : paxBounds.min) !== undefined)
|
|
1798
|
-
|
|
1799
|
-
if (this.store.resource) this.store.resource.requestPaxMin = paxBounds.min;
|
|
1800
|
-
}
|
|
1801
|
-
if ((paxBounds === null || paxBounds === void 0 ? void 0 : paxBounds.max) !== undefined) {
|
|
1802
|
-
availabilityInfo.requestPaxMax = paxBounds.max;
|
|
1803
|
-
if (this.store.resource) this.store.resource.requestPaxMax = paxBounds.max;
|
|
1804
|
-
}
|
|
1805
|
-
} else if (this.store.resource) {
|
|
1806
|
-
delete this.store.resource.requestEntryPax;
|
|
1807
|
-
delete this.store.resource.requestPaxMin;
|
|
1808
|
-
delete this.store.resource.requestPaxMax;
|
|
2591
|
+
if ((paxBounds === null || paxBounds === void 0 ? void 0 : paxBounds.min) !== undefined) pendingRequestPaxMin = paxBounds.min;
|
|
2592
|
+
if ((paxBounds === null || paxBounds === void 0 ? void 0 : paxBounds.max) !== undefined) pendingRequestPaxMax = paxBounds.max;
|
|
1809
2593
|
}
|
|
1810
2594
|
} else {
|
|
1811
2595
|
this.enabledReservationRuleProducts = [];
|
|
1812
|
-
if (this.store.resource) {
|
|
1813
|
-
delete this.store.resource.requestEntryPax;
|
|
1814
|
-
delete this.store.resource.requestPaxMin;
|
|
1815
|
-
delete this.store.resource.requestPaxMax;
|
|
1816
|
-
}
|
|
1817
2596
|
void this.addScanOrderLog({
|
|
1818
2597
|
level: 'error',
|
|
1819
2598
|
title: '[ScanOrder] enabled_reservation_rules product query failed',
|
|
@@ -1823,41 +2602,80 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1823
2602
|
}
|
|
1824
2603
|
});
|
|
1825
2604
|
}
|
|
1826
|
-
case
|
|
2605
|
+
case 43:
|
|
2606
|
+
_context36.next = 45;
|
|
2607
|
+
return this.fetchResourceOccupyDetailByResourceId(resourceId);
|
|
2608
|
+
case 45:
|
|
2609
|
+
occupyDetail = _context36.sent;
|
|
2610
|
+
// Step3: 结合预约规则商品的 product_resource.resources 与占用接口返回的 form_id,
|
|
2611
|
+
// 计算当前桌台的 resourceSelectType(single/multiple/capacity)
|
|
2612
|
+
resourceSelectType = this.resolveResourceSelectType(toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_id)); // Step4: 用 occupyDetail + resourceSelectType 规整为 resourceState
|
|
2613
|
+
resourceState = this.normalizeResourceState(occupyDetail, resourceSelectType, hasOrderId);
|
|
2614
|
+
this.store.resource = resourceState;
|
|
2615
|
+
|
|
2616
|
+
// Step5: 把预约规则商品阶段暂存的 requestEntryPax 等注入 store.resource
|
|
2617
|
+
if (pendingRequestEntryPax !== undefined) {
|
|
2618
|
+
this.store.resource.requestEntryPax = pendingRequestEntryPax;
|
|
2619
|
+
}
|
|
2620
|
+
if (pendingRequestPaxMin !== undefined) {
|
|
2621
|
+
this.store.resource.requestPaxMin = pendingRequestPaxMin;
|
|
2622
|
+
}
|
|
2623
|
+
if (pendingRequestPaxMax !== undefined) {
|
|
2624
|
+
this.store.resource.requestPaxMax = pendingRequestPaxMax;
|
|
2625
|
+
}
|
|
2626
|
+
availabilityInfo = _objectSpread(_objectSpread(_objectSpread({
|
|
2627
|
+
mode: resourceState.mode,
|
|
2628
|
+
order_id: resourceState.order_id,
|
|
2629
|
+
relation_id: resourceState.relationId,
|
|
2630
|
+
table_form_id: resourceState.tableFormId,
|
|
2631
|
+
deskmate_valid: resourceState.deskmate_valid,
|
|
2632
|
+
table_form_record: resourceState.table_form_record,
|
|
2633
|
+
policy: occupyDetail === null || occupyDetail === void 0 || (_occupyDetail$form_re = occupyDetail.form_record) === null || _occupyDetail$form_re === void 0 ? void 0 : _occupyDetail$form_re.policy,
|
|
2634
|
+
partyroom_booking: occupyDetail === null || occupyDetail === void 0 || (_occupyDetail$form_re2 = occupyDetail.form_record) === null || _occupyDetail$form_re2 === void 0 ? void 0 : _occupyDetail$form_re2.partyroom_booking
|
|
2635
|
+
}, this.store.resource.requestEntryPax !== undefined ? {
|
|
2636
|
+
requestEntryPax: this.store.resource.requestEntryPax
|
|
2637
|
+
} : {}), this.store.resource.requestPaxMin !== undefined ? {
|
|
2638
|
+
requestPaxMin: this.store.resource.requestPaxMin
|
|
2639
|
+
} : {}), this.store.resource.requestPaxMax !== undefined ? {
|
|
2640
|
+
requestPaxMax: this.store.resource.requestPaxMax
|
|
2641
|
+
} : {});
|
|
2642
|
+
tempOrder.relation_id = resourceId || ((_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.relation_id);
|
|
2643
|
+
tempOrder.table_form_id = resourceState.tableFormId;
|
|
2644
|
+
tempOrder.resource_id = resourceId;
|
|
1827
2645
|
(_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 || _this$store$order5.persistTempOrder();
|
|
1828
2646
|
|
|
1829
2647
|
// 空闲状态下自动准备本地临时订单,供后续“购物车式”商品操作使用
|
|
1830
2648
|
if (!(availabilityInfo.mode === 'idle')) {
|
|
1831
|
-
|
|
2649
|
+
_context36.next = 60;
|
|
1832
2650
|
break;
|
|
1833
2651
|
}
|
|
1834
|
-
|
|
2652
|
+
_context36.next = 60;
|
|
1835
2653
|
return this.addNewOrder();
|
|
1836
|
-
case
|
|
2654
|
+
case 60:
|
|
1837
2655
|
// 如果是加单模式,tempOrder 里 需要记录 lastOrderId,提交的时候走加单接口
|
|
1838
2656
|
if (availabilityInfo.mode === 'additional_order' || availabilityInfo.mode === 'additional_order_with_code') {
|
|
1839
2657
|
tempOrder.order_id = resourceState.lastOrderId;
|
|
1840
2658
|
}
|
|
1841
2659
|
if (!tempOrder.order_id) {
|
|
1842
|
-
|
|
2660
|
+
_context36.next = 69;
|
|
1843
2661
|
break;
|
|
1844
2662
|
}
|
|
1845
|
-
|
|
2663
|
+
_context36.next = 64;
|
|
1846
2664
|
return (_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 ? void 0 : _this$store$order6.getOrderInfoByRemote(tempOrder.order_id);
|
|
1847
|
-
case
|
|
1848
|
-
res =
|
|
2665
|
+
case 64:
|
|
2666
|
+
res = _context36.sent;
|
|
1849
2667
|
// 找到下单的时候输入的 entryPaxNumber
|
|
1850
2668
|
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) {
|
|
1851
2669
|
var _p$metadata;
|
|
1852
2670
|
return (_p$metadata = p.metadata) === null || _p$metadata === void 0 ? void 0 : _p$metadata.collect_pax;
|
|
1853
2671
|
})) === null || _res$data === void 0 || (_res$data = _res$data.metadata) === null || _res$data === void 0 ? void 0 : _res$data.collect_pax;
|
|
1854
2672
|
if (!entryPaxNumber) {
|
|
1855
|
-
|
|
2673
|
+
_context36.next = 69;
|
|
1856
2674
|
break;
|
|
1857
2675
|
}
|
|
1858
|
-
|
|
2676
|
+
_context36.next = 69;
|
|
1859
2677
|
return this.setEntryPaxNumber(entryPaxNumber);
|
|
1860
|
-
case
|
|
2678
|
+
case 69:
|
|
1861
2679
|
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);
|
|
1862
2680
|
historicalItems = hasOrderId && Array.isArray(lastOrderInfo === null || lastOrderInfo === void 0 ? void 0 : lastOrderInfo.products) ? lastOrderInfo.products.reduce(function (acc, p) {
|
|
1863
2681
|
if (typeof (p === null || p === void 0 ? void 0 : p.product_id) !== 'number') return acc;
|
|
@@ -1869,13 +2687,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1869
2687
|
} : {}));
|
|
1870
2688
|
return acc;
|
|
1871
2689
|
}, []) : []; // pax 由 setEntryPaxNumber 负责写入 itemRuleRuntimeConfig.pax
|
|
1872
|
-
|
|
2690
|
+
_context36.next = 73;
|
|
1873
2691
|
return this.setItemRuleRuntimeConfig({
|
|
1874
|
-
serviceType: (_this$
|
|
2692
|
+
serviceType: (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.businessCode,
|
|
1875
2693
|
submissionIndex: hasOrderId ? 1 : 0,
|
|
1876
2694
|
historicalItems: historicalItems
|
|
1877
2695
|
});
|
|
1878
|
-
case
|
|
2696
|
+
case 73:
|
|
2697
|
+
// operating_hours 超出营业时段 + closed_behavior=show_menu_disabled:
|
|
2698
|
+
// 允许浏览商品但 UI 层需拦截“下一步”,这里覆盖最终 mode 并回传错误提示
|
|
2699
|
+
if (outsideOperatingHours && closedBehaviorValue === 'show_menu_disabled') {
|
|
2700
|
+
availabilityInfo.mode = 'submit_disabled';
|
|
2701
|
+
availabilityInfo.errorTips = closedMessage;
|
|
2702
|
+
availabilityInfo.closed_behavior = closedBehaviorValue;
|
|
2703
|
+
}
|
|
1879
2704
|
this.logMethodSuccess('checkResourceAvailable', {
|
|
1880
2705
|
resourceId: resourceId,
|
|
1881
2706
|
mode: availabilityInfo.mode,
|
|
@@ -1885,26 +2710,25 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1885
2710
|
persistedRelationId: tempOrder.relation_id,
|
|
1886
2711
|
persistedResourceId: tempOrder.resource_id,
|
|
1887
2712
|
deskmateValid: availabilityInfo.deskmate_valid,
|
|
1888
|
-
|
|
1889
|
-
tableMaxNumber: resourceState.tableMaxNumber,
|
|
2713
|
+
resourceSelectType: resourceState.resourceSelectType,
|
|
1890
2714
|
isExclusive: resourceState.isExclusive,
|
|
1891
2715
|
isFull: resourceState.isFull
|
|
1892
2716
|
});
|
|
1893
|
-
return
|
|
1894
|
-
case
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
this.logMethodError('checkResourceAvailable',
|
|
2717
|
+
return _context36.abrupt("return", availabilityInfo);
|
|
2718
|
+
case 78:
|
|
2719
|
+
_context36.prev = 78;
|
|
2720
|
+
_context36.t0 = _context36["catch"](1);
|
|
2721
|
+
this.logMethodError('checkResourceAvailable', _context36.t0.message, {
|
|
1898
2722
|
resourceId: resourceId
|
|
1899
2723
|
});
|
|
1900
|
-
throw
|
|
1901
|
-
case
|
|
2724
|
+
throw _context36.t0;
|
|
2725
|
+
case 82:
|
|
1902
2726
|
case "end":
|
|
1903
|
-
return
|
|
2727
|
+
return _context36.stop();
|
|
1904
2728
|
}
|
|
1905
|
-
},
|
|
2729
|
+
}, _callee36, this, [[1, 78]]);
|
|
1906
2730
|
}));
|
|
1907
|
-
function checkResourceAvailable(
|
|
2731
|
+
function checkResourceAvailable(_x18, _x19) {
|
|
1908
2732
|
return _checkResourceAvailable.apply(this, arguments);
|
|
1909
2733
|
}
|
|
1910
2734
|
return checkResourceAvailable;
|
|
@@ -1912,10 +2736,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1912
2736
|
}, {
|
|
1913
2737
|
key: "getAdditionalOrderInfo",
|
|
1914
2738
|
value: function () {
|
|
1915
|
-
var _getAdditionalOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2739
|
+
var _getAdditionalOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {
|
|
1916
2740
|
var result;
|
|
1917
|
-
return _regeneratorRuntime().wrap(function
|
|
1918
|
-
while (1) switch (
|
|
2741
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
2742
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
1919
2743
|
case 0:
|
|
1920
2744
|
this.logMethodStart('getAdditionalOrderInfo');
|
|
1921
2745
|
result = {
|
|
@@ -1929,12 +2753,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1929
2753
|
orderId: result.orderId,
|
|
1930
2754
|
orderStatus: result.orderStatus
|
|
1931
2755
|
});
|
|
1932
|
-
return
|
|
2756
|
+
return _context37.abrupt("return", result);
|
|
1933
2757
|
case 4:
|
|
1934
2758
|
case "end":
|
|
1935
|
-
return
|
|
2759
|
+
return _context37.stop();
|
|
1936
2760
|
}
|
|
1937
|
-
},
|
|
2761
|
+
}, _callee37, this);
|
|
1938
2762
|
}));
|
|
1939
2763
|
function getAdditionalOrderInfo() {
|
|
1940
2764
|
return _getAdditionalOrderInfo.apply(this, arguments);
|
|
@@ -1944,19 +2768,19 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1944
2768
|
}, {
|
|
1945
2769
|
key: "getProductList",
|
|
1946
2770
|
value: function () {
|
|
1947
|
-
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1948
|
-
var _this$
|
|
2771
|
+
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
|
|
2772
|
+
var _this$otherParams13;
|
|
1949
2773
|
var menu_list_ids, _this$store$products, res, formattedRes;
|
|
1950
|
-
return _regeneratorRuntime().wrap(function
|
|
1951
|
-
while (1) switch (
|
|
2774
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
2775
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
1952
2776
|
case 0:
|
|
1953
2777
|
this.logMethodStart('getProductList');
|
|
1954
2778
|
// 可以直接通过配置里的 menu 读取
|
|
1955
|
-
menu_list_ids = ((_this$
|
|
2779
|
+
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) {
|
|
1956
2780
|
return Number(n.value);
|
|
1957
2781
|
})) || [];
|
|
1958
|
-
|
|
1959
|
-
|
|
2782
|
+
_context38.prev = 2;
|
|
2783
|
+
_context38.next = 5;
|
|
1960
2784
|
return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
|
|
1961
2785
|
menu_list_ids: menu_list_ids,
|
|
1962
2786
|
cacheId: this.cacheId,
|
|
@@ -1964,22 +2788,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1964
2788
|
schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
1965
2789
|
});
|
|
1966
2790
|
case 5:
|
|
1967
|
-
res =
|
|
2791
|
+
res = _context38.sent;
|
|
1968
2792
|
formattedRes = attachItemRuleLimitsToTopLevelProducts(res, this.store.itemRuleQuantityLimits || []);
|
|
1969
2793
|
this.logMethodSuccess('getProductList', {
|
|
1970
2794
|
menuCount: menu_list_ids.length
|
|
1971
2795
|
});
|
|
1972
|
-
return
|
|
2796
|
+
return _context38.abrupt("return", formattedRes);
|
|
1973
2797
|
case 11:
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
this.logMethodError('getProductList',
|
|
1977
|
-
throw
|
|
2798
|
+
_context38.prev = 11;
|
|
2799
|
+
_context38.t0 = _context38["catch"](2);
|
|
2800
|
+
this.logMethodError('getProductList', _context38.t0.message);
|
|
2801
|
+
throw _context38.t0;
|
|
1978
2802
|
case 15:
|
|
1979
2803
|
case "end":
|
|
1980
|
-
return
|
|
2804
|
+
return _context38.stop();
|
|
1981
2805
|
}
|
|
1982
|
-
},
|
|
2806
|
+
}, _callee38, this, [[2, 11]]);
|
|
1983
2807
|
}));
|
|
1984
2808
|
function getProductList() {
|
|
1985
2809
|
return _getProductList.apply(this, arguments);
|
|
@@ -1994,15 +2818,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1994
2818
|
}, {
|
|
1995
2819
|
key: "setOtherParams",
|
|
1996
2820
|
value: function () {
|
|
1997
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1998
|
-
var
|
|
1999
|
-
|
|
2821
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
|
|
2822
|
+
var _ref8,
|
|
2823
|
+
_ref8$cover,
|
|
2000
2824
|
cover,
|
|
2001
|
-
|
|
2002
|
-
return _regeneratorRuntime().wrap(function
|
|
2003
|
-
while (1) switch (
|
|
2825
|
+
_args39 = arguments;
|
|
2826
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
2827
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
2004
2828
|
case 0:
|
|
2005
|
-
|
|
2829
|
+
_ref8 = _args39.length > 1 && _args39[1] !== undefined ? _args39[1] : {}, _ref8$cover = _ref8.cover, cover = _ref8$cover === void 0 ? false : _ref8$cover;
|
|
2006
2830
|
if (cover) {
|
|
2007
2831
|
this.otherParams = params;
|
|
2008
2832
|
} else {
|
|
@@ -2010,22 +2834,104 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2010
2834
|
}
|
|
2011
2835
|
case 2:
|
|
2012
2836
|
case "end":
|
|
2013
|
-
return
|
|
2837
|
+
return _context39.stop();
|
|
2014
2838
|
}
|
|
2015
|
-
},
|
|
2839
|
+
}, _callee39, this);
|
|
2016
2840
|
}));
|
|
2017
|
-
function setOtherParams(
|
|
2841
|
+
function setOtherParams(_x20) {
|
|
2018
2842
|
return _setOtherParams.apply(this, arguments);
|
|
2019
2843
|
}
|
|
2020
2844
|
return setOtherParams;
|
|
2021
|
-
}()
|
|
2845
|
+
}() // ─── UI 状态缓存(按 cacheId 分桶,localStorage) ───
|
|
2846
|
+
//
|
|
2847
|
+
// 用于物料层持久化 UI 层面的轻量状态(如当前步骤、gate 标记、登录回跳意图等)。
|
|
2848
|
+
// 桶键:pisell.scanOrder.uiState:<cacheId>;内部以 JSON object 形式存储多个字段。
|
|
2849
|
+
// 无 cacheId 时所有方法自动降级为 no-op,上层不用判空。
|
|
2850
|
+
//
|
|
2851
|
+
// 之所以用 localStorage 而不是 sessionStorage:
|
|
2852
|
+
// 1. 与 Order 模块 openCache 下的 tempOrder 同栈,购物车在 / UIState 在,行为对齐;
|
|
2853
|
+
// 2. pisell1.login 整页 OAuth 跳转在 H5 壳 / iOS Safari 场景下可能丢 sessionStorage,
|
|
2854
|
+
// 导致登录回跳后 gate 标记失效、pax 弹窗重开、落点错误;localStorage 稳定不受影响。
|
|
2855
|
+
// 3. 失效由上层显式控制:提交成功 clearStepCache / entryContext 不一致 clearUIState /
|
|
2856
|
+
// pendingStep 登录回调 deleteUIState,足够约束生命周期。
|
|
2857
|
+
}, {
|
|
2858
|
+
key: "getUIStateBucketKey",
|
|
2859
|
+
value: function getUIStateBucketKey() {
|
|
2860
|
+
if (!this.cacheId) return null;
|
|
2861
|
+
return "".concat(ScanOrderImpl.UI_STATE_KEY_PREFIX).concat(this.cacheId);
|
|
2862
|
+
}
|
|
2863
|
+
}, {
|
|
2864
|
+
key: "readUIStateBucket",
|
|
2865
|
+
value: function readUIStateBucket() {
|
|
2866
|
+
var _this$window;
|
|
2867
|
+
var key = this.getUIStateBucketKey();
|
|
2868
|
+
if (!key || !((_this$window = this.window) !== null && _this$window !== void 0 && _this$window.localStorage)) return {};
|
|
2869
|
+
try {
|
|
2870
|
+
var raw = this.window.localStorage.getItem(key) || '{}';
|
|
2871
|
+
var parsed = JSON.parse(raw);
|
|
2872
|
+
return parsed && _typeof(parsed) === 'object' ? parsed : {};
|
|
2873
|
+
} catch (_unused) {
|
|
2874
|
+
return {};
|
|
2875
|
+
}
|
|
2876
|
+
}
|
|
2877
|
+
}, {
|
|
2878
|
+
key: "writeUIStateBucket",
|
|
2879
|
+
value: function writeUIStateBucket(bucket) {
|
|
2880
|
+
var _this$window2;
|
|
2881
|
+
var key = this.getUIStateBucketKey();
|
|
2882
|
+
if (!key || !((_this$window2 = this.window) !== null && _this$window2 !== void 0 && _this$window2.localStorage)) return;
|
|
2883
|
+
try {
|
|
2884
|
+
this.window.localStorage.setItem(key, JSON.stringify(bucket));
|
|
2885
|
+
} catch (error) {
|
|
2886
|
+
console.warn('[ScanOrder] writeUIStateBucket failed', error);
|
|
2887
|
+
}
|
|
2888
|
+
}
|
|
2889
|
+
}, {
|
|
2890
|
+
key: "setUIState",
|
|
2891
|
+
value: function setUIState(key, value) {
|
|
2892
|
+
if (!this.getUIStateBucketKey()) return;
|
|
2893
|
+
var bucket = this.readUIStateBucket();
|
|
2894
|
+
bucket[key] = value;
|
|
2895
|
+
this.writeUIStateBucket(bucket);
|
|
2896
|
+
}
|
|
2897
|
+
}, {
|
|
2898
|
+
key: "getUIState",
|
|
2899
|
+
value: function getUIState(key) {
|
|
2900
|
+
if (!this.getUIStateBucketKey()) return undefined;
|
|
2901
|
+
var bucket = this.readUIStateBucket();
|
|
2902
|
+
return bucket[key];
|
|
2903
|
+
}
|
|
2904
|
+
}, {
|
|
2905
|
+
key: "deleteUIState",
|
|
2906
|
+
value: function deleteUIState(key) {
|
|
2907
|
+
if (!this.getUIStateBucketKey()) return;
|
|
2908
|
+
var bucket = this.readUIStateBucket();
|
|
2909
|
+
if (key in bucket) {
|
|
2910
|
+
delete bucket[key];
|
|
2911
|
+
this.writeUIStateBucket(bucket);
|
|
2912
|
+
}
|
|
2913
|
+
}
|
|
2914
|
+
|
|
2915
|
+
// 整桶清空(用于扫新桌、提交成功、restoreOrder 等场景)
|
|
2916
|
+
}, {
|
|
2917
|
+
key: "clearUIState",
|
|
2918
|
+
value: function clearUIState() {
|
|
2919
|
+
var _this$window3;
|
|
2920
|
+
var key = this.getUIStateBucketKey();
|
|
2921
|
+
if (!key || !((_this$window3 = this.window) !== null && _this$window3 !== void 0 && _this$window3.localStorage)) return;
|
|
2922
|
+
try {
|
|
2923
|
+
this.window.localStorage.removeItem(key);
|
|
2924
|
+
} catch (error) {
|
|
2925
|
+
console.warn('[ScanOrder] clearUIState failed', error);
|
|
2926
|
+
}
|
|
2927
|
+
}
|
|
2022
2928
|
}, {
|
|
2023
2929
|
key: "setEntryPaxNumber",
|
|
2024
2930
|
value: function () {
|
|
2025
|
-
var _setEntryPaxNumber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2931
|
+
var _setEntryPaxNumber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(number) {
|
|
2026
2932
|
var pax, t;
|
|
2027
|
-
return _regeneratorRuntime().wrap(function
|
|
2028
|
-
while (1) switch (
|
|
2933
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
2934
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
2029
2935
|
case 0:
|
|
2030
2936
|
pax = normalizeSubmitCollectPaxValue(number);
|
|
2031
2937
|
this.store.entryPaxNumber = pax;
|
|
@@ -2046,18 +2952,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2046
2952
|
}
|
|
2047
2953
|
});
|
|
2048
2954
|
this.itemRulePrefillApplied = false;
|
|
2049
|
-
|
|
2955
|
+
_context40.next = 7;
|
|
2050
2956
|
return this.refreshItemRuleQuantityLimits();
|
|
2051
2957
|
case 7:
|
|
2052
|
-
|
|
2958
|
+
_context40.next = 9;
|
|
2053
2959
|
return this.refreshCartValidationPassed();
|
|
2054
2960
|
case 9:
|
|
2055
2961
|
case "end":
|
|
2056
|
-
return
|
|
2962
|
+
return _context40.stop();
|
|
2057
2963
|
}
|
|
2058
|
-
},
|
|
2964
|
+
}, _callee40, this);
|
|
2059
2965
|
}));
|
|
2060
|
-
function setEntryPaxNumber(
|
|
2966
|
+
function setEntryPaxNumber(_x21) {
|
|
2061
2967
|
return _setEntryPaxNumber.apply(this, arguments);
|
|
2062
2968
|
}
|
|
2063
2969
|
return setEntryPaxNumber;
|
|
@@ -2067,6 +2973,48 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2067
2973
|
value: function getEntryPaxNumber() {
|
|
2068
2974
|
return this.store.entryPaxNumber;
|
|
2069
2975
|
}
|
|
2976
|
+
|
|
2977
|
+
// 读取取餐/送餐开关
|
|
2978
|
+
// 依赖 checkResourceAvailable 已缓存的 dineInConfig
|
|
2979
|
+
}, {
|
|
2980
|
+
key: "getFulfillmentModes",
|
|
2981
|
+
value: function getFulfillmentModes() {
|
|
2982
|
+
var _this$otherParams14;
|
|
2983
|
+
this.logMethodStart('getFulfillmentModes');
|
|
2984
|
+
var dineInConfig = ((_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.dineInConfig) || {};
|
|
2985
|
+
var result = {
|
|
2986
|
+
enablePickup: Boolean(dineInConfig['fulfillment.enable_pickup']),
|
|
2987
|
+
enableTableService: Boolean(dineInConfig['fulfillment.enable_table_service'])
|
|
2988
|
+
};
|
|
2989
|
+
this.logMethodSuccess('getFulfillmentModes', result);
|
|
2990
|
+
return result;
|
|
2991
|
+
}
|
|
2992
|
+
|
|
2993
|
+
// 判定后台是否开启客户自定义取餐标识
|
|
2994
|
+
// 依赖 checkResourceAvailable 已缓存的 dineInConfig
|
|
2995
|
+
}, {
|
|
2996
|
+
key: "checkManualPickupRef",
|
|
2997
|
+
value: function checkManualPickupRef() {
|
|
2998
|
+
var _this$otherParams15;
|
|
2999
|
+
this.logMethodStart('checkManualPickupRef');
|
|
3000
|
+
var dineInConfig = ((_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.dineInConfig) || {};
|
|
3001
|
+
var refMode = dineInConfig['fulfillment.fulfillment_ref_mode'];
|
|
3002
|
+
var manualInputType = dineInConfig['fulfillment.manual_input_type'];
|
|
3003
|
+
var enabled = refMode === 'manual_input';
|
|
3004
|
+
var result = enabled ? {
|
|
3005
|
+
enabled: true,
|
|
3006
|
+
manualInputType: manualInputType
|
|
3007
|
+
} : {
|
|
3008
|
+
enabled: false
|
|
3009
|
+
};
|
|
3010
|
+
this.logMethodSuccess('checkManualPickupRef', {
|
|
3011
|
+
enabled: enabled,
|
|
3012
|
+
manualInputType: enabled ? manualInputType : undefined
|
|
3013
|
+
});
|
|
3014
|
+
return result;
|
|
3015
|
+
}
|
|
2070
3016
|
}]);
|
|
2071
3017
|
return ScanOrderImpl;
|
|
2072
|
-
}(BaseModule);
|
|
3018
|
+
}(BaseModule);
|
|
3019
|
+
_defineProperty(ScanOrderImpl, "PISELL1_LOGIN_SUCCESS", 'pisell1.login.success');
|
|
3020
|
+
_defineProperty(ScanOrderImpl, "UI_STATE_KEY_PREFIX", 'pisell.scanOrder.uiState:');
|