@pisell/pisellos 2.2.243 → 2.2.245

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.
Files changed (37) hide show
  1. package/dist/modules/Discount/index.d.ts +1 -1
  2. package/dist/modules/Discount/index.js +10 -4
  3. package/dist/modules/Order/index.d.ts +7 -1
  4. package/dist/modules/Order/index.js +649 -514
  5. package/dist/modules/Order/types.d.ts +7 -0
  6. package/dist/modules/Order/utils.js +5 -2
  7. package/dist/modules/Payment/walletpass.js +33 -24
  8. package/dist/modules/Rules/index.js +4 -1
  9. package/dist/server/index.js +6 -4
  10. package/dist/server/modules/order/index.d.ts +1 -0
  11. package/dist/server/modules/order/index.js +60 -46
  12. package/dist/server/utils/small-ticket.js +39 -29
  13. package/dist/solution/BaseSales/index.d.ts +3 -2
  14. package/dist/solution/BaseSales/index.js +6 -0
  15. package/dist/solution/BaseSales/types.d.ts +6 -0
  16. package/dist/solution/BookingByStep/index.d.ts +1 -1
  17. package/dist/solution/BookingTicket/index.d.ts +1 -1
  18. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +46 -45
  19. package/lib/modules/Discount/index.d.ts +1 -1
  20. package/lib/modules/Discount/index.js +4 -0
  21. package/lib/modules/Order/index.d.ts +7 -1
  22. package/lib/modules/Order/index.js +105 -1
  23. package/lib/modules/Order/types.d.ts +7 -0
  24. package/lib/modules/Order/utils.js +1 -0
  25. package/lib/modules/Payment/walletpass.js +9 -0
  26. package/lib/modules/Rules/index.js +1 -0
  27. package/lib/server/index.js +1 -0
  28. package/lib/server/modules/order/index.d.ts +1 -0
  29. package/lib/server/modules/order/index.js +54 -42
  30. package/lib/server/utils/small-ticket.js +21 -2
  31. package/lib/solution/BaseSales/index.d.ts +3 -2
  32. package/lib/solution/BaseSales/index.js +5 -0
  33. package/lib/solution/BaseSales/types.d.ts +6 -0
  34. package/lib/solution/BookingByStep/index.d.ts +1 -1
  35. package/lib/solution/BookingTicket/index.d.ts +1 -1
  36. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +2 -1
  37. package/package.json +1 -1
@@ -18,6 +18,8 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
18
18
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
19
19
  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); } }
20
20
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
21
+ 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); }
22
+ function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
21
23
  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); }
22
24
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
23
25
  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); }; }
@@ -275,6 +277,64 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
275
277
  }
276
278
  return initialize;
277
279
  }()
