@pisell/pisellos 2.1.129 → 2.1.130
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/Order/index.d.ts +4 -0
- package/dist/modules/Order/index.js +18 -1
- package/dist/modules/Order/types.d.ts +9 -1
- package/dist/modules/Order/utils.d.ts +7 -0
- package/dist/modules/Order/utils.js +27 -11
- package/dist/solution/ScanOrder/index.d.ts +27 -3
- package/dist/solution/ScanOrder/index.js +865 -481
- package/dist/solution/ScanOrder/types.d.ts +34 -24
- package/dist/solution/ScanOrder/types.js +5 -1
- package/dist/solution/ScanOrder/utils.d.ts +13 -1
- package/dist/solution/ScanOrder/utils.js +45 -6
- package/dist/solution/VenueBooking/index.d.ts +28 -5
- package/dist/solution/VenueBooking/index.js +428 -193
- 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 +4 -0
- package/lib/modules/Order/index.js +14 -1
- package/lib/modules/Order/types.d.ts +9 -1
- package/lib/modules/Order/utils.d.ts +7 -0
- package/lib/modules/Order/utils.js +22 -12
- package/lib/solution/ScanOrder/index.d.ts +27 -3
- package/lib/solution/ScanOrder/index.js +409 -114
- package/lib/solution/ScanOrder/types.d.ts +34 -24
- package/lib/solution/ScanOrder/utils.d.ts +13 -1
- package/lib/solution/ScanOrder/utils.js +37 -0
- package/lib/solution/VenueBooking/index.d.ts +28 -5
- package/lib/solution/VenueBooking/index.js +193 -45
- 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,5 +1,9 @@
|
|
|
1
1
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
2
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
|
+
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."); }
|
|
2
4
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
5
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
3
7
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
4
8
|
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; }
|
|
@@ -22,10 +26,12 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
22
26
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
23
27
|
import { BaseModule } from "../../modules/BaseModule";
|
|
24
28
|
import { ScanOrderHooks } from "./types";
|
|
25
|
-
import { attachItemRuleLimitsToTopLevelProducts, buildProductKey, buildItemRuleBusinessData, collectLinkProductIdsFromReservationRules, createEmptySummary, getProductIdentityIndex, getSafeProductNum, hasCustomCapacityProduct, pickFirstCustomCapacityPaxBounds, normalizeEnabledItemRuleIds, normalizeOrderProduct, normalizeItemRuleStrategies, pickFirstDurationMinutesFromProducts, toNonNegativeInt,
|
|
29
|
+
import { attachItemRuleLimitsToTopLevelProducts, buildProductKey, buildItemRuleBusinessData, collectLinkProductIdsFromReservationRules, computeResourceIsFull, createEmptySummary, getProductIdentityIndex, getSafeProductNum, hasCustomCapacityProduct, pickFirstCustomCapacityPaxBounds, normalizeEnabledItemRuleIds, normalizeOrderProduct, normalizeItemRuleStrategies, pickFirstDurationMinutesFromProducts, toNonNegativeInt, toPriceString, toBoolean, toPositiveString } from "./utils";
|
|
26
30
|
import { createModule } from "../BookingByStep/types";
|
|
27
31
|
import { ProductList } from "../../modules/ProductList";
|
|
28
|
-
import {
|
|
32
|
+
import { ScheduleModule } from "../../modules/Schedule";
|
|
33
|
+
import { getDateIsInSchedule } from "../../modules/Schedule/getDateIsInSchedule";
|
|
34
|
+
import { createUuidV4, normalizeSubmitCollectPaxValue } from "../../modules/Order/utils";
|
|
29
35
|
import dayjs from 'dayjs';
|
|
30
36
|
import { ItemRuleEvaluator } from "../../model/strategy/adapter/itemRule";
|
|
31
37
|
export * from "./types";
|
|
@@ -81,11 +87,11 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
81
87
|
key: "serializeError",
|
|
82
88
|
value: function serializeError(error) {
|
|
83
89
|
if (error instanceof Error) {
|
|
84
|
-
return {
|
|
90
|
+
return JSON.stringify({
|
|
85
91
|
name: error.name,
|
|
86
92
|
message: error.message,
|
|
87
93
|
stack: error.stack
|
|
88
|
-
};
|
|
94
|
+
});
|
|
89
95
|
}
|
|
90
96
|
return {
|
|
91
97
|
message: String(error)
|
|
@@ -210,6 +216,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
210
216
|
_this2 = this;
|
|
211
217
|
var options,
|
|
212
218
|
moduleArr,
|
|
219
|
+
scheduleModule,
|
|
213
220
|
_this$store$order,
|
|
214
221
|
_this$store$order2,
|
|
215
222
|
_args3 = arguments;
|
|
@@ -263,7 +270,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
263
270
|
var loggerProvider = ((_this2$otherParams = _this2.otherParams) === null || _this2$otherParams === void 0 ? void 0 : _this2$otherParams.scanOrderLoggerProvider) || 'feishu';
|
|
264
271
|
var loggerConfig = ((_this2$otherParams2 = _this2.otherParams) === null || _this2$otherParams2 === void 0 ? void 0 : _this2$otherParams2.scanOrderLoggerConfig) || {
|
|
265
272
|
feishu: {
|
|
266
|
-
|
|
273
|
+
webhook: 'https://open.feishu.cn/open-apis/bot/v2/hook/216b3fe6-af98-424e-8706-f0471241a7ed'
|
|
267
274
|
}
|
|
268
275
|
};
|
|
269
276
|
_this2.core.registerModule(targetModule, {
|
|
@@ -286,47 +293,69 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
286
293
|
if (this.store.scanOrderLogger) {
|
|
287
294
|
this.store.scanOrderLogger.setContext(this.getScanOrderLoggerContext());
|
|
288
295
|
}
|
|
296
|
+
scheduleModule = new ScheduleModule("".concat(this.name, "_schedule"));
|
|
297
|
+
this.store.schedule = scheduleModule;
|
|
298
|
+
this.core.registerModule(scheduleModule, {
|
|
299
|
+
otherParams: _objectSpread(_objectSpread({}, this.otherParams), {}, {
|
|
300
|
+
fatherModule: this.name
|
|
301
|
+
})
|
|
302
|
+
});
|
|
289
303
|
console.log('[ScanOrder] 初始化开始');
|
|
290
|
-
_context3.prev =
|
|
291
|
-
_context3.next =
|
|
304
|
+
_context3.prev = 31;
|
|
305
|
+
_context3.next = 34;
|
|
292
306
|
return (_this$store$order = this.store.order) === null || _this$store$order === void 0 ? void 0 : _this$store$order.recalculateSummary({
|
|
293
307
|
createIfMissing: false
|
|
294
308
|
});
|
|
295
|
-
case
|
|
309
|
+
case 34:
|
|
296
310
|
(_this$store$order2 = this.store.order) === null || _this$store$order2 === void 0 || _this$store$order2.persistTempOrder();
|
|
297
|
-
_context3.next =
|
|
311
|
+
_context3.next = 37;
|
|
298
312
|
return this.loadRuntimeConfigs();
|
|
299
|
-
case
|
|
300
|
-
|
|
313
|
+
case 37:
|
|
314
|
+
if (!this.store.schedule) {
|
|
315
|
+
_context3.next = 46;
|
|
316
|
+
break;
|
|
317
|
+
}
|
|
318
|
+
_context3.prev = 38;
|
|
319
|
+
_context3.next = 41;
|
|
320
|
+
return this.store.schedule.loadAllSchedule();
|
|
321
|
+
case 41:
|
|
322
|
+
_context3.next = 46;
|
|
323
|
+
break;
|
|
324
|
+
case 43:
|
|
325
|
+
_context3.prev = 43;
|
|
326
|
+
_context3.t0 = _context3["catch"](38);
|
|
327
|
+
console.warn('[ScanOrder] loadAllSchedule 失败,operating_hours 判定将跳过', _context3.t0);
|
|
328
|
+
case 46:
|
|
329
|
+
_context3.next = 48;
|
|
301
330
|
return this.refreshItemRuleQuantityLimits();
|
|
302
|
-
case
|
|
331
|
+
case 48:
|
|
303
332
|
this.store.status = 'ready';
|
|
304
333
|
console.log('[ScanOrder] 初始化完成');
|
|
305
|
-
_context3.next =
|
|
334
|
+
_context3.next = 52;
|
|
306
335
|
return this.core.effects.emit(ScanOrderHooks.onInited, {
|
|
307
336
|
status: this.store.status
|
|
308
337
|
});
|
|
309
|
-
case
|
|
338
|
+
case 52:
|
|
310
339
|
this.logMethodSuccess('initialize', {
|
|
311
340
|
status: this.store.status
|
|
312
341
|
});
|
|
313
|
-
_context3.next =
|
|
342
|
+
_context3.next = 62;
|
|
314
343
|
break;
|
|
315
|
-
case
|
|
316
|
-
_context3.prev =
|
|
317
|
-
_context3.
|
|
344
|
+
case 55:
|
|
345
|
+
_context3.prev = 55;
|
|
346
|
+
_context3.t1 = _context3["catch"](31);
|
|
318
347
|
this.store.status = 'error';
|
|
319
|
-
this.store.error = _context3.
|
|
320
|
-
console.error('[ScanOrder] 初始化失败', _context3.
|
|
321
|
-
this.logMethodError('initialize', _context3.
|
|
348
|
+
this.store.error = _context3.t1 instanceof Error ? _context3.t1.message : '初始化失败';
|
|
349
|
+
console.error('[ScanOrder] 初始化失败', _context3.t1);
|
|
350
|
+
this.logMethodError('initialize', _context3.t1, {
|
|
322
351
|
status: this.store.status
|
|
323
352
|
});
|
|
324
|
-
throw _context3.
|
|
325
|
-
case
|
|
353
|
+
throw _context3.t1;
|
|
354
|
+
case 62:
|
|
326
355
|
case "end":
|
|
327
356
|
return _context3.stop();
|
|
328
357
|
}
|
|
329
|
-
}, _callee3, this, [[
|
|
358
|
+
}, _callee3, this, [[31, 55], [38, 43]]);
|
|
330
359
|
}));
|
|
331
360
|
function initialize(_x3) {
|
|
332
361
|
return _initialize.apply(this, arguments);
|
|
@@ -534,6 +563,56 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
534
563
|
throw error;
|
|
535
564
|
}
|
|
536
565
|
}
|
|
566
|
+
|
|
567
|
+
// 存储 UI 层选择的取餐方式到 tempOrder.metadata.shop_service_data
|
|
568
|
+
// service_type 在扫码点餐场景固定为 dine_in
|
|
569
|
+
}, {
|
|
570
|
+
key: "setPickupReferenceMode",
|
|
571
|
+
value: function setPickupReferenceMode(mode) {
|
|
572
|
+
this.logMethodStart('setPickupReferenceMode', {
|
|
573
|
+
mode: mode
|
|
574
|
+
});
|
|
575
|
+
try {
|
|
576
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
577
|
+
var tempOrder = this.store.order.ensureTempOrder();
|
|
578
|
+
tempOrder.metadata = _objectSpread(_objectSpread({}, tempOrder.metadata || {}), {}, {
|
|
579
|
+
shop_service_data: _objectSpread(_objectSpread({}, (tempOrder.metadata || {}).shop_service_data || {}), {}, {
|
|
580
|
+
service_type: 'dine_in',
|
|
581
|
+
pickup_reference_mode: mode
|
|
582
|
+
})
|
|
583
|
+
});
|
|
584
|
+
this.store.order.persistTempOrder();
|
|
585
|
+
this.logMethodSuccess('setPickupReferenceMode', {
|
|
586
|
+
mode: mode
|
|
587
|
+
});
|
|
588
|
+
return tempOrder.metadata.shop_service_data;
|
|
589
|
+
} catch (error) {
|
|
590
|
+
this.logMethodError('setPickupReferenceMode', error, {
|
|
591
|
+
mode: mode
|
|
592
|
+
});
|
|
593
|
+
throw error;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
// 存储用户自定义取餐标识到 tempOrder.buzzer
|
|
598
|
+
}, {
|
|
599
|
+
key: "setPickupRef",
|
|
600
|
+
value: function setPickupRef(buzzer) {
|
|
601
|
+
this.logMethodStart('setPickupRef', {
|
|
602
|
+
buzzerLength: String(buzzer || '').length
|
|
603
|
+
});
|
|
604
|
+
try {
|
|
605
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
606
|
+
var result = this.store.order.updateTempOrderBuzzer(buzzer);
|
|
607
|
+
this.logMethodSuccess('setPickupRef', {
|
|
608
|
+
buzzerLength: result.length
|
|
609
|
+
});
|
|
610
|
+
return result;
|
|
611
|
+
} catch (error) {
|
|
612
|
+
this.logMethodError('setPickupRef', error);
|
|
613
|
+
throw error;
|
|
614
|
+
}
|
|
615
|
+
}
|
|
537
616
|
}, {
|
|
538
617
|
key: "ensureTempOrder",
|
|
539
618
|
value: function ensureTempOrder() {
|
|
@@ -581,6 +660,45 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
581
660
|
return _addNewOrder.apply(this, arguments);
|
|
582
661
|
}
|
|
583
662
|
return addNewOrder;
|
|
663
|
+
}() // 重置 tempOrder 与与上一单强相关的运行态(resource/entryPaxNumber/enabledReservationRuleProducts),
|
|
664
|
+
// 适用于从支付页通过 react-router 跳回继续下单时清理残留数据
|
|
665
|
+
}, {
|
|
666
|
+
key: "restoreOrder",
|
|
667
|
+
value: function () {
|
|
668
|
+
var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
669
|
+
var tempOrder;
|
|
670
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
671
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
672
|
+
case 0:
|
|
673
|
+
this.logMethodStart('restoreOrder');
|
|
674
|
+
_context8.prev = 1;
|
|
675
|
+
if (this.store.order) {
|
|
676
|
+
_context8.next = 4;
|
|
677
|
+
break;
|
|
678
|
+
}
|
|
679
|
+
throw new Error('scanOrder 解决方案需要 order 模块支持');
|
|
680
|
+
case 4:
|
|
681
|
+
this.store.resource = null;
|
|
682
|
+
this.store.entryPaxNumber = 1;
|
|
683
|
+
this.enabledReservationRuleProducts = [];
|
|
684
|
+
tempOrder = this.store.order.restoreOrder();
|
|
685
|
+
this.logMethodSuccess('restoreOrder');
|
|
686
|
+
return _context8.abrupt("return", tempOrder);
|
|
687
|
+
case 12:
|
|
688
|
+
_context8.prev = 12;
|
|
689
|
+
_context8.t0 = _context8["catch"](1);
|
|
690
|
+
this.logMethodError('restoreOrder', _context8.t0);
|
|
691
|
+
throw _context8.t0;
|
|
692
|
+
case 16:
|
|
693
|
+
case "end":
|
|
694
|
+
return _context8.stop();
|
|
695
|
+
}
|
|
696
|
+
}, _callee8, this, [[1, 12]]);
|
|
697
|
+
}));
|
|
698
|
+
function restoreOrder() {
|
|
699
|
+
return _restoreOrder.apply(this, arguments);
|
|
700
|
+
}
|
|
701
|
+
return restoreOrder;
|
|
584
702
|
}()
|
|
585
703
|
}, {
|
|
586
704
|
key: "getOrderProducts",
|
|
@@ -596,58 +714,153 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
596
714
|
}, {
|
|
597
715
|
key: "getSummary",
|
|
598
716
|
value: function () {
|
|
599
|
-
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
717
|
+
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
600
718
|
var summary;
|
|
601
|
-
return _regeneratorRuntime().wrap(function
|
|
602
|
-
while (1) switch (
|
|
719
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
720
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
603
721
|
case 0:
|
|
604
722
|
this.logMethodStart('getSummary');
|
|
605
|
-
|
|
723
|
+
_context9.prev = 1;
|
|
606
724
|
if (this.store.order) {
|
|
607
|
-
|
|
725
|
+
_context9.next = 4;
|
|
608
726
|
break;
|
|
609
727
|
}
|
|
610
728
|
throw new Error('order 模块未初始化');
|
|
611
729
|
case 4:
|
|
612
|
-
|
|
730
|
+
_context9.next = 6;
|
|
613
731
|
return this.store.order.getScanOrderSummary();
|
|
614
732
|
case 6:
|
|
615
|
-
summary =
|
|
733
|
+
summary = _context9.sent;
|
|
616
734
|
this.logMethodSuccess('getSummary', {
|
|
617
735
|
totalAmount: summary.total_amount
|
|
618
736
|
});
|
|
619
|
-
return
|
|
737
|
+
return _context9.abrupt("return", summary);
|
|
620
738
|
case 11:
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
this.logMethodError('getSummary',
|
|
624
|
-
throw
|
|
739
|
+
_context9.prev = 11;
|
|
740
|
+
_context9.t0 = _context9["catch"](1);
|
|
741
|
+
this.logMethodError('getSummary', _context9.t0);
|
|
742
|
+
throw _context9.t0;
|
|
625
743
|
case 15:
|
|
626
744
|
case "end":
|
|
627
|
-
return
|
|
745
|
+
return _context9.stop();
|
|
628
746
|
}
|
|
629
|
-
},
|
|
747
|
+
}, _callee9, this, [[1, 11]]);
|
|
630
748
|
}));
|
|
631
749
|
function getSummary() {
|
|
632
750
|
return _getSummary.apply(this, arguments);
|
|
633
751
|
}
|
|
634
752
|
return getSummary;
|
|
635
|
-
}()
|
|
753
|
+
}() // ScanOrder 提交 payload enhancer:
|
|
754
|
+
// - 给所有 booking 注入 appointment_status: 'started'(扫码点餐语义)
|
|
755
|
+
// - 给所有 booking 的 metadata 注入 resource_select_type(来自预约规则商品的 resource.type)
|
|
756
|
+
// - 给第一条 booking 补 resources 与 product_uid(仅当存在 resource / rule product)
|
|
757
|
+
// - 追加一条 is_rule=true 的 rule product,与 booking 互相关联
|
|
758
|
+
}, {
|
|
759
|
+
key: "buildSubmitPayloadEnhancer",
|
|
760
|
+
value: function buildSubmitPayloadEnhancer() {
|
|
761
|
+
var ruleProduct = this.enabledReservationRuleProducts[0];
|
|
762
|
+
var resourceState = this.store.resource;
|
|
763
|
+
var resourceSelectType = resourceState === null || resourceState === void 0 ? void 0 : resourceState.resourceSelectType;
|
|
764
|
+
|
|
765
|
+
// single 预约独占整张桌台,capacity 取 form_record.capacity;其他情况(multiple / capacity / undefined)占 1 个容量位
|
|
766
|
+
var resolveResourceCapacity = function resolveResourceCapacity() {
|
|
767
|
+
if (resourceSelectType === 'single') {
|
|
768
|
+
var _resourceState$table_;
|
|
769
|
+
var raw = resourceState === null || resourceState === void 0 || (_resourceState$table_ = resourceState.table_form_record) === null || _resourceState$table_ === void 0 ? void 0 : _resourceState$table_.capacity;
|
|
770
|
+
var num = Number(raw);
|
|
771
|
+
if (Number.isFinite(num) && num > 0) return num;
|
|
772
|
+
return 1;
|
|
773
|
+
}
|
|
774
|
+
return 1;
|
|
775
|
+
};
|
|
776
|
+
return function (payload, _ref) {
|
|
777
|
+
var _tempOrder$resource_i, _ref2, _pickOriginal, _resourceState$table_2, _resourceState$relati;
|
|
778
|
+
var bookingUuid = _ref.bookingUuid,
|
|
779
|
+
tempOrder = _ref.tempOrder;
|
|
780
|
+
var resourceId = (_tempOrder$resource_i = tempOrder.resource_id) !== null && _tempOrder$resource_i !== void 0 ? _tempOrder$resource_i : resourceState === null || resourceState === void 0 ? void 0 : resourceState.relationId;
|
|
781
|
+
var pickOriginal = function pickOriginal(value) {
|
|
782
|
+
if (value && _typeof(value) === 'object' && !Array.isArray(value)) {
|
|
783
|
+
var original = value.original;
|
|
784
|
+
return typeof original === 'string' && original.length > 0 ? original : undefined;
|
|
785
|
+
}
|
|
786
|
+
return undefined;
|
|
787
|
+
};
|
|
788
|
+
var mainField = (_ref2 = (_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 && _ref2 !== void 0 ? _ref2 : '';
|
|
789
|
+
var resourceEntry = resourceState && resourceId ? {
|
|
790
|
+
relation_type: 'form',
|
|
791
|
+
like_status: 'common',
|
|
792
|
+
id: Number(resourceId),
|
|
793
|
+
main_field: mainField,
|
|
794
|
+
form_id: resourceState.tableFormId,
|
|
795
|
+
relation_id: (_resourceState$relati = resourceState.relationId) !== null && _resourceState$relati !== void 0 ? _resourceState$relati : resourceId,
|
|
796
|
+
capacity: resolveResourceCapacity(),
|
|
797
|
+
metadata: {}
|
|
798
|
+
} : undefined;
|
|
799
|
+
var ruleProductUid = ruleProduct ? createUuidV4() : undefined;
|
|
800
|
+
var bookingCapacityValue = resolveResourceCapacity();
|
|
801
|
+
var nextBookings = (payload.bookings || []).map(function (booking, idx) {
|
|
802
|
+
return _objectSpread(_objectSpread(_objectSpread({}, booking), {}, {
|
|
803
|
+
appointment_status: 'started',
|
|
804
|
+
metadata: _objectSpread(_objectSpread(_objectSpread({}, booking.metadata || {}), resourceSelectType ? {
|
|
805
|
+
resource_select_type: resourceSelectType
|
|
806
|
+
} : {}), resourceSelectType ? {
|
|
807
|
+
capacity: [{
|
|
808
|
+
id: 0,
|
|
809
|
+
value: bookingCapacityValue,
|
|
810
|
+
name: ''
|
|
811
|
+
}]
|
|
812
|
+
} : {})
|
|
813
|
+
}, idx === 0 && resourceEntry ? {
|
|
814
|
+
resources: [resourceEntry]
|
|
815
|
+
} : {}), idx === 0 && ruleProductUid ? {
|
|
816
|
+
product_uid: ruleProductUid
|
|
817
|
+
} : {});
|
|
818
|
+
});
|
|
819
|
+
var nextProducts = _toConsumableArray(payload.products || []);
|
|
820
|
+
if (ruleProduct && ruleProductUid) {
|
|
821
|
+
var _ruleProduct$price, _ref3, _ruleProduct$original, _ruleProduct$is_gst;
|
|
822
|
+
var sellingPrice = String((_ruleProduct$price = ruleProduct.price) !== null && _ruleProduct$price !== void 0 ? _ruleProduct$price : '0.00');
|
|
823
|
+
var originalPrice = String((_ref3 = (_ruleProduct$original = ruleProduct.original_price) !== null && _ruleProduct$original !== void 0 ? _ruleProduct$original : ruleProduct.price) !== null && _ref3 !== void 0 ? _ref3 : '0.00');
|
|
824
|
+
nextProducts.push({
|
|
825
|
+
product_id: ruleProduct.id,
|
|
826
|
+
product_variant_id: 0,
|
|
827
|
+
num: 1,
|
|
828
|
+
selling_price: sellingPrice,
|
|
829
|
+
original_price: originalPrice,
|
|
830
|
+
payment_price: sellingPrice,
|
|
831
|
+
is_charge_tax: (_ruleProduct$is_gst = ruleProduct.is_gst) !== null && _ruleProduct$is_gst !== void 0 ? _ruleProduct$is_gst : 0,
|
|
832
|
+
product_option_item: [],
|
|
833
|
+
discount_list: [],
|
|
834
|
+
product_bundle: [],
|
|
835
|
+
booking_uid: bookingUuid,
|
|
836
|
+
metadata: {
|
|
837
|
+
is_rule: true,
|
|
838
|
+
unique_identification_number: ruleProductUid,
|
|
839
|
+
booking_uid: bookingUuid
|
|
840
|
+
}
|
|
841
|
+
});
|
|
842
|
+
}
|
|
843
|
+
return _objectSpread(_objectSpread({}, payload), {}, {
|
|
844
|
+
bookings: nextBookings,
|
|
845
|
+
products: nextProducts
|
|
846
|
+
});
|
|
847
|
+
};
|
|
848
|
+
}
|
|
636
849
|
}, {
|
|
637
850
|
key: "submitScanOrder",
|
|
638
851
|
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 (
|
|
852
|
+
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
853
|
+
var _this$store$resource, _this$otherParams4, _this$otherParams5, _this$otherParams6, _this$otherParams7, _tempOrder$products, pax, tempOrderForSubmit, resourceTableName, enhancePayload, result, tempOrder;
|
|
854
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
855
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
643
856
|
case 0:
|
|
644
857
|
this.logMethodStart('submitScanOrder');
|
|
645
|
-
|
|
646
|
-
|
|
858
|
+
_context10.prev = 1;
|
|
859
|
+
_context10.next = 4;
|
|
647
860
|
return this.validateBeforeSubmitByItemRule();
|
|
648
861
|
case 4:
|
|
649
862
|
if (this.store.order) {
|
|
650
|
-
|
|
863
|
+
_context10.next = 6;
|
|
651
864
|
break;
|
|
652
865
|
}
|
|
653
866
|
throw new Error('scanOrder解决方案需要 order 模块支持');
|
|
@@ -658,32 +871,41 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
658
871
|
tempOrderForSubmit.metadata = _objectSpread(_objectSpread({}, tempOrderForSubmit.metadata), {}, {
|
|
659
872
|
collect_pax: pax
|
|
660
873
|
});
|
|
874
|
+
tempOrderForSubmit.delivery_type = 'shop_service';
|
|
875
|
+
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;
|
|
876
|
+
if (resourceTableName && _typeof(resourceTableName) === 'object') {
|
|
877
|
+
tempOrderForSubmit.table_number = resourceTableName;
|
|
878
|
+
} else {
|
|
879
|
+
delete tempOrderForSubmit.table_number;
|
|
880
|
+
}
|
|
661
881
|
this.store.order.persistTempOrder();
|
|
662
|
-
|
|
882
|
+
enhancePayload = this.buildSubmitPayloadEnhancer();
|
|
883
|
+
_context10.next = 17;
|
|
663
884
|
return this.store.order.submitTempOrder({
|
|
664
885
|
cacheId: this.cacheId,
|
|
665
886
|
platform: (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.platform,
|
|
666
887
|
businessCode: (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.businessCode,
|
|
667
888
|
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
|
|
889
|
+
type: (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.type,
|
|
890
|
+
enhancePayload: enhancePayload
|
|
669
891
|
});
|
|
670
|
-
case
|
|
671
|
-
result =
|
|
892
|
+
case 17:
|
|
893
|
+
result = _context10.sent;
|
|
672
894
|
tempOrder = this.store.order.getTempOrder();
|
|
673
895
|
this.logMethodSuccess('submitScanOrder', {
|
|
674
896
|
productCount: (tempOrder === null || tempOrder === void 0 || (_tempOrder$products = tempOrder.products) === null || _tempOrder$products === void 0 ? void 0 : _tempOrder$products.length) || 0
|
|
675
897
|
});
|
|
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;
|
|
898
|
+
return _context10.abrupt("return", result);
|
|
682
899
|
case 23:
|
|
900
|
+
_context10.prev = 23;
|
|
901
|
+
_context10.t0 = _context10["catch"](1);
|
|
902
|
+
this.logMethodError('submitScanOrder', _context10.t0);
|
|
903
|
+
throw _context10.t0;
|
|
904
|
+
case 27:
|
|
683
905
|
case "end":
|
|
684
|
-
return
|
|
906
|
+
return _context10.stop();
|
|
685
907
|
}
|
|
686
|
-
},
|
|
908
|
+
}, _callee10, this, [[1, 23]]);
|
|
687
909
|
}));
|
|
688
910
|
function submitScanOrder() {
|
|
689
911
|
return _submitScanOrder.apply(this, arguments);
|
|
@@ -693,46 +915,46 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
693
915
|
}, {
|
|
694
916
|
key: "addProductToOrder",
|
|
695
917
|
value: function () {
|
|
696
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
918
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(product) {
|
|
697
919
|
var products;
|
|
698
|
-
return _regeneratorRuntime().wrap(function
|
|
699
|
-
while (1) switch (
|
|
920
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
921
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
700
922
|
case 0:
|
|
701
923
|
this.logMethodStart('addProductToOrder', {
|
|
702
924
|
product_id: product.product_id,
|
|
703
925
|
product_variant_id: product.product_variant_id
|
|
704
926
|
});
|
|
705
|
-
|
|
927
|
+
_context11.prev = 1;
|
|
706
928
|
if (this.store.order) {
|
|
707
|
-
|
|
929
|
+
_context11.next = 4;
|
|
708
930
|
break;
|
|
709
931
|
}
|
|
710
932
|
throw new Error('order 模块未初始化');
|
|
711
933
|
case 4:
|
|
712
|
-
|
|
934
|
+
_context11.next = 6;
|
|
713
935
|
return this.store.order.addProductToOrder(product);
|
|
714
936
|
case 6:
|
|
715
|
-
products =
|
|
716
|
-
|
|
937
|
+
products = _context11.sent;
|
|
938
|
+
_context11.next = 9;
|
|
717
939
|
return this.refreshItemRuleQuantityLimits();
|
|
718
940
|
case 9:
|
|
719
|
-
|
|
941
|
+
_context11.next = 11;
|
|
720
942
|
return this.refreshCartValidationPassed();
|
|
721
943
|
case 11:
|
|
722
944
|
this.logMethodSuccess('addProductToOrder', {
|
|
723
945
|
productCount: products.length
|
|
724
946
|
});
|
|
725
|
-
return
|
|
947
|
+
return _context11.abrupt("return", products);
|
|
726
948
|
case 15:
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
this.logMethodError('addProductToOrder',
|
|
730
|
-
throw
|
|
949
|
+
_context11.prev = 15;
|
|
950
|
+
_context11.t0 = _context11["catch"](1);
|
|
951
|
+
this.logMethodError('addProductToOrder', _context11.t0);
|
|
952
|
+
throw _context11.t0;
|
|
731
953
|
case 19:
|
|
732
954
|
case "end":
|
|
733
|
-
return
|
|
955
|
+
return _context11.stop();
|
|
734
956
|
}
|
|
735
|
-
},
|
|
957
|
+
}, _callee11, this, [[1, 15]]);
|
|
736
958
|
}));
|
|
737
959
|
function addProductToOrder(_x4) {
|
|
738
960
|
return _addProductToOrder.apply(this, arguments);
|
|
@@ -742,46 +964,46 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
742
964
|
}, {
|
|
743
965
|
key: "updateProductInOrder",
|
|
744
966
|
value: function () {
|
|
745
|
-
var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
967
|
+
var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(params) {
|
|
746
968
|
var products;
|
|
747
|
-
return _regeneratorRuntime().wrap(function
|
|
748
|
-
while (1) switch (
|
|
969
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
970
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
749
971
|
case 0:
|
|
750
972
|
this.logMethodStart('updateProductInOrder', {
|
|
751
973
|
product_id: params.product_id,
|
|
752
974
|
product_variant_id: params.product_variant_id
|
|
753
975
|
});
|
|
754
|
-
|
|
976
|
+
_context12.prev = 1;
|
|
755
977
|
if (this.store.order) {
|
|
756
|
-
|
|
978
|
+
_context12.next = 4;
|
|
757
979
|
break;
|
|
758
980
|
}
|
|
759
981
|
throw new Error('order 模块未初始化');
|
|
760
982
|
case 4:
|
|
761
|
-
|
|
983
|
+
_context12.next = 6;
|
|
762
984
|
return this.store.order.updateProductInOrder(params);
|
|
763
985
|
case 6:
|
|
764
|
-
products =
|
|
765
|
-
|
|
986
|
+
products = _context12.sent;
|
|
987
|
+
_context12.next = 9;
|
|
766
988
|
return this.refreshItemRuleQuantityLimits();
|
|
767
989
|
case 9:
|
|
768
|
-
|
|
990
|
+
_context12.next = 11;
|
|
769
991
|
return this.refreshCartValidationPassed();
|
|
770
992
|
case 11:
|
|
771
993
|
this.logMethodSuccess('updateProductInOrder', {
|
|
772
994
|
productCount: products.length
|
|
773
995
|
});
|
|
774
|
-
return
|
|
996
|
+
return _context12.abrupt("return", products);
|
|
775
997
|
case 15:
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
this.logMethodError('updateProductInOrder',
|
|
779
|
-
throw
|
|
998
|
+
_context12.prev = 15;
|
|
999
|
+
_context12.t0 = _context12["catch"](1);
|
|
1000
|
+
this.logMethodError('updateProductInOrder', _context12.t0);
|
|
1001
|
+
throw _context12.t0;
|
|
780
1002
|
case 19:
|
|
781
1003
|
case "end":
|
|
782
|
-
return
|
|
1004
|
+
return _context12.stop();
|
|
783
1005
|
}
|
|
784
|
-
},
|
|
1006
|
+
}, _callee12, this, [[1, 15]]);
|
|
785
1007
|
}));
|
|
786
1008
|
function updateProductInOrder(_x5) {
|
|
787
1009
|
return _updateProductInOrder.apply(this, arguments);
|
|
@@ -791,46 +1013,46 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
791
1013
|
}, {
|
|
792
1014
|
key: "removeProductFromOrder",
|
|
793
1015
|
value: function () {
|
|
794
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1016
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(identity) {
|
|
795
1017
|
var products;
|
|
796
|
-
return _regeneratorRuntime().wrap(function
|
|
797
|
-
while (1) switch (
|
|
1018
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
1019
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
798
1020
|
case 0:
|
|
799
1021
|
this.logMethodStart('removeProductFromOrder', {
|
|
800
1022
|
product_id: identity.product_id,
|
|
801
1023
|
product_variant_id: identity.product_variant_id
|
|
802
1024
|
});
|
|
803
|
-
|
|
1025
|
+
_context13.prev = 1;
|
|
804
1026
|
if (this.store.order) {
|
|
805
|
-
|
|
1027
|
+
_context13.next = 4;
|
|
806
1028
|
break;
|
|
807
1029
|
}
|
|
808
1030
|
throw new Error('order 模块未初始化');
|
|
809
1031
|
case 4:
|
|
810
|
-
|
|
1032
|
+
_context13.next = 6;
|
|
811
1033
|
return this.store.order.removeProductFromOrder(identity);
|
|
812
1034
|
case 6:
|
|
813
|
-
products =
|
|
814
|
-
|
|
1035
|
+
products = _context13.sent;
|
|
1036
|
+
_context13.next = 9;
|
|
815
1037
|
return this.refreshItemRuleQuantityLimits();
|
|
816
1038
|
case 9:
|
|
817
|
-
|
|
1039
|
+
_context13.next = 11;
|
|
818
1040
|
return this.refreshCartValidationPassed();
|
|
819
1041
|
case 11:
|
|
820
1042
|
this.logMethodSuccess('removeProductFromOrder', {
|
|
821
1043
|
productCount: products.length
|
|
822
1044
|
});
|
|
823
|
-
return
|
|
1045
|
+
return _context13.abrupt("return", products);
|
|
824
1046
|
case 15:
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
this.logMethodError('removeProductFromOrder',
|
|
828
|
-
throw
|
|
1047
|
+
_context13.prev = 15;
|
|
1048
|
+
_context13.t0 = _context13["catch"](1);
|
|
1049
|
+
this.logMethodError('removeProductFromOrder', _context13.t0);
|
|
1050
|
+
throw _context13.t0;
|
|
829
1051
|
case 19:
|
|
830
1052
|
case "end":
|
|
831
|
-
return
|
|
1053
|
+
return _context13.stop();
|
|
832
1054
|
}
|
|
833
|
-
},
|
|
1055
|
+
}, _callee13, this, [[1, 15]]);
|
|
834
1056
|
}));
|
|
835
1057
|
function removeProductFromOrder(_x6) {
|
|
836
1058
|
return _removeProductFromOrder.apply(this, arguments);
|
|
@@ -840,26 +1062,26 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
840
1062
|
}, {
|
|
841
1063
|
key: "loadRuntimeConfigs",
|
|
842
1064
|
value: function () {
|
|
843
|
-
var _loadRuntimeConfigs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1065
|
+
var _loadRuntimeConfigs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
844
1066
|
var itemRuleConfigs;
|
|
845
|
-
return _regeneratorRuntime().wrap(function
|
|
846
|
-
while (1) switch (
|
|
1067
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1068
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
847
1069
|
case 0:
|
|
848
|
-
|
|
1070
|
+
_context14.next = 2;
|
|
849
1071
|
return this.ensureItemRuleConfigsLoaded();
|
|
850
1072
|
case 2:
|
|
851
|
-
itemRuleConfigs =
|
|
1073
|
+
itemRuleConfigs = _context14.sent;
|
|
852
1074
|
this.logMethodSuccess('loadRuntimeConfigs', {
|
|
853
1075
|
itemRuleCount: itemRuleConfigs.length
|
|
854
1076
|
});
|
|
855
|
-
return
|
|
1077
|
+
return _context14.abrupt("return", {
|
|
856
1078
|
itemRuleConfigs: itemRuleConfigs
|
|
857
1079
|
});
|
|
858
1080
|
case 5:
|
|
859
1081
|
case "end":
|
|
860
|
-
return
|
|
1082
|
+
return _context14.stop();
|
|
861
1083
|
}
|
|
862
|
-
},
|
|
1084
|
+
}, _callee14, this);
|
|
863
1085
|
}));
|
|
864
1086
|
function loadRuntimeConfigs() {
|
|
865
1087
|
return _loadRuntimeConfigs.apply(this, arguments);
|
|
@@ -869,15 +1091,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
869
1091
|
}, {
|
|
870
1092
|
key: "syncItemRuleConfigsFromDineInConfig",
|
|
871
1093
|
value: function () {
|
|
872
|
-
var _syncItemRuleConfigsFromDineInConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1094
|
+
var _syncItemRuleConfigsFromDineInConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(dineInConfig) {
|
|
873
1095
|
var enableItemRules, strategyModelIds, itemRuleConfigs;
|
|
874
|
-
return _regeneratorRuntime().wrap(function
|
|
875
|
-
while (1) switch (
|
|
1096
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1097
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
876
1098
|
case 0:
|
|
877
1099
|
enableItemRules = toBoolean(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['sale.enable_item_rules']);
|
|
878
1100
|
strategyModelIds = normalizeEnabledItemRuleIds(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['sale.enabled_item_rules']);
|
|
879
1101
|
if (!(!enableItemRules || !strategyModelIds.length)) {
|
|
880
|
-
|
|
1102
|
+
_context15.next = 8;
|
|
881
1103
|
break;
|
|
882
1104
|
}
|
|
883
1105
|
this.itemRuleConfigs = [];
|
|
@@ -888,12 +1110,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
888
1110
|
strategyModelIds: [],
|
|
889
1111
|
itemRuleCount: 0
|
|
890
1112
|
});
|
|
891
|
-
return
|
|
1113
|
+
return _context15.abrupt("return", []);
|
|
892
1114
|
case 8:
|
|
893
|
-
|
|
1115
|
+
_context15.next = 10;
|
|
894
1116
|
return this.fetchItemRuleConfigsByModelIds(strategyModelIds);
|
|
895
1117
|
case 10:
|
|
896
|
-
itemRuleConfigs =
|
|
1118
|
+
itemRuleConfigs = _context15.sent;
|
|
897
1119
|
this.itemRuleConfigs = itemRuleConfigs;
|
|
898
1120
|
this.itemRuleConfigsPromise = Promise.resolve(itemRuleConfigs);
|
|
899
1121
|
this.itemRuleEvaluator.setStrategyConfigs(itemRuleConfigs);
|
|
@@ -902,12 +1124,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
902
1124
|
strategyModelIds: strategyModelIds,
|
|
903
1125
|
itemRuleCount: itemRuleConfigs.length
|
|
904
1126
|
});
|
|
905
|
-
return
|
|
1127
|
+
return _context15.abrupt("return", itemRuleConfigs);
|
|
906
1128
|
case 16:
|
|
907
1129
|
case "end":
|
|
908
|
-
return
|
|
1130
|
+
return _context15.stop();
|
|
909
1131
|
}
|
|
910
|
-
},
|
|
1132
|
+
}, _callee15, this);
|
|
911
1133
|
}));
|
|
912
1134
|
function syncItemRuleConfigsFromDineInConfig(_x7) {
|
|
913
1135
|
return _syncItemRuleConfigsFromDineInConfig.apply(this, arguments);
|
|
@@ -917,22 +1139,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
917
1139
|
}, {
|
|
918
1140
|
key: "fetchItemRuleConfigsByModelIds",
|
|
919
1141
|
value: function () {
|
|
920
|
-
var _fetchItemRuleConfigsByModelIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1142
|
+
var _fetchItemRuleConfigsByModelIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(strategyModelIds) {
|
|
921
1143
|
var result, configs;
|
|
922
|
-
return _regeneratorRuntime().wrap(function
|
|
923
|
-
while (1) switch (
|
|
1144
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1145
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
924
1146
|
case 0:
|
|
925
1147
|
this.logMethodStart('fetchItemRuleConfigsByModelIds', {
|
|
926
1148
|
strategyModelIds: strategyModelIds
|
|
927
1149
|
});
|
|
928
1150
|
if (strategyModelIds.length) {
|
|
929
|
-
|
|
1151
|
+
_context16.next = 3;
|
|
930
1152
|
break;
|
|
931
1153
|
}
|
|
932
|
-
return
|
|
1154
|
+
return _context16.abrupt("return", []);
|
|
933
1155
|
case 3:
|
|
934
|
-
|
|
935
|
-
|
|
1156
|
+
_context16.prev = 3;
|
|
1157
|
+
_context16.next = 6;
|
|
936
1158
|
return this.request.get('/promotion', {
|
|
937
1159
|
skip: 1,
|
|
938
1160
|
num: 99,
|
|
@@ -940,7 +1162,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
940
1162
|
ids: strategyModelIds
|
|
941
1163
|
});
|
|
942
1164
|
case 6:
|
|
943
|
-
result =
|
|
1165
|
+
result = _context16.sent;
|
|
944
1166
|
configs = [];
|
|
945
1167
|
if (result.code === 200) {
|
|
946
1168
|
configs = result.data.list.map(function (item) {
|
|
@@ -951,20 +1173,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
951
1173
|
strategyModelIds: strategyModelIds,
|
|
952
1174
|
strategyCount: configs.length
|
|
953
1175
|
});
|
|
954
|
-
return
|
|
1176
|
+
return _context16.abrupt("return", configs);
|
|
955
1177
|
case 13:
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
this.logMethodError('fetchItemRuleConfigsByModelIds',
|
|
1178
|
+
_context16.prev = 13;
|
|
1179
|
+
_context16.t0 = _context16["catch"](3);
|
|
1180
|
+
this.logMethodError('fetchItemRuleConfigsByModelIds', _context16.t0, {
|
|
959
1181
|
strategyModelIds: strategyModelIds
|
|
960
1182
|
});
|
|
961
1183
|
// A:策略加载失败时不阻塞下单
|
|
962
|
-
return
|
|
1184
|
+
return _context16.abrupt("return", []);
|
|
963
1185
|
case 17:
|
|
964
1186
|
case "end":
|
|
965
|
-
return
|
|
1187
|
+
return _context16.stop();
|
|
966
1188
|
}
|
|
967
|
-
},
|
|
1189
|
+
}, _callee16, this, [[3, 13]]);
|
|
968
1190
|
}));
|
|
969
1191
|
function fetchItemRuleConfigsByModelIds(_x8) {
|
|
970
1192
|
return _fetchItemRuleConfigsByModelIds.apply(this, arguments);
|
|
@@ -974,22 +1196,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
974
1196
|
}, {
|
|
975
1197
|
key: "buildPrefillProductSourceMap",
|
|
976
1198
|
value: function () {
|
|
977
|
-
var _buildPrefillProductSourceMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1199
|
+
var _buildPrefillProductSourceMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
978
1200
|
var sourceMap, productList, visited, collectFromValue;
|
|
979
|
-
return _regeneratorRuntime().wrap(function
|
|
980
|
-
while (1) switch (
|
|
1201
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1202
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
981
1203
|
case 0:
|
|
982
1204
|
sourceMap = new Map();
|
|
983
|
-
|
|
984
|
-
|
|
1205
|
+
_context17.prev = 1;
|
|
1206
|
+
_context17.next = 4;
|
|
985
1207
|
return this.getProductList();
|
|
986
1208
|
case 4:
|
|
987
|
-
productList =
|
|
1209
|
+
productList = _context17.sent;
|
|
988
1210
|
if (Array.isArray(productList)) {
|
|
989
|
-
|
|
1211
|
+
_context17.next = 7;
|
|
990
1212
|
break;
|
|
991
1213
|
}
|
|
992
|
-
return
|
|
1214
|
+
return _context17.abrupt("return", sourceMap);
|
|
993
1215
|
case 7:
|
|
994
1216
|
visited = new Set();
|
|
995
1217
|
collectFromValue = function collectFromValue(value) {
|
|
@@ -1016,8 +1238,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1016
1238
|
var rawProductId = (_node$product_id = node.product_id) !== null && _node$product_id !== void 0 ? _node$product_id : node.id;
|
|
1017
1239
|
var productId = Number(rawProductId);
|
|
1018
1240
|
if (Number.isFinite(productId) && productId > 0) {
|
|
1019
|
-
var
|
|
1020
|
-
var productVariantId = Number((
|
|
1241
|
+
var _ref4, _node$product_variant;
|
|
1242
|
+
var productVariantId = Number((_ref4 = (_node$product_variant = node.product_variant_id) !== null && _node$product_variant !== void 0 ? _node$product_variant : node.variant_id) !== null && _ref4 !== void 0 ? _ref4 : 0);
|
|
1021
1243
|
var normalizedVariantId = Number.isNaN(productVariantId) ? 0 : productVariantId;
|
|
1022
1244
|
var key = buildProductKey(productId, normalizedVariantId);
|
|
1023
1245
|
if (!sourceMap.has(key)) {
|
|
@@ -1032,19 +1254,19 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1032
1254
|
}
|
|
1033
1255
|
};
|
|
1034
1256
|
collectFromValue(productList);
|
|
1035
|
-
|
|
1257
|
+
_context17.next = 15;
|
|
1036
1258
|
break;
|
|
1037
1259
|
case 12:
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
this.logMethodError('buildPrefillProductSourceMap',
|
|
1260
|
+
_context17.prev = 12;
|
|
1261
|
+
_context17.t0 = _context17["catch"](1);
|
|
1262
|
+
this.logMethodError('buildPrefillProductSourceMap', _context17.t0);
|
|
1041
1263
|
case 15:
|
|
1042
|
-
return
|
|
1264
|
+
return _context17.abrupt("return", sourceMap);
|
|
1043
1265
|
case 16:
|
|
1044
1266
|
case "end":
|
|
1045
|
-
return
|
|
1267
|
+
return _context17.stop();
|
|
1046
1268
|
}
|
|
1047
|
-
},
|
|
1269
|
+
}, _callee17, this, [[1, 12]]);
|
|
1048
1270
|
}));
|
|
1049
1271
|
function buildPrefillProductSourceMap() {
|
|
1050
1272
|
return _buildPrefillProductSourceMap.apply(this, arguments);
|
|
@@ -1059,58 +1281,58 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1059
1281
|
}, {
|
|
1060
1282
|
key: "ensureItemRuleConfigsLoaded",
|
|
1061
1283
|
value: function () {
|
|
1062
|
-
var _ensureItemRuleConfigsLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1284
|
+
var _ensureItemRuleConfigsLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
|
|
1063
1285
|
var _this3 = this;
|
|
1064
1286
|
var loadedConfigs;
|
|
1065
|
-
return _regeneratorRuntime().wrap(function
|
|
1066
|
-
while (1) switch (
|
|
1287
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1288
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1067
1289
|
case 0:
|
|
1068
1290
|
if (!(this.itemRuleConfigs.length > 0)) {
|
|
1069
|
-
|
|
1291
|
+
_context19.next = 2;
|
|
1070
1292
|
break;
|
|
1071
1293
|
}
|
|
1072
|
-
return
|
|
1294
|
+
return _context19.abrupt("return", this.itemRuleConfigs);
|
|
1073
1295
|
case 2:
|
|
1074
1296
|
if (!this.itemRuleConfigsPromise) {
|
|
1075
|
-
|
|
1297
|
+
_context19.next = 4;
|
|
1076
1298
|
break;
|
|
1077
1299
|
}
|
|
1078
|
-
return
|
|
1300
|
+
return _context19.abrupt("return", this.itemRuleConfigsPromise);
|
|
1079
1301
|
case 4:
|
|
1080
|
-
this.itemRuleConfigsPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1302
|
+
this.itemRuleConfigsPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
1081
1303
|
var runtimeConfig, staticConfigs;
|
|
1082
|
-
return _regeneratorRuntime().wrap(function
|
|
1083
|
-
while (1) switch (
|
|
1304
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1305
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1084
1306
|
case 0:
|
|
1085
1307
|
runtimeConfig = _this3.getItemRuleRuntimeConfig();
|
|
1086
1308
|
staticConfigs = normalizeItemRuleStrategies(runtimeConfig.strategyConfigs);
|
|
1087
1309
|
if (!(staticConfigs.length > 0)) {
|
|
1088
|
-
|
|
1310
|
+
_context18.next = 6;
|
|
1089
1311
|
break;
|
|
1090
1312
|
}
|
|
1091
1313
|
_this3.itemRuleConfigs = staticConfigs;
|
|
1092
1314
|
_this3.itemRuleEvaluator.setStrategyConfigs(staticConfigs);
|
|
1093
|
-
return
|
|
1315
|
+
return _context18.abrupt("return", _this3.itemRuleConfigs);
|
|
1094
1316
|
case 6:
|
|
1095
1317
|
_this3.itemRuleConfigs = [];
|
|
1096
1318
|
_this3.itemRuleEvaluator.setStrategyConfigs([]);
|
|
1097
|
-
return
|
|
1319
|
+
return _context18.abrupt("return", _this3.itemRuleConfigs);
|
|
1098
1320
|
case 9:
|
|
1099
1321
|
case "end":
|
|
1100
|
-
return
|
|
1322
|
+
return _context18.stop();
|
|
1101
1323
|
}
|
|
1102
|
-
},
|
|
1324
|
+
}, _callee18);
|
|
1103
1325
|
}))();
|
|
1104
|
-
|
|
1326
|
+
_context19.next = 7;
|
|
1105
1327
|
return this.itemRuleConfigsPromise;
|
|
1106
1328
|
case 7:
|
|
1107
|
-
loadedConfigs =
|
|
1108
|
-
return
|
|
1329
|
+
loadedConfigs = _context19.sent;
|
|
1330
|
+
return _context19.abrupt("return", loadedConfigs);
|
|
1109
1331
|
case 9:
|
|
1110
1332
|
case "end":
|
|
1111
|
-
return
|
|
1333
|
+
return _context19.stop();
|
|
1112
1334
|
}
|
|
1113
|
-
},
|
|
1335
|
+
}, _callee19, this);
|
|
1114
1336
|
}));
|
|
1115
1337
|
function ensureItemRuleConfigsLoaded() {
|
|
1116
1338
|
return _ensureItemRuleConfigsLoaded.apply(this, arguments);
|
|
@@ -1120,22 +1342,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1120
1342
|
}, {
|
|
1121
1343
|
key: "refreshItemRuleQuantityLimits",
|
|
1122
1344
|
value: function () {
|
|
1123
|
-
var _refreshItemRuleQuantityLimits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1345
|
+
var _refreshItemRuleQuantityLimits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
1124
1346
|
var strategyConfigs, businessData, limits;
|
|
1125
|
-
return _regeneratorRuntime().wrap(function
|
|
1126
|
-
while (1) switch (
|
|
1347
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1348
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1127
1349
|
case 0:
|
|
1128
|
-
|
|
1129
|
-
|
|
1350
|
+
_context20.prev = 0;
|
|
1351
|
+
_context20.next = 3;
|
|
1130
1352
|
return this.ensureItemRuleConfigsLoaded();
|
|
1131
1353
|
case 3:
|
|
1132
|
-
strategyConfigs =
|
|
1354
|
+
strategyConfigs = _context20.sent;
|
|
1133
1355
|
if (strategyConfigs.length) {
|
|
1134
|
-
|
|
1356
|
+
_context20.next = 7;
|
|
1135
1357
|
break;
|
|
1136
1358
|
}
|
|
1137
1359
|
this.store.itemRuleQuantityLimits = [];
|
|
1138
|
-
return
|
|
1360
|
+
return _context20.abrupt("return", []);
|
|
1139
1361
|
case 7:
|
|
1140
1362
|
businessData = buildItemRuleBusinessData({
|
|
1141
1363
|
tempOrder: this.ensureTempOrder(),
|
|
@@ -1147,18 +1369,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1147
1369
|
this.logMethodSuccess('refreshItemRuleQuantityLimits', {
|
|
1148
1370
|
limitCount: limits.length
|
|
1149
1371
|
});
|
|
1150
|
-
return
|
|
1372
|
+
return _context20.abrupt("return", limits);
|
|
1151
1373
|
case 14:
|
|
1152
|
-
|
|
1153
|
-
|
|
1374
|
+
_context20.prev = 14;
|
|
1375
|
+
_context20.t0 = _context20["catch"](0);
|
|
1154
1376
|
this.store.itemRuleQuantityLimits = [];
|
|
1155
|
-
this.logMethodError('refreshItemRuleQuantityLimits',
|
|
1156
|
-
return
|
|
1377
|
+
this.logMethodError('refreshItemRuleQuantityLimits', _context20.t0);
|
|
1378
|
+
return _context20.abrupt("return", []);
|
|
1157
1379
|
case 19:
|
|
1158
1380
|
case "end":
|
|
1159
|
-
return
|
|
1381
|
+
return _context20.stop();
|
|
1160
1382
|
}
|
|
1161
|
-
},
|
|
1383
|
+
}, _callee20, this, [[0, 14]]);
|
|
1162
1384
|
}));
|
|
1163
1385
|
function refreshItemRuleQuantityLimits() {
|
|
1164
1386
|
return _refreshItemRuleQuantityLimits.apply(this, arguments);
|
|
@@ -1168,32 +1390,32 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1168
1390
|
}, {
|
|
1169
1391
|
key: "applyPrefillByItemRule",
|
|
1170
1392
|
value: function () {
|
|
1171
|
-
var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1393
|
+
var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
|
1172
1394
|
var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges, _iterator2, _step2, _prefillItem$product_, _targetProduct$_origi, _targetProduct$_origi2, _targetProduct$_origi3, prefillItem, productId, productVariantId, targetQuantity, sourceItem, productIndex, _sourceItem$price, sellingPrice, targetProduct, existedQuantity, delta, nextProduct, hasQuantityChanged, hasOriginChanged;
|
|
1173
|
-
return _regeneratorRuntime().wrap(function
|
|
1174
|
-
while (1) switch (
|
|
1395
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1396
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1175
1397
|
case 0:
|
|
1176
1398
|
if (!this.itemRulePrefillApplied) {
|
|
1177
|
-
|
|
1399
|
+
_context21.next = 2;
|
|
1178
1400
|
break;
|
|
1179
1401
|
}
|
|
1180
|
-
return
|
|
1402
|
+
return _context21.abrupt("return");
|
|
1181
1403
|
case 2:
|
|
1182
1404
|
if (this.store.order) {
|
|
1183
|
-
|
|
1405
|
+
_context21.next = 4;
|
|
1184
1406
|
break;
|
|
1185
1407
|
}
|
|
1186
|
-
return
|
|
1408
|
+
return _context21.abrupt("return");
|
|
1187
1409
|
case 4:
|
|
1188
|
-
|
|
1410
|
+
_context21.next = 6;
|
|
1189
1411
|
return this.ensureItemRuleConfigsLoaded();
|
|
1190
1412
|
case 6:
|
|
1191
|
-
strategyConfigs =
|
|
1413
|
+
strategyConfigs = _context21.sent;
|
|
1192
1414
|
if (strategyConfigs.length) {
|
|
1193
|
-
|
|
1415
|
+
_context21.next = 9;
|
|
1194
1416
|
break;
|
|
1195
1417
|
}
|
|
1196
|
-
return
|
|
1418
|
+
return _context21.abrupt("return");
|
|
1197
1419
|
case 9:
|
|
1198
1420
|
businessData = buildItemRuleBusinessData({
|
|
1199
1421
|
tempOrder: this.ensureTempOrder(),
|
|
@@ -1202,24 +1424,24 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1202
1424
|
});
|
|
1203
1425
|
prefillItems = this.itemRuleEvaluator.getPrefillItems(businessData);
|
|
1204
1426
|
if (prefillItems.length) {
|
|
1205
|
-
|
|
1427
|
+
_context21.next = 14;
|
|
1206
1428
|
break;
|
|
1207
1429
|
}
|
|
1208
1430
|
this.itemRulePrefillApplied = true;
|
|
1209
|
-
return
|
|
1431
|
+
return _context21.abrupt("return");
|
|
1210
1432
|
case 14:
|
|
1211
|
-
|
|
1433
|
+
_context21.next = 16;
|
|
1212
1434
|
return this.buildPrefillProductSourceMap();
|
|
1213
1435
|
case 16:
|
|
1214
|
-
productSourceMap =
|
|
1436
|
+
productSourceMap = _context21.sent;
|
|
1215
1437
|
tempOrder = this.ensureTempOrder();
|
|
1216
1438
|
hasChanges = false;
|
|
1217
1439
|
_iterator2 = _createForOfIteratorHelper(prefillItems);
|
|
1218
|
-
|
|
1440
|
+
_context21.prev = 20;
|
|
1219
1441
|
_iterator2.s();
|
|
1220
1442
|
case 22:
|
|
1221
1443
|
if ((_step2 = _iterator2.n()).done) {
|
|
1222
|
-
|
|
1444
|
+
_context21.next = 47;
|
|
1223
1445
|
break;
|
|
1224
1446
|
}
|
|
1225
1447
|
prefillItem = _step2.value;
|
|
@@ -1227,16 +1449,16 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1227
1449
|
productVariantId = Number((_prefillItem$product_ = prefillItem.product_variant_id) !== null && _prefillItem$product_ !== void 0 ? _prefillItem$product_ : 0);
|
|
1228
1450
|
targetQuantity = toNonNegativeInt(prefillItem.quantity);
|
|
1229
1451
|
if (!(!Number.isFinite(productId) || targetQuantity <= 0)) {
|
|
1230
|
-
|
|
1452
|
+
_context21.next = 29;
|
|
1231
1453
|
break;
|
|
1232
1454
|
}
|
|
1233
|
-
return
|
|
1455
|
+
return _context21.abrupt("continue", 45);
|
|
1234
1456
|
case 29:
|
|
1235
1457
|
if (!Number.isNaN(productVariantId)) {
|
|
1236
|
-
|
|
1458
|
+
_context21.next = 31;
|
|
1237
1459
|
break;
|
|
1238
1460
|
}
|
|
1239
|
-
return
|
|
1461
|
+
return _context21.abrupt("continue", 45);
|
|
1240
1462
|
case 31:
|
|
1241
1463
|
sourceItem = productSourceMap.get(buildProductKey(productId, productVariantId)) || productSourceMap.get(buildProductKey(productId, 0)) || null;
|
|
1242
1464
|
productIndex = getProductIdentityIndex(tempOrder.products, {
|
|
@@ -1244,7 +1466,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1244
1466
|
product_variant_id: productVariantId
|
|
1245
1467
|
});
|
|
1246
1468
|
if (!(productIndex === -1)) {
|
|
1247
|
-
|
|
1469
|
+
_context21.next = 38;
|
|
1248
1470
|
break;
|
|
1249
1471
|
}
|
|
1250
1472
|
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 +1486,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1264
1486
|
})
|
|
1265
1487
|
})));
|
|
1266
1488
|
hasChanges = true;
|
|
1267
|
-
return
|
|
1489
|
+
return _context21.abrupt("continue", 45);
|
|
1268
1490
|
case 38:
|
|
1269
1491
|
targetProduct = tempOrder.products[productIndex];
|
|
1270
1492
|
existedQuantity = toNonNegativeInt(targetProduct.num);
|
|
@@ -1285,34 +1507,34 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1285
1507
|
hasChanges = true;
|
|
1286
1508
|
}
|
|
1287
1509
|
case 45:
|
|
1288
|
-
|
|
1510
|
+
_context21.next = 22;
|
|
1289
1511
|
break;
|
|
1290
1512
|
case 47:
|
|
1291
|
-
|
|
1513
|
+
_context21.next = 52;
|
|
1292
1514
|
break;
|
|
1293
1515
|
case 49:
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
_iterator2.e(
|
|
1516
|
+
_context21.prev = 49;
|
|
1517
|
+
_context21.t0 = _context21["catch"](20);
|
|
1518
|
+
_iterator2.e(_context21.t0);
|
|
1297
1519
|
case 52:
|
|
1298
|
-
|
|
1520
|
+
_context21.prev = 52;
|
|
1299
1521
|
_iterator2.f();
|
|
1300
|
-
return
|
|
1522
|
+
return _context21.finish(52);
|
|
1301
1523
|
case 55:
|
|
1302
1524
|
if (!hasChanges) {
|
|
1303
|
-
|
|
1525
|
+
_context21.next = 60;
|
|
1304
1526
|
break;
|
|
1305
1527
|
}
|
|
1306
1528
|
// Prefill 属于 products CRUD 的一种形式:新增后让 Rules 重算,以支持自动应用可用优惠券。
|
|
1307
1529
|
this.store.order.applyDiscount();
|
|
1308
|
-
|
|
1530
|
+
_context21.next = 59;
|
|
1309
1531
|
return this.store.order.recalculateSummary({
|
|
1310
1532
|
createIfMissing: true
|
|
1311
1533
|
});
|
|
1312
1534
|
case 59:
|
|
1313
1535
|
this.store.order.persistTempOrder();
|
|
1314
1536
|
case 60:
|
|
1315
|
-
|
|
1537
|
+
_context21.next = 62;
|
|
1316
1538
|
return this.refreshItemRuleQuantityLimits();
|
|
1317
1539
|
case 62:
|
|
1318
1540
|
this.itemRulePrefillApplied = true;
|
|
@@ -1322,9 +1544,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1322
1544
|
});
|
|
1323
1545
|
case 64:
|
|
1324
1546
|
case "end":
|
|
1325
|
-
return
|
|
1547
|
+
return _context21.stop();
|
|
1326
1548
|
}
|
|
1327
|
-
},
|
|
1549
|
+
}, _callee21, this, [[20, 49, 52, 55]]);
|
|
1328
1550
|
}));
|
|
1329
1551
|
function applyPrefillByItemRule() {
|
|
1330
1552
|
return _applyPrefillByItemRule.apply(this, arguments);
|
|
@@ -1334,31 +1556,31 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1334
1556
|
}, {
|
|
1335
1557
|
key: "applyItemRulePrefill",
|
|
1336
1558
|
value: function () {
|
|
1337
|
-
var _applyItemRulePrefill = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1559
|
+
var _applyItemRulePrefill = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
|
|
1338
1560
|
var _this$store$order4, _this$store$order4$ge;
|
|
1339
|
-
return _regeneratorRuntime().wrap(function
|
|
1340
|
-
while (1) switch (
|
|
1561
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
1562
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1341
1563
|
case 0:
|
|
1342
1564
|
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
|
-
|
|
1565
|
+
_context22.next = 2;
|
|
1344
1566
|
break;
|
|
1345
1567
|
}
|
|
1346
|
-
return
|
|
1568
|
+
return _context22.abrupt("return");
|
|
1347
1569
|
case 2:
|
|
1348
1570
|
this.logMethodStart('applyItemRulePrefill');
|
|
1349
|
-
|
|
1571
|
+
_context22.next = 5;
|
|
1350
1572
|
return this.applyPrefillByItemRule();
|
|
1351
1573
|
case 5:
|
|
1352
|
-
|
|
1574
|
+
_context22.next = 7;
|
|
1353
1575
|
return this.refreshItemRuleQuantityLimits();
|
|
1354
1576
|
case 7:
|
|
1355
|
-
|
|
1577
|
+
_context22.next = 9;
|
|
1356
1578
|
return this.refreshCartValidationPassed();
|
|
1357
1579
|
case 9:
|
|
1358
1580
|
case "end":
|
|
1359
|
-
return
|
|
1581
|
+
return _context22.stop();
|
|
1360
1582
|
}
|
|
1361
|
-
},
|
|
1583
|
+
}, _callee22, this);
|
|
1362
1584
|
}));
|
|
1363
1585
|
function applyItemRulePrefill() {
|
|
1364
1586
|
return _applyItemRulePrefill.apply(this, arguments);
|
|
@@ -1368,20 +1590,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1368
1590
|
}, {
|
|
1369
1591
|
key: "evaluateCartValidationByItemRule",
|
|
1370
1592
|
value: function () {
|
|
1371
|
-
var _evaluateCartValidationByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1593
|
+
var _evaluateCartValidationByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
1372
1594
|
var strategyConfigs, businessData;
|
|
1373
|
-
return _regeneratorRuntime().wrap(function
|
|
1374
|
-
while (1) switch (
|
|
1595
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
1596
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1375
1597
|
case 0:
|
|
1376
|
-
|
|
1598
|
+
_context23.next = 2;
|
|
1377
1599
|
return this.ensureItemRuleConfigsLoaded();
|
|
1378
1600
|
case 2:
|
|
1379
|
-
strategyConfigs =
|
|
1601
|
+
strategyConfigs = _context23.sent;
|
|
1380
1602
|
if (strategyConfigs.length) {
|
|
1381
|
-
|
|
1603
|
+
_context23.next = 5;
|
|
1382
1604
|
break;
|
|
1383
1605
|
}
|
|
1384
|
-
return
|
|
1606
|
+
return _context23.abrupt("return", {
|
|
1385
1607
|
passed: true,
|
|
1386
1608
|
failures: []
|
|
1387
1609
|
});
|
|
@@ -1391,12 +1613,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1391
1613
|
runtimeConfig: this.getItemRuleRuntimeConfig(),
|
|
1392
1614
|
itemRuleConfigs: this.itemRuleConfigs
|
|
1393
1615
|
});
|
|
1394
|
-
return
|
|
1616
|
+
return _context23.abrupt("return", this.itemRuleEvaluator.validateCart(businessData));
|
|
1395
1617
|
case 7:
|
|
1396
1618
|
case "end":
|
|
1397
|
-
return
|
|
1619
|
+
return _context23.stop();
|
|
1398
1620
|
}
|
|
1399
|
-
},
|
|
1621
|
+
}, _callee23, this);
|
|
1400
1622
|
}));
|
|
1401
1623
|
function evaluateCartValidationByItemRule() {
|
|
1402
1624
|
return _evaluateCartValidationByItemRule.apply(this, arguments);
|
|
@@ -1406,20 +1628,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1406
1628
|
}, {
|
|
1407
1629
|
key: "validateBeforeSubmitByItemRule",
|
|
1408
1630
|
value: function () {
|
|
1409
|
-
var _validateBeforeSubmitByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1631
|
+
var _validateBeforeSubmitByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
1410
1632
|
var validationResult, firstFailure, errorMessage, error;
|
|
1411
|
-
return _regeneratorRuntime().wrap(function
|
|
1412
|
-
while (1) switch (
|
|
1633
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
1634
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1413
1635
|
case 0:
|
|
1414
|
-
|
|
1636
|
+
_context24.next = 2;
|
|
1415
1637
|
return this.evaluateCartValidationByItemRule();
|
|
1416
1638
|
case 2:
|
|
1417
|
-
validationResult =
|
|
1639
|
+
validationResult = _context24.sent;
|
|
1418
1640
|
if (!validationResult.passed) {
|
|
1419
|
-
|
|
1641
|
+
_context24.next = 5;
|
|
1420
1642
|
break;
|
|
1421
1643
|
}
|
|
1422
|
-
return
|
|
1644
|
+
return _context24.abrupt("return");
|
|
1423
1645
|
case 5:
|
|
1424
1646
|
firstFailure = validationResult.failures[0];
|
|
1425
1647
|
errorMessage = (firstFailure === null || firstFailure === void 0 ? void 0 : firstFailure.validationMessage) || '当前购物车未满足商品规则,请调整后再提交';
|
|
@@ -1428,9 +1650,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1428
1650
|
throw error;
|
|
1429
1651
|
case 10:
|
|
1430
1652
|
case "end":
|
|
1431
|
-
return
|
|
1653
|
+
return _context24.stop();
|
|
1432
1654
|
}
|
|
1433
|
-
},
|
|
1655
|
+
}, _callee24, this);
|
|
1434
1656
|
}));
|
|
1435
1657
|
function validateBeforeSubmitByItemRule() {
|
|
1436
1658
|
return _validateBeforeSubmitByItemRule.apply(this, arguments);
|
|
@@ -1440,10 +1662,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1440
1662
|
}, {
|
|
1441
1663
|
key: "refreshCartValidationPassed",
|
|
1442
1664
|
value: function () {
|
|
1443
|
-
var _refreshCartValidationPassed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1665
|
+
var _refreshCartValidationPassed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
|
|
1444
1666
|
var previous, nextState, validationResult, changed;
|
|
1445
|
-
return _regeneratorRuntime().wrap(function
|
|
1446
|
-
while (1) switch (
|
|
1667
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
1668
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
1447
1669
|
case 0:
|
|
1448
1670
|
previous = this.store.cartValidation || {
|
|
1449
1671
|
passed: null,
|
|
@@ -1453,20 +1675,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1453
1675
|
passed: null,
|
|
1454
1676
|
failures: []
|
|
1455
1677
|
};
|
|
1456
|
-
|
|
1457
|
-
|
|
1678
|
+
_context25.prev = 2;
|
|
1679
|
+
_context25.next = 5;
|
|
1458
1680
|
return this.evaluateCartValidationByItemRule();
|
|
1459
1681
|
case 5:
|
|
1460
|
-
validationResult =
|
|
1682
|
+
validationResult = _context25.sent;
|
|
1461
1683
|
nextState = {
|
|
1462
1684
|
passed: validationResult.passed,
|
|
1463
1685
|
failures: validationResult.failures || []
|
|
1464
1686
|
};
|
|
1465
|
-
|
|
1687
|
+
_context25.next = 12;
|
|
1466
1688
|
break;
|
|
1467
1689
|
case 9:
|
|
1468
|
-
|
|
1469
|
-
|
|
1690
|
+
_context25.prev = 9;
|
|
1691
|
+
_context25.t0 = _context25["catch"](2);
|
|
1470
1692
|
nextState = {
|
|
1471
1693
|
passed: false,
|
|
1472
1694
|
failures: []
|
|
@@ -1475,21 +1697,21 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1475
1697
|
this.store.cartValidation = nextState;
|
|
1476
1698
|
changed = previous.passed !== nextState.passed || previous.failures !== nextState.failures;
|
|
1477
1699
|
if (!changed) {
|
|
1478
|
-
|
|
1700
|
+
_context25.next = 17;
|
|
1479
1701
|
break;
|
|
1480
1702
|
}
|
|
1481
|
-
|
|
1703
|
+
_context25.next = 17;
|
|
1482
1704
|
return this.core.effects.emit(ScanOrderHooks.onCartValidationChanged, {
|
|
1483
1705
|
cartValidation: nextState,
|
|
1484
1706
|
cartValidationPassed: nextState.passed
|
|
1485
1707
|
});
|
|
1486
1708
|
case 17:
|
|
1487
|
-
return
|
|
1709
|
+
return _context25.abrupt("return", nextState.passed);
|
|
1488
1710
|
case 18:
|
|
1489
1711
|
case "end":
|
|
1490
|
-
return
|
|
1712
|
+
return _context25.stop();
|
|
1491
1713
|
}
|
|
1492
|
-
},
|
|
1714
|
+
}, _callee25, this, [[2, 9]]);
|
|
1493
1715
|
}));
|
|
1494
1716
|
function refreshCartValidationPassed() {
|
|
1495
1717
|
return _refreshCartValidationPassed.apply(this, arguments);
|
|
@@ -1499,14 +1721,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1499
1721
|
}, {
|
|
1500
1722
|
key: "setItemRuleRuntimeConfig",
|
|
1501
1723
|
value: function () {
|
|
1502
|
-
var _setItemRuleRuntimeConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1724
|
+
var _setItemRuleRuntimeConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
|
|
1503
1725
|
var _this$itemRuleRuntime, _this$itemRuleRuntime2;
|
|
1504
1726
|
var config,
|
|
1505
|
-
|
|
1506
|
-
return _regeneratorRuntime().wrap(function
|
|
1507
|
-
while (1) switch (
|
|
1727
|
+
_args26 = arguments;
|
|
1728
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
1729
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
1508
1730
|
case 0:
|
|
1509
|
-
config =
|
|
1731
|
+
config = _args26.length > 0 && _args26[0] !== undefined ? _args26[0] : {};
|
|
1510
1732
|
this.logMethodStart('setItemRuleRuntimeConfig');
|
|
1511
1733
|
this.itemRuleRuntimeConfig = _objectSpread(_objectSpread(_objectSpread({}, this.itemRuleRuntimeConfig), config), {}, {
|
|
1512
1734
|
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 +1740,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1518
1740
|
this.itemRuleEvaluator.setStrategyConfigs([]);
|
|
1519
1741
|
}
|
|
1520
1742
|
this.itemRulePrefillApplied = false;
|
|
1521
|
-
|
|
1743
|
+
_context26.next = 7;
|
|
1522
1744
|
return this.refreshItemRuleQuantityLimits();
|
|
1523
1745
|
case 7:
|
|
1524
|
-
|
|
1746
|
+
_context26.next = 9;
|
|
1525
1747
|
return this.refreshCartValidationPassed();
|
|
1526
1748
|
case 9:
|
|
1527
1749
|
this.logMethodSuccess('setItemRuleRuntimeConfig', {
|
|
@@ -1529,9 +1751,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1529
1751
|
});
|
|
1530
1752
|
case 10:
|
|
1531
1753
|
case "end":
|
|
1532
|
-
return
|
|
1754
|
+
return _context26.stop();
|
|
1533
1755
|
}
|
|
1534
|
-
},
|
|
1756
|
+
}, _callee26, this);
|
|
1535
1757
|
}));
|
|
1536
1758
|
function setItemRuleRuntimeConfig() {
|
|
1537
1759
|
return _setItemRuleRuntimeConfig.apply(this, arguments);
|
|
@@ -1540,22 +1762,24 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1540
1762
|
}()
|
|
1541
1763
|
}, {
|
|
1542
1764
|
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);
|
|
1765
|
+
value: function normalizeResourceState(detail, resourceSelectType, hasOrderId) {
|
|
1766
|
+
var _detail$form_record, _this$otherParams8, _detail$resource_capa, _detail$resource_capa2;
|
|
1767
|
+
var currentOrderId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.order_id);
|
|
1768
|
+
var lastOrderId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.last_order_id);
|
|
1769
|
+
var relationId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.form_record_id);
|
|
1770
|
+
var tableFormId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.form_id);
|
|
1771
|
+
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
1772
|
// 是否允许加餐
|
|
1553
1773
|
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['workflow.allow_add_items']) || false;
|
|
1554
1774
|
// 开启同桌验证 - 本期没有这个配置,默认关掉
|
|
1555
1775
|
var deskmateValid = false;
|
|
1556
|
-
var isExclusive =
|
|
1557
|
-
var isFull =
|
|
1558
|
-
|
|
1776
|
+
var isExclusive = resourceSelectType === 'single';
|
|
1777
|
+
var isFull = computeResourceIsFull({
|
|
1778
|
+
resourceSelectType: resourceSelectType,
|
|
1779
|
+
lastOrderId: lastOrderId,
|
|
1780
|
+
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 : [],
|
|
1781
|
+
capacity: formRecord === null || formRecord === void 0 ? void 0 : formRecord.capacity
|
|
1782
|
+
});
|
|
1559
1783
|
var availabilityInfo = {
|
|
1560
1784
|
mode: 'idle',
|
|
1561
1785
|
deskmate_valid: deskmateValid
|
|
@@ -1584,33 +1808,19 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1584
1808
|
}
|
|
1585
1809
|
} else if (lastOrderId) {
|
|
1586
1810
|
// 如果有其他人点的单
|
|
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
|
-
};
|
|
1811
|
+
// multiple 预约且容量仍有剩余时,其他人的单不影响当前用户下单,保持 idle 走正常下单流程
|
|
1812
|
+
var canFallthroughToIdle = resourceSelectType === 'multiple' && !isFull;
|
|
1813
|
+
if (!canFallthroughToIdle) {
|
|
1814
|
+
availabilityInfo = {
|
|
1815
|
+
mode: 'resource_busy',
|
|
1816
|
+
order_id: '0',
|
|
1817
|
+
relation_id: relationId,
|
|
1818
|
+
table_form_id: tableFormId,
|
|
1819
|
+
deskmate_valid: deskmateValid
|
|
1820
|
+
};
|
|
1821
|
+
}
|
|
1610
1822
|
}
|
|
1611
1823
|
return _objectSpread(_objectSpread({}, availabilityInfo), {}, {
|
|
1612
|
-
tableMaxNumber: tableMaxNumber,
|
|
1613
|
-
orderCount: orderCount,
|
|
1614
1824
|
currentOrderId: currentOrderId,
|
|
1615
1825
|
lastOrderId: lastOrderId,
|
|
1616
1826
|
relationId: relationId,
|
|
@@ -1619,142 +1829,177 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1619
1829
|
deskmateValid: deskmateValid,
|
|
1620
1830
|
isExclusive: isExclusive,
|
|
1621
1831
|
isFull: isFull,
|
|
1622
|
-
|
|
1623
|
-
raw:
|
|
1624
|
-
table_form_record:
|
|
1832
|
+
resourceSelectType: resourceSelectType,
|
|
1833
|
+
raw: detail,
|
|
1834
|
+
table_form_record: formRecord
|
|
1835
|
+
});
|
|
1836
|
+
}
|
|
1837
|
+
|
|
1838
|
+
// 从首个预约规则商品的 product_resource.resources 中,按 form_id 匹配返回 type
|
|
1839
|
+
}, {
|
|
1840
|
+
key: "resolveResourceSelectType",
|
|
1841
|
+
value: function resolveResourceSelectType(formId) {
|
|
1842
|
+
var _firstProduct$product;
|
|
1843
|
+
var firstProduct = this.enabledReservationRuleProducts[0];
|
|
1844
|
+
var resources = (firstProduct === null || firstProduct === void 0 || (_firstProduct$product = firstProduct.product_resource) === null || _firstProduct$product === void 0 ? void 0 : _firstProduct$product.resources) || [];
|
|
1845
|
+
var numericFormId = Number(formId);
|
|
1846
|
+
if (!Number.isFinite(numericFormId) || numericFormId <= 0) return undefined;
|
|
1847
|
+
var matched = resources.find(function (r) {
|
|
1848
|
+
return Number(r === null || r === void 0 ? void 0 : r.id) === numericFormId;
|
|
1625
1849
|
});
|
|
1850
|
+
return matched === null || matched === void 0 ? void 0 : matched.type;
|
|
1626
1851
|
}
|
|
1627
1852
|
}, {
|
|
1628
|
-
key: "
|
|
1853
|
+
key: "fetchResourceOccupyDetailByResourceId",
|
|
1629
1854
|
value: function () {
|
|
1630
|
-
var
|
|
1631
|
-
var
|
|
1632
|
-
|
|
1633
|
-
|
|
1855
|
+
var _fetchResourceOccupyDetailByResourceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(resourceId) {
|
|
1856
|
+
var _this$otherParams9, _this$otherParams9$ge, _response$data$occupy, _response$data;
|
|
1857
|
+
var formRecordId, shopId, response;
|
|
1858
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
1859
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
1634
1860
|
case 0:
|
|
1635
|
-
|
|
1636
|
-
if (!(!Number.isFinite(
|
|
1637
|
-
|
|
1861
|
+
formRecordId = Number(resourceId);
|
|
1862
|
+
if (!(!Number.isFinite(formRecordId) || formRecordId <= 0)) {
|
|
1863
|
+
_context27.next = 3;
|
|
1638
1864
|
break;
|
|
1639
1865
|
}
|
|
1640
1866
|
throw new Error("[ScanOrder] \u975E\u6CD5\u684C\u53F0 resourceId: ".concat(resourceId));
|
|
1641
1867
|
case 3:
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1868
|
+
shopId = (_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 || (_this$otherParams9$ge = _this$otherParams9.getStateData) === null || _this$otherParams9$ge === void 0 ? void 0 : _this$otherParams9$ge.call(_this$otherParams9, 'shop_id');
|
|
1869
|
+
if (shopId) {
|
|
1870
|
+
_context27.next = 6;
|
|
1871
|
+
break;
|
|
1872
|
+
}
|
|
1873
|
+
throw new Error('[ScanOrder] 无法获取 shop_id');
|
|
1874
|
+
case 6:
|
|
1875
|
+
_context27.next = 8;
|
|
1876
|
+
return this.request.get('/order/resource/occupy-detail', {
|
|
1877
|
+
shop_id: shopId,
|
|
1878
|
+
'form_record_ids[]': formRecordId,
|
|
1879
|
+
with_resource_capacity_info: 1,
|
|
1880
|
+
with_resource_order_info: 1,
|
|
1881
|
+
with_resource_form_info: 1
|
|
1646
1882
|
});
|
|
1647
|
-
case
|
|
1648
|
-
response =
|
|
1883
|
+
case 8:
|
|
1884
|
+
response = _context27.sent;
|
|
1649
1885
|
if (response !== null && response !== void 0 && response.status) {
|
|
1650
|
-
|
|
1886
|
+
_context27.next = 11;
|
|
1651
1887
|
break;
|
|
1652
1888
|
}
|
|
1653
|
-
throw new Error((response === null || response === void 0 ? void 0 : response.message) || '
|
|
1654
|
-
case
|
|
1655
|
-
return
|
|
1656
|
-
case
|
|
1889
|
+
throw new Error((response === null || response === void 0 ? void 0 : response.message) || '获取资源占用详情失败');
|
|
1890
|
+
case 11:
|
|
1891
|
+
return _context27.abrupt("return", (_response$data$occupy = response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 || (_response$data = _response$data.occupy_details) === null || _response$data === void 0 ? void 0 : _response$data[0]) !== null && _response$data$occupy !== void 0 ? _response$data$occupy : null);
|
|
1892
|
+
case 12:
|
|
1657
1893
|
case "end":
|
|
1658
|
-
return
|
|
1894
|
+
return _context27.stop();
|
|
1659
1895
|
}
|
|
1660
|
-
},
|
|
1896
|
+
}, _callee27, this);
|
|
1661
1897
|
}));
|
|
1662
|
-
function
|
|
1663
|
-
return
|
|
1898
|
+
function fetchResourceOccupyDetailByResourceId(_x9) {
|
|
1899
|
+
return _fetchResourceOccupyDetailByResourceId.apply(this, arguments);
|
|
1664
1900
|
}
|
|
1665
|
-
return
|
|
1901
|
+
return fetchResourceOccupyDetailByResourceId;
|
|
1666
1902
|
}() // 检测当前链接是否可用
|
|
1667
1903
|
// 通过 resource_id + 店铺配置
|
|
1668
1904
|
// hasOrderId 表示 url 上是否有 orderid,如果是的话,后续的流程会走加单
|
|
1669
1905
|
}, {
|
|
1670
1906
|
key: "checkResourceAvailable",
|
|
1671
1907
|
value: function () {
|
|
1672
|
-
var _checkResourceAvailable = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1673
|
-
var _this$
|
|
1674
|
-
return _regeneratorRuntime().wrap(function
|
|
1675
|
-
while (1) switch (
|
|
1908
|
+
var _checkResourceAvailable = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(resourceId, hasOrderId) {
|
|
1909
|
+
var _this$otherParams10, _this$otherParams10$g, _occupyDetail$form_re, _occupyDetail$form_re2, _this$otherParams11, _this$store$order5, _this$store$order7, _this$store$order7$ge, _this$otherParams12, openData, dineInConfig, closedBehaviorValue, closedMessage, basicUnavailableMessage, pauseMessage, makeShopClosed, operatingHourIds, outsideOperatingHours, scheduleList, now, tempOrder, reservationLinkIds, pendingRequestEntryPax, pendingRequestPaxMin, pendingRequestPaxMax, reservationProductList, scheduleDate, scheduleDatetime, loaded, occupancyMinutes, paxBounds, occupyDetail, resourceSelectType, resourceState, availabilityInfo, _this$store$order6, _res$data, res, entryPaxNumber, lastOrderInfo, historicalItems;
|
|
1910
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
1911
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
1676
1912
|
case 0:
|
|
1677
1913
|
this.logMethodStart('checkResourceAvailable', {
|
|
1678
1914
|
resourceId: resourceId
|
|
1679
1915
|
});
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
return (_this$
|
|
1916
|
+
_context28.prev = 1;
|
|
1917
|
+
_context28.next = 4;
|
|
1918
|
+
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
1919
|
scope: 'board',
|
|
1684
1920
|
target: 'dine_in+scan_to_order',
|
|
1685
1921
|
section_code: ['basic', 'fulfillment', 'reservation', 'sale', 'menu', 'availability', 'workflow']
|
|
1686
1922
|
});
|
|
1687
1923
|
case 4:
|
|
1688
|
-
openData =
|
|
1924
|
+
openData = _context28.sent;
|
|
1689
1925
|
if (!((openData === null || openData === void 0 ? void 0 : openData.status) === false)) {
|
|
1690
|
-
|
|
1926
|
+
_context28.next = 7;
|
|
1691
1927
|
break;
|
|
1692
1928
|
}
|
|
1693
1929
|
throw new Error((openData === null || openData === void 0 ? void 0 : openData.message) || '获取店铺配置失败');
|
|
1694
1930
|
case 7:
|
|
1695
1931
|
dineInConfig = (openData === null || openData === void 0 ? void 0 : openData.data) || {};
|
|
1696
1932
|
this.otherParams.dineInConfig = dineInConfig;
|
|
1697
|
-
|
|
1933
|
+
_context28.next = 11;
|
|
1698
1934
|
return this.syncItemRuleConfigsFromDineInConfig(dineInConfig);
|
|
1699
1935
|
case 11:
|
|
1700
|
-
|
|
1936
|
+
closedBehaviorValue = dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.closed_behavior'];
|
|
1937
|
+
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']);
|
|
1938
|
+
basicUnavailableMessage = (dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['basic.unavailable_message']) || closedMessage;
|
|
1939
|
+
pauseMessage = (dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.pause_message']) || closedMessage;
|
|
1940
|
+
makeShopClosed = function makeShopClosed(errorTips, closed_behavior) {
|
|
1701
1941
|
return {
|
|
1702
1942
|
mode: 'shop_closed',
|
|
1703
1943
|
order_id: undefined,
|
|
1704
1944
|
relation_id: undefined,
|
|
1705
1945
|
table_form_id: undefined,
|
|
1706
1946
|
deskmate_valid: false,
|
|
1707
|
-
errorTips:
|
|
1947
|
+
errorTips: errorTips,
|
|
1948
|
+
closed_behavior: closed_behavior
|
|
1708
1949
|
};
|
|
1709
|
-
}; //
|
|
1950
|
+
}; // 1. 基础开关 basic.enable 关闭
|
|
1951
|
+
if (!((dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['basic.enable']) === false)) {
|
|
1952
|
+
_context28.next = 18;
|
|
1953
|
+
break;
|
|
1954
|
+
}
|
|
1955
|
+
return _context28.abrupt("return", makeShopClosed(basicUnavailableMessage));
|
|
1956
|
+
case 18:
|
|
1710
1957
|
if (!toBoolean(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.paused'])) {
|
|
1711
|
-
|
|
1958
|
+
_context28.next = 21;
|
|
1712
1959
|
break;
|
|
1713
1960
|
}
|
|
1714
1961
|
if (!((dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.pause_behavior']) === 'hide_all')) {
|
|
1715
|
-
|
|
1962
|
+
_context28.next = 21;
|
|
1716
1963
|
break;
|
|
1717
1964
|
}
|
|
1718
|
-
return
|
|
1719
|
-
case
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1965
|
+
return _context28.abrupt("return", makeShopClosed(pauseMessage));
|
|
1966
|
+
case 21:
|
|
1967
|
+
// 3. 营业时间 operating_hours 闸门
|
|
1968
|
+
operatingHourIds = Array.isArray(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.operating_hours']) ? dineInConfig['availability.operating_hours'].map(function (id) {
|
|
1969
|
+
return Number(id);
|
|
1970
|
+
}).filter(function (id) {
|
|
1971
|
+
return Number.isFinite(id) && id > 0;
|
|
1972
|
+
}) : [];
|
|
1973
|
+
outsideOperatingHours = false;
|
|
1974
|
+
if (operatingHourIds.length && this.store.schedule) {
|
|
1975
|
+
scheduleList = this.store.schedule.getScheduleListByIds(operatingHourIds);
|
|
1976
|
+
if (scheduleList.length) {
|
|
1977
|
+
now = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
1978
|
+
outsideOperatingHours = !getDateIsInSchedule(now, scheduleList);
|
|
1979
|
+
}
|
|
1980
|
+
}
|
|
1981
|
+
if (!(outsideOperatingHours && closedBehaviorValue !== 'show_menu_disabled')) {
|
|
1982
|
+
_context28.next = 26;
|
|
1983
|
+
break;
|
|
1984
|
+
}
|
|
1985
|
+
return _context28.abrupt("return", makeShopClosed(closedMessage, closedBehaviorValue));
|
|
1986
|
+
case 26:
|
|
1987
|
+
// Step1: 先加载预约规则商品,拿到 enabledReservationRuleProducts 与容量附加信息
|
|
1988
|
+
// (resourceSelectType 需要基于这些商品 + 占用接口的 form_id 计算,故必须前置)
|
|
1736
1989
|
tempOrder = this.ensureTempOrder();
|
|
1737
|
-
|
|
1738
|
-
tempOrder.table_form_id = resourceState.tableFormId;
|
|
1739
|
-
tempOrder.resource_id = resourceId;
|
|
1740
|
-
reservationLinkIds = collectLinkProductIdsFromReservationRules(dineInConfig['reservation.enabled_reservation_rules']);
|
|
1990
|
+
reservationLinkIds = collectLinkProductIdsFromReservationRules(dineInConfig['fulfillment.enabled_resource_rules']);
|
|
1741
1991
|
if (!(reservationLinkIds.length === 0)) {
|
|
1742
|
-
|
|
1992
|
+
_context28.next = 32;
|
|
1743
1993
|
break;
|
|
1744
1994
|
}
|
|
1745
1995
|
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;
|
|
1996
|
+
_context28.next = 43;
|
|
1752
1997
|
break;
|
|
1753
|
-
case
|
|
1998
|
+
case 32:
|
|
1754
1999
|
tempOrder.metadata = _objectSpread({}, tempOrder.metadata || {});
|
|
1755
2000
|
delete tempOrder.metadata.table_occupancy_duration;
|
|
1756
2001
|
reservationProductList = new ProductList("".concat(this.name, "_reservationEnabledRules"), this.defaultVersion);
|
|
1757
|
-
|
|
2002
|
+
_context28.next = 37;
|
|
1758
2003
|
return reservationProductList.initialize(this.core, {
|
|
1759
2004
|
store: {
|
|
1760
2005
|
list: [],
|
|
@@ -1766,18 +2011,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1766
2011
|
cacheId: this.cacheId
|
|
1767
2012
|
})
|
|
1768
2013
|
});
|
|
1769
|
-
case
|
|
2014
|
+
case 37:
|
|
1770
2015
|
scheduleDate = dayjs().format('YYYY-MM-DD');
|
|
1771
2016
|
scheduleDatetime = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
1772
|
-
|
|
2017
|
+
_context28.next = 41;
|
|
1773
2018
|
return reservationProductList.loadProducts({
|
|
1774
2019
|
product_ids: reservationLinkIds,
|
|
1775
2020
|
schedule_date: scheduleDate,
|
|
1776
2021
|
schedule_datetime: scheduleDatetime,
|
|
1777
2022
|
cacheId: this.cacheId
|
|
1778
2023
|
});
|
|
1779
|
-
case
|
|
1780
|
-
loaded =
|
|
2024
|
+
case 41:
|
|
2025
|
+
loaded = _context28.sent;
|
|
1781
2026
|
if (Array.isArray(loaded)) {
|
|
1782
2027
|
this.enabledReservationRuleProducts = loaded;
|
|
1783
2028
|
occupancyMinutes = pickFirstDurationMinutesFromProducts(loaded);
|
|
@@ -1785,35 +2030,13 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1785
2030
|
tempOrder.metadata.table_occupancy_duration = occupancyMinutes;
|
|
1786
2031
|
}
|
|
1787
2032
|
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
|
-
}
|
|
2033
|
+
pendingRequestEntryPax = 1;
|
|
1796
2034
|
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;
|
|
2035
|
+
if ((paxBounds === null || paxBounds === void 0 ? void 0 : paxBounds.min) !== undefined) pendingRequestPaxMin = paxBounds.min;
|
|
2036
|
+
if ((paxBounds === null || paxBounds === void 0 ? void 0 : paxBounds.max) !== undefined) pendingRequestPaxMax = paxBounds.max;
|
|
1809
2037
|
}
|
|
1810
2038
|
} else {
|
|
1811
2039
|
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
2040
|
void this.addScanOrderLog({
|
|
1818
2041
|
level: 'error',
|
|
1819
2042
|
title: '[ScanOrder] enabled_reservation_rules product query failed',
|
|
@@ -1823,41 +2046,80 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1823
2046
|
}
|
|
1824
2047
|
});
|
|
1825
2048
|
}
|
|
1826
|
-
case
|
|
2049
|
+
case 43:
|
|
2050
|
+
_context28.next = 45;
|
|
2051
|
+
return this.fetchResourceOccupyDetailByResourceId(resourceId);
|
|
2052
|
+
case 45:
|
|
2053
|
+
occupyDetail = _context28.sent;
|
|
2054
|
+
// Step3: 结合预约规则商品的 product_resource.resources 与占用接口返回的 form_id,
|
|
2055
|
+
// 计算当前桌台的 resourceSelectType(single/multiple/capacity)
|
|
2056
|
+
resourceSelectType = this.resolveResourceSelectType(toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_id)); // Step4: 用 occupyDetail + resourceSelectType 规整为 resourceState
|
|
2057
|
+
resourceState = this.normalizeResourceState(occupyDetail, resourceSelectType, hasOrderId);
|
|
2058
|
+
this.store.resource = resourceState;
|
|
2059
|
+
|
|
2060
|
+
// Step5: 把预约规则商品阶段暂存的 requestEntryPax 等注入 store.resource
|
|
2061
|
+
if (pendingRequestEntryPax !== undefined) {
|
|
2062
|
+
this.store.resource.requestEntryPax = pendingRequestEntryPax;
|
|
2063
|
+
}
|
|
2064
|
+
if (pendingRequestPaxMin !== undefined) {
|
|
2065
|
+
this.store.resource.requestPaxMin = pendingRequestPaxMin;
|
|
2066
|
+
}
|
|
2067
|
+
if (pendingRequestPaxMax !== undefined) {
|
|
2068
|
+
this.store.resource.requestPaxMax = pendingRequestPaxMax;
|
|
2069
|
+
}
|
|
2070
|
+
availabilityInfo = _objectSpread(_objectSpread(_objectSpread({
|
|
2071
|
+
mode: resourceState.mode,
|
|
2072
|
+
order_id: resourceState.order_id,
|
|
2073
|
+
relation_id: resourceState.relationId,
|
|
2074
|
+
table_form_id: resourceState.tableFormId,
|
|
2075
|
+
deskmate_valid: resourceState.deskmate_valid,
|
|
2076
|
+
table_form_record: resourceState.table_form_record,
|
|
2077
|
+
policy: occupyDetail === null || occupyDetail === void 0 || (_occupyDetail$form_re = occupyDetail.form_record) === null || _occupyDetail$form_re === void 0 ? void 0 : _occupyDetail$form_re.policy,
|
|
2078
|
+
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
|
|
2079
|
+
}, this.store.resource.requestEntryPax !== undefined ? {
|
|
2080
|
+
requestEntryPax: this.store.resource.requestEntryPax
|
|
2081
|
+
} : {}), this.store.resource.requestPaxMin !== undefined ? {
|
|
2082
|
+
requestPaxMin: this.store.resource.requestPaxMin
|
|
2083
|
+
} : {}), this.store.resource.requestPaxMax !== undefined ? {
|
|
2084
|
+
requestPaxMax: this.store.resource.requestPaxMax
|
|
2085
|
+
} : {});
|
|
2086
|
+
tempOrder.relation_id = resourceId || ((_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.relation_id);
|
|
2087
|
+
tempOrder.table_form_id = resourceState.tableFormId;
|
|
2088
|
+
tempOrder.resource_id = resourceId;
|
|
1827
2089
|
(_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 || _this$store$order5.persistTempOrder();
|
|
1828
2090
|
|
|
1829
2091
|
// 空闲状态下自动准备本地临时订单,供后续“购物车式”商品操作使用
|
|
1830
2092
|
if (!(availabilityInfo.mode === 'idle')) {
|
|
1831
|
-
|
|
2093
|
+
_context28.next = 60;
|
|
1832
2094
|
break;
|
|
1833
2095
|
}
|
|
1834
|
-
|
|
2096
|
+
_context28.next = 60;
|
|
1835
2097
|
return this.addNewOrder();
|
|
1836
|
-
case
|
|
2098
|
+
case 60:
|
|
1837
2099
|
// 如果是加单模式,tempOrder 里 需要记录 lastOrderId,提交的时候走加单接口
|
|
1838
2100
|
if (availabilityInfo.mode === 'additional_order' || availabilityInfo.mode === 'additional_order_with_code') {
|
|
1839
2101
|
tempOrder.order_id = resourceState.lastOrderId;
|
|
1840
2102
|
}
|
|
1841
2103
|
if (!tempOrder.order_id) {
|
|
1842
|
-
|
|
2104
|
+
_context28.next = 69;
|
|
1843
2105
|
break;
|
|
1844
2106
|
}
|
|
1845
|
-
|
|
2107
|
+
_context28.next = 64;
|
|
1846
2108
|
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 =
|
|
2109
|
+
case 64:
|
|
2110
|
+
res = _context28.sent;
|
|
1849
2111
|
// 找到下单的时候输入的 entryPaxNumber
|
|
1850
2112
|
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
2113
|
var _p$metadata;
|
|
1852
2114
|
return (_p$metadata = p.metadata) === null || _p$metadata === void 0 ? void 0 : _p$metadata.collect_pax;
|
|
1853
2115
|
})) === null || _res$data === void 0 || (_res$data = _res$data.metadata) === null || _res$data === void 0 ? void 0 : _res$data.collect_pax;
|
|
1854
2116
|
if (!entryPaxNumber) {
|
|
1855
|
-
|
|
2117
|
+
_context28.next = 69;
|
|
1856
2118
|
break;
|
|
1857
2119
|
}
|
|
1858
|
-
|
|
2120
|
+
_context28.next = 69;
|
|
1859
2121
|
return this.setEntryPaxNumber(entryPaxNumber);
|
|
1860
|
-
case
|
|
2122
|
+
case 69:
|
|
1861
2123
|
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
2124
|
historicalItems = hasOrderId && Array.isArray(lastOrderInfo === null || lastOrderInfo === void 0 ? void 0 : lastOrderInfo.products) ? lastOrderInfo.products.reduce(function (acc, p) {
|
|
1863
2125
|
if (typeof (p === null || p === void 0 ? void 0 : p.product_id) !== 'number') return acc;
|
|
@@ -1869,13 +2131,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1869
2131
|
} : {}));
|
|
1870
2132
|
return acc;
|
|
1871
2133
|
}, []) : []; // pax 由 setEntryPaxNumber 负责写入 itemRuleRuntimeConfig.pax
|
|
1872
|
-
|
|
2134
|
+
_context28.next = 73;
|
|
1873
2135
|
return this.setItemRuleRuntimeConfig({
|
|
1874
|
-
serviceType: (_this$
|
|
2136
|
+
serviceType: (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.businessCode,
|
|
1875
2137
|
submissionIndex: hasOrderId ? 1 : 0,
|
|
1876
2138
|
historicalItems: historicalItems
|
|
1877
2139
|
});
|
|
1878
|
-
case
|
|
2140
|
+
case 73:
|
|
2141
|
+
// operating_hours 超出营业时段 + closed_behavior=show_menu_disabled:
|
|
2142
|
+
// 允许浏览商品但 UI 层需拦截“下一步”,这里覆盖最终 mode 并回传错误提示
|
|
2143
|
+
if (outsideOperatingHours && closedBehaviorValue === 'show_menu_disabled') {
|
|
2144
|
+
availabilityInfo.mode = 'submit_disabled';
|
|
2145
|
+
availabilityInfo.errorTips = closedMessage;
|
|
2146
|
+
availabilityInfo.closed_behavior = closedBehaviorValue;
|
|
2147
|
+
}
|
|
1879
2148
|
this.logMethodSuccess('checkResourceAvailable', {
|
|
1880
2149
|
resourceId: resourceId,
|
|
1881
2150
|
mode: availabilityInfo.mode,
|
|
@@ -1885,24 +2154,23 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1885
2154
|
persistedRelationId: tempOrder.relation_id,
|
|
1886
2155
|
persistedResourceId: tempOrder.resource_id,
|
|
1887
2156
|
deskmateValid: availabilityInfo.deskmate_valid,
|
|
1888
|
-
|
|
1889
|
-
tableMaxNumber: resourceState.tableMaxNumber,
|
|
2157
|
+
resourceSelectType: resourceState.resourceSelectType,
|
|
1890
2158
|
isExclusive: resourceState.isExclusive,
|
|
1891
2159
|
isFull: resourceState.isFull
|
|
1892
2160
|
});
|
|
1893
|
-
return
|
|
1894
|
-
case
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
this.logMethodError('checkResourceAvailable',
|
|
2161
|
+
return _context28.abrupt("return", availabilityInfo);
|
|
2162
|
+
case 78:
|
|
2163
|
+
_context28.prev = 78;
|
|
2164
|
+
_context28.t0 = _context28["catch"](1);
|
|
2165
|
+
this.logMethodError('checkResourceAvailable', _context28.t0.message, {
|
|
1898
2166
|
resourceId: resourceId
|
|
1899
2167
|
});
|
|
1900
|
-
throw
|
|
1901
|
-
case
|
|
2168
|
+
throw _context28.t0;
|
|
2169
|
+
case 82:
|
|
1902
2170
|
case "end":
|
|
1903
|
-
return
|
|
2171
|
+
return _context28.stop();
|
|
1904
2172
|
}
|
|
1905
|
-
},
|
|
2173
|
+
}, _callee28, this, [[1, 78]]);
|
|
1906
2174
|
}));
|
|
1907
2175
|
function checkResourceAvailable(_x10, _x11) {
|
|
1908
2176
|
return _checkResourceAvailable.apply(this, arguments);
|
|
@@ -1912,10 +2180,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1912
2180
|
}, {
|
|
1913
2181
|
key: "getAdditionalOrderInfo",
|
|
1914
2182
|
value: function () {
|
|
1915
|
-
var _getAdditionalOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2183
|
+
var _getAdditionalOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
|
|
1916
2184
|
var result;
|
|
1917
|
-
return _regeneratorRuntime().wrap(function
|
|
1918
|
-
while (1) switch (
|
|
2185
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
2186
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
1919
2187
|
case 0:
|
|
1920
2188
|
this.logMethodStart('getAdditionalOrderInfo');
|
|
1921
2189
|
result = {
|
|
@@ -1929,12 +2197,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1929
2197
|
orderId: result.orderId,
|
|
1930
2198
|
orderStatus: result.orderStatus
|
|
1931
2199
|
});
|
|
1932
|
-
return
|
|
2200
|
+
return _context29.abrupt("return", result);
|
|
1933
2201
|
case 4:
|
|
1934
2202
|
case "end":
|
|
1935
|
-
return
|
|
2203
|
+
return _context29.stop();
|
|
1936
2204
|
}
|
|
1937
|
-
},
|
|
2205
|
+
}, _callee29, this);
|
|
1938
2206
|
}));
|
|
1939
2207
|
function getAdditionalOrderInfo() {
|
|
1940
2208
|
return _getAdditionalOrderInfo.apply(this, arguments);
|
|
@@ -1944,19 +2212,19 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1944
2212
|
}, {
|
|
1945
2213
|
key: "getProductList",
|
|
1946
2214
|
value: function () {
|
|
1947
|
-
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1948
|
-
var _this$
|
|
2215
|
+
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
|
|
2216
|
+
var _this$otherParams13;
|
|
1949
2217
|
var menu_list_ids, _this$store$products, res, formattedRes;
|
|
1950
|
-
return _regeneratorRuntime().wrap(function
|
|
1951
|
-
while (1) switch (
|
|
2218
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
2219
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
1952
2220
|
case 0:
|
|
1953
2221
|
this.logMethodStart('getProductList');
|
|
1954
2222
|
// 可以直接通过配置里的 menu 读取
|
|
1955
|
-
menu_list_ids = ((_this$
|
|
2223
|
+
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
2224
|
return Number(n.value);
|
|
1957
2225
|
})) || [];
|
|
1958
|
-
|
|
1959
|
-
|
|
2226
|
+
_context30.prev = 2;
|
|
2227
|
+
_context30.next = 5;
|
|
1960
2228
|
return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
|
|
1961
2229
|
menu_list_ids: menu_list_ids,
|
|
1962
2230
|
cacheId: this.cacheId,
|
|
@@ -1964,22 +2232,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1964
2232
|
schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
1965
2233
|
});
|
|
1966
2234
|
case 5:
|
|
1967
|
-
res =
|
|
2235
|
+
res = _context30.sent;
|
|
1968
2236
|
formattedRes = attachItemRuleLimitsToTopLevelProducts(res, this.store.itemRuleQuantityLimits || []);
|
|
1969
2237
|
this.logMethodSuccess('getProductList', {
|
|
1970
2238
|
menuCount: menu_list_ids.length
|
|
1971
2239
|
});
|
|
1972
|
-
return
|
|
2240
|
+
return _context30.abrupt("return", formattedRes);
|
|
1973
2241
|
case 11:
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
this.logMethodError('getProductList',
|
|
1977
|
-
throw
|
|
2242
|
+
_context30.prev = 11;
|
|
2243
|
+
_context30.t0 = _context30["catch"](2);
|
|
2244
|
+
this.logMethodError('getProductList', _context30.t0.message);
|
|
2245
|
+
throw _context30.t0;
|
|
1978
2246
|
case 15:
|
|
1979
2247
|
case "end":
|
|
1980
|
-
return
|
|
2248
|
+
return _context30.stop();
|
|
1981
2249
|
}
|
|
1982
|
-
},
|
|
2250
|
+
}, _callee30, this, [[2, 11]]);
|
|
1983
2251
|
}));
|
|
1984
2252
|
function getProductList() {
|
|
1985
2253
|
return _getProductList.apply(this, arguments);
|
|
@@ -1994,15 +2262,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1994
2262
|
}, {
|
|
1995
2263
|
key: "setOtherParams",
|
|
1996
2264
|
value: function () {
|
|
1997
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1998
|
-
var
|
|
1999
|
-
|
|
2265
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
|
|
2266
|
+
var _ref6,
|
|
2267
|
+
_ref6$cover,
|
|
2000
2268
|
cover,
|
|
2001
|
-
|
|
2002
|
-
return _regeneratorRuntime().wrap(function
|
|
2003
|
-
while (1) switch (
|
|
2269
|
+
_args31 = arguments;
|
|
2270
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
2271
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
2004
2272
|
case 0:
|
|
2005
|
-
|
|
2273
|
+
_ref6 = _args31.length > 1 && _args31[1] !== undefined ? _args31[1] : {}, _ref6$cover = _ref6.cover, cover = _ref6$cover === void 0 ? false : _ref6$cover;
|
|
2006
2274
|
if (cover) {
|
|
2007
2275
|
this.otherParams = params;
|
|
2008
2276
|
} else {
|
|
@@ -2010,22 +2278,97 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2010
2278
|
}
|
|
2011
2279
|
case 2:
|
|
2012
2280
|
case "end":
|
|
2013
|
-
return
|
|
2281
|
+
return _context31.stop();
|
|
2014
2282
|
}
|
|
2015
|
-
},
|
|
2283
|
+
}, _callee31, this);
|
|
2016
2284
|
}));
|
|
2017
2285
|
function setOtherParams(_x12) {
|
|
2018
2286
|
return _setOtherParams.apply(this, arguments);
|
|
2019
2287
|
}
|
|
2020
2288
|
return setOtherParams;
|
|
2021
|
-
}()
|
|
2289
|
+
}() // ─── UI 状态缓存(按 cacheId 分桶,sessionStorage) ───
|
|
2290
|
+
//
|
|
2291
|
+
// 用于物料层持久化 UI 层面的轻量状态(如当前步骤、gate 标记、登录回跳意图等)。
|
|
2292
|
+
// 桶键:pisell.scanOrder.uiState:<cacheId>;内部以 JSON object 形式存储多个字段。
|
|
2293
|
+
// 无 cacheId 时所有方法自动降级为 no-op,上层不用判空。
|
|
2294
|
+
}, {
|
|
2295
|
+
key: "getUIStateBucketKey",
|
|
2296
|
+
value: function getUIStateBucketKey() {
|
|
2297
|
+
if (!this.cacheId) return null;
|
|
2298
|
+
return "".concat(ScanOrderImpl.UI_STATE_KEY_PREFIX).concat(this.cacheId);
|
|
2299
|
+
}
|
|
2300
|
+
}, {
|
|
2301
|
+
key: "readUIStateBucket",
|
|
2302
|
+
value: function readUIStateBucket() {
|
|
2303
|
+
var _this$window;
|
|
2304
|
+
var key = this.getUIStateBucketKey();
|
|
2305
|
+
if (!key || !((_this$window = this.window) !== null && _this$window !== void 0 && _this$window.sessionStorage)) return {};
|
|
2306
|
+
try {
|
|
2307
|
+
var raw = this.window.sessionStorage.getItem(key) || '{}';
|
|
2308
|
+
var parsed = JSON.parse(raw);
|
|
2309
|
+
return parsed && _typeof(parsed) === 'object' ? parsed : {};
|
|
2310
|
+
} catch (_unused) {
|
|
2311
|
+
return {};
|
|
2312
|
+
}
|
|
2313
|
+
}
|
|
2314
|
+
}, {
|
|
2315
|
+
key: "writeUIStateBucket",
|
|
2316
|
+
value: function writeUIStateBucket(bucket) {
|
|
2317
|
+
var _this$window2;
|
|
2318
|
+
var key = this.getUIStateBucketKey();
|
|
2319
|
+
if (!key || !((_this$window2 = this.window) !== null && _this$window2 !== void 0 && _this$window2.sessionStorage)) return;
|
|
2320
|
+
try {
|
|
2321
|
+
this.window.sessionStorage.setItem(key, JSON.stringify(bucket));
|
|
2322
|
+
} catch (error) {
|
|
2323
|
+
console.warn('[ScanOrder] writeUIStateBucket failed', error);
|
|
2324
|
+
}
|
|
2325
|
+
}
|
|
2326
|
+
}, {
|
|
2327
|
+
key: "setUIState",
|
|
2328
|
+
value: function setUIState(key, value) {
|
|
2329
|
+
if (!this.getUIStateBucketKey()) return;
|
|
2330
|
+
var bucket = this.readUIStateBucket();
|
|
2331
|
+
bucket[key] = value;
|
|
2332
|
+
this.writeUIStateBucket(bucket);
|
|
2333
|
+
}
|
|
2334
|
+
}, {
|
|
2335
|
+
key: "getUIState",
|
|
2336
|
+
value: function getUIState(key) {
|
|
2337
|
+
if (!this.getUIStateBucketKey()) return undefined;
|
|
2338
|
+
var bucket = this.readUIStateBucket();
|
|
2339
|
+
return bucket[key];
|
|
2340
|
+
}
|
|
2341
|
+
}, {
|
|
2342
|
+
key: "deleteUIState",
|
|
2343
|
+
value: function deleteUIState(key) {
|
|
2344
|
+
if (!this.getUIStateBucketKey()) return;
|
|
2345
|
+
var bucket = this.readUIStateBucket();
|
|
2346
|
+
if (key in bucket) {
|
|
2347
|
+
delete bucket[key];
|
|
2348
|
+
this.writeUIStateBucket(bucket);
|
|
2349
|
+
}
|
|
2350
|
+
}
|
|
2351
|
+
|
|
2352
|
+
// 整桶清空(用于扫新桌、提交成功、restoreOrder 等场景)
|
|
2353
|
+
}, {
|
|
2354
|
+
key: "clearUIState",
|
|
2355
|
+
value: function clearUIState() {
|
|
2356
|
+
var _this$window3;
|
|
2357
|
+
var key = this.getUIStateBucketKey();
|
|
2358
|
+
if (!key || !((_this$window3 = this.window) !== null && _this$window3 !== void 0 && _this$window3.sessionStorage)) return;
|
|
2359
|
+
try {
|
|
2360
|
+
this.window.sessionStorage.removeItem(key);
|
|
2361
|
+
} catch (error) {
|
|
2362
|
+
console.warn('[ScanOrder] clearUIState failed', error);
|
|
2363
|
+
}
|
|
2364
|
+
}
|
|
2022
2365
|
}, {
|
|
2023
2366
|
key: "setEntryPaxNumber",
|
|
2024
2367
|
value: function () {
|
|
2025
|
-
var _setEntryPaxNumber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2368
|
+
var _setEntryPaxNumber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(number) {
|
|
2026
2369
|
var pax, t;
|
|
2027
|
-
return _regeneratorRuntime().wrap(function
|
|
2028
|
-
while (1) switch (
|
|
2370
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
2371
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
2029
2372
|
case 0:
|
|
2030
2373
|
pax = normalizeSubmitCollectPaxValue(number);
|
|
2031
2374
|
this.store.entryPaxNumber = pax;
|
|
@@ -2046,16 +2389,16 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2046
2389
|
}
|
|
2047
2390
|
});
|
|
2048
2391
|
this.itemRulePrefillApplied = false;
|
|
2049
|
-
|
|
2392
|
+
_context32.next = 7;
|
|
2050
2393
|
return this.refreshItemRuleQuantityLimits();
|
|
2051
2394
|
case 7:
|
|
2052
|
-
|
|
2395
|
+
_context32.next = 9;
|
|
2053
2396
|
return this.refreshCartValidationPassed();
|
|
2054
2397
|
case 9:
|
|
2055
2398
|
case "end":
|
|
2056
|
-
return
|
|
2399
|
+
return _context32.stop();
|
|
2057
2400
|
}
|
|
2058
|
-
},
|
|
2401
|
+
}, _callee32, this);
|
|
2059
2402
|
}));
|
|
2060
2403
|
function setEntryPaxNumber(_x13) {
|
|
2061
2404
|
return _setEntryPaxNumber.apply(this, arguments);
|
|
@@ -2067,6 +2410,47 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2067
2410
|
value: function getEntryPaxNumber() {
|
|
2068
2411
|
return this.store.entryPaxNumber;
|
|
2069
2412
|
}
|
|
2413
|
+
|
|
2414
|
+
// 读取取餐/送餐开关
|
|
2415
|
+
// 依赖 checkResourceAvailable 已缓存的 dineInConfig
|
|
2416
|
+
}, {
|
|
2417
|
+
key: "getFulfillmentModes",
|
|
2418
|
+
value: function getFulfillmentModes() {
|
|
2419
|
+
var _this$otherParams14;
|
|
2420
|
+
this.logMethodStart('getFulfillmentModes');
|
|
2421
|
+
var dineInConfig = ((_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.dineInConfig) || {};
|
|
2422
|
+
var result = {
|
|
2423
|
+
enablePickup: Boolean(dineInConfig['fulfillment.enable_pickup']),
|
|
2424
|
+
enableTableService: Boolean(dineInConfig['fulfillment.enable_table_service'])
|
|
2425
|
+
};
|
|
2426
|
+
this.logMethodSuccess('getFulfillmentModes', result);
|
|
2427
|
+
return result;
|
|
2428
|
+
}
|
|
2429
|
+
|
|
2430
|
+
// 判定后台是否开启客户自定义取餐标识
|
|
2431
|
+
// 依赖 checkResourceAvailable 已缓存的 dineInConfig
|
|
2432
|
+
}, {
|
|
2433
|
+
key: "checkManualPickupRef",
|
|
2434
|
+
value: function checkManualPickupRef() {
|
|
2435
|
+
var _this$otherParams15;
|
|
2436
|
+
this.logMethodStart('checkManualPickupRef');
|
|
2437
|
+
var dineInConfig = ((_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.dineInConfig) || {};
|
|
2438
|
+
var refMode = dineInConfig['fulfillment.fulfillment_ref_mode'];
|
|
2439
|
+
var manualInputType = dineInConfig['fulfillment.manual_input_type'];
|
|
2440
|
+
var enabled = refMode === 'manual_input';
|
|
2441
|
+
var result = enabled ? {
|
|
2442
|
+
enabled: true,
|
|
2443
|
+
manualInputType: manualInputType
|
|
2444
|
+
} : {
|
|
2445
|
+
enabled: false
|
|
2446
|
+
};
|
|
2447
|
+
this.logMethodSuccess('checkManualPickupRef', {
|
|
2448
|
+
enabled: enabled,
|
|
2449
|
+
manualInputType: enabled ? manualInputType : undefined
|
|
2450
|
+
});
|
|
2451
|
+
return result;
|
|
2452
|
+
}
|
|
2070
2453
|
}]);
|
|
2071
2454
|
return ScanOrderImpl;
|
|
2072
|
-
}(BaseModule);
|
|
2455
|
+
}(BaseModule);
|
|
2456
|
+
_defineProperty(ScanOrderImpl, "UI_STATE_KEY_PREFIX", 'pisell.scanOrder.uiState:');
|