@pisell/pisellos 2.3.40 → 2.3.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +7 -0
- package/dist/model/strategy/adapter/promotion/adapter.d.ts +4 -0
- package/dist/model/strategy/adapter/promotion/adapter.js +23 -0
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
- package/dist/model/strategy/adapter/promotion/evaluator.js +279 -6
- package/dist/model/strategy/adapter/promotion/examples.d.ts +86 -0
- package/dist/model/strategy/adapter/promotion/examples.js +99 -0
- package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/model/strategy/adapter/promotion/type.d.ts +90 -2
- package/dist/model/strategy/adapter/promotion/type.js +45 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -3
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +6 -3
- package/dist/modules/Discount/index.d.ts +0 -1
- package/dist/modules/Discount/index.js +11 -40
- package/dist/modules/Discount/types.d.ts +0 -1
- package/dist/modules/OpenData/index.d.ts +2 -0
- package/dist/modules/OpenData/index.js +10 -2
- package/dist/modules/Order/index.d.ts +29 -12
- package/dist/modules/Order/index.js +750 -509
- package/dist/modules/Order/payment-utils.d.ts +26 -0
- package/dist/modules/Order/payment-utils.js +225 -0
- package/dist/modules/Order/types.d.ts +33 -10
- package/dist/modules/Order/utils/orderCollectionIdentity.js +7 -2
- package/dist/modules/Order/utils.d.ts +0 -10
- package/dist/modules/Order/utils.js +13 -41
- package/dist/modules/Payment/index.d.ts +2 -0
- package/dist/modules/Payment/index.js +79 -50
- package/dist/modules/Payment/types.d.ts +99 -28
- package/dist/modules/Payment/types.js +20 -3
- package/dist/modules/Payment/walletpass.d.ts +25 -1
- package/dist/modules/Payment/walletpass.js +707 -157
- package/dist/modules/Product/types.d.ts +0 -1
- package/dist/modules/ProductList/index.js +14 -33
- package/dist/modules/Quotation/index.d.ts +1 -1
- package/dist/modules/Quotation/index.js +2 -2
- package/dist/modules/Rules/index.d.ts +1 -0
- package/dist/modules/Rules/index.js +89 -96
- package/dist/modules/SalesSummary/index.js +13 -12
- package/dist/modules/ScanOrderLogger/index.d.ts +0 -2
- package/dist/modules/ScanOrderLogger/index.js +2 -15
- package/dist/modules/ScanOrderLogger/providers/feishu.js +27 -45
- package/dist/modules/ScanOrderLogger/types.d.ts +0 -1
- package/dist/modules/Schedule/index.d.ts +1 -3
- package/dist/modules/Schedule/index.js +16 -21
- package/dist/modules/Summary/utils.js +13 -38
- package/dist/modules/index.d.ts +0 -2
- package/dist/modules/index.js +1 -3
- package/dist/plugins/window.d.ts +0 -1
- package/dist/server/index.d.ts +16 -14
- package/dist/server/index.js +1925 -1143
- package/dist/server/modules/order/index.d.ts +54 -4
- package/dist/server/modules/order/index.js +1600 -700
- package/dist/server/modules/order/types.d.ts +11 -3
- package/dist/server/modules/order/types.js +1 -1
- package/dist/solution/BaseSales/index.d.ts +109 -20
- package/dist/solution/BaseSales/index.js +1800 -480
- package/dist/solution/BaseSales/types.d.ts +52 -0
- package/dist/solution/BaseSales/types.js +2 -1
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/dist/solution/BaseSales/utils/cartPromotion.js +90 -31
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
- package/dist/solution/BookingByStep/index.d.ts +2 -17
- package/dist/solution/BookingByStep/index.js +215 -294
- package/dist/solution/BookingByStep/types.d.ts +1 -2
- package/dist/solution/BookingByStep/types.js +1 -3
- package/dist/solution/BookingByStep/utils/capacity.js +1 -17
- package/dist/solution/BookingByStep/utils/timeslots.d.ts +1 -3
- package/dist/solution/BookingByStep/utils/timeslots.js +12 -19
- package/dist/solution/BookingTicket/index.d.ts +8 -4
- package/dist/solution/BookingTicket/index.js +134 -51
- package/dist/solution/BookingTicket/utils/addProductDecision.js +6 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +172 -82
- package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +1 -3
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +2 -10
- package/dist/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
- package/dist/solution/BookingTicket/utils/weighingProductSku.js +45 -0
- package/dist/solution/Sales/index.d.ts +1 -0
- package/dist/solution/Sales/index.js +10 -2
- package/dist/solution/ScanOrder/index.d.ts +14 -26
- package/dist/solution/ScanOrder/index.js +756 -1148
- package/dist/solution/ScanOrder/types.d.ts +1 -21
- package/dist/solution/ScanOrder/utils.d.ts +0 -8
- package/dist/solution/ScanOrder/utils.js +25 -66
- package/dist/solution/ShopDiscount/index.d.ts +0 -1
- package/dist/solution/ShopDiscount/index.js +87 -125
- package/dist/solution/VenueBooking/index.d.ts +11 -39
- package/dist/solution/VenueBooking/index.js +860 -1176
- package/dist/solution/VenueBooking/types.d.ts +0 -3
- package/dist/solution/VenueBooking/utils/resource.js +0 -1
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
- package/dist/solution/VenueBooking/utils/slotMerge.js +5 -10
- package/dist/solution/index.d.ts +0 -1
- package/dist/solution/index.js +1 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/payment-number.d.ts +9 -0
- package/dist/utils/payment-number.js +69 -0
- package/lib/core/index.d.ts +2 -0
- package/lib/core/index.js +4 -0
- package/lib/model/strategy/adapter/promotion/adapter.d.ts +4 -0
- package/lib/model/strategy/adapter/promotion/adapter.js +20 -0
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
- package/lib/model/strategy/adapter/promotion/evaluator.js +235 -0
- package/lib/model/strategy/adapter/promotion/examples.d.ts +86 -0
- package/lib/model/strategy/adapter/promotion/examples.js +91 -0
- package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +2 -0
- package/lib/model/strategy/adapter/promotion/type.d.ts +90 -2
- package/lib/model/strategy/adapter/promotion/type.js +2 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +2 -1
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
- package/lib/modules/Discount/index.d.ts +0 -1
- package/lib/modules/Discount/index.js +0 -9
- package/lib/modules/Discount/types.d.ts +0 -1
- package/lib/modules/OpenData/index.d.ts +2 -0
- package/lib/modules/OpenData/index.js +6 -1
- package/lib/modules/Order/index.d.ts +29 -12
- package/lib/modules/Order/index.js +196 -86
- package/lib/modules/Order/payment-utils.d.ts +26 -0
- package/lib/modules/Order/payment-utils.js +224 -0
- package/lib/modules/Order/types.d.ts +33 -10
- package/lib/modules/Order/utils/orderCollectionIdentity.js +3 -0
- package/lib/modules/Order/utils.d.ts +0 -10
- package/lib/modules/Order/utils.js +16 -40
- package/lib/modules/Payment/index.d.ts +2 -0
- package/lib/modules/Payment/index.js +34 -13
- package/lib/modules/Payment/types.d.ts +99 -28
- package/lib/modules/Payment/types.js +4 -3
- package/lib/modules/Payment/walletpass.d.ts +25 -1
- package/lib/modules/Payment/walletpass.js +470 -21
- package/lib/modules/Product/types.d.ts +0 -1
- package/lib/modules/ProductList/index.js +31 -40
- package/lib/modules/Quotation/index.d.ts +1 -1
- package/lib/modules/Quotation/index.js +2 -2
- package/lib/modules/Rules/index.d.ts +1 -0
- package/lib/modules/Rules/index.js +47 -40
- package/lib/modules/SalesSummary/index.js +7 -6
- package/lib/modules/ScanOrderLogger/index.d.ts +0 -2
- package/lib/modules/ScanOrderLogger/index.js +1 -13
- package/lib/modules/ScanOrderLogger/providers/feishu.js +6 -15
- package/lib/modules/ScanOrderLogger/types.d.ts +0 -1
- package/lib/modules/Schedule/index.d.ts +1 -3
- package/lib/modules/Schedule/index.js +8 -10
- package/lib/modules/Summary/utils.js +1 -21
- package/lib/modules/index.d.ts +0 -2
- package/lib/modules/index.js +1 -5
- package/lib/plugins/window.d.ts +0 -1
- package/lib/server/index.d.ts +16 -14
- package/lib/server/index.js +675 -83
- package/lib/server/modules/order/index.d.ts +54 -4
- package/lib/server/modules/order/index.js +679 -66
- package/lib/server/modules/order/types.d.ts +11 -3
- package/lib/solution/BaseSales/index.d.ts +109 -20
- package/lib/solution/BaseSales/index.js +883 -70
- package/lib/solution/BaseSales/types.d.ts +52 -0
- package/lib/solution/BaseSales/types.js +2 -1
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/lib/solution/BaseSales/utils/cartPromotion.js +63 -12
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
- package/lib/solution/BookingByStep/index.d.ts +2 -17
- package/lib/solution/BookingByStep/index.js +18 -60
- package/lib/solution/BookingByStep/types.d.ts +1 -2
- package/lib/solution/BookingByStep/types.js +0 -5
- package/lib/solution/BookingByStep/utils/capacity.js +1 -20
- package/lib/solution/BookingByStep/utils/timeslots.d.ts +1 -3
- package/lib/solution/BookingByStep/utils/timeslots.js +11 -19
- package/lib/solution/BookingTicket/index.d.ts +8 -4
- package/lib/solution/BookingTicket/index.js +64 -19
- package/lib/solution/BookingTicket/utils/addProductDecision.js +4 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +36 -4
- package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +1 -3
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -2
- package/lib/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
- package/lib/solution/BookingTicket/utils/weighingProductSku.js +63 -0
- package/lib/solution/Sales/index.d.ts +1 -0
- package/lib/solution/Sales/index.js +5 -3
- package/lib/solution/ScanOrder/index.d.ts +14 -26
- package/lib/solution/ScanOrder/index.js +190 -449
- package/lib/solution/ScanOrder/types.d.ts +1 -21
- package/lib/solution/ScanOrder/utils.d.ts +0 -8
- package/lib/solution/ScanOrder/utils.js +0 -31
- package/lib/solution/ShopDiscount/index.d.ts +0 -1
- package/lib/solution/ShopDiscount/index.js +0 -14
- package/lib/solution/VenueBooking/index.d.ts +11 -39
- package/lib/solution/VenueBooking/index.js +123 -328
- package/lib/solution/VenueBooking/types.d.ts +0 -3
- package/lib/solution/VenueBooking/utils/resource.js +0 -1
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
- package/lib/solution/VenueBooking/utils/slotMerge.js +4 -6
- package/lib/solution/index.d.ts +0 -1
- package/lib/solution/index.js +1 -3
- package/lib/types/index.d.ts +1 -1
- package/lib/utils/payment-number.d.ts +9 -0
- package/lib/utils/payment-number.js +64 -0
- package/package.json +1 -1
- package/dist/modules/Holder/index.d.ts +0 -48
- package/dist/modules/Holder/index.js +0 -640
- package/dist/modules/Holder/types.d.ts +0 -123
- package/dist/modules/Holder/types.js +0 -1
- package/dist/modules/Holder/utils.d.ts +0 -13
- package/dist/modules/Holder/utils.js +0 -34
- package/dist/modules/ResourcePlanner/index.d.ts +0 -24
- package/dist/modules/ResourcePlanner/index.js +0 -181
- package/dist/modules/ResourcePlanner/planner.d.ts +0 -14
- package/dist/modules/ResourcePlanner/planner.js +0 -1069
- package/dist/modules/ResourcePlanner/types.d.ts +0 -227
- package/dist/modules/ResourcePlanner/types.js +0 -1
- package/dist/solution/UnifiedBookingSales/index.d.ts +0 -183
- package/dist/solution/UnifiedBookingSales/index.js +0 -1871
- package/dist/solution/UnifiedBookingSales/types.d.ts +0 -143
- package/dist/solution/UnifiedBookingSales/types.js +0 -11
- package/lib/modules/Holder/index.d.ts +0 -48
- package/lib/modules/Holder/index.js +0 -402
- package/lib/modules/Holder/types.d.ts +0 -123
- package/lib/modules/Holder/types.js +0 -17
- package/lib/modules/Holder/utils.d.ts +0 -13
- package/lib/modules/Holder/utils.js +0 -71
- package/lib/modules/ResourcePlanner/index.d.ts +0 -24
- package/lib/modules/ResourcePlanner/index.js +0 -148
- package/lib/modules/ResourcePlanner/planner.d.ts +0 -14
- package/lib/modules/ResourcePlanner/planner.js +0 -933
- package/lib/modules/ResourcePlanner/types.d.ts +0 -227
- package/lib/modules/ResourcePlanner/types.js +0 -17
- package/lib/solution/UnifiedBookingSales/index.d.ts +0 -183
- package/lib/solution/UnifiedBookingSales/index.js +0 -1076
- package/lib/solution/UnifiedBookingSales/types.d.ts +0 -143
- package/lib/solution/UnifiedBookingSales/types.js +0 -33
|
@@ -37,6 +37,8 @@ import Decimal from 'decimal.js';
|
|
|
37
37
|
import { cloneDeep, 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 { ensureOrderPaymentNumber, isIdentifiedPendingOrderPayment, isPendingOrderPayment, mergeOrderPaymentListsByIdentity, resolveOrderPaymentIdentity } from "../../modules/Order/payment-utils";
|
|
41
|
+
import { resolvePaymentNumberDevicePrefix, resolvePaymentNumberDevicePrefixFromDeviceId } from "../../utils/payment-number";
|
|
40
42
|
import { applyOrderCollectionUidRemaps, getOrderCollectionPersistentId, getOrderCollectionReferenceUid, getOrderCollectionUid, isSameOrderCollectionItem, mergeOrderCollectionItems, normalizeOrderCollection, normalizeOrderCollections, setOrderCollectionUid } from "../../modules/Order/utils/orderCollectionIdentity";
|
|
41
43
|
import dayjs from 'dayjs';
|
|
42
44
|
export * from "./types";
|
|
@@ -44,6 +46,89 @@ import { QuotationModule } from "../../modules/Quotation";
|
|
|
44
46
|
import { transformBaseProductToOrderProduct as _transformBaseProductToOrderProduct } from "./utils/transformBaseProductToOrderProduct";
|
|
45
47
|
import { calculateBaseSalesProductBookingPrice } from "./utils/quotationPrice";
|
|
46
48
|
var SERVER_ORDER_CHANGED_EVENT = 'order:onOrdersChanged';
|
|
49
|
+
var WALLET_PAYMENT_CODE_BY_TAG = {
|
|
50
|
+
product_voucher: 'PRODUCTVOUCHER',
|
|
51
|
+
gift_card: 'GIFTCARD',
|
|
52
|
+
point_card: 'POINTCARD'
|
|
53
|
+
};
|
|
54
|
+
function getSharedWalletAssetId(asset) {
|
|
55
|
+
var _ref, _asset$id;
|
|
56
|
+
return (_ref = (_asset$id = asset === null || asset === void 0 ? void 0 : asset.id) !== null && _asset$id !== void 0 ? _asset$id : asset === null || asset === void 0 ? void 0 : asset.voucher_id) !== null && _ref !== void 0 ? _ref : asset === null || asset === void 0 ? void 0 : asset.code;
|
|
57
|
+
}
|
|
58
|
+
function getSharedWalletAssetAmount(asset) {
|
|
59
|
+
var _ref2, _ref3, _ref4, _ref5, _asset$edit_current_a;
|
|
60
|
+
var value = (_ref2 = (_ref3 = (_ref4 = (_ref5 = (_asset$edit_current_a = asset === null || asset === void 0 ? void 0 : asset.edit_current_amount) !== null && _asset$edit_current_a !== void 0 ? _asset$edit_current_a : asset === null || asset === void 0 ? void 0 : asset._available_max_amount) !== null && _ref5 !== void 0 ? _ref5 : (asset === null || asset === void 0 ? void 0 : asset.tag) === 'point_card' ? asset === null || asset === void 0 ? void 0 : asset.recommended_usage_amount : asset === null || asset === void 0 ? void 0 : asset.available_max_amount) !== null && _ref4 !== void 0 ? _ref4 : asset === null || asset === void 0 ? void 0 : asset.actualDeduction) !== null && _ref3 !== void 0 ? _ref3 : asset === null || asset === void 0 ? void 0 : asset.amount) !== null && _ref2 !== void 0 ? _ref2 : 0;
|
|
61
|
+
var amount = Number(value);
|
|
62
|
+
return Number.isFinite(amount) && amount > 0 ? amount : 0;
|
|
63
|
+
}
|
|
64
|
+
function isRejectedSalesSubmitResult(result) {
|
|
65
|
+
var _result$response, _result$response2;
|
|
66
|
+
var candidates = [result, result === null || result === void 0 ? void 0 : result.data, result === null || result === void 0 || (_result$response = result.response) === null || _result$response === void 0 ? void 0 : _result$response.data, result === null || result === void 0 || (_result$response2 = result.response) === null || _result$response2 === void 0 ? void 0 : _result$response2.body];
|
|
67
|
+
return candidates.some(function (candidate) {
|
|
68
|
+
var _candidate$code;
|
|
69
|
+
if (!candidate || _typeof(candidate) !== 'object') return false;
|
|
70
|
+
var responseCode = Number((_candidate$code = candidate.code) !== null && _candidate$code !== void 0 ? _candidate$code : candidate.statusCode);
|
|
71
|
+
if (Number.isFinite(responseCode) && responseCode >= 400) return true;
|
|
72
|
+
if (candidate.status === false || candidate.success === false || candidate.result === false) {
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
return ['failed', 'error'].includes(String(candidate.status || '').toLowerCase());
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function getSalesSubmitErrorMessage(result) {
|
|
79
|
+
var _result$data, _result$data2;
|
|
80
|
+
return (result === null || result === void 0 ? void 0 : result.message) || (result === null || result === void 0 ? void 0 : result.msg) || (result === null || result === void 0 || (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.message) || (result === null || result === void 0 || (_result$data2 = result.data) === null || _result$data2 === void 0 ? void 0 : _result$data2.msg) || 'Wallet 支付确认失败';
|
|
81
|
+
}
|
|
82
|
+
function toWalletFundValue(value) {
|
|
83
|
+
try {
|
|
84
|
+
return new Decimal(value || 0).toDecimalPlaces(2).toFixed(2);
|
|
85
|
+
} catch (_unused) {
|
|
86
|
+
return '0.00';
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function subtractWalletFundValue(left, right) {
|
|
90
|
+
try {
|
|
91
|
+
return new Decimal(left || 0).minus(right || 0).toDecimalPlaces(2).toFixed(2);
|
|
92
|
+
} catch (_unused2) {
|
|
93
|
+
return '0.00';
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function getSharedWalletPassUseValue(params) {
|
|
97
|
+
var asset = params.asset,
|
|
98
|
+
amount = params.amount,
|
|
99
|
+
paymentMethod = params.paymentMethod;
|
|
100
|
+
var configuredValue = Number(asset === null || asset === void 0 ? void 0 : asset.wallet_pass_use_value);
|
|
101
|
+
if (Number.isFinite(configuredValue) && configuredValue > 0) {
|
|
102
|
+
return configuredValue;
|
|
103
|
+
}
|
|
104
|
+
var isPointCard = (asset === null || asset === void 0 ? void 0 : asset.tag) === 'point_card' || paymentMethod.code === 'POINTCARD';
|
|
105
|
+
var usageUnit = asset === null || asset === void 0 ? void 0 : asset.wallet_pass_usage_unit;
|
|
106
|
+
if (isPointCard && usageUnit !== null && usageUnit !== void 0 && usageUnit.points && usageUnit !== null && usageUnit !== void 0 && usageUnit.price) {
|
|
107
|
+
return new Decimal(amount).div(usageUnit.price).mul(usageUnit.points).toDecimalPlaces(2, Decimal.ROUND_DOWN).toNumber();
|
|
108
|
+
}
|
|
109
|
+
return amount;
|
|
110
|
+
}
|
|
111
|
+
function buildSharedWalletFundRecord(params) {
|
|
112
|
+
var _ref6, _ref7, _asset$balance_par_va, _asset$voucher_id;
|
|
113
|
+
var asset = params.asset,
|
|
114
|
+
amount = params.amount,
|
|
115
|
+
paymentMethod = params.paymentMethod;
|
|
116
|
+
var isPointCard = (asset === null || asset === void 0 ? void 0 : asset.tag) === 'point_card' || paymentMethod.code === 'POINTCARD';
|
|
117
|
+
var usingBeforeValue = (_ref6 = (_ref7 = (_asset$balance_par_va = asset === null || asset === void 0 ? void 0 : asset.balance_par_value) !== null && _asset$balance_par_va !== void 0 ? _asset$balance_par_va : asset === null || asset === void 0 ? void 0 : asset.balance) !== null && _ref7 !== void 0 ? _ref7 : asset === null || asset === void 0 ? void 0 : asset.using_before_value) !== null && _ref6 !== void 0 ? _ref6 : 0;
|
|
118
|
+
var walletPassUseValue = getSharedWalletPassUseValue(params);
|
|
119
|
+
var usingValue = isPointCard ? walletPassUseValue : amount;
|
|
120
|
+
var walletPassName = (asset === null || asset === void 0 ? void 0 : asset.wallet_pass_name) || (asset === null || asset === void 0 ? void 0 : asset.format_title) || (asset === null || asset === void 0 ? void 0 : asset.product_name) || (asset === null || asset === void 0 ? void 0 : asset.name) || paymentMethod.name;
|
|
121
|
+
return {
|
|
122
|
+
voucher_id: (_asset$voucher_id = asset === null || asset === void 0 ? void 0 : asset.voucher_id) !== null && _asset$voucher_id !== void 0 ? _asset$voucher_id : asset === null || asset === void 0 ? void 0 : asset.id,
|
|
123
|
+
wallet_pass_name: walletPassName && _typeof(walletPassName) === 'object' ? walletPassName : {
|
|
124
|
+
default: walletPassName || ''
|
|
125
|
+
},
|
|
126
|
+
code: (asset === null || asset === void 0 ? void 0 : asset.code) || (asset === null || asset === void 0 ? void 0 : asset.tag),
|
|
127
|
+
encoded: asset === null || asset === void 0 ? void 0 : asset.encoded,
|
|
128
|
+
using_before_value: toWalletFundValue(usingBeforeValue),
|
|
129
|
+
using_after_value: subtractWalletFundValue(usingBeforeValue, usingValue)
|
|
130
|
+
};
|
|
131
|
+
}
|
|
47
132
|
function isBaseSalesManualProductDiscountProduct(product) {
|
|
48
133
|
var _product$metadata, _product$metadata2;
|
|
49
134
|
return (product === null || product === void 0 || (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.is_manual_discount) === true || (product === null || product === void 0 || (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.is_manual_discount) === 1 || ((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (item) {
|
|
@@ -72,6 +157,10 @@ function preserveManualProductDiscountProducts(previousProducts, nextProducts) {
|
|
|
72
157
|
function isBaseSalesHistoricalDiscountEntry(discount) {
|
|
73
158
|
return Boolean((discount === null || discount === void 0 ? void 0 : discount.isEditMode) || (discount === null || discount === void 0 ? void 0 : discount.isDisabled) || (discount === null || discount === void 0 ? void 0 : discount.order_discount_id) != null);
|
|
74
159
|
}
|
|
160
|
+
function getBaseSalesUniqueArrayMetadataKey(key) {
|
|
161
|
+
if (key === 'products' || key === 'bookings') return 'unique_identification_number';
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
75
164
|
var BASE_SALES_PERSISTENT_ID_FIELD_BY_KIND = {
|
|
76
165
|
product: 'order_detail_id',
|
|
77
166
|
booking: 'schedule_event_id',
|
|
@@ -143,6 +232,15 @@ function mergeBaseSalesCollectionItem(kind, currentItem, incomingItem, uidRemaps
|
|
|
143
232
|
return kind === 'product' ? mergeBaseSalesProductSnapshotFields(currentItem, mergedItem) : mergedItem;
|
|
144
233
|
}
|
|
145
234
|
function mergeBaseSalesOrderCollection(kind, currentValue, incomingValue, strategy, uidRemaps) {
|
|
235
|
+
if (kind === 'payment') {
|
|
236
|
+
return mergeOrderPaymentListsByIdentity(currentValue, incomingValue, strategy === 'preserve-local' ? {
|
|
237
|
+
preserveUnmatchedExisting: true
|
|
238
|
+
} : {
|
|
239
|
+
preserveUnmatchedExistingWhen: function preserveUnmatchedExistingWhen(payment) {
|
|
240
|
+
return isIdentifiedPendingOrderPayment(payment) || !getOrderCollectionPersistentId('payment', payment);
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
}
|
|
146
244
|
var currentItems = normalizeOrderCollection(kind, currentValue, {
|
|
147
245
|
ensureUid: false
|
|
148
246
|
}).items;
|
|
@@ -189,6 +287,34 @@ function normalizeBaseSalesRecordCollections(sourceRecord, options) {
|
|
|
189
287
|
}
|
|
190
288
|
return normalizedRecord;
|
|
191
289
|
}
|
|
290
|
+
function getBaseSalesMetadataUid(item, metadataKey) {
|
|
291
|
+
var _item$metadata$metada, _item$metadata;
|
|
292
|
+
var uid = (_item$metadata$metada = item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata[metadataKey]) !== null && _item$metadata$metada !== void 0 ? _item$metadata$metada : item === null || item === void 0 ? void 0 : item[metadataKey];
|
|
293
|
+
if (uid === undefined || uid === null || uid === '') return null;
|
|
294
|
+
return String(uid);
|
|
295
|
+
}
|
|
296
|
+
function mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey) {
|
|
297
|
+
var result = [];
|
|
298
|
+
var indexByUid = new Map();
|
|
299
|
+
var appendOrReplaceByUid = function appendOrReplaceByUid(item) {
|
|
300
|
+
var clonedItem = cloneDeep(item);
|
|
301
|
+
var uid = getBaseSalesMetadataUid(clonedItem, metadataKey);
|
|
302
|
+
if (!uid) {
|
|
303
|
+
result.push(clonedItem);
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
var existingIndex = indexByUid.get(uid);
|
|
307
|
+
if (existingIndex !== undefined) {
|
|
308
|
+
result[existingIndex] = clonedItem;
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
indexByUid.set(uid, result.length);
|
|
312
|
+
result.push(clonedItem);
|
|
313
|
+
};
|
|
314
|
+
currentValue.forEach(appendOrReplaceByUid);
|
|
315
|
+
loadedValue.forEach(appendOrReplaceByUid);
|
|
316
|
+
return result;
|
|
317
|
+
}
|
|
192
318
|
function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, strategy) {
|
|
193
319
|
var normalizedLoadedRecord = normalizeBaseSalesRecordCollections(loadedRecord || {}, {
|
|
194
320
|
ensureUid: false
|
|
@@ -206,6 +332,15 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, str
|
|
|
206
332
|
return mergeBaseSalesOrderCollection(collectionKind, Array.isArray(currentValue) ? currentValue : [], loadedValue, strategy, uidRemaps);
|
|
207
333
|
}
|
|
208
334
|
if (Array.isArray(currentValue) && Array.isArray(loadedValue)) {
|
|
335
|
+
if (key === 'payments' || key === 'payment') {
|
|
336
|
+
return mergeOrderPaymentListsByIdentity(currentValue, loadedValue, {
|
|
337
|
+
preserveUnmatchedExisting: true
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
var metadataKey = getBaseSalesUniqueArrayMetadataKey(key);
|
|
341
|
+
if (metadataKey) {
|
|
342
|
+
return mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey);
|
|
343
|
+
}
|
|
209
344
|
return [].concat(_toConsumableArray(cloneDeep(currentValue)), _toConsumableArray(cloneDeep(loadedValue)));
|
|
210
345
|
}
|
|
211
346
|
if (Array.isArray(loadedValue)) return cloneDeep(loadedValue);
|
|
@@ -217,6 +352,22 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, str
|
|
|
217
352
|
delete mergedRecord.request_unique_idempotency_token;
|
|
218
353
|
return normalizeBaseSalesRecordCollections(applyOrderCollectionUidRemaps(mergedRecord, uidRemaps));
|
|
219
354
|
}
|
|
355
|
+
function filterPendingPaymentsFromLoadedSalesDetail(sourceRecord) {
|
|
356
|
+
if (!sourceRecord || _typeof(sourceRecord) !== 'object') return sourceRecord;
|
|
357
|
+
var record = _objectSpread({}, sourceRecord);
|
|
358
|
+
if (Array.isArray(sourceRecord.payments)) {
|
|
359
|
+
record.payments = sourceRecord.payments.filter(function (payment) {
|
|
360
|
+
return !isPendingOrderPayment(payment);
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
// 兼容少量历史详情数据使用的单数 payment 字段。
|
|
364
|
+
if (Array.isArray(sourceRecord.payment)) {
|
|
365
|
+
record.payment = sourceRecord.payment.filter(function (payment) {
|
|
366
|
+
return !isPendingOrderPayment(payment);
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
return record;
|
|
370
|
+
}
|
|
220
371
|
export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
221
372
|
_inherits(BaseSalesImpl, _BaseModule);
|
|
222
373
|
var _super = _createSuper(BaseSalesImpl);
|
|
@@ -236,6 +387,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
236
387
|
});
|
|
237
388
|
_defineProperty(_assertThisInitialized(_this), "otherParams", {});
|
|
238
389
|
_defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
|
|
390
|
+
/**
|
|
391
|
+
* 由已在初始化阶段解析过设备短号的业务解决方案写入。
|
|
392
|
+
* 未设置时,支付编号仍按原逻辑实时读取设备信息。
|
|
393
|
+
*/
|
|
394
|
+
_defineProperty(_assertThisInitialized(_this), "paymentNumberDevicePrefix", null);
|
|
239
395
|
/**
|
|
240
396
|
* window / request 暴露为 public:现存外部工具(如 BookingTicket Scan)通过
|
|
241
397
|
* `solution.window` / `solution.request` 直接访问插件,保持原有契约不破坏。
|
|
@@ -253,6 +409,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
253
409
|
_defineProperty(_assertThisInitialized(_this), "autoPaymentSyncTimer", null);
|
|
254
410
|
_defineProperty(_assertThisInitialized(_this), "salesDetailLoadInFlightCount", 0);
|
|
255
411
|
_defineProperty(_assertThisInitialized(_this), "salesDetailLoadSequence", 0);
|
|
412
|
+
_defineProperty(_assertThisInitialized(_this), "walletAssetsRefreshSequence", 0);
|
|
256
413
|
_defineProperty(_assertThisInitialized(_this), "salesDetailHydrateQueue", Promise.resolve());
|
|
257
414
|
_defineProperty(_assertThisInitialized(_this), "serverOrderChangeUnsubscribe", null);
|
|
258
415
|
_defineProperty(_assertThisInitialized(_this), "serverOrderChangeHydrateInFlight", null);
|
|
@@ -445,12 +602,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
445
602
|
return _context3.abrupt("return");
|
|
446
603
|
case 14:
|
|
447
604
|
this.serverOrderChangeHydrateInFlight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
448
|
-
var _getTempOrder,
|
|
605
|
+
var _getTempOrder, _ref9;
|
|
449
606
|
var currentTempOrder, record, sales;
|
|
450
607
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
451
608
|
while (1) switch (_context2.prev = _context2.next) {
|
|
452
609
|
case 0:
|
|
453
|
-
currentTempOrder = (_getTempOrder = (
|
|
610
|
+
currentTempOrder = (_getTempOrder = (_ref9 = _this2.store.order).getTempOrder) === null || _getTempOrder === void 0 ? void 0 : _getTempOrder.call(_ref9);
|
|
454
611
|
record = mergeSalesDetailRecordWithTempOrder(currentTempOrder, changedOrder, 'authoritative-incoming');
|
|
455
612
|
_context2.next = 4;
|
|
456
613
|
return _this2.store.order.hydrateTempOrderFromRecord(record, {
|
|
@@ -519,7 +676,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
519
676
|
hydratedSales = null;
|
|
520
677
|
skippedBeforeHydrate = false;
|
|
521
678
|
hydrateTask = /*#__PURE__*/function () {
|
|
522
|
-
var
|
|
679
|
+
var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
523
680
|
var sales;
|
|
524
681
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
525
682
|
while (1) switch (_context4.prev = _context4.next) {
|
|
@@ -564,7 +721,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
564
721
|
}, _callee4);
|
|
565
722
|
}));
|
|
566
723
|
return function hydrateTask() {
|
|
567
|
-
return
|
|
724
|
+
return _ref10.apply(this, arguments);
|
|
568
725
|
};
|
|
569
726
|
}();
|
|
570
727
|
queuedTask = this.salesDetailHydrateQueue.then(hydrateTask, hydrateTask);
|
|
@@ -658,10 +815,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
658
815
|
});
|
|
659
816
|
}
|
|
660
817
|
quotation.setScheduleResolver(function (id) {
|
|
661
|
-
var _scheduleModule$getSc, _getScheduleByIds,
|
|
818
|
+
var _scheduleModule$getSc, _getScheduleByIds, _ref11;
|
|
662
819
|
var scheduleId = String(id);
|
|
663
820
|
if (scheduleById.has(scheduleId)) return scheduleById.get(scheduleId);
|
|
664
|
-
var schedules = ((_scheduleModule$getSc = scheduleModule.getScheduleListByIds) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule, [id])) || ((_getScheduleByIds = (
|
|
821
|
+
var schedules = ((_scheduleModule$getSc = scheduleModule.getScheduleListByIds) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule, [id])) || ((_getScheduleByIds = (_ref11 = scheduleModule).getScheduleByIds) === null || _getScheduleByIds === void 0 ? void 0 : _getScheduleByIds.call(_ref11, [id])) || [];
|
|
665
822
|
if (schedules[0]) scheduleById.set(scheduleId, schedules[0]);
|
|
666
823
|
return schedules[0];
|
|
667
824
|
});
|
|
@@ -848,10 +1005,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
848
1005
|
return groups.flatMap(function (group) {
|
|
849
1006
|
var items = Array.isArray(group === null || group === void 0 ? void 0 : group.bundle_item) ? group.bundle_item : Array.isArray(group === null || group === void 0 ? void 0 : group.bundleItem) ? group.bundleItem : [];
|
|
850
1007
|
return items.map(function (item) {
|
|
851
|
-
var _item$group_id,
|
|
1008
|
+
var _item$group_id, _ref12, _item$bundle_group_id;
|
|
852
1009
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
853
1010
|
group_id: (_item$group_id = item === null || item === void 0 ? void 0 : item.group_id) !== null && _item$group_id !== void 0 ? _item$group_id : group === null || group === void 0 ? void 0 : group.id,
|
|
854
|
-
bundle_group_id: (
|
|
1011
|
+
bundle_group_id: (_ref12 = (_item$bundle_group_id = item === null || item === void 0 ? void 0 : item.bundle_group_id) !== null && _item$bundle_group_id !== void 0 ? _item$bundle_group_id : item === null || item === void 0 ? void 0 : item.group_id) !== null && _ref12 !== void 0 ? _ref12 : group === null || group === void 0 ? void 0 : group.id
|
|
855
1012
|
});
|
|
856
1013
|
});
|
|
857
1014
|
});
|
|
@@ -882,21 +1039,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
882
1039
|
}, {
|
|
883
1040
|
key: "getAuthoritativeBundleUnitPrice",
|
|
884
1041
|
value: function getAuthoritativeBundleUnitPrice(bundle) {
|
|
885
|
-
var
|
|
886
|
-
return (
|
|
1042
|
+
var _ref13, _ref14, _ref15, _bundle$price;
|
|
1043
|
+
return (_ref13 = (_ref14 = (_ref15 = (_bundle$price = bundle.price) !== null && _bundle$price !== void 0 ? _bundle$price : bundle.bundle_selling_price) !== null && _ref15 !== void 0 ? _ref15 : bundle.custom_price) !== null && _ref14 !== void 0 ? _ref14 : bundle.product_price) !== null && _ref13 !== void 0 ? _ref13 : bundle.base_price;
|
|
887
1044
|
}
|
|
888
1045
|
}, {
|
|
889
1046
|
key: "mergeProductForPriceQuery",
|
|
890
1047
|
value: function mergeProductForPriceQuery(product, authoritativeProduct) {
|
|
891
1048
|
var _this5 = this,
|
|
892
1049
|
_product$id,
|
|
893
|
-
|
|
1050
|
+
_ref16,
|
|
894
1051
|
_product$product_id2,
|
|
895
|
-
|
|
1052
|
+
_ref17,
|
|
896
1053
|
_product$product_vari,
|
|
897
|
-
|
|
1054
|
+
_ref18,
|
|
898
1055
|
_product$num,
|
|
899
|
-
|
|
1056
|
+
_ref19,
|
|
900
1057
|
_product$quantity,
|
|
901
1058
|
_product$metadata4;
|
|
902
1059
|
if (!authoritativeProduct) return product;
|
|
@@ -916,10 +1073,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
916
1073
|
});
|
|
917
1074
|
return _objectSpread(_objectSpread(_objectSpread({}, product), authoritativeProduct), {}, {
|
|
918
1075
|
id: (_product$id = product.id) !== null && _product$id !== void 0 ? _product$id : authoritativeProduct.id,
|
|
919
|
-
product_id: (
|
|
920
|
-
product_variant_id: (
|
|
921
|
-
num: (
|
|
922
|
-
quantity: (
|
|
1076
|
+
product_id: (_ref16 = (_product$product_id2 = product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : authoritativeProduct.product_id) !== null && _ref16 !== void 0 ? _ref16 : authoritativeProduct.id,
|
|
1077
|
+
product_variant_id: (_ref17 = (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : authoritativeProduct.product_variant_id) !== null && _ref17 !== void 0 ? _ref17 : 0,
|
|
1078
|
+
num: (_ref18 = (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : product.quantity) !== null && _ref18 !== void 0 ? _ref18 : authoritativeProduct.num,
|
|
1079
|
+
quantity: (_ref19 = (_product$quantity = product.quantity) !== null && _product$quantity !== void 0 ? _product$quantity : product.num) !== null && _ref19 !== void 0 ? _ref19 : authoritativeProduct.quantity,
|
|
923
1080
|
product_sku: function () {
|
|
924
1081
|
var authoritativeSku = ensureProductSku(authoritativeProduct);
|
|
925
1082
|
var productSku = ensureProductSku(product);
|
|
@@ -995,24 +1152,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
995
1152
|
value: (function () {
|
|
996
1153
|
var _syncOtherParamsToSubModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(changedParams) {
|
|
997
1154
|
var _this6 = this;
|
|
998
|
-
var
|
|
999
|
-
|
|
1155
|
+
var _ref20,
|
|
1156
|
+
_ref20$cover,
|
|
1000
1157
|
cover,
|
|
1001
1158
|
nextSubModuleOtherParams,
|
|
1002
1159
|
_args10 = arguments;
|
|
1003
1160
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
1004
1161
|
while (1) switch (_context10.prev = _context10.next) {
|
|
1005
1162
|
case 0:
|
|
1006
|
-
|
|
1163
|
+
_ref20 = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : {}, _ref20$cover = _ref20.cover, cover = _ref20$cover === void 0 ? false : _ref20$cover;
|
|
1007
1164
|
nextSubModuleOtherParams = this.buildSubModuleOtherParams();
|
|
1008
1165
|
_context10.next = 4;
|
|
1009
1166
|
return Promise.all(Object.entries(this.store).map( /*#__PURE__*/function () {
|
|
1010
|
-
var
|
|
1011
|
-
var
|
|
1167
|
+
var _ref22 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(_ref21) {
|
|
1168
|
+
var _ref23, moduleName, subModule, targetModule;
|
|
1012
1169
|
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
1013
1170
|
while (1) switch (_context9.prev = _context9.next) {
|
|
1014
1171
|
case 0:
|
|
1015
|
-
|
|
1172
|
+
_ref23 = _slicedToArray(_ref21, 2), moduleName = _ref23[0], subModule = _ref23[1];
|
|
1016
1173
|
if (!_this6.reusedSharedSubModuleNames.has(moduleName)) {
|
|
1017
1174
|
_context9.next = 3;
|
|
1018
1175
|
break;
|
|
@@ -1038,7 +1195,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1038
1195
|
}, _callee9);
|
|
1039
1196
|
}));
|
|
1040
1197
|
return function (_x9) {
|
|
1041
|
-
return
|
|
1198
|
+
return _ref22.apply(this, arguments);
|
|
1042
1199
|
};
|
|
1043
1200
|
}()));
|
|
1044
1201
|
case 4:
|
|
@@ -1066,7 +1223,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1066
1223
|
if (!sessionData) return {};
|
|
1067
1224
|
var data = JSON.parse(sessionData);
|
|
1068
1225
|
return data && data[this.cacheId] || {};
|
|
1069
|
-
} catch (
|
|
1226
|
+
} catch (_unused3) {
|
|
1070
1227
|
return {};
|
|
1071
1228
|
}
|
|
1072
1229
|
}
|
|
@@ -1080,6 +1237,38 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1080
1237
|
var coreData = app === null || app === void 0 || (_app$models = app.models) === null || _app$models === void 0 || (_app$models$getStore = _app$models.getStore) === null || _app$models$getStore === void 0 || (_app$models$getStore$ = (_app$models$getStore$2 = _app$models$getStore.call(_app$models)).getDataByModel) === null || _app$models$getStore$ === void 0 ? void 0 : _app$models$getStore$.call(_app$models$getStore$2, 'core', 'core');
|
|
1081
1238
|
return coreData === null || coreData === void 0 ? void 0 : coreData[key];
|
|
1082
1239
|
}
|
|
1240
|
+
|
|
1241
|
+
/**
|
|
1242
|
+
* 复用业务解决方案初始化时已解析的支付设备短号。
|
|
1243
|
+
* 空值会清除缓存,使后续支付恢复实时读取设备信息的兼容路径。
|
|
1244
|
+
*/
|
|
1245
|
+
}, {
|
|
1246
|
+
key: "setPaymentNumberDevicePrefix",
|
|
1247
|
+
value: function setPaymentNumberDevicePrefix(prefix) {
|
|
1248
|
+
var normalized = String(prefix !== null && prefix !== void 0 ? prefix : '').trim();
|
|
1249
|
+
this.paymentNumberDevicePrefix = normalized || null;
|
|
1250
|
+
}
|
|
1251
|
+
}, {
|
|
1252
|
+
key: "getPaymentNumberDevicePrefixSync",
|
|
1253
|
+
value: function getPaymentNumberDevicePrefixSync() {
|
|
1254
|
+
var _this7 = this;
|
|
1255
|
+
if (!this.appPlugin) return 'LOCAL';
|
|
1256
|
+
return resolvePaymentNumberDevicePrefixFromDeviceId(function (key) {
|
|
1257
|
+
return _this7.getAppData(key);
|
|
1258
|
+
});
|
|
1259
|
+
}
|
|
1260
|
+
}, {
|
|
1261
|
+
key: "getPaymentNumberDevicePrefixAsync",
|
|
1262
|
+
value: function getPaymentNumberDevicePrefixAsync() {
|
|
1263
|
+
var _this8 = this;
|
|
1264
|
+
if (!this.appPlugin) return Promise.resolve('LOCAL');
|
|
1265
|
+
if (this.paymentNumberDevicePrefix) {
|
|
1266
|
+
return Promise.resolve(this.paymentNumberDevicePrefix);
|
|
1267
|
+
}
|
|
1268
|
+
return resolvePaymentNumberDevicePrefix(function (key) {
|
|
1269
|
+
return _this8.getAppData(key);
|
|
1270
|
+
});
|
|
1271
|
+
}
|
|
1083
1272
|
}, {
|
|
1084
1273
|
key: "syncAppDataToTempOrder",
|
|
1085
1274
|
value: function syncAppDataToTempOrder(tempOrder) {
|
|
@@ -1123,9 +1312,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1123
1312
|
value: function () {
|
|
1124
1313
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(core) {
|
|
1125
1314
|
var _this$otherParams4,
|
|
1126
|
-
|
|
1127
|
-
_this$appPlugin2$getA,
|
|
1128
|
-
_this7 = this,
|
|
1315
|
+
_this9 = this,
|
|
1129
1316
|
_this$otherParams5;
|
|
1130
1317
|
var options,
|
|
1131
1318
|
app,
|
|
@@ -1138,6 +1325,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1138
1325
|
options = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {};
|
|
1139
1326
|
this.core = core;
|
|
1140
1327
|
this.initializeOptions = options || {};
|
|
1328
|
+
this.paymentNumberDevicePrefix = null;
|
|
1141
1329
|
// this.store = { ...this.store, ...(options.store as Partial<BaseSalesState>) };
|
|
1142
1330
|
this.otherParams = options.otherParams || {};
|
|
1143
1331
|
this.cacheId = (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.cacheId;
|
|
@@ -1147,50 +1335,53 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1147
1335
|
|
|
1148
1336
|
// 获取 logger 实例
|
|
1149
1337
|
this.appPlugin = core.getPlugin('app');
|
|
1150
|
-
if (
|
|
1151
|
-
|
|
1338
|
+
if (this.appPlugin) {
|
|
1339
|
+
_context11.next = 12;
|
|
1340
|
+
break;
|
|
1152
1341
|
}
|
|
1153
|
-
|
|
1154
|
-
|
|
1342
|
+
throw new Error('Checkout 解决方案需要 app 插件支持');
|
|
1343
|
+
case 12:
|
|
1344
|
+
app = this.appPlugin.getApp();
|
|
1345
|
+
this.logger = app.logger;
|
|
1155
1346
|
targetCacheData = this.readSessionCacheData();
|
|
1156
1347
|
moduleNames = this.getRegisteredModuleNames();
|
|
1157
1348
|
moduleNames.forEach(function (step) {
|
|
1158
|
-
var reusedModule =
|
|
1349
|
+
var reusedModule = _this9.getReusableSharedSubModule(step);
|
|
1159
1350
|
if (reusedModule) {
|
|
1160
|
-
|
|
1161
|
-
|
|
1351
|
+
_this9.store[step] = reusedModule;
|
|
1352
|
+
_this9.reusedSharedSubModuleNames.add(step);
|
|
1162
1353
|
return;
|
|
1163
1354
|
}
|
|
1164
|
-
var targetModule =
|
|
1355
|
+
var targetModule = _this9.createSubModule(step);
|
|
1165
1356
|
if (!targetModule) {
|
|
1166
1357
|
throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
|
|
1167
1358
|
}
|
|
1168
|
-
var hooks =
|
|
1169
|
-
|
|
1170
|
-
|
|
1359
|
+
var hooks = _this9.getSubModuleHooks(step);
|
|
1360
|
+
_this9.store[step] = targetModule;
|
|
1361
|
+
_this9.core.registerModule(targetModule, _objectSpread(_objectSpread({
|
|
1171
1362
|
initialState: (targetCacheData === null || targetCacheData === void 0 ? void 0 : targetCacheData[targetModule.name]) || {}
|
|
1172
1363
|
}, hooks ? {
|
|
1173
1364
|
hooks: hooks
|
|
1174
1365
|
} : {}), {}, {
|
|
1175
|
-
otherParams:
|
|
1366
|
+
otherParams: _this9.buildSubModuleOtherParams()
|
|
1176
1367
|
}));
|
|
1177
1368
|
});
|
|
1178
1369
|
if (!(this.store.schedule && !this.isScheduleListLoaded(this.store.schedule))) {
|
|
1179
|
-
_context11.next =
|
|
1370
|
+
_context11.next = 20;
|
|
1180
1371
|
break;
|
|
1181
1372
|
}
|
|
1182
|
-
_context11.next =
|
|
1373
|
+
_context11.next = 20;
|
|
1183
1374
|
return this.store.schedule.loadAllSchedule();
|
|
1184
|
-
case
|
|
1375
|
+
case 20:
|
|
1185
1376
|
if (this.store.order && typeof ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.enableTempOrderPersist) === 'boolean') {
|
|
1186
1377
|
this.store.order.setEnableTempOrderPersist(this.otherParams.enableTempOrderPersist);
|
|
1187
1378
|
}
|
|
1188
|
-
_context11.next =
|
|
1379
|
+
_context11.next = 23;
|
|
1189
1380
|
return this.getPaymentMethodsAsync();
|
|
1190
|
-
case
|
|
1381
|
+
case 23:
|
|
1191
1382
|
this.registerServerOrderChangeSync();
|
|
1192
1383
|
this.core.effects.emit("".concat(this.name, ":onInited"), {});
|
|
1193
|
-
case
|
|
1384
|
+
case 25:
|
|
1194
1385
|
case "end":
|
|
1195
1386
|
return _context11.stop();
|
|
1196
1387
|
}
|
|
@@ -1206,15 +1397,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1206
1397
|
value: function () {
|
|
1207
1398
|
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
1208
1399
|
var _this$serverOrderChan2,
|
|
1209
|
-
|
|
1400
|
+
_this10 = this;
|
|
1210
1401
|
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
1211
1402
|
while (1) switch (_context12.prev = _context12.next) {
|
|
1212
1403
|
case 0:
|
|
1213
1404
|
(_this$serverOrderChan2 = this.serverOrderChangeUnsubscribe) === null || _this$serverOrderChan2 === void 0 || _this$serverOrderChan2.call(this);
|
|
1214
1405
|
this.serverOrderChangeUnsubscribe = null;
|
|
1215
1406
|
Object.keys(this.store).forEach(function (key) {
|
|
1216
|
-
if (
|
|
1217
|
-
var sub =
|
|
1407
|
+
if (_this10.reusedSharedSubModuleNames.has(key)) return;
|
|
1408
|
+
var sub = _this10.store[key];
|
|
1218
1409
|
if (sub && typeof sub.destroy === 'function') {
|
|
1219
1410
|
try {
|
|
1220
1411
|
sub.destroy();
|
|
@@ -1224,13 +1415,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1224
1415
|
}
|
|
1225
1416
|
});
|
|
1226
1417
|
this.currentSalesDetail = null;
|
|
1418
|
+
this.paymentNumberDevicePrefix = null;
|
|
1227
1419
|
this.queuedServerOrderChanges = [];
|
|
1228
1420
|
this.salesDetailLoadSequence += 1;
|
|
1229
|
-
|
|
1421
|
+
this.walletAssetsRefreshSequence += 1;
|
|
1422
|
+
_context12.next = 10;
|
|
1230
1423
|
return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
|
|
1231
|
-
case
|
|
1424
|
+
case 10:
|
|
1232
1425
|
_get(_getPrototypeOf(BaseSalesImpl.prototype), "destroy", this).call(this);
|
|
1233
|
-
case
|
|
1426
|
+
case 11:
|
|
1234
1427
|
case "end":
|
|
1235
1428
|
return _context12.stop();
|
|
1236
1429
|
}
|
|
@@ -1252,7 +1445,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1252
1445
|
key: "loadSalesDetail",
|
|
1253
1446
|
value: (function () {
|
|
1254
1447
|
var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderIdOrParams) {
|
|
1255
|
-
var loadSequence,
|
|
1448
|
+
var loadSequence, _ref24, _ref25, _ref26, _ref27, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, remoteRecord, currentTempOrder, mergedRecord, record;
|
|
1256
1449
|
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
1257
1450
|
while (1) switch (_context13.prev = _context13.next) {
|
|
1258
1451
|
case 0:
|
|
@@ -1270,7 +1463,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1270
1463
|
};
|
|
1271
1464
|
externalSaleNumber = params.externalSaleNumber || params.external_sale_number;
|
|
1272
1465
|
preloadedSalesDetail = params.preloadedSalesDetail;
|
|
1273
|
-
lookup = (
|
|
1466
|
+
lookup = (_ref24 = (_ref25 = (_ref26 = (_ref27 = (_params$orderId = params.orderId) !== null && _params$orderId !== void 0 ? _params$orderId : externalSaleNumber) !== null && _ref27 !== void 0 ? _ref27 : params.orderNumber) !== null && _ref26 !== void 0 ? _ref26 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_id) !== null && _ref25 !== void 0 ? _ref25 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.external_sale_number) !== null && _ref24 !== void 0 ? _ref24 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_number;
|
|
1274
1467
|
if (!(!preloadedSalesDetail && (lookup === undefined || lookup === null || lookup === ''))) {
|
|
1275
1468
|
_context13.next = 11;
|
|
1276
1469
|
break;
|
|
@@ -1301,39 +1494,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1301
1494
|
message = loadedRecord && (loadedRecord.message || loadedRecord.msg) || "\u52A0\u8F7D\u9500\u552E\u8BE6\u60C5\u5931\u8D25: ".concat(lookup);
|
|
1302
1495
|
throw new Error(message);
|
|
1303
1496
|
case 22:
|
|
1304
|
-
remoteRecord = preloadedSalesDetail !== null && preloadedSalesDetail !== void 0 ? preloadedSalesDetail : loadedRecord.data;
|
|
1497
|
+
remoteRecord = filterPendingPaymentsFromLoadedSalesDetail(preloadedSalesDetail !== null && preloadedSalesDetail !== void 0 ? preloadedSalesDetail : loadedRecord.data);
|
|
1305
1498
|
currentTempOrder = params.merge ? this.store.order.getTempOrder() : null;
|
|
1306
|
-
|
|
1307
|
-
|
|
1499
|
+
mergedRecord = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder, remoteRecord, 'preserve-local') : remoteRecord;
|
|
1500
|
+
record = filterPendingPaymentsFromLoadedSalesDetail(mergedRecord);
|
|
1501
|
+
_context13.next = 28;
|
|
1308
1502
|
return this.hydrateLatestLoadedSalesDetail(record, loadSequence);
|
|
1309
|
-
case 27:
|
|
1310
|
-
return _context13.abrupt("return", _context13.sent);
|
|
1311
1503
|
case 28:
|
|
1312
|
-
_context13.
|
|
1504
|
+
return _context13.abrupt("return", _context13.sent);
|
|
1505
|
+
case 29:
|
|
1506
|
+
_context13.prev = 29;
|
|
1313
1507
|
this.salesDetailLoadInFlightCount = Math.max(0, this.salesDetailLoadInFlightCount - 1);
|
|
1314
1508
|
if (!(this.salesDetailLoadInFlightCount === 0)) {
|
|
1315
|
-
_context13.next =
|
|
1509
|
+
_context13.next = 40;
|
|
1316
1510
|
break;
|
|
1317
1511
|
}
|
|
1318
|
-
_context13.prev =
|
|
1319
|
-
_context13.next =
|
|
1512
|
+
_context13.prev = 32;
|
|
1513
|
+
_context13.next = 35;
|
|
1320
1514
|
return this.drainQueuedServerOrderChanges();
|
|
1321
|
-
case
|
|
1322
|
-
_context13.next =
|
|
1515
|
+
case 35:
|
|
1516
|
+
_context13.next = 40;
|
|
1323
1517
|
break;
|
|
1324
|
-
case
|
|
1325
|
-
_context13.prev =
|
|
1326
|
-
_context13.t1 = _context13["catch"](
|
|
1518
|
+
case 37:
|
|
1519
|
+
_context13.prev = 37;
|
|
1520
|
+
_context13.t1 = _context13["catch"](32);
|
|
1327
1521
|
this.logError('drain queued server order changes failed', {
|
|
1328
1522
|
error: _context13.t1 instanceof Error ? _context13.t1.message : String(_context13.t1)
|
|
1329
1523
|
});
|
|
1330
|
-
case 39:
|
|
1331
|
-
return _context13.finish(28);
|
|
1332
1524
|
case 40:
|
|
1525
|
+
return _context13.finish(29);
|
|
1526
|
+
case 41:
|
|
1333
1527
|
case "end":
|
|
1334
1528
|
return _context13.stop();
|
|
1335
1529
|
}
|
|
1336
|
-
}, _callee13, this, [[4,,
|
|
1530
|
+
}, _callee13, this, [[4,, 29, 41], [32, 37]]);
|
|
1337
1531
|
}));
|
|
1338
1532
|
function loadSalesDetail(_x11) {
|
|
1339
1533
|
return _loadSalesDetail.apply(this, arguments);
|
|
@@ -1610,7 +1804,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1610
1804
|
key: "restoreOrder",
|
|
1611
1805
|
value: function () {
|
|
1612
1806
|
var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
1613
|
-
var tempOrder;
|
|
1807
|
+
var _this$store$payment, tempOrder, wallet;
|
|
1614
1808
|
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1615
1809
|
while (1) switch (_context17.prev = _context17.next) {
|
|
1616
1810
|
case 0:
|
|
@@ -1626,29 +1820,39 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1626
1820
|
this.currentSalesDetail = null;
|
|
1627
1821
|
this.discountConfigCacheKey = null;
|
|
1628
1822
|
this.hasManualDiscountSelection = false;
|
|
1629
|
-
|
|
1823
|
+
wallet = (_this$store$payment = this.store.payment) === null || _this$store$payment === void 0 ? void 0 : _this$store$payment.wallet;
|
|
1824
|
+
if (!wallet) {
|
|
1825
|
+
_context17.next = 13;
|
|
1826
|
+
break;
|
|
1827
|
+
}
|
|
1828
|
+
this.walletAssetsRefreshSequence += 1;
|
|
1829
|
+
wallet.clearAllCache();
|
|
1830
|
+
_context17.next = 13;
|
|
1831
|
+
return this.publishWalletAssetsState(wallet.getWalletAssetsState());
|
|
1832
|
+
case 13:
|
|
1833
|
+
_context17.next = 15;
|
|
1630
1834
|
return this.effectsEmit('onTempOrderReplaced', {
|
|
1631
1835
|
tempOrder: tempOrder
|
|
1632
1836
|
});
|
|
1633
|
-
case
|
|
1837
|
+
case 15:
|
|
1634
1838
|
if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
|
|
1635
|
-
_context17.next =
|
|
1839
|
+
_context17.next = 19;
|
|
1636
1840
|
break;
|
|
1637
1841
|
}
|
|
1638
1842
|
this.store.order.persistTempOrder();
|
|
1639
|
-
_context17.next =
|
|
1843
|
+
_context17.next = 19;
|
|
1640
1844
|
return this.store.order.saveDraft();
|
|
1641
|
-
case
|
|
1845
|
+
case 19:
|
|
1642
1846
|
return _context17.abrupt("return", tempOrder);
|
|
1643
|
-
case
|
|
1644
|
-
_context17.prev =
|
|
1847
|
+
case 22:
|
|
1848
|
+
_context17.prev = 22;
|
|
1645
1849
|
_context17.t0 = _context17["catch"](0);
|
|
1646
1850
|
throw _context17.t0;
|
|
1647
|
-
case
|
|
1851
|
+
case 25:
|
|
1648
1852
|
case "end":
|
|
1649
1853
|
return _context17.stop();
|
|
1650
1854
|
}
|
|
1651
|
-
}, _callee17, this, [[0,
|
|
1855
|
+
}, _callee17, this, [[0, 22]]);
|
|
1652
1856
|
}));
|
|
1653
1857
|
function restoreOrder() {
|
|
1654
1858
|
return _restoreOrder.apply(this, arguments);
|
|
@@ -1761,10 +1965,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1761
1965
|
}, {
|
|
1762
1966
|
key: "getHistoricalProductDiscountList",
|
|
1763
1967
|
value: function getHistoricalProductDiscountList(products) {
|
|
1764
|
-
var
|
|
1968
|
+
var _this11 = this;
|
|
1765
1969
|
var historyDiscountList = [];
|
|
1766
1970
|
products.forEach(function (item) {
|
|
1767
|
-
if (!
|
|
1971
|
+
if (!_this11.isPersistedOrderProduct(item)) return;
|
|
1768
1972
|
(item.discount_list || []).forEach(function (discount) {
|
|
1769
1973
|
var _discount$discount, _discount$metadata, _discount$discount2, _discount$discount3, _discount$discount4;
|
|
1770
1974
|
var discountId = ((_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) || discount.id;
|
|
@@ -1824,11 +2028,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1824
2028
|
}, {
|
|
1825
2029
|
key: "shouldSkipAutoApplyFetchedDiscountsInEditMode",
|
|
1826
2030
|
value: function shouldSkipAutoApplyFetchedDiscountsInEditMode(params) {
|
|
1827
|
-
var
|
|
2031
|
+
var _this12 = this;
|
|
1828
2032
|
if (params.discountAction !== 'edit') return false;
|
|
1829
2033
|
if (!params.products.length) return false;
|
|
1830
2034
|
var hasDraftProduct = params.products.some(function (product) {
|
|
1831
|
-
return !
|
|
2035
|
+
return !_this12.isPersistedOrderProduct(product);
|
|
1832
2036
|
});
|
|
1833
2037
|
if (hasDraftProduct) return false;
|
|
1834
2038
|
var hasSelectedDiscount = params.currentDiscountList.some(function (discount) {
|
|
@@ -2407,10 +2611,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2407
2611
|
product.discount_list = filterSelectedDiscountDetails(product.discount_list);
|
|
2408
2612
|
if (Array.isArray(product.product_bundle)) {
|
|
2409
2613
|
product.product_bundle = product.product_bundle.map(function (bundle) {
|
|
2410
|
-
var
|
|
2614
|
+
var _ref28, _bundle$original_pric;
|
|
2411
2615
|
var nextBundleDiscountList = filterSelectedDiscountDetails(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list);
|
|
2412
2616
|
var shouldRestoreBundlePrice = nextBundleDiscountList.length === 0;
|
|
2413
|
-
var restoredBundlePrice = (
|
|
2617
|
+
var restoredBundlePrice = (_ref28 = (_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 && _ref28 !== void 0 ? _ref28 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
|
|
2414
2618
|
return _objectSpread(_objectSpread(_objectSpread({}, bundle), shouldRestoreBundlePrice ? {
|
|
2415
2619
|
price: restoredBundlePrice,
|
|
2416
2620
|
bundle_selling_price: restoredBundlePrice
|
|
@@ -2587,8 +2791,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2587
2791
|
key: "submitSalesOrder",
|
|
2588
2792
|
value: (function () {
|
|
2589
2793
|
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
|
|
2590
|
-
var
|
|
2591
|
-
var inferredPaymentStatus,
|
|
2794
|
+
var _this$otherParams6, _this$otherParams7, _this$otherParams8, _this$otherParams9;
|
|
2795
|
+
var inferredPaymentStatus, submitParams;
|
|
2592
2796
|
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
2593
2797
|
while (1) switch (_context27.prev = _context27.next) {
|
|
2594
2798
|
case 0:
|
|
@@ -2600,7 +2804,6 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2600
2804
|
case 2:
|
|
2601
2805
|
// this.store.order.persistTempOrder();
|
|
2602
2806
|
inferredPaymentStatus = this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
|
|
2603
|
-
smallTicketDataFlag = (_params$smallTicketDa = params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== null && _params$smallTicketDa !== void 0 ? _params$smallTicketDa : this.getDefaultCheckoutSmallTicketDataFlag();
|
|
2604
2807
|
submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
2605
2808
|
cacheId: this.cacheId,
|
|
2606
2809
|
platform: (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform,
|
|
@@ -2612,15 +2815,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2612
2815
|
payments: params.payments
|
|
2613
2816
|
} : {}), inferredPaymentStatus !== undefined ? {
|
|
2614
2817
|
paymentStatus: inferredPaymentStatus
|
|
2615
|
-
} : {}), smallTicketDataFlag !== undefined ? {
|
|
2616
|
-
smallTicketDataFlag: smallTicketDataFlag
|
|
2818
|
+
} : {}), (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined ? {
|
|
2819
|
+
smallTicketDataFlag: params.smallTicketDataFlag
|
|
2617
2820
|
} : {}), (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== undefined ? {
|
|
2618
2821
|
confirmPendingVoucherPayments: params.confirmPendingVoucherPayments
|
|
2619
2822
|
} : {}), (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
|
|
2620
2823
|
enhancePayload: params.enhancePayload
|
|
2621
2824
|
} : {});
|
|
2622
|
-
return _context27.abrupt("return", this.
|
|
2623
|
-
case
|
|
2825
|
+
return _context27.abrupt("return", this.store.order.submitTempOrder(submitParams));
|
|
2826
|
+
case 5:
|
|
2624
2827
|
case "end":
|
|
2625
2828
|
return _context27.stop();
|
|
2626
2829
|
}
|
|
@@ -2632,11 +2835,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2632
2835
|
return submitSalesOrder;
|
|
2633
2836
|
}())
|
|
2634
2837
|
}, {
|
|
2635
|
-
key: "
|
|
2838
|
+
key: "saveSalesOrderDraft",
|
|
2636
2839
|
value: function () {
|
|
2637
|
-
var
|
|
2638
|
-
var _params$
|
|
2639
|
-
var inferredPaymentStatus, smallTicketDataFlag, submitParams;
|
|
2840
|
+
var _saveSalesOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
|
|
2841
|
+
var _params$platform, _this$otherParams10, _this$otherParams11, _this$otherParams12, _params$channel, _params$type, _this$otherParams13;
|
|
2640
2842
|
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
2641
2843
|
while (1) switch (_context28.prev = _context28.next) {
|
|
2642
2844
|
case 0:
|
|
@@ -2645,68 +2847,83 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2645
2847
|
break;
|
|
2646
2848
|
}
|
|
2647
2849
|
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
2850
|
+
case 2:
|
|
2851
|
+
return _context28.abrupt("return", this.store.order.saveTempOrderAsDraft(_objectSpread({
|
|
2852
|
+
cacheId: this.cacheId,
|
|
2853
|
+
platform: (_params$platform = params === null || params === void 0 ? void 0 : params.platform) !== null && _params$platform !== void 0 ? _params$platform : (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.platform,
|
|
2854
|
+
businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.businessCode) || ((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.business_code),
|
|
2855
|
+
channel: (_params$channel = params === null || params === void 0 ? void 0 : params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel(),
|
|
2856
|
+
type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.type
|
|
2857
|
+
}, (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
|
|
2858
|
+
enhancePayload: params.enhancePayload
|
|
2859
|
+
} : {})));
|
|
2860
|
+
case 3:
|
|
2861
|
+
case "end":
|
|
2862
|
+
return _context28.stop();
|
|
2863
|
+
}
|
|
2864
|
+
}, _callee28, this);
|
|
2865
|
+
}));
|
|
2866
|
+
function saveSalesOrderDraft(_x22) {
|
|
2867
|
+
return _saveSalesOrderDraft.apply(this, arguments);
|
|
2868
|
+
}
|
|
2869
|
+
return saveSalesOrderDraft;
|
|
2870
|
+
}()
|
|
2871
|
+
}, {
|
|
2872
|
+
key: "submitTempOrderAsync",
|
|
2873
|
+
value: function () {
|
|
2874
|
+
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
|
|
2875
|
+
var _this$otherParams14, _this$otherParams15, _this$otherParams16, _this$otherParams17;
|
|
2876
|
+
var inferredPaymentStatus, submitParams;
|
|
2877
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
2878
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
2879
|
+
case 0:
|
|
2880
|
+
if (this.store.order) {
|
|
2881
|
+
_context29.next = 2;
|
|
2882
|
+
break;
|
|
2883
|
+
}
|
|
2884
|
+
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
2648
2885
|
case 2:
|
|
2649
2886
|
inferredPaymentStatus = this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
|
|
2650
|
-
smallTicketDataFlag = (_params$smallTicketDa2 = params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== null && _params$smallTicketDa2 !== void 0 ? _params$smallTicketDa2 : this.getDefaultCheckoutSmallTicketDataFlag();
|
|
2651
2887
|
submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
2652
2888
|
cacheId: this.cacheId,
|
|
2653
|
-
platform: (_this$
|
|
2654
|
-
businessCode: ((_this$
|
|
2889
|
+
platform: (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.platform,
|
|
2890
|
+
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),
|
|
2655
2891
|
channel: this.getSubmitOrderSalesChannel(),
|
|
2656
|
-
type: (_this$
|
|
2657
|
-
request_unique_idempotency_token: this.store.order.generateIdempotencyToken()
|
|
2892
|
+
type: (_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.type
|
|
2658
2893
|
}, (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
|
|
2659
2894
|
payments: params.payments
|
|
2660
2895
|
} : {}), inferredPaymentStatus !== undefined ? {
|
|
2661
2896
|
paymentStatus: inferredPaymentStatus
|
|
2662
|
-
} : {}), smallTicketDataFlag !== undefined ? {
|
|
2663
|
-
smallTicketDataFlag: smallTicketDataFlag
|
|
2897
|
+
} : {}), (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined ? {
|
|
2898
|
+
smallTicketDataFlag: params.smallTicketDataFlag
|
|
2664
2899
|
} : {}), (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== undefined ? {
|
|
2665
2900
|
confirmPendingVoucherPayments: params.confirmPendingVoucherPayments
|
|
2666
2901
|
} : {}), (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
|
|
2667
2902
|
enhancePayload: params.enhancePayload
|
|
2668
2903
|
} : {});
|
|
2669
|
-
return
|
|
2670
|
-
case
|
|
2904
|
+
return _context29.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
|
|
2905
|
+
case 5:
|
|
2671
2906
|
case "end":
|
|
2672
|
-
return
|
|
2907
|
+
return _context29.stop();
|
|
2673
2908
|
}
|
|
2674
|
-
},
|
|
2909
|
+
}, _callee29, this);
|
|
2675
2910
|
}));
|
|
2676
|
-
function submitTempOrderAsync(
|
|
2911
|
+
function submitTempOrderAsync(_x23) {
|
|
2677
2912
|
return _submitTempOrderAsync.apply(this, arguments);
|
|
2678
2913
|
}
|
|
2679
2914
|
return submitTempOrderAsync;
|
|
2680
2915
|
}()
|
|
2681
|
-
/**
|
|
2682
|
-
* 默认保持 WebPOS 的本地待同步订单模式;需要云端确认后才算成功的渠道可覆盖此策略。
|
|
2683
|
-
* otherParams.checkoutSyncTaskEnabled 优先,便于同一 solution 按入口恢复旧行为。
|
|
2684
|
-
*/
|
|
2685
|
-
}, {
|
|
2686
|
-
key: "shouldUseCheckoutSyncTask",
|
|
2687
|
-
value: function shouldUseCheckoutSyncTask() {
|
|
2688
|
-
var _this$otherParams14;
|
|
2689
|
-
var configured = (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.checkoutSyncTaskEnabled;
|
|
2690
|
-
return typeof configured === 'boolean' ? configured : true;
|
|
2691
|
-
}
|
|
2692
|
-
|
|
2693
|
-
/** 可由特定 solution 为真实 checkout 补充默认收据数据请求。 */
|
|
2694
|
-
}, {
|
|
2695
|
-
key: "getDefaultCheckoutSmallTicketDataFlag",
|
|
2696
|
-
value: function getDefaultCheckoutSmallTicketDataFlag() {
|
|
2697
|
-
return undefined;
|
|
2698
|
-
}
|
|
2699
2916
|
}, {
|
|
2700
2917
|
key: "printLocalOrderReceipt",
|
|
2701
2918
|
value: function () {
|
|
2702
|
-
var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2703
|
-
var _this$
|
|
2919
|
+
var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(lookup) {
|
|
2920
|
+
var _this$otherParams18, _this$otherParams19, _this$otherParams20, _this$otherParams21;
|
|
2704
2921
|
var hasLookup, lookupPayload, context, payload, response, _this$store$order$app, _this$store$order5, _data;
|
|
2705
|
-
return _regeneratorRuntime().wrap(function
|
|
2706
|
-
while (1) switch (
|
|
2922
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
2923
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
2707
2924
|
case 0:
|
|
2708
2925
|
if (this.store.order) {
|
|
2709
|
-
|
|
2926
|
+
_context30.next = 2;
|
|
2710
2927
|
break;
|
|
2711
2928
|
}
|
|
2712
2929
|
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
@@ -2718,10 +2935,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2718
2935
|
external_sale_number: lookup
|
|
2719
2936
|
};
|
|
2720
2937
|
context = {
|
|
2721
|
-
platform: (_this$
|
|
2722
|
-
businessCode: ((_this$
|
|
2938
|
+
platform: (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.platform,
|
|
2939
|
+
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),
|
|
2723
2940
|
channel: this.getSubmitOrderSalesChannel(),
|
|
2724
|
-
type: (_this$
|
|
2941
|
+
type: (_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.type
|
|
2725
2942
|
};
|
|
2726
2943
|
payload = hasLookup ? _objectSpread(_objectSpread({}, lookupPayload), {}, {
|
|
2727
2944
|
lookup_order_from_db: 1,
|
|
@@ -2737,28 +2954,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2737
2954
|
channel: context.channel,
|
|
2738
2955
|
type: context.type
|
|
2739
2956
|
});
|
|
2740
|
-
|
|
2957
|
+
_context30.next = 8;
|
|
2741
2958
|
return this.request.post('/local/print-order', payload, {
|
|
2742
2959
|
osServer: true,
|
|
2743
2960
|
customToast: function customToast() {}
|
|
2744
2961
|
});
|
|
2745
2962
|
case 8:
|
|
2746
|
-
response =
|
|
2963
|
+
response = _context30.sent;
|
|
2747
2964
|
if (hasLookup) {
|
|
2748
|
-
|
|
2965
|
+
_context30.next = 12;
|
|
2749
2966
|
break;
|
|
2750
2967
|
}
|
|
2751
|
-
|
|
2968
|
+
_context30.next = 12;
|
|
2752
2969
|
return (_this$store$order$app = (_this$store$order5 = this.store.order).applyLocalPrintOrderNumbers) === null || _this$store$order$app === void 0 ? void 0 : _this$store$order$app.call(_this$store$order5, response === null || response === void 0 || (_data = response.data) === null || _data === void 0 ? void 0 : _data.order);
|
|
2753
2970
|
case 12:
|
|
2754
|
-
return
|
|
2971
|
+
return _context30.abrupt("return", response);
|
|
2755
2972
|
case 13:
|
|
2756
2973
|
case "end":
|
|
2757
|
-
return
|
|
2974
|
+
return _context30.stop();
|
|
2758
2975
|
}
|
|
2759
|
-
},
|
|
2976
|
+
}, _callee30, this);
|
|
2760
2977
|
}));
|
|
2761
|
-
function printLocalOrderReceipt(
|
|
2978
|
+
function printLocalOrderReceipt(_x24) {
|
|
2762
2979
|
return _printLocalOrderReceipt.apply(this, arguments);
|
|
2763
2980
|
}
|
|
2764
2981
|
return printLocalOrderReceipt;
|
|
@@ -2772,44 +2989,42 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2772
2989
|
if (!amountSnapshot) return undefined;
|
|
2773
2990
|
try {
|
|
2774
2991
|
return new Decimal(amountSnapshot.amountGap || 0).lte(0) ? 'paid' : undefined;
|
|
2775
|
-
} catch (
|
|
2992
|
+
} catch (_unused4) {
|
|
2776
2993
|
return undefined;
|
|
2777
2994
|
}
|
|
2778
2995
|
}
|
|
2779
2996
|
}, {
|
|
2780
2997
|
key: "syncPaymentsToOrder",
|
|
2781
2998
|
value: function () {
|
|
2782
|
-
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2783
|
-
var
|
|
2999
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
|
|
3000
|
+
var _ref29, _params$businessCode, _this$otherParams22, _this$otherParams23, _params$channel2;
|
|
2784
3001
|
var businessCode, channel, syncParams, syncState, payments, syncResult, latestPayments, amountSnapshot, orderSnapshot, syncPayload;
|
|
2785
|
-
return _regeneratorRuntime().wrap(function
|
|
2786
|
-
while (1) switch (
|
|
3002
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
3003
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
2787
3004
|
case 0:
|
|
2788
3005
|
if (this.store.order) {
|
|
2789
|
-
|
|
3006
|
+
_context31.next = 2;
|
|
2790
3007
|
break;
|
|
2791
3008
|
}
|
|
2792
3009
|
throw new Error('order 模块未初始化');
|
|
2793
3010
|
case 2:
|
|
2794
|
-
businessCode = (
|
|
2795
|
-
channel = (_params$
|
|
2796
|
-
syncParams = _objectSpread(_objectSpread(_objectSpread({}, params),
|
|
2797
|
-
checkoutSyncTaskEnabled: this.shouldUseCheckoutSyncTask()
|
|
2798
|
-
}, businessCode !== undefined ? {
|
|
3011
|
+
businessCode = (_ref29 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.businessCode) !== null && _ref29 !== void 0 ? _ref29 : (_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.business_code;
|
|
3012
|
+
channel = (_params$channel2 = params.channel) !== null && _params$channel2 !== void 0 ? _params$channel2 : this.getSubmitOrderSalesChannel();
|
|
3013
|
+
syncParams = _objectSpread(_objectSpread(_objectSpread({}, params), businessCode !== undefined ? {
|
|
2799
3014
|
businessCode: businessCode
|
|
2800
3015
|
} : {}), channel !== undefined ? {
|
|
2801
3016
|
channel: channel
|
|
2802
3017
|
} : {});
|
|
2803
3018
|
syncState = this.store.order.getOrderSyncState();
|
|
2804
3019
|
if (!(params.submitWhenPaid && syncState === 'submitting')) {
|
|
2805
|
-
|
|
3020
|
+
_context31.next = 9;
|
|
2806
3021
|
break;
|
|
2807
3022
|
}
|
|
2808
3023
|
this.queueLatestAutoPaymentSync();
|
|
2809
|
-
return
|
|
3024
|
+
return _context31.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
|
|
2810
3025
|
case 9:
|
|
2811
3026
|
payments = params.payments || [];
|
|
2812
|
-
|
|
3027
|
+
_context31.next = 12;
|
|
2813
3028
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncStart, {
|
|
2814
3029
|
payments: payments,
|
|
2815
3030
|
params: syncParams,
|
|
@@ -2817,11 +3032,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2817
3032
|
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
2818
3033
|
});
|
|
2819
3034
|
case 12:
|
|
2820
|
-
|
|
2821
|
-
|
|
3035
|
+
_context31.prev = 12;
|
|
3036
|
+
_context31.next = 15;
|
|
2822
3037
|
return this.store.order.syncPaymentsToOrder(syncParams);
|
|
2823
3038
|
case 15:
|
|
2824
|
-
syncResult =
|
|
3039
|
+
syncResult = _context31.sent;
|
|
2825
3040
|
latestPayments = this.store.order.getOrderPayments();
|
|
2826
3041
|
amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
2827
3042
|
orderSnapshot = this.store.order.getOrderSnapshot();
|
|
@@ -2839,25 +3054,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2839
3054
|
depositAmount: syncResult.depositAmount,
|
|
2840
3055
|
orderExpectedAmount: syncResult.orderExpectedAmount
|
|
2841
3056
|
};
|
|
2842
|
-
|
|
3057
|
+
_context31.next = 22;
|
|
2843
3058
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, syncPayload);
|
|
2844
3059
|
case 22:
|
|
2845
3060
|
if (!(syncResult.isDepositFullyPaid && !syncResult.isOrderFullyPaid)) {
|
|
2846
|
-
|
|
3061
|
+
_context31.next = 25;
|
|
2847
3062
|
break;
|
|
2848
3063
|
}
|
|
2849
|
-
|
|
3064
|
+
_context31.next = 25;
|
|
2850
3065
|
return this.effectsEmit(BaseSalesHookNames.onDepositPaymentSyncEnd, syncPayload);
|
|
2851
3066
|
case 25:
|
|
2852
3067
|
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
2853
|
-
return
|
|
3068
|
+
return _context31.abrupt("return", syncResult);
|
|
2854
3069
|
case 29:
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
3070
|
+
_context31.prev = 29;
|
|
3071
|
+
_context31.t0 = _context31["catch"](12);
|
|
3072
|
+
_context31.next = 33;
|
|
2858
3073
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
|
|
2859
3074
|
ok: false,
|
|
2860
|
-
error:
|
|
3075
|
+
error: _context31.t0,
|
|
2861
3076
|
payments: this.store.order.getOrderPayments(),
|
|
2862
3077
|
params: syncParams,
|
|
2863
3078
|
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
@@ -2865,14 +3080,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2865
3080
|
});
|
|
2866
3081
|
case 33:
|
|
2867
3082
|
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
2868
|
-
throw
|
|
3083
|
+
throw _context31.t0;
|
|
2869
3084
|
case 35:
|
|
2870
3085
|
case "end":
|
|
2871
|
-
return
|
|
3086
|
+
return _context31.stop();
|
|
2872
3087
|
}
|
|
2873
|
-
},
|
|
3088
|
+
}, _callee31, this, [[12, 29]]);
|
|
2874
3089
|
}));
|
|
2875
|
-
function syncPaymentsToOrder(
|
|
3090
|
+
function syncPaymentsToOrder(_x25) {
|
|
2876
3091
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
2877
3092
|
}
|
|
2878
3093
|
return syncPaymentsToOrder;
|
|
@@ -2909,58 +3124,58 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2909
3124
|
}, {
|
|
2910
3125
|
key: "scheduleQueuedAutoPaymentSyncFlush",
|
|
2911
3126
|
value: function scheduleQueuedAutoPaymentSyncFlush() {
|
|
2912
|
-
var
|
|
3127
|
+
var _this13 = this;
|
|
2913
3128
|
var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;
|
|
2914
3129
|
if (!this.queuedAutoPaymentSync) return;
|
|
2915
3130
|
if (this.autoPaymentSyncTimer) return;
|
|
2916
3131
|
this.autoPaymentSyncTimer = setTimeout(function () {
|
|
2917
|
-
|
|
2918
|
-
void
|
|
3132
|
+
_this13.autoPaymentSyncTimer = null;
|
|
3133
|
+
void _this13.flushQueuedAutoPaymentSync();
|
|
2919
3134
|
}, delay);
|
|
2920
3135
|
}
|
|
2921
3136
|
}, {
|
|
2922
3137
|
key: "flushQueuedAutoPaymentSync",
|
|
2923
3138
|
value: function () {
|
|
2924
|
-
var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3139
|
+
var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
|
|
2925
3140
|
var payments;
|
|
2926
|
-
return _regeneratorRuntime().wrap(function
|
|
2927
|
-
while (1) switch (
|
|
3141
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
3142
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
2928
3143
|
case 0:
|
|
2929
3144
|
if (this.store.order) {
|
|
2930
|
-
|
|
3145
|
+
_context32.next = 2;
|
|
2931
3146
|
break;
|
|
2932
3147
|
}
|
|
2933
|
-
return
|
|
3148
|
+
return _context32.abrupt("return");
|
|
2934
3149
|
case 2:
|
|
2935
3150
|
if (!(!this.queuedAutoPaymentSync || this.autoPaymentSyncFlushing)) {
|
|
2936
|
-
|
|
3151
|
+
_context32.next = 4;
|
|
2937
3152
|
break;
|
|
2938
3153
|
}
|
|
2939
|
-
return
|
|
3154
|
+
return _context32.abrupt("return");
|
|
2940
3155
|
case 4:
|
|
2941
3156
|
if (!(this.store.order.getOrderSyncState() === 'submitting')) {
|
|
2942
|
-
|
|
3157
|
+
_context32.next = 7;
|
|
2943
3158
|
break;
|
|
2944
3159
|
}
|
|
2945
3160
|
this.scheduleQueuedAutoPaymentSyncFlush();
|
|
2946
|
-
return
|
|
3161
|
+
return _context32.abrupt("return");
|
|
2947
3162
|
case 7:
|
|
2948
3163
|
this.autoPaymentSyncFlushing = true;
|
|
2949
|
-
|
|
3164
|
+
_context32.prev = 8;
|
|
2950
3165
|
case 9:
|
|
2951
3166
|
if (!this.queuedAutoPaymentSync) {
|
|
2952
|
-
|
|
3167
|
+
_context32.next = 18;
|
|
2953
3168
|
break;
|
|
2954
3169
|
}
|
|
2955
3170
|
this.queuedAutoPaymentSync = false;
|
|
2956
3171
|
payments = this.store.order.getOrderPayments();
|
|
2957
3172
|
if (payments.length) {
|
|
2958
|
-
|
|
3173
|
+
_context32.next = 14;
|
|
2959
3174
|
break;
|
|
2960
3175
|
}
|
|
2961
|
-
return
|
|
3176
|
+
return _context32.abrupt("continue", 9);
|
|
2962
3177
|
case 14:
|
|
2963
|
-
|
|
3178
|
+
_context32.next = 16;
|
|
2964
3179
|
return this.syncPaymentsToOrder({
|
|
2965
3180
|
payments: payments,
|
|
2966
3181
|
paymentStatus: this.getPaymentStatusForSync(payments),
|
|
@@ -2968,44 +3183,94 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2968
3183
|
smallTicketDataFlag: 1
|
|
2969
3184
|
});
|
|
2970
3185
|
case 16:
|
|
2971
|
-
|
|
3186
|
+
_context32.next = 9;
|
|
2972
3187
|
break;
|
|
2973
3188
|
case 18:
|
|
2974
|
-
|
|
3189
|
+
_context32.next = 23;
|
|
2975
3190
|
break;
|
|
2976
3191
|
case 20:
|
|
2977
|
-
|
|
2978
|
-
|
|
3192
|
+
_context32.prev = 20;
|
|
3193
|
+
_context32.t0 = _context32["catch"](8);
|
|
2979
3194
|
this.logError('queued auto sync payments failed', {
|
|
2980
|
-
error:
|
|
3195
|
+
error: _context32.t0 instanceof Error ? _context32.t0.message : String(_context32.t0)
|
|
2981
3196
|
});
|
|
2982
3197
|
case 23:
|
|
2983
|
-
|
|
3198
|
+
_context32.prev = 23;
|
|
2984
3199
|
this.autoPaymentSyncFlushing = false;
|
|
2985
3200
|
if (this.queuedAutoPaymentSync) {
|
|
2986
3201
|
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
2987
3202
|
}
|
|
2988
|
-
return
|
|
3203
|
+
return _context32.finish(23);
|
|
2989
3204
|
case 27:
|
|
2990
3205
|
case "end":
|
|
2991
|
-
return
|
|
3206
|
+
return _context32.stop();
|
|
2992
3207
|
}
|
|
2993
|
-
},
|
|
3208
|
+
}, _callee32, this, [[8, 20, 23, 27]]);
|
|
2994
3209
|
}));
|
|
2995
3210
|
function flushQueuedAutoPaymentSync() {
|
|
2996
3211
|
return _flushQueuedAutoPaymentSync.apply(this, arguments);
|
|
2997
3212
|
}
|
|
2998
3213
|
return flushQueuedAutoPaymentSync;
|
|
2999
|
-
}()
|
|
3214
|
+
}()
|
|
3215
|
+
/**
|
|
3216
|
+
* 同步兼容入口。无法等待 IoT 短号时,按调用当下的 device_id 或 LOCAL 生成。
|
|
3217
|
+
*/
|
|
3000
3218
|
}, {
|
|
3001
3219
|
key: "addOrderPayment",
|
|
3002
3220
|
value: function addOrderPayment(payment) {
|
|
3003
|
-
var
|
|
3221
|
+
var hasPaymentNumber = String(payment.payment_number || '').trim() !== '';
|
|
3222
|
+
return this.addOrderPaymentWithDevicePrefix(payment, hasPaymentNumber ? 'LOCAL' : this.getPaymentNumberDevicePrefixSync());
|
|
3223
|
+
}
|
|
3224
|
+
|
|
3225
|
+
/**
|
|
3226
|
+
* 创建新支付项时优先使用业务解决方案初始化阶段缓存的设备短号;
|
|
3227
|
+
* 未缓存的通用 BaseSales 保持实时读取设备信息的兼容语义。
|
|
3228
|
+
*/
|
|
3229
|
+
}, {
|
|
3230
|
+
key: "addOrderPaymentAsync",
|
|
3231
|
+
value: (function () {
|
|
3232
|
+
var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(payment) {
|
|
3233
|
+
var paymentRecord, hasPaymentNumber, devicePrefix;
|
|
3234
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
3235
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
3236
|
+
case 0:
|
|
3237
|
+
paymentRecord = payment;
|
|
3238
|
+
hasPaymentNumber = String(paymentRecord.payment_number || '').trim() !== '';
|
|
3239
|
+
if (!hasPaymentNumber) {
|
|
3240
|
+
_context33.next = 6;
|
|
3241
|
+
break;
|
|
3242
|
+
}
|
|
3243
|
+
_context33.t0 = 'LOCAL';
|
|
3244
|
+
_context33.next = 9;
|
|
3245
|
+
break;
|
|
3246
|
+
case 6:
|
|
3247
|
+
_context33.next = 8;
|
|
3248
|
+
return this.getPaymentNumberDevicePrefixAsync();
|
|
3249
|
+
case 8:
|
|
3250
|
+
_context33.t0 = _context33.sent;
|
|
3251
|
+
case 9:
|
|
3252
|
+
devicePrefix = _context33.t0;
|
|
3253
|
+
return _context33.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
|
|
3254
|
+
case 11:
|
|
3255
|
+
case "end":
|
|
3256
|
+
return _context33.stop();
|
|
3257
|
+
}
|
|
3258
|
+
}, _callee33, this);
|
|
3259
|
+
}));
|
|
3260
|
+
function addOrderPaymentAsync(_x26) {
|
|
3261
|
+
return _addOrderPaymentAsync.apply(this, arguments);
|
|
3262
|
+
}
|
|
3263
|
+
return addOrderPaymentAsync;
|
|
3264
|
+
}())
|
|
3265
|
+
}, {
|
|
3266
|
+
key: "addOrderPaymentWithDevicePrefix",
|
|
3267
|
+
value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
|
|
3268
|
+
var _this$otherParams24,
|
|
3004
3269
|
_paymentRecord$paymen,
|
|
3005
3270
|
_paymentRecord$create,
|
|
3006
|
-
|
|
3271
|
+
_ref30,
|
|
3007
3272
|
_paymentRecord$origin,
|
|
3008
|
-
|
|
3273
|
+
_this14 = this;
|
|
3009
3274
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
3010
3275
|
var paymentRecord = payment;
|
|
3011
3276
|
var paymentAmount = new Decimal(paymentRecord.amount || 0);
|
|
@@ -3016,25 +3281,26 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3016
3281
|
return this.store.order.getOrderPayments();
|
|
3017
3282
|
}
|
|
3018
3283
|
var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
|
|
3019
|
-
var shopWalletPassId = (_this$
|
|
3284
|
+
var shopWalletPassId = (_this$otherParams24 = this.otherParams) === null || _this$otherParams24 === void 0 ? void 0 : _this$otherParams24.shop_wallet_pass_id;
|
|
3020
3285
|
if (shopWalletPassId !== undefined && shopWalletPassId !== null) {
|
|
3021
3286
|
metadata.shop_wallet_pass_id = shopWalletPassId;
|
|
3022
3287
|
}
|
|
3023
|
-
|
|
3024
|
-
metadata.unique_payment_number = createUuidV4();
|
|
3025
|
-
}
|
|
3288
|
+
var normalizedPaymentRecord = ensureOrderPaymentNumber(paymentRecord, devicePrefix, createUuidV4);
|
|
3026
3289
|
var paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
3027
3290
|
var paymentTime = (_paymentRecord$paymen = paymentRecord.payment_time) !== null && _paymentRecord$paymen !== void 0 ? _paymentRecord$paymen : paymentTimestamp;
|
|
3028
3291
|
var createdAt = (_paymentRecord$create = paymentRecord.created_at) !== null && _paymentRecord$create !== void 0 ? _paymentRecord$create : paymentTimestamp;
|
|
3029
3292
|
var serviceCharge = paymentRecord.service_charge && _typeof(paymentRecord.service_charge) === 'object' ? paymentRecord.service_charge : null;
|
|
3030
|
-
var calculatedServiceFee = serviceCharge ? new Decimal((
|
|
3031
|
-
var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread({},
|
|
3293
|
+
var calculatedServiceFee = serviceCharge ? new Decimal((_ref30 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref30 !== void 0 ? _ref30 : 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
|
|
3294
|
+
var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread({}, normalizedPaymentRecord), calculatedServiceFee !== undefined ? {
|
|
3032
3295
|
service_fee: calculatedServiceFee
|
|
3033
3296
|
} : {}), {}, {
|
|
3034
3297
|
metadata: metadata,
|
|
3035
3298
|
payment_time: paymentTime,
|
|
3036
3299
|
created_at: createdAt
|
|
3037
3300
|
}));
|
|
3301
|
+
if (paymentRecord.status === 'payment_pending') {
|
|
3302
|
+
return payments;
|
|
3303
|
+
}
|
|
3038
3304
|
var amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
3039
3305
|
var syncState = this.store.order.getOrderSyncState();
|
|
3040
3306
|
if (amountSnapshot) {
|
|
@@ -3048,7 +3314,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3048
3314
|
submitWhenPaid: true,
|
|
3049
3315
|
smallTicketDataFlag: 1
|
|
3050
3316
|
}).catch(function (error) {
|
|
3051
|
-
|
|
3317
|
+
_this14.logError('auto sync payments failed', {
|
|
3052
3318
|
error: error instanceof Error ? error.message : String(error)
|
|
3053
3319
|
});
|
|
3054
3320
|
});
|
|
@@ -3059,12 +3325,131 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3059
3325
|
/** 更新当前订单中的指定支付项。 */
|
|
3060
3326
|
}, {
|
|
3061
3327
|
key: "updateOrderPayment",
|
|
3062
|
-
value: function
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3328
|
+
value: (function () {
|
|
3329
|
+
var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(paymentIdentity, updates) {
|
|
3330
|
+
var _result$payment, _result$payment2;
|
|
3331
|
+
var options,
|
|
3332
|
+
matchMode,
|
|
3333
|
+
previousMatch,
|
|
3334
|
+
previousPayment,
|
|
3335
|
+
_this$store$order$get2,
|
|
3336
|
+
currentPayments,
|
|
3337
|
+
_syncResult,
|
|
3338
|
+
_options$smallTicketD,
|
|
3339
|
+
result,
|
|
3340
|
+
draftResult,
|
|
3341
|
+
draftError,
|
|
3342
|
+
becamePaid,
|
|
3343
|
+
shouldSubmit,
|
|
3344
|
+
syncResult,
|
|
3345
|
+
_options$smallTicketD2,
|
|
3346
|
+
_args34 = arguments;
|
|
3347
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
3348
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
3349
|
+
case 0:
|
|
3350
|
+
options = _args34.length > 2 && _args34[2] !== undefined ? _args34[2] : {};
|
|
3351
|
+
if (this.store.order) {
|
|
3352
|
+
_context34.next = 3;
|
|
3353
|
+
break;
|
|
3354
|
+
}
|
|
3355
|
+
throw new Error('order 模块未初始化');
|
|
3356
|
+
case 3:
|
|
3357
|
+
matchMode = options.matchBy === 'compat' || options.matchBy === 'legacy' ? 'compat' : 'payment_number';
|
|
3358
|
+
previousMatch = resolveOrderPaymentIdentity(this.store.order.getOrderPayments(), paymentIdentity, matchMode);
|
|
3359
|
+
previousPayment = previousMatch === null || previousMatch === void 0 ? void 0 : previousMatch.payment;
|
|
3360
|
+
if (!((previousPayment === null || previousPayment === void 0 ? void 0 : previousPayment.status) === 'paid' && !options.applyUpdatesWhenPaid)) {
|
|
3361
|
+
_context34.next = 13;
|
|
3362
|
+
break;
|
|
3363
|
+
}
|
|
3364
|
+
currentPayments = this.store.order.getOrderPayments();
|
|
3365
|
+
if (!(options.submitWhenPaid && options.forceSubmitIfPaid)) {
|
|
3366
|
+
_context34.next = 12;
|
|
3367
|
+
break;
|
|
3368
|
+
}
|
|
3369
|
+
_context34.next = 11;
|
|
3370
|
+
return this.syncPaymentsToOrder({
|
|
3371
|
+
payments: currentPayments,
|
|
3372
|
+
paymentStatus: this.getPaymentStatusForSync(currentPayments),
|
|
3373
|
+
submitWhenPaid: true,
|
|
3374
|
+
smallTicketDataFlag: (_options$smallTicketD = options.smallTicketDataFlag) !== null && _options$smallTicketD !== void 0 ? _options$smallTicketD : 1
|
|
3375
|
+
});
|
|
3376
|
+
case 11:
|
|
3377
|
+
_syncResult = _context34.sent;
|
|
3378
|
+
case 12:
|
|
3379
|
+
return _context34.abrupt("return", _objectSpread({
|
|
3380
|
+
updated: false,
|
|
3381
|
+
payment: previousPayment,
|
|
3382
|
+
payments: currentPayments,
|
|
3383
|
+
summary: ((_this$store$order$get2 = this.store.order.getOrderAmountSnapshot()) === null || _this$store$order$get2 === void 0 ? void 0 : _this$store$order$get2.summary) || null
|
|
3384
|
+
}, _syncResult !== undefined ? {
|
|
3385
|
+
syncResult: _syncResult
|
|
3386
|
+
} : {}));
|
|
3387
|
+
case 13:
|
|
3388
|
+
_context34.next = 15;
|
|
3389
|
+
return this.store.order.updateOrderPayment(paymentIdentity, updates, {
|
|
3390
|
+
matchBy: matchMode
|
|
3391
|
+
});
|
|
3392
|
+
case 15:
|
|
3393
|
+
result = _context34.sent;
|
|
3394
|
+
if (!(options.persistDraft !== false)) {
|
|
3395
|
+
_context34.next = 29;
|
|
3396
|
+
break;
|
|
3397
|
+
}
|
|
3398
|
+
_context34.prev = 17;
|
|
3399
|
+
_context34.next = 20;
|
|
3400
|
+
return this.saveSalesOrderDraft();
|
|
3401
|
+
case 20:
|
|
3402
|
+
draftResult = _context34.sent;
|
|
3403
|
+
_context34.next = 29;
|
|
3404
|
+
break;
|
|
3405
|
+
case 23:
|
|
3406
|
+
_context34.prev = 23;
|
|
3407
|
+
_context34.t0 = _context34["catch"](17);
|
|
3408
|
+
draftError = _context34.t0;
|
|
3409
|
+
this.logError('updateOrderPayment: 保存支付草稿失败', {
|
|
3410
|
+
paymentIdentity: paymentIdentity,
|
|
3411
|
+
error: _context34.t0 instanceof Error ? _context34.t0.message : String(_context34.t0)
|
|
3412
|
+
});
|
|
3413
|
+
if (options.submitWhenPaid) {
|
|
3414
|
+
_context34.next = 29;
|
|
3415
|
+
break;
|
|
3416
|
+
}
|
|
3417
|
+
throw _context34.t0;
|
|
3418
|
+
case 29:
|
|
3419
|
+
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';
|
|
3420
|
+
shouldSubmit = Boolean(options.submitWhenPaid && ((_result$payment2 = result.payment) === null || _result$payment2 === void 0 ? void 0 : _result$payment2.status) === 'paid' && (becamePaid || options.forceSubmitIfPaid));
|
|
3421
|
+
if (!shouldSubmit) {
|
|
3422
|
+
_context34.next = 35;
|
|
3423
|
+
break;
|
|
3424
|
+
}
|
|
3425
|
+
_context34.next = 34;
|
|
3426
|
+
return this.syncPaymentsToOrder({
|
|
3427
|
+
payments: result.payments,
|
|
3428
|
+
paymentStatus: this.getPaymentStatusForSync(result.payments),
|
|
3429
|
+
submitWhenPaid: true,
|
|
3430
|
+
smallTicketDataFlag: (_options$smallTicketD2 = options.smallTicketDataFlag) !== null && _options$smallTicketD2 !== void 0 ? _options$smallTicketD2 : 1
|
|
3431
|
+
});
|
|
3432
|
+
case 34:
|
|
3433
|
+
syncResult = _context34.sent;
|
|
3434
|
+
case 35:
|
|
3435
|
+
return _context34.abrupt("return", _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, result), draftResult !== undefined ? {
|
|
3436
|
+
draftResult: draftResult
|
|
3437
|
+
} : {}), draftError !== undefined ? {
|
|
3438
|
+
draftError: draftError
|
|
3439
|
+
} : {}), syncResult !== undefined ? {
|
|
3440
|
+
syncResult: syncResult
|
|
3441
|
+
} : {}));
|
|
3442
|
+
case 36:
|
|
3443
|
+
case "end":
|
|
3444
|
+
return _context34.stop();
|
|
3445
|
+
}
|
|
3446
|
+
}, _callee34, this, [[17, 23]]);
|
|
3447
|
+
}));
|
|
3448
|
+
function updateOrderPayment(_x27, _x28) {
|
|
3449
|
+
return _updateOrderPayment.apply(this, arguments);
|
|
3450
|
+
}
|
|
3451
|
+
return updateOrderPayment;
|
|
3452
|
+
}() /** 删除当前订单中的指定支付项。 */)
|
|
3068
3453
|
}, {
|
|
3069
3454
|
key: "deleteOrderPayment",
|
|
3070
3455
|
value: function deleteOrderPayment(paymentIdentity) {
|
|
@@ -3079,11 +3464,42 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3079
3464
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
3080
3465
|
return this.store.order.updateVoucherOrderPayments(payments, options);
|
|
3081
3466
|
}
|
|
3467
|
+
}, {
|
|
3468
|
+
key: "updateVoucherOrderPaymentsAsync",
|
|
3469
|
+
value: function () {
|
|
3470
|
+
var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(payments, options) {
|
|
3471
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
3472
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
3473
|
+
case 0:
|
|
3474
|
+
if (this.store.order) {
|
|
3475
|
+
_context35.next = 2;
|
|
3476
|
+
break;
|
|
3477
|
+
}
|
|
3478
|
+
throw new Error('order 模块未初始化');
|
|
3479
|
+
case 2:
|
|
3480
|
+
return _context35.abrupt("return", this.store.order.updateVoucherOrderPaymentsAsync(payments, options));
|
|
3481
|
+
case 3:
|
|
3482
|
+
case "end":
|
|
3483
|
+
return _context35.stop();
|
|
3484
|
+
}
|
|
3485
|
+
}, _callee35, this);
|
|
3486
|
+
}));
|
|
3487
|
+
function updateVoucherOrderPaymentsAsync(_x29, _x30) {
|
|
3488
|
+
return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
|
|
3489
|
+
}
|
|
3490
|
+
return updateVoucherOrderPaymentsAsync;
|
|
3491
|
+
}()
|
|
3082
3492
|
}, {
|
|
3083
3493
|
key: "confirmPendingVoucherPayments",
|
|
3084
3494
|
value: function confirmPendingVoucherPayments() {
|
|
3085
3495
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
3086
|
-
|
|
3496
|
+
var payments = this.store.order.confirmPendingVoucherPayments();
|
|
3497
|
+
if (this.store.payment) {
|
|
3498
|
+
var committed = this.getCommittedWalletAssets();
|
|
3499
|
+
var state = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
3500
|
+
void this.publishWalletAssetsState(state);
|
|
3501
|
+
}
|
|
3502
|
+
return payments;
|
|
3087
3503
|
}
|
|
3088
3504
|
}, {
|
|
3089
3505
|
key: "discardPendingVoucherPayments",
|
|
@@ -3152,64 +3568,72 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3152
3568
|
});
|
|
3153
3569
|
return walletProducts;
|
|
3154
3570
|
}
|
|
3571
|
+
}, {
|
|
3572
|
+
key: "buildWalletInitBusinessData",
|
|
3573
|
+
value: function buildWalletInitBusinessData(params) {
|
|
3574
|
+
var _this$store$order8, _params$order_wait_pa, _ref31, _tempOrder$is_price_i;
|
|
3575
|
+
var snapshot = (_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 ? void 0 : _this$store$order8.getOrderSnapshot();
|
|
3576
|
+
var tempOrder = snapshot === null || snapshot === void 0 ? void 0 : snapshot.tempOrder;
|
|
3577
|
+
var amount = snapshot === null || snapshot === void 0 ? void 0 : snapshot.amount;
|
|
3578
|
+
if (!tempOrder || !amount) return null;
|
|
3579
|
+
return _objectSpread({
|
|
3580
|
+
customer_id: tempOrder.customer_id ? Number(tempOrder.customer_id) : undefined,
|
|
3581
|
+
holder: tempOrder.holder,
|
|
3582
|
+
amountInfo: {
|
|
3583
|
+
totalAmount: amount.totalAmount,
|
|
3584
|
+
subTotal: amount.summary.product_amount || amount.summary.product_expect_amount || amount.totalAmount,
|
|
3585
|
+
depositAmount: amount.depositAmount,
|
|
3586
|
+
isDeposit: tempOrder.is_deposit
|
|
3587
|
+
},
|
|
3588
|
+
products: this.getWalletProductList(),
|
|
3589
|
+
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),
|
|
3590
|
+
is_price_include_tax: (_ref31 = (_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 && _ref31 !== void 0 ? _ref31 : 1
|
|
3591
|
+
}, snapshot.identity.orderId ? {
|
|
3592
|
+
payment_order_id: String(snapshot.identity.orderId)
|
|
3593
|
+
} : {});
|
|
3594
|
+
}
|
|
3155
3595
|
}, {
|
|
3156
3596
|
key: "initWalletData",
|
|
3157
3597
|
value: function () {
|
|
3158
|
-
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3159
|
-
var
|
|
3160
|
-
var snapshot,
|
|
3161
|
-
return _regeneratorRuntime().wrap(function
|
|
3162
|
-
while (1) switch (
|
|
3598
|
+
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
|
|
3599
|
+
var _snapshot$identity;
|
|
3600
|
+
var snapshot, walletBusinessData, result;
|
|
3601
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
3602
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
3163
3603
|
case 0:
|
|
3164
3604
|
if (this.store.order) {
|
|
3165
|
-
|
|
3605
|
+
_context36.next = 2;
|
|
3166
3606
|
break;
|
|
3167
3607
|
}
|
|
3168
3608
|
throw new Error('order 模块未初始化');
|
|
3169
3609
|
case 2:
|
|
3170
3610
|
if (this.store.payment) {
|
|
3171
|
-
|
|
3611
|
+
_context36.next = 4;
|
|
3172
3612
|
break;
|
|
3173
3613
|
}
|
|
3174
3614
|
throw new Error('payment 模块未初始化');
|
|
3175
3615
|
case 4:
|
|
3176
3616
|
snapshot = this.store.order.getOrderSnapshot();
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
_context32.next = 9;
|
|
3617
|
+
walletBusinessData = this.buildWalletInitBusinessData(params);
|
|
3618
|
+
if (walletBusinessData) {
|
|
3619
|
+
_context36.next = 8;
|
|
3181
3620
|
break;
|
|
3182
3621
|
}
|
|
3183
|
-
return
|
|
3622
|
+
return _context36.abrupt("return", {
|
|
3184
3623
|
walletRecommendList: [],
|
|
3185
3624
|
userIdentificationCodes: [],
|
|
3186
3625
|
transformList: [],
|
|
3187
3626
|
noApplicableVoucher: [],
|
|
3188
3627
|
products: []
|
|
3189
3628
|
});
|
|
3190
|
-
case
|
|
3191
|
-
|
|
3192
|
-
customer_id: tempOrder.customer_id ? Number(tempOrder.customer_id) : undefined,
|
|
3193
|
-
holder: tempOrder.holder,
|
|
3194
|
-
amountInfo: {
|
|
3195
|
-
totalAmount: amount.totalAmount,
|
|
3196
|
-
subTotal: amount.summary.product_amount || amount.summary.product_expect_amount || amount.totalAmount,
|
|
3197
|
-
depositAmount: amount.depositAmount,
|
|
3198
|
-
isDeposit: tempOrder.is_deposit
|
|
3199
|
-
},
|
|
3200
|
-
products: this.getWalletProductList(),
|
|
3201
|
-
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),
|
|
3202
|
-
is_price_include_tax: (_ref24 = (_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 && _ref24 !== void 0 ? _ref24 : 1
|
|
3203
|
-
}, snapshot.identity.orderId ? {
|
|
3204
|
-
payment_order_id: String(snapshot.identity.orderId)
|
|
3205
|
-
} : {});
|
|
3206
|
-
_context32.next = 12;
|
|
3629
|
+
case 8:
|
|
3630
|
+
_context36.next = 10;
|
|
3207
3631
|
return this.store.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
|
|
3208
|
-
case
|
|
3209
|
-
result =
|
|
3210
|
-
|
|
3632
|
+
case 10:
|
|
3633
|
+
result = _context36.sent;
|
|
3634
|
+
_context36.next = 13;
|
|
3211
3635
|
return this.core.effects.emit("".concat(this.name, ":onWalletDataInitialized"), {
|
|
3212
|
-
orderId: snapshot.identity.orderId,
|
|
3636
|
+
orderId: snapshot === null || snapshot === void 0 || (_snapshot$identity = snapshot.identity) === null || _snapshot$identity === void 0 ? void 0 : _snapshot$identity.orderId,
|
|
3213
3637
|
customerId: walletBusinessData.customer_id,
|
|
3214
3638
|
walletBusinessData: {
|
|
3215
3639
|
customer_id: walletBusinessData.customer_id,
|
|
@@ -3218,25 +3642,413 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3218
3642
|
},
|
|
3219
3643
|
timestamp: Date.now()
|
|
3220
3644
|
});
|
|
3221
|
-
case
|
|
3222
|
-
return
|
|
3223
|
-
case
|
|
3645
|
+
case 13:
|
|
3646
|
+
return _context36.abrupt("return", result);
|
|
3647
|
+
case 14:
|
|
3224
3648
|
case "end":
|
|
3225
|
-
return
|
|
3649
|
+
return _context36.stop();
|
|
3226
3650
|
}
|
|
3227
|
-
},
|
|
3651
|
+
}, _callee36, this);
|
|
3228
3652
|
}));
|
|
3229
|
-
function initWalletData(
|
|
3653
|
+
function initWalletData(_x31) {
|
|
3230
3654
|
return _initWalletData.apply(this, arguments);
|
|
3231
3655
|
}
|
|
3232
3656
|
return initWalletData;
|
|
3233
3657
|
}()
|
|
3658
|
+
}, {
|
|
3659
|
+
key: "getCommittedWalletAssets",
|
|
3660
|
+
value: function getCommittedWalletAssets() {
|
|
3661
|
+
var _this$store$order9, _this$store$order9$ge;
|
|
3662
|
+
var payments = ((_this$store$order9 = this.store.order) === null || _this$store$order9 === void 0 || (_this$store$order9$ge = _this$store$order9.getOrderPayments) === null || _this$store$order9$ge === void 0 ? void 0 : _this$store$order9$ge.call(_this$store$order9)) || [];
|
|
3663
|
+
var committed = payments.filter(function (payment) {
|
|
3664
|
+
var voucherId = payment === null || payment === void 0 ? void 0 : payment.voucher_id;
|
|
3665
|
+
if (voucherId === undefined || voucherId === null || voucherId === 0) {
|
|
3666
|
+
return false;
|
|
3667
|
+
}
|
|
3668
|
+
return (payment === null || payment === void 0 ? void 0 : payment.status) === 'paid' || (payment === null || payment === void 0 ? void 0 : payment.isSynced) === true || (payment === null || payment === void 0 ? void 0 : payment.order_payment_id) !== undefined && (payment === null || payment === void 0 ? void 0 : payment.order_payment_id) !== null && (payment === null || payment === void 0 ? void 0 : payment.order_payment_id) !== '';
|
|
3669
|
+
});
|
|
3670
|
+
return {
|
|
3671
|
+
ids: committed.map(function (payment) {
|
|
3672
|
+
return payment.voucher_id;
|
|
3673
|
+
}),
|
|
3674
|
+
assets: committed.map(function (payment) {
|
|
3675
|
+
var _Object$entries$find;
|
|
3676
|
+
var fundRecord = (payment === null || payment === void 0 ? void 0 : payment.fund_record) || {};
|
|
3677
|
+
var walletPassName = fundRecord.wallet_pass_name;
|
|
3678
|
+
var title = walletPassName && _typeof(walletPassName) === 'object' ? walletPassName.default || Object.values(walletPassName)[0] : walletPassName;
|
|
3679
|
+
var code = String((payment === null || payment === void 0 ? void 0 : payment.code) || '').toUpperCase();
|
|
3680
|
+
var tag = ((_Object$entries$find = Object.entries(WALLET_PAYMENT_CODE_BY_TAG).find(function (_ref32) {
|
|
3681
|
+
var _ref33 = _slicedToArray(_ref32, 2),
|
|
3682
|
+
paymentCode = _ref33[1];
|
|
3683
|
+
return paymentCode === code;
|
|
3684
|
+
})) === null || _Object$entries$find === void 0 ? void 0 : _Object$entries$find[0]) || fundRecord.tag;
|
|
3685
|
+
return {
|
|
3686
|
+
id: payment.voucher_id,
|
|
3687
|
+
voucher_id: payment.voucher_id,
|
|
3688
|
+
code: fundRecord.code,
|
|
3689
|
+
tag: tag,
|
|
3690
|
+
product_name: title || payment.name,
|
|
3691
|
+
name: title || payment.name,
|
|
3692
|
+
amount: Number(payment.amount || 0),
|
|
3693
|
+
_available_max_amount: Number(payment.amount || 0),
|
|
3694
|
+
unified_available_status: 1,
|
|
3695
|
+
_unified_available_status: 1,
|
|
3696
|
+
_committed_payment: payment
|
|
3697
|
+
};
|
|
3698
|
+
})
|
|
3699
|
+
};
|
|
3700
|
+
}
|
|
3701
|
+
}, {
|
|
3702
|
+
key: "publishWalletAssetsState",
|
|
3703
|
+
value: function () {
|
|
3704
|
+
var _publishWalletAssetsState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(state) {
|
|
3705
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
3706
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
3707
|
+
case 0:
|
|
3708
|
+
_context37.next = 2;
|
|
3709
|
+
return this.effectsEmit(BaseSalesHookNames.onWalletAssetsStateChanged, {
|
|
3710
|
+
state: state
|
|
3711
|
+
});
|
|
3712
|
+
case 2:
|
|
3713
|
+
return _context37.abrupt("return", state);
|
|
3714
|
+
case 3:
|
|
3715
|
+
case "end":
|
|
3716
|
+
return _context37.stop();
|
|
3717
|
+
}
|
|
3718
|
+
}, _callee37, this);
|
|
3719
|
+
}));
|
|
3720
|
+
function publishWalletAssetsState(_x32) {
|
|
3721
|
+
return _publishWalletAssetsState.apply(this, arguments);
|
|
3722
|
+
}
|
|
3723
|
+
return publishWalletAssetsState;
|
|
3724
|
+
}()
|
|
3725
|
+
}, {
|
|
3726
|
+
key: "syncSelectedWalletAssets",
|
|
3727
|
+
value: function () {
|
|
3728
|
+
var _syncSelectedWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(state) {
|
|
3729
|
+
var paymentMethods, methodByCode, preparePayments, selectedAssetById, voucherPayments, payments;
|
|
3730
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
3731
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
3732
|
+
case 0:
|
|
3733
|
+
if (!(!this.store.order || !this.store.payment)) {
|
|
3734
|
+
_context38.next = 2;
|
|
3735
|
+
break;
|
|
3736
|
+
}
|
|
3737
|
+
throw new Error('订单或支付模块未初始化');
|
|
3738
|
+
case 2:
|
|
3739
|
+
paymentMethods = this.getPaymentMethods();
|
|
3740
|
+
if (!(!paymentMethods.length && state.selectedItems.length)) {
|
|
3741
|
+
_context38.next = 7;
|
|
3742
|
+
break;
|
|
3743
|
+
}
|
|
3744
|
+
_context38.next = 6;
|
|
3745
|
+
return this.getPaymentMethodsAsync();
|
|
3746
|
+
case 6:
|
|
3747
|
+
paymentMethods = _context38.sent;
|
|
3748
|
+
case 7:
|
|
3749
|
+
methodByCode = new Map(paymentMethods.map(function (method) {
|
|
3750
|
+
return [String(method.code || '').toUpperCase(), method];
|
|
3751
|
+
}));
|
|
3752
|
+
preparePayments = this.store.payment.wallet.formatWalletPassList2PreparePayments(state.selectedItems);
|
|
3753
|
+
selectedAssetById = new Map(state.selectedItems.map(function (asset) {
|
|
3754
|
+
return [String(getSharedWalletAssetId(asset)), asset];
|
|
3755
|
+
}));
|
|
3756
|
+
voucherPayments = preparePayments.flatMap(function (item) {
|
|
3757
|
+
var asset = selectedAssetById.get(String(item.voucher_id));
|
|
3758
|
+
var paymentCode = WALLET_PAYMENT_CODE_BY_TAG[String(item.tag || (asset === null || asset === void 0 ? void 0 : asset.tag) || '')] || String(item.tag || (asset === null || asset === void 0 ? void 0 : asset.tag) || '').toUpperCase();
|
|
3759
|
+
var paymentMethod = methodByCode.get(paymentCode);
|
|
3760
|
+
var formattedAmount = Number(item.amount);
|
|
3761
|
+
var amount = Number.isFinite(formattedAmount) && formattedAmount > 0 ? formattedAmount : getSharedWalletAssetAmount(asset);
|
|
3762
|
+
if (!asset || !paymentMethod || !Number.isFinite(amount) || amount <= 0) {
|
|
3763
|
+
return [];
|
|
3764
|
+
}
|
|
3765
|
+
var walletPassUseValue = getSharedWalletPassUseValue({
|
|
3766
|
+
asset: asset,
|
|
3767
|
+
amount: amount,
|
|
3768
|
+
paymentMethod: paymentMethod
|
|
3769
|
+
});
|
|
3770
|
+
return [{
|
|
3771
|
+
amount: amount.toFixed(2),
|
|
3772
|
+
code: paymentMethod.code,
|
|
3773
|
+
custom_payment_id: paymentMethod.id,
|
|
3774
|
+
name: paymentMethod.name,
|
|
3775
|
+
type: paymentMethod.type,
|
|
3776
|
+
voucher_id: item.voucher_id,
|
|
3777
|
+
wallet_pass_usage_unit: item.wallet_pass_usage_unit,
|
|
3778
|
+
wallet_pass_use_value: walletPassUseValue,
|
|
3779
|
+
fund_record: buildSharedWalletFundRecord({
|
|
3780
|
+
asset: asset,
|
|
3781
|
+
amount: amount,
|
|
3782
|
+
paymentMethod: paymentMethod
|
|
3783
|
+
})
|
|
3784
|
+
}];
|
|
3785
|
+
});
|
|
3786
|
+
payments = this.updateVoucherOrderPayments(voucherPayments, {
|
|
3787
|
+
status: 'payment_pending'
|
|
3788
|
+
});
|
|
3789
|
+
_context38.next = 14;
|
|
3790
|
+
return this.store.order.recalculateSummary({
|
|
3791
|
+
createIfMissing: true
|
|
3792
|
+
});
|
|
3793
|
+
case 14:
|
|
3794
|
+
return _context38.abrupt("return", payments);
|
|
3795
|
+
case 15:
|
|
3796
|
+
case "end":
|
|
3797
|
+
return _context38.stop();
|
|
3798
|
+
}
|
|
3799
|
+
}, _callee38, this);
|
|
3800
|
+
}));
|
|
3801
|
+
function syncSelectedWalletAssets(_x33) {
|
|
3802
|
+
return _syncSelectedWalletAssets.apply(this, arguments);
|
|
3803
|
+
}
|
|
3804
|
+
return syncSelectedWalletAssets;
|
|
3805
|
+
}() /** 读取购物车与 Shared Checkout 共用的钱包资产状态。 */
|
|
3806
|
+
}, {
|
|
3807
|
+
key: "getWalletAssetsState",
|
|
3808
|
+
value: function getWalletAssetsState() {
|
|
3809
|
+
if (!this.store.payment) throw new Error('payment 模块未初始化');
|
|
3810
|
+
return this.store.payment.wallet.getWalletAssetsState();
|
|
3811
|
+
}
|
|
3812
|
+
|
|
3813
|
+
/** 导出 Shared Checkout 跨运行时恢复所需的钱包状态与搜索缓存。 */
|
|
3814
|
+
}, {
|
|
3815
|
+
key: "exportWalletAssetsSnapshot",
|
|
3816
|
+
value: function exportWalletAssetsSnapshot() {
|
|
3817
|
+
if (!this.store.payment) throw new Error('payment 模块未初始化');
|
|
3818
|
+
return this.store.payment.wallet.exportWalletAssetsSnapshot();
|
|
3819
|
+
}
|
|
3820
|
+
|
|
3821
|
+
/**
|
|
3822
|
+
* 恢复 Shared Checkout 钱包快照,并把选择重新同步为订单 pending payment。
|
|
3823
|
+
*/
|
|
3824
|
+
}, {
|
|
3825
|
+
key: "importWalletAssetsSnapshot",
|
|
3826
|
+
value: (function () {
|
|
3827
|
+
var _importWalletAssetsSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(snapshot) {
|
|
3828
|
+
var state;
|
|
3829
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
3830
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
3831
|
+
case 0:
|
|
3832
|
+
if (this.store.payment) {
|
|
3833
|
+
_context39.next = 2;
|
|
3834
|
+
break;
|
|
3835
|
+
}
|
|
3836
|
+
throw new Error('payment 模块未初始化');
|
|
3837
|
+
case 2:
|
|
3838
|
+
state = this.store.payment.wallet.importWalletAssetsSnapshot(snapshot);
|
|
3839
|
+
_context39.next = 5;
|
|
3840
|
+
return this.syncSelectedWalletAssets(state);
|
|
3841
|
+
case 5:
|
|
3842
|
+
return _context39.abrupt("return", this.publishWalletAssetsState(state));
|
|
3843
|
+
case 6:
|
|
3844
|
+
case "end":
|
|
3845
|
+
return _context39.stop();
|
|
3846
|
+
}
|
|
3847
|
+
}, _callee39, this);
|
|
3848
|
+
}));
|
|
3849
|
+
function importWalletAssetsSnapshot(_x34) {
|
|
3850
|
+
return _importWalletAssetsSnapshot.apply(this, arguments);
|
|
3851
|
+
}
|
|
3852
|
+
return importWalletAssetsSnapshot;
|
|
3853
|
+
}()
|
|
3854
|
+
/**
|
|
3855
|
+
* 基于当前订单快照刷新钱包资产。商品变化保留并重验选择;客户变化强制清空。
|
|
3856
|
+
*/
|
|
3857
|
+
)
|
|
3858
|
+
}, {
|
|
3859
|
+
key: "refreshWalletAssets",
|
|
3860
|
+
value: (function () {
|
|
3861
|
+
var _refreshWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
|
|
3862
|
+
var _previousState$custom, _businessData$custome;
|
|
3863
|
+
var refreshSequence, wallet, businessData, emptyState, previousState, hasPreviousWalletContext, customerChanged, clearedState, refreshTask, state, committed;
|
|
3864
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
3865
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
3866
|
+
case 0:
|
|
3867
|
+
if (this.store.order) {
|
|
3868
|
+
_context40.next = 2;
|
|
3869
|
+
break;
|
|
3870
|
+
}
|
|
3871
|
+
throw new Error('order 模块未初始化');
|
|
3872
|
+
case 2:
|
|
3873
|
+
if (this.store.payment) {
|
|
3874
|
+
_context40.next = 4;
|
|
3875
|
+
break;
|
|
3876
|
+
}
|
|
3877
|
+
throw new Error('payment 模块未初始化');
|
|
3878
|
+
case 4:
|
|
3879
|
+
refreshSequence = ++this.walletAssetsRefreshSequence;
|
|
3880
|
+
wallet = this.store.payment.wallet;
|
|
3881
|
+
businessData = this.buildWalletInitBusinessData(params);
|
|
3882
|
+
if (businessData) {
|
|
3883
|
+
_context40.next = 12;
|
|
3884
|
+
break;
|
|
3885
|
+
}
|
|
3886
|
+
wallet.clearAllCache();
|
|
3887
|
+
emptyState = wallet.getWalletAssetsState();
|
|
3888
|
+
this.updateVoucherOrderPayments([], {
|
|
3889
|
+
status: 'payment_pending'
|
|
3890
|
+
});
|
|
3891
|
+
return _context40.abrupt("return", this.publishWalletAssetsState(emptyState));
|
|
3892
|
+
case 12:
|
|
3893
|
+
previousState = wallet.getWalletAssetsState();
|
|
3894
|
+
hasPreviousWalletContext = previousState.status !== 'idle' || previousState.items.length > 0 || previousState.selectedIds.length > 0 || previousState.customerId !== undefined;
|
|
3895
|
+
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 : '');
|
|
3896
|
+
if (!customerChanged) {
|
|
3897
|
+
_context40.next = 20;
|
|
3898
|
+
break;
|
|
3899
|
+
}
|
|
3900
|
+
clearedState = wallet.clearWalletAssetSelection();
|
|
3901
|
+
this.updateVoucherOrderPayments([], {
|
|
3902
|
+
status: 'payment_pending'
|
|
3903
|
+
});
|
|
3904
|
+
_context40.next = 20;
|
|
3905
|
+
return this.publishWalletAssetsState(clearedState);
|
|
3906
|
+
case 20:
|
|
3907
|
+
refreshTask = wallet.refreshWalletAssetsFromBusinessAsync(businessData, {
|
|
3908
|
+
preserveSelection: (params === null || params === void 0 ? void 0 : params.preserveSelection) !== false && !customerChanged
|
|
3909
|
+
});
|
|
3910
|
+
_context40.next = 23;
|
|
3911
|
+
return this.publishWalletAssetsState(wallet.getWalletAssetsState());
|
|
3912
|
+
case 23:
|
|
3913
|
+
_context40.next = 25;
|
|
3914
|
+
return refreshTask;
|
|
3915
|
+
case 25:
|
|
3916
|
+
state = _context40.sent;
|
|
3917
|
+
if (!(refreshSequence !== this.walletAssetsRefreshSequence)) {
|
|
3918
|
+
_context40.next = 28;
|
|
3919
|
+
break;
|
|
3920
|
+
}
|
|
3921
|
+
return _context40.abrupt("return", wallet.getWalletAssetsState());
|
|
3922
|
+
case 28:
|
|
3923
|
+
if (state.status !== 'error') {
|
|
3924
|
+
committed = this.getCommittedWalletAssets();
|
|
3925
|
+
state = wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
3926
|
+
}
|
|
3927
|
+
_context40.next = 31;
|
|
3928
|
+
return this.syncSelectedWalletAssets(state);
|
|
3929
|
+
case 31:
|
|
3930
|
+
return _context40.abrupt("return", this.publishWalletAssetsState(state));
|
|
3931
|
+
case 32:
|
|
3932
|
+
case "end":
|
|
3933
|
+
return _context40.stop();
|
|
3934
|
+
}
|
|
3935
|
+
}, _callee40, this);
|
|
3936
|
+
}));
|
|
3937
|
+
function refreshWalletAssets(_x35) {
|
|
3938
|
+
return _refreshWalletAssets.apply(this, arguments);
|
|
3939
|
+
}
|
|
3940
|
+
return refreshWalletAssets;
|
|
3941
|
+
}() /** 选择或取消单张钱包资产,并立即同步 pending wallet payments。 */)
|
|
3942
|
+
}, {
|
|
3943
|
+
key: "selectWalletAsset",
|
|
3944
|
+
value: (function () {
|
|
3945
|
+
var _selectWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
|
|
3946
|
+
var state;
|
|
3947
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context41) {
|
|
3948
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
3949
|
+
case 0:
|
|
3950
|
+
if (this.store.payment) {
|
|
3951
|
+
_context41.next = 2;
|
|
3952
|
+
break;
|
|
3953
|
+
}
|
|
3954
|
+
throw new Error('payment 模块未初始化');
|
|
3955
|
+
case 2:
|
|
3956
|
+
state = this.store.payment.wallet.selectWalletAsset(params.assetId, {
|
|
3957
|
+
selected: params.selected,
|
|
3958
|
+
source: params.source
|
|
3959
|
+
});
|
|
3960
|
+
_context41.next = 5;
|
|
3961
|
+
return this.syncSelectedWalletAssets(state);
|
|
3962
|
+
case 5:
|
|
3963
|
+
return _context41.abrupt("return", this.publishWalletAssetsState(state));
|
|
3964
|
+
case 6:
|
|
3965
|
+
case "end":
|
|
3966
|
+
return _context41.stop();
|
|
3967
|
+
}
|
|
3968
|
+
}, _callee41, this);
|
|
3969
|
+
}));
|
|
3970
|
+
function selectWalletAsset(_x36) {
|
|
3971
|
+
return _selectWalletAsset.apply(this, arguments);
|
|
3972
|
+
}
|
|
3973
|
+
return selectWalletAsset;
|
|
3974
|
+
}() /** 扫码精确查券;仅可用资产会被自动选中。 */)
|
|
3975
|
+
}, {
|
|
3976
|
+
key: "scanWalletAsset",
|
|
3977
|
+
value: (function () {
|
|
3978
|
+
var _scanWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(code) {
|
|
3979
|
+
var result;
|
|
3980
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context42) {
|
|
3981
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
3982
|
+
case 0:
|
|
3983
|
+
if (this.store.payment) {
|
|
3984
|
+
_context42.next = 2;
|
|
3985
|
+
break;
|
|
3986
|
+
}
|
|
3987
|
+
throw new Error('payment 模块未初始化');
|
|
3988
|
+
case 2:
|
|
3989
|
+
_context42.next = 4;
|
|
3990
|
+
return this.store.payment.wallet.scanWalletAssetAsync(code);
|
|
3991
|
+
case 4:
|
|
3992
|
+
result = _context42.sent;
|
|
3993
|
+
if (!(result.type === 'normalCode')) {
|
|
3994
|
+
_context42.next = 10;
|
|
3995
|
+
break;
|
|
3996
|
+
}
|
|
3997
|
+
_context42.next = 8;
|
|
3998
|
+
return this.syncSelectedWalletAssets(result.state);
|
|
3999
|
+
case 8:
|
|
4000
|
+
_context42.next = 10;
|
|
4001
|
+
return this.publishWalletAssetsState(result.state);
|
|
4002
|
+
case 10:
|
|
4003
|
+
return _context42.abrupt("return", result);
|
|
4004
|
+
case 11:
|
|
4005
|
+
case "end":
|
|
4006
|
+
return _context42.stop();
|
|
4007
|
+
}
|
|
4008
|
+
}, _callee42, this);
|
|
4009
|
+
}));
|
|
4010
|
+
function scanWalletAsset(_x37) {
|
|
4011
|
+
return _scanWalletAsset.apply(this, arguments);
|
|
4012
|
+
}
|
|
4013
|
+
return scanWalletAsset;
|
|
4014
|
+
}() /** 清空全部未确认钱包选择,已支付钱包项由 Order 模块继续保留。 */)
|
|
4015
|
+
}, {
|
|
4016
|
+
key: "clearWalletAssetSelection",
|
|
4017
|
+
value: (function () {
|
|
4018
|
+
var _clearWalletAssetSelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43() {
|
|
4019
|
+
var state;
|
|
4020
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context43) {
|
|
4021
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
4022
|
+
case 0:
|
|
4023
|
+
if (this.store.payment) {
|
|
4024
|
+
_context43.next = 2;
|
|
4025
|
+
break;
|
|
4026
|
+
}
|
|
4027
|
+
throw new Error('payment 模块未初始化');
|
|
4028
|
+
case 2:
|
|
4029
|
+
state = this.store.payment.wallet.clearWalletAssetSelection();
|
|
4030
|
+
_context43.next = 5;
|
|
4031
|
+
return this.syncSelectedWalletAssets(state);
|
|
4032
|
+
case 5:
|
|
4033
|
+
return _context43.abrupt("return", this.publishWalletAssetsState(state));
|
|
4034
|
+
case 6:
|
|
4035
|
+
case "end":
|
|
4036
|
+
return _context43.stop();
|
|
4037
|
+
}
|
|
4038
|
+
}, _callee43, this);
|
|
4039
|
+
}));
|
|
4040
|
+
function clearWalletAssetSelection() {
|
|
4041
|
+
return _clearWalletAssetSelection.apply(this, arguments);
|
|
4042
|
+
}
|
|
4043
|
+
return clearWalletAssetSelection;
|
|
4044
|
+
}()
|
|
3234
4045
|
/**
|
|
3235
4046
|
* 更新当前订单客户字段。
|
|
3236
4047
|
*
|
|
3237
4048
|
* 这是 PaymentModal 客户切换的订单事实入口;外部客户模块同步应由
|
|
3238
4049
|
* 调用方通过 onCustomerChange 回调完成。
|
|
3239
4050
|
*/
|
|
4051
|
+
)
|
|
3240
4052
|
}, {
|
|
3241
4053
|
key: "updateOrderCustomer",
|
|
3242
4054
|
value: function updateOrderCustomer(customer) {
|
|
@@ -3253,35 +4065,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3253
4065
|
}, {
|
|
3254
4066
|
key: "getPaymentMethodsAsync",
|
|
3255
4067
|
value: (function () {
|
|
3256
|
-
var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4068
|
+
var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
|
|
3257
4069
|
var response, paymentMethods;
|
|
3258
|
-
return _regeneratorRuntime().wrap(function
|
|
3259
|
-
while (1) switch (
|
|
4070
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context44) {
|
|
4071
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
3260
4072
|
case 0:
|
|
3261
|
-
|
|
3262
|
-
|
|
4073
|
+
_context44.prev = 0;
|
|
4074
|
+
_context44.next = 3;
|
|
3263
4075
|
return this.request.get('/pay/custom-payment/all', {
|
|
3264
4076
|
filterPaymentMethods: true
|
|
3265
4077
|
}, {
|
|
3266
4078
|
osServer: true
|
|
3267
4079
|
});
|
|
3268
4080
|
case 3:
|
|
3269
|
-
response =
|
|
4081
|
+
response = _context44.sent;
|
|
3270
4082
|
paymentMethods = (response === null || response === void 0 ? void 0 : response.data) || [];
|
|
3271
4083
|
this.paymentMethodsCache = Array.isArray(paymentMethods) ? _toConsumableArray(paymentMethods) : [];
|
|
3272
|
-
return
|
|
4084
|
+
return _context44.abrupt("return", this.getPaymentMethods());
|
|
3273
4085
|
case 9:
|
|
3274
|
-
|
|
3275
|
-
|
|
4086
|
+
_context44.prev = 9;
|
|
4087
|
+
_context44.t0 = _context44["catch"](0);
|
|
3276
4088
|
this.logWarning('getPaymentMethodsAsync: 获取支付方式列表失败,使用缓存列表', {
|
|
3277
|
-
error:
|
|
4089
|
+
error: _context44.t0 instanceof Error ? _context44.t0.message : String(_context44.t0)
|
|
3278
4090
|
});
|
|
3279
|
-
return
|
|
4091
|
+
return _context44.abrupt("return", this.getPaymentMethods());
|
|
3280
4092
|
case 13:
|
|
3281
4093
|
case "end":
|
|
3282
|
-
return
|
|
4094
|
+
return _context44.stop();
|
|
3283
4095
|
}
|
|
3284
|
-
},
|
|
4096
|
+
}, _callee44, this, [[0, 9]]);
|
|
3285
4097
|
}));
|
|
3286
4098
|
function getPaymentMethodsAsync() {
|
|
3287
4099
|
return _getPaymentMethodsAsync.apply(this, arguments);
|
|
@@ -3293,85 +4105,593 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3293
4105
|
value: function getPaymentMethods() {
|
|
3294
4106
|
return _toConsumableArray(this.paymentMethodsCache);
|
|
3295
4107
|
}
|
|
3296
|
-
|
|
3297
|
-
/** 轻量舍入能力,供现金支付 UI 计算 rounding_amount。 */
|
|
3298
4108
|
}, {
|
|
3299
|
-
key: "
|
|
3300
|
-
value: function
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
4109
|
+
key: "findCashPaymentMethod",
|
|
4110
|
+
value: function findCashPaymentMethod(paymentMethods) {
|
|
4111
|
+
return paymentMethods.find(function (method) {
|
|
4112
|
+
var identifiers = [method === null || method === void 0 ? void 0 : method.code, method === null || method === void 0 ? void 0 : method.type, method === null || method === void 0 ? void 0 : method.tag].map(function (value) {
|
|
4113
|
+
return String(value || '').toUpperCase();
|
|
4114
|
+
});
|
|
4115
|
+
return identifiers.includes('CASHMANUAL') && (method === null || method === void 0 ? void 0 : method.enabled) !== false && (method === null || method === void 0 ? void 0 : method.enable) !== false;
|
|
4116
|
+
});
|
|
4117
|
+
}
|
|
4118
|
+
}, {
|
|
4119
|
+
key: "getPendingWalletPaymentAmount",
|
|
4120
|
+
value: function getPendingWalletPaymentAmount() {
|
|
4121
|
+
var _this$store$order10, _this$store$order10$g;
|
|
4122
|
+
var payments = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ((_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)) || [];
|
|
4123
|
+
return payments.reduce(function (total, payment) {
|
|
4124
|
+
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) {
|
|
4125
|
+
return total;
|
|
4126
|
+
}
|
|
4127
|
+
try {
|
|
4128
|
+
return total.plus(payment.amount || 0).plus(payment.rounding_amount || 0);
|
|
4129
|
+
} catch (_unused5) {
|
|
4130
|
+
return total;
|
|
4131
|
+
}
|
|
4132
|
+
}, new Decimal(0));
|
|
3321
4133
|
}
|
|
3322
4134
|
|
|
4135
|
+
/** 读取现金 action 所需的支付方式、待付金额和快捷金额。 */
|
|
4136
|
+
}, {
|
|
4137
|
+
key: "getCashPaymentConfig",
|
|
4138
|
+
value: (function () {
|
|
4139
|
+
var _getCashPaymentConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45() {
|
|
4140
|
+
var _this$store$order11, _this$store$order11$g, _this$store$order12, _this$store$order12$g, _this$otherParams25;
|
|
4141
|
+
var paymentMethods, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, currency, recommendedAmounts;
|
|
4142
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context45) {
|
|
4143
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
4144
|
+
case 0:
|
|
4145
|
+
if (this.store.payment) {
|
|
4146
|
+
_context45.next = 2;
|
|
4147
|
+
break;
|
|
4148
|
+
}
|
|
4149
|
+
throw new Error('payment 模块未初始化');
|
|
4150
|
+
case 2:
|
|
4151
|
+
paymentMethods = this.getPaymentMethods();
|
|
4152
|
+
paymentMethod = this.findCashPaymentMethod(paymentMethods);
|
|
4153
|
+
if (paymentMethod) {
|
|
4154
|
+
_context45.next = 9;
|
|
4155
|
+
break;
|
|
4156
|
+
}
|
|
4157
|
+
_context45.next = 7;
|
|
4158
|
+
return this.getPaymentMethodsAsync();
|
|
4159
|
+
case 7:
|
|
4160
|
+
paymentMethods = _context45.sent;
|
|
4161
|
+
paymentMethod = this.findCashPaymentMethod(paymentMethods);
|
|
4162
|
+
case 9:
|
|
4163
|
+
amountSnapshot = (_this$store$order11 = this.store.order) === null || _this$store$order11 === void 0 || (_this$store$order11$g = _this$store$order11.getOrderAmountSnapshot) === null || _this$store$order11$g === void 0 ? void 0 : _this$store$order11$g.call(_this$store$order11);
|
|
4164
|
+
pendingWalletAmount = this.getPendingWalletPaymentAmount();
|
|
4165
|
+
amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0).toDecimalPlaces(2).toNumber();
|
|
4166
|
+
currency = ((_this$store$order12 = this.store.order) === null || _this$store$order12 === void 0 || (_this$store$order12$g = _this$store$order12.getTempOrder) === null || _this$store$order12$g === void 0 || (_this$store$order12$g = _this$store$order12$g.call(_this$store$order12)) === null || _this$store$order12$g === void 0 ? void 0 : _this$store$order12$g.currency_code) || ((_this$otherParams25 = this.otherParams) === null || _this$otherParams25 === void 0 ? void 0 : _this$otherParams25.currency) || 'USD';
|
|
4167
|
+
recommendedAmounts = amountDue > 0 ? this.store.payment.cash.getRecommendedAmount(amountDue, currency) : [];
|
|
4168
|
+
return _context45.abrupt("return", {
|
|
4169
|
+
available: Boolean(paymentMethod && amountDue > 0),
|
|
4170
|
+
paymentMethod: paymentMethod,
|
|
4171
|
+
amountDue: amountDue,
|
|
4172
|
+
recommendedAmounts: recommendedAmounts
|
|
4173
|
+
});
|
|
4174
|
+
case 15:
|
|
4175
|
+
case "end":
|
|
4176
|
+
return _context45.stop();
|
|
4177
|
+
}
|
|
4178
|
+
}, _callee45, this);
|
|
4179
|
+
}));
|
|
4180
|
+
function getCashPaymentConfig() {
|
|
4181
|
+
return _getCashPaymentConfig.apply(this, arguments);
|
|
4182
|
+
}
|
|
4183
|
+
return getCashPaymentConfig;
|
|
4184
|
+
}()
|
|
4185
|
+
/**
|
|
4186
|
+
* 确认足额覆盖订单的 pending Wallet 支付并提交订单。
|
|
4187
|
+
*
|
|
4188
|
+
* Order 模块在构造提交参数时将 pending voucher 转为 paid;只有提交成功后
|
|
4189
|
+
* 才同步 Wallet committed 状态。失败时恢复调用前 payments,允许用户重试。
|
|
4190
|
+
*/
|
|
4191
|
+
)
|
|
4192
|
+
}, {
|
|
4193
|
+
key: "confirmWalletPayment",
|
|
4194
|
+
value: (function () {
|
|
4195
|
+
var _confirmWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
|
|
4196
|
+
var _this$store$order$get3, _this$store$order13, _this$store$order$get4, _this$store$order$get5, _this$store$order14;
|
|
4197
|
+
var beforePayments, pendingWalletAmount, amountSnapshot, effectiveAmountDue, beforePaymentStatus, submitResult, restoredTempOrder, committed, walletState, latestAmountSnapshot;
|
|
4198
|
+
return _regeneratorRuntime().wrap(function _callee46$(_context46) {
|
|
4199
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
4200
|
+
case 0:
|
|
4201
|
+
if (this.store.order) {
|
|
4202
|
+
_context46.next = 2;
|
|
4203
|
+
break;
|
|
4204
|
+
}
|
|
4205
|
+
throw new Error('order 模块未初始化');
|
|
4206
|
+
case 2:
|
|
4207
|
+
beforePayments = cloneDeep(this.store.order.getOrderPayments());
|
|
4208
|
+
pendingWalletAmount = this.getPendingWalletPaymentAmount(beforePayments);
|
|
4209
|
+
if (!pendingWalletAmount.lte(0)) {
|
|
4210
|
+
_context46.next = 6;
|
|
4211
|
+
break;
|
|
4212
|
+
}
|
|
4213
|
+
throw new Error('当前订单没有待确认的 Wallet 支付');
|
|
4214
|
+
case 6:
|
|
4215
|
+
amountSnapshot = (_this$store$order$get3 = (_this$store$order13 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get3 === void 0 ? void 0 : _this$store$order$get3.call(_this$store$order13);
|
|
4216
|
+
effectiveAmountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
|
|
4217
|
+
if (!effectiveAmountDue.gt(0.01)) {
|
|
4218
|
+
_context46.next = 10;
|
|
4219
|
+
break;
|
|
4220
|
+
}
|
|
4221
|
+
throw new Error('Wallet 支付尚未覆盖全部待支付金额');
|
|
4222
|
+
case 10:
|
|
4223
|
+
beforePaymentStatus = (_this$store$order$get4 = this.store.order.getTempOrder()) === null || _this$store$order$get4 === void 0 ? void 0 : _this$store$order$get4.payment_status;
|
|
4224
|
+
_context46.prev = 11;
|
|
4225
|
+
_context46.next = 14;
|
|
4226
|
+
return this.submitSalesOrder({
|
|
4227
|
+
smallTicketDataFlag: 1,
|
|
4228
|
+
confirmPendingVoucherPayments: true
|
|
4229
|
+
});
|
|
4230
|
+
case 14:
|
|
4231
|
+
submitResult = _context46.sent;
|
|
4232
|
+
if (!isRejectedSalesSubmitResult(submitResult)) {
|
|
4233
|
+
_context46.next = 17;
|
|
4234
|
+
break;
|
|
4235
|
+
}
|
|
4236
|
+
throw new Error(getSalesSubmitErrorMessage(submitResult));
|
|
4237
|
+
case 17:
|
|
4238
|
+
_context46.next = 27;
|
|
4239
|
+
break;
|
|
4240
|
+
case 19:
|
|
4241
|
+
_context46.prev = 19;
|
|
4242
|
+
_context46.t0 = _context46["catch"](11);
|
|
4243
|
+
this.store.order.setOrderPayments(beforePayments);
|
|
4244
|
+
restoredTempOrder = this.store.order.getTempOrder();
|
|
4245
|
+
if (restoredTempOrder && beforePaymentStatus !== undefined) {
|
|
4246
|
+
restoredTempOrder.payment_status = beforePaymentStatus;
|
|
4247
|
+
this.store.order.persistTempOrder();
|
|
4248
|
+
}
|
|
4249
|
+
_context46.next = 26;
|
|
4250
|
+
return this.store.order.recalculateSummary({
|
|
4251
|
+
createIfMissing: true
|
|
4252
|
+
});
|
|
4253
|
+
case 26:
|
|
4254
|
+
throw _context46.t0;
|
|
4255
|
+
case 27:
|
|
4256
|
+
if (!this.store.payment) {
|
|
4257
|
+
_context46.next = 38;
|
|
4258
|
+
break;
|
|
4259
|
+
}
|
|
4260
|
+
_context46.prev = 28;
|
|
4261
|
+
committed = this.getCommittedWalletAssets();
|
|
4262
|
+
walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
4263
|
+
_context46.next = 33;
|
|
4264
|
+
return this.publishWalletAssetsState(walletState);
|
|
4265
|
+
case 33:
|
|
4266
|
+
_context46.next = 38;
|
|
4267
|
+
break;
|
|
4268
|
+
case 35:
|
|
4269
|
+
_context46.prev = 35;
|
|
4270
|
+
_context46.t1 = _context46["catch"](28);
|
|
4271
|
+
this.logWarning('confirmWalletPayment: Wallet committed 状态同步失败', {
|
|
4272
|
+
error: _context46.t1 instanceof Error ? _context46.t1.message : String(_context46.t1)
|
|
4273
|
+
});
|
|
4274
|
+
case 38:
|
|
4275
|
+
latestAmountSnapshot = (_this$store$order$get5 = (_this$store$order14 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get5 === void 0 ? void 0 : _this$store$order$get5.call(_this$store$order14);
|
|
4276
|
+
return _context46.abrupt("return", {
|
|
4277
|
+
submitResult: submitResult,
|
|
4278
|
+
payments: this.store.order.getOrderPayments(),
|
|
4279
|
+
isOrderFullyPaid: new Decimal((latestAmountSnapshot === null || latestAmountSnapshot === void 0 ? void 0 : latestAmountSnapshot.amountGap) || 0).lte(0)
|
|
4280
|
+
});
|
|
4281
|
+
case 40:
|
|
4282
|
+
case "end":
|
|
4283
|
+
return _context46.stop();
|
|
4284
|
+
}
|
|
4285
|
+
}, _callee46, this, [[11, 19], [28, 35]]);
|
|
4286
|
+
}));
|
|
4287
|
+
function confirmWalletPayment() {
|
|
4288
|
+
return _confirmWalletPayment.apply(this, arguments);
|
|
4289
|
+
}
|
|
4290
|
+
return confirmWalletPayment;
|
|
4291
|
+
}()
|
|
4292
|
+
/**
|
|
4293
|
+
* 购物车现金直付:写入现金记录并等待支付同步完成。
|
|
4294
|
+
* 同步失败会恢复调用前 payments(包含 Wallet pending 状态)。
|
|
4295
|
+
*/
|
|
4296
|
+
)
|
|
4297
|
+
}, {
|
|
4298
|
+
key: "payCash",
|
|
4299
|
+
value: (function () {
|
|
4300
|
+
var _payCash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(params) {
|
|
4301
|
+
var _this$store$order$get6, _params$actualPaidAmo, _this$otherParams26, _this$window, _this$window$postMess;
|
|
4302
|
+
var amount, config, paymentMethod, roundingAmount, effectivePaymentAmount, beforePayments, beforePaymentStatus, uniquePaymentNumber, paymentTimestamp, actualPaidAmount, changeAmount, shopWalletPassId, payments, payment, syncResult, committed, walletState, restoredTempOrder;
|
|
4303
|
+
return _regeneratorRuntime().wrap(function _callee47$(_context47) {
|
|
4304
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
4305
|
+
case 0:
|
|
4306
|
+
if (this.store.order) {
|
|
4307
|
+
_context47.next = 2;
|
|
4308
|
+
break;
|
|
4309
|
+
}
|
|
4310
|
+
throw new Error('order 模块未初始化');
|
|
4311
|
+
case 2:
|
|
4312
|
+
amount = Number(params.amount || 0);
|
|
4313
|
+
if (!(!Number.isFinite(amount) || amount <= 0)) {
|
|
4314
|
+
_context47.next = 5;
|
|
4315
|
+
break;
|
|
4316
|
+
}
|
|
4317
|
+
throw new Error('现金支付金额必须大于 0');
|
|
4318
|
+
case 5:
|
|
4319
|
+
_context47.next = 7;
|
|
4320
|
+
return this.getCashPaymentConfig();
|
|
4321
|
+
case 7:
|
|
4322
|
+
config = _context47.sent;
|
|
4323
|
+
paymentMethod = config.paymentMethod;
|
|
4324
|
+
if (paymentMethod) {
|
|
4325
|
+
_context47.next = 11;
|
|
4326
|
+
break;
|
|
4327
|
+
}
|
|
4328
|
+
throw new Error('未找到可用的 CASHMANUAL 支付方式');
|
|
4329
|
+
case 11:
|
|
4330
|
+
if (!(config.amountDue <= 0)) {
|
|
4331
|
+
_context47.next = 13;
|
|
4332
|
+
break;
|
|
4333
|
+
}
|
|
4334
|
+
throw new Error('当前订单没有待支付金额');
|
|
4335
|
+
case 13:
|
|
4336
|
+
roundingAmount = Number(params.roundingAmount || 0);
|
|
4337
|
+
effectivePaymentAmount = new Decimal(amount).minus(roundingAmount);
|
|
4338
|
+
if (!effectivePaymentAmount.gt(new Decimal(config.amountDue).plus(0.01))) {
|
|
4339
|
+
_context47.next = 17;
|
|
4340
|
+
break;
|
|
4341
|
+
}
|
|
4342
|
+
throw new Error('现金支付金额超过当前待支付金额');
|
|
4343
|
+
case 17:
|
|
4344
|
+
beforePayments = cloneDeep(this.store.order.getOrderPayments());
|
|
4345
|
+
beforePaymentStatus = (_this$store$order$get6 = this.store.order.getTempOrder()) === null || _this$store$order$get6 === void 0 ? void 0 : _this$store$order$get6.payment_status;
|
|
4346
|
+
uniquePaymentNumber = createUuidV4();
|
|
4347
|
+
paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
4348
|
+
actualPaidAmount = Number((_params$actualPaidAmo = params.actualPaidAmount) !== null && _params$actualPaidAmo !== void 0 ? _params$actualPaidAmo : amount);
|
|
4349
|
+
changeAmount = Number(params.changeAmount || 0);
|
|
4350
|
+
shopWalletPassId = (_this$otherParams26 = this.otherParams) === null || _this$otherParams26 === void 0 ? void 0 : _this$otherParams26.shop_wallet_pass_id;
|
|
4351
|
+
if (!(!Number.isFinite(actualPaidAmount) || actualPaidAmount + 0.01 < amount)) {
|
|
4352
|
+
_context47.next = 26;
|
|
4353
|
+
break;
|
|
4354
|
+
}
|
|
4355
|
+
throw new Error('顾客实收现金不能小于支付金额');
|
|
4356
|
+
case 26:
|
|
4357
|
+
(_this$window = this.window) === null || _this$window === void 0 || (_this$window = _this$window.interaction) === null || _this$window === void 0 || (_this$window = _this$window.utils) === null || _this$window === void 0 || (_this$window$postMess = _this$window.postMessageToApp) === null || _this$window$postMess === void 0 || _this$window$postMess.call(_this$window, {
|
|
4358
|
+
module: 'till',
|
|
4359
|
+
key: 'open_till',
|
|
4360
|
+
data: {
|
|
4361
|
+
type: 'cash'
|
|
4362
|
+
}
|
|
4363
|
+
});
|
|
4364
|
+
payments = this.store.order.addOrderPayment({
|
|
4365
|
+
amount: amount.toFixed(2),
|
|
4366
|
+
code: paymentMethod.code,
|
|
4367
|
+
custom_payment_id: paymentMethod.id,
|
|
4368
|
+
name: paymentMethod.name,
|
|
4369
|
+
custom_payment_type: paymentMethod.type,
|
|
4370
|
+
voucher_id: 0,
|
|
4371
|
+
rounding_amount: roundingAmount.toFixed(2),
|
|
4372
|
+
metadata: _objectSpread(_objectSpread({
|
|
4373
|
+
unique_payment_number: uniquePaymentNumber
|
|
4374
|
+
}, shopWalletPassId !== undefined && shopWalletPassId !== null ? {
|
|
4375
|
+
shop_wallet_pass_id: shopWalletPassId
|
|
4376
|
+
} : {}), {}, {
|
|
4377
|
+
actual_paid_amount: Number.isFinite(actualPaidAmount) ? actualPaidAmount : amount,
|
|
4378
|
+
change_given_amount: Number.isFinite(changeAmount) ? changeAmount : 0
|
|
4379
|
+
}),
|
|
4380
|
+
payment_time: paymentTimestamp,
|
|
4381
|
+
created_at: paymentTimestamp
|
|
4382
|
+
});
|
|
4383
|
+
payment = payments.find(function (item) {
|
|
4384
|
+
var _item$metadata2;
|
|
4385
|
+
return (item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.unique_payment_number) === uniquePaymentNumber;
|
|
4386
|
+
});
|
|
4387
|
+
_context47.prev = 29;
|
|
4388
|
+
_context47.next = 32;
|
|
4389
|
+
return this.syncPaymentsToOrder({
|
|
4390
|
+
payments: payments,
|
|
4391
|
+
submitWhenPaid: true,
|
|
4392
|
+
smallTicketDataFlag: 1,
|
|
4393
|
+
confirmPendingVoucherPayments: true
|
|
4394
|
+
});
|
|
4395
|
+
case 32:
|
|
4396
|
+
syncResult = _context47.sent;
|
|
4397
|
+
if (!this.store.payment) {
|
|
4398
|
+
_context47.next = 38;
|
|
4399
|
+
break;
|
|
4400
|
+
}
|
|
4401
|
+
committed = this.getCommittedWalletAssets();
|
|
4402
|
+
walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
4403
|
+
_context47.next = 38;
|
|
4404
|
+
return this.publishWalletAssetsState(walletState);
|
|
4405
|
+
case 38:
|
|
4406
|
+
return _context47.abrupt("return", {
|
|
4407
|
+
payment: payment || {},
|
|
4408
|
+
payments: this.store.order.getOrderPayments(),
|
|
4409
|
+
syncResult: syncResult,
|
|
4410
|
+
isOrderFullyPaid: syncResult.isOrderFullyPaid
|
|
4411
|
+
});
|
|
4412
|
+
case 41:
|
|
4413
|
+
_context47.prev = 41;
|
|
4414
|
+
_context47.t0 = _context47["catch"](29);
|
|
4415
|
+
this.store.order.setOrderPayments(beforePayments);
|
|
4416
|
+
restoredTempOrder = this.store.order.getTempOrder();
|
|
4417
|
+
if (restoredTempOrder && beforePaymentStatus !== undefined) {
|
|
4418
|
+
restoredTempOrder.payment_status = beforePaymentStatus;
|
|
4419
|
+
this.store.order.persistTempOrder();
|
|
4420
|
+
}
|
|
4421
|
+
_context47.next = 48;
|
|
4422
|
+
return this.store.order.recalculateSummary({
|
|
4423
|
+
createIfMissing: true
|
|
4424
|
+
});
|
|
4425
|
+
case 48:
|
|
4426
|
+
throw _context47.t0;
|
|
4427
|
+
case 49:
|
|
4428
|
+
case "end":
|
|
4429
|
+
return _context47.stop();
|
|
4430
|
+
}
|
|
4431
|
+
}, _callee47, this, [[29, 41]]);
|
|
4432
|
+
}));
|
|
4433
|
+
function payCash(_x38) {
|
|
4434
|
+
return _payCash.apply(this, arguments);
|
|
4435
|
+
}
|
|
4436
|
+
return payCash;
|
|
4437
|
+
}()
|
|
4438
|
+
/**
|
|
4439
|
+
* 提交一次已由支付设备确认成功的非 Wallet 支付。
|
|
4440
|
+
*
|
|
4441
|
+
* 与 addOrderPayment 不同,本入口不会启动后台 fire-and-forget 同步;调用方会等待
|
|
4442
|
+
* 本次 payment、当前 pending Wallet 以及订单提交共同完成。任何同步失败都会恢复
|
|
4443
|
+
* 调用前的 payments 与 payment_status,便于 UI 安全解锁并重试。
|
|
4444
|
+
*/
|
|
4445
|
+
)
|
|
4446
|
+
}, {
|
|
4447
|
+
key: "commitPaymentMethodPayment",
|
|
4448
|
+
value: (function () {
|
|
4449
|
+
var _commitPaymentMethodPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(params) {
|
|
4450
|
+
var _this$store$order$get7, _this$store$order15, _this$store$order$get8, _params$metadata, _params$originAmount;
|
|
4451
|
+
var amount, paymentMethods, findPaymentMethod, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, beforePayments, beforePaymentStatus, paymentTimestamp, metadata, serviceCharge, serviceFee, payments, payment, syncResult, committed, walletState, restoredTempOrder;
|
|
4452
|
+
return _regeneratorRuntime().wrap(function _callee48$(_context48) {
|
|
4453
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
4454
|
+
case 0:
|
|
4455
|
+
if (this.store.order) {
|
|
4456
|
+
_context48.next = 2;
|
|
4457
|
+
break;
|
|
4458
|
+
}
|
|
4459
|
+
throw new Error('order 模块未初始化');
|
|
4460
|
+
case 2:
|
|
4461
|
+
amount = Number(params.amount || 0);
|
|
4462
|
+
if (!(!Number.isFinite(amount) || amount <= 0)) {
|
|
4463
|
+
_context48.next = 5;
|
|
4464
|
+
break;
|
|
4465
|
+
}
|
|
4466
|
+
throw new Error('支付金额必须大于 0');
|
|
4467
|
+
case 5:
|
|
4468
|
+
paymentMethods = this.getPaymentMethods();
|
|
4469
|
+
findPaymentMethod = function findPaymentMethod() {
|
|
4470
|
+
var methodCode = String(params.paymentMethodCode || '').toUpperCase();
|
|
4471
|
+
return paymentMethods.find(function (method) {
|
|
4472
|
+
var idMatched = params.paymentMethodId !== undefined && String(method.id) === String(params.paymentMethodId);
|
|
4473
|
+
var codeMatched = Boolean(methodCode) && String(method.code || '').toUpperCase() === methodCode;
|
|
4474
|
+
return (idMatched || codeMatched) && method.enabled !== false && method.enable !== false;
|
|
4475
|
+
});
|
|
4476
|
+
};
|
|
4477
|
+
paymentMethod = findPaymentMethod();
|
|
4478
|
+
if (paymentMethod) {
|
|
4479
|
+
_context48.next = 13;
|
|
4480
|
+
break;
|
|
4481
|
+
}
|
|
4482
|
+
_context48.next = 11;
|
|
4483
|
+
return this.getPaymentMethodsAsync();
|
|
4484
|
+
case 11:
|
|
4485
|
+
paymentMethods = _context48.sent;
|
|
4486
|
+
paymentMethod = findPaymentMethod();
|
|
4487
|
+
case 13:
|
|
4488
|
+
if (paymentMethod) {
|
|
4489
|
+
_context48.next = 15;
|
|
4490
|
+
break;
|
|
4491
|
+
}
|
|
4492
|
+
throw new Error("\u672A\u627E\u5230\u53EF\u7528\u7684\u652F\u4ED8\u65B9\u5F0F\uFF1A".concat(params.paymentMethodCode || params.paymentMethodId || ''));
|
|
4493
|
+
case 15:
|
|
4494
|
+
amountSnapshot = (_this$store$order$get7 = (_this$store$order15 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get7 === void 0 ? void 0 : _this$store$order$get7.call(_this$store$order15);
|
|
4495
|
+
pendingWalletAmount = this.getPendingWalletPaymentAmount();
|
|
4496
|
+
amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
|
|
4497
|
+
if (!amountDue.lte(0)) {
|
|
4498
|
+
_context48.next = 20;
|
|
4499
|
+
break;
|
|
4500
|
+
}
|
|
4501
|
+
throw new Error('当前订单没有待支付金额');
|
|
4502
|
+
case 20:
|
|
4503
|
+
if (!new Decimal(amount).gt(amountDue.plus(0.01))) {
|
|
4504
|
+
_context48.next = 22;
|
|
4505
|
+
break;
|
|
4506
|
+
}
|
|
4507
|
+
throw new Error('支付金额超过当前待支付金额');
|
|
4508
|
+
case 22:
|
|
4509
|
+
beforePayments = cloneDeep(this.store.order.getOrderPayments());
|
|
4510
|
+
beforePaymentStatus = (_this$store$order$get8 = this.store.order.getTempOrder()) === null || _this$store$order$get8 === void 0 ? void 0 : _this$store$order$get8.payment_status;
|
|
4511
|
+
paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
4512
|
+
metadata = _objectSpread(_objectSpread({}, params.metadata || {}), {}, {
|
|
4513
|
+
unique_payment_number: ((_params$metadata = params.metadata) === null || _params$metadata === void 0 ? void 0 : _params$metadata.unique_payment_number) || createUuidV4()
|
|
4514
|
+
});
|
|
4515
|
+
serviceCharge = params.serviceCharge ? {
|
|
4516
|
+
amount: String(params.serviceCharge.amount || 0),
|
|
4517
|
+
percentage: String(params.serviceCharge.percentage || 0)
|
|
4518
|
+
} : undefined;
|
|
4519
|
+
serviceFee = serviceCharge ? new Decimal((_params$originAmount = params.originAmount) !== null && _params$originAmount !== void 0 ? _params$originAmount : amount).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
|
|
4520
|
+
payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, params.paymentData || {}), {}, {
|
|
4521
|
+
amount: amount.toFixed(2)
|
|
4522
|
+
}, params.originAmount !== undefined ? {
|
|
4523
|
+
origin_amount: Number(params.originAmount).toFixed(2)
|
|
4524
|
+
} : {}), {}, {
|
|
4525
|
+
code: paymentMethod.code,
|
|
4526
|
+
custom_payment_id: paymentMethod.id,
|
|
4527
|
+
name: paymentMethod.name,
|
|
4528
|
+
custom_payment_type: paymentMethod.type,
|
|
4529
|
+
voucher_id: 0
|
|
4530
|
+
}, serviceCharge ? {
|
|
4531
|
+
service_charge: serviceCharge
|
|
4532
|
+
} : {}), serviceFee !== undefined ? {
|
|
4533
|
+
service_fee: serviceFee
|
|
4534
|
+
} : {}), {}, {
|
|
4535
|
+
metadata: metadata,
|
|
4536
|
+
payment_time: paymentTimestamp,
|
|
4537
|
+
created_at: paymentTimestamp
|
|
4538
|
+
}));
|
|
4539
|
+
payment = payments.find(function (item) {
|
|
4540
|
+
var _item$metadata3;
|
|
4541
|
+
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;
|
|
4542
|
+
});
|
|
4543
|
+
_context48.prev = 30;
|
|
4544
|
+
_context48.next = 33;
|
|
4545
|
+
return this.syncPaymentsToOrder({
|
|
4546
|
+
payments: payments,
|
|
4547
|
+
submitWhenPaid: true,
|
|
4548
|
+
smallTicketDataFlag: 1,
|
|
4549
|
+
confirmPendingVoucherPayments: true
|
|
4550
|
+
});
|
|
4551
|
+
case 33:
|
|
4552
|
+
syncResult = _context48.sent;
|
|
4553
|
+
if (!this.store.payment) {
|
|
4554
|
+
_context48.next = 39;
|
|
4555
|
+
break;
|
|
4556
|
+
}
|
|
4557
|
+
committed = this.getCommittedWalletAssets();
|
|
4558
|
+
walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
4559
|
+
_context48.next = 39;
|
|
4560
|
+
return this.publishWalletAssetsState(walletState);
|
|
4561
|
+
case 39:
|
|
4562
|
+
return _context48.abrupt("return", {
|
|
4563
|
+
payment: payment || {},
|
|
4564
|
+
payments: this.store.order.getOrderPayments(),
|
|
4565
|
+
syncResult: syncResult,
|
|
4566
|
+
isOrderFullyPaid: syncResult.isOrderFullyPaid
|
|
4567
|
+
});
|
|
4568
|
+
case 42:
|
|
4569
|
+
_context48.prev = 42;
|
|
4570
|
+
_context48.t0 = _context48["catch"](30);
|
|
4571
|
+
this.store.order.setOrderPayments(beforePayments);
|
|
4572
|
+
restoredTempOrder = this.store.order.getTempOrder();
|
|
4573
|
+
if (restoredTempOrder && beforePaymentStatus !== undefined) {
|
|
4574
|
+
restoredTempOrder.payment_status = beforePaymentStatus;
|
|
4575
|
+
this.store.order.persistTempOrder();
|
|
4576
|
+
}
|
|
4577
|
+
_context48.next = 49;
|
|
4578
|
+
return this.store.order.recalculateSummary({
|
|
4579
|
+
createIfMissing: true
|
|
4580
|
+
});
|
|
4581
|
+
case 49:
|
|
4582
|
+
throw _context48.t0;
|
|
4583
|
+
case 50:
|
|
4584
|
+
case "end":
|
|
4585
|
+
return _context48.stop();
|
|
4586
|
+
}
|
|
4587
|
+
}, _callee48, this, [[30, 42]]);
|
|
4588
|
+
}));
|
|
4589
|
+
function commitPaymentMethodPayment(_x39) {
|
|
4590
|
+
return _commitPaymentMethodPayment.apply(this, arguments);
|
|
4591
|
+
}
|
|
4592
|
+
return commitPaymentMethodPayment;
|
|
4593
|
+
}()
|
|
4594
|
+
/**
|
|
4595
|
+
* 按当前店铺的现金舍入配置计算金额,供现金支付 UI 使用。
|
|
4596
|
+
*
|
|
4597
|
+
* 舍入开关取自 CASHMANUAL 支付方式;舍入规则取自
|
|
4598
|
+
* otherParams.order_rounding_setting,金额算法统一由 PaymentModule 维护。
|
|
4599
|
+
*/
|
|
4600
|
+
)
|
|
4601
|
+
}, {
|
|
4602
|
+
key: "roundAmount",
|
|
4603
|
+
value: (function () {
|
|
4604
|
+
var _roundAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(params) {
|
|
4605
|
+
var _cashManualPayment$me, _this$otherParams$ord2, _this$otherParams$ord3;
|
|
4606
|
+
var amount, cashManualPayment;
|
|
4607
|
+
return _regeneratorRuntime().wrap(function _callee49$(_context49) {
|
|
4608
|
+
while (1) switch (_context49.prev = _context49.next) {
|
|
4609
|
+
case 0:
|
|
4610
|
+
amount = params.amount;
|
|
4611
|
+
cashManualPayment = this.paymentMethodsCache.find(function (paymentMethod) {
|
|
4612
|
+
return paymentMethod.code === 'CASHMANUAL';
|
|
4613
|
+
});
|
|
4614
|
+
if (cashManualPayment !== null && cashManualPayment !== void 0 && (_cashManualPayment$me = cashManualPayment.metadata) !== null && _cashManualPayment$me !== void 0 && _cashManualPayment$me.order_rounding_switch) {
|
|
4615
|
+
_context49.next = 4;
|
|
4616
|
+
break;
|
|
4617
|
+
}
|
|
4618
|
+
return _context49.abrupt("return", {
|
|
4619
|
+
originalAmount: amount.toString(),
|
|
4620
|
+
roundedAmount: amount.toString(),
|
|
4621
|
+
roundingDifference: '0.00'
|
|
4622
|
+
});
|
|
4623
|
+
case 4:
|
|
4624
|
+
if (this.payment) {
|
|
4625
|
+
_context49.next = 6;
|
|
4626
|
+
break;
|
|
4627
|
+
}
|
|
4628
|
+
throw new Error('payment 模块未初始化');
|
|
4629
|
+
case 6:
|
|
4630
|
+
return _context49.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));
|
|
4631
|
+
case 7:
|
|
4632
|
+
case "end":
|
|
4633
|
+
return _context49.stop();
|
|
4634
|
+
}
|
|
4635
|
+
}, _callee49, this);
|
|
4636
|
+
}));
|
|
4637
|
+
function roundAmount(_x40) {
|
|
4638
|
+
return _roundAmount.apply(this, arguments);
|
|
4639
|
+
}
|
|
4640
|
+
return roundAmount;
|
|
4641
|
+
}()
|
|
3323
4642
|
/**
|
|
3324
4643
|
* 发送支付链接。
|
|
3325
4644
|
*
|
|
3326
4645
|
* 如果没有 orderIds 或显式 submitBeforeSend,会先提交当前本地订单到云端;
|
|
3327
4646
|
* 只有成功拿到远端 order_id 后才调用 OrderModule 发送邮件。
|
|
3328
4647
|
*/
|
|
4648
|
+
)
|
|
3329
4649
|
}, {
|
|
3330
4650
|
key: "sendCustomerPayLink",
|
|
3331
4651
|
value: (function () {
|
|
3332
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3333
|
-
var orderIds,
|
|
3334
|
-
return _regeneratorRuntime().wrap(function
|
|
3335
|
-
while (1) switch (
|
|
4652
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(params) {
|
|
4653
|
+
var orderIds, _ref34, _ref35, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
|
|
4654
|
+
return _regeneratorRuntime().wrap(function _callee50$(_context50) {
|
|
4655
|
+
while (1) switch (_context50.prev = _context50.next) {
|
|
3336
4656
|
case 0:
|
|
3337
4657
|
if (this.store.order) {
|
|
3338
|
-
|
|
4658
|
+
_context50.next = 2;
|
|
3339
4659
|
break;
|
|
3340
4660
|
}
|
|
3341
4661
|
throw new Error('order 模块未初始化');
|
|
3342
4662
|
case 2:
|
|
3343
4663
|
orderIds = params.order_ids || params.orderIds || [];
|
|
3344
4664
|
if (!(!orderIds.length || params.submitBeforeSend)) {
|
|
3345
|
-
|
|
4665
|
+
_context50.next = 11;
|
|
3346
4666
|
break;
|
|
3347
4667
|
}
|
|
3348
|
-
|
|
4668
|
+
_context50.next = 6;
|
|
3349
4669
|
return this.submitSalesOrder({
|
|
3350
4670
|
smallTicketDataFlag: 1
|
|
3351
4671
|
});
|
|
3352
4672
|
case 6:
|
|
3353
|
-
submitResult =
|
|
3354
|
-
orderId = (
|
|
4673
|
+
submitResult = _context50.sent;
|
|
4674
|
+
orderId = (_ref34 = (_ref35 = (_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 && _ref35 !== void 0 ? _ref35 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref34 !== void 0 ? _ref34 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
|
|
3355
4675
|
if (orderId) {
|
|
3356
|
-
|
|
4676
|
+
_context50.next = 10;
|
|
3357
4677
|
break;
|
|
3358
4678
|
}
|
|
3359
4679
|
throw new Error('本地订单提交云端失败,无法发送支付链接');
|
|
3360
4680
|
case 10:
|
|
3361
4681
|
orderIds = [orderId];
|
|
3362
4682
|
case 11:
|
|
3363
|
-
return
|
|
4683
|
+
return _context50.abrupt("return", this.store.order.sendCustomerPayLink({
|
|
3364
4684
|
emails: params.emails,
|
|
3365
4685
|
notify_action: params.notify_action,
|
|
3366
4686
|
order_ids: orderIds
|
|
3367
4687
|
}));
|
|
3368
4688
|
case 12:
|
|
3369
4689
|
case "end":
|
|
3370
|
-
return
|
|
4690
|
+
return _context50.stop();
|
|
3371
4691
|
}
|
|
3372
|
-
},
|
|
4692
|
+
}, _callee50, this);
|
|
3373
4693
|
}));
|
|
3374
|
-
function sendCustomerPayLink(
|
|
4694
|
+
function sendCustomerPayLink(_x41) {
|
|
3375
4695
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
3376
4696
|
}
|
|
3377
4697
|
return sendCustomerPayLink;
|
|
@@ -3384,27 +4704,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3384
4704
|
}, {
|
|
3385
4705
|
key: "calculateProductBookingPrice",
|
|
3386
4706
|
value: function () {
|
|
3387
|
-
var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4707
|
+
var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
|
|
3388
4708
|
var _params$customer_id;
|
|
3389
4709
|
var quotation, customerId, authoritativeProduct, product;
|
|
3390
|
-
return _regeneratorRuntime().wrap(function
|
|
3391
|
-
while (1) switch (
|
|
4710
|
+
return _regeneratorRuntime().wrap(function _callee51$(_context51) {
|
|
4711
|
+
while (1) switch (_context51.prev = _context51.next) {
|
|
3392
4712
|
case 0:
|
|
3393
4713
|
quotation = this.store.quotation;
|
|
3394
4714
|
customerId = (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : this.getCurrentOrderCustomerId();
|
|
3395
|
-
|
|
4715
|
+
_context51.next = 4;
|
|
3396
4716
|
return this.loadProductForPriceQuery(params, customerId);
|
|
3397
4717
|
case 4:
|
|
3398
|
-
authoritativeProduct =
|
|
4718
|
+
authoritativeProduct = _context51.sent;
|
|
3399
4719
|
product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
|
|
3400
|
-
|
|
4720
|
+
_context51.next = 8;
|
|
3401
4721
|
return this.loadQuotationForPriceQuery({
|
|
3402
4722
|
quotation: quotation,
|
|
3403
4723
|
customer_id: customerId,
|
|
3404
4724
|
channel: params.channel
|
|
3405
4725
|
});
|
|
3406
4726
|
case 8:
|
|
3407
|
-
return
|
|
4727
|
+
return _context51.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
|
|
3408
4728
|
product: product,
|
|
3409
4729
|
fallback_price: authoritativeProduct ? undefined : params.fallback_price,
|
|
3410
4730
|
customer_id: customerId,
|
|
@@ -3412,11 +4732,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3412
4732
|
})));
|
|
3413
4733
|
case 9:
|
|
3414
4734
|
case "end":
|
|
3415
|
-
return
|
|
4735
|
+
return _context51.stop();
|
|
3416
4736
|
}
|
|
3417
|
-
},
|
|
4737
|
+
}, _callee51, this);
|
|
3418
4738
|
}));
|
|
3419
|
-
function calculateProductBookingPrice(
|
|
4739
|
+
function calculateProductBookingPrice(_x42) {
|
|
3420
4740
|
return _calculateProductBookingPrice.apply(this, arguments);
|
|
3421
4741
|
}
|
|
3422
4742
|
return calculateProductBookingPrice;
|
|
@@ -3424,7 +4744,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3424
4744
|
}, {
|
|
3425
4745
|
key: "getQuotationCustomerScopeInfo",
|
|
3426
4746
|
value: function getQuotationCustomerScopeInfo() {
|
|
3427
|
-
var
|
|
4747
|
+
var _this15 = this;
|
|
3428
4748
|
var quotation = this.store.quotation;
|
|
3429
4749
|
if (quotation && typeof quotation.getQuotationCustomerScopeInfo === 'function') {
|
|
3430
4750
|
return quotation.getQuotationCustomerScopeInfo();
|
|
@@ -3436,7 +4756,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3436
4756
|
}).map(function (item) {
|
|
3437
4757
|
var localSeen = new Set();
|
|
3438
4758
|
var customers = item.customer.filter(function (customer) {
|
|
3439
|
-
var customerId =
|
|
4759
|
+
var customerId = _this15.normalizePriceContextCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
|
|
3440
4760
|
if (!customerId || localSeen.has(customerId)) return false;
|
|
3441
4761
|
localSeen.add(customerId);
|
|
3442
4762
|
if (!customerById.has(customerId)) customerById.set(customerId, customer);
|
|
@@ -3486,32 +4806,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3486
4806
|
}, {
|
|
3487
4807
|
key: "calculateProductBookingPrices",
|
|
3488
4808
|
value: function () {
|
|
3489
|
-
var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4809
|
+
var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(paramsList) {
|
|
3490
4810
|
var _paramsList$0$custome,
|
|
3491
4811
|
_paramsList$,
|
|
3492
|
-
|
|
4812
|
+
_this16 = this,
|
|
3493
4813
|
_paramsList$2;
|
|
3494
4814
|
var quotation, customerId, productMapsByGroup, groups;
|
|
3495
|
-
return _regeneratorRuntime().wrap(function
|
|
3496
|
-
while (1) switch (
|
|
4815
|
+
return _regeneratorRuntime().wrap(function _callee53$(_context53) {
|
|
4816
|
+
while (1) switch (_context53.prev = _context53.next) {
|
|
3497
4817
|
case 0:
|
|
3498
4818
|
if (paramsList.length) {
|
|
3499
|
-
|
|
4819
|
+
_context53.next = 2;
|
|
3500
4820
|
break;
|
|
3501
4821
|
}
|
|
3502
|
-
return
|
|
4822
|
+
return _context53.abrupt("return", []);
|
|
3503
4823
|
case 2:
|
|
3504
4824
|
quotation = this.store.quotation;
|
|
3505
4825
|
customerId = (_paramsList$0$custome = (_paramsList$ = paramsList[0]) === null || _paramsList$ === void 0 ? void 0 : _paramsList$.customer_id) !== null && _paramsList$0$custome !== void 0 ? _paramsList$0$custome : this.getCurrentOrderCustomerId();
|
|
3506
4826
|
productMapsByGroup = new Map();
|
|
3507
4827
|
groups = new Map();
|
|
3508
4828
|
paramsList.forEach(function (params) {
|
|
3509
|
-
var
|
|
4829
|
+
var _this16$otherParams;
|
|
3510
4830
|
var product = params.product || {};
|
|
3511
|
-
var productId =
|
|
4831
|
+
var productId = _this16.getPriceQueryProductId(product);
|
|
3512
4832
|
if (productId === null) return;
|
|
3513
|
-
var schedule =
|
|
3514
|
-
var channel = params.channel || ((
|
|
4833
|
+
var schedule = _this16.getPriceQuerySchedule(params);
|
|
4834
|
+
var channel = params.channel || ((_this16$otherParams = _this16.otherParams) === null || _this16$otherParams === void 0 ? void 0 : _this16$otherParams.channel);
|
|
3515
4835
|
var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || ''].join('|');
|
|
3516
4836
|
var group = groups.get(groupKey) || {
|
|
3517
4837
|
ids: new Set(),
|
|
@@ -3521,51 +4841,51 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3521
4841
|
group.ids.add(productId);
|
|
3522
4842
|
groups.set(groupKey, group);
|
|
3523
4843
|
});
|
|
3524
|
-
|
|
4844
|
+
_context53.next = 9;
|
|
3525
4845
|
return Promise.all(Array.from(groups.entries()).map( /*#__PURE__*/function () {
|
|
3526
|
-
var
|
|
3527
|
-
var
|
|
3528
|
-
return _regeneratorRuntime().wrap(function
|
|
3529
|
-
while (1) switch (
|
|
4846
|
+
var _ref37 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(_ref36) {
|
|
4847
|
+
var _ref38, groupKey, group, productsById;
|
|
4848
|
+
return _regeneratorRuntime().wrap(function _callee52$(_context52) {
|
|
4849
|
+
while (1) switch (_context52.prev = _context52.next) {
|
|
3530
4850
|
case 0:
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
return
|
|
4851
|
+
_ref38 = _slicedToArray(_ref36, 2), groupKey = _ref38[0], group = _ref38[1];
|
|
4852
|
+
_context52.next = 3;
|
|
4853
|
+
return _this16.loadProductsForPriceQuery({
|
|
3534
4854
|
ids: Array.from(group.ids),
|
|
3535
4855
|
schedule: group.schedule,
|
|
3536
4856
|
customerId: customerId,
|
|
3537
4857
|
channel: group.channel
|
|
3538
4858
|
});
|
|
3539
4859
|
case 3:
|
|
3540
|
-
productsById =
|
|
4860
|
+
productsById = _context52.sent;
|
|
3541
4861
|
productMapsByGroup.set(groupKey, productsById);
|
|
3542
4862
|
case 5:
|
|
3543
4863
|
case "end":
|
|
3544
|
-
return
|
|
4864
|
+
return _context52.stop();
|
|
3545
4865
|
}
|
|
3546
|
-
},
|
|
4866
|
+
}, _callee52);
|
|
3547
4867
|
}));
|
|
3548
|
-
return function (
|
|
3549
|
-
return
|
|
4868
|
+
return function (_x44) {
|
|
4869
|
+
return _ref37.apply(this, arguments);
|
|
3550
4870
|
};
|
|
3551
4871
|
}()));
|
|
3552
4872
|
case 9:
|
|
3553
|
-
|
|
4873
|
+
_context53.next = 11;
|
|
3554
4874
|
return this.loadQuotationForPriceQuery({
|
|
3555
4875
|
quotation: quotation,
|
|
3556
4876
|
customer_id: customerId,
|
|
3557
4877
|
channel: (_paramsList$2 = paramsList[0]) === null || _paramsList$2 === void 0 ? void 0 : _paramsList$2.channel
|
|
3558
4878
|
});
|
|
3559
4879
|
case 11:
|
|
3560
|
-
return
|
|
3561
|
-
var
|
|
4880
|
+
return _context53.abrupt("return", paramsList.map(function (params) {
|
|
4881
|
+
var _this16$otherParams2, _productMapsByGroup$g;
|
|
3562
4882
|
var productInput = params.product || {};
|
|
3563
|
-
var productId =
|
|
3564
|
-
var schedule =
|
|
3565
|
-
var channel = params.channel || ((
|
|
4883
|
+
var productId = _this16.getPriceQueryProductId(productInput);
|
|
4884
|
+
var schedule = _this16.getPriceQuerySchedule(params);
|
|
4885
|
+
var channel = params.channel || ((_this16$otherParams2 = _this16.otherParams) === null || _this16$otherParams2 === void 0 ? void 0 : _this16$otherParams2.channel);
|
|
3566
4886
|
var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || ''].join('|');
|
|
3567
4887
|
var authoritativeProduct = productId === null ? null : ((_productMapsByGroup$g = productMapsByGroup.get(groupKey)) === null || _productMapsByGroup$g === void 0 ? void 0 : _productMapsByGroup$g.get(productId)) || null;
|
|
3568
|
-
var product =
|
|
4888
|
+
var product = _this16.mergeProductForPriceQuery(productInput, authoritativeProduct);
|
|
3569
4889
|
return calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
|
|
3570
4890
|
product: product,
|
|
3571
4891
|
fallback_price: authoritativeProduct ? undefined : params.fallback_price,
|
|
@@ -3575,11 +4895,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3575
4895
|
}));
|
|
3576
4896
|
case 12:
|
|
3577
4897
|
case "end":
|
|
3578
|
-
return
|
|
4898
|
+
return _context53.stop();
|
|
3579
4899
|
}
|
|
3580
|
-
},
|
|
4900
|
+
}, _callee53, this);
|
|
3581
4901
|
}));
|
|
3582
|
-
function calculateProductBookingPrices(
|
|
4902
|
+
function calculateProductBookingPrices(_x43) {
|
|
3583
4903
|
return _calculateProductBookingPrices.apply(this, arguments);
|
|
3584
4904
|
}
|
|
3585
4905
|
return calculateProductBookingPrices;
|
|
@@ -3587,34 +4907,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3587
4907
|
}, {
|
|
3588
4908
|
key: "addProductToOrder",
|
|
3589
4909
|
value: function () {
|
|
3590
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4910
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(product, booking) {
|
|
3591
4911
|
var products;
|
|
3592
|
-
return _regeneratorRuntime().wrap(function
|
|
3593
|
-
while (1) switch (
|
|
4912
|
+
return _regeneratorRuntime().wrap(function _callee54$(_context54) {
|
|
4913
|
+
while (1) switch (_context54.prev = _context54.next) {
|
|
3594
4914
|
case 0:
|
|
3595
|
-
|
|
4915
|
+
_context54.prev = 0;
|
|
3596
4916
|
if (this.store.order) {
|
|
3597
|
-
|
|
4917
|
+
_context54.next = 3;
|
|
3598
4918
|
break;
|
|
3599
4919
|
}
|
|
3600
4920
|
throw new Error('order 模块未初始化');
|
|
3601
4921
|
case 3:
|
|
3602
|
-
|
|
4922
|
+
_context54.next = 5;
|
|
3603
4923
|
return this.store.order.addProductToOrder(product, booking);
|
|
3604
4924
|
case 5:
|
|
3605
|
-
products =
|
|
3606
|
-
return
|
|
4925
|
+
products = _context54.sent;
|
|
4926
|
+
return _context54.abrupt("return", products);
|
|
3607
4927
|
case 9:
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
throw
|
|
4928
|
+
_context54.prev = 9;
|
|
4929
|
+
_context54.t0 = _context54["catch"](0);
|
|
4930
|
+
throw _context54.t0;
|
|
3611
4931
|
case 12:
|
|
3612
4932
|
case "end":
|
|
3613
|
-
return
|
|
4933
|
+
return _context54.stop();
|
|
3614
4934
|
}
|
|
3615
|
-
},
|
|
4935
|
+
}, _callee54, this, [[0, 9]]);
|
|
3616
4936
|
}));
|
|
3617
|
-
function addProductToOrder(
|
|
4937
|
+
function addProductToOrder(_x45, _x46) {
|
|
3618
4938
|
return _addProductToOrder.apply(this, arguments);
|
|
3619
4939
|
}
|
|
3620
4940
|
return addProductToOrder;
|
|
@@ -3622,34 +4942,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3622
4942
|
}, {
|
|
3623
4943
|
key: "updateOrderProduct",
|
|
3624
4944
|
value: function () {
|
|
3625
|
-
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4945
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(params) {
|
|
3626
4946
|
var products;
|
|
3627
|
-
return _regeneratorRuntime().wrap(function
|
|
3628
|
-
while (1) switch (
|
|
4947
|
+
return _regeneratorRuntime().wrap(function _callee55$(_context55) {
|
|
4948
|
+
while (1) switch (_context55.prev = _context55.next) {
|
|
3629
4949
|
case 0:
|
|
3630
|
-
|
|
4950
|
+
_context55.prev = 0;
|
|
3631
4951
|
if (this.store.order) {
|
|
3632
|
-
|
|
4952
|
+
_context55.next = 3;
|
|
3633
4953
|
break;
|
|
3634
4954
|
}
|
|
3635
4955
|
throw new Error('order 模块未初始化');
|
|
3636
4956
|
case 3:
|
|
3637
|
-
|
|
4957
|
+
_context55.next = 5;
|
|
3638
4958
|
return this.store.order.updateOrderProduct(params);
|
|
3639
4959
|
case 5:
|
|
3640
|
-
products =
|
|
3641
|
-
return
|
|
4960
|
+
products = _context55.sent;
|
|
4961
|
+
return _context55.abrupt("return", products);
|
|
3642
4962
|
case 9:
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
throw
|
|
4963
|
+
_context55.prev = 9;
|
|
4964
|
+
_context55.t0 = _context55["catch"](0);
|
|
4965
|
+
throw _context55.t0;
|
|
3646
4966
|
case 12:
|
|
3647
4967
|
case "end":
|
|
3648
|
-
return
|
|
4968
|
+
return _context55.stop();
|
|
3649
4969
|
}
|
|
3650
|
-
},
|
|
4970
|
+
}, _callee55, this, [[0, 9]]);
|
|
3651
4971
|
}));
|
|
3652
|
-
function updateOrderProduct(
|
|
4972
|
+
function updateOrderProduct(_x47) {
|
|
3653
4973
|
return _updateOrderProduct.apply(this, arguments);
|
|
3654
4974
|
}
|
|
3655
4975
|
return updateOrderProduct;
|
|
@@ -3657,34 +4977,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3657
4977
|
}, {
|
|
3658
4978
|
key: "updateOrderProducts",
|
|
3659
4979
|
value: function () {
|
|
3660
|
-
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4980
|
+
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(paramsList) {
|
|
3661
4981
|
var products;
|
|
3662
|
-
return _regeneratorRuntime().wrap(function
|
|
3663
|
-
while (1) switch (
|
|
4982
|
+
return _regeneratorRuntime().wrap(function _callee56$(_context56) {
|
|
4983
|
+
while (1) switch (_context56.prev = _context56.next) {
|
|
3664
4984
|
case 0:
|
|
3665
|
-
|
|
4985
|
+
_context56.prev = 0;
|
|
3666
4986
|
if (this.store.order) {
|
|
3667
|
-
|
|
4987
|
+
_context56.next = 3;
|
|
3668
4988
|
break;
|
|
3669
4989
|
}
|
|
3670
4990
|
throw new Error('order 模块未初始化');
|
|
3671
4991
|
case 3:
|
|
3672
|
-
|
|
4992
|
+
_context56.next = 5;
|
|
3673
4993
|
return this.store.order.updateOrderProducts(paramsList);
|
|
3674
4994
|
case 5:
|
|
3675
|
-
products =
|
|
3676
|
-
return
|
|
4995
|
+
products = _context56.sent;
|
|
4996
|
+
return _context56.abrupt("return", products);
|
|
3677
4997
|
case 9:
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
throw
|
|
4998
|
+
_context56.prev = 9;
|
|
4999
|
+
_context56.t0 = _context56["catch"](0);
|
|
5000
|
+
throw _context56.t0;
|
|
3681
5001
|
case 12:
|
|
3682
5002
|
case "end":
|
|
3683
|
-
return
|
|
5003
|
+
return _context56.stop();
|
|
3684
5004
|
}
|
|
3685
|
-
},
|
|
5005
|
+
}, _callee56, this, [[0, 9]]);
|
|
3686
5006
|
}));
|
|
3687
|
-
function updateOrderProducts(
|
|
5007
|
+
function updateOrderProducts(_x48) {
|
|
3688
5008
|
return _updateOrderProducts.apply(this, arguments);
|
|
3689
5009
|
}
|
|
3690
5010
|
return updateOrderProducts;
|
|
@@ -3692,34 +5012,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3692
5012
|
}, {
|
|
3693
5013
|
key: "updateOrderProductQuantity",
|
|
3694
5014
|
value: function () {
|
|
3695
|
-
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5015
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(params) {
|
|
3696
5016
|
var products;
|
|
3697
|
-
return _regeneratorRuntime().wrap(function
|
|
3698
|
-
while (1) switch (
|
|
5017
|
+
return _regeneratorRuntime().wrap(function _callee57$(_context57) {
|
|
5018
|
+
while (1) switch (_context57.prev = _context57.next) {
|
|
3699
5019
|
case 0:
|
|
3700
|
-
|
|
5020
|
+
_context57.prev = 0;
|
|
3701
5021
|
if (this.store.order) {
|
|
3702
|
-
|
|
5022
|
+
_context57.next = 3;
|
|
3703
5023
|
break;
|
|
3704
5024
|
}
|
|
3705
5025
|
throw new Error('order 模块未初始化');
|
|
3706
5026
|
case 3:
|
|
3707
|
-
|
|
5027
|
+
_context57.next = 5;
|
|
3708
5028
|
return this.store.order.updateOrderProductQuantity(params);
|
|
3709
5029
|
case 5:
|
|
3710
|
-
products =
|
|
3711
|
-
return
|
|
5030
|
+
products = _context57.sent;
|
|
5031
|
+
return _context57.abrupt("return", products);
|
|
3712
5032
|
case 9:
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
throw
|
|
5033
|
+
_context57.prev = 9;
|
|
5034
|
+
_context57.t0 = _context57["catch"](0);
|
|
5035
|
+
throw _context57.t0;
|
|
3716
5036
|
case 12:
|
|
3717
5037
|
case "end":
|
|
3718
|
-
return
|
|
5038
|
+
return _context57.stop();
|
|
3719
5039
|
}
|
|
3720
|
-
},
|
|
5040
|
+
}, _callee57, this, [[0, 9]]);
|
|
3721
5041
|
}));
|
|
3722
|
-
function updateOrderProductQuantity(
|
|
5042
|
+
function updateOrderProductQuantity(_x49) {
|
|
3723
5043
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
3724
5044
|
}
|
|
3725
5045
|
return updateOrderProductQuantity;
|
|
@@ -3742,12 +5062,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3742
5062
|
}, {
|
|
3743
5063
|
key: "setOrderProductLineNote",
|
|
3744
5064
|
value: (function () {
|
|
3745
|
-
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5065
|
+
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(identity, note) {
|
|
3746
5066
|
var params, products;
|
|
3747
|
-
return _regeneratorRuntime().wrap(function
|
|
3748
|
-
while (1) switch (
|
|
5067
|
+
return _regeneratorRuntime().wrap(function _callee58$(_context58) {
|
|
5068
|
+
while (1) switch (_context58.prev = _context58.next) {
|
|
3749
5069
|
case 0:
|
|
3750
|
-
|
|
5070
|
+
_context58.prev = 0;
|
|
3751
5071
|
params = {
|
|
3752
5072
|
product_id: identity.product_id,
|
|
3753
5073
|
product_variant_id: identity.product_variant_id,
|
|
@@ -3762,22 +5082,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3762
5082
|
params.product_sku = identity.product_sku;
|
|
3763
5083
|
}
|
|
3764
5084
|
if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
|
|
3765
|
-
|
|
5085
|
+
_context58.next = 7;
|
|
3766
5086
|
return this.updateOrderProduct(params);
|
|
3767
5087
|
case 7:
|
|
3768
|
-
products =
|
|
3769
|
-
return
|
|
5088
|
+
products = _context58.sent;
|
|
5089
|
+
return _context58.abrupt("return", products);
|
|
3770
5090
|
case 11:
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
throw
|
|
5091
|
+
_context58.prev = 11;
|
|
5092
|
+
_context58.t0 = _context58["catch"](0);
|
|
5093
|
+
throw _context58.t0;
|
|
3774
5094
|
case 14:
|
|
3775
5095
|
case "end":
|
|
3776
|
-
return
|
|
5096
|
+
return _context58.stop();
|
|
3777
5097
|
}
|
|
3778
|
-
},
|
|
5098
|
+
}, _callee58, this, [[0, 11]]);
|
|
3779
5099
|
}));
|
|
3780
|
-
function setOrderProductLineNote(
|
|
5100
|
+
function setOrderProductLineNote(_x50, _x51) {
|
|
3781
5101
|
return _setOrderProductLineNote.apply(this, arguments);
|
|
3782
5102
|
}
|
|
3783
5103
|
return setOrderProductLineNote;
|
|
@@ -3792,32 +5112,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3792
5112
|
}, {
|
|
3793
5113
|
key: "removeProductsFromOrder",
|
|
3794
5114
|
value: (function () {
|
|
3795
|
-
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3796
|
-
return _regeneratorRuntime().wrap(function
|
|
3797
|
-
while (1) switch (
|
|
5115
|
+
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(identities) {
|
|
5116
|
+
return _regeneratorRuntime().wrap(function _callee59$(_context59) {
|
|
5117
|
+
while (1) switch (_context59.prev = _context59.next) {
|
|
3798
5118
|
case 0:
|
|
3799
|
-
|
|
5119
|
+
_context59.prev = 0;
|
|
3800
5120
|
if (this.store.order) {
|
|
3801
|
-
|
|
5121
|
+
_context59.next = 3;
|
|
3802
5122
|
break;
|
|
3803
5123
|
}
|
|
3804
5124
|
throw new Error('order 模块未初始化');
|
|
3805
5125
|
case 3:
|
|
3806
|
-
|
|
5126
|
+
_context59.next = 5;
|
|
3807
5127
|
return this.store.order.removeProductsFromOrder(identities);
|
|
3808
5128
|
case 5:
|
|
3809
|
-
return
|
|
5129
|
+
return _context59.abrupt("return", _context59.sent);
|
|
3810
5130
|
case 8:
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
throw
|
|
5131
|
+
_context59.prev = 8;
|
|
5132
|
+
_context59.t0 = _context59["catch"](0);
|
|
5133
|
+
throw _context59.t0;
|
|
3814
5134
|
case 11:
|
|
3815
5135
|
case "end":
|
|
3816
|
-
return
|
|
5136
|
+
return _context59.stop();
|
|
3817
5137
|
}
|
|
3818
|
-
},
|
|
5138
|
+
}, _callee59, this, [[0, 8]]);
|
|
3819
5139
|
}));
|
|
3820
|
-
function removeProductsFromOrder(
|
|
5140
|
+
function removeProductsFromOrder(_x52) {
|
|
3821
5141
|
return _removeProductsFromOrder.apply(this, arguments);
|
|
3822
5142
|
}
|
|
3823
5143
|
return removeProductsFromOrder;
|
|
@@ -3825,18 +5145,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3825
5145
|
}, {
|
|
3826
5146
|
key: "removeProductFromOrder",
|
|
3827
5147
|
value: function () {
|
|
3828
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3829
|
-
return _regeneratorRuntime().wrap(function
|
|
3830
|
-
while (1) switch (
|
|
5148
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(identity) {
|
|
5149
|
+
return _regeneratorRuntime().wrap(function _callee60$(_context60) {
|
|
5150
|
+
while (1) switch (_context60.prev = _context60.next) {
|
|
3831
5151
|
case 0:
|
|
3832
|
-
return
|
|
5152
|
+
return _context60.abrupt("return", this.removeProductsFromOrder([identity]));
|
|
3833
5153
|
case 1:
|
|
3834
5154
|
case "end":
|
|
3835
|
-
return
|
|
5155
|
+
return _context60.stop();
|
|
3836
5156
|
}
|
|
3837
|
-
},
|
|
5157
|
+
}, _callee60, this);
|
|
3838
5158
|
}));
|
|
3839
|
-
function removeProductFromOrder(
|
|
5159
|
+
function removeProductFromOrder(_x53) {
|
|
3840
5160
|
return _removeProductFromOrder.apply(this, arguments);
|
|
3841
5161
|
}
|
|
3842
5162
|
return removeProductFromOrder;
|
|
@@ -3886,23 +5206,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3886
5206
|
}, {
|
|
3887
5207
|
key: "applyPromotion",
|
|
3888
5208
|
value: (function () {
|
|
3889
|
-
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3890
|
-
return _regeneratorRuntime().wrap(function
|
|
3891
|
-
while (1) switch (
|
|
5209
|
+
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61() {
|
|
5210
|
+
return _regeneratorRuntime().wrap(function _callee61$(_context61) {
|
|
5211
|
+
while (1) switch (_context61.prev = _context61.next) {
|
|
3892
5212
|
case 0:
|
|
3893
5213
|
if (this.store.order) {
|
|
3894
|
-
|
|
5214
|
+
_context61.next = 2;
|
|
3895
5215
|
break;
|
|
3896
5216
|
}
|
|
3897
5217
|
throw new Error('order 模块未初始化');
|
|
3898
5218
|
case 2:
|
|
3899
|
-
|
|
5219
|
+
_context61.next = 4;
|
|
3900
5220
|
return this.store.order.applyPromotion();
|
|
3901
5221
|
case 4:
|
|
3902
5222
|
case "end":
|
|
3903
|
-
return
|
|
5223
|
+
return _context61.stop();
|
|
3904
5224
|
}
|
|
3905
|
-
},
|
|
5225
|
+
}, _callee61, this);
|
|
3906
5226
|
}));
|
|
3907
5227
|
function applyPromotion() {
|
|
3908
5228
|
return _applyPromotion.apply(this, arguments);
|
|
@@ -3912,16 +5232,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3912
5232
|
}, {
|
|
3913
5233
|
key: "getUnfulfilledPromotions",
|
|
3914
5234
|
value: function getUnfulfilledPromotions() {
|
|
3915
|
-
var _this$store$
|
|
3916
|
-
return ((_this$store$
|
|
5235
|
+
var _this$store$order16;
|
|
5236
|
+
return ((_this$store$order16 = this.store.order) === null || _this$store$order16 === void 0 ? void 0 : _this$store$order16.getUnfulfilledPromotions()) || [];
|
|
3917
5237
|
}
|
|
3918
5238
|
|
|
3919
5239
|
/** 最近一次促销计算输出的赠品操作 diff。 */
|
|
3920
5240
|
}, {
|
|
3921
5241
|
key: "getLastGiftActions",
|
|
3922
5242
|
value: function getLastGiftActions() {
|
|
3923
|
-
var _this$store$
|
|
3924
|
-
return ((_this$store$
|
|
5243
|
+
var _this$store$order17;
|
|
5244
|
+
return ((_this$store$order17 = this.store.order) === null || _this$store$order17 === void 0 ? void 0 : _this$store$order17.getLastGiftActions()) || null;
|
|
3925
5245
|
}
|
|
3926
5246
|
|
|
3927
5247
|
// 获取商品列表
|
|
@@ -3929,18 +5249,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3929
5249
|
}, {
|
|
3930
5250
|
key: "getProductList",
|
|
3931
5251
|
value: function () {
|
|
3932
|
-
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3933
|
-
var _this$
|
|
5252
|
+
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62() {
|
|
5253
|
+
var _this$otherParams27;
|
|
3934
5254
|
var menu_list_ids, _this$store$products, res;
|
|
3935
|
-
return _regeneratorRuntime().wrap(function
|
|
3936
|
-
while (1) switch (
|
|
5255
|
+
return _regeneratorRuntime().wrap(function _callee62$(_context62) {
|
|
5256
|
+
while (1) switch (_context62.prev = _context62.next) {
|
|
3937
5257
|
case 0:
|
|
3938
5258
|
// 可以直接通过配置里的 menu 读取
|
|
3939
|
-
menu_list_ids = ((_this$
|
|
5259
|
+
menu_list_ids = ((_this$otherParams27 = this.otherParams) === null || _this$otherParams27 === void 0 || (_this$otherParams27 = _this$otherParams27.dineInConfig) === null || _this$otherParams27 === void 0 ? void 0 : _this$otherParams27['menu.associated_menus'].map(function (n) {
|
|
3940
5260
|
return Number(n.value);
|
|
3941
5261
|
})) || [];
|
|
3942
|
-
|
|
3943
|
-
|
|
5262
|
+
_context62.prev = 1;
|
|
5263
|
+
_context62.next = 4;
|
|
3944
5264
|
return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
|
|
3945
5265
|
menu_list_ids: menu_list_ids,
|
|
3946
5266
|
cacheId: this.cacheId,
|
|
@@ -3948,17 +5268,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3948
5268
|
schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
3949
5269
|
});
|
|
3950
5270
|
case 4:
|
|
3951
|
-
res =
|
|
3952
|
-
return
|
|
5271
|
+
res = _context62.sent;
|
|
5272
|
+
return _context62.abrupt("return", res);
|
|
3953
5273
|
case 8:
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
throw
|
|
5274
|
+
_context62.prev = 8;
|
|
5275
|
+
_context62.t0 = _context62["catch"](1);
|
|
5276
|
+
throw _context62.t0;
|
|
3957
5277
|
case 11:
|
|
3958
5278
|
case "end":
|
|
3959
|
-
return
|
|
5279
|
+
return _context62.stop();
|
|
3960
5280
|
}
|
|
3961
|
-
},
|
|
5281
|
+
}, _callee62, this, [[1, 8]]);
|
|
3962
5282
|
}));
|
|
3963
5283
|
function getProductList() {
|
|
3964
5284
|
return _getProductList.apply(this, arguments);
|
|
@@ -3973,33 +5293,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3973
5293
|
}, {
|
|
3974
5294
|
key: "setOtherParams",
|
|
3975
5295
|
value: function () {
|
|
3976
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3977
|
-
var _this$
|
|
3978
|
-
var
|
|
3979
|
-
|
|
5296
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(params) {
|
|
5297
|
+
var _this$otherParams28;
|
|
5298
|
+
var _ref39,
|
|
5299
|
+
_ref39$cover,
|
|
3980
5300
|
cover,
|
|
3981
|
-
|
|
3982
|
-
return _regeneratorRuntime().wrap(function
|
|
3983
|
-
while (1) switch (
|
|
5301
|
+
_args63 = arguments;
|
|
5302
|
+
return _regeneratorRuntime().wrap(function _callee63$(_context63) {
|
|
5303
|
+
while (1) switch (_context63.prev = _context63.next) {
|
|
3984
5304
|
case 0:
|
|
3985
|
-
|
|
5305
|
+
_ref39 = _args63.length > 1 && _args63[1] !== undefined ? _args63[1] : {}, _ref39$cover = _ref39.cover, cover = _ref39$cover === void 0 ? false : _ref39$cover;
|
|
3986
5306
|
if (cover) {
|
|
3987
5307
|
this.otherParams = _objectSpread({}, params);
|
|
3988
5308
|
} else {
|
|
3989
5309
|
this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
|
|
3990
5310
|
}
|
|
3991
|
-
this.cacheId = (_this$
|
|
3992
|
-
|
|
5311
|
+
this.cacheId = (_this$otherParams28 = this.otherParams) === null || _this$otherParams28 === void 0 ? void 0 : _this$otherParams28.cacheId;
|
|
5312
|
+
_context63.next = 5;
|
|
3993
5313
|
return this.syncOtherParamsToSubModules(params, {
|
|
3994
5314
|
cover: cover
|
|
3995
5315
|
});
|
|
3996
5316
|
case 5:
|
|
3997
5317
|
case "end":
|
|
3998
|
-
return
|
|
5318
|
+
return _context63.stop();
|
|
3999
5319
|
}
|
|
4000
|
-
},
|
|
5320
|
+
}, _callee63, this);
|
|
4001
5321
|
}));
|
|
4002
|
-
function setOtherParams(
|
|
5322
|
+
function setOtherParams(_x54) {
|
|
4003
5323
|
return _setOtherParams.apply(this, arguments);
|
|
4004
5324
|
}
|
|
4005
5325
|
return setOtherParams;
|