280
+ }, {
281
+ key: "destroy",
282
+ value: function () {
283
+ var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
284
+ var _this$store, _this$store2;
285
+ var childModules, _i, _childModules, childModule, errorMessage;
286
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
287
+ while (1) switch (_context2.prev = _context2.next) {
288
+ case 0:
289
+ childModules = [(_this$store = this.store) === null || _this$store === void 0 ? void 0 : _this$store.discount, (_this$store2 = this.store) === null || _this$store2 === void 0 ? void 0 : _this$store2.rules];
290
+ _i = 0, _childModules = childModules;
291
+ case 2:
292
+ if (!(_i < _childModules.length)) {
293
+ _context2.next = 18;
294
+ break;
295
+ }
296
+ childModule = _childModules[_i];
297
+ if (!(!childModule || typeof childModule.destroy !== 'function')) {
298
+ _context2.next = 6;
299
+ break;
300
+ }
301
+ return _context2.abrupt("continue", 15);
302
+ case 6:
303
+ _context2.prev = 6;
304
+ _context2.next = 9;
305
+ return childModule.destroy();
306
+ case 9:
307
+ _context2.next = 15;
308
+ break;
309
+ case 11:
310
+ _context2.prev = 11;
311
+ _context2.t0 = _context2["catch"](6);
312
+ errorMessage = _context2.t0 instanceof Error ? _context2.t0.message : String(_context2.t0);
313
+ this.logWarning('Destroy child module failed', {
314
+ module: childModule.name,
315
+ error: errorMessage
316
+ });
317
+ case 15:
318
+ _i++;
319
+ _context2.next = 2;
320
+ break;
321
+ case 18:
322
+ if (this.store) {
323
+ this.store.discount = null;
324
+ this.store.rules = null;
325
+ }
326
+ _get(_getPrototypeOf(OrderModule.prototype), "destroy", this).call(this);
327
+ case 20:
328
+ case "end":
329
+ return _context2.stop();
330
+ }
331
+ }, _callee2, this, [[6, 11]]);
332
+ }));
333
+ function destroy() {
334
+ return _destroy.apply(this, arguments);
335
+ }
336
+ return destroy;
337
+ }()
278
338
  /**
279
339
  * 更新父级解决方案透传的运行态参数,并同步 Order 内部依赖的派生字段。
280
340
  *
@@ -381,14 +441,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
381
441
  }, {
382
442
  key: "loadDiscountConfig",
383
443
  value: function () {
384
- var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
444
+ var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
385
445
  var _this$store$tempOrder, _this$store$discount, _this$store$tempOrder2;
386
446
  var orderId, discountList, _this$store$discount2, _this$store$discount3, _this$store$discount4, currentEditDiscounts, currentEditDiscountIds, mergedDiscountList;
387
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
388
- while (1) switch (_context2.prev = _context2.next) {
447
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
448
+ while (1) switch (_context3.prev = _context3.next) {
389
449
  case 0:
390
450
  orderId = params.orderId || ((_this$store$tempOrder = this.store.tempOrder) === null || _this$store$tempOrder === void 0 ? void 0 : _this$store$tempOrder.order_id) || undefined;
391
- _context2.next = 3;
451
+ _context3.next = 3;
392
452
  return (_this$store$discount = this.store.discount) === null || _this$store$discount === void 0 ? void 0 : _this$store$discount.loadPrepareConfig(_objectSpread({
393
453
  customer_id: params.customerId,
394
454
  action: params.action || (orderId ? 'edit' : 'create'),
@@ -400,9 +460,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
400
460
  order_id: orderId
401
461
  } : {}));
402
462
  case 3:
403
- discountList = _context2.sent;
463
+ discountList = _context3.sent;
404
464
  if (!discountList) {
405
- _context2.next = 12;
465
+ _context3.next = 12;
406
466
  break;
407
467
  }
408
468
  currentEditDiscounts = (((_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 ? void 0 : _this$store$discount2.getDiscountList()) || []).filter(function (discount) {
@@ -414,21 +474,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
414
474
  mergedDiscountList = [].concat(_toConsumableArray(currentEditDiscounts), _toConsumableArray(discountList.filter(function (discount) {
415
475
  return !currentEditDiscountIds.has(discount === null || discount === void 0 ? void 0 : discount.id);
416
476
  })));
417
- _context2.next = 10;
477
+ _context3.next = 10;
418
478
  return (_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.setOriginalDiscountList(mergedDiscountList);
419
479
  case 10:
420
- _context2.next = 12;
480
+ _context3.next = 12;
421
481
  return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.setDiscountList(mergedDiscountList);
422
482
  case 12:
423
483
  if (params.apply !== false && (_this$store$tempOrder2 = this.store.tempOrder) !== null && _this$store$tempOrder2 !== void 0 && (_this$store$tempOrder2 = _this$store$tempOrder2.products) !== null && _this$store$tempOrder2 !== void 0 && _this$store$tempOrder2.length) {
424
484
  this.applyDiscount();
425
485
  }
426
- return _context2.abrupt("return", this.getDiscountList());
486
+ return _context3.abrupt("return", this.getDiscountList());
427
487
  case 14:
428
488
  case "end":
429
- return _context2.stop();
489
+ return _context3.stop();
430
490
  }
431
- }, _callee2, this);
491
+ }, _callee3, this);
432
492
  }));
433
493
  function loadDiscountConfig(_x3) {
434
494
  return _loadDiscountConfig.apply(this, arguments);
@@ -444,31 +504,31 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
444
504
  }, {
445
505
  key: "ensureEditDiscountConfigForProductChange",
446
506
  value: function () {
447
- var _ensureEditDiscountConfigForProductChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(tempOrder) {
507
+ var _ensureEditDiscountConfigForProductChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(tempOrder) {
448
508
  var _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _this$store$discount6;
449
509
  var orderId, customerId, currentDiscountList, hasRuntimeDiscounts;
450
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
451
- while (1) switch (_context3.prev = _context3.next) {
510
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
511
+ while (1) switch (_context4.prev = _context4.next) {
452
512
  case 0:
453
513
  orderId = tempOrder.order_id;
454
514
  customerId = Number(tempOrder.customer_id || ((_tempOrder$customer = tempOrder.customer) === null || _tempOrder$customer === void 0 ? void 0 : _tempOrder$customer.id) || ((_tempOrder$_extend = tempOrder._extend) === null || _tempOrder$_extend === void 0 || (_tempOrder$_extend = _tempOrder$_extend.customerSnapshot) === null || _tempOrder$_extend === void 0 ? void 0 : _tempOrder$_extend.id) || ((_tempOrder$_extend2 = tempOrder._extend) === null || _tempOrder$_extend2 === void 0 || (_tempOrder$_extend2 = _tempOrder$_extend2.customerSnapshot) === null || _tempOrder$_extend2 === void 0 ? void 0 : _tempOrder$_extend2.customer_id) || 0);
455
515
  if (!(!orderId || !customerId || customerId === 1)) {
456
- _context3.next = 4;
516
+ _context4.next = 4;
457
517
  break;
458
518
  }
459
- return _context3.abrupt("return");
519
+ return _context4.abrupt("return");
460
520
  case 4:
461
521
  currentDiscountList = ((_this$store$discount6 = this.store.discount) === null || _this$store$discount6 === void 0 ? void 0 : _this$store$discount6.getDiscountList()) || [];
462
522
  hasRuntimeDiscounts = currentDiscountList.some(function (discount) {
463
523
  return !(discount !== null && discount !== void 0 && discount.isEditMode);
464
524
  });
465
525
  if (!hasRuntimeDiscounts) {
466
- _context3.next = 8;
526
+ _context4.next = 8;
467
527
  break;
468
528
  }
469
- return _context3.abrupt("return");
529
+ return _context4.abrupt("return");
470
530
  case 8:
471
- _context3.next = 10;
531
+ _context4.next = 10;
472
532
  return this.loadDiscountConfig({
473
533
  customerId: customerId,
474
534
  action: 'edit',
@@ -477,9 +537,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
477
537
  });
478
538
  case 10:
479
539
  case "end":
480
- return _context3.stop();
540
+ return _context4.stop();
481
541
  }
482
- }, _callee3, this);
542
+ }, _callee4, this);
483
543
  }));
484
544
  function ensureEditDiscountConfigForProductChange(_x4) {
485
545
  return _ensureEditDiscountConfigForProductChange.apply(this, arguments);
@@ -489,35 +549,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
489
549
  }, {
490
550
  key: "scanCode",
491
551
  value: function () {
492
- var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(code, customerId) {
552
+ var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code, customerId) {
493
553
  var _this$store$discount7, _tempOrder$holder, _this$store$summary, _tempOrder$holder2;
494
554
  var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref12, isAvailable, newDiscountList, unavailableReason, _this$store$discount8;
495
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
496
- while (1) switch (_context4.prev = _context4.next) {
555
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
556
+ while (1) switch (_context5.prev = _context5.next) {
497
557
  case 0:
498
- _context4.next = 2;
558
+ _context5.next = 2;
499
559
  return (_this$store$discount7 = this.store.discount) === null || _this$store$discount7 === void 0 ? void 0 : _this$store$discount7.batchSearch(code, {
500
560
  customerId: customerId
501
561
  });
502
562
  case 2:
503
- _context4.t0 = _context4.sent;
504
- if (_context4.t0) {
505
- _context4.next = 5;
563
+ _context5.t0 = _context5.sent;
564
+ if (_context5.t0) {
565
+ _context5.next = 5;
506
566
  break;
507
567
  }
508
- _context4.t0 = {
568
+ _context5.t0 = {
509
569
  discountList: [],
510
570
  unavailableReasonKey: null
511
571
  };
512
572
  case 5:
513
- resultDiscountWithReason = _context4.t0;
573
+ resultDiscountWithReason = _context5.t0;
514
574
  resultDiscountList = resultDiscountWithReason.discountList, unavailableReasonKey = resultDiscountWithReason.unavailableReasonKey;
515
575
  rulesModule = this.store.rules;
516
576
  if (rulesModule) {
517
- _context4.next = 10;
577
+ _context5.next = 10;
518
578
  break;
519
579
  }
520
- return _context4.abrupt("return", {
580
+ return _context5.abrupt("return", {
521
581
  type: 'clientCalc',
522
582
  isAvailable: false,
523
583
  discountList: this.getDiscountList(),
@@ -526,10 +586,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
526
586
  });
527
587
  case 10:
528
588
  if (resultDiscountList.length) {
529
- _context4.next = 12;
589
+ _context5.next = 12;
530
590
  break;
531
591
  }
532
- return _context4.abrupt("return", {
592
+ return _context5.abrupt("return", {
533
593
  type: 'server',
534
594
  isAvailable: false,
535
595
  discountList: this.getDiscountList(),
@@ -550,10 +610,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
550
610
  return m.id === n.id;
551
611
  });
552
612
  }))) {
553
- _context4.next = 16;
613
+ _context5.next = 16;
554
614
  break;
555
615
  }
556
- return _context4.abrupt("return", {
616
+ return _context5.abrupt("return", {
557
617
  type: 'clientCalc',
558
618
  isAvailable: true,
559
619
  discountList: this.getDiscountList(),
@@ -579,7 +639,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
579
639
  (_this$store$discount8 = this.store.discount) === null || _this$store$discount8 === void 0 || _this$store$discount8.setDiscountList(newDiscountList);
580
640
  this.applyDiscount();
581
641
  }
582
- return _context4.abrupt("return", {
642
+ return _context5.abrupt("return", {
583
643
  type: 'clientCalc',
584
644
  isAvailable: isAvailable || false,
585
645
  discountList: newDiscountList || this.getDiscountList(),
@@ -588,9 +648,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
588
648
  });
589
649
  case 21:
590
650
  case "end":
591
- return _context4.stop();
651
+ return _context5.stop();
592
652
  }
593
- }, _callee4, this);
653
+ }, _callee5, this);
594
654
  }));
595
655
  function scanCode(_x5, _x6) {
596
656
  return _scanCode.apply(this, arguments);
@@ -697,33 +757,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
697
757
  }, {
698
758
  key: "applyPromotion",
699
759
  value: (function () {
700
- var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
760
+ var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
701
761
  var _this2 = this;
702
762
  var tempOrder, result, removeSet, _iterator3, _step3, reduce, _iterator6, _step6, _loop2, _iterator4, _step4, _loop, payload;
703
- return _regeneratorRuntime().wrap(function _callee5$(_context7) {
704
- while (1) switch (_context7.prev = _context7.next) {
763
+ return _regeneratorRuntime().wrap(function _callee6$(_context8) {
764
+ while (1) switch (_context8.prev = _context8.next) {
705
765
  case 0:
706
766
  if (!this.isApplyingPromotion) {
707
- _context7.next = 2;
767
+ _context8.next = 2;
708
768
  break;
709
769
  }
710
- return _context7.abrupt("return");
770
+ return _context8.abrupt("return");
711
771
  case 2:
712
772
  if (this.promotionEvaluator) {
713
- _context7.next = 4;
773
+ _context8.next = 4;
714
774
  break;
715
775
  }
716
- return _context7.abrupt("return");
776
+ return _context8.abrupt("return");
717
777
  case 4:
718
778
  tempOrder = this.store.tempOrder;
719
779
  if (tempOrder) {
720
- _context7.next = 7;
780
+ _context8.next = 7;
721
781
  break;
722
782
  }
723
- return _context7.abrupt("return");
783
+ return _context8.abrupt("return");
724
784
  case 7:
725
785
  this.isApplyingPromotion = true;
726
- _context7.prev = 8;
786
+ _context8.prev = 8;
727
787
  result = processCartPromotion(tempOrder.products, this.promotionEvaluator); // step 1: toRemove —— 直接过滤
728
788
  if (result.giftActions.toRemove.length > 0) {
729
789
  removeSet = new Set(result.giftActions.toRemove.map(String));
@@ -735,20 +795,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
735
795
 
736
796
  // step 2: toReduce —— 调整数量
737
797
  _iterator3 = _createForOfIteratorHelper(result.giftActions.toReduce);
738
- _context7.prev = 12;
798
+ _context8.prev = 12;
739
799
  _iterator3.s();
740
800
  case 14:
741
801
  if ((_step3 = _iterator3.n()).done) {
742
- _context7.next = 34;
802
+ _context8.next = 34;
743
803
  break;
744
804
  }
745
805
  reduce = _step3.value;
746
806
  _iterator6 = _createForOfIteratorHelper(reduce.items);
747
- _context7.prev = 17;
807
+ _context8.prev = 17;
748
808
  _loop2 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop2() {
749
809
  var item, product;
750
- return _regeneratorRuntime().wrap(function _loop2$(_context6) {
751
- while (1) switch (_context6.prev = _context6.next) {
810
+ return _regeneratorRuntime().wrap(function _loop2$(_context7) {
811
+ while (1) switch (_context7.prev = _context7.next) {
752
812
  case 0:
753
813
  item = _step6.value;
754
814
  product = result.products.find(function (p) {
@@ -759,52 +819,52 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
759
819
  }
760
820
  case 3:
761
821
  case "end":
762
- return _context6.stop();
822
+ return _context7.stop();
763
823
  }
764
824
  }, _loop2);
765
825
  });
766
826
  _iterator6.s();
767
827
  case 20:
768
828
  if ((_step6 = _iterator6.n()).done) {
769
- _context7.next = 24;
829
+ _context8.next = 24;
770
830
  break;
771
831
  }
772
- return _context7.delegateYield(_loop2(), "t0", 22);
832
+ return _context8.delegateYield(_loop2(), "t0", 22);
773
833
  case 22:
774
- _context7.next = 20;
834
+ _context8.next = 20;
775
835
  break;
776
836
  case 24:
777
- _context7.next = 29;
837
+ _context8.next = 29;
778
838
  break;
779
839
  case 26:
780
- _context7.prev = 26;
781
- _context7.t1 = _context7["catch"](17);
782
- _iterator6.e(_context7.t1);
840
+ _context8.prev = 26;
841
+ _context8.t1 = _context8["catch"](17);
842
+ _iterator6.e(_context8.t1);
783
843
  case 29:
784
- _context7.prev = 29;
844
+ _context8.prev = 29;
785
845
  _iterator6.f();
786
- return _context7.finish(29);
846
+ return _context8.finish(29);
787
847
  case 32:
788
- _context7.next = 14;
848
+ _context8.next = 14;
789
849
  break;
790
850
  case 34:
791
- _context7.next = 39;
851
+ _context8.next = 39;
792
852
  break;
793
853
  case 36:
794
- _context7.prev = 36;
795
- _context7.t2 = _context7["catch"](12);
796
- _iterator3.e(_context7.t2);
854
+ _context8.prev = 36;
855
+ _context8.t2 = _context8["catch"](12);
856
+ _iterator3.e(_context8.t2);
797
857
  case 39:
798
- _context7.prev = 39;
858
+ _context8.prev = 39;
799
859
  _iterator3.f();
800
- return _context7.finish(39);
860
+ return _context8.finish(39);
801
861
  case 42:
802
862
  if (!(result.giftActions.toAdd.length > 0)) {
803
- _context7.next = 65;
863
+ _context8.next = 65;
804
864
  break;
805
865
  }
806
866
  if (this.giftSelectResolver) {
807
- _context7.next = 47;
867
+ _context8.next = 47;
808
868
  break;
809
869
  }
810
870
  if (result.giftActions.toAdd.some(function (g) {
@@ -815,19 +875,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
815
875
  } else {
816
876
  console.warn('[OrderModule] giftSelectResolver not set, skip applying single-option gifts', result.giftActions.toAdd);
817
877
  }
818
- _context7.next = 65;
878
+ _context8.next = 65;
819
879
  break;
820
880
  case 47:
821
881
  _iterator4 = _createForOfIteratorHelper(result.giftActions.toAdd);
822
- _context7.prev = 48;
882
+ _context8.prev = 48;
823
883
  _loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
824
884
  var addAction, _sameStrategy$metadat, sameStrategy, giftResult, giftProducts, giftBookings, _iterator5, _step5, _step5$value, index, gp, booking, linked;
825
- return _regeneratorRuntime().wrap(function _loop$(_context5) {
826
- while (1) switch (_context5.prev = _context5.next) {
885
+ return _regeneratorRuntime().wrap(function _loop$(_context6) {
886
+ while (1) switch (_context6.prev = _context6.next) {
827
887
  case 0:
828
888
  addAction = _step4.value;
829
889
  if (!(addAction.giftOptions.length === 1)) {
830
- _context5.next = 6;
890
+ _context6.next = 6;
831
891
  break;
832
892
  }
833
893
  sameStrategy = result.products.find(function (p) {
@@ -835,14 +895,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
835
895
  return ((_p$metadata = p.metadata) === null || _p$metadata === void 0 || (_p$metadata = _p$metadata._giftInfo) === null || _p$metadata === void 0 ? void 0 : _p$metadata.strategyId) === addAction.strategyId;
836
896
  });
837
897
  if (!(sameStrategy && !sameStrategy.booking_uid && !((_sameStrategy$metadat = sameStrategy.metadata) !== null && _sameStrategy$metadat !== void 0 && _sameStrategy$metadat.booking_uid))) {
838
- _context5.next = 6;
898
+ _context6.next = 6;
839
899
  break;
840
900
  }
841
901
  sameStrategy.num = (Number(sameStrategy.num) || 0) + (addAction.giftCount || 1);
842
- return _context5.abrupt("return", 1);
902
+ return _context6.abrupt("return", 1);
843
903
  case 6:
844
- _context5.prev = 6;
845
- _context5.next = 9;
904
+ _context6.prev = 6;
905
+ _context6.next = 9;
846
906
  return _this2.giftSelectResolver({
847
907
  strategyId: addAction.strategyId,
848
908
  strategyName: addAction.strategyName,
@@ -851,31 +911,31 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
851
911
  sourceProductIds: addAction.sourceProductIds
852
912
  });
853
913
  case 9:
854
- giftResult = _context5.sent;
914
+ giftResult = _context6.sent;
855
915
  giftProducts = Array.isArray(giftResult) ? giftResult : giftResult === null || giftResult === void 0 ? void 0 : giftResult.products;
856
916
  giftBookings = Array.isArray(giftResult) ? [] : (giftResult === null || giftResult === void 0 ? void 0 : giftResult.bookings) || [];
857
917
  if (!(Array.isArray(giftProducts) && giftProducts.length > 0)) {
858
- _context5.next = 37;
918
+ _context6.next = 37;
859
919
  break;
860
920
  }
861
921
  _iterator5 = _createForOfIteratorHelper(giftProducts.entries());
862
- _context5.prev = 14;
922
+ _context6.prev = 14;
863
923
  _iterator5.s();
864
924
  case 16:
865
925
  if ((_step5 = _iterator5.n()).done) {
866
- _context5.next = 29;
926
+ _context6.next = 29;
867
927
  break;
868
928
  }
869
929
  _step5$value = _slicedToArray(_step5.value, 2), index = _step5$value[0], gp = _step5$value[1];
870
930
  if (gp) {
871
- _context5.next = 20;
931
+ _context6.next = 20;
872
932
  break;
873
933
  }
874
- return _context5.abrupt("continue", 27);
934
+ return _context6.abrupt("continue", 27);
875
935
  case 20:
876
936
  booking = giftBookings[index];
877
937
  if (!booking) {
878
- _context5.next = 26;
938
+ _context6.next = 26;
879
939
  break;
880
940
  }
881
941
  linked = _this2.createLinkedProductAndBooking({
@@ -884,65 +944,65 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
884
944
  });
885
945
  result.products.push(linked.product);
886
946
  tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
887
- return _context5.abrupt("continue", 27);
947
+ return _context6.abrupt("continue", 27);
888
948
  case 26:
889
949
  // normalize 略过:调用方应保证返回完整 OrderProduct。
890
950
  result.products.push(gp);
891
951
  case 27:
892
- _context5.next = 16;
952
+ _context6.next = 16;
893
953
  break;
894
954
  case 29:
895
- _context5.next = 34;
955
+ _context6.next = 34;
896
956
  break;
897
957
  case 31:
898
- _context5.prev = 31;
899
- _context5.t0 = _context5["catch"](14);
900
- _iterator5.e(_context5.t0);
958
+ _context6.prev = 31;
959
+ _context6.t0 = _context6["catch"](14);
960
+ _iterator5.e(_context6.t0);
901
961
  case 34:
902
- _context5.prev = 34;
962
+ _context6.prev = 34;
903
963
  _iterator5.f();
904
- return _context5.finish(34);
964
+ return _context6.finish(34);
905
965
  case 37:
906
- _context5.next = 42;
966
+ _context6.next = 42;
907
967
  break;
908
968
  case 39:
909
- _context5.prev = 39;
910
- _context5.t1 = _context5["catch"](6);
969
+ _context6.prev = 39;
970
+ _context6.t1 = _context6["catch"](6);
911
971
  // 用户取消 / 选择失败 → 视为放弃本次新增
912
- console.warn('[OrderModule] giftSelectResolver rejected, skip add gift', addAction.strategyId, _context5.t1);
972
+ console.warn('[OrderModule] giftSelectResolver rejected, skip add gift', addAction.strategyId, _context6.t1);
913
973
  case 42:
914
974
  case "end":
915
- return _context5.stop();
975
+ return _context6.stop();
916
976
  }
917
977
  }, _loop, null, [[6, 39], [14, 31, 34, 37]]);
918
978
  });
919
979
  _iterator4.s();
920
980
  case 51:
921
981
  if ((_step4 = _iterator4.n()).done) {
922
- _context7.next = 57;
982
+ _context8.next = 57;
923
983
  break;
924
984
  }
925
- return _context7.delegateYield(_loop(), "t3", 53);
985
+ return _context8.delegateYield(_loop(), "t3", 53);
926
986
  case 53:
927
- if (!_context7.t3) {
928
- _context7.next = 55;
987
+ if (!_context8.t3) {
988
+ _context8.next = 55;
929
989
  break;
930
990
  }
931
- return _context7.abrupt("continue", 55);
991
+ return _context8.abrupt("continue", 55);
932
992
  case 55:
933
- _context7.next = 51;
993
+ _context8.next = 51;
934
994
  break;
935
995
  case 57:
936
- _context7.next = 62;
996
+ _context8.next = 62;
937
997
  break;
938
998
  case 59:
939
- _context7.prev = 59;
940
- _context7.t4 = _context7["catch"](48);
941
- _iterator4.e(_context7.t4);
999
+ _context8.prev = 59;
1000
+ _context8.t4 = _context8["catch"](48);
1001
+ _iterator4.e(_context8.t4);
942
1002
  case 62:
943
- _context7.prev = 62;
1003
+ _context8.prev = 62;
944
1004
  _iterator4.f();
945
- return _context7.finish(62);
1005
+ return _context8.finish(62);
946
1006
  case 65:
947
1007
  tempOrder.products = result.products;
948
1008
  this.lastUnfulfilledPromotions = result.unfulfilledPromotions;
@@ -961,21 +1021,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
961
1021
  products: tempOrder.products
962
1022
  };
963
1023
  this.effectsEmit('onPromotionApplied', payload);
964
- _context7.next = 75;
1024
+ _context8.next = 75;
965
1025
  break;
966
1026
  case 72:
967
- _context7.prev = 72;
968
- _context7.t5 = _context7["catch"](8);
969
- console.error('[OrderModule] applyPromotion failed', _context7.t5);
1027
+ _context8.prev = 72;
1028
+ _context8.t5 = _context8["catch"](8);
1029
+ console.error('[OrderModule] applyPromotion failed', _context8.t5);
970
1030
  case 75:
971
- _context7.prev = 75;
1031
+ _context8.prev = 75;
972
1032
  this.isApplyingPromotion = false;
973
- return _context7.finish(75);
1033
+ return _context8.finish(75);
974
1034
  case 78:
975
1035
  case "end":
976
- return _context7.stop();
1036
+ return _context8.stop();
977
1037
  }
978
- }, _callee5, this, [[8, 72, 75, 78], [12, 36, 39, 42], [17, 26, 29, 32], [48, 59, 62, 65]]);
1038
+ }, _callee6, this, [[8, 72, 75, 78], [12, 36, 39, 42], [17, 26, 29, 32], [48, 59, 62, 65]]);
979
1039
  }));
980
1040
  function applyPromotion() {
981
1041
  return _applyPromotion.apply(this, arguments);
@@ -1097,14 +1157,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1097
1157
  }, {
1098
1158
  key: "saveDraft",
1099
1159
  value: function () {
1100
- var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
1101
- return _regeneratorRuntime().wrap(function _callee6$(_context8) {
1102
- while (1) switch (_context8.prev = _context8.next) {
1160
+ var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
1161
+ return _regeneratorRuntime().wrap(function _callee7$(_context9) {
1162
+ while (1) switch (_context9.prev = _context9.next) {
1103
1163
  case 0:
1104
1164
  case "end":
1105
- return _context8.stop();
1165
+ return _context9.stop();
1106
1166
  }
1107
- }, _callee6);
1167
+ }, _callee7);
1108
1168
  }));
1109
1169
  function saveDraft() {
1110
1170
  return _saveDraft.apply(this, arguments);
@@ -1119,16 +1179,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1119
1179
  }, {
1120
1180
  key: "hydrateTempOrderFromLocalRecord",
1121
1181
  value: function () {
1122
- var _hydrateTempOrderFromLocalRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(record) {
1123
- return _regeneratorRuntime().wrap(function _callee7$(_context9) {
1124
- while (1) switch (_context9.prev = _context9.next) {
1182
+ var _hydrateTempOrderFromLocalRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(record) {
1183
+ return _regeneratorRuntime().wrap(function _callee8$(_context10) {
1184
+ while (1) switch (_context10.prev = _context10.next) {
1125
1185
  case 0:
1126
- return _context9.abrupt("return", this.hydrateTempOrderFromRecord(record));
1186
+ return _context10.abrupt("return", this.hydrateTempOrderFromRecord(record));
1127
1187
  case 1:
1128
1188
  case "end":
1129
- return _context9.stop();
1189
+ return _context10.stop();
1130
1190
  }
1131
- }, _callee7, this);
1191
+ }, _callee8, this);
1132
1192
  }));
1133
1193
  function hydrateTempOrderFromLocalRecord(_x7) {
1134
1194
  return _hydrateTempOrderFromLocalRecord.apply(this, arguments);
@@ -1163,6 +1223,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1163
1223
  value: function getDepositAmount(tempOrder, summary) {
1164
1224
  return new Decimal(summary.deposit_amount || tempOrder.deposit_amount || '0.00');
1165
1225
  }
1226
+ }, {
1227
+ key: "normalizeDepositAmount",
1228
+ value: function normalizeDepositAmount(amount) {
1229
+ return Decimal.max(new Decimal(Number(amount) || 0), 0).toDecimalPlaces(2).toFixed(2);
1230
+ }
1231
+ }, {
1232
+ key: "applyDepositAmountToSummary",
1233
+ value: function applyDepositAmountToSummary(tempOrder, summary, amount) {
1234
+ var depositAmount = this.normalizeDepositAmount(amount);
1235
+ var hasDepositAmount = new Decimal(depositAmount).gt(0);
1236
+ var existedDeposit = summary.deposit && _typeof(summary.deposit) === 'object' ? summary.deposit : undefined;
1237
+ var nextSummary = _objectSpread(_objectSpread({}, summary), {}, {
1238
+ deposit_amount: depositAmount,
1239
+ deposit: hasDepositAmount ? _objectSpread(_objectSpread({}, existedDeposit || {}), {}, {
1240
+ total: depositAmount,
1241
+ deposit_policy_ids: (existedDeposit === null || existedDeposit === void 0 ? void 0 : existedDeposit.deposit_policy_ids) || [],
1242
+ hasDeposit: true
1243
+ }) : undefined
1244
+ });
1245
+ tempOrder.deposit_amount = depositAmount;
1246
+ tempOrder.is_deposit = hasDepositAmount ? 1 : 0;
1247
+ return nextSummary;
1248
+ }
1166
1249
  }, {
1167
1250
  key: "isDepositOrder",
1168
1251
  value: function isDepositOrder(tempOrder, depositAmount) {
@@ -1181,6 +1264,31 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1181
1264
  if (depositAmount.lte(0)) return false;
1182
1265
  return params.paidAmount.gte(depositAmount);
1183
1266
  }
1267
+ }, {
1268
+ key: "calculateDepositPaidAmount",
1269
+ value: function calculateDepositPaidAmount(payments) {
1270
+ var _this4 = this;
1271
+ return (payments || []).reduce(function (sum, payment) {
1272
+ var paymentRecord = payment;
1273
+ if ((paymentRecord === null || paymentRecord === void 0 ? void 0 : paymentRecord.status) !== 'paid') return sum;
1274
+ var isDepositPayment = paymentRecord.type === 'deposit' || paymentRecord.order_payment_type === 'deposit';
1275
+ if (!isDepositPayment) return sum;
1276
+ if (paymentRecord.origin_amount !== undefined && paymentRecord.origin_amount !== null && paymentRecord.origin_amount !== '') {
1277
+ return sum.plus(_this4.calculatePaymentGapAmount(paymentRecord));
1278
+ }
1279
+ var rounding = new Decimal(paymentRecord.rounding_amount || 0);
1280
+ return sum.plus(new Decimal(paymentRecord.amount || 0).minus(rounding));
1281
+ }, new Decimal(0));
1282
+ }
1283
+ }, {
1284
+ key: "resolveNextOrderPaymentType",
1285
+ value: function resolveNextOrderPaymentType(tempOrder) {
1286
+ var depositAmount = new Decimal(tempOrder.deposit_amount || '0.00');
1287
+ if (!this.isDepositOrder(tempOrder, depositAmount)) return 'normal';
1288
+ if (depositAmount.lte(0)) return 'normal';
1289
+ var depositPaidAmount = this.calculateDepositPaidAmount(tempOrder.payments || []);
1290
+ return depositPaidAmount.lt(depositAmount) ? 'deposit' : 'normal';
1291
+ }
1184
1292
  }, {
1185
1293
  key: "normalizePaymentSource",
1186
1294
  value: function normalizePaymentSource(payment, options) {
@@ -1311,16 +1419,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1311
1419
  }, {
1312
1420
  key: "calculatePaidPaymentSummary",
1313
1421
  value: function calculatePaidPaymentSummary(payments) {
1314
- var _this4 = this;
1422
+ var _this5 = this;
1315
1423
  return (payments || []).reduce(function (summary, payment) {
1316
1424
  var paymentRecord = payment;
1317
1425
  if ((paymentRecord === null || paymentRecord === void 0 ? void 0 : paymentRecord.status) !== 'paid') return summary;
1318
1426
  return {
1319
1427
  customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
1320
1428
  orderPaidAmount: summary.orderPaidAmount.plus(paymentRecord.origin_amount || 0),
1321
- gapPaidAmount: summary.gapPaidAmount.plus(_this4.calculatePaymentGapAmount(paymentRecord)),
1322
- payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this4.calculatePaymentServiceFee(paymentRecord)),
1323
- roundingAmount: summary.roundingAmount.plus(_this4.calculatePaymentRoundingAmount(paymentRecord))
1429
+ gapPaidAmount: summary.gapPaidAmount.plus(_this5.calculatePaymentGapAmount(paymentRecord)),
1430
+ payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this5.calculatePaymentServiceFee(paymentRecord)),
1431
+ roundingAmount: summary.roundingAmount.plus(_this5.calculatePaymentRoundingAmount(paymentRecord))
1324
1432
  };
1325
1433
  }, {
1326
1434
  customerPaidAmount: new Decimal(0),
@@ -1505,15 +1613,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1505
1613
  }, {
1506
1614
  key: "normalizeFingerprintValue",
1507
1615
  value: function normalizeFingerprintValue(value) {
1508
- var _this5 = this;
1616
+ var _this6 = this;
1509
1617
  if (Array.isArray(value)) {
1510
1618
  return value.map(function (item) {
1511
- return _this5.normalizeFingerprintValue(item);
1619
+ return _this6.normalizeFingerprintValue(item);
1512
1620
  });
1513
1621
  }
1514
1622
  if (!value || _typeof(value) !== 'object') return value !== null && value !== void 0 ? value : '';
1515
1623
  return Object.keys(value).sort().reduce(function (result, key) {
1516
- result[key] = _this5.normalizeFingerprintValue(value[key]);
1624
+ result[key] = _this6.normalizeFingerprintValue(value[key]);
1517
1625
  return result;
1518
1626
  }, {});
1519
1627
  }
@@ -1528,7 +1636,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1528
1636
  _sku$barcode,
1529
1637
  _ref18,
1530
1638
  _sku$variant_id,
1531
- _this6 = this;
1639
+ _this7 = this;
1532
1640
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
1533
1641
  var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
1534
1642
  var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
@@ -1562,7 +1670,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1562
1670
  option_group_id: (_option$option_group_ = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_ !== void 0 ? _option$option_group_ : null,
1563
1671
  option_group_item_id: (_ref20 = (_option$option_group_2 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_2 !== void 0 ? _option$option_group_2 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref20 !== void 0 ? _ref20 : null,
1564
1672
  num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
1565
- add_price: _this6.normalizeFingerprintMoney((_option$add_price = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price !== void 0 ? _option$add_price : option === null || option === void 0 ? void 0 : option.price)
1673
+ add_price: _this7.normalizeFingerprintMoney((_option$add_price = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price !== void 0 ? _option$add_price : option === null || option === void 0 ? void 0 : option.price)
1566
1674
  };
1567
1675
  })
1568
1676
  }),
@@ -1572,8 +1680,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1572
1680
  bundle_product_id: (_ref21 = (_ref22 = (_bundle$bundle_produc = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref22 !== void 0 ? _ref22 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref21 !== void 0 ? _ref21 : null,
1573
1681
  bundle_variant_id: (_ref23 = (_bundle$bundle_varian = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle === null || bundle === void 0 ? void 0 : bundle.product_variant_id) !== null && _ref23 !== void 0 ? _ref23 : 0,
1574
1682
  num: getSafeProductNum((_bundle$num = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num !== void 0 ? _bundle$num : bundle === null || bundle === void 0 ? void 0 : bundle.quantity),
1575
- price: _this6.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
1576
- bundle_selling_price: _this6.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
1683
+ price: _this7.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
1684
+ bundle_selling_price: _this7.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
1577
1685
  price_type: (_bundle$price_type = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type !== void 0 ? _bundle$price_type : '',
1578
1686
  price_type_ext: (_bundle$price_type_ex = bundle === null || bundle === void 0 ? void 0 : bundle.price_type_ext) !== null && _bundle$price_type_ex !== void 0 ? _bundle$price_type_ex : ''
1579
1687
  };
@@ -1583,7 +1691,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1583
1691
  return {
1584
1692
  type: (_ref24 = (_discount$type2 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type2 !== void 0 ? _discount$type2 : discount === null || discount === void 0 ? void 0 : discount.tag) !== null && _ref24 !== void 0 ? _ref24 : '',
1585
1693
  discount_id: (_ref25 = (_ref26 = (_discount$discount_id = discount === null || discount === void 0 ? void 0 : discount.discount_id) !== null && _discount$discount_id !== void 0 ? _discount$discount_id : discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== null && _ref26 !== void 0 ? _ref26 : discount === null || discount === void 0 || (_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) !== null && _ref25 !== void 0 ? _ref25 : null,
1586
- amount: _this6.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
1694
+ amount: _this7.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
1587
1695
  };
1588
1696
  }))
1589
1697
  };
@@ -1591,9 +1699,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1591
1699
  }, {
1592
1700
  key: "buildOrderProductsFingerprint",
1593
1701
  value: function buildOrderProductsFingerprint(products) {
1594
- var _this7 = this;
1702
+ var _this8 = this;
1595
1703
  var items = (products || []).map(function (product) {
1596
- return _this7.buildProductFingerprintItem(product);
1704
+ return _this8.buildProductFingerprintItem(product);
1597
1705
  });
1598
1706
  items.sort(function (left, right) {
1599
1707
  return JSON.stringify(left).localeCompare(JSON.stringify(right));
@@ -1615,7 +1723,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1615
1723
  _sku$barcode2,
1616
1724
  _ref28,
1617
1725
  _sku$variant_id2,
1618
- _this8 = this;
1726
+ _this9 = this;
1619
1727
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
1620
1728
  var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
1621
1729
  var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
@@ -1646,7 +1754,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1646
1754
  option_group_id: (_option$option_group_3 = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_3 !== void 0 ? _option$option_group_3 : null,
1647
1755
  option_group_item_id: (_ref30 = (_option$option_group_4 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_4 !== void 0 ? _option$option_group_4 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref30 !== void 0 ? _ref30 : null,
1648
1756
  num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
1649
- add_price: _this8.normalizeFingerprintMoney((_option$add_price2 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price2 !== void 0 ? _option$add_price2 : option === null || option === void 0 ? void 0 : option.price)
1757
+ add_price: _this9.normalizeFingerprintMoney((_option$add_price2 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price2 !== void 0 ? _option$add_price2 : option === null || option === void 0 ? void 0 : option.price)
1650
1758
  };
1651
1759
  })
1652
1760
  }),
@@ -1660,14 +1768,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1660
1768
  num: getSafeProductNum((_bundle$num2 = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num2 !== void 0 ? _bundle$num2 : bundle === null || bundle === void 0 ? void 0 : bundle.quantity),
1661
1769
  price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
1662
1770
  price_type_ext: (_bundle$price_type_ex2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type_ext) !== null && _bundle$price_type_ex2 !== void 0 ? _bundle$price_type_ex2 : '',
1663
- option: _this8.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
1771
+ option: _this9.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
1664
1772
  var _ref36, _option$id3, _option$option_group_5, _ref37, _option$option_group_6, _option$num3, _option$add_price3;
1665
1773
  return {
1666
1774
  id: (_ref36 = (_option$id3 = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id3 !== void 0 ? _option$id3 : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref36 !== void 0 ? _ref36 : null,
1667
1775
  option_group_id: (_option$option_group_5 = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_5 !== void 0 ? _option$option_group_5 : null,
1668
1776
  option_group_item_id: (_ref37 = (_option$option_group_6 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_6 !== void 0 ? _option$option_group_6 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref37 !== void 0 ? _ref37 : null,
1669
1777
  num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
1670
- add_price: _this8.normalizeFingerprintMoney((_option$add_price3 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price3 !== void 0 ? _option$add_price3 : option === null || option === void 0 ? void 0 : option.price)
1778
+ add_price: _this9.normalizeFingerprintMoney((_option$add_price3 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price3 !== void 0 ? _option$add_price3 : option === null || option === void 0 ? void 0 : option.price)
1671
1779
  };
1672
1780
  }))
1673
1781
  };
@@ -1677,7 +1785,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1677
1785
  return {
1678
1786
  type: (_ref38 = (_discount$type4 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type4 !== void 0 ? _discount$type4 : discount === null || discount === void 0 ? void 0 : discount.tag) !== null && _ref38 !== void 0 ? _ref38 : '',
1679
1787
  discount_id: (_ref39 = (_ref40 = (_discount$discount_id2 = discount === null || discount === void 0 ? void 0 : discount.discount_id) !== null && _discount$discount_id2 !== void 0 ? _discount$discount_id2 : discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== null && _ref40 !== void 0 ? _ref40 : discount === null || discount === void 0 || (_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) !== null && _ref39 !== void 0 ? _ref39 : null,
1680
- amount: _this8.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
1788
+ amount: _this9.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
1681
1789
  };
1682
1790
  }))
1683
1791
  };
@@ -1685,9 +1793,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1685
1793
  }, {
1686
1794
  key: "buildOrderProductsStructuralFingerprint",
1687
1795
  value: function buildOrderProductsStructuralFingerprint(products) {
1688
- var _this9 = this;
1796
+ var _this10 = this;
1689
1797
  var items = (products || []).map(function (product) {
1690
- return _this9.buildProductStructuralFingerprintItem(product);
1798
+ return _this10.buildProductStructuralFingerprintItem(product);
1691
1799
  });
1692
1800
  items.sort(function (left, right) {
1693
1801
  return JSON.stringify(left).localeCompare(JSON.stringify(right));
@@ -1874,13 +1982,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1874
1982
  }, {
1875
1983
  key: "replaceTempOrder",
1876
1984
  value: function () {
1877
- var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(tempOrder, options) {
1985
+ var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(tempOrder, options) {
1878
1986
  var nextTempOrder;
1879
- return _regeneratorRuntime().wrap(function _callee8$(_context10) {
1880
- while (1) switch (_context10.prev = _context10.next) {
1987
+ return _regeneratorRuntime().wrap(function _callee9$(_context11) {
1988
+ while (1) switch (_context11.prev = _context11.next) {
1881
1989
  case 0:
1882
1990
  if (isTempOrder(tempOrder)) {
1883
- _context10.next = 2;
1991
+ _context11.next = 2;
1884
1992
  break;
1885
1993
  }
1886
1994
  throw new Error('无效的 tempOrder 数据');
@@ -1890,15 +1998,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1890
1998
  });
1891
1999
  this.store.tempOrder = nextTempOrder;
1892
2000
  if (!((options === null || options === void 0 ? void 0 : options.recalculateSummary) !== false)) {
1893
- _context10.next = 9;
2001
+ _context11.next = 9;
1894
2002
  break;
1895
2003
  }
1896
- _context10.next = 7;
2004
+ _context11.next = 7;
1897
2005
  return this.recalculateSummary({
1898
2006
  createIfMissing: false
1899
2007
  });
1900
2008
  case 7:
1901
- _context10.next = 10;
2009
+ _context11.next = 10;
1902
2010
  break;
1903
2011
  case 9:
1904
2012
  this.store.summary = createEmptySummary();
@@ -1907,18 +2015,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1907
2015
  this.persistTempOrder();
1908
2016
  }
1909
2017
  if (!(options !== null && options !== void 0 && options.saveDraft)) {
1910
- _context10.next = 14;
2018
+ _context11.next = 14;
1911
2019
  break;
1912
2020
  }
1913
- _context10.next = 14;
2021
+ _context11.next = 14;
1914
2022
  return this.saveDraft();
1915
2023
  case 14:
1916
- return _context10.abrupt("return", nextTempOrder);
2024
+ return _context11.abrupt("return", nextTempOrder);
1917
2025
  case 15:
1918
2026
  case "end":
1919
- return _context10.stop();
2027
+ return _context11.stop();
1920
2028
  }
1921
- }, _callee8, this);
2029
+ }, _callee9, this);
1922
2030
  }));
1923
2031
  function replaceTempOrder(_x8, _x9) {
1924
2032
  return _replaceTempOrder.apply(this, arguments);
@@ -2006,32 +2114,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2006
2114
  }, {
2007
2115
  key: "addNewOrder",
2008
2116
  value: function () {
2009
- var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
2117
+ var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
2010
2118
  var tempOrder;
2011
- return _regeneratorRuntime().wrap(function _callee9$(_context11) {
2012
- while (1) switch (_context11.prev = _context11.next) {
2119
+ return _regeneratorRuntime().wrap(function _callee10$(_context12) {
2120
+ while (1) switch (_context12.prev = _context12.next) {
2013
2121
  case 0:
2014
2122
  tempOrder = this.ensureTempOrder();
2015
2123
  this.ensureExternalSaleNumber(tempOrder);
2016
- _context11.next = 4;
2124
+ _context12.next = 4;
2017
2125
  return this.recalculateSummary({
2018
2126
  createIfMissing: true
2019
2127
  });
2020
2128
  case 4:
2021
2129
  this.persistTempOrder();
2022
2130
  if (!this.draftPersistEnabled) {
2023
- _context11.next = 8;
2131
+ _context12.next = 8;
2024
2132
  break;
2025
2133
  }
2026
- _context11.next = 8;
2134
+ _context12.next = 8;
2027
2135
  return this.saveDraft();
2028
2136
  case 8:
2029
- return _context11.abrupt("return", tempOrder);
2137
+ return _context12.abrupt("return", tempOrder);
2030
2138
  case 9:
2031
2139
  case "end":
2032
- return _context11.stop();
2140
+ return _context12.stop();
2033
2141
  }
2034
- }, _callee9, this);
2142
+ }, _callee10, this);
2035
2143
  }));
2036
2144
  function addNewOrder() {
2037
2145
  return _addNewOrder.apply(this, arguments);
@@ -2064,9 +2172,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2064
2172
  }, {
2065
2173
  key: "sanitizeTempOrderProducts",
2066
2174
  value: function sanitizeTempOrderProducts(tempOrder) {
2067
- var _this10 = this;
2175
+ var _this11 = this;
2068
2176
  tempOrder.products = (tempOrder.products || []).map(function (product) {
2069
- return _this10.sanitizeOrderProductForTempOrder(product);
2177
+ return _this11.sanitizeOrderProductForTempOrder(product);
2070
2178
  });
2071
2179
  }
2072
2180
  }, {
@@ -2279,9 +2387,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2279
2387
  }, {
2280
2388
  key: "findBookingIndexByUniqueIdentificationNumber",
2281
2389
  value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
2282
- var _this11 = this;
2390
+ var _this12 = this;
2283
2391
  return (tempOrder.bookings || []).findIndex(function (booking) {
2284
- return _this11.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
2392
+ return _this12.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
2285
2393
  });
2286
2394
  }
2287
2395
  }, {
@@ -2289,12 +2397,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2289
2397
  value: function removeLinkedBookingsForProduct(tempOrder, product) {
2290
2398
  var _product$metadata5,
2291
2399
  _product$metadata6,
2292
- _this12 = this;
2400
+ _this13 = this;
2293
2401
  var productUid = (product === null || product === void 0 || (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
2294
2402
  var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.booking_uid);
2295
2403
  if (!productUid && !bookingUid) return;
2296
2404
  tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
2297
- var currentBookingUid = _this12.getBookingUniqueIdentificationNumber(booking);
2405
+ var currentBookingUid = _this13.getBookingUniqueIdentificationNumber(booking);
2298
2406
  if (bookingUid && currentBookingUid === String(bookingUid)) return false;
2299
2407
  if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
2300
2408
  return true;
@@ -2331,26 +2439,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2331
2439
  }, {
2332
2440
  key: "recalculateSummary",
2333
2441
  value: function () {
2334
- var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(options) {
2442
+ var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(options) {
2335
2443
  var _ref45, _salesSummaryResult$e;
2336
2444
  var tempOrder, snapshotSummary, shouldFullRecalculateFromSnapshot, summaryProducts, salesSummary, existedSummary, totalRefundAmount, paidPaymentSummary, emptyBaseSummary, emptySummaryBase, emptySummaryWithDeposit, emptySummary, salesSummaryResult, roundingAmount, payServiceChargeAmount, hasSalesSummaryAmount, expectAmount, amountPaymentPatch, normalizedExpectAmountPatch, summaryForGap, summary;
2337
- return _regeneratorRuntime().wrap(function _callee10$(_context12) {
2338
- while (1) switch (_context12.prev = _context12.next) {
2445
+ return _regeneratorRuntime().wrap(function _callee11$(_context13) {
2446
+ while (1) switch (_context13.prev = _context13.next) {
2339
2447
  case 0:
2340
2448
  tempOrder = options !== null && options !== void 0 && options.createIfMissing ? this.ensureTempOrder() : this.store.tempOrder;
2341
2449
  if (tempOrder) {
2342
- _context12.next = 3;
2450
+ _context13.next = 3;
2343
2451
  break;
2344
2452
  }
2345
- return _context12.abrupt("return", null);
2453
+ return _context13.abrupt("return", null);
2346
2454
  case 3:
2347
2455
  this.sanitizeTempOrderProducts(tempOrder);
2348
2456
  snapshotSummary = this.restoreOriginalSnapshotIfProductsUnchanged(tempOrder);
2349
2457
  if (!snapshotSummary) {
2350
- _context12.next = 7;
2458
+ _context13.next = 7;
2351
2459
  break;
2352
2460
  }
2353
- return _context12.abrupt("return", snapshotSummary);
2461
+ return _context13.abrupt("return", snapshotSummary);
2354
2462
  case 7:
2355
2463
  shouldFullRecalculateFromSnapshot = Boolean(this.getOriginalSalesSnapshot(tempOrder));
2356
2464
  summaryProducts = shouldFullRecalculateFromSnapshot ? cloneDeep(tempOrder.products || []) : tempOrder.products;
@@ -2362,7 +2470,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2362
2470
  totalRefundAmount = existedSummary.total_refund_amount || '0.00';
2363
2471
  paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
2364
2472
  if (salesSummary) {
2365
- _context12.next = 23;
2473
+ _context13.next = 23;
2366
2474
  break;
2367
2475
  }
2368
2476
  emptyBaseSummary = _objectSpread(_objectSpread(_objectSpread({}, createEmptySummary()), existedSummary), {}, {
@@ -2388,16 +2496,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2388
2496
  previousSummary: existedSummary,
2389
2497
  summary: emptySummary
2390
2498
  });
2391
- return _context12.abrupt("return", this.store.summary);
2499
+ return _context13.abrupt("return", this.store.summary);
2392
2500
  case 23:
2393
- _context12.next = 25;
2501
+ _context13.next = 25;
2394
2502
  return salesSummary.getSummary({
2395
2503
  products: summaryProducts,
2396
2504
  isPriceIncludeTax: tempOrder.is_price_include_tax,
2397
2505
  shopDiscount: tempOrder.shop_discount
2398
2506
  });
2399
2507
  case 25:
2400
- salesSummaryResult = _context12.sent;
2508
+ salesSummaryResult = _context13.sent;
2401
2509
  if (shouldFullRecalculateFromSnapshot) {
2402
2510
  tempOrder.products = summaryProducts;
2403
2511
  }
@@ -2442,12 +2550,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2442
2550
  previousSummary: existedSummary,
2443
2551
  summary: summary
2444
2552
  });
2445
- return _context12.abrupt("return", this.store.summary);
2553
+ return _context13.abrupt("return", this.store.summary);
2446
2554
  case 43:
2447
2555
  case "end":
2448
- return _context12.stop();
2556
+ return _context13.stop();
2449
2557
  }
2450
- }, _callee10, this);
2558
+ }, _callee11, this);
2451
2559
  }));
2452
2560
  function recalculateSummary(_x10) {
2453
2561
  return _recalculateSummary.apply(this, arguments);
@@ -2457,30 +2565,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2457
2565
  }, {
2458
2566
  key: "getOrderSummary",
2459
2567
  value: function () {
2460
- var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
2568
+ var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
2461
2569
  var summary;
2462
- return _regeneratorRuntime().wrap(function _callee11$(_context13) {
2463
- while (1) switch (_context13.prev = _context13.next) {
2570
+ return _regeneratorRuntime().wrap(function _callee12$(_context14) {
2571
+ while (1) switch (_context14.prev = _context14.next) {
2464
2572
  case 0:
2465
- _context13.next = 2;
2573
+ _context14.next = 2;
2466
2574
  return this.recalculateSummary({
2467
2575
  createIfMissing: true
2468
2576
  });
2469
2577
  case 2:
2470
- summary = _context13.sent;
2578
+ summary = _context14.sent;
2471
2579
  if (summary) {
2472
- _context13.next = 5;
2580
+ _context14.next = 5;
2473
2581
  break;
2474
2582
  }
2475
- return _context13.abrupt("return", createEmptySummary());
2583
+ return _context14.abrupt("return", createEmptySummary());
2476
2584
  case 5:
2477
2585
  this.persistTempOrder();
2478
- return _context13.abrupt("return", summary);
2586
+ return _context14.abrupt("return", summary);
2479
2587
  case 7:
2480
2588
  case "end":
2481
- return _context13.stop();
2589
+ return _context14.stop();
2482
2590
  }
2483
- }, _callee11, this);
2591
+ }, _callee12, this);
2484
2592
  }));
2485
2593
  function getOrderSummary() {
2486
2594
  return _getOrderSummary.apply(this, arguments);
@@ -2504,21 +2612,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2504
2612
  }, {
2505
2613
  key: "syncTempOrderNoteToRemote",
2506
2614
  value: function () {
2507
- var _syncTempOrderNoteToRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(orderId, note) {
2508
- return _regeneratorRuntime().wrap(function _callee12$(_context14) {
2509
- while (1) switch (_context14.prev = _context14.next) {
2615
+ var _syncTempOrderNoteToRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderId, note) {
2616
+ return _regeneratorRuntime().wrap(function _callee13$(_context15) {
2617
+ while (1) switch (_context15.prev = _context15.next) {
2510
2618
  case 0:
2511
- _context14.next = 2;
2619
+ _context15.next = 2;
2512
2620
  return this.request.put("/order/order/".concat(orderId, "/note"), {
2513
2621
  note: note
2514
2622
  });
2515
2623
  case 2:
2516
- return _context14.abrupt("return", note);
2624
+ return _context15.abrupt("return", note);
2517
2625
  case 3:
2518
2626
  case "end":
2519
- return _context14.stop();
2627
+ return _context15.stop();
2520
2628
  }
2521
- }, _callee12, this);
2629
+ }, _callee13, this);
2522
2630
  }));
2523
2631
  function syncTempOrderNoteToRemote(_x11, _x12) {
2524
2632
  return _syncTempOrderNoteToRemote.apply(this, arguments);
@@ -2540,6 +2648,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2540
2648
  this.persistTempOrder();
2541
2649
  return tempOrder.shop_discount;
2542
2650
  }
2651
+ }, {
2652
+ key: "updateTempOrderDepositAmount",
2653
+ value: function updateTempOrderDepositAmount(amount) {
2654
+ var tempOrder = this.ensureTempOrder();
2655
+ var depositAmount = this.normalizeDepositAmount(amount);
2656
+ var previousSummary = this.store.summary || createEmptySummary();
2657
+ var summaryWithDeposit = this.applyDepositAmountToSummary(tempOrder, _objectSpread(_objectSpread({}, createEmptySummary()), previousSummary), depositAmount);
2658
+ var paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
2659
+ var summary = _objectSpread(_objectSpread({}, summaryWithDeposit), {}, {
2660
+ amount_gap: this.calculateSummaryAmountGap({
2661
+ tempOrder: tempOrder,
2662
+ summary: summaryWithDeposit,
2663
+ orderPaidAmount: paidPaymentSummary.gapPaidAmount
2664
+ })
2665
+ });
2666
+ this.store.summary = summary;
2667
+ this.updateTempOrderPaymentStatus(tempOrder, {
2668
+ previousSummary: previousSummary,
2669
+ summary: summary
2670
+ });
2671
+ this.persistTempOrder();
2672
+ return summary;
2673
+ }
2543
2674
  }, {
2544
2675
  key: "updateTempOrderBuzzer",
2545
2676
  value: function updateTempOrderBuzzer(buzzer) {
@@ -2584,7 +2715,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2584
2715
  }, {
2585
2716
  key: "clearCustomerBoundDiscounts",
2586
2717
  value: function clearCustomerBoundDiscounts(tempOrder) {
2587
- var _this13 = this,
2718
+ var _this14 = this,
2588
2719
  _discountModule$getDi,
2589
2720
  _discountModule$getOr,
2590
2721
  _discountModule$setDi,
@@ -2592,7 +2723,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2592
2723
  var filterDiscountList = function filterDiscountList(discountList) {
2593
2724
  if (!Array.isArray(discountList)) return [];
2594
2725
  return discountList.filter(function (discount) {
2595
- return !_this13.isCustomerBoundDiscount(discount);
2726
+ return !_this14.isCustomerBoundDiscount(discount);
2596
2727
  });
2597
2728
  };
2598
2729
  tempOrder.products = (tempOrder.products || []).map(function (product) {
@@ -2615,11 +2746,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2615
2746
  var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
2616
2747
  var nextDiscounts = currentDiscounts.filter(function (discount) {
2617
2748
  if (discount !== null && discount !== void 0 && discount.isEditMode) return true;
2618
- return !_this13.isCustomerBoundDiscount(discount);
2749
+ return !_this14.isCustomerBoundDiscount(discount);
2619
2750
  });
2620
2751
  var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
2621
2752
  if (discount !== null && discount !== void 0 && discount.isEditMode) return true;
2622
- return !_this13.isCustomerBoundDiscount(discount);
2753
+ return !_this14.isCustomerBoundDiscount(discount);
2623
2754
  });
2624
2755
  void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
2625
2756
  void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
@@ -2786,12 +2917,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2786
2917
  }, {
2787
2918
  key: "addOrderPayment",
2788
2919
  value: function addOrderPayment(payment) {
2789
- var _this14 = this;
2920
+ var _this15 = this;
2790
2921
  this.logInfo('addOrderPayment', {
2791
2922
  payment: payment
2792
2923
  });
2793
2924
  var tempOrder = this.ensureTempOrder();
2794
- var mapped = mapPaymentItemsToOrderPayments([this.normalizePaymentSource(payment, {
2925
+ var orderPaymentType = this.resolveNextOrderPaymentType(tempOrder);
2926
+ var mapped = mapPaymentItemsToOrderPayments([this.normalizePaymentSource(_objectSpread(_objectSpread({}, payment), {}, {
2927
+ type: orderPaymentType,
2928
+ order_payment_type: orderPaymentType
2929
+ }), {
2795
2930
  defaultPaid: true
2796
2931
  })]);
2797
2932
  tempOrder.payments = [].concat(_toConsumableArray(tempOrder.payments || []), _toConsumableArray(mapped));
@@ -2799,7 +2934,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2799
2934
  void this.recalculateSummary({
2800
2935
  createIfMissing: true
2801
2936
  }).catch(function (error) {
2802
- _this14.logError('recalculate summary after addOrderPayment failed', {
2937
+ _this15.logError('recalculate summary after addOrderPayment failed', {
2803
2938
  error: error instanceof Error ? error.message : String(error)
2804
2939
  });
2805
2940
  });
@@ -2864,7 +2999,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2864
2999
  }, {
2865
3000
  key: "updateVoucherOrderPayments",
2866
3001
  value: function updateVoucherOrderPayments(payments) {
2867
- var _this15 = this;
3002
+ var _this16 = this;
2868
3003
  var tempOrder = this.ensureTempOrder();
2869
3004
  var isVoucherPayment = function isVoucherPayment(payment) {
2870
3005
  return payment.voucher_id !== undefined && Number(payment.voucher_id) !== 0;
@@ -2885,7 +3020,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2885
3020
  // return paymentRecord
2886
3021
  // };
2887
3022
  var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
2888
- return _this15.normalizePaymentSource(payment, {
3023
+ return _this16.normalizePaymentSource(payment, {
2889
3024
  defaultPaid: true
2890
3025
  });
2891
3026
  })).filter(function (payment) {
@@ -2914,7 +3049,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2914
3049
  void this.recalculateSummary({
2915
3050
  createIfMissing: true
2916
3051
  }).catch(function (error) {
2917
- _this15.logError('recalculate summary after updateVoucherOrderPayments failed', {
3052
+ _this16.logError('recalculate summary after updateVoucherOrderPayments failed', {
2918
3053
  error: error instanceof Error ? error.message : String(error)
2919
3054
  });
2920
3055
  });
@@ -2923,43 +3058,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2923
3058
  }, {
2924
3059
  key: "shouldMergeProductToOrder",
2925
3060
  value: function () {
2926
- var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(params) {
3061
+ var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(params) {
2927
3062
  var _this$orderHooks;
2928
3063
  var onBeforeMergeProductToOrder, result;
2929
- return _regeneratorRuntime().wrap(function _callee13$(_context15) {
2930
- while (1) switch (_context15.prev = _context15.next) {
3064
+ return _regeneratorRuntime().wrap(function _callee14$(_context16) {
3065
+ while (1) switch (_context16.prev = _context16.next) {
2931
3066
  case 0:
2932
3067
  onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
2933
3068
  if (onBeforeMergeProductToOrder) {
2934
- _context15.next = 3;
3069
+ _context16.next = 3;
2935
3070
  break;
2936
3071
  }
2937
- return _context15.abrupt("return", true);
3072
+ return _context16.abrupt("return", true);
2938
3073
  case 3:
2939
- _context15.next = 5;
3074
+ _context16.next = 5;
2940
3075
  return onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
2941
3076
  defaultShouldMerge: true
2942
3077
  }));
2943
3078
  case 5:
2944
- result = _context15.sent;
3079
+ result = _context16.sent;
2945
3080
  if (!(typeof result === 'boolean')) {
2946
- _context15.next = 8;
3081
+ _context16.next = 8;
2947
3082
  break;
2948
3083
  }
2949
- return _context15.abrupt("return", result);
3084
+ return _context16.abrupt("return", result);
2950
3085
  case 8:
2951
3086
  if (!(result && _typeof(result) === 'object' && typeof result.shouldMerge === 'boolean')) {
2952
- _context15.next = 10;
3087
+ _context16.next = 10;
2953
3088
  break;
2954
3089
  }
2955
- return _context15.abrupt("return", result.shouldMerge);
3090
+ return _context16.abrupt("return", result.shouldMerge);
2956
3091
  case 10:
2957
- return _context15.abrupt("return", true);
3092
+ return _context16.abrupt("return", true);
2958
3093
  case 11:
2959
3094
  case "end":
2960
- return _context15.stop();
3095
+ return _context16.stop();
2961
3096
  }
2962
- }, _callee13, this);
3097
+ }, _callee14, this);
2963
3098
  }));
2964
3099
  function shouldMergeProductToOrder(_x13) {
2965
3100
  return _shouldMergeProductToOrder.apply(this, arguments);
@@ -2997,30 +3132,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2997
3132
  }, {
2998
3133
  key: "finalizeProductOrderMutation",
2999
3134
  value: function () {
3000
- var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(tempOrder, options) {
3001
- return _regeneratorRuntime().wrap(function _callee14$(_context16) {
3002
- while (1) switch (_context16.prev = _context16.next) {
3135
+ var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(tempOrder, options) {
3136
+ return _regeneratorRuntime().wrap(function _callee15$(_context17) {
3137
+ while (1) switch (_context17.prev = _context17.next) {
3003
3138
  case 0:
3004
3139
  this.syncTempOrderHolderFromBookings(tempOrder);
3005
3140
  if (options !== null && options !== void 0 && options.skipEditDiscountConfigRefresh) {
3006
- _context16.next = 4;
3141
+ _context17.next = 4;
3007
3142
  break;
3008
3143
  }
3009
- _context16.next = 4;
3144
+ _context17.next = 4;
3010
3145
  return this.ensureEditDiscountConfigForProductChange(tempOrder);
3011
3146
  case 4:
3012
3147
  if (options !== null && options !== void 0 && options.skipDiscountRecalculation) {
3013
- _context16.next = 7;
3148
+ _context17.next = 7;
3014
3149
  break;
3015
3150
  }
3016
- _context16.next = 7;
3151
+ _context17.next = 7;
3017
3152
  return this.applyPromotion();
3018
3153
  case 7:
3019
3154
  if (!(options !== null && options !== void 0 && options.skipDiscountRecalculation)) {
3020
3155
  this.applyDiscount();
3021
3156
  }
3022
3157
  this.sanitizeTempOrderProducts(tempOrder);
3023
- _context16.next = 11;
3158
+ _context17.next = 11;
3024
3159
  return this.recalculateSummary({
3025
3160
  createIfMissing: true
3026
3161
  });
@@ -3028,9 +3163,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3028
3163
  this.persistTempOrder();
3029
3164
  case 12:
3030
3165
  case "end":
3031
- return _context16.stop();
3166
+ return _context17.stop();
3032
3167
  }
3033
- }, _callee14, this);
3168
+ }, _callee15, this);
3034
3169
  }));
3035
3170
  function finalizeProductOrderMutation(_x14, _x15) {
3036
3171
  return _finalizeProductOrderMutation.apply(this, arguments);
@@ -3047,13 +3182,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3047
3182
  }, {
3048
3183
  key: "appendProductLineToTempOrder",
3049
3184
  value: (function () {
3050
- var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(tempOrder, product, booking) {
3185
+ var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(tempOrder, product, booking) {
3051
3186
  var _booking_uid,
3052
3187
  _metadata,
3053
- _this16 = this;
3188
+ _this17 = this;
3054
3189
  var linked, productToAdd, incomingFingerprint, normalizedIncoming, incomingBookingUid, hasIncomingGoodPass, hasIncomingProductNote, hasIncomingBookingUid, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList;
3055
- return _regeneratorRuntime().wrap(function _callee15$(_context17) {
3056
- while (1) switch (_context17.prev = _context17.next) {
3190
+ return _regeneratorRuntime().wrap(function _callee16$(_context18) {
3191
+ while (1) switch (_context18.prev = _context18.next) {
3057
3192
  case 0:
3058
3193
  linked = booking ? this.createLinkedProductAndBooking({
3059
3194
  product: product,
@@ -3075,8 +3210,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3075
3210
  hasIncomingBookingUid = this.hasLinkedBookingUid(productToAdd) || this.hasLinkedBookingUid(normalizedIncoming);
3076
3211
  shouldForceNewLine = !!booking || hasIncomingProductNote || hasIncomingBookingUid;
3077
3212
  matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
3078
- if (_this16.hasGoodPassDiscount(item)) return false;
3079
- if (_this16.hasOrderProductLineNote(item)) return false;
3213
+ if (_this17.hasGoodPassDiscount(item)) return false;
3214
+ if (_this17.hasOrderProductLineNote(item)) return false;
3080
3215
  if (item.order_detail_id !== undefined && item.order_detail_id !== null) return false;
3081
3216
  if (item.product_id !== productToAdd.product_id) return false;
3082
3217
  if (item.product_variant_id !== productToAdd.product_variant_id) return false;
@@ -3086,10 +3221,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3086
3221
  matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
3087
3222
  existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
3088
3223
  if (!matchedProduct) {
3089
- _context17.next = 20;
3224
+ _context18.next = 20;
3090
3225
  break;
3091
3226
  }
3092
- _context17.next = 17;
3227
+ _context18.next = 17;
3093
3228
  return this.shouldMergeProductToOrder({
3094
3229
  incomingProduct: productToAdd,
3095
3230
  normalizedIncoming: normalizedIncoming,
@@ -3101,13 +3236,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3101
3236
  booking: booking
3102
3237
  });
3103
3238
  case 17:
3104
- _context17.t0 = _context17.sent;
3105
- _context17.next = 21;
3239
+ _context18.t0 = _context18.sent;
3240
+ _context18.next = 21;
3106
3241
  break;
3107
3242
  case 20:
3108
- _context17.t0 = false;
3243
+ _context18.t0 = false;
3109
3244
  case 21:
3110
- shouldMerge = _context17.t0;
3245
+ shouldMerge = _context18.t0;
3111
3246
  if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
3112
3247
  this.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
3113
3248
  if (linked) {
@@ -3161,9 +3296,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3161
3296
  }
3162
3297
  case 24:
3163
3298
  case "end":
3164
- return _context17.stop();
3299
+ return _context18.stop();
3165
3300
  }
3166
- }, _callee15, this);
3301
+ }, _callee16, this);
3167
3302
  }));
3168
3303
  function appendProductLineToTempOrder(_x16, _x17, _x18) {
3169
3304
  return _appendProductLineToTempOrder.apply(this, arguments);
@@ -3181,55 +3316,55 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3181
3316
  }, {
3182
3317
  key: "addProductToOrder",
3183
3318
  value: (function () {
3184
- var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(product, booking) {
3319
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(product, booking) {
3185
3320
  var tempOrder, _ref59, _productRecord$num, productRecord, splitCount, i, singleLine;
3186
- return _regeneratorRuntime().wrap(function _callee16$(_context18) {
3187
- while (1) switch (_context18.prev = _context18.next) {
3321
+ return _regeneratorRuntime().wrap(function _callee17$(_context19) {
3322
+ while (1) switch (_context19.prev = _context19.next) {
3188
3323
  case 0:
3189
3324
  tempOrder = this.ensureTempOrder();
3190
3325
  if (!booking) {
3191
- _context18.next = 18;
3326
+ _context19.next = 18;
3192
3327
  break;
3193
3328
  }
3194
3329
  productRecord = product;
3195
3330
  splitCount = getSafeProductNum((_ref59 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref59 !== void 0 ? _ref59 : 1);
3196
3331
  if (!(splitCount > 1)) {
3197
- _context18.next = 18;
3332
+ _context19.next = 18;
3198
3333
  break;
3199
3334
  }
3200
3335
  i = 0;
3201
3336
  case 6:
3202
3337
  if (!(i < splitCount)) {
3203
- _context18.next = 15;
3338
+ _context19.next = 15;
3204
3339
  break;
3205
3340
  }
3206
3341
  singleLine = cloneDeep(productRecord);
3207
3342
  singleLine.num = 1;
3208
3343
  delete singleLine.product_quantity;
3209
- _context18.next = 12;
3344
+ _context19.next = 12;
3210
3345
  return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
3211
3346
  case 12:
3212
3347
  i += 1;
3213
- _context18.next = 6;
3348
+ _context19.next = 6;
3214
3349
  break;
3215
3350
  case 15:
3216
- _context18.next = 17;
3351
+ _context19.next = 17;
3217
3352
  return this.finalizeProductOrderMutation(tempOrder);
3218
3353
  case 17:
3219
- return _context18.abrupt("return", tempOrder.products);
3354
+ return _context19.abrupt("return", tempOrder.products);
3220
3355
  case 18:
3221
- _context18.next = 20;
3356
+ _context19.next = 20;
3222
3357
  return this.appendProductLineToTempOrder(tempOrder, product, booking);
3223
3358
  case 20:
3224
- _context18.next = 22;
3359
+ _context19.next = 22;
3225
3360
  return this.finalizeProductOrderMutation(tempOrder);
3226
3361
  case 22:
3227
- return _context18.abrupt("return", tempOrder.products);
3362
+ return _context19.abrupt("return", tempOrder.products);
3228
3363
  case 23:
3229
3364
  case "end":
3230
- return _context18.stop();
3365
+ return _context19.stop();
3231
3366
  }
3232
- }, _callee16, this);
3367
+ }, _callee17, this);
3233
3368
  }));
3234
3369
  function addProductToOrder(_x19, _x20) {
3235
3370
  return _addProductToOrder.apply(this, arguments);
@@ -3249,88 +3384,88 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3249
3384
  }, {
3250
3385
  key: "addProductsToOrder",
3251
3386
  value: (function () {
3252
- var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(items, options) {
3387
+ var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(items, options) {
3253
3388
  var tempOrder, _iterator20, _step20, item, product, booking, _ref60, _productRecord$num2, productRecord, splitCount, i, singleLine;
3254
- return _regeneratorRuntime().wrap(function _callee17$(_context19) {
3255
- while (1) switch (_context19.prev = _context19.next) {
3389
+ return _regeneratorRuntime().wrap(function _callee18$(_context20) {
3390
+ while (1) switch (_context20.prev = _context20.next) {
3256
3391
  case 0:
3257
3392
  tempOrder = this.ensureTempOrder();
3258
3393
  if (!(!Array.isArray(items) || items.length === 0)) {
3259
- _context19.next = 3;
3394
+ _context20.next = 3;
3260
3395
  break;
3261
3396
  }
3262
- return _context19.abrupt("return", tempOrder.products);
3397
+ return _context20.abrupt("return", tempOrder.products);
3263
3398
  case 3:
3264
3399
  _iterator20 = _createForOfIteratorHelper(items || []);
3265
- _context19.prev = 4;
3400
+ _context20.prev = 4;
3266
3401
  _iterator20.s();
3267
3402
  case 6:
3268
3403
  if ((_step20 = _iterator20.n()).done) {
3269
- _context19.next = 30;
3404
+ _context20.next = 30;
3270
3405
  break;
3271
3406
  }
3272
3407
  item = _step20.value;
3273
3408
  product = item.product, booking = item.booking;
3274
3409
  if (product) {
3275
- _context19.next = 11;
3410
+ _context20.next = 11;
3276
3411
  break;
3277
3412
  }
3278
- return _context19.abrupt("continue", 28);
3413
+ return _context20.abrupt("continue", 28);
3279
3414
  case 11:
3280
3415
  if (!booking) {
3281
- _context19.next = 26;
3416
+ _context20.next = 26;
3282
3417
  break;
3283
3418
  }
3284
3419
  productRecord = product;
3285
3420
  splitCount = getSafeProductNum((_ref60 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref60 !== void 0 ? _ref60 : 1);
3286
3421
  if (!(splitCount > 1)) {
3287
- _context19.next = 26;
3422
+ _context20.next = 26;
3288
3423
  break;
3289
3424
  }
3290
3425
  i = 0;
3291
3426
  case 16:
3292
3427
  if (!(i < splitCount)) {
3293
- _context19.next = 25;
3428
+ _context20.next = 25;
3294
3429
  break;
3295
3430
  }
3296
3431
  singleLine = cloneDeep(productRecord);
3297
3432
  singleLine.num = 1;
3298
3433
  delete singleLine.product_quantity;
3299
- _context19.next = 22;
3434
+ _context20.next = 22;
3300
3435
  return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
3301
3436
  case 22:
3302
3437
  i += 1;
3303
- _context19.next = 16;
3438
+ _context20.next = 16;
3304
3439
  break;
3305
3440
  case 25:
3306
- return _context19.abrupt("continue", 28);
3441
+ return _context20.abrupt("continue", 28);
3307
3442
  case 26:
3308
- _context19.next = 28;
3443
+ _context20.next = 28;
3309
3444
  return this.appendProductLineToTempOrder(tempOrder, product, booking);
3310
3445
  case 28:
3311
- _context19.next = 6;
3446
+ _context20.next = 6;
3312
3447
  break;
3313
3448
  case 30:
3314
- _context19.next = 35;
3449
+ _context20.next = 35;
3315
3450
  break;
3316
3451
  case 32:
3317
- _context19.prev = 32;
3318
- _context19.t0 = _context19["catch"](4);
3319
- _iterator20.e(_context19.t0);
3452
+ _context20.prev = 32;
3453
+ _context20.t0 = _context20["catch"](4);
3454
+ _iterator20.e(_context20.t0);
3320
3455
  case 35:
3321
- _context19.prev = 35;
3456
+ _context20.prev = 35;
3322
3457
  _iterator20.f();
3323
- return _context19.finish(35);
3458
+ return _context20.finish(35);
3324
3459
  case 38:
3325
- _context19.next = 40;
3460
+ _context20.next = 40;
3326
3461
  return this.finalizeProductOrderMutation(tempOrder, options);
3327
3462
  case 40:
3328
- return _context19.abrupt("return", tempOrder.products);
3463
+ return _context20.abrupt("return", tempOrder.products);
3329
3464
  case 41:
3330
3465
  case "end":
3331
- return _context19.stop();
3466
+ return _context20.stop();
3332
3467
  }
3333
- }, _callee17, this, [[4, 32, 35, 38]]);
3468
+ }, _callee18, this, [[4, 32, 35, 38]]);
3334
3469
  }));
3335
3470
  function addProductsToOrder(_x21, _x22) {
3336
3471
  return _addProductsToOrder.apply(this, arguments);
@@ -3366,17 +3501,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3366
3501
  }, {
3367
3502
  key: "preservePersistedBundlePriceFields",
3368
3503
  value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
3369
- var _this17 = this;
3504
+ var _this18 = this;
3370
3505
  if (!Array.isArray(nextBundles)) return nextBundles;
3371
3506
  if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
3372
3507
  var previousByIdentity = new Map();
3373
3508
  previousBundles.forEach(function (bundle) {
3374
- var identity = _this17.getBundleRuntimeIdentity(bundle);
3509
+ var identity = _this18.getBundleRuntimeIdentity(bundle);
3375
3510
  if (identity) previousByIdentity.set(identity, bundle);
3376
3511
  });
3377
3512
  return nextBundles.map(function (bundle, index) {
3378
3513
  if (!bundle || _typeof(bundle) !== 'object') return bundle;
3379
- var previous = previousByIdentity.get(_this17.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
3514
+ var previous = previousByIdentity.get(_this18.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
3380
3515
  if (!previous || _typeof(previous) !== 'object') return bundle;
3381
3516
  return _objectSpread(_objectSpread({}, bundle), {}, {
3382
3517
  price: previous.price,
@@ -3391,11 +3526,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3391
3526
  }, {
3392
3527
  key: "updateOrderProduct",
3393
3528
  value: function () {
3394
- var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(params) {
3529
+ var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
3395
3530
  var _targetProduct$metada2, _product_sku, _metadata2, _metadata3, _metadata4, _metadata5, _metadata6, _metadata7, _nextProduct$metadata, _targetProduct$metada8, _tempOrder$products$p;
3396
3531
  var product_id, product_variant_id, updates, unique_identification_number, identity_key, product_sku, product_bundle, booking, tempOrder, identityLookup, productIndex, targetUid, targetProduct, nextProduct, callerUpdatesTopPrice, callerUpdatesMainMeta, isPersistedOrderLine, callerChangesDiscountList, callerUpdatesManualPrice, callerAllowsBookingReprice, _targetProduct$metada3, _targetProduct$metada4, _targetProduct$metada5, _targetProduct$metada6, _targetProduct$metada7, existedMeta, normalizedProduct, preservedBookingUid, _normalizedProduct$me, _targetProduct$metada9, productUid, linked;
3397
- return _regeneratorRuntime().wrap(function _callee18$(_context20) {
3398
- while (1) switch (_context20.prev = _context20.next) {
3532
+ return _regeneratorRuntime().wrap(function _callee19$(_context21) {
3533
+ while (1) switch (_context21.prev = _context21.next) {
3399
3534
  case 0:
3400
3535
  product_id = params.product_id, product_variant_id = params.product_variant_id, updates = params.updates, unique_identification_number = params.unique_identification_number, identity_key = params.identity_key, product_sku = params.product_sku, product_bundle = params.product_bundle, booking = params.booking;
3401
3536
  tempOrder = this.ensureTempOrder();
@@ -3426,7 +3561,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3426
3561
  productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
3427
3562
  }
3428
3563
  if (!(productIndex === -1)) {
3429
- _context20.next = 12;
3564
+ _context21.next = 12;
3430
3565
  break;
3431
3566
  }
3432
3567
  throw new Error('[Order] 目标商品不存在,无法更新');
@@ -3522,23 +3657,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3522
3657
  tempOrder.products[productIndex] = normalizedProduct;
3523
3658
  this.syncTempOrderHolderFromBookings(tempOrder);
3524
3659
  this.captureProductRuntime(tempOrder, updates, tempOrder.products[productIndex], (_tempOrder$products$p = tempOrder.products[productIndex].metadata) === null || _tempOrder$products$p === void 0 ? void 0 : _tempOrder$products$p.unique_identification_number);
3525
- _context20.next = 32;
3660
+ _context21.next = 32;
3526
3661
  return this.applyPromotion();
3527
3662
  case 32:
3528
3663
  this.applyDiscount();
3529
3664
  this.sanitizeTempOrderProducts(tempOrder);
3530
- _context20.next = 36;
3665
+ _context21.next = 36;
3531
3666
  return this.recalculateSummary({
3532
3667
  createIfMissing: true
3533
3668
  });
3534
3669
  case 36:
3535
3670
  this.persistTempOrder();
3536
- return _context20.abrupt("return", tempOrder.products);
3671
+ return _context21.abrupt("return", tempOrder.products);
3537
3672
  case 38:
3538
3673
  case "end":
3539
- return _context20.stop();
3674
+ return _context21.stop();
3540
3675
  }
3541
- }, _callee18, this);
3676
+ }, _callee19, this);
3542
3677
  }));
3543
3678
  function updateOrderProduct(_x23) {
3544
3679
  return _updateOrderProduct.apply(this, arguments);
@@ -3548,11 +3683,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3548
3683
  }, {
3549
3684
  key: "updateOrderProductQuantity",
3550
3685
  value: function () {
3551
- var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
3686
+ var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
3552
3687
  var _targetProduct$metada10;
3553
3688
  var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct;
3554
- return _regeneratorRuntime().wrap(function _callee19$(_context21) {
3555
- while (1) switch (_context21.prev = _context21.next) {
3689
+ return _regeneratorRuntime().wrap(function _callee20$(_context22) {
3690
+ while (1) switch (_context22.prev = _context22.next) {
3556
3691
  case 0:
3557
3692
  product_id = params.product_id, product_variant_id = params.product_variant_id, num = params.num, unique_identification_number = params.unique_identification_number, identity_key = params.identity_key, product_sku = params.product_sku, product_bundle = params.product_bundle;
3558
3693
  tempOrder = this.ensureTempOrder();
@@ -3581,7 +3716,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3581
3716
  productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
3582
3717
  }
3583
3718
  if (!(productIndex === -1)) {
3584
- _context21.next = 12;
3719
+ _context22.next = 12;
3585
3720
  break;
3586
3721
  }
3587
3722
  throw new Error('[Order] 目标商品不存在,无法更新数量');
@@ -3595,23 +3730,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3595
3730
  }));
3596
3731
  normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
3597
3732
  tempOrder.products[productIndex] = normalizedProduct;
3598
- _context21.next = 18;
3733
+ _context22.next = 18;
3599
3734
  return this.applyPromotion();
3600
3735
  case 18:
3601
3736
  this.applyDiscount();
3602
3737
  this.sanitizeTempOrderProducts(tempOrder);
3603
- _context21.next = 22;
3738
+ _context22.next = 22;
3604
3739
  return this.recalculateSummary({
3605
3740
  createIfMissing: true
3606
3741
  });
3607
3742
  case 22:
3608
3743
  this.persistTempOrder();
3609
- return _context21.abrupt("return", tempOrder.products);
3744
+ return _context22.abrupt("return", tempOrder.products);
3610
3745
  case 24:
3611
3746
  case "end":
3612
- return _context21.stop();
3747
+ return _context22.stop();
3613
3748
  }
3614
- }, _callee19, this);
3749
+ }, _callee20, this);
3615
3750
  }));
3616
3751
  function updateOrderProductQuantity(_x24) {
3617
3752
  return _updateOrderProductQuantity.apply(this, arguments);
@@ -3654,17 +3789,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3654
3789
  }, {
3655
3790
  key: "finalizeAfterProductsMutation",
3656
3791
  value: (function () {
3657
- var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(tempOrder) {
3658
- return _regeneratorRuntime().wrap(function _callee20$(_context22) {
3659
- while (1) switch (_context22.prev = _context22.next) {
3792
+ var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(tempOrder) {
3793
+ return _regeneratorRuntime().wrap(function _callee21$(_context23) {
3794
+ while (1) switch (_context23.prev = _context23.next) {
3660
3795
  case 0:
3661
3796
  this.syncTempOrderHolderFromBookings(tempOrder);
3662
- _context22.next = 3;
3797
+ _context23.next = 3;
3663
3798
  return this.applyPromotion();
3664
3799
  case 3:
3665
3800
  this.applyDiscount();
3666
3801
  this.sanitizeTempOrderProducts(tempOrder);
3667
- _context22.next = 7;
3802
+ _context23.next = 7;
3668
3803
  return this.recalculateSummary({
3669
3804
  createIfMissing: true
3670
3805
  });
@@ -3672,9 +3807,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3672
3807
  this.persistTempOrder();
3673
3808
  case 8:
3674
3809
  case "end":
3675
- return _context22.stop();
3810
+ return _context23.stop();
3676
3811
  }
3677
- }, _callee20, this);
3812
+ }, _callee21, this);
3678
3813
  }));
3679
3814
  function finalizeAfterProductsMutation(_x25) {
3680
3815
  return _finalizeAfterProductsMutation.apply(this, arguments);
@@ -3691,17 +3826,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3691
3826
  }, {
3692
3827
  key: "removeProductsFromOrder",
3693
3828
  value: (function () {
3694
- var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(identities) {
3695
- var tempOrder, removedProducts, _i, _removedProducts, product;
3696
- return _regeneratorRuntime().wrap(function _callee21$(_context23) {
3697
- while (1) switch (_context23.prev = _context23.next) {
3829
+ var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(identities) {
3830
+ var tempOrder, removedProducts, _i2, _removedProducts, product;
3831
+ return _regeneratorRuntime().wrap(function _callee22$(_context24) {
3832
+ while (1) switch (_context24.prev = _context24.next) {
3698
3833
  case 0:
3699
3834
  tempOrder = this.ensureTempOrder();
3700
3835
  if (identities.length) {
3701
- _context23.next = 3;
3836
+ _context24.next = 3;
3702
3837
  break;
3703
3838
  }
3704
- return _context23.abrupt("return", tempOrder.products);
3839
+ return _context24.abrupt("return", tempOrder.products);
3705
3840
  case 3:
3706
3841
  removedProducts = [];
3707
3842
  tempOrder.products = tempOrder.products.filter(function (item) {
@@ -3711,19 +3846,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3711
3846
  if (shouldRemove) removedProducts.push(item);
3712
3847
  return !shouldRemove;
3713
3848
  });
3714
- for (_i = 0, _removedProducts = removedProducts; _i < _removedProducts.length; _i++) {
3715
- product = _removedProducts[_i];
3849
+ for (_i2 = 0, _removedProducts = removedProducts; _i2 < _removedProducts.length; _i2++) {
3850
+ product = _removedProducts[_i2];
3716
3851
  this.removeLinkedBookingsForProduct(tempOrder, product);
3717
3852
  }
3718
- _context23.next = 8;
3853
+ _context24.next = 8;
3719
3854
  return this.finalizeAfterProductsMutation(tempOrder);
3720
3855
  case 8:
3721
- return _context23.abrupt("return", tempOrder.products);
3856
+ return _context24.abrupt("return", tempOrder.products);
3722
3857
  case 9:
3723
3858
  case "end":
3724
- return _context23.stop();
3859
+ return _context24.stop();
3725
3860
  }
3726
- }, _callee21, this);
3861
+ }, _callee22, this);
3727
3862
  }));
3728
3863
  function removeProductsFromOrder(_x26) {
3729
3864
  return _removeProductsFromOrder.apply(this, arguments);
@@ -3733,16 +3868,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3733
3868
  }, {
3734
3869
  key: "removeProductFromOrder",
3735
3870
  value: function () {
3736
- var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(identity) {
3737
- return _regeneratorRuntime().wrap(function _callee22$(_context24) {
3738
- while (1) switch (_context24.prev = _context24.next) {
3871
+ var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(identity) {
3872
+ return _regeneratorRuntime().wrap(function _callee23$(_context25) {
3873
+ while (1) switch (_context25.prev = _context25.next) {
3739
3874
  case 0:
3740
- return _context24.abrupt("return", this.removeProductsFromOrder([identity]));
3875
+ return _context25.abrupt("return", this.removeProductsFromOrder([identity]));
3741
3876
  case 1:
3742
3877
  case "end":
3743
- return _context24.stop();
3878
+ return _context25.stop();
3744
3879
  }
3745
- }, _callee22, this);
3880
+ }, _callee23, this);
3746
3881
  }));
3747
3882
  function removeProductFromOrder(_x27) {
3748
3883
  return _removeProductFromOrder.apply(this, arguments);
@@ -3756,10 +3891,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3756
3891
  }, {
3757
3892
  key: "clearOrderCartLines",
3758
3893
  value: (function () {
3759
- var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
3894
+ var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
3760
3895
  var tempOrder;
3761
- return _regeneratorRuntime().wrap(function _callee23$(_context25) {
3762
- while (1) switch (_context25.prev = _context25.next) {
3896
+ return _regeneratorRuntime().wrap(function _callee24$(_context26) {
3897
+ while (1) switch (_context26.prev = _context26.next) {
3763
3898
  case 0:
3764
3899
  tempOrder = this.ensureTempOrder();
3765
3900
  tempOrder.products = [];
@@ -3770,23 +3905,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3770
3905
  productsByUid: {}
3771
3906
  });
3772
3907
  }
3773
- _context25.next = 7;
3908
+ _context26.next = 7;
3774
3909
  return this.applyPromotion();
3775
3910
  case 7:
3776
3911
  this.applyDiscount();
3777
3912
  this.sanitizeTempOrderProducts(tempOrder);
3778
- _context25.next = 11;
3913
+ _context26.next = 11;
3779
3914
  return this.recalculateSummary({
3780
3915
  createIfMissing: true
3781
3916
  });
3782
3917
  case 11:
3783
3918
  this.persistTempOrder();
3784
- return _context25.abrupt("return", tempOrder);
3919
+ return _context26.abrupt("return", tempOrder);
3785
3920
  case 13:
3786
3921
  case "end":
3787
- return _context25.stop();
3922
+ return _context26.stop();
3788
3923
  }
3789
- }, _callee23, this);
3924
+ }, _callee24, this);
3790
3925
  }));
3791
3926
  function clearOrderCartLines() {
3792
3927
  return _clearOrderCartLines.apply(this, arguments);
@@ -3824,17 +3959,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3824
3959
  }, {
3825
3960
  key: "applyLocalPrintOrderNumbers",
3826
3961
  value: function () {
3827
- var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(order) {
3962
+ var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(order) {
3828
3963
  var tempOrder, shopOrderNumber, shopFullOrderNumber;
3829
- return _regeneratorRuntime().wrap(function _callee24$(_context26) {
3830
- while (1) switch (_context26.prev = _context26.next) {
3964
+ return _regeneratorRuntime().wrap(function _callee25$(_context27) {
3965
+ while (1) switch (_context27.prev = _context27.next) {
3831
3966
  case 0:
3832
3967
  tempOrder = this.ensureTempOrder();
3833
3968
  if (!(!order || _typeof(order) !== 'object')) {
3834
- _context26.next = 3;
3969
+ _context27.next = 3;
3835
3970
  break;
3836
3971
  }
3837
- return _context26.abrupt("return", tempOrder);
3972
+ return _context27.abrupt("return", tempOrder);
3838
3973
  case 3:
3839
3974
  shopOrderNumber = order.shop_order_number;
3840
3975
  shopFullOrderNumber = order.shop_full_order_number;
@@ -3845,15 +3980,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3845
3980
  tempOrder.shop_full_order_number = String(shopFullOrderNumber);
3846
3981
  }
3847
3982
  this.persistTempOrder();
3848
- _context26.next = 10;
3983
+ _context27.next = 10;
3849
3984
  return this.saveDraft();
3850
3985
  case 10:
3851
- return _context26.abrupt("return", tempOrder);
3986
+ return _context27.abrupt("return", tempOrder);
3852
3987
  case 11:
3853
3988
  case "end":
3854
- return _context26.stop();
3989
+ return _context27.stop();
3855
3990
  }
3856
- }, _callee24, this);
3991
+ }, _callee25, this);
3857
3992
  }));
3858
3993
  function applyLocalPrintOrderNumbers(_x28) {
3859
3994
  return _applyLocalPrintOrderNumbers.apply(this, arguments);
@@ -3869,16 +4004,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3869
4004
  }, {
3870
4005
  key: "submitTempOrder",
3871
4006
  value: (function () {
3872
- var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
3873
- return _regeneratorRuntime().wrap(function _callee25$(_context27) {
3874
- while (1) switch (_context27.prev = _context27.next) {
4007
+ var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
4008
+ return _regeneratorRuntime().wrap(function _callee26$(_context28) {
4009
+ while (1) switch (_context28.prev = _context28.next) {
3875
4010
  case 0:
3876
- return _context27.abrupt("return", this.runSubmitTempOrder(params));
4011
+ return _context28.abrupt("return", this.runSubmitTempOrder(params));
3877
4012
  case 1:
3878
4013
  case "end":
3879
- return _context27.stop();
4014
+ return _context28.stop();
3880
4015
  }
3881
- }, _callee25, this);
4016
+ }, _callee26, this);
3882
4017
  }));
3883
4018
  function submitTempOrder(_x29) {
3884
4019
  return _submitTempOrder.apply(this, arguments);
@@ -3888,18 +4023,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3888
4023
  }, {
3889
4024
  key: "submitTempOrderAsync",
3890
4025
  value: function () {
3891
- var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
3892
- return _regeneratorRuntime().wrap(function _callee26$(_context28) {
3893
- while (1) switch (_context28.prev = _context28.next) {
4026
+ var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
4027
+ return _regeneratorRuntime().wrap(function _callee27$(_context29) {
4028
+ while (1) switch (_context29.prev = _context29.next) {
3894
4029
  case 0:
3895
- return _context28.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
4030
+ return _context29.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
3896
4031
  syncMode: true
3897
4032
  })));
3898
4033
  case 1:
3899
4034
  case "end":
3900
- return _context28.stop();
4035
+ return _context29.stop();
3901
4036
  }
3902
- }, _callee26, this);
4037
+ }, _callee27, this);
3903
4038
  }));
3904
4039
  function submitTempOrderAsync(_x30) {
3905
4040
  return _submitTempOrderAsync.apply(this, arguments);
@@ -3909,34 +4044,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3909
4044
  }, {
3910
4045
  key: "runSubmitTempOrder",
3911
4046
  value: function () {
3912
- var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
4047
+ var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
3913
4048
  var _params$cacheId2, _this$otherParams5, _ref70, _params$businessCode2, _this$otherParams6, _this$otherParams7;
3914
4049
  var tempOrder, latestSummary, effectiveCacheId, hasPaymentOverride, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
3915
- return _regeneratorRuntime().wrap(function _callee27$(_context29) {
3916
- while (1) switch (_context29.prev = _context29.next) {
4050
+ return _regeneratorRuntime().wrap(function _callee28$(_context30) {
4051
+ while (1) switch (_context30.prev = _context30.next) {
3917
4052
  case 0:
3918
4053
  tempOrder = this.ensureTempOrder();
3919
4054
  this.persistTempOrder();
3920
- _context29.next = 4;
4055
+ _context30.next = 4;
3921
4056
  return this.recalculateSummary({
3922
4057
  createIfMissing: true
3923
4058
  });
3924
4059
  case 4:
3925
- _context29.t1 = _context29.sent;
3926
- if (_context29.t1) {
3927
- _context29.next = 7;
4060
+ _context30.t1 = _context30.sent;
4061
+ if (_context30.t1) {
4062
+ _context30.next = 7;
3928
4063
  break;
3929
4064
  }
3930
- _context29.t1 = this.store.summary;
4065
+ _context30.t1 = this.store.summary;
3931
4066
  case 7:
3932
- _context29.t0 = _context29.t1;
3933
- if (_context29.t0) {
3934
- _context29.next = 10;
4067
+ _context30.t0 = _context30.t1;
4068
+ if (_context30.t0) {
4069
+ _context30.next = 10;
3935
4070
  break;
3936
4071
  }
3937
- _context29.t0 = createEmptySummary();
4072
+ _context30.t0 = createEmptySummary();
3938
4073
  case 10:
3939
- latestSummary = _context29.t0;
4074
+ latestSummary = _context30.t0;
3940
4075
  effectiveCacheId = (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId;
3941
4076
  hasPaymentOverride = (params === null || params === void 0 ? void 0 : params.payments) !== undefined;
3942
4077
  hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
@@ -3970,10 +4105,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3970
4105
  if (!payload.created_at) {
3971
4106
  payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
3972
4107
  }
3973
- _context29.next = 21;
4108
+ _context30.next = 21;
3974
4109
  return this.saveDraft();
3975
4110
  case 21:
3976
- _context29.prev = 21;
4111
+ _context30.prev = 21;
3977
4112
  this.logInfo('submitTempOrder calling sales checkout', {
3978
4113
  orderId: payload.order_id,
3979
4114
  externalSaleNumber: payload.external_sale_number,
@@ -3983,43 +4118,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3983
4118
  smallTicketDataFlag: payload.small_ticket_data_flag,
3984
4119
  syncMode: payload.sync_mode
3985
4120
  });
3986
- _context29.next = 25;
4121
+ _context30.next = 25;
3987
4122
  return this.submitSalesOrder({
3988
4123
  query: payload
3989
4124
  });
3990
4125
  case 25:
3991
- result = _context29.sent;
3992
- _context29.next = 38;
4126
+ result = _context30.sent;
4127
+ _context30.next = 38;
3993
4128
  break;
3994
4129
  case 28:
3995
- _context29.prev = 28;
3996
- _context29.t2 = _context29["catch"](21);
3997
- backendErrorResponse = this.extractSubmitErrorResponse(_context29.t2);
4130
+ _context30.prev = 28;
4131
+ _context30.t2 = _context30["catch"](21);
4132
+ backendErrorResponse = this.extractSubmitErrorResponse(_context30.t2);
3998
4133
  if (!backendErrorResponse) {
3999
- _context29.next = 35;
4134
+ _context30.next = 35;
4000
4135
  break;
4001
4136
  }
4002
4137
  this.store.syncState = 'failed';
4003
4138
  this.logSubmitBackendRejected(backendErrorResponse, payload);
4004
- return _context29.abrupt("return", backendErrorResponse);
4139
+ return _context30.abrupt("return", backendErrorResponse);
4005
4140
  case 35:
4006
4141
  this.store.syncState = 'failed';
4007
4142
  this.logError('submitTempOrder failed', {
4008
- error: _context29.t2 instanceof Error ? _context29.t2.message : String(_context29.t2),
4143
+ error: _context30.t2 instanceof Error ? _context30.t2.message : String(_context30.t2),
4009
4144
  orderId: payload.order_id,
4010
4145
  externalSaleNumber: payload.external_sale_number,
4011
4146
  paymentStatus: payload.payment_status,
4012
4147
  paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
4013
4148
  });
4014
- throw _context29.t2;
4149
+ throw _context30.t2;
4015
4150
  case 38:
4016
4151
  if (!this.isSubmitResponseRejected(result)) {
4017
- _context29.next = 42;
4152
+ _context30.next = 42;
4018
4153
  break;
4019
4154
  }
4020
4155
  this.store.syncState = 'failed';
4021
4156
  this.logSubmitBackendRejected(result, payload);
4022
- return _context29.abrupt("return", result);
4157
+ return _context30.abrupt("return", result);
4023
4158
  case 42:
4024
4159
  submittedOrderId = this.extractOrderIdFromSubmitResult(result);
4025
4160
  this.logInfo('runSubmitTempOrder: 提交成功', {
@@ -4028,15 +4163,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4028
4163
  tempOrder: tempOrder
4029
4164
  });
4030
4165
  if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
4031
- _context29.next = 51;
4166
+ _context30.next = 51;
4032
4167
  break;
4033
4168
  }
4034
4169
  tempOrder.order_id = submittedOrderId;
4035
4170
  resultRecord = result;
4036
- _context29.next = 49;
4171
+ _context30.next = 49;
4037
4172
  return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
4038
4173
  case 49:
4039
- _context29.next = 52;
4174
+ _context30.next = 52;
4040
4175
  break;
4041
4176
  case 51:
4042
4177
  if (this.isLocalPendingSubmitResult(result)) {
@@ -4045,12 +4180,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4045
4180
  this.store.syncState = 'submitted';
4046
4181
  }
4047
4182
  case 52:
4048
- return _context29.abrupt("return", result);
4183
+ return _context30.abrupt("return", result);
4049
4184
  case 53:
4050
4185
  case "end":
4051
- return _context29.stop();
4186
+ return _context30.stop();
4052
4187
  }
4053
- }, _callee27, this, [[21, 28]]);
4188
+ }, _callee28, this, [[21, 28]]);
4054
4189
  }));
4055
4190
  function runSubmitTempOrder(_x31) {
4056
4191
  return _runSubmitTempOrder.apply(this, arguments);
@@ -4060,10 +4195,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4060
4195
  }, {
4061
4196
  key: "markLocalOrderSynced",
4062
4197
  value: function () {
4063
- var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(orderId, remoteOrder) {
4198
+ var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(orderId, remoteOrder) {
4064
4199
  var tempOrder;
4065
- return _regeneratorRuntime().wrap(function _callee28$(_context30) {
4066
- while (1) switch (_context30.prev = _context30.next) {
4200
+ return _regeneratorRuntime().wrap(function _callee29$(_context31) {
4201
+ while (1) switch (_context31.prev = _context31.next) {
4067
4202
  case 0:
4068
4203
  tempOrder = this.ensureTempOrder();
4069
4204
  tempOrder.order_id = orderId;
@@ -4071,13 +4206,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4071
4206
  this.store.lastOrderInfo = remoteOrder;
4072
4207
  this.store.syncState = 'submitted';
4073
4208
  this.persistTempOrder();
4074
- _context30.next = 8;
4209
+ _context31.next = 8;
4075
4210
  return this.saveDraft();
4076
4211
  case 8:
4077
4212
  case "end":
4078
- return _context30.stop();
4213
+ return _context31.stop();
4079
4214
  }
4080
- }, _callee28, this);
4215
+ }, _callee29, this);
4081
4216
  }));
4082
4217
  function markLocalOrderSynced(_x32, _x33) {
4083
4218
  return _markLocalOrderSynced.apply(this, arguments);
@@ -4122,10 +4257,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4122
4257
  value: function extractSubmitErrorResponse(error) {
4123
4258
  var _error$response,
4124
4259
  _error$response2,
4125
- _this18 = this;
4260
+ _this19 = this;
4126
4261
  var candidates = [error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data, error === null || error === void 0 ? void 0 : error.data, error === null || error === void 0 || (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.body, error === null || error === void 0 ? void 0 : error.body];
4127
4262
  return candidates.find(function (candidate) {
4128
- return _this18.isSubmitErrorResponse(candidate);
4263
+ return _this19.isSubmitErrorResponse(candidate);
4129
4264
  }) || null;
4130
4265
  }
4131
4266
  }, {
@@ -4152,10 +4287,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4152
4287
  }, {
4153
4288
  key: "syncPaymentsToOrder",
4154
4289
  value: function () {
4155
- var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
4290
+ var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
4156
4291
  var tempOrder, mappedPayments, paymentTotal, targetAmount, isFullyPaid, paymentStatus, paymentSyncIdempotencyToken, submitResult;
4157
- return _regeneratorRuntime().wrap(function _callee29$(_context31) {
4158
- while (1) switch (_context31.prev = _context31.next) {
4292
+ return _regeneratorRuntime().wrap(function _callee30$(_context32) {
4293
+ while (1) switch (_context32.prev = _context32.next) {
4159
4294
  case 0:
4160
4295
  tempOrder = this.ensureTempOrder();
4161
4296
  mappedPayments = mapPaymentItemsToOrderPayments(params.payments || []);
@@ -4166,28 +4301,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4166
4301
  tempOrder.payments = mappedPayments;
4167
4302
  tempOrder.payment_status = paymentStatus;
4168
4303
  this.persistTempOrder();
4169
- _context31.next = 11;
4304
+ _context32.next = 11;
4170
4305
  return this.saveDraft();
4171
4306
  case 11:
4172
4307
  if (params.submitWhenPaid) {
4173
- _context31.next = 13;
4308
+ _context32.next = 13;
4174
4309
  break;
4175
4310
  }
4176
- return _context31.abrupt("return", {
4311
+ return _context32.abrupt("return", {
4177
4312
  isFullyPaid: isFullyPaid
4178
4313
  });
4179
4314
  case 13:
4180
4315
  if (!(this.store.syncState === 'submitting')) {
4181
- _context31.next = 15;
4316
+ _context32.next = 15;
4182
4317
  break;
4183
4318
  }
4184
- return _context31.abrupt("return", {
4319
+ return _context32.abrupt("return", {
4185
4320
  isFullyPaid: isFullyPaid
4186
4321
  });
4187
4322
  case 15:
4188
4323
  this.store.syncState = 'submitting';
4189
4324
  paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, mappedPayments);
4190
- _context31.next = 19;
4325
+ _context32.next = 19;
4191
4326
  return this.submitTempOrder({
4192
4327
  payments: mappedPayments,
4193
4328
  paymentStatus: paymentStatus,
@@ -4202,16 +4337,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4202
4337
  }
4203
4338
  });
4204
4339
  case 19:
4205
- submitResult = _context31.sent;
4206
- return _context31.abrupt("return", {
4340
+ submitResult = _context32.sent;
4341
+ return _context32.abrupt("return", {
4207
4342
  isFullyPaid: isFullyPaid,
4208
4343
  submitResult: submitResult
4209
4344
  });
4210
4345
  case 21:
4211
4346
  case "end":
4212
- return _context31.stop();
4347
+ return _context32.stop();
4213
4348
  }
4214
- }, _callee29, this);
4349
+ }, _callee30, this);
4215
4350
  }));
4216
4351
  function syncPaymentsToOrder(_x34) {
4217
4352
  return _syncPaymentsToOrder.apply(this, arguments);
@@ -4302,11 +4437,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4302
4437
  }, {
4303
4438
  key: "submitOrder",
4304
4439
  value: function () {
4305
- var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(order) {
4440
+ var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(order) {
4306
4441
  var _order$query$cartItem, _params$bookings, _params$relation_prod;
4307
4442
  var url, query, fetchUrl, params;
4308
- return _regeneratorRuntime().wrap(function _callee30$(_context32) {
4309
- while (1) switch (_context32.prev = _context32.next) {
4443
+ return _regeneratorRuntime().wrap(function _callee31$(_context33) {
4444
+ while (1) switch (_context33.prev = _context33.next) {
4310
4445
  case 0:
4311
4446
  this.logInfo('submitOrder called', {
4312
4447
  url: order.url,
@@ -4326,12 +4461,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4326
4461
  relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
4327
4462
  scheduleDate: params.schedule_date
4328
4463
  });
4329
- return _context32.abrupt("return", this.request.post(fetchUrl, params));
4464
+ return _context33.abrupt("return", this.request.post(fetchUrl, params));
4330
4465
  case 6:
4331
4466
  case "end":
4332
- return _context32.stop();
4467
+ return _context33.stop();
4333
4468
  }
4334
- }, _callee30, this);
4469
+ }, _callee31, this);
4335
4470
  }));
4336
4471
  function submitOrder(_x35) {
4337
4472
  return _submitOrder.apply(this, arguments);
@@ -4341,13 +4476,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4341
4476
  }, {
4342
4477
  key: "cancelOrder",
4343
4478
  value: function () {
4344
- var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
4479
+ var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
4345
4480
  var payload;
4346
- return _regeneratorRuntime().wrap(function _callee31$(_context33) {
4347
- while (1) switch (_context33.prev = _context33.next) {
4481
+ return _regeneratorRuntime().wrap(function _callee32$(_context34) {
4482
+ while (1) switch (_context34.prev = _context34.next) {
4348
4483
  case 0:
4349
4484
  if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
4350
- _context33.next = 2;
4485
+ _context34.next = 2;
4351
4486
  break;
4352
4487
  }
4353
4488
  throw new Error('取消订单失败:order_ids 不能为空');
@@ -4363,14 +4498,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4363
4498
  method: 'PUT',
4364
4499
  orderIdsCount: params.order_ids.length
4365
4500
  });
4366
- return _context33.abrupt("return", this.request.put('/order/update-status', payload, {
4501
+ return _context34.abrupt("return", this.request.put('/order/update-status', payload, {
4367
4502
  isShopApi: true
4368
4503
  }));
4369
4504
  case 5:
4370
4505
  case "end":
4371
- return _context33.stop();
4506
+ return _context34.stop();
4372
4507
  }
4373
- }, _callee31, this);
4508
+ }, _callee32, this);
4374
4509
  }));
4375
4510
  function cancelOrder(_x36) {
4376
4511
  return _cancelOrder.apply(this, arguments);
@@ -4380,19 +4515,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4380
4515
  }, {
4381
4516
  key: "changeBookingStatus",
4382
4517
  value: function () {
4383
- var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
4518
+ var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
4384
4519
  var url, payload;
4385
- return _regeneratorRuntime().wrap(function _callee32$(_context34) {
4386
- while (1) switch (_context34.prev = _context34.next) {
4520
+ return _regeneratorRuntime().wrap(function _callee33$(_context35) {
4521
+ while (1) switch (_context35.prev = _context35.next) {
4387
4522
  case 0:
4388
4523
  if (params.booking_id) {
4389
- _context34.next = 2;
4524
+ _context35.next = 2;
4390
4525
  break;
4391
4526
  }
4392
4527
  throw new Error('变更预约状态失败:booking_id 不能为空');
4393
4528
  case 2:
4394
4529
  if (params.appointment_status) {
4395
- _context34.next = 4;
4530
+ _context35.next = 4;
4396
4531
  break;
4397
4532
  }
4398
4533
  throw new Error('变更预约状态失败:appointment_status 不能为空');
@@ -4407,14 +4542,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4407
4542
  bookingId: params.booking_id,
4408
4543
  appointmentStatus: params.appointment_status
4409
4544
  });
4410
- return _context34.abrupt("return", this.request.put(url, payload, {
4545
+ return _context35.abrupt("return", this.request.put(url, payload, {
4411
4546
  isShopApi: true
4412
4547
  }));
4413
4548
  case 8:
4414
4549
  case "end":
4415
- return _context34.stop();
4550
+ return _context35.stop();
4416
4551
  }
4417
- }, _callee32, this);
4552
+ }, _callee33, this);
4418
4553
  }));
4419
4554
  function changeBookingStatus(_x37) {
4420
4555
  return _changeBookingStatus.apply(this, arguments);
@@ -4434,11 +4569,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4434
4569
  }, {
4435
4570
  key: "createOrderByCheckout",
4436
4571
  value: (function () {
4437
- var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
4572
+ var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
4438
4573
  var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3, _params$bookings3, _params$relation_prod3, _params$payments4;
4439
4574
  var onlineStorePaymentCodeList, _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, _orderData$bookings2, _orderData$relation_p2, _orderData$payments4, _orderData$payments5, _response$data, orderData, response;
4440
- return _regeneratorRuntime().wrap(function _callee33$(_context35) {
4441
- while (1) switch (_context35.prev = _context35.next) {
4575
+ return _regeneratorRuntime().wrap(function _callee34$(_context36) {
4576
+ while (1) switch (_context36.prev = _context36.next) {
4442
4577
  case 0:
4443
4578
  // 过滤掉由在线店铺下单的 payment 支付数据
4444
4579
  onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
@@ -4472,7 +4607,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4472
4607
  relationProductsCount: ((_params$relation_prod3 = params.relation_products) === null || _params$relation_prod3 === void 0 ? void 0 : _params$relation_prod3.length) || 0,
4473
4608
  paymentsCount: ((_params$payments4 = params.payments) === null || _params$payments4 === void 0 ? void 0 : _params$payments4.length) || 0
4474
4609
  });
4475
- _context35.prev = 4;
4610
+ _context36.prev = 4;
4476
4611
  // 构建订单数据,设置默认值并允许 params 覆盖
4477
4612
  orderData = _objectSpread({
4478
4613
  sales_channel: 'my_pisel',
@@ -4534,13 +4669,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4534
4669
  hasOrderId: !!orderData.order_id,
4535
4670
  smallTicketDataFlag: orderData.small_ticket_data_flag
4536
4671
  });
4537
- _context35.next = 12;
4672
+ _context36.next = 12;
4538
4673
  return this.request.post('/order/checkout', orderData, {
4539
4674
  osServer: true,
4540
4675
  customToast: function customToast() {}
4541
4676
  });
4542
4677
  case 12:
4543
- response = _context35.sent;
4678
+ response = _context36.sent;
4544
4679
  this.logInfo('Order API called successfully', {
4545
4680
  response: response
4546
4681
  });
@@ -4548,20 +4683,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4548
4683
  success: !!response,
4549
4684
  hasOrderId: !!(response !== null && response !== void 0 && (_response$data = response.data) !== null && _response$data !== void 0 && _response$data.order_id || response !== null && response !== void 0 && response.order_id)
4550
4685
  });
4551
- return _context35.abrupt("return", response);
4686
+ return _context36.abrupt("return", response);
4552
4687
  case 18:
4553
- _context35.prev = 18;
4554
- _context35.t0 = _context35["catch"](4);
4555
- console.error('[Order] createOrderByCheckout 创建订单失败:', _context35.t0);
4688
+ _context36.prev = 18;
4689
+ _context36.t0 = _context36["catch"](4);
4690
+ console.error('[Order] createOrderByCheckout 创建订单失败:', _context36.t0);
4556
4691
  this.logInfo('Order API called failed', {
4557
- error: _context35.t0 instanceof Error ? _context35.t0.message : String(_context35.t0)
4692
+ error: _context36.t0 instanceof Error ? _context36.t0.message : String(_context36.t0)
4558
4693
  });
4559
- throw _context35.t0;
4694
+ throw _context36.t0;
4560
4695
  case 23:
4561
4696
  case "end":
4562
- return _context35.stop();
4697
+ return _context36.stop();
4563
4698
  }
4564
- }, _callee33, this, [[4, 18]]);
4699
+ }, _callee34, this, [[4, 18]]);
4565
4700
  }));
4566
4701
  function createOrderByCheckout(_x38) {
4567
4702
  return _createOrderByCheckout.apply(this, arguments);
@@ -4571,22 +4706,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4571
4706
  }, {
4572
4707
  key: "submitSalesOrder",
4573
4708
  value: function () {
4574
- var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
4709
+ var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
4575
4710
  var url, query, fetchUrl;
4576
- return _regeneratorRuntime().wrap(function _callee34$(_context36) {
4577
- while (1) switch (_context36.prev = _context36.next) {
4711
+ return _regeneratorRuntime().wrap(function _callee35$(_context37) {
4712
+ while (1) switch (_context37.prev = _context37.next) {
4578
4713
  case 0:
4579
4714
  url = params.url, query = params.query;
4580
4715
  fetchUrl = url || '/order/sales/checkout';
4581
- return _context36.abrupt("return", this.request.post(fetchUrl, query, {
4716
+ return _context37.abrupt("return", this.request.post(fetchUrl, query, {
4582
4717
  osServer: true,
4583
4718
  customToast: function customToast() {}
4584
4719
  }));
4585
4720
  case 3:
4586
4721
  case "end":
4587
- return _context36.stop();
4722
+ return _context37.stop();
4588
4723
  }
4589
- }, _callee34, this);
4724
+ }, _callee35, this);
4590
4725
  }));
4591
4726
  function submitSalesOrder(_x39) {
4592
4727
  return _submitSalesOrder.apply(this, arguments);
@@ -4602,35 +4737,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4602
4737
  }, {
4603
4738
  key: "sendCustomerPayLink",
4604
4739
  value: (function () {
4605
- var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
4740
+ var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
4606
4741
  var _params$emails;
4607
4742
  var orderIds;
4608
- return _regeneratorRuntime().wrap(function _callee35$(_context37) {
4609
- while (1) switch (_context37.prev = _context37.next) {
4743
+ return _regeneratorRuntime().wrap(function _callee36$(_context38) {
4744
+ while (1) switch (_context38.prev = _context38.next) {
4610
4745
  case 0:
4611
4746
  orderIds = params.order_ids || params.orderIds || [];
4612
4747
  if (orderIds.length) {
4613
- _context37.next = 3;
4748
+ _context38.next = 3;
4614
4749
  break;
4615
4750
  }
4616
4751
  throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
4617
4752
  case 3:
4618
4753
  if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
4619
- _context37.next = 5;
4754
+ _context38.next = 5;
4620
4755
  break;
4621
4756
  }
4622
4757
  throw new Error('发送支付链接需要至少一个邮箱');
4623
4758
  case 5:
4624
- return _context37.abrupt("return", this.request.post('/order/batch-email', {
4759
+ return _context38.abrupt("return", this.request.post('/order/batch-email', {
4625
4760
  order_ids: orderIds,
4626
4761
  notify_action: params.notify_action || 'order_payment_reminder',
4627
4762
  emails: params.emails
4628
4763
  }));
4629
4764
  case 6:
4630
4765
  case "end":
4631
- return _context37.stop();
4766
+ return _context38.stop();
4632
4767
  }
4633
- }, _callee35, this);
4768
+ }, _callee36, this);
4634
4769
  }));
4635
4770
  function sendCustomerPayLink(_x40) {
4636
4771
  return _sendCustomerPayLink.apply(this, arguments);
@@ -4640,14 +4775,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4640
4775
  }, {
4641
4776
  key: "getSalesOrderByLookup",
4642
4777
  value: function () {
4643
- var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
4778
+ var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
4644
4779
  var lookup, res;
4645
- return _regeneratorRuntime().wrap(function _callee36$(_context38) {
4646
- while (1) switch (_context38.prev = _context38.next) {
4780
+ return _regeneratorRuntime().wrap(function _callee37$(_context39) {
4781
+ while (1) switch (_context39.prev = _context39.next) {
4647
4782
  case 0:
4648
4783
  lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
4649
4784
  if (lookup) {
4650
- _context38.next = 3;
4785
+ _context39.next = 3;
4651
4786
  break;
4652
4787
  }
4653
4788
  throw new Error('加载销售详情需要 lookup');
@@ -4656,7 +4791,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4656
4791
  if (lookup.startsWith('LOCAL_')) {
4657
4792
  params.forceRemote = false;
4658
4793
  }
4659
- _context38.next = 6;
4794
+ _context39.next = 6;
4660
4795
  return this.request.get("/order/sales/".concat(encodeURIComponent(lookup)), _objectSpread({
4661
4796
  with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info']
4662
4797
  }, params.forceRemote ? {
@@ -4665,16 +4800,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4665
4800
  osServer: true
4666
4801
  });
4667
4802
  case 6:
4668
- res = _context38.sent;
4803
+ res = _context39.sent;
4669
4804
  if (res.code === 200) {
4670
4805
  this.store.lastOrderInfo = res.data;
4671
4806
  }
4672
- return _context38.abrupt("return", res);
4807
+ return _context39.abrupt("return", res);
4673
4808
  case 9:
4674
4809
  case "end":
4675
- return _context38.stop();
4810
+ return _context39.stop();
4676
4811
  }
4677
- }, _callee36, this);
4812
+ }, _callee37, this);
4678
4813
  }));
4679
4814
  function getSalesOrderByLookup(_x41) {
4680
4815
  return _getSalesOrderByLookup.apply(this, arguments);
@@ -4690,11 +4825,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4690
4825
  }, {
4691
4826
  key: "hydrateTempOrderFromRecord",
4692
4827
  value: (function () {
4693
- var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(record, options) {
4828
+ var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(record, options) {
4694
4829
  var _this$store$discount13;
4695
4830
  var raw, nextTempOrder, rawSummary, summarySurcharges, hydratedEditDiscounts, currentDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount14, _this$store$discount15;
4696
- return _regeneratorRuntime().wrap(function _callee37$(_context39) {
4697
- while (1) switch (_context39.prev = _context39.next) {
4831
+ return _regeneratorRuntime().wrap(function _callee38$(_context40) {
4832
+ while (1) switch (_context40.prev = _context40.next) {
4698
4833
  case 0:
4699
4834
  raw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
4700
4835
  nextTempOrder = this.normalizeTempOrderForRuntime(raw);
@@ -4720,31 +4855,31 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4720
4855
  currentDiscounts = typeof ((_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.getDiscountList) === 'function' ? this.store.discount.getDiscountList() || [] : [];
4721
4856
  shouldSkipEmptyDiscountSync = hydratedEditDiscounts.length === 0 && currentDiscounts.length === 0;
4722
4857
  if (shouldSkipEmptyDiscountSync) {
4723
- _context39.next = 16;
4858
+ _context40.next = 16;
4724
4859
  break;
4725
4860
  }
4726
- _context39.next = 14;
4861
+ _context40.next = 14;
4727
4862
  return (_this$store$discount14 = this.store.discount) === null || _this$store$discount14 === void 0 ? void 0 : _this$store$discount14.setOriginalDiscountList(hydratedEditDiscounts);
4728
4863
  case 14:
4729
- _context39.next = 16;
4864
+ _context40.next = 16;
4730
4865
  return (_this$store$discount15 = this.store.discount) === null || _this$store$discount15 === void 0 ? void 0 : _this$store$discount15.setDiscountList(hydratedEditDiscounts);
4731
4866
  case 16:
4732
4867
  if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
4733
- _context39.next = 19;
4868
+ _context40.next = 19;
4734
4869
  break;
4735
4870
  }
4736
- _context39.next = 19;
4871
+ _context40.next = 19;
4737
4872
  return this.recalculateSummary({
4738
4873
  createIfMissing: false
4739
4874
  });
4740
4875
  case 19:
4741
4876
  this.persistTempOrder();
4742
- return _context39.abrupt("return", nextTempOrder);
4877
+ return _context40.abrupt("return", nextTempOrder);
4743
4878
  case 21:
4744
4879
  case "end":
4745
- return _context39.stop();
4880
+ return _context40.stop();
4746
4881
  }
4747
- }, _callee37, this);
4882
+ }, _callee38, this);
4748
4883
  }));
4749
4884
  function hydrateTempOrderFromRecord(_x42, _x43) {
4750
4885
  return _hydrateTempOrderFromRecord.apply(this, arguments);
@@ -4754,7 +4889,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4754
4889
  }, {
4755
4890
  key: "normalizeTempOrderForRuntime",
4756
4891
  value: function normalizeTempOrderForRuntime(raw, options) {
4757
- var _this19 = this;
4892
+ var _this20 = this;
4758
4893
  var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), raw || {});
4759
4894
  delete nextTempOrder.summary;
4760
4895
  delete nextTempOrder.lastOrderInfo;
@@ -4773,7 +4908,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4773
4908
  nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
4774
4909
  var rawProducts = Array.isArray(raw.products) ? raw.products : [];
4775
4910
  nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
4776
- return _this19.normalizeHydratedOrderProduct(p);
4911
+ return _this20.normalizeHydratedOrderProduct(p);
4777
4912
  }) : [];
4778
4913
  nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
4779
4914
  return _objectSpread(_objectSpread({}, b || {}), {}, {
@@ -4901,7 +5036,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4901
5036
  }, {
4902
5037
  key: "normalizeHydratedOrderProduct",
4903
5038
  value: function normalizeHydratedOrderProduct(product) {
4904
- var _this20 = this;
5039
+ var _this21 = this;
4905
5040
  var row = _objectSpread({}, product || {});
4906
5041
  if (row.num === undefined && row.product_quantity !== undefined) {
4907
5042
  row.num = row.product_quantity;
@@ -4909,7 +5044,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4909
5044
  var productSku = ensureProductSku(row);
4910
5045
  row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
4911
5046
  option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
4912
- return _this20.normalizeHydratedProductOptionItem(optionItem || {});
5047
+ return _this21.normalizeHydratedProductOptionItem(optionItem || {});
4913
5048
  }))
4914
5049
  });
4915
5050
  delete row["product_".concat('option', "_item")];
@@ -4934,29 +5069,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4934
5069
  }, {
4935
5070
  key: "getLastOrderInfo",
4936
5071
  value: function getLastOrderInfo() {
4937
- var _this$store;
4938
- return (_this$store = this.store) === null || _this$store === void 0 ? void 0 : _this$store.lastOrderInfo;
5072
+ var _this$store3;
5073
+ return (_this$store3 = this.store) === null || _this$store3 === void 0 ? void 0 : _this$store3.lastOrderInfo;
4939
5074
  }
4940
5075
  }, {
4941
5076
  key: "getOrderInfo",
4942
5077
  value: function () {
4943
- var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(order_id) {
5078
+ var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(order_id) {
4944
5079
  var res;
4945
- return _regeneratorRuntime().wrap(function _callee38$(_context40) {
4946
- while (1) switch (_context40.prev = _context40.next) {
5080
+ return _regeneratorRuntime().wrap(function _callee39$(_context41) {
5081
+ while (1) switch (_context41.prev = _context41.next) {
4947
5082
  case 0:
4948
- _context40.next = 2;
5083
+ _context41.next = 2;
4949
5084
  return this.request.get("/order/sales/".concat(order_id), {
4950
5085
  with: ['products', 'bookings']
4951
5086
  });
4952
5087
  case 2:
4953
- res = _context40.sent;
4954
- return _context40.abrupt("return", res);
5088
+ res = _context41.sent;
5089
+ return _context41.abrupt("return", res);
4955
5090
  case 4:
4956
5091
  case "end":
4957
- return _context40.stop();
5092
+ return _context41.stop();
4958
5093
  }
4959
- }, _callee38, this);
5094
+ }, _callee39, this);
4960
5095
  }));
4961
5096
  function getOrderInfo(_x44) {
4962
5097
  return _getOrderInfo.apply(this, arguments);