@pisell/pisellos 2.3.129 → 2.3.131
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/index.d.ts +2 -0
- package/dist/index.js +3 -1
- package/dist/modules/BusinessAvailability/index.d.ts +30 -0
- package/dist/modules/BusinessAvailability/index.js +204 -0
- package/dist/modules/FulfillmentTiming/index.d.ts +11 -0
- package/dist/modules/FulfillmentTiming/index.js +407 -0
- package/dist/modules/FulfillmentTiming/types.d.ts +67 -0
- package/dist/modules/FulfillmentTiming/types.js +1 -0
- package/dist/modules/OpenData/types.d.ts +8 -0
- package/dist/modules/Order/index.d.ts +11 -2
- package/dist/modules/Order/index.js +370 -253
- package/dist/modules/Order/pickupTiming.d.ts +46 -0
- package/dist/modules/Order/pickupTiming.js +53 -0
- package/dist/modules/Order/types.d.ts +13 -1
- package/dist/modules/Order/utils.js +16 -6
- package/dist/modules/Payment/index.js +9 -10
- package/dist/modules/Schedule/index.d.ts +8 -0
- package/dist/modules/Schedule/index.js +141 -39
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +1 -0
- package/dist/plugins/request.d.ts +7 -0
- package/dist/server/utils/small-ticket.d.ts +1 -85
- package/dist/server/utils/small-ticket.js +2 -2542
- package/dist/shared/payment/loadPaymentMethods.d.ts +9 -0
- package/dist/shared/payment/loadPaymentMethods.js +66 -0
- package/dist/shared/receipt/loadCustomerInvoiceLayout.d.ts +22 -0
- package/dist/shared/receipt/loadCustomerInvoiceLayout.js +142 -0
- package/dist/shared/receipt/small-ticket.d.ts +85 -0
- package/dist/shared/receipt/small-ticket.js +2576 -0
- package/dist/shared/sales/loadSalesOrderSnapshot.d.ts +9 -0
- package/dist/shared/sales/loadSalesOrderSnapshot.js +21 -0
- package/dist/solution/BaseSales/index.d.ts +28 -15
- package/dist/solution/BaseSales/index.js +1346 -1101
- package/dist/solution/BaseSales/pickupTiming.d.ts +43 -0
- package/dist/solution/BaseSales/pickupTiming.js +589 -0
- package/dist/solution/BaseSales/types.d.ts +11 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +3 -0
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +2 -2
- package/dist/solution/BookingTicket/index.js +41 -13
- package/dist/solution/BookingTicket/utils/cartView.js +3 -1
- package/dist/solution/OrderInvoicePreview/index.d.ts +56 -0
- package/dist/solution/OrderInvoicePreview/index.js +269 -0
- package/dist/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
- package/dist/solution/UnifiedBookingSales/businessAvailability.js +292 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +24 -4
- package/dist/solution/UnifiedBookingSales/index.js +953 -709
- package/dist/solution/UnifiedBookingSales/types.d.ts +2 -0
- package/dist/solution/index.d.ts +1 -0
- package/dist/solution/index.js +2 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +21 -1
- package/lib/model/strategy/adapter/promotion/index.js +46 -1
- package/lib/modules/BusinessAvailability/index.d.ts +30 -0
- package/lib/modules/BusinessAvailability/index.js +146 -0
- package/lib/modules/FulfillmentTiming/index.d.ts +11 -0
- package/lib/modules/FulfillmentTiming/index.js +359 -0
- package/lib/modules/FulfillmentTiming/types.d.ts +67 -0
- package/lib/modules/FulfillmentTiming/types.js +5 -0
- package/lib/modules/OpenData/types.d.ts +8 -0
- package/lib/modules/Order/index.d.ts +11 -2
- package/lib/modules/Order/index.js +101 -14
- package/lib/modules/Order/pickupTiming.d.ts +46 -0
- package/lib/modules/Order/pickupTiming.js +61 -0
- package/lib/modules/Order/types.d.ts +13 -1
- package/lib/modules/Order/utils.js +12 -4
- package/lib/modules/Payment/index.js +3 -4
- package/lib/modules/Schedule/index.d.ts +8 -0
- package/lib/modules/Schedule/index.js +68 -12
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +11 -0
- package/lib/plugins/request.d.ts +7 -0
- package/lib/server/utils/small-ticket.d.ts +1 -85
- package/lib/server/utils/small-ticket.js +9 -2305
- package/lib/shared/payment/loadPaymentMethods.d.ts +9 -0
- package/lib/shared/payment/loadPaymentMethods.js +40 -0
- package/lib/shared/receipt/loadCustomerInvoiceLayout.d.ts +22 -0
- package/lib/shared/receipt/loadCustomerInvoiceLayout.js +86 -0
- package/lib/shared/receipt/small-ticket.d.ts +85 -0
- package/lib/shared/receipt/small-ticket.js +2342 -0
- package/lib/shared/sales/loadSalesOrderSnapshot.d.ts +9 -0
- package/lib/shared/sales/loadSalesOrderSnapshot.js +22 -0
- package/lib/solution/BaseSales/index.d.ts +28 -15
- package/lib/solution/BaseSales/index.js +161 -25
- package/lib/solution/BaseSales/pickupTiming.d.ts +43 -0
- package/lib/solution/BaseSales/pickupTiming.js +269 -0
- package/lib/solution/BaseSales/types.d.ts +11 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +3 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +2 -2
- package/lib/solution/BookingTicket/index.js +37 -4
- package/lib/solution/BookingTicket/utils/cartView.js +3 -1
- package/lib/solution/OrderInvoicePreview/index.d.ts +56 -0
- package/lib/solution/OrderInvoicePreview/index.js +192 -0
- package/lib/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
- package/lib/solution/UnifiedBookingSales/businessAvailability.js +138 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +24 -4
- package/lib/solution/UnifiedBookingSales/index.js +184 -46
- package/lib/solution/UnifiedBookingSales/types.d.ts +2 -0
- package/lib/solution/index.d.ts +1 -0
- package/lib/solution/index.js +11 -0
- package/package.json +1 -1
|
@@ -30,11 +30,13 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
30
30
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
31
31
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
32
32
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
33
|
+
import { loadSalesOrderSnapshot } from "../../shared/sales/loadSalesOrderSnapshot";
|
|
33
34
|
import { BaseModule } from "../BaseModule";
|
|
34
35
|
import { OrderHooks } from "./types";
|
|
35
36
|
import { composeLinePrice, generateDuration, getAllDiscountList, mergeRelationForms, ensureCartItemOriginHolder, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, isTempOrder, normalizeOrderMetaList, normalizeBookingIsAll, normalizeBookingSubType, mapPaymentItemsToOrderPayments, normalizeOrderProductDiscountList, resolveEffectivePerUnitDiscount, ensureProductSku, getProductSkuOptions, normalizeProductSkuOptions, sumOptionUnitPrice, clearTempOrderHolderAssignments, getOrderProductLineUid, indexOrderProductsByUid, calculateOrderProductsDeposit, collectPointCardSnapshotCodeCandidates, mergePointCardSnapshotCodes as _mergePointCardSnapshotCodes, buildVirtualCurrencySnapshotFromList, mergeOrderProductDisplayFields, resolveIsFormSubject, isMarkdownBundle } from "./utils";
|
|
36
37
|
import { isNormalProduct } from "../Product/utils";
|
|
37
38
|
import { getWeighedProductPriceFingerprint, resolveWeighedSourcePrice, withOriginalBundleOptionPrices } from "./utils/weighedProduct";
|
|
39
|
+
import { buildPickupTimingBooking, isFulfillmentTimingBooking } from "./pickupTiming";
|
|
38
40
|
import dayjs from 'dayjs';
|
|
39
41
|
import { getDiscountLifecycleReason } from "../Discount/availability";
|
|
40
42
|
import { stripOsPrivatePayloadFields } from "../../utils/os-private-payload";
|
|
@@ -520,6 +522,36 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
520
522
|
this.otherParams = otherParams;
|
|
521
523
|
}
|
|
522
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
|
+
|
|
523
555
|
/** PC/H5 属于在线店铺;其它或缺失平台统一沿用 POS 行为。 */
|
|
524
556
|
}, {
|
|
525
557
|
key: "isOnlineStorePlatform",
|
|
@@ -611,10 +643,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
611
643
|
}, {
|
|
612
644
|
key: "createDefaultRulesHooks",
|
|
613
645
|
value: function createDefaultRulesHooks() {
|
|
614
|
-
var
|
|
646
|
+
var _this3 = this;
|
|
615
647
|
return createDefaultOrderRulesHooks(function () {
|
|
616
|
-
var
|
|
617
|
-
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) || [];
|
|
618
650
|
});
|
|
619
651
|
}
|
|
620
652
|
|
|
@@ -637,7 +669,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
637
669
|
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
638
670
|
var _this$store$tempOrder,
|
|
639
671
|
_this$store$discount,
|
|
640
|
-
|
|
672
|
+
_this4 = this,
|
|
641
673
|
_this$store$tempOrder2;
|
|
642
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;
|
|
643
675
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
@@ -665,8 +697,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
665
697
|
case 5:
|
|
666
698
|
prepareConfigResult = _context3.sent;
|
|
667
699
|
isCurrentRequest = function isCurrentRequest() {
|
|
668
|
-
var
|
|
669
|
-
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);
|
|
670
702
|
};
|
|
671
703
|
if (isCurrentRequest()) {
|
|
672
704
|
_context3.next = 9;
|
|
@@ -898,12 +930,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
898
930
|
value: function () {
|
|
899
931
|
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(code, customerId) {
|
|
900
932
|
var _this$store$discount11, _tempOrder$holder, _this$store$summary;
|
|
901
|
-
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;
|
|
902
934
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
903
935
|
while (1) switch (_context6.prev = _context6.next) {
|
|
904
936
|
case 0:
|
|
937
|
+
beforeCommit = this.createCartIntentCommitGuard('scan_promotion');
|
|
905
938
|
if (!this.isActiveVirtualSettlementOrder(this.store.tempOrder)) {
|
|
906
|
-
_context6.next =
|
|
939
|
+
_context6.next = 3;
|
|
907
940
|
break;
|
|
908
941
|
}
|
|
909
942
|
return _context6.abrupt("return", {
|
|
@@ -914,27 +947,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
914
947
|
scannedDiscountList: [],
|
|
915
948
|
unavailableReason: UnavailableReason.ProductNotApplicable
|
|
916
949
|
});
|
|
917
|
-
case
|
|
918
|
-
_context6.next =
|
|
950
|
+
case 3:
|
|
951
|
+
_context6.next = 5;
|
|
919
952
|
return (_this$store$discount11 = this.store.discount) === null || _this$store$discount11 === void 0 ? void 0 : _this$store$discount11.batchSearch(code, {
|
|
920
953
|
customerId: customerId
|
|
921
954
|
});
|
|
922
|
-
case
|
|
955
|
+
case 5:
|
|
923
956
|
_context6.t0 = _context6.sent;
|
|
924
957
|
if (_context6.t0) {
|
|
925
|
-
_context6.next =
|
|
958
|
+
_context6.next = 8;
|
|
926
959
|
break;
|
|
927
960
|
}
|
|
928
961
|
_context6.t0 = {
|
|
929
962
|
discountList: [],
|
|
930
963
|
unavailableReasonKey: null
|
|
931
964
|
};
|
|
932
|
-
case
|
|
965
|
+
case 8:
|
|
933
966
|
resultDiscountWithReason = _context6.t0;
|
|
934
967
|
resultDiscountList = resultDiscountWithReason.discountList, unavailableReasonKey = resultDiscountWithReason.unavailableReasonKey;
|
|
935
968
|
rulesModule = this.store.rules;
|
|
936
969
|
if (rulesModule) {
|
|
937
|
-
_context6.next =
|
|
970
|
+
_context6.next = 13;
|
|
938
971
|
break;
|
|
939
972
|
}
|
|
940
973
|
return _context6.abrupt("return", {
|
|
@@ -945,9 +978,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
945
978
|
scannedDiscountList: resultDiscountList,
|
|
946
979
|
unavailableReason: UnavailableReason.Unknown
|
|
947
980
|
});
|
|
948
|
-
case
|
|
981
|
+
case 13:
|
|
949
982
|
if (resultDiscountList.length) {
|
|
950
|
-
_context6.next =
|
|
983
|
+
_context6.next = 15;
|
|
951
984
|
break;
|
|
952
985
|
}
|
|
953
986
|
return _context6.abrupt("return", {
|
|
@@ -958,7 +991,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
958
991
|
scannedDiscountList: resultDiscountList,
|
|
959
992
|
unavailableReasonKey: unavailableReasonKey
|
|
960
993
|
});
|
|
961
|
-
case
|
|
994
|
+
case 15:
|
|
962
995
|
withScanList = resultDiscountList.map(function (item) {
|
|
963
996
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
964
997
|
isScan: true
|
|
@@ -972,12 +1005,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
972
1005
|
return m.id === n.id;
|
|
973
1006
|
});
|
|
974
1007
|
}))) {
|
|
975
|
-
_context6.next =
|
|
1008
|
+
_context6.next = 22;
|
|
976
1009
|
break;
|
|
977
1010
|
}
|
|
978
|
-
|
|
1011
|
+
beforeCommit();
|
|
1012
|
+
_context6.next = 21;
|
|
979
1013
|
return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
980
|
-
case
|
|
1014
|
+
case 21:
|
|
981
1015
|
return _context6.abrupt("return", {
|
|
982
1016
|
type: 'clientCalc',
|
|
983
1017
|
isAvailable: true,
|
|
@@ -985,7 +1019,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
985
1019
|
discountList: this.getDiscountList(),
|
|
986
1020
|
scannedDiscountList: resultDiscountList
|
|
987
1021
|
});
|
|
988
|
-
case
|
|
1022
|
+
case 22:
|
|
989
1023
|
tempOrder = this.store.tempOrder;
|
|
990
1024
|
holders = (tempOrder === null || tempOrder === void 0 || (_tempOrder$holder = tempOrder.holder) === null || _tempOrder$holder === void 0 ? void 0 : _tempOrder$holder.form_record) || [];
|
|
991
1025
|
_ref16 = rulesModule.isDiscountListAvailable({
|
|
@@ -1011,12 +1045,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1011
1045
|
normalizedNewDiscountList = newDiscountList ? markScannedDiscounts(newDiscountList, withScanList) : undefined;
|
|
1012
1046
|
resolvedDiscountList = normalizedNewDiscountList || this.getDiscountList();
|
|
1013
1047
|
if (!(isAvailable && normalizedNewDiscountList)) {
|
|
1014
|
-
_context6.next =
|
|
1048
|
+
_context6.next = 40;
|
|
1015
1049
|
break;
|
|
1016
1050
|
}
|
|
1017
|
-
|
|
1051
|
+
beforeCommit();
|
|
1052
|
+
_context6.next = 34;
|
|
1018
1053
|
return (_this$store$discount12 = this.store.discount) === null || _this$store$discount12 === void 0 ? void 0 : _this$store$discount12.setDiscountList(normalizedNewDiscountList);
|
|
1019
|
-
case
|
|
1054
|
+
case 34:
|
|
1020
1055
|
// 实际写回商品时沿用扫码试算的优先级,避免旧商品行的选卡覆盖本次扫码。
|
|
1021
1056
|
this.applyDiscount({
|
|
1022
1057
|
preferredEntitlementPassIds: withScanList.filter(function (discount) {
|
|
@@ -1025,17 +1060,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1025
1060
|
return discount.id;
|
|
1026
1061
|
})
|
|
1027
1062
|
});
|
|
1028
|
-
_context6.next =
|
|
1063
|
+
_context6.next = 37;
|
|
1029
1064
|
return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
1030
|
-
case
|
|
1065
|
+
case 37:
|
|
1031
1066
|
resolvedDiscountList = this.getDiscountList();
|
|
1032
|
-
_context6.next =
|
|
1067
|
+
_context6.next = 49;
|
|
1033
1068
|
break;
|
|
1034
|
-
case
|
|
1069
|
+
case 40:
|
|
1035
1070
|
if (!shouldRetainForLater) {
|
|
1036
|
-
_context6.next =
|
|
1071
|
+
_context6.next = 49;
|
|
1037
1072
|
break;
|
|
1038
1073
|
}
|
|
1074
|
+
beforeCommit();
|
|
1039
1075
|
// 只合并本次识别的卡券;不把试算产生的其他选券状态写回订单。
|
|
1040
1076
|
retainedDiscounts = new Map(this.getDiscountList().map(function (discount) {
|
|
1041
1077
|
return [String(discount.id), discount];
|
|
@@ -1050,14 +1086,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1050
1086
|
savedAmount: 0
|
|
1051
1087
|
}));
|
|
1052
1088
|
});
|
|
1053
|
-
_context6.next =
|
|
1089
|
+
_context6.next = 46;
|
|
1054
1090
|
return (_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.setDiscountList(_toConsumableArray(retainedDiscounts.values()));
|
|
1055
|
-
case
|
|
1056
|
-
_context6.next =
|
|
1091
|
+
case 46:
|
|
1092
|
+
_context6.next = 48;
|
|
1057
1093
|
return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
1058
|
-
case
|
|
1094
|
+
case 48:
|
|
1059
1095
|
resolvedDiscountList = this.getDiscountList();
|
|
1060
|
-
case
|
|
1096
|
+
case 49:
|
|
1061
1097
|
return _context6.abrupt("return", {
|
|
1062
1098
|
type: 'clientCalc',
|
|
1063
1099
|
isAvailable: isAvailable || false,
|
|
@@ -1066,7 +1102,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1066
1102
|
scannedDiscountList: evaluatedScannedDiscounts,
|
|
1067
1103
|
unavailableReason: unavailableReason
|
|
1068
1104
|
});
|
|
1069
|
-
case
|
|
1105
|
+
case 50:
|
|
1070
1106
|
case "end":
|
|
1071
1107
|
return _context6.stop();
|
|
1072
1108
|
}
|
|
@@ -1082,7 +1118,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1082
1118
|
value: function applyDiscount(options) {
|
|
1083
1119
|
var _this$store$discount16,
|
|
1084
1120
|
_this$store$summary2,
|
|
1085
|
-
|
|
1121
|
+
_this5 = this;
|
|
1086
1122
|
var tempOrder = this.store.tempOrder;
|
|
1087
1123
|
// 任意 products CRUD 后都应当重算 discount 状态;即使 products 为空,
|
|
1088
1124
|
// 也需要让 Rules.calcDiscount 把 DiscountModule 的 isSelected / isAvailable /
|
|
@@ -1140,7 +1176,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1140
1176
|
(_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 || _this$store$discount17.setDiscountList(result.discountList);
|
|
1141
1177
|
}
|
|
1142
1178
|
this.hasActiveCustomerBoundDiscount = (tempOrder.products || []).some(function (product) {
|
|
1143
|
-
return
|
|
1179
|
+
return _this5.productHasCustomerBoundDiscount(product);
|
|
1144
1180
|
});
|
|
1145
1181
|
}
|
|
1146
1182
|
|
|
@@ -1203,7 +1239,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1203
1239
|
var _evaluatePromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
1204
1240
|
var _this$promotionEvalua,
|
|
1205
1241
|
_this$promotionEvalua2,
|
|
1206
|
-
|
|
1242
|
+
_this6 = this;
|
|
1207
1243
|
var tempOrder, strategyConfigs, result, removeSet, _iterator3, _step3, reduce, _iterator6, _step6, _loop2, _iterator4, _step4, _loop, payload;
|
|
1208
1244
|
return _regeneratorRuntime().wrap(function _callee7$(_context9) {
|
|
1209
1245
|
while (1) switch (_context9.prev = _context9.next) {
|
|
@@ -1362,7 +1398,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1362
1398
|
case 6:
|
|
1363
1399
|
_context7.prev = 6;
|
|
1364
1400
|
_context7.next = 9;
|
|
1365
|
-
return
|
|
1401
|
+
return _this6.giftSelectResolver({
|
|
1366
1402
|
strategyId: addAction.strategyId,
|
|
1367
1403
|
strategyName: addAction.strategyName,
|
|
1368
1404
|
giftCount: addAction.giftCount,
|
|
@@ -1397,7 +1433,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1397
1433
|
_context7.next = 26;
|
|
1398
1434
|
break;
|
|
1399
1435
|
}
|
|
1400
|
-
linked =
|
|
1436
|
+
linked = _this6.createLinkedProductAndBooking({
|
|
1401
1437
|
product: gp,
|
|
1402
1438
|
booking: booking
|
|
1403
1439
|
});
|
|
@@ -1727,12 +1763,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1727
1763
|
}, {
|
|
1728
1764
|
key: "rememberPointCardSnapshotCodeCandidates",
|
|
1729
1765
|
value: function rememberPointCardSnapshotCodeCandidates(value) {
|
|
1730
|
-
var
|
|
1766
|
+
var _this7 = this;
|
|
1731
1767
|
collectPointCardSnapshotCodeCandidates(value).forEach(function (_ref18) {
|
|
1732
1768
|
var id = _ref18.id,
|
|
1733
1769
|
code = _ref18.code;
|
|
1734
|
-
if (!
|
|
1735
|
-
|
|
1770
|
+
if (!_this7.pointCardSnapshotCodeCandidates.has(id)) {
|
|
1771
|
+
_this7.pointCardSnapshotCodeCandidates.set(id, code);
|
|
1736
1772
|
}
|
|
1737
1773
|
});
|
|
1738
1774
|
}
|
|
@@ -1939,23 +1975,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1939
1975
|
}, {
|
|
1940
1976
|
key: "calculatePaymentTotal",
|
|
1941
1977
|
value: function calculatePaymentTotal(payments) {
|
|
1942
|
-
var
|
|
1978
|
+
var _this8 = this;
|
|
1943
1979
|
return mapPaymentItemsToOrderPayments(payments, {
|
|
1944
1980
|
includeVoided: false
|
|
1945
1981
|
}).reduce(function (sum, payment) {
|
|
1946
1982
|
if (!isPaidPaymentRecord(payment)) return sum;
|
|
1947
|
-
return sum.plus(
|
|
1983
|
+
return sum.plus(_this8.calculatePaymentEffectiveAmount(payment));
|
|
1948
1984
|
}, new Decimal(0));
|
|
1949
1985
|
}
|
|
1950
1986
|
}, {
|
|
1951
1987
|
key: "calculateOrderPaidPaymentTotal",
|
|
1952
1988
|
value: function calculateOrderPaidPaymentTotal(payments) {
|
|
1953
|
-
var
|
|
1989
|
+
var _this9 = this;
|
|
1954
1990
|
return mapPaymentItemsToOrderPayments(payments, {
|
|
1955
1991
|
includeVoided: false
|
|
1956
1992
|
}).reduce(function (sum, payment) {
|
|
1957
1993
|
if (!isPaidPaymentRecord(payment)) return sum;
|
|
1958
|
-
return sum.plus(
|
|
1994
|
+
return sum.plus(_this9.calculatePaymentGapAmount(payment));
|
|
1959
1995
|
}, new Decimal(0));
|
|
1960
1996
|
}
|
|
1961
1997
|
}, {
|
|
@@ -2091,13 +2127,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2091
2127
|
}, {
|
|
2092
2128
|
key: "calculateDepositPaidAmount",
|
|
2093
2129
|
value: function calculateDepositPaidAmount(payments) {
|
|
2094
|
-
var
|
|
2130
|
+
var _this10 = this;
|
|
2095
2131
|
return (payments || []).reduce(function (sum, payment) {
|
|
2096
2132
|
var paymentRecord = payment;
|
|
2097
2133
|
if (!isPaidPaymentRecord(paymentRecord)) return sum;
|
|
2098
2134
|
var isDepositPayment = paymentRecord.type === 'deposit' || paymentRecord.order_payment_type === 'deposit';
|
|
2099
2135
|
if (!isDepositPayment) return sum;
|
|
2100
|
-
return sum.plus(
|
|
2136
|
+
return sum.plus(_this10.calculatePaymentGapAmount(paymentRecord));
|
|
2101
2137
|
}, new Decimal(0));
|
|
2102
2138
|
}
|
|
2103
2139
|
}, {
|
|
@@ -2134,17 +2170,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2134
2170
|
}, {
|
|
2135
2171
|
key: "getPaymentNumberDevicePrefixSync",
|
|
2136
2172
|
value: function getPaymentNumberDevicePrefixSync() {
|
|
2137
|
-
var
|
|
2173
|
+
var _this11 = this;
|
|
2138
2174
|
return resolvePaymentNumberDevicePrefixFromDeviceId(function (key) {
|
|
2139
|
-
return
|
|
2175
|
+
return _this11.getPaymentNumberAppData(key);
|
|
2140
2176
|
});
|
|
2141
2177
|
}
|
|
2142
2178
|
}, {
|
|
2143
2179
|
key: "getPaymentNumberDevicePrefixAsync",
|
|
2144
2180
|
value: function getPaymentNumberDevicePrefixAsync() {
|
|
2145
|
-
var
|
|
2181
|
+
var _this12 = this;
|
|
2146
2182
|
return resolvePaymentNumberDevicePrefix(function (key) {
|
|
2147
|
-
return
|
|
2183
|
+
return _this12.getPaymentNumberAppData(key);
|
|
2148
2184
|
});
|
|
2149
2185
|
}
|
|
2150
2186
|
}, {
|
|
@@ -2274,16 +2310,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2274
2310
|
}, {
|
|
2275
2311
|
key: "calculatePaidPaymentSummary",
|
|
2276
2312
|
value: function calculatePaidPaymentSummary(payments) {
|
|
2277
|
-
var
|
|
2313
|
+
var _this13 = this;
|
|
2278
2314
|
return (payments || []).reduce(function (summary, payment) {
|
|
2279
2315
|
var paymentRecord = payment;
|
|
2280
2316
|
if (!isPaidPaymentRecord(paymentRecord)) return summary;
|
|
2281
2317
|
return {
|
|
2282
2318
|
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(
|
|
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))
|
|
2287
2323
|
};
|
|
2288
2324
|
}, {
|
|
2289
2325
|
customerPaidAmount: new Decimal(0),
|
|
@@ -2490,15 +2526,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2490
2526
|
}, {
|
|
2491
2527
|
key: "normalizeFingerprintValue",
|
|
2492
2528
|
value: function normalizeFingerprintValue(value) {
|
|
2493
|
-
var
|
|
2529
|
+
var _this14 = this;
|
|
2494
2530
|
if (Array.isArray(value)) {
|
|
2495
2531
|
return value.map(function (item) {
|
|
2496
|
-
return
|
|
2532
|
+
return _this14.normalizeFingerprintValue(item);
|
|
2497
2533
|
});
|
|
2498
2534
|
}
|
|
2499
2535
|
if (!value || _typeof(value) !== 'object') return value !== null && value !== void 0 ? value : '';
|
|
2500
2536
|
return Object.keys(value).sort().reduce(function (result, key) {
|
|
2501
|
-
result[key] =
|
|
2537
|
+
result[key] = _this14.normalizeFingerprintValue(value[key]);
|
|
2502
2538
|
return result;
|
|
2503
2539
|
}, {});
|
|
2504
2540
|
}
|
|
@@ -2513,7 +2549,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2513
2549
|
_sku$barcode,
|
|
2514
2550
|
_ref26,
|
|
2515
2551
|
_sku$variant_id,
|
|
2516
|
-
|
|
2552
|
+
_this15 = this;
|
|
2517
2553
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
2518
2554
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
2519
2555
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
@@ -2550,7 +2586,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2550
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,
|
|
2551
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,
|
|
2552
2588
|
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:
|
|
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)
|
|
2554
2590
|
};
|
|
2555
2591
|
})
|
|
2556
2592
|
}),
|
|
@@ -2560,8 +2596,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2560
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,
|
|
2561
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,
|
|
2562
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),
|
|
2563
|
-
price:
|
|
2564
|
-
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),
|
|
2565
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 : '',
|
|
2566
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 : ''
|
|
2567
2603
|
};
|
|
@@ -2571,7 +2607,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2571
2607
|
return {
|
|
2572
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 : '',
|
|
2573
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,
|
|
2574
|
-
amount:
|
|
2610
|
+
amount: _this15.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
2575
2611
|
};
|
|
2576
2612
|
}))
|
|
2577
2613
|
};
|
|
@@ -2579,9 +2615,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2579
2615
|
}, {
|
|
2580
2616
|
key: "buildOrderProductsFingerprint",
|
|
2581
2617
|
value: function buildOrderProductsFingerprint(products) {
|
|
2582
|
-
var
|
|
2618
|
+
var _this16 = this;
|
|
2583
2619
|
var items = (products || []).map(function (product) {
|
|
2584
|
-
return
|
|
2620
|
+
return _this16.buildProductFingerprintItem(product);
|
|
2585
2621
|
});
|
|
2586
2622
|
items.sort(function (left, right) {
|
|
2587
2623
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -2603,7 +2639,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2603
2639
|
_sku$barcode2,
|
|
2604
2640
|
_ref36,
|
|
2605
2641
|
_sku$variant_id2,
|
|
2606
|
-
|
|
2642
|
+
_this17 = this;
|
|
2607
2643
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
2608
2644
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
2609
2645
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
@@ -2637,7 +2673,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2637
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,
|
|
2638
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,
|
|
2639
2675
|
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:
|
|
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)
|
|
2641
2677
|
};
|
|
2642
2678
|
})
|
|
2643
2679
|
}),
|
|
@@ -2651,14 +2687,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2651
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),
|
|
2652
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 : '',
|
|
2653
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 : '',
|
|
2654
|
-
option:
|
|
2690
|
+
option: _this17.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
|
|
2655
2691
|
var _ref44, _option$id3, _option$option_group_5, _ref45, _option$option_group_6, _option$num3, _option$add_price3;
|
|
2656
2692
|
return {
|
|
2657
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,
|
|
2658
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,
|
|
2659
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,
|
|
2660
2696
|
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:
|
|
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)
|
|
2662
2698
|
};
|
|
2663
2699
|
}))
|
|
2664
2700
|
};
|
|
@@ -2668,7 +2704,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2668
2704
|
return {
|
|
2669
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 : '',
|
|
2670
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,
|
|
2671
|
-
amount:
|
|
2707
|
+
amount: _this17.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
2672
2708
|
};
|
|
2673
2709
|
}))
|
|
2674
2710
|
};
|
|
@@ -2676,9 +2712,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2676
2712
|
}, {
|
|
2677
2713
|
key: "buildOrderProductsStructuralFingerprint",
|
|
2678
2714
|
value: function buildOrderProductsStructuralFingerprint(products) {
|
|
2679
|
-
var
|
|
2715
|
+
var _this18 = this;
|
|
2680
2716
|
var items = (products || []).map(function (product) {
|
|
2681
|
-
return
|
|
2717
|
+
return _this18.buildProductStructuralFingerprintItem(product);
|
|
2682
2718
|
});
|
|
2683
2719
|
items.sort(function (left, right) {
|
|
2684
2720
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -3130,9 +3166,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3130
3166
|
}, {
|
|
3131
3167
|
key: "sanitizeTempOrderProducts",
|
|
3132
3168
|
value: function sanitizeTempOrderProducts(tempOrder) {
|
|
3133
|
-
var
|
|
3169
|
+
var _this19 = this;
|
|
3134
3170
|
tempOrder.products = (tempOrder.products || []).map(function (product) {
|
|
3135
|
-
return
|
|
3171
|
+
return _this19.sanitizeOrderProductForTempOrder(_this19.normalizeVirtualSettlementProductIfEnabled(product));
|
|
3136
3172
|
});
|
|
3137
3173
|
this.syncTempOrderSettlementState(tempOrder);
|
|
3138
3174
|
ensureUniqueProductLineUids(tempOrder);
|
|
@@ -3252,7 +3288,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3252
3288
|
}, {
|
|
3253
3289
|
key: "syncLinkedBookingHoldersToProducts",
|
|
3254
3290
|
value: function syncLinkedBookingHoldersToProducts(tempOrder) {
|
|
3255
|
-
var
|
|
3291
|
+
var _this20 = this;
|
|
3256
3292
|
var bookings = tempOrder.bookings || [];
|
|
3257
3293
|
var products = tempOrder.products || [];
|
|
3258
3294
|
if (!bookings.length || !products.length) return;
|
|
@@ -3261,6 +3297,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3261
3297
|
bookings.forEach(function (booking) {
|
|
3262
3298
|
var _booking$metadata2, _booking$metadata3;
|
|
3263
3299
|
if (!booking || _typeof(booking) !== 'object') return;
|
|
3300
|
+
if (isFulfillmentTimingBooking(booking)) return;
|
|
3264
3301
|
var productUid = booking.product_uid || ((_booking$metadata2 = booking.metadata) === null || _booking$metadata2 === void 0 ? void 0 : _booking$metadata2.product_uid);
|
|
3265
3302
|
if (productUid !== undefined && productUid !== null && String(productUid) !== '') {
|
|
3266
3303
|
bookingByProductUid.set(String(productUid), booking);
|
|
@@ -3277,7 +3314,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3277
3314
|
var bookingUid = product.booking_uid || ((_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.booking_uid);
|
|
3278
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);
|
|
3279
3316
|
if (linkedBooking) {
|
|
3280
|
-
|
|
3317
|
+
_this20.setProductHolderFromBooking(product, linkedBooking);
|
|
3281
3318
|
}
|
|
3282
3319
|
});
|
|
3283
3320
|
}
|
|
@@ -3325,6 +3362,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3325
3362
|
try {
|
|
3326
3363
|
for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
|
|
3327
3364
|
var booking = _step18.value;
|
|
3365
|
+
if (isFulfillmentTimingBooking(booking)) continue;
|
|
3328
3366
|
var holder = booking !== null && booking !== void 0 && booking.holder && _typeof(booking.holder) === 'object' ? booking.holder : null;
|
|
3329
3367
|
if (!baseHolder && holder) {
|
|
3330
3368
|
baseHolder = holder;
|
|
@@ -3383,7 +3421,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3383
3421
|
}, {
|
|
3384
3422
|
key: "syncTempOrderHolderFromBookings",
|
|
3385
3423
|
value: function syncTempOrderHolderFromBookings(tempOrder) {
|
|
3386
|
-
var bookings = tempOrder.bookings || []
|
|
3424
|
+
var bookings = (tempOrder.bookings || []).filter(function (booking) {
|
|
3425
|
+
return !isFulfillmentTimingBooking(booking);
|
|
3426
|
+
});
|
|
3387
3427
|
var hasHolderSource = bookings.some(function (booking) {
|
|
3388
3428
|
var _booking$metadata4;
|
|
3389
3429
|
return (booking === null || booking === void 0 ? void 0 : booking.holder) !== undefined || (booking === null || booking === void 0 || (_booking$metadata4 = booking.metadata) === null || _booking$metadata4 === void 0 ? void 0 : _booking$metadata4.holder_id) !== undefined;
|
|
@@ -3405,9 +3445,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3405
3445
|
}, {
|
|
3406
3446
|
key: "findBookingIndexByUniqueIdentificationNumber",
|
|
3407
3447
|
value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
|
|
3408
|
-
var
|
|
3448
|
+
var _this21 = this;
|
|
3409
3449
|
return (tempOrder.bookings || []).findIndex(function (booking) {
|
|
3410
|
-
return
|
|
3450
|
+
return _this21.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
|
|
3411
3451
|
});
|
|
3412
3452
|
}
|
|
3413
3453
|
}, {
|
|
@@ -3415,12 +3455,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3415
3455
|
value: function removeLinkedBookingsForProduct(tempOrder, product) {
|
|
3416
3456
|
var _product$metadata5,
|
|
3417
3457
|
_product$metadata6,
|
|
3418
|
-
|
|
3458
|
+
_this22 = this;
|
|
3419
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);
|
|
3420
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);
|
|
3421
3461
|
if (!productUid && !bookingUid) return;
|
|
3422
3462
|
tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
|
|
3423
|
-
|
|
3463
|
+
if (isFulfillmentTimingBooking(booking)) return true;
|
|
3464
|
+
var currentBookingUid = _this22.getBookingUniqueIdentificationNumber(booking);
|
|
3424
3465
|
if (bookingUid && currentBookingUid === String(bookingUid)) return false;
|
|
3425
3466
|
if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
|
|
3426
3467
|
return true;
|
|
@@ -3722,7 +3763,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3722
3763
|
}, {
|
|
3723
3764
|
key: "removeSalesNotesForMissingProductLines",
|
|
3724
3765
|
value: function removeSalesNotesForMissingProductLines(tempOrder) {
|
|
3725
|
-
var
|
|
3766
|
+
var _this23 = this;
|
|
3726
3767
|
var state = this.ensureSalesNotesRuntimeState(tempOrder);
|
|
3727
3768
|
if (!state.loaded || !Array.isArray(tempOrder.notes) || tempOrder.notes.length === 0) {
|
|
3728
3769
|
return;
|
|
@@ -3734,7 +3775,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3734
3775
|
return typeof uid === 'string' && uid.length > 0;
|
|
3735
3776
|
}));
|
|
3736
3777
|
var nextNotes = tempOrder.notes.filter(function (note) {
|
|
3737
|
-
var primary =
|
|
3778
|
+
var primary = _this23.getSalesNotePrimaryRelation(note);
|
|
3738
3779
|
if (!primary || primary.target_type !== 'order_detail') return true;
|
|
3739
3780
|
return remainingProductUids.has(primary.target_uuid);
|
|
3740
3781
|
});
|
|
@@ -3746,7 +3787,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3746
3787
|
key: "setSalesNoteOnTempOrder",
|
|
3747
3788
|
value: function setSalesNoteOnTempOrder(tempOrder, input) {
|
|
3748
3789
|
var _input$target,
|
|
3749
|
-
|
|
3790
|
+
_this24 = this,
|
|
3750
3791
|
_tempOrder$shop_order;
|
|
3751
3792
|
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
3752
3793
|
var note_type = String(input.note_type || '').trim();
|
|
@@ -3770,7 +3811,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3770
3811
|
var notes = tempOrder.notes || [];
|
|
3771
3812
|
// 当前 allergy policy 固定同一商品行只保留一条;业务调用方不参与去重规则。
|
|
3772
3813
|
var existingIndex = policy.uniquePerPrimaryTarget ? notes.findIndex(function (note) {
|
|
3773
|
-
var primary =
|
|
3814
|
+
var primary = _this24.getSalesNotePrimaryRelation(note);
|
|
3774
3815
|
return note.note_type === note_type && (primary === null || primary === void 0 ? void 0 : primary.target_type) === 'order_detail' && primary.target_uuid === target_uuid;
|
|
3775
3816
|
}) : -1;
|
|
3776
3817
|
var existing = existingIndex >= 0 ? notes[existingIndex] : null;
|
|
@@ -4007,10 +4048,47 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4007
4048
|
}, {
|
|
4008
4049
|
key: "updateTempOrderServiceType",
|
|
4009
4050
|
value: function updateTempOrderServiceType(serviceType) {
|
|
4051
|
+
if (serviceType !== 'pick_up') {
|
|
4052
|
+
var tempOrder = this.ensureTempOrder();
|
|
4053
|
+
tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
|
|
4054
|
+
return !isFulfillmentTimingBooking(booking);
|
|
4055
|
+
});
|
|
4056
|
+
}
|
|
4010
4057
|
return this.updateTempOrderShopServiceData({
|
|
4011
4058
|
service_type: serviceType
|
|
4012
4059
|
});
|
|
4013
4060
|
}
|
|
4061
|
+
}, {
|
|
4062
|
+
key: "getPickupTimingBooking",
|
|
4063
|
+
value: function getPickupTimingBooking() {
|
|
4064
|
+
var _this$store$tempOrder7;
|
|
4065
|
+
return (((_this$store$tempOrder7 = this.store.tempOrder) === null || _this$store$tempOrder7 === void 0 ? void 0 : _this$store$tempOrder7.bookings) || []).find(isFulfillmentTimingBooking) || null;
|
|
4066
|
+
}
|
|
4067
|
+
}, {
|
|
4068
|
+
key: "setPickupTimingBooking",
|
|
4069
|
+
value: function setPickupTimingBooking(input) {
|
|
4070
|
+
var tempOrder = this.ensureTempOrder();
|
|
4071
|
+
var bookings = tempOrder.bookings || [];
|
|
4072
|
+
var firstIndex = bookings.findIndex(isFulfillmentTimingBooking);
|
|
4073
|
+
var nextBooking = buildPickupTimingBooking(input, bookings[firstIndex]);
|
|
4074
|
+
// Keep the first row's identity and position; repair duplicate marked rows only.
|
|
4075
|
+
tempOrder.bookings = firstIndex === -1 ? [].concat(_toConsumableArray(bookings), [nextBooking]) : bookings.flatMap(function (booking, index) {
|
|
4076
|
+
return index === firstIndex ? [nextBooking] : isFulfillmentTimingBooking(booking) ? [] : [booking];
|
|
4077
|
+
});
|
|
4078
|
+
this.notifyTempOrderChanged();
|
|
4079
|
+
return nextBooking;
|
|
4080
|
+
}
|
|
4081
|
+
}, {
|
|
4082
|
+
key: "clearPickupTimingBooking",
|
|
4083
|
+
value: function clearPickupTimingBooking() {
|
|
4084
|
+
var _tempOrder$bookings;
|
|
4085
|
+
var tempOrder = this.store.tempOrder;
|
|
4086
|
+
if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$bookings = tempOrder.bookings) !== null && _tempOrder$bookings !== void 0 && _tempOrder$bookings.some(isFulfillmentTimingBooking))) return;
|
|
4087
|
+
tempOrder.bookings = tempOrder.bookings.filter(function (booking) {
|
|
4088
|
+
return !isFulfillmentTimingBooking(booking);
|
|
4089
|
+
});
|
|
4090
|
+
this.notifyTempOrderChanged();
|
|
4091
|
+
}
|
|
4014
4092
|
}, {
|
|
4015
4093
|
key: "updateTempOrderContactsInfo",
|
|
4016
4094
|
value: function updateTempOrderContactsInfo(contactsInfo) {
|
|
@@ -4052,15 +4130,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4052
4130
|
}, {
|
|
4053
4131
|
key: "productHasCustomerBoundDiscount",
|
|
4054
4132
|
value: function productHasCustomerBoundDiscount(product) {
|
|
4055
|
-
var
|
|
4133
|
+
var _this25 = this;
|
|
4056
4134
|
if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
|
|
4057
|
-
return
|
|
4135
|
+
return _this25.isCustomerBoundDiscount(discount);
|
|
4058
4136
|
})) {
|
|
4059
4137
|
return true;
|
|
4060
4138
|
}
|
|
4061
4139
|
return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
|
|
4062
4140
|
return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
|
|
4063
|
-
return
|
|
4141
|
+
return _this25.isCustomerBoundDiscount(discount);
|
|
4064
4142
|
});
|
|
4065
4143
|
});
|
|
4066
4144
|
}
|
|
@@ -4069,18 +4147,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4069
4147
|
value: function shouldSkipDiscountCalculation(tempOrder) {
|
|
4070
4148
|
var _this$store$discount20,
|
|
4071
4149
|
_this$store$discount21,
|
|
4072
|
-
|
|
4150
|
+
_this26 = this;
|
|
4073
4151
|
if (this.hasActiveCustomerBoundDiscount) return false;
|
|
4074
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)) || [];
|
|
4075
4153
|
if (discountList.length > 0) return false;
|
|
4076
4154
|
return !(tempOrder.products || []).some(function (product) {
|
|
4077
|
-
return
|
|
4155
|
+
return _this26.productHasCustomerBoundDiscount(product);
|
|
4078
4156
|
});
|
|
4079
4157
|
}
|
|
4080
4158
|
}, {
|
|
4081
4159
|
key: "clearCustomerBoundDiscounts",
|
|
4082
4160
|
value: function clearCustomerBoundDiscounts(tempOrder) {
|
|
4083
|
-
var
|
|
4161
|
+
var _this27 = this,
|
|
4084
4162
|
_discountModule$getDi,
|
|
4085
4163
|
_discountModule$getOr,
|
|
4086
4164
|
_discountModule$setDi,
|
|
@@ -4089,7 +4167,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4089
4167
|
var filterDiscountList = function filterDiscountList(discountList) {
|
|
4090
4168
|
if (!Array.isArray(discountList)) return [];
|
|
4091
4169
|
return discountList.filter(function (discount) {
|
|
4092
|
-
var shouldRemove =
|
|
4170
|
+
var shouldRemove = _this27.isCustomerBoundDiscount(discount);
|
|
4093
4171
|
if (shouldRemove) didRemoveCustomerBoundDiscount = true;
|
|
4094
4172
|
return !shouldRemove;
|
|
4095
4173
|
});
|
|
@@ -4116,12 +4194,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4116
4194
|
var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
|
|
4117
4195
|
var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
|
|
4118
4196
|
var nextDiscounts = currentDiscounts.filter(function (discount) {
|
|
4119
|
-
if (
|
|
4120
|
-
return !
|
|
4197
|
+
if (_this27.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
4198
|
+
return !_this27.isCustomerBoundDiscount(discount);
|
|
4121
4199
|
});
|
|
4122
4200
|
var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
|
|
4123
|
-
if (
|
|
4124
|
-
return !
|
|
4201
|
+
if (_this27.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
4202
|
+
return !_this27.isCustomerBoundDiscount(discount);
|
|
4125
4203
|
});
|
|
4126
4204
|
void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
|
|
4127
4205
|
void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
|
|
@@ -4224,8 +4302,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4224
4302
|
}, {
|
|
4225
4303
|
key: "getOrderCustomerSnapshot",
|
|
4226
4304
|
value: function getOrderCustomerSnapshot() {
|
|
4227
|
-
var _this$store$
|
|
4228
|
-
var snapshot = (_this$store$
|
|
4305
|
+
var _this$store$tempOrder8;
|
|
4306
|
+
var snapshot = (_this$store$tempOrder8 = this.store.tempOrder) === null || _this$store$tempOrder8 === void 0 || (_this$store$tempOrder8 = _this$store$tempOrder8._extend) === null || _this$store$tempOrder8 === void 0 ? void 0 : _this$store$tempOrder8.customerSnapshot;
|
|
4229
4307
|
return snapshot ? cloneDeep(snapshot) : null;
|
|
4230
4308
|
}
|
|
4231
4309
|
}, {
|
|
@@ -4285,10 +4363,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4285
4363
|
}, {
|
|
4286
4364
|
key: "setOrderPayments",
|
|
4287
4365
|
value: function setOrderPayments(payments) {
|
|
4288
|
-
var
|
|
4366
|
+
var _this28 = this;
|
|
4289
4367
|
var tempOrder = this.ensureTempOrder();
|
|
4290
4368
|
tempOrder.payments = mapPaymentItemsToOrderPayments((payments || []).map(function (payment) {
|
|
4291
|
-
return
|
|
4369
|
+
return _this28.normalizePaymentSource(payment, {
|
|
4292
4370
|
defaultPaid: false
|
|
4293
4371
|
});
|
|
4294
4372
|
}));
|
|
@@ -4343,7 +4421,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4343
4421
|
}, {
|
|
4344
4422
|
key: "addOrderPaymentWithDevicePrefix",
|
|
4345
4423
|
value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
|
|
4346
|
-
var
|
|
4424
|
+
var _this29 = this;
|
|
4347
4425
|
this.logInfo('addOrderPayment', {
|
|
4348
4426
|
payment: payment
|
|
4349
4427
|
});
|
|
@@ -4361,7 +4439,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4361
4439
|
void this.recalculateSummary({
|
|
4362
4440
|
createIfMissing: true
|
|
4363
4441
|
}).catch(function (error) {
|
|
4364
|
-
|
|
4442
|
+
_this29.logError('recalculate summary after addOrderPayment failed', {
|
|
4365
4443
|
error: error instanceof Error ? error.message : String(error)
|
|
4366
4444
|
});
|
|
4367
4445
|
});
|
|
@@ -4474,7 +4552,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4474
4552
|
}, {
|
|
4475
4553
|
key: "applyPaymentLifecycleChange",
|
|
4476
4554
|
value: function applyPaymentLifecycleChange(tempOrder, options) {
|
|
4477
|
-
var
|
|
4555
|
+
var _this30 = this;
|
|
4478
4556
|
this.updateTempOrderPaymentStatus(tempOrder);
|
|
4479
4557
|
if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
|
|
4480
4558
|
this.persistTempOrder();
|
|
@@ -4484,7 +4562,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4484
4562
|
void this.recalculateSummary({
|
|
4485
4563
|
createIfMissing: true
|
|
4486
4564
|
}).catch(function (error) {
|
|
4487
|
-
|
|
4565
|
+
_this30.logError("recalculate summary after ".concat(logContext, " failed"), {
|
|
4488
4566
|
error: error instanceof Error ? error.message : String(error)
|
|
4489
4567
|
});
|
|
4490
4568
|
});
|
|
@@ -4528,7 +4606,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4528
4606
|
}, {
|
|
4529
4607
|
key: "updateVoucherOrderPayments",
|
|
4530
4608
|
value: function updateVoucherOrderPayments(payments, options) {
|
|
4531
|
-
var
|
|
4609
|
+
var _this31 = this;
|
|
4532
4610
|
var tempOrder = this.ensureTempOrder();
|
|
4533
4611
|
var isOrderPaymentType = function isOrderPaymentType(value) {
|
|
4534
4612
|
return value === 'normal' || value === 'deposit';
|
|
@@ -4563,7 +4641,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4563
4641
|
});
|
|
4564
4642
|
};
|
|
4565
4643
|
var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
|
|
4566
|
-
return
|
|
4644
|
+
return _this31.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
|
|
4567
4645
|
defaultPaid: false,
|
|
4568
4646
|
devicePrefix: options === null || options === void 0 ? void 0 : options.devicePrefix
|
|
4569
4647
|
});
|
|
@@ -4616,7 +4694,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4616
4694
|
void this.recalculateSummary({
|
|
4617
4695
|
createIfMissing: true
|
|
4618
4696
|
}).catch(function (error) {
|
|
4619
|
-
|
|
4697
|
+
_this31.logError('recalculate summary after updateVoucherOrderPayments failed', {
|
|
4620
4698
|
error: error instanceof Error ? error.message : String(error)
|
|
4621
4699
|
});
|
|
4622
4700
|
});
|
|
@@ -4673,16 +4751,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4673
4751
|
}, {
|
|
4674
4752
|
key: "shouldMergeProductToOrder",
|
|
4675
4753
|
value: function shouldMergeProductToOrder(params) {
|
|
4676
|
-
var _this$
|
|
4677
|
-
|
|
4678
|
-
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;
|
|
4679
4757
|
if (!onBeforeMergeProductToOrder) return true;
|
|
4680
4758
|
var result = onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
4681
4759
|
defaultShouldMerge: true
|
|
4682
4760
|
}));
|
|
4683
4761
|
if (result && _typeof(result) === 'object' && typeof result.then === 'function') {
|
|
4684
4762
|
return Promise.resolve(result).then(function (resolved) {
|
|
4685
|
-
return
|
|
4763
|
+
return _this32.normalizeShouldMergeProductResult(resolved);
|
|
4686
4764
|
});
|
|
4687
4765
|
}
|
|
4688
4766
|
return this.normalizeShouldMergeProductResult(result);
|
|
@@ -4883,13 +4961,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4883
4961
|
_metadata,
|
|
4884
4962
|
_productToAdd$metadat,
|
|
4885
4963
|
_origin,
|
|
4886
|
-
|
|
4964
|
+
_this33 = this;
|
|
4887
4965
|
var linked = booking ? this.createLinkedProductAndBooking({
|
|
4888
4966
|
product: product,
|
|
4889
4967
|
booking: booking
|
|
4890
4968
|
}) : null;
|
|
4891
4969
|
var productToAdd = (linked === null || linked === void 0 ? void 0 : linked.product) || product;
|
|
4892
|
-
this.assertAndLockProductSettlement(tempOrder, productToAdd);
|
|
4893
4970
|
var disableMerge = (options === null || options === void 0 ? void 0 : options.disableMerge) === true;
|
|
4894
4971
|
var incomingFingerprint = disableMerge ? '' : buildProductLineFingerprint(getProductSkuOptions(productToAdd), productToAdd.product_bundle);
|
|
4895
4972
|
var normalizedIncoming = this.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(productToAdd, normalizeOrderProduct(productToAdd)));
|
|
@@ -4919,26 +4996,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4919
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;
|
|
4920
4997
|
var shouldForceNewLine = disableMerge || !!booking || hasIncomingGoodPass || isIncomingPersistedEntitlementPass || hasIncomingBookingUid || isIncomingCustomItem || isWeighingProduct;
|
|
4921
4998
|
var matchedIndex = shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
4922
|
-
if (
|
|
4923
|
-
var isRuntimeEntitlementPass =
|
|
4999
|
+
if (_this33.hasGoodPassDiscount(item)) return false;
|
|
5000
|
+
var isRuntimeEntitlementPass = _this33.isRuntimeEntitlementAppend(item, tempOrder);
|
|
4924
5001
|
if (isIncomingEntitlementAppend !== isRuntimeEntitlementPass) {
|
|
4925
5002
|
return false;
|
|
4926
5003
|
}
|
|
4927
|
-
if (isIncomingEntitlementAppend &&
|
|
5004
|
+
if (isIncomingEntitlementAppend && _this33.isPersistedProductLine(item)) {
|
|
4928
5005
|
return false;
|
|
4929
5006
|
}
|
|
4930
|
-
var hasExistingProductNote =
|
|
5007
|
+
var hasExistingProductNote = _this33.hasOrderProductLineNote(item);
|
|
4931
5008
|
if ((hasIncomingProductNote || hasExistingProductNote) && (!isRuntimeEntitlementPass || String(normalizedIncoming.note || '').trim() !== String(item.note || '').trim())) {
|
|
4932
5009
|
return false;
|
|
4933
5010
|
}
|
|
4934
5011
|
var hasExistingManualProductDiscount = isManualProductDiscountProduct(item);
|
|
4935
|
-
if (isRuntimeEntitlementPass && !
|
|
5012
|
+
if (isRuntimeEntitlementPass && !_this33.hasSameEntitlementMergePriceConfig(normalizedIncoming, item)) {
|
|
4936
5013
|
return false;
|
|
4937
5014
|
}
|
|
4938
5015
|
if ((hasIncomingManualProductDiscount || hasExistingManualProductDiscount) && !isRuntimeEntitlementPass) {
|
|
4939
5016
|
return false;
|
|
4940
5017
|
}
|
|
4941
|
-
if (
|
|
5018
|
+
if (_this33.isPersistedProductLine(item)) return false;
|
|
4942
5019
|
if (item.product_id !== productToAdd.product_id) return false;
|
|
4943
5020
|
if (item.product_variant_id !== productToAdd.product_variant_id) return false;
|
|
4944
5021
|
var existedFingerprint = buildProductLineFingerprint(getProductSkuOptions(item), item.product_bundle);
|
|
@@ -4947,9 +5024,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4947
5024
|
var matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
|
|
4948
5025
|
var existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
|
|
4949
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);
|
|
4950
5030
|
var committedProduct;
|
|
4951
5031
|
if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
|
|
4952
|
-
|
|
5032
|
+
_this33.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
|
|
4953
5033
|
if (linked) {
|
|
4954
5034
|
normalizedIncoming.booking_uid = linked.bookingUid;
|
|
4955
5035
|
normalizedIncoming.metadata = _objectSpread(_objectSpread({}, normalizedIncoming.metadata || {}), {}, {
|
|
@@ -4967,7 +5047,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4967
5047
|
var _targetProduct$metada;
|
|
4968
5048
|
var targetProduct = matchedProduct;
|
|
4969
5049
|
var targetUid = (_targetProduct$metada = targetProduct.metadata) === null || _targetProduct$metada === void 0 ? void 0 : _targetProduct$metada.unique_identification_number;
|
|
4970
|
-
var normalizedProduct =
|
|
5050
|
+
var normalizedProduct = _this33.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(targetProduct, normalizeOrderProduct(_objectSpread(_objectSpread({}, productToAdd), {}, {
|
|
4971
5051
|
metadata: _objectSpread(_objectSpread({}, productToAdd.metadata || {}), {}, {
|
|
4972
5052
|
unique_identification_number: targetUid
|
|
4973
5053
|
})
|
|
@@ -4990,7 +5070,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4990
5070
|
order_detail_id: targetProduct.order_detail_id,
|
|
4991
5071
|
num: nextNum
|
|
4992
5072
|
});
|
|
4993
|
-
|
|
5073
|
+
_this33.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
|
|
4994
5074
|
committedProduct = tempOrder.products[matchedIndex];
|
|
4995
5075
|
if (matchedIndex !== tempOrder.products.length - 1) {
|
|
4996
5076
|
var mergedProduct = tempOrder.products[matchedIndex];
|
|
@@ -5100,12 +5180,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5100
5180
|
key: "addProductToOrder",
|
|
5101
5181
|
value: (function () {
|
|
5102
5182
|
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(product, booking, options) {
|
|
5103
|
-
var
|
|
5104
|
-
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;
|
|
5105
5185
|
return _regeneratorRuntime().wrap(function _callee23$(_context25) {
|
|
5106
5186
|
while (1) switch (_context25.prev = _context25.next) {
|
|
5107
5187
|
case 0:
|
|
5108
5188
|
tempOrder = this.ensureTempOrder();
|
|
5189
|
+
beforeCommit = this.createCartIntentCommitGuard('add_product', tempOrder);
|
|
5109
5190
|
salesNoteDrafts = ((options === null || options === void 0 ? void 0 : options.salesNotes) || []).map(function (draft) {
|
|
5110
5191
|
return {
|
|
5111
5192
|
note_type: String(draft.note_type || '').trim(),
|
|
@@ -5129,7 +5210,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5129
5210
|
throw new Error('[Order Notes] 商品行缺少 unique_identification_number');
|
|
5130
5211
|
}
|
|
5131
5212
|
salesNoteDrafts.forEach(function (draft) {
|
|
5132
|
-
|
|
5213
|
+
_this34.setSalesNoteOnTempOrder(tempOrder, {
|
|
5133
5214
|
note_type: draft.note_type,
|
|
5134
5215
|
target: {
|
|
5135
5216
|
target_type: 'order_detail',
|
|
@@ -5153,21 +5234,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5153
5234
|
return uid !== undefined && uid !== null && String(uid) === String(insertAfterProductUid);
|
|
5154
5235
|
}) : -1;
|
|
5155
5236
|
insertAtIndex = anchorIndex >= 0 ? anchorIndex + 1 : undefined;
|
|
5156
|
-
_context25.prev =
|
|
5237
|
+
_context25.prev = 9;
|
|
5157
5238
|
if (!booking) {
|
|
5158
|
-
_context25.next =
|
|
5239
|
+
_context25.next = 34;
|
|
5159
5240
|
break;
|
|
5160
5241
|
}
|
|
5161
5242
|
productRecord = product;
|
|
5162
5243
|
splitCount = getSafeProductNum((_ref71 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref71 !== void 0 ? _ref71 : 1);
|
|
5163
5244
|
if (!(splitCount > 1)) {
|
|
5164
|
-
_context25.next =
|
|
5245
|
+
_context25.next = 28;
|
|
5165
5246
|
break;
|
|
5166
5247
|
}
|
|
5167
5248
|
i = 0;
|
|
5168
|
-
case
|
|
5249
|
+
case 15:
|
|
5169
5250
|
if (!(i < splitCount)) {
|
|
5170
|
-
_context25.next =
|
|
5251
|
+
_context25.next = 26;
|
|
5171
5252
|
break;
|
|
5172
5253
|
}
|
|
5173
5254
|
splitLine = this.createSplitBookingLine(productRecord, booking, i, splitCount);
|
|
@@ -5185,65 +5266,68 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5185
5266
|
delete splitLine.booking.metadata.unique_identification_number;
|
|
5186
5267
|
}
|
|
5187
5268
|
}
|
|
5188
|
-
_context25.next =
|
|
5269
|
+
_context25.next = 20;
|
|
5189
5270
|
return this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking, {
|
|
5190
5271
|
insertAtIndex: insertAtIndex,
|
|
5191
|
-
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge
|
|
5272
|
+
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge,
|
|
5273
|
+
beforeCommit: beforeCommit
|
|
5192
5274
|
});
|
|
5193
|
-
case
|
|
5275
|
+
case 20:
|
|
5194
5276
|
committedProduct = _context25.sent;
|
|
5195
5277
|
attachSalesNoteDrafts(committedProduct);
|
|
5196
5278
|
if (insertAtIndex !== undefined) insertAtIndex += 1;
|
|
5197
|
-
case
|
|
5279
|
+
case 23:
|
|
5198
5280
|
i += 1;
|
|
5199
|
-
_context25.next =
|
|
5281
|
+
_context25.next = 15;
|
|
5200
5282
|
break;
|
|
5201
|
-
case
|
|
5202
|
-
_context25.next =
|
|
5283
|
+
case 26:
|
|
5284
|
+
_context25.next = 32;
|
|
5203
5285
|
break;
|
|
5204
|
-
case
|
|
5205
|
-
_context25.next =
|
|
5286
|
+
case 28:
|
|
5287
|
+
_context25.next = 30;
|
|
5206
5288
|
return this.appendProductLineToTempOrder(tempOrder, product, cloneDeep(booking), {
|
|
5207
5289
|
insertAtIndex: insertAtIndex,
|
|
5208
|
-
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge
|
|
5290
|
+
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge,
|
|
5291
|
+
beforeCommit: beforeCommit
|
|
5209
5292
|
});
|
|
5210
|
-
case
|
|
5293
|
+
case 30:
|
|
5211
5294
|
_committedProduct = _context25.sent;
|
|
5212
5295
|
attachSalesNoteDrafts(_committedProduct);
|
|
5213
|
-
case
|
|
5214
|
-
_context25.next =
|
|
5296
|
+
case 32:
|
|
5297
|
+
_context25.next = 38;
|
|
5215
5298
|
break;
|
|
5216
|
-
case
|
|
5217
|
-
_context25.next =
|
|
5299
|
+
case 34:
|
|
5300
|
+
_context25.next = 36;
|
|
5218
5301
|
return this.appendProductLineToTempOrder(tempOrder, product, undefined, {
|
|
5219
5302
|
insertAtIndex: insertAtIndex,
|
|
5220
|
-
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge
|
|
5303
|
+
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge,
|
|
5304
|
+
beforeCommit: beforeCommit
|
|
5221
5305
|
});
|
|
5222
|
-
case
|
|
5306
|
+
case 36:
|
|
5223
5307
|
_committedProduct2 = _context25.sent;
|
|
5224
5308
|
attachSalesNoteDrafts(_committedProduct2);
|
|
5225
|
-
case
|
|
5226
|
-
_context25.next =
|
|
5309
|
+
case 38:
|
|
5310
|
+
_context25.next = 44;
|
|
5227
5311
|
break;
|
|
5228
|
-
case
|
|
5229
|
-
_context25.prev =
|
|
5230
|
-
_context25.t0 = _context25["catch"](
|
|
5312
|
+
case 40:
|
|
5313
|
+
_context25.prev = 40;
|
|
5314
|
+
_context25.t0 = _context25["catch"](9);
|
|
5231
5315
|
rollbackProductAndNotesMutation();
|
|
5232
5316
|
throw _context25.t0;
|
|
5233
|
-
case
|
|
5234
|
-
_context25.next =
|
|
5317
|
+
case 44:
|
|
5318
|
+
_context25.next = 46;
|
|
5235
5319
|
return this.finalizeProductOrderMutation(tempOrder);
|
|
5236
|
-
case
|
|
5320
|
+
case 46:
|
|
5237
5321
|
this.logInfo('addProductToOrder success', {
|
|
5238
5322
|
product_id: product.product_id,
|
|
5239
5323
|
with_booking: !!booking
|
|
5240
5324
|
});
|
|
5241
5325
|
return _context25.abrupt("return", tempOrder.products);
|
|
5242
|
-
case
|
|
5326
|
+
case 48:
|
|
5243
5327
|
case "end":
|
|
5244
5328
|
return _context25.stop();
|
|
5245
5329
|
}
|
|
5246
|
-
}, _callee23, this, [[
|
|
5330
|
+
}, _callee23, this, [[9, 40]]);
|
|
5247
5331
|
}));
|
|
5248
5332
|
function addProductToOrder(_x23, _x24, _x25) {
|
|
5249
5333
|
return _addProductToOrder.apply(this, arguments);
|
|
@@ -5264,7 +5348,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5264
5348
|
key: "addProductsToOrder",
|
|
5265
5349
|
value: (function () {
|
|
5266
5350
|
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(items, options) {
|
|
5267
|
-
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;
|
|
5268
5352
|
return _regeneratorRuntime().wrap(function _callee24$(_context26) {
|
|
5269
5353
|
while (1) switch (_context26.prev = _context26.next) {
|
|
5270
5354
|
case 0:
|
|
@@ -5275,87 +5359,92 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5275
5359
|
}
|
|
5276
5360
|
return _context26.abrupt("return", tempOrder.products);
|
|
5277
5361
|
case 3:
|
|
5362
|
+
beforeCommit = this.createCartIntentCommitGuard('add_product', tempOrder);
|
|
5278
5363
|
_iterator20 = _createForOfIteratorHelper(items || []);
|
|
5279
|
-
_context26.prev =
|
|
5364
|
+
_context26.prev = 5;
|
|
5280
5365
|
_iterator20.s();
|
|
5281
|
-
case
|
|
5366
|
+
case 7:
|
|
5282
5367
|
if ((_step20 = _iterator20.n()).done) {
|
|
5283
|
-
_context26.next =
|
|
5368
|
+
_context26.next = 33;
|
|
5284
5369
|
break;
|
|
5285
5370
|
}
|
|
5286
5371
|
item = _step20.value;
|
|
5287
5372
|
product = item.product, booking = item.booking;
|
|
5288
5373
|
if (product) {
|
|
5289
|
-
_context26.next =
|
|
5374
|
+
_context26.next = 12;
|
|
5290
5375
|
break;
|
|
5291
5376
|
}
|
|
5292
|
-
return _context26.abrupt("continue",
|
|
5293
|
-
case
|
|
5377
|
+
return _context26.abrupt("continue", 31);
|
|
5378
|
+
case 12:
|
|
5294
5379
|
if (!booking) {
|
|
5295
|
-
_context26.next =
|
|
5380
|
+
_context26.next = 27;
|
|
5296
5381
|
break;
|
|
5297
5382
|
}
|
|
5298
5383
|
productRecord = product;
|
|
5299
5384
|
splitCount = getSafeProductNum((_ref72 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref72 !== void 0 ? _ref72 : 1);
|
|
5300
5385
|
if (!(splitCount > 1)) {
|
|
5301
|
-
_context26.next =
|
|
5386
|
+
_context26.next = 27;
|
|
5302
5387
|
break;
|
|
5303
5388
|
}
|
|
5304
5389
|
i = 0;
|
|
5305
|
-
case
|
|
5390
|
+
case 17:
|
|
5306
5391
|
if (!(i < splitCount)) {
|
|
5307
|
-
_context26.next =
|
|
5392
|
+
_context26.next = 26;
|
|
5308
5393
|
break;
|
|
5309
5394
|
}
|
|
5310
5395
|
splitLine = this.createSplitBookingLine(productRecord, booking, i, splitCount);
|
|
5311
|
-
_appendResult = this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking
|
|
5396
|
+
_appendResult = this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking, {
|
|
5397
|
+
beforeCommit: beforeCommit
|
|
5398
|
+
});
|
|
5312
5399
|
if (!_appendResult) {
|
|
5313
|
-
_context26.next =
|
|
5400
|
+
_context26.next = 23;
|
|
5314
5401
|
break;
|
|
5315
5402
|
}
|
|
5316
|
-
_context26.next =
|
|
5403
|
+
_context26.next = 23;
|
|
5317
5404
|
return _appendResult;
|
|
5318
|
-
case
|
|
5405
|
+
case 23:
|
|
5319
5406
|
i += 1;
|
|
5320
|
-
_context26.next =
|
|
5407
|
+
_context26.next = 17;
|
|
5321
5408
|
break;
|
|
5322
|
-
case 25:
|
|
5323
|
-
return _context26.abrupt("continue", 30);
|
|
5324
5409
|
case 26:
|
|
5325
|
-
|
|
5410
|
+
return _context26.abrupt("continue", 31);
|
|
5411
|
+
case 27:
|
|
5412
|
+
appendResult = this.appendProductLineToTempOrder(tempOrder, product, booking, {
|
|
5413
|
+
beforeCommit: beforeCommit
|
|
5414
|
+
});
|
|
5326
5415
|
if (!appendResult) {
|
|
5327
|
-
_context26.next =
|
|
5416
|
+
_context26.next = 31;
|
|
5328
5417
|
break;
|
|
5329
5418
|
}
|
|
5330
|
-
_context26.next =
|
|
5419
|
+
_context26.next = 31;
|
|
5331
5420
|
return appendResult;
|
|
5332
|
-
case
|
|
5333
|
-
_context26.next =
|
|
5421
|
+
case 31:
|
|
5422
|
+
_context26.next = 7;
|
|
5334
5423
|
break;
|
|
5335
|
-
case
|
|
5336
|
-
_context26.next =
|
|
5424
|
+
case 33:
|
|
5425
|
+
_context26.next = 38;
|
|
5337
5426
|
break;
|
|
5338
|
-
case
|
|
5339
|
-
_context26.prev =
|
|
5340
|
-
_context26.t0 = _context26["catch"](
|
|
5427
|
+
case 35:
|
|
5428
|
+
_context26.prev = 35;
|
|
5429
|
+
_context26.t0 = _context26["catch"](5);
|
|
5341
5430
|
_iterator20.e(_context26.t0);
|
|
5342
|
-
case
|
|
5343
|
-
_context26.prev =
|
|
5431
|
+
case 38:
|
|
5432
|
+
_context26.prev = 38;
|
|
5344
5433
|
_iterator20.f();
|
|
5345
|
-
return _context26.finish(
|
|
5346
|
-
case
|
|
5347
|
-
_context26.next =
|
|
5434
|
+
return _context26.finish(38);
|
|
5435
|
+
case 41:
|
|
5436
|
+
_context26.next = 43;
|
|
5348
5437
|
return this.finalizeProductOrderMutation(tempOrder, options);
|
|
5349
|
-
case
|
|
5438
|
+
case 43:
|
|
5350
5439
|
this.logInfo('addProductsToOrder success', {
|
|
5351
5440
|
itemsCount: items.length
|
|
5352
5441
|
});
|
|
5353
5442
|
return _context26.abrupt("return", tempOrder.products);
|
|
5354
|
-
case
|
|
5443
|
+
case 45:
|
|
5355
5444
|
case "end":
|
|
5356
5445
|
return _context26.stop();
|
|
5357
5446
|
}
|
|
5358
|
-
}, _callee24, this, [[
|
|
5447
|
+
}, _callee24, this, [[5, 35, 38, 41]]);
|
|
5359
5448
|
}));
|
|
5360
5449
|
function addProductsToOrder(_x26, _x27) {
|
|
5361
5450
|
return _addProductsToOrder.apply(this, arguments);
|
|
@@ -5409,7 +5498,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5409
5498
|
}, {
|
|
5410
5499
|
key: "hasSameEntitlementMergePriceConfig",
|
|
5411
5500
|
value: function hasSameEntitlementMergePriceConfig(incoming, existing) {
|
|
5412
|
-
var
|
|
5501
|
+
var _this35 = this;
|
|
5413
5502
|
var buildPriceConfig = function buildPriceConfig(product) {
|
|
5414
5503
|
var metadata = product.metadata || {};
|
|
5415
5504
|
var bundle = (product.product_bundle || []).map(function (item) {
|
|
@@ -5425,10 +5514,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5425
5514
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
5426
5515
|
});
|
|
5427
5516
|
return JSON.stringify({
|
|
5428
|
-
original_price:
|
|
5429
|
-
source_product_price:
|
|
5430
|
-
main_product_original_price:
|
|
5431
|
-
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),
|
|
5432
5521
|
is_manual_discount: Boolean(metadata.is_manual_discount),
|
|
5433
5522
|
bundle: bundle
|
|
5434
5523
|
});
|
|
@@ -5445,17 +5534,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5445
5534
|
}, {
|
|
5446
5535
|
key: "preservePersistedBundlePriceFields",
|
|
5447
5536
|
value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
|
|
5448
|
-
var
|
|
5537
|
+
var _this36 = this;
|
|
5449
5538
|
if (!Array.isArray(nextBundles)) return nextBundles;
|
|
5450
5539
|
if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
|
|
5451
5540
|
var previousByIdentity = new Map();
|
|
5452
5541
|
previousBundles.forEach(function (bundle) {
|
|
5453
|
-
var identity =
|
|
5542
|
+
var identity = _this36.getBundleRuntimeIdentity(bundle);
|
|
5454
5543
|
if (identity) previousByIdentity.set(identity, bundle);
|
|
5455
5544
|
});
|
|
5456
5545
|
return nextBundles.map(function (bundle, index) {
|
|
5457
5546
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
5458
|
-
var previous = previousByIdentity.get(
|
|
5547
|
+
var previous = previousByIdentity.get(_this36.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
|
|
5459
5548
|
if (!previous || _typeof(previous) !== 'object') return bundle;
|
|
5460
5549
|
return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
|
|
5461
5550
|
cover: previous.cover
|
|
@@ -5469,6 +5558,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5469
5558
|
});
|
|
5470
5559
|
});
|
|
5471
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
|
+
}
|
|
5472
5579
|
}, {
|
|
5473
5580
|
key: "applyOrderProductUpdateToTempOrder",
|
|
5474
5581
|
value: function applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids) {
|
|
@@ -5500,8 +5607,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5500
5607
|
if (unique_identification_number !== undefined) {
|
|
5501
5608
|
var targetUid = String(unique_identification_number);
|
|
5502
5609
|
productIndex = tempOrder.products.findIndex(function (item) {
|
|
5503
|
-
var _item$
|
|
5504
|
-
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;
|
|
5505
5612
|
});
|
|
5506
5613
|
}
|
|
5507
5614
|
if (productIndex === -1) {
|
|
@@ -5714,29 +5821,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5714
5821
|
while (1) switch (_context27.prev = _context27.next) {
|
|
5715
5822
|
case 0:
|
|
5716
5823
|
tempOrder = this.ensureTempOrder();
|
|
5824
|
+
if (this.isRestrictedCartProductUpdate(tempOrder, params)) {
|
|
5825
|
+
this.createCartIntentCommitGuard('update_product', tempOrder)();
|
|
5826
|
+
}
|
|
5717
5827
|
reapplyWeighedDiscountProductUids = [];
|
|
5718
5828
|
updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
|
|
5719
|
-
_context27.next =
|
|
5829
|
+
_context27.next = 6;
|
|
5720
5830
|
return this.evaluatePromotion();
|
|
5721
|
-
case
|
|
5831
|
+
case 6:
|
|
5722
5832
|
promotionPayload = _context27.sent;
|
|
5723
5833
|
this.applyDiscount({
|
|
5724
5834
|
reapplyWeighedDiscountProductUids: reapplyWeighedDiscountProductUids,
|
|
5725
5835
|
reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
|
|
5726
5836
|
});
|
|
5727
5837
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
5728
|
-
_context27.next =
|
|
5838
|
+
_context27.next = 11;
|
|
5729
5839
|
return this.recalculateSummary({
|
|
5730
5840
|
createIfMissing: true
|
|
5731
5841
|
});
|
|
5732
|
-
case
|
|
5842
|
+
case 11:
|
|
5733
5843
|
this.persistTempOrder();
|
|
5734
5844
|
this.emitPromotionApplied(promotionPayload);
|
|
5735
5845
|
this.logInfo('updateOrderProduct success', {
|
|
5736
5846
|
params: params
|
|
5737
5847
|
});
|
|
5738
5848
|
return _context27.abrupt("return", tempOrder.products);
|
|
5739
|
-
case
|
|
5849
|
+
case 15:
|
|
5740
5850
|
case "end":
|
|
5741
5851
|
return _context27.stop();
|
|
5742
5852
|
}
|
|
@@ -5751,7 +5861,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5751
5861
|
key: "updateOrderProducts",
|
|
5752
5862
|
value: function () {
|
|
5753
5863
|
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(paramsList) {
|
|
5754
|
-
var
|
|
5864
|
+
var _this37 = this;
|
|
5755
5865
|
var tempOrder, reapplyWeighedDiscountProductUids, reapplyBookingDiscountProductUids;
|
|
5756
5866
|
return _regeneratorRuntime().wrap(function _callee26$(_context28) {
|
|
5757
5867
|
while (1) switch (_context28.prev = _context28.next) {
|
|
@@ -5763,26 +5873,31 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5763
5873
|
}
|
|
5764
5874
|
return _context28.abrupt("return", tempOrder.products);
|
|
5765
5875
|
case 3:
|
|
5876
|
+
if (paramsList.some(function (params) {
|
|
5877
|
+
return _this37.isRestrictedCartProductUpdate(tempOrder, params);
|
|
5878
|
+
})) {
|
|
5879
|
+
this.createCartIntentCommitGuard('update_product', tempOrder)();
|
|
5880
|
+
}
|
|
5766
5881
|
reapplyWeighedDiscountProductUids = [];
|
|
5767
5882
|
reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
|
|
5768
|
-
var updatedProductUid =
|
|
5883
|
+
var updatedProductUid = _this37.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
|
|
5769
5884
|
// 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
|
|
5770
5885
|
if (params.allow_booking_discount_reapply && updatedProductUid) {
|
|
5771
5886
|
acc.push(String(updatedProductUid));
|
|
5772
5887
|
}
|
|
5773
5888
|
return acc;
|
|
5774
5889
|
}, []);
|
|
5775
|
-
_context28.next =
|
|
5890
|
+
_context28.next = 8;
|
|
5776
5891
|
return this.finalizeAfterProductsMutation(tempOrder, {
|
|
5777
5892
|
reapplyWeighedDiscountProductUids: reapplyWeighedDiscountProductUids,
|
|
5778
5893
|
reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
|
|
5779
5894
|
});
|
|
5780
|
-
case
|
|
5895
|
+
case 8:
|
|
5781
5896
|
this.logInfo('updateOrderProduct success', {
|
|
5782
5897
|
paramsList: paramsList
|
|
5783
5898
|
});
|
|
5784
5899
|
return _context28.abrupt("return", tempOrder.products);
|
|
5785
|
-
case
|
|
5900
|
+
case 10:
|
|
5786
5901
|
case "end":
|
|
5787
5902
|
return _context28.stop();
|
|
5788
5903
|
}
|
|
@@ -5822,8 +5937,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5822
5937
|
if (unique_identification_number !== undefined) {
|
|
5823
5938
|
targetUid = String(unique_identification_number);
|
|
5824
5939
|
productIndex = tempOrder.products.findIndex(function (item) {
|
|
5825
|
-
var _item$
|
|
5826
|
-
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;
|
|
5827
5942
|
});
|
|
5828
5943
|
}
|
|
5829
5944
|
if (productIndex === -1) {
|
|
@@ -5871,39 +5986,42 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5871
5986
|
}
|
|
5872
5987
|
throw new VirtualCurrencyBalanceError(balance.toFixed(2), requiredAmount.toFixed(2));
|
|
5873
5988
|
case 27:
|
|
5989
|
+
if (normalizedProduct.num > targetProduct.num) {
|
|
5990
|
+
this.createCartIntentCommitGuard('increase_quantity', tempOrder)();
|
|
5991
|
+
}
|
|
5874
5992
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
5875
5993
|
this.prepareVirtualSettlementTempOrder(tempOrder);
|
|
5876
5994
|
isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder);
|
|
5877
5995
|
if (isVirtualSettlement) {
|
|
5878
|
-
_context29.next =
|
|
5996
|
+
_context29.next = 37;
|
|
5879
5997
|
break;
|
|
5880
5998
|
}
|
|
5881
|
-
_context29.next =
|
|
5999
|
+
_context29.next = 34;
|
|
5882
6000
|
return this.evaluatePromotion();
|
|
5883
|
-
case
|
|
6001
|
+
case 34:
|
|
5884
6002
|
_context29.t0 = _context29.sent;
|
|
5885
|
-
_context29.next =
|
|
6003
|
+
_context29.next = 38;
|
|
5886
6004
|
break;
|
|
5887
|
-
case 36:
|
|
5888
|
-
_context29.t0 = null;
|
|
5889
6005
|
case 37:
|
|
6006
|
+
_context29.t0 = null;
|
|
6007
|
+
case 38:
|
|
5890
6008
|
promotionPayload = _context29.t0;
|
|
5891
6009
|
if (!isVirtualSettlement) {
|
|
5892
6010
|
this.applyDiscount();
|
|
5893
6011
|
}
|
|
5894
6012
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
5895
|
-
_context29.next =
|
|
6013
|
+
_context29.next = 43;
|
|
5896
6014
|
return this.recalculateSummary({
|
|
5897
6015
|
createIfMissing: true
|
|
5898
6016
|
});
|
|
5899
|
-
case
|
|
6017
|
+
case 43:
|
|
5900
6018
|
this.persistTempOrder();
|
|
5901
6019
|
this.emitPromotionApplied(promotionPayload);
|
|
5902
6020
|
this.logInfo('updateOrderProductQuantity success', {
|
|
5903
6021
|
params: params
|
|
5904
6022
|
});
|
|
5905
6023
|
return _context29.abrupt("return", tempOrder.products);
|
|
5906
|
-
case
|
|
6024
|
+
case 47:
|
|
5907
6025
|
case "end":
|
|
5908
6026
|
return _context29.stop();
|
|
5909
6027
|
}
|
|
@@ -5994,7 +6112,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5994
6112
|
key: "removeProductsFromOrder",
|
|
5995
6113
|
value: (function () {
|
|
5996
6114
|
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(identities, options) {
|
|
5997
|
-
var
|
|
6115
|
+
var _this38 = this;
|
|
5998
6116
|
var tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
|
|
5999
6117
|
return _regeneratorRuntime().wrap(function _callee29$(_context32) {
|
|
6000
6118
|
while (1) switch (_context32.prev = _context32.next) {
|
|
@@ -6013,8 +6131,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6013
6131
|
bookingsBeforeRemove = tempOrder.bookings || [];
|
|
6014
6132
|
preserveDisplayPosition = options === null || options === void 0 ? void 0 : options.preserveDisplayPosition;
|
|
6015
6133
|
anchorIndex = preserveDisplayPosition ? productsBeforeRemove.findIndex(function (item) {
|
|
6016
|
-
var _item$
|
|
6017
|
-
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;
|
|
6018
6136
|
return uid !== undefined && uid !== null && String(uid) === String(preserveDisplayPosition.anchorProductUid);
|
|
6019
6137
|
}) : -1;
|
|
6020
6138
|
productsAfterAnchor = anchorIndex >= 0 ? productsBeforeRemove.slice(anchorIndex + 1) : [];
|
|
@@ -6059,7 +6177,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6059
6177
|
}
|
|
6060
6178
|
if (productUid !== undefined && productUid !== null && productUid !== '') {
|
|
6061
6179
|
bookingsBeforeRemove.forEach(function (booking) {
|
|
6062
|
-
var bookingUid =
|
|
6180
|
+
var bookingUid = _this38.getBookingUniqueIdentificationNumber(booking);
|
|
6063
6181
|
if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
|
|
6064
6182
|
linkedBookingUidsToRemove.add(bookingUid);
|
|
6065
6183
|
}
|
|
@@ -6110,8 +6228,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6110
6228
|
}
|
|
6111
6229
|
if (preserveDisplayPosition && anchorIndex >= 0) {
|
|
6112
6230
|
remainingProductIndex = tempOrder.products.findIndex(function (item) {
|
|
6113
|
-
var _item$
|
|
6114
|
-
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;
|
|
6115
6233
|
return uid !== undefined && uid !== null && String(uid) === String(preserveDisplayPosition.remainingProductUid);
|
|
6116
6234
|
});
|
|
6117
6235
|
if (remainingProductIndex >= 0) {
|
|
@@ -6691,10 +6809,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6691
6809
|
value: function extractSubmitErrorResponse(error) {
|
|
6692
6810
|
var _error$response,
|
|
6693
6811
|
_error$response2,
|
|
6694
|
-
|
|
6812
|
+
_this39 = this;
|
|
6695
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];
|
|
6696
6814
|
return candidates.find(function (candidate) {
|
|
6697
|
-
return
|
|
6815
|
+
return _this39.isSubmitErrorResponse(candidate);
|
|
6698
6816
|
}) || null;
|
|
6699
6817
|
}
|
|
6700
6818
|
}, {
|
|
@@ -6722,7 +6840,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6722
6840
|
key: "syncPaymentsToOrder",
|
|
6723
6841
|
value: function () {
|
|
6724
6842
|
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
|
|
6725
|
-
var
|
|
6843
|
+
var _this40 = this,
|
|
6726
6844
|
_params$confirmPendin;
|
|
6727
6845
|
var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, enhancePayload, submitParams, submitResult;
|
|
6728
6846
|
return _regeneratorRuntime().wrap(function _callee39$(_context42) {
|
|
@@ -6747,7 +6865,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6747
6865
|
case 9:
|
|
6748
6866
|
devicePrefix = _context42.t0;
|
|
6749
6867
|
mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
|
|
6750
|
-
return
|
|
6868
|
+
return _this40.normalizePaymentSource(payment, {
|
|
6751
6869
|
defaultPaid: false,
|
|
6752
6870
|
devicePrefix: devicePrefix
|
|
6753
6871
|
});
|
|
@@ -6826,7 +6944,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6826
6944
|
}, {
|
|
6827
6945
|
key: "createOrder",
|
|
6828
6946
|
value: function createOrder(params) {
|
|
6829
|
-
var
|
|
6947
|
+
var _this41 = this;
|
|
6830
6948
|
var order = _objectSpread({
|
|
6831
6949
|
type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
|
|
6832
6950
|
// 要从外面拿,virtual
|
|
@@ -6858,7 +6976,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6858
6976
|
|
|
6859
6977
|
// 为预约补齐 holder 信息
|
|
6860
6978
|
if (params !== null && params !== void 0 && (_params$extraData = params.extraData) !== null && _params$extraData !== void 0 && _params$extraData.is_add_holder_info) {
|
|
6861
|
-
ensureCartItemOriginHolder(item,
|
|
6979
|
+
ensureCartItemOriginHolder(item, _this41.window);
|
|
6862
6980
|
}
|
|
6863
6981
|
|
|
6864
6982
|
// 购物车是否为普通商品
|
|
@@ -7257,12 +7375,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7257
7375
|
params.forceRemote = false;
|
|
7258
7376
|
}
|
|
7259
7377
|
_context49.next = 6;
|
|
7260
|
-
return this.request
|
|
7261
|
-
|
|
7262
|
-
|
|
7263
|
-
forceRemote:
|
|
7264
|
-
} : {}), {
|
|
7265
|
-
osServer: true
|
|
7378
|
+
return loadSalesOrderSnapshot(this.request, {
|
|
7379
|
+
lookup: lookup,
|
|
7380
|
+
transport: 'os-server',
|
|
7381
|
+
forceRemote: params.forceRemote
|
|
7266
7382
|
});
|
|
7267
7383
|
case 6:
|
|
7268
7384
|
res = _context49.sent;
|
|
@@ -7561,7 +7677,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7561
7677
|
}, {
|
|
7562
7678
|
key: "normalizeTempOrderForRuntime",
|
|
7563
7679
|
value: function normalizeTempOrderForRuntime(raw, options) {
|
|
7564
|
-
var
|
|
7680
|
+
var _this42 = this,
|
|
7565
7681
|
_raw$_extend;
|
|
7566
7682
|
var runtimeRaw = this.withoutSyntheticDraftOrderIdForRuntime(raw);
|
|
7567
7683
|
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
|
|
@@ -7586,12 +7702,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7586
7702
|
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
7587
7703
|
var rawProducts = Array.isArray(raw.products) ? raw.products : [];
|
|
7588
7704
|
nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
|
|
7589
|
-
return
|
|
7705
|
+
return _this42.normalizeHydratedOrderProduct(p, {
|
|
7590
7706
|
makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
|
|
7591
7707
|
});
|
|
7592
7708
|
}) : [];
|
|
7593
7709
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
7594
|
-
var booking =
|
|
7710
|
+
var booking = _this42.normalizeHydratedBookingHolder(b || {});
|
|
7595
7711
|
return _objectSpread(_objectSpread({}, booking), {}, {
|
|
7596
7712
|
is_all: normalizeBookingIsAll(booking),
|
|
7597
7713
|
sub_type: normalizeBookingSubType(booking)
|
|
@@ -7798,7 +7914,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7798
7914
|
}, {
|
|
7799
7915
|
key: "normalizeHydratedOrderProduct",
|
|
7800
7916
|
value: function normalizeHydratedOrderProduct(product, options) {
|
|
7801
|
-
var
|
|
7917
|
+
var _this43 = this;
|
|
7802
7918
|
var row = _objectSpread({}, product || {});
|
|
7803
7919
|
if (row.num === undefined && row.product_quantity !== undefined) {
|
|
7804
7920
|
row.num = row.product_quantity;
|
|
@@ -7806,7 +7922,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7806
7922
|
var productSku = ensureProductSku(row);
|
|
7807
7923
|
row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
|
|
7808
7924
|
option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
|
|
7809
|
-
return
|
|
7925
|
+
return _this43.normalizeHydratedProductOptionItem(optionItem || {});
|
|
7810
7926
|
}))
|
|
7811
7927
|
});
|
|
7812
7928
|
delete row["product_".concat('option', "_item")];
|
|
@@ -7894,8 +8010,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7894
8010
|
}, {
|
|
7895
8011
|
key: "getVouchers",
|
|
7896
8012
|
value: function getVouchers() {
|
|
7897
|
-
var _this$store$
|
|
7898
|
-
return ((_this$store$
|
|
8013
|
+
var _this$store$tempOrder9;
|
|
8014
|
+
return ((_this$store$tempOrder9 = this.store.tempOrder) === null || _this$store$tempOrder9 === void 0 ? void 0 : _this$store$tempOrder9.vouchers) || [];
|
|
7899
8015
|
}
|
|
7900
8016
|
}], [{
|
|
7901
8017
|
key: "populateSavedAmounts",
|
|
@@ -7989,4 +8105,5 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7989
8105
|
}
|
|
7990
8106
|
}]);
|
|
7991
8107
|
return OrderModule;
|
|
7992
|
-
}(BaseModule);
|
|
8108
|
+
}(BaseModule);
|
|
8109
|
+
export { isFulfillmentTimingBooking } from "./pickupTiming";
|