@pisell/pisellos 2.2.265 → 2.2.267
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -3
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +6 -3
- package/dist/modules/Order/index.d.ts +8 -27
- package/dist/modules/Order/index.js +490 -743
- package/dist/modules/Order/types.d.ts +1 -33
- package/dist/modules/Order/utils/orderCollectionIdentity.js +2 -7
- package/dist/modules/Order/utils.js +5 -8
- 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/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 +11 -42
- package/dist/solution/BaseSales/index.js +385 -676
- package/dist/solution/BaseSales/utils/cartPromotion.js +5 -3
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +1 -2
- package/dist/solution/BookingTicket/utils/addProductDecision.js +6 -0
- 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/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +2 -1
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
- package/lib/modules/Order/index.d.ts +8 -27
- package/lib/modules/Order/index.js +69 -184
- package/lib/modules/Order/types.d.ts +1 -33
- package/lib/modules/Order/utils/orderCollectionIdentity.js +0 -3
- package/lib/modules/Order/utils.js +3 -5
- 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/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 +11 -42
- package/lib/solution/BaseSales/index.js +35 -214
- package/lib/solution/BaseSales/utils/cartPromotion.js +5 -2
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +1 -2
- package/lib/solution/BookingTicket/utils/addProductDecision.js +4 -0
- 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/package.json +2 -2
- 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";
|
|
@@ -99,7 +97,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
99
97
|
_defineProperty(_assertThisInitialized(_this), "logger", void 0);
|
|
100
98
|
// LoggerManager 实例
|
|
101
99
|
_defineProperty(_assertThisInitialized(_this), "window", void 0);
|
|
102
|
-
_defineProperty(_assertThisInitialized(_this), "appPlugin", void 0);
|
|
103
100
|
_defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
|
|
104
101
|
_defineProperty(_assertThisInitialized(_this), "salesSummaryModuleName", void 0);
|
|
105
102
|
_defineProperty(_assertThisInitialized(_this), "rulesHooksOverride", void 0);
|
|
@@ -287,7 +284,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
287
284
|
value: function () {
|
|
288
285
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
|
|
289
286
|
var _otherParams$rules, _otherParams$order, _otherParams$hooks;
|
|
290
|
-
var app, otherParams;
|
|
287
|
+
var appPlugin, app, otherParams;
|
|
291
288
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
292
289
|
while (1) switch (_context.prev = _context.next) {
|
|
293
290
|
case 0:
|
|
@@ -303,14 +300,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
303
300
|
this.store.availableWalletIds = [];
|
|
304
301
|
}
|
|
305
302
|
this.request = this.core.getPlugin('request');
|
|
306
|
-
|
|
307
|
-
if (
|
|
303
|
+
appPlugin = this.core.getPlugin('app');
|
|
304
|
+
if (appPlugin) {
|
|
308
305
|
_context.next = 9;
|
|
309
306
|
break;
|
|
310
307
|
}
|
|
311
308
|
throw new Error('Order 模块需要 app 插件支持');
|
|
312
309
|
case 9:
|
|
313
|
-
app =
|
|
310
|
+
app = appPlugin.getApp();
|
|
314
311
|
this.logger = app.logger;
|
|
315
312
|
this.window = this.core.getPlugin('window');
|
|
316
313
|
otherParams = options.otherParams || {};
|
|
@@ -1513,44 +1510,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1513
1510
|
var depositPaidAmount = this.calculateDepositPaidAmount(tempOrder.payments || []);
|
|
1514
1511
|
return depositPaidAmount.lt(depositAmount) ? 'deposit' : 'normal';
|
|
1515
1512
|
}
|
|
1516
|
-
}, {
|
|
1517
|
-
key: "getPaymentNumberAppData",
|
|
1518
|
-
value: function getPaymentNumberAppData(key) {
|
|
1519
|
-
var _appPlugin$getData, _app$models, _app$models$getStore, _app$models$getStore$, _app$models$getStore$2;
|
|
1520
|
-
var appPlugin = this.appPlugin;
|
|
1521
|
-
if (!appPlugin) return undefined;
|
|
1522
|
-
var getData = (_appPlugin$getData = appPlugin.getData) === null || _appPlugin$getData === void 0 ? void 0 : _appPlugin$getData.call(appPlugin);
|
|
1523
|
-
if (typeof getData === 'function') return getData(key);
|
|
1524
|
-
var app = appPlugin.getApp();
|
|
1525
|
-
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');
|
|
1526
|
-
return coreData === null || coreData === void 0 ? void 0 : coreData[key];
|
|
1527
|
-
}
|
|
1528
|
-
}, {
|
|
1529
|
-
key: "getPaymentNumberDevicePrefixSync",
|
|
1530
|
-
value: function getPaymentNumberDevicePrefixSync() {
|
|
1531
|
-
var _this7 = this;
|
|
1532
|
-
return resolvePaymentNumberDevicePrefixFromDeviceId(function (key) {
|
|
1533
|
-
return _this7.getPaymentNumberAppData(key);
|
|
1534
|
-
});
|
|
1535
|
-
}
|
|
1536
|
-
}, {
|
|
1537
|
-
key: "getPaymentNumberDevicePrefixAsync",
|
|
1538
|
-
value: function getPaymentNumberDevicePrefixAsync() {
|
|
1539
|
-
var _this8 = this;
|
|
1540
|
-
return resolvePaymentNumberDevicePrefix(function (key) {
|
|
1541
|
-
return _this8.getPaymentNumberAppData(key);
|
|
1542
|
-
});
|
|
1543
|
-
}
|
|
1544
1513
|
}, {
|
|
1545
1514
|
key: "normalizePaymentSource",
|
|
1546
1515
|
value: function normalizePaymentSource(payment, options) {
|
|
1547
1516
|
var _ref19, _paymentRecord$origin;
|
|
1548
1517
|
var paymentRecord = payment;
|
|
1549
1518
|
var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
|
|
1550
|
-
|
|
1519
|
+
if (!metadata.unique_payment_number) {
|
|
1520
|
+
metadata.unique_payment_number = createUuidV4();
|
|
1521
|
+
}
|
|
1522
|
+
var normalized = _objectSpread(_objectSpread({}, paymentRecord), {}, {
|
|
1551
1523
|
metadata: metadata,
|
|
1552
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'
|
|
1553
|
-
})
|
|
1525
|
+
});
|
|
1554
1526
|
if (paymentRecord.status !== undefined) {
|
|
1555
1527
|
normalized.status = paymentRecord.status;
|
|
1556
1528
|
} else if ((options === null || options === void 0 ? void 0 : options.defaultPaid) !== false) {
|
|
@@ -1668,16 +1640,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1668
1640
|
}, {
|
|
1669
1641
|
key: "calculatePaidPaymentSummary",
|
|
1670
1642
|
value: function calculatePaidPaymentSummary(payments) {
|
|
1671
|
-
var
|
|
1643
|
+
var _this7 = this;
|
|
1672
1644
|
return (payments || []).reduce(function (summary, payment) {
|
|
1673
1645
|
var paymentRecord = payment;
|
|
1674
1646
|
if (!isPaidPaymentRecord(paymentRecord)) return summary;
|
|
1675
1647
|
return {
|
|
1676
1648
|
customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
|
|
1677
|
-
orderPaidAmount: summary.orderPaidAmount.plus(
|
|
1678
|
-
gapPaidAmount: summary.gapPaidAmount.plus(
|
|
1679
|
-
payServiceChargeAmount: summary.payServiceChargeAmount.plus(
|
|
1680
|
-
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))
|
|
1681
1653
|
};
|
|
1682
1654
|
}, {
|
|
1683
1655
|
customerPaidAmount: new Decimal(0),
|
|
@@ -1879,15 +1851,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1879
1851
|
}, {
|
|
1880
1852
|
key: "normalizeFingerprintValue",
|
|
1881
1853
|
value: function normalizeFingerprintValue(value) {
|
|
1882
|
-
var
|
|
1854
|
+
var _this8 = this;
|
|
1883
1855
|
if (Array.isArray(value)) {
|
|
1884
1856
|
return value.map(function (item) {
|
|
1885
|
-
return
|
|
1857
|
+
return _this8.normalizeFingerprintValue(item);
|
|
1886
1858
|
});
|
|
1887
1859
|
}
|
|
1888
1860
|
if (!value || _typeof(value) !== 'object') return value !== null && value !== void 0 ? value : '';
|
|
1889
1861
|
return Object.keys(value).sort().reduce(function (result, key) {
|
|
1890
|
-
result[key] =
|
|
1862
|
+
result[key] = _this8.normalizeFingerprintValue(value[key]);
|
|
1891
1863
|
return result;
|
|
1892
1864
|
}, {});
|
|
1893
1865
|
}
|
|
@@ -1902,7 +1874,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1902
1874
|
_sku$barcode,
|
|
1903
1875
|
_ref20,
|
|
1904
1876
|
_sku$variant_id,
|
|
1905
|
-
|
|
1877
|
+
_this9 = this;
|
|
1906
1878
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
1907
1879
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
1908
1880
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
@@ -1936,7 +1908,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1936
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,
|
|
1937
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,
|
|
1938
1910
|
num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
|
|
1939
|
-
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)
|
|
1940
1912
|
};
|
|
1941
1913
|
})
|
|
1942
1914
|
}),
|
|
@@ -1946,8 +1918,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1946
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,
|
|
1947
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,
|
|
1948
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),
|
|
1949
|
-
price:
|
|
1950
|
-
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),
|
|
1951
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 : '',
|
|
1952
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 : ''
|
|
1953
1925
|
};
|
|
@@ -1957,7 +1929,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1957
1929
|
return {
|
|
1958
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 : '',
|
|
1959
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,
|
|
1960
|
-
amount:
|
|
1932
|
+
amount: _this9.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
1961
1933
|
};
|
|
1962
1934
|
}))
|
|
1963
1935
|
};
|
|
@@ -1965,9 +1937,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1965
1937
|
}, {
|
|
1966
1938
|
key: "buildOrderProductsFingerprint",
|
|
1967
1939
|
value: function buildOrderProductsFingerprint(products) {
|
|
1968
|
-
var
|
|
1940
|
+
var _this10 = this;
|
|
1969
1941
|
var items = (products || []).map(function (product) {
|
|
1970
|
-
return
|
|
1942
|
+
return _this10.buildProductFingerprintItem(product);
|
|
1971
1943
|
});
|
|
1972
1944
|
items.sort(function (left, right) {
|
|
1973
1945
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -1989,7 +1961,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1989
1961
|
_sku$barcode2,
|
|
1990
1962
|
_ref30,
|
|
1991
1963
|
_sku$variant_id2,
|
|
1992
|
-
|
|
1964
|
+
_this11 = this;
|
|
1993
1965
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
1994
1966
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
1995
1967
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
@@ -2020,7 +1992,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2020
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,
|
|
2021
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,
|
|
2022
1994
|
num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
|
|
2023
|
-
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)
|
|
2024
1996
|
};
|
|
2025
1997
|
})
|
|
2026
1998
|
}),
|
|
@@ -2034,14 +2006,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2034
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),
|
|
2035
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 : '',
|
|
2036
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 : '',
|
|
2037
|
-
option:
|
|
2009
|
+
option: _this11.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
|
|
2038
2010
|
var _ref38, _option$id3, _option$option_group_5, _ref39, _option$option_group_6, _option$num3, _option$add_price3;
|
|
2039
2011
|
return {
|
|
2040
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,
|
|
2041
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,
|
|
2042
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,
|
|
2043
2015
|
num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
|
|
2044
|
-
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)
|
|
2045
2017
|
};
|
|
2046
2018
|
}))
|
|
2047
2019
|
};
|
|
@@ -2051,7 +2023,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2051
2023
|
return {
|
|
2052
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 : '',
|
|
2053
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,
|
|
2054
|
-
amount:
|
|
2026
|
+
amount: _this11.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
2055
2027
|
};
|
|
2056
2028
|
}))
|
|
2057
2029
|
};
|
|
@@ -2059,9 +2031,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2059
2031
|
}, {
|
|
2060
2032
|
key: "buildOrderProductsStructuralFingerprint",
|
|
2061
2033
|
value: function buildOrderProductsStructuralFingerprint(products) {
|
|
2062
|
-
var
|
|
2034
|
+
var _this12 = this;
|
|
2063
2035
|
var items = (products || []).map(function (product) {
|
|
2064
|
-
return
|
|
2036
|
+
return _this12.buildProductStructuralFingerprintItem(product);
|
|
2065
2037
|
});
|
|
2066
2038
|
items.sort(function (left, right) {
|
|
2067
2039
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -2489,9 +2461,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2489
2461
|
}, {
|
|
2490
2462
|
key: "sanitizeTempOrderProducts",
|
|
2491
2463
|
value: function sanitizeTempOrderProducts(tempOrder) {
|
|
2492
|
-
var
|
|
2464
|
+
var _this13 = this;
|
|
2493
2465
|
tempOrder.products = (tempOrder.products || []).map(function (product) {
|
|
2494
|
-
return
|
|
2466
|
+
return _this13.sanitizeOrderProductForTempOrder(product);
|
|
2495
2467
|
});
|
|
2496
2468
|
}
|
|
2497
2469
|
}, {
|
|
@@ -2594,7 +2566,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2594
2566
|
}, {
|
|
2595
2567
|
key: "syncLinkedBookingHoldersToProducts",
|
|
2596
2568
|
value: function syncLinkedBookingHoldersToProducts(tempOrder) {
|
|
2597
|
-
var
|
|
2569
|
+
var _this14 = this;
|
|
2598
2570
|
var bookings = tempOrder.bookings || [];
|
|
2599
2571
|
var products = tempOrder.products || [];
|
|
2600
2572
|
if (!bookings.length || !products.length) return;
|
|
@@ -2619,7 +2591,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2619
2591
|
var bookingUid = product.booking_uid || ((_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.booking_uid);
|
|
2620
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);
|
|
2621
2593
|
if (linkedBooking) {
|
|
2622
|
-
|
|
2594
|
+
_this14.setProductHolderFromBooking(product, linkedBooking);
|
|
2623
2595
|
}
|
|
2624
2596
|
});
|
|
2625
2597
|
}
|
|
@@ -2747,9 +2719,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2747
2719
|
}, {
|
|
2748
2720
|
key: "findBookingIndexByUniqueIdentificationNumber",
|
|
2749
2721
|
value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
|
|
2750
|
-
var
|
|
2722
|
+
var _this15 = this;
|
|
2751
2723
|
return (tempOrder.bookings || []).findIndex(function (booking) {
|
|
2752
|
-
return
|
|
2724
|
+
return _this15.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
|
|
2753
2725
|
});
|
|
2754
2726
|
}
|
|
2755
2727
|
}, {
|
|
@@ -2757,12 +2729,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2757
2729
|
value: function removeLinkedBookingsForProduct(tempOrder, product) {
|
|
2758
2730
|
var _product$metadata7,
|
|
2759
2731
|
_product$metadata8,
|
|
2760
|
-
|
|
2732
|
+
_this16 = this;
|
|
2761
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);
|
|
2762
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);
|
|
2763
2735
|
if (!productUid && !bookingUid) return;
|
|
2764
2736
|
tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
|
|
2765
|
-
var currentBookingUid =
|
|
2737
|
+
var currentBookingUid = _this16.getBookingUniqueIdentificationNumber(booking);
|
|
2766
2738
|
if (bookingUid && currentBookingUid === String(bookingUid)) return false;
|
|
2767
2739
|
if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
|
|
2768
2740
|
return true;
|
|
@@ -3095,15 +3067,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3095
3067
|
}, {
|
|
3096
3068
|
key: "productHasCustomerBoundDiscount",
|
|
3097
3069
|
value: function productHasCustomerBoundDiscount(product) {
|
|
3098
|
-
var
|
|
3070
|
+
var _this17 = this;
|
|
3099
3071
|
if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
|
|
3100
|
-
return
|
|
3072
|
+
return _this17.isCustomerBoundDiscount(discount);
|
|
3101
3073
|
})) {
|
|
3102
3074
|
return true;
|
|
3103
3075
|
}
|
|
3104
3076
|
return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
|
|
3105
3077
|
return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
|
|
3106
|
-
return
|
|
3078
|
+
return _this17.isCustomerBoundDiscount(discount);
|
|
3107
3079
|
});
|
|
3108
3080
|
});
|
|
3109
3081
|
}
|
|
@@ -3112,18 +3084,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3112
3084
|
value: function shouldSkipDiscountCalculation(tempOrder) {
|
|
3113
3085
|
var _this$store$discount17,
|
|
3114
3086
|
_this$store$discount18,
|
|
3115
|
-
|
|
3087
|
+
_this18 = this;
|
|
3116
3088
|
if (this.hasActiveCustomerBoundDiscount) return false;
|
|
3117
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)) || [];
|
|
3118
3090
|
if (discountList.length > 0) return false;
|
|
3119
3091
|
return !(tempOrder.products || []).some(function (product) {
|
|
3120
|
-
return
|
|
3092
|
+
return _this18.productHasCustomerBoundDiscount(product);
|
|
3121
3093
|
});
|
|
3122
3094
|
}
|
|
3123
3095
|
}, {
|
|
3124
3096
|
key: "clearCustomerBoundDiscounts",
|
|
3125
3097
|
value: function clearCustomerBoundDiscounts(tempOrder) {
|
|
3126
|
-
var
|
|
3098
|
+
var _this19 = this,
|
|
3127
3099
|
_discountModule$getDi,
|
|
3128
3100
|
_discountModule$getOr,
|
|
3129
3101
|
_discountModule$setDi,
|
|
@@ -3132,7 +3104,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3132
3104
|
var filterDiscountList = function filterDiscountList(discountList) {
|
|
3133
3105
|
if (!Array.isArray(discountList)) return [];
|
|
3134
3106
|
return discountList.filter(function (discount) {
|
|
3135
|
-
var shouldRemove =
|
|
3107
|
+
var shouldRemove = _this19.isCustomerBoundDiscount(discount);
|
|
3136
3108
|
if (shouldRemove) didRemoveCustomerBoundDiscount = true;
|
|
3137
3109
|
return !shouldRemove;
|
|
3138
3110
|
});
|
|
@@ -3159,12 +3131,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3159
3131
|
var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
|
|
3160
3132
|
var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
|
|
3161
3133
|
var nextDiscounts = currentDiscounts.filter(function (discount) {
|
|
3162
|
-
if (
|
|
3163
|
-
return !
|
|
3134
|
+
if (_this19.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
3135
|
+
return !_this19.isCustomerBoundDiscount(discount);
|
|
3164
3136
|
});
|
|
3165
3137
|
var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
|
|
3166
|
-
if (
|
|
3167
|
-
return !
|
|
3138
|
+
if (_this19.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
3139
|
+
return !_this19.isCustomerBoundDiscount(discount);
|
|
3168
3140
|
});
|
|
3169
3141
|
void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
|
|
3170
3142
|
void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
|
|
@@ -3318,71 +3290,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3318
3290
|
* 用一组支付来源覆盖当前订单支付项。
|
|
3319
3291
|
*
|
|
3320
3292
|
* 入参允许来自 PaymentModule 的 PaymentItem,内部统一映射为 Sales 协议:
|
|
3321
|
-
*
|
|
3293
|
+
* uuid -> metadata.unique_payment_number,id -> custom_payment_id,
|
|
3322
3294
|
* isSynced 等运行态字段不会进入 tempOrder.payments。
|
|
3323
3295
|
*/
|
|
3324
3296
|
}, {
|
|
3325
3297
|
key: "setOrderPayments",
|
|
3326
3298
|
value: function setOrderPayments(payments) {
|
|
3327
|
-
var _this22 = this;
|
|
3328
3299
|
var tempOrder = this.ensureTempOrder();
|
|
3329
|
-
tempOrder.payments = mapPaymentItemsToOrderPayments(
|
|
3330
|
-
return _this22.normalizePaymentSource(payment, {
|
|
3331
|
-
defaultPaid: false
|
|
3332
|
-
});
|
|
3333
|
-
}));
|
|
3300
|
+
tempOrder.payments = mapPaymentItemsToOrderPayments(payments);
|
|
3334
3301
|
this.persistTempOrder();
|
|
3335
3302
|
return tempOrder.payments;
|
|
3336
3303
|
}
|
|
3337
3304
|
|
|
3338
|
-
/**
|
|
3305
|
+
/** 追加单个支付项,并立即持久化当前 tempOrder。 */
|
|
3339
3306
|
}, {
|
|
3340
3307
|
key: "addOrderPayment",
|
|
3341
3308
|
value: function addOrderPayment(payment) {
|
|
3342
|
-
var
|
|
3343
|
-
return this.addOrderPaymentWithDevicePrefix(payment, hasPaymentNumber ? 'LOCAL' : this.getPaymentNumberDevicePrefixSync());
|
|
3344
|
-
}
|
|
3345
|
-
|
|
3346
|
-
/** 异步入口:创建支付项时读取最新 IoT 设备短号。 */
|
|
3347
|
-
}, {
|
|
3348
|
-
key: "addOrderPaymentAsync",
|
|
3349
|
-
value: (function () {
|
|
3350
|
-
var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(payment) {
|
|
3351
|
-
var hasPaymentNumber, devicePrefix;
|
|
3352
|
-
return _regeneratorRuntime().wrap(function _callee15$(_context17) {
|
|
3353
|
-
while (1) switch (_context17.prev = _context17.next) {
|
|
3354
|
-
case 0:
|
|
3355
|
-
hasPaymentNumber = String(payment.payment_number || '').trim() !== '';
|
|
3356
|
-
if (!hasPaymentNumber) {
|
|
3357
|
-
_context17.next = 5;
|
|
3358
|
-
break;
|
|
3359
|
-
}
|
|
3360
|
-
_context17.t0 = 'LOCAL';
|
|
3361
|
-
_context17.next = 8;
|
|
3362
|
-
break;
|
|
3363
|
-
case 5:
|
|
3364
|
-
_context17.next = 7;
|
|
3365
|
-
return this.getPaymentNumberDevicePrefixAsync();
|
|
3366
|
-
case 7:
|
|
3367
|
-
_context17.t0 = _context17.sent;
|
|
3368
|
-
case 8:
|
|
3369
|
-
devicePrefix = _context17.t0;
|
|
3370
|
-
return _context17.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
|
|
3371
|
-
case 10:
|
|
3372
|
-
case "end":
|
|
3373
|
-
return _context17.stop();
|
|
3374
|
-
}
|
|
3375
|
-
}, _callee15, this);
|
|
3376
|
-
}));
|
|
3377
|
-
function addOrderPaymentAsync(_x14) {
|
|
3378
|
-
return _addOrderPaymentAsync.apply(this, arguments);
|
|
3379
|
-
}
|
|
3380
|
-
return addOrderPaymentAsync;
|
|
3381
|
-
}())
|
|
3382
|
-
}, {
|
|
3383
|
-
key: "addOrderPaymentWithDevicePrefix",
|
|
3384
|
-
value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
|
|
3385
|
-
var _this23 = this;
|
|
3309
|
+
var _this20 = this;
|
|
3386
3310
|
this.logInfo('addOrderPayment', {
|
|
3387
3311
|
payment: payment
|
|
3388
3312
|
});
|
|
@@ -3392,15 +3316,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3392
3316
|
type: orderPaymentType,
|
|
3393
3317
|
order_payment_type: orderPaymentType
|
|
3394
3318
|
}), {
|
|
3395
|
-
defaultPaid: true
|
|
3396
|
-
devicePrefix: devicePrefix
|
|
3319
|
+
defaultPaid: true
|
|
3397
3320
|
})]);
|
|
3398
3321
|
tempOrder.payments = [].concat(_toConsumableArray(tempOrder.payments || []), _toConsumableArray(mapped));
|
|
3399
3322
|
this.persistTempOrder();
|
|
3400
3323
|
void this.recalculateSummary({
|
|
3401
3324
|
createIfMissing: true
|
|
3402
3325
|
}).catch(function (error) {
|
|
3403
|
-
|
|
3326
|
+
_this20.logError('recalculate summary after addOrderPayment failed', {
|
|
3404
3327
|
error: error instanceof Error ? error.message : String(error)
|
|
3405
3328
|
});
|
|
3406
3329
|
});
|
|
@@ -3408,80 +3331,49 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3408
3331
|
}
|
|
3409
3332
|
|
|
3410
3333
|
/**
|
|
3411
|
-
*
|
|
3412
|
-
*
|
|
3334
|
+
* 按支付唯一号、后端支付 ID、自定义支付方式 ID 或旧 uuid 更新支付项。
|
|
3335
|
+
*
|
|
3336
|
+
* 该方法服务 PaymentModal 的 void / 编辑场景;更新 metadata 时会做浅合并,
|
|
3337
|
+
* 避免覆盖 unique_payment_number、现金实付/找零等已有元数据。
|
|
3413
3338
|
*/
|
|
3414
3339
|
}, {
|
|
3415
3340
|
key: "updateOrderPayment",
|
|
3416
|
-
value:
|
|
3417
|
-
var
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
}
|
|
3439
|
-
throw new Error("\u672A\u627E\u5230\u652F\u4ED8\u9879: ".concat(identity));
|
|
3440
|
-
case 7:
|
|
3441
|
-
updatedPayment = null;
|
|
3442
|
-
tempOrder.payments = (tempOrder.payments || []).map(function (payment, index) {
|
|
3443
|
-
if (index !== matchedPayment.index) return payment;
|
|
3444
|
-
var nextPayment = mergeOrderPaymentRecord(payment, _objectSpread(_objectSpread({}, updates), {}, {
|
|
3445
|
-
updated_at: updates.updated_at || dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
3446
|
-
}));
|
|
3447
|
-
updatedPayment = nextPayment;
|
|
3448
|
-
return nextPayment;
|
|
3449
|
-
});
|
|
3450
|
-
this.persistTempOrder();
|
|
3451
|
-
_context18.next = 12;
|
|
3452
|
-
return this.recalculateSummary({
|
|
3453
|
-
createIfMissing: true
|
|
3454
|
-
});
|
|
3455
|
-
case 12:
|
|
3456
|
-
summary = _context18.sent;
|
|
3457
|
-
this.persistTempOrder();
|
|
3458
|
-
payments = tempOrder.payments;
|
|
3459
|
-
return _context18.abrupt("return", {
|
|
3460
|
-
updated: true,
|
|
3461
|
-
payment: payments[matchedPayment.index] || updatedPayment,
|
|
3462
|
-
payments: payments,
|
|
3463
|
-
summary: summary
|
|
3464
|
-
});
|
|
3465
|
-
case 16:
|
|
3466
|
-
case "end":
|
|
3467
|
-
return _context18.stop();
|
|
3468
|
-
}
|
|
3469
|
-
}, _callee16, this);
|
|
3470
|
-
}));
|
|
3471
|
-
function updateOrderPayment(_x15, _x16) {
|
|
3472
|
-
return _updateOrderPayment.apply(this, arguments);
|
|
3473
|
-
}
|
|
3474
|
-
return updateOrderPayment;
|
|
3475
|
-
}() /** 从当前订单支付项中移除指定支付项。 */)
|
|
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
|
+
/** 从当前订单支付项中移除指定支付项。 */
|
|
3476
3363
|
}, {
|
|
3477
3364
|
key: "deleteOrderPayment",
|
|
3478
3365
|
value: function deleteOrderPayment(paymentIdentity) {
|
|
3479
3366
|
var tempOrder = this.ensureTempOrder();
|
|
3480
3367
|
var identity = String(paymentIdentity);
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
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
|
+
});
|
|
3485
3377
|
});
|
|
3486
3378
|
this.persistTempOrder();
|
|
3487
3379
|
return tempOrder.payments;
|
|
@@ -3513,7 +3405,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3513
3405
|
}, {
|
|
3514
3406
|
key: "applyPaymentLifecycleChange",
|
|
3515
3407
|
value: function applyPaymentLifecycleChange(tempOrder, options) {
|
|
3516
|
-
var
|
|
3408
|
+
var _this21 = this;
|
|
3517
3409
|
this.updateTempOrderPaymentStatus(tempOrder);
|
|
3518
3410
|
if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
|
|
3519
3411
|
this.persistTempOrder();
|
|
@@ -3523,7 +3415,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3523
3415
|
void this.recalculateSummary({
|
|
3524
3416
|
createIfMissing: true
|
|
3525
3417
|
}).catch(function (error) {
|
|
3526
|
-
|
|
3418
|
+
_this21.logError("recalculate summary after ".concat(logContext, " failed"), {
|
|
3527
3419
|
error: error instanceof Error ? error.message : String(error)
|
|
3528
3420
|
});
|
|
3529
3421
|
});
|
|
@@ -3567,7 +3459,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3567
3459
|
}, {
|
|
3568
3460
|
key: "updateVoucherOrderPayments",
|
|
3569
3461
|
value: function updateVoucherOrderPayments(payments, options) {
|
|
3570
|
-
var
|
|
3462
|
+
var _this22 = this;
|
|
3571
3463
|
var tempOrder = this.ensureTempOrder();
|
|
3572
3464
|
var isOrderPaymentType = function isOrderPaymentType(value) {
|
|
3573
3465
|
return value === 'normal' || value === 'deposit';
|
|
@@ -3602,9 +3494,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3602
3494
|
});
|
|
3603
3495
|
};
|
|
3604
3496
|
var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
|
|
3605
|
-
return
|
|
3606
|
-
defaultPaid: false
|
|
3607
|
-
devicePrefix: options === null || options === void 0 ? void 0 : options.devicePrefix
|
|
3497
|
+
return _this22.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
|
|
3498
|
+
defaultPaid: false
|
|
3608
3499
|
});
|
|
3609
3500
|
})).filter(function (payment) {
|
|
3610
3501
|
return isVoucherPaymentRecord(payment);
|
|
@@ -3652,93 +3543,54 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3652
3543
|
void this.recalculateSummary({
|
|
3653
3544
|
createIfMissing: true
|
|
3654
3545
|
}).catch(function (error) {
|
|
3655
|
-
|
|
3546
|
+
_this22.logError('recalculate summary after updateVoucherOrderPayments failed', {
|
|
3656
3547
|
error: error instanceof Error ? error.message : String(error)
|
|
3657
3548
|
});
|
|
3658
3549
|
});
|
|
3659
3550
|
return tempOrder.payments;
|
|
3660
3551
|
}
|
|
3661
|
-
}, {
|
|
3662
|
-
key: "updateVoucherOrderPaymentsAsync",
|
|
3663
|
-
value: function () {
|
|
3664
|
-
var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(payments, options) {
|
|
3665
|
-
var needsPaymentNumber, devicePrefix;
|
|
3666
|
-
return _regeneratorRuntime().wrap(function _callee17$(_context19) {
|
|
3667
|
-
while (1) switch (_context19.prev = _context19.next) {
|
|
3668
|
-
case 0:
|
|
3669
|
-
needsPaymentNumber = (payments || []).some(function (payment) {
|
|
3670
|
-
return String(payment.payment_number || '').trim() === '';
|
|
3671
|
-
});
|
|
3672
|
-
if (!needsPaymentNumber) {
|
|
3673
|
-
_context19.next = 7;
|
|
3674
|
-
break;
|
|
3675
|
-
}
|
|
3676
|
-
_context19.next = 4;
|
|
3677
|
-
return this.getPaymentNumberDevicePrefixAsync();
|
|
3678
|
-
case 4:
|
|
3679
|
-
_context19.t0 = _context19.sent;
|
|
3680
|
-
_context19.next = 8;
|
|
3681
|
-
break;
|
|
3682
|
-
case 7:
|
|
3683
|
-
_context19.t0 = 'LOCAL';
|
|
3684
|
-
case 8:
|
|
3685
|
-
devicePrefix = _context19.t0;
|
|
3686
|
-
return _context19.abrupt("return", this.updateVoucherOrderPayments(payments, _objectSpread(_objectSpread({}, options), {}, {
|
|
3687
|
-
devicePrefix: devicePrefix
|
|
3688
|
-
})));
|
|
3689
|
-
case 10:
|
|
3690
|
-
case "end":
|
|
3691
|
-
return _context19.stop();
|
|
3692
|
-
}
|
|
3693
|
-
}, _callee17, this);
|
|
3694
|
-
}));
|
|
3695
|
-
function updateVoucherOrderPaymentsAsync(_x17, _x18) {
|
|
3696
|
-
return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
|
|
3697
|
-
}
|
|
3698
|
-
return updateVoucherOrderPaymentsAsync;
|
|
3699
|
-
}()
|
|
3700
3552
|
}, {
|
|
3701
3553
|
key: "shouldMergeProductToOrder",
|
|
3702
3554
|
value: function () {
|
|
3703
|
-
var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3555
|
+
var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
|
|
3704
3556
|
var _this$orderHooks;
|
|
3705
3557
|
var onBeforeMergeProductToOrder, result;
|
|
3706
|
-
return _regeneratorRuntime().wrap(function
|
|
3707
|
-
while (1) switch (
|
|
3558
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context17) {
|
|
3559
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
3708
3560
|
case 0:
|
|
3709
3561
|
onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
|
|
3710
3562
|
if (onBeforeMergeProductToOrder) {
|
|
3711
|
-
|
|
3563
|
+
_context17.next = 3;
|
|
3712
3564
|
break;
|
|
3713
3565
|
}
|
|
3714
|
-
return
|
|
3566
|
+
return _context17.abrupt("return", true);
|
|
3715
3567
|
case 3:
|
|
3716
|
-
|
|
3568
|
+
_context17.next = 5;
|
|
3717
3569
|
return onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
3718
3570
|
defaultShouldMerge: true
|
|
3719
3571
|
}));
|
|
3720
3572
|
case 5:
|
|
3721
|
-
result =
|
|
3573
|
+
result = _context17.sent;
|
|
3722
3574
|
if (!(typeof result === 'boolean')) {
|
|
3723
|
-
|
|
3575
|
+
_context17.next = 8;
|
|
3724
3576
|
break;
|
|
3725
3577
|
}
|
|
3726
|
-
return
|
|
3578
|
+
return _context17.abrupt("return", result);
|
|
3727
3579
|
case 8:
|
|
3728
3580
|
if (!(result && _typeof(result) === 'object' && typeof result.shouldMerge === 'boolean')) {
|
|
3729
|
-
|
|
3581
|
+
_context17.next = 10;
|
|
3730
3582
|
break;
|
|
3731
3583
|
}
|
|
3732
|
-
return
|
|
3584
|
+
return _context17.abrupt("return", result.shouldMerge);
|
|
3733
3585
|
case 10:
|
|
3734
|
-
return
|
|
3586
|
+
return _context17.abrupt("return", true);
|
|
3735
3587
|
case 11:
|
|
3736
3588
|
case "end":
|
|
3737
|
-
return
|
|
3589
|
+
return _context17.stop();
|
|
3738
3590
|
}
|
|
3739
|
-
},
|
|
3591
|
+
}, _callee15, this);
|
|
3740
3592
|
}));
|
|
3741
|
-
function shouldMergeProductToOrder(
|
|
3593
|
+
function shouldMergeProductToOrder(_x14) {
|
|
3742
3594
|
return _shouldMergeProductToOrder.apply(this, arguments);
|
|
3743
3595
|
}
|
|
3744
3596
|
return shouldMergeProductToOrder;
|
|
@@ -3774,30 +3626,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3774
3626
|
}, {
|
|
3775
3627
|
key: "finalizeProductOrderMutation",
|
|
3776
3628
|
value: function () {
|
|
3777
|
-
var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3778
|
-
return _regeneratorRuntime().wrap(function
|
|
3779
|
-
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) {
|
|
3780
3632
|
case 0:
|
|
3781
3633
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
3782
3634
|
if (options !== null && options !== void 0 && options.skipEditDiscountConfigRefresh) {
|
|
3783
|
-
|
|
3635
|
+
_context18.next = 4;
|
|
3784
3636
|
break;
|
|
3785
3637
|
}
|
|
3786
|
-
|
|
3638
|
+
_context18.next = 4;
|
|
3787
3639
|
return this.ensureEditDiscountConfigForProductChange(tempOrder);
|
|
3788
3640
|
case 4:
|
|
3789
3641
|
if (options !== null && options !== void 0 && options.skipDiscountRecalculation) {
|
|
3790
|
-
|
|
3642
|
+
_context18.next = 7;
|
|
3791
3643
|
break;
|
|
3792
3644
|
}
|
|
3793
|
-
|
|
3645
|
+
_context18.next = 7;
|
|
3794
3646
|
return this.applyPromotion();
|
|
3795
3647
|
case 7:
|
|
3796
3648
|
if (!(options !== null && options !== void 0 && options.skipDiscountRecalculation)) {
|
|
3797
3649
|
this.applyDiscount();
|
|
3798
3650
|
}
|
|
3799
3651
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
3800
|
-
|
|
3652
|
+
_context18.next = 11;
|
|
3801
3653
|
return this.recalculateSummary({
|
|
3802
3654
|
createIfMissing: true
|
|
3803
3655
|
});
|
|
@@ -3805,11 +3657,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3805
3657
|
this.persistTempOrder();
|
|
3806
3658
|
case 12:
|
|
3807
3659
|
case "end":
|
|
3808
|
-
return
|
|
3660
|
+
return _context18.stop();
|
|
3809
3661
|
}
|
|
3810
|
-
},
|
|
3662
|
+
}, _callee16, this);
|
|
3811
3663
|
}));
|
|
3812
|
-
function finalizeProductOrderMutation(
|
|
3664
|
+
function finalizeProductOrderMutation(_x15, _x16) {
|
|
3813
3665
|
return _finalizeProductOrderMutation.apply(this, arguments);
|
|
3814
3666
|
}
|
|
3815
3667
|
return finalizeProductOrderMutation;
|
|
@@ -3824,13 +3676,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3824
3676
|
}, {
|
|
3825
3677
|
key: "appendProductLineToTempOrder",
|
|
3826
3678
|
value: (function () {
|
|
3827
|
-
var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3828
|
-
var
|
|
3679
|
+
var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(tempOrder, product, booking) {
|
|
3680
|
+
var _normalizedIncoming$p,
|
|
3681
|
+
_normalizedIncoming$p2,
|
|
3682
|
+
_booking_uid,
|
|
3829
3683
|
_metadata,
|
|
3830
|
-
|
|
3831
|
-
var linked, productToAdd, incomingFingerprint, normalizedIncoming, incomingBookingUid, hasIncomingGoodPass, hasIncomingProductNote, hasIncomingBookingUid, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList;
|
|
3832
|
-
return _regeneratorRuntime().wrap(function
|
|
3833
|
-
while (1) switch (
|
|
3684
|
+
_this23 = this;
|
|
3685
|
+
var linked, productToAdd, incomingFingerprint, normalizedIncoming, isWeighingProduct, netWeight, incomingBookingUid, hasIncomingGoodPass, hasIncomingProductNote, hasIncomingBookingUid, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList;
|
|
3686
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context19) {
|
|
3687
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
3834
3688
|
case 0:
|
|
3835
3689
|
linked = booking ? this.createLinkedProductAndBooking({
|
|
3836
3690
|
product: product,
|
|
@@ -3839,6 +3693,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3839
3693
|
productToAdd = (linked === null || linked === void 0 ? void 0 : linked.product) || product;
|
|
3840
3694
|
incomingFingerprint = buildProductLineFingerprint(getProductSkuOptions(productToAdd), productToAdd.product_bundle);
|
|
3841
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:
|
|
3842
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;
|
|
3843
3705
|
if (incomingBookingUid !== undefined && incomingBookingUid !== null && String(incomingBookingUid) !== '') {
|
|
3844
3706
|
normalizedIncoming.booking_uid = String(incomingBookingUid);
|
|
@@ -3850,11 +3712,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3850
3712
|
hasIncomingGoodPass = this.hasGoodPassDiscount(normalizedIncoming);
|
|
3851
3713
|
hasIncomingProductNote = this.hasOrderProductLineNote(normalizedIncoming);
|
|
3852
3714
|
hasIncomingBookingUid = this.hasLinkedBookingUid(productToAdd) || this.hasLinkedBookingUid(normalizedIncoming);
|
|
3853
|
-
shouldForceNewLine = !!booking || hasIncomingProductNote || hasIncomingBookingUid;
|
|
3715
|
+
shouldForceNewLine = !!booking || hasIncomingProductNote || hasIncomingBookingUid || isWeighingProduct;
|
|
3854
3716
|
matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
3855
3717
|
var _item$metadata3;
|
|
3856
|
-
if (
|
|
3857
|
-
if (
|
|
3718
|
+
if (_this23.hasGoodPassDiscount(item)) return false;
|
|
3719
|
+
if (_this23.hasOrderProductLineNote(item)) return false;
|
|
3858
3720
|
if (item.order_detail_id !== undefined && item.order_detail_id !== null) return false;
|
|
3859
3721
|
if ((_item$metadata3 = item.metadata) !== null && _item$metadata3 !== void 0 && _item$metadata3.is_edit_for_runtime) return false;
|
|
3860
3722
|
if (item.product_id !== productToAdd.product_id) return false;
|
|
@@ -3865,10 +3727,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3865
3727
|
matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
|
|
3866
3728
|
existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
|
|
3867
3729
|
if (!matchedProduct) {
|
|
3868
|
-
|
|
3730
|
+
_context19.next = 24;
|
|
3869
3731
|
break;
|
|
3870
3732
|
}
|
|
3871
|
-
|
|
3733
|
+
_context19.next = 21;
|
|
3872
3734
|
return this.shouldMergeProductToOrder({
|
|
3873
3735
|
incomingProduct: productToAdd,
|
|
3874
3736
|
normalizedIncoming: normalizedIncoming,
|
|
@@ -3879,14 +3741,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3879
3741
|
tempOrder: tempOrder,
|
|
3880
3742
|
booking: booking
|
|
3881
3743
|
});
|
|
3882
|
-
case 17:
|
|
3883
|
-
_context22.t0 = _context22.sent;
|
|
3884
|
-
_context22.next = 21;
|
|
3885
|
-
break;
|
|
3886
|
-
case 20:
|
|
3887
|
-
_context22.t0 = false;
|
|
3888
3744
|
case 21:
|
|
3889
|
-
|
|
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;
|
|
3890
3752
|
if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
|
|
3891
3753
|
this.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
|
|
3892
3754
|
if (linked) {
|
|
@@ -3938,13 +3800,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3938
3800
|
if (linked) {
|
|
3939
3801
|
tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
|
|
3940
3802
|
}
|
|
3941
|
-
case
|
|
3803
|
+
case 28:
|
|
3942
3804
|
case "end":
|
|
3943
|
-
return
|
|
3805
|
+
return _context19.stop();
|
|
3944
3806
|
}
|
|
3945
|
-
},
|
|
3807
|
+
}, _callee17, this);
|
|
3946
3808
|
}));
|
|
3947
|
-
function appendProductLineToTempOrder(
|
|
3809
|
+
function appendProductLineToTempOrder(_x17, _x18, _x19) {
|
|
3948
3810
|
return _appendProductLineToTempOrder.apply(this, arguments);
|
|
3949
3811
|
}
|
|
3950
3812
|
return appendProductLineToTempOrder;
|
|
@@ -3960,61 +3822,61 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3960
3822
|
}, {
|
|
3961
3823
|
key: "addProductToOrder",
|
|
3962
3824
|
value: (function () {
|
|
3963
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3825
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(product, booking) {
|
|
3964
3826
|
var tempOrder, _ref61, _productRecord$num, productRecord, splitCount, i, singleLine;
|
|
3965
|
-
return _regeneratorRuntime().wrap(function
|
|
3966
|
-
while (1) switch (
|
|
3827
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context20) {
|
|
3828
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
3967
3829
|
case 0:
|
|
3968
3830
|
tempOrder = this.ensureTempOrder();
|
|
3969
3831
|
if (!booking) {
|
|
3970
|
-
|
|
3832
|
+
_context20.next = 18;
|
|
3971
3833
|
break;
|
|
3972
3834
|
}
|
|
3973
3835
|
productRecord = product;
|
|
3974
3836
|
splitCount = getSafeProductNum((_ref61 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref61 !== void 0 ? _ref61 : 1);
|
|
3975
3837
|
if (!(splitCount > 1)) {
|
|
3976
|
-
|
|
3838
|
+
_context20.next = 18;
|
|
3977
3839
|
break;
|
|
3978
3840
|
}
|
|
3979
3841
|
i = 0;
|
|
3980
3842
|
case 6:
|
|
3981
3843
|
if (!(i < splitCount)) {
|
|
3982
|
-
|
|
3844
|
+
_context20.next = 15;
|
|
3983
3845
|
break;
|
|
3984
3846
|
}
|
|
3985
3847
|
singleLine = cloneDeep(productRecord);
|
|
3986
3848
|
singleLine.num = 1;
|
|
3987
3849
|
delete singleLine.product_quantity;
|
|
3988
|
-
|
|
3850
|
+
_context20.next = 12;
|
|
3989
3851
|
return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
|
|
3990
3852
|
case 12:
|
|
3991
3853
|
i += 1;
|
|
3992
|
-
|
|
3854
|
+
_context20.next = 6;
|
|
3993
3855
|
break;
|
|
3994
3856
|
case 15:
|
|
3995
|
-
|
|
3857
|
+
_context20.next = 17;
|
|
3996
3858
|
return this.finalizeProductOrderMutation(tempOrder);
|
|
3997
3859
|
case 17:
|
|
3998
|
-
return
|
|
3860
|
+
return _context20.abrupt("return", tempOrder.products);
|
|
3999
3861
|
case 18:
|
|
4000
|
-
|
|
3862
|
+
_context20.next = 20;
|
|
4001
3863
|
return this.appendProductLineToTempOrder(tempOrder, product, booking);
|
|
4002
3864
|
case 20:
|
|
4003
|
-
|
|
3865
|
+
_context20.next = 22;
|
|
4004
3866
|
return this.finalizeProductOrderMutation(tempOrder);
|
|
4005
3867
|
case 22:
|
|
4006
3868
|
this.logInfo('addProductToOrder success', {
|
|
4007
3869
|
product_id: product.product_id,
|
|
4008
3870
|
with_booking: !!booking
|
|
4009
3871
|
});
|
|
4010
|
-
return
|
|
3872
|
+
return _context20.abrupt("return", tempOrder.products);
|
|
4011
3873
|
case 24:
|
|
4012
3874
|
case "end":
|
|
4013
|
-
return
|
|
3875
|
+
return _context20.stop();
|
|
4014
3876
|
}
|
|
4015
|
-
},
|
|
3877
|
+
}, _callee18, this);
|
|
4016
3878
|
}));
|
|
4017
|
-
function addProductToOrder(
|
|
3879
|
+
function addProductToOrder(_x20, _x21) {
|
|
4018
3880
|
return _addProductToOrder.apply(this, arguments);
|
|
4019
3881
|
}
|
|
4020
3882
|
return addProductToOrder;
|
|
@@ -4032,93 +3894,93 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4032
3894
|
}, {
|
|
4033
3895
|
key: "addProductsToOrder",
|
|
4034
3896
|
value: (function () {
|
|
4035
|
-
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3897
|
+
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(items, options) {
|
|
4036
3898
|
var tempOrder, _iterator20, _step20, item, product, booking, _ref62, _productRecord$num2, productRecord, splitCount, i, singleLine;
|
|
4037
|
-
return _regeneratorRuntime().wrap(function
|
|
4038
|
-
while (1) switch (
|
|
3899
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context21) {
|
|
3900
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
4039
3901
|
case 0:
|
|
4040
3902
|
tempOrder = this.ensureTempOrder();
|
|
4041
3903
|
if (!(!Array.isArray(items) || items.length === 0)) {
|
|
4042
|
-
|
|
3904
|
+
_context21.next = 3;
|
|
4043
3905
|
break;
|
|
4044
3906
|
}
|
|
4045
|
-
return
|
|
3907
|
+
return _context21.abrupt("return", tempOrder.products);
|
|
4046
3908
|
case 3:
|
|
4047
3909
|
_iterator20 = _createForOfIteratorHelper(items || []);
|
|
4048
|
-
|
|
3910
|
+
_context21.prev = 4;
|
|
4049
3911
|
_iterator20.s();
|
|
4050
3912
|
case 6:
|
|
4051
3913
|
if ((_step20 = _iterator20.n()).done) {
|
|
4052
|
-
|
|
3914
|
+
_context21.next = 30;
|
|
4053
3915
|
break;
|
|
4054
3916
|
}
|
|
4055
3917
|
item = _step20.value;
|
|
4056
3918
|
product = item.product, booking = item.booking;
|
|
4057
3919
|
if (product) {
|
|
4058
|
-
|
|
3920
|
+
_context21.next = 11;
|
|
4059
3921
|
break;
|
|
4060
3922
|
}
|
|
4061
|
-
return
|
|
3923
|
+
return _context21.abrupt("continue", 28);
|
|
4062
3924
|
case 11:
|
|
4063
3925
|
if (!booking) {
|
|
4064
|
-
|
|
3926
|
+
_context21.next = 26;
|
|
4065
3927
|
break;
|
|
4066
3928
|
}
|
|
4067
3929
|
productRecord = product;
|
|
4068
3930
|
splitCount = getSafeProductNum((_ref62 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref62 !== void 0 ? _ref62 : 1);
|
|
4069
3931
|
if (!(splitCount > 1)) {
|
|
4070
|
-
|
|
3932
|
+
_context21.next = 26;
|
|
4071
3933
|
break;
|
|
4072
3934
|
}
|
|
4073
3935
|
i = 0;
|
|
4074
3936
|
case 16:
|
|
4075
3937
|
if (!(i < splitCount)) {
|
|
4076
|
-
|
|
3938
|
+
_context21.next = 25;
|
|
4077
3939
|
break;
|
|
4078
3940
|
}
|
|
4079
3941
|
singleLine = cloneDeep(productRecord);
|
|
4080
3942
|
singleLine.num = 1;
|
|
4081
3943
|
delete singleLine.product_quantity;
|
|
4082
|
-
|
|
3944
|
+
_context21.next = 22;
|
|
4083
3945
|
return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
|
|
4084
3946
|
case 22:
|
|
4085
3947
|
i += 1;
|
|
4086
|
-
|
|
3948
|
+
_context21.next = 16;
|
|
4087
3949
|
break;
|
|
4088
3950
|
case 25:
|
|
4089
|
-
return
|
|
3951
|
+
return _context21.abrupt("continue", 28);
|
|
4090
3952
|
case 26:
|
|
4091
|
-
|
|
3953
|
+
_context21.next = 28;
|
|
4092
3954
|
return this.appendProductLineToTempOrder(tempOrder, product, booking);
|
|
4093
3955
|
case 28:
|
|
4094
|
-
|
|
3956
|
+
_context21.next = 6;
|
|
4095
3957
|
break;
|
|
4096
3958
|
case 30:
|
|
4097
|
-
|
|
3959
|
+
_context21.next = 35;
|
|
4098
3960
|
break;
|
|
4099
3961
|
case 32:
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
_iterator20.e(
|
|
3962
|
+
_context21.prev = 32;
|
|
3963
|
+
_context21.t0 = _context21["catch"](4);
|
|
3964
|
+
_iterator20.e(_context21.t0);
|
|
4103
3965
|
case 35:
|
|
4104
|
-
|
|
3966
|
+
_context21.prev = 35;
|
|
4105
3967
|
_iterator20.f();
|
|
4106
|
-
return
|
|
3968
|
+
return _context21.finish(35);
|
|
4107
3969
|
case 38:
|
|
4108
|
-
|
|
3970
|
+
_context21.next = 40;
|
|
4109
3971
|
return this.finalizeProductOrderMutation(tempOrder, options);
|
|
4110
3972
|
case 40:
|
|
4111
3973
|
this.logInfo('addProductsToOrder success', {
|
|
4112
3974
|
itemsCount: items.length
|
|
4113
3975
|
});
|
|
4114
|
-
return
|
|
3976
|
+
return _context21.abrupt("return", tempOrder.products);
|
|
4115
3977
|
case 42:
|
|
4116
3978
|
case "end":
|
|
4117
|
-
return
|
|
3979
|
+
return _context21.stop();
|
|
4118
3980
|
}
|
|
4119
|
-
},
|
|
3981
|
+
}, _callee19, this, [[4, 32, 35, 38]]);
|
|
4120
3982
|
}));
|
|
4121
|
-
function addProductsToOrder(
|
|
3983
|
+
function addProductsToOrder(_x22, _x23) {
|
|
4122
3984
|
return _addProductsToOrder.apply(this, arguments);
|
|
4123
3985
|
}
|
|
4124
3986
|
return addProductsToOrder;
|
|
@@ -4152,17 +4014,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4152
4014
|
}, {
|
|
4153
4015
|
key: "preservePersistedBundlePriceFields",
|
|
4154
4016
|
value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
|
|
4155
|
-
var
|
|
4017
|
+
var _this24 = this;
|
|
4156
4018
|
if (!Array.isArray(nextBundles)) return nextBundles;
|
|
4157
4019
|
if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
|
|
4158
4020
|
var previousByIdentity = new Map();
|
|
4159
4021
|
previousBundles.forEach(function (bundle) {
|
|
4160
|
-
var identity =
|
|
4022
|
+
var identity = _this24.getBundleRuntimeIdentity(bundle);
|
|
4161
4023
|
if (identity) previousByIdentity.set(identity, bundle);
|
|
4162
4024
|
});
|
|
4163
4025
|
return nextBundles.map(function (bundle, index) {
|
|
4164
4026
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
4165
|
-
var previous = previousByIdentity.get(
|
|
4027
|
+
var previous = previousByIdentity.get(_this24.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
|
|
4166
4028
|
if (!previous || _typeof(previous) !== 'object') return bundle;
|
|
4167
4029
|
return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
|
|
4168
4030
|
cover: previous.cover
|
|
@@ -4363,21 +4225,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4363
4225
|
}, {
|
|
4364
4226
|
key: "updateOrderProduct",
|
|
4365
4227
|
value: function () {
|
|
4366
|
-
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4228
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
|
|
4367
4229
|
var tempOrder, updatedProductUid;
|
|
4368
|
-
return _regeneratorRuntime().wrap(function
|
|
4369
|
-
while (1) switch (
|
|
4230
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context22) {
|
|
4231
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
4370
4232
|
case 0:
|
|
4371
4233
|
tempOrder = this.ensureTempOrder();
|
|
4372
4234
|
updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
4373
|
-
|
|
4235
|
+
_context22.next = 4;
|
|
4374
4236
|
return this.applyPromotion();
|
|
4375
4237
|
case 4:
|
|
4376
4238
|
this.applyDiscount({
|
|
4377
4239
|
reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
|
|
4378
4240
|
});
|
|
4379
4241
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4380
|
-
|
|
4242
|
+
_context22.next = 8;
|
|
4381
4243
|
return this.recalculateSummary({
|
|
4382
4244
|
createIfMissing: true
|
|
4383
4245
|
});
|
|
@@ -4386,14 +4248,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4386
4248
|
this.logInfo('updateOrderProduct success', {
|
|
4387
4249
|
params: params
|
|
4388
4250
|
});
|
|
4389
|
-
return
|
|
4251
|
+
return _context22.abrupt("return", tempOrder.products);
|
|
4390
4252
|
case 11:
|
|
4391
4253
|
case "end":
|
|
4392
|
-
return
|
|
4254
|
+
return _context22.stop();
|
|
4393
4255
|
}
|
|
4394
|
-
},
|
|
4256
|
+
}, _callee20, this);
|
|
4395
4257
|
}));
|
|
4396
|
-
function updateOrderProduct(
|
|
4258
|
+
function updateOrderProduct(_x24) {
|
|
4397
4259
|
return _updateOrderProduct.apply(this, arguments);
|
|
4398
4260
|
}
|
|
4399
4261
|
return updateOrderProduct;
|
|
@@ -4401,28 +4263,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4401
4263
|
}, {
|
|
4402
4264
|
key: "updateOrderProducts",
|
|
4403
4265
|
value: function () {
|
|
4404
|
-
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4405
|
-
var
|
|
4266
|
+
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(paramsList) {
|
|
4267
|
+
var _this25 = this;
|
|
4406
4268
|
var tempOrder, reapplyBookingDiscountProductUids;
|
|
4407
|
-
return _regeneratorRuntime().wrap(function
|
|
4408
|
-
while (1) switch (
|
|
4269
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context23) {
|
|
4270
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
4409
4271
|
case 0:
|
|
4410
4272
|
tempOrder = this.ensureTempOrder();
|
|
4411
4273
|
if (paramsList.length) {
|
|
4412
|
-
|
|
4274
|
+
_context23.next = 3;
|
|
4413
4275
|
break;
|
|
4414
4276
|
}
|
|
4415
|
-
return
|
|
4277
|
+
return _context23.abrupt("return", tempOrder.products);
|
|
4416
4278
|
case 3:
|
|
4417
4279
|
reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
|
|
4418
|
-
var updatedProductUid =
|
|
4280
|
+
var updatedProductUid = _this25.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
4419
4281
|
// 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
|
|
4420
4282
|
if (params.allow_booking_discount_reapply && updatedProductUid) {
|
|
4421
4283
|
acc.push(String(updatedProductUid));
|
|
4422
4284
|
}
|
|
4423
4285
|
return acc;
|
|
4424
4286
|
}, []);
|
|
4425
|
-
|
|
4287
|
+
_context23.next = 6;
|
|
4426
4288
|
return this.finalizeAfterProductsMutation(tempOrder, {
|
|
4427
4289
|
reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
|
|
4428
4290
|
});
|
|
@@ -4430,14 +4292,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4430
4292
|
this.logInfo('updateOrderProduct success', {
|
|
4431
4293
|
paramsList: paramsList
|
|
4432
4294
|
});
|
|
4433
|
-
return
|
|
4295
|
+
return _context23.abrupt("return", tempOrder.products);
|
|
4434
4296
|
case 8:
|
|
4435
4297
|
case "end":
|
|
4436
|
-
return
|
|
4298
|
+
return _context23.stop();
|
|
4437
4299
|
}
|
|
4438
|
-
},
|
|
4300
|
+
}, _callee21, this);
|
|
4439
4301
|
}));
|
|
4440
|
-
function updateOrderProducts(
|
|
4302
|
+
function updateOrderProducts(_x25) {
|
|
4441
4303
|
return _updateOrderProducts.apply(this, arguments);
|
|
4442
4304
|
}
|
|
4443
4305
|
return updateOrderProducts;
|
|
@@ -4445,11 +4307,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4445
4307
|
}, {
|
|
4446
4308
|
key: "updateOrderProductQuantity",
|
|
4447
4309
|
value: function () {
|
|
4448
|
-
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4310
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
|
|
4449
4311
|
var _targetProduct$metada17;
|
|
4450
4312
|
var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct;
|
|
4451
|
-
return _regeneratorRuntime().wrap(function
|
|
4452
|
-
while (1) switch (
|
|
4313
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context24) {
|
|
4314
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
4453
4315
|
case 0:
|
|
4454
4316
|
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;
|
|
4455
4317
|
tempOrder = this.ensureTempOrder();
|
|
@@ -4478,7 +4340,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4478
4340
|
productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
|
|
4479
4341
|
}
|
|
4480
4342
|
if (!(productIndex === -1)) {
|
|
4481
|
-
|
|
4343
|
+
_context24.next = 12;
|
|
4482
4344
|
break;
|
|
4483
4345
|
}
|
|
4484
4346
|
throw new Error('[Order] 目标商品不存在,无法更新数量');
|
|
@@ -4492,12 +4354,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4492
4354
|
}));
|
|
4493
4355
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
4494
4356
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
4495
|
-
|
|
4357
|
+
_context24.next = 18;
|
|
4496
4358
|
return this.applyPromotion();
|
|
4497
4359
|
case 18:
|
|
4498
4360
|
this.applyDiscount();
|
|
4499
4361
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4500
|
-
|
|
4362
|
+
_context24.next = 22;
|
|
4501
4363
|
return this.recalculateSummary({
|
|
4502
4364
|
createIfMissing: true
|
|
4503
4365
|
});
|
|
@@ -4506,14 +4368,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4506
4368
|
this.logInfo('updateOrderProductQuantity success', {
|
|
4507
4369
|
params: params
|
|
4508
4370
|
});
|
|
4509
|
-
return
|
|
4371
|
+
return _context24.abrupt("return", tempOrder.products);
|
|
4510
4372
|
case 25:
|
|
4511
4373
|
case "end":
|
|
4512
|
-
return
|
|
4374
|
+
return _context24.stop();
|
|
4513
4375
|
}
|
|
4514
|
-
},
|
|
4376
|
+
}, _callee22, this);
|
|
4515
4377
|
}));
|
|
4516
|
-
function updateOrderProductQuantity(
|
|
4378
|
+
function updateOrderProductQuantity(_x26) {
|
|
4517
4379
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
4518
4380
|
}
|
|
4519
4381
|
return updateOrderProductQuantity;
|
|
@@ -4554,19 +4416,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4554
4416
|
}, {
|
|
4555
4417
|
key: "finalizeAfterProductsMutation",
|
|
4556
4418
|
value: (function () {
|
|
4557
|
-
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4558
|
-
return _regeneratorRuntime().wrap(function
|
|
4559
|
-
while (1) switch (
|
|
4419
|
+
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(tempOrder, options) {
|
|
4420
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context25) {
|
|
4421
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
4560
4422
|
case 0:
|
|
4561
4423
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
4562
|
-
|
|
4424
|
+
_context25.next = 3;
|
|
4563
4425
|
return this.applyPromotion();
|
|
4564
4426
|
case 3:
|
|
4565
4427
|
this.applyDiscount({
|
|
4566
4428
|
reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids
|
|
4567
4429
|
});
|
|
4568
4430
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4569
|
-
|
|
4431
|
+
_context25.next = 7;
|
|
4570
4432
|
return this.recalculateSummary({
|
|
4571
4433
|
createIfMissing: true
|
|
4572
4434
|
});
|
|
@@ -4574,11 +4436,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4574
4436
|
this.persistTempOrder();
|
|
4575
4437
|
case 8:
|
|
4576
4438
|
case "end":
|
|
4577
|
-
return
|
|
4439
|
+
return _context25.stop();
|
|
4578
4440
|
}
|
|
4579
|
-
},
|
|
4441
|
+
}, _callee23, this);
|
|
4580
4442
|
}));
|
|
4581
|
-
function finalizeAfterProductsMutation(
|
|
4443
|
+
function finalizeAfterProductsMutation(_x27, _x28) {
|
|
4582
4444
|
return _finalizeAfterProductsMutation.apply(this, arguments);
|
|
4583
4445
|
}
|
|
4584
4446
|
return finalizeAfterProductsMutation;
|
|
@@ -4593,18 +4455,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4593
4455
|
}, {
|
|
4594
4456
|
key: "removeProductsFromOrder",
|
|
4595
4457
|
value: (function () {
|
|
4596
|
-
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4597
|
-
var
|
|
4458
|
+
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(identities) {
|
|
4459
|
+
var _this26 = this;
|
|
4598
4460
|
var tempOrder, productsBeforeRemove, bookingsBeforeRemove, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3;
|
|
4599
|
-
return _regeneratorRuntime().wrap(function
|
|
4600
|
-
while (1) switch (
|
|
4461
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context27) {
|
|
4462
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
4601
4463
|
case 0:
|
|
4602
4464
|
tempOrder = this.ensureTempOrder();
|
|
4603
4465
|
if (identities.length) {
|
|
4604
|
-
|
|
4466
|
+
_context27.next = 3;
|
|
4605
4467
|
break;
|
|
4606
4468
|
}
|
|
4607
|
-
return
|
|
4469
|
+
return _context27.abrupt("return", tempOrder.products);
|
|
4608
4470
|
case 3:
|
|
4609
4471
|
productsBeforeRemove = tempOrder.products || [];
|
|
4610
4472
|
bookingsBeforeRemove = tempOrder.bookings || [];
|
|
@@ -4627,29 +4489,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4627
4489
|
}
|
|
4628
4490
|
linkedBookingUidsToRemove = new Set();
|
|
4629
4491
|
_iterator21 = _createForOfIteratorHelper(matchedProducts);
|
|
4630
|
-
|
|
4492
|
+
_context27.prev = 11;
|
|
4631
4493
|
_loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
|
|
4632
4494
|
var _metadata11, _metadata12, _metadata13, _metadata14;
|
|
4633
4495
|
var product, productUid, productBookingUid, isAddTimeProduct;
|
|
4634
|
-
return _regeneratorRuntime().wrap(function _loop3$(
|
|
4635
|
-
while (1) switch (
|
|
4496
|
+
return _regeneratorRuntime().wrap(function _loop3$(_context26) {
|
|
4497
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
4636
4498
|
case 0:
|
|
4637
4499
|
product = _step21.value;
|
|
4638
4500
|
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);
|
|
4639
4501
|
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);
|
|
4640
4502
|
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;
|
|
4641
4503
|
if (!isAddTimeProduct) {
|
|
4642
|
-
|
|
4504
|
+
_context26.next = 6;
|
|
4643
4505
|
break;
|
|
4644
4506
|
}
|
|
4645
|
-
return
|
|
4507
|
+
return _context26.abrupt("return", 1);
|
|
4646
4508
|
case 6:
|
|
4647
4509
|
if (productBookingUid !== undefined && productBookingUid !== null && productBookingUid !== '') {
|
|
4648
4510
|
linkedBookingUidsToRemove.add(String(productBookingUid));
|
|
4649
4511
|
}
|
|
4650
4512
|
if (productUid !== undefined && productUid !== null && productUid !== '') {
|
|
4651
4513
|
bookingsBeforeRemove.forEach(function (booking) {
|
|
4652
|
-
var bookingUid =
|
|
4514
|
+
var bookingUid = _this26.getBookingUniqueIdentificationNumber(booking);
|
|
4653
4515
|
if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
|
|
4654
4516
|
linkedBookingUidsToRemove.add(bookingUid);
|
|
4655
4517
|
}
|
|
@@ -4657,37 +4519,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4657
4519
|
}
|
|
4658
4520
|
case 8:
|
|
4659
4521
|
case "end":
|
|
4660
|
-
return
|
|
4522
|
+
return _context26.stop();
|
|
4661
4523
|
}
|
|
4662
4524
|
}, _loop3);
|
|
4663
4525
|
});
|
|
4664
4526
|
_iterator21.s();
|
|
4665
4527
|
case 14:
|
|
4666
4528
|
if ((_step21 = _iterator21.n()).done) {
|
|
4667
|
-
|
|
4529
|
+
_context27.next = 20;
|
|
4668
4530
|
break;
|
|
4669
4531
|
}
|
|
4670
|
-
return
|
|
4532
|
+
return _context27.delegateYield(_loop3(), "t0", 16);
|
|
4671
4533
|
case 16:
|
|
4672
|
-
if (!
|
|
4673
|
-
|
|
4534
|
+
if (!_context27.t0) {
|
|
4535
|
+
_context27.next = 18;
|
|
4674
4536
|
break;
|
|
4675
4537
|
}
|
|
4676
|
-
return
|
|
4538
|
+
return _context27.abrupt("continue", 18);
|
|
4677
4539
|
case 18:
|
|
4678
|
-
|
|
4540
|
+
_context27.next = 14;
|
|
4679
4541
|
break;
|
|
4680
4542
|
case 20:
|
|
4681
|
-
|
|
4543
|
+
_context27.next = 25;
|
|
4682
4544
|
break;
|
|
4683
4545
|
case 22:
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
_iterator21.e(
|
|
4546
|
+
_context27.prev = 22;
|
|
4547
|
+
_context27.t1 = _context27["catch"](11);
|
|
4548
|
+
_iterator21.e(_context27.t1);
|
|
4687
4549
|
case 25:
|
|
4688
|
-
|
|
4550
|
+
_context27.prev = 25;
|
|
4689
4551
|
_iterator21.f();
|
|
4690
|
-
return
|
|
4552
|
+
return _context27.finish(25);
|
|
4691
4553
|
case 28:
|
|
4692
4554
|
if (linkedBookingUidsToRemove.size > 0) {
|
|
4693
4555
|
// 删除主预约商品时,同步移除挂在同一 booking_uid 下的加时商品,避免残留孤儿行。
|
|
@@ -4698,20 +4560,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4698
4560
|
return !(isAddTimeProduct && lineBookingUid !== undefined && lineBookingUid !== null && linkedBookingUidsToRemove.has(String(lineBookingUid)));
|
|
4699
4561
|
});
|
|
4700
4562
|
}
|
|
4701
|
-
|
|
4563
|
+
_context27.next = 31;
|
|
4702
4564
|
return this.finalizeAfterProductsMutation(tempOrder);
|
|
4703
4565
|
case 31:
|
|
4704
4566
|
this.logInfo('removeProductsFromOrder success', {
|
|
4705
4567
|
identities: identities
|
|
4706
4568
|
});
|
|
4707
|
-
return
|
|
4569
|
+
return _context27.abrupt("return", tempOrder.products);
|
|
4708
4570
|
case 33:
|
|
4709
4571
|
case "end":
|
|
4710
|
-
return
|
|
4572
|
+
return _context27.stop();
|
|
4711
4573
|
}
|
|
4712
|
-
},
|
|
4574
|
+
}, _callee24, this, [[11, 22, 25, 28]]);
|
|
4713
4575
|
}));
|
|
4714
|
-
function removeProductsFromOrder(
|
|
4576
|
+
function removeProductsFromOrder(_x29) {
|
|
4715
4577
|
return _removeProductsFromOrder.apply(this, arguments);
|
|
4716
4578
|
}
|
|
4717
4579
|
return removeProductsFromOrder;
|
|
@@ -4719,18 +4581,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4719
4581
|
}, {
|
|
4720
4582
|
key: "removeProductFromOrder",
|
|
4721
4583
|
value: function () {
|
|
4722
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4723
|
-
return _regeneratorRuntime().wrap(function
|
|
4724
|
-
while (1) switch (
|
|
4584
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(identity) {
|
|
4585
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context28) {
|
|
4586
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
4725
4587
|
case 0:
|
|
4726
|
-
return
|
|
4588
|
+
return _context28.abrupt("return", this.removeProductsFromOrder([identity]));
|
|
4727
4589
|
case 1:
|
|
4728
4590
|
case "end":
|
|
4729
|
-
return
|
|
4591
|
+
return _context28.stop();
|
|
4730
4592
|
}
|
|
4731
|
-
},
|
|
4593
|
+
}, _callee25, this);
|
|
4732
4594
|
}));
|
|
4733
|
-
function removeProductFromOrder(
|
|
4595
|
+
function removeProductFromOrder(_x30) {
|
|
4734
4596
|
return _removeProductFromOrder.apply(this, arguments);
|
|
4735
4597
|
}
|
|
4736
4598
|
return removeProductFromOrder;
|
|
@@ -4742,10 +4604,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4742
4604
|
}, {
|
|
4743
4605
|
key: "clearOrderCartLines",
|
|
4744
4606
|
value: (function () {
|
|
4745
|
-
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4607
|
+
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
|
|
4746
4608
|
var tempOrder;
|
|
4747
|
-
return _regeneratorRuntime().wrap(function
|
|
4748
|
-
while (1) switch (
|
|
4609
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context29) {
|
|
4610
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
4749
4611
|
case 0:
|
|
4750
4612
|
tempOrder = this.ensureTempOrder();
|
|
4751
4613
|
tempOrder.products = [];
|
|
@@ -4756,24 +4618,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4756
4618
|
productsByUid: {}
|
|
4757
4619
|
});
|
|
4758
4620
|
}
|
|
4759
|
-
|
|
4621
|
+
_context29.next = 7;
|
|
4760
4622
|
return this.applyPromotion();
|
|
4761
4623
|
case 7:
|
|
4762
4624
|
this.applyDiscount();
|
|
4763
4625
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4764
|
-
|
|
4626
|
+
_context29.next = 11;
|
|
4765
4627
|
return this.recalculateSummary({
|
|
4766
4628
|
createIfMissing: true
|
|
4767
4629
|
});
|
|
4768
4630
|
case 11:
|
|
4769
4631
|
this.persistTempOrder();
|
|
4770
4632
|
this.logInfo('clearOrderCartLines success', {});
|
|
4771
|
-
return
|
|
4633
|
+
return _context29.abrupt("return", tempOrder);
|
|
4772
4634
|
case 14:
|
|
4773
4635
|
case "end":
|
|
4774
|
-
return
|
|
4636
|
+
return _context29.stop();
|
|
4775
4637
|
}
|
|
4776
|
-
},
|
|
4638
|
+
}, _callee26, this);
|
|
4777
4639
|
}));
|
|
4778
4640
|
function clearOrderCartLines() {
|
|
4779
4641
|
return _clearOrderCartLines.apply(this, arguments);
|
|
@@ -4811,17 +4673,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4811
4673
|
}, {
|
|
4812
4674
|
key: "applyLocalPrintOrderNumbers",
|
|
4813
4675
|
value: function () {
|
|
4814
|
-
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4676
|
+
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(order) {
|
|
4815
4677
|
var tempOrder, shopOrderNumber, shopFullOrderNumber;
|
|
4816
|
-
return _regeneratorRuntime().wrap(function
|
|
4817
|
-
while (1) switch (
|
|
4678
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context30) {
|
|
4679
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
4818
4680
|
case 0:
|
|
4819
4681
|
tempOrder = this.ensureTempOrder();
|
|
4820
4682
|
if (!(!order || _typeof(order) !== 'object')) {
|
|
4821
|
-
|
|
4683
|
+
_context30.next = 3;
|
|
4822
4684
|
break;
|
|
4823
4685
|
}
|
|
4824
|
-
return
|
|
4686
|
+
return _context30.abrupt("return", tempOrder);
|
|
4825
4687
|
case 3:
|
|
4826
4688
|
shopOrderNumber = order.shop_order_number;
|
|
4827
4689
|
shopFullOrderNumber = order.shop_full_order_number;
|
|
@@ -4832,88 +4694,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4832
4694
|
tempOrder.shop_full_order_number = String(shopFullOrderNumber);
|
|
4833
4695
|
}
|
|
4834
4696
|
this.persistTempOrder();
|
|
4835
|
-
|
|
4697
|
+
_context30.next = 10;
|
|
4836
4698
|
return this.saveDraft();
|
|
4837
4699
|
case 10:
|
|
4838
|
-
return
|
|
4700
|
+
return _context30.abrupt("return", tempOrder);
|
|
4839
4701
|
case 11:
|
|
4840
4702
|
case "end":
|
|
4841
|
-
return
|
|
4703
|
+
return _context30.stop();
|
|
4842
4704
|
}
|
|
4843
|
-
},
|
|
4705
|
+
}, _callee27, this);
|
|
4844
4706
|
}));
|
|
4845
|
-
function applyLocalPrintOrderNumbers(
|
|
4707
|
+
function applyLocalPrintOrderNumbers(_x31) {
|
|
4846
4708
|
return _applyLocalPrintOrderNumbers.apply(this, arguments);
|
|
4847
4709
|
}
|
|
4848
4710
|
return applyLocalPrintOrderNumbers;
|
|
4849
4711
|
}()
|
|
4850
|
-
}, {
|
|
4851
|
-
key: "saveTempOrderAsDraft",
|
|
4852
|
-
value: function () {
|
|
4853
|
-
var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
|
|
4854
|
-
var _params$cacheId2, _this$otherParams6, _ref74, _params$businessCode2, _this$otherParams7, _this$otherParams8, _params$type, _this$otherParams9, _payload$products;
|
|
4855
|
-
var tempOrder, latestSummary, payload;
|
|
4856
|
-
return _regeneratorRuntime().wrap(function _callee31$(_context34) {
|
|
4857
|
-
while (1) switch (_context34.prev = _context34.next) {
|
|
4858
|
-
case 0:
|
|
4859
|
-
tempOrder = this.ensureTempOrder();
|
|
4860
|
-
this.ensureExternalSaleNumber(tempOrder);
|
|
4861
|
-
this.persistTempOrder();
|
|
4862
|
-
_context34.next = 5;
|
|
4863
|
-
return this.recalculateSummary({
|
|
4864
|
-
createIfMissing: true
|
|
4865
|
-
});
|
|
4866
|
-
case 5:
|
|
4867
|
-
_context34.t1 = _context34.sent;
|
|
4868
|
-
if (_context34.t1) {
|
|
4869
|
-
_context34.next = 8;
|
|
4870
|
-
break;
|
|
4871
|
-
}
|
|
4872
|
-
_context34.t1 = this.store.summary;
|
|
4873
|
-
case 8:
|
|
4874
|
-
_context34.t0 = _context34.t1;
|
|
4875
|
-
if (_context34.t0) {
|
|
4876
|
-
_context34.next = 11;
|
|
4877
|
-
break;
|
|
4878
|
-
}
|
|
4879
|
-
_context34.t0 = createEmptySummary();
|
|
4880
|
-
case 11:
|
|
4881
|
-
latestSummary = _context34.t0;
|
|
4882
|
-
payload = buildSubmitPayload({
|
|
4883
|
-
tempOrder: tempOrder,
|
|
4884
|
-
cacheId: (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId,
|
|
4885
|
-
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform),
|
|
4886
|
-
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,
|
|
4887
|
-
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
4888
|
-
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,
|
|
4889
|
-
summary: latestSummary,
|
|
4890
|
-
enhance: params === null || params === void 0 ? void 0 : params.enhancePayload
|
|
4891
|
-
});
|
|
4892
|
-
if (!payload.created_at) {
|
|
4893
|
-
payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
4894
|
-
}
|
|
4895
|
-
payload.need_sync = 0;
|
|
4896
|
-
payload.is_draft_order = 1;
|
|
4897
|
-
this.logInfo('saveTempOrderAsDraft calling sales draft', {
|
|
4898
|
-
orderId: payload.order_id,
|
|
4899
|
-
externalSaleNumber: payload.external_sale_number,
|
|
4900
|
-
productsCount: ((_payload$products = payload.products) === null || _payload$products === void 0 ? void 0 : _payload$products.length) || 0
|
|
4901
|
-
});
|
|
4902
|
-
return _context34.abrupt("return", this.request.post('/order/sales/draft', payload, {
|
|
4903
|
-
osServer: true,
|
|
4904
|
-
customToast: function customToast() {}
|
|
4905
|
-
}));
|
|
4906
|
-
case 18:
|
|
4907
|
-
case "end":
|
|
4908
|
-
return _context34.stop();
|
|
4909
|
-
}
|
|
4910
|
-
}, _callee31, this);
|
|
4911
|
-
}));
|
|
4912
|
-
function saveTempOrderAsDraft(_x37) {
|
|
4913
|
-
return _saveTempOrderAsDraft.apply(this, arguments);
|
|
4914
|
-
}
|
|
4915
|
-
return saveTempOrderAsDraft;
|
|
4916
|
-
}()
|
|
4917
4712
|
/**
|
|
4918
4713
|
* 提交当前 Sales tempOrder。
|
|
4919
4714
|
*
|
|
@@ -4923,18 +4718,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4923
4718
|
}, {
|
|
4924
4719
|
key: "submitTempOrder",
|
|
4925
4720
|
value: (function () {
|
|
4926
|
-
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4927
|
-
return _regeneratorRuntime().wrap(function
|
|
4928
|
-
while (1) switch (
|
|
4721
|
+
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
|
|
4722
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context31) {
|
|
4723
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
4929
4724
|
case 0:
|
|
4930
|
-
return
|
|
4725
|
+
return _context31.abrupt("return", this.runSubmitTempOrder(params));
|
|
4931
4726
|
case 1:
|
|
4932
4727
|
case "end":
|
|
4933
|
-
return
|
|
4728
|
+
return _context31.stop();
|
|
4934
4729
|
}
|
|
4935
|
-
},
|
|
4730
|
+
}, _callee28, this);
|
|
4936
4731
|
}));
|
|
4937
|
-
function submitTempOrder(
|
|
4732
|
+
function submitTempOrder(_x32) {
|
|
4938
4733
|
return _submitTempOrder.apply(this, arguments);
|
|
4939
4734
|
}
|
|
4940
4735
|
return submitTempOrder;
|
|
@@ -4942,20 +4737,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4942
4737
|
}, {
|
|
4943
4738
|
key: "submitTempOrderAsync",
|
|
4944
4739
|
value: function () {
|
|
4945
|
-
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4946
|
-
return _regeneratorRuntime().wrap(function
|
|
4947
|
-
while (1) switch (
|
|
4740
|
+
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
|
|
4741
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context32) {
|
|
4742
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
4948
4743
|
case 0:
|
|
4949
|
-
return
|
|
4744
|
+
return _context32.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
4950
4745
|
syncMode: true
|
|
4951
4746
|
})));
|
|
4952
4747
|
case 1:
|
|
4953
4748
|
case "end":
|
|
4954
|
-
return
|
|
4749
|
+
return _context32.stop();
|
|
4955
4750
|
}
|
|
4956
|
-
},
|
|
4751
|
+
}, _callee29, this);
|
|
4957
4752
|
}));
|
|
4958
|
-
function submitTempOrderAsync(
|
|
4753
|
+
function submitTempOrderAsync(_x33) {
|
|
4959
4754
|
return _submitTempOrderAsync.apply(this, arguments);
|
|
4960
4755
|
}
|
|
4961
4756
|
return submitTempOrderAsync;
|
|
@@ -4963,11 +4758,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4963
4758
|
}, {
|
|
4964
4759
|
key: "runSubmitTempOrder",
|
|
4965
4760
|
value: function () {
|
|
4966
|
-
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4967
|
-
var _params$
|
|
4761
|
+
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
|
|
4762
|
+
var _params$cacheId2, _this$otherParams6, _ref74, _ref75, _submitSnapshot$busin, _this$otherParams7, _this$otherParams8, _submitSnapshot$type;
|
|
4968
4763
|
var tempOrder, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
|
|
4969
|
-
return _regeneratorRuntime().wrap(function
|
|
4970
|
-
while (1) switch (
|
|
4764
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context33) {
|
|
4765
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
4971
4766
|
case 0:
|
|
4972
4767
|
tempOrder = this.ensureTempOrder();
|
|
4973
4768
|
shouldConfirmPendingVoucherPayments = (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== false;
|
|
@@ -4987,27 +4782,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4987
4782
|
}
|
|
4988
4783
|
}
|
|
4989
4784
|
this.persistTempOrder();
|
|
4990
|
-
|
|
4785
|
+
_context33.next = 8;
|
|
4991
4786
|
return this.recalculateSummary({
|
|
4992
4787
|
createIfMissing: true
|
|
4993
4788
|
});
|
|
4994
4789
|
case 8:
|
|
4995
|
-
|
|
4996
|
-
if (
|
|
4997
|
-
|
|
4790
|
+
_context33.t1 = _context33.sent;
|
|
4791
|
+
if (_context33.t1) {
|
|
4792
|
+
_context33.next = 11;
|
|
4998
4793
|
break;
|
|
4999
4794
|
}
|
|
5000
|
-
|
|
4795
|
+
_context33.t1 = this.store.summary;
|
|
5001
4796
|
case 11:
|
|
5002
|
-
|
|
5003
|
-
if (
|
|
5004
|
-
|
|
4797
|
+
_context33.t0 = _context33.t1;
|
|
4798
|
+
if (_context33.t0) {
|
|
4799
|
+
_context33.next = 14;
|
|
5005
4800
|
break;
|
|
5006
4801
|
}
|
|
5007
|
-
|
|
4802
|
+
_context33.t0 = createEmptySummary();
|
|
5008
4803
|
case 14:
|
|
5009
|
-
latestSummary =
|
|
5010
|
-
effectiveCacheId = (_params$
|
|
4804
|
+
latestSummary = _context33.t0;
|
|
4805
|
+
effectiveCacheId = (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId;
|
|
5011
4806
|
hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
|
|
5012
4807
|
hasSmallTicketDataFlagOverride = (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined;
|
|
5013
4808
|
enhancePayload = hasPaymentOverride || hasPaymentStatusOverride || hasSmallTicketDataFlagOverride || params !== null && params !== void 0 && params.enhancePayload ? function (payload, ctx) {
|
|
@@ -5025,8 +4820,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5025
4820
|
payload = buildSubmitPayload({
|
|
5026
4821
|
tempOrder: tempOrder,
|
|
5027
4822
|
cacheId: effectiveCacheId,
|
|
5028
|
-
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$
|
|
5029
|
-
businessCode: (
|
|
4823
|
+
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform),
|
|
4824
|
+
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,
|
|
5030
4825
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
5031
4826
|
type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
|
|
5032
4827
|
summary: latestSummary,
|
|
@@ -5041,10 +4836,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5041
4836
|
if (!payload.created_at) {
|
|
5042
4837
|
payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
5043
4838
|
}
|
|
5044
|
-
|
|
4839
|
+
_context33.next = 26;
|
|
5045
4840
|
return this.saveDraft();
|
|
5046
4841
|
case 26:
|
|
5047
|
-
|
|
4842
|
+
_context33.prev = 26;
|
|
5048
4843
|
this.logInfo('submitTempOrder calling sales checkout', {
|
|
5049
4844
|
orderId: payload.order_id,
|
|
5050
4845
|
externalSaleNumber: payload.external_sale_number,
|
|
@@ -5054,43 +4849,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5054
4849
|
smallTicketDataFlag: payload.small_ticket_data_flag,
|
|
5055
4850
|
syncMode: payload.sync_mode
|
|
5056
4851
|
});
|
|
5057
|
-
|
|
4852
|
+
_context33.next = 30;
|
|
5058
4853
|
return this.submitSalesOrder({
|
|
5059
4854
|
query: payload
|
|
5060
4855
|
});
|
|
5061
4856
|
case 30:
|
|
5062
|
-
result =
|
|
5063
|
-
|
|
4857
|
+
result = _context33.sent;
|
|
4858
|
+
_context33.next = 43;
|
|
5064
4859
|
break;
|
|
5065
4860
|
case 33:
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
backendErrorResponse = this.extractSubmitErrorResponse(
|
|
4861
|
+
_context33.prev = 33;
|
|
4862
|
+
_context33.t2 = _context33["catch"](26);
|
|
4863
|
+
backendErrorResponse = this.extractSubmitErrorResponse(_context33.t2);
|
|
5069
4864
|
if (!backendErrorResponse) {
|
|
5070
|
-
|
|
4865
|
+
_context33.next = 40;
|
|
5071
4866
|
break;
|
|
5072
4867
|
}
|
|
5073
4868
|
this.store.syncState = 'failed';
|
|
5074
4869
|
this.logSubmitBackendRejected(backendErrorResponse, payload);
|
|
5075
|
-
return
|
|
4870
|
+
return _context33.abrupt("return", backendErrorResponse);
|
|
5076
4871
|
case 40:
|
|
5077
4872
|
this.store.syncState = 'failed';
|
|
5078
4873
|
this.logError('submitTempOrder failed', {
|
|
5079
|
-
error:
|
|
4874
|
+
error: _context33.t2 instanceof Error ? _context33.t2.message : String(_context33.t2),
|
|
5080
4875
|
orderId: payload.order_id,
|
|
5081
4876
|
externalSaleNumber: payload.external_sale_number,
|
|
5082
4877
|
paymentStatus: payload.payment_status,
|
|
5083
4878
|
paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
|
|
5084
4879
|
});
|
|
5085
|
-
throw
|
|
4880
|
+
throw _context33.t2;
|
|
5086
4881
|
case 43:
|
|
5087
4882
|
if (!this.isSubmitResponseRejected(result)) {
|
|
5088
|
-
|
|
4883
|
+
_context33.next = 47;
|
|
5089
4884
|
break;
|
|
5090
4885
|
}
|
|
5091
4886
|
this.store.syncState = 'failed';
|
|
5092
4887
|
this.logSubmitBackendRejected(result, payload);
|
|
5093
|
-
return
|
|
4888
|
+
return _context33.abrupt("return", result);
|
|
5094
4889
|
case 47:
|
|
5095
4890
|
submittedOrderId = this.extractOrderIdFromSubmitResult(result);
|
|
5096
4891
|
this.logInfo('runSubmitTempOrder: 提交成功', {
|
|
@@ -5101,15 +4896,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5101
4896
|
})
|
|
5102
4897
|
});
|
|
5103
4898
|
if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
|
|
5104
|
-
|
|
4899
|
+
_context33.next = 56;
|
|
5105
4900
|
break;
|
|
5106
4901
|
}
|
|
5107
4902
|
tempOrder.order_id = submittedOrderId;
|
|
5108
4903
|
resultRecord = result;
|
|
5109
|
-
|
|
4904
|
+
_context33.next = 54;
|
|
5110
4905
|
return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
|
|
5111
4906
|
case 54:
|
|
5112
|
-
|
|
4907
|
+
_context33.next = 57;
|
|
5113
4908
|
break;
|
|
5114
4909
|
case 56:
|
|
5115
4910
|
if (this.isLocalPendingSubmitResult(result)) {
|
|
@@ -5118,14 +4913,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5118
4913
|
this.store.syncState = 'submitted';
|
|
5119
4914
|
}
|
|
5120
4915
|
case 57:
|
|
5121
|
-
return
|
|
4916
|
+
return _context33.abrupt("return", result);
|
|
5122
4917
|
case 58:
|
|
5123
4918
|
case "end":
|
|
5124
|
-
return
|
|
4919
|
+
return _context33.stop();
|
|
5125
4920
|
}
|
|
5126
|
-
},
|
|
4921
|
+
}, _callee30, this, [[26, 33]]);
|
|
5127
4922
|
}));
|
|
5128
|
-
function runSubmitTempOrder(
|
|
4923
|
+
function runSubmitTempOrder(_x34) {
|
|
5129
4924
|
return _runSubmitTempOrder.apply(this, arguments);
|
|
5130
4925
|
}
|
|
5131
4926
|
return runSubmitTempOrder;
|
|
@@ -5133,10 +4928,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5133
4928
|
}, {
|
|
5134
4929
|
key: "markLocalOrderSynced",
|
|
5135
4930
|
value: function () {
|
|
5136
|
-
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4931
|
+
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(orderId, remoteOrder) {
|
|
5137
4932
|
var tempOrder;
|
|
5138
|
-
return _regeneratorRuntime().wrap(function
|
|
5139
|
-
while (1) switch (
|
|
4933
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context34) {
|
|
4934
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
5140
4935
|
case 0:
|
|
5141
4936
|
tempOrder = this.ensureTempOrder();
|
|
5142
4937
|
tempOrder.order_id = orderId;
|
|
@@ -5144,15 +4939,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5144
4939
|
this.store.lastOrderInfo = remoteOrder;
|
|
5145
4940
|
this.store.syncState = 'submitted';
|
|
5146
4941
|
this.persistTempOrder();
|
|
5147
|
-
|
|
4942
|
+
_context34.next = 8;
|
|
5148
4943
|
return this.saveDraft();
|
|
5149
4944
|
case 8:
|
|
5150
4945
|
case "end":
|
|
5151
|
-
return
|
|
4946
|
+
return _context34.stop();
|
|
5152
4947
|
}
|
|
5153
|
-
},
|
|
4948
|
+
}, _callee31, this);
|
|
5154
4949
|
}));
|
|
5155
|
-
function markLocalOrderSynced(
|
|
4950
|
+
function markLocalOrderSynced(_x35, _x36) {
|
|
5156
4951
|
return _markLocalOrderSynced.apply(this, arguments);
|
|
5157
4952
|
}
|
|
5158
4953
|
return markLocalOrderSynced;
|
|
@@ -5195,10 +4990,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5195
4990
|
value: function extractSubmitErrorResponse(error) {
|
|
5196
4991
|
var _error$response,
|
|
5197
4992
|
_error$response2,
|
|
5198
|
-
|
|
4993
|
+
_this27 = this;
|
|
5199
4994
|
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];
|
|
5200
4995
|
return candidates.find(function (candidate) {
|
|
5201
|
-
return
|
|
4996
|
+
return _this27.isSubmitErrorResponse(candidate);
|
|
5202
4997
|
}) || null;
|
|
5203
4998
|
}
|
|
5204
4999
|
}, {
|
|
@@ -5225,37 +5020,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5225
5020
|
}, {
|
|
5226
5021
|
key: "syncPaymentsToOrder",
|
|
5227
5022
|
value: function () {
|
|
5228
|
-
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5229
|
-
var
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
while (1) switch (_context39.prev = _context39.next) {
|
|
5023
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
|
|
5024
|
+
var _params$confirmPendin;
|
|
5025
|
+
var tempOrder, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, submitResult;
|
|
5026
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context35) {
|
|
5027
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
5234
5028
|
case 0:
|
|
5235
5029
|
tempOrder = this.ensureTempOrder();
|
|
5236
|
-
|
|
5237
|
-
return String(payment.payment_number || '').trim() === '';
|
|
5238
|
-
});
|
|
5239
|
-
if (!needsPaymentNumber) {
|
|
5240
|
-
_context39.next = 8;
|
|
5241
|
-
break;
|
|
5242
|
-
}
|
|
5243
|
-
_context39.next = 5;
|
|
5244
|
-
return this.getPaymentNumberDevicePrefixAsync();
|
|
5245
|
-
case 5:
|
|
5246
|
-
_context39.t0 = _context39.sent;
|
|
5247
|
-
_context39.next = 9;
|
|
5248
|
-
break;
|
|
5249
|
-
case 8:
|
|
5250
|
-
_context39.t0 = 'LOCAL';
|
|
5251
|
-
case 9:
|
|
5252
|
-
devicePrefix = _context39.t0;
|
|
5253
|
-
mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
|
|
5254
|
-
return _this31.normalizePaymentSource(payment, {
|
|
5255
|
-
defaultPaid: false,
|
|
5256
|
-
devicePrefix: devicePrefix
|
|
5257
|
-
});
|
|
5258
|
-
}));
|
|
5030
|
+
mappedPayments = mapPaymentItemsToOrderPayments(params.payments || []);
|
|
5259
5031
|
shouldConfirmPendingVoucherPayments = (_params$confirmPendin = params.confirmPendingVoucherPayments) !== null && _params$confirmPendin !== void 0 ? _params$confirmPendin : params.submitWhenPaid === true;
|
|
5260
5032
|
effectivePayments = shouldConfirmPendingVoucherPayments ? this.confirmPendingVoucherPaymentsInList(mappedPayments) : params.confirmPendingVoucherPayments === false ? this.discardPendingVoucherPaymentsFromList(mappedPayments) : mappedPayments;
|
|
5261
5033
|
completion = this.getPaymentCompletion(effectivePayments);
|
|
@@ -5264,24 +5036,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5264
5036
|
tempOrder.payments = effectivePayments;
|
|
5265
5037
|
tempOrder.payment_status = paymentStatus;
|
|
5266
5038
|
this.persistTempOrder();
|
|
5267
|
-
|
|
5039
|
+
_context35.next = 12;
|
|
5268
5040
|
return this.saveDraft();
|
|
5269
|
-
case
|
|
5041
|
+
case 12:
|
|
5270
5042
|
if (params.submitWhenPaid) {
|
|
5271
|
-
|
|
5043
|
+
_context35.next = 14;
|
|
5272
5044
|
break;
|
|
5273
5045
|
}
|
|
5274
|
-
return
|
|
5275
|
-
case
|
|
5046
|
+
return _context35.abrupt("return", completion);
|
|
5047
|
+
case 14:
|
|
5276
5048
|
if (!(this.store.syncState === 'submitting')) {
|
|
5277
|
-
|
|
5049
|
+
_context35.next = 16;
|
|
5278
5050
|
break;
|
|
5279
5051
|
}
|
|
5280
|
-
return
|
|
5281
|
-
case
|
|
5052
|
+
return _context35.abrupt("return", completion);
|
|
5053
|
+
case 16:
|
|
5282
5054
|
this.store.syncState = 'submitting';
|
|
5283
5055
|
paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, effectivePayments);
|
|
5284
|
-
|
|
5056
|
+
_context35.next = 20;
|
|
5285
5057
|
return this.submitTempOrder({
|
|
5286
5058
|
payments: effectivePayments,
|
|
5287
5059
|
paymentStatus: paymentStatus,
|
|
@@ -5296,18 +5068,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5296
5068
|
return nextPayload;
|
|
5297
5069
|
}
|
|
5298
5070
|
});
|
|
5299
|
-
case
|
|
5300
|
-
submitResult =
|
|
5301
|
-
return
|
|
5071
|
+
case 20:
|
|
5072
|
+
submitResult = _context35.sent;
|
|
5073
|
+
return _context35.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
|
|
5302
5074
|
submitResult: submitResult
|
|
5303
5075
|
}));
|
|
5304
|
-
case
|
|
5076
|
+
case 22:
|
|
5305
5077
|
case "end":
|
|
5306
|
-
return
|
|
5078
|
+
return _context35.stop();
|
|
5307
5079
|
}
|
|
5308
|
-
},
|
|
5080
|
+
}, _callee32, this);
|
|
5309
5081
|
}));
|
|
5310
|
-
function syncPaymentsToOrder(
|
|
5082
|
+
function syncPaymentsToOrder(_x37) {
|
|
5311
5083
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
5312
5084
|
}
|
|
5313
5085
|
return syncPaymentsToOrder;
|
|
@@ -5396,11 +5168,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5396
5168
|
}, {
|
|
5397
5169
|
key: "submitOrder",
|
|
5398
5170
|
value: function () {
|
|
5399
|
-
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5171
|
+
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(order) {
|
|
5400
5172
|
var _order$query$cartItem, _params$bookings, _params$relation_prod;
|
|
5401
5173
|
var url, query, fetchUrl, params;
|
|
5402
|
-
return _regeneratorRuntime().wrap(function
|
|
5403
|
-
while (1) switch (
|
|
5174
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context36) {
|
|
5175
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
5404
5176
|
case 0:
|
|
5405
5177
|
this.logInfo('submitOrder called', {
|
|
5406
5178
|
url: order.url,
|
|
@@ -5420,14 +5192,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5420
5192
|
relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
|
|
5421
5193
|
scheduleDate: params.schedule_date
|
|
5422
5194
|
});
|
|
5423
|
-
return
|
|
5195
|
+
return _context36.abrupt("return", this.request.post(fetchUrl, params));
|
|
5424
5196
|
case 6:
|
|
5425
5197
|
case "end":
|
|
5426
|
-
return
|
|
5198
|
+
return _context36.stop();
|
|
5427
5199
|
}
|
|
5428
|
-
},
|
|
5200
|
+
}, _callee33, this);
|
|
5429
5201
|
}));
|
|
5430
|
-
function submitOrder(
|
|
5202
|
+
function submitOrder(_x38) {
|
|
5431
5203
|
return _submitOrder.apply(this, arguments);
|
|
5432
5204
|
}
|
|
5433
5205
|
return submitOrder;
|
|
@@ -5435,13 +5207,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5435
5207
|
}, {
|
|
5436
5208
|
key: "cancelOrder",
|
|
5437
5209
|
value: function () {
|
|
5438
|
-
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5210
|
+
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
|
|
5439
5211
|
var payload;
|
|
5440
|
-
return _regeneratorRuntime().wrap(function
|
|
5441
|
-
while (1) switch (
|
|
5212
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context37) {
|
|
5213
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
5442
5214
|
case 0:
|
|
5443
5215
|
if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
|
|
5444
|
-
|
|
5216
|
+
_context37.next = 2;
|
|
5445
5217
|
break;
|
|
5446
5218
|
}
|
|
5447
5219
|
throw new Error('取消订单失败:order_ids 不能为空');
|
|
@@ -5457,16 +5229,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5457
5229
|
method: 'PUT',
|
|
5458
5230
|
orderIdsCount: params.order_ids.length
|
|
5459
5231
|
});
|
|
5460
|
-
return
|
|
5232
|
+
return _context37.abrupt("return", this.request.put('/order/update-status', payload, {
|
|
5461
5233
|
isShopApi: true
|
|
5462
5234
|
}));
|
|
5463
5235
|
case 5:
|
|
5464
5236
|
case "end":
|
|
5465
|
-
return
|
|
5237
|
+
return _context37.stop();
|
|
5466
5238
|
}
|
|
5467
|
-
},
|
|
5239
|
+
}, _callee34, this);
|
|
5468
5240
|
}));
|
|
5469
|
-
function cancelOrder(
|
|
5241
|
+
function cancelOrder(_x39) {
|
|
5470
5242
|
return _cancelOrder.apply(this, arguments);
|
|
5471
5243
|
}
|
|
5472
5244
|
return cancelOrder;
|
|
@@ -5474,19 +5246,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5474
5246
|
}, {
|
|
5475
5247
|
key: "changeBookingStatus",
|
|
5476
5248
|
value: function () {
|
|
5477
|
-
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5249
|
+
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
|
|
5478
5250
|
var url, payload;
|
|
5479
|
-
return _regeneratorRuntime().wrap(function
|
|
5480
|
-
while (1) switch (
|
|
5251
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context38) {
|
|
5252
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
5481
5253
|
case 0:
|
|
5482
5254
|
if (params.booking_id) {
|
|
5483
|
-
|
|
5255
|
+
_context38.next = 2;
|
|
5484
5256
|
break;
|
|
5485
5257
|
}
|
|
5486
5258
|
throw new Error('变更预约状态失败:booking_id 不能为空');
|
|
5487
5259
|
case 2:
|
|
5488
5260
|
if (params.appointment_status) {
|
|
5489
|
-
|
|
5261
|
+
_context38.next = 4;
|
|
5490
5262
|
break;
|
|
5491
5263
|
}
|
|
5492
5264
|
throw new Error('变更预约状态失败:appointment_status 不能为空');
|
|
@@ -5501,16 +5273,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5501
5273
|
bookingId: params.booking_id,
|
|
5502
5274
|
appointmentStatus: params.appointment_status
|
|
5503
5275
|
});
|
|
5504
|
-
return
|
|
5276
|
+
return _context38.abrupt("return", this.request.put(url, payload, {
|
|
5505
5277
|
isShopApi: true
|
|
5506
5278
|
}));
|
|
5507
5279
|
case 8:
|
|
5508
5280
|
case "end":
|
|
5509
|
-
return
|
|
5281
|
+
return _context38.stop();
|
|
5510
5282
|
}
|
|
5511
|
-
},
|
|
5283
|
+
}, _callee35, this);
|
|
5512
5284
|
}));
|
|
5513
|
-
function changeBookingStatus(
|
|
5285
|
+
function changeBookingStatus(_x40) {
|
|
5514
5286
|
return _changeBookingStatus.apply(this, arguments);
|
|
5515
5287
|
}
|
|
5516
5288
|
return changeBookingStatus;
|
|
@@ -5528,11 +5300,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5528
5300
|
}, {
|
|
5529
5301
|
key: "createOrderByCheckout",
|
|
5530
5302
|
value: (function () {
|
|
5531
|
-
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5303
|
+
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
|
|
5532
5304
|
var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3, _params$bookings3, _params$relation_prod3, _params$payments4;
|
|
5533
5305
|
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;
|
|
5534
|
-
return _regeneratorRuntime().wrap(function
|
|
5535
|
-
while (1) switch (
|
|
5306
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context39) {
|
|
5307
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
5536
5308
|
case 0:
|
|
5537
5309
|
// 过滤掉由在线店铺下单的 payment 支付数据
|
|
5538
5310
|
onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
|
|
@@ -5566,7 +5338,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5566
5338
|
relationProductsCount: ((_params$relation_prod3 = params.relation_products) === null || _params$relation_prod3 === void 0 ? void 0 : _params$relation_prod3.length) || 0,
|
|
5567
5339
|
paymentsCount: ((_params$payments4 = params.payments) === null || _params$payments4 === void 0 ? void 0 : _params$payments4.length) || 0
|
|
5568
5340
|
});
|
|
5569
|
-
|
|
5341
|
+
_context39.prev = 4;
|
|
5570
5342
|
// 构建订单数据,设置默认值并允许 params 覆盖
|
|
5571
5343
|
orderData = _objectSpread({
|
|
5572
5344
|
sales_channel: 'my_pisel',
|
|
@@ -5628,13 +5400,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5628
5400
|
hasOrderId: !!orderData.order_id,
|
|
5629
5401
|
smallTicketDataFlag: orderData.small_ticket_data_flag
|
|
5630
5402
|
});
|
|
5631
|
-
|
|
5403
|
+
_context39.next = 12;
|
|
5632
5404
|
return this.request.post('/order/checkout', orderData, {
|
|
5633
5405
|
osServer: true,
|
|
5634
5406
|
customToast: function customToast() {}
|
|
5635
5407
|
});
|
|
5636
5408
|
case 12:
|
|
5637
|
-
response =
|
|
5409
|
+
response = _context39.sent;
|
|
5638
5410
|
this.logInfo('Order API called successfully', {
|
|
5639
5411
|
response: response
|
|
5640
5412
|
});
|
|
@@ -5642,22 +5414,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5642
5414
|
success: !!response,
|
|
5643
5415
|
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)
|
|
5644
5416
|
});
|
|
5645
|
-
return
|
|
5417
|
+
return _context39.abrupt("return", response);
|
|
5646
5418
|
case 18:
|
|
5647
|
-
|
|
5648
|
-
|
|
5649
|
-
console.error('[Order] createOrderByCheckout 创建订单失败:',
|
|
5419
|
+
_context39.prev = 18;
|
|
5420
|
+
_context39.t0 = _context39["catch"](4);
|
|
5421
|
+
console.error('[Order] createOrderByCheckout 创建订单失败:', _context39.t0);
|
|
5650
5422
|
this.logInfo('Order API called failed', {
|
|
5651
|
-
error:
|
|
5423
|
+
error: _context39.t0 instanceof Error ? _context39.t0.message : String(_context39.t0)
|
|
5652
5424
|
});
|
|
5653
|
-
throw
|
|
5425
|
+
throw _context39.t0;
|
|
5654
5426
|
case 23:
|
|
5655
5427
|
case "end":
|
|
5656
|
-
return
|
|
5428
|
+
return _context39.stop();
|
|
5657
5429
|
}
|
|
5658
|
-
},
|
|
5430
|
+
}, _callee36, this, [[4, 18]]);
|
|
5659
5431
|
}));
|
|
5660
|
-
function createOrderByCheckout(
|
|
5432
|
+
function createOrderByCheckout(_x41) {
|
|
5661
5433
|
return _createOrderByCheckout.apply(this, arguments);
|
|
5662
5434
|
}
|
|
5663
5435
|
return createOrderByCheckout;
|
|
@@ -5665,24 +5437,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5665
5437
|
}, {
|
|
5666
5438
|
key: "submitSalesOrder",
|
|
5667
5439
|
value: function () {
|
|
5668
|
-
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5440
|
+
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
|
|
5669
5441
|
var url, query, fetchUrl;
|
|
5670
|
-
return _regeneratorRuntime().wrap(function
|
|
5671
|
-
while (1) switch (
|
|
5442
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context40) {
|
|
5443
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
5672
5444
|
case 0:
|
|
5673
5445
|
url = params.url, query = params.query;
|
|
5674
5446
|
fetchUrl = url || '/order/sales/checkout';
|
|
5675
|
-
return
|
|
5447
|
+
return _context40.abrupt("return", this.request.post(fetchUrl, query, {
|
|
5676
5448
|
osServer: true,
|
|
5677
5449
|
customToast: function customToast() {}
|
|
5678
5450
|
}));
|
|
5679
5451
|
case 3:
|
|
5680
5452
|
case "end":
|
|
5681
|
-
return
|
|
5453
|
+
return _context40.stop();
|
|
5682
5454
|
}
|
|
5683
|
-
},
|
|
5455
|
+
}, _callee37, this);
|
|
5684
5456
|
}));
|
|
5685
|
-
function submitSalesOrder(
|
|
5457
|
+
function submitSalesOrder(_x42) {
|
|
5686
5458
|
return _submitSalesOrder.apply(this, arguments);
|
|
5687
5459
|
}
|
|
5688
5460
|
return submitSalesOrder;
|
|
@@ -5696,37 +5468,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5696
5468
|
}, {
|
|
5697
5469
|
key: "sendCustomerPayLink",
|
|
5698
5470
|
value: (function () {
|
|
5699
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5471
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
|
|
5700
5472
|
var _params$emails;
|
|
5701
5473
|
var orderIds;
|
|
5702
|
-
return _regeneratorRuntime().wrap(function
|
|
5703
|
-
while (1) switch (
|
|
5474
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context41) {
|
|
5475
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
5704
5476
|
case 0:
|
|
5705
5477
|
orderIds = params.order_ids || params.orderIds || [];
|
|
5706
5478
|
if (orderIds.length) {
|
|
5707
|
-
|
|
5479
|
+
_context41.next = 3;
|
|
5708
5480
|
break;
|
|
5709
5481
|
}
|
|
5710
5482
|
throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
|
|
5711
5483
|
case 3:
|
|
5712
5484
|
if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
|
|
5713
|
-
|
|
5485
|
+
_context41.next = 5;
|
|
5714
5486
|
break;
|
|
5715
5487
|
}
|
|
5716
5488
|
throw new Error('发送支付链接需要至少一个邮箱');
|
|
5717
5489
|
case 5:
|
|
5718
|
-
return
|
|
5490
|
+
return _context41.abrupt("return", this.request.post('/order/batch-email', {
|
|
5719
5491
|
order_ids: orderIds,
|
|
5720
5492
|
notify_action: params.notify_action || 'order_payment_reminder',
|
|
5721
5493
|
emails: params.emails
|
|
5722
5494
|
}));
|
|
5723
5495
|
case 6:
|
|
5724
5496
|
case "end":
|
|
5725
|
-
return
|
|
5497
|
+
return _context41.stop();
|
|
5726
5498
|
}
|
|
5727
|
-
},
|
|
5499
|
+
}, _callee38, this);
|
|
5728
5500
|
}));
|
|
5729
|
-
function sendCustomerPayLink(
|
|
5501
|
+
function sendCustomerPayLink(_x43) {
|
|
5730
5502
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
5731
5503
|
}
|
|
5732
5504
|
return sendCustomerPayLink;
|
|
@@ -5734,14 +5506,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5734
5506
|
}, {
|
|
5735
5507
|
key: "getSalesOrderByLookup",
|
|
5736
5508
|
value: function () {
|
|
5737
|
-
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5509
|
+
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
|
|
5738
5510
|
var lookup, res;
|
|
5739
|
-
return _regeneratorRuntime().wrap(function
|
|
5740
|
-
while (1) switch (
|
|
5511
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context42) {
|
|
5512
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
5741
5513
|
case 0:
|
|
5742
5514
|
lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
|
|
5743
5515
|
if (lookup) {
|
|
5744
|
-
|
|
5516
|
+
_context42.next = 3;
|
|
5745
5517
|
break;
|
|
5746
5518
|
}
|
|
5747
5519
|
throw new Error('加载销售详情需要 lookup');
|
|
@@ -5750,7 +5522,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5750
5522
|
if (lookup.startsWith('LOCAL_')) {
|
|
5751
5523
|
params.forceRemote = false;
|
|
5752
5524
|
}
|
|
5753
|
-
|
|
5525
|
+
_context42.next = 6;
|
|
5754
5526
|
return this.request.get("/order/sales/".concat(encodeURIComponent(lookup)), _objectSpread({
|
|
5755
5527
|
with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info']
|
|
5756
5528
|
}, params.forceRemote ? {
|
|
@@ -5759,18 +5531,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5759
5531
|
osServer: true
|
|
5760
5532
|
});
|
|
5761
5533
|
case 6:
|
|
5762
|
-
res =
|
|
5534
|
+
res = _context42.sent;
|
|
5763
5535
|
if (res.code === 200) {
|
|
5764
5536
|
this.store.lastOrderInfo = res.data;
|
|
5765
5537
|
}
|
|
5766
|
-
return
|
|
5538
|
+
return _context42.abrupt("return", res);
|
|
5767
5539
|
case 9:
|
|
5768
5540
|
case "end":
|
|
5769
|
-
return
|
|
5541
|
+
return _context42.stop();
|
|
5770
5542
|
}
|
|
5771
|
-
},
|
|
5543
|
+
}, _callee39, this);
|
|
5772
5544
|
}));
|
|
5773
|
-
function getSalesOrderByLookup(
|
|
5545
|
+
function getSalesOrderByLookup(_x44) {
|
|
5774
5546
|
return _getSalesOrderByLookup.apply(this, arguments);
|
|
5775
5547
|
}
|
|
5776
5548
|
return getSalesOrderByLookup;
|
|
@@ -5784,11 +5556,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5784
5556
|
}, {
|
|
5785
5557
|
key: "hydrateTempOrderFromRecord",
|
|
5786
5558
|
value: (function () {
|
|
5787
|
-
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5559
|
+
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(record, options) {
|
|
5788
5560
|
var _this$store$discount19;
|
|
5789
|
-
var sourceRaw, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, nextTempOrder,
|
|
5790
|
-
return _regeneratorRuntime().wrap(function
|
|
5791
|
-
while (1) switch (
|
|
5561
|
+
var sourceRaw, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, nextTempOrder, rawSummary, summarySurcharges, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount20, _this$store$discount21;
|
|
5562
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context43) {
|
|
5563
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
5792
5564
|
case 0:
|
|
5793
5565
|
sourceRaw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
|
|
5794
5566
|
identityReadySource = this.seedAnonymousBookingUidsFromProducts(sourceRaw);
|
|
@@ -5813,13 +5585,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5813
5585
|
}
|
|
5814
5586
|
nextTempOrder = this.normalizeTempOrderForRuntime(raw, {
|
|
5815
5587
|
makeEditMark: true
|
|
5816
|
-
});
|
|
5817
|
-
sourceLastOrderInfo = raw.lastOrderInfo || raw;
|
|
5818
|
-
isDraftOrder = Number(nextTempOrder.is_draft_order || 0) === 1;
|
|
5819
|
-
syntheticIdentityOptions = {
|
|
5820
|
-
isDraftOrder: isDraftOrder,
|
|
5821
|
-
externalSaleNumber: nextTempOrder.external_sale_number
|
|
5822
|
-
};
|
|
5588
|
+
});
|
|
5823
5589
|
rawSummary = raw.summary && _typeof(raw.summary) === 'object' ? raw.summary : {};
|
|
5824
5590
|
summarySurcharges = Array.isArray(rawSummary.surcharges) ? rawSummary.surcharges.map(function (s) {
|
|
5825
5591
|
return _objectSpread({}, s || {});
|
|
@@ -5839,11 +5605,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5839
5605
|
productFingerprint: this.buildOrderProductsFingerprint(nextTempOrder.products || [])
|
|
5840
5606
|
}
|
|
5841
5607
|
});
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
|
|
5845
|
-
|
|
5846
|
-
}
|
|
5608
|
+
// lastOrderInfo carries the exact backend snapshot used by deposit/type recovery.
|
|
5609
|
+
// Runtime collection repair lives in tempOrder/originalSalesSnapshot and must not
|
|
5610
|
+
// rewrite this protocol snapshot as a side effect of hydration.
|
|
5611
|
+
this.store.lastOrderInfo = sourceRaw.lastOrderInfo || sourceRaw;
|
|
5847
5612
|
hydratedEditDiscounts = this.collectHydratedEditDiscounts(nextTempOrder.products);
|
|
5848
5613
|
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() || [] : [];
|
|
5849
5614
|
currentScanDiscounts = currentDiscounts.filter(function (discount) {
|
|
@@ -5858,34 +5623,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5858
5623
|
nextDiscounts = [].concat(_toConsumableArray(hydratedEditDiscounts), _toConsumableArray(retainedScanDiscounts));
|
|
5859
5624
|
shouldSkipEmptyDiscountSync = nextDiscounts.length === 0 && currentDiscounts.length === 0;
|
|
5860
5625
|
if (shouldSkipEmptyDiscountSync) {
|
|
5861
|
-
|
|
5626
|
+
_context43.next = 26;
|
|
5862
5627
|
break;
|
|
5863
5628
|
}
|
|
5864
5629
|
OrderModule.populateSavedAmounts(nextTempOrder.products, nextDiscounts);
|
|
5865
|
-
|
|
5630
|
+
_context43.next = 24;
|
|
5866
5631
|
return (_this$store$discount20 = this.store.discount) === null || _this$store$discount20 === void 0 ? void 0 : _this$store$discount20.setOriginalDiscountList(nextDiscounts);
|
|
5867
|
-
case
|
|
5868
|
-
|
|
5632
|
+
case 24:
|
|
5633
|
+
_context43.next = 26;
|
|
5869
5634
|
return (_this$store$discount21 = this.store.discount) === null || _this$store$discount21 === void 0 ? void 0 : _this$store$discount21.setDiscountList(nextDiscounts);
|
|
5870
|
-
case
|
|
5635
|
+
case 26:
|
|
5871
5636
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
5872
|
-
|
|
5637
|
+
_context43.next = 29;
|
|
5873
5638
|
break;
|
|
5874
5639
|
}
|
|
5875
|
-
|
|
5640
|
+
_context43.next = 29;
|
|
5876
5641
|
return this.recalculateSummary({
|
|
5877
5642
|
createIfMissing: false
|
|
5878
5643
|
});
|
|
5879
|
-
case
|
|
5644
|
+
case 29:
|
|
5880
5645
|
this.persistTempOrder();
|
|
5881
|
-
return
|
|
5882
|
-
case
|
|
5646
|
+
return _context43.abrupt("return", nextTempOrder);
|
|
5647
|
+
case 31:
|
|
5883
5648
|
case "end":
|
|
5884
|
-
return
|
|
5649
|
+
return _context43.stop();
|
|
5885
5650
|
}
|
|
5886
|
-
},
|
|
5651
|
+
}, _callee40, this);
|
|
5887
5652
|
}));
|
|
5888
|
-
function hydrateTempOrderFromRecord(
|
|
5653
|
+
function hydrateTempOrderFromRecord(_x45, _x46) {
|
|
5889
5654
|
return _hydrateTempOrderFromRecord.apply(this, arguments);
|
|
5890
5655
|
}
|
|
5891
5656
|
return hydrateTempOrderFromRecord;
|
|
@@ -5999,12 +5764,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5999
5764
|
}, {
|
|
6000
5765
|
key: "normalizeTempOrderForRuntime",
|
|
6001
5766
|
value: function normalizeTempOrderForRuntime(raw, options) {
|
|
6002
|
-
var
|
|
6003
|
-
var
|
|
6004
|
-
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
|
|
5767
|
+
var _this28 = this;
|
|
5768
|
+
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), raw || {});
|
|
6005
5769
|
// ES 列表详情使用 id 表示订单主键;OS 详情态统一依赖 order_id 驱动操作按钮。
|
|
6006
|
-
if ((nextTempOrder.order_id === undefined || nextTempOrder.order_id === null) && (
|
|
6007
|
-
nextTempOrder.order_id =
|
|
5770
|
+
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) {
|
|
5771
|
+
nextTempOrder.order_id = raw.id;
|
|
6008
5772
|
}
|
|
6009
5773
|
delete nextTempOrder.summary;
|
|
6010
5774
|
delete nextTempOrder.lastOrderInfo;
|
|
@@ -6023,12 +5787,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6023
5787
|
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
6024
5788
|
var rawProducts = Array.isArray(raw.products) ? raw.products : [];
|
|
6025
5789
|
nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
|
|
6026
|
-
return
|
|
5790
|
+
return _this28.normalizeHydratedOrderProduct(p, {
|
|
6027
5791
|
makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
|
|
6028
5792
|
});
|
|
6029
5793
|
}) : [];
|
|
6030
5794
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
6031
|
-
var booking =
|
|
5795
|
+
var booking = _this28.normalizeHydratedBookingHolder(b || {});
|
|
6032
5796
|
return _objectSpread(_objectSpread({}, booking), {}, {
|
|
6033
5797
|
is_all: normalizeBookingIsAll(booking),
|
|
6034
5798
|
sub_type: normalizeBookingSubType(booking)
|
|
@@ -6058,7 +5822,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6058
5822
|
_step24;
|
|
6059
5823
|
try {
|
|
6060
5824
|
for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
|
|
6061
|
-
var _product$metadata11,
|
|
5825
|
+
var _product$metadata11, _ref76, _ref77, _existed$origin, _rawProduct$metadata;
|
|
6062
5826
|
var _step24$value = _slicedToArray(_step24.value, 2),
|
|
6063
5827
|
index = _step24$value[0],
|
|
6064
5828
|
product = _step24$value[1];
|
|
@@ -6066,7 +5830,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6066
5830
|
if (!uid) continue;
|
|
6067
5831
|
var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
|
|
6068
5832
|
var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
|
|
6069
|
-
var origin = (
|
|
5833
|
+
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;
|
|
6070
5834
|
var originSnapshot = cloneDeep(origin);
|
|
6071
5835
|
var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
|
|
6072
5836
|
if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
|
|
@@ -6094,23 +5858,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6094
5858
|
nextTempOrder.vouchers = raw.vouchers || [];
|
|
6095
5859
|
return nextTempOrder;
|
|
6096
5860
|
}
|
|
6097
|
-
}, {
|
|
6098
|
-
key: "isSyntheticDraftOrderIdForRuntime",
|
|
6099
|
-
value: function isSyntheticDraftOrderIdForRuntime(record, options) {
|
|
6100
|
-
var _options$isDraftOrder, _record$external_sale;
|
|
6101
|
-
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;
|
|
6102
|
-
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;
|
|
6103
|
-
var orderId = record === null || record === void 0 ? void 0 : record.order_id;
|
|
6104
|
-
return Boolean(isDraftOrder && orderId !== undefined && orderId !== null && orderId !== '' && externalSaleNumber !== undefined && externalSaleNumber !== null && externalSaleNumber !== '' && String(orderId) === String(externalSaleNumber));
|
|
6105
|
-
}
|
|
6106
|
-
}, {
|
|
6107
|
-
key: "withoutSyntheticDraftOrderIdForRuntime",
|
|
6108
|
-
value: function withoutSyntheticDraftOrderIdForRuntime(record, options) {
|
|
6109
|
-
if (!this.isSyntheticDraftOrderIdForRuntime(record, options)) return record;
|
|
6110
|
-
return _objectSpread(_objectSpread({}, record), {}, {
|
|
6111
|
-
order_id: null
|
|
6112
|
-
});
|
|
6113
|
-
}
|
|
6114
5861
|
}, {
|
|
6115
5862
|
key: "hydrateLinkedBookingIdentity",
|
|
6116
5863
|
value: function hydrateLinkedBookingIdentity(tempOrder) {
|
|
@@ -6195,10 +5942,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6195
5942
|
}, {
|
|
6196
5943
|
key: "normalizeHydratedProductOptionItem",
|
|
6197
5944
|
value: function normalizeHydratedProductOptionItem(optionItem) {
|
|
6198
|
-
var
|
|
6199
|
-
var rawNum = (
|
|
5945
|
+
var _ref78, _optionItem$num, _ref79, _optionItem$add_price;
|
|
5946
|
+
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;
|
|
6200
5947
|
var parsedNum = Number(rawNum);
|
|
6201
|
-
var rawPrice = (
|
|
5948
|
+
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;
|
|
6202
5949
|
var parsedPrice = Number(rawPrice);
|
|
6203
5950
|
var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
|
|
6204
5951
|
option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
|
|
@@ -6215,7 +5962,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6215
5962
|
}, {
|
|
6216
5963
|
key: "normalizeHydratedOrderProduct",
|
|
6217
5964
|
value: function normalizeHydratedOrderProduct(product, options) {
|
|
6218
|
-
var
|
|
5965
|
+
var _this29 = this;
|
|
6219
5966
|
var row = _objectSpread({}, product || {});
|
|
6220
5967
|
if (row.num === undefined && row.product_quantity !== undefined) {
|
|
6221
5968
|
row.num = row.product_quantity;
|
|
@@ -6223,7 +5970,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6223
5970
|
var productSku = ensureProductSku(row);
|
|
6224
5971
|
row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
|
|
6225
5972
|
option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
|
|
6226
|
-
return
|
|
5973
|
+
return _this29.normalizeHydratedProductOptionItem(optionItem || {});
|
|
6227
5974
|
}))
|
|
6228
5975
|
});
|
|
6229
5976
|
delete row["product_".concat('option', "_item")];
|
|
@@ -6260,27 +6007,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6260
6007
|
}, {
|
|
6261
6008
|
key: "getOrderInfo",
|
|
6262
6009
|
value: function () {
|
|
6263
|
-
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6010
|
+
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(order_id) {
|
|
6264
6011
|
var res;
|
|
6265
|
-
return _regeneratorRuntime().wrap(function
|
|
6266
|
-
while (1) switch (
|
|
6012
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context44) {
|
|
6013
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
6267
6014
|
case 0:
|
|
6268
|
-
|
|
6015
|
+
_context44.next = 2;
|
|
6269
6016
|
return this.request.get("/order/sales/".concat(order_id), {
|
|
6270
6017
|
with: ['products', 'bookings']
|
|
6271
6018
|
}, {
|
|
6272
6019
|
osServer: true
|
|
6273
6020
|
});
|
|
6274
6021
|
case 2:
|
|
6275
|
-
res =
|
|
6276
|
-
return
|
|
6022
|
+
res = _context44.sent;
|
|
6023
|
+
return _context44.abrupt("return", res);
|
|
6277
6024
|
case 4:
|
|
6278
6025
|
case "end":
|
|
6279
|
-
return
|
|
6026
|
+
return _context44.stop();
|
|
6280
6027
|
}
|
|
6281
|
-
},
|
|
6028
|
+
}, _callee41, this);
|
|
6282
6029
|
}));
|
|
6283
|
-
function getOrderInfo(
|
|
6030
|
+
function getOrderInfo(_x47) {
|
|
6284
6031
|
return _getOrderInfo.apply(this, arguments);
|
|
6285
6032
|
}
|
|
6286
6033
|
return getOrderInfo;
|
|
@@ -6339,10 +6086,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6339
6086
|
_step29;
|
|
6340
6087
|
try {
|
|
6341
6088
|
for (_iterator29.s(); !(_step29 = _iterator29.n()).done;) {
|
|
6342
|
-
var
|
|
6089
|
+
var _ref80, _bundle$num3;
|
|
6343
6090
|
var bundle = _step29.value;
|
|
6344
6091
|
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));
|
|
6345
|
-
var bundleQty = new Decimal(Number(qty) || 1).times(Number((
|
|
6092
|
+
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();
|
|
6346
6093
|
var _iterator30 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
|
|
6347
6094
|
_step30;
|
|
6348
6095
|
try {
|