@pisell/pisellos 2.2.272 → 2.2.274
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/core/index.d.ts +0 -2
- package/dist/core/index.js +0 -7
- package/dist/model/strategy/adapter/promotion/adapter.d.ts +0 -4
- package/dist/model/strategy/adapter/promotion/adapter.js +0 -23
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
- package/dist/model/strategy/adapter/promotion/evaluator.js +6 -279
- package/dist/model/strategy/adapter/promotion/examples.d.ts +0 -86
- package/dist/model/strategy/adapter/promotion/examples.js +0 -99
- package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/model/strategy/adapter/promotion/type.d.ts +2 -90
- package/dist/model/strategy/adapter/promotion/type.js +0 -45
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +16 -12
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +6 -3
- package/dist/modules/OpenData/index.d.ts +0 -2
- package/dist/modules/OpenData/index.js +0 -8
- package/dist/modules/Order/index.d.ts +12 -31
- package/dist/modules/Order/index.js +562 -778
- package/dist/modules/Order/types.d.ts +22 -36
- package/dist/modules/Order/types.js +11 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.js +2 -7
- package/dist/modules/Order/utils.js +6 -10
- package/dist/modules/Payment/index.d.ts +0 -2
- package/dist/modules/Payment/index.js +50 -79
- package/dist/modules/Payment/types.d.ts +27 -29
- package/dist/modules/Payment/types.js +3 -5
- package/dist/modules/Rules/index.d.ts +0 -1
- package/dist/modules/Rules/index.js +39 -55
- package/dist/modules/SalesSummary/utils.js +7 -1
- package/dist/server/index.d.ts +0 -16
- package/dist/server/index.js +1036 -1933
- package/dist/server/modules/order/index.d.ts +4 -49
- package/dist/server/modules/order/index.js +695 -1574
- package/dist/server/modules/order/types.d.ts +3 -11
- package/dist/server/modules/order/types.js +1 -1
- package/dist/solution/BaseSales/index.d.ts +25 -59
- package/dist/solution/BaseSales/index.js +490 -767
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
- package/dist/solution/BaseSales/utils/cartPromotion.js +36 -93
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +5 -21
- package/dist/solution/BookingTicket/index.js +49 -126
- package/dist/solution/BookingTicket/types.d.ts +3 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.js +6 -0
- package/dist/solution/BookingTicket/utils/cartView.js +44 -32
- package/dist/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
- package/dist/solution/BookingTicket/utils/weighingProductSku.js +45 -0
- package/dist/solution/Sales/index.d.ts +0 -1
- package/dist/solution/Sales/index.js +2 -10
- package/dist/solution/ScanOrder/index.js +20 -31
- package/dist/solution/VenueBooking/index.js +19 -30
- package/dist/types/index.d.ts +0 -1
- package/lib/core/index.d.ts +0 -2
- package/lib/core/index.js +0 -4
- package/lib/model/strategy/adapter/promotion/adapter.d.ts +0 -4
- package/lib/model/strategy/adapter/promotion/adapter.js +0 -20
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
- package/lib/model/strategy/adapter/promotion/evaluator.js +0 -235
- package/lib/model/strategy/adapter/promotion/examples.d.ts +0 -86
- package/lib/model/strategy/adapter/promotion/examples.js +0 -91
- package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/model/strategy/adapter/promotion/type.d.ts +2 -90
- package/lib/model/strategy/adapter/promotion/type.js +0 -2
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -2
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
- package/lib/modules/OpenData/index.d.ts +0 -2
- package/lib/modules/OpenData/index.js +0 -5
- package/lib/modules/Order/index.d.ts +12 -31
- package/lib/modules/Order/index.js +142 -201
- package/lib/modules/Order/types.d.ts +22 -36
- package/lib/modules/Order/utils/orderCollectionIdentity.js +0 -3
- package/lib/modules/Order/utils.js +4 -11
- package/lib/modules/Payment/index.d.ts +0 -2
- package/lib/modules/Payment/index.js +13 -34
- package/lib/modules/Payment/types.d.ts +27 -29
- package/lib/modules/Payment/types.js +3 -3
- package/lib/modules/Rules/index.d.ts +0 -1
- package/lib/modules/Rules/index.js +22 -41
- package/lib/modules/SalesSummary/utils.js +5 -1
- package/lib/server/index.d.ts +0 -16
- package/lib/server/index.js +18 -670
- package/lib/server/modules/order/index.d.ts +4 -49
- package/lib/server/modules/order/index.js +66 -657
- package/lib/server/modules/order/types.d.ts +3 -11
- package/lib/solution/BaseSales/index.d.ts +25 -59
- package/lib/solution/BaseSales/index.js +79 -246
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
- package/lib/solution/BaseSales/utils/cartPromotion.js +17 -65
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +5 -21
- package/lib/solution/BookingTicket/index.js +8 -59
- package/lib/solution/BookingTicket/types.d.ts +3 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.js +4 -0
- package/lib/solution/BookingTicket/utils/cartView.js +43 -30
- package/lib/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
- package/lib/solution/BookingTicket/utils/weighingProductSku.js +63 -0
- package/lib/solution/Sales/index.d.ts +0 -1
- package/lib/solution/Sales/index.js +3 -5
- package/lib/solution/ScanOrder/index.js +0 -8
- package/lib/solution/VenueBooking/index.js +0 -8
- package/lib/types/index.d.ts +0 -1
- package/package.json +1 -1
- package/dist/modules/Order/payment-utils.d.ts +0 -26
- package/dist/modules/Order/payment-utils.js +0 -225
- package/dist/utils/payment-number.d.ts +0 -9
- package/dist/utils/payment-number.js +0 -69
- package/lib/modules/Order/payment-utils.d.ts +0 -26
- package/lib/modules/Order/payment-utils.js +0 -224
- package/lib/utils/payment-number.d.ts +0 -9
- package/lib/utils/payment-number.js +0 -64
|
@@ -35,8 +35,6 @@ import { OrderHooks } from "./types";
|
|
|
35
35
|
import { composeLinePrice, generateDuration, getAllDiscountList, mergeRelationForms, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, isTempOrder, normalizeBookingIsAll, normalizeBookingSubType, mapPaymentItemsToOrderPayments, normalizeOrderProductDiscountList, resolveEffectivePerUnitDiscount, ensureProductSku, getProductSkuOptions, normalizeProductSkuOptions, sumOptionUnitPrice, clearTempOrderHolderAssignments, getOrderProductLineUid, indexOrderProductsByUid, calculateOrderProductsDeposit, mergeOrderProductDisplayFields, resolveIsFormSubject } from "./utils";
|
|
36
36
|
import { isNormalProduct } from "../Product/utils";
|
|
37
37
|
import dayjs from 'dayjs';
|
|
38
|
-
import { ensureOrderPaymentNumber, mergeOrderPaymentRecord, resolveOrderPaymentIdentity } from "./payment-utils";
|
|
39
|
-
import { resolvePaymentNumberDevicePrefix, resolvePaymentNumberDevicePrefixFromDeviceId } from "../../utils/payment-number";
|
|
40
38
|
import { processCartPromotion, appendPromotionTags as _appendPromotionTags, getOrderProductUid as getPromotionUid } from "../../solution/BaseSales/utils/cartPromotion";
|
|
41
39
|
import { buildProductLineFingerprint, getProductIdentityIndex, getSafeProductNum, isIdentityMatch, normalizeOrderProduct } from "../../solution/ScanOrder/utils";
|
|
42
40
|
import { syncManualProductDiscountProductNum } from "./utils/manualProductDiscount";
|
|
@@ -85,10 +83,6 @@ function isPaidPaymentRecord(payment) {
|
|
|
85
83
|
function isCommittedVoucherPaymentRecord(payment) {
|
|
86
84
|
return isVoucherPaymentRecord(payment) && (payment === null || payment === void 0 ? void 0 : payment.status) !== 'voided' && (hasSyncedOrderPaymentRecord(payment) || isPaidPaymentRecord(payment));
|
|
87
85
|
}
|
|
88
|
-
function getVoucherPaymentLifecycleKey(payment) {
|
|
89
|
-
if (!isVoucherPaymentRecord(payment)) return null;
|
|
90
|
-
return "".concat(String(payment.voucher_id), "::").concat(String(payment.status || ''));
|
|
91
|
-
}
|
|
92
86
|
export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
93
87
|
_inherits(OrderModule, _BaseModule);
|
|
94
88
|
var _super = _createSuper(OrderModule);
|
|
@@ -103,7 +97,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
103
97
|
_defineProperty(_assertThisInitialized(_this), "logger", void 0);
|
|
104
98
|
// LoggerManager 实例
|
|
105
99
|
_defineProperty(_assertThisInitialized(_this), "window", void 0);
|
|
106
|
-
_defineProperty(_assertThisInitialized(_this), "appPlugin", void 0);
|
|
107
100
|
_defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
|
|
108
101
|
_defineProperty(_assertThisInitialized(_this), "salesSummaryModuleName", void 0);
|
|
109
102
|
_defineProperty(_assertThisInitialized(_this), "rulesHooksOverride", void 0);
|
|
@@ -291,7 +284,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
291
284
|
value: function () {
|
|
292
285
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
|
|
293
286
|
var _otherParams$rules, _otherParams$order, _otherParams$hooks;
|
|
294
|
-
var app, otherParams;
|
|
287
|
+
var appPlugin, app, otherParams;
|
|
295
288
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
296
289
|
while (1) switch (_context.prev = _context.next) {
|
|
297
290
|
case 0:
|
|
@@ -307,14 +300,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
307
300
|
this.store.availableWalletIds = [];
|
|
308
301
|
}
|
|
309
302
|
this.request = this.core.getPlugin('request');
|
|
310
|
-
|
|
311
|
-
if (
|
|
303
|
+
appPlugin = this.core.getPlugin('app');
|
|
304
|
+
if (appPlugin) {
|
|
312
305
|
_context.next = 9;
|
|
313
306
|
break;
|
|
314
307
|
}
|
|
315
308
|
throw new Error('Order 模块需要 app 插件支持');
|
|
316
309
|
case 9:
|
|
317
|
-
app =
|
|
310
|
+
app = appPlugin.getApp();
|
|
318
311
|
this.logger = app.logger;
|
|
319
312
|
this.window = this.core.getPlugin('window');
|
|
320
313
|
otherParams = options.otherParams || {};
|
|
@@ -1517,44 +1510,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1517
1510
|
var depositPaidAmount = this.calculateDepositPaidAmount(tempOrder.payments || []);
|
|
1518
1511
|
return depositPaidAmount.lt(depositAmount) ? 'deposit' : 'normal';
|
|
1519
1512
|
}
|
|
1520
|
-
}, {
|
|
1521
|
-
key: "getPaymentNumberAppData",
|
|
1522
|
-
value: function getPaymentNumberAppData(key) {
|
|
1523
|
-
var _appPlugin$getData, _app$models, _app$models$getStore, _app$models$getStore$, _app$models$getStore$2;
|
|
1524
|
-
var appPlugin = this.appPlugin;
|
|
1525
|
-
if (!appPlugin) return undefined;
|
|
1526
|
-
var getData = (_appPlugin$getData = appPlugin.getData) === null || _appPlugin$getData === void 0 ? void 0 : _appPlugin$getData.call(appPlugin);
|
|
1527
|
-
if (typeof getData === 'function') return getData(key);
|
|
1528
|
-
var app = appPlugin.getApp();
|
|
1529
|
-
var coreData = app === null || app === void 0 || (_app$models = app.models) === null || _app$models === void 0 || (_app$models$getStore = _app$models.getStore) === null || _app$models$getStore === void 0 || (_app$models$getStore$ = (_app$models$getStore$2 = _app$models$getStore.call(_app$models)).getDataByModel) === null || _app$models$getStore$ === void 0 ? void 0 : _app$models$getStore$.call(_app$models$getStore$2, 'core', 'core');
|
|
1530
|
-
return coreData === null || coreData === void 0 ? void 0 : coreData[key];
|
|
1531
|
-
}
|
|
1532
|
-
}, {
|
|
1533
|
-
key: "getPaymentNumberDevicePrefixSync",
|
|
1534
|
-
value: function getPaymentNumberDevicePrefixSync() {
|
|
1535
|
-
var _this7 = this;
|
|
1536
|
-
return resolvePaymentNumberDevicePrefixFromDeviceId(function (key) {
|
|
1537
|
-
return _this7.getPaymentNumberAppData(key);
|
|
1538
|
-
});
|
|
1539
|
-
}
|
|
1540
|
-
}, {
|
|
1541
|
-
key: "getPaymentNumberDevicePrefixAsync",
|
|
1542
|
-
value: function getPaymentNumberDevicePrefixAsync() {
|
|
1543
|
-
var _this8 = this;
|
|
1544
|
-
return resolvePaymentNumberDevicePrefix(function (key) {
|
|
1545
|
-
return _this8.getPaymentNumberAppData(key);
|
|
1546
|
-
});
|
|
1547
|
-
}
|
|
1548
1513
|
}, {
|
|
1549
1514
|
key: "normalizePaymentSource",
|
|
1550
1515
|
value: function normalizePaymentSource(payment, options) {
|
|
1551
1516
|
var _ref19, _paymentRecord$origin;
|
|
1552
1517
|
var paymentRecord = payment;
|
|
1553
1518
|
var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
|
|
1554
|
-
|
|
1519
|
+
if (!metadata.unique_payment_number) {
|
|
1520
|
+
metadata.unique_payment_number = createUuidV4();
|
|
1521
|
+
}
|
|
1522
|
+
var normalized = _objectSpread(_objectSpread({}, paymentRecord), {}, {
|
|
1555
1523
|
metadata: metadata,
|
|
1556
1524
|
origin_amount: (_ref19 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref19 !== void 0 ? _ref19 : '0.00'
|
|
1557
|
-
})
|
|
1525
|
+
});
|
|
1558
1526
|
if (paymentRecord.status !== undefined) {
|
|
1559
1527
|
normalized.status = paymentRecord.status;
|
|
1560
1528
|
} else if ((options === null || options === void 0 ? void 0 : options.defaultPaid) !== false) {
|
|
@@ -1672,16 +1640,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1672
1640
|
}, {
|
|
1673
1641
|
key: "calculatePaidPaymentSummary",
|
|
1674
1642
|
value: function calculatePaidPaymentSummary(payments) {
|
|
1675
|
-
var
|
|
1643
|
+
var _this7 = this;
|
|
1676
1644
|
return (payments || []).reduce(function (summary, payment) {
|
|
1677
1645
|
var paymentRecord = payment;
|
|
1678
1646
|
if (!isPaidPaymentRecord(paymentRecord)) return summary;
|
|
1679
1647
|
return {
|
|
1680
1648
|
customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
|
|
1681
|
-
orderPaidAmount: summary.orderPaidAmount.plus(
|
|
1682
|
-
gapPaidAmount: summary.gapPaidAmount.plus(
|
|
1683
|
-
payServiceChargeAmount: summary.payServiceChargeAmount.plus(
|
|
1684
|
-
roundingAmount: summary.roundingAmount.plus(
|
|
1649
|
+
orderPaidAmount: summary.orderPaidAmount.plus(_this7.calculatePaymentOrderAmount(paymentRecord)),
|
|
1650
|
+
gapPaidAmount: summary.gapPaidAmount.plus(_this7.calculatePaymentGapAmount(paymentRecord)),
|
|
1651
|
+
payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this7.calculatePaymentServiceFee(paymentRecord)),
|
|
1652
|
+
roundingAmount: summary.roundingAmount.plus(_this7.calculatePaymentRoundingAmount(paymentRecord))
|
|
1685
1653
|
};
|
|
1686
1654
|
}, {
|
|
1687
1655
|
customerPaidAmount: new Decimal(0),
|
|
@@ -1883,15 +1851,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1883
1851
|
}, {
|
|
1884
1852
|
key: "normalizeFingerprintValue",
|
|
1885
1853
|
value: function normalizeFingerprintValue(value) {
|
|
1886
|
-
var
|
|
1854
|
+
var _this8 = this;
|
|
1887
1855
|
if (Array.isArray(value)) {
|
|
1888
1856
|
return value.map(function (item) {
|
|
1889
|
-
return
|
|
1857
|
+
return _this8.normalizeFingerprintValue(item);
|
|
1890
1858
|
});
|
|
1891
1859
|
}
|
|
1892
1860
|
if (!value || _typeof(value) !== 'object') return value !== null && value !== void 0 ? value : '';
|
|
1893
1861
|
return Object.keys(value).sort().reduce(function (result, key) {
|
|
1894
|
-
result[key] =
|
|
1862
|
+
result[key] = _this8.normalizeFingerprintValue(value[key]);
|
|
1895
1863
|
return result;
|
|
1896
1864
|
}, {});
|
|
1897
1865
|
}
|
|
@@ -1906,7 +1874,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1906
1874
|
_sku$barcode,
|
|
1907
1875
|
_ref20,
|
|
1908
1876
|
_sku$variant_id,
|
|
1909
|
-
|
|
1877
|
+
_this9 = this;
|
|
1910
1878
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
1911
1879
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
1912
1880
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
@@ -1940,7 +1908,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1940
1908
|
option_group_id: (_option$option_group_ = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_ !== void 0 ? _option$option_group_ : null,
|
|
1941
1909
|
option_group_item_id: (_ref22 = (_option$option_group_2 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_2 !== void 0 ? _option$option_group_2 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref22 !== void 0 ? _ref22 : null,
|
|
1942
1910
|
num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
|
|
1943
|
-
add_price:
|
|
1911
|
+
add_price: _this9.normalizeFingerprintMoney((_option$add_price = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price !== void 0 ? _option$add_price : option === null || option === void 0 ? void 0 : option.price)
|
|
1944
1912
|
};
|
|
1945
1913
|
})
|
|
1946
1914
|
}),
|
|
@@ -1950,8 +1918,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1950
1918
|
bundle_product_id: (_ref23 = (_ref24 = (_bundle$bundle_produc = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref24 !== void 0 ? _ref24 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref23 !== void 0 ? _ref23 : null,
|
|
1951
1919
|
bundle_variant_id: (_ref25 = (_bundle$bundle_varian = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle === null || bundle === void 0 ? void 0 : bundle.product_variant_id) !== null && _ref25 !== void 0 ? _ref25 : 0,
|
|
1952
1920
|
num: getSafeProductNum((_bundle$num = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num !== void 0 ? _bundle$num : bundle === null || bundle === void 0 ? void 0 : bundle.quantity),
|
|
1953
|
-
price:
|
|
1954
|
-
bundle_selling_price:
|
|
1921
|
+
price: _this9.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
|
|
1922
|
+
bundle_selling_price: _this9.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
|
|
1955
1923
|
price_type: (_bundle$price_type = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type !== void 0 ? _bundle$price_type : '',
|
|
1956
1924
|
price_type_ext: (_bundle$price_type_ex = bundle === null || bundle === void 0 ? void 0 : bundle.price_type_ext) !== null && _bundle$price_type_ex !== void 0 ? _bundle$price_type_ex : ''
|
|
1957
1925
|
};
|
|
@@ -1961,7 +1929,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1961
1929
|
return {
|
|
1962
1930
|
type: (_ref26 = (_discount$type2 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type2 !== void 0 ? _discount$type2 : discount === null || discount === void 0 ? void 0 : discount.tag) !== null && _ref26 !== void 0 ? _ref26 : '',
|
|
1963
1931
|
discount_id: (_ref27 = (_ref28 = (_discount$discount_id = discount === null || discount === void 0 ? void 0 : discount.discount_id) !== null && _discount$discount_id !== void 0 ? _discount$discount_id : discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== null && _ref28 !== void 0 ? _ref28 : discount === null || discount === void 0 || (_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) !== null && _ref27 !== void 0 ? _ref27 : null,
|
|
1964
|
-
amount:
|
|
1932
|
+
amount: _this9.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
1965
1933
|
};
|
|
1966
1934
|
}))
|
|
1967
1935
|
};
|
|
@@ -1969,9 +1937,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1969
1937
|
}, {
|
|
1970
1938
|
key: "buildOrderProductsFingerprint",
|
|
1971
1939
|
value: function buildOrderProductsFingerprint(products) {
|
|
1972
|
-
var
|
|
1940
|
+
var _this10 = this;
|
|
1973
1941
|
var items = (products || []).map(function (product) {
|
|
1974
|
-
return
|
|
1942
|
+
return _this10.buildProductFingerprintItem(product);
|
|
1975
1943
|
});
|
|
1976
1944
|
items.sort(function (left, right) {
|
|
1977
1945
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -1993,7 +1961,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1993
1961
|
_sku$barcode2,
|
|
1994
1962
|
_ref30,
|
|
1995
1963
|
_sku$variant_id2,
|
|
1996
|
-
|
|
1964
|
+
_this11 = this;
|
|
1997
1965
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
1998
1966
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
1999
1967
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
@@ -2024,7 +1992,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2024
1992
|
option_group_id: (_option$option_group_3 = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_3 !== void 0 ? _option$option_group_3 : null,
|
|
2025
1993
|
option_group_item_id: (_ref32 = (_option$option_group_4 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_4 !== void 0 ? _option$option_group_4 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref32 !== void 0 ? _ref32 : null,
|
|
2026
1994
|
num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
|
|
2027
|
-
add_price:
|
|
1995
|
+
add_price: _this11.normalizeFingerprintMoney((_option$add_price2 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price2 !== void 0 ? _option$add_price2 : option === null || option === void 0 ? void 0 : option.price)
|
|
2028
1996
|
};
|
|
2029
1997
|
})
|
|
2030
1998
|
}),
|
|
@@ -2038,14 +2006,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2038
2006
|
num: getSafeProductNum((_bundle$num2 = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num2 !== void 0 ? _bundle$num2 : bundle === null || bundle === void 0 ? void 0 : bundle.quantity),
|
|
2039
2007
|
price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
|
|
2040
2008
|
price_type_ext: (_bundle$price_type_ex2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type_ext) !== null && _bundle$price_type_ex2 !== void 0 ? _bundle$price_type_ex2 : '',
|
|
2041
|
-
option:
|
|
2009
|
+
option: _this11.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
|
|
2042
2010
|
var _ref38, _option$id3, _option$option_group_5, _ref39, _option$option_group_6, _option$num3, _option$add_price3;
|
|
2043
2011
|
return {
|
|
2044
2012
|
id: (_ref38 = (_option$id3 = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id3 !== void 0 ? _option$id3 : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref38 !== void 0 ? _ref38 : null,
|
|
2045
2013
|
option_group_id: (_option$option_group_5 = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_5 !== void 0 ? _option$option_group_5 : null,
|
|
2046
2014
|
option_group_item_id: (_ref39 = (_option$option_group_6 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_6 !== void 0 ? _option$option_group_6 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref39 !== void 0 ? _ref39 : null,
|
|
2047
2015
|
num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
|
|
2048
|
-
add_price:
|
|
2016
|
+
add_price: _this11.normalizeFingerprintMoney((_option$add_price3 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price3 !== void 0 ? _option$add_price3 : option === null || option === void 0 ? void 0 : option.price)
|
|
2049
2017
|
};
|
|
2050
2018
|
}))
|
|
2051
2019
|
};
|
|
@@ -2055,7 +2023,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2055
2023
|
return {
|
|
2056
2024
|
type: (_ref40 = (_discount$type4 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type4 !== void 0 ? _discount$type4 : discount === null || discount === void 0 ? void 0 : discount.tag) !== null && _ref40 !== void 0 ? _ref40 : '',
|
|
2057
2025
|
discount_id: (_ref41 = (_ref42 = (_discount$discount_id2 = discount === null || discount === void 0 ? void 0 : discount.discount_id) !== null && _discount$discount_id2 !== void 0 ? _discount$discount_id2 : discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== null && _ref42 !== void 0 ? _ref42 : discount === null || discount === void 0 || (_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) !== null && _ref41 !== void 0 ? _ref41 : null,
|
|
2058
|
-
amount:
|
|
2026
|
+
amount: _this11.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
2059
2027
|
};
|
|
2060
2028
|
}))
|
|
2061
2029
|
};
|
|
@@ -2063,9 +2031,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2063
2031
|
}, {
|
|
2064
2032
|
key: "buildOrderProductsStructuralFingerprint",
|
|
2065
2033
|
value: function buildOrderProductsStructuralFingerprint(products) {
|
|
2066
|
-
var
|
|
2034
|
+
var _this12 = this;
|
|
2067
2035
|
var items = (products || []).map(function (product) {
|
|
2068
|
-
return
|
|
2036
|
+
return _this12.buildProductStructuralFingerprintItem(product);
|
|
2069
2037
|
});
|
|
2070
2038
|
items.sort(function (left, right) {
|
|
2071
2039
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -2493,9 +2461,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2493
2461
|
}, {
|
|
2494
2462
|
key: "sanitizeTempOrderProducts",
|
|
2495
2463
|
value: function sanitizeTempOrderProducts(tempOrder) {
|
|
2496
|
-
var
|
|
2464
|
+
var _this13 = this;
|
|
2497
2465
|
tempOrder.products = (tempOrder.products || []).map(function (product) {
|
|
2498
|
-
return
|
|
2466
|
+
return _this13.sanitizeOrderProductForTempOrder(product);
|
|
2499
2467
|
});
|
|
2500
2468
|
}
|
|
2501
2469
|
}, {
|
|
@@ -2598,7 +2566,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2598
2566
|
}, {
|
|
2599
2567
|
key: "syncLinkedBookingHoldersToProducts",
|
|
2600
2568
|
value: function syncLinkedBookingHoldersToProducts(tempOrder) {
|
|
2601
|
-
var
|
|
2569
|
+
var _this14 = this;
|
|
2602
2570
|
var bookings = tempOrder.bookings || [];
|
|
2603
2571
|
var products = tempOrder.products || [];
|
|
2604
2572
|
if (!bookings.length || !products.length) return;
|
|
@@ -2623,7 +2591,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2623
2591
|
var bookingUid = product.booking_uid || ((_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.booking_uid);
|
|
2624
2592
|
var linkedBooking = (productUid !== undefined && productUid !== null && String(productUid) !== '' ? bookingByProductUid.get(String(productUid)) : undefined) || (bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '' ? bookingByBookingUid.get(String(bookingUid)) : undefined);
|
|
2625
2593
|
if (linkedBooking) {
|
|
2626
|
-
|
|
2594
|
+
_this14.setProductHolderFromBooking(product, linkedBooking);
|
|
2627
2595
|
}
|
|
2628
2596
|
});
|
|
2629
2597
|
}
|
|
@@ -2751,9 +2719,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2751
2719
|
}, {
|
|
2752
2720
|
key: "findBookingIndexByUniqueIdentificationNumber",
|
|
2753
2721
|
value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
|
|
2754
|
-
var
|
|
2722
|
+
var _this15 = this;
|
|
2755
2723
|
return (tempOrder.bookings || []).findIndex(function (booking) {
|
|
2756
|
-
return
|
|
2724
|
+
return _this15.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
|
|
2757
2725
|
});
|
|
2758
2726
|
}
|
|
2759
2727
|
}, {
|
|
@@ -2761,12 +2729,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2761
2729
|
value: function removeLinkedBookingsForProduct(tempOrder, product) {
|
|
2762
2730
|
var _product$metadata7,
|
|
2763
2731
|
_product$metadata8,
|
|
2764
|
-
|
|
2732
|
+
_this16 = this;
|
|
2765
2733
|
var productUid = (product === null || product === void 0 || (_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
2766
2734
|
var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.booking_uid);
|
|
2767
2735
|
if (!productUid && !bookingUid) return;
|
|
2768
2736
|
tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
|
|
2769
|
-
var currentBookingUid =
|
|
2737
|
+
var currentBookingUid = _this16.getBookingUniqueIdentificationNumber(booking);
|
|
2770
2738
|
if (bookingUid && currentBookingUid === String(bookingUid)) return false;
|
|
2771
2739
|
if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
|
|
2772
2740
|
return true;
|
|
@@ -3099,15 +3067,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3099
3067
|
}, {
|
|
3100
3068
|
key: "productHasCustomerBoundDiscount",
|
|
3101
3069
|
value: function productHasCustomerBoundDiscount(product) {
|
|
3102
|
-
var
|
|
3070
|
+
var _this17 = this;
|
|
3103
3071
|
if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
|
|
3104
|
-
return
|
|
3072
|
+
return _this17.isCustomerBoundDiscount(discount);
|
|
3105
3073
|
})) {
|
|
3106
3074
|
return true;
|
|
3107
3075
|
}
|
|
3108
3076
|
return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
|
|
3109
3077
|
return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
|
|
3110
|
-
return
|
|
3078
|
+
return _this17.isCustomerBoundDiscount(discount);
|
|
3111
3079
|
});
|
|
3112
3080
|
});
|
|
3113
3081
|
}
|
|
@@ -3116,18 +3084,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3116
3084
|
value: function shouldSkipDiscountCalculation(tempOrder) {
|
|
3117
3085
|
var _this$store$discount17,
|
|
3118
3086
|
_this$store$discount18,
|
|
3119
|
-
|
|
3087
|
+
_this18 = this;
|
|
3120
3088
|
if (this.hasActiveCustomerBoundDiscount) return false;
|
|
3121
3089
|
var discountList = ((_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 || (_this$store$discount18 = _this$store$discount17.getDiscountList) === null || _this$store$discount18 === void 0 ? void 0 : _this$store$discount18.call(_this$store$discount17)) || [];
|
|
3122
3090
|
if (discountList.length > 0) return false;
|
|
3123
3091
|
return !(tempOrder.products || []).some(function (product) {
|
|
3124
|
-
return
|
|
3092
|
+
return _this18.productHasCustomerBoundDiscount(product);
|
|
3125
3093
|
});
|
|
3126
3094
|
}
|
|
3127
3095
|
}, {
|
|
3128
3096
|
key: "clearCustomerBoundDiscounts",
|
|
3129
3097
|
value: function clearCustomerBoundDiscounts(tempOrder) {
|
|
3130
|
-
var
|
|
3098
|
+
var _this19 = this,
|
|
3131
3099
|
_discountModule$getDi,
|
|
3132
3100
|
_discountModule$getOr,
|
|
3133
3101
|
_discountModule$setDi,
|
|
@@ -3136,7 +3104,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3136
3104
|
var filterDiscountList = function filterDiscountList(discountList) {
|
|
3137
3105
|
if (!Array.isArray(discountList)) return [];
|
|
3138
3106
|
return discountList.filter(function (discount) {
|
|
3139
|
-
var shouldRemove =
|
|
3107
|
+
var shouldRemove = _this19.isCustomerBoundDiscount(discount);
|
|
3140
3108
|
if (shouldRemove) didRemoveCustomerBoundDiscount = true;
|
|
3141
3109
|
return !shouldRemove;
|
|
3142
3110
|
});
|
|
@@ -3163,12 +3131,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3163
3131
|
var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
|
|
3164
3132
|
var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
|
|
3165
3133
|
var nextDiscounts = currentDiscounts.filter(function (discount) {
|
|
3166
|
-
if (
|
|
3167
|
-
return !
|
|
3134
|
+
if (_this19.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
3135
|
+
return !_this19.isCustomerBoundDiscount(discount);
|
|
3168
3136
|
});
|
|
3169
3137
|
var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
|
|
3170
|
-
if (
|
|
3171
|
-
return !
|
|
3138
|
+
if (_this19.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
3139
|
+
return !_this19.isCustomerBoundDiscount(discount);
|
|
3172
3140
|
});
|
|
3173
3141
|
void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
|
|
3174
3142
|
void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
|
|
@@ -3322,71 +3290,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3322
3290
|
* 用一组支付来源覆盖当前订单支付项。
|
|
3323
3291
|
*
|
|
3324
3292
|
* 入参允许来自 PaymentModule 的 PaymentItem,内部统一映射为 Sales 协议:
|
|
3325
|
-
*
|
|
3293
|
+
* uuid -> metadata.unique_payment_number,id -> custom_payment_id,
|
|
3326
3294
|
* isSynced 等运行态字段不会进入 tempOrder.payments。
|
|
3327
3295
|
*/
|
|
3328
3296
|
}, {
|
|
3329
3297
|
key: "setOrderPayments",
|
|
3330
3298
|
value: function setOrderPayments(payments) {
|
|
3331
|
-
var _this22 = this;
|
|
3332
3299
|
var tempOrder = this.ensureTempOrder();
|
|
3333
|
-
tempOrder.payments = mapPaymentItemsToOrderPayments(
|
|
3334
|
-
return _this22.normalizePaymentSource(payment, {
|
|
3335
|
-
defaultPaid: false
|
|
3336
|
-
});
|
|
3337
|
-
}));
|
|
3300
|
+
tempOrder.payments = mapPaymentItemsToOrderPayments(payments);
|
|
3338
3301
|
this.persistTempOrder();
|
|
3339
3302
|
return tempOrder.payments;
|
|
3340
3303
|
}
|
|
3341
3304
|
|
|
3342
|
-
/**
|
|
3305
|
+
/** 追加单个支付项,并立即持久化当前 tempOrder。 */
|
|
3343
3306
|
}, {
|
|
3344
3307
|
key: "addOrderPayment",
|
|
3345
3308
|
value: function addOrderPayment(payment) {
|
|
3346
|
-
var
|
|
3347
|
-
return this.addOrderPaymentWithDevicePrefix(payment, hasPaymentNumber ? 'LOCAL' : this.getPaymentNumberDevicePrefixSync());
|
|
3348
|
-
}
|
|
3349
|
-
|
|
3350
|
-
/** 异步入口:创建支付项时读取最新 IoT 设备短号。 */
|
|
3351
|
-
}, {
|
|
3352
|
-
key: "addOrderPaymentAsync",
|
|
3353
|
-
value: (function () {
|
|
3354
|
-
var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(payment) {
|
|
3355
|
-
var hasPaymentNumber, devicePrefix;
|
|
3356
|
-
return _regeneratorRuntime().wrap(function _callee15$(_context17) {
|
|
3357
|
-
while (1) switch (_context17.prev = _context17.next) {
|
|
3358
|
-
case 0:
|
|
3359
|
-
hasPaymentNumber = String(payment.payment_number || '').trim() !== '';
|
|
3360
|
-
if (!hasPaymentNumber) {
|
|
3361
|
-
_context17.next = 5;
|
|
3362
|
-
break;
|
|
3363
|
-
}
|
|
3364
|
-
_context17.t0 = 'LOCAL';
|
|
3365
|
-
_context17.next = 8;
|
|
3366
|
-
break;
|
|
3367
|
-
case 5:
|
|
3368
|
-
_context17.next = 7;
|
|
3369
|
-
return this.getPaymentNumberDevicePrefixAsync();
|
|
3370
|
-
case 7:
|
|
3371
|
-
_context17.t0 = _context17.sent;
|
|
3372
|
-
case 8:
|
|
3373
|
-
devicePrefix = _context17.t0;
|
|
3374
|
-
return _context17.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
|
|
3375
|
-
case 10:
|
|
3376
|
-
case "end":
|
|
3377
|
-
return _context17.stop();
|
|
3378
|
-
}
|
|
3379
|
-
}, _callee15, this);
|
|
3380
|
-
}));
|
|
3381
|
-
function addOrderPaymentAsync(_x14) {
|
|
3382
|
-
return _addOrderPaymentAsync.apply(this, arguments);
|
|
3383
|
-
}
|
|
3384
|
-
return addOrderPaymentAsync;
|
|
3385
|
-
}())
|
|
3386
|
-
}, {
|
|
3387
|
-
key: "addOrderPaymentWithDevicePrefix",
|
|
3388
|
-
value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
|
|
3389
|
-
var _this23 = this;
|
|
3309
|
+
var _this20 = this;
|
|
3390
3310
|
this.logInfo('addOrderPayment', {
|
|
3391
3311
|
payment: payment
|
|
3392
3312
|
});
|
|
@@ -3396,15 +3316,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3396
3316
|
type: orderPaymentType,
|
|
3397
3317
|
order_payment_type: orderPaymentType
|
|
3398
3318
|
}), {
|
|
3399
|
-
defaultPaid: true
|
|
3400
|
-
devicePrefix: devicePrefix
|
|
3319
|
+
defaultPaid: true
|
|
3401
3320
|
})]);
|
|
3402
3321
|
tempOrder.payments = [].concat(_toConsumableArray(tempOrder.payments || []), _toConsumableArray(mapped));
|
|
3403
3322
|
this.persistTempOrder();
|
|
3404
3323
|
void this.recalculateSummary({
|
|
3405
3324
|
createIfMissing: true
|
|
3406
3325
|
}).catch(function (error) {
|
|
3407
|
-
|
|
3326
|
+
_this20.logError('recalculate summary after addOrderPayment failed', {
|
|
3408
3327
|
error: error instanceof Error ? error.message : String(error)
|
|
3409
3328
|
});
|
|
3410
3329
|
});
|
|
@@ -3412,80 +3331,49 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3412
3331
|
}
|
|
3413
3332
|
|
|
3414
3333
|
/**
|
|
3415
|
-
*
|
|
3416
|
-
*
|
|
3334
|
+
* 按支付唯一号、后端支付 ID、自定义支付方式 ID 或旧 uuid 更新支付项。
|
|
3335
|
+
*
|
|
3336
|
+
* 该方法服务 PaymentModal 的 void / 编辑场景;更新 metadata 时会做浅合并,
|
|
3337
|
+
* 避免覆盖 unique_payment_number、现金实付/找零等已有元数据。
|
|
3417
3338
|
*/
|
|
3418
3339
|
}, {
|
|
3419
3340
|
key: "updateOrderPayment",
|
|
3420
|
-
value:
|
|
3421
|
-
var
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
}
|
|
3443
|
-
throw new Error("\u672A\u627E\u5230\u652F\u4ED8\u9879: ".concat(identity));
|
|
3444
|
-
case 7:
|
|
3445
|
-
updatedPayment = null;
|
|
3446
|
-
tempOrder.payments = (tempOrder.payments || []).map(function (payment, index) {
|
|
3447
|
-
if (index !== matchedPayment.index) return payment;
|
|
3448
|
-
var nextPayment = mergeOrderPaymentRecord(payment, _objectSpread(_objectSpread({}, updates), {}, {
|
|
3449
|
-
updated_at: updates.updated_at || dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
3450
|
-
}));
|
|
3451
|
-
updatedPayment = nextPayment;
|
|
3452
|
-
return nextPayment;
|
|
3453
|
-
});
|
|
3454
|
-
this.persistTempOrder();
|
|
3455
|
-
_context18.next = 12;
|
|
3456
|
-
return this.recalculateSummary({
|
|
3457
|
-
createIfMissing: true
|
|
3458
|
-
});
|
|
3459
|
-
case 12:
|
|
3460
|
-
summary = _context18.sent;
|
|
3461
|
-
this.persistTempOrder();
|
|
3462
|
-
payments = tempOrder.payments;
|
|
3463
|
-
return _context18.abrupt("return", {
|
|
3464
|
-
updated: true,
|
|
3465
|
-
payment: payments[matchedPayment.index] || updatedPayment,
|
|
3466
|
-
payments: payments,
|
|
3467
|
-
summary: summary
|
|
3468
|
-
});
|
|
3469
|
-
case 16:
|
|
3470
|
-
case "end":
|
|
3471
|
-
return _context18.stop();
|
|
3472
|
-
}
|
|
3473
|
-
}, _callee16, this);
|
|
3474
|
-
}));
|
|
3475
|
-
function updateOrderPayment(_x15, _x16) {
|
|
3476
|
-
return _updateOrderPayment.apply(this, arguments);
|
|
3477
|
-
}
|
|
3478
|
-
return updateOrderPayment;
|
|
3479
|
-
}() /** 从当前订单支付项中移除指定支付项。 */)
|
|
3341
|
+
value: function updateOrderPayment(paymentIdentity, updates) {
|
|
3342
|
+
var tempOrder = this.ensureTempOrder();
|
|
3343
|
+
var identity = String(paymentIdentity);
|
|
3344
|
+
tempOrder.payments = (tempOrder.payments || []).map(function (payment) {
|
|
3345
|
+
var _payment$metadata;
|
|
3346
|
+
var uniquePaymentNumber = payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.unique_payment_number;
|
|
3347
|
+
var orderPaymentId = payment === null || payment === void 0 ? void 0 : payment.order_payment_id;
|
|
3348
|
+
var customPaymentId = payment === null || payment === void 0 ? void 0 : payment.custom_payment_id;
|
|
3349
|
+
var uuid = payment === null || payment === void 0 ? void 0 : payment.uuid;
|
|
3350
|
+
var matched = [uniquePaymentNumber, orderPaymentId, customPaymentId, uuid].some(function (value) {
|
|
3351
|
+
return value !== undefined && String(value) === identity;
|
|
3352
|
+
});
|
|
3353
|
+
if (!matched) return payment;
|
|
3354
|
+
return _objectSpread(_objectSpread(_objectSpread({}, payment), updates), {}, {
|
|
3355
|
+
metadata: _objectSpread(_objectSpread({}, payment.metadata || {}), updates.metadata || {})
|
|
3356
|
+
});
|
|
3357
|
+
});
|
|
3358
|
+
this.persistTempOrder();
|
|
3359
|
+
return tempOrder.payments;
|
|
3360
|
+
}
|
|
3361
|
+
|
|
3362
|
+
/** 从当前订单支付项中移除指定支付项。 */
|
|
3480
3363
|
}, {
|
|
3481
3364
|
key: "deleteOrderPayment",
|
|
3482
3365
|
value: function deleteOrderPayment(paymentIdentity) {
|
|
3483
3366
|
var tempOrder = this.ensureTempOrder();
|
|
3484
3367
|
var identity = String(paymentIdentity);
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3368
|
+
tempOrder.payments = (tempOrder.payments || []).filter(function (payment) {
|
|
3369
|
+
var _payment$metadata2;
|
|
3370
|
+
var uniquePaymentNumber = payment === null || payment === void 0 || (_payment$metadata2 = payment.metadata) === null || _payment$metadata2 === void 0 ? void 0 : _payment$metadata2.unique_payment_number;
|
|
3371
|
+
var orderPaymentId = payment === null || payment === void 0 ? void 0 : payment.order_payment_id;
|
|
3372
|
+
var customPaymentId = payment === null || payment === void 0 ? void 0 : payment.custom_payment_id;
|
|
3373
|
+
var uuid = payment === null || payment === void 0 ? void 0 : payment.uuid;
|
|
3374
|
+
return ![uniquePaymentNumber, orderPaymentId, customPaymentId, uuid].some(function (value) {
|
|
3375
|
+
return value !== undefined && String(value) === identity;
|
|
3376
|
+
});
|
|
3489
3377
|
});
|
|
3490
3378
|
this.persistTempOrder();
|
|
3491
3379
|
return tempOrder.payments;
|
|
@@ -3517,7 +3405,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3517
3405
|
}, {
|
|
3518
3406
|
key: "applyPaymentLifecycleChange",
|
|
3519
3407
|
value: function applyPaymentLifecycleChange(tempOrder, options) {
|
|
3520
|
-
var
|
|
3408
|
+
var _this21 = this;
|
|
3521
3409
|
this.updateTempOrderPaymentStatus(tempOrder);
|
|
3522
3410
|
if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
|
|
3523
3411
|
this.persistTempOrder();
|
|
@@ -3527,7 +3415,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3527
3415
|
void this.recalculateSummary({
|
|
3528
3416
|
createIfMissing: true
|
|
3529
3417
|
}).catch(function (error) {
|
|
3530
|
-
|
|
3418
|
+
_this21.logError("recalculate summary after ".concat(logContext, " failed"), {
|
|
3531
3419
|
error: error instanceof Error ? error.message : String(error)
|
|
3532
3420
|
});
|
|
3533
3421
|
});
|
|
@@ -3571,7 +3459,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3571
3459
|
}, {
|
|
3572
3460
|
key: "updateVoucherOrderPayments",
|
|
3573
3461
|
value: function updateVoucherOrderPayments(payments, options) {
|
|
3574
|
-
var
|
|
3462
|
+
var _this22 = this;
|
|
3575
3463
|
var tempOrder = this.ensureTempOrder();
|
|
3576
3464
|
var isOrderPaymentType = function isOrderPaymentType(value) {
|
|
3577
3465
|
return value === 'normal' || value === 'deposit';
|
|
@@ -3606,9 +3494,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3606
3494
|
});
|
|
3607
3495
|
};
|
|
3608
3496
|
var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
|
|
3609
|
-
return
|
|
3610
|
-
defaultPaid: false
|
|
3611
|
-
devicePrefix: options === null || options === void 0 ? void 0 : options.devicePrefix
|
|
3497
|
+
return _this22.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
|
|
3498
|
+
defaultPaid: false
|
|
3612
3499
|
});
|
|
3613
3500
|
})).filter(function (payment) {
|
|
3614
3501
|
return isVoucherPaymentRecord(payment);
|
|
@@ -3634,17 +3521,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3634
3521
|
}).map(function (payment) {
|
|
3635
3522
|
return String(payment.order_payment_id);
|
|
3636
3523
|
}));
|
|
3637
|
-
var
|
|
3638
|
-
return
|
|
3639
|
-
}).filter(function (key) {
|
|
3640
|
-
return key !== null;
|
|
3524
|
+
var committedVoucherIds = new Set(committedVoucherPayments.map(function (payment) {
|
|
3525
|
+
return String(payment.voucher_id);
|
|
3641
3526
|
}));
|
|
3642
3527
|
var replaceableVouchers = mappedVouchers.filter(function (payment) {
|
|
3643
3528
|
if (hasSyncedOrderPaymentRecord(payment) && committedVoucherPaymentIds.has(String(payment.order_payment_id))) {
|
|
3644
3529
|
return false;
|
|
3645
3530
|
}
|
|
3646
|
-
|
|
3647
|
-
if (lifecycleKey && committedVoucherLifecycleKeys.has(lifecycleKey)) {
|
|
3531
|
+
if (payment.voucher_id !== undefined && committedVoucherIds.has(String(payment.voucher_id))) {
|
|
3648
3532
|
return false;
|
|
3649
3533
|
}
|
|
3650
3534
|
return true;
|
|
@@ -3659,93 +3543,54 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3659
3543
|
void this.recalculateSummary({
|
|
3660
3544
|
createIfMissing: true
|
|
3661
3545
|
}).catch(function (error) {
|
|
3662
|
-
|
|
3546
|
+
_this22.logError('recalculate summary after updateVoucherOrderPayments failed', {
|
|
3663
3547
|
error: error instanceof Error ? error.message : String(error)
|
|
3664
3548
|
});
|
|
3665
3549
|
});
|
|
3666
3550
|
return tempOrder.payments;
|
|
3667
3551
|
}
|
|
3668
|
-
}, {
|
|
3669
|
-
key: "updateVoucherOrderPaymentsAsync",
|
|
3670
|
-
value: function () {
|
|
3671
|
-
var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(payments, options) {
|
|
3672
|
-
var needsPaymentNumber, devicePrefix;
|
|
3673
|
-
return _regeneratorRuntime().wrap(function _callee17$(_context19) {
|
|
3674
|
-
while (1) switch (_context19.prev = _context19.next) {
|
|
3675
|
-
case 0:
|
|
3676
|
-
needsPaymentNumber = (payments || []).some(function (payment) {
|
|
3677
|
-
return String(payment.payment_number || '').trim() === '';
|
|
3678
|
-
});
|
|
3679
|
-
if (!needsPaymentNumber) {
|
|
3680
|
-
_context19.next = 7;
|
|
3681
|
-
break;
|
|
3682
|
-
}
|
|
3683
|
-
_context19.next = 4;
|
|
3684
|
-
return this.getPaymentNumberDevicePrefixAsync();
|
|
3685
|
-
case 4:
|
|
3686
|
-
_context19.t0 = _context19.sent;
|
|
3687
|
-
_context19.next = 8;
|
|
3688
|
-
break;
|
|
3689
|
-
case 7:
|
|
3690
|
-
_context19.t0 = 'LOCAL';
|
|
3691
|
-
case 8:
|
|
3692
|
-
devicePrefix = _context19.t0;
|
|
3693
|
-
return _context19.abrupt("return", this.updateVoucherOrderPayments(payments, _objectSpread(_objectSpread({}, options), {}, {
|
|
3694
|
-
devicePrefix: devicePrefix
|
|
3695
|
-
})));
|
|
3696
|
-
case 10:
|
|
3697
|
-
case "end":
|
|
3698
|
-
return _context19.stop();
|
|
3699
|
-
}
|
|
3700
|
-
}, _callee17, this);
|
|
3701
|
-
}));
|
|
3702
|
-
function updateVoucherOrderPaymentsAsync(_x17, _x18) {
|
|
3703
|
-
return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
|
|
3704
|
-
}
|
|
3705
|
-
return updateVoucherOrderPaymentsAsync;
|
|
3706
|
-
}()
|
|
3707
3552
|
}, {
|
|
3708
3553
|
key: "shouldMergeProductToOrder",
|
|
3709
3554
|
value: function () {
|
|
3710
|
-
var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3555
|
+
var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
|
|
3711
3556
|
var _this$orderHooks;
|
|
3712
3557
|
var onBeforeMergeProductToOrder, result;
|
|
3713
|
-
return _regeneratorRuntime().wrap(function
|
|
3714
|
-
while (1) switch (
|
|
3558
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context17) {
|
|
3559
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
3715
3560
|
case 0:
|
|
3716
3561
|
onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
|
|
3717
3562
|
if (onBeforeMergeProductToOrder) {
|
|
3718
|
-
|
|
3563
|
+
_context17.next = 3;
|
|
3719
3564
|
break;
|
|
3720
3565
|
}
|
|
3721
|
-
return
|
|
3566
|
+
return _context17.abrupt("return", true);
|
|
3722
3567
|
case 3:
|
|
3723
|
-
|
|
3568
|
+
_context17.next = 5;
|
|
3724
3569
|
return onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
3725
3570
|
defaultShouldMerge: true
|
|
3726
3571
|
}));
|
|
3727
3572
|
case 5:
|
|
3728
|
-
result =
|
|
3573
|
+
result = _context17.sent;
|
|
3729
3574
|
if (!(typeof result === 'boolean')) {
|
|
3730
|
-
|
|
3575
|
+
_context17.next = 8;
|
|
3731
3576
|
break;
|
|
3732
3577
|
}
|
|
3733
|
-
return
|
|
3578
|
+
return _context17.abrupt("return", result);
|
|
3734
3579
|
case 8:
|
|
3735
3580
|
if (!(result && _typeof(result) === 'object' && typeof result.shouldMerge === 'boolean')) {
|
|
3736
|
-
|
|
3581
|
+
_context17.next = 10;
|
|
3737
3582
|
break;
|
|
3738
3583
|
}
|
|
3739
|
-
return
|
|
3584
|
+
return _context17.abrupt("return", result.shouldMerge);
|
|
3740
3585
|
case 10:
|
|
3741
|
-
return
|
|
3586
|
+
return _context17.abrupt("return", true);
|
|
3742
3587
|
case 11:
|
|
3743
3588
|
case "end":
|
|
3744
|
-
return
|
|
3589
|
+
return _context17.stop();
|
|
3745
3590
|
}
|
|
3746
|
-
},
|
|
3591
|
+
}, _callee15, this);
|
|
3747
3592
|
}));
|
|
3748
|
-
function shouldMergeProductToOrder(
|
|
3593
|
+
function shouldMergeProductToOrder(_x14) {
|
|
3749
3594
|
return _shouldMergeProductToOrder.apply(this, arguments);
|
|
3750
3595
|
}
|
|
3751
3596
|
return shouldMergeProductToOrder;
|
|
@@ -3781,30 +3626,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3781
3626
|
}, {
|
|
3782
3627
|
key: "finalizeProductOrderMutation",
|
|
3783
3628
|
value: function () {
|
|
3784
|
-
var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3785
|
-
return _regeneratorRuntime().wrap(function
|
|
3786
|
-
while (1) switch (
|
|
3629
|
+
var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(tempOrder, options) {
|
|
3630
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context18) {
|
|
3631
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
3787
3632
|
case 0:
|
|
3788
3633
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
3789
3634
|
if (options !== null && options !== void 0 && options.skipEditDiscountConfigRefresh) {
|
|
3790
|
-
|
|
3635
|
+
_context18.next = 4;
|
|
3791
3636
|
break;
|
|
3792
3637
|
}
|
|
3793
|
-
|
|
3638
|
+
_context18.next = 4;
|
|
3794
3639
|
return this.ensureEditDiscountConfigForProductChange(tempOrder);
|
|
3795
3640
|
case 4:
|
|
3796
3641
|
if (options !== null && options !== void 0 && options.skipDiscountRecalculation) {
|
|
3797
|
-
|
|
3642
|
+
_context18.next = 7;
|
|
3798
3643
|
break;
|
|
3799
3644
|
}
|
|
3800
|
-
|
|
3645
|
+
_context18.next = 7;
|
|
3801
3646
|
return this.applyPromotion();
|
|
3802
3647
|
case 7:
|
|
3803
3648
|
if (!(options !== null && options !== void 0 && options.skipDiscountRecalculation)) {
|
|
3804
3649
|
this.applyDiscount();
|
|
3805
3650
|
}
|
|
3806
3651
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
3807
|
-
|
|
3652
|
+
_context18.next = 11;
|
|
3808
3653
|
return this.recalculateSummary({
|
|
3809
3654
|
createIfMissing: true
|
|
3810
3655
|
});
|
|
@@ -3812,11 +3657,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3812
3657
|
this.persistTempOrder();
|
|
3813
3658
|
case 12:
|
|
3814
3659
|
case "end":
|
|
3815
|
-
return
|
|
3660
|
+
return _context18.stop();
|
|
3816
3661
|
}
|
|
3817
|
-
},
|
|
3662
|
+
}, _callee16, this);
|
|
3818
3663
|
}));
|
|
3819
|
-
function finalizeProductOrderMutation(
|
|
3664
|
+
function finalizeProductOrderMutation(_x15, _x16) {
|
|
3820
3665
|
return _finalizeProductOrderMutation.apply(this, arguments);
|
|
3821
3666
|
}
|
|
3822
3667
|
return finalizeProductOrderMutation;
|
|
@@ -3831,13 +3676,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3831
3676
|
}, {
|
|
3832
3677
|
key: "appendProductLineToTempOrder",
|
|
3833
3678
|
value: (function () {
|
|
3834
|
-
var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3835
|
-
var
|
|
3679
|
+
var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(tempOrder, product, booking, options) {
|
|
3680
|
+
var _normalizedIncoming$p,
|
|
3681
|
+
_normalizedIncoming$p2,
|
|
3682
|
+
_booking_uid,
|
|
3836
3683
|
_metadata,
|
|
3837
|
-
|
|
3838
|
-
var linked, productToAdd, incomingFingerprint, normalizedIncoming, incomingBookingUid, hasIncomingGoodPass, hasIncomingProductNote, hasIncomingBookingUid, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList;
|
|
3839
|
-
return _regeneratorRuntime().wrap(function
|
|
3840
|
-
while (1) switch (
|
|
3684
|
+
_this23 = this;
|
|
3685
|
+
var linked, productToAdd, incomingFingerprint, normalizedIncoming, isWeighingProduct, netWeight, incomingBookingUid, hasIncomingGoodPass, hasIncomingProductNote, hasIncomingBookingUid, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, insertAtIndex, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList, mergedProduct;
|
|
3686
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context19) {
|
|
3687
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
3841
3688
|
case 0:
|
|
3842
3689
|
linked = booking ? this.createLinkedProductAndBooking({
|
|
3843
3690
|
product: product,
|
|
@@ -3846,6 +3693,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3846
3693
|
productToAdd = (linked === null || linked === void 0 ? void 0 : linked.product) || product;
|
|
3847
3694
|
incomingFingerprint = buildProductLineFingerprint(getProductSkuOptions(productToAdd), productToAdd.product_bundle);
|
|
3848
3695
|
normalizedIncoming = mergeOrderProductDisplayFields(productToAdd, normalizeOrderProduct(productToAdd));
|
|
3696
|
+
isWeighingProduct = Number(((_normalizedIncoming$p = normalizedIncoming.product_sku) === null || _normalizedIncoming$p === void 0 ? void 0 : _normalizedIncoming$p.open_sold_weight) || 0) === 1;
|
|
3697
|
+
netWeight = Number((_normalizedIncoming$p2 = normalizedIncoming.product_sku) === null || _normalizedIncoming$p2 === void 0 ? void 0 : _normalizedIncoming$p2.net_weight);
|
|
3698
|
+
if (!(isWeighingProduct && (!Number.isFinite(netWeight) || netWeight <= 0))) {
|
|
3699
|
+
_context19.next = 8;
|
|
3700
|
+
break;
|
|
3701
|
+
}
|
|
3702
|
+
throw new Error('[Order] 称重商品净重必须大于 0');
|
|
3703
|
+
case 8:
|
|
3849
3704
|
incomingBookingUid = (_booking_uid = productToAdd.booking_uid) !== null && _booking_uid !== void 0 ? _booking_uid : (_metadata = productToAdd.metadata) === null || _metadata === void 0 ? void 0 : _metadata.booking_uid;
|
|
3850
3705
|
if (incomingBookingUid !== undefined && incomingBookingUid !== null && String(incomingBookingUid) !== '') {
|
|
3851
3706
|
normalizedIncoming.booking_uid = String(incomingBookingUid);
|
|
@@ -3857,11 +3712,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3857
3712
|
hasIncomingGoodPass = this.hasGoodPassDiscount(normalizedIncoming);
|
|
3858
3713
|
hasIncomingProductNote = this.hasOrderProductLineNote(normalizedIncoming);
|
|
3859
3714
|
hasIncomingBookingUid = this.hasLinkedBookingUid(productToAdd) || this.hasLinkedBookingUid(normalizedIncoming);
|
|
3860
|
-
shouldForceNewLine = !!booking || hasIncomingProductNote || hasIncomingBookingUid;
|
|
3715
|
+
shouldForceNewLine = !!booking || hasIncomingProductNote || hasIncomingBookingUid || isWeighingProduct;
|
|
3861
3716
|
matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
3862
3717
|
var _item$metadata3;
|
|
3863
|
-
if (
|
|
3864
|
-
if (
|
|
3718
|
+
if (_this23.hasGoodPassDiscount(item)) return false;
|
|
3719
|
+
if (_this23.hasOrderProductLineNote(item)) return false;
|
|
3865
3720
|
if (item.order_detail_id !== undefined && item.order_detail_id !== null) return false;
|
|
3866
3721
|
if ((_item$metadata3 = item.metadata) !== null && _item$metadata3 !== void 0 && _item$metadata3.is_edit_for_runtime) return false;
|
|
3867
3722
|
if (item.product_id !== productToAdd.product_id) return false;
|
|
@@ -3872,10 +3727,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3872
3727
|
matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
|
|
3873
3728
|
existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
|
|
3874
3729
|
if (!matchedProduct) {
|
|
3875
|
-
|
|
3730
|
+
_context19.next = 24;
|
|
3876
3731
|
break;
|
|
3877
3732
|
}
|
|
3878
|
-
|
|
3733
|
+
_context19.next = 21;
|
|
3879
3734
|
return this.shouldMergeProductToOrder({
|
|
3880
3735
|
incomingProduct: productToAdd,
|
|
3881
3736
|
normalizedIncoming: normalizedIncoming,
|
|
@@ -3886,14 +3741,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3886
3741
|
tempOrder: tempOrder,
|
|
3887
3742
|
booking: booking
|
|
3888
3743
|
});
|
|
3889
|
-
case 17:
|
|
3890
|
-
_context22.t0 = _context22.sent;
|
|
3891
|
-
_context22.next = 21;
|
|
3892
|
-
break;
|
|
3893
|
-
case 20:
|
|
3894
|
-
_context22.t0 = false;
|
|
3895
3744
|
case 21:
|
|
3896
|
-
|
|
3745
|
+
_context19.t0 = _context19.sent;
|
|
3746
|
+
_context19.next = 25;
|
|
3747
|
+
break;
|
|
3748
|
+
case 24:
|
|
3749
|
+
_context19.t0 = false;
|
|
3750
|
+
case 25:
|
|
3751
|
+
shouldMerge = _context19.t0;
|
|
3897
3752
|
if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
|
|
3898
3753
|
this.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
|
|
3899
3754
|
if (linked) {
|
|
@@ -3902,8 +3757,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3902
3757
|
booking_uid: linked.bookingUid
|
|
3903
3758
|
});
|
|
3904
3759
|
}
|
|
3905
|
-
|
|
3906
|
-
|
|
3760
|
+
insertAtIndex = options === null || options === void 0 ? void 0 : options.insertAtIndex;
|
|
3761
|
+
if (Number.isInteger(insertAtIndex) && Number(insertAtIndex) >= 0 && Number(insertAtIndex) < tempOrder.products.length) {
|
|
3762
|
+
tempOrder.products = [].concat(_toConsumableArray(tempOrder.products.slice(0, insertAtIndex)), [normalizedIncoming], _toConsumableArray(tempOrder.products.slice(insertAtIndex)));
|
|
3763
|
+
} else {
|
|
3764
|
+
tempOrder.products = [].concat(_toConsumableArray(tempOrder.products), [normalizedIncoming]);
|
|
3765
|
+
}
|
|
3907
3766
|
} else {
|
|
3908
3767
|
targetProduct = matchedProduct;
|
|
3909
3768
|
targetUid = (_targetProduct$metada = targetProduct.metadata) === null || _targetProduct$metada === void 0 ? void 0 : _targetProduct$metada.unique_identification_number;
|
|
@@ -3941,17 +3800,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3941
3800
|
num: nextNum
|
|
3942
3801
|
});
|
|
3943
3802
|
this.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
|
|
3803
|
+
if (matchedIndex !== tempOrder.products.length - 1) {
|
|
3804
|
+
mergedProduct = tempOrder.products[matchedIndex];
|
|
3805
|
+
tempOrder.products = [].concat(_toConsumableArray(tempOrder.products.slice(0, matchedIndex)), _toConsumableArray(tempOrder.products.slice(matchedIndex + 1)), [mergedProduct]);
|
|
3806
|
+
}
|
|
3944
3807
|
}
|
|
3945
3808
|
if (linked) {
|
|
3946
3809
|
tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
|
|
3947
3810
|
}
|
|
3948
|
-
case
|
|
3811
|
+
case 28:
|
|
3949
3812
|
case "end":
|
|
3950
|
-
return
|
|
3813
|
+
return _context19.stop();
|
|
3951
3814
|
}
|
|
3952
|
-
},
|
|
3815
|
+
}, _callee17, this);
|
|
3953
3816
|
}));
|
|
3954
|
-
function appendProductLineToTempOrder(
|
|
3817
|
+
function appendProductLineToTempOrder(_x17, _x18, _x19, _x20) {
|
|
3955
3818
|
return _appendProductLineToTempOrder.apply(this, arguments);
|
|
3956
3819
|
}
|
|
3957
3820
|
return appendProductLineToTempOrder;
|
|
@@ -3967,61 +3830,74 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3967
3830
|
}, {
|
|
3968
3831
|
key: "addProductToOrder",
|
|
3969
3832
|
value: (function () {
|
|
3970
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3971
|
-
var tempOrder, _ref61, _productRecord$num, productRecord, splitCount, i, singleLine;
|
|
3972
|
-
return _regeneratorRuntime().wrap(function
|
|
3973
|
-
while (1) switch (
|
|
3833
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(product, booking, options) {
|
|
3834
|
+
var tempOrder, insertAfterProductUid, anchorIndex, insertAtIndex, _ref61, _productRecord$num, productRecord, splitCount, i, singleLine;
|
|
3835
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context20) {
|
|
3836
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
3974
3837
|
case 0:
|
|
3975
3838
|
tempOrder = this.ensureTempOrder();
|
|
3839
|
+
insertAfterProductUid = options === null || options === void 0 ? void 0 : options.insertAfterProductUid;
|
|
3840
|
+
anchorIndex = booking && insertAfterProductUid ? tempOrder.products.findIndex(function (line) {
|
|
3841
|
+
var _line$metadata;
|
|
3842
|
+
var uid = ((_line$metadata = line.metadata) === null || _line$metadata === void 0 ? void 0 : _line$metadata.unique_identification_number) || line.unique_identification_number;
|
|
3843
|
+
return uid !== undefined && uid !== null && String(uid) === String(insertAfterProductUid);
|
|
3844
|
+
}) : -1;
|
|
3845
|
+
insertAtIndex = anchorIndex >= 0 ? anchorIndex + 1 : undefined;
|
|
3976
3846
|
if (!booking) {
|
|
3977
|
-
|
|
3847
|
+
_context20.next = 22;
|
|
3978
3848
|
break;
|
|
3979
3849
|
}
|
|
3980
3850
|
productRecord = product;
|
|
3981
3851
|
splitCount = getSafeProductNum((_ref61 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref61 !== void 0 ? _ref61 : 1);
|
|
3982
3852
|
if (!(splitCount > 1)) {
|
|
3983
|
-
|
|
3853
|
+
_context20.next = 22;
|
|
3984
3854
|
break;
|
|
3985
3855
|
}
|
|
3986
3856
|
i = 0;
|
|
3987
|
-
case
|
|
3857
|
+
case 9:
|
|
3988
3858
|
if (!(i < splitCount)) {
|
|
3989
|
-
|
|
3859
|
+
_context20.next = 19;
|
|
3990
3860
|
break;
|
|
3991
3861
|
}
|
|
3992
3862
|
singleLine = cloneDeep(productRecord);
|
|
3993
3863
|
singleLine.num = 1;
|
|
3994
3864
|
delete singleLine.product_quantity;
|
|
3995
|
-
|
|
3996
|
-
return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking)
|
|
3997
|
-
|
|
3865
|
+
_context20.next = 15;
|
|
3866
|
+
return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking), {
|
|
3867
|
+
insertAtIndex: insertAtIndex
|
|
3868
|
+
});
|
|
3869
|
+
case 15:
|
|
3870
|
+
if (insertAtIndex !== undefined) insertAtIndex += 1;
|
|
3871
|
+
case 16:
|
|
3998
3872
|
i += 1;
|
|
3999
|
-
|
|
3873
|
+
_context20.next = 9;
|
|
4000
3874
|
break;
|
|
4001
|
-
case
|
|
4002
|
-
|
|
4003
|
-
return this.finalizeProductOrderMutation(tempOrder);
|
|
4004
|
-
case 17:
|
|
4005
|
-
return _context23.abrupt("return", tempOrder.products);
|
|
4006
|
-
case 18:
|
|
4007
|
-
_context23.next = 20;
|
|
4008
|
-
return this.appendProductLineToTempOrder(tempOrder, product, booking);
|
|
4009
|
-
case 20:
|
|
4010
|
-
_context23.next = 22;
|
|
3875
|
+
case 19:
|
|
3876
|
+
_context20.next = 21;
|
|
4011
3877
|
return this.finalizeProductOrderMutation(tempOrder);
|
|
3878
|
+
case 21:
|
|
3879
|
+
return _context20.abrupt("return", tempOrder.products);
|
|
4012
3880
|
case 22:
|
|
3881
|
+
_context20.next = 24;
|
|
3882
|
+
return this.appendProductLineToTempOrder(tempOrder, product, booking, {
|
|
3883
|
+
insertAtIndex: insertAtIndex
|
|
3884
|
+
});
|
|
3885
|
+
case 24:
|
|
3886
|
+
_context20.next = 26;
|
|
3887
|
+
return this.finalizeProductOrderMutation(tempOrder);
|
|
3888
|
+
case 26:
|
|
4013
3889
|
this.logInfo('addProductToOrder success', {
|
|
4014
3890
|
product_id: product.product_id,
|
|
4015
3891
|
with_booking: !!booking
|
|
4016
3892
|
});
|
|
4017
|
-
return
|
|
4018
|
-
case
|
|
3893
|
+
return _context20.abrupt("return", tempOrder.products);
|
|
3894
|
+
case 28:
|
|
4019
3895
|
case "end":
|
|
4020
|
-
return
|
|
3896
|
+
return _context20.stop();
|
|
4021
3897
|
}
|
|
4022
|
-
},
|
|
3898
|
+
}, _callee18, this);
|
|
4023
3899
|
}));
|
|
4024
|
-
function addProductToOrder(
|
|
3900
|
+
function addProductToOrder(_x21, _x22, _x23) {
|
|
4025
3901
|
return _addProductToOrder.apply(this, arguments);
|
|
4026
3902
|
}
|
|
4027
3903
|
return addProductToOrder;
|
|
@@ -4039,93 +3915,93 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4039
3915
|
}, {
|
|
4040
3916
|
key: "addProductsToOrder",
|
|
4041
3917
|
value: (function () {
|
|
4042
|
-
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3918
|
+
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(items, options) {
|
|
4043
3919
|
var tempOrder, _iterator20, _step20, item, product, booking, _ref62, _productRecord$num2, productRecord, splitCount, i, singleLine;
|
|
4044
|
-
return _regeneratorRuntime().wrap(function
|
|
4045
|
-
while (1) switch (
|
|
3920
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context21) {
|
|
3921
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
4046
3922
|
case 0:
|
|
4047
3923
|
tempOrder = this.ensureTempOrder();
|
|
4048
3924
|
if (!(!Array.isArray(items) || items.length === 0)) {
|
|
4049
|
-
|
|
3925
|
+
_context21.next = 3;
|
|
4050
3926
|
break;
|
|
4051
3927
|
}
|
|
4052
|
-
return
|
|
3928
|
+
return _context21.abrupt("return", tempOrder.products);
|
|
4053
3929
|
case 3:
|
|
4054
3930
|
_iterator20 = _createForOfIteratorHelper(items || []);
|
|
4055
|
-
|
|
3931
|
+
_context21.prev = 4;
|
|
4056
3932
|
_iterator20.s();
|
|
4057
3933
|
case 6:
|
|
4058
3934
|
if ((_step20 = _iterator20.n()).done) {
|
|
4059
|
-
|
|
3935
|
+
_context21.next = 30;
|
|
4060
3936
|
break;
|
|
4061
3937
|
}
|
|
4062
3938
|
item = _step20.value;
|
|
4063
3939
|
product = item.product, booking = item.booking;
|
|
4064
3940
|
if (product) {
|
|
4065
|
-
|
|
3941
|
+
_context21.next = 11;
|
|
4066
3942
|
break;
|
|
4067
3943
|
}
|
|
4068
|
-
return
|
|
3944
|
+
return _context21.abrupt("continue", 28);
|
|
4069
3945
|
case 11:
|
|
4070
3946
|
if (!booking) {
|
|
4071
|
-
|
|
3947
|
+
_context21.next = 26;
|
|
4072
3948
|
break;
|
|
4073
3949
|
}
|
|
4074
3950
|
productRecord = product;
|
|
4075
3951
|
splitCount = getSafeProductNum((_ref62 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref62 !== void 0 ? _ref62 : 1);
|
|
4076
3952
|
if (!(splitCount > 1)) {
|
|
4077
|
-
|
|
3953
|
+
_context21.next = 26;
|
|
4078
3954
|
break;
|
|
4079
3955
|
}
|
|
4080
3956
|
i = 0;
|
|
4081
3957
|
case 16:
|
|
4082
3958
|
if (!(i < splitCount)) {
|
|
4083
|
-
|
|
3959
|
+
_context21.next = 25;
|
|
4084
3960
|
break;
|
|
4085
3961
|
}
|
|
4086
3962
|
singleLine = cloneDeep(productRecord);
|
|
4087
3963
|
singleLine.num = 1;
|
|
4088
3964
|
delete singleLine.product_quantity;
|
|
4089
|
-
|
|
3965
|
+
_context21.next = 22;
|
|
4090
3966
|
return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
|
|
4091
3967
|
case 22:
|
|
4092
3968
|
i += 1;
|
|
4093
|
-
|
|
3969
|
+
_context21.next = 16;
|
|
4094
3970
|
break;
|
|
4095
3971
|
case 25:
|
|
4096
|
-
return
|
|
3972
|
+
return _context21.abrupt("continue", 28);
|
|
4097
3973
|
case 26:
|
|
4098
|
-
|
|
3974
|
+
_context21.next = 28;
|
|
4099
3975
|
return this.appendProductLineToTempOrder(tempOrder, product, booking);
|
|
4100
3976
|
case 28:
|
|
4101
|
-
|
|
3977
|
+
_context21.next = 6;
|
|
4102
3978
|
break;
|
|
4103
3979
|
case 30:
|
|
4104
|
-
|
|
3980
|
+
_context21.next = 35;
|
|
4105
3981
|
break;
|
|
4106
3982
|
case 32:
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
_iterator20.e(
|
|
3983
|
+
_context21.prev = 32;
|
|
3984
|
+
_context21.t0 = _context21["catch"](4);
|
|
3985
|
+
_iterator20.e(_context21.t0);
|
|
4110
3986
|
case 35:
|
|
4111
|
-
|
|
3987
|
+
_context21.prev = 35;
|
|
4112
3988
|
_iterator20.f();
|
|
4113
|
-
return
|
|
3989
|
+
return _context21.finish(35);
|
|
4114
3990
|
case 38:
|
|
4115
|
-
|
|
3991
|
+
_context21.next = 40;
|
|
4116
3992
|
return this.finalizeProductOrderMutation(tempOrder, options);
|
|
4117
3993
|
case 40:
|
|
4118
3994
|
this.logInfo('addProductsToOrder success', {
|
|
4119
3995
|
itemsCount: items.length
|
|
4120
3996
|
});
|
|
4121
|
-
return
|
|
3997
|
+
return _context21.abrupt("return", tempOrder.products);
|
|
4122
3998
|
case 42:
|
|
4123
3999
|
case "end":
|
|
4124
|
-
return
|
|
4000
|
+
return _context21.stop();
|
|
4125
4001
|
}
|
|
4126
|
-
},
|
|
4002
|
+
}, _callee19, this, [[4, 32, 35, 38]]);
|
|
4127
4003
|
}));
|
|
4128
|
-
function addProductsToOrder(
|
|
4004
|
+
function addProductsToOrder(_x24, _x25) {
|
|
4129
4005
|
return _addProductsToOrder.apply(this, arguments);
|
|
4130
4006
|
}
|
|
4131
4007
|
return addProductsToOrder;
|
|
@@ -4159,17 +4035,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4159
4035
|
}, {
|
|
4160
4036
|
key: "preservePersistedBundlePriceFields",
|
|
4161
4037
|
value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
|
|
4162
|
-
var
|
|
4038
|
+
var _this24 = this;
|
|
4163
4039
|
if (!Array.isArray(nextBundles)) return nextBundles;
|
|
4164
4040
|
if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
|
|
4165
4041
|
var previousByIdentity = new Map();
|
|
4166
4042
|
previousBundles.forEach(function (bundle) {
|
|
4167
|
-
var identity =
|
|
4043
|
+
var identity = _this24.getBundleRuntimeIdentity(bundle);
|
|
4168
4044
|
if (identity) previousByIdentity.set(identity, bundle);
|
|
4169
4045
|
});
|
|
4170
4046
|
return nextBundles.map(function (bundle, index) {
|
|
4171
4047
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
4172
|
-
var previous = previousByIdentity.get(
|
|
4048
|
+
var previous = previousByIdentity.get(_this24.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
|
|
4173
4049
|
if (!previous || _typeof(previous) !== 'object') return bundle;
|
|
4174
4050
|
return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
|
|
4175
4051
|
cover: previous.cover
|
|
@@ -4370,21 +4246,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4370
4246
|
}, {
|
|
4371
4247
|
key: "updateOrderProduct",
|
|
4372
4248
|
value: function () {
|
|
4373
|
-
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4249
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
|
|
4374
4250
|
var tempOrder, updatedProductUid;
|
|
4375
|
-
return _regeneratorRuntime().wrap(function
|
|
4376
|
-
while (1) switch (
|
|
4251
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context22) {
|
|
4252
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
4377
4253
|
case 0:
|
|
4378
4254
|
tempOrder = this.ensureTempOrder();
|
|
4379
4255
|
updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
4380
|
-
|
|
4256
|
+
_context22.next = 4;
|
|
4381
4257
|
return this.applyPromotion();
|
|
4382
4258
|
case 4:
|
|
4383
4259
|
this.applyDiscount({
|
|
4384
4260
|
reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
|
|
4385
4261
|
});
|
|
4386
4262
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4387
|
-
|
|
4263
|
+
_context22.next = 8;
|
|
4388
4264
|
return this.recalculateSummary({
|
|
4389
4265
|
createIfMissing: true
|
|
4390
4266
|
});
|
|
@@ -4393,14 +4269,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4393
4269
|
this.logInfo('updateOrderProduct success', {
|
|
4394
4270
|
params: params
|
|
4395
4271
|
});
|
|
4396
|
-
return
|
|
4272
|
+
return _context22.abrupt("return", tempOrder.products);
|
|
4397
4273
|
case 11:
|
|
4398
4274
|
case "end":
|
|
4399
|
-
return
|
|
4275
|
+
return _context22.stop();
|
|
4400
4276
|
}
|
|
4401
|
-
},
|
|
4277
|
+
}, _callee20, this);
|
|
4402
4278
|
}));
|
|
4403
|
-
function updateOrderProduct(
|
|
4279
|
+
function updateOrderProduct(_x26) {
|
|
4404
4280
|
return _updateOrderProduct.apply(this, arguments);
|
|
4405
4281
|
}
|
|
4406
4282
|
return updateOrderProduct;
|
|
@@ -4408,28 +4284,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4408
4284
|
}, {
|
|
4409
4285
|
key: "updateOrderProducts",
|
|
4410
4286
|
value: function () {
|
|
4411
|
-
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4412
|
-
var
|
|
4287
|
+
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(paramsList) {
|
|
4288
|
+
var _this25 = this;
|
|
4413
4289
|
var tempOrder, reapplyBookingDiscountProductUids;
|
|
4414
|
-
return _regeneratorRuntime().wrap(function
|
|
4415
|
-
while (1) switch (
|
|
4290
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context23) {
|
|
4291
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
4416
4292
|
case 0:
|
|
4417
4293
|
tempOrder = this.ensureTempOrder();
|
|
4418
4294
|
if (paramsList.length) {
|
|
4419
|
-
|
|
4295
|
+
_context23.next = 3;
|
|
4420
4296
|
break;
|
|
4421
4297
|
}
|
|
4422
|
-
return
|
|
4298
|
+
return _context23.abrupt("return", tempOrder.products);
|
|
4423
4299
|
case 3:
|
|
4424
4300
|
reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
|
|
4425
|
-
var updatedProductUid =
|
|
4301
|
+
var updatedProductUid = _this25.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
4426
4302
|
// 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
|
|
4427
4303
|
if (params.allow_booking_discount_reapply && updatedProductUid) {
|
|
4428
4304
|
acc.push(String(updatedProductUid));
|
|
4429
4305
|
}
|
|
4430
4306
|
return acc;
|
|
4431
4307
|
}, []);
|
|
4432
|
-
|
|
4308
|
+
_context23.next = 6;
|
|
4433
4309
|
return this.finalizeAfterProductsMutation(tempOrder, {
|
|
4434
4310
|
reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
|
|
4435
4311
|
});
|
|
@@ -4437,14 +4313,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4437
4313
|
this.logInfo('updateOrderProduct success', {
|
|
4438
4314
|
paramsList: paramsList
|
|
4439
4315
|
});
|
|
4440
|
-
return
|
|
4316
|
+
return _context23.abrupt("return", tempOrder.products);
|
|
4441
4317
|
case 8:
|
|
4442
4318
|
case "end":
|
|
4443
|
-
return
|
|
4319
|
+
return _context23.stop();
|
|
4444
4320
|
}
|
|
4445
|
-
},
|
|
4321
|
+
}, _callee21, this);
|
|
4446
4322
|
}));
|
|
4447
|
-
function updateOrderProducts(
|
|
4323
|
+
function updateOrderProducts(_x27) {
|
|
4448
4324
|
return _updateOrderProducts.apply(this, arguments);
|
|
4449
4325
|
}
|
|
4450
4326
|
return updateOrderProducts;
|
|
@@ -4452,11 +4328,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4452
4328
|
}, {
|
|
4453
4329
|
key: "updateOrderProductQuantity",
|
|
4454
4330
|
value: function () {
|
|
4455
|
-
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4331
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
|
|
4456
4332
|
var _targetProduct$metada17;
|
|
4457
4333
|
var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct;
|
|
4458
|
-
return _regeneratorRuntime().wrap(function
|
|
4459
|
-
while (1) switch (
|
|
4334
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context24) {
|
|
4335
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
4460
4336
|
case 0:
|
|
4461
4337
|
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;
|
|
4462
4338
|
tempOrder = this.ensureTempOrder();
|
|
@@ -4485,7 +4361,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4485
4361
|
productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
|
|
4486
4362
|
}
|
|
4487
4363
|
if (!(productIndex === -1)) {
|
|
4488
|
-
|
|
4364
|
+
_context24.next = 12;
|
|
4489
4365
|
break;
|
|
4490
4366
|
}
|
|
4491
4367
|
throw new Error('[Order] 目标商品不存在,无法更新数量');
|
|
@@ -4499,12 +4375,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4499
4375
|
}));
|
|
4500
4376
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
4501
4377
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
4502
|
-
|
|
4378
|
+
_context24.next = 18;
|
|
4503
4379
|
return this.applyPromotion();
|
|
4504
4380
|
case 18:
|
|
4505
4381
|
this.applyDiscount();
|
|
4506
4382
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4507
|
-
|
|
4383
|
+
_context24.next = 22;
|
|
4508
4384
|
return this.recalculateSummary({
|
|
4509
4385
|
createIfMissing: true
|
|
4510
4386
|
});
|
|
@@ -4513,14 +4389,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4513
4389
|
this.logInfo('updateOrderProductQuantity success', {
|
|
4514
4390
|
params: params
|
|
4515
4391
|
});
|
|
4516
|
-
return
|
|
4392
|
+
return _context24.abrupt("return", tempOrder.products);
|
|
4517
4393
|
case 25:
|
|
4518
4394
|
case "end":
|
|
4519
|
-
return
|
|
4395
|
+
return _context24.stop();
|
|
4520
4396
|
}
|
|
4521
|
-
},
|
|
4397
|
+
}, _callee22, this);
|
|
4522
4398
|
}));
|
|
4523
|
-
function updateOrderProductQuantity(
|
|
4399
|
+
function updateOrderProductQuantity(_x28) {
|
|
4524
4400
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
4525
4401
|
}
|
|
4526
4402
|
return updateOrderProductQuantity;
|
|
@@ -4561,19 +4437,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4561
4437
|
}, {
|
|
4562
4438
|
key: "finalizeAfterProductsMutation",
|
|
4563
4439
|
value: (function () {
|
|
4564
|
-
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4565
|
-
return _regeneratorRuntime().wrap(function
|
|
4566
|
-
while (1) switch (
|
|
4440
|
+
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(tempOrder, options) {
|
|
4441
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context25) {
|
|
4442
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
4567
4443
|
case 0:
|
|
4568
4444
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
4569
|
-
|
|
4445
|
+
_context25.next = 3;
|
|
4570
4446
|
return this.applyPromotion();
|
|
4571
4447
|
case 3:
|
|
4572
4448
|
this.applyDiscount({
|
|
4573
4449
|
reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids
|
|
4574
4450
|
});
|
|
4575
4451
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4576
|
-
|
|
4452
|
+
_context25.next = 7;
|
|
4577
4453
|
return this.recalculateSummary({
|
|
4578
4454
|
createIfMissing: true
|
|
4579
4455
|
});
|
|
@@ -4581,11 +4457,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4581
4457
|
this.persistTempOrder();
|
|
4582
4458
|
case 8:
|
|
4583
4459
|
case "end":
|
|
4584
|
-
return
|
|
4460
|
+
return _context25.stop();
|
|
4585
4461
|
}
|
|
4586
|
-
},
|
|
4462
|
+
}, _callee23, this);
|
|
4587
4463
|
}));
|
|
4588
|
-
function finalizeAfterProductsMutation(
|
|
4464
|
+
function finalizeAfterProductsMutation(_x29, _x30) {
|
|
4589
4465
|
return _finalizeAfterProductsMutation.apply(this, arguments);
|
|
4590
4466
|
}
|
|
4591
4467
|
return finalizeAfterProductsMutation;
|
|
@@ -4600,21 +4476,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4600
4476
|
}, {
|
|
4601
4477
|
key: "removeProductsFromOrder",
|
|
4602
4478
|
value: (function () {
|
|
4603
|
-
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4604
|
-
var
|
|
4605
|
-
var tempOrder, productsBeforeRemove, bookingsBeforeRemove, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3;
|
|
4606
|
-
return _regeneratorRuntime().wrap(function
|
|
4607
|
-
while (1) switch (
|
|
4479
|
+
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(identities, options) {
|
|
4480
|
+
var _this26 = this;
|
|
4481
|
+
var tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
|
|
4482
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context27) {
|
|
4483
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
4608
4484
|
case 0:
|
|
4609
4485
|
tempOrder = this.ensureTempOrder();
|
|
4610
4486
|
if (identities.length) {
|
|
4611
|
-
|
|
4487
|
+
_context27.next = 3;
|
|
4612
4488
|
break;
|
|
4613
4489
|
}
|
|
4614
|
-
return
|
|
4490
|
+
return _context27.abrupt("return", tempOrder.products);
|
|
4615
4491
|
case 3:
|
|
4616
4492
|
productsBeforeRemove = tempOrder.products || [];
|
|
4617
4493
|
bookingsBeforeRemove = tempOrder.bookings || [];
|
|
4494
|
+
preserveDisplayPosition = options === null || options === void 0 ? void 0 : options.preserveDisplayPosition;
|
|
4495
|
+
anchorIndex = preserveDisplayPosition ? productsBeforeRemove.findIndex(function (item) {
|
|
4496
|
+
var _item$metadata6;
|
|
4497
|
+
var uid = ((_item$metadata6 = item.metadata) === null || _item$metadata6 === void 0 ? void 0 : _item$metadata6.unique_identification_number) || item.unique_identification_number;
|
|
4498
|
+
return uid !== undefined && uid !== null && String(uid) === String(preserveDisplayPosition.anchorProductUid);
|
|
4499
|
+
}) : -1;
|
|
4500
|
+
productsAfterAnchor = anchorIndex >= 0 ? productsBeforeRemove.slice(anchorIndex + 1) : [];
|
|
4618
4501
|
matchedProducts = productsBeforeRemove.filter(function (item) {
|
|
4619
4502
|
return identities.some(function (identity) {
|
|
4620
4503
|
return isIdentityMatch(item, identity);
|
|
@@ -4634,29 +4517,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4634
4517
|
}
|
|
4635
4518
|
linkedBookingUidsToRemove = new Set();
|
|
4636
4519
|
_iterator21 = _createForOfIteratorHelper(matchedProducts);
|
|
4637
|
-
|
|
4520
|
+
_context27.prev = 14;
|
|
4638
4521
|
_loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
|
|
4639
4522
|
var _metadata11, _metadata12, _metadata13, _metadata14;
|
|
4640
4523
|
var product, productUid, productBookingUid, isAddTimeProduct;
|
|
4641
|
-
return _regeneratorRuntime().wrap(function _loop3$(
|
|
4642
|
-
while (1) switch (
|
|
4524
|
+
return _regeneratorRuntime().wrap(function _loop3$(_context26) {
|
|
4525
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
4643
4526
|
case 0:
|
|
4644
4527
|
product = _step21.value;
|
|
4645
4528
|
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);
|
|
4646
4529
|
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);
|
|
4647
4530
|
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;
|
|
4648
4531
|
if (!isAddTimeProduct) {
|
|
4649
|
-
|
|
4532
|
+
_context26.next = 6;
|
|
4650
4533
|
break;
|
|
4651
4534
|
}
|
|
4652
|
-
return
|
|
4535
|
+
return _context26.abrupt("return", 1);
|
|
4653
4536
|
case 6:
|
|
4654
4537
|
if (productBookingUid !== undefined && productBookingUid !== null && productBookingUid !== '') {
|
|
4655
4538
|
linkedBookingUidsToRemove.add(String(productBookingUid));
|
|
4656
4539
|
}
|
|
4657
4540
|
if (productUid !== undefined && productUid !== null && productUid !== '') {
|
|
4658
4541
|
bookingsBeforeRemove.forEach(function (booking) {
|
|
4659
|
-
var bookingUid =
|
|
4542
|
+
var bookingUid = _this26.getBookingUniqueIdentificationNumber(booking);
|
|
4660
4543
|
if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
|
|
4661
4544
|
linkedBookingUidsToRemove.add(bookingUid);
|
|
4662
4545
|
}
|
|
@@ -4664,61 +4547,77 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4664
4547
|
}
|
|
4665
4548
|
case 8:
|
|
4666
4549
|
case "end":
|
|
4667
|
-
return
|
|
4550
|
+
return _context26.stop();
|
|
4668
4551
|
}
|
|
4669
4552
|
}, _loop3);
|
|
4670
4553
|
});
|
|
4671
4554
|
_iterator21.s();
|
|
4672
|
-
case
|
|
4555
|
+
case 17:
|
|
4673
4556
|
if ((_step21 = _iterator21.n()).done) {
|
|
4674
|
-
|
|
4557
|
+
_context27.next = 23;
|
|
4675
4558
|
break;
|
|
4676
4559
|
}
|
|
4677
|
-
return
|
|
4678
|
-
case
|
|
4679
|
-
if (!
|
|
4680
|
-
|
|
4560
|
+
return _context27.delegateYield(_loop3(), "t0", 19);
|
|
4561
|
+
case 19:
|
|
4562
|
+
if (!_context27.t0) {
|
|
4563
|
+
_context27.next = 21;
|
|
4681
4564
|
break;
|
|
4682
4565
|
}
|
|
4683
|
-
return
|
|
4684
|
-
case
|
|
4685
|
-
|
|
4566
|
+
return _context27.abrupt("continue", 21);
|
|
4567
|
+
case 21:
|
|
4568
|
+
_context27.next = 17;
|
|
4686
4569
|
break;
|
|
4687
|
-
case
|
|
4688
|
-
|
|
4570
|
+
case 23:
|
|
4571
|
+
_context27.next = 28;
|
|
4689
4572
|
break;
|
|
4690
|
-
case 22:
|
|
4691
|
-
_context30.prev = 22;
|
|
4692
|
-
_context30.t1 = _context30["catch"](11);
|
|
4693
|
-
_iterator21.e(_context30.t1);
|
|
4694
4573
|
case 25:
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
|
|
4574
|
+
_context27.prev = 25;
|
|
4575
|
+
_context27.t1 = _context27["catch"](14);
|
|
4576
|
+
_iterator21.e(_context27.t1);
|
|
4698
4577
|
case 28:
|
|
4578
|
+
_context27.prev = 28;
|
|
4579
|
+
_iterator21.f();
|
|
4580
|
+
return _context27.finish(28);
|
|
4581
|
+
case 31:
|
|
4699
4582
|
if (linkedBookingUidsToRemove.size > 0) {
|
|
4700
4583
|
// 删除主预约商品时,同步移除挂在同一 booking_uid 下的加时商品,避免残留孤儿行。
|
|
4701
4584
|
tempOrder.products = (tempOrder.products || []).filter(function (line) {
|
|
4702
|
-
var _line$
|
|
4703
|
-
var lineBookingUid = (line === null || line === void 0 || (_line$
|
|
4704
|
-
var isAddTimeProduct = (line === null || line === void 0 || (_line$
|
|
4585
|
+
var _line$metadata2, _line$metadata3, _line$metadata4;
|
|
4586
|
+
var lineBookingUid = (line === null || line === void 0 || (_line$metadata2 = line.metadata) === null || _line$metadata2 === void 0 ? void 0 : _line$metadata2.booking_uid) || (line === null || line === void 0 ? void 0 : line.booking_uid);
|
|
4587
|
+
var isAddTimeProduct = (line === null || line === void 0 || (_line$metadata3 = line.metadata) === null || _line$metadata3 === void 0 ? void 0 : _line$metadata3.product_add_schedule_time) !== undefined && (line === null || line === void 0 || (_line$metadata4 = line.metadata) === null || _line$metadata4 === void 0 ? void 0 : _line$metadata4.product_add_schedule_time) !== null;
|
|
4705
4588
|
return !(isAddTimeProduct && lineBookingUid !== undefined && lineBookingUid !== null && linkedBookingUidsToRemove.has(String(lineBookingUid)));
|
|
4706
4589
|
});
|
|
4707
4590
|
}
|
|
4708
|
-
|
|
4591
|
+
if (preserveDisplayPosition && anchorIndex >= 0) {
|
|
4592
|
+
remainingProductIndex = tempOrder.products.findIndex(function (item) {
|
|
4593
|
+
var _item$metadata7;
|
|
4594
|
+
var uid = ((_item$metadata7 = item.metadata) === null || _item$metadata7 === void 0 ? void 0 : _item$metadata7.unique_identification_number) || item.unique_identification_number;
|
|
4595
|
+
return uid !== undefined && uid !== null && String(uid) === String(preserveDisplayPosition.remainingProductUid);
|
|
4596
|
+
});
|
|
4597
|
+
if (remainingProductIndex >= 0) {
|
|
4598
|
+
remainingProduct = tempOrder.products[remainingProductIndex];
|
|
4599
|
+
nextProduct = productsAfterAnchor.find(function (item) {
|
|
4600
|
+
return tempOrder.products.includes(item);
|
|
4601
|
+
});
|
|
4602
|
+
productsWithoutRemaining = [].concat(_toConsumableArray(tempOrder.products.slice(0, remainingProductIndex)), _toConsumableArray(tempOrder.products.slice(remainingProductIndex + 1)));
|
|
4603
|
+
nextProductIndex = nextProduct ? productsWithoutRemaining.indexOf(nextProduct) : -1;
|
|
4604
|
+
tempOrder.products = nextProductIndex >= 0 ? [].concat(_toConsumableArray(productsWithoutRemaining.slice(0, nextProductIndex)), [remainingProduct], _toConsumableArray(productsWithoutRemaining.slice(nextProductIndex))) : [].concat(_toConsumableArray(productsWithoutRemaining), [remainingProduct]);
|
|
4605
|
+
}
|
|
4606
|
+
}
|
|
4607
|
+
_context27.next = 35;
|
|
4709
4608
|
return this.finalizeAfterProductsMutation(tempOrder);
|
|
4710
|
-
case
|
|
4609
|
+
case 35:
|
|
4711
4610
|
this.logInfo('removeProductsFromOrder success', {
|
|
4712
4611
|
identities: identities
|
|
4713
4612
|
});
|
|
4714
|
-
return
|
|
4715
|
-
case
|
|
4613
|
+
return _context27.abrupt("return", tempOrder.products);
|
|
4614
|
+
case 37:
|
|
4716
4615
|
case "end":
|
|
4717
|
-
return
|
|
4616
|
+
return _context27.stop();
|
|
4718
4617
|
}
|
|
4719
|
-
},
|
|
4618
|
+
}, _callee24, this, [[14, 25, 28, 31]]);
|
|
4720
4619
|
}));
|
|
4721
|
-
function removeProductsFromOrder(
|
|
4620
|
+
function removeProductsFromOrder(_x31, _x32) {
|
|
4722
4621
|
return _removeProductsFromOrder.apply(this, arguments);
|
|
4723
4622
|
}
|
|
4724
4623
|
return removeProductsFromOrder;
|
|
@@ -4726,18 +4625,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4726
4625
|
}, {
|
|
4727
4626
|
key: "removeProductFromOrder",
|
|
4728
4627
|
value: function () {
|
|
4729
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4730
|
-
return _regeneratorRuntime().wrap(function
|
|
4731
|
-
while (1) switch (
|
|
4628
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(identity, options) {
|
|
4629
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context28) {
|
|
4630
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
4732
4631
|
case 0:
|
|
4733
|
-
return
|
|
4632
|
+
return _context28.abrupt("return", this.removeProductsFromOrder([identity], options));
|
|
4734
4633
|
case 1:
|
|
4735
4634
|
case "end":
|
|
4736
|
-
return
|
|
4635
|
+
return _context28.stop();
|
|
4737
4636
|
}
|
|
4738
|
-
},
|
|
4637
|
+
}, _callee25, this);
|
|
4739
4638
|
}));
|
|
4740
|
-
function removeProductFromOrder(
|
|
4639
|
+
function removeProductFromOrder(_x33, _x34) {
|
|
4741
4640
|
return _removeProductFromOrder.apply(this, arguments);
|
|
4742
4641
|
}
|
|
4743
4642
|
return removeProductFromOrder;
|
|
@@ -4749,10 +4648,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4749
4648
|
}, {
|
|
4750
4649
|
key: "clearOrderCartLines",
|
|
4751
4650
|
value: (function () {
|
|
4752
|
-
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4651
|
+
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
|
|
4753
4652
|
var tempOrder;
|
|
4754
|
-
return _regeneratorRuntime().wrap(function
|
|
4755
|
-
while (1) switch (
|
|
4653
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context29) {
|
|
4654
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
4756
4655
|
case 0:
|
|
4757
4656
|
tempOrder = this.ensureTempOrder();
|
|
4758
4657
|
tempOrder.products = [];
|
|
@@ -4763,24 +4662,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4763
4662
|
productsByUid: {}
|
|
4764
4663
|
});
|
|
4765
4664
|
}
|
|
4766
|
-
|
|
4665
|
+
_context29.next = 7;
|
|
4767
4666
|
return this.applyPromotion();
|
|
4768
4667
|
case 7:
|
|
4769
4668
|
this.applyDiscount();
|
|
4770
4669
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4771
|
-
|
|
4670
|
+
_context29.next = 11;
|
|
4772
4671
|
return this.recalculateSummary({
|
|
4773
4672
|
createIfMissing: true
|
|
4774
4673
|
});
|
|
4775
4674
|
case 11:
|
|
4776
4675
|
this.persistTempOrder();
|
|
4777
4676
|
this.logInfo('clearOrderCartLines success', {});
|
|
4778
|
-
return
|
|
4677
|
+
return _context29.abrupt("return", tempOrder);
|
|
4779
4678
|
case 14:
|
|
4780
4679
|
case "end":
|
|
4781
|
-
return
|
|
4680
|
+
return _context29.stop();
|
|
4782
4681
|
}
|
|
4783
|
-
},
|
|
4682
|
+
}, _callee26, this);
|
|
4784
4683
|
}));
|
|
4785
4684
|
function clearOrderCartLines() {
|
|
4786
4685
|
return _clearOrderCartLines.apply(this, arguments);
|
|
@@ -4818,17 +4717,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4818
4717
|
}, {
|
|
4819
4718
|
key: "applyLocalPrintOrderNumbers",
|
|
4820
4719
|
value: function () {
|
|
4821
|
-
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4720
|
+
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(order) {
|
|
4822
4721
|
var tempOrder, shopOrderNumber, shopFullOrderNumber;
|
|
4823
|
-
return _regeneratorRuntime().wrap(function
|
|
4824
|
-
while (1) switch (
|
|
4722
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context30) {
|
|
4723
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
4825
4724
|
case 0:
|
|
4826
4725
|
tempOrder = this.ensureTempOrder();
|
|
4827
4726
|
if (!(!order || _typeof(order) !== 'object')) {
|
|
4828
|
-
|
|
4727
|
+
_context30.next = 3;
|
|
4829
4728
|
break;
|
|
4830
4729
|
}
|
|
4831
|
-
return
|
|
4730
|
+
return _context30.abrupt("return", tempOrder);
|
|
4832
4731
|
case 3:
|
|
4833
4732
|
shopOrderNumber = order.shop_order_number;
|
|
4834
4733
|
shopFullOrderNumber = order.shop_full_order_number;
|
|
@@ -4839,88 +4738,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4839
4738
|
tempOrder.shop_full_order_number = String(shopFullOrderNumber);
|
|
4840
4739
|
}
|
|
4841
4740
|
this.persistTempOrder();
|
|
4842
|
-
|
|
4741
|
+
_context30.next = 10;
|
|
4843
4742
|
return this.saveDraft();
|
|
4844
4743
|
case 10:
|
|
4845
|
-
return
|
|
4744
|
+
return _context30.abrupt("return", tempOrder);
|
|
4846
4745
|
case 11:
|
|
4847
4746
|
case "end":
|
|
4848
|
-
return
|
|
4747
|
+
return _context30.stop();
|
|
4849
4748
|
}
|
|
4850
|
-
},
|
|
4749
|
+
}, _callee27, this);
|
|
4851
4750
|
}));
|
|
4852
|
-
function applyLocalPrintOrderNumbers(
|
|
4751
|
+
function applyLocalPrintOrderNumbers(_x35) {
|
|
4853
4752
|
return _applyLocalPrintOrderNumbers.apply(this, arguments);
|
|
4854
4753
|
}
|
|
4855
4754
|
return applyLocalPrintOrderNumbers;
|
|
4856
4755
|
}()
|
|
4857
|
-
}, {
|
|
4858
|
-
key: "saveTempOrderAsDraft",
|
|
4859
|
-
value: function () {
|
|
4860
|
-
var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
|
|
4861
|
-
var _params$cacheId2, _this$otherParams6, _ref74, _params$businessCode2, _this$otherParams7, _this$otherParams8, _params$type, _this$otherParams9, _payload$products;
|
|
4862
|
-
var tempOrder, latestSummary, payload;
|
|
4863
|
-
return _regeneratorRuntime().wrap(function _callee31$(_context34) {
|
|
4864
|
-
while (1) switch (_context34.prev = _context34.next) {
|
|
4865
|
-
case 0:
|
|
4866
|
-
tempOrder = this.ensureTempOrder();
|
|
4867
|
-
this.ensureExternalSaleNumber(tempOrder);
|
|
4868
|
-
this.persistTempOrder();
|
|
4869
|
-
_context34.next = 5;
|
|
4870
|
-
return this.recalculateSummary({
|
|
4871
|
-
createIfMissing: true
|
|
4872
|
-
});
|
|
4873
|
-
case 5:
|
|
4874
|
-
_context34.t1 = _context34.sent;
|
|
4875
|
-
if (_context34.t1) {
|
|
4876
|
-
_context34.next = 8;
|
|
4877
|
-
break;
|
|
4878
|
-
}
|
|
4879
|
-
_context34.t1 = this.store.summary;
|
|
4880
|
-
case 8:
|
|
4881
|
-
_context34.t0 = _context34.t1;
|
|
4882
|
-
if (_context34.t0) {
|
|
4883
|
-
_context34.next = 11;
|
|
4884
|
-
break;
|
|
4885
|
-
}
|
|
4886
|
-
_context34.t0 = createEmptySummary();
|
|
4887
|
-
case 11:
|
|
4888
|
-
latestSummary = _context34.t0;
|
|
4889
|
-
payload = buildSubmitPayload({
|
|
4890
|
-
tempOrder: tempOrder,
|
|
4891
|
-
cacheId: (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId,
|
|
4892
|
-
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform),
|
|
4893
|
-
businessCode: (_ref74 = (_params$businessCode2 = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode2 !== void 0 ? _params$businessCode2 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.businessCode) !== null && _ref74 !== void 0 ? _ref74 : (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.business_code,
|
|
4894
|
-
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
4895
|
-
type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.type,
|
|
4896
|
-
summary: latestSummary,
|
|
4897
|
-
enhance: params === null || params === void 0 ? void 0 : params.enhancePayload
|
|
4898
|
-
});
|
|
4899
|
-
if (!payload.created_at) {
|
|
4900
|
-
payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
4901
|
-
}
|
|
4902
|
-
payload.need_sync = 0;
|
|
4903
|
-
payload.is_draft_order = 1;
|
|
4904
|
-
this.logInfo('saveTempOrderAsDraft calling sales draft', {
|
|
4905
|
-
orderId: payload.order_id,
|
|
4906
|
-
externalSaleNumber: payload.external_sale_number,
|
|
4907
|
-
productsCount: ((_payload$products = payload.products) === null || _payload$products === void 0 ? void 0 : _payload$products.length) || 0
|
|
4908
|
-
});
|
|
4909
|
-
return _context34.abrupt("return", this.request.post('/order/sales/draft', payload, {
|
|
4910
|
-
osServer: true,
|
|
4911
|
-
customToast: function customToast() {}
|
|
4912
|
-
}));
|
|
4913
|
-
case 18:
|
|
4914
|
-
case "end":
|
|
4915
|
-
return _context34.stop();
|
|
4916
|
-
}
|
|
4917
|
-
}, _callee31, this);
|
|
4918
|
-
}));
|
|
4919
|
-
function saveTempOrderAsDraft(_x37) {
|
|
4920
|
-
return _saveTempOrderAsDraft.apply(this, arguments);
|
|
4921
|
-
}
|
|
4922
|
-
return saveTempOrderAsDraft;
|
|
4923
|
-
}()
|
|
4924
4756
|
/**
|
|
4925
4757
|
* 提交当前 Sales tempOrder。
|
|
4926
4758
|
*
|
|
@@ -4930,18 +4762,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4930
4762
|
}, {
|
|
4931
4763
|
key: "submitTempOrder",
|
|
4932
4764
|
value: (function () {
|
|
4933
|
-
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4934
|
-
return _regeneratorRuntime().wrap(function
|
|
4935
|
-
while (1) switch (
|
|
4765
|
+
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
|
|
4766
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context31) {
|
|
4767
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
4936
4768
|
case 0:
|
|
4937
|
-
return
|
|
4769
|
+
return _context31.abrupt("return", this.runSubmitTempOrder(params));
|
|
4938
4770
|
case 1:
|
|
4939
4771
|
case "end":
|
|
4940
|
-
return
|
|
4772
|
+
return _context31.stop();
|
|
4941
4773
|
}
|
|
4942
|
-
},
|
|
4774
|
+
}, _callee28, this);
|
|
4943
4775
|
}));
|
|
4944
|
-
function submitTempOrder(
|
|
4776
|
+
function submitTempOrder(_x36) {
|
|
4945
4777
|
return _submitTempOrder.apply(this, arguments);
|
|
4946
4778
|
}
|
|
4947
4779
|
return submitTempOrder;
|
|
@@ -4949,20 +4781,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4949
4781
|
}, {
|
|
4950
4782
|
key: "submitTempOrderAsync",
|
|
4951
4783
|
value: function () {
|
|
4952
|
-
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4953
|
-
return _regeneratorRuntime().wrap(function
|
|
4954
|
-
while (1) switch (
|
|
4784
|
+
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
|
|
4785
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context32) {
|
|
4786
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
4955
4787
|
case 0:
|
|
4956
|
-
return
|
|
4788
|
+
return _context32.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
4957
4789
|
syncMode: true
|
|
4958
4790
|
})));
|
|
4959
4791
|
case 1:
|
|
4960
4792
|
case "end":
|
|
4961
|
-
return
|
|
4793
|
+
return _context32.stop();
|
|
4962
4794
|
}
|
|
4963
|
-
},
|
|
4795
|
+
}, _callee29, this);
|
|
4964
4796
|
}));
|
|
4965
|
-
function submitTempOrderAsync(
|
|
4797
|
+
function submitTempOrderAsync(_x37) {
|
|
4966
4798
|
return _submitTempOrderAsync.apply(this, arguments);
|
|
4967
4799
|
}
|
|
4968
4800
|
return submitTempOrderAsync;
|
|
@@ -4970,11 +4802,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4970
4802
|
}, {
|
|
4971
4803
|
key: "runSubmitTempOrder",
|
|
4972
4804
|
value: function () {
|
|
4973
|
-
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4974
|
-
var _params$
|
|
4805
|
+
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
|
|
4806
|
+
var _params$cacheId2, _this$otherParams6, _ref74, _ref75, _submitSnapshot$busin, _this$otherParams7, _this$otherParams8, _submitSnapshot$type;
|
|
4975
4807
|
var tempOrder, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
|
|
4976
|
-
return _regeneratorRuntime().wrap(function
|
|
4977
|
-
while (1) switch (
|
|
4808
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context33) {
|
|
4809
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
4978
4810
|
case 0:
|
|
4979
4811
|
tempOrder = this.ensureTempOrder();
|
|
4980
4812
|
shouldConfirmPendingVoucherPayments = (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== false;
|
|
@@ -4994,27 +4826,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4994
4826
|
}
|
|
4995
4827
|
}
|
|
4996
4828
|
this.persistTempOrder();
|
|
4997
|
-
|
|
4829
|
+
_context33.next = 8;
|
|
4998
4830
|
return this.recalculateSummary({
|
|
4999
4831
|
createIfMissing: true
|
|
5000
4832
|
});
|
|
5001
4833
|
case 8:
|
|
5002
|
-
|
|
5003
|
-
if (
|
|
5004
|
-
|
|
4834
|
+
_context33.t1 = _context33.sent;
|
|
4835
|
+
if (_context33.t1) {
|
|
4836
|
+
_context33.next = 11;
|
|
5005
4837
|
break;
|
|
5006
4838
|
}
|
|
5007
|
-
|
|
4839
|
+
_context33.t1 = this.store.summary;
|
|
5008
4840
|
case 11:
|
|
5009
|
-
|
|
5010
|
-
if (
|
|
5011
|
-
|
|
4841
|
+
_context33.t0 = _context33.t1;
|
|
4842
|
+
if (_context33.t0) {
|
|
4843
|
+
_context33.next = 14;
|
|
5012
4844
|
break;
|
|
5013
4845
|
}
|
|
5014
|
-
|
|
4846
|
+
_context33.t0 = createEmptySummary();
|
|
5015
4847
|
case 14:
|
|
5016
|
-
latestSummary =
|
|
5017
|
-
effectiveCacheId = (_params$
|
|
4848
|
+
latestSummary = _context33.t0;
|
|
4849
|
+
effectiveCacheId = (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId;
|
|
5018
4850
|
hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
|
|
5019
4851
|
hasSmallTicketDataFlagOverride = (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined;
|
|
5020
4852
|
enhancePayload = hasPaymentOverride || hasPaymentStatusOverride || hasSmallTicketDataFlagOverride || params !== null && params !== void 0 && params.enhancePayload ? function (payload, ctx) {
|
|
@@ -5032,8 +4864,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5032
4864
|
payload = buildSubmitPayload({
|
|
5033
4865
|
tempOrder: tempOrder,
|
|
5034
4866
|
cacheId: effectiveCacheId,
|
|
5035
|
-
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$
|
|
5036
|
-
businessCode: (
|
|
4867
|
+
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform),
|
|
4868
|
+
businessCode: (_ref74 = (_ref75 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref75 !== void 0 ? _ref75 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.businessCode) !== null && _ref74 !== void 0 ? _ref74 : (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.business_code,
|
|
5037
4869
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
5038
4870
|
type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
|
|
5039
4871
|
summary: latestSummary,
|
|
@@ -5048,10 +4880,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5048
4880
|
if (!payload.created_at) {
|
|
5049
4881
|
payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
5050
4882
|
}
|
|
5051
|
-
|
|
4883
|
+
_context33.next = 26;
|
|
5052
4884
|
return this.saveDraft();
|
|
5053
4885
|
case 26:
|
|
5054
|
-
|
|
4886
|
+
_context33.prev = 26;
|
|
5055
4887
|
this.logInfo('submitTempOrder calling sales checkout', {
|
|
5056
4888
|
orderId: payload.order_id,
|
|
5057
4889
|
externalSaleNumber: payload.external_sale_number,
|
|
@@ -5061,43 +4893,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5061
4893
|
smallTicketDataFlag: payload.small_ticket_data_flag,
|
|
5062
4894
|
syncMode: payload.sync_mode
|
|
5063
4895
|
});
|
|
5064
|
-
|
|
4896
|
+
_context33.next = 30;
|
|
5065
4897
|
return this.submitSalesOrder({
|
|
5066
4898
|
query: payload
|
|
5067
4899
|
});
|
|
5068
4900
|
case 30:
|
|
5069
|
-
result =
|
|
5070
|
-
|
|
4901
|
+
result = _context33.sent;
|
|
4902
|
+
_context33.next = 43;
|
|
5071
4903
|
break;
|
|
5072
4904
|
case 33:
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
backendErrorResponse = this.extractSubmitErrorResponse(
|
|
4905
|
+
_context33.prev = 33;
|
|
4906
|
+
_context33.t2 = _context33["catch"](26);
|
|
4907
|
+
backendErrorResponse = this.extractSubmitErrorResponse(_context33.t2);
|
|
5076
4908
|
if (!backendErrorResponse) {
|
|
5077
|
-
|
|
4909
|
+
_context33.next = 40;
|
|
5078
4910
|
break;
|
|
5079
4911
|
}
|
|
5080
4912
|
this.store.syncState = 'failed';
|
|
5081
4913
|
this.logSubmitBackendRejected(backendErrorResponse, payload);
|
|
5082
|
-
return
|
|
4914
|
+
return _context33.abrupt("return", backendErrorResponse);
|
|
5083
4915
|
case 40:
|
|
5084
4916
|
this.store.syncState = 'failed';
|
|
5085
4917
|
this.logError('submitTempOrder failed', {
|
|
5086
|
-
error:
|
|
4918
|
+
error: _context33.t2 instanceof Error ? _context33.t2.message : String(_context33.t2),
|
|
5087
4919
|
orderId: payload.order_id,
|
|
5088
4920
|
externalSaleNumber: payload.external_sale_number,
|
|
5089
4921
|
paymentStatus: payload.payment_status,
|
|
5090
4922
|
paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
|
|
5091
4923
|
});
|
|
5092
|
-
throw
|
|
4924
|
+
throw _context33.t2;
|
|
5093
4925
|
case 43:
|
|
5094
4926
|
if (!this.isSubmitResponseRejected(result)) {
|
|
5095
|
-
|
|
4927
|
+
_context33.next = 47;
|
|
5096
4928
|
break;
|
|
5097
4929
|
}
|
|
5098
4930
|
this.store.syncState = 'failed';
|
|
5099
4931
|
this.logSubmitBackendRejected(result, payload);
|
|
5100
|
-
return
|
|
4932
|
+
return _context33.abrupt("return", result);
|
|
5101
4933
|
case 47:
|
|
5102
4934
|
submittedOrderId = this.extractOrderIdFromSubmitResult(result);
|
|
5103
4935
|
this.logInfo('runSubmitTempOrder: 提交成功', {
|
|
@@ -5108,15 +4940,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5108
4940
|
})
|
|
5109
4941
|
});
|
|
5110
4942
|
if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
|
|
5111
|
-
|
|
4943
|
+
_context33.next = 56;
|
|
5112
4944
|
break;
|
|
5113
4945
|
}
|
|
5114
4946
|
tempOrder.order_id = submittedOrderId;
|
|
5115
4947
|
resultRecord = result;
|
|
5116
|
-
|
|
4948
|
+
_context33.next = 54;
|
|
5117
4949
|
return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
|
|
5118
4950
|
case 54:
|
|
5119
|
-
|
|
4951
|
+
_context33.next = 57;
|
|
5120
4952
|
break;
|
|
5121
4953
|
case 56:
|
|
5122
4954
|
if (this.isLocalPendingSubmitResult(result)) {
|
|
@@ -5125,14 +4957,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5125
4957
|
this.store.syncState = 'submitted';
|
|
5126
4958
|
}
|
|
5127
4959
|
case 57:
|
|
5128
|
-
return
|
|
4960
|
+
return _context33.abrupt("return", result);
|
|
5129
4961
|
case 58:
|
|
5130
4962
|
case "end":
|
|
5131
|
-
return
|
|
4963
|
+
return _context33.stop();
|
|
5132
4964
|
}
|
|
5133
|
-
},
|
|
4965
|
+
}, _callee30, this, [[26, 33]]);
|
|
5134
4966
|
}));
|
|
5135
|
-
function runSubmitTempOrder(
|
|
4967
|
+
function runSubmitTempOrder(_x38) {
|
|
5136
4968
|
return _runSubmitTempOrder.apply(this, arguments);
|
|
5137
4969
|
}
|
|
5138
4970
|
return runSubmitTempOrder;
|
|
@@ -5140,10 +4972,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5140
4972
|
}, {
|
|
5141
4973
|
key: "markLocalOrderSynced",
|
|
5142
4974
|
value: function () {
|
|
5143
|
-
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4975
|
+
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(orderId, remoteOrder) {
|
|
5144
4976
|
var tempOrder;
|
|
5145
|
-
return _regeneratorRuntime().wrap(function
|
|
5146
|
-
while (1) switch (
|
|
4977
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context34) {
|
|
4978
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
5147
4979
|
case 0:
|
|
5148
4980
|
tempOrder = this.ensureTempOrder();
|
|
5149
4981
|
tempOrder.order_id = orderId;
|
|
@@ -5151,15 +4983,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5151
4983
|
this.store.lastOrderInfo = remoteOrder;
|
|
5152
4984
|
this.store.syncState = 'submitted';
|
|
5153
4985
|
this.persistTempOrder();
|
|
5154
|
-
|
|
4986
|
+
_context34.next = 8;
|
|
5155
4987
|
return this.saveDraft();
|
|
5156
4988
|
case 8:
|
|
5157
4989
|
case "end":
|
|
5158
|
-
return
|
|
4990
|
+
return _context34.stop();
|
|
5159
4991
|
}
|
|
5160
|
-
},
|
|
4992
|
+
}, _callee31, this);
|
|
5161
4993
|
}));
|
|
5162
|
-
function markLocalOrderSynced(
|
|
4994
|
+
function markLocalOrderSynced(_x39, _x40) {
|
|
5163
4995
|
return _markLocalOrderSynced.apply(this, arguments);
|
|
5164
4996
|
}
|
|
5165
4997
|
return markLocalOrderSynced;
|
|
@@ -5202,10 +5034,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5202
5034
|
value: function extractSubmitErrorResponse(error) {
|
|
5203
5035
|
var _error$response,
|
|
5204
5036
|
_error$response2,
|
|
5205
|
-
|
|
5037
|
+
_this27 = this;
|
|
5206
5038
|
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];
|
|
5207
5039
|
return candidates.find(function (candidate) {
|
|
5208
|
-
return
|
|
5040
|
+
return _this27.isSubmitErrorResponse(candidate);
|
|
5209
5041
|
}) || null;
|
|
5210
5042
|
}
|
|
5211
5043
|
}, {
|
|
@@ -5232,37 +5064,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5232
5064
|
}, {
|
|
5233
5065
|
key: "syncPaymentsToOrder",
|
|
5234
5066
|
value: function () {
|
|
5235
|
-
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5236
|
-
var
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
while (1) switch (_context39.prev = _context39.next) {
|
|
5067
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
|
|
5068
|
+
var _params$confirmPendin;
|
|
5069
|
+
var tempOrder, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, submitResult;
|
|
5070
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context35) {
|
|
5071
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
5241
5072
|
case 0:
|
|
5242
5073
|
tempOrder = this.ensureTempOrder();
|
|
5243
|
-
|
|
5244
|
-
return String(payment.payment_number || '').trim() === '';
|
|
5245
|
-
});
|
|
5246
|
-
if (!needsPaymentNumber) {
|
|
5247
|
-
_context39.next = 8;
|
|
5248
|
-
break;
|
|
5249
|
-
}
|
|
5250
|
-
_context39.next = 5;
|
|
5251
|
-
return this.getPaymentNumberDevicePrefixAsync();
|
|
5252
|
-
case 5:
|
|
5253
|
-
_context39.t0 = _context39.sent;
|
|
5254
|
-
_context39.next = 9;
|
|
5255
|
-
break;
|
|
5256
|
-
case 8:
|
|
5257
|
-
_context39.t0 = 'LOCAL';
|
|
5258
|
-
case 9:
|
|
5259
|
-
devicePrefix = _context39.t0;
|
|
5260
|
-
mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
|
|
5261
|
-
return _this31.normalizePaymentSource(payment, {
|
|
5262
|
-
defaultPaid: false,
|
|
5263
|
-
devicePrefix: devicePrefix
|
|
5264
|
-
});
|
|
5265
|
-
}));
|
|
5074
|
+
mappedPayments = mapPaymentItemsToOrderPayments(params.payments || []);
|
|
5266
5075
|
shouldConfirmPendingVoucherPayments = (_params$confirmPendin = params.confirmPendingVoucherPayments) !== null && _params$confirmPendin !== void 0 ? _params$confirmPendin : params.submitWhenPaid === true;
|
|
5267
5076
|
effectivePayments = shouldConfirmPendingVoucherPayments ? this.confirmPendingVoucherPaymentsInList(mappedPayments) : params.confirmPendingVoucherPayments === false ? this.discardPendingVoucherPaymentsFromList(mappedPayments) : mappedPayments;
|
|
5268
5077
|
completion = this.getPaymentCompletion(effectivePayments);
|
|
@@ -5271,24 +5080,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5271
5080
|
tempOrder.payments = effectivePayments;
|
|
5272
5081
|
tempOrder.payment_status = paymentStatus;
|
|
5273
5082
|
this.persistTempOrder();
|
|
5274
|
-
|
|
5083
|
+
_context35.next = 12;
|
|
5275
5084
|
return this.saveDraft();
|
|
5276
|
-
case
|
|
5085
|
+
case 12:
|
|
5277
5086
|
if (params.submitWhenPaid) {
|
|
5278
|
-
|
|
5087
|
+
_context35.next = 14;
|
|
5279
5088
|
break;
|
|
5280
5089
|
}
|
|
5281
|
-
return
|
|
5282
|
-
case
|
|
5090
|
+
return _context35.abrupt("return", completion);
|
|
5091
|
+
case 14:
|
|
5283
5092
|
if (!(this.store.syncState === 'submitting')) {
|
|
5284
|
-
|
|
5093
|
+
_context35.next = 16;
|
|
5285
5094
|
break;
|
|
5286
5095
|
}
|
|
5287
|
-
return
|
|
5288
|
-
case
|
|
5096
|
+
return _context35.abrupt("return", completion);
|
|
5097
|
+
case 16:
|
|
5289
5098
|
this.store.syncState = 'submitting';
|
|
5290
5099
|
paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, effectivePayments);
|
|
5291
|
-
|
|
5100
|
+
_context35.next = 20;
|
|
5292
5101
|
return this.submitTempOrder({
|
|
5293
5102
|
payments: effectivePayments,
|
|
5294
5103
|
paymentStatus: paymentStatus,
|
|
@@ -5303,18 +5112,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5303
5112
|
return nextPayload;
|
|
5304
5113
|
}
|
|
5305
5114
|
});
|
|
5306
|
-
case
|
|
5307
|
-
submitResult =
|
|
5308
|
-
return
|
|
5115
|
+
case 20:
|
|
5116
|
+
submitResult = _context35.sent;
|
|
5117
|
+
return _context35.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
|
|
5309
5118
|
submitResult: submitResult
|
|
5310
5119
|
}));
|
|
5311
|
-
case
|
|
5120
|
+
case 22:
|
|
5312
5121
|
case "end":
|
|
5313
|
-
return
|
|
5122
|
+
return _context35.stop();
|
|
5314
5123
|
}
|
|
5315
|
-
},
|
|
5124
|
+
}, _callee32, this);
|
|
5316
5125
|
}));
|
|
5317
|
-
function syncPaymentsToOrder(
|
|
5126
|
+
function syncPaymentsToOrder(_x41) {
|
|
5318
5127
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
5319
5128
|
}
|
|
5320
5129
|
return syncPaymentsToOrder;
|
|
@@ -5403,11 +5212,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5403
5212
|
}, {
|
|
5404
5213
|
key: "submitOrder",
|
|
5405
5214
|
value: function () {
|
|
5406
|
-
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5215
|
+
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(order) {
|
|
5407
5216
|
var _order$query$cartItem, _params$bookings, _params$relation_prod;
|
|
5408
5217
|
var url, query, fetchUrl, params;
|
|
5409
|
-
return _regeneratorRuntime().wrap(function
|
|
5410
|
-
while (1) switch (
|
|
5218
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context36) {
|
|
5219
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
5411
5220
|
case 0:
|
|
5412
5221
|
this.logInfo('submitOrder called', {
|
|
5413
5222
|
url: order.url,
|
|
@@ -5427,14 +5236,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5427
5236
|
relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
|
|
5428
5237
|
scheduleDate: params.schedule_date
|
|
5429
5238
|
});
|
|
5430
|
-
return
|
|
5239
|
+
return _context36.abrupt("return", this.request.post(fetchUrl, params));
|
|
5431
5240
|
case 6:
|
|
5432
5241
|
case "end":
|
|
5433
|
-
return
|
|
5242
|
+
return _context36.stop();
|
|
5434
5243
|
}
|
|
5435
|
-
},
|
|
5244
|
+
}, _callee33, this);
|
|
5436
5245
|
}));
|
|
5437
|
-
function submitOrder(
|
|
5246
|
+
function submitOrder(_x42) {
|
|
5438
5247
|
return _submitOrder.apply(this, arguments);
|
|
5439
5248
|
}
|
|
5440
5249
|
return submitOrder;
|
|
@@ -5442,13 +5251,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5442
5251
|
}, {
|
|
5443
5252
|
key: "cancelOrder",
|
|
5444
5253
|
value: function () {
|
|
5445
|
-
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5254
|
+
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
|
|
5446
5255
|
var payload;
|
|
5447
|
-
return _regeneratorRuntime().wrap(function
|
|
5448
|
-
while (1) switch (
|
|
5256
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context37) {
|
|
5257
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
5449
5258
|
case 0:
|
|
5450
5259
|
if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
|
|
5451
|
-
|
|
5260
|
+
_context37.next = 2;
|
|
5452
5261
|
break;
|
|
5453
5262
|
}
|
|
5454
5263
|
throw new Error('取消订单失败:order_ids 不能为空');
|
|
@@ -5464,16 +5273,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5464
5273
|
method: 'PUT',
|
|
5465
5274
|
orderIdsCount: params.order_ids.length
|
|
5466
5275
|
});
|
|
5467
|
-
return
|
|
5276
|
+
return _context37.abrupt("return", this.request.put('/order/update-status', payload, {
|
|
5468
5277
|
isShopApi: true
|
|
5469
5278
|
}));
|
|
5470
5279
|
case 5:
|
|
5471
5280
|
case "end":
|
|
5472
|
-
return
|
|
5281
|
+
return _context37.stop();
|
|
5473
5282
|
}
|
|
5474
|
-
},
|
|
5283
|
+
}, _callee34, this);
|
|
5475
5284
|
}));
|
|
5476
|
-
function cancelOrder(
|
|
5285
|
+
function cancelOrder(_x43) {
|
|
5477
5286
|
return _cancelOrder.apply(this, arguments);
|
|
5478
5287
|
}
|
|
5479
5288
|
return cancelOrder;
|
|
@@ -5481,19 +5290,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5481
5290
|
}, {
|
|
5482
5291
|
key: "changeBookingStatus",
|
|
5483
5292
|
value: function () {
|
|
5484
|
-
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5293
|
+
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
|
|
5485
5294
|
var url, payload;
|
|
5486
|
-
return _regeneratorRuntime().wrap(function
|
|
5487
|
-
while (1) switch (
|
|
5295
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context38) {
|
|
5296
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
5488
5297
|
case 0:
|
|
5489
5298
|
if (params.booking_id) {
|
|
5490
|
-
|
|
5299
|
+
_context38.next = 2;
|
|
5491
5300
|
break;
|
|
5492
5301
|
}
|
|
5493
5302
|
throw new Error('变更预约状态失败:booking_id 不能为空');
|
|
5494
5303
|
case 2:
|
|
5495
5304
|
if (params.appointment_status) {
|
|
5496
|
-
|
|
5305
|
+
_context38.next = 4;
|
|
5497
5306
|
break;
|
|
5498
5307
|
}
|
|
5499
5308
|
throw new Error('变更预约状态失败:appointment_status 不能为空');
|
|
@@ -5508,16 +5317,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5508
5317
|
bookingId: params.booking_id,
|
|
5509
5318
|
appointmentStatus: params.appointment_status
|
|
5510
5319
|
});
|
|
5511
|
-
return
|
|
5320
|
+
return _context38.abrupt("return", this.request.put(url, payload, {
|
|
5512
5321
|
isShopApi: true
|
|
5513
5322
|
}));
|
|
5514
5323
|
case 8:
|
|
5515
5324
|
case "end":
|
|
5516
|
-
return
|
|
5325
|
+
return _context38.stop();
|
|
5517
5326
|
}
|
|
5518
|
-
},
|
|
5327
|
+
}, _callee35, this);
|
|
5519
5328
|
}));
|
|
5520
|
-
function changeBookingStatus(
|
|
5329
|
+
function changeBookingStatus(_x44) {
|
|
5521
5330
|
return _changeBookingStatus.apply(this, arguments);
|
|
5522
5331
|
}
|
|
5523
5332
|
return changeBookingStatus;
|
|
@@ -5535,11 +5344,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5535
5344
|
}, {
|
|
5536
5345
|
key: "createOrderByCheckout",
|
|
5537
5346
|
value: (function () {
|
|
5538
|
-
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5347
|
+
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
|
|
5539
5348
|
var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3, _params$bookings3, _params$relation_prod3, _params$payments4;
|
|
5540
5349
|
var onlineStorePaymentCodeList, _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, _orderData$bookings2, _orderData$relation_p2, _orderData$payments4, _orderData$payments5, _response$data, orderData, response;
|
|
5541
|
-
return _regeneratorRuntime().wrap(function
|
|
5542
|
-
while (1) switch (
|
|
5350
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context39) {
|
|
5351
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
5543
5352
|
case 0:
|
|
5544
5353
|
// 过滤掉由在线店铺下单的 payment 支付数据
|
|
5545
5354
|
onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
|
|
@@ -5573,7 +5382,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5573
5382
|
relationProductsCount: ((_params$relation_prod3 = params.relation_products) === null || _params$relation_prod3 === void 0 ? void 0 : _params$relation_prod3.length) || 0,
|
|
5574
5383
|
paymentsCount: ((_params$payments4 = params.payments) === null || _params$payments4 === void 0 ? void 0 : _params$payments4.length) || 0
|
|
5575
5384
|
});
|
|
5576
|
-
|
|
5385
|
+
_context39.prev = 4;
|
|
5577
5386
|
// 构建订单数据,设置默认值并允许 params 覆盖
|
|
5578
5387
|
orderData = _objectSpread({
|
|
5579
5388
|
sales_channel: 'my_pisel',
|
|
@@ -5635,13 +5444,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5635
5444
|
hasOrderId: !!orderData.order_id,
|
|
5636
5445
|
smallTicketDataFlag: orderData.small_ticket_data_flag
|
|
5637
5446
|
});
|
|
5638
|
-
|
|
5447
|
+
_context39.next = 12;
|
|
5639
5448
|
return this.request.post('/order/checkout', orderData, {
|
|
5640
5449
|
osServer: true,
|
|
5641
5450
|
customToast: function customToast() {}
|
|
5642
5451
|
});
|
|
5643
5452
|
case 12:
|
|
5644
|
-
response =
|
|
5453
|
+
response = _context39.sent;
|
|
5645
5454
|
this.logInfo('Order API called successfully', {
|
|
5646
5455
|
response: response
|
|
5647
5456
|
});
|
|
@@ -5649,22 +5458,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5649
5458
|
success: !!response,
|
|
5650
5459
|
hasOrderId: !!(response !== null && response !== void 0 && (_response$data = response.data) !== null && _response$data !== void 0 && _response$data.order_id || response !== null && response !== void 0 && response.order_id)
|
|
5651
5460
|
});
|
|
5652
|
-
return
|
|
5461
|
+
return _context39.abrupt("return", response);
|
|
5653
5462
|
case 18:
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
console.error('[Order] createOrderByCheckout 创建订单失败:',
|
|
5463
|
+
_context39.prev = 18;
|
|
5464
|
+
_context39.t0 = _context39["catch"](4);
|
|
5465
|
+
console.error('[Order] createOrderByCheckout 创建订单失败:', _context39.t0);
|
|
5657
5466
|
this.logInfo('Order API called failed', {
|
|
5658
|
-
error:
|
|
5467
|
+
error: _context39.t0 instanceof Error ? _context39.t0.message : String(_context39.t0)
|
|
5659
5468
|
});
|
|
5660
|
-
throw
|
|
5469
|
+
throw _context39.t0;
|
|
5661
5470
|
case 23:
|
|
5662
5471
|
case "end":
|
|
5663
|
-
return
|
|
5472
|
+
return _context39.stop();
|
|
5664
5473
|
}
|
|
5665
|
-
},
|
|
5474
|
+
}, _callee36, this, [[4, 18]]);
|
|
5666
5475
|
}));
|
|
5667
|
-
function createOrderByCheckout(
|
|
5476
|
+
function createOrderByCheckout(_x45) {
|
|
5668
5477
|
return _createOrderByCheckout.apply(this, arguments);
|
|
5669
5478
|
}
|
|
5670
5479
|
return createOrderByCheckout;
|
|
@@ -5672,24 +5481,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5672
5481
|
}, {
|
|
5673
5482
|
key: "submitSalesOrder",
|
|
5674
5483
|
value: function () {
|
|
5675
|
-
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5484
|
+
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
|
|
5676
5485
|
var url, query, fetchUrl;
|
|
5677
|
-
return _regeneratorRuntime().wrap(function
|
|
5678
|
-
while (1) switch (
|
|
5486
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context40) {
|
|
5487
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
5679
5488
|
case 0:
|
|
5680
5489
|
url = params.url, query = params.query;
|
|
5681
5490
|
fetchUrl = url || '/order/sales/checkout';
|
|
5682
|
-
return
|
|
5491
|
+
return _context40.abrupt("return", this.request.post(fetchUrl, query, {
|
|
5683
5492
|
osServer: true,
|
|
5684
5493
|
customToast: function customToast() {}
|
|
5685
5494
|
}));
|
|
5686
5495
|
case 3:
|
|
5687
5496
|
case "end":
|
|
5688
|
-
return
|
|
5497
|
+
return _context40.stop();
|
|
5689
5498
|
}
|
|
5690
|
-
},
|
|
5499
|
+
}, _callee37, this);
|
|
5691
5500
|
}));
|
|
5692
|
-
function submitSalesOrder(
|
|
5501
|
+
function submitSalesOrder(_x46) {
|
|
5693
5502
|
return _submitSalesOrder.apply(this, arguments);
|
|
5694
5503
|
}
|
|
5695
5504
|
return submitSalesOrder;
|
|
@@ -5703,37 +5512,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5703
5512
|
}, {
|
|
5704
5513
|
key: "sendCustomerPayLink",
|
|
5705
5514
|
value: (function () {
|
|
5706
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5515
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
|
|
5707
5516
|
var _params$emails;
|
|
5708
5517
|
var orderIds;
|
|
5709
|
-
return _regeneratorRuntime().wrap(function
|
|
5710
|
-
while (1) switch (
|
|
5518
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context41) {
|
|
5519
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
5711
5520
|
case 0:
|
|
5712
5521
|
orderIds = params.order_ids || params.orderIds || [];
|
|
5713
5522
|
if (orderIds.length) {
|
|
5714
|
-
|
|
5523
|
+
_context41.next = 3;
|
|
5715
5524
|
break;
|
|
5716
5525
|
}
|
|
5717
5526
|
throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
|
|
5718
5527
|
case 3:
|
|
5719
5528
|
if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
|
|
5720
|
-
|
|
5529
|
+
_context41.next = 5;
|
|
5721
5530
|
break;
|
|
5722
5531
|
}
|
|
5723
5532
|
throw new Error('发送支付链接需要至少一个邮箱');
|
|
5724
5533
|
case 5:
|
|
5725
|
-
return
|
|
5534
|
+
return _context41.abrupt("return", this.request.post('/order/batch-email', {
|
|
5726
5535
|
order_ids: orderIds,
|
|
5727
5536
|
notify_action: params.notify_action || 'order_payment_reminder',
|
|
5728
5537
|
emails: params.emails
|
|
5729
5538
|
}));
|
|
5730
5539
|
case 6:
|
|
5731
5540
|
case "end":
|
|
5732
|
-
return
|
|
5541
|
+
return _context41.stop();
|
|
5733
5542
|
}
|
|
5734
|
-
},
|
|
5543
|
+
}, _callee38, this);
|
|
5735
5544
|
}));
|
|
5736
|
-
function sendCustomerPayLink(
|
|
5545
|
+
function sendCustomerPayLink(_x47) {
|
|
5737
5546
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
5738
5547
|
}
|
|
5739
5548
|
return sendCustomerPayLink;
|
|
@@ -5741,14 +5550,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5741
5550
|
}, {
|
|
5742
5551
|
key: "getSalesOrderByLookup",
|
|
5743
5552
|
value: function () {
|
|
5744
|
-
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5553
|
+
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
|
|
5745
5554
|
var lookup, res;
|
|
5746
|
-
return _regeneratorRuntime().wrap(function
|
|
5747
|
-
while (1) switch (
|
|
5555
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context42) {
|
|
5556
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
5748
5557
|
case 0:
|
|
5749
5558
|
lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
|
|
5750
5559
|
if (lookup) {
|
|
5751
|
-
|
|
5560
|
+
_context42.next = 3;
|
|
5752
5561
|
break;
|
|
5753
5562
|
}
|
|
5754
5563
|
throw new Error('加载销售详情需要 lookup');
|
|
@@ -5757,7 +5566,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5757
5566
|
if (lookup.startsWith('LOCAL_')) {
|
|
5758
5567
|
params.forceRemote = false;
|
|
5759
5568
|
}
|
|
5760
|
-
|
|
5569
|
+
_context42.next = 6;
|
|
5761
5570
|
return this.request.get("/order/sales/".concat(encodeURIComponent(lookup)), _objectSpread({
|
|
5762
5571
|
with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info']
|
|
5763
5572
|
}, params.forceRemote ? {
|
|
@@ -5766,18 +5575,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5766
5575
|
osServer: true
|
|
5767
5576
|
});
|
|
5768
5577
|
case 6:
|
|
5769
|
-
res =
|
|
5578
|
+
res = _context42.sent;
|
|
5770
5579
|
if (res.code === 200) {
|
|
5771
5580
|
this.store.lastOrderInfo = res.data;
|
|
5772
5581
|
}
|
|
5773
|
-
return
|
|
5582
|
+
return _context42.abrupt("return", res);
|
|
5774
5583
|
case 9:
|
|
5775
5584
|
case "end":
|
|
5776
|
-
return
|
|
5585
|
+
return _context42.stop();
|
|
5777
5586
|
}
|
|
5778
|
-
},
|
|
5587
|
+
}, _callee39, this);
|
|
5779
5588
|
}));
|
|
5780
|
-
function getSalesOrderByLookup(
|
|
5589
|
+
function getSalesOrderByLookup(_x48) {
|
|
5781
5590
|
return _getSalesOrderByLookup.apply(this, arguments);
|
|
5782
5591
|
}
|
|
5783
5592
|
return getSalesOrderByLookup;
|
|
@@ -5791,11 +5600,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5791
5600
|
}, {
|
|
5792
5601
|
key: "hydrateTempOrderFromRecord",
|
|
5793
5602
|
value: (function () {
|
|
5794
|
-
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5603
|
+
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(record, options) {
|
|
5795
5604
|
var _this$store$discount19;
|
|
5796
|
-
var sourceRaw, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, nextTempOrder,
|
|
5797
|
-
return _regeneratorRuntime().wrap(function
|
|
5798
|
-
while (1) switch (
|
|
5605
|
+
var sourceRaw, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, nextTempOrder, rawSummary, summarySurcharges, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount20, _this$store$discount21;
|
|
5606
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context43) {
|
|
5607
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
5799
5608
|
case 0:
|
|
5800
5609
|
sourceRaw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
|
|
5801
5610
|
identityReadySource = this.seedAnonymousBookingUidsFromProducts(sourceRaw);
|
|
@@ -5820,13 +5629,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5820
5629
|
}
|
|
5821
5630
|
nextTempOrder = this.normalizeTempOrderForRuntime(raw, {
|
|
5822
5631
|
makeEditMark: true
|
|
5823
|
-
});
|
|
5824
|
-
sourceLastOrderInfo = raw.lastOrderInfo || raw;
|
|
5825
|
-
isDraftOrder = Number(nextTempOrder.is_draft_order || 0) === 1;
|
|
5826
|
-
syntheticIdentityOptions = {
|
|
5827
|
-
isDraftOrder: isDraftOrder,
|
|
5828
|
-
externalSaleNumber: nextTempOrder.external_sale_number
|
|
5829
|
-
};
|
|
5632
|
+
});
|
|
5830
5633
|
rawSummary = raw.summary && _typeof(raw.summary) === 'object' ? raw.summary : {};
|
|
5831
5634
|
summarySurcharges = Array.isArray(rawSummary.surcharges) ? rawSummary.surcharges.map(function (s) {
|
|
5832
5635
|
return _objectSpread({}, s || {});
|
|
@@ -5846,11 +5649,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5846
5649
|
productFingerprint: this.buildOrderProductsFingerprint(nextTempOrder.products || [])
|
|
5847
5650
|
}
|
|
5848
5651
|
});
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
}
|
|
5652
|
+
// lastOrderInfo carries the exact backend snapshot used by deposit/type recovery.
|
|
5653
|
+
// Runtime collection repair lives in tempOrder/originalSalesSnapshot and must not
|
|
5654
|
+
// rewrite this protocol snapshot as a side effect of hydration.
|
|
5655
|
+
this.store.lastOrderInfo = sourceRaw.lastOrderInfo || sourceRaw;
|
|
5854
5656
|
hydratedEditDiscounts = this.collectHydratedEditDiscounts(nextTempOrder.products);
|
|
5855
5657
|
currentDiscounts = typeof ((_this$store$discount19 = this.store.discount) === null || _this$store$discount19 === void 0 ? void 0 : _this$store$discount19.getDiscountList) === 'function' ? this.store.discount.getDiscountList() || [] : [];
|
|
5856
5658
|
currentScanDiscounts = currentDiscounts.filter(function (discount) {
|
|
@@ -5865,34 +5667,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5865
5667
|
nextDiscounts = [].concat(_toConsumableArray(hydratedEditDiscounts), _toConsumableArray(retainedScanDiscounts));
|
|
5866
5668
|
shouldSkipEmptyDiscountSync = nextDiscounts.length === 0 && currentDiscounts.length === 0;
|
|
5867
5669
|
if (shouldSkipEmptyDiscountSync) {
|
|
5868
|
-
|
|
5670
|
+
_context43.next = 26;
|
|
5869
5671
|
break;
|
|
5870
5672
|
}
|
|
5871
5673
|
OrderModule.populateSavedAmounts(nextTempOrder.products, nextDiscounts);
|
|
5872
|
-
|
|
5674
|
+
_context43.next = 24;
|
|
5873
5675
|
return (_this$store$discount20 = this.store.discount) === null || _this$store$discount20 === void 0 ? void 0 : _this$store$discount20.setOriginalDiscountList(nextDiscounts);
|
|
5874
|
-
case
|
|
5875
|
-
|
|
5676
|
+
case 24:
|
|
5677
|
+
_context43.next = 26;
|
|
5876
5678
|
return (_this$store$discount21 = this.store.discount) === null || _this$store$discount21 === void 0 ? void 0 : _this$store$discount21.setDiscountList(nextDiscounts);
|
|
5877
|
-
case
|
|
5679
|
+
case 26:
|
|
5878
5680
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
5879
|
-
|
|
5681
|
+
_context43.next = 29;
|
|
5880
5682
|
break;
|
|
5881
5683
|
}
|
|
5882
|
-
|
|
5684
|
+
_context43.next = 29;
|
|
5883
5685
|
return this.recalculateSummary({
|
|
5884
5686
|
createIfMissing: false
|
|
5885
5687
|
});
|
|
5886
|
-
case
|
|
5688
|
+
case 29:
|
|
5887
5689
|
this.persistTempOrder();
|
|
5888
|
-
return
|
|
5889
|
-
case
|
|
5690
|
+
return _context43.abrupt("return", nextTempOrder);
|
|
5691
|
+
case 31:
|
|
5890
5692
|
case "end":
|
|
5891
|
-
return
|
|
5693
|
+
return _context43.stop();
|
|
5892
5694
|
}
|
|
5893
|
-
},
|
|
5695
|
+
}, _callee40, this);
|
|
5894
5696
|
}));
|
|
5895
|
-
function hydrateTempOrderFromRecord(
|
|
5697
|
+
function hydrateTempOrderFromRecord(_x49, _x50) {
|
|
5896
5698
|
return _hydrateTempOrderFromRecord.apply(this, arguments);
|
|
5897
5699
|
}
|
|
5898
5700
|
return hydrateTempOrderFromRecord;
|
|
@@ -6006,12 +5808,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6006
5808
|
}, {
|
|
6007
5809
|
key: "normalizeTempOrderForRuntime",
|
|
6008
5810
|
value: function normalizeTempOrderForRuntime(raw, options) {
|
|
6009
|
-
var
|
|
6010
|
-
var
|
|
6011
|
-
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
|
|
5811
|
+
var _this28 = this;
|
|
5812
|
+
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), raw || {});
|
|
6012
5813
|
// ES 列表详情使用 id 表示订单主键;OS 详情态统一依赖 order_id 驱动操作按钮。
|
|
6013
|
-
if ((nextTempOrder.order_id === undefined || nextTempOrder.order_id === null) && (
|
|
6014
|
-
nextTempOrder.order_id =
|
|
5814
|
+
if ((nextTempOrder.order_id === undefined || nextTempOrder.order_id === null) && (raw === null || raw === void 0 ? void 0 : raw.id) !== undefined && (raw === null || raw === void 0 ? void 0 : raw.id) !== null) {
|
|
5815
|
+
nextTempOrder.order_id = raw.id;
|
|
6015
5816
|
}
|
|
6016
5817
|
delete nextTempOrder.summary;
|
|
6017
5818
|
delete nextTempOrder.lastOrderInfo;
|
|
@@ -6030,12 +5831,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6030
5831
|
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
6031
5832
|
var rawProducts = Array.isArray(raw.products) ? raw.products : [];
|
|
6032
5833
|
nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
|
|
6033
|
-
return
|
|
5834
|
+
return _this28.normalizeHydratedOrderProduct(p, {
|
|
6034
5835
|
makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
|
|
6035
5836
|
});
|
|
6036
5837
|
}) : [];
|
|
6037
5838
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
6038
|
-
var booking =
|
|
5839
|
+
var booking = _this28.normalizeHydratedBookingHolder(b || {});
|
|
6039
5840
|
return _objectSpread(_objectSpread({}, booking), {}, {
|
|
6040
5841
|
is_all: normalizeBookingIsAll(booking),
|
|
6041
5842
|
sub_type: normalizeBookingSubType(booking)
|
|
@@ -6065,7 +5866,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6065
5866
|
_step24;
|
|
6066
5867
|
try {
|
|
6067
5868
|
for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
|
|
6068
|
-
var _product$metadata11,
|
|
5869
|
+
var _product$metadata11, _ref76, _ref77, _existed$origin, _rawProduct$metadata;
|
|
6069
5870
|
var _step24$value = _slicedToArray(_step24.value, 2),
|
|
6070
5871
|
index = _step24$value[0],
|
|
6071
5872
|
product = _step24$value[1];
|
|
@@ -6073,7 +5874,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6073
5874
|
if (!uid) continue;
|
|
6074
5875
|
var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
|
|
6075
5876
|
var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
|
|
6076
|
-
var origin = (
|
|
5877
|
+
var origin = (_ref76 = (_ref77 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref77 !== void 0 ? _ref77 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref76 !== void 0 ? _ref76 : rawProduct;
|
|
6077
5878
|
var originSnapshot = cloneDeep(origin);
|
|
6078
5879
|
var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
|
|
6079
5880
|
if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
|
|
@@ -6101,23 +5902,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6101
5902
|
nextTempOrder.vouchers = raw.vouchers || [];
|
|
6102
5903
|
return nextTempOrder;
|
|
6103
5904
|
}
|
|
6104
|
-
}, {
|
|
6105
|
-
key: "isSyntheticDraftOrderIdForRuntime",
|
|
6106
|
-
value: function isSyntheticDraftOrderIdForRuntime(record, options) {
|
|
6107
|
-
var _options$isDraftOrder, _record$external_sale;
|
|
6108
|
-
var isDraftOrder = (_options$isDraftOrder = options === null || options === void 0 ? void 0 : options.isDraftOrder) !== null && _options$isDraftOrder !== void 0 ? _options$isDraftOrder : Number((record === null || record === void 0 ? void 0 : record.is_draft_order) || 0) === 1;
|
|
6109
|
-
var externalSaleNumber = (_record$external_sale = record === null || record === void 0 ? void 0 : record.external_sale_number) !== null && _record$external_sale !== void 0 ? _record$external_sale : options === null || options === void 0 ? void 0 : options.externalSaleNumber;
|
|
6110
|
-
var orderId = record === null || record === void 0 ? void 0 : record.order_id;
|
|
6111
|
-
return Boolean(isDraftOrder && orderId !== undefined && orderId !== null && orderId !== '' && externalSaleNumber !== undefined && externalSaleNumber !== null && externalSaleNumber !== '' && String(orderId) === String(externalSaleNumber));
|
|
6112
|
-
}
|
|
6113
|
-
}, {
|
|
6114
|
-
key: "withoutSyntheticDraftOrderIdForRuntime",
|
|
6115
|
-
value: function withoutSyntheticDraftOrderIdForRuntime(record, options) {
|
|
6116
|
-
if (!this.isSyntheticDraftOrderIdForRuntime(record, options)) return record;
|
|
6117
|
-
return _objectSpread(_objectSpread({}, record), {}, {
|
|
6118
|
-
order_id: null
|
|
6119
|
-
});
|
|
6120
|
-
}
|
|
6121
5905
|
}, {
|
|
6122
5906
|
key: "hydrateLinkedBookingIdentity",
|
|
6123
5907
|
value: function hydrateLinkedBookingIdentity(tempOrder) {
|
|
@@ -6202,10 +5986,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6202
5986
|
}, {
|
|
6203
5987
|
key: "normalizeHydratedProductOptionItem",
|
|
6204
5988
|
value: function normalizeHydratedProductOptionItem(optionItem) {
|
|
6205
|
-
var
|
|
6206
|
-
var rawNum = (
|
|
5989
|
+
var _ref78, _optionItem$num, _ref79, _optionItem$add_price;
|
|
5990
|
+
var rawNum = (_ref78 = (_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 && _ref78 !== void 0 ? _ref78 : 1;
|
|
6207
5991
|
var parsedNum = Number(rawNum);
|
|
6208
|
-
var rawPrice = (
|
|
5992
|
+
var rawPrice = (_ref79 = (_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 && _ref79 !== void 0 ? _ref79 : 0;
|
|
6209
5993
|
var parsedPrice = Number(rawPrice);
|
|
6210
5994
|
var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
|
|
6211
5995
|
option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
|
|
@@ -6222,7 +6006,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6222
6006
|
}, {
|
|
6223
6007
|
key: "normalizeHydratedOrderProduct",
|
|
6224
6008
|
value: function normalizeHydratedOrderProduct(product, options) {
|
|
6225
|
-
var
|
|
6009
|
+
var _this29 = this;
|
|
6226
6010
|
var row = _objectSpread({}, product || {});
|
|
6227
6011
|
if (row.num === undefined && row.product_quantity !== undefined) {
|
|
6228
6012
|
row.num = row.product_quantity;
|
|
@@ -6230,7 +6014,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6230
6014
|
var productSku = ensureProductSku(row);
|
|
6231
6015
|
row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
|
|
6232
6016
|
option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
|
|
6233
|
-
return
|
|
6017
|
+
return _this29.normalizeHydratedProductOptionItem(optionItem || {});
|
|
6234
6018
|
}))
|
|
6235
6019
|
});
|
|
6236
6020
|
delete row["product_".concat('option', "_item")];
|
|
@@ -6267,27 +6051,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6267
6051
|
}, {
|
|
6268
6052
|
key: "getOrderInfo",
|
|
6269
6053
|
value: function () {
|
|
6270
|
-
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6054
|
+
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(order_id) {
|
|
6271
6055
|
var res;
|
|
6272
|
-
return _regeneratorRuntime().wrap(function
|
|
6273
|
-
while (1) switch (
|
|
6056
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context44) {
|
|
6057
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
6274
6058
|
case 0:
|
|
6275
|
-
|
|
6059
|
+
_context44.next = 2;
|
|
6276
6060
|
return this.request.get("/order/sales/".concat(order_id), {
|
|
6277
6061
|
with: ['products', 'bookings']
|
|
6278
6062
|
}, {
|
|
6279
6063
|
osServer: true
|
|
6280
6064
|
});
|
|
6281
6065
|
case 2:
|
|
6282
|
-
res =
|
|
6283
|
-
return
|
|
6066
|
+
res = _context44.sent;
|
|
6067
|
+
return _context44.abrupt("return", res);
|
|
6284
6068
|
case 4:
|
|
6285
6069
|
case "end":
|
|
6286
|
-
return
|
|
6070
|
+
return _context44.stop();
|
|
6287
6071
|
}
|
|
6288
|
-
},
|
|
6072
|
+
}, _callee41, this);
|
|
6289
6073
|
}));
|
|
6290
|
-
function getOrderInfo(
|
|
6074
|
+
function getOrderInfo(_x51) {
|
|
6291
6075
|
return _getOrderInfo.apply(this, arguments);
|
|
6292
6076
|
}
|
|
6293
6077
|
return getOrderInfo;
|
|
@@ -6346,10 +6130,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6346
6130
|
_step29;
|
|
6347
6131
|
try {
|
|
6348
6132
|
for (_iterator29.s(); !(_step29 = _iterator29.n()).done;) {
|
|
6349
|
-
var
|
|
6133
|
+
var _ref80, _bundle$num3;
|
|
6350
6134
|
var bundle = _step29.value;
|
|
6351
6135
|
var isPersistedBundleProduct = isPersistedProduct || Boolean((bundle === null || bundle === void 0 ? void 0 : bundle.order_detail_id) || (bundle === null || bundle === void 0 ? void 0 : bundle.orderDetailId) || (bundle === null || bundle === void 0 ? void 0 : bundle.booking_id));
|
|
6352
|
-
var bundleQty = new Decimal(Number(qty) || 1).times(Number((
|
|
6136
|
+
var bundleQty = new Decimal(Number(qty) || 1).times(Number((_ref80 = (_bundle$num3 = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num3 !== void 0 ? _bundle$num3 : bundle === null || bundle === void 0 ? void 0 : bundle.quantity) !== null && _ref80 !== void 0 ? _ref80 : 1) || 1).toNumber();
|
|
6353
6137
|
var _iterator30 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
|
|
6354
6138
|
_step30;
|
|
6355
6139
|
try {
|