@pisell/pisellos 2.3.37 → 2.3.39
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/Discount/index.d.ts +1 -0
- package/dist/modules/Discount/index.js +40 -11
- package/dist/modules/Discount/types.d.ts +1 -0
- package/dist/modules/Holder/index.d.ts +48 -0
- package/dist/modules/Holder/index.js +640 -0
- package/dist/modules/Holder/types.d.ts +123 -0
- package/dist/modules/Holder/types.js +1 -0
- package/dist/modules/Holder/utils.d.ts +13 -0
- package/dist/modules/Holder/utils.js +34 -0
- package/dist/modules/OpenData/index.js +2 -2
- package/dist/modules/Order/index.d.ts +11 -28
- package/dist/modules/Order/index.js +513 -747
- package/dist/modules/Order/types.d.ts +10 -33
- package/dist/modules/Order/utils/orderCollectionIdentity.js +2 -7
- package/dist/modules/Order/utils.d.ts +10 -0
- package/dist/modules/Order/utils.js +40 -11
- package/dist/modules/Payment/index.d.ts +0 -2
- package/dist/modules/Payment/index.js +49 -78
- package/dist/modules/Payment/types.d.ts +24 -26
- package/dist/modules/Payment/types.js +0 -2
- package/dist/modules/Product/types.d.ts +1 -0
- package/dist/modules/ProductList/index.js +33 -14
- package/dist/modules/Quotation/index.d.ts +1 -1
- package/dist/modules/Quotation/index.js +2 -2
- package/dist/modules/ResourcePlanner/index.d.ts +24 -0
- package/dist/modules/ResourcePlanner/index.js +181 -0
- package/dist/modules/ResourcePlanner/planner.d.ts +14 -0
- package/dist/modules/ResourcePlanner/planner.js +1069 -0
- package/dist/modules/ResourcePlanner/types.d.ts +227 -0
- package/dist/modules/ResourcePlanner/types.js +1 -0
- package/dist/modules/Rules/index.js +48 -15
- package/dist/modules/SalesSummary/index.js +12 -13
- package/dist/modules/ScanOrderLogger/index.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/index.js +15 -2
- package/dist/modules/ScanOrderLogger/providers/feishu.js +45 -27
- package/dist/modules/ScanOrderLogger/types.d.ts +1 -0
- package/dist/modules/Schedule/index.d.ts +3 -1
- package/dist/modules/Schedule/index.js +21 -16
- package/dist/modules/Summary/utils.js +38 -13
- package/dist/modules/index.d.ts +2 -0
- package/dist/modules/index.js +3 -1
- package/dist/plugins/window.d.ts +1 -0
- package/dist/server/index.d.ts +14 -16
- package/dist/server/index.js +1162 -1943
- package/dist/server/modules/order/index.d.ts +4 -49
- package/dist/server/modules/order/index.js +695 -1574
- package/dist/server/modules/order/types.d.ts +3 -11
- package/dist/server/modules/order/types.js +1 -1
- package/dist/solution/BaseSales/index.d.ts +10 -33
- package/dist/solution/BaseSales/index.js +385 -676
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
- package/dist/solution/BookingByStep/index.d.ts +17 -2
- package/dist/solution/BookingByStep/index.js +294 -215
- package/dist/solution/BookingByStep/types.d.ts +2 -1
- package/dist/solution/BookingByStep/types.js +3 -1
- package/dist/solution/BookingByStep/utils/capacity.js +17 -1
- package/dist/solution/BookingByStep/utils/timeslots.d.ts +3 -1
- package/dist/solution/BookingByStep/utils/timeslots.js +19 -12
- package/dist/solution/BookingTicket/index.js +1 -2
- package/dist/solution/Sales/index.d.ts +0 -1
- package/dist/solution/Sales/index.js +2 -10
- package/dist/solution/ScanOrder/index.d.ts +26 -14
- package/dist/solution/ScanOrder/index.js +1140 -737
- package/dist/solution/ScanOrder/types.d.ts +21 -1
- package/dist/solution/ScanOrder/utils.d.ts +8 -0
- package/dist/solution/ScanOrder/utils.js +66 -25
- package/dist/solution/ShopDiscount/index.d.ts +1 -0
- package/dist/solution/ShopDiscount/index.js +125 -87
- package/dist/solution/UnifiedBookingSales/index.d.ts +183 -0
- package/dist/solution/UnifiedBookingSales/index.js +1871 -0
- package/dist/solution/UnifiedBookingSales/types.d.ts +143 -0
- package/dist/solution/UnifiedBookingSales/types.js +11 -0
- package/dist/solution/VenueBooking/index.d.ts +39 -11
- package/dist/solution/VenueBooking/index.js +1177 -850
- package/dist/solution/VenueBooking/types.d.ts +3 -0
- package/dist/solution/VenueBooking/utils/resource.js +1 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
- package/dist/solution/VenueBooking/utils/slotMerge.js +10 -5
- package/dist/solution/index.d.ts +1 -0
- package/dist/solution/index.js +2 -1
- package/dist/types/index.d.ts +1 -0
- package/lib/modules/Discount/index.d.ts +1 -0
- package/lib/modules/Discount/index.js +9 -0
- package/lib/modules/Discount/types.d.ts +1 -0
- package/lib/modules/Holder/index.d.ts +48 -0
- package/lib/modules/Holder/index.js +402 -0
- package/lib/modules/Holder/types.d.ts +123 -0
- package/lib/modules/Holder/types.js +17 -0
- package/lib/modules/Holder/utils.d.ts +13 -0
- package/lib/modules/Holder/utils.js +71 -0
- package/lib/modules/OpenData/index.js +1 -1
- package/lib/modules/Order/index.d.ts +11 -28
- package/lib/modules/Order/index.js +83 -187
- package/lib/modules/Order/types.d.ts +10 -33
- package/lib/modules/Order/utils/orderCollectionIdentity.js +0 -3
- package/lib/modules/Order/utils.d.ts +10 -0
- package/lib/modules/Order/utils.js +39 -10
- package/lib/modules/Payment/index.d.ts +0 -2
- package/lib/modules/Payment/index.js +12 -33
- package/lib/modules/Payment/types.d.ts +24 -26
- package/lib/modules/Product/types.d.ts +1 -0
- package/lib/modules/ProductList/index.js +40 -31
- package/lib/modules/Quotation/index.d.ts +1 -1
- package/lib/modules/Quotation/index.js +2 -2
- package/lib/modules/ResourcePlanner/index.d.ts +24 -0
- package/lib/modules/ResourcePlanner/index.js +148 -0
- package/lib/modules/ResourcePlanner/planner.d.ts +14 -0
- package/lib/modules/ResourcePlanner/planner.js +933 -0
- package/lib/modules/ResourcePlanner/types.d.ts +227 -0
- package/lib/modules/ResourcePlanner/types.js +17 -0
- package/lib/modules/Rules/index.js +34 -18
- package/lib/modules/SalesSummary/index.js +6 -7
- package/lib/modules/ScanOrderLogger/index.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/index.js +13 -1
- package/lib/modules/ScanOrderLogger/providers/feishu.js +15 -6
- package/lib/modules/ScanOrderLogger/types.d.ts +1 -0
- package/lib/modules/Schedule/index.d.ts +3 -1
- package/lib/modules/Schedule/index.js +10 -8
- package/lib/modules/Summary/utils.js +21 -1
- package/lib/modules/index.d.ts +2 -0
- package/lib/modules/index.js +5 -1
- package/lib/plugins/window.d.ts +1 -0
- package/lib/server/index.d.ts +14 -16
- package/lib/server/index.js +88 -678
- package/lib/server/modules/order/index.d.ts +4 -49
- package/lib/server/modules/order/index.js +66 -657
- package/lib/server/modules/order/types.d.ts +3 -11
- package/lib/solution/BaseSales/index.d.ts +10 -33
- package/lib/solution/BaseSales/index.js +33 -201
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
- package/lib/solution/BookingByStep/index.d.ts +17 -2
- package/lib/solution/BookingByStep/index.js +60 -18
- package/lib/solution/BookingByStep/types.d.ts +2 -1
- package/lib/solution/BookingByStep/types.js +5 -0
- package/lib/solution/BookingByStep/utils/capacity.js +20 -1
- package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
- package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
- package/lib/solution/BookingTicket/index.js +1 -2
- package/lib/solution/Sales/index.d.ts +0 -1
- package/lib/solution/Sales/index.js +3 -5
- package/lib/solution/ScanOrder/index.d.ts +26 -14
- package/lib/solution/ScanOrder/index.js +449 -182
- package/lib/solution/ScanOrder/types.d.ts +21 -1
- package/lib/solution/ScanOrder/utils.d.ts +8 -0
- package/lib/solution/ScanOrder/utils.js +31 -0
- package/lib/solution/ShopDiscount/index.d.ts +1 -0
- package/lib/solution/ShopDiscount/index.js +14 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +183 -0
- package/lib/solution/UnifiedBookingSales/index.js +1076 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +143 -0
- package/lib/solution/UnifiedBookingSales/types.js +33 -0
- package/lib/solution/VenueBooking/index.d.ts +39 -11
- package/lib/solution/VenueBooking/index.js +328 -115
- package/lib/solution/VenueBooking/types.d.ts +3 -0
- package/lib/solution/VenueBooking/utils/resource.js +1 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
- package/lib/solution/VenueBooking/utils/slotMerge.js +6 -4
- package/lib/solution/index.d.ts +1 -0
- package/lib/solution/index.js +3 -1
- package/lib/types/index.d.ts +1 -0
- package/package.json +2 -2
- package/dist/modules/Order/payment-utils.d.ts +0 -26
- package/dist/modules/Order/payment-utils.js +0 -225
- package/dist/utils/payment-number.d.ts +0 -9
- package/dist/utils/payment-number.js +0 -69
- package/lib/modules/Order/payment-utils.d.ts +0 -26
- package/lib/modules/Order/payment-utils.js +0 -224
- package/lib/utils/payment-number.d.ts +0 -9
- package/lib/utils/payment-number.js +0 -64
|
@@ -26,23 +26,22 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
26
26
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
27
27
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
28
28
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
29
|
-
import {
|
|
29
|
+
import { BaseSalesImpl } from "../BaseSales";
|
|
30
30
|
import { ScanOrderHooks } from "./types";
|
|
31
31
|
import { OrderModule } from "../../modules/Order";
|
|
32
32
|
import { AccountHooks } from "../../modules/Account/types";
|
|
33
33
|
import { RegisterAndLoginHooks } from "../RegisterAndLogin/types";
|
|
34
34
|
import Decimal from 'decimal.js';
|
|
35
|
-
import { attachItemRuleLimitsToTopLevelProducts, buildProductKey, buildItemRuleBusinessData, collectLinkProductIdsFromReservationRules, computeResourceIsFull,
|
|
35
|
+
import { attachItemRuleLimitsToTopLevelProducts, buildProductKey, buildItemRuleBusinessData, collectLinkProductIdsFromReservationRules, computeResourceIsFull, filterProductsForScanOrderMore, findReservationRuleProductByResourceId, getProductIdentityIndex, getSafeProductNum, hasCustomCapacityProduct, pickFirstCustomCapacityDimensionId, pickFirstCustomCapacityPaxBounds, normalizeEnabledItemRuleIds, normalizeOrderProduct, normalizeItemRuleStrategies, pickFirstDurationMinutesFromProducts, toNonNegativeInt, toPriceString, toBoolean, toPositiveString } from "./utils";
|
|
36
36
|
import { createModule } from "../BookingByStep/types";
|
|
37
37
|
import { ProductList } from "../../modules/ProductList";
|
|
38
|
-
import { ScheduleModule } from "../../modules/Schedule";
|
|
39
38
|
import { getDateIsInSchedule } from "../../modules/Schedule/getDateIsInSchedule";
|
|
40
|
-
import { composeLinePrice, createUuidV4, getProductSkuOptions, normalizeSubmitCollectPaxValue, sumOptionUnitPrice } from "../../modules/Order/utils";
|
|
39
|
+
import { composeLinePrice, buildSubmitPayload, createUuidV4, getProductSkuOptions, normalizeSubmitCollectPaxValue, sumOptionUnitPrice } from "../../modules/Order/utils";
|
|
41
40
|
import dayjs from 'dayjs';
|
|
42
41
|
import { ItemRuleEvaluator } from "../../model/strategy/adapter/itemRule";
|
|
43
42
|
export * from "./types";
|
|
44
|
-
export var ScanOrderImpl = /*#__PURE__*/function (
|
|
45
|
-
_inherits(ScanOrderImpl,
|
|
43
|
+
export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
44
|
+
_inherits(ScanOrderImpl, _BaseSalesImpl);
|
|
46
45
|
var _super = _createSuper(ScanOrderImpl);
|
|
47
46
|
function ScanOrderImpl(name, version) {
|
|
48
47
|
var _this;
|
|
@@ -83,8 +82,6 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
83
82
|
_defineProperty(_assertThisInitialized(_this), "customerLoginRefreshIdInFlight", null);
|
|
84
83
|
return _this;
|
|
85
84
|
}
|
|
86
|
-
|
|
87
|
-
/** 与 `otherParams.cacheId` 一致,供宿主在 URL 变化时判断是否需要重新注册模块 */
|
|
88
85
|
_createClass(ScanOrderImpl, [{
|
|
89
86
|
key: "getScanOrderLoggerContext",
|
|
90
87
|
value: function getScanOrderLoggerContext() {
|
|
@@ -435,70 +432,42 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
435
432
|
}
|
|
436
433
|
return refreshOrderMarketingAfterLogin;
|
|
437
434
|
}()
|
|
435
|
+
}, {
|
|
436
|
+
key: "getRegisteredModuleNames",
|
|
437
|
+
value: function getRegisteredModuleNames() {
|
|
438
|
+
return ['scanOrderLogger', 'products', 'order', 'salesSummary', 'schedule'];
|
|
439
|
+
}
|
|
440
|
+
}, {
|
|
441
|
+
key: "createSubModule",
|
|
442
|
+
value: function createSubModule(moduleName) {
|
|
443
|
+
if (moduleName === 'scanOrderLogger') {
|
|
444
|
+
return createModule('scanOrderLogger', this.name);
|
|
445
|
+
}
|
|
446
|
+
return _get(_getPrototypeOf(ScanOrderImpl.prototype), "createSubModule", this).call(this, moduleName);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
/** 与 `otherParams.cacheId` 一致,供宿主在 URL 变化时判断是否需要重新注册模块 */
|
|
438
450
|
}, {
|
|
439
451
|
key: "getCacheId",
|
|
440
452
|
value: function getCacheId() {
|
|
441
453
|
return this.cacheId;
|
|
442
454
|
}
|
|
443
|
-
}, {
|
|
444
|
-
key: "destroyRegisteredChildModules",
|
|
445
|
-
value: function () {
|
|
446
|
-
var _destroyRegisteredChildModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
447
|
-
var modules, _i3, _modules, mod;
|
|
448
|
-
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
449
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
450
|
-
case 0:
|
|
451
|
-
modules = [this.store.schedule, this.store.salesSummary, this.store.order, this.store.products, this.store.scanOrderLogger];
|
|
452
|
-
_i3 = 0, _modules = modules;
|
|
453
|
-
case 2:
|
|
454
|
-
if (!(_i3 < _modules.length)) {
|
|
455
|
-
_context6.next = 10;
|
|
456
|
-
break;
|
|
457
|
-
}
|
|
458
|
-
mod = _modules[_i3];
|
|
459
|
-
if (!(mod && typeof mod.destroy === 'function')) {
|
|
460
|
-
_context6.next = 7;
|
|
461
|
-
break;
|
|
462
|
-
}
|
|
463
|
-
_context6.next = 7;
|
|
464
|
-
return Promise.resolve(mod.destroy());
|
|
465
|
-
case 7:
|
|
466
|
-
_i3++;
|
|
467
|
-
_context6.next = 2;
|
|
468
|
-
break;
|
|
469
|
-
case 10:
|
|
470
|
-
case "end":
|
|
471
|
-
return _context6.stop();
|
|
472
|
-
}
|
|
473
|
-
}, _callee6, this);
|
|
474
|
-
}));
|
|
475
|
-
function destroyRegisteredChildModules() {
|
|
476
|
-
return _destroyRegisteredChildModules.apply(this, arguments);
|
|
477
|
-
}
|
|
478
|
-
return destroyRegisteredChildModules;
|
|
479
|
-
}()
|
|
480
455
|
}, {
|
|
481
456
|
key: "initialize",
|
|
482
457
|
value: function () {
|
|
483
|
-
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
484
|
-
var _options$otherParams,
|
|
485
|
-
_this$otherParams,
|
|
486
|
-
_this$otherParams2,
|
|
487
|
-
_this$otherParams3,
|
|
488
|
-
_this4 = this;
|
|
458
|
+
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(core) {
|
|
459
|
+
var _options$otherParams, _this$otherParams, _this$otherParams2, _this$otherParams3;
|
|
489
460
|
var options,
|
|
490
|
-
|
|
491
|
-
|
|
461
|
+
_this$otherParams4,
|
|
462
|
+
_this$otherParams5,
|
|
492
463
|
_this$store$order,
|
|
493
464
|
_this$store$order2,
|
|
494
|
-
|
|
495
|
-
return _regeneratorRuntime().wrap(function
|
|
496
|
-
while (1) switch (
|
|
465
|
+
_args6 = arguments;
|
|
466
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
467
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
497
468
|
case 0:
|
|
498
|
-
options =
|
|
469
|
+
options = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : {};
|
|
499
470
|
this.logMethodStart('initialize');
|
|
500
|
-
this.core = core;
|
|
501
|
-
this.initializeOptions = options || {};
|
|
502
471
|
this.store = _objectSpread(_objectSpread({}, this.store), options.store);
|
|
503
472
|
this.store.entryContext = ((_options$otherParams = options.otherParams) === null || _options$otherParams === void 0 ? void 0 : _options$otherParams.entryContext) || this.store.entryContext;
|
|
504
473
|
this.store.status = 'initializing';
|
|
@@ -514,122 +483,76 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
514
483
|
passed: null,
|
|
515
484
|
failures: []
|
|
516
485
|
};
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
_context7.next = 21;
|
|
521
|
-
break;
|
|
522
|
-
}
|
|
523
|
-
this.logMethodError('initialize', 'window plugin missing');
|
|
524
|
-
throw new Error('scanOrder解决方案需要 window 插件支持');
|
|
525
|
-
case 21:
|
|
526
|
-
if (this.request) {
|
|
527
|
-
_context7.next = 24;
|
|
528
|
-
break;
|
|
529
|
-
}
|
|
530
|
-
this.logMethodError('initialize', 'request plugin missing');
|
|
531
|
-
throw new Error('scanOrder解决方案需要 request 插件支持');
|
|
532
|
-
case 24:
|
|
533
|
-
moduleArr = ['scanOrderLogger', 'products', 'order', 'salesSummary'];
|
|
534
|
-
moduleArr.forEach(function (step) {
|
|
535
|
-
var targetModule = createModule(step, _this4.name);
|
|
536
|
-
if (targetModule) {
|
|
537
|
-
var _this4$store$order, _this4$otherParams, _this4$otherParams2, _this4$otherParams3, _this4$otherParams4;
|
|
538
|
-
_this4.store[step] = targetModule;
|
|
539
|
-
var initialState = step === 'salesSummary' ? {
|
|
540
|
-
summary: ((_this4$store$order = _this4.store.order) === null || _this4$store$order === void 0 || (_this4$store$order = _this4$store$order.getTempOrder()) === null || _this4$store$order === void 0 ? void 0 : _this4$store$order.summary) || createEmptySummary()
|
|
541
|
-
} : {};
|
|
542
|
-
var loggerProvider = ((_this4$otherParams = _this4.otherParams) === null || _this4$otherParams === void 0 ? void 0 : _this4$otherParams.scanOrderLoggerProvider) || 'feishu';
|
|
543
|
-
var loggerConfig = ((_this4$otherParams2 = _this4.otherParams) === null || _this4$otherParams2 === void 0 ? void 0 : _this4$otherParams2.scanOrderLoggerConfig) || {
|
|
544
|
-
feishu: {
|
|
545
|
-
webhook: 'https://open.feishu.cn/open-apis/bot/v2/hook/216b3fe6-af98-424e-8706-f0471241a7ed',
|
|
546
|
-
errorHook: 'https://open.feishu.cn/open-apis/bot/v2/hook/015b7c2a-dd3c-4c30-9898-ef0f5253111f'
|
|
547
|
-
}
|
|
548
|
-
};
|
|
549
|
-
_this4.core.registerModule(targetModule, {
|
|
550
|
-
initialState: initialState,
|
|
551
|
-
otherParams: _objectSpread(_objectSpread({}, _this4.otherParams), {}, {
|
|
552
|
-
fatherModule: _this4.name,
|
|
553
|
-
openCache: (_this4$otherParams3 = _this4.otherParams) !== null && _this4$otherParams3 !== void 0 && _this4$otherParams3.cacheId ? true : false,
|
|
554
|
-
cacheId: (_this4$otherParams4 = _this4.otherParams) === null || _this4$otherParams4 === void 0 ? void 0 : _this4$otherParams4.cacheId,
|
|
555
|
-
salesSummaryModuleName: "".concat(_this4.name, "_salesSummary"),
|
|
556
|
-
provider: loggerProvider,
|
|
557
|
-
providerConfig: loggerConfig,
|
|
558
|
-
context: _this4.getScanOrderLoggerContext()
|
|
559
|
-
})
|
|
560
|
-
});
|
|
561
|
-
} else {
|
|
562
|
-
_this4.logMethodError('initialize', "module ".concat(step, " missing"));
|
|
563
|
-
throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
|
|
564
|
-
}
|
|
565
|
-
});
|
|
486
|
+
_context6.next = 16;
|
|
487
|
+
return _get(_getPrototypeOf(ScanOrderImpl.prototype), "initialize", this).call(this, core, options);
|
|
488
|
+
case 16:
|
|
566
489
|
if (this.store.scanOrderLogger) {
|
|
490
|
+
this.store.scanOrderLogger.setProvider(((_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.scanOrderLoggerProvider) || 'feishu');
|
|
491
|
+
this.store.scanOrderLogger.setProviderConfig(((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.scanOrderLoggerConfig) || {
|
|
492
|
+
feishu: {
|
|
493
|
+
webhook: 'https://open.feishu.cn/open-apis/bot/v2/hook/216b3fe6-af98-424e-8706-f0471241a7ed',
|
|
494
|
+
errorHook: 'https://open.feishu.cn/open-apis/bot/v2/hook/015b7c2a-dd3c-4c30-9898-ef0f5253111f'
|
|
495
|
+
}
|
|
496
|
+
});
|
|
567
497
|
this.store.scanOrderLogger.setContext(this.getScanOrderLoggerContext());
|
|
568
498
|
}
|
|
569
|
-
scheduleModule = new ScheduleModule("".concat(this.name, "_schedule"));
|
|
570
|
-
this.store.schedule = scheduleModule;
|
|
571
|
-
this.core.registerModule(scheduleModule, {
|
|
572
|
-
otherParams: _objectSpread(_objectSpread({}, this.otherParams), {}, {
|
|
573
|
-
fatherModule: this.name
|
|
574
|
-
})
|
|
575
|
-
});
|
|
576
499
|
this.registerCustomerLoginListeners();
|
|
577
500
|
console.log('[ScanOrder] 初始化开始');
|
|
578
|
-
|
|
579
|
-
|
|
501
|
+
_context6.prev = 19;
|
|
502
|
+
_context6.next = 22;
|
|
580
503
|
return (_this$store$order = this.store.order) === null || _this$store$order === void 0 ? void 0 : _this$store$order.recalculateSummary({
|
|
581
504
|
createIfMissing: false
|
|
582
505
|
});
|
|
583
|
-
case
|
|
506
|
+
case 22:
|
|
584
507
|
(_this$store$order2 = this.store.order) === null || _this$store$order2 === void 0 || _this$store$order2.persistTempOrder();
|
|
585
|
-
|
|
508
|
+
_context6.next = 25;
|
|
586
509
|
return this.loadRuntimeConfigs();
|
|
587
|
-
case
|
|
510
|
+
case 25:
|
|
588
511
|
if (!this.store.schedule) {
|
|
589
|
-
|
|
512
|
+
_context6.next = 34;
|
|
590
513
|
break;
|
|
591
514
|
}
|
|
592
|
-
|
|
593
|
-
|
|
515
|
+
_context6.prev = 26;
|
|
516
|
+
_context6.next = 29;
|
|
594
517
|
return this.store.schedule.loadAllSchedule();
|
|
595
|
-
case
|
|
596
|
-
|
|
518
|
+
case 29:
|
|
519
|
+
_context6.next = 34;
|
|
597
520
|
break;
|
|
598
|
-
case
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
console.warn('[ScanOrder] loadAllSchedule 失败,operating_hours 判定将跳过',
|
|
602
|
-
case
|
|
603
|
-
|
|
521
|
+
case 31:
|
|
522
|
+
_context6.prev = 31;
|
|
523
|
+
_context6.t0 = _context6["catch"](26);
|
|
524
|
+
console.warn('[ScanOrder] loadAllSchedule 失败,operating_hours 判定将跳过', _context6.t0);
|
|
525
|
+
case 34:
|
|
526
|
+
_context6.next = 36;
|
|
604
527
|
return this.refreshItemRuleQuantityLimits();
|
|
605
|
-
case
|
|
528
|
+
case 36:
|
|
606
529
|
this.store.status = 'ready';
|
|
607
530
|
console.log('[ScanOrder] 初始化完成');
|
|
608
|
-
|
|
531
|
+
_context6.next = 40;
|
|
609
532
|
return this.core.effects.emit(ScanOrderHooks.onInited, {
|
|
610
533
|
status: this.store.status
|
|
611
534
|
});
|
|
612
|
-
case
|
|
535
|
+
case 40:
|
|
613
536
|
this.logMethodSuccess('initialize', {
|
|
614
537
|
status: this.store.status
|
|
615
538
|
});
|
|
616
|
-
|
|
539
|
+
_context6.next = 50;
|
|
617
540
|
break;
|
|
618
|
-
case
|
|
619
|
-
|
|
620
|
-
|
|
541
|
+
case 43:
|
|
542
|
+
_context6.prev = 43;
|
|
543
|
+
_context6.t1 = _context6["catch"](19);
|
|
621
544
|
this.store.status = 'error';
|
|
622
|
-
this.store.error =
|
|
623
|
-
console.error('[ScanOrder] 初始化失败',
|
|
624
|
-
this.logMethodError('initialize',
|
|
545
|
+
this.store.error = _context6.t1 instanceof Error ? _context6.t1.message : '初始化失败';
|
|
546
|
+
console.error('[ScanOrder] 初始化失败', _context6.t1);
|
|
547
|
+
this.logMethodError('initialize', _context6.t1, {
|
|
625
548
|
status: this.store.status
|
|
626
549
|
});
|
|
627
|
-
throw
|
|
628
|
-
case
|
|
550
|
+
throw _context6.t1;
|
|
551
|
+
case 50:
|
|
629
552
|
case "end":
|
|
630
|
-
return
|
|
553
|
+
return _context6.stop();
|
|
631
554
|
}
|
|
632
|
-
},
|
|
555
|
+
}, _callee6, this, [[19, 43], [26, 31]]);
|
|
633
556
|
}));
|
|
634
557
|
function initialize(_x5) {
|
|
635
558
|
return _initialize.apply(this, arguments);
|
|
@@ -639,26 +562,23 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
639
562
|
}, {
|
|
640
563
|
key: "destroy",
|
|
641
564
|
value: function () {
|
|
642
|
-
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
643
|
-
return _regeneratorRuntime().wrap(function
|
|
644
|
-
while (1) switch (
|
|
565
|
+
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
566
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
567
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
645
568
|
case 0:
|
|
646
569
|
this.logMethodStart('destroy');
|
|
647
570
|
this.clearLoginEffectListeners();
|
|
648
|
-
|
|
571
|
+
_context7.next = 4;
|
|
649
572
|
return this.core.effects.emit(ScanOrderHooks.onDestroy, {});
|
|
650
573
|
case 4:
|
|
651
|
-
_context8.next = 6;
|
|
652
|
-
return this.destroyRegisteredChildModules();
|
|
653
|
-
case 6:
|
|
654
574
|
_get(_getPrototypeOf(ScanOrderImpl.prototype), "destroy", this).call(this);
|
|
655
575
|
console.log('[ScanOrder] 已销毁');
|
|
656
576
|
this.logMethodSuccess('destroy');
|
|
657
|
-
case
|
|
577
|
+
case 7:
|
|
658
578
|
case "end":
|
|
659
|
-
return
|
|
579
|
+
return _context7.stop();
|
|
660
580
|
}
|
|
661
|
-
},
|
|
581
|
+
}, _callee7, this);
|
|
662
582
|
}));
|
|
663
583
|
function destroy() {
|
|
664
584
|
return _destroy.apply(this, arguments);
|
|
@@ -668,33 +588,33 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
668
588
|
}, {
|
|
669
589
|
key: "retryInit",
|
|
670
590
|
value: function () {
|
|
671
|
-
var _retryInit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
672
|
-
return _regeneratorRuntime().wrap(function
|
|
673
|
-
while (1) switch (
|
|
591
|
+
var _retryInit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
592
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
593
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
674
594
|
case 0:
|
|
675
595
|
this.logMethodStart('retryInit');
|
|
676
596
|
// TODO: 细化重试策略(指数退避、最大重试次数)后替换当前实现
|
|
677
597
|
console.log('[ScanOrder] retryInit 调用');
|
|
678
|
-
|
|
598
|
+
_context8.next = 4;
|
|
679
599
|
return this.core.effects.emit(ScanOrderHooks.onRetryInit, {});
|
|
680
600
|
case 4:
|
|
681
|
-
|
|
682
|
-
|
|
601
|
+
_context8.prev = 4;
|
|
602
|
+
_context8.next = 7;
|
|
683
603
|
return this.initialize(this.core, this.initializeOptions);
|
|
684
604
|
case 7:
|
|
685
605
|
this.logMethodSuccess('retryInit');
|
|
686
|
-
|
|
606
|
+
_context8.next = 14;
|
|
687
607
|
break;
|
|
688
608
|
case 10:
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
this.logMethodError('retryInit',
|
|
692
|
-
throw
|
|
609
|
+
_context8.prev = 10;
|
|
610
|
+
_context8.t0 = _context8["catch"](4);
|
|
611
|
+
this.logMethodError('retryInit', _context8.t0);
|
|
612
|
+
throw _context8.t0;
|
|
693
613
|
case 14:
|
|
694
614
|
case "end":
|
|
695
|
-
return
|
|
615
|
+
return _context8.stop();
|
|
696
616
|
}
|
|
697
|
-
},
|
|
617
|
+
}, _callee8, this, [[4, 10]]);
|
|
698
618
|
}));
|
|
699
619
|
function retryInit() {
|
|
700
620
|
return _retryInit.apply(this, arguments);
|
|
@@ -704,23 +624,23 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
704
624
|
}, {
|
|
705
625
|
key: "refresh",
|
|
706
626
|
value: function () {
|
|
707
|
-
var _refresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
708
|
-
return _regeneratorRuntime().wrap(function
|
|
709
|
-
while (1) switch (
|
|
627
|
+
var _refresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
628
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
629
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
710
630
|
case 0:
|
|
711
631
|
this.logMethodStart('refresh');
|
|
712
632
|
// TODO: 接入真实刷新逻辑(资源重拉取、流程重建)后替换当前实现
|
|
713
633
|
console.log('[ScanOrder] refresh 调用');
|
|
714
|
-
|
|
634
|
+
_context9.prev = 2;
|
|
715
635
|
this.store.status = 'initializing';
|
|
716
|
-
|
|
636
|
+
_context9.next = 6;
|
|
717
637
|
return this.loadRuntimeConfigs();
|
|
718
638
|
case 6:
|
|
719
|
-
|
|
639
|
+
_context9.next = 8;
|
|
720
640
|
return this.refreshItemRuleQuantityLimits();
|
|
721
641
|
case 8:
|
|
722
642
|
this.store.status = 'ready';
|
|
723
|
-
|
|
643
|
+
_context9.next = 11;
|
|
724
644
|
return this.core.effects.emit(ScanOrderHooks.onRefresh, {
|
|
725
645
|
status: this.store.status
|
|
726
646
|
});
|
|
@@ -728,18 +648,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
728
648
|
this.logMethodSuccess('refresh', {
|
|
729
649
|
status: this.store.status
|
|
730
650
|
});
|
|
731
|
-
|
|
651
|
+
_context9.next = 18;
|
|
732
652
|
break;
|
|
733
653
|
case 14:
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
this.logMethodError('refresh',
|
|
737
|
-
throw
|
|
654
|
+
_context9.prev = 14;
|
|
655
|
+
_context9.t0 = _context9["catch"](2);
|
|
656
|
+
this.logMethodError('refresh', _context9.t0);
|
|
657
|
+
throw _context9.t0;
|
|
738
658
|
case 18:
|
|
739
659
|
case "end":
|
|
740
|
-
return
|
|
660
|
+
return _context9.stop();
|
|
741
661
|
}
|
|
742
|
-
},
|
|
662
|
+
}, _callee9, this, [[2, 14]]);
|
|
743
663
|
}));
|
|
744
664
|
function refresh() {
|
|
745
665
|
return _refresh.apply(this, arguments);
|
|
@@ -827,16 +747,27 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
827
747
|
}, {
|
|
828
748
|
key: "updateTempOrderNote",
|
|
829
749
|
value: function updateTempOrderNote(note) {
|
|
750
|
+
var _this4 = this;
|
|
751
|
+
var sync = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
830
752
|
this.logMethodStart('updateTempOrderNote', {
|
|
831
753
|
noteLength: String(note || '').length
|
|
832
754
|
});
|
|
833
755
|
try {
|
|
834
756
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
835
|
-
var result = this.store.order.updateTempOrderNote(note);
|
|
757
|
+
var result = this.store.order.updateTempOrderNote(note, sync);
|
|
758
|
+
if (result && typeof result.then === 'function') {
|
|
759
|
+
return result.then(function (nextNote) {
|
|
760
|
+
_this4.logMethodSuccess('updateTempOrderNote', {
|
|
761
|
+
noteLength: nextNote.length
|
|
762
|
+
});
|
|
763
|
+
return nextNote;
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
var nextNote = result;
|
|
836
767
|
this.logMethodSuccess('updateTempOrderNote', {
|
|
837
|
-
noteLength:
|
|
768
|
+
noteLength: nextNote.length
|
|
838
769
|
});
|
|
839
|
-
return
|
|
770
|
+
return nextNote;
|
|
840
771
|
} catch (error) {
|
|
841
772
|
this.logMethodError('updateTempOrderNote', error);
|
|
842
773
|
throw error;
|
|
@@ -852,11 +783,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
852
783
|
mode: mode
|
|
853
784
|
});
|
|
854
785
|
try {
|
|
786
|
+
var _this$otherParams6;
|
|
855
787
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
856
788
|
var tempOrder = this.store.order.ensureTempOrder();
|
|
857
789
|
tempOrder.metadata = _objectSpread(_objectSpread({}, tempOrder.metadata || {}), {}, {
|
|
858
790
|
shop_service_data: _objectSpread(_objectSpread({}, (tempOrder.metadata || {}).shop_service_data || {}), {}, {
|
|
859
|
-
service_type: 'dine_in',
|
|
791
|
+
service_type: ((_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.businessCode) === 'dine_in' ? 'dine_in' : '',
|
|
860
792
|
pickup_reference_mode: mode
|
|
861
793
|
})
|
|
862
794
|
});
|
|
@@ -893,8 +825,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
893
825
|
}
|
|
894
826
|
}
|
|
895
827
|
}, {
|
|
896
|
-
key: "
|
|
897
|
-
value: function
|
|
828
|
+
key: "ensureScanOrderTempOrder",
|
|
829
|
+
value: function ensureScanOrderTempOrder() {
|
|
898
830
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
899
831
|
return this.store.order.ensureTempOrder();
|
|
900
832
|
}
|
|
@@ -903,37 +835,37 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
903
835
|
}, {
|
|
904
836
|
key: "addNewOrder",
|
|
905
837
|
value: function () {
|
|
906
|
-
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
838
|
+
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
907
839
|
var tempOrder;
|
|
908
|
-
return _regeneratorRuntime().wrap(function
|
|
909
|
-
while (1) switch (
|
|
840
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
841
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
910
842
|
case 0:
|
|
911
843
|
this.logMethodStart('addNewOrder');
|
|
912
|
-
|
|
844
|
+
_context10.prev = 1;
|
|
913
845
|
if (this.store.order) {
|
|
914
|
-
|
|
846
|
+
_context10.next = 4;
|
|
915
847
|
break;
|
|
916
848
|
}
|
|
917
849
|
throw new Error('order 模块未初始化');
|
|
918
850
|
case 4:
|
|
919
|
-
|
|
851
|
+
_context10.next = 6;
|
|
920
852
|
return this.store.order.addNewOrder();
|
|
921
853
|
case 6:
|
|
922
|
-
tempOrder =
|
|
854
|
+
tempOrder = _context10.sent;
|
|
923
855
|
this.logMethodSuccess('addNewOrder', {
|
|
924
856
|
productCount: tempOrder.products.length
|
|
925
857
|
});
|
|
926
|
-
return
|
|
858
|
+
return _context10.abrupt("return", tempOrder);
|
|
927
859
|
case 11:
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
this.logMethodError('addNewOrder',
|
|
931
|
-
throw
|
|
860
|
+
_context10.prev = 11;
|
|
861
|
+
_context10.t0 = _context10["catch"](1);
|
|
862
|
+
this.logMethodError('addNewOrder', _context10.t0);
|
|
863
|
+
throw _context10.t0;
|
|
932
864
|
case 15:
|
|
933
865
|
case "end":
|
|
934
|
-
return
|
|
866
|
+
return _context10.stop();
|
|
935
867
|
}
|
|
936
|
-
},
|
|
868
|
+
}, _callee10, this, [[1, 11]]);
|
|
937
869
|
}));
|
|
938
870
|
function addNewOrder() {
|
|
939
871
|
return _addNewOrder.apply(this, arguments);
|
|
@@ -944,15 +876,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
944
876
|
}, {
|
|
945
877
|
key: "restoreOrder",
|
|
946
878
|
value: function () {
|
|
947
|
-
var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
879
|
+
var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
948
880
|
var tempOrder;
|
|
949
|
-
return _regeneratorRuntime().wrap(function
|
|
950
|
-
while (1) switch (
|
|
881
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
882
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
951
883
|
case 0:
|
|
952
884
|
this.logMethodStart('restoreOrder');
|
|
953
|
-
|
|
885
|
+
_context11.prev = 1;
|
|
954
886
|
if (this.store.order) {
|
|
955
|
-
|
|
887
|
+
_context11.next = 4;
|
|
956
888
|
break;
|
|
957
889
|
}
|
|
958
890
|
throw new Error('scanOrder 解决方案需要 order 模块支持');
|
|
@@ -962,17 +894,17 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
962
894
|
this.enabledReservationRuleProducts = [];
|
|
963
895
|
tempOrder = this.store.order.restoreOrder();
|
|
964
896
|
this.logMethodSuccess('restoreOrder');
|
|
965
|
-
return
|
|
897
|
+
return _context11.abrupt("return", tempOrder);
|
|
966
898
|
case 12:
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
this.logMethodError('restoreOrder',
|
|
970
|
-
throw
|
|
899
|
+
_context11.prev = 12;
|
|
900
|
+
_context11.t0 = _context11["catch"](1);
|
|
901
|
+
this.logMethodError('restoreOrder', _context11.t0);
|
|
902
|
+
throw _context11.t0;
|
|
971
903
|
case 16:
|
|
972
904
|
case "end":
|
|
973
|
-
return
|
|
905
|
+
return _context11.stop();
|
|
974
906
|
}
|
|
975
|
-
},
|
|
907
|
+
}, _callee11, this, [[1, 12]]);
|
|
976
908
|
}));
|
|
977
909
|
function restoreOrder() {
|
|
978
910
|
return _restoreOrder.apply(this, arguments);
|
|
@@ -993,37 +925,37 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
993
925
|
}, {
|
|
994
926
|
key: "getSummary",
|
|
995
927
|
value: function () {
|
|
996
|
-
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
928
|
+
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
997
929
|
var summary;
|
|
998
|
-
return _regeneratorRuntime().wrap(function
|
|
999
|
-
while (1) switch (
|
|
930
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
931
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1000
932
|
case 0:
|
|
1001
933
|
this.logMethodStart('getSummary');
|
|
1002
|
-
|
|
934
|
+
_context12.prev = 1;
|
|
1003
935
|
if (this.store.order) {
|
|
1004
|
-
|
|
936
|
+
_context12.next = 4;
|
|
1005
937
|
break;
|
|
1006
938
|
}
|
|
1007
939
|
throw new Error('order 模块未初始化');
|
|
1008
940
|
case 4:
|
|
1009
|
-
|
|
941
|
+
_context12.next = 6;
|
|
1010
942
|
return this.store.order.getOrderSummary();
|
|
1011
943
|
case 6:
|
|
1012
|
-
summary =
|
|
944
|
+
summary = _context12.sent;
|
|
1013
945
|
this.logMethodSuccess('getSummary', {
|
|
1014
946
|
totalAmount: summary.total_amount
|
|
1015
947
|
});
|
|
1016
|
-
return
|
|
948
|
+
return _context12.abrupt("return", summary);
|
|
1017
949
|
case 11:
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
this.logMethodError('getSummary',
|
|
1021
|
-
throw
|
|
950
|
+
_context12.prev = 11;
|
|
951
|
+
_context12.t0 = _context12["catch"](1);
|
|
952
|
+
this.logMethodError('getSummary', _context12.t0);
|
|
953
|
+
throw _context12.t0;
|
|
1022
954
|
case 15:
|
|
1023
955
|
case "end":
|
|
1024
|
-
return
|
|
956
|
+
return _context12.stop();
|
|
1025
957
|
}
|
|
1026
|
-
},
|
|
958
|
+
}, _callee12, this, [[1, 11]]);
|
|
1027
959
|
}));
|
|
1028
960
|
function getSummary() {
|
|
1029
961
|
return _getSummary.apply(this, arguments);
|
|
@@ -1039,30 +971,30 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1039
971
|
}, {
|
|
1040
972
|
key: "scanCode",
|
|
1041
973
|
value: function () {
|
|
1042
|
-
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
974
|
+
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(code, customerId) {
|
|
1043
975
|
var raw;
|
|
1044
|
-
return _regeneratorRuntime().wrap(function
|
|
1045
|
-
while (1) switch (
|
|
976
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
977
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1046
978
|
case 0:
|
|
1047
979
|
this.logMethodStart('scanCode', {
|
|
1048
980
|
code: code
|
|
1049
981
|
});
|
|
1050
|
-
|
|
982
|
+
_context13.prev = 1;
|
|
1051
983
|
if (this.store.order) {
|
|
1052
|
-
|
|
984
|
+
_context13.next = 4;
|
|
1053
985
|
break;
|
|
1054
986
|
}
|
|
1055
987
|
throw new Error('order 模块未初始化');
|
|
1056
988
|
case 4:
|
|
1057
|
-
|
|
989
|
+
_context13.next = 6;
|
|
1058
990
|
return this.store.order.scanCode(code, customerId);
|
|
1059
991
|
case 6:
|
|
1060
|
-
raw =
|
|
992
|
+
raw = _context13.sent;
|
|
1061
993
|
if (!raw.isAvailable) {
|
|
1062
|
-
|
|
994
|
+
_context13.next = 11;
|
|
1063
995
|
break;
|
|
1064
996
|
}
|
|
1065
|
-
|
|
997
|
+
_context13.next = 10;
|
|
1066
998
|
return this.store.order.recalculateSummary({
|
|
1067
999
|
createIfMissing: true
|
|
1068
1000
|
});
|
|
@@ -1072,21 +1004,21 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1072
1004
|
this.logMethodSuccess('scanCode', {
|
|
1073
1005
|
isAvailable: raw.isAvailable
|
|
1074
1006
|
});
|
|
1075
|
-
return
|
|
1007
|
+
return _context13.abrupt("return", {
|
|
1076
1008
|
isAvailable: raw.isAvailable,
|
|
1077
1009
|
type: raw.type,
|
|
1078
1010
|
unavailableReason: raw.unavailableReason
|
|
1079
1011
|
});
|
|
1080
1012
|
case 15:
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
this.logMethodError('scanCode',
|
|
1084
|
-
throw
|
|
1013
|
+
_context13.prev = 15;
|
|
1014
|
+
_context13.t0 = _context13["catch"](1);
|
|
1015
|
+
this.logMethodError('scanCode', _context13.t0);
|
|
1016
|
+
throw _context13.t0;
|
|
1085
1017
|
case 19:
|
|
1086
1018
|
case "end":
|
|
1087
|
-
return
|
|
1019
|
+
return _context13.stop();
|
|
1088
1020
|
}
|
|
1089
|
-
},
|
|
1021
|
+
}, _callee13, this, [[1, 15]]);
|
|
1090
1022
|
}));
|
|
1091
1023
|
function scanCode(_x6, _x7) {
|
|
1092
1024
|
return _scanCode.apply(this, arguments);
|
|
@@ -1096,15 +1028,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1096
1028
|
}, {
|
|
1097
1029
|
key: "setDiscountSelected",
|
|
1098
1030
|
value: function () {
|
|
1099
|
-
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1031
|
+
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(params) {
|
|
1100
1032
|
var _tempOrder$holder, list, updated, tempOrder, orderStore, discountModule, rulesModule, holders, nextDiscountList, _tempOrder$holder2, result, beforeSelectedIds, _iterator2, _step2, d, selectedResourceIds, _iterator3, _step3, _origin, _product$metadata$sou, _product$metadata, _product$metadata2, _product$original_pri, product, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
|
|
1101
|
-
return _regeneratorRuntime().wrap(function
|
|
1102
|
-
while (1) switch (
|
|
1033
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1034
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1103
1035
|
case 0:
|
|
1104
1036
|
this.logMethodStart('setDiscountSelected', params);
|
|
1105
|
-
|
|
1037
|
+
_context14.prev = 1;
|
|
1106
1038
|
if (this.store.order) {
|
|
1107
|
-
|
|
1039
|
+
_context14.next = 4;
|
|
1108
1040
|
break;
|
|
1109
1041
|
}
|
|
1110
1042
|
throw new Error('order 模块未初始化');
|
|
@@ -1124,7 +1056,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1124
1056
|
form_record_id: tempOrder.holder.form_record_id
|
|
1125
1057
|
}] : [];
|
|
1126
1058
|
nextDiscountList = updated;
|
|
1127
|
-
|
|
1059
|
+
_context14.next = 14;
|
|
1128
1060
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(updated);
|
|
1129
1061
|
case 14:
|
|
1130
1062
|
if (rulesModule) {
|
|
@@ -1173,19 +1105,19 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1173
1105
|
return d.id;
|
|
1174
1106
|
}));
|
|
1175
1107
|
_iterator3 = _createForOfIteratorHelper(tempOrder.products);
|
|
1176
|
-
|
|
1108
|
+
_context14.prev = 17;
|
|
1177
1109
|
_iterator3.s();
|
|
1178
1110
|
case 19:
|
|
1179
1111
|
if ((_step3 = _iterator3.n()).done) {
|
|
1180
|
-
|
|
1112
|
+
_context14.next = 33;
|
|
1181
1113
|
break;
|
|
1182
1114
|
}
|
|
1183
1115
|
product = _step3.value;
|
|
1184
1116
|
if (!((_origin = product._origin) !== null && _origin !== void 0 && _origin.isManualDiscount)) {
|
|
1185
|
-
|
|
1117
|
+
_context14.next = 23;
|
|
1186
1118
|
break;
|
|
1187
1119
|
}
|
|
1188
|
-
return
|
|
1120
|
+
return _context14.abrupt("continue", 31);
|
|
1189
1121
|
case 23:
|
|
1190
1122
|
product.discount_list = (product.discount_list || []).filter(function (pd) {
|
|
1191
1123
|
var _pd$discount$resource, _pd$discount;
|
|
@@ -1211,46 +1143,46 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1211
1143
|
bundle: product.product_bundle
|
|
1212
1144
|
});
|
|
1213
1145
|
case 31:
|
|
1214
|
-
|
|
1146
|
+
_context14.next = 19;
|
|
1215
1147
|
break;
|
|
1216
1148
|
case 33:
|
|
1217
|
-
|
|
1149
|
+
_context14.next = 38;
|
|
1218
1150
|
break;
|
|
1219
1151
|
case 35:
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
_iterator3.e(
|
|
1152
|
+
_context14.prev = 35;
|
|
1153
|
+
_context14.t0 = _context14["catch"](17);
|
|
1154
|
+
_iterator3.e(_context14.t0);
|
|
1223
1155
|
case 38:
|
|
1224
|
-
|
|
1156
|
+
_context14.prev = 38;
|
|
1225
1157
|
_iterator3.f();
|
|
1226
|
-
return
|
|
1158
|
+
return _context14.finish(38);
|
|
1227
1159
|
case 41:
|
|
1228
1160
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
1229
|
-
|
|
1161
|
+
_context14.next = 44;
|
|
1230
1162
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
1231
1163
|
case 44:
|
|
1232
1164
|
tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
|
|
1233
1165
|
return d.isSelected;
|
|
1234
1166
|
});
|
|
1235
|
-
|
|
1167
|
+
_context14.next = 47;
|
|
1236
1168
|
return this.store.order.recalculateSummary({
|
|
1237
1169
|
createIfMissing: true
|
|
1238
1170
|
});
|
|
1239
1171
|
case 47:
|
|
1240
1172
|
this.store.order.persistTempOrder();
|
|
1241
1173
|
this.logMethodSuccess('setDiscountSelected', params);
|
|
1242
|
-
|
|
1174
|
+
_context14.next = 55;
|
|
1243
1175
|
break;
|
|
1244
1176
|
case 51:
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
this.logMethodError('setDiscountSelected',
|
|
1248
|
-
throw
|
|
1177
|
+
_context14.prev = 51;
|
|
1178
|
+
_context14.t1 = _context14["catch"](1);
|
|
1179
|
+
this.logMethodError('setDiscountSelected', _context14.t1);
|
|
1180
|
+
throw _context14.t1;
|
|
1249
1181
|
case 55:
|
|
1250
1182
|
case "end":
|
|
1251
|
-
return
|
|
1183
|
+
return _context14.stop();
|
|
1252
1184
|
}
|
|
1253
|
-
},
|
|
1185
|
+
}, _callee14, this, [[1, 51], [17, 35, 38, 41]]);
|
|
1254
1186
|
}));
|
|
1255
1187
|
function setDiscountSelected(_x8) {
|
|
1256
1188
|
return _setDiscountSelected.apply(this, arguments);
|
|
@@ -1260,15 +1192,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1260
1192
|
}, {
|
|
1261
1193
|
key: "onCustomerLogin",
|
|
1262
1194
|
value: function () {
|
|
1263
|
-
var _onCustomerLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1264
|
-
return _regeneratorRuntime().wrap(function
|
|
1265
|
-
while (1) switch (
|
|
1195
|
+
var _onCustomerLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
|
|
1196
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1197
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1266
1198
|
case 0:
|
|
1267
1199
|
this.logMethodStart('onCustomerLogin', {
|
|
1268
1200
|
customerId: params.customerId
|
|
1269
1201
|
});
|
|
1270
|
-
|
|
1271
|
-
|
|
1202
|
+
_context15.prev = 1;
|
|
1203
|
+
_context15.next = 4;
|
|
1272
1204
|
return this.refreshOrderMarketingAfterLogin({
|
|
1273
1205
|
customerId: params.customerId
|
|
1274
1206
|
});
|
|
@@ -1276,18 +1208,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1276
1208
|
this.logMethodSuccess('onCustomerLogin', {
|
|
1277
1209
|
customerId: params.customerId
|
|
1278
1210
|
});
|
|
1279
|
-
|
|
1211
|
+
_context15.next = 11;
|
|
1280
1212
|
break;
|
|
1281
1213
|
case 7:
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
this.logMethodError('onCustomerLogin',
|
|
1285
|
-
throw
|
|
1214
|
+
_context15.prev = 7;
|
|
1215
|
+
_context15.t0 = _context15["catch"](1);
|
|
1216
|
+
this.logMethodError('onCustomerLogin', _context15.t0);
|
|
1217
|
+
throw _context15.t0;
|
|
1286
1218
|
case 11:
|
|
1287
1219
|
case "end":
|
|
1288
|
-
return
|
|
1220
|
+
return _context15.stop();
|
|
1289
1221
|
}
|
|
1290
|
-
},
|
|
1222
|
+
}, _callee15, this, [[1, 7]]);
|
|
1291
1223
|
}));
|
|
1292
1224
|
function onCustomerLogin(_x9) {
|
|
1293
1225
|
return _onCustomerLogin.apply(this, arguments);
|
|
@@ -1335,8 +1267,70 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1335
1267
|
combined_resource: isCombined ? combined : null
|
|
1336
1268
|
};
|
|
1337
1269
|
}
|
|
1338
|
-
|
|
1339
|
-
|
|
1270
|
+
}, {
|
|
1271
|
+
key: "prepareRetailAvailability",
|
|
1272
|
+
value: function () {
|
|
1273
|
+
var _prepareRetailAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(params) {
|
|
1274
|
+
var _this$store$order4, _this$otherParams7;
|
|
1275
|
+
var tempOrder, hasOrderId, resourceId, reason, resourceState, availabilityInfo;
|
|
1276
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1277
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1278
|
+
case 0:
|
|
1279
|
+
tempOrder = params.tempOrder, hasOrderId = params.hasOrderId, resourceId = params.resourceId, reason = params.reason;
|
|
1280
|
+
this.enabledReservationRuleProducts = [];
|
|
1281
|
+
tempOrder.bookings = [];
|
|
1282
|
+
tempOrder.order_id = null;
|
|
1283
|
+
delete tempOrder.relation_id;
|
|
1284
|
+
delete tempOrder.table_form_id;
|
|
1285
|
+
delete tempOrder.resource_id;
|
|
1286
|
+
delete tempOrder.table_number;
|
|
1287
|
+
tempOrder.metadata = _objectSpread({}, tempOrder.metadata || {});
|
|
1288
|
+
delete tempOrder.metadata.table_occupancy_duration;
|
|
1289
|
+
resourceState = {
|
|
1290
|
+
mode: 'idle',
|
|
1291
|
+
deskmate_valid: false,
|
|
1292
|
+
allowSnack: false,
|
|
1293
|
+
deskmateValid: false,
|
|
1294
|
+
isExclusive: false,
|
|
1295
|
+
isFull: false,
|
|
1296
|
+
raw: null
|
|
1297
|
+
};
|
|
1298
|
+
this.store.resource = resourceState;
|
|
1299
|
+
(_this$store$order4 = this.store.order) === null || _this$store$order4 === void 0 || _this$store$order4.persistTempOrder();
|
|
1300
|
+
_context16.next = 15;
|
|
1301
|
+
return this.addNewOrder();
|
|
1302
|
+
case 15:
|
|
1303
|
+
_context16.next = 17;
|
|
1304
|
+
return this.setItemRuleRuntimeConfig({
|
|
1305
|
+
serviceType: (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.businessCode,
|
|
1306
|
+
submissionIndex: hasOrderId ? 1 : 0,
|
|
1307
|
+
historicalItems: []
|
|
1308
|
+
});
|
|
1309
|
+
case 17:
|
|
1310
|
+
availabilityInfo = {
|
|
1311
|
+
mode: 'idle',
|
|
1312
|
+
deskmate_valid: false
|
|
1313
|
+
};
|
|
1314
|
+
this.logMethodSuccess('checkResourceAvailable', {
|
|
1315
|
+
resourceId: resourceId,
|
|
1316
|
+
mode: availabilityInfo.mode,
|
|
1317
|
+
retailMode: true,
|
|
1318
|
+
retailReason: reason,
|
|
1319
|
+
relationId: resourceState.relationId,
|
|
1320
|
+
persistedResourceId: resourceState.relationId
|
|
1321
|
+
});
|
|
1322
|
+
return _context16.abrupt("return", availabilityInfo);
|
|
1323
|
+
case 20:
|
|
1324
|
+
case "end":
|
|
1325
|
+
return _context16.stop();
|
|
1326
|
+
}
|
|
1327
|
+
}, _callee16, this);
|
|
1328
|
+
}));
|
|
1329
|
+
function prepareRetailAvailability(_x10) {
|
|
1330
|
+
return _prepareRetailAvailability.apply(this, arguments);
|
|
1331
|
+
}
|
|
1332
|
+
return prepareRetailAvailability;
|
|
1333
|
+
}() // ScanOrder 提交 payload enhancer:
|
|
1340
1334
|
// - 给所有 booking 注入 appointment_status: 'started'(扫码点餐语义)
|
|
1341
1335
|
// - 给所有 booking 的 metadata 注入 resource_select_type(来自预约规则商品的 resource.type)
|
|
1342
1336
|
// - 给第一条 booking 补 resources 与 product_uid(仅当存在 resource / rule product)
|
|
@@ -1349,25 +1343,32 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1349
1343
|
var resourceState = this.store.resource;
|
|
1350
1344
|
var resourceSelectType = resourceState === null || resourceState === void 0 ? void 0 : resourceState.resourceSelectType;
|
|
1351
1345
|
|
|
1352
|
-
//
|
|
1353
|
-
var
|
|
1346
|
+
// ScanOrder 的 booking 容量只由预约规则决定:single 占用整张桌台,multiple 占用 1 个容量位。
|
|
1347
|
+
var resolveBookingCapacityValue = function resolveBookingCapacityValue() {
|
|
1354
1348
|
if (resourceSelectType === 'single') {
|
|
1355
1349
|
var _resourceState$table_;
|
|
1356
1350
|
var raw = resourceState === null || resourceState === void 0 || (_resourceState$table_ = resourceState.table_form_record) === null || _resourceState$table_ === void 0 ? void 0 : _resourceState$table_.capacity;
|
|
1357
1351
|
var num = Number(raw);
|
|
1358
|
-
if (Number.isFinite(num) && num > 0) return num;
|
|
1352
|
+
if (Number.isFinite(num) && num > 0) return Math.max(1, Math.floor(num));
|
|
1359
1353
|
return 1;
|
|
1360
1354
|
}
|
|
1361
1355
|
return 1;
|
|
1362
1356
|
};
|
|
1363
1357
|
return function (payload, _ref3) {
|
|
1364
|
-
var
|
|
1358
|
+
var _resourceState$relati, _tempOrder$metadata, _ref4, _pickOriginal, _resourceState$table_2, _resourceState$relati2, _pickFirstCustomCapac;
|
|
1365
1359
|
var bookingUuid = _ref3.bookingUuid,
|
|
1366
1360
|
tempOrder = _ref3.tempOrder;
|
|
1367
|
-
var resourceId = (
|
|
1361
|
+
var resourceId = String((_resourceState$relati = resourceState === null || resourceState === void 0 ? void 0 : resourceState.relationId) !== null && _resourceState$relati !== void 0 ? _resourceState$relati : '').trim();
|
|
1362
|
+
var hasReservationBookingContext = Boolean(ruleProduct && resourceState && resourceId && resourceState.relationId && resourceState.tableFormId);
|
|
1363
|
+
if (!hasReservationBookingContext) {
|
|
1364
|
+
return _objectSpread(_objectSpread({}, payload), {}, {
|
|
1365
|
+
bookings: [],
|
|
1366
|
+
products: _toConsumableArray(payload.products || [])
|
|
1367
|
+
});
|
|
1368
|
+
}
|
|
1368
1369
|
var rawCollectPax = (_tempOrder$metadata = tempOrder.metadata) === null || _tempOrder$metadata === void 0 ? void 0 : _tempOrder$metadata.collect_pax;
|
|
1369
|
-
var
|
|
1370
|
-
var
|
|
1370
|
+
var hasExplicitCollectPax = rawCollectPax !== null && rawCollectPax !== undefined && rawCollectPax !== '';
|
|
1371
|
+
var bookingCapacityValue = resolveBookingCapacityValue();
|
|
1371
1372
|
var pickOriginal = function pickOriginal(value) {
|
|
1372
1373
|
if (value && _typeof(value) === 'object' && !Array.isArray(value)) {
|
|
1373
1374
|
var original = value.original;
|
|
@@ -1382,22 +1383,26 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1382
1383
|
id: Number(resourceId),
|
|
1383
1384
|
main_field: mainField,
|
|
1384
1385
|
form_id: resourceState.tableFormId,
|
|
1385
|
-
relation_id: (_resourceState$
|
|
1386
|
-
capacity:
|
|
1386
|
+
relation_id: (_resourceState$relati2 = resourceState.relationId) !== null && _resourceState$relati2 !== void 0 ? _resourceState$relati2 : resourceId,
|
|
1387
|
+
capacity: bookingCapacityValue,
|
|
1387
1388
|
metadata: _this5.buildScanOrderResourceMetadata({
|
|
1388
1389
|
resourceState: resourceState,
|
|
1389
1390
|
resourceName: mainField
|
|
1390
1391
|
})
|
|
1391
1392
|
} : undefined;
|
|
1392
1393
|
var ruleProductUid = ruleProduct ? createUuidV4() : undefined;
|
|
1393
|
-
// 有 collect_pax 时 booking/resource capacity 与 number 都代表本次 pax;否则使用资源占用兜底值。
|
|
1394
|
-
var bookingCapacityValue = resourceCapacityValue;
|
|
1395
1394
|
var bookingCapacityDimensionId = (_pickFirstCustomCapac = pickFirstCustomCapacityDimensionId(_this5.enabledReservationRuleProducts)) !== null && _pickFirstCustomCapac !== void 0 ? _pickFirstCustomCapac : 0;
|
|
1396
1395
|
var nextBookings = (payload.bookings || []).map(function (booking, idx) {
|
|
1396
|
+
var metadata = _objectSpread({}, booking.metadata || {});
|
|
1397
|
+
if (hasExplicitCollectPax) {
|
|
1398
|
+
metadata.collect_pax = normalizeSubmitCollectPaxValue(rawCollectPax);
|
|
1399
|
+
} else {
|
|
1400
|
+
delete metadata.collect_pax;
|
|
1401
|
+
}
|
|
1397
1402
|
return _objectSpread(_objectSpread(_objectSpread({}, booking), {}, {
|
|
1398
1403
|
number: bookingCapacityValue,
|
|
1399
1404
|
appointment_status: 'started',
|
|
1400
|
-
metadata: _objectSpread(_objectSpread(_objectSpread({},
|
|
1405
|
+
metadata: _objectSpread(_objectSpread(_objectSpread({}, metadata), resourceSelectType ? {
|
|
1401
1406
|
resource_select_type: resourceSelectType
|
|
1402
1407
|
} : {}), resourceSelectType ? {
|
|
1403
1408
|
capacity: [{
|
|
@@ -1446,20 +1451,98 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1446
1451
|
};
|
|
1447
1452
|
}
|
|
1448
1453
|
}, {
|
|
1449
|
-
key: "
|
|
1454
|
+
key: "isScanOrderMoreMode",
|
|
1455
|
+
value: function isScanOrderMoreMode(tempOrder) {
|
|
1456
|
+
var _this$store$resource, _this$store$entryCont;
|
|
1457
|
+
var mode = (_this$store$resource = this.store.resource) === null || _this$store$resource === void 0 ? void 0 : _this$store$resource.mode;
|
|
1458
|
+
return Boolean(tempOrder.order_id && (mode === 'additional_order' || mode === 'additional_order_with_code' || ((_this$store$entryCont = this.store.entryContext) === null || _this$store$entryCont === void 0 ? void 0 : _this$store$entryCont.mode) === 'append'));
|
|
1459
|
+
}
|
|
1460
|
+
}, {
|
|
1461
|
+
key: "submitScanOrderMore",
|
|
1450
1462
|
value: function () {
|
|
1451
|
-
var
|
|
1452
|
-
var _this$
|
|
1463
|
+
var _submitScanOrderMore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(params) {
|
|
1464
|
+
var _this$otherParams8, _this$otherParams9, _this$otherParams10, _this$otherParams11, _this$otherParams12;
|
|
1465
|
+
var tempOrder, enhancePayload, latestSummary, payload, products, orderId, result;
|
|
1453
1466
|
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1454
1467
|
while (1) switch (_context17.prev = _context17.next) {
|
|
1468
|
+
case 0:
|
|
1469
|
+
if (this.request) {
|
|
1470
|
+
_context17.next = 2;
|
|
1471
|
+
break;
|
|
1472
|
+
}
|
|
1473
|
+
throw new Error('scanOrder解决方案需要 request 插件支持');
|
|
1474
|
+
case 2:
|
|
1475
|
+
if (this.store.order) {
|
|
1476
|
+
_context17.next = 4;
|
|
1477
|
+
break;
|
|
1478
|
+
}
|
|
1479
|
+
throw new Error('scanOrder解决方案需要 order 模块支持');
|
|
1480
|
+
case 4:
|
|
1481
|
+
tempOrder = params.tempOrder, enhancePayload = params.enhancePayload;
|
|
1482
|
+
_context17.next = 7;
|
|
1483
|
+
return this.store.order.recalculateSummary({
|
|
1484
|
+
createIfMissing: true
|
|
1485
|
+
});
|
|
1486
|
+
case 7:
|
|
1487
|
+
latestSummary = _context17.sent;
|
|
1488
|
+
payload = buildSubmitPayload({
|
|
1489
|
+
tempOrder: tempOrder,
|
|
1490
|
+
cacheId: this.cacheId,
|
|
1491
|
+
platform: (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.platform,
|
|
1492
|
+
businessCode: ((_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.businessCode) || ((_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.business_code),
|
|
1493
|
+
channel: (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.channel,
|
|
1494
|
+
type: (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.type,
|
|
1495
|
+
summary: latestSummary,
|
|
1496
|
+
enhance: enhancePayload
|
|
1497
|
+
});
|
|
1498
|
+
products = filterProductsForScanOrderMore(payload.products);
|
|
1499
|
+
orderId = tempOrder.order_id;
|
|
1500
|
+
_context17.next = 13;
|
|
1501
|
+
return this.request.put("/order/order/product/".concat(orderId), {
|
|
1502
|
+
products: products,
|
|
1503
|
+
request_unique_idempotency_token: payload.request_unique_idempotency_token
|
|
1504
|
+
}, {
|
|
1505
|
+
customToast: function customToast() {}
|
|
1506
|
+
});
|
|
1507
|
+
case 13:
|
|
1508
|
+
result = _context17.sent;
|
|
1509
|
+
if (!((result === null || result === void 0 ? void 0 : result.code) === 200 && !(result !== null && result !== void 0 && result.data))) {
|
|
1510
|
+
_context17.next = 16;
|
|
1511
|
+
break;
|
|
1512
|
+
}
|
|
1513
|
+
return _context17.abrupt("return", _objectSpread(_objectSpread({}, result), {}, {
|
|
1514
|
+
data: {
|
|
1515
|
+
order_id: orderId
|
|
1516
|
+
}
|
|
1517
|
+
}));
|
|
1518
|
+
case 16:
|
|
1519
|
+
return _context17.abrupt("return", result);
|
|
1520
|
+
case 17:
|
|
1521
|
+
case "end":
|
|
1522
|
+
return _context17.stop();
|
|
1523
|
+
}
|
|
1524
|
+
}, _callee17, this);
|
|
1525
|
+
}));
|
|
1526
|
+
function submitScanOrderMore(_x11) {
|
|
1527
|
+
return _submitScanOrderMore.apply(this, arguments);
|
|
1528
|
+
}
|
|
1529
|
+
return submitScanOrderMore;
|
|
1530
|
+
}()
|
|
1531
|
+
}, {
|
|
1532
|
+
key: "submitScanOrder",
|
|
1533
|
+
value: function () {
|
|
1534
|
+
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
1535
|
+
var _this$store$resource2, _tempOrder$products, pax, tempOrderForSubmit, resourceTableName, enhancePayload, result, tempOrder;
|
|
1536
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1537
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1455
1538
|
case 0:
|
|
1456
1539
|
this.logMethodStart('submitScanOrder');
|
|
1457
|
-
|
|
1458
|
-
|
|
1540
|
+
_context18.prev = 1;
|
|
1541
|
+
_context18.next = 4;
|
|
1459
1542
|
return this.validateBeforeSubmitByItemRule();
|
|
1460
1543
|
case 4:
|
|
1461
1544
|
if (this.store.order) {
|
|
1462
|
-
|
|
1545
|
+
_context18.next = 6;
|
|
1463
1546
|
break;
|
|
1464
1547
|
}
|
|
1465
1548
|
throw new Error('scanOrder解决方案需要 order 模块支持');
|
|
@@ -1471,7 +1554,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1471
1554
|
collect_pax: pax
|
|
1472
1555
|
});
|
|
1473
1556
|
tempOrderForSubmit.delivery_type = 'shop_service';
|
|
1474
|
-
resourceTableName = (_this$store$
|
|
1557
|
+
resourceTableName = (_this$store$resource2 = this.store.resource) === null || _this$store$resource2 === void 0 || (_this$store$resource2 = _this$store$resource2.table_form_record) === null || _this$store$resource2 === void 0 ? void 0 : _this$store$resource2.name;
|
|
1475
1558
|
if (resourceTableName && _typeof(resourceTableName) === 'object') {
|
|
1476
1559
|
tempOrderForSubmit.table_number = resourceTableName;
|
|
1477
1560
|
} else {
|
|
@@ -1479,32 +1562,43 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1479
1562
|
}
|
|
1480
1563
|
this.store.order.persistTempOrder();
|
|
1481
1564
|
enhancePayload = this.buildSubmitPayloadEnhancer();
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1565
|
+
if (!this.isScanOrderMoreMode(tempOrderForSubmit)) {
|
|
1566
|
+
_context18.next = 21;
|
|
1567
|
+
break;
|
|
1568
|
+
}
|
|
1569
|
+
_context18.next = 18;
|
|
1570
|
+
return this.submitScanOrderMore({
|
|
1571
|
+
tempOrder: tempOrderForSubmit,
|
|
1489
1572
|
enhancePayload: enhancePayload
|
|
1490
1573
|
});
|
|
1491
|
-
case
|
|
1492
|
-
|
|
1574
|
+
case 18:
|
|
1575
|
+
_context18.t0 = _context18.sent;
|
|
1576
|
+
_context18.next = 24;
|
|
1577
|
+
break;
|
|
1578
|
+
case 21:
|
|
1579
|
+
_context18.next = 23;
|
|
1580
|
+
return this.submitSalesOrder({
|
|
1581
|
+
enhancePayload: enhancePayload
|
|
1582
|
+
});
|
|
1583
|
+
case 23:
|
|
1584
|
+
_context18.t0 = _context18.sent;
|
|
1585
|
+
case 24:
|
|
1586
|
+
result = _context18.t0;
|
|
1493
1587
|
tempOrder = this.store.order.getTempOrder();
|
|
1494
1588
|
this.logMethodSuccess('submitScanOrder', {
|
|
1495
1589
|
productCount: (tempOrder === null || tempOrder === void 0 || (_tempOrder$products = tempOrder.products) === null || _tempOrder$products === void 0 ? void 0 : _tempOrder$products.length) || 0
|
|
1496
1590
|
});
|
|
1497
|
-
return
|
|
1498
|
-
case
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
this.logMethodError('submitScanOrder',
|
|
1502
|
-
throw
|
|
1503
|
-
case
|
|
1591
|
+
return _context18.abrupt("return", result);
|
|
1592
|
+
case 30:
|
|
1593
|
+
_context18.prev = 30;
|
|
1594
|
+
_context18.t1 = _context18["catch"](1);
|
|
1595
|
+
this.logMethodError('submitScanOrder', _context18.t1);
|
|
1596
|
+
throw _context18.t1;
|
|
1597
|
+
case 34:
|
|
1504
1598
|
case "end":
|
|
1505
|
-
return
|
|
1599
|
+
return _context18.stop();
|
|
1506
1600
|
}
|
|
1507
|
-
},
|
|
1601
|
+
}, _callee18, this, [[1, 30]]);
|
|
1508
1602
|
}));
|
|
1509
1603
|
function submitScanOrder() {
|
|
1510
1604
|
return _submitScanOrder.apply(this, arguments);
|
|
@@ -1514,48 +1608,48 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1514
1608
|
}, {
|
|
1515
1609
|
key: "addProductToOrder",
|
|
1516
1610
|
value: function () {
|
|
1517
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1611
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(product) {
|
|
1518
1612
|
var products;
|
|
1519
|
-
return _regeneratorRuntime().wrap(function
|
|
1520
|
-
while (1) switch (
|
|
1613
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1614
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1521
1615
|
case 0:
|
|
1522
1616
|
this.logMethodStart('addProductToOrder', {
|
|
1523
1617
|
product_id: product.product_id,
|
|
1524
1618
|
product_variant_id: product.product_variant_id
|
|
1525
1619
|
});
|
|
1526
|
-
|
|
1620
|
+
_context19.prev = 1;
|
|
1527
1621
|
if (this.store.order) {
|
|
1528
|
-
|
|
1622
|
+
_context19.next = 4;
|
|
1529
1623
|
break;
|
|
1530
1624
|
}
|
|
1531
1625
|
throw new Error('order 模块未初始化');
|
|
1532
1626
|
case 4:
|
|
1533
|
-
|
|
1627
|
+
_context19.next = 6;
|
|
1534
1628
|
return this.store.order.addProductToOrder(product);
|
|
1535
1629
|
case 6:
|
|
1536
|
-
products =
|
|
1537
|
-
|
|
1630
|
+
products = _context19.sent;
|
|
1631
|
+
_context19.next = 9;
|
|
1538
1632
|
return this.refreshItemRuleQuantityLimits();
|
|
1539
1633
|
case 9:
|
|
1540
|
-
|
|
1634
|
+
_context19.next = 11;
|
|
1541
1635
|
return this.refreshCartValidationPassed();
|
|
1542
1636
|
case 11:
|
|
1543
1637
|
this.logMethodSuccess('addProductToOrder', {
|
|
1544
1638
|
productCount: products.length
|
|
1545
1639
|
});
|
|
1546
|
-
return
|
|
1640
|
+
return _context19.abrupt("return", products);
|
|
1547
1641
|
case 15:
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
this.logMethodError('addProductToOrder',
|
|
1551
|
-
throw
|
|
1642
|
+
_context19.prev = 15;
|
|
1643
|
+
_context19.t0 = _context19["catch"](1);
|
|
1644
|
+
this.logMethodError('addProductToOrder', _context19.t0);
|
|
1645
|
+
throw _context19.t0;
|
|
1552
1646
|
case 19:
|
|
1553
1647
|
case "end":
|
|
1554
|
-
return
|
|
1648
|
+
return _context19.stop();
|
|
1555
1649
|
}
|
|
1556
|
-
},
|
|
1650
|
+
}, _callee19, this, [[1, 15]]);
|
|
1557
1651
|
}));
|
|
1558
|
-
function addProductToOrder(
|
|
1652
|
+
function addProductToOrder(_x12) {
|
|
1559
1653
|
return _addProductToOrder.apply(this, arguments);
|
|
1560
1654
|
}
|
|
1561
1655
|
return addProductToOrder;
|
|
@@ -1563,48 +1657,48 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1563
1657
|
}, {
|
|
1564
1658
|
key: "updateOrderProduct",
|
|
1565
1659
|
value: function () {
|
|
1566
|
-
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1660
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
|
|
1567
1661
|
var products;
|
|
1568
|
-
return _regeneratorRuntime().wrap(function
|
|
1569
|
-
while (1) switch (
|
|
1662
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1663
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1570
1664
|
case 0:
|
|
1571
1665
|
this.logMethodStart('updateOrderProduct', {
|
|
1572
1666
|
product_id: params.product_id,
|
|
1573
1667
|
product_variant_id: params.product_variant_id
|
|
1574
1668
|
});
|
|
1575
|
-
|
|
1669
|
+
_context20.prev = 1;
|
|
1576
1670
|
if (this.store.order) {
|
|
1577
|
-
|
|
1671
|
+
_context20.next = 4;
|
|
1578
1672
|
break;
|
|
1579
1673
|
}
|
|
1580
1674
|
throw new Error('order 模块未初始化');
|
|
1581
1675
|
case 4:
|
|
1582
|
-
|
|
1676
|
+
_context20.next = 6;
|
|
1583
1677
|
return this.store.order.updateOrderProduct(params);
|
|
1584
1678
|
case 6:
|
|
1585
|
-
products =
|
|
1586
|
-
|
|
1679
|
+
products = _context20.sent;
|
|
1680
|
+
_context20.next = 9;
|
|
1587
1681
|
return this.refreshItemRuleQuantityLimits();
|
|
1588
1682
|
case 9:
|
|
1589
|
-
|
|
1683
|
+
_context20.next = 11;
|
|
1590
1684
|
return this.refreshCartValidationPassed();
|
|
1591
1685
|
case 11:
|
|
1592
1686
|
this.logMethodSuccess('updateOrderProduct', {
|
|
1593
1687
|
productCount: products.length
|
|
1594
1688
|
});
|
|
1595
|
-
return
|
|
1689
|
+
return _context20.abrupt("return", products);
|
|
1596
1690
|
case 15:
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
this.logMethodError('updateOrderProduct',
|
|
1600
|
-
throw
|
|
1691
|
+
_context20.prev = 15;
|
|
1692
|
+
_context20.t0 = _context20["catch"](1);
|
|
1693
|
+
this.logMethodError('updateOrderProduct', _context20.t0);
|
|
1694
|
+
throw _context20.t0;
|
|
1601
1695
|
case 19:
|
|
1602
1696
|
case "end":
|
|
1603
|
-
return
|
|
1697
|
+
return _context20.stop();
|
|
1604
1698
|
}
|
|
1605
|
-
},
|
|
1699
|
+
}, _callee20, this, [[1, 15]]);
|
|
1606
1700
|
}));
|
|
1607
|
-
function updateOrderProduct(
|
|
1701
|
+
function updateOrderProduct(_x13) {
|
|
1608
1702
|
return _updateOrderProduct.apply(this, arguments);
|
|
1609
1703
|
}
|
|
1610
1704
|
return updateOrderProduct;
|
|
@@ -1616,16 +1710,16 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1616
1710
|
}, {
|
|
1617
1711
|
key: "setOrderProductLineNote",
|
|
1618
1712
|
value: (function () {
|
|
1619
|
-
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1713
|
+
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(identity, note) {
|
|
1620
1714
|
var params, products;
|
|
1621
|
-
return _regeneratorRuntime().wrap(function
|
|
1622
|
-
while (1) switch (
|
|
1715
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1716
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1623
1717
|
case 0:
|
|
1624
1718
|
this.logMethodStart('setOrderProductLineNote', {
|
|
1625
1719
|
product_id: identity.product_id,
|
|
1626
1720
|
product_variant_id: identity.product_variant_id
|
|
1627
1721
|
});
|
|
1628
|
-
|
|
1722
|
+
_context21.prev = 1;
|
|
1629
1723
|
params = {
|
|
1630
1724
|
product_id: identity.product_id,
|
|
1631
1725
|
product_variant_id: identity.product_variant_id,
|
|
@@ -1638,26 +1732,26 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1638
1732
|
params.product_sku = identity.product_sku;
|
|
1639
1733
|
}
|
|
1640
1734
|
if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
|
|
1641
|
-
|
|
1735
|
+
_context21.next = 8;
|
|
1642
1736
|
return this.updateOrderProduct(params);
|
|
1643
1737
|
case 8:
|
|
1644
|
-
products =
|
|
1738
|
+
products = _context21.sent;
|
|
1645
1739
|
this.logMethodSuccess('setOrderProductLineNote', {
|
|
1646
1740
|
productCount: products.length
|
|
1647
1741
|
});
|
|
1648
|
-
return
|
|
1742
|
+
return _context21.abrupt("return", products);
|
|
1649
1743
|
case 13:
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
this.logMethodError('setOrderProductLineNote',
|
|
1653
|
-
throw
|
|
1744
|
+
_context21.prev = 13;
|
|
1745
|
+
_context21.t0 = _context21["catch"](1);
|
|
1746
|
+
this.logMethodError('setOrderProductLineNote', _context21.t0);
|
|
1747
|
+
throw _context21.t0;
|
|
1654
1748
|
case 17:
|
|
1655
1749
|
case "end":
|
|
1656
|
-
return
|
|
1750
|
+
return _context21.stop();
|
|
1657
1751
|
}
|
|
1658
|
-
},
|
|
1752
|
+
}, _callee21, this, [[1, 13]]);
|
|
1659
1753
|
}));
|
|
1660
|
-
function setOrderProductLineNote(
|
|
1754
|
+
function setOrderProductLineNote(_x14, _x15) {
|
|
1661
1755
|
return _setOrderProductLineNote.apply(this, arguments);
|
|
1662
1756
|
}
|
|
1663
1757
|
return setOrderProductLineNote;
|
|
@@ -1665,48 +1759,48 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1665
1759
|
}, {
|
|
1666
1760
|
key: "removeProductFromOrder",
|
|
1667
1761
|
value: function () {
|
|
1668
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1762
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(identity) {
|
|
1669
1763
|
var products;
|
|
1670
|
-
return _regeneratorRuntime().wrap(function
|
|
1671
|
-
while (1) switch (
|
|
1764
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
1765
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1672
1766
|
case 0:
|
|
1673
1767
|
this.logMethodStart('removeProductFromOrder', {
|
|
1674
1768
|
product_id: identity.product_id,
|
|
1675
1769
|
product_variant_id: identity.product_variant_id
|
|
1676
1770
|
});
|
|
1677
|
-
|
|
1771
|
+
_context22.prev = 1;
|
|
1678
1772
|
if (this.store.order) {
|
|
1679
|
-
|
|
1773
|
+
_context22.next = 4;
|
|
1680
1774
|
break;
|
|
1681
1775
|
}
|
|
1682
1776
|
throw new Error('order 模块未初始化');
|
|
1683
1777
|
case 4:
|
|
1684
|
-
|
|
1778
|
+
_context22.next = 6;
|
|
1685
1779
|
return this.store.order.removeProductFromOrder(identity);
|
|
1686
1780
|
case 6:
|
|
1687
|
-
products =
|
|
1688
|
-
|
|
1781
|
+
products = _context22.sent;
|
|
1782
|
+
_context22.next = 9;
|
|
1689
1783
|
return this.refreshItemRuleQuantityLimits();
|
|
1690
1784
|
case 9:
|
|
1691
|
-
|
|
1785
|
+
_context22.next = 11;
|
|
1692
1786
|
return this.refreshCartValidationPassed();
|
|
1693
1787
|
case 11:
|
|
1694
1788
|
this.logMethodSuccess('removeProductFromOrder', {
|
|
1695
1789
|
productCount: products.length
|
|
1696
1790
|
});
|
|
1697
|
-
return
|
|
1791
|
+
return _context22.abrupt("return", products);
|
|
1698
1792
|
case 15:
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
this.logMethodError('removeProductFromOrder',
|
|
1702
|
-
throw
|
|
1793
|
+
_context22.prev = 15;
|
|
1794
|
+
_context22.t0 = _context22["catch"](1);
|
|
1795
|
+
this.logMethodError('removeProductFromOrder', _context22.t0);
|
|
1796
|
+
throw _context22.t0;
|
|
1703
1797
|
case 19:
|
|
1704
1798
|
case "end":
|
|
1705
|
-
return
|
|
1799
|
+
return _context22.stop();
|
|
1706
1800
|
}
|
|
1707
|
-
},
|
|
1801
|
+
}, _callee22, this, [[1, 15]]);
|
|
1708
1802
|
}));
|
|
1709
|
-
function removeProductFromOrder(
|
|
1803
|
+
function removeProductFromOrder(_x16) {
|
|
1710
1804
|
return _removeProductFromOrder.apply(this, arguments);
|
|
1711
1805
|
}
|
|
1712
1806
|
return removeProductFromOrder;
|
|
@@ -1714,26 +1808,26 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1714
1808
|
}, {
|
|
1715
1809
|
key: "loadRuntimeConfigs",
|
|
1716
1810
|
value: function () {
|
|
1717
|
-
var _loadRuntimeConfigs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1811
|
+
var _loadRuntimeConfigs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
1718
1812
|
var itemRuleConfigs;
|
|
1719
|
-
return _regeneratorRuntime().wrap(function
|
|
1720
|
-
while (1) switch (
|
|
1813
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
1814
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1721
1815
|
case 0:
|
|
1722
|
-
|
|
1816
|
+
_context23.next = 2;
|
|
1723
1817
|
return this.ensureItemRuleConfigsLoaded();
|
|
1724
1818
|
case 2:
|
|
1725
|
-
itemRuleConfigs =
|
|
1819
|
+
itemRuleConfigs = _context23.sent;
|
|
1726
1820
|
this.logMethodSuccess('loadRuntimeConfigs', {
|
|
1727
1821
|
itemRuleCount: itemRuleConfigs.length
|
|
1728
1822
|
});
|
|
1729
|
-
return
|
|
1823
|
+
return _context23.abrupt("return", {
|
|
1730
1824
|
itemRuleConfigs: itemRuleConfigs
|
|
1731
1825
|
});
|
|
1732
1826
|
case 5:
|
|
1733
1827
|
case "end":
|
|
1734
|
-
return
|
|
1828
|
+
return _context23.stop();
|
|
1735
1829
|
}
|
|
1736
|
-
},
|
|
1830
|
+
}, _callee23, this);
|
|
1737
1831
|
}));
|
|
1738
1832
|
function loadRuntimeConfigs() {
|
|
1739
1833
|
return _loadRuntimeConfigs.apply(this, arguments);
|
|
@@ -1743,15 +1837,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1743
1837
|
}, {
|
|
1744
1838
|
key: "syncItemRuleConfigsFromDineInConfig",
|
|
1745
1839
|
value: function () {
|
|
1746
|
-
var _syncItemRuleConfigsFromDineInConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1840
|
+
var _syncItemRuleConfigsFromDineInConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(dineInConfig) {
|
|
1747
1841
|
var enableItemRules, strategyModelIds, itemRuleConfigs;
|
|
1748
|
-
return _regeneratorRuntime().wrap(function
|
|
1749
|
-
while (1) switch (
|
|
1842
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
1843
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1750
1844
|
case 0:
|
|
1751
1845
|
enableItemRules = toBoolean(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['sale.enable_item_rules']);
|
|
1752
1846
|
strategyModelIds = normalizeEnabledItemRuleIds(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['sale.enabled_item_rules']);
|
|
1753
1847
|
if (!(!enableItemRules || !strategyModelIds.length)) {
|
|
1754
|
-
|
|
1848
|
+
_context24.next = 8;
|
|
1755
1849
|
break;
|
|
1756
1850
|
}
|
|
1757
1851
|
this.itemRuleConfigs = [];
|
|
@@ -1762,12 +1856,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1762
1856
|
strategyModelIds: [],
|
|
1763
1857
|
itemRuleCount: 0
|
|
1764
1858
|
});
|
|
1765
|
-
return
|
|
1859
|
+
return _context24.abrupt("return", []);
|
|
1766
1860
|
case 8:
|
|
1767
|
-
|
|
1861
|
+
_context24.next = 10;
|
|
1768
1862
|
return this.fetchItemRuleConfigsByModelIds(strategyModelIds);
|
|
1769
1863
|
case 10:
|
|
1770
|
-
itemRuleConfigs =
|
|
1864
|
+
itemRuleConfigs = _context24.sent;
|
|
1771
1865
|
this.itemRuleConfigs = itemRuleConfigs;
|
|
1772
1866
|
this.itemRuleConfigsPromise = Promise.resolve(itemRuleConfigs);
|
|
1773
1867
|
this.itemRuleEvaluator.setStrategyConfigs(itemRuleConfigs);
|
|
@@ -1776,14 +1870,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1776
1870
|
strategyModelIds: strategyModelIds,
|
|
1777
1871
|
itemRuleCount: itemRuleConfigs.length
|
|
1778
1872
|
});
|
|
1779
|
-
return
|
|
1873
|
+
return _context24.abrupt("return", itemRuleConfigs);
|
|
1780
1874
|
case 16:
|
|
1781
1875
|
case "end":
|
|
1782
|
-
return
|
|
1876
|
+
return _context24.stop();
|
|
1783
1877
|
}
|
|
1784
|
-
},
|
|
1878
|
+
}, _callee24, this);
|
|
1785
1879
|
}));
|
|
1786
|
-
function syncItemRuleConfigsFromDineInConfig(
|
|
1880
|
+
function syncItemRuleConfigsFromDineInConfig(_x17) {
|
|
1787
1881
|
return _syncItemRuleConfigsFromDineInConfig.apply(this, arguments);
|
|
1788
1882
|
}
|
|
1789
1883
|
return syncItemRuleConfigsFromDineInConfig;
|
|
@@ -1791,22 +1885,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1791
1885
|
}, {
|
|
1792
1886
|
key: "fetchItemRuleConfigsByModelIds",
|
|
1793
1887
|
value: function () {
|
|
1794
|
-
var _fetchItemRuleConfigsByModelIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1888
|
+
var _fetchItemRuleConfigsByModelIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(strategyModelIds) {
|
|
1795
1889
|
var result, configs;
|
|
1796
|
-
return _regeneratorRuntime().wrap(function
|
|
1797
|
-
while (1) switch (
|
|
1890
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
1891
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
1798
1892
|
case 0:
|
|
1799
1893
|
this.logMethodStart('fetchItemRuleConfigsByModelIds', {
|
|
1800
1894
|
strategyModelIds: strategyModelIds
|
|
1801
1895
|
});
|
|
1802
1896
|
if (strategyModelIds.length) {
|
|
1803
|
-
|
|
1897
|
+
_context25.next = 3;
|
|
1804
1898
|
break;
|
|
1805
1899
|
}
|
|
1806
|
-
return
|
|
1900
|
+
return _context25.abrupt("return", []);
|
|
1807
1901
|
case 3:
|
|
1808
|
-
|
|
1809
|
-
|
|
1902
|
+
_context25.prev = 3;
|
|
1903
|
+
_context25.next = 6;
|
|
1810
1904
|
return this.request.get('/promotion', {
|
|
1811
1905
|
skip: 1,
|
|
1812
1906
|
num: 99,
|
|
@@ -1814,7 +1908,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1814
1908
|
ids: strategyModelIds
|
|
1815
1909
|
});
|
|
1816
1910
|
case 6:
|
|
1817
|
-
result =
|
|
1911
|
+
result = _context25.sent;
|
|
1818
1912
|
configs = [];
|
|
1819
1913
|
if (result.code === 200) {
|
|
1820
1914
|
configs = result.data.list.map(function (item) {
|
|
@@ -1825,22 +1919,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1825
1919
|
strategyModelIds: strategyModelIds,
|
|
1826
1920
|
strategyCount: configs.length
|
|
1827
1921
|
});
|
|
1828
|
-
return
|
|
1922
|
+
return _context25.abrupt("return", configs);
|
|
1829
1923
|
case 13:
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
this.logMethodError('fetchItemRuleConfigsByModelIds',
|
|
1924
|
+
_context25.prev = 13;
|
|
1925
|
+
_context25.t0 = _context25["catch"](3);
|
|
1926
|
+
this.logMethodError('fetchItemRuleConfigsByModelIds', _context25.t0, {
|
|
1833
1927
|
strategyModelIds: strategyModelIds
|
|
1834
1928
|
});
|
|
1835
1929
|
// A:策略加载失败时不阻塞下单
|
|
1836
|
-
return
|
|
1930
|
+
return _context25.abrupt("return", []);
|
|
1837
1931
|
case 17:
|
|
1838
1932
|
case "end":
|
|
1839
|
-
return
|
|
1933
|
+
return _context25.stop();
|
|
1840
1934
|
}
|
|
1841
|
-
},
|
|
1935
|
+
}, _callee25, this, [[3, 13]]);
|
|
1842
1936
|
}));
|
|
1843
|
-
function fetchItemRuleConfigsByModelIds(
|
|
1937
|
+
function fetchItemRuleConfigsByModelIds(_x18) {
|
|
1844
1938
|
return _fetchItemRuleConfigsByModelIds.apply(this, arguments);
|
|
1845
1939
|
}
|
|
1846
1940
|
return fetchItemRuleConfigsByModelIds;
|
|
@@ -1848,22 +1942,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1848
1942
|
}, {
|
|
1849
1943
|
key: "buildPrefillProductSourceMap",
|
|
1850
1944
|
value: function () {
|
|
1851
|
-
var _buildPrefillProductSourceMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1945
|
+
var _buildPrefillProductSourceMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
|
|
1852
1946
|
var sourceMap, productList, visited, collectFromValue;
|
|
1853
|
-
return _regeneratorRuntime().wrap(function
|
|
1854
|
-
while (1) switch (
|
|
1947
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
1948
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
1855
1949
|
case 0:
|
|
1856
1950
|
sourceMap = new Map();
|
|
1857
|
-
|
|
1858
|
-
|
|
1951
|
+
_context26.prev = 1;
|
|
1952
|
+
_context26.next = 4;
|
|
1859
1953
|
return this.getProductList();
|
|
1860
1954
|
case 4:
|
|
1861
|
-
productList =
|
|
1955
|
+
productList = _context26.sent;
|
|
1862
1956
|
if (Array.isArray(productList)) {
|
|
1863
|
-
|
|
1957
|
+
_context26.next = 7;
|
|
1864
1958
|
break;
|
|
1865
1959
|
}
|
|
1866
|
-
return
|
|
1960
|
+
return _context26.abrupt("return", sourceMap);
|
|
1867
1961
|
case 7:
|
|
1868
1962
|
visited = new Set();
|
|
1869
1963
|
collectFromValue = function collectFromValue(value) {
|
|
@@ -1898,27 +1992,27 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1898
1992
|
sourceMap.set(key, node);
|
|
1899
1993
|
}
|
|
1900
1994
|
}
|
|
1901
|
-
for (var
|
|
1902
|
-
var childValue = _Object$values[
|
|
1995
|
+
for (var _i3 = 0, _Object$values = Object.values(node); _i3 < _Object$values.length; _i3++) {
|
|
1996
|
+
var childValue = _Object$values[_i3];
|
|
1903
1997
|
if (childValue && _typeof(childValue) === 'object') {
|
|
1904
1998
|
collectFromValue(childValue);
|
|
1905
1999
|
}
|
|
1906
2000
|
}
|
|
1907
2001
|
};
|
|
1908
2002
|
collectFromValue(productList);
|
|
1909
|
-
|
|
2003
|
+
_context26.next = 15;
|
|
1910
2004
|
break;
|
|
1911
2005
|
case 12:
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
this.logMethodError('buildPrefillProductSourceMap',
|
|
2006
|
+
_context26.prev = 12;
|
|
2007
|
+
_context26.t0 = _context26["catch"](1);
|
|
2008
|
+
this.logMethodError('buildPrefillProductSourceMap', _context26.t0);
|
|
1915
2009
|
case 15:
|
|
1916
|
-
return
|
|
2010
|
+
return _context26.abrupt("return", sourceMap);
|
|
1917
2011
|
case 16:
|
|
1918
2012
|
case "end":
|
|
1919
|
-
return
|
|
2013
|
+
return _context26.stop();
|
|
1920
2014
|
}
|
|
1921
|
-
},
|
|
2015
|
+
}, _callee26, this, [[1, 12]]);
|
|
1922
2016
|
}));
|
|
1923
2017
|
function buildPrefillProductSourceMap() {
|
|
1924
2018
|
return _buildPrefillProductSourceMap.apply(this, arguments);
|
|
@@ -1933,58 +2027,58 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1933
2027
|
}, {
|
|
1934
2028
|
key: "ensureItemRuleConfigsLoaded",
|
|
1935
2029
|
value: function () {
|
|
1936
|
-
var _ensureItemRuleConfigsLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2030
|
+
var _ensureItemRuleConfigsLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
|
|
1937
2031
|
var _this6 = this;
|
|
1938
2032
|
var loadedConfigs;
|
|
1939
|
-
return _regeneratorRuntime().wrap(function
|
|
1940
|
-
while (1) switch (
|
|
2033
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
2034
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
1941
2035
|
case 0:
|
|
1942
2036
|
if (!(this.itemRuleConfigs.length > 0)) {
|
|
1943
|
-
|
|
2037
|
+
_context28.next = 2;
|
|
1944
2038
|
break;
|
|
1945
2039
|
}
|
|
1946
|
-
return
|
|
2040
|
+
return _context28.abrupt("return", this.itemRuleConfigs);
|
|
1947
2041
|
case 2:
|
|
1948
2042
|
if (!this.itemRuleConfigsPromise) {
|
|
1949
|
-
|
|
2043
|
+
_context28.next = 4;
|
|
1950
2044
|
break;
|
|
1951
2045
|
}
|
|
1952
|
-
return
|
|
2046
|
+
return _context28.abrupt("return", this.itemRuleConfigsPromise);
|
|
1953
2047
|
case 4:
|
|
1954
|
-
this.itemRuleConfigsPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2048
|
+
this.itemRuleConfigsPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
|
|
1955
2049
|
var runtimeConfig, staticConfigs;
|
|
1956
|
-
return _regeneratorRuntime().wrap(function
|
|
1957
|
-
while (1) switch (
|
|
2050
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
2051
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
1958
2052
|
case 0:
|
|
1959
2053
|
runtimeConfig = _this6.getItemRuleRuntimeConfig();
|
|
1960
2054
|
staticConfigs = normalizeItemRuleStrategies(runtimeConfig.strategyConfigs);
|
|
1961
2055
|
if (!(staticConfigs.length > 0)) {
|
|
1962
|
-
|
|
2056
|
+
_context27.next = 6;
|
|
1963
2057
|
break;
|
|
1964
2058
|
}
|
|
1965
2059
|
_this6.itemRuleConfigs = staticConfigs;
|
|
1966
2060
|
_this6.itemRuleEvaluator.setStrategyConfigs(staticConfigs);
|
|
1967
|
-
return
|
|
2061
|
+
return _context27.abrupt("return", _this6.itemRuleConfigs);
|
|
1968
2062
|
case 6:
|
|
1969
2063
|
_this6.itemRuleConfigs = [];
|
|
1970
2064
|
_this6.itemRuleEvaluator.setStrategyConfigs([]);
|
|
1971
|
-
return
|
|
2065
|
+
return _context27.abrupt("return", _this6.itemRuleConfigs);
|
|
1972
2066
|
case 9:
|
|
1973
2067
|
case "end":
|
|
1974
|
-
return
|
|
2068
|
+
return _context27.stop();
|
|
1975
2069
|
}
|
|
1976
|
-
},
|
|
2070
|
+
}, _callee27);
|
|
1977
2071
|
}))();
|
|
1978
|
-
|
|
2072
|
+
_context28.next = 7;
|
|
1979
2073
|
return this.itemRuleConfigsPromise;
|
|
1980
2074
|
case 7:
|
|
1981
|
-
loadedConfigs =
|
|
1982
|
-
return
|
|
2075
|
+
loadedConfigs = _context28.sent;
|
|
2076
|
+
return _context28.abrupt("return", loadedConfigs);
|
|
1983
2077
|
case 9:
|
|
1984
2078
|
case "end":
|
|
1985
|
-
return
|
|
2079
|
+
return _context28.stop();
|
|
1986
2080
|
}
|
|
1987
|
-
},
|
|
2081
|
+
}, _callee28, this);
|
|
1988
2082
|
}));
|
|
1989
2083
|
function ensureItemRuleConfigsLoaded() {
|
|
1990
2084
|
return _ensureItemRuleConfigsLoaded.apply(this, arguments);
|
|
@@ -1994,25 +2088,25 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1994
2088
|
}, {
|
|
1995
2089
|
key: "refreshItemRuleQuantityLimits",
|
|
1996
2090
|
value: function () {
|
|
1997
|
-
var _refreshItemRuleQuantityLimits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2091
|
+
var _refreshItemRuleQuantityLimits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
|
|
1998
2092
|
var strategyConfigs, businessData, limits;
|
|
1999
|
-
return _regeneratorRuntime().wrap(function
|
|
2000
|
-
while (1) switch (
|
|
2093
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
2094
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
2001
2095
|
case 0:
|
|
2002
|
-
|
|
2003
|
-
|
|
2096
|
+
_context29.prev = 0;
|
|
2097
|
+
_context29.next = 3;
|
|
2004
2098
|
return this.ensureItemRuleConfigsLoaded();
|
|
2005
2099
|
case 3:
|
|
2006
|
-
strategyConfigs =
|
|
2100
|
+
strategyConfigs = _context29.sent;
|
|
2007
2101
|
if (strategyConfigs.length) {
|
|
2008
|
-
|
|
2102
|
+
_context29.next = 7;
|
|
2009
2103
|
break;
|
|
2010
2104
|
}
|
|
2011
2105
|
this.store.itemRuleQuantityLimits = [];
|
|
2012
|
-
return
|
|
2106
|
+
return _context29.abrupt("return", []);
|
|
2013
2107
|
case 7:
|
|
2014
2108
|
businessData = buildItemRuleBusinessData({
|
|
2015
|
-
tempOrder: this.
|
|
2109
|
+
tempOrder: this.ensureScanOrderTempOrder(),
|
|
2016
2110
|
runtimeConfig: this.getItemRuleRuntimeConfig(),
|
|
2017
2111
|
itemRuleConfigs: this.itemRuleConfigs
|
|
2018
2112
|
});
|
|
@@ -2021,18 +2115,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2021
2115
|
this.logMethodSuccess('refreshItemRuleQuantityLimits', {
|
|
2022
2116
|
limitCount: limits.length
|
|
2023
2117
|
});
|
|
2024
|
-
return
|
|
2118
|
+
return _context29.abrupt("return", limits);
|
|
2025
2119
|
case 14:
|
|
2026
|
-
|
|
2027
|
-
|
|
2120
|
+
_context29.prev = 14;
|
|
2121
|
+
_context29.t0 = _context29["catch"](0);
|
|
2028
2122
|
this.store.itemRuleQuantityLimits = [];
|
|
2029
|
-
this.logMethodError('refreshItemRuleQuantityLimits',
|
|
2030
|
-
return
|
|
2123
|
+
this.logMethodError('refreshItemRuleQuantityLimits', _context29.t0);
|
|
2124
|
+
return _context29.abrupt("return", []);
|
|
2031
2125
|
case 19:
|
|
2032
2126
|
case "end":
|
|
2033
|
-
return
|
|
2127
|
+
return _context29.stop();
|
|
2034
2128
|
}
|
|
2035
|
-
},
|
|
2129
|
+
}, _callee29, this, [[0, 14]]);
|
|
2036
2130
|
}));
|
|
2037
2131
|
function refreshItemRuleQuantityLimits() {
|
|
2038
2132
|
return _refreshItemRuleQuantityLimits.apply(this, arguments);
|
|
@@ -2042,58 +2136,58 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2042
2136
|
}, {
|
|
2043
2137
|
key: "applyPrefillByItemRule",
|
|
2044
2138
|
value: function () {
|
|
2045
|
-
var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2139
|
+
var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
|
|
2046
2140
|
var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges, _iterator6, _step6, _prefillItem$product_, _origin2, _origin3, _origin4, prefillItem, productId, productVariantId, targetQuantity, sourceItem, productIndex, _sourceItem$price, sellingPrice, targetProduct, existedQuantity, delta, nextProduct, hasQuantityChanged, hasOriginChanged;
|
|
2047
|
-
return _regeneratorRuntime().wrap(function
|
|
2048
|
-
while (1) switch (
|
|
2141
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
2142
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
2049
2143
|
case 0:
|
|
2050
2144
|
if (!this.itemRulePrefillApplied) {
|
|
2051
|
-
|
|
2145
|
+
_context30.next = 2;
|
|
2052
2146
|
break;
|
|
2053
2147
|
}
|
|
2054
|
-
return
|
|
2148
|
+
return _context30.abrupt("return");
|
|
2055
2149
|
case 2:
|
|
2056
2150
|
if (this.store.order) {
|
|
2057
|
-
|
|
2151
|
+
_context30.next = 4;
|
|
2058
2152
|
break;
|
|
2059
2153
|
}
|
|
2060
|
-
return
|
|
2154
|
+
return _context30.abrupt("return");
|
|
2061
2155
|
case 4:
|
|
2062
|
-
|
|
2156
|
+
_context30.next = 6;
|
|
2063
2157
|
return this.ensureItemRuleConfigsLoaded();
|
|
2064
2158
|
case 6:
|
|
2065
|
-
strategyConfigs =
|
|
2159
|
+
strategyConfigs = _context30.sent;
|
|
2066
2160
|
if (strategyConfigs.length) {
|
|
2067
|
-
|
|
2161
|
+
_context30.next = 9;
|
|
2068
2162
|
break;
|
|
2069
2163
|
}
|
|
2070
|
-
return
|
|
2164
|
+
return _context30.abrupt("return");
|
|
2071
2165
|
case 9:
|
|
2072
2166
|
businessData = buildItemRuleBusinessData({
|
|
2073
|
-
tempOrder: this.
|
|
2167
|
+
tempOrder: this.ensureScanOrderTempOrder(),
|
|
2074
2168
|
runtimeConfig: this.getItemRuleRuntimeConfig(),
|
|
2075
2169
|
itemRuleConfigs: this.itemRuleConfigs
|
|
2076
2170
|
});
|
|
2077
2171
|
prefillItems = this.itemRuleEvaluator.getPrefillItems(businessData);
|
|
2078
2172
|
if (prefillItems.length) {
|
|
2079
|
-
|
|
2173
|
+
_context30.next = 14;
|
|
2080
2174
|
break;
|
|
2081
2175
|
}
|
|
2082
2176
|
this.itemRulePrefillApplied = true;
|
|
2083
|
-
return
|
|
2177
|
+
return _context30.abrupt("return");
|
|
2084
2178
|
case 14:
|
|
2085
|
-
|
|
2179
|
+
_context30.next = 16;
|
|
2086
2180
|
return this.buildPrefillProductSourceMap();
|
|
2087
2181
|
case 16:
|
|
2088
|
-
productSourceMap =
|
|
2089
|
-
tempOrder = this.
|
|
2182
|
+
productSourceMap = _context30.sent;
|
|
2183
|
+
tempOrder = this.ensureScanOrderTempOrder();
|
|
2090
2184
|
hasChanges = false;
|
|
2091
2185
|
_iterator6 = _createForOfIteratorHelper(prefillItems);
|
|
2092
|
-
|
|
2186
|
+
_context30.prev = 20;
|
|
2093
2187
|
_iterator6.s();
|
|
2094
2188
|
case 22:
|
|
2095
2189
|
if ((_step6 = _iterator6.n()).done) {
|
|
2096
|
-
|
|
2190
|
+
_context30.next = 47;
|
|
2097
2191
|
break;
|
|
2098
2192
|
}
|
|
2099
2193
|
prefillItem = _step6.value;
|
|
@@ -2101,16 +2195,16 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2101
2195
|
productVariantId = Number((_prefillItem$product_ = prefillItem.product_variant_id) !== null && _prefillItem$product_ !== void 0 ? _prefillItem$product_ : 0);
|
|
2102
2196
|
targetQuantity = toNonNegativeInt(prefillItem.quantity);
|
|
2103
2197
|
if (!(!Number.isFinite(productId) || targetQuantity <= 0)) {
|
|
2104
|
-
|
|
2198
|
+
_context30.next = 29;
|
|
2105
2199
|
break;
|
|
2106
2200
|
}
|
|
2107
|
-
return
|
|
2201
|
+
return _context30.abrupt("continue", 45);
|
|
2108
2202
|
case 29:
|
|
2109
2203
|
if (!Number.isNaN(productVariantId)) {
|
|
2110
|
-
|
|
2204
|
+
_context30.next = 31;
|
|
2111
2205
|
break;
|
|
2112
2206
|
}
|
|
2113
|
-
return
|
|
2207
|
+
return _context30.abrupt("continue", 45);
|
|
2114
2208
|
case 31:
|
|
2115
2209
|
sourceItem = productSourceMap.get(buildProductKey(productId, productVariantId)) || productSourceMap.get(buildProductKey(productId, 0)) || null;
|
|
2116
2210
|
productIndex = getProductIdentityIndex(tempOrder.products, {
|
|
@@ -2118,7 +2212,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2118
2212
|
product_variant_id: productVariantId
|
|
2119
2213
|
});
|
|
2120
2214
|
if (!(productIndex === -1)) {
|
|
2121
|
-
|
|
2215
|
+
_context30.next = 38;
|
|
2122
2216
|
break;
|
|
2123
2217
|
}
|
|
2124
2218
|
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');
|
|
@@ -2138,7 +2232,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2138
2232
|
})
|
|
2139
2233
|
})));
|
|
2140
2234
|
hasChanges = true;
|
|
2141
|
-
return
|
|
2235
|
+
return _context30.abrupt("continue", 45);
|
|
2142
2236
|
case 38:
|
|
2143
2237
|
targetProduct = tempOrder.products[productIndex];
|
|
2144
2238
|
existedQuantity = toNonNegativeInt(targetProduct.num);
|
|
@@ -2159,34 +2253,34 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2159
2253
|
hasChanges = true;
|
|
2160
2254
|
}
|
|
2161
2255
|
case 45:
|
|
2162
|
-
|
|
2256
|
+
_context30.next = 22;
|
|
2163
2257
|
break;
|
|
2164
2258
|
case 47:
|
|
2165
|
-
|
|
2259
|
+
_context30.next = 52;
|
|
2166
2260
|
break;
|
|
2167
2261
|
case 49:
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
_iterator6.e(
|
|
2262
|
+
_context30.prev = 49;
|
|
2263
|
+
_context30.t0 = _context30["catch"](20);
|
|
2264
|
+
_iterator6.e(_context30.t0);
|
|
2171
2265
|
case 52:
|
|
2172
|
-
|
|
2266
|
+
_context30.prev = 52;
|
|
2173
2267
|
_iterator6.f();
|
|
2174
|
-
return
|
|
2268
|
+
return _context30.finish(52);
|
|
2175
2269
|
case 55:
|
|
2176
2270
|
if (!hasChanges) {
|
|
2177
|
-
|
|
2271
|
+
_context30.next = 60;
|
|
2178
2272
|
break;
|
|
2179
2273
|
}
|
|
2180
2274
|
// Prefill 属于 products CRUD 的一种形式:新增后让 Rules 重算,以支持自动应用可用优惠券。
|
|
2181
2275
|
this.store.order.applyDiscount();
|
|
2182
|
-
|
|
2276
|
+
_context30.next = 59;
|
|
2183
2277
|
return this.store.order.recalculateSummary({
|
|
2184
2278
|
createIfMissing: true
|
|
2185
2279
|
});
|
|
2186
2280
|
case 59:
|
|
2187
2281
|
this.store.order.persistTempOrder();
|
|
2188
2282
|
case 60:
|
|
2189
|
-
|
|
2283
|
+
_context30.next = 62;
|
|
2190
2284
|
return this.refreshItemRuleQuantityLimits();
|
|
2191
2285
|
case 62:
|
|
2192
2286
|
this.itemRulePrefillApplied = true;
|
|
@@ -2196,9 +2290,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2196
2290
|
});
|
|
2197
2291
|
case 64:
|
|
2198
2292
|
case "end":
|
|
2199
|
-
return
|
|
2293
|
+
return _context30.stop();
|
|
2200
2294
|
}
|
|
2201
|
-
},
|
|
2295
|
+
}, _callee30, this, [[20, 49, 52, 55]]);
|
|
2202
2296
|
}));
|
|
2203
2297
|
function applyPrefillByItemRule() {
|
|
2204
2298
|
return _applyPrefillByItemRule.apply(this, arguments);
|
|
@@ -2208,31 +2302,31 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2208
2302
|
}, {
|
|
2209
2303
|
key: "applyItemRulePrefill",
|
|
2210
2304
|
value: function () {
|
|
2211
|
-
var _applyItemRulePrefill = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2212
|
-
var _this$store$
|
|
2213
|
-
return _regeneratorRuntime().wrap(function
|
|
2214
|
-
while (1) switch (
|
|
2305
|
+
var _applyItemRulePrefill = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
|
|
2306
|
+
var _this$store$order5, _this$store$order5$ge;
|
|
2307
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
2308
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
2215
2309
|
case 0:
|
|
2216
|
-
if (!((_this$store$
|
|
2217
|
-
|
|
2310
|
+
if (!((_this$store$order5 = this.store.order) !== null && _this$store$order5 !== void 0 && (_this$store$order5$ge = _this$store$order5.getLastOrderInfo) !== null && _this$store$order5$ge !== void 0 && _this$store$order5$ge.call(_this$store$order5))) {
|
|
2311
|
+
_context31.next = 2;
|
|
2218
2312
|
break;
|
|
2219
2313
|
}
|
|
2220
|
-
return
|
|
2314
|
+
return _context31.abrupt("return");
|
|
2221
2315
|
case 2:
|
|
2222
2316
|
this.logMethodStart('applyItemRulePrefill');
|
|
2223
|
-
|
|
2317
|
+
_context31.next = 5;
|
|
2224
2318
|
return this.applyPrefillByItemRule();
|
|
2225
2319
|
case 5:
|
|
2226
|
-
|
|
2320
|
+
_context31.next = 7;
|
|
2227
2321
|
return this.refreshItemRuleQuantityLimits();
|
|
2228
2322
|
case 7:
|
|
2229
|
-
|
|
2323
|
+
_context31.next = 9;
|
|
2230
2324
|
return this.refreshCartValidationPassed();
|
|
2231
2325
|
case 9:
|
|
2232
2326
|
case "end":
|
|
2233
|
-
return
|
|
2327
|
+
return _context31.stop();
|
|
2234
2328
|
}
|
|
2235
|
-
},
|
|
2329
|
+
}, _callee31, this);
|
|
2236
2330
|
}));
|
|
2237
2331
|
function applyItemRulePrefill() {
|
|
2238
2332
|
return _applyItemRulePrefill.apply(this, arguments);
|
|
@@ -2242,35 +2336,35 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2242
2336
|
}, {
|
|
2243
2337
|
key: "evaluateCartValidationByItemRule",
|
|
2244
2338
|
value: function () {
|
|
2245
|
-
var _evaluateCartValidationByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2339
|
+
var _evaluateCartValidationByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
|
|
2246
2340
|
var strategyConfigs, businessData;
|
|
2247
|
-
return _regeneratorRuntime().wrap(function
|
|
2248
|
-
while (1) switch (
|
|
2341
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
2342
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
2249
2343
|
case 0:
|
|
2250
|
-
|
|
2344
|
+
_context32.next = 2;
|
|
2251
2345
|
return this.ensureItemRuleConfigsLoaded();
|
|
2252
2346
|
case 2:
|
|
2253
|
-
strategyConfigs =
|
|
2347
|
+
strategyConfigs = _context32.sent;
|
|
2254
2348
|
if (strategyConfigs.length) {
|
|
2255
|
-
|
|
2349
|
+
_context32.next = 5;
|
|
2256
2350
|
break;
|
|
2257
2351
|
}
|
|
2258
|
-
return
|
|
2352
|
+
return _context32.abrupt("return", {
|
|
2259
2353
|
passed: true,
|
|
2260
2354
|
failures: []
|
|
2261
2355
|
});
|
|
2262
2356
|
case 5:
|
|
2263
2357
|
businessData = buildItemRuleBusinessData({
|
|
2264
|
-
tempOrder: this.
|
|
2358
|
+
tempOrder: this.ensureScanOrderTempOrder(),
|
|
2265
2359
|
runtimeConfig: this.getItemRuleRuntimeConfig(),
|
|
2266
2360
|
itemRuleConfigs: this.itemRuleConfigs
|
|
2267
2361
|
});
|
|
2268
|
-
return
|
|
2362
|
+
return _context32.abrupt("return", this.itemRuleEvaluator.validateCart(businessData));
|
|
2269
2363
|
case 7:
|
|
2270
2364
|
case "end":
|
|
2271
|
-
return
|
|
2365
|
+
return _context32.stop();
|
|
2272
2366
|
}
|
|
2273
|
-
},
|
|
2367
|
+
}, _callee32, this);
|
|
2274
2368
|
}));
|
|
2275
2369
|
function evaluateCartValidationByItemRule() {
|
|
2276
2370
|
return _evaluateCartValidationByItemRule.apply(this, arguments);
|
|
@@ -2280,20 +2374,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2280
2374
|
}, {
|
|
2281
2375
|
key: "validateBeforeSubmitByItemRule",
|
|
2282
2376
|
value: function () {
|
|
2283
|
-
var _validateBeforeSubmitByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2377
|
+
var _validateBeforeSubmitByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
|
|
2284
2378
|
var validationResult, firstFailure, errorMessage, error;
|
|
2285
|
-
return _regeneratorRuntime().wrap(function
|
|
2286
|
-
while (1) switch (
|
|
2379
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
2380
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
2287
2381
|
case 0:
|
|
2288
|
-
|
|
2382
|
+
_context33.next = 2;
|
|
2289
2383
|
return this.evaluateCartValidationByItemRule();
|
|
2290
2384
|
case 2:
|
|
2291
|
-
validationResult =
|
|
2385
|
+
validationResult = _context33.sent;
|
|
2292
2386
|
if (!validationResult.passed) {
|
|
2293
|
-
|
|
2387
|
+
_context33.next = 5;
|
|
2294
2388
|
break;
|
|
2295
2389
|
}
|
|
2296
|
-
return
|
|
2390
|
+
return _context33.abrupt("return");
|
|
2297
2391
|
case 5:
|
|
2298
2392
|
firstFailure = validationResult.failures[0];
|
|
2299
2393
|
errorMessage = (firstFailure === null || firstFailure === void 0 ? void 0 : firstFailure.validationMessage) || '当前购物车未满足商品规则,请调整后再提交';
|
|
@@ -2302,9 +2396,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2302
2396
|
throw error;
|
|
2303
2397
|
case 10:
|
|
2304
2398
|
case "end":
|
|
2305
|
-
return
|
|
2399
|
+
return _context33.stop();
|
|
2306
2400
|
}
|
|
2307
|
-
},
|
|
2401
|
+
}, _callee33, this);
|
|
2308
2402
|
}));
|
|
2309
2403
|
function validateBeforeSubmitByItemRule() {
|
|
2310
2404
|
return _validateBeforeSubmitByItemRule.apply(this, arguments);
|
|
@@ -2314,10 +2408,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2314
2408
|
}, {
|
|
2315
2409
|
key: "refreshCartValidationPassed",
|
|
2316
2410
|
value: function () {
|
|
2317
|
-
var _refreshCartValidationPassed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2411
|
+
var _refreshCartValidationPassed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
|
|
2318
2412
|
var previous, nextState, validationResult, changed;
|
|
2319
|
-
return _regeneratorRuntime().wrap(function
|
|
2320
|
-
while (1) switch (
|
|
2413
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
2414
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
2321
2415
|
case 0:
|
|
2322
2416
|
previous = this.store.cartValidation || {
|
|
2323
2417
|
passed: null,
|
|
@@ -2327,20 +2421,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2327
2421
|
passed: null,
|
|
2328
2422
|
failures: []
|
|
2329
2423
|
};
|
|
2330
|
-
|
|
2331
|
-
|
|
2424
|
+
_context34.prev = 2;
|
|
2425
|
+
_context34.next = 5;
|
|
2332
2426
|
return this.evaluateCartValidationByItemRule();
|
|
2333
2427
|
case 5:
|
|
2334
|
-
validationResult =
|
|
2428
|
+
validationResult = _context34.sent;
|
|
2335
2429
|
nextState = {
|
|
2336
2430
|
passed: validationResult.passed,
|
|
2337
2431
|
failures: validationResult.failures || []
|
|
2338
2432
|
};
|
|
2339
|
-
|
|
2433
|
+
_context34.next = 12;
|
|
2340
2434
|
break;
|
|
2341
2435
|
case 9:
|
|
2342
|
-
|
|
2343
|
-
|
|
2436
|
+
_context34.prev = 9;
|
|
2437
|
+
_context34.t0 = _context34["catch"](2);
|
|
2344
2438
|
nextState = {
|
|
2345
2439
|
passed: false,
|
|
2346
2440
|
failures: []
|
|
@@ -2349,21 +2443,21 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2349
2443
|
this.store.cartValidation = nextState;
|
|
2350
2444
|
changed = previous.passed !== nextState.passed || previous.failures !== nextState.failures;
|
|
2351
2445
|
if (!changed) {
|
|
2352
|
-
|
|
2446
|
+
_context34.next = 17;
|
|
2353
2447
|
break;
|
|
2354
2448
|
}
|
|
2355
|
-
|
|
2449
|
+
_context34.next = 17;
|
|
2356
2450
|
return this.core.effects.emit(ScanOrderHooks.onCartValidationChanged, {
|
|
2357
2451
|
cartValidation: nextState,
|
|
2358
2452
|
cartValidationPassed: nextState.passed
|
|
2359
2453
|
});
|
|
2360
2454
|
case 17:
|
|
2361
|
-
return
|
|
2455
|
+
return _context34.abrupt("return", nextState.passed);
|
|
2362
2456
|
case 18:
|
|
2363
2457
|
case "end":
|
|
2364
|
-
return
|
|
2458
|
+
return _context34.stop();
|
|
2365
2459
|
}
|
|
2366
|
-
},
|
|
2460
|
+
}, _callee34, this, [[2, 9]]);
|
|
2367
2461
|
}));
|
|
2368
2462
|
function refreshCartValidationPassed() {
|
|
2369
2463
|
return _refreshCartValidationPassed.apply(this, arguments);
|
|
@@ -2373,14 +2467,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2373
2467
|
}, {
|
|
2374
2468
|
key: "setItemRuleRuntimeConfig",
|
|
2375
2469
|
value: function () {
|
|
2376
|
-
var _setItemRuleRuntimeConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2470
|
+
var _setItemRuleRuntimeConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {
|
|
2377
2471
|
var _this$itemRuleRuntime, _this$itemRuleRuntime2;
|
|
2378
2472
|
var config,
|
|
2379
|
-
|
|
2380
|
-
return _regeneratorRuntime().wrap(function
|
|
2381
|
-
while (1) switch (
|
|
2473
|
+
_args35 = arguments;
|
|
2474
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
2475
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
2382
2476
|
case 0:
|
|
2383
|
-
config =
|
|
2477
|
+
config = _args35.length > 0 && _args35[0] !== undefined ? _args35[0] : {};
|
|
2384
2478
|
this.logMethodStart('setItemRuleRuntimeConfig');
|
|
2385
2479
|
this.itemRuleRuntimeConfig = _objectSpread(_objectSpread(_objectSpread({}, this.itemRuleRuntimeConfig), config), {}, {
|
|
2386
2480
|
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) || {}),
|
|
@@ -2392,10 +2486,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2392
2486
|
this.itemRuleEvaluator.setStrategyConfigs([]);
|
|
2393
2487
|
}
|
|
2394
2488
|
this.itemRulePrefillApplied = false;
|
|
2395
|
-
|
|
2489
|
+
_context35.next = 7;
|
|
2396
2490
|
return this.refreshItemRuleQuantityLimits();
|
|
2397
2491
|
case 7:
|
|
2398
|
-
|
|
2492
|
+
_context35.next = 9;
|
|
2399
2493
|
return this.refreshCartValidationPassed();
|
|
2400
2494
|
case 9:
|
|
2401
2495
|
this.logMethodSuccess('setItemRuleRuntimeConfig', {
|
|
@@ -2403,9 +2497,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2403
2497
|
});
|
|
2404
2498
|
case 10:
|
|
2405
2499
|
case "end":
|
|
2406
|
-
return
|
|
2500
|
+
return _context35.stop();
|
|
2407
2501
|
}
|
|
2408
|
-
},
|
|
2502
|
+
}, _callee35, this);
|
|
2409
2503
|
}));
|
|
2410
2504
|
function setItemRuleRuntimeConfig() {
|
|
2411
2505
|
return _setItemRuleRuntimeConfig.apply(this, arguments);
|
|
@@ -2415,14 +2509,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2415
2509
|
}, {
|
|
2416
2510
|
key: "normalizeResourceState",
|
|
2417
2511
|
value: function normalizeResourceState(detail, resourceSelectType, hasOrderId) {
|
|
2418
|
-
var _detail$form_record, _this$
|
|
2512
|
+
var _detail$form_record, _this$otherParams13, _detail$resource_capa, _detail$resource_capa2;
|
|
2419
2513
|
var currentOrderId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.order_id);
|
|
2420
2514
|
var lastOrderId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.last_order_id);
|
|
2421
2515
|
var relationId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.form_record_id);
|
|
2422
2516
|
var tableFormId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.form_id);
|
|
2423
2517
|
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;
|
|
2424
2518
|
// 是否允许加餐
|
|
2425
|
-
var allowSnack = ((_this$
|
|
2519
|
+
var allowSnack = ((_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 || (_this$otherParams13 = _this$otherParams13.dineInConfig) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13['sale.allow_add_items']) || false;
|
|
2426
2520
|
// 开启同桌验证 - 本期没有这个配置,默认关掉
|
|
2427
2521
|
var deskmateValid = false;
|
|
2428
2522
|
var isExclusive = resourceSelectType === 'single';
|
|
@@ -2502,29 +2596,29 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2502
2596
|
return matched === null || matched === void 0 ? void 0 : matched.type;
|
|
2503
2597
|
}
|
|
2504
2598
|
}, {
|
|
2505
|
-
key: "
|
|
2599
|
+
key: "fetchResourceOccupyDetailsByResourceId",
|
|
2506
2600
|
value: function () {
|
|
2507
|
-
var
|
|
2508
|
-
var _this$
|
|
2601
|
+
var _fetchResourceOccupyDetailsByResourceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(resourceId) {
|
|
2602
|
+
var _this$otherParams14, _this$otherParams14$g, _response$data$occupy, _response$data;
|
|
2509
2603
|
var formRecordId, shopId, response;
|
|
2510
|
-
return _regeneratorRuntime().wrap(function
|
|
2511
|
-
while (1) switch (
|
|
2604
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
2605
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
2512
2606
|
case 0:
|
|
2513
2607
|
formRecordId = Number(resourceId);
|
|
2514
2608
|
if (!(!Number.isFinite(formRecordId) || formRecordId <= 0)) {
|
|
2515
|
-
|
|
2609
|
+
_context36.next = 3;
|
|
2516
2610
|
break;
|
|
2517
2611
|
}
|
|
2518
2612
|
throw new Error("[ScanOrder] \u975E\u6CD5\u684C\u53F0 resourceId: ".concat(resourceId));
|
|
2519
2613
|
case 3:
|
|
2520
|
-
shopId = (_this$
|
|
2614
|
+
shopId = (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 || (_this$otherParams14$g = _this$otherParams14.getStateData) === null || _this$otherParams14$g === void 0 ? void 0 : _this$otherParams14$g.call(_this$otherParams14, 'shop_id');
|
|
2521
2615
|
if (shopId) {
|
|
2522
|
-
|
|
2616
|
+
_context36.next = 6;
|
|
2523
2617
|
break;
|
|
2524
2618
|
}
|
|
2525
2619
|
throw new Error('[ScanOrder] 无法获取 shop_id');
|
|
2526
2620
|
case 6:
|
|
2527
|
-
|
|
2621
|
+
_context36.next = 8;
|
|
2528
2622
|
return this.request.get('/order/resource/occupy-detail', {
|
|
2529
2623
|
shop_id: shopId,
|
|
2530
2624
|
'form_record_ids[]': formRecordId,
|
|
@@ -2533,61 +2627,175 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2533
2627
|
with_resource_form_info: 1
|
|
2534
2628
|
});
|
|
2535
2629
|
case 8:
|
|
2536
|
-
response =
|
|
2630
|
+
response = _context36.sent;
|
|
2537
2631
|
if (response !== null && response !== void 0 && response.status) {
|
|
2538
|
-
|
|
2632
|
+
_context36.next = 11;
|
|
2539
2633
|
break;
|
|
2540
2634
|
}
|
|
2541
2635
|
throw new Error((response === null || response === void 0 ? void 0 : response.message) || '获取资源占用详情失败');
|
|
2542
2636
|
case 11:
|
|
2543
|
-
return
|
|
2637
|
+
return _context36.abrupt("return", (_response$data$occupy = response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.occupy_details) !== null && _response$data$occupy !== void 0 ? _response$data$occupy : []);
|
|
2544
2638
|
case 12:
|
|
2545
2639
|
case "end":
|
|
2546
|
-
return
|
|
2640
|
+
return _context36.stop();
|
|
2547
2641
|
}
|
|
2548
|
-
},
|
|
2642
|
+
}, _callee36, this);
|
|
2549
2643
|
}));
|
|
2550
|
-
function
|
|
2551
|
-
return
|
|
2644
|
+
function fetchResourceOccupyDetailsByResourceId(_x19) {
|
|
2645
|
+
return _fetchResourceOccupyDetailsByResourceId.apply(this, arguments);
|
|
2646
|
+
}
|
|
2647
|
+
return fetchResourceOccupyDetailsByResourceId;
|
|
2648
|
+
}()
|
|
2649
|
+
}, {
|
|
2650
|
+
key: "resolveAdditionalOrderFromOccupyDetail",
|
|
2651
|
+
value: function resolveAdditionalOrderFromOccupyDetail(detail, resourceSelectType, allowAddItems) {
|
|
2652
|
+
var currentOrderId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.order_id);
|
|
2653
|
+
if (currentOrderId) {
|
|
2654
|
+
return {
|
|
2655
|
+
matched: true,
|
|
2656
|
+
order_id: currentOrderId
|
|
2657
|
+
};
|
|
2658
|
+
}
|
|
2659
|
+
var orderListIds = (Array.isArray(detail === null || detail === void 0 ? void 0 : detail.order_list) ? (detail === null || detail === void 0 ? void 0 : detail.order_list) || [] : []).map(function (order) {
|
|
2660
|
+
return toPositiveString(order === null || order === void 0 ? void 0 : order.id);
|
|
2661
|
+
}).filter(Boolean);
|
|
2662
|
+
if (resourceSelectType !== 'single') {
|
|
2663
|
+
return {
|
|
2664
|
+
matched: false,
|
|
2665
|
+
reason: 'no_order'
|
|
2666
|
+
};
|
|
2667
|
+
}
|
|
2668
|
+
if (!orderListIds.length) {
|
|
2669
|
+
return {
|
|
2670
|
+
matched: false,
|
|
2671
|
+
reason: 'no_order'
|
|
2672
|
+
};
|
|
2673
|
+
}
|
|
2674
|
+
if (!allowAddItems) {
|
|
2675
|
+
return {
|
|
2676
|
+
matched: false,
|
|
2677
|
+
reason: 'add_items_disabled'
|
|
2678
|
+
};
|
|
2552
2679
|
}
|
|
2553
|
-
|
|
2554
|
-
|
|
2680
|
+
if (orderListIds.length === 1) {
|
|
2681
|
+
return {
|
|
2682
|
+
matched: true,
|
|
2683
|
+
order_id: orderListIds[0]
|
|
2684
|
+
};
|
|
2685
|
+
}
|
|
2686
|
+
if (orderListIds.length > 1) {
|
|
2687
|
+
return {
|
|
2688
|
+
matched: false,
|
|
2689
|
+
reason: 'multiple_orders'
|
|
2690
|
+
};
|
|
2691
|
+
}
|
|
2692
|
+
return {
|
|
2693
|
+
matched: false,
|
|
2694
|
+
reason: 'no_order'
|
|
2695
|
+
};
|
|
2696
|
+
}
|
|
2697
|
+
|
|
2698
|
+
// 检测当前链接是否可用
|
|
2555
2699
|
// 通过 resource_id + 店铺配置
|
|
2556
2700
|
// hasOrderId 表示 url 上是否有 orderid,如果是的话,后续的流程会走加单
|
|
2557
2701
|
}, {
|
|
2558
2702
|
key: "checkResourceAvailable",
|
|
2559
2703
|
value: function () {
|
|
2560
|
-
var _checkResourceAvailable = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2561
|
-
var
|
|
2562
|
-
|
|
2563
|
-
|
|
2704
|
+
var _checkResourceAvailable = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(resourceId) {
|
|
2705
|
+
var hasOrderId,
|
|
2706
|
+
normalizedResourceId,
|
|
2707
|
+
_this$otherParams$bus,
|
|
2708
|
+
_this$otherParams15,
|
|
2709
|
+
_this$otherParams$cha,
|
|
2710
|
+
_this$otherParams16,
|
|
2711
|
+
_this$otherParams17,
|
|
2712
|
+
_this$otherParams17$g,
|
|
2713
|
+
_occupyDetails$,
|
|
2714
|
+
_occupyDetail$form_re,
|
|
2715
|
+
_occupyDetail$form_re2,
|
|
2716
|
+
_this$store$order6,
|
|
2717
|
+
_this$store$order7,
|
|
2718
|
+
_this$store$order7$ge,
|
|
2719
|
+
_this$otherParams18,
|
|
2720
|
+
_this$store$resource3,
|
|
2721
|
+
_this$store$resource4,
|
|
2722
|
+
businessCode,
|
|
2723
|
+
channel,
|
|
2724
|
+
openDataTarget,
|
|
2725
|
+
openData,
|
|
2726
|
+
dineInConfig,
|
|
2727
|
+
closedBehaviorValue,
|
|
2728
|
+
closedMessage,
|
|
2729
|
+
basicUnavailableMessage,
|
|
2730
|
+
pauseMessage,
|
|
2731
|
+
makeShopClosed,
|
|
2732
|
+
operatingHourIds,
|
|
2733
|
+
outsideOperatingHours,
|
|
2734
|
+
scheduleList,
|
|
2735
|
+
now,
|
|
2736
|
+
tempOrder,
|
|
2737
|
+
reservationLinkIds,
|
|
2738
|
+
pendingRequestEntryPax,
|
|
2739
|
+
pendingRequestPaxMin,
|
|
2740
|
+
pendingRequestPaxMax,
|
|
2741
|
+
reservationProductList,
|
|
2742
|
+
scheduleDate,
|
|
2743
|
+
scheduleDatetime,
|
|
2744
|
+
loaded,
|
|
2745
|
+
matchedRuleProduct,
|
|
2746
|
+
ruleProductsForResource,
|
|
2747
|
+
occupancyMinutes,
|
|
2748
|
+
paxBounds,
|
|
2749
|
+
error,
|
|
2750
|
+
_occupancyMinutes,
|
|
2751
|
+
_paxBounds,
|
|
2752
|
+
_error,
|
|
2753
|
+
occupyDetails,
|
|
2754
|
+
occupyDetail,
|
|
2755
|
+
resourceSelectType,
|
|
2756
|
+
allowAddItems,
|
|
2757
|
+
additionalOrderResult,
|
|
2758
|
+
_occupyDetail$order_l,
|
|
2759
|
+
multipleOrdersState,
|
|
2760
|
+
_availabilityInfo,
|
|
2761
|
+
resourceState,
|
|
2762
|
+
additionalOrderId,
|
|
2763
|
+
availabilityInfo,
|
|
2764
|
+
isAdditionalOrderMode,
|
|
2765
|
+
lastOrderInfo,
|
|
2766
|
+
historicalItems,
|
|
2767
|
+
_args37 = arguments;
|
|
2768
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
2769
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
2564
2770
|
case 0:
|
|
2771
|
+
hasOrderId = _args37.length > 1 && _args37[1] !== undefined ? _args37[1] : false;
|
|
2772
|
+
normalizedResourceId = String(resourceId !== null && resourceId !== void 0 ? resourceId : '').trim();
|
|
2565
2773
|
this.logMethodStart('checkResourceAvailable', {
|
|
2566
|
-
resourceId:
|
|
2774
|
+
resourceId: normalizedResourceId
|
|
2567
2775
|
});
|
|
2568
|
-
|
|
2569
|
-
businessCode = String((_this$otherParams$bus = (_this$
|
|
2570
|
-
channel = String((_this$otherParams$cha = (_this$
|
|
2776
|
+
_context37.prev = 3;
|
|
2777
|
+
businessCode = String((_this$otherParams$bus = (_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.businessCode) !== null && _this$otherParams$bus !== void 0 ? _this$otherParams$bus : '').trim();
|
|
2778
|
+
channel = String((_this$otherParams$cha = (_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.channel) !== null && _this$otherParams$cha !== void 0 ? _this$otherParams$cha : '').trim();
|
|
2571
2779
|
openDataTarget = businessCode && channel ? "".concat(businessCode, "+").concat(channel) : 'dine_in+scan_to_order';
|
|
2572
|
-
|
|
2573
|
-
return (_this$
|
|
2780
|
+
_context37.next = 9;
|
|
2781
|
+
return (_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 || (_this$otherParams17$g = _this$otherParams17.getOpenData) === null || _this$otherParams17$g === void 0 ? void 0 : _this$otherParams17$g.call(_this$otherParams17, {
|
|
2574
2782
|
scope: 'board',
|
|
2575
2783
|
target: openDataTarget,
|
|
2576
2784
|
section_code: ['basic', 'fulfillment', 'reservation', 'sale', 'menu', 'availability', 'workflow']
|
|
2577
2785
|
});
|
|
2578
|
-
case
|
|
2579
|
-
openData =
|
|
2786
|
+
case 9:
|
|
2787
|
+
openData = _context37.sent;
|
|
2580
2788
|
if (!((openData === null || openData === void 0 ? void 0 : openData.status) === false)) {
|
|
2581
|
-
|
|
2789
|
+
_context37.next = 12;
|
|
2582
2790
|
break;
|
|
2583
2791
|
}
|
|
2584
2792
|
throw new Error((openData === null || openData === void 0 ? void 0 : openData.message) || '获取店铺配置失败');
|
|
2585
|
-
case
|
|
2793
|
+
case 12:
|
|
2586
2794
|
dineInConfig = (openData === null || openData === void 0 ? void 0 : openData.data) || {};
|
|
2587
2795
|
this.otherParams.dineInConfig = dineInConfig;
|
|
2588
|
-
|
|
2796
|
+
_context37.next = 16;
|
|
2589
2797
|
return this.syncItemRuleConfigsFromDineInConfig(dineInConfig);
|
|
2590
|
-
case
|
|
2798
|
+
case 16:
|
|
2591
2799
|
closedBehaviorValue = dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.closed_behavior'];
|
|
2592
2800
|
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']);
|
|
2593
2801
|
basicUnavailableMessage = (dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['basic.unavailable_message']) || closedMessage;
|
|
@@ -2604,21 +2812,21 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2604
2812
|
};
|
|
2605
2813
|
}; // 1. 基础开关 basic.enable 关闭
|
|
2606
2814
|
if (!((dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['basic.enable']) === false)) {
|
|
2607
|
-
|
|
2815
|
+
_context37.next = 23;
|
|
2608
2816
|
break;
|
|
2609
2817
|
}
|
|
2610
|
-
return
|
|
2611
|
-
case
|
|
2818
|
+
return _context37.abrupt("return", makeShopClosed(basicUnavailableMessage));
|
|
2819
|
+
case 23:
|
|
2612
2820
|
if (!toBoolean(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.paused'])) {
|
|
2613
|
-
|
|
2821
|
+
_context37.next = 26;
|
|
2614
2822
|
break;
|
|
2615
2823
|
}
|
|
2616
2824
|
if (!((dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.pause_behavior']) === 'hide_all')) {
|
|
2617
|
-
|
|
2825
|
+
_context37.next = 26;
|
|
2618
2826
|
break;
|
|
2619
2827
|
}
|
|
2620
|
-
return
|
|
2621
|
-
case
|
|
2828
|
+
return _context37.abrupt("return", makeShopClosed(pauseMessage));
|
|
2829
|
+
case 26:
|
|
2622
2830
|
// 3. 营业时间 operating_hours 闸门
|
|
2623
2831
|
operatingHourIds = Array.isArray(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.operating_hours']) ? dineInConfig['availability.operating_hours'].map(function (id) {
|
|
2624
2832
|
return Number(id);
|
|
@@ -2634,27 +2842,33 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2634
2842
|
}
|
|
2635
2843
|
}
|
|
2636
2844
|
if (!(outsideOperatingHours && closedBehaviorValue !== 'show_menu_disabled')) {
|
|
2637
|
-
|
|
2845
|
+
_context37.next = 31;
|
|
2638
2846
|
break;
|
|
2639
2847
|
}
|
|
2640
|
-
return
|
|
2641
|
-
case
|
|
2848
|
+
return _context37.abrupt("return", makeShopClosed(closedMessage, closedBehaviorValue));
|
|
2849
|
+
case 31:
|
|
2642
2850
|
// Step1: 先加载预约规则商品,拿到 enabledReservationRuleProducts 与容量附加信息
|
|
2643
2851
|
// (resourceSelectType 需要基于这些商品 + 占用接口的 form_id 计算,故必须前置)
|
|
2644
|
-
tempOrder = this.
|
|
2852
|
+
tempOrder = this.ensureScanOrderTempOrder();
|
|
2645
2853
|
reservationLinkIds = collectLinkProductIdsFromReservationRules(dineInConfig['fulfillment.enabled_resource_rules']);
|
|
2646
|
-
if (!(reservationLinkIds.length === 0)) {
|
|
2647
|
-
|
|
2854
|
+
if (!(!normalizedResourceId || reservationLinkIds.length === 0)) {
|
|
2855
|
+
_context37.next = 37;
|
|
2648
2856
|
break;
|
|
2649
2857
|
}
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2858
|
+
_context37.next = 36;
|
|
2859
|
+
return this.prepareRetailAvailability({
|
|
2860
|
+
tempOrder: tempOrder,
|
|
2861
|
+
hasOrderId: hasOrderId,
|
|
2862
|
+
resourceId: normalizedResourceId,
|
|
2863
|
+
reason: !normalizedResourceId ? 'missing_resource_id' : 'missing_enabled_resource_rules'
|
|
2864
|
+
});
|
|
2865
|
+
case 36:
|
|
2866
|
+
return _context37.abrupt("return", _context37.sent);
|
|
2867
|
+
case 37:
|
|
2654
2868
|
tempOrder.metadata = _objectSpread({}, tempOrder.metadata || {});
|
|
2655
2869
|
delete tempOrder.metadata.table_occupancy_duration;
|
|
2656
2870
|
reservationProductList = new ProductList("".concat(this.name, "_reservationEnabledRules"), this.defaultVersion);
|
|
2657
|
-
|
|
2871
|
+
_context37.next = 42;
|
|
2658
2872
|
return reservationProductList.initialize(this.core, {
|
|
2659
2873
|
store: {
|
|
2660
2874
|
list: [],
|
|
@@ -2666,27 +2880,29 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2666
2880
|
cacheId: this.cacheId
|
|
2667
2881
|
})
|
|
2668
2882
|
});
|
|
2669
|
-
case
|
|
2883
|
+
case 42:
|
|
2670
2884
|
scheduleDate = dayjs().format('YYYY-MM-DD');
|
|
2671
2885
|
scheduleDatetime = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
2672
|
-
|
|
2886
|
+
_context37.next = 46;
|
|
2673
2887
|
return reservationProductList.loadProducts({
|
|
2674
2888
|
product_ids: reservationLinkIds,
|
|
2675
2889
|
schedule_date: scheduleDate,
|
|
2676
2890
|
schedule_datetime: scheduleDatetime,
|
|
2677
2891
|
cacheId: this.cacheId
|
|
2678
2892
|
});
|
|
2679
|
-
case
|
|
2680
|
-
loaded =
|
|
2893
|
+
case 46:
|
|
2894
|
+
loaded = _context37.sent;
|
|
2681
2895
|
if (Array.isArray(loaded)) {
|
|
2682
|
-
|
|
2683
|
-
|
|
2896
|
+
matchedRuleProduct = findReservationRuleProductByResourceId(loaded, normalizedResourceId);
|
|
2897
|
+
ruleProductsForResource = matchedRuleProduct ? [matchedRuleProduct] : [];
|
|
2898
|
+
this.enabledReservationRuleProducts = ruleProductsForResource;
|
|
2899
|
+
occupancyMinutes = pickFirstDurationMinutesFromProducts(ruleProductsForResource);
|
|
2684
2900
|
if (occupancyMinutes !== undefined) {
|
|
2685
2901
|
tempOrder.metadata.table_occupancy_duration = occupancyMinutes;
|
|
2686
2902
|
}
|
|
2687
|
-
if (hasCustomCapacityProduct(
|
|
2903
|
+
if (hasCustomCapacityProduct(ruleProductsForResource)) {
|
|
2688
2904
|
pendingRequestEntryPax = 1;
|
|
2689
|
-
paxBounds = pickFirstCustomCapacityPaxBounds(
|
|
2905
|
+
paxBounds = pickFirstCustomCapacityPaxBounds(ruleProductsForResource);
|
|
2690
2906
|
if ((paxBounds === null || paxBounds === void 0 ? void 0 : paxBounds.min) !== undefined) pendingRequestPaxMin = paxBounds.min;
|
|
2691
2907
|
if ((paxBounds === null || paxBounds === void 0 ? void 0 : paxBounds.max) !== undefined) pendingRequestPaxMax = paxBounds.max;
|
|
2692
2908
|
}
|
|
@@ -2694,22 +2910,83 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2694
2910
|
this.enabledReservationRuleProducts = [];
|
|
2695
2911
|
error = loaded instanceof Error ? loaded : new Error('预约规则商品列表接口返回异常');
|
|
2696
2912
|
this.logMethodError('loadReservationRuleProducts', error, {
|
|
2697
|
-
resourceId:
|
|
2913
|
+
resourceId: normalizedResourceId,
|
|
2698
2914
|
reservationLinkIds: reservationLinkIds,
|
|
2699
2915
|
scheduleDate: scheduleDate,
|
|
2700
2916
|
scheduleDatetime: scheduleDatetime,
|
|
2701
2917
|
cacheId: this.cacheId
|
|
2702
2918
|
});
|
|
2919
|
+
if (Array.isArray(loaded)) {
|
|
2920
|
+
this.enabledReservationRuleProducts = loaded;
|
|
2921
|
+
_occupancyMinutes = pickFirstDurationMinutesFromProducts(loaded);
|
|
2922
|
+
if (_occupancyMinutes !== undefined) {
|
|
2923
|
+
tempOrder.metadata.table_occupancy_duration = _occupancyMinutes;
|
|
2924
|
+
}
|
|
2925
|
+
if (hasCustomCapacityProduct(loaded)) {
|
|
2926
|
+
pendingRequestEntryPax = 1;
|
|
2927
|
+
_paxBounds = pickFirstCustomCapacityPaxBounds(loaded);
|
|
2928
|
+
if ((_paxBounds === null || _paxBounds === void 0 ? void 0 : _paxBounds.min) !== undefined) pendingRequestPaxMin = _paxBounds.min;
|
|
2929
|
+
if ((_paxBounds === null || _paxBounds === void 0 ? void 0 : _paxBounds.max) !== undefined) pendingRequestPaxMax = _paxBounds.max;
|
|
2930
|
+
}
|
|
2931
|
+
} else {
|
|
2932
|
+
this.enabledReservationRuleProducts = [];
|
|
2933
|
+
_error = loaded instanceof Error ? loaded : new Error('预约规则商品列表接口返回异常');
|
|
2934
|
+
this.logMethodError('loadReservationRuleProducts', _error, {
|
|
2935
|
+
resourceId: resourceId,
|
|
2936
|
+
reservationLinkIds: reservationLinkIds,
|
|
2937
|
+
scheduleDate: scheduleDate,
|
|
2938
|
+
scheduleDatetime: scheduleDatetime,
|
|
2939
|
+
cacheId: this.cacheId
|
|
2940
|
+
});
|
|
2941
|
+
}
|
|
2703
2942
|
}
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2943
|
+
|
|
2944
|
+
// Step2: 请求新的资源占用详情接口。occupy_details 第一维是资源,不是订单。
|
|
2945
|
+
_context37.next = 50;
|
|
2946
|
+
return this.fetchResourceOccupyDetailsByResourceId(normalizedResourceId);
|
|
2947
|
+
case 50:
|
|
2948
|
+
occupyDetails = _context37.sent;
|
|
2949
|
+
occupyDetail = (_occupyDetails$ = occupyDetails[0]) !== null && _occupyDetails$ !== void 0 ? _occupyDetails$ : null; // Step3: 结合预约规则商品的 product_resource.resources 与占用接口返回的 form_id,
|
|
2710
2950
|
// 计算当前桌台的 resourceSelectType(single/multiple/capacity)
|
|
2711
|
-
resourceSelectType = this.resolveResourceSelectType(toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_id));
|
|
2951
|
+
resourceSelectType = this.resolveResourceSelectType(toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_id));
|
|
2952
|
+
allowAddItems = toBoolean(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['sale.allow_add_items']);
|
|
2953
|
+
additionalOrderResult = this.resolveAdditionalOrderFromOccupyDetail(occupyDetail, resourceSelectType, allowAddItems);
|
|
2954
|
+
if (!(additionalOrderResult.reason === 'multiple_orders')) {
|
|
2955
|
+
_context37.next = 61;
|
|
2956
|
+
break;
|
|
2957
|
+
}
|
|
2958
|
+
multipleOrdersState = _objectSpread(_objectSpread({}, this.normalizeResourceState(occupyDetail, resourceSelectType, hasOrderId)), {}, {
|
|
2959
|
+
mode: 'multiple_orders'
|
|
2960
|
+
});
|
|
2961
|
+
this.store.resource = multipleOrdersState;
|
|
2962
|
+
_availabilityInfo = {
|
|
2963
|
+
mode: 'multiple_orders',
|
|
2964
|
+
deskmate_valid: multipleOrdersState.deskmate_valid,
|
|
2965
|
+
relation_id: multipleOrdersState.relationId,
|
|
2966
|
+
table_form_id: multipleOrdersState.tableFormId,
|
|
2967
|
+
table_form_record: multipleOrdersState.table_form_record
|
|
2968
|
+
};
|
|
2969
|
+
this.logMethodSuccess('checkResourceAvailable', {
|
|
2970
|
+
resourceId: normalizedResourceId,
|
|
2971
|
+
mode: _availabilityInfo.mode,
|
|
2972
|
+
orderListCount: (occupyDetail === null || occupyDetail === void 0 || (_occupyDetail$order_l = occupyDetail.order_list) === null || _occupyDetail$order_l === void 0 ? void 0 : _occupyDetail$order_l.length) || 0,
|
|
2973
|
+
resourceSelectType: resourceSelectType
|
|
2974
|
+
});
|
|
2975
|
+
return _context37.abrupt("return", _availabilityInfo);
|
|
2976
|
+
case 61:
|
|
2977
|
+
// Step4: 用 occupyDetail + resourceSelectType 规整为 resourceState
|
|
2712
2978
|
resourceState = this.normalizeResourceState(occupyDetail, resourceSelectType, hasOrderId);
|
|
2979
|
+
additionalOrderId = additionalOrderResult.order_id;
|
|
2980
|
+
if (additionalOrderId) {
|
|
2981
|
+
resourceState.mode = 'additional_order';
|
|
2982
|
+
resourceState.order_id = additionalOrderId;
|
|
2983
|
+
} else if (additionalOrderResult.reason === 'add_items_disabled') {
|
|
2984
|
+
resourceState.mode = 'resource_busy';
|
|
2985
|
+
resourceState.order_id = '0';
|
|
2986
|
+
} else if (resourceSelectType === 'multiple' && resourceState.isFull) {
|
|
2987
|
+
resourceState.mode = 'resource_busy';
|
|
2988
|
+
resourceState.order_id = '0';
|
|
2989
|
+
}
|
|
2713
2990
|
this.store.resource = resourceState;
|
|
2714
2991
|
|
|
2715
2992
|
// Step5: 把预约规则商品阶段暂存的 requestEntryPax 等注入 store.resource
|
|
@@ -2738,47 +3015,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2738
3015
|
} : {}), this.store.resource.requestPaxMax !== undefined ? {
|
|
2739
3016
|
requestPaxMax: this.store.resource.requestPaxMax
|
|
2740
3017
|
} : {});
|
|
2741
|
-
|
|
2742
|
-
tempOrder.table_form_id = resourceState.tableFormId;
|
|
2743
|
-
tempOrder.resource_id = resourceId;
|
|
2744
|
-
(_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 || _this$store$order5.persistTempOrder();
|
|
3018
|
+
(_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 || _this$store$order6.persistTempOrder();
|
|
2745
3019
|
|
|
2746
3020
|
// 空闲状态下自动准备本地临时订单,供后续“购物车式”商品操作使用
|
|
2747
3021
|
if (!(availabilityInfo.mode === 'idle')) {
|
|
2748
|
-
|
|
3022
|
+
_context37.next = 73;
|
|
2749
3023
|
break;
|
|
2750
3024
|
}
|
|
2751
|
-
|
|
3025
|
+
_context37.next = 73;
|
|
2752
3026
|
return this.addNewOrder();
|
|
2753
|
-
case
|
|
2754
|
-
// 如果是加单模式,tempOrder
|
|
2755
|
-
if (
|
|
2756
|
-
tempOrder.order_id =
|
|
2757
|
-
}
|
|
2758
|
-
if (!tempOrder.order_id) {
|
|
2759
|
-
_context36.next = 72;
|
|
2760
|
-
break;
|
|
2761
|
-
}
|
|
2762
|
-
_context36.next = 67;
|
|
2763
|
-
return (_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 ? void 0 : _this$store$order6.getSalesOrderByLookup({
|
|
2764
|
-
lookup: tempOrder.order_id
|
|
2765
|
-
});
|
|
2766
|
-
case 67:
|
|
2767
|
-
res = _context36.sent;
|
|
2768
|
-
// 找到下单的时候输入的 entryPaxNumber
|
|
2769
|
-
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) {
|
|
2770
|
-
var _p$metadata;
|
|
2771
|
-
return (_p$metadata = p.metadata) === null || _p$metadata === void 0 ? void 0 : _p$metadata.collect_pax;
|
|
2772
|
-
})) === null || _res$data === void 0 || (_res$data = _res$data.metadata) === null || _res$data === void 0 ? void 0 : _res$data.collect_pax;
|
|
2773
|
-
if (!entryPaxNumber) {
|
|
2774
|
-
_context36.next = 72;
|
|
2775
|
-
break;
|
|
3027
|
+
case 73:
|
|
3028
|
+
isAdditionalOrderMode = availabilityInfo.mode === 'additional_order' || availabilityInfo.mode === 'additional_order_with_code'; // 如果是加单模式,tempOrder 里需要记录目标订单 id,提交的时候走加单接口
|
|
3029
|
+
if (isAdditionalOrderMode) {
|
|
3030
|
+
tempOrder.order_id = additionalOrderId;
|
|
2776
3031
|
}
|
|
2777
|
-
_context36.next = 72;
|
|
2778
|
-
return this.setEntryPaxNumber(entryPaxNumber);
|
|
2779
|
-
case 72:
|
|
2780
3032
|
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);
|
|
2781
|
-
historicalItems =
|
|
3033
|
+
historicalItems = isAdditionalOrderMode && Array.isArray(lastOrderInfo === null || lastOrderInfo === void 0 ? void 0 : lastOrderInfo.products) ? lastOrderInfo.products.reduce(function (acc, p) {
|
|
2782
3034
|
if (typeof (p === null || p === void 0 ? void 0 : p.product_id) !== 'number') return acc;
|
|
2783
3035
|
acc.push(_objectSpread({
|
|
2784
3036
|
product_id: p.product_id,
|
|
@@ -2788,13 +3040,13 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2788
3040
|
} : {}));
|
|
2789
3041
|
return acc;
|
|
2790
3042
|
}, []) : []; // pax 由 setEntryPaxNumber 负责写入 itemRuleRuntimeConfig.pax
|
|
2791
|
-
|
|
3043
|
+
_context37.next = 79;
|
|
2792
3044
|
return this.setItemRuleRuntimeConfig({
|
|
2793
|
-
serviceType: (_this$
|
|
2794
|
-
submissionIndex:
|
|
3045
|
+
serviceType: (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.businessCode,
|
|
3046
|
+
submissionIndex: isAdditionalOrderMode ? 1 : 0,
|
|
2795
3047
|
historicalItems: historicalItems
|
|
2796
3048
|
});
|
|
2797
|
-
case
|
|
3049
|
+
case 79:
|
|
2798
3050
|
// operating_hours 超出营业时段 + closed_behavior=show_menu_disabled:
|
|
2799
3051
|
// 允许浏览商品但 UI 层需拦截“下一步”,这里覆盖最终 mode 并回传错误提示
|
|
2800
3052
|
if (outsideOperatingHours && closedBehaviorValue === 'show_menu_disabled') {
|
|
@@ -2803,44 +3055,90 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2803
3055
|
availabilityInfo.closed_behavior = closedBehaviorValue;
|
|
2804
3056
|
}
|
|
2805
3057
|
this.logMethodSuccess('checkResourceAvailable', {
|
|
2806
|
-
resourceId:
|
|
3058
|
+
resourceId: normalizedResourceId,
|
|
2807
3059
|
mode: availabilityInfo.mode,
|
|
2808
3060
|
orderId: availabilityInfo.order_id,
|
|
2809
3061
|
relationId: availabilityInfo.relation_id,
|
|
2810
3062
|
tableFormId: availabilityInfo.table_form_id,
|
|
2811
|
-
persistedRelationId:
|
|
2812
|
-
persistedResourceId:
|
|
3063
|
+
persistedRelationId: (_this$store$resource3 = this.store.resource) === null || _this$store$resource3 === void 0 ? void 0 : _this$store$resource3.relationId,
|
|
3064
|
+
persistedResourceId: (_this$store$resource4 = this.store.resource) === null || _this$store$resource4 === void 0 ? void 0 : _this$store$resource4.relationId,
|
|
2813
3065
|
deskmateValid: availabilityInfo.deskmate_valid,
|
|
2814
3066
|
resourceSelectType: resourceState.resourceSelectType,
|
|
2815
3067
|
isExclusive: resourceState.isExclusive,
|
|
2816
3068
|
isFull: resourceState.isFull
|
|
2817
3069
|
});
|
|
2818
|
-
return
|
|
2819
|
-
case
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
this.logMethodError('checkResourceAvailable',
|
|
2823
|
-
resourceId:
|
|
3070
|
+
return _context37.abrupt("return", availabilityInfo);
|
|
3071
|
+
case 84:
|
|
3072
|
+
_context37.prev = 84;
|
|
3073
|
+
_context37.t0 = _context37["catch"](3);
|
|
3074
|
+
this.logMethodError('checkResourceAvailable', _context37.t0.message, {
|
|
3075
|
+
resourceId: normalizedResourceId
|
|
2824
3076
|
});
|
|
2825
|
-
throw
|
|
2826
|
-
case
|
|
3077
|
+
throw _context37.t0;
|
|
3078
|
+
case 88:
|
|
2827
3079
|
case "end":
|
|
2828
|
-
return
|
|
3080
|
+
return _context37.stop();
|
|
2829
3081
|
}
|
|
2830
|
-
},
|
|
3082
|
+
}, _callee37, this, [[3, 84]]);
|
|
2831
3083
|
}));
|
|
2832
|
-
function checkResourceAvailable(
|
|
3084
|
+
function checkResourceAvailable(_x20) {
|
|
2833
3085
|
return _checkResourceAvailable.apply(this, arguments);
|
|
2834
3086
|
}
|
|
2835
3087
|
return checkResourceAvailable;
|
|
3088
|
+
}() // 恢复之前订单的数据,读取 entrypax
|
|
3089
|
+
}, {
|
|
3090
|
+
key: "restorePreviousOrderData",
|
|
3091
|
+
value: function () {
|
|
3092
|
+
var _restorePreviousOrderData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
|
|
3093
|
+
var orderModule, tempOrder, _res$data, res, entryPaxNumber;
|
|
3094
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
3095
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
3096
|
+
case 0:
|
|
3097
|
+
orderModule = this.store.order;
|
|
3098
|
+
if (orderModule) {
|
|
3099
|
+
_context38.next = 3;
|
|
3100
|
+
break;
|
|
3101
|
+
}
|
|
3102
|
+
return _context38.abrupt("return");
|
|
3103
|
+
case 3:
|
|
3104
|
+
tempOrder = orderModule.ensureTempOrder();
|
|
3105
|
+
if (!tempOrder.order_id) {
|
|
3106
|
+
_context38.next = 12;
|
|
3107
|
+
break;
|
|
3108
|
+
}
|
|
3109
|
+
_context38.next = 7;
|
|
3110
|
+
return orderModule.getOrderInfo(tempOrder.order_id);
|
|
3111
|
+
case 7:
|
|
3112
|
+
res = _context38.sent;
|
|
3113
|
+
// 找到下单的时候输入的 entryPaxNumber
|
|
3114
|
+
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) {
|
|
3115
|
+
var _p$metadata;
|
|
3116
|
+
return (_p$metadata = p.metadata) === null || _p$metadata === void 0 ? void 0 : _p$metadata.collect_pax;
|
|
3117
|
+
})) === null || _res$data === void 0 || (_res$data = _res$data.metadata) === null || _res$data === void 0 ? void 0 : _res$data.collect_pax;
|
|
3118
|
+
if (!entryPaxNumber) {
|
|
3119
|
+
_context38.next = 12;
|
|
3120
|
+
break;
|
|
3121
|
+
}
|
|
3122
|
+
_context38.next = 12;
|
|
3123
|
+
return this.setEntryPaxNumber(entryPaxNumber);
|
|
3124
|
+
case 12:
|
|
3125
|
+
case "end":
|
|
3126
|
+
return _context38.stop();
|
|
3127
|
+
}
|
|
3128
|
+
}, _callee38, this);
|
|
3129
|
+
}));
|
|
3130
|
+
function restorePreviousOrderData() {
|
|
3131
|
+
return _restorePreviousOrderData.apply(this, arguments);
|
|
3132
|
+
}
|
|
3133
|
+
return restorePreviousOrderData;
|
|
2836
3134
|
}() // 如果是加单的情况,提供返回当前订单相关信息的能力
|
|
2837
3135
|
}, {
|
|
2838
3136
|
key: "getAdditionalOrderInfo",
|
|
2839
3137
|
value: function () {
|
|
2840
|
-
var _getAdditionalOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3138
|
+
var _getAdditionalOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
|
|
2841
3139
|
var result;
|
|
2842
|
-
return _regeneratorRuntime().wrap(function
|
|
2843
|
-
while (1) switch (
|
|
3140
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
3141
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
2844
3142
|
case 0:
|
|
2845
3143
|
this.logMethodStart('getAdditionalOrderInfo');
|
|
2846
3144
|
result = {
|
|
@@ -2854,12 +3152,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2854
3152
|
orderId: result.orderId,
|
|
2855
3153
|
orderStatus: result.orderStatus
|
|
2856
3154
|
});
|
|
2857
|
-
return
|
|
3155
|
+
return _context39.abrupt("return", result);
|
|
2858
3156
|
case 4:
|
|
2859
3157
|
case "end":
|
|
2860
|
-
return
|
|
3158
|
+
return _context39.stop();
|
|
2861
3159
|
}
|
|
2862
|
-
},
|
|
3160
|
+
}, _callee39, this);
|
|
2863
3161
|
}));
|
|
2864
3162
|
function getAdditionalOrderInfo() {
|
|
2865
3163
|
return _getAdditionalOrderInfo.apply(this, arguments);
|
|
@@ -2869,33 +3167,34 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2869
3167
|
}, {
|
|
2870
3168
|
key: "getProductList",
|
|
2871
3169
|
value: function () {
|
|
2872
|
-
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2873
|
-
var _this$
|
|
2874
|
-
var menu_list_ids, res, productList, formattedRes;
|
|
2875
|
-
return _regeneratorRuntime().wrap(function
|
|
2876
|
-
while (1) switch (
|
|
3170
|
+
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40() {
|
|
3171
|
+
var _this$otherParams19;
|
|
3172
|
+
var associatedMenus, menu_list_ids, res, productList, formattedRes;
|
|
3173
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
3174
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
2877
3175
|
case 0:
|
|
2878
3176
|
this.logMethodStart('getProductList');
|
|
2879
3177
|
// 可以直接通过配置里的 menu 读取
|
|
2880
|
-
|
|
3178
|
+
associatedMenus = (_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 || (_this$otherParams19 = _this$otherParams19.dineInConfig) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19['menu.associated_menus'];
|
|
3179
|
+
menu_list_ids = associatedMenus.map(function (n) {
|
|
2881
3180
|
return Number(n.value);
|
|
2882
|
-
})
|
|
2883
|
-
|
|
3181
|
+
}) || [];
|
|
3182
|
+
_context40.prev = 3;
|
|
2884
3183
|
if (this.store.products) {
|
|
2885
|
-
|
|
3184
|
+
_context40.next = 6;
|
|
2886
3185
|
break;
|
|
2887
3186
|
}
|
|
2888
3187
|
throw new Error('products 模块未初始化');
|
|
2889
|
-
case
|
|
2890
|
-
|
|
3188
|
+
case 6:
|
|
3189
|
+
_context40.next = 8;
|
|
2891
3190
|
return this.store.products.loadProducts({
|
|
2892
3191
|
menu_list_ids: menu_list_ids,
|
|
2893
3192
|
cacheId: this.cacheId,
|
|
2894
3193
|
schedule_date: dayjs().format('YYYY-MM-DD'),
|
|
2895
3194
|
schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
2896
3195
|
});
|
|
2897
|
-
case
|
|
2898
|
-
res =
|
|
3196
|
+
case 8:
|
|
3197
|
+
res = _context40.sent;
|
|
2899
3198
|
productList = this.assertProductListLoaded('getProductList', res, {
|
|
2900
3199
|
menu_list_ids: menu_list_ids,
|
|
2901
3200
|
cacheId: this.cacheId
|
|
@@ -2904,22 +3203,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2904
3203
|
this.logMethodSuccess('getProductList', {
|
|
2905
3204
|
menuCount: menu_list_ids.length
|
|
2906
3205
|
});
|
|
2907
|
-
return
|
|
2908
|
-
case
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
if (!(
|
|
2912
|
-
this.logMethodError('getProductList',
|
|
3206
|
+
return _context40.abrupt("return", formattedRes);
|
|
3207
|
+
case 15:
|
|
3208
|
+
_context40.prev = 15;
|
|
3209
|
+
_context40.t0 = _context40["catch"](3);
|
|
3210
|
+
if (!(_context40.t0 !== null && _context40.t0 !== void 0 && _context40.t0.__scanOrderLogged)) {
|
|
3211
|
+
this.logMethodError('getProductList', _context40.t0, {
|
|
2913
3212
|
menu_list_ids: menu_list_ids,
|
|
2914
3213
|
cacheId: this.cacheId
|
|
2915
3214
|
});
|
|
2916
3215
|
}
|
|
2917
|
-
throw
|
|
2918
|
-
case
|
|
3216
|
+
throw _context40.t0;
|
|
3217
|
+
case 19:
|
|
2919
3218
|
case "end":
|
|
2920
|
-
return
|
|
3219
|
+
return _context40.stop();
|
|
2921
3220
|
}
|
|
2922
|
-
},
|
|
3221
|
+
}, _callee40, this, [[3, 15]]);
|
|
2923
3222
|
}));
|
|
2924
3223
|
function getProductList() {
|
|
2925
3224
|
return _getProductList.apply(this, arguments);
|
|
@@ -2934,15 +3233,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2934
3233
|
}, {
|
|
2935
3234
|
key: "setOtherParams",
|
|
2936
3235
|
value: function () {
|
|
2937
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3236
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
|
|
2938
3237
|
var _ref8,
|
|
2939
3238
|
_ref8$cover,
|
|
2940
3239
|
cover,
|
|
2941
|
-
|
|
2942
|
-
return _regeneratorRuntime().wrap(function
|
|
2943
|
-
while (1) switch (
|
|
3240
|
+
_args41 = arguments;
|
|
3241
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context41) {
|
|
3242
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
2944
3243
|
case 0:
|
|
2945
|
-
_ref8 =
|
|
3244
|
+
_ref8 = _args41.length > 1 && _args41[1] !== undefined ? _args41[1] : {}, _ref8$cover = _ref8.cover, cover = _ref8$cover === void 0 ? false : _ref8$cover;
|
|
2946
3245
|
if (cover) {
|
|
2947
3246
|
this.otherParams = params;
|
|
2948
3247
|
} else {
|
|
@@ -2950,11 +3249,11 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2950
3249
|
}
|
|
2951
3250
|
case 2:
|
|
2952
3251
|
case "end":
|
|
2953
|
-
return
|
|
3252
|
+
return _context41.stop();
|
|
2954
3253
|
}
|
|
2955
|
-
},
|
|
3254
|
+
}, _callee41, this);
|
|
2956
3255
|
}));
|
|
2957
|
-
function setOtherParams(
|
|
3256
|
+
function setOtherParams(_x21) {
|
|
2958
3257
|
return _setOtherParams.apply(this, arguments);
|
|
2959
3258
|
}
|
|
2960
3259
|
return setOtherParams;
|
|
@@ -3044,10 +3343,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3044
3343
|
}, {
|
|
3045
3344
|
key: "setEntryPaxNumber",
|
|
3046
3345
|
value: function () {
|
|
3047
|
-
var _setEntryPaxNumber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3346
|
+
var _setEntryPaxNumber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(number) {
|
|
3048
3347
|
var pax, t;
|
|
3049
|
-
return _regeneratorRuntime().wrap(function
|
|
3050
|
-
while (1) switch (
|
|
3348
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context42) {
|
|
3349
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
3051
3350
|
case 0:
|
|
3052
3351
|
pax = normalizeSubmitCollectPaxValue(number);
|
|
3053
3352
|
this.store.entryPaxNumber = pax;
|
|
@@ -3068,18 +3367,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3068
3367
|
}
|
|
3069
3368
|
});
|
|
3070
3369
|
this.itemRulePrefillApplied = false;
|
|
3071
|
-
|
|
3370
|
+
_context42.next = 7;
|
|
3072
3371
|
return this.refreshItemRuleQuantityLimits();
|
|
3073
3372
|
case 7:
|
|
3074
|
-
|
|
3373
|
+
_context42.next = 9;
|
|
3075
3374
|
return this.refreshCartValidationPassed();
|
|
3076
3375
|
case 9:
|
|
3077
3376
|
case "end":
|
|
3078
|
-
return
|
|
3377
|
+
return _context42.stop();
|
|
3079
3378
|
}
|
|
3080
|
-
},
|
|
3379
|
+
}, _callee42, this);
|
|
3081
3380
|
}));
|
|
3082
|
-
function setEntryPaxNumber(
|
|
3381
|
+
function setEntryPaxNumber(_x22) {
|
|
3083
3382
|
return _setEntryPaxNumber.apply(this, arguments);
|
|
3084
3383
|
}
|
|
3085
3384
|
return setEntryPaxNumber;
|
|
@@ -3089,15 +3388,119 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3089
3388
|
value: function getEntryPaxNumber() {
|
|
3090
3389
|
return this.store.entryPaxNumber;
|
|
3091
3390
|
}
|
|
3391
|
+
}, {
|
|
3392
|
+
key: "syncAdditionalOrderFromResource",
|
|
3393
|
+
value: function () {
|
|
3394
|
+
var _syncAdditionalOrderFromResource = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(resourceId) {
|
|
3395
|
+
var _ref9, _ref10, _ref11, _this$store$resource5, _this$store$resource6, _occupyDetails$2, _this$store$resource7, _this$otherParams20, _this$store$order8;
|
|
3396
|
+
var tempOrder, normalizedResourceId, _result, occupyDetails, occupyDetail, resourceSelectType, allowAddItems, result;
|
|
3397
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context43) {
|
|
3398
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
3399
|
+
case 0:
|
|
3400
|
+
if (this.store.order) {
|
|
3401
|
+
_context43.next = 2;
|
|
3402
|
+
break;
|
|
3403
|
+
}
|
|
3404
|
+
throw new Error('order 模块未初始化');
|
|
3405
|
+
case 2:
|
|
3406
|
+
tempOrder = this.store.order.ensureTempOrder();
|
|
3407
|
+
normalizedResourceId = String((_ref9 = (_ref10 = (_ref11 = resourceId !== null && resourceId !== void 0 ? resourceId : tempOrder.resource_id) !== null && _ref11 !== void 0 ? _ref11 : (_this$store$resource5 = this.store.resource) === null || _this$store$resource5 === void 0 ? void 0 : _this$store$resource5.relationId) !== null && _ref10 !== void 0 ? _ref10 : (_this$store$resource6 = this.store.resource) === null || _this$store$resource6 === void 0 ? void 0 : _this$store$resource6.relation_id) !== null && _ref9 !== void 0 ? _ref9 : '').trim();
|
|
3408
|
+
this.logMethodStart('syncAdditionalOrderFromResource', {
|
|
3409
|
+
resourceId: normalizedResourceId
|
|
3410
|
+
});
|
|
3411
|
+
if (normalizedResourceId) {
|
|
3412
|
+
_context43.next = 9;
|
|
3413
|
+
break;
|
|
3414
|
+
}
|
|
3415
|
+
_result = {
|
|
3416
|
+
matched: false,
|
|
3417
|
+
reason: 'missing_resource_id'
|
|
3418
|
+
};
|
|
3419
|
+
this.logMethodSuccess('syncAdditionalOrderFromResource', _result);
|
|
3420
|
+
return _context43.abrupt("return", _result);
|
|
3421
|
+
case 9:
|
|
3422
|
+
_context43.next = 11;
|
|
3423
|
+
return this.fetchResourceOccupyDetailsByResourceId(normalizedResourceId);
|
|
3424
|
+
case 11:
|
|
3425
|
+
occupyDetails = _context43.sent;
|
|
3426
|
+
occupyDetail = (_occupyDetails$2 = occupyDetails[0]) !== null && _occupyDetails$2 !== void 0 ? _occupyDetails$2 : null;
|
|
3427
|
+
resourceSelectType = ((_this$store$resource7 = this.store.resource) === null || _this$store$resource7 === void 0 ? void 0 : _this$store$resource7.resourceSelectType) || this.resolveResourceSelectType(toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_id));
|
|
3428
|
+
allowAddItems = toBoolean((_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 || (_this$otherParams20 = _this$otherParams20.dineInConfig) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20['sale.allow_add_items']);
|
|
3429
|
+
result = this.resolveAdditionalOrderFromOccupyDetail(occupyDetail, resourceSelectType, allowAddItems);
|
|
3430
|
+
if (!(!result.matched || !result.order_id)) {
|
|
3431
|
+
_context43.next = 19;
|
|
3432
|
+
break;
|
|
3433
|
+
}
|
|
3434
|
+
this.logMethodSuccess('syncAdditionalOrderFromResource', _objectSpread(_objectSpread({}, result), {}, {
|
|
3435
|
+
resourceId: normalizedResourceId,
|
|
3436
|
+
resourceSelectType: resourceSelectType,
|
|
3437
|
+
allowAddItems: allowAddItems
|
|
3438
|
+
}));
|
|
3439
|
+
return _context43.abrupt("return", result);
|
|
3440
|
+
case 19:
|
|
3441
|
+
tempOrder.order_id = result.order_id;
|
|
3442
|
+
tempOrder.resource_id = normalizedResourceId;
|
|
3443
|
+
tempOrder.relation_id = toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_record_id) || normalizedResourceId || tempOrder.relation_id;
|
|
3444
|
+
tempOrder.table_form_id = toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_id) || tempOrder.table_form_id;
|
|
3445
|
+
(_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 || _this$store$order8.persistTempOrder();
|
|
3446
|
+
this.logMethodSuccess('syncAdditionalOrderFromResource', _objectSpread(_objectSpread({}, result), {}, {
|
|
3447
|
+
resourceId: normalizedResourceId,
|
|
3448
|
+
resourceSelectType: resourceSelectType,
|
|
3449
|
+
allowAddItems: allowAddItems
|
|
3450
|
+
}));
|
|
3451
|
+
return _context43.abrupt("return", result);
|
|
3452
|
+
case 26:
|
|
3453
|
+
case "end":
|
|
3454
|
+
return _context43.stop();
|
|
3455
|
+
}
|
|
3456
|
+
}, _callee43, this);
|
|
3457
|
+
}));
|
|
3458
|
+
function syncAdditionalOrderFromResource(_x23) {
|
|
3459
|
+
return _syncAdditionalOrderFromResource.apply(this, arguments);
|
|
3460
|
+
}
|
|
3461
|
+
return syncAdditionalOrderFromResource;
|
|
3462
|
+
}() // 读取预约规则商品的资源选择类型:single=单个预约,multiple=多个预约,capacity=容量型预约
|
|
3463
|
+
// 依赖 checkResourceAvailable 已根据预约规则商品与 occupy-detail 的 form_id 计算并缓存 store.resource
|
|
3464
|
+
}, {
|
|
3465
|
+
key: "getReservationResourceSelectType",
|
|
3466
|
+
value: function getReservationResourceSelectType() {
|
|
3467
|
+
var _this$store$resource8;
|
|
3468
|
+
this.logMethodStart('getReservationResourceSelectType');
|
|
3469
|
+
var resourceSelectType = (_this$store$resource8 = this.store.resource) === null || _this$store$resource8 === void 0 ? void 0 : _this$store$resource8.resourceSelectType;
|
|
3470
|
+
var result = _objectSpread(_objectSpread({}, resourceSelectType ? {
|
|
3471
|
+
resourceSelectType: resourceSelectType
|
|
3472
|
+
} : {}), {}, {
|
|
3473
|
+
isSingleReservation: resourceSelectType === 'single',
|
|
3474
|
+
isMultipleReservation: resourceSelectType === 'multiple',
|
|
3475
|
+
isCapacityReservation: resourceSelectType === 'capacity'
|
|
3476
|
+
});
|
|
3477
|
+
this.logMethodSuccess('getReservationResourceSelectType', result);
|
|
3478
|
+
return result;
|
|
3479
|
+
}
|
|
3480
|
+
|
|
3481
|
+
// 判定后台是否开启允许加餐
|
|
3482
|
+
// 依赖 checkResourceAvailable 已缓存的 dineInConfig
|
|
3483
|
+
}, {
|
|
3484
|
+
key: "checkAllowAddItems",
|
|
3485
|
+
value: function checkAllowAddItems() {
|
|
3486
|
+
var _this$otherParams21;
|
|
3487
|
+
this.logMethodStart('checkAllowAddItems');
|
|
3488
|
+
var dineInConfig = ((_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.dineInConfig) || {};
|
|
3489
|
+
var result = {
|
|
3490
|
+
enabled: toBoolean(dineInConfig['sale.allow_add_items'])
|
|
3491
|
+
};
|
|
3492
|
+
this.logMethodSuccess('checkAllowAddItems', result);
|
|
3493
|
+
return result;
|
|
3494
|
+
}
|
|
3092
3495
|
|
|
3093
3496
|
// 读取取餐/送餐开关
|
|
3094
3497
|
// 依赖 checkResourceAvailable 已缓存的 dineInConfig
|
|
3095
3498
|
}, {
|
|
3096
3499
|
key: "getFulfillmentModes",
|
|
3097
3500
|
value: function getFulfillmentModes() {
|
|
3098
|
-
var _this$
|
|
3501
|
+
var _this$otherParams22;
|
|
3099
3502
|
this.logMethodStart('getFulfillmentModes');
|
|
3100
|
-
var dineInConfig = ((_this$
|
|
3503
|
+
var dineInConfig = ((_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.dineInConfig) || {};
|
|
3101
3504
|
var result = {
|
|
3102
3505
|
enablePickup: Boolean(dineInConfig['fulfillment.enable_pickup']),
|
|
3103
3506
|
enableTableService: Boolean(dineInConfig['fulfillment.enable_table_service'])
|
|
@@ -3111,9 +3514,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3111
3514
|
}, {
|
|
3112
3515
|
key: "checkManualPickupRef",
|
|
3113
3516
|
value: function checkManualPickupRef() {
|
|
3114
|
-
var _this$
|
|
3517
|
+
var _this$otherParams23;
|
|
3115
3518
|
this.logMethodStart('checkManualPickupRef');
|
|
3116
|
-
var dineInConfig = ((_this$
|
|
3519
|
+
var dineInConfig = ((_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.dineInConfig) || {};
|
|
3117
3520
|
var refMode = dineInConfig['fulfillment.fulfillment_ref_mode'];
|
|
3118
3521
|
var manualInputType = dineInConfig['fulfillment.manual_input_type'];
|
|
3119
3522
|
var enabled = refMode === 'manual_input';
|
|
@@ -3131,6 +3534,6 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3131
3534
|
}
|
|
3132
3535
|
}]);
|
|
3133
3536
|
return ScanOrderImpl;
|
|
3134
|
-
}(
|
|
3537
|
+
}(BaseSalesImpl);
|
|
3135
3538
|
_defineProperty(ScanOrderImpl, "PISELL1_LOGIN_SUCCESS", 'pisell1.login.success');
|
|
3136
3539
|
_defineProperty(ScanOrderImpl, "UI_STATE_KEY_PREFIX", 'pisell.scanOrder.uiState:');
|