@pisell/pisellos 0.0.511 → 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.
@@ -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 _callee6(core) {
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
- _args6 = arguments;
404
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
405
- while (1) switch (_context6.prev = _context6.next) {
449
+ _args7 = arguments;
450
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
451
+ while (1) switch (_context7.prev = _context7.next) {
406
452
  case 0:
407
- options = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : {};
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
- _context6.next = 21;
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
- _context6.next = 24;
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
- _context6.prev = 32;
487
- _context6.next = 35;
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
- _context6.next = 38;
539
+ _context7.next = 38;
494
540
  return this.loadRuntimeConfigs();
495
541
  case 38:
496
542
  if (!this.store.schedule) {
497
- _context6.next = 47;
543
+ _context7.next = 47;
498
544
  break;
499
545
  }
500
- _context6.prev = 39;
501
- _context6.next = 42;
546
+ _context7.prev = 39;
547
+ _context7.next = 42;
502
548
  return this.store.schedule.loadAllSchedule();
503
549
  case 42:
504
- _context6.next = 47;
550
+ _context7.next = 47;
505
551
  break;
506
552
  case 44:
507
- _context6.prev = 44;
508
- _context6.t0 = _context6["catch"](39);
509
- console.warn('[ScanOrder] loadAllSchedule 失败,operating_hours 判定将跳过', _context6.t0);
553
+ _context7.prev = 44;
554
+ _context7.t0 = _context7["catch"](39);
555
+ console.warn('[ScanOrder] loadAllSchedule 失败,operating_hours 判定将跳过', _context7.t0);
510
556
  case 47:
511
- _context6.next = 49;
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
- _context6.next = 53;
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
- _context6.next = 63;
570
+ _context7.next = 63;
525
571
  break;
526
572
  case 56:
527
- _context6.prev = 56;
528
- _context6.t1 = _context6["catch"](32);
573
+ _context7.prev = 56;
574
+ _context7.t1 = _context7["catch"](32);
529
575
  this.store.status = 'error';
530
- this.store.error = _context6.t1 instanceof Error ? _context6.t1.message : '初始化失败';
531
- console.error('[ScanOrder] 初始化失败', _context6.t1);
532
- this.logMethodError('initialize', _context6.t1, {
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 _context6.t1;
581
+ throw _context7.t1;
536
582
  case 63:
537
583
  case "end":
538
- return _context6.stop();
584
+ return _context7.stop();
539
585
  }
540
- }, _callee6, this, [[32, 56], [39, 44]]);
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 _callee7() {
551
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
552
- while (1) switch (_context7.prev = _context7.next) {
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
- _context7.next = 4;
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 6:
611
+ case 9:
562
612
  case "end":
563
- return _context7.stop();
613
+ return _context8.stop();
564
614
  }
565
- }, _callee7, this);
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 _callee8() {
576
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
577
- while (1) switch (_context8.prev = _context8.next) {
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
- _context8.next = 4;
632
+ _context9.next = 4;
583
633
  return this.core.effects.emit(ScanOrderHooks.onRetryInit, {});
584
634
  case 4:
585
- _context8.prev = 4;
586
- _context8.next = 7;
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
- _context8.next = 14;
640
+ _context9.next = 14;
591
641
  break;
592
642
  case 10:
593
- _context8.prev = 10;
594
- _context8.t0 = _context8["catch"](4);
595
- this.logMethodError('retryInit', _context8.t0);
596
- throw _context8.t0;
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 _context8.stop();
649
+ return _context9.stop();
600
650
  }
601
- }, _callee8, this, [[4, 10]]);
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 _callee9() {
612
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
613
- while (1) switch (_context9.prev = _context9.next) {
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
- _context9.prev = 2;
668
+ _context10.prev = 2;
619
669
  this.store.status = 'initializing';
620
- _context9.next = 6;
670
+ _context10.next = 6;
621
671
  return this.loadRuntimeConfigs();
622
672
  case 6:
623
- _context9.next = 8;
673
+ _context10.next = 8;
624
674
  return this.refreshItemRuleQuantityLimits();
625
675
  case 8:
626
676
  this.store.status = 'ready';
627
- _context9.next = 11;
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
- _context9.next = 18;
685
+ _context10.next = 18;
636
686
  break;
637
687
  case 14:
638
- _context9.prev = 14;
639
- _context9.t0 = _context9["catch"](2);
640
- this.logMethodError('refresh', _context9.t0);
641
- throw _context9.t0;
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 _context9.stop();
694
+ return _context10.stop();
645
695
  }
646
- }, _callee9, this, [[2, 14]]);
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 _callee10() {
860
+ var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
811
861
  var tempOrder;
812
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
813
- while (1) switch (_context10.prev = _context10.next) {
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
- _context10.prev = 1;
866
+ _context11.prev = 1;
817
867
  if (this.store.order) {
818
- _context10.next = 4;
868
+ _context11.next = 4;
819
869
  break;
820
870
  }
821
871
  throw new Error('order 模块未初始化');
822
872
  case 4:
823
- _context10.next = 6;
873
+ _context11.next = 6;
824
874
  return this.store.order.addNewOrder();
825
875
  case 6:
826
- tempOrder = _context10.sent;
876
+ tempOrder = _context11.sent;
827
877
  this.logMethodSuccess('addNewOrder', {
828
878
  productCount: tempOrder.products.length
829
879
  });
830
- return _context10.abrupt("return", tempOrder);
880
+ return _context11.abrupt("return", tempOrder);
831
881
  case 11:
832
- _context10.prev = 11;
833
- _context10.t0 = _context10["catch"](1);
834
- this.logMethodError('addNewOrder', _context10.t0);
835
- throw _context10.t0;
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 _context10.stop();
888
+ return _context11.stop();
839
889
  }
840
- }, _callee10, this, [[1, 11]]);
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 _callee11() {
901
+ var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
852
902
  var tempOrder;
853
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
854
- while (1) switch (_context11.prev = _context11.next) {
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
- _context11.prev = 1;
907
+ _context12.prev = 1;
858
908
  if (this.store.order) {
859
- _context11.next = 4;
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 _context11.abrupt("return", tempOrder);
919
+ return _context12.abrupt("return", tempOrder);
870
920
  case 12:
871
- _context11.prev = 12;
872
- _context11.t0 = _context11["catch"](1);
873
- this.logMethodError('restoreOrder', _context11.t0);
874
- throw _context11.t0;
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 _context11.stop();
927
+ return _context12.stop();
878
928
  }
879
- }, _callee11, this, [[1, 12]]);
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 _callee12() {
950
+ var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
901
951
  var summary;
902
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
903
- while (1) switch (_context12.prev = _context12.next) {
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
- _context12.prev = 1;
956
+ _context13.prev = 1;
907
957
  if (this.store.order) {
908
- _context12.next = 4;
958
+ _context13.next = 4;
909
959
  break;
910
960
  }
911
961
  throw new Error('order 模块未初始化');
912
962
  case 4:
913
- _context12.next = 6;
963
+ _context13.next = 6;
914
964
  return this.store.order.getScanOrderSummary();
915
965
  case 6:
916
- summary = _context12.sent;
966
+ summary = _context13.sent;
917
967
  this.logMethodSuccess('getSummary', {
918
968
  totalAmount: summary.total_amount
919
969
  });
920
- return _context12.abrupt("return", summary);
970
+ return _context13.abrupt("return", summary);
921
971
  case 11:
922
- _context12.prev = 11;
923
- _context12.t0 = _context12["catch"](1);
924
- this.logMethodError('getSummary', _context12.t0);
925
- throw _context12.t0;
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 _context12.stop();
978
+ return _context13.stop();
929
979
  }
930
- }, _callee12, this, [[1, 11]]);
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 _callee13(code, customerId) {
996
+ var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(code, customerId) {
947
997
  var raw;
948
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
949
- while (1) switch (_context13.prev = _context13.next) {
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
- _context13.prev = 1;
1004
+ _context14.prev = 1;
955
1005
  if (this.store.order) {
956
- _context13.next = 4;
1006
+ _context14.next = 4;
957
1007
  break;
958
1008
  }
959
1009
  throw new Error('order 模块未初始化');
960
1010
  case 4:
961
- _context13.next = 6;
1011
+ _context14.next = 6;
962
1012
  return this.store.order.scanCode(code, customerId);
963
1013
  case 6:
964
- raw = _context13.sent;
1014
+ raw = _context14.sent;
965
1015
  if (!raw.isAvailable) {
966
- _context13.next = 11;
1016
+ _context14.next = 11;
967
1017
  break;
968
1018
  }
969
- _context13.next = 10;
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 _context13.abrupt("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
- _context13.prev = 15;
986
- _context13.t0 = _context13["catch"](1);
987
- this.logMethodError('scanCode', _context13.t0);
988
- throw _context13.t0;
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 _context13.stop();
1041
+ return _context14.stop();
992
1042
  }
993
- }, _callee13, this, [[1, 15]]);
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 _callee14(params) {
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, newSellingPrice;
1005
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1006
- while (1) switch (_context14.prev = _context14.next) {
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
- _context14.prev = 1;
1059
+ _context15.prev = 1;
1010
1060
  if (this.store.order) {
1011
- _context14.next = 4;
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
- _context14.next = 14;
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
- _context14.prev = 17;
1130
+ _context15.prev = 17;
1081
1131
  _iterator3.s();
1082
1132
  case 19:
1083
1133
  if ((_step3 = _iterator3.n()).done) {
1084
- _context14.next = 30;
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
- _context14.next = 23;
1139
+ _context15.next = 23;
1090
1140
  break;
1091
1141
  }
1092
- return _context14.abrupt("continue", 28);
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
- newSellingPrice = new Decimal(product.original_price || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
1103
- product.selling_price = newSellingPrice;
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 = newSellingPrice;
1160
+ product.metadata.main_product_selling_price = newMainSellingPrice;
1161
+ product.metadata.price_schema_version = 2;
1106
1162
  }
1107
- case 28:
1108
- _context14.next = 19;
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 30:
1111
- _context14.next = 35;
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
- _context14.prev = 35;
1119
- _iterator3.f();
1120
- return _context14.finish(35);
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
- _context14.next = 41;
1183
+ _context15.next = 44;
1124
1184
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
1125
- case 41:
1185
+ case 44:
1126
1186
  tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
1127
1187
  return d.isSelected;
1128
1188
  });
1129
- _context14.next = 44;
1189
+ _context15.next = 47;
1130
1190
  return this.store.order.recalculateSummary({
1131
1191
  createIfMissing: true
1132
1192
  });
1133
- case 44:
1193
+ case 47:
1134
1194
  this.store.order.persistTempOrder();
1135
1195
  this.logMethodSuccess('setDiscountSelected', params);
1136
- _context14.next = 52;
1196
+ _context15.next = 55;
1137
1197
  break;
1138
- case 48:
1139
- _context14.prev = 48;
1140
- _context14.t1 = _context14["catch"](1);
1141
- this.logMethodError('setDiscountSelected', _context14.t1);
1142
- throw _context14.t1;
1143
- case 52:
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 _context14.stop();
1205
+ return _context15.stop();
1146
1206
  }
1147
- }, _callee14, this, [[1, 48], [17, 32, 35, 38]]);
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 _callee15(params) {
1158
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1159
- while (1) switch (_context15.prev = _context15.next) {
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
- _context15.prev = 1;
1165
- _context15.next = 4;
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
- _context15.next = 11;
1233
+ _context16.next = 11;
1174
1234
  break;
1175
1235
  case 7:
1176
- _context15.prev = 7;
1177
- _context15.t0 = _context15["catch"](1);
1178
- this.logMethodError('onCustomerLogin', _context15.t0);
1179
- throw _context15.t0;
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 _context15.stop();
1242
+ return _context16.stop();
1183
1243
  }
1184
- }, _callee15, this, [[1, 7]]);
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 _callee16() {
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 _callee16$(_context16) {
1298
- while (1) switch (_context16.prev = _context16.next) {
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
- _context16.prev = 1;
1302
- _context16.next = 4;
1361
+ _context17.prev = 1;
1362
+ _context17.next = 4;
1303
1363
  return this.validateBeforeSubmitByItemRule();
1304
1364
  case 4:
1305
1365
  if (this.store.order) {
1306
- _context16.next = 6;
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
- _context16.next = 17;
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 = _context16.sent;
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 _context16.abrupt("return", result);
1401
+ return _context17.abrupt("return", result);
1342
1402
  case 23:
1343
- _context16.prev = 23;
1344
- _context16.t0 = _context16["catch"](1);
1345
- this.logMethodError('submitScanOrder', _context16.t0);
1346
- throw _context16.t0;
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 _context16.stop();
1409
+ return _context17.stop();
1350
1410
  }
1351
- }, _callee16, this, [[1, 23]]);
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 _callee17(product) {
1421
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(product) {
1362
1422
  var products;
1363
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1364
- while (1) switch (_context17.prev = _context17.next) {
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
- _context17.prev = 1;
1430
+ _context18.prev = 1;
1371
1431
  if (this.store.order) {
1372
- _context17.next = 4;
1432
+ _context18.next = 4;
1373
1433
  break;
1374
1434
  }
1375
1435
  throw new Error('order 模块未初始化');
1376
1436
  case 4:
1377
- _context17.next = 6;
1437
+ _context18.next = 6;
1378
1438
  return this.store.order.addProductToOrder(product);
1379
1439
  case 6:
1380
- products = _context17.sent;
1381
- _context17.next = 9;
1440
+ products = _context18.sent;
1441
+ _context18.next = 9;
1382
1442
  return this.refreshItemRuleQuantityLimits();
1383
1443
  case 9:
1384
- _context17.next = 11;
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 _context17.abrupt("return", products);
1450
+ return _context18.abrupt("return", products);
1391
1451
  case 15:
1392
- _context17.prev = 15;
1393
- _context17.t0 = _context17["catch"](1);
1394
- this.logMethodError('addProductToOrder', _context17.t0);
1395
- throw _context17.t0;
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 _context17.stop();
1458
+ return _context18.stop();
1399
1459
  }
1400
- }, _callee17, this, [[1, 15]]);
1460
+ }, _callee18, this, [[1, 15]]);
1401
1461
  }));
