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