@pisell/pisellos 2.3.29 → 2.3.30
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/index.d.ts +0 -4
- package/dist/model/strategy/adapter/index.js +1 -5
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/Discount/index.d.ts +2 -5
- package/dist/modules/Discount/index.js +7 -30
- package/dist/modules/Discount/types.d.ts +0 -4
- package/dist/modules/Order/index.d.ts +28 -10
- package/dist/modules/Order/index.js +747 -498
- package/dist/modules/Order/payment-utils.d.ts +23 -0
- package/dist/modules/Order/payment-utils.js +203 -0
- package/dist/modules/Order/types.d.ts +33 -3
- package/dist/modules/Order/utils.js +4 -4
- package/dist/modules/Payment/index.d.ts +2 -0
- package/dist/modules/Payment/index.js +78 -49
- package/dist/modules/Payment/types.d.ts +26 -24
- package/dist/modules/Payment/types.js +2 -0
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Product/types.d.ts +0 -22
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +2 -4
- package/dist/modules/ProductList/types.d.ts +0 -2
- package/dist/server/index.d.ts +14 -50
- package/dist/server/index.js +1975 -1395
- package/dist/server/modules/order/index.d.ts +40 -3
- package/dist/server/modules/order/index.js +1200 -501
- package/dist/server/modules/order/types.d.ts +11 -3
- package/dist/server/modules/order/types.js +1 -1
- package/dist/server/modules/products/index.d.ts +7 -26
- package/dist/server/modules/products/index.js +76 -167
- package/dist/server/modules/products/types.d.ts +0 -14
- package/dist/solution/BaseSales/index.d.ts +33 -5
- package/dist/solution/BaseSales/index.js +622 -345
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +2 -1
- package/dist/solution/BookingTicket/types.d.ts +0 -2
- package/dist/solution/ShopDiscount/index.js +14 -15
- package/dist/utils/payment-number.d.ts +9 -0
- package/dist/utils/payment-number.js +69 -0
- package/lib/model/strategy/adapter/index.d.ts +0 -4
- package/lib/model/strategy/adapter/index.js +2 -13
- package/lib/modules/Discount/index.d.ts +2 -5
- package/lib/modules/Discount/index.js +3 -23
- package/lib/modules/Discount/types.d.ts +0 -4
- package/lib/modules/Order/index.d.ts +28 -10
- package/lib/modules/Order/index.js +181 -73
- package/lib/modules/Order/payment-utils.d.ts +23 -0
- package/lib/modules/Order/payment-utils.js +193 -0
- package/lib/modules/Order/types.d.ts +33 -3
- package/lib/modules/Order/utils.js +2 -3
- package/lib/modules/Payment/index.d.ts +2 -0
- package/lib/modules/Payment/index.js +33 -12
- package/lib/modules/Payment/types.d.ts +26 -24
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Product/types.d.ts +0 -22
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +2 -4
- package/lib/modules/ProductList/types.d.ts +0 -2
- package/lib/server/index.d.ts +14 -50
- package/lib/server/index.js +633 -214
- package/lib/server/modules/order/index.d.ts +40 -3
- package/lib/server/modules/order/index.js +434 -31
- package/lib/server/modules/order/types.d.ts +11 -3
- package/lib/server/modules/products/index.d.ts +7 -26
- package/lib/server/modules/products/index.js +35 -114
- package/lib/server/modules/products/types.d.ts +0 -14
- package/lib/solution/BaseSales/index.d.ts +33 -5
- package/lib/solution/BaseSales/index.js +170 -19
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +2 -1
- package/lib/solution/BookingTicket/types.d.ts +0 -2
- package/lib/solution/ShopDiscount/index.js +1 -2
- package/lib/utils/payment-number.d.ts +9 -0
- package/lib/utils/payment-number.js +64 -0
- package/package.json +1 -1
- package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
- package/dist/model/strategy/adapter/dataVariant/adapter.js +0 -167
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +0 -780
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
- package/dist/model/strategy/adapter/dataVariant/examples.js +0 -277
- package/dist/model/strategy/adapter/dataVariant/index.d.ts +0 -4
- package/dist/model/strategy/adapter/dataVariant/index.js +0 -4
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +0 -148
- package/dist/model/strategy/adapter/dataVariant/type.js +0 -54
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
- package/lib/model/strategy/adapter/dataVariant/adapter.js +0 -149
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +0 -583
- package/lib/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
- package/lib/model/strategy/adapter/dataVariant/examples.js +0 -293
- package/lib/model/strategy/adapter/dataVariant/index.d.ts +0 -4
- package/lib/model/strategy/adapter/dataVariant/index.js +0 -38
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +0 -148
- package/lib/model/strategy/adapter/dataVariant/type.js +0 -31
|
@@ -35,6 +35,8 @@ 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";
|
|
38
40
|
import { processCartPromotion, appendPromotionTags as _appendPromotionTags, getOrderProductUid as getPromotionUid } from "../../solution/BaseSales/utils/cartPromotion";
|
|
39
41
|
import { buildProductLineFingerprint, getProductIdentityIndex, getSafeProductNum, isIdentityMatch, normalizeOrderProduct } from "../../solution/ScanOrder/utils";
|
|
40
42
|
import { syncManualProductDiscountProductNum } from "./utils/manualProductDiscount";
|
|
@@ -97,6 +99,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
97
99
|
_defineProperty(_assertThisInitialized(_this), "logger", void 0);
|
|
98
100
|
// LoggerManager 实例
|
|
99
101
|
_defineProperty(_assertThisInitialized(_this), "window", void 0);
|
|
102
|
+
_defineProperty(_assertThisInitialized(_this), "appPlugin", void 0);
|
|
100
103
|
_defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
|
|
101
104
|
_defineProperty(_assertThisInitialized(_this), "salesSummaryModuleName", void 0);
|
|
102
105
|
_defineProperty(_assertThisInitialized(_this), "rulesHooksOverride", void 0);
|
|
@@ -284,7 +287,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
284
287
|
value: function () {
|
|
285
288
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
|
|
286
289
|
var _otherParams$rules, _otherParams$order, _otherParams$hooks;
|
|
287
|
-
var
|
|
290
|
+
var app, otherParams;
|
|
288
291
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
289
292
|
while (1) switch (_context.prev = _context.next) {
|
|
290
293
|
case 0:
|
|
@@ -296,18 +299,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
296
299
|
if (!this.store.summary) {
|
|
297
300
|
this.store.summary = createEmptySummary();
|
|
298
301
|
}
|
|
299
|
-
if (!Array.isArray(this.store.availableWalletIds)) {
|
|
300
|
-
this.store.availableWalletIds = [];
|
|
301
|
-
}
|
|
302
302
|
this.request = this.core.getPlugin('request');
|
|
303
|
-
appPlugin = this.core.getPlugin('app');
|
|
304
|
-
if (appPlugin) {
|
|
305
|
-
_context.next =
|
|
303
|
+
this.appPlugin = this.core.getPlugin('app');
|
|
304
|
+
if (this.appPlugin) {
|
|
305
|
+
_context.next = 8;
|
|
306
306
|
break;
|
|
307
307
|
}
|
|
308
308
|
throw new Error('Order 模块需要 app 插件支持');
|
|
309
|
-
case
|
|
310
|
-
app = appPlugin.getApp();
|
|
309
|
+
case 8:
|
|
310
|
+
app = this.appPlugin.getApp();
|
|
311
311
|
this.logger = app.logger;
|
|
312
312
|
this.window = this.core.getPlugin('window');
|
|
313
313
|
otherParams = options.otherParams || {};
|
|
@@ -319,7 +319,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
319
319
|
this.otherParams = otherParams;
|
|
320
320
|
this.registerDiscountModules(options);
|
|
321
321
|
this.logInfo('OrderModule initialized successfully');
|
|
322
|
-
case
|
|
322
|
+
case 20:
|
|
323
323
|
case "end":
|
|
324
324
|
return _context.stop();
|
|
325
325
|
}
|
|
@@ -496,7 +496,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
496
496
|
value: function () {
|
|
497
497
|
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
498
498
|
var _this$store$tempOrder, _this$store$discount, _this$store$tempOrder2;
|
|
499
|
-
var orderId,
|
|
499
|
+
var orderId, discountList, _this$store$discount2, _this$store$discount3, _this$store$discount4, currentDiscountList, currentEditDiscounts, currentScanDiscounts, currentScanDiscountIds, runtimeDiscountIds, runtimeDiscounts, mergedDiscountList;
|
|
500
500
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
501
501
|
while (1) switch (_context3.prev = _context3.next) {
|
|
502
502
|
case 0:
|
|
@@ -508,18 +508,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
508
508
|
with_good_pass: 1,
|
|
509
509
|
with_discount_card: 1,
|
|
510
510
|
with_wallet_pass_holder: 1,
|
|
511
|
-
with_available_wallet_flag: 1,
|
|
512
|
-
with_available_wallet_pass_flag: 1,
|
|
513
511
|
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
514
512
|
}, orderId ? {
|
|
515
513
|
order_id: orderId
|
|
516
514
|
} : {}));
|
|
517
515
|
case 3:
|
|
518
|
-
|
|
519
|
-
discountList = prepareConfigResult === null || prepareConfigResult === void 0 ? void 0 : prepareConfigResult.discountList;
|
|
520
|
-
this.store.availableWalletIds = (prepareConfigResult === null || prepareConfigResult === void 0 ? void 0 : prepareConfigResult.availableWalletIds) || [];
|
|
516
|
+
discountList = _context3.sent;
|
|
521
517
|
if (!discountList) {
|
|
522
|
-
_context3.next =
|
|
518
|
+
_context3.next = 16;
|
|
523
519
|
break;
|
|
524
520
|
}
|
|
525
521
|
currentDiscountList = ((_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 ? void 0 : _this$store$discount2.getDiscountList()) || [];
|
|
@@ -540,17 +536,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
540
536
|
return true;
|
|
541
537
|
});
|
|
542
538
|
mergedDiscountList = [].concat(_toConsumableArray(currentEditDiscounts), _toConsumableArray(currentScanDiscounts), _toConsumableArray(runtimeDiscounts));
|
|
543
|
-
_context3.next =
|
|
539
|
+
_context3.next = 14;
|
|
544
540
|
return (_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.setOriginalDiscountList(mergedDiscountList);
|
|
545
|
-
case
|
|
546
|
-
_context3.next =
|
|
541
|
+
case 14:
|
|
542
|
+
_context3.next = 16;
|
|
547
543
|
return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.setDiscountList(mergedDiscountList);
|
|
548
|
-
case
|
|
544
|
+
case 16:
|
|
549
545
|
if (params.apply !== false && (_this$store$tempOrder2 = this.store.tempOrder) !== null && _this$store$tempOrder2 !== void 0 && (_this$store$tempOrder2 = _this$store$tempOrder2.products) !== null && _this$store$tempOrder2 !== void 0 && _this$store$tempOrder2.length) {
|
|
550
546
|
this.applyDiscount();
|
|
551
547
|
}
|
|
552
548
|
return _context3.abrupt("return", this.getDiscountList());
|
|
553
|
-
case
|
|
549
|
+
case 18:
|
|
554
550
|
case "end":
|
|
555
551
|
return _context3.stop();
|
|
556
552
|
}
|
|
@@ -567,11 +563,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
567
563
|
var _this$store$discount5;
|
|
568
564
|
return ((_this$store$discount5 = this.store.discount) === null || _this$store$discount5 === void 0 ? void 0 : _this$store$discount5.getDiscountList()) || [];
|
|
569
565
|
}
|
|
570
|
-
}, {
|
|
571
|
-
key: "getAvailableWalletIds",
|
|
572
|
-
value: function getAvailableWalletIds() {
|
|
573
|
-
return Array.isArray(this.store.availableWalletIds) ? _toConsumableArray(this.store.availableWalletIds) : [];
|
|
574
|
-
}
|
|
575
566
|
}, {
|
|
576
567
|
key: "syncScannedDiscountsToOriginalDiscountList",
|
|
577
568
|
value: function () {
|
|
@@ -1510,19 +1501,44 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1510
1501
|
var depositPaidAmount = this.calculateDepositPaidAmount(tempOrder.payments || []);
|
|
1511
1502
|
return depositPaidAmount.lt(depositAmount) ? 'deposit' : 'normal';
|
|
1512
1503
|
}
|
|
1504
|
+
}, {
|
|
1505
|
+
key: "getPaymentNumberAppData",
|
|
1506
|
+
value: function getPaymentNumberAppData(key) {
|
|
1507
|
+
var _appPlugin$getData, _app$models, _app$models$getStore, _app$models$getStore$, _app$models$getStore$2;
|
|
1508
|
+
var appPlugin = this.appPlugin;
|
|
1509
|
+
if (!appPlugin) return undefined;
|
|
1510
|
+
var getData = (_appPlugin$getData = appPlugin.getData) === null || _appPlugin$getData === void 0 ? void 0 : _appPlugin$getData.call(appPlugin);
|
|
1511
|
+
if (typeof getData === 'function') return getData(key);
|
|
1512
|
+
var app = appPlugin.getApp();
|
|
1513
|
+
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');
|
|
1514
|
+
return coreData === null || coreData === void 0 ? void 0 : coreData[key];
|
|
1515
|
+
}
|
|
1516
|
+
}, {
|
|
1517
|
+
key: "getPaymentNumberDevicePrefixSync",
|
|
1518
|
+
value: function getPaymentNumberDevicePrefixSync() {
|
|
1519
|
+
var _this7 = this;
|
|
1520
|
+
return resolvePaymentNumberDevicePrefixFromDeviceId(function (key) {
|
|
1521
|
+
return _this7.getPaymentNumberAppData(key);
|
|
1522
|
+
});
|
|
1523
|
+
}
|
|
1524
|
+
}, {
|
|
1525
|
+
key: "getPaymentNumberDevicePrefixAsync",
|
|
1526
|
+
value: function getPaymentNumberDevicePrefixAsync() {
|
|
1527
|
+
var _this8 = this;
|
|
1528
|
+
return resolvePaymentNumberDevicePrefix(function (key) {
|
|
1529
|
+
return _this8.getPaymentNumberAppData(key);
|
|
1530
|
+
});
|
|
1531
|
+
}
|
|
1513
1532
|
}, {
|
|
1514
1533
|
key: "normalizePaymentSource",
|
|
1515
1534
|
value: function normalizePaymentSource(payment, options) {
|
|
1516
1535
|
var _ref19, _paymentRecord$origin;
|
|
1517
1536
|
var paymentRecord = payment;
|
|
1518
1537
|
var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
|
|
1519
|
-
|
|
1520
|
-
metadata.unique_payment_number = createUuidV4();
|
|
1521
|
-
}
|
|
1522
|
-
var normalized = _objectSpread(_objectSpread({}, paymentRecord), {}, {
|
|
1538
|
+
var normalized = ensureOrderPaymentNumber(_objectSpread(_objectSpread({}, paymentRecord), {}, {
|
|
1523
1539
|
metadata: metadata,
|
|
1524
1540
|
origin_amount: (_ref19 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref19 !== void 0 ? _ref19 : '0.00'
|
|
1525
|
-
});
|
|
1541
|
+
}), (options === null || options === void 0 ? void 0 : options.devicePrefix) || this.getPaymentNumberDevicePrefixSync(), createUuidV4);
|
|
1526
1542
|
if (paymentRecord.status !== undefined) {
|
|
1527
1543
|
normalized.status = paymentRecord.status;
|
|
1528
1544
|
} else if ((options === null || options === void 0 ? void 0 : options.defaultPaid) !== false) {
|
|
@@ -1640,16 +1656,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1640
1656
|
}, {
|
|
1641
1657
|
key: "calculatePaidPaymentSummary",
|
|
1642
1658
|
value: function calculatePaidPaymentSummary(payments) {
|
|
1643
|
-
var
|
|
1659
|
+
var _this9 = this;
|
|
1644
1660
|
return (payments || []).reduce(function (summary, payment) {
|
|
1645
1661
|
var paymentRecord = payment;
|
|
1646
1662
|
if (!isPaidPaymentRecord(paymentRecord)) return summary;
|
|
1647
1663
|
return {
|
|
1648
1664
|
customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
|
|
1649
|
-
orderPaidAmount: summary.orderPaidAmount.plus(
|
|
1650
|
-
gapPaidAmount: summary.gapPaidAmount.plus(
|
|
1651
|
-
payServiceChargeAmount: summary.payServiceChargeAmount.plus(
|
|
1652
|
-
roundingAmount: summary.roundingAmount.plus(
|
|
1665
|
+
orderPaidAmount: summary.orderPaidAmount.plus(_this9.calculatePaymentOrderAmount(paymentRecord)),
|
|
1666
|
+
gapPaidAmount: summary.gapPaidAmount.plus(_this9.calculatePaymentGapAmount(paymentRecord)),
|
|
1667
|
+
payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this9.calculatePaymentServiceFee(paymentRecord)),
|
|
1668
|
+
roundingAmount: summary.roundingAmount.plus(_this9.calculatePaymentRoundingAmount(paymentRecord))
|
|
1653
1669
|
};
|
|
1654
1670
|
}, {
|
|
1655
1671
|
customerPaidAmount: new Decimal(0),
|
|
@@ -1851,15 +1867,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1851
1867
|
}, {
|
|
1852
1868
|
key: "normalizeFingerprintValue",
|
|
1853
1869
|
value: function normalizeFingerprintValue(value) {
|
|
1854
|
-
var
|
|
1870
|
+
var _this10 = this;
|
|
1855
1871
|
if (Array.isArray(value)) {
|
|
1856
1872
|
return value.map(function (item) {
|
|
1857
|
-
return
|
|
1873
|
+
return _this10.normalizeFingerprintValue(item);
|
|
1858
1874
|
});
|
|
1859
1875
|
}
|
|
1860
1876
|
if (!value || _typeof(value) !== 'object') return value !== null && value !== void 0 ? value : '';
|
|
1861
1877
|
return Object.keys(value).sort().reduce(function (result, key) {
|
|
1862
|
-
result[key] =
|
|
1878
|
+
result[key] = _this10.normalizeFingerprintValue(value[key]);
|
|
1863
1879
|
return result;
|
|
1864
1880
|
}, {});
|
|
1865
1881
|
}
|
|
@@ -1874,7 +1890,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1874
1890
|
_sku$barcode,
|
|
1875
1891
|
_ref20,
|
|
1876
1892
|
_sku$variant_id,
|
|
1877
|
-
|
|
1893
|
+
_this11 = this;
|
|
1878
1894
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
1879
1895
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
1880
1896
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
@@ -1908,7 +1924,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1908
1924
|
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,
|
|
1909
1925
|
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,
|
|
1910
1926
|
num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
|
|
1911
|
-
add_price:
|
|
1927
|
+
add_price: _this11.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)
|
|
1912
1928
|
};
|
|
1913
1929
|
})
|
|
1914
1930
|
}),
|
|
@@ -1918,8 +1934,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1918
1934
|
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,
|
|
1919
1935
|
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,
|
|
1920
1936
|
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),
|
|
1921
|
-
price:
|
|
1922
|
-
bundle_selling_price:
|
|
1937
|
+
price: _this11.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
|
|
1938
|
+
bundle_selling_price: _this11.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
|
|
1923
1939
|
price_type: (_bundle$price_type = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type !== void 0 ? _bundle$price_type : '',
|
|
1924
1940
|
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 : ''
|
|
1925
1941
|
};
|
|
@@ -1929,7 +1945,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1929
1945
|
return {
|
|
1930
1946
|
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 : '',
|
|
1931
1947
|
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,
|
|
1932
|
-
amount:
|
|
1948
|
+
amount: _this11.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
1933
1949
|
};
|
|
1934
1950
|
}))
|
|
1935
1951
|
};
|
|
@@ -1937,9 +1953,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1937
1953
|
}, {
|
|
1938
1954
|
key: "buildOrderProductsFingerprint",
|
|
1939
1955
|
value: function buildOrderProductsFingerprint(products) {
|
|
1940
|
-
var
|
|
1956
|
+
var _this12 = this;
|
|
1941
1957
|
var items = (products || []).map(function (product) {
|
|
1942
|
-
return
|
|
1958
|
+
return _this12.buildProductFingerprintItem(product);
|
|
1943
1959
|
});
|
|
1944
1960
|
items.sort(function (left, right) {
|
|
1945
1961
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -1961,7 +1977,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1961
1977
|
_sku$barcode2,
|
|
1962
1978
|
_ref30,
|
|
1963
1979
|
_sku$variant_id2,
|
|
1964
|
-
|
|
1980
|
+
_this13 = this;
|
|
1965
1981
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
1966
1982
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
1967
1983
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
@@ -1992,7 +2008,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1992
2008
|
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,
|
|
1993
2009
|
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,
|
|
1994
2010
|
num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
|
|
1995
|
-
add_price:
|
|
2011
|
+
add_price: _this13.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)
|
|
1996
2012
|
};
|
|
1997
2013
|
})
|
|
1998
2014
|
}),
|
|
@@ -2006,14 +2022,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2006
2022
|
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),
|
|
2007
2023
|
price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
|
|
2008
2024
|
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 : '',
|
|
2009
|
-
option:
|
|
2025
|
+
option: _this13.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
|
|
2010
2026
|
var _ref38, _option$id3, _option$option_group_5, _ref39, _option$option_group_6, _option$num3, _option$add_price3;
|
|
2011
2027
|
return {
|
|
2012
2028
|
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,
|
|
2013
2029
|
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,
|
|
2014
2030
|
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,
|
|
2015
2031
|
num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
|
|
2016
|
-
add_price:
|
|
2032
|
+
add_price: _this13.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)
|
|
2017
2033
|
};
|
|
2018
2034
|
}))
|
|
2019
2035
|
};
|
|
@@ -2023,7 +2039,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2023
2039
|
return {
|
|
2024
2040
|
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 : '',
|
|
2025
2041
|
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,
|
|
2026
|
-
amount:
|
|
2042
|
+
amount: _this13.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
2027
2043
|
};
|
|
2028
2044
|
}))
|
|
2029
2045
|
};
|
|
@@ -2031,9 +2047,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2031
2047
|
}, {
|
|
2032
2048
|
key: "buildOrderProductsStructuralFingerprint",
|
|
2033
2049
|
value: function buildOrderProductsStructuralFingerprint(products) {
|
|
2034
|
-
var
|
|
2050
|
+
var _this14 = this;
|
|
2035
2051
|
var items = (products || []).map(function (product) {
|
|
2036
|
-
return
|
|
2052
|
+
return _this14.buildProductStructuralFingerprintItem(product);
|
|
2037
2053
|
});
|
|
2038
2054
|
items.sort(function (left, right) {
|
|
2039
2055
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -2461,9 +2477,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2461
2477
|
}, {
|
|
2462
2478
|
key: "sanitizeTempOrderProducts",
|
|
2463
2479
|
value: function sanitizeTempOrderProducts(tempOrder) {
|
|
2464
|
-
var
|
|
2480
|
+
var _this15 = this;
|
|
2465
2481
|
tempOrder.products = (tempOrder.products || []).map(function (product) {
|
|
2466
|
-
return
|
|
2482
|
+
return _this15.sanitizeOrderProductForTempOrder(product);
|
|
2467
2483
|
});
|
|
2468
2484
|
}
|
|
2469
2485
|
}, {
|
|
@@ -2566,7 +2582,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2566
2582
|
}, {
|
|
2567
2583
|
key: "syncLinkedBookingHoldersToProducts",
|
|
2568
2584
|
value: function syncLinkedBookingHoldersToProducts(tempOrder) {
|
|
2569
|
-
var
|
|
2585
|
+
var _this16 = this;
|
|
2570
2586
|
var bookings = tempOrder.bookings || [];
|
|
2571
2587
|
var products = tempOrder.products || [];
|
|
2572
2588
|
if (!bookings.length || !products.length) return;
|
|
@@ -2591,7 +2607,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2591
2607
|
var bookingUid = product.booking_uid || ((_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.booking_uid);
|
|
2592
2608
|
var linkedBooking = (productUid !== undefined && productUid !== null && String(productUid) !== '' ? bookingByProductUid.get(String(productUid)) : undefined) || (bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '' ? bookingByBookingUid.get(String(bookingUid)) : undefined);
|
|
2593
2609
|
if (linkedBooking) {
|
|
2594
|
-
|
|
2610
|
+
_this16.setProductHolderFromBooking(product, linkedBooking);
|
|
2595
2611
|
}
|
|
2596
2612
|
});
|
|
2597
2613
|
}
|
|
@@ -2719,9 +2735,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2719
2735
|
}, {
|
|
2720
2736
|
key: "findBookingIndexByUniqueIdentificationNumber",
|
|
2721
2737
|
value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
|
|
2722
|
-
var
|
|
2738
|
+
var _this17 = this;
|
|
2723
2739
|
return (tempOrder.bookings || []).findIndex(function (booking) {
|
|
2724
|
-
return
|
|
2740
|
+
return _this17.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
|
|
2725
2741
|
});
|
|
2726
2742
|
}
|
|
2727
2743
|
}, {
|
|
@@ -2729,12 +2745,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2729
2745
|
value: function removeLinkedBookingsForProduct(tempOrder, product) {
|
|
2730
2746
|
var _product$metadata7,
|
|
2731
2747
|
_product$metadata8,
|
|
2732
|
-
|
|
2748
|
+
_this18 = this;
|
|
2733
2749
|
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);
|
|
2734
2750
|
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);
|
|
2735
2751
|
if (!productUid && !bookingUid) return;
|
|
2736
2752
|
tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
|
|
2737
|
-
var currentBookingUid =
|
|
2753
|
+
var currentBookingUid = _this18.getBookingUniqueIdentificationNumber(booking);
|
|
2738
2754
|
if (bookingUid && currentBookingUid === String(bookingUid)) return false;
|
|
2739
2755
|
if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
|
|
2740
2756
|
return true;
|
|
@@ -3067,15 +3083,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3067
3083
|
}, {
|
|
3068
3084
|
key: "productHasCustomerBoundDiscount",
|
|
3069
3085
|
value: function productHasCustomerBoundDiscount(product) {
|
|
3070
|
-
var
|
|
3086
|
+
var _this19 = this;
|
|
3071
3087
|
if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
|
|
3072
|
-
return
|
|
3088
|
+
return _this19.isCustomerBoundDiscount(discount);
|
|
3073
3089
|
})) {
|
|
3074
3090
|
return true;
|
|
3075
3091
|
}
|
|
3076
3092
|
return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
|
|
3077
3093
|
return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
|
|
3078
|
-
return
|
|
3094
|
+
return _this19.isCustomerBoundDiscount(discount);
|
|
3079
3095
|
});
|
|
3080
3096
|
});
|
|
3081
3097
|
}
|
|
@@ -3084,18 +3100,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3084
3100
|
value: function shouldSkipDiscountCalculation(tempOrder) {
|
|
3085
3101
|
var _this$store$discount17,
|
|
3086
3102
|
_this$store$discount18,
|
|
3087
|
-
|
|
3103
|
+
_this20 = this;
|
|
3088
3104
|
if (this.hasActiveCustomerBoundDiscount) return false;
|
|
3089
3105
|
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)) || [];
|
|
3090
3106
|
if (discountList.length > 0) return false;
|
|
3091
3107
|
return !(tempOrder.products || []).some(function (product) {
|
|
3092
|
-
return
|
|
3108
|
+
return _this20.productHasCustomerBoundDiscount(product);
|
|
3093
3109
|
});
|
|
3094
3110
|
}
|
|
3095
3111
|
}, {
|
|
3096
3112
|
key: "clearCustomerBoundDiscounts",
|
|
3097
3113
|
value: function clearCustomerBoundDiscounts(tempOrder) {
|
|
3098
|
-
var
|
|
3114
|
+
var _this21 = this,
|
|
3099
3115
|
_discountModule$getDi,
|
|
3100
3116
|
_discountModule$getOr,
|
|
3101
3117
|
_discountModule$setDi,
|
|
@@ -3104,7 +3120,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3104
3120
|
var filterDiscountList = function filterDiscountList(discountList) {
|
|
3105
3121
|
if (!Array.isArray(discountList)) return [];
|
|
3106
3122
|
return discountList.filter(function (discount) {
|
|
3107
|
-
var shouldRemove =
|
|
3123
|
+
var shouldRemove = _this21.isCustomerBoundDiscount(discount);
|
|
3108
3124
|
if (shouldRemove) didRemoveCustomerBoundDiscount = true;
|
|
3109
3125
|
return !shouldRemove;
|
|
3110
3126
|
});
|
|
@@ -3131,12 +3147,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3131
3147
|
var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
|
|
3132
3148
|
var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
|
|
3133
3149
|
var nextDiscounts = currentDiscounts.filter(function (discount) {
|
|
3134
|
-
if (
|
|
3135
|
-
return !
|
|
3150
|
+
if (_this21.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
3151
|
+
return !_this21.isCustomerBoundDiscount(discount);
|
|
3136
3152
|
});
|
|
3137
3153
|
var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
|
|
3138
|
-
if (
|
|
3139
|
-
return !
|
|
3154
|
+
if (_this21.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
3155
|
+
return !_this21.isCustomerBoundDiscount(discount);
|
|
3140
3156
|
});
|
|
3141
3157
|
void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
|
|
3142
3158
|
void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
|
|
@@ -3207,7 +3223,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3207
3223
|
}
|
|
3208
3224
|
var nextCustomerId = (_tempOrder$customer_i5 = tempOrder.customer_id) !== null && _tempOrder$customer_i5 !== void 0 ? _tempOrder$customer_i5 : null;
|
|
3209
3225
|
if (String(previousCustomerId !== null && previousCustomerId !== void 0 ? previousCustomerId : '') !== String(nextCustomerId !== null && nextCustomerId !== void 0 ? nextCustomerId : '')) {
|
|
3210
|
-
this.store.availableWalletIds = [];
|
|
3211
3226
|
clearTempOrderHolderAssignments(tempOrder);
|
|
3212
3227
|
this.clearCustomerBoundDiscounts(tempOrder);
|
|
3213
3228
|
this.applyDiscount();
|
|
@@ -3252,7 +3267,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3252
3267
|
tempOrder.email = '';
|
|
3253
3268
|
tempOrder.customer = null;
|
|
3254
3269
|
if (tempOrder._extend) delete tempOrder._extend.customerSnapshot;
|
|
3255
|
-
this.store.availableWalletIds = [];
|
|
3256
3270
|
this.clearCustomerBoundDiscounts(tempOrder);
|
|
3257
3271
|
this.persistTempOrder();
|
|
3258
3272
|
this.saveDraftInBackground();
|
|
@@ -3290,23 +3304,71 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3290
3304
|
* 用一组支付来源覆盖当前订单支付项。
|
|
3291
3305
|
*
|
|
3292
3306
|
* 入参允许来自 PaymentModule 的 PaymentItem,内部统一映射为 Sales 协议:
|
|
3293
|
-
* uuid
|
|
3307
|
+
* 新支付来源的 uuid 会作为 payment_number 的唯一号段,id -> custom_payment_id,
|
|
3294
3308
|
* isSynced 等运行态字段不会进入 tempOrder.payments。
|
|
3295
3309
|
*/
|
|
3296
3310
|
}, {
|
|
3297
3311
|
key: "setOrderPayments",
|
|
3298
3312
|
value: function setOrderPayments(payments) {
|
|
3313
|
+
var _this22 = this;
|
|
3299
3314
|
var tempOrder = this.ensureTempOrder();
|
|
3300
|
-
tempOrder.payments = mapPaymentItemsToOrderPayments(payments)
|
|
3315
|
+
tempOrder.payments = mapPaymentItemsToOrderPayments((payments || []).map(function (payment) {
|
|
3316
|
+
return _this22.normalizePaymentSource(payment, {
|
|
3317
|
+
defaultPaid: false
|
|
3318
|
+
});
|
|
3319
|
+
}));
|
|
3301
3320
|
this.persistTempOrder();
|
|
3302
3321
|
return tempOrder.payments;
|
|
3303
3322
|
}
|
|
3304
3323
|
|
|
3305
|
-
/**
|
|
3324
|
+
/** 同步兼容入口:按调用当下的 device_id 或 LOCAL 生成支付编号。 */
|
|
3306
3325
|
}, {
|
|
3307
3326
|
key: "addOrderPayment",
|
|
3308
3327
|
value: function addOrderPayment(payment) {
|
|
3309
|
-
var
|
|
3328
|
+
var hasPaymentNumber = String(payment.payment_number || '').trim() !== '';
|
|
3329
|
+
return this.addOrderPaymentWithDevicePrefix(payment, hasPaymentNumber ? 'LOCAL' : this.getPaymentNumberDevicePrefixSync());
|
|
3330
|
+
}
|
|
3331
|
+
|
|
3332
|
+
/** 异步入口:创建支付项时读取最新 IoT 设备短号。 */
|
|
3333
|
+
}, {
|
|
3334
|
+
key: "addOrderPaymentAsync",
|
|
3335
|
+
value: (function () {
|
|
3336
|
+
var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(payment) {
|
|
3337
|
+
var hasPaymentNumber, devicePrefix;
|
|
3338
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context17) {
|
|
3339
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
3340
|
+
case 0:
|
|
3341
|
+
hasPaymentNumber = String(payment.payment_number || '').trim() !== '';
|
|
3342
|
+
if (!hasPaymentNumber) {
|
|
3343
|
+
_context17.next = 5;
|
|
3344
|
+
break;
|
|
3345
|
+
}
|
|
3346
|
+
_context17.t0 = 'LOCAL';
|
|
3347
|
+
_context17.next = 8;
|
|
3348
|
+
break;
|
|
3349
|
+
case 5:
|
|
3350
|
+
_context17.next = 7;
|
|
3351
|
+
return this.getPaymentNumberDevicePrefixAsync();
|
|
3352
|
+
case 7:
|
|
3353
|
+
_context17.t0 = _context17.sent;
|
|
3354
|
+
case 8:
|
|
3355
|
+
devicePrefix = _context17.t0;
|
|
3356
|
+
return _context17.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
|
|
3357
|
+
case 10:
|
|
3358
|
+
case "end":
|
|
3359
|
+
return _context17.stop();
|
|
3360
|
+
}
|
|
3361
|
+
}, _callee15, this);
|
|
3362
|
+
}));
|
|
3363
|
+
function addOrderPaymentAsync(_x14) {
|
|
3364
|
+
return _addOrderPaymentAsync.apply(this, arguments);
|
|
3365
|
+
}
|
|
3366
|
+
return addOrderPaymentAsync;
|
|
3367
|
+
}())
|
|
3368
|
+
}, {
|
|
3369
|
+
key: "addOrderPaymentWithDevicePrefix",
|
|
3370
|
+
value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
|
|
3371
|
+
var _this23 = this;
|
|
3310
3372
|
this.logInfo('addOrderPayment', {
|
|
3311
3373
|
payment: payment
|
|
3312
3374
|
});
|
|
@@ -3316,14 +3378,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3316
3378
|
type: orderPaymentType,
|
|
3317
3379
|
order_payment_type: orderPaymentType
|
|
3318
3380
|
}), {
|
|
3319
|
-
defaultPaid: true
|
|
3381
|
+
defaultPaid: true,
|
|
3382
|
+
devicePrefix: devicePrefix
|
|
3320
3383
|
})]);
|
|
3321
3384
|
tempOrder.payments = [].concat(_toConsumableArray(tempOrder.payments || []), _toConsumableArray(mapped));
|
|
3322
3385
|
this.persistTempOrder();
|
|
3323
3386
|
void this.recalculateSummary({
|
|
3324
3387
|
createIfMissing: true
|
|
3325
3388
|
}).catch(function (error) {
|
|
3326
|
-
|
|
3389
|
+
_this23.logError('recalculate summary after addOrderPayment failed', {
|
|
3327
3390
|
error: error instanceof Error ? error.message : String(error)
|
|
3328
3391
|
});
|
|
3329
3392
|
});
|
|
@@ -3331,49 +3394,80 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3331
3394
|
}
|
|
3332
3395
|
|
|
3333
3396
|
/**
|
|
3334
|
-
*
|
|
3335
|
-
*
|
|
3336
|
-
* 该方法服务 PaymentModal 的 void / 编辑场景;更新 metadata 时会做浅合并,
|
|
3337
|
-
* 避免覆盖 unique_payment_number、现金实付/找零等已有元数据。
|
|
3397
|
+
* 默认按支付唯一号精确更新;仅显式指定 legacy 时兼容历史支付标识。
|
|
3398
|
+
* metadata 与 transactions 会分别合并,避免覆盖支付会话号和已有交易记录。
|
|
3338
3399
|
*/
|
|
3339
3400
|
}, {
|
|
3340
3401
|
key: "updateOrderPayment",
|
|
3341
|
-
value: function
|
|
3342
|
-
var
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3402
|
+
value: (function () {
|
|
3403
|
+
var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(paymentIdentity, updates) {
|
|
3404
|
+
var options,
|
|
3405
|
+
tempOrder,
|
|
3406
|
+
identity,
|
|
3407
|
+
matchMode,
|
|
3408
|
+
matchedPayment,
|
|
3409
|
+
updatedPayment,
|
|
3410
|
+
summary,
|
|
3411
|
+
payments,
|
|
3412
|
+
_args18 = arguments;
|
|
3413
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context18) {
|
|
3414
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
3415
|
+
case 0:
|
|
3416
|
+
options = _args18.length > 2 && _args18[2] !== undefined ? _args18[2] : {};
|
|
3417
|
+
tempOrder = this.ensureTempOrder();
|
|
3418
|
+
identity = String(paymentIdentity);
|
|
3419
|
+
matchMode = options.matchBy === 'compat' || options.matchBy === 'legacy' ? 'compat' : 'payment_number';
|
|
3420
|
+
matchedPayment = resolveOrderPaymentIdentity(tempOrder.payments || [], identity, matchMode);
|
|
3421
|
+
if (matchedPayment) {
|
|
3422
|
+
_context18.next = 7;
|
|
3423
|
+
break;
|
|
3424
|
+
}
|
|
3425
|
+
throw new Error("\u672A\u627E\u5230\u652F\u4ED8\u9879: ".concat(identity));
|
|
3426
|
+
case 7:
|
|
3427
|
+
updatedPayment = null;
|
|
3428
|
+
tempOrder.payments = (tempOrder.payments || []).map(function (payment, index) {
|
|
3429
|
+
if (index !== matchedPayment.index) return payment;
|
|
3430
|
+
var nextPayment = mergeOrderPaymentRecord(payment, _objectSpread(_objectSpread({}, updates), {}, {
|
|
3431
|
+
updated_at: updates.updated_at || dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
3432
|
+
}));
|
|
3433
|
+
updatedPayment = nextPayment;
|
|
3434
|
+
return nextPayment;
|
|
3435
|
+
});
|
|
3436
|
+
this.persistTempOrder();
|
|
3437
|
+
_context18.next = 12;
|
|
3438
|
+
return this.recalculateSummary({
|
|
3439
|
+
createIfMissing: true
|
|
3440
|
+
});
|
|
3441
|
+
case 12:
|
|
3442
|
+
summary = _context18.sent;
|
|
3443
|
+
this.persistTempOrder();
|
|
3444
|
+
payments = tempOrder.payments;
|
|
3445
|
+
return _context18.abrupt("return", {
|
|
3446
|
+
updated: true,
|
|
3447
|
+
payment: payments[matchedPayment.index] || updatedPayment,
|
|
3448
|
+
payments: payments,
|
|
3449
|
+
summary: summary
|
|
3450
|
+
});
|
|
3451
|
+
case 16:
|
|
3452
|
+
case "end":
|
|
3453
|
+
return _context18.stop();
|
|
3454
|
+
}
|
|
3455
|
+
}, _callee16, this);
|
|
3456
|
+
}));
|
|
3457
|
+
function updateOrderPayment(_x15, _x16) {
|
|
3458
|
+
return _updateOrderPayment.apply(this, arguments);
|
|
3459
|
+
}
|
|
3460
|
+
return updateOrderPayment;
|
|
3461
|
+
}() /** 从当前订单支付项中移除指定支付项。 */)
|
|
3363
3462
|
}, {
|
|
3364
3463
|
key: "deleteOrderPayment",
|
|
3365
3464
|
value: function deleteOrderPayment(paymentIdentity) {
|
|
3366
3465
|
var tempOrder = this.ensureTempOrder();
|
|
3367
3466
|
var identity = String(paymentIdentity);
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
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
|
-
});
|
|
3467
|
+
var matchedPayment = resolveOrderPaymentIdentity(tempOrder.payments || [], identity, 'compat');
|
|
3468
|
+
if (!matchedPayment) return tempOrder.payments;
|
|
3469
|
+
tempOrder.payments = (tempOrder.payments || []).filter(function (_, index) {
|
|
3470
|
+
return index !== matchedPayment.index;
|
|
3377
3471
|
});
|
|
3378
3472
|
this.persistTempOrder();
|
|
3379
3473
|
return tempOrder.payments;
|
|
@@ -3405,7 +3499,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3405
3499
|
}, {
|
|
3406
3500
|
key: "applyPaymentLifecycleChange",
|
|
3407
3501
|
value: function applyPaymentLifecycleChange(tempOrder, options) {
|
|
3408
|
-
var
|
|
3502
|
+
var _this24 = this;
|
|
3409
3503
|
this.updateTempOrderPaymentStatus(tempOrder);
|
|
3410
3504
|
if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
|
|
3411
3505
|
this.persistTempOrder();
|
|
@@ -3415,7 +3509,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3415
3509
|
void this.recalculateSummary({
|
|
3416
3510
|
createIfMissing: true
|
|
3417
3511
|
}).catch(function (error) {
|
|
3418
|
-
|
|
3512
|
+
_this24.logError("recalculate summary after ".concat(logContext, " failed"), {
|
|
3419
3513
|
error: error instanceof Error ? error.message : String(error)
|
|
3420
3514
|
});
|
|
3421
3515
|
});
|
|
@@ -3459,7 +3553,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3459
3553
|
}, {
|
|
3460
3554
|
key: "updateVoucherOrderPayments",
|
|
3461
3555
|
value: function updateVoucherOrderPayments(payments, options) {
|
|
3462
|
-
var
|
|
3556
|
+
var _this25 = this;
|
|
3463
3557
|
var tempOrder = this.ensureTempOrder();
|
|
3464
3558
|
var isOrderPaymentType = function isOrderPaymentType(value) {
|
|
3465
3559
|
return value === 'normal' || value === 'deposit';
|
|
@@ -3494,8 +3588,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3494
3588
|
});
|
|
3495
3589
|
};
|
|
3496
3590
|
var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
|
|
3497
|
-
return
|
|
3498
|
-
defaultPaid: false
|
|
3591
|
+
return _this25.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
|
|
3592
|
+
defaultPaid: false,
|
|
3593
|
+
devicePrefix: options === null || options === void 0 ? void 0 : options.devicePrefix
|
|
3499
3594
|
});
|
|
3500
3595
|
})).filter(function (payment) {
|
|
3501
3596
|
return isVoucherPaymentRecord(payment);
|
|
@@ -3543,54 +3638,93 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3543
3638
|
void this.recalculateSummary({
|
|
3544
3639
|
createIfMissing: true
|
|
3545
3640
|
}).catch(function (error) {
|
|
3546
|
-
|
|
3641
|
+
_this25.logError('recalculate summary after updateVoucherOrderPayments failed', {
|
|
3547
3642
|
error: error instanceof Error ? error.message : String(error)
|
|
3548
3643
|
});
|
|
3549
3644
|
});
|
|
3550
3645
|
return tempOrder.payments;
|
|
3551
3646
|
}
|
|
3647
|
+
}, {
|
|
3648
|
+
key: "updateVoucherOrderPaymentsAsync",
|
|
3649
|
+
value: function () {
|
|
3650
|
+
var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(payments, options) {
|
|
3651
|
+
var needsPaymentNumber, devicePrefix;
|
|
3652
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context19) {
|
|
3653
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
3654
|
+
case 0:
|
|
3655
|
+
needsPaymentNumber = (payments || []).some(function (payment) {
|
|
3656
|
+
return String(payment.payment_number || '').trim() === '';
|
|
3657
|
+
});
|
|
3658
|
+
if (!needsPaymentNumber) {
|
|
3659
|
+
_context19.next = 7;
|
|
3660
|
+
break;
|
|
3661
|
+
}
|
|
3662
|
+
_context19.next = 4;
|
|
3663
|
+
return this.getPaymentNumberDevicePrefixAsync();
|
|
3664
|
+
case 4:
|
|
3665
|
+
_context19.t0 = _context19.sent;
|
|
3666
|
+
_context19.next = 8;
|
|
3667
|
+
break;
|
|
3668
|
+
case 7:
|
|
3669
|
+
_context19.t0 = 'LOCAL';
|
|
3670
|
+
case 8:
|
|
3671
|
+
devicePrefix = _context19.t0;
|
|
3672
|
+
return _context19.abrupt("return", this.updateVoucherOrderPayments(payments, _objectSpread(_objectSpread({}, options), {}, {
|
|
3673
|
+
devicePrefix: devicePrefix
|
|
3674
|
+
})));
|
|
3675
|
+
case 10:
|
|
3676
|
+
case "end":
|
|
3677
|
+
return _context19.stop();
|
|
3678
|
+
}
|
|
3679
|
+
}, _callee17, this);
|
|
3680
|
+
}));
|
|
3681
|
+
function updateVoucherOrderPaymentsAsync(_x17, _x18) {
|
|
3682
|
+
return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
|
|
3683
|
+
}
|
|
3684
|
+
return updateVoucherOrderPaymentsAsync;
|
|
3685
|
+
}()
|
|
3552
3686
|
}, {
|
|
3553
3687
|
key: "shouldMergeProductToOrder",
|
|
3554
3688
|
value: function () {
|
|
3555
|
-
var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3689
|
+
var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(params) {
|
|
3556
3690
|
var _this$orderHooks;
|
|
3557
3691
|
var onBeforeMergeProductToOrder, result;
|
|
3558
|
-
return _regeneratorRuntime().wrap(function
|
|
3559
|
-
while (1) switch (
|
|
3692
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context20) {
|
|
3693
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
3560
3694
|
case 0:
|
|
3561
3695
|
onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
|
|
3562
3696
|
if (onBeforeMergeProductToOrder) {
|
|
3563
|
-
|
|
3697
|
+
_context20.next = 3;
|
|
3564
3698
|
break;
|
|
3565
3699
|
}
|
|
3566
|
-
return
|
|
3700
|
+
return _context20.abrupt("return", true);
|
|
3567
3701
|
case 3:
|
|
3568
|
-
|
|
3702
|
+
_context20.next = 5;
|
|
3569
3703
|
return onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
3570
3704
|
defaultShouldMerge: true
|
|
3571
3705
|
}));
|
|
3572
3706
|
case 5:
|
|
3573
|
-
result =
|
|
3707
|
+
result = _context20.sent;
|
|
3574
3708
|
if (!(typeof result === 'boolean')) {
|
|
3575
|
-
|
|
3709
|
+
_context20.next = 8;
|
|
3576
3710
|
break;
|
|
3577
3711
|
}
|
|
3578
|
-
return
|
|
3712
|
+
return _context20.abrupt("return", result);
|
|
3579
3713
|
case 8:
|
|
3580
3714
|
if (!(result && _typeof(result) === 'object' && typeof result.shouldMerge === 'boolean')) {
|
|
3581
|
-
|
|
3715
|
+
_context20.next = 10;
|
|
3582
3716
|
break;
|
|
3583
3717
|
}
|
|
3584
|
-
return
|
|
3718
|
+
return _context20.abrupt("return", result.shouldMerge);
|
|
3585
3719
|
case 10:
|
|
3586
|
-
return
|
|
3720
|
+
return _context20.abrupt("return", true);
|
|
3587
3721
|
case 11:
|
|
3588
3722
|
case "end":
|
|
3589
|
-
return
|
|
3723
|
+
return _context20.stop();
|
|
3590
3724
|
}
|
|
3591
|
-
},
|
|
3725
|
+
}, _callee18, this);
|
|
3592
3726
|
}));
|
|
3593
|
-
function shouldMergeProductToOrder(
|
|
3727
|
+
function shouldMergeProductToOrder(_x19) {
|
|
3594
3728
|
return _shouldMergeProductToOrder.apply(this, arguments);
|
|
3595
3729
|
}
|
|
3596
3730
|
return shouldMergeProductToOrder;
|
|
@@ -3626,30 +3760,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3626
3760
|
}, {
|
|
3627
3761
|
key: "finalizeProductOrderMutation",
|
|
3628
3762
|
value: function () {
|
|
3629
|
-
var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3630
|
-
return _regeneratorRuntime().wrap(function
|
|
3631
|
-
while (1) switch (
|
|
3763
|
+
var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(tempOrder, options) {
|
|
3764
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context21) {
|
|
3765
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
3632
3766
|
case 0:
|
|
3633
3767
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
3634
3768
|
if (options !== null && options !== void 0 && options.skipEditDiscountConfigRefresh) {
|
|
3635
|
-
|
|
3769
|
+
_context21.next = 4;
|
|
3636
3770
|
break;
|
|
3637
3771
|
}
|
|
3638
|
-
|
|
3772
|
+
_context21.next = 4;
|
|
3639
3773
|
return this.ensureEditDiscountConfigForProductChange(tempOrder);
|
|
3640
3774
|
case 4:
|
|
3641
3775
|
if (options !== null && options !== void 0 && options.skipDiscountRecalculation) {
|
|
3642
|
-
|
|
3776
|
+
_context21.next = 7;
|
|
3643
3777
|
break;
|
|
3644
3778
|
}
|
|
3645
|
-
|
|
3779
|
+
_context21.next = 7;
|
|
3646
3780
|
return this.applyPromotion();
|
|
3647
3781
|
case 7:
|
|
3648
3782
|
if (!(options !== null && options !== void 0 && options.skipDiscountRecalculation)) {
|
|
3649
3783
|
this.applyDiscount();
|
|
3650
3784
|
}
|
|
3651
3785
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
3652
|
-
|
|
3786
|
+
_context21.next = 11;
|
|
3653
3787
|
return this.recalculateSummary({
|
|
3654
3788
|
createIfMissing: true
|
|
3655
3789
|
});
|
|
@@ -3657,11 +3791,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3657
3791
|
this.persistTempOrder();
|
|
3658
3792
|
case 12:
|
|
3659
3793
|
case "end":
|
|
3660
|
-
return
|
|
3794
|
+
return _context21.stop();
|
|
3661
3795
|
}
|
|
3662
|
-
},
|
|
3796
|
+
}, _callee19, this);
|
|
3663
3797
|
}));
|
|
3664
|
-
function finalizeProductOrderMutation(
|
|
3798
|
+
function finalizeProductOrderMutation(_x20, _x21) {
|
|
3665
3799
|
return _finalizeProductOrderMutation.apply(this, arguments);
|
|
3666
3800
|
}
|
|
3667
3801
|
return finalizeProductOrderMutation;
|
|
@@ -3676,13 +3810,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3676
3810
|
}, {
|
|
3677
3811
|
key: "appendProductLineToTempOrder",
|
|
3678
3812
|
value: (function () {
|
|
3679
|
-
var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3813
|
+
var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(tempOrder, product, booking) {
|
|
3680
3814
|
var _booking_uid,
|
|
3681
3815
|
_metadata,
|
|
3682
|
-
|
|
3816
|
+
_this26 = this;
|
|
3683
3817
|
var linked, productToAdd, incomingFingerprint, normalizedIncoming, incomingBookingUid, hasIncomingGoodPass, hasIncomingProductNote, hasIncomingBookingUid, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList;
|
|
3684
|
-
return _regeneratorRuntime().wrap(function
|
|
3685
|
-
while (1) switch (
|
|
3818
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context22) {
|
|
3819
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
3686
3820
|
case 0:
|
|
3687
3821
|
linked = booking ? this.createLinkedProductAndBooking({
|
|
3688
3822
|
product: product,
|
|
@@ -3704,8 +3838,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3704
3838
|
hasIncomingBookingUid = this.hasLinkedBookingUid(productToAdd) || this.hasLinkedBookingUid(normalizedIncoming);
|
|
3705
3839
|
shouldForceNewLine = !!booking || hasIncomingProductNote || hasIncomingBookingUid;
|
|
3706
3840
|
matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
3707
|
-
if (
|
|
3708
|
-
if (
|
|
3841
|
+
if (_this26.hasGoodPassDiscount(item)) return false;
|
|
3842
|
+
if (_this26.hasOrderProductLineNote(item)) return false;
|
|
3709
3843
|
if (item.order_detail_id !== undefined && item.order_detail_id !== null) return false;
|
|
3710
3844
|
if (item.product_id !== productToAdd.product_id) return false;
|
|
3711
3845
|
if (item.product_variant_id !== productToAdd.product_variant_id) return false;
|
|
@@ -3715,10 +3849,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3715
3849
|
matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
|
|
3716
3850
|
existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
|
|
3717
3851
|
if (!matchedProduct) {
|
|
3718
|
-
|
|
3852
|
+
_context22.next = 20;
|
|
3719
3853
|
break;
|
|
3720
3854
|
}
|
|
3721
|
-
|
|
3855
|
+
_context22.next = 17;
|
|
3722
3856
|
return this.shouldMergeProductToOrder({
|
|
3723
3857
|
incomingProduct: productToAdd,
|
|
3724
3858
|
normalizedIncoming: normalizedIncoming,
|
|
@@ -3730,13 +3864,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3730
3864
|
booking: booking
|
|
3731
3865
|
});
|
|
3732
3866
|
case 17:
|
|
3733
|
-
|
|
3734
|
-
|
|
3867
|
+
_context22.t0 = _context22.sent;
|
|
3868
|
+
_context22.next = 21;
|
|
3735
3869
|
break;
|
|
3736
3870
|
case 20:
|
|
3737
|
-
|
|
3871
|
+
_context22.t0 = false;
|
|
3738
3872
|
case 21:
|
|
3739
|
-
shouldMerge =
|
|
3873
|
+
shouldMerge = _context22.t0;
|
|
3740
3874
|
if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
|
|
3741
3875
|
this.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
|
|
3742
3876
|
if (linked) {
|
|
@@ -3790,11 +3924,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3790
3924
|
}
|
|
3791
3925
|
case 24:
|
|
3792
3926
|
case "end":
|
|
3793
|
-
return
|
|
3927
|
+
return _context22.stop();
|
|
3794
3928
|
}
|
|
3795
|
-
},
|
|
3929
|
+
}, _callee20, this);
|
|
3796
3930
|
}));
|
|
3797
|
-
function appendProductLineToTempOrder(
|
|
3931
|
+
function appendProductLineToTempOrder(_x22, _x23, _x24) {
|
|
3798
3932
|
return _appendProductLineToTempOrder.apply(this, arguments);
|
|
3799
3933
|
}
|
|
3800
3934
|
return appendProductLineToTempOrder;
|
|
@@ -3810,61 +3944,61 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3810
3944
|
}, {
|
|
3811
3945
|
key: "addProductToOrder",
|
|
3812
3946
|
value: (function () {
|
|
3813
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3947
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(product, booking) {
|
|
3814
3948
|
var tempOrder, _ref61, _productRecord$num, productRecord, splitCount, i, singleLine;
|
|
3815
|
-
return _regeneratorRuntime().wrap(function
|
|
3816
|
-
while (1) switch (
|
|
3949
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context23) {
|
|
3950
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
3817
3951
|
case 0:
|
|
3818
3952
|
tempOrder = this.ensureTempOrder();
|
|
3819
3953
|
if (!booking) {
|
|
3820
|
-
|
|
3954
|
+
_context23.next = 18;
|
|
3821
3955
|
break;
|
|
3822
3956
|
}
|
|
3823
3957
|
productRecord = product;
|
|
3824
3958
|
splitCount = getSafeProductNum((_ref61 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref61 !== void 0 ? _ref61 : 1);
|
|
3825
3959
|
if (!(splitCount > 1)) {
|
|
3826
|
-
|
|
3960
|
+
_context23.next = 18;
|
|
3827
3961
|
break;
|
|
3828
3962
|
}
|
|
3829
3963
|
i = 0;
|
|
3830
3964
|
case 6:
|
|
3831
3965
|
if (!(i < splitCount)) {
|
|
3832
|
-
|
|
3966
|
+
_context23.next = 15;
|
|
3833
3967
|
break;
|
|
3834
3968
|
}
|
|
3835
3969
|
singleLine = cloneDeep(productRecord);
|
|
3836
3970
|
singleLine.num = 1;
|
|
3837
3971
|
delete singleLine.product_quantity;
|
|
3838
|
-
|
|
3972
|
+
_context23.next = 12;
|
|
3839
3973
|
return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
|
|
3840
3974
|
case 12:
|
|
3841
3975
|
i += 1;
|
|
3842
|
-
|
|
3976
|
+
_context23.next = 6;
|
|
3843
3977
|
break;
|
|
3844
3978
|
case 15:
|
|
3845
|
-
|
|
3979
|
+
_context23.next = 17;
|
|
3846
3980
|
return this.finalizeProductOrderMutation(tempOrder);
|
|
3847
3981
|
case 17:
|
|
3848
|
-
return
|
|
3982
|
+
return _context23.abrupt("return", tempOrder.products);
|
|
3849
3983
|
case 18:
|
|
3850
|
-
|
|
3984
|
+
_context23.next = 20;
|
|
3851
3985
|
return this.appendProductLineToTempOrder(tempOrder, product, booking);
|
|
3852
3986
|
case 20:
|
|
3853
|
-
|
|
3987
|
+
_context23.next = 22;
|
|
3854
3988
|
return this.finalizeProductOrderMutation(tempOrder);
|
|
3855
3989
|
case 22:
|
|
3856
3990
|
this.logInfo('addProductToOrder success', {
|
|
3857
3991
|
product_id: product.product_id,
|
|
3858
3992
|
with_booking: !!booking
|
|
3859
3993
|
});
|
|
3860
|
-
return
|
|
3994
|
+
return _context23.abrupt("return", tempOrder.products);
|
|
3861
3995
|
case 24:
|
|
3862
3996
|
case "end":
|
|
3863
|
-
return
|
|
3997
|
+
return _context23.stop();
|
|
3864
3998
|
}
|
|
3865
|
-
},
|
|
3999
|
+
}, _callee21, this);
|
|
3866
4000
|
}));
|
|
3867
|
-
function addProductToOrder(
|
|
4001
|
+
function addProductToOrder(_x25, _x26) {
|
|
3868
4002
|
return _addProductToOrder.apply(this, arguments);
|
|
3869
4003
|
}
|
|
3870
4004
|
return addProductToOrder;
|
|
@@ -3882,93 +4016,93 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3882
4016
|
}, {
|
|
3883
4017
|
key: "addProductsToOrder",
|
|
3884
4018
|
value: (function () {
|
|
3885
|
-
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4019
|
+
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(items, options) {
|
|
3886
4020
|
var tempOrder, _iterator20, _step20, item, product, booking, _ref62, _productRecord$num2, productRecord, splitCount, i, singleLine;
|
|
3887
|
-
return _regeneratorRuntime().wrap(function
|
|
3888
|
-
while (1) switch (
|
|
4021
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context24) {
|
|
4022
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
3889
4023
|
case 0:
|
|
3890
4024
|
tempOrder = this.ensureTempOrder();
|
|
3891
4025
|
if (!(!Array.isArray(items) || items.length === 0)) {
|
|
3892
|
-
|
|
4026
|
+
_context24.next = 3;
|
|
3893
4027
|
break;
|
|
3894
4028
|
}
|
|
3895
|
-
return
|
|
4029
|
+
return _context24.abrupt("return", tempOrder.products);
|
|
3896
4030
|
case 3:
|
|
3897
4031
|
_iterator20 = _createForOfIteratorHelper(items || []);
|
|
3898
|
-
|
|
4032
|
+
_context24.prev = 4;
|
|
3899
4033
|
_iterator20.s();
|
|
3900
4034
|
case 6:
|
|
3901
4035
|
if ((_step20 = _iterator20.n()).done) {
|
|
3902
|
-
|
|
4036
|
+
_context24.next = 30;
|
|
3903
4037
|
break;
|
|
3904
4038
|
}
|
|
3905
4039
|
item = _step20.value;
|
|
3906
4040
|
product = item.product, booking = item.booking;
|
|
3907
4041
|
if (product) {
|
|
3908
|
-
|
|
4042
|
+
_context24.next = 11;
|
|
3909
4043
|
break;
|
|
3910
4044
|
}
|
|
3911
|
-
return
|
|
4045
|
+
return _context24.abrupt("continue", 28);
|
|
3912
4046
|
case 11:
|
|
3913
4047
|
if (!booking) {
|
|
3914
|
-
|
|
4048
|
+
_context24.next = 26;
|
|
3915
4049
|
break;
|
|
3916
4050
|
}
|
|
3917
4051
|
productRecord = product;
|
|
3918
4052
|
splitCount = getSafeProductNum((_ref62 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref62 !== void 0 ? _ref62 : 1);
|
|
3919
4053
|
if (!(splitCount > 1)) {
|
|
3920
|
-
|
|
4054
|
+
_context24.next = 26;
|
|
3921
4055
|
break;
|
|
3922
4056
|
}
|
|
3923
4057
|
i = 0;
|
|
3924
4058
|
case 16:
|
|
3925
4059
|
if (!(i < splitCount)) {
|
|
3926
|
-
|
|
4060
|
+
_context24.next = 25;
|
|
3927
4061
|
break;
|
|
3928
4062
|
}
|
|
3929
4063
|
singleLine = cloneDeep(productRecord);
|
|
3930
4064
|
singleLine.num = 1;
|
|
3931
4065
|
delete singleLine.product_quantity;
|
|
3932
|
-
|
|
4066
|
+
_context24.next = 22;
|
|
3933
4067
|
return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
|
|
3934
4068
|
case 22:
|
|
3935
4069
|
i += 1;
|
|
3936
|
-
|
|
4070
|
+
_context24.next = 16;
|
|
3937
4071
|
break;
|
|
3938
4072
|
case 25:
|
|
3939
|
-
return
|
|
4073
|
+
return _context24.abrupt("continue", 28);
|
|
3940
4074
|
case 26:
|
|
3941
|
-
|
|
4075
|
+
_context24.next = 28;
|
|
3942
4076
|
return this.appendProductLineToTempOrder(tempOrder, product, booking);
|
|
3943
4077
|
case 28:
|
|
3944
|
-
|
|
4078
|
+
_context24.next = 6;
|
|
3945
4079
|
break;
|
|
3946
4080
|
case 30:
|
|
3947
|
-
|
|
4081
|
+
_context24.next = 35;
|
|
3948
4082
|
break;
|
|
3949
4083
|
case 32:
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
_iterator20.e(
|
|
4084
|
+
_context24.prev = 32;
|
|
4085
|
+
_context24.t0 = _context24["catch"](4);
|
|
4086
|
+
_iterator20.e(_context24.t0);
|
|
3953
4087
|
case 35:
|
|
3954
|
-
|
|
4088
|
+
_context24.prev = 35;
|
|
3955
4089
|
_iterator20.f();
|
|
3956
|
-
return
|
|
4090
|
+
return _context24.finish(35);
|
|
3957
4091
|
case 38:
|
|
3958
|
-
|
|
4092
|
+
_context24.next = 40;
|
|
3959
4093
|
return this.finalizeProductOrderMutation(tempOrder, options);
|
|
3960
4094
|
case 40:
|
|
3961
4095
|
this.logInfo('addProductsToOrder success', {
|
|
3962
4096
|
itemsCount: items.length
|
|
3963
4097
|
});
|
|
3964
|
-
return
|
|
4098
|
+
return _context24.abrupt("return", tempOrder.products);
|
|
3965
4099
|
case 42:
|
|
3966
4100
|
case "end":
|
|
3967
|
-
return
|
|
4101
|
+
return _context24.stop();
|
|
3968
4102
|
}
|
|
3969
|
-
},
|
|
4103
|
+
}, _callee22, this, [[4, 32, 35, 38]]);
|
|
3970
4104
|
}));
|
|
3971
|
-
function addProductsToOrder(
|
|
4105
|
+
function addProductsToOrder(_x27, _x28) {
|
|
3972
4106
|
return _addProductsToOrder.apply(this, arguments);
|
|
3973
4107
|
}
|
|
3974
4108
|
return addProductsToOrder;
|
|
@@ -4002,17 +4136,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4002
4136
|
}, {
|
|
4003
4137
|
key: "preservePersistedBundlePriceFields",
|
|
4004
4138
|
value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
|
|
4005
|
-
var
|
|
4139
|
+
var _this27 = this;
|
|
4006
4140
|
if (!Array.isArray(nextBundles)) return nextBundles;
|
|
4007
4141
|
if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
|
|
4008
4142
|
var previousByIdentity = new Map();
|
|
4009
4143
|
previousBundles.forEach(function (bundle) {
|
|
4010
|
-
var identity =
|
|
4144
|
+
var identity = _this27.getBundleRuntimeIdentity(bundle);
|
|
4011
4145
|
if (identity) previousByIdentity.set(identity, bundle);
|
|
4012
4146
|
});
|
|
4013
4147
|
return nextBundles.map(function (bundle, index) {
|
|
4014
4148
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
4015
|
-
var previous = previousByIdentity.get(
|
|
4149
|
+
var previous = previousByIdentity.get(_this27.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
|
|
4016
4150
|
if (!previous || _typeof(previous) !== 'object') return bundle;
|
|
4017
4151
|
return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
|
|
4018
4152
|
cover: previous.cover
|
|
@@ -4165,21 +4299,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4165
4299
|
}, {
|
|
4166
4300
|
key: "updateOrderProduct",
|
|
4167
4301
|
value: function () {
|
|
4168
|
-
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4302
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
|
|
4169
4303
|
var tempOrder, updatedProductUid;
|
|
4170
|
-
return _regeneratorRuntime().wrap(function
|
|
4171
|
-
while (1) switch (
|
|
4304
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context25) {
|
|
4305
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
4172
4306
|
case 0:
|
|
4173
4307
|
tempOrder = this.ensureTempOrder();
|
|
4174
4308
|
updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
4175
|
-
|
|
4309
|
+
_context25.next = 4;
|
|
4176
4310
|
return this.applyPromotion();
|
|
4177
4311
|
case 4:
|
|
4178
4312
|
this.applyDiscount({
|
|
4179
4313
|
reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
|
|
4180
4314
|
});
|
|
4181
4315
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4182
|
-
|
|
4316
|
+
_context25.next = 8;
|
|
4183
4317
|
return this.recalculateSummary({
|
|
4184
4318
|
createIfMissing: true
|
|
4185
4319
|
});
|
|
@@ -4188,14 +4322,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4188
4322
|
this.logInfo('updateOrderProduct success', {
|
|
4189
4323
|
params: params
|
|
4190
4324
|
});
|
|
4191
|
-
return
|
|
4325
|
+
return _context25.abrupt("return", tempOrder.products);
|
|
4192
4326
|
case 11:
|
|
4193
4327
|
case "end":
|
|
4194
|
-
return
|
|
4328
|
+
return _context25.stop();
|
|
4195
4329
|
}
|
|
4196
|
-
},
|
|
4330
|
+
}, _callee23, this);
|
|
4197
4331
|
}));
|
|
4198
|
-
function updateOrderProduct(
|
|
4332
|
+
function updateOrderProduct(_x29) {
|
|
4199
4333
|
return _updateOrderProduct.apply(this, arguments);
|
|
4200
4334
|
}
|
|
4201
4335
|
return updateOrderProduct;
|
|
@@ -4203,28 +4337,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4203
4337
|
}, {
|
|
4204
4338
|
key: "updateOrderProducts",
|
|
4205
4339
|
value: function () {
|
|
4206
|
-
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4207
|
-
var
|
|
4340
|
+
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(paramsList) {
|
|
4341
|
+
var _this28 = this;
|
|
4208
4342
|
var tempOrder, reapplyBookingDiscountProductUids;
|
|
4209
|
-
return _regeneratorRuntime().wrap(function
|
|
4210
|
-
while (1) switch (
|
|
4343
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context26) {
|
|
4344
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
4211
4345
|
case 0:
|
|
4212
4346
|
tempOrder = this.ensureTempOrder();
|
|
4213
4347
|
if (paramsList.length) {
|
|
4214
|
-
|
|
4348
|
+
_context26.next = 3;
|
|
4215
4349
|
break;
|
|
4216
4350
|
}
|
|
4217
|
-
return
|
|
4351
|
+
return _context26.abrupt("return", tempOrder.products);
|
|
4218
4352
|
case 3:
|
|
4219
4353
|
reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
|
|
4220
|
-
var updatedProductUid =
|
|
4354
|
+
var updatedProductUid = _this28.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
4221
4355
|
// 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
|
|
4222
4356
|
if (params.allow_booking_discount_reapply && updatedProductUid) {
|
|
4223
4357
|
acc.push(String(updatedProductUid));
|
|
4224
4358
|
}
|
|
4225
4359
|
return acc;
|
|
4226
4360
|
}, []);
|
|
4227
|
-
|
|
4361
|
+
_context26.next = 6;
|
|
4228
4362
|
return this.finalizeAfterProductsMutation(tempOrder, {
|
|
4229
4363
|
reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
|
|
4230
4364
|
});
|
|
@@ -4232,14 +4366,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4232
4366
|
this.logInfo('updateOrderProduct success', {
|
|
4233
4367
|
paramsList: paramsList
|
|
4234
4368
|
});
|
|
4235
|
-
return
|
|
4369
|
+
return _context26.abrupt("return", tempOrder.products);
|
|
4236
4370
|
case 8:
|
|
4237
4371
|
case "end":
|
|
4238
|
-
return
|
|
4372
|
+
return _context26.stop();
|
|
4239
4373
|
}
|
|
4240
|
-
},
|
|
4374
|
+
}, _callee24, this);
|
|
4241
4375
|
}));
|
|
4242
|
-
function updateOrderProducts(
|
|
4376
|
+
function updateOrderProducts(_x30) {
|
|
4243
4377
|
return _updateOrderProducts.apply(this, arguments);
|
|
4244
4378
|
}
|
|
4245
4379
|
return updateOrderProducts;
|
|
@@ -4247,11 +4381,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4247
4381
|
}, {
|
|
4248
4382
|
key: "updateOrderProductQuantity",
|
|
4249
4383
|
value: function () {
|
|
4250
|
-
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4384
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
|
|
4251
4385
|
var _targetProduct$metada10;
|
|
4252
4386
|
var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct;
|
|
4253
|
-
return _regeneratorRuntime().wrap(function
|
|
4254
|
-
while (1) switch (
|
|
4387
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context27) {
|
|
4388
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
4255
4389
|
case 0:
|
|
4256
4390
|
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;
|
|
4257
4391
|
tempOrder = this.ensureTempOrder();
|
|
@@ -4280,7 +4414,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4280
4414
|
productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
|
|
4281
4415
|
}
|
|
4282
4416
|
if (!(productIndex === -1)) {
|
|
4283
|
-
|
|
4417
|
+
_context27.next = 12;
|
|
4284
4418
|
break;
|
|
4285
4419
|
}
|
|
4286
4420
|
throw new Error('[Order] 目标商品不存在,无法更新数量');
|
|
@@ -4294,12 +4428,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4294
4428
|
}));
|
|
4295
4429
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
4296
4430
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
4297
|
-
|
|
4431
|
+
_context27.next = 18;
|
|
4298
4432
|
return this.applyPromotion();
|
|
4299
4433
|
case 18:
|
|
4300
4434
|
this.applyDiscount();
|
|
4301
4435
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4302
|
-
|
|
4436
|
+
_context27.next = 22;
|
|
4303
4437
|
return this.recalculateSummary({
|
|
4304
4438
|
createIfMissing: true
|
|
4305
4439
|
});
|
|
@@ -4308,14 +4442,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4308
4442
|
this.logInfo('updateOrderProductQuantity success', {
|
|
4309
4443
|
params: params
|
|
4310
4444
|
});
|
|
4311
|
-
return
|
|
4445
|
+
return _context27.abrupt("return", tempOrder.products);
|
|
4312
4446
|
case 25:
|
|
4313
4447
|
case "end":
|
|
4314
|
-
return
|
|
4448
|
+
return _context27.stop();
|
|
4315
4449
|
}
|
|
4316
|
-
},
|
|
4450
|
+
}, _callee25, this);
|
|
4317
4451
|
}));
|
|
4318
|
-
function updateOrderProductQuantity(
|
|
4452
|
+
function updateOrderProductQuantity(_x31) {
|
|
4319
4453
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
4320
4454
|
}
|
|
4321
4455
|
return updateOrderProductQuantity;
|
|
@@ -4356,19 +4490,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4356
4490
|
}, {
|
|
4357
4491
|
key: "finalizeAfterProductsMutation",
|
|
4358
4492
|
value: (function () {
|
|
4359
|
-
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4360
|
-
return _regeneratorRuntime().wrap(function
|
|
4361
|
-
while (1) switch (
|
|
4493
|
+
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(tempOrder, options) {
|
|
4494
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context28) {
|
|
4495
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
4362
4496
|
case 0:
|
|
4363
4497
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
4364
|
-
|
|
4498
|
+
_context28.next = 3;
|
|
4365
4499
|
return this.applyPromotion();
|
|
4366
4500
|
case 3:
|
|
4367
4501
|
this.applyDiscount({
|
|
4368
4502
|
reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids
|
|
4369
4503
|
});
|
|
4370
4504
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4371
|
-
|
|
4505
|
+
_context28.next = 7;
|
|
4372
4506
|
return this.recalculateSummary({
|
|
4373
4507
|
createIfMissing: true
|
|
4374
4508
|
});
|
|
@@ -4376,11 +4510,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4376
4510
|
this.persistTempOrder();
|
|
4377
4511
|
case 8:
|
|
4378
4512
|
case "end":
|
|
4379
|
-
return
|
|
4513
|
+
return _context28.stop();
|
|
4380
4514
|
}
|
|
4381
|
-
},
|
|
4515
|
+
}, _callee26, this);
|
|
4382
4516
|
}));
|
|
4383
|
-
function finalizeAfterProductsMutation(
|
|
4517
|
+
function finalizeAfterProductsMutation(_x32, _x33) {
|
|
4384
4518
|
return _finalizeAfterProductsMutation.apply(this, arguments);
|
|
4385
4519
|
}
|
|
4386
4520
|
return finalizeAfterProductsMutation;
|
|
@@ -4395,18 +4529,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4395
4529
|
}, {
|
|
4396
4530
|
key: "removeProductsFromOrder",
|
|
4397
4531
|
value: (function () {
|
|
4398
|
-
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4399
|
-
var
|
|
4532
|
+
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(identities) {
|
|
4533
|
+
var _this29 = this;
|
|
4400
4534
|
var tempOrder, productsBeforeRemove, bookingsBeforeRemove, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3;
|
|
4401
|
-
return _regeneratorRuntime().wrap(function
|
|
4402
|
-
while (1) switch (
|
|
4535
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context30) {
|
|
4536
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
4403
4537
|
case 0:
|
|
4404
4538
|
tempOrder = this.ensureTempOrder();
|
|
4405
4539
|
if (identities.length) {
|
|
4406
|
-
|
|
4540
|
+
_context30.next = 3;
|
|
4407
4541
|
break;
|
|
4408
4542
|
}
|
|
4409
|
-
return
|
|
4543
|
+
return _context30.abrupt("return", tempOrder.products);
|
|
4410
4544
|
case 3:
|
|
4411
4545
|
productsBeforeRemove = tempOrder.products || [];
|
|
4412
4546
|
bookingsBeforeRemove = tempOrder.bookings || [];
|
|
@@ -4429,29 +4563,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4429
4563
|
}
|
|
4430
4564
|
linkedBookingUidsToRemove = new Set();
|
|
4431
4565
|
_iterator21 = _createForOfIteratorHelper(matchedProducts);
|
|
4432
|
-
|
|
4566
|
+
_context30.prev = 11;
|
|
4433
4567
|
_loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
|
|
4434
4568
|
var _metadata8, _metadata9, _metadata10, _metadata11;
|
|
4435
4569
|
var product, productUid, productBookingUid, isAddTimeProduct;
|
|
4436
|
-
return _regeneratorRuntime().wrap(function _loop3$(
|
|
4437
|
-
while (1) switch (
|
|
4570
|
+
return _regeneratorRuntime().wrap(function _loop3$(_context29) {
|
|
4571
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
4438
4572
|
case 0:
|
|
4439
4573
|
product = _step21.value;
|
|
4440
4574
|
productUid = (product === null || product === void 0 || (_metadata8 = product.metadata) === null || _metadata8 === void 0 ? void 0 : _metadata8.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
4441
4575
|
productBookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_metadata9 = product.metadata) === null || _metadata9 === void 0 ? void 0 : _metadata9.booking_uid);
|
|
4442
4576
|
isAddTimeProduct = (product === null || product === void 0 || (_metadata10 = product.metadata) === null || _metadata10 === void 0 ? void 0 : _metadata10.product_add_schedule_time) !== undefined && (product === null || product === void 0 || (_metadata11 = product.metadata) === null || _metadata11 === void 0 ? void 0 : _metadata11.product_add_schedule_time) !== null;
|
|
4443
4577
|
if (!isAddTimeProduct) {
|
|
4444
|
-
|
|
4578
|
+
_context29.next = 6;
|
|
4445
4579
|
break;
|
|
4446
4580
|
}
|
|
4447
|
-
return
|
|
4581
|
+
return _context29.abrupt("return", 1);
|
|
4448
4582
|
case 6:
|
|
4449
4583
|
if (productBookingUid !== undefined && productBookingUid !== null && productBookingUid !== '') {
|
|
4450
4584
|
linkedBookingUidsToRemove.add(String(productBookingUid));
|
|
4451
4585
|
}
|
|
4452
4586
|
if (productUid !== undefined && productUid !== null && productUid !== '') {
|
|
4453
4587
|
bookingsBeforeRemove.forEach(function (booking) {
|
|
4454
|
-
var bookingUid =
|
|
4588
|
+
var bookingUid = _this29.getBookingUniqueIdentificationNumber(booking);
|
|
4455
4589
|
if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
|
|
4456
4590
|
linkedBookingUidsToRemove.add(bookingUid);
|
|
4457
4591
|
}
|
|
@@ -4459,37 +4593,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4459
4593
|
}
|
|
4460
4594
|
case 8:
|
|
4461
4595
|
case "end":
|
|
4462
|
-
return
|
|
4596
|
+
return _context29.stop();
|
|
4463
4597
|
}
|
|
4464
4598
|
}, _loop3);
|
|
4465
4599
|
});
|
|
4466
4600
|
_iterator21.s();
|
|
4467
4601
|
case 14:
|
|
4468
4602
|
if ((_step21 = _iterator21.n()).done) {
|
|
4469
|
-
|
|
4603
|
+
_context30.next = 20;
|
|
4470
4604
|
break;
|
|
4471
4605
|
}
|
|
4472
|
-
return
|
|
4606
|
+
return _context30.delegateYield(_loop3(), "t0", 16);
|
|
4473
4607
|
case 16:
|
|
4474
|
-
if (!
|
|
4475
|
-
|
|
4608
|
+
if (!_context30.t0) {
|
|
4609
|
+
_context30.next = 18;
|
|
4476
4610
|
break;
|
|
4477
4611
|
}
|
|
4478
|
-
return
|
|
4612
|
+
return _context30.abrupt("continue", 18);
|
|
4479
4613
|
case 18:
|
|
4480
|
-
|
|
4614
|
+
_context30.next = 14;
|
|
4481
4615
|
break;
|
|
4482
4616
|
case 20:
|
|
4483
|
-
|
|
4617
|
+
_context30.next = 25;
|
|
4484
4618
|
break;
|
|
4485
4619
|
case 22:
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
_iterator21.e(
|
|
4620
|
+
_context30.prev = 22;
|
|
4621
|
+
_context30.t1 = _context30["catch"](11);
|
|
4622
|
+
_iterator21.e(_context30.t1);
|
|
4489
4623
|
case 25:
|
|
4490
|
-
|
|
4624
|
+
_context30.prev = 25;
|
|
4491
4625
|
_iterator21.f();
|
|
4492
|
-
return
|
|
4626
|
+
return _context30.finish(25);
|
|
4493
4627
|
case 28:
|
|
4494
4628
|
if (linkedBookingUidsToRemove.size > 0) {
|
|
4495
4629
|
// 删除主预约商品时,同步移除挂在同一 booking_uid 下的加时商品,避免残留孤儿行。
|
|
@@ -4500,20 +4634,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4500
4634
|
return !(isAddTimeProduct && lineBookingUid !== undefined && lineBookingUid !== null && linkedBookingUidsToRemove.has(String(lineBookingUid)));
|
|
4501
4635
|
});
|
|
4502
4636
|
}
|
|
4503
|
-
|
|
4637
|
+
_context30.next = 31;
|
|
4504
4638
|
return this.finalizeAfterProductsMutation(tempOrder);
|
|
4505
4639
|
case 31:
|
|
4506
4640
|
this.logInfo('removeProductsFromOrder success', {
|
|
4507
4641
|
identities: identities
|
|
4508
4642
|
});
|
|
4509
|
-
return
|
|
4643
|
+
return _context30.abrupt("return", tempOrder.products);
|
|
4510
4644
|
case 33:
|
|
4511
4645
|
case "end":
|
|
4512
|
-
return
|
|
4646
|
+
return _context30.stop();
|
|
4513
4647
|
}
|
|
4514
|
-
},
|
|
4648
|
+
}, _callee27, this, [[11, 22, 25, 28]]);
|
|
4515
4649
|
}));
|
|
4516
|
-
function removeProductsFromOrder(
|
|
4650
|
+
function removeProductsFromOrder(_x34) {
|
|
4517
4651
|
return _removeProductsFromOrder.apply(this, arguments);
|
|
4518
4652
|
}
|
|
4519
4653
|
return removeProductsFromOrder;
|
|
@@ -4521,18 +4655,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4521
4655
|
}, {
|
|
4522
4656
|
key: "removeProductFromOrder",
|
|
4523
4657
|
value: function () {
|
|
4524
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4525
|
-
return _regeneratorRuntime().wrap(function
|
|
4526
|
-
while (1) switch (
|
|
4658
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(identity) {
|
|
4659
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context31) {
|
|
4660
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
4527
4661
|
case 0:
|
|
4528
|
-
return
|
|
4662
|
+
return _context31.abrupt("return", this.removeProductsFromOrder([identity]));
|
|
4529
4663
|
case 1:
|
|
4530
4664
|
case "end":
|
|
4531
|
-
return
|
|
4665
|
+
return _context31.stop();
|
|
4532
4666
|
}
|
|
4533
|
-
},
|
|
4667
|
+
}, _callee28, this);
|
|
4534
4668
|
}));
|
|
4535
|
-
function removeProductFromOrder(
|
|
4669
|
+
function removeProductFromOrder(_x35) {
|
|
4536
4670
|
return _removeProductFromOrder.apply(this, arguments);
|
|
4537
4671
|
}
|
|
4538
4672
|
return removeProductFromOrder;
|
|
@@ -4544,10 +4678,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4544
4678
|
}, {
|
|
4545
4679
|
key: "clearOrderCartLines",
|
|
4546
4680
|
value: (function () {
|
|
4547
|
-
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4681
|
+
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
|
|
4548
4682
|
var tempOrder;
|
|
4549
|
-
return _regeneratorRuntime().wrap(function
|
|
4550
|
-
while (1) switch (
|
|
4683
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context32) {
|
|
4684
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
4551
4685
|
case 0:
|
|
4552
4686
|
tempOrder = this.ensureTempOrder();
|
|
4553
4687
|
tempOrder.products = [];
|
|
@@ -4558,24 +4692,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4558
4692
|
productsByUid: {}
|
|
4559
4693
|
});
|
|
4560
4694
|
}
|
|
4561
|
-
|
|
4695
|
+
_context32.next = 7;
|
|
4562
4696
|
return this.applyPromotion();
|
|
4563
4697
|
case 7:
|
|
4564
4698
|
this.applyDiscount();
|
|
4565
4699
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4566
|
-
|
|
4700
|
+
_context32.next = 11;
|
|
4567
4701
|
return this.recalculateSummary({
|
|
4568
4702
|
createIfMissing: true
|
|
4569
4703
|
});
|
|
4570
4704
|
case 11:
|
|
4571
4705
|
this.persistTempOrder();
|
|
4572
4706
|
this.logInfo('clearOrderCartLines success', {});
|
|
4573
|
-
return
|
|
4707
|
+
return _context32.abrupt("return", tempOrder);
|
|
4574
4708
|
case 14:
|
|
4575
4709
|
case "end":
|
|
4576
|
-
return
|
|
4710
|
+
return _context32.stop();
|
|
4577
4711
|
}
|
|
4578
|
-
},
|
|
4712
|
+
}, _callee29, this);
|
|
4579
4713
|
}));
|
|
4580
4714
|
function clearOrderCartLines() {
|
|
4581
4715
|
return _clearOrderCartLines.apply(this, arguments);
|
|
@@ -4613,17 +4747,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4613
4747
|
}, {
|
|
4614
4748
|
key: "applyLocalPrintOrderNumbers",
|
|
4615
4749
|
value: function () {
|
|
4616
|
-
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4750
|
+
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(order) {
|
|
4617
4751
|
var tempOrder, shopOrderNumber, shopFullOrderNumber;
|
|
4618
|
-
return _regeneratorRuntime().wrap(function
|
|
4619
|
-
while (1) switch (
|
|
4752
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context33) {
|
|
4753
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
4620
4754
|
case 0:
|
|
4621
4755
|
tempOrder = this.ensureTempOrder();
|
|
4622
4756
|
if (!(!order || _typeof(order) !== 'object')) {
|
|
4623
|
-
|
|
4757
|
+
_context33.next = 3;
|
|
4624
4758
|
break;
|
|
4625
4759
|
}
|
|
4626
|
-
return
|
|
4760
|
+
return _context33.abrupt("return", tempOrder);
|
|
4627
4761
|
case 3:
|
|
4628
4762
|
shopOrderNumber = order.shop_order_number;
|
|
4629
4763
|
shopFullOrderNumber = order.shop_full_order_number;
|
|
@@ -4634,21 +4768,88 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4634
4768
|
tempOrder.shop_full_order_number = String(shopFullOrderNumber);
|
|
4635
4769
|
}
|
|
4636
4770
|
this.persistTempOrder();
|
|
4637
|
-
|
|
4771
|
+
_context33.next = 10;
|
|
4638
4772
|
return this.saveDraft();
|
|
4639
4773
|
case 10:
|
|
4640
|
-
return
|
|
4774
|
+
return _context33.abrupt("return", tempOrder);
|
|
4641
4775
|
case 11:
|
|
4642
4776
|
case "end":
|
|
4643
|
-
return
|
|
4777
|
+
return _context33.stop();
|
|
4644
4778
|
}
|
|
4645
|
-
},
|
|
4779
|
+
}, _callee30, this);
|
|
4646
4780
|
}));
|
|
4647
|
-
function applyLocalPrintOrderNumbers(
|
|
4781
|
+
function applyLocalPrintOrderNumbers(_x36) {
|
|
4648
4782
|
return _applyLocalPrintOrderNumbers.apply(this, arguments);
|
|
4649
4783
|
}
|
|
4650
4784
|
return applyLocalPrintOrderNumbers;
|
|
4651
4785
|
}()
|
|
4786
|
+
}, {
|
|
4787
|
+
key: "saveTempOrderAsDraft",
|
|
4788
|
+
value: function () {
|
|
4789
|
+
var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
|
|
4790
|
+
var _params$cacheId2, _this$otherParams6, _ref72, _params$businessCode2, _this$otherParams7, _this$otherParams8, _params$type, _this$otherParams9, _payload$products;
|
|
4791
|
+
var tempOrder, latestSummary, payload;
|
|
4792
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context34) {
|
|
4793
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
4794
|
+
case 0:
|
|
4795
|
+
tempOrder = this.ensureTempOrder();
|
|
4796
|
+
this.ensureExternalSaleNumber(tempOrder);
|
|
4797
|
+
this.persistTempOrder();
|
|
4798
|
+
_context34.next = 5;
|
|
4799
|
+
return this.recalculateSummary({
|
|
4800
|
+
createIfMissing: true
|
|
4801
|
+
});
|
|
4802
|
+
case 5:
|
|
4803
|
+
_context34.t1 = _context34.sent;
|
|
4804
|
+
if (_context34.t1) {
|
|
4805
|
+
_context34.next = 8;
|
|
4806
|
+
break;
|
|
4807
|
+
}
|
|
4808
|
+
_context34.t1 = this.store.summary;
|
|
4809
|
+
case 8:
|
|
4810
|
+
_context34.t0 = _context34.t1;
|
|
4811
|
+
if (_context34.t0) {
|
|
4812
|
+
_context34.next = 11;
|
|
4813
|
+
break;
|
|
4814
|
+
}
|
|
4815
|
+
_context34.t0 = createEmptySummary();
|
|
4816
|
+
case 11:
|
|
4817
|
+
latestSummary = _context34.t0;
|
|
4818
|
+
payload = buildSubmitPayload({
|
|
4819
|
+
tempOrder: tempOrder,
|
|
4820
|
+
cacheId: (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId,
|
|
4821
|
+
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform),
|
|
4822
|
+
businessCode: (_ref72 = (_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 && _ref72 !== void 0 ? _ref72 : (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.business_code,
|
|
4823
|
+
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
4824
|
+
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,
|
|
4825
|
+
summary: latestSummary,
|
|
4826
|
+
enhance: params === null || params === void 0 ? void 0 : params.enhancePayload
|
|
4827
|
+
});
|
|
4828
|
+
if (!payload.created_at) {
|
|
4829
|
+
payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
4830
|
+
}
|
|
4831
|
+
payload.need_sync = 0;
|
|
4832
|
+
payload.is_draft_order = 1;
|
|
4833
|
+
this.logInfo('saveTempOrderAsDraft calling sales draft', {
|
|
4834
|
+
orderId: payload.order_id,
|
|
4835
|
+
externalSaleNumber: payload.external_sale_number,
|
|
4836
|
+
productsCount: ((_payload$products = payload.products) === null || _payload$products === void 0 ? void 0 : _payload$products.length) || 0
|
|
4837
|
+
});
|
|
4838
|
+
return _context34.abrupt("return", this.request.post('/order/sales/draft', payload, {
|
|
4839
|
+
osServer: true,
|
|
4840
|
+
customToast: function customToast() {}
|
|
4841
|
+
}));
|
|
4842
|
+
case 18:
|
|
4843
|
+
case "end":
|
|
4844
|
+
return _context34.stop();
|
|
4845
|
+
}
|
|
4846
|
+
}, _callee31, this);
|
|
4847
|
+
}));
|
|
4848
|
+
function saveTempOrderAsDraft(_x37) {
|
|
4849
|
+
return _saveTempOrderAsDraft.apply(this, arguments);
|
|
4850
|
+
}
|
|
4851
|
+
return saveTempOrderAsDraft;
|
|
4852
|
+
}()
|
|
4652
4853
|
/**
|
|
4653
4854
|
* 提交当前 Sales tempOrder。
|
|
4654
4855
|
*
|
|
@@ -4658,18 +4859,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4658
4859
|
}, {
|
|
4659
4860
|
key: "submitTempOrder",
|
|
4660
4861
|
value: (function () {
|
|
4661
|
-
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4662
|
-
return _regeneratorRuntime().wrap(function
|
|
4663
|
-
while (1) switch (
|
|
4862
|
+
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
|
|
4863
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context35) {
|
|
4864
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
4664
4865
|
case 0:
|
|
4665
|
-
return
|
|
4866
|
+
return _context35.abrupt("return", this.runSubmitTempOrder(params));
|
|
4666
4867
|
case 1:
|
|
4667
4868
|
case "end":
|
|
4668
|
-
return
|
|
4869
|
+
return _context35.stop();
|
|
4669
4870
|
}
|
|
4670
|
-
},
|
|
4871
|
+
}, _callee32, this);
|
|
4671
4872
|
}));
|
|
4672
|
-
function submitTempOrder(
|
|
4873
|
+
function submitTempOrder(_x38) {
|
|
4673
4874
|
return _submitTempOrder.apply(this, arguments);
|
|
4674
4875
|
}
|
|
4675
4876
|
return submitTempOrder;
|
|
@@ -4677,20 +4878,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4677
4878
|
}, {
|
|
4678
4879
|
key: "submitTempOrderAsync",
|
|
4679
4880
|
value: function () {
|
|
4680
|
-
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4681
|
-
return _regeneratorRuntime().wrap(function
|
|
4682
|
-
while (1) switch (
|
|
4881
|
+
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
|
|
4882
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context36) {
|
|
4883
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
4683
4884
|
case 0:
|
|
4684
|
-
return
|
|
4885
|
+
return _context36.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
4685
4886
|
syncMode: true
|
|
4686
4887
|
})));
|
|
4687
4888
|
case 1:
|
|
4688
4889
|
case "end":
|
|
4689
|
-
return
|
|
4890
|
+
return _context36.stop();
|
|
4690
4891
|
}
|
|
4691
|
-
},
|
|
4892
|
+
}, _callee33, this);
|
|
4692
4893
|
}));
|
|
4693
|
-
function submitTempOrderAsync(
|
|
4894
|
+
function submitTempOrderAsync(_x39) {
|
|
4694
4895
|
return _submitTempOrderAsync.apply(this, arguments);
|
|
4695
4896
|
}
|
|
4696
4897
|
return submitTempOrderAsync;
|
|
@@ -4698,11 +4899,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4698
4899
|
}, {
|
|
4699
4900
|
key: "runSubmitTempOrder",
|
|
4700
4901
|
value: function () {
|
|
4701
|
-
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4702
|
-
var _params$
|
|
4902
|
+
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
|
|
4903
|
+
var _params$cacheId3, _this$otherParams10, _ref73, _ref74, _submitSnapshot$busin, _this$otherParams11, _this$otherParams12, _submitSnapshot$type;
|
|
4703
4904
|
var tempOrder, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
|
|
4704
|
-
return _regeneratorRuntime().wrap(function
|
|
4705
|
-
while (1) switch (
|
|
4905
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context37) {
|
|
4906
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
4706
4907
|
case 0:
|
|
4707
4908
|
tempOrder = this.ensureTempOrder();
|
|
4708
4909
|
shouldConfirmPendingVoucherPayments = (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== false;
|
|
@@ -4722,27 +4923,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4722
4923
|
}
|
|
4723
4924
|
}
|
|
4724
4925
|
this.persistTempOrder();
|
|
4725
|
-
|
|
4926
|
+
_context37.next = 8;
|
|
4726
4927
|
return this.recalculateSummary({
|
|
4727
4928
|
createIfMissing: true
|
|
4728
4929
|
});
|
|
4729
4930
|
case 8:
|
|
4730
|
-
|
|
4731
|
-
if (
|
|
4732
|
-
|
|
4931
|
+
_context37.t1 = _context37.sent;
|
|
4932
|
+
if (_context37.t1) {
|
|
4933
|
+
_context37.next = 11;
|
|
4733
4934
|
break;
|
|
4734
4935
|
}
|
|
4735
|
-
|
|
4936
|
+
_context37.t1 = this.store.summary;
|
|
4736
4937
|
case 11:
|
|
4737
|
-
|
|
4738
|
-
if (
|
|
4739
|
-
|
|
4938
|
+
_context37.t0 = _context37.t1;
|
|
4939
|
+
if (_context37.t0) {
|
|
4940
|
+
_context37.next = 14;
|
|
4740
4941
|
break;
|
|
4741
4942
|
}
|
|
4742
|
-
|
|
4943
|
+
_context37.t0 = createEmptySummary();
|
|
4743
4944
|
case 14:
|
|
4744
|
-
latestSummary =
|
|
4745
|
-
effectiveCacheId = (_params$
|
|
4945
|
+
latestSummary = _context37.t0;
|
|
4946
|
+
effectiveCacheId = (_params$cacheId3 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId3 !== void 0 ? _params$cacheId3 : this.cacheId;
|
|
4746
4947
|
hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
|
|
4747
4948
|
hasSmallTicketDataFlagOverride = (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined;
|
|
4748
4949
|
enhancePayload = hasPaymentOverride || hasPaymentStatusOverride || hasSmallTicketDataFlagOverride || params !== null && params !== void 0 && params.enhancePayload ? function (payload, ctx) {
|
|
@@ -4760,8 +4961,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4760
4961
|
payload = buildSubmitPayload({
|
|
4761
4962
|
tempOrder: tempOrder,
|
|
4762
4963
|
cacheId: effectiveCacheId,
|
|
4763
|
-
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$
|
|
4764
|
-
businessCode: (
|
|
4964
|
+
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.platform),
|
|
4965
|
+
businessCode: (_ref73 = (_ref74 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref74 !== void 0 ? _ref74 : (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.businessCode) !== null && _ref73 !== void 0 ? _ref73 : (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.business_code,
|
|
4765
4966
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
4766
4967
|
type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
|
|
4767
4968
|
summary: latestSummary,
|
|
@@ -4776,10 +4977,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4776
4977
|
if (!payload.created_at) {
|
|
4777
4978
|
payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
4778
4979
|
}
|
|
4779
|
-
|
|
4980
|
+
_context37.next = 26;
|
|
4780
4981
|
return this.saveDraft();
|
|
4781
4982
|
case 26:
|
|
4782
|
-
|
|
4983
|
+
_context37.prev = 26;
|
|
4783
4984
|
this.logInfo('submitTempOrder calling sales checkout', {
|
|
4784
4985
|
orderId: payload.order_id,
|
|
4785
4986
|
externalSaleNumber: payload.external_sale_number,
|
|
@@ -4789,43 +4990,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4789
4990
|
smallTicketDataFlag: payload.small_ticket_data_flag,
|
|
4790
4991
|
syncMode: payload.sync_mode
|
|
4791
4992
|
});
|
|
4792
|
-
|
|
4993
|
+
_context37.next = 30;
|
|
4793
4994
|
return this.submitSalesOrder({
|
|
4794
4995
|
query: payload
|
|
4795
4996
|
});
|
|
4796
4997
|
case 30:
|
|
4797
|
-
result =
|
|
4798
|
-
|
|
4998
|
+
result = _context37.sent;
|
|
4999
|
+
_context37.next = 43;
|
|
4799
5000
|
break;
|
|
4800
5001
|
case 33:
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
backendErrorResponse = this.extractSubmitErrorResponse(
|
|
5002
|
+
_context37.prev = 33;
|
|
5003
|
+
_context37.t2 = _context37["catch"](26);
|
|
5004
|
+
backendErrorResponse = this.extractSubmitErrorResponse(_context37.t2);
|
|
4804
5005
|
if (!backendErrorResponse) {
|
|
4805
|
-
|
|
5006
|
+
_context37.next = 40;
|
|
4806
5007
|
break;
|
|
4807
5008
|
}
|
|
4808
5009
|
this.store.syncState = 'failed';
|
|
4809
5010
|
this.logSubmitBackendRejected(backendErrorResponse, payload);
|
|
4810
|
-
return
|
|
5011
|
+
return _context37.abrupt("return", backendErrorResponse);
|
|
4811
5012
|
case 40:
|
|
4812
5013
|
this.store.syncState = 'failed';
|
|
4813
5014
|
this.logError('submitTempOrder failed', {
|
|
4814
|
-
error:
|
|
5015
|
+
error: _context37.t2 instanceof Error ? _context37.t2.message : String(_context37.t2),
|
|
4815
5016
|
orderId: payload.order_id,
|
|
4816
5017
|
externalSaleNumber: payload.external_sale_number,
|
|
4817
5018
|
paymentStatus: payload.payment_status,
|
|
4818
5019
|
paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
|
|
4819
5020
|
});
|
|
4820
|
-
throw
|
|
5021
|
+
throw _context37.t2;
|
|
4821
5022
|
case 43:
|
|
4822
5023
|
if (!this.isSubmitResponseRejected(result)) {
|
|
4823
|
-
|
|
5024
|
+
_context37.next = 47;
|
|
4824
5025
|
break;
|
|
4825
5026
|
}
|
|
4826
5027
|
this.store.syncState = 'failed';
|
|
4827
5028
|
this.logSubmitBackendRejected(result, payload);
|
|
4828
|
-
return
|
|
5029
|
+
return _context37.abrupt("return", result);
|
|
4829
5030
|
case 47:
|
|
4830
5031
|
submittedOrderId = this.extractOrderIdFromSubmitResult(result);
|
|
4831
5032
|
this.logInfo('runSubmitTempOrder: 提交成功', {
|
|
@@ -4836,15 +5037,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4836
5037
|
})
|
|
4837
5038
|
});
|
|
4838
5039
|
if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
|
|
4839
|
-
|
|
5040
|
+
_context37.next = 56;
|
|
4840
5041
|
break;
|
|
4841
5042
|
}
|
|
4842
5043
|
tempOrder.order_id = submittedOrderId;
|
|
4843
5044
|
resultRecord = result;
|
|
4844
|
-
|
|
5045
|
+
_context37.next = 54;
|
|
4845
5046
|
return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
|
|
4846
5047
|
case 54:
|
|
4847
|
-
|
|
5048
|
+
_context37.next = 57;
|
|
4848
5049
|
break;
|
|
4849
5050
|
case 56:
|
|
4850
5051
|
if (this.isLocalPendingSubmitResult(result)) {
|
|
@@ -4853,14 +5054,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4853
5054
|
this.store.syncState = 'submitted';
|
|
4854
5055
|
}
|
|
4855
5056
|
case 57:
|
|
4856
|
-
return
|
|
5057
|
+
return _context37.abrupt("return", result);
|
|
4857
5058
|
case 58:
|
|
4858
5059
|
case "end":
|
|
4859
|
-
return
|
|
5060
|
+
return _context37.stop();
|
|
4860
5061
|
}
|
|
4861
|
-
},
|
|
5062
|
+
}, _callee34, this, [[26, 33]]);
|
|
4862
5063
|
}));
|
|
4863
|
-
function runSubmitTempOrder(
|
|
5064
|
+
function runSubmitTempOrder(_x40) {
|
|
4864
5065
|
return _runSubmitTempOrder.apply(this, arguments);
|
|
4865
5066
|
}
|
|
4866
5067
|
return runSubmitTempOrder;
|
|
@@ -4868,10 +5069,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4868
5069
|
}, {
|
|
4869
5070
|
key: "markLocalOrderSynced",
|
|
4870
5071
|
value: function () {
|
|
4871
|
-
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5072
|
+
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(orderId, remoteOrder) {
|
|
4872
5073
|
var tempOrder;
|
|
4873
|
-
return _regeneratorRuntime().wrap(function
|
|
4874
|
-
while (1) switch (
|
|
5074
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context38) {
|
|
5075
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
4875
5076
|
case 0:
|
|
4876
5077
|
tempOrder = this.ensureTempOrder();
|
|
4877
5078
|
tempOrder.order_id = orderId;
|
|
@@ -4879,15 +5080,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4879
5080
|
this.store.lastOrderInfo = remoteOrder;
|
|
4880
5081
|
this.store.syncState = 'submitted';
|
|
4881
5082
|
this.persistTempOrder();
|
|
4882
|
-
|
|
5083
|
+
_context38.next = 8;
|
|
4883
5084
|
return this.saveDraft();
|
|
4884
5085
|
case 8:
|
|
4885
5086
|
case "end":
|
|
4886
|
-
return
|
|
5087
|
+
return _context38.stop();
|
|
4887
5088
|
}
|
|
4888
|
-
},
|
|
5089
|
+
}, _callee35, this);
|
|
4889
5090
|
}));
|
|
4890
|
-
function markLocalOrderSynced(
|
|
5091
|
+
function markLocalOrderSynced(_x41, _x42) {
|
|
4891
5092
|
return _markLocalOrderSynced.apply(this, arguments);
|
|
4892
5093
|
}
|
|
4893
5094
|
return markLocalOrderSynced;
|
|
@@ -4930,10 +5131,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4930
5131
|
value: function extractSubmitErrorResponse(error) {
|
|
4931
5132
|
var _error$response,
|
|
4932
5133
|
_error$response2,
|
|
4933
|
-
|
|
5134
|
+
_this30 = this;
|
|
4934
5135
|
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];
|
|
4935
5136
|
return candidates.find(function (candidate) {
|
|
4936
|
-
return
|
|
5137
|
+
return _this30.isSubmitErrorResponse(candidate);
|
|
4937
5138
|
}) || null;
|
|
4938
5139
|
}
|
|
4939
5140
|
}, {
|
|
@@ -4960,14 +5161,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4960
5161
|
}, {
|
|
4961
5162
|
key: "syncPaymentsToOrder",
|
|
4962
5163
|
value: function () {
|
|
4963
|
-
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4964
|
-
var
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
5164
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
|
|
5165
|
+
var _this31 = this,
|
|
5166
|
+
_params$confirmPendin;
|
|
5167
|
+
var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, submitResult;
|
|
5168
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context39) {
|
|
5169
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
4968
5170
|
case 0:
|
|
4969
5171
|
tempOrder = this.ensureTempOrder();
|
|
4970
|
-
|
|
5172
|
+
needsPaymentNumber = (params.payments || []).some(function (payment) {
|
|
5173
|
+
return String(payment.payment_number || '').trim() === '';
|
|
5174
|
+
});
|
|
5175
|
+
if (!needsPaymentNumber) {
|
|
5176
|
+
_context39.next = 8;
|
|
5177
|
+
break;
|
|
5178
|
+
}
|
|
5179
|
+
_context39.next = 5;
|
|
5180
|
+
return this.getPaymentNumberDevicePrefixAsync();
|
|
5181
|
+
case 5:
|
|
5182
|
+
_context39.t0 = _context39.sent;
|
|
5183
|
+
_context39.next = 9;
|
|
5184
|
+
break;
|
|
5185
|
+
case 8:
|
|
5186
|
+
_context39.t0 = 'LOCAL';
|
|
5187
|
+
case 9:
|
|
5188
|
+
devicePrefix = _context39.t0;
|
|
5189
|
+
mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
|
|
5190
|
+
return _this31.normalizePaymentSource(payment, {
|
|
5191
|
+
defaultPaid: false,
|
|
5192
|
+
devicePrefix: devicePrefix
|
|
5193
|
+
});
|
|
5194
|
+
}));
|
|
4971
5195
|
shouldConfirmPendingVoucherPayments = (_params$confirmPendin = params.confirmPendingVoucherPayments) !== null && _params$confirmPendin !== void 0 ? _params$confirmPendin : params.submitWhenPaid === true;
|
|
4972
5196
|
effectivePayments = shouldConfirmPendingVoucherPayments ? this.confirmPendingVoucherPaymentsInList(mappedPayments) : params.confirmPendingVoucherPayments === false ? this.discardPendingVoucherPaymentsFromList(mappedPayments) : mappedPayments;
|
|
4973
5197
|
completion = this.getPaymentCompletion(effectivePayments);
|
|
@@ -4976,24 +5200,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4976
5200
|
tempOrder.payments = effectivePayments;
|
|
4977
5201
|
tempOrder.payment_status = paymentStatus;
|
|
4978
5202
|
this.persistTempOrder();
|
|
4979
|
-
|
|
5203
|
+
_context39.next = 21;
|
|
4980
5204
|
return this.saveDraft();
|
|
4981
|
-
case
|
|
5205
|
+
case 21:
|
|
4982
5206
|
if (params.submitWhenPaid) {
|
|
4983
|
-
|
|
5207
|
+
_context39.next = 23;
|
|
4984
5208
|
break;
|
|
4985
5209
|
}
|
|
4986
|
-
return
|
|
4987
|
-
case
|
|
5210
|
+
return _context39.abrupt("return", completion);
|
|
5211
|
+
case 23:
|
|
4988
5212
|
if (!(this.store.syncState === 'submitting')) {
|
|
4989
|
-
|
|
5213
|
+
_context39.next = 25;
|
|
4990
5214
|
break;
|
|
4991
5215
|
}
|
|
4992
|
-
return
|
|
4993
|
-
case
|
|
5216
|
+
return _context39.abrupt("return", completion);
|
|
5217
|
+
case 25:
|
|
4994
5218
|
this.store.syncState = 'submitting';
|
|
4995
5219
|
paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, effectivePayments);
|
|
4996
|
-
|
|
5220
|
+
_context39.next = 29;
|
|
4997
5221
|
return this.submitTempOrder({
|
|
4998
5222
|
payments: effectivePayments,
|
|
4999
5223
|
paymentStatus: paymentStatus,
|
|
@@ -5008,18 +5232,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5008
5232
|
return nextPayload;
|
|
5009
5233
|
}
|
|
5010
5234
|
});
|
|
5011
|
-
case
|
|
5012
|
-
submitResult =
|
|
5013
|
-
return
|
|
5235
|
+
case 29:
|
|
5236
|
+
submitResult = _context39.sent;
|
|
5237
|
+
return _context39.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
|
|
5014
5238
|
submitResult: submitResult
|
|
5015
5239
|
}));
|
|
5016
|
-
case
|
|
5240
|
+
case 31:
|
|
5017
5241
|
case "end":
|
|
5018
|
-
return
|
|
5242
|
+
return _context39.stop();
|
|
5019
5243
|
}
|
|
5020
|
-
},
|
|
5244
|
+
}, _callee36, this);
|
|
5021
5245
|
}));
|
|
5022
|
-
function syncPaymentsToOrder(
|
|
5246
|
+
function syncPaymentsToOrder(_x43) {
|
|
5023
5247
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
5024
5248
|
}
|
|
5025
5249
|
return syncPaymentsToOrder;
|
|
@@ -5108,11 +5332,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5108
5332
|
}, {
|
|
5109
5333
|
key: "submitOrder",
|
|
5110
5334
|
value: function () {
|
|
5111
|
-
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5335
|
+
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(order) {
|
|
5112
5336
|
var _order$query$cartItem, _params$bookings, _params$relation_prod;
|
|
5113
5337
|
var url, query, fetchUrl, params;
|
|
5114
|
-
return _regeneratorRuntime().wrap(function
|
|
5115
|
-
while (1) switch (
|
|
5338
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context40) {
|
|
5339
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
5116
5340
|
case 0:
|
|
5117
5341
|
this.logInfo('submitOrder called', {
|
|
5118
5342
|
url: order.url,
|
|
@@ -5132,14 +5356,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5132
5356
|
relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
|
|
5133
5357
|
scheduleDate: params.schedule_date
|
|
5134
5358
|
});
|
|
5135
|
-
return
|
|
5359
|
+
return _context40.abrupt("return", this.request.post(fetchUrl, params));
|
|
5136
5360
|
case 6:
|
|
5137
5361
|
case "end":
|
|
5138
|
-
return
|
|
5362
|
+
return _context40.stop();
|
|
5139
5363
|
}
|
|
5140
|
-
},
|
|
5364
|
+
}, _callee37, this);
|
|
5141
5365
|
}));
|
|
5142
|
-
function submitOrder(
|
|
5366
|
+
function submitOrder(_x44) {
|
|
5143
5367
|
return _submitOrder.apply(this, arguments);
|
|
5144
5368
|
}
|
|
5145
5369
|
return submitOrder;
|
|
@@ -5147,13 +5371,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5147
5371
|
}, {
|
|
5148
5372
|
key: "cancelOrder",
|
|
5149
5373
|
value: function () {
|
|
5150
|
-
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5374
|
+
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
|
|
5151
5375
|
var payload;
|
|
5152
|
-
return _regeneratorRuntime().wrap(function
|
|
5153
|
-
while (1) switch (
|
|
5376
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context41) {
|
|
5377
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
5154
5378
|
case 0:
|
|
5155
5379
|
if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
|
|
5156
|
-
|
|
5380
|
+
_context41.next = 2;
|
|
5157
5381
|
break;
|
|
5158
5382
|
}
|
|
5159
5383
|
throw new Error('取消订单失败:order_ids 不能为空');
|
|
@@ -5169,16 +5393,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5169
5393
|
method: 'PUT',
|
|
5170
5394
|
orderIdsCount: params.order_ids.length
|
|
5171
5395
|
});
|
|
5172
|
-
return
|
|
5396
|
+
return _context41.abrupt("return", this.request.put('/order/update-status', payload, {
|
|
5173
5397
|
isShopApi: true
|
|
5174
5398
|
}));
|
|
5175
5399
|
case 5:
|
|
5176
5400
|
case "end":
|
|
5177
|
-
return
|
|
5401
|
+
return _context41.stop();
|
|
5178
5402
|
}
|
|
5179
|
-
},
|
|
5403
|
+
}, _callee38, this);
|
|
5180
5404
|
}));
|
|
5181
|
-
function cancelOrder(
|
|
5405
|
+
function cancelOrder(_x45) {
|
|
5182
5406
|
return _cancelOrder.apply(this, arguments);
|
|
5183
5407
|
}
|
|
5184
5408
|
return cancelOrder;
|
|
@@ -5186,19 +5410,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5186
5410
|
}, {
|
|
5187
5411
|
key: "changeBookingStatus",
|
|
5188
5412
|
value: function () {
|
|
5189
|
-
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5413
|
+
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
|
|
5190
5414
|
var url, payload;
|
|
5191
|
-
return _regeneratorRuntime().wrap(function
|
|
5192
|
-
while (1) switch (
|
|
5415
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context42) {
|
|
5416
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
5193
5417
|
case 0:
|
|
5194
5418
|
if (params.booking_id) {
|
|
5195
|
-
|
|
5419
|
+
_context42.next = 2;
|
|
5196
5420
|
break;
|
|
5197
5421
|
}
|
|
5198
5422
|
throw new Error('变更预约状态失败:booking_id 不能为空');
|
|
5199
5423
|
case 2:
|
|
5200
5424
|
if (params.appointment_status) {
|
|
5201
|
-
|
|
5425
|
+
_context42.next = 4;
|
|
5202
5426
|
break;
|
|
5203
5427
|
}
|
|
5204
5428
|
throw new Error('变更预约状态失败:appointment_status 不能为空');
|
|
@@ -5213,16 +5437,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5213
5437
|
bookingId: params.booking_id,
|
|
5214
5438
|
appointmentStatus: params.appointment_status
|
|
5215
5439
|
});
|
|
5216
|
-
return
|
|
5440
|
+
return _context42.abrupt("return", this.request.put(url, payload, {
|
|
5217
5441
|
isShopApi: true
|
|
5218
5442
|
}));
|
|
5219
5443
|
case 8:
|
|
5220
5444
|
case "end":
|
|
5221
|
-
return
|
|
5445
|
+
return _context42.stop();
|
|
5222
5446
|
}
|
|
5223
|
-
},
|
|
5447
|
+
}, _callee39, this);
|
|
5224
5448
|
}));
|
|
5225
|
-
function changeBookingStatus(
|
|
5449
|
+
function changeBookingStatus(_x46) {
|
|
5226
5450
|
return _changeBookingStatus.apply(this, arguments);
|
|
5227
5451
|
}
|
|
5228
5452
|
return changeBookingStatus;
|
|
@@ -5240,11 +5464,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5240
5464
|
}, {
|
|
5241
5465
|
key: "createOrderByCheckout",
|
|
5242
5466
|
value: (function () {
|
|
5243
|
-
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5467
|
+
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
|
|
5244
5468
|
var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3, _params$bookings3, _params$relation_prod3, _params$payments4;
|
|
5245
5469
|
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;
|
|
5246
|
-
return _regeneratorRuntime().wrap(function
|
|
5247
|
-
while (1) switch (
|
|
5470
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context43) {
|
|
5471
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
5248
5472
|
case 0:
|
|
5249
5473
|
// 过滤掉由在线店铺下单的 payment 支付数据
|
|
5250
5474
|
onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
|
|
@@ -5278,7 +5502,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5278
5502
|
relationProductsCount: ((_params$relation_prod3 = params.relation_products) === null || _params$relation_prod3 === void 0 ? void 0 : _params$relation_prod3.length) || 0,
|
|
5279
5503
|
paymentsCount: ((_params$payments4 = params.payments) === null || _params$payments4 === void 0 ? void 0 : _params$payments4.length) || 0
|
|
5280
5504
|
});
|
|
5281
|
-
|
|
5505
|
+
_context43.prev = 4;
|
|
5282
5506
|
// 构建订单数据,设置默认值并允许 params 覆盖
|
|
5283
5507
|
orderData = _objectSpread({
|
|
5284
5508
|
sales_channel: 'my_pisel',
|
|
@@ -5340,13 +5564,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5340
5564
|
hasOrderId: !!orderData.order_id,
|
|
5341
5565
|
smallTicketDataFlag: orderData.small_ticket_data_flag
|
|
5342
5566
|
});
|
|
5343
|
-
|
|
5567
|
+
_context43.next = 12;
|
|
5344
5568
|
return this.request.post('/order/checkout', orderData, {
|
|
5345
5569
|
osServer: true,
|
|
5346
5570
|
customToast: function customToast() {}
|
|
5347
5571
|
});
|
|
5348
5572
|
case 12:
|
|
5349
|
-
response =
|
|
5573
|
+
response = _context43.sent;
|
|
5350
5574
|
this.logInfo('Order API called successfully', {
|
|
5351
5575
|
response: response
|
|
5352
5576
|
});
|
|
@@ -5354,22 +5578,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5354
5578
|
success: !!response,
|
|
5355
5579
|
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)
|
|
5356
5580
|
});
|
|
5357
|
-
return
|
|
5581
|
+
return _context43.abrupt("return", response);
|
|
5358
5582
|
case 18:
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
console.error('[Order] createOrderByCheckout 创建订单失败:',
|
|
5583
|
+
_context43.prev = 18;
|
|
5584
|
+
_context43.t0 = _context43["catch"](4);
|
|
5585
|
+
console.error('[Order] createOrderByCheckout 创建订单失败:', _context43.t0);
|
|
5362
5586
|
this.logInfo('Order API called failed', {
|
|
5363
|
-
error:
|
|
5587
|
+
error: _context43.t0 instanceof Error ? _context43.t0.message : String(_context43.t0)
|
|
5364
5588
|
});
|
|
5365
|
-
throw
|
|
5589
|
+
throw _context43.t0;
|
|
5366
5590
|
case 23:
|
|
5367
5591
|
case "end":
|
|
5368
|
-
return
|
|
5592
|
+
return _context43.stop();
|
|
5369
5593
|
}
|
|
5370
|
-
},
|
|
5594
|
+
}, _callee40, this, [[4, 18]]);
|
|
5371
5595
|
}));
|
|
5372
|
-
function createOrderByCheckout(
|
|
5596
|
+
function createOrderByCheckout(_x47) {
|
|
5373
5597
|
return _createOrderByCheckout.apply(this, arguments);
|
|
5374
5598
|
}
|
|
5375
5599
|
return createOrderByCheckout;
|
|
@@ -5377,24 +5601,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5377
5601
|
}, {
|
|
5378
5602
|
key: "submitSalesOrder",
|
|
5379
5603
|
value: function () {
|
|
5380
|
-
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5604
|
+
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
|
|
5381
5605
|
var url, query, fetchUrl;
|
|
5382
|
-
return _regeneratorRuntime().wrap(function
|
|
5383
|
-
while (1) switch (
|
|
5606
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context44) {
|
|
5607
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
5384
5608
|
case 0:
|
|
5385
5609
|
url = params.url, query = params.query;
|
|
5386
5610
|
fetchUrl = url || '/order/sales/checkout';
|
|
5387
|
-
return
|
|
5611
|
+
return _context44.abrupt("return", this.request.post(fetchUrl, query, {
|
|
5388
5612
|
osServer: true,
|
|
5389
5613
|
customToast: function customToast() {}
|
|
5390
5614
|
}));
|
|
5391
5615
|
case 3:
|
|
5392
5616
|
case "end":
|
|
5393
|
-
return
|
|
5617
|
+
return _context44.stop();
|
|
5394
5618
|
}
|
|
5395
|
-
},
|
|
5619
|
+
}, _callee41, this);
|
|
5396
5620
|
}));
|
|
5397
|
-
function submitSalesOrder(
|
|
5621
|
+
function submitSalesOrder(_x48) {
|
|
5398
5622
|
return _submitSalesOrder.apply(this, arguments);
|
|
5399
5623
|
}
|
|
5400
5624
|
return submitSalesOrder;
|
|
@@ -5408,37 +5632,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5408
5632
|
}, {
|
|
5409
5633
|
key: "sendCustomerPayLink",
|
|
5410
5634
|
value: (function () {
|
|
5411
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5635
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
|
|
5412
5636
|
var _params$emails;
|
|
5413
5637
|
var orderIds;
|
|
5414
|
-
return _regeneratorRuntime().wrap(function
|
|
5415
|
-
while (1) switch (
|
|
5638
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context45) {
|
|
5639
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
5416
5640
|
case 0:
|
|
5417
5641
|
orderIds = params.order_ids || params.orderIds || [];
|
|
5418
5642
|
if (orderIds.length) {
|
|
5419
|
-
|
|
5643
|
+
_context45.next = 3;
|
|
5420
5644
|
break;
|
|
5421
5645
|
}
|
|
5422
5646
|
throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
|
|
5423
5647
|
case 3:
|
|
5424
5648
|
if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
|
|
5425
|
-
|
|
5649
|
+
_context45.next = 5;
|
|
5426
5650
|
break;
|
|
5427
5651
|
}
|
|
5428
5652
|
throw new Error('发送支付链接需要至少一个邮箱');
|
|
5429
5653
|
case 5:
|
|
5430
|
-
return
|
|
5654
|
+
return _context45.abrupt("return", this.request.post('/order/batch-email', {
|
|
5431
5655
|
order_ids: orderIds,
|
|
5432
5656
|
notify_action: params.notify_action || 'order_payment_reminder',
|
|
5433
5657
|
emails: params.emails
|
|
5434
5658
|
}));
|
|
5435
5659
|
case 6:
|
|
5436
5660
|
case "end":
|
|
5437
|
-
return
|
|
5661
|
+
return _context45.stop();
|
|
5438
5662
|
}
|
|
5439
|
-
},
|
|
5663
|
+
}, _callee42, this);
|
|
5440
5664
|
}));
|
|
5441
|
-
function sendCustomerPayLink(
|
|
5665
|
+
function sendCustomerPayLink(_x49) {
|
|
5442
5666
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
5443
5667
|
}
|
|
5444
5668
|
return sendCustomerPayLink;
|
|
@@ -5446,14 +5670,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5446
5670
|
}, {
|
|
5447
5671
|
key: "getSalesOrderByLookup",
|
|
5448
5672
|
value: function () {
|
|
5449
|
-
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5673
|
+
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
|
|
5450
5674
|
var lookup, res;
|
|
5451
|
-
return _regeneratorRuntime().wrap(function
|
|
5452
|
-
while (1) switch (
|
|
5675
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context46) {
|
|
5676
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
5453
5677
|
case 0:
|
|
5454
5678
|
lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
|
|
5455
5679
|
if (lookup) {
|
|
5456
|
-
|
|
5680
|
+
_context46.next = 3;
|
|
5457
5681
|
break;
|
|
5458
5682
|
}
|
|
5459
5683
|
throw new Error('加载销售详情需要 lookup');
|
|
@@ -5462,7 +5686,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5462
5686
|
if (lookup.startsWith('LOCAL_')) {
|
|
5463
5687
|
params.forceRemote = false;
|
|
5464
5688
|
}
|
|
5465
|
-
|
|
5689
|
+
_context46.next = 6;
|
|
5466
5690
|
return this.request.get("/order/sales/".concat(encodeURIComponent(lookup)), _objectSpread({
|
|
5467
5691
|
with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info']
|
|
5468
5692
|
}, params.forceRemote ? {
|
|
@@ -5471,18 +5695,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5471
5695
|
osServer: true
|
|
5472
5696
|
});
|
|
5473
5697
|
case 6:
|
|
5474
|
-
res =
|
|
5698
|
+
res = _context46.sent;
|
|
5475
5699
|
if (res.code === 200) {
|
|
5476
5700
|
this.store.lastOrderInfo = res.data;
|
|
5477
5701
|
}
|
|
5478
|
-
return
|
|
5702
|
+
return _context46.abrupt("return", res);
|
|
5479
5703
|
case 9:
|
|
5480
5704
|
case "end":
|
|
5481
|
-
return
|
|
5705
|
+
return _context46.stop();
|
|
5482
5706
|
}
|
|
5483
|
-
},
|
|
5707
|
+
}, _callee43, this);
|
|
5484
5708
|
}));
|
|
5485
|
-
function getSalesOrderByLookup(
|
|
5709
|
+
function getSalesOrderByLookup(_x50) {
|
|
5486
5710
|
return _getSalesOrderByLookup.apply(this, arguments);
|
|
5487
5711
|
}
|
|
5488
5712
|
return getSalesOrderByLookup;
|
|
@@ -5496,11 +5720,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5496
5720
|
}, {
|
|
5497
5721
|
key: "hydrateTempOrderFromRecord",
|
|
5498
5722
|
value: (function () {
|
|
5499
|
-
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5723
|
+
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(record, options) {
|
|
5500
5724
|
var _this$store$discount19;
|
|
5501
|
-
var sourceRaw, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, nextTempOrder, rawSummary, summarySurcharges, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount20, _this$store$discount21;
|
|
5502
|
-
return _regeneratorRuntime().wrap(function
|
|
5503
|
-
while (1) switch (
|
|
5725
|
+
var sourceRaw, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, nextTempOrder, sourceLastOrderInfo, isDraftOrder, syntheticIdentityOptions, rawSummary, summarySurcharges, hadSyntheticDraftOrderId, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount20, _this$store$discount21;
|
|
5726
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context47) {
|
|
5727
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
5504
5728
|
case 0:
|
|
5505
5729
|
sourceRaw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
|
|
5506
5730
|
identityReadySource = this.seedAnonymousBookingUidsFromProducts(sourceRaw);
|
|
@@ -5525,7 +5749,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5525
5749
|
}
|
|
5526
5750
|
nextTempOrder = this.normalizeTempOrderForRuntime(raw, {
|
|
5527
5751
|
makeEditMark: true
|
|
5528
|
-
});
|
|
5752
|
+
}); // Server list compatibility may synthesize order_id from external_sale_number; tempOrder must not.
|
|
5753
|
+
sourceLastOrderInfo = raw.lastOrderInfo || raw;
|
|
5754
|
+
isDraftOrder = Number(nextTempOrder.is_draft_order || 0) === 1;
|
|
5755
|
+
syntheticIdentityOptions = {
|
|
5756
|
+
isDraftOrder: isDraftOrder,
|
|
5757
|
+
externalSaleNumber: nextTempOrder.external_sale_number
|
|
5758
|
+
};
|
|
5529
5759
|
rawSummary = raw.summary && _typeof(raw.summary) === 'object' ? raw.summary : {};
|
|
5530
5760
|
summarySurcharges = Array.isArray(rawSummary.surcharges) ? rawSummary.surcharges.map(function (s) {
|
|
5531
5761
|
return _objectSpread({}, s || {});
|
|
@@ -5545,10 +5775,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5545
5775
|
productFingerprint: this.buildOrderProductsFingerprint(nextTempOrder.products || [])
|
|
5546
5776
|
}
|
|
5547
5777
|
});
|
|
5548
|
-
|
|
5549
|
-
|
|
5550
|
-
|
|
5551
|
-
|
|
5778
|
+
this.store.lastOrderInfo = this.withoutSyntheticDraftOrderIdForRuntime(sourceLastOrderInfo, syntheticIdentityOptions);
|
|
5779
|
+
hadSyntheticDraftOrderId = this.isSyntheticDraftOrderIdForRuntime(raw, syntheticIdentityOptions) || this.isSyntheticDraftOrderIdForRuntime(sourceLastOrderInfo, syntheticIdentityOptions);
|
|
5780
|
+
if (hadSyntheticDraftOrderId && this.store.syncState !== 'submitting') {
|
|
5781
|
+
this.store.syncState = 'local';
|
|
5782
|
+
}
|
|
5552
5783
|
hydratedEditDiscounts = this.collectHydratedEditDiscounts(nextTempOrder.products);
|
|
5553
5784
|
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() || [] : [];
|
|
5554
5785
|
currentScanDiscounts = currentDiscounts.filter(function (discount) {
|
|
@@ -5563,34 +5794,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5563
5794
|
nextDiscounts = [].concat(_toConsumableArray(hydratedEditDiscounts), _toConsumableArray(retainedScanDiscounts));
|
|
5564
5795
|
shouldSkipEmptyDiscountSync = nextDiscounts.length === 0 && currentDiscounts.length === 0;
|
|
5565
5796
|
if (shouldSkipEmptyDiscountSync) {
|
|
5566
|
-
|
|
5797
|
+
_context47.next = 31;
|
|
5567
5798
|
break;
|
|
5568
5799
|
}
|
|
5569
5800
|
OrderModule.populateSavedAmounts(nextTempOrder.products, nextDiscounts);
|
|
5570
|
-
|
|
5801
|
+
_context47.next = 29;
|
|
5571
5802
|
return (_this$store$discount20 = this.store.discount) === null || _this$store$discount20 === void 0 ? void 0 : _this$store$discount20.setOriginalDiscountList(nextDiscounts);
|
|
5572
|
-
case
|
|
5573
|
-
|
|
5803
|
+
case 29:
|
|
5804
|
+
_context47.next = 31;
|
|
5574
5805
|
return (_this$store$discount21 = this.store.discount) === null || _this$store$discount21 === void 0 ? void 0 : _this$store$discount21.setDiscountList(nextDiscounts);
|
|
5575
|
-
case
|
|
5806
|
+
case 31:
|
|
5576
5807
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
5577
|
-
|
|
5808
|
+
_context47.next = 34;
|
|
5578
5809
|
break;
|
|
5579
5810
|
}
|
|
5580
|
-
|
|
5811
|
+
_context47.next = 34;
|
|
5581
5812
|
return this.recalculateSummary({
|
|
5582
5813
|
createIfMissing: false
|
|
5583
5814
|
});
|
|
5584
|
-
case
|
|
5815
|
+
case 34:
|
|
5585
5816
|
this.persistTempOrder();
|
|
5586
|
-
return
|
|
5587
|
-
case
|
|
5817
|
+
return _context47.abrupt("return", nextTempOrder);
|
|
5818
|
+
case 36:
|
|
5588
5819
|
case "end":
|
|
5589
|
-
return
|
|
5820
|
+
return _context47.stop();
|
|
5590
5821
|
}
|
|
5591
|
-
},
|
|
5822
|
+
}, _callee44, this);
|
|
5592
5823
|
}));
|
|
5593
|
-
function hydrateTempOrderFromRecord(
|
|
5824
|
+
function hydrateTempOrderFromRecord(_x51, _x52) {
|
|
5594
5825
|
return _hydrateTempOrderFromRecord.apply(this, arguments);
|
|
5595
5826
|
}
|
|
5596
5827
|
return hydrateTempOrderFromRecord;
|
|
@@ -5704,11 +5935,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5704
5935
|
}, {
|
|
5705
5936
|
key: "normalizeTempOrderForRuntime",
|
|
5706
5937
|
value: function normalizeTempOrderForRuntime(raw, options) {
|
|
5707
|
-
var
|
|
5708
|
-
var
|
|
5938
|
+
var _this32 = this;
|
|
5939
|
+
var runtimeRaw = this.withoutSyntheticDraftOrderIdForRuntime(raw);
|
|
5940
|
+
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
|
|
5709
5941
|
// ES 列表详情使用 id 表示订单主键;OS 详情态统一依赖 order_id 驱动操作按钮。
|
|
5710
|
-
if ((nextTempOrder.order_id === undefined || nextTempOrder.order_id === null) && (
|
|
5711
|
-
nextTempOrder.order_id =
|
|
5942
|
+
if ((nextTempOrder.order_id === undefined || nextTempOrder.order_id === null) && (runtimeRaw === null || runtimeRaw === void 0 ? void 0 : runtimeRaw.id) !== undefined && (runtimeRaw === null || runtimeRaw === void 0 ? void 0 : runtimeRaw.id) !== null) {
|
|
5943
|
+
nextTempOrder.order_id = runtimeRaw.id;
|
|
5712
5944
|
}
|
|
5713
5945
|
delete nextTempOrder.summary;
|
|
5714
5946
|
delete nextTempOrder.lastOrderInfo;
|
|
@@ -5727,12 +5959,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5727
5959
|
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
5728
5960
|
var rawProducts = Array.isArray(raw.products) ? raw.products : [];
|
|
5729
5961
|
nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
|
|
5730
|
-
return
|
|
5962
|
+
return _this32.normalizeHydratedOrderProduct(p, {
|
|
5731
5963
|
makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
|
|
5732
5964
|
});
|
|
5733
5965
|
}) : [];
|
|
5734
5966
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
5735
|
-
var booking =
|
|
5967
|
+
var booking = _this32.normalizeHydratedBookingHolder(b || {});
|
|
5736
5968
|
return _objectSpread(_objectSpread({}, booking), {}, {
|
|
5737
5969
|
is_all: normalizeBookingIsAll(booking),
|
|
5738
5970
|
sub_type: normalizeBookingSubType(booking)
|
|
@@ -5762,7 +5994,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5762
5994
|
_step24;
|
|
5763
5995
|
try {
|
|
5764
5996
|
for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
|
|
5765
|
-
var _product$metadata11,
|
|
5997
|
+
var _product$metadata11, _ref75, _ref76, _existed$origin, _rawProduct$metadata;
|
|
5766
5998
|
var _step24$value = _slicedToArray(_step24.value, 2),
|
|
5767
5999
|
index = _step24$value[0],
|
|
5768
6000
|
product = _step24$value[1];
|
|
@@ -5770,7 +6002,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5770
6002
|
if (!uid) continue;
|
|
5771
6003
|
var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
|
|
5772
6004
|
var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
|
|
5773
|
-
var origin = (
|
|
6005
|
+
var origin = (_ref75 = (_ref76 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref76 !== void 0 ? _ref76 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref75 !== void 0 ? _ref75 : rawProduct;
|
|
5774
6006
|
var originSnapshot = cloneDeep(origin);
|
|
5775
6007
|
var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
|
|
5776
6008
|
if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
|
|
@@ -5798,6 +6030,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5798
6030
|
nextTempOrder.vouchers = raw.vouchers || [];
|
|
5799
6031
|
return nextTempOrder;
|
|
5800
6032
|
}
|
|
6033
|
+
}, {
|
|
6034
|
+
key: "isSyntheticDraftOrderIdForRuntime",
|
|
6035
|
+
value: function isSyntheticDraftOrderIdForRuntime(record, options) {
|
|
6036
|
+
var _options$isDraftOrder, _record$external_sale;
|
|
6037
|
+
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;
|
|
6038
|
+
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;
|
|
6039
|
+
var orderId = record === null || record === void 0 ? void 0 : record.order_id;
|
|
6040
|
+
return Boolean(isDraftOrder && orderId !== undefined && orderId !== null && orderId !== '' && externalSaleNumber !== undefined && externalSaleNumber !== null && externalSaleNumber !== '' && String(orderId) === String(externalSaleNumber));
|
|
6041
|
+
}
|
|
6042
|
+
}, {
|
|
6043
|
+
key: "withoutSyntheticDraftOrderIdForRuntime",
|
|
6044
|
+
value: function withoutSyntheticDraftOrderIdForRuntime(record, options) {
|
|
6045
|
+
if (!this.isSyntheticDraftOrderIdForRuntime(record, options)) return record;
|
|
6046
|
+
return _objectSpread(_objectSpread({}, record), {}, {
|
|
6047
|
+
order_id: null
|
|
6048
|
+
});
|
|
6049
|
+
}
|
|
5801
6050
|
}, {
|
|
5802
6051
|
key: "hydrateLinkedBookingIdentity",
|
|
5803
6052
|
value: function hydrateLinkedBookingIdentity(tempOrder) {
|
|
@@ -5882,10 +6131,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5882
6131
|
}, {
|
|
5883
6132
|
key: "normalizeHydratedProductOptionItem",
|
|
5884
6133
|
value: function normalizeHydratedProductOptionItem(optionItem) {
|
|
5885
|
-
var
|
|
5886
|
-
var rawNum = (
|
|
6134
|
+
var _ref77, _optionItem$num, _ref78, _optionItem$add_price;
|
|
6135
|
+
var rawNum = (_ref77 = (_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 && _ref77 !== void 0 ? _ref77 : 1;
|
|
5887
6136
|
var parsedNum = Number(rawNum);
|
|
5888
|
-
var rawPrice = (
|
|
6137
|
+
var rawPrice = (_ref78 = (_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 && _ref78 !== void 0 ? _ref78 : 0;
|
|
5889
6138
|
var parsedPrice = Number(rawPrice);
|
|
5890
6139
|
var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
|
|
5891
6140
|
option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
|
|
@@ -5902,7 +6151,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5902
6151
|
}, {
|
|
5903
6152
|
key: "normalizeHydratedOrderProduct",
|
|
5904
6153
|
value: function normalizeHydratedOrderProduct(product, options) {
|
|
5905
|
-
var
|
|
6154
|
+
var _this33 = this;
|
|
5906
6155
|
var row = _objectSpread({}, product || {});
|
|
5907
6156
|
if (row.num === undefined && row.product_quantity !== undefined) {
|
|
5908
6157
|
row.num = row.product_quantity;
|
|
@@ -5910,7 +6159,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5910
6159
|
var productSku = ensureProductSku(row);
|
|
5911
6160
|
row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
|
|
5912
6161
|
option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
|
|
5913
|
-
return
|
|
6162
|
+
return _this33.normalizeHydratedProductOptionItem(optionItem || {});
|
|
5914
6163
|
}))
|
|
5915
6164
|
});
|
|
5916
6165
|
delete row["product_".concat('option', "_item")];
|
|
@@ -5947,27 +6196,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5947
6196
|
}, {
|
|
5948
6197
|
key: "getOrderInfo",
|
|
5949
6198
|
value: function () {
|
|
5950
|
-
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6199
|
+
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(order_id) {
|
|
5951
6200
|
var res;
|
|
5952
|
-
return _regeneratorRuntime().wrap(function
|
|
5953
|
-
while (1) switch (
|
|
6201
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context48) {
|
|
6202
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
5954
6203
|
case 0:
|
|
5955
|
-
|
|
6204
|
+
_context48.next = 2;
|
|
5956
6205
|
return this.request.get("/order/sales/".concat(order_id), {
|
|
5957
6206
|
with: ['products', 'bookings']
|
|
5958
6207
|
}, {
|
|
5959
6208
|
osServer: true
|
|
5960
6209
|
});
|
|
5961
6210
|
case 2:
|
|
5962
|
-
res =
|
|
5963
|
-
return
|
|
6211
|
+
res = _context48.sent;
|
|
6212
|
+
return _context48.abrupt("return", res);
|
|
5964
6213
|
case 4:
|
|
5965
6214
|
case "end":
|
|
5966
|
-
return
|
|
6215
|
+
return _context48.stop();
|
|
5967
6216
|
}
|
|
5968
|
-
},
|
|
6217
|
+
}, _callee45, this);
|
|
5969
6218
|
}));
|
|
5970
|
-
function getOrderInfo(
|
|
6219
|
+
function getOrderInfo(_x53) {
|
|
5971
6220
|
return _getOrderInfo.apply(this, arguments);
|
|
5972
6221
|
}
|
|
5973
6222
|
return getOrderInfo;
|
|
@@ -6026,10 +6275,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6026
6275
|
_step29;
|
|
6027
6276
|
try {
|
|
6028
6277
|
for (_iterator29.s(); !(_step29 = _iterator29.n()).done;) {
|
|
6029
|
-
var
|
|
6278
|
+
var _ref79, _bundle$num3;
|
|
6030
6279
|
var bundle = _step29.value;
|
|
6031
6280
|
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));
|
|
6032
|
-
var bundleQty = new Decimal(Number(qty) || 1).times(Number((
|
|
6281
|
+
var bundleQty = new Decimal(Number(qty) || 1).times(Number((_ref79 = (_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 && _ref79 !== void 0 ? _ref79 : 1) || 1).toNumber();
|
|
6033
6282
|
var _iterator30 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
|
|
6034
6283
|
_step30;
|
|
6035
6284
|
try {
|