@pisell/pisellos 0.0.510 → 0.0.512
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/Order/index.d.ts +3 -6
- package/dist/modules/Order/index.js +129 -62
- package/dist/modules/Order/types.d.ts +23 -5
- package/dist/modules/Order/types.js +2 -0
- package/dist/modules/Order/utils.d.ts +64 -11
- package/dist/modules/Order/utils.js +269 -43
- package/dist/modules/SalesSummary/utils.js +33 -68
- package/dist/modules/Summary/utils.js +6 -21
- package/dist/solution/ScanOrder/index.d.ts +10 -5
- package/dist/solution/ScanOrder/index.js +605 -492
- package/dist/solution/ScanOrder/types.d.ts +43 -2
- package/dist/solution/ScanOrder/types.js +13 -0
- package/dist/solution/ScanOrder/utils.d.ts +26 -12
- package/dist/solution/ScanOrder/utils.js +130 -82
- package/dist/solution/VenueBooking/index.d.ts +2 -5
- package/dist/solution/VenueBooking/index.js +35 -27
- package/lib/modules/Order/index.d.ts +3 -6
- package/lib/modules/Order/index.js +98 -24
- package/lib/modules/Order/types.d.ts +23 -5
- package/lib/modules/Order/utils.d.ts +64 -11
- package/lib/modules/Order/utils.js +167 -15
- package/lib/modules/SalesSummary/utils.js +13 -47
- package/lib/modules/Summary/utils.js +4 -18
- package/lib/solution/ScanOrder/index.d.ts +10 -5
- package/lib/solution/ScanOrder/index.js +60 -4
- package/lib/solution/ScanOrder/types.d.ts +43 -2
- package/lib/solution/ScanOrder/utils.d.ts +26 -12
- package/lib/solution/ScanOrder/utils.js +76 -68
- package/lib/solution/VenueBooking/index.d.ts +2 -5
- package/lib/solution/VenueBooking/index.js +13 -6
- package/package.json +1 -1
|
@@ -14,6 +14,8 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
|
|
|
14
14
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
15
15
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
16
16
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
17
|
+
function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
|
|
18
|
+
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
17
19
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
18
20
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
19
21
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
@@ -35,7 +37,7 @@ import { createModule } from "../BookingByStep/types";
|
|
|
35
37
|
import { ProductList } from "../../modules/ProductList";
|
|
36
38
|
import { ScheduleModule } from "../../modules/Schedule";
|
|
37
39
|
import { getDateIsInSchedule } from "../../modules/Schedule/getDateIsInSchedule";
|
|
38
|
-
import { createUuidV4, normalizeSubmitCollectPaxValue } from "../../modules/Order/utils";
|
|
40
|
+
import { composeLinePrice, createUuidV4, normalizeSubmitCollectPaxValue, sumOptionUnitPrice } from "../../modules/Order/utils";
|
|
39
41
|
import dayjs from 'dayjs';
|
|
40
42
|
import { ItemRuleEvaluator } from "../../model/strategy/adapter/itemRule";
|
|
41
43
|
export * from "./types";
|
|
@@ -81,6 +83,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
81
83
|
_defineProperty(_assertThisInitialized(_this), "customerLoginRefreshIdInFlight", null);
|
|
82
84
|
return _this;
|
|
83
85
|
}
|
|
86
|
+
|
|
87
|
+
/** 与 `otherParams.cacheId` 一致,供宿主在 URL 变化时判断是否需要重新注册模块 */
|
|
84
88
|
_createClass(ScanOrderImpl, [{
|
|
85
89
|
key: "getScanOrderLoggerContext",
|
|
86
90
|
value: function getScanOrderLoggerContext() {
|
|
@@ -386,10 +390,52 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
386
390
|
}
|
|
387
391
|
return refreshOrderMarketingAfterLogin;
|
|
388
392
|
}()
|
|
393
|
+
}, {
|
|
394
|
+
key: "getCacheId",
|
|
395
|
+
value: function getCacheId() {
|
|
396
|
+
return this.cacheId;
|
|
397
|
+
}
|
|
398
|
+
}, {
|
|
399
|
+
key: "destroyRegisteredChildModules",
|
|
400
|
+
value: function () {
|
|
401
|
+
var _destroyRegisteredChildModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
402
|
+
var modules, _i2, _modules, mod;
|
|
403
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
404
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
405
|
+
case 0:
|
|
406
|
+
modules = [this.store.schedule, this.store.salesSummary, this.store.order, this.store.products, this.store.scanOrderLogger];
|
|
407
|
+
_i2 = 0, _modules = modules;
|
|
408
|
+
case 2:
|
|
409
|
+
if (!(_i2 < _modules.length)) {
|
|
410
|
+
_context6.next = 10;
|
|
411
|
+
break;
|
|
412
|
+
}
|
|
413
|
+
mod = _modules[_i2];
|
|
414
|
+
if (!(mod && typeof mod.destroy === 'function')) {
|
|
415
|
+
_context6.next = 7;
|
|
416
|
+
break;
|
|
417
|
+
}
|
|
418
|
+
_context6.next = 7;
|
|
419
|
+
return Promise.resolve(mod.destroy());
|
|
420
|
+
case 7:
|
|
421
|
+
_i2++;
|
|
422
|
+
_context6.next = 2;
|
|
423
|
+
break;
|
|
424
|
+
case 10:
|
|
425
|
+
case "end":
|
|
426
|
+
return _context6.stop();
|
|
427
|
+
}
|
|
428
|
+
}, _callee6, this);
|
|
429
|
+
}));
|
|
430
|
+
function destroyRegisteredChildModules() {
|
|
431
|
+
return _destroyRegisteredChildModules.apply(this, arguments);
|
|
432
|
+
}
|
|
433
|
+
return destroyRegisteredChildModules;
|
|
434
|
+
}()
|
|
389
435
|
}, {
|
|
390
436
|
key: "initialize",
|
|
391
437
|
value: function () {
|
|
392
|
-
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
438
|
+
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(core) {
|
|
393
439
|
var _options$otherParams,
|
|
394
440
|
_this$otherParams,
|
|
395
441
|
_this$otherParams2,
|
|
@@ -400,11 +446,11 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
400
446
|
scheduleModule,
|
|
401
447
|
_this$store$order,
|
|
402
448
|
_this$store$order2,
|
|
403
|
-
|
|
404
|
-
return _regeneratorRuntime().wrap(function
|
|
405
|
-
while (1) switch (
|
|
449
|
+
_args7 = arguments;
|
|
450
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
451
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
406
452
|
case 0:
|
|
407
|
-
options =
|
|
453
|
+
options = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : {};
|
|
408
454
|
this.logMethodStart('initialize');
|
|
409
455
|
this.core = core;
|
|
410
456
|
this.initializeOptions = options || {};
|
|
@@ -426,14 +472,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
426
472
|
this.window = core.getPlugin('window');
|
|
427
473
|
this.request = core.getPlugin('request');
|
|
428
474
|
if (this.window) {
|
|
429
|
-
|
|
475
|
+
_context7.next = 21;
|
|
430
476
|
break;
|
|
431
477
|
}
|
|
432
478
|
this.logMethodError('initialize', 'window plugin missing');
|
|
433
479
|
throw new Error('scanOrder解决方案需要 window 插件支持');
|
|
434
480
|
case 21:
|
|
435
481
|
if (this.request) {
|
|
436
|
-
|
|
482
|
+
_context7.next = 24;
|
|
437
483
|
break;
|
|
438
484
|
}
|
|
439
485
|
this.logMethodError('initialize', 'request plugin missing');
|
|
@@ -483,37 +529,37 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
483
529
|
});
|
|
484
530
|
this.registerCustomerLoginListeners();
|
|
485
531
|
console.log('[ScanOrder] 初始化开始');
|
|
486
|
-
|
|
487
|
-
|
|
532
|
+
_context7.prev = 32;
|
|
533
|
+
_context7.next = 35;
|
|
488
534
|
return (_this$store$order = this.store.order) === null || _this$store$order === void 0 ? void 0 : _this$store$order.recalculateSummary({
|
|
489
535
|
createIfMissing: false
|
|
490
536
|
});
|
|
491
537
|
case 35:
|
|
492
538
|
(_this$store$order2 = this.store.order) === null || _this$store$order2 === void 0 || _this$store$order2.persistTempOrder();
|
|
493
|
-
|
|
539
|
+
_context7.next = 38;
|
|
494
540
|
return this.loadRuntimeConfigs();
|
|
495
541
|
case 38:
|
|
496
542
|
if (!this.store.schedule) {
|
|
497
|
-
|
|
543
|
+
_context7.next = 47;
|
|
498
544
|
break;
|
|
499
545
|
}
|
|
500
|
-
|
|
501
|
-
|
|
546
|
+
_context7.prev = 39;
|
|
547
|
+
_context7.next = 42;
|
|
502
548
|
return this.store.schedule.loadAllSchedule();
|
|
503
549
|
case 42:
|
|
504
|
-
|
|
550
|
+
_context7.next = 47;
|
|
505
551
|
break;
|
|
506
552
|
case 44:
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
console.warn('[ScanOrder] loadAllSchedule 失败,operating_hours 判定将跳过',
|
|
553
|
+
_context7.prev = 44;
|
|
554
|
+
_context7.t0 = _context7["catch"](39);
|
|
555
|
+
console.warn('[ScanOrder] loadAllSchedule 失败,operating_hours 判定将跳过', _context7.t0);
|
|
510
556
|
case 47:
|
|
511
|
-
|
|
557
|
+
_context7.next = 49;
|
|
512
558
|
return this.refreshItemRuleQuantityLimits();
|
|
513
559
|
case 49:
|
|
514
560
|
this.store.status = 'ready';
|
|
515
561
|
console.log('[ScanOrder] 初始化完成');
|
|
516
|
-
|
|
562
|
+
_context7.next = 53;
|
|
517
563
|
return this.core.effects.emit(ScanOrderHooks.onInited, {
|
|
518
564
|
status: this.store.status
|
|
519
565
|
});
|
|
@@ -521,23 +567,23 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
521
567
|
this.logMethodSuccess('initialize', {
|
|
522
568
|
status: this.store.status
|
|
523
569
|
});
|
|
524
|
-
|
|
570
|
+
_context7.next = 63;
|
|
525
571
|
break;
|
|
526
572
|
case 56:
|
|
527
|
-
|
|
528
|
-
|
|
573
|
+
_context7.prev = 56;
|
|
574
|
+
_context7.t1 = _context7["catch"](32);
|
|
529
575
|
this.store.status = 'error';
|
|
530
|
-
this.store.error =
|
|
531
|
-
console.error('[ScanOrder] 初始化失败',
|
|
532
|
-
this.logMethodError('initialize',
|
|
576
|
+
this.store.error = _context7.t1 instanceof Error ? _context7.t1.message : '初始化失败';
|
|
577
|
+
console.error('[ScanOrder] 初始化失败', _context7.t1);
|
|
578
|
+
this.logMethodError('initialize', _context7.t1, {
|
|
533
579
|
status: this.store.status
|
|
534
580
|
});
|
|
535
|
-
throw
|
|
581
|
+
throw _context7.t1;
|
|
536
582
|
case 63:
|
|
537
583
|
case "end":
|
|
538
|
-
return
|
|
584
|
+
return _context7.stop();
|
|
539
585
|
}
|
|
540
|
-
},
|
|
586
|
+
}, _callee7, this, [[32, 56], [39, 44]]);
|
|
541
587
|
}));
|
|
542
588
|
function initialize(_x5) {
|
|
543
589
|
return _initialize.apply(this, arguments);
|
|
@@ -547,22 +593,26 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
547
593
|
}, {
|
|
548
594
|
key: "destroy",
|
|
549
595
|
value: function () {
|
|
550
|
-
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
551
|
-
return _regeneratorRuntime().wrap(function
|
|
552
|
-
while (1) switch (
|
|
596
|
+
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
597
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
598
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
553
599
|
case 0:
|
|
554
600
|
this.logMethodStart('destroy');
|
|
555
601
|
this.clearLoginEffectListeners();
|
|
556
|
-
|
|
602
|
+
_context8.next = 4;
|
|
557
603
|
return this.core.effects.emit(ScanOrderHooks.onDestroy, {});
|
|
558
604
|
case 4:
|
|
605
|
+
_context8.next = 6;
|
|
606
|
+
return this.destroyRegisteredChildModules();
|
|
607
|
+
case 6:
|
|
608
|
+
_get(_getPrototypeOf(ScanOrderImpl.prototype), "destroy", this).call(this);
|
|
559
609
|
console.log('[ScanOrder] 已销毁');
|
|
560
610
|
this.logMethodSuccess('destroy');
|
|
561
|
-
case
|
|
611
|
+
case 9:
|
|
562
612
|
case "end":
|
|
563
|
-
return
|
|
613
|
+
return _context8.stop();
|
|
564
614
|
}
|
|
565
|
-
},
|
|
615
|
+
}, _callee8, this);
|
|
566
616
|
}));
|
|
567
617
|
function destroy() {
|
|
568
618
|
return _destroy.apply(this, arguments);
|
|
@@ -572,33 +622,33 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
572
622
|
}, {
|
|
573
623
|
key: "retryInit",
|
|
574
624
|
value: function () {
|
|
575
|
-
var _retryInit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
576
|
-
return _regeneratorRuntime().wrap(function
|
|
577
|
-
while (1) switch (
|
|
625
|
+
var _retryInit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
626
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
627
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
578
628
|
case 0:
|
|
579
629
|
this.logMethodStart('retryInit');
|
|
580
630
|
// TODO: 细化重试策略(指数退避、最大重试次数)后替换当前实现
|
|
581
631
|
console.log('[ScanOrder] retryInit 调用');
|
|
582
|
-
|
|
632
|
+
_context9.next = 4;
|
|
583
633
|
return this.core.effects.emit(ScanOrderHooks.onRetryInit, {});
|
|
584
634
|
case 4:
|
|
585
|
-
|
|
586
|
-
|
|
635
|
+
_context9.prev = 4;
|
|
636
|
+
_context9.next = 7;
|
|
587
637
|
return this.initialize(this.core, this.initializeOptions);
|
|
588
638
|
case 7:
|
|
589
639
|
this.logMethodSuccess('retryInit');
|
|
590
|
-
|
|
640
|
+
_context9.next = 14;
|
|
591
641
|
break;
|
|
592
642
|
case 10:
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
this.logMethodError('retryInit',
|
|
596
|
-
throw
|
|
643
|
+
_context9.prev = 10;
|
|
644
|
+
_context9.t0 = _context9["catch"](4);
|
|
645
|
+
this.logMethodError('retryInit', _context9.t0);
|
|
646
|
+
throw _context9.t0;
|
|
597
647
|
case 14:
|
|
598
648
|
case "end":
|
|
599
|
-
return
|
|
649
|
+
return _context9.stop();
|
|
600
650
|
}
|
|
601
|
-
},
|
|
651
|
+
}, _callee9, this, [[4, 10]]);
|
|
602
652
|
}));
|
|
603
653
|
function retryInit() {
|
|
604
654
|
return _retryInit.apply(this, arguments);
|
|
@@ -608,23 +658,23 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
608
658
|
}, {
|
|
609
659
|
key: "refresh",
|
|
610
660
|
value: function () {
|
|
611
|
-
var _refresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
612
|
-
return _regeneratorRuntime().wrap(function
|
|
613
|
-
while (1) switch (
|
|
661
|
+
var _refresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
662
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
663
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
614
664
|
case 0:
|
|
615
665
|
this.logMethodStart('refresh');
|
|
616
666
|
// TODO: 接入真实刷新逻辑(资源重拉取、流程重建)后替换当前实现
|
|
617
667
|
console.log('[ScanOrder] refresh 调用');
|
|
618
|
-
|
|
668
|
+
_context10.prev = 2;
|
|
619
669
|
this.store.status = 'initializing';
|
|
620
|
-
|
|
670
|
+
_context10.next = 6;
|
|
621
671
|
return this.loadRuntimeConfigs();
|
|
622
672
|
case 6:
|
|
623
|
-
|
|
673
|
+
_context10.next = 8;
|
|
624
674
|
return this.refreshItemRuleQuantityLimits();
|
|
625
675
|
case 8:
|
|
626
676
|
this.store.status = 'ready';
|
|
627
|
-
|
|
677
|
+
_context10.next = 11;
|
|
628
678
|
return this.core.effects.emit(ScanOrderHooks.onRefresh, {
|
|
629
679
|
status: this.store.status
|
|
630
680
|
});
|
|
@@ -632,18 +682,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
632
682
|
this.logMethodSuccess('refresh', {
|
|
633
683
|
status: this.store.status
|
|
634
684
|
});
|
|
635
|
-
|
|
685
|
+
_context10.next = 18;
|
|
636
686
|
break;
|
|
637
687
|
case 14:
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
this.logMethodError('refresh',
|
|
641
|
-
throw
|
|
688
|
+
_context10.prev = 14;
|
|
689
|
+
_context10.t0 = _context10["catch"](2);
|
|
690
|
+
this.logMethodError('refresh', _context10.t0);
|
|
691
|
+
throw _context10.t0;
|
|
642
692
|
case 18:
|
|
643
693
|
case "end":
|
|
644
|
-
return
|
|
694
|
+
return _context10.stop();
|
|
645
695
|
}
|
|
646
|
-
},
|
|
696
|
+
}, _callee10, this, [[2, 14]]);
|
|
647
697
|
}));
|
|
648
698
|
function refresh() {
|
|
649
699
|
return _refresh.apply(this, arguments);
|
|
@@ -807,37 +857,37 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
807
857
|
}, {
|
|
808
858
|
key: "addNewOrder",
|
|
809
859
|
value: function () {
|
|
810
|
-
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
860
|
+
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
811
861
|
var tempOrder;
|
|
812
|
-
return _regeneratorRuntime().wrap(function
|
|
813
|
-
while (1) switch (
|
|
862
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
863
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
814
864
|
case 0:
|
|
815
865
|
this.logMethodStart('addNewOrder');
|
|
816
|
-
|
|
866
|
+
_context11.prev = 1;
|
|
817
867
|
if (this.store.order) {
|
|
818
|
-
|
|
868
|
+
_context11.next = 4;
|
|
819
869
|
break;
|
|
820
870
|
}
|
|
821
871
|
throw new Error('order 模块未初始化');
|
|
822
872
|
case 4:
|
|
823
|
-
|
|
873
|
+
_context11.next = 6;
|
|
824
874
|
return this.store.order.addNewOrder();
|
|
825
875
|
case 6:
|
|
826
|
-
tempOrder =
|
|
876
|
+
tempOrder = _context11.sent;
|
|
827
877
|
this.logMethodSuccess('addNewOrder', {
|
|
828
878
|
productCount: tempOrder.products.length
|
|
829
879
|
});
|
|
830
|
-
return
|
|
880
|
+
return _context11.abrupt("return", tempOrder);
|
|
831
881
|
case 11:
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
this.logMethodError('addNewOrder',
|
|
835
|
-
throw
|
|
882
|
+
_context11.prev = 11;
|
|
883
|
+
_context11.t0 = _context11["catch"](1);
|
|
884
|
+
this.logMethodError('addNewOrder', _context11.t0);
|
|
885
|
+
throw _context11.t0;
|
|
836
886
|
case 15:
|
|
837
887
|
case "end":
|
|
838
|
-
return
|
|
888
|
+
return _context11.stop();
|
|
839
889
|
}
|
|
840
|
-
},
|
|
890
|
+
}, _callee11, this, [[1, 11]]);
|
|
841
891
|
}));
|
|
842
892
|
function addNewOrder() {
|
|
843
893
|
return _addNewOrder.apply(this, arguments);
|
|
@@ -848,15 +898,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
848
898
|
}, {
|
|
849
899
|
key: "restoreOrder",
|
|
850
900
|
value: function () {
|
|
851
|
-
var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
901
|
+
var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
852
902
|
var tempOrder;
|
|
853
|
-
return _regeneratorRuntime().wrap(function
|
|
854
|
-
while (1) switch (
|
|
903
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
904
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
855
905
|
case 0:
|
|
856
906
|
this.logMethodStart('restoreOrder');
|
|
857
|
-
|
|
907
|
+
_context12.prev = 1;
|
|
858
908
|
if (this.store.order) {
|
|
859
|
-
|
|
909
|
+
_context12.next = 4;
|
|
860
910
|
break;
|
|
861
911
|
}
|
|
862
912
|
throw new Error('scanOrder 解决方案需要 order 模块支持');
|
|
@@ -866,17 +916,17 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
866
916
|
this.enabledReservationRuleProducts = [];
|
|
867
917
|
tempOrder = this.store.order.restoreOrder();
|
|
868
918
|
this.logMethodSuccess('restoreOrder');
|
|
869
|
-
return
|
|
919
|
+
return _context12.abrupt("return", tempOrder);
|
|
870
920
|
case 12:
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
this.logMethodError('restoreOrder',
|
|
874
|
-
throw
|
|
921
|
+
_context12.prev = 12;
|
|
922
|
+
_context12.t0 = _context12["catch"](1);
|
|
923
|
+
this.logMethodError('restoreOrder', _context12.t0);
|
|
924
|
+
throw _context12.t0;
|
|
875
925
|
case 16:
|
|
876
926
|
case "end":
|
|
877
|
-
return
|
|
927
|
+
return _context12.stop();
|
|
878
928
|
}
|
|
879
|
-
},
|
|
929
|
+
}, _callee12, this, [[1, 12]]);
|
|
880
930
|
}));
|
|
881
931
|
function restoreOrder() {
|
|
882
932
|
return _restoreOrder.apply(this, arguments);
|
|
@@ -897,37 +947,37 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
897
947
|
}, {
|
|
898
948
|
key: "getSummary",
|
|
899
949
|
value: function () {
|
|
900
|
-
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
950
|
+
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
901
951
|
var summary;
|
|
902
|
-
return _regeneratorRuntime().wrap(function
|
|
903
|
-
while (1) switch (
|
|
952
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
953
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
904
954
|
case 0:
|
|
905
955
|
this.logMethodStart('getSummary');
|
|
906
|
-
|
|
956
|
+
_context13.prev = 1;
|
|
907
957
|
if (this.store.order) {
|
|
908
|
-
|
|
958
|
+
_context13.next = 4;
|
|
909
959
|
break;
|
|
910
960
|
}
|
|
911
961
|
throw new Error('order 模块未初始化');
|
|
912
962
|
case 4:
|
|
913
|
-
|
|
963
|
+
_context13.next = 6;
|
|
914
964
|
return this.store.order.getScanOrderSummary();
|
|
915
965
|
case 6:
|
|
916
|
-
summary =
|
|
966
|
+
summary = _context13.sent;
|
|
917
967
|
this.logMethodSuccess('getSummary', {
|
|
918
968
|
totalAmount: summary.total_amount
|
|
919
969
|
});
|
|
920
|
-
return
|
|
970
|
+
return _context13.abrupt("return", summary);
|
|
921
971
|
case 11:
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
this.logMethodError('getSummary',
|
|
925
|
-
throw
|
|
972
|
+
_context13.prev = 11;
|
|
973
|
+
_context13.t0 = _context13["catch"](1);
|
|
974
|
+
this.logMethodError('getSummary', _context13.t0);
|
|
975
|
+
throw _context13.t0;
|
|
926
976
|
case 15:
|
|
927
977
|
case "end":
|
|
928
|
-
return
|
|
978
|
+
return _context13.stop();
|
|
929
979
|
}
|
|
930
|
-
},
|
|
980
|
+
}, _callee13, this, [[1, 11]]);
|
|
931
981
|
}));
|
|
932
982
|
function getSummary() {
|
|
933
983
|
return _getSummary.apply(this, arguments);
|
|
@@ -943,30 +993,30 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
943
993
|
}, {
|
|
944
994
|
key: "scanCode",
|
|
945
995
|
value: function () {
|
|
946
|
-
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
996
|
+
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(code, customerId) {
|
|
947
997
|
var raw;
|
|
948
|
-
return _regeneratorRuntime().wrap(function
|
|
949
|
-
while (1) switch (
|
|
998
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
999
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
950
1000
|
case 0:
|
|
951
1001
|
this.logMethodStart('scanCode', {
|
|
952
1002
|
code: code
|
|
953
1003
|
});
|
|
954
|
-
|
|
1004
|
+
_context14.prev = 1;
|
|
955
1005
|
if (this.store.order) {
|
|
956
|
-
|
|
1006
|
+
_context14.next = 4;
|
|
957
1007
|
break;
|
|
958
1008
|
}
|
|
959
1009
|
throw new Error('order 模块未初始化');
|
|
960
1010
|
case 4:
|
|
961
|
-
|
|
1011
|
+
_context14.next = 6;
|
|
962
1012
|
return this.store.order.scanCode(code, customerId);
|
|
963
1013
|
case 6:
|
|
964
|
-
raw =
|
|
1014
|
+
raw = _context14.sent;
|
|
965
1015
|
if (!raw.isAvailable) {
|
|
966
|
-
|
|
1016
|
+
_context14.next = 11;
|
|
967
1017
|
break;
|
|
968
1018
|
}
|
|
969
|
-
|
|
1019
|
+
_context14.next = 10;
|
|
970
1020
|
return this.store.order.recalculateSummary({
|
|
971
1021
|
createIfMissing: true
|
|
972
1022
|
});
|
|
@@ -976,21 +1026,21 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
976
1026
|
this.logMethodSuccess('scanCode', {
|
|
977
1027
|
isAvailable: raw.isAvailable
|
|
978
1028
|
});
|
|
979
|
-
return
|
|
1029
|
+
return _context14.abrupt("return", {
|
|
980
1030
|
isAvailable: raw.isAvailable,
|
|
981
1031
|
type: raw.type,
|
|
982
1032
|
unavailableReason: raw.unavailableReason
|
|
983
1033
|
});
|
|
984
1034
|
case 15:
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
this.logMethodError('scanCode',
|
|
988
|
-
throw
|
|
1035
|
+
_context14.prev = 15;
|
|
1036
|
+
_context14.t0 = _context14["catch"](1);
|
|
1037
|
+
this.logMethodError('scanCode', _context14.t0);
|
|
1038
|
+
throw _context14.t0;
|
|
989
1039
|
case 19:
|
|
990
1040
|
case "end":
|
|
991
|
-
return
|
|
1041
|
+
return _context14.stop();
|
|
992
1042
|
}
|
|
993
|
-
},
|
|
1043
|
+
}, _callee14, this, [[1, 15]]);
|
|
994
1044
|
}));
|
|
995
1045
|
function scanCode(_x6, _x7) {
|
|
996
1046
|
return _scanCode.apply(this, arguments);
|
|
@@ -1000,15 +1050,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1000
1050
|
}, {
|
|
1001
1051
|
key: "setDiscountSelected",
|
|
1002
1052
|
value: function () {
|
|
1003
|
-
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1004
|
-
var _tempOrder$holder, list, updated, tempOrder, orderStore, discountModule, rulesModule, holders, nextDiscountList, _tempOrder$holder2, result, beforeSelectedIds, _iterator2, _step2, d, selectedResourceIds, _iterator3, _step3, _product$_origin, product, totalPerUnitDiscount,
|
|
1005
|
-
return _regeneratorRuntime().wrap(function
|
|
1006
|
-
while (1) switch (
|
|
1053
|
+
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
|
|
1054
|
+
var _tempOrder$holder, list, updated, tempOrder, orderStore, discountModule, rulesModule, holders, nextDiscountList, _tempOrder$holder2, result, beforeSelectedIds, _iterator2, _step2, d, selectedResourceIds, _iterator3, _step3, _product$_origin, _product$metadata$sou, _product$metadata, _product$metadata2, _product$original_pri, product, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
|
|
1055
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1056
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1007
1057
|
case 0:
|
|
1008
1058
|
this.logMethodStart('setDiscountSelected', params);
|
|
1009
|
-
|
|
1059
|
+
_context15.prev = 1;
|
|
1010
1060
|
if (this.store.order) {
|
|
1011
|
-
|
|
1061
|
+
_context15.next = 4;
|
|
1012
1062
|
break;
|
|
1013
1063
|
}
|
|
1014
1064
|
throw new Error('order 模块未初始化');
|
|
@@ -1028,7 +1078,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1028
1078
|
form_record_id: tempOrder.holder.form_record_id
|
|
1029
1079
|
}] : [];
|
|
1030
1080
|
nextDiscountList = updated;
|
|
1031
|
-
|
|
1081
|
+
_context15.next = 14;
|
|
1032
1082
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(updated);
|
|
1033
1083
|
case 14:
|
|
1034
1084
|
if (rulesModule) {
|
|
@@ -1077,74 +1127,84 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1077
1127
|
return d.id;
|
|
1078
1128
|
}));
|
|
1079
1129
|
_iterator3 = _createForOfIteratorHelper(tempOrder.products);
|
|
1080
|
-
|
|
1130
|
+
_context15.prev = 17;
|
|
1081
1131
|
_iterator3.s();
|
|
1082
1132
|
case 19:
|
|
1083
1133
|
if ((_step3 = _iterator3.n()).done) {
|
|
1084
|
-
|
|
1134
|
+
_context15.next = 33;
|
|
1085
1135
|
break;
|
|
1086
1136
|
}
|
|
1087
1137
|
product = _step3.value;
|
|
1088
1138
|
if (!((_product$_origin = product._origin) !== null && _product$_origin !== void 0 && _product$_origin.isManualDiscount)) {
|
|
1089
|
-
|
|
1139
|
+
_context15.next = 23;
|
|
1090
1140
|
break;
|
|
1091
1141
|
}
|
|
1092
|
-
return
|
|
1142
|
+
return _context15.abrupt("continue", 31);
|
|
1093
1143
|
case 23:
|
|
1094
1144
|
product.discount_list = (product.discount_list || []).filter(function (pd) {
|
|
1095
1145
|
var _pd$discount$resource, _pd$discount;
|
|
1096
1146
|
var rid = (_pd$discount$resource = (_pd$discount = pd.discount) === null || _pd$discount === void 0 ? void 0 : _pd$discount.resource_id) !== null && _pd$discount$resource !== void 0 ? _pd$discount$resource : pd.id;
|
|
1097
1147
|
return rid != null && selectedResourceIds.has(rid);
|
|
1098
1148
|
});
|
|
1149
|
+
|
|
1150
|
+
// 券作用于 source(不含 option、不含 bundle);算出新 source 折后价后补回 options
|
|
1151
|
+
// 写入含 option 的 main_product_selling_price,再合成 composite 回写 selling_price。
|
|
1099
1152
|
totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
|
|
1100
1153
|
return sum + (pd.amount || 0);
|
|
1101
1154
|
}, 0);
|
|
1102
|
-
|
|
1103
|
-
product.
|
|
1155
|
+
optionSum = sumOptionUnitPrice(product.product_option_item);
|
|
1156
|
+
sourcePrice = (_product$metadata$sou = (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.source_product_price) !== null && _product$metadata$sou !== void 0 ? _product$metadata$sou : ((_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.main_product_original_price) != null ? new Decimal(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : (_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : '0';
|
|
1157
|
+
newSourceSellingPrice = new Decimal(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
1158
|
+
newMainSellingPrice = new Decimal(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
1104
1159
|
if (product.metadata) {
|
|
1105
|
-
product.metadata.main_product_selling_price =
|
|
1160
|
+
product.metadata.main_product_selling_price = newMainSellingPrice;
|
|
1161
|
+
product.metadata.price_schema_version = 2;
|
|
1106
1162
|
}
|
|
1107
|
-
|
|
1108
|
-
|
|
1163
|
+
product.selling_price = composeLinePrice({
|
|
1164
|
+
mainPrice: newMainSellingPrice,
|
|
1165
|
+
bundle: product.product_bundle
|
|
1166
|
+
});
|
|
1167
|
+
case 31:
|
|
1168
|
+
_context15.next = 19;
|
|
1109
1169
|
break;
|
|
1110
|
-
case
|
|
1111
|
-
|
|
1170
|
+
case 33:
|
|
1171
|
+
_context15.next = 38;
|
|
1112
1172
|
break;
|
|
1113
|
-
case 32:
|
|
1114
|
-
_context14.prev = 32;
|
|
1115
|
-
_context14.t0 = _context14["catch"](17);
|
|
1116
|
-
_iterator3.e(_context14.t0);
|
|
1117
1173
|
case 35:
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1174
|
+
_context15.prev = 35;
|
|
1175
|
+
_context15.t0 = _context15["catch"](17);
|
|
1176
|
+
_iterator3.e(_context15.t0);
|
|
1121
1177
|
case 38:
|
|
1178
|
+
_context15.prev = 38;
|
|
1179
|
+
_iterator3.f();
|
|
1180
|
+
return _context15.finish(38);
|
|
1181
|
+
case 41:
|
|
1122
1182
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
1123
|
-
|
|
1183
|
+
_context15.next = 44;
|
|
1124
1184
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
1125
|
-
case
|
|
1185
|
+
case 44:
|
|
1126
1186
|
tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
|
|
1127
1187
|
return d.isSelected;
|
|
1128
1188
|
});
|
|
1129
|
-
|
|
1189
|
+
_context15.next = 47;
|
|
1130
1190
|
return this.store.order.recalculateSummary({
|
|
1131
1191
|
createIfMissing: true
|
|
1132
1192
|
});
|
|
1133
|
-
case
|
|
1193
|
+
case 47:
|
|
1134
1194
|
this.store.order.persistTempOrder();
|
|
1135
1195
|
this.logMethodSuccess('setDiscountSelected', params);
|
|
1136
|
-
|
|
1196
|
+
_context15.next = 55;
|
|
1137
1197
|
break;
|
|
1138
|
-
case
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
this.logMethodError('setDiscountSelected',
|
|
1142
|
-
throw
|
|
1143
|
-
case
|
|
1198
|
+
case 51:
|
|
1199
|
+
_context15.prev = 51;
|
|
1200
|
+
_context15.t1 = _context15["catch"](1);
|
|
1201
|
+
this.logMethodError('setDiscountSelected', _context15.t1);
|
|
1202
|
+
throw _context15.t1;
|
|
1203
|
+
case 55:
|
|
1144
1204
|
case "end":
|
|
1145
|
-
return
|
|
1205
|
+
return _context15.stop();
|
|
1146
1206
|
}
|
|
1147
|
-
},
|
|
1207
|
+
}, _callee15, this, [[1, 51], [17, 35, 38, 41]]);
|
|
1148
1208
|
}));
|
|
1149
1209
|
function setDiscountSelected(_x8) {
|
|
1150
1210
|
return _setDiscountSelected.apply(this, arguments);
|
|
@@ -1154,15 +1214,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1154
1214
|
}, {
|
|
1155
1215
|
key: "onCustomerLogin",
|
|
1156
1216
|
value: function () {
|
|
1157
|
-
var _onCustomerLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1158
|
-
return _regeneratorRuntime().wrap(function
|
|
1159
|
-
while (1) switch (
|
|
1217
|
+
var _onCustomerLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(params) {
|
|
1218
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1219
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1160
1220
|
case 0:
|
|
1161
1221
|
this.logMethodStart('onCustomerLogin', {
|
|
1162
1222
|
customerId: params.customerId
|
|
1163
1223
|
});
|
|
1164
|
-
|
|
1165
|
-
|
|
1224
|
+
_context16.prev = 1;
|
|
1225
|
+
_context16.next = 4;
|
|
1166
1226
|
return this.refreshOrderMarketingAfterLogin({
|
|
1167
1227
|
customerId: params.customerId
|
|
1168
1228
|
});
|
|
@@ -1170,18 +1230,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1170
1230
|
this.logMethodSuccess('onCustomerLogin', {
|
|
1171
1231
|
customerId: params.customerId
|
|
1172
1232
|
});
|
|
1173
|
-
|
|
1233
|
+
_context16.next = 11;
|
|
1174
1234
|
break;
|
|
1175
1235
|
case 7:
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
this.logMethodError('onCustomerLogin',
|
|
1179
|
-
throw
|
|
1236
|
+
_context16.prev = 7;
|
|
1237
|
+
_context16.t0 = _context16["catch"](1);
|
|
1238
|
+
this.logMethodError('onCustomerLogin', _context16.t0);
|
|
1239
|
+
throw _context16.t0;
|
|
1180
1240
|
case 11:
|
|
1181
1241
|
case "end":
|
|
1182
|
-
return
|
|
1242
|
+
return _context16.stop();
|
|
1183
1243
|
}
|
|
1184
|
-
},
|
|
1244
|
+
}, _callee16, this, [[1, 7]]);
|
|
1185
1245
|
}));
|
|
1186
1246
|
function onCustomerLogin(_x9) {
|
|
1187
1247
|
return _onCustomerLogin.apply(this, arguments);
|
|
@@ -1292,18 +1352,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1292
1352
|
}, {
|
|
1293
1353
|
key: "submitScanOrder",
|
|
1294
1354
|
value: function () {
|
|
1295
|
-
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1355
|
+
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
1296
1356
|
var _this$store$resource, _this$otherParams4, _this$otherParams5, _this$otherParams6, _this$otherParams7, _tempOrder$products, pax, tempOrderForSubmit, resourceTableName, enhancePayload, result, tempOrder;
|
|
1297
|
-
return _regeneratorRuntime().wrap(function
|
|
1298
|
-
while (1) switch (
|
|
1357
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1358
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1299
1359
|
case 0:
|
|
1300
1360
|
this.logMethodStart('submitScanOrder');
|
|
1301
|
-
|
|
1302
|
-
|
|
1361
|
+
_context17.prev = 1;
|
|
1362
|
+
_context17.next = 4;
|
|
1303
1363
|
return this.validateBeforeSubmitByItemRule();
|
|
1304
1364
|
case 4:
|
|
1305
1365
|
if (this.store.order) {
|
|
1306
|
-
|
|
1366
|
+
_context17.next = 6;
|
|
1307
1367
|
break;
|
|
1308
1368
|
}
|
|
1309
1369
|
throw new Error('scanOrder解决方案需要 order 模块支持');
|
|
@@ -1323,7 +1383,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1323
1383
|
}
|
|
1324
1384
|
this.store.order.persistTempOrder();
|
|
1325
1385
|
enhancePayload = this.buildSubmitPayloadEnhancer();
|
|
1326
|
-
|
|
1386
|
+
_context17.next = 17;
|
|
1327
1387
|
return this.store.order.submitTempOrder({
|
|
1328
1388
|
cacheId: this.cacheId,
|
|
1329
1389
|
platform: (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.platform,
|
|
@@ -1333,22 +1393,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1333
1393
|
enhancePayload: enhancePayload
|
|
1334
1394
|
});
|
|
1335
1395
|
case 17:
|
|
1336
|
-
result =
|
|
1396
|
+
result = _context17.sent;
|
|
1337
1397
|
tempOrder = this.store.order.getTempOrder();
|
|
1338
1398
|
this.logMethodSuccess('submitScanOrder', {
|
|
1339
1399
|
productCount: (tempOrder === null || tempOrder === void 0 || (_tempOrder$products = tempOrder.products) === null || _tempOrder$products === void 0 ? void 0 : _tempOrder$products.length) || 0
|
|
1340
1400
|
});
|
|
1341
|
-
return
|
|
1401
|
+
return _context17.abrupt("return", result);
|
|
1342
1402
|
case 23:
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
this.logMethodError('submitScanOrder',
|
|
1346
|
-
throw
|
|
1403
|
+
_context17.prev = 23;
|
|
1404
|
+
_context17.t0 = _context17["catch"](1);
|
|
1405
|
+
this.logMethodError('submitScanOrder', _context17.t0);
|
|
1406
|
+
throw _context17.t0;
|
|
1347
1407
|
case 27:
|
|
1348
1408
|
case "end":
|
|
1349
|
-
return
|
|
1409
|
+
return _context17.stop();
|
|
1350
1410
|
}
|
|
1351
|
-
},
|
|
1411
|
+
}, _callee17, this, [[1, 23]]);
|
|
1352
1412
|
}));
|
|
1353
1413
|
function submitScanOrder() {
|
|
1354
1414
|
return _submitScanOrder.apply(this, arguments);
|
|
@@ -1358,46 +1418,46 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1358
1418
|
}, {
|
|
1359
1419
|
key: "addProductToOrder",
|
|
1360
1420
|
value: function () {
|
|
1361
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1421
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(product) {
|
|
1362
1422
|
var products;
|
|
1363
|
-
return _regeneratorRuntime().wrap(function
|
|
1364
|
-
while (1) switch (
|
|
1423
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1424
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1365
1425
|
case 0:
|
|
1366
1426
|
this.logMethodStart('addProductToOrder', {
|
|
1367
1427
|
product_id: product.product_id,
|
|
1368
1428
|
product_variant_id: product.product_variant_id
|
|
1369
1429
|
});
|
|
1370
|
-
|
|
1430
|
+
_context18.prev = 1;
|
|
1371
1431
|
if (this.store.order) {
|
|
1372
|
-
|
|
1432
|
+
_context18.next = 4;
|
|
1373
1433
|
break;
|
|
1374
1434
|
}
|
|
1375
1435
|
throw new Error('order 模块未初始化');
|
|
1376
1436
|
case 4:
|
|
1377
|
-
|
|
1437
|
+
_context18.next = 6;
|
|
1378
1438
|
return this.store.order.addProductToOrder(product);
|
|
1379
1439
|
case 6:
|
|
1380
|
-
products =
|
|
1381
|
-
|
|
1440
|
+
products = _context18.sent;
|
|
1441
|
+
_context18.next = 9;
|
|
1382
1442
|
return this.refreshItemRuleQuantityLimits();
|
|
1383
1443
|
case 9:
|
|
1384
|
-
|
|
1444
|
+
_context18.next = 11;
|
|
1385
1445
|
return this.refreshCartValidationPassed();
|
|
1386
1446
|
case 11:
|
|
1387
1447
|
this.logMethodSuccess('addProductToOrder', {
|
|
1388
1448
|
productCount: products.length
|
|
1389
1449
|
});
|
|
1390
|
-
return
|
|
1450
|
+
return _context18.abrupt("return", products);
|
|
1391
1451
|
case 15:
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
this.logMethodError('addProductToOrder',
|
|
1395
|
-
throw
|
|
1452
|
+
_context18.prev = 15;
|
|
1453
|
+
_context18.t0 = _context18["catch"](1);
|
|
1454
|
+
this.logMethodError('addProductToOrder', _context18.t0);
|
|
1455
|
+
throw _context18.t0;
|
|
1396
1456
|
case 19:
|
|
1397
1457
|
case "end":
|
|
1398
|
-
return
|
|
1458
|
+
return _context18.stop();
|
|
1399
1459
|
}
|
|
1400
|
-
},
|
|
1460
|
+
}, _callee18, this, [[1, 15]]);
|
|
1401
1461
|
}));
|
|
1402
1462
|
function addProductToOrder(_x10) {
|
|
1403
1463
|
return _addProductToOrder.apply(this, arguments);
|
|
@@ -1407,97 +1467,150 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1407
1467
|
}, {
|
|
1408
1468
|
key: "updateProductInOrder",
|
|
1409
1469
|
value: function () {
|
|
1410
|
-
var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1470
|
+
var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
|
|
1411
1471
|
var products;
|
|
1412
|
-
return _regeneratorRuntime().wrap(function
|
|
1413
|
-
while (1) switch (
|
|
1472
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1473
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1414
1474
|
case 0:
|
|
1415
1475
|
this.logMethodStart('updateProductInOrder', {
|
|
1416
1476
|
product_id: params.product_id,
|
|
1417
1477
|
product_variant_id: params.product_variant_id
|
|
1418
1478
|
});
|
|
1419
|
-
|
|
1479
|
+
_context19.prev = 1;
|
|
1420
1480
|
if (this.store.order) {
|
|
1421
|
-
|
|
1481
|
+
_context19.next = 4;
|
|
1422
1482
|
break;
|
|
1423
1483
|
}
|
|
1424
1484
|
throw new Error('order 模块未初始化');
|
|
1425
1485
|
case 4:
|
|
1426
|
-
|
|
1486
|
+
_context19.next = 6;
|
|
1427
1487
|
return this.store.order.updateProductInOrder(params);
|
|
1428
1488
|
case 6:
|
|
1429
|
-
products =
|
|
1430
|
-
|
|
1489
|
+
products = _context19.sent;
|
|
1490
|
+
_context19.next = 9;
|
|
1431
1491
|
return this.refreshItemRuleQuantityLimits();
|
|
1432
1492
|
case 9:
|
|
1433
|
-
|
|
1493
|
+
_context19.next = 11;
|
|
1434
1494
|
return this.refreshCartValidationPassed();
|
|
1435
1495
|
case 11:
|
|
1436
1496
|
this.logMethodSuccess('updateProductInOrder', {
|
|
1437
1497
|
productCount: products.length
|
|
1438
1498
|
});
|
|
1439
|
-
return
|
|
1499
|
+
return _context19.abrupt("return", products);
|
|
1440
1500
|
case 15:
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
this.logMethodError('updateProductInOrder',
|
|
1444
|
-
throw
|
|
1501
|
+
_context19.prev = 15;
|
|
1502
|
+
_context19.t0 = _context19["catch"](1);
|
|
1503
|
+
this.logMethodError('updateProductInOrder', _context19.t0);
|
|
1504
|
+
throw _context19.t0;
|
|
1445
1505
|
case 19:
|
|
1446
1506
|
case "end":
|
|
1447
|
-
return
|
|
1507
|
+
return _context19.stop();
|
|
1448
1508
|
}
|
|
1449
|
-
},
|
|
1509
|
+
}, _callee19, this, [[1, 15]]);
|
|
1450
1510
|
}));
|
|
1451
1511
|
function updateProductInOrder(_x11) {
|
|
1452
1512
|
return _updateProductInOrder.apply(this, arguments);
|
|
1453
1513
|
}
|
|
1454
1514
|
return updateProductInOrder;
|
|
1455
1515
|
}()
|
|
1516
|
+
/**
|
|
1517
|
+
* 设置单行商品备注(与整单 `updateTempOrderNote` 区分)。
|
|
1518
|
+
* 多行同 SKU 时必须传入与删除/更新一致的 identity(如 `identity_key`)。
|
|
1519
|
+
*/
|
|
1520
|
+
}, {
|
|
1521
|
+
key: "setOrderProductLineNote",
|
|
1522
|
+
value: (function () {
|
|
1523
|
+
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(identity, note) {
|
|
1524
|
+
var params, products;
|
|
1525
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1526
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1527
|
+
case 0:
|
|
1528
|
+
this.logMethodStart('setOrderProductLineNote', {
|
|
1529
|
+
product_id: identity.product_id,
|
|
1530
|
+
product_variant_id: identity.product_variant_id
|
|
1531
|
+
});
|
|
1532
|
+
_context20.prev = 1;
|
|
1533
|
+
params = {
|
|
1534
|
+
product_id: identity.product_id,
|
|
1535
|
+
product_variant_id: identity.product_variant_id,
|
|
1536
|
+
updates: {
|
|
1537
|
+
note: String(note || '')
|
|
1538
|
+
}
|
|
1539
|
+
};
|
|
1540
|
+
if (identity.identity_key !== undefined) params.identity_key = identity.identity_key;
|
|
1541
|
+
if (identity.product_option_item !== undefined) {
|
|
1542
|
+
params.product_option_item = identity.product_option_item;
|
|
1543
|
+
}
|
|
1544
|
+
if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
|
|
1545
|
+
_context20.next = 8;
|
|
1546
|
+
return this.updateProductInOrder(params);
|
|
1547
|
+
case 8:
|
|
1548
|
+
products = _context20.sent;
|
|
1549
|
+
this.logMethodSuccess('setOrderProductLineNote', {
|
|
1550
|
+
productCount: products.length
|
|
1551
|
+
});
|
|
1552
|
+
return _context20.abrupt("return", products);
|
|
1553
|
+
case 13:
|
|
1554
|
+
_context20.prev = 13;
|
|
1555
|
+
_context20.t0 = _context20["catch"](1);
|
|
1556
|
+
this.logMethodError('setOrderProductLineNote', _context20.t0);
|
|
1557
|
+
throw _context20.t0;
|
|
1558
|
+
case 17:
|
|
1559
|
+
case "end":
|
|
1560
|
+
return _context20.stop();
|
|
1561
|
+
}
|
|
1562
|
+
}, _callee20, this, [[1, 13]]);
|
|
1563
|
+
}));
|
|
1564
|
+
function setOrderProductLineNote(_x12, _x13) {
|
|
1565
|
+
return _setOrderProductLineNote.apply(this, arguments);
|
|
1566
|
+
}
|
|
1567
|
+
return setOrderProductLineNote;
|
|
1568
|
+
}())
|
|
1456
1569
|
}, {
|
|
1457
1570
|
key: "removeProductFromOrder",
|
|
1458
1571
|
value: function () {
|
|
1459
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1572
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(identity) {
|
|
1460
1573
|
var products;
|
|
1461
|
-
return _regeneratorRuntime().wrap(function
|
|
1462
|
-
while (1) switch (
|
|
1574
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1575
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1463
1576
|
case 0:
|
|
1464
1577
|
this.logMethodStart('removeProductFromOrder', {
|
|
1465
1578
|
product_id: identity.product_id,
|
|
1466
1579
|
product_variant_id: identity.product_variant_id
|
|
1467
1580
|
});
|
|
1468
|
-
|
|
1581
|
+
_context21.prev = 1;
|
|
1469
1582
|
if (this.store.order) {
|
|
1470
|
-
|
|
1583
|
+
_context21.next = 4;
|
|
1471
1584
|
break;
|
|
1472
1585
|
}
|
|
1473
1586
|
throw new Error('order 模块未初始化');
|
|
1474
1587
|
case 4:
|
|
1475
|
-
|
|
1588
|
+
_context21.next = 6;
|
|
1476
1589
|
return this.store.order.removeProductFromOrder(identity);
|
|
1477
1590
|
case 6:
|
|
1478
|
-
products =
|
|
1479
|
-
|
|
1591
|
+
products = _context21.sent;
|
|
1592
|
+
_context21.next = 9;
|
|
1480
1593
|
return this.refreshItemRuleQuantityLimits();
|
|
1481
1594
|
case 9:
|
|
1482
|
-
|
|
1595
|
+
_context21.next = 11;
|
|
1483
1596
|
return this.refreshCartValidationPassed();
|
|
1484
1597
|
case 11:
|
|
1485
1598
|
this.logMethodSuccess('removeProductFromOrder', {
|
|
1486
1599
|
productCount: products.length
|
|
1487
1600
|
});
|
|
1488
|
-
return
|
|
1601
|
+
return _context21.abrupt("return", products);
|
|
1489
1602
|
case 15:
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
this.logMethodError('removeProductFromOrder',
|
|
1493
|
-
throw
|
|
1603
|
+
_context21.prev = 15;
|
|
1604
|
+
_context21.t0 = _context21["catch"](1);
|
|
1605
|
+
this.logMethodError('removeProductFromOrder', _context21.t0);
|
|
1606
|
+
throw _context21.t0;
|
|
1494
1607
|
case 19:
|
|
1495
1608
|
case "end":
|
|
1496
|
-
return
|
|
1609
|
+
return _context21.stop();
|
|
1497
1610
|
}
|
|
1498
|
-
},
|
|
1611
|
+
}, _callee21, this, [[1, 15]]);
|
|
1499
1612
|
}));
|
|
1500
|
-
function removeProductFromOrder(
|
|
1613
|
+
function removeProductFromOrder(_x14) {
|
|
1501
1614
|
return _removeProductFromOrder.apply(this, arguments);
|
|
1502
1615
|
}
|
|
1503
1616
|
return removeProductFromOrder;
|
|
@@ -1505,26 +1618,26 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1505
1618
|
}, {
|
|
1506
1619
|
key: "loadRuntimeConfigs",
|
|
1507
1620
|
value: function () {
|
|
1508
|
-
var _loadRuntimeConfigs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1621
|
+
var _loadRuntimeConfigs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
|
|
1509
1622
|
var itemRuleConfigs;
|
|
1510
|
-
return _regeneratorRuntime().wrap(function
|
|
1511
|
-
while (1) switch (
|
|
1623
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
1624
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1512
1625
|
case 0:
|
|
1513
|
-
|
|
1626
|
+
_context22.next = 2;
|
|
1514
1627
|
return this.ensureItemRuleConfigsLoaded();
|
|
1515
1628
|
case 2:
|
|
1516
|
-
itemRuleConfigs =
|
|
1629
|
+
itemRuleConfigs = _context22.sent;
|
|
1517
1630
|
this.logMethodSuccess('loadRuntimeConfigs', {
|
|
1518
1631
|
itemRuleCount: itemRuleConfigs.length
|
|
1519
1632
|
});
|
|
1520
|
-
return
|
|
1633
|
+
return _context22.abrupt("return", {
|
|
1521
1634
|
itemRuleConfigs: itemRuleConfigs
|
|
1522
1635
|
});
|
|
1523
1636
|
case 5:
|
|
1524
1637
|
case "end":
|
|
1525
|
-
return
|
|
1638
|
+
return _context22.stop();
|
|
1526
1639
|
}
|
|
1527
|
-
},
|
|
1640
|
+
}, _callee22, this);
|
|
1528
1641
|
}));
|
|
1529
1642
|
function loadRuntimeConfigs() {
|
|
1530
1643
|
return _loadRuntimeConfigs.apply(this, arguments);
|
|
@@ -1534,15 +1647,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1534
1647
|
}, {
|
|
1535
1648
|
key: "syncItemRuleConfigsFromDineInConfig",
|
|
1536
1649
|
value: function () {
|
|
1537
|
-
var _syncItemRuleConfigsFromDineInConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1650
|
+
var _syncItemRuleConfigsFromDineInConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(dineInConfig) {
|
|
1538
1651
|
var enableItemRules, strategyModelIds, itemRuleConfigs;
|
|
1539
|
-
return _regeneratorRuntime().wrap(function
|
|
1540
|
-
while (1) switch (
|
|
1652
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
1653
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1541
1654
|
case 0:
|
|
1542
1655
|
enableItemRules = toBoolean(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['sale.enable_item_rules']);
|
|
1543
1656
|
strategyModelIds = normalizeEnabledItemRuleIds(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['sale.enabled_item_rules']);
|
|
1544
1657
|
if (!(!enableItemRules || !strategyModelIds.length)) {
|
|
1545
|
-
|
|
1658
|
+
_context23.next = 8;
|
|
1546
1659
|
break;
|
|
1547
1660
|
}
|
|
1548
1661
|
this.itemRuleConfigs = [];
|
|
@@ -1553,12 +1666,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1553
1666
|
strategyModelIds: [],
|
|
1554
1667
|
itemRuleCount: 0
|
|
1555
1668
|
});
|
|
1556
|
-
return
|
|
1669
|
+
return _context23.abrupt("return", []);
|
|
1557
1670
|
case 8:
|
|
1558
|
-
|
|
1671
|
+
_context23.next = 10;
|
|
1559
1672
|
return this.fetchItemRuleConfigsByModelIds(strategyModelIds);
|
|
1560
1673
|
case 10:
|
|
1561
|
-
itemRuleConfigs =
|
|
1674
|
+
itemRuleConfigs = _context23.sent;
|
|
1562
1675
|
this.itemRuleConfigs = itemRuleConfigs;
|
|
1563
1676
|
this.itemRuleConfigsPromise = Promise.resolve(itemRuleConfigs);
|
|
1564
1677
|
this.itemRuleEvaluator.setStrategyConfigs(itemRuleConfigs);
|
|
@@ -1567,14 +1680,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1567
1680
|
strategyModelIds: strategyModelIds,
|
|
1568
1681
|
itemRuleCount: itemRuleConfigs.length
|
|
1569
1682
|
});
|
|
1570
|
-
return
|
|
1683
|
+
return _context23.abrupt("return", itemRuleConfigs);
|
|
1571
1684
|
case 16:
|
|
1572
1685
|
case "end":
|
|
1573
|
-
return
|
|
1686
|
+
return _context23.stop();
|
|
1574
1687
|
}
|
|
1575
|
-
},
|
|
1688
|
+
}, _callee23, this);
|
|
1576
1689
|
}));
|
|
1577
|
-
function syncItemRuleConfigsFromDineInConfig(
|
|
1690
|
+
function syncItemRuleConfigsFromDineInConfig(_x15) {
|
|
1578
1691
|
return _syncItemRuleConfigsFromDineInConfig.apply(this, arguments);
|
|
1579
1692
|
}
|
|
1580
1693
|
return syncItemRuleConfigsFromDineInConfig;
|
|
@@ -1582,22 +1695,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1582
1695
|
}, {
|
|
1583
1696
|
key: "fetchItemRuleConfigsByModelIds",
|
|
1584
1697
|
value: function () {
|
|
1585
|
-
var _fetchItemRuleConfigsByModelIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1698
|
+
var _fetchItemRuleConfigsByModelIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(strategyModelIds) {
|
|
1586
1699
|
var result, configs;
|
|
1587
|
-
return _regeneratorRuntime().wrap(function
|
|
1588
|
-
while (1) switch (
|
|
1700
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
1701
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1589
1702
|
case 0:
|
|
1590
1703
|
this.logMethodStart('fetchItemRuleConfigsByModelIds', {
|
|
1591
1704
|
strategyModelIds: strategyModelIds
|
|
1592
1705
|
});
|
|
1593
1706
|
if (strategyModelIds.length) {
|
|
1594
|
-
|
|
1707
|
+
_context24.next = 3;
|
|
1595
1708
|
break;
|
|
1596
1709
|
}
|
|
1597
|
-
return
|
|
1710
|
+
return _context24.abrupt("return", []);
|
|
1598
1711
|
case 3:
|
|
1599
|
-
|
|
1600
|
-
|
|
1712
|
+
_context24.prev = 3;
|
|
1713
|
+
_context24.next = 6;
|
|
1601
1714
|
return this.request.get('/promotion', {
|
|
1602
1715
|
skip: 1,
|
|
1603
1716
|
num: 99,
|
|
@@ -1605,7 +1718,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1605
1718
|
ids: strategyModelIds
|
|
1606
1719
|
});
|
|
1607
1720
|
case 6:
|
|
1608
|
-
result =
|
|
1721
|
+
result = _context24.sent;
|
|
1609
1722
|
configs = [];
|
|
1610
1723
|
if (result.code === 200) {
|
|
1611
1724
|
configs = result.data.list.map(function (item) {
|
|
@@ -1616,22 +1729,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1616
1729
|
strategyModelIds: strategyModelIds,
|
|
1617
1730
|
strategyCount: configs.length
|
|
1618
1731
|
});
|
|
1619
|
-
return
|
|
1732
|
+
return _context24.abrupt("return", configs);
|
|
1620
1733
|
case 13:
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
this.logMethodError('fetchItemRuleConfigsByModelIds',
|
|
1734
|
+
_context24.prev = 13;
|
|
1735
|
+
_context24.t0 = _context24["catch"](3);
|
|
1736
|
+
this.logMethodError('fetchItemRuleConfigsByModelIds', _context24.t0, {
|
|
1624
1737
|
strategyModelIds: strategyModelIds
|
|
1625
1738
|
});
|
|
1626
1739
|
// A:策略加载失败时不阻塞下单
|
|
1627
|
-
return
|
|
1740
|
+
return _context24.abrupt("return", []);
|
|
1628
1741
|
case 17:
|
|
1629
1742
|
case "end":
|
|
1630
|
-
return
|
|
1743
|
+
return _context24.stop();
|
|
1631
1744
|
}
|
|
1632
|
-
},
|
|
1745
|
+
}, _callee24, this, [[3, 13]]);
|
|
1633
1746
|
}));
|
|
1634
|
-
function fetchItemRuleConfigsByModelIds(
|
|
1747
|
+
function fetchItemRuleConfigsByModelIds(_x16) {
|
|
1635
1748
|
return _fetchItemRuleConfigsByModelIds.apply(this, arguments);
|
|
1636
1749
|
}
|
|
1637
1750
|
return fetchItemRuleConfigsByModelIds;
|
|
@@ -1639,22 +1752,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1639
1752
|
}, {
|
|
1640
1753
|
key: "buildPrefillProductSourceMap",
|
|
1641
1754
|
value: function () {
|
|
1642
|
-
var _buildPrefillProductSourceMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1755
|
+
var _buildPrefillProductSourceMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
|
|
1643
1756
|
var sourceMap, productList, visited, collectFromValue;
|
|
1644
|
-
return _regeneratorRuntime().wrap(function
|
|
1645
|
-
while (1) switch (
|
|
1757
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
1758
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
1646
1759
|
case 0:
|
|
1647
1760
|
sourceMap = new Map();
|
|
1648
|
-
|
|
1649
|
-
|
|
1761
|
+
_context25.prev = 1;
|
|
1762
|
+
_context25.next = 4;
|
|
1650
1763
|
return this.getProductList();
|
|
1651
1764
|
case 4:
|
|
1652
|
-
productList =
|
|
1765
|
+
productList = _context25.sent;
|
|
1653
1766
|
if (Array.isArray(productList)) {
|
|
1654
|
-
|
|
1767
|
+
_context25.next = 7;
|
|
1655
1768
|
break;
|
|
1656
1769
|
}
|
|
1657
|
-
return
|
|
1770
|
+
return _context25.abrupt("return", sourceMap);
|
|
1658
1771
|
case 7:
|
|
1659
1772
|
visited = new Set();
|
|
1660
1773
|
collectFromValue = function collectFromValue(value) {
|
|
@@ -1689,27 +1802,27 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1689
1802
|
sourceMap.set(key, node);
|
|
1690
1803
|
}
|
|
1691
1804
|
}
|
|
1692
|
-
for (var
|
|
1693
|
-
var childValue = _Object$values[
|
|
1805
|
+
for (var _i3 = 0, _Object$values = Object.values(node); _i3 < _Object$values.length; _i3++) {
|
|
1806
|
+
var childValue = _Object$values[_i3];
|
|
1694
1807
|
if (childValue && _typeof(childValue) === 'object') {
|
|
1695
1808
|
collectFromValue(childValue);
|
|
1696
1809
|
}
|
|
1697
1810
|
}
|
|
1698
1811
|
};
|
|
1699
1812
|
collectFromValue(productList);
|
|
1700
|
-
|
|
1813
|
+
_context25.next = 15;
|
|
1701
1814
|
break;
|
|
1702
1815
|
case 12:
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
this.logMethodError('buildPrefillProductSourceMap',
|
|
1816
|
+
_context25.prev = 12;
|
|
1817
|
+
_context25.t0 = _context25["catch"](1);
|
|
1818
|
+
this.logMethodError('buildPrefillProductSourceMap', _context25.t0);
|
|
1706
1819
|
case 15:
|
|
1707
|
-
return
|
|
1820
|
+
return _context25.abrupt("return", sourceMap);
|
|
1708
1821
|
case 16:
|
|
1709
1822
|
case "end":
|
|
1710
|
-
return
|
|
1823
|
+
return _context25.stop();
|
|
1711
1824
|
}
|
|
1712
|
-
},
|
|
1825
|
+
}, _callee25, this, [[1, 12]]);
|
|
1713
1826
|
}));
|
|
1714
1827
|
function buildPrefillProductSourceMap() {
|
|
1715
1828
|
return _buildPrefillProductSourceMap.apply(this, arguments);
|
|
@@ -1724,58 +1837,58 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1724
1837
|
}, {
|
|
1725
1838
|
key: "ensureItemRuleConfigsLoaded",
|
|
1726
1839
|
value: function () {
|
|
1727
|
-
var _ensureItemRuleConfigsLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1840
|
+
var _ensureItemRuleConfigsLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
|
|
1728
1841
|
var _this6 = this;
|
|
1729
1842
|
var loadedConfigs;
|
|
1730
|
-
return _regeneratorRuntime().wrap(function
|
|
1731
|
-
while (1) switch (
|
|
1843
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
1844
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
1732
1845
|
case 0:
|
|
1733
1846
|
if (!(this.itemRuleConfigs.length > 0)) {
|
|
1734
|
-
|
|
1847
|
+
_context27.next = 2;
|
|
1735
1848
|
break;
|
|
1736
1849
|
}
|
|
1737
|
-
return
|
|
1850
|
+
return _context27.abrupt("return", this.itemRuleConfigs);
|
|
1738
1851
|
case 2:
|
|
1739
1852
|
if (!this.itemRuleConfigsPromise) {
|
|
1740
|
-
|
|
1853
|
+
_context27.next = 4;
|
|
1741
1854
|
break;
|
|
1742
1855
|
}
|
|
1743
|
-
return
|
|
1856
|
+
return _context27.abrupt("return", this.itemRuleConfigsPromise);
|
|
1744
1857
|
case 4:
|
|
1745
|
-
this.itemRuleConfigsPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1858
|
+
this.itemRuleConfigsPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
|
|
1746
1859
|
var runtimeConfig, staticConfigs;
|
|
1747
|
-
return _regeneratorRuntime().wrap(function
|
|
1748
|
-
while (1) switch (
|
|
1860
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
1861
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
1749
1862
|
case 0:
|
|
1750
1863
|
runtimeConfig = _this6.getItemRuleRuntimeConfig();
|
|
1751
1864
|
staticConfigs = normalizeItemRuleStrategies(runtimeConfig.strategyConfigs);
|
|
1752
1865
|
if (!(staticConfigs.length > 0)) {
|
|
1753
|
-
|
|
1866
|
+
_context26.next = 6;
|
|
1754
1867
|
break;
|
|
1755
1868
|
}
|
|
1756
1869
|
_this6.itemRuleConfigs = staticConfigs;
|
|
1757
1870
|
_this6.itemRuleEvaluator.setStrategyConfigs(staticConfigs);
|
|
1758
|
-
return
|
|
1871
|
+
return _context26.abrupt("return", _this6.itemRuleConfigs);
|
|
1759
1872
|
case 6:
|
|
1760
1873
|
_this6.itemRuleConfigs = [];
|
|
1761
1874
|
_this6.itemRuleEvaluator.setStrategyConfigs([]);
|
|
1762
|
-
return
|
|
1875
|
+
return _context26.abrupt("return", _this6.itemRuleConfigs);
|
|
1763
1876
|
case 9:
|
|
1764
1877
|
case "end":
|
|
1765
|
-
return
|
|
1878
|
+
return _context26.stop();
|
|
1766
1879
|
}
|
|
1767
|
-
},
|
|
1880
|
+
}, _callee26);
|
|
1768
1881
|
}))();
|
|
1769
|
-
|
|
1882
|
+
_context27.next = 7;
|
|
1770
1883
|
return this.itemRuleConfigsPromise;
|
|
1771
1884
|
case 7:
|
|
1772
|
-
loadedConfigs =
|
|
1773
|
-
return
|
|
1885
|
+
loadedConfigs = _context27.sent;
|
|
1886
|
+
return _context27.abrupt("return", loadedConfigs);
|
|
1774
1887
|
case 9:
|
|
1775
1888
|
case "end":
|
|
1776
|
-
return
|
|
1889
|
+
return _context27.stop();
|
|
1777
1890
|
}
|
|
1778
|
-
},
|
|
1891
|
+
}, _callee27, this);
|
|
1779
1892
|
}));
|
|
1780
1893
|
function ensureItemRuleConfigsLoaded() {
|
|
1781
1894
|
return _ensureItemRuleConfigsLoaded.apply(this, arguments);
|
|
@@ -1785,22 +1898,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1785
1898
|
}, {
|
|
1786
1899
|
key: "refreshItemRuleQuantityLimits",
|
|
1787
1900
|
value: function () {
|
|
1788
|
-
var _refreshItemRuleQuantityLimits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1901
|
+
var _refreshItemRuleQuantityLimits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
|
|
1789
1902
|
var strategyConfigs, businessData, limits;
|
|
1790
|
-
return _regeneratorRuntime().wrap(function
|
|
1791
|
-
while (1) switch (
|
|
1903
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
1904
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
1792
1905
|
case 0:
|
|
1793
|
-
|
|
1794
|
-
|
|
1906
|
+
_context28.prev = 0;
|
|
1907
|
+
_context28.next = 3;
|
|
1795
1908
|
return this.ensureItemRuleConfigsLoaded();
|
|
1796
1909
|
case 3:
|
|
1797
|
-
strategyConfigs =
|
|
1910
|
+
strategyConfigs = _context28.sent;
|
|
1798
1911
|
if (strategyConfigs.length) {
|
|
1799
|
-
|
|
1912
|
+
_context28.next = 7;
|
|
1800
1913
|
break;
|
|
1801
1914
|
}
|
|
1802
1915
|
this.store.itemRuleQuantityLimits = [];
|
|
1803
|
-
return
|
|
1916
|
+
return _context28.abrupt("return", []);
|
|
1804
1917
|
case 7:
|
|
1805
1918
|
businessData = buildItemRuleBusinessData({
|
|
1806
1919
|
tempOrder: this.ensureTempOrder(),
|
|
@@ -1812,18 +1925,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1812
1925
|
this.logMethodSuccess('refreshItemRuleQuantityLimits', {
|
|
1813
1926
|
limitCount: limits.length
|
|
1814
1927
|
});
|
|
1815
|
-
return
|
|
1928
|
+
return _context28.abrupt("return", limits);
|
|
1816
1929
|
case 14:
|
|
1817
|
-
|
|
1818
|
-
|
|
1930
|
+
_context28.prev = 14;
|
|
1931
|
+
_context28.t0 = _context28["catch"](0);
|
|
1819
1932
|
this.store.itemRuleQuantityLimits = [];
|
|
1820
|
-
this.logMethodError('refreshItemRuleQuantityLimits',
|
|
1821
|
-
return
|
|
1933
|
+
this.logMethodError('refreshItemRuleQuantityLimits', _context28.t0);
|
|
1934
|
+
return _context28.abrupt("return", []);
|
|
1822
1935
|
case 19:
|
|
1823
1936
|
case "end":
|
|
1824
|
-
return
|
|
1937
|
+
return _context28.stop();
|
|
1825
1938
|
}
|
|
1826
|
-
},
|
|
1939
|
+
}, _callee28, this, [[0, 14]]);
|
|
1827
1940
|
}));
|
|
1828
1941
|
function refreshItemRuleQuantityLimits() {
|
|
1829
1942
|
return _refreshItemRuleQuantityLimits.apply(this, arguments);
|
|
@@ -1833,32 +1946,32 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1833
1946
|
}, {
|
|
1834
1947
|
key: "applyPrefillByItemRule",
|
|
1835
1948
|
value: function () {
|
|
1836
|
-
var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1949
|
+
var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
|
|
1837
1950
|
var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges, _iterator5, _step5, _prefillItem$product_, _targetProduct$_origi, _targetProduct$_origi2, _targetProduct$_origi3, prefillItem, productId, productVariantId, targetQuantity, sourceItem, productIndex, _sourceItem$price, sellingPrice, targetProduct, existedQuantity, delta, nextProduct, hasQuantityChanged, hasOriginChanged;
|
|
1838
|
-
return _regeneratorRuntime().wrap(function
|
|
1839
|
-
while (1) switch (
|
|
1951
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
1952
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
1840
1953
|
case 0:
|
|
1841
1954
|
if (!this.itemRulePrefillApplied) {
|
|
1842
|
-
|
|
1955
|
+
_context29.next = 2;
|
|
1843
1956
|
break;
|
|
1844
1957
|
}
|
|
1845
|
-
return
|
|
1958
|
+
return _context29.abrupt("return");
|
|
1846
1959
|
case 2:
|
|
1847
1960
|
if (this.store.order) {
|
|
1848
|
-
|
|
1961
|
+
_context29.next = 4;
|
|
1849
1962
|
break;
|
|
1850
1963
|
}
|
|
1851
|
-
return
|
|
1964
|
+
return _context29.abrupt("return");
|
|
1852
1965
|
case 4:
|
|
1853
|
-
|
|
1966
|
+
_context29.next = 6;
|
|
1854
1967
|
return this.ensureItemRuleConfigsLoaded();
|
|
1855
1968
|
case 6:
|
|
1856
|
-
strategyConfigs =
|
|
1969
|
+
strategyConfigs = _context29.sent;
|
|
1857
1970
|
if (strategyConfigs.length) {
|
|
1858
|
-
|
|
1971
|
+
_context29.next = 9;
|
|
1859
1972
|
break;
|
|
1860
1973
|
}
|
|
1861
|
-
return
|
|
1974
|
+
return _context29.abrupt("return");
|
|
1862
1975
|
case 9:
|
|
1863
1976
|
businessData = buildItemRuleBusinessData({
|
|
1864
1977
|
tempOrder: this.ensureTempOrder(),
|
|
@@ -1867,24 +1980,24 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1867
1980
|
});
|
|
1868
1981
|
prefillItems = this.itemRuleEvaluator.getPrefillItems(businessData);
|
|
1869
1982
|
if (prefillItems.length) {
|
|
1870
|
-
|
|
1983
|
+
_context29.next = 14;
|
|
1871
1984
|
break;
|
|
1872
1985
|
}
|
|
1873
1986
|
this.itemRulePrefillApplied = true;
|
|
1874
|
-
return
|
|
1987
|
+
return _context29.abrupt("return");
|
|
1875
1988
|
case 14:
|
|
1876
|
-
|
|
1989
|
+
_context29.next = 16;
|
|
1877
1990
|
return this.buildPrefillProductSourceMap();
|
|
1878
1991
|
case 16:
|
|
1879
|
-
productSourceMap =
|
|
1992
|
+
productSourceMap = _context29.sent;
|
|
1880
1993
|
tempOrder = this.ensureTempOrder();
|
|
1881
1994
|
hasChanges = false;
|
|
1882
1995
|
_iterator5 = _createForOfIteratorHelper(prefillItems);
|
|
1883
|
-
|
|
1996
|
+
_context29.prev = 20;
|
|
1884
1997
|
_iterator5.s();
|
|
1885
1998
|
case 22:
|
|
1886
1999
|
if ((_step5 = _iterator5.n()).done) {
|
|
1887
|
-
|
|
2000
|
+
_context29.next = 47;
|
|
1888
2001
|
break;
|
|
1889
2002
|
}
|
|
1890
2003
|
prefillItem = _step5.value;
|
|
@@ -1892,16 +2005,16 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1892
2005
|
productVariantId = Number((_prefillItem$product_ = prefillItem.product_variant_id) !== null && _prefillItem$product_ !== void 0 ? _prefillItem$product_ : 0);
|
|
1893
2006
|
targetQuantity = toNonNegativeInt(prefillItem.quantity);
|
|
1894
2007
|
if (!(!Number.isFinite(productId) || targetQuantity <= 0)) {
|
|
1895
|
-
|
|
2008
|
+
_context29.next = 29;
|
|
1896
2009
|
break;
|
|
1897
2010
|
}
|
|
1898
|
-
return
|
|
2011
|
+
return _context29.abrupt("continue", 45);
|
|
1899
2012
|
case 29:
|
|
1900
2013
|
if (!Number.isNaN(productVariantId)) {
|
|
1901
|
-
|
|
2014
|
+
_context29.next = 31;
|
|
1902
2015
|
break;
|
|
1903
2016
|
}
|
|
1904
|
-
return
|
|
2017
|
+
return _context29.abrupt("continue", 45);
|
|
1905
2018
|
case 31:
|
|
1906
2019
|
sourceItem = productSourceMap.get(buildProductKey(productId, productVariantId)) || productSourceMap.get(buildProductKey(productId, 0)) || null;
|
|
1907
2020
|
productIndex = getProductIdentityIndex(tempOrder.products, {
|
|
@@ -1909,7 +2022,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1909
2022
|
product_variant_id: productVariantId
|
|
1910
2023
|
});
|
|
1911
2024
|
if (!(productIndex === -1)) {
|
|
1912
|
-
|
|
2025
|
+
_context29.next = 38;
|
|
1913
2026
|
break;
|
|
1914
2027
|
}
|
|
1915
2028
|
sellingPrice = toPriceString((_sourceItem$price = sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.price) !== null && _sourceItem$price !== void 0 ? _sourceItem$price : sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.selling_price, '0.00');
|
|
@@ -1929,7 +2042,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1929
2042
|
})
|
|
1930
2043
|
})));
|
|
1931
2044
|
hasChanges = true;
|
|
1932
|
-
return
|
|
2045
|
+
return _context29.abrupt("continue", 45);
|
|
1933
2046
|
case 38:
|
|
1934
2047
|
targetProduct = tempOrder.products[productIndex];
|
|
1935
2048
|
existedQuantity = toNonNegativeInt(targetProduct.num);
|
|
@@ -1950,34 +2063,34 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1950
2063
|
hasChanges = true;
|
|
1951
2064
|
}
|
|
1952
2065
|
case 45:
|
|
1953
|
-
|
|
2066
|
+
_context29.next = 22;
|
|
1954
2067
|
break;
|
|
1955
2068
|
case 47:
|
|
1956
|
-
|
|
2069
|
+
_context29.next = 52;
|
|
1957
2070
|
break;
|
|
1958
2071
|
case 49:
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
_iterator5.e(
|
|
2072
|
+
_context29.prev = 49;
|
|
2073
|
+
_context29.t0 = _context29["catch"](20);
|
|
2074
|
+
_iterator5.e(_context29.t0);
|
|
1962
2075
|
case 52:
|
|
1963
|
-
|
|
2076
|
+
_context29.prev = 52;
|
|
1964
2077
|
_iterator5.f();
|
|
1965
|
-
return
|
|
2078
|
+
return _context29.finish(52);
|
|
1966
2079
|
case 55:
|
|
1967
2080
|
if (!hasChanges) {
|
|
1968
|
-
|
|
2081
|
+
_context29.next = 60;
|
|
1969
2082
|
break;
|
|
1970
2083
|
}
|
|
1971
2084
|
// Prefill 属于 products CRUD 的一种形式:新增后让 Rules 重算,以支持自动应用可用优惠券。
|
|
1972
2085
|
this.store.order.applyDiscount();
|
|
1973
|
-
|
|
2086
|
+
_context29.next = 59;
|
|
1974
2087
|
return this.store.order.recalculateSummary({
|
|
1975
2088
|
createIfMissing: true
|
|
1976
2089
|
});
|
|
1977
2090
|
case 59:
|
|
1978
2091
|
this.store.order.persistTempOrder();
|
|
1979
2092
|
case 60:
|
|
1980
|
-
|
|
2093
|
+
_context29.next = 62;
|
|
1981
2094
|
return this.refreshItemRuleQuantityLimits();
|
|
1982
2095
|
case 62:
|
|
1983
2096
|
this.itemRulePrefillApplied = true;
|
|
@@ -1987,9 +2100,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1987
2100
|
});
|
|
1988
2101
|
case 64:
|
|
1989
2102
|
case "end":
|
|
1990
|
-
return
|
|
2103
|
+
return _context29.stop();
|
|
1991
2104
|
}
|
|
1992
|
-
},
|
|
2105
|
+
}, _callee29, this, [[20, 49, 52, 55]]);
|
|
1993
2106
|
}));
|
|
1994
2107
|
function applyPrefillByItemRule() {
|
|
1995
2108
|
return _applyPrefillByItemRule.apply(this, arguments);
|
|
@@ -1999,31 +2112,31 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1999
2112
|
}, {
|
|
2000
2113
|
key: "applyItemRulePrefill",
|
|
2001
2114
|
value: function () {
|
|
2002
|
-
var _applyItemRulePrefill = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2115
|
+
var _applyItemRulePrefill = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
|
|
2003
2116
|
var _this$store$order4, _this$store$order4$ge;
|
|
2004
|
-
return _regeneratorRuntime().wrap(function
|
|
2005
|
-
while (1) switch (
|
|
2117
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
2118
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
2006
2119
|
case 0:
|
|
2007
2120
|
if (!((_this$store$order4 = this.store.order) !== null && _this$store$order4 !== void 0 && (_this$store$order4$ge = _this$store$order4.getLastOrderInfo) !== null && _this$store$order4$ge !== void 0 && _this$store$order4$ge.call(_this$store$order4))) {
|
|
2008
|
-
|
|
2121
|
+
_context30.next = 2;
|
|
2009
2122
|
break;
|
|
2010
2123
|
}
|
|
2011
|
-
return
|
|
2124
|
+
return _context30.abrupt("return");
|
|
2012
2125
|
case 2:
|
|
2013
2126
|
this.logMethodStart('applyItemRulePrefill');
|
|
2014
|
-
|
|
2127
|
+
_context30.next = 5;
|
|
2015
2128
|
return this.applyPrefillByItemRule();
|
|
2016
2129
|
case 5:
|
|
2017
|
-
|
|
2130
|
+
_context30.next = 7;
|
|
2018
2131
|
return this.refreshItemRuleQuantityLimits();
|
|
2019
2132
|
case 7:
|
|
2020
|
-
|
|
2133
|
+
_context30.next = 9;
|
|
2021
2134
|
return this.refreshCartValidationPassed();
|
|
2022
2135
|
case 9:
|
|
2023
2136
|
case "end":
|
|
2024
|
-
return
|
|
2137
|
+
return _context30.stop();
|
|
2025
2138
|
}
|
|
2026
|
-
},
|
|
2139
|
+
}, _callee30, this);
|
|
2027
2140
|
}));
|
|
2028
2141
|
function applyItemRulePrefill() {
|
|
2029
2142
|
return _applyItemRulePrefill.apply(this, arguments);
|
|
@@ -2033,20 +2146,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2033
2146
|
}, {
|
|
2034
2147
|
key: "evaluateCartValidationByItemRule",
|
|
2035
2148
|
value: function () {
|
|
2036
|
-
var _evaluateCartValidationByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2149
|
+
var _evaluateCartValidationByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
|
|
2037
2150
|
var strategyConfigs, businessData;
|
|
2038
|
-
return _regeneratorRuntime().wrap(function
|
|
2039
|
-
while (1) switch (
|
|
2151
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
2152
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
2040
2153
|
case 0:
|
|
2041
|
-
|
|
2154
|
+
_context31.next = 2;
|
|
2042
2155
|
return this.ensureItemRuleConfigsLoaded();
|
|
2043
2156
|
case 2:
|
|
2044
|
-
strategyConfigs =
|
|
2157
|
+
strategyConfigs = _context31.sent;
|
|
2045
2158
|
if (strategyConfigs.length) {
|
|
2046
|
-
|
|
2159
|
+
_context31.next = 5;
|
|
2047
2160
|
break;
|
|
2048
2161
|
}
|
|
2049
|
-
return
|
|
2162
|
+
return _context31.abrupt("return", {
|
|
2050
2163
|
passed: true,
|
|
2051
2164
|
failures: []
|
|
2052
2165
|
});
|
|
@@ -2056,12 +2169,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2056
2169
|
runtimeConfig: this.getItemRuleRuntimeConfig(),
|
|
2057
2170
|
itemRuleConfigs: this.itemRuleConfigs
|
|
2058
2171
|
});
|
|
2059
|
-
return
|
|
2172
|
+
return _context31.abrupt("return", this.itemRuleEvaluator.validateCart(businessData));
|
|
2060
2173
|
case 7:
|
|
2061
2174
|
case "end":
|
|
2062
|
-
return
|
|
2175
|
+
return _context31.stop();
|
|
2063
2176
|
}
|
|
2064
|
-
},
|
|
2177
|
+
}, _callee31, this);
|
|
2065
2178
|
}));
|
|
2066
2179
|
function evaluateCartValidationByItemRule() {
|
|
2067
2180
|
return _evaluateCartValidationByItemRule.apply(this, arguments);
|
|
@@ -2071,20 +2184,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2071
2184
|
}, {
|
|
2072
2185
|
key: "validateBeforeSubmitByItemRule",
|
|
2073
2186
|
value: function () {
|
|
2074
|
-
var _validateBeforeSubmitByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2187
|
+
var _validateBeforeSubmitByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
|
|
2075
2188
|
var validationResult, firstFailure, errorMessage, error;
|
|
2076
|
-
return _regeneratorRuntime().wrap(function
|
|
2077
|
-
while (1) switch (
|
|
2189
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
2190
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
2078
2191
|
case 0:
|
|
2079
|
-
|
|
2192
|
+
_context32.next = 2;
|
|
2080
2193
|
return this.evaluateCartValidationByItemRule();
|
|
2081
2194
|
case 2:
|
|
2082
|
-
validationResult =
|
|
2195
|
+
validationResult = _context32.sent;
|
|
2083
2196
|
if (!validationResult.passed) {
|
|
2084
|
-
|
|
2197
|
+
_context32.next = 5;
|
|
2085
2198
|
break;
|
|
2086
2199
|
}
|
|
2087
|
-
return
|
|
2200
|
+
return _context32.abrupt("return");
|
|
2088
2201
|
case 5:
|
|
2089
2202
|
firstFailure = validationResult.failures[0];
|
|
2090
2203
|
errorMessage = (firstFailure === null || firstFailure === void 0 ? void 0 : firstFailure.validationMessage) || '当前购物车未满足商品规则,请调整后再提交';
|
|
@@ -2093,9 +2206,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2093
2206
|
throw error;
|
|
2094
2207
|
case 10:
|
|
2095
2208
|
case "end":
|
|
2096
|
-
return
|
|
2209
|
+
return _context32.stop();
|
|
2097
2210
|
}
|
|
2098
|
-
},
|
|
2211
|
+
}, _callee32, this);
|
|
2099
2212
|
}));
|
|
2100
2213
|
function validateBeforeSubmitByItemRule() {
|
|
2101
2214
|
return _validateBeforeSubmitByItemRule.apply(this, arguments);
|
|
@@ -2105,10 +2218,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2105
2218
|
}, {
|
|
2106
2219
|
key: "refreshCartValidationPassed",
|
|
2107
2220
|
value: function () {
|
|
2108
|
-
var _refreshCartValidationPassed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2221
|
+
var _refreshCartValidationPassed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
|
|
2109
2222
|
var previous, nextState, validationResult, changed;
|
|
2110
|
-
return _regeneratorRuntime().wrap(function
|
|
2111
|
-
while (1) switch (
|
|
2223
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
2224
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
2112
2225
|
case 0:
|
|
2113
2226
|
previous = this.store.cartValidation || {
|
|
2114
2227
|
passed: null,
|
|
@@ -2118,20 +2231,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2118
2231
|
passed: null,
|
|
2119
2232
|
failures: []
|
|
2120
2233
|
};
|
|
2121
|
-
|
|
2122
|
-
|
|
2234
|
+
_context33.prev = 2;
|
|
2235
|
+
_context33.next = 5;
|
|
2123
2236
|
return this.evaluateCartValidationByItemRule();
|
|
2124
2237
|
case 5:
|
|
2125
|
-
validationResult =
|
|
2238
|
+
validationResult = _context33.sent;
|
|
2126
2239
|
nextState = {
|
|
2127
2240
|
passed: validationResult.passed,
|
|
2128
2241
|
failures: validationResult.failures || []
|
|
2129
2242
|
};
|
|
2130
|
-
|
|
2243
|
+
_context33.next = 12;
|
|
2131
2244
|
break;
|
|
2132
2245
|
case 9:
|
|
2133
|
-
|
|
2134
|
-
|
|
2246
|
+
_context33.prev = 9;
|
|
2247
|
+
_context33.t0 = _context33["catch"](2);
|
|
2135
2248
|
nextState = {
|
|
2136
2249
|
passed: false,
|
|
2137
2250
|
failures: []
|
|
@@ -2140,21 +2253,21 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2140
2253
|
this.store.cartValidation = nextState;
|
|
2141
2254
|
changed = previous.passed !== nextState.passed || previous.failures !== nextState.failures;
|
|
2142
2255
|
if (!changed) {
|
|
2143
|
-
|
|
2256
|
+
_context33.next = 17;
|
|
2144
2257
|
break;
|
|
2145
2258
|
}
|
|
2146
|
-
|
|
2259
|
+
_context33.next = 17;
|
|
2147
2260
|
return this.core.effects.emit(ScanOrderHooks.onCartValidationChanged, {
|
|
2148
2261
|
cartValidation: nextState,
|
|
2149
2262
|
cartValidationPassed: nextState.passed
|
|
2150
2263
|
});
|
|
2151
2264
|
case 17:
|
|
2152
|
-
return
|
|
2265
|
+
return _context33.abrupt("return", nextState.passed);
|
|
2153
2266
|
case 18:
|
|
2154
2267
|
case "end":
|
|
2155
|
-
return
|
|
2268
|
+
return _context33.stop();
|
|
2156
2269
|
}
|
|
2157
|
-
},
|
|
2270
|
+
}, _callee33, this, [[2, 9]]);
|
|
2158
2271
|
}));
|
|
2159
2272
|
function refreshCartValidationPassed() {
|
|
2160
2273
|
return _refreshCartValidationPassed.apply(this, arguments);
|
|
@@ -2164,14 +2277,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2164
2277
|
}, {
|
|
2165
2278
|
key: "setItemRuleRuntimeConfig",
|
|
2166
2279
|
value: function () {
|
|
2167
|
-
var _setItemRuleRuntimeConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2280
|
+
var _setItemRuleRuntimeConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
|
|
2168
2281
|
var _this$itemRuleRuntime, _this$itemRuleRuntime2;
|
|
2169
2282
|
var config,
|
|
2170
|
-
|
|
2171
|
-
return _regeneratorRuntime().wrap(function
|
|
2172
|
-
while (1) switch (
|
|
2283
|
+
_args34 = arguments;
|
|
2284
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
2285
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
2173
2286
|
case 0:
|
|
2174
|
-
config =
|
|
2287
|
+
config = _args34.length > 0 && _args34[0] !== undefined ? _args34[0] : {};
|
|
2175
2288
|
this.logMethodStart('setItemRuleRuntimeConfig');
|
|
2176
2289
|
this.itemRuleRuntimeConfig = _objectSpread(_objectSpread(_objectSpread({}, this.itemRuleRuntimeConfig), config), {}, {
|
|
2177
2290
|
pax: _objectSpread(_objectSpread({}, ((_this$itemRuleRuntime = this.itemRuleRuntimeConfig) === null || _this$itemRuleRuntime === void 0 ? void 0 : _this$itemRuleRuntime.pax) || {}), (config === null || config === void 0 ? void 0 : config.pax) || {}),
|
|
@@ -2183,10 +2296,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2183
2296
|
this.itemRuleEvaluator.setStrategyConfigs([]);
|
|
2184
2297
|
}
|
|
2185
2298
|
this.itemRulePrefillApplied = false;
|
|
2186
|
-
|
|
2299
|
+
_context34.next = 7;
|
|
2187
2300
|
return this.refreshItemRuleQuantityLimits();
|
|
2188
2301
|
case 7:
|
|
2189
|
-
|
|
2302
|
+
_context34.next = 9;
|
|
2190
2303
|
return this.refreshCartValidationPassed();
|
|
2191
2304
|
case 9:
|
|
2192
2305
|
this.logMethodSuccess('setItemRuleRuntimeConfig', {
|
|
@@ -2194,9 +2307,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2194
2307
|
});
|
|
2195
2308
|
case 10:
|
|
2196
2309
|
case "end":
|
|
2197
|
-
return
|
|
2310
|
+
return _context34.stop();
|
|
2198
2311
|
}
|
|
2199
|
-
},
|
|
2312
|
+
}, _callee34, this);
|
|
2200
2313
|
}));
|
|
2201
2314
|
function setItemRuleRuntimeConfig() {
|
|
2202
2315
|
return _setItemRuleRuntimeConfig.apply(this, arguments);
|
|
@@ -2295,27 +2408,27 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2295
2408
|
}, {
|
|
2296
2409
|
key: "fetchResourceOccupyDetailByResourceId",
|
|
2297
2410
|
value: function () {
|
|
2298
|
-
var _fetchResourceOccupyDetailByResourceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2411
|
+
var _fetchResourceOccupyDetailByResourceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(resourceId) {
|
|
2299
2412
|
var _this$otherParams9, _this$otherParams9$ge, _response$data$occupy, _response$data;
|
|
2300
2413
|
var formRecordId, shopId, response;
|
|
2301
|
-
return _regeneratorRuntime().wrap(function
|
|
2302
|
-
while (1) switch (
|
|
2414
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
2415
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
2303
2416
|
case 0:
|
|
2304
2417
|
formRecordId = Number(resourceId);
|
|
2305
2418
|
if (!(!Number.isFinite(formRecordId) || formRecordId <= 0)) {
|
|
2306
|
-
|
|
2419
|
+
_context35.next = 3;
|
|
2307
2420
|
break;
|
|
2308
2421
|
}
|
|
2309
2422
|
throw new Error("[ScanOrder] \u975E\u6CD5\u684C\u53F0 resourceId: ".concat(resourceId));
|
|
2310
2423
|
case 3:
|
|
2311
2424
|
shopId = (_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 || (_this$otherParams9$ge = _this$otherParams9.getStateData) === null || _this$otherParams9$ge === void 0 ? void 0 : _this$otherParams9$ge.call(_this$otherParams9, 'shop_id');
|
|
2312
2425
|
if (shopId) {
|
|
2313
|
-
|
|
2426
|
+
_context35.next = 6;
|
|
2314
2427
|
break;
|
|
2315
2428
|
}
|
|
2316
2429
|
throw new Error('[ScanOrder] 无法获取 shop_id');
|
|
2317
2430
|
case 6:
|
|
2318
|
-
|
|
2431
|
+
_context35.next = 8;
|
|
2319
2432
|
return this.request.get('/order/resource/occupy-detail', {
|
|
2320
2433
|
shop_id: shopId,
|
|
2321
2434
|
'form_record_ids[]': formRecordId,
|
|
@@ -2324,21 +2437,21 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2324
2437
|
with_resource_form_info: 1
|
|
2325
2438
|
});
|
|
2326
2439
|
case 8:
|
|
2327
|
-
response =
|
|
2440
|
+
response = _context35.sent;
|
|
2328
2441
|
if (response !== null && response !== void 0 && response.status) {
|
|
2329
|
-
|
|
2442
|
+
_context35.next = 11;
|
|
2330
2443
|
break;
|
|
2331
2444
|
}
|
|
2332
2445
|
throw new Error((response === null || response === void 0 ? void 0 : response.message) || '获取资源占用详情失败');
|
|
2333
2446
|
case 11:
|
|
2334
|
-
return
|
|
2447
|
+
return _context35.abrupt("return", (_response$data$occupy = response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 || (_response$data = _response$data.occupy_details) === null || _response$data === void 0 ? void 0 : _response$data[0]) !== null && _response$data$occupy !== void 0 ? _response$data$occupy : null);
|
|
2335
2448
|
case 12:
|
|
2336
2449
|
case "end":
|
|
2337
|
-
return
|
|
2450
|
+
return _context35.stop();
|
|
2338
2451
|
}
|
|
2339
|
-
},
|
|
2452
|
+
}, _callee35, this);
|
|
2340
2453
|
}));
|
|
2341
|
-
function fetchResourceOccupyDetailByResourceId(
|
|
2454
|
+
function fetchResourceOccupyDetailByResourceId(_x17) {
|
|
2342
2455
|
return _fetchResourceOccupyDetailByResourceId.apply(this, arguments);
|
|
2343
2456
|
}
|
|
2344
2457
|
return fetchResourceOccupyDetailByResourceId;
|
|
@@ -2348,32 +2461,32 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2348
2461
|
}, {
|
|
2349
2462
|
key: "checkResourceAvailable",
|
|
2350
2463
|
value: function () {
|
|
2351
|
-
var _checkResourceAvailable = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2464
|
+
var _checkResourceAvailable = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(resourceId, hasOrderId) {
|
|
2352
2465
|
var _this$otherParams10, _this$otherParams10$g, _occupyDetail$form_re, _occupyDetail$form_re2, _this$otherParams11, _this$store$order5, _this$store$order7, _this$store$order7$ge, _this$otherParams12, openData, dineInConfig, closedBehaviorValue, closedMessage, basicUnavailableMessage, pauseMessage, makeShopClosed, operatingHourIds, outsideOperatingHours, scheduleList, now, tempOrder, reservationLinkIds, pendingRequestEntryPax, pendingRequestPaxMin, pendingRequestPaxMax, reservationProductList, scheduleDate, scheduleDatetime, loaded, occupancyMinutes, paxBounds, occupyDetail, resourceSelectType, resourceState, availabilityInfo, _this$store$order6, _res$data, res, entryPaxNumber, lastOrderInfo, historicalItems;
|
|
2353
|
-
return _regeneratorRuntime().wrap(function
|
|
2354
|
-
while (1) switch (
|
|
2466
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
2467
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
2355
2468
|
case 0:
|
|
2356
2469
|
this.logMethodStart('checkResourceAvailable', {
|
|
2357
2470
|
resourceId: resourceId
|
|
2358
2471
|
});
|
|
2359
|
-
|
|
2360
|
-
|
|
2472
|
+
_context36.prev = 1;
|
|
2473
|
+
_context36.next = 4;
|
|
2361
2474
|
return (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 || (_this$otherParams10$g = _this$otherParams10.getOpenData) === null || _this$otherParams10$g === void 0 ? void 0 : _this$otherParams10$g.call(_this$otherParams10, {
|
|
2362
2475
|
scope: 'board',
|
|
2363
2476
|
target: 'dine_in+scan_to_order',
|
|
2364
2477
|
section_code: ['basic', 'fulfillment', 'reservation', 'sale', 'menu', 'availability', 'workflow']
|
|
2365
2478
|
});
|
|
2366
2479
|
case 4:
|
|
2367
|
-
openData =
|
|
2480
|
+
openData = _context36.sent;
|
|
2368
2481
|
if (!((openData === null || openData === void 0 ? void 0 : openData.status) === false)) {
|
|
2369
|
-
|
|
2482
|
+
_context36.next = 7;
|
|
2370
2483
|
break;
|
|
2371
2484
|
}
|
|
2372
2485
|
throw new Error((openData === null || openData === void 0 ? void 0 : openData.message) || '获取店铺配置失败');
|
|
2373
2486
|
case 7:
|
|
2374
2487
|
dineInConfig = (openData === null || openData === void 0 ? void 0 : openData.data) || {};
|
|
2375
2488
|
this.otherParams.dineInConfig = dineInConfig;
|
|
2376
|
-
|
|
2489
|
+
_context36.next = 11;
|
|
2377
2490
|
return this.syncItemRuleConfigsFromDineInConfig(dineInConfig);
|
|
2378
2491
|
case 11:
|
|
2379
2492
|
closedBehaviorValue = dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.closed_behavior'];
|
|
@@ -2392,20 +2505,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2392
2505
|
};
|
|
2393
2506
|
}; // 1. 基础开关 basic.enable 关闭
|
|
2394
2507
|
if (!((dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['basic.enable']) === false)) {
|
|
2395
|
-
|
|
2508
|
+
_context36.next = 18;
|
|
2396
2509
|
break;
|
|
2397
2510
|
}
|
|
2398
|
-
return
|
|
2511
|
+
return _context36.abrupt("return", makeShopClosed(basicUnavailableMessage));
|
|
2399
2512
|
case 18:
|
|
2400
2513
|
if (!toBoolean(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.paused'])) {
|
|
2401
|
-
|
|
2514
|
+
_context36.next = 21;
|
|
2402
2515
|
break;
|
|
2403
2516
|
}
|
|
2404
2517
|
if (!((dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.pause_behavior']) === 'hide_all')) {
|
|
2405
|
-
|
|
2518
|
+
_context36.next = 21;
|
|
2406
2519
|
break;
|
|
2407
2520
|
}
|
|
2408
|
-
return
|
|
2521
|
+
return _context36.abrupt("return", makeShopClosed(pauseMessage));
|
|
2409
2522
|
case 21:
|
|
2410
2523
|
// 3. 营业时间 operating_hours 闸门
|
|
2411
2524
|
operatingHourIds = Array.isArray(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.operating_hours']) ? dineInConfig['availability.operating_hours'].map(function (id) {
|
|
@@ -2422,27 +2535,27 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2422
2535
|
}
|
|
2423
2536
|
}
|
|
2424
2537
|
if (!(outsideOperatingHours && closedBehaviorValue !== 'show_menu_disabled')) {
|
|
2425
|
-
|
|
2538
|
+
_context36.next = 26;
|
|
2426
2539
|
break;
|
|
2427
2540
|
}
|
|
2428
|
-
return
|
|
2541
|
+
return _context36.abrupt("return", makeShopClosed(closedMessage, closedBehaviorValue));
|
|
2429
2542
|
case 26:
|
|
2430
2543
|
// Step1: 先加载预约规则商品,拿到 enabledReservationRuleProducts 与容量附加信息
|
|
2431
2544
|
// (resourceSelectType 需要基于这些商品 + 占用接口的 form_id 计算,故必须前置)
|
|
2432
2545
|
tempOrder = this.ensureTempOrder();
|
|
2433
2546
|
reservationLinkIds = collectLinkProductIdsFromReservationRules(dineInConfig['fulfillment.enabled_resource_rules']);
|
|
2434
2547
|
if (!(reservationLinkIds.length === 0)) {
|
|
2435
|
-
|
|
2548
|
+
_context36.next = 32;
|
|
2436
2549
|
break;
|
|
2437
2550
|
}
|
|
2438
2551
|
this.enabledReservationRuleProducts = [];
|
|
2439
|
-
|
|
2552
|
+
_context36.next = 43;
|
|
2440
2553
|
break;
|
|
2441
2554
|
case 32:
|
|
2442
2555
|
tempOrder.metadata = _objectSpread({}, tempOrder.metadata || {});
|
|
2443
2556
|
delete tempOrder.metadata.table_occupancy_duration;
|
|
2444
2557
|
reservationProductList = new ProductList("".concat(this.name, "_reservationEnabledRules"), this.defaultVersion);
|
|
2445
|
-
|
|
2558
|
+
_context36.next = 37;
|
|
2446
2559
|
return reservationProductList.initialize(this.core, {
|
|
2447
2560
|
store: {
|
|
2448
2561
|
list: [],
|
|
@@ -2457,7 +2570,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2457
2570
|
case 37:
|
|
2458
2571
|
scheduleDate = dayjs().format('YYYY-MM-DD');
|
|
2459
2572
|
scheduleDatetime = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
2460
|
-
|
|
2573
|
+
_context36.next = 41;
|
|
2461
2574
|
return reservationProductList.loadProducts({
|
|
2462
2575
|
product_ids: reservationLinkIds,
|
|
2463
2576
|
schedule_date: scheduleDate,
|
|
@@ -2465,7 +2578,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2465
2578
|
cacheId: this.cacheId
|
|
2466
2579
|
});
|
|
2467
2580
|
case 41:
|
|
2468
|
-
loaded =
|
|
2581
|
+
loaded = _context36.sent;
|
|
2469
2582
|
if (Array.isArray(loaded)) {
|
|
2470
2583
|
this.enabledReservationRuleProducts = loaded;
|
|
2471
2584
|
occupancyMinutes = pickFirstDurationMinutesFromProducts(loaded);
|
|
@@ -2490,10 +2603,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2490
2603
|
});
|
|
2491
2604
|
}
|
|
2492
2605
|
case 43:
|
|
2493
|
-
|
|
2606
|
+
_context36.next = 45;
|
|
2494
2607
|
return this.fetchResourceOccupyDetailByResourceId(resourceId);
|
|
2495
2608
|
case 45:
|
|
2496
|
-
occupyDetail =
|
|
2609
|
+
occupyDetail = _context36.sent;
|
|
2497
2610
|
// Step3: 结合预约规则商品的 product_resource.resources 与占用接口返回的 form_id,
|
|
2498
2611
|
// 计算当前桌台的 resourceSelectType(single/multiple/capacity)
|
|
2499
2612
|
resourceSelectType = this.resolveResourceSelectType(toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_id)); // Step4: 用 occupyDetail + resourceSelectType 规整为 resourceState
|
|
@@ -2533,10 +2646,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2533
2646
|
|
|
2534
2647
|
// 空闲状态下自动准备本地临时订单,供后续“购物车式”商品操作使用
|
|
2535
2648
|
if (!(availabilityInfo.mode === 'idle')) {
|
|
2536
|
-
|
|
2649
|
+
_context36.next = 60;
|
|
2537
2650
|
break;
|
|
2538
2651
|
}
|
|
2539
|
-
|
|
2652
|
+
_context36.next = 60;
|
|
2540
2653
|
return this.addNewOrder();
|
|
2541
2654
|
case 60:
|
|
2542
2655
|
// 如果是加单模式,tempOrder 里 需要记录 lastOrderId,提交的时候走加单接口
|
|
@@ -2544,23 +2657,23 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2544
2657
|
tempOrder.order_id = resourceState.lastOrderId;
|
|
2545
2658
|
}
|
|
2546
2659
|
if (!tempOrder.order_id) {
|
|
2547
|
-
|
|
2660
|
+
_context36.next = 69;
|
|
2548
2661
|
break;
|
|
2549
2662
|
}
|
|
2550
|
-
|
|
2663
|
+
_context36.next = 64;
|
|
2551
2664
|
return (_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 ? void 0 : _this$store$order6.getOrderInfoByRemote(tempOrder.order_id);
|
|
2552
2665
|
case 64:
|
|
2553
|
-
res =
|
|
2666
|
+
res = _context36.sent;
|
|
2554
2667
|
// 找到下单的时候输入的 entryPaxNumber
|
|
2555
2668
|
entryPaxNumber = res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 || (_res$data = _res$data.bookings) === null || _res$data === void 0 || (_res$data = _res$data.find(function (p) {
|
|
2556
2669
|
var _p$metadata;
|
|
2557
2670
|
return (_p$metadata = p.metadata) === null || _p$metadata === void 0 ? void 0 : _p$metadata.collect_pax;
|
|
2558
2671
|
})) === null || _res$data === void 0 || (_res$data = _res$data.metadata) === null || _res$data === void 0 ? void 0 : _res$data.collect_pax;
|
|
2559
2672
|
if (!entryPaxNumber) {
|
|
2560
|
-
|
|
2673
|
+
_context36.next = 69;
|
|
2561
2674
|
break;
|
|
2562
2675
|
}
|
|
2563
|
-
|
|
2676
|
+
_context36.next = 69;
|
|
2564
2677
|
return this.setEntryPaxNumber(entryPaxNumber);
|
|
2565
2678
|
case 69:
|
|
2566
2679
|
lastOrderInfo = (_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 || (_this$store$order7$ge = _this$store$order7.getLastOrderInfo) === null || _this$store$order7$ge === void 0 ? void 0 : _this$store$order7$ge.call(_this$store$order7);
|
|
@@ -2574,7 +2687,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2574
2687
|
} : {}));
|
|
2575
2688
|
return acc;
|
|
2576
2689
|
}, []) : []; // pax 由 setEntryPaxNumber 负责写入 itemRuleRuntimeConfig.pax
|
|
2577
|
-
|
|
2690
|
+
_context36.next = 73;
|
|
2578
2691
|
return this.setItemRuleRuntimeConfig({
|
|
2579
2692
|
serviceType: (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.businessCode,
|
|
2580
2693
|
submissionIndex: hasOrderId ? 1 : 0,
|
|
@@ -2601,21 +2714,21 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2601
2714
|
isExclusive: resourceState.isExclusive,
|
|
2602
2715
|
isFull: resourceState.isFull
|
|
2603
2716
|
});
|
|
2604
|
-
return
|
|
2717
|
+
return _context36.abrupt("return", availabilityInfo);
|
|
2605
2718
|
case 78:
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
this.logMethodError('checkResourceAvailable',
|
|
2719
|
+
_context36.prev = 78;
|
|
2720
|
+
_context36.t0 = _context36["catch"](1);
|
|
2721
|
+
this.logMethodError('checkResourceAvailable', _context36.t0.message, {
|
|
2609
2722
|
resourceId: resourceId
|
|
2610
2723
|
});
|
|
2611
|
-
throw
|
|
2724
|
+
throw _context36.t0;
|
|
2612
2725
|
case 82:
|
|
2613
2726
|
case "end":
|
|
2614
|
-
return
|
|
2727
|
+
return _context36.stop();
|
|
2615
2728
|
}
|
|
2616
|
-
},
|
|
2729
|
+
}, _callee36, this, [[1, 78]]);
|
|
2617
2730
|
}));
|
|
2618
|
-
function checkResourceAvailable(
|
|
2731
|
+
function checkResourceAvailable(_x18, _x19) {
|
|
2619
2732
|
return _checkResourceAvailable.apply(this, arguments);
|
|
2620
2733
|
}
|
|
2621
2734
|
return checkResourceAvailable;
|
|
@@ -2623,10 +2736,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2623
2736
|
}, {
|
|
2624
2737
|
key: "getAdditionalOrderInfo",
|
|
2625
2738
|
value: function () {
|
|
2626
|
-
var _getAdditionalOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2739
|
+
var _getAdditionalOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {
|
|
2627
2740
|
var result;
|
|
2628
|
-
return _regeneratorRuntime().wrap(function
|
|
2629
|
-
while (1) switch (
|
|
2741
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
2742
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
2630
2743
|
case 0:
|
|
2631
2744
|
this.logMethodStart('getAdditionalOrderInfo');
|
|
2632
2745
|
result = {
|
|
@@ -2640,12 +2753,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2640
2753
|
orderId: result.orderId,
|
|
2641
2754
|
orderStatus: result.orderStatus
|
|
2642
2755
|
});
|
|
2643
|
-
return
|
|
2756
|
+
return _context37.abrupt("return", result);
|
|
2644
2757
|
case 4:
|
|
2645
2758
|
case "end":
|
|
2646
|
-
return
|
|
2759
|
+
return _context37.stop();
|
|
2647
2760
|
}
|
|
2648
|
-
},
|
|
2761
|
+
}, _callee37, this);
|
|
2649
2762
|
}));
|
|
2650
2763
|
function getAdditionalOrderInfo() {
|
|
2651
2764
|
return _getAdditionalOrderInfo.apply(this, arguments);
|
|
@@ -2655,19 +2768,19 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2655
2768
|
}, {
|
|
2656
2769
|
key: "getProductList",
|
|
2657
2770
|
value: function () {
|
|
2658
|
-
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2771
|
+
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
|
|
2659
2772
|
var _this$otherParams13;
|
|
2660
2773
|
var menu_list_ids, _this$store$products, res, formattedRes;
|
|
2661
|
-
return _regeneratorRuntime().wrap(function
|
|
2662
|
-
while (1) switch (
|
|
2774
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
2775
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
2663
2776
|
case 0:
|
|
2664
2777
|
this.logMethodStart('getProductList');
|
|
2665
2778
|
// 可以直接通过配置里的 menu 读取
|
|
2666
2779
|
menu_list_ids = ((_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 || (_this$otherParams13 = _this$otherParams13.dineInConfig) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13['menu.associated_menus'].map(function (n) {
|
|
2667
2780
|
return Number(n.value);
|
|
2668
2781
|
})) || [];
|
|
2669
|
-
|
|
2670
|
-
|
|
2782
|
+
_context38.prev = 2;
|
|
2783
|
+
_context38.next = 5;
|
|
2671
2784
|
return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
|
|
2672
2785
|
menu_list_ids: menu_list_ids,
|
|
2673
2786
|
cacheId: this.cacheId,
|
|
@@ -2675,22 +2788,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2675
2788
|
schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
2676
2789
|
});
|
|
2677
2790
|
case 5:
|
|
2678
|
-
res =
|
|
2791
|
+
res = _context38.sent;
|
|
2679
2792
|
formattedRes = attachItemRuleLimitsToTopLevelProducts(res, this.store.itemRuleQuantityLimits || []);
|
|
2680
2793
|
this.logMethodSuccess('getProductList', {
|
|
2681
2794
|
menuCount: menu_list_ids.length
|
|
2682
2795
|
});
|
|
2683
|
-
return
|
|
2796
|
+
return _context38.abrupt("return", formattedRes);
|
|
2684
2797
|
case 11:
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
this.logMethodError('getProductList',
|
|
2688
|
-
throw
|
|
2798
|
+
_context38.prev = 11;
|
|
2799
|
+
_context38.t0 = _context38["catch"](2);
|
|
2800
|
+
this.logMethodError('getProductList', _context38.t0.message);
|
|
2801
|
+
throw _context38.t0;
|
|
2689
2802
|
case 15:
|
|
2690
2803
|
case "end":
|
|
2691
|
-
return
|
|
2804
|
+
return _context38.stop();
|
|
2692
2805
|
}
|
|
2693
|
-
},
|
|
2806
|
+
}, _callee38, this, [[2, 11]]);
|
|
2694
2807
|
}));
|
|
2695
2808
|
function getProductList() {
|
|
2696
2809
|
return _getProductList.apply(this, arguments);
|
|
@@ -2705,15 +2818,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2705
2818
|
}, {
|
|
2706
2819
|
key: "setOtherParams",
|
|
2707
2820
|
value: function () {
|
|
2708
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2821
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
|
|
2709
2822
|
var _ref8,
|
|
2710
2823
|
_ref8$cover,
|
|
2711
2824
|
cover,
|
|
2712
|
-
|
|
2713
|
-
return _regeneratorRuntime().wrap(function
|
|
2714
|
-
while (1) switch (
|
|
2825
|
+
_args39 = arguments;
|
|
2826
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
2827
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
2715
2828
|
case 0:
|
|
2716
|
-
_ref8 =
|
|
2829
|
+
_ref8 = _args39.length > 1 && _args39[1] !== undefined ? _args39[1] : {}, _ref8$cover = _ref8.cover, cover = _ref8$cover === void 0 ? false : _ref8$cover;
|
|
2717
2830
|
if (cover) {
|
|
2718
2831
|
this.otherParams = params;
|
|
2719
2832
|
} else {
|
|
@@ -2721,11 +2834,11 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2721
2834
|
}
|
|
2722
2835
|
case 2:
|
|
2723
2836
|
case "end":
|
|
2724
|
-
return
|
|
2837
|
+
return _context39.stop();
|
|
2725
2838
|
}
|
|
2726
|
-
},
|
|
2839
|
+
}, _callee39, this);
|
|
2727
2840
|
}));
|
|
2728
|
-
function setOtherParams(
|
|
2841
|
+
function setOtherParams(_x20) {
|
|
2729
2842
|
return _setOtherParams.apply(this, arguments);
|
|
2730
2843
|
}
|
|
2731
2844
|
return setOtherParams;
|
|
@@ -2815,10 +2928,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2815
2928
|
}, {
|
|
2816
2929
|
key: "setEntryPaxNumber",
|
|
2817
2930
|
value: function () {
|
|
2818
|
-
var _setEntryPaxNumber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2931
|
+
var _setEntryPaxNumber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(number) {
|
|
2819
2932
|
var pax, t;
|
|
2820
|
-
return _regeneratorRuntime().wrap(function
|
|
2821
|
-
while (1) switch (
|
|
2933
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
2934
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
2822
2935
|
case 0:
|
|
2823
2936
|
pax = normalizeSubmitCollectPaxValue(number);
|
|
2824
2937
|
this.store.entryPaxNumber = pax;
|
|
@@ -2839,18 +2952,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2839
2952
|
}
|
|
2840
2953
|
});
|
|
2841
2954
|
this.itemRulePrefillApplied = false;
|
|
2842
|
-
|
|
2955
|
+
_context40.next = 7;
|
|
2843
2956
|
return this.refreshItemRuleQuantityLimits();
|
|
2844
2957
|
case 7:
|
|
2845
|
-
|
|
2958
|
+
_context40.next = 9;
|
|
2846
2959
|
return this.refreshCartValidationPassed();
|
|
2847
2960
|
case 9:
|
|
2848
2961
|
case "end":
|
|
2849
|
-
return
|
|
2962
|
+
return _context40.stop();
|
|
2850
2963
|
}
|
|
2851
|
-
},
|
|
2964
|
+
}, _callee40, this);
|
|
2852
2965
|
}));
|
|
2853
|
-
function setEntryPaxNumber(
|
|
2966
|
+
function setEntryPaxNumber(_x21) {
|
|
2854
2967
|
return _setEntryPaxNumber.apply(this, arguments);
|
|
2855
2968
|
}
|
|
2856
2969
|
return setEntryPaxNumber;
|