1402
1462
  function addProductToOrder(_x10) {
1403
1463
  return _addProductToOrder.apply(this, arguments);
@@ -1407,46 +1467,46 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1407
1467
  }, {
1408
1468
  key: "updateProductInOrder",
1409
1469
  value: function () {
1410
- var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(params) {
1470
+ var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
1411
1471
  var products;
1412
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1413
- while (1) switch (_context18.prev = _context18.next) {
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
- _context18.prev = 1;
1479
+ _context19.prev = 1;
1420
1480
  if (this.store.order) {
1421
- _context18.next = 4;
1481
+ _context19.next = 4;
1422
1482
  break;
1423
1483
  }
1424
1484
  throw new Error('order 模块未初始化');
1425
1485
  case 4:
1426
- _context18.next = 6;
1486
+ _context19.next = 6;
1427
1487
  return this.store.order.updateProductInOrder(params);
1428
1488
  case 6:
1429
- products = _context18.sent;
1430
- _context18.next = 9;
1489
+ products = _context19.sent;
1490
+ _context19.next = 9;
1431
1491
  return this.refreshItemRuleQuantityLimits();
1432
1492
  case 9:
1433
- _context18.next = 11;
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 _context18.abrupt("return", products);
1499
+ return _context19.abrupt("return", products);
1440
1500
  case 15:
1441
- _context18.prev = 15;
1442
- _context18.t0 = _context18["catch"](1);
1443
- this.logMethodError('updateProductInOrder', _context18.t0);
1444
- throw _context18.t0;
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 _context18.stop();
1507
+ return _context19.stop();
1448
1508
  }
1449
- }, _callee18, this, [[1, 15]]);
1509
+ }, _callee19, this, [[1, 15]]);
1450
1510
  }));
1451
1511
  function updateProductInOrder(_x11) {
1452
1512
  return _updateProductInOrder.apply(this, arguments);
@@ -1460,16 +1520,16 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1460
1520
  }, {
1461
1521
  key: "setOrderProductLineNote",
1462
1522
  value: (function () {
1463
- var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(identity, note) {
1523
+ var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(identity, note) {
1464
1524
  var params, products;
1465
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1466
- while (1) switch (_context19.prev = _context19.next) {
1525
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1526
+ while (1) switch (_context20.prev = _context20.next) {
1467
1527
  case 0:
1468
1528
  this.logMethodStart('setOrderProductLineNote', {
1469
1529
  product_id: identity.product_id,
1470
1530
  product_variant_id: identity.product_variant_id
1471
1531
  });
1472
- _context19.prev = 1;
1532
+ _context20.prev = 1;
1473
1533
  params = {
1474
1534
  product_id: identity.product_id,
1475
1535
  product_variant_id: identity.product_variant_id,
@@ -1482,24 +1542,24 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1482
1542
  params.product_option_item = identity.product_option_item;
1483
1543
  }
1484
1544
  if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
1485
- _context19.next = 8;
1545
+ _context20.next = 8;
1486
1546
  return this.updateProductInOrder(params);
1487
1547
  case 8:
1488
- products = _context19.sent;
1548
+ products = _context20.sent;
1489
1549
  this.logMethodSuccess('setOrderProductLineNote', {
1490
1550
  productCount: products.length
1491
1551
  });
1492
- return _context19.abrupt("return", products);
1552
+ return _context20.abrupt("return", products);
1493
1553
  case 13:
1494
- _context19.prev = 13;
1495
- _context19.t0 = _context19["catch"](1);
1496
- this.logMethodError('setOrderProductLineNote', _context19.t0);
1497
- throw _context19.t0;
1554
+ _context20.prev = 13;
1555
+ _context20.t0 = _context20["catch"](1);
1556
+ this.logMethodError('setOrderProductLineNote', _context20.t0);
1557
+ throw _context20.t0;
1498
1558
  case 17:
1499
1559
  case "end":
1500
- return _context19.stop();
1560
+ return _context20.stop();
1501
1561
  }
1502
- }, _callee19, this, [[1, 13]]);
1562
+ }, _callee20, this, [[1, 13]]);
1503
1563
  }));
