@pisell/pisellos 2.3.130 → 2.3.132
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/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 +151 -89
- 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/dist/solution/VenueBooking/index.js +45 -44
- 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 +64 -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/lib/solution/VenueBooking/index.js +9 -8
- package/package.json +1 -1
|
@@ -522,6 +522,36 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
522
522
|
this.otherParams = otherParams;
|
|
523
523
|
}
|
|
524
524
|
|
|
525
|
+
/** Internal intent boundary shared with asynchronous scanner/detail flows. */
|
|
526
|
+
}, {
|
|
527
|
+
key: "createCartIntentCommitGuard",
|
|
528
|
+
value: function createCartIntentCommitGuard(action) {
|
|
529
|
+
var _this$orderHooks,
|
|
530
|
+
_this$orderHooks2,
|
|
531
|
+
_this2 = this;
|
|
532
|
+
var tempOrder = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.store.tempOrder;
|
|
533
|
+
var hook = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.beforeCartIntentCommit;
|
|
534
|
+
if (!hook) return function () {};
|
|
535
|
+
var getScope = (_this$orderHooks2 = this.orderHooks) === null || _this$orderHooks2 === void 0 ? void 0 : _this$orderHooks2.getCartIntentScope;
|
|
536
|
+
var scope = getScope === null || getScope === void 0 ? void 0 : getScope();
|
|
537
|
+
var otherParams = this.otherParams;
|
|
538
|
+
var committed = false;
|
|
539
|
+
return function () {
|
|
540
|
+
var _this2$orderHooks, _this2$orderHooks2;
|
|
541
|
+
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) {
|
|
542
|
+
throw new Error('[Order] Cart intent belongs to a previous order or business');
|
|
543
|
+
}
|
|
544
|
+
// Derived gifts, discounts and persistence belong to the accepted intent,
|
|
545
|
+
// but an asynchronous continuation must never target a different cart.
|
|
546
|
+
if (committed) return;
|
|
547
|
+
hook({
|
|
548
|
+
action: action,
|
|
549
|
+
tempOrder: tempOrder
|
|
550
|
+
});
|
|
551
|
+
committed = true;
|
|
552
|
+
};
|
|
553
|
+
}
|
|
554
|
+
|
|
525
555
|
/** PC/H5 属于在线店铺;其它或缺失平台统一沿用 POS 行为。 */
|
|
526
556
|
}, {
|
|
527
557
|
key: "isOnlineStorePlatform",
|
|
@@ -613,10 +643,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
613
643
|
}, {
|
|
614
644
|
key: "createDefaultRulesHooks",
|
|
615
645
|
value: function createDefaultRulesHooks() {
|
|
616
|
-
var
|
|
646
|
+
var _this3 = this;
|
|
617
647
|
return createDefaultOrderRulesHooks(function () {
|
|
618
|
-
var
|
|
619
|
-
return ((
|
|
648
|
+
var _this3$store$tempOrde;
|
|
649
|
+
return ((_this3$store$tempOrde = _this3.store.tempOrder) === null || _this3$store$tempOrde === void 0 ? void 0 : _this3$store$tempOrde.bookings) || [];
|
|
620
650
|
});
|
|
621
651
|
}
|
|
622
652
|
|
|
@@ -639,7 +669,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
639
669
|
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
640
670
|
var _this$store$tempOrder,
|
|
641
671
|
_this$store$discount,
|
|
642
|
-
|
|
672
|
+
_this4 = this,
|
|
643
673
|
_this$store$tempOrder2;
|
|
644
674
|
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;
|
|
645
675
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
@@ -667,8 +697,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
667
697
|
case 5:
|
|
668
698
|
prepareConfigResult = _context3.sent;
|
|
669
699
|
isCurrentRequest = function isCurrentRequest() {
|
|
670
|
-
var
|
|
671
|
-
return requestEpoch ===
|
|
700
|
+
var _this4$store$tempOrde, _this4$store$tempOrde2;
|
|
701
|
+
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);
|
|
672
702
|
};
|
|
673
703
|
if (isCurrentRequest()) {
|
|
674
704
|
_context3.next = 9;
|
|
@@ -900,12 +930,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
900
930
|
value: function () {
|
|
901
931
|
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(code, customerId) {
|
|
902
932
|
var _this$store$discount11, _tempOrder$holder, _this$store$summary;
|
|
903
|
-
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;
|
|
933
|
+
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;
|
|
904
934
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
905
935
|
while (1) switch (_context6.prev = _context6.next) {
|
|
906
936
|
case 0:
|
|
937
|
+
beforeCommit = this.createCartIntentCommitGuard('scan_promotion');
|
|
907
938
|
if (!this.isActiveVirtualSettlementOrder(this.store.tempOrder)) {
|
|
908
|
-
_context6.next =
|
|
939
|
+
_context6.next = 3;
|
|
909
940
|
break;
|
|
910
941
|
}
|
|
911
942
|
return _context6.abrupt("return", {
|
|
@@ -916,27 +947,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
916
947
|
scannedDiscountList: [],
|
|
917
948
|
unavailableReason: UnavailableReason.ProductNotApplicable
|
|
918
949
|
});
|
|
919
|
-
case
|
|
920
|
-
_context6.next =
|
|
950
|
+
case 3:
|
|
951
|
+
_context6.next = 5;
|
|
921
952
|
return (_this$store$discount11 = this.store.discount) === null || _this$store$discount11 === void 0 ? void 0 : _this$store$discount11.batchSearch(code, {
|
|
922
953
|
customerId: customerId
|
|
923
954
|
});
|
|
924
|
-
case
|
|
955
|
+
case 5:
|
|
925
956
|
_context6.t0 = _context6.sent;
|
|
926
957
|
if (_context6.t0) {
|
|
927
|
-
_context6.next =
|
|
958
|
+
_context6.next = 8;
|
|
928
959
|
break;
|
|
929
960
|
}
|
|
930
961
|
_context6.t0 = {
|
|
931
962
|
discountList: [],
|
|
932
963
|
unavailableReasonKey: null
|
|
933
964
|
};
|
|
934
|
-
case
|
|
965
|
+
case 8:
|
|
935
966
|
resultDiscountWithReason = _context6.t0;
|
|
936
967
|
resultDiscountList = resultDiscountWithReason.discountList, unavailableReasonKey = resultDiscountWithReason.unavailableReasonKey;
|
|
937
968
|
rulesModule = this.store.rules;
|
|
938
969
|
if (rulesModule) {
|
|
939
|
-
_context6.next =
|
|
970
|
+
_context6.next = 13;
|
|
940
971
|
break;
|
|
941
972
|
}
|
|
942
973
|
return _context6.abrupt("return", {
|
|
@@ -947,9 +978,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
947
978
|
scannedDiscountList: resultDiscountList,
|
|
948
979
|
unavailableReason: UnavailableReason.Unknown
|
|
949
980
|
});
|
|
950
|
-
case
|
|
981
|
+
case 13:
|
|
951
982
|
if (resultDiscountList.length) {
|
|
952
|
-
_context6.next =
|
|
983
|
+
_context6.next = 15;
|
|
953
984
|
break;
|
|
954
985
|
}
|
|
955
986
|
return _context6.abrupt("return", {
|
|
@@ -960,7 +991,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
960
991
|
scannedDiscountList: resultDiscountList,
|
|
961
992
|
unavailableReasonKey: unavailableReasonKey
|
|
962
993
|
});
|
|
963
|
-
case
|
|
994
|
+
case 15:
|
|
964
995
|
withScanList = resultDiscountList.map(function (item) {
|
|
965
996
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
966
997
|
isScan: true
|
|
@@ -974,12 +1005,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
974
1005
|
return m.id === n.id;
|
|
975
1006
|
});
|
|
976
1007
|
}))) {
|
|
977
|
-
_context6.next =
|
|
1008
|
+
_context6.next = 22;
|
|
978
1009
|
break;
|
|
979
1010
|
}
|
|
980
|
-
|
|
1011
|
+
beforeCommit();
|
|
1012
|
+
_context6.next = 21;
|
|
981
1013
|
return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
982
|
-
case
|
|
1014
|
+
case 21:
|
|
983
1015
|
return _context6.abrupt("return", {
|
|
984
1016
|
type: 'clientCalc',
|
|
985
1017
|
isAvailable: true,
|
|
@@ -987,7 +1019,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
987
1019
|
discountList: this.getDiscountList(),
|
|
988
1020
|
scannedDiscountList: resultDiscountList
|
|
989
1021
|
});
|
|
990
|
-
case
|
|
1022
|
+
case 22:
|
|
991
1023
|
tempOrder = this.store.tempOrder;
|
|
992
1024
|
holders = (tempOrder === null || tempOrder === void 0 || (_tempOrder$holder = tempOrder.holder) === null || _tempOrder$holder === void 0 ? void 0 : _tempOrder$holder.form_record) || [];
|
|
993
1025
|
_ref16 = rulesModule.isDiscountListAvailable({
|
|
@@ -1013,12 +1045,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1013
1045
|
normalizedNewDiscountList = newDiscountList ? markScannedDiscounts(newDiscountList, withScanList) : undefined;
|
|
1014
1046
|
resolvedDiscountList = normalizedNewDiscountList || this.getDiscountList();
|
|
1015
1047
|
if (!(isAvailable && normalizedNewDiscountList)) {
|
|
1016
|
-
_context6.next =
|
|
1048
|
+
_context6.next = 40;
|
|
1017
1049
|
break;
|
|
1018
1050
|
}
|
|
1019
|
-
|
|
1051
|
+
beforeCommit();
|
|
1052
|
+
_context6.next = 34;
|
|
1020
1053
|
return (_this$store$discount12 = this.store.discount) === null || _this$store$discount12 === void 0 ? void 0 : _this$store$discount12.setDiscountList(normalizedNewDiscountList);
|
|
1021
|
-
case
|
|
1054
|
+
case 34:
|
|
1022
1055
|
// 实际写回商品时沿用扫码试算的优先级,避免旧商品行的选卡覆盖本次扫码。
|
|
1023
1056
|
this.applyDiscount({
|
|
1024
1057
|
preferredEntitlementPassIds: withScanList.filter(function (discount) {
|
|
@@ -1027,17 +1060,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1027
1060
|
return discount.id;
|
|
1028
1061
|
})
|
|
1029
1062
|
});
|
|
1030
|
-
_context6.next =
|
|
1063
|
+
_context6.next = 37;
|
|
1031
1064
|
return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
1032
|
-
case
|
|
1065
|
+
case 37:
|
|
1033
1066
|
resolvedDiscountList = this.getDiscountList();
|
|
1034
|
-
_context6.next =
|
|
1067
|
+
_context6.next = 49;
|
|
1035
1068
|
break;
|
|
1036
|
-
case
|
|
1069
|
+
case 40:
|
|
1037
1070
|
if (!shouldRetainForLater) {
|
|
1038
|
-
_context6.next =
|
|
1071
|
+
_context6.next = 49;
|
|
1039
1072
|
break;
|
|
1040
1073
|
}
|
|
1074
|
+
beforeCommit();
|
|
1041
1075
|
// 只合并本次识别的卡券;不把试算产生的其他选券状态写回订单。
|
|
1042
1076
|
retainedDiscounts = new Map(this.getDiscountList().map(function (discount) {
|
|
1043
1077
|
return [String(discount.id), discount];
|
|
@@ -1052,14 +1086,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1052
1086
|
savedAmount: 0
|
|
1053
1087
|
}));
|
|
1054
1088
|
});
|
|
1055
|
-
_context6.next =
|
|
1089
|
+
_context6.next = 46;
|
|
1056
1090
|
return (_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.setDiscountList(_toConsumableArray(retainedDiscounts.values()));
|
|
1057
|
-
case
|
|
1058
|
-
_context6.next =
|
|
1091
|
+
case 46:
|
|
1092
|
+
_context6.next = 48;
|
|
1059
1093
|
return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
1060
|
-
case
|
|
1094
|
+
case 48:
|
|
1061
1095
|
resolvedDiscountList = this.getDiscountList();
|
|
1062
|
-
case
|
|
1096
|
+
case 49:
|
|
1063
1097
|
return _context6.abrupt("return", {
|
|
1064
1098
|
type: 'clientCalc',
|
|
1065
1099
|
isAvailable: isAvailable || false,
|
|
@@ -1068,7 +1102,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1068
1102
|
scannedDiscountList: evaluatedScannedDiscounts,
|
|
1069
1103
|
unavailableReason: unavailableReason
|
|
1070
1104
|
});
|
|
1071
|
-
case
|
|
1105
|
+
case 50:
|
|
1072
1106
|
case "end":
|
|
1073
1107
|
return _context6.stop();
|
|
1074
1108
|
}
|
|
@@ -1084,7 +1118,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1084
1118
|
value: function applyDiscount(options) {
|
|
1085
1119
|
var _this$store$discount16,
|
|
1086
1120
|
_this$store$summary2,
|
|
1087
|
-
|
|
1121
|
+
_this5 = this;
|
|
1088
1122
|
var tempOrder = this.store.tempOrder;
|
|
1089
1123
|
// 任意 products CRUD 后都应当重算 discount 状态;即使 products 为空,
|
|
1090
1124
|
// 也需要让 Rules.calcDiscount 把 DiscountModule 的 isSelected / isAvailable /
|
|
@@ -1142,7 +1176,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1142
1176
|
(_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 || _this$store$discount17.setDiscountList(result.discountList);
|
|
1143
1177
|
}
|
|
1144
1178
|
this.hasActiveCustomerBoundDiscount = (tempOrder.products || []).some(function (product) {
|
|
1145
|
-
return
|
|
1179
|
+
return _this5.productHasCustomerBoundDiscount(product);
|
|
1146
1180
|
});
|
|
1147
1181
|
}
|
|
1148
1182
|
|
|
@@ -1205,7 +1239,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1205
1239
|
var _evaluatePromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
1206
1240
|
var _this$promotionEvalua,
|
|
1207
1241
|
_this$promotionEvalua2,
|
|
1208
|
-
|
|
1242
|
+
_this6 = this;
|
|
1209
1243
|
var tempOrder, strategyConfigs, result, removeSet, _iterator3, _step3, reduce, _iterator6, _step6, _loop2, _iterator4, _step4, _loop, payload;
|
|
1210
1244
|
return _regeneratorRuntime().wrap(function _callee7$(_context9) {
|
|
1211
1245
|
while (1) switch (_context9.prev = _context9.next) {
|
|
@@ -1364,7 +1398,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1364
1398
|
case 6:
|
|
1365
1399
|
_context7.prev = 6;
|
|
1366
1400
|
_context7.next = 9;
|
|
1367
|
-
return
|
|
1401
|
+
return _this6.giftSelectResolver({
|
|
1368
1402
|
strategyId: addAction.strategyId,
|
|
1369
1403
|
strategyName: addAction.strategyName,
|
|
1370
1404
|
giftCount: addAction.giftCount,
|
|
@@ -1399,7 +1433,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1399
1433
|
_context7.next = 26;
|
|
1400
1434
|
break;
|
|
1401
1435
|
}
|
|
1402
|
-
linked =
|
|
1436
|
+
linked = _this6.createLinkedProductAndBooking({
|
|
1403
1437
|
product: gp,
|
|
1404
1438
|
booking: booking
|
|
1405
1439
|
});
|
|
@@ -1729,12 +1763,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1729
1763
|
}, {
|
|
1730
1764
|
key: "rememberPointCardSnapshotCodeCandidates",
|
|
1731
1765
|
value: function rememberPointCardSnapshotCodeCandidates(value) {
|
|
1732
|
-
var
|
|
1766
|
+
var _this7 = this;
|
|
1733
1767
|
collectPointCardSnapshotCodeCandidates(value).forEach(function (_ref18) {
|
|
1734
1768
|
var id = _ref18.id,
|
|
1735
1769
|
code = _ref18.code;
|
|
1736
|
-
if (!
|
|
1737
|
-
|
|
1770
|
+
if (!_this7.pointCardSnapshotCodeCandidates.has(id)) {
|
|
1771
|
+
_this7.pointCardSnapshotCodeCandidates.set(id, code);
|
|
1738
1772
|
}
|
|
1739
1773
|
});
|
|
1740
1774
|
}
|
|
@@ -1941,23 +1975,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1941
1975
|
}, {
|
|
1942
1976
|
key: "calculatePaymentTotal",
|
|
1943
1977
|
value: function calculatePaymentTotal(payments) {
|
|
1944
|
-
var
|
|
1978
|
+
var _this8 = this;
|
|
1945
1979
|
return mapPaymentItemsToOrderPayments(payments, {
|
|
1946
1980
|
includeVoided: false
|
|
1947
1981
|
}).reduce(function (sum, payment) {
|
|
1948
1982
|
if (!isPaidPaymentRecord(payment)) return sum;
|
|
1949
|
-
return sum.plus(
|
|
1983
|
+
return sum.plus(_this8.calculatePaymentEffectiveAmount(payment));
|
|
1950
1984
|
}, new Decimal(0));
|
|
1951
1985
|
}
|
|
1952
1986
|
}, {
|
|
1953
1987
|
key: "calculateOrderPaidPaymentTotal",
|
|
1954
1988
|
value: function calculateOrderPaidPaymentTotal(payments) {
|
|
1955
|
-
var
|
|
1989
|
+
var _this9 = this;
|
|
1956
1990
|
return mapPaymentItemsToOrderPayments(payments, {
|
|
1957
1991
|
includeVoided: false
|
|
1958
1992
|
}).reduce(function (sum, payment) {
|
|
1959
1993
|
if (!isPaidPaymentRecord(payment)) return sum;
|
|
1960
|
-
return sum.plus(
|
|
1994
|
+
return sum.plus(_this9.calculatePaymentGapAmount(payment));
|
|
1961
1995
|
}, new Decimal(0));
|
|
1962
1996
|
}
|
|
1963
1997
|
}, {
|
|
@@ -2093,13 +2127,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2093
2127
|
}, {
|
|
2094
2128
|
key: "calculateDepositPaidAmount",
|
|
2095
2129
|
value: function calculateDepositPaidAmount(payments) {
|
|
2096
|
-
var
|
|
2130
|
+
var _this10 = this;
|
|
2097
2131
|
return (payments || []).reduce(function (sum, payment) {
|
|
2098
2132
|
var paymentRecord = payment;
|
|
2099
2133
|
if (!isPaidPaymentRecord(paymentRecord)) return sum;
|
|
2100
2134
|
var isDepositPayment = paymentRecord.type === 'deposit' || paymentRecord.order_payment_type === 'deposit';
|
|
2101
2135
|
if (!isDepositPayment) return sum;
|
|
2102
|
-
return sum.plus(
|
|
2136
|
+
return sum.plus(_this10.calculatePaymentGapAmount(paymentRecord));
|
|
2103
2137
|
}, new Decimal(0));
|
|
2104
2138
|
}
|
|
2105
2139
|
}, {
|
|
@@ -2136,17 +2170,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2136
2170
|
}, {
|
|
2137
2171
|
key: "getPaymentNumberDevicePrefixSync",
|
|
2138
2172
|
value: function getPaymentNumberDevicePrefixSync() {
|
|
2139
|
-
var
|
|
2173
|
+
var _this11 = this;
|
|
2140
2174
|
return resolvePaymentNumberDevicePrefixFromDeviceId(function (key) {
|
|
2141
|
-
return
|
|
2175
|
+
return _this11.getPaymentNumberAppData(key);
|
|
2142
2176
|
});
|
|
2143
2177
|
}
|
|
2144
2178
|
}, {
|
|
2145
2179
|
key: "getPaymentNumberDevicePrefixAsync",
|
|
2146
2180
|
value: function getPaymentNumberDevicePrefixAsync() {
|
|
2147
|
-
var
|
|
2181
|
+
var _this12 = this;
|
|
2148
2182
|
return resolvePaymentNumberDevicePrefix(function (key) {
|
|
2149
|
-
return
|
|
2183
|
+
return _this12.getPaymentNumberAppData(key);
|
|
2150
2184
|
});
|
|
2151
2185
|
}
|
|
2152
2186
|
}, {
|
|
@@ -2276,16 +2310,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2276
2310
|
}, {
|
|
2277
2311
|
key: "calculatePaidPaymentSummary",
|
|
2278
2312
|
value: function calculatePaidPaymentSummary(payments) {
|
|
2279
|
-
var
|
|
2313
|
+
var _this13 = this;
|
|
2280
2314
|
return (payments || []).reduce(function (summary, payment) {
|
|
2281
2315
|
var paymentRecord = payment;
|
|
2282
2316
|
if (!isPaidPaymentRecord(paymentRecord)) return summary;
|
|
2283
2317
|
return {
|
|
2284
2318
|
customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
|
|
2285
|
-
orderPaidAmount: summary.orderPaidAmount.plus(
|
|
2286
|
-
gapPaidAmount: summary.gapPaidAmount.plus(
|
|
2287
|
-
payServiceChargeAmount: summary.payServiceChargeAmount.plus(
|
|
2288
|
-
roundingAmount: summary.roundingAmount.plus(
|
|
2319
|
+
orderPaidAmount: summary.orderPaidAmount.plus(_this13.calculatePaymentOrderAmount(paymentRecord)),
|
|
2320
|
+
gapPaidAmount: summary.gapPaidAmount.plus(_this13.calculatePaymentGapAmount(paymentRecord)),
|
|
2321
|
+
payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this13.calculatePaymentServiceFee(paymentRecord)),
|
|
2322
|
+
roundingAmount: summary.roundingAmount.plus(_this13.calculatePaymentRoundingAmount(paymentRecord))
|
|
2289
2323
|
};
|
|
2290
2324
|
}, {
|
|
2291
2325
|
customerPaidAmount: new Decimal(0),
|
|
@@ -2492,15 +2526,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2492
2526
|
}, {
|
|
2493
2527
|
key: "normalizeFingerprintValue",
|
|
2494
2528
|
value: function normalizeFingerprintValue(value) {
|
|
2495
|
-
var
|
|
2529
|
+
var _this14 = this;
|
|
2496
2530
|
if (Array.isArray(value)) {
|
|
2497
2531
|
return value.map(function (item) {
|
|
2498
|
-
return
|
|
2532
|
+
return _this14.normalizeFingerprintValue(item);
|
|
2499
2533
|
});
|
|
2500
2534
|
}
|
|
2501
2535
|
if (!value || _typeof(value) !== 'object') return value !== null && value !== void 0 ? value : '';
|
|
2502
2536
|
return Object.keys(value).sort().reduce(function (result, key) {
|
|
2503
|
-
result[key] =
|
|
2537
|
+
result[key] = _this14.normalizeFingerprintValue(value[key]);
|
|
2504
2538
|
return result;
|
|
2505
2539
|
}, {});
|
|
2506
2540
|
}
|
|
@@ -2515,7 +2549,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2515
2549
|
_sku$barcode,
|
|
2516
2550
|
_ref26,
|
|
2517
2551
|
_sku$variant_id,
|
|
2518
|
-
|
|
2552
|
+
_this15 = this;
|
|
2519
2553
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
2520
2554
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
2521
2555
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
@@ -2552,7 +2586,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2552
2586
|
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,
|
|
2553
2587
|
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,
|
|
2554
2588
|
num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
|
|
2555
|
-
add_price:
|
|
2589
|
+
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)
|
|
2556
2590
|
};
|
|
2557
2591
|
})
|
|
2558
2592
|
}),
|
|
@@ -2562,8 +2596,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2562
2596
|
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,
|
|
2563
2597
|
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,
|
|
2564
2598
|
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),
|
|
2565
|
-
price:
|
|
2566
|
-
bundle_selling_price:
|
|
2599
|
+
price: _this15.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
|
|
2600
|
+
bundle_selling_price: _this15.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
|
|
2567
2601
|
price_type: (_bundle$price_type = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type !== void 0 ? _bundle$price_type : '',
|
|
2568
2602
|
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 : ''
|
|
2569
2603
|
};
|
|
@@ -2573,7 +2607,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2573
2607
|
return {
|
|
2574
2608
|
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 : '',
|
|
2575
2609
|
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,
|
|
2576
|
-
amount:
|
|
2610
|
+
amount: _this15.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
2577
2611
|
};
|
|
2578
2612
|
}))
|
|
2579
2613
|
};
|
|
@@ -2581,9 +2615,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2581
2615
|
}, {
|
|
2582
2616
|
key: "buildOrderProductsFingerprint",
|
|
2583
2617
|
value: function buildOrderProductsFingerprint(products) {
|
|
2584
|
-
var
|
|
2618
|
+
var _this16 = this;
|
|
2585
2619
|
var items = (products || []).map(function (product) {
|
|
2586
|
-
return
|
|
2620
|
+
return _this16.buildProductFingerprintItem(product);
|
|
2587
2621
|
});
|
|
2588
2622
|
items.sort(function (left, right) {
|
|
2589
2623
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -2605,7 +2639,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2605
2639
|
_sku$barcode2,
|
|
2606
2640
|
_ref36,
|
|
2607
2641
|
_sku$variant_id2,
|
|
2608
|
-
|
|
2642
|
+
_this17 = this;
|
|
2609
2643
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
2610
2644
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
2611
2645
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
@@ -2639,7 +2673,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2639
2673
|
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,
|
|
2640
2674
|
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,
|
|
2641
2675
|
num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
|
|
2642
|
-
add_price:
|
|
2676
|
+
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)
|
|
2643
2677
|
};
|
|
2644
2678
|
})
|
|
2645
2679
|
}),
|
|
@@ -2653,14 +2687,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2653
2687
|
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),
|
|
2654
2688
|
price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
|
|
2655
2689
|
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 : '',
|
|
2656
|
-
option:
|
|
2690
|
+
option: _this17.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
|
|
2657
2691
|
var _ref44, _option$id3, _option$option_group_5, _ref45, _option$option_group_6, _option$num3, _option$add_price3;
|
|
2658
2692
|
return {
|
|
2659
2693
|
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,
|
|
2660
2694
|
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,
|
|
2661
2695
|
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,
|
|
2662
2696
|
num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
|
|
2663
|
-
add_price:
|
|
2697
|
+
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)
|
|
2664
2698
|
};
|
|
2665
2699
|
}))
|
|
2666
2700
|
};
|
|
@@ -2670,7 +2704,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2670
2704
|
return {
|
|
2671
2705
|
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 : '',
|
|
2672
2706
|
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,
|
|
2673
|
-
amount:
|
|
2707
|
+
amount: _this17.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
2674
2708
|
};
|
|
2675
2709
|
}))
|
|
2676
2710
|
};
|
|
@@ -2678,9 +2712,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2678
2712
|
}, {
|
|
2679
2713
|
key: "buildOrderProductsStructuralFingerprint",
|
|
2680
2714
|
value: function buildOrderProductsStructuralFingerprint(products) {
|
|
2681
|
-
var
|
|
2715
|
+
var _this18 = this;
|
|
2682
2716
|
var items = (products || []).map(function (product) {
|
|
2683
|
-
return
|
|
2717
|
+
return _this18.buildProductStructuralFingerprintItem(product);
|
|
2684
2718
|
});
|
|
2685
2719
|
items.sort(function (left, right) {
|
|
2686
2720
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -3132,9 +3166,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3132
3166
|
}, {
|
|
3133
3167
|
key: "sanitizeTempOrderProducts",
|
|
3134
3168
|
value: function sanitizeTempOrderProducts(tempOrder) {
|
|
3135
|
-
var
|
|
3169
|
+
var _this19 = this;
|
|
3136
3170
|
tempOrder.products = (tempOrder.products || []).map(function (product) {
|
|
3137
|
-
return
|
|
3171
|
+
return _this19.sanitizeOrderProductForTempOrder(_this19.normalizeVirtualSettlementProductIfEnabled(product));
|
|
3138
3172
|
});
|
|
3139
3173
|
this.syncTempOrderSettlementState(tempOrder);
|
|
3140
3174
|
ensureUniqueProductLineUids(tempOrder);
|
|
@@ -3254,7 +3288,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3254
3288
|
}, {
|
|
3255
3289
|
key: "syncLinkedBookingHoldersToProducts",
|
|
3256
3290
|
value: function syncLinkedBookingHoldersToProducts(tempOrder) {
|
|
3257
|
-
var
|
|
3291
|
+
var _this20 = this;
|
|
3258
3292
|
var bookings = tempOrder.bookings || [];
|
|
3259
3293
|
var products = tempOrder.products || [];
|
|
3260
3294
|
if (!bookings.length || !products.length) return;
|
|
@@ -3280,7 +3314,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3280
3314
|
var bookingUid = product.booking_uid || ((_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.booking_uid);
|
|
3281
3315
|
var linkedBooking = (productUid !== undefined && productUid !== null && String(productUid) !== '' ? bookingByProductUid.get(String(productUid)) : undefined) || (bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '' ? bookingByBookingUid.get(String(bookingUid)) : undefined);
|
|
3282
3316
|
if (linkedBooking) {
|
|
3283
|
-
|
|
3317
|
+
_this20.setProductHolderFromBooking(product, linkedBooking);
|
|
3284
3318
|
}
|
|
3285
3319
|
});
|
|
3286
3320
|
}
|
|
@@ -3411,9 +3445,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3411
3445
|
}, {
|
|
3412
3446
|
key: "findBookingIndexByUniqueIdentificationNumber",
|
|
3413
3447
|
value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
|
|
3414
|
-
var
|
|
3448
|
+
var _this21 = this;
|
|
3415
3449
|
return (tempOrder.bookings || []).findIndex(function (booking) {
|
|
3416
|
-
return
|
|
3450
|
+
return _this21.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
|
|
3417
3451
|
});
|
|
3418
3452
|
}
|
|
3419
3453
|
}, {
|
|
@@ -3421,13 +3455,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3421
3455
|
value: function removeLinkedBookingsForProduct(tempOrder, product) {
|
|
3422
3456
|
var _product$metadata5,
|
|
3423
3457
|
_product$metadata6,
|
|
3424
|
-
|
|
3458
|
+
_this22 = this;
|
|
3425
3459
|
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);
|
|
3426
3460
|
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);
|
|
3427
3461
|
if (!productUid && !bookingUid) return;
|
|
3428
3462
|
tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
|
|
3429
3463
|
if (isFulfillmentTimingBooking(booking)) return true;
|
|
3430
|
-
var currentBookingUid =
|
|
3464
|
+
var currentBookingUid = _this22.getBookingUniqueIdentificationNumber(booking);
|
|
3431
3465
|
if (bookingUid && currentBookingUid === String(bookingUid)) return false;
|
|
3432
3466
|
if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
|
|
3433
3467
|
return true;
|
|
@@ -3729,7 +3763,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3729
3763
|
}, {
|
|
3730
3764
|
key: "removeSalesNotesForMissingProductLines",
|
|
3731
3765
|
value: function removeSalesNotesForMissingProductLines(tempOrder) {
|
|
3732
|
-
var
|
|
3766
|
+
var _this23 = this;
|
|
3733
3767
|
var state = this.ensureSalesNotesRuntimeState(tempOrder);
|
|
3734
3768
|
if (!state.loaded || !Array.isArray(tempOrder.notes) || tempOrder.notes.length === 0) {
|
|
3735
3769
|
return;
|
|
@@ -3741,7 +3775,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3741
3775
|
return typeof uid === 'string' && uid.length > 0;
|
|
3742
3776
|
}));
|
|
3743
3777
|
var nextNotes = tempOrder.notes.filter(function (note) {
|
|
3744
|
-
var primary =
|
|
3778
|
+
var primary = _this23.getSalesNotePrimaryRelation(note);
|
|
3745
3779
|
if (!primary || primary.target_type !== 'order_detail') return true;
|
|
3746
3780
|
return remainingProductUids.has(primary.target_uuid);
|
|
3747
3781
|
});
|
|
@@ -3753,7 +3787,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3753
3787
|
key: "setSalesNoteOnTempOrder",
|
|
3754
3788
|
value: function setSalesNoteOnTempOrder(tempOrder, input) {
|
|
3755
3789
|
var _input$target,
|
|
3756
|
-
|
|
3790
|
+
_this24 = this,
|
|
3757
3791
|
_tempOrder$shop_order;
|
|
3758
3792
|
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
3759
3793
|
var note_type = String(input.note_type || '').trim();
|
|
@@ -3777,7 +3811,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3777
3811
|
var notes = tempOrder.notes || [];
|
|
3778
3812
|
// 当前 allergy policy 固定同一商品行只保留一条;业务调用方不参与去重规则。
|
|
3779
3813
|
var existingIndex = policy.uniquePerPrimaryTarget ? notes.findIndex(function (note) {
|
|
3780
|
-
var primary =
|
|
3814
|
+
var primary = _this24.getSalesNotePrimaryRelation(note);
|
|
3781
3815
|
return note.note_type === note_type && (primary === null || primary === void 0 ? void 0 : primary.target_type) === 'order_detail' && primary.target_uuid === target_uuid;
|
|
3782
3816
|
}) : -1;
|
|
3783
3817
|
var existing = existingIndex >= 0 ? notes[existingIndex] : null;
|
|
@@ -4096,15 +4130,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4096
4130
|
}, {
|
|
4097
4131
|
key: "productHasCustomerBoundDiscount",
|
|
4098
4132
|
value: function productHasCustomerBoundDiscount(product) {
|
|
4099
|
-
var
|
|
4133
|
+
var _this25 = this;
|
|
4100
4134
|
if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
|
|
4101
|
-
return
|
|
4135
|
+
return _this25.isCustomerBoundDiscount(discount);
|
|
4102
4136
|
})) {
|
|
4103
4137
|
return true;
|
|
4104
4138
|
}
|
|
4105
4139
|
return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
|
|
4106
4140
|
return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
|
|
4107
|
-
return
|
|
4141
|
+
return _this25.isCustomerBoundDiscount(discount);
|
|
4108
4142
|
});
|
|
4109
4143
|
});
|
|
4110
4144
|
}
|
|
@@ -4113,18 +4147,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4113
4147
|
value: function shouldSkipDiscountCalculation(tempOrder) {
|
|
4114
4148
|
var _this$store$discount20,
|
|
4115
4149
|
_this$store$discount21,
|
|
4116
|
-
|
|
4150
|
+
_this26 = this;
|
|
4117
4151
|
if (this.hasActiveCustomerBoundDiscount) return false;
|
|
4118
4152
|
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)) || [];
|
|
4119
4153
|
if (discountList.length > 0) return false;
|
|
4120
4154
|
return !(tempOrder.products || []).some(function (product) {
|
|
4121
|
-
return
|
|
4155
|
+
return _this26.productHasCustomerBoundDiscount(product);
|
|
4122
4156
|
});
|
|
4123
4157
|
}
|
|
4124
4158
|
}, {
|
|
4125
4159
|
key: "clearCustomerBoundDiscounts",
|
|
4126
4160
|
value: function clearCustomerBoundDiscounts(tempOrder) {
|
|
4127
|
-
var
|
|
4161
|
+
var _this27 = this,
|
|
4128
4162
|
_discountModule$getDi,
|
|
4129
4163
|
_discountModule$getOr,
|
|
4130
4164
|
_discountModule$setDi,
|
|
@@ -4133,7 +4167,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4133
4167
|
var filterDiscountList = function filterDiscountList(discountList) {
|
|
4134
4168
|
if (!Array.isArray(discountList)) return [];
|
|
4135
4169
|
return discountList.filter(function (discount) {
|
|
4136
|
-
var shouldRemove =
|
|
4170
|
+
var shouldRemove = _this27.isCustomerBoundDiscount(discount);
|
|
4137
4171
|
if (shouldRemove) didRemoveCustomerBoundDiscount = true;
|
|
4138
4172
|
return !shouldRemove;
|
|
4139
4173
|
});
|
|
@@ -4160,12 +4194,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4160
4194
|
var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
|
|
4161
4195
|
var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
|
|
4162
4196
|
var nextDiscounts = currentDiscounts.filter(function (discount) {
|
|
4163
|
-
if (
|
|
4164
|
-
return !
|
|
4197
|
+
if (_this27.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
4198
|
+
return !_this27.isCustomerBoundDiscount(discount);
|
|
4165
4199
|
});
|
|
4166
4200
|
var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
|
|
4167
|
-
if (
|
|
4168
|
-
return !
|
|
4201
|
+
if (_this27.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
4202
|
+
return !_this27.isCustomerBoundDiscount(discount);
|
|
4169
4203
|
});
|
|
4170
4204
|
void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
|
|
4171
4205
|
void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
|
|
@@ -4329,10 +4363,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4329
4363
|
}, {
|
|
4330
4364
|
key: "setOrderPayments",
|
|
4331
4365
|
value: function setOrderPayments(payments) {
|
|
4332
|
-
var
|
|
4366
|
+
var _this28 = this;
|
|
4333
4367
|
var tempOrder = this.ensureTempOrder();
|
|
4334
4368
|
tempOrder.payments = mapPaymentItemsToOrderPayments((payments || []).map(function (payment) {
|
|
4335
|
-
return
|
|
4369
|
+
return _this28.normalizePaymentSource(payment, {
|
|
4336
4370
|
defaultPaid: false
|
|
4337
4371
|
});
|
|
4338
4372
|
}));
|
|
@@ -4387,7 +4421,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4387
4421
|
}, {
|
|
4388
4422
|
key: "addOrderPaymentWithDevicePrefix",
|
|
4389
4423
|
value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
|
|
4390
|
-
var
|
|
4424
|
+
var _this29 = this;
|
|
4391
4425
|
this.logInfo('addOrderPayment', {
|
|
4392
4426
|
payment: payment
|
|
4393
4427
|
});
|
|
@@ -4405,7 +4439,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4405
4439
|
void this.recalculateSummary({
|
|
4406
4440
|
createIfMissing: true
|
|
4407
4441
|
}).catch(function (error) {
|
|
4408
|
-
|
|
4442
|
+
_this29.logError('recalculate summary after addOrderPayment failed', {
|
|
4409
4443
|
error: error instanceof Error ? error.message : String(error)
|
|
4410
4444
|
});
|
|
4411
4445
|
});
|
|
@@ -4518,7 +4552,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4518
4552
|
}, {
|
|
4519
4553
|
key: "applyPaymentLifecycleChange",
|
|
4520
4554
|
value: function applyPaymentLifecycleChange(tempOrder, options) {
|
|
4521
|
-
var
|
|
4555
|
+
var _this30 = this;
|
|
4522
4556
|
this.updateTempOrderPaymentStatus(tempOrder);
|
|
4523
4557
|
if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
|
|
4524
4558
|
this.persistTempOrder();
|
|
@@ -4528,7 +4562,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4528
4562
|
void this.recalculateSummary({
|
|
4529
4563
|
createIfMissing: true
|
|
4530
4564
|
}).catch(function (error) {
|
|
4531
|
-
|
|
4565
|
+
_this30.logError("recalculate summary after ".concat(logContext, " failed"), {
|
|
4532
4566
|
error: error instanceof Error ? error.message : String(error)
|
|
4533
4567
|
});
|
|
4534
4568
|
});
|
|
@@ -4572,7 +4606,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4572
4606
|
}, {
|
|
4573
4607
|
key: "updateVoucherOrderPayments",
|
|
4574
4608
|
value: function updateVoucherOrderPayments(payments, options) {
|
|
4575
|
-
var
|
|
4609
|
+
var _this31 = this;
|
|
4576
4610
|
var tempOrder = this.ensureTempOrder();
|
|
4577
4611
|
var isOrderPaymentType = function isOrderPaymentType(value) {
|
|
4578
4612
|
return value === 'normal' || value === 'deposit';
|
|
@@ -4607,7 +4641,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4607
4641
|
});
|
|
4608
4642
|
};
|
|
4609
4643
|
var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
|
|
4610
|
-
return
|
|
4644
|
+
return _this31.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
|
|
4611
4645
|
defaultPaid: false,
|
|
4612
4646
|
devicePrefix: options === null || options === void 0 ? void 0 : options.devicePrefix
|
|
4613
4647
|
});
|
|
@@ -4660,7 +4694,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4660
4694
|
void this.recalculateSummary({
|
|
4661
4695
|
createIfMissing: true
|
|
4662
4696
|
}).catch(function (error) {
|
|
4663
|
-
|
|
4697
|
+
_this31.logError('recalculate summary after updateVoucherOrderPayments failed', {
|
|
4664
4698
|
error: error instanceof Error ? error.message : String(error)
|
|
4665
4699
|
});
|
|
4666
4700
|
});
|
|
@@ -4717,16 +4751,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4717
4751
|
}, {
|
|
4718
4752
|
key: "shouldMergeProductToOrder",
|
|
4719
4753
|
value: function shouldMergeProductToOrder(params) {
|
|
4720
|
-
var _this$
|
|
4721
|
-
|
|
4722
|
-
var onBeforeMergeProductToOrder = (_this$
|
|
4754
|
+
var _this$orderHooks3,
|
|
4755
|
+
_this32 = this;
|
|
4756
|
+
var onBeforeMergeProductToOrder = (_this$orderHooks3 = this.orderHooks) === null || _this$orderHooks3 === void 0 ? void 0 : _this$orderHooks3.onBeforeMergeProductToOrder;
|
|
4723
4757
|
if (!onBeforeMergeProductToOrder) return true;
|
|
4724
4758
|
var result = onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
4725
4759
|
defaultShouldMerge: true
|
|
4726
4760
|
}));
|
|
4727
4761
|
if (result && _typeof(result) === 'object' && typeof result.then === 'function') {
|
|
4728
4762
|
return Promise.resolve(result).then(function (resolved) {
|
|
4729
|
-
return
|
|
4763
|
+
return _this32.normalizeShouldMergeProductResult(resolved);
|
|
4730
4764
|
});
|
|
4731
4765
|
}
|
|
4732
4766
|
return this.normalizeShouldMergeProductResult(result);
|
|
@@ -4927,13 +4961,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4927
4961
|
_metadata,
|
|
4928
4962
|
_productToAdd$metadat,
|
|
4929
4963
|
_origin,
|
|
4930
|
-
|
|
4964
|
+
_this33 = this;
|
|
4931
4965
|
var linked = booking ? this.createLinkedProductAndBooking({
|
|
4932
4966
|
product: product,
|
|
4933
4967
|
booking: booking
|
|
4934
4968
|
}) : null;
|
|
4935
4969
|
var productToAdd = (linked === null || linked === void 0 ? void 0 : linked.product) || product;
|
|
4936
|
-
this.assertAndLockProductSettlement(tempOrder, productToAdd);
|
|
4937
4970
|
var disableMerge = (options === null || options === void 0 ? void 0 : options.disableMerge) === true;
|
|
4938
4971
|
var incomingFingerprint = disableMerge ? '' : buildProductLineFingerprint(getProductSkuOptions(productToAdd), productToAdd.product_bundle);
|
|
4939
4972
|
var normalizedIncoming = this.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(productToAdd, normalizeOrderProduct(productToAdd)));
|
|
@@ -4963,26 +4996,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4963
4996
|
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;
|
|
4964
4997
|
var shouldForceNewLine = disableMerge || !!booking || hasIncomingGoodPass || isIncomingPersistedEntitlementPass || hasIncomingBookingUid || isIncomingCustomItem || isWeighingProduct;
|
|
4965
4998
|
var matchedIndex = shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
4966
|
-
if (
|
|
4967
|
-
var isRuntimeEntitlementPass =
|
|
4999
|
+
if (_this33.hasGoodPassDiscount(item)) return false;
|
|
5000
|
+
var isRuntimeEntitlementPass = _this33.isRuntimeEntitlementAppend(item, tempOrder);
|
|
4968
5001
|
if (isIncomingEntitlementAppend !== isRuntimeEntitlementPass) {
|
|
4969
5002
|
return false;
|
|
4970
5003
|
}
|
|
4971
|
-
if (isIncomingEntitlementAppend &&
|
|
5004
|
+
if (isIncomingEntitlementAppend && _this33.isPersistedProductLine(item)) {
|
|
4972
5005
|
return false;
|
|
4973
5006
|
}
|
|
4974
|
-
var hasExistingProductNote =
|
|
5007
|
+
var hasExistingProductNote = _this33.hasOrderProductLineNote(item);
|
|
4975
5008
|
if ((hasIncomingProductNote || hasExistingProductNote) && (!isRuntimeEntitlementPass || String(normalizedIncoming.note || '').trim() !== String(item.note || '').trim())) {
|
|
4976
5009
|
return false;
|
|
4977
5010
|
}
|
|
4978
5011
|
var hasExistingManualProductDiscount = isManualProductDiscountProduct(item);
|
|
4979
|
-
if (isRuntimeEntitlementPass && !
|
|
5012
|
+
if (isRuntimeEntitlementPass && !_this33.hasSameEntitlementMergePriceConfig(normalizedIncoming, item)) {
|
|
4980
5013
|
return false;
|
|
4981
5014
|
}
|
|
4982
5015
|
if ((hasIncomingManualProductDiscount || hasExistingManualProductDiscount) && !isRuntimeEntitlementPass) {
|
|
4983
5016
|
return false;
|
|
4984
5017
|
}
|
|
4985
|
-
if (
|
|
5018
|
+
if (_this33.isPersistedProductLine(item)) return false;
|
|
4986
5019
|
if (item.product_id !== productToAdd.product_id) return false;
|
|
4987
5020
|
if (item.product_variant_id !== productToAdd.product_variant_id) return false;
|
|
4988
5021
|
var existedFingerprint = buildProductLineFingerprint(getProductSkuOptions(item), item.product_bundle);
|
|
@@ -4991,9 +5024,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4991
5024
|
var matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
|
|
4992
5025
|
var existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
|
|
4993
5026
|
var commitProductLine = function commitProductLine(shouldMerge) {
|
|
5027
|
+
var _options$beforeCommit;
|
|
5028
|
+
options === null || options === void 0 || (_options$beforeCommit = options.beforeCommit) === null || _options$beforeCommit === void 0 || _options$beforeCommit.call(options);
|
|
5029
|
+
_this33.assertAndLockProductSettlement(tempOrder, productToAdd);
|
|
4994
5030
|
var committedProduct;
|
|
4995
5031
|
if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
|
|
4996
|
-
|
|
5032
|
+
_this33.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
|
|
4997
5033
|
if (linked) {
|
|
4998
5034
|
normalizedIncoming.booking_uid = linked.bookingUid;
|
|
4999
5035
|
normalizedIncoming.metadata = _objectSpread(_objectSpread({}, normalizedIncoming.metadata || {}), {}, {
|
|
@@ -5011,7 +5047,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5011
5047
|
var _targetProduct$metada;
|
|
5012
5048
|
var targetProduct = matchedProduct;
|
|
5013
5049
|
var targetUid = (_targetProduct$metada = targetProduct.metadata) === null || _targetProduct$metada === void 0 ? void 0 : _targetProduct$metada.unique_identification_number;
|
|
5014
|
-
var normalizedProduct =
|
|
5050
|
+
var normalizedProduct = _this33.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(targetProduct, normalizeOrderProduct(_objectSpread(_objectSpread({}, productToAdd), {}, {
|
|
5015
5051
|
metadata: _objectSpread(_objectSpread({}, productToAdd.metadata || {}), {}, {
|
|
5016
5052
|
unique_identification_number: targetUid
|
|
5017
5053
|
})
|
|
@@ -5034,7 +5070,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5034
5070
|
order_detail_id: targetProduct.order_detail_id,
|
|
5035
5071
|
num: nextNum
|
|
5036
5072
|
});
|
|
5037
|
-
|
|
5073
|
+
_this33.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
|
|
5038
5074
|
committedProduct = tempOrder.products[matchedIndex];
|
|
5039
5075
|
if (matchedIndex !== tempOrder.products.length - 1) {
|
|
5040
5076
|
var mergedProduct = tempOrder.products[matchedIndex];
|
|
@@ -5144,12 +5180,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5144
5180
|
key: "addProductToOrder",
|
|
5145
5181
|
value: (function () {
|
|
5146
5182
|
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(product, booking, options) {
|
|
5147
|
-
var
|
|
5148
|
-
var tempOrder, salesNoteDrafts, mutationSnapshot, attachSalesNoteDrafts, rollbackProductAndNotesMutation, insertAfterProductUid, anchorIndex, insertAtIndex, _ref71, _productRecord$num, productRecord, splitCount, i, splitLine, committedProduct, _committedProduct, _committedProduct2;
|
|
5183
|
+
var _this34 = this;
|
|
5184
|
+
var tempOrder, beforeCommit, salesNoteDrafts, mutationSnapshot, attachSalesNoteDrafts, rollbackProductAndNotesMutation, insertAfterProductUid, anchorIndex, insertAtIndex, _ref71, _productRecord$num, productRecord, splitCount, i, splitLine, committedProduct, _committedProduct, _committedProduct2;
|
|
5149
5185
|
return _regeneratorRuntime().wrap(function _callee23$(_context25) {
|
|
5150
5186
|
while (1) switch (_context25.prev = _context25.next) {
|
|
5151
5187
|
case 0:
|
|
5152
5188
|
tempOrder = this.ensureTempOrder();
|
|
5189
|
+
beforeCommit = this.createCartIntentCommitGuard('add_product', tempOrder);
|
|
5153
5190
|
salesNoteDrafts = ((options === null || options === void 0 ? void 0 : options.salesNotes) || []).map(function (draft) {
|
|
5154
5191
|
return {
|
|
5155
5192
|
note_type: String(draft.note_type || '').trim(),
|
|
@@ -5173,7 +5210,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5173
5210
|
throw new Error('[Order Notes] 商品行缺少 unique_identification_number');
|
|
5174
5211
|
}
|
|
5175
5212
|
salesNoteDrafts.forEach(function (draft) {
|
|
5176
|
-
|
|
5213
|
+
_this34.setSalesNoteOnTempOrder(tempOrder, {
|
|
5177
5214
|
note_type: draft.note_type,
|
|
5178
5215
|
target: {
|
|
5179
5216
|
target_type: 'order_detail',
|
|
@@ -5197,21 +5234,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5197
5234
|
return uid !== undefined && uid !== null && String(uid) === String(insertAfterProductUid);
|
|
5198
5235
|
}) : -1;
|
|
5199
5236
|
insertAtIndex = anchorIndex >= 0 ? anchorIndex + 1 : undefined;
|
|
5200
|
-
_context25.prev =
|
|
5237
|
+
_context25.prev = 9;
|
|
5201
5238
|
if (!booking) {
|
|
5202
|
-
_context25.next =
|
|
5239
|
+
_context25.next = 34;
|
|
5203
5240
|
break;
|
|
5204
5241
|
}
|
|
5205
5242
|
productRecord = product;
|
|
5206
5243
|
splitCount = getSafeProductNum((_ref71 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref71 !== void 0 ? _ref71 : 1);
|
|
5207
5244
|
if (!(splitCount > 1)) {
|
|
5208
|
-
_context25.next =
|
|
5245
|
+
_context25.next = 28;
|
|
5209
5246
|
break;
|
|
5210
5247
|
}
|
|
5211
5248
|
i = 0;
|
|
5212
|
-
case
|
|
5249
|
+
case 15:
|
|
5213
5250
|
if (!(i < splitCount)) {
|
|
5214
|
-
_context25.next =
|
|
5251
|
+
_context25.next = 26;
|
|
5215
5252
|
break;
|
|
5216
5253
|
}
|
|
5217
5254
|
splitLine = this.createSplitBookingLine(productRecord, booking, i, splitCount);
|
|
@@ -5229,65 +5266,68 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5229
5266
|
delete splitLine.booking.metadata.unique_identification_number;
|
|
5230
5267
|
}
|
|
5231
5268
|
}
|
|
5232
|
-
_context25.next =
|
|
5269
|
+
_context25.next = 20;
|
|
5233
5270
|
return this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking, {
|
|
5234
5271
|
insertAtIndex: insertAtIndex,
|
|
5235
|
-
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge
|
|
5272
|
+
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge,
|
|
5273
|
+
beforeCommit: beforeCommit
|
|
5236
5274
|
});
|
|
5237
|
-
case
|
|
5275
|
+
case 20:
|
|
5238
5276
|
committedProduct = _context25.sent;
|
|
5239
5277
|
attachSalesNoteDrafts(committedProduct);
|
|
5240
5278
|
if (insertAtIndex !== undefined) insertAtIndex += 1;
|
|
5241
|
-
case
|
|
5279
|
+
case 23:
|
|
5242
5280
|
i += 1;
|
|
5243
|
-
_context25.next =
|
|
5281
|
+
_context25.next = 15;
|
|
5244
5282
|
break;
|
|
5245
|
-
case
|
|
5246
|
-
_context25.next =
|
|
5283
|
+
case 26:
|
|
5284
|
+
_context25.next = 32;
|
|
5247
5285
|
break;
|
|
5248
|
-
case
|
|
5249
|
-
_context25.next =
|
|
5286
|
+
case 28:
|
|
5287
|
+
_context25.next = 30;
|
|
5250
5288
|
return this.appendProductLineToTempOrder(tempOrder, product, cloneDeep(booking), {
|
|
5251
5289
|
insertAtIndex: insertAtIndex,
|
|
5252
|
-
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge
|
|
5290
|
+
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge,
|
|
5291
|
+
beforeCommit: beforeCommit
|
|
5253
5292
|
});
|
|
5254
|
-
case
|
|
5293
|
+
case 30:
|
|
5255
5294
|
_committedProduct = _context25.sent;
|
|
5256
5295
|
attachSalesNoteDrafts(_committedProduct);
|
|
5257
|
-
case
|
|
5258
|
-
_context25.next =
|
|
5296
|
+
case 32:
|
|
5297
|
+
_context25.next = 38;
|
|
5259
5298
|
break;
|
|
5260
|
-
case
|
|
5261
|
-
_context25.next =
|
|
5299
|
+
case 34:
|
|
5300
|
+
_context25.next = 36;
|
|
5262
5301
|
return this.appendProductLineToTempOrder(tempOrder, product, undefined, {
|
|
5263
5302
|
insertAtIndex: insertAtIndex,
|
|
5264
|
-
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge
|
|
5303
|
+
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge,
|
|
5304
|
+
beforeCommit: beforeCommit
|
|
5265
5305
|
});
|
|
5266
|
-
case
|
|
5306
|
+
case 36:
|
|
5267
5307
|
_committedProduct2 = _context25.sent;
|
|
5268
5308
|
attachSalesNoteDrafts(_committedProduct2);
|
|
5269
|
-
case
|
|
5270
|
-
_context25.next =
|
|
5309
|
+
case 38:
|
|
5310
|
+
_context25.next = 44;
|
|
5271
5311
|
break;
|
|
5272
|
-
case
|
|
5273
|
-
_context25.prev =
|
|
5274
|
-
_context25.t0 = _context25["catch"](
|
|
5312
|
+
case 40:
|
|
5313
|
+
_context25.prev = 40;
|
|
5314
|
+
_context25.t0 = _context25["catch"](9);
|
|
5275
5315
|
rollbackProductAndNotesMutation();
|
|
5276
5316
|
throw _context25.t0;
|
|
5277
|
-
case
|
|
5278
|
-
_context25.next =
|
|
5317
|
+
case 44:
|
|
5318
|
+
_context25.next = 46;
|
|
5279
5319
|
return this.finalizeProductOrderMutation(tempOrder);
|
|
5280
|
-
case
|
|
5320
|
+
case 46:
|
|
5281
5321
|
this.logInfo('addProductToOrder success', {
|
|
5282
5322
|
product_id: product.product_id,
|
|
5283
5323
|
with_booking: !!booking
|
|
5284
5324
|
});
|
|
5285
5325
|
return _context25.abrupt("return", tempOrder.products);
|
|
5286
|
-
case
|
|
5326
|
+
case 48:
|
|
5287
5327
|
case "end":
|
|
5288
5328
|
return _context25.stop();
|
|
5289
5329
|
}
|
|
5290
|
-
}, _callee23, this, [[
|
|
5330
|
+
}, _callee23, this, [[9, 40]]);
|
|
5291
5331
|
}));
|
|
5292
5332
|
function addProductToOrder(_x23, _x24, _x25) {
|
|
5293
5333
|
return _addProductToOrder.apply(this, arguments);
|
|
@@ -5308,7 +5348,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5308
5348
|
key: "addProductsToOrder",
|
|
5309
5349
|
value: (function () {
|
|
5310
5350
|
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(items, options) {
|
|
5311
|
-
var tempOrder, _iterator20, _step20, item, product, booking, _ref72, _productRecord$num2, productRecord, splitCount, i, splitLine, _appendResult, appendResult;
|
|
5351
|
+
var tempOrder, beforeCommit, _iterator20, _step20, item, product, booking, _ref72, _productRecord$num2, productRecord, splitCount, i, splitLine, _appendResult, appendResult;
|
|
5312
5352
|
return _regeneratorRuntime().wrap(function _callee24$(_context26) {
|
|
5313
5353
|
while (1) switch (_context26.prev = _context26.next) {
|
|
5314
5354
|
case 0:
|
|
@@ -5319,87 +5359,92 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5319
5359
|
}
|
|
5320
5360
|
return _context26.abrupt("return", tempOrder.products);
|
|
5321
5361
|
case 3:
|
|
5362
|
+
beforeCommit = this.createCartIntentCommitGuard('add_product', tempOrder);
|
|
5322
5363
|
_iterator20 = _createForOfIteratorHelper(items || []);
|
|
5323
|
-
_context26.prev =
|
|
5364
|
+
_context26.prev = 5;
|
|
5324
5365
|
_iterator20.s();
|
|
5325
|
-
case
|
|
5366
|
+
case 7:
|
|
5326
5367
|
if ((_step20 = _iterator20.n()).done) {
|
|
5327
|
-
_context26.next =
|
|
5368
|
+
_context26.next = 33;
|
|
5328
5369
|
break;
|
|
5329
5370
|
}
|
|
5330
5371
|
item = _step20.value;
|
|
5331
5372
|
product = item.product, booking = item.booking;
|
|
5332
5373
|
if (product) {
|
|
5333
|
-
_context26.next =
|
|
5374
|
+
_context26.next = 12;
|
|
5334
5375
|
break;
|
|
5335
5376
|
}
|
|
5336
|
-
return _context26.abrupt("continue",
|
|
5337
|
-
case
|
|
5377
|
+
return _context26.abrupt("continue", 31);
|
|
5378
|
+
case 12:
|
|
5338
5379
|
if (!booking) {
|
|
5339
|
-
_context26.next =
|
|
5380
|
+
_context26.next = 27;
|
|
5340
5381
|
break;
|
|
5341
5382
|
}
|
|
5342
5383
|
productRecord = product;
|
|
5343
5384
|
splitCount = getSafeProductNum((_ref72 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref72 !== void 0 ? _ref72 : 1);
|
|
5344
5385
|
if (!(splitCount > 1)) {
|
|
5345
|
-
_context26.next =
|
|
5386
|
+
_context26.next = 27;
|
|
5346
5387
|
break;
|
|
5347
5388
|
}
|
|
5348
5389
|
i = 0;
|
|
5349
|
-
case
|
|
5390
|
+
case 17:
|
|
5350
5391
|
if (!(i < splitCount)) {
|
|
5351
|
-
_context26.next =
|
|
5392
|
+
_context26.next = 26;
|
|
5352
5393
|
break;
|
|
5353
5394
|
}
|
|
5354
5395
|
splitLine = this.createSplitBookingLine(productRecord, booking, i, splitCount);
|
|
5355
|
-
_appendResult = this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking
|
|
5396
|
+
_appendResult = this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking, {
|
|
5397
|
+
beforeCommit: beforeCommit
|
|
5398
|
+
});
|
|
5356
5399
|
if (!_appendResult) {
|
|
5357
|
-
_context26.next =
|
|
5400
|
+
_context26.next = 23;
|
|
5358
5401
|
break;
|
|
5359
5402
|
}
|
|
5360
|
-
_context26.next =
|
|
5403
|
+
_context26.next = 23;
|
|
5361
5404
|
return _appendResult;
|
|
5362
|
-
case
|
|
5405
|
+
case 23:
|
|
5363
5406
|
i += 1;
|
|
5364
|
-
_context26.next =
|
|
5407
|
+
_context26.next = 17;
|
|
5365
5408
|
break;
|
|
5366
|
-
case 25:
|
|
5367
|
-
return _context26.abrupt("continue", 30);
|
|
5368
5409
|
case 26:
|
|
5369
|
-
|
|
5410
|
+
return _context26.abrupt("continue", 31);
|
|
5411
|
+
case 27:
|
|
5412
|
+
appendResult = this.appendProductLineToTempOrder(tempOrder, product, booking, {
|
|
5413
|
+
beforeCommit: beforeCommit
|
|
5414
|
+
});
|
|
5370
5415
|
if (!appendResult) {
|
|
5371
|
-
_context26.next =
|
|
5416
|
+
_context26.next = 31;
|
|
5372
5417
|
break;
|
|
5373
5418
|
}
|
|
5374
|
-
_context26.next =
|
|
5419
|
+
_context26.next = 31;
|
|
5375
5420
|
return appendResult;
|
|
5376
|
-
case
|
|
5377
|
-
_context26.next =
|
|
5421
|
+
case 31:
|
|
5422
|
+
_context26.next = 7;
|
|
5378
5423
|
break;
|
|
5379
|
-
case
|
|
5380
|
-
_context26.next =
|
|
5424
|
+
case 33:
|
|
5425
|
+
_context26.next = 38;
|
|
5381
5426
|
break;
|
|
5382
|
-
case
|
|
5383
|
-
_context26.prev =
|
|
5384
|
-
_context26.t0 = _context26["catch"](
|
|
5427
|
+
case 35:
|
|
5428
|
+
_context26.prev = 35;
|
|
5429
|
+
_context26.t0 = _context26["catch"](5);
|
|
5385
5430
|
_iterator20.e(_context26.t0);
|
|
5386
|
-
case
|
|
5387
|
-
_context26.prev =
|
|
5431
|
+
case 38:
|
|
5432
|
+
_context26.prev = 38;
|
|
5388
5433
|
_iterator20.f();
|
|
5389
|
-
return _context26.finish(
|
|
5390
|
-
case
|
|
5391
|
-
_context26.next =
|
|
5434
|
+
return _context26.finish(38);
|
|
5435
|
+
case 41:
|
|
5436
|
+
_context26.next = 43;
|
|
5392
5437
|
return this.finalizeProductOrderMutation(tempOrder, options);
|
|
5393
|
-
case
|
|
5438
|
+
case 43:
|
|
5394
5439
|
this.logInfo('addProductsToOrder success', {
|
|
5395
5440
|
itemsCount: items.length
|
|
5396
5441
|
});
|
|
5397
5442
|
return _context26.abrupt("return", tempOrder.products);
|
|
5398
|
-
case
|
|
5443
|
+
case 45:
|
|
5399
5444
|
case "end":
|
|
5400
5445
|
return _context26.stop();
|
|
5401
5446
|
}
|
|
5402
|
-
}, _callee24, this, [[
|
|
5447
|
+
}, _callee24, this, [[5, 35, 38, 41]]);
|
|
5403
5448
|
}));
|
|
5404
5449
|
function addProductsToOrder(_x26, _x27) {
|
|
5405
5450
|
return _addProductsToOrder.apply(this, arguments);
|
|
@@ -5453,7 +5498,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5453
5498
|
}, {
|
|
5454
5499
|
key: "hasSameEntitlementMergePriceConfig",
|
|
5455
5500
|
value: function hasSameEntitlementMergePriceConfig(incoming, existing) {
|
|
5456
|
-
var
|
|
5501
|
+
var _this35 = this;
|
|
5457
5502
|
var buildPriceConfig = function buildPriceConfig(product) {
|
|
5458
5503
|
var metadata = product.metadata || {};
|
|
5459
5504
|
var bundle = (product.product_bundle || []).map(function (item) {
|
|
@@ -5469,10 +5514,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5469
5514
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
5470
5515
|
});
|
|
5471
5516
|
return JSON.stringify({
|
|
5472
|
-
original_price:
|
|
5473
|
-
source_product_price:
|
|
5474
|
-
main_product_original_price:
|
|
5475
|
-
price_override:
|
|
5517
|
+
original_price: _this35.normalizeFingerprintMoney(product.original_price),
|
|
5518
|
+
source_product_price: _this35.normalizeFingerprintMoney(metadata.source_product_price),
|
|
5519
|
+
main_product_original_price: _this35.normalizeFingerprintMoney(metadata.main_product_original_price),
|
|
5520
|
+
price_override: _this35.normalizeFingerprintMoney(metadata.price_override),
|
|
5476
5521
|
is_manual_discount: Boolean(metadata.is_manual_discount),
|
|
5477
5522
|
bundle: bundle
|
|
5478
5523
|
});
|
|
@@ -5489,17 +5534,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5489
5534
|
}, {
|
|
5490
5535
|
key: "preservePersistedBundlePriceFields",
|
|
5491
5536
|
value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
|
|
5492
|
-
var
|
|
5537
|
+
var _this36 = this;
|
|
5493
5538
|
if (!Array.isArray(nextBundles)) return nextBundles;
|
|
5494
5539
|
if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
|
|
5495
5540
|
var previousByIdentity = new Map();
|
|
5496
5541
|
previousBundles.forEach(function (bundle) {
|
|
5497
|
-
var identity =
|
|
5542
|
+
var identity = _this36.getBundleRuntimeIdentity(bundle);
|
|
5498
5543
|
if (identity) previousByIdentity.set(identity, bundle);
|
|
5499
5544
|
});
|
|
5500
5545
|
return nextBundles.map(function (bundle, index) {
|
|
5501
5546
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
5502
|
-
var previous = previousByIdentity.get(
|
|
5547
|
+
var previous = previousByIdentity.get(_this36.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
|
|
5503
5548
|
if (!previous || _typeof(previous) !== 'object') return bundle;
|
|
5504
5549
|
return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
|
|
5505
5550
|
cover: previous.cover
|
|
@@ -5513,6 +5558,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5513
5558
|
});
|
|
5514
5559
|
});
|
|
5515
5560
|
}
|
|
5561
|
+
}, {
|
|
5562
|
+
key: "isRestrictedCartProductUpdate",
|
|
5563
|
+
value: function isRestrictedCartProductUpdate(tempOrder, params) {
|
|
5564
|
+
var _this$orderHooks4, _params$updates;
|
|
5565
|
+
if (!((_this$orderHooks4 = this.orderHooks) !== null && _this$orderHooks4 !== void 0 && _this$orderHooks4.beforeCartIntentCommit)) return false;
|
|
5566
|
+
if (params.booking || Object.keys(params.updates || {}).some(function (key) {
|
|
5567
|
+
return key !== 'num';
|
|
5568
|
+
})) {
|
|
5569
|
+
return true;
|
|
5570
|
+
}
|
|
5571
|
+
if (((_params$updates = params.updates) === null || _params$updates === void 0 ? void 0 : _params$updates.num) === undefined) return false;
|
|
5572
|
+
var uid = params.unique_identification_number;
|
|
5573
|
+
var product = uid !== undefined ? tempOrder.products.find(function (item) {
|
|
5574
|
+
var _item$metadata4;
|
|
5575
|
+
return String(((_item$metadata4 = item.metadata) === null || _item$metadata4 === void 0 ? void 0 : _item$metadata4.unique_identification_number) || item.unique_identification_number || '') === String(uid);
|
|
5576
|
+
}) : tempOrder.products[getProductIdentityIndex(tempOrder.products, params)];
|
|
5577
|
+
return !product || getSafeProductNum(params.updates.num) > product.num;
|
|
5578
|
+
}
|
|
5516
5579
|
}, {
|
|
5517
5580
|
key: "applyOrderProductUpdateToTempOrder",
|
|
5518
5581
|
value: function applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids) {
|
|
@@ -5544,8 +5607,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5544
5607
|
if (unique_identification_number !== undefined) {
|
|
5545
5608
|
var targetUid = String(unique_identification_number);
|
|
5546
5609
|
productIndex = tempOrder.products.findIndex(function (item) {
|
|
5547
|
-
var _item$
|
|
5548
|
-
return String(((_item$
|
|
5610
|
+
var _item$metadata5;
|
|
5611
|
+
return String(((_item$metadata5 = item.metadata) === null || _item$metadata5 === void 0 ? void 0 : _item$metadata5.unique_identification_number) || item.unique_identification_number || '') === targetUid;
|
|
5549
5612
|
});
|
|
5550
5613
|
}
|
|
5551
5614
|
if (productIndex === -1) {
|
|
@@ -5758,29 +5821,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5758
5821
|
while (1) switch (_context27.prev = _context27.next) {
|
|
5759
5822
|
case 0:
|
|
5760
5823
|
tempOrder = this.ensureTempOrder();
|
|
5824
|
+
if (this.isRestrictedCartProductUpdate(tempOrder, params)) {
|
|
5825
|
+
this.createCartIntentCommitGuard('update_product', tempOrder)();
|
|
5826
|
+
}
|
|
5761
5827
|
reapplyWeighedDiscountProductUids = [];
|
|
5762
5828
|
updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
|
|
5763
|
-
_context27.next =
|
|
5829
|
+
_context27.next = 6;
|
|
5764
5830
|
return this.evaluatePromotion();
|
|
5765
|
-
case
|
|
5831
|
+
case 6:
|
|
5766
5832
|
promotionPayload = _context27.sent;
|
|
5767
5833
|
this.applyDiscount({
|
|
5768
5834
|
reapplyWeighedDiscountProductUids: reapplyWeighedDiscountProductUids,
|
|
5769
5835
|
reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
|
|
5770
5836
|
});
|
|
5771
5837
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
5772
|
-
_context27.next =
|
|
5838
|
+
_context27.next = 11;
|
|
5773
5839
|
return this.recalculateSummary({
|
|
5774
5840
|
createIfMissing: true
|
|
5775
5841
|
});
|
|
5776
|
-
case
|
|
5842
|
+
case 11:
|
|
5777
5843
|
this.persistTempOrder();
|
|
5778
5844
|
this.emitPromotionApplied(promotionPayload);
|
|
5779
5845
|
this.logInfo('updateOrderProduct success', {
|
|
5780
5846
|
params: params
|
|
5781
5847
|
});
|
|
5782
5848
|
return _context27.abrupt("return", tempOrder.products);
|
|
5783
|
-
case
|
|
5849
|
+
case 15:
|
|
5784
5850
|
case "end":
|
|
5785
5851
|
return _context27.stop();
|
|
5786
5852
|
}
|
|
@@ -5795,7 +5861,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5795
5861
|
key: "updateOrderProducts",
|
|
5796
5862
|
value: function () {
|
|
5797
5863
|
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(paramsList) {
|
|
5798
|
-
var
|
|
5864
|
+
var _this37 = this;
|
|
5799
5865
|
var tempOrder, reapplyWeighedDiscountProductUids, reapplyBookingDiscountProductUids;
|
|
5800
5866
|
return _regeneratorRuntime().wrap(function _callee26$(_context28) {
|
|
5801
5867
|
while (1) switch (_context28.prev = _context28.next) {
|
|
@@ -5807,26 +5873,31 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5807
5873
|
}
|
|
5808
5874
|
return _context28.abrupt("return", tempOrder.products);
|
|
5809
5875
|
case 3:
|
|
5876
|
+
if (paramsList.some(function (params) {
|
|
5877
|
+
return _this37.isRestrictedCartProductUpdate(tempOrder, params);
|
|
5878
|
+
})) {
|
|
5879
|
+
this.createCartIntentCommitGuard('update_product', tempOrder)();
|
|
5880
|
+
}
|
|
5810
5881
|
reapplyWeighedDiscountProductUids = [];
|
|
5811
5882
|
reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
|
|
5812
|
-
var updatedProductUid =
|
|
5883
|
+
var updatedProductUid = _this37.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
|
|
5813
5884
|
// 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
|
|
5814
5885
|
if (params.allow_booking_discount_reapply && updatedProductUid) {
|
|
5815
5886
|
acc.push(String(updatedProductUid));
|
|
5816
5887
|
}
|
|
5817
5888
|
return acc;
|
|
5818
5889
|
}, []);
|
|
5819
|
-
_context28.next =
|
|
5890
|
+
_context28.next = 8;
|
|
5820
5891
|
return this.finalizeAfterProductsMutation(tempOrder, {
|
|
5821
5892
|
reapplyWeighedDiscountProductUids: reapplyWeighedDiscountProductUids,
|
|
5822
5893
|
reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
|
|
5823
5894
|
});
|
|
5824
|
-
case
|
|
5895
|
+
case 8:
|
|
5825
5896
|
this.logInfo('updateOrderProduct success', {
|
|
5826
5897
|
paramsList: paramsList
|
|
5827
5898
|
});
|
|
5828
5899
|
return _context28.abrupt("return", tempOrder.products);
|
|
5829
|
-
case
|
|
5900
|
+
case 10:
|
|
5830
5901
|
case "end":
|
|
5831
5902
|
return _context28.stop();
|
|
5832
5903
|
}
|
|
@@ -5866,8 +5937,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5866
5937
|
if (unique_identification_number !== undefined) {
|
|
5867
5938
|
targetUid = String(unique_identification_number);
|
|
5868
5939
|
productIndex = tempOrder.products.findIndex(function (item) {
|
|
5869
|
-
var _item$
|
|
5870
|
-
return String(((_item$
|
|
5940
|
+
var _item$metadata6;
|
|
5941
|
+
return String(((_item$metadata6 = item.metadata) === null || _item$metadata6 === void 0 ? void 0 : _item$metadata6.unique_identification_number) || item.unique_identification_number || '') === targetUid;
|
|
5871
5942
|
});
|
|
5872
5943
|
}
|
|
5873
5944
|
if (productIndex === -1) {
|
|
@@ -5915,39 +5986,42 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5915
5986
|
}
|
|
5916
5987
|
throw new VirtualCurrencyBalanceError(balance.toFixed(2), requiredAmount.toFixed(2));
|
|
5917
5988
|
case 27:
|
|
5989
|
+
if (normalizedProduct.num > targetProduct.num) {
|
|
5990
|
+
this.createCartIntentCommitGuard('increase_quantity', tempOrder)();
|
|
5991
|
+
}
|
|
5918
5992
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
5919
5993
|
this.prepareVirtualSettlementTempOrder(tempOrder);
|
|
5920
5994
|
isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder);
|
|
5921
5995
|
if (isVirtualSettlement) {
|
|
5922
|
-
_context29.next =
|
|
5996
|
+
_context29.next = 37;
|
|
5923
5997
|
break;
|
|
5924
5998
|
}
|
|
5925
|
-
_context29.next =
|
|
5999
|
+
_context29.next = 34;
|
|
5926
6000
|
return this.evaluatePromotion();
|
|
5927
|
-
case
|
|
6001
|
+
case 34:
|
|
5928
6002
|
_context29.t0 = _context29.sent;
|
|
5929
|
-
_context29.next =
|
|
6003
|
+
_context29.next = 38;
|
|
5930
6004
|
break;
|
|
5931
|
-
case 36:
|
|
5932
|
-
_context29.t0 = null;
|
|
5933
6005
|
case 37:
|
|
6006
|
+
_context29.t0 = null;
|
|
6007
|
+
case 38:
|
|
5934
6008
|
promotionPayload = _context29.t0;
|
|
5935
6009
|
if (!isVirtualSettlement) {
|
|
5936
6010
|
this.applyDiscount();
|
|
5937
6011
|
}
|
|
5938
6012
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
5939
|
-
_context29.next =
|
|
6013
|
+
_context29.next = 43;
|
|
5940
6014
|
return this.recalculateSummary({
|
|
5941
6015
|
createIfMissing: true
|
|
5942
6016
|
});
|
|
5943
|
-
case
|
|
6017
|
+
case 43:
|
|
5944
6018
|
this.persistTempOrder();
|
|
5945
6019
|
this.emitPromotionApplied(promotionPayload);
|
|
5946
6020
|
this.logInfo('updateOrderProductQuantity success', {
|
|
5947
6021
|
params: params
|
|
5948
6022
|
});
|
|
5949
6023
|
return _context29.abrupt("return", tempOrder.products);
|
|
5950
|
-
case
|
|
6024
|
+
case 47:
|
|
5951
6025
|
case "end":
|
|
5952
6026
|
return _context29.stop();
|
|
5953
6027
|
}
|
|
@@ -6038,7 +6112,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6038
6112
|
key: "removeProductsFromOrder",
|
|
6039
6113
|
value: (function () {
|
|
6040
6114
|
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(identities, options) {
|
|
6041
|
-
var
|
|
6115
|
+
var _this38 = this;
|
|
6042
6116
|
var tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
|
|
6043
6117
|
return _regeneratorRuntime().wrap(function _callee29$(_context32) {
|
|
6044
6118
|
while (1) switch (_context32.prev = _context32.next) {
|
|
@@ -6057,8 +6131,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6057
6131
|
bookingsBeforeRemove = tempOrder.bookings || [];
|
|
6058
6132
|
preserveDisplayPosition = options === null || options === void 0 ? void 0 : options.preserveDisplayPosition;
|
|
6059
6133
|
anchorIndex = preserveDisplayPosition ? productsBeforeRemove.findIndex(function (item) {
|
|
6060
|
-
var _item$
|
|
6061
|
-
var uid = ((_item$
|
|
6134
|
+
var _item$metadata7;
|
|
6135
|
+
var uid = ((_item$metadata7 = item.metadata) === null || _item$metadata7 === void 0 ? void 0 : _item$metadata7.unique_identification_number) || item.unique_identification_number;
|
|
6062
6136
|
return uid !== undefined && uid !== null && String(uid) === String(preserveDisplayPosition.anchorProductUid);
|
|
6063
6137
|
}) : -1;
|
|
6064
6138
|
productsAfterAnchor = anchorIndex >= 0 ? productsBeforeRemove.slice(anchorIndex + 1) : [];
|
|
@@ -6103,7 +6177,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6103
6177
|
}
|
|
6104
6178
|
if (productUid !== undefined && productUid !== null && productUid !== '') {
|
|
6105
6179
|
bookingsBeforeRemove.forEach(function (booking) {
|
|
6106
|
-
var bookingUid =
|
|
6180
|
+
var bookingUid = _this38.getBookingUniqueIdentificationNumber(booking);
|
|
6107
6181
|
if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
|
|
6108
6182
|
linkedBookingUidsToRemove.add(bookingUid);
|
|
6109
6183
|
}
|
|
@@ -6154,8 +6228,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6154
6228
|
}
|
|
6155
6229
|
if (preserveDisplayPosition && anchorIndex >= 0) {
|
|
6156
6230
|
remainingProductIndex = tempOrder.products.findIndex(function (item) {
|
|
6157
|
-
var _item$
|
|
6158
|
-
var uid = ((_item$
|
|
6231
|
+
var _item$metadata8;
|
|
6232
|
+
var uid = ((_item$metadata8 = item.metadata) === null || _item$metadata8 === void 0 ? void 0 : _item$metadata8.unique_identification_number) || item.unique_identification_number;
|
|
6159
6233
|
return uid !== undefined && uid !== null && String(uid) === String(preserveDisplayPosition.remainingProductUid);
|
|
6160
6234
|
});
|
|
6161
6235
|
if (remainingProductIndex >= 0) {
|
|
@@ -6735,10 +6809,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6735
6809
|
value: function extractSubmitErrorResponse(error) {
|
|
6736
6810
|
var _error$response,
|
|
6737
6811
|
_error$response2,
|
|
6738
|
-
|
|
6812
|
+
_this39 = this;
|
|
6739
6813
|
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];
|
|
6740
6814
|
return candidates.find(function (candidate) {
|
|
6741
|
-
return
|
|
6815
|
+
return _this39.isSubmitErrorResponse(candidate);
|
|
6742
6816
|
}) || null;
|
|
6743
6817
|
}
|
|
6744
6818
|
}, {
|
|
@@ -6766,7 +6840,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6766
6840
|
key: "syncPaymentsToOrder",
|
|
6767
6841
|
value: function () {
|
|
6768
6842
|
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
|
|
6769
|
-
var
|
|
6843
|
+
var _this40 = this,
|
|
6770
6844
|
_params$confirmPendin;
|
|
6771
6845
|
var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, enhancePayload, submitParams, submitResult;
|
|
6772
6846
|
return _regeneratorRuntime().wrap(function _callee39$(_context42) {
|
|
@@ -6791,7 +6865,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6791
6865
|
case 9:
|
|
6792
6866
|
devicePrefix = _context42.t0;
|
|
6793
6867
|
mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
|
|
6794
|
-
return
|
|
6868
|
+
return _this40.normalizePaymentSource(payment, {
|
|
6795
6869
|
defaultPaid: false,
|
|
6796
6870
|
devicePrefix: devicePrefix
|
|
6797
6871
|
});
|
|
@@ -6870,7 +6944,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6870
6944
|
}, {
|
|
6871
6945
|
key: "createOrder",
|
|
6872
6946
|
value: function createOrder(params) {
|
|
6873
|
-
var
|
|
6947
|
+
var _this41 = this;
|
|
6874
6948
|
var order = _objectSpread({
|
|
6875
6949
|
type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
|
|
6876
6950
|
// 要从外面拿,virtual
|
|
@@ -6902,7 +6976,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6902
6976
|
|
|
6903
6977
|
// 为预约补齐 holder 信息
|
|
6904
6978
|
if (params !== null && params !== void 0 && (_params$extraData = params.extraData) !== null && _params$extraData !== void 0 && _params$extraData.is_add_holder_info) {
|
|
6905
|
-
ensureCartItemOriginHolder(item,
|
|
6979
|
+
ensureCartItemOriginHolder(item, _this41.window);
|
|
6906
6980
|
}
|
|
6907
6981
|
|
|
6908
6982
|
// 购物车是否为普通商品
|
|
@@ -7603,7 +7677,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7603
7677
|
}, {
|
|
7604
7678
|
key: "normalizeTempOrderForRuntime",
|
|
7605
7679
|
value: function normalizeTempOrderForRuntime(raw, options) {
|
|
7606
|
-
var
|
|
7680
|
+
var _this42 = this,
|
|
7607
7681
|
_raw$_extend;
|
|
7608
7682
|
var runtimeRaw = this.withoutSyntheticDraftOrderIdForRuntime(raw);
|
|
7609
7683
|
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
|
|
@@ -7628,12 +7702,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7628
7702
|
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
7629
7703
|
var rawProducts = Array.isArray(raw.products) ? raw.products : [];
|
|
7630
7704
|
nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
|
|
7631
|
-
return
|
|
7705
|
+
return _this42.normalizeHydratedOrderProduct(p, {
|
|
7632
7706
|
makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
|
|
7633
7707
|
});
|
|
7634
7708
|
}) : [];
|
|
7635
7709
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
7636
|
-
var booking =
|
|
7710
|
+
var booking = _this42.normalizeHydratedBookingHolder(b || {});
|
|
7637
7711
|
return _objectSpread(_objectSpread({}, booking), {}, {
|
|
7638
7712
|
is_all: normalizeBookingIsAll(booking),
|
|
7639
7713
|
sub_type: normalizeBookingSubType(booking)
|
|
@@ -7840,7 +7914,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7840
7914
|
}, {
|
|
7841
7915
|
key: "normalizeHydratedOrderProduct",
|
|
7842
7916
|
value: function normalizeHydratedOrderProduct(product, options) {
|
|
7843
|
-
var
|
|
7917
|
+
var _this43 = this;
|
|
7844
7918
|
var row = _objectSpread({}, product || {});
|
|
7845
7919
|
if (row.num === undefined && row.product_quantity !== undefined) {
|
|
7846
7920
|
row.num = row.product_quantity;
|
|
@@ -7848,7 +7922,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7848
7922
|
var productSku = ensureProductSku(row);
|
|
7849
7923
|
row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
|
|
7850
7924
|
option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
|
|
7851
|
-
return
|
|
7925
|
+
return _this43.normalizeHydratedProductOptionItem(optionItem || {});
|
|
7852
7926
|
}))
|
|
7853
7927
|
});
|
|
7854
7928
|
delete row["product_".concat('option', "_item")];
|