@pisell/pisellos 2.3.38 → 2.3.39
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 +0 -2
- package/dist/core/index.js +0 -7
- package/dist/model/strategy/adapter/promotion/adapter.d.ts +0 -4
- package/dist/model/strategy/adapter/promotion/adapter.js +0 -23
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
- package/dist/model/strategy/adapter/promotion/evaluator.js +6 -279
- package/dist/model/strategy/adapter/promotion/examples.d.ts +0 -86
- package/dist/model/strategy/adapter/promotion/examples.js +0 -99
- package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/dist/model/strategy/adapter/promotion/type.d.ts +2 -90
- package/dist/model/strategy/adapter/promotion/type.js +0 -45
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +3 -5
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +3 -6
- package/dist/modules/Discount/index.d.ts +1 -0
- package/dist/modules/Discount/index.js +40 -11
- package/dist/modules/Discount/types.d.ts +1 -0
- package/dist/modules/Holder/index.d.ts +48 -0
- package/dist/modules/Holder/index.js +640 -0
- package/dist/modules/Holder/types.d.ts +123 -0
- package/dist/modules/Holder/types.js +1 -0
- package/dist/modules/Holder/utils.d.ts +13 -0
- package/dist/modules/Holder/utils.js +34 -0
- package/dist/modules/OpenData/index.d.ts +0 -2
- package/dist/modules/OpenData/index.js +2 -10
- package/dist/modules/Order/index.d.ts +11 -28
- package/dist/modules/Order/index.js +509 -750
- package/dist/modules/Order/types.d.ts +10 -33
- package/dist/modules/Order/utils/orderCollectionIdentity.js +2 -7
- package/dist/modules/Order/utils.d.ts +10 -0
- package/dist/modules/Order/utils.js +41 -13
- package/dist/modules/Payment/index.d.ts +0 -2
- package/dist/modules/Payment/index.js +50 -79
- package/dist/modules/Payment/types.d.ts +28 -99
- package/dist/modules/Payment/types.js +3 -20
- package/dist/modules/Payment/walletpass.d.ts +1 -25
- package/dist/modules/Payment/walletpass.js +157 -707
- package/dist/modules/Product/types.d.ts +1 -0
- package/dist/modules/ProductList/index.js +33 -14
- package/dist/modules/Quotation/index.d.ts +1 -1
- package/dist/modules/Quotation/index.js +2 -2
- package/dist/modules/ResourcePlanner/index.d.ts +24 -0
- package/dist/modules/ResourcePlanner/index.js +181 -0
- package/dist/modules/ResourcePlanner/planner.d.ts +14 -0
- package/dist/modules/ResourcePlanner/planner.js +1069 -0
- package/dist/modules/ResourcePlanner/types.d.ts +227 -0
- package/dist/modules/ResourcePlanner/types.js +1 -0
- package/dist/modules/Rules/index.d.ts +0 -1
- package/dist/modules/Rules/index.js +96 -89
- package/dist/modules/SalesSummary/index.js +12 -13
- package/dist/modules/ScanOrderLogger/index.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/index.js +15 -2
- package/dist/modules/ScanOrderLogger/providers/feishu.js +45 -27
- package/dist/modules/ScanOrderLogger/types.d.ts +1 -0
- package/dist/modules/Schedule/index.d.ts +3 -1
- package/dist/modules/Schedule/index.js +21 -16
- package/dist/modules/Summary/utils.js +38 -13
- package/dist/modules/index.d.ts +2 -0
- package/dist/modules/index.js +3 -1
- package/dist/plugins/window.d.ts +1 -0
- package/dist/server/index.d.ts +14 -16
- package/dist/server/index.js +1148 -1930
- package/dist/server/modules/order/index.d.ts +4 -54
- package/dist/server/modules/order/index.js +695 -1595
- package/dist/server/modules/order/types.d.ts +3 -11
- package/dist/server/modules/order/types.js +1 -1
- package/dist/solution/BaseSales/index.d.ts +20 -109
- package/dist/solution/BaseSales/index.js +481 -1797
- package/dist/solution/BaseSales/types.d.ts +0 -52
- package/dist/solution/BaseSales/types.js +1 -2
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
- package/dist/solution/BaseSales/utils/cartPromotion.js +31 -90
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
- package/dist/solution/BookingByStep/index.d.ts +17 -2
- package/dist/solution/BookingByStep/index.js +294 -215
- package/dist/solution/BookingByStep/types.d.ts +2 -1
- package/dist/solution/BookingByStep/types.js +3 -1
- package/dist/solution/BookingByStep/utils/capacity.js +17 -1
- package/dist/solution/BookingByStep/utils/timeslots.d.ts +3 -1
- package/dist/solution/BookingByStep/utils/timeslots.js +19 -12
- package/dist/solution/BookingTicket/index.d.ts +3 -7
- package/dist/solution/BookingTicket/index.js +49 -132
- package/dist/solution/BookingTicket/utils/addProductDecision.js +0 -6
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -8
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +82 -172
- package/dist/solution/Sales/index.d.ts +0 -1
- package/dist/solution/Sales/index.js +2 -10
- package/dist/solution/ScanOrder/index.d.ts +26 -14
- package/dist/solution/ScanOrder/index.js +1148 -756
- package/dist/solution/ScanOrder/types.d.ts +21 -1
- package/dist/solution/ScanOrder/utils.d.ts +8 -0
- package/dist/solution/ScanOrder/utils.js +66 -25
- package/dist/solution/ShopDiscount/index.d.ts +1 -0
- package/dist/solution/ShopDiscount/index.js +125 -87
- package/dist/solution/UnifiedBookingSales/index.d.ts +183 -0
- package/dist/solution/UnifiedBookingSales/index.js +1871 -0
- package/dist/solution/UnifiedBookingSales/types.d.ts +143 -0
- package/dist/solution/UnifiedBookingSales/types.js +11 -0
- package/dist/solution/VenueBooking/index.d.ts +39 -11
- package/dist/solution/VenueBooking/index.js +1176 -860
- package/dist/solution/VenueBooking/types.d.ts +3 -0
- package/dist/solution/VenueBooking/utils/resource.js +1 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
- package/dist/solution/VenueBooking/utils/slotMerge.js +10 -5
- package/dist/solution/index.d.ts +1 -0
- package/dist/solution/index.js +2 -1
- package/dist/types/index.d.ts +1 -1
- package/lib/core/index.d.ts +0 -2
- package/lib/core/index.js +0 -4
- package/lib/model/strategy/adapter/promotion/adapter.d.ts +0 -4
- package/lib/model/strategy/adapter/promotion/adapter.js +0 -20
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
- package/lib/model/strategy/adapter/promotion/evaluator.js +0 -235
- package/lib/model/strategy/adapter/promotion/examples.d.ts +0 -86
- package/lib/model/strategy/adapter/promotion/examples.js +0 -91
- package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +0 -51
- package/lib/model/strategy/adapter/promotion/type.d.ts +2 -90
- package/lib/model/strategy/adapter/promotion/type.js +0 -2
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +1 -2
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -2
- package/lib/modules/Discount/index.d.ts +1 -0
- package/lib/modules/Discount/index.js +9 -0
- package/lib/modules/Discount/types.d.ts +1 -0
- package/lib/modules/Holder/index.d.ts +48 -0
- package/lib/modules/Holder/index.js +402 -0
- package/lib/modules/Holder/types.d.ts +123 -0
- package/lib/modules/Holder/types.js +17 -0
- package/lib/modules/Holder/utils.d.ts +13 -0
- package/lib/modules/Holder/utils.js +71 -0
- package/lib/modules/OpenData/index.d.ts +0 -2
- package/lib/modules/OpenData/index.js +1 -6
- package/lib/modules/Order/index.d.ts +11 -28
- package/lib/modules/Order/index.js +86 -196
- package/lib/modules/Order/types.d.ts +10 -33
- package/lib/modules/Order/utils/orderCollectionIdentity.js +0 -3
- package/lib/modules/Order/utils.d.ts +10 -0
- package/lib/modules/Order/utils.js +40 -16
- package/lib/modules/Payment/index.d.ts +0 -2
- package/lib/modules/Payment/index.js +13 -34
- package/lib/modules/Payment/types.d.ts +28 -99
- package/lib/modules/Payment/types.js +3 -4
- package/lib/modules/Payment/walletpass.d.ts +1 -25
- package/lib/modules/Payment/walletpass.js +21 -470
- package/lib/modules/Product/types.d.ts +1 -0
- package/lib/modules/ProductList/index.js +40 -31
- package/lib/modules/Quotation/index.d.ts +1 -1
- package/lib/modules/Quotation/index.js +2 -2
- package/lib/modules/ResourcePlanner/index.d.ts +24 -0
- package/lib/modules/ResourcePlanner/index.js +148 -0
- package/lib/modules/ResourcePlanner/planner.d.ts +14 -0
- package/lib/modules/ResourcePlanner/planner.js +933 -0
- package/lib/modules/ResourcePlanner/types.d.ts +227 -0
- package/lib/modules/ResourcePlanner/types.js +17 -0
- package/lib/modules/Rules/index.d.ts +0 -1
- package/lib/modules/Rules/index.js +40 -47
- package/lib/modules/SalesSummary/index.js +6 -7
- package/lib/modules/ScanOrderLogger/index.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/index.js +13 -1
- package/lib/modules/ScanOrderLogger/providers/feishu.js +15 -6
- package/lib/modules/ScanOrderLogger/types.d.ts +1 -0
- package/lib/modules/Schedule/index.d.ts +3 -1
- package/lib/modules/Schedule/index.js +10 -8
- package/lib/modules/Summary/utils.js +21 -1
- package/lib/modules/index.d.ts +2 -0
- package/lib/modules/index.js +5 -1
- package/lib/plugins/window.d.ts +1 -0
- package/lib/server/index.d.ts +14 -16
- package/lib/server/index.js +83 -675
- package/lib/server/modules/order/index.d.ts +4 -54
- package/lib/server/modules/order/index.js +66 -679
- package/lib/server/modules/order/types.d.ts +3 -11
- package/lib/solution/BaseSales/index.d.ts +20 -109
- package/lib/solution/BaseSales/index.js +70 -881
- package/lib/solution/BaseSales/types.d.ts +0 -52
- package/lib/solution/BaseSales/types.js +1 -2
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
- package/lib/solution/BaseSales/utils/cartPromotion.js +12 -63
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
- package/lib/solution/BookingByStep/index.d.ts +17 -2
- package/lib/solution/BookingByStep/index.js +60 -18
- package/lib/solution/BookingByStep/types.d.ts +2 -1
- package/lib/solution/BookingByStep/types.js +5 -0
- package/lib/solution/BookingByStep/utils/capacity.js +20 -1
- package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
- package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
- package/lib/solution/BookingTicket/index.d.ts +3 -7
- package/lib/solution/BookingTicket/index.js +9 -62
- package/lib/solution/BookingTicket/utils/addProductDecision.js +0 -4
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -8
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +4 -36
- package/lib/solution/Sales/index.d.ts +0 -1
- package/lib/solution/Sales/index.js +3 -5
- package/lib/solution/ScanOrder/index.d.ts +26 -14
- package/lib/solution/ScanOrder/index.js +449 -190
- package/lib/solution/ScanOrder/types.d.ts +21 -1
- package/lib/solution/ScanOrder/utils.d.ts +8 -0
- package/lib/solution/ScanOrder/utils.js +31 -0
- package/lib/solution/ShopDiscount/index.d.ts +1 -0
- package/lib/solution/ShopDiscount/index.js +14 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +183 -0
- package/lib/solution/UnifiedBookingSales/index.js +1076 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +143 -0
- package/lib/solution/UnifiedBookingSales/types.js +33 -0
- package/lib/solution/VenueBooking/index.d.ts +39 -11
- package/lib/solution/VenueBooking/index.js +328 -123
- package/lib/solution/VenueBooking/types.d.ts +3 -0
- package/lib/solution/VenueBooking/utils/resource.js +1 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
- package/lib/solution/VenueBooking/utils/slotMerge.js +6 -4
- package/lib/solution/index.d.ts +1 -0
- package/lib/solution/index.js +3 -1
- package/lib/types/index.d.ts +1 -1
- package/package.json +1 -1
- package/dist/modules/Order/payment-utils.d.ts +0 -26
- package/dist/modules/Order/payment-utils.js +0 -225
- package/dist/solution/BookingTicket/utils/weighingProductSku.d.ts +0 -5
- package/dist/solution/BookingTicket/utils/weighingProductSku.js +0 -45
- package/dist/utils/payment-number.d.ts +0 -9
- package/dist/utils/payment-number.js +0 -69
- package/lib/modules/Order/payment-utils.d.ts +0 -26
- package/lib/modules/Order/payment-utils.js +0 -224
- package/lib/solution/BookingTicket/utils/weighingProductSku.d.ts +0 -5
- package/lib/solution/BookingTicket/utils/weighingProductSku.js +0 -63
- package/lib/utils/payment-number.d.ts +0 -9
- package/lib/utils/payment-number.js +0 -64
|
@@ -37,8 +37,6 @@ 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";
|
|
42
40
|
import { applyOrderCollectionUidRemaps, getOrderCollectionPersistentId, getOrderCollectionReferenceUid, getOrderCollectionUid, isSameOrderCollectionItem, mergeOrderCollectionItems, normalizeOrderCollection, normalizeOrderCollections, setOrderCollectionUid } from "../../modules/Order/utils/orderCollectionIdentity";
|
|
43
41
|
import dayjs from 'dayjs';
|
|
44
42
|
export * from "./types";
|
|
@@ -46,89 +44,6 @@ import { QuotationModule } from "../../modules/Quotation";
|
|
|
46
44
|
import { transformBaseProductToOrderProduct as _transformBaseProductToOrderProduct } from "./utils/transformBaseProductToOrderProduct";
|
|
47
45
|
import { calculateBaseSalesProductBookingPrice } from "./utils/quotationPrice";
|
|
48
46
|
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
|
-
}
|
|
132
47
|
function isBaseSalesManualProductDiscountProduct(product) {
|
|
133
48
|
var _product$metadata, _product$metadata2;
|
|
134
49
|
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) {
|
|
@@ -157,10 +72,6 @@ function preserveManualProductDiscountProducts(previousProducts, nextProducts) {
|
|
|
157
72
|
function isBaseSalesHistoricalDiscountEntry(discount) {
|
|
158
73
|
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);
|
|
159
74
|
}
|
|
160
|
-
function getBaseSalesUniqueArrayMetadataKey(key) {
|
|
161
|
-
if (key === 'products' || key === 'bookings') return 'unique_identification_number';
|
|
162
|
-
return null;
|
|
163
|
-
}
|
|
164
75
|
var BASE_SALES_PERSISTENT_ID_FIELD_BY_KIND = {
|
|
165
76
|
product: 'order_detail_id',
|
|
166
77
|
booking: 'schedule_event_id',
|
|
@@ -232,15 +143,6 @@ function mergeBaseSalesCollectionItem(kind, currentItem, incomingItem, uidRemaps
|
|
|
232
143
|
return kind === 'product' ? mergeBaseSalesProductSnapshotFields(currentItem, mergedItem) : mergedItem;
|
|
233
144
|
}
|
|
234
145
|
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
|
-
}
|
|
244
146
|
var currentItems = normalizeOrderCollection(kind, currentValue, {
|
|
245
147
|
ensureUid: false
|
|
246
148
|
}).items;
|
|
@@ -287,34 +189,6 @@ function normalizeBaseSalesRecordCollections(sourceRecord, options) {
|
|
|
287
189
|
}
|
|
288
190
|
return normalizedRecord;
|
|
289
191
|
}
|
|
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
|
-
}
|
|
318
192
|
function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, strategy) {
|
|
319
193
|
var normalizedLoadedRecord = normalizeBaseSalesRecordCollections(loadedRecord || {}, {
|
|
320
194
|
ensureUid: false
|
|
@@ -332,15 +206,6 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, str
|
|
|
332
206
|
return mergeBaseSalesOrderCollection(collectionKind, Array.isArray(currentValue) ? currentValue : [], loadedValue, strategy, uidRemaps);
|
|
333
207
|
}
|
|
334
208
|
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
|
-
}
|
|
344
209
|
return [].concat(_toConsumableArray(cloneDeep(currentValue)), _toConsumableArray(cloneDeep(loadedValue)));
|
|
345
210
|
}
|
|
346
211
|
if (Array.isArray(loadedValue)) return cloneDeep(loadedValue);
|
|
@@ -352,22 +217,6 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, str
|
|
|
352
217
|
delete mergedRecord.request_unique_idempotency_token;
|
|
353
218
|
return normalizeBaseSalesRecordCollections(applyOrderCollectionUidRemaps(mergedRecord, uidRemaps));
|
|
354
219
|
}
|
|
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
|
-
}
|
|
371
220
|
export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
372
221
|
_inherits(BaseSalesImpl, _BaseModule);
|
|
373
222
|
var _super = _createSuper(BaseSalesImpl);
|
|
@@ -387,11 +236,6 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
387
236
|
});
|
|
388
237
|
_defineProperty(_assertThisInitialized(_this), "otherParams", {});
|
|
389
238
|
_defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
|
|
390
|
-
/**
|
|
391
|
-
* 由已在初始化阶段解析过设备短号的业务解决方案写入。
|
|
392
|
-
* 未设置时,支付编号仍按原逻辑实时读取设备信息。
|
|
393
|
-
*/
|
|
394
|
-
_defineProperty(_assertThisInitialized(_this), "paymentNumberDevicePrefix", null);
|
|
395
239
|
/**
|
|
396
240
|
* window / request 暴露为 public:现存外部工具(如 BookingTicket Scan)通过
|
|
397
241
|
* `solution.window` / `solution.request` 直接访问插件,保持原有契约不破坏。
|
|
@@ -409,7 +253,6 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
409
253
|
_defineProperty(_assertThisInitialized(_this), "autoPaymentSyncTimer", null);
|
|
410
254
|
_defineProperty(_assertThisInitialized(_this), "salesDetailLoadInFlightCount", 0);
|
|
411
255
|
_defineProperty(_assertThisInitialized(_this), "salesDetailLoadSequence", 0);
|
|
412
|
-
_defineProperty(_assertThisInitialized(_this), "walletAssetsRefreshSequence", 0);
|
|
413
256
|
_defineProperty(_assertThisInitialized(_this), "salesDetailHydrateQueue", Promise.resolve());
|
|
414
257
|
_defineProperty(_assertThisInitialized(_this), "serverOrderChangeUnsubscribe", null);
|
|
415
258
|
_defineProperty(_assertThisInitialized(_this), "serverOrderChangeHydrateInFlight", null);
|
|
@@ -602,12 +445,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
602
445
|
return _context3.abrupt("return");
|
|
603
446
|
case 14:
|
|
604
447
|
this.serverOrderChangeHydrateInFlight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
605
|
-
var _getTempOrder,
|
|
448
|
+
var _getTempOrder, _ref2;
|
|
606
449
|
var currentTempOrder, record, sales;
|
|
607
450
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
608
451
|
while (1) switch (_context2.prev = _context2.next) {
|
|
609
452
|
case 0:
|
|
610
|
-
currentTempOrder = (_getTempOrder = (
|
|
453
|
+
currentTempOrder = (_getTempOrder = (_ref2 = _this2.store.order).getTempOrder) === null || _getTempOrder === void 0 ? void 0 : _getTempOrder.call(_ref2);
|
|
611
454
|
record = mergeSalesDetailRecordWithTempOrder(currentTempOrder, changedOrder, 'authoritative-incoming');
|
|
612
455
|
_context2.next = 4;
|
|
613
456
|
return _this2.store.order.hydrateTempOrderFromRecord(record, {
|
|
@@ -676,7 +519,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
676
519
|
hydratedSales = null;
|
|
677
520
|
skippedBeforeHydrate = false;
|
|
678
521
|
hydrateTask = /*#__PURE__*/function () {
|
|
679
|
-
var
|
|
522
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
680
523
|
var sales;
|
|
681
524
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
682
525
|
while (1) switch (_context4.prev = _context4.next) {
|
|
@@ -721,7 +564,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
721
564
|
}, _callee4);
|
|
722
565
|
}));
|
|
723
566
|
return function hydrateTask() {
|
|
724
|
-
return
|
|
567
|
+
return _ref3.apply(this, arguments);
|
|
725
568
|
};
|
|
726
569
|
}();
|
|
727
570
|
queuedTask = this.salesDetailHydrateQueue.then(hydrateTask, hydrateTask);
|
|
@@ -815,10 +658,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
815
658
|
});
|
|
816
659
|
}
|
|
817
660
|
quotation.setScheduleResolver(function (id) {
|
|
818
|
-
var _scheduleModule$getSc, _getScheduleByIds,
|
|
661
|
+
var _scheduleModule$getSc, _getScheduleByIds, _ref4;
|
|
819
662
|
var scheduleId = String(id);
|
|
820
663
|
if (scheduleById.has(scheduleId)) return scheduleById.get(scheduleId);
|
|
821
|
-
var schedules = ((_scheduleModule$getSc = scheduleModule.getScheduleListByIds) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule, [id])) || ((_getScheduleByIds = (
|
|
664
|
+
var schedules = ((_scheduleModule$getSc = scheduleModule.getScheduleListByIds) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule, [id])) || ((_getScheduleByIds = (_ref4 = scheduleModule).getScheduleByIds) === null || _getScheduleByIds === void 0 ? void 0 : _getScheduleByIds.call(_ref4, [id])) || [];
|
|
822
665
|
if (schedules[0]) scheduleById.set(scheduleId, schedules[0]);
|
|
823
666
|
return schedules[0];
|
|
824
667
|
});
|
|
@@ -1005,10 +848,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1005
848
|
return groups.flatMap(function (group) {
|
|
1006
849
|
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 : [];
|
|
1007
850
|
return items.map(function (item) {
|
|
1008
|
-
var _item$group_id,
|
|
851
|
+
var _item$group_id, _ref5, _item$bundle_group_id;
|
|
1009
852
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
1010
853
|
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,
|
|
1011
|
-
bundle_group_id: (
|
|
854
|
+
bundle_group_id: (_ref5 = (_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 && _ref5 !== void 0 ? _ref5 : group === null || group === void 0 ? void 0 : group.id
|
|
1012
855
|
});
|
|
1013
856
|
});
|
|
1014
857
|
});
|
|
@@ -1039,21 +882,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1039
882
|
}, {
|
|
1040
883
|
key: "getAuthoritativeBundleUnitPrice",
|
|
1041
884
|
value: function getAuthoritativeBundleUnitPrice(bundle) {
|
|
1042
|
-
var
|
|
1043
|
-
return (
|
|
885
|
+
var _ref6, _ref7, _ref8, _bundle$price;
|
|
886
|
+
return (_ref6 = (_ref7 = (_ref8 = (_bundle$price = bundle.price) !== null && _bundle$price !== void 0 ? _bundle$price : bundle.bundle_selling_price) !== null && _ref8 !== void 0 ? _ref8 : bundle.custom_price) !== null && _ref7 !== void 0 ? _ref7 : bundle.product_price) !== null && _ref6 !== void 0 ? _ref6 : bundle.base_price;
|
|
1044
887
|
}
|
|
1045
888
|
}, {
|
|
1046
889
|
key: "mergeProductForPriceQuery",
|
|
1047
890
|
value: function mergeProductForPriceQuery(product, authoritativeProduct) {
|
|
1048
891
|
var _this5 = this,
|
|
1049
892
|
_product$id,
|
|
1050
|
-
|
|
893
|
+
_ref9,
|
|
1051
894
|
_product$product_id2,
|
|
1052
|
-
|
|
895
|
+
_ref10,
|
|
1053
896
|
_product$product_vari,
|
|
1054
|
-
|
|
897
|
+
_ref11,
|
|
1055
898
|
_product$num,
|
|
1056
|
-
|
|
899
|
+
_ref12,
|
|
1057
900
|
_product$quantity,
|
|
1058
901
|
_product$metadata4;
|
|
1059
902
|
if (!authoritativeProduct) return product;
|
|
@@ -1073,10 +916,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1073
916
|
});
|
|
1074
917
|
return _objectSpread(_objectSpread(_objectSpread({}, product), authoritativeProduct), {}, {
|
|
1075
918
|
id: (_product$id = product.id) !== null && _product$id !== void 0 ? _product$id : authoritativeProduct.id,
|
|
1076
|
-
product_id: (
|
|
1077
|
-
product_variant_id: (
|
|
1078
|
-
num: (
|
|
1079
|
-
quantity: (
|
|
919
|
+
product_id: (_ref9 = (_product$product_id2 = product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : authoritativeProduct.product_id) !== null && _ref9 !== void 0 ? _ref9 : authoritativeProduct.id,
|
|
920
|
+
product_variant_id: (_ref10 = (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : authoritativeProduct.product_variant_id) !== null && _ref10 !== void 0 ? _ref10 : 0,
|
|
921
|
+
num: (_ref11 = (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : product.quantity) !== null && _ref11 !== void 0 ? _ref11 : authoritativeProduct.num,
|
|
922
|
+
quantity: (_ref12 = (_product$quantity = product.quantity) !== null && _product$quantity !== void 0 ? _product$quantity : product.num) !== null && _ref12 !== void 0 ? _ref12 : authoritativeProduct.quantity,
|
|
1080
923
|
product_sku: function () {
|
|
1081
924
|
var authoritativeSku = ensureProductSku(authoritativeProduct);
|
|
1082
925
|
var productSku = ensureProductSku(product);
|
|
@@ -1152,24 +995,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1152
995
|
value: (function () {
|
|
1153
996
|
var _syncOtherParamsToSubModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(changedParams) {
|
|
1154
997
|
var _this6 = this;
|
|
1155
|
-
var
|
|
1156
|
-
|
|
998
|
+
var _ref13,
|
|
999
|
+
_ref13$cover,
|
|
1157
1000
|
cover,
|
|
1158
1001
|
nextSubModuleOtherParams,
|
|
1159
1002
|
_args10 = arguments;
|
|
1160
1003
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
1161
1004
|
while (1) switch (_context10.prev = _context10.next) {
|
|
1162
1005
|
case 0:
|
|
1163
|
-
|
|
1006
|
+
_ref13 = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : {}, _ref13$cover = _ref13.cover, cover = _ref13$cover === void 0 ? false : _ref13$cover;
|
|
1164
1007
|
nextSubModuleOtherParams = this.buildSubModuleOtherParams();
|
|
1165
1008
|
_context10.next = 4;
|
|
1166
1009
|
return Promise.all(Object.entries(this.store).map( /*#__PURE__*/function () {
|
|
1167
|
-
var
|
|
1168
|
-
var
|
|
1010
|
+
var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(_ref14) {
|
|
1011
|
+
var _ref16, moduleName, subModule, targetModule;
|
|
1169
1012
|
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
1170
1013
|
while (1) switch (_context9.prev = _context9.next) {
|
|
1171
1014
|
case 0:
|
|
1172
|
-
|
|
1015
|
+
_ref16 = _slicedToArray(_ref14, 2), moduleName = _ref16[0], subModule = _ref16[1];
|
|
1173
1016
|
if (!_this6.reusedSharedSubModuleNames.has(moduleName)) {
|
|
1174
1017
|
_context9.next = 3;
|
|
1175
1018
|
break;
|
|
@@ -1195,7 +1038,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1195
1038
|
}, _callee9);
|
|
1196
1039
|
}));
|
|
1197
1040
|
return function (_x9) {
|
|
1198
|
-
return
|
|
1041
|
+
return _ref15.apply(this, arguments);
|
|
1199
1042
|
};
|
|
1200
1043
|
}()));
|
|
1201
1044
|
case 4:
|
|
@@ -1223,7 +1066,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1223
1066
|
if (!sessionData) return {};
|
|
1224
1067
|
var data = JSON.parse(sessionData);
|
|
1225
1068
|
return data && data[this.cacheId] || {};
|
|
1226
|
-
} catch (
|
|
1069
|
+
} catch (_unused) {
|
|
1227
1070
|
return {};
|
|
1228
1071
|
}
|
|
1229
1072
|
}
|
|
@@ -1237,38 +1080,6 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1237
1080
|
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');
|
|
1238
1081
|
return coreData === null || coreData === void 0 ? void 0 : coreData[key];
|
|
1239
1082
|
}
|
|
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
|
-
}
|
|
1272
1083
|
}, {
|
|
1273
1084
|
key: "syncAppDataToTempOrder",
|
|
1274
1085
|
value: function syncAppDataToTempOrder(tempOrder) {
|
|
@@ -1312,7 +1123,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1312
1123
|
value: function () {
|
|
1313
1124
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(core) {
|
|
1314
1125
|
var _this$otherParams4,
|
|
1315
|
-
|
|
1126
|
+
_this$appPlugin2,
|
|
1127
|
+
_this$appPlugin2$getA,
|
|
1128
|
+
_this7 = this,
|
|
1316
1129
|
_this$otherParams5;
|
|
1317
1130
|
var options,
|
|
1318
1131
|
app,
|
|
@@ -1325,7 +1138,6 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1325
1138
|
options = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {};
|
|
1326
1139
|
this.core = core;
|
|
1327
1140
|
this.initializeOptions = options || {};
|
|
1328
|
-
this.paymentNumberDevicePrefix = null;
|
|
1329
1141
|
// this.store = { ...this.store, ...(options.store as Partial<BaseSalesState>) };
|
|
1330
1142
|
this.otherParams = options.otherParams || {};
|
|
1331
1143
|
this.cacheId = (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.cacheId;
|
|
@@ -1335,53 +1147,50 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1335
1147
|
|
|
1336
1148
|
// 获取 logger 实例
|
|
1337
1149
|
this.appPlugin = core.getPlugin('app');
|
|
1338
|
-
if (this.appPlugin) {
|
|
1339
|
-
|
|
1340
|
-
break;
|
|
1150
|
+
if (!this.appPlugin) {
|
|
1151
|
+
// throw new Error('Checkout 解决方案需要 app 插件支持');
|
|
1341
1152
|
}
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
app = this.appPlugin.getApp();
|
|
1345
|
-
this.logger = app.logger;
|
|
1153
|
+
app = (_this$appPlugin2 = this.appPlugin) === null || _this$appPlugin2 === void 0 || (_this$appPlugin2$getA = _this$appPlugin2.getApp) === null || _this$appPlugin2$getA === void 0 ? void 0 : _this$appPlugin2$getA.call(_this$appPlugin2);
|
|
1154
|
+
this.logger = app === null || app === void 0 ? void 0 : app.logger;
|
|
1346
1155
|
targetCacheData = this.readSessionCacheData();
|
|
1347
1156
|
moduleNames = this.getRegisteredModuleNames();
|
|
1348
1157
|
moduleNames.forEach(function (step) {
|
|
1349
|
-
var reusedModule =
|
|
1158
|
+
var reusedModule = _this7.getReusableSharedSubModule(step);
|
|
1350
1159
|
if (reusedModule) {
|
|
1351
|
-
|
|
1352
|
-
|
|
1160
|
+
_this7.store[step] = reusedModule;
|
|
1161
|
+
_this7.reusedSharedSubModuleNames.add(step);
|
|
1353
1162
|
return;
|
|
1354
1163
|
}
|
|
1355
|
-
var targetModule =
|
|
1164
|
+
var targetModule = _this7.createSubModule(step);
|
|
1356
1165
|
if (!targetModule) {
|
|
1357
1166
|
throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
|
|
1358
1167
|
}
|
|
1359
|
-
var hooks =
|
|
1360
|
-
|
|
1361
|
-
|
|
1168
|
+
var hooks = _this7.getSubModuleHooks(step);
|
|
1169
|
+
_this7.store[step] = targetModule;
|
|
1170
|
+
_this7.core.registerModule(targetModule, _objectSpread(_objectSpread({
|
|
1362
1171
|
initialState: (targetCacheData === null || targetCacheData === void 0 ? void 0 : targetCacheData[targetModule.name]) || {}
|
|
1363
1172
|
}, hooks ? {
|
|
1364
1173
|
hooks: hooks
|
|
1365
1174
|
} : {}), {}, {
|
|
1366
|
-
otherParams:
|
|
1175
|
+
otherParams: _this7.buildSubModuleOtherParams()
|
|
1367
1176
|
}));
|
|
1368
1177
|
});
|
|
1369
1178
|
if (!(this.store.schedule && !this.isScheduleListLoaded(this.store.schedule))) {
|
|
1370
|
-
_context11.next =
|
|
1179
|
+
_context11.next = 18;
|
|
1371
1180
|
break;
|
|
1372
1181
|
}
|
|
1373
|
-
_context11.next =
|
|
1182
|
+
_context11.next = 18;
|
|
1374
1183
|
return this.store.schedule.loadAllSchedule();
|
|
1375
|
-
case
|
|
1184
|
+
case 18:
|
|
1376
1185
|
if (this.store.order && typeof ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.enableTempOrderPersist) === 'boolean') {
|
|
1377
1186
|
this.store.order.setEnableTempOrderPersist(this.otherParams.enableTempOrderPersist);
|
|
1378
1187
|
}
|
|
1379
|
-
_context11.next =
|
|
1188
|
+
_context11.next = 21;
|
|
1380
1189
|
return this.getPaymentMethodsAsync();
|
|
1381
|
-
case
|
|
1190
|
+
case 21:
|
|
1382
1191
|
this.registerServerOrderChangeSync();
|
|
1383
1192
|
this.core.effects.emit("".concat(this.name, ":onInited"), {});
|
|
1384
|
-
case
|
|
1193
|
+
case 23:
|
|
1385
1194
|
case "end":
|
|
1386
1195
|
return _context11.stop();
|
|
1387
1196
|
}
|
|
@@ -1397,15 +1206,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1397
1206
|
value: function () {
|
|
1398
1207
|
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
1399
1208
|
var _this$serverOrderChan2,
|
|
1400
|
-
|
|
1209
|
+
_this8 = this;
|
|
1401
1210
|
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
1402
1211
|
while (1) switch (_context12.prev = _context12.next) {
|
|
1403
1212
|
case 0:
|
|
1404
1213
|
(_this$serverOrderChan2 = this.serverOrderChangeUnsubscribe) === null || _this$serverOrderChan2 === void 0 || _this$serverOrderChan2.call(this);
|
|
1405
1214
|
this.serverOrderChangeUnsubscribe = null;
|
|
1406
1215
|
Object.keys(this.store).forEach(function (key) {
|
|
1407
|
-
if (
|
|
1408
|
-
var sub =
|
|
1216
|
+
if (_this8.reusedSharedSubModuleNames.has(key)) return;
|
|
1217
|
+
var sub = _this8.store[key];
|
|
1409
1218
|
if (sub && typeof sub.destroy === 'function') {
|
|
1410
1219
|
try {
|
|
1411
1220
|
sub.destroy();
|
|
@@ -1415,15 +1224,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1415
1224
|
}
|
|
1416
1225
|
});
|
|
1417
1226
|
this.currentSalesDetail = null;
|
|
1418
|
-
this.paymentNumberDevicePrefix = null;
|
|
1419
1227
|
this.queuedServerOrderChanges = [];
|
|
1420
1228
|
this.salesDetailLoadSequence += 1;
|
|
1421
|
-
|
|
1422
|
-
_context12.next = 10;
|
|
1229
|
+
_context12.next = 8;
|
|
1423
1230
|
return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
|
|
1424
|
-
case
|
|
1231
|
+
case 8:
|
|
1425
1232
|
_get(_getPrototypeOf(BaseSalesImpl.prototype), "destroy", this).call(this);
|
|
1426
|
-
case
|
|
1233
|
+
case 9:
|
|
1427
1234
|
case "end":
|
|
1428
1235
|
return _context12.stop();
|
|
1429
1236
|
}
|
|
@@ -1445,7 +1252,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1445
1252
|
key: "loadSalesDetail",
|
|
1446
1253
|
value: (function () {
|
|
1447
1254
|
var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderIdOrParams) {
|
|
1448
|
-
var loadSequence,
|
|
1255
|
+
var loadSequence, _ref17, _ref18, _ref19, _ref20, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, remoteRecord, currentTempOrder, record;
|
|
1449
1256
|
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
1450
1257
|
while (1) switch (_context13.prev = _context13.next) {
|
|
1451
1258
|
case 0:
|
|
@@ -1463,7 +1270,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1463
1270
|
};
|
|
1464
1271
|
externalSaleNumber = params.externalSaleNumber || params.external_sale_number;
|
|
1465
1272
|
preloadedSalesDetail = params.preloadedSalesDetail;
|
|
1466
|
-
lookup = (
|
|
1273
|
+
lookup = (_ref17 = (_ref18 = (_ref19 = (_ref20 = (_params$orderId = params.orderId) !== null && _params$orderId !== void 0 ? _params$orderId : externalSaleNumber) !== null && _ref20 !== void 0 ? _ref20 : params.orderNumber) !== null && _ref19 !== void 0 ? _ref19 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_id) !== null && _ref18 !== void 0 ? _ref18 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.external_sale_number) !== null && _ref17 !== void 0 ? _ref17 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_number;
|
|
1467
1274
|
if (!(!preloadedSalesDetail && (lookup === undefined || lookup === null || lookup === ''))) {
|
|
1468
1275
|
_context13.next = 11;
|
|
1469
1276
|
break;
|
|
@@ -1494,40 +1301,39 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1494
1301
|
message = loadedRecord && (loadedRecord.message || loadedRecord.msg) || "\u52A0\u8F7D\u9500\u552E\u8BE6\u60C5\u5931\u8D25: ".concat(lookup);
|
|
1495
1302
|
throw new Error(message);
|
|
1496
1303
|
case 22:
|
|
1497
|
-
remoteRecord =
|
|
1304
|
+
remoteRecord = preloadedSalesDetail !== null && preloadedSalesDetail !== void 0 ? preloadedSalesDetail : loadedRecord.data;
|
|
1498
1305
|
currentTempOrder = params.merge ? this.store.order.getTempOrder() : null;
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
_context13.next = 28;
|
|
1306
|
+
record = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder, remoteRecord, 'preserve-local') : remoteRecord;
|
|
1307
|
+
_context13.next = 27;
|
|
1502
1308
|
return this.hydrateLatestLoadedSalesDetail(record, loadSequence);
|
|
1503
|
-
case
|
|
1309
|
+
case 27:
|
|
1504
1310
|
return _context13.abrupt("return", _context13.sent);
|
|
1505
|
-
case
|
|
1506
|
-
_context13.prev =
|
|
1311
|
+
case 28:
|
|
1312
|
+
_context13.prev = 28;
|
|
1507
1313
|
this.salesDetailLoadInFlightCount = Math.max(0, this.salesDetailLoadInFlightCount - 1);
|
|
1508
1314
|
if (!(this.salesDetailLoadInFlightCount === 0)) {
|
|
1509
|
-
_context13.next =
|
|
1315
|
+
_context13.next = 39;
|
|
1510
1316
|
break;
|
|
1511
1317
|
}
|
|
1512
|
-
_context13.prev =
|
|
1513
|
-
_context13.next =
|
|
1318
|
+
_context13.prev = 31;
|
|
1319
|
+
_context13.next = 34;
|
|
1514
1320
|
return this.drainQueuedServerOrderChanges();
|
|
1515
|
-
case
|
|
1516
|
-
_context13.next =
|
|
1321
|
+
case 34:
|
|
1322
|
+
_context13.next = 39;
|
|
1517
1323
|
break;
|
|
1518
|
-
case
|
|
1519
|
-
_context13.prev =
|
|
1520
|
-
_context13.t1 = _context13["catch"](
|
|
1324
|
+
case 36:
|
|
1325
|
+
_context13.prev = 36;
|
|
1326
|
+
_context13.t1 = _context13["catch"](31);
|
|
1521
1327
|
this.logError('drain queued server order changes failed', {
|
|
1522
1328
|
error: _context13.t1 instanceof Error ? _context13.t1.message : String(_context13.t1)
|
|
1523
1329
|
});
|
|
1330
|
+
case 39:
|
|
1331
|
+
return _context13.finish(28);
|
|
1524
1332
|
case 40:
|
|
1525
|
-
return _context13.finish(29);
|
|
1526
|
-
case 41:
|
|
1527
1333
|
case "end":
|
|
1528
1334
|
return _context13.stop();
|
|
1529
1335
|
}
|
|
1530
|
-
}, _callee13, this, [[4,,
|
|
1336
|
+
}, _callee13, this, [[4,, 28, 40], [31, 36]]);
|
|
1531
1337
|
}));
|
|
1532
1338
|
function loadSalesDetail(_x11) {
|
|
1533
1339
|
return _loadSalesDetail.apply(this, arguments);
|
|
@@ -1804,7 +1610,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1804
1610
|
key: "restoreOrder",
|
|
1805
1611
|
value: function () {
|
|
1806
1612
|
var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
1807
|
-
var
|
|
1613
|
+
var tempOrder;
|
|
1808
1614
|
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1809
1615
|
while (1) switch (_context17.prev = _context17.next) {
|
|
1810
1616
|
case 0:
|
|
@@ -1820,39 +1626,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1820
1626
|
this.currentSalesDetail = null;
|
|
1821
1627
|
this.discountConfigCacheKey = null;
|
|
1822
1628
|
this.hasManualDiscountSelection = false;
|
|
1823
|
-
|
|
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;
|
|
1629
|
+
_context17.next = 9;
|
|
1834
1630
|
return this.effectsEmit('onTempOrderReplaced', {
|
|
1835
1631
|
tempOrder: tempOrder
|
|
1836
1632
|
});
|
|
1837
|
-
case
|
|
1633
|
+
case 9:
|
|
1838
1634
|
if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
|
|
1839
|
-
_context17.next =
|
|
1635
|
+
_context17.next = 13;
|
|
1840
1636
|
break;
|
|
1841
1637
|
}
|
|
1842
1638
|
this.store.order.persistTempOrder();
|
|
1843
|
-
_context17.next =
|
|
1639
|
+
_context17.next = 13;
|
|
1844
1640
|
return this.store.order.saveDraft();
|
|
1845
|
-
case
|
|
1641
|
+
case 13:
|
|
1846
1642
|
return _context17.abrupt("return", tempOrder);
|
|
1847
|
-
case
|
|
1848
|
-
_context17.prev =
|
|
1643
|
+
case 16:
|
|
1644
|
+
_context17.prev = 16;
|
|
1849
1645
|
_context17.t0 = _context17["catch"](0);
|
|
1850
1646
|
throw _context17.t0;
|
|
1851
|
-
case
|
|
1647
|
+
case 19:
|
|
1852
1648
|
case "end":
|
|
1853
1649
|
return _context17.stop();
|
|
1854
1650
|
}
|
|
1855
|
-
}, _callee17, this, [[0,
|
|
1651
|
+
}, _callee17, this, [[0, 16]]);
|
|
1856
1652
|
}));
|
|
1857
1653
|
function restoreOrder() {
|
|
1858
1654
|
return _restoreOrder.apply(this, arguments);
|
|
@@ -1965,10 +1761,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1965
1761
|
}, {
|
|
1966
1762
|
key: "getHistoricalProductDiscountList",
|
|
1967
1763
|
value: function getHistoricalProductDiscountList(products) {
|
|
1968
|
-
var
|
|
1764
|
+
var _this9 = this;
|
|
1969
1765
|
var historyDiscountList = [];
|
|
1970
1766
|
products.forEach(function (item) {
|
|
1971
|
-
if (!
|
|
1767
|
+
if (!_this9.isPersistedOrderProduct(item)) return;
|
|
1972
1768
|
(item.discount_list || []).forEach(function (discount) {
|
|
1973
1769
|
var _discount$discount, _discount$metadata, _discount$discount2, _discount$discount3, _discount$discount4;
|
|
1974
1770
|
var discountId = ((_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) || discount.id;
|
|
@@ -2028,11 +1824,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2028
1824
|
}, {
|
|
2029
1825
|
key: "shouldSkipAutoApplyFetchedDiscountsInEditMode",
|
|
2030
1826
|
value: function shouldSkipAutoApplyFetchedDiscountsInEditMode(params) {
|
|
2031
|
-
var
|
|
1827
|
+
var _this10 = this;
|
|
2032
1828
|
if (params.discountAction !== 'edit') return false;
|
|
2033
1829
|
if (!params.products.length) return false;
|
|
2034
1830
|
var hasDraftProduct = params.products.some(function (product) {
|
|
2035
|
-
return !
|
|
1831
|
+
return !_this10.isPersistedOrderProduct(product);
|
|
2036
1832
|
});
|
|
2037
1833
|
if (hasDraftProduct) return false;
|
|
2038
1834
|
var hasSelectedDiscount = params.currentDiscountList.some(function (discount) {
|
|
@@ -2611,10 +2407,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2611
2407
|
product.discount_list = filterSelectedDiscountDetails(product.discount_list);
|
|
2612
2408
|
if (Array.isArray(product.product_bundle)) {
|
|
2613
2409
|
product.product_bundle = product.product_bundle.map(function (bundle) {
|
|
2614
|
-
var
|
|
2410
|
+
var _ref21, _bundle$original_pric;
|
|
2615
2411
|
var nextBundleDiscountList = filterSelectedDiscountDetails(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list);
|
|
2616
2412
|
var shouldRestoreBundlePrice = nextBundleDiscountList.length === 0;
|
|
2617
|
-
var restoredBundlePrice = (
|
|
2413
|
+
var restoredBundlePrice = (_ref21 = (_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 && _ref21 !== void 0 ? _ref21 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
|
|
2618
2414
|
return _objectSpread(_objectSpread(_objectSpread({}, bundle), shouldRestoreBundlePrice ? {
|
|
2619
2415
|
price: restoredBundlePrice,
|
|
2620
2416
|
bundle_selling_price: restoredBundlePrice
|
|
@@ -2791,8 +2587,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2791
2587
|
key: "submitSalesOrder",
|
|
2792
2588
|
value: (function () {
|
|
2793
2589
|
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
|
|
2794
|
-
var _this$otherParams6, _this$otherParams7, _this$otherParams8, _this$otherParams9;
|
|
2795
|
-
var inferredPaymentStatus, submitParams;
|
|
2590
|
+
var _params$smallTicketDa, _this$otherParams6, _this$otherParams7, _this$otherParams8, _this$otherParams9;
|
|
2591
|
+
var inferredPaymentStatus, smallTicketDataFlag, submitParams;
|
|
2796
2592
|
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
2797
2593
|
while (1) switch (_context27.prev = _context27.next) {
|
|
2798
2594
|
case 0:
|
|
@@ -2804,6 +2600,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2804
2600
|
case 2:
|
|
2805
2601
|
// this.store.order.persistTempOrder();
|
|
2806
2602
|
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();
|
|
2807
2604
|
submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
2808
2605
|
cacheId: this.cacheId,
|
|
2809
2606
|
platform: (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform,
|
|
@@ -2815,15 +2612,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2815
2612
|
payments: params.payments
|
|
2816
2613
|
} : {}), inferredPaymentStatus !== undefined ? {
|
|
2817
2614
|
paymentStatus: inferredPaymentStatus
|
|
2818
|
-
} : {}),
|
|
2819
|
-
smallTicketDataFlag:
|
|
2615
|
+
} : {}), smallTicketDataFlag !== undefined ? {
|
|
2616
|
+
smallTicketDataFlag: smallTicketDataFlag
|
|
2820
2617
|
} : {}), (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== undefined ? {
|
|
2821
2618
|
confirmPendingVoucherPayments: params.confirmPendingVoucherPayments
|
|
2822
2619
|
} : {}), (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
|
|
2823
2620
|
enhancePayload: params.enhancePayload
|
|
2824
2621
|
} : {});
|
|
2825
|
-
return _context27.abrupt("return", this.store.order.submitTempOrder(submitParams));
|
|
2826
|
-
case
|
|
2622
|
+
return _context27.abrupt("return", this.shouldUseCheckoutSyncTask() ? this.store.order.submitTempOrder(submitParams) : this.store.order.submitTempOrderAsync(submitParams));
|
|
2623
|
+
case 6:
|
|
2827
2624
|
case "end":
|
|
2828
2625
|
return _context27.stop();
|
|
2829
2626
|
}
|
|
@@ -2835,10 +2632,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2835
2632
|
return submitSalesOrder;
|
|
2836
2633
|
}())
|
|
2837
2634
|
}, {
|
|
2838
|
-
key: "
|
|
2635
|
+
key: "submitTempOrderAsync",
|
|
2839
2636
|
value: function () {
|
|
2840
|
-
var
|
|
2841
|
-
var _params$
|
|
2637
|
+
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
|
|
2638
|
+
var _params$smallTicketDa2, _this$otherParams10, _this$otherParams11, _this$otherParams12, _this$otherParams13;
|
|
2639
|
+
var inferredPaymentStatus, smallTicketDataFlag, submitParams;
|
|
2842
2640
|
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
2843
2641
|
while (1) switch (_context28.prev = _context28.next) {
|
|
2844
2642
|
case 0:
|
|
@@ -2847,83 +2645,68 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2847
2645
|
break;
|
|
2848
2646
|
}
|
|
2849
2647
|
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 模块支持');
|
|
2885
2648
|
case 2:
|
|
2886
2649
|
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();
|
|
2887
2651
|
submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
2888
2652
|
cacheId: this.cacheId,
|
|
2889
|
-
platform: (_this$
|
|
2890
|
-
businessCode: ((_this$
|
|
2653
|
+
platform: (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.platform,
|
|
2654
|
+
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),
|
|
2891
2655
|
channel: this.getSubmitOrderSalesChannel(),
|
|
2892
|
-
type: (_this$
|
|
2656
|
+
type: (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.type,
|
|
2657
|
+
request_unique_idempotency_token: this.store.order.generateIdempotencyToken()
|
|
2893
2658
|
}, (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
|
|
2894
2659
|
payments: params.payments
|
|
2895
2660
|
} : {}), inferredPaymentStatus !== undefined ? {
|
|
2896
2661
|
paymentStatus: inferredPaymentStatus
|
|
2897
|
-
} : {}),
|
|
2898
|
-
smallTicketDataFlag:
|
|
2662
|
+
} : {}), smallTicketDataFlag !== undefined ? {
|
|
2663
|
+
smallTicketDataFlag: smallTicketDataFlag
|
|
2899
2664
|
} : {}), (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== undefined ? {
|
|
2900
2665
|
confirmPendingVoucherPayments: params.confirmPendingVoucherPayments
|
|
2901
2666
|
} : {}), (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
|
|
2902
2667
|
enhancePayload: params.enhancePayload
|
|
2903
2668
|
} : {});
|
|
2904
|
-
return
|
|
2905
|
-
case
|
|
2669
|
+
return _context28.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
|
|
2670
|
+
case 6:
|
|
2906
2671
|
case "end":
|
|
2907
|
-
return
|
|
2672
|
+
return _context28.stop();
|
|
2908
2673
|
}
|
|
2909
|
-
},
|
|
2674
|
+
}, _callee28, this);
|
|
2910
2675
|
}));
|
|
2911
|
-
function submitTempOrderAsync(
|
|
2676
|
+
function submitTempOrderAsync(_x22) {
|
|
2912
2677
|
return _submitTempOrderAsync.apply(this, arguments);
|
|
2913
2678
|
}
|
|
2914
2679
|
return submitTempOrderAsync;
|
|
2915
2680
|
}()
|
|
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
|
+
}
|
|
2916
2699
|
}, {
|
|
2917
2700
|
key: "printLocalOrderReceipt",
|
|
2918
2701
|
value: function () {
|
|
2919
|
-
var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2920
|
-
var _this$
|
|
2702
|
+
var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(lookup) {
|
|
2703
|
+
var _this$otherParams15, _this$otherParams16, _this$otherParams17, _this$otherParams18;
|
|
2921
2704
|
var hasLookup, lookupPayload, context, payload, response, _this$store$order$app, _this$store$order5, _data;
|
|
2922
|
-
return _regeneratorRuntime().wrap(function
|
|
2923
|
-
while (1) switch (
|
|
2705
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
2706
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
2924
2707
|
case 0:
|
|
2925
2708
|
if (this.store.order) {
|
|
2926
|
-
|
|
2709
|
+
_context29.next = 2;
|
|
2927
2710
|
break;
|
|
2928
2711
|
}
|
|
2929
2712
|
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
@@ -2935,10 +2718,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2935
2718
|
external_sale_number: lookup
|
|
2936
2719
|
};
|
|
2937
2720
|
context = {
|
|
2938
|
-
platform: (_this$
|
|
2939
|
-
businessCode: ((_this$
|
|
2721
|
+
platform: (_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.platform,
|
|
2722
|
+
businessCode: ((_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.businessCode) || ((_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.business_code),
|
|
2940
2723
|
channel: this.getSubmitOrderSalesChannel(),
|
|
2941
|
-
type: (_this$
|
|
2724
|
+
type: (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.type
|
|
2942
2725
|
};
|
|
2943
2726
|
payload = hasLookup ? _objectSpread(_objectSpread({}, lookupPayload), {}, {
|
|
2944
2727
|
lookup_order_from_db: 1,
|
|
@@ -2954,28 +2737,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2954
2737
|
channel: context.channel,
|
|
2955
2738
|
type: context.type
|
|
2956
2739
|
});
|
|
2957
|
-
|
|
2740
|
+
_context29.next = 8;
|
|
2958
2741
|
return this.request.post('/local/print-order', payload, {
|
|
2959
2742
|
osServer: true,
|
|
2960
2743
|
customToast: function customToast() {}
|
|
2961
2744
|
});
|
|
2962
2745
|
case 8:
|
|
2963
|
-
response =
|
|
2746
|
+
response = _context29.sent;
|
|
2964
2747
|
if (hasLookup) {
|
|
2965
|
-
|
|
2748
|
+
_context29.next = 12;
|
|
2966
2749
|
break;
|
|
2967
2750
|
}
|
|
2968
|
-
|
|
2751
|
+
_context29.next = 12;
|
|
2969
2752
|
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);
|
|
2970
2753
|
case 12:
|
|
2971
|
-
return
|
|
2754
|
+
return _context29.abrupt("return", response);
|
|
2972
2755
|
case 13:
|
|
2973
2756
|
case "end":
|
|
2974
|
-
return
|
|
2757
|
+
return _context29.stop();
|
|
2975
2758
|
}
|
|
2976
|
-
},
|
|
2759
|
+
}, _callee29, this);
|
|
2977
2760
|
}));
|
|
2978
|
-
function printLocalOrderReceipt(
|
|
2761
|
+
function printLocalOrderReceipt(_x23) {
|
|
2979
2762
|
return _printLocalOrderReceipt.apply(this, arguments);
|
|
2980
2763
|
}
|
|
2981
2764
|
return printLocalOrderReceipt;
|
|
@@ -2989,42 +2772,44 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2989
2772
|
if (!amountSnapshot) return undefined;
|
|
2990
2773
|
try {
|
|
2991
2774
|
return new Decimal(amountSnapshot.amountGap || 0).lte(0) ? 'paid' : undefined;
|
|
2992
|
-
} catch (
|
|
2775
|
+
} catch (_unused2) {
|
|
2993
2776
|
return undefined;
|
|
2994
2777
|
}
|
|
2995
2778
|
}
|
|
2996
2779
|
}, {
|
|
2997
2780
|
key: "syncPaymentsToOrder",
|
|
2998
2781
|
value: function () {
|
|
2999
|
-
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3000
|
-
var
|
|
2782
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
|
|
2783
|
+
var _ref22, _params$businessCode, _this$otherParams19, _this$otherParams20, _params$channel;
|
|
3001
2784
|
var businessCode, channel, syncParams, syncState, payments, syncResult, latestPayments, amountSnapshot, orderSnapshot, syncPayload;
|
|
3002
|
-
return _regeneratorRuntime().wrap(function
|
|
3003
|
-
while (1) switch (
|
|
2785
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
2786
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
3004
2787
|
case 0:
|
|
3005
2788
|
if (this.store.order) {
|
|
3006
|
-
|
|
2789
|
+
_context30.next = 2;
|
|
3007
2790
|
break;
|
|
3008
2791
|
}
|
|
3009
2792
|
throw new Error('order 模块未初始化');
|
|
3010
2793
|
case 2:
|
|
3011
|
-
businessCode = (
|
|
3012
|
-
channel = (_params$
|
|
3013
|
-
syncParams = _objectSpread(_objectSpread(_objectSpread({}, params),
|
|
2794
|
+
businessCode = (_ref22 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.businessCode) !== null && _ref22 !== void 0 ? _ref22 : (_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.business_code;
|
|
2795
|
+
channel = (_params$channel = params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel();
|
|
2796
|
+
syncParams = _objectSpread(_objectSpread(_objectSpread({}, params), {}, {
|
|
2797
|
+
checkoutSyncTaskEnabled: this.shouldUseCheckoutSyncTask()
|
|
2798
|
+
}, businessCode !== undefined ? {
|
|
3014
2799
|
businessCode: businessCode
|
|
3015
2800
|
} : {}), channel !== undefined ? {
|
|
3016
2801
|
channel: channel
|
|
3017
2802
|
} : {});
|
|
3018
2803
|
syncState = this.store.order.getOrderSyncState();
|
|
3019
2804
|
if (!(params.submitWhenPaid && syncState === 'submitting')) {
|
|
3020
|
-
|
|
2805
|
+
_context30.next = 9;
|
|
3021
2806
|
break;
|
|
3022
2807
|
}
|
|
3023
2808
|
this.queueLatestAutoPaymentSync();
|
|
3024
|
-
return
|
|
2809
|
+
return _context30.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
|
|
3025
2810
|
case 9:
|
|
3026
2811
|
payments = params.payments || [];
|
|
3027
|
-
|
|
2812
|
+
_context30.next = 12;
|
|
3028
2813
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncStart, {
|
|
3029
2814
|
payments: payments,
|
|
3030
2815
|
params: syncParams,
|
|
@@ -3032,11 +2817,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3032
2817
|
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
3033
2818
|
});
|
|
3034
2819
|
case 12:
|
|
3035
|
-
|
|
3036
|
-
|
|
2820
|
+
_context30.prev = 12;
|
|
2821
|
+
_context30.next = 15;
|
|
3037
2822
|
return this.store.order.syncPaymentsToOrder(syncParams);
|
|
3038
2823
|
case 15:
|
|
3039
|
-
syncResult =
|
|
2824
|
+
syncResult = _context30.sent;
|
|
3040
2825
|
latestPayments = this.store.order.getOrderPayments();
|
|
3041
2826
|
amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
3042
2827
|
orderSnapshot = this.store.order.getOrderSnapshot();
|
|
@@ -3054,25 +2839,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3054
2839
|
depositAmount: syncResult.depositAmount,
|
|
3055
2840
|
orderExpectedAmount: syncResult.orderExpectedAmount
|
|
3056
2841
|
};
|
|
3057
|
-
|
|
2842
|
+
_context30.next = 22;
|
|
3058
2843
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, syncPayload);
|
|
3059
2844
|
case 22:
|
|
3060
2845
|
if (!(syncResult.isDepositFullyPaid && !syncResult.isOrderFullyPaid)) {
|
|
3061
|
-
|
|
2846
|
+
_context30.next = 25;
|
|
3062
2847
|
break;
|
|
3063
2848
|
}
|
|
3064
|
-
|
|
2849
|
+
_context30.next = 25;
|
|
3065
2850
|
return this.effectsEmit(BaseSalesHookNames.onDepositPaymentSyncEnd, syncPayload);
|
|
3066
2851
|
case 25:
|
|
3067
2852
|
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
3068
|
-
return
|
|
2853
|
+
return _context30.abrupt("return", syncResult);
|
|
3069
2854
|
case 29:
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
2855
|
+
_context30.prev = 29;
|
|
2856
|
+
_context30.t0 = _context30["catch"](12);
|
|
2857
|
+
_context30.next = 33;
|
|
3073
2858
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
|
|
3074
2859
|
ok: false,
|
|
3075
|
-
error:
|
|
2860
|
+
error: _context30.t0,
|
|
3076
2861
|
payments: this.store.order.getOrderPayments(),
|
|
3077
2862
|
params: syncParams,
|
|
3078
2863
|
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
@@ -3080,14 +2865,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3080
2865
|
});
|
|
3081
2866
|
case 33:
|
|
3082
2867
|
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
3083
|
-
throw
|
|
2868
|
+
throw _context30.t0;
|
|
3084
2869
|
case 35:
|
|
3085
2870
|
case "end":
|
|
3086
|
-
return
|
|
2871
|
+
return _context30.stop();
|
|
3087
2872
|
}
|
|
3088
|
-
},
|
|
2873
|
+
}, _callee30, this, [[12, 29]]);
|
|
3089
2874
|
}));
|
|
3090
|
-
function syncPaymentsToOrder(
|
|
2875
|
+
function syncPaymentsToOrder(_x24) {
|
|
3091
2876
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
3092
2877
|
}
|
|
3093
2878
|
return syncPaymentsToOrder;
|
|
@@ -3124,58 +2909,58 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3124
2909
|
}, {
|
|
3125
2910
|
key: "scheduleQueuedAutoPaymentSyncFlush",
|
|
3126
2911
|
value: function scheduleQueuedAutoPaymentSyncFlush() {
|
|
3127
|
-
var
|
|
2912
|
+
var _this11 = this;
|
|
3128
2913
|
var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;
|
|
3129
2914
|
if (!this.queuedAutoPaymentSync) return;
|
|
3130
2915
|
if (this.autoPaymentSyncTimer) return;
|
|
3131
2916
|
this.autoPaymentSyncTimer = setTimeout(function () {
|
|
3132
|
-
|
|
3133
|
-
void
|
|
2917
|
+
_this11.autoPaymentSyncTimer = null;
|
|
2918
|
+
void _this11.flushQueuedAutoPaymentSync();
|
|
3134
2919
|
}, delay);
|
|
3135
2920
|
}
|
|
3136
2921
|
}, {
|
|
3137
2922
|
key: "flushQueuedAutoPaymentSync",
|
|
3138
2923
|
value: function () {
|
|
3139
|
-
var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2924
|
+
var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
|
|
3140
2925
|
var payments;
|
|
3141
|
-
return _regeneratorRuntime().wrap(function
|
|
3142
|
-
while (1) switch (
|
|
2926
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
2927
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
3143
2928
|
case 0:
|
|
3144
2929
|
if (this.store.order) {
|
|
3145
|
-
|
|
2930
|
+
_context31.next = 2;
|
|
3146
2931
|
break;
|
|
3147
2932
|
}
|
|
3148
|
-
return
|
|
2933
|
+
return _context31.abrupt("return");
|
|
3149
2934
|
case 2:
|
|
3150
2935
|
if (!(!this.queuedAutoPaymentSync || this.autoPaymentSyncFlushing)) {
|
|
3151
|
-
|
|
2936
|
+
_context31.next = 4;
|
|
3152
2937
|
break;
|
|
3153
2938
|
}
|
|
3154
|
-
return
|
|
2939
|
+
return _context31.abrupt("return");
|
|
3155
2940
|
case 4:
|
|
3156
2941
|
if (!(this.store.order.getOrderSyncState() === 'submitting')) {
|
|
3157
|
-
|
|
2942
|
+
_context31.next = 7;
|
|
3158
2943
|
break;
|
|
3159
2944
|
}
|
|
3160
2945
|
this.scheduleQueuedAutoPaymentSyncFlush();
|
|
3161
|
-
return
|
|
2946
|
+
return _context31.abrupt("return");
|
|
3162
2947
|
case 7:
|
|
3163
2948
|
this.autoPaymentSyncFlushing = true;
|
|
3164
|
-
|
|
2949
|
+
_context31.prev = 8;
|
|
3165
2950
|
case 9:
|
|
3166
2951
|
if (!this.queuedAutoPaymentSync) {
|
|
3167
|
-
|
|
2952
|
+
_context31.next = 18;
|
|
3168
2953
|
break;
|
|
3169
2954
|
}
|
|
3170
2955
|
this.queuedAutoPaymentSync = false;
|
|
3171
2956
|
payments = this.store.order.getOrderPayments();
|
|
3172
2957
|
if (payments.length) {
|
|
3173
|
-
|
|
2958
|
+
_context31.next = 14;
|
|
3174
2959
|
break;
|
|
3175
2960
|
}
|
|
3176
|
-
return
|
|
2961
|
+
return _context31.abrupt("continue", 9);
|
|
3177
2962
|
case 14:
|
|
3178
|
-
|
|
2963
|
+
_context31.next = 16;
|
|
3179
2964
|
return this.syncPaymentsToOrder({
|
|
3180
2965
|
payments: payments,
|
|
3181
2966
|
paymentStatus: this.getPaymentStatusForSync(payments),
|
|
@@ -3183,94 +2968,44 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3183
2968
|
smallTicketDataFlag: 1
|
|
3184
2969
|
});
|
|
3185
2970
|
case 16:
|
|
3186
|
-
|
|
2971
|
+
_context31.next = 9;
|
|
3187
2972
|
break;
|
|
3188
2973
|
case 18:
|
|
3189
|
-
|
|
2974
|
+
_context31.next = 23;
|
|
3190
2975
|
break;
|
|
3191
2976
|
case 20:
|
|
3192
|
-
|
|
3193
|
-
|
|
2977
|
+
_context31.prev = 20;
|
|
2978
|
+
_context31.t0 = _context31["catch"](8);
|
|
3194
2979
|
this.logError('queued auto sync payments failed', {
|
|
3195
|
-
error:
|
|
2980
|
+
error: _context31.t0 instanceof Error ? _context31.t0.message : String(_context31.t0)
|
|
3196
2981
|
});
|
|
3197
2982
|
case 23:
|
|
3198
|
-
|
|
2983
|
+
_context31.prev = 23;
|
|
3199
2984
|
this.autoPaymentSyncFlushing = false;
|
|
3200
2985
|
if (this.queuedAutoPaymentSync) {
|
|
3201
2986
|
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
3202
2987
|
}
|
|
3203
|
-
return
|
|
2988
|
+
return _context31.finish(23);
|
|
3204
2989
|
case 27:
|
|
3205
2990
|
case "end":
|
|
3206
|
-
return
|
|
2991
|
+
return _context31.stop();
|
|
3207
2992
|
}
|
|
3208
|
-
},
|
|
2993
|
+
}, _callee31, this, [[8, 20, 23, 27]]);
|
|
3209
2994
|
}));
|
|
3210
2995
|
function flushQueuedAutoPaymentSync() {
|
|
3211
2996
|
return _flushQueuedAutoPaymentSync.apply(this, arguments);
|
|
3212
2997
|
}
|
|
3213
2998
|
return flushQueuedAutoPaymentSync;
|
|
3214
|
-
}()
|
|
3215
|
-
/**
|
|
3216
|
-
* 同步兼容入口。无法等待 IoT 短号时,按调用当下的 device_id 或 LOCAL 生成。
|
|
3217
|
-
*/
|
|
2999
|
+
}() /** 追加单个支付项到当前订单。 */
|
|
3218
3000
|
}, {
|
|
3219
3001
|
key: "addOrderPayment",
|
|
3220
3002
|
value: function addOrderPayment(payment) {
|
|
3221
|
-
var
|
|
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,
|
|
3003
|
+
var _this$otherParams21,
|
|
3269
3004
|
_paymentRecord$paymen,
|
|
3270
3005
|
_paymentRecord$create,
|
|
3271
|
-
|
|
3006
|
+
_ref23,
|
|
3272
3007
|
_paymentRecord$origin,
|
|
3273
|
-
|
|
3008
|
+
_this12 = this;
|
|
3274
3009
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
3275
3010
|
var paymentRecord = payment;
|
|
3276
3011
|
var paymentAmount = new Decimal(paymentRecord.amount || 0);
|
|
@@ -3281,26 +3016,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3281
3016
|
return this.store.order.getOrderPayments();
|
|
3282
3017
|
}
|
|
3283
3018
|
var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
|
|
3284
|
-
var shopWalletPassId = (_this$
|
|
3019
|
+
var shopWalletPassId = (_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.shop_wallet_pass_id;
|
|
3285
3020
|
if (shopWalletPassId !== undefined && shopWalletPassId !== null) {
|
|
3286
3021
|
metadata.shop_wallet_pass_id = shopWalletPassId;
|
|
3287
3022
|
}
|
|
3288
|
-
|
|
3023
|
+
if (!metadata.unique_payment_number) {
|
|
3024
|
+
metadata.unique_payment_number = createUuidV4();
|
|
3025
|
+
}
|
|
3289
3026
|
var paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
3290
3027
|
var paymentTime = (_paymentRecord$paymen = paymentRecord.payment_time) !== null && _paymentRecord$paymen !== void 0 ? _paymentRecord$paymen : paymentTimestamp;
|
|
3291
3028
|
var createdAt = (_paymentRecord$create = paymentRecord.created_at) !== null && _paymentRecord$create !== void 0 ? _paymentRecord$create : paymentTimestamp;
|
|
3292
3029
|
var serviceCharge = paymentRecord.service_charge && _typeof(paymentRecord.service_charge) === 'object' ? paymentRecord.service_charge : null;
|
|
3293
|
-
var calculatedServiceFee = serviceCharge ? new Decimal((
|
|
3294
|
-
var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread({},
|
|
3030
|
+
var calculatedServiceFee = serviceCharge ? new Decimal((_ref23 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref23 !== void 0 ? _ref23 : 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
|
|
3031
|
+
var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread({}, paymentRecord), calculatedServiceFee !== undefined ? {
|
|
3295
3032
|
service_fee: calculatedServiceFee
|
|
3296
3033
|
} : {}), {}, {
|
|
3297
3034
|
metadata: metadata,
|
|
3298
3035
|
payment_time: paymentTime,
|
|
3299
3036
|
created_at: createdAt
|
|
3300
3037
|
}));
|
|
3301
|
-
if (paymentRecord.status === 'payment_pending') {
|
|
3302
|
-
return payments;
|
|
3303
|
-
}
|
|
3304
3038
|
var amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
3305
3039
|
var syncState = this.store.order.getOrderSyncState();
|
|
3306
3040
|
if (amountSnapshot) {
|
|
@@ -3314,7 +3048,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3314
3048
|
submitWhenPaid: true,
|
|
3315
3049
|
smallTicketDataFlag: 1
|
|
3316
3050
|
}).catch(function (error) {
|
|
3317
|
-
|
|
3051
|
+
_this12.logError('auto sync payments failed', {
|
|
3318
3052
|
error: error instanceof Error ? error.message : String(error)
|
|
3319
3053
|
});
|
|
3320
3054
|
});
|
|
@@ -3325,131 +3059,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3325
3059
|
/** 更新当前订单中的指定支付项。 */
|
|
3326
3060
|
}, {
|
|
3327
3061
|
key: "updateOrderPayment",
|
|
3328
|
-
value:
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
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
|
-
}() /** 删除当前订单中的指定支付项。 */)
|
|
3062
|
+
value: function updateOrderPayment(paymentIdentity, updates) {
|
|
3063
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
3064
|
+
return this.store.order.updateOrderPayment(paymentIdentity, updates);
|
|
3065
|
+
}
|
|
3066
|
+
|
|
3067
|
+
/** 删除当前订单中的指定支付项。 */
|
|
3453
3068
|
}, {
|
|
3454
3069
|
key: "deleteOrderPayment",
|
|
3455
3070
|
value: function deleteOrderPayment(paymentIdentity) {
|
|
@@ -3464,42 +3079,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3464
3079
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
3465
3080
|
return this.store.order.updateVoucherOrderPayments(payments, options);
|
|
3466
3081
|
}
|
|
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
|
-
}()
|
|
3492
3082
|
}, {
|
|
3493
3083
|
key: "confirmPendingVoucherPayments",
|
|
3494
3084
|
value: function confirmPendingVoucherPayments() {
|
|
3495
3085
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
3496
|
-
|
|
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;
|
|
3086
|
+
return this.store.order.confirmPendingVoucherPayments();
|
|
3503
3087
|
}
|
|
3504
3088
|
}, {
|
|
3505
3089
|
key: "discardPendingVoucherPayments",
|
|
@@ -3568,72 +3152,64 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3568
3152
|
});
|
|
3569
3153
|
return walletProducts;
|
|
3570
3154
|
}
|
|
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
|
-
}
|
|
3595
3155
|
}, {
|
|
3596
3156
|
key: "initWalletData",
|
|
3597
3157
|
value: function () {
|
|
3598
|
-
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3599
|
-
var
|
|
3600
|
-
var snapshot, walletBusinessData, result;
|
|
3601
|
-
return _regeneratorRuntime().wrap(function
|
|
3602
|
-
while (1) switch (
|
|
3603
|
-
case 0:
|
|
3158
|
+
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
|
|
3159
|
+
var _params$order_wait_pa, _ref24, _tempOrder$is_price_i;
|
|
3160
|
+
var snapshot, tempOrder, amount, walletBusinessData, result;
|
|
3161
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
3162
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
3163
|
+
case 0:
|
|
3604
3164
|
if (this.store.order) {
|
|
3605
|
-
|
|
3165
|
+
_context32.next = 2;
|
|
3606
3166
|
break;
|
|
3607
3167
|
}
|
|
3608
3168
|
throw new Error('order 模块未初始化');
|
|
3609
3169
|
case 2:
|
|
3610
3170
|
if (this.store.payment) {
|
|
3611
|
-
|
|
3171
|
+
_context32.next = 4;
|
|
3612
3172
|
break;
|
|
3613
3173
|
}
|
|
3614
3174
|
throw new Error('payment 模块未初始化');
|
|
3615
3175
|
case 4:
|
|
3616
3176
|
snapshot = this.store.order.getOrderSnapshot();
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3177
|
+
tempOrder = snapshot === null || snapshot === void 0 ? void 0 : snapshot.tempOrder;
|
|
3178
|
+
amount = snapshot === null || snapshot === void 0 ? void 0 : snapshot.amount;
|
|
3179
|
+
if (!(!tempOrder || !amount)) {
|
|
3180
|
+
_context32.next = 9;
|
|
3620
3181
|
break;
|
|
3621
3182
|
}
|
|
3622
|
-
return
|
|
3183
|
+
return _context32.abrupt("return", {
|
|
3623
3184
|
walletRecommendList: [],
|
|
3624
3185
|
userIdentificationCodes: [],
|
|
3625
3186
|
transformList: [],
|
|
3626
3187
|
noApplicableVoucher: [],
|
|
3627
3188
|
products: []
|
|
3628
3189
|
});
|
|
3629
|
-
case
|
|
3630
|
-
|
|
3190
|
+
case 9:
|
|
3191
|
+
walletBusinessData = _objectSpread({
|
|
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;
|
|
3631
3207
|
return this.store.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
|
|
3632
|
-
case
|
|
3633
|
-
result =
|
|
3634
|
-
|
|
3208
|
+
case 12:
|
|
3209
|
+
result = _context32.sent;
|
|
3210
|
+
_context32.next = 15;
|
|
3635
3211
|
return this.core.effects.emit("".concat(this.name, ":onWalletDataInitialized"), {
|
|
3636
|
-
orderId: snapshot
|
|
3212
|
+
orderId: snapshot.identity.orderId,
|
|
3637
3213
|
customerId: walletBusinessData.customer_id,
|
|
3638
3214
|
walletBusinessData: {
|
|
3639
3215
|
customer_id: walletBusinessData.customer_id,
|
|
@@ -3642,413 +3218,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3642
3218
|
},
|
|
3643
3219
|
timestamp: Date.now()
|
|
3644
3220
|
});
|
|
3645
|
-
case
|
|
3646
|
-
return
|
|
3647
|
-
case
|
|
3221
|
+
case 15:
|
|
3222
|
+
return _context32.abrupt("return", result);
|
|
3223
|
+
case 16:
|
|
3648
3224
|
case "end":
|
|
3649
|
-
return
|
|
3225
|
+
return _context32.stop();
|
|
3650
3226
|
}
|
|
3651
|
-
},
|
|
3227
|
+
}, _callee32, this);
|
|
3652
3228
|
}));
|
|
3653
|
-
function initWalletData(
|
|
3229
|
+
function initWalletData(_x25) {
|
|
3654
3230
|
return _initWalletData.apply(this, arguments);
|
|
3655
3231
|
}
|
|
3656
3232
|
return initWalletData;
|
|
3657
3233
|
}()
|
|
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
|
-
}()
|
|
4045
3234
|
/**
|
|
4046
3235
|
* 更新当前订单客户字段。
|
|
4047
3236
|
*
|
|
4048
3237
|
* 这是 PaymentModal 客户切换的订单事实入口;外部客户模块同步应由
|
|
4049
3238
|
* 调用方通过 onCustomerChange 回调完成。
|
|
4050
3239
|
*/
|
|
4051
|
-
)
|
|
4052
3240
|
}, {
|
|
4053
3241
|
key: "updateOrderCustomer",
|
|
4054
3242
|
value: function updateOrderCustomer(customer) {
|
|
@@ -4065,35 +3253,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4065
3253
|
}, {
|
|
4066
3254
|
key: "getPaymentMethodsAsync",
|
|
4067
3255
|
value: (function () {
|
|
4068
|
-
var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3256
|
+
var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
|
|
4069
3257
|
var response, paymentMethods;
|
|
4070
|
-
return _regeneratorRuntime().wrap(function
|
|
4071
|
-
while (1) switch (
|
|
3258
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
3259
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
4072
3260
|
case 0:
|
|
4073
|
-
|
|
4074
|
-
|
|
3261
|
+
_context33.prev = 0;
|
|
3262
|
+
_context33.next = 3;
|
|
4075
3263
|
return this.request.get('/pay/custom-payment/all', {
|
|
4076
3264
|
filterPaymentMethods: true
|
|
4077
3265
|
}, {
|
|
4078
3266
|
osServer: true
|
|
4079
3267
|
});
|
|
4080
3268
|
case 3:
|
|
4081
|
-
response =
|
|
3269
|
+
response = _context33.sent;
|
|
4082
3270
|
paymentMethods = (response === null || response === void 0 ? void 0 : response.data) || [];
|
|
4083
3271
|
this.paymentMethodsCache = Array.isArray(paymentMethods) ? _toConsumableArray(paymentMethods) : [];
|
|
4084
|
-
return
|
|
3272
|
+
return _context33.abrupt("return", this.getPaymentMethods());
|
|
4085
3273
|
case 9:
|
|
4086
|
-
|
|
4087
|
-
|
|
3274
|
+
_context33.prev = 9;
|
|
3275
|
+
_context33.t0 = _context33["catch"](0);
|
|
4088
3276
|
this.logWarning('getPaymentMethodsAsync: 获取支付方式列表失败,使用缓存列表', {
|
|
4089
|
-
error:
|
|
3277
|
+
error: _context33.t0 instanceof Error ? _context33.t0.message : String(_context33.t0)
|
|
4090
3278
|
});
|
|
4091
|
-
return
|
|
3279
|
+
return _context33.abrupt("return", this.getPaymentMethods());
|
|
4092
3280
|
case 13:
|
|
4093
3281
|
case "end":
|
|
4094
|
-
return
|
|
3282
|
+
return _context33.stop();
|
|
4095
3283
|
}
|
|
4096
|
-
},
|
|
3284
|
+
}, _callee33, this, [[0, 9]]);
|
|
4097
3285
|
}));
|
|
4098
3286
|
function getPaymentMethodsAsync() {
|
|
4099
3287
|
return _getPaymentMethodsAsync.apply(this, arguments);
|
|
@@ -4105,589 +3293,85 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4105
3293
|
value: function getPaymentMethods() {
|
|
4106
3294
|
return _toConsumableArray(this.paymentMethodsCache);
|
|
4107
3295
|
}
|
|
4108
|
-
}, {
|
|
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));
|
|
4133
|
-
}
|
|
4134
3296
|
|
|
4135
|
-
/**
|
|
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$window, _this$window$postMess;
|
|
4302
|
-
var amount, config, paymentMethod, roundingAmount, effectivePaymentAmount, beforePayments, beforePaymentStatus, uniquePaymentNumber, paymentTimestamp, actualPaidAmount, changeAmount, 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
|
-
if (!(!Number.isFinite(actualPaidAmount) || actualPaidAmount + 0.01 < amount)) {
|
|
4351
|
-
_context47.next = 25;
|
|
4352
|
-
break;
|
|
4353
|
-
}
|
|
4354
|
-
throw new Error('顾客实收现金不能小于支付金额');
|
|
4355
|
-
case 25:
|
|
4356
|
-
(_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, {
|
|
4357
|
-
module: 'till',
|
|
4358
|
-
key: 'open_till',
|
|
4359
|
-
data: {
|
|
4360
|
-
type: 'cash'
|
|
4361
|
-
}
|
|
4362
|
-
});
|
|
4363
|
-
payments = this.store.order.addOrderPayment({
|
|
4364
|
-
amount: amount.toFixed(2),
|
|
4365
|
-
code: paymentMethod.code,
|
|
4366
|
-
custom_payment_id: paymentMethod.id,
|
|
4367
|
-
name: paymentMethod.name,
|
|
4368
|
-
custom_payment_type: paymentMethod.type,
|
|
4369
|
-
voucher_id: 0,
|
|
4370
|
-
rounding_amount: roundingAmount.toFixed(2),
|
|
4371
|
-
metadata: {
|
|
4372
|
-
unique_payment_number: uniquePaymentNumber,
|
|
4373
|
-
actual_paid_amount: Number.isFinite(actualPaidAmount) ? actualPaidAmount : amount,
|
|
4374
|
-
change_given_amount: Number.isFinite(changeAmount) ? changeAmount : 0
|
|
4375
|
-
},
|
|
4376
|
-
payment_time: paymentTimestamp,
|
|
4377
|
-
created_at: paymentTimestamp
|
|
4378
|
-
});
|
|
4379
|
-
payment = payments.find(function (item) {
|
|
4380
|
-
var _item$metadata2;
|
|
4381
|
-
return (item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.unique_payment_number) === uniquePaymentNumber;
|
|
4382
|
-
});
|
|
4383
|
-
_context47.prev = 28;
|
|
4384
|
-
_context47.next = 31;
|
|
4385
|
-
return this.syncPaymentsToOrder({
|
|
4386
|
-
payments: payments,
|
|
4387
|
-
submitWhenPaid: true,
|
|
4388
|
-
smallTicketDataFlag: 1,
|
|
4389
|
-
confirmPendingVoucherPayments: true
|
|
4390
|
-
});
|
|
4391
|
-
case 31:
|
|
4392
|
-
syncResult = _context47.sent;
|
|
4393
|
-
if (!this.store.payment) {
|
|
4394
|
-
_context47.next = 37;
|
|
4395
|
-
break;
|
|
4396
|
-
}
|
|
4397
|
-
committed = this.getCommittedWalletAssets();
|
|
4398
|
-
walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
4399
|
-
_context47.next = 37;
|
|
4400
|
-
return this.publishWalletAssetsState(walletState);
|
|
4401
|
-
case 37:
|
|
4402
|
-
return _context47.abrupt("return", {
|
|
4403
|
-
payment: payment || {},
|
|
4404
|
-
payments: this.store.order.getOrderPayments(),
|
|
4405
|
-
syncResult: syncResult,
|
|
4406
|
-
isOrderFullyPaid: syncResult.isOrderFullyPaid
|
|
4407
|
-
});
|
|
4408
|
-
case 40:
|
|
4409
|
-
_context47.prev = 40;
|
|
4410
|
-
_context47.t0 = _context47["catch"](28);
|
|
4411
|
-
this.store.order.setOrderPayments(beforePayments);
|
|
4412
|
-
restoredTempOrder = this.store.order.getTempOrder();
|
|
4413
|
-
if (restoredTempOrder && beforePaymentStatus !== undefined) {
|
|
4414
|
-
restoredTempOrder.payment_status = beforePaymentStatus;
|
|
4415
|
-
this.store.order.persistTempOrder();
|
|
4416
|
-
}
|
|
4417
|
-
_context47.next = 47;
|
|
4418
|
-
return this.store.order.recalculateSummary({
|
|
4419
|
-
createIfMissing: true
|
|
4420
|
-
});
|
|
4421
|
-
case 47:
|
|
4422
|
-
throw _context47.t0;
|
|
4423
|
-
case 48:
|
|
4424
|
-
case "end":
|
|
4425
|
-
return _context47.stop();
|
|
4426
|
-
}
|
|
4427
|
-
}, _callee47, this, [[28, 40]]);
|
|
4428
|
-
}));
|
|
4429
|
-
function payCash(_x38) {
|
|
4430
|
-
return _payCash.apply(this, arguments);
|
|
4431
|
-
}
|
|
4432
|
-
return payCash;
|
|
4433
|
-
}()
|
|
4434
|
-
/**
|
|
4435
|
-
* 提交一次已由支付设备确认成功的非 Wallet 支付。
|
|
4436
|
-
*
|
|
4437
|
-
* 与 addOrderPayment 不同,本入口不会启动后台 fire-and-forget 同步;调用方会等待
|
|
4438
|
-
* 本次 payment、当前 pending Wallet 以及订单提交共同完成。任何同步失败都会恢复
|
|
4439
|
-
* 调用前的 payments 与 payment_status,便于 UI 安全解锁并重试。
|
|
4440
|
-
*/
|
|
4441
|
-
)
|
|
4442
|
-
}, {
|
|
4443
|
-
key: "commitPaymentMethodPayment",
|
|
4444
|
-
value: (function () {
|
|
4445
|
-
var _commitPaymentMethodPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(params) {
|
|
4446
|
-
var _this$store$order$get7, _this$store$order15, _this$store$order$get8, _params$metadata, _params$originAmount;
|
|
4447
|
-
var amount, paymentMethods, findPaymentMethod, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, beforePayments, beforePaymentStatus, paymentTimestamp, metadata, serviceCharge, serviceFee, payments, payment, syncResult, committed, walletState, restoredTempOrder;
|
|
4448
|
-
return _regeneratorRuntime().wrap(function _callee48$(_context48) {
|
|
4449
|
-
while (1) switch (_context48.prev = _context48.next) {
|
|
4450
|
-
case 0:
|
|
4451
|
-
if (this.store.order) {
|
|
4452
|
-
_context48.next = 2;
|
|
4453
|
-
break;
|
|
4454
|
-
}
|
|
4455
|
-
throw new Error('order 模块未初始化');
|
|
4456
|
-
case 2:
|
|
4457
|
-
amount = Number(params.amount || 0);
|
|
4458
|
-
if (!(!Number.isFinite(amount) || amount <= 0)) {
|
|
4459
|
-
_context48.next = 5;
|
|
4460
|
-
break;
|
|
4461
|
-
}
|
|
4462
|
-
throw new Error('支付金额必须大于 0');
|
|
4463
|
-
case 5:
|
|
4464
|
-
paymentMethods = this.getPaymentMethods();
|
|
4465
|
-
findPaymentMethod = function findPaymentMethod() {
|
|
4466
|
-
var methodCode = String(params.paymentMethodCode || '').toUpperCase();
|
|
4467
|
-
return paymentMethods.find(function (method) {
|
|
4468
|
-
var idMatched = params.paymentMethodId !== undefined && String(method.id) === String(params.paymentMethodId);
|
|
4469
|
-
var codeMatched = Boolean(methodCode) && String(method.code || '').toUpperCase() === methodCode;
|
|
4470
|
-
return (idMatched || codeMatched) && method.enabled !== false && method.enable !== false;
|
|
4471
|
-
});
|
|
4472
|
-
};
|
|
4473
|
-
paymentMethod = findPaymentMethod();
|
|
4474
|
-
if (paymentMethod) {
|
|
4475
|
-
_context48.next = 13;
|
|
4476
|
-
break;
|
|
4477
|
-
}
|
|
4478
|
-
_context48.next = 11;
|
|
4479
|
-
return this.getPaymentMethodsAsync();
|
|
4480
|
-
case 11:
|
|
4481
|
-
paymentMethods = _context48.sent;
|
|
4482
|
-
paymentMethod = findPaymentMethod();
|
|
4483
|
-
case 13:
|
|
4484
|
-
if (paymentMethod) {
|
|
4485
|
-
_context48.next = 15;
|
|
4486
|
-
break;
|
|
4487
|
-
}
|
|
4488
|
-
throw new Error("\u672A\u627E\u5230\u53EF\u7528\u7684\u652F\u4ED8\u65B9\u5F0F\uFF1A".concat(params.paymentMethodCode || params.paymentMethodId || ''));
|
|
4489
|
-
case 15:
|
|
4490
|
-
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);
|
|
4491
|
-
pendingWalletAmount = this.getPendingWalletPaymentAmount();
|
|
4492
|
-
amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
|
|
4493
|
-
if (!amountDue.lte(0)) {
|
|
4494
|
-
_context48.next = 20;
|
|
4495
|
-
break;
|
|
4496
|
-
}
|
|
4497
|
-
throw new Error('当前订单没有待支付金额');
|
|
4498
|
-
case 20:
|
|
4499
|
-
if (!new Decimal(amount).gt(amountDue.plus(0.01))) {
|
|
4500
|
-
_context48.next = 22;
|
|
4501
|
-
break;
|
|
4502
|
-
}
|
|
4503
|
-
throw new Error('支付金额超过当前待支付金额');
|
|
4504
|
-
case 22:
|
|
4505
|
-
beforePayments = cloneDeep(this.store.order.getOrderPayments());
|
|
4506
|
-
beforePaymentStatus = (_this$store$order$get8 = this.store.order.getTempOrder()) === null || _this$store$order$get8 === void 0 ? void 0 : _this$store$order$get8.payment_status;
|
|
4507
|
-
paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
4508
|
-
metadata = _objectSpread(_objectSpread({}, params.metadata || {}), {}, {
|
|
4509
|
-
unique_payment_number: ((_params$metadata = params.metadata) === null || _params$metadata === void 0 ? void 0 : _params$metadata.unique_payment_number) || createUuidV4()
|
|
4510
|
-
});
|
|
4511
|
-
serviceCharge = params.serviceCharge ? {
|
|
4512
|
-
amount: String(params.serviceCharge.amount || 0),
|
|
4513
|
-
percentage: String(params.serviceCharge.percentage || 0)
|
|
4514
|
-
} : undefined;
|
|
4515
|
-
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;
|
|
4516
|
-
payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, params.paymentData || {}), {}, {
|
|
4517
|
-
amount: amount.toFixed(2)
|
|
4518
|
-
}, params.originAmount !== undefined ? {
|
|
4519
|
-
origin_amount: Number(params.originAmount).toFixed(2)
|
|
4520
|
-
} : {}), {}, {
|
|
4521
|
-
code: paymentMethod.code,
|
|
4522
|
-
custom_payment_id: paymentMethod.id,
|
|
4523
|
-
name: paymentMethod.name,
|
|
4524
|
-
custom_payment_type: paymentMethod.type,
|
|
4525
|
-
voucher_id: 0
|
|
4526
|
-
}, serviceCharge ? {
|
|
4527
|
-
service_charge: serviceCharge
|
|
4528
|
-
} : {}), serviceFee !== undefined ? {
|
|
4529
|
-
service_fee: serviceFee
|
|
4530
|
-
} : {}), {}, {
|
|
4531
|
-
metadata: metadata,
|
|
4532
|
-
payment_time: paymentTimestamp,
|
|
4533
|
-
created_at: paymentTimestamp
|
|
4534
|
-
}));
|
|
4535
|
-
payment = payments.find(function (item) {
|
|
4536
|
-
var _item$metadata3;
|
|
4537
|
-
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;
|
|
4538
|
-
});
|
|
4539
|
-
_context48.prev = 30;
|
|
4540
|
-
_context48.next = 33;
|
|
4541
|
-
return this.syncPaymentsToOrder({
|
|
4542
|
-
payments: payments,
|
|
4543
|
-
submitWhenPaid: true,
|
|
4544
|
-
smallTicketDataFlag: 1,
|
|
4545
|
-
confirmPendingVoucherPayments: true
|
|
4546
|
-
});
|
|
4547
|
-
case 33:
|
|
4548
|
-
syncResult = _context48.sent;
|
|
4549
|
-
if (!this.store.payment) {
|
|
4550
|
-
_context48.next = 39;
|
|
4551
|
-
break;
|
|
4552
|
-
}
|
|
4553
|
-
committed = this.getCommittedWalletAssets();
|
|
4554
|
-
walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
4555
|
-
_context48.next = 39;
|
|
4556
|
-
return this.publishWalletAssetsState(walletState);
|
|
4557
|
-
case 39:
|
|
4558
|
-
return _context48.abrupt("return", {
|
|
4559
|
-
payment: payment || {},
|
|
4560
|
-
payments: this.store.order.getOrderPayments(),
|
|
4561
|
-
syncResult: syncResult,
|
|
4562
|
-
isOrderFullyPaid: syncResult.isOrderFullyPaid
|
|
4563
|
-
});
|
|
4564
|
-
case 42:
|
|
4565
|
-
_context48.prev = 42;
|
|
4566
|
-
_context48.t0 = _context48["catch"](30);
|
|
4567
|
-
this.store.order.setOrderPayments(beforePayments);
|
|
4568
|
-
restoredTempOrder = this.store.order.getTempOrder();
|
|
4569
|
-
if (restoredTempOrder && beforePaymentStatus !== undefined) {
|
|
4570
|
-
restoredTempOrder.payment_status = beforePaymentStatus;
|
|
4571
|
-
this.store.order.persistTempOrder();
|
|
4572
|
-
}
|
|
4573
|
-
_context48.next = 49;
|
|
4574
|
-
return this.store.order.recalculateSummary({
|
|
4575
|
-
createIfMissing: true
|
|
4576
|
-
});
|
|
4577
|
-
case 49:
|
|
4578
|
-
throw _context48.t0;
|
|
4579
|
-
case 50:
|
|
4580
|
-
case "end":
|
|
4581
|
-
return _context48.stop();
|
|
4582
|
-
}
|
|
4583
|
-
}, _callee48, this, [[30, 42]]);
|
|
4584
|
-
}));
|
|
4585
|
-
function commitPaymentMethodPayment(_x39) {
|
|
4586
|
-
return _commitPaymentMethodPayment.apply(this, arguments);
|
|
4587
|
-
}
|
|
4588
|
-
return commitPaymentMethodPayment;
|
|
4589
|
-
}()
|
|
4590
|
-
/**
|
|
4591
|
-
* 按当前店铺的现金舍入配置计算金额,供现金支付 UI 使用。
|
|
4592
|
-
*
|
|
4593
|
-
* 舍入开关取自 CASHMANUAL 支付方式;舍入规则取自
|
|
4594
|
-
* otherParams.order_rounding_setting,金额算法统一由 PaymentModule 维护。
|
|
4595
|
-
*/
|
|
4596
|
-
)
|
|
3297
|
+
/** 轻量舍入能力,供现金支付 UI 计算 rounding_amount。 */
|
|
4597
3298
|
}, {
|
|
4598
3299
|
key: "roundAmount",
|
|
4599
|
-
value:
|
|
4600
|
-
var
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
break;
|
|
4623
|
-
}
|
|
4624
|
-
throw new Error('payment 模块未初始化');
|
|
4625
|
-
case 6:
|
|
4626
|
-
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));
|
|
4627
|
-
case 7:
|
|
4628
|
-
case "end":
|
|
4629
|
-
return _context49.stop();
|
|
4630
|
-
}
|
|
4631
|
-
}, _callee49, this);
|
|
4632
|
-
}));
|
|
4633
|
-
function roundAmount(_x40) {
|
|
4634
|
-
return _roundAmount.apply(this, arguments);
|
|
4635
|
-
}
|
|
4636
|
-
return roundAmount;
|
|
4637
|
-
}()
|
|
3300
|
+
value: function roundAmount(params) {
|
|
3301
|
+
var amount = new Decimal(params.amount || 0);
|
|
3302
|
+
var interval = new Decimal(params.interval || 0.05);
|
|
3303
|
+
var rule = params.rule || 'standard_rounding';
|
|
3304
|
+
var quotient = amount.div(interval);
|
|
3305
|
+
var roundedQuotient;
|
|
3306
|
+
if (rule === 'always_up') {
|
|
3307
|
+
roundedQuotient = quotient.ceil();
|
|
3308
|
+
} else if (rule === 'always_down') {
|
|
3309
|
+
roundedQuotient = quotient.floor();
|
|
3310
|
+
} else if (rule === 'standard_down') {
|
|
3311
|
+
roundedQuotient = quotient.toDecimalPlaces(0, Decimal.ROUND_HALF_DOWN);
|
|
3312
|
+
} else {
|
|
3313
|
+
roundedQuotient = quotient.toDecimalPlaces(0, Decimal.ROUND_HALF_UP);
|
|
3314
|
+
}
|
|
3315
|
+
var roundedAmount = roundedQuotient.times(interval).toDecimalPlaces(2);
|
|
3316
|
+
return {
|
|
3317
|
+
originalAmount: amount.toFixed(2),
|
|
3318
|
+
roundedAmount: roundedAmount.toFixed(2),
|
|
3319
|
+
roundingDifference: roundedAmount.minus(amount).toFixed(2)
|
|
3320
|
+
};
|
|
3321
|
+
}
|
|
3322
|
+
|
|
4638
3323
|
/**
|
|
4639
3324
|
* 发送支付链接。
|
|
4640
3325
|
*
|
|
4641
3326
|
* 如果没有 orderIds 或显式 submitBeforeSend,会先提交当前本地订单到云端;
|
|
4642
3327
|
* 只有成功拿到远端 order_id 后才调用 OrderModule 发送邮件。
|
|
4643
3328
|
*/
|
|
4644
|
-
)
|
|
4645
3329
|
}, {
|
|
4646
3330
|
key: "sendCustomerPayLink",
|
|
4647
3331
|
value: (function () {
|
|
4648
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4649
|
-
var orderIds,
|
|
4650
|
-
return _regeneratorRuntime().wrap(function
|
|
4651
|
-
while (1) switch (
|
|
3332
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
|
|
3333
|
+
var orderIds, _ref25, _ref26, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
|
|
3334
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
3335
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
4652
3336
|
case 0:
|
|
4653
3337
|
if (this.store.order) {
|
|
4654
|
-
|
|
3338
|
+
_context34.next = 2;
|
|
4655
3339
|
break;
|
|
4656
3340
|
}
|
|
4657
3341
|
throw new Error('order 模块未初始化');
|
|
4658
3342
|
case 2:
|
|
4659
3343
|
orderIds = params.order_ids || params.orderIds || [];
|
|
4660
3344
|
if (!(!orderIds.length || params.submitBeforeSend)) {
|
|
4661
|
-
|
|
3345
|
+
_context34.next = 11;
|
|
4662
3346
|
break;
|
|
4663
3347
|
}
|
|
4664
|
-
|
|
3348
|
+
_context34.next = 6;
|
|
4665
3349
|
return this.submitSalesOrder({
|
|
4666
3350
|
smallTicketDataFlag: 1
|
|
4667
3351
|
});
|
|
4668
3352
|
case 6:
|
|
4669
|
-
submitResult =
|
|
4670
|
-
orderId = (
|
|
3353
|
+
submitResult = _context34.sent;
|
|
3354
|
+
orderId = (_ref25 = (_ref26 = (_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 && _ref26 !== void 0 ? _ref26 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref25 !== void 0 ? _ref25 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
|
|
4671
3355
|
if (orderId) {
|
|
4672
|
-
|
|
3356
|
+
_context34.next = 10;
|
|
4673
3357
|
break;
|
|
4674
3358
|
}
|
|
4675
3359
|
throw new Error('本地订单提交云端失败,无法发送支付链接');
|
|
4676
3360
|
case 10:
|
|
4677
3361
|
orderIds = [orderId];
|
|
4678
3362
|
case 11:
|
|
4679
|
-
return
|
|
3363
|
+
return _context34.abrupt("return", this.store.order.sendCustomerPayLink({
|
|
4680
3364
|
emails: params.emails,
|
|
4681
3365
|
notify_action: params.notify_action,
|
|
4682
3366
|
order_ids: orderIds
|
|
4683
3367
|
}));
|
|
4684
3368
|
case 12:
|
|
4685
3369
|
case "end":
|
|
4686
|
-
return
|
|
3370
|
+
return _context34.stop();
|
|
4687
3371
|
}
|
|
4688
|
-
},
|
|
3372
|
+
}, _callee34, this);
|
|
4689
3373
|
}));
|
|
4690
|
-
function sendCustomerPayLink(
|
|
3374
|
+
function sendCustomerPayLink(_x26) {
|
|
4691
3375
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
4692
3376
|
}
|
|
4693
3377
|
return sendCustomerPayLink;
|
|
@@ -4700,27 +3384,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4700
3384
|
}, {
|
|
4701
3385
|
key: "calculateProductBookingPrice",
|
|
4702
3386
|
value: function () {
|
|
4703
|
-
var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3387
|
+
var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
|
|
4704
3388
|
var _params$customer_id;
|
|
4705
3389
|
var quotation, customerId, authoritativeProduct, product;
|
|
4706
|
-
return _regeneratorRuntime().wrap(function
|
|
4707
|
-
while (1) switch (
|
|
3390
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
3391
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
4708
3392
|
case 0:
|
|
4709
3393
|
quotation = this.store.quotation;
|
|
4710
3394
|
customerId = (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : this.getCurrentOrderCustomerId();
|
|
4711
|
-
|
|
3395
|
+
_context35.next = 4;
|
|
4712
3396
|
return this.loadProductForPriceQuery(params, customerId);
|
|
4713
3397
|
case 4:
|
|
4714
|
-
authoritativeProduct =
|
|
3398
|
+
authoritativeProduct = _context35.sent;
|
|
4715
3399
|
product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
|
|
4716
|
-
|
|
3400
|
+
_context35.next = 8;
|
|
4717
3401
|
return this.loadQuotationForPriceQuery({
|
|
4718
3402
|
quotation: quotation,
|
|
4719
3403
|
customer_id: customerId,
|
|
4720
3404
|
channel: params.channel
|
|
4721
3405
|
});
|
|
4722
3406
|
case 8:
|
|
4723
|
-
return
|
|
3407
|
+
return _context35.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
|
|
4724
3408
|
product: product,
|
|
4725
3409
|
fallback_price: authoritativeProduct ? undefined : params.fallback_price,
|
|
4726
3410
|
customer_id: customerId,
|
|
@@ -4728,11 +3412,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4728
3412
|
})));
|
|
4729
3413
|
case 9:
|
|
4730
3414
|
case "end":
|
|
4731
|
-
return
|
|
3415
|
+
return _context35.stop();
|
|
4732
3416
|
}
|
|
4733
|
-
},
|
|
3417
|
+
}, _callee35, this);
|
|
4734
3418
|
}));
|
|
4735
|
-
function calculateProductBookingPrice(
|
|
3419
|
+
function calculateProductBookingPrice(_x27) {
|
|
4736
3420
|
return _calculateProductBookingPrice.apply(this, arguments);
|
|
4737
3421
|
}
|
|
4738
3422
|
return calculateProductBookingPrice;
|
|
@@ -4740,7 +3424,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4740
3424
|
}, {
|
|
4741
3425
|
key: "getQuotationCustomerScopeInfo",
|
|
4742
3426
|
value: function getQuotationCustomerScopeInfo() {
|
|
4743
|
-
var
|
|
3427
|
+
var _this13 = this;
|
|
4744
3428
|
var quotation = this.store.quotation;
|
|
4745
3429
|
if (quotation && typeof quotation.getQuotationCustomerScopeInfo === 'function') {
|
|
4746
3430
|
return quotation.getQuotationCustomerScopeInfo();
|
|
@@ -4752,7 +3436,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4752
3436
|
}).map(function (item) {
|
|
4753
3437
|
var localSeen = new Set();
|
|
4754
3438
|
var customers = item.customer.filter(function (customer) {
|
|
4755
|
-
var customerId =
|
|
3439
|
+
var customerId = _this13.normalizePriceContextCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
|
|
4756
3440
|
if (!customerId || localSeen.has(customerId)) return false;
|
|
4757
3441
|
localSeen.add(customerId);
|
|
4758
3442
|
if (!customerById.has(customerId)) customerById.set(customerId, customer);
|
|
@@ -4802,32 +3486,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4802
3486
|
}, {
|
|
4803
3487
|
key: "calculateProductBookingPrices",
|
|
4804
3488
|
value: function () {
|
|
4805
|
-
var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3489
|
+
var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(paramsList) {
|
|
4806
3490
|
var _paramsList$0$custome,
|
|
4807
3491
|
_paramsList$,
|
|
4808
|
-
|
|
3492
|
+
_this14 = this,
|
|
4809
3493
|
_paramsList$2;
|
|
4810
3494
|
var quotation, customerId, productMapsByGroup, groups;
|
|
4811
|
-
return _regeneratorRuntime().wrap(function
|
|
4812
|
-
while (1) switch (
|
|
3495
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
3496
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
4813
3497
|
case 0:
|
|
4814
3498
|
if (paramsList.length) {
|
|
4815
|
-
|
|
3499
|
+
_context37.next = 2;
|
|
4816
3500
|
break;
|
|
4817
3501
|
}
|
|
4818
|
-
return
|
|
3502
|
+
return _context37.abrupt("return", []);
|
|
4819
3503
|
case 2:
|
|
4820
3504
|
quotation = this.store.quotation;
|
|
4821
3505
|
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();
|
|
4822
3506
|
productMapsByGroup = new Map();
|
|
4823
3507
|
groups = new Map();
|
|
4824
3508
|
paramsList.forEach(function (params) {
|
|
4825
|
-
var
|
|
3509
|
+
var _this14$otherParams;
|
|
4826
3510
|
var product = params.product || {};
|
|
4827
|
-
var productId =
|
|
3511
|
+
var productId = _this14.getPriceQueryProductId(product);
|
|
4828
3512
|
if (productId === null) return;
|
|
4829
|
-
var schedule =
|
|
4830
|
-
var channel = params.channel || ((
|
|
3513
|
+
var schedule = _this14.getPriceQuerySchedule(params);
|
|
3514
|
+
var channel = params.channel || ((_this14$otherParams = _this14.otherParams) === null || _this14$otherParams === void 0 ? void 0 : _this14$otherParams.channel);
|
|
4831
3515
|
var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || ''].join('|');
|
|
4832
3516
|
var group = groups.get(groupKey) || {
|
|
4833
3517
|
ids: new Set(),
|
|
@@ -4837,51 +3521,51 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4837
3521
|
group.ids.add(productId);
|
|
4838
3522
|
groups.set(groupKey, group);
|
|
4839
3523
|
});
|
|
4840
|
-
|
|
3524
|
+
_context37.next = 9;
|
|
4841
3525
|
return Promise.all(Array.from(groups.entries()).map( /*#__PURE__*/function () {
|
|
4842
|
-
var
|
|
4843
|
-
var
|
|
4844
|
-
return _regeneratorRuntime().wrap(function
|
|
4845
|
-
while (1) switch (
|
|
3526
|
+
var _ref28 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(_ref27) {
|
|
3527
|
+
var _ref29, groupKey, group, productsById;
|
|
3528
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
3529
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
4846
3530
|
case 0:
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
return
|
|
3531
|
+
_ref29 = _slicedToArray(_ref27, 2), groupKey = _ref29[0], group = _ref29[1];
|
|
3532
|
+
_context36.next = 3;
|
|
3533
|
+
return _this14.loadProductsForPriceQuery({
|
|
4850
3534
|
ids: Array.from(group.ids),
|
|
4851
3535
|
schedule: group.schedule,
|
|
4852
3536
|
customerId: customerId,
|
|
4853
3537
|
channel: group.channel
|
|
4854
3538
|
});
|
|
4855
3539
|
case 3:
|
|
4856
|
-
productsById =
|
|
3540
|
+
productsById = _context36.sent;
|
|
4857
3541
|
productMapsByGroup.set(groupKey, productsById);
|
|
4858
3542
|
case 5:
|
|
4859
3543
|
case "end":
|
|
4860
|
-
return
|
|
3544
|
+
return _context36.stop();
|
|
4861
3545
|
}
|
|
4862
|
-
},
|
|
3546
|
+
}, _callee36);
|
|
4863
3547
|
}));
|
|
4864
|
-
return function (
|
|
4865
|
-
return
|
|
3548
|
+
return function (_x29) {
|
|
3549
|
+
return _ref28.apply(this, arguments);
|
|
4866
3550
|
};
|
|
4867
3551
|
}()));
|
|
4868
3552
|
case 9:
|
|
4869
|
-
|
|
3553
|
+
_context37.next = 11;
|
|
4870
3554
|
return this.loadQuotationForPriceQuery({
|
|
4871
3555
|
quotation: quotation,
|
|
4872
3556
|
customer_id: customerId,
|
|
4873
3557
|
channel: (_paramsList$2 = paramsList[0]) === null || _paramsList$2 === void 0 ? void 0 : _paramsList$2.channel
|
|
4874
3558
|
});
|
|
4875
3559
|
case 11:
|
|
4876
|
-
return
|
|
4877
|
-
var
|
|
3560
|
+
return _context37.abrupt("return", paramsList.map(function (params) {
|
|
3561
|
+
var _this14$otherParams2, _productMapsByGroup$g;
|
|
4878
3562
|
var productInput = params.product || {};
|
|
4879
|
-
var productId =
|
|
4880
|
-
var schedule =
|
|
4881
|
-
var channel = params.channel || ((
|
|
3563
|
+
var productId = _this14.getPriceQueryProductId(productInput);
|
|
3564
|
+
var schedule = _this14.getPriceQuerySchedule(params);
|
|
3565
|
+
var channel = params.channel || ((_this14$otherParams2 = _this14.otherParams) === null || _this14$otherParams2 === void 0 ? void 0 : _this14$otherParams2.channel);
|
|
4882
3566
|
var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || ''].join('|');
|
|
4883
3567
|
var authoritativeProduct = productId === null ? null : ((_productMapsByGroup$g = productMapsByGroup.get(groupKey)) === null || _productMapsByGroup$g === void 0 ? void 0 : _productMapsByGroup$g.get(productId)) || null;
|
|
4884
|
-
var product =
|
|
3568
|
+
var product = _this14.mergeProductForPriceQuery(productInput, authoritativeProduct);
|
|
4885
3569
|
return calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
|
|
4886
3570
|
product: product,
|
|
4887
3571
|
fallback_price: authoritativeProduct ? undefined : params.fallback_price,
|
|
@@ -4891,11 +3575,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4891
3575
|
}));
|
|
4892
3576
|
case 12:
|
|
4893
3577
|
case "end":
|
|
4894
|
-
return
|
|
3578
|
+
return _context37.stop();
|
|
4895
3579
|
}
|
|
4896
|
-
},
|
|
3580
|
+
}, _callee37, this);
|
|
4897
3581
|
}));
|
|
4898
|
-
function calculateProductBookingPrices(
|
|
3582
|
+
function calculateProductBookingPrices(_x28) {
|
|
4899
3583
|
return _calculateProductBookingPrices.apply(this, arguments);
|
|
4900
3584
|
}
|
|
4901
3585
|
return calculateProductBookingPrices;
|
|
@@ -4903,34 +3587,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4903
3587
|
}, {
|
|
4904
3588
|
key: "addProductToOrder",
|
|
4905
3589
|
value: function () {
|
|
4906
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3590
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(product, booking) {
|
|
4907
3591
|
var products;
|
|
4908
|
-
return _regeneratorRuntime().wrap(function
|
|
4909
|
-
while (1) switch (
|
|
3592
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
3593
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
4910
3594
|
case 0:
|
|
4911
|
-
|
|
3595
|
+
_context38.prev = 0;
|
|
4912
3596
|
if (this.store.order) {
|
|
4913
|
-
|
|
3597
|
+
_context38.next = 3;
|
|
4914
3598
|
break;
|
|
4915
3599
|
}
|
|
4916
3600
|
throw new Error('order 模块未初始化');
|
|
4917
3601
|
case 3:
|
|
4918
|
-
|
|
3602
|
+
_context38.next = 5;
|
|
4919
3603
|
return this.store.order.addProductToOrder(product, booking);
|
|
4920
3604
|
case 5:
|
|
4921
|
-
products =
|
|
4922
|
-
return
|
|
3605
|
+
products = _context38.sent;
|
|
3606
|
+
return _context38.abrupt("return", products);
|
|
4923
3607
|
case 9:
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
throw
|
|
3608
|
+
_context38.prev = 9;
|
|
3609
|
+
_context38.t0 = _context38["catch"](0);
|
|
3610
|
+
throw _context38.t0;
|
|
4927
3611
|
case 12:
|
|
4928
3612
|
case "end":
|
|
4929
|
-
return
|
|
3613
|
+
return _context38.stop();
|
|
4930
3614
|
}
|
|
4931
|
-
},
|
|
3615
|
+
}, _callee38, this, [[0, 9]]);
|
|
4932
3616
|
}));
|
|
4933
|
-
function addProductToOrder(
|
|
3617
|
+
function addProductToOrder(_x30, _x31) {
|
|
4934
3618
|
return _addProductToOrder.apply(this, arguments);
|
|
4935
3619
|
}
|
|
4936
3620
|
return addProductToOrder;
|
|
@@ -4938,34 +3622,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4938
3622
|
}, {
|
|
4939
3623
|
key: "updateOrderProduct",
|
|
4940
3624
|
value: function () {
|
|
4941
|
-
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3625
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
|
|
4942
3626
|
var products;
|
|
4943
|
-
return _regeneratorRuntime().wrap(function
|
|
4944
|
-
while (1) switch (
|
|
3627
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
3628
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
4945
3629
|
case 0:
|
|
4946
|
-
|
|
3630
|
+
_context39.prev = 0;
|
|
4947
3631
|
if (this.store.order) {
|
|
4948
|
-
|
|
3632
|
+
_context39.next = 3;
|
|
4949
3633
|
break;
|
|
4950
3634
|
}
|
|
4951
3635
|
throw new Error('order 模块未初始化');
|
|
4952
3636
|
case 3:
|
|
4953
|
-
|
|
3637
|
+
_context39.next = 5;
|
|
4954
3638
|
return this.store.order.updateOrderProduct(params);
|
|
4955
3639
|
case 5:
|
|
4956
|
-
products =
|
|
4957
|
-
return
|
|
3640
|
+
products = _context39.sent;
|
|
3641
|
+
return _context39.abrupt("return", products);
|
|
4958
3642
|
case 9:
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
throw
|
|
3643
|
+
_context39.prev = 9;
|
|
3644
|
+
_context39.t0 = _context39["catch"](0);
|
|
3645
|
+
throw _context39.t0;
|
|
4962
3646
|
case 12:
|
|
4963
3647
|
case "end":
|
|
4964
|
-
return
|
|
3648
|
+
return _context39.stop();
|
|
4965
3649
|
}
|
|
4966
|
-
},
|
|
3650
|
+
}, _callee39, this, [[0, 9]]);
|
|
4967
3651
|
}));
|
|
4968
|
-
function updateOrderProduct(
|
|
3652
|
+
function updateOrderProduct(_x32) {
|
|
4969
3653
|
return _updateOrderProduct.apply(this, arguments);
|
|
4970
3654
|
}
|
|
4971
3655
|
return updateOrderProduct;
|
|
@@ -4973,34 +3657,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4973
3657
|
}, {
|
|
4974
3658
|
key: "updateOrderProducts",
|
|
4975
3659
|
value: function () {
|
|
4976
|
-
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3660
|
+
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(paramsList) {
|
|
4977
3661
|
var products;
|
|
4978
|
-
return _regeneratorRuntime().wrap(function
|
|
4979
|
-
while (1) switch (
|
|
3662
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
3663
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
4980
3664
|
case 0:
|
|
4981
|
-
|
|
3665
|
+
_context40.prev = 0;
|
|
4982
3666
|
if (this.store.order) {
|
|
4983
|
-
|
|
3667
|
+
_context40.next = 3;
|
|
4984
3668
|
break;
|
|
4985
3669
|
}
|
|
4986
3670
|
throw new Error('order 模块未初始化');
|
|
4987
3671
|
case 3:
|
|
4988
|
-
|
|
3672
|
+
_context40.next = 5;
|
|
4989
3673
|
return this.store.order.updateOrderProducts(paramsList);
|
|
4990
3674
|
case 5:
|
|
4991
|
-
products =
|
|
4992
|
-
return
|
|
3675
|
+
products = _context40.sent;
|
|
3676
|
+
return _context40.abrupt("return", products);
|
|
4993
3677
|
case 9:
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
throw
|
|
3678
|
+
_context40.prev = 9;
|
|
3679
|
+
_context40.t0 = _context40["catch"](0);
|
|
3680
|
+
throw _context40.t0;
|
|
4997
3681
|
case 12:
|
|
4998
3682
|
case "end":
|
|
4999
|
-
return
|
|
3683
|
+
return _context40.stop();
|
|
5000
3684
|
}
|
|
5001
|
-
},
|
|
3685
|
+
}, _callee40, this, [[0, 9]]);
|
|
5002
3686
|
}));
|
|
5003
|
-
function updateOrderProducts(
|
|
3687
|
+
function updateOrderProducts(_x33) {
|
|
5004
3688
|
return _updateOrderProducts.apply(this, arguments);
|
|
5005
3689
|
}
|
|
5006
3690
|
return updateOrderProducts;
|
|
@@ -5008,34 +3692,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5008
3692
|
}, {
|
|
5009
3693
|
key: "updateOrderProductQuantity",
|
|
5010
3694
|
value: function () {
|
|
5011
|
-
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3695
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
|
|
5012
3696
|
var products;
|
|
5013
|
-
return _regeneratorRuntime().wrap(function
|
|
5014
|
-
while (1) switch (
|
|
3697
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context41) {
|
|
3698
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
5015
3699
|
case 0:
|
|
5016
|
-
|
|
3700
|
+
_context41.prev = 0;
|
|
5017
3701
|
if (this.store.order) {
|
|
5018
|
-
|
|
3702
|
+
_context41.next = 3;
|
|
5019
3703
|
break;
|
|
5020
3704
|
}
|
|
5021
3705
|
throw new Error('order 模块未初始化');
|
|
5022
3706
|
case 3:
|
|
5023
|
-
|
|
3707
|
+
_context41.next = 5;
|
|
5024
3708
|
return this.store.order.updateOrderProductQuantity(params);
|
|
5025
3709
|
case 5:
|
|
5026
|
-
products =
|
|
5027
|
-
return
|
|
3710
|
+
products = _context41.sent;
|
|
3711
|
+
return _context41.abrupt("return", products);
|
|
5028
3712
|
case 9:
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
throw
|
|
3713
|
+
_context41.prev = 9;
|
|
3714
|
+
_context41.t0 = _context41["catch"](0);
|
|
3715
|
+
throw _context41.t0;
|
|
5032
3716
|
case 12:
|
|
5033
3717
|
case "end":
|
|
5034
|
-
return
|
|
3718
|
+
return _context41.stop();
|
|
5035
3719
|
}
|
|
5036
|
-
},
|
|
3720
|
+
}, _callee41, this, [[0, 9]]);
|
|
5037
3721
|
}));
|
|
5038
|
-
function updateOrderProductQuantity(
|
|
3722
|
+
function updateOrderProductQuantity(_x34) {
|
|
5039
3723
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
5040
3724
|
}
|
|
5041
3725
|
return updateOrderProductQuantity;
|
|
@@ -5058,12 +3742,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5058
3742
|
}, {
|
|
5059
3743
|
key: "setOrderProductLineNote",
|
|
5060
3744
|
value: (function () {
|
|
5061
|
-
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3745
|
+
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(identity, note) {
|
|
5062
3746
|
var params, products;
|
|
5063
|
-
return _regeneratorRuntime().wrap(function
|
|
5064
|
-
while (1) switch (
|
|
3747
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context42) {
|
|
3748
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
5065
3749
|
case 0:
|
|
5066
|
-
|
|
3750
|
+
_context42.prev = 0;
|
|
5067
3751
|
params = {
|
|
5068
3752
|
product_id: identity.product_id,
|
|
5069
3753
|
product_variant_id: identity.product_variant_id,
|
|
@@ -5078,22 +3762,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5078
3762
|
params.product_sku = identity.product_sku;
|
|
5079
3763
|
}
|
|
5080
3764
|
if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
|
|
5081
|
-
|
|
3765
|
+
_context42.next = 7;
|
|
5082
3766
|
return this.updateOrderProduct(params);
|
|
5083
3767
|
case 7:
|
|
5084
|
-
products =
|
|
5085
|
-
return
|
|
3768
|
+
products = _context42.sent;
|
|
3769
|
+
return _context42.abrupt("return", products);
|
|
5086
3770
|
case 11:
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
throw
|
|
3771
|
+
_context42.prev = 11;
|
|
3772
|
+
_context42.t0 = _context42["catch"](0);
|
|
3773
|
+
throw _context42.t0;
|
|
5090
3774
|
case 14:
|
|
5091
3775
|
case "end":
|
|
5092
|
-
return
|
|
3776
|
+
return _context42.stop();
|
|
5093
3777
|
}
|
|
5094
|
-
},
|
|
3778
|
+
}, _callee42, this, [[0, 11]]);
|
|
5095
3779
|
}));
|
|
5096
|
-
function setOrderProductLineNote(
|
|
3780
|
+
function setOrderProductLineNote(_x35, _x36) {
|
|
5097
3781
|
return _setOrderProductLineNote.apply(this, arguments);
|
|
5098
3782
|
}
|
|
5099
3783
|
return setOrderProductLineNote;
|
|
@@ -5108,32 +3792,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5108
3792
|
}, {
|
|
5109
3793
|
key: "removeProductsFromOrder",
|
|
5110
3794
|
value: (function () {
|
|
5111
|
-
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5112
|
-
return _regeneratorRuntime().wrap(function
|
|
5113
|
-
while (1) switch (
|
|
3795
|
+
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(identities) {
|
|
3796
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context43) {
|
|
3797
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
5114
3798
|
case 0:
|
|
5115
|
-
|
|
3799
|
+
_context43.prev = 0;
|
|
5116
3800
|
if (this.store.order) {
|
|
5117
|
-
|
|
3801
|
+
_context43.next = 3;
|
|
5118
3802
|
break;
|
|
5119
3803
|
}
|
|
5120
3804
|
throw new Error('order 模块未初始化');
|
|
5121
3805
|
case 3:
|
|
5122
|
-
|
|
3806
|
+
_context43.next = 5;
|
|
5123
3807
|
return this.store.order.removeProductsFromOrder(identities);
|
|
5124
3808
|
case 5:
|
|
5125
|
-
return
|
|
3809
|
+
return _context43.abrupt("return", _context43.sent);
|
|
5126
3810
|
case 8:
|
|
5127
|
-
|
|
5128
|
-
|
|
5129
|
-
throw
|
|
3811
|
+
_context43.prev = 8;
|
|
3812
|
+
_context43.t0 = _context43["catch"](0);
|
|
3813
|
+
throw _context43.t0;
|
|
5130
3814
|
case 11:
|
|
5131
3815
|
case "end":
|
|
5132
|
-
return
|
|
3816
|
+
return _context43.stop();
|
|
5133
3817
|
}
|
|
5134
|
-
},
|
|
3818
|
+
}, _callee43, this, [[0, 8]]);
|
|
5135
3819
|
}));
|
|
5136
|
-
function removeProductsFromOrder(
|
|
3820
|
+
function removeProductsFromOrder(_x37) {
|
|
5137
3821
|
return _removeProductsFromOrder.apply(this, arguments);
|
|
5138
3822
|
}
|
|
5139
3823
|
return removeProductsFromOrder;
|
|
@@ -5141,18 +3825,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5141
3825
|
}, {
|
|
5142
3826
|
key: "removeProductFromOrder",
|
|
5143
3827
|
value: function () {
|
|
5144
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5145
|
-
return _regeneratorRuntime().wrap(function
|
|
5146
|
-
while (1) switch (
|
|
3828
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(identity) {
|
|
3829
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context44) {
|
|
3830
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
5147
3831
|
case 0:
|
|
5148
|
-
return
|
|
3832
|
+
return _context44.abrupt("return", this.removeProductsFromOrder([identity]));
|
|
5149
3833
|
case 1:
|
|
5150
3834
|
case "end":
|
|
5151
|
-
return
|
|
3835
|
+
return _context44.stop();
|
|
5152
3836
|
}
|
|
5153
|
-
},
|
|
3837
|
+
}, _callee44, this);
|
|
5154
3838
|
}));
|
|
5155
|
-
function removeProductFromOrder(
|
|
3839
|
+
function removeProductFromOrder(_x38) {
|
|
5156
3840
|
return _removeProductFromOrder.apply(this, arguments);
|
|
5157
3841
|
}
|
|
5158
3842
|
return removeProductFromOrder;
|
|
@@ -5202,23 +3886,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5202
3886
|
}, {
|
|
5203
3887
|
key: "applyPromotion",
|
|
5204
3888
|
value: (function () {
|
|
5205
|
-
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5206
|
-
return _regeneratorRuntime().wrap(function
|
|
5207
|
-
while (1) switch (
|
|
3889
|
+
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45() {
|
|
3890
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context45) {
|
|
3891
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
5208
3892
|
case 0:
|
|
5209
3893
|
if (this.store.order) {
|
|
5210
|
-
|
|
3894
|
+
_context45.next = 2;
|
|
5211
3895
|
break;
|
|
5212
3896
|
}
|
|
5213
3897
|
throw new Error('order 模块未初始化');
|
|
5214
3898
|
case 2:
|
|
5215
|
-
|
|
3899
|
+
_context45.next = 4;
|
|
5216
3900
|
return this.store.order.applyPromotion();
|
|
5217
3901
|
case 4:
|
|
5218
3902
|
case "end":
|
|
5219
|
-
return
|
|
3903
|
+
return _context45.stop();
|
|
5220
3904
|
}
|
|
5221
|
-
},
|
|
3905
|
+
}, _callee45, this);
|
|
5222
3906
|
}));
|
|
5223
3907
|
function applyPromotion() {
|
|
5224
3908
|
return _applyPromotion.apply(this, arguments);
|
|
@@ -5228,16 +3912,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5228
3912
|
}, {
|
|
5229
3913
|
key: "getUnfulfilledPromotions",
|
|
5230
3914
|
value: function getUnfulfilledPromotions() {
|
|
5231
|
-
var _this$store$
|
|
5232
|
-
return ((_this$store$
|
|
3915
|
+
var _this$store$order8;
|
|
3916
|
+
return ((_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 ? void 0 : _this$store$order8.getUnfulfilledPromotions()) || [];
|
|
5233
3917
|
}
|
|
5234
3918
|
|
|
5235
3919
|
/** 最近一次促销计算输出的赠品操作 diff。 */
|
|
5236
3920
|
}, {
|
|
5237
3921
|
key: "getLastGiftActions",
|
|
5238
3922
|
value: function getLastGiftActions() {
|
|
5239
|
-
var _this$store$
|
|
5240
|
-
return ((_this$store$
|
|
3923
|
+
var _this$store$order9;
|
|
3924
|
+
return ((_this$store$order9 = this.store.order) === null || _this$store$order9 === void 0 ? void 0 : _this$store$order9.getLastGiftActions()) || null;
|
|
5241
3925
|
}
|
|
5242
3926
|
|
|
5243
3927
|
// 获取商品列表
|
|
@@ -5245,18 +3929,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5245
3929
|
}, {
|
|
5246
3930
|
key: "getProductList",
|
|
5247
3931
|
value: function () {
|
|
5248
|
-
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5249
|
-
var _this$
|
|
3932
|
+
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
|
|
3933
|
+
var _this$otherParams22;
|
|
5250
3934
|
var menu_list_ids, _this$store$products, res;
|
|
5251
|
-
return _regeneratorRuntime().wrap(function
|
|
5252
|
-
while (1) switch (
|
|
3935
|
+
return _regeneratorRuntime().wrap(function _callee46$(_context46) {
|
|
3936
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
5253
3937
|
case 0:
|
|
5254
3938
|
// 可以直接通过配置里的 menu 读取
|
|
5255
|
-
menu_list_ids = ((_this$
|
|
3939
|
+
menu_list_ids = ((_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 || (_this$otherParams22 = _this$otherParams22.dineInConfig) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22['menu.associated_menus'].map(function (n) {
|
|
5256
3940
|
return Number(n.value);
|
|
5257
3941
|
})) || [];
|
|
5258
|
-
|
|
5259
|
-
|
|
3942
|
+
_context46.prev = 1;
|
|
3943
|
+
_context46.next = 4;
|
|
5260
3944
|
return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
|
|
5261
3945
|
menu_list_ids: menu_list_ids,
|
|
5262
3946
|
cacheId: this.cacheId,
|
|
@@ -5264,17 +3948,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5264
3948
|
schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
5265
3949
|
});
|
|
5266
3950
|
case 4:
|
|
5267
|
-
res =
|
|
5268
|
-
return
|
|
3951
|
+
res = _context46.sent;
|
|
3952
|
+
return _context46.abrupt("return", res);
|
|
5269
3953
|
case 8:
|
|
5270
|
-
|
|
5271
|
-
|
|
5272
|
-
throw
|
|
3954
|
+
_context46.prev = 8;
|
|
3955
|
+
_context46.t0 = _context46["catch"](1);
|
|
3956
|
+
throw _context46.t0;
|
|
5273
3957
|
case 11:
|
|
5274
3958
|
case "end":
|
|
5275
|
-
return
|
|
3959
|
+
return _context46.stop();
|
|
5276
3960
|
}
|
|
5277
|
-
},
|
|
3961
|
+
}, _callee46, this, [[1, 8]]);
|
|
5278
3962
|
}));
|
|
5279
3963
|
function getProductList() {
|
|
5280
3964
|
return _getProductList.apply(this, arguments);
|
|
@@ -5289,33 +3973,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5289
3973
|
}, {
|
|
5290
3974
|
key: "setOtherParams",
|
|
5291
3975
|
value: function () {
|
|
5292
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5293
|
-
var _this$
|
|
5294
|
-
var
|
|
5295
|
-
|
|
3976
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(params) {
|
|
3977
|
+
var _this$otherParams23;
|
|
3978
|
+
var _ref30,
|
|
3979
|
+
_ref30$cover,
|
|
5296
3980
|
cover,
|
|
5297
|
-
|
|
5298
|
-
return _regeneratorRuntime().wrap(function
|
|
5299
|
-
while (1) switch (
|
|
3981
|
+
_args47 = arguments;
|
|
3982
|
+
return _regeneratorRuntime().wrap(function _callee47$(_context47) {
|
|
3983
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
5300
3984
|
case 0:
|
|
5301
|
-
|
|
3985
|
+
_ref30 = _args47.length > 1 && _args47[1] !== undefined ? _args47[1] : {}, _ref30$cover = _ref30.cover, cover = _ref30$cover === void 0 ? false : _ref30$cover;
|
|
5302
3986
|
if (cover) {
|
|
5303
3987
|
this.otherParams = _objectSpread({}, params);
|
|
5304
3988
|
} else {
|
|
5305
3989
|
this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
|
|
5306
3990
|
}
|
|
5307
|
-
this.cacheId = (_this$
|
|
5308
|
-
|
|
3991
|
+
this.cacheId = (_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.cacheId;
|
|
3992
|
+
_context47.next = 5;
|
|
5309
3993
|
return this.syncOtherParamsToSubModules(params, {
|
|
5310
3994
|
cover: cover
|
|
5311
3995
|
});
|
|
5312
3996
|
case 5:
|
|
5313
3997
|
case "end":
|
|
5314
|
-
return
|
|
3998
|
+
return _context47.stop();
|
|
5315
3999
|
}
|
|
5316
|
-
},
|
|
4000
|
+
}, _callee47, this);
|
|
5317
4001
|
}));
|
|
5318
|
-
function setOtherParams(
|
|
4002
|
+
function setOtherParams(_x39) {
|
|
5319
4003
|
return _setOtherParams.apply(this, arguments);
|
|
5320
4004
|
}
|
|
5321
4005
|
return setOtherParams;
|