1504
1564
  function setOrderProductLineNote(_x12, _x13) {
1505
1565
  return _setOrderProductLineNote.apply(this, arguments);
@@ -1509,46 +1569,46 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1509
1569
  }, {
1510
1570
  key: "removeProductFromOrder",
1511
1571
  value: function () {
1512
- var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(identity) {
1572
+ var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(identity) {
1513
1573
  var products;
1514
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1515
- while (1) switch (_context20.prev = _context20.next) {
1574
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1575
+ while (1) switch (_context21.prev = _context21.next) {
1516
1576
  case 0:
1517
1577
  this.logMethodStart('removeProductFromOrder', {
1518
1578
  product_id: identity.product_id,
1519
1579
  product_variant_id: identity.product_variant_id
1520
1580
  });
1521
- _context20.prev = 1;
1581
+ _context21.prev = 1;
1522
1582
  if (this.store.order) {
1523
- _context20.next = 4;
1583
+ _context21.next = 4;
1524
1584
  break;
1525
1585
  }
1526
1586
  throw new Error('order 模块未初始化');
1527
1587
  case 4:
1528
- _context20.next = 6;
1588
+ _context21.next = 6;
1529
1589
  return this.store.order.removeProductFromOrder(identity);
1530
1590
  case 6:
1531
- products = _context20.sent;
1532
- _context20.next = 9;
1591
+ products = _context21.sent;
1592
+ _context21.next = 9;
1533
1593
  return this.refreshItemRuleQuantityLimits();
1534
1594
  case 9:
1535
- _context20.next = 11;
1595
+ _context21.next = 11;
1536
1596
  return this.refreshCartValidationPassed();
1537
1597
  case 11:
1538
1598
  this.logMethodSuccess('removeProductFromOrder', {
1539
1599
  productCount: products.length
1540
1600
  });
1541
- return _context20.abrupt("return", products);
1601
+ return _context21.abrupt("return", products);
1542
1602
  case 15:
1543
- _context20.prev = 15;
1544
- _context20.t0 = _context20["catch"](1);
1545
- this.logMethodError('removeProductFromOrder', _context20.t0);
1546
- throw _context20.t0;
1603
+ _context21.prev = 15;
1604
+ _context21.t0 = _context21["catch"](1);
1605
+ this.logMethodError('removeProductFromOrder', _context21.t0);
1606
+ throw _context21.t0;
1547
1607
  case 19:
1548
1608
  case "end":
1549
- return _context20.stop();
1609
+ return _context21.stop();
1550
1610
  }
1551
- }, _callee20, this, [[1, 15]]);
1611
+ }, _callee21, this, [[1, 15]]);
1552
1612
  }));
1553
1613
  function removeProductFromOrder(_x14) {
1554
1614
  return _removeProductFromOrder.apply(this, arguments);
@@ -1558,26 +1618,26 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1558
1618
  }, {
1559
1619
  key: "loadRuntimeConfigs",
1560
1620
  value: function () {
1561
- var _loadRuntimeConfigs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
1621
+ var _loadRuntimeConfigs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
1562
1622
  var itemRuleConfigs;
1563
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1564
- while (1) switch (_context21.prev = _context21.next) {
1623
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1624
+ while (1) switch (_context22.prev = _context22.next) {
1565
1625
  case 0:
1566
- _context21.next = 2;
1626
+ _context22.next = 2;
1567
1627
  return this.ensureItemRuleConfigsLoaded();
1568
1628
  case 2:
1569
- itemRuleConfigs = _context21.sent;
1629
+ itemRuleConfigs = _context22.sent;
1570
1630
  this.logMethodSuccess('loadRuntimeConfigs', {
1571
1631
  itemRuleCount: itemRuleConfigs.length
1572
1632
  });
1573
- return _context21.abrupt("return", {
1633
+ return _context22.abrupt("return", {
1574
1634
  itemRuleConfigs: itemRuleConfigs
1575
1635
  });
1576
1636
  case 5:
1577
1637
  case "end":
1578
- return _context21.stop();
1638
+ return _context22.stop();
1579
1639
  }
1580
- }, _callee21, this);
1640
+ }, _callee22, this);
1581
1641
  }));
1582
1642
  function loadRuntimeConfigs() {
1583
1643
  return _loadRuntimeConfigs.apply(this, arguments);
@@ -1587,15 +1647,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1587
1647
  }, {
1588
1648
  key: "syncItemRuleConfigsFromDineInConfig",
1589
1649
  value: function () {
1590
- var _syncItemRuleConfigsFromDineInConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(dineInConfig) {
1650
+ var _syncItemRuleConfigsFromDineInConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(dineInConfig) {
1591
1651
  var enableItemRules, strategyModelIds, itemRuleConfigs;
1592
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1593
- while (1) switch (_context22.prev = _context22.next) {
1652
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1653
+ while (1) switch (_context23.prev = _context23.next) {
1594
1654
  case 0:
1595
1655
  enableItemRules = toBoolean(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['sale.enable_item_rules']);
1596
1656
  strategyModelIds = normalizeEnabledItemRuleIds(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['sale.enabled_item_rules']);
1597
1657
  if (!(!enableItemRules || !strategyModelIds.length)) {
1598
- _context22.next = 8;
1658
+ _context23.next = 8;
1599
1659
  break;
1600
1660
  }
1601
1661
  this.itemRuleConfigs = [];
@@ -1606,12 +1666,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1606
1666
  strategyModelIds: [],
1607
1667
  itemRuleCount: 0
1608
1668
  });
1609
- return _context22.abrupt("return", []);
1669
+ return _context23.abrupt("return", []);
1610
1670
  case 8:
1611
- _context22.next = 10;
1671
+ _context23.next = 10;
1612
1672
  return this.fetchItemRuleConfigsByModelIds(strategyModelIds);
1613
1673
  case 10:
1614
- itemRuleConfigs = _context22.sent;
1674
+ itemRuleConfigs = _context23.sent;
1615
1675
  this.itemRuleConfigs = itemRuleConfigs;
1616
1676
  this.itemRuleConfigsPromise = Promise.resolve(itemRuleConfigs);
1617
1677
  this.itemRuleEvaluator.setStrategyConfigs(itemRuleConfigs);
@@ -1620,12 +1680,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1620
1680
  strategyModelIds: strategyModelIds,
1621
1681
  itemRuleCount: itemRuleConfigs.length
1622
1682
  });
1623
- return _context22.abrupt("return", itemRuleConfigs);
1683
+ return _context23.abrupt("return", itemRuleConfigs);
1624
1684
  case 16:
1625
1685
  case "end":
1626
- return _context22.stop();
1686
+ return _context23.stop();
1627
1687
  }
1628
- }, _callee22, this);
1688
+ }, _callee23, this);
1629
1689
  }));
1630
1690
  function syncItemRuleConfigsFromDineInConfig(_x15) {
1631
1691
  return _syncItemRuleConfigsFromDineInConfig.apply(this, arguments);
@@ -1635,22 +1695,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1635
1695
  }, {
1636
1696
  key: "fetchItemRuleConfigsByModelIds",
1637
1697
  value: function () {
1638
- var _fetchItemRuleConfigsByModelIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(strategyModelIds) {
1698
+ var _fetchItemRuleConfigsByModelIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(strategyModelIds) {
1639
1699
  var result, configs;
1640
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1641
- while (1) switch (_context23.prev = _context23.next) {
1700
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1701
+ while (1) switch (_context24.prev = _context24.next) {
1642
1702
  case 0:
1643
1703
  this.logMethodStart('fetchItemRuleConfigsByModelIds', {
1644
1704
  strategyModelIds: strategyModelIds
1645
1705
  });
1646
1706
  if (strategyModelIds.length) {
1647
- _context23.next = 3;
1707
+ _context24.next = 3;
1648
1708
  break;
1649
1709
  }
1650
- return _context23.abrupt("return", []);
1710
+ return _context24.abrupt("return", []);
1651
1711
  case 3:
1652
- _context23.prev = 3;
1653
- _context23.next = 6;
1712
+ _context24.prev = 3;
1713
+ _context24.next = 6;
1654
1714
  return this.request.get('/promotion', {
1655
1715
  skip: 1,
1656
1716
  num: 99,
@@ -1658,7 +1718,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1658
1718
  ids: strategyModelIds
1659
1719
  });
1660
1720
  case 6:
1661
- result = _context23.sent;
1721
+ result = _context24.sent;
1662
1722
  configs = [];
1663
1723
  if (result.code === 200) {
1664
1724
  configs = result.data.list.map(function (item) {
@@ -1669,20 +1729,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1669
1729
  strategyModelIds: strategyModelIds,
1670
1730
  strategyCount: configs.length
1671
1731
  });
1672
- return _context23.abrupt("return", configs);
1732
+ return _context24.abrupt("return", configs);
1673
1733
  case 13:
1674
- _context23.prev = 13;
1675
- _context23.t0 = _context23["catch"](3);
1676
- this.logMethodError('fetchItemRuleConfigsByModelIds', _context23.t0, {
1734
+ _context24.prev = 13;
1735
+ _context24.t0 = _context24["catch"](3);
1736
+ this.logMethodError('fetchItemRuleConfigsByModelIds', _context24.t0, {
1677
1737
  strategyModelIds: strategyModelIds
1678
1738
  });
1679
1739
  // A:策略加载失败时不阻塞下单
1680
- return _context23.abrupt("return", []);
1740
+ return _context24.abrupt("return", []);
1681
1741
  case 17:
1682
1742
  case "end":
1683
- return _context23.stop();
1743
+ return _context24.stop();
1684
1744
  }
1685
- }, _callee23, this, [[3, 13]]);
1745
+ }, _callee24, this, [[3, 13]]);
1686
1746
  }));
1687
1747
  function fetchItemRuleConfigsByModelIds(_x16) {
1688
1748
  return _fetchItemRuleConfigsByModelIds.apply(this, arguments);
@@ -1692,22 +1752,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1692
1752
  }, {
1693
1753
  key: "buildPrefillProductSourceMap",
1694
1754
  value: function () {
1695
- var _buildPrefillProductSourceMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
1755
+ var _buildPrefillProductSourceMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
1696
1756
  var sourceMap, productList, visited, collectFromValue;
1697
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1698
- while (1) switch (_context24.prev = _context24.next) {
1757
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
1758
+ while (1) switch (_context25.prev = _context25.next) {
1699
1759
  case 0:
1700
1760
  sourceMap = new Map();
1701
- _context24.prev = 1;
1702
- _context24.next = 4;
1761
+ _context25.prev = 1;
1762
+ _context25.next = 4;
1703
1763
  return this.getProductList();
1704
1764
  case 4:
1705
- productList = _context24.sent;
1765
+ productList = _context25.sent;
1706
1766
  if (Array.isArray(productList)) {
1707
- _context24.next = 7;
1767
+ _context25.next = 7;
1708
1768
  break;
1709
1769
  }
1710
- return _context24.abrupt("return", sourceMap);
1770
+ return _context25.abrupt("return", sourceMap);
1711
1771
  case 7:
1712
1772
  visited = new Set();
1713
1773
  collectFromValue = function collectFromValue(value) {
@@ -1742,27 +1802,27 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1742
1802
  sourceMap.set(key, node);
1743
1803
  }
1744
1804
  }
1745
- for (var _i2 = 0, _Object$values = Object.values(node); _i2 < _Object$values.length; _i2++) {
1746
- var childValue = _Object$values[_i2];
1805
+ for (var _i3 = 0, _Object$values = Object.values(node); _i3 < _Object$values.length; _i3++) {
1806
+ var childValue = _Object$values[_i3];
1747
1807
  if (childValue && _typeof(childValue) === 'object') {
1748
1808
  collectFromValue(childValue);
1749
1809
  }
1750
1810
  }
1751
1811
  };
1752
1812
  collectFromValue(productList);
1753
- _context24.next = 15;
1813
+ _context25.next = 15;
1754
1814
  break;
1755
1815
  case 12:
1756
- _context24.prev = 12;
1757
- _context24.t0 = _context24["catch"](1);
1758
- this.logMethodError('buildPrefillProductSourceMap', _context24.t0);
1816
+ _context25.prev = 12;
1817
+ _context25.t0 = _context25["catch"](1);
1818
+ this.logMethodError('buildPrefillProductSourceMap', _context25.t0);
1759
1819
  case 15:
1760
- return _context24.abrupt("return", sourceMap);
1820
+ return _context25.abrupt("return", sourceMap);
1761
1821
  case 16:
1762
1822
  case "end":
1763
- return _context24.stop();
1823
+ return _context25.stop();
1764
1824
  }
1765
- }, _callee24, this, [[1, 12]]);
1825
+ }, _callee25, this, [[1, 12]]);
1766
1826
  }));
