@pisell/pisellos 2.3.101 → 2.3.103
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +287 -101
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +25 -0
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +10 -7
- package/dist/modules/Discount/index.d.ts +2 -0
- package/dist/modules/Discount/index.js +38 -5
- package/dist/modules/Discount/types.d.ts +11 -0
- package/dist/modules/Order/index.d.ts +29 -3
- package/dist/modules/Order/index.js +1105 -703
- package/dist/modules/Order/types.d.ts +14 -6
- package/dist/modules/Order/types.js +1 -1
- package/dist/modules/Order/utils/virtualSettlement.d.ts +63 -0
- package/dist/modules/Order/utils/virtualSettlement.js +284 -0
- package/dist/modules/Order/utils.d.ts +1 -0
- package/dist/modules/Order/utils.js +63 -24
- package/dist/modules/Product/types.d.ts +23 -0
- package/dist/modules/SalesSummary/index.d.ts +1 -0
- package/dist/modules/SalesSummary/index.js +4 -3
- package/dist/modules/SalesSummary/types.d.ts +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +1 -0
- package/dist/modules/SalesSummary/utils.js +21 -1
- package/dist/solution/BaseSales/index.d.ts +10 -1
- package/dist/solution/BaseSales/index.js +1074 -746
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +72 -9
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingTicket/utils/addProductDecision.js +2 -1
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +137 -6
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +25 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +4 -0
- package/lib/modules/Discount/index.d.ts +2 -0
- package/lib/modules/Discount/index.js +31 -2
- package/lib/modules/Discount/types.d.ts +11 -0
- package/lib/modules/Order/index.d.ts +29 -3
- package/lib/modules/Order/index.js +326 -51
- package/lib/modules/Order/types.d.ts +14 -6
- package/lib/modules/Order/types.js +1 -1
- package/lib/modules/Order/utils/virtualSettlement.d.ts +63 -0
- package/lib/modules/Order/utils/virtualSettlement.js +262 -0
- package/lib/modules/Order/utils.d.ts +1 -0
- package/lib/modules/Order/utils.js +57 -20
- package/lib/modules/Product/types.d.ts +23 -0
- package/lib/modules/SalesSummary/index.d.ts +1 -0
- package/lib/modules/SalesSummary/index.js +4 -2
- package/lib/modules/SalesSummary/types.d.ts +1 -0
- package/lib/modules/SalesSummary/utils.d.ts +1 -0
- package/lib/modules/SalesSummary/utils.js +17 -1
- package/lib/solution/BaseSales/index.d.ts +10 -1
- package/lib/solution/BaseSales/index.js +228 -20
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +38 -0
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingTicket/utils/addProductDecision.js +1 -0
- package/package.json +1 -1
|
@@ -44,6 +44,7 @@ import { hasManualProductDiscountFlag, syncManualProductDiscountProductNum } fro
|
|
|
44
44
|
import { expandHydratedProductsForDiscountCollection, restoreHydratedBundleDiscounts } from "./utils/bundleDiscountHydration";
|
|
45
45
|
import { getOrderCollectionPersistentId, getOrderCollectionUid, normalizeOrderCollections, repairDuplicateProductLineIdentities as repairDuplicateOrderProductLineIdentities, setOrderCollectionUid } from "./utils/orderCollectionIdentity";
|
|
46
46
|
import { consolidateDiscountFreeProductLines, ensureUniqueProductLineUids } from "./utils/discountProductLineIdentity";
|
|
47
|
+
import { applyTempOrderSettlementState, getSelectedSettlementSnapshot, getSettlementKey, getTempOrderSettlementKey, getTempOrderSettlementSnapshot, isVirtualSettlementOrder, normalizeVirtualSettlementOrderProduct, normalizeVirtualSettlementProducts, OrderSettlementConflictError, releaseTempOrderSettlementState, VirtualCurrencyAssetNotFoundError, VirtualCurrencyBalanceError } from "./utils/virtualSettlement";
|
|
47
48
|
import { DiscountModule } from "../Discount";
|
|
48
49
|
import { RulesModule } from "../Rules";
|
|
49
50
|
import { UnavailableReason } from "../Rules/types";
|
|
@@ -136,8 +137,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
136
137
|
_defineProperty(_assertThisInitialized(_this), "promotionEvaluator", null);
|
|
137
138
|
/** 赠品选择 resolver;由 SDK host bridge 注入 */
|
|
138
139
|
_defineProperty(_assertThisInitialized(_this), "giftSelectResolver", null);
|
|
139
|
-
/**
|
|
140
|
+
/** 促销评估递归保护 flag(写路径同步评估促销,禁止重入) */
|
|
140
141
|
_defineProperty(_assertThisInitialized(_this), "isApplyingPromotion", false);
|
|
142
|
+
/** 保持旧事件语义:同步事件监听器内触发的订单写入不得递归评估促销。 */
|
|
143
|
+
_defineProperty(_assertThisInitialized(_this), "isEmittingPromotionApplied", false);
|
|
141
144
|
/** 商品曾应用过客户券卡,客户变更剥离后需强制跑一次 calcDiscount 复位价格 */
|
|
142
145
|
_defineProperty(_assertThisInitialized(_this), "hasActiveCustomerBoundDiscount", false);
|
|
143
146
|
/** 最近一次 applyPromotion 的未满足促销提示 */
|
|
@@ -340,6 +343,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
340
343
|
this.store.tempOrder = null;
|
|
341
344
|
this.store.summary = createEmptySummary();
|
|
342
345
|
this.store.availableWalletIds = [];
|
|
346
|
+
this.store.virtualCurrencyList = [];
|
|
343
347
|
this.store.lastOrderInfo = undefined;
|
|
344
348
|
this.store.syncState = undefined;
|
|
345
349
|
this.store.discountList = [];
|
|
@@ -352,6 +356,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
352
356
|
if (!Array.isArray(this.store.availableWalletIds)) {
|
|
353
357
|
this.store.availableWalletIds = [];
|
|
354
358
|
}
|
|
359
|
+
if (!Array.isArray(this.store.virtualCurrencyList)) {
|
|
360
|
+
this.store.virtualCurrencyList = [];
|
|
361
|
+
}
|
|
355
362
|
this.request = this.core.getPlugin('request');
|
|
356
363
|
appPlugin = this.core.getPlugin('app');
|
|
357
364
|
if (!appPlugin) {
|
|
@@ -367,7 +374,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
367
374
|
this.otherParams = otherParams;
|
|
368
375
|
this.registerDiscountModules(options);
|
|
369
376
|
this.logInfo('OrderModule initialized successfully');
|
|
370
|
-
case
|
|
377
|
+
case 21:
|
|
371
378
|
case "end":
|
|
372
379
|
return _context.stop();
|
|
373
380
|
}
|
|
@@ -455,6 +462,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
455
462
|
this.otherParams = otherParams;
|
|
456
463
|
}
|
|
457
464
|
|
|
465
|
+
/** PC/H5 属于在线店铺;其它或缺失平台统一沿用 POS 行为。 */
|
|
466
|
+
}, {
|
|
467
|
+
key: "isOnlineStorePlatform",
|
|
468
|
+
value: function isOnlineStorePlatform() {
|
|
469
|
+
var _this$otherParams;
|
|
470
|
+
var platform = String(((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.platform) || '').trim().toLowerCase();
|
|
471
|
+
return platform === 'pc' || platform === 'h5';
|
|
472
|
+
}
|
|
473
|
+
|
|
458
474
|
/**
|
|
459
475
|
* 记录信息日志
|
|
460
476
|
*/
|
|
@@ -560,6 +576,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
560
576
|
with_wallet_pass_holder: 1,
|
|
561
577
|
with_available_wallet_flag: 1,
|
|
562
578
|
with_available_wallet_pass_flag: 1,
|
|
579
|
+
with_virtual_currency: 1,
|
|
563
580
|
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
564
581
|
}, orderId ? {
|
|
565
582
|
order_id: orderId
|
|
@@ -568,8 +585,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
568
585
|
prepareConfigResult = _context3.sent;
|
|
569
586
|
discountList = prepareConfigResult === null || prepareConfigResult === void 0 ? void 0 : prepareConfigResult.discountList;
|
|
570
587
|
this.store.availableWalletIds = (prepareConfigResult === null || prepareConfigResult === void 0 ? void 0 : prepareConfigResult.availableWalletIds) || [];
|
|
588
|
+
this.store.virtualCurrencyList = (prepareConfigResult === null || prepareConfigResult === void 0 ? void 0 : prepareConfigResult.virtualCurrencyList) || [];
|
|
571
589
|
if (!discountList) {
|
|
572
|
-
_context3.next =
|
|
590
|
+
_context3.next = 19;
|
|
573
591
|
break;
|
|
574
592
|
}
|
|
575
593
|
currentDiscountList = ((_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 ? void 0 : _this$store$discount2.getDiscountList()) || [];
|
|
@@ -590,17 +608,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
590
608
|
return true;
|
|
591
609
|
});
|
|
592
610
|
mergedDiscountList = [].concat(_toConsumableArray(currentEditDiscounts), _toConsumableArray(currentScanDiscounts), _toConsumableArray(runtimeDiscounts));
|
|
593
|
-
_context3.next =
|
|
611
|
+
_context3.next = 17;
|
|
594
612
|
return (_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.setOriginalDiscountList(mergedDiscountList);
|
|
595
|
-
case
|
|
596
|
-
_context3.next =
|
|
613
|
+
case 17:
|
|
614
|
+
_context3.next = 19;
|
|
597
615
|
return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.setDiscountList(mergedDiscountList);
|
|
598
|
-
case
|
|
616
|
+
case 19:
|
|
599
617
|
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) {
|
|
600
618
|
this.applyDiscount();
|
|
601
619
|
}
|
|
602
620
|
return _context3.abrupt("return", this.getDiscountList());
|
|
603
|
-
case
|
|
621
|
+
case 21:
|
|
604
622
|
case "end":
|
|
605
623
|
return _context3.stop();
|
|
606
624
|
}
|
|
@@ -622,6 +640,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
622
640
|
value: function getAvailableWalletIds() {
|
|
623
641
|
return Array.isArray(this.store.availableWalletIds) ? _toConsumableArray(this.store.availableWalletIds) : [];
|
|
624
642
|
}
|
|
643
|
+
}, {
|
|
644
|
+
key: "getVirtualCurrencyList",
|
|
645
|
+
value: function getVirtualCurrencyList() {
|
|
646
|
+
return cloneDeep(this.store.virtualCurrencyList || []);
|
|
647
|
+
}
|
|
625
648
|
}, {
|
|
626
649
|
key: "syncScannedDiscountsToOriginalDiscountList",
|
|
627
650
|
value: function () {
|
|
@@ -714,26 +737,39 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
714
737
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
715
738
|
while (1) switch (_context6.prev = _context6.next) {
|
|
716
739
|
case 0:
|
|
717
|
-
|
|
740
|
+
if (!this.isActiveVirtualSettlementOrder(this.store.tempOrder)) {
|
|
741
|
+
_context6.next = 2;
|
|
742
|
+
break;
|
|
743
|
+
}
|
|
744
|
+
return _context6.abrupt("return", {
|
|
745
|
+
type: 'clientCalc',
|
|
746
|
+
isAvailable: false,
|
|
747
|
+
isAccepted: false,
|
|
748
|
+
discountList: [],
|
|
749
|
+
scannedDiscountList: [],
|
|
750
|
+
unavailableReason: UnavailableReason.ProductNotApplicable
|
|
751
|
+
});
|
|
752
|
+
case 2:
|
|
753
|
+
_context6.next = 4;
|
|
718
754
|
return (_this$store$discount11 = this.store.discount) === null || _this$store$discount11 === void 0 ? void 0 : _this$store$discount11.batchSearch(code, {
|
|
719
755
|
customerId: customerId
|
|
720
756
|
});
|
|
721
|
-
case
|
|
757
|
+
case 4:
|
|
722
758
|
_context6.t0 = _context6.sent;
|
|
723
759
|
if (_context6.t0) {
|
|
724
|
-
_context6.next =
|
|
760
|
+
_context6.next = 7;
|
|
725
761
|
break;
|
|
726
762
|
}
|
|
727
763
|
_context6.t0 = {
|
|
728
764
|
discountList: [],
|
|
729
765
|
unavailableReasonKey: null
|
|
730
766
|
};
|
|
731
|
-
case
|
|
767
|
+
case 7:
|
|
732
768
|
resultDiscountWithReason = _context6.t0;
|
|
733
769
|
resultDiscountList = resultDiscountWithReason.discountList, unavailableReasonKey = resultDiscountWithReason.unavailableReasonKey;
|
|
734
770
|
rulesModule = this.store.rules;
|
|
735
771
|
if (rulesModule) {
|
|
736
|
-
_context6.next =
|
|
772
|
+
_context6.next = 12;
|
|
737
773
|
break;
|
|
738
774
|
}
|
|
739
775
|
return _context6.abrupt("return", {
|
|
@@ -744,9 +780,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
744
780
|
scannedDiscountList: resultDiscountList,
|
|
745
781
|
unavailableReason: UnavailableReason.Unknown
|
|
746
782
|
});
|
|
747
|
-
case
|
|
783
|
+
case 12:
|
|
748
784
|
if (resultDiscountList.length) {
|
|
749
|
-
_context6.next =
|
|
785
|
+
_context6.next = 14;
|
|
750
786
|
break;
|
|
751
787
|
}
|
|
752
788
|
return _context6.abrupt("return", {
|
|
@@ -757,7 +793,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
757
793
|
scannedDiscountList: resultDiscountList,
|
|
758
794
|
unavailableReasonKey: unavailableReasonKey
|
|
759
795
|
});
|
|
760
|
-
case
|
|
796
|
+
case 14:
|
|
761
797
|
withScanList = resultDiscountList.map(function (item) {
|
|
762
798
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
763
799
|
isScan: true
|
|
@@ -771,12 +807,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
771
807
|
return m.id === n.id;
|
|
772
808
|
});
|
|
773
809
|
}))) {
|
|
774
|
-
_context6.next =
|
|
810
|
+
_context6.next = 20;
|
|
775
811
|
break;
|
|
776
812
|
}
|
|
777
|
-
_context6.next =
|
|
813
|
+
_context6.next = 19;
|
|
778
814
|
return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
779
|
-
case
|
|
815
|
+
case 19:
|
|
780
816
|
return _context6.abrupt("return", {
|
|
781
817
|
type: 'clientCalc',
|
|
782
818
|
isAvailable: true,
|
|
@@ -784,7 +820,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
784
820
|
discountList: this.getDiscountList(),
|
|
785
821
|
scannedDiscountList: resultDiscountList
|
|
786
822
|
});
|
|
787
|
-
case
|
|
823
|
+
case 20:
|
|
788
824
|
tempOrder = this.store.tempOrder;
|
|
789
825
|
holders = (tempOrder === null || tempOrder === void 0 || (_tempOrder$holder = tempOrder.holder) === null || _tempOrder$holder === void 0 ? void 0 : _tempOrder$holder.form_record) || [];
|
|
790
826
|
_ref12 = rulesModule.isDiscountListAvailable({
|
|
@@ -805,32 +841,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
805
841
|
retainedDiscountList = evaluatedDiscountList ? markScannedDiscounts(evaluatedDiscountList, withScanList) : normalizedNewDiscountList;
|
|
806
842
|
resolvedDiscountList = normalizedNewDiscountList || this.getDiscountList();
|
|
807
843
|
if (!(isAvailable && normalizedNewDiscountList)) {
|
|
808
|
-
_context6.next =
|
|
844
|
+
_context6.next = 36;
|
|
809
845
|
break;
|
|
810
846
|
}
|
|
811
|
-
_context6.next =
|
|
847
|
+
_context6.next = 30;
|
|
812
848
|
return (_this$store$discount12 = this.store.discount) === null || _this$store$discount12 === void 0 ? void 0 : _this$store$discount12.setDiscountList(normalizedNewDiscountList);
|
|
813
|
-
case
|
|
849
|
+
case 30:
|
|
814
850
|
this.applyDiscount();
|
|
815
|
-
_context6.next =
|
|
851
|
+
_context6.next = 33;
|
|
816
852
|
return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
817
|
-
case
|
|
853
|
+
case 33:
|
|
818
854
|
resolvedDiscountList = this.getDiscountList();
|
|
819
|
-
_context6.next =
|
|
855
|
+
_context6.next = 42;
|
|
820
856
|
break;
|
|
821
|
-
case
|
|
857
|
+
case 36:
|
|
822
858
|
if (!(shouldRetainForLater && retainedDiscountList)) {
|
|
823
|
-
_context6.next =
|
|
859
|
+
_context6.next = 42;
|
|
824
860
|
break;
|
|
825
861
|
}
|
|
826
|
-
_context6.next = 37;
|
|
827
|
-
return (_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.setDiscountList(retainedDiscountList);
|
|
828
|
-
case 37:
|
|
829
862
|
_context6.next = 39;
|
|
830
|
-
return
|
|
863
|
+
return (_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.setDiscountList(retainedDiscountList);
|
|
831
864
|
case 39:
|
|
865
|
+
_context6.next = 41;
|
|
866
|
+
return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
867
|
+
case 41:
|
|
832
868
|
resolvedDiscountList = this.getDiscountList();
|
|
833
|
-
case
|
|
869
|
+
case 42:
|
|
834
870
|
return _context6.abrupt("return", {
|
|
835
871
|
type: 'clientCalc',
|
|
836
872
|
isAvailable: isAvailable || false,
|
|
@@ -839,7 +875,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
839
875
|
scannedDiscountList: resultDiscountList,
|
|
840
876
|
unavailableReason: unavailableReason
|
|
841
877
|
});
|
|
842
|
-
case
|
|
878
|
+
case 43:
|
|
843
879
|
case "end":
|
|
844
880
|
return _context6.stop();
|
|
845
881
|
}
|
|
@@ -853,7 +889,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
853
889
|
}, {
|
|
854
890
|
key: "applyDiscount",
|
|
855
891
|
value: function applyDiscount(options) {
|
|
856
|
-
var _this$store$
|
|
892
|
+
var _this$store$discount16,
|
|
857
893
|
_this$store$summary2,
|
|
858
894
|
_this2 = this;
|
|
859
895
|
var tempOrder = this.store.tempOrder;
|
|
@@ -861,9 +897,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
861
897
|
// 也需要让 Rules.calcDiscount 把 DiscountModule 的 isSelected / isAvailable /
|
|
862
898
|
// appliedProductDetails / savedAmount 复位。
|
|
863
899
|
if (!tempOrder) return;
|
|
900
|
+
if (this.isActiveVirtualSettlementOrder(tempOrder)) {
|
|
901
|
+
var _this$store$discount14, _this$store$discount15;
|
|
902
|
+
tempOrder.products = normalizeVirtualSettlementProducts(tempOrder.products);
|
|
903
|
+
tempOrder.discount_list = [];
|
|
904
|
+
tempOrder.shop_discount = '0.00';
|
|
905
|
+
void ((_this$store$discount14 = this.store.discount) === null || _this$store$discount14 === void 0 ? void 0 : _this$store$discount14.setDiscountList([]));
|
|
906
|
+
void ((_this$store$discount15 = this.store.discount) === null || _this$store$discount15 === void 0 ? void 0 : _this$store$discount15.setOriginalDiscountList([]));
|
|
907
|
+
return;
|
|
908
|
+
}
|
|
864
909
|
this.syncLinkedBookingHoldersToProducts(tempOrder);
|
|
865
910
|
delete tempOrder.discount_list;
|
|
866
|
-
var discountList = ((_this$store$
|
|
911
|
+
var discountList = ((_this$store$discount16 = this.store.discount) === null || _this$store$discount16 === void 0 ? void 0 : _this$store$discount16.getDiscountList()) || [];
|
|
867
912
|
var shouldSkipDiscountCalculation = this.shouldSkipDiscountCalculation(tempOrder);
|
|
868
913
|
if (shouldSkipDiscountCalculation) return;
|
|
869
914
|
var rulesModule = this.store.rules;
|
|
@@ -897,9 +942,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
897
942
|
consolidateDiscountFreeProductLines(tempOrder);
|
|
898
943
|
}
|
|
899
944
|
if (result !== null && result !== void 0 && result.discountList) {
|
|
900
|
-
var _this$store$
|
|
945
|
+
var _this$store$discount17;
|
|
901
946
|
OrderModule.populateSavedAmounts(result.productList || tempOrder.products, result.discountList);
|
|
902
|
-
(_this$store$
|
|
947
|
+
(_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 || _this$store$discount17.setDiscountList(result.discountList);
|
|
903
948
|
}
|
|
904
949
|
this.hasActiveCustomerBoundDiscount = (tempOrder.products || []).some(function (product) {
|
|
905
950
|
return _this2.productHasCustomerBoundDiscount(product);
|
|
@@ -948,7 +993,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
948
993
|
}
|
|
949
994
|
|
|
950
995
|
/**
|
|
951
|
-
*
|
|
996
|
+
* 只执行购物车促销评估与赠品写回,不发布稳定态事件。
|
|
952
997
|
*
|
|
953
998
|
* 调用时机:写路径(add/update/remove/clear/setCustomer)末尾自动触发;外部一般无需手动调。
|
|
954
999
|
*
|
|
@@ -956,12 +1001,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
956
1001
|
* - 不调用任何公开 CRUD API(如 removeProductFromOrder),全部内部 mutate tempOrder.products,避免事件风暴;
|
|
957
1002
|
* - 用 `isApplyingPromotion` 防递归;
|
|
958
1003
|
* - 多选项赠品依赖 giftSelectResolver,未注入则跳过且 console.warn;
|
|
959
|
-
* - 不主动调用 applyDiscount / recalculateSummary
|
|
1004
|
+
* - 不主动调用 applyDiscount / recalculateSummary,调用方负责跟进;
|
|
1005
|
+
* - 返回的 payload 只能在 applyDiscount(商品写路径还需 summary/persist)完成后发布。
|
|
960
1006
|
*/
|
|
961
1007
|
}, {
|
|
962
|
-
key: "
|
|
1008
|
+
key: "evaluatePromotion",
|
|
963
1009
|
value: (function () {
|
|
964
|
-
var
|
|
1010
|
+
var _evaluatePromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
965
1011
|
var _this$promotionEvalua,
|
|
966
1012
|
_this$promotionEvalua2,
|
|
967
1013
|
_this3 = this;
|
|
@@ -969,34 +1015,41 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
969
1015
|
return _regeneratorRuntime().wrap(function _callee7$(_context9) {
|
|
970
1016
|
while (1) switch (_context9.prev = _context9.next) {
|
|
971
1017
|
case 0:
|
|
972
|
-
if (!this.isApplyingPromotion) {
|
|
1018
|
+
if (!(this.isApplyingPromotion || this.isEmittingPromotionApplied)) {
|
|
973
1019
|
_context9.next = 2;
|
|
974
1020
|
break;
|
|
975
1021
|
}
|
|
976
|
-
return _context9.abrupt("return");
|
|
1022
|
+
return _context9.abrupt("return", null);
|
|
977
1023
|
case 2:
|
|
978
1024
|
if (this.promotionEvaluator) {
|
|
979
1025
|
_context9.next = 4;
|
|
980
1026
|
break;
|
|
981
1027
|
}
|
|
982
|
-
return _context9.abrupt("return");
|
|
1028
|
+
return _context9.abrupt("return", null);
|
|
983
1029
|
case 4:
|
|
984
1030
|
tempOrder = this.store.tempOrder;
|
|
985
1031
|
if (tempOrder) {
|
|
986
1032
|
_context9.next = 7;
|
|
987
1033
|
break;
|
|
988
1034
|
}
|
|
989
|
-
return _context9.abrupt("return");
|
|
1035
|
+
return _context9.abrupt("return", null);
|
|
990
1036
|
case 7:
|
|
991
|
-
|
|
992
|
-
if (!(Array.isArray(strategyConfigs) && strategyConfigs.length === 0)) {
|
|
1037
|
+
if (!this.isActiveVirtualSettlementOrder(tempOrder)) {
|
|
993
1038
|
_context9.next = 10;
|
|
994
1039
|
break;
|
|
995
1040
|
}
|
|
996
|
-
|
|
1041
|
+
tempOrder.products = normalizeVirtualSettlementProducts(tempOrder.products);
|
|
1042
|
+
return _context9.abrupt("return", null);
|
|
997
1043
|
case 10:
|
|
1044
|
+
strategyConfigs = (_this$promotionEvalua = (_this$promotionEvalua2 = this.promotionEvaluator).getStrategyConfigs) === null || _this$promotionEvalua === void 0 ? void 0 : _this$promotionEvalua.call(_this$promotionEvalua2);
|
|
1045
|
+
if (!(Array.isArray(strategyConfigs) && strategyConfigs.length === 0)) {
|
|
1046
|
+
_context9.next = 13;
|
|
1047
|
+
break;
|
|
1048
|
+
}
|
|
1049
|
+
return _context9.abrupt("return", null);
|
|
1050
|
+
case 13:
|
|
998
1051
|
this.isApplyingPromotion = true;
|
|
999
|
-
_context9.prev =
|
|
1052
|
+
_context9.prev = 14;
|
|
1000
1053
|
result = processCartPromotion(tempOrder.products, this.promotionEvaluator); // step 1: toRemove —— 直接过滤
|
|
1001
1054
|
if (result.giftActions.toRemove.length > 0) {
|
|
1002
1055
|
removeSet = new Set(result.giftActions.toRemove.map(String));
|
|
@@ -1008,16 +1061,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1008
1061
|
|
|
1009
1062
|
// step 2: toReduce —— 调整数量
|
|
1010
1063
|
_iterator3 = _createForOfIteratorHelper(result.giftActions.toReduce);
|
|
1011
|
-
_context9.prev =
|
|
1064
|
+
_context9.prev = 18;
|
|
1012
1065
|
_iterator3.s();
|
|
1013
|
-
case
|
|
1066
|
+
case 20:
|
|
1014
1067
|
if ((_step3 = _iterator3.n()).done) {
|
|
1015
|
-
_context9.next =
|
|
1068
|
+
_context9.next = 40;
|
|
1016
1069
|
break;
|
|
1017
1070
|
}
|
|
1018
1071
|
reduce = _step3.value;
|
|
1019
1072
|
_iterator6 = _createForOfIteratorHelper(reduce.items);
|
|
1020
|
-
_context9.prev =
|
|
1073
|
+
_context9.prev = 23;
|
|
1021
1074
|
_loop2 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop2() {
|
|
1022
1075
|
var item, product;
|
|
1023
1076
|
return _regeneratorRuntime().wrap(function _loop2$(_context8) {
|
|
@@ -1037,47 +1090,47 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1037
1090
|
}, _loop2);
|
|
1038
1091
|
});
|
|
1039
1092
|
_iterator6.s();
|
|
1040
|
-
case
|
|
1093
|
+
case 26:
|
|
1041
1094
|
if ((_step6 = _iterator6.n()).done) {
|
|
1042
|
-
_context9.next =
|
|
1095
|
+
_context9.next = 30;
|
|
1043
1096
|
break;
|
|
1044
1097
|
}
|
|
1045
|
-
return _context9.delegateYield(_loop2(), "t0",
|
|
1046
|
-
case
|
|
1047
|
-
_context9.next =
|
|
1098
|
+
return _context9.delegateYield(_loop2(), "t0", 28);
|
|
1099
|
+
case 28:
|
|
1100
|
+
_context9.next = 26;
|
|
1048
1101
|
break;
|
|
1049
|
-
case
|
|
1050
|
-
_context9.next =
|
|
1102
|
+
case 30:
|
|
1103
|
+
_context9.next = 35;
|
|
1051
1104
|
break;
|
|
1052
|
-
case 29:
|
|
1053
|
-
_context9.prev = 29;
|
|
1054
|
-
_context9.t1 = _context9["catch"](20);
|
|
1055
|
-
_iterator6.e(_context9.t1);
|
|
1056
1105
|
case 32:
|
|
1057
1106
|
_context9.prev = 32;
|
|
1058
|
-
|
|
1059
|
-
|
|
1107
|
+
_context9.t1 = _context9["catch"](23);
|
|
1108
|
+
_iterator6.e(_context9.t1);
|
|
1060
1109
|
case 35:
|
|
1061
|
-
_context9.
|
|
1110
|
+
_context9.prev = 35;
|
|
1111
|
+
_iterator6.f();
|
|
1112
|
+
return _context9.finish(35);
|
|
1113
|
+
case 38:
|
|
1114
|
+
_context9.next = 20;
|
|
1062
1115
|
break;
|
|
1063
|
-
case
|
|
1064
|
-
_context9.next =
|
|
1116
|
+
case 40:
|
|
1117
|
+
_context9.next = 45;
|
|
1065
1118
|
break;
|
|
1066
|
-
case 39:
|
|
1067
|
-
_context9.prev = 39;
|
|
1068
|
-
_context9.t2 = _context9["catch"](15);
|
|
1069
|
-
_iterator3.e(_context9.t2);
|
|
1070
1119
|
case 42:
|
|
1071
1120
|
_context9.prev = 42;
|
|
1072
|
-
|
|
1073
|
-
|
|
1121
|
+
_context9.t2 = _context9["catch"](18);
|
|
1122
|
+
_iterator3.e(_context9.t2);
|
|
1074
1123
|
case 45:
|
|
1124
|
+
_context9.prev = 45;
|
|
1125
|
+
_iterator3.f();
|
|
1126
|
+
return _context9.finish(45);
|
|
1127
|
+
case 48:
|
|
1075
1128
|
if (!(result.giftActions.toAdd.length > 0)) {
|
|
1076
|
-
_context9.next =
|
|
1129
|
+
_context9.next = 71;
|
|
1077
1130
|
break;
|
|
1078
1131
|
}
|
|
1079
1132
|
if (this.giftSelectResolver) {
|
|
1080
|
-
_context9.next =
|
|
1133
|
+
_context9.next = 53;
|
|
1081
1134
|
break;
|
|
1082
1135
|
}
|
|
1083
1136
|
if (result.giftActions.toAdd.some(function (g) {
|
|
@@ -1088,11 +1141,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1088
1141
|
} else {
|
|
1089
1142
|
console.warn('[OrderModule] giftSelectResolver not set, skip applying single-option gifts', result.giftActions.toAdd);
|
|
1090
1143
|
}
|
|
1091
|
-
_context9.next =
|
|
1144
|
+
_context9.next = 71;
|
|
1092
1145
|
break;
|
|
1093
|
-
case
|
|
1146
|
+
case 53:
|
|
1094
1147
|
_iterator4 = _createForOfIteratorHelper(result.giftActions.toAdd);
|
|
1095
|
-
_context9.prev =
|
|
1148
|
+
_context9.prev = 54;
|
|
1096
1149
|
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
1097
1150
|
var addAction, _sameStrategy$metadat, sameStrategy, giftResult, giftProducts, giftBookings, _iterator5, _step5, _step5$value, index, gp, booking, linked;
|
|
1098
1151
|
return _regeneratorRuntime().wrap(function _loop$(_context7) {
|
|
@@ -1190,33 +1243,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1190
1243
|
}, _loop, null, [[6, 39], [14, 31, 34, 37]]);
|
|
1191
1244
|
});
|
|
1192
1245
|
_iterator4.s();
|
|
1193
|
-
case
|
|
1246
|
+
case 57:
|
|
1194
1247
|
if ((_step4 = _iterator4.n()).done) {
|
|
1195
|
-
_context9.next =
|
|
1248
|
+
_context9.next = 63;
|
|
1196
1249
|
break;
|
|
1197
1250
|
}
|
|
1198
|
-
return _context9.delegateYield(_loop(), "t3",
|
|
1199
|
-
case
|
|
1251
|
+
return _context9.delegateYield(_loop(), "t3", 59);
|
|
1252
|
+
case 59:
|
|
1200
1253
|
if (!_context9.t3) {
|
|
1201
|
-
_context9.next =
|
|
1254
|
+
_context9.next = 61;
|
|
1202
1255
|
break;
|
|
1203
1256
|
}
|
|
1204
|
-
return _context9.abrupt("continue",
|
|
1205
|
-
case
|
|
1206
|
-
_context9.next =
|
|
1257
|
+
return _context9.abrupt("continue", 61);
|
|
1258
|
+
case 61:
|
|
1259
|
+
_context9.next = 57;
|
|
1207
1260
|
break;
|
|
1208
|
-
case
|
|
1209
|
-
_context9.next =
|
|
1261
|
+
case 63:
|
|
1262
|
+
_context9.next = 68;
|
|
1210
1263
|
break;
|
|
1211
|
-
case 62:
|
|
1212
|
-
_context9.prev = 62;
|
|
1213
|
-
_context9.t4 = _context9["catch"](51);
|
|
1214
|
-
_iterator4.e(_context9.t4);
|
|
1215
1264
|
case 65:
|
|
1216
1265
|
_context9.prev = 65;
|
|
1217
|
-
|
|
1218
|
-
|
|
1266
|
+
_context9.t4 = _context9["catch"](54);
|
|
1267
|
+
_iterator4.e(_context9.t4);
|
|
1219
1268
|
case 68:
|
|
1269
|
+
_context9.prev = 68;
|
|
1270
|
+
_iterator4.f();
|
|
1271
|
+
return _context9.finish(68);
|
|
1272
|
+
case 71:
|
|
1220
1273
|
tempOrder.products = result.products;
|
|
1221
1274
|
this.lastUnfulfilledPromotions = result.unfulfilledPromotions;
|
|
1222
1275
|
this.lastGiftActions = result.giftActions;
|
|
@@ -1233,22 +1286,84 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1233
1286
|
}),
|
|
1234
1287
|
products: tempOrder.products
|
|
1235
1288
|
};
|
|
1236
|
-
|
|
1237
|
-
_context9.next = 78;
|
|
1238
|
-
break;
|
|
1239
|
-
case 75:
|
|
1240
|
-
_context9.prev = 75;
|
|
1241
|
-
_context9.t5 = _context9["catch"](11);
|
|
1242
|
-
console.error('[OrderModule] applyPromotion failed', _context9.t5);
|
|
1289
|
+
return _context9.abrupt("return", payload);
|
|
1243
1290
|
case 78:
|
|
1244
1291
|
_context9.prev = 78;
|
|
1292
|
+
_context9.t5 = _context9["catch"](14);
|
|
1293
|
+
console.error('[OrderModule] applyPromotion failed', _context9.t5);
|
|
1294
|
+
return _context9.abrupt("return", null);
|
|
1295
|
+
case 82:
|
|
1296
|
+
_context9.prev = 82;
|
|
1245
1297
|
this.isApplyingPromotion = false;
|
|
1246
|
-
return _context9.finish(
|
|
1247
|
-
case
|
|
1298
|
+
return _context9.finish(82);
|
|
1299
|
+
case 85:
|
|
1248
1300
|
case "end":
|
|
1249
1301
|
return _context9.stop();
|
|
1250
1302
|
}
|
|
1251
|
-
}, _callee7, this, [[
|
|
1303
|
+
}, _callee7, this, [[14, 78, 82, 85], [18, 42, 45, 48], [23, 32, 35, 38], [54, 65, 68, 71]]);
|
|
1304
|
+
}));
|
|
1305
|
+
function evaluatePromotion() {
|
|
1306
|
+
return _evaluatePromotion.apply(this, arguments);
|
|
1307
|
+
}
|
|
1308
|
+
return evaluatePromotion;
|
|
1309
|
+
}() /** 发布促销稳定态;products 必须读取折扣计算后的当前数组。 */)
|
|
1310
|
+
}, {
|
|
1311
|
+
key: "emitPromotionApplied",
|
|
1312
|
+
value: function emitPromotionApplied(payload) {
|
|
1313
|
+
var _this$store$tempOrder3;
|
|
1314
|
+
if (!payload) return;
|
|
1315
|
+
var products = ((_this$store$tempOrder3 = this.store.tempOrder) === null || _this$store$tempOrder3 === void 0 ? void 0 : _this$store$tempOrder3.products) || payload.products;
|
|
1316
|
+
this.isEmittingPromotionApplied = true;
|
|
1317
|
+
try {
|
|
1318
|
+
void this.effectsEmit('onPromotionApplied', _objectSpread(_objectSpread({}, payload), {}, {
|
|
1319
|
+
products: products
|
|
1320
|
+
}));
|
|
1321
|
+
} finally {
|
|
1322
|
+
// effectsEmit 同步调用监听器后返回 Promise;保持既有的非阻塞事件行为。
|
|
1323
|
+
this.isEmittingPromotionApplied = false;
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
/** 公开入口:促销、折扣、summary 与持久化完成后发布稳定态事件。 */
|
|
1328
|
+
}, {
|
|
1329
|
+
key: "applyPromotion",
|
|
1330
|
+
value: (function () {
|
|
1331
|
+
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
1332
|
+
var payload, tempOrder;
|
|
1333
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context10) {
|
|
1334
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
1335
|
+
case 0:
|
|
1336
|
+
_context10.next = 2;
|
|
1337
|
+
return this.evaluatePromotion();
|
|
1338
|
+
case 2:
|
|
1339
|
+
payload = _context10.sent;
|
|
1340
|
+
if (payload) {
|
|
1341
|
+
_context10.next = 5;
|
|
1342
|
+
break;
|
|
1343
|
+
}
|
|
1344
|
+
return _context10.abrupt("return");
|
|
1345
|
+
case 5:
|
|
1346
|
+
tempOrder = this.store.tempOrder;
|
|
1347
|
+
if (tempOrder) {
|
|
1348
|
+
_context10.next = 8;
|
|
1349
|
+
break;
|
|
1350
|
+
}
|
|
1351
|
+
return _context10.abrupt("return");
|
|
1352
|
+
case 8:
|
|
1353
|
+
this.applyDiscount();
|
|
1354
|
+
this.sanitizeTempOrderProducts(tempOrder);
|
|
1355
|
+
_context10.next = 12;
|
|
1356
|
+
return this.recalculateSummary({
|
|
1357
|
+
createIfMissing: true
|
|
1358
|
+
});
|
|
1359
|
+
case 12:
|
|
1360
|
+
this.persistTempOrder();
|
|
1361
|
+
this.emitPromotionApplied(payload);
|
|
1362
|
+
case 14:
|
|
1363
|
+
case "end":
|
|
1364
|
+
return _context10.stop();
|
|
1365
|
+
}
|
|
1366
|
+
}, _callee8, this);
|
|
1252
1367
|
}));
|
|
1253
1368
|
function applyPromotion() {
|
|
1254
1369
|
return _applyPromotion.apply(this, arguments);
|
|
@@ -1447,14 +1562,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1447
1562
|
}, {
|
|
1448
1563
|
key: "saveDraft",
|
|
1449
1564
|
value: function () {
|
|
1450
|
-
var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1451
|
-
return _regeneratorRuntime().wrap(function
|
|
1452
|
-
while (1) switch (
|
|
1565
|
+
var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
1566
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context11) {
|
|
1567
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
1453
1568
|
case 0:
|
|
1454
1569
|
case "end":
|
|
1455
|
-
return
|
|
1570
|
+
return _context11.stop();
|
|
1456
1571
|
}
|
|
1457
|
-
},
|
|
1572
|
+
}, _callee9);
|
|
1458
1573
|
}));
|
|
1459
1574
|
function saveDraft() {
|
|
1460
1575
|
return _saveDraft.apply(this, arguments);
|
|
@@ -1469,16 +1584,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1469
1584
|
}, {
|
|
1470
1585
|
key: "hydrateTempOrderFromLocalRecord",
|
|
1471
1586
|
value: function () {
|
|
1472
|
-
var _hydrateTempOrderFromLocalRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1473
|
-
return _regeneratorRuntime().wrap(function
|
|
1474
|
-
while (1) switch (
|
|
1587
|
+
var _hydrateTempOrderFromLocalRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(record) {
|
|
1588
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context12) {
|
|
1589
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1475
1590
|
case 0:
|
|
1476
|
-
return
|
|
1591
|
+
return _context12.abrupt("return", this.hydrateTempOrderFromRecord(record));
|
|
1477
1592
|
case 1:
|
|
1478
1593
|
case "end":
|
|
1479
|
-
return
|
|
1594
|
+
return _context12.stop();
|
|
1480
1595
|
}
|
|
1481
|
-
},
|
|
1596
|
+
}, _callee10, this);
|
|
1482
1597
|
}));
|
|
1483
1598
|
function hydrateTempOrderFromLocalRecord(_x8) {
|
|
1484
1599
|
return _hydrateTempOrderFromLocalRecord.apply(this, arguments);
|
|
@@ -2476,7 +2591,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2476
2591
|
}, {
|
|
2477
2592
|
key: "restoreOrder",
|
|
2478
2593
|
value: function restoreOrder() {
|
|
2479
|
-
var _this$store$
|
|
2594
|
+
var _this$store$discount18, _this$store$discount19;
|
|
2480
2595
|
this.logInfo('restoreOrder start', {});
|
|
2481
2596
|
this.sessionStorageRestoreRecord = null;
|
|
2482
2597
|
var freshTempOrder = this.createDefaultTempOrderInstance();
|
|
@@ -2485,8 +2600,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2485
2600
|
this.store.summary = createEmptySummary();
|
|
2486
2601
|
this.store.lastOrderInfo = undefined;
|
|
2487
2602
|
this.store.syncState = undefined;
|
|
2488
|
-
void ((_this$store$
|
|
2489
|
-
void ((_this$store$
|
|
2603
|
+
void ((_this$store$discount18 = this.store.discount) === null || _this$store$discount18 === void 0 ? void 0 : _this$store$discount18.setOriginalDiscountList([]));
|
|
2604
|
+
void ((_this$store$discount19 = this.store.discount) === null || _this$store$discount19 === void 0 ? void 0 : _this$store$discount19.setDiscountList([]));
|
|
2490
2605
|
this.persistTempOrder();
|
|
2491
2606
|
return freshTempOrder;
|
|
2492
2607
|
}
|
|
@@ -2498,13 +2613,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2498
2613
|
}, {
|
|
2499
2614
|
key: "replaceTempOrder",
|
|
2500
2615
|
value: function () {
|
|
2501
|
-
var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2616
|
+
var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(tempOrder, options) {
|
|
2502
2617
|
var nextTempOrder;
|
|
2503
|
-
return _regeneratorRuntime().wrap(function
|
|
2504
|
-
while (1) switch (
|
|
2618
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context13) {
|
|
2619
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
2505
2620
|
case 0:
|
|
2506
2621
|
if (isTempOrder(tempOrder)) {
|
|
2507
|
-
|
|
2622
|
+
_context13.next = 2;
|
|
2508
2623
|
break;
|
|
2509
2624
|
}
|
|
2510
2625
|
throw new Error('无效的 tempOrder 数据');
|
|
@@ -2515,15 +2630,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2515
2630
|
});
|
|
2516
2631
|
this.store.tempOrder = nextTempOrder;
|
|
2517
2632
|
if (!((options === null || options === void 0 ? void 0 : options.recalculateSummary) !== false)) {
|
|
2518
|
-
|
|
2633
|
+
_context13.next = 10;
|
|
2519
2634
|
break;
|
|
2520
2635
|
}
|
|
2521
|
-
|
|
2636
|
+
_context13.next = 8;
|
|
2522
2637
|
return this.recalculateSummary({
|
|
2523
2638
|
createIfMissing: false
|
|
2524
2639
|
});
|
|
2525
2640
|
case 8:
|
|
2526
|
-
|
|
2641
|
+
_context13.next = 11;
|
|
2527
2642
|
break;
|
|
2528
2643
|
case 10:
|
|
2529
2644
|
this.store.summary = createEmptySummary();
|
|
@@ -2532,18 +2647,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2532
2647
|
this.persistTempOrder();
|
|
2533
2648
|
}
|
|
2534
2649
|
if (!(options !== null && options !== void 0 && options.saveDraft)) {
|
|
2535
|
-
|
|
2650
|
+
_context13.next = 15;
|
|
2536
2651
|
break;
|
|
2537
2652
|
}
|
|
2538
|
-
|
|
2653
|
+
_context13.next = 15;
|
|
2539
2654
|
return this.saveDraft();
|
|
2540
2655
|
case 15:
|
|
2541
|
-
return
|
|
2656
|
+
return _context13.abrupt("return", nextTempOrder);
|
|
2542
2657
|
case 16:
|
|
2543
2658
|
case "end":
|
|
2544
|
-
return
|
|
2659
|
+
return _context13.stop();
|
|
2545
2660
|
}
|
|
2546
|
-
},
|
|
2661
|
+
}, _callee11, this);
|
|
2547
2662
|
}));
|
|
2548
2663
|
function replaceTempOrder(_x9, _x10) {
|
|
2549
2664
|
return _replaceTempOrder.apply(this, arguments);
|
|
@@ -2631,32 +2746,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2631
2746
|
}, {
|
|
2632
2747
|
key: "addNewOrder",
|
|
2633
2748
|
value: function () {
|
|
2634
|
-
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2749
|
+
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
2635
2750
|
var tempOrder;
|
|
2636
|
-
return _regeneratorRuntime().wrap(function
|
|
2637
|
-
while (1) switch (
|
|
2751
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context14) {
|
|
2752
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
2638
2753
|
case 0:
|
|
2639
2754
|
tempOrder = this.ensureTempOrder();
|
|
2640
2755
|
this.ensureExternalSaleNumber(tempOrder);
|
|
2641
|
-
|
|
2756
|
+
_context14.next = 4;
|
|
2642
2757
|
return this.recalculateSummary({
|
|
2643
2758
|
createIfMissing: true
|
|
2644
2759
|
});
|
|
2645
2760
|
case 4:
|
|
2646
2761
|
this.persistTempOrder();
|
|
2647
2762
|
if (!this.draftPersistEnabled) {
|
|
2648
|
-
|
|
2763
|
+
_context14.next = 8;
|
|
2649
2764
|
break;
|
|
2650
2765
|
}
|
|
2651
|
-
|
|
2766
|
+
_context14.next = 8;
|
|
2652
2767
|
return this.saveDraft();
|
|
2653
2768
|
case 8:
|
|
2654
|
-
return
|
|
2769
|
+
return _context14.abrupt("return", tempOrder);
|
|
2655
2770
|
case 9:
|
|
2656
2771
|
case "end":
|
|
2657
|
-
return
|
|
2772
|
+
return _context14.stop();
|
|
2658
2773
|
}
|
|
2659
|
-
},
|
|
2774
|
+
}, _callee12, this);
|
|
2660
2775
|
}));
|
|
2661
2776
|
function addNewOrder() {
|
|
2662
2777
|
return _addNewOrder.apply(this, arguments);
|
|
@@ -2691,8 +2806,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2691
2806
|
value: function sanitizeTempOrderProducts(tempOrder) {
|
|
2692
2807
|
var _this15 = this;
|
|
2693
2808
|
tempOrder.products = (tempOrder.products || []).map(function (product) {
|
|
2694
|
-
return _this15.sanitizeOrderProductForTempOrder(product);
|
|
2809
|
+
return _this15.sanitizeOrderProductForTempOrder(_this15.normalizeVirtualSettlementProductIfEnabled(product));
|
|
2695
2810
|
});
|
|
2811
|
+
this.syncTempOrderSettlementState(tempOrder);
|
|
2696
2812
|
ensureUniqueProductLineUids(tempOrder);
|
|
2697
2813
|
}
|
|
2698
2814
|
}, {
|
|
@@ -2873,7 +2989,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2873
2989
|
}, {
|
|
2874
2990
|
key: "buildTempOrderHolderFromBookings",
|
|
2875
2991
|
value: function buildTempOrderHolderFromBookings(tempOrder) {
|
|
2876
|
-
var _baseHolder$customer_, _baseHolder, _ref45, _baseHolder$form_id, _baseHolder2, _tempOrder$holder2, _baseHolder3, _this$
|
|
2992
|
+
var _baseHolder$customer_, _baseHolder, _ref45, _baseHolder$form_id, _baseHolder2, _tempOrder$holder2, _baseHolder3, _this$otherParams2;
|
|
2877
2993
|
var holderRecords = [];
|
|
2878
2994
|
var holderNames = [];
|
|
2879
2995
|
var baseHolder = null;
|
|
@@ -2926,7 +3042,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2926
3042
|
if (holderNames.length) {
|
|
2927
3043
|
nextHolder.name = holderNames.join(',');
|
|
2928
3044
|
}
|
|
2929
|
-
if ((_baseHolder3 = baseHolder) !== null && _baseHolder3 !== void 0 && _baseHolder3.is_source_shop || (_this$
|
|
3045
|
+
if ((_baseHolder3 = baseHolder) !== null && _baseHolder3 !== void 0 && _baseHolder3.is_source_shop || (_this$otherParams2 = this.otherParams) !== null && _this$otherParams2 !== void 0 && _this$otherParams2.isFranchisee) {
|
|
2930
3046
|
nextHolder.is_source_shop = 1;
|
|
2931
3047
|
}
|
|
2932
3048
|
return nextHolder;
|
|
@@ -3024,18 +3140,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3024
3140
|
}, {
|
|
3025
3141
|
key: "recalculateSummary",
|
|
3026
3142
|
value: function () {
|
|
3027
|
-
var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3028
|
-
var _this$
|
|
3143
|
+
var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(options) {
|
|
3144
|
+
var _this$otherParams3, _ref46, _salesSummaryResult$e;
|
|
3029
3145
|
var tempOrder, originalSnapshot, hasShopDiscountChanged, shouldReuseOriginalSnapshot, snapshotSummary, shouldFullRecalculateFromSnapshot, summaryProducts, salesSummary, existedSummary, totalRefundAmount, paidPaymentSummary, emptyBaseSummary, emptySummaryBase, emptySummaryWithDeposit, emptySummary, salesSummaryResult, roundingAmount, payServiceChargeAmount, hasSalesSummaryAmount, expectAmount, amountPaymentPatch, normalizedExpectAmountPatch, summaryForGap, summary;
|
|
3030
|
-
return _regeneratorRuntime().wrap(function
|
|
3031
|
-
while (1) switch (
|
|
3146
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context15) {
|
|
3147
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
3032
3148
|
case 0:
|
|
3033
3149
|
tempOrder = options !== null && options !== void 0 && options.createIfMissing ? this.ensureTempOrder() : this.store.tempOrder;
|
|
3034
3150
|
if (tempOrder) {
|
|
3035
|
-
|
|
3151
|
+
_context15.next = 3;
|
|
3036
3152
|
break;
|
|
3037
3153
|
}
|
|
3038
|
-
return
|
|
3154
|
+
return _context15.abrupt("return", null);
|
|
3039
3155
|
case 3:
|
|
3040
3156
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
3041
3157
|
originalSnapshot = this.getOriginalSalesSnapshot(tempOrder);
|
|
@@ -3043,10 +3159,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3043
3159
|
shouldReuseOriginalSnapshot = originalSnapshot && !hasShopDiscountChanged;
|
|
3044
3160
|
snapshotSummary = shouldReuseOriginalSnapshot ? this.restoreOriginalSnapshotIfProductsUnchanged(tempOrder, originalSnapshot) : null;
|
|
3045
3161
|
if (!snapshotSummary) {
|
|
3046
|
-
|
|
3162
|
+
_context15.next = 10;
|
|
3047
3163
|
break;
|
|
3048
3164
|
}
|
|
3049
|
-
return
|
|
3165
|
+
return _context15.abrupt("return", snapshotSummary);
|
|
3050
3166
|
case 10:
|
|
3051
3167
|
shouldFullRecalculateFromSnapshot = Boolean(originalSnapshot);
|
|
3052
3168
|
summaryProducts = shouldFullRecalculateFromSnapshot ? cloneDeep(tempOrder.products || []) : tempOrder.products;
|
|
@@ -3058,7 +3174,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3058
3174
|
totalRefundAmount = existedSummary.total_refund_amount || '0.00';
|
|
3059
3175
|
paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
|
|
3060
3176
|
if (salesSummary) {
|
|
3061
|
-
|
|
3177
|
+
_context15.next = 26;
|
|
3062
3178
|
break;
|
|
3063
3179
|
}
|
|
3064
3180
|
emptyBaseSummary = _objectSpread(_objectSpread(_objectSpread({}, createEmptySummary()), existedSummary), {}, {
|
|
@@ -3084,18 +3200,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3084
3200
|
previousSummary: existedSummary,
|
|
3085
3201
|
summary: emptySummary
|
|
3086
3202
|
});
|
|
3087
|
-
return
|
|
3203
|
+
return _context15.abrupt("return", this.store.summary);
|
|
3088
3204
|
case 26:
|
|
3089
|
-
|
|
3205
|
+
_context15.next = 28;
|
|
3090
3206
|
return salesSummary.getSummary(_objectSpread({
|
|
3091
3207
|
products: summaryProducts,
|
|
3092
3208
|
isPriceIncludeTax: tempOrder.is_price_include_tax,
|
|
3093
|
-
shopDiscount: tempOrder.shop_discount
|
|
3094
|
-
|
|
3209
|
+
shopDiscount: tempOrder.shop_discount,
|
|
3210
|
+
virtualSettlementMode: this.shouldUseVirtualSettlementSummary(tempOrder)
|
|
3211
|
+
}, (_this$otherParams3 = this.otherParams) !== null && _this$otherParams3 !== void 0 && _this$otherParams3.channel ? {
|
|
3095
3212
|
channel: this.otherParams.channel
|
|
3096
3213
|
} : {}));
|
|
3097
3214
|
case 28:
|
|
3098
|
-
salesSummaryResult =
|
|
3215
|
+
salesSummaryResult = _context15.sent;
|
|
3099
3216
|
if (shouldFullRecalculateFromSnapshot) {
|
|
3100
3217
|
tempOrder.products = summaryProducts;
|
|
3101
3218
|
}
|
|
@@ -3140,12 +3257,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3140
3257
|
previousSummary: existedSummary,
|
|
3141
3258
|
summary: summary
|
|
3142
3259
|
});
|
|
3143
|
-
return
|
|
3260
|
+
return _context15.abrupt("return", this.store.summary);
|
|
3144
3261
|
case 46:
|
|
3145
3262
|
case "end":
|
|
3146
|
-
return
|
|
3263
|
+
return _context15.stop();
|
|
3147
3264
|
}
|
|
3148
|
-
},
|
|
3265
|
+
}, _callee13, this);
|
|
3149
3266
|
}));
|
|
3150
3267
|
function recalculateSummary(_x11) {
|
|
3151
3268
|
return _recalculateSummary.apply(this, arguments);
|
|
@@ -3155,30 +3272,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3155
3272
|
}, {
|
|
3156
3273
|
key: "getOrderSummary",
|
|
3157
3274
|
value: function () {
|
|
3158
|
-
var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3275
|
+
var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
3159
3276
|
var summary;
|
|
3160
|
-
return _regeneratorRuntime().wrap(function
|
|
3161
|
-
while (1) switch (
|
|
3277
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context16) {
|
|
3278
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
3162
3279
|
case 0:
|
|
3163
|
-
|
|
3280
|
+
_context16.next = 2;
|
|
3164
3281
|
return this.recalculateSummary({
|
|
3165
3282
|
createIfMissing: true
|
|
3166
3283
|
});
|
|
3167
3284
|
case 2:
|
|
3168
|
-
summary =
|
|
3285
|
+
summary = _context16.sent;
|
|
3169
3286
|
if (summary) {
|
|
3170
|
-
|
|
3287
|
+
_context16.next = 5;
|
|
3171
3288
|
break;
|
|
3172
3289
|
}
|
|
3173
|
-
return
|
|
3290
|
+
return _context16.abrupt("return", createEmptySummary());
|
|
3174
3291
|
case 5:
|
|
3175
3292
|
this.persistTempOrder();
|
|
3176
|
-
return
|
|
3293
|
+
return _context16.abrupt("return", summary);
|
|
3177
3294
|
case 7:
|
|
3178
3295
|
case "end":
|
|
3179
|
-
return
|
|
3296
|
+
return _context16.stop();
|
|
3180
3297
|
}
|
|
3181
|
-
},
|
|
3298
|
+
}, _callee14, this);
|
|
3182
3299
|
}));
|
|
3183
3300
|
function getOrderSummary() {
|
|
3184
3301
|
return _getOrderSummary.apply(this, arguments);
|
|
@@ -3202,21 +3319,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3202
3319
|
}, {
|
|
3203
3320
|
key: "syncTempOrderNoteToRemote",
|
|
3204
3321
|
value: function () {
|
|
3205
|
-
var _syncTempOrderNoteToRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3206
|
-
return _regeneratorRuntime().wrap(function
|
|
3207
|
-
while (1) switch (
|
|
3322
|
+
var _syncTempOrderNoteToRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(orderId, note) {
|
|
3323
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context17) {
|
|
3324
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
3208
3325
|
case 0:
|
|
3209
|
-
|
|
3326
|
+
_context17.next = 2;
|
|
3210
3327
|
return this.request.put("/order/order/".concat(orderId, "/note"), {
|
|
3211
3328
|
note: note
|
|
3212
3329
|
});
|
|
3213
3330
|
case 2:
|
|
3214
|
-
return
|
|
3331
|
+
return _context17.abrupt("return", note);
|
|
3215
3332
|
case 3:
|
|
3216
3333
|
case "end":
|
|
3217
|
-
return
|
|
3334
|
+
return _context17.stop();
|
|
3218
3335
|
}
|
|
3219
|
-
},
|
|
3336
|
+
}, _callee15, this);
|
|
3220
3337
|
}));
|
|
3221
3338
|
function syncTempOrderNoteToRemote(_x12, _x13) {
|
|
3222
3339
|
return _syncTempOrderNoteToRemote.apply(this, arguments);
|
|
@@ -3226,8 +3343,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3226
3343
|
}, {
|
|
3227
3344
|
key: "getTempOrderNote",
|
|
3228
3345
|
value: function getTempOrderNote() {
|
|
3229
|
-
var _this$store$
|
|
3230
|
-
return ((_this$store$
|
|
3346
|
+
var _this$store$tempOrder4;
|
|
3347
|
+
return ((_this$store$tempOrder4 = this.store.tempOrder) === null || _this$store$tempOrder4 === void 0 ? void 0 : _this$store$tempOrder4.note) || '';
|
|
3231
3348
|
}
|
|
3232
3349
|
}, {
|
|
3233
3350
|
key: "ensureSalesNotesRuntimeState",
|
|
@@ -3419,20 +3536,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3419
3536
|
}, {
|
|
3420
3537
|
key: "setSalesNote",
|
|
3421
3538
|
value: function () {
|
|
3422
|
-
var _setSalesNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3539
|
+
var _setSalesNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(input) {
|
|
3423
3540
|
var tempOrder, note;
|
|
3424
|
-
return _regeneratorRuntime().wrap(function
|
|
3425
|
-
while (1) switch (
|
|
3541
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context18) {
|
|
3542
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
3426
3543
|
case 0:
|
|
3427
3544
|
tempOrder = this.ensureTempOrder();
|
|
3428
3545
|
note = this.setSalesNoteOnTempOrder(tempOrder, input);
|
|
3429
3546
|
this.notifyTempOrderChanged();
|
|
3430
|
-
return
|
|
3547
|
+
return _context18.abrupt("return", cloneDeep(note));
|
|
3431
3548
|
case 4:
|
|
3432
3549
|
case "end":
|
|
3433
|
-
return
|
|
3550
|
+
return _context18.stop();
|
|
3434
3551
|
}
|
|
3435
|
-
},
|
|
3552
|
+
}, _callee16, this);
|
|
3436
3553
|
}));
|
|
3437
3554
|
function setSalesNote(_x14) {
|
|
3438
3555
|
return _setSalesNote.apply(this, arguments);
|
|
@@ -3442,10 +3559,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3442
3559
|
}, {
|
|
3443
3560
|
key: "removeSalesNote",
|
|
3444
3561
|
value: function () {
|
|
3445
|
-
var _removeSalesNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3562
|
+
var _removeSalesNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(uuid) {
|
|
3446
3563
|
var tempOrder, normalizedUuid, notes, nextNotes, state;
|
|
3447
|
-
return _regeneratorRuntime().wrap(function
|
|
3448
|
-
while (1) switch (
|
|
3564
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context19) {
|
|
3565
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
3449
3566
|
case 0:
|
|
3450
3567
|
tempOrder = this.ensureTempOrder();
|
|
3451
3568
|
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
@@ -3455,10 +3572,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3455
3572
|
return note.uuid !== normalizedUuid;
|
|
3456
3573
|
});
|
|
3457
3574
|
if (!(nextNotes.length === notes.length)) {
|
|
3458
|
-
|
|
3575
|
+
_context19.next = 7;
|
|
3459
3576
|
break;
|
|
3460
3577
|
}
|
|
3461
|
-
return
|
|
3578
|
+
return _context19.abrupt("return");
|
|
3462
3579
|
case 7:
|
|
3463
3580
|
tempOrder.notes = nextNotes;
|
|
3464
3581
|
state = this.ensureSalesNotesRuntimeState(tempOrder);
|
|
@@ -3466,9 +3583,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3466
3583
|
this.notifyTempOrderChanged();
|
|
3467
3584
|
case 11:
|
|
3468
3585
|
case "end":
|
|
3469
|
-
return
|
|
3586
|
+
return _context19.stop();
|
|
3470
3587
|
}
|
|
3471
|
-
},
|
|
3588
|
+
}, _callee17, this);
|
|
3472
3589
|
}));
|
|
3473
3590
|
function removeSalesNote(_x15) {
|
|
3474
3591
|
return _removeSalesNote.apply(this, arguments);
|
|
@@ -3478,10 +3595,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3478
3595
|
}, {
|
|
3479
3596
|
key: "clearSalesNotes",
|
|
3480
3597
|
value: function () {
|
|
3481
|
-
var _clearSalesNotes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3598
|
+
var _clearSalesNotes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
3482
3599
|
var tempOrder, state;
|
|
3483
|
-
return _regeneratorRuntime().wrap(function
|
|
3484
|
-
while (1) switch (
|
|
3600
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context20) {
|
|
3601
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
3485
3602
|
case 0:
|
|
3486
3603
|
tempOrder = this.ensureTempOrder();
|
|
3487
3604
|
tempOrder.notes = [];
|
|
@@ -3491,9 +3608,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3491
3608
|
this.notifyTempOrderChanged();
|
|
3492
3609
|
case 6:
|
|
3493
3610
|
case "end":
|
|
3494
|
-
return
|
|
3611
|
+
return _context20.stop();
|
|
3495
3612
|
}
|
|
3496
|
-
},
|
|
3613
|
+
}, _callee18, this);
|
|
3497
3614
|
}));
|
|
3498
3615
|
function clearSalesNotes() {
|
|
3499
3616
|
return _clearSalesNotes.apply(this, arguments);
|
|
@@ -3624,11 +3741,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3624
3741
|
}, {
|
|
3625
3742
|
key: "shouldSkipDiscountCalculation",
|
|
3626
3743
|
value: function shouldSkipDiscountCalculation(tempOrder) {
|
|
3627
|
-
var _this$store$
|
|
3628
|
-
_this$store$
|
|
3744
|
+
var _this$store$discount20,
|
|
3745
|
+
_this$store$discount21,
|
|
3629
3746
|
_this22 = this;
|
|
3630
3747
|
if (this.hasActiveCustomerBoundDiscount) return false;
|
|
3631
|
-
var discountList = ((_this$store$
|
|
3748
|
+
var discountList = ((_this$store$discount20 = this.store.discount) === null || _this$store$discount20 === void 0 || (_this$store$discount21 = _this$store$discount20.getDiscountList) === null || _this$store$discount21 === void 0 ? void 0 : _this$store$discount21.call(_this$store$discount20)) || [];
|
|
3632
3749
|
if (discountList.length > 0) return false;
|
|
3633
3750
|
return !(tempOrder.products || []).some(function (product) {
|
|
3634
3751
|
return _this22.productHasCustomerBoundDiscount(product);
|
|
@@ -3750,6 +3867,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3750
3867
|
var nextCustomerId = (_tempOrder$customer_i5 = tempOrder.customer_id) !== null && _tempOrder$customer_i5 !== void 0 ? _tempOrder$customer_i5 : null;
|
|
3751
3868
|
if (String(previousCustomerId !== null && previousCustomerId !== void 0 ? previousCustomerId : '') !== String(nextCustomerId !== null && nextCustomerId !== void 0 ? nextCustomerId : '')) {
|
|
3752
3869
|
this.store.availableWalletIds = [];
|
|
3870
|
+
this.store.virtualCurrencyList = [];
|
|
3753
3871
|
clearTempOrderHolderAssignments(tempOrder);
|
|
3754
3872
|
this.clearCustomerBoundDiscounts(tempOrder);
|
|
3755
3873
|
this.applyDiscount();
|
|
@@ -3778,8 +3896,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3778
3896
|
}, {
|
|
3779
3897
|
key: "getOrderCustomerSnapshot",
|
|
3780
3898
|
value: function getOrderCustomerSnapshot() {
|
|
3781
|
-
var _this$store$
|
|
3782
|
-
var snapshot = (_this$store$
|
|
3899
|
+
var _this$store$tempOrder5;
|
|
3900
|
+
var snapshot = (_this$store$tempOrder5 = this.store.tempOrder) === null || _this$store$tempOrder5 === void 0 || (_this$store$tempOrder5 = _this$store$tempOrder5._extend) === null || _this$store$tempOrder5 === void 0 ? void 0 : _this$store$tempOrder5.customerSnapshot;
|
|
3783
3901
|
return snapshot ? cloneDeep(snapshot) : null;
|
|
3784
3902
|
}
|
|
3785
3903
|
}, {
|
|
@@ -3795,6 +3913,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3795
3913
|
tempOrder.customer = null;
|
|
3796
3914
|
if (tempOrder._extend) delete tempOrder._extend.customerSnapshot;
|
|
3797
3915
|
this.store.availableWalletIds = [];
|
|
3916
|
+
this.store.virtualCurrencyList = [];
|
|
3798
3917
|
this.clearCustomerBoundDiscounts(tempOrder);
|
|
3799
3918
|
this.applyDiscount();
|
|
3800
3919
|
this.persistTempOrder();
|
|
@@ -3862,32 +3981,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3862
3981
|
}, {
|
|
3863
3982
|
key: "addOrderPaymentAsync",
|
|
3864
3983
|
value: (function () {
|
|
3865
|
-
var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3984
|
+
var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(payment) {
|
|
3866
3985
|
var hasPaymentNumber, devicePrefix;
|
|
3867
|
-
return _regeneratorRuntime().wrap(function
|
|
3868
|
-
while (1) switch (
|
|
3986
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context21) {
|
|
3987
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
3869
3988
|
case 0:
|
|
3870
3989
|
hasPaymentNumber = String(payment.payment_number || '').trim() !== '';
|
|
3871
3990
|
if (!hasPaymentNumber) {
|
|
3872
|
-
|
|
3991
|
+
_context21.next = 5;
|
|
3873
3992
|
break;
|
|
3874
3993
|
}
|
|
3875
|
-
|
|
3876
|
-
|
|
3994
|
+
_context21.t0 = 'LOCAL';
|
|
3995
|
+
_context21.next = 8;
|
|
3877
3996
|
break;
|
|
3878
3997
|
case 5:
|
|
3879
|
-
|
|
3998
|
+
_context21.next = 7;
|
|
3880
3999
|
return this.getPaymentNumberDevicePrefixAsync();
|
|
3881
4000
|
case 7:
|
|
3882
|
-
|
|
4001
|
+
_context21.t0 = _context21.sent;
|
|
3883
4002
|
case 8:
|
|
3884
|
-
devicePrefix =
|
|
3885
|
-
return
|
|
4003
|
+
devicePrefix = _context21.t0;
|
|
4004
|
+
return _context21.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
|
|
3886
4005
|
case 10:
|
|
3887
4006
|
case "end":
|
|
3888
|
-
return
|
|
4007
|
+
return _context21.stop();
|
|
3889
4008
|
}
|
|
3890
|
-
},
|
|
4009
|
+
}, _callee19, this);
|
|
3891
4010
|
}));
|
|
3892
4011
|
function addOrderPaymentAsync(_x16) {
|
|
3893
4012
|
return _addOrderPaymentAsync.apply(this, arguments);
|
|
@@ -3929,7 +4048,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3929
4048
|
}, {
|
|
3930
4049
|
key: "updateOrderPayment",
|
|
3931
4050
|
value: (function () {
|
|
3932
|
-
var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4051
|
+
var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(paymentIdentity, updates) {
|
|
3933
4052
|
var options,
|
|
3934
4053
|
tempOrder,
|
|
3935
4054
|
identity,
|
|
@@ -3938,17 +4057,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3938
4057
|
updatedPayment,
|
|
3939
4058
|
summary,
|
|
3940
4059
|
payments,
|
|
3941
|
-
|
|
3942
|
-
return _regeneratorRuntime().wrap(function
|
|
3943
|
-
while (1) switch (
|
|
4060
|
+
_args22 = arguments;
|
|
4061
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context22) {
|
|
4062
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
3944
4063
|
case 0:
|
|
3945
|
-
options =
|
|
4064
|
+
options = _args22.length > 2 && _args22[2] !== undefined ? _args22[2] : {};
|
|
3946
4065
|
tempOrder = this.ensureTempOrder();
|
|
3947
4066
|
identity = String(paymentIdentity);
|
|
3948
4067
|
matchMode = options.matchBy === 'compat' || options.matchBy === 'legacy' ? 'compat' : 'payment_number';
|
|
3949
4068
|
matchedPayment = resolveOrderPaymentIdentity(tempOrder.payments || [], identity, matchMode);
|
|
3950
4069
|
if (matchedPayment) {
|
|
3951
|
-
|
|
4070
|
+
_context22.next = 7;
|
|
3952
4071
|
break;
|
|
3953
4072
|
}
|
|
3954
4073
|
throw new Error("\u672A\u627E\u5230\u652F\u4ED8\u9879: ".concat(identity));
|
|
@@ -3963,15 +4082,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3963
4082
|
return nextPayment;
|
|
3964
4083
|
});
|
|
3965
4084
|
this.persistTempOrder();
|
|
3966
|
-
|
|
4085
|
+
_context22.next = 12;
|
|
3967
4086
|
return this.recalculateSummary({
|
|
3968
4087
|
createIfMissing: true
|
|
3969
4088
|
});
|
|
3970
4089
|
case 12:
|
|
3971
|
-
summary =
|
|
4090
|
+
summary = _context22.sent;
|
|
3972
4091
|
this.persistTempOrder();
|
|
3973
4092
|
payments = tempOrder.payments;
|
|
3974
|
-
return
|
|
4093
|
+
return _context22.abrupt("return", {
|
|
3975
4094
|
updated: true,
|
|
3976
4095
|
payment: payments[matchedPayment.index] || updatedPayment,
|
|
3977
4096
|
payments: payments,
|
|
@@ -3979,9 +4098,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3979
4098
|
});
|
|
3980
4099
|
case 16:
|
|
3981
4100
|
case "end":
|
|
3982
|
-
return
|
|
4101
|
+
return _context22.stop();
|
|
3983
4102
|
}
|
|
3984
|
-
},
|
|
4103
|
+
}, _callee20, this);
|
|
3985
4104
|
}));
|
|
3986
4105
|
function updateOrderPayment(_x17, _x18) {
|
|
3987
4106
|
return _updateOrderPayment.apply(this, arguments);
|
|
@@ -4179,36 +4298,36 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4179
4298
|
}, {
|
|
4180
4299
|
key: "updateVoucherOrderPaymentsAsync",
|
|
4181
4300
|
value: function () {
|
|
4182
|
-
var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4301
|
+
var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(payments, options) {
|
|
4183
4302
|
var needsPaymentNumber, devicePrefix;
|
|
4184
|
-
return _regeneratorRuntime().wrap(function
|
|
4185
|
-
while (1) switch (
|
|
4303
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context23) {
|
|
4304
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
4186
4305
|
case 0:
|
|
4187
4306
|
needsPaymentNumber = (payments || []).some(function (payment) {
|
|
4188
4307
|
return String(payment.payment_number || '').trim() === '';
|
|
4189
4308
|
});
|
|
4190
4309
|
if (!needsPaymentNumber) {
|
|
4191
|
-
|
|
4310
|
+
_context23.next = 7;
|
|
4192
4311
|
break;
|
|
4193
4312
|
}
|
|
4194
|
-
|
|
4313
|
+
_context23.next = 4;
|
|
4195
4314
|
return this.getPaymentNumberDevicePrefixAsync();
|
|
4196
4315
|
case 4:
|
|
4197
|
-
|
|
4198
|
-
|
|
4316
|
+
_context23.t0 = _context23.sent;
|
|
4317
|
+
_context23.next = 8;
|
|
4199
4318
|
break;
|
|
4200
4319
|
case 7:
|
|
4201
|
-
|
|
4320
|
+
_context23.t0 = 'LOCAL';
|
|
4202
4321
|
case 8:
|
|
4203
|
-
devicePrefix =
|
|
4204
|
-
return
|
|
4322
|
+
devicePrefix = _context23.t0;
|
|
4323
|
+
return _context23.abrupt("return", this.updateVoucherOrderPayments(payments, _objectSpread(_objectSpread({}, options), {}, {
|
|
4205
4324
|
devicePrefix: devicePrefix
|
|
4206
4325
|
})));
|
|
4207
4326
|
case 10:
|
|
4208
4327
|
case "end":
|
|
4209
|
-
return
|
|
4328
|
+
return _context23.stop();
|
|
4210
4329
|
}
|
|
4211
|
-
},
|
|
4330
|
+
}, _callee21, this);
|
|
4212
4331
|
}));
|
|
4213
4332
|
function updateVoucherOrderPaymentsAsync(_x19, _x20) {
|
|
4214
4333
|
return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
|
|
@@ -4260,52 +4379,156 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4260
4379
|
var bookingUid = (_product$booking_uid = product === null || product === void 0 ? void 0 : product.booking_uid) !== null && _product$booking_uid !== void 0 ? _product$booking_uid : product === null || product === void 0 || (_product$metadata9 = product.metadata) === null || _product$metadata9 === void 0 ? void 0 : _product$metadata9.booking_uid;
|
|
4261
4380
|
return bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '';
|
|
4262
4381
|
}
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4382
|
+
}, {
|
|
4383
|
+
key: "isMultiCurrencySettlementEnabled",
|
|
4384
|
+
value: function isMultiCurrencySettlementEnabled() {
|
|
4385
|
+
var _this$otherParams4;
|
|
4386
|
+
return ((_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.enableMultiCurrencySettlement) === true;
|
|
4387
|
+
}
|
|
4388
|
+
}, {
|
|
4389
|
+
key: "isActiveVirtualSettlementOrder",
|
|
4390
|
+
value: function isActiveVirtualSettlementOrder(tempOrder) {
|
|
4391
|
+
return this.isMultiCurrencySettlementEnabled() && isVirtualSettlementOrder(tempOrder);
|
|
4392
|
+
}
|
|
4393
|
+
}, {
|
|
4394
|
+
key: "shouldUseVirtualSettlementSummary",
|
|
4395
|
+
value: function shouldUseVirtualSettlementSummary(tempOrder) {
|
|
4396
|
+
var _tempOrder$metadata;
|
|
4397
|
+
return this.isActiveVirtualSettlementOrder(tempOrder) || (tempOrder === null || tempOrder === void 0 || (_tempOrder$metadata = tempOrder.metadata) === null || _tempOrder$metadata === void 0 || (_tempOrder$metadata = _tempOrder$metadata.currency_settlement_config) === null || _tempOrder$metadata === void 0 ? void 0 : _tempOrder$metadata.settlement_type) === 'virtual_currency';
|
|
4398
|
+
}
|
|
4399
|
+
}, {
|
|
4400
|
+
key: "normalizeVirtualSettlementProductIfEnabled",
|
|
4401
|
+
value: function normalizeVirtualSettlementProductIfEnabled(product) {
|
|
4402
|
+
return this.isMultiCurrencySettlementEnabled() ? normalizeVirtualSettlementOrderProduct(product) : product;
|
|
4403
|
+
}
|
|
4404
|
+
}, {
|
|
4405
|
+
key: "assertAndLockProductSettlement",
|
|
4406
|
+
value: function assertAndLockProductSettlement(tempOrder, product) {
|
|
4407
|
+
var _ref60, _ref61, _product$selling_pric;
|
|
4408
|
+
if (!this.isMultiCurrencySettlementEnabled()) return;
|
|
4409
|
+
var currentKey = getTempOrderSettlementKey(tempOrder);
|
|
4410
|
+
var incomingKey = getSettlementKey(getSelectedSettlementSnapshot(product)) || 'legal_currency';
|
|
4411
|
+
if (currentKey && currentKey !== incomingKey) {
|
|
4412
|
+
throw new OrderSettlementConflictError(currentKey, incomingKey);
|
|
4413
|
+
}
|
|
4414
|
+
var snapshot = getSelectedSettlementSnapshot(product);
|
|
4415
|
+
if ((snapshot === null || snapshot === void 0 ? void 0 : snapshot.settlement_type) === 'virtual_currency' && tempOrder.customer_id && Number(tempOrder.customer_id) !== 1) {
|
|
4416
|
+
var currencyProductId = Number(snapshot.currency_product_id);
|
|
4417
|
+
var asset = (this.store.virtualCurrencyList || []).find(function (item) {
|
|
4418
|
+
return Number(item === null || item === void 0 ? void 0 : item.product_id) === currencyProductId;
|
|
4419
|
+
});
|
|
4420
|
+
if (!asset) {
|
|
4421
|
+
throw new VirtualCurrencyAssetNotFoundError(currencyProductId);
|
|
4422
|
+
}
|
|
4423
|
+
var existedAmount = tempOrder.products.reduce(function (sum, item) {
|
|
4424
|
+
return sum.plus(new Decimal(item.selling_price || 0).times(item.num || 1));
|
|
4425
|
+
}, new Decimal(0));
|
|
4426
|
+
var requiredAmount = existedAmount.plus(new Decimal(snapshot.price || 0).times(product.num || 1));
|
|
4427
|
+
var balance = new Decimal(asset.balance || 0);
|
|
4428
|
+
if (balance.lt(requiredAmount)) {
|
|
4429
|
+
throw new VirtualCurrencyBalanceError(balance.toFixed(2), requiredAmount.toFixed(2));
|
|
4430
|
+
}
|
|
4431
|
+
}
|
|
4432
|
+
applyTempOrderSettlementState(tempOrder, snapshot || {
|
|
4433
|
+
settlement_type: 'legal_currency',
|
|
4434
|
+
price: (_ref60 = (_ref61 = (_product$selling_pric = product.selling_price) !== null && _product$selling_pric !== void 0 ? _product$selling_pric : product.original_price) !== null && _ref61 !== void 0 ? _ref61 : product.payment_price) !== null && _ref60 !== void 0 ? _ref60 : 0,
|
|
4435
|
+
unit_label: tempOrder.currency_code,
|
|
4436
|
+
symbol: tempOrder.currency_symbol,
|
|
4437
|
+
amount_format: tempOrder.currency_format
|
|
4438
|
+
});
|
|
4439
|
+
}
|
|
4440
|
+
}, {
|
|
4441
|
+
key: "syncTempOrderSettlementState",
|
|
4442
|
+
value: function syncTempOrderSettlementState(tempOrder) {
|
|
4443
|
+
if (!this.isMultiCurrencySettlementEnabled()) return;
|
|
4444
|
+
tempOrder.metadata = tempOrder.metadata || {};
|
|
4445
|
+
if (!tempOrder.products.length) {
|
|
4446
|
+
releaseTempOrderSettlementState(tempOrder);
|
|
4447
|
+
return;
|
|
4448
|
+
}
|
|
4449
|
+
var snapshot = getTempOrderSettlementSnapshot(tempOrder);
|
|
4450
|
+
if (snapshot) {
|
|
4451
|
+
applyTempOrderSettlementState(tempOrder, snapshot);
|
|
4452
|
+
return;
|
|
4453
|
+
}
|
|
4454
|
+
tempOrder.metadata.cart_settlement_key = 'legal_currency';
|
|
4455
|
+
}
|
|
4456
|
+
}, {
|
|
4457
|
+
key: "prepareVirtualSettlementTempOrder",
|
|
4458
|
+
value: function prepareVirtualSettlementTempOrder(tempOrder) {
|
|
4459
|
+
if (!this.isMultiCurrencySettlementEnabled()) return;
|
|
4460
|
+
this.syncTempOrderSettlementState(tempOrder);
|
|
4461
|
+
if (!this.isActiveVirtualSettlementOrder(tempOrder)) return;
|
|
4462
|
+
tempOrder.products = normalizeVirtualSettlementProducts(tempOrder.products);
|
|
4463
|
+
tempOrder.discount_list = [];
|
|
4464
|
+
tempOrder.shop_discount = '0.00';
|
|
4465
|
+
tempOrder.surcharge_fee = '0.00';
|
|
4466
|
+
tempOrder.surcharges = [];
|
|
4467
|
+
var virtualOrder = tempOrder;
|
|
4468
|
+
virtualOrder.discount_amount = '0.00';
|
|
4469
|
+
virtualOrder.product_tax_fee = '0.00';
|
|
4470
|
+
virtualOrder.tax_fee = '0.00';
|
|
4471
|
+
virtualOrder.shipping_fee = '0.00';
|
|
4472
|
+
virtualOrder.shipping_tax_fee = '0.00';
|
|
4473
|
+
virtualOrder.tip_fee = '0.00';
|
|
4474
|
+
}
|
|
4475
|
+
|
|
4476
|
+
// ─── TempOrder: 商品 CRUD ───
|
|
4477
|
+
|
|
4478
|
+
/**
|
|
4479
|
+
* 预约商品加车后的统一收尾:促销、折扣、summary 重算与持久化(批量拆行时只调用一次)。
|
|
4480
|
+
*
|
|
4481
|
+
* @example
|
|
4482
|
+
* await this.finalizeProductOrderMutation(tempOrder);
|
|
4483
|
+
*/
|
|
4272
4484
|
}, {
|
|
4273
4485
|
key: "finalizeProductOrderMutation",
|
|
4274
4486
|
value: function () {
|
|
4275
|
-
var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4276
|
-
|
|
4277
|
-
|
|
4487
|
+
var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(tempOrder, options) {
|
|
4488
|
+
var isVirtualSettlement, promotionPayload;
|
|
4489
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context24) {
|
|
4490
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
4278
4491
|
case 0:
|
|
4279
4492
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
4280
|
-
|
|
4281
|
-
|
|
4493
|
+
this.prepareVirtualSettlementTempOrder(tempOrder);
|
|
4494
|
+
isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder);
|
|
4495
|
+
if (!(!(options !== null && options !== void 0 && options.skipEditDiscountConfigRefresh) && !isVirtualSettlement)) {
|
|
4496
|
+
_context24.next = 6;
|
|
4282
4497
|
break;
|
|
4283
4498
|
}
|
|
4284
|
-
|
|
4499
|
+
_context24.next = 6;
|
|
4285
4500
|
return this.ensureEditDiscountConfigForProductChange(tempOrder);
|
|
4286
|
-
case
|
|
4287
|
-
if (options !== null && options !== void 0 && options.skipDiscountRecalculation) {
|
|
4288
|
-
|
|
4501
|
+
case 6:
|
|
4502
|
+
if (!(!(options !== null && options !== void 0 && options.skipDiscountRecalculation) && !isVirtualSettlement)) {
|
|
4503
|
+
_context24.next = 12;
|
|
4289
4504
|
break;
|
|
4290
4505
|
}
|
|
4291
|
-
|
|
4292
|
-
return this.
|
|
4293
|
-
case
|
|
4294
|
-
|
|
4506
|
+
_context24.next = 9;
|
|
4507
|
+
return this.evaluatePromotion();
|
|
4508
|
+
case 9:
|
|
4509
|
+
_context24.t0 = _context24.sent;
|
|
4510
|
+
_context24.next = 13;
|
|
4511
|
+
break;
|
|
4512
|
+
case 12:
|
|
4513
|
+
_context24.t0 = null;
|
|
4514
|
+
case 13:
|
|
4515
|
+
promotionPayload = _context24.t0;
|
|
4516
|
+
if (!(options !== null && options !== void 0 && options.skipDiscountRecalculation) && !isVirtualSettlement) {
|
|
4295
4517
|
this.applyDiscount();
|
|
4296
4518
|
}
|
|
4297
4519
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4298
|
-
|
|
4520
|
+
_context24.next = 18;
|
|
4299
4521
|
return this.recalculateSummary({
|
|
4300
4522
|
createIfMissing: true
|
|
4301
4523
|
});
|
|
4302
|
-
case
|
|
4524
|
+
case 18:
|
|
4303
4525
|
this.persistTempOrder();
|
|
4304
|
-
|
|
4526
|
+
this.emitPromotionApplied(promotionPayload);
|
|
4527
|
+
case 20:
|
|
4305
4528
|
case "end":
|
|
4306
|
-
return
|
|
4529
|
+
return _context24.stop();
|
|
4307
4530
|
}
|
|
4308
|
-
},
|
|
4531
|
+
}, _callee22, this);
|
|
4309
4532
|
}));
|
|
4310
4533
|
function finalizeProductOrderMutation(_x21, _x22) {
|
|
4311
4534
|
return _finalizeProductOrderMutation.apply(this, arguments);
|
|
@@ -4339,9 +4562,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4339
4562
|
booking: booking
|
|
4340
4563
|
}) : null;
|
|
4341
4564
|
var productToAdd = (linked === null || linked === void 0 ? void 0 : linked.product) || product;
|
|
4565
|
+
this.assertAndLockProductSettlement(tempOrder, productToAdd);
|
|
4342
4566
|
var disableMerge = (options === null || options === void 0 ? void 0 : options.disableMerge) === true;
|
|
4343
4567
|
var incomingFingerprint = disableMerge ? '' : buildProductLineFingerprint(getProductSkuOptions(productToAdd), productToAdd.product_bundle);
|
|
4344
|
-
var normalizedIncoming = mergeOrderProductDisplayFields(productToAdd, normalizeOrderProduct(productToAdd));
|
|
4568
|
+
var normalizedIncoming = this.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(productToAdd, normalizeOrderProduct(productToAdd)));
|
|
4345
4569
|
if (disableMerge) {
|
|
4346
4570
|
normalizedIncoming.metadata = _objectSpread(_objectSpread({}, normalizedIncoming.metadata || {}), {}, _defineProperty({}, PRODUCT_LINE_MERGE_DISABLED_METADATA_KEY, true));
|
|
4347
4571
|
}
|
|
@@ -4399,11 +4623,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4399
4623
|
var _targetProduct$metada;
|
|
4400
4624
|
var targetProduct = matchedProduct;
|
|
4401
4625
|
var targetUid = (_targetProduct$metada = targetProduct.metadata) === null || _targetProduct$metada === void 0 ? void 0 : _targetProduct$metada.unique_identification_number;
|
|
4402
|
-
var normalizedProduct = mergeOrderProductDisplayFields(targetProduct, normalizeOrderProduct(_objectSpread(_objectSpread({}, productToAdd), {}, {
|
|
4626
|
+
var normalizedProduct = _this29.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(targetProduct, normalizeOrderProduct(_objectSpread(_objectSpread({}, productToAdd), {}, {
|
|
4403
4627
|
metadata: _objectSpread(_objectSpread({}, productToAdd.metadata || {}), {}, {
|
|
4404
4628
|
unique_identification_number: targetUid
|
|
4405
4629
|
})
|
|
4406
|
-
})));
|
|
4630
|
+
}))));
|
|
4407
4631
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
4408
4632
|
var nextNum = getSafeProductNum(targetProduct.num + normalizedProduct.num);
|
|
4409
4633
|
tempOrder.products[matchedIndex] = _objectSpread(_objectSpread(_objectSpread({}, targetProduct), normalizedProduct), {}, {
|
|
@@ -4453,6 +4677,74 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4453
4677
|
return commitProductLine(shouldMerge);
|
|
4454
4678
|
}
|
|
4455
4679
|
|
|
4680
|
+
/**
|
|
4681
|
+
* booking 数量拆行时,若 Holder 数量与拆行数严格一致,则按下标分配。
|
|
4682
|
+
* 数量不一致时保持旧数据,避免猜测 Holder 与商品份数的对应关系。
|
|
4683
|
+
*/
|
|
4684
|
+
}, {
|
|
4685
|
+
key: "createSplitBookingLine",
|
|
4686
|
+
value: function createSplitBookingLine(product, booking, index, splitCount) {
|
|
4687
|
+
var _booking$metadata6, _ref62, _ref63, _bookingHolder$form_r, _booking$metadata7, _product$metadata10, _bookingHolder$name, _singleBooking$metada;
|
|
4688
|
+
var singleLine = cloneDeep(product);
|
|
4689
|
+
singleLine.num = 1;
|
|
4690
|
+
delete singleLine.product_quantity;
|
|
4691
|
+
var singleBooking = cloneDeep(booking);
|
|
4692
|
+
var bookingHolder = booking !== null && booking !== void 0 && booking.holder && _typeof(booking.holder) === 'object' ? booking.holder : null;
|
|
4693
|
+
var metadataHolder = booking !== null && booking !== void 0 && (_booking$metadata6 = booking.metadata) !== null && _booking$metadata6 !== void 0 && _booking$metadata6.holder && _typeof(booking.metadata.holder) === 'object' ? booking.metadata.holder : null;
|
|
4694
|
+
var rawHolderIds = (_ref62 = (_ref63 = (_bookingHolder$form_r = bookingHolder === null || bookingHolder === void 0 ? void 0 : bookingHolder.form_record) !== null && _bookingHolder$form_r !== void 0 ? _bookingHolder$form_r : booking === null || booking === void 0 || (_booking$metadata7 = booking.metadata) === null || _booking$metadata7 === void 0 ? void 0 : _booking$metadata7.holder_id) !== null && _ref63 !== void 0 ? _ref63 : metadataHolder === null || metadataHolder === void 0 ? void 0 : metadataHolder.form_record) !== null && _ref62 !== void 0 ? _ref62 : product === null || product === void 0 || (_product$metadata10 = product.metadata) === null || _product$metadata10 === void 0 ? void 0 : _product$metadata10.holder_id;
|
|
4695
|
+
var holderIds = (Array.isArray(rawHolderIds) ? rawHolderIds : [rawHolderIds]).map(function (holderId) {
|
|
4696
|
+
return holderId && _typeof(holderId) === 'object' ? holderId.form_record_id : holderId;
|
|
4697
|
+
}).filter(function (holderId) {
|
|
4698
|
+
return holderId !== undefined && holderId !== null && holderId !== '';
|
|
4699
|
+
});
|
|
4700
|
+
if (holderIds.length !== splitCount) {
|
|
4701
|
+
return {
|
|
4702
|
+
product: singleLine,
|
|
4703
|
+
booking: singleBooking
|
|
4704
|
+
};
|
|
4705
|
+
}
|
|
4706
|
+
var holderId = holderIds[index];
|
|
4707
|
+
var rawHolderName = (_bookingHolder$name = bookingHolder === null || bookingHolder === void 0 ? void 0 : bookingHolder.name) !== null && _bookingHolder$name !== void 0 ? _bookingHolder$name : metadataHolder === null || metadataHolder === void 0 ? void 0 : metadataHolder.name;
|
|
4708
|
+
var holderNames = Array.isArray(rawHolderName) ? rawHolderName.map(function (name) {
|
|
4709
|
+
return String(name || '').trim();
|
|
4710
|
+
}) : typeof rawHolderName === 'string' ? rawHolderName.split(',').map(function (name) {
|
|
4711
|
+
return name.trim();
|
|
4712
|
+
}) : [];
|
|
4713
|
+
var holderName = holderNames.length === splitCount ? holderNames[index] : undefined;
|
|
4714
|
+
var splitHolder = function splitHolder(holder) {
|
|
4715
|
+
return _objectSpread(_objectSpread({}, holder), {}, {
|
|
4716
|
+
form_record: [holderId]
|
|
4717
|
+
}, holderName ? {
|
|
4718
|
+
name: holderName
|
|
4719
|
+
} : Object.prototype.hasOwnProperty.call(holder, 'name') ? {
|
|
4720
|
+
name: undefined
|
|
4721
|
+
} : {});
|
|
4722
|
+
};
|
|
4723
|
+
singleLine.metadata = _objectSpread(_objectSpread({}, singleLine.metadata || {}), {}, {
|
|
4724
|
+
holder_id: [holderId]
|
|
4725
|
+
});
|
|
4726
|
+
if (singleLine._extend && _typeof(singleLine._extend) === 'object') {
|
|
4727
|
+
singleLine._extend = _objectSpread(_objectSpread({}, singleLine._extend), {}, {
|
|
4728
|
+
holder_id: [holderId]
|
|
4729
|
+
});
|
|
4730
|
+
}
|
|
4731
|
+
if (singleBooking.holder && _typeof(singleBooking.holder) === 'object') {
|
|
4732
|
+
singleBooking.holder = splitHolder(singleBooking.holder);
|
|
4733
|
+
}
|
|
4734
|
+
singleBooking.metadata = _objectSpread(_objectSpread({}, singleBooking.metadata || {}), {}, {
|
|
4735
|
+
holder_id: [holderId]
|
|
4736
|
+
}, (_singleBooking$metada = singleBooking.metadata) !== null && _singleBooking$metada !== void 0 && _singleBooking$metada.holder && _typeof(singleBooking.metadata.holder) === 'object' ? {
|
|
4737
|
+
holder: splitHolder(singleBooking.metadata.holder)
|
|
4738
|
+
} : {});
|
|
4739
|
+
if (Object.prototype.hasOwnProperty.call(singleBooking, 'holder_id')) {
|
|
4740
|
+
singleBooking.holder_id = [holderId];
|
|
4741
|
+
}
|
|
4742
|
+
return {
|
|
4743
|
+
product: singleLine,
|
|
4744
|
+
booking: singleBooking
|
|
4745
|
+
};
|
|
4746
|
+
}
|
|
4747
|
+
|
|
4456
4748
|
/**
|
|
4457
4749
|
* 添加商品行。带 booking 时强制独立行;num>1 时拆成多条 num=1 的 product+booking(对齐 BookingByStep / ticketBooking addService)。
|
|
4458
4750
|
*
|
|
@@ -4463,11 +4755,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4463
4755
|
}, {
|
|
4464
4756
|
key: "addProductToOrder",
|
|
4465
4757
|
value: (function () {
|
|
4466
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4758
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(product, booking, options) {
|
|
4467
4759
|
var _this30 = this;
|
|
4468
|
-
var tempOrder, salesNoteDrafts, mutationSnapshot, attachSalesNoteDrafts, rollbackProductAndNotesMutation, insertAfterProductUid, anchorIndex, insertAtIndex,
|
|
4469
|
-
return _regeneratorRuntime().wrap(function
|
|
4470
|
-
while (1) switch (
|
|
4760
|
+
var tempOrder, salesNoteDrafts, mutationSnapshot, attachSalesNoteDrafts, rollbackProductAndNotesMutation, insertAfterProductUid, anchorIndex, insertAtIndex, _ref64, _productRecord$num, productRecord, splitCount, i, splitLine, committedProduct, _committedProduct, _committedProduct2;
|
|
4761
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context25) {
|
|
4762
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
4471
4763
|
case 0:
|
|
4472
4764
|
tempOrder = this.ensureTempOrder();
|
|
4473
4765
|
salesNoteDrafts = ((options === null || options === void 0 ? void 0 : options.salesNotes) || []).map(function (draft) {
|
|
@@ -4517,100 +4809,97 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4517
4809
|
return uid !== undefined && uid !== null && String(uid) === String(insertAfterProductUid);
|
|
4518
4810
|
}) : -1;
|
|
4519
4811
|
insertAtIndex = anchorIndex >= 0 ? anchorIndex + 1 : undefined;
|
|
4520
|
-
|
|
4812
|
+
_context25.prev = 8;
|
|
4521
4813
|
if (!booking) {
|
|
4522
|
-
|
|
4814
|
+
_context25.next = 33;
|
|
4523
4815
|
break;
|
|
4524
4816
|
}
|
|
4525
4817
|
productRecord = product;
|
|
4526
|
-
splitCount = getSafeProductNum((
|
|
4818
|
+
splitCount = getSafeProductNum((_ref64 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref64 !== void 0 ? _ref64 : 1);
|
|
4527
4819
|
if (!(splitCount > 1)) {
|
|
4528
|
-
|
|
4820
|
+
_context25.next = 27;
|
|
4529
4821
|
break;
|
|
4530
4822
|
}
|
|
4531
4823
|
i = 0;
|
|
4532
4824
|
case 14:
|
|
4533
4825
|
if (!(i < splitCount)) {
|
|
4534
|
-
|
|
4826
|
+
_context25.next = 25;
|
|
4535
4827
|
break;
|
|
4536
4828
|
}
|
|
4537
|
-
|
|
4538
|
-
singleBooking = cloneDeep(booking);
|
|
4539
|
-
singleLine.num = 1;
|
|
4540
|
-
delete singleLine.product_quantity;
|
|
4829
|
+
splitLine = this.createSplitBookingLine(productRecord, booking, i, splitCount);
|
|
4541
4830
|
if (i > 0) {
|
|
4542
|
-
delete
|
|
4543
|
-
delete
|
|
4544
|
-
if (
|
|
4545
|
-
|
|
4546
|
-
delete
|
|
4547
|
-
delete
|
|
4831
|
+
delete splitLine.product.unique_identification_number;
|
|
4832
|
+
delete splitLine.product.identity_key;
|
|
4833
|
+
if (splitLine.product.metadata) {
|
|
4834
|
+
splitLine.product.metadata = _objectSpread({}, splitLine.product.metadata);
|
|
4835
|
+
delete splitLine.product.metadata.unique_identification_number;
|
|
4836
|
+
delete splitLine.product.metadata.identity_key;
|
|
4548
4837
|
}
|
|
4549
|
-
delete
|
|
4550
|
-
if (
|
|
4551
|
-
|
|
4552
|
-
delete
|
|
4838
|
+
delete splitLine.booking.booking_uid;
|
|
4839
|
+
if (splitLine.booking.metadata) {
|
|
4840
|
+
splitLine.booking.metadata = _objectSpread({}, splitLine.booking.metadata);
|
|
4841
|
+
delete splitLine.booking.metadata.unique_identification_number;
|
|
4553
4842
|
}
|
|
4554
4843
|
}
|
|
4555
|
-
|
|
4556
|
-
return this.appendProductLineToTempOrder(tempOrder,
|
|
4844
|
+
_context25.next = 19;
|
|
4845
|
+
return this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking, {
|
|
4557
4846
|
insertAtIndex: insertAtIndex,
|
|
4558
4847
|
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge
|
|
4559
4848
|
});
|
|
4560
|
-
case
|
|
4561
|
-
committedProduct =
|
|
4849
|
+
case 19:
|
|
4850
|
+
committedProduct = _context25.sent;
|
|
4562
4851
|
attachSalesNoteDrafts(committedProduct);
|
|
4563
4852
|
if (insertAtIndex !== undefined) insertAtIndex += 1;
|
|
4564
|
-
case
|
|
4853
|
+
case 22:
|
|
4565
4854
|
i += 1;
|
|
4566
|
-
|
|
4855
|
+
_context25.next = 14;
|
|
4567
4856
|
break;
|
|
4568
|
-
case
|
|
4569
|
-
|
|
4857
|
+
case 25:
|
|
4858
|
+
_context25.next = 31;
|
|
4570
4859
|
break;
|
|
4571
|
-
case
|
|
4572
|
-
|
|
4860
|
+
case 27:
|
|
4861
|
+
_context25.next = 29;
|
|
4573
4862
|
return this.appendProductLineToTempOrder(tempOrder, product, cloneDeep(booking), {
|
|
4574
4863
|
insertAtIndex: insertAtIndex,
|
|
4575
4864
|
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge
|
|
4576
4865
|
});
|
|
4577
|
-
case
|
|
4578
|
-
_committedProduct =
|
|
4866
|
+
case 29:
|
|
4867
|
+
_committedProduct = _context25.sent;
|
|
4579
4868
|
attachSalesNoteDrafts(_committedProduct);
|
|
4580
|
-
case
|
|
4581
|
-
|
|
4869
|
+
case 31:
|
|
4870
|
+
_context25.next = 37;
|
|
4582
4871
|
break;
|
|
4583
|
-
case
|
|
4584
|
-
|
|
4872
|
+
case 33:
|
|
4873
|
+
_context25.next = 35;
|
|
4585
4874
|
return this.appendProductLineToTempOrder(tempOrder, product, undefined, {
|
|
4586
4875
|
insertAtIndex: insertAtIndex,
|
|
4587
4876
|
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge
|
|
4588
4877
|
});
|
|
4589
|
-
case
|
|
4590
|
-
_committedProduct2 =
|
|
4878
|
+
case 35:
|
|
4879
|
+
_committedProduct2 = _context25.sent;
|
|
4591
4880
|
attachSalesNoteDrafts(_committedProduct2);
|
|
4592
|
-
case
|
|
4593
|
-
|
|
4881
|
+
case 37:
|
|
4882
|
+
_context25.next = 43;
|
|
4594
4883
|
break;
|
|
4595
|
-
case
|
|
4596
|
-
|
|
4597
|
-
|
|
4884
|
+
case 39:
|
|
4885
|
+
_context25.prev = 39;
|
|
4886
|
+
_context25.t0 = _context25["catch"](8);
|
|
4598
4887
|
rollbackProductAndNotesMutation();
|
|
4599
|
-
throw
|
|
4600
|
-
case
|
|
4601
|
-
|
|
4888
|
+
throw _context25.t0;
|
|
4889
|
+
case 43:
|
|
4890
|
+
_context25.next = 45;
|
|
4602
4891
|
return this.finalizeProductOrderMutation(tempOrder);
|
|
4603
|
-
case
|
|
4892
|
+
case 45:
|
|
4604
4893
|
this.logInfo('addProductToOrder success', {
|
|
4605
4894
|
product_id: product.product_id,
|
|
4606
4895
|
with_booking: !!booking
|
|
4607
4896
|
});
|
|
4608
|
-
return
|
|
4609
|
-
case
|
|
4897
|
+
return _context25.abrupt("return", tempOrder.products);
|
|
4898
|
+
case 47:
|
|
4610
4899
|
case "end":
|
|
4611
|
-
return
|
|
4900
|
+
return _context25.stop();
|
|
4612
4901
|
}
|
|
4613
|
-
},
|
|
4902
|
+
}, _callee23, this, [[8, 39]]);
|
|
4614
4903
|
}));
|
|
4615
4904
|
function addProductToOrder(_x23, _x24, _x25) {
|
|
4616
4905
|
return _addProductToOrder.apply(this, arguments);
|
|
@@ -4630,101 +4919,99 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4630
4919
|
}, {
|
|
4631
4920
|
key: "addProductsToOrder",
|
|
4632
4921
|
value: (function () {
|
|
4633
|
-
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4634
|
-
var tempOrder, _iterator20, _step20, item, product, booking,
|
|
4635
|
-
return _regeneratorRuntime().wrap(function
|
|
4636
|
-
while (1) switch (
|
|
4922
|
+
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(items, options) {
|
|
4923
|
+
var tempOrder, _iterator20, _step20, item, product, booking, _ref65, _productRecord$num2, productRecord, splitCount, i, splitLine, _appendResult, appendResult;
|
|
4924
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context26) {
|
|
4925
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
4637
4926
|
case 0:
|
|
4638
4927
|
tempOrder = this.ensureTempOrder();
|
|
4639
4928
|
if (!(!Array.isArray(items) || items.length === 0)) {
|
|
4640
|
-
|
|
4929
|
+
_context26.next = 3;
|
|
4641
4930
|
break;
|
|
4642
4931
|
}
|
|
4643
|
-
return
|
|
4932
|
+
return _context26.abrupt("return", tempOrder.products);
|
|
4644
4933
|
case 3:
|
|
4645
4934
|
_iterator20 = _createForOfIteratorHelper(items || []);
|
|
4646
|
-
|
|
4935
|
+
_context26.prev = 4;
|
|
4647
4936
|
_iterator20.s();
|
|
4648
4937
|
case 6:
|
|
4649
4938
|
if ((_step20 = _iterator20.n()).done) {
|
|
4650
|
-
|
|
4939
|
+
_context26.next = 32;
|
|
4651
4940
|
break;
|
|
4652
4941
|
}
|
|
4653
4942
|
item = _step20.value;
|
|
4654
4943
|
product = item.product, booking = item.booking;
|
|
4655
4944
|
if (product) {
|
|
4656
|
-
|
|
4945
|
+
_context26.next = 11;
|
|
4657
4946
|
break;
|
|
4658
4947
|
}
|
|
4659
|
-
return
|
|
4948
|
+
return _context26.abrupt("continue", 30);
|
|
4660
4949
|
case 11:
|
|
4661
4950
|
if (!booking) {
|
|
4662
|
-
|
|
4951
|
+
_context26.next = 26;
|
|
4663
4952
|
break;
|
|
4664
4953
|
}
|
|
4665
4954
|
productRecord = product;
|
|
4666
|
-
splitCount = getSafeProductNum((
|
|
4955
|
+
splitCount = getSafeProductNum((_ref65 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref65 !== void 0 ? _ref65 : 1);
|
|
4667
4956
|
if (!(splitCount > 1)) {
|
|
4668
|
-
|
|
4957
|
+
_context26.next = 26;
|
|
4669
4958
|
break;
|
|
4670
4959
|
}
|
|
4671
4960
|
i = 0;
|
|
4672
4961
|
case 16:
|
|
4673
4962
|
if (!(i < splitCount)) {
|
|
4674
|
-
|
|
4963
|
+
_context26.next = 25;
|
|
4675
4964
|
break;
|
|
4676
4965
|
}
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
delete singleLine.product_quantity;
|
|
4680
|
-
_appendResult = this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
|
|
4966
|
+
splitLine = this.createSplitBookingLine(productRecord, booking, i, splitCount);
|
|
4967
|
+
_appendResult = this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking);
|
|
4681
4968
|
if (!_appendResult) {
|
|
4682
|
-
|
|
4969
|
+
_context26.next = 22;
|
|
4683
4970
|
break;
|
|
4684
4971
|
}
|
|
4685
|
-
|
|
4972
|
+
_context26.next = 22;
|
|
4686
4973
|
return _appendResult;
|
|
4687
|
-
case
|
|
4974
|
+
case 22:
|
|
4688
4975
|
i += 1;
|
|
4689
|
-
|
|
4976
|
+
_context26.next = 16;
|
|
4690
4977
|
break;
|
|
4691
|
-
case
|
|
4692
|
-
return
|
|
4693
|
-
case
|
|
4978
|
+
case 25:
|
|
4979
|
+
return _context26.abrupt("continue", 30);
|
|
4980
|
+
case 26:
|
|
4694
4981
|
appendResult = this.appendProductLineToTempOrder(tempOrder, product, booking);
|
|
4695
4982
|
if (!appendResult) {
|
|
4696
|
-
|
|
4983
|
+
_context26.next = 30;
|
|
4697
4984
|
break;
|
|
4698
4985
|
}
|
|
4699
|
-
|
|
4986
|
+
_context26.next = 30;
|
|
4700
4987
|
return appendResult;
|
|
4988
|
+
case 30:
|
|
4989
|
+
_context26.next = 6;
|
|
4990
|
+
break;
|
|
4701
4991
|
case 32:
|
|
4702
|
-
|
|
4992
|
+
_context26.next = 37;
|
|
4703
4993
|
break;
|
|
4704
4994
|
case 34:
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
|
|
4709
|
-
|
|
4710
|
-
_iterator20.e(_context25.t0);
|
|
4711
|
-
case 39:
|
|
4712
|
-
_context25.prev = 39;
|
|
4995
|
+
_context26.prev = 34;
|
|
4996
|
+
_context26.t0 = _context26["catch"](4);
|
|
4997
|
+
_iterator20.e(_context26.t0);
|
|
4998
|
+
case 37:
|
|
4999
|
+
_context26.prev = 37;
|
|
4713
5000
|
_iterator20.f();
|
|
4714
|
-
return
|
|
4715
|
-
case
|
|
4716
|
-
|
|
5001
|
+
return _context26.finish(37);
|
|
5002
|
+
case 40:
|
|
5003
|
+
_context26.next = 42;
|
|
4717
5004
|
return this.finalizeProductOrderMutation(tempOrder, options);
|
|
4718
|
-
case
|
|
5005
|
+
case 42:
|
|
4719
5006
|
this.logInfo('addProductsToOrder success', {
|
|
4720
5007
|
itemsCount: items.length
|
|
4721
5008
|
});
|
|
4722
|
-
return
|
|
4723
|
-
case
|
|
5009
|
+
return _context26.abrupt("return", tempOrder.products);
|
|
5010
|
+
case 44:
|
|
4724
5011
|
case "end":
|
|
4725
|
-
return
|
|
5012
|
+
return _context26.stop();
|
|
4726
5013
|
}
|
|
4727
|
-
},
|
|
5014
|
+
}, _callee24, this, [[4, 34, 37, 40]]);
|
|
4728
5015
|
}));
|
|
4729
5016
|
function addProductsToOrder(_x26, _x27) {
|
|
4730
5017
|
return _addProductsToOrder.apply(this, arguments);
|
|
@@ -4753,9 +5040,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4753
5040
|
}, {
|
|
4754
5041
|
key: "getBundleRuntimeIdentity",
|
|
4755
5042
|
value: function getBundleRuntimeIdentity(bundle) {
|
|
4756
|
-
var
|
|
5043
|
+
var _ref66, _bundle$bundle_id2, _ref67, _bundle$bundle_group_2, _ref68, _ref69, _bundle$bundle_produc3, _ref70, _bundle$bundle_varian3;
|
|
4757
5044
|
if (!bundle || _typeof(bundle) !== 'object') return '';
|
|
4758
|
-
return [(
|
|
5045
|
+
return [(_ref66 = (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id) !== null && _ref66 !== void 0 ? _ref66 : '', (_ref67 = (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id) !== null && _ref67 !== void 0 ? _ref67 : '', (_ref68 = (_ref69 = (_bundle$bundle_produc3 = bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle._bundle_product_id) !== null && _ref69 !== void 0 ? _ref69 : bundle.product_id) !== null && _ref68 !== void 0 ? _ref68 : '', (_ref70 = (_bundle$bundle_varian3 = bundle.bundle_variant_id) !== null && _bundle$bundle_varian3 !== void 0 ? _bundle$bundle_varian3 : bundle.product_variant_id) !== null && _ref70 !== void 0 ? _ref70 : 0].join('|');
|
|
4759
5046
|
}
|
|
4760
5047
|
}, {
|
|
4761
5048
|
key: "preservePersistedBundlePriceFields",
|
|
@@ -4906,13 +5193,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4906
5193
|
delete nextProduct.metadata.main_product_original_price;
|
|
4907
5194
|
delete nextProduct.metadata.price_schema_version;
|
|
4908
5195
|
} else if (callerChangesLineConfiguration && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
4909
|
-
var
|
|
5196
|
+
var _ref71, _targetProduct$metada10, _targetProduct$metada11, _ref72, _targetProduct$metada12, _targetProduct$metada13, _targetProduct$metada14;
|
|
4910
5197
|
// 仅 option / bundle 变化时,保留历史 source 和主商品折扣金额,
|
|
4911
5198
|
// 但必须让 original 与 selling 一起随新的 option 金额移动。
|
|
4912
5199
|
var previousOptionSum = sumOptionUnitPrice(getProductSkuOptions(targetProduct));
|
|
4913
5200
|
var nextOptionSum = sumOptionUnitPrice(getProductSkuOptions(nextProduct));
|
|
4914
|
-
var _previousMainOriginal = new Decimal(Number((
|
|
4915
|
-
var _previousMainSelling = new Decimal(Number((
|
|
5201
|
+
var _previousMainOriginal = new Decimal(Number((_ref71 = (_targetProduct$metada10 = (_targetProduct$metada11 = targetProduct.metadata) === null || _targetProduct$metada11 === void 0 ? void 0 : _targetProduct$metada11.main_product_original_price) !== null && _targetProduct$metada10 !== void 0 ? _targetProduct$metada10 : targetProduct.original_price) !== null && _ref71 !== void 0 ? _ref71 : 0) || 0);
|
|
5202
|
+
var _previousMainSelling = new Decimal(Number((_ref72 = (_targetProduct$metada12 = (_targetProduct$metada13 = targetProduct.metadata) === null || _targetProduct$metada13 === void 0 ? void 0 : _targetProduct$metada13.main_product_selling_price) !== null && _targetProduct$metada12 !== void 0 ? _targetProduct$metada12 : targetProduct.selling_price) !== null && _ref72 !== void 0 ? _ref72 : _previousMainOriginal.toNumber()) || 0);
|
|
4916
5203
|
var _preservedDiscount = _previousMainOriginal.minus(_previousMainSelling);
|
|
4917
5204
|
var previousSource = ((_targetProduct$metada14 = targetProduct.metadata) === null || _targetProduct$metada14 === void 0 ? void 0 : _targetProduct$metada14.source_product_price) != null ? new Decimal(Number(targetProduct.metadata.source_product_price) || 0) : _previousMainOriginal.minus(previousOptionSum);
|
|
4918
5205
|
var _nextMainOriginal = previousSource.plus(nextOptionSum);
|
|
@@ -4932,7 +5219,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4932
5219
|
}
|
|
4933
5220
|
// normalizeOrderProduct 幂等:v2 metadata 存在 → 保留 main_product_* 折扣重算 composite;
|
|
4934
5221
|
// 否则 → 把顶层 selling_price 视作 source,派生 main_product_* 并写 price_schema_version: 2。
|
|
4935
|
-
var normalizedProduct = mergeOrderProductDisplayFields(nextProduct, normalizeOrderProduct(nextProduct));
|
|
5222
|
+
var normalizedProduct = this.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(nextProduct, normalizeOrderProduct(nextProduct)));
|
|
4936
5223
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
4937
5224
|
var preservedBookingUid = nextProduct.booking_uid || ((_nextProduct$metadata = nextProduct.metadata) === null || _nextProduct$metadata === void 0 ? void 0 : _nextProduct$metadata.booking_uid) || targetProduct.booking_uid || ((_targetProduct$metada15 = targetProduct.metadata) === null || _targetProduct$metada15 === void 0 ? void 0 : _targetProduct$metada15.booking_uid);
|
|
4938
5225
|
if (!booking && preservedBookingUid) {
|
|
@@ -4971,35 +5258,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4971
5258
|
}, {
|
|
4972
5259
|
key: "updateOrderProduct",
|
|
4973
5260
|
value: function () {
|
|
4974
|
-
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4975
|
-
var tempOrder, updatedProductUid;
|
|
4976
|
-
return _regeneratorRuntime().wrap(function
|
|
4977
|
-
while (1) switch (
|
|
5261
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
|
|
5262
|
+
var tempOrder, updatedProductUid, promotionPayload;
|
|
5263
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context27) {
|
|
5264
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
4978
5265
|
case 0:
|
|
4979
5266
|
tempOrder = this.ensureTempOrder();
|
|
4980
5267
|
updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
4981
|
-
|
|
4982
|
-
return this.
|
|
5268
|
+
_context27.next = 4;
|
|
5269
|
+
return this.evaluatePromotion();
|
|
4983
5270
|
case 4:
|
|
5271
|
+
promotionPayload = _context27.sent;
|
|
4984
5272
|
this.applyDiscount({
|
|
4985
5273
|
reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
|
|
4986
5274
|
});
|
|
4987
5275
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4988
|
-
|
|
5276
|
+
_context27.next = 9;
|
|
4989
5277
|
return this.recalculateSummary({
|
|
4990
5278
|
createIfMissing: true
|
|
4991
5279
|
});
|
|
4992
|
-
case
|
|
5280
|
+
case 9:
|
|
4993
5281
|
this.persistTempOrder();
|
|
5282
|
+
this.emitPromotionApplied(promotionPayload);
|
|
4994
5283
|
this.logInfo('updateOrderProduct success', {
|
|
4995
5284
|
params: params
|
|
4996
5285
|
});
|
|
4997
|
-
return
|
|
4998
|
-
case
|
|
5286
|
+
return _context27.abrupt("return", tempOrder.products);
|
|
5287
|
+
case 13:
|
|
4999
5288
|
case "end":
|
|
5000
|
-
return
|
|
5289
|
+
return _context27.stop();
|
|
5001
5290
|
}
|
|
5002
|
-
},
|
|
5291
|
+
}, _callee25, this);
|
|
5003
5292
|
}));
|
|
5004
5293
|
function updateOrderProduct(_x28) {
|
|
5005
5294
|
return _updateOrderProduct.apply(this, arguments);
|
|
@@ -5009,18 +5298,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5009
5298
|
}, {
|
|
5010
5299
|
key: "updateOrderProducts",
|
|
5011
5300
|
value: function () {
|
|
5012
|
-
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5301
|
+
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(paramsList) {
|
|
5013
5302
|
var _this32 = this;
|
|
5014
5303
|
var tempOrder, reapplyBookingDiscountProductUids;
|
|
5015
|
-
return _regeneratorRuntime().wrap(function
|
|
5016
|
-
while (1) switch (
|
|
5304
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context28) {
|
|
5305
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
5017
5306
|
case 0:
|
|
5018
5307
|
tempOrder = this.ensureTempOrder();
|
|
5019
5308
|
if (paramsList.length) {
|
|
5020
|
-
|
|
5309
|
+
_context28.next = 3;
|
|
5021
5310
|
break;
|
|
5022
5311
|
}
|
|
5023
|
-
return
|
|
5312
|
+
return _context28.abrupt("return", tempOrder.products);
|
|
5024
5313
|
case 3:
|
|
5025
5314
|
reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
|
|
5026
5315
|
var updatedProductUid = _this32.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
@@ -5030,7 +5319,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5030
5319
|
}
|
|
5031
5320
|
return acc;
|
|
5032
5321
|
}, []);
|
|
5033
|
-
|
|
5322
|
+
_context28.next = 6;
|
|
5034
5323
|
return this.finalizeAfterProductsMutation(tempOrder, {
|
|
5035
5324
|
reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
|
|
5036
5325
|
});
|
|
@@ -5038,12 +5327,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5038
5327
|
this.logInfo('updateOrderProduct success', {
|
|
5039
5328
|
paramsList: paramsList
|
|
5040
5329
|
});
|
|
5041
|
-
return
|
|
5330
|
+
return _context28.abrupt("return", tempOrder.products);
|
|
5042
5331
|
case 8:
|
|
5043
5332
|
case "end":
|
|
5044
|
-
return
|
|
5333
|
+
return _context28.stop();
|
|
5045
5334
|
}
|
|
5046
|
-
},
|
|
5335
|
+
}, _callee26, this);
|
|
5047
5336
|
}));
|
|
5048
5337
|
function updateOrderProducts(_x29) {
|
|
5049
5338
|
return _updateOrderProducts.apply(this, arguments);
|
|
@@ -5053,11 +5342,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5053
5342
|
}, {
|
|
5054
5343
|
key: "updateOrderProductQuantity",
|
|
5055
5344
|
value: function () {
|
|
5056
|
-
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5345
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
|
|
5057
5346
|
var _targetProduct$metada17;
|
|
5058
|
-
var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct;
|
|
5059
|
-
return _regeneratorRuntime().wrap(function
|
|
5060
|
-
while (1) switch (
|
|
5347
|
+
var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct, settlementSnapshot, currencyProductId, asset, requiredAmount, balance, isVirtualSettlement, promotionPayload;
|
|
5348
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context29) {
|
|
5349
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
5061
5350
|
case 0:
|
|
5062
5351
|
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;
|
|
5063
5352
|
tempOrder = this.ensureTempOrder();
|
|
@@ -5087,40 +5376,83 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5087
5376
|
productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
|
|
5088
5377
|
}
|
|
5089
5378
|
if (!(productIndex === -1)) {
|
|
5090
|
-
|
|
5379
|
+
_context29.next = 13;
|
|
5091
5380
|
break;
|
|
5092
5381
|
}
|
|
5093
5382
|
throw new Error('[Order] 目标商品不存在,无法更新数量');
|
|
5094
5383
|
case 13:
|
|
5095
5384
|
targetProduct = tempOrder.products[productIndex];
|
|
5096
|
-
normalizedProduct = normalizeOrderProduct(_objectSpread(_objectSpread({}, targetProduct), {}, {
|
|
5385
|
+
normalizedProduct = this.normalizeVirtualSettlementProductIfEnabled(normalizeOrderProduct(_objectSpread(_objectSpread({}, targetProduct), {}, {
|
|
5097
5386
|
num: getSafeProductNum(num),
|
|
5098
5387
|
metadata: _objectSpread(_objectSpread({}, targetProduct.metadata || {}), {}, {
|
|
5099
5388
|
unique_identification_number: ((_targetProduct$metada17 = targetProduct.metadata) === null || _targetProduct$metada17 === void 0 ? void 0 : _targetProduct$metada17.unique_identification_number) || unique_identification_number
|
|
5100
5389
|
})
|
|
5101
|
-
}));
|
|
5390
|
+
})));
|
|
5102
5391
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
5392
|
+
settlementSnapshot = getSelectedSettlementSnapshot(normalizedProduct);
|
|
5393
|
+
if (!(this.isMultiCurrencySettlementEnabled() && (settlementSnapshot === null || settlementSnapshot === void 0 ? void 0 : settlementSnapshot.settlement_type) === 'virtual_currency' && tempOrder.customer_id && Number(tempOrder.customer_id) !== 1)) {
|
|
5394
|
+
_context29.next = 26;
|
|
5395
|
+
break;
|
|
5396
|
+
}
|
|
5397
|
+
currencyProductId = Number(settlementSnapshot.currency_product_id);
|
|
5398
|
+
asset = (this.store.virtualCurrencyList || []).find(function (item) {
|
|
5399
|
+
return Number(item === null || item === void 0 ? void 0 : item.product_id) === currencyProductId;
|
|
5400
|
+
});
|
|
5401
|
+
if (asset) {
|
|
5402
|
+
_context29.next = 22;
|
|
5403
|
+
break;
|
|
5404
|
+
}
|
|
5405
|
+
throw new VirtualCurrencyAssetNotFoundError(currencyProductId);
|
|
5406
|
+
case 22:
|
|
5407
|
+
requiredAmount = tempOrder.products.reduce(function (sum, item, index) {
|
|
5408
|
+
var current = index === productIndex ? normalizedProduct : item;
|
|
5409
|
+
var currentSnapshot = getSelectedSettlementSnapshot(current);
|
|
5410
|
+
return sum.plus(new Decimal((currentSnapshot === null || currentSnapshot === void 0 ? void 0 : currentSnapshot.price) || current.selling_price || 0).times(current.num || 1));
|
|
5411
|
+
}, new Decimal(0));
|
|
5412
|
+
balance = new Decimal(asset.balance || 0);
|
|
5413
|
+
if (!balance.lt(requiredAmount)) {
|
|
5414
|
+
_context29.next = 26;
|
|
5415
|
+
break;
|
|
5416
|
+
}
|
|
5417
|
+
throw new VirtualCurrencyBalanceError(balance.toFixed(2), requiredAmount.toFixed(2));
|
|
5418
|
+
case 26:
|
|
5103
5419
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5420
|
+
this.prepareVirtualSettlementTempOrder(tempOrder);
|
|
5421
|
+
isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder);
|
|
5422
|
+
if (isVirtualSettlement) {
|
|
5423
|
+
_context29.next = 35;
|
|
5424
|
+
break;
|
|
5425
|
+
}
|
|
5426
|
+
_context29.next = 32;
|
|
5427
|
+
return this.evaluatePromotion();
|
|
5428
|
+
case 32:
|
|
5429
|
+
_context29.t0 = _context29.sent;
|
|
5430
|
+
_context29.next = 36;
|
|
5431
|
+
break;
|
|
5432
|
+
case 35:
|
|
5433
|
+
_context29.t0 = null;
|
|
5434
|
+
case 36:
|
|
5435
|
+
promotionPayload = _context29.t0;
|
|
5436
|
+
if (!isVirtualSettlement) {
|
|
5437
|
+
this.applyDiscount();
|
|
5438
|
+
}
|
|
5108
5439
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
5109
|
-
|
|
5440
|
+
_context29.next = 41;
|
|
5110
5441
|
return this.recalculateSummary({
|
|
5111
5442
|
createIfMissing: true
|
|
5112
5443
|
});
|
|
5113
|
-
case
|
|
5444
|
+
case 41:
|
|
5114
5445
|
this.persistTempOrder();
|
|
5446
|
+
this.emitPromotionApplied(promotionPayload);
|
|
5115
5447
|
this.logInfo('updateOrderProductQuantity success', {
|
|
5116
5448
|
params: params
|
|
5117
5449
|
});
|
|
5118
|
-
return
|
|
5119
|
-
case
|
|
5450
|
+
return _context29.abrupt("return", tempOrder.products);
|
|
5451
|
+
case 45:
|
|
5120
5452
|
case "end":
|
|
5121
|
-
return
|
|
5453
|
+
return _context29.stop();
|
|
5122
5454
|
}
|
|
5123
|
-
},
|
|
5455
|
+
}, _callee27, this);
|
|
5124
5456
|
}));
|
|
5125
5457
|
function updateOrderProductQuantity(_x30) {
|
|
5126
5458
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
@@ -5163,29 +5495,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5163
5495
|
}, {
|
|
5164
5496
|
key: "finalizeAfterProductsMutation",
|
|
5165
5497
|
value: (function () {
|
|
5166
|
-
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5167
|
-
|
|
5168
|
-
|
|
5498
|
+
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(tempOrder, options) {
|
|
5499
|
+
var promotionPayload;
|
|
5500
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context30) {
|
|
5501
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
5169
5502
|
case 0:
|
|
5170
5503
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
5171
|
-
|
|
5172
|
-
return this.
|
|
5504
|
+
_context30.next = 3;
|
|
5505
|
+
return this.evaluatePromotion();
|
|
5173
5506
|
case 3:
|
|
5507
|
+
promotionPayload = _context30.sent;
|
|
5174
5508
|
this.applyDiscount({
|
|
5175
5509
|
reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids
|
|
5176
5510
|
});
|
|
5177
5511
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
5178
|
-
|
|
5512
|
+
_context30.next = 8;
|
|
5179
5513
|
return this.recalculateSummary({
|
|
5180
5514
|
createIfMissing: true
|
|
5181
5515
|
});
|
|
5182
|
-
case 7:
|
|
5183
|
-
this.persistTempOrder();
|
|
5184
5516
|
case 8:
|
|
5517
|
+
this.persistTempOrder();
|
|
5518
|
+
this.emitPromotionApplied(promotionPayload);
|
|
5519
|
+
case 10:
|
|
5185
5520
|
case "end":
|
|
5186
|
-
return
|
|
5521
|
+
return _context30.stop();
|
|
5187
5522
|
}
|
|
5188
|
-
},
|
|
5523
|
+
}, _callee28, this);
|
|
5189
5524
|
}));
|
|
5190
5525
|
function finalizeAfterProductsMutation(_x31, _x32) {
|
|
5191
5526
|
return _finalizeAfterProductsMutation.apply(this, arguments);
|
|
@@ -5202,18 +5537,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5202
5537
|
}, {
|
|
5203
5538
|
key: "removeProductsFromOrder",
|
|
5204
5539
|
value: (function () {
|
|
5205
|
-
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5540
|
+
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(identities, options) {
|
|
5206
5541
|
var _this33 = this;
|
|
5207
5542
|
var tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
|
|
5208
|
-
return _regeneratorRuntime().wrap(function
|
|
5209
|
-
while (1) switch (
|
|
5543
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context32) {
|
|
5544
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
5210
5545
|
case 0:
|
|
5211
5546
|
tempOrder = this.ensureTempOrder();
|
|
5212
5547
|
if (identities.length) {
|
|
5213
|
-
|
|
5548
|
+
_context32.next = 3;
|
|
5214
5549
|
break;
|
|
5215
5550
|
}
|
|
5216
|
-
return
|
|
5551
|
+
return _context32.abrupt("return", tempOrder.products);
|
|
5217
5552
|
case 3:
|
|
5218
5553
|
// 商品删除会同步删除以商品行为主关系的 Notes;快照不完整时禁止产生孤儿 Relation。
|
|
5219
5554
|
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
@@ -5246,22 +5581,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5246
5581
|
}
|
|
5247
5582
|
linkedBookingUidsToRemove = new Set();
|
|
5248
5583
|
_iterator21 = _createForOfIteratorHelper(matchedProducts);
|
|
5249
|
-
|
|
5584
|
+
_context32.prev = 16;
|
|
5250
5585
|
_loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
|
|
5251
5586
|
var _metadata11, _metadata12, _metadata13, _metadata14;
|
|
5252
5587
|
var product, productUid, productBookingUid, isAddTimeProduct;
|
|
5253
|
-
return _regeneratorRuntime().wrap(function _loop3$(
|
|
5254
|
-
while (1) switch (
|
|
5588
|
+
return _regeneratorRuntime().wrap(function _loop3$(_context31) {
|
|
5589
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
5255
5590
|
case 0:
|
|
5256
5591
|
product = _step21.value;
|
|
5257
5592
|
productUid = (product === null || product === void 0 || (_metadata11 = product.metadata) === null || _metadata11 === void 0 ? void 0 : _metadata11.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
5258
5593
|
productBookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_metadata12 = product.metadata) === null || _metadata12 === void 0 ? void 0 : _metadata12.booking_uid);
|
|
5259
5594
|
isAddTimeProduct = (product === null || product === void 0 || (_metadata13 = product.metadata) === null || _metadata13 === void 0 ? void 0 : _metadata13.product_add_schedule_time) !== undefined && (product === null || product === void 0 || (_metadata14 = product.metadata) === null || _metadata14 === void 0 ? void 0 : _metadata14.product_add_schedule_time) !== null;
|
|
5260
5595
|
if (!isAddTimeProduct) {
|
|
5261
|
-
|
|
5596
|
+
_context31.next = 6;
|
|
5262
5597
|
break;
|
|
5263
5598
|
}
|
|
5264
|
-
return
|
|
5599
|
+
return _context31.abrupt("return", 1);
|
|
5265
5600
|
case 6:
|
|
5266
5601
|
if (productBookingUid !== undefined && productBookingUid !== null && productBookingUid !== '') {
|
|
5267
5602
|
linkedBookingUidsToRemove.add(String(productBookingUid));
|
|
@@ -5276,37 +5611,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5276
5611
|
}
|
|
5277
5612
|
case 8:
|
|
5278
5613
|
case "end":
|
|
5279
|
-
return
|
|
5614
|
+
return _context31.stop();
|
|
5280
5615
|
}
|
|
5281
5616
|
}, _loop3);
|
|
5282
5617
|
});
|
|
5283
5618
|
_iterator21.s();
|
|
5284
5619
|
case 19:
|
|
5285
5620
|
if ((_step21 = _iterator21.n()).done) {
|
|
5286
|
-
|
|
5621
|
+
_context32.next = 25;
|
|
5287
5622
|
break;
|
|
5288
5623
|
}
|
|
5289
|
-
return
|
|
5624
|
+
return _context32.delegateYield(_loop3(), "t0", 21);
|
|
5290
5625
|
case 21:
|
|
5291
|
-
if (!
|
|
5292
|
-
|
|
5626
|
+
if (!_context32.t0) {
|
|
5627
|
+
_context32.next = 23;
|
|
5293
5628
|
break;
|
|
5294
5629
|
}
|
|
5295
|
-
return
|
|
5630
|
+
return _context32.abrupt("continue", 23);
|
|
5296
5631
|
case 23:
|
|
5297
|
-
|
|
5632
|
+
_context32.next = 19;
|
|
5298
5633
|
break;
|
|
5299
5634
|
case 25:
|
|
5300
|
-
|
|
5635
|
+
_context32.next = 30;
|
|
5301
5636
|
break;
|
|
5302
5637
|
case 27:
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
_iterator21.e(
|
|
5638
|
+
_context32.prev = 27;
|
|
5639
|
+
_context32.t1 = _context32["catch"](16);
|
|
5640
|
+
_iterator21.e(_context32.t1);
|
|
5306
5641
|
case 30:
|
|
5307
|
-
|
|
5642
|
+
_context32.prev = 30;
|
|
5308
5643
|
_iterator21.f();
|
|
5309
|
-
return
|
|
5644
|
+
return _context32.finish(30);
|
|
5310
5645
|
case 33:
|
|
5311
5646
|
if (linkedBookingUidsToRemove.size > 0) {
|
|
5312
5647
|
// 删除主预约商品时,同步移除挂在同一 booking_uid 下的加时商品,避免残留孤儿行。
|
|
@@ -5334,18 +5669,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5334
5669
|
}
|
|
5335
5670
|
}
|
|
5336
5671
|
this.removeSalesNotesForMissingProductLines(tempOrder);
|
|
5337
|
-
|
|
5672
|
+
_context32.next = 38;
|
|
5338
5673
|
return this.finalizeAfterProductsMutation(tempOrder);
|
|
5339
5674
|
case 38:
|
|
5340
5675
|
this.logInfo('removeProductsFromOrder success', {
|
|
5341
5676
|
identities: identities
|
|
5342
5677
|
});
|
|
5343
|
-
return
|
|
5678
|
+
return _context32.abrupt("return", tempOrder.products);
|
|
5344
5679
|
case 40:
|
|
5345
5680
|
case "end":
|
|
5346
|
-
return
|
|
5681
|
+
return _context32.stop();
|
|
5347
5682
|
}
|
|
5348
|
-
},
|
|
5683
|
+
}, _callee29, this, [[16, 27, 30, 33]]);
|
|
5349
5684
|
}));
|
|
5350
5685
|
function removeProductsFromOrder(_x33, _x34) {
|
|
5351
5686
|
return _removeProductsFromOrder.apply(this, arguments);
|
|
@@ -5355,16 +5690,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5355
5690
|
}, {
|
|
5356
5691
|
key: "removeProductFromOrder",
|
|
5357
5692
|
value: function () {
|
|
5358
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5359
|
-
return _regeneratorRuntime().wrap(function
|
|
5360
|
-
while (1) switch (
|
|
5693
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(identity, options) {
|
|
5694
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context33) {
|
|
5695
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
5361
5696
|
case 0:
|
|
5362
|
-
return
|
|
5697
|
+
return _context33.abrupt("return", this.removeProductsFromOrder([identity], options));
|
|
5363
5698
|
case 1:
|
|
5364
5699
|
case "end":
|
|
5365
|
-
return
|
|
5700
|
+
return _context33.stop();
|
|
5366
5701
|
}
|
|
5367
|
-
},
|
|
5702
|
+
}, _callee30, this);
|
|
5368
5703
|
}));
|
|
5369
5704
|
function removeProductFromOrder(_x35, _x36) {
|
|
5370
5705
|
return _removeProductFromOrder.apply(this, arguments);
|
|
@@ -5378,15 +5713,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5378
5713
|
}, {
|
|
5379
5714
|
key: "clearOrderCartLines",
|
|
5380
5715
|
value: (function () {
|
|
5381
|
-
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5382
|
-
var tempOrder;
|
|
5383
|
-
return _regeneratorRuntime().wrap(function
|
|
5384
|
-
while (1) switch (
|
|
5716
|
+
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
|
|
5717
|
+
var tempOrder, promotionPayload;
|
|
5718
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context34) {
|
|
5719
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
5385
5720
|
case 0:
|
|
5386
5721
|
tempOrder = this.ensureTempOrder();
|
|
5387
5722
|
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
5388
5723
|
tempOrder.products = [];
|
|
5389
5724
|
tempOrder.bookings = [];
|
|
5725
|
+
releaseTempOrderSettlementState(tempOrder);
|
|
5390
5726
|
this.removeSalesNotesForMissingProductLines(tempOrder);
|
|
5391
5727
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
5392
5728
|
if (tempOrder._extend && _typeof(tempOrder._extend) === 'object') {
|
|
@@ -5394,51 +5730,111 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5394
5730
|
productsByUid: {}
|
|
5395
5731
|
});
|
|
5396
5732
|
}
|
|
5397
|
-
|
|
5398
|
-
return this.
|
|
5399
|
-
case
|
|
5733
|
+
_context34.next = 10;
|
|
5734
|
+
return this.evaluatePromotion();
|
|
5735
|
+
case 10:
|
|
5736
|
+
promotionPayload = _context34.sent;
|
|
5400
5737
|
this.applyDiscount();
|
|
5401
5738
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
5402
|
-
|
|
5739
|
+
_context34.next = 15;
|
|
5403
5740
|
return this.recalculateSummary({
|
|
5404
5741
|
createIfMissing: true
|
|
5405
5742
|
});
|
|
5406
|
-
case
|
|
5743
|
+
case 15:
|
|
5407
5744
|
this.persistTempOrder();
|
|
5745
|
+
this.emitPromotionApplied(promotionPayload);
|
|
5408
5746
|
this.logInfo('clearOrderCartLines success', {});
|
|
5409
|
-
return
|
|
5410
|
-
case
|
|
5747
|
+
return _context34.abrupt("return", tempOrder);
|
|
5748
|
+
case 19:
|
|
5411
5749
|
case "end":
|
|
5412
|
-
return
|
|
5750
|
+
return _context34.stop();
|
|
5413
5751
|
}
|
|
5414
|
-
},
|
|
5752
|
+
}, _callee31, this);
|
|
5415
5753
|
}));
|
|
5416
5754
|
function clearOrderCartLines() {
|
|
5417
5755
|
return _clearOrderCartLines.apply(this, arguments);
|
|
5418
5756
|
}
|
|
5419
5757
|
return clearOrderCartLines;
|
|
5758
|
+
}()
|
|
5759
|
+
/**
|
|
5760
|
+
* 切换购物车结算单位时清理所有会影响新币种的订单状态,但保留当前客户。
|
|
5761
|
+
*/
|
|
5762
|
+
)
|
|
5763
|
+
}, {
|
|
5764
|
+
key: "clearOrderForSettlementSwitch",
|
|
5765
|
+
value: (function () {
|
|
5766
|
+
var _clearOrderForSettlementSwitch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
|
|
5767
|
+
var _this$store$discount22, _this$store$discount23;
|
|
5768
|
+
var tempOrder;
|
|
5769
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context35) {
|
|
5770
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
5771
|
+
case 0:
|
|
5772
|
+
tempOrder = this.ensureTempOrder();
|
|
5773
|
+
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
5774
|
+
tempOrder.products = [];
|
|
5775
|
+
tempOrder.bookings = [];
|
|
5776
|
+
this.removeSalesNotesForMissingProductLines(tempOrder);
|
|
5777
|
+
tempOrder.discount_list = [];
|
|
5778
|
+
tempOrder.payments = [];
|
|
5779
|
+
tempOrder.refunds = [];
|
|
5780
|
+
tempOrder.shop_discount = '0.00';
|
|
5781
|
+
tempOrder.surcharges = [];
|
|
5782
|
+
releaseTempOrderSettlementState(tempOrder);
|
|
5783
|
+
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
5784
|
+
if (tempOrder._extend && _typeof(tempOrder._extend) === 'object') {
|
|
5785
|
+
tempOrder._extend = _objectSpread(_objectSpread({}, tempOrder._extend), {}, {
|
|
5786
|
+
productsByUid: {}
|
|
5787
|
+
});
|
|
5788
|
+
}
|
|
5789
|
+
_context35.next = 15;
|
|
5790
|
+
return (_this$store$discount22 = this.store.discount) === null || _this$store$discount22 === void 0 ? void 0 : _this$store$discount22.setDiscountList([]);
|
|
5791
|
+
case 15:
|
|
5792
|
+
_context35.next = 17;
|
|
5793
|
+
return (_this$store$discount23 = this.store.discount) === null || _this$store$discount23 === void 0 ? void 0 : _this$store$discount23.setOriginalDiscountList([]);
|
|
5794
|
+
case 17:
|
|
5795
|
+
this.hasActiveCustomerBoundDiscount = false;
|
|
5796
|
+
this.lastUnfulfilledPromotions = [];
|
|
5797
|
+
this.lastGiftActions = null;
|
|
5798
|
+
_context35.next = 22;
|
|
5799
|
+
return this.recalculateSummary({
|
|
5800
|
+
createIfMissing: true
|
|
5801
|
+
});
|
|
5802
|
+
case 22:
|
|
5803
|
+
this.persistTempOrder();
|
|
5804
|
+
this.logInfo('clearOrderForSettlementSwitch success', {});
|
|
5805
|
+
return _context35.abrupt("return", tempOrder);
|
|
5806
|
+
case 25:
|
|
5807
|
+
case "end":
|
|
5808
|
+
return _context35.stop();
|
|
5809
|
+
}
|
|
5810
|
+
}, _callee32, this);
|
|
5811
|
+
}));
|
|
5812
|
+
function clearOrderForSettlementSwitch() {
|
|
5813
|
+
return _clearOrderForSettlementSwitch.apply(this, arguments);
|
|
5814
|
+
}
|
|
5815
|
+
return clearOrderForSettlementSwitch;
|
|
5420
5816
|
}() // ─── TempOrder: 提交 ───
|
|
5421
5817
|
)
|
|
5422
5818
|
}, {
|
|
5423
5819
|
key: "buildCurrentSubmitPayloadForLocalPrint",
|
|
5424
5820
|
value: function buildCurrentSubmitPayloadForLocalPrint(params) {
|
|
5425
|
-
var _params$cacheId, _this$
|
|
5821
|
+
var _params$cacheId, _this$otherParams5, _ref73, _params$businessCode, _this$otherParams6, _this$otherParams7;
|
|
5426
5822
|
var tempOrder = this.ensureTempOrder();
|
|
5427
5823
|
this.persistTempOrder();
|
|
5428
5824
|
var payload = buildSubmitPayload({
|
|
5429
5825
|
tempOrder: tempOrder,
|
|
5430
5826
|
cacheId: (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId,
|
|
5431
|
-
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$
|
|
5432
|
-
businessCode: (
|
|
5827
|
+
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.platform),
|
|
5828
|
+
businessCode: (_ref73 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.businessCode) !== null && _ref73 !== void 0 ? _ref73 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.business_code,
|
|
5433
5829
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
5434
5830
|
type: params === null || params === void 0 ? void 0 : params.type,
|
|
5435
5831
|
summary: this.store.summary || createEmptySummary(),
|
|
5436
5832
|
enhance: function enhance(nextPayload) {
|
|
5437
|
-
var
|
|
5833
|
+
var _ref74, _tempOrder$order_numb, _ref75, _tempOrder$shop_order2, _ref76, _tempOrder$shop_full_;
|
|
5438
5834
|
return _objectSpread(_objectSpread({}, nextPayload), {}, {
|
|
5439
|
-
order_number: (
|
|
5440
|
-
shop_order_number: (
|
|
5441
|
-
shop_full_order_number: (
|
|
5835
|
+
order_number: (_ref74 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref74 !== void 0 ? _ref74 : null,
|
|
5836
|
+
shop_order_number: (_ref75 = (_tempOrder$shop_order2 = tempOrder.shop_order_number) !== null && _tempOrder$shop_order2 !== void 0 ? _tempOrder$shop_order2 : nextPayload.shop_order_number) !== null && _ref75 !== void 0 ? _ref75 : null,
|
|
5837
|
+
shop_full_order_number: (_ref76 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref76 !== void 0 ? _ref76 : null,
|
|
5442
5838
|
small_ticket_data_flag: 1
|
|
5443
5839
|
});
|
|
5444
5840
|
}
|
|
@@ -5449,17 +5845,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5449
5845
|
}, {
|
|
5450
5846
|
key: "applyLocalPrintOrderNumbers",
|
|
5451
5847
|
value: function () {
|
|
5452
|
-
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5848
|
+
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(order) {
|
|
5453
5849
|
var tempOrder, shopOrderNumber, shopFullOrderNumber;
|
|
5454
|
-
return _regeneratorRuntime().wrap(function
|
|
5455
|
-
while (1) switch (
|
|
5850
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context36) {
|
|
5851
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
5456
5852
|
case 0:
|
|
5457
5853
|
tempOrder = this.ensureTempOrder();
|
|
5458
5854
|
if (!(!order || _typeof(order) !== 'object')) {
|
|
5459
|
-
|
|
5855
|
+
_context36.next = 3;
|
|
5460
5856
|
break;
|
|
5461
5857
|
}
|
|
5462
|
-
return
|
|
5858
|
+
return _context36.abrupt("return", tempOrder);
|
|
5463
5859
|
case 3:
|
|
5464
5860
|
shopOrderNumber = order.shop_order_number;
|
|
5465
5861
|
shopFullOrderNumber = order.shop_full_order_number;
|
|
@@ -5470,15 +5866,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5470
5866
|
tempOrder.shop_full_order_number = String(shopFullOrderNumber);
|
|
5471
5867
|
}
|
|
5472
5868
|
this.persistTempOrder();
|
|
5473
|
-
|
|
5869
|
+
_context36.next = 10;
|
|
5474
5870
|
return this.saveDraft();
|
|
5475
5871
|
case 10:
|
|
5476
|
-
return
|
|
5872
|
+
return _context36.abrupt("return", tempOrder);
|
|
5477
5873
|
case 11:
|
|
5478
5874
|
case "end":
|
|
5479
|
-
return
|
|
5875
|
+
return _context36.stop();
|
|
5480
5876
|
}
|
|
5481
|
-
},
|
|
5877
|
+
}, _callee33, this);
|
|
5482
5878
|
}));
|
|
5483
5879
|
function applyLocalPrintOrderNumbers(_x37) {
|
|
5484
5880
|
return _applyLocalPrintOrderNumbers.apply(this, arguments);
|
|
@@ -5488,42 +5884,42 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5488
5884
|
}, {
|
|
5489
5885
|
key: "saveTempOrderAsDraft",
|
|
5490
5886
|
value: function () {
|
|
5491
|
-
var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5492
|
-
var _params$cacheId2, _this$
|
|
5887
|
+
var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
|
|
5888
|
+
var _params$cacheId2, _this$otherParams8, _this$otherParams9, _this$otherParams10, _params$type, _this$otherParams11, _payload$products;
|
|
5493
5889
|
var tempOrder, latestSummary, payload;
|
|
5494
|
-
return _regeneratorRuntime().wrap(function
|
|
5495
|
-
while (1) switch (
|
|
5890
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context37) {
|
|
5891
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
5496
5892
|
case 0:
|
|
5497
5893
|
tempOrder = this.ensureTempOrder();
|
|
5498
5894
|
this.ensureExternalSaleNumber(tempOrder);
|
|
5499
5895
|
this.persistTempOrder();
|
|
5500
|
-
|
|
5896
|
+
_context37.next = 5;
|
|
5501
5897
|
return this.recalculateSummary({
|
|
5502
5898
|
createIfMissing: true
|
|
5503
5899
|
});
|
|
5504
5900
|
case 5:
|
|
5505
|
-
|
|
5506
|
-
if (
|
|
5507
|
-
|
|
5901
|
+
_context37.t1 = _context37.sent;
|
|
5902
|
+
if (_context37.t1) {
|
|
5903
|
+
_context37.next = 8;
|
|
5508
5904
|
break;
|
|
5509
5905
|
}
|
|
5510
|
-
|
|
5906
|
+
_context37.t1 = this.store.summary;
|
|
5511
5907
|
case 8:
|
|
5512
|
-
|
|
5513
|
-
if (
|
|
5514
|
-
|
|
5908
|
+
_context37.t0 = _context37.t1;
|
|
5909
|
+
if (_context37.t0) {
|
|
5910
|
+
_context37.next = 11;
|
|
5515
5911
|
break;
|
|
5516
5912
|
}
|
|
5517
|
-
|
|
5913
|
+
_context37.t0 = createEmptySummary();
|
|
5518
5914
|
case 11:
|
|
5519
|
-
latestSummary =
|
|
5915
|
+
latestSummary = _context37.t0;
|
|
5520
5916
|
payload = buildSubmitPayload({
|
|
5521
5917
|
tempOrder: tempOrder,
|
|
5522
5918
|
cacheId: (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId,
|
|
5523
|
-
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$
|
|
5524
|
-
businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$
|
|
5919
|
+
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.platform),
|
|
5920
|
+
businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.businessCode) || ((_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.business_code) || tempOrder.business_code,
|
|
5525
5921
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
5526
|
-
type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$
|
|
5922
|
+
type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.type,
|
|
5527
5923
|
summary: latestSummary,
|
|
5528
5924
|
enhance: params === null || params === void 0 ? void 0 : params.enhancePayload
|
|
5529
5925
|
});
|
|
@@ -5537,15 +5933,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5537
5933
|
externalSaleNumber: payload.external_sale_number,
|
|
5538
5934
|
productsCount: ((_payload$products = payload.products) === null || _payload$products === void 0 ? void 0 : _payload$products.length) || 0
|
|
5539
5935
|
});
|
|
5540
|
-
return
|
|
5936
|
+
return _context37.abrupt("return", this.request.post('/order/sales/draft', payload, {
|
|
5541
5937
|
osServer: true,
|
|
5542
5938
|
customToast: function customToast() {}
|
|
5543
5939
|
}));
|
|
5544
5940
|
case 18:
|
|
5545
5941
|
case "end":
|
|
5546
|
-
return
|
|
5942
|
+
return _context37.stop();
|
|
5547
5943
|
}
|
|
5548
|
-
},
|
|
5944
|
+
}, _callee34, this);
|
|
5549
5945
|
}));
|
|
5550
5946
|
function saveTempOrderAsDraft(_x38) {
|
|
5551
5947
|
return _saveTempOrderAsDraft.apply(this, arguments);
|
|
@@ -5561,16 +5957,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5561
5957
|
}, {
|
|
5562
5958
|
key: "submitTempOrder",
|
|
5563
5959
|
value: (function () {
|
|
5564
|
-
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5565
|
-
return _regeneratorRuntime().wrap(function
|
|
5566
|
-
while (1) switch (
|
|
5960
|
+
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
|
|
5961
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context38) {
|
|
5962
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
5567
5963
|
case 0:
|
|
5568
|
-
return
|
|
5964
|
+
return _context38.abrupt("return", this.runSubmitTempOrder(params));
|
|
5569
5965
|
case 1:
|
|
5570
5966
|
case "end":
|
|
5571
|
-
return
|
|
5967
|
+
return _context38.stop();
|
|
5572
5968
|
}
|
|
5573
|
-
},
|
|
5969
|
+
}, _callee35, this);
|
|
5574
5970
|
}));
|
|
5575
5971
|
function submitTempOrder(_x39) {
|
|
5576
5972
|
return _submitTempOrder.apply(this, arguments);
|
|
@@ -5580,18 +5976,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5580
5976
|
}, {
|
|
5581
5977
|
key: "submitTempOrderAsync",
|
|
5582
5978
|
value: function () {
|
|
5583
|
-
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5584
|
-
return _regeneratorRuntime().wrap(function
|
|
5585
|
-
while (1) switch (
|
|
5979
|
+
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
|
|
5980
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context39) {
|
|
5981
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
5586
5982
|
case 0:
|
|
5587
|
-
return
|
|
5983
|
+
return _context39.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
5588
5984
|
syncMode: true
|
|
5589
5985
|
})));
|
|
5590
5986
|
case 1:
|
|
5591
5987
|
case "end":
|
|
5592
|
-
return
|
|
5988
|
+
return _context39.stop();
|
|
5593
5989
|
}
|
|
5594
|
-
},
|
|
5990
|
+
}, _callee36, this);
|
|
5595
5991
|
}));
|
|
5596
5992
|
function submitTempOrderAsync(_x40) {
|
|
5597
5993
|
return _submitTempOrderAsync.apply(this, arguments);
|
|
@@ -5601,16 +5997,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5601
5997
|
}, {
|
|
5602
5998
|
key: "runSubmitTempOrder",
|
|
5603
5999
|
value: function () {
|
|
5604
|
-
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5605
|
-
var _params$cacheId3, _this$
|
|
5606
|
-
var tempOrder, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, isLocalPendingSubmit, salesNotesState, submittedOrderId, resultRecord;
|
|
5607
|
-
return _regeneratorRuntime().wrap(function
|
|
5608
|
-
while (1) switch (
|
|
6000
|
+
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
|
|
6001
|
+
var _params$cacheId3, _this$otherParams12, _ref77, _ref78, _submitSnapshot$busin, _this$otherParams13, _this$otherParams14, _submitSnapshot$type;
|
|
6002
|
+
var tempOrder, isOnlineStorePlatform, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, shouldOverridePaymentStatus, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, isLocalPendingSubmit, salesNotesState, submittedOrderId, resultRecord;
|
|
6003
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context40) {
|
|
6004
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
5609
6005
|
case 0:
|
|
5610
6006
|
tempOrder = this.ensureTempOrder();
|
|
6007
|
+
this.prepareVirtualSettlementTempOrder(tempOrder);
|
|
6008
|
+
isOnlineStorePlatform = this.isOnlineStorePlatform();
|
|
5611
6009
|
shouldConfirmPendingVoucherPayments = (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== false;
|
|
5612
6010
|
hasPaymentOverride = (params === null || params === void 0 ? void 0 : params.payments) !== undefined;
|
|
5613
|
-
|
|
6011
|
+
if (hasPaymentOverride) {
|
|
6012
|
+
preparedPaymentOverride = isOnlineStorePlatform ? (params === null || params === void 0 ? void 0 : params.payments) || [] : this.prepareVoucherPaymentsForSubmit((params === null || params === void 0 ? void 0 : params.payments) || [], shouldConfirmPendingVoucherPayments);
|
|
6013
|
+
}
|
|
5614
6014
|
if (!hasPaymentOverride) {
|
|
5615
6015
|
if (shouldConfirmPendingVoucherPayments) {
|
|
5616
6016
|
this.confirmPendingVoucherPayments({
|
|
@@ -5625,33 +6025,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5625
6025
|
}
|
|
5626
6026
|
}
|
|
5627
6027
|
this.persistTempOrder();
|
|
5628
|
-
|
|
6028
|
+
_context40.next = 10;
|
|
5629
6029
|
return this.recalculateSummary({
|
|
5630
6030
|
createIfMissing: true
|
|
5631
6031
|
});
|
|
5632
|
-
case
|
|
5633
|
-
|
|
5634
|
-
if (
|
|
5635
|
-
|
|
6032
|
+
case 10:
|
|
6033
|
+
_context40.t1 = _context40.sent;
|
|
6034
|
+
if (_context40.t1) {
|
|
6035
|
+
_context40.next = 13;
|
|
5636
6036
|
break;
|
|
5637
6037
|
}
|
|
5638
|
-
|
|
5639
|
-
case
|
|
5640
|
-
|
|
5641
|
-
if (
|
|
5642
|
-
|
|
6038
|
+
_context40.t1 = this.store.summary;
|
|
6039
|
+
case 13:
|
|
6040
|
+
_context40.t0 = _context40.t1;
|
|
6041
|
+
if (_context40.t0) {
|
|
6042
|
+
_context40.next = 16;
|
|
5643
6043
|
break;
|
|
5644
6044
|
}
|
|
5645
|
-
|
|
5646
|
-
case
|
|
5647
|
-
latestSummary =
|
|
6045
|
+
_context40.t0 = createEmptySummary();
|
|
6046
|
+
case 16:
|
|
6047
|
+
latestSummary = _context40.t0;
|
|
5648
6048
|
effectiveCacheId = (_params$cacheId3 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId3 !== void 0 ? _params$cacheId3 : this.cacheId;
|
|
5649
6049
|
hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
|
|
6050
|
+
shouldOverridePaymentStatus = hasPaymentStatusOverride && !isOnlineStorePlatform && !shouldConfirmPendingVoucherPayments;
|
|
5650
6051
|
hasSmallTicketDataFlagOverride = (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined;
|
|
5651
6052
|
enhancePayload = hasPaymentOverride || hasPaymentStatusOverride || hasSmallTicketDataFlagOverride || params !== null && params !== void 0 && params.enhancePayload ? function (payload, ctx) {
|
|
5652
6053
|
var nextPayload = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, payload), hasPaymentOverride ? {
|
|
5653
6054
|
payments: preparedPaymentOverride || []
|
|
5654
|
-
} : {}),
|
|
6055
|
+
} : {}), shouldOverridePaymentStatus ? {
|
|
5655
6056
|
payment_status: params === null || params === void 0 ? void 0 : params.paymentStatus
|
|
5656
6057
|
} : {}), hasSmallTicketDataFlagOverride ? {
|
|
5657
6058
|
small_ticket_data_flag: params === null || params === void 0 ? void 0 : params.smallTicketDataFlag
|
|
@@ -5663,12 +6064,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5663
6064
|
payload = buildSubmitPayload({
|
|
5664
6065
|
tempOrder: tempOrder,
|
|
5665
6066
|
cacheId: effectiveCacheId,
|
|
5666
|
-
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$
|
|
5667
|
-
businessCode: (
|
|
6067
|
+
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.platform),
|
|
6068
|
+
businessCode: (_ref77 = (_ref78 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref78 !== void 0 ? _ref78 : (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.businessCode) !== null && _ref77 !== void 0 ? _ref77 : (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.business_code,
|
|
5668
6069
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
5669
6070
|
type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
|
|
5670
6071
|
summary: latestSummary,
|
|
5671
6072
|
request_unique_idempotency_token: params === null || params === void 0 ? void 0 : params.request_unique_idempotency_token,
|
|
6073
|
+
includePaymentStatus: !isOnlineStorePlatform,
|
|
5672
6074
|
enhance: enhancePayload
|
|
5673
6075
|
});
|
|
5674
6076
|
if (params !== null && params !== void 0 && params.syncMode) {
|
|
@@ -5678,10 +6080,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5678
6080
|
if (!payload.created_at) {
|
|
5679
6081
|
payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
5680
6082
|
}
|
|
5681
|
-
|
|
6083
|
+
_context40.next = 28;
|
|
5682
6084
|
return this.saveDraft();
|
|
5683
|
-
case
|
|
5684
|
-
|
|
6085
|
+
case 28:
|
|
6086
|
+
_context40.prev = 28;
|
|
5685
6087
|
this.logInfo('submitTempOrder calling sales checkout', {
|
|
5686
6088
|
orderId: payload.order_id,
|
|
5687
6089
|
externalSaleNumber: payload.external_sale_number,
|
|
@@ -5691,44 +6093,44 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5691
6093
|
smallTicketDataFlag: payload.small_ticket_data_flag,
|
|
5692
6094
|
syncMode: payload.sync_mode
|
|
5693
6095
|
});
|
|
5694
|
-
|
|
6096
|
+
_context40.next = 32;
|
|
5695
6097
|
return this.submitSalesOrder({
|
|
5696
6098
|
query: payload
|
|
5697
6099
|
});
|
|
5698
|
-
case 29:
|
|
5699
|
-
result = _context38.sent;
|
|
5700
|
-
_context38.next = 42;
|
|
5701
|
-
break;
|
|
5702
6100
|
case 32:
|
|
5703
|
-
|
|
5704
|
-
|
|
5705
|
-
|
|
6101
|
+
result = _context40.sent;
|
|
6102
|
+
_context40.next = 45;
|
|
6103
|
+
break;
|
|
6104
|
+
case 35:
|
|
6105
|
+
_context40.prev = 35;
|
|
6106
|
+
_context40.t2 = _context40["catch"](28);
|
|
6107
|
+
backendErrorResponse = this.extractSubmitErrorResponse(_context40.t2);
|
|
5706
6108
|
if (!backendErrorResponse) {
|
|
5707
|
-
|
|
6109
|
+
_context40.next = 42;
|
|
5708
6110
|
break;
|
|
5709
6111
|
}
|
|
5710
6112
|
this.store.syncState = 'failed';
|
|
5711
6113
|
this.logSubmitBackendRejected(backendErrorResponse, payload);
|
|
5712
|
-
return
|
|
5713
|
-
case
|
|
6114
|
+
return _context40.abrupt("return", backendErrorResponse);
|
|
6115
|
+
case 42:
|
|
5714
6116
|
this.store.syncState = 'failed';
|
|
5715
6117
|
this.logError('submitTempOrder failed', {
|
|
5716
|
-
error:
|
|
6118
|
+
error: _context40.t2 instanceof Error ? _context40.t2.message : String(_context40.t2),
|
|
5717
6119
|
orderId: payload.order_id,
|
|
5718
6120
|
externalSaleNumber: payload.external_sale_number,
|
|
5719
6121
|
paymentStatus: payload.payment_status,
|
|
5720
6122
|
paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
|
|
5721
6123
|
});
|
|
5722
|
-
throw
|
|
5723
|
-
case
|
|
6124
|
+
throw _context40.t2;
|
|
6125
|
+
case 45:
|
|
5724
6126
|
if (!this.isSubmitResponseRejected(result)) {
|
|
5725
|
-
|
|
6127
|
+
_context40.next = 49;
|
|
5726
6128
|
break;
|
|
5727
6129
|
}
|
|
5728
6130
|
this.store.syncState = 'failed';
|
|
5729
6131
|
this.logSubmitBackendRejected(result, payload);
|
|
5730
|
-
return
|
|
5731
|
-
case
|
|
6132
|
+
return _context40.abrupt("return", result);
|
|
6133
|
+
case 49:
|
|
5732
6134
|
isLocalPendingSubmit = this.isLocalPendingSubmitResult(result); // need_sync=1 仅表示已进入本地同步队列,不能视为远端已确认 Notes。
|
|
5733
6135
|
if (Object.prototype.hasOwnProperty.call(payload, 'notes') && !isLocalPendingSubmit) {
|
|
5734
6136
|
salesNotesState = this.ensureSalesNotesRuntimeState(tempOrder);
|
|
@@ -5743,25 +6145,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5743
6145
|
})
|
|
5744
6146
|
});
|
|
5745
6147
|
if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
|
|
5746
|
-
|
|
6148
|
+
_context40.next = 58;
|
|
5747
6149
|
break;
|
|
5748
6150
|
}
|
|
5749
6151
|
tempOrder.order_id = submittedOrderId;
|
|
5750
6152
|
resultRecord = result;
|
|
5751
|
-
|
|
6153
|
+
_context40.next = 58;
|
|
5752
6154
|
return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
|
|
5753
|
-
case
|
|
6155
|
+
case 58:
|
|
5754
6156
|
if (isLocalPendingSubmit) {
|
|
5755
6157
|
this.store.syncState = 'local';
|
|
5756
6158
|
} else if (submittedOrderId === null || submittedOrderId === undefined) {
|
|
5757
6159
|
this.store.syncState = 'submitted';
|
|
5758
6160
|
}
|
|
5759
|
-
return
|
|
5760
|
-
case
|
|
6161
|
+
return _context40.abrupt("return", result);
|
|
6162
|
+
case 60:
|
|
5761
6163
|
case "end":
|
|
5762
|
-
return
|
|
6164
|
+
return _context40.stop();
|
|
5763
6165
|
}
|
|
5764
|
-
},
|
|
6166
|
+
}, _callee37, this, [[28, 35]]);
|
|
5765
6167
|
}));
|
|
5766
6168
|
function runSubmitTempOrder(_x41) {
|
|
5767
6169
|
return _runSubmitTempOrder.apply(this, arguments);
|
|
@@ -5771,10 +6173,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5771
6173
|
}, {
|
|
5772
6174
|
key: "markLocalOrderSynced",
|
|
5773
6175
|
value: function () {
|
|
5774
|
-
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6176
|
+
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(orderId, remoteOrder) {
|
|
5775
6177
|
var tempOrder;
|
|
5776
|
-
return _regeneratorRuntime().wrap(function
|
|
5777
|
-
while (1) switch (
|
|
6178
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context41) {
|
|
6179
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
5778
6180
|
case 0:
|
|
5779
6181
|
tempOrder = this.ensureTempOrder();
|
|
5780
6182
|
tempOrder.order_id = orderId;
|
|
@@ -5782,13 +6184,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5782
6184
|
this.store.lastOrderInfo = remoteOrder;
|
|
5783
6185
|
this.store.syncState = 'submitted';
|
|
5784
6186
|
this.persistTempOrder();
|
|
5785
|
-
|
|
6187
|
+
_context41.next = 8;
|
|
5786
6188
|
return this.saveDraft();
|
|
5787
6189
|
case 8:
|
|
5788
6190
|
case "end":
|
|
5789
|
-
return
|
|
6191
|
+
return _context41.stop();
|
|
5790
6192
|
}
|
|
5791
|
-
},
|
|
6193
|
+
}, _callee38, this);
|
|
5792
6194
|
}));
|
|
5793
6195
|
function markLocalOrderSynced(_x42, _x43) {
|
|
5794
6196
|
return _markLocalOrderSynced.apply(this, arguments);
|
|
@@ -5863,31 +6265,31 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5863
6265
|
}, {
|
|
5864
6266
|
key: "syncPaymentsToOrder",
|
|
5865
6267
|
value: function () {
|
|
5866
|
-
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6268
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
|
|
5867
6269
|
var _this35 = this,
|
|
5868
6270
|
_params$confirmPendin;
|
|
5869
6271
|
var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, enhancePayload, submitParams, submitResult;
|
|
5870
|
-
return _regeneratorRuntime().wrap(function
|
|
5871
|
-
while (1) switch (
|
|
6272
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context42) {
|
|
6273
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
5872
6274
|
case 0:
|
|
5873
6275
|
tempOrder = this.ensureTempOrder();
|
|
5874
6276
|
needsPaymentNumber = (params.payments || []).some(function (payment) {
|
|
5875
6277
|
return String(payment.payment_number || '').trim() === '';
|
|
5876
6278
|
});
|
|
5877
6279
|
if (!needsPaymentNumber) {
|
|
5878
|
-
|
|
6280
|
+
_context42.next = 8;
|
|
5879
6281
|
break;
|
|
5880
6282
|
}
|
|
5881
|
-
|
|
6283
|
+
_context42.next = 5;
|
|
5882
6284
|
return this.getPaymentNumberDevicePrefixAsync();
|
|
5883
6285
|
case 5:
|
|
5884
|
-
|
|
5885
|
-
|
|
6286
|
+
_context42.t0 = _context42.sent;
|
|
6287
|
+
_context42.next = 9;
|
|
5886
6288
|
break;
|
|
5887
6289
|
case 8:
|
|
5888
|
-
|
|
6290
|
+
_context42.t0 = 'LOCAL';
|
|
5889
6291
|
case 9:
|
|
5890
|
-
devicePrefix =
|
|
6292
|
+
devicePrefix = _context42.t0;
|
|
5891
6293
|
mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
|
|
5892
6294
|
return _this35.normalizePaymentSource(payment, {
|
|
5893
6295
|
defaultPaid: false,
|
|
@@ -5902,20 +6304,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5902
6304
|
tempOrder.payments = effectivePayments;
|
|
5903
6305
|
tempOrder.payment_status = paymentStatus;
|
|
5904
6306
|
this.persistTempOrder();
|
|
5905
|
-
|
|
6307
|
+
_context42.next = 21;
|
|
5906
6308
|
return this.saveDraft();
|
|
5907
6309
|
case 21:
|
|
5908
6310
|
if (params.submitWhenPaid) {
|
|
5909
|
-
|
|
6311
|
+
_context42.next = 23;
|
|
5910
6312
|
break;
|
|
5911
6313
|
}
|
|
5912
|
-
return
|
|
6314
|
+
return _context42.abrupt("return", completion);
|
|
5913
6315
|
case 23:
|
|
5914
6316
|
if (!(this.store.syncState === 'submitting')) {
|
|
5915
|
-
|
|
6317
|
+
_context42.next = 25;
|
|
5916
6318
|
break;
|
|
5917
6319
|
}
|
|
5918
|
-
return
|
|
6320
|
+
return _context42.abrupt("return", completion);
|
|
5919
6321
|
case 25:
|
|
5920
6322
|
this.store.syncState = 'submitting';
|
|
5921
6323
|
paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, effectivePayments);
|
|
@@ -5935,30 +6337,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5935
6337
|
enhancePayload: enhancePayload
|
|
5936
6338
|
};
|
|
5937
6339
|
if (!(params.checkoutSyncTaskEnabled === false)) {
|
|
5938
|
-
|
|
6340
|
+
_context42.next = 35;
|
|
5939
6341
|
break;
|
|
5940
6342
|
}
|
|
5941
|
-
|
|
6343
|
+
_context42.next = 32;
|
|
5942
6344
|
return this.submitTempOrderAsync(submitParams);
|
|
5943
6345
|
case 32:
|
|
5944
|
-
|
|
5945
|
-
|
|
6346
|
+
_context42.t1 = _context42.sent;
|
|
6347
|
+
_context42.next = 38;
|
|
5946
6348
|
break;
|
|
5947
6349
|
case 35:
|
|
5948
|
-
|
|
6350
|
+
_context42.next = 37;
|
|
5949
6351
|
return this.submitTempOrder(submitParams);
|
|
5950
6352
|
case 37:
|
|
5951
|
-
|
|
6353
|
+
_context42.t1 = _context42.sent;
|
|
5952
6354
|
case 38:
|
|
5953
|
-
submitResult =
|
|
5954
|
-
return
|
|
6355
|
+
submitResult = _context42.t1;
|
|
6356
|
+
return _context42.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
|
|
5955
6357
|
submitResult: submitResult
|
|
5956
6358
|
}));
|
|
5957
6359
|
case 40:
|
|
5958
6360
|
case "end":
|
|
5959
|
-
return
|
|
6361
|
+
return _context42.stop();
|
|
5960
6362
|
}
|
|
5961
|
-
},
|
|
6363
|
+
}, _callee39, this);
|
|
5962
6364
|
}));
|
|
5963
6365
|
function syncPaymentsToOrder(_x44) {
|
|
5964
6366
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
@@ -6057,11 +6459,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6057
6459
|
}, {
|
|
6058
6460
|
key: "submitOrder",
|
|
6059
6461
|
value: function () {
|
|
6060
|
-
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6462
|
+
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(order) {
|
|
6061
6463
|
var _order$query$cartItem, _params$bookings, _params$relation_prod;
|
|
6062
6464
|
var url, query, fetchUrl, params;
|
|
6063
|
-
return _regeneratorRuntime().wrap(function
|
|
6064
|
-
while (1) switch (
|
|
6465
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context43) {
|
|
6466
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
6065
6467
|
case 0:
|
|
6066
6468
|
this.logInfo('submitOrder called', {
|
|
6067
6469
|
url: order.url,
|
|
@@ -6081,12 +6483,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6081
6483
|
relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
|
|
6082
6484
|
scheduleDate: params.schedule_date
|
|
6083
6485
|
});
|
|
6084
|
-
return
|
|
6486
|
+
return _context43.abrupt("return", this.request.post(fetchUrl, params));
|
|
6085
6487
|
case 6:
|
|
6086
6488
|
case "end":
|
|
6087
|
-
return
|
|
6489
|
+
return _context43.stop();
|
|
6088
6490
|
}
|
|
6089
|
-
},
|
|
6491
|
+
}, _callee40, this);
|
|
6090
6492
|
}));
|
|
6091
6493
|
function submitOrder(_x45) {
|
|
6092
6494
|
return _submitOrder.apply(this, arguments);
|
|
@@ -6096,13 +6498,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6096
6498
|
}, {
|
|
6097
6499
|
key: "cancelOrder",
|
|
6098
6500
|
value: function () {
|
|
6099
|
-
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6501
|
+
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
|
|
6100
6502
|
var payload;
|
|
6101
|
-
return _regeneratorRuntime().wrap(function
|
|
6102
|
-
while (1) switch (
|
|
6503
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context44) {
|
|
6504
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
6103
6505
|
case 0:
|
|
6104
6506
|
if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
|
|
6105
|
-
|
|
6507
|
+
_context44.next = 2;
|
|
6106
6508
|
break;
|
|
6107
6509
|
}
|
|
6108
6510
|
throw new Error('取消订单失败:order_ids 不能为空');
|
|
@@ -6118,14 +6520,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6118
6520
|
method: 'PUT',
|
|
6119
6521
|
orderIdsCount: params.order_ids.length
|
|
6120
6522
|
});
|
|
6121
|
-
return
|
|
6523
|
+
return _context44.abrupt("return", this.request.put('/order/update-status', payload, {
|
|
6122
6524
|
isShopApi: true
|
|
6123
6525
|
}));
|
|
6124
6526
|
case 5:
|
|
6125
6527
|
case "end":
|
|
6126
|
-
return
|
|
6528
|
+
return _context44.stop();
|
|
6127
6529
|
}
|
|
6128
|
-
},
|
|
6530
|
+
}, _callee41, this);
|
|
6129
6531
|
}));
|
|
6130
6532
|
function cancelOrder(_x46) {
|
|
6131
6533
|
return _cancelOrder.apply(this, arguments);
|
|
@@ -6135,19 +6537,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6135
6537
|
}, {
|
|
6136
6538
|
key: "changeBookingStatus",
|
|
6137
6539
|
value: function () {
|
|
6138
|
-
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6540
|
+
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
|
|
6139
6541
|
var url, payload;
|
|
6140
|
-
return _regeneratorRuntime().wrap(function
|
|
6141
|
-
while (1) switch (
|
|
6542
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context45) {
|
|
6543
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
6142
6544
|
case 0:
|
|
6143
6545
|
if (params.booking_id) {
|
|
6144
|
-
|
|
6546
|
+
_context45.next = 2;
|
|
6145
6547
|
break;
|
|
6146
6548
|
}
|
|
6147
6549
|
throw new Error('变更预约状态失败:booking_id 不能为空');
|
|
6148
6550
|
case 2:
|
|
6149
6551
|
if (params.appointment_status) {
|
|
6150
|
-
|
|
6552
|
+
_context45.next = 4;
|
|
6151
6553
|
break;
|
|
6152
6554
|
}
|
|
6153
6555
|
throw new Error('变更预约状态失败:appointment_status 不能为空');
|
|
@@ -6162,14 +6564,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6162
6564
|
bookingId: params.booking_id,
|
|
6163
6565
|
appointmentStatus: params.appointment_status
|
|
6164
6566
|
});
|
|
6165
|
-
return
|
|
6567
|
+
return _context45.abrupt("return", this.request.put(url, payload, {
|
|
6166
6568
|
isShopApi: true
|
|
6167
6569
|
}));
|
|
6168
6570
|
case 8:
|
|
6169
6571
|
case "end":
|
|
6170
|
-
return
|
|
6572
|
+
return _context45.stop();
|
|
6171
6573
|
}
|
|
6172
|
-
},
|
|
6574
|
+
}, _callee42, this);
|
|
6173
6575
|
}));
|
|
6174
6576
|
function changeBookingStatus(_x47) {
|
|
6175
6577
|
return _changeBookingStatus.apply(this, arguments);
|
|
@@ -6189,11 +6591,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6189
6591
|
}, {
|
|
6190
6592
|
key: "createOrderByCheckout",
|
|
6191
6593
|
value: (function () {
|
|
6192
|
-
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6594
|
+
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
|
|
6193
6595
|
var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3;
|
|
6194
6596
|
var onlineStorePaymentCodeList, _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, orderData, response;
|
|
6195
|
-
return _regeneratorRuntime().wrap(function
|
|
6196
|
-
while (1) switch (
|
|
6597
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context46) {
|
|
6598
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
6197
6599
|
case 0:
|
|
6198
6600
|
// 过滤掉由在线店铺下单的 payment 支付数据
|
|
6199
6601
|
onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
|
|
@@ -6218,7 +6620,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6218
6620
|
return p.code;
|
|
6219
6621
|
})) || []
|
|
6220
6622
|
});
|
|
6221
|
-
|
|
6623
|
+
_context46.prev = 3;
|
|
6222
6624
|
// 构建订单数据,设置默认值并允许 params 覆盖
|
|
6223
6625
|
orderData = _objectSpread({
|
|
6224
6626
|
sales_channel: 'my_pisel',
|
|
@@ -6266,30 +6668,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6266
6668
|
hasOrderId: !!orderData.order_id,
|
|
6267
6669
|
smallTicketDataFlag: orderData.small_ticket_data_flag
|
|
6268
6670
|
});
|
|
6269
|
-
|
|
6671
|
+
_context46.next = 10;
|
|
6270
6672
|
return this.request.post('/order/checkout', orderData, {
|
|
6271
6673
|
osServer: true,
|
|
6272
6674
|
customToast: function customToast() {}
|
|
6273
6675
|
});
|
|
6274
6676
|
case 10:
|
|
6275
|
-
response =
|
|
6677
|
+
response = _context46.sent;
|
|
6276
6678
|
this.logInfo('Order API called successfully', {
|
|
6277
6679
|
response: response
|
|
6278
6680
|
});
|
|
6279
|
-
return
|
|
6681
|
+
return _context46.abrupt("return", response);
|
|
6280
6682
|
case 15:
|
|
6281
|
-
|
|
6282
|
-
|
|
6283
|
-
console.error('[Order] createOrderByCheckout 创建订单失败:',
|
|
6683
|
+
_context46.prev = 15;
|
|
6684
|
+
_context46.t0 = _context46["catch"](3);
|
|
6685
|
+
console.error('[Order] createOrderByCheckout 创建订单失败:', _context46.t0);
|
|
6284
6686
|
this.logInfo('Order API called failed', {
|
|
6285
|
-
error:
|
|
6687
|
+
error: _context46.t0 instanceof Error ? _context46.t0.message : String(_context46.t0)
|
|
6286
6688
|
});
|
|
6287
|
-
throw
|
|
6689
|
+
throw _context46.t0;
|
|
6288
6690
|
case 20:
|
|
6289
6691
|
case "end":
|
|
6290
|
-
return
|
|
6692
|
+
return _context46.stop();
|
|
6291
6693
|
}
|
|
6292
|
-
},
|
|
6694
|
+
}, _callee43, this, [[3, 15]]);
|
|
6293
6695
|
}));
|
|
6294
6696
|
function createOrderByCheckout(_x48) {
|
|
6295
6697
|
return _createOrderByCheckout.apply(this, arguments);
|
|
@@ -6299,22 +6701,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6299
6701
|
}, {
|
|
6300
6702
|
key: "submitSalesOrder",
|
|
6301
6703
|
value: function () {
|
|
6302
|
-
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6704
|
+
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(params) {
|
|
6303
6705
|
var url, query, fetchUrl;
|
|
6304
|
-
return _regeneratorRuntime().wrap(function
|
|
6305
|
-
while (1) switch (
|
|
6706
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context47) {
|
|
6707
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
6306
6708
|
case 0:
|
|
6307
6709
|
url = params.url, query = params.query;
|
|
6308
6710
|
fetchUrl = url || '/order/sales/checkout';
|
|
6309
|
-
return
|
|
6711
|
+
return _context47.abrupt("return", this.request.post(fetchUrl, query, {
|
|
6310
6712
|
osServer: true,
|
|
6311
6713
|
customToast: function customToast() {}
|
|
6312
6714
|
}));
|
|
6313
6715
|
case 3:
|
|
6314
6716
|
case "end":
|
|
6315
|
-
return
|
|
6717
|
+
return _context47.stop();
|
|
6316
6718
|
}
|
|
6317
|
-
},
|
|
6719
|
+
}, _callee44, this);
|
|
6318
6720
|
}));
|
|
6319
6721
|
function submitSalesOrder(_x49) {
|
|
6320
6722
|
return _submitSalesOrder.apply(this, arguments);
|
|
@@ -6330,35 +6732,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6330
6732
|
}, {
|
|
6331
6733
|
key: "sendCustomerPayLink",
|
|
6332
6734
|
value: (function () {
|
|
6333
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6735
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(params) {
|
|
6334
6736
|
var _params$emails;
|
|
6335
6737
|
var orderIds;
|
|
6336
|
-
return _regeneratorRuntime().wrap(function
|
|
6337
|
-
while (1) switch (
|
|
6738
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context48) {
|
|
6739
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
6338
6740
|
case 0:
|
|
6339
6741
|
orderIds = params.order_ids || params.orderIds || [];
|
|
6340
6742
|
if (orderIds.length) {
|
|
6341
|
-
|
|
6743
|
+
_context48.next = 3;
|
|
6342
6744
|
break;
|
|
6343
6745
|
}
|
|
6344
6746
|
throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
|
|
6345
6747
|
case 3:
|
|
6346
6748
|
if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
|
|
6347
|
-
|
|
6749
|
+
_context48.next = 5;
|
|
6348
6750
|
break;
|
|
6349
6751
|
}
|
|
6350
6752
|
throw new Error('发送支付链接需要至少一个邮箱');
|
|
6351
6753
|
case 5:
|
|
6352
|
-
return
|
|
6754
|
+
return _context48.abrupt("return", this.request.post('/order/batch-email', {
|
|
6353
6755
|
order_ids: orderIds,
|
|
6354
6756
|
notify_action: params.notify_action || 'order_payment_reminder',
|
|
6355
6757
|
emails: params.emails
|
|
6356
6758
|
}));
|
|
6357
6759
|
case 6:
|
|
6358
6760
|
case "end":
|
|
6359
|
-
return
|
|
6761
|
+
return _context48.stop();
|
|
6360
6762
|
}
|
|
6361
|
-
},
|
|
6763
|
+
}, _callee45, this);
|
|
6362
6764
|
}));
|
|
6363
6765
|
function sendCustomerPayLink(_x50) {
|
|
6364
6766
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
@@ -6368,14 +6770,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6368
6770
|
}, {
|
|
6369
6771
|
key: "getSalesOrderByLookup",
|
|
6370
6772
|
value: function () {
|
|
6371
|
-
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6773
|
+
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(params) {
|
|
6372
6774
|
var lookup, res;
|
|
6373
|
-
return _regeneratorRuntime().wrap(function
|
|
6374
|
-
while (1) switch (
|
|
6775
|
+
return _regeneratorRuntime().wrap(function _callee46$(_context49) {
|
|
6776
|
+
while (1) switch (_context49.prev = _context49.next) {
|
|
6375
6777
|
case 0:
|
|
6376
6778
|
lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
|
|
6377
6779
|
if (lookup) {
|
|
6378
|
-
|
|
6780
|
+
_context49.next = 3;
|
|
6379
6781
|
break;
|
|
6380
6782
|
}
|
|
6381
6783
|
throw new Error('加载销售详情需要 lookup');
|
|
@@ -6384,7 +6786,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6384
6786
|
if (lookup.startsWith('LOCAL_')) {
|
|
6385
6787
|
params.forceRemote = false;
|
|
6386
6788
|
}
|
|
6387
|
-
|
|
6789
|
+
_context49.next = 6;
|
|
6388
6790
|
return this.request.get("/order/sales/".concat(encodeURIComponent(lookup)), _objectSpread({
|
|
6389
6791
|
with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info', 'refunds', 'notes']
|
|
6390
6792
|
}, params.forceRemote ? {
|
|
@@ -6393,16 +6795,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6393
6795
|
osServer: true
|
|
6394
6796
|
});
|
|
6395
6797
|
case 6:
|
|
6396
|
-
res =
|
|
6798
|
+
res = _context49.sent;
|
|
6397
6799
|
if (res.code === 200) {
|
|
6398
6800
|
this.store.lastOrderInfo = res.data;
|
|
6399
6801
|
}
|
|
6400
|
-
return
|
|
6802
|
+
return _context49.abrupt("return", res);
|
|
6401
6803
|
case 9:
|
|
6402
6804
|
case "end":
|
|
6403
|
-
return
|
|
6805
|
+
return _context49.stop();
|
|
6404
6806
|
}
|
|
6405
|
-
},
|
|
6807
|
+
}, _callee46, this);
|
|
6406
6808
|
}));
|
|
6407
6809
|
function getSalesOrderByLookup(_x51) {
|
|
6408
6810
|
return _getSalesOrderByLookup.apply(this, arguments);
|
|
@@ -6418,11 +6820,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6418
6820
|
}, {
|
|
6419
6821
|
key: "hydrateTempOrderFromRecord",
|
|
6420
6822
|
value: (function () {
|
|
6421
|
-
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6422
|
-
var _sourceRaw$_extend, _this$store$
|
|
6423
|
-
var sourceRaw, duplicateProductIdentityRepair, duplicateIdentityReadySource, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, isSessionStorageHydrate, isMergedSalesDetailHydrate, nextTempOrder, _this$store$
|
|
6424
|
-
return _regeneratorRuntime().wrap(function
|
|
6425
|
-
while (1) switch (
|
|
6823
|
+
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(record, options) {
|
|
6824
|
+
var _sourceRaw$_extend, _this$store$discount26;
|
|
6825
|
+
var sourceRaw, duplicateProductIdentityRepair, duplicateIdentityReadySource, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, isSessionStorageHydrate, isMergedSalesDetailHydrate, nextTempOrder, _this$store$discount24, _this$store$discount25, restoredSessionDiscounts, nextExtend, sourceLastOrderInfo, isDraftOrder, syntheticIdentityOptions, rawSummary, historicalDepositSnapshot, summarySurcharges, hadSyntheticDraftOrderId, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount27, _this$store$discount28;
|
|
6826
|
+
return _regeneratorRuntime().wrap(function _callee47$(_context50) {
|
|
6827
|
+
while (1) switch (_context50.prev = _context50.next) {
|
|
6426
6828
|
case 0:
|
|
6427
6829
|
sourceRaw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
|
|
6428
6830
|
duplicateProductIdentityRepair = repairDuplicateOrderProductLineIdentities(Array.isArray(sourceRaw.products) ? sourceRaw.products : [], (_sourceRaw$_extend = sourceRaw._extend) === null || _sourceRaw$_extend === void 0 ? void 0 : _sourceRaw$_extend.productsByUid);
|
|
@@ -6463,7 +6865,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6463
6865
|
});
|
|
6464
6866
|
this.store.tempOrder = nextTempOrder;
|
|
6465
6867
|
if (!isSessionStorageHydrate) {
|
|
6466
|
-
|
|
6868
|
+
_context50.next = 30;
|
|
6467
6869
|
break;
|
|
6468
6870
|
}
|
|
6469
6871
|
// 会话快照是未提交购物车,不应获得编辑订单的 saved/edit 标记与服务端基线。
|
|
@@ -6479,23 +6881,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6479
6881
|
nextTempOrder.discount_list = restoredSessionDiscounts;
|
|
6480
6882
|
this.store.summary = createEmptySummary();
|
|
6481
6883
|
this.store.lastOrderInfo = undefined;
|
|
6482
|
-
|
|
6483
|
-
return (_this$store$
|
|
6884
|
+
_context50.next = 23;
|
|
6885
|
+
return (_this$store$discount24 = this.store.discount) === null || _this$store$discount24 === void 0 ? void 0 : _this$store$discount24.setOriginalDiscountList(cloneDeep(restoredSessionDiscounts));
|
|
6484
6886
|
case 23:
|
|
6485
|
-
|
|
6486
|
-
return (_this$store$
|
|
6887
|
+
_context50.next = 25;
|
|
6888
|
+
return (_this$store$discount25 = this.store.discount) === null || _this$store$discount25 === void 0 ? void 0 : _this$store$discount25.setDiscountList(cloneDeep(restoredSessionDiscounts));
|
|
6487
6889
|
case 25:
|
|
6488
6890
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
6489
|
-
|
|
6891
|
+
_context50.next = 28;
|
|
6490
6892
|
break;
|
|
6491
6893
|
}
|
|
6492
|
-
|
|
6894
|
+
_context50.next = 28;
|
|
6493
6895
|
return this.recalculateSummary({
|
|
6494
6896
|
createIfMissing: false
|
|
6495
6897
|
});
|
|
6496
6898
|
case 28:
|
|
6497
6899
|
this.persistTempOrder();
|
|
6498
|
-
return
|
|
6900
|
+
return _context50.abrupt("return", nextTempOrder);
|
|
6499
6901
|
case 30:
|
|
6500
6902
|
// Server list compatibility may synthesize order_id from external_sale_number; tempOrder must not.
|
|
6501
6903
|
sourceLastOrderInfo = sourceRaw.lastOrderInfo || sourceRaw;
|
|
@@ -6534,7 +6936,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6534
6936
|
this.store.syncState = 'local';
|
|
6535
6937
|
}
|
|
6536
6938
|
hydratedEditDiscounts = this.collectHydratedEditDiscounts(nextTempOrder.products);
|
|
6537
|
-
currentDiscounts = typeof ((_this$store$
|
|
6939
|
+
currentDiscounts = typeof ((_this$store$discount26 = this.store.discount) === null || _this$store$discount26 === void 0 ? void 0 : _this$store$discount26.getDiscountList) === 'function' ? this.store.discount.getDiscountList() || [] : [];
|
|
6538
6940
|
currentScanDiscounts = currentDiscounts.filter(function (discount) {
|
|
6539
6941
|
return discount === null || discount === void 0 ? void 0 : discount.isScan;
|
|
6540
6942
|
});
|
|
@@ -6547,32 +6949,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6547
6949
|
nextDiscounts = [].concat(_toConsumableArray(hydratedEditDiscounts), _toConsumableArray(retainedScanDiscounts));
|
|
6548
6950
|
shouldSkipEmptyDiscountSync = nextDiscounts.length === 0 && currentDiscounts.length === 0;
|
|
6549
6951
|
if (shouldSkipEmptyDiscountSync) {
|
|
6550
|
-
|
|
6952
|
+
_context50.next = 54;
|
|
6551
6953
|
break;
|
|
6552
6954
|
}
|
|
6553
6955
|
OrderModule.populateSavedAmounts(nextTempOrder.products, nextDiscounts);
|
|
6554
|
-
|
|
6555
|
-
return (_this$store$
|
|
6956
|
+
_context50.next = 52;
|
|
6957
|
+
return (_this$store$discount27 = this.store.discount) === null || _this$store$discount27 === void 0 ? void 0 : _this$store$discount27.setOriginalDiscountList(nextDiscounts);
|
|
6556
6958
|
case 52:
|
|
6557
|
-
|
|
6558
|
-
return (_this$store$
|
|
6959
|
+
_context50.next = 54;
|
|
6960
|
+
return (_this$store$discount28 = this.store.discount) === null || _this$store$discount28 === void 0 ? void 0 : _this$store$discount28.setDiscountList(nextDiscounts);
|
|
6559
6961
|
case 54:
|
|
6560
6962
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
6561
|
-
|
|
6963
|
+
_context50.next = 57;
|
|
6562
6964
|
break;
|
|
6563
6965
|
}
|
|
6564
|
-
|
|
6966
|
+
_context50.next = 57;
|
|
6565
6967
|
return this.recalculateSummary({
|
|
6566
6968
|
createIfMissing: false
|
|
6567
6969
|
});
|
|
6568
6970
|
case 57:
|
|
6569
6971
|
this.persistTempOrder();
|
|
6570
|
-
return
|
|
6972
|
+
return _context50.abrupt("return", nextTempOrder);
|
|
6571
6973
|
case 59:
|
|
6572
6974
|
case "end":
|
|
6573
|
-
return
|
|
6975
|
+
return _context50.stop();
|
|
6574
6976
|
}
|
|
6575
|
-
},
|
|
6977
|
+
}, _callee47, this);
|
|
6576
6978
|
}));
|
|
6577
6979
|
function hydrateTempOrderFromRecord(_x52, _x53) {
|
|
6578
6980
|
return _hydrateTempOrderFromRecord.apply(this, arguments);
|
|
@@ -6627,10 +7029,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6627
7029
|
_step22;
|
|
6628
7030
|
try {
|
|
6629
7031
|
for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
|
|
6630
|
-
var _product$
|
|
7032
|
+
var _product$metadata11;
|
|
6631
7033
|
var product = _step22.value;
|
|
6632
7034
|
var productUid = getOrderCollectionUid('product', product);
|
|
6633
|
-
var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$
|
|
7035
|
+
var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata11 = product.metadata) === null || _product$metadata11 === void 0 ? void 0 : _product$metadata11.booking_uid);
|
|
6634
7036
|
if (!productUid || bookingUid === undefined || bookingUid === null || bookingUid === '') {
|
|
6635
7037
|
continue;
|
|
6636
7038
|
}
|
|
@@ -6649,12 +7051,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6649
7051
|
_step23;
|
|
6650
7052
|
try {
|
|
6651
7053
|
for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {
|
|
6652
|
-
var _booking$
|
|
7054
|
+
var _booking$metadata9;
|
|
6653
7055
|
var booking = _step23.value;
|
|
6654
7056
|
if (getOrderCollectionPersistentId('booking', booking) || getOrderCollectionUid('booking', booking)) {
|
|
6655
7057
|
continue;
|
|
6656
7058
|
}
|
|
6657
|
-
var _productUid = (booking === null || booking === void 0 ? void 0 : booking.product_uid) || (booking === null || booking === void 0 || (_booking$
|
|
7059
|
+
var _productUid = (booking === null || booking === void 0 ? void 0 : booking.product_uid) || (booking === null || booking === void 0 || (_booking$metadata9 = booking.metadata) === null || _booking$metadata9 === void 0 ? void 0 : _booking$metadata9.product_uid);
|
|
6658
7060
|
if (_productUid === undefined || _productUid === null || _productUid === '') continue;
|
|
6659
7061
|
var key = String(_productUid);
|
|
6660
7062
|
anonymousBookingCountByProductUid.set(key, (anonymousBookingCountByProductUid.get(key) || 0) + 1);
|
|
@@ -6666,11 +7068,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6666
7068
|
}
|
|
6667
7069
|
return _objectSpread(_objectSpread({}, raw), {}, {
|
|
6668
7070
|
bookings: raw.bookings.map(function (booking) {
|
|
6669
|
-
var _booking$
|
|
7071
|
+
var _booking$metadata8;
|
|
6670
7072
|
if (getOrderCollectionPersistentId('booking', booking) || getOrderCollectionUid('booking', booking)) {
|
|
6671
7073
|
return booking;
|
|
6672
7074
|
}
|
|
6673
|
-
var productUid = (booking === null || booking === void 0 ? void 0 : booking.product_uid) || (booking === null || booking === void 0 || (_booking$
|
|
7075
|
+
var productUid = (booking === null || booking === void 0 ? void 0 : booking.product_uid) || (booking === null || booking === void 0 || (_booking$metadata8 = booking.metadata) === null || _booking$metadata8 === void 0 ? void 0 : _booking$metadata8.product_uid);
|
|
6674
7076
|
if (productUid === undefined || productUid === null || productUid === '') {
|
|
6675
7077
|
return booking;
|
|
6676
7078
|
}
|
|
@@ -6767,15 +7169,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6767
7169
|
_step24;
|
|
6768
7170
|
try {
|
|
6769
7171
|
for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
|
|
6770
|
-
var _product$
|
|
7172
|
+
var _product$metadata12, _ref79, _ref80, _existed$origin, _rawProduct$metadata;
|
|
6771
7173
|
var _step24$value = _slicedToArray(_step24.value, 2),
|
|
6772
7174
|
index = _step24$value[0],
|
|
6773
7175
|
product = _step24$value[1];
|
|
6774
|
-
var uid = (_product$
|
|
7176
|
+
var uid = (_product$metadata12 = product.metadata) === null || _product$metadata12 === void 0 ? void 0 : _product$metadata12.unique_identification_number;
|
|
6775
7177
|
if (!uid) continue;
|
|
6776
7178
|
var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
|
|
6777
7179
|
var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
|
|
6778
|
-
var origin = (
|
|
7180
|
+
var origin = (_ref79 = (_ref80 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref80 !== void 0 ? _ref80 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref79 !== void 0 ? _ref79 : rawProduct;
|
|
6779
7181
|
var originSnapshot = cloneDeep(origin);
|
|
6780
7182
|
var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
|
|
6781
7183
|
if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
|
|
@@ -6826,8 +7228,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6826
7228
|
var bookingUidByProductUid = new Map();
|
|
6827
7229
|
var productByUid = new Map();
|
|
6828
7230
|
(tempOrder.products || []).forEach(function (product) {
|
|
6829
|
-
var _product$
|
|
6830
|
-
var productUid = (product === null || product === void 0 || (_product$
|
|
7231
|
+
var _product$metadata13;
|
|
7232
|
+
var productUid = (product === null || product === void 0 || (_product$metadata13 = product.metadata) === null || _product$metadata13 === void 0 ? void 0 : _product$metadata13.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
6831
7233
|
if (productUid !== undefined && productUid !== null && String(productUid) !== '') {
|
|
6832
7234
|
productByUid.set(String(productUid), product);
|
|
6833
7235
|
}
|
|
@@ -6848,8 +7250,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6848
7250
|
bookingUidByProductUid.set(String(productUid), bookingUid);
|
|
6849
7251
|
});
|
|
6850
7252
|
(tempOrder.products || []).forEach(function (product) {
|
|
6851
|
-
var _product$
|
|
6852
|
-
var productUid = (product === null || product === void 0 || (_product$
|
|
7253
|
+
var _product$metadata14;
|
|
7254
|
+
var productUid = (product === null || product === void 0 || (_product$metadata14 = product.metadata) === null || _product$metadata14 === void 0 ? void 0 : _product$metadata14.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
6853
7255
|
if (productUid === undefined || productUid === null || String(productUid) === '') return;
|
|
6854
7256
|
var bookingUid = bookingUidByProductUid.get(String(productUid));
|
|
6855
7257
|
if (!bookingUid) return;
|
|
@@ -6904,10 +7306,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6904
7306
|
}, {
|
|
6905
7307
|
key: "normalizeHydratedProductOptionItem",
|
|
6906
7308
|
value: function normalizeHydratedProductOptionItem(optionItem) {
|
|
6907
|
-
var
|
|
6908
|
-
var rawNum = (
|
|
7309
|
+
var _ref81, _optionItem$num, _ref82, _optionItem$add_price;
|
|
7310
|
+
var rawNum = (_ref81 = (_optionItem$num = optionItem === null || optionItem === void 0 ? void 0 : optionItem.num) !== null && _optionItem$num !== void 0 ? _optionItem$num : optionItem === null || optionItem === void 0 ? void 0 : optionItem.quantity) !== null && _ref81 !== void 0 ? _ref81 : 1;
|
|
6909
7311
|
var parsedNum = Number(rawNum);
|
|
6910
|
-
var rawPrice = (
|
|
7312
|
+
var rawPrice = (_ref82 = (_optionItem$add_price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _optionItem$add_price !== void 0 ? _optionItem$add_price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _ref82 !== void 0 ? _ref82 : 0;
|
|
6911
7313
|
var parsedPrice = Number(rawPrice);
|
|
6912
7314
|
var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
|
|
6913
7315
|
option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
|
|
@@ -6961,7 +7363,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6961
7363
|
});
|
|
6962
7364
|
if (result.metadata) delete result.metadata.price_schema_version;
|
|
6963
7365
|
var restored = restoreHydratedBundleDiscounts(result, normalizeOrderProductDiscountList);
|
|
6964
|
-
return this.sanitizeOrderProductForTempOrder(restored);
|
|
7366
|
+
return this.sanitizeOrderProductForTempOrder(this.normalizeVirtualSettlementProductIfEnabled(restored));
|
|
6965
7367
|
}
|
|
6966
7368
|
}, {
|
|
6967
7369
|
key: "getLastOrderInfo",
|
|
@@ -6972,25 +7374,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6972
7374
|
}, {
|
|
6973
7375
|
key: "getOrderInfo",
|
|
6974
7376
|
value: function () {
|
|
6975
|
-
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7377
|
+
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(order_id) {
|
|
6976
7378
|
var res;
|
|
6977
|
-
return _regeneratorRuntime().wrap(function
|
|
6978
|
-
while (1) switch (
|
|
7379
|
+
return _regeneratorRuntime().wrap(function _callee48$(_context51) {
|
|
7380
|
+
while (1) switch (_context51.prev = _context51.next) {
|
|
6979
7381
|
case 0:
|
|
6980
|
-
|
|
7382
|
+
_context51.next = 2;
|
|
6981
7383
|
return this.request.get("/order/sales/".concat(order_id), {
|
|
6982
7384
|
with: ['products', 'bookings', 'notes']
|
|
6983
7385
|
}, {
|
|
6984
7386
|
osServer: true
|
|
6985
7387
|
});
|
|
6986
7388
|
case 2:
|
|
6987
|
-
res =
|
|
6988
|
-
return
|
|
7389
|
+
res = _context51.sent;
|
|
7390
|
+
return _context51.abrupt("return", res);
|
|
6989
7391
|
case 4:
|
|
6990
7392
|
case "end":
|
|
6991
|
-
return
|
|
7393
|
+
return _context51.stop();
|
|
6992
7394
|
}
|
|
6993
|
-
},
|
|
7395
|
+
}, _callee48, this);
|
|
6994
7396
|
}));
|
|
6995
7397
|
function getOrderInfo(_x54) {
|
|
6996
7398
|
return _getOrderInfo.apply(this, arguments);
|
|
@@ -7000,8 +7402,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7000
7402
|
}, {
|
|
7001
7403
|
key: "getVouchers",
|
|
7002
7404
|
value: function getVouchers() {
|
|
7003
|
-
var _this$store$
|
|
7004
|
-
return ((_this$store$
|
|
7405
|
+
var _this$store$tempOrder6;
|
|
7406
|
+
return ((_this$store$tempOrder6 = this.store.tempOrder) === null || _this$store$tempOrder6 === void 0 ? void 0 : _this$store$tempOrder6.vouchers) || [];
|
|
7005
7407
|
}
|
|
7006
7408
|
}], [{
|
|
7007
7409
|
key: "populateSavedAmounts",
|