@pisell/pisellos 2.3.100 → 2.3.102
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +287 -101
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +25 -0
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/Discount/index.d.ts +2 -0
- package/dist/modules/Discount/index.js +38 -5
- package/dist/modules/Discount/types.d.ts +11 -0
- package/dist/modules/Order/index.d.ts +14 -0
- package/dist/modules/Order/index.js +617 -368
- package/dist/modules/Order/types.d.ts +11 -3
- package/dist/modules/Order/utils/virtualSettlement.d.ts +63 -0
- package/dist/modules/Order/utils/virtualSettlement.js +284 -0
- package/dist/modules/Order/utils.d.ts +1 -0
- package/dist/modules/Order/utils.js +63 -24
- package/dist/modules/Product/types.d.ts +23 -0
- package/dist/modules/Rules/index.d.ts +5 -0
- package/dist/modules/Rules/index.js +27 -12
- package/dist/modules/SalesSummary/index.d.ts +1 -0
- package/dist/modules/SalesSummary/index.js +4 -3
- package/dist/modules/SalesSummary/types.d.ts +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +1 -0
- package/dist/modules/SalesSummary/utils.js +21 -1
- package/dist/solution/BaseSales/index.d.ts +10 -1
- package/dist/solution/BaseSales/index.js +1099 -784
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +72 -9
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingTicket/utils/addProductDecision.js +2 -1
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +137 -6
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +25 -0
- package/lib/modules/Discount/index.d.ts +2 -0
- package/lib/modules/Discount/index.js +31 -2
- package/lib/modules/Discount/types.d.ts +11 -0
- package/lib/modules/Order/index.d.ts +14 -0
- package/lib/modules/Order/index.js +195 -15
- package/lib/modules/Order/types.d.ts +11 -3
- package/lib/modules/Order/utils/virtualSettlement.d.ts +63 -0
- package/lib/modules/Order/utils/virtualSettlement.js +262 -0
- package/lib/modules/Order/utils.d.ts +1 -0
- package/lib/modules/Order/utils.js +57 -20
- package/lib/modules/Product/types.d.ts +23 -0
- package/lib/modules/Rules/index.d.ts +5 -0
- package/lib/modules/Rules/index.js +20 -11
- package/lib/modules/SalesSummary/index.d.ts +1 -0
- package/lib/modules/SalesSummary/index.js +4 -2
- package/lib/modules/SalesSummary/types.d.ts +1 -0
- package/lib/modules/SalesSummary/utils.d.ts +1 -0
- package/lib/modules/SalesSummary/utils.js +17 -1
- package/lib/solution/BaseSales/index.d.ts +10 -1
- package/lib/solution/BaseSales/index.js +211 -9
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +38 -0
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingTicket/utils/addProductDecision.js +1 -0
- package/package.json +1 -1
|
@@ -37,6 +37,7 @@ import Decimal from 'decimal.js';
|
|
|
37
37
|
import { cloneDeep, isEqual, mergeWith } from 'lodash-es';
|
|
38
38
|
import { createModule } from "../BookingByStep/types";
|
|
39
39
|
import { composeLinePrice, createUuidV4, ensureProductSku, getProductSkuOptions, resolveIsFormSubject, sumOptionUnitPrice } from "../../modules/Order/utils";
|
|
40
|
+
import { buildCurrencyDisplaySnapshot, getTempOrderSettlementSnapshot, isVirtualSettlementOrder } from "../../modules/Order/utils/virtualSettlement";
|
|
40
41
|
import { ensureOrderPaymentNumber, isIdentifiedPendingOrderPayment, isPendingOrderPayment, mergeOrderPaymentListsByIdentity, resolveOrderPaymentIdentity } from "../../modules/Order/payment-utils";
|
|
41
42
|
import { resolvePaymentNumberDevicePrefix, resolvePaymentNumberDevicePrefixFromDeviceId } from "../../utils/payment-number";
|
|
42
43
|
import { applyOrderCollectionUidRemaps, getOrderCollectionPersistentId, getOrderCollectionReferenceUid, getOrderCollectionUid, isSameOrderCollectionItem, mergeOrderCollectionItems, normalizeOrderCollection, normalizeOrderCollections, setOrderCollectionUid } from "../../modules/Order/utils/orderCollectionIdentity";
|
|
@@ -1763,6 +1764,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1763
1764
|
return _this10.getAppData(key);
|
|
1764
1765
|
});
|
|
1765
1766
|
}
|
|
1767
|
+
}, {
|
|
1768
|
+
key: "isMultiCurrencySettlementEnabled",
|
|
1769
|
+
value: function isMultiCurrencySettlementEnabled() {
|
|
1770
|
+
var _this$otherParams11;
|
|
1771
|
+
return ((_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.enableMultiCurrencySettlement) === true;
|
|
1772
|
+
}
|
|
1773
|
+
}, {
|
|
1774
|
+
key: "isActiveVirtualSettlementOrder",
|
|
1775
|
+
value: function isActiveVirtualSettlementOrder(tempOrder) {
|
|
1776
|
+
return this.isMultiCurrencySettlementEnabled() && isVirtualSettlementOrder(tempOrder);
|
|
1777
|
+
}
|
|
1778
|
+
}, {
|
|
1779
|
+
key: "isHistoricalVirtualSettlementOrder",
|
|
1780
|
+
value: function isHistoricalVirtualSettlementOrder(tempOrder) {
|
|
1781
|
+
var _tempOrder$metadata;
|
|
1782
|
+
return (tempOrder === null || tempOrder === void 0 || (_tempOrder$metadata = tempOrder.metadata) === null || _tempOrder$metadata === void 0 || (_tempOrder$metadata = _tempOrder$metadata.currency_settlement_config) === null || _tempOrder$metadata === void 0 ? void 0 : _tempOrder$metadata.settlement_type) === 'virtual_currency';
|
|
1783
|
+
}
|
|
1766
1784
|
}, {
|
|
1767
1785
|
key: "syncAppDataToTempOrder",
|
|
1768
1786
|
value: function syncAppDataToTempOrder(tempOrder) {
|
|
@@ -1770,6 +1788,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1770
1788
|
var taxCountryCode = this.getAppData('tax_country_code');
|
|
1771
1789
|
var currencyCode = this.getAppData('shop_currency_code');
|
|
1772
1790
|
var currencySymbol = this.getAppData('shop_symbol');
|
|
1791
|
+
// 历史虚拟币订单不依赖交易开关;普通 POS 不从商品行残留快照推断订单币种。
|
|
1792
|
+
var isHistoricalVirtualSettlement = this.isHistoricalVirtualSettlementOrder(tempOrder);
|
|
1793
|
+
var isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder) || isHistoricalVirtualSettlement;
|
|
1794
|
+
var shouldManageLegalCurrencySnapshot = this.isMultiCurrencySettlementEnabled() || isHistoricalVirtualSettlement;
|
|
1773
1795
|
var isChanged = false;
|
|
1774
1796
|
if (isPriceIncludeTax !== undefined) {
|
|
1775
1797
|
var nextIsPriceIncludeTax = Number(isPriceIncludeTax);
|
|
@@ -1785,14 +1807,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1785
1807
|
isChanged = true;
|
|
1786
1808
|
}
|
|
1787
1809
|
}
|
|
1788
|
-
|
|
1810
|
+
tempOrder.metadata = tempOrder.metadata || {};
|
|
1811
|
+
if (shouldManageLegalCurrencySnapshot) {
|
|
1812
|
+
var _ref31, _ref32, _tempOrder$metadata$l, _ref33, _ref34, _tempOrder$metadata$l2, _tempOrder$metadata$l3;
|
|
1813
|
+
var legalCurrencySnapshot = {
|
|
1814
|
+
currency_code: String((_ref31 = (_ref32 = currencyCode !== null && currencyCode !== void 0 ? currencyCode : (_tempOrder$metadata$l = tempOrder.metadata.legal_currency_snapshot) === null || _tempOrder$metadata$l === void 0 ? void 0 : _tempOrder$metadata$l.currency_code) !== null && _ref32 !== void 0 ? _ref32 : tempOrder.currency_code) !== null && _ref31 !== void 0 ? _ref31 : ''),
|
|
1815
|
+
currency_symbol: String((_ref33 = (_ref34 = currencySymbol !== null && currencySymbol !== void 0 ? currencySymbol : (_tempOrder$metadata$l2 = tempOrder.metadata.legal_currency_snapshot) === null || _tempOrder$metadata$l2 === void 0 ? void 0 : _tempOrder$metadata$l2.currency_symbol) !== null && _ref34 !== void 0 ? _ref34 : tempOrder.currency_symbol) !== null && _ref33 !== void 0 ? _ref33 : ''),
|
|
1816
|
+
currency_format: String(((_tempOrder$metadata$l3 = tempOrder.metadata.legal_currency_snapshot) === null || _tempOrder$metadata$l3 === void 0 ? void 0 : _tempOrder$metadata$l3.currency_format) || (isVirtualSettlement ? 'symbol_first' : tempOrder.currency_format) || 'symbol_first')
|
|
1817
|
+
};
|
|
1818
|
+
if (JSON.stringify(tempOrder.metadata.legal_currency_snapshot || {}) !== JSON.stringify(legalCurrencySnapshot)) {
|
|
1819
|
+
tempOrder.metadata.legal_currency_snapshot = legalCurrencySnapshot;
|
|
1820
|
+
isChanged = true;
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
if (!isVirtualSettlement && currencyCode !== undefined) {
|
|
1789
1824
|
var nextCurrencyCode = String(currencyCode || '');
|
|
1790
1825
|
if (tempOrder.currency_code !== nextCurrencyCode) {
|
|
1791
1826
|
tempOrder.currency_code = nextCurrencyCode;
|
|
1792
1827
|
isChanged = true;
|
|
1793
1828
|
}
|
|
1794
1829
|
}
|
|
1795
|
-
if (currencySymbol !== undefined) {
|
|
1830
|
+
if (!isVirtualSettlement && currencySymbol !== undefined) {
|
|
1796
1831
|
var nextCurrencySymbol = String(currencySymbol || '');
|
|
1797
1832
|
if (tempOrder.currency_symbol !== nextCurrencySymbol) {
|
|
1798
1833
|
tempOrder.currency_symbol = nextCurrencySymbol;
|
|
@@ -1805,11 +1840,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1805
1840
|
key: "initialize",
|
|
1806
1841
|
value: function () {
|
|
1807
1842
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(core) {
|
|
1808
|
-
var _this$
|
|
1843
|
+
var _this$otherParams12,
|
|
1809
1844
|
_this$appPlugin2,
|
|
1810
1845
|
_this$appPlugin2$getA,
|
|
1811
1846
|
_this11 = this,
|
|
1812
|
-
_this$
|
|
1847
|
+
_this$otherParams13;
|
|
1813
1848
|
var options,
|
|
1814
1849
|
app,
|
|
1815
1850
|
targetCacheData,
|
|
@@ -1824,7 +1859,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1824
1859
|
this.paymentNumberDevicePrefix = null;
|
|
1825
1860
|
// this.store = { ...this.store, ...(options.store as Partial<BaseSalesState>) };
|
|
1826
1861
|
this.otherParams = options.otherParams || {};
|
|
1827
|
-
this.cacheId = (_this$
|
|
1862
|
+
this.cacheId = (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.cacheId;
|
|
1828
1863
|
this.reusedSharedSubModuleNames.clear();
|
|
1829
1864
|
this.window = core.getPlugin('window');
|
|
1830
1865
|
this.request = core.getPlugin('request');
|
|
@@ -1866,7 +1901,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1866
1901
|
_context12.next = 19;
|
|
1867
1902
|
return this.store.schedule.loadAllSchedule();
|
|
1868
1903
|
case 19:
|
|
1869
|
-
if (this.store.order && typeof ((_this$
|
|
1904
|
+
if (this.store.order && typeof ((_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.enableTempOrderPersist) === 'boolean') {
|
|
1870
1905
|
this.store.order.setEnableTempOrderPersist(this.otherParams.enableTempOrderPersist);
|
|
1871
1906
|
}
|
|
1872
1907
|
_context12.next = 22;
|
|
@@ -1938,7 +1973,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1938
1973
|
key: "loadSalesDetail",
|
|
1939
1974
|
value: (function () {
|
|
1940
1975
|
var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(orderIdOrParams) {
|
|
1941
|
-
var loadSequence,
|
|
1976
|
+
var loadSequence, _ref35, _ref36, _ref37, _ref38, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, loadedSalesDetail, shouldFilterPendingPayments, remoteRecord, mergeSourceRecord, currentTempOrder, mergedRecord, record;
|
|
1942
1977
|
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1943
1978
|
while (1) switch (_context14.prev = _context14.next) {
|
|
1944
1979
|
case 0:
|
|
@@ -1956,7 +1991,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1956
1991
|
};
|
|
1957
1992
|
externalSaleNumber = params.externalSaleNumber || params.external_sale_number;
|
|
1958
1993
|
preloadedSalesDetail = params.preloadedSalesDetail;
|
|
1959
|
-
lookup = (
|
|
1994
|
+
lookup = (_ref35 = (_ref36 = (_ref37 = (_ref38 = (_params$orderId = params.orderId) !== null && _params$orderId !== void 0 ? _params$orderId : externalSaleNumber) !== null && _ref38 !== void 0 ? _ref38 : params.orderNumber) !== null && _ref37 !== void 0 ? _ref37 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_id) !== null && _ref36 !== void 0 ? _ref36 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.external_sale_number) !== null && _ref35 !== void 0 ? _ref35 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_number;
|
|
1960
1995
|
if (!(!preloadedSalesDetail && (lookup === undefined || lookup === null || lookup === ''))) {
|
|
1961
1996
|
_context14.next = 11;
|
|
1962
1997
|
break;
|
|
@@ -2526,6 +2561,46 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2526
2561
|
return _clearOrderCartLines.apply(this, arguments);
|
|
2527
2562
|
}
|
|
2528
2563
|
return clearOrderCartLines;
|
|
2564
|
+
}() /** 切换法币 / WalletPass 单位时清空商品、折扣与支付状态,保留客户。 */)
|
|
2565
|
+
}, {
|
|
2566
|
+
key: "clearOrderForSettlementSwitch",
|
|
2567
|
+
value: (function () {
|
|
2568
|
+
var _clearOrderForSettlementSwitch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
2569
|
+
var tempOrder;
|
|
2570
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
2571
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
2572
|
+
case 0:
|
|
2573
|
+
if (this.store.order) {
|
|
2574
|
+
_context23.next = 2;
|
|
2575
|
+
break;
|
|
2576
|
+
}
|
|
2577
|
+
throw new Error('order 模块未初始化');
|
|
2578
|
+
case 2:
|
|
2579
|
+
_context23.next = 4;
|
|
2580
|
+
return this.store.order.clearOrderForSettlementSwitch();
|
|
2581
|
+
case 4:
|
|
2582
|
+
tempOrder = _context23.sent;
|
|
2583
|
+
if (this.currentSalesDetail) {
|
|
2584
|
+
this.currentSalesDetail = _objectSpread(_objectSpread({}, this.currentSalesDetail), {}, {
|
|
2585
|
+
products: [],
|
|
2586
|
+
bookings: [],
|
|
2587
|
+
rootBooking: null,
|
|
2588
|
+
bookingsByProductUid: {},
|
|
2589
|
+
discount_list: [],
|
|
2590
|
+
payments: []
|
|
2591
|
+
});
|
|
2592
|
+
}
|
|
2593
|
+
return _context23.abrupt("return", tempOrder);
|
|
2594
|
+
case 7:
|
|
2595
|
+
case "end":
|
|
2596
|
+
return _context23.stop();
|
|
2597
|
+
}
|
|
2598
|
+
}, _callee23, this);
|
|
2599
|
+
}));
|
|
2600
|
+
function clearOrderForSettlementSwitch() {
|
|
2601
|
+
return _clearOrderForSettlementSwitch.apply(this, arguments);
|
|
2602
|
+
}
|
|
2603
|
+
return clearOrderForSettlementSwitch;
|
|
2529
2604
|
}())
|
|
2530
2605
|
}, {
|
|
2531
2606
|
key: "getOrderProducts",
|
|
@@ -2537,32 +2612,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2537
2612
|
}, {
|
|
2538
2613
|
key: "getSummary",
|
|
2539
2614
|
value: function () {
|
|
2540
|
-
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2615
|
+
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
2541
2616
|
var summary;
|
|
2542
|
-
return _regeneratorRuntime().wrap(function
|
|
2543
|
-
while (1) switch (
|
|
2617
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
2618
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
2544
2619
|
case 0:
|
|
2545
|
-
|
|
2620
|
+
_context24.prev = 0;
|
|
2546
2621
|
if (this.store.order) {
|
|
2547
|
-
|
|
2622
|
+
_context24.next = 3;
|
|
2548
2623
|
break;
|
|
2549
2624
|
}
|
|
2550
2625
|
throw new Error('order 模块未初始化');
|
|
2551
2626
|
case 3:
|
|
2552
|
-
|
|
2627
|
+
_context24.next = 5;
|
|
2553
2628
|
return this.store.order.getOrderSummary();
|
|
2554
2629
|
case 5:
|
|
2555
|
-
summary =
|
|
2556
|
-
return
|
|
2630
|
+
summary = _context24.sent;
|
|
2631
|
+
return _context24.abrupt("return", summary);
|
|
2557
2632
|
case 9:
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
throw
|
|
2633
|
+
_context24.prev = 9;
|
|
2634
|
+
_context24.t0 = _context24["catch"](0);
|
|
2635
|
+
throw _context24.t0;
|
|
2561
2636
|
case 12:
|
|
2562
2637
|
case "end":
|
|
2563
|
-
return
|
|
2638
|
+
return _context24.stop();
|
|
2564
2639
|
}
|
|
2565
|
-
},
|
|
2640
|
+
}, _callee24, this, [[0, 9]]);
|
|
2566
2641
|
}));
|
|
2567
2642
|
function getSummary() {
|
|
2568
2643
|
return _getSummary.apply(this, arguments);
|
|
@@ -2690,14 +2765,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2690
2765
|
}, {
|
|
2691
2766
|
key: "loadDiscountConfig",
|
|
2692
2767
|
value: function () {
|
|
2693
|
-
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2768
|
+
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
|
|
2694
2769
|
var _this$getOrderIdentit, _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _discountModule$getDi, _discountModule$getOr, _discountModule$getDi2;
|
|
2695
|
-
var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, discountConfigCacheKey, preparedDiscountList, _discountModule$setOr, nextDiscountList, shouldSkipAutoApplyFetchedDiscounts, _summary, _orderStore$summary, orderTotalAmount, result, _iterator3, _step3, _product$metadata5, _tempOrder$_extend3, _product$metadata$sou, _product$metadata6, _product$metadata7, _product$original_pri, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice, summary;
|
|
2696
|
-
return _regeneratorRuntime().wrap(function
|
|
2697
|
-
while (1) switch (
|
|
2770
|
+
var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, discountConfigCacheKey, preparedDiscountList, _discountModule$setOr, _discountModule$setOr2, _discountModule$setDi, nextDiscountList, shouldSkipAutoApplyFetchedDiscounts, _summary, _orderStore$summary, orderTotalAmount, result, _iterator3, _step3, _product$metadata5, _tempOrder$_extend3, _product$metadata$sou, _product$metadata6, _product$metadata7, _product$original_pri, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice, summary;
|
|
2771
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
2772
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
2698
2773
|
case 0:
|
|
2699
2774
|
if (this.store.order) {
|
|
2700
|
-
|
|
2775
|
+
_context25.next = 2;
|
|
2701
2776
|
break;
|
|
2702
2777
|
}
|
|
2703
2778
|
throw new Error('order 模块未初始化');
|
|
@@ -2717,18 +2792,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2717
2792
|
discountConfigCacheKey = [customerId, discountAction, Number(orderId) || 0].join(':');
|
|
2718
2793
|
preparedDiscountList = [];
|
|
2719
2794
|
if (!(customerId && customerId !== 1)) {
|
|
2720
|
-
|
|
2795
|
+
_context25.next = 25;
|
|
2721
2796
|
break;
|
|
2722
2797
|
}
|
|
2723
|
-
if (!(this.discountConfigCacheKey === discountConfigCacheKey)) {
|
|
2724
|
-
|
|
2798
|
+
if (!(!(params !== null && params !== void 0 && params.force) && this.discountConfigCacheKey === discountConfigCacheKey)) {
|
|
2799
|
+
_context25.next = 19;
|
|
2725
2800
|
break;
|
|
2726
2801
|
}
|
|
2727
2802
|
preparedDiscountList = originalDiscountList;
|
|
2728
|
-
|
|
2803
|
+
_context25.next = 25;
|
|
2729
2804
|
break;
|
|
2730
2805
|
case 19:
|
|
2731
|
-
|
|
2806
|
+
_context25.next = 21;
|
|
2732
2807
|
return this.store.order.loadDiscountConfig({
|
|
2733
2808
|
customerId: customerId,
|
|
2734
2809
|
action: discountAction,
|
|
@@ -2736,26 +2811,46 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2736
2811
|
apply: false
|
|
2737
2812
|
});
|
|
2738
2813
|
case 21:
|
|
2739
|
-
preparedDiscountList =
|
|
2814
|
+
preparedDiscountList = _context25.sent;
|
|
2740
2815
|
this.discountConfigCacheKey = discountConfigCacheKey;
|
|
2741
|
-
|
|
2816
|
+
_context25.next = 25;
|
|
2742
2817
|
return discountModule === null || discountModule === void 0 || (_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, preparedDiscountList);
|
|
2743
2818
|
case 25:
|
|
2819
|
+
if (!this.isActiveVirtualSettlementOrder(tempOrder)) {
|
|
2820
|
+
_context25.next = 33;
|
|
2821
|
+
break;
|
|
2822
|
+
}
|
|
2823
|
+
_context25.next = 28;
|
|
2824
|
+
return discountModule === null || discountModule === void 0 || (_discountModule$setOr2 = discountModule.setOriginalDiscountList) === null || _discountModule$setOr2 === void 0 ? void 0 : _discountModule$setOr2.call(discountModule, []);
|
|
2825
|
+
case 28:
|
|
2826
|
+
_context25.next = 30;
|
|
2827
|
+
return discountModule === null || discountModule === void 0 || (_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, []);
|
|
2828
|
+
case 30:
|
|
2829
|
+
tempOrder.discount_list = [];
|
|
2830
|
+
tempOrder.shop_discount = '0.00';
|
|
2831
|
+
return _context25.abrupt("return", {
|
|
2832
|
+
productList: tempOrder.products || [],
|
|
2833
|
+
discountList: [],
|
|
2834
|
+
availableWalletIds: this.getAvailableWalletIds(),
|
|
2835
|
+
virtualCurrencyList: this.store.order.getVirtualCurrencyList()
|
|
2836
|
+
});
|
|
2837
|
+
case 33:
|
|
2744
2838
|
if (!(hasManualDiscountSelection && currentDiscountList.length)) {
|
|
2745
|
-
|
|
2839
|
+
_context25.next = 35;
|
|
2746
2840
|
break;
|
|
2747
2841
|
}
|
|
2748
|
-
return
|
|
2842
|
+
return _context25.abrupt("return", {
|
|
2749
2843
|
productList: tempOrder.products || [],
|
|
2750
2844
|
discountList: currentDiscountList,
|
|
2751
|
-
availableWalletIds: this.getAvailableWalletIds()
|
|
2845
|
+
availableWalletIds: this.getAvailableWalletIds(),
|
|
2846
|
+
virtualCurrencyList: this.store.order.getVirtualCurrencyList()
|
|
2752
2847
|
});
|
|
2753
|
-
case
|
|
2848
|
+
case 35:
|
|
2754
2849
|
nextDiscountList = this.mergeHistoricalDiscountList(preparedDiscountList || (discountModule === null || discountModule === void 0 || (_discountModule$getDi2 = discountModule.getDiscountList) === null || _discountModule$getDi2 === void 0 ? void 0 : _discountModule$getDi2.call(discountModule)) || [], tempOrder.products || []);
|
|
2755
2850
|
nextDiscountList = this.mergeCurrentDiscountSelectionState(nextDiscountList, currentDiscountList);
|
|
2756
|
-
|
|
2851
|
+
_context25.next = 39;
|
|
2757
2852
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
2758
|
-
case
|
|
2853
|
+
case 39:
|
|
2759
2854
|
shouldSkipAutoApplyFetchedDiscounts = this.shouldSkipAutoApplyFetchedDiscountsInEditMode({
|
|
2760
2855
|
discountAction: discountAction,
|
|
2761
2856
|
products: tempOrder.products || [],
|
|
@@ -2763,32 +2858,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2763
2858
|
nextDiscountList: nextDiscountList
|
|
2764
2859
|
});
|
|
2765
2860
|
if (!shouldSkipAutoApplyFetchedDiscounts) {
|
|
2766
|
-
|
|
2861
|
+
_context25.next = 48;
|
|
2767
2862
|
break;
|
|
2768
2863
|
}
|
|
2769
|
-
|
|
2864
|
+
_context25.next = 43;
|
|
2770
2865
|
return this.store.order.recalculateSummary({
|
|
2771
2866
|
createIfMissing: true
|
|
2772
2867
|
});
|
|
2773
|
-
case
|
|
2774
|
-
_summary =
|
|
2868
|
+
case 43:
|
|
2869
|
+
_summary = _context25.sent;
|
|
2775
2870
|
this.store.order.persistTempOrder();
|
|
2776
|
-
|
|
2871
|
+
_context25.next = 47;
|
|
2777
2872
|
return this.effectsEmit('onDiscountApplied', {
|
|
2778
2873
|
productList: tempOrder.products || [],
|
|
2779
2874
|
discountList: nextDiscountList,
|
|
2780
2875
|
selectedDiscountList: tempOrder.discount_list || [],
|
|
2781
2876
|
tempOrder: tempOrder
|
|
2782
2877
|
});
|
|
2783
|
-
case
|
|
2784
|
-
return
|
|
2878
|
+
case 47:
|
|
2879
|
+
return _context25.abrupt("return", {
|
|
2785
2880
|
productList: tempOrder.products || [],
|
|
2786
2881
|
discountList: nextDiscountList,
|
|
2787
|
-
availableWalletIds: this.getAvailableWalletIds()
|
|
2882
|
+
availableWalletIds: this.getAvailableWalletIds(),
|
|
2883
|
+
virtualCurrencyList: this.store.order.getVirtualCurrencyList()
|
|
2788
2884
|
});
|
|
2789
|
-
case
|
|
2885
|
+
case 48:
|
|
2790
2886
|
if (!rulesModule) {
|
|
2791
|
-
|
|
2887
|
+
_context25.next = 84;
|
|
2792
2888
|
break;
|
|
2793
2889
|
}
|
|
2794
2890
|
orderTotalAmount = Number(((_orderStore$summary = orderStore.summary) === null || _orderStore$summary === void 0 ? void 0 : _orderStore$summary.total_amount) || 0);
|
|
@@ -2808,22 +2904,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2808
2904
|
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
2809
2905
|
}
|
|
2810
2906
|
_iterator3 = _createForOfIteratorHelper(tempOrder.products || []);
|
|
2811
|
-
|
|
2907
|
+
_context25.prev = 53;
|
|
2812
2908
|
_iterator3.s();
|
|
2813
|
-
case
|
|
2909
|
+
case 55:
|
|
2814
2910
|
if ((_step3 = _iterator3.n()).done) {
|
|
2815
|
-
|
|
2911
|
+
_context25.next = 70;
|
|
2816
2912
|
break;
|
|
2817
2913
|
}
|
|
2818
2914
|
product = _step3.value;
|
|
2819
2915
|
productUid = (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number;
|
|
2820
2916
|
runtimeOrigin = productUid ? (_tempOrder$_extend3 = tempOrder._extend) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3.productsByUid) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3[productUid]) === null || _tempOrder$_extend3 === void 0 ? void 0 : _tempOrder$_extend3.origin : undefined;
|
|
2821
2917
|
if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
|
|
2822
|
-
|
|
2918
|
+
_context25.next = 61;
|
|
2823
2919
|
break;
|
|
2824
2920
|
}
|
|
2825
|
-
return
|
|
2826
|
-
case
|
|
2921
|
+
return _context25.abrupt("continue", 68);
|
|
2922
|
+
case 61:
|
|
2827
2923
|
totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
|
|
2828
2924
|
return sum + Number(pd.amount || 0);
|
|
2829
2925
|
}, 0);
|
|
@@ -2839,59 +2935,60 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2839
2935
|
mainPrice: newMainSellingPrice,
|
|
2840
2936
|
bundle: product.product_bundle
|
|
2841
2937
|
});
|
|
2842
|
-
case
|
|
2843
|
-
|
|
2938
|
+
case 68:
|
|
2939
|
+
_context25.next = 55;
|
|
2844
2940
|
break;
|
|
2845
|
-
case
|
|
2846
|
-
|
|
2941
|
+
case 70:
|
|
2942
|
+
_context25.next = 75;
|
|
2847
2943
|
break;
|
|
2848
|
-
case
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
_iterator3.e(
|
|
2852
|
-
case
|
|
2853
|
-
|
|
2944
|
+
case 72:
|
|
2945
|
+
_context25.prev = 72;
|
|
2946
|
+
_context25.t0 = _context25["catch"](53);
|
|
2947
|
+
_iterator3.e(_context25.t0);
|
|
2948
|
+
case 75:
|
|
2949
|
+
_context25.prev = 75;
|
|
2854
2950
|
_iterator3.f();
|
|
2855
|
-
return
|
|
2856
|
-
case
|
|
2951
|
+
return _context25.finish(75);
|
|
2952
|
+
case 78:
|
|
2857
2953
|
if (!result.discountList) {
|
|
2858
|
-
|
|
2954
|
+
_context25.next = 84;
|
|
2859
2955
|
break;
|
|
2860
2956
|
}
|
|
2861
2957
|
nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
|
|
2862
2958
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
2863
|
-
|
|
2959
|
+
_context25.next = 83;
|
|
2864
2960
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
2865
|
-
case
|
|
2961
|
+
case 83:
|
|
2866
2962
|
tempOrder.discount_list = nextDiscountList.filter(function (discount) {
|
|
2867
2963
|
return discount.isSelected;
|
|
2868
2964
|
});
|
|
2869
|
-
case
|
|
2870
|
-
|
|
2965
|
+
case 84:
|
|
2966
|
+
_context25.next = 86;
|
|
2871
2967
|
return this.store.order.recalculateSummary({
|
|
2872
2968
|
createIfMissing: true
|
|
2873
2969
|
});
|
|
2874
|
-
case
|
|
2875
|
-
summary =
|
|
2970
|
+
case 86:
|
|
2971
|
+
summary = _context25.sent;
|
|
2876
2972
|
this.store.order.persistTempOrder();
|
|
2877
|
-
|
|
2973
|
+
_context25.next = 90;
|
|
2878
2974
|
return this.effectsEmit('onDiscountApplied', {
|
|
2879
2975
|
productList: tempOrder.products || [],
|
|
2880
2976
|
discountList: nextDiscountList,
|
|
2881
2977
|
selectedDiscountList: tempOrder.discount_list || [],
|
|
2882
2978
|
tempOrder: tempOrder
|
|
2883
2979
|
});
|
|
2884
|
-
case
|
|
2885
|
-
return
|
|
2980
|
+
case 90:
|
|
2981
|
+
return _context25.abrupt("return", {
|
|
2886
2982
|
productList: tempOrder.products || [],
|
|
2887
2983
|
discountList: nextDiscountList,
|
|
2888
|
-
availableWalletIds: this.getAvailableWalletIds()
|
|
2984
|
+
availableWalletIds: this.getAvailableWalletIds(),
|
|
2985
|
+
virtualCurrencyList: this.store.order.getVirtualCurrencyList()
|
|
2889
2986
|
});
|
|
2890
|
-
case
|
|
2987
|
+
case 91:
|
|
2891
2988
|
case "end":
|
|
2892
|
-
return
|
|
2989
|
+
return _context25.stop();
|
|
2893
2990
|
}
|
|
2894
|
-
},
|
|
2991
|
+
}, _callee25, this, [[53, 72, 75, 78]]);
|
|
2895
2992
|
}));
|
|
2896
2993
|
function loadDiscountConfig(_x17) {
|
|
2897
2994
|
return _loadDiscountConfig.apply(this, arguments);
|
|
@@ -2905,22 +3002,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2905
3002
|
if (!((_this$store$order4 = this.store.order) !== null && _this$store$order4 !== void 0 && _this$store$order4.getAvailableWalletIds)) return [];
|
|
2906
3003
|
return this.store.order.getAvailableWalletIds();
|
|
2907
3004
|
}
|
|
3005
|
+
}, {
|
|
3006
|
+
key: "getVirtualCurrencyList",
|
|
3007
|
+
value: function getVirtualCurrencyList() {
|
|
3008
|
+
var _this$store$order5;
|
|
3009
|
+
if (!((_this$store$order5 = this.store.order) !== null && _this$store$order5 !== void 0 && _this$store$order5.getVirtualCurrencyList)) return [];
|
|
3010
|
+
return this.store.order.getVirtualCurrencyList();
|
|
3011
|
+
}
|
|
2908
3012
|
}, {
|
|
2909
3013
|
key: "bestDiscount",
|
|
2910
3014
|
value: function () {
|
|
2911
|
-
var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3015
|
+
var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(cb) {
|
|
2912
3016
|
var _discountModule$getOr2, _discountModule$getDi3;
|
|
2913
|
-
var tempOrder, orderStore, discountModule, rulesModule, originalDiscountList, currentDiscountList, nextDiscountList, result, _orderStore$summary2, orderTotalAmount;
|
|
2914
|
-
return _regeneratorRuntime().wrap(function
|
|
2915
|
-
while (1) switch (
|
|
3017
|
+
var tempOrder, _result2, orderStore, discountModule, rulesModule, originalDiscountList, currentDiscountList, nextDiscountList, result, _orderStore$summary2, orderTotalAmount;
|
|
3018
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
3019
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
2916
3020
|
case 0:
|
|
2917
3021
|
if (this.store.order) {
|
|
2918
|
-
|
|
3022
|
+
_context26.next = 2;
|
|
2919
3023
|
break;
|
|
2920
3024
|
}
|
|
2921
3025
|
throw new Error('order 模块未初始化');
|
|
2922
3026
|
case 2:
|
|
2923
3027
|
tempOrder = this.store.order.ensureTempOrder();
|
|
3028
|
+
if (!this.isActiveVirtualSettlementOrder(tempOrder)) {
|
|
3029
|
+
_context26.next = 7;
|
|
3030
|
+
break;
|
|
3031
|
+
}
|
|
3032
|
+
_result2 = {
|
|
3033
|
+
productList: tempOrder.products || [],
|
|
3034
|
+
discountList: []
|
|
3035
|
+
};
|
|
3036
|
+
cb === null || cb === void 0 || cb(_result2);
|
|
3037
|
+
return _context26.abrupt("return", _result2);
|
|
3038
|
+
case 7:
|
|
2924
3039
|
orderStore = this.store.order.store || {};
|
|
2925
3040
|
discountModule = orderStore.discount;
|
|
2926
3041
|
rulesModule = orderStore.rules;
|
|
@@ -2931,11 +3046,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2931
3046
|
productList: tempOrder.products || [],
|
|
2932
3047
|
discountList: nextDiscountList
|
|
2933
3048
|
};
|
|
2934
|
-
|
|
3049
|
+
_context26.next = 16;
|
|
2935
3050
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
2936
|
-
case
|
|
3051
|
+
case 16:
|
|
2937
3052
|
if (!rulesModule) {
|
|
2938
|
-
|
|
3053
|
+
_context26.next = 27;
|
|
2939
3054
|
break;
|
|
2940
3055
|
}
|
|
2941
3056
|
orderTotalAmount = Number(((_orderStore$summary2 = orderStore.summary) === null || _orderStore$summary2 === void 0 ? void 0 : _orderStore$summary2.total_amount) || 0);
|
|
@@ -2952,14 +3067,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2952
3067
|
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
2953
3068
|
}
|
|
2954
3069
|
if (!result.discountList) {
|
|
2955
|
-
|
|
3070
|
+
_context26.next = 27;
|
|
2956
3071
|
break;
|
|
2957
3072
|
}
|
|
2958
3073
|
nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
|
|
2959
3074
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
2960
|
-
|
|
3075
|
+
_context26.next = 25;
|
|
2961
3076
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
2962
|
-
case
|
|
3077
|
+
case 25:
|
|
2963
3078
|
tempOrder.discount_list = nextDiscountList.filter(function (discount) {
|
|
2964
3079
|
return discount.isSelected;
|
|
2965
3080
|
});
|
|
@@ -2967,28 +3082,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2967
3082
|
productList: tempOrder.products,
|
|
2968
3083
|
discountList: nextDiscountList
|
|
2969
3084
|
};
|
|
2970
|
-
case
|
|
2971
|
-
|
|
3085
|
+
case 27:
|
|
3086
|
+
_context26.next = 29;
|
|
2972
3087
|
return this.store.order.recalculateSummary({
|
|
2973
3088
|
createIfMissing: true
|
|
2974
3089
|
});
|
|
2975
|
-
case
|
|
3090
|
+
case 29:
|
|
2976
3091
|
this.store.order.persistTempOrder();
|
|
2977
|
-
|
|
3092
|
+
_context26.next = 32;
|
|
2978
3093
|
return this.effectsEmit('onDiscountApplied', {
|
|
2979
3094
|
productList: tempOrder.products || [],
|
|
2980
3095
|
discountList: nextDiscountList,
|
|
2981
3096
|
selectedDiscountList: tempOrder.discount_list || [],
|
|
2982
3097
|
tempOrder: tempOrder
|
|
2983
3098
|
});
|
|
2984
|
-
case
|
|
3099
|
+
case 32:
|
|
2985
3100
|
cb === null || cb === void 0 || cb(result);
|
|
2986
|
-
return
|
|
2987
|
-
case
|
|
3101
|
+
return _context26.abrupt("return", result);
|
|
3102
|
+
case 34:
|
|
2988
3103
|
case "end":
|
|
2989
|
-
return
|
|
3104
|
+
return _context26.stop();
|
|
2990
3105
|
}
|
|
2991
|
-
},
|
|
3106
|
+
}, _callee26, this);
|
|
2992
3107
|
}));
|
|
2993
3108
|
function bestDiscount(_x18) {
|
|
2994
3109
|
return _bestDiscount.apply(this, arguments);
|
|
@@ -3019,39 +3134,39 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3019
3134
|
}, {
|
|
3020
3135
|
key: "replaceDiscountStoreLists",
|
|
3021
3136
|
value: (function () {
|
|
3022
|
-
var _replaceDiscountStoreLists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3137
|
+
var _replaceDiscountStoreLists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
|
|
3023
3138
|
var _store2;
|
|
3024
3139
|
var discountModule;
|
|
3025
|
-
return _regeneratorRuntime().wrap(function
|
|
3026
|
-
while (1) switch (
|
|
3140
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
3141
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
3027
3142
|
case 0:
|
|
3028
3143
|
if (this.store.order) {
|
|
3029
|
-
|
|
3144
|
+
_context27.next = 2;
|
|
3030
3145
|
break;
|
|
3031
3146
|
}
|
|
3032
3147
|
throw new Error('order 模块未初始化');
|
|
3033
3148
|
case 2:
|
|
3034
3149
|
discountModule = (_store2 = this.store.order.store) === null || _store2 === void 0 ? void 0 : _store2.discount;
|
|
3035
3150
|
if (discountModule) {
|
|
3036
|
-
|
|
3151
|
+
_context27.next = 5;
|
|
3037
3152
|
break;
|
|
3038
3153
|
}
|
|
3039
|
-
return
|
|
3154
|
+
return _context27.abrupt("return");
|
|
3040
3155
|
case 5:
|
|
3041
3156
|
if (!params.originalDiscountList) {
|
|
3042
|
-
|
|
3157
|
+
_context27.next = 8;
|
|
3043
3158
|
break;
|
|
3044
3159
|
}
|
|
3045
|
-
|
|
3160
|
+
_context27.next = 8;
|
|
3046
3161
|
return discountModule.setOriginalDiscountList(params.originalDiscountList);
|
|
3047
3162
|
case 8:
|
|
3048
|
-
|
|
3163
|
+
_context27.next = 10;
|
|
3049
3164
|
return discountModule.setDiscountList(params.discountList);
|
|
3050
3165
|
case 10:
|
|
3051
3166
|
case "end":
|
|
3052
|
-
return
|
|
3167
|
+
return _context27.stop();
|
|
3053
3168
|
}
|
|
3054
|
-
},
|
|
3169
|
+
}, _callee27, this);
|
|
3055
3170
|
}));
|
|
3056
3171
|
function replaceDiscountStoreLists(_x19) {
|
|
3057
3172
|
return _replaceDiscountStoreLists.apply(this, arguments);
|
|
@@ -3061,34 +3176,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3061
3176
|
}, {
|
|
3062
3177
|
key: "scanPromotionCode",
|
|
3063
3178
|
value: function () {
|
|
3064
|
-
var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3179
|
+
var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(code, customerId) {
|
|
3065
3180
|
var raw, tempOrder;
|
|
3066
|
-
return _regeneratorRuntime().wrap(function
|
|
3067
|
-
while (1) switch (
|
|
3181
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
3182
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
3068
3183
|
case 0:
|
|
3069
|
-
|
|
3184
|
+
_context28.prev = 0;
|
|
3070
3185
|
if (this.store.order) {
|
|
3071
|
-
|
|
3186
|
+
_context28.next = 3;
|
|
3072
3187
|
break;
|
|
3073
3188
|
}
|
|
3074
3189
|
throw new Error('order 模块未初始化');
|
|
3075
3190
|
case 3:
|
|
3076
|
-
|
|
3191
|
+
_context28.next = 5;
|
|
3077
3192
|
return this.store.order.scanCode(code, customerId);
|
|
3078
3193
|
case 5:
|
|
3079
|
-
raw =
|
|
3194
|
+
raw = _context28.sent;
|
|
3080
3195
|
if (!raw.isAvailable) {
|
|
3081
|
-
|
|
3196
|
+
_context28.next = 13;
|
|
3082
3197
|
break;
|
|
3083
3198
|
}
|
|
3084
|
-
|
|
3199
|
+
_context28.next = 9;
|
|
3085
3200
|
return this.store.order.recalculateSummary({
|
|
3086
3201
|
createIfMissing: true
|
|
3087
3202
|
});
|
|
3088
3203
|
case 9:
|
|
3089
3204
|
this.store.order.persistTempOrder();
|
|
3090
3205
|
tempOrder = this.store.order.ensureTempOrder();
|
|
3091
|
-
|
|
3206
|
+
_context28.next = 13;
|
|
3092
3207
|
return this.effectsEmit('onDiscountApplied', {
|
|
3093
3208
|
productList: tempOrder.products || [],
|
|
3094
3209
|
discountList: this.store.order.getDiscountList(),
|
|
@@ -3096,7 +3211,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3096
3211
|
tempOrder: tempOrder
|
|
3097
3212
|
});
|
|
3098
3213
|
case 13:
|
|
3099
|
-
return
|
|
3214
|
+
return _context28.abrupt("return", _objectSpread(_objectSpread({
|
|
3100
3215
|
isAvailable: raw.isAvailable
|
|
3101
3216
|
}, raw.isAccepted !== undefined ? {
|
|
3102
3217
|
isAccepted: raw.isAccepted
|
|
@@ -3106,14 +3221,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3106
3221
|
scannedDiscountList: raw.scannedDiscountList
|
|
3107
3222
|
}));
|
|
3108
3223
|
case 16:
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
throw
|
|
3224
|
+
_context28.prev = 16;
|
|
3225
|
+
_context28.t0 = _context28["catch"](0);
|
|
3226
|
+
throw _context28.t0;
|
|
3112
3227
|
case 19:
|
|
3113
3228
|
case "end":
|
|
3114
|
-
return
|
|
3229
|
+
return _context28.stop();
|
|
3115
3230
|
}
|
|
3116
|
-
},
|
|
3231
|
+
}, _callee28, this, [[0, 16]]);
|
|
3117
3232
|
}));
|
|
3118
3233
|
function scanPromotionCode(_x20, _x21) {
|
|
3119
3234
|
return _scanPromotionCode.apply(this, arguments);
|
|
@@ -3123,18 +3238,36 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3123
3238
|
}, {
|
|
3124
3239
|
key: "setDiscountSelected",
|
|
3125
3240
|
value: function () {
|
|
3126
|
-
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3127
|
-
var list, updated, tempOrder, orderStore, discountModule, rulesModule, nextDiscountList, _orderStore$summary3, orderTotalAmount, result, beforeSelectedIds, _iterator4, _step4, d, selectedResourceIds, filterSelectedDiscountDetails, _iterator5, _step5, _product$metadata8, _tempOrder$_extend4, _product$metadata$sou2, _product$metadata9, _product$metadata10, _product$original_pri2, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
|
|
3128
|
-
return _regeneratorRuntime().wrap(function
|
|
3129
|
-
while (1) switch (
|
|
3241
|
+
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
|
|
3242
|
+
var currentOrder, _store3, _store3$setDiscountLi, list, updated, tempOrder, orderStore, discountModule, rulesModule, nextDiscountList, _orderStore$summary3, orderTotalAmount, result, beforeSelectedIds, _iterator4, _step4, d, selectedResourceIds, filterSelectedDiscountDetails, _iterator5, _step5, _product$metadata8, _tempOrder$_extend4, _product$metadata$sou2, _product$metadata9, _product$metadata10, _product$original_pri2, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
|
|
3243
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
3244
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
3130
3245
|
case 0:
|
|
3131
|
-
|
|
3246
|
+
_context29.prev = 0;
|
|
3132
3247
|
if (this.store.order) {
|
|
3133
|
-
|
|
3248
|
+
_context29.next = 3;
|
|
3134
3249
|
break;
|
|
3135
3250
|
}
|
|
3136
3251
|
throw new Error('order 模块未初始化');
|
|
3137
3252
|
case 3:
|
|
3253
|
+
currentOrder = this.store.order.ensureTempOrder();
|
|
3254
|
+
if (!this.isActiveVirtualSettlementOrder(currentOrder)) {
|
|
3255
|
+
_context29.next = 13;
|
|
3256
|
+
break;
|
|
3257
|
+
}
|
|
3258
|
+
currentOrder.discount_list = [];
|
|
3259
|
+
currentOrder.shop_discount = '0.00';
|
|
3260
|
+
_context29.next = 9;
|
|
3261
|
+
return (_store3 = this.store.order.store) === null || _store3 === void 0 || (_store3 = _store3.discount) === null || _store3 === void 0 || (_store3$setDiscountLi = _store3.setDiscountList) === null || _store3$setDiscountLi === void 0 ? void 0 : _store3$setDiscountLi.call(_store3, []);
|
|
3262
|
+
case 9:
|
|
3263
|
+
_context29.next = 11;
|
|
3264
|
+
return this.store.order.recalculateSummary({
|
|
3265
|
+
createIfMissing: true
|
|
3266
|
+
});
|
|
3267
|
+
case 11:
|
|
3268
|
+
this.store.order.persistTempOrder();
|
|
3269
|
+
return _context29.abrupt("return");
|
|
3270
|
+
case 13:
|
|
3138
3271
|
list = this.store.order.getDiscountList();
|
|
3139
3272
|
updated = list.map(function (d) {
|
|
3140
3273
|
return d.id === params.discountId && !isBaseSalesHistoricalDiscountEntry(d) ? _objectSpread(_objectSpread({}, d), {}, {
|
|
@@ -3148,9 +3281,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3148
3281
|
discountModule = orderStore.discount;
|
|
3149
3282
|
rulesModule = orderStore.rules;
|
|
3150
3283
|
nextDiscountList = updated;
|
|
3151
|
-
|
|
3284
|
+
_context29.next = 23;
|
|
3152
3285
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(updated);
|
|
3153
|
-
case
|
|
3286
|
+
case 23:
|
|
3154
3287
|
if (rulesModule) {
|
|
3155
3288
|
orderTotalAmount = Number(((_orderStore$summary3 = orderStore.summary) === null || _orderStore$summary3 === void 0 ? void 0 : _orderStore$summary3.total_amount) || 0);
|
|
3156
3289
|
result = rulesModule.calcDiscount({
|
|
@@ -3210,29 +3343,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3210
3343
|
});
|
|
3211
3344
|
};
|
|
3212
3345
|
_iterator5 = _createForOfIteratorHelper(tempOrder.products);
|
|
3213
|
-
|
|
3346
|
+
_context29.prev = 27;
|
|
3214
3347
|
_iterator5.s();
|
|
3215
|
-
case
|
|
3348
|
+
case 29:
|
|
3216
3349
|
if ((_step5 = _iterator5.n()).done) {
|
|
3217
|
-
|
|
3350
|
+
_context29.next = 46;
|
|
3218
3351
|
break;
|
|
3219
3352
|
}
|
|
3220
3353
|
product = _step5.value;
|
|
3221
3354
|
productUid = (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.unique_identification_number;
|
|
3222
3355
|
runtimeOrigin = productUid ? (_tempOrder$_extend4 = tempOrder._extend) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4.productsByUid) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4[productUid]) === null || _tempOrder$_extend4 === void 0 ? void 0 : _tempOrder$_extend4.origin : undefined;
|
|
3223
3356
|
if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
|
|
3224
|
-
|
|
3357
|
+
_context29.next = 35;
|
|
3225
3358
|
break;
|
|
3226
3359
|
}
|
|
3227
|
-
return
|
|
3228
|
-
case
|
|
3360
|
+
return _context29.abrupt("continue", 44);
|
|
3361
|
+
case 35:
|
|
3229
3362
|
product.discount_list = filterSelectedDiscountDetails(product.discount_list);
|
|
3230
3363
|
if (Array.isArray(product.product_bundle)) {
|
|
3231
3364
|
product.product_bundle = product.product_bundle.map(function (bundle) {
|
|
3232
|
-
var
|
|
3365
|
+
var _ref39, _bundle$original_pric;
|
|
3233
3366
|
var nextBundleDiscountList = filterSelectedDiscountDetails(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list);
|
|
3234
3367
|
var shouldRestoreBundlePrice = nextBundleDiscountList.length === 0;
|
|
3235
|
-
var restoredBundlePrice = (
|
|
3368
|
+
var restoredBundlePrice = (_ref39 = (_bundle$original_pric = bundle === null || bundle === void 0 ? void 0 : bundle.original_price) !== null && _bundle$original_pric !== void 0 ? _bundle$original_pric : bundle === null || bundle === void 0 ? void 0 : bundle.product_price) !== null && _ref39 !== void 0 ? _ref39 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
|
|
3236
3369
|
return _objectSpread(_objectSpread(_objectSpread({}, bundle), shouldRestoreBundlePrice ? {
|
|
3237
3370
|
price: restoredBundlePrice,
|
|
3238
3371
|
bundle_selling_price: restoredBundlePrice
|
|
@@ -3259,33 +3392,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3259
3392
|
mainPrice: newMainSellingPrice,
|
|
3260
3393
|
bundle: product.product_bundle
|
|
3261
3394
|
});
|
|
3262
|
-
case
|
|
3263
|
-
|
|
3395
|
+
case 44:
|
|
3396
|
+
_context29.next = 29;
|
|
3264
3397
|
break;
|
|
3265
|
-
case
|
|
3266
|
-
|
|
3398
|
+
case 46:
|
|
3399
|
+
_context29.next = 51;
|
|
3267
3400
|
break;
|
|
3268
|
-
case
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
_iterator5.e(
|
|
3272
|
-
case
|
|
3273
|
-
|
|
3401
|
+
case 48:
|
|
3402
|
+
_context29.prev = 48;
|
|
3403
|
+
_context29.t0 = _context29["catch"](27);
|
|
3404
|
+
_iterator5.e(_context29.t0);
|
|
3405
|
+
case 51:
|
|
3406
|
+
_context29.prev = 51;
|
|
3274
3407
|
_iterator5.f();
|
|
3275
|
-
return
|
|
3276
|
-
case
|
|
3408
|
+
return _context29.finish(51);
|
|
3409
|
+
case 54:
|
|
3277
3410
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
3278
|
-
|
|
3411
|
+
_context29.next = 57;
|
|
3279
3412
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
3280
|
-
case
|
|
3413
|
+
case 57:
|
|
3281
3414
|
tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
|
|
3282
3415
|
return d.isSelected;
|
|
3283
3416
|
});
|
|
3284
|
-
|
|
3417
|
+
_context29.next = 60;
|
|
3285
3418
|
return this.store.order.recalculateSummary({
|
|
3286
3419
|
createIfMissing: true
|
|
3287
3420
|
});
|
|
3288
|
-
case
|
|
3421
|
+
case 60:
|
|
3289
3422
|
this.store.order.persistTempOrder();
|
|
3290
3423
|
this.effectsEmit('onDiscountApplied', {
|
|
3291
3424
|
productList: tempOrder.products,
|
|
@@ -3293,17 +3426,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3293
3426
|
selectedDiscountList: tempOrder.discount_list,
|
|
3294
3427
|
tempOrder: tempOrder
|
|
3295
3428
|
});
|
|
3296
|
-
|
|
3429
|
+
_context29.next = 67;
|
|
3297
3430
|
break;
|
|
3298
|
-
case
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
throw
|
|
3302
|
-
case
|
|
3431
|
+
case 64:
|
|
3432
|
+
_context29.prev = 64;
|
|
3433
|
+
_context29.t1 = _context29["catch"](0);
|
|
3434
|
+
throw _context29.t1;
|
|
3435
|
+
case 67:
|
|
3303
3436
|
case "end":
|
|
3304
|
-
return
|
|
3437
|
+
return _context29.stop();
|
|
3305
3438
|
}
|
|
3306
|
-
},
|
|
3439
|
+
}, _callee29, this, [[0, 64], [27, 48, 51, 54]]);
|
|
3307
3440
|
}));
|
|
3308
3441
|
function setDiscountSelected(_x22) {
|
|
3309
3442
|
return _setDiscountSelected.apply(this, arguments);
|
|
@@ -3313,23 +3446,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3313
3446
|
}, {
|
|
3314
3447
|
key: "applyDiscountCalculationResult",
|
|
3315
3448
|
value: function () {
|
|
3316
|
-
var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3449
|
+
var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(result) {
|
|
3317
3450
|
var tempOrder, orderStore, discountModule;
|
|
3318
|
-
return _regeneratorRuntime().wrap(function
|
|
3319
|
-
while (1) switch (
|
|
3451
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
3452
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
3320
3453
|
case 0:
|
|
3321
|
-
|
|
3454
|
+
_context30.prev = 0;
|
|
3322
3455
|
if (this.store.order) {
|
|
3323
|
-
|
|
3456
|
+
_context30.next = 3;
|
|
3324
3457
|
break;
|
|
3325
3458
|
}
|
|
3326
3459
|
throw new Error('order 模块未初始化');
|
|
3327
3460
|
case 3:
|
|
3328
3461
|
if (result) {
|
|
3329
|
-
|
|
3462
|
+
_context30.next = 5;
|
|
3330
3463
|
break;
|
|
3331
3464
|
}
|
|
3332
|
-
return
|
|
3465
|
+
return _context30.abrupt("return");
|
|
3333
3466
|
case 5:
|
|
3334
3467
|
tempOrder = this.store.order.ensureTempOrder();
|
|
3335
3468
|
orderStore = this.store.order.store || {};
|
|
@@ -3338,24 +3471,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3338
3471
|
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
3339
3472
|
}
|
|
3340
3473
|
if (!result.discountList) {
|
|
3341
|
-
|
|
3474
|
+
_context30.next = 14;
|
|
3342
3475
|
break;
|
|
3343
3476
|
}
|
|
3344
3477
|
OrderModule.populateSavedAmounts(tempOrder.products, result.discountList);
|
|
3345
|
-
|
|
3478
|
+
_context30.next = 13;
|
|
3346
3479
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(result.discountList);
|
|
3347
3480
|
case 13:
|
|
3348
3481
|
tempOrder.discount_list = result.discountList.filter(function (discount) {
|
|
3349
3482
|
return discount.isSelected;
|
|
3350
3483
|
});
|
|
3351
3484
|
case 14:
|
|
3352
|
-
|
|
3485
|
+
_context30.next = 16;
|
|
3353
3486
|
return this.store.order.recalculateSummary({
|
|
3354
3487
|
createIfMissing: true
|
|
3355
3488
|
});
|
|
3356
3489
|
case 16:
|
|
3357
3490
|
this.store.order.persistTempOrder();
|
|
3358
|
-
|
|
3491
|
+
_context30.next = 19;
|
|
3359
3492
|
return this.effectsEmit('onDiscountApplied', {
|
|
3360
3493
|
productList: tempOrder.products || [],
|
|
3361
3494
|
discountList: result.discountList || [],
|
|
@@ -3363,17 +3496,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3363
3496
|
tempOrder: tempOrder
|
|
3364
3497
|
});
|
|
3365
3498
|
case 19:
|
|
3366
|
-
|
|
3499
|
+
_context30.next = 24;
|
|
3367
3500
|
break;
|
|
3368
3501
|
case 21:
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
throw
|
|
3502
|
+
_context30.prev = 21;
|
|
3503
|
+
_context30.t0 = _context30["catch"](0);
|
|
3504
|
+
throw _context30.t0;
|
|
3372
3505
|
case 24:
|
|
3373
3506
|
case "end":
|
|
3374
|
-
return
|
|
3507
|
+
return _context30.stop();
|
|
3375
3508
|
}
|
|
3376
|
-
},
|
|
3509
|
+
}, _callee30, this, [[0, 21]]);
|
|
3377
3510
|
}));
|
|
3378
3511
|
function applyDiscountCalculationResult(_x23) {
|
|
3379
3512
|
return _applyDiscountCalculationResult.apply(this, arguments);
|
|
@@ -3383,82 +3516,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3383
3516
|
}, {
|
|
3384
3517
|
key: "submitScanOrder",
|
|
3385
3518
|
value: function () {
|
|
3386
|
-
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3387
|
-
return _regeneratorRuntime().wrap(function
|
|
3388
|
-
while (1) switch (
|
|
3519
|
+
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
|
|
3520
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
3521
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
3389
3522
|
case 0:
|
|
3390
|
-
return
|
|
3523
|
+
return _context31.abrupt("return", this.submitSalesOrder(params));
|
|
3391
3524
|
case 1:
|
|
3392
3525
|
case "end":
|
|
3393
|
-
return
|
|
3526
|
+
return _context31.stop();
|
|
3394
3527
|
}
|
|
3395
|
-
},
|
|
3528
|
+
}, _callee31, this);
|
|
3396
3529
|
}));
|
|
3397
3530
|
function submitScanOrder(_x24) {
|
|
3398
3531
|
return _submitScanOrder.apply(this, arguments);
|
|
3399
3532
|
}
|
|
3400
3533
|
return submitScanOrder;
|
|
3401
3534
|
}()
|
|
3402
|
-
/**
|
|
3403
|
-
* 提交当前 Sales 订单。
|
|
3404
|
-
*
|
|
3405
|
-
* PaymentModal 场景通过 smallTicketDataFlag=1 请求 B 端小票数据;
|
|
3406
|
-
* payments 会交给 OrderModule 统一映射为 Sales 协议支付项。
|
|
3407
|
-
*/
|
|
3408
|
-
}, {
|
|
3409
|
-
key: "submitSalesOrder",
|
|
3410
|
-
value: (function () {
|
|
3411
|
-
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
|
|
3412
|
-
var _params$smallTicketDa, _this$otherParams13, _this$otherParams14, _this$otherParams15, _this$otherParams16;
|
|
3413
|
-
var inferredPaymentStatus, smallTicketDataFlag, enhancePayload, submitParams;
|
|
3414
|
-
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
3415
|
-
while (1) switch (_context31.prev = _context31.next) {
|
|
3416
|
-
case 0:
|
|
3417
|
-
if (this.store.order) {
|
|
3418
|
-
_context31.next = 2;
|
|
3419
|
-
break;
|
|
3420
|
-
}
|
|
3421
|
-
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
3422
|
-
case 2:
|
|
3423
|
-
// this.store.order.persistTempOrder();
|
|
3424
|
-
inferredPaymentStatus = this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
|
|
3425
|
-
smallTicketDataFlag = (_params$smallTicketDa = params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== null && _params$smallTicketDa !== void 0 ? _params$smallTicketDa : this.getDefaultCheckoutSmallTicketDataFlag();
|
|
3426
|
-
enhancePayload = this.buildSubmitPayloadEnhancerWithFulfillmentRefMode(params === null || params === void 0 ? void 0 : params.enhancePayload);
|
|
3427
|
-
submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
3428
|
-
cacheId: this.cacheId,
|
|
3429
|
-
platform: (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.platform,
|
|
3430
|
-
businessCode: ((_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.businessCode) || ((_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.business_code),
|
|
3431
|
-
channel: this.getSubmitOrderSalesChannel(),
|
|
3432
|
-
type: (_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.type,
|
|
3433
|
-
request_unique_idempotency_token: this.store.order.generateIdempotencyToken()
|
|
3434
|
-
}, (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
|
|
3435
|
-
payments: params.payments
|
|
3436
|
-
} : {}), inferredPaymentStatus !== undefined ? {
|
|
3437
|
-
paymentStatus: inferredPaymentStatus
|
|
3438
|
-
} : {}), smallTicketDataFlag !== undefined ? {
|
|
3439
|
-
smallTicketDataFlag: smallTicketDataFlag
|
|
3440
|
-
} : {}), (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== undefined ? {
|
|
3441
|
-
confirmPendingVoucherPayments: params.confirmPendingVoucherPayments
|
|
3442
|
-
} : {}), enhancePayload !== undefined ? {
|
|
3443
|
-
enhancePayload: enhancePayload
|
|
3444
|
-
} : {});
|
|
3445
|
-
return _context31.abrupt("return", this.shouldUseCheckoutSyncTask() ? this.store.order.submitTempOrder(submitParams) : this.store.order.submitTempOrderAsync(submitParams));
|
|
3446
|
-
case 7:
|
|
3447
|
-
case "end":
|
|
3448
|
-
return _context31.stop();
|
|
3449
|
-
}
|
|
3450
|
-
}, _callee31, this);
|
|
3451
|
-
}));
|
|
3452
|
-
function submitSalesOrder(_x25) {
|
|
3453
|
-
return _submitSalesOrder.apply(this, arguments);
|
|
3454
|
-
}
|
|
3455
|
-
return submitSalesOrder;
|
|
3456
|
-
}())
|
|
3457
3535
|
}, {
|
|
3458
|
-
key: "
|
|
3536
|
+
key: "buildVirtualSettlementSubmitData",
|
|
3459
3537
|
value: function () {
|
|
3460
|
-
var
|
|
3461
|
-
var
|
|
3538
|
+
var _buildVirtualSettlementSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
|
|
3539
|
+
var _tempOrder$metadata$c, _tempOrder$metadata2;
|
|
3540
|
+
var tempOrder, snapshot, currencyProductId, summary, amount, customerId, asset, currencyCode, currencySymbol, currencyFormat, balance, amountText, paymentNumber, payment, _paymentMethod$custom, paymentMethods, paymentMethod;
|
|
3462
3541
|
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
3463
3542
|
while (1) switch (_context32.prev = _context32.next) {
|
|
3464
3543
|
case 0:
|
|
@@ -3466,34 +3545,161 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3466
3545
|
_context32.next = 2;
|
|
3467
3546
|
break;
|
|
3468
3547
|
}
|
|
3469
|
-
|
|
3548
|
+
return _context32.abrupt("return", null);
|
|
3470
3549
|
case 2:
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3550
|
+
tempOrder = this.store.order.getTempOrder();
|
|
3551
|
+
if (this.isActiveVirtualSettlementOrder(tempOrder)) {
|
|
3552
|
+
_context32.next = 5;
|
|
3553
|
+
break;
|
|
3554
|
+
}
|
|
3555
|
+
return _context32.abrupt("return", null);
|
|
3556
|
+
case 5:
|
|
3557
|
+
snapshot = getTempOrderSettlementSnapshot(tempOrder);
|
|
3558
|
+
currencyProductId = Number((_tempOrder$metadata$c = tempOrder === null || tempOrder === void 0 || (_tempOrder$metadata2 = tempOrder.metadata) === null || _tempOrder$metadata2 === void 0 || (_tempOrder$metadata2 = _tempOrder$metadata2.currency_settlement_config) === null || _tempOrder$metadata2 === void 0 || (_tempOrder$metadata2 = _tempOrder$metadata2.settlement_ids) === null || _tempOrder$metadata2 === void 0 ? void 0 : _tempOrder$metadata2[0]) !== null && _tempOrder$metadata$c !== void 0 ? _tempOrder$metadata$c : snapshot === null || snapshot === void 0 ? void 0 : snapshot.currency_product_id);
|
|
3559
|
+
if (!(!snapshot || !Number.isFinite(currencyProductId) || currencyProductId <= 0)) {
|
|
3560
|
+
_context32.next = 9;
|
|
3561
|
+
break;
|
|
3562
|
+
}
|
|
3563
|
+
throw new Error('Virtual currency settlement configuration is invalid.');
|
|
3564
|
+
case 9:
|
|
3565
|
+
_context32.next = 11;
|
|
3566
|
+
return this.store.order.recalculateSummary({
|
|
3567
|
+
createIfMissing: true
|
|
3568
|
+
});
|
|
3569
|
+
case 11:
|
|
3570
|
+
summary = _context32.sent;
|
|
3571
|
+
amount = new Decimal((summary === null || summary === void 0 ? void 0 : summary.total_amount) || 0).toDecimalPlaces(2);
|
|
3572
|
+
customerId = Number((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.customer_id) || 0);
|
|
3573
|
+
if (!(amount.gt(0) && customerId > 0 && customerId !== 1)) {
|
|
3574
|
+
_context32.next = 17;
|
|
3575
|
+
break;
|
|
3576
|
+
}
|
|
3577
|
+
_context32.next = 17;
|
|
3578
|
+
return this.store.order.loadDiscountConfig({
|
|
3579
|
+
customerId: customerId,
|
|
3580
|
+
action: tempOrder !== null && tempOrder !== void 0 && tempOrder.order_id ? 'edit' : 'create',
|
|
3581
|
+
orderId: Number(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.order_id) || undefined,
|
|
3582
|
+
apply: false
|
|
3583
|
+
});
|
|
3584
|
+
case 17:
|
|
3585
|
+
asset = this.store.order.getVirtualCurrencyList().find(function (item) {
|
|
3586
|
+
return Number(item === null || item === void 0 ? void 0 : item.product_id) === currencyProductId;
|
|
3587
|
+
});
|
|
3588
|
+
currencyCode = String((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.currency_code) || '');
|
|
3589
|
+
currencySymbol = String((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.currency_symbol) || '');
|
|
3590
|
+
currencyFormat = String((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.currency_format) || 'symbol_first');
|
|
3591
|
+
if (!amount.lte(0)) {
|
|
3592
|
+
_context32.next = 23;
|
|
3593
|
+
break;
|
|
3594
|
+
}
|
|
3595
|
+
return _context32.abrupt("return", {
|
|
3596
|
+
payments: [],
|
|
3597
|
+
snapshot: snapshot,
|
|
3598
|
+
currencyProductId: currencyProductId,
|
|
3599
|
+
currencyCode: currencyCode,
|
|
3600
|
+
currencySymbol: currencySymbol,
|
|
3601
|
+
currencyFormat: currencyFormat
|
|
3602
|
+
});
|
|
3603
|
+
case 23:
|
|
3604
|
+
if (asset) {
|
|
3605
|
+
_context32.next = 25;
|
|
3606
|
+
break;
|
|
3607
|
+
}
|
|
3608
|
+
throw new Error('No matching virtual currency card is available.');
|
|
3609
|
+
case 25:
|
|
3610
|
+
balance = new Decimal(asset.balance || 0);
|
|
3611
|
+
if (!balance.lt(amount)) {
|
|
3612
|
+
_context32.next = 28;
|
|
3613
|
+
break;
|
|
3614
|
+
}
|
|
3615
|
+
throw new Error('Insufficient virtual currency balance.');
|
|
3616
|
+
case 28:
|
|
3617
|
+
amountText = amount.toFixed(2);
|
|
3618
|
+
paymentNumber = "LOCAL_".concat(createUuidV4());
|
|
3619
|
+
if (!this.store.order.isOnlineStorePlatform()) {
|
|
3620
|
+
_context32.next = 34;
|
|
3621
|
+
break;
|
|
3622
|
+
}
|
|
3623
|
+
payment = {
|
|
3624
|
+
payment_number: paymentNumber,
|
|
3625
|
+
amount: amount.toNumber(),
|
|
3626
|
+
metadata: {
|
|
3627
|
+
unique_payment_number: createUuidV4()
|
|
3628
|
+
},
|
|
3629
|
+
tag: asset.tag,
|
|
3630
|
+
voucher_id: asset.id,
|
|
3631
|
+
wallet_pass_usage_unit: {
|
|
3632
|
+
price: 1,
|
|
3633
|
+
points: 1
|
|
3634
|
+
},
|
|
3635
|
+
wallet_pass_use_value: amountText
|
|
3636
|
+
};
|
|
3637
|
+
_context32.next = 41;
|
|
3638
|
+
break;
|
|
3639
|
+
case 34:
|
|
3640
|
+
_context32.next = 36;
|
|
3641
|
+
return this.getPaymentMethodsAsync();
|
|
3642
|
+
case 36:
|
|
3643
|
+
paymentMethods = _context32.sent;
|
|
3644
|
+
paymentMethod = paymentMethods.find(function (method) {
|
|
3645
|
+
return String(method.code || '').toUpperCase() === 'PRODUCTVOUCHER';
|
|
3646
|
+
});
|
|
3647
|
+
if (paymentMethod) {
|
|
3648
|
+
_context32.next = 40;
|
|
3649
|
+
break;
|
|
3650
|
+
}
|
|
3651
|
+
throw new Error('PRODUCTVOUCHER payment method is unavailable.');
|
|
3652
|
+
case 40:
|
|
3653
|
+
payment = {
|
|
3654
|
+
payment_number: paymentNumber,
|
|
3655
|
+
amount: amountText,
|
|
3656
|
+
origin_amount: amountText,
|
|
3657
|
+
code: paymentMethod.code,
|
|
3658
|
+
custom_payment_id: paymentMethod.id,
|
|
3659
|
+
custom_payment_type: (_paymentMethod$custom = paymentMethod.custom_payment_type) !== null && _paymentMethod$custom !== void 0 ? _paymentMethod$custom : paymentMethod.type,
|
|
3660
|
+
name: paymentMethod.name,
|
|
3661
|
+
type: 'normal',
|
|
3662
|
+
voucher_id: asset.id,
|
|
3663
|
+
order_payment_type: 'normal',
|
|
3664
|
+
wallet_pass_usage_unit: {
|
|
3665
|
+
price: 1,
|
|
3666
|
+
points: 1
|
|
3667
|
+
},
|
|
3668
|
+
wallet_pass_use_value: amountText,
|
|
3669
|
+
metadata: {}
|
|
3670
|
+
};
|
|
3671
|
+
case 41:
|
|
3672
|
+
return _context32.abrupt("return", {
|
|
3673
|
+
payments: [payment],
|
|
3674
|
+
snapshot: snapshot,
|
|
3675
|
+
currencyProductId: currencyProductId,
|
|
3676
|
+
currencyCode: currencyCode,
|
|
3677
|
+
currencySymbol: currencySymbol,
|
|
3678
|
+
currencyFormat: currencyFormat
|
|
3679
|
+
});
|
|
3680
|
+
case 42:
|
|
3681
|
+
case "end":
|
|
3682
|
+
return _context32.stop();
|
|
3683
|
+
}
|
|
3684
|
+
}, _callee32, this);
|
|
3685
|
+
}));
|
|
3686
|
+
function buildVirtualSettlementSubmitData() {
|
|
3687
|
+
return _buildVirtualSettlementSubmitData.apply(this, arguments);
|
|
3688
|
+
}
|
|
3689
|
+
return buildVirtualSettlementSubmitData;
|
|
3690
|
+
}()
|
|
3691
|
+
/**
|
|
3692
|
+
* 提交当前 Sales 订单。
|
|
3693
|
+
*
|
|
3694
|
+
* PaymentModal 场景通过 smallTicketDataFlag=1 请求 B 端小票数据;
|
|
3695
|
+
* payments 会交给 OrderModule 统一映射为 Sales 协议支付项。
|
|
3696
|
+
*/
|
|
3491
3697
|
}, {
|
|
3492
|
-
key: "
|
|
3493
|
-
value: function () {
|
|
3494
|
-
var
|
|
3495
|
-
var _params$
|
|
3496
|
-
var inferredPaymentStatus, smallTicketDataFlag,
|
|
3698
|
+
key: "submitSalesOrder",
|
|
3699
|
+
value: (function () {
|
|
3700
|
+
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
|
|
3701
|
+
var _params$smallTicketDa, _this$otherParams14, _this$otherParams15, _this$otherParams16, _this$otherParams17;
|
|
3702
|
+
var virtualSettlement, inferredPaymentStatus, smallTicketDataFlag, _enhancePayload, submitParams;
|
|
3497
3703
|
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
3498
3704
|
while (1) switch (_context33.prev = _context33.next) {
|
|
3499
3705
|
case 0:
|
|
@@ -3502,16 +3708,125 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3502
3708
|
break;
|
|
3503
3709
|
}
|
|
3504
3710
|
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
3711
|
+
case 2:
|
|
3712
|
+
_context33.next = 4;
|
|
3713
|
+
return this.buildVirtualSettlementSubmitData();
|
|
3714
|
+
case 4:
|
|
3715
|
+
virtualSettlement = _context33.sent;
|
|
3716
|
+
// this.store.order.persistTempOrder();
|
|
3717
|
+
inferredPaymentStatus = this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
|
|
3718
|
+
smallTicketDataFlag = (_params$smallTicketDa = params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== null && _params$smallTicketDa !== void 0 ? _params$smallTicketDa : this.getDefaultCheckoutSmallTicketDataFlag();
|
|
3719
|
+
_enhancePayload = this.buildSubmitPayloadEnhancerWithFulfillmentRefMode(params === null || params === void 0 ? void 0 : params.enhancePayload);
|
|
3720
|
+
submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
3721
|
+
cacheId: this.cacheId,
|
|
3722
|
+
platform: (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.platform,
|
|
3723
|
+
businessCode: ((_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.businessCode) || ((_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.business_code),
|
|
3724
|
+
channel: this.getSubmitOrderSalesChannel(),
|
|
3725
|
+
type: (_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.type,
|
|
3726
|
+
request_unique_idempotency_token: this.store.order.generateIdempotencyToken()
|
|
3727
|
+
}, virtualSettlement ? {
|
|
3728
|
+
payments: virtualSettlement.payments
|
|
3729
|
+
} : (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
|
|
3730
|
+
payments: params.payments
|
|
3731
|
+
} : {}), inferredPaymentStatus !== undefined ? {
|
|
3732
|
+
paymentStatus: inferredPaymentStatus
|
|
3733
|
+
} : {}), smallTicketDataFlag !== undefined ? {
|
|
3734
|
+
smallTicketDataFlag: smallTicketDataFlag
|
|
3735
|
+
} : {}), virtualSettlement ? {
|
|
3736
|
+
confirmPendingVoucherPayments: false
|
|
3737
|
+
} : (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== undefined ? {
|
|
3738
|
+
confirmPendingVoucherPayments: params.confirmPendingVoucherPayments
|
|
3739
|
+
} : {}), virtualSettlement ? {
|
|
3740
|
+
enhancePayload: function enhancePayload(payload, ctx) {
|
|
3741
|
+
var _callerPayload$metada, _currencySettlementCo;
|
|
3742
|
+
var callerPayload = _enhancePayload ? _enhancePayload(payload, ctx) : payload;
|
|
3743
|
+
var currencySettlementConfig = ((_callerPayload$metada = callerPayload.metadata) === null || _callerPayload$metada === void 0 ? void 0 : _callerPayload$metada.currency_settlement_config) || {};
|
|
3744
|
+
return _objectSpread(_objectSpread({}, callerPayload), {}, {
|
|
3745
|
+
metadata: _objectSpread(_objectSpread({}, callerPayload.metadata || {}), {}, {
|
|
3746
|
+
currency_settlement_config: _objectSpread(_objectSpread({}, currencySettlementConfig), {}, {
|
|
3747
|
+
settlement_type: 'virtual_currency',
|
|
3748
|
+
settlement_ids: [virtualSettlement.currencyProductId],
|
|
3749
|
+
currency_display_snapshot: cloneDeep((_currencySettlementCo = currencySettlementConfig.currency_display_snapshot) !== null && _currencySettlementCo !== void 0 ? _currencySettlementCo : buildCurrencyDisplaySnapshot(virtualSettlement.snapshot))
|
|
3750
|
+
})
|
|
3751
|
+
}),
|
|
3752
|
+
currency_code: virtualSettlement.currencyCode,
|
|
3753
|
+
currency_symbol: virtualSettlement.currencySymbol,
|
|
3754
|
+
currency_format: virtualSettlement.currencyFormat
|
|
3755
|
+
});
|
|
3756
|
+
}
|
|
3757
|
+
} : _enhancePayload !== undefined ? {
|
|
3758
|
+
enhancePayload: _enhancePayload
|
|
3759
|
+
} : {});
|
|
3760
|
+
return _context33.abrupt("return", this.shouldUseCheckoutSyncTask() ? this.store.order.submitTempOrder(submitParams) : this.store.order.submitTempOrderAsync(submitParams));
|
|
3761
|
+
case 10:
|
|
3762
|
+
case "end":
|
|
3763
|
+
return _context33.stop();
|
|
3764
|
+
}
|
|
3765
|
+
}, _callee33, this);
|
|
3766
|
+
}));
|
|
3767
|
+
function submitSalesOrder(_x25) {
|
|
3768
|
+
return _submitSalesOrder.apply(this, arguments);
|
|
3769
|
+
}
|
|
3770
|
+
return submitSalesOrder;
|
|
3771
|
+
}())
|
|
3772
|
+
}, {
|
|
3773
|
+
key: "saveSalesOrderDraft",
|
|
3774
|
+
value: function () {
|
|
3775
|
+
var _saveSalesOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
|
|
3776
|
+
var _params$platform, _this$otherParams18, _this$otherParams19, _this$otherParams20, _params$channel, _params$type, _this$otherParams21;
|
|
3777
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
3778
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
3779
|
+
case 0:
|
|
3780
|
+
if (this.store.order) {
|
|
3781
|
+
_context34.next = 2;
|
|
3782
|
+
break;
|
|
3783
|
+
}
|
|
3784
|
+
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
3785
|
+
case 2:
|
|
3786
|
+
return _context34.abrupt("return", this.store.order.saveTempOrderAsDraft(_objectSpread({
|
|
3787
|
+
cacheId: this.cacheId,
|
|
3788
|
+
platform: (_params$platform = params === null || params === void 0 ? void 0 : params.platform) !== null && _params$platform !== void 0 ? _params$platform : (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.platform,
|
|
3789
|
+
businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.businessCode) || ((_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.business_code),
|
|
3790
|
+
channel: (_params$channel = params === null || params === void 0 ? void 0 : params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel(),
|
|
3791
|
+
type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.type
|
|
3792
|
+
}, (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
|
|
3793
|
+
enhancePayload: params.enhancePayload
|
|
3794
|
+
} : {})));
|
|
3795
|
+
case 3:
|
|
3796
|
+
case "end":
|
|
3797
|
+
return _context34.stop();
|
|
3798
|
+
}
|
|
3799
|
+
}, _callee34, this);
|
|
3800
|
+
}));
|
|
3801
|
+
function saveSalesOrderDraft(_x26) {
|
|
3802
|
+
return _saveSalesOrderDraft.apply(this, arguments);
|
|
3803
|
+
}
|
|
3804
|
+
return saveSalesOrderDraft;
|
|
3805
|
+
}()
|
|
3806
|
+
}, {
|
|
3807
|
+
key: "submitTempOrderAsync",
|
|
3808
|
+
value: function () {
|
|
3809
|
+
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
|
|
3810
|
+
var _params$smallTicketDa2, _this$otherParams22, _this$otherParams23, _this$otherParams24, _this$otherParams25;
|
|
3811
|
+
var inferredPaymentStatus, smallTicketDataFlag, enhancePayload, submitParams;
|
|
3812
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
3813
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
3814
|
+
case 0:
|
|
3815
|
+
if (this.store.order) {
|
|
3816
|
+
_context35.next = 2;
|
|
3817
|
+
break;
|
|
3818
|
+
}
|
|
3819
|
+
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
3505
3820
|
case 2:
|
|
3506
3821
|
inferredPaymentStatus = this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
|
|
3507
3822
|
smallTicketDataFlag = (_params$smallTicketDa2 = params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== null && _params$smallTicketDa2 !== void 0 ? _params$smallTicketDa2 : this.getDefaultCheckoutSmallTicketDataFlag();
|
|
3508
3823
|
enhancePayload = this.buildSubmitPayloadEnhancerWithFulfillmentRefMode(params === null || params === void 0 ? void 0 : params.enhancePayload);
|
|
3509
3824
|
submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
3510
3825
|
cacheId: this.cacheId,
|
|
3511
|
-
platform: (_this$
|
|
3512
|
-
businessCode: ((_this$
|
|
3826
|
+
platform: (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.platform,
|
|
3827
|
+
businessCode: ((_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.businessCode) || ((_this$otherParams24 = this.otherParams) === null || _this$otherParams24 === void 0 ? void 0 : _this$otherParams24.business_code),
|
|
3513
3828
|
channel: this.getSubmitOrderSalesChannel(),
|
|
3514
|
-
type: (_this$
|
|
3829
|
+
type: (_this$otherParams25 = this.otherParams) === null || _this$otherParams25 === void 0 ? void 0 : _this$otherParams25.type,
|
|
3515
3830
|
request_unique_idempotency_token: this.store.order.generateIdempotencyToken()
|
|
3516
3831
|
}, (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
|
|
3517
3832
|
payments: params.payments
|
|
@@ -3524,12 +3839,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3524
3839
|
} : {}), enhancePayload !== undefined ? {
|
|
3525
3840
|
enhancePayload: enhancePayload
|
|
3526
3841
|
} : {});
|
|
3527
|
-
return
|
|
3842
|
+
return _context35.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
|
|
3528
3843
|
case 7:
|
|
3529
3844
|
case "end":
|
|
3530
|
-
return
|
|
3845
|
+
return _context35.stop();
|
|
3531
3846
|
}
|
|
3532
|
-
},
|
|
3847
|
+
}, _callee35, this);
|
|
3533
3848
|
}));
|
|
3534
3849
|
function submitTempOrderAsync(_x27) {
|
|
3535
3850
|
return _submitTempOrderAsync.apply(this, arguments);
|
|
@@ -3543,8 +3858,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3543
3858
|
}, {
|
|
3544
3859
|
key: "shouldUseCheckoutSyncTask",
|
|
3545
3860
|
value: function shouldUseCheckoutSyncTask() {
|
|
3546
|
-
var _this$
|
|
3547
|
-
var configured = (_this$
|
|
3861
|
+
var _this$otherParams26;
|
|
3862
|
+
var configured = (_this$otherParams26 = this.otherParams) === null || _this$otherParams26 === void 0 ? void 0 : _this$otherParams26.checkoutSyncTaskEnabled;
|
|
3548
3863
|
return typeof configured === 'boolean' ? configured : true;
|
|
3549
3864
|
}
|
|
3550
3865
|
|
|
@@ -3557,14 +3872,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3557
3872
|
}, {
|
|
3558
3873
|
key: "printLocalOrderReceipt",
|
|
3559
3874
|
value: function () {
|
|
3560
|
-
var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3561
|
-
var _this$
|
|
3562
|
-
var hasLookup, lookupPayload, context, payload, response, _this$store$order$app, _this$store$
|
|
3563
|
-
return _regeneratorRuntime().wrap(function
|
|
3564
|
-
while (1) switch (
|
|
3875
|
+
var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(lookup) {
|
|
3876
|
+
var _this$otherParams27, _this$otherParams28, _this$otherParams29, _this$otherParams30;
|
|
3877
|
+
var hasLookup, lookupPayload, context, payload, response, _this$store$order$app, _this$store$order6, _data;
|
|
3878
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
3879
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
3565
3880
|
case 0:
|
|
3566
3881
|
if (this.store.order) {
|
|
3567
|
-
|
|
3882
|
+
_context36.next = 2;
|
|
3568
3883
|
break;
|
|
3569
3884
|
}
|
|
3570
3885
|
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
@@ -3576,10 +3891,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3576
3891
|
external_sale_number: lookup
|
|
3577
3892
|
};
|
|
3578
3893
|
context = {
|
|
3579
|
-
platform: (_this$
|
|
3580
|
-
businessCode: ((_this$
|
|
3894
|
+
platform: (_this$otherParams27 = this.otherParams) === null || _this$otherParams27 === void 0 ? void 0 : _this$otherParams27.platform,
|
|
3895
|
+
businessCode: ((_this$otherParams28 = this.otherParams) === null || _this$otherParams28 === void 0 ? void 0 : _this$otherParams28.businessCode) || ((_this$otherParams29 = this.otherParams) === null || _this$otherParams29 === void 0 ? void 0 : _this$otherParams29.business_code),
|
|
3581
3896
|
channel: this.getSubmitOrderSalesChannel(),
|
|
3582
|
-
type: (_this$
|
|
3897
|
+
type: (_this$otherParams30 = this.otherParams) === null || _this$otherParams30 === void 0 ? void 0 : _this$otherParams30.type
|
|
3583
3898
|
};
|
|
3584
3899
|
payload = hasLookup ? _objectSpread(_objectSpread({}, lookupPayload), {}, {
|
|
3585
3900
|
lookup_order_from_db: 1,
|
|
@@ -3595,26 +3910,26 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3595
3910
|
channel: context.channel,
|
|
3596
3911
|
type: context.type
|
|
3597
3912
|
});
|
|
3598
|
-
|
|
3913
|
+
_context36.next = 8;
|
|
3599
3914
|
return this.request.post('/local/print-order', payload, {
|
|
3600
3915
|
osServer: true,
|
|
3601
3916
|
customToast: function customToast() {}
|
|
3602
3917
|
});
|
|
3603
3918
|
case 8:
|
|
3604
|
-
response =
|
|
3919
|
+
response = _context36.sent;
|
|
3605
3920
|
if (hasLookup) {
|
|
3606
|
-
|
|
3921
|
+
_context36.next = 12;
|
|
3607
3922
|
break;
|
|
3608
3923
|
}
|
|
3609
|
-
|
|
3610
|
-
return (_this$store$order$app = (_this$store$
|
|
3924
|
+
_context36.next = 12;
|
|
3925
|
+
return (_this$store$order$app = (_this$store$order6 = this.store.order).applyLocalPrintOrderNumbers) === null || _this$store$order$app === void 0 ? void 0 : _this$store$order$app.call(_this$store$order6, response === null || response === void 0 || (_data = response.data) === null || _data === void 0 ? void 0 : _data.order);
|
|
3611
3926
|
case 12:
|
|
3612
|
-
return
|
|
3927
|
+
return _context36.abrupt("return", response);
|
|
3613
3928
|
case 13:
|
|
3614
3929
|
case "end":
|
|
3615
|
-
return
|
|
3930
|
+
return _context36.stop();
|
|
3616
3931
|
}
|
|
3617
|
-
},
|
|
3932
|
+
}, _callee36, this);
|
|
3618
3933
|
}));
|
|
3619
3934
|
function printLocalOrderReceipt(_x28) {
|
|
3620
3935
|
return _printLocalOrderReceipt.apply(this, arguments);
|
|
@@ -3624,9 +3939,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3624
3939
|
}, {
|
|
3625
3940
|
key: "getSubmitPaymentStatus",
|
|
3626
3941
|
value: function getSubmitPaymentStatus(paymentStatus) {
|
|
3627
|
-
var _this$store$
|
|
3942
|
+
var _this$store$order7, _this$store$order7$ge;
|
|
3628
3943
|
if (paymentStatus !== undefined) return paymentStatus;
|
|
3629
|
-
var amountSnapshot = (_this$store$
|
|
3944
|
+
var amountSnapshot = (_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 || (_this$store$order7$ge = _this$store$order7.getOrderAmountSnapshot) === null || _this$store$order7$ge === void 0 ? void 0 : _this$store$order7$ge.call(_this$store$order7);
|
|
3630
3945
|
if (!amountSnapshot) return undefined;
|
|
3631
3946
|
try {
|
|
3632
3947
|
return new Decimal(amountSnapshot.amountGap || 0).lte(0) ? 'paid' : undefined;
|
|
@@ -3637,19 +3952,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3637
3952
|
}, {
|
|
3638
3953
|
key: "syncPaymentsToOrder",
|
|
3639
3954
|
value: function () {
|
|
3640
|
-
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3641
|
-
var
|
|
3955
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
|
|
3956
|
+
var _ref40, _params$businessCode, _this$otherParams31, _this$otherParams32, _params$channel2;
|
|
3642
3957
|
var businessCode, channel, enhancePayload, syncParams, syncState, payments, syncResult, latestPayments, amountSnapshot, orderSnapshot, syncPayload;
|
|
3643
|
-
return _regeneratorRuntime().wrap(function
|
|
3644
|
-
while (1) switch (
|
|
3958
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
3959
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
3645
3960
|
case 0:
|
|
3646
3961
|
if (this.store.order) {
|
|
3647
|
-
|
|
3962
|
+
_context37.next = 2;
|
|
3648
3963
|
break;
|
|
3649
3964
|
}
|
|
3650
3965
|
throw new Error('order 模块未初始化');
|
|
3651
3966
|
case 2:
|
|
3652
|
-
businessCode = (
|
|
3967
|
+
businessCode = (_ref40 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams31 = this.otherParams) === null || _this$otherParams31 === void 0 ? void 0 : _this$otherParams31.businessCode) !== null && _ref40 !== void 0 ? _ref40 : (_this$otherParams32 = this.otherParams) === null || _this$otherParams32 === void 0 ? void 0 : _this$otherParams32.business_code;
|
|
3653
3968
|
channel = (_params$channel2 = params.channel) !== null && _params$channel2 !== void 0 ? _params$channel2 : this.getSubmitOrderSalesChannel();
|
|
3654
3969
|
enhancePayload = this.buildSubmitPayloadEnhancerWithFulfillmentRefMode(params.enhancePayload);
|
|
3655
3970
|
syncParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, params), {}, {
|
|
@@ -3663,14 +3978,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3663
3978
|
} : {});
|
|
3664
3979
|
syncState = this.store.order.getOrderSyncState();
|
|
3665
3980
|
if (!(params.submitWhenPaid && syncState === 'submitting')) {
|
|
3666
|
-
|
|
3981
|
+
_context37.next = 10;
|
|
3667
3982
|
break;
|
|
3668
3983
|
}
|
|
3669
3984
|
this.queueLatestAutoPaymentSync();
|
|
3670
|
-
return
|
|
3985
|
+
return _context37.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
|
|
3671
3986
|
case 10:
|
|
3672
3987
|
payments = params.payments || [];
|
|
3673
|
-
|
|
3988
|
+
_context37.next = 13;
|
|
3674
3989
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncStart, {
|
|
3675
3990
|
payments: payments,
|
|
3676
3991
|
params: syncParams,
|
|
@@ -3678,11 +3993,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3678
3993
|
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
3679
3994
|
});
|
|
3680
3995
|
case 13:
|
|
3681
|
-
|
|
3682
|
-
|
|
3996
|
+
_context37.prev = 13;
|
|
3997
|
+
_context37.next = 16;
|
|
3683
3998
|
return this.store.order.syncPaymentsToOrder(syncParams);
|
|
3684
3999
|
case 16:
|
|
3685
|
-
syncResult =
|
|
4000
|
+
syncResult = _context37.sent;
|
|
3686
4001
|
latestPayments = this.store.order.getOrderPayments();
|
|
3687
4002
|
amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
3688
4003
|
orderSnapshot = this.store.order.getOrderSnapshot();
|
|
@@ -3700,25 +4015,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3700
4015
|
depositAmount: syncResult.depositAmount,
|
|
3701
4016
|
orderExpectedAmount: syncResult.orderExpectedAmount
|
|
3702
4017
|
};
|
|
3703
|
-
|
|
4018
|
+
_context37.next = 23;
|
|
3704
4019
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, syncPayload);
|
|
3705
4020
|
case 23:
|
|
3706
4021
|
if (!(syncResult.isDepositFullyPaid && !syncResult.isOrderFullyPaid)) {
|
|
3707
|
-
|
|
4022
|
+
_context37.next = 26;
|
|
3708
4023
|
break;
|
|
3709
4024
|
}
|
|
3710
|
-
|
|
4025
|
+
_context37.next = 26;
|
|
3711
4026
|
return this.effectsEmit(BaseSalesHookNames.onDepositPaymentSyncEnd, syncPayload);
|
|
3712
4027
|
case 26:
|
|
3713
4028
|
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
3714
|
-
return
|
|
4029
|
+
return _context37.abrupt("return", syncResult);
|
|
3715
4030
|
case 30:
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
4031
|
+
_context37.prev = 30;
|
|
4032
|
+
_context37.t0 = _context37["catch"](13);
|
|
4033
|
+
_context37.next = 34;
|
|
3719
4034
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
|
|
3720
4035
|
ok: false,
|
|
3721
|
-
error:
|
|
4036
|
+
error: _context37.t0,
|
|
3722
4037
|
payments: this.store.order.getOrderPayments(),
|
|
3723
4038
|
params: syncParams,
|
|
3724
4039
|
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
@@ -3726,12 +4041,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3726
4041
|
});
|
|
3727
4042
|
case 34:
|
|
3728
4043
|
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
3729
|
-
throw
|
|
4044
|
+
throw _context37.t0;
|
|
3730
4045
|
case 36:
|
|
3731
4046
|
case "end":
|
|
3732
|
-
return
|
|
4047
|
+
return _context37.stop();
|
|
3733
4048
|
}
|
|
3734
|
-
},
|
|
4049
|
+
}, _callee37, this, [[13, 30]]);
|
|
3735
4050
|
}));
|
|
3736
4051
|
function syncPaymentsToOrder(_x29) {
|
|
3737
4052
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
@@ -3782,46 +4097,46 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3782
4097
|
}, {
|
|
3783
4098
|
key: "flushQueuedAutoPaymentSync",
|
|
3784
4099
|
value: function () {
|
|
3785
|
-
var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4100
|
+
var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
|
|
3786
4101
|
var payments;
|
|
3787
|
-
return _regeneratorRuntime().wrap(function
|
|
3788
|
-
while (1) switch (
|
|
4102
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
4103
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
3789
4104
|
case 0:
|
|
3790
4105
|
if (this.store.order) {
|
|
3791
|
-
|
|
4106
|
+
_context38.next = 2;
|
|
3792
4107
|
break;
|
|
3793
4108
|
}
|
|
3794
|
-
return
|
|
4109
|
+
return _context38.abrupt("return");
|
|
3795
4110
|
case 2:
|
|
3796
4111
|
if (!(!this.queuedAutoPaymentSync || this.autoPaymentSyncFlushing)) {
|
|
3797
|
-
|
|
4112
|
+
_context38.next = 4;
|
|
3798
4113
|
break;
|
|
3799
4114
|
}
|
|
3800
|
-
return
|
|
4115
|
+
return _context38.abrupt("return");
|
|
3801
4116
|
case 4:
|
|
3802
4117
|
if (!(this.store.order.getOrderSyncState() === 'submitting')) {
|
|
3803
|
-
|
|
4118
|
+
_context38.next = 7;
|
|
3804
4119
|
break;
|
|
3805
4120
|
}
|
|
3806
4121
|
this.scheduleQueuedAutoPaymentSyncFlush();
|
|
3807
|
-
return
|
|
4122
|
+
return _context38.abrupt("return");
|
|
3808
4123
|
case 7:
|
|
3809
4124
|
this.autoPaymentSyncFlushing = true;
|
|
3810
|
-
|
|
4125
|
+
_context38.prev = 8;
|
|
3811
4126
|
case 9:
|
|
3812
4127
|
if (!this.queuedAutoPaymentSync) {
|
|
3813
|
-
|
|
4128
|
+
_context38.next = 18;
|
|
3814
4129
|
break;
|
|
3815
4130
|
}
|
|
3816
4131
|
this.queuedAutoPaymentSync = false;
|
|
3817
4132
|
payments = this.store.order.getOrderPayments();
|
|
3818
4133
|
if (payments.length) {
|
|
3819
|
-
|
|
4134
|
+
_context38.next = 14;
|
|
3820
4135
|
break;
|
|
3821
4136
|
}
|
|
3822
|
-
return
|
|
4137
|
+
return _context38.abrupt("continue", 9);
|
|
3823
4138
|
case 14:
|
|
3824
|
-
|
|
4139
|
+
_context38.next = 16;
|
|
3825
4140
|
return this.syncPaymentsToOrder({
|
|
3826
4141
|
payments: payments,
|
|
3827
4142
|
paymentStatus: this.getPaymentStatusForSync(payments),
|
|
@@ -3829,29 +4144,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3829
4144
|
smallTicketDataFlag: 1
|
|
3830
4145
|
});
|
|
3831
4146
|
case 16:
|
|
3832
|
-
|
|
4147
|
+
_context38.next = 9;
|
|
3833
4148
|
break;
|
|
3834
4149
|
case 18:
|
|
3835
|
-
|
|
4150
|
+
_context38.next = 23;
|
|
3836
4151
|
break;
|
|
3837
4152
|
case 20:
|
|
3838
|
-
|
|
3839
|
-
|
|
4153
|
+
_context38.prev = 20;
|
|
4154
|
+
_context38.t0 = _context38["catch"](8);
|
|
3840
4155
|
this.logError('queued auto sync payments failed', {
|
|
3841
|
-
error:
|
|
4156
|
+
error: _context38.t0 instanceof Error ? _context38.t0.message : String(_context38.t0)
|
|
3842
4157
|
});
|
|
3843
4158
|
case 23:
|
|
3844
|
-
|
|
4159
|
+
_context38.prev = 23;
|
|
3845
4160
|
this.autoPaymentSyncFlushing = false;
|
|
3846
4161
|
if (this.queuedAutoPaymentSync) {
|
|
3847
4162
|
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
3848
4163
|
}
|
|
3849
|
-
return
|
|
4164
|
+
return _context38.finish(23);
|
|
3850
4165
|
case 27:
|
|
3851
4166
|
case "end":
|
|
3852
|
-
return
|
|
4167
|
+
return _context38.stop();
|
|
3853
4168
|
}
|
|
3854
|
-
},
|
|
4169
|
+
}, _callee38, this, [[8, 20, 23, 27]]);
|
|
3855
4170
|
}));
|
|
3856
4171
|
function flushQueuedAutoPaymentSync() {
|
|
3857
4172
|
return _flushQueuedAutoPaymentSync.apply(this, arguments);
|
|
@@ -3875,33 +4190,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3875
4190
|
}, {
|
|
3876
4191
|
key: "addOrderPaymentAsync",
|
|
3877
4192
|
value: (function () {
|
|
3878
|
-
var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4193
|
+
var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(payment) {
|
|
3879
4194
|
var paymentRecord, hasPaymentNumber, devicePrefix;
|
|
3880
|
-
return _regeneratorRuntime().wrap(function
|
|
3881
|
-
while (1) switch (
|
|
4195
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
4196
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
3882
4197
|
case 0:
|
|
3883
4198
|
paymentRecord = payment;
|
|
3884
4199
|
hasPaymentNumber = String(paymentRecord.payment_number || '').trim() !== '';
|
|
3885
4200
|
if (!hasPaymentNumber) {
|
|
3886
|
-
|
|
4201
|
+
_context39.next = 6;
|
|
3887
4202
|
break;
|
|
3888
4203
|
}
|
|
3889
|
-
|
|
3890
|
-
|
|
4204
|
+
_context39.t0 = 'LOCAL';
|
|
4205
|
+
_context39.next = 9;
|
|
3891
4206
|
break;
|
|
3892
4207
|
case 6:
|
|
3893
|
-
|
|
4208
|
+
_context39.next = 8;
|
|
3894
4209
|
return this.getPaymentNumberDevicePrefixAsync();
|
|
3895
4210
|
case 8:
|
|
3896
|
-
|
|
4211
|
+
_context39.t0 = _context39.sent;
|
|
3897
4212
|
case 9:
|
|
3898
|
-
devicePrefix =
|
|
3899
|
-
return
|
|
4213
|
+
devicePrefix = _context39.t0;
|
|
4214
|
+
return _context39.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
|
|
3900
4215
|
case 11:
|
|
3901
4216
|
case "end":
|
|
3902
|
-
return
|
|
4217
|
+
return _context39.stop();
|
|
3903
4218
|
}
|
|
3904
|
-
},
|
|
4219
|
+
}, _callee39, this);
|
|
3905
4220
|
}));
|
|
3906
4221
|
function addOrderPaymentAsync(_x30) {
|
|
3907
4222
|
return _addOrderPaymentAsync.apply(this, arguments);
|
|
@@ -3911,10 +4226,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3911
4226
|
}, {
|
|
3912
4227
|
key: "addOrderPaymentWithDevicePrefix",
|
|
3913
4228
|
value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
|
|
3914
|
-
var _this$
|
|
4229
|
+
var _this$otherParams33,
|
|
3915
4230
|
_paymentRecord$paymen,
|
|
3916
4231
|
_paymentRecord$create,
|
|
3917
|
-
|
|
4232
|
+
_ref41,
|
|
3918
4233
|
_paymentRecord$origin,
|
|
3919
4234
|
_this16 = this;
|
|
3920
4235
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
@@ -3927,7 +4242,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3927
4242
|
return this.store.order.getOrderPayments();
|
|
3928
4243
|
}
|
|
3929
4244
|
var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
|
|
3930
|
-
var shopWalletPassId = (_this$
|
|
4245
|
+
var shopWalletPassId = (_this$otherParams33 = this.otherParams) === null || _this$otherParams33 === void 0 ? void 0 : _this$otherParams33.shop_wallet_pass_id;
|
|
3931
4246
|
if (shopWalletPassId !== undefined && shopWalletPassId !== null) {
|
|
3932
4247
|
metadata.shop_wallet_pass_id = shopWalletPassId;
|
|
3933
4248
|
}
|
|
@@ -3936,7 +4251,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3936
4251
|
var paymentTime = (_paymentRecord$paymen = paymentRecord.payment_time) !== null && _paymentRecord$paymen !== void 0 ? _paymentRecord$paymen : paymentTimestamp;
|
|
3937
4252
|
var createdAt = (_paymentRecord$create = paymentRecord.created_at) !== null && _paymentRecord$create !== void 0 ? _paymentRecord$create : paymentTimestamp;
|
|
3938
4253
|
var serviceCharge = paymentRecord.service_charge && _typeof(paymentRecord.service_charge) === 'object' ? paymentRecord.service_charge : null;
|
|
3939
|
-
var calculatedServiceFee = serviceCharge ? new Decimal((
|
|
4254
|
+
var calculatedServiceFee = serviceCharge ? new Decimal((_ref41 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref41 !== void 0 ? _ref41 : 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
|
|
3940
4255
|
var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread({}, normalizedPaymentRecord), calculatedServiceFee !== undefined ? {
|
|
3941
4256
|
service_fee: calculatedServiceFee
|
|
3942
4257
|
} : {}), {}, {
|
|
@@ -3972,7 +4287,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3972
4287
|
}, {
|
|
3973
4288
|
key: "updateOrderPayment",
|
|
3974
4289
|
value: (function () {
|
|
3975
|
-
var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4290
|
+
var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(paymentIdentity, updates) {
|
|
3976
4291
|
var _result$payment, _result$payment2;
|
|
3977
4292
|
var options,
|
|
3978
4293
|
matchMode,
|
|
@@ -3989,13 +4304,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3989
4304
|
shouldSubmit,
|
|
3990
4305
|
syncResult,
|
|
3991
4306
|
_options$smallTicketD2,
|
|
3992
|
-
|
|
3993
|
-
return _regeneratorRuntime().wrap(function
|
|
3994
|
-
while (1) switch (
|
|
4307
|
+
_args40 = arguments;
|
|
4308
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
4309
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
3995
4310
|
case 0:
|
|
3996
|
-
options =
|
|
4311
|
+
options = _args40.length > 2 && _args40[2] !== undefined ? _args40[2] : {};
|
|
3997
4312
|
if (this.store.order) {
|
|
3998
|
-
|
|
4313
|
+
_context40.next = 3;
|
|
3999
4314
|
break;
|
|
4000
4315
|
}
|
|
4001
4316
|
throw new Error('order 模块未初始化');
|
|
@@ -4004,15 +4319,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4004
4319
|
previousMatch = resolveOrderPaymentIdentity(this.store.order.getOrderPayments(), paymentIdentity, matchMode);
|
|
4005
4320
|
previousPayment = previousMatch === null || previousMatch === void 0 ? void 0 : previousMatch.payment;
|
|
4006
4321
|
if (!((previousPayment === null || previousPayment === void 0 ? void 0 : previousPayment.status) === 'paid' && !options.applyUpdatesWhenPaid)) {
|
|
4007
|
-
|
|
4322
|
+
_context40.next = 13;
|
|
4008
4323
|
break;
|
|
4009
4324
|
}
|
|
4010
4325
|
currentPayments = this.store.order.getOrderPayments();
|
|
4011
4326
|
if (!(options.submitWhenPaid && options.forceSubmitIfPaid)) {
|
|
4012
|
-
|
|
4327
|
+
_context40.next = 12;
|
|
4013
4328
|
break;
|
|
4014
4329
|
}
|
|
4015
|
-
|
|
4330
|
+
_context40.next = 11;
|
|
4016
4331
|
return this.syncPaymentsToOrder({
|
|
4017
4332
|
payments: currentPayments,
|
|
4018
4333
|
paymentStatus: this.getPaymentStatusForSync(currentPayments),
|
|
@@ -4020,9 +4335,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4020
4335
|
smallTicketDataFlag: (_options$smallTicketD = options.smallTicketDataFlag) !== null && _options$smallTicketD !== void 0 ? _options$smallTicketD : 1
|
|
4021
4336
|
});
|
|
4022
4337
|
case 11:
|
|
4023
|
-
_syncResult =
|
|
4338
|
+
_syncResult = _context40.sent;
|
|
4024
4339
|
case 12:
|
|
4025
|
-
return
|
|
4340
|
+
return _context40.abrupt("return", _objectSpread({
|
|
4026
4341
|
updated: false,
|
|
4027
4342
|
payment: previousPayment,
|
|
4028
4343
|
payments: currentPayments,
|
|
@@ -4031,44 +4346,44 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4031
4346
|
syncResult: _syncResult
|
|
4032
4347
|
} : {}));
|
|
4033
4348
|
case 13:
|
|
4034
|
-
|
|
4349
|
+
_context40.next = 15;
|
|
4035
4350
|
return this.store.order.updateOrderPayment(paymentIdentity, updates, {
|
|
4036
4351
|
matchBy: matchMode
|
|
4037
4352
|
});
|
|
4038
4353
|
case 15:
|
|
4039
|
-
result =
|
|
4354
|
+
result = _context40.sent;
|
|
4040
4355
|
if (!(options.persistDraft !== false)) {
|
|
4041
|
-
|
|
4356
|
+
_context40.next = 29;
|
|
4042
4357
|
break;
|
|
4043
4358
|
}
|
|
4044
|
-
|
|
4045
|
-
|
|
4359
|
+
_context40.prev = 17;
|
|
4360
|
+
_context40.next = 20;
|
|
4046
4361
|
return this.saveSalesOrderDraft();
|
|
4047
4362
|
case 20:
|
|
4048
|
-
draftResult =
|
|
4049
|
-
|
|
4363
|
+
draftResult = _context40.sent;
|
|
4364
|
+
_context40.next = 29;
|
|
4050
4365
|
break;
|
|
4051
4366
|
case 23:
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
draftError =
|
|
4367
|
+
_context40.prev = 23;
|
|
4368
|
+
_context40.t0 = _context40["catch"](17);
|
|
4369
|
+
draftError = _context40.t0;
|
|
4055
4370
|
this.logError('updateOrderPayment: 保存支付草稿失败', {
|
|
4056
4371
|
paymentIdentity: paymentIdentity,
|
|
4057
|
-
error:
|
|
4372
|
+
error: _context40.t0 instanceof Error ? _context40.t0.message : String(_context40.t0)
|
|
4058
4373
|
});
|
|
4059
4374
|
if (options.submitWhenPaid) {
|
|
4060
|
-
|
|
4375
|
+
_context40.next = 29;
|
|
4061
4376
|
break;
|
|
4062
4377
|
}
|
|
4063
|
-
throw
|
|
4378
|
+
throw _context40.t0;
|
|
4064
4379
|
case 29:
|
|
4065
4380
|
becamePaid = (previousPayment === null || previousPayment === void 0 ? void 0 : previousPayment.status) !== 'paid' && ((_result$payment = result.payment) === null || _result$payment === void 0 ? void 0 : _result$payment.status) === 'paid';
|
|
4066
4381
|
shouldSubmit = Boolean(options.submitWhenPaid && ((_result$payment2 = result.payment) === null || _result$payment2 === void 0 ? void 0 : _result$payment2.status) === 'paid' && (becamePaid || options.forceSubmitIfPaid));
|
|
4067
4382
|
if (!shouldSubmit) {
|
|
4068
|
-
|
|
4383
|
+
_context40.next = 35;
|
|
4069
4384
|
break;
|
|
4070
4385
|
}
|
|
4071
|
-
|
|
4386
|
+
_context40.next = 34;
|
|
4072
4387
|
return this.syncPaymentsToOrder({
|
|
4073
4388
|
payments: result.payments,
|
|
4074
4389
|
paymentStatus: this.getPaymentStatusForSync(result.payments),
|
|
@@ -4076,9 +4391,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4076
4391
|
smallTicketDataFlag: (_options$smallTicketD2 = options.smallTicketDataFlag) !== null && _options$smallTicketD2 !== void 0 ? _options$smallTicketD2 : 1
|
|
4077
4392
|
});
|
|
4078
4393
|
case 34:
|
|
4079
|
-
syncResult =
|
|
4394
|
+
syncResult = _context40.sent;
|
|
4080
4395
|
case 35:
|
|
4081
|
-
return
|
|
4396
|
+
return _context40.abrupt("return", _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, result), draftResult !== undefined ? {
|
|
4082
4397
|
draftResult: draftResult
|
|
4083
4398
|
} : {}), draftError !== undefined ? {
|
|
4084
4399
|
draftError: draftError
|
|
@@ -4087,9 +4402,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4087
4402
|
} : {}));
|
|
4088
4403
|
case 36:
|
|
4089
4404
|
case "end":
|
|
4090
|
-
return
|
|
4405
|
+
return _context40.stop();
|
|
4091
4406
|
}
|
|
4092
|
-
},
|
|
4407
|
+
}, _callee40, this, [[17, 23]]);
|
|
4093
4408
|
}));
|
|
4094
4409
|
function updateOrderPayment(_x31, _x32) {
|
|
4095
4410
|
return _updateOrderPayment.apply(this, arguments);
|
|
@@ -4113,22 +4428,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4113
4428
|
}, {
|
|
4114
4429
|
key: "updateVoucherOrderPaymentsAsync",
|
|
4115
4430
|
value: function () {
|
|
4116
|
-
var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4117
|
-
return _regeneratorRuntime().wrap(function
|
|
4118
|
-
while (1) switch (
|
|
4431
|
+
var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(payments, options) {
|
|
4432
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context41) {
|
|
4433
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
4119
4434
|
case 0:
|
|
4120
4435
|
if (this.store.order) {
|
|
4121
|
-
|
|
4436
|
+
_context41.next = 2;
|
|
4122
4437
|
break;
|
|
4123
4438
|
}
|
|
4124
4439
|
throw new Error('order 模块未初始化');
|
|
4125
4440
|
case 2:
|
|
4126
|
-
return
|
|
4441
|
+
return _context41.abrupt("return", this.store.order.updateVoucherOrderPaymentsAsync(payments, options));
|
|
4127
4442
|
case 3:
|
|
4128
4443
|
case "end":
|
|
4129
|
-
return
|
|
4444
|
+
return _context41.stop();
|
|
4130
4445
|
}
|
|
4131
|
-
},
|
|
4446
|
+
}, _callee41, this);
|
|
4132
4447
|
}));
|
|
4133
4448
|
function updateVoucherOrderPaymentsAsync(_x33, _x34) {
|
|
4134
4449
|
return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
|
|
@@ -4156,8 +4471,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4156
4471
|
}, {
|
|
4157
4472
|
key: "getWalletProductList",
|
|
4158
4473
|
value: function getWalletProductList() {
|
|
4159
|
-
var _this$store$
|
|
4160
|
-
var tempOrder = (_this$store$
|
|
4474
|
+
var _this$store$order8, _tempOrder$products;
|
|
4475
|
+
var tempOrder = (_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 ? void 0 : _this$store$order8.getTempOrder();
|
|
4161
4476
|
if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$products = tempOrder.products) !== null && _tempOrder$products !== void 0 && _tempOrder$products.length)) return [];
|
|
4162
4477
|
// 过滤出有 product_id的商品来,如果没有代表他是自定义商品,不需要参与 wallet
|
|
4163
4478
|
// debugger
|
|
@@ -4217,8 +4532,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4217
4532
|
}, {
|
|
4218
4533
|
key: "buildWalletInitBusinessData",
|
|
4219
4534
|
value: function buildWalletInitBusinessData(params) {
|
|
4220
|
-
var _this$store$
|
|
4221
|
-
var snapshot = (_this$store$
|
|
4535
|
+
var _this$store$order9, _params$order_wait_pa, _ref42, _tempOrder$is_price_i;
|
|
4536
|
+
var snapshot = (_this$store$order9 = this.store.order) === null || _this$store$order9 === void 0 ? void 0 : _this$store$order9.getOrderSnapshot();
|
|
4222
4537
|
var tempOrder = snapshot === null || snapshot === void 0 ? void 0 : snapshot.tempOrder;
|
|
4223
4538
|
var amount = snapshot === null || snapshot === void 0 ? void 0 : snapshot.amount;
|
|
4224
4539
|
if (!tempOrder || !amount) return null;
|
|
@@ -4233,7 +4548,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4233
4548
|
},
|
|
4234
4549
|
products: this.getWalletProductList(),
|
|
4235
4550
|
order_wait_pay_amount: (_params$order_wait_pa = params === null || params === void 0 ? void 0 : params.order_wait_pay_amount) !== null && _params$order_wait_pa !== void 0 ? _params$order_wait_pa : Number(amount.amountGap || 0),
|
|
4236
|
-
is_price_include_tax: (
|
|
4551
|
+
is_price_include_tax: (_ref42 = (_tempOrder$is_price_i = tempOrder.is_price_include_tax) !== null && _tempOrder$is_price_i !== void 0 ? _tempOrder$is_price_i : this.otherParams.is_price_include_tax) !== null && _ref42 !== void 0 ? _ref42 : 1
|
|
4237
4552
|
}, snapshot.identity.orderId ? {
|
|
4238
4553
|
payment_order_id: String(snapshot.identity.orderId)
|
|
4239
4554
|
} : {});
|
|
@@ -4241,20 +4556,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4241
4556
|
}, {
|
|
4242
4557
|
key: "initWalletData",
|
|
4243
4558
|
value: function () {
|
|
4244
|
-
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4559
|
+
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
|
|
4245
4560
|
var _snapshot$identity;
|
|
4246
4561
|
var snapshot, walletBusinessData, result;
|
|
4247
|
-
return _regeneratorRuntime().wrap(function
|
|
4248
|
-
while (1) switch (
|
|
4562
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context42) {
|
|
4563
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
4249
4564
|
case 0:
|
|
4250
4565
|
if (this.store.order) {
|
|
4251
|
-
|
|
4566
|
+
_context42.next = 2;
|
|
4252
4567
|
break;
|
|
4253
4568
|
}
|
|
4254
4569
|
throw new Error('order 模块未初始化');
|
|
4255
4570
|
case 2:
|
|
4256
4571
|
if (this.store.payment) {
|
|
4257
|
-
|
|
4572
|
+
_context42.next = 4;
|
|
4258
4573
|
break;
|
|
4259
4574
|
}
|
|
4260
4575
|
throw new Error('payment 模块未初始化');
|
|
@@ -4262,10 +4577,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4262
4577
|
snapshot = this.store.order.getOrderSnapshot();
|
|
4263
4578
|
walletBusinessData = this.buildWalletInitBusinessData(params);
|
|
4264
4579
|
if (walletBusinessData) {
|
|
4265
|
-
|
|
4580
|
+
_context42.next = 8;
|
|
4266
4581
|
break;
|
|
4267
4582
|
}
|
|
4268
|
-
return
|
|
4583
|
+
return _context42.abrupt("return", {
|
|
4269
4584
|
walletRecommendList: [],
|
|
4270
4585
|
userIdentificationCodes: [],
|
|
4271
4586
|
transformList: [],
|
|
@@ -4273,11 +4588,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4273
4588
|
products: []
|
|
4274
4589
|
});
|
|
4275
4590
|
case 8:
|
|
4276
|
-
|
|
4591
|
+
_context42.next = 10;
|
|
4277
4592
|
return this.store.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
|
|
4278
4593
|
case 10:
|
|
4279
|
-
result =
|
|
4280
|
-
|
|
4594
|
+
result = _context42.sent;
|
|
4595
|
+
_context42.next = 13;
|
|
4281
4596
|
return this.core.effects.emit("".concat(this.name, ":onWalletDataInitialized"), {
|
|
4282
4597
|
orderId: snapshot === null || snapshot === void 0 || (_snapshot$identity = snapshot.identity) === null || _snapshot$identity === void 0 ? void 0 : _snapshot$identity.orderId,
|
|
4283
4598
|
customerId: walletBusinessData.customer_id,
|
|
@@ -4289,12 +4604,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4289
4604
|
timestamp: Date.now()
|
|
4290
4605
|
});
|
|
4291
4606
|
case 13:
|
|
4292
|
-
return
|
|
4607
|
+
return _context42.abrupt("return", result);
|
|
4293
4608
|
case 14:
|
|
4294
4609
|
case "end":
|
|
4295
|
-
return
|
|
4610
|
+
return _context42.stop();
|
|
4296
4611
|
}
|
|
4297
|
-
},
|
|
4612
|
+
}, _callee42, this);
|
|
4298
4613
|
}));
|
|
4299
4614
|
function initWalletData(_x35) {
|
|
4300
4615
|
return _initWalletData.apply(this, arguments);
|
|
@@ -4304,8 +4619,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4304
4619
|
}, {
|
|
4305
4620
|
key: "getCommittedWalletAssets",
|
|
4306
4621
|
value: function getCommittedWalletAssets() {
|
|
4307
|
-
var _this$store$
|
|
4308
|
-
var payments = ((_this$store$
|
|
4622
|
+
var _this$store$order10, _this$store$order10$g;
|
|
4623
|
+
var payments = ((_this$store$order10 = this.store.order) === null || _this$store$order10 === void 0 || (_this$store$order10$g = _this$store$order10.getOrderPayments) === null || _this$store$order10$g === void 0 ? void 0 : _this$store$order10$g.call(_this$store$order10)) || [];
|
|
4309
4624
|
var committed = payments.filter(function (payment) {
|
|
4310
4625
|
var voucherId = payment === null || payment === void 0 ? void 0 : payment.voucher_id;
|
|
4311
4626
|
if (voucherId === undefined || voucherId === null || voucherId === 0) {
|
|
@@ -4323,9 +4638,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4323
4638
|
var walletPassName = fundRecord.wallet_pass_name;
|
|
4324
4639
|
var title = walletPassName && _typeof(walletPassName) === 'object' ? walletPassName.default || Object.values(walletPassName)[0] : walletPassName;
|
|
4325
4640
|
var code = String((payment === null || payment === void 0 ? void 0 : payment.code) || '').toUpperCase();
|
|
4326
|
-
var tag = ((_Object$entries$find = Object.entries(WALLET_PAYMENT_CODE_BY_TAG).find(function (
|
|
4327
|
-
var
|
|
4328
|
-
paymentCode =
|
|
4641
|
+
var tag = ((_Object$entries$find = Object.entries(WALLET_PAYMENT_CODE_BY_TAG).find(function (_ref43) {
|
|
4642
|
+
var _ref44 = _slicedToArray(_ref43, 2),
|
|
4643
|
+
paymentCode = _ref44[1];
|
|
4329
4644
|
return paymentCode === code;
|
|
4330
4645
|
})) === null || _Object$entries$find === void 0 ? void 0 : _Object$entries$find[0]) || fundRecord.tag;
|
|
4331
4646
|
return {
|
|
@@ -4347,21 +4662,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4347
4662
|
}, {
|
|
4348
4663
|
key: "publishWalletAssetsState",
|
|
4349
4664
|
value: function () {
|
|
4350
|
-
var _publishWalletAssetsState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4351
|
-
return _regeneratorRuntime().wrap(function
|
|
4352
|
-
while (1) switch (
|
|
4665
|
+
var _publishWalletAssetsState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(state) {
|
|
4666
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context43) {
|
|
4667
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
4353
4668
|
case 0:
|
|
4354
|
-
|
|
4669
|
+
_context43.next = 2;
|
|
4355
4670
|
return this.effectsEmit(BaseSalesHookNames.onWalletAssetsStateChanged, {
|
|
4356
4671
|
state: state
|
|
4357
4672
|
});
|
|
4358
4673
|
case 2:
|
|
4359
|
-
return
|
|
4674
|
+
return _context43.abrupt("return", state);
|
|
4360
4675
|
case 3:
|
|
4361
4676
|
case "end":
|
|
4362
|
-
return
|
|
4677
|
+
return _context43.stop();
|
|
4363
4678
|
}
|
|
4364
|
-
},
|
|
4679
|
+
}, _callee43, this);
|
|
4365
4680
|
}));
|
|
4366
4681
|
function publishWalletAssetsState(_x36) {
|
|
4367
4682
|
return _publishWalletAssetsState.apply(this, arguments);
|
|
@@ -4371,26 +4686,26 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4371
4686
|
}, {
|
|
4372
4687
|
key: "syncSelectedWalletAssets",
|
|
4373
4688
|
value: function () {
|
|
4374
|
-
var _syncSelectedWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4689
|
+
var _syncSelectedWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(state) {
|
|
4375
4690
|
var paymentMethods, methodByCode, preparePayments, selectedAssetById, voucherPayments, payments;
|
|
4376
|
-
return _regeneratorRuntime().wrap(function
|
|
4377
|
-
while (1) switch (
|
|
4691
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context44) {
|
|
4692
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
4378
4693
|
case 0:
|
|
4379
4694
|
if (!(!this.store.order || !this.store.payment)) {
|
|
4380
|
-
|
|
4695
|
+
_context44.next = 2;
|
|
4381
4696
|
break;
|
|
4382
4697
|
}
|
|
4383
4698
|
throw new Error('订单或支付模块未初始化');
|
|
4384
4699
|
case 2:
|
|
4385
4700
|
paymentMethods = this.getPaymentMethods();
|
|
4386
4701
|
if (!(!paymentMethods.length && state.selectedItems.length)) {
|
|
4387
|
-
|
|
4702
|
+
_context44.next = 7;
|
|
4388
4703
|
break;
|
|
4389
4704
|
}
|
|
4390
|
-
|
|
4705
|
+
_context44.next = 6;
|
|
4391
4706
|
return this.getPaymentMethodsAsync();
|
|
4392
4707
|
case 6:
|
|
4393
|
-
paymentMethods =
|
|
4708
|
+
paymentMethods = _context44.sent;
|
|
4394
4709
|
case 7:
|
|
4395
4710
|
methodByCode = new Map(paymentMethods.map(function (method) {
|
|
4396
4711
|
return [String(method.code || '').toUpperCase(), method];
|
|
@@ -4432,17 +4747,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4432
4747
|
payments = this.updateVoucherOrderPayments(voucherPayments, {
|
|
4433
4748
|
status: 'payment_pending'
|
|
4434
4749
|
});
|
|
4435
|
-
|
|
4750
|
+
_context44.next = 14;
|
|
4436
4751
|
return this.store.order.recalculateSummary({
|
|
4437
4752
|
createIfMissing: true
|
|
4438
4753
|
});
|
|
4439
4754
|
case 14:
|
|
4440
|
-
return
|
|
4755
|
+
return _context44.abrupt("return", payments);
|
|
4441
4756
|
case 15:
|
|
4442
4757
|
case "end":
|
|
4443
|
-
return
|
|
4758
|
+
return _context44.stop();
|
|
4444
4759
|
}
|
|
4445
|
-
},
|
|
4760
|
+
}, _callee44, this);
|
|
4446
4761
|
}));
|
|
4447
4762
|
function syncSelectedWalletAssets(_x37) {
|
|
4448
4763
|
return _syncSelectedWalletAssets.apply(this, arguments);
|
|
@@ -4478,27 +4793,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4478
4793
|
}, {
|
|
4479
4794
|
key: "importWalletAssetsSnapshot",
|
|
4480
4795
|
value: (function () {
|
|
4481
|
-
var _importWalletAssetsSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4796
|
+
var _importWalletAssetsSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(snapshot) {
|
|
4482
4797
|
var state;
|
|
4483
|
-
return _regeneratorRuntime().wrap(function
|
|
4484
|
-
while (1) switch (
|
|
4798
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context45) {
|
|
4799
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
4485
4800
|
case 0:
|
|
4486
4801
|
if (this.store.payment) {
|
|
4487
|
-
|
|
4802
|
+
_context45.next = 2;
|
|
4488
4803
|
break;
|
|
4489
4804
|
}
|
|
4490
4805
|
throw new Error('payment 模块未初始化');
|
|
4491
4806
|
case 2:
|
|
4492
4807
|
state = this.store.payment.wallet.importWalletAssetsSnapshot(snapshot);
|
|
4493
|
-
|
|
4808
|
+
_context45.next = 5;
|
|
4494
4809
|
return this.syncSelectedWalletAssets(state);
|
|
4495
4810
|
case 5:
|
|
4496
|
-
return
|
|
4811
|
+
return _context45.abrupt("return", this.publishWalletAssetsState(state));
|
|
4497
4812
|
case 6:
|
|
4498
4813
|
case "end":
|
|
4499
|
-
return
|
|
4814
|
+
return _context45.stop();
|
|
4500
4815
|
}
|
|
4501
|
-
},
|
|
4816
|
+
}, _callee45, this);
|
|
4502
4817
|
}));
|
|
4503
4818
|
function importWalletAssetsSnapshot(_x38) {
|
|
4504
4819
|
return _importWalletAssetsSnapshot.apply(this, arguments);
|
|
@@ -4512,20 +4827,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4512
4827
|
}, {
|
|
4513
4828
|
key: "refreshWalletAssets",
|
|
4514
4829
|
value: (function () {
|
|
4515
|
-
var _refreshWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4830
|
+
var _refreshWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(params) {
|
|
4516
4831
|
var _previousState$custom, _businessData$custome;
|
|
4517
4832
|
var refreshSequence, wallet, businessData, emptyState, previousState, hasPreviousWalletContext, customerChanged, clearedState, refreshTask, state, committed;
|
|
4518
|
-
return _regeneratorRuntime().wrap(function
|
|
4519
|
-
while (1) switch (
|
|
4833
|
+
return _regeneratorRuntime().wrap(function _callee46$(_context46) {
|
|
4834
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
4520
4835
|
case 0:
|
|
4521
4836
|
if (this.store.order) {
|
|
4522
|
-
|
|
4837
|
+
_context46.next = 2;
|
|
4523
4838
|
break;
|
|
4524
4839
|
}
|
|
4525
4840
|
throw new Error('order 模块未初始化');
|
|
4526
4841
|
case 2:
|
|
4527
4842
|
if (this.store.payment) {
|
|
4528
|
-
|
|
4843
|
+
_context46.next = 4;
|
|
4529
4844
|
break;
|
|
4530
4845
|
}
|
|
4531
4846
|
throw new Error('payment 模块未初始化');
|
|
@@ -4534,7 +4849,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4534
4849
|
wallet = this.store.payment.wallet;
|
|
4535
4850
|
businessData = this.buildWalletInitBusinessData(params);
|
|
4536
4851
|
if (businessData) {
|
|
4537
|
-
|
|
4852
|
+
_context46.next = 12;
|
|
4538
4853
|
break;
|
|
4539
4854
|
}
|
|
4540
4855
|
wallet.clearAllCache();
|
|
@@ -4542,51 +4857,51 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4542
4857
|
this.updateVoucherOrderPayments([], {
|
|
4543
4858
|
status: 'payment_pending'
|
|
4544
4859
|
});
|
|
4545
|
-
return
|
|
4860
|
+
return _context46.abrupt("return", this.publishWalletAssetsState(emptyState));
|
|
4546
4861
|
case 12:
|
|
4547
4862
|
previousState = wallet.getWalletAssetsState();
|
|
4548
4863
|
hasPreviousWalletContext = previousState.status !== 'idle' || previousState.items.length > 0 || previousState.selectedIds.length > 0 || previousState.customerId !== undefined;
|
|
4549
4864
|
customerChanged = hasPreviousWalletContext && String((_previousState$custom = previousState.customerId) !== null && _previousState$custom !== void 0 ? _previousState$custom : '') !== String((_businessData$custome = businessData.customer_id) !== null && _businessData$custome !== void 0 ? _businessData$custome : '');
|
|
4550
4865
|
if (!customerChanged) {
|
|
4551
|
-
|
|
4866
|
+
_context46.next = 20;
|
|
4552
4867
|
break;
|
|
4553
4868
|
}
|
|
4554
4869
|
clearedState = wallet.clearWalletAssetSelection();
|
|
4555
4870
|
this.updateVoucherOrderPayments([], {
|
|
4556
4871
|
status: 'payment_pending'
|
|
4557
4872
|
});
|
|
4558
|
-
|
|
4873
|
+
_context46.next = 20;
|
|
4559
4874
|
return this.publishWalletAssetsState(clearedState);
|
|
4560
4875
|
case 20:
|
|
4561
4876
|
refreshTask = wallet.refreshWalletAssetsFromBusinessAsync(businessData, {
|
|
4562
4877
|
preserveSelection: (params === null || params === void 0 ? void 0 : params.preserveSelection) !== false && !customerChanged
|
|
4563
4878
|
});
|
|
4564
|
-
|
|
4879
|
+
_context46.next = 23;
|
|
4565
4880
|
return this.publishWalletAssetsState(wallet.getWalletAssetsState());
|
|
4566
4881
|
case 23:
|
|
4567
|
-
|
|
4882
|
+
_context46.next = 25;
|
|
4568
4883
|
return refreshTask;
|
|
4569
4884
|
case 25:
|
|
4570
|
-
state =
|
|
4885
|
+
state = _context46.sent;
|
|
4571
4886
|
if (!(refreshSequence !== this.walletAssetsRefreshSequence)) {
|
|
4572
|
-
|
|
4887
|
+
_context46.next = 28;
|
|
4573
4888
|
break;
|
|
4574
4889
|
}
|
|
4575
|
-
return
|
|
4890
|
+
return _context46.abrupt("return", wallet.getWalletAssetsState());
|
|
4576
4891
|
case 28:
|
|
4577
4892
|
if (state.status !== 'error') {
|
|
4578
4893
|
committed = this.getCommittedWalletAssets();
|
|
4579
4894
|
state = wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
4580
4895
|
}
|
|
4581
|
-
|
|
4896
|
+
_context46.next = 31;
|
|
4582
4897
|
return this.syncSelectedWalletAssets(state);
|
|
4583
4898
|
case 31:
|
|
4584
|
-
return
|
|
4899
|
+
return _context46.abrupt("return", this.publishWalletAssetsState(state));
|
|
4585
4900
|
case 32:
|
|
4586
4901
|
case "end":
|
|
4587
|
-
return
|
|
4902
|
+
return _context46.stop();
|
|
4588
4903
|
}
|
|
4589
|
-
},
|
|
4904
|
+
}, _callee46, this);
|
|
4590
4905
|
}));
|
|
4591
4906
|
function refreshWalletAssets(_x39) {
|
|
4592
4907
|
return _refreshWalletAssets.apply(this, arguments);
|
|
@@ -4596,13 +4911,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4596
4911
|
}, {
|
|
4597
4912
|
key: "selectWalletAsset",
|
|
4598
4913
|
value: (function () {
|
|
4599
|
-
var _selectWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4914
|
+
var _selectWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(params) {
|
|
4600
4915
|
var state;
|
|
4601
|
-
return _regeneratorRuntime().wrap(function
|
|
4602
|
-
while (1) switch (
|
|
4916
|
+
return _regeneratorRuntime().wrap(function _callee47$(_context47) {
|
|
4917
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
4603
4918
|
case 0:
|
|
4604
4919
|
if (this.store.payment) {
|
|
4605
|
-
|
|
4920
|
+
_context47.next = 2;
|
|
4606
4921
|
break;
|
|
4607
4922
|
}
|
|
4608
4923
|
throw new Error('payment 模块未初始化');
|
|
@@ -4611,15 +4926,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4611
4926
|
selected: params.selected,
|
|
4612
4927
|
source: params.source
|
|
4613
4928
|
});
|
|
4614
|
-
|
|
4929
|
+
_context47.next = 5;
|
|
4615
4930
|
return this.syncSelectedWalletAssets(state);
|
|
4616
4931
|
case 5:
|
|
4617
|
-
return
|
|
4932
|
+
return _context47.abrupt("return", this.publishWalletAssetsState(state));
|
|
4618
4933
|
case 6:
|
|
4619
4934
|
case "end":
|
|
4620
|
-
return
|
|
4935
|
+
return _context47.stop();
|
|
4621
4936
|
}
|
|
4622
|
-
},
|
|
4937
|
+
}, _callee47, this);
|
|
4623
4938
|
}));
|
|
4624
4939
|
function selectWalletAsset(_x40) {
|
|
4625
4940
|
return _selectWalletAsset.apply(this, arguments);
|
|
@@ -4629,27 +4944,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4629
4944
|
}, {
|
|
4630
4945
|
key: "updateWalletAssetAmount",
|
|
4631
4946
|
value: (function () {
|
|
4632
|
-
var _updateWalletAssetAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4947
|
+
var _updateWalletAssetAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(params) {
|
|
4633
4948
|
var state;
|
|
4634
|
-
return _regeneratorRuntime().wrap(function
|
|
4635
|
-
while (1) switch (
|
|
4949
|
+
return _regeneratorRuntime().wrap(function _callee48$(_context48) {
|
|
4950
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
4636
4951
|
case 0:
|
|
4637
4952
|
if (this.store.payment) {
|
|
4638
|
-
|
|
4953
|
+
_context48.next = 2;
|
|
4639
4954
|
break;
|
|
4640
4955
|
}
|
|
4641
4956
|
throw new Error('payment 模块未初始化');
|
|
4642
4957
|
case 2:
|
|
4643
4958
|
state = this.store.payment.wallet.updateWalletAssetAmount(params.assetId, params.amount);
|
|
4644
|
-
|
|
4959
|
+
_context48.next = 5;
|
|
4645
4960
|
return this.syncSelectedWalletAssets(state);
|
|
4646
4961
|
case 5:
|
|
4647
|
-
return
|
|
4962
|
+
return _context48.abrupt("return", this.publishWalletAssetsState(state));
|
|
4648
4963
|
case 6:
|
|
4649
4964
|
case "end":
|
|
4650
|
-
return
|
|
4965
|
+
return _context48.stop();
|
|
4651
4966
|
}
|
|
4652
|
-
},
|
|
4967
|
+
}, _callee48, this);
|
|
4653
4968
|
}));
|
|
4654
4969
|
function updateWalletAssetAmount(_x41) {
|
|
4655
4970
|
return _updateWalletAssetAmount.apply(this, arguments);
|
|
@@ -4659,13 +4974,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4659
4974
|
}, {
|
|
4660
4975
|
key: "scanWalletAsset",
|
|
4661
4976
|
value: (function () {
|
|
4662
|
-
var _scanWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4977
|
+
var _scanWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(code) {
|
|
4663
4978
|
var wallet, businessData, result;
|
|
4664
|
-
return _regeneratorRuntime().wrap(function
|
|
4665
|
-
while (1) switch (
|
|
4979
|
+
return _regeneratorRuntime().wrap(function _callee49$(_context49) {
|
|
4980
|
+
while (1) switch (_context49.prev = _context49.next) {
|
|
4666
4981
|
case 0:
|
|
4667
4982
|
if (this.store.payment) {
|
|
4668
|
-
|
|
4983
|
+
_context49.next = 2;
|
|
4669
4984
|
break;
|
|
4670
4985
|
}
|
|
4671
4986
|
throw new Error('payment 模块未初始化');
|
|
@@ -4675,26 +4990,26 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4675
4990
|
if (businessData) {
|
|
4676
4991
|
wallet.generateWalletParams(businessData);
|
|
4677
4992
|
}
|
|
4678
|
-
|
|
4993
|
+
_context49.next = 7;
|
|
4679
4994
|
return wallet.scanWalletAssetAsync(code);
|
|
4680
4995
|
case 7:
|
|
4681
|
-
result =
|
|
4996
|
+
result = _context49.sent;
|
|
4682
4997
|
if (!(result.type === 'normalCode')) {
|
|
4683
|
-
|
|
4998
|
+
_context49.next = 13;
|
|
4684
4999
|
break;
|
|
4685
5000
|
}
|
|
4686
|
-
|
|
5001
|
+
_context49.next = 11;
|
|
4687
5002
|
return this.syncSelectedWalletAssets(result.state);
|
|
4688
5003
|
case 11:
|
|
4689
|
-
|
|
5004
|
+
_context49.next = 13;
|
|
4690
5005
|
return this.publishWalletAssetsState(result.state);
|
|
4691
5006
|
case 13:
|
|
4692
|
-
return
|
|
5007
|
+
return _context49.abrupt("return", result);
|
|
4693
5008
|
case 14:
|
|
4694
5009
|
case "end":
|
|
4695
|
-
return
|
|
5010
|
+
return _context49.stop();
|
|
4696
5011
|
}
|
|
4697
|
-
},
|
|
5012
|
+
}, _callee49, this);
|
|
4698
5013
|
}));
|
|
4699
5014
|
function scanWalletAsset(_x42) {
|
|
4700
5015
|
return _scanWalletAsset.apply(this, arguments);
|
|
@@ -4704,27 +5019,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4704
5019
|
}, {
|
|
4705
5020
|
key: "clearWalletAssetSelection",
|
|
4706
5021
|
value: (function () {
|
|
4707
|
-
var _clearWalletAssetSelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5022
|
+
var _clearWalletAssetSelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50() {
|
|
4708
5023
|
var state;
|
|
4709
|
-
return _regeneratorRuntime().wrap(function
|
|
4710
|
-
while (1) switch (
|
|
5024
|
+
return _regeneratorRuntime().wrap(function _callee50$(_context50) {
|
|
5025
|
+
while (1) switch (_context50.prev = _context50.next) {
|
|
4711
5026
|
case 0:
|
|
4712
5027
|
if (this.store.payment) {
|
|
4713
|
-
|
|
5028
|
+
_context50.next = 2;
|
|
4714
5029
|
break;
|
|
4715
5030
|
}
|
|
4716
5031
|
throw new Error('payment 模块未初始化');
|
|
4717
5032
|
case 2:
|
|
4718
5033
|
state = this.store.payment.wallet.clearWalletAssetSelection();
|
|
4719
|
-
|
|
5034
|
+
_context50.next = 5;
|
|
4720
5035
|
return this.syncSelectedWalletAssets(state);
|
|
4721
5036
|
case 5:
|
|
4722
|
-
return
|
|
5037
|
+
return _context50.abrupt("return", this.publishWalletAssetsState(state));
|
|
4723
5038
|
case 6:
|
|
4724
5039
|
case "end":
|
|
4725
|
-
return
|
|
5040
|
+
return _context50.stop();
|
|
4726
5041
|
}
|
|
4727
|
-
},
|
|
5042
|
+
}, _callee50, this);
|
|
4728
5043
|
}));
|
|
4729
5044
|
function clearWalletAssetSelection() {
|
|
4730
5045
|
return _clearWalletAssetSelection.apply(this, arguments);
|
|
@@ -4754,35 +5069,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4754
5069
|
}, {
|
|
4755
5070
|
key: "getPaymentMethodsAsync",
|
|
4756
5071
|
value: (function () {
|
|
4757
|
-
var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5072
|
+
var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51() {
|
|
4758
5073
|
var response, paymentMethods;
|
|
4759
|
-
return _regeneratorRuntime().wrap(function
|
|
4760
|
-
while (1) switch (
|
|
5074
|
+
return _regeneratorRuntime().wrap(function _callee51$(_context51) {
|
|
5075
|
+
while (1) switch (_context51.prev = _context51.next) {
|
|
4761
5076
|
case 0:
|
|
4762
|
-
|
|
4763
|
-
|
|
5077
|
+
_context51.prev = 0;
|
|
5078
|
+
_context51.next = 3;
|
|
4764
5079
|
return this.request.get('/pay/custom-payment/all', {
|
|
4765
5080
|
filterPaymentMethods: true
|
|
4766
5081
|
}, {
|
|
4767
5082
|
osServer: true
|
|
4768
5083
|
});
|
|
4769
5084
|
case 3:
|
|
4770
|
-
response =
|
|
5085
|
+
response = _context51.sent;
|
|
4771
5086
|
paymentMethods = (response === null || response === void 0 ? void 0 : response.data) || [];
|
|
4772
5087
|
this.paymentMethodsCache = Array.isArray(paymentMethods) ? _toConsumableArray(paymentMethods) : [];
|
|
4773
|
-
return
|
|
5088
|
+
return _context51.abrupt("return", this.getPaymentMethods());
|
|
4774
5089
|
case 9:
|
|
4775
|
-
|
|
4776
|
-
|
|
5090
|
+
_context51.prev = 9;
|
|
5091
|
+
_context51.t0 = _context51["catch"](0);
|
|
4777
5092
|
this.logWarning('getPaymentMethodsAsync: 获取支付方式列表失败,使用缓存列表', {
|
|
4778
|
-
error:
|
|
5093
|
+
error: _context51.t0 instanceof Error ? _context51.t0.message : String(_context51.t0)
|
|
4779
5094
|
});
|
|
4780
|
-
return
|
|
5095
|
+
return _context51.abrupt("return", this.getPaymentMethods());
|
|
4781
5096
|
case 13:
|
|
4782
5097
|
case "end":
|
|
4783
|
-
return
|
|
5098
|
+
return _context51.stop();
|
|
4784
5099
|
}
|
|
4785
|
-
},
|
|
5100
|
+
}, _callee51, this, [[0, 9]]);
|
|
4786
5101
|
}));
|
|
4787
5102
|
function getPaymentMethodsAsync() {
|
|
4788
5103
|
return _getPaymentMethodsAsync.apply(this, arguments);
|
|
@@ -4807,8 +5122,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4807
5122
|
}, {
|
|
4808
5123
|
key: "getPendingWalletPaymentAmount",
|
|
4809
5124
|
value: function getPendingWalletPaymentAmount() {
|
|
4810
|
-
var _this$store$
|
|
4811
|
-
var payments = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ((_this$store$
|
|
5125
|
+
var _this$store$order11, _this$store$order11$g;
|
|
5126
|
+
var payments = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ((_this$store$order11 = this.store.order) === null || _this$store$order11 === void 0 || (_this$store$order11$g = _this$store$order11.getOrderPayments) === null || _this$store$order11$g === void 0 ? void 0 : _this$store$order11$g.call(_this$store$order11)) || [];
|
|
4812
5127
|
return payments.reduce(function (total, payment) {
|
|
4813
5128
|
if ((payment === null || payment === void 0 ? void 0 : payment.status) !== 'payment_pending' || (payment === null || payment === void 0 ? void 0 : payment.voucher_id) === undefined || Number(payment.voucher_id) === 0) {
|
|
4814
5129
|
return total;
|
|
@@ -4825,14 +5140,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4825
5140
|
}, {
|
|
4826
5141
|
key: "getCashPaymentConfig",
|
|
4827
5142
|
value: (function () {
|
|
4828
|
-
var _getCashPaymentConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4829
|
-
var _this$store$
|
|
5143
|
+
var _getCashPaymentConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52() {
|
|
5144
|
+
var _this$store$order12, _this$store$order12$g, _this$store$order13, _this$store$order13$g, _this$otherParams34;
|
|
4830
5145
|
var paymentMethods, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, currency, recommendedAmounts;
|
|
4831
|
-
return _regeneratorRuntime().wrap(function
|
|
4832
|
-
while (1) switch (
|
|
5146
|
+
return _regeneratorRuntime().wrap(function _callee52$(_context52) {
|
|
5147
|
+
while (1) switch (_context52.prev = _context52.next) {
|
|
4833
5148
|
case 0:
|
|
4834
5149
|
if (this.store.payment) {
|
|
4835
|
-
|
|
5150
|
+
_context52.next = 2;
|
|
4836
5151
|
break;
|
|
4837
5152
|
}
|
|
4838
5153
|
throw new Error('payment 模块未初始化');
|
|
@@ -4840,21 +5155,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4840
5155
|
paymentMethods = this.getPaymentMethods();
|
|
4841
5156
|
paymentMethod = this.findCashPaymentMethod(paymentMethods);
|
|
4842
5157
|
if (paymentMethod) {
|
|
4843
|
-
|
|
5158
|
+
_context52.next = 9;
|
|
4844
5159
|
break;
|
|
4845
5160
|
}
|
|
4846
|
-
|
|
5161
|
+
_context52.next = 7;
|
|
4847
5162
|
return this.getPaymentMethodsAsync();
|
|
4848
5163
|
case 7:
|
|
4849
|
-
paymentMethods =
|
|
5164
|
+
paymentMethods = _context52.sent;
|
|
4850
5165
|
paymentMethod = this.findCashPaymentMethod(paymentMethods);
|
|
4851
5166
|
case 9:
|
|
4852
|
-
amountSnapshot = (_this$store$
|
|
5167
|
+
amountSnapshot = (_this$store$order12 = this.store.order) === null || _this$store$order12 === void 0 || (_this$store$order12$g = _this$store$order12.getOrderAmountSnapshot) === null || _this$store$order12$g === void 0 ? void 0 : _this$store$order12$g.call(_this$store$order12);
|
|
4853
5168
|
pendingWalletAmount = this.getPendingWalletPaymentAmount();
|
|
4854
5169
|
amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0).toDecimalPlaces(2).toNumber();
|
|
4855
|
-
currency = ((_this$store$
|
|
5170
|
+
currency = ((_this$store$order13 = this.store.order) === null || _this$store$order13 === void 0 || (_this$store$order13$g = _this$store$order13.getTempOrder) === null || _this$store$order13$g === void 0 || (_this$store$order13$g = _this$store$order13$g.call(_this$store$order13)) === null || _this$store$order13$g === void 0 ? void 0 : _this$store$order13$g.currency_code) || ((_this$otherParams34 = this.otherParams) === null || _this$otherParams34 === void 0 ? void 0 : _this$otherParams34.currency) || 'USD';
|
|
4856
5171
|
recommendedAmounts = amountDue > 0 ? this.store.payment.cash.getRecommendedAmount(amountDue, currency) : [];
|
|
4857
|
-
return
|
|
5172
|
+
return _context52.abrupt("return", {
|
|
4858
5173
|
available: Boolean(paymentMethod && amountDue > 0),
|
|
4859
5174
|
paymentMethod: paymentMethod,
|
|
4860
5175
|
amountDue: amountDue,
|
|
@@ -4862,9 +5177,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4862
5177
|
});
|
|
4863
5178
|
case 15:
|
|
4864
5179
|
case "end":
|
|
4865
|
-
return
|
|
5180
|
+
return _context52.stop();
|
|
4866
5181
|
}
|
|
4867
|
-
},
|
|
5182
|
+
}, _callee52, this);
|
|
4868
5183
|
}));
|
|
4869
5184
|
function getCashPaymentConfig() {
|
|
4870
5185
|
return _getCashPaymentConfig.apply(this, arguments);
|
|
@@ -4881,14 +5196,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4881
5196
|
}, {
|
|
4882
5197
|
key: "confirmWalletPayment",
|
|
4883
5198
|
value: (function () {
|
|
4884
|
-
var _confirmWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4885
|
-
var _this$store$order$get3, _this$store$
|
|
5199
|
+
var _confirmWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53() {
|
|
5200
|
+
var _this$store$order$get3, _this$store$order14, _this$store$order$get4, _this$store$order$get5, _this$store$order15;
|
|
4886
5201
|
var beforePayments, pendingWalletAmount, amountSnapshot, effectiveAmountDue, beforePaymentStatus, submitResult, restoredTempOrder, committed, walletState, latestAmountSnapshot;
|
|
4887
|
-
return _regeneratorRuntime().wrap(function
|
|
4888
|
-
while (1) switch (
|
|
5202
|
+
return _regeneratorRuntime().wrap(function _callee53$(_context53) {
|
|
5203
|
+
while (1) switch (_context53.prev = _context53.next) {
|
|
4889
5204
|
case 0:
|
|
4890
5205
|
if (this.store.order) {
|
|
4891
|
-
|
|
5206
|
+
_context53.next = 2;
|
|
4892
5207
|
break;
|
|
4893
5208
|
}
|
|
4894
5209
|
throw new Error('order 模块未初始化');
|
|
@@ -4896,82 +5211,82 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4896
5211
|
beforePayments = cloneDeep(this.store.order.getOrderPayments());
|
|
4897
5212
|
pendingWalletAmount = this.getPendingWalletPaymentAmount(beforePayments);
|
|
4898
5213
|
if (!pendingWalletAmount.lte(0)) {
|
|
4899
|
-
|
|
5214
|
+
_context53.next = 6;
|
|
4900
5215
|
break;
|
|
4901
5216
|
}
|
|
4902
5217
|
throw new Error('当前订单没有待确认的 Wallet 支付');
|
|
4903
5218
|
case 6:
|
|
4904
|
-
amountSnapshot = (_this$store$order$get3 = (_this$store$
|
|
5219
|
+
amountSnapshot = (_this$store$order$get3 = (_this$store$order14 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get3 === void 0 ? void 0 : _this$store$order$get3.call(_this$store$order14);
|
|
4905
5220
|
effectiveAmountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
|
|
4906
5221
|
if (!effectiveAmountDue.gt(0.01)) {
|
|
4907
|
-
|
|
5222
|
+
_context53.next = 10;
|
|
4908
5223
|
break;
|
|
4909
5224
|
}
|
|
4910
5225
|
throw new Error('Wallet 支付尚未覆盖全部待支付金额');
|
|
4911
5226
|
case 10:
|
|
4912
5227
|
beforePaymentStatus = (_this$store$order$get4 = this.store.order.getTempOrder()) === null || _this$store$order$get4 === void 0 ? void 0 : _this$store$order$get4.payment_status;
|
|
4913
|
-
|
|
4914
|
-
|
|
5228
|
+
_context53.prev = 11;
|
|
5229
|
+
_context53.next = 14;
|
|
4915
5230
|
return this.submitSalesOrder({
|
|
4916
5231
|
smallTicketDataFlag: 1,
|
|
4917
5232
|
confirmPendingVoucherPayments: true
|
|
4918
5233
|
});
|
|
4919
5234
|
case 14:
|
|
4920
|
-
submitResult =
|
|
5235
|
+
submitResult = _context53.sent;
|
|
4921
5236
|
if (!isRejectedSalesSubmitResult(submitResult)) {
|
|
4922
|
-
|
|
5237
|
+
_context53.next = 17;
|
|
4923
5238
|
break;
|
|
4924
5239
|
}
|
|
4925
5240
|
throw new Error(getSalesSubmitErrorMessage(submitResult, 'Wallet 支付确认失败'));
|
|
4926
5241
|
case 17:
|
|
4927
|
-
|
|
5242
|
+
_context53.next = 27;
|
|
4928
5243
|
break;
|
|
4929
5244
|
case 19:
|
|
4930
|
-
|
|
4931
|
-
|
|
5245
|
+
_context53.prev = 19;
|
|
5246
|
+
_context53.t0 = _context53["catch"](11);
|
|
4932
5247
|
this.store.order.setOrderPayments(beforePayments);
|
|
4933
5248
|
restoredTempOrder = this.store.order.getTempOrder();
|
|
4934
5249
|
if (restoredTempOrder && beforePaymentStatus !== undefined) {
|
|
4935
5250
|
restoredTempOrder.payment_status = beforePaymentStatus;
|
|
4936
5251
|
this.store.order.persistTempOrder();
|
|
4937
5252
|
}
|
|
4938
|
-
|
|
5253
|
+
_context53.next = 26;
|
|
4939
5254
|
return this.store.order.recalculateSummary({
|
|
4940
5255
|
createIfMissing: true
|
|
4941
5256
|
});
|
|
4942
5257
|
case 26:
|
|
4943
|
-
throw
|
|
5258
|
+
throw _context53.t0;
|
|
4944
5259
|
case 27:
|
|
4945
5260
|
if (!this.store.payment) {
|
|
4946
|
-
|
|
5261
|
+
_context53.next = 38;
|
|
4947
5262
|
break;
|
|
4948
5263
|
}
|
|
4949
|
-
|
|
5264
|
+
_context53.prev = 28;
|
|
4950
5265
|
committed = this.getCommittedWalletAssets();
|
|
4951
5266
|
walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
4952
|
-
|
|
5267
|
+
_context53.next = 33;
|
|
4953
5268
|
return this.publishWalletAssetsState(walletState);
|
|
4954
5269
|
case 33:
|
|
4955
|
-
|
|
5270
|
+
_context53.next = 38;
|
|
4956
5271
|
break;
|
|
4957
5272
|
case 35:
|
|
4958
|
-
|
|
4959
|
-
|
|
5273
|
+
_context53.prev = 35;
|
|
5274
|
+
_context53.t1 = _context53["catch"](28);
|
|
4960
5275
|
this.logWarning('confirmWalletPayment: Wallet committed 状态同步失败', {
|
|
4961
|
-
error:
|
|
5276
|
+
error: _context53.t1 instanceof Error ? _context53.t1.message : String(_context53.t1)
|
|
4962
5277
|
});
|
|
4963
5278
|
case 38:
|
|
4964
|
-
latestAmountSnapshot = (_this$store$order$get5 = (_this$store$
|
|
4965
|
-
return
|
|
5279
|
+
latestAmountSnapshot = (_this$store$order$get5 = (_this$store$order15 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get5 === void 0 ? void 0 : _this$store$order$get5.call(_this$store$order15);
|
|
5280
|
+
return _context53.abrupt("return", {
|
|
4966
5281
|
submitResult: submitResult,
|
|
4967
5282
|
payments: this.store.order.getOrderPayments(),
|
|
4968
5283
|
isOrderFullyPaid: new Decimal((latestAmountSnapshot === null || latestAmountSnapshot === void 0 ? void 0 : latestAmountSnapshot.amountGap) || 0).lte(0)
|
|
4969
5284
|
});
|
|
4970
5285
|
case 40:
|
|
4971
5286
|
case "end":
|
|
4972
|
-
return
|
|
5287
|
+
return _context53.stop();
|
|
4973
5288
|
}
|
|
4974
|
-
},
|
|
5289
|
+
}, _callee53, this, [[11, 19], [28, 35]]);
|
|
4975
5290
|
}));
|
|
4976
5291
|
function confirmWalletPayment() {
|
|
4977
5292
|
return _confirmWalletPayment.apply(this, arguments);
|
|
@@ -4986,38 +5301,38 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4986
5301
|
}, {
|
|
4987
5302
|
key: "payCash",
|
|
4988
5303
|
value: (function () {
|
|
4989
|
-
var _payCash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4990
|
-
var _this$store$order$get6, _params$actualPaidAmo, _this$
|
|
5304
|
+
var _payCash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(params) {
|
|
5305
|
+
var _this$store$order$get6, _params$actualPaidAmo, _this$otherParams35, _this$window, _this$window$postMess;
|
|
4991
5306
|
var amount, config, paymentMethod, roundingAmount, effectivePaymentAmount, beforePayments, beforePaymentStatus, uniquePaymentNumber, paymentTimestamp, actualPaidAmount, changeAmount, shopWalletPassId, payments, payment, syncResult, committed, walletState, restoredTempOrder;
|
|
4992
|
-
return _regeneratorRuntime().wrap(function
|
|
4993
|
-
while (1) switch (
|
|
5307
|
+
return _regeneratorRuntime().wrap(function _callee54$(_context54) {
|
|
5308
|
+
while (1) switch (_context54.prev = _context54.next) {
|
|
4994
5309
|
case 0:
|
|
4995
5310
|
if (this.store.order) {
|
|
4996
|
-
|
|
5311
|
+
_context54.next = 2;
|
|
4997
5312
|
break;
|
|
4998
5313
|
}
|
|
4999
5314
|
throw new Error('order 模块未初始化');
|
|
5000
5315
|
case 2:
|
|
5001
5316
|
amount = Number(params.amount || 0);
|
|
5002
5317
|
if (!(!Number.isFinite(amount) || amount <= 0)) {
|
|
5003
|
-
|
|
5318
|
+
_context54.next = 5;
|
|
5004
5319
|
break;
|
|
5005
5320
|
}
|
|
5006
5321
|
throw new Error('现金支付金额必须大于 0');
|
|
5007
5322
|
case 5:
|
|
5008
|
-
|
|
5323
|
+
_context54.next = 7;
|
|
5009
5324
|
return this.getCashPaymentConfig();
|
|
5010
5325
|
case 7:
|
|
5011
|
-
config =
|
|
5326
|
+
config = _context54.sent;
|
|
5012
5327
|
paymentMethod = config.paymentMethod;
|
|
5013
5328
|
if (paymentMethod) {
|
|
5014
|
-
|
|
5329
|
+
_context54.next = 11;
|
|
5015
5330
|
break;
|
|
5016
5331
|
}
|
|
5017
5332
|
throw new Error('未找到可用的 CASHMANUAL 支付方式');
|
|
5018
5333
|
case 11:
|
|
5019
5334
|
if (!(config.amountDue <= 0)) {
|
|
5020
|
-
|
|
5335
|
+
_context54.next = 13;
|
|
5021
5336
|
break;
|
|
5022
5337
|
}
|
|
5023
5338
|
throw new Error('当前订单没有待支付金额');
|
|
@@ -5025,7 +5340,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5025
5340
|
roundingAmount = Number(params.roundingAmount || 0);
|
|
5026
5341
|
effectivePaymentAmount = new Decimal(amount).minus(roundingAmount);
|
|
5027
5342
|
if (!effectivePaymentAmount.gt(new Decimal(config.amountDue).plus(0.01))) {
|
|
5028
|
-
|
|
5343
|
+
_context54.next = 17;
|
|
5029
5344
|
break;
|
|
5030
5345
|
}
|
|
5031
5346
|
throw new Error('现金支付金额超过当前待支付金额');
|
|
@@ -5036,9 +5351,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5036
5351
|
paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
5037
5352
|
actualPaidAmount = Number((_params$actualPaidAmo = params.actualPaidAmount) !== null && _params$actualPaidAmo !== void 0 ? _params$actualPaidAmo : amount);
|
|
5038
5353
|
changeAmount = Number(params.changeAmount || 0);
|
|
5039
|
-
shopWalletPassId = (_this$
|
|
5354
|
+
shopWalletPassId = (_this$otherParams35 = this.otherParams) === null || _this$otherParams35 === void 0 ? void 0 : _this$otherParams35.shop_wallet_pass_id;
|
|
5040
5355
|
if (!(!Number.isFinite(actualPaidAmount) || actualPaidAmount + 0.01 < amount)) {
|
|
5041
|
-
|
|
5356
|
+
_context54.next = 26;
|
|
5042
5357
|
break;
|
|
5043
5358
|
}
|
|
5044
5359
|
throw new Error('顾客实收现金不能小于支付金额');
|
|
@@ -5073,8 +5388,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5073
5388
|
var _item$metadata2;
|
|
5074
5389
|
return (item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.unique_payment_number) === uniquePaymentNumber;
|
|
5075
5390
|
});
|
|
5076
|
-
|
|
5077
|
-
|
|
5391
|
+
_context54.prev = 29;
|
|
5392
|
+
_context54.next = 32;
|
|
5078
5393
|
return this.syncPaymentsToOrder({
|
|
5079
5394
|
payments: payments,
|
|
5080
5395
|
submitWhenPaid: true,
|
|
@@ -5082,48 +5397,48 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5082
5397
|
confirmPendingVoucherPayments: true
|
|
5083
5398
|
});
|
|
5084
5399
|
case 32:
|
|
5085
|
-
syncResult =
|
|
5400
|
+
syncResult = _context54.sent;
|
|
5086
5401
|
if (!isRejectedSalesSubmitResult(syncResult.submitResult)) {
|
|
5087
|
-
|
|
5402
|
+
_context54.next = 35;
|
|
5088
5403
|
break;
|
|
5089
5404
|
}
|
|
5090
5405
|
throw new Error(getSalesSubmitErrorMessage(syncResult.submitResult, '订单提交失败'));
|
|
5091
5406
|
case 35:
|
|
5092
5407
|
if (!this.store.payment) {
|
|
5093
|
-
|
|
5408
|
+
_context54.next = 40;
|
|
5094
5409
|
break;
|
|
5095
5410
|
}
|
|
5096
5411
|
committed = this.getCommittedWalletAssets();
|
|
5097
5412
|
walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
5098
|
-
|
|
5413
|
+
_context54.next = 40;
|
|
5099
5414
|
return this.publishWalletAssetsState(walletState);
|
|
5100
5415
|
case 40:
|
|
5101
|
-
return
|
|
5416
|
+
return _context54.abrupt("return", {
|
|
5102
5417
|
payment: payment || {},
|
|
5103
5418
|
payments: this.store.order.getOrderPayments(),
|
|
5104
5419
|
syncResult: syncResult,
|
|
5105
5420
|
isOrderFullyPaid: syncResult.isOrderFullyPaid
|
|
5106
5421
|
});
|
|
5107
5422
|
case 43:
|
|
5108
|
-
|
|
5109
|
-
|
|
5423
|
+
_context54.prev = 43;
|
|
5424
|
+
_context54.t0 = _context54["catch"](29);
|
|
5110
5425
|
this.store.order.setOrderPayments(beforePayments);
|
|
5111
5426
|
restoredTempOrder = this.store.order.getTempOrder();
|
|
5112
5427
|
if (restoredTempOrder && beforePaymentStatus !== undefined) {
|
|
5113
5428
|
restoredTempOrder.payment_status = beforePaymentStatus;
|
|
5114
5429
|
this.store.order.persistTempOrder();
|
|
5115
5430
|
}
|
|
5116
|
-
|
|
5431
|
+
_context54.next = 50;
|
|
5117
5432
|
return this.store.order.recalculateSummary({
|
|
5118
5433
|
createIfMissing: true
|
|
5119
5434
|
});
|
|
5120
5435
|
case 50:
|
|
5121
|
-
throw
|
|
5436
|
+
throw _context54.t0;
|
|
5122
5437
|
case 51:
|
|
5123
5438
|
case "end":
|
|
5124
|
-
return
|
|
5439
|
+
return _context54.stop();
|
|
5125
5440
|
}
|
|
5126
|
-
},
|
|
5441
|
+
}, _callee54, this, [[29, 43]]);
|
|
5127
5442
|
}));
|
|
5128
5443
|
function payCash(_x43) {
|
|
5129
5444
|
return _payCash.apply(this, arguments);
|
|
@@ -5141,21 +5456,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5141
5456
|
}, {
|
|
5142
5457
|
key: "commitPaymentMethodPayment",
|
|
5143
5458
|
value: (function () {
|
|
5144
|
-
var _commitPaymentMethodPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5145
|
-
var _this$store$order$get7, _this$store$
|
|
5459
|
+
var _commitPaymentMethodPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(params) {
|
|
5460
|
+
var _this$store$order$get7, _this$store$order16, _this$store$order$get8, _params$metadata, _params$originAmount;
|
|
5146
5461
|
var amount, paymentMethods, findPaymentMethod, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, beforePayments, beforePaymentStatus, paymentTimestamp, metadata, serviceCharge, serviceFee, payments, payment, syncResult, committed, walletState, restoredTempOrder;
|
|
5147
|
-
return _regeneratorRuntime().wrap(function
|
|
5148
|
-
while (1) switch (
|
|
5462
|
+
return _regeneratorRuntime().wrap(function _callee55$(_context55) {
|
|
5463
|
+
while (1) switch (_context55.prev = _context55.next) {
|
|
5149
5464
|
case 0:
|
|
5150
5465
|
if (this.store.order) {
|
|
5151
|
-
|
|
5466
|
+
_context55.next = 2;
|
|
5152
5467
|
break;
|
|
5153
5468
|
}
|
|
5154
5469
|
throw new Error('order 模块未初始化');
|
|
5155
5470
|
case 2:
|
|
5156
5471
|
amount = Number(params.amount || 0);
|
|
5157
5472
|
if (!(!Number.isFinite(amount) || amount <= 0)) {
|
|
5158
|
-
|
|
5473
|
+
_context55.next = 5;
|
|
5159
5474
|
break;
|
|
5160
5475
|
}
|
|
5161
5476
|
throw new Error('支付金额必须大于 0');
|
|
@@ -5171,32 +5486,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5171
5486
|
};
|
|
5172
5487
|
paymentMethod = findPaymentMethod();
|
|
5173
5488
|
if (paymentMethod) {
|
|
5174
|
-
|
|
5489
|
+
_context55.next = 13;
|
|
5175
5490
|
break;
|
|
5176
5491
|
}
|
|
5177
|
-
|
|
5492
|
+
_context55.next = 11;
|
|
5178
5493
|
return this.getPaymentMethodsAsync();
|
|
5179
5494
|
case 11:
|
|
5180
|
-
paymentMethods =
|
|
5495
|
+
paymentMethods = _context55.sent;
|
|
5181
5496
|
paymentMethod = findPaymentMethod();
|
|
5182
5497
|
case 13:
|
|
5183
5498
|
if (paymentMethod) {
|
|
5184
|
-
|
|
5499
|
+
_context55.next = 15;
|
|
5185
5500
|
break;
|
|
5186
5501
|
}
|
|
5187
5502
|
throw new Error("\u672A\u627E\u5230\u53EF\u7528\u7684\u652F\u4ED8\u65B9\u5F0F\uFF1A".concat(params.paymentMethodCode || params.paymentMethodId || ''));
|
|
5188
5503
|
case 15:
|
|
5189
|
-
amountSnapshot = (_this$store$order$get7 = (_this$store$
|
|
5504
|
+
amountSnapshot = (_this$store$order$get7 = (_this$store$order16 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get7 === void 0 ? void 0 : _this$store$order$get7.call(_this$store$order16);
|
|
5190
5505
|
pendingWalletAmount = this.getPendingWalletPaymentAmount();
|
|
5191
5506
|
amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
|
|
5192
5507
|
if (!amountDue.lte(0)) {
|
|
5193
|
-
|
|
5508
|
+
_context55.next = 20;
|
|
5194
5509
|
break;
|
|
5195
5510
|
}
|
|
5196
5511
|
throw new Error('当前订单没有待支付金额');
|
|
5197
5512
|
case 20:
|
|
5198
5513
|
if (!new Decimal(amount).gt(amountDue.plus(0.01))) {
|
|
5199
|
-
|
|
5514
|
+
_context55.next = 22;
|
|
5200
5515
|
break;
|
|
5201
5516
|
}
|
|
5202
5517
|
throw new Error('支付金额超过当前待支付金额');
|
|
@@ -5235,8 +5550,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5235
5550
|
var _item$metadata3;
|
|
5236
5551
|
return (item === null || item === void 0 || (_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.unique_payment_number) === metadata.unique_payment_number;
|
|
5237
5552
|
});
|
|
5238
|
-
|
|
5239
|
-
|
|
5553
|
+
_context55.prev = 30;
|
|
5554
|
+
_context55.next = 33;
|
|
5240
5555
|
return this.syncPaymentsToOrder({
|
|
5241
5556
|
payments: payments,
|
|
5242
5557
|
submitWhenPaid: true,
|
|
@@ -5244,48 +5559,48 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5244
5559
|
confirmPendingVoucherPayments: true
|
|
5245
5560
|
});
|
|
5246
5561
|
case 33:
|
|
5247
|
-
syncResult =
|
|
5562
|
+
syncResult = _context55.sent;
|
|
5248
5563
|
if (!isRejectedSalesSubmitResult(syncResult.submitResult)) {
|
|
5249
|
-
|
|
5564
|
+
_context55.next = 36;
|
|
5250
5565
|
break;
|
|
5251
5566
|
}
|
|
5252
5567
|
throw new Error(getSalesSubmitErrorMessage(syncResult.submitResult, '订单提交失败'));
|
|
5253
5568
|
case 36:
|
|
5254
5569
|
if (!this.store.payment) {
|
|
5255
|
-
|
|
5570
|
+
_context55.next = 41;
|
|
5256
5571
|
break;
|
|
5257
5572
|
}
|
|
5258
5573
|
committed = this.getCommittedWalletAssets();
|
|
5259
5574
|
walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
5260
|
-
|
|
5575
|
+
_context55.next = 41;
|
|
5261
5576
|
return this.publishWalletAssetsState(walletState);
|
|
5262
5577
|
case 41:
|
|
5263
|
-
return
|
|
5578
|
+
return _context55.abrupt("return", {
|
|
5264
5579
|
payment: payment || {},
|
|
5265
5580
|
payments: this.store.order.getOrderPayments(),
|
|
5266
5581
|
syncResult: syncResult,
|
|
5267
5582
|
isOrderFullyPaid: syncResult.isOrderFullyPaid
|
|
5268
5583
|
});
|
|
5269
5584
|
case 44:
|
|
5270
|
-
|
|
5271
|
-
|
|
5585
|
+
_context55.prev = 44;
|
|
5586
|
+
_context55.t0 = _context55["catch"](30);
|
|
5272
5587
|
this.store.order.setOrderPayments(beforePayments);
|
|
5273
5588
|
restoredTempOrder = this.store.order.getTempOrder();
|
|
5274
5589
|
if (restoredTempOrder && beforePaymentStatus !== undefined) {
|
|
5275
5590
|
restoredTempOrder.payment_status = beforePaymentStatus;
|
|
5276
5591
|
this.store.order.persistTempOrder();
|
|
5277
5592
|
}
|
|
5278
|
-
|
|
5593
|
+
_context55.next = 51;
|
|
5279
5594
|
return this.store.order.recalculateSummary({
|
|
5280
5595
|
createIfMissing: true
|
|
5281
5596
|
});
|
|
5282
5597
|
case 51:
|
|
5283
|
-
throw
|
|
5598
|
+
throw _context55.t0;
|
|
5284
5599
|
case 52:
|
|
5285
5600
|
case "end":
|
|
5286
|
-
return
|
|
5601
|
+
return _context55.stop();
|
|
5287
5602
|
}
|
|
5288
|
-
},
|
|
5603
|
+
}, _callee55, this, [[30, 44]]);
|
|
5289
5604
|
}));
|
|
5290
5605
|
function commitPaymentMethodPayment(_x44) {
|
|
5291
5606
|
return _commitPaymentMethodPayment.apply(this, arguments);
|
|
@@ -5302,38 +5617,38 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5302
5617
|
}, {
|
|
5303
5618
|
key: "roundAmount",
|
|
5304
5619
|
value: (function () {
|
|
5305
|
-
var _roundAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5620
|
+
var _roundAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(params) {
|
|
5306
5621
|
var _cashManualPayment$me, _this$otherParams$ord2, _this$otherParams$ord3;
|
|
5307
5622
|
var amount, cashManualPayment;
|
|
5308
|
-
return _regeneratorRuntime().wrap(function
|
|
5309
|
-
while (1) switch (
|
|
5623
|
+
return _regeneratorRuntime().wrap(function _callee56$(_context56) {
|
|
5624
|
+
while (1) switch (_context56.prev = _context56.next) {
|
|
5310
5625
|
case 0:
|
|
5311
5626
|
amount = params.amount;
|
|
5312
5627
|
cashManualPayment = this.paymentMethodsCache.find(function (paymentMethod) {
|
|
5313
5628
|
return paymentMethod.code === 'CASHMANUAL';
|
|
5314
5629
|
});
|
|
5315
5630
|
if (cashManualPayment !== null && cashManualPayment !== void 0 && (_cashManualPayment$me = cashManualPayment.metadata) !== null && _cashManualPayment$me !== void 0 && _cashManualPayment$me.order_rounding_switch) {
|
|
5316
|
-
|
|
5631
|
+
_context56.next = 4;
|
|
5317
5632
|
break;
|
|
5318
5633
|
}
|
|
5319
|
-
return
|
|
5634
|
+
return _context56.abrupt("return", {
|
|
5320
5635
|
originalAmount: amount.toString(),
|
|
5321
5636
|
roundedAmount: amount.toString(),
|
|
5322
5637
|
roundingDifference: '0.00'
|
|
5323
5638
|
});
|
|
5324
5639
|
case 4:
|
|
5325
5640
|
if (this.payment) {
|
|
5326
|
-
|
|
5641
|
+
_context56.next = 6;
|
|
5327
5642
|
break;
|
|
5328
5643
|
}
|
|
5329
5644
|
throw new Error('payment 模块未初始化');
|
|
5330
5645
|
case 6:
|
|
5331
|
-
return
|
|
5646
|
+
return _context56.abrupt("return", this.payment.roundAmountAsync(amount, (_this$otherParams$ord2 = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord2 === void 0 ? void 0 : _this$otherParams$ord2.interval, (_this$otherParams$ord3 = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord3 === void 0 ? void 0 : _this$otherParams$ord3.type));
|
|
5332
5647
|
case 7:
|
|
5333
5648
|
case "end":
|
|
5334
|
-
return
|
|
5649
|
+
return _context56.stop();
|
|
5335
5650
|
}
|
|
5336
|
-
},
|
|
5651
|
+
}, _callee56, this);
|
|
5337
5652
|
}));
|
|
5338
5653
|
function roundAmount(_x45) {
|
|
5339
5654
|
return _roundAmount.apply(this, arguments);
|
|
@@ -5350,47 +5665,47 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5350
5665
|
}, {
|
|
5351
5666
|
key: "sendCustomerPayLink",
|
|
5352
5667
|
value: (function () {
|
|
5353
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5354
|
-
var orderIds,
|
|
5355
|
-
return _regeneratorRuntime().wrap(function
|
|
5356
|
-
while (1) switch (
|
|
5668
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(params) {
|
|
5669
|
+
var orderIds, _ref45, _ref46, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
|
|
5670
|
+
return _regeneratorRuntime().wrap(function _callee57$(_context57) {
|
|
5671
|
+
while (1) switch (_context57.prev = _context57.next) {
|
|
5357
5672
|
case 0:
|
|
5358
5673
|
if (this.store.order) {
|
|
5359
|
-
|
|
5674
|
+
_context57.next = 2;
|
|
5360
5675
|
break;
|
|
5361
5676
|
}
|
|
5362
5677
|
throw new Error('order 模块未初始化');
|
|
5363
5678
|
case 2:
|
|
5364
5679
|
orderIds = params.order_ids || params.orderIds || [];
|
|
5365
5680
|
if (!(!orderIds.length || params.submitBeforeSend)) {
|
|
5366
|
-
|
|
5681
|
+
_context57.next = 11;
|
|
5367
5682
|
break;
|
|
5368
5683
|
}
|
|
5369
|
-
|
|
5684
|
+
_context57.next = 6;
|
|
5370
5685
|
return this.submitSalesOrder({
|
|
5371
5686
|
smallTicketDataFlag: 1
|
|
5372
5687
|
});
|
|
5373
5688
|
case 6:
|
|
5374
|
-
submitResult =
|
|
5375
|
-
orderId = (
|
|
5689
|
+
submitResult = _context57.sent;
|
|
5690
|
+
orderId = (_ref45 = (_ref46 = (_submitResult$data$or = submitResult === null || submitResult === void 0 || (_submitResult$data = submitResult.data) === null || _submitResult$data === void 0 ? void 0 : _submitResult$data.order_id) !== null && _submitResult$data$or !== void 0 ? _submitResult$data$or : submitResult === null || submitResult === void 0 ? void 0 : submitResult.order_id) !== null && _ref46 !== void 0 ? _ref46 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref45 !== void 0 ? _ref45 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
|
|
5376
5691
|
if (orderId) {
|
|
5377
|
-
|
|
5692
|
+
_context57.next = 10;
|
|
5378
5693
|
break;
|
|
5379
5694
|
}
|
|
5380
5695
|
throw new Error('本地订单提交云端失败,无法发送支付链接');
|
|
5381
5696
|
case 10:
|
|
5382
5697
|
orderIds = [orderId];
|
|
5383
5698
|
case 11:
|
|
5384
|
-
return
|
|
5699
|
+
return _context57.abrupt("return", this.store.order.sendCustomerPayLink({
|
|
5385
5700
|
emails: params.emails,
|
|
5386
5701
|
notify_action: params.notify_action,
|
|
5387
5702
|
order_ids: orderIds
|
|
5388
5703
|
}));
|
|
5389
5704
|
case 12:
|
|
5390
5705
|
case "end":
|
|
5391
|
-
return
|
|
5706
|
+
return _context57.stop();
|
|
5392
5707
|
}
|
|
5393
|
-
},
|
|
5708
|
+
}, _callee57, this);
|
|
5394
5709
|
}));
|
|
5395
5710
|
function sendCustomerPayLink(_x46) {
|
|
5396
5711
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
@@ -5405,20 +5720,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5405
5720
|
}, {
|
|
5406
5721
|
key: "calculateProductBookingPrice",
|
|
5407
5722
|
value: function () {
|
|
5408
|
-
var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5723
|
+
var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(params) {
|
|
5409
5724
|
var _params$customer_id;
|
|
5410
5725
|
var useCustomerUserPricing, quotation, customerId, channel, _yield$this$resolvePr, _yield$this$resolvePr2, authoritativeProduct, product;
|
|
5411
|
-
return _regeneratorRuntime().wrap(function
|
|
5412
|
-
while (1) switch (
|
|
5726
|
+
return _regeneratorRuntime().wrap(function _callee58$(_context58) {
|
|
5727
|
+
while (1) switch (_context58.prev = _context58.next) {
|
|
5413
5728
|
case 0:
|
|
5414
5729
|
useCustomerUserPricing = this.isCustomerUserPriceQuery();
|
|
5415
5730
|
quotation = useCustomerUserPricing ? undefined : this.store.quotation;
|
|
5416
5731
|
customerId = (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : this.getCurrentOrderCustomerId();
|
|
5417
|
-
|
|
5732
|
+
_context58.next = 5;
|
|
5418
5733
|
return this.prepareProductPriceQueryContext(customerId);
|
|
5419
5734
|
case 5:
|
|
5420
5735
|
channel = this.getPriceQueryChannel(params.channel);
|
|
5421
|
-
|
|
5736
|
+
_context58.next = 8;
|
|
5422
5737
|
return this.resolveProductsForPriceQuery({
|
|
5423
5738
|
priceQueries: [params],
|
|
5424
5739
|
schedule: this.getPriceQuerySchedule(params),
|
|
@@ -5426,22 +5741,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5426
5741
|
channel: channel
|
|
5427
5742
|
});
|
|
5428
5743
|
case 8:
|
|
5429
|
-
_yield$this$resolvePr =
|
|
5744
|
+
_yield$this$resolvePr = _context58.sent;
|
|
5430
5745
|
_yield$this$resolvePr2 = _slicedToArray(_yield$this$resolvePr, 1);
|
|
5431
5746
|
authoritativeProduct = _yield$this$resolvePr2[0];
|
|
5432
5747
|
product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
|
|
5433
5748
|
if (useCustomerUserPricing) {
|
|
5434
|
-
|
|
5749
|
+
_context58.next = 15;
|
|
5435
5750
|
break;
|
|
5436
5751
|
}
|
|
5437
|
-
|
|
5752
|
+
_context58.next = 15;
|
|
5438
5753
|
return this.loadQuotationForPriceQuery({
|
|
5439
5754
|
quotation: quotation,
|
|
5440
5755
|
customer_id: customerId,
|
|
5441
5756
|
channel: channel
|
|
5442
5757
|
});
|
|
5443
5758
|
case 15:
|
|
5444
|
-
return
|
|
5759
|
+
return _context58.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
|
|
5445
5760
|
channel: channel,
|
|
5446
5761
|
product: product,
|
|
5447
5762
|
fallback_price: authoritativeProduct ? undefined : params.fallback_price,
|
|
@@ -5450,9 +5765,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5450
5765
|
})));
|
|
5451
5766
|
case 16:
|
|
5452
5767
|
case "end":
|
|
5453
|
-
return
|
|
5768
|
+
return _context58.stop();
|
|
5454
5769
|
}
|
|
5455
|
-
},
|
|
5770
|
+
}, _callee58, this);
|
|
5456
5771
|
}));
|
|
5457
5772
|
function calculateProductBookingPrice(_x47) {
|
|
5458
5773
|
return _calculateProductBookingPrice.apply(this, arguments);
|
|
@@ -5538,17 +5853,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5538
5853
|
}, {
|
|
5539
5854
|
key: "calculateProductBookingPrices",
|
|
5540
5855
|
value: function () {
|
|
5541
|
-
var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5856
|
+
var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(paramsList) {
|
|
5542
5857
|
var _this18 = this;
|
|
5543
5858
|
var useCustomerUserPricing, quotation, currentOrderCustomerId, resolvedChannels, authoritativeProducts, groups, quotationContexts;
|
|
5544
|
-
return _regeneratorRuntime().wrap(function
|
|
5545
|
-
while (1) switch (
|
|
5859
|
+
return _regeneratorRuntime().wrap(function _callee60$(_context60) {
|
|
5860
|
+
while (1) switch (_context60.prev = _context60.next) {
|
|
5546
5861
|
case 0:
|
|
5547
5862
|
if (paramsList.length) {
|
|
5548
|
-
|
|
5863
|
+
_context60.next = 2;
|
|
5549
5864
|
break;
|
|
5550
5865
|
}
|
|
5551
|
-
return
|
|
5866
|
+
return _context60.abrupt("return", []);
|
|
5552
5867
|
case 2:
|
|
5553
5868
|
useCustomerUserPricing = this.isCustomerUserPriceQuery();
|
|
5554
5869
|
quotation = useCustomerUserPricing ? undefined : this.store.quotation;
|
|
@@ -5575,20 +5890,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5575
5890
|
group.indices.push(index);
|
|
5576
5891
|
groups.set(groupKey, group);
|
|
5577
5892
|
});
|
|
5578
|
-
|
|
5893
|
+
_context60.next = 11;
|
|
5579
5894
|
return Promise.all(Array.from(groups.values()).map( /*#__PURE__*/function () {
|
|
5580
|
-
var
|
|
5895
|
+
var _ref47 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(group) {
|
|
5581
5896
|
var priceQueries, resolvedProducts;
|
|
5582
|
-
return _regeneratorRuntime().wrap(function
|
|
5583
|
-
while (1) switch (
|
|
5897
|
+
return _regeneratorRuntime().wrap(function _callee59$(_context59) {
|
|
5898
|
+
while (1) switch (_context59.prev = _context59.next) {
|
|
5584
5899
|
case 0:
|
|
5585
|
-
|
|
5900
|
+
_context59.next = 2;
|
|
5586
5901
|
return _this18.prepareProductPriceQueryContext(group.customerId);
|
|
5587
5902
|
case 2:
|
|
5588
5903
|
priceQueries = group.indices.map(function (index) {
|
|
5589
5904
|
return paramsList[index];
|
|
5590
5905
|
});
|
|
5591
|
-
|
|
5906
|
+
_context59.next = 5;
|
|
5592
5907
|
return _this18.resolveProductsForPriceQuery({
|
|
5593
5908
|
priceQueries: priceQueries,
|
|
5594
5909
|
schedule: group.schedule,
|
|
@@ -5596,23 +5911,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5596
5911
|
channel: group.channel
|
|
5597
5912
|
});
|
|
5598
5913
|
case 5:
|
|
5599
|
-
resolvedProducts =
|
|
5914
|
+
resolvedProducts = _context59.sent;
|
|
5600
5915
|
group.indices.forEach(function (originalIndex, groupIndex) {
|
|
5601
5916
|
authoritativeProducts[originalIndex] = resolvedProducts[groupIndex] || null;
|
|
5602
5917
|
});
|
|
5603
5918
|
case 7:
|
|
5604
5919
|
case "end":
|
|
5605
|
-
return
|
|
5920
|
+
return _context59.stop();
|
|
5606
5921
|
}
|
|
5607
|
-
},
|
|
5922
|
+
}, _callee59);
|
|
5608
5923
|
}));
|
|
5609
5924
|
return function (_x49) {
|
|
5610
|
-
return
|
|
5925
|
+
return _ref47.apply(this, arguments);
|
|
5611
5926
|
};
|
|
5612
5927
|
}()));
|
|
5613
5928
|
case 11:
|
|
5614
5929
|
if (useCustomerUserPricing) {
|
|
5615
|
-
|
|
5930
|
+
_context60.next = 16;
|
|
5616
5931
|
break;
|
|
5617
5932
|
}
|
|
5618
5933
|
quotationContexts = new Map();
|
|
@@ -5626,14 +5941,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5626
5941
|
customer_id: (_params$customer_id3 = params.customer_id) !== null && _params$customer_id3 !== void 0 ? _params$customer_id3 : currentOrderCustomerId
|
|
5627
5942
|
});
|
|
5628
5943
|
});
|
|
5629
|
-
|
|
5944
|
+
_context60.next = 16;
|
|
5630
5945
|
return Promise.all(Array.from(quotationContexts.values()).map(function (context) {
|
|
5631
5946
|
return _this18.loadQuotationForPriceQuery(_objectSpread({
|
|
5632
5947
|
quotation: quotation
|
|
5633
5948
|
}, context));
|
|
5634
5949
|
}));
|
|
5635
5950
|
case 16:
|
|
5636
|
-
return
|
|
5951
|
+
return _context60.abrupt("return", paramsList.map(function (params, index) {
|
|
5637
5952
|
var _params$customer_id4;
|
|
5638
5953
|
var productInput = params.product || {};
|
|
5639
5954
|
var authoritativeProduct = authoritativeProducts[index];
|
|
@@ -5650,9 +5965,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5650
5965
|
}));
|
|
5651
5966
|
case 17:
|
|
5652
5967
|
case "end":
|
|
5653
|
-
return
|
|
5968
|
+
return _context60.stop();
|
|
5654
5969
|
}
|
|
5655
|
-
},
|
|
5970
|
+
}, _callee60, this);
|
|
5656
5971
|
}));
|
|
5657
5972
|
function calculateProductBookingPrices(_x48) {
|
|
5658
5973
|
return _calculateProductBookingPrices.apply(this, arguments);
|
|
@@ -5662,32 +5977,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5662
5977
|
}, {
|
|
5663
5978
|
key: "addProductToOrder",
|
|
5664
5979
|
value: function () {
|
|
5665
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5980
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(product, booking, options) {
|
|
5666
5981
|
var products;
|
|
5667
|
-
return _regeneratorRuntime().wrap(function
|
|
5668
|
-
while (1) switch (
|
|
5982
|
+
return _regeneratorRuntime().wrap(function _callee61$(_context61) {
|
|
5983
|
+
while (1) switch (_context61.prev = _context61.next) {
|
|
5669
5984
|
case 0:
|
|
5670
|
-
|
|
5985
|
+
_context61.prev = 0;
|
|
5671
5986
|
if (this.store.order) {
|
|
5672
|
-
|
|
5987
|
+
_context61.next = 3;
|
|
5673
5988
|
break;
|
|
5674
5989
|
}
|
|
5675
5990
|
throw new Error('order 模块未初始化');
|
|
5676
5991
|
case 3:
|
|
5677
|
-
|
|
5992
|
+
_context61.next = 5;
|
|
5678
5993
|
return this.store.order.addProductToOrder(product, booking, options);
|
|
5679
5994
|
case 5:
|
|
5680
|
-
products =
|
|
5681
|
-
return
|
|
5995
|
+
products = _context61.sent;
|
|
5996
|
+
return _context61.abrupt("return", products);
|
|
5682
5997
|
case 9:
|
|
5683
|
-
|
|
5684
|
-
|
|
5685
|
-
throw
|
|
5998
|
+
_context61.prev = 9;
|
|
5999
|
+
_context61.t0 = _context61["catch"](0);
|
|
6000
|
+
throw _context61.t0;
|
|
5686
6001
|
case 12:
|
|
5687
6002
|
case "end":
|
|
5688
|
-
return
|
|
6003
|
+
return _context61.stop();
|
|
5689
6004
|
}
|
|
5690
|
-
},
|
|
6005
|
+
}, _callee61, this, [[0, 9]]);
|
|
5691
6006
|
}));
|
|
5692
6007
|
function addProductToOrder(_x50, _x51, _x52) {
|
|
5693
6008
|
return _addProductToOrder.apply(this, arguments);
|
|
@@ -5697,32 +6012,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5697
6012
|
}, {
|
|
5698
6013
|
key: "updateOrderProduct",
|
|
5699
6014
|
value: function () {
|
|
5700
|
-
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6015
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(params) {
|
|
5701
6016
|
var products;
|
|
5702
|
-
return _regeneratorRuntime().wrap(function
|
|
5703
|
-
while (1) switch (
|
|
6017
|
+
return _regeneratorRuntime().wrap(function _callee62$(_context62) {
|
|
6018
|
+
while (1) switch (_context62.prev = _context62.next) {
|
|
5704
6019
|
case 0:
|
|
5705
|
-
|
|
6020
|
+
_context62.prev = 0;
|
|
5706
6021
|
if (this.store.order) {
|
|
5707
|
-
|
|
6022
|
+
_context62.next = 3;
|
|
5708
6023
|
break;
|
|
5709
6024
|
}
|
|
5710
6025
|
throw new Error('order 模块未初始化');
|
|
5711
6026
|
case 3:
|
|
5712
|
-
|
|
6027
|
+
_context62.next = 5;
|
|
5713
6028
|
return this.store.order.updateOrderProduct(params);
|
|
5714
6029
|
case 5:
|
|
5715
|
-
products =
|
|
5716
|
-
return
|
|
6030
|
+
products = _context62.sent;
|
|
6031
|
+
return _context62.abrupt("return", products);
|
|
5717
6032
|
case 9:
|
|
5718
|
-
|
|
5719
|
-
|
|
5720
|
-
throw
|
|
6033
|
+
_context62.prev = 9;
|
|
6034
|
+
_context62.t0 = _context62["catch"](0);
|
|
6035
|
+
throw _context62.t0;
|
|
5721
6036
|
case 12:
|
|
5722
6037
|
case "end":
|
|
5723
|
-
return
|
|
6038
|
+
return _context62.stop();
|
|
5724
6039
|
}
|
|
5725
|
-
},
|
|
6040
|
+
}, _callee62, this, [[0, 9]]);
|
|
5726
6041
|
}));
|
|
5727
6042
|
function updateOrderProduct(_x53) {
|
|
5728
6043
|
return _updateOrderProduct.apply(this, arguments);
|
|
@@ -5732,32 +6047,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5732
6047
|
}, {
|
|
5733
6048
|
key: "updateOrderProducts",
|
|
5734
6049
|
value: function () {
|
|
5735
|
-
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6050
|
+
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(paramsList) {
|
|
5736
6051
|
var products;
|
|
5737
|
-
return _regeneratorRuntime().wrap(function
|
|
5738
|
-
while (1) switch (
|
|
6052
|
+
return _regeneratorRuntime().wrap(function _callee63$(_context63) {
|
|
6053
|
+
while (1) switch (_context63.prev = _context63.next) {
|
|
5739
6054
|
case 0:
|
|
5740
|
-
|
|
6055
|
+
_context63.prev = 0;
|
|
5741
6056
|
if (this.store.order) {
|
|
5742
|
-
|
|
6057
|
+
_context63.next = 3;
|
|
5743
6058
|
break;
|
|
5744
6059
|
}
|
|
5745
6060
|
throw new Error('order 模块未初始化');
|
|
5746
6061
|
case 3:
|
|
5747
|
-
|
|
6062
|
+
_context63.next = 5;
|
|
5748
6063
|
return this.store.order.updateOrderProducts(paramsList);
|
|
5749
6064
|
case 5:
|
|
5750
|
-
products =
|
|
5751
|
-
return
|
|
6065
|
+
products = _context63.sent;
|
|
6066
|
+
return _context63.abrupt("return", products);
|
|
5752
6067
|
case 9:
|
|
5753
|
-
|
|
5754
|
-
|
|
5755
|
-
throw
|
|
6068
|
+
_context63.prev = 9;
|
|
6069
|
+
_context63.t0 = _context63["catch"](0);
|
|
6070
|
+
throw _context63.t0;
|
|
5756
6071
|
case 12:
|
|
5757
6072
|
case "end":
|
|
5758
|
-
return
|
|
6073
|
+
return _context63.stop();
|
|
5759
6074
|
}
|
|
5760
|
-
},
|
|
6075
|
+
}, _callee63, this, [[0, 9]]);
|
|
5761
6076
|
}));
|
|
5762
6077
|
function updateOrderProducts(_x54) {
|
|
5763
6078
|
return _updateOrderProducts.apply(this, arguments);
|
|
@@ -5767,32 +6082,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5767
6082
|
}, {
|
|
5768
6083
|
key: "updateOrderProductQuantity",
|
|
5769
6084
|
value: function () {
|
|
5770
|
-
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6085
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(params) {
|
|
5771
6086
|
var products;
|
|
5772
|
-
return _regeneratorRuntime().wrap(function
|
|
5773
|
-
while (1) switch (
|
|
6087
|
+
return _regeneratorRuntime().wrap(function _callee64$(_context64) {
|
|
6088
|
+
while (1) switch (_context64.prev = _context64.next) {
|
|
5774
6089
|
case 0:
|
|
5775
|
-
|
|
6090
|
+
_context64.prev = 0;
|
|
5776
6091
|
if (this.store.order) {
|
|
5777
|
-
|
|
6092
|
+
_context64.next = 3;
|
|
5778
6093
|
break;
|
|
5779
6094
|
}
|
|
5780
6095
|
throw new Error('order 模块未初始化');
|
|
5781
6096
|
case 3:
|
|
5782
|
-
|
|
6097
|
+
_context64.next = 5;
|
|
5783
6098
|
return this.store.order.updateOrderProductQuantity(params);
|
|
5784
6099
|
case 5:
|
|
5785
|
-
products =
|
|
5786
|
-
return
|
|
6100
|
+
products = _context64.sent;
|
|
6101
|
+
return _context64.abrupt("return", products);
|
|
5787
6102
|
case 9:
|
|
5788
|
-
|
|
5789
|
-
|
|
5790
|
-
throw
|
|
6103
|
+
_context64.prev = 9;
|
|
6104
|
+
_context64.t0 = _context64["catch"](0);
|
|
6105
|
+
throw _context64.t0;
|
|
5791
6106
|
case 12:
|
|
5792
6107
|
case "end":
|
|
5793
|
-
return
|
|
6108
|
+
return _context64.stop();
|
|
5794
6109
|
}
|
|
5795
|
-
},
|
|
6110
|
+
}, _callee64, this, [[0, 9]]);
|
|
5796
6111
|
}));
|
|
5797
6112
|
function updateOrderProductQuantity(_x55) {
|
|
5798
6113
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
@@ -5817,12 +6132,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5817
6132
|
}, {
|
|
5818
6133
|
key: "setOrderProductLineNote",
|
|
5819
6134
|
value: (function () {
|
|
5820
|
-
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6135
|
+
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(identity, note) {
|
|
5821
6136
|
var params, products;
|
|
5822
|
-
return _regeneratorRuntime().wrap(function
|
|
5823
|
-
while (1) switch (
|
|
6137
|
+
return _regeneratorRuntime().wrap(function _callee65$(_context65) {
|
|
6138
|
+
while (1) switch (_context65.prev = _context65.next) {
|
|
5824
6139
|
case 0:
|
|
5825
|
-
|
|
6140
|
+
_context65.prev = 0;
|
|
5826
6141
|
params = {
|
|
5827
6142
|
product_id: identity.product_id,
|
|
5828
6143
|
product_variant_id: identity.product_variant_id,
|
|
@@ -5837,20 +6152,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5837
6152
|
params.product_sku = identity.product_sku;
|
|
5838
6153
|
}
|
|
5839
6154
|
if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
|
|
5840
|
-
|
|
6155
|
+
_context65.next = 7;
|
|
5841
6156
|
return this.updateOrderProduct(params);
|
|
5842
6157
|
case 7:
|
|
5843
|
-
products =
|
|
5844
|
-
return
|
|
6158
|
+
products = _context65.sent;
|
|
6159
|
+
return _context65.abrupt("return", products);
|
|
5845
6160
|
case 11:
|
|
5846
|
-
|
|
5847
|
-
|
|
5848
|
-
throw
|
|
6161
|
+
_context65.prev = 11;
|
|
6162
|
+
_context65.t0 = _context65["catch"](0);
|
|
6163
|
+
throw _context65.t0;
|
|
5849
6164
|
case 14:
|
|
5850
6165
|
case "end":
|
|
5851
|
-
return
|
|
6166
|
+
return _context65.stop();
|
|
5852
6167
|
}
|
|
5853
|
-
},
|
|
6168
|
+
}, _callee65, this, [[0, 11]]);
|
|
5854
6169
|
}));
|
|
5855
6170
|
function setOrderProductLineNote(_x56, _x57) {
|
|
5856
6171
|
return _setOrderProductLineNote.apply(this, arguments);
|
|
@@ -5867,30 +6182,30 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5867
6182
|
}, {
|
|
5868
6183
|
key: "removeProductsFromOrder",
|
|
5869
6184
|
value: (function () {
|
|
5870
|
-
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5871
|
-
return _regeneratorRuntime().wrap(function
|
|
5872
|
-
while (1) switch (
|
|
6185
|
+
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(identities, options) {
|
|
6186
|
+
return _regeneratorRuntime().wrap(function _callee66$(_context66) {
|
|
6187
|
+
while (1) switch (_context66.prev = _context66.next) {
|
|
5873
6188
|
case 0:
|
|
5874
|
-
|
|
6189
|
+
_context66.prev = 0;
|
|
5875
6190
|
if (this.store.order) {
|
|
5876
|
-
|
|
6191
|
+
_context66.next = 3;
|
|
5877
6192
|
break;
|
|
5878
6193
|
}
|
|
5879
6194
|
throw new Error('order 模块未初始化');
|
|
5880
6195
|
case 3:
|
|
5881
|
-
|
|
6196
|
+
_context66.next = 5;
|
|
5882
6197
|
return this.store.order.removeProductsFromOrder(identities, options);
|
|
5883
6198
|
case 5:
|
|
5884
|
-
return
|
|
6199
|
+
return _context66.abrupt("return", _context66.sent);
|
|
5885
6200
|
case 8:
|
|
5886
|
-
|
|
5887
|
-
|
|
5888
|
-
throw
|
|
6201
|
+
_context66.prev = 8;
|
|
6202
|
+
_context66.t0 = _context66["catch"](0);
|
|
6203
|
+
throw _context66.t0;
|
|
5889
6204
|
case 11:
|
|
5890
6205
|
case "end":
|
|
5891
|
-
return
|
|
6206
|
+
return _context66.stop();
|
|
5892
6207
|
}
|
|
5893
|
-
},
|
|
6208
|
+
}, _callee66, this, [[0, 8]]);
|
|
5894
6209
|
}));
|
|
5895
6210
|
function removeProductsFromOrder(_x58, _x59) {
|
|
5896
6211
|
return _removeProductsFromOrder.apply(this, arguments);
|
|
@@ -5900,16 +6215,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5900
6215
|
}, {
|
|
5901
6216
|
key: "removeProductFromOrder",
|
|
5902
6217
|
value: function () {
|
|
5903
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5904
|
-
return _regeneratorRuntime().wrap(function
|
|
5905
|
-
while (1) switch (
|
|
6218
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(identity, options) {
|
|
6219
|
+
return _regeneratorRuntime().wrap(function _callee67$(_context67) {
|
|
6220
|
+
while (1) switch (_context67.prev = _context67.next) {
|
|
5906
6221
|
case 0:
|
|
5907
|
-
return
|
|
6222
|
+
return _context67.abrupt("return", this.removeProductsFromOrder([identity], options));
|
|
5908
6223
|
case 1:
|
|
5909
6224
|
case "end":
|
|
5910
|
-
return
|
|
6225
|
+
return _context67.stop();
|
|
5911
6226
|
}
|
|
5912
|
-
},
|
|
6227
|
+
}, _callee67, this);
|
|
5913
6228
|
}));
|
|
5914
6229
|
function removeProductFromOrder(_x60, _x61) {
|
|
5915
6230
|
return _removeProductFromOrder.apply(this, arguments);
|
|
@@ -5961,23 +6276,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5961
6276
|
}, {
|
|
5962
6277
|
key: "applyPromotion",
|
|
5963
6278
|
value: (function () {
|
|
5964
|
-
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5965
|
-
return _regeneratorRuntime().wrap(function
|
|
5966
|
-
while (1) switch (
|
|
6279
|
+
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68() {
|
|
6280
|
+
return _regeneratorRuntime().wrap(function _callee68$(_context68) {
|
|
6281
|
+
while (1) switch (_context68.prev = _context68.next) {
|
|
5967
6282
|
case 0:
|
|
5968
6283
|
if (this.store.order) {
|
|
5969
|
-
|
|
6284
|
+
_context68.next = 2;
|
|
5970
6285
|
break;
|
|
5971
6286
|
}
|
|
5972
6287
|
throw new Error('order 模块未初始化');
|
|
5973
6288
|
case 2:
|
|
5974
|
-
|
|
6289
|
+
_context68.next = 4;
|
|
5975
6290
|
return this.store.order.applyPromotion();
|
|
5976
6291
|
case 4:
|
|
5977
6292
|
case "end":
|
|
5978
|
-
return
|
|
6293
|
+
return _context68.stop();
|
|
5979
6294
|
}
|
|
5980
|
-
},
|
|
6295
|
+
}, _callee68, this);
|
|
5981
6296
|
}));
|
|
5982
6297
|
function applyPromotion() {
|
|
5983
6298
|
return _applyPromotion.apply(this, arguments);
|
|
@@ -5987,16 +6302,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5987
6302
|
}, {
|
|
5988
6303
|
key: "getUnfulfilledPromotions",
|
|
5989
6304
|
value: function getUnfulfilledPromotions() {
|
|
5990
|
-
var _this$store$
|
|
5991
|
-
return ((_this$store$
|
|
6305
|
+
var _this$store$order17;
|
|
6306
|
+
return ((_this$store$order17 = this.store.order) === null || _this$store$order17 === void 0 ? void 0 : _this$store$order17.getUnfulfilledPromotions()) || [];
|
|
5992
6307
|
}
|
|
5993
6308
|
|
|
5994
6309
|
/** 最近一次促销计算输出的赠品操作 diff。 */
|
|
5995
6310
|
}, {
|
|
5996
6311
|
key: "getLastGiftActions",
|
|
5997
6312
|
value: function getLastGiftActions() {
|
|
5998
|
-
var _this$store$
|
|
5999
|
-
return ((_this$store$
|
|
6313
|
+
var _this$store$order18;
|
|
6314
|
+
return ((_this$store$order18 = this.store.order) === null || _this$store$order18 === void 0 ? void 0 : _this$store$order18.getLastGiftActions()) || null;
|
|
6000
6315
|
}
|
|
6001
6316
|
|
|
6002
6317
|
// 获取商品列表
|
|
@@ -6004,18 +6319,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
6004
6319
|
}, {
|
|
6005
6320
|
key: "getProductList",
|
|
6006
6321
|
value: function () {
|
|
6007
|
-
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6008
|
-
var _this$
|
|
6322
|
+
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69() {
|
|
6323
|
+
var _this$otherParams36;
|
|
6009
6324
|
var menu_list_ids, _this$store$products, res;
|
|
6010
|
-
return _regeneratorRuntime().wrap(function
|
|
6011
|
-
while (1) switch (
|
|
6325
|
+
return _regeneratorRuntime().wrap(function _callee69$(_context69) {
|
|
6326
|
+
while (1) switch (_context69.prev = _context69.next) {
|
|
6012
6327
|
case 0:
|
|
6013
6328
|
// 可以直接通过配置里的 menu 读取
|
|
6014
|
-
menu_list_ids = ((_this$
|
|
6329
|
+
menu_list_ids = ((_this$otherParams36 = this.otherParams) === null || _this$otherParams36 === void 0 || (_this$otherParams36 = _this$otherParams36.dineInConfig) === null || _this$otherParams36 === void 0 ? void 0 : _this$otherParams36['menu.associated_menus'].map(function (n) {
|
|
6015
6330
|
return Number(n.value);
|
|
6016
6331
|
})) || [];
|
|
6017
|
-
|
|
6018
|
-
|
|
6332
|
+
_context69.prev = 1;
|
|
6333
|
+
_context69.next = 4;
|
|
6019
6334
|
return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
|
|
6020
6335
|
menu_list_ids: menu_list_ids,
|
|
6021
6336
|
cacheId: this.cacheId,
|
|
@@ -6023,17 +6338,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
6023
6338
|
schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
6024
6339
|
});
|
|
6025
6340
|
case 4:
|
|
6026
|
-
res =
|
|
6027
|
-
return
|
|
6341
|
+
res = _context69.sent;
|
|
6342
|
+
return _context69.abrupt("return", res);
|
|
6028
6343
|
case 8:
|
|
6029
|
-
|
|
6030
|
-
|
|
6031
|
-
throw
|
|
6344
|
+
_context69.prev = 8;
|
|
6345
|
+
_context69.t0 = _context69["catch"](1);
|
|
6346
|
+
throw _context69.t0;
|
|
6032
6347
|
case 11:
|
|
6033
6348
|
case "end":
|
|
6034
|
-
return
|
|
6349
|
+
return _context69.stop();
|
|
6035
6350
|
}
|
|
6036
|
-
},
|
|
6351
|
+
}, _callee69, this, [[1, 8]]);
|
|
6037
6352
|
}));
|
|
6038
6353
|
function getProductList() {
|
|
6039
6354
|
return _getProductList.apply(this, arguments);
|
|
@@ -6048,31 +6363,31 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
6048
6363
|
}, {
|
|
6049
6364
|
key: "setOtherParams",
|
|
6050
6365
|
value: function () {
|
|
6051
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6052
|
-
var _this$
|
|
6053
|
-
var
|
|
6054
|
-
|
|
6366
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70(params) {
|
|
6367
|
+
var _this$otherParams37;
|
|
6368
|
+
var _ref48,
|
|
6369
|
+
_ref48$cover,
|
|
6055
6370
|
cover,
|
|
6056
|
-
|
|
6057
|
-
return _regeneratorRuntime().wrap(function
|
|
6058
|
-
while (1) switch (
|
|
6371
|
+
_args70 = arguments;
|
|
6372
|
+
return _regeneratorRuntime().wrap(function _callee70$(_context70) {
|
|
6373
|
+
while (1) switch (_context70.prev = _context70.next) {
|
|
6059
6374
|
case 0:
|
|
6060
|
-
|
|
6375
|
+
_ref48 = _args70.length > 1 && _args70[1] !== undefined ? _args70[1] : {}, _ref48$cover = _ref48.cover, cover = _ref48$cover === void 0 ? false : _ref48$cover;
|
|
6061
6376
|
if (cover) {
|
|
6062
6377
|
this.otherParams = _objectSpread({}, params);
|
|
6063
6378
|
} else {
|
|
6064
6379
|
this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
|
|
6065
6380
|
}
|
|
6066
|
-
this.cacheId = (_this$
|
|
6067
|
-
|
|
6381
|
+
this.cacheId = (_this$otherParams37 = this.otherParams) === null || _this$otherParams37 === void 0 ? void 0 : _this$otherParams37.cacheId;
|
|
6382
|
+
_context70.next = 5;
|
|
6068
6383
|
return this.syncOtherParamsToSubModules(params, {
|
|
6069
6384
|
cover: cover
|
|
6070
6385
|
});
|
|
6071
6386
|
case 5:
|
|
6072
6387
|
case "end":
|
|
6073
|
-
return
|
|
6388
|
+
return _context70.stop();
|
|
6074
6389
|
}
|
|
6075
|
-
},
|
|
6390
|
+
}, _callee70, this);
|
|
6076
6391
|
}));
|
|
6077
6392
|
function setOtherParams(_x62) {
|
|
6078
6393
|
return _setOtherParams.apply(this, arguments);
|