1767
1827
  function buildPrefillProductSourceMap() {
1768
1828
  return _buildPrefillProductSourceMap.apply(this, arguments);
@@ -1777,58 +1837,58 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1777
1837
  }, {
1778
1838
  key: "ensureItemRuleConfigsLoaded",
1779
1839
  value: function () {
1780
- var _ensureItemRuleConfigsLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
1840
+ var _ensureItemRuleConfigsLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
1781
1841
  var _this6 = this;
1782
1842
  var loadedConfigs;
1783
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
1784
- while (1) switch (_context26.prev = _context26.next) {
1843
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
1844
+ while (1) switch (_context27.prev = _context27.next) {
1785
1845
  case 0:
1786
1846
  if (!(this.itemRuleConfigs.length > 0)) {
1787
- _context26.next = 2;
1847
+ _context27.next = 2;
1788
1848
  break;
1789
1849
  }
1790
- return _context26.abrupt("return", this.itemRuleConfigs);
1850
+ return _context27.abrupt("return", this.itemRuleConfigs);
1791
1851
  case 2:
1792
1852
  if (!this.itemRuleConfigsPromise) {
1793
- _context26.next = 4;
1853
+ _context27.next = 4;
1794
1854
  break;
1795
1855
  }
1796
- return _context26.abrupt("return", this.itemRuleConfigsPromise);
1856
+ return _context27.abrupt("return", this.itemRuleConfigsPromise);
1797
1857
  case 4:
1798
- this.itemRuleConfigsPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
1858
+ this.itemRuleConfigsPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
1799
1859
  var runtimeConfig, staticConfigs;
1800
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
1801
- while (1) switch (_context25.prev = _context25.next) {
1860
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
1861
+ while (1) switch (_context26.prev = _context26.next) {
1802
1862
  case 0:
1803
1863
  runtimeConfig = _this6.getItemRuleRuntimeConfig();
1804
1864
  staticConfigs = normalizeItemRuleStrategies(runtimeConfig.strategyConfigs);
1805
1865
  if (!(staticConfigs.length > 0)) {
1806
- _context25.next = 6;
1866
+ _context26.next = 6;
1807
1867
  break;
1808
1868
  }
1809
1869
  _this6.itemRuleConfigs = staticConfigs;
1810
1870
  _this6.itemRuleEvaluator.setStrategyConfigs(staticConfigs);
1811
- return _context25.abrupt("return", _this6.itemRuleConfigs);
1871
+ return _context26.abrupt("return", _this6.itemRuleConfigs);
1812
1872
  case 6:
1813
1873
  _this6.itemRuleConfigs = [];
1814
1874
  _this6.itemRuleEvaluator.setStrategyConfigs([]);
1815
- return _context25.abrupt("return", _this6.itemRuleConfigs);
1875
+ return _context26.abrupt("return", _this6.itemRuleConfigs);
1816
1876
  case 9:
1817
1877
  case "end":
1818
- return _context25.stop();
1878
+ return _context26.stop();
1819
1879
  }
1820
- }, _callee25);
1880
+ }, _callee26);
1821
1881
  }))();
1822
- _context26.next = 7;
1882
+ _context27.next = 7;
1823
1883
  return this.itemRuleConfigsPromise;
1824
1884
  case 7:
1825
- loadedConfigs = _context26.sent;
1826
- return _context26.abrupt("return", loadedConfigs);
1885
+ loadedConfigs = _context27.sent;
1886
+ return _context27.abrupt("return", loadedConfigs);
1827
1887
  case 9:
1828
1888
  case "end":
1829
- return _context26.stop();
1889
+ return _context27.stop();
1830
1890
  }
1831
- }, _callee26, this);
1891
+ }, _callee27, this);
1832
1892
  }));
1833
1893
  function ensureItemRuleConfigsLoaded() {
1834
1894
  return _ensureItemRuleConfigsLoaded.apply(this, arguments);
@@ -1838,22 +1898,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1838
1898
  }, {
1839
1899
  key: "refreshItemRuleQuantityLimits",
1840
1900
  value: function () {
1841
- var _refreshItemRuleQuantityLimits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
1901
+ var _refreshItemRuleQuantityLimits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
1842
1902
  var strategyConfigs, businessData, limits;
1843
- return _regeneratorRuntime().wrap(function _callee27$(_context27) {
1844
- while (1) switch (_context27.prev = _context27.next) {
1903
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
1904
+ while (1) switch (_context28.prev = _context28.next) {
1845
1905
  case 0:
1846
- _context27.prev = 0;
1847
- _context27.next = 3;
1906
+ _context28.prev = 0;
1907
+ _context28.next = 3;
1848
1908
  return this.ensureItemRuleConfigsLoaded();
1849
1909
  case 3:
1850
- strategyConfigs = _context27.sent;
1910
+ strategyConfigs = _context28.sent;
1851
1911
  if (strategyConfigs.length) {
1852
- _context27.next = 7;
1912
+ _context28.next = 7;
1853
1913
  break;
1854
1914
  }
1855
1915
  this.store.itemRuleQuantityLimits = [];
1856
- return _context27.abrupt("return", []);
1916
+ return _context28.abrupt("return", []);
1857
1917
  case 7:
1858
1918
  businessData = buildItemRuleBusinessData({
1859
1919
  tempOrder: this.ensureTempOrder(),
@@ -1865,18 +1925,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1865
1925
  this.logMethodSuccess('refreshItemRuleQuantityLimits', {
1866
1926
  limitCount: limits.length
1867
1927
  });
1868
- return _context27.abrupt("return", limits);
1928
+ return _context28.abrupt("return", limits);
1869
1929
  case 14:
1870
- _context27.prev = 14;
1871
- _context27.t0 = _context27["catch"](0);
1930
+ _context28.prev = 14;
1931
+ _context28.t0 = _context28["catch"](0);
1872
1932
  this.store.itemRuleQuantityLimits = [];
1873
- this.logMethodError('refreshItemRuleQuantityLimits', _context27.t0);
1874
- return _context27.abrupt("return", []);
1933
+ this.logMethodError('refreshItemRuleQuantityLimits', _context28.t0);
1934
+ return _context28.abrupt("return", []);
1875
1935
  case 19:
1876
1936
  case "end":
1877
- return _context27.stop();
1937
+ return _context28.stop();
1878
1938
  }
1879
- }, _callee27, this, [[0, 14]]);
1939
+ }, _callee28, this, [[0, 14]]);
1880
1940
  }));
