@pisell/pisellos 2.2.302 → 2.2.304
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +287 -101
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +25 -0
- package/dist/model/strategy/adapter/itemRule/adapter.d.ts +4 -1
- package/dist/model/strategy/adapter/itemRule/adapter.js +135 -35
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +8 -1
- package/dist/model/strategy/adapter/itemRule/evaluator.js +25 -1
- package/dist/model/strategy/adapter/itemRule/type.d.ts +44 -0
- package/dist/model/strategy/adapter/itemRule/type.js +19 -1
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +10 -7
- package/dist/modules/Discount/index.d.ts +2 -0
- package/dist/modules/Discount/index.js +41 -5
- package/dist/modules/Discount/types.d.ts +21 -0
- package/dist/modules/OpenData/index.d.ts +15 -2
- package/dist/modules/OpenData/index.js +307 -19
- package/dist/modules/OpenData/types.d.ts +55 -0
- package/dist/modules/OpenData/types.js +7 -1
- package/dist/modules/OpenData/utils.d.ts +21 -1
- package/dist/modules/OpenData/utils.js +138 -0
- package/dist/modules/Order/index.d.ts +50 -7
- package/dist/modules/Order/index.js +1690 -815
- package/dist/modules/Order/salesNotes.d.ts +31 -0
- package/dist/modules/Order/salesNotes.js +492 -0
- package/dist/modules/Order/types.d.ts +117 -10
- package/dist/modules/Order/types.js +6 -1
- package/dist/modules/Order/utils/virtualSettlement.d.ts +63 -0
- package/dist/modules/Order/utils/virtualSettlement.js +284 -0
- package/dist/modules/Order/utils.d.ts +5 -1
- package/dist/modules/Order/utils.js +138 -33
- package/dist/modules/Payment/cashRecommendationAlgorithm.d.ts +4 -5
- package/dist/modules/Payment/cashRecommendationAlgorithm.js +17 -367
- package/dist/modules/Payment/walletpass.js +20 -21
- package/dist/modules/Product/types.d.ts +23 -0
- package/dist/modules/ProductList/index.d.ts +2 -1
- package/dist/modules/ProductList/index.js +100 -20
- package/dist/modules/ProductList/types.d.ts +10 -0
- package/dist/modules/Rules/index.d.ts +5 -0
- package/dist/modules/Rules/index.js +30 -14
- package/dist/modules/SalesSummary/index.d.ts +1 -0
- package/dist/modules/SalesSummary/index.js +4 -3
- package/dist/modules/SalesSummary/types.d.ts +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +1 -0
- package/dist/modules/SalesSummary/utils.js +21 -1
- package/dist/plugins/request.d.ts +2 -1
- package/dist/plugins/request.js +4 -2
- package/dist/server/index.d.ts +21 -0
- package/dist/server/index.js +1774 -1285
- package/dist/server/modules/order/types.d.ts +50 -0
- package/dist/server/modules/order/types.js +2 -0
- package/dist/server/utils/small-ticket.d.ts +4 -1
- package/dist/server/utils/small-ticket.js +461 -96
- package/dist/solution/BaseSales/index.d.ts +24 -3
- package/dist/solution/BaseSales/index.js +1484 -873
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +2 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +1 -1
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +72 -9
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +22 -5
- package/dist/solution/BookingTicket/index.js +558 -443
- package/dist/solution/BookingTicket/utils/addProductDecision.js +2 -1
- package/dist/solution/BookingTicket/utils/orderCustomer.js +3 -2
- package/dist/solution/RegisterAndLogin/config.d.ts +9 -3
- package/dist/solution/RegisterAndLogin/config.js +95 -40
- package/dist/solution/RegisterAndLogin/index.js +4 -1
- package/dist/solution/Sales/index.d.ts +16 -1
- package/dist/solution/Sales/index.js +338 -63
- package/dist/solution/Sales/types.d.ts +10 -0
- package/dist/solution/ScanOrder/index.d.ts +1 -0
- package/dist/solution/ScanOrder/index.js +31 -27
- package/dist/solution/ScanOrder/utils.d.ts +1 -0
- package/dist/solution/ScanOrder/utils.js +2 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +20 -6
- package/dist/solution/UnifiedBookingSales/index.js +874 -527
- package/dist/solution/UnifiedBookingSales/types.d.ts +21 -2
- package/dist/solution/VenueBooking/index.d.ts +1 -0
- package/dist/solution/VenueBooking/index.js +8 -4
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +137 -6
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +25 -0
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +4 -1
- package/lib/model/strategy/adapter/itemRule/adapter.js +73 -4
- package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +8 -1
- package/lib/model/strategy/adapter/itemRule/evaluator.js +23 -1
- package/lib/model/strategy/adapter/itemRule/type.d.ts +44 -0
- package/lib/model/strategy/adapter/itemRule/type.js +19 -1
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +4 -0
- package/lib/modules/Discount/index.d.ts +2 -0
- package/lib/modules/Discount/index.js +34 -2
- package/lib/modules/Discount/types.d.ts +21 -0
- package/lib/modules/OpenData/index.d.ts +15 -2
- package/lib/modules/OpenData/index.js +230 -3
- package/lib/modules/OpenData/types.d.ts +55 -0
- package/lib/modules/OpenData/types.js +9 -1
- package/lib/modules/OpenData/utils.d.ts +21 -1
- package/lib/modules/OpenData/utils.js +126 -0
- package/lib/modules/Order/index.d.ts +50 -7
- package/lib/modules/Order/index.js +704 -64
- package/lib/modules/Order/salesNotes.d.ts +31 -0
- package/lib/modules/Order/salesNotes.js +382 -0
- package/lib/modules/Order/types.d.ts +117 -10
- package/lib/modules/Order/types.js +5 -1
- package/lib/modules/Order/utils/virtualSettlement.d.ts +63 -0
- package/lib/modules/Order/utils/virtualSettlement.js +262 -0
- package/lib/modules/Order/utils.d.ts +5 -1
- package/lib/modules/Order/utils.js +127 -21
- package/lib/modules/Payment/cashRecommendationAlgorithm.d.ts +4 -5
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +9 -354
- package/lib/modules/Payment/walletpass.js +14 -11
- package/lib/modules/Product/types.d.ts +23 -0
- package/lib/modules/ProductList/index.d.ts +2 -1
- package/lib/modules/ProductList/index.js +47 -2
- package/lib/modules/ProductList/types.d.ts +10 -0
- package/lib/modules/Rules/index.d.ts +5 -0
- package/lib/modules/Rules/index.js +22 -12
- package/lib/modules/SalesSummary/index.d.ts +1 -0
- package/lib/modules/SalesSummary/index.js +4 -2
- package/lib/modules/SalesSummary/types.d.ts +1 -0
- package/lib/modules/SalesSummary/utils.d.ts +1 -0
- package/lib/modules/SalesSummary/utils.js +17 -1
- package/lib/plugins/request.d.ts +2 -1
- package/lib/plugins/request.js +3 -2
- package/lib/server/index.d.ts +21 -0
- package/lib/server/index.js +492 -108
- package/lib/server/modules/order/types.d.ts +50 -0
- package/lib/server/modules/order/types.js +1 -0
- package/lib/server/utils/small-ticket.d.ts +4 -1
- package/lib/server/utils/small-ticket.js +427 -72
- package/lib/solution/BaseSales/index.d.ts +24 -3
- package/lib/solution/BaseSales/index.js +433 -30
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +2 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +1 -1
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +38 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +22 -5
- package/lib/solution/BookingTicket/index.js +60 -15
- package/lib/solution/BookingTicket/utils/addProductDecision.js +1 -0
- package/lib/solution/BookingTicket/utils/orderCustomer.js +2 -1
- package/lib/solution/RegisterAndLogin/config.d.ts +9 -3
- package/lib/solution/RegisterAndLogin/config.js +49 -8
- package/lib/solution/RegisterAndLogin/index.js +4 -1
- package/lib/solution/Sales/index.d.ts +16 -1
- package/lib/solution/Sales/index.js +168 -1
- package/lib/solution/Sales/types.d.ts +10 -0
- package/lib/solution/ScanOrder/index.d.ts +1 -0
- package/lib/solution/ScanOrder/index.js +5 -1
- package/lib/solution/ScanOrder/utils.d.ts +1 -0
- package/lib/solution/ScanOrder/utils.js +1 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +20 -6
- package/lib/solution/UnifiedBookingSales/index.js +169 -16
- package/lib/solution/UnifiedBookingSales/types.d.ts +21 -2
- package/lib/solution/VenueBooking/index.d.ts +1 -0
- package/lib/solution/VenueBooking/index.js +5 -1
- package/package.json +1 -1
|
@@ -32,9 +32,10 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
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
33
|
import { BaseModule } from "../BaseModule";
|
|
34
34
|
import { OrderHooks } from "./types";
|
|
35
|
-
import { composeLinePrice, generateDuration, getAllDiscountList, mergeRelationForms, ensureCartItemOriginHolder, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, isTempOrder, normalizeBookingIsAll, normalizeBookingSubType, mapPaymentItemsToOrderPayments, normalizeOrderProductDiscountList, resolveEffectivePerUnitDiscount, ensureProductSku, getProductSkuOptions, normalizeProductSkuOptions, sumOptionUnitPrice, clearTempOrderHolderAssignments, getOrderProductLineUid, indexOrderProductsByUid, calculateOrderProductsDeposit, mergeOrderProductDisplayFields, resolveIsFormSubject } from "./utils";
|
|
35
|
+
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, buildPointCardSnapshotFromWalletPassList, mergeOrderProductDisplayFields, resolveIsFormSubject, isMarkdownBundle } from "./utils";
|
|
36
36
|
import { isNormalProduct } from "../Product/utils";
|
|
37
37
|
import dayjs from 'dayjs';
|
|
38
|
+
import { buildSalesNoteText, decodeSalesNotesSnapshot, getSalesNotePolicy } from "./salesNotes";
|
|
38
39
|
import { ensureOrderPaymentNumber, mergeOrderPaymentRecord, resolveOrderPaymentIdentity } from "./payment-utils";
|
|
39
40
|
import { resolvePaymentNumberDevicePrefix, resolvePaymentNumberDevicePrefixFromDeviceId } from "../../utils/payment-number";
|
|
40
41
|
import { processCartPromotion, appendPromotionTags as _appendPromotionTags, getOrderProductUid as getPromotionUid, PRODUCT_LINE_MERGE_DISABLED_METADATA_KEY } from "../../solution/BaseSales/utils/cartPromotion";
|
|
@@ -43,6 +44,7 @@ import { hasManualProductDiscountFlag, syncManualProductDiscountProductNum } fro
|
|
|
43
44
|
import { expandHydratedProductsForDiscountCollection, restoreHydratedBundleDiscounts } from "./utils/bundleDiscountHydration";
|
|
44
45
|
import { getOrderCollectionPersistentId, getOrderCollectionUid, normalizeOrderCollections, repairDuplicateProductLineIdentities as repairDuplicateOrderProductLineIdentities, setOrderCollectionUid } from "./utils/orderCollectionIdentity";
|
|
45
46
|
import { consolidateDiscountFreeProductLines, ensureUniqueProductLineUids } from "./utils/discountProductLineIdentity";
|
|
47
|
+
import { applyTempOrderSettlementState, getSelectedSettlementSnapshot, getSettlementKey, getTempOrderSettlementKey, getTempOrderSettlementSnapshot, isVirtualSettlementOrder, normalizeVirtualSettlementOrderProduct, normalizeVirtualSettlementProducts, OrderSettlementConflictError, releaseTempOrderSettlementState, VirtualCurrencyAssetNotFoundError, VirtualCurrencyBalanceError } from "./utils/virtualSettlement";
|
|
46
48
|
import { DiscountModule } from "../Discount";
|
|
47
49
|
import { RulesModule } from "../Rules";
|
|
48
50
|
import { UnavailableReason } from "../Rules/types";
|
|
@@ -105,6 +107,13 @@ function getVoucherPaymentLifecycleKey(payment) {
|
|
|
105
107
|
if (!isVoucherPaymentRecord(payment)) return null;
|
|
106
108
|
return "".concat(String(payment.voucher_id), "::").concat(String(payment.status || ''));
|
|
107
109
|
}
|
|
110
|
+
function hasPersistedOrderId(orderId) {
|
|
111
|
+
if (orderId === undefined || orderId === null || orderId === '') return false;
|
|
112
|
+
if (typeof orderId === 'string' && orderId.startsWith('LOCAL_')) return false;
|
|
113
|
+
var normalizedOrderId = Number(orderId);
|
|
114
|
+
if (Number.isFinite(normalizedOrderId)) return normalizedOrderId > 0;
|
|
115
|
+
return String(orderId).trim() !== '';
|
|
116
|
+
}
|
|
108
117
|
export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
109
118
|
_inherits(OrderModule, _BaseModule);
|
|
110
119
|
var _super = _createSuper(OrderModule);
|
|
@@ -135,8 +144,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
135
144
|
_defineProperty(_assertThisInitialized(_this), "promotionEvaluator", null);
|
|
136
145
|
/** 赠品选择 resolver;由 SDK host bridge 注入 */
|
|
137
146
|
_defineProperty(_assertThisInitialized(_this), "giftSelectResolver", null);
|
|
138
|
-
/**
|
|
147
|
+
/** 促销评估递归保护 flag(写路径同步评估促销,禁止重入) */
|
|
139
148
|
_defineProperty(_assertThisInitialized(_this), "isApplyingPromotion", false);
|
|
149
|
+
/** 保持旧事件语义:同步事件监听器内触发的订单写入不得递归评估促销。 */
|
|
150
|
+
_defineProperty(_assertThisInitialized(_this), "isEmittingPromotionApplied", false);
|
|
140
151
|
/** 商品曾应用过客户券卡,客户变更剥离后需强制跑一次 calcDiscount 复位价格 */
|
|
141
152
|
_defineProperty(_assertThisInitialized(_this), "hasActiveCustomerBoundDiscount", false);
|
|
142
153
|
/** 最近一次 applyPromotion 的未满足促销提示 */
|
|
@@ -293,14 +304,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
293
304
|
}
|
|
294
305
|
if (Array.isArray(product.product_bundle)) {
|
|
295
306
|
product.product_bundle = product.product_bundle.map(function (bundle) {
|
|
296
|
-
var _ref11, _bundle$
|
|
307
|
+
var _ref11, _bundle$price, _bundle$bundle_sellin;
|
|
297
308
|
var hasBundleDiscount = Array.isArray(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) && bundle.discount_list.length > 0;
|
|
298
309
|
if (hasBundleDiscount) return bundle;
|
|
299
|
-
var restoredPrice = (_ref11 = (_bundle$
|
|
310
|
+
var restoredPrice = (_ref11 = (_bundle$price = bundle === null || bundle === void 0 ? void 0 : bundle.price) !== null && _bundle$price !== void 0 ? _bundle$price : bundle === null || bundle === void 0 ? void 0 : bundle.original_price) !== null && _ref11 !== void 0 ? _ref11 : bundle === null || bundle === void 0 ? void 0 : bundle.product_price;
|
|
300
311
|
if (restoredPrice === undefined || restoredPrice === null || restoredPrice === '') return bundle;
|
|
301
312
|
return _objectSpread(_objectSpread({}, bundle), {}, {
|
|
302
313
|
price: restoredPrice,
|
|
303
|
-
bundle_selling_price: restoredPrice
|
|
314
|
+
bundle_selling_price: (_bundle$bundle_sellin = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price) !== null && _bundle$bundle_sellin !== void 0 ? _bundle$bundle_sellin : restoredPrice
|
|
304
315
|
});
|
|
305
316
|
});
|
|
306
317
|
}
|
|
@@ -339,6 +350,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
339
350
|
this.store.tempOrder = null;
|
|
340
351
|
this.store.summary = createEmptySummary();
|
|
341
352
|
this.store.availableWalletIds = [];
|
|
353
|
+
this.store.virtualCurrencyList = [];
|
|
342
354
|
this.store.lastOrderInfo = undefined;
|
|
343
355
|
this.store.syncState = undefined;
|
|
344
356
|
this.store.discountList = [];
|
|
@@ -351,6 +363,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
351
363
|
if (!Array.isArray(this.store.availableWalletIds)) {
|
|
352
364
|
this.store.availableWalletIds = [];
|
|
353
365
|
}
|
|
366
|
+
if (!Array.isArray(this.store.virtualCurrencyList)) {
|
|
367
|
+
this.store.virtualCurrencyList = [];
|
|
368
|
+
}
|
|
354
369
|
this.request = this.core.getPlugin('request');
|
|
355
370
|
appPlugin = this.core.getPlugin('app');
|
|
356
371
|
if (!appPlugin) {
|
|
@@ -366,7 +381,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
366
381
|
this.otherParams = otherParams;
|
|
367
382
|
this.registerDiscountModules(options);
|
|
368
383
|
this.logInfo('OrderModule initialized successfully');
|
|
369
|
-
case
|
|
384
|
+
case 21:
|
|
370
385
|
case "end":
|
|
371
386
|
return _context.stop();
|
|
372
387
|
}
|
|
@@ -454,6 +469,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
454
469
|
this.otherParams = otherParams;
|
|
455
470
|
}
|
|
456
471
|
|
|
472
|
+
/** PC/H5 属于在线店铺;其它或缺失平台统一沿用 POS 行为。 */
|
|
473
|
+
}, {
|
|
474
|
+
key: "isOnlineStorePlatform",
|
|
475
|
+
value: function isOnlineStorePlatform() {
|
|
476
|
+
var _this$otherParams;
|
|
477
|
+
var platform = String(((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.platform) || '').trim().toLowerCase();
|
|
478
|
+
return platform === 'pc' || platform === 'h5';
|
|
479
|
+
}
|
|
480
|
+
|
|
457
481
|
/**
|
|
458
482
|
* 记录信息日志
|
|
459
483
|
*/
|
|
@@ -559,6 +583,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
559
583
|
with_wallet_pass_holder: 1,
|
|
560
584
|
with_available_wallet_flag: 1,
|
|
561
585
|
with_available_wallet_pass_flag: 1,
|
|
586
|
+
with_virtual_currency: 1,
|
|
562
587
|
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
563
588
|
}, orderId ? {
|
|
564
589
|
order_id: orderId
|
|
@@ -567,8 +592,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
567
592
|
prepareConfigResult = _context3.sent;
|
|
568
593
|
discountList = prepareConfigResult === null || prepareConfigResult === void 0 ? void 0 : prepareConfigResult.discountList;
|
|
569
594
|
this.store.availableWalletIds = (prepareConfigResult === null || prepareConfigResult === void 0 ? void 0 : prepareConfigResult.availableWalletIds) || [];
|
|
595
|
+
this.store.virtualCurrencyList = (prepareConfigResult === null || prepareConfigResult === void 0 ? void 0 : prepareConfigResult.virtualCurrencyList) || [];
|
|
596
|
+
if (prepareConfigResult) {
|
|
597
|
+
this.writePointCardSnapshotFromPrepareConfig({
|
|
598
|
+
orderId: orderId,
|
|
599
|
+
customerId: params.customerId,
|
|
600
|
+
availableWalletPassList: prepareConfigResult.availableWalletPassList || []
|
|
601
|
+
});
|
|
602
|
+
}
|
|
570
603
|
if (!discountList) {
|
|
571
|
-
_context3.next =
|
|
604
|
+
_context3.next = 20;
|
|
572
605
|
break;
|
|
573
606
|
}
|
|
574
607
|
currentDiscountList = ((_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 ? void 0 : _this$store$discount2.getDiscountList()) || [];
|
|
@@ -589,17 +622,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
589
622
|
return true;
|
|
590
623
|
});
|
|
591
624
|
mergedDiscountList = [].concat(_toConsumableArray(currentEditDiscounts), _toConsumableArray(currentScanDiscounts), _toConsumableArray(runtimeDiscounts));
|
|
592
|
-
_context3.next = 16;
|
|
593
|
-
return (_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.setOriginalDiscountList(mergedDiscountList);
|
|
594
|
-
case 16:
|
|
595
625
|
_context3.next = 18;
|
|
596
|
-
return (_this$store$
|
|
626
|
+
return (_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.setOriginalDiscountList(mergedDiscountList);
|
|
597
627
|
case 18:
|
|
628
|
+
_context3.next = 20;
|
|
629
|
+
return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.setDiscountList(mergedDiscountList);
|
|
630
|
+
case 20:
|
|
598
631
|
if (params.apply !== false && (_this$store$tempOrder2 = this.store.tempOrder) !== null && _this$store$tempOrder2 !== void 0 && (_this$store$tempOrder2 = _this$store$tempOrder2.products) !== null && _this$store$tempOrder2 !== void 0 && _this$store$tempOrder2.length) {
|
|
599
632
|
this.applyDiscount();
|
|
600
633
|
}
|
|
601
634
|
return _context3.abrupt("return", this.getDiscountList());
|
|
602
|
-
case
|
|
635
|
+
case 22:
|
|
603
636
|
case "end":
|
|
604
637
|
return _context3.stop();
|
|
605
638
|
}
|
|
@@ -621,6 +654,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
621
654
|
value: function getAvailableWalletIds() {
|
|
622
655
|
return Array.isArray(this.store.availableWalletIds) ? _toConsumableArray(this.store.availableWalletIds) : [];
|
|
623
656
|
}
|
|
657
|
+
}, {
|
|
658
|
+
key: "getVirtualCurrencyList",
|
|
659
|
+
value: function getVirtualCurrencyList() {
|
|
660
|
+
return cloneDeep(this.store.virtualCurrencyList || []);
|
|
661
|
+
}
|
|
624
662
|
}, {
|
|
625
663
|
key: "syncScannedDiscountsToOriginalDiscountList",
|
|
626
664
|
value: function () {
|
|
@@ -713,26 +751,39 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
713
751
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
714
752
|
while (1) switch (_context6.prev = _context6.next) {
|
|
715
753
|
case 0:
|
|
716
|
-
|
|
754
|
+
if (!this.isActiveVirtualSettlementOrder(this.store.tempOrder)) {
|
|
755
|
+
_context6.next = 2;
|
|
756
|
+
break;
|
|
757
|
+
}
|
|
758
|
+
return _context6.abrupt("return", {
|
|
759
|
+
type: 'clientCalc',
|
|
760
|
+
isAvailable: false,
|
|
761
|
+
isAccepted: false,
|
|
762
|
+
discountList: [],
|
|
763
|
+
scannedDiscountList: [],
|
|
764
|
+
unavailableReason: UnavailableReason.ProductNotApplicable
|
|
765
|
+
});
|
|
766
|
+
case 2:
|
|
767
|
+
_context6.next = 4;
|
|
717
768
|
return (_this$store$discount11 = this.store.discount) === null || _this$store$discount11 === void 0 ? void 0 : _this$store$discount11.batchSearch(code, {
|
|
718
769
|
customerId: customerId
|
|
719
770
|
});
|
|
720
|
-
case
|
|
771
|
+
case 4:
|
|
721
772
|
_context6.t0 = _context6.sent;
|
|
722
773
|
if (_context6.t0) {
|
|
723
|
-
_context6.next =
|
|
774
|
+
_context6.next = 7;
|
|
724
775
|
break;
|
|
725
776
|
}
|
|
726
777
|
_context6.t0 = {
|
|
727
778
|
discountList: [],
|
|
728
779
|
unavailableReasonKey: null
|
|
729
780
|
};
|
|
730
|
-
case
|
|
781
|
+
case 7:
|
|
731
782
|
resultDiscountWithReason = _context6.t0;
|
|
732
783
|
resultDiscountList = resultDiscountWithReason.discountList, unavailableReasonKey = resultDiscountWithReason.unavailableReasonKey;
|
|
733
784
|
rulesModule = this.store.rules;
|
|
734
785
|
if (rulesModule) {
|
|
735
|
-
_context6.next =
|
|
786
|
+
_context6.next = 12;
|
|
736
787
|
break;
|
|
737
788
|
}
|
|
738
789
|
return _context6.abrupt("return", {
|
|
@@ -743,9 +794,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
743
794
|
scannedDiscountList: resultDiscountList,
|
|
744
795
|
unavailableReason: UnavailableReason.Unknown
|
|
745
796
|
});
|
|
746
|
-
case
|
|
797
|
+
case 12:
|
|
747
798
|
if (resultDiscountList.length) {
|
|
748
|
-
_context6.next =
|
|
799
|
+
_context6.next = 14;
|
|
749
800
|
break;
|
|
750
801
|
}
|
|
751
802
|
return _context6.abrupt("return", {
|
|
@@ -756,7 +807,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
756
807
|
scannedDiscountList: resultDiscountList,
|
|
757
808
|
unavailableReasonKey: unavailableReasonKey
|
|
758
809
|
});
|
|
759
|
-
case
|
|
810
|
+
case 14:
|
|
760
811
|
withScanList = resultDiscountList.map(function (item) {
|
|
761
812
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
762
813
|
isScan: true
|
|
@@ -770,12 +821,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
770
821
|
return m.id === n.id;
|
|
771
822
|
});
|
|
772
823
|
}))) {
|
|
773
|
-
_context6.next =
|
|
824
|
+
_context6.next = 20;
|
|
774
825
|
break;
|
|
775
826
|
}
|
|
776
|
-
_context6.next =
|
|
827
|
+
_context6.next = 19;
|
|
777
828
|
return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
778
|
-
case
|
|
829
|
+
case 19:
|
|
779
830
|
return _context6.abrupt("return", {
|
|
780
831
|
type: 'clientCalc',
|
|
781
832
|
isAvailable: true,
|
|
@@ -783,7 +834,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
783
834
|
discountList: this.getDiscountList(),
|
|
784
835
|
scannedDiscountList: resultDiscountList
|
|
785
836
|
});
|
|
786
|
-
case
|
|
837
|
+
case 20:
|
|
787
838
|
tempOrder = this.store.tempOrder;
|
|
788
839
|
holders = (tempOrder === null || tempOrder === void 0 || (_tempOrder$holder = tempOrder.holder) === null || _tempOrder$holder === void 0 ? void 0 : _tempOrder$holder.form_record) || [];
|
|
789
840
|
_ref12 = rulesModule.isDiscountListAvailable({
|
|
@@ -804,32 +855,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
804
855
|
retainedDiscountList = evaluatedDiscountList ? markScannedDiscounts(evaluatedDiscountList, withScanList) : normalizedNewDiscountList;
|
|
805
856
|
resolvedDiscountList = normalizedNewDiscountList || this.getDiscountList();
|
|
806
857
|
if (!(isAvailable && normalizedNewDiscountList)) {
|
|
807
|
-
_context6.next =
|
|
858
|
+
_context6.next = 36;
|
|
808
859
|
break;
|
|
809
860
|
}
|
|
810
|
-
_context6.next =
|
|
861
|
+
_context6.next = 30;
|
|
811
862
|
return (_this$store$discount12 = this.store.discount) === null || _this$store$discount12 === void 0 ? void 0 : _this$store$discount12.setDiscountList(normalizedNewDiscountList);
|
|
812
|
-
case
|
|
863
|
+
case 30:
|
|
813
864
|
this.applyDiscount();
|
|
814
|
-
_context6.next =
|
|
865
|
+
_context6.next = 33;
|
|
815
866
|
return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
816
|
-
case
|
|
867
|
+
case 33:
|
|
817
868
|
resolvedDiscountList = this.getDiscountList();
|
|
818
|
-
_context6.next =
|
|
869
|
+
_context6.next = 42;
|
|
819
870
|
break;
|
|
820
|
-
case
|
|
871
|
+
case 36:
|
|
821
872
|
if (!(shouldRetainForLater && retainedDiscountList)) {
|
|
822
|
-
_context6.next =
|
|
873
|
+
_context6.next = 42;
|
|
823
874
|
break;
|
|
824
875
|
}
|
|
825
|
-
_context6.next = 37;
|
|
826
|
-
return (_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.setDiscountList(retainedDiscountList);
|
|
827
|
-
case 37:
|
|
828
876
|
_context6.next = 39;
|
|
829
|
-
return
|
|
877
|
+
return (_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.setDiscountList(retainedDiscountList);
|
|
830
878
|
case 39:
|
|
879
|
+
_context6.next = 41;
|
|
880
|
+
return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
881
|
+
case 41:
|
|
831
882
|
resolvedDiscountList = this.getDiscountList();
|
|
832
|
-
case
|
|
883
|
+
case 42:
|
|
833
884
|
return _context6.abrupt("return", {
|
|
834
885
|
type: 'clientCalc',
|
|
835
886
|
isAvailable: isAvailable || false,
|
|
@@ -838,7 +889,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
838
889
|
scannedDiscountList: resultDiscountList,
|
|
839
890
|
unavailableReason: unavailableReason
|
|
840
891
|
});
|
|
841
|
-
case
|
|
892
|
+
case 43:
|
|
842
893
|
case "end":
|
|
843
894
|
return _context6.stop();
|
|
844
895
|
}
|
|
@@ -852,7 +903,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
852
903
|
}, {
|
|
853
904
|
key: "applyDiscount",
|
|
854
905
|
value: function applyDiscount(options) {
|
|
855
|
-
var _this$store$
|
|
906
|
+
var _this$store$discount16,
|
|
856
907
|
_this$store$summary2,
|
|
857
908
|
_this2 = this;
|
|
858
909
|
var tempOrder = this.store.tempOrder;
|
|
@@ -860,9 +911,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
860
911
|
// 也需要让 Rules.calcDiscount 把 DiscountModule 的 isSelected / isAvailable /
|
|
861
912
|
// appliedProductDetails / savedAmount 复位。
|
|
862
913
|
if (!tempOrder) return;
|
|
914
|
+
if (this.isActiveVirtualSettlementOrder(tempOrder)) {
|
|
915
|
+
var _this$store$discount14, _this$store$discount15;
|
|
916
|
+
tempOrder.products = normalizeVirtualSettlementProducts(tempOrder.products);
|
|
917
|
+
tempOrder.discount_list = [];
|
|
918
|
+
tempOrder.shop_discount = '0.00';
|
|
919
|
+
void ((_this$store$discount14 = this.store.discount) === null || _this$store$discount14 === void 0 ? void 0 : _this$store$discount14.setDiscountList([]));
|
|
920
|
+
void ((_this$store$discount15 = this.store.discount) === null || _this$store$discount15 === void 0 ? void 0 : _this$store$discount15.setOriginalDiscountList([]));
|
|
921
|
+
return;
|
|
922
|
+
}
|
|
863
923
|
this.syncLinkedBookingHoldersToProducts(tempOrder);
|
|
864
924
|
delete tempOrder.discount_list;
|
|
865
|
-
var discountList = ((_this$store$
|
|
925
|
+
var discountList = ((_this$store$discount16 = this.store.discount) === null || _this$store$discount16 === void 0 ? void 0 : _this$store$discount16.getDiscountList()) || [];
|
|
866
926
|
var shouldSkipDiscountCalculation = this.shouldSkipDiscountCalculation(tempOrder);
|
|
867
927
|
if (shouldSkipDiscountCalculation) return;
|
|
868
928
|
var rulesModule = this.store.rules;
|
|
@@ -896,9 +956,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
896
956
|
consolidateDiscountFreeProductLines(tempOrder);
|
|
897
957
|
}
|
|
898
958
|
if (result !== null && result !== void 0 && result.discountList) {
|
|
899
|
-
var _this$store$
|
|
959
|
+
var _this$store$discount17;
|
|
900
960
|
OrderModule.populateSavedAmounts(result.productList || tempOrder.products, result.discountList);
|
|
901
|
-
(_this$store$
|
|
961
|
+
(_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 || _this$store$discount17.setDiscountList(result.discountList);
|
|
902
962
|
}
|
|
903
963
|
this.hasActiveCustomerBoundDiscount = (tempOrder.products || []).some(function (product) {
|
|
904
964
|
return _this2.productHasCustomerBoundDiscount(product);
|
|
@@ -947,7 +1007,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
947
1007
|
}
|
|
948
1008
|
|
|
949
1009
|
/**
|
|
950
|
-
*
|
|
1010
|
+
* 只执行购物车促销评估与赠品写回,不发布稳定态事件。
|
|
951
1011
|
*
|
|
952
1012
|
* 调用时机:写路径(add/update/remove/clear/setCustomer)末尾自动触发;外部一般无需手动调。
|
|
953
1013
|
*
|
|
@@ -955,12 +1015,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
955
1015
|
* - 不调用任何公开 CRUD API(如 removeProductFromOrder),全部内部 mutate tempOrder.products,避免事件风暴;
|
|
956
1016
|
* - 用 `isApplyingPromotion` 防递归;
|
|
957
1017
|
* - 多选项赠品依赖 giftSelectResolver,未注入则跳过且 console.warn;
|
|
958
|
-
* - 不主动调用 applyDiscount / recalculateSummary
|
|
1018
|
+
* - 不主动调用 applyDiscount / recalculateSummary,调用方负责跟进;
|
|
1019
|
+
* - 返回的 payload 只能在 applyDiscount(商品写路径还需 summary/persist)完成后发布。
|
|
959
1020
|
*/
|
|
960
1021
|
}, {
|
|
961
|
-
key: "
|
|
1022
|
+
key: "evaluatePromotion",
|
|
962
1023
|
value: (function () {
|
|
963
|
-
var
|
|
1024
|
+
var _evaluatePromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
964
1025
|
var _this$promotionEvalua,
|
|
965
1026
|
_this$promotionEvalua2,
|
|
966
1027
|
_this3 = this;
|
|
@@ -968,34 +1029,41 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
968
1029
|
return _regeneratorRuntime().wrap(function _callee7$(_context9) {
|
|
969
1030
|
while (1) switch (_context9.prev = _context9.next) {
|
|
970
1031
|
case 0:
|
|
971
|
-
if (!this.isApplyingPromotion) {
|
|
1032
|
+
if (!(this.isApplyingPromotion || this.isEmittingPromotionApplied)) {
|
|
972
1033
|
_context9.next = 2;
|
|
973
1034
|
break;
|
|
974
1035
|
}
|
|
975
|
-
return _context9.abrupt("return");
|
|
1036
|
+
return _context9.abrupt("return", null);
|
|
976
1037
|
case 2:
|
|
977
1038
|
if (this.promotionEvaluator) {
|
|
978
1039
|
_context9.next = 4;
|
|
979
1040
|
break;
|
|
980
1041
|
}
|
|
981
|
-
return _context9.abrupt("return");
|
|
1042
|
+
return _context9.abrupt("return", null);
|
|
982
1043
|
case 4:
|
|
983
1044
|
tempOrder = this.store.tempOrder;
|
|
984
1045
|
if (tempOrder) {
|
|
985
1046
|
_context9.next = 7;
|
|
986
1047
|
break;
|
|
987
1048
|
}
|
|
988
|
-
return _context9.abrupt("return");
|
|
1049
|
+
return _context9.abrupt("return", null);
|
|
989
1050
|
case 7:
|
|
990
|
-
|
|
991
|
-
if (!(Array.isArray(strategyConfigs) && strategyConfigs.length === 0)) {
|
|
1051
|
+
if (!this.isActiveVirtualSettlementOrder(tempOrder)) {
|
|
992
1052
|
_context9.next = 10;
|
|
993
1053
|
break;
|
|
994
1054
|
}
|
|
995
|
-
|
|
1055
|
+
tempOrder.products = normalizeVirtualSettlementProducts(tempOrder.products);
|
|
1056
|
+
return _context9.abrupt("return", null);
|
|
996
1057
|
case 10:
|
|
1058
|
+
strategyConfigs = (_this$promotionEvalua = (_this$promotionEvalua2 = this.promotionEvaluator).getStrategyConfigs) === null || _this$promotionEvalua === void 0 ? void 0 : _this$promotionEvalua.call(_this$promotionEvalua2);
|
|
1059
|
+
if (!(Array.isArray(strategyConfigs) && strategyConfigs.length === 0)) {
|
|
1060
|
+
_context9.next = 13;
|
|
1061
|
+
break;
|
|
1062
|
+
}
|
|
1063
|
+
return _context9.abrupt("return", null);
|
|
1064
|
+
case 13:
|
|
997
1065
|
this.isApplyingPromotion = true;
|
|
998
|
-
_context9.prev =
|
|
1066
|
+
_context9.prev = 14;
|
|
999
1067
|
result = processCartPromotion(tempOrder.products, this.promotionEvaluator); // step 1: toRemove —— 直接过滤
|
|
1000
1068
|
if (result.giftActions.toRemove.length > 0) {
|
|
1001
1069
|
removeSet = new Set(result.giftActions.toRemove.map(String));
|
|
@@ -1007,16 +1075,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1007
1075
|
|
|
1008
1076
|
// step 2: toReduce —— 调整数量
|
|
1009
1077
|
_iterator3 = _createForOfIteratorHelper(result.giftActions.toReduce);
|
|
1010
|
-
_context9.prev =
|
|
1078
|
+
_context9.prev = 18;
|
|
1011
1079
|
_iterator3.s();
|
|
1012
|
-
case
|
|
1080
|
+
case 20:
|
|
1013
1081
|
if ((_step3 = _iterator3.n()).done) {
|
|
1014
|
-
_context9.next =
|
|
1082
|
+
_context9.next = 40;
|
|
1015
1083
|
break;
|
|
1016
1084
|
}
|
|
1017
1085
|
reduce = _step3.value;
|
|
1018
1086
|
_iterator6 = _createForOfIteratorHelper(reduce.items);
|
|
1019
|
-
_context9.prev =
|
|
1087
|
+
_context9.prev = 23;
|
|
1020
1088
|
_loop2 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop2() {
|
|
1021
1089
|
var item, product;
|
|
1022
1090
|
return _regeneratorRuntime().wrap(function _loop2$(_context8) {
|
|
@@ -1036,47 +1104,47 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1036
1104
|
}, _loop2);
|
|
1037
1105
|
});
|
|
1038
1106
|
_iterator6.s();
|
|
1039
|
-
case
|
|
1107
|
+
case 26:
|
|
1040
1108
|
if ((_step6 = _iterator6.n()).done) {
|
|
1041
|
-
_context9.next =
|
|
1109
|
+
_context9.next = 30;
|
|
1042
1110
|
break;
|
|
1043
1111
|
}
|
|
1044
|
-
return _context9.delegateYield(_loop2(), "t0",
|
|
1045
|
-
case
|
|
1046
|
-
_context9.next =
|
|
1112
|
+
return _context9.delegateYield(_loop2(), "t0", 28);
|
|
1113
|
+
case 28:
|
|
1114
|
+
_context9.next = 26;
|
|
1047
1115
|
break;
|
|
1048
|
-
case
|
|
1049
|
-
_context9.next =
|
|
1116
|
+
case 30:
|
|
1117
|
+
_context9.next = 35;
|
|
1050
1118
|
break;
|
|
1051
|
-
case 29:
|
|
1052
|
-
_context9.prev = 29;
|
|
1053
|
-
_context9.t1 = _context9["catch"](20);
|
|
1054
|
-
_iterator6.e(_context9.t1);
|
|
1055
1119
|
case 32:
|
|
1056
1120
|
_context9.prev = 32;
|
|
1057
|
-
|
|
1058
|
-
|
|
1121
|
+
_context9.t1 = _context9["catch"](23);
|
|
1122
|
+
_iterator6.e(_context9.t1);
|
|
1059
1123
|
case 35:
|
|
1060
|
-
_context9.
|
|
1124
|
+
_context9.prev = 35;
|
|
1125
|
+
_iterator6.f();
|
|
1126
|
+
return _context9.finish(35);
|
|
1127
|
+
case 38:
|
|
1128
|
+
_context9.next = 20;
|
|
1061
1129
|
break;
|
|
1062
|
-
case
|
|
1063
|
-
_context9.next =
|
|
1130
|
+
case 40:
|
|
1131
|
+
_context9.next = 45;
|
|
1064
1132
|
break;
|
|
1065
|
-
case 39:
|
|
1066
|
-
_context9.prev = 39;
|
|
1067
|
-
_context9.t2 = _context9["catch"](15);
|
|
1068
|
-
_iterator3.e(_context9.t2);
|
|
1069
1133
|
case 42:
|
|
1070
1134
|
_context9.prev = 42;
|
|
1071
|
-
|
|
1072
|
-
|
|
1135
|
+
_context9.t2 = _context9["catch"](18);
|
|
1136
|
+
_iterator3.e(_context9.t2);
|
|
1073
1137
|
case 45:
|
|
1138
|
+
_context9.prev = 45;
|
|
1139
|
+
_iterator3.f();
|
|
1140
|
+
return _context9.finish(45);
|
|
1141
|
+
case 48:
|
|
1074
1142
|
if (!(result.giftActions.toAdd.length > 0)) {
|
|
1075
|
-
_context9.next =
|
|
1143
|
+
_context9.next = 71;
|
|
1076
1144
|
break;
|
|
1077
1145
|
}
|
|
1078
1146
|
if (this.giftSelectResolver) {
|
|
1079
|
-
_context9.next =
|
|
1147
|
+
_context9.next = 53;
|
|
1080
1148
|
break;
|
|
1081
1149
|
}
|
|
1082
1150
|
if (result.giftActions.toAdd.some(function (g) {
|
|
@@ -1087,11 +1155,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1087
1155
|
} else {
|
|
1088
1156
|
console.warn('[OrderModule] giftSelectResolver not set, skip applying single-option gifts', result.giftActions.toAdd);
|
|
1089
1157
|
}
|
|
1090
|
-
_context9.next =
|
|
1158
|
+
_context9.next = 71;
|
|
1091
1159
|
break;
|
|
1092
|
-
case
|
|
1160
|
+
case 53:
|
|
1093
1161
|
_iterator4 = _createForOfIteratorHelper(result.giftActions.toAdd);
|
|
1094
|
-
_context9.prev =
|
|
1162
|
+
_context9.prev = 54;
|
|
1095
1163
|
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
1096
1164
|
var addAction, _sameStrategy$metadat, sameStrategy, giftResult, giftProducts, giftBookings, _iterator5, _step5, _step5$value, index, gp, booking, linked;
|
|
1097
1165
|
return _regeneratorRuntime().wrap(function _loop$(_context7) {
|
|
@@ -1189,33 +1257,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1189
1257
|
}, _loop, null, [[6, 39], [14, 31, 34, 37]]);
|
|
1190
1258
|
});
|
|
1191
1259
|
_iterator4.s();
|
|
1192
|
-
case
|
|
1260
|
+
case 57:
|
|
1193
1261
|
if ((_step4 = _iterator4.n()).done) {
|
|
1194
|
-
_context9.next =
|
|
1262
|
+
_context9.next = 63;
|
|
1195
1263
|
break;
|
|
1196
1264
|
}
|
|
1197
|
-
return _context9.delegateYield(_loop(), "t3",
|
|
1198
|
-
case
|
|
1265
|
+
return _context9.delegateYield(_loop(), "t3", 59);
|
|
1266
|
+
case 59:
|
|
1199
1267
|
if (!_context9.t3) {
|
|
1200
|
-
_context9.next =
|
|
1268
|
+
_context9.next = 61;
|
|
1201
1269
|
break;
|
|
1202
1270
|
}
|
|
1203
|
-
return _context9.abrupt("continue",
|
|
1204
|
-
case
|
|
1205
|
-
_context9.next =
|
|
1271
|
+
return _context9.abrupt("continue", 61);
|
|
1272
|
+
case 61:
|
|
1273
|
+
_context9.next = 57;
|
|
1206
1274
|
break;
|
|
1207
|
-
case
|
|
1208
|
-
_context9.next =
|
|
1275
|
+
case 63:
|
|
1276
|
+
_context9.next = 68;
|
|
1209
1277
|
break;
|
|
1210
|
-
case 62:
|
|
1211
|
-
_context9.prev = 62;
|
|
1212
|
-
_context9.t4 = _context9["catch"](51);
|
|
1213
|
-
_iterator4.e(_context9.t4);
|
|
1214
1278
|
case 65:
|
|
1215
1279
|
_context9.prev = 65;
|
|
1216
|
-
|
|
1217
|
-
|
|
1280
|
+
_context9.t4 = _context9["catch"](54);
|
|
1281
|
+
_iterator4.e(_context9.t4);
|
|
1218
1282
|
case 68:
|
|
1283
|
+
_context9.prev = 68;
|
|
1284
|
+
_iterator4.f();
|
|
1285
|
+
return _context9.finish(68);
|
|
1286
|
+
case 71:
|
|
1219
1287
|
tempOrder.products = result.products;
|
|
1220
1288
|
this.lastUnfulfilledPromotions = result.unfulfilledPromotions;
|
|
1221
1289
|
this.lastGiftActions = result.giftActions;
|
|
@@ -1232,22 +1300,84 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1232
1300
|
}),
|
|
1233
1301
|
products: tempOrder.products
|
|
1234
1302
|
};
|
|
1235
|
-
|
|
1236
|
-
_context9.next = 78;
|
|
1237
|
-
break;
|
|
1238
|
-
case 75:
|
|
1239
|
-
_context9.prev = 75;
|
|
1240
|
-
_context9.t5 = _context9["catch"](11);
|
|
1241
|
-
console.error('[OrderModule] applyPromotion failed', _context9.t5);
|
|
1303
|
+
return _context9.abrupt("return", payload);
|
|
1242
1304
|
case 78:
|
|
1243
1305
|
_context9.prev = 78;
|
|
1306
|
+
_context9.t5 = _context9["catch"](14);
|
|
1307
|
+
console.error('[OrderModule] applyPromotion failed', _context9.t5);
|
|
1308
|
+
return _context9.abrupt("return", null);
|
|
1309
|
+
case 82:
|
|
1310
|
+
_context9.prev = 82;
|
|
1244
1311
|
this.isApplyingPromotion = false;
|
|
1245
|
-
return _context9.finish(
|
|
1246
|
-
case
|
|
1312
|
+
return _context9.finish(82);
|
|
1313
|
+
case 85:
|
|
1247
1314
|
case "end":
|
|
1248
1315
|
return _context9.stop();
|
|
1249
1316
|
}
|
|
1250
|
-
}, _callee7, this, [[
|
|
1317
|
+
}, _callee7, this, [[14, 78, 82, 85], [18, 42, 45, 48], [23, 32, 35, 38], [54, 65, 68, 71]]);
|
|
1318
|
+
}));
|
|
1319
|
+
function evaluatePromotion() {
|
|
1320
|
+
return _evaluatePromotion.apply(this, arguments);
|
|
1321
|
+
}
|
|
1322
|
+
return evaluatePromotion;
|
|
1323
|
+
}() /** 发布促销稳定态;products 必须读取折扣计算后的当前数组。 */)
|
|
1324
|
+
}, {
|
|
1325
|
+
key: "emitPromotionApplied",
|
|
1326
|
+
value: function emitPromotionApplied(payload) {
|
|
1327
|
+
var _this$store$tempOrder3;
|
|
1328
|
+
if (!payload) return;
|
|
1329
|
+
var products = ((_this$store$tempOrder3 = this.store.tempOrder) === null || _this$store$tempOrder3 === void 0 ? void 0 : _this$store$tempOrder3.products) || payload.products;
|
|
1330
|
+
this.isEmittingPromotionApplied = true;
|
|
1331
|
+
try {
|
|
1332
|
+
void this.effectsEmit('onPromotionApplied', _objectSpread(_objectSpread({}, payload), {}, {
|
|
1333
|
+
products: products
|
|
1334
|
+
}));
|
|
1335
|
+
} finally {
|
|
1336
|
+
// effectsEmit 同步调用监听器后返回 Promise;保持既有的非阻塞事件行为。
|
|
1337
|
+
this.isEmittingPromotionApplied = false;
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
/** 公开入口:促销、折扣、summary 与持久化完成后发布稳定态事件。 */
|
|
1342
|
+
}, {
|
|
1343
|
+
key: "applyPromotion",
|
|
1344
|
+
value: (function () {
|
|
1345
|
+
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
1346
|
+
var payload, tempOrder;
|
|
1347
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context10) {
|
|
1348
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
1349
|
+
case 0:
|
|
1350
|
+
_context10.next = 2;
|
|
1351
|
+
return this.evaluatePromotion();
|
|
1352
|
+
case 2:
|
|
1353
|
+
payload = _context10.sent;
|
|
1354
|
+
if (payload) {
|
|
1355
|
+
_context10.next = 5;
|
|
1356
|
+
break;
|
|
1357
|
+
}
|
|
1358
|
+
return _context10.abrupt("return");
|
|
1359
|
+
case 5:
|
|
1360
|
+
tempOrder = this.store.tempOrder;
|
|
1361
|
+
if (tempOrder) {
|
|
1362
|
+
_context10.next = 8;
|
|
1363
|
+
break;
|
|
1364
|
+
}
|
|
1365
|
+
return _context10.abrupt("return");
|
|
1366
|
+
case 8:
|
|
1367
|
+
this.applyDiscount();
|
|
1368
|
+
this.sanitizeTempOrderProducts(tempOrder);
|
|
1369
|
+
_context10.next = 12;
|
|
1370
|
+
return this.recalculateSummary({
|
|
1371
|
+
createIfMissing: true
|
|
1372
|
+
});
|
|
1373
|
+
case 12:
|
|
1374
|
+
this.persistTempOrder();
|
|
1375
|
+
this.emitPromotionApplied(payload);
|
|
1376
|
+
case 14:
|
|
1377
|
+
case "end":
|
|
1378
|
+
return _context10.stop();
|
|
1379
|
+
}
|
|
1380
|
+
}, _callee8, this);
|
|
1251
1381
|
}));
|
|
1252
1382
|
function applyPromotion() {
|
|
1253
1383
|
return _applyPromotion.apply(this, arguments);
|
|
@@ -1373,6 +1503,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1373
1503
|
if (!this.store.tempOrder) return;
|
|
1374
1504
|
this.store.tempOrder = _objectSpread(_objectSpread({}, this.store.tempOrder), {}, {
|
|
1375
1505
|
products: _toConsumableArray(this.store.tempOrder.products),
|
|
1506
|
+
notes: _toConsumableArray(this.store.tempOrder.notes || []),
|
|
1376
1507
|
bookings: this.store.tempOrder.bookings ? _toConsumableArray(this.store.tempOrder.bookings) : []
|
|
1377
1508
|
});
|
|
1378
1509
|
this.persistTempOrder();
|
|
@@ -1386,6 +1517,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1386
1517
|
now: formatDateTime(new Date())
|
|
1387
1518
|
});
|
|
1388
1519
|
}
|
|
1520
|
+
}, {
|
|
1521
|
+
key: "clearTempOrderPointCardSnapshot",
|
|
1522
|
+
value: function clearTempOrderPointCardSnapshot(tempOrder) {
|
|
1523
|
+
var orderMetaList = normalizeOrderMetaList(tempOrder.order_meta_list);
|
|
1524
|
+
if (!orderMetaList) return;
|
|
1525
|
+
var nextOrderMetaList = _objectSpread({}, orderMetaList);
|
|
1526
|
+
delete nextOrderMetaList.point_cards_snapshot;
|
|
1527
|
+
if (Object.keys(nextOrderMetaList).length === 0) {
|
|
1528
|
+
delete tempOrder.order_meta_list;
|
|
1529
|
+
return;
|
|
1530
|
+
}
|
|
1531
|
+
tempOrder.order_meta_list = nextOrderMetaList;
|
|
1532
|
+
}
|
|
1533
|
+
}, {
|
|
1534
|
+
key: "writePointCardSnapshotFromPrepareConfig",
|
|
1535
|
+
value: function writePointCardSnapshotFromPrepareConfig(params) {
|
|
1536
|
+
var _tempOrder$customer_i, _params$orderId;
|
|
1537
|
+
var tempOrder = this.store.tempOrder;
|
|
1538
|
+
if (!tempOrder) return;
|
|
1539
|
+
if (String((_tempOrder$customer_i = tempOrder.customer_id) !== null && _tempOrder$customer_i !== void 0 ? _tempOrder$customer_i : '') !== String(params.customerId)) return;
|
|
1540
|
+
var effectiveOrderId = (_params$orderId = params.orderId) !== null && _params$orderId !== void 0 ? _params$orderId : tempOrder.order_id;
|
|
1541
|
+
if (hasPersistedOrderId(effectiveOrderId)) return;
|
|
1542
|
+
tempOrder.order_meta_list = _objectSpread(_objectSpread({}, normalizeOrderMetaList(tempOrder.order_meta_list) || {}), {}, {
|
|
1543
|
+
point_cards_snapshot: buildPointCardSnapshotFromWalletPassList(params.availableWalletPassList)
|
|
1544
|
+
});
|
|
1545
|
+
this.persistTempOrder();
|
|
1546
|
+
this.saveDraftInBackground();
|
|
1547
|
+
}
|
|
1389
1548
|
}, {
|
|
1390
1549
|
key: "createExternalSaleNumber",
|
|
1391
1550
|
value: function createExternalSaleNumber() {
|
|
@@ -1445,14 +1604,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1445
1604
|
}, {
|
|
1446
1605
|
key: "saveDraft",
|
|
1447
1606
|
value: function () {
|
|
1448
|
-
var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1449
|
-
return _regeneratorRuntime().wrap(function
|
|
1450
|
-
while (1) switch (
|
|
1607
|
+
var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
1608
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context11) {
|
|
1609
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
1451
1610
|
case 0:
|
|
1452
1611
|
case "end":
|
|
1453
|
-
return
|
|
1612
|
+
return _context11.stop();
|
|
1454
1613
|
}
|
|
1455
|
-
},
|
|
1614
|
+
}, _callee9);
|
|
1456
1615
|
}));
|
|
1457
1616
|
function saveDraft() {
|
|
1458
1617
|
return _saveDraft.apply(this, arguments);
|
|
@@ -1467,16 +1626,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1467
1626
|
}, {
|
|
1468
1627
|
key: "hydrateTempOrderFromLocalRecord",
|
|
1469
1628
|
value: function () {
|
|
1470
|
-
var _hydrateTempOrderFromLocalRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1471
|
-
return _regeneratorRuntime().wrap(function
|
|
1472
|
-
while (1) switch (
|
|
1629
|
+
var _hydrateTempOrderFromLocalRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(record) {
|
|
1630
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context12) {
|
|
1631
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1473
1632
|
case 0:
|
|
1474
|
-
return
|
|
1633
|
+
return _context12.abrupt("return", this.hydrateTempOrderFromRecord(record));
|
|
1475
1634
|
case 1:
|
|
1476
1635
|
case "end":
|
|
1477
|
-
return
|
|
1636
|
+
return _context12.stop();
|
|
1478
1637
|
}
|
|
1479
|
-
},
|
|
1638
|
+
}, _callee10, this);
|
|
1480
1639
|
}));
|
|
1481
1640
|
function hydrateTempOrderFromLocalRecord(_x8) {
|
|
1482
1641
|
return _hydrateTempOrderFromLocalRecord.apply(this, arguments);
|
|
@@ -2474,7 +2633,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2474
2633
|
}, {
|
|
2475
2634
|
key: "restoreOrder",
|
|
2476
2635
|
value: function restoreOrder() {
|
|
2477
|
-
var _this$store$
|
|
2636
|
+
var _this$store$discount18, _this$store$discount19;
|
|
2478
2637
|
this.logInfo('restoreOrder start', {});
|
|
2479
2638
|
this.sessionStorageRestoreRecord = null;
|
|
2480
2639
|
var freshTempOrder = this.createDefaultTempOrderInstance();
|
|
@@ -2483,8 +2642,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2483
2642
|
this.store.summary = createEmptySummary();
|
|
2484
2643
|
this.store.lastOrderInfo = undefined;
|
|
2485
2644
|
this.store.syncState = undefined;
|
|
2486
|
-
void ((_this$store$
|
|
2487
|
-
void ((_this$store$
|
|
2645
|
+
void ((_this$store$discount18 = this.store.discount) === null || _this$store$discount18 === void 0 ? void 0 : _this$store$discount18.setOriginalDiscountList([]));
|
|
2646
|
+
void ((_this$store$discount19 = this.store.discount) === null || _this$store$discount19 === void 0 ? void 0 : _this$store$discount19.setDiscountList([]));
|
|
2488
2647
|
this.persistTempOrder();
|
|
2489
2648
|
return freshTempOrder;
|
|
2490
2649
|
}
|
|
@@ -2496,13 +2655,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2496
2655
|
}, {
|
|
2497
2656
|
key: "replaceTempOrder",
|
|
2498
2657
|
value: function () {
|
|
2499
|
-
var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2658
|
+
var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(tempOrder, options) {
|
|
2500
2659
|
var nextTempOrder;
|
|
2501
|
-
return _regeneratorRuntime().wrap(function
|
|
2502
|
-
while (1) switch (
|
|
2660
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context13) {
|
|
2661
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
2503
2662
|
case 0:
|
|
2504
2663
|
if (isTempOrder(tempOrder)) {
|
|
2505
|
-
|
|
2664
|
+
_context13.next = 2;
|
|
2506
2665
|
break;
|
|
2507
2666
|
}
|
|
2508
2667
|
throw new Error('无效的 tempOrder 数据');
|
|
@@ -2513,15 +2672,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2513
2672
|
});
|
|
2514
2673
|
this.store.tempOrder = nextTempOrder;
|
|
2515
2674
|
if (!((options === null || options === void 0 ? void 0 : options.recalculateSummary) !== false)) {
|
|
2516
|
-
|
|
2675
|
+
_context13.next = 10;
|
|
2517
2676
|
break;
|
|
2518
2677
|
}
|
|
2519
|
-
|
|
2678
|
+
_context13.next = 8;
|
|
2520
2679
|
return this.recalculateSummary({
|
|
2521
2680
|
createIfMissing: false
|
|
2522
2681
|
});
|
|
2523
2682
|
case 8:
|
|
2524
|
-
|
|
2683
|
+
_context13.next = 11;
|
|
2525
2684
|
break;
|
|
2526
2685
|
case 10:
|
|
2527
2686
|
this.store.summary = createEmptySummary();
|
|
@@ -2530,18 +2689,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2530
2689
|
this.persistTempOrder();
|
|
2531
2690
|
}
|
|
2532
2691
|
if (!(options !== null && options !== void 0 && options.saveDraft)) {
|
|
2533
|
-
|
|
2692
|
+
_context13.next = 15;
|
|
2534
2693
|
break;
|
|
2535
2694
|
}
|
|
2536
|
-
|
|
2695
|
+
_context13.next = 15;
|
|
2537
2696
|
return this.saveDraft();
|
|
2538
2697
|
case 15:
|
|
2539
|
-
return
|
|
2698
|
+
return _context13.abrupt("return", nextTempOrder);
|
|
2540
2699
|
case 16:
|
|
2541
2700
|
case "end":
|
|
2542
|
-
return
|
|
2701
|
+
return _context13.stop();
|
|
2543
2702
|
}
|
|
2544
|
-
},
|
|
2703
|
+
}, _callee11, this);
|
|
2545
2704
|
}));
|
|
2546
2705
|
function replaceTempOrder(_x9, _x10) {
|
|
2547
2706
|
return _replaceTempOrder.apply(this, arguments);
|
|
@@ -2601,7 +2760,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2601
2760
|
}, {
|
|
2602
2761
|
key: "getOrderSnapshot",
|
|
2603
2762
|
value: function getOrderSnapshot() {
|
|
2604
|
-
var _tempOrder$
|
|
2763
|
+
var _tempOrder$customer_i2, _tempOrder$products;
|
|
2605
2764
|
var tempOrder = this.store.tempOrder;
|
|
2606
2765
|
if (!tempOrder) return null;
|
|
2607
2766
|
var identity = this.getOrderIdentity();
|
|
@@ -2616,7 +2775,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2616
2775
|
shippingStatus: tempOrder.shipping_status || '',
|
|
2617
2776
|
note: tempOrder.note || '',
|
|
2618
2777
|
customer: {
|
|
2619
|
-
customerId: (_tempOrder$
|
|
2778
|
+
customerId: (_tempOrder$customer_i2 = tempOrder.customer_id) !== null && _tempOrder$customer_i2 !== void 0 ? _tempOrder$customer_i2 : null,
|
|
2620
2779
|
customerName: tempOrder.customer_name || '',
|
|
2621
2780
|
phone: tempOrder.phone || '',
|
|
2622
2781
|
email: tempOrder.email || ''
|
|
@@ -2629,32 +2788,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2629
2788
|
}, {
|
|
2630
2789
|
key: "addNewOrder",
|
|
2631
2790
|
value: function () {
|
|
2632
|
-
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2791
|
+
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
2633
2792
|
var tempOrder;
|
|
2634
|
-
return _regeneratorRuntime().wrap(function
|
|
2635
|
-
while (1) switch (
|
|
2793
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context14) {
|
|
2794
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
2636
2795
|
case 0:
|
|
2637
2796
|
tempOrder = this.ensureTempOrder();
|
|
2638
2797
|
this.ensureExternalSaleNumber(tempOrder);
|
|
2639
|
-
|
|
2798
|
+
_context14.next = 4;
|
|
2640
2799
|
return this.recalculateSummary({
|
|
2641
2800
|
createIfMissing: true
|
|
2642
2801
|
});
|
|
2643
2802
|
case 4:
|
|
2644
2803
|
this.persistTempOrder();
|
|
2645
2804
|
if (!this.draftPersistEnabled) {
|
|
2646
|
-
|
|
2805
|
+
_context14.next = 8;
|
|
2647
2806
|
break;
|
|
2648
2807
|
}
|
|
2649
|
-
|
|
2808
|
+
_context14.next = 8;
|
|
2650
2809
|
return this.saveDraft();
|
|
2651
2810
|
case 8:
|
|
2652
|
-
return
|
|
2811
|
+
return _context14.abrupt("return", tempOrder);
|
|
2653
2812
|
case 9:
|
|
2654
2813
|
case "end":
|
|
2655
|
-
return
|
|
2814
|
+
return _context14.stop();
|
|
2656
2815
|
}
|
|
2657
|
-
},
|
|
2816
|
+
}, _callee12, this);
|
|
2658
2817
|
}));
|
|
2659
2818
|
function addNewOrder() {
|
|
2660
2819
|
return _addNewOrder.apply(this, arguments);
|
|
@@ -2689,8 +2848,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2689
2848
|
value: function sanitizeTempOrderProducts(tempOrder) {
|
|
2690
2849
|
var _this15 = this;
|
|
2691
2850
|
tempOrder.products = (tempOrder.products || []).map(function (product) {
|
|
2692
|
-
return _this15.sanitizeOrderProductForTempOrder(product);
|
|
2851
|
+
return _this15.sanitizeOrderProductForTempOrder(_this15.normalizeVirtualSettlementProductIfEnabled(product));
|
|
2693
2852
|
});
|
|
2853
|
+
this.syncTempOrderSettlementState(tempOrder);
|
|
2694
2854
|
ensureUniqueProductLineUids(tempOrder);
|
|
2695
2855
|
}
|
|
2696
2856
|
}, {
|
|
@@ -2871,7 +3031,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2871
3031
|
}, {
|
|
2872
3032
|
key: "buildTempOrderHolderFromBookings",
|
|
2873
3033
|
value: function buildTempOrderHolderFromBookings(tempOrder) {
|
|
2874
|
-
var _baseHolder$customer_, _baseHolder, _ref45, _baseHolder$form_id, _baseHolder2, _tempOrder$holder2, _baseHolder3, _this$
|
|
3034
|
+
var _baseHolder$customer_, _baseHolder, _ref45, _baseHolder$form_id, _baseHolder2, _tempOrder$holder2, _baseHolder3, _this$otherParams2;
|
|
2875
3035
|
var holderRecords = [];
|
|
2876
3036
|
var holderNames = [];
|
|
2877
3037
|
var baseHolder = null;
|
|
@@ -2924,7 +3084,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2924
3084
|
if (holderNames.length) {
|
|
2925
3085
|
nextHolder.name = holderNames.join(',');
|
|
2926
3086
|
}
|
|
2927
|
-
if ((_baseHolder3 = baseHolder) !== null && _baseHolder3 !== void 0 && _baseHolder3.is_source_shop || (_this$
|
|
3087
|
+
if ((_baseHolder3 = baseHolder) !== null && _baseHolder3 !== void 0 && _baseHolder3.is_source_shop || (_this$otherParams2 = this.otherParams) !== null && _this$otherParams2 !== void 0 && _this$otherParams2.isFranchisee) {
|
|
2928
3088
|
nextHolder.is_source_shop = 1;
|
|
2929
3089
|
}
|
|
2930
3090
|
return nextHolder;
|
|
@@ -3022,18 +3182,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3022
3182
|
}, {
|
|
3023
3183
|
key: "recalculateSummary",
|
|
3024
3184
|
value: function () {
|
|
3025
|
-
var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3026
|
-
var _this$
|
|
3185
|
+
var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(options) {
|
|
3186
|
+
var _this$otherParams3, _ref46, _salesSummaryResult$e;
|
|
3027
3187
|
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;
|
|
3028
|
-
return _regeneratorRuntime().wrap(function
|
|
3029
|
-
while (1) switch (
|
|
3188
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context15) {
|
|
3189
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
3030
3190
|
case 0:
|
|
3031
3191
|
tempOrder = options !== null && options !== void 0 && options.createIfMissing ? this.ensureTempOrder() : this.store.tempOrder;
|
|
3032
3192
|
if (tempOrder) {
|
|
3033
|
-
|
|
3193
|
+
_context15.next = 3;
|
|
3034
3194
|
break;
|
|
3035
3195
|
}
|
|
3036
|
-
return
|
|
3196
|
+
return _context15.abrupt("return", null);
|
|
3037
3197
|
case 3:
|
|
3038
3198
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
3039
3199
|
originalSnapshot = this.getOriginalSalesSnapshot(tempOrder);
|
|
@@ -3041,10 +3201,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3041
3201
|
shouldReuseOriginalSnapshot = originalSnapshot && !hasShopDiscountChanged;
|
|
3042
3202
|
snapshotSummary = shouldReuseOriginalSnapshot ? this.restoreOriginalSnapshotIfProductsUnchanged(tempOrder, originalSnapshot) : null;
|
|
3043
3203
|
if (!snapshotSummary) {
|
|
3044
|
-
|
|
3204
|
+
_context15.next = 10;
|
|
3045
3205
|
break;
|
|
3046
3206
|
}
|
|
3047
|
-
return
|
|
3207
|
+
return _context15.abrupt("return", snapshotSummary);
|
|
3048
3208
|
case 10:
|
|
3049
3209
|
shouldFullRecalculateFromSnapshot = Boolean(originalSnapshot);
|
|
3050
3210
|
summaryProducts = shouldFullRecalculateFromSnapshot ? cloneDeep(tempOrder.products || []) : tempOrder.products;
|
|
@@ -3056,7 +3216,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3056
3216
|
totalRefundAmount = existedSummary.total_refund_amount || '0.00';
|
|
3057
3217
|
paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
|
|
3058
3218
|
if (salesSummary) {
|
|
3059
|
-
|
|
3219
|
+
_context15.next = 26;
|
|
3060
3220
|
break;
|
|
3061
3221
|
}
|
|
3062
3222
|
emptyBaseSummary = _objectSpread(_objectSpread(_objectSpread({}, createEmptySummary()), existedSummary), {}, {
|
|
@@ -3082,18 +3242,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3082
3242
|
previousSummary: existedSummary,
|
|
3083
3243
|
summary: emptySummary
|
|
3084
3244
|
});
|
|
3085
|
-
return
|
|
3245
|
+
return _context15.abrupt("return", this.store.summary);
|
|
3086
3246
|
case 26:
|
|
3087
|
-
|
|
3247
|
+
_context15.next = 28;
|
|
3088
3248
|
return salesSummary.getSummary(_objectSpread({
|
|
3089
3249
|
products: summaryProducts,
|
|
3090
3250
|
isPriceIncludeTax: tempOrder.is_price_include_tax,
|
|
3091
|
-
shopDiscount: tempOrder.shop_discount
|
|
3092
|
-
|
|
3251
|
+
shopDiscount: tempOrder.shop_discount,
|
|
3252
|
+
virtualSettlementMode: this.shouldUseVirtualSettlementSummary(tempOrder)
|
|
3253
|
+
}, (_this$otherParams3 = this.otherParams) !== null && _this$otherParams3 !== void 0 && _this$otherParams3.channel ? {
|
|
3093
3254
|
channel: this.otherParams.channel
|
|
3094
3255
|
} : {}));
|
|
3095
3256
|
case 28:
|
|
3096
|
-
salesSummaryResult =
|
|
3257
|
+
salesSummaryResult = _context15.sent;
|
|
3097
3258
|
if (shouldFullRecalculateFromSnapshot) {
|
|
3098
3259
|
tempOrder.products = summaryProducts;
|
|
3099
3260
|
}
|
|
@@ -3138,12 +3299,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3138
3299
|
previousSummary: existedSummary,
|
|
3139
3300
|
summary: summary
|
|
3140
3301
|
});
|
|
3141
|
-
return
|
|
3302
|
+
return _context15.abrupt("return", this.store.summary);
|
|
3142
3303
|
case 46:
|
|
3143
3304
|
case "end":
|
|
3144
|
-
return
|
|
3305
|
+
return _context15.stop();
|
|
3145
3306
|
}
|
|
3146
|
-
},
|
|
3307
|
+
}, _callee13, this);
|
|
3147
3308
|
}));
|
|
3148
3309
|
function recalculateSummary(_x11) {
|
|
3149
3310
|
return _recalculateSummary.apply(this, arguments);
|
|
@@ -3153,30 +3314,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3153
3314
|
}, {
|
|
3154
3315
|
key: "getOrderSummary",
|
|
3155
3316
|
value: function () {
|
|
3156
|
-
var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3317
|
+
var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
3157
3318
|
var summary;
|
|
3158
|
-
return _regeneratorRuntime().wrap(function
|
|
3159
|
-
while (1) switch (
|
|
3319
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context16) {
|
|
3320
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
3160
3321
|
case 0:
|
|
3161
|
-
|
|
3322
|
+
_context16.next = 2;
|
|
3162
3323
|
return this.recalculateSummary({
|
|
3163
3324
|
createIfMissing: true
|
|
3164
3325
|
});
|
|
3165
3326
|
case 2:
|
|
3166
|
-
summary =
|
|
3327
|
+
summary = _context16.sent;
|
|
3167
3328
|
if (summary) {
|
|
3168
|
-
|
|
3329
|
+
_context16.next = 5;
|
|
3169
3330
|
break;
|
|
3170
3331
|
}
|
|
3171
|
-
return
|
|
3332
|
+
return _context16.abrupt("return", createEmptySummary());
|
|
3172
3333
|
case 5:
|
|
3173
3334
|
this.persistTempOrder();
|
|
3174
|
-
return
|
|
3335
|
+
return _context16.abrupt("return", summary);
|
|
3175
3336
|
case 7:
|
|
3176
3337
|
case "end":
|
|
3177
|
-
return
|
|
3338
|
+
return _context16.stop();
|
|
3178
3339
|
}
|
|
3179
|
-
},
|
|
3340
|
+
}, _callee14, this);
|
|
3180
3341
|
}));
|
|
3181
3342
|
function getOrderSummary() {
|
|
3182
3343
|
return _getOrderSummary.apply(this, arguments);
|
|
@@ -3200,21 +3361,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3200
3361
|
}, {
|
|
3201
3362
|
key: "syncTempOrderNoteToRemote",
|
|
3202
3363
|
value: function () {
|
|
3203
|
-
var _syncTempOrderNoteToRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3204
|
-
return _regeneratorRuntime().wrap(function
|
|
3205
|
-
while (1) switch (
|
|
3364
|
+
var _syncTempOrderNoteToRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(orderId, note) {
|
|
3365
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context17) {
|
|
3366
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
3206
3367
|
case 0:
|
|
3207
|
-
|
|
3368
|
+
_context17.next = 2;
|
|
3208
3369
|
return this.request.put("/order/order/".concat(orderId, "/note"), {
|
|
3209
3370
|
note: note
|
|
3210
3371
|
});
|
|
3211
3372
|
case 2:
|
|
3212
|
-
return
|
|
3373
|
+
return _context17.abrupt("return", note);
|
|
3213
3374
|
case 3:
|
|
3214
3375
|
case "end":
|
|
3215
|
-
return
|
|
3376
|
+
return _context17.stop();
|
|
3216
3377
|
}
|
|
3217
|
-
},
|
|
3378
|
+
}, _callee15, this);
|
|
3218
3379
|
}));
|
|
3219
3380
|
function syncTempOrderNoteToRemote(_x12, _x13) {
|
|
3220
3381
|
return _syncTempOrderNoteToRemote.apply(this, arguments);
|
|
@@ -3224,54 +3385,352 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3224
3385
|
}, {
|
|
3225
3386
|
key: "getTempOrderNote",
|
|
3226
3387
|
value: function getTempOrderNote() {
|
|
3227
|
-
var _this$store$
|
|
3228
|
-
return ((_this$store$
|
|
3388
|
+
var _this$store$tempOrder4;
|
|
3389
|
+
return ((_this$store$tempOrder4 = this.store.tempOrder) === null || _this$store$tempOrder4 === void 0 ? void 0 : _this$store$tempOrder4.note) || '';
|
|
3229
3390
|
}
|
|
3230
3391
|
}, {
|
|
3231
|
-
key: "
|
|
3232
|
-
value: function
|
|
3233
|
-
var
|
|
3234
|
-
|
|
3235
|
-
tempOrder.
|
|
3236
|
-
|
|
3237
|
-
|
|
3392
|
+
key: "ensureSalesNotesRuntimeState",
|
|
3393
|
+
value: function ensureSalesNotesRuntimeState(tempOrder) {
|
|
3394
|
+
var hadNotesSnapshot = Array.isArray(tempOrder.notes);
|
|
3395
|
+
if (!Array.isArray(tempOrder.notes)) tempOrder.notes = [];
|
|
3396
|
+
if (!tempOrder._extend || _typeof(tempOrder._extend) !== 'object') {
|
|
3397
|
+
tempOrder._extend = {
|
|
3398
|
+
productsByUid: {}
|
|
3399
|
+
};
|
|
3400
|
+
}
|
|
3401
|
+
if (!tempOrder._extend.salesNotesState) {
|
|
3402
|
+
tempOrder._extend.salesNotesState = {
|
|
3403
|
+
loaded: hadNotesSnapshot,
|
|
3404
|
+
dirty: false
|
|
3405
|
+
};
|
|
3406
|
+
}
|
|
3407
|
+
return tempOrder._extend.salesNotesState;
|
|
3238
3408
|
}
|
|
3239
3409
|
}, {
|
|
3240
|
-
key: "
|
|
3241
|
-
value: function
|
|
3242
|
-
var
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
tempOrder: tempOrder,
|
|
3251
|
-
summary: summaryWithDeposit,
|
|
3252
|
-
orderPaidAmount: paidPaymentSummary.gapPaidAmount
|
|
3253
|
-
})
|
|
3254
|
-
});
|
|
3255
|
-
this.store.summary = summary;
|
|
3256
|
-
this.updateTempOrderPaymentStatus(tempOrder, {
|
|
3257
|
-
previousSummary: previousSummary,
|
|
3258
|
-
summary: summary
|
|
3259
|
-
});
|
|
3260
|
-
this.persistTempOrder();
|
|
3261
|
-
return summary;
|
|
3410
|
+
key: "ensureSalesNotesLoadedForMutation",
|
|
3411
|
+
value: function ensureSalesNotesLoadedForMutation(tempOrder) {
|
|
3412
|
+
var state = this.ensureSalesNotesRuntimeState(tempOrder);
|
|
3413
|
+
if (state.loaded) return;
|
|
3414
|
+
if (tempOrder.order_id === null || tempOrder.order_id === undefined) {
|
|
3415
|
+
state.loaded = true;
|
|
3416
|
+
tempOrder.notes = [];
|
|
3417
|
+
return;
|
|
3418
|
+
}
|
|
3419
|
+
throw new Error('[Order Notes] 当前订单 Notes 尚未完整加载,禁止提交部分快照');
|
|
3262
3420
|
}
|
|
3263
3421
|
}, {
|
|
3264
|
-
key: "
|
|
3265
|
-
value: function
|
|
3266
|
-
var
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3422
|
+
key: "normalizeSalesNoteUuid",
|
|
3423
|
+
value: function normalizeSalesNoteUuid(value, field) {
|
|
3424
|
+
var uuid = String(value !== null && value !== void 0 ? value : '').trim();
|
|
3425
|
+
if (!uuid) throw new Error("[Order Notes] ".concat(field, " \u4E0D\u80FD\u4E3A\u7A7A"));
|
|
3426
|
+
if (uuid.length > 255) {
|
|
3427
|
+
throw new Error("[Order Notes] ".concat(field, " \u4E0D\u80FD\u8D85\u8FC7 255 \u4E2A\u5B57\u7B26"));
|
|
3428
|
+
}
|
|
3429
|
+
return uuid;
|
|
3270
3430
|
}
|
|
3271
3431
|
}, {
|
|
3272
|
-
key: "
|
|
3273
|
-
value: function
|
|
3274
|
-
|
|
3432
|
+
key: "getSalesNotePrimaryRelation",
|
|
3433
|
+
value: function getSalesNotePrimaryRelation(note) {
|
|
3434
|
+
return note.note_relations.find(function (relation) {
|
|
3435
|
+
return relation.is_primary === 1;
|
|
3436
|
+
}) || null;
|
|
3437
|
+
}
|
|
3438
|
+
}, {
|
|
3439
|
+
key: "removeSalesNotesForMissingProductLines",
|
|
3440
|
+
value: function removeSalesNotesForMissingProductLines(tempOrder) {
|
|
3441
|
+
var _this19 = this;
|
|
3442
|
+
var state = this.ensureSalesNotesRuntimeState(tempOrder);
|
|
3443
|
+
if (!state.loaded || !Array.isArray(tempOrder.notes) || tempOrder.notes.length === 0) {
|
|
3444
|
+
return;
|
|
3445
|
+
}
|
|
3446
|
+
var remainingProductUids = new Set((tempOrder.products || []).map(function (product) {
|
|
3447
|
+
var _product$metadata7;
|
|
3448
|
+
return ((_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.unique_identification_number) || product.unique_identification_number;
|
|
3449
|
+
}).filter(function (uid) {
|
|
3450
|
+
return typeof uid === 'string' && uid.length > 0;
|
|
3451
|
+
}));
|
|
3452
|
+
var nextNotes = tempOrder.notes.filter(function (note) {
|
|
3453
|
+
var primary = _this19.getSalesNotePrimaryRelation(note);
|
|
3454
|
+
if (!primary || primary.target_type !== 'order_detail') return true;
|
|
3455
|
+
return remainingProductUids.has(primary.target_uuid);
|
|
3456
|
+
});
|
|
3457
|
+
if (nextNotes.length === tempOrder.notes.length) return;
|
|
3458
|
+
tempOrder.notes = nextNotes;
|
|
3459
|
+
state.dirty = true;
|
|
3460
|
+
}
|
|
3461
|
+
}, {
|
|
3462
|
+
key: "setSalesNoteOnTempOrder",
|
|
3463
|
+
value: function setSalesNoteOnTempOrder(tempOrder, input) {
|
|
3464
|
+
var _input$target,
|
|
3465
|
+
_this20 = this,
|
|
3466
|
+
_tempOrder$shop_order;
|
|
3467
|
+
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
3468
|
+
var note_type = String(input.note_type || '').trim();
|
|
3469
|
+
var policy = getSalesNotePolicy(note_type);
|
|
3470
|
+
if (!policy) {
|
|
3471
|
+
throw new Error("[Order Notes] \u5F53\u524D\u672A\u6CE8\u518C\u5907\u6CE8\u7C7B\u578B: ".concat(note_type || '(empty)'));
|
|
3472
|
+
}
|
|
3473
|
+
if (((_input$target = input.target) === null || _input$target === void 0 ? void 0 : _input$target.target_type) !== 'order_detail') {
|
|
3474
|
+
throw new Error('[Order Notes] 本期只支持 order_detail 作为主体');
|
|
3475
|
+
}
|
|
3476
|
+
var target_uuid = this.normalizeSalesNoteUuid(input.target.target_uuid, 'target_uuid');
|
|
3477
|
+
var targetProductExists = (tempOrder.products || []).some(function (product) {
|
|
3478
|
+
var _product$metadata8;
|
|
3479
|
+
var productLineUid = ((_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.unique_identification_number) || product.unique_identification_number;
|
|
3480
|
+
return String(productLineUid !== null && productLineUid !== void 0 ? productLineUid : '') === target_uuid;
|
|
3481
|
+
});
|
|
3482
|
+
if (!targetProductExists) {
|
|
3483
|
+
throw new Error('[Order Notes] 目标商品行不存在');
|
|
3484
|
+
}
|
|
3485
|
+
var text = buildSalesNoteText(input.text);
|
|
3486
|
+
var notes = tempOrder.notes || [];
|
|
3487
|
+
// 当前 allergy policy 固定同一商品行只保留一条;业务调用方不参与去重规则。
|
|
3488
|
+
var existingIndex = policy.uniquePerPrimaryTarget ? notes.findIndex(function (note) {
|
|
3489
|
+
var primary = _this20.getSalesNotePrimaryRelation(note);
|
|
3490
|
+
return note.note_type === note_type && (primary === null || primary === void 0 ? void 0 : primary.target_type) === 'order_detail' && primary.target_uuid === target_uuid;
|
|
3491
|
+
}) : -1;
|
|
3492
|
+
var existing = existingIndex >= 0 ? notes[existingIndex] : null;
|
|
3493
|
+
var existingPrimary = existing === null || existing === void 0 ? void 0 : existing.note_relations.find(function (relation) {
|
|
3494
|
+
return relation.is_primary === 1 && relation.target_type === 'order_detail';
|
|
3495
|
+
});
|
|
3496
|
+
var existingOrderRelation = existing === null || existing === void 0 ? void 0 : existing.note_relations.find(function (relation) {
|
|
3497
|
+
return relation.is_primary === 0 && relation.target_type === 'order';
|
|
3498
|
+
});
|
|
3499
|
+
var note = {
|
|
3500
|
+
uuid: (existing === null || existing === void 0 ? void 0 : existing.uuid) || createUuidV4(),
|
|
3501
|
+
note_type: policy.note_type,
|
|
3502
|
+
content: {
|
|
3503
|
+
text: text
|
|
3504
|
+
},
|
|
3505
|
+
importance: policy.importance,
|
|
3506
|
+
note_relations: [{
|
|
3507
|
+
uuid: (existingPrimary === null || existingPrimary === void 0 ? void 0 : existingPrimary.uuid) || createUuidV4(),
|
|
3508
|
+
relation_type: policy.primary_relation_type,
|
|
3509
|
+
target_type: 'order_detail',
|
|
3510
|
+
target_uuid: target_uuid,
|
|
3511
|
+
is_primary: 1
|
|
3512
|
+
}, {
|
|
3513
|
+
uuid: (existingOrderRelation === null || existingOrderRelation === void 0 ? void 0 : existingOrderRelation.uuid) || createUuidV4(),
|
|
3514
|
+
relation_type: policy.secondary_order_relation_type,
|
|
3515
|
+
target_type: 'order',
|
|
3516
|
+
target_uuid: String((_tempOrder$shop_order = tempOrder.shop_order_number) !== null && _tempOrder$shop_order !== void 0 ? _tempOrder$shop_order : ''),
|
|
3517
|
+
is_primary: 0
|
|
3518
|
+
}]
|
|
3519
|
+
};
|
|
3520
|
+
var duplicateIndex = notes.findIndex(function (item, index) {
|
|
3521
|
+
return item.uuid === note.uuid && index !== existingIndex;
|
|
3522
|
+
});
|
|
3523
|
+
if (duplicateIndex >= 0) {
|
|
3524
|
+
throw new Error('[Order Notes] uuid 已被其他 Note 使用');
|
|
3525
|
+
}
|
|
3526
|
+
tempOrder.notes = existingIndex >= 0 ? notes.map(function (item, index) {
|
|
3527
|
+
return index === existingIndex ? note : item;
|
|
3528
|
+
}) : [].concat(_toConsumableArray(notes), [note]);
|
|
3529
|
+
var state = this.ensureSalesNotesRuntimeState(tempOrder);
|
|
3530
|
+
state.loaded = true;
|
|
3531
|
+
state.dirty = true;
|
|
3532
|
+
return note;
|
|
3533
|
+
}
|
|
3534
|
+
}, {
|
|
3535
|
+
key: "getSalesNotes",
|
|
3536
|
+
value: function getSalesNotes() {
|
|
3537
|
+
var tempOrder = this.ensureTempOrder();
|
|
3538
|
+
this.ensureSalesNotesRuntimeState(tempOrder);
|
|
3539
|
+
return cloneDeep(tempOrder.notes || []);
|
|
3540
|
+
}
|
|
3541
|
+
}, {
|
|
3542
|
+
key: "createSalesNotesMutationSnapshot",
|
|
3543
|
+
value: function createSalesNotesMutationSnapshot() {
|
|
3544
|
+
var _tempOrder$order_id2;
|
|
3545
|
+
var tempOrder = this.ensureTempOrder();
|
|
3546
|
+
var state = this.ensureSalesNotesRuntimeState(tempOrder);
|
|
3547
|
+
return {
|
|
3548
|
+
orderIdentity: {
|
|
3549
|
+
orderId: (_tempOrder$order_id2 = tempOrder.order_id) !== null && _tempOrder$order_id2 !== void 0 ? _tempOrder$order_id2 : null,
|
|
3550
|
+
externalSaleNumber: String(tempOrder.external_sale_number || '')
|
|
3551
|
+
},
|
|
3552
|
+
notes: cloneDeep(tempOrder.notes || []),
|
|
3553
|
+
state: cloneDeep(state)
|
|
3554
|
+
};
|
|
3555
|
+
}
|
|
3556
|
+
}, {
|
|
3557
|
+
key: "restoreSalesNotesMutationSnapshot",
|
|
3558
|
+
value: function restoreSalesNotesMutationSnapshot(snapshot) {
|
|
3559
|
+
var _snapshot$state, _snapshot$state2;
|
|
3560
|
+
if (!snapshot || !Array.isArray(snapshot.notes) || !snapshot.orderIdentity || typeof snapshot.orderIdentity.externalSaleNumber !== 'string' || typeof ((_snapshot$state = snapshot.state) === null || _snapshot$state === void 0 ? void 0 : _snapshot$state.loaded) !== 'boolean' || typeof ((_snapshot$state2 = snapshot.state) === null || _snapshot$state2 === void 0 ? void 0 : _snapshot$state2.dirty) !== 'boolean') {
|
|
3561
|
+
throw new Error('[Order Notes] 无效的 mutation snapshot');
|
|
3562
|
+
}
|
|
3563
|
+
var tempOrder = this.store.tempOrder;
|
|
3564
|
+
if (!tempOrder) throw new Error('[Order Notes] 当前订单不存在');
|
|
3565
|
+
var snapshotOrderId = snapshot.orderIdentity.orderId;
|
|
3566
|
+
var currentOrderId = tempOrder.order_id;
|
|
3567
|
+
var hasSnapshotOrderId = snapshotOrderId !== null && snapshotOrderId !== undefined && String(snapshotOrderId).trim().length > 0;
|
|
3568
|
+
var hasCurrentOrderId = currentOrderId !== null && currentOrderId !== undefined && String(currentOrderId).trim().length > 0;
|
|
3569
|
+
var isSameOrder = hasSnapshotOrderId && hasCurrentOrderId ? String(snapshotOrderId) === String(currentOrderId) : Boolean(snapshot.orderIdentity.externalSaleNumber) && snapshot.orderIdentity.externalSaleNumber === String(tempOrder.external_sale_number || '');
|
|
3570
|
+
if (!isSameOrder) {
|
|
3571
|
+
throw new Error('[Order Notes] 当前订单已切换,拒绝恢复旧订单快照');
|
|
3572
|
+
}
|
|
3573
|
+
this.ensureSalesNotesRuntimeState(tempOrder);
|
|
3574
|
+
tempOrder.notes = cloneDeep(snapshot.notes);
|
|
3575
|
+
tempOrder._extend.salesNotesState = cloneDeep(snapshot.state);
|
|
3576
|
+
this.notifyTempOrderChanged();
|
|
3577
|
+
}
|
|
3578
|
+
}, {
|
|
3579
|
+
key: "setSalesNote",
|
|
3580
|
+
value: function () {
|
|
3581
|
+
var _setSalesNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(input) {
|
|
3582
|
+
var tempOrder, note;
|
|
3583
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context18) {
|
|
3584
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
3585
|
+
case 0:
|
|
3586
|
+
tempOrder = this.ensureTempOrder();
|
|
3587
|
+
note = this.setSalesNoteOnTempOrder(tempOrder, input);
|
|
3588
|
+
this.notifyTempOrderChanged();
|
|
3589
|
+
return _context18.abrupt("return", cloneDeep(note));
|
|
3590
|
+
case 4:
|
|
3591
|
+
case "end":
|
|
3592
|
+
return _context18.stop();
|
|
3593
|
+
}
|
|
3594
|
+
}, _callee16, this);
|
|
3595
|
+
}));
|
|
3596
|
+
function setSalesNote(_x14) {
|
|
3597
|
+
return _setSalesNote.apply(this, arguments);
|
|
3598
|
+
}
|
|
3599
|
+
return setSalesNote;
|
|
3600
|
+
}()
|
|
3601
|
+
}, {
|
|
3602
|
+
key: "removeSalesNote",
|
|
3603
|
+
value: function () {
|
|
3604
|
+
var _removeSalesNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(uuid) {
|
|
3605
|
+
var tempOrder, normalizedUuid, notes, nextNotes, state;
|
|
3606
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context19) {
|
|
3607
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
3608
|
+
case 0:
|
|
3609
|
+
tempOrder = this.ensureTempOrder();
|
|
3610
|
+
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
3611
|
+
normalizedUuid = this.normalizeSalesNoteUuid(uuid, 'uuid');
|
|
3612
|
+
notes = tempOrder.notes || [];
|
|
3613
|
+
nextNotes = notes.filter(function (note) {
|
|
3614
|
+
return note.uuid !== normalizedUuid;
|
|
3615
|
+
});
|
|
3616
|
+
if (!(nextNotes.length === notes.length)) {
|
|
3617
|
+
_context19.next = 7;
|
|
3618
|
+
break;
|
|
3619
|
+
}
|
|
3620
|
+
return _context19.abrupt("return");
|
|
3621
|
+
case 7:
|
|
3622
|
+
tempOrder.notes = nextNotes;
|
|
3623
|
+
state = this.ensureSalesNotesRuntimeState(tempOrder);
|
|
3624
|
+
state.dirty = true;
|
|
3625
|
+
this.notifyTempOrderChanged();
|
|
3626
|
+
case 11:
|
|
3627
|
+
case "end":
|
|
3628
|
+
return _context19.stop();
|
|
3629
|
+
}
|
|
3630
|
+
}, _callee17, this);
|
|
3631
|
+
}));
|
|
3632
|
+
function removeSalesNote(_x15) {
|
|
3633
|
+
return _removeSalesNote.apply(this, arguments);
|
|
3634
|
+
}
|
|
3635
|
+
return removeSalesNote;
|
|
3636
|
+
}()
|
|
3637
|
+
}, {
|
|
3638
|
+
key: "clearSalesNotes",
|
|
3639
|
+
value: function () {
|
|
3640
|
+
var _clearSalesNotes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
3641
|
+
var tempOrder, state;
|
|
3642
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context20) {
|
|
3643
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
3644
|
+
case 0:
|
|
3645
|
+
tempOrder = this.ensureTempOrder();
|
|
3646
|
+
tempOrder.notes = [];
|
|
3647
|
+
state = this.ensureSalesNotesRuntimeState(tempOrder);
|
|
3648
|
+
state.loaded = true;
|
|
3649
|
+
state.dirty = true;
|
|
3650
|
+
this.notifyTempOrderChanged();
|
|
3651
|
+
case 6:
|
|
3652
|
+
case "end":
|
|
3653
|
+
return _context20.stop();
|
|
3654
|
+
}
|
|
3655
|
+
}, _callee18, this);
|
|
3656
|
+
}));
|
|
3657
|
+
function clearSalesNotes() {
|
|
3658
|
+
return _clearSalesNotes.apply(this, arguments);
|
|
3659
|
+
}
|
|
3660
|
+
return clearSalesNotes;
|
|
3661
|
+
}()
|
|
3662
|
+
}, {
|
|
3663
|
+
key: "updateTempOrderShopDiscount",
|
|
3664
|
+
value: function updateTempOrderShopDiscount(amount) {
|
|
3665
|
+
var tempOrder = this.ensureTempOrder();
|
|
3666
|
+
var discount = Decimal.max(new Decimal(Number(amount) || 0), 0).toDecimalPlaces(2).toFixed(2);
|
|
3667
|
+
tempOrder.shop_discount = discount;
|
|
3668
|
+
this.persistTempOrder();
|
|
3669
|
+
return tempOrder.shop_discount;
|
|
3670
|
+
}
|
|
3671
|
+
}, {
|
|
3672
|
+
key: "updateTempOrderDepositAmount",
|
|
3673
|
+
value: function updateTempOrderDepositAmount(amount) {
|
|
3674
|
+
var tempOrder = this.ensureTempOrder();
|
|
3675
|
+
var depositAmount = this.normalizeDepositAmount(amount);
|
|
3676
|
+
var previousSummary = this.store.summary || createEmptySummary();
|
|
3677
|
+
var summaryWithDeposit = this.applyDepositAmountToSummary(tempOrder, _objectSpread(_objectSpread({}, createEmptySummary()), previousSummary), depositAmount);
|
|
3678
|
+
this.setManualDepositOverride(tempOrder, depositAmount);
|
|
3679
|
+
var paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
|
|
3680
|
+
var summary = _objectSpread(_objectSpread({}, summaryWithDeposit), {}, {
|
|
3681
|
+
amount_gap: this.calculateSummaryAmountGap({
|
|
3682
|
+
tempOrder: tempOrder,
|
|
3683
|
+
summary: summaryWithDeposit,
|
|
3684
|
+
orderPaidAmount: paidPaymentSummary.gapPaidAmount
|
|
3685
|
+
})
|
|
3686
|
+
});
|
|
3687
|
+
this.store.summary = summary;
|
|
3688
|
+
this.updateTempOrderPaymentStatus(tempOrder, {
|
|
3689
|
+
previousSummary: previousSummary,
|
|
3690
|
+
summary: summary
|
|
3691
|
+
});
|
|
3692
|
+
this.persistTempOrder();
|
|
3693
|
+
return summary;
|
|
3694
|
+
}
|
|
3695
|
+
}, {
|
|
3696
|
+
key: "updateTempOrderBuzzer",
|
|
3697
|
+
value: function updateTempOrderBuzzer(buzzer) {
|
|
3698
|
+
var tempOrder = this.ensureTempOrder();
|
|
3699
|
+
tempOrder.buzzer = String(buzzer || '');
|
|
3700
|
+
this.persistTempOrder();
|
|
3701
|
+
return tempOrder.buzzer;
|
|
3702
|
+
}
|
|
3703
|
+
}, {
|
|
3704
|
+
key: "updateTempOrderShopServiceData",
|
|
3705
|
+
value: function updateTempOrderShopServiceData(patch) {
|
|
3706
|
+
var tempOrder = this.ensureTempOrder();
|
|
3707
|
+
var metadata = tempOrder.metadata && _typeof(tempOrder.metadata) === 'object' && !Array.isArray(tempOrder.metadata) ? tempOrder.metadata : {};
|
|
3708
|
+
var currentShopServiceData = metadata.shop_service_data && _typeof(metadata.shop_service_data) === 'object' && !Array.isArray(metadata.shop_service_data) ? metadata.shop_service_data : {};
|
|
3709
|
+
var shopServiceData = _objectSpread(_objectSpread({}, currentShopServiceData), patch);
|
|
3710
|
+
tempOrder.metadata = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
3711
|
+
shop_service_data: shopServiceData
|
|
3712
|
+
});
|
|
3713
|
+
this.persistTempOrder();
|
|
3714
|
+
return shopServiceData;
|
|
3715
|
+
}
|
|
3716
|
+
}, {
|
|
3717
|
+
key: "updateTempOrderPickupReferenceMode",
|
|
3718
|
+
value: function updateTempOrderPickupReferenceMode(mode) {
|
|
3719
|
+
return this.updateTempOrderShopServiceData({
|
|
3720
|
+
pickup_reference_mode: mode
|
|
3721
|
+
});
|
|
3722
|
+
}
|
|
3723
|
+
}, {
|
|
3724
|
+
key: "updateTempOrderServiceType",
|
|
3725
|
+
value: function updateTempOrderServiceType(serviceType) {
|
|
3726
|
+
return this.updateTempOrderShopServiceData({
|
|
3727
|
+
service_type: serviceType
|
|
3728
|
+
});
|
|
3729
|
+
}
|
|
3730
|
+
}, {
|
|
3731
|
+
key: "updateTempOrderContactsInfo",
|
|
3732
|
+
value: function updateTempOrderContactsInfo(contactsInfo) {
|
|
3733
|
+
var tempOrder = this.ensureTempOrder();
|
|
3275
3734
|
tempOrder.contacts_info = contactsInfo && _typeof(contactsInfo) === 'object' && !Array.isArray(contactsInfo) ? contactsInfo : null;
|
|
3276
3735
|
this.persistTempOrder();
|
|
3277
3736
|
return tempOrder.contacts_info;
|
|
@@ -3309,35 +3768,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3309
3768
|
}, {
|
|
3310
3769
|
key: "productHasCustomerBoundDiscount",
|
|
3311
3770
|
value: function productHasCustomerBoundDiscount(product) {
|
|
3312
|
-
var
|
|
3771
|
+
var _this21 = this;
|
|
3313
3772
|
if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
|
|
3314
|
-
return
|
|
3773
|
+
return _this21.isCustomerBoundDiscount(discount);
|
|
3315
3774
|
})) {
|
|
3316
3775
|
return true;
|
|
3317
3776
|
}
|
|
3318
3777
|
return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
|
|
3319
3778
|
return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
|
|
3320
|
-
return
|
|
3779
|
+
return _this21.isCustomerBoundDiscount(discount);
|
|
3321
3780
|
});
|
|
3322
3781
|
});
|
|
3323
3782
|
}
|
|
3324
3783
|
}, {
|
|
3325
3784
|
key: "shouldSkipDiscountCalculation",
|
|
3326
3785
|
value: function shouldSkipDiscountCalculation(tempOrder) {
|
|
3327
|
-
var _this$store$
|
|
3328
|
-
_this$store$
|
|
3329
|
-
|
|
3786
|
+
var _this$store$discount20,
|
|
3787
|
+
_this$store$discount21,
|
|
3788
|
+
_this22 = this;
|
|
3330
3789
|
if (this.hasActiveCustomerBoundDiscount) return false;
|
|
3331
|
-
var discountList = ((_this$store$
|
|
3790
|
+
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)) || [];
|
|
3332
3791
|
if (discountList.length > 0) return false;
|
|
3333
3792
|
return !(tempOrder.products || []).some(function (product) {
|
|
3334
|
-
return
|
|
3793
|
+
return _this22.productHasCustomerBoundDiscount(product);
|
|
3335
3794
|
});
|
|
3336
3795
|
}
|
|
3337
3796
|
}, {
|
|
3338
3797
|
key: "clearCustomerBoundDiscounts",
|
|
3339
3798
|
value: function clearCustomerBoundDiscounts(tempOrder) {
|
|
3340
|
-
var
|
|
3799
|
+
var _this23 = this,
|
|
3341
3800
|
_discountModule$getDi,
|
|
3342
3801
|
_discountModule$getOr,
|
|
3343
3802
|
_discountModule$setDi,
|
|
@@ -3346,7 +3805,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3346
3805
|
var filterDiscountList = function filterDiscountList(discountList) {
|
|
3347
3806
|
if (!Array.isArray(discountList)) return [];
|
|
3348
3807
|
return discountList.filter(function (discount) {
|
|
3349
|
-
var shouldRemove =
|
|
3808
|
+
var shouldRemove = _this23.isCustomerBoundDiscount(discount);
|
|
3350
3809
|
if (shouldRemove) didRemoveCustomerBoundDiscount = true;
|
|
3351
3810
|
return !shouldRemove;
|
|
3352
3811
|
});
|
|
@@ -3373,12 +3832,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3373
3832
|
var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
|
|
3374
3833
|
var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
|
|
3375
3834
|
var nextDiscounts = currentDiscounts.filter(function (discount) {
|
|
3376
|
-
if (
|
|
3377
|
-
return !
|
|
3835
|
+
if (_this23.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
3836
|
+
return !_this23.isCustomerBoundDiscount(discount);
|
|
3378
3837
|
});
|
|
3379
3838
|
var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
|
|
3380
|
-
if (
|
|
3381
|
-
return !
|
|
3839
|
+
if (_this23.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
3840
|
+
return !_this23.isCustomerBoundDiscount(discount);
|
|
3382
3841
|
});
|
|
3383
3842
|
void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
|
|
3384
3843
|
void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
|
|
@@ -3393,9 +3852,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3393
3852
|
}, {
|
|
3394
3853
|
key: "updateTempOrderCustomer",
|
|
3395
3854
|
value: function updateTempOrderCustomer(customer) {
|
|
3396
|
-
var _tempOrder$
|
|
3855
|
+
var _tempOrder$customer_i3, _ref54, _ref55, _customer$customer_id, _ref56, _ref57, _ref58, _customer$customer_na, _ref59, _customer$country_cal, _tempOrder$customer_i4;
|
|
3397
3856
|
var tempOrder = this.ensureTempOrder();
|
|
3398
|
-
var previousCustomerId = (_tempOrder$
|
|
3857
|
+
var previousCustomerId = (_tempOrder$customer_i3 = tempOrder.customer_id) !== null && _tempOrder$customer_i3 !== void 0 ? _tempOrder$customer_i3 : null;
|
|
3399
3858
|
var customerId = (_ref54 = (_ref55 = (_customer$customer_id = customer.customer_id) !== null && _customer$customer_id !== void 0 ? _customer$customer_id : customer.customerId) !== null && _ref55 !== void 0 ? _ref55 : customer.id) !== null && _ref54 !== void 0 ? _ref54 : null;
|
|
3400
3859
|
var customerName = (_ref56 = (_ref57 = (_ref58 = (_customer$customer_na = customer.customer_name) !== null && _customer$customer_na !== void 0 ? _customer$customer_na : customer.customerName) !== null && _ref58 !== void 0 ? _ref58 : customer.display_name) !== null && _ref57 !== void 0 ? _ref57 : customer.name) !== null && _ref56 !== void 0 ? _ref56 : '';
|
|
3401
3860
|
tempOrder.customer_id = customerId === null || customerId === undefined || customerId === '' ? null : Number(customerId);
|
|
@@ -3411,7 +3870,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3411
3870
|
phone: tempOrder.phone,
|
|
3412
3871
|
email: tempOrder.email
|
|
3413
3872
|
});
|
|
3414
|
-
var nextCustomerId = (_tempOrder$
|
|
3873
|
+
var nextCustomerId = (_tempOrder$customer_i4 = tempOrder.customer_id) !== null && _tempOrder$customer_i4 !== void 0 ? _tempOrder$customer_i4 : null;
|
|
3874
|
+
if (String(previousCustomerId !== null && previousCustomerId !== void 0 ? previousCustomerId : '') !== String(nextCustomerId !== null && nextCustomerId !== void 0 ? nextCustomerId : '') && !hasPersistedOrderId(tempOrder.order_id)) {
|
|
3875
|
+
this.store.availableWalletIds = [];
|
|
3876
|
+
this.clearTempOrderPointCardSnapshot(tempOrder);
|
|
3877
|
+
}
|
|
3415
3878
|
this.persistTempOrder();
|
|
3416
3879
|
return {
|
|
3417
3880
|
customerId: tempOrder.customer_id,
|
|
@@ -3423,13 +3886,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3423
3886
|
}, {
|
|
3424
3887
|
key: "setOrderCustomer",
|
|
3425
3888
|
value: function setOrderCustomer(patch, snapshot) {
|
|
3426
|
-
var _tempOrder$
|
|
3889
|
+
var _tempOrder$customer_i5, _tempOrder$customer_i6;
|
|
3427
3890
|
if (!patch) {
|
|
3428
3891
|
this.clearOrderCustomer();
|
|
3429
3892
|
return;
|
|
3430
3893
|
}
|
|
3431
3894
|
var tempOrder = this.ensureTempOrder();
|
|
3432
|
-
var previousCustomerId = (_tempOrder$
|
|
3895
|
+
var previousCustomerId = (_tempOrder$customer_i5 = tempOrder.customer_id) !== null && _tempOrder$customer_i5 !== void 0 ? _tempOrder$customer_i5 : null;
|
|
3433
3896
|
tempOrder.customer_id = patch.customer_id || patch.id || null;
|
|
3434
3897
|
tempOrder.customer_name = String(patch.customer_name || '');
|
|
3435
3898
|
tempOrder.country_calling_code = String(patch.country_calling_code || '');
|
|
@@ -3447,9 +3910,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3447
3910
|
var extend = this.ensureExtend(tempOrder);
|
|
3448
3911
|
if (snapshot === null) delete extend.customerSnapshot;else extend.customerSnapshot = cloneDeep(snapshot);
|
|
3449
3912
|
}
|
|
3450
|
-
var nextCustomerId = (_tempOrder$
|
|
3913
|
+
var nextCustomerId = (_tempOrder$customer_i6 = tempOrder.customer_id) !== null && _tempOrder$customer_i6 !== void 0 ? _tempOrder$customer_i6 : null;
|
|
3451
3914
|
if (String(previousCustomerId !== null && previousCustomerId !== void 0 ? previousCustomerId : '') !== String(nextCustomerId !== null && nextCustomerId !== void 0 ? nextCustomerId : '')) {
|
|
3452
3915
|
this.store.availableWalletIds = [];
|
|
3916
|
+
this.store.virtualCurrencyList = [];
|
|
3917
|
+
if (!hasPersistedOrderId(tempOrder.order_id)) {
|
|
3918
|
+
this.clearTempOrderPointCardSnapshot(tempOrder);
|
|
3919
|
+
}
|
|
3453
3920
|
clearTempOrderHolderAssignments(tempOrder);
|
|
3454
3921
|
this.clearCustomerBoundDiscounts(tempOrder);
|
|
3455
3922
|
this.applyDiscount();
|
|
@@ -3478,8 +3945,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3478
3945
|
}, {
|
|
3479
3946
|
key: "getOrderCustomerSnapshot",
|
|
3480
3947
|
value: function getOrderCustomerSnapshot() {
|
|
3481
|
-
var _this$store$
|
|
3482
|
-
var snapshot = (_this$store$
|
|
3948
|
+
var _this$store$tempOrder5;
|
|
3949
|
+
var snapshot = (_this$store$tempOrder5 = this.store.tempOrder) === null || _this$store$tempOrder5 === void 0 || (_this$store$tempOrder5 = _this$store$tempOrder5._extend) === null || _this$store$tempOrder5 === void 0 ? void 0 : _this$store$tempOrder5.customerSnapshot;
|
|
3483
3950
|
return snapshot ? cloneDeep(snapshot) : null;
|
|
3484
3951
|
}
|
|
3485
3952
|
}, {
|
|
@@ -3495,6 +3962,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3495
3962
|
tempOrder.customer = null;
|
|
3496
3963
|
if (tempOrder._extend) delete tempOrder._extend.customerSnapshot;
|
|
3497
3964
|
this.store.availableWalletIds = [];
|
|
3965
|
+
this.store.virtualCurrencyList = [];
|
|
3966
|
+
if (!hasPersistedOrderId(tempOrder.order_id)) {
|
|
3967
|
+
this.clearTempOrderPointCardSnapshot(tempOrder);
|
|
3968
|
+
}
|
|
3498
3969
|
this.clearCustomerBoundDiscounts(tempOrder);
|
|
3499
3970
|
this.applyDiscount();
|
|
3500
3971
|
this.persistTempOrder();
|
|
@@ -3539,10 +4010,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3539
4010
|
}, {
|
|
3540
4011
|
key: "setOrderPayments",
|
|
3541
4012
|
value: function setOrderPayments(payments) {
|
|
3542
|
-
var
|
|
4013
|
+
var _this24 = this;
|
|
3543
4014
|
var tempOrder = this.ensureTempOrder();
|
|
3544
4015
|
tempOrder.payments = mapPaymentItemsToOrderPayments((payments || []).map(function (payment) {
|
|
3545
|
-
return
|
|
4016
|
+
return _this24.normalizePaymentSource(payment, {
|
|
3546
4017
|
defaultPaid: false
|
|
3547
4018
|
});
|
|
3548
4019
|
}));
|
|
@@ -3562,34 +4033,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3562
4033
|
}, {
|
|
3563
4034
|
key: "addOrderPaymentAsync",
|
|
3564
4035
|
value: (function () {
|
|
3565
|
-
var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4036
|
+
var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(payment) {
|
|
3566
4037
|
var hasPaymentNumber, devicePrefix;
|
|
3567
|
-
return _regeneratorRuntime().wrap(function
|
|
3568
|
-
while (1) switch (
|
|
4038
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context21) {
|
|
4039
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
3569
4040
|
case 0:
|
|
3570
4041
|
hasPaymentNumber = String(payment.payment_number || '').trim() !== '';
|
|
3571
4042
|
if (!hasPaymentNumber) {
|
|
3572
|
-
|
|
4043
|
+
_context21.next = 5;
|
|
3573
4044
|
break;
|
|
3574
4045
|
}
|
|
3575
|
-
|
|
3576
|
-
|
|
4046
|
+
_context21.t0 = 'LOCAL';
|
|
4047
|
+
_context21.next = 8;
|
|
3577
4048
|
break;
|
|
3578
4049
|
case 5:
|
|
3579
|
-
|
|
4050
|
+
_context21.next = 7;
|
|
3580
4051
|
return this.getPaymentNumberDevicePrefixAsync();
|
|
3581
4052
|
case 7:
|
|
3582
|
-
|
|
4053
|
+
_context21.t0 = _context21.sent;
|
|
3583
4054
|
case 8:
|
|
3584
|
-
devicePrefix =
|
|
3585
|
-
return
|
|
4055
|
+
devicePrefix = _context21.t0;
|
|
4056
|
+
return _context21.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
|
|
3586
4057
|
case 10:
|
|
3587
4058
|
case "end":
|
|
3588
|
-
return
|
|
4059
|
+
return _context21.stop();
|
|
3589
4060
|
}
|
|
3590
|
-
},
|
|
4061
|
+
}, _callee19, this);
|
|
3591
4062
|
}));
|
|
3592
|
-
function addOrderPaymentAsync(
|
|
4063
|
+
function addOrderPaymentAsync(_x16) {
|
|
3593
4064
|
return _addOrderPaymentAsync.apply(this, arguments);
|
|
3594
4065
|
}
|
|
3595
4066
|
return addOrderPaymentAsync;
|
|
@@ -3597,7 +4068,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3597
4068
|
}, {
|
|
3598
4069
|
key: "addOrderPaymentWithDevicePrefix",
|
|
3599
4070
|
value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
|
|
3600
|
-
var
|
|
4071
|
+
var _this25 = this;
|
|
3601
4072
|
this.logInfo('addOrderPayment', {
|
|
3602
4073
|
payment: payment
|
|
3603
4074
|
});
|
|
@@ -3615,7 +4086,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3615
4086
|
void this.recalculateSummary({
|
|
3616
4087
|
createIfMissing: true
|
|
3617
4088
|
}).catch(function (error) {
|
|
3618
|
-
|
|
4089
|
+
_this25.logError('recalculate summary after addOrderPayment failed', {
|
|
3619
4090
|
error: error instanceof Error ? error.message : String(error)
|
|
3620
4091
|
});
|
|
3621
4092
|
});
|
|
@@ -3629,7 +4100,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3629
4100
|
}, {
|
|
3630
4101
|
key: "updateOrderPayment",
|
|
3631
4102
|
value: (function () {
|
|
3632
|
-
var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4103
|
+
var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(paymentIdentity, updates) {
|
|
3633
4104
|
var options,
|
|
3634
4105
|
tempOrder,
|
|
3635
4106
|
identity,
|
|
@@ -3638,17 +4109,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3638
4109
|
updatedPayment,
|
|
3639
4110
|
summary,
|
|
3640
4111
|
payments,
|
|
3641
|
-
|
|
3642
|
-
return _regeneratorRuntime().wrap(function
|
|
3643
|
-
while (1) switch (
|
|
4112
|
+
_args22 = arguments;
|
|
4113
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context22) {
|
|
4114
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
3644
4115
|
case 0:
|
|
3645
|
-
options =
|
|
4116
|
+
options = _args22.length > 2 && _args22[2] !== undefined ? _args22[2] : {};
|
|
3646
4117
|
tempOrder = this.ensureTempOrder();
|
|
3647
4118
|
identity = String(paymentIdentity);
|
|
3648
4119
|
matchMode = options.matchBy === 'compat' || options.matchBy === 'legacy' ? 'compat' : 'payment_number';
|
|
3649
4120
|
matchedPayment = resolveOrderPaymentIdentity(tempOrder.payments || [], identity, matchMode);
|
|
3650
4121
|
if (matchedPayment) {
|
|
3651
|
-
|
|
4122
|
+
_context22.next = 7;
|
|
3652
4123
|
break;
|
|
3653
4124
|
}
|
|
3654
4125
|
throw new Error("\u672A\u627E\u5230\u652F\u4ED8\u9879: ".concat(identity));
|
|
@@ -3663,15 +4134,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3663
4134
|
return nextPayment;
|
|
3664
4135
|
});
|
|
3665
4136
|
this.persistTempOrder();
|
|
3666
|
-
|
|
4137
|
+
_context22.next = 12;
|
|
3667
4138
|
return this.recalculateSummary({
|
|
3668
4139
|
createIfMissing: true
|
|
3669
4140
|
});
|
|
3670
4141
|
case 12:
|
|
3671
|
-
summary =
|
|
4142
|
+
summary = _context22.sent;
|
|
3672
4143
|
this.persistTempOrder();
|
|
3673
4144
|
payments = tempOrder.payments;
|
|
3674
|
-
return
|
|
4145
|
+
return _context22.abrupt("return", {
|
|
3675
4146
|
updated: true,
|
|
3676
4147
|
payment: payments[matchedPayment.index] || updatedPayment,
|
|
3677
4148
|
payments: payments,
|
|
@@ -3679,11 +4150,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3679
4150
|
});
|
|
3680
4151
|
case 16:
|
|
3681
4152
|
case "end":
|
|
3682
|
-
return
|
|
4153
|
+
return _context22.stop();
|
|
3683
4154
|
}
|
|
3684
|
-
},
|
|
4155
|
+
}, _callee20, this);
|
|
3685
4156
|
}));
|
|
3686
|
-
function updateOrderPayment(
|
|
4157
|
+
function updateOrderPayment(_x17, _x18) {
|
|
3687
4158
|
return _updateOrderPayment.apply(this, arguments);
|
|
3688
4159
|
}
|
|
3689
4160
|
return updateOrderPayment;
|
|
@@ -3728,7 +4199,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3728
4199
|
}, {
|
|
3729
4200
|
key: "applyPaymentLifecycleChange",
|
|
3730
4201
|
value: function applyPaymentLifecycleChange(tempOrder, options) {
|
|
3731
|
-
var
|
|
4202
|
+
var _this26 = this;
|
|
3732
4203
|
this.updateTempOrderPaymentStatus(tempOrder);
|
|
3733
4204
|
if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
|
|
3734
4205
|
this.persistTempOrder();
|
|
@@ -3738,7 +4209,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3738
4209
|
void this.recalculateSummary({
|
|
3739
4210
|
createIfMissing: true
|
|
3740
4211
|
}).catch(function (error) {
|
|
3741
|
-
|
|
4212
|
+
_this26.logError("recalculate summary after ".concat(logContext, " failed"), {
|
|
3742
4213
|
error: error instanceof Error ? error.message : String(error)
|
|
3743
4214
|
});
|
|
3744
4215
|
});
|
|
@@ -3782,7 +4253,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3782
4253
|
}, {
|
|
3783
4254
|
key: "updateVoucherOrderPayments",
|
|
3784
4255
|
value: function updateVoucherOrderPayments(payments, options) {
|
|
3785
|
-
var
|
|
4256
|
+
var _this27 = this;
|
|
3786
4257
|
var tempOrder = this.ensureTempOrder();
|
|
3787
4258
|
var isOrderPaymentType = function isOrderPaymentType(value) {
|
|
3788
4259
|
return value === 'normal' || value === 'deposit';
|
|
@@ -3817,7 +4288,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3817
4288
|
});
|
|
3818
4289
|
};
|
|
3819
4290
|
var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
|
|
3820
|
-
return
|
|
4291
|
+
return _this27.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
|
|
3821
4292
|
defaultPaid: false,
|
|
3822
4293
|
devicePrefix: options === null || options === void 0 ? void 0 : options.devicePrefix
|
|
3823
4294
|
});
|
|
@@ -3870,7 +4341,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3870
4341
|
void this.recalculateSummary({
|
|
3871
4342
|
createIfMissing: true
|
|
3872
4343
|
}).catch(function (error) {
|
|
3873
|
-
|
|
4344
|
+
_this27.logError('recalculate summary after updateVoucherOrderPayments failed', {
|
|
3874
4345
|
error: error instanceof Error ? error.message : String(error)
|
|
3875
4346
|
});
|
|
3876
4347
|
});
|
|
@@ -3879,38 +4350,38 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3879
4350
|
}, {
|
|
3880
4351
|
key: "updateVoucherOrderPaymentsAsync",
|
|
3881
4352
|
value: function () {
|
|
3882
|
-
var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4353
|
+
var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(payments, options) {
|
|
3883
4354
|
var needsPaymentNumber, devicePrefix;
|
|
3884
|
-
return _regeneratorRuntime().wrap(function
|
|
3885
|
-
while (1) switch (
|
|
4355
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context23) {
|
|
4356
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
3886
4357
|
case 0:
|
|
3887
4358
|
needsPaymentNumber = (payments || []).some(function (payment) {
|
|
3888
4359
|
return String(payment.payment_number || '').trim() === '';
|
|
3889
4360
|
});
|
|
3890
4361
|
if (!needsPaymentNumber) {
|
|
3891
|
-
|
|
4362
|
+
_context23.next = 7;
|
|
3892
4363
|
break;
|
|
3893
4364
|
}
|
|
3894
|
-
|
|
4365
|
+
_context23.next = 4;
|
|
3895
4366
|
return this.getPaymentNumberDevicePrefixAsync();
|
|
3896
4367
|
case 4:
|
|
3897
|
-
|
|
3898
|
-
|
|
4368
|
+
_context23.t0 = _context23.sent;
|
|
4369
|
+
_context23.next = 8;
|
|
3899
4370
|
break;
|
|
3900
4371
|
case 7:
|
|
3901
|
-
|
|
4372
|
+
_context23.t0 = 'LOCAL';
|
|
3902
4373
|
case 8:
|
|
3903
|
-
devicePrefix =
|
|
3904
|
-
return
|
|
4374
|
+
devicePrefix = _context23.t0;
|
|
4375
|
+
return _context23.abrupt("return", this.updateVoucherOrderPayments(payments, _objectSpread(_objectSpread({}, options), {}, {
|
|
3905
4376
|
devicePrefix: devicePrefix
|
|
3906
4377
|
})));
|
|
3907
4378
|
case 10:
|
|
3908
4379
|
case "end":
|
|
3909
|
-
return
|
|
4380
|
+
return _context23.stop();
|
|
3910
4381
|
}
|
|
3911
|
-
},
|
|
4382
|
+
}, _callee21, this);
|
|
3912
4383
|
}));
|
|
3913
|
-
function updateVoucherOrderPaymentsAsync(
|
|
4384
|
+
function updateVoucherOrderPaymentsAsync(_x19, _x20) {
|
|
3914
4385
|
return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
|
|
3915
4386
|
}
|
|
3916
4387
|
return updateVoucherOrderPaymentsAsync;
|
|
@@ -3928,7 +4399,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3928
4399
|
key: "shouldMergeProductToOrder",
|
|
3929
4400
|
value: function shouldMergeProductToOrder(params) {
|
|
3930
4401
|
var _this$orderHooks,
|
|
3931
|
-
|
|
4402
|
+
_this28 = this;
|
|
3932
4403
|
var onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
|
|
3933
4404
|
if (!onBeforeMergeProductToOrder) return true;
|
|
3934
4405
|
var result = onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
@@ -3936,7 +4407,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3936
4407
|
}));
|
|
3937
4408
|
if (result && _typeof(result) === 'object' && typeof result.then === 'function') {
|
|
3938
4409
|
return Promise.resolve(result).then(function (resolved) {
|
|
3939
|
-
return
|
|
4410
|
+
return _this28.normalizeShouldMergeProductResult(resolved);
|
|
3940
4411
|
});
|
|
3941
4412
|
}
|
|
3942
4413
|
return this.normalizeShouldMergeProductResult(result);
|
|
@@ -3956,10 +4427,103 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3956
4427
|
}, {
|
|
3957
4428
|
key: "hasLinkedBookingUid",
|
|
3958
4429
|
value: function hasLinkedBookingUid(product) {
|
|
3959
|
-
var _product$booking_uid, _product$
|
|
3960
|
-
var bookingUid = (_product$booking_uid = product === null || product === void 0 ? void 0 : product.booking_uid) !== null && _product$booking_uid !== void 0 ? _product$booking_uid : product === null || product === void 0 || (_product$
|
|
4430
|
+
var _product$booking_uid, _product$metadata9;
|
|
4431
|
+
var bookingUid = (_product$booking_uid = product === null || product === void 0 ? void 0 : product.booking_uid) !== null && _product$booking_uid !== void 0 ? _product$booking_uid : product === null || product === void 0 || (_product$metadata9 = product.metadata) === null || _product$metadata9 === void 0 ? void 0 : _product$metadata9.booking_uid;
|
|
3961
4432
|
return bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '';
|
|
3962
4433
|
}
|
|
4434
|
+
}, {
|
|
4435
|
+
key: "isMultiCurrencySettlementEnabled",
|
|
4436
|
+
value: function isMultiCurrencySettlementEnabled() {
|
|
4437
|
+
var _this$otherParams4;
|
|
4438
|
+
return ((_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.enableMultiCurrencySettlement) === true;
|
|
4439
|
+
}
|
|
4440
|
+
}, {
|
|
4441
|
+
key: "isActiveVirtualSettlementOrder",
|
|
4442
|
+
value: function isActiveVirtualSettlementOrder(tempOrder) {
|
|
4443
|
+
return this.isMultiCurrencySettlementEnabled() && isVirtualSettlementOrder(tempOrder);
|
|
4444
|
+
}
|
|
4445
|
+
}, {
|
|
4446
|
+
key: "shouldUseVirtualSettlementSummary",
|
|
4447
|
+
value: function shouldUseVirtualSettlementSummary(tempOrder) {
|
|
4448
|
+
var _tempOrder$metadata;
|
|
4449
|
+
return this.isActiveVirtualSettlementOrder(tempOrder) || (tempOrder === null || tempOrder === void 0 || (_tempOrder$metadata = tempOrder.metadata) === null || _tempOrder$metadata === void 0 || (_tempOrder$metadata = _tempOrder$metadata.currency_settlement_config) === null || _tempOrder$metadata === void 0 ? void 0 : _tempOrder$metadata.settlement_type) === 'virtual_currency';
|
|
4450
|
+
}
|
|
4451
|
+
}, {
|
|
4452
|
+
key: "normalizeVirtualSettlementProductIfEnabled",
|
|
4453
|
+
value: function normalizeVirtualSettlementProductIfEnabled(product) {
|
|
4454
|
+
return this.isMultiCurrencySettlementEnabled() ? normalizeVirtualSettlementOrderProduct(product) : product;
|
|
4455
|
+
}
|
|
4456
|
+
}, {
|
|
4457
|
+
key: "assertAndLockProductSettlement",
|
|
4458
|
+
value: function assertAndLockProductSettlement(tempOrder, product) {
|
|
4459
|
+
var _ref60, _ref61, _product$selling_pric;
|
|
4460
|
+
if (!this.isMultiCurrencySettlementEnabled()) return;
|
|
4461
|
+
var currentKey = getTempOrderSettlementKey(tempOrder);
|
|
4462
|
+
var incomingKey = getSettlementKey(getSelectedSettlementSnapshot(product)) || 'legal_currency';
|
|
4463
|
+
if (currentKey && currentKey !== incomingKey) {
|
|
4464
|
+
throw new OrderSettlementConflictError(currentKey, incomingKey);
|
|
4465
|
+
}
|
|
4466
|
+
var snapshot = getSelectedSettlementSnapshot(product);
|
|
4467
|
+
if ((snapshot === null || snapshot === void 0 ? void 0 : snapshot.settlement_type) === 'virtual_currency' && tempOrder.customer_id && Number(tempOrder.customer_id) !== 1) {
|
|
4468
|
+
var currencyProductId = Number(snapshot.currency_product_id);
|
|
4469
|
+
var asset = (this.store.virtualCurrencyList || []).find(function (item) {
|
|
4470
|
+
return Number(item === null || item === void 0 ? void 0 : item.product_id) === currencyProductId;
|
|
4471
|
+
});
|
|
4472
|
+
if (!asset) {
|
|
4473
|
+
throw new VirtualCurrencyAssetNotFoundError(currencyProductId);
|
|
4474
|
+
}
|
|
4475
|
+
var existedAmount = tempOrder.products.reduce(function (sum, item) {
|
|
4476
|
+
return sum.plus(new Decimal(item.selling_price || 0).times(item.num || 1));
|
|
4477
|
+
}, new Decimal(0));
|
|
4478
|
+
var requiredAmount = existedAmount.plus(new Decimal(snapshot.price || 0).times(product.num || 1));
|
|
4479
|
+
var balance = new Decimal(asset.balance || 0);
|
|
4480
|
+
if (balance.lt(requiredAmount)) {
|
|
4481
|
+
throw new VirtualCurrencyBalanceError(balance.toFixed(2), requiredAmount.toFixed(2));
|
|
4482
|
+
}
|
|
4483
|
+
}
|
|
4484
|
+
applyTempOrderSettlementState(tempOrder, snapshot || {
|
|
4485
|
+
settlement_type: 'legal_currency',
|
|
4486
|
+
price: (_ref60 = (_ref61 = (_product$selling_pric = product.selling_price) !== null && _product$selling_pric !== void 0 ? _product$selling_pric : product.original_price) !== null && _ref61 !== void 0 ? _ref61 : product.payment_price) !== null && _ref60 !== void 0 ? _ref60 : 0,
|
|
4487
|
+
unit_label: tempOrder.currency_code,
|
|
4488
|
+
symbol: tempOrder.currency_symbol,
|
|
4489
|
+
amount_format: tempOrder.currency_format
|
|
4490
|
+
});
|
|
4491
|
+
}
|
|
4492
|
+
}, {
|
|
4493
|
+
key: "syncTempOrderSettlementState",
|
|
4494
|
+
value: function syncTempOrderSettlementState(tempOrder) {
|
|
4495
|
+
if (!this.isMultiCurrencySettlementEnabled()) return;
|
|
4496
|
+
tempOrder.metadata = tempOrder.metadata || {};
|
|
4497
|
+
if (!tempOrder.products.length) {
|
|
4498
|
+
releaseTempOrderSettlementState(tempOrder);
|
|
4499
|
+
return;
|
|
4500
|
+
}
|
|
4501
|
+
var snapshot = getTempOrderSettlementSnapshot(tempOrder);
|
|
4502
|
+
if (snapshot) {
|
|
4503
|
+
applyTempOrderSettlementState(tempOrder, snapshot);
|
|
4504
|
+
return;
|
|
4505
|
+
}
|
|
4506
|
+
tempOrder.metadata.cart_settlement_key = 'legal_currency';
|
|
4507
|
+
}
|
|
4508
|
+
}, {
|
|
4509
|
+
key: "prepareVirtualSettlementTempOrder",
|
|
4510
|
+
value: function prepareVirtualSettlementTempOrder(tempOrder) {
|
|
4511
|
+
if (!this.isMultiCurrencySettlementEnabled()) return;
|
|
4512
|
+
this.syncTempOrderSettlementState(tempOrder);
|
|
4513
|
+
if (!this.isActiveVirtualSettlementOrder(tempOrder)) return;
|
|
4514
|
+
tempOrder.products = normalizeVirtualSettlementProducts(tempOrder.products);
|
|
4515
|
+
tempOrder.discount_list = [];
|
|
4516
|
+
tempOrder.shop_discount = '0.00';
|
|
4517
|
+
tempOrder.surcharge_fee = '0.00';
|
|
4518
|
+
tempOrder.surcharges = [];
|
|
4519
|
+
var virtualOrder = tempOrder;
|
|
4520
|
+
virtualOrder.discount_amount = '0.00';
|
|
4521
|
+
virtualOrder.product_tax_fee = '0.00';
|
|
4522
|
+
virtualOrder.tax_fee = '0.00';
|
|
4523
|
+
virtualOrder.shipping_fee = '0.00';
|
|
4524
|
+
virtualOrder.shipping_tax_fee = '0.00';
|
|
4525
|
+
virtualOrder.tip_fee = '0.00';
|
|
4526
|
+
}
|
|
3963
4527
|
|
|
3964
4528
|
// ─── TempOrder: 商品 CRUD ───
|
|
3965
4529
|
|
|
@@ -3972,42 +4536,53 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3972
4536
|
}, {
|
|
3973
4537
|
key: "finalizeProductOrderMutation",
|
|
3974
4538
|
value: function () {
|
|
3975
|
-
var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3976
|
-
|
|
3977
|
-
|
|
4539
|
+
var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(tempOrder, options) {
|
|
4540
|
+
var isVirtualSettlement, promotionPayload;
|
|
4541
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context24) {
|
|
4542
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
3978
4543
|
case 0:
|
|
3979
4544
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
3980
|
-
|
|
3981
|
-
|
|
4545
|
+
this.prepareVirtualSettlementTempOrder(tempOrder);
|
|
4546
|
+
isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder);
|
|
4547
|
+
if (!(!(options !== null && options !== void 0 && options.skipEditDiscountConfigRefresh) && !isVirtualSettlement)) {
|
|
4548
|
+
_context24.next = 6;
|
|
3982
4549
|
break;
|
|
3983
4550
|
}
|
|
3984
|
-
|
|
4551
|
+
_context24.next = 6;
|
|
3985
4552
|
return this.ensureEditDiscountConfigForProductChange(tempOrder);
|
|
3986
|
-
case
|
|
3987
|
-
if (options !== null && options !== void 0 && options.skipDiscountRecalculation) {
|
|
3988
|
-
|
|
4553
|
+
case 6:
|
|
4554
|
+
if (!(!(options !== null && options !== void 0 && options.skipDiscountRecalculation) && !isVirtualSettlement)) {
|
|
4555
|
+
_context24.next = 12;
|
|
3989
4556
|
break;
|
|
3990
4557
|
}
|
|
3991
|
-
|
|
3992
|
-
return this.
|
|
3993
|
-
case
|
|
3994
|
-
|
|
4558
|
+
_context24.next = 9;
|
|
4559
|
+
return this.evaluatePromotion();
|
|
4560
|
+
case 9:
|
|
4561
|
+
_context24.t0 = _context24.sent;
|
|
4562
|
+
_context24.next = 13;
|
|
4563
|
+
break;
|
|
4564
|
+
case 12:
|
|
4565
|
+
_context24.t0 = null;
|
|
4566
|
+
case 13:
|
|
4567
|
+
promotionPayload = _context24.t0;
|
|
4568
|
+
if (!(options !== null && options !== void 0 && options.skipDiscountRecalculation) && !isVirtualSettlement) {
|
|
3995
4569
|
this.applyDiscount();
|
|
3996
4570
|
}
|
|
3997
4571
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
3998
|
-
|
|
4572
|
+
_context24.next = 18;
|
|
3999
4573
|
return this.recalculateSummary({
|
|
4000
4574
|
createIfMissing: true
|
|
4001
4575
|
});
|
|
4002
|
-
case
|
|
4576
|
+
case 18:
|
|
4003
4577
|
this.persistTempOrder();
|
|
4004
|
-
|
|
4578
|
+
this.emitPromotionApplied(promotionPayload);
|
|
4579
|
+
case 20:
|
|
4005
4580
|
case "end":
|
|
4006
|
-
return
|
|
4581
|
+
return _context24.stop();
|
|
4007
4582
|
}
|
|
4008
|
-
},
|
|
4583
|
+
}, _callee22, this);
|
|
4009
4584
|
}));
|
|
4010
|
-
function finalizeProductOrderMutation(
|
|
4585
|
+
function finalizeProductOrderMutation(_x21, _x22) {
|
|
4011
4586
|
return _finalizeProductOrderMutation.apply(this, arguments);
|
|
4012
4587
|
}
|
|
4013
4588
|
return finalizeProductOrderMutation;
|
|
@@ -4033,15 +4608,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4033
4608
|
_metadata,
|
|
4034
4609
|
_productToAdd$metadat,
|
|
4035
4610
|
_origin,
|
|
4036
|
-
|
|
4611
|
+
_this29 = this;
|
|
4037
4612
|
var linked = booking ? this.createLinkedProductAndBooking({
|
|
4038
4613
|
product: product,
|
|
4039
4614
|
booking: booking
|
|
4040
4615
|
}) : null;
|
|
4041
4616
|
var productToAdd = (linked === null || linked === void 0 ? void 0 : linked.product) || product;
|
|
4617
|
+
this.assertAndLockProductSettlement(tempOrder, productToAdd);
|
|
4042
4618
|
var disableMerge = (options === null || options === void 0 ? void 0 : options.disableMerge) === true;
|
|
4043
4619
|
var incomingFingerprint = disableMerge ? '' : buildProductLineFingerprint(getProductSkuOptions(productToAdd), productToAdd.product_bundle);
|
|
4044
|
-
var normalizedIncoming = mergeOrderProductDisplayFields(productToAdd, normalizeOrderProduct(productToAdd));
|
|
4620
|
+
var normalizedIncoming = this.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(productToAdd, normalizeOrderProduct(productToAdd)));
|
|
4045
4621
|
if (disableMerge) {
|
|
4046
4622
|
normalizedIncoming.metadata = _objectSpread(_objectSpread({}, normalizedIncoming.metadata || {}), {}, _defineProperty({}, PRODUCT_LINE_MERGE_DISABLED_METADATA_KEY, true));
|
|
4047
4623
|
}
|
|
@@ -4066,8 +4642,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4066
4642
|
var shouldForceNewLine = disableMerge || !!booking || hasIncomingProductNote || hasIncomingManualProductDiscount || hasIncomingBookingUid || isIncomingCustomItem || isWeighingProduct;
|
|
4067
4643
|
var matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
4068
4644
|
var _item$metadata3;
|
|
4069
|
-
if (
|
|
4070
|
-
if (
|
|
4645
|
+
if (_this29.hasGoodPassDiscount(item)) return false;
|
|
4646
|
+
if (_this29.hasOrderProductLineNote(item)) return false;
|
|
4071
4647
|
if (isManualProductDiscountProduct(item)) return false;
|
|
4072
4648
|
if (item.order_detail_id !== undefined && item.order_detail_id !== null) return false;
|
|
4073
4649
|
if ((_item$metadata3 = item.metadata) !== null && _item$metadata3 !== void 0 && _item$metadata3.is_edit_for_runtime) return false;
|
|
@@ -4079,8 +4655,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4079
4655
|
var matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
|
|
4080
4656
|
var existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
|
|
4081
4657
|
var commitProductLine = function commitProductLine(shouldMerge) {
|
|
4658
|
+
var committedProduct;
|
|
4082
4659
|
if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
|
|
4083
|
-
|
|
4660
|
+
_this29.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
|
|
4084
4661
|
if (linked) {
|
|
4085
4662
|
normalizedIncoming.booking_uid = linked.bookingUid;
|
|
4086
4663
|
normalizedIncoming.metadata = _objectSpread(_objectSpread({}, normalizedIncoming.metadata || {}), {}, {
|
|
@@ -4093,15 +4670,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4093
4670
|
} else {
|
|
4094
4671
|
tempOrder.products = [].concat(_toConsumableArray(tempOrder.products), [normalizedIncoming]);
|
|
4095
4672
|
}
|
|
4673
|
+
committedProduct = normalizedIncoming;
|
|
4096
4674
|
} else {
|
|
4097
4675
|
var _targetProduct$metada;
|
|
4098
4676
|
var targetProduct = matchedProduct;
|
|
4099
4677
|
var targetUid = (_targetProduct$metada = targetProduct.metadata) === null || _targetProduct$metada === void 0 ? void 0 : _targetProduct$metada.unique_identification_number;
|
|
4100
|
-
var normalizedProduct = mergeOrderProductDisplayFields(targetProduct, normalizeOrderProduct(_objectSpread(_objectSpread({}, productToAdd), {}, {
|
|
4678
|
+
var normalizedProduct = _this29.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(targetProduct, normalizeOrderProduct(_objectSpread(_objectSpread({}, productToAdd), {}, {
|
|
4101
4679
|
metadata: _objectSpread(_objectSpread({}, productToAdd.metadata || {}), {}, {
|
|
4102
4680
|
unique_identification_number: targetUid
|
|
4103
4681
|
})
|
|
4104
|
-
})));
|
|
4682
|
+
}))));
|
|
4105
4683
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
4106
4684
|
var nextNum = getSafeProductNum(targetProduct.num + normalizedProduct.num);
|
|
4107
4685
|
tempOrder.products[matchedIndex] = _objectSpread(_objectSpread(_objectSpread({}, targetProduct), normalizedProduct), {}, {
|
|
@@ -4120,7 +4698,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4120
4698
|
order_detail_id: targetProduct.order_detail_id,
|
|
4121
4699
|
num: nextNum
|
|
4122
4700
|
});
|
|
4123
|
-
|
|
4701
|
+
_this29.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
|
|
4702
|
+
committedProduct = tempOrder.products[matchedIndex];
|
|
4124
4703
|
if (matchedIndex !== tempOrder.products.length - 1) {
|
|
4125
4704
|
var mergedProduct = tempOrder.products[matchedIndex];
|
|
4126
4705
|
tempOrder.products = [].concat(_toConsumableArray(tempOrder.products.slice(0, matchedIndex)), _toConsumableArray(tempOrder.products.slice(matchedIndex + 1)), [mergedProduct]);
|
|
@@ -4129,10 +4708,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4129
4708
|
if (linked) {
|
|
4130
4709
|
tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
|
|
4131
4710
|
}
|
|
4711
|
+
return committedProduct;
|
|
4132
4712
|
};
|
|
4133
4713
|
if (!matchedProduct) {
|
|
4134
|
-
commitProductLine(false);
|
|
4135
|
-
return;
|
|
4714
|
+
return commitProductLine(false);
|
|
4136
4715
|
}
|
|
4137
4716
|
var shouldMerge = this.shouldMergeProductToOrder({
|
|
4138
4717
|
incomingProduct: productToAdd,
|
|
@@ -4147,7 +4726,75 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4147
4726
|
if (shouldMerge && _typeof(shouldMerge) === 'object' && typeof shouldMerge.then === 'function') {
|
|
4148
4727
|
return Promise.resolve(shouldMerge).then(commitProductLine);
|
|
4149
4728
|
}
|
|
4150
|
-
commitProductLine(shouldMerge);
|
|
4729
|
+
return commitProductLine(shouldMerge);
|
|
4730
|
+
}
|
|
4731
|
+
|
|
4732
|
+
/**
|
|
4733
|
+
* booking 数量拆行时,若 Holder 数量与拆行数严格一致,则按下标分配。
|
|
4734
|
+
* 数量不一致时保持旧数据,避免猜测 Holder 与商品份数的对应关系。
|
|
4735
|
+
*/
|
|
4736
|
+
}, {
|
|
4737
|
+
key: "createSplitBookingLine",
|
|
4738
|
+
value: function createSplitBookingLine(product, booking, index, splitCount) {
|
|
4739
|
+
var _booking$metadata6, _ref62, _ref63, _bookingHolder$form_r, _booking$metadata7, _product$metadata10, _bookingHolder$name, _singleBooking$metada;
|
|
4740
|
+
var singleLine = cloneDeep(product);
|
|
4741
|
+
singleLine.num = 1;
|
|
4742
|
+
delete singleLine.product_quantity;
|
|
4743
|
+
var singleBooking = cloneDeep(booking);
|
|
4744
|
+
var bookingHolder = booking !== null && booking !== void 0 && booking.holder && _typeof(booking.holder) === 'object' ? booking.holder : null;
|
|
4745
|
+
var metadataHolder = booking !== null && booking !== void 0 && (_booking$metadata6 = booking.metadata) !== null && _booking$metadata6 !== void 0 && _booking$metadata6.holder && _typeof(booking.metadata.holder) === 'object' ? booking.metadata.holder : null;
|
|
4746
|
+
var rawHolderIds = (_ref62 = (_ref63 = (_bookingHolder$form_r = bookingHolder === null || bookingHolder === void 0 ? void 0 : bookingHolder.form_record) !== null && _bookingHolder$form_r !== void 0 ? _bookingHolder$form_r : booking === null || booking === void 0 || (_booking$metadata7 = booking.metadata) === null || _booking$metadata7 === void 0 ? void 0 : _booking$metadata7.holder_id) !== null && _ref63 !== void 0 ? _ref63 : metadataHolder === null || metadataHolder === void 0 ? void 0 : metadataHolder.form_record) !== null && _ref62 !== void 0 ? _ref62 : product === null || product === void 0 || (_product$metadata10 = product.metadata) === null || _product$metadata10 === void 0 ? void 0 : _product$metadata10.holder_id;
|
|
4747
|
+
var holderIds = (Array.isArray(rawHolderIds) ? rawHolderIds : [rawHolderIds]).map(function (holderId) {
|
|
4748
|
+
return holderId && _typeof(holderId) === 'object' ? holderId.form_record_id : holderId;
|
|
4749
|
+
}).filter(function (holderId) {
|
|
4750
|
+
return holderId !== undefined && holderId !== null && holderId !== '';
|
|
4751
|
+
});
|
|
4752
|
+
if (holderIds.length !== splitCount) {
|
|
4753
|
+
return {
|
|
4754
|
+
product: singleLine,
|
|
4755
|
+
booking: singleBooking
|
|
4756
|
+
};
|
|
4757
|
+
}
|
|
4758
|
+
var holderId = holderIds[index];
|
|
4759
|
+
var rawHolderName = (_bookingHolder$name = bookingHolder === null || bookingHolder === void 0 ? void 0 : bookingHolder.name) !== null && _bookingHolder$name !== void 0 ? _bookingHolder$name : metadataHolder === null || metadataHolder === void 0 ? void 0 : metadataHolder.name;
|
|
4760
|
+
var holderNames = Array.isArray(rawHolderName) ? rawHolderName.map(function (name) {
|
|
4761
|
+
return String(name || '').trim();
|
|
4762
|
+
}) : typeof rawHolderName === 'string' ? rawHolderName.split(',').map(function (name) {
|
|
4763
|
+
return name.trim();
|
|
4764
|
+
}) : [];
|
|
4765
|
+
var holderName = holderNames.length === splitCount ? holderNames[index] : undefined;
|
|
4766
|
+
var splitHolder = function splitHolder(holder) {
|
|
4767
|
+
return _objectSpread(_objectSpread({}, holder), {}, {
|
|
4768
|
+
form_record: [holderId]
|
|
4769
|
+
}, holderName ? {
|
|
4770
|
+
name: holderName
|
|
4771
|
+
} : Object.prototype.hasOwnProperty.call(holder, 'name') ? {
|
|
4772
|
+
name: undefined
|
|
4773
|
+
} : {});
|
|
4774
|
+
};
|
|
4775
|
+
singleLine.metadata = _objectSpread(_objectSpread({}, singleLine.metadata || {}), {}, {
|
|
4776
|
+
holder_id: [holderId]
|
|
4777
|
+
});
|
|
4778
|
+
if (singleLine._extend && _typeof(singleLine._extend) === 'object') {
|
|
4779
|
+
singleLine._extend = _objectSpread(_objectSpread({}, singleLine._extend), {}, {
|
|
4780
|
+
holder_id: [holderId]
|
|
4781
|
+
});
|
|
4782
|
+
}
|
|
4783
|
+
if (singleBooking.holder && _typeof(singleBooking.holder) === 'object') {
|
|
4784
|
+
singleBooking.holder = splitHolder(singleBooking.holder);
|
|
4785
|
+
}
|
|
4786
|
+
singleBooking.metadata = _objectSpread(_objectSpread({}, singleBooking.metadata || {}), {}, {
|
|
4787
|
+
holder_id: [holderId]
|
|
4788
|
+
}, (_singleBooking$metada = singleBooking.metadata) !== null && _singleBooking$metada !== void 0 && _singleBooking$metada.holder && _typeof(singleBooking.metadata.holder) === 'object' ? {
|
|
4789
|
+
holder: splitHolder(singleBooking.metadata.holder)
|
|
4790
|
+
} : {});
|
|
4791
|
+
if (Object.prototype.hasOwnProperty.call(singleBooking, 'holder_id')) {
|
|
4792
|
+
singleBooking.holder_id = [holderId];
|
|
4793
|
+
}
|
|
4794
|
+
return {
|
|
4795
|
+
product: singleLine,
|
|
4796
|
+
booking: singleBooking
|
|
4797
|
+
};
|
|
4151
4798
|
}
|
|
4152
4799
|
|
|
4153
4800
|
/**
|
|
@@ -4160,12 +4807,53 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4160
4807
|
}, {
|
|
4161
4808
|
key: "addProductToOrder",
|
|
4162
4809
|
value: (function () {
|
|
4163
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4164
|
-
var
|
|
4165
|
-
|
|
4166
|
-
|
|
4810
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(product, booking, options) {
|
|
4811
|
+
var _this30 = this;
|
|
4812
|
+
var tempOrder, salesNoteDrafts, mutationSnapshot, attachSalesNoteDrafts, rollbackProductAndNotesMutation, insertAfterProductUid, anchorIndex, insertAtIndex, _ref64, _productRecord$num, productRecord, splitCount, i, splitLine, committedProduct, _committedProduct, _committedProduct2;
|
|
4813
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context25) {
|
|
4814
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
4167
4815
|
case 0:
|
|
4168
4816
|
tempOrder = this.ensureTempOrder();
|
|
4817
|
+
salesNoteDrafts = ((options === null || options === void 0 ? void 0 : options.salesNotes) || []).map(function (draft) {
|
|
4818
|
+
return {
|
|
4819
|
+
note_type: String(draft.note_type || '').trim(),
|
|
4820
|
+
text: {
|
|
4821
|
+
kind: 'resolved',
|
|
4822
|
+
text: buildSalesNoteText(draft.text)
|
|
4823
|
+
}
|
|
4824
|
+
};
|
|
4825
|
+
});
|
|
4826
|
+
mutationSnapshot = salesNoteDrafts.length > 0 ? {
|
|
4827
|
+
products: cloneDeep(tempOrder.products || []),
|
|
4828
|
+
bookings: cloneDeep(tempOrder.bookings || []),
|
|
4829
|
+
notes: cloneDeep(tempOrder.notes || []),
|
|
4830
|
+
extend: cloneDeep(tempOrder._extend || {})
|
|
4831
|
+
} : null;
|
|
4832
|
+
attachSalesNoteDrafts = function attachSalesNoteDrafts(orderProduct) {
|
|
4833
|
+
var _orderProduct$metadat;
|
|
4834
|
+
if (!salesNoteDrafts.length) return;
|
|
4835
|
+
var productLineUid = ((_orderProduct$metadat = orderProduct.metadata) === null || _orderProduct$metadat === void 0 ? void 0 : _orderProduct$metadat.unique_identification_number) || orderProduct.unique_identification_number;
|
|
4836
|
+
if (!productLineUid) {
|
|
4837
|
+
throw new Error('[Order Notes] 商品行缺少 unique_identification_number');
|
|
4838
|
+
}
|
|
4839
|
+
salesNoteDrafts.forEach(function (draft) {
|
|
4840
|
+
_this30.setSalesNoteOnTempOrder(tempOrder, {
|
|
4841
|
+
note_type: draft.note_type,
|
|
4842
|
+
target: {
|
|
4843
|
+
target_type: 'order_detail',
|
|
4844
|
+
target_uuid: String(productLineUid)
|
|
4845
|
+
},
|
|
4846
|
+
text: draft.text
|
|
4847
|
+
});
|
|
4848
|
+
});
|
|
4849
|
+
};
|
|
4850
|
+
rollbackProductAndNotesMutation = function rollbackProductAndNotesMutation() {
|
|
4851
|
+
if (!mutationSnapshot) return;
|
|
4852
|
+
tempOrder.products = mutationSnapshot.products;
|
|
4853
|
+
tempOrder.bookings = mutationSnapshot.bookings;
|
|
4854
|
+
tempOrder.notes = mutationSnapshot.notes;
|
|
4855
|
+
tempOrder._extend = mutationSnapshot.extend;
|
|
4856
|
+
};
|
|
4169
4857
|
insertAfterProductUid = options === null || options === void 0 ? void 0 : options.insertAfterProductUid;
|
|
4170
4858
|
anchorIndex = booking && insertAfterProductUid ? tempOrder.products.findIndex(function (line) {
|
|
4171
4859
|
var _line$metadata;
|
|
@@ -4173,73 +4861,99 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4173
4861
|
return uid !== undefined && uid !== null && String(uid) === String(insertAfterProductUid);
|
|
4174
4862
|
}) : -1;
|
|
4175
4863
|
insertAtIndex = anchorIndex >= 0 ? anchorIndex + 1 : undefined;
|
|
4864
|
+
_context25.prev = 8;
|
|
4176
4865
|
if (!booking) {
|
|
4177
|
-
|
|
4866
|
+
_context25.next = 33;
|
|
4178
4867
|
break;
|
|
4179
4868
|
}
|
|
4180
4869
|
productRecord = product;
|
|
4181
|
-
splitCount = getSafeProductNum((
|
|
4870
|
+
splitCount = getSafeProductNum((_ref64 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref64 !== void 0 ? _ref64 : 1);
|
|
4182
4871
|
if (!(splitCount > 1)) {
|
|
4183
|
-
|
|
4872
|
+
_context25.next = 27;
|
|
4184
4873
|
break;
|
|
4185
4874
|
}
|
|
4186
4875
|
i = 0;
|
|
4187
|
-
case
|
|
4876
|
+
case 14:
|
|
4188
4877
|
if (!(i < splitCount)) {
|
|
4189
|
-
|
|
4878
|
+
_context25.next = 25;
|
|
4190
4879
|
break;
|
|
4191
4880
|
}
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4881
|
+
splitLine = this.createSplitBookingLine(productRecord, booking, i, splitCount);
|
|
4882
|
+
if (i > 0) {
|
|
4883
|
+
delete splitLine.product.unique_identification_number;
|
|
4884
|
+
delete splitLine.product.identity_key;
|
|
4885
|
+
if (splitLine.product.metadata) {
|
|
4886
|
+
splitLine.product.metadata = _objectSpread({}, splitLine.product.metadata);
|
|
4887
|
+
delete splitLine.product.metadata.unique_identification_number;
|
|
4888
|
+
delete splitLine.product.metadata.identity_key;
|
|
4889
|
+
}
|
|
4890
|
+
delete splitLine.booking.booking_uid;
|
|
4891
|
+
if (splitLine.booking.metadata) {
|
|
4892
|
+
splitLine.booking.metadata = _objectSpread({}, splitLine.booking.metadata);
|
|
4893
|
+
delete splitLine.booking.metadata.unique_identification_number;
|
|
4894
|
+
}
|
|
4895
|
+
}
|
|
4896
|
+
_context25.next = 19;
|
|
4897
|
+
return this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking, {
|
|
4196
4898
|
insertAtIndex: insertAtIndex,
|
|
4197
4899
|
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge
|
|
4198
4900
|
});
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
}
|
|
4203
|
-
_context21.next = 17;
|
|
4204
|
-
return _appendResult;
|
|
4205
|
-
case 17:
|
|
4901
|
+
case 19:
|
|
4902
|
+
committedProduct = _context25.sent;
|
|
4903
|
+
attachSalesNoteDrafts(committedProduct);
|
|
4206
4904
|
if (insertAtIndex !== undefined) insertAtIndex += 1;
|
|
4207
|
-
case
|
|
4905
|
+
case 22:
|
|
4208
4906
|
i += 1;
|
|
4209
|
-
|
|
4907
|
+
_context25.next = 14;
|
|
4210
4908
|
break;
|
|
4211
|
-
case
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
case
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
appendResult = this.appendProductLineToTempOrder(tempOrder, product, booking, {
|
|
4909
|
+
case 25:
|
|
4910
|
+
_context25.next = 31;
|
|
4911
|
+
break;
|
|
4912
|
+
case 27:
|
|
4913
|
+
_context25.next = 29;
|
|
4914
|
+
return this.appendProductLineToTempOrder(tempOrder, product, cloneDeep(booking), {
|
|
4218
4915
|
insertAtIndex: insertAtIndex,
|
|
4219
4916
|
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge
|
|
4220
4917
|
});
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
case
|
|
4228
|
-
|
|
4918
|
+
case 29:
|
|
4919
|
+
_committedProduct = _context25.sent;
|
|
4920
|
+
attachSalesNoteDrafts(_committedProduct);
|
|
4921
|
+
case 31:
|
|
4922
|
+
_context25.next = 37;
|
|
4923
|
+
break;
|
|
4924
|
+
case 33:
|
|
4925
|
+
_context25.next = 35;
|
|
4926
|
+
return this.appendProductLineToTempOrder(tempOrder, product, undefined, {
|
|
4927
|
+
insertAtIndex: insertAtIndex,
|
|
4928
|
+
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge
|
|
4929
|
+
});
|
|
4930
|
+
case 35:
|
|
4931
|
+
_committedProduct2 = _context25.sent;
|
|
4932
|
+
attachSalesNoteDrafts(_committedProduct2);
|
|
4933
|
+
case 37:
|
|
4934
|
+
_context25.next = 43;
|
|
4935
|
+
break;
|
|
4936
|
+
case 39:
|
|
4937
|
+
_context25.prev = 39;
|
|
4938
|
+
_context25.t0 = _context25["catch"](8);
|
|
4939
|
+
rollbackProductAndNotesMutation();
|
|
4940
|
+
throw _context25.t0;
|
|
4941
|
+
case 43:
|
|
4942
|
+
_context25.next = 45;
|
|
4229
4943
|
return this.finalizeProductOrderMutation(tempOrder);
|
|
4230
|
-
case
|
|
4944
|
+
case 45:
|
|
4231
4945
|
this.logInfo('addProductToOrder success', {
|
|
4232
4946
|
product_id: product.product_id,
|
|
4233
4947
|
with_booking: !!booking
|
|
4234
4948
|
});
|
|
4235
|
-
return
|
|
4236
|
-
case
|
|
4949
|
+
return _context25.abrupt("return", tempOrder.products);
|
|
4950
|
+
case 47:
|
|
4237
4951
|
case "end":
|
|
4238
|
-
return
|
|
4952
|
+
return _context25.stop();
|
|
4239
4953
|
}
|
|
4240
|
-
},
|
|
4954
|
+
}, _callee23, this, [[8, 39]]);
|
|
4241
4955
|
}));
|
|
4242
|
-
function addProductToOrder(
|
|
4956
|
+
function addProductToOrder(_x23, _x24, _x25) {
|
|
4243
4957
|
return _addProductToOrder.apply(this, arguments);
|
|
4244
4958
|
}
|
|
4245
4959
|
return addProductToOrder;
|
|
@@ -4257,103 +4971,101 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4257
4971
|
}, {
|
|
4258
4972
|
key: "addProductsToOrder",
|
|
4259
4973
|
value: (function () {
|
|
4260
|
-
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4261
|
-
var tempOrder, _iterator20, _step20, item, product, booking,
|
|
4262
|
-
return _regeneratorRuntime().wrap(function
|
|
4263
|
-
while (1) switch (
|
|
4974
|
+
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(items, options) {
|
|
4975
|
+
var tempOrder, _iterator20, _step20, item, product, booking, _ref65, _productRecord$num2, productRecord, splitCount, i, splitLine, _appendResult, appendResult;
|
|
4976
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context26) {
|
|
4977
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
4264
4978
|
case 0:
|
|
4265
4979
|
tempOrder = this.ensureTempOrder();
|
|
4266
4980
|
if (!(!Array.isArray(items) || items.length === 0)) {
|
|
4267
|
-
|
|
4981
|
+
_context26.next = 3;
|
|
4268
4982
|
break;
|
|
4269
4983
|
}
|
|
4270
|
-
return
|
|
4984
|
+
return _context26.abrupt("return", tempOrder.products);
|
|
4271
4985
|
case 3:
|
|
4272
4986
|
_iterator20 = _createForOfIteratorHelper(items || []);
|
|
4273
|
-
|
|
4987
|
+
_context26.prev = 4;
|
|
4274
4988
|
_iterator20.s();
|
|
4275
4989
|
case 6:
|
|
4276
4990
|
if ((_step20 = _iterator20.n()).done) {
|
|
4277
|
-
|
|
4991
|
+
_context26.next = 32;
|
|
4278
4992
|
break;
|
|
4279
4993
|
}
|
|
4280
4994
|
item = _step20.value;
|
|
4281
4995
|
product = item.product, booking = item.booking;
|
|
4282
4996
|
if (product) {
|
|
4283
|
-
|
|
4997
|
+
_context26.next = 11;
|
|
4284
4998
|
break;
|
|
4285
4999
|
}
|
|
4286
|
-
return
|
|
5000
|
+
return _context26.abrupt("continue", 30);
|
|
4287
5001
|
case 11:
|
|
4288
5002
|
if (!booking) {
|
|
4289
|
-
|
|
5003
|
+
_context26.next = 26;
|
|
4290
5004
|
break;
|
|
4291
5005
|
}
|
|
4292
5006
|
productRecord = product;
|
|
4293
|
-
splitCount = getSafeProductNum((
|
|
5007
|
+
splitCount = getSafeProductNum((_ref65 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref65 !== void 0 ? _ref65 : 1);
|
|
4294
5008
|
if (!(splitCount > 1)) {
|
|
4295
|
-
|
|
5009
|
+
_context26.next = 26;
|
|
4296
5010
|
break;
|
|
4297
5011
|
}
|
|
4298
5012
|
i = 0;
|
|
4299
5013
|
case 16:
|
|
4300
5014
|
if (!(i < splitCount)) {
|
|
4301
|
-
|
|
5015
|
+
_context26.next = 25;
|
|
4302
5016
|
break;
|
|
4303
5017
|
}
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
if (!_appendResult2) {
|
|
4309
|
-
_context22.next = 24;
|
|
5018
|
+
splitLine = this.createSplitBookingLine(productRecord, booking, i, splitCount);
|
|
5019
|
+
_appendResult = this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking);
|
|
5020
|
+
if (!_appendResult) {
|
|
5021
|
+
_context26.next = 22;
|
|
4310
5022
|
break;
|
|
4311
5023
|
}
|
|
4312
|
-
|
|
4313
|
-
return
|
|
4314
|
-
case
|
|
5024
|
+
_context26.next = 22;
|
|
5025
|
+
return _appendResult;
|
|
5026
|
+
case 22:
|
|
4315
5027
|
i += 1;
|
|
4316
|
-
|
|
5028
|
+
_context26.next = 16;
|
|
4317
5029
|
break;
|
|
4318
|
-
case
|
|
4319
|
-
return
|
|
4320
|
-
case
|
|
5030
|
+
case 25:
|
|
5031
|
+
return _context26.abrupt("continue", 30);
|
|
5032
|
+
case 26:
|
|
4321
5033
|
appendResult = this.appendProductLineToTempOrder(tempOrder, product, booking);
|
|
4322
5034
|
if (!appendResult) {
|
|
4323
|
-
|
|
5035
|
+
_context26.next = 30;
|
|
4324
5036
|
break;
|
|
4325
5037
|
}
|
|
4326
|
-
|
|
5038
|
+
_context26.next = 30;
|
|
4327
5039
|
return appendResult;
|
|
5040
|
+
case 30:
|
|
5041
|
+
_context26.next = 6;
|
|
5042
|
+
break;
|
|
4328
5043
|
case 32:
|
|
4329
|
-
|
|
5044
|
+
_context26.next = 37;
|
|
4330
5045
|
break;
|
|
4331
5046
|
case 34:
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
_iterator20.e(_context22.t0);
|
|
4338
|
-
case 39:
|
|
4339
|
-
_context22.prev = 39;
|
|
5047
|
+
_context26.prev = 34;
|
|
5048
|
+
_context26.t0 = _context26["catch"](4);
|
|
5049
|
+
_iterator20.e(_context26.t0);
|
|
5050
|
+
case 37:
|
|
5051
|
+
_context26.prev = 37;
|
|
4340
5052
|
_iterator20.f();
|
|
4341
|
-
return
|
|
4342
|
-
case
|
|
4343
|
-
|
|
5053
|
+
return _context26.finish(37);
|
|
5054
|
+
case 40:
|
|
5055
|
+
_context26.next = 42;
|
|
4344
5056
|
return this.finalizeProductOrderMutation(tempOrder, options);
|
|
4345
|
-
case
|
|
5057
|
+
case 42:
|
|
4346
5058
|
this.logInfo('addProductsToOrder success', {
|
|
4347
5059
|
itemsCount: items.length
|
|
4348
5060
|
});
|
|
4349
|
-
return
|
|
4350
|
-
case
|
|
5061
|
+
return _context26.abrupt("return", tempOrder.products);
|
|
5062
|
+
case 44:
|
|
4351
5063
|
case "end":
|
|
4352
|
-
return
|
|
5064
|
+
return _context26.stop();
|
|
4353
5065
|
}
|
|
4354
|
-
},
|
|
5066
|
+
}, _callee24, this, [[4, 34, 37, 40]]);
|
|
4355
5067
|
}));
|
|
4356
|
-
function addProductsToOrder(
|
|
5068
|
+
function addProductsToOrder(_x26, _x27) {
|
|
4357
5069
|
return _addProductsToOrder.apply(this, arguments);
|
|
4358
5070
|
}
|
|
4359
5071
|
return addProductsToOrder;
|
|
@@ -4380,24 +5092,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4380
5092
|
}, {
|
|
4381
5093
|
key: "getBundleRuntimeIdentity",
|
|
4382
5094
|
value: function getBundleRuntimeIdentity(bundle) {
|
|
4383
|
-
var
|
|
5095
|
+
var _ref66, _bundle$bundle_id2, _ref67, _bundle$bundle_group_2, _ref68, _ref69, _bundle$bundle_produc3, _ref70, _bundle$bundle_varian3;
|
|
4384
5096
|
if (!bundle || _typeof(bundle) !== 'object') return '';
|
|
4385
|
-
return [(
|
|
5097
|
+
return [(_ref66 = (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id) !== null && _ref66 !== void 0 ? _ref66 : '', (_ref67 = (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id) !== null && _ref67 !== void 0 ? _ref67 : '', (_ref68 = (_ref69 = (_bundle$bundle_produc3 = bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle._bundle_product_id) !== null && _ref69 !== void 0 ? _ref69 : bundle.product_id) !== null && _ref68 !== void 0 ? _ref68 : '', (_ref70 = (_bundle$bundle_varian3 = bundle.bundle_variant_id) !== null && _bundle$bundle_varian3 !== void 0 ? _bundle$bundle_varian3 : bundle.product_variant_id) !== null && _ref70 !== void 0 ? _ref70 : 0].join('|');
|
|
4386
5098
|
}
|
|
4387
5099
|
}, {
|
|
4388
5100
|
key: "preservePersistedBundlePriceFields",
|
|
4389
5101
|
value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
|
|
4390
|
-
var
|
|
5102
|
+
var _this31 = this;
|
|
4391
5103
|
if (!Array.isArray(nextBundles)) return nextBundles;
|
|
4392
5104
|
if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
|
|
4393
5105
|
var previousByIdentity = new Map();
|
|
4394
5106
|
previousBundles.forEach(function (bundle) {
|
|
4395
|
-
var identity =
|
|
5107
|
+
var identity = _this31.getBundleRuntimeIdentity(bundle);
|
|
4396
5108
|
if (identity) previousByIdentity.set(identity, bundle);
|
|
4397
5109
|
});
|
|
4398
5110
|
return nextBundles.map(function (bundle, index) {
|
|
4399
5111
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
4400
|
-
var previous = previousByIdentity.get(
|
|
5112
|
+
var previous = previousByIdentity.get(_this31.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
|
|
4401
5113
|
if (!previous || _typeof(previous) !== 'object') return bundle;
|
|
4402
5114
|
return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
|
|
4403
5115
|
cover: previous.cover
|
|
@@ -4533,13 +5245,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4533
5245
|
delete nextProduct.metadata.main_product_original_price;
|
|
4534
5246
|
delete nextProduct.metadata.price_schema_version;
|
|
4535
5247
|
} else if (callerChangesLineConfiguration && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
4536
|
-
var
|
|
5248
|
+
var _ref71, _targetProduct$metada10, _targetProduct$metada11, _ref72, _targetProduct$metada12, _targetProduct$metada13, _targetProduct$metada14;
|
|
4537
5249
|
// 仅 option / bundle 变化时,保留历史 source 和主商品折扣金额,
|
|
4538
5250
|
// 但必须让 original 与 selling 一起随新的 option 金额移动。
|
|
4539
5251
|
var previousOptionSum = sumOptionUnitPrice(getProductSkuOptions(targetProduct));
|
|
4540
5252
|
var nextOptionSum = sumOptionUnitPrice(getProductSkuOptions(nextProduct));
|
|
4541
|
-
var _previousMainOriginal = new Decimal(Number((
|
|
4542
|
-
var _previousMainSelling = new Decimal(Number((
|
|
5253
|
+
var _previousMainOriginal = new Decimal(Number((_ref71 = (_targetProduct$metada10 = (_targetProduct$metada11 = targetProduct.metadata) === null || _targetProduct$metada11 === void 0 ? void 0 : _targetProduct$metada11.main_product_original_price) !== null && _targetProduct$metada10 !== void 0 ? _targetProduct$metada10 : targetProduct.original_price) !== null && _ref71 !== void 0 ? _ref71 : 0) || 0);
|
|
5254
|
+
var _previousMainSelling = new Decimal(Number((_ref72 = (_targetProduct$metada12 = (_targetProduct$metada13 = targetProduct.metadata) === null || _targetProduct$metada13 === void 0 ? void 0 : _targetProduct$metada13.main_product_selling_price) !== null && _targetProduct$metada12 !== void 0 ? _targetProduct$metada12 : targetProduct.selling_price) !== null && _ref72 !== void 0 ? _ref72 : _previousMainOriginal.toNumber()) || 0);
|
|
4543
5255
|
var _preservedDiscount = _previousMainOriginal.minus(_previousMainSelling);
|
|
4544
5256
|
var previousSource = ((_targetProduct$metada14 = targetProduct.metadata) === null || _targetProduct$metada14 === void 0 ? void 0 : _targetProduct$metada14.source_product_price) != null ? new Decimal(Number(targetProduct.metadata.source_product_price) || 0) : _previousMainOriginal.minus(previousOptionSum);
|
|
4545
5257
|
var _nextMainOriginal = previousSource.plus(nextOptionSum);
|
|
@@ -4559,7 +5271,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4559
5271
|
}
|
|
4560
5272
|
// normalizeOrderProduct 幂等:v2 metadata 存在 → 保留 main_product_* 折扣重算 composite;
|
|
4561
5273
|
// 否则 → 把顶层 selling_price 视作 source,派生 main_product_* 并写 price_schema_version: 2。
|
|
4562
|
-
var normalizedProduct = mergeOrderProductDisplayFields(nextProduct, normalizeOrderProduct(nextProduct));
|
|
5274
|
+
var normalizedProduct = this.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(nextProduct, normalizeOrderProduct(nextProduct)));
|
|
4563
5275
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
4564
5276
|
var preservedBookingUid = nextProduct.booking_uid || ((_nextProduct$metadata = nextProduct.metadata) === null || _nextProduct$metadata === void 0 ? void 0 : _nextProduct$metadata.booking_uid) || targetProduct.booking_uid || ((_targetProduct$metada15 = targetProduct.metadata) === null || _targetProduct$metada15 === void 0 ? void 0 : _targetProduct$metada15.booking_uid);
|
|
4565
5277
|
if (!booking && preservedBookingUid) {
|
|
@@ -4598,37 +5310,39 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4598
5310
|
}, {
|
|
4599
5311
|
key: "updateOrderProduct",
|
|
4600
5312
|
value: function () {
|
|
4601
|
-
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4602
|
-
var tempOrder, updatedProductUid;
|
|
4603
|
-
return _regeneratorRuntime().wrap(function
|
|
4604
|
-
while (1) switch (
|
|
5313
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
|
|
5314
|
+
var tempOrder, updatedProductUid, promotionPayload;
|
|
5315
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context27) {
|
|
5316
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
4605
5317
|
case 0:
|
|
4606
5318
|
tempOrder = this.ensureTempOrder();
|
|
4607
5319
|
updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
4608
|
-
|
|
4609
|
-
return this.
|
|
5320
|
+
_context27.next = 4;
|
|
5321
|
+
return this.evaluatePromotion();
|
|
4610
5322
|
case 4:
|
|
5323
|
+
promotionPayload = _context27.sent;
|
|
4611
5324
|
this.applyDiscount({
|
|
4612
5325
|
reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
|
|
4613
5326
|
});
|
|
4614
5327
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4615
|
-
|
|
5328
|
+
_context27.next = 9;
|
|
4616
5329
|
return this.recalculateSummary({
|
|
4617
5330
|
createIfMissing: true
|
|
4618
5331
|
});
|
|
4619
|
-
case
|
|
5332
|
+
case 9:
|
|
4620
5333
|
this.persistTempOrder();
|
|
5334
|
+
this.emitPromotionApplied(promotionPayload);
|
|
4621
5335
|
this.logInfo('updateOrderProduct success', {
|
|
4622
5336
|
params: params
|
|
4623
5337
|
});
|
|
4624
|
-
return
|
|
4625
|
-
case
|
|
5338
|
+
return _context27.abrupt("return", tempOrder.products);
|
|
5339
|
+
case 13:
|
|
4626
5340
|
case "end":
|
|
4627
|
-
return
|
|
5341
|
+
return _context27.stop();
|
|
4628
5342
|
}
|
|
4629
|
-
},
|
|
5343
|
+
}, _callee25, this);
|
|
4630
5344
|
}));
|
|
4631
|
-
function updateOrderProduct(
|
|
5345
|
+
function updateOrderProduct(_x28) {
|
|
4632
5346
|
return _updateOrderProduct.apply(this, arguments);
|
|
4633
5347
|
}
|
|
4634
5348
|
return updateOrderProduct;
|
|
@@ -4636,28 +5350,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4636
5350
|
}, {
|
|
4637
5351
|
key: "updateOrderProducts",
|
|
4638
5352
|
value: function () {
|
|
4639
|
-
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4640
|
-
var
|
|
5353
|
+
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(paramsList) {
|
|
5354
|
+
var _this32 = this;
|
|
4641
5355
|
var tempOrder, reapplyBookingDiscountProductUids;
|
|
4642
|
-
return _regeneratorRuntime().wrap(function
|
|
4643
|
-
while (1) switch (
|
|
5356
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context28) {
|
|
5357
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
4644
5358
|
case 0:
|
|
4645
5359
|
tempOrder = this.ensureTempOrder();
|
|
4646
5360
|
if (paramsList.length) {
|
|
4647
|
-
|
|
5361
|
+
_context28.next = 3;
|
|
4648
5362
|
break;
|
|
4649
5363
|
}
|
|
4650
|
-
return
|
|
5364
|
+
return _context28.abrupt("return", tempOrder.products);
|
|
4651
5365
|
case 3:
|
|
4652
5366
|
reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
|
|
4653
|
-
var updatedProductUid =
|
|
5367
|
+
var updatedProductUid = _this32.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
4654
5368
|
// 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
|
|
4655
5369
|
if (params.allow_booking_discount_reapply && updatedProductUid) {
|
|
4656
5370
|
acc.push(String(updatedProductUid));
|
|
4657
5371
|
}
|
|
4658
5372
|
return acc;
|
|
4659
5373
|
}, []);
|
|
4660
|
-
|
|
5374
|
+
_context28.next = 6;
|
|
4661
5375
|
return this.finalizeAfterProductsMutation(tempOrder, {
|
|
4662
5376
|
reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
|
|
4663
5377
|
});
|
|
@@ -4665,14 +5379,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4665
5379
|
this.logInfo('updateOrderProduct success', {
|
|
4666
5380
|
paramsList: paramsList
|
|
4667
5381
|
});
|
|
4668
|
-
return
|
|
5382
|
+
return _context28.abrupt("return", tempOrder.products);
|
|
4669
5383
|
case 8:
|
|
4670
5384
|
case "end":
|
|
4671
|
-
return
|
|
5385
|
+
return _context28.stop();
|
|
4672
5386
|
}
|
|
4673
|
-
},
|
|
5387
|
+
}, _callee26, this);
|
|
4674
5388
|
}));
|
|
4675
|
-
function updateOrderProducts(
|
|
5389
|
+
function updateOrderProducts(_x29) {
|
|
4676
5390
|
return _updateOrderProducts.apply(this, arguments);
|
|
4677
5391
|
}
|
|
4678
5392
|
return updateOrderProducts;
|
|
@@ -4680,11 +5394,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4680
5394
|
}, {
|
|
4681
5395
|
key: "updateOrderProductQuantity",
|
|
4682
5396
|
value: function () {
|
|
4683
|
-
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5397
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
|
|
4684
5398
|
var _targetProduct$metada17;
|
|
4685
|
-
var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct;
|
|
4686
|
-
return _regeneratorRuntime().wrap(function
|
|
4687
|
-
while (1) switch (
|
|
5399
|
+
var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct, settlementSnapshot, currencyProductId, asset, requiredAmount, balance, isVirtualSettlement, promotionPayload;
|
|
5400
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context29) {
|
|
5401
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
4688
5402
|
case 0:
|
|
4689
5403
|
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;
|
|
4690
5404
|
tempOrder = this.ensureTempOrder();
|
|
@@ -4714,42 +5428,85 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4714
5428
|
productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
|
|
4715
5429
|
}
|
|
4716
5430
|
if (!(productIndex === -1)) {
|
|
4717
|
-
|
|
5431
|
+
_context29.next = 13;
|
|
4718
5432
|
break;
|
|
4719
5433
|
}
|
|
4720
5434
|
throw new Error('[Order] 目标商品不存在,无法更新数量');
|
|
4721
5435
|
case 13:
|
|
4722
5436
|
targetProduct = tempOrder.products[productIndex];
|
|
4723
|
-
normalizedProduct = normalizeOrderProduct(_objectSpread(_objectSpread({}, targetProduct), {}, {
|
|
5437
|
+
normalizedProduct = this.normalizeVirtualSettlementProductIfEnabled(normalizeOrderProduct(_objectSpread(_objectSpread({}, targetProduct), {}, {
|
|
4724
5438
|
num: getSafeProductNum(num),
|
|
4725
5439
|
metadata: _objectSpread(_objectSpread({}, targetProduct.metadata || {}), {}, {
|
|
4726
5440
|
unique_identification_number: ((_targetProduct$metada17 = targetProduct.metadata) === null || _targetProduct$metada17 === void 0 ? void 0 : _targetProduct$metada17.unique_identification_number) || unique_identification_number
|
|
4727
5441
|
})
|
|
4728
|
-
}));
|
|
5442
|
+
})));
|
|
4729
5443
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
5444
|
+
settlementSnapshot = getSelectedSettlementSnapshot(normalizedProduct);
|
|
5445
|
+
if (!(this.isMultiCurrencySettlementEnabled() && (settlementSnapshot === null || settlementSnapshot === void 0 ? void 0 : settlementSnapshot.settlement_type) === 'virtual_currency' && tempOrder.customer_id && Number(tempOrder.customer_id) !== 1)) {
|
|
5446
|
+
_context29.next = 26;
|
|
5447
|
+
break;
|
|
5448
|
+
}
|
|
5449
|
+
currencyProductId = Number(settlementSnapshot.currency_product_id);
|
|
5450
|
+
asset = (this.store.virtualCurrencyList || []).find(function (item) {
|
|
5451
|
+
return Number(item === null || item === void 0 ? void 0 : item.product_id) === currencyProductId;
|
|
5452
|
+
});
|
|
5453
|
+
if (asset) {
|
|
5454
|
+
_context29.next = 22;
|
|
5455
|
+
break;
|
|
5456
|
+
}
|
|
5457
|
+
throw new VirtualCurrencyAssetNotFoundError(currencyProductId);
|
|
5458
|
+
case 22:
|
|
5459
|
+
requiredAmount = tempOrder.products.reduce(function (sum, item, index) {
|
|
5460
|
+
var current = index === productIndex ? normalizedProduct : item;
|
|
5461
|
+
var currentSnapshot = getSelectedSettlementSnapshot(current);
|
|
5462
|
+
return sum.plus(new Decimal((currentSnapshot === null || currentSnapshot === void 0 ? void 0 : currentSnapshot.price) || current.selling_price || 0).times(current.num || 1));
|
|
5463
|
+
}, new Decimal(0));
|
|
5464
|
+
balance = new Decimal(asset.balance || 0);
|
|
5465
|
+
if (!balance.lt(requiredAmount)) {
|
|
5466
|
+
_context29.next = 26;
|
|
5467
|
+
break;
|
|
5468
|
+
}
|
|
5469
|
+
throw new VirtualCurrencyBalanceError(balance.toFixed(2), requiredAmount.toFixed(2));
|
|
5470
|
+
case 26:
|
|
4730
5471
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
5472
|
+
this.prepareVirtualSettlementTempOrder(tempOrder);
|
|
5473
|
+
isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder);
|
|
5474
|
+
if (isVirtualSettlement) {
|
|
5475
|
+
_context29.next = 35;
|
|
5476
|
+
break;
|
|
5477
|
+
}
|
|
5478
|
+
_context29.next = 32;
|
|
5479
|
+
return this.evaluatePromotion();
|
|
5480
|
+
case 32:
|
|
5481
|
+
_context29.t0 = _context29.sent;
|
|
5482
|
+
_context29.next = 36;
|
|
5483
|
+
break;
|
|
5484
|
+
case 35:
|
|
5485
|
+
_context29.t0 = null;
|
|
5486
|
+
case 36:
|
|
5487
|
+
promotionPayload = _context29.t0;
|
|
5488
|
+
if (!isVirtualSettlement) {
|
|
5489
|
+
this.applyDiscount();
|
|
5490
|
+
}
|
|
4735
5491
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4736
|
-
|
|
5492
|
+
_context29.next = 41;
|
|
4737
5493
|
return this.recalculateSummary({
|
|
4738
5494
|
createIfMissing: true
|
|
4739
5495
|
});
|
|
4740
|
-
case
|
|
5496
|
+
case 41:
|
|
4741
5497
|
this.persistTempOrder();
|
|
5498
|
+
this.emitPromotionApplied(promotionPayload);
|
|
4742
5499
|
this.logInfo('updateOrderProductQuantity success', {
|
|
4743
5500
|
params: params
|
|
4744
5501
|
});
|
|
4745
|
-
return
|
|
4746
|
-
case
|
|
5502
|
+
return _context29.abrupt("return", tempOrder.products);
|
|
5503
|
+
case 45:
|
|
4747
5504
|
case "end":
|
|
4748
|
-
return
|
|
5505
|
+
return _context29.stop();
|
|
4749
5506
|
}
|
|
4750
|
-
},
|
|
5507
|
+
}, _callee27, this);
|
|
4751
5508
|
}));
|
|
4752
|
-
function updateOrderProductQuantity(
|
|
5509
|
+
function updateOrderProductQuantity(_x30) {
|
|
4753
5510
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
4754
5511
|
}
|
|
4755
5512
|
return updateOrderProductQuantity;
|
|
@@ -4790,31 +5547,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4790
5547
|
}, {
|
|
4791
5548
|
key: "finalizeAfterProductsMutation",
|
|
4792
5549
|
value: (function () {
|
|
4793
|
-
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4794
|
-
|
|
4795
|
-
|
|
5550
|
+
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(tempOrder, options) {
|
|
5551
|
+
var promotionPayload;
|
|
5552
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context30) {
|
|
5553
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
4796
5554
|
case 0:
|
|
4797
5555
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
4798
|
-
|
|
4799
|
-
return this.
|
|
5556
|
+
_context30.next = 3;
|
|
5557
|
+
return this.evaluatePromotion();
|
|
4800
5558
|
case 3:
|
|
5559
|
+
promotionPayload = _context30.sent;
|
|
4801
5560
|
this.applyDiscount({
|
|
4802
5561
|
reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids
|
|
4803
5562
|
});
|
|
4804
5563
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4805
|
-
|
|
5564
|
+
_context30.next = 8;
|
|
4806
5565
|
return this.recalculateSummary({
|
|
4807
5566
|
createIfMissing: true
|
|
4808
5567
|
});
|
|
4809
|
-
case 7:
|
|
4810
|
-
this.persistTempOrder();
|
|
4811
5568
|
case 8:
|
|
5569
|
+
this.persistTempOrder();
|
|
5570
|
+
this.emitPromotionApplied(promotionPayload);
|
|
5571
|
+
case 10:
|
|
4812
5572
|
case "end":
|
|
4813
|
-
return
|
|
5573
|
+
return _context30.stop();
|
|
4814
5574
|
}
|
|
4815
|
-
},
|
|
5575
|
+
}, _callee28, this);
|
|
4816
5576
|
}));
|
|
4817
|
-
function finalizeAfterProductsMutation(
|
|
5577
|
+
function finalizeAfterProductsMutation(_x31, _x32) {
|
|
4818
5578
|
return _finalizeAfterProductsMutation.apply(this, arguments);
|
|
4819
5579
|
}
|
|
4820
5580
|
return finalizeAfterProductsMutation;
|
|
@@ -4829,20 +5589,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4829
5589
|
}, {
|
|
4830
5590
|
key: "removeProductsFromOrder",
|
|
4831
5591
|
value: (function () {
|
|
4832
|
-
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4833
|
-
var
|
|
5592
|
+
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(identities, options) {
|
|
5593
|
+
var _this33 = this;
|
|
4834
5594
|
var tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
|
|
4835
|
-
return _regeneratorRuntime().wrap(function
|
|
4836
|
-
while (1) switch (
|
|
5595
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context32) {
|
|
5596
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
4837
5597
|
case 0:
|
|
4838
5598
|
tempOrder = this.ensureTempOrder();
|
|
4839
|
-
this.repairDuplicateProductLineIdentities(tempOrder);
|
|
4840
5599
|
if (identities.length) {
|
|
4841
|
-
|
|
5600
|
+
_context32.next = 3;
|
|
4842
5601
|
break;
|
|
4843
5602
|
}
|
|
4844
|
-
return
|
|
4845
|
-
case
|
|
5603
|
+
return _context32.abrupt("return", tempOrder.products);
|
|
5604
|
+
case 3:
|
|
5605
|
+
// 商品删除会同步删除以商品行为主关系的 Notes;快照不完整时禁止产生孤儿 Relation。
|
|
5606
|
+
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
5607
|
+
this.repairDuplicateProductLineIdentities(tempOrder);
|
|
4846
5608
|
productsBeforeRemove = tempOrder.products || [];
|
|
4847
5609
|
bookingsBeforeRemove = tempOrder.bookings || [];
|
|
4848
5610
|
preserveDisplayPosition = options === null || options === void 0 ? void 0 : options.preserveDisplayPosition;
|
|
@@ -4871,29 +5633,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4871
5633
|
}
|
|
4872
5634
|
linkedBookingUidsToRemove = new Set();
|
|
4873
5635
|
_iterator21 = _createForOfIteratorHelper(matchedProducts);
|
|
4874
|
-
|
|
5636
|
+
_context32.prev = 16;
|
|
4875
5637
|
_loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
|
|
4876
5638
|
var _metadata11, _metadata12, _metadata13, _metadata14;
|
|
4877
5639
|
var product, productUid, productBookingUid, isAddTimeProduct;
|
|
4878
|
-
return _regeneratorRuntime().wrap(function _loop3$(
|
|
4879
|
-
while (1) switch (
|
|
5640
|
+
return _regeneratorRuntime().wrap(function _loop3$(_context31) {
|
|
5641
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
4880
5642
|
case 0:
|
|
4881
5643
|
product = _step21.value;
|
|
4882
5644
|
productUid = (product === null || product === void 0 || (_metadata11 = product.metadata) === null || _metadata11 === void 0 ? void 0 : _metadata11.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
4883
5645
|
productBookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_metadata12 = product.metadata) === null || _metadata12 === void 0 ? void 0 : _metadata12.booking_uid);
|
|
4884
5646
|
isAddTimeProduct = (product === null || product === void 0 || (_metadata13 = product.metadata) === null || _metadata13 === void 0 ? void 0 : _metadata13.product_add_schedule_time) !== undefined && (product === null || product === void 0 || (_metadata14 = product.metadata) === null || _metadata14 === void 0 ? void 0 : _metadata14.product_add_schedule_time) !== null;
|
|
4885
5647
|
if (!isAddTimeProduct) {
|
|
4886
|
-
|
|
5648
|
+
_context31.next = 6;
|
|
4887
5649
|
break;
|
|
4888
5650
|
}
|
|
4889
|
-
return
|
|
5651
|
+
return _context31.abrupt("return", 1);
|
|
4890
5652
|
case 6:
|
|
4891
5653
|
if (productBookingUid !== undefined && productBookingUid !== null && productBookingUid !== '') {
|
|
4892
5654
|
linkedBookingUidsToRemove.add(String(productBookingUid));
|
|
4893
5655
|
}
|
|
4894
5656
|
if (productUid !== undefined && productUid !== null && productUid !== '') {
|
|
4895
5657
|
bookingsBeforeRemove.forEach(function (booking) {
|
|
4896
|
-
var bookingUid =
|
|
5658
|
+
var bookingUid = _this33.getBookingUniqueIdentificationNumber(booking);
|
|
4897
5659
|
if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
|
|
4898
5660
|
linkedBookingUidsToRemove.add(bookingUid);
|
|
4899
5661
|
}
|
|
@@ -4901,38 +5663,38 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4901
5663
|
}
|
|
4902
5664
|
case 8:
|
|
4903
5665
|
case "end":
|
|
4904
|
-
return
|
|
5666
|
+
return _context31.stop();
|
|
4905
5667
|
}
|
|
4906
5668
|
}, _loop3);
|
|
4907
5669
|
});
|
|
4908
5670
|
_iterator21.s();
|
|
4909
|
-
case
|
|
5671
|
+
case 19:
|
|
4910
5672
|
if ((_step21 = _iterator21.n()).done) {
|
|
4911
|
-
|
|
5673
|
+
_context32.next = 25;
|
|
4912
5674
|
break;
|
|
4913
5675
|
}
|
|
4914
|
-
return
|
|
4915
|
-
case
|
|
4916
|
-
if (!
|
|
4917
|
-
|
|
5676
|
+
return _context32.delegateYield(_loop3(), "t0", 21);
|
|
5677
|
+
case 21:
|
|
5678
|
+
if (!_context32.t0) {
|
|
5679
|
+
_context32.next = 23;
|
|
4918
5680
|
break;
|
|
4919
5681
|
}
|
|
4920
|
-
return
|
|
4921
|
-
case
|
|
4922
|
-
|
|
5682
|
+
return _context32.abrupt("continue", 23);
|
|
5683
|
+
case 23:
|
|
5684
|
+
_context32.next = 19;
|
|
4923
5685
|
break;
|
|
4924
|
-
case
|
|
4925
|
-
|
|
5686
|
+
case 25:
|
|
5687
|
+
_context32.next = 30;
|
|
4926
5688
|
break;
|
|
4927
|
-
case
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
_iterator21.e(
|
|
4931
|
-
case
|
|
4932
|
-
|
|
5689
|
+
case 27:
|
|
5690
|
+
_context32.prev = 27;
|
|
5691
|
+
_context32.t1 = _context32["catch"](16);
|
|
5692
|
+
_iterator21.e(_context32.t1);
|
|
5693
|
+
case 30:
|
|
5694
|
+
_context32.prev = 30;
|
|
4933
5695
|
_iterator21.f();
|
|
4934
|
-
return
|
|
4935
|
-
case
|
|
5696
|
+
return _context32.finish(30);
|
|
5697
|
+
case 33:
|
|
4936
5698
|
if (linkedBookingUidsToRemove.size > 0) {
|
|
4937
5699
|
// 删除主预约商品时,同步移除挂在同一 booking_uid 下的加时商品,避免残留孤儿行。
|
|
4938
5700
|
tempOrder.products = (tempOrder.products || []).filter(function (line) {
|
|
@@ -4958,20 +5720,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4958
5720
|
tempOrder.products = nextProductIndex >= 0 ? [].concat(_toConsumableArray(productsWithoutRemaining.slice(0, nextProductIndex)), [remainingProduct], _toConsumableArray(productsWithoutRemaining.slice(nextProductIndex))) : [].concat(_toConsumableArray(productsWithoutRemaining), [remainingProduct]);
|
|
4959
5721
|
}
|
|
4960
5722
|
}
|
|
4961
|
-
|
|
5723
|
+
this.removeSalesNotesForMissingProductLines(tempOrder);
|
|
5724
|
+
_context32.next = 38;
|
|
4962
5725
|
return this.finalizeAfterProductsMutation(tempOrder);
|
|
4963
|
-
case
|
|
5726
|
+
case 38:
|
|
4964
5727
|
this.logInfo('removeProductsFromOrder success', {
|
|
4965
5728
|
identities: identities
|
|
4966
5729
|
});
|
|
4967
|
-
return
|
|
4968
|
-
case
|
|
5730
|
+
return _context32.abrupt("return", tempOrder.products);
|
|
5731
|
+
case 40:
|
|
4969
5732
|
case "end":
|
|
4970
|
-
return
|
|
5733
|
+
return _context32.stop();
|
|
4971
5734
|
}
|
|
4972
|
-
},
|
|
5735
|
+
}, _callee29, this, [[16, 27, 30, 33]]);
|
|
4973
5736
|
}));
|
|
4974
|
-
function removeProductsFromOrder(
|
|
5737
|
+
function removeProductsFromOrder(_x33, _x34) {
|
|
4975
5738
|
return _removeProductsFromOrder.apply(this, arguments);
|
|
4976
5739
|
}
|
|
4977
5740
|
return removeProductsFromOrder;
|
|
@@ -4979,88 +5742,151 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4979
5742
|
}, {
|
|
4980
5743
|
key: "removeProductFromOrder",
|
|
4981
5744
|
value: function () {
|
|
4982
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4983
|
-
return _regeneratorRuntime().wrap(function
|
|
4984
|
-
while (1) switch (
|
|
5745
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(identity, options) {
|
|
5746
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context33) {
|
|
5747
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
4985
5748
|
case 0:
|
|
4986
|
-
return
|
|
5749
|
+
return _context33.abrupt("return", this.removeProductsFromOrder([identity], options));
|
|
4987
5750
|
case 1:
|
|
4988
5751
|
case "end":
|
|
4989
|
-
return
|
|
5752
|
+
return _context33.stop();
|
|
4990
5753
|
}
|
|
4991
|
-
},
|
|
5754
|
+
}, _callee30, this);
|
|
4992
5755
|
}));
|
|
4993
|
-
function removeProductFromOrder(
|
|
5756
|
+
function removeProductFromOrder(_x35, _x36) {
|
|
4994
5757
|
return _removeProductFromOrder.apply(this, arguments);
|
|
4995
5758
|
}
|
|
4996
5759
|
return removeProductFromOrder;
|
|
4997
5760
|
}()
|
|
4998
5761
|
/**
|
|
4999
5762
|
* 仅清空购物车行(products / bookings),不重置整单。
|
|
5000
|
-
*
|
|
5763
|
+
* 普通整单 note 保持不变;以商品行为主体的 Sales Notes 同步删除。
|
|
5001
5764
|
*/
|
|
5002
5765
|
}, {
|
|
5003
5766
|
key: "clearOrderCartLines",
|
|
5004
5767
|
value: (function () {
|
|
5005
|
-
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5006
|
-
var tempOrder;
|
|
5007
|
-
return _regeneratorRuntime().wrap(function
|
|
5008
|
-
while (1) switch (
|
|
5768
|
+
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
|
|
5769
|
+
var tempOrder, promotionPayload;
|
|
5770
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context34) {
|
|
5771
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
5009
5772
|
case 0:
|
|
5010
5773
|
tempOrder = this.ensureTempOrder();
|
|
5774
|
+
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
5011
5775
|
tempOrder.products = [];
|
|
5012
5776
|
tempOrder.bookings = [];
|
|
5777
|
+
releaseTempOrderSettlementState(tempOrder);
|
|
5778
|
+
this.removeSalesNotesForMissingProductLines(tempOrder);
|
|
5013
5779
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
5014
5780
|
if (tempOrder._extend && _typeof(tempOrder._extend) === 'object') {
|
|
5015
5781
|
tempOrder._extend = _objectSpread(_objectSpread({}, tempOrder._extend), {}, {
|
|
5016
5782
|
productsByUid: {}
|
|
5017
5783
|
});
|
|
5018
5784
|
}
|
|
5019
|
-
|
|
5020
|
-
return this.
|
|
5021
|
-
case
|
|
5785
|
+
_context34.next = 10;
|
|
5786
|
+
return this.evaluatePromotion();
|
|
5787
|
+
case 10:
|
|
5788
|
+
promotionPayload = _context34.sent;
|
|
5022
5789
|
this.applyDiscount();
|
|
5023
5790
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
5024
|
-
|
|
5791
|
+
_context34.next = 15;
|
|
5025
5792
|
return this.recalculateSummary({
|
|
5026
5793
|
createIfMissing: true
|
|
5027
5794
|
});
|
|
5028
|
-
case
|
|
5795
|
+
case 15:
|
|
5029
5796
|
this.persistTempOrder();
|
|
5797
|
+
this.emitPromotionApplied(promotionPayload);
|
|
5030
5798
|
this.logInfo('clearOrderCartLines success', {});
|
|
5031
|
-
return
|
|
5032
|
-
case
|
|
5799
|
+
return _context34.abrupt("return", tempOrder);
|
|
5800
|
+
case 19:
|
|
5033
5801
|
case "end":
|
|
5034
|
-
return
|
|
5802
|
+
return _context34.stop();
|
|
5035
5803
|
}
|
|
5036
|
-
},
|
|
5804
|
+
}, _callee31, this);
|
|
5037
5805
|
}));
|
|
5038
5806
|
function clearOrderCartLines() {
|
|
5039
5807
|
return _clearOrderCartLines.apply(this, arguments);
|
|
5040
5808
|
}
|
|
5041
5809
|
return clearOrderCartLines;
|
|
5810
|
+
}()
|
|
5811
|
+
/**
|
|
5812
|
+
* 切换购物车结算单位时清理所有会影响新币种的订单状态,但保留当前客户。
|
|
5813
|
+
*/
|
|
5814
|
+
)
|
|
5815
|
+
}, {
|
|
5816
|
+
key: "clearOrderForSettlementSwitch",
|
|
5817
|
+
value: (function () {
|
|
5818
|
+
var _clearOrderForSettlementSwitch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
|
|
5819
|
+
var _this$store$discount22, _this$store$discount23;
|
|
5820
|
+
var tempOrder;
|
|
5821
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context35) {
|
|
5822
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
5823
|
+
case 0:
|
|
5824
|
+
tempOrder = this.ensureTempOrder();
|
|
5825
|
+
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
5826
|
+
tempOrder.products = [];
|
|
5827
|
+
tempOrder.bookings = [];
|
|
5828
|
+
this.removeSalesNotesForMissingProductLines(tempOrder);
|
|
5829
|
+
tempOrder.discount_list = [];
|
|
5830
|
+
tempOrder.payments = [];
|
|
5831
|
+
tempOrder.refunds = [];
|
|
5832
|
+
tempOrder.shop_discount = '0.00';
|
|
5833
|
+
tempOrder.surcharges = [];
|
|
5834
|
+
releaseTempOrderSettlementState(tempOrder);
|
|
5835
|
+
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
5836
|
+
if (tempOrder._extend && _typeof(tempOrder._extend) === 'object') {
|
|
5837
|
+
tempOrder._extend = _objectSpread(_objectSpread({}, tempOrder._extend), {}, {
|
|
5838
|
+
productsByUid: {}
|
|
5839
|
+
});
|
|
5840
|
+
}
|
|
5841
|
+
_context35.next = 15;
|
|
5842
|
+
return (_this$store$discount22 = this.store.discount) === null || _this$store$discount22 === void 0 ? void 0 : _this$store$discount22.setDiscountList([]);
|
|
5843
|
+
case 15:
|
|
5844
|
+
_context35.next = 17;
|
|
5845
|
+
return (_this$store$discount23 = this.store.discount) === null || _this$store$discount23 === void 0 ? void 0 : _this$store$discount23.setOriginalDiscountList([]);
|
|
5846
|
+
case 17:
|
|
5847
|
+
this.hasActiveCustomerBoundDiscount = false;
|
|
5848
|
+
this.lastUnfulfilledPromotions = [];
|
|
5849
|
+
this.lastGiftActions = null;
|
|
5850
|
+
_context35.next = 22;
|
|
5851
|
+
return this.recalculateSummary({
|
|
5852
|
+
createIfMissing: true
|
|
5853
|
+
});
|
|
5854
|
+
case 22:
|
|
5855
|
+
this.persistTempOrder();
|
|
5856
|
+
this.logInfo('clearOrderForSettlementSwitch success', {});
|
|
5857
|
+
return _context35.abrupt("return", tempOrder);
|
|
5858
|
+
case 25:
|
|
5859
|
+
case "end":
|
|
5860
|
+
return _context35.stop();
|
|
5861
|
+
}
|
|
5862
|
+
}, _callee32, this);
|
|
5863
|
+
}));
|
|
5864
|
+
function clearOrderForSettlementSwitch() {
|
|
5865
|
+
return _clearOrderForSettlementSwitch.apply(this, arguments);
|
|
5866
|
+
}
|
|
5867
|
+
return clearOrderForSettlementSwitch;
|
|
5042
5868
|
}() // ─── TempOrder: 提交 ───
|
|
5043
5869
|
)
|
|
5044
5870
|
}, {
|
|
5045
5871
|
key: "buildCurrentSubmitPayloadForLocalPrint",
|
|
5046
5872
|
value: function buildCurrentSubmitPayloadForLocalPrint(params) {
|
|
5047
|
-
var _params$cacheId, _this$
|
|
5873
|
+
var _params$cacheId, _this$otherParams5, _ref73, _params$businessCode, _this$otherParams6, _this$otherParams7;
|
|
5048
5874
|
var tempOrder = this.ensureTempOrder();
|
|
5049
5875
|
this.persistTempOrder();
|
|
5050
5876
|
var payload = buildSubmitPayload({
|
|
5051
5877
|
tempOrder: tempOrder,
|
|
5052
5878
|
cacheId: (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId,
|
|
5053
|
-
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$
|
|
5054
|
-
businessCode: (
|
|
5879
|
+
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.platform),
|
|
5880
|
+
businessCode: (_ref73 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.businessCode) !== null && _ref73 !== void 0 ? _ref73 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.business_code,
|
|
5055
5881
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
5056
5882
|
type: params === null || params === void 0 ? void 0 : params.type,
|
|
5057
5883
|
summary: this.store.summary || createEmptySummary(),
|
|
5058
5884
|
enhance: function enhance(nextPayload) {
|
|
5059
|
-
var
|
|
5885
|
+
var _ref74, _tempOrder$order_numb, _ref75, _tempOrder$shop_order2, _ref76, _tempOrder$shop_full_;
|
|
5060
5886
|
return _objectSpread(_objectSpread({}, nextPayload), {}, {
|
|
5061
|
-
order_number: (
|
|
5062
|
-
shop_order_number: (
|
|
5063
|
-
shop_full_order_number: (
|
|
5887
|
+
order_number: (_ref74 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref74 !== void 0 ? _ref74 : null,
|
|
5888
|
+
shop_order_number: (_ref75 = (_tempOrder$shop_order2 = tempOrder.shop_order_number) !== null && _tempOrder$shop_order2 !== void 0 ? _tempOrder$shop_order2 : nextPayload.shop_order_number) !== null && _ref75 !== void 0 ? _ref75 : null,
|
|
5889
|
+
shop_full_order_number: (_ref76 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref76 !== void 0 ? _ref76 : null,
|
|
5064
5890
|
small_ticket_data_flag: 1
|
|
5065
5891
|
});
|
|
5066
5892
|
}
|
|
@@ -5071,17 +5897,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5071
5897
|
}, {
|
|
5072
5898
|
key: "applyLocalPrintOrderNumbers",
|
|
5073
5899
|
value: function () {
|
|
5074
|
-
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5900
|
+
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(order) {
|
|
5075
5901
|
var tempOrder, shopOrderNumber, shopFullOrderNumber;
|
|
5076
|
-
return _regeneratorRuntime().wrap(function
|
|
5077
|
-
while (1) switch (
|
|
5902
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context36) {
|
|
5903
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
5078
5904
|
case 0:
|
|
5079
5905
|
tempOrder = this.ensureTempOrder();
|
|
5080
5906
|
if (!(!order || _typeof(order) !== 'object')) {
|
|
5081
|
-
|
|
5907
|
+
_context36.next = 3;
|
|
5082
5908
|
break;
|
|
5083
5909
|
}
|
|
5084
|
-
return
|
|
5910
|
+
return _context36.abrupt("return", tempOrder);
|
|
5085
5911
|
case 3:
|
|
5086
5912
|
shopOrderNumber = order.shop_order_number;
|
|
5087
5913
|
shopFullOrderNumber = order.shop_full_order_number;
|
|
@@ -5092,17 +5918,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5092
5918
|
tempOrder.shop_full_order_number = String(shopFullOrderNumber);
|
|
5093
5919
|
}
|
|
5094
5920
|
this.persistTempOrder();
|
|
5095
|
-
|
|
5921
|
+
_context36.next = 10;
|
|
5096
5922
|
return this.saveDraft();
|
|
5097
5923
|
case 10:
|
|
5098
|
-
return
|
|
5924
|
+
return _context36.abrupt("return", tempOrder);
|
|
5099
5925
|
case 11:
|
|
5100
5926
|
case "end":
|
|
5101
|
-
return
|
|
5927
|
+
return _context36.stop();
|
|
5102
5928
|
}
|
|
5103
|
-
},
|
|
5929
|
+
}, _callee33, this);
|
|
5104
5930
|
}));
|
|
5105
|
-
function applyLocalPrintOrderNumbers(
|
|
5931
|
+
function applyLocalPrintOrderNumbers(_x37) {
|
|
5106
5932
|
return _applyLocalPrintOrderNumbers.apply(this, arguments);
|
|
5107
5933
|
}
|
|
5108
5934
|
return applyLocalPrintOrderNumbers;
|
|
@@ -5110,42 +5936,42 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5110
5936
|
}, {
|
|
5111
5937
|
key: "saveTempOrderAsDraft",
|
|
5112
5938
|
value: function () {
|
|
5113
|
-
var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5114
|
-
var _params$cacheId2, _this$
|
|
5939
|
+
var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
|
|
5940
|
+
var _params$cacheId2, _this$otherParams8, _this$otherParams9, _this$otherParams10, _params$type, _this$otherParams11, _payload$products;
|
|
5115
5941
|
var tempOrder, latestSummary, payload;
|
|
5116
|
-
return _regeneratorRuntime().wrap(function
|
|
5117
|
-
while (1) switch (
|
|
5942
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context37) {
|
|
5943
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
5118
5944
|
case 0:
|
|
5119
5945
|
tempOrder = this.ensureTempOrder();
|
|
5120
5946
|
this.ensureExternalSaleNumber(tempOrder);
|
|
5121
5947
|
this.persistTempOrder();
|
|
5122
|
-
|
|
5948
|
+
_context37.next = 5;
|
|
5123
5949
|
return this.recalculateSummary({
|
|
5124
5950
|
createIfMissing: true
|
|
5125
5951
|
});
|
|
5126
5952
|
case 5:
|
|
5127
|
-
|
|
5128
|
-
if (
|
|
5129
|
-
|
|
5953
|
+
_context37.t1 = _context37.sent;
|
|
5954
|
+
if (_context37.t1) {
|
|
5955
|
+
_context37.next = 8;
|
|
5130
5956
|
break;
|
|
5131
5957
|
}
|
|
5132
|
-
|
|
5958
|
+
_context37.t1 = this.store.summary;
|
|
5133
5959
|
case 8:
|
|
5134
|
-
|
|
5135
|
-
if (
|
|
5136
|
-
|
|
5960
|
+
_context37.t0 = _context37.t1;
|
|
5961
|
+
if (_context37.t0) {
|
|
5962
|
+
_context37.next = 11;
|
|
5137
5963
|
break;
|
|
5138
5964
|
}
|
|
5139
|
-
|
|
5965
|
+
_context37.t0 = createEmptySummary();
|
|
5140
5966
|
case 11:
|
|
5141
|
-
latestSummary =
|
|
5967
|
+
latestSummary = _context37.t0;
|
|
5142
5968
|
payload = buildSubmitPayload({
|
|
5143
5969
|
tempOrder: tempOrder,
|
|
5144
5970
|
cacheId: (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId,
|
|
5145
|
-
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$
|
|
5146
|
-
businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$
|
|
5971
|
+
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.platform),
|
|
5972
|
+
businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.businessCode) || ((_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.business_code) || tempOrder.business_code,
|
|
5147
5973
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
5148
|
-
type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$
|
|
5974
|
+
type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.type,
|
|
5149
5975
|
summary: latestSummary,
|
|
5150
5976
|
enhance: params === null || params === void 0 ? void 0 : params.enhancePayload
|
|
5151
5977
|
});
|
|
@@ -5159,17 +5985,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5159
5985
|
externalSaleNumber: payload.external_sale_number,
|
|
5160
5986
|
productsCount: ((_payload$products = payload.products) === null || _payload$products === void 0 ? void 0 : _payload$products.length) || 0
|
|
5161
5987
|
});
|
|
5162
|
-
return
|
|
5988
|
+
return _context37.abrupt("return", this.request.post('/order/sales/draft', payload, {
|
|
5163
5989
|
osServer: true,
|
|
5164
5990
|
customToast: function customToast() {}
|
|
5165
5991
|
}));
|
|
5166
5992
|
case 18:
|
|
5167
5993
|
case "end":
|
|
5168
|
-
return
|
|
5994
|
+
return _context37.stop();
|
|
5169
5995
|
}
|
|
5170
|
-
},
|
|
5996
|
+
}, _callee34, this);
|
|
5171
5997
|
}));
|
|
5172
|
-
function saveTempOrderAsDraft(
|
|
5998
|
+
function saveTempOrderAsDraft(_x38) {
|
|
5173
5999
|
return _saveTempOrderAsDraft.apply(this, arguments);
|
|
5174
6000
|
}
|
|
5175
6001
|
return saveTempOrderAsDraft;
|
|
@@ -5183,18 +6009,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5183
6009
|
}, {
|
|
5184
6010
|
key: "submitTempOrder",
|
|
5185
6011
|
value: (function () {
|
|
5186
|
-
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5187
|
-
return _regeneratorRuntime().wrap(function
|
|
5188
|
-
while (1) switch (
|
|
6012
|
+
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
|
|
6013
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context38) {
|
|
6014
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
5189
6015
|
case 0:
|
|
5190
|
-
return
|
|
6016
|
+
return _context38.abrupt("return", this.runSubmitTempOrder(params));
|
|
5191
6017
|
case 1:
|
|
5192
6018
|
case "end":
|
|
5193
|
-
return
|
|
6019
|
+
return _context38.stop();
|
|
5194
6020
|
}
|
|
5195
|
-
},
|
|
6021
|
+
}, _callee35, this);
|
|
5196
6022
|
}));
|
|
5197
|
-
function submitTempOrder(
|
|
6023
|
+
function submitTempOrder(_x39) {
|
|
5198
6024
|
return _submitTempOrder.apply(this, arguments);
|
|
5199
6025
|
}
|
|
5200
6026
|
return submitTempOrder;
|
|
@@ -5202,20 +6028,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5202
6028
|
}, {
|
|
5203
6029
|
key: "submitTempOrderAsync",
|
|
5204
6030
|
value: function () {
|
|
5205
|
-
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5206
|
-
return _regeneratorRuntime().wrap(function
|
|
5207
|
-
while (1) switch (
|
|
6031
|
+
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
|
|
6032
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context39) {
|
|
6033
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
5208
6034
|
case 0:
|
|
5209
|
-
return
|
|
6035
|
+
return _context39.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
5210
6036
|
syncMode: true
|
|
5211
6037
|
})));
|
|
5212
6038
|
case 1:
|
|
5213
6039
|
case "end":
|
|
5214
|
-
return
|
|
6040
|
+
return _context39.stop();
|
|
5215
6041
|
}
|
|
5216
|
-
},
|
|
6042
|
+
}, _callee36, this);
|
|
5217
6043
|
}));
|
|
5218
|
-
function submitTempOrderAsync(
|
|
6044
|
+
function submitTempOrderAsync(_x40) {
|
|
5219
6045
|
return _submitTempOrderAsync.apply(this, arguments);
|
|
5220
6046
|
}
|
|
5221
6047
|
return submitTempOrderAsync;
|
|
@@ -5223,16 +6049,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5223
6049
|
}, {
|
|
5224
6050
|
key: "runSubmitTempOrder",
|
|
5225
6051
|
value: function () {
|
|
5226
|
-
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5227
|
-
var _params$cacheId3, _this$
|
|
5228
|
-
var tempOrder, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
|
|
5229
|
-
return _regeneratorRuntime().wrap(function
|
|
5230
|
-
while (1) switch (
|
|
6052
|
+
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
|
|
6053
|
+
var _params$cacheId3, _this$otherParams12, _ref77, _ref78, _submitSnapshot$busin, _this$otherParams13, _this$otherParams14, _submitSnapshot$type;
|
|
6054
|
+
var tempOrder, isOnlineStorePlatform, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, shouldOverridePaymentStatus, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, isLocalPendingSubmit, salesNotesState, submittedOrderId, resultRecord;
|
|
6055
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context40) {
|
|
6056
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
5231
6057
|
case 0:
|
|
5232
6058
|
tempOrder = this.ensureTempOrder();
|
|
6059
|
+
this.prepareVirtualSettlementTempOrder(tempOrder);
|
|
6060
|
+
isOnlineStorePlatform = this.isOnlineStorePlatform();
|
|
5233
6061
|
shouldConfirmPendingVoucherPayments = (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== false;
|
|
5234
6062
|
hasPaymentOverride = (params === null || params === void 0 ? void 0 : params.payments) !== undefined;
|
|
5235
|
-
|
|
6063
|
+
if (hasPaymentOverride) {
|
|
6064
|
+
preparedPaymentOverride = isOnlineStorePlatform ? (params === null || params === void 0 ? void 0 : params.payments) || [] : this.prepareVoucherPaymentsForSubmit((params === null || params === void 0 ? void 0 : params.payments) || [], shouldConfirmPendingVoucherPayments);
|
|
6065
|
+
}
|
|
5236
6066
|
if (!hasPaymentOverride) {
|
|
5237
6067
|
if (shouldConfirmPendingVoucherPayments) {
|
|
5238
6068
|
this.confirmPendingVoucherPayments({
|
|
@@ -5247,33 +6077,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5247
6077
|
}
|
|
5248
6078
|
}
|
|
5249
6079
|
this.persistTempOrder();
|
|
5250
|
-
|
|
6080
|
+
_context40.next = 10;
|
|
5251
6081
|
return this.recalculateSummary({
|
|
5252
6082
|
createIfMissing: true
|
|
5253
6083
|
});
|
|
5254
|
-
case
|
|
5255
|
-
|
|
5256
|
-
if (
|
|
5257
|
-
|
|
6084
|
+
case 10:
|
|
6085
|
+
_context40.t1 = _context40.sent;
|
|
6086
|
+
if (_context40.t1) {
|
|
6087
|
+
_context40.next = 13;
|
|
5258
6088
|
break;
|
|
5259
6089
|
}
|
|
5260
|
-
|
|
5261
|
-
case
|
|
5262
|
-
|
|
5263
|
-
if (
|
|
5264
|
-
|
|
6090
|
+
_context40.t1 = this.store.summary;
|
|
6091
|
+
case 13:
|
|
6092
|
+
_context40.t0 = _context40.t1;
|
|
6093
|
+
if (_context40.t0) {
|
|
6094
|
+
_context40.next = 16;
|
|
5265
6095
|
break;
|
|
5266
6096
|
}
|
|
5267
|
-
|
|
5268
|
-
case
|
|
5269
|
-
latestSummary =
|
|
6097
|
+
_context40.t0 = createEmptySummary();
|
|
6098
|
+
case 16:
|
|
6099
|
+
latestSummary = _context40.t0;
|
|
5270
6100
|
effectiveCacheId = (_params$cacheId3 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId3 !== void 0 ? _params$cacheId3 : this.cacheId;
|
|
5271
6101
|
hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
|
|
6102
|
+
shouldOverridePaymentStatus = hasPaymentStatusOverride && !isOnlineStorePlatform && !shouldConfirmPendingVoucherPayments;
|
|
5272
6103
|
hasSmallTicketDataFlagOverride = (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined;
|
|
5273
6104
|
enhancePayload = hasPaymentOverride || hasPaymentStatusOverride || hasSmallTicketDataFlagOverride || params !== null && params !== void 0 && params.enhancePayload ? function (payload, ctx) {
|
|
5274
6105
|
var nextPayload = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, payload), hasPaymentOverride ? {
|
|
5275
6106
|
payments: preparedPaymentOverride || []
|
|
5276
|
-
} : {}),
|
|
6107
|
+
} : {}), shouldOverridePaymentStatus ? {
|
|
5277
6108
|
payment_status: params === null || params === void 0 ? void 0 : params.paymentStatus
|
|
5278
6109
|
} : {}), hasSmallTicketDataFlagOverride ? {
|
|
5279
6110
|
small_ticket_data_flag: params === null || params === void 0 ? void 0 : params.smallTicketDataFlag
|
|
@@ -5285,12 +6116,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5285
6116
|
payload = buildSubmitPayload({
|
|
5286
6117
|
tempOrder: tempOrder,
|
|
5287
6118
|
cacheId: effectiveCacheId,
|
|
5288
|
-
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$
|
|
5289
|
-
businessCode: (
|
|
6119
|
+
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.platform),
|
|
6120
|
+
businessCode: (_ref77 = (_ref78 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref78 !== void 0 ? _ref78 : (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.businessCode) !== null && _ref77 !== void 0 ? _ref77 : (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.business_code,
|
|
5290
6121
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
5291
6122
|
type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
|
|
5292
6123
|
summary: latestSummary,
|
|
5293
6124
|
request_unique_idempotency_token: params === null || params === void 0 ? void 0 : params.request_unique_idempotency_token,
|
|
6125
|
+
includePaymentStatus: !isOnlineStorePlatform,
|
|
5294
6126
|
enhance: enhancePayload
|
|
5295
6127
|
});
|
|
5296
6128
|
if (params !== null && params !== void 0 && params.syncMode) {
|
|
@@ -5300,10 +6132,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5300
6132
|
if (!payload.created_at) {
|
|
5301
6133
|
payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
5302
6134
|
}
|
|
5303
|
-
|
|
6135
|
+
_context40.next = 28;
|
|
5304
6136
|
return this.saveDraft();
|
|
5305
|
-
case
|
|
5306
|
-
|
|
6137
|
+
case 28:
|
|
6138
|
+
_context40.prev = 28;
|
|
5307
6139
|
this.logInfo('submitTempOrder calling sales checkout', {
|
|
5308
6140
|
orderId: payload.order_id,
|
|
5309
6141
|
externalSaleNumber: payload.external_sale_number,
|
|
@@ -5313,44 +6145,49 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5313
6145
|
smallTicketDataFlag: payload.small_ticket_data_flag,
|
|
5314
6146
|
syncMode: payload.sync_mode
|
|
5315
6147
|
});
|
|
5316
|
-
|
|
6148
|
+
_context40.next = 32;
|
|
5317
6149
|
return this.submitSalesOrder({
|
|
5318
6150
|
query: payload
|
|
5319
6151
|
});
|
|
5320
|
-
case 29:
|
|
5321
|
-
result = _context35.sent;
|
|
5322
|
-
_context35.next = 42;
|
|
5323
|
-
break;
|
|
5324
6152
|
case 32:
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
6153
|
+
result = _context40.sent;
|
|
6154
|
+
_context40.next = 45;
|
|
6155
|
+
break;
|
|
6156
|
+
case 35:
|
|
6157
|
+
_context40.prev = 35;
|
|
6158
|
+
_context40.t2 = _context40["catch"](28);
|
|
6159
|
+
backendErrorResponse = this.extractSubmitErrorResponse(_context40.t2);
|
|
5328
6160
|
if (!backendErrorResponse) {
|
|
5329
|
-
|
|
6161
|
+
_context40.next = 42;
|
|
5330
6162
|
break;
|
|
5331
6163
|
}
|
|
5332
6164
|
this.store.syncState = 'failed';
|
|
5333
6165
|
this.logSubmitBackendRejected(backendErrorResponse, payload);
|
|
5334
|
-
return
|
|
5335
|
-
case
|
|
6166
|
+
return _context40.abrupt("return", backendErrorResponse);
|
|
6167
|
+
case 42:
|
|
5336
6168
|
this.store.syncState = 'failed';
|
|
5337
6169
|
this.logError('submitTempOrder failed', {
|
|
5338
|
-
error:
|
|
6170
|
+
error: _context40.t2 instanceof Error ? _context40.t2.message : String(_context40.t2),
|
|
5339
6171
|
orderId: payload.order_id,
|
|
5340
6172
|
externalSaleNumber: payload.external_sale_number,
|
|
5341
6173
|
paymentStatus: payload.payment_status,
|
|
5342
6174
|
paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
|
|
5343
6175
|
});
|
|
5344
|
-
throw
|
|
5345
|
-
case
|
|
6176
|
+
throw _context40.t2;
|
|
6177
|
+
case 45:
|
|
5346
6178
|
if (!this.isSubmitResponseRejected(result)) {
|
|
5347
|
-
|
|
6179
|
+
_context40.next = 49;
|
|
5348
6180
|
break;
|
|
5349
6181
|
}
|
|
5350
6182
|
this.store.syncState = 'failed';
|
|
5351
6183
|
this.logSubmitBackendRejected(result, payload);
|
|
5352
|
-
return
|
|
5353
|
-
case
|
|
6184
|
+
return _context40.abrupt("return", result);
|
|
6185
|
+
case 49:
|
|
6186
|
+
isLocalPendingSubmit = this.isLocalPendingSubmitResult(result); // need_sync=1 仅表示已进入本地同步队列,不能视为远端已确认 Notes。
|
|
6187
|
+
if (Object.prototype.hasOwnProperty.call(payload, 'notes') && !isLocalPendingSubmit) {
|
|
6188
|
+
salesNotesState = this.ensureSalesNotesRuntimeState(tempOrder);
|
|
6189
|
+
salesNotesState.dirty = false;
|
|
6190
|
+
}
|
|
5354
6191
|
submittedOrderId = this.extractOrderIdFromSubmitResult(result);
|
|
5355
6192
|
this.logInfo('runSubmitTempOrder: 提交成功', {
|
|
5356
6193
|
submittedOrderId: submittedOrderId,
|
|
@@ -5360,31 +6197,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5360
6197
|
})
|
|
5361
6198
|
});
|
|
5362
6199
|
if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
|
|
5363
|
-
|
|
6200
|
+
_context40.next = 58;
|
|
5364
6201
|
break;
|
|
5365
6202
|
}
|
|
5366
6203
|
tempOrder.order_id = submittedOrderId;
|
|
5367
6204
|
resultRecord = result;
|
|
5368
|
-
|
|
6205
|
+
_context40.next = 58;
|
|
5369
6206
|
return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
|
|
5370
|
-
case
|
|
5371
|
-
|
|
5372
|
-
break;
|
|
5373
|
-
case 55:
|
|
5374
|
-
if (this.isLocalPendingSubmitResult(result)) {
|
|
6207
|
+
case 58:
|
|
6208
|
+
if (isLocalPendingSubmit) {
|
|
5375
6209
|
this.store.syncState = 'local';
|
|
5376
|
-
} else {
|
|
6210
|
+
} else if (submittedOrderId === null || submittedOrderId === undefined) {
|
|
5377
6211
|
this.store.syncState = 'submitted';
|
|
5378
6212
|
}
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
case 57:
|
|
6213
|
+
return _context40.abrupt("return", result);
|
|
6214
|
+
case 60:
|
|
5382
6215
|
case "end":
|
|
5383
|
-
return
|
|
6216
|
+
return _context40.stop();
|
|
5384
6217
|
}
|
|
5385
|
-
},
|
|
6218
|
+
}, _callee37, this, [[28, 35]]);
|
|
5386
6219
|
}));
|
|
5387
|
-
function runSubmitTempOrder(
|
|
6220
|
+
function runSubmitTempOrder(_x41) {
|
|
5388
6221
|
return _runSubmitTempOrder.apply(this, arguments);
|
|
5389
6222
|
}
|
|
5390
6223
|
return runSubmitTempOrder;
|
|
@@ -5392,10 +6225,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5392
6225
|
}, {
|
|
5393
6226
|
key: "markLocalOrderSynced",
|
|
5394
6227
|
value: function () {
|
|
5395
|
-
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6228
|
+
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(orderId, remoteOrder) {
|
|
5396
6229
|
var tempOrder;
|
|
5397
|
-
return _regeneratorRuntime().wrap(function
|
|
5398
|
-
while (1) switch (
|
|
6230
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context41) {
|
|
6231
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
5399
6232
|
case 0:
|
|
5400
6233
|
tempOrder = this.ensureTempOrder();
|
|
5401
6234
|
tempOrder.order_id = orderId;
|
|
@@ -5403,15 +6236,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5403
6236
|
this.store.lastOrderInfo = remoteOrder;
|
|
5404
6237
|
this.store.syncState = 'submitted';
|
|
5405
6238
|
this.persistTempOrder();
|
|
5406
|
-
|
|
6239
|
+
_context41.next = 8;
|
|
5407
6240
|
return this.saveDraft();
|
|
5408
6241
|
case 8:
|
|
5409
6242
|
case "end":
|
|
5410
|
-
return
|
|
6243
|
+
return _context41.stop();
|
|
5411
6244
|
}
|
|
5412
|
-
},
|
|
6245
|
+
}, _callee38, this);
|
|
5413
6246
|
}));
|
|
5414
|
-
function markLocalOrderSynced(
|
|
6247
|
+
function markLocalOrderSynced(_x42, _x43) {
|
|
5415
6248
|
return _markLocalOrderSynced.apply(this, arguments);
|
|
5416
6249
|
}
|
|
5417
6250
|
return markLocalOrderSynced;
|
|
@@ -5454,10 +6287,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5454
6287
|
value: function extractSubmitErrorResponse(error) {
|
|
5455
6288
|
var _error$response,
|
|
5456
6289
|
_error$response2,
|
|
5457
|
-
|
|
6290
|
+
_this34 = this;
|
|
5458
6291
|
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];
|
|
5459
6292
|
return candidates.find(function (candidate) {
|
|
5460
|
-
return
|
|
6293
|
+
return _this34.isSubmitErrorResponse(candidate);
|
|
5461
6294
|
}) || null;
|
|
5462
6295
|
}
|
|
5463
6296
|
}, {
|
|
@@ -5484,33 +6317,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5484
6317
|
}, {
|
|
5485
6318
|
key: "syncPaymentsToOrder",
|
|
5486
6319
|
value: function () {
|
|
5487
|
-
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5488
|
-
var
|
|
6320
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
|
|
6321
|
+
var _this35 = this,
|
|
5489
6322
|
_params$confirmPendin;
|
|
5490
6323
|
var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, enhancePayload, submitParams, submitResult;
|
|
5491
|
-
return _regeneratorRuntime().wrap(function
|
|
5492
|
-
while (1) switch (
|
|
6324
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context42) {
|
|
6325
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
5493
6326
|
case 0:
|
|
5494
6327
|
tempOrder = this.ensureTempOrder();
|
|
5495
6328
|
needsPaymentNumber = (params.payments || []).some(function (payment) {
|
|
5496
6329
|
return String(payment.payment_number || '').trim() === '';
|
|
5497
6330
|
});
|
|
5498
6331
|
if (!needsPaymentNumber) {
|
|
5499
|
-
|
|
6332
|
+
_context42.next = 8;
|
|
5500
6333
|
break;
|
|
5501
6334
|
}
|
|
5502
|
-
|
|
6335
|
+
_context42.next = 5;
|
|
5503
6336
|
return this.getPaymentNumberDevicePrefixAsync();
|
|
5504
6337
|
case 5:
|
|
5505
|
-
|
|
5506
|
-
|
|
6338
|
+
_context42.t0 = _context42.sent;
|
|
6339
|
+
_context42.next = 9;
|
|
5507
6340
|
break;
|
|
5508
6341
|
case 8:
|
|
5509
|
-
|
|
6342
|
+
_context42.t0 = 'LOCAL';
|
|
5510
6343
|
case 9:
|
|
5511
|
-
devicePrefix =
|
|
6344
|
+
devicePrefix = _context42.t0;
|
|
5512
6345
|
mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
|
|
5513
|
-
return
|
|
6346
|
+
return _this35.normalizePaymentSource(payment, {
|
|
5514
6347
|
defaultPaid: false,
|
|
5515
6348
|
devicePrefix: devicePrefix
|
|
5516
6349
|
});
|
|
@@ -5523,20 +6356,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5523
6356
|
tempOrder.payments = effectivePayments;
|
|
5524
6357
|
tempOrder.payment_status = paymentStatus;
|
|
5525
6358
|
this.persistTempOrder();
|
|
5526
|
-
|
|
6359
|
+
_context42.next = 21;
|
|
5527
6360
|
return this.saveDraft();
|
|
5528
6361
|
case 21:
|
|
5529
6362
|
if (params.submitWhenPaid) {
|
|
5530
|
-
|
|
6363
|
+
_context42.next = 23;
|
|
5531
6364
|
break;
|
|
5532
6365
|
}
|
|
5533
|
-
return
|
|
6366
|
+
return _context42.abrupt("return", completion);
|
|
5534
6367
|
case 23:
|
|
5535
6368
|
if (!(this.store.syncState === 'submitting')) {
|
|
5536
|
-
|
|
6369
|
+
_context42.next = 25;
|
|
5537
6370
|
break;
|
|
5538
6371
|
}
|
|
5539
|
-
return
|
|
6372
|
+
return _context42.abrupt("return", completion);
|
|
5540
6373
|
case 25:
|
|
5541
6374
|
this.store.syncState = 'submitting';
|
|
5542
6375
|
paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, effectivePayments);
|
|
@@ -5556,32 +6389,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5556
6389
|
enhancePayload: enhancePayload
|
|
5557
6390
|
};
|
|
5558
6391
|
if (!(params.checkoutSyncTaskEnabled === false)) {
|
|
5559
|
-
|
|
6392
|
+
_context42.next = 35;
|
|
5560
6393
|
break;
|
|
5561
6394
|
}
|
|
5562
|
-
|
|
6395
|
+
_context42.next = 32;
|
|
5563
6396
|
return this.submitTempOrderAsync(submitParams);
|
|
5564
6397
|
case 32:
|
|
5565
|
-
|
|
5566
|
-
|
|
6398
|
+
_context42.t1 = _context42.sent;
|
|
6399
|
+
_context42.next = 38;
|
|
5567
6400
|
break;
|
|
5568
6401
|
case 35:
|
|
5569
|
-
|
|
6402
|
+
_context42.next = 37;
|
|
5570
6403
|
return this.submitTempOrder(submitParams);
|
|
5571
6404
|
case 37:
|
|
5572
|
-
|
|
6405
|
+
_context42.t1 = _context42.sent;
|
|
5573
6406
|
case 38:
|
|
5574
|
-
submitResult =
|
|
5575
|
-
return
|
|
6407
|
+
submitResult = _context42.t1;
|
|
6408
|
+
return _context42.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
|
|
5576
6409
|
submitResult: submitResult
|
|
5577
6410
|
}));
|
|
5578
6411
|
case 40:
|
|
5579
6412
|
case "end":
|
|
5580
|
-
return
|
|
6413
|
+
return _context42.stop();
|
|
5581
6414
|
}
|
|
5582
|
-
},
|
|
6415
|
+
}, _callee39, this);
|
|
5583
6416
|
}));
|
|
5584
|
-
function syncPaymentsToOrder(
|
|
6417
|
+
function syncPaymentsToOrder(_x44) {
|
|
5585
6418
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
5586
6419
|
}
|
|
5587
6420
|
return syncPaymentsToOrder;
|
|
@@ -5589,7 +6422,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5589
6422
|
}, {
|
|
5590
6423
|
key: "createOrder",
|
|
5591
6424
|
value: function createOrder(params) {
|
|
5592
|
-
var
|
|
6425
|
+
var _this36 = this;
|
|
5593
6426
|
var order = _objectSpread({
|
|
5594
6427
|
type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
|
|
5595
6428
|
// 要从外面拿,virtual
|
|
@@ -5621,7 +6454,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5621
6454
|
|
|
5622
6455
|
// 为预约补齐 holder 信息
|
|
5623
6456
|
if (params !== null && params !== void 0 && (_params$extraData = params.extraData) !== null && _params$extraData !== void 0 && _params$extraData.is_add_holder_info) {
|
|
5624
|
-
ensureCartItemOriginHolder(item,
|
|
6457
|
+
ensureCartItemOriginHolder(item, _this36.window);
|
|
5625
6458
|
}
|
|
5626
6459
|
|
|
5627
6460
|
// 购物车是否为普通商品
|
|
@@ -5678,11 +6511,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5678
6511
|
}, {
|
|
5679
6512
|
key: "submitOrder",
|
|
5680
6513
|
value: function () {
|
|
5681
|
-
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6514
|
+
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(order) {
|
|
5682
6515
|
var _order$query$cartItem, _params$bookings, _params$relation_prod;
|
|
5683
6516
|
var url, query, fetchUrl, params;
|
|
5684
|
-
return _regeneratorRuntime().wrap(function
|
|
5685
|
-
while (1) switch (
|
|
6517
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context43) {
|
|
6518
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
5686
6519
|
case 0:
|
|
5687
6520
|
this.logInfo('submitOrder called', {
|
|
5688
6521
|
url: order.url,
|
|
@@ -5702,14 +6535,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5702
6535
|
relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
|
|
5703
6536
|
scheduleDate: params.schedule_date
|
|
5704
6537
|
});
|
|
5705
|
-
return
|
|
6538
|
+
return _context43.abrupt("return", this.request.post(fetchUrl, params));
|
|
5706
6539
|
case 6:
|
|
5707
6540
|
case "end":
|
|
5708
|
-
return
|
|
6541
|
+
return _context43.stop();
|
|
5709
6542
|
}
|
|
5710
|
-
},
|
|
6543
|
+
}, _callee40, this);
|
|
5711
6544
|
}));
|
|
5712
|
-
function submitOrder(
|
|
6545
|
+
function submitOrder(_x45) {
|
|
5713
6546
|
return _submitOrder.apply(this, arguments);
|
|
5714
6547
|
}
|
|
5715
6548
|
return submitOrder;
|
|
@@ -5717,13 +6550,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5717
6550
|
}, {
|
|
5718
6551
|
key: "cancelOrder",
|
|
5719
6552
|
value: function () {
|
|
5720
|
-
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6553
|
+
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
|
|
5721
6554
|
var payload;
|
|
5722
|
-
return _regeneratorRuntime().wrap(function
|
|
5723
|
-
while (1) switch (
|
|
6555
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context44) {
|
|
6556
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
5724
6557
|
case 0:
|
|
5725
6558
|
if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
|
|
5726
|
-
|
|
6559
|
+
_context44.next = 2;
|
|
5727
6560
|
break;
|
|
5728
6561
|
}
|
|
5729
6562
|
throw new Error('取消订单失败:order_ids 不能为空');
|
|
@@ -5739,16 +6572,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5739
6572
|
method: 'PUT',
|
|
5740
6573
|
orderIdsCount: params.order_ids.length
|
|
5741
6574
|
});
|
|
5742
|
-
return
|
|
6575
|
+
return _context44.abrupt("return", this.request.put('/order/update-status', payload, {
|
|
5743
6576
|
isShopApi: true
|
|
5744
6577
|
}));
|
|
5745
6578
|
case 5:
|
|
5746
6579
|
case "end":
|
|
5747
|
-
return
|
|
6580
|
+
return _context44.stop();
|
|
5748
6581
|
}
|
|
5749
|
-
},
|
|
6582
|
+
}, _callee41, this);
|
|
5750
6583
|
}));
|
|
5751
|
-
function cancelOrder(
|
|
6584
|
+
function cancelOrder(_x46) {
|
|
5752
6585
|
return _cancelOrder.apply(this, arguments);
|
|
5753
6586
|
}
|
|
5754
6587
|
return cancelOrder;
|
|
@@ -5756,19 +6589,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5756
6589
|
}, {
|
|
5757
6590
|
key: "changeBookingStatus",
|
|
5758
6591
|
value: function () {
|
|
5759
|
-
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6592
|
+
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
|
|
5760
6593
|
var url, payload;
|
|
5761
|
-
return _regeneratorRuntime().wrap(function
|
|
5762
|
-
while (1) switch (
|
|
6594
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context45) {
|
|
6595
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
5763
6596
|
case 0:
|
|
5764
6597
|
if (params.booking_id) {
|
|
5765
|
-
|
|
6598
|
+
_context45.next = 2;
|
|
5766
6599
|
break;
|
|
5767
6600
|
}
|
|
5768
6601
|
throw new Error('变更预约状态失败:booking_id 不能为空');
|
|
5769
6602
|
case 2:
|
|
5770
6603
|
if (params.appointment_status) {
|
|
5771
|
-
|
|
6604
|
+
_context45.next = 4;
|
|
5772
6605
|
break;
|
|
5773
6606
|
}
|
|
5774
6607
|
throw new Error('变更预约状态失败:appointment_status 不能为空');
|
|
@@ -5783,16 +6616,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5783
6616
|
bookingId: params.booking_id,
|
|
5784
6617
|
appointmentStatus: params.appointment_status
|
|
5785
6618
|
});
|
|
5786
|
-
return
|
|
6619
|
+
return _context45.abrupt("return", this.request.put(url, payload, {
|
|
5787
6620
|
isShopApi: true
|
|
5788
6621
|
}));
|
|
5789
6622
|
case 8:
|
|
5790
6623
|
case "end":
|
|
5791
|
-
return
|
|
6624
|
+
return _context45.stop();
|
|
5792
6625
|
}
|
|
5793
|
-
},
|
|
6626
|
+
}, _callee42, this);
|
|
5794
6627
|
}));
|
|
5795
|
-
function changeBookingStatus(
|
|
6628
|
+
function changeBookingStatus(_x47) {
|
|
5796
6629
|
return _changeBookingStatus.apply(this, arguments);
|
|
5797
6630
|
}
|
|
5798
6631
|
return changeBookingStatus;
|
|
@@ -5810,11 +6643,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5810
6643
|
}, {
|
|
5811
6644
|
key: "createOrderByCheckout",
|
|
5812
6645
|
value: (function () {
|
|
5813
|
-
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6646
|
+
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
|
|
5814
6647
|
var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3;
|
|
5815
6648
|
var onlineStorePaymentCodeList, _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, orderData, response;
|
|
5816
|
-
return _regeneratorRuntime().wrap(function
|
|
5817
|
-
while (1) switch (
|
|
6649
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context46) {
|
|
6650
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
5818
6651
|
case 0:
|
|
5819
6652
|
// 过滤掉由在线店铺下单的 payment 支付数据
|
|
5820
6653
|
onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
|
|
@@ -5839,7 +6672,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5839
6672
|
return p.code;
|
|
5840
6673
|
})) || []
|
|
5841
6674
|
});
|
|
5842
|
-
|
|
6675
|
+
_context46.prev = 3;
|
|
5843
6676
|
// 构建订单数据,设置默认值并允许 params 覆盖
|
|
5844
6677
|
orderData = _objectSpread({
|
|
5845
6678
|
sales_channel: 'my_pisel',
|
|
@@ -5887,32 +6720,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5887
6720
|
hasOrderId: !!orderData.order_id,
|
|
5888
6721
|
smallTicketDataFlag: orderData.small_ticket_data_flag
|
|
5889
6722
|
});
|
|
5890
|
-
|
|
6723
|
+
_context46.next = 10;
|
|
5891
6724
|
return this.request.post('/order/checkout', orderData, {
|
|
5892
6725
|
osServer: true,
|
|
5893
6726
|
customToast: function customToast() {}
|
|
5894
6727
|
});
|
|
5895
6728
|
case 10:
|
|
5896
|
-
response =
|
|
6729
|
+
response = _context46.sent;
|
|
5897
6730
|
this.logInfo('Order API called successfully', {
|
|
5898
6731
|
response: response
|
|
5899
6732
|
});
|
|
5900
|
-
return
|
|
6733
|
+
return _context46.abrupt("return", response);
|
|
5901
6734
|
case 15:
|
|
5902
|
-
|
|
5903
|
-
|
|
5904
|
-
console.error('[Order] createOrderByCheckout 创建订单失败:',
|
|
6735
|
+
_context46.prev = 15;
|
|
6736
|
+
_context46.t0 = _context46["catch"](3);
|
|
6737
|
+
console.error('[Order] createOrderByCheckout 创建订单失败:', _context46.t0);
|
|
5905
6738
|
this.logInfo('Order API called failed', {
|
|
5906
|
-
error:
|
|
6739
|
+
error: _context46.t0 instanceof Error ? _context46.t0.message : String(_context46.t0)
|
|
5907
6740
|
});
|
|
5908
|
-
throw
|
|
6741
|
+
throw _context46.t0;
|
|
5909
6742
|
case 20:
|
|
5910
6743
|
case "end":
|
|
5911
|
-
return
|
|
6744
|
+
return _context46.stop();
|
|
5912
6745
|
}
|
|
5913
|
-
},
|
|
6746
|
+
}, _callee43, this, [[3, 15]]);
|
|
5914
6747
|
}));
|
|
5915
|
-
function createOrderByCheckout(
|
|
6748
|
+
function createOrderByCheckout(_x48) {
|
|
5916
6749
|
return _createOrderByCheckout.apply(this, arguments);
|
|
5917
6750
|
}
|
|
5918
6751
|
return createOrderByCheckout;
|
|
@@ -5920,24 +6753,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5920
6753
|
}, {
|
|
5921
6754
|
key: "submitSalesOrder",
|
|
5922
6755
|
value: function () {
|
|
5923
|
-
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6756
|
+
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(params) {
|
|
5924
6757
|
var url, query, fetchUrl;
|
|
5925
|
-
return _regeneratorRuntime().wrap(function
|
|
5926
|
-
while (1) switch (
|
|
6758
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context47) {
|
|
6759
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
5927
6760
|
case 0:
|
|
5928
6761
|
url = params.url, query = params.query;
|
|
5929
6762
|
fetchUrl = url || '/order/sales/checkout';
|
|
5930
|
-
return
|
|
6763
|
+
return _context47.abrupt("return", this.request.post(fetchUrl, query, {
|
|
5931
6764
|
osServer: true,
|
|
5932
6765
|
customToast: function customToast() {}
|
|
5933
6766
|
}));
|
|
5934
6767
|
case 3:
|
|
5935
6768
|
case "end":
|
|
5936
|
-
return
|
|
6769
|
+
return _context47.stop();
|
|
5937
6770
|
}
|
|
5938
|
-
},
|
|
6771
|
+
}, _callee44, this);
|
|
5939
6772
|
}));
|
|
5940
|
-
function submitSalesOrder(
|
|
6773
|
+
function submitSalesOrder(_x49) {
|
|
5941
6774
|
return _submitSalesOrder.apply(this, arguments);
|
|
5942
6775
|
}
|
|
5943
6776
|
return submitSalesOrder;
|
|
@@ -5951,37 +6784,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5951
6784
|
}, {
|
|
5952
6785
|
key: "sendCustomerPayLink",
|
|
5953
6786
|
value: (function () {
|
|
5954
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6787
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(params) {
|
|
5955
6788
|
var _params$emails;
|
|
5956
6789
|
var orderIds;
|
|
5957
|
-
return _regeneratorRuntime().wrap(function
|
|
5958
|
-
while (1) switch (
|
|
6790
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context48) {
|
|
6791
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
5959
6792
|
case 0:
|
|
5960
6793
|
orderIds = params.order_ids || params.orderIds || [];
|
|
5961
6794
|
if (orderIds.length) {
|
|
5962
|
-
|
|
6795
|
+
_context48.next = 3;
|
|
5963
6796
|
break;
|
|
5964
6797
|
}
|
|
5965
6798
|
throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
|
|
5966
6799
|
case 3:
|
|
5967
6800
|
if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
|
|
5968
|
-
|
|
6801
|
+
_context48.next = 5;
|
|
5969
6802
|
break;
|
|
5970
6803
|
}
|
|
5971
6804
|
throw new Error('发送支付链接需要至少一个邮箱');
|
|
5972
6805
|
case 5:
|
|
5973
|
-
return
|
|
6806
|
+
return _context48.abrupt("return", this.request.post('/order/batch-email', {
|
|
5974
6807
|
order_ids: orderIds,
|
|
5975
6808
|
notify_action: params.notify_action || 'order_payment_reminder',
|
|
5976
6809
|
emails: params.emails
|
|
5977
6810
|
}));
|
|
5978
6811
|
case 6:
|
|
5979
6812
|
case "end":
|
|
5980
|
-
return
|
|
6813
|
+
return _context48.stop();
|
|
5981
6814
|
}
|
|
5982
|
-
},
|
|
6815
|
+
}, _callee45, this);
|
|
5983
6816
|
}));
|
|
5984
|
-
function sendCustomerPayLink(
|
|
6817
|
+
function sendCustomerPayLink(_x50) {
|
|
5985
6818
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
5986
6819
|
}
|
|
5987
6820
|
return sendCustomerPayLink;
|
|
@@ -5989,14 +6822,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5989
6822
|
}, {
|
|
5990
6823
|
key: "getSalesOrderByLookup",
|
|
5991
6824
|
value: function () {
|
|
5992
|
-
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6825
|
+
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(params) {
|
|
5993
6826
|
var lookup, res;
|
|
5994
|
-
return _regeneratorRuntime().wrap(function
|
|
5995
|
-
while (1) switch (
|
|
6827
|
+
return _regeneratorRuntime().wrap(function _callee46$(_context49) {
|
|
6828
|
+
while (1) switch (_context49.prev = _context49.next) {
|
|
5996
6829
|
case 0:
|
|
5997
6830
|
lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
|
|
5998
6831
|
if (lookup) {
|
|
5999
|
-
|
|
6832
|
+
_context49.next = 3;
|
|
6000
6833
|
break;
|
|
6001
6834
|
}
|
|
6002
6835
|
throw new Error('加载销售详情需要 lookup');
|
|
@@ -6005,27 +6838,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6005
6838
|
if (lookup.startsWith('LOCAL_')) {
|
|
6006
6839
|
params.forceRemote = false;
|
|
6007
6840
|
}
|
|
6008
|
-
|
|
6841
|
+
_context49.next = 6;
|
|
6009
6842
|
return this.request.get("/order/sales/".concat(encodeURIComponent(lookup)), _objectSpread({
|
|
6010
|
-
with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info', 'refunds']
|
|
6843
|
+
with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info', 'order_meta_list', 'refunds', 'notes']
|
|
6011
6844
|
}, params.forceRemote ? {
|
|
6012
6845
|
forceRemote: true
|
|
6013
6846
|
} : {}), {
|
|
6014
6847
|
osServer: true
|
|
6015
6848
|
});
|
|
6016
6849
|
case 6:
|
|
6017
|
-
res =
|
|
6850
|
+
res = _context49.sent;
|
|
6018
6851
|
if (res.code === 200) {
|
|
6019
6852
|
this.store.lastOrderInfo = res.data;
|
|
6020
6853
|
}
|
|
6021
|
-
return
|
|
6854
|
+
return _context49.abrupt("return", res);
|
|
6022
6855
|
case 9:
|
|
6023
6856
|
case "end":
|
|
6024
|
-
return
|
|
6857
|
+
return _context49.stop();
|
|
6025
6858
|
}
|
|
6026
|
-
},
|
|
6859
|
+
}, _callee46, this);
|
|
6027
6860
|
}));
|
|
6028
|
-
function getSalesOrderByLookup(
|
|
6861
|
+
function getSalesOrderByLookup(_x51) {
|
|
6029
6862
|
return _getSalesOrderByLookup.apply(this, arguments);
|
|
6030
6863
|
}
|
|
6031
6864
|
return getSalesOrderByLookup;
|
|
@@ -6039,11 +6872,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6039
6872
|
}, {
|
|
6040
6873
|
key: "hydrateTempOrderFromRecord",
|
|
6041
6874
|
value: (function () {
|
|
6042
|
-
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6043
|
-
var _sourceRaw$_extend, _this$store$
|
|
6044
|
-
var sourceRaw, duplicateProductIdentityRepair, duplicateIdentityReadySource, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, isSessionStorageHydrate, isMergedSalesDetailHydrate, nextTempOrder, _this$store$
|
|
6045
|
-
return _regeneratorRuntime().wrap(function
|
|
6046
|
-
while (1) switch (
|
|
6875
|
+
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(record, options) {
|
|
6876
|
+
var _sourceRaw$_extend, _this$store$discount26;
|
|
6877
|
+
var sourceRaw, duplicateProductIdentityRepair, duplicateIdentityReadySource, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, isSessionStorageHydrate, isMergedSalesDetailHydrate, nextTempOrder, _this$store$discount24, _this$store$discount25, restoredSessionDiscounts, nextExtend, sourceLastOrderInfo, isDraftOrder, syntheticIdentityOptions, rawSummary, historicalDepositSnapshot, summarySurcharges, hadSyntheticDraftOrderId, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount27, _this$store$discount28;
|
|
6878
|
+
return _regeneratorRuntime().wrap(function _callee47$(_context50) {
|
|
6879
|
+
while (1) switch (_context50.prev = _context50.next) {
|
|
6047
6880
|
case 0:
|
|
6048
6881
|
sourceRaw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
|
|
6049
6882
|
duplicateProductIdentityRepair = repairDuplicateOrderProductLineIdentities(Array.isArray(sourceRaw.products) ? sourceRaw.products : [], (_sourceRaw$_extend = sourceRaw._extend) === null || _sourceRaw$_extend === void 0 ? void 0 : _sourceRaw$_extend.productsByUid);
|
|
@@ -6079,11 +6912,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6079
6912
|
isMergedSalesDetailHydrate = (options === null || options === void 0 ? void 0 : options.source) === 'mergedSalesDetail';
|
|
6080
6913
|
nextTempOrder = this.normalizeTempOrderForRuntime(raw, {
|
|
6081
6914
|
// merge 前已只给远端商品补标记;这里不能把本地未提交商品一并变成 saved item。
|
|
6082
|
-
makeEditMark: !isSessionStorageHydrate && !isMergedSalesDetailHydrate
|
|
6915
|
+
makeEditMark: !isSessionStorageHydrate && !isMergedSalesDetailHydrate,
|
|
6916
|
+
allowUnresolvedSalesNotes: isSessionStorageHydrate
|
|
6083
6917
|
});
|
|
6084
6918
|
this.store.tempOrder = nextTempOrder;
|
|
6085
6919
|
if (!isSessionStorageHydrate) {
|
|
6086
|
-
|
|
6920
|
+
_context50.next = 30;
|
|
6087
6921
|
break;
|
|
6088
6922
|
}
|
|
6089
6923
|
// 会话快照是未提交购物车,不应获得编辑订单的 saved/edit 标记与服务端基线。
|
|
@@ -6099,23 +6933,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6099
6933
|
nextTempOrder.discount_list = restoredSessionDiscounts;
|
|
6100
6934
|
this.store.summary = createEmptySummary();
|
|
6101
6935
|
this.store.lastOrderInfo = undefined;
|
|
6102
|
-
|
|
6103
|
-
return (_this$store$
|
|
6936
|
+
_context50.next = 23;
|
|
6937
|
+
return (_this$store$discount24 = this.store.discount) === null || _this$store$discount24 === void 0 ? void 0 : _this$store$discount24.setOriginalDiscountList(cloneDeep(restoredSessionDiscounts));
|
|
6104
6938
|
case 23:
|
|
6105
|
-
|
|
6106
|
-
return (_this$store$
|
|
6939
|
+
_context50.next = 25;
|
|
6940
|
+
return (_this$store$discount25 = this.store.discount) === null || _this$store$discount25 === void 0 ? void 0 : _this$store$discount25.setDiscountList(cloneDeep(restoredSessionDiscounts));
|
|
6107
6941
|
case 25:
|
|
6108
6942
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
6109
|
-
|
|
6943
|
+
_context50.next = 28;
|
|
6110
6944
|
break;
|
|
6111
6945
|
}
|
|
6112
|
-
|
|
6946
|
+
_context50.next = 28;
|
|
6113
6947
|
return this.recalculateSummary({
|
|
6114
6948
|
createIfMissing: false
|
|
6115
6949
|
});
|
|
6116
6950
|
case 28:
|
|
6117
6951
|
this.persistTempOrder();
|
|
6118
|
-
return
|
|
6952
|
+
return _context50.abrupt("return", nextTempOrder);
|
|
6119
6953
|
case 30:
|
|
6120
6954
|
// Server list compatibility may synthesize order_id from external_sale_number; tempOrder must not.
|
|
6121
6955
|
sourceLastOrderInfo = sourceRaw.lastOrderInfo || sourceRaw;
|
|
@@ -6154,7 +6988,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6154
6988
|
this.store.syncState = 'local';
|
|
6155
6989
|
}
|
|
6156
6990
|
hydratedEditDiscounts = this.collectHydratedEditDiscounts(nextTempOrder.products);
|
|
6157
|
-
currentDiscounts = typeof ((_this$store$
|
|
6991
|
+
currentDiscounts = typeof ((_this$store$discount26 = this.store.discount) === null || _this$store$discount26 === void 0 ? void 0 : _this$store$discount26.getDiscountList) === 'function' ? this.store.discount.getDiscountList() || [] : [];
|
|
6158
6992
|
currentScanDiscounts = currentDiscounts.filter(function (discount) {
|
|
6159
6993
|
return discount === null || discount === void 0 ? void 0 : discount.isScan;
|
|
6160
6994
|
});
|
|
@@ -6167,34 +7001,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6167
7001
|
nextDiscounts = [].concat(_toConsumableArray(hydratedEditDiscounts), _toConsumableArray(retainedScanDiscounts));
|
|
6168
7002
|
shouldSkipEmptyDiscountSync = nextDiscounts.length === 0 && currentDiscounts.length === 0;
|
|
6169
7003
|
if (shouldSkipEmptyDiscountSync) {
|
|
6170
|
-
|
|
7004
|
+
_context50.next = 54;
|
|
6171
7005
|
break;
|
|
6172
7006
|
}
|
|
6173
7007
|
OrderModule.populateSavedAmounts(nextTempOrder.products, nextDiscounts);
|
|
6174
|
-
|
|
6175
|
-
return (_this$store$
|
|
7008
|
+
_context50.next = 52;
|
|
7009
|
+
return (_this$store$discount27 = this.store.discount) === null || _this$store$discount27 === void 0 ? void 0 : _this$store$discount27.setOriginalDiscountList(nextDiscounts);
|
|
6176
7010
|
case 52:
|
|
6177
|
-
|
|
6178
|
-
return (_this$store$
|
|
7011
|
+
_context50.next = 54;
|
|
7012
|
+
return (_this$store$discount28 = this.store.discount) === null || _this$store$discount28 === void 0 ? void 0 : _this$store$discount28.setDiscountList(nextDiscounts);
|
|
6179
7013
|
case 54:
|
|
6180
7014
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
6181
|
-
|
|
7015
|
+
_context50.next = 57;
|
|
6182
7016
|
break;
|
|
6183
7017
|
}
|
|
6184
|
-
|
|
7018
|
+
_context50.next = 57;
|
|
6185
7019
|
return this.recalculateSummary({
|
|
6186
7020
|
createIfMissing: false
|
|
6187
7021
|
});
|
|
6188
7022
|
case 57:
|
|
6189
7023
|
this.persistTempOrder();
|
|
6190
|
-
return
|
|
7024
|
+
return _context50.abrupt("return", nextTempOrder);
|
|
6191
7025
|
case 59:
|
|
6192
7026
|
case "end":
|
|
6193
|
-
return
|
|
7027
|
+
return _context50.stop();
|
|
6194
7028
|
}
|
|
6195
|
-
},
|
|
7029
|
+
}, _callee47, this);
|
|
6196
7030
|
}));
|
|
6197
|
-
function hydrateTempOrderFromRecord(
|
|
7031
|
+
function hydrateTempOrderFromRecord(_x52, _x53) {
|
|
6198
7032
|
return _hydrateTempOrderFromRecord.apply(this, arguments);
|
|
6199
7033
|
}
|
|
6200
7034
|
return hydrateTempOrderFromRecord;
|
|
@@ -6247,10 +7081,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6247
7081
|
_step22;
|
|
6248
7082
|
try {
|
|
6249
7083
|
for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
|
|
6250
|
-
var _product$
|
|
7084
|
+
var _product$metadata11;
|
|
6251
7085
|
var product = _step22.value;
|
|
6252
7086
|
var productUid = getOrderCollectionUid('product', product);
|
|
6253
|
-
var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$
|
|
7087
|
+
var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata11 = product.metadata) === null || _product$metadata11 === void 0 ? void 0 : _product$metadata11.booking_uid);
|
|
6254
7088
|
if (!productUid || bookingUid === undefined || bookingUid === null || bookingUid === '') {
|
|
6255
7089
|
continue;
|
|
6256
7090
|
}
|
|
@@ -6269,12 +7103,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6269
7103
|
_step23;
|
|
6270
7104
|
try {
|
|
6271
7105
|
for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {
|
|
6272
|
-
var _booking$
|
|
7106
|
+
var _booking$metadata9;
|
|
6273
7107
|
var booking = _step23.value;
|
|
6274
7108
|
if (getOrderCollectionPersistentId('booking', booking) || getOrderCollectionUid('booking', booking)) {
|
|
6275
7109
|
continue;
|
|
6276
7110
|
}
|
|
6277
|
-
var _productUid = (booking === null || booking === void 0 ? void 0 : booking.product_uid) || (booking === null || booking === void 0 || (_booking$
|
|
7111
|
+
var _productUid = (booking === null || booking === void 0 ? void 0 : booking.product_uid) || (booking === null || booking === void 0 || (_booking$metadata9 = booking.metadata) === null || _booking$metadata9 === void 0 ? void 0 : _booking$metadata9.product_uid);
|
|
6278
7112
|
if (_productUid === undefined || _productUid === null || _productUid === '') continue;
|
|
6279
7113
|
var key = String(_productUid);
|
|
6280
7114
|
anonymousBookingCountByProductUid.set(key, (anonymousBookingCountByProductUid.get(key) || 0) + 1);
|
|
@@ -6286,11 +7120,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6286
7120
|
}
|
|
6287
7121
|
return _objectSpread(_objectSpread({}, raw), {}, {
|
|
6288
7122
|
bookings: raw.bookings.map(function (booking) {
|
|
6289
|
-
var _booking$
|
|
7123
|
+
var _booking$metadata8;
|
|
6290
7124
|
if (getOrderCollectionPersistentId('booking', booking) || getOrderCollectionUid('booking', booking)) {
|
|
6291
7125
|
return booking;
|
|
6292
7126
|
}
|
|
6293
|
-
var productUid = (booking === null || booking === void 0 ? void 0 : booking.product_uid) || (booking === null || booking === void 0 || (_booking$
|
|
7127
|
+
var productUid = (booking === null || booking === void 0 ? void 0 : booking.product_uid) || (booking === null || booking === void 0 || (_booking$metadata8 = booking.metadata) === null || _booking$metadata8 === void 0 ? void 0 : _booking$metadata8.product_uid);
|
|
6294
7128
|
if (productUid === undefined || productUid === null || productUid === '') {
|
|
6295
7129
|
return booking;
|
|
6296
7130
|
}
|
|
@@ -6308,7 +7142,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6308
7142
|
}, {
|
|
6309
7143
|
key: "normalizeTempOrderForRuntime",
|
|
6310
7144
|
value: function normalizeTempOrderForRuntime(raw, options) {
|
|
6311
|
-
var
|
|
7145
|
+
var _this37 = this,
|
|
7146
|
+
_raw$_extend;
|
|
6312
7147
|
var runtimeRaw = this.withoutSyntheticDraftOrderIdForRuntime(raw);
|
|
6313
7148
|
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
|
|
6314
7149
|
// ES 列表详情使用 id 表示订单主键;OS 详情态统一依赖 order_id 驱动操作按钮。
|
|
@@ -6332,12 +7167,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6332
7167
|
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
6333
7168
|
var rawProducts = Array.isArray(raw.products) ? raw.products : [];
|
|
6334
7169
|
nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
|
|
6335
|
-
return
|
|
7170
|
+
return _this37.normalizeHydratedOrderProduct(p, {
|
|
6336
7171
|
makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
|
|
6337
7172
|
});
|
|
6338
7173
|
}) : [];
|
|
6339
7174
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
6340
|
-
var booking =
|
|
7175
|
+
var booking = _this37.normalizeHydratedBookingHolder(b || {});
|
|
6341
7176
|
return _objectSpread(_objectSpread({}, booking), {}, {
|
|
6342
7177
|
is_all: normalizeBookingIsAll(booking),
|
|
6343
7178
|
sub_type: normalizeBookingSubType(booking)
|
|
@@ -6346,6 +7181,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6346
7181
|
nextTempOrder.payments = Array.isArray(raw.payments) ? raw.payments.map(function (p) {
|
|
6347
7182
|
return _objectSpread({}, p || {});
|
|
6348
7183
|
}) : [];
|
|
7184
|
+
var rawHasSalesNotes = Object.prototype.hasOwnProperty.call(raw, 'notes');
|
|
7185
|
+
var restoredSalesNotesState = (_raw$_extend = raw._extend) === null || _raw$_extend === void 0 ? void 0 : _raw$_extend.salesNotesState;
|
|
7186
|
+
var allowUnresolvedSalesNotes = (options === null || options === void 0 ? void 0 : options.allowUnresolvedSalesNotes) === true || (restoredSalesNotesState === null || restoredSalesNotesState === void 0 ? void 0 : restoredSalesNotesState.dirty) === true || Number(raw.is_draft_order || 0) === 1;
|
|
7187
|
+
var decodedSalesNotes = rawHasSalesNotes ? decodeSalesNotesSnapshot(raw.notes, {
|
|
7188
|
+
allowUnresolvedOrderTarget: allowUnresolvedSalesNotes
|
|
7189
|
+
}) : {
|
|
7190
|
+
notes: [],
|
|
7191
|
+
complete: false
|
|
7192
|
+
};
|
|
7193
|
+
var hasUnresolvedSalesNoteOrderTarget = decodedSalesNotes.notes.some(function (note) {
|
|
7194
|
+
return note.note_relations.some(function (relation) {
|
|
7195
|
+
return relation.is_primary === 0 && relation.relation_type === 'related_to' && relation.target_type === 'order' && relation.target_uuid === '';
|
|
7196
|
+
});
|
|
7197
|
+
});
|
|
7198
|
+
nextTempOrder.notes = decodedSalesNotes.notes;
|
|
6349
7199
|
nextTempOrder.surcharges = Array.isArray(raw.surcharges) ? raw.surcharges.map(function (s) {
|
|
6350
7200
|
return _objectSpread({}, s || {});
|
|
6351
7201
|
}) : [];
|
|
@@ -6356,26 +7206,31 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6356
7206
|
return _objectSpread({}, c || {});
|
|
6357
7207
|
}) : [];
|
|
6358
7208
|
nextTempOrder.contacts_info = raw.contacts_info && _typeof(raw.contacts_info) === 'object' && !Array.isArray(raw.contacts_info) ? _objectSpread({}, raw.contacts_info) : null;
|
|
7209
|
+
nextTempOrder.order_meta_list = normalizeOrderMetaList(raw.order_meta_list);
|
|
6359
7210
|
nextTempOrder._extend = raw._extend && _typeof(raw._extend) === 'object' ? _objectSpread(_objectSpread({}, raw._extend), {}, {
|
|
6360
7211
|
productsByUid: raw._extend.productsByUid || {}
|
|
6361
7212
|
}) : {
|
|
6362
7213
|
productsByUid: {}
|
|
6363
7214
|
};
|
|
6364
7215
|
var tempOrderExtend = nextTempOrder._extend;
|
|
7216
|
+
tempOrderExtend.salesNotesState = {
|
|
7217
|
+
loaded: rawHasSalesNotes ? decodedSalesNotes.complete : (restoredSalesNotesState === null || restoredSalesNotesState === void 0 ? void 0 : restoredSalesNotesState.loaded) === true,
|
|
7218
|
+
dirty: decodedSalesNotes.complete && ((restoredSalesNotesState === null || restoredSalesNotesState === void 0 ? void 0 : restoredSalesNotesState.dirty) === true || allowUnresolvedSalesNotes && hasUnresolvedSalesNoteOrderTarget)
|
|
7219
|
+
};
|
|
6365
7220
|
var productsByUid = tempOrderExtend.productsByUid || {};
|
|
6366
7221
|
var _iterator24 = _createForOfIteratorHelper(nextTempOrder.products.entries()),
|
|
6367
7222
|
_step24;
|
|
6368
7223
|
try {
|
|
6369
7224
|
for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
|
|
6370
|
-
var _product$
|
|
7225
|
+
var _product$metadata12, _ref79, _ref80, _existed$origin, _rawProduct$metadata;
|
|
6371
7226
|
var _step24$value = _slicedToArray(_step24.value, 2),
|
|
6372
7227
|
index = _step24$value[0],
|
|
6373
7228
|
product = _step24$value[1];
|
|
6374
|
-
var uid = (_product$
|
|
7229
|
+
var uid = (_product$metadata12 = product.metadata) === null || _product$metadata12 === void 0 ? void 0 : _product$metadata12.unique_identification_number;
|
|
6375
7230
|
if (!uid) continue;
|
|
6376
7231
|
var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
|
|
6377
7232
|
var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
|
|
6378
|
-
var origin = (
|
|
7233
|
+
var origin = (_ref79 = (_ref80 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref80 !== void 0 ? _ref80 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref79 !== void 0 ? _ref79 : rawProduct;
|
|
6379
7234
|
var originSnapshot = cloneDeep(origin);
|
|
6380
7235
|
var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
|
|
6381
7236
|
if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
|
|
@@ -6426,8 +7281,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6426
7281
|
var bookingUidByProductUid = new Map();
|
|
6427
7282
|
var productByUid = new Map();
|
|
6428
7283
|
(tempOrder.products || []).forEach(function (product) {
|
|
6429
|
-
var _product$
|
|
6430
|
-
var productUid = (product === null || product === void 0 || (_product$
|
|
7284
|
+
var _product$metadata13;
|
|
7285
|
+
var productUid = (product === null || product === void 0 || (_product$metadata13 = product.metadata) === null || _product$metadata13 === void 0 ? void 0 : _product$metadata13.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
6431
7286
|
if (productUid !== undefined && productUid !== null && String(productUid) !== '') {
|
|
6432
7287
|
productByUid.set(String(productUid), product);
|
|
6433
7288
|
}
|
|
@@ -6448,8 +7303,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6448
7303
|
bookingUidByProductUid.set(String(productUid), bookingUid);
|
|
6449
7304
|
});
|
|
6450
7305
|
(tempOrder.products || []).forEach(function (product) {
|
|
6451
|
-
var _product$
|
|
6452
|
-
var productUid = (product === null || product === void 0 || (_product$
|
|
7306
|
+
var _product$metadata14;
|
|
7307
|
+
var productUid = (product === null || product === void 0 || (_product$metadata14 = product.metadata) === null || _product$metadata14 === void 0 ? void 0 : _product$metadata14.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
6453
7308
|
if (productUid === undefined || productUid === null || String(productUid) === '') return;
|
|
6454
7309
|
var bookingUid = bookingUidByProductUid.get(String(productUid));
|
|
6455
7310
|
if (!bookingUid) return;
|
|
@@ -6504,10 +7359,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6504
7359
|
}, {
|
|
6505
7360
|
key: "normalizeHydratedProductOptionItem",
|
|
6506
7361
|
value: function normalizeHydratedProductOptionItem(optionItem) {
|
|
6507
|
-
var
|
|
6508
|
-
var rawNum = (
|
|
7362
|
+
var _ref81, _optionItem$num, _ref82, _optionItem$add_price;
|
|
7363
|
+
var rawNum = (_ref81 = (_optionItem$num = optionItem === null || optionItem === void 0 ? void 0 : optionItem.num) !== null && _optionItem$num !== void 0 ? _optionItem$num : optionItem === null || optionItem === void 0 ? void 0 : optionItem.quantity) !== null && _ref81 !== void 0 ? _ref81 : 1;
|
|
6509
7364
|
var parsedNum = Number(rawNum);
|
|
6510
|
-
var rawPrice = (
|
|
7365
|
+
var rawPrice = (_ref82 = (_optionItem$add_price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _optionItem$add_price !== void 0 ? _optionItem$add_price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _ref82 !== void 0 ? _ref82 : 0;
|
|
6511
7366
|
var parsedPrice = Number(rawPrice);
|
|
6512
7367
|
var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
|
|
6513
7368
|
option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
|
|
@@ -6524,7 +7379,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6524
7379
|
}, {
|
|
6525
7380
|
key: "normalizeHydratedOrderProduct",
|
|
6526
7381
|
value: function normalizeHydratedOrderProduct(product, options) {
|
|
6527
|
-
var
|
|
7382
|
+
var _this38 = this;
|
|
6528
7383
|
var row = _objectSpread({}, product || {});
|
|
6529
7384
|
if (row.num === undefined && row.product_quantity !== undefined) {
|
|
6530
7385
|
row.num = row.product_quantity;
|
|
@@ -6532,7 +7387,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6532
7387
|
var productSku = ensureProductSku(row);
|
|
6533
7388
|
row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
|
|
6534
7389
|
option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
|
|
6535
|
-
return
|
|
7390
|
+
return _this38.normalizeHydratedProductOptionItem(optionItem || {});
|
|
6536
7391
|
}))
|
|
6537
7392
|
});
|
|
6538
7393
|
delete row["product_".concat('option', "_item")];
|
|
@@ -6545,6 +7400,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6545
7400
|
row.metadata.booking_uid = row.booking_uid;
|
|
6546
7401
|
}
|
|
6547
7402
|
row = restoreHydratedBundleDiscounts(row, normalizeOrderProductDiscountList);
|
|
7403
|
+
var rawOriginalPrice = Number(row.original_price);
|
|
7404
|
+
var rawSellingPrice = Number(row.selling_price);
|
|
7405
|
+
var hasProductDiscounts = Array.isArray(row.discount_list) && row.discount_list.length > 0;
|
|
7406
|
+
var hasBundleDiscounts = row.product_bundle.some(function (bundle) {
|
|
7407
|
+
return Array.isArray(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) && bundle.discount_list.length > 0;
|
|
7408
|
+
});
|
|
7409
|
+
var isUndiscountedV2Line = String(row.metadata.price_schema_version) === '2' && Number.isFinite(rawOriginalPrice) && Number.isFinite(rawSellingPrice) && new Decimal(rawOriginalPrice).eq(rawSellingPrice) && !hasProductDiscounts && !hasBundleDiscounts;
|
|
7410
|
+
if (isUndiscountedV2Line) {
|
|
7411
|
+
var hasPriceValue = function hasPriceValue(value) {
|
|
7412
|
+
return value !== undefined && value !== null && value !== '';
|
|
7413
|
+
};
|
|
7414
|
+
row.product_bundle = row.product_bundle.map(function (bundle) {
|
|
7415
|
+
if (!bundle || isMarkdownBundle(bundle) || hasPriceValue(bundle.original_price) || hasPriceValue(bundle.product_price) || !hasPriceValue(bundle.bundle_selling_price)) {
|
|
7416
|
+
return bundle;
|
|
7417
|
+
}
|
|
7418
|
+
return _objectSpread(_objectSpread({}, bundle), {}, {
|
|
7419
|
+
original_price: bundle.bundle_selling_price
|
|
7420
|
+
});
|
|
7421
|
+
});
|
|
7422
|
+
}
|
|
6548
7423
|
var existingIdentity = row.metadata.unique_identification_number || row.unique_identification_number;
|
|
6549
7424
|
if (!existingIdentity) {
|
|
6550
7425
|
row.metadata.unique_identification_number = createUuidV4();
|
|
@@ -6561,7 +7436,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6561
7436
|
});
|
|
6562
7437
|
if (result.metadata) delete result.metadata.price_schema_version;
|
|
6563
7438
|
var restored = restoreHydratedBundleDiscounts(result, normalizeOrderProductDiscountList);
|
|
6564
|
-
return this.sanitizeOrderProductForTempOrder(restored);
|
|
7439
|
+
return this.sanitizeOrderProductForTempOrder(this.normalizeVirtualSettlementProductIfEnabled(restored));
|
|
6565
7440
|
}
|
|
6566
7441
|
}, {
|
|
6567
7442
|
key: "getLastOrderInfo",
|
|
@@ -6572,27 +7447,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6572
7447
|
}, {
|
|
6573
7448
|
key: "getOrderInfo",
|
|
6574
7449
|
value: function () {
|
|
6575
|
-
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7450
|
+
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(order_id) {
|
|
6576
7451
|
var res;
|
|
6577
|
-
return _regeneratorRuntime().wrap(function
|
|
6578
|
-
while (1) switch (
|
|
7452
|
+
return _regeneratorRuntime().wrap(function _callee48$(_context51) {
|
|
7453
|
+
while (1) switch (_context51.prev = _context51.next) {
|
|
6579
7454
|
case 0:
|
|
6580
|
-
|
|
7455
|
+
_context51.next = 2;
|
|
6581
7456
|
return this.request.get("/order/sales/".concat(order_id), {
|
|
6582
|
-
with: ['products', 'bookings']
|
|
7457
|
+
with: ['products', 'bookings', 'notes']
|
|
6583
7458
|
}, {
|
|
6584
7459
|
osServer: true
|
|
6585
7460
|
});
|
|
6586
7461
|
case 2:
|
|
6587
|
-
res =
|
|
6588
|
-
return
|
|
7462
|
+
res = _context51.sent;
|
|
7463
|
+
return _context51.abrupt("return", res);
|
|
6589
7464
|
case 4:
|
|
6590
7465
|
case "end":
|
|
6591
|
-
return
|
|
7466
|
+
return _context51.stop();
|
|
6592
7467
|
}
|
|
6593
|
-
},
|
|
7468
|
+
}, _callee48, this);
|
|
6594
7469
|
}));
|
|
6595
|
-
function getOrderInfo(
|
|
7470
|
+
function getOrderInfo(_x54) {
|
|
6596
7471
|
return _getOrderInfo.apply(this, arguments);
|
|
6597
7472
|
}
|
|
6598
7473
|
return getOrderInfo;
|
|
@@ -6600,8 +7475,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6600
7475
|
}, {
|
|
6601
7476
|
key: "getVouchers",
|
|
6602
7477
|
value: function getVouchers() {
|
|
6603
|
-
var _this$store$
|
|
6604
|
-
return ((_this$store$
|
|
7478
|
+
var _this$store$tempOrder6;
|
|
7479
|
+
return ((_this$store$tempOrder6 = this.store.tempOrder) === null || _this$store$tempOrder6 === void 0 ? void 0 : _this$store$tempOrder6.vouchers) || [];
|
|
6605
7480
|
}
|
|
6606
7481
|
}], [{
|
|
6607
7482
|
key: "populateSavedAmounts",
|