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