1881
1941
  function refreshItemRuleQuantityLimits() {
1882
1942
  return _refreshItemRuleQuantityLimits.apply(this, arguments);
@@ -1886,32 +1946,32 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1886
1946
  }, {
1887
1947
  key: "applyPrefillByItemRule",
1888
1948
  value: function () {
1889
- var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
1949
+ var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
1890
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;
1891
- return _regeneratorRuntime().wrap(function _callee28$(_context28) {
1892
- while (1) switch (_context28.prev = _context28.next) {
1951
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
1952
+ while (1) switch (_context29.prev = _context29.next) {
1893
1953
  case 0:
1894
1954
  if (!this.itemRulePrefillApplied) {
1895
- _context28.next = 2;
1955
+ _context29.next = 2;
1896
1956
  break;
1897
1957
  }
1898
- return _context28.abrupt("return");
1958
+ return _context29.abrupt("return");
1899
1959
  case 2:
1900
1960
  if (this.store.order) {
1901
- _context28.next = 4;
1961
+ _context29.next = 4;
1902
1962
  break;
1903
1963
  }
1904
- return _context28.abrupt("return");
1964
+ return _context29.abrupt("return");
1905
1965
  case 4:
1906
- _context28.next = 6;
1966
+ _context29.next = 6;
1907
1967
  return this.ensureItemRuleConfigsLoaded();
1908
1968
  case 6:
1909
- strategyConfigs = _context28.sent;
1969
+ strategyConfigs = _context29.sent;
1910
1970
  if (strategyConfigs.length) {
1911
- _context28.next = 9;
1971
+ _context29.next = 9;
1912
1972
  break;
1913
1973
  }
1914
- return _context28.abrupt("return");
1974
+ return _context29.abrupt("return");
1915
1975
  case 9:
1916
1976
  businessData = buildItemRuleBusinessData({
1917
1977
  tempOrder: this.ensureTempOrder(),
@@ -1920,24 +1980,24 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1920
1980
  });
1921
1981
  prefillItems = this.itemRuleEvaluator.getPrefillItems(businessData);
1922
1982
  if (prefillItems.length) {
1923
- _context28.next = 14;
1983
+ _context29.next = 14;
1924
1984
  break;
1925
1985
  }
1926
1986
  this.itemRulePrefillApplied = true;
1927
- return _context28.abrupt("return");
1987
+ return _context29.abrupt("return");
1928
1988
  case 14:
1929
- _context28.next = 16;
1989
+ _context29.next = 16;
1930
1990
  return this.buildPrefillProductSourceMap();
1931
1991
  case 16:
1932
- productSourceMap = _context28.sent;
1992
+ productSourceMap = _context29.sent;
1933
1993
  tempOrder = this.ensureTempOrder();
1934
1994
  hasChanges = false;
1935
1995
  _iterator5 = _createForOfIteratorHelper(prefillItems);
1936
- _context28.prev = 20;
1996
+ _context29.prev = 20;
1937
1997
  _iterator5.s();
1938
1998
  case 22:
1939
1999
  if ((_step5 = _iterator5.n()).done) {
1940
- _context28.next = 47;
2000
+ _context29.next = 47;
1941
2001
  break;
1942
2002
  }
1943
2003
  prefillItem = _step5.value;
@@ -1945,16 +2005,16 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1945
2005
  productVariantId = Number((_prefillItem$product_ = prefillItem.product_variant_id) !== null && _prefillItem$product_ !== void 0 ? _prefillItem$product_ : 0);
1946
2006
  targetQuantity = toNonNegativeInt(prefillItem.quantity);
1947
2007
  if (!(!Number.isFinite(productId) || targetQuantity <= 0)) {
1948
- _context28.next = 29;
2008
+ _context29.next = 29;
1949
2009
  break;
1950
2010
  }
1951
- return _context28.abrupt("continue", 45);
2011
+ return _context29.abrupt("continue", 45);
1952
2012
  case 29:
1953
2013
  if (!Number.isNaN(productVariantId)) {
1954
- _context28.next = 31;
2014
+ _context29.next = 31;
1955
2015
  break;
1956
2016
  }
1957
- return _context28.abrupt("continue", 45);
2017
+ return _context29.abrupt("continue", 45);
1958
2018
  case 31:
1959
2019
  sourceItem = productSourceMap.get(buildProductKey(productId, productVariantId)) || productSourceMap.get(buildProductKey(productId, 0)) || null;
1960
2020
  productIndex = getProductIdentityIndex(tempOrder.products, {
@@ -1962,7 +2022,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1962
2022
  product_variant_id: productVariantId
1963
2023
  });
1964
2024
  if (!(productIndex === -1)) {
1965
- _context28.next = 38;
2025
+ _context29.next = 38;
1966
2026
  break;
1967
2027
  }
1968
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');
@@ -1982,7 +2042,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1982
2042
  })
1983
2043
  })));
1984
2044
  hasChanges = true;
1985
- return _context28.abrupt("continue", 45);
2045
+ return _context29.abrupt("continue", 45);
1986
2046
  case 38:
1987
2047
  targetProduct = tempOrder.products[productIndex];
1988
2048
  existedQuantity = toNonNegativeInt(targetProduct.num);
@@ -2003,34 +2063,34 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2003
2063
  hasChanges = true;
2004
2064
  }
2005
2065
  case 45:
2006
- _context28.next = 22;
2066
+ _context29.next = 22;
2007
2067
  break;
2008
2068
  case 47:
2009
- _context28.next = 52;
2069
+ _context29.next = 52;
2010
2070
  break;
2011
2071
  case 49:
2012
- _context28.prev = 49;
2013
- _context28.t0 = _context28["catch"](20);
2014
- _iterator5.e(_context28.t0);
2072
+ _context29.prev = 49;
2073
+ _context29.t0 = _context29["catch"](20);
2074
+ _iterator5.e(_context29.t0);
2015
2075
  case 52:
2016
- _context28.prev = 52;
2076
+ _context29.prev = 52;
2017
2077
  _iterator5.f();
2018
- return _context28.finish(52);
2078
+ return _context29.finish(52);
2019
2079
  case 55:
2020
2080
  if (!hasChanges) {
2021
- _context28.next = 60;
2081
+ _context29.next = 60;
2022
2082
  break;
2023
2083
  }
2024
2084
  // Prefill 属于 products CRUD 的一种形式:新增后让 Rules 重算,以支持自动应用可用优惠券。
2025
2085
  this.store.order.applyDiscount();
2026
- _context28.next = 59;
2086
+ _context29.next = 59;
2027
2087
  return this.store.order.recalculateSummary({
2028
2088
  createIfMissing: true
2029
2089
  });
2030
2090
  case 59:
2031
2091
  this.store.order.persistTempOrder();
2032
2092
  case 60:
2033
- _context28.next = 62;
2093
+ _context29.next = 62;
2034
2094
  return this.refreshItemRuleQuantityLimits();
2035
2095
  case 62:
2036
2096
  this.itemRulePrefillApplied = true;
@@ -2040,9 +2100,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2040
2100
  });
2041
2101
  case 64:
2042
2102
  case "end":
2043
- return _context28.stop();
2103
+ return _context29.stop();
2044
2104
  }
2045
- }, _callee28, this, [[20, 49, 52, 55]]);
2105
+ }, _callee29, this, [[20, 49, 52, 55]]);
2046
2106
  }));
2047
2107
  function applyPrefillByItemRule() {
2048
2108
  return _applyPrefillByItemRule.apply(this, arguments);
@@ -2052,31 +2112,31 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2052
2112
  }, {
2053
2113
  key: "applyItemRulePrefill",
2054
2114
  value: function () {
2055
- var _applyItemRulePrefill = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
2115
+ var _applyItemRulePrefill = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
2056
2116
  var _this$store$order4, _this$store$order4$ge;
2057
- return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2058
- while (1) switch (_context29.prev = _context29.next) {
2117
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2118
+ while (1) switch (_context30.prev = _context30.next) {
2059
2119
  case 0:
2060
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))) {
2061
- _context29.next = 2;
2121
+ _context30.next = 2;
2062
2122
  break;
2063
2123
  }
2064
- return _context29.abrupt("return");
2124
+ return _context30.abrupt("return");
2065
2125
  case 2:
2066
2126
  this.logMethodStart('applyItemRulePrefill');
2067
- _context29.next = 5;
2127
+ _context30.next = 5;
2068
2128
  return this.applyPrefillByItemRule();
2069
2129
  case 5:
2070
- _context29.next = 7;
2130
+ _context30.next = 7;
2071
2131
  return this.refreshItemRuleQuantityLimits();
2072
2132
  case 7:
2073
- _context29.next = 9;
2133
+ _context30.next = 9;
2074
2134
  return this.refreshCartValidationPassed();
2075
2135
  case 9:
2076
2136
  case "end":
2077
- return _context29.stop();
2137
+ return _context30.stop();
2078
2138
  }
2079
- }, _callee29, this);
2139
+ }, _callee30, this);
2080
2140
  }));
