@pisell/pisellos 0.10.54 → 0.10.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/BusinessAvailability/index.d.ts +30 -0
- package/dist/modules/BusinessAvailability/index.js +204 -0
- package/dist/modules/OpenData/types.d.ts +2 -0
- package/dist/modules/Order/index.d.ts +5 -2
- package/dist/modules/Order/index.js +315 -241
- package/dist/modules/Order/types.d.ts +8 -0
- package/dist/solution/BaseSales/index.d.ts +4 -15
- package/dist/solution/BaseSales/index.js +131 -86
- package/dist/solution/BaseSales/types.d.ts +11 -0
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +41 -13
- package/dist/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
- package/dist/solution/UnifiedBookingSales/businessAvailability.js +292 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +11 -0
- package/dist/solution/UnifiedBookingSales/index.js +154 -75
- package/dist/solution/UnifiedBookingSales/types.d.ts +2 -0
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/modules/BusinessAvailability/index.d.ts +30 -0
- package/lib/modules/BusinessAvailability/index.js +146 -0
- package/lib/modules/OpenData/types.d.ts +2 -0
- package/lib/modules/Order/index.d.ts +5 -2
- package/lib/modules/Order/index.js +62 -6
- package/lib/modules/Order/types.d.ts +8 -0
- package/lib/solution/BaseSales/index.d.ts +4 -15
- package/lib/solution/BaseSales/index.js +45 -24
- package/lib/solution/BaseSales/types.d.ts +11 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +37 -4
- package/lib/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
- package/lib/solution/UnifiedBookingSales/businessAvailability.js +138 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +11 -0
- package/lib/solution/UnifiedBookingSales/index.js +54 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +2 -0
- package/package.json +1 -1
|
@@ -521,6 +521,36 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
521
521
|
this.otherParams = otherParams;
|
|
522
522
|
}
|
|
523
523
|
|
|
524
|
+
/** Internal intent boundary shared with asynchronous scanner/detail flows. */
|
|
525
|
+
}, {
|
|
526
|
+
key: "createCartIntentCommitGuard",
|
|
527
|
+
value: function createCartIntentCommitGuard(action) {
|
|
528
|
+
var _this$orderHooks,
|
|
529
|
+
_this$orderHooks2,
|
|
530
|
+
_this2 = this;
|
|
531
|
+
var tempOrder = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.store.tempOrder;
|
|
532
|
+
var hook = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.beforeCartIntentCommit;
|
|
533
|
+
if (!hook) return function () {};
|
|
534
|
+
var getScope = (_this$orderHooks2 = this.orderHooks) === null || _this$orderHooks2 === void 0 ? void 0 : _this$orderHooks2.getCartIntentScope;
|
|
535
|
+
var scope = getScope === null || getScope === void 0 ? void 0 : getScope();
|
|
536
|
+
var otherParams = this.otherParams;
|
|
537
|
+
var committed = false;
|
|
538
|
+
return function () {
|
|
539
|
+
var _this2$orderHooks, _this2$orderHooks2;
|
|
540
|
+
if (_this2.store.tempOrder !== tempOrder || _this2.otherParams !== otherParams || ((_this2$orderHooks = _this2.orderHooks) === null || _this2$orderHooks === void 0 ? void 0 : _this2$orderHooks.beforeCartIntentCommit) !== hook || ((_this2$orderHooks2 = _this2.orderHooks) === null || _this2$orderHooks2 === void 0 ? void 0 : _this2$orderHooks2.getCartIntentScope) !== getScope || (getScope === null || getScope === void 0 ? void 0 : getScope()) !== scope) {
|
|
541
|
+
throw new Error('[Order] Cart intent belongs to a previous order or business');
|
|
542
|
+
}
|
|
543
|
+
// Derived gifts, discounts and persistence belong to the accepted intent,
|
|
544
|
+
// but an asynchronous continuation must never target a different cart.
|
|
545
|
+
if (committed) return;
|
|
546
|
+
hook({
|
|
547
|
+
action: action,
|
|
548
|
+
tempOrder: tempOrder
|
|
549
|
+
});
|
|
550
|
+
committed = true;
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
|
|
524
554
|
/** PC/H5 属于在线店铺;其它或缺失平台统一沿用 POS 行为。 */
|
|
525
555
|
}, {
|
|
526
556
|
key: "isOnlineStorePlatform",
|
|
@@ -612,10 +642,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
612
642
|
}, {
|
|
613
643
|
key: "createDefaultRulesHooks",
|
|
614
644
|
value: function createDefaultRulesHooks() {
|
|
615
|
-
var
|
|
645
|
+
var _this3 = this;
|
|
616
646
|
return createDefaultOrderRulesHooks(function () {
|
|
617
|
-
var
|
|
618
|
-
return ((
|
|
647
|
+
var _this3$store$tempOrde;
|
|
648
|
+
return ((_this3$store$tempOrde = _this3.store.tempOrder) === null || _this3$store$tempOrde === void 0 ? void 0 : _this3$store$tempOrde.bookings) || [];
|
|
619
649
|
});
|
|
620
650
|
}
|
|
621
651
|
|
|
@@ -638,7 +668,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
638
668
|
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
639
669
|
var _this$store$tempOrder,
|
|
640
670
|
_this$store$discount,
|
|
641
|
-
|
|
671
|
+
_this4 = this,
|
|
642
672
|
_this$store$tempOrder2;
|
|
643
673
|
var orderId, requestEpoch, requestOrderIdentityKey, prepareConfigResult, isCurrentRequest, discountList, _this$store$discount2, _this$store$discount3, _this$store$discount4, currentDiscountList, currentCommittedDiscounts, currentScanDiscounts, currentScanDiscountById, committedDiscountById, mergedCommittedDiscountIds, refreshedScanDiscountIds, runtimeDiscountIds, runtimeDiscounts, retainedCommittedDiscounts, retainedScanDiscounts, mergedDiscountList;
|
|
644
674
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
@@ -666,8 +696,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
666
696
|
case 5:
|
|
667
697
|
prepareConfigResult = _context3.sent;
|
|
668
698
|
isCurrentRequest = function isCurrentRequest() {
|
|
669
|
-
var
|
|
670
|
-
return requestEpoch ===
|
|
699
|
+
var _this4$store$tempOrde, _this4$store$tempOrde2;
|
|
700
|
+
return requestEpoch === _this4.customerWalletPrepareConfigEpoch && _this4.getDiscountConfigOrderIdentityKey(_this4.store.tempOrder) === requestOrderIdentityKey && String((_this4$store$tempOrde = (_this4$store$tempOrde2 = _this4.store.tempOrder) === null || _this4$store$tempOrde2 === void 0 ? void 0 : _this4$store$tempOrde2.customer_id) !== null && _this4$store$tempOrde !== void 0 ? _this4$store$tempOrde : '') === String(params.customerId);
|
|
671
701
|
};
|
|
672
702
|
if (isCurrentRequest()) {
|
|
673
703
|
_context3.next = 9;
|
|
@@ -899,12 +929,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
899
929
|
value: function () {
|
|
900
930
|
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(code, customerId) {
|
|
901
931
|
var _this$store$discount11, _tempOrder$holder, _this$store$summary;
|
|
902
|
-
var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref16, isAvailable, newDiscountList, evaluatedDiscountList, unavailableReason, scannedIds, evaluatedScannedDiscounts, shouldRetainForLater, normalizedNewDiscountList, resolvedDiscountList, _this$store$discount12, _this$store$discount13, retainedDiscounts;
|
|
932
|
+
var beforeCommit, resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref16, isAvailable, newDiscountList, evaluatedDiscountList, unavailableReason, scannedIds, evaluatedScannedDiscounts, shouldRetainForLater, normalizedNewDiscountList, resolvedDiscountList, _this$store$discount12, _this$store$discount13, retainedDiscounts;
|
|
903
933
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
904
934
|
while (1) switch (_context6.prev = _context6.next) {
|
|
905
935
|
case 0:
|
|
936
|
+
beforeCommit = this.createCartIntentCommitGuard('scan_promotion');
|
|
906
937
|
if (!this.isActiveVirtualSettlementOrder(this.store.tempOrder)) {
|
|
907
|
-
_context6.next =
|
|
938
|
+
_context6.next = 3;
|
|
908
939
|
break;
|
|
909
940
|
}
|
|
910
941
|
return _context6.abrupt("return", {
|
|
@@ -915,27 +946,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
915
946
|
scannedDiscountList: [],
|
|
916
947
|
unavailableReason: UnavailableReason.ProductNotApplicable
|
|
917
948
|
});
|
|
918
|
-
case
|
|
919
|
-
_context6.next =
|
|
949
|
+
case 3:
|
|
950
|
+
_context6.next = 5;
|
|
920
951
|
return (_this$store$discount11 = this.store.discount) === null || _this$store$discount11 === void 0 ? void 0 : _this$store$discount11.batchSearch(code, {
|
|
921
952
|
customerId: customerId
|
|
922
953
|
});
|
|
923
|
-
case
|
|
954
|
+
case 5:
|
|
924
955
|
_context6.t0 = _context6.sent;
|
|
925
956
|
if (_context6.t0) {
|
|
926
|
-
_context6.next =
|
|
957
|
+
_context6.next = 8;
|
|
927
958
|
break;
|
|
928
959
|
}
|
|
929
960
|
_context6.t0 = {
|
|
930
961
|
discountList: [],
|
|
931
962
|
unavailableReasonKey: null
|
|
932
963
|
};
|
|
933
|
-
case
|
|
964
|
+
case 8:
|
|
934
965
|
resultDiscountWithReason = _context6.t0;
|
|
935
966
|
resultDiscountList = resultDiscountWithReason.discountList, unavailableReasonKey = resultDiscountWithReason.unavailableReasonKey;
|
|
936
967
|
rulesModule = this.store.rules;
|
|
937
968
|
if (rulesModule) {
|
|
938
|
-
_context6.next =
|
|
969
|
+
_context6.next = 13;
|
|
939
970
|
break;
|
|
940
971
|
}
|
|
941
972
|
return _context6.abrupt("return", {
|
|
@@ -946,9 +977,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
946
977
|
scannedDiscountList: resultDiscountList,
|
|
947
978
|
unavailableReason: UnavailableReason.Unknown
|
|
948
979
|
});
|
|
949
|
-
case
|
|
980
|
+
case 13:
|
|
950
981
|
if (resultDiscountList.length) {
|
|
951
|
-
_context6.next =
|
|
982
|
+
_context6.next = 15;
|
|
952
983
|
break;
|
|
953
984
|
}
|
|
954
985
|
return _context6.abrupt("return", {
|
|
@@ -959,7 +990,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
959
990
|
scannedDiscountList: resultDiscountList,
|
|
960
991
|
unavailableReasonKey: unavailableReasonKey
|
|
961
992
|
});
|
|
962
|
-
case
|
|
993
|
+
case 15:
|
|
963
994
|
withScanList = resultDiscountList.map(function (item) {
|
|
964
995
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
965
996
|
isScan: true
|
|
@@ -973,12 +1004,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
973
1004
|
return m.id === n.id;
|
|
974
1005
|
});
|
|
975
1006
|
}))) {
|
|
976
|
-
_context6.next =
|
|
1007
|
+
_context6.next = 22;
|
|
977
1008
|
break;
|
|
978
1009
|
}
|
|
979
|
-
|
|
1010
|
+
beforeCommit();
|
|
1011
|
+
_context6.next = 21;
|
|
980
1012
|
return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
981
|
-
case
|
|
1013
|
+
case 21:
|
|
982
1014
|
return _context6.abrupt("return", {
|
|
983
1015
|
type: 'clientCalc',
|
|
984
1016
|
isAvailable: true,
|
|
@@ -986,7 +1018,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
986
1018
|
discountList: this.getDiscountList(),
|
|
987
1019
|
scannedDiscountList: resultDiscountList
|
|
988
1020
|
});
|
|
989
|
-
case
|
|
1021
|
+
case 22:
|
|
990
1022
|
tempOrder = this.store.tempOrder;
|
|
991
1023
|
holders = (tempOrder === null || tempOrder === void 0 || (_tempOrder$holder = tempOrder.holder) === null || _tempOrder$holder === void 0 ? void 0 : _tempOrder$holder.form_record) || [];
|
|
992
1024
|
_ref16 = rulesModule.isDiscountListAvailable({
|
|
@@ -1012,12 +1044,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1012
1044
|
normalizedNewDiscountList = newDiscountList ? markScannedDiscounts(newDiscountList, withScanList) : undefined;
|
|
1013
1045
|
resolvedDiscountList = normalizedNewDiscountList || this.getDiscountList();
|
|
1014
1046
|
if (!(isAvailable && normalizedNewDiscountList)) {
|
|
1015
|
-
_context6.next =
|
|
1047
|
+
_context6.next = 40;
|
|
1016
1048
|
break;
|
|
1017
1049
|
}
|
|
1018
|
-
|
|
1050
|
+
beforeCommit();
|
|
1051
|
+
_context6.next = 34;
|
|
1019
1052
|
return (_this$store$discount12 = this.store.discount) === null || _this$store$discount12 === void 0 ? void 0 : _this$store$discount12.setDiscountList(normalizedNewDiscountList);
|
|
1020
|
-
case
|
|
1053
|
+
case 34:
|
|
1021
1054
|
// 实际写回商品时沿用扫码试算的优先级,避免旧商品行的选卡覆盖本次扫码。
|
|
1022
1055
|
this.applyDiscount({
|
|
1023
1056
|
preferredEntitlementPassIds: withScanList.filter(function (discount) {
|
|
@@ -1026,17 +1059,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1026
1059
|
return discount.id;
|
|
1027
1060
|
})
|
|
1028
1061
|
});
|
|
1029
|
-
_context6.next =
|
|
1062
|
+
_context6.next = 37;
|
|
1030
1063
|
return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
1031
|
-
case
|
|
1064
|
+
case 37:
|
|
1032
1065
|
resolvedDiscountList = this.getDiscountList();
|
|
1033
|
-
_context6.next =
|
|
1066
|
+
_context6.next = 49;
|
|
1034
1067
|
break;
|
|
1035
|
-
case
|
|
1068
|
+
case 40:
|
|
1036
1069
|
if (!shouldRetainForLater) {
|
|
1037
|
-
_context6.next =
|
|
1070
|
+
_context6.next = 49;
|
|
1038
1071
|
break;
|
|
1039
1072
|
}
|
|
1073
|
+
beforeCommit();
|
|
1040
1074
|
// 只合并本次识别的卡券;不把试算产生的其他选券状态写回订单。
|
|
1041
1075
|
retainedDiscounts = new Map(this.getDiscountList().map(function (discount) {
|
|
1042
1076
|
return [String(discount.id), discount];
|
|
@@ -1051,14 +1085,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1051
1085
|
savedAmount: 0
|
|
1052
1086
|
}));
|
|
1053
1087
|
});
|
|
1054
|
-
_context6.next =
|
|
1088
|
+
_context6.next = 46;
|
|
1055
1089
|
return (_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.setDiscountList(_toConsumableArray(retainedDiscounts.values()));
|
|
1056
|
-
case
|
|
1057
|
-
_context6.next =
|
|
1090
|
+
case 46:
|
|
1091
|
+
_context6.next = 48;
|
|
1058
1092
|
return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
1059
|
-
case
|
|
1093
|
+
case 48:
|
|
1060
1094
|
resolvedDiscountList = this.getDiscountList();
|
|
1061
|
-
case
|
|
1095
|
+
case 49:
|
|
1062
1096
|
return _context6.abrupt("return", {
|
|
1063
1097
|
type: 'clientCalc',
|
|
1064
1098
|
isAvailable: isAvailable || false,
|
|
@@ -1067,7 +1101,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1067
1101
|
scannedDiscountList: evaluatedScannedDiscounts,
|
|
1068
1102
|
unavailableReason: unavailableReason
|
|
1069
1103
|
});
|
|
1070
|
-
case
|
|
1104
|
+
case 50:
|
|
1071
1105
|
case "end":
|
|
1072
1106
|
return _context6.stop();
|
|
1073
1107
|
}
|
|
@@ -1083,7 +1117,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1083
1117
|
value: function applyDiscount(options) {
|
|
1084
1118
|
var _this$store$discount16,
|
|
1085
1119
|
_this$store$summary2,
|
|
1086
|
-
|
|
1120
|
+
_this5 = this;
|
|
1087
1121
|
var tempOrder = this.store.tempOrder;
|
|
1088
1122
|
// 任意 products CRUD 后都应当重算 discount 状态;即使 products 为空,
|
|
1089
1123
|
// 也需要让 Rules.calcDiscount 把 DiscountModule 的 isSelected / isAvailable /
|
|
@@ -1140,7 +1174,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1140
1174
|
(_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 || _this$store$discount17.setDiscountList(result.discountList);
|
|
1141
1175
|
}
|
|
1142
1176
|
this.hasActiveCustomerBoundDiscount = (tempOrder.products || []).some(function (product) {
|
|
1143
|
-
return
|
|
1177
|
+
return _this5.productHasCustomerBoundDiscount(product);
|
|
1144
1178
|
});
|
|
1145
1179
|
}
|
|
1146
1180
|
|
|
@@ -1203,7 +1237,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1203
1237
|
var _evaluatePromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
1204
1238
|
var _this$promotionEvalua,
|
|
1205
1239
|
_this$promotionEvalua2,
|
|
1206
|
-
|
|
1240
|
+
_this6 = this;
|
|
1207
1241
|
var tempOrder, strategyConfigs, result, removeSet, _iterator3, _step3, reduce, _iterator6, _step6, _loop2, _iterator4, _step4, _loop, payload;
|
|
1208
1242
|
return _regeneratorRuntime().wrap(function _callee7$(_context9) {
|
|
1209
1243
|
while (1) switch (_context9.prev = _context9.next) {
|
|
@@ -1362,7 +1396,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1362
1396
|
case 6:
|
|
1363
1397
|
_context7.prev = 6;
|
|
1364
1398
|
_context7.next = 9;
|
|
1365
|
-
return
|
|
1399
|
+
return _this6.giftSelectResolver({
|
|
1366
1400
|
strategyId: addAction.strategyId,
|
|
1367
1401
|
strategyName: addAction.strategyName,
|
|
1368
1402
|
giftCount: addAction.giftCount,
|
|
@@ -1397,7 +1431,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1397
1431
|
_context7.next = 26;
|
|
1398
1432
|
break;
|
|
1399
1433
|
}
|
|
1400
|
-
linked =
|
|
1434
|
+
linked = _this6.createLinkedProductAndBooking({
|
|
1401
1435
|
product: gp,
|
|
1402
1436
|
booking: booking
|
|
1403
1437
|
});
|
|
@@ -1727,12 +1761,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1727
1761
|
}, {
|
|
1728
1762
|
key: "rememberPointCardSnapshotCodeCandidates",
|
|
1729
1763
|
value: function rememberPointCardSnapshotCodeCandidates(value) {
|
|
1730
|
-
var
|
|
1764
|
+
var _this7 = this;
|
|
1731
1765
|
collectPointCardSnapshotCodeCandidates(value).forEach(function (_ref18) {
|
|
1732
1766
|
var id = _ref18.id,
|
|
1733
1767
|
code = _ref18.code;
|
|
1734
|
-
if (!
|
|
1735
|
-
|
|
1768
|
+
if (!_this7.pointCardSnapshotCodeCandidates.has(id)) {
|
|
1769
|
+
_this7.pointCardSnapshotCodeCandidates.set(id, code);
|
|
1736
1770
|
}
|
|
1737
1771
|
});
|
|
1738
1772
|
}
|
|
@@ -1939,23 +1973,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1939
1973
|
}, {
|
|
1940
1974
|
key: "calculatePaymentTotal",
|
|
1941
1975
|
value: function calculatePaymentTotal(payments) {
|
|
1942
|
-
var
|
|
1976
|
+
var _this8 = this;
|
|
1943
1977
|
return mapPaymentItemsToOrderPayments(payments, {
|
|
1944
1978
|
includeVoided: false
|
|
1945
1979
|
}).reduce(function (sum, payment) {
|
|
1946
1980
|
if (!isPaidPaymentRecord(payment)) return sum;
|
|
1947
|
-
return sum.plus(
|
|
1981
|
+
return sum.plus(_this8.calculatePaymentEffectiveAmount(payment));
|
|
1948
1982
|
}, new Decimal(0));
|
|
1949
1983
|
}
|
|
1950
1984
|
}, {
|
|
1951
1985
|
key: "calculateOrderPaidPaymentTotal",
|
|
1952
1986
|
value: function calculateOrderPaidPaymentTotal(payments) {
|
|
1953
|
-
var
|
|
1987
|
+
var _this9 = this;
|
|
1954
1988
|
return mapPaymentItemsToOrderPayments(payments, {
|
|
1955
1989
|
includeVoided: false
|
|
1956
1990
|
}).reduce(function (sum, payment) {
|
|
1957
1991
|
if (!isPaidPaymentRecord(payment)) return sum;
|
|
1958
|
-
return sum.plus(
|
|
1992
|
+
return sum.plus(_this9.calculatePaymentGapAmount(payment));
|
|
1959
1993
|
}, new Decimal(0));
|
|
1960
1994
|
}
|
|
1961
1995
|
}, {
|
|
@@ -2091,13 +2125,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2091
2125
|
}, {
|
|
2092
2126
|
key: "calculateDepositPaidAmount",
|
|
2093
2127
|
value: function calculateDepositPaidAmount(payments) {
|
|
2094
|
-
var
|
|
2128
|
+
var _this10 = this;
|
|
2095
2129
|
return (payments || []).reduce(function (sum, payment) {
|
|
2096
2130
|
var paymentRecord = payment;
|
|
2097
2131
|
if (!isPaidPaymentRecord(paymentRecord)) return sum;
|
|
2098
2132
|
var isDepositPayment = paymentRecord.type === 'deposit' || paymentRecord.order_payment_type === 'deposit';
|
|
2099
2133
|
if (!isDepositPayment) return sum;
|
|
2100
|
-
return sum.plus(
|
|
2134
|
+
return sum.plus(_this10.calculatePaymentGapAmount(paymentRecord));
|
|
2101
2135
|
}, new Decimal(0));
|
|
2102
2136
|
}
|
|
2103
2137
|
}, {
|
|
@@ -2134,17 +2168,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2134
2168
|
}, {
|
|
2135
2169
|
key: "getPaymentNumberDevicePrefixSync",
|
|
2136
2170
|
value: function getPaymentNumberDevicePrefixSync() {
|
|
2137
|
-
var
|
|
2171
|
+
var _this11 = this;
|
|
2138
2172
|
return resolvePaymentNumberDevicePrefixFromDeviceId(function (key) {
|
|
2139
|
-
return
|
|
2173
|
+
return _this11.getPaymentNumberAppData(key);
|
|
2140
2174
|
});
|
|
2141
2175
|
}
|
|
2142
2176
|
}, {
|
|
2143
2177
|
key: "getPaymentNumberDevicePrefixAsync",
|
|
2144
2178
|
value: function getPaymentNumberDevicePrefixAsync() {
|
|
2145
|
-
var
|
|
2179
|
+
var _this12 = this;
|
|
2146
2180
|
return resolvePaymentNumberDevicePrefix(function (key) {
|
|
2147
|
-
return
|
|
2181
|
+
return _this12.getPaymentNumberAppData(key);
|
|
2148
2182
|
});
|
|
2149
2183
|
}
|
|
2150
2184
|
}, {
|
|
@@ -2274,16 +2308,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2274
2308
|
}, {
|
|
2275
2309
|
key: "calculatePaidPaymentSummary",
|
|
2276
2310
|
value: function calculatePaidPaymentSummary(payments) {
|
|
2277
|
-
var
|
|
2311
|
+
var _this13 = this;
|
|
2278
2312
|
return (payments || []).reduce(function (summary, payment) {
|
|
2279
2313
|
var paymentRecord = payment;
|
|
2280
2314
|
if (!isPaidPaymentRecord(paymentRecord)) return summary;
|
|
2281
2315
|
return {
|
|
2282
2316
|
customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
|
|
2283
|
-
orderPaidAmount: summary.orderPaidAmount.plus(
|
|
2284
|
-
gapPaidAmount: summary.gapPaidAmount.plus(
|
|
2285
|
-
payServiceChargeAmount: summary.payServiceChargeAmount.plus(
|
|
2286
|
-
roundingAmount: summary.roundingAmount.plus(
|
|
2317
|
+
orderPaidAmount: summary.orderPaidAmount.plus(_this13.calculatePaymentOrderAmount(paymentRecord)),
|
|
2318
|
+
gapPaidAmount: summary.gapPaidAmount.plus(_this13.calculatePaymentGapAmount(paymentRecord)),
|
|
2319
|
+
payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this13.calculatePaymentServiceFee(paymentRecord)),
|
|
2320
|
+
roundingAmount: summary.roundingAmount.plus(_this13.calculatePaymentRoundingAmount(paymentRecord))
|
|
2287
2321
|
};
|
|
2288
2322
|
}, {
|
|
2289
2323
|
customerPaidAmount: new Decimal(0),
|
|
@@ -2490,15 +2524,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2490
2524
|
}, {
|
|
2491
2525
|
key: "normalizeFingerprintValue",
|
|
2492
2526
|
value: function normalizeFingerprintValue(value) {
|
|
2493
|
-
var
|
|
2527
|
+
var _this14 = this;
|
|
2494
2528
|
if (Array.isArray(value)) {
|
|
2495
2529
|
return value.map(function (item) {
|
|
2496
|
-
return
|
|
2530
|
+
return _this14.normalizeFingerprintValue(item);
|
|
2497
2531
|
});
|
|
2498
2532
|
}
|
|
2499
2533
|
if (!value || _typeof(value) !== 'object') return value !== null && value !== void 0 ? value : '';
|
|
2500
2534
|
return Object.keys(value).sort().reduce(function (result, key) {
|
|
2501
|
-
result[key] =
|
|
2535
|
+
result[key] = _this14.normalizeFingerprintValue(value[key]);
|
|
2502
2536
|
return result;
|
|
2503
2537
|
}, {});
|
|
2504
2538
|
}
|
|
@@ -2513,7 +2547,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2513
2547
|
_sku$barcode,
|
|
2514
2548
|
_ref26,
|
|
2515
2549
|
_sku$variant_id,
|
|
2516
|
-
|
|
2550
|
+
_this15 = this;
|
|
2517
2551
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
2518
2552
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
2519
2553
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
@@ -2550,7 +2584,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2550
2584
|
option_group_id: (_option$option_group_ = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_ !== void 0 ? _option$option_group_ : null,
|
|
2551
2585
|
option_group_item_id: (_ref28 = (_option$option_group_2 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_2 !== void 0 ? _option$option_group_2 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref28 !== void 0 ? _ref28 : null,
|
|
2552
2586
|
num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
|
|
2553
|
-
add_price:
|
|
2587
|
+
add_price: _this15.normalizeFingerprintMoney((_option$add_price = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price !== void 0 ? _option$add_price : option === null || option === void 0 ? void 0 : option.price)
|
|
2554
2588
|
};
|
|
2555
2589
|
})
|
|
2556
2590
|
}),
|
|
@@ -2560,8 +2594,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2560
2594
|
bundle_product_id: (_ref29 = (_ref30 = (_bundle$bundle_produc = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref30 !== void 0 ? _ref30 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref29 !== void 0 ? _ref29 : null,
|
|
2561
2595
|
bundle_variant_id: (_ref31 = (_bundle$bundle_varian = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle === null || bundle === void 0 ? void 0 : bundle.product_variant_id) !== null && _ref31 !== void 0 ? _ref31 : 0,
|
|
2562
2596
|
num: getSafeProductNum((_bundle$num = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num !== void 0 ? _bundle$num : bundle === null || bundle === void 0 ? void 0 : bundle.quantity),
|
|
2563
|
-
price:
|
|
2564
|
-
bundle_selling_price:
|
|
2597
|
+
price: _this15.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
|
|
2598
|
+
bundle_selling_price: _this15.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
|
|
2565
2599
|
price_type: (_bundle$price_type = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type !== void 0 ? _bundle$price_type : '',
|
|
2566
2600
|
price_type_ext: (_bundle$price_type_ex = bundle === null || bundle === void 0 ? void 0 : bundle.price_type_ext) !== null && _bundle$price_type_ex !== void 0 ? _bundle$price_type_ex : ''
|
|
2567
2601
|
};
|
|
@@ -2571,7 +2605,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2571
2605
|
return {
|
|
2572
2606
|
type: (_ref32 = (_discount$type2 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type2 !== void 0 ? _discount$type2 : discount === null || discount === void 0 ? void 0 : discount.tag) !== null && _ref32 !== void 0 ? _ref32 : '',
|
|
2573
2607
|
discount_id: (_ref33 = (_ref34 = (_discount$discount_id = discount === null || discount === void 0 ? void 0 : discount.discount_id) !== null && _discount$discount_id !== void 0 ? _discount$discount_id : discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== null && _ref34 !== void 0 ? _ref34 : discount === null || discount === void 0 || (_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) !== null && _ref33 !== void 0 ? _ref33 : null,
|
|
2574
|
-
amount:
|
|
2608
|
+
amount: _this15.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
2575
2609
|
};
|
|
2576
2610
|
}))
|
|
2577
2611
|
};
|
|
@@ -2579,9 +2613,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2579
2613
|
}, {
|
|
2580
2614
|
key: "buildOrderProductsFingerprint",
|
|
2581
2615
|
value: function buildOrderProductsFingerprint(products) {
|
|
2582
|
-
var
|
|
2616
|
+
var _this16 = this;
|
|
2583
2617
|
var items = (products || []).map(function (product) {
|
|
2584
|
-
return
|
|
2618
|
+
return _this16.buildProductFingerprintItem(product);
|
|
2585
2619
|
});
|
|
2586
2620
|
items.sort(function (left, right) {
|
|
2587
2621
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -2603,7 +2637,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2603
2637
|
_sku$barcode2,
|
|
2604
2638
|
_ref36,
|
|
2605
2639
|
_sku$variant_id2,
|
|
2606
|
-
|
|
2640
|
+
_this17 = this;
|
|
2607
2641
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
2608
2642
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
2609
2643
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
@@ -2637,7 +2671,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2637
2671
|
option_group_id: (_option$option_group_3 = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_3 !== void 0 ? _option$option_group_3 : null,
|
|
2638
2672
|
option_group_item_id: (_ref38 = (_option$option_group_4 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_4 !== void 0 ? _option$option_group_4 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref38 !== void 0 ? _ref38 : null,
|
|
2639
2673
|
num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
|
|
2640
|
-
add_price:
|
|
2674
|
+
add_price: _this17.normalizeFingerprintMoney((_option$add_price2 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price2 !== void 0 ? _option$add_price2 : option === null || option === void 0 ? void 0 : option.price)
|
|
2641
2675
|
};
|
|
2642
2676
|
})
|
|
2643
2677
|
}),
|
|
@@ -2651,14 +2685,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2651
2685
|
num: getSafeProductNum((_bundle$num2 = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num2 !== void 0 ? _bundle$num2 : bundle === null || bundle === void 0 ? void 0 : bundle.quantity),
|
|
2652
2686
|
price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
|
|
2653
2687
|
price_type_ext: (_bundle$price_type_ex2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type_ext) !== null && _bundle$price_type_ex2 !== void 0 ? _bundle$price_type_ex2 : '',
|
|
2654
|
-
option:
|
|
2688
|
+
option: _this17.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
|
|
2655
2689
|
var _ref44, _option$id3, _option$option_group_5, _ref45, _option$option_group_6, _option$num3, _option$add_price3;
|
|
2656
2690
|
return {
|
|
2657
2691
|
id: (_ref44 = (_option$id3 = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id3 !== void 0 ? _option$id3 : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref44 !== void 0 ? _ref44 : null,
|
|
2658
2692
|
option_group_id: (_option$option_group_5 = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_5 !== void 0 ? _option$option_group_5 : null,
|
|
2659
2693
|
option_group_item_id: (_ref45 = (_option$option_group_6 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_6 !== void 0 ? _option$option_group_6 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref45 !== void 0 ? _ref45 : null,
|
|
2660
2694
|
num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
|
|
2661
|
-
add_price:
|
|
2695
|
+
add_price: _this17.normalizeFingerprintMoney((_option$add_price3 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price3 !== void 0 ? _option$add_price3 : option === null || option === void 0 ? void 0 : option.price)
|
|
2662
2696
|
};
|
|
2663
2697
|
}))
|
|
2664
2698
|
};
|
|
@@ -2668,7 +2702,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2668
2702
|
return {
|
|
2669
2703
|
type: (_ref46 = (_discount$type4 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type4 !== void 0 ? _discount$type4 : discount === null || discount === void 0 ? void 0 : discount.tag) !== null && _ref46 !== void 0 ? _ref46 : '',
|
|
2670
2704
|
discount_id: (_ref47 = (_ref48 = (_discount$discount_id2 = discount === null || discount === void 0 ? void 0 : discount.discount_id) !== null && _discount$discount_id2 !== void 0 ? _discount$discount_id2 : discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== null && _ref48 !== void 0 ? _ref48 : discount === null || discount === void 0 || (_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) !== null && _ref47 !== void 0 ? _ref47 : null,
|
|
2671
|
-
amount:
|
|
2705
|
+
amount: _this17.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
2672
2706
|
};
|
|
2673
2707
|
}))
|
|
2674
2708
|
};
|
|
@@ -2676,9 +2710,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2676
2710
|
}, {
|
|
2677
2711
|
key: "buildOrderProductsStructuralFingerprint",
|
|
2678
2712
|
value: function buildOrderProductsStructuralFingerprint(products) {
|
|
2679
|
-
var
|
|
2713
|
+
var _this18 = this;
|
|
2680
2714
|
var items = (products || []).map(function (product) {
|
|
2681
|
-
return
|
|
2715
|
+
return _this18.buildProductStructuralFingerprintItem(product);
|
|
2682
2716
|
});
|
|
2683
2717
|
items.sort(function (left, right) {
|
|
2684
2718
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -3130,9 +3164,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3130
3164
|
}, {
|
|
3131
3165
|
key: "sanitizeTempOrderProducts",
|
|
3132
3166
|
value: function sanitizeTempOrderProducts(tempOrder) {
|
|
3133
|
-
var
|
|
3167
|
+
var _this19 = this;
|
|
3134
3168
|
tempOrder.products = (tempOrder.products || []).map(function (product) {
|
|
3135
|
-
return
|
|
3169
|
+
return _this19.sanitizeOrderProductForTempOrder(_this19.normalizeVirtualSettlementProductIfEnabled(product));
|
|
3136
3170
|
});
|
|
3137
3171
|
this.syncTempOrderSettlementState(tempOrder);
|
|
3138
3172
|
ensureUniqueProductLineUids(tempOrder);
|
|
@@ -3252,7 +3286,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3252
3286
|
}, {
|
|
3253
3287
|
key: "syncLinkedBookingHoldersToProducts",
|
|
3254
3288
|
value: function syncLinkedBookingHoldersToProducts(tempOrder) {
|
|
3255
|
-
var
|
|
3289
|
+
var _this20 = this;
|
|
3256
3290
|
var bookings = tempOrder.bookings || [];
|
|
3257
3291
|
var products = tempOrder.products || [];
|
|
3258
3292
|
if (!bookings.length || !products.length) return;
|
|
@@ -3278,7 +3312,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3278
3312
|
var bookingUid = product.booking_uid || ((_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.booking_uid);
|
|
3279
3313
|
var linkedBooking = (productUid !== undefined && productUid !== null && String(productUid) !== '' ? bookingByProductUid.get(String(productUid)) : undefined) || (bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '' ? bookingByBookingUid.get(String(bookingUid)) : undefined);
|
|
3280
3314
|
if (linkedBooking) {
|
|
3281
|
-
|
|
3315
|
+
_this20.setProductHolderFromBooking(product, linkedBooking);
|
|
3282
3316
|
}
|
|
3283
3317
|
});
|
|
3284
3318
|
}
|
|
@@ -3409,9 +3443,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3409
3443
|
}, {
|
|
3410
3444
|
key: "findBookingIndexByUniqueIdentificationNumber",
|
|
3411
3445
|
value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
|
|
3412
|
-
var
|
|
3446
|
+
var _this21 = this;
|
|
3413
3447
|
return (tempOrder.bookings || []).findIndex(function (booking) {
|
|
3414
|
-
return
|
|
3448
|
+
return _this21.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
|
|
3415
3449
|
});
|
|
3416
3450
|
}
|
|
3417
3451
|
}, {
|
|
@@ -3419,13 +3453,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3419
3453
|
value: function removeLinkedBookingsForProduct(tempOrder, product) {
|
|
3420
3454
|
var _product$metadata5,
|
|
3421
3455
|
_product$metadata6,
|
|
3422
|
-
|
|
3456
|
+
_this22 = this;
|
|
3423
3457
|
var productUid = (product === null || product === void 0 || (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
3424
3458
|
var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.booking_uid);
|
|
3425
3459
|
if (!productUid && !bookingUid) return;
|
|
3426
3460
|
tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
|
|
3427
3461
|
if (isFulfillmentTimingBooking(booking)) return true;
|
|
3428
|
-
var currentBookingUid =
|
|
3462
|
+
var currentBookingUid = _this22.getBookingUniqueIdentificationNumber(booking);
|
|
3429
3463
|
if (bookingUid && currentBookingUid === String(bookingUid)) return false;
|
|
3430
3464
|
if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
|
|
3431
3465
|
return true;
|
|
@@ -3727,7 +3761,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3727
3761
|
}, {
|
|
3728
3762
|
key: "removeSalesNotesForMissingProductLines",
|
|
3729
3763
|
value: function removeSalesNotesForMissingProductLines(tempOrder) {
|
|
3730
|
-
var
|
|
3764
|
+
var _this23 = this;
|
|
3731
3765
|
var state = this.ensureSalesNotesRuntimeState(tempOrder);
|
|
3732
3766
|
if (!state.loaded || !Array.isArray(tempOrder.notes) || tempOrder.notes.length === 0) {
|
|
3733
3767
|
return;
|
|
@@ -3739,7 +3773,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3739
3773
|
return typeof uid === 'string' && uid.length > 0;
|
|
3740
3774
|
}));
|
|
3741
3775
|
var nextNotes = tempOrder.notes.filter(function (note) {
|
|
3742
|
-
var primary =
|
|
3776
|
+
var primary = _this23.getSalesNotePrimaryRelation(note);
|
|
3743
3777
|
if (!primary || primary.target_type !== 'order_detail') return true;
|
|
3744
3778
|
return remainingProductUids.has(primary.target_uuid);
|
|
3745
3779
|
});
|
|
@@ -3751,7 +3785,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3751
3785
|
key: "setSalesNoteOnTempOrder",
|
|
3752
3786
|
value: function setSalesNoteOnTempOrder(tempOrder, input) {
|
|
3753
3787
|
var _input$target,
|
|
3754
|
-
|
|
3788
|
+
_this24 = this,
|
|
3755
3789
|
_tempOrder$shop_order;
|
|
3756
3790
|
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
3757
3791
|
var note_type = String(input.note_type || '').trim();
|
|
@@ -3775,7 +3809,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3775
3809
|
var notes = tempOrder.notes || [];
|
|
3776
3810
|
// 当前 allergy policy 固定同一商品行只保留一条;业务调用方不参与去重规则。
|
|
3777
3811
|
var existingIndex = policy.uniquePerPrimaryTarget ? notes.findIndex(function (note) {
|
|
3778
|
-
var primary =
|
|
3812
|
+
var primary = _this24.getSalesNotePrimaryRelation(note);
|
|
3779
3813
|
return note.note_type === note_type && (primary === null || primary === void 0 ? void 0 : primary.target_type) === 'order_detail' && primary.target_uuid === target_uuid;
|
|
3780
3814
|
}) : -1;
|
|
3781
3815
|
var existing = existingIndex >= 0 ? notes[existingIndex] : null;
|
|
@@ -4094,15 +4128,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4094
4128
|
}, {
|
|
4095
4129
|
key: "productHasCustomerBoundDiscount",
|
|
4096
4130
|
value: function productHasCustomerBoundDiscount(product) {
|
|
4097
|
-
var
|
|
4131
|
+
var _this25 = this;
|
|
4098
4132
|
if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
|
|
4099
|
-
return
|
|
4133
|
+
return _this25.isCustomerBoundDiscount(discount);
|
|
4100
4134
|
})) {
|
|
4101
4135
|
return true;
|
|
4102
4136
|
}
|
|
4103
4137
|
return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
|
|
4104
4138
|
return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
|
|
4105
|
-
return
|
|
4139
|
+
return _this25.isCustomerBoundDiscount(discount);
|
|
4106
4140
|
});
|
|
4107
4141
|
});
|
|
4108
4142
|
}
|
|
@@ -4111,18 +4145,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4111
4145
|
value: function shouldSkipDiscountCalculation(tempOrder) {
|
|
4112
4146
|
var _this$store$discount20,
|
|
4113
4147
|
_this$store$discount21,
|
|
4114
|
-
|
|
4148
|
+
_this26 = this;
|
|
4115
4149
|
if (this.hasActiveCustomerBoundDiscount) return false;
|
|
4116
4150
|
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)) || [];
|
|
4117
4151
|
if (discountList.length > 0) return false;
|
|
4118
4152
|
return !(tempOrder.products || []).some(function (product) {
|
|
4119
|
-
return
|
|
4153
|
+
return _this26.productHasCustomerBoundDiscount(product);
|
|
4120
4154
|
});
|
|
4121
4155
|
}
|
|
4122
4156
|
}, {
|
|
4123
4157
|
key: "clearCustomerBoundDiscounts",
|
|
4124
4158
|
value: function clearCustomerBoundDiscounts(tempOrder) {
|
|
4125
|
-
var
|
|
4159
|
+
var _this27 = this,
|
|
4126
4160
|
_discountModule$getDi,
|
|
4127
4161
|
_discountModule$getOr,
|
|
4128
4162
|
_discountModule$setDi,
|
|
@@ -4131,7 +4165,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4131
4165
|
var filterDiscountList = function filterDiscountList(discountList) {
|
|
4132
4166
|
if (!Array.isArray(discountList)) return [];
|
|
4133
4167
|
return discountList.filter(function (discount) {
|
|
4134
|
-
var shouldRemove =
|
|
4168
|
+
var shouldRemove = _this27.isCustomerBoundDiscount(discount);
|
|
4135
4169
|
if (shouldRemove) didRemoveCustomerBoundDiscount = true;
|
|
4136
4170
|
return !shouldRemove;
|
|
4137
4171
|
});
|
|
@@ -4158,12 +4192,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4158
4192
|
var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
|
|
4159
4193
|
var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
|
|
4160
4194
|
var nextDiscounts = currentDiscounts.filter(function (discount) {
|
|
4161
|
-
if (
|
|
4162
|
-
return !
|
|
4195
|
+
if (_this27.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
4196
|
+
return !_this27.isCustomerBoundDiscount(discount);
|
|
4163
4197
|
});
|
|
4164
4198
|
var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
|
|
4165
|
-
if (
|
|
4166
|
-
return !
|
|
4199
|
+
if (_this27.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
4200
|
+
return !_this27.isCustomerBoundDiscount(discount);
|
|
4167
4201
|
});
|
|
4168
4202
|
void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
|
|
4169
4203
|
void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
|
|
@@ -4327,10 +4361,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4327
4361
|
}, {
|
|
4328
4362
|
key: "setOrderPayments",
|
|
4329
4363
|
value: function setOrderPayments(payments) {
|
|
4330
|
-
var
|
|
4364
|
+
var _this28 = this;
|
|
4331
4365
|
var tempOrder = this.ensureTempOrder();
|
|
4332
4366
|
tempOrder.payments = mapPaymentItemsToOrderPayments((payments || []).map(function (payment) {
|
|
4333
|
-
return
|
|
4367
|
+
return _this28.normalizePaymentSource(payment, {
|
|
4334
4368
|
defaultPaid: false
|
|
4335
4369
|
});
|
|
4336
4370
|
}));
|
|
@@ -4385,7 +4419,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4385
4419
|
}, {
|
|
4386
4420
|
key: "addOrderPaymentWithDevicePrefix",
|
|
4387
4421
|
value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
|
|
4388
|
-
var
|
|
4422
|
+
var _this29 = this;
|
|
4389
4423
|
this.logInfo('addOrderPayment', {
|
|
4390
4424
|
payment: payment
|
|
4391
4425
|
});
|
|
@@ -4403,7 +4437,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4403
4437
|
void this.recalculateSummary({
|
|
4404
4438
|
createIfMissing: true
|
|
4405
4439
|
}).catch(function (error) {
|
|
4406
|
-
|
|
4440
|
+
_this29.logError('recalculate summary after addOrderPayment failed', {
|
|
4407
4441
|
error: error instanceof Error ? error.message : String(error)
|
|
4408
4442
|
});
|
|
4409
4443
|
});
|
|
@@ -4516,7 +4550,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4516
4550
|
}, {
|
|
4517
4551
|
key: "applyPaymentLifecycleChange",
|
|
4518
4552
|
value: function applyPaymentLifecycleChange(tempOrder, options) {
|
|
4519
|
-
var
|
|
4553
|
+
var _this30 = this;
|
|
4520
4554
|
this.updateTempOrderPaymentStatus(tempOrder);
|
|
4521
4555
|
if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
|
|
4522
4556
|
this.persistTempOrder();
|
|
@@ -4526,7 +4560,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4526
4560
|
void this.recalculateSummary({
|
|
4527
4561
|
createIfMissing: true
|
|
4528
4562
|
}).catch(function (error) {
|
|
4529
|
-
|
|
4563
|
+
_this30.logError("recalculate summary after ".concat(logContext, " failed"), {
|
|
4530
4564
|
error: error instanceof Error ? error.message : String(error)
|
|
4531
4565
|
});
|
|
4532
4566
|
});
|
|
@@ -4570,7 +4604,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4570
4604
|
}, {
|
|
4571
4605
|
key: "updateVoucherOrderPayments",
|
|
4572
4606
|
value: function updateVoucherOrderPayments(payments, options) {
|
|
4573
|
-
var
|
|
4607
|
+
var _this31 = this;
|
|
4574
4608
|
var tempOrder = this.ensureTempOrder();
|
|
4575
4609
|
var isOrderPaymentType = function isOrderPaymentType(value) {
|
|
4576
4610
|
return value === 'normal' || value === 'deposit';
|
|
@@ -4605,7 +4639,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4605
4639
|
});
|
|
4606
4640
|
};
|
|
4607
4641
|
var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
|
|
4608
|
-
return
|
|
4642
|
+
return _this31.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
|
|
4609
4643
|
defaultPaid: false,
|
|
4610
4644
|
devicePrefix: options === null || options === void 0 ? void 0 : options.devicePrefix
|
|
4611
4645
|
});
|
|
@@ -4658,7 +4692,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4658
4692
|
void this.recalculateSummary({
|
|
4659
4693
|
createIfMissing: true
|
|
4660
4694
|
}).catch(function (error) {
|
|
4661
|
-
|
|
4695
|
+
_this31.logError('recalculate summary after updateVoucherOrderPayments failed', {
|
|
4662
4696
|
error: error instanceof Error ? error.message : String(error)
|
|
4663
4697
|
});
|
|
4664
4698
|
});
|
|
@@ -4715,16 +4749,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4715
4749
|
}, {
|
|
4716
4750
|
key: "shouldMergeProductToOrder",
|
|
4717
4751
|
value: function shouldMergeProductToOrder(params) {
|
|
4718
|
-
var _this$
|
|
4719
|
-
|
|
4720
|
-
var onBeforeMergeProductToOrder = (_this$
|
|
4752
|
+
var _this$orderHooks3,
|
|
4753
|
+
_this32 = this;
|
|
4754
|
+
var onBeforeMergeProductToOrder = (_this$orderHooks3 = this.orderHooks) === null || _this$orderHooks3 === void 0 ? void 0 : _this$orderHooks3.onBeforeMergeProductToOrder;
|
|
4721
4755
|
if (!onBeforeMergeProductToOrder) return true;
|
|
4722
4756
|
var result = onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
4723
4757
|
defaultShouldMerge: true
|
|
4724
4758
|
}));
|
|
4725
4759
|
if (result && _typeof(result) === 'object' && typeof result.then === 'function') {
|
|
4726
4760
|
return Promise.resolve(result).then(function (resolved) {
|
|
4727
|
-
return
|
|
4761
|
+
return _this32.normalizeShouldMergeProductResult(resolved);
|
|
4728
4762
|
});
|
|
4729
4763
|
}
|
|
4730
4764
|
return this.normalizeShouldMergeProductResult(result);
|
|
@@ -4925,14 +4959,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4925
4959
|
_metadata,
|
|
4926
4960
|
_productToAdd$metadat,
|
|
4927
4961
|
_origin,
|
|
4928
|
-
|
|
4962
|
+
_this33 = this;
|
|
4929
4963
|
var linked = booking ? this.createLinkedProductAndBooking({
|
|
4930
4964
|
product: product,
|
|
4931
4965
|
booking: booking
|
|
4932
4966
|
}) : null;
|
|
4933
4967
|
var productToAdd = (linked === null || linked === void 0 ? void 0 : linked.product) || product;
|
|
4934
4968
|
var disableMerge = (options === null || options === void 0 ? void 0 : options.disableMerge) === true;
|
|
4935
|
-
this.assertAndLockProductSettlement(tempOrder, productToAdd);
|
|
4936
4969
|
var incomingFingerprint = disableMerge ? '' : buildProductLineFingerprint(getProductSkuOptions(productToAdd), productToAdd.product_bundle);
|
|
4937
4970
|
var normalizedIncoming = this.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(productToAdd, normalizeOrderProduct(productToAdd)));
|
|
4938
4971
|
if (disableMerge) {
|
|
@@ -4961,26 +4994,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4961
4994
|
var isIncomingCustomItem = ((_productToAdd$metadat = productToAdd.metadata) === null || _productToAdd$metadat === void 0 || (_productToAdd$metadat = _productToAdd$metadat.origin) === null || _productToAdd$metadat === void 0 ? void 0 : _productToAdd$metadat.isCustomItem) === true || ((_origin = productToAdd._origin) === null || _origin === void 0 ? void 0 : _origin.isCustomItem) === true;
|
|
4962
4995
|
var shouldForceNewLine = disableMerge || !!booking || hasIncomingGoodPass || isIncomingPersistedEntitlementPass || hasIncomingBookingUid || isIncomingCustomItem || isWeighingProduct;
|
|
4963
4996
|
var matchedIndex = shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
4964
|
-
if (
|
|
4965
|
-
var isRuntimeEntitlementPass =
|
|
4997
|
+
if (_this33.hasGoodPassDiscount(item)) return false;
|
|
4998
|
+
var isRuntimeEntitlementPass = _this33.isRuntimeEntitlementAppend(item, tempOrder);
|
|
4966
4999
|
if (isIncomingEntitlementAppend !== isRuntimeEntitlementPass) {
|
|
4967
5000
|
return false;
|
|
4968
5001
|
}
|
|
4969
|
-
if (isIncomingEntitlementAppend &&
|
|
5002
|
+
if (isIncomingEntitlementAppend && _this33.isPersistedProductLine(item)) {
|
|
4970
5003
|
return false;
|
|
4971
5004
|
}
|
|
4972
|
-
var hasExistingProductNote =
|
|
5005
|
+
var hasExistingProductNote = _this33.hasOrderProductLineNote(item);
|
|
4973
5006
|
if ((hasIncomingProductNote || hasExistingProductNote) && (!isRuntimeEntitlementPass || String(normalizedIncoming.note || '').trim() !== String(item.note || '').trim())) {
|
|
4974
5007
|
return false;
|
|
4975
5008
|
}
|
|
4976
5009
|
var hasExistingManualProductDiscount = isManualProductDiscountProduct(item);
|
|
4977
|
-
if (isRuntimeEntitlementPass && !
|
|
5010
|
+
if (isRuntimeEntitlementPass && !_this33.hasSameEntitlementMergePriceConfig(normalizedIncoming, item)) {
|
|
4978
5011
|
return false;
|
|
4979
5012
|
}
|
|
4980
5013
|
if ((hasIncomingManualProductDiscount || hasExistingManualProductDiscount) && !isRuntimeEntitlementPass) {
|
|
4981
5014
|
return false;
|
|
4982
5015
|
}
|
|
4983
|
-
if (
|
|
5016
|
+
if (_this33.isPersistedProductLine(item)) return false;
|
|
4984
5017
|
if (item.product_id !== productToAdd.product_id) return false;
|
|
4985
5018
|
if (item.product_variant_id !== productToAdd.product_variant_id) return false;
|
|
4986
5019
|
var existedFingerprint = buildProductLineFingerprint(getProductSkuOptions(item), item.product_bundle);
|
|
@@ -4989,9 +5022,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4989
5022
|
var matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
|
|
4990
5023
|
var existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
|
|
4991
5024
|
var commitProductLine = function commitProductLine(shouldMerge) {
|
|
5025
|
+
var _options$beforeCommit;
|
|
5026
|
+
options === null || options === void 0 || (_options$beforeCommit = options.beforeCommit) === null || _options$beforeCommit === void 0 || _options$beforeCommit.call(options);
|
|
5027
|
+
_this33.assertAndLockProductSettlement(tempOrder, productToAdd);
|
|
4992
5028
|
var committedProduct;
|
|
4993
5029
|
if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
|
|
4994
|
-
|
|
5030
|
+
_this33.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
|
|
4995
5031
|
if (linked) {
|
|
4996
5032
|
normalizedIncoming.booking_uid = linked.bookingUid;
|
|
4997
5033
|
normalizedIncoming.metadata = _objectSpread(_objectSpread({}, normalizedIncoming.metadata || {}), {}, {
|
|
@@ -5009,7 +5045,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5009
5045
|
var _targetProduct$metada;
|
|
5010
5046
|
var targetProduct = matchedProduct;
|
|
5011
5047
|
var targetUid = (_targetProduct$metada = targetProduct.metadata) === null || _targetProduct$metada === void 0 ? void 0 : _targetProduct$metada.unique_identification_number;
|
|
5012
|
-
var normalizedProduct =
|
|
5048
|
+
var normalizedProduct = _this33.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(targetProduct, normalizeOrderProduct(_objectSpread(_objectSpread({}, productToAdd), {}, {
|
|
5013
5049
|
metadata: _objectSpread(_objectSpread({}, productToAdd.metadata || {}), {}, {
|
|
5014
5050
|
unique_identification_number: targetUid
|
|
5015
5051
|
})
|
|
@@ -5032,7 +5068,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5032
5068
|
order_detail_id: targetProduct.order_detail_id,
|
|
5033
5069
|
num: nextNum
|
|
5034
5070
|
});
|
|
5035
|
-
|
|
5071
|
+
_this33.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
|
|
5036
5072
|
committedProduct = tempOrder.products[matchedIndex];
|
|
5037
5073
|
if (matchedIndex !== tempOrder.products.length - 1) {
|
|
5038
5074
|
var mergedProduct = tempOrder.products[matchedIndex];
|
|
@@ -5142,12 +5178,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5142
5178
|
key: "addProductToOrder",
|
|
5143
5179
|
value: (function () {
|
|
5144
5180
|
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(product, booking, options) {
|
|
5145
|
-
var
|
|
5146
|
-
var tempOrder, salesNoteDrafts, mutationSnapshot, attachSalesNoteDrafts, rollbackProductAndNotesMutation, insertAfterProductUid, anchorIndex, insertAtIndex, _ref71, _productRecord$num, productRecord, splitCount, i, splitLine, committedProduct, _committedProduct, _committedProduct2;
|
|
5181
|
+
var _this34 = this;
|
|
5182
|
+
var tempOrder, beforeCommit, salesNoteDrafts, mutationSnapshot, attachSalesNoteDrafts, rollbackProductAndNotesMutation, insertAfterProductUid, anchorIndex, insertAtIndex, _ref71, _productRecord$num, productRecord, splitCount, i, splitLine, committedProduct, _committedProduct, _committedProduct2;
|
|
5147
5183
|
return _regeneratorRuntime().wrap(function _callee23$(_context25) {
|
|
5148
5184
|
while (1) switch (_context25.prev = _context25.next) {
|
|
5149
5185
|
case 0:
|
|
5150
5186
|
tempOrder = this.ensureTempOrder();
|
|
5187
|
+
beforeCommit = this.createCartIntentCommitGuard('add_product', tempOrder);
|
|
5151
5188
|
salesNoteDrafts = ((options === null || options === void 0 ? void 0 : options.salesNotes) || []).map(function (draft) {
|
|
5152
5189
|
return {
|
|
5153
5190
|
note_type: String(draft.note_type || '').trim(),
|
|
@@ -5171,7 +5208,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5171
5208
|
throw new Error('[Order Notes] 商品行缺少 unique_identification_number');
|
|
5172
5209
|
}
|
|
5173
5210
|
salesNoteDrafts.forEach(function (draft) {
|
|
5174
|
-
|
|
5211
|
+
_this34.setSalesNoteOnTempOrder(tempOrder, {
|
|
5175
5212
|
note_type: draft.note_type,
|
|
5176
5213
|
target: {
|
|
5177
5214
|
target_type: 'order_detail',
|
|
@@ -5195,21 +5232,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5195
5232
|
return uid !== undefined && uid !== null && String(uid) === String(insertAfterProductUid);
|
|
5196
5233
|
}) : -1;
|
|
5197
5234
|
insertAtIndex = anchorIndex >= 0 ? anchorIndex + 1 : undefined;
|
|
5198
|
-
_context25.prev =
|
|
5235
|
+
_context25.prev = 9;
|
|
5199
5236
|
if (!booking) {
|
|
5200
|
-
_context25.next =
|
|
5237
|
+
_context25.next = 34;
|
|
5201
5238
|
break;
|
|
5202
5239
|
}
|
|
5203
5240
|
productRecord = product;
|
|
5204
5241
|
splitCount = getSafeProductNum((_ref71 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref71 !== void 0 ? _ref71 : 1);
|
|
5205
5242
|
if (!(splitCount > 1)) {
|
|
5206
|
-
_context25.next =
|
|
5243
|
+
_context25.next = 28;
|
|
5207
5244
|
break;
|
|
5208
5245
|
}
|
|
5209
5246
|
i = 0;
|
|
5210
|
-
case
|
|
5247
|
+
case 15:
|
|
5211
5248
|
if (!(i < splitCount)) {
|
|
5212
|
-
_context25.next =
|
|
5249
|
+
_context25.next = 26;
|
|
5213
5250
|
break;
|
|
5214
5251
|
}
|
|
5215
5252
|
splitLine = this.createSplitBookingLine(productRecord, booking, i, splitCount);
|
|
@@ -5227,65 +5264,68 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5227
5264
|
delete splitLine.booking.metadata.unique_identification_number;
|
|
5228
5265
|
}
|
|
5229
5266
|
}
|
|
5230
|
-
_context25.next =
|
|
5267
|
+
_context25.next = 20;
|
|
5231
5268
|
return this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking, {
|
|
5232
5269
|
insertAtIndex: insertAtIndex,
|
|
5233
|
-
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge
|
|
5270
|
+
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge,
|
|
5271
|
+
beforeCommit: beforeCommit
|
|
5234
5272
|
});
|
|
5235
|
-
case
|
|
5273
|
+
case 20:
|
|
5236
5274
|
committedProduct = _context25.sent;
|
|
5237
5275
|
attachSalesNoteDrafts(committedProduct);
|
|
5238
5276
|
if (insertAtIndex !== undefined) insertAtIndex += 1;
|
|
5239
|
-
case
|
|
5277
|
+
case 23:
|
|
5240
5278
|
i += 1;
|
|
5241
|
-
_context25.next =
|
|
5279
|
+
_context25.next = 15;
|
|
5242
5280
|
break;
|
|
5243
|
-
case
|
|
5244
|
-
_context25.next =
|
|
5281
|
+
case 26:
|
|
5282
|
+
_context25.next = 32;
|
|
5245
5283
|
break;
|
|
5246
|
-
case
|
|
5247
|
-
_context25.next =
|
|
5284
|
+
case 28:
|
|
5285
|
+
_context25.next = 30;
|
|
5248
5286
|
return this.appendProductLineToTempOrder(tempOrder, product, cloneDeep(booking), {
|
|
5249
5287
|
insertAtIndex: insertAtIndex,
|
|
5250
|
-
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge
|
|
5288
|
+
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge,
|
|
5289
|
+
beforeCommit: beforeCommit
|
|
5251
5290
|
});
|
|
5252
|
-
case
|
|
5291
|
+
case 30:
|
|
5253
5292
|
_committedProduct = _context25.sent;
|
|
5254
5293
|
attachSalesNoteDrafts(_committedProduct);
|
|
5255
|
-
case
|
|
5256
|
-
_context25.next =
|
|
5294
|
+
case 32:
|
|
5295
|
+
_context25.next = 38;
|
|
5257
5296
|
break;
|
|
5258
|
-
case
|
|
5259
|
-
_context25.next =
|
|
5297
|
+
case 34:
|
|
5298
|
+
_context25.next = 36;
|
|
5260
5299
|
return this.appendProductLineToTempOrder(tempOrder, product, undefined, {
|
|
5261
5300
|
insertAtIndex: insertAtIndex,
|
|
5262
|
-
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge
|
|
5301
|
+
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge,
|
|
5302
|
+
beforeCommit: beforeCommit
|
|
5263
5303
|
});
|
|
5264
|
-
case
|
|
5304
|
+
case 36:
|
|
5265
5305
|
_committedProduct2 = _context25.sent;
|
|
5266
5306
|
attachSalesNoteDrafts(_committedProduct2);
|
|
5267
|
-
case
|
|
5268
|
-
_context25.next =
|
|
5307
|
+
case 38:
|
|
5308
|
+
_context25.next = 44;
|
|
5269
5309
|
break;
|
|
5270
|
-
case
|
|
5271
|
-
_context25.prev =
|
|
5272
|
-
_context25.t0 = _context25["catch"](
|
|
5310
|
+
case 40:
|
|
5311
|
+
_context25.prev = 40;
|
|
5312
|
+
_context25.t0 = _context25["catch"](9);
|
|
5273
5313
|
rollbackProductAndNotesMutation();
|
|
5274
5314
|
throw _context25.t0;
|
|
5275
|
-
case
|
|
5276
|
-
_context25.next =
|
|
5315
|
+
case 44:
|
|
5316
|
+
_context25.next = 46;
|
|
5277
5317
|
return this.finalizeProductOrderMutation(tempOrder);
|
|
5278
|
-
case
|
|
5318
|
+
case 46:
|
|
5279
5319
|
this.logInfo('addProductToOrder success', {
|
|
5280
5320
|
product_id: product.product_id,
|
|
5281
5321
|
with_booking: !!booking
|
|
5282
5322
|
});
|
|
5283
5323
|
return _context25.abrupt("return", tempOrder.products);
|
|
5284
|
-
case
|
|
5324
|
+
case 48:
|
|
5285
5325
|
case "end":
|
|
5286
5326
|
return _context25.stop();
|
|
5287
5327
|
}
|
|
5288
|
-
}, _callee23, this, [[
|
|
5328
|
+
}, _callee23, this, [[9, 40]]);
|
|
5289
5329
|
}));
|
|
5290
5330
|
function addProductToOrder(_x23, _x24, _x25) {
|
|
5291
5331
|
return _addProductToOrder.apply(this, arguments);
|
|
@@ -5306,7 +5346,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5306
5346
|
key: "addProductsToOrder",
|
|
5307
5347
|
value: (function () {
|
|
5308
5348
|
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(items, options) {
|
|
5309
|
-
var tempOrder, _iterator20, _step20, item, product, booking, _ref72, _productRecord$num2, productRecord, splitCount, i, splitLine, _appendResult, appendResult;
|
|
5349
|
+
var tempOrder, beforeCommit, _iterator20, _step20, item, product, booking, _ref72, _productRecord$num2, productRecord, splitCount, i, splitLine, _appendResult, appendResult;
|
|
5310
5350
|
return _regeneratorRuntime().wrap(function _callee24$(_context26) {
|
|
5311
5351
|
while (1) switch (_context26.prev = _context26.next) {
|
|
5312
5352
|
case 0:
|
|
@@ -5317,87 +5357,92 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5317
5357
|
}
|
|
5318
5358
|
return _context26.abrupt("return", tempOrder.products);
|
|
5319
5359
|
case 3:
|
|
5360
|
+
beforeCommit = this.createCartIntentCommitGuard('add_product', tempOrder);
|
|
5320
5361
|
_iterator20 = _createForOfIteratorHelper(items || []);
|
|
5321
|
-
_context26.prev =
|
|
5362
|
+
_context26.prev = 5;
|
|
5322
5363
|
_iterator20.s();
|
|
5323
|
-
case
|
|
5364
|
+
case 7:
|
|
5324
5365
|
if ((_step20 = _iterator20.n()).done) {
|
|
5325
|
-
_context26.next =
|
|
5366
|
+
_context26.next = 33;
|
|
5326
5367
|
break;
|
|
5327
5368
|
}
|
|
5328
5369
|
item = _step20.value;
|
|
5329
5370
|
product = item.product, booking = item.booking;
|
|
5330
5371
|
if (product) {
|
|
5331
|
-
_context26.next =
|
|
5372
|
+
_context26.next = 12;
|
|
5332
5373
|
break;
|
|
5333
5374
|
}
|
|
5334
|
-
return _context26.abrupt("continue",
|
|
5335
|
-
case
|
|
5375
|
+
return _context26.abrupt("continue", 31);
|
|
5376
|
+
case 12:
|
|
5336
5377
|
if (!booking) {
|
|
5337
|
-
_context26.next =
|
|
5378
|
+
_context26.next = 27;
|
|
5338
5379
|
break;
|
|
5339
5380
|
}
|
|
5340
5381
|
productRecord = product;
|
|
5341
5382
|
splitCount = getSafeProductNum((_ref72 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref72 !== void 0 ? _ref72 : 1);
|
|
5342
5383
|
if (!(splitCount > 1)) {
|
|
5343
|
-
_context26.next =
|
|
5384
|
+
_context26.next = 27;
|
|
5344
5385
|
break;
|
|
5345
5386
|
}
|
|
5346
5387
|
i = 0;
|
|
5347
|
-
case
|
|
5388
|
+
case 17:
|
|
5348
5389
|
if (!(i < splitCount)) {
|
|
5349
|
-
_context26.next =
|
|
5390
|
+
_context26.next = 26;
|
|
5350
5391
|
break;
|
|
5351
5392
|
}
|
|
5352
5393
|
splitLine = this.createSplitBookingLine(productRecord, booking, i, splitCount);
|
|
5353
|
-
_appendResult = this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking
|
|
5394
|
+
_appendResult = this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking, {
|
|
5395
|
+
beforeCommit: beforeCommit
|
|
5396
|
+
});
|
|
5354
5397
|
if (!_appendResult) {
|
|
5355
|
-
_context26.next =
|
|
5398
|
+
_context26.next = 23;
|
|
5356
5399
|
break;
|
|
5357
5400
|
}
|
|
5358
|
-
_context26.next =
|
|
5401
|
+
_context26.next = 23;
|
|
5359
5402
|
return _appendResult;
|
|
5360
|
-
case
|
|
5403
|
+
case 23:
|
|
5361
5404
|
i += 1;
|
|
5362
|
-
_context26.next =
|
|
5405
|
+
_context26.next = 17;
|
|
5363
5406
|
break;
|
|
5364
|
-
case 25:
|
|
5365
|
-
return _context26.abrupt("continue", 30);
|
|
5366
5407
|
case 26:
|
|
5367
|
-
|
|
5408
|
+
return _context26.abrupt("continue", 31);
|
|
5409
|
+
case 27:
|
|
5410
|
+
appendResult = this.appendProductLineToTempOrder(tempOrder, product, booking, {
|
|
5411
|
+
beforeCommit: beforeCommit
|
|
5412
|
+
});
|
|
5368
5413
|
if (!appendResult) {
|
|
5369
|
-
_context26.next =
|
|
5414
|
+
_context26.next = 31;
|
|
5370
5415
|
break;
|
|
5371
5416
|
}
|
|
5372
|
-
_context26.next =
|
|
5417
|
+
_context26.next = 31;
|
|
5373
5418
|
return appendResult;
|
|
5374
|
-
case
|
|
5375
|
-
_context26.next =
|
|
5419
|
+
case 31:
|
|
5420
|
+
_context26.next = 7;
|
|
5376
5421
|
break;
|
|
5377
|
-
case
|
|
5378
|
-
_context26.next =
|
|
5422
|
+
case 33:
|
|
5423
|
+
_context26.next = 38;
|
|
5379
5424
|
break;
|
|
5380
|
-
case
|
|
5381
|
-
_context26.prev =
|
|
5382
|
-
_context26.t0 = _context26["catch"](
|
|
5425
|
+
case 35:
|
|
5426
|
+
_context26.prev = 35;
|
|
5427
|
+
_context26.t0 = _context26["catch"](5);
|
|
5383
5428
|
_iterator20.e(_context26.t0);
|
|
5384
|
-
case
|
|
5385
|
-
_context26.prev =
|
|
5429
|
+
case 38:
|
|
5430
|
+
_context26.prev = 38;
|
|
5386
5431
|
_iterator20.f();
|
|
5387
|
-
return _context26.finish(
|
|
5388
|
-
case
|
|
5389
|
-
_context26.next =
|
|
5432
|
+
return _context26.finish(38);
|
|
5433
|
+
case 41:
|
|
5434
|
+
_context26.next = 43;
|
|
5390
5435
|
return this.finalizeProductOrderMutation(tempOrder, options);
|
|
5391
|
-
case
|
|
5436
|
+
case 43:
|
|
5392
5437
|
this.logInfo('addProductsToOrder success', {
|
|
5393
5438
|
itemsCount: items.length
|
|
5394
5439
|
});
|
|
5395
5440
|
return _context26.abrupt("return", tempOrder.products);
|
|
5396
|
-
case
|
|
5441
|
+
case 45:
|
|
5397
5442
|
case "end":
|
|
5398
5443
|
return _context26.stop();
|
|
5399
5444
|
}
|
|
5400
|
-
}, _callee24, this, [[
|
|
5445
|
+
}, _callee24, this, [[5, 35, 38, 41]]);
|
|
5401
5446
|
}));
|
|
5402
5447
|
function addProductsToOrder(_x26, _x27) {
|
|
5403
5448
|
return _addProductsToOrder.apply(this, arguments);
|
|
@@ -5451,7 +5496,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5451
5496
|
}, {
|
|
5452
5497
|
key: "hasSameEntitlementMergePriceConfig",
|
|
5453
5498
|
value: function hasSameEntitlementMergePriceConfig(incoming, existing) {
|
|
5454
|
-
var
|
|
5499
|
+
var _this35 = this;
|
|
5455
5500
|
var buildPriceConfig = function buildPriceConfig(product) {
|
|
5456
5501
|
var metadata = product.metadata || {};
|
|
5457
5502
|
var bundle = (product.product_bundle || []).map(function (item) {
|
|
@@ -5467,10 +5512,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5467
5512
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
5468
5513
|
});
|
|
5469
5514
|
return JSON.stringify({
|
|
5470
|
-
original_price:
|
|
5471
|
-
source_product_price:
|
|
5472
|
-
main_product_original_price:
|
|
5473
|
-
price_override:
|
|
5515
|
+
original_price: _this35.normalizeFingerprintMoney(product.original_price),
|
|
5516
|
+
source_product_price: _this35.normalizeFingerprintMoney(metadata.source_product_price),
|
|
5517
|
+
main_product_original_price: _this35.normalizeFingerprintMoney(metadata.main_product_original_price),
|
|
5518
|
+
price_override: _this35.normalizeFingerprintMoney(metadata.price_override),
|
|
5474
5519
|
is_manual_discount: Boolean(metadata.is_manual_discount),
|
|
5475
5520
|
bundle: bundle
|
|
5476
5521
|
});
|
|
@@ -5487,17 +5532,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5487
5532
|
}, {
|
|
5488
5533
|
key: "preservePersistedBundlePriceFields",
|
|
5489
5534
|
value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
|
|
5490
|
-
var
|
|
5535
|
+
var _this36 = this;
|
|
5491
5536
|
if (!Array.isArray(nextBundles)) return nextBundles;
|
|
5492
5537
|
if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
|
|
5493
5538
|
var previousByIdentity = new Map();
|
|
5494
5539
|
previousBundles.forEach(function (bundle) {
|
|
5495
|
-
var identity =
|
|
5540
|
+
var identity = _this36.getBundleRuntimeIdentity(bundle);
|
|
5496
5541
|
if (identity) previousByIdentity.set(identity, bundle);
|
|
5497
5542
|
});
|
|
5498
5543
|
return nextBundles.map(function (bundle, index) {
|
|
5499
5544
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
5500
|
-
var previous = previousByIdentity.get(
|
|
5545
|
+
var previous = previousByIdentity.get(_this36.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
|
|
5501
5546
|
if (!previous || _typeof(previous) !== 'object') return bundle;
|
|
5502
5547
|
return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
|
|
5503
5548
|
cover: previous.cover
|
|
@@ -5511,6 +5556,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5511
5556
|
});
|
|
5512
5557
|
});
|
|
5513
5558
|
}
|
|
5559
|
+
}, {
|
|
5560
|
+
key: "isRestrictedCartProductUpdate",
|
|
5561
|
+
value: function isRestrictedCartProductUpdate(tempOrder, params) {
|
|
5562
|
+
var _this$orderHooks4, _params$updates;
|
|
5563
|
+
if (!((_this$orderHooks4 = this.orderHooks) !== null && _this$orderHooks4 !== void 0 && _this$orderHooks4.beforeCartIntentCommit)) return false;
|
|
5564
|
+
if (params.booking || Object.keys(params.updates || {}).some(function (key) {
|
|
5565
|
+
return key !== 'num';
|
|
5566
|
+
})) {
|
|
5567
|
+
return true;
|
|
5568
|
+
}
|
|
5569
|
+
if (((_params$updates = params.updates) === null || _params$updates === void 0 ? void 0 : _params$updates.num) === undefined) return false;
|
|
5570
|
+
var uid = params.unique_identification_number;
|
|
5571
|
+
var product = uid !== undefined ? tempOrder.products.find(function (item) {
|
|
5572
|
+
var _item$metadata4;
|
|
5573
|
+
return String(((_item$metadata4 = item.metadata) === null || _item$metadata4 === void 0 ? void 0 : _item$metadata4.unique_identification_number) || item.unique_identification_number || '') === String(uid);
|
|
5574
|
+
}) : tempOrder.products[getProductIdentityIndex(tempOrder.products, params)];
|
|
5575
|
+
return !product || getSafeProductNum(params.updates.num) > product.num;
|
|
5576
|
+
}
|
|
5514
5577
|
}, {
|
|
5515
5578
|
key: "applyOrderProductUpdateToTempOrder",
|
|
5516
5579
|
value: function applyOrderProductUpdateToTempOrder(tempOrder, params) {
|
|
@@ -5542,8 +5605,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5542
5605
|
if (unique_identification_number !== undefined) {
|
|
5543
5606
|
var targetUid = String(unique_identification_number);
|
|
5544
5607
|
productIndex = tempOrder.products.findIndex(function (item) {
|
|
5545
|
-
var _item$
|
|
5546
|
-
return String(((_item$
|
|
5608
|
+
var _item$metadata5;
|
|
5609
|
+
return String(((_item$metadata5 = item.metadata) === null || _item$metadata5 === void 0 ? void 0 : _item$metadata5.unique_identification_number) || item.unique_identification_number || '') === targetUid;
|
|
5547
5610
|
});
|
|
5548
5611
|
}
|
|
5549
5612
|
if (productIndex === -1) {
|
|
@@ -5704,27 +5767,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5704
5767
|
while (1) switch (_context27.prev = _context27.next) {
|
|
5705
5768
|
case 0:
|
|
5706
5769
|
tempOrder = this.ensureTempOrder();
|
|
5770
|
+
if (this.isRestrictedCartProductUpdate(tempOrder, params)) {
|
|
5771
|
+
this.createCartIntentCommitGuard('update_product', tempOrder)();
|
|
5772
|
+
}
|
|
5707
5773
|
updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
5708
|
-
_context27.next =
|
|
5774
|
+
_context27.next = 5;
|
|
5709
5775
|
return this.evaluatePromotion();
|
|
5710
|
-
case
|
|
5776
|
+
case 5:
|
|
5711
5777
|
promotionPayload = _context27.sent;
|
|
5712
5778
|
this.applyDiscount({
|
|
5713
5779
|
reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
|
|
5714
5780
|
});
|
|
5715
5781
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
5716
|
-
_context27.next =
|
|
5782
|
+
_context27.next = 10;
|
|
5717
5783
|
return this.recalculateSummary({
|
|
5718
5784
|
createIfMissing: true
|
|
5719
5785
|
});
|
|
5720
|
-
case
|
|
5786
|
+
case 10:
|
|
5721
5787
|
this.persistTempOrder();
|
|
5722
5788
|
this.emitPromotionApplied(promotionPayload);
|
|
5723
5789
|
this.logInfo('updateOrderProduct success', {
|
|
5724
5790
|
params: params
|
|
5725
5791
|
});
|
|
5726
5792
|
return _context27.abrupt("return", tempOrder.products);
|
|
5727
|
-
case
|
|
5793
|
+
case 14:
|
|
5728
5794
|
case "end":
|
|
5729
5795
|
return _context27.stop();
|
|
5730
5796
|
}
|
|
@@ -5739,7 +5805,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5739
5805
|
key: "updateOrderProducts",
|
|
5740
5806
|
value: function () {
|
|
5741
5807
|
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(paramsList) {
|
|
5742
|
-
var
|
|
5808
|
+
var _this37 = this;
|
|
5743
5809
|
var tempOrder, reapplyBookingDiscountProductUids;
|
|
5744
5810
|
return _regeneratorRuntime().wrap(function _callee26$(_context28) {
|
|
5745
5811
|
while (1) switch (_context28.prev = _context28.next) {
|
|
@@ -5751,24 +5817,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5751
5817
|
}
|
|
5752
5818
|
return _context28.abrupt("return", tempOrder.products);
|
|
5753
5819
|
case 3:
|
|
5820
|
+
if (paramsList.some(function (params) {
|
|
5821
|
+
return _this37.isRestrictedCartProductUpdate(tempOrder, params);
|
|
5822
|
+
})) {
|
|
5823
|
+
this.createCartIntentCommitGuard('update_product', tempOrder)();
|
|
5824
|
+
}
|
|
5754
5825
|
reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
|
|
5755
|
-
var updatedProductUid =
|
|
5826
|
+
var updatedProductUid = _this37.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
5756
5827
|
// 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
|
|
5757
5828
|
if (params.allow_booking_discount_reapply && updatedProductUid) {
|
|
5758
5829
|
acc.push(String(updatedProductUid));
|
|
5759
5830
|
}
|
|
5760
5831
|
return acc;
|
|
5761
5832
|
}, []);
|
|
5762
|
-
_context28.next =
|
|
5833
|
+
_context28.next = 7;
|
|
5763
5834
|
return this.finalizeAfterProductsMutation(tempOrder, {
|
|
5764
5835
|
reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
|
|
5765
5836
|
});
|
|
5766
|
-
case
|
|
5837
|
+
case 7:
|
|
5767
5838
|
this.logInfo('updateOrderProduct success', {
|
|
5768
5839
|
paramsList: paramsList
|
|
5769
5840
|
});
|
|
5770
5841
|
return _context28.abrupt("return", tempOrder.products);
|
|
5771
|
-
case
|
|
5842
|
+
case 9:
|
|
5772
5843
|
case "end":
|
|
5773
5844
|
return _context28.stop();
|
|
5774
5845
|
}
|
|
@@ -5808,8 +5879,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5808
5879
|
if (unique_identification_number !== undefined) {
|
|
5809
5880
|
targetUid = String(unique_identification_number);
|
|
5810
5881
|
productIndex = tempOrder.products.findIndex(function (item) {
|
|
5811
|
-
var _item$
|
|
5812
|
-
return String(((_item$
|
|
5882
|
+
var _item$metadata6;
|
|
5883
|
+
return String(((_item$metadata6 = item.metadata) === null || _item$metadata6 === void 0 ? void 0 : _item$metadata6.unique_identification_number) || item.unique_identification_number || '') === targetUid;
|
|
5813
5884
|
});
|
|
5814
5885
|
}
|
|
5815
5886
|
if (productIndex === -1) {
|
|
@@ -5857,39 +5928,42 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5857
5928
|
}
|
|
5858
5929
|
throw new VirtualCurrencyBalanceError(balance.toFixed(2), requiredAmount.toFixed(2));
|
|
5859
5930
|
case 27:
|
|
5931
|
+
if (normalizedProduct.num > targetProduct.num) {
|
|
5932
|
+
this.createCartIntentCommitGuard('increase_quantity', tempOrder)();
|
|
5933
|
+
}
|
|
5860
5934
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
5861
5935
|
this.prepareVirtualSettlementTempOrder(tempOrder);
|
|
5862
5936
|
isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder);
|
|
5863
5937
|
if (isVirtualSettlement) {
|
|
5864
|
-
_context29.next =
|
|
5938
|
+
_context29.next = 37;
|
|
5865
5939
|
break;
|
|
5866
5940
|
}
|
|
5867
|
-
_context29.next =
|
|
5941
|
+
_context29.next = 34;
|
|
5868
5942
|
return this.evaluatePromotion();
|
|
5869
|
-
case
|
|
5943
|
+
case 34:
|
|
5870
5944
|
_context29.t0 = _context29.sent;
|
|
5871
|
-
_context29.next =
|
|
5945
|
+
_context29.next = 38;
|
|
5872
5946
|
break;
|
|
5873
|
-
case 36:
|
|
5874
|
-
_context29.t0 = null;
|
|
5875
5947
|
case 37:
|
|
5948
|
+
_context29.t0 = null;
|
|
5949
|
+
case 38:
|
|
5876
5950
|
promotionPayload = _context29.t0;
|
|
5877
5951
|
if (!isVirtualSettlement) {
|
|
5878
5952
|
this.applyDiscount();
|
|
5879
5953
|
}
|
|
5880
5954
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
5881
|
-
_context29.next =
|
|
5955
|
+
_context29.next = 43;
|
|
5882
5956
|
return this.recalculateSummary({
|
|
5883
5957
|
createIfMissing: true
|
|
5884
5958
|
});
|
|
5885
|
-
case
|
|
5959
|
+
case 43:
|
|
5886
5960
|
this.persistTempOrder();
|
|
5887
5961
|
this.emitPromotionApplied(promotionPayload);
|
|
5888
5962
|
this.logInfo('updateOrderProductQuantity success', {
|
|
5889
5963
|
params: params
|
|
5890
5964
|
});
|
|
5891
5965
|
return _context29.abrupt("return", tempOrder.products);
|
|
5892
|
-
case
|
|
5966
|
+
case 47:
|
|
5893
5967
|
case "end":
|
|
5894
5968
|
return _context29.stop();
|
|
5895
5969
|
}
|
|
@@ -5979,7 +6053,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5979
6053
|
key: "removeProductsFromOrder",
|
|
5980
6054
|
value: (function () {
|
|
5981
6055
|
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(identities, options) {
|
|
5982
|
-
var
|
|
6056
|
+
var _this38 = this;
|
|
5983
6057
|
var tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
|
|
5984
6058
|
return _regeneratorRuntime().wrap(function _callee29$(_context32) {
|
|
5985
6059
|
while (1) switch (_context32.prev = _context32.next) {
|
|
@@ -5998,8 +6072,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5998
6072
|
bookingsBeforeRemove = tempOrder.bookings || [];
|
|
5999
6073
|
preserveDisplayPosition = options === null || options === void 0 ? void 0 : options.preserveDisplayPosition;
|
|
6000
6074
|
anchorIndex = preserveDisplayPosition ? productsBeforeRemove.findIndex(function (item) {
|
|
6001
|
-
var _item$
|
|
6002
|
-
var uid = ((_item$
|
|
6075
|
+
var _item$metadata7;
|
|
6076
|
+
var uid = ((_item$metadata7 = item.metadata) === null || _item$metadata7 === void 0 ? void 0 : _item$metadata7.unique_identification_number) || item.unique_identification_number;
|
|
6003
6077
|
return uid !== undefined && uid !== null && String(uid) === String(preserveDisplayPosition.anchorProductUid);
|
|
6004
6078
|
}) : -1;
|
|
6005
6079
|
productsAfterAnchor = anchorIndex >= 0 ? productsBeforeRemove.slice(anchorIndex + 1) : [];
|
|
@@ -6044,7 +6118,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6044
6118
|
}
|
|
6045
6119
|
if (productUid !== undefined && productUid !== null && productUid !== '') {
|
|
6046
6120
|
bookingsBeforeRemove.forEach(function (booking) {
|
|
6047
|
-
var bookingUid =
|
|
6121
|
+
var bookingUid = _this38.getBookingUniqueIdentificationNumber(booking);
|
|
6048
6122
|
if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
|
|
6049
6123
|
linkedBookingUidsToRemove.add(bookingUid);
|
|
6050
6124
|
}
|
|
@@ -6095,8 +6169,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6095
6169
|
}
|
|
6096
6170
|
if (preserveDisplayPosition && anchorIndex >= 0) {
|
|
6097
6171
|
remainingProductIndex = tempOrder.products.findIndex(function (item) {
|
|
6098
|
-
var _item$
|
|
6099
|
-
var uid = ((_item$
|
|
6172
|
+
var _item$metadata8;
|
|
6173
|
+
var uid = ((_item$metadata8 = item.metadata) === null || _item$metadata8 === void 0 ? void 0 : _item$metadata8.unique_identification_number) || item.unique_identification_number;
|
|
6100
6174
|
return uid !== undefined && uid !== null && String(uid) === String(preserveDisplayPosition.remainingProductUid);
|
|
6101
6175
|
});
|
|
6102
6176
|
if (remainingProductIndex >= 0) {
|
|
@@ -6676,10 +6750,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6676
6750
|
value: function extractSubmitErrorResponse(error) {
|
|
6677
6751
|
var _error$response,
|
|
6678
6752
|
_error$response2,
|
|
6679
|
-
|
|
6753
|
+
_this39 = this;
|
|
6680
6754
|
var candidates = [error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data, error === null || error === void 0 ? void 0 : error.data, error === null || error === void 0 || (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.body, error === null || error === void 0 ? void 0 : error.body];
|
|
6681
6755
|
return candidates.find(function (candidate) {
|
|
6682
|
-
return
|
|
6756
|
+
return _this39.isSubmitErrorResponse(candidate);
|
|
6683
6757
|
}) || null;
|
|
6684
6758
|
}
|
|
6685
6759
|
}, {
|
|
@@ -6707,7 +6781,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6707
6781
|
key: "syncPaymentsToOrder",
|
|
6708
6782
|
value: function () {
|
|
6709
6783
|
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
|
|
6710
|
-
var
|
|
6784
|
+
var _this40 = this,
|
|
6711
6785
|
_params$confirmPendin;
|
|
6712
6786
|
var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, enhancePayload, submitParams, submitResult;
|
|
6713
6787
|
return _regeneratorRuntime().wrap(function _callee39$(_context42) {
|
|
@@ -6732,7 +6806,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6732
6806
|
case 9:
|
|
6733
6807
|
devicePrefix = _context42.t0;
|
|
6734
6808
|
mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
|
|
6735
|
-
return
|
|
6809
|
+
return _this40.normalizePaymentSource(payment, {
|
|
6736
6810
|
defaultPaid: false,
|
|
6737
6811
|
devicePrefix: devicePrefix
|
|
6738
6812
|
});
|
|
@@ -6811,7 +6885,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6811
6885
|
}, {
|
|
6812
6886
|
key: "createOrder",
|
|
6813
6887
|
value: function createOrder(params) {
|
|
6814
|
-
var
|
|
6888
|
+
var _this41 = this;
|
|
6815
6889
|
var order = _objectSpread({
|
|
6816
6890
|
type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
|
|
6817
6891
|
// 要从外面拿,virtual
|
|
@@ -6843,7 +6917,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6843
6917
|
|
|
6844
6918
|
// 为预约补齐 holder 信息
|
|
6845
6919
|
if (params !== null && params !== void 0 && (_params$extraData = params.extraData) !== null && _params$extraData !== void 0 && _params$extraData.is_add_holder_info) {
|
|
6846
|
-
ensureCartItemOriginHolder(item,
|
|
6920
|
+
ensureCartItemOriginHolder(item, _this41.window);
|
|
6847
6921
|
}
|
|
6848
6922
|
|
|
6849
6923
|
// 购物车是否为普通商品
|
|
@@ -7544,7 +7618,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7544
7618
|
}, {
|
|
7545
7619
|
key: "normalizeTempOrderForRuntime",
|
|
7546
7620
|
value: function normalizeTempOrderForRuntime(raw, options) {
|
|
7547
|
-
var
|
|
7621
|
+
var _this42 = this,
|
|
7548
7622
|
_raw$_extend;
|
|
7549
7623
|
var runtimeRaw = this.withoutSyntheticDraftOrderIdForRuntime(raw);
|
|
7550
7624
|
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
|
|
@@ -7569,12 +7643,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7569
7643
|
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
7570
7644
|
var rawProducts = Array.isArray(raw.products) ? raw.products : [];
|
|
7571
7645
|
nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
|
|
7572
|
-
return
|
|
7646
|
+
return _this42.normalizeHydratedOrderProduct(p, {
|
|
7573
7647
|
makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
|
|
7574
7648
|
});
|
|
7575
7649
|
}) : [];
|
|
7576
7650
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
7577
|
-
var booking =
|
|
7651
|
+
var booking = _this42.normalizeHydratedBookingHolder(b || {});
|
|
7578
7652
|
return _objectSpread(_objectSpread({}, booking), {}, {
|
|
7579
7653
|
is_all: normalizeBookingIsAll(booking),
|
|
7580
7654
|
sub_type: normalizeBookingSubType(booking)
|
|
@@ -7781,7 +7855,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7781
7855
|
}, {
|
|
7782
7856
|
key: "normalizeHydratedOrderProduct",
|
|
7783
7857
|
value: function normalizeHydratedOrderProduct(product, options) {
|
|
7784
|
-
var
|
|
7858
|
+
var _this43 = this;
|
|
7785
7859
|
var row = _objectSpread({}, product || {});
|
|
7786
7860
|
if (row.num === undefined && row.product_quantity !== undefined) {
|
|
7787
7861
|
row.num = row.product_quantity;
|
|
@@ -7789,7 +7863,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7789
7863
|
var productSku = ensureProductSku(row);
|
|
7790
7864
|
row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
|
|
7791
7865
|
option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
|
|
7792
|
-
return
|
|
7866
|
+
return _this43.normalizeHydratedProductOptionItem(optionItem || {});
|
|
7793
7867
|
}))
|
|
7794
7868
|
});
|
|
7795
7869
|
delete row["product_".concat('option', "_item")];
|