@pisell/pisellos 2.2.313 → 2.2.315
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/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
- package/dist/model/strategy/adapter/itemRule/adapter.js +74 -7
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
- package/dist/model/strategy/adapter/itemRule/evaluator.js +13 -0
- package/dist/model/strategy/adapter/itemRule/type.d.ts +40 -1
- package/dist/model/strategy/adapter/itemRule/type.js +10 -0
- package/dist/modules/BookingContext/utils/productExtend.d.ts +7 -0
- package/dist/modules/BookingContext/utils/productExtend.js +62 -18
- package/dist/modules/BookingContext/utils/resources.js +1 -1
- package/dist/modules/BusinessAvailability/index.d.ts +30 -0
- package/dist/modules/BusinessAvailability/index.js +204 -0
- package/dist/modules/Cart/index.js +4 -3
- package/dist/modules/Cart/types.d.ts +2 -0
- package/dist/modules/Cart/utils/cartProduct.d.ts +3 -1
- package/dist/modules/Cart/utils/cartProduct.js +59 -32
- 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 +14 -0
- package/dist/modules/Order/index.d.ts +14 -2
- package/dist/modules/Order/index.js +856 -486
- package/dist/modules/Order/localEftposState.d.ts +13 -0
- package/dist/modules/Order/localEftposState.js +39 -0
- package/dist/modules/Order/pickupTiming.d.ts +46 -0
- package/dist/modules/Order/pickupTiming.js +53 -0
- package/dist/modules/Order/types.d.ts +30 -2
- package/dist/modules/Order/utils.js +25 -7
- package/dist/modules/Payment/index.js +9 -10
- package/dist/modules/Product/types.d.ts +11 -0
- package/dist/modules/ProductList/index.js +1 -1
- package/dist/modules/ResourcePlanner/planner.d.ts +2 -0
- package/dist/modules/ResourcePlanner/planner.js +332 -23
- package/dist/modules/ResourcePlanner/types.d.ts +29 -0
- 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/index.d.ts +1 -0
- package/dist/server/index.js +1536 -1309
- package/dist/server/modules/form/index.d.ts +19 -0
- package/dist/server/modules/form/index.js +205 -0
- package/dist/server/modules/form/types.d.ts +13 -0
- package/dist/server/modules/form/types.js +3 -0
- package/dist/server/modules/index.d.ts +3 -0
- package/dist/server/modules/index.js +4 -0
- package/dist/server/modules/order/index.d.ts +15 -0
- package/dist/server/modules/order/index.js +920 -688
- package/dist/server/modules/order/types.d.ts +1 -0
- package/dist/server/test.json +1 -1
- 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/customerInvoiceLanguages.d.ts +8 -0
- package/dist/shared/receipt/customerInvoiceLanguages.js +60 -0
- package/dist/shared/receipt/loadCustomerInvoiceLayout.d.ts +27 -0
- package/dist/shared/receipt/loadCustomerInvoiceLayout.js +184 -0
- package/dist/shared/receipt/small-ticket.d.ts +96 -0
- package/dist/shared/receipt/small-ticket.js +2751 -0
- package/dist/shared/receipt/templateVisibility.d.ts +23 -0
- package/dist/shared/receipt/templateVisibility.js +64 -0
- package/dist/shared/sales/loadSalesOrderSnapshot.d.ts +9 -0
- package/dist/shared/sales/loadSalesOrderSnapshot.js +21 -0
- package/dist/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
- package/dist/solution/BaseSales/fulfillmentItemRules.js +750 -0
- package/dist/solution/BaseSales/index.d.ts +39 -16
- package/dist/solution/BaseSales/index.js +1754 -1154
- package/dist/solution/BaseSales/pickupTiming.d.ts +47 -0
- package/dist/solution/BaseSales/pickupTiming.js +616 -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 +4 -2
- package/dist/solution/BookingByStep/index.js +8 -3
- package/dist/solution/BookingTicket/index.d.ts +8 -2
- package/dist/solution/BookingTicket/index.js +513 -436
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -1
- package/dist/solution/BookingTicket/utils/addProductDecision.js +1 -1
- package/dist/solution/BookingTicket/utils/cartView.js +3 -1
- package/dist/solution/OrderInvoicePreview/index.d.ts +66 -0
- package/dist/solution/OrderInvoicePreview/index.js +340 -0
- package/dist/solution/RegisterAndLogin/config.js +54 -11
- package/dist/solution/RegisterAndLogin/index.d.ts +2 -0
- package/dist/solution/RegisterAndLogin/index.js +1 -1
- package/dist/solution/RegisterAndLogin/utils.d.ts +12 -4
- package/dist/solution/RegisterAndLogin/utils.js +36 -16
- package/dist/solution/Sales/index.js +1 -1
- package/dist/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
- package/dist/solution/UnifiedBookingSales/businessAvailability.js +292 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +36 -4
- package/dist/solution/UnifiedBookingSales/index.js +1714 -905
- package/dist/solution/UnifiedBookingSales/types.d.ts +16 -2
- package/dist/solution/VenueBooking/index.d.ts +15 -2
- package/dist/solution/VenueBooking/index.js +1062 -785
- package/dist/solution/VenueBooking/types.d.ts +2 -1
- package/dist/solution/VenueBooking/types.js +1 -0
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +7 -4
- package/dist/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
- package/dist/solution/VenueBooking/utils/smartPricing.js +273 -0
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +1 -0
- package/dist/solution/VenueBooking/utils/timeSlot.js +6 -3
- 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/itemRule/adapter.d.ts +3 -1
- package/lib/model/strategy/adapter/itemRule/adapter.js +54 -4
- package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
- package/lib/model/strategy/adapter/itemRule/evaluator.js +9 -0
- package/lib/model/strategy/adapter/itemRule/type.d.ts +40 -1
- package/lib/model/strategy/adapter/itemRule/type.js +10 -0
- package/lib/modules/BookingContext/utils/productExtend.d.ts +7 -0
- package/lib/modules/BookingContext/utils/productExtend.js +45 -2
- package/lib/modules/BookingContext/utils/resources.js +1 -1
- package/lib/modules/BusinessAvailability/index.d.ts +30 -0
- package/lib/modules/BusinessAvailability/index.js +146 -0
- package/lib/modules/Cart/index.js +4 -2
- package/lib/modules/Cart/types.d.ts +2 -0
- package/lib/modules/Cart/utils/cartProduct.d.ts +3 -1
- package/lib/modules/Cart/utils/cartProduct.js +39 -20
- 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 +14 -0
- package/lib/modules/Order/index.d.ts +14 -2
- package/lib/modules/Order/index.js +240 -38
- package/lib/modules/Order/localEftposState.d.ts +13 -0
- package/lib/modules/Order/localEftposState.js +44 -0
- package/lib/modules/Order/pickupTiming.d.ts +46 -0
- package/lib/modules/Order/pickupTiming.js +61 -0
- package/lib/modules/Order/types.d.ts +30 -2
- package/lib/modules/Order/utils.js +21 -5
- package/lib/modules/Payment/index.js +3 -4
- package/lib/modules/Product/types.d.ts +11 -0
- package/lib/modules/ProductList/index.js +1 -1
- package/lib/modules/ResourcePlanner/planner.d.ts +2 -0
- package/lib/modules/ResourcePlanner/planner.js +252 -8
- package/lib/modules/ResourcePlanner/types.d.ts +29 -0
- 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/index.d.ts +1 -0
- package/lib/server/index.js +158 -37
- package/lib/server/modules/form/index.d.ts +19 -0
- package/lib/server/modules/form/index.js +73 -0
- package/lib/server/modules/form/types.d.ts +13 -0
- package/lib/server/modules/form/types.js +9 -0
- package/lib/server/modules/index.d.ts +3 -0
- package/lib/server/modules/index.js +15 -1
- package/lib/server/modules/order/index.d.ts +15 -0
- package/lib/server/modules/order/index.js +114 -3
- package/lib/server/modules/order/types.d.ts +1 -0
- package/lib/server/test.json +1 -1
- 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/customerInvoiceLanguages.d.ts +8 -0
- package/lib/shared/receipt/customerInvoiceLanguages.js +58 -0
- package/lib/shared/receipt/loadCustomerInvoiceLayout.d.ts +27 -0
- package/lib/shared/receipt/loadCustomerInvoiceLayout.js +124 -0
- package/lib/shared/receipt/small-ticket.d.ts +96 -0
- package/lib/shared/receipt/small-ticket.js +2546 -0
- package/lib/shared/receipt/templateVisibility.d.ts +23 -0
- package/lib/shared/receipt/templateVisibility.js +63 -0
- package/lib/shared/sales/loadSalesOrderSnapshot.d.ts +9 -0
- package/lib/shared/sales/loadSalesOrderSnapshot.js +22 -0
- package/lib/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
- package/lib/solution/BaseSales/fulfillmentItemRules.js +259 -0
- package/lib/solution/BaseSales/index.d.ts +39 -16
- package/lib/solution/BaseSales/index.js +333 -31
- package/lib/solution/BaseSales/pickupTiming.d.ts +47 -0
- package/lib/solution/BaseSales/pickupTiming.js +290 -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 +4 -2
- package/lib/solution/BookingByStep/index.js +7 -3
- package/lib/solution/BookingTicket/index.d.ts +8 -2
- package/lib/solution/BookingTicket/index.js +65 -6
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.js +1 -1
- package/lib/solution/BookingTicket/utils/cartView.js +3 -1
- package/lib/solution/OrderInvoicePreview/index.d.ts +66 -0
- package/lib/solution/OrderInvoicePreview/index.js +246 -0
- package/lib/solution/RegisterAndLogin/config.js +57 -11
- package/lib/solution/RegisterAndLogin/index.d.ts +2 -0
- package/lib/solution/RegisterAndLogin/index.js +9 -1
- package/lib/solution/RegisterAndLogin/utils.d.ts +12 -4
- package/lib/solution/RegisterAndLogin/utils.js +24 -17
- package/lib/solution/Sales/index.js +1 -1
- package/lib/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
- package/lib/solution/UnifiedBookingSales/businessAvailability.js +138 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +36 -4
- package/lib/solution/UnifiedBookingSales/index.js +561 -74
- package/lib/solution/UnifiedBookingSales/types.d.ts +16 -2
- package/lib/solution/VenueBooking/index.d.ts +15 -2
- package/lib/solution/VenueBooking/index.js +243 -96
- package/lib/solution/VenueBooking/types.d.ts +2 -1
- package/lib/solution/VenueBooking/types.js +1 -0
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +7 -4
- package/lib/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
- package/lib/solution/VenueBooking/utils/smartPricing.js +224 -0
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +1 -0
- package/lib/solution/VenueBooking/utils/timeSlot.js +5 -2
- package/lib/solution/index.d.ts +1 -0
- package/lib/solution/index.js +11 -0
- package/package.json +1 -1
|
@@ -30,11 +30,14 @@ 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";
|
|
34
|
+
import { PAYMENT_REFRESH_MESSAGE, requiresLocalPaymentRefresh, stripLocalEftposState } from "./localEftposState";
|
|
33
35
|
import { BaseModule } from "../BaseModule";
|
|
34
36
|
import { OrderHooks } from "./types";
|
|
35
37
|
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
38
|
import { isNormalProduct } from "../Product/utils";
|
|
37
39
|
import { getWeighedProductPriceFingerprint, resolveWeighedSourcePrice, withOriginalBundleOptionPrices } from "./utils/weighedProduct";
|
|
40
|
+
import { buildPickupTimingBooking, isFulfillmentTimingBooking } from "./pickupTiming";
|
|
38
41
|
import dayjs from 'dayjs';
|
|
39
42
|
import { getDiscountLifecycleReason } from "../Discount/availability";
|
|
40
43
|
import { stripOsPrivatePayloadFields } from "../../utils/os-private-payload";
|
|
@@ -53,7 +56,7 @@ import { RulesModule } from "../Rules";
|
|
|
53
56
|
import { isEntitlementPass, isFullCoveragePass } from "../Discount/entitlementPass";
|
|
54
57
|
import { UnavailableReason } from "../Rules/types";
|
|
55
58
|
import Decimal from 'decimal.js';
|
|
56
|
-
import { cloneDeep } from 'lodash-es';
|
|
59
|
+
import { cloneDeep, isEqual } from 'lodash-es';
|
|
57
60
|
function normalizeDiscountListSignature(discountList) {
|
|
58
61
|
return (discountList || []).map(function (item) {
|
|
59
62
|
var _item$type, _item$discount_id, _item$order_discount_;
|
|
@@ -520,6 +523,36 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
520
523
|
this.otherParams = otherParams;
|
|
521
524
|
}
|
|
522
525
|
|
|
526
|
+
/** Internal intent boundary shared with asynchronous scanner/detail flows. */
|
|
527
|
+
}, {
|
|
528
|
+
key: "createCartIntentCommitGuard",
|
|
529
|
+
value: function createCartIntentCommitGuard(action) {
|
|
530
|
+
var _this$orderHooks,
|
|
531
|
+
_this$orderHooks2,
|
|
532
|
+
_this2 = this;
|
|
533
|
+
var tempOrder = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.store.tempOrder;
|
|
534
|
+
var hook = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.beforeCartIntentCommit;
|
|
535
|
+
if (!hook) return function () {};
|
|
536
|
+
var getScope = (_this$orderHooks2 = this.orderHooks) === null || _this$orderHooks2 === void 0 ? void 0 : _this$orderHooks2.getCartIntentScope;
|
|
537
|
+
var scope = getScope === null || getScope === void 0 ? void 0 : getScope();
|
|
538
|
+
var otherParams = this.otherParams;
|
|
539
|
+
var committed = false;
|
|
540
|
+
return function () {
|
|
541
|
+
var _this2$orderHooks, _this2$orderHooks2;
|
|
542
|
+
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) {
|
|
543
|
+
throw new Error('[Order] Cart intent belongs to a previous order or business');
|
|
544
|
+
}
|
|
545
|
+
// Derived gifts, discounts and persistence belong to the accepted intent,
|
|
546
|
+
// but an asynchronous continuation must never target a different cart.
|
|
547
|
+
if (committed) return;
|
|
548
|
+
hook({
|
|
549
|
+
action: action,
|
|
550
|
+
tempOrder: tempOrder
|
|
551
|
+
});
|
|
552
|
+
committed = true;
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
|
|
523
556
|
/** PC/H5 属于在线店铺;其它或缺失平台统一沿用 POS 行为。 */
|
|
524
557
|
}, {
|
|
525
558
|
key: "isOnlineStorePlatform",
|
|
@@ -611,10 +644,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
611
644
|
}, {
|
|
612
645
|
key: "createDefaultRulesHooks",
|
|
613
646
|
value: function createDefaultRulesHooks() {
|
|
614
|
-
var
|
|
647
|
+
var _this3 = this;
|
|
615
648
|
return createDefaultOrderRulesHooks(function () {
|
|
616
|
-
var
|
|
617
|
-
return ((
|
|
649
|
+
var _this3$store$tempOrde;
|
|
650
|
+
return ((_this3$store$tempOrde = _this3.store.tempOrder) === null || _this3$store$tempOrde === void 0 ? void 0 : _this3$store$tempOrde.bookings) || [];
|
|
618
651
|
});
|
|
619
652
|
}
|
|
620
653
|
|
|
@@ -637,7 +670,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
637
670
|
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
638
671
|
var _this$store$tempOrder,
|
|
639
672
|
_this$store$discount,
|
|
640
|
-
|
|
673
|
+
_this4 = this,
|
|
641
674
|
_this$store$tempOrder2;
|
|
642
675
|
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
676
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
@@ -665,8 +698,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
665
698
|
case 5:
|
|
666
699
|
prepareConfigResult = _context3.sent;
|
|
667
700
|
isCurrentRequest = function isCurrentRequest() {
|
|
668
|
-
var
|
|
669
|
-
return requestEpoch ===
|
|
701
|
+
var _this4$store$tempOrde, _this4$store$tempOrde2;
|
|
702
|
+
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
703
|
};
|
|
671
704
|
if (isCurrentRequest()) {
|
|
672
705
|
_context3.next = 9;
|
|
@@ -898,12 +931,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
898
931
|
value: function () {
|
|
899
932
|
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(code, customerId) {
|
|
900
933
|
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;
|
|
934
|
+
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
935
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
903
936
|
while (1) switch (_context6.prev = _context6.next) {
|
|
904
937
|
case 0:
|
|
938
|
+
beforeCommit = this.createCartIntentCommitGuard('scan_promotion');
|
|
905
939
|
if (!this.isActiveVirtualSettlementOrder(this.store.tempOrder)) {
|
|
906
|
-
_context6.next =
|
|
940
|
+
_context6.next = 3;
|
|
907
941
|
break;
|
|
908
942
|
}
|
|
909
943
|
return _context6.abrupt("return", {
|
|
@@ -914,27 +948,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
914
948
|
scannedDiscountList: [],
|
|
915
949
|
unavailableReason: UnavailableReason.ProductNotApplicable
|
|
916
950
|
});
|
|
917
|
-
case
|
|
918
|
-
_context6.next =
|
|
951
|
+
case 3:
|
|
952
|
+
_context6.next = 5;
|
|
919
953
|
return (_this$store$discount11 = this.store.discount) === null || _this$store$discount11 === void 0 ? void 0 : _this$store$discount11.batchSearch(code, {
|
|
920
954
|
customerId: customerId
|
|
921
955
|
});
|
|
922
|
-
case
|
|
956
|
+
case 5:
|
|
923
957
|
_context6.t0 = _context6.sent;
|
|
924
958
|
if (_context6.t0) {
|
|
925
|
-
_context6.next =
|
|
959
|
+
_context6.next = 8;
|
|
926
960
|
break;
|
|
927
961
|
}
|
|
928
962
|
_context6.t0 = {
|
|
929
963
|
discountList: [],
|
|
930
964
|
unavailableReasonKey: null
|
|
931
965
|
};
|
|
932
|
-
case
|
|
966
|
+
case 8:
|
|
933
967
|
resultDiscountWithReason = _context6.t0;
|
|
934
968
|
resultDiscountList = resultDiscountWithReason.discountList, unavailableReasonKey = resultDiscountWithReason.unavailableReasonKey;
|
|
935
969
|
rulesModule = this.store.rules;
|
|
936
970
|
if (rulesModule) {
|
|
937
|
-
_context6.next =
|
|
971
|
+
_context6.next = 13;
|
|
938
972
|
break;
|
|
939
973
|
}
|
|
940
974
|
return _context6.abrupt("return", {
|
|
@@ -945,9 +979,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
945
979
|
scannedDiscountList: resultDiscountList,
|
|
946
980
|
unavailableReason: UnavailableReason.Unknown
|
|
947
981
|
});
|
|
948
|
-
case
|
|
982
|
+
case 13:
|
|
949
983
|
if (resultDiscountList.length) {
|
|
950
|
-
_context6.next =
|
|
984
|
+
_context6.next = 15;
|
|
951
985
|
break;
|
|
952
986
|
}
|
|
953
987
|
return _context6.abrupt("return", {
|
|
@@ -958,7 +992,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
958
992
|
scannedDiscountList: resultDiscountList,
|
|
959
993
|
unavailableReasonKey: unavailableReasonKey
|
|
960
994
|
});
|
|
961
|
-
case
|
|
995
|
+
case 15:
|
|
962
996
|
withScanList = resultDiscountList.map(function (item) {
|
|
963
997
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
964
998
|
isScan: true
|
|
@@ -972,12 +1006,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
972
1006
|
return m.id === n.id;
|
|
973
1007
|
});
|
|
974
1008
|
}))) {
|
|
975
|
-
_context6.next =
|
|
1009
|
+
_context6.next = 22;
|
|
976
1010
|
break;
|
|
977
1011
|
}
|
|
978
|
-
|
|
1012
|
+
beforeCommit();
|
|
1013
|
+
_context6.next = 21;
|
|
979
1014
|
return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
980
|
-
case
|
|
1015
|
+
case 21:
|
|
981
1016
|
return _context6.abrupt("return", {
|
|
982
1017
|
type: 'clientCalc',
|
|
983
1018
|
isAvailable: true,
|
|
@@ -985,7 +1020,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
985
1020
|
discountList: this.getDiscountList(),
|
|
986
1021
|
scannedDiscountList: resultDiscountList
|
|
987
1022
|
});
|
|
988
|
-
case
|
|
1023
|
+
case 22:
|
|
989
1024
|
tempOrder = this.store.tempOrder;
|
|
990
1025
|
holders = (tempOrder === null || tempOrder === void 0 || (_tempOrder$holder = tempOrder.holder) === null || _tempOrder$holder === void 0 ? void 0 : _tempOrder$holder.form_record) || [];
|
|
991
1026
|
_ref16 = rulesModule.isDiscountListAvailable({
|
|
@@ -1011,12 +1046,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1011
1046
|
normalizedNewDiscountList = newDiscountList ? markScannedDiscounts(newDiscountList, withScanList) : undefined;
|
|
1012
1047
|
resolvedDiscountList = normalizedNewDiscountList || this.getDiscountList();
|
|
1013
1048
|
if (!(isAvailable && normalizedNewDiscountList)) {
|
|
1014
|
-
_context6.next =
|
|
1049
|
+
_context6.next = 40;
|
|
1015
1050
|
break;
|
|
1016
1051
|
}
|
|
1017
|
-
|
|
1052
|
+
beforeCommit();
|
|
1053
|
+
_context6.next = 34;
|
|
1018
1054
|
return (_this$store$discount12 = this.store.discount) === null || _this$store$discount12 === void 0 ? void 0 : _this$store$discount12.setDiscountList(normalizedNewDiscountList);
|
|
1019
|
-
case
|
|
1055
|
+
case 34:
|
|
1020
1056
|
// 实际写回商品时沿用扫码试算的优先级,避免旧商品行的选卡覆盖本次扫码。
|
|
1021
1057
|
this.applyDiscount({
|
|
1022
1058
|
preferredEntitlementPassIds: withScanList.filter(function (discount) {
|
|
@@ -1025,17 +1061,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1025
1061
|
return discount.id;
|
|
1026
1062
|
})
|
|
1027
1063
|
});
|
|
1028
|
-
_context6.next =
|
|
1064
|
+
_context6.next = 37;
|
|
1029
1065
|
return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
1030
|
-
case
|
|
1066
|
+
case 37:
|
|
1031
1067
|
resolvedDiscountList = this.getDiscountList();
|
|
1032
|
-
_context6.next =
|
|
1068
|
+
_context6.next = 49;
|
|
1033
1069
|
break;
|
|
1034
|
-
case
|
|
1070
|
+
case 40:
|
|
1035
1071
|
if (!shouldRetainForLater) {
|
|
1036
|
-
_context6.next =
|
|
1072
|
+
_context6.next = 49;
|
|
1037
1073
|
break;
|
|
1038
1074
|
}
|
|
1075
|
+
beforeCommit();
|
|
1039
1076
|
// 只合并本次识别的卡券;不把试算产生的其他选券状态写回订单。
|
|
1040
1077
|
retainedDiscounts = new Map(this.getDiscountList().map(function (discount) {
|
|
1041
1078
|
return [String(discount.id), discount];
|
|
@@ -1050,14 +1087,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1050
1087
|
savedAmount: 0
|
|
1051
1088
|
}));
|
|
1052
1089
|
});
|
|
1053
|
-
_context6.next =
|
|
1090
|
+
_context6.next = 46;
|
|
1054
1091
|
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 =
|
|
1092
|
+
case 46:
|
|
1093
|
+
_context6.next = 48;
|
|
1057
1094
|
return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
1058
|
-
case
|
|
1095
|
+
case 48:
|
|
1059
1096
|
resolvedDiscountList = this.getDiscountList();
|
|
1060
|
-
case
|
|
1097
|
+
case 49:
|
|
1061
1098
|
return _context6.abrupt("return", {
|
|
1062
1099
|
type: 'clientCalc',
|
|
1063
1100
|
isAvailable: isAvailable || false,
|
|
@@ -1066,7 +1103,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1066
1103
|
scannedDiscountList: evaluatedScannedDiscounts,
|
|
1067
1104
|
unavailableReason: unavailableReason
|
|
1068
1105
|
});
|
|
1069
|
-
case
|
|
1106
|
+
case 50:
|
|
1070
1107
|
case "end":
|
|
1071
1108
|
return _context6.stop();
|
|
1072
1109
|
}
|
|
@@ -1082,7 +1119,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1082
1119
|
value: function applyDiscount(options) {
|
|
1083
1120
|
var _this$store$discount16,
|
|
1084
1121
|
_this$store$summary2,
|
|
1085
|
-
|
|
1122
|
+
_this5 = this;
|
|
1086
1123
|
var tempOrder = this.store.tempOrder;
|
|
1087
1124
|
// 任意 products CRUD 后都应当重算 discount 状态;即使 products 为空,
|
|
1088
1125
|
// 也需要让 Rules.calcDiscount 把 DiscountModule 的 isSelected / isAvailable /
|
|
@@ -1140,7 +1177,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1140
1177
|
(_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 || _this$store$discount17.setDiscountList(result.discountList);
|
|
1141
1178
|
}
|
|
1142
1179
|
this.hasActiveCustomerBoundDiscount = (tempOrder.products || []).some(function (product) {
|
|
1143
|
-
return
|
|
1180
|
+
return _this5.productHasCustomerBoundDiscount(product);
|
|
1144
1181
|
});
|
|
1145
1182
|
}
|
|
1146
1183
|
|
|
@@ -1200,49 +1237,55 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1200
1237
|
}, {
|
|
1201
1238
|
key: "evaluatePromotion",
|
|
1202
1239
|
value: (function () {
|
|
1203
|
-
var _evaluatePromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
1240
|
+
var _evaluatePromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(options) {
|
|
1204
1241
|
var _this$promotionEvalua,
|
|
1205
1242
|
_this$promotionEvalua2,
|
|
1206
|
-
|
|
1207
|
-
var tempOrder, strategyConfigs, result, removeSet, _iterator3, _step3, reduce, _iterator6, _step6, _loop2, _iterator4, _step4, _loop, payload;
|
|
1243
|
+
_this6 = this;
|
|
1244
|
+
var tempOrder, strategyConfigs, result, removeSet, _iterator3, _step3, reduce, _iterator6, _step6, _loop2, _iterator4, _step4, _loop, _ret, payload;
|
|
1208
1245
|
return _regeneratorRuntime().wrap(function _callee7$(_context9) {
|
|
1209
1246
|
while (1) switch (_context9.prev = _context9.next) {
|
|
1210
1247
|
case 0:
|
|
1211
|
-
if (!(
|
|
1248
|
+
if (!(options !== null && options !== void 0 && options.isCurrentOrder && !options.isCurrentOrder())) {
|
|
1212
1249
|
_context9.next = 2;
|
|
1213
1250
|
break;
|
|
1214
1251
|
}
|
|
1215
1252
|
return _context9.abrupt("return", null);
|
|
1216
1253
|
case 2:
|
|
1217
|
-
if (this.
|
|
1254
|
+
if (!(this.isApplyingPromotion || this.isEmittingPromotionApplied)) {
|
|
1218
1255
|
_context9.next = 4;
|
|
1219
1256
|
break;
|
|
1220
1257
|
}
|
|
1221
1258
|
return _context9.abrupt("return", null);
|
|
1222
1259
|
case 4:
|
|
1260
|
+
if (this.promotionEvaluator) {
|
|
1261
|
+
_context9.next = 6;
|
|
1262
|
+
break;
|
|
1263
|
+
}
|
|
1264
|
+
return _context9.abrupt("return", null);
|
|
1265
|
+
case 6:
|
|
1223
1266
|
tempOrder = this.store.tempOrder;
|
|
1224
1267
|
if (tempOrder) {
|
|
1225
|
-
_context9.next =
|
|
1268
|
+
_context9.next = 9;
|
|
1226
1269
|
break;
|
|
1227
1270
|
}
|
|
1228
1271
|
return _context9.abrupt("return", null);
|
|
1229
|
-
case
|
|
1272
|
+
case 9:
|
|
1230
1273
|
if (!this.isActiveVirtualSettlementOrder(tempOrder)) {
|
|
1231
|
-
_context9.next =
|
|
1274
|
+
_context9.next = 12;
|
|
1232
1275
|
break;
|
|
1233
1276
|
}
|
|
1234
1277
|
tempOrder.products = normalizeVirtualSettlementProducts(tempOrder.products);
|
|
1235
1278
|
return _context9.abrupt("return", null);
|
|
1236
|
-
case
|
|
1279
|
+
case 12:
|
|
1237
1280
|
strategyConfigs = (_this$promotionEvalua = (_this$promotionEvalua2 = this.promotionEvaluator).getStrategyConfigs) === null || _this$promotionEvalua === void 0 ? void 0 : _this$promotionEvalua.call(_this$promotionEvalua2);
|
|
1238
1281
|
if (!(Array.isArray(strategyConfigs) && strategyConfigs.length === 0)) {
|
|
1239
|
-
_context9.next =
|
|
1282
|
+
_context9.next = 15;
|
|
1240
1283
|
break;
|
|
1241
1284
|
}
|
|
1242
1285
|
return _context9.abrupt("return", null);
|
|
1243
|
-
case
|
|
1286
|
+
case 15:
|
|
1244
1287
|
this.isApplyingPromotion = true;
|
|
1245
|
-
_context9.prev =
|
|
1288
|
+
_context9.prev = 16;
|
|
1246
1289
|
result = processCartPromotion(tempOrder.products, this.promotionEvaluator); // step 1: toRemove —— 直接过滤
|
|
1247
1290
|
if (result.giftActions.toRemove.length > 0) {
|
|
1248
1291
|
removeSet = new Set(result.giftActions.toRemove.map(String));
|
|
@@ -1254,16 +1297,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1254
1297
|
|
|
1255
1298
|
// step 2: toReduce —— 调整数量
|
|
1256
1299
|
_iterator3 = _createForOfIteratorHelper(result.giftActions.toReduce);
|
|
1257
|
-
_context9.prev =
|
|
1300
|
+
_context9.prev = 20;
|
|
1258
1301
|
_iterator3.s();
|
|
1259
|
-
case
|
|
1302
|
+
case 22:
|
|
1260
1303
|
if ((_step3 = _iterator3.n()).done) {
|
|
1261
|
-
_context9.next =
|
|
1304
|
+
_context9.next = 42;
|
|
1262
1305
|
break;
|
|
1263
1306
|
}
|
|
1264
1307
|
reduce = _step3.value;
|
|
1265
1308
|
_iterator6 = _createForOfIteratorHelper(reduce.items);
|
|
1266
|
-
_context9.prev =
|
|
1309
|
+
_context9.prev = 25;
|
|
1267
1310
|
_loop2 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop2() {
|
|
1268
1311
|
var item, product;
|
|
1269
1312
|
return _regeneratorRuntime().wrap(function _loop2$(_context8) {
|
|
@@ -1283,47 +1326,47 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1283
1326
|
}, _loop2);
|
|
1284
1327
|
});
|
|
1285
1328
|
_iterator6.s();
|
|
1286
|
-
case
|
|
1329
|
+
case 28:
|
|
1287
1330
|
if ((_step6 = _iterator6.n()).done) {
|
|
1288
|
-
_context9.next =
|
|
1331
|
+
_context9.next = 32;
|
|
1289
1332
|
break;
|
|
1290
1333
|
}
|
|
1291
|
-
return _context9.delegateYield(_loop2(), "t0",
|
|
1292
|
-
case 28:
|
|
1293
|
-
_context9.next = 26;
|
|
1294
|
-
break;
|
|
1334
|
+
return _context9.delegateYield(_loop2(), "t0", 30);
|
|
1295
1335
|
case 30:
|
|
1296
|
-
_context9.next =
|
|
1336
|
+
_context9.next = 28;
|
|
1297
1337
|
break;
|
|
1298
1338
|
case 32:
|
|
1299
|
-
_context9.
|
|
1300
|
-
|
|
1339
|
+
_context9.next = 37;
|
|
1340
|
+
break;
|
|
1341
|
+
case 34:
|
|
1342
|
+
_context9.prev = 34;
|
|
1343
|
+
_context9.t1 = _context9["catch"](25);
|
|
1301
1344
|
_iterator6.e(_context9.t1);
|
|
1302
|
-
case
|
|
1303
|
-
_context9.prev =
|
|
1345
|
+
case 37:
|
|
1346
|
+
_context9.prev = 37;
|
|
1304
1347
|
_iterator6.f();
|
|
1305
|
-
return _context9.finish(
|
|
1306
|
-
case 38:
|
|
1307
|
-
_context9.next = 20;
|
|
1308
|
-
break;
|
|
1348
|
+
return _context9.finish(37);
|
|
1309
1349
|
case 40:
|
|
1310
|
-
_context9.next =
|
|
1350
|
+
_context9.next = 22;
|
|
1311
1351
|
break;
|
|
1312
1352
|
case 42:
|
|
1313
|
-
_context9.
|
|
1314
|
-
|
|
1353
|
+
_context9.next = 47;
|
|
1354
|
+
break;
|
|
1355
|
+
case 44:
|
|
1356
|
+
_context9.prev = 44;
|
|
1357
|
+
_context9.t2 = _context9["catch"](20);
|
|
1315
1358
|
_iterator3.e(_context9.t2);
|
|
1316
|
-
case
|
|
1317
|
-
_context9.prev =
|
|
1359
|
+
case 47:
|
|
1360
|
+
_context9.prev = 47;
|
|
1318
1361
|
_iterator3.f();
|
|
1319
|
-
return _context9.finish(
|
|
1320
|
-
case
|
|
1362
|
+
return _context9.finish(47);
|
|
1363
|
+
case 50:
|
|
1321
1364
|
if (!(result.giftActions.toAdd.length > 0)) {
|
|
1322
|
-
_context9.next =
|
|
1365
|
+
_context9.next = 76;
|
|
1323
1366
|
break;
|
|
1324
1367
|
}
|
|
1325
1368
|
if (this.giftSelectResolver) {
|
|
1326
|
-
_context9.next =
|
|
1369
|
+
_context9.next = 55;
|
|
1327
1370
|
break;
|
|
1328
1371
|
}
|
|
1329
1372
|
if (result.giftActions.toAdd.some(function (g) {
|
|
@@ -1334,13 +1377,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1334
1377
|
} else {
|
|
1335
1378
|
console.warn('[OrderModule] giftSelectResolver not set, skip applying single-option gifts', result.giftActions.toAdd);
|
|
1336
1379
|
}
|
|
1337
|
-
_context9.next =
|
|
1380
|
+
_context9.next = 76;
|
|
1338
1381
|
break;
|
|
1339
|
-
case
|
|
1382
|
+
case 55:
|
|
1340
1383
|
_iterator4 = _createForOfIteratorHelper(result.giftActions.toAdd);
|
|
1341
|
-
_context9.prev =
|
|
1384
|
+
_context9.prev = 56;
|
|
1342
1385
|
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
1343
|
-
var addAction, _sameStrategy$metadat, sameStrategy, giftResult, giftProducts, giftBookings, _iterator5, _step5, _step5$value, index, gp, booking, linked;
|
|
1386
|
+
var addAction, _sameStrategy$metadat, sameStrategy, giftMutationBaseline, giftResult, giftProducts, giftBookings, _iterator5, _step5, _step5$value, index, gp, booking, linked;
|
|
1344
1387
|
return _regeneratorRuntime().wrap(function _loop$(_context7) {
|
|
1345
1388
|
while (1) switch (_context7.prev = _context7.next) {
|
|
1346
1389
|
case 0:
|
|
@@ -1358,111 +1401,166 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1358
1401
|
break;
|
|
1359
1402
|
}
|
|
1360
1403
|
sameStrategy.num = (Number(sameStrategy.num) || 0) + (addAction.giftCount || 1);
|
|
1361
|
-
return _context7.abrupt("return",
|
|
1404
|
+
return _context7.abrupt("return", 0);
|
|
1362
1405
|
case 6:
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1406
|
+
giftMutationBaseline = options !== null && options !== void 0 && options.isCurrentOrder ? cloneDeep({
|
|
1407
|
+
products: tempOrder.products,
|
|
1408
|
+
bookings: tempOrder.bookings
|
|
1409
|
+
}) : null;
|
|
1410
|
+
_context7.prev = 7;
|
|
1411
|
+
_context7.next = 10;
|
|
1412
|
+
return _this6.giftSelectResolver({
|
|
1366
1413
|
strategyId: addAction.strategyId,
|
|
1367
1414
|
strategyName: addAction.strategyName,
|
|
1368
1415
|
giftCount: addAction.giftCount,
|
|
1369
1416
|
giftOptions: addAction.giftOptions,
|
|
1370
1417
|
sourceProductIds: addAction.sourceProductIds
|
|
1371
1418
|
});
|
|
1372
|
-
case
|
|
1419
|
+
case 10:
|
|
1373
1420
|
giftResult = _context7.sent;
|
|
1421
|
+
if (!(options !== null && options !== void 0 && options.isCurrentOrder && !options.isCurrentOrder())) {
|
|
1422
|
+
_context7.next = 13;
|
|
1423
|
+
break;
|
|
1424
|
+
}
|
|
1425
|
+
return _context7.abrupt("return", {
|
|
1426
|
+
v: null
|
|
1427
|
+
});
|
|
1428
|
+
case 13:
|
|
1429
|
+
if (!(options !== null && options !== void 0 && options.isCurrentOrder && !isEqual({
|
|
1430
|
+
products: tempOrder.products,
|
|
1431
|
+
bookings: tempOrder.bookings
|
|
1432
|
+
}, giftMutationBaseline))) {
|
|
1433
|
+
_context7.next = 15;
|
|
1434
|
+
break;
|
|
1435
|
+
}
|
|
1436
|
+
return _context7.abrupt("return", {
|
|
1437
|
+
v: null
|
|
1438
|
+
});
|
|
1439
|
+
case 15:
|
|
1374
1440
|
giftProducts = Array.isArray(giftResult) ? giftResult : giftResult === null || giftResult === void 0 ? void 0 : giftResult.products;
|
|
1375
1441
|
giftBookings = Array.isArray(giftResult) ? [] : (giftResult === null || giftResult === void 0 ? void 0 : giftResult.bookings) || [];
|
|
1376
1442
|
if (!(Array.isArray(giftProducts) && giftProducts.length > 0)) {
|
|
1377
|
-
_context7.next =
|
|
1443
|
+
_context7.next = 42;
|
|
1378
1444
|
break;
|
|
1379
1445
|
}
|
|
1380
1446
|
_iterator5 = _createForOfIteratorHelper(giftProducts.entries());
|
|
1381
|
-
_context7.prev =
|
|
1447
|
+
_context7.prev = 19;
|
|
1382
1448
|
_iterator5.s();
|
|
1383
|
-
case
|
|
1449
|
+
case 21:
|
|
1384
1450
|
if ((_step5 = _iterator5.n()).done) {
|
|
1385
|
-
_context7.next =
|
|
1451
|
+
_context7.next = 34;
|
|
1386
1452
|
break;
|
|
1387
1453
|
}
|
|
1388
1454
|
_step5$value = _slicedToArray(_step5.value, 2), index = _step5$value[0], gp = _step5$value[1];
|
|
1389
1455
|
if (gp) {
|
|
1390
|
-
_context7.next =
|
|
1456
|
+
_context7.next = 25;
|
|
1391
1457
|
break;
|
|
1392
1458
|
}
|
|
1393
|
-
return _context7.abrupt("continue",
|
|
1394
|
-
case
|
|
1459
|
+
return _context7.abrupt("continue", 32);
|
|
1460
|
+
case 25:
|
|
1395
1461
|
booking = giftBookings[index];
|
|
1396
1462
|
if (!booking) {
|
|
1397
|
-
_context7.next =
|
|
1463
|
+
_context7.next = 31;
|
|
1398
1464
|
break;
|
|
1399
1465
|
}
|
|
1400
|
-
linked =
|
|
1466
|
+
linked = _this6.createLinkedProductAndBooking({
|
|
1401
1467
|
product: gp,
|
|
1402
1468
|
booking: booking
|
|
1403
1469
|
});
|
|
1404
1470
|
result.products.push(linked.product);
|
|
1405
1471
|
tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
|
|
1406
|
-
return _context7.abrupt("continue",
|
|
1407
|
-
case
|
|
1472
|
+
return _context7.abrupt("continue", 32);
|
|
1473
|
+
case 31:
|
|
1408
1474
|
// normalize 略过:调用方应保证返回完整 OrderProduct。
|
|
1409
1475
|
result.products.push(gp);
|
|
1410
|
-
case
|
|
1411
|
-
_context7.next =
|
|
1412
|
-
break;
|
|
1413
|
-
case 29:
|
|
1414
|
-
_context7.next = 34;
|
|
1476
|
+
case 32:
|
|
1477
|
+
_context7.next = 21;
|
|
1415
1478
|
break;
|
|
1416
|
-
case 31:
|
|
1417
|
-
_context7.prev = 31;
|
|
1418
|
-
_context7.t0 = _context7["catch"](14);
|
|
1419
|
-
_iterator5.e(_context7.t0);
|
|
1420
1479
|
case 34:
|
|
1421
|
-
_context7.
|
|
1422
|
-
_iterator5.f();
|
|
1423
|
-
return _context7.finish(34);
|
|
1424
|
-
case 37:
|
|
1425
|
-
_context7.next = 42;
|
|
1480
|
+
_context7.next = 39;
|
|
1426
1481
|
break;
|
|
1482
|
+
case 36:
|
|
1483
|
+
_context7.prev = 36;
|
|
1484
|
+
_context7.t0 = _context7["catch"](19);
|
|
1485
|
+
_iterator5.e(_context7.t0);
|
|
1427
1486
|
case 39:
|
|
1428
1487
|
_context7.prev = 39;
|
|
1429
|
-
|
|
1488
|
+
_iterator5.f();
|
|
1489
|
+
return _context7.finish(39);
|
|
1490
|
+
case 42:
|
|
1491
|
+
_context7.next = 51;
|
|
1492
|
+
break;
|
|
1493
|
+
case 44:
|
|
1494
|
+
_context7.prev = 44;
|
|
1495
|
+
_context7.t1 = _context7["catch"](7);
|
|
1496
|
+
if (!(options !== null && options !== void 0 && options.isCurrentOrder && !options.isCurrentOrder())) {
|
|
1497
|
+
_context7.next = 48;
|
|
1498
|
+
break;
|
|
1499
|
+
}
|
|
1500
|
+
return _context7.abrupt("return", {
|
|
1501
|
+
v: null
|
|
1502
|
+
});
|
|
1503
|
+
case 48:
|
|
1504
|
+
if (!(options !== null && options !== void 0 && options.isCurrentOrder && !isEqual({
|
|
1505
|
+
products: tempOrder.products,
|
|
1506
|
+
bookings: tempOrder.bookings
|
|
1507
|
+
}, giftMutationBaseline))) {
|
|
1508
|
+
_context7.next = 50;
|
|
1509
|
+
break;
|
|
1510
|
+
}
|
|
1511
|
+
return _context7.abrupt("return", {
|
|
1512
|
+
v: null
|
|
1513
|
+
});
|
|
1514
|
+
case 50:
|
|
1430
1515
|
// 用户取消 / 选择失败 → 视为放弃本次新增
|
|
1431
1516
|
console.warn('[OrderModule] giftSelectResolver rejected, skip add gift', addAction.strategyId, _context7.t1);
|
|
1432
|
-
case
|
|
1517
|
+
case 51:
|
|
1433
1518
|
case "end":
|
|
1434
1519
|
return _context7.stop();
|
|
1435
1520
|
}
|
|
1436
|
-
}, _loop, null, [[
|
|
1521
|
+
}, _loop, null, [[7, 44], [19, 36, 39, 42]]);
|
|
1437
1522
|
});
|
|
1438
1523
|
_iterator4.s();
|
|
1439
|
-
case
|
|
1524
|
+
case 59:
|
|
1440
1525
|
if ((_step4 = _iterator4.n()).done) {
|
|
1441
|
-
_context9.next =
|
|
1526
|
+
_context9.next = 68;
|
|
1442
1527
|
break;
|
|
1443
1528
|
}
|
|
1444
|
-
return _context9.delegateYield(_loop(), "t3",
|
|
1445
|
-
case
|
|
1446
|
-
|
|
1447
|
-
|
|
1529
|
+
return _context9.delegateYield(_loop(), "t3", 61);
|
|
1530
|
+
case 61:
|
|
1531
|
+
_ret = _context9.t3;
|
|
1532
|
+
if (!(_ret === 0)) {
|
|
1533
|
+
_context9.next = 64;
|
|
1448
1534
|
break;
|
|
1449
1535
|
}
|
|
1450
|
-
return _context9.abrupt("continue",
|
|
1451
|
-
case
|
|
1452
|
-
|
|
1536
|
+
return _context9.abrupt("continue", 66);
|
|
1537
|
+
case 64:
|
|
1538
|
+
if (!_ret) {
|
|
1539
|
+
_context9.next = 66;
|
|
1540
|
+
break;
|
|
1541
|
+
}
|
|
1542
|
+
return _context9.abrupt("return", _ret.v);
|
|
1543
|
+
case 66:
|
|
1544
|
+
_context9.next = 59;
|
|
1453
1545
|
break;
|
|
1454
|
-
case
|
|
1455
|
-
_context9.next =
|
|
1546
|
+
case 68:
|
|
1547
|
+
_context9.next = 73;
|
|
1456
1548
|
break;
|
|
1457
|
-
case
|
|
1458
|
-
_context9.prev =
|
|
1459
|
-
_context9.t4 = _context9["catch"](
|
|
1549
|
+
case 70:
|
|
1550
|
+
_context9.prev = 70;
|
|
1551
|
+
_context9.t4 = _context9["catch"](56);
|
|
1460
1552
|
_iterator4.e(_context9.t4);
|
|
1461
|
-
case
|
|
1462
|
-
_context9.prev =
|
|
1553
|
+
case 73:
|
|
1554
|
+
_context9.prev = 73;
|
|
1463
1555
|
_iterator4.f();
|
|
1464
|
-
return _context9.finish(
|
|
1465
|
-
case
|
|
1556
|
+
return _context9.finish(73);
|
|
1557
|
+
case 76:
|
|
1558
|
+
if (!(options !== null && options !== void 0 && options.isCurrentOrder && !options.isCurrentOrder())) {
|
|
1559
|
+
_context9.next = 78;
|
|
1560
|
+
break;
|
|
1561
|
+
}
|
|
1562
|
+
return _context9.abrupt("return", null);
|
|
1563
|
+
case 78:
|
|
1466
1564
|
tempOrder.products = result.products;
|
|
1467
1565
|
this.lastUnfulfilledPromotions = result.unfulfilledPromotions;
|
|
1468
1566
|
this.lastGiftActions = result.giftActions;
|
|
@@ -1480,22 +1578,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1480
1578
|
products: tempOrder.products
|
|
1481
1579
|
};
|
|
1482
1580
|
return _context9.abrupt("return", payload);
|
|
1483
|
-
case
|
|
1484
|
-
_context9.prev =
|
|
1485
|
-
_context9.t5 = _context9["catch"](
|
|
1581
|
+
case 85:
|
|
1582
|
+
_context9.prev = 85;
|
|
1583
|
+
_context9.t5 = _context9["catch"](16);
|
|
1486
1584
|
console.error('[OrderModule] applyPromotion failed', _context9.t5);
|
|
1487
1585
|
return _context9.abrupt("return", null);
|
|
1488
|
-
case
|
|
1489
|
-
_context9.prev =
|
|
1586
|
+
case 89:
|
|
1587
|
+
_context9.prev = 89;
|
|
1490
1588
|
this.isApplyingPromotion = false;
|
|
1491
|
-
return _context9.finish(
|
|
1492
|
-
case
|
|
1589
|
+
return _context9.finish(89);
|
|
1590
|
+
case 92:
|
|
1493
1591
|
case "end":
|
|
1494
1592
|
return _context9.stop();
|
|
1495
1593
|
}
|
|
1496
|
-
}, _callee7, this, [[
|
|
1594
|
+
}, _callee7, this, [[16, 85, 89, 92], [20, 44, 47, 50], [25, 34, 37, 40], [56, 70, 73, 76]]);
|
|
1497
1595
|
}));
|
|
1498
|
-
function evaluatePromotion() {
|
|
1596
|
+
function evaluatePromotion(_x8) {
|
|
1499
1597
|
return _evaluatePromotion.apply(this, arguments);
|
|
1500
1598
|
}
|
|
1501
1599
|
return evaluatePromotion;
|
|
@@ -1727,12 +1825,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1727
1825
|
}, {
|
|
1728
1826
|
key: "rememberPointCardSnapshotCodeCandidates",
|
|
1729
1827
|
value: function rememberPointCardSnapshotCodeCandidates(value) {
|
|
1730
|
-
var
|
|
1828
|
+
var _this7 = this;
|
|
1731
1829
|
collectPointCardSnapshotCodeCandidates(value).forEach(function (_ref18) {
|
|
1732
1830
|
var id = _ref18.id,
|
|
1733
1831
|
code = _ref18.code;
|
|
1734
|
-
if (!
|
|
1735
|
-
|
|
1832
|
+
if (!_this7.pointCardSnapshotCodeCandidates.has(id)) {
|
|
1833
|
+
_this7.pointCardSnapshotCodeCandidates.set(id, code);
|
|
1736
1834
|
}
|
|
1737
1835
|
});
|
|
1738
1836
|
}
|
|
@@ -1913,7 +2011,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1913
2011
|
}
|
|
1914
2012
|
}, _callee10, this);
|
|
1915
2013
|
}));
|
|
1916
|
-
function hydrateTempOrderFromLocalRecord(
|
|
2014
|
+
function hydrateTempOrderFromLocalRecord(_x9) {
|
|
1917
2015
|
return _hydrateTempOrderFromLocalRecord.apply(this, arguments);
|
|
1918
2016
|
}
|
|
1919
2017
|
return hydrateTempOrderFromLocalRecord;
|
|
@@ -1939,23 +2037,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1939
2037
|
}, {
|
|
1940
2038
|
key: "calculatePaymentTotal",
|
|
1941
2039
|
value: function calculatePaymentTotal(payments) {
|
|
1942
|
-
var
|
|
2040
|
+
var _this8 = this;
|
|
1943
2041
|
return mapPaymentItemsToOrderPayments(payments, {
|
|
1944
2042
|
includeVoided: false
|
|
1945
2043
|
}).reduce(function (sum, payment) {
|
|
1946
2044
|
if (!isPaidPaymentRecord(payment)) return sum;
|
|
1947
|
-
return sum.plus(
|
|
2045
|
+
return sum.plus(_this8.calculatePaymentEffectiveAmount(payment));
|
|
1948
2046
|
}, new Decimal(0));
|
|
1949
2047
|
}
|
|
1950
2048
|
}, {
|
|
1951
2049
|
key: "calculateOrderPaidPaymentTotal",
|
|
1952
2050
|
value: function calculateOrderPaidPaymentTotal(payments) {
|
|
1953
|
-
var
|
|
2051
|
+
var _this9 = this;
|
|
1954
2052
|
return mapPaymentItemsToOrderPayments(payments, {
|
|
1955
2053
|
includeVoided: false
|
|
1956
2054
|
}).reduce(function (sum, payment) {
|
|
1957
2055
|
if (!isPaidPaymentRecord(payment)) return sum;
|
|
1958
|
-
return sum.plus(
|
|
2056
|
+
return sum.plus(_this9.calculatePaymentGapAmount(payment));
|
|
1959
2057
|
}, new Decimal(0));
|
|
1960
2058
|
}
|
|
1961
2059
|
}, {
|
|
@@ -2091,13 +2189,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2091
2189
|
}, {
|
|
2092
2190
|
key: "calculateDepositPaidAmount",
|
|
2093
2191
|
value: function calculateDepositPaidAmount(payments) {
|
|
2094
|
-
var
|
|
2192
|
+
var _this10 = this;
|
|
2095
2193
|
return (payments || []).reduce(function (sum, payment) {
|
|
2096
2194
|
var paymentRecord = payment;
|
|
2097
2195
|
if (!isPaidPaymentRecord(paymentRecord)) return sum;
|
|
2098
2196
|
var isDepositPayment = paymentRecord.type === 'deposit' || paymentRecord.order_payment_type === 'deposit';
|
|
2099
2197
|
if (!isDepositPayment) return sum;
|
|
2100
|
-
return sum.plus(
|
|
2198
|
+
return sum.plus(_this10.calculatePaymentGapAmount(paymentRecord));
|
|
2101
2199
|
}, new Decimal(0));
|
|
2102
2200
|
}
|
|
2103
2201
|
}, {
|
|
@@ -2134,17 +2232,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2134
2232
|
}, {
|
|
2135
2233
|
key: "getPaymentNumberDevicePrefixSync",
|
|
2136
2234
|
value: function getPaymentNumberDevicePrefixSync() {
|
|
2137
|
-
var
|
|
2235
|
+
var _this11 = this;
|
|
2138
2236
|
return resolvePaymentNumberDevicePrefixFromDeviceId(function (key) {
|
|
2139
|
-
return
|
|
2237
|
+
return _this11.getPaymentNumberAppData(key);
|
|
2140
2238
|
});
|
|
2141
2239
|
}
|
|
2142
2240
|
}, {
|
|
2143
2241
|
key: "getPaymentNumberDevicePrefixAsync",
|
|
2144
2242
|
value: function getPaymentNumberDevicePrefixAsync() {
|
|
2145
|
-
var
|
|
2243
|
+
var _this12 = this;
|
|
2146
2244
|
return resolvePaymentNumberDevicePrefix(function (key) {
|
|
2147
|
-
return
|
|
2245
|
+
return _this12.getPaymentNumberAppData(key);
|
|
2148
2246
|
});
|
|
2149
2247
|
}
|
|
2150
2248
|
}, {
|
|
@@ -2274,16 +2372,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2274
2372
|
}, {
|
|
2275
2373
|
key: "calculatePaidPaymentSummary",
|
|
2276
2374
|
value: function calculatePaidPaymentSummary(payments) {
|
|
2277
|
-
var
|
|
2375
|
+
var _this13 = this;
|
|
2278
2376
|
return (payments || []).reduce(function (summary, payment) {
|
|
2279
2377
|
var paymentRecord = payment;
|
|
2280
2378
|
if (!isPaidPaymentRecord(paymentRecord)) return summary;
|
|
2281
2379
|
return {
|
|
2282
2380
|
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(
|
|
2381
|
+
orderPaidAmount: summary.orderPaidAmount.plus(_this13.calculatePaymentOrderAmount(paymentRecord)),
|
|
2382
|
+
gapPaidAmount: summary.gapPaidAmount.plus(_this13.calculatePaymentGapAmount(paymentRecord)),
|
|
2383
|
+
payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this13.calculatePaymentServiceFee(paymentRecord)),
|
|
2384
|
+
roundingAmount: summary.roundingAmount.plus(_this13.calculatePaymentRoundingAmount(paymentRecord))
|
|
2287
2385
|
};
|
|
2288
2386
|
}, {
|
|
2289
2387
|
customerPaidAmount: new Decimal(0),
|
|
@@ -2490,15 +2588,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2490
2588
|
}, {
|
|
2491
2589
|
key: "normalizeFingerprintValue",
|
|
2492
2590
|
value: function normalizeFingerprintValue(value) {
|
|
2493
|
-
var
|
|
2591
|
+
var _this14 = this;
|
|
2494
2592
|
if (Array.isArray(value)) {
|
|
2495
2593
|
return value.map(function (item) {
|
|
2496
|
-
return
|
|
2594
|
+
return _this14.normalizeFingerprintValue(item);
|
|
2497
2595
|
});
|
|
2498
2596
|
}
|
|
2499
2597
|
if (!value || _typeof(value) !== 'object') return value !== null && value !== void 0 ? value : '';
|
|
2500
2598
|
return Object.keys(value).sort().reduce(function (result, key) {
|
|
2501
|
-
result[key] =
|
|
2599
|
+
result[key] = _this14.normalizeFingerprintValue(value[key]);
|
|
2502
2600
|
return result;
|
|
2503
2601
|
}, {});
|
|
2504
2602
|
}
|
|
@@ -2513,7 +2611,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2513
2611
|
_sku$barcode,
|
|
2514
2612
|
_ref26,
|
|
2515
2613
|
_sku$variant_id,
|
|
2516
|
-
|
|
2614
|
+
_this15 = this;
|
|
2517
2615
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
2518
2616
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
2519
2617
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
@@ -2550,7 +2648,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2550
2648
|
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
2649
|
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
2650
|
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:
|
|
2651
|
+
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
2652
|
};
|
|
2555
2653
|
})
|
|
2556
2654
|
}),
|
|
@@ -2560,8 +2658,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2560
2658
|
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
2659
|
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
2660
|
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:
|
|
2661
|
+
price: _this15.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
|
|
2662
|
+
bundle_selling_price: _this15.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
|
|
2565
2663
|
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
2664
|
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
2665
|
};
|
|
@@ -2571,7 +2669,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2571
2669
|
return {
|
|
2572
2670
|
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
2671
|
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:
|
|
2672
|
+
amount: _this15.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
2575
2673
|
};
|
|
2576
2674
|
}))
|
|
2577
2675
|
};
|
|
@@ -2579,9 +2677,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2579
2677
|
}, {
|
|
2580
2678
|
key: "buildOrderProductsFingerprint",
|
|
2581
2679
|
value: function buildOrderProductsFingerprint(products) {
|
|
2582
|
-
var
|
|
2680
|
+
var _this16 = this;
|
|
2583
2681
|
var items = (products || []).map(function (product) {
|
|
2584
|
-
return
|
|
2682
|
+
return _this16.buildProductFingerprintItem(product);
|
|
2585
2683
|
});
|
|
2586
2684
|
items.sort(function (left, right) {
|
|
2587
2685
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -2603,7 +2701,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2603
2701
|
_sku$barcode2,
|
|
2604
2702
|
_ref36,
|
|
2605
2703
|
_sku$variant_id2,
|
|
2606
|
-
|
|
2704
|
+
_this17 = this;
|
|
2607
2705
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
2608
2706
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
2609
2707
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
@@ -2637,7 +2735,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2637
2735
|
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
2736
|
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
2737
|
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:
|
|
2738
|
+
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
2739
|
};
|
|
2642
2740
|
})
|
|
2643
2741
|
}),
|
|
@@ -2651,14 +2749,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2651
2749
|
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
2750
|
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
2751
|
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:
|
|
2752
|
+
option: _this17.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
|
|
2655
2753
|
var _ref44, _option$id3, _option$option_group_5, _ref45, _option$option_group_6, _option$num3, _option$add_price3;
|
|
2656
2754
|
return {
|
|
2657
2755
|
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
2756
|
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
2757
|
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
2758
|
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:
|
|
2759
|
+
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
2760
|
};
|
|
2663
2761
|
}))
|
|
2664
2762
|
};
|
|
@@ -2668,7 +2766,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2668
2766
|
return {
|
|
2669
2767
|
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
2768
|
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:
|
|
2769
|
+
amount: _this17.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
2672
2770
|
};
|
|
2673
2771
|
}))
|
|
2674
2772
|
};
|
|
@@ -2676,9 +2774,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2676
2774
|
}, {
|
|
2677
2775
|
key: "buildOrderProductsStructuralFingerprint",
|
|
2678
2776
|
value: function buildOrderProductsStructuralFingerprint(products) {
|
|
2679
|
-
var
|
|
2777
|
+
var _this18 = this;
|
|
2680
2778
|
var items = (products || []).map(function (product) {
|
|
2681
|
-
return
|
|
2779
|
+
return _this18.buildProductStructuralFingerprintItem(product);
|
|
2682
2780
|
});
|
|
2683
2781
|
items.sort(function (left, right) {
|
|
2684
2782
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -2986,7 +3084,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2986
3084
|
}
|
|
2987
3085
|
}, _callee11, this);
|
|
2988
3086
|
}));
|
|
2989
|
-
function replaceTempOrder(
|
|
3087
|
+
function replaceTempOrder(_x10, _x11) {
|
|
2990
3088
|
return _replaceTempOrder.apply(this, arguments);
|
|
2991
3089
|
}
|
|
2992
3090
|
return replaceTempOrder;
|
|
@@ -3130,9 +3228,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3130
3228
|
}, {
|
|
3131
3229
|
key: "sanitizeTempOrderProducts",
|
|
3132
3230
|
value: function sanitizeTempOrderProducts(tempOrder) {
|
|
3133
|
-
var
|
|
3231
|
+
var _this19 = this;
|
|
3134
3232
|
tempOrder.products = (tempOrder.products || []).map(function (product) {
|
|
3135
|
-
return
|
|
3233
|
+
return _this19.sanitizeOrderProductForTempOrder(_this19.normalizeVirtualSettlementProductIfEnabled(product));
|
|
3136
3234
|
});
|
|
3137
3235
|
this.syncTempOrderSettlementState(tempOrder);
|
|
3138
3236
|
ensureUniqueProductLineUids(tempOrder);
|
|
@@ -3252,7 +3350,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3252
3350
|
}, {
|
|
3253
3351
|
key: "syncLinkedBookingHoldersToProducts",
|
|
3254
3352
|
value: function syncLinkedBookingHoldersToProducts(tempOrder) {
|
|
3255
|
-
var
|
|
3353
|
+
var _this20 = this;
|
|
3256
3354
|
var bookings = tempOrder.bookings || [];
|
|
3257
3355
|
var products = tempOrder.products || [];
|
|
3258
3356
|
if (!bookings.length || !products.length) return;
|
|
@@ -3261,6 +3359,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3261
3359
|
bookings.forEach(function (booking) {
|
|
3262
3360
|
var _booking$metadata2, _booking$metadata3;
|
|
3263
3361
|
if (!booking || _typeof(booking) !== 'object') return;
|
|
3362
|
+
if (isFulfillmentTimingBooking(booking)) return;
|
|
3264
3363
|
var productUid = booking.product_uid || ((_booking$metadata2 = booking.metadata) === null || _booking$metadata2 === void 0 ? void 0 : _booking$metadata2.product_uid);
|
|
3265
3364
|
if (productUid !== undefined && productUid !== null && String(productUid) !== '') {
|
|
3266
3365
|
bookingByProductUid.set(String(productUid), booking);
|
|
@@ -3277,7 +3376,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3277
3376
|
var bookingUid = product.booking_uid || ((_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.booking_uid);
|
|
3278
3377
|
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
3378
|
if (linkedBooking) {
|
|
3280
|
-
|
|
3379
|
+
_this20.setProductHolderFromBooking(product, linkedBooking);
|
|
3281
3380
|
}
|
|
3282
3381
|
});
|
|
3283
3382
|
}
|
|
@@ -3325,6 +3424,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3325
3424
|
try {
|
|
3326
3425
|
for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
|
|
3327
3426
|
var booking = _step18.value;
|
|
3427
|
+
if (isFulfillmentTimingBooking(booking)) continue;
|
|
3328
3428
|
var holder = booking !== null && booking !== void 0 && booking.holder && _typeof(booking.holder) === 'object' ? booking.holder : null;
|
|
3329
3429
|
if (!baseHolder && holder) {
|
|
3330
3430
|
baseHolder = holder;
|
|
@@ -3383,7 +3483,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3383
3483
|
}, {
|
|
3384
3484
|
key: "syncTempOrderHolderFromBookings",
|
|
3385
3485
|
value: function syncTempOrderHolderFromBookings(tempOrder) {
|
|
3386
|
-
var bookings = tempOrder.bookings || []
|
|
3486
|
+
var bookings = (tempOrder.bookings || []).filter(function (booking) {
|
|
3487
|
+
return !isFulfillmentTimingBooking(booking);
|
|
3488
|
+
});
|
|
3387
3489
|
var hasHolderSource = bookings.some(function (booking) {
|
|
3388
3490
|
var _booking$metadata4;
|
|
3389
3491
|
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 +3507,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3405
3507
|
}, {
|
|
3406
3508
|
key: "findBookingIndexByUniqueIdentificationNumber",
|
|
3407
3509
|
value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
|
|
3408
|
-
var
|
|
3510
|
+
var _this21 = this;
|
|
3409
3511
|
return (tempOrder.bookings || []).findIndex(function (booking) {
|
|
3410
|
-
return
|
|
3512
|
+
return _this21.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
|
|
3411
3513
|
});
|
|
3412
3514
|
}
|
|
3413
3515
|
}, {
|
|
@@ -3415,12 +3517,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3415
3517
|
value: function removeLinkedBookingsForProduct(tempOrder, product) {
|
|
3416
3518
|
var _product$metadata5,
|
|
3417
3519
|
_product$metadata6,
|
|
3418
|
-
|
|
3520
|
+
_this22 = this;
|
|
3419
3521
|
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
3522
|
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
3523
|
if (!productUid && !bookingUid) return;
|
|
3422
3524
|
tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
|
|
3423
|
-
|
|
3525
|
+
if (isFulfillmentTimingBooking(booking)) return true;
|
|
3526
|
+
var currentBookingUid = _this22.getBookingUniqueIdentificationNumber(booking);
|
|
3424
3527
|
if (bookingUid && currentBookingUid === String(bookingUid)) return false;
|
|
3425
3528
|
if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
|
|
3426
3529
|
return true;
|
|
@@ -3468,30 +3571,36 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3468
3571
|
value: function () {
|
|
3469
3572
|
var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(options) {
|
|
3470
3573
|
var _this$otherParams3, _ref53, _salesSummaryResult$e;
|
|
3471
|
-
var tempOrder, originalSnapshot, hasShopDiscountChanged, shouldReuseOriginalSnapshot, snapshotSummary, shouldFullRecalculateFromSnapshot, summaryProducts, salesSummary, existedSummary, totalRefundAmount, paidPaymentSummary, emptyBaseSummary, emptySummaryBase, emptySummaryWithDeposit, emptySummary, salesSummaryResult, roundingAmount, payServiceChargeAmount, hasSalesSummaryAmount, expectAmount, amountPaymentPatch, normalizedExpectAmountPatch, summaryForGap, summary;
|
|
3574
|
+
var tempOrder, originalSnapshot, hasShopDiscountChanged, shouldReuseOriginalSnapshot, snapshotSummary, shouldFullRecalculateFromSnapshot, summaryProducts, salesSummary, existedSummary, totalRefundAmount, paidPaymentSummary, emptyBaseSummary, emptySummaryBase, emptySummaryWithDeposit, emptySummary, summaryMutationBaseline, salesSummaryResult, roundingAmount, payServiceChargeAmount, hasSalesSummaryAmount, expectAmount, amountPaymentPatch, normalizedExpectAmountPatch, summaryForGap, summary;
|
|
3472
3575
|
return _regeneratorRuntime().wrap(function _callee13$(_context15) {
|
|
3473
3576
|
while (1) switch (_context15.prev = _context15.next) {
|
|
3474
3577
|
case 0:
|
|
3578
|
+
if (!(options !== null && options !== void 0 && options.isCurrentOrder && !options.isCurrentOrder())) {
|
|
3579
|
+
_context15.next = 2;
|
|
3580
|
+
break;
|
|
3581
|
+
}
|
|
3582
|
+
return _context15.abrupt("return", null);
|
|
3583
|
+
case 2:
|
|
3475
3584
|
tempOrder = options !== null && options !== void 0 && options.createIfMissing ? this.ensureTempOrder() : this.store.tempOrder;
|
|
3476
3585
|
if (tempOrder) {
|
|
3477
|
-
_context15.next =
|
|
3586
|
+
_context15.next = 5;
|
|
3478
3587
|
break;
|
|
3479
3588
|
}
|
|
3480
3589
|
return _context15.abrupt("return", null);
|
|
3481
|
-
case
|
|
3590
|
+
case 5:
|
|
3482
3591
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
3483
3592
|
originalSnapshot = this.getOriginalSalesSnapshot(tempOrder);
|
|
3484
3593
|
hasShopDiscountChanged = originalSnapshot ? this.hasShopDiscountChangedFromSnapshot(tempOrder, originalSnapshot) : false;
|
|
3485
3594
|
shouldReuseOriginalSnapshot = originalSnapshot && !hasShopDiscountChanged;
|
|
3486
3595
|
snapshotSummary = shouldReuseOriginalSnapshot ? this.restoreOriginalSnapshotIfProductsUnchanged(tempOrder, originalSnapshot) : null;
|
|
3487
3596
|
if (!snapshotSummary) {
|
|
3488
|
-
_context15.next =
|
|
3597
|
+
_context15.next = 12;
|
|
3489
3598
|
break;
|
|
3490
3599
|
}
|
|
3491
3600
|
return _context15.abrupt("return", snapshotSummary);
|
|
3492
|
-
case
|
|
3601
|
+
case 12:
|
|
3493
3602
|
shouldFullRecalculateFromSnapshot = Boolean(originalSnapshot);
|
|
3494
|
-
summaryProducts = shouldFullRecalculateFromSnapshot ? cloneDeep(tempOrder.products || []) : tempOrder.products;
|
|
3603
|
+
summaryProducts = shouldFullRecalculateFromSnapshot || options !== null && options !== void 0 && options.isCurrentOrder ? cloneDeep(tempOrder.products || []) : tempOrder.products;
|
|
3495
3604
|
if (shouldFullRecalculateFromSnapshot) {
|
|
3496
3605
|
this.clearPersistedAmountFieldsForFullRecalc(summaryProducts || []);
|
|
3497
3606
|
}
|
|
@@ -3500,7 +3609,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3500
3609
|
totalRefundAmount = existedSummary.total_refund_amount || '0.00';
|
|
3501
3610
|
paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
|
|
3502
3611
|
if (salesSummary) {
|
|
3503
|
-
_context15.next =
|
|
3612
|
+
_context15.next = 28;
|
|
3504
3613
|
break;
|
|
3505
3614
|
}
|
|
3506
3615
|
emptyBaseSummary = _objectSpread(_objectSpread(_objectSpread({}, createEmptySummary()), existedSummary), {}, {
|
|
@@ -3527,8 +3636,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3527
3636
|
summary: emptySummary
|
|
3528
3637
|
});
|
|
3529
3638
|
return _context15.abrupt("return", this.store.summary);
|
|
3530
|
-
case
|
|
3531
|
-
|
|
3639
|
+
case 28:
|
|
3640
|
+
summaryMutationBaseline = options !== null && options !== void 0 && options.isCurrentOrder ? cloneDeep({
|
|
3641
|
+
tempOrder: tempOrder,
|
|
3642
|
+
summary: this.store.summary
|
|
3643
|
+
}) : null;
|
|
3644
|
+
_context15.next = 31;
|
|
3532
3645
|
return salesSummary.getSummary(_objectSpread({
|
|
3533
3646
|
products: summaryProducts,
|
|
3534
3647
|
isPriceIncludeTax: tempOrder.is_price_include_tax,
|
|
@@ -3537,9 +3650,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3537
3650
|
}, (_this$otherParams3 = this.otherParams) !== null && _this$otherParams3 !== void 0 && _this$otherParams3.channel ? {
|
|
3538
3651
|
channel: this.otherParams.channel
|
|
3539
3652
|
} : {}));
|
|
3540
|
-
case
|
|
3653
|
+
case 31:
|
|
3541
3654
|
salesSummaryResult = _context15.sent;
|
|
3542
|
-
if (
|
|
3655
|
+
if (!(options !== null && options !== void 0 && options.isCurrentOrder && !options.isCurrentOrder())) {
|
|
3656
|
+
_context15.next = 34;
|
|
3657
|
+
break;
|
|
3658
|
+
}
|
|
3659
|
+
return _context15.abrupt("return", null);
|
|
3660
|
+
case 34:
|
|
3661
|
+
if (!(options !== null && options !== void 0 && options.isCurrentOrder && !isEqual({
|
|
3662
|
+
tempOrder: tempOrder,
|
|
3663
|
+
summary: this.store.summary
|
|
3664
|
+
}, summaryMutationBaseline))) {
|
|
3665
|
+
_context15.next = 36;
|
|
3666
|
+
break;
|
|
3667
|
+
}
|
|
3668
|
+
return _context15.abrupt("return", null);
|
|
3669
|
+
case 36:
|
|
3670
|
+
if (shouldFullRecalculateFromSnapshot || options !== null && options !== void 0 && options.isCurrentOrder) {
|
|
3543
3671
|
tempOrder.products = summaryProducts;
|
|
3544
3672
|
}
|
|
3545
3673
|
this.syncSummaryProductMetadata(tempOrder.products || []);
|
|
@@ -3584,13 +3712,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3584
3712
|
summary: summary
|
|
3585
3713
|
});
|
|
3586
3714
|
return _context15.abrupt("return", this.store.summary);
|
|
3587
|
-
case
|
|
3715
|
+
case 53:
|
|
3588
3716
|
case "end":
|
|
3589
3717
|
return _context15.stop();
|
|
3590
3718
|
}
|
|
3591
3719
|
}, _callee13, this);
|
|
3592
3720
|
}));
|
|
3593
|
-
function recalculateSummary(
|
|
3721
|
+
function recalculateSummary(_x12) {
|
|
3594
3722
|
return _recalculateSummary.apply(this, arguments);
|
|
3595
3723
|
}
|
|
3596
3724
|
return recalculateSummary;
|
|
@@ -3661,7 +3789,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3661
3789
|
}
|
|
3662
3790
|
}, _callee15, this);
|
|
3663
3791
|
}));
|
|
3664
|
-
function syncTempOrderNoteToRemote(
|
|
3792
|
+
function syncTempOrderNoteToRemote(_x13, _x14) {
|
|
3665
3793
|
return _syncTempOrderNoteToRemote.apply(this, arguments);
|
|
3666
3794
|
}
|
|
3667
3795
|
return syncTempOrderNoteToRemote;
|
|
@@ -3722,7 +3850,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3722
3850
|
}, {
|
|
3723
3851
|
key: "removeSalesNotesForMissingProductLines",
|
|
3724
3852
|
value: function removeSalesNotesForMissingProductLines(tempOrder) {
|
|
3725
|
-
var
|
|
3853
|
+
var _this23 = this;
|
|
3726
3854
|
var state = this.ensureSalesNotesRuntimeState(tempOrder);
|
|
3727
3855
|
if (!state.loaded || !Array.isArray(tempOrder.notes) || tempOrder.notes.length === 0) {
|
|
3728
3856
|
return;
|
|
@@ -3734,7 +3862,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3734
3862
|
return typeof uid === 'string' && uid.length > 0;
|
|
3735
3863
|
}));
|
|
3736
3864
|
var nextNotes = tempOrder.notes.filter(function (note) {
|
|
3737
|
-
var primary =
|
|
3865
|
+
var primary = _this23.getSalesNotePrimaryRelation(note);
|
|
3738
3866
|
if (!primary || primary.target_type !== 'order_detail') return true;
|
|
3739
3867
|
return remainingProductUids.has(primary.target_uuid);
|
|
3740
3868
|
});
|
|
@@ -3746,7 +3874,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3746
3874
|
key: "setSalesNoteOnTempOrder",
|
|
3747
3875
|
value: function setSalesNoteOnTempOrder(tempOrder, input) {
|
|
3748
3876
|
var _input$target,
|
|
3749
|
-
|
|
3877
|
+
_this24 = this,
|
|
3750
3878
|
_tempOrder$shop_order;
|
|
3751
3879
|
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
3752
3880
|
var note_type = String(input.note_type || '').trim();
|
|
@@ -3770,7 +3898,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3770
3898
|
var notes = tempOrder.notes || [];
|
|
3771
3899
|
// 当前 allergy policy 固定同一商品行只保留一条;业务调用方不参与去重规则。
|
|
3772
3900
|
var existingIndex = policy.uniquePerPrimaryTarget ? notes.findIndex(function (note) {
|
|
3773
|
-
var primary =
|
|
3901
|
+
var primary = _this24.getSalesNotePrimaryRelation(note);
|
|
3774
3902
|
return note.note_type === note_type && (primary === null || primary === void 0 ? void 0 : primary.target_type) === 'order_detail' && primary.target_uuid === target_uuid;
|
|
3775
3903
|
}) : -1;
|
|
3776
3904
|
var existing = existingIndex >= 0 ? notes[existingIndex] : null;
|
|
@@ -3877,7 +4005,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3877
4005
|
}
|
|
3878
4006
|
}, _callee16, this);
|
|
3879
4007
|
}));
|
|
3880
|
-
function setSalesNote(
|
|
4008
|
+
function setSalesNote(_x15) {
|
|
3881
4009
|
return _setSalesNote.apply(this, arguments);
|
|
3882
4010
|
}
|
|
3883
4011
|
return setSalesNote;
|
|
@@ -3913,7 +4041,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3913
4041
|
}
|
|
3914
4042
|
}, _callee17, this);
|
|
3915
4043
|
}));
|
|
3916
|
-
function removeSalesNote(
|
|
4044
|
+
function removeSalesNote(_x16) {
|
|
3917
4045
|
return _removeSalesNote.apply(this, arguments);
|
|
3918
4046
|
}
|
|
3919
4047
|
return removeSalesNote;
|
|
@@ -4007,10 +4135,47 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4007
4135
|
}, {
|
|
4008
4136
|
key: "updateTempOrderServiceType",
|
|
4009
4137
|
value: function updateTempOrderServiceType(serviceType) {
|
|
4138
|
+
if (serviceType !== 'pick_up') {
|
|
4139
|
+
var tempOrder = this.ensureTempOrder();
|
|
4140
|
+
tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
|
|
4141
|
+
return !isFulfillmentTimingBooking(booking);
|
|
4142
|
+
});
|
|
4143
|
+
}
|
|
4010
4144
|
return this.updateTempOrderShopServiceData({
|
|
4011
4145
|
service_type: serviceType
|
|
4012
4146
|
});
|
|
4013
4147
|
}
|
|
4148
|
+
}, {
|
|
4149
|
+
key: "getPickupTimingBooking",
|
|
4150
|
+
value: function getPickupTimingBooking() {
|
|
4151
|
+
var _this$store$tempOrder7;
|
|
4152
|
+
return (((_this$store$tempOrder7 = this.store.tempOrder) === null || _this$store$tempOrder7 === void 0 ? void 0 : _this$store$tempOrder7.bookings) || []).find(isFulfillmentTimingBooking) || null;
|
|
4153
|
+
}
|
|
4154
|
+
}, {
|
|
4155
|
+
key: "setPickupTimingBooking",
|
|
4156
|
+
value: function setPickupTimingBooking(input) {
|
|
4157
|
+
var tempOrder = this.ensureTempOrder();
|
|
4158
|
+
var bookings = tempOrder.bookings || [];
|
|
4159
|
+
var firstIndex = bookings.findIndex(isFulfillmentTimingBooking);
|
|
4160
|
+
var nextBooking = buildPickupTimingBooking(input, bookings[firstIndex]);
|
|
4161
|
+
// Keep the first row's identity and position; repair duplicate marked rows only.
|
|
4162
|
+
tempOrder.bookings = firstIndex === -1 ? [].concat(_toConsumableArray(bookings), [nextBooking]) : bookings.flatMap(function (booking, index) {
|
|
4163
|
+
return index === firstIndex ? [nextBooking] : isFulfillmentTimingBooking(booking) ? [] : [booking];
|
|
4164
|
+
});
|
|
4165
|
+
this.notifyTempOrderChanged();
|
|
4166
|
+
return nextBooking;
|
|
4167
|
+
}
|
|
4168
|
+
}, {
|
|
4169
|
+
key: "clearPickupTimingBooking",
|
|
4170
|
+
value: function clearPickupTimingBooking() {
|
|
4171
|
+
var _tempOrder$bookings;
|
|
4172
|
+
var tempOrder = this.store.tempOrder;
|
|
4173
|
+
if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$bookings = tempOrder.bookings) !== null && _tempOrder$bookings !== void 0 && _tempOrder$bookings.some(isFulfillmentTimingBooking))) return;
|
|
4174
|
+
tempOrder.bookings = tempOrder.bookings.filter(function (booking) {
|
|
4175
|
+
return !isFulfillmentTimingBooking(booking);
|
|
4176
|
+
});
|
|
4177
|
+
this.notifyTempOrderChanged();
|
|
4178
|
+
}
|
|
4014
4179
|
}, {
|
|
4015
4180
|
key: "updateTempOrderContactsInfo",
|
|
4016
4181
|
value: function updateTempOrderContactsInfo(contactsInfo) {
|
|
@@ -4052,15 +4217,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4052
4217
|
}, {
|
|
4053
4218
|
key: "productHasCustomerBoundDiscount",
|
|
4054
4219
|
value: function productHasCustomerBoundDiscount(product) {
|
|
4055
|
-
var
|
|
4220
|
+
var _this25 = this;
|
|
4056
4221
|
if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
|
|
4057
|
-
return
|
|
4222
|
+
return _this25.isCustomerBoundDiscount(discount);
|
|
4058
4223
|
})) {
|
|
4059
4224
|
return true;
|
|
4060
4225
|
}
|
|
4061
4226
|
return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
|
|
4062
4227
|
return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
|
|
4063
|
-
return
|
|
4228
|
+
return _this25.isCustomerBoundDiscount(discount);
|
|
4064
4229
|
});
|
|
4065
4230
|
});
|
|
4066
4231
|
}
|
|
@@ -4069,18 +4234,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4069
4234
|
value: function shouldSkipDiscountCalculation(tempOrder) {
|
|
4070
4235
|
var _this$store$discount20,
|
|
4071
4236
|
_this$store$discount21,
|
|
4072
|
-
|
|
4237
|
+
_this26 = this;
|
|
4073
4238
|
if (this.hasActiveCustomerBoundDiscount) return false;
|
|
4074
4239
|
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
4240
|
if (discountList.length > 0) return false;
|
|
4076
4241
|
return !(tempOrder.products || []).some(function (product) {
|
|
4077
|
-
return
|
|
4242
|
+
return _this26.productHasCustomerBoundDiscount(product);
|
|
4078
4243
|
});
|
|
4079
4244
|
}
|
|
4080
4245
|
}, {
|
|
4081
4246
|
key: "clearCustomerBoundDiscounts",
|
|
4082
4247
|
value: function clearCustomerBoundDiscounts(tempOrder) {
|
|
4083
|
-
var
|
|
4248
|
+
var _this27 = this,
|
|
4084
4249
|
_discountModule$getDi,
|
|
4085
4250
|
_discountModule$getOr,
|
|
4086
4251
|
_discountModule$setDi,
|
|
@@ -4089,7 +4254,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4089
4254
|
var filterDiscountList = function filterDiscountList(discountList) {
|
|
4090
4255
|
if (!Array.isArray(discountList)) return [];
|
|
4091
4256
|
return discountList.filter(function (discount) {
|
|
4092
|
-
var shouldRemove =
|
|
4257
|
+
var shouldRemove = _this27.isCustomerBoundDiscount(discount);
|
|
4093
4258
|
if (shouldRemove) didRemoveCustomerBoundDiscount = true;
|
|
4094
4259
|
return !shouldRemove;
|
|
4095
4260
|
});
|
|
@@ -4116,12 +4281,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4116
4281
|
var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
|
|
4117
4282
|
var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
|
|
4118
4283
|
var nextDiscounts = currentDiscounts.filter(function (discount) {
|
|
4119
|
-
if (
|
|
4120
|
-
return !
|
|
4284
|
+
if (_this27.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
4285
|
+
return !_this27.isCustomerBoundDiscount(discount);
|
|
4121
4286
|
});
|
|
4122
4287
|
var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
|
|
4123
|
-
if (
|
|
4124
|
-
return !
|
|
4288
|
+
if (_this27.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
4289
|
+
return !_this27.isCustomerBoundDiscount(discount);
|
|
4125
4290
|
});
|
|
4126
4291
|
void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
|
|
4127
4292
|
void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
|
|
@@ -4224,8 +4389,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4224
4389
|
}, {
|
|
4225
4390
|
key: "getOrderCustomerSnapshot",
|
|
4226
4391
|
value: function getOrderCustomerSnapshot() {
|
|
4227
|
-
var _this$store$
|
|
4228
|
-
var snapshot = (_this$store$
|
|
4392
|
+
var _this$store$tempOrder8;
|
|
4393
|
+
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
4394
|
return snapshot ? cloneDeep(snapshot) : null;
|
|
4230
4395
|
}
|
|
4231
4396
|
}, {
|
|
@@ -4285,10 +4450,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4285
4450
|
}, {
|
|
4286
4451
|
key: "setOrderPayments",
|
|
4287
4452
|
value: function setOrderPayments(payments) {
|
|
4288
|
-
var
|
|
4453
|
+
var _this28 = this;
|
|
4289
4454
|
var tempOrder = this.ensureTempOrder();
|
|
4290
4455
|
tempOrder.payments = mapPaymentItemsToOrderPayments((payments || []).map(function (payment) {
|
|
4291
|
-
return
|
|
4456
|
+
return _this28.normalizePaymentSource(payment, {
|
|
4292
4457
|
defaultPaid: false
|
|
4293
4458
|
});
|
|
4294
4459
|
}));
|
|
@@ -4335,7 +4500,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4335
4500
|
}
|
|
4336
4501
|
}, _callee19, this);
|
|
4337
4502
|
}));
|
|
4338
|
-
function addOrderPaymentAsync(
|
|
4503
|
+
function addOrderPaymentAsync(_x17) {
|
|
4339
4504
|
return _addOrderPaymentAsync.apply(this, arguments);
|
|
4340
4505
|
}
|
|
4341
4506
|
return addOrderPaymentAsync;
|
|
@@ -4343,7 +4508,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4343
4508
|
}, {
|
|
4344
4509
|
key: "addOrderPaymentWithDevicePrefix",
|
|
4345
4510
|
value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
|
|
4346
|
-
var
|
|
4511
|
+
var _this29 = this;
|
|
4347
4512
|
this.logInfo('addOrderPayment', {
|
|
4348
4513
|
payment: payment
|
|
4349
4514
|
});
|
|
@@ -4361,7 +4526,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4361
4526
|
void this.recalculateSummary({
|
|
4362
4527
|
createIfMissing: true
|
|
4363
4528
|
}).catch(function (error) {
|
|
4364
|
-
|
|
4529
|
+
_this29.logError('recalculate summary after addOrderPayment failed', {
|
|
4365
4530
|
error: error instanceof Error ? error.message : String(error)
|
|
4366
4531
|
});
|
|
4367
4532
|
});
|
|
@@ -4381,6 +4546,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4381
4546
|
identity,
|
|
4382
4547
|
matchMode,
|
|
4383
4548
|
matchedPayment,
|
|
4549
|
+
_this$logger,
|
|
4550
|
+
_this$logger$addLog,
|
|
4384
4551
|
updatedPayment,
|
|
4385
4552
|
summary,
|
|
4386
4553
|
payments,
|
|
@@ -4394,11 +4561,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4394
4561
|
matchMode = options.matchBy === 'compat' || options.matchBy === 'legacy' ? 'compat' : 'payment_number';
|
|
4395
4562
|
matchedPayment = resolveOrderPaymentIdentity(tempOrder.payments || [], identity, matchMode);
|
|
4396
4563
|
if (matchedPayment) {
|
|
4397
|
-
_context22.next =
|
|
4564
|
+
_context22.next = 8;
|
|
4398
4565
|
break;
|
|
4399
4566
|
}
|
|
4567
|
+
try {
|
|
4568
|
+
void Promise.resolve((_this$logger = this.logger) === null || _this$logger === void 0 || (_this$logger$addLog = _this$logger.addLog) === null || _this$logger$addLog === void 0 ? void 0 : _this$logger$addLog.call(_this$logger, {
|
|
4569
|
+
type: 'warning',
|
|
4570
|
+
title: '[PaymentTrace] payment-missing',
|
|
4571
|
+
metadata: {
|
|
4572
|
+
moduleName: this.name,
|
|
4573
|
+
saleId: tempOrder.external_sale_number,
|
|
4574
|
+
paymentNumber: identity,
|
|
4575
|
+
currentPaymentNumbers: (tempOrder.payments || []).map(function (p) {
|
|
4576
|
+
return p.payment_number;
|
|
4577
|
+
})
|
|
4578
|
+
}
|
|
4579
|
+
})).catch(function () {});
|
|
4580
|
+
} catch (_unused4) {/* 日志失败不影响原异常。 */}
|
|
4400
4581
|
throw new Error("\u672A\u627E\u5230\u652F\u4ED8\u9879: ".concat(identity));
|
|
4401
|
-
case
|
|
4582
|
+
case 8:
|
|
4402
4583
|
updatedPayment = null;
|
|
4403
4584
|
tempOrder.payments = (tempOrder.payments || []).map(function (payment, index) {
|
|
4404
4585
|
if (index !== matchedPayment.index) return payment;
|
|
@@ -4409,11 +4590,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4409
4590
|
return nextPayment;
|
|
4410
4591
|
});
|
|
4411
4592
|
this.persistTempOrder();
|
|
4412
|
-
_context22.next =
|
|
4593
|
+
_context22.next = 13;
|
|
4413
4594
|
return this.recalculateSummary({
|
|
4414
4595
|
createIfMissing: true
|
|
4415
4596
|
});
|
|
4416
|
-
case
|
|
4597
|
+
case 13:
|
|
4417
4598
|
summary = _context22.sent;
|
|
4418
4599
|
this.persistTempOrder();
|
|
4419
4600
|
payments = tempOrder.payments;
|
|
@@ -4423,13 +4604,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4423
4604
|
payments: payments,
|
|
4424
4605
|
summary: summary
|
|
4425
4606
|
});
|
|
4426
|
-
case
|
|
4607
|
+
case 17:
|
|
4427
4608
|
case "end":
|
|
4428
4609
|
return _context22.stop();
|
|
4429
4610
|
}
|
|
4430
4611
|
}, _callee20, this);
|
|
4431
4612
|
}));
|
|
4432
|
-
function updateOrderPayment(
|
|
4613
|
+
function updateOrderPayment(_x18, _x19) {
|
|
4433
4614
|
return _updateOrderPayment.apply(this, arguments);
|
|
4434
4615
|
}
|
|
4435
4616
|
return updateOrderPayment;
|
|
@@ -4474,7 +4655,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4474
4655
|
}, {
|
|
4475
4656
|
key: "applyPaymentLifecycleChange",
|
|
4476
4657
|
value: function applyPaymentLifecycleChange(tempOrder, options) {
|
|
4477
|
-
var
|
|
4658
|
+
var _this30 = this;
|
|
4478
4659
|
this.updateTempOrderPaymentStatus(tempOrder);
|
|
4479
4660
|
if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
|
|
4480
4661
|
this.persistTempOrder();
|
|
@@ -4484,7 +4665,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4484
4665
|
void this.recalculateSummary({
|
|
4485
4666
|
createIfMissing: true
|
|
4486
4667
|
}).catch(function (error) {
|
|
4487
|
-
|
|
4668
|
+
_this30.logError("recalculate summary after ".concat(logContext, " failed"), {
|
|
4488
4669
|
error: error instanceof Error ? error.message : String(error)
|
|
4489
4670
|
});
|
|
4490
4671
|
});
|
|
@@ -4528,7 +4709,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4528
4709
|
}, {
|
|
4529
4710
|
key: "updateVoucherOrderPayments",
|
|
4530
4711
|
value: function updateVoucherOrderPayments(payments, options) {
|
|
4531
|
-
var
|
|
4712
|
+
var _this31 = this;
|
|
4532
4713
|
var tempOrder = this.ensureTempOrder();
|
|
4533
4714
|
var isOrderPaymentType = function isOrderPaymentType(value) {
|
|
4534
4715
|
return value === 'normal' || value === 'deposit';
|
|
@@ -4563,7 +4744,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4563
4744
|
});
|
|
4564
4745
|
};
|
|
4565
4746
|
var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
|
|
4566
|
-
return
|
|
4747
|
+
return _this31.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
|
|
4567
4748
|
defaultPaid: false,
|
|
4568
4749
|
devicePrefix: options === null || options === void 0 ? void 0 : options.devicePrefix
|
|
4569
4750
|
});
|
|
@@ -4616,7 +4797,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4616
4797
|
void this.recalculateSummary({
|
|
4617
4798
|
createIfMissing: true
|
|
4618
4799
|
}).catch(function (error) {
|
|
4619
|
-
|
|
4800
|
+
_this31.logError('recalculate summary after updateVoucherOrderPayments failed', {
|
|
4620
4801
|
error: error instanceof Error ? error.message : String(error)
|
|
4621
4802
|
});
|
|
4622
4803
|
});
|
|
@@ -4656,7 +4837,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4656
4837
|
}
|
|
4657
4838
|
}, _callee21, this);
|
|
4658
4839
|
}));
|
|
4659
|
-
function updateVoucherOrderPaymentsAsync(
|
|
4840
|
+
function updateVoucherOrderPaymentsAsync(_x20, _x21) {
|
|
4660
4841
|
return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
|
|
4661
4842
|
}
|
|
4662
4843
|
return updateVoucherOrderPaymentsAsync;
|
|
@@ -4673,16 +4854,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4673
4854
|
}, {
|
|
4674
4855
|
key: "shouldMergeProductToOrder",
|
|
4675
4856
|
value: function shouldMergeProductToOrder(params) {
|
|
4676
|
-
var _this$
|
|
4677
|
-
|
|
4678
|
-
var onBeforeMergeProductToOrder = (_this$
|
|
4857
|
+
var _this$orderHooks3,
|
|
4858
|
+
_this32 = this;
|
|
4859
|
+
var onBeforeMergeProductToOrder = (_this$orderHooks3 = this.orderHooks) === null || _this$orderHooks3 === void 0 ? void 0 : _this$orderHooks3.onBeforeMergeProductToOrder;
|
|
4679
4860
|
if (!onBeforeMergeProductToOrder) return true;
|
|
4680
4861
|
var result = onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
4681
4862
|
defaultShouldMerge: true
|
|
4682
4863
|
}));
|
|
4683
4864
|
if (result && _typeof(result) === 'object' && typeof result.then === 'function') {
|
|
4684
4865
|
return Promise.resolve(result).then(function (resolved) {
|
|
4685
|
-
return
|
|
4866
|
+
return _this32.normalizeShouldMergeProductResult(resolved);
|
|
4686
4867
|
});
|
|
4687
4868
|
}
|
|
4688
4869
|
return this.normalizeShouldMergeProductResult(result);
|
|
@@ -4812,52 +4993,82 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4812
4993
|
key: "finalizeProductOrderMutation",
|
|
4813
4994
|
value: function () {
|
|
4814
4995
|
var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(tempOrder, options) {
|
|
4815
|
-
var isVirtualSettlement, promotionPayload;
|
|
4996
|
+
var isCurrentOrder, isVirtualSettlement, promotionPayload, summary;
|
|
4816
4997
|
return _regeneratorRuntime().wrap(function _callee22$(_context24) {
|
|
4817
4998
|
while (1) switch (_context24.prev = _context24.next) {
|
|
4818
4999
|
case 0:
|
|
5000
|
+
isCurrentOrder = options === null || options === void 0 ? void 0 : options.isCurrentOrder;
|
|
5001
|
+
if (!(isCurrentOrder && !isCurrentOrder())) {
|
|
5002
|
+
_context24.next = 3;
|
|
5003
|
+
break;
|
|
5004
|
+
}
|
|
5005
|
+
return _context24.abrupt("return");
|
|
5006
|
+
case 3:
|
|
4819
5007
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
4820
5008
|
this.prepareVirtualSettlementTempOrder(tempOrder);
|
|
4821
5009
|
isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder);
|
|
4822
5010
|
if (!(!(options !== null && options !== void 0 && options.skipEditDiscountConfigRefresh) && !isVirtualSettlement)) {
|
|
4823
|
-
_context24.next =
|
|
5011
|
+
_context24.next = 9;
|
|
4824
5012
|
break;
|
|
4825
5013
|
}
|
|
4826
|
-
_context24.next =
|
|
5014
|
+
_context24.next = 9;
|
|
4827
5015
|
return this.ensureEditDiscountConfigForProductChange(tempOrder);
|
|
4828
|
-
case
|
|
5016
|
+
case 9:
|
|
5017
|
+
if (!(isCurrentOrder && !isCurrentOrder())) {
|
|
5018
|
+
_context24.next = 11;
|
|
5019
|
+
break;
|
|
5020
|
+
}
|
|
5021
|
+
return _context24.abrupt("return");
|
|
5022
|
+
case 11:
|
|
4829
5023
|
if (!(!(options !== null && options !== void 0 && options.skipDiscountRecalculation) && !isVirtualSettlement)) {
|
|
4830
|
-
_context24.next =
|
|
5024
|
+
_context24.next = 17;
|
|
4831
5025
|
break;
|
|
4832
5026
|
}
|
|
4833
|
-
_context24.next =
|
|
4834
|
-
return this.evaluatePromotion(
|
|
4835
|
-
|
|
5027
|
+
_context24.next = 14;
|
|
5028
|
+
return this.evaluatePromotion(isCurrentOrder ? {
|
|
5029
|
+
isCurrentOrder: isCurrentOrder
|
|
5030
|
+
} : undefined);
|
|
5031
|
+
case 14:
|
|
4836
5032
|
_context24.t0 = _context24.sent;
|
|
4837
|
-
_context24.next =
|
|
5033
|
+
_context24.next = 18;
|
|
4838
5034
|
break;
|
|
4839
|
-
case
|
|
5035
|
+
case 17:
|
|
4840
5036
|
_context24.t0 = null;
|
|
4841
|
-
case
|
|
5037
|
+
case 18:
|
|
4842
5038
|
promotionPayload = _context24.t0;
|
|
5039
|
+
if (!(isCurrentOrder && !isCurrentOrder())) {
|
|
5040
|
+
_context24.next = 21;
|
|
5041
|
+
break;
|
|
5042
|
+
}
|
|
5043
|
+
return _context24.abrupt("return");
|
|
5044
|
+
case 21:
|
|
4843
5045
|
if (!(options !== null && options !== void 0 && options.skipDiscountRecalculation) && !isVirtualSettlement) {
|
|
4844
5046
|
this.applyDiscount();
|
|
4845
5047
|
}
|
|
4846
5048
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4847
|
-
_context24.next =
|
|
4848
|
-
return this.recalculateSummary({
|
|
5049
|
+
_context24.next = 25;
|
|
5050
|
+
return this.recalculateSummary(_objectSpread({
|
|
4849
5051
|
createIfMissing: true
|
|
4850
|
-
}
|
|
4851
|
-
|
|
5052
|
+
}, isCurrentOrder ? {
|
|
5053
|
+
isCurrentOrder: isCurrentOrder
|
|
5054
|
+
} : {}));
|
|
5055
|
+
case 25:
|
|
5056
|
+
summary = _context24.sent;
|
|
5057
|
+
if (!(isCurrentOrder && (!isCurrentOrder() || !summary))) {
|
|
5058
|
+
_context24.next = 28;
|
|
5059
|
+
break;
|
|
5060
|
+
}
|
|
5061
|
+
return _context24.abrupt("return");
|
|
5062
|
+
case 28:
|
|
4852
5063
|
this.persistTempOrder();
|
|
4853
5064
|
this.emitPromotionApplied(promotionPayload);
|
|
4854
|
-
case
|
|
5065
|
+
case 30:
|
|
4855
5066
|
case "end":
|
|
4856
5067
|
return _context24.stop();
|
|
4857
5068
|
}
|
|
4858
5069
|
}, _callee22, this);
|
|
4859
5070
|
}));
|
|
4860
|
-
function finalizeProductOrderMutation(
|
|
5071
|
+
function finalizeProductOrderMutation(_x22, _x23) {
|
|
4861
5072
|
return _finalizeProductOrderMutation.apply(this, arguments);
|
|
4862
5073
|
}
|
|
4863
5074
|
return finalizeProductOrderMutation;
|
|
@@ -4883,13 +5094,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4883
5094
|
_metadata,
|
|
4884
5095
|
_productToAdd$metadat,
|
|
4885
5096
|
_origin,
|
|
4886
|
-
|
|
5097
|
+
_this33 = this;
|
|
4887
5098
|
var linked = booking ? this.createLinkedProductAndBooking({
|
|
4888
5099
|
product: product,
|
|
4889
5100
|
booking: booking
|
|
4890
5101
|
}) : null;
|
|
4891
5102
|
var productToAdd = (linked === null || linked === void 0 ? void 0 : linked.product) || product;
|
|
4892
|
-
this.assertAndLockProductSettlement(tempOrder, productToAdd);
|
|
4893
5103
|
var disableMerge = (options === null || options === void 0 ? void 0 : options.disableMerge) === true;
|
|
4894
5104
|
var incomingFingerprint = disableMerge ? '' : buildProductLineFingerprint(getProductSkuOptions(productToAdd), productToAdd.product_bundle);
|
|
4895
5105
|
var normalizedIncoming = this.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(productToAdd, normalizeOrderProduct(productToAdd)));
|
|
@@ -4919,26 +5129,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4919
5129
|
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
5130
|
var shouldForceNewLine = disableMerge || !!booking || hasIncomingGoodPass || isIncomingPersistedEntitlementPass || hasIncomingBookingUid || isIncomingCustomItem || isWeighingProduct;
|
|
4921
5131
|
var matchedIndex = shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
4922
|
-
if (
|
|
4923
|
-
var isRuntimeEntitlementPass =
|
|
5132
|
+
if (_this33.hasGoodPassDiscount(item)) return false;
|
|
5133
|
+
var isRuntimeEntitlementPass = _this33.isRuntimeEntitlementAppend(item, tempOrder);
|
|
4924
5134
|
if (isIncomingEntitlementAppend !== isRuntimeEntitlementPass) {
|
|
4925
5135
|
return false;
|
|
4926
5136
|
}
|
|
4927
|
-
if (isIncomingEntitlementAppend &&
|
|
5137
|
+
if (isIncomingEntitlementAppend && _this33.isPersistedProductLine(item)) {
|
|
4928
5138
|
return false;
|
|
4929
5139
|
}
|
|
4930
|
-
var hasExistingProductNote =
|
|
5140
|
+
var hasExistingProductNote = _this33.hasOrderProductLineNote(item);
|
|
4931
5141
|
if ((hasIncomingProductNote || hasExistingProductNote) && (!isRuntimeEntitlementPass || String(normalizedIncoming.note || '').trim() !== String(item.note || '').trim())) {
|
|
4932
5142
|
return false;
|
|
4933
5143
|
}
|
|
4934
5144
|
var hasExistingManualProductDiscount = isManualProductDiscountProduct(item);
|
|
4935
|
-
if (isRuntimeEntitlementPass && !
|
|
5145
|
+
if (isRuntimeEntitlementPass && !_this33.hasSameEntitlementMergePriceConfig(normalizedIncoming, item)) {
|
|
4936
5146
|
return false;
|
|
4937
5147
|
}
|
|
4938
5148
|
if ((hasIncomingManualProductDiscount || hasExistingManualProductDiscount) && !isRuntimeEntitlementPass) {
|
|
4939
5149
|
return false;
|
|
4940
5150
|
}
|
|
4941
|
-
if (
|
|
5151
|
+
if (_this33.isPersistedProductLine(item)) return false;
|
|
4942
5152
|
if (item.product_id !== productToAdd.product_id) return false;
|
|
4943
5153
|
if (item.product_variant_id !== productToAdd.product_variant_id) return false;
|
|
4944
5154
|
var existedFingerprint = buildProductLineFingerprint(getProductSkuOptions(item), item.product_bundle);
|
|
@@ -4947,9 +5157,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4947
5157
|
var matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
|
|
4948
5158
|
var existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
|
|
4949
5159
|
var commitProductLine = function commitProductLine(shouldMerge) {
|
|
5160
|
+
var _options$beforeCommit;
|
|
5161
|
+
options === null || options === void 0 || (_options$beforeCommit = options.beforeCommit) === null || _options$beforeCommit === void 0 || _options$beforeCommit.call(options);
|
|
5162
|
+
_this33.assertAndLockProductSettlement(tempOrder, productToAdd);
|
|
4950
5163
|
var committedProduct;
|
|
4951
5164
|
if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
|
|
4952
|
-
|
|
5165
|
+
_this33.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
|
|
4953
5166
|
if (linked) {
|
|
4954
5167
|
normalizedIncoming.booking_uid = linked.bookingUid;
|
|
4955
5168
|
normalizedIncoming.metadata = _objectSpread(_objectSpread({}, normalizedIncoming.metadata || {}), {}, {
|
|
@@ -4967,7 +5180,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4967
5180
|
var _targetProduct$metada;
|
|
4968
5181
|
var targetProduct = matchedProduct;
|
|
4969
5182
|
var targetUid = (_targetProduct$metada = targetProduct.metadata) === null || _targetProduct$metada === void 0 ? void 0 : _targetProduct$metada.unique_identification_number;
|
|
4970
|
-
var normalizedProduct =
|
|
5183
|
+
var normalizedProduct = _this33.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(targetProduct, normalizeOrderProduct(_objectSpread(_objectSpread({}, productToAdd), {}, {
|
|
4971
5184
|
metadata: _objectSpread(_objectSpread({}, productToAdd.metadata || {}), {}, {
|
|
4972
5185
|
unique_identification_number: targetUid
|
|
4973
5186
|
})
|
|
@@ -4990,7 +5203,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4990
5203
|
order_detail_id: targetProduct.order_detail_id,
|
|
4991
5204
|
num: nextNum
|
|
4992
5205
|
});
|
|
4993
|
-
|
|
5206
|
+
_this33.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
|
|
4994
5207
|
committedProduct = tempOrder.products[matchedIndex];
|
|
4995
5208
|
if (matchedIndex !== tempOrder.products.length - 1) {
|
|
4996
5209
|
var mergedProduct = tempOrder.products[matchedIndex];
|
|
@@ -5100,12 +5313,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5100
5313
|
key: "addProductToOrder",
|
|
5101
5314
|
value: (function () {
|
|
5102
5315
|
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;
|
|
5316
|
+
var _this34 = this;
|
|
5317
|
+
var availabilityCommitGuard, liveTempOrder, beforeCommit, tempOrder, guardedMutationFields, readGuardedMutationFields, guardedMutationBaseline, salesNoteDrafts, mutationSnapshot, attachSalesNoteDrafts, rollbackProductAndNotesMutation, insertAfterProductUid, anchorIndex, insertAtIndex, _ref71, _productRecord$num, productRecord, splitCount, i, splitLine, committedProduct, _committedProduct, _committedProduct2, committedIdentity, isCurrentOrder;
|
|
5105
5318
|
return _regeneratorRuntime().wrap(function _callee23$(_context25) {
|
|
5106
5319
|
while (1) switch (_context25.prev = _context25.next) {
|
|
5107
5320
|
case 0:
|
|
5108
|
-
|
|
5321
|
+
availabilityCommitGuard = options === null || options === void 0 ? void 0 : options.availabilityCommitGuard;
|
|
5322
|
+
availabilityCommitGuard === null || availabilityCommitGuard === void 0 || availabilityCommitGuard();
|
|
5323
|
+
liveTempOrder = this.ensureTempOrder();
|
|
5324
|
+
beforeCommit = this.createCartIntentCommitGuard('add_product', liveTempOrder); // 自动预约在草稿上准备完整批次,避免拆票期间暴露半成品,或在失败时
|
|
5325
|
+
// 用整单快照回滚而抹掉其他入口的并发修改。人工路径保持原有写入行为。
|
|
5326
|
+
tempOrder = availabilityCommitGuard ? cloneDeep(liveTempOrder) : liveTempOrder;
|
|
5327
|
+
guardedMutationFields = ['products', 'bookings', 'notes', '_extend', 'metadata', 'currency_code', 'currency_symbol', 'currency_format'];
|
|
5328
|
+
readGuardedMutationFields = function readGuardedMutationFields(order) {
|
|
5329
|
+
return Object.fromEntries(guardedMutationFields.map(function (key) {
|
|
5330
|
+
return [key, order[key]];
|
|
5331
|
+
}));
|
|
5332
|
+
};
|
|
5333
|
+
guardedMutationBaseline = availabilityCommitGuard ? cloneDeep(readGuardedMutationFields(liveTempOrder)) : null;
|
|
5109
5334
|
salesNoteDrafts = ((options === null || options === void 0 ? void 0 : options.salesNotes) || []).map(function (draft) {
|
|
5110
5335
|
return {
|
|
5111
5336
|
note_type: String(draft.note_type || '').trim(),
|
|
@@ -5129,7 +5354,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5129
5354
|
throw new Error('[Order Notes] 商品行缺少 unique_identification_number');
|
|
5130
5355
|
}
|
|
5131
5356
|
salesNoteDrafts.forEach(function (draft) {
|
|
5132
|
-
|
|
5357
|
+
_this34.setSalesNoteOnTempOrder(tempOrder, {
|
|
5133
5358
|
note_type: draft.note_type,
|
|
5134
5359
|
target: {
|
|
5135
5360
|
target_type: 'order_detail',
|
|
@@ -5152,22 +5377,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5152
5377
|
var uid = ((_line$metadata = line.metadata) === null || _line$metadata === void 0 ? void 0 : _line$metadata.unique_identification_number) || line.unique_identification_number;
|
|
5153
5378
|
return uid !== undefined && uid !== null && String(uid) === String(insertAfterProductUid);
|
|
5154
5379
|
}) : -1;
|
|
5155
|
-
insertAtIndex = anchorIndex >= 0 ? anchorIndex + 1 : undefined;
|
|
5156
|
-
_context25.prev =
|
|
5380
|
+
insertAtIndex = options !== null && options !== void 0 && options.insertAtStart ? 0 : anchorIndex >= 0 ? anchorIndex + 1 : undefined;
|
|
5381
|
+
_context25.prev = 15;
|
|
5157
5382
|
if (!booking) {
|
|
5158
|
-
_context25.next =
|
|
5383
|
+
_context25.next = 42;
|
|
5159
5384
|
break;
|
|
5160
5385
|
}
|
|
5161
5386
|
productRecord = product;
|
|
5162
5387
|
splitCount = getSafeProductNum((_ref71 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref71 !== void 0 ? _ref71 : 1);
|
|
5163
5388
|
if (!(splitCount > 1)) {
|
|
5164
|
-
_context25.next =
|
|
5389
|
+
_context25.next = 35;
|
|
5165
5390
|
break;
|
|
5166
5391
|
}
|
|
5167
5392
|
i = 0;
|
|
5168
|
-
case
|
|
5393
|
+
case 21:
|
|
5169
5394
|
if (!(i < splitCount)) {
|
|
5170
|
-
_context25.next =
|
|
5395
|
+
_context25.next = 33;
|
|
5171
5396
|
break;
|
|
5172
5397
|
}
|
|
5173
5398
|
splitLine = this.createSplitBookingLine(productRecord, booking, i, splitCount);
|
|
@@ -5185,67 +5410,125 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5185
5410
|
delete splitLine.booking.metadata.unique_identification_number;
|
|
5186
5411
|
}
|
|
5187
5412
|
}
|
|
5188
|
-
_context25.next =
|
|
5413
|
+
_context25.next = 26;
|
|
5189
5414
|
return this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking, {
|
|
5190
5415
|
insertAtIndex: insertAtIndex,
|
|
5191
|
-
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge
|
|
5416
|
+
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge,
|
|
5417
|
+
beforeCommit: beforeCommit
|
|
5192
5418
|
});
|
|
5193
|
-
case
|
|
5419
|
+
case 26:
|
|
5194
5420
|
committedProduct = _context25.sent;
|
|
5421
|
+
availabilityCommitGuard === null || availabilityCommitGuard === void 0 || availabilityCommitGuard();
|
|
5195
5422
|
attachSalesNoteDrafts(committedProduct);
|
|
5196
5423
|
if (insertAtIndex !== undefined) insertAtIndex += 1;
|
|
5197
|
-
case
|
|
5424
|
+
case 30:
|
|
5198
5425
|
i += 1;
|
|
5199
|
-
_context25.next =
|
|
5426
|
+
_context25.next = 21;
|
|
5200
5427
|
break;
|
|
5201
|
-
case
|
|
5202
|
-
_context25.next =
|
|
5428
|
+
case 33:
|
|
5429
|
+
_context25.next = 40;
|
|
5203
5430
|
break;
|
|
5204
|
-
case
|
|
5205
|
-
_context25.next =
|
|
5431
|
+
case 35:
|
|
5432
|
+
_context25.next = 37;
|
|
5206
5433
|
return this.appendProductLineToTempOrder(tempOrder, product, cloneDeep(booking), {
|
|
5207
5434
|
insertAtIndex: insertAtIndex,
|
|
5208
|
-
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge
|
|
5435
|
+
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge,
|
|
5436
|
+
beforeCommit: beforeCommit
|
|
5209
5437
|
});
|
|
5210
|
-
case
|
|
5438
|
+
case 37:
|
|
5211
5439
|
_committedProduct = _context25.sent;
|
|
5440
|
+
availabilityCommitGuard === null || availabilityCommitGuard === void 0 || availabilityCommitGuard();
|
|
5212
5441
|
attachSalesNoteDrafts(_committedProduct);
|
|
5213
|
-
case
|
|
5214
|
-
_context25.next =
|
|
5442
|
+
case 40:
|
|
5443
|
+
_context25.next = 47;
|
|
5215
5444
|
break;
|
|
5216
|
-
case
|
|
5217
|
-
_context25.next =
|
|
5445
|
+
case 42:
|
|
5446
|
+
_context25.next = 44;
|
|
5218
5447
|
return this.appendProductLineToTempOrder(tempOrder, product, undefined, {
|
|
5219
5448
|
insertAtIndex: insertAtIndex,
|
|
5220
|
-
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge
|
|
5449
|
+
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge,
|
|
5450
|
+
beforeCommit: beforeCommit
|
|
5221
5451
|
});
|
|
5222
|
-
case
|
|
5452
|
+
case 44:
|
|
5223
5453
|
_committedProduct2 = _context25.sent;
|
|
5454
|
+
availabilityCommitGuard === null || availabilityCommitGuard === void 0 || availabilityCommitGuard();
|
|
5224
5455
|
attachSalesNoteDrafts(_committedProduct2);
|
|
5225
|
-
case
|
|
5226
|
-
|
|
5456
|
+
case 47:
|
|
5457
|
+
if (!availabilityCommitGuard) {
|
|
5458
|
+
_context25.next = 53;
|
|
5459
|
+
break;
|
|
5460
|
+
}
|
|
5461
|
+
availabilityCommitGuard();
|
|
5462
|
+
beforeCommit();
|
|
5463
|
+
// 调用方的结构 revision 可能不包括备注、价格或结算元数据。
|
|
5464
|
+
// 本次会覆盖的字段也要保持原值,不能让草稿覆盖并发编辑。
|
|
5465
|
+
if (isEqual(readGuardedMutationFields(liveTempOrder), guardedMutationBaseline)) {
|
|
5466
|
+
_context25.next = 52;
|
|
5467
|
+
break;
|
|
5468
|
+
}
|
|
5469
|
+
throw Object.assign(new Error('预约加购期间订单已变化,请重新选择'), {
|
|
5470
|
+
code: 'AVAILABILITY_SELECTION_STALE'
|
|
5471
|
+
});
|
|
5472
|
+
case 52:
|
|
5473
|
+
// 从最后一次门禁到真正新增之间不再 await。只发布本次新增会改写的
|
|
5474
|
+
// 字段;其余订单字段继续使用 live 对象,外部持有的订单引用也不变。
|
|
5475
|
+
Object.assign(liveTempOrder, readGuardedMutationFields(tempOrder));
|
|
5476
|
+
case 53:
|
|
5477
|
+
_context25.next = 59;
|
|
5227
5478
|
break;
|
|
5228
|
-
case
|
|
5229
|
-
_context25.prev =
|
|
5230
|
-
_context25.t0 = _context25["catch"](
|
|
5479
|
+
case 55:
|
|
5480
|
+
_context25.prev = 55;
|
|
5481
|
+
_context25.t0 = _context25["catch"](15);
|
|
5231
5482
|
rollbackProductAndNotesMutation();
|
|
5232
5483
|
throw _context25.t0;
|
|
5233
|
-
case
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5484
|
+
case 59:
|
|
5485
|
+
if (!availabilityCommitGuard) {
|
|
5486
|
+
_context25.next = 73;
|
|
5487
|
+
break;
|
|
5488
|
+
}
|
|
5489
|
+
committedIdentity = [liveTempOrder.order_id, liveTempOrder.external_sale_number];
|
|
5490
|
+
isCurrentOrder = function isCurrentOrder() {
|
|
5491
|
+
var _options$availability, _options$availability2;
|
|
5492
|
+
return _this34.store.tempOrder === liveTempOrder && liveTempOrder.order_id === committedIdentity[0] && liveTempOrder.external_sale_number === committedIdentity[1] && ((_options$availability = options === null || options === void 0 || (_options$availability2 = options.availabilityCommitTargetGuard) === null || _options$availability2 === void 0 ? void 0 : _options$availability2.call(options)) !== null && _options$availability !== void 0 ? _options$availability : true);
|
|
5493
|
+
};
|
|
5494
|
+
_context25.prev = 62;
|
|
5495
|
+
// 新增已发布,即使后续报价/促销收尾失败,也不能向调用方报告未加购。
|
|
5496
|
+
// 先保存已提交行;异步结果只允许写回仍属于本次提交的订单。
|
|
5497
|
+
if (isCurrentOrder()) this.persistTempOrder();
|
|
5498
|
+
_context25.next = 66;
|
|
5499
|
+
return this.finalizeProductOrderMutation(liveTempOrder, {
|
|
5500
|
+
isCurrentOrder: isCurrentOrder
|
|
5501
|
+
});
|
|
5502
|
+
case 66:
|
|
5503
|
+
_context25.next = 71;
|
|
5504
|
+
break;
|
|
5505
|
+
case 68:
|
|
5506
|
+
_context25.prev = 68;
|
|
5507
|
+
_context25.t1 = _context25["catch"](62);
|
|
5508
|
+
this.logWarning('addProductToOrder committed; finalization failed', {
|
|
5509
|
+
product_id: product.product_id,
|
|
5510
|
+
committed: true,
|
|
5511
|
+
error: _context25.t1 instanceof Error ? _context25.t1.message : String(_context25.t1)
|
|
5512
|
+
});
|
|
5513
|
+
case 71:
|
|
5514
|
+
_context25.next = 75;
|
|
5515
|
+
break;
|
|
5516
|
+
case 73:
|
|
5517
|
+
_context25.next = 75;
|
|
5518
|
+
return this.finalizeProductOrderMutation(liveTempOrder);
|
|
5519
|
+
case 75:
|
|
5237
5520
|
this.logInfo('addProductToOrder success', {
|
|
5238
5521
|
product_id: product.product_id,
|
|
5239
5522
|
with_booking: !!booking
|
|
5240
5523
|
});
|
|
5241
|
-
return _context25.abrupt("return",
|
|
5242
|
-
case
|
|
5524
|
+
return _context25.abrupt("return", liveTempOrder.products);
|
|
5525
|
+
case 77:
|
|
5243
5526
|
case "end":
|
|
5244
5527
|
return _context25.stop();
|
|
5245
5528
|
}
|
|
5246
|
-
}, _callee23, this, [[
|
|
5529
|
+
}, _callee23, this, [[15, 55], [62, 68]]);
|
|
5247
5530
|
}));
|
|
5248
|
-
function addProductToOrder(
|
|
5531
|
+
function addProductToOrder(_x24, _x25, _x26) {
|
|
5249
5532
|
return _addProductToOrder.apply(this, arguments);
|
|
5250
5533
|
}
|
|
5251
5534
|
return addProductToOrder;
|
|
@@ -5264,7 +5547,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5264
5547
|
key: "addProductsToOrder",
|
|
5265
5548
|
value: (function () {
|
|
5266
5549
|
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;
|
|
5550
|
+
var tempOrder, beforeCommit, _iterator20, _step20, item, product, booking, _ref72, _productRecord$num2, productRecord, splitCount, i, splitLine, _appendResult, appendResult;
|
|
5268
5551
|
return _regeneratorRuntime().wrap(function _callee24$(_context26) {
|
|
5269
5552
|
while (1) switch (_context26.prev = _context26.next) {
|
|
5270
5553
|
case 0:
|
|
@@ -5275,89 +5558,94 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5275
5558
|
}
|
|
5276
5559
|
return _context26.abrupt("return", tempOrder.products);
|
|
5277
5560
|
case 3:
|
|
5561
|
+
beforeCommit = this.createCartIntentCommitGuard('add_product', tempOrder);
|
|
5278
5562
|
_iterator20 = _createForOfIteratorHelper(items || []);
|
|
5279
|
-
_context26.prev =
|
|
5563
|
+
_context26.prev = 5;
|
|
5280
5564
|
_iterator20.s();
|
|
5281
|
-
case
|
|
5565
|
+
case 7:
|
|
5282
5566
|
if ((_step20 = _iterator20.n()).done) {
|
|
5283
|
-
_context26.next =
|
|
5567
|
+
_context26.next = 33;
|
|
5284
5568
|
break;
|
|
5285
5569
|
}
|
|
5286
5570
|
item = _step20.value;
|
|
5287
5571
|
product = item.product, booking = item.booking;
|
|
5288
5572
|
if (product) {
|
|
5289
|
-
_context26.next =
|
|
5573
|
+
_context26.next = 12;
|
|
5290
5574
|
break;
|
|
5291
5575
|
}
|
|
5292
|
-
return _context26.abrupt("continue",
|
|
5293
|
-
case
|
|
5576
|
+
return _context26.abrupt("continue", 31);
|
|
5577
|
+
case 12:
|
|
5294
5578
|
if (!booking) {
|
|
5295
|
-
_context26.next =
|
|
5579
|
+
_context26.next = 27;
|
|
5296
5580
|
break;
|
|
5297
5581
|
}
|
|
5298
5582
|
productRecord = product;
|
|
5299
5583
|
splitCount = getSafeProductNum((_ref72 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref72 !== void 0 ? _ref72 : 1);
|
|
5300
5584
|
if (!(splitCount > 1)) {
|
|
5301
|
-
_context26.next =
|
|
5585
|
+
_context26.next = 27;
|
|
5302
5586
|
break;
|
|
5303
5587
|
}
|
|
5304
5588
|
i = 0;
|
|
5305
|
-
case
|
|
5589
|
+
case 17:
|
|
5306
5590
|
if (!(i < splitCount)) {
|
|
5307
|
-
_context26.next =
|
|
5591
|
+
_context26.next = 26;
|
|
5308
5592
|
break;
|
|
5309
5593
|
}
|
|
5310
5594
|
splitLine = this.createSplitBookingLine(productRecord, booking, i, splitCount);
|
|
5311
|
-
_appendResult = this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking
|
|
5595
|
+
_appendResult = this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking, {
|
|
5596
|
+
beforeCommit: beforeCommit
|
|
5597
|
+
});
|
|
5312
5598
|
if (!_appendResult) {
|
|
5313
|
-
_context26.next =
|
|
5599
|
+
_context26.next = 23;
|
|
5314
5600
|
break;
|
|
5315
5601
|
}
|
|
5316
|
-
_context26.next =
|
|
5602
|
+
_context26.next = 23;
|
|
5317
5603
|
return _appendResult;
|
|
5318
|
-
case
|
|
5604
|
+
case 23:
|
|
5319
5605
|
i += 1;
|
|
5320
|
-
_context26.next =
|
|
5606
|
+
_context26.next = 17;
|
|
5321
5607
|
break;
|
|
5322
|
-
case 25:
|
|
5323
|
-
return _context26.abrupt("continue", 30);
|
|
5324
5608
|
case 26:
|
|
5325
|
-
|
|
5609
|
+
return _context26.abrupt("continue", 31);
|
|
5610
|
+
case 27:
|
|
5611
|
+
appendResult = this.appendProductLineToTempOrder(tempOrder, product, booking, {
|
|
5612
|
+
beforeCommit: beforeCommit
|
|
5613
|
+
});
|
|
5326
5614
|
if (!appendResult) {
|
|
5327
|
-
_context26.next =
|
|
5615
|
+
_context26.next = 31;
|
|
5328
5616
|
break;
|
|
5329
5617
|
}
|
|
5330
|
-
_context26.next =
|
|
5618
|
+
_context26.next = 31;
|
|
5331
5619
|
return appendResult;
|
|
5332
|
-
case
|
|
5333
|
-
_context26.next =
|
|
5620
|
+
case 31:
|
|
5621
|
+
_context26.next = 7;
|
|
5334
5622
|
break;
|
|
5335
|
-
case
|
|
5336
|
-
_context26.next =
|
|
5623
|
+
case 33:
|
|
5624
|
+
_context26.next = 38;
|
|
5337
5625
|
break;
|
|
5338
|
-
case
|
|
5339
|
-
_context26.prev =
|
|
5340
|
-
_context26.t0 = _context26["catch"](
|
|
5626
|
+
case 35:
|
|
5627
|
+
_context26.prev = 35;
|
|
5628
|
+
_context26.t0 = _context26["catch"](5);
|
|
5341
5629
|
_iterator20.e(_context26.t0);
|
|
5342
|
-
case
|
|
5343
|
-
_context26.prev =
|
|
5630
|
+
case 38:
|
|
5631
|
+
_context26.prev = 38;
|
|
5344
5632
|
_iterator20.f();
|
|
5345
|
-
return _context26.finish(
|
|
5346
|
-
case
|
|
5347
|
-
_context26.next =
|
|
5633
|
+
return _context26.finish(38);
|
|
5634
|
+
case 41:
|
|
5635
|
+
_context26.next = 43;
|
|
5348
5636
|
return this.finalizeProductOrderMutation(tempOrder, options);
|
|
5349
|
-
case
|
|
5637
|
+
case 43:
|
|
5350
5638
|
this.logInfo('addProductsToOrder success', {
|
|
5351
5639
|
itemsCount: items.length
|
|
5352
5640
|
});
|
|
5353
5641
|
return _context26.abrupt("return", tempOrder.products);
|
|
5354
|
-
case
|
|
5642
|
+
case 45:
|
|
5355
5643
|
case "end":
|
|
5356
5644
|
return _context26.stop();
|
|
5357
5645
|
}
|
|
5358
|
-
}, _callee24, this, [[
|
|
5646
|
+
}, _callee24, this, [[5, 35, 38, 41]]);
|
|
5359
5647
|
}));
|
|
5360
|
-
function addProductsToOrder(
|
|
5648
|
+
function addProductsToOrder(_x27, _x28) {
|
|
5361
5649
|
return _addProductsToOrder.apply(this, arguments);
|
|
5362
5650
|
}
|
|
5363
5651
|
return addProductsToOrder;
|
|
@@ -5409,7 +5697,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5409
5697
|
}, {
|
|
5410
5698
|
key: "hasSameEntitlementMergePriceConfig",
|
|
5411
5699
|
value: function hasSameEntitlementMergePriceConfig(incoming, existing) {
|
|
5412
|
-
var
|
|
5700
|
+
var _this35 = this;
|
|
5413
5701
|
var buildPriceConfig = function buildPriceConfig(product) {
|
|
5414
5702
|
var metadata = product.metadata || {};
|
|
5415
5703
|
var bundle = (product.product_bundle || []).map(function (item) {
|
|
@@ -5425,10 +5713,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5425
5713
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
5426
5714
|
});
|
|
5427
5715
|
return JSON.stringify({
|
|
5428
|
-
original_price:
|
|
5429
|
-
source_product_price:
|
|
5430
|
-
main_product_original_price:
|
|
5431
|
-
price_override:
|
|
5716
|
+
original_price: _this35.normalizeFingerprintMoney(product.original_price),
|
|
5717
|
+
source_product_price: _this35.normalizeFingerprintMoney(metadata.source_product_price),
|
|
5718
|
+
main_product_original_price: _this35.normalizeFingerprintMoney(metadata.main_product_original_price),
|
|
5719
|
+
price_override: _this35.normalizeFingerprintMoney(metadata.price_override),
|
|
5432
5720
|
is_manual_discount: Boolean(metadata.is_manual_discount),
|
|
5433
5721
|
bundle: bundle
|
|
5434
5722
|
});
|
|
@@ -5445,17 +5733,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5445
5733
|
}, {
|
|
5446
5734
|
key: "preservePersistedBundlePriceFields",
|
|
5447
5735
|
value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
|
|
5448
|
-
var
|
|
5736
|
+
var _this36 = this;
|
|
5449
5737
|
if (!Array.isArray(nextBundles)) return nextBundles;
|
|
5450
5738
|
if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
|
|
5451
5739
|
var previousByIdentity = new Map();
|
|
5452
5740
|
previousBundles.forEach(function (bundle) {
|
|
5453
|
-
var identity =
|
|
5741
|
+
var identity = _this36.getBundleRuntimeIdentity(bundle);
|
|
5454
5742
|
if (identity) previousByIdentity.set(identity, bundle);
|
|
5455
5743
|
});
|
|
5456
5744
|
return nextBundles.map(function (bundle, index) {
|
|
5457
5745
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
5458
|
-
var previous = previousByIdentity.get(
|
|
5746
|
+
var previous = previousByIdentity.get(_this36.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
|
|
5459
5747
|
if (!previous || _typeof(previous) !== 'object') return bundle;
|
|
5460
5748
|
return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
|
|
5461
5749
|
cover: previous.cover
|
|
@@ -5469,6 +5757,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5469
5757
|
});
|
|
5470
5758
|
});
|
|
5471
5759
|
}
|
|
5760
|
+
}, {
|
|
5761
|
+
key: "isRestrictedCartProductUpdate",
|
|
5762
|
+
value: function isRestrictedCartProductUpdate(tempOrder, params) {
|
|
5763
|
+
var _this$orderHooks4, _params$updates;
|
|
5764
|
+
if (!((_this$orderHooks4 = this.orderHooks) !== null && _this$orderHooks4 !== void 0 && _this$orderHooks4.beforeCartIntentCommit)) return false;
|
|
5765
|
+
if (params.booking || Object.keys(params.updates || {}).some(function (key) {
|
|
5766
|
+
return key !== 'num';
|
|
5767
|
+
})) {
|
|
5768
|
+
return true;
|
|
5769
|
+
}
|
|
5770
|
+
if (((_params$updates = params.updates) === null || _params$updates === void 0 ? void 0 : _params$updates.num) === undefined) return false;
|
|
5771
|
+
var uid = params.unique_identification_number;
|
|
5772
|
+
var product = uid !== undefined ? tempOrder.products.find(function (item) {
|
|
5773
|
+
var _item$metadata4;
|
|
5774
|
+
return String(((_item$metadata4 = item.metadata) === null || _item$metadata4 === void 0 ? void 0 : _item$metadata4.unique_identification_number) || item.unique_identification_number || '') === String(uid);
|
|
5775
|
+
}) : tempOrder.products[getProductIdentityIndex(tempOrder.products, params)];
|
|
5776
|
+
return !product || getSafeProductNum(params.updates.num) > product.num;
|
|
5777
|
+
}
|
|
5472
5778
|
}, {
|
|
5473
5779
|
key: "applyOrderProductUpdateToTempOrder",
|
|
5474
5780
|
value: function applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids) {
|
|
@@ -5500,8 +5806,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5500
5806
|
if (unique_identification_number !== undefined) {
|
|
5501
5807
|
var targetUid = String(unique_identification_number);
|
|
5502
5808
|
productIndex = tempOrder.products.findIndex(function (item) {
|
|
5503
|
-
var _item$
|
|
5504
|
-
return String(((_item$
|
|
5809
|
+
var _item$metadata5;
|
|
5810
|
+
return String(((_item$metadata5 = item.metadata) === null || _item$metadata5 === void 0 ? void 0 : _item$metadata5.unique_identification_number) || item.unique_identification_number || '') === targetUid;
|
|
5505
5811
|
});
|
|
5506
5812
|
}
|
|
5507
5813
|
if (productIndex === -1) {
|
|
@@ -5714,35 +6020,38 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5714
6020
|
while (1) switch (_context27.prev = _context27.next) {
|
|
5715
6021
|
case 0:
|
|
5716
6022
|
tempOrder = this.ensureTempOrder();
|
|
6023
|
+
if (this.isRestrictedCartProductUpdate(tempOrder, params)) {
|
|
6024
|
+
this.createCartIntentCommitGuard('update_product', tempOrder)();
|
|
6025
|
+
}
|
|
5717
6026
|
reapplyWeighedDiscountProductUids = [];
|
|
5718
6027
|
updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
|
|
5719
|
-
_context27.next =
|
|
6028
|
+
_context27.next = 6;
|
|
5720
6029
|
return this.evaluatePromotion();
|
|
5721
|
-
case
|
|
6030
|
+
case 6:
|
|
5722
6031
|
promotionPayload = _context27.sent;
|
|
5723
6032
|
this.applyDiscount({
|
|
5724
6033
|
reapplyWeighedDiscountProductUids: reapplyWeighedDiscountProductUids,
|
|
5725
6034
|
reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
|
|
5726
6035
|
});
|
|
5727
6036
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
5728
|
-
_context27.next =
|
|
6037
|
+
_context27.next = 11;
|
|
5729
6038
|
return this.recalculateSummary({
|
|
5730
6039
|
createIfMissing: true
|
|
5731
6040
|
});
|
|
5732
|
-
case
|
|
6041
|
+
case 11:
|
|
5733
6042
|
this.persistTempOrder();
|
|
5734
6043
|
this.emitPromotionApplied(promotionPayload);
|
|
5735
6044
|
this.logInfo('updateOrderProduct success', {
|
|
5736
6045
|
params: params
|
|
5737
6046
|
});
|
|
5738
6047
|
return _context27.abrupt("return", tempOrder.products);
|
|
5739
|
-
case
|
|
6048
|
+
case 15:
|
|
5740
6049
|
case "end":
|
|
5741
6050
|
return _context27.stop();
|
|
5742
6051
|
}
|
|
5743
6052
|
}, _callee25, this);
|
|
5744
6053
|
}));
|
|
5745
|
-
function updateOrderProduct(
|
|
6054
|
+
function updateOrderProduct(_x29) {
|
|
5746
6055
|
return _updateOrderProduct.apply(this, arguments);
|
|
5747
6056
|
}
|
|
5748
6057
|
return updateOrderProduct;
|
|
@@ -5751,7 +6060,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5751
6060
|
key: "updateOrderProducts",
|
|
5752
6061
|
value: function () {
|
|
5753
6062
|
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(paramsList) {
|
|
5754
|
-
var
|
|
6063
|
+
var _this37 = this;
|
|
5755
6064
|
var tempOrder, reapplyWeighedDiscountProductUids, reapplyBookingDiscountProductUids;
|
|
5756
6065
|
return _regeneratorRuntime().wrap(function _callee26$(_context28) {
|
|
5757
6066
|
while (1) switch (_context28.prev = _context28.next) {
|
|
@@ -5763,32 +6072,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5763
6072
|
}
|
|
5764
6073
|
return _context28.abrupt("return", tempOrder.products);
|
|
5765
6074
|
case 3:
|
|
6075
|
+
if (paramsList.some(function (params) {
|
|
6076
|
+
return _this37.isRestrictedCartProductUpdate(tempOrder, params);
|
|
6077
|
+
})) {
|
|
6078
|
+
this.createCartIntentCommitGuard('update_product', tempOrder)();
|
|
6079
|
+
}
|
|
5766
6080
|
reapplyWeighedDiscountProductUids = [];
|
|
5767
6081
|
reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
|
|
5768
|
-
var updatedProductUid =
|
|
6082
|
+
var updatedProductUid = _this37.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
|
|
5769
6083
|
// 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
|
|
5770
6084
|
if (params.allow_booking_discount_reapply && updatedProductUid) {
|
|
5771
6085
|
acc.push(String(updatedProductUid));
|
|
5772
6086
|
}
|
|
5773
6087
|
return acc;
|
|
5774
6088
|
}, []);
|
|
5775
|
-
_context28.next =
|
|
6089
|
+
_context28.next = 8;
|
|
5776
6090
|
return this.finalizeAfterProductsMutation(tempOrder, {
|
|
5777
6091
|
reapplyWeighedDiscountProductUids: reapplyWeighedDiscountProductUids,
|
|
5778
6092
|
reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
|
|
5779
6093
|
});
|
|
5780
|
-
case
|
|
6094
|
+
case 8:
|
|
5781
6095
|
this.logInfo('updateOrderProduct success', {
|
|
5782
6096
|
paramsList: paramsList
|
|
5783
6097
|
});
|
|
5784
6098
|
return _context28.abrupt("return", tempOrder.products);
|
|
5785
|
-
case
|
|
6099
|
+
case 10:
|
|
5786
6100
|
case "end":
|
|
5787
6101
|
return _context28.stop();
|
|
5788
6102
|
}
|
|
5789
6103
|
}, _callee26, this);
|
|
5790
6104
|
}));
|
|
5791
|
-
function updateOrderProducts(
|
|
6105
|
+
function updateOrderProducts(_x30) {
|
|
5792
6106
|
return _updateOrderProducts.apply(this, arguments);
|
|
5793
6107
|
}
|
|
5794
6108
|
return updateOrderProducts;
|
|
@@ -5796,12 +6110,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5796
6110
|
}, {
|
|
5797
6111
|
key: "updateOrderProductQuantity",
|
|
5798
6112
|
value: function () {
|
|
5799
|
-
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
|
|
5800
|
-
var _targetProduct$metada22;
|
|
5801
|
-
var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, isPersistedOrderLine, normalizedProduct, settlementSnapshot, currencyProductId, asset, requiredAmount, balance, isVirtualSettlement, promotionPayload;
|
|
6113
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params, options) {
|
|
6114
|
+
var _this$store$tempOrder9, _targetProduct$metada22;
|
|
6115
|
+
var isCurrentOrder, product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, isPersistedOrderLine, normalizedProduct, settlementSnapshot, currencyProductId, asset, requiredAmount, balance, isVirtualSettlement, promotionPayload;
|
|
5802
6116
|
return _regeneratorRuntime().wrap(function _callee27$(_context29) {
|
|
5803
6117
|
while (1) switch (_context29.prev = _context29.next) {
|
|
5804
6118
|
case 0:
|
|
6119
|
+
isCurrentOrder = options === null || options === void 0 ? void 0 : options.isCurrentOrder;
|
|
6120
|
+
if (!(isCurrentOrder && !isCurrentOrder())) {
|
|
6121
|
+
_context29.next = 3;
|
|
6122
|
+
break;
|
|
6123
|
+
}
|
|
6124
|
+
return _context29.abrupt("return", ((_this$store$tempOrder9 = this.store.tempOrder) === null || _this$store$tempOrder9 === void 0 ? void 0 : _this$store$tempOrder9.products) || []);
|
|
6125
|
+
case 3:
|
|
5805
6126
|
product_id = params.product_id, product_variant_id = params.product_variant_id, num = params.num, unique_identification_number = params.unique_identification_number, identity_key = params.identity_key, product_sku = params.product_sku, product_bundle = params.product_bundle;
|
|
5806
6127
|
tempOrder = this.ensureTempOrder();
|
|
5807
6128
|
this.repairDuplicateProductLineIdentities(tempOrder);
|
|
@@ -5822,19 +6143,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5822
6143
|
if (unique_identification_number !== undefined) {
|
|
5823
6144
|
targetUid = String(unique_identification_number);
|
|
5824
6145
|
productIndex = tempOrder.products.findIndex(function (item) {
|
|
5825
|
-
var _item$
|
|
5826
|
-
return String(((_item$
|
|
6146
|
+
var _item$metadata6;
|
|
6147
|
+
return String(((_item$metadata6 = item.metadata) === null || _item$metadata6 === void 0 ? void 0 : _item$metadata6.unique_identification_number) || item.unique_identification_number || '') === targetUid;
|
|
5827
6148
|
});
|
|
5828
6149
|
}
|
|
5829
6150
|
if (productIndex === -1) {
|
|
5830
6151
|
productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
|
|
5831
6152
|
}
|
|
5832
6153
|
if (!(productIndex === -1)) {
|
|
5833
|
-
_context29.next =
|
|
6154
|
+
_context29.next = 16;
|
|
5834
6155
|
break;
|
|
5835
6156
|
}
|
|
5836
6157
|
throw new Error('[Order] 目标商品不存在,无法更新数量');
|
|
5837
|
-
case
|
|
6158
|
+
case 16:
|
|
5838
6159
|
targetProduct = tempOrder.products[productIndex];
|
|
5839
6160
|
isPersistedOrderLine = targetProduct.order_detail_id !== undefined && targetProduct.order_detail_id !== null;
|
|
5840
6161
|
normalizedProduct = this.normalizeVirtualSettlementProductIfEnabled(normalizeOrderProduct(_objectSpread(_objectSpread({}, targetProduct), {}, {
|
|
@@ -5846,7 +6167,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5846
6167
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(isPersistedOrderLine ? syncReducedEntitlementPassUsageCount(normalizedProduct.discount_list, targetProduct.num, normalizedProduct.num) : normalizedProduct.discount_list);
|
|
5847
6168
|
settlementSnapshot = getSelectedSettlementSnapshot(normalizedProduct);
|
|
5848
6169
|
if (!(this.isMultiCurrencySettlementEnabled() && (settlementSnapshot === null || settlementSnapshot === void 0 ? void 0 : settlementSnapshot.settlement_type) === 'virtual_currency' && tempOrder.customer_id && Number(tempOrder.customer_id) !== 1)) {
|
|
5849
|
-
_context29.next =
|
|
6170
|
+
_context29.next = 30;
|
|
5850
6171
|
break;
|
|
5851
6172
|
}
|
|
5852
6173
|
currencyProductId = Number(settlementSnapshot.currency_product_id);
|
|
@@ -5854,11 +6175,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5854
6175
|
return Number(item === null || item === void 0 ? void 0 : item.product_id) === currencyProductId;
|
|
5855
6176
|
});
|
|
5856
6177
|
if (asset) {
|
|
5857
|
-
_context29.next =
|
|
6178
|
+
_context29.next = 26;
|
|
5858
6179
|
break;
|
|
5859
6180
|
}
|
|
5860
6181
|
throw new VirtualCurrencyAssetNotFoundError(currencyProductId);
|
|
5861
|
-
case
|
|
6182
|
+
case 26:
|
|
5862
6183
|
requiredAmount = tempOrder.products.reduce(function (sum, item, index) {
|
|
5863
6184
|
var current = index === productIndex ? normalizedProduct : item;
|
|
5864
6185
|
var currentSnapshot = getSelectedSettlementSnapshot(current);
|
|
@@ -5866,50 +6187,73 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5866
6187
|
}, new Decimal(0));
|
|
5867
6188
|
balance = new Decimal(asset.balance || 0);
|
|
5868
6189
|
if (!balance.lt(requiredAmount)) {
|
|
5869
|
-
_context29.next =
|
|
6190
|
+
_context29.next = 30;
|
|
5870
6191
|
break;
|
|
5871
6192
|
}
|
|
5872
6193
|
throw new VirtualCurrencyBalanceError(balance.toFixed(2), requiredAmount.toFixed(2));
|
|
5873
|
-
case
|
|
6194
|
+
case 30:
|
|
6195
|
+
if (normalizedProduct.num > targetProduct.num) {
|
|
6196
|
+
this.createCartIntentCommitGuard('increase_quantity', tempOrder)();
|
|
6197
|
+
}
|
|
6198
|
+
if (!(isCurrentOrder && !isCurrentOrder())) {
|
|
6199
|
+
_context29.next = 33;
|
|
6200
|
+
break;
|
|
6201
|
+
}
|
|
6202
|
+
return _context29.abrupt("return", tempOrder.products);
|
|
6203
|
+
case 33:
|
|
5874
6204
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
6205
|
+
if (!isCurrentOrder) {
|
|
6206
|
+
_context29.next = 39;
|
|
6207
|
+
break;
|
|
6208
|
+
}
|
|
6209
|
+
_context29.next = 37;
|
|
6210
|
+
return this.finalizeProductOrderMutation(tempOrder, {
|
|
6211
|
+
skipEditDiscountConfigRefresh: true,
|
|
6212
|
+
isCurrentOrder: isCurrentOrder
|
|
6213
|
+
});
|
|
6214
|
+
case 37:
|
|
6215
|
+
_context29.next = 55;
|
|
6216
|
+
break;
|
|
6217
|
+
case 39:
|
|
5875
6218
|
this.prepareVirtualSettlementTempOrder(tempOrder);
|
|
5876
6219
|
isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder);
|
|
5877
6220
|
if (isVirtualSettlement) {
|
|
5878
|
-
_context29.next =
|
|
6221
|
+
_context29.next = 47;
|
|
5879
6222
|
break;
|
|
5880
6223
|
}
|
|
5881
|
-
_context29.next =
|
|
6224
|
+
_context29.next = 44;
|
|
5882
6225
|
return this.evaluatePromotion();
|
|
5883
|
-
case
|
|
6226
|
+
case 44:
|
|
5884
6227
|
_context29.t0 = _context29.sent;
|
|
5885
|
-
_context29.next =
|
|
6228
|
+
_context29.next = 48;
|
|
5886
6229
|
break;
|
|
5887
|
-
case
|
|
6230
|
+
case 47:
|
|
5888
6231
|
_context29.t0 = null;
|
|
5889
|
-
case
|
|
6232
|
+
case 48:
|
|
5890
6233
|
promotionPayload = _context29.t0;
|
|
5891
6234
|
if (!isVirtualSettlement) {
|
|
5892
6235
|
this.applyDiscount();
|
|
5893
6236
|
}
|
|
5894
6237
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
5895
|
-
_context29.next =
|
|
6238
|
+
_context29.next = 53;
|
|
5896
6239
|
return this.recalculateSummary({
|
|
5897
6240
|
createIfMissing: true
|
|
5898
6241
|
});
|
|
5899
|
-
case
|
|
6242
|
+
case 53:
|
|
5900
6243
|
this.persistTempOrder();
|
|
5901
6244
|
this.emitPromotionApplied(promotionPayload);
|
|
6245
|
+
case 55:
|
|
5902
6246
|
this.logInfo('updateOrderProductQuantity success', {
|
|
5903
6247
|
params: params
|
|
5904
6248
|
});
|
|
5905
6249
|
return _context29.abrupt("return", tempOrder.products);
|
|
5906
|
-
case
|
|
6250
|
+
case 57:
|
|
5907
6251
|
case "end":
|
|
5908
6252
|
return _context29.stop();
|
|
5909
6253
|
}
|
|
5910
6254
|
}, _callee27, this);
|
|
5911
6255
|
}));
|
|
5912
|
-
function updateOrderProductQuantity(
|
|
6256
|
+
function updateOrderProductQuantity(_x31, _x32) {
|
|
5913
6257
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
5914
6258
|
}
|
|
5915
6259
|
return updateOrderProductQuantity;
|
|
@@ -5978,7 +6322,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5978
6322
|
}
|
|
5979
6323
|
}, _callee28, this);
|
|
5980
6324
|
}));
|
|
5981
|
-
function finalizeAfterProductsMutation(
|
|
6325
|
+
function finalizeAfterProductsMutation(_x33, _x34) {
|
|
5982
6326
|
return _finalizeAfterProductsMutation.apply(this, arguments);
|
|
5983
6327
|
}
|
|
5984
6328
|
return finalizeAfterProductsMutation;
|
|
@@ -5994,18 +6338,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5994
6338
|
key: "removeProductsFromOrder",
|
|
5995
6339
|
value: (function () {
|
|
5996
6340
|
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(identities, options) {
|
|
5997
|
-
var
|
|
5998
|
-
|
|
6341
|
+
var _this$store$tempOrder10,
|
|
6342
|
+
_this38 = this;
|
|
6343
|
+
var isCurrentOrder, tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
|
|
5999
6344
|
return _regeneratorRuntime().wrap(function _callee29$(_context32) {
|
|
6000
6345
|
while (1) switch (_context32.prev = _context32.next) {
|
|
6001
6346
|
case 0:
|
|
6347
|
+
isCurrentOrder = options === null || options === void 0 ? void 0 : options.isCurrentOrder;
|
|
6348
|
+
if (!(isCurrentOrder && !isCurrentOrder())) {
|
|
6349
|
+
_context32.next = 3;
|
|
6350
|
+
break;
|
|
6351
|
+
}
|
|
6352
|
+
return _context32.abrupt("return", ((_this$store$tempOrder10 = this.store.tempOrder) === null || _this$store$tempOrder10 === void 0 ? void 0 : _this$store$tempOrder10.products) || []);
|
|
6353
|
+
case 3:
|
|
6002
6354
|
tempOrder = this.ensureTempOrder();
|
|
6003
6355
|
if (identities.length) {
|
|
6004
|
-
_context32.next =
|
|
6356
|
+
_context32.next = 6;
|
|
6005
6357
|
break;
|
|
6006
6358
|
}
|
|
6007
6359
|
return _context32.abrupt("return", tempOrder.products);
|
|
6008
|
-
case
|
|
6360
|
+
case 6:
|
|
6009
6361
|
// 商品删除会同步删除以商品行为主关系的 Notes;快照不完整时禁止产生孤儿 Relation。
|
|
6010
6362
|
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
6011
6363
|
this.repairDuplicateProductLineIdentities(tempOrder);
|
|
@@ -6013,8 +6365,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6013
6365
|
bookingsBeforeRemove = tempOrder.bookings || [];
|
|
6014
6366
|
preserveDisplayPosition = options === null || options === void 0 ? void 0 : options.preserveDisplayPosition;
|
|
6015
6367
|
anchorIndex = preserveDisplayPosition ? productsBeforeRemove.findIndex(function (item) {
|
|
6016
|
-
var _item$
|
|
6017
|
-
var uid = ((_item$
|
|
6368
|
+
var _item$metadata7;
|
|
6369
|
+
var uid = ((_item$metadata7 = item.metadata) === null || _item$metadata7 === void 0 ? void 0 : _item$metadata7.unique_identification_number) || item.unique_identification_number;
|
|
6018
6370
|
return uid !== undefined && uid !== null && String(uid) === String(preserveDisplayPosition.anchorProductUid);
|
|
6019
6371
|
}) : -1;
|
|
6020
6372
|
productsAfterAnchor = anchorIndex >= 0 ? productsBeforeRemove.slice(anchorIndex + 1) : [];
|
|
@@ -6037,7 +6389,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6037
6389
|
}
|
|
6038
6390
|
linkedBookingUidsToRemove = new Set();
|
|
6039
6391
|
_iterator21 = _createForOfIteratorHelper(matchedProducts);
|
|
6040
|
-
_context32.prev =
|
|
6392
|
+
_context32.prev = 19;
|
|
6041
6393
|
_loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
|
|
6042
6394
|
var _metadata11, _metadata12, _metadata13, _metadata14;
|
|
6043
6395
|
var product, productUid, productBookingUid, isAddTimeProduct;
|
|
@@ -6059,7 +6411,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6059
6411
|
}
|
|
6060
6412
|
if (productUid !== undefined && productUid !== null && productUid !== '') {
|
|
6061
6413
|
bookingsBeforeRemove.forEach(function (booking) {
|
|
6062
|
-
var bookingUid =
|
|
6414
|
+
var bookingUid = _this38.getBookingUniqueIdentificationNumber(booking);
|
|
6063
6415
|
if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
|
|
6064
6416
|
linkedBookingUidsToRemove.add(bookingUid);
|
|
6065
6417
|
}
|
|
@@ -6072,33 +6424,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6072
6424
|
}, _loop3);
|
|
6073
6425
|
});
|
|
6074
6426
|
_iterator21.s();
|
|
6075
|
-
case
|
|
6427
|
+
case 22:
|
|
6076
6428
|
if ((_step21 = _iterator21.n()).done) {
|
|
6077
|
-
_context32.next =
|
|
6429
|
+
_context32.next = 28;
|
|
6078
6430
|
break;
|
|
6079
6431
|
}
|
|
6080
|
-
return _context32.delegateYield(_loop3(), "t0",
|
|
6081
|
-
case
|
|
6432
|
+
return _context32.delegateYield(_loop3(), "t0", 24);
|
|
6433
|
+
case 24:
|
|
6082
6434
|
if (!_context32.t0) {
|
|
6083
|
-
_context32.next =
|
|
6435
|
+
_context32.next = 26;
|
|
6084
6436
|
break;
|
|
6085
6437
|
}
|
|
6086
|
-
return _context32.abrupt("continue",
|
|
6087
|
-
case
|
|
6088
|
-
_context32.next =
|
|
6438
|
+
return _context32.abrupt("continue", 26);
|
|
6439
|
+
case 26:
|
|
6440
|
+
_context32.next = 22;
|
|
6089
6441
|
break;
|
|
6090
|
-
case
|
|
6091
|
-
_context32.next =
|
|
6442
|
+
case 28:
|
|
6443
|
+
_context32.next = 33;
|
|
6092
6444
|
break;
|
|
6093
|
-
case 27:
|
|
6094
|
-
_context32.prev = 27;
|
|
6095
|
-
_context32.t1 = _context32["catch"](16);
|
|
6096
|
-
_iterator21.e(_context32.t1);
|
|
6097
6445
|
case 30:
|
|
6098
6446
|
_context32.prev = 30;
|
|
6099
|
-
|
|
6100
|
-
|
|
6447
|
+
_context32.t1 = _context32["catch"](19);
|
|
6448
|
+
_iterator21.e(_context32.t1);
|
|
6101
6449
|
case 33:
|
|
6450
|
+
_context32.prev = 33;
|
|
6451
|
+
_iterator21.f();
|
|
6452
|
+
return _context32.finish(33);
|
|
6453
|
+
case 36:
|
|
6102
6454
|
if (linkedBookingUidsToRemove.size > 0) {
|
|
6103
6455
|
// 删除主预约商品时,同步移除挂在同一 booking_uid 下的加时商品,避免残留孤儿行。
|
|
6104
6456
|
tempOrder.products = (tempOrder.products || []).filter(function (line) {
|
|
@@ -6110,8 +6462,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6110
6462
|
}
|
|
6111
6463
|
if (preserveDisplayPosition && anchorIndex >= 0) {
|
|
6112
6464
|
remainingProductIndex = tempOrder.products.findIndex(function (item) {
|
|
6113
|
-
var _item$
|
|
6114
|
-
var uid = ((_item$
|
|
6465
|
+
var _item$metadata8;
|
|
6466
|
+
var uid = ((_item$metadata8 = item.metadata) === null || _item$metadata8 === void 0 ? void 0 : _item$metadata8.unique_identification_number) || item.unique_identification_number;
|
|
6115
6467
|
return uid !== undefined && uid !== null && String(uid) === String(preserveDisplayPosition.remainingProductUid);
|
|
6116
6468
|
});
|
|
6117
6469
|
if (remainingProductIndex >= 0) {
|
|
@@ -6125,20 +6477,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6125
6477
|
}
|
|
6126
6478
|
}
|
|
6127
6479
|
this.removeSalesNotesForMissingProductLines(tempOrder);
|
|
6128
|
-
|
|
6480
|
+
if (!isCurrentOrder) {
|
|
6481
|
+
_context32.next = 44;
|
|
6482
|
+
break;
|
|
6483
|
+
}
|
|
6484
|
+
_context32.next = 42;
|
|
6485
|
+
return this.finalizeProductOrderMutation(tempOrder, {
|
|
6486
|
+
skipEditDiscountConfigRefresh: true,
|
|
6487
|
+
isCurrentOrder: isCurrentOrder
|
|
6488
|
+
});
|
|
6489
|
+
case 42:
|
|
6490
|
+
_context32.next = 46;
|
|
6491
|
+
break;
|
|
6492
|
+
case 44:
|
|
6493
|
+
_context32.next = 46;
|
|
6129
6494
|
return this.finalizeAfterProductsMutation(tempOrder);
|
|
6130
|
-
case
|
|
6495
|
+
case 46:
|
|
6131
6496
|
this.logInfo('removeProductsFromOrder success', {
|
|
6132
6497
|
identities: identities
|
|
6133
6498
|
});
|
|
6134
6499
|
return _context32.abrupt("return", tempOrder.products);
|
|
6135
|
-
case
|
|
6500
|
+
case 48:
|
|
6136
6501
|
case "end":
|
|
6137
6502
|
return _context32.stop();
|
|
6138
6503
|
}
|
|
6139
|
-
}, _callee29, this, [[
|
|
6504
|
+
}, _callee29, this, [[19, 30, 33, 36]]);
|
|
6140
6505
|
}));
|
|
6141
|
-
function removeProductsFromOrder(
|
|
6506
|
+
function removeProductsFromOrder(_x35, _x36) {
|
|
6142
6507
|
return _removeProductsFromOrder.apply(this, arguments);
|
|
6143
6508
|
}
|
|
6144
6509
|
return removeProductsFromOrder;
|
|
@@ -6157,7 +6522,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6157
6522
|
}
|
|
6158
6523
|
}, _callee30, this);
|
|
6159
6524
|
}));
|
|
6160
|
-
function removeProductFromOrder(
|
|
6525
|
+
function removeProductFromOrder(_x37, _x38) {
|
|
6161
6526
|
return _removeProductFromOrder.apply(this, arguments);
|
|
6162
6527
|
}
|
|
6163
6528
|
return removeProductFromOrder;
|
|
@@ -6332,7 +6697,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6332
6697
|
}
|
|
6333
6698
|
}, _callee33, this);
|
|
6334
6699
|
}));
|
|
6335
|
-
function applyLocalPrintOrderNumbers(
|
|
6700
|
+
function applyLocalPrintOrderNumbers(_x39) {
|
|
6336
6701
|
return _applyLocalPrintOrderNumbers.apply(this, arguments);
|
|
6337
6702
|
}
|
|
6338
6703
|
return applyLocalPrintOrderNumbers;
|
|
@@ -6399,7 +6764,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6399
6764
|
}
|
|
6400
6765
|
}, _callee34, this);
|
|
6401
6766
|
}));
|
|
6402
|
-
function saveTempOrderAsDraft(
|
|
6767
|
+
function saveTempOrderAsDraft(_x40) {
|
|
6403
6768
|
return _saveTempOrderAsDraft.apply(this, arguments);
|
|
6404
6769
|
}
|
|
6405
6770
|
return saveTempOrderAsDraft;
|
|
@@ -6424,7 +6789,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6424
6789
|
}
|
|
6425
6790
|
}, _callee35, this);
|
|
6426
6791
|
}));
|
|
6427
|
-
function submitTempOrder(
|
|
6792
|
+
function submitTempOrder(_x41) {
|
|
6428
6793
|
return _submitTempOrder.apply(this, arguments);
|
|
6429
6794
|
}
|
|
6430
6795
|
return submitTempOrder;
|
|
@@ -6445,7 +6810,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6445
6810
|
}
|
|
6446
6811
|
}, _callee36, this);
|
|
6447
6812
|
}));
|
|
6448
|
-
function submitTempOrderAsync(
|
|
6813
|
+
function submitTempOrderAsync(_x42) {
|
|
6449
6814
|
return _submitTempOrderAsync.apply(this, arguments);
|
|
6450
6815
|
}
|
|
6451
6816
|
return submitTempOrderAsync;
|
|
@@ -6460,6 +6825,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6460
6825
|
while (1) switch (_context40.prev = _context40.next) {
|
|
6461
6826
|
case 0:
|
|
6462
6827
|
tempOrder = this.ensureTempOrder();
|
|
6828
|
+
if (!requiresLocalPaymentRefresh(tempOrder)) {
|
|
6829
|
+
_context40.next = 3;
|
|
6830
|
+
break;
|
|
6831
|
+
}
|
|
6832
|
+
throw new Error(PAYMENT_REFRESH_MESSAGE);
|
|
6833
|
+
case 3:
|
|
6463
6834
|
this.prepareVirtualSettlementTempOrder(tempOrder);
|
|
6464
6835
|
isOnlineStorePlatform = this.isOnlineStorePlatform();
|
|
6465
6836
|
shouldConfirmPendingVoucherPayments = (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== false;
|
|
@@ -6481,25 +6852,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6481
6852
|
}
|
|
6482
6853
|
}
|
|
6483
6854
|
this.persistTempOrder();
|
|
6484
|
-
_context40.next =
|
|
6855
|
+
_context40.next = 12;
|
|
6485
6856
|
return this.recalculateSummary({
|
|
6486
6857
|
createIfMissing: true
|
|
6487
6858
|
});
|
|
6488
|
-
case
|
|
6859
|
+
case 12:
|
|
6489
6860
|
_context40.t1 = _context40.sent;
|
|
6490
6861
|
if (_context40.t1) {
|
|
6491
|
-
_context40.next =
|
|
6862
|
+
_context40.next = 15;
|
|
6492
6863
|
break;
|
|
6493
6864
|
}
|
|
6494
6865
|
_context40.t1 = this.store.summary;
|
|
6495
|
-
case
|
|
6866
|
+
case 15:
|
|
6496
6867
|
_context40.t0 = _context40.t1;
|
|
6497
6868
|
if (_context40.t0) {
|
|
6498
|
-
_context40.next =
|
|
6869
|
+
_context40.next = 18;
|
|
6499
6870
|
break;
|
|
6500
6871
|
}
|
|
6501
6872
|
_context40.t0 = createEmptySummary();
|
|
6502
|
-
case
|
|
6873
|
+
case 18:
|
|
6503
6874
|
latestSummary = _context40.t0;
|
|
6504
6875
|
effectiveCacheId = (_params$cacheId3 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId3 !== void 0 ? _params$cacheId3 : this.cacheId;
|
|
6505
6876
|
hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
|
|
@@ -6536,10 +6907,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6536
6907
|
if (!payload.created_at) {
|
|
6537
6908
|
payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
6538
6909
|
}
|
|
6539
|
-
_context40.next =
|
|
6910
|
+
_context40.next = 30;
|
|
6540
6911
|
return this.saveDraft();
|
|
6541
|
-
case
|
|
6542
|
-
_context40.prev =
|
|
6912
|
+
case 30:
|
|
6913
|
+
_context40.prev = 30;
|
|
6543
6914
|
this.logInfo('submitTempOrder calling sales checkout', {
|
|
6544
6915
|
orderId: payload.order_id,
|
|
6545
6916
|
externalSaleNumber: payload.external_sale_number,
|
|
@@ -6549,26 +6920,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6549
6920
|
smallTicketDataFlag: payload.small_ticket_data_flag,
|
|
6550
6921
|
syncMode: payload.sync_mode
|
|
6551
6922
|
});
|
|
6552
|
-
_context40.next =
|
|
6923
|
+
_context40.next = 34;
|
|
6553
6924
|
return this.submitSalesOrder({
|
|
6554
6925
|
query: payload
|
|
6555
6926
|
});
|
|
6556
|
-
case
|
|
6927
|
+
case 34:
|
|
6557
6928
|
result = _context40.sent;
|
|
6558
|
-
_context40.next =
|
|
6929
|
+
_context40.next = 47;
|
|
6559
6930
|
break;
|
|
6560
|
-
case
|
|
6561
|
-
_context40.prev =
|
|
6562
|
-
_context40.t2 = _context40["catch"](
|
|
6931
|
+
case 37:
|
|
6932
|
+
_context40.prev = 37;
|
|
6933
|
+
_context40.t2 = _context40["catch"](30);
|
|
6563
6934
|
backendErrorResponse = this.extractSubmitErrorResponse(_context40.t2);
|
|
6564
6935
|
if (!backendErrorResponse) {
|
|
6565
|
-
_context40.next =
|
|
6936
|
+
_context40.next = 44;
|
|
6566
6937
|
break;
|
|
6567
6938
|
}
|
|
6568
6939
|
this.store.syncState = 'failed';
|
|
6569
6940
|
this.logSubmitBackendRejected(backendErrorResponse, payload);
|
|
6570
6941
|
return _context40.abrupt("return", backendErrorResponse);
|
|
6571
|
-
case
|
|
6942
|
+
case 44:
|
|
6572
6943
|
this.store.syncState = 'failed';
|
|
6573
6944
|
this.logError('submitTempOrder failed', {
|
|
6574
6945
|
error: _context40.t2 instanceof Error ? _context40.t2.message : String(_context40.t2),
|
|
@@ -6578,15 +6949,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6578
6949
|
paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
|
|
6579
6950
|
});
|
|
6580
6951
|
throw _context40.t2;
|
|
6581
|
-
case
|
|
6952
|
+
case 47:
|
|
6582
6953
|
if (!this.isSubmitResponseRejected(result)) {
|
|
6583
|
-
_context40.next =
|
|
6954
|
+
_context40.next = 51;
|
|
6584
6955
|
break;
|
|
6585
6956
|
}
|
|
6586
6957
|
this.store.syncState = 'failed';
|
|
6587
6958
|
this.logSubmitBackendRejected(result, payload);
|
|
6588
6959
|
return _context40.abrupt("return", result);
|
|
6589
|
-
case
|
|
6960
|
+
case 51:
|
|
6590
6961
|
isLocalPendingSubmit = this.isLocalPendingSubmitResult(result); // need_sync=1 仅表示已进入本地同步队列,不能视为远端已确认 Notes。
|
|
6591
6962
|
if (Object.prototype.hasOwnProperty.call(payload, 'notes') && !isLocalPendingSubmit) {
|
|
6592
6963
|
salesNotesState = this.ensureSalesNotesRuntimeState(tempOrder);
|
|
@@ -6601,27 +6972,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6601
6972
|
})
|
|
6602
6973
|
});
|
|
6603
6974
|
if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
|
|
6604
|
-
_context40.next =
|
|
6975
|
+
_context40.next = 60;
|
|
6605
6976
|
break;
|
|
6606
6977
|
}
|
|
6607
6978
|
tempOrder.order_id = submittedOrderId;
|
|
6608
6979
|
resultRecord = result;
|
|
6609
|
-
_context40.next =
|
|
6980
|
+
_context40.next = 60;
|
|
6610
6981
|
return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
|
|
6611
|
-
case
|
|
6982
|
+
case 60:
|
|
6612
6983
|
if (isLocalPendingSubmit) {
|
|
6613
6984
|
this.store.syncState = 'local';
|
|
6614
6985
|
} else if (submittedOrderId === null || submittedOrderId === undefined) {
|
|
6615
6986
|
this.store.syncState = 'submitted';
|
|
6616
6987
|
}
|
|
6617
6988
|
return _context40.abrupt("return", result);
|
|
6618
|
-
case
|
|
6989
|
+
case 62:
|
|
6619
6990
|
case "end":
|
|
6620
6991
|
return _context40.stop();
|
|
6621
6992
|
}
|
|
6622
|
-
}, _callee37, this, [[
|
|
6993
|
+
}, _callee37, this, [[30, 37]]);
|
|
6623
6994
|
}));
|
|
6624
|
-
function runSubmitTempOrder(
|
|
6995
|
+
function runSubmitTempOrder(_x43) {
|
|
6625
6996
|
return _runSubmitTempOrder.apply(this, arguments);
|
|
6626
6997
|
}
|
|
6627
6998
|
return runSubmitTempOrder;
|
|
@@ -6648,7 +7019,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6648
7019
|
}
|
|
6649
7020
|
}, _callee38, this);
|
|
6650
7021
|
}));
|
|
6651
|
-
function markLocalOrderSynced(
|
|
7022
|
+
function markLocalOrderSynced(_x44, _x45) {
|
|
6652
7023
|
return _markLocalOrderSynced.apply(this, arguments);
|
|
6653
7024
|
}
|
|
6654
7025
|
return markLocalOrderSynced;
|
|
@@ -6691,10 +7062,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6691
7062
|
value: function extractSubmitErrorResponse(error) {
|
|
6692
7063
|
var _error$response,
|
|
6693
7064
|
_error$response2,
|
|
6694
|
-
|
|
7065
|
+
_this39 = this;
|
|
6695
7066
|
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
7067
|
return candidates.find(function (candidate) {
|
|
6697
|
-
return
|
|
7068
|
+
return _this39.isSubmitErrorResponse(candidate);
|
|
6698
7069
|
}) || null;
|
|
6699
7070
|
}
|
|
6700
7071
|
}, {
|
|
@@ -6722,7 +7093,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6722
7093
|
key: "syncPaymentsToOrder",
|
|
6723
7094
|
value: function () {
|
|
6724
7095
|
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
|
|
6725
|
-
var
|
|
7096
|
+
var _this40 = this,
|
|
6726
7097
|
_params$confirmPendin;
|
|
6727
7098
|
var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, enhancePayload, submitParams, submitResult;
|
|
6728
7099
|
return _regeneratorRuntime().wrap(function _callee39$(_context42) {
|
|
@@ -6747,7 +7118,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6747
7118
|
case 9:
|
|
6748
7119
|
devicePrefix = _context42.t0;
|
|
6749
7120
|
mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
|
|
6750
|
-
return
|
|
7121
|
+
return _this40.normalizePaymentSource(payment, {
|
|
6751
7122
|
defaultPaid: false,
|
|
6752
7123
|
devicePrefix: devicePrefix
|
|
6753
7124
|
});
|
|
@@ -6818,7 +7189,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6818
7189
|
}
|
|
6819
7190
|
}, _callee39, this);
|
|
6820
7191
|
}));
|
|
6821
|
-
function syncPaymentsToOrder(
|
|
7192
|
+
function syncPaymentsToOrder(_x46) {
|
|
6822
7193
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
6823
7194
|
}
|
|
6824
7195
|
return syncPaymentsToOrder;
|
|
@@ -6826,7 +7197,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6826
7197
|
}, {
|
|
6827
7198
|
key: "createOrder",
|
|
6828
7199
|
value: function createOrder(params) {
|
|
6829
|
-
var
|
|
7200
|
+
var _this41 = this;
|
|
6830
7201
|
var order = _objectSpread({
|
|
6831
7202
|
type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
|
|
6832
7203
|
// 要从外面拿,virtual
|
|
@@ -6858,7 +7229,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6858
7229
|
|
|
6859
7230
|
// 为预约补齐 holder 信息
|
|
6860
7231
|
if (params !== null && params !== void 0 && (_params$extraData = params.extraData) !== null && _params$extraData !== void 0 && _params$extraData.is_add_holder_info) {
|
|
6861
|
-
ensureCartItemOriginHolder(item,
|
|
7232
|
+
ensureCartItemOriginHolder(item, _this41.window);
|
|
6862
7233
|
}
|
|
6863
7234
|
|
|
6864
7235
|
// 购物车是否为普通商品
|
|
@@ -6946,7 +7317,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6946
7317
|
}
|
|
6947
7318
|
}, _callee40, this);
|
|
6948
7319
|
}));
|
|
6949
|
-
function submitOrder(
|
|
7320
|
+
function submitOrder(_x47) {
|
|
6950
7321
|
return _submitOrder.apply(this, arguments);
|
|
6951
7322
|
}
|
|
6952
7323
|
return submitOrder;
|
|
@@ -6985,7 +7356,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6985
7356
|
}
|
|
6986
7357
|
}, _callee41, this);
|
|
6987
7358
|
}));
|
|
6988
|
-
function cancelOrder(
|
|
7359
|
+
function cancelOrder(_x48) {
|
|
6989
7360
|
return _cancelOrder.apply(this, arguments);
|
|
6990
7361
|
}
|
|
6991
7362
|
return cancelOrder;
|
|
@@ -7029,7 +7400,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7029
7400
|
}
|
|
7030
7401
|
}, _callee42, this);
|
|
7031
7402
|
}));
|
|
7032
|
-
function changeBookingStatus(
|
|
7403
|
+
function changeBookingStatus(_x49) {
|
|
7033
7404
|
return _changeBookingStatus.apply(this, arguments);
|
|
7034
7405
|
}
|
|
7035
7406
|
return changeBookingStatus;
|
|
@@ -7149,7 +7520,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7149
7520
|
}
|
|
7150
7521
|
}, _callee43, this, [[3, 15]]);
|
|
7151
7522
|
}));
|
|
7152
|
-
function createOrderByCheckout(
|
|
7523
|
+
function createOrderByCheckout(_x50) {
|
|
7153
7524
|
return _createOrderByCheckout.apply(this, arguments);
|
|
7154
7525
|
}
|
|
7155
7526
|
return createOrderByCheckout;
|
|
@@ -7164,7 +7535,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7164
7535
|
case 0:
|
|
7165
7536
|
url = params.url, query = params.query;
|
|
7166
7537
|
fetchUrl = url || '/order/sales/checkout';
|
|
7167
|
-
requestQuery = this.isSalesCheckoutHandledByOsServer(fetchUrl) ? query : stripOsPrivatePayloadFields(query);
|
|
7538
|
+
requestQuery = this.isSalesCheckoutHandledByOsServer(fetchUrl) ? query : stripLocalEftposState(stripOsPrivatePayloadFields(query));
|
|
7168
7539
|
return _context47.abrupt("return", this.request.post(fetchUrl, requestQuery, {
|
|
7169
7540
|
osServer: true,
|
|
7170
7541
|
customToast: function customToast() {}
|
|
@@ -7175,7 +7546,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7175
7546
|
}
|
|
7176
7547
|
}, _callee44, this);
|
|
7177
7548
|
}));
|
|
7178
|
-
function submitSalesOrder(
|
|
7549
|
+
function submitSalesOrder(_x51) {
|
|
7179
7550
|
return _submitSalesOrder.apply(this, arguments);
|
|
7180
7551
|
}
|
|
7181
7552
|
return submitSalesOrder;
|
|
@@ -7232,7 +7603,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7232
7603
|
}
|
|
7233
7604
|
}, _callee45, this);
|
|
7234
7605
|
}));
|
|
7235
|
-
function sendCustomerPayLink(
|
|
7606
|
+
function sendCustomerPayLink(_x52) {
|
|
7236
7607
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
7237
7608
|
}
|
|
7238
7609
|
return sendCustomerPayLink;
|
|
@@ -7257,12 +7628,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7257
7628
|
params.forceRemote = false;
|
|
7258
7629
|
}
|
|
7259
7630
|
_context49.next = 6;
|
|
7260
|
-
return this.request
|
|
7261
|
-
|
|
7262
|
-
|
|
7263
|
-
forceRemote:
|
|
7264
|
-
} : {}), {
|
|
7265
|
-
osServer: true
|
|
7631
|
+
return loadSalesOrderSnapshot(this.request, {
|
|
7632
|
+
lookup: lookup,
|
|
7633
|
+
transport: 'os-server',
|
|
7634
|
+
forceRemote: params.forceRemote
|
|
7266
7635
|
});
|
|
7267
7636
|
case 6:
|
|
7268
7637
|
res = _context49.sent;
|
|
@@ -7276,7 +7645,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7276
7645
|
}
|
|
7277
7646
|
}, _callee46, this);
|
|
7278
7647
|
}));
|
|
7279
|
-
function getSalesOrderByLookup(
|
|
7648
|
+
function getSalesOrderByLookup(_x53) {
|
|
7280
7649
|
return _getSalesOrderByLookup.apply(this, arguments);
|
|
7281
7650
|
}
|
|
7282
7651
|
return getSalesOrderByLookup;
|
|
@@ -7447,7 +7816,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7447
7816
|
}
|
|
7448
7817
|
}, _callee47, this);
|
|
7449
7818
|
}));
|
|
7450
|
-
function hydrateTempOrderFromRecord(
|
|
7819
|
+
function hydrateTempOrderFromRecord(_x54, _x55) {
|
|
7451
7820
|
return _hydrateTempOrderFromRecord.apply(this, arguments);
|
|
7452
7821
|
}
|
|
7453
7822
|
return hydrateTempOrderFromRecord;
|
|
@@ -7561,7 +7930,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7561
7930
|
}, {
|
|
7562
7931
|
key: "normalizeTempOrderForRuntime",
|
|
7563
7932
|
value: function normalizeTempOrderForRuntime(raw, options) {
|
|
7564
|
-
var
|
|
7933
|
+
var _this42 = this,
|
|
7565
7934
|
_raw$_extend;
|
|
7566
7935
|
var runtimeRaw = this.withoutSyntheticDraftOrderIdForRuntime(raw);
|
|
7567
7936
|
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
|
|
@@ -7586,12 +7955,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7586
7955
|
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
7587
7956
|
var rawProducts = Array.isArray(raw.products) ? raw.products : [];
|
|
7588
7957
|
nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
|
|
7589
|
-
return
|
|
7958
|
+
return _this42.normalizeHydratedOrderProduct(p, {
|
|
7590
7959
|
makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
|
|
7591
7960
|
});
|
|
7592
7961
|
}) : [];
|
|
7593
7962
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
7594
|
-
var booking =
|
|
7963
|
+
var booking = _this42.normalizeHydratedBookingHolder(b || {});
|
|
7595
7964
|
return _objectSpread(_objectSpread({}, booking), {}, {
|
|
7596
7965
|
is_all: normalizeBookingIsAll(booking),
|
|
7597
7966
|
sub_type: normalizeBookingSubType(booking)
|
|
@@ -7798,7 +8167,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7798
8167
|
}, {
|
|
7799
8168
|
key: "normalizeHydratedOrderProduct",
|
|
7800
8169
|
value: function normalizeHydratedOrderProduct(product, options) {
|
|
7801
|
-
var
|
|
8170
|
+
var _this43 = this;
|
|
7802
8171
|
var row = _objectSpread({}, product || {});
|
|
7803
8172
|
if (row.num === undefined && row.product_quantity !== undefined) {
|
|
7804
8173
|
row.num = row.product_quantity;
|
|
@@ -7806,7 +8175,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7806
8175
|
var productSku = ensureProductSku(row);
|
|
7807
8176
|
row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
|
|
7808
8177
|
option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
|
|
7809
|
-
return
|
|
8178
|
+
return _this43.normalizeHydratedProductOptionItem(optionItem || {});
|
|
7810
8179
|
}))
|
|
7811
8180
|
});
|
|
7812
8181
|
delete row["product_".concat('option', "_item")];
|
|
@@ -7886,7 +8255,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7886
8255
|
}
|
|
7887
8256
|
}, _callee48, this);
|
|
7888
8257
|
}));
|
|
7889
|
-
function getOrderInfo(
|
|
8258
|
+
function getOrderInfo(_x56) {
|
|
7890
8259
|
return _getOrderInfo.apply(this, arguments);
|
|
7891
8260
|
}
|
|
7892
8261
|
return getOrderInfo;
|
|
@@ -7894,8 +8263,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7894
8263
|
}, {
|
|
7895
8264
|
key: "getVouchers",
|
|
7896
8265
|
value: function getVouchers() {
|
|
7897
|
-
var _this$store$
|
|
7898
|
-
return ((_this$store$
|
|
8266
|
+
var _this$store$tempOrder11;
|
|
8267
|
+
return ((_this$store$tempOrder11 = this.store.tempOrder) === null || _this$store$tempOrder11 === void 0 ? void 0 : _this$store$tempOrder11.vouchers) || [];
|
|
7899
8268
|
}
|
|
7900
8269
|
}], [{
|
|
7901
8270
|
key: "populateSavedAmounts",
|
|
@@ -7989,4 +8358,5 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7989
8358
|
}
|
|
7990
8359
|
}]);
|
|
7991
8360
|
return OrderModule;
|
|
7992
|
-
}(BaseModule);
|
|
8361
|
+
}(BaseModule);
|
|
8362
|
+
export { isFulfillmentTimingBooking } from "./pickupTiming";
|