2081
2141
  function applyItemRulePrefill() {
2082
2142
  return _applyItemRulePrefill.apply(this, arguments);
@@ -2086,20 +2146,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2086
2146
  }, {
2087
2147
  key: "evaluateCartValidationByItemRule",
2088
2148
  value: function () {
2089
- var _evaluateCartValidationByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
2149
+ var _evaluateCartValidationByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
2090
2150
  var strategyConfigs, businessData;
2091
- return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2092
- while (1) switch (_context30.prev = _context30.next) {
2151
+ return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2152
+ while (1) switch (_context31.prev = _context31.next) {
2093
2153
  case 0:
2094
- _context30.next = 2;
2154
+ _context31.next = 2;
2095
2155
  return this.ensureItemRuleConfigsLoaded();
2096
2156
  case 2:
2097
- strategyConfigs = _context30.sent;
2157
+ strategyConfigs = _context31.sent;
2098
2158
  if (strategyConfigs.length) {
2099
- _context30.next = 5;
2159
+ _context31.next = 5;
2100
2160
  break;
2101
2161
  }
2102
- return _context30.abrupt("return", {
2162
+ return _context31.abrupt("return", {
2103
2163
  passed: true,
2104
2164
  failures: []
2105
2165
  });
@@ -2109,12 +2169,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2109
2169
  runtimeConfig: this.getItemRuleRuntimeConfig(),
2110
2170
  itemRuleConfigs: this.itemRuleConfigs
2111
2171
  });
2112
- return _context30.abrupt("return", this.itemRuleEvaluator.validateCart(businessData));
2172
+ return _context31.abrupt("return", this.itemRuleEvaluator.validateCart(businessData));
2113
2173
  case 7:
2114
2174
  case "end":
2115
- return _context30.stop();
2175
+ return _context31.stop();
2116
2176
  }
2117
- }, _callee30, this);
2177
+ }, _callee31, this);
2118
2178
  }));
2119
2179
  function evaluateCartValidationByItemRule() {
2120
2180
  return _evaluateCartValidationByItemRule.apply(this, arguments);
@@ -2124,20 +2184,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2124
2184
  }, {
2125
2185
  key: "validateBeforeSubmitByItemRule",
2126
2186
  value: function () {
2127
- var _validateBeforeSubmitByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
2187
+ var _validateBeforeSubmitByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
2128
2188
  var validationResult, firstFailure, errorMessage, error;
2129
- return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2130
- while (1) switch (_context31.prev = _context31.next) {
2189
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2190
+ while (1) switch (_context32.prev = _context32.next) {
2131
2191
  case 0:
2132
- _context31.next = 2;
2192
+ _context32.next = 2;
2133
2193
  return this.evaluateCartValidationByItemRule();
2134
2194
  case 2:
2135
- validationResult = _context31.sent;
2195
+ validationResult = _context32.sent;
2136
2196
  if (!validationResult.passed) {
2137
- _context31.next = 5;
2197
+ _context32.next = 5;
2138
2198
  break;
2139
2199
  }
2140
- return _context31.abrupt("return");
2200
+ return _context32.abrupt("return");
2141
2201
  case 5:
2142
2202
  firstFailure = validationResult.failures[0];
2143
2203
  errorMessage = (firstFailure === null || firstFailure === void 0 ? void 0 : firstFailure.validationMessage) || '当前购物车未满足商品规则,请调整后再提交';
@@ -2146,9 +2206,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2146
2206
  throw error;
2147
2207
  case 10:
2148
2208
  case "end":
2149
- return _context31.stop();
2209
+ return _context32.stop();
2150
2210
  }
2151
- }, _callee31, this);
2211
+ }, _callee32, this);
2152
2212
  }));
2153
2213
  function validateBeforeSubmitByItemRule() {
2154
2214
  return _validateBeforeSubmitByItemRule.apply(this, arguments);
@@ -2158,10 +2218,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2158
2218
  }, {
2159
2219
  key: "refreshCartValidationPassed",
2160
2220
  value: function () {
2161
- var _refreshCartValidationPassed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
2221
+ var _refreshCartValidationPassed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
2162
2222
  var previous, nextState, validationResult, changed;
2163
- return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2164
- while (1) switch (_context32.prev = _context32.next) {
2223
+ return _regeneratorRuntime().wrap(function _callee33$(_context33) {
2224
+ while (1) switch (_context33.prev = _context33.next) {
2165
2225
  case 0:
2166
2226
  previous = this.store.cartValidation || {
2167
2227
  passed: null,
@@ -2171,20 +2231,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2171
2231
  passed: null,
2172
2232
  failures: []
2173
2233
  };
2174
- _context32.prev = 2;
2175
- _context32.next = 5;
2234
+ _context33.prev = 2;
2235
+ _context33.next = 5;
2176
2236
  return this.evaluateCartValidationByItemRule();
2177
2237
  case 5:
2178
- validationResult = _context32.sent;
2238
+ validationResult = _context33.sent;
2179
2239
  nextState = {
2180
2240
  passed: validationResult.passed,
2181
2241
  failures: validationResult.failures || []
2182
2242
  };
2183
- _context32.next = 12;
2243
+ _context33.next = 12;
2184
2244
  break;
2185
2245
  case 9:
2186
- _context32.prev = 9;
2187
- _context32.t0 = _context32["catch"](2);
2246
+ _context33.prev = 9;
2247
+ _context33.t0 = _context33["catch"](2);
2188
2248
  nextState = {
2189
2249
  passed: false,
2190
2250
  failures: []
@@ -2193,21 +2253,21 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2193
2253
  this.store.cartValidation = nextState;
2194
2254
  changed = previous.passed !== nextState.passed || previous.failures !== nextState.failures;
2195
2255
  if (!changed) {
2196
- _context32.next = 17;
2256
+ _context33.next = 17;
2197
2257
  break;
2198
2258
  }
2199
- _context32.next = 17;
2259
+ _context33.next = 17;
2200
2260
  return this.core.effects.emit(ScanOrderHooks.onCartValidationChanged, {
2201
2261
  cartValidation: nextState,
2202
2262
  cartValidationPassed: nextState.passed
2203
2263
  });
2204
2264
  case 17:
2205
- return _context32.abrupt("return", nextState.passed);
2265
+ return _context33.abrupt("return", nextState.passed);
2206
2266
  case 18:
2207
2267
  case "end":
2208
- return _context32.stop();
2268
+ return _context33.stop();
2209
2269
  }
2210
- }, _callee32, this, [[2, 9]]);
2270
+ }, _callee33, this, [[2, 9]]);
2211
2271
  }));
2212
2272
  function refreshCartValidationPassed() {
2213
2273
  return _refreshCartValidationPassed.apply(this, arguments);
@@ -2217,14 +2277,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2217
2277
  }, {
2218
2278
  key: "setItemRuleRuntimeConfig",
2219
2279
  value: function () {
2220
- var _setItemRuleRuntimeConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
2280
+ var _setItemRuleRuntimeConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
2221
2281
  var _this$itemRuleRuntime, _this$itemRuleRuntime2;
2222
2282
  var config,
2223
- _args33 = arguments;
2224
- return _regeneratorRuntime().wrap(function _callee33$(_context33) {
2225
- while (1) switch (_context33.prev = _context33.next) {
2283
+ _args34 = arguments;
2284
+ return _regeneratorRuntime().wrap(function _callee34$(_context34) {
2285
+ while (1) switch (_context34.prev = _context34.next) {
2226
2286
  case 0:
2227
- config = _args33.length > 0 && _args33[0] !== undefined ? _args33[0] : {};
2287
+ config = _args34.length > 0 && _args34[0] !== undefined ? _args34[0] : {};
2228
2288
  this.logMethodStart('setItemRuleRuntimeConfig');
2229
2289
  this.itemRuleRuntimeConfig = _objectSpread(_objectSpread(_objectSpread({}, this.itemRuleRuntimeConfig), config), {}, {
2230
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) || {}),
@@ -2236,10 +2296,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2236
2296
  this.itemRuleEvaluator.setStrategyConfigs([]);
2237
2297
  }
2238
2298
  this.itemRulePrefillApplied = false;
2239
- _context33.next = 7;
2299
+ _context34.next = 7;
2240
2300
  return this.refreshItemRuleQuantityLimits();
2241
2301
  case 7:
2242
- _context33.next = 9;
2302
+ _context34.next = 9;
2243
2303
  return this.refreshCartValidationPassed();
2244
2304
  case 9:
2245
2305
  this.logMethodSuccess('setItemRuleRuntimeConfig', {
@@ -2247,9 +2307,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2247
2307
  });
2248
2308
  case 10:
2249
2309
  case "end":
2250
- return _context33.stop();
2310
+ return _context34.stop();
2251
2311
  }
2252
- }, _callee33, this);
2312
+ }, _callee34, this);
2253
2313
  }));
2254
2314
  function setItemRuleRuntimeConfig() {
2255
2315
  return _setItemRuleRuntimeConfig.apply(this, arguments);
@@ -2348,27 +2408,27 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2348
2408
  }, {
2349
2409
  key: "fetchResourceOccupyDetailByResourceId",
2350
2410
  value: function () {
2351
- var _fetchResourceOccupyDetailByResourceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(resourceId) {
2411
+ var _fetchResourceOccupyDetailByResourceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(resourceId) {
2352
2412
  var _this$otherParams9, _this$otherParams9$ge, _response$data$occupy, _response$data;
2353
2413
  var formRecordId, shopId, response;
2354
- return _regeneratorRuntime().wrap(function _callee34$(_context34) {
2355
- while (1) switch (_context34.prev = _context34.next) {
2414
+ return _regeneratorRuntime().wrap(function _callee35$(_context35) {
2415
+ while (1) switch (_context35.prev = _context35.next) {
2356
2416
  case 0:
2357
2417
  formRecordId = Number(resourceId);
2358
2418
  if (!(!Number.isFinite(formRecordId) || formRecordId <= 0)) {
2359
- _context34.next = 3;
2419
+ _context35.next = 3;
2360
2420
  break;
2361
2421
  }
2362
2422
  throw new Error("[ScanOrder] \u975E\u6CD5\u684C\u53F0 resourceId: ".concat(resourceId));
2363
2423
  case 3:
2364
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');
2365
2425
  if (shopId) {
2366
- _context34.next = 6;
2426
+ _context35.next = 6;
2367
2427
  break;
2368
2428
  }
2369
2429
  throw new Error('[ScanOrder] 无法获取 shop_id');
2370
2430
  case 6:
2371
- _context34.next = 8;
2431
+ _context35.next = 8;
2372
2432
  return this.request.get('/order/resource/occupy-detail', {
2373
2433
  shop_id: shopId,
2374
2434
  'form_record_ids[]': formRecordId,
@@ -2377,19 +2437,19 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2377
2437
  with_resource_form_info: 1
2378
2438
  });
2379
2439
  case 8:
2380
- response = _context34.sent;
2440
+ response = _context35.sent;
2381
2441
  if (response !== null && response !== void 0 && response.status) {
2382
- _context34.next = 11;
2442
+ _context35.next = 11;
2383
2443
  break;
2384
2444
  }
2385
2445
  throw new Error((response === null || response === void 0 ? void 0 : response.message) || '获取资源占用详情失败');
2386
2446
  case 11:
2387
- return _context34.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);
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);
2388
2448
  case 12:
2389
2449
  case "end":
2390
- return _context34.stop();
2450
+ return _context35.stop();
2391
2451
  }
2392
- }, _callee34, this);
2452
+ }, _callee35, this);
2393
2453
  }));
2394
2454
  function fetchResourceOccupyDetailByResourceId(_x17) {
2395
2455
  return _fetchResourceOccupyDetailByResourceId.apply(this, arguments);
@@ -2401,32 +2461,32 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2401
2461
  }, {
2402
2462
  key: "checkResourceAvailable",
2403
2463
  value: function () {
2404
- var _checkResourceAvailable = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(resourceId, hasOrderId) {
2464
+ var _checkResourceAvailable = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(resourceId, hasOrderId) {
2405
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;
2406
- return _regeneratorRuntime().wrap(function _callee35$(_context35) {
2407
- while (1) switch (_context35.prev = _context35.next) {
2466
+ return _regeneratorRuntime().wrap(function _callee36$(_context36) {
2467
+ while (1) switch (_context36.prev = _context36.next) {
2408
2468
  case 0:
2409
2469
  this.logMethodStart('checkResourceAvailable', {
2410
2470
  resourceId: resourceId
2411
2471
  });
2412
- _context35.prev = 1;
2413
- _context35.next = 4;
2472
+ _context36.prev = 1;
2473
+ _context36.next = 4;
2414
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, {
2415
2475
  scope: 'board',
2416
2476
  target: 'dine_in+scan_to_order',
2417
2477
  section_code: ['basic', 'fulfillment', 'reservation', 'sale', 'menu', 'availability', 'workflow']
2418
2478
  });
2419
2479
  case 4:
2420
- openData = _context35.sent;
2480
+ openData = _context36.sent;
2421
2481
  if (!((openData === null || openData === void 0 ? void 0 : openData.status) === false)) {
2422
- _context35.next = 7;
2482
+ _context36.next = 7;
2423
2483
  break;
2424
2484
  }
2425
2485
  throw new Error((openData === null || openData === void 0 ? void 0 : openData.message) || '获取店铺配置失败');
2426
2486
  case 7:
2427
2487
  dineInConfig = (openData === null || openData === void 0 ? void 0 : openData.data) || {};
2428
2488
  this.otherParams.dineInConfig = dineInConfig;
2429
- _context35.next = 11;
2489
+ _context36.next = 11;
2430
2490
  return this.syncItemRuleConfigsFromDineInConfig(dineInConfig);
2431
2491
  case 11:
2432
2492
  closedBehaviorValue = dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.closed_behavior'];
@@ -2445,20 +2505,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2445
2505
  };
2446
2506
  }; // 1. 基础开关 basic.enable 关闭
2447
2507
  if (!((dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['basic.enable']) === false)) {
2448
- _context35.next = 18;
2508
+ _context36.next = 18;
2449
2509
  break;
2450
2510
  }
2451
- return _context35.abrupt("return", makeShopClosed(basicUnavailableMessage));
2511
+ return _context36.abrupt("return", makeShopClosed(basicUnavailableMessage));
2452
2512
  case 18:
2453
2513
  if (!toBoolean(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.paused'])) {
2454
- _context35.next = 21;
2514
+ _context36.next = 21;
2455
2515
  break;
2456
2516
  }
2457
2517
  if (!((dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.pause_behavior']) === 'hide_all')) {
2458
- _context35.next = 21;
2518
+ _context36.next = 21;
2459
2519
  break;
2460
2520
  }
2461
- return _context35.abrupt("return", makeShopClosed(pauseMessage));
2521
+ return _context36.abrupt("return", makeShopClosed(pauseMessage));
2462
2522
  case 21:
2463
2523
  // 3. 营业时间 operating_hours 闸门
2464
2524
  operatingHourIds = Array.isArray(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.operating_hours']) ? dineInConfig['availability.operating_hours'].map(function (id) {
@@ -2475,27 +2535,27 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2475
2535
  }
2476
2536
  }
2477
2537
  if (!(outsideOperatingHours && closedBehaviorValue !== 'show_menu_disabled')) {
2478
- _context35.next = 26;
2538
+ _context36.next = 26;
2479
2539
  break;
2480
2540
  }
2481
- return _context35.abrupt("return", makeShopClosed(closedMessage, closedBehaviorValue));
2541
+ return _context36.abrupt("return", makeShopClosed(closedMessage, closedBehaviorValue));
2482
2542
  case 26:
2483
2543
  // Step1: 先加载预约规则商品,拿到 enabledReservationRuleProducts 与容量附加信息
2484
2544
  // (resourceSelectType 需要基于这些商品 + 占用接口的 form_id 计算,故必须前置)
2485
2545
  tempOrder = this.ensureTempOrder();
2486
2546
  reservationLinkIds = collectLinkProductIdsFromReservationRules(dineInConfig['fulfillment.enabled_resource_rules']);
2487
2547
  if (!(reservationLinkIds.length === 0)) {
2488
- _context35.next = 32;
2548
+ _context36.next = 32;
2489
2549
  break;
2490
2550
  }
2491
2551
  this.enabledReservationRuleProducts = [];
2492
- _context35.next = 43;
2552
+ _context36.next = 43;
2493
2553
  break;
2494
2554
  case 32:
2495
2555
  tempOrder.metadata = _objectSpread({}, tempOrder.metadata || {});
2496
2556
  delete tempOrder.metadata.table_occupancy_duration;
2497
2557
  reservationProductList = new ProductList("".concat(this.name, "_reservationEnabledRules"), this.defaultVersion);
2498
- _context35.next = 37;
2558
+ _context36.next = 37;
2499
2559
  return reservationProductList.initialize(this.core, {
2500
2560
  store: {
2501
2561
  list: [],
@@ -2510,7 +2570,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2510
2570
  case 37:
2511
2571
  scheduleDate = dayjs().format('YYYY-MM-DD');
2512
2572
  scheduleDatetime = dayjs().format('YYYY-MM-DD HH:mm:ss');
2513
- _context35.next = 41;
2573
+ _context36.next = 41;
2514
2574
  return reservationProductList.loadProducts({
2515
2575
  product_ids: reservationLinkIds,
2516
2576
  schedule_date: scheduleDate,
@@ -2518,7 +2578,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2518
2578
  cacheId: this.cacheId
2519
2579
  });
2520
2580
  case 41:
2521
- loaded = _context35.sent;
2581
+ loaded = _context36.sent;
2522
2582
  if (Array.isArray(loaded)) {
2523
2583
  this.enabledReservationRuleProducts = loaded;
2524
2584
  occupancyMinutes = pickFirstDurationMinutesFromProducts(loaded);
@@ -2543,10 +2603,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2543
2603
  });
2544
2604
  }
2545
2605
  case 43:
2546
- _context35.next = 45;
2606
+ _context36.next = 45;
2547
2607
  return this.fetchResourceOccupyDetailByResourceId(resourceId);
2548
2608
  case 45:
2549
- occupyDetail = _context35.sent;
2609
+ occupyDetail = _context36.sent;
2550
2610
  // Step3: 结合预约规则商品的 product_resource.resources 与占用接口返回的 form_id,
2551
2611
  // 计算当前桌台的 resourceSelectType(single/multiple/capacity)
2552
2612
  resourceSelectType = this.resolveResourceSelectType(toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_id)); // Step4: 用 occupyDetail + resourceSelectType 规整为 resourceState
@@ -2586,10 +2646,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2586
2646
 
2587
2647
  // 空闲状态下自动准备本地临时订单,供后续“购物车式”商品操作使用
2588
2648
  if (!(availabilityInfo.mode === 'idle')) {
2589
- _context35.next = 60;
2649
+ _context36.next = 60;
2590
2650
  break;
2591
2651
  }
2592
- _context35.next = 60;
2652
+ _context36.next = 60;
2593
2653
  return this.addNewOrder();
2594
2654
  case 60:
2595
2655
  // 如果是加单模式,tempOrder 里 需要记录 lastOrderId,提交的时候走加单接口
@@ -2597,23 +2657,23 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2597
2657
  tempOrder.order_id = resourceState.lastOrderId;
2598
2658
  }
2599
2659
  if (!tempOrder.order_id) {
2600
- _context35.next = 69;
2660
+ _context36.next = 69;
2601
2661
  break;
2602
2662
  }
2603
- _context35.next = 64;
2663
+ _context36.next = 64;
2604
2664
  return (_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 ? void 0 : _this$store$order6.getOrderInfoByRemote(tempOrder.order_id);
2605
2665
  case 64:
2606
- res = _context35.sent;
2666
+ res = _context36.sent;
2607
2667
  // 找到下单的时候输入的 entryPaxNumber
2608
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) {
2609
2669
  var _p$metadata;
2610
2670
  return (_p$metadata = p.metadata) === null || _p$metadata === void 0 ? void 0 : _p$metadata.collect_pax;
2611
2671
  })) === null || _res$data === void 0 || (_res$data = _res$data.metadata) === null || _res$data === void 0 ? void 0 : _res$data.collect_pax;
2612
2672
  if (!entryPaxNumber) {
2613
- _context35.next = 69;
2673
+ _context36.next = 69;
2614
2674
  break;
2615
2675
  }
2616
- _context35.next = 69;
2676
+ _context36.next = 69;
2617
2677
  return this.setEntryPaxNumber(entryPaxNumber);
2618
2678
  case 69:
2619
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);
@@ -2627,7 +2687,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2627
2687
  } : {}));
2628
2688
  return acc;
2629
2689
  }, []) : []; // pax 由 setEntryPaxNumber 负责写入 itemRuleRuntimeConfig.pax
2630
- _context35.next = 73;
2690
+ _context36.next = 73;
2631
2691
  return this.setItemRuleRuntimeConfig({
2632
2692
  serviceType: (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.businessCode,
2633
2693
  submissionIndex: hasOrderId ? 1 : 0,
@@ -2654,19 +2714,19 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2654
2714
  isExclusive: resourceState.isExclusive,
2655
2715
  isFull: resourceState.isFull
2656
2716
  });
2657
- return _context35.abrupt("return", availabilityInfo);
2717
+ return _context36.abrupt("return", availabilityInfo);
2658
2718
  case 78:
2659
- _context35.prev = 78;
2660
- _context35.t0 = _context35["catch"](1);
2661
- this.logMethodError('checkResourceAvailable', _context35.t0.message, {
2719
+ _context36.prev = 78;
2720
+ _context36.t0 = _context36["catch"](1);
2721
+ this.logMethodError('checkResourceAvailable', _context36.t0.message, {
2662
2722
  resourceId: resourceId
2663
2723
  });
2664
- throw _context35.t0;
2724
+ throw _context36.t0;
2665
2725
  case 82:
2666
2726
  case "end":
2667
- return _context35.stop();
2727
+ return _context36.stop();
2668
2728
  }
2669
- }, _callee35, this, [[1, 78]]);
2729
+ }, _callee36, this, [[1, 78]]);
2670
2730
  }));
2671
2731
  function checkResourceAvailable(_x18, _x19) {
2672
2732
  return _checkResourceAvailable.apply(this, arguments);
@@ -2676,10 +2736,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2676
2736
  }, {
2677
2737
  key: "getAdditionalOrderInfo",
2678
2738
  value: function () {
2679
- var _getAdditionalOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {
2739
+ var _getAdditionalOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {
2680
2740
  var result;
2681
- return _regeneratorRuntime().wrap(function _callee36$(_context36) {
2682
- while (1) switch (_context36.prev = _context36.next) {
2741
+ return _regeneratorRuntime().wrap(function _callee37$(_context37) {
2742
+ while (1) switch (_context37.prev = _context37.next) {
2683
2743
  case 0:
2684
2744
  this.logMethodStart('getAdditionalOrderInfo');
2685
2745
  result = {
@@ -2693,12 +2753,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2693
2753
  orderId: result.orderId,
2694
2754
  orderStatus: result.orderStatus
2695
2755
  });
2696
- return _context36.abrupt("return", result);
2756
+ return _context37.abrupt("return", result);
2697
2757
  case 4:
2698
2758
  case "end":
2699
- return _context36.stop();
2759
+ return _context37.stop();
2700
2760
  }
2701
- }, _callee36, this);
2761
+ }, _callee37, this);
2702
2762
  }));
2703
2763
  function getAdditionalOrderInfo() {
2704
2764
  return _getAdditionalOrderInfo.apply(this, arguments);
@@ -2708,19 +2768,19 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2708
2768
  }, {
2709
2769
  key: "getProductList",
2710
2770
  value: function () {
2711
- var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {
2771
+ var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
2712
2772
  var _this$otherParams13;
2713
2773
  var menu_list_ids, _this$store$products, res, formattedRes;
2714
- return _regeneratorRuntime().wrap(function _callee37$(_context37) {
2715
- while (1) switch (_context37.prev = _context37.next) {
2774
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
2775
+ while (1) switch (_context38.prev = _context38.next) {
2716
2776
  case 0:
2717
2777
  this.logMethodStart('getProductList');
2718
2778
  // 可以直接通过配置里的 menu 读取
2719
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) {
2720
2780
  return Number(n.value);
2721
2781
  })) || [];
2722
- _context37.prev = 2;
2723
- _context37.next = 5;
2782
+ _context38.prev = 2;
2783
+ _context38.next = 5;
2724
2784
  return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
2725
2785
  menu_list_ids: menu_list_ids,
2726
2786
  cacheId: this.cacheId,
@@ -2728,22 +2788,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2728
2788
  schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
2729
2789
  });
2730
2790
  case 5:
2731
- res = _context37.sent;
2791
+ res = _context38.sent;
2732
2792
  formattedRes = attachItemRuleLimitsToTopLevelProducts(res, this.store.itemRuleQuantityLimits || []);
2733
2793
  this.logMethodSuccess('getProductList', {
2734
2794
  menuCount: menu_list_ids.length
2735
2795
  });
2736
- return _context37.abrupt("return", formattedRes);
2796
+ return _context38.abrupt("return", formattedRes);
2737
2797
  case 11:
2738
- _context37.prev = 11;
2739
- _context37.t0 = _context37["catch"](2);
2740
- this.logMethodError('getProductList', _context37.t0.message);
2741
- throw _context37.t0;
2798
+ _context38.prev = 11;
2799
+ _context38.t0 = _context38["catch"](2);
2800
+ this.logMethodError('getProductList', _context38.t0.message);
2801
+ throw _context38.t0;
2742
2802
  case 15:
2743
2803
  case "end":
2744
- return _context37.stop();
2804
+ return _context38.stop();
2745
2805
  }
2746
- }, _callee37, this, [[2, 11]]);
2806
+ }, _callee38, this, [[2, 11]]);
2747
2807
  }));
2748
2808
  function getProductList() {
2749
2809
  return _getProductList.apply(this, arguments);
@@ -2758,15 +2818,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2758
2818
  }, {
2759
2819
  key: "setOtherParams",
2760
2820
  value: function () {
2761
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
2821
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
2762
2822
  var _ref8,
2763
2823
  _ref8$cover,
2764
2824
  cover,
2765
- _args38 = arguments;
2766
- return _regeneratorRuntime().wrap(function _callee38$(_context38) {
2767
- while (1) switch (_context38.prev = _context38.next) {
2825
+ _args39 = arguments;
2826
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
2827
+ while (1) switch (_context39.prev = _context39.next) {
2768
2828
  case 0:
2769
- _ref8 = _args38.length > 1 && _args38[1] !== undefined ? _args38[1] : {}, _ref8$cover = _ref8.cover, cover = _ref8$cover === void 0 ? false : _ref8$cover;
2829
+ _ref8 = _args39.length > 1 && _args39[1] !== undefined ? _args39[1] : {}, _ref8$cover = _ref8.cover, cover = _ref8$cover === void 0 ? false : _ref8$cover;
2770
2830
  if (cover) {
2771
2831
  this.otherParams = params;
2772
2832
  } else {
@@ -2774,9 +2834,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2774
2834
  }
2775
2835
  case 2:
2776
2836
  case "end":
2777
- return _context38.stop();
2837
+ return _context39.stop();
2778
2838
  }
2779
- }, _callee38, this);
2839
+ }, _callee39, this);
2780
2840
  }));
2781
2841
  function setOtherParams(_x20) {
2782
2842
  return _setOtherParams.apply(this, arguments);
@@ -2868,10 +2928,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2868
2928
  }, {
2869
2929
  key: "setEntryPaxNumber",
2870
2930
  value: function () {
2871
- var _setEntryPaxNumber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(number) {
2931
+ var _setEntryPaxNumber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(number) {
2872
2932
  var pax, t;
2873
- return _regeneratorRuntime().wrap(function _callee39$(_context39) {
2874
- while (1) switch (_context39.prev = _context39.next) {
2933
+ return _regeneratorRuntime().wrap(function _callee40$(_context40) {
2934
+ while (1) switch (_context40.prev = _context40.next) {
2875
2935
  case 0:
2876
2936
  pax = normalizeSubmitCollectPaxValue(number);
2877
2937
  this.store.entryPaxNumber = pax;
@@ -2892,16 +2952,16 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2892
2952
  }
2893
2953
  });
2894
2954
  this.itemRulePrefillApplied = false;
2895
- _context39.next = 7;
2955
+ _context40.next = 7;
2896
2956
  return this.refreshItemRuleQuantityLimits();
2897
2957
  case 7:
2898
- _context39.next = 9;
2958
+ _context40.next = 9;
2899
2959
  return this.refreshCartValidationPassed();
2900
2960
  case 9:
2901
2961
  case "end":
2902
- return _context39.stop();
2962
+ return _context40.stop();
2903
2963
  }
2904
- }, _callee39, this);
2964
+ }, _callee40, this);
2905
2965
  }));
2906
2966
  function setEntryPaxNumber(_x21) {
2907
2967
  return _setEntryPaxNumber.apply(this, arguments);