@pisell/pisellos 2.3.38 → 2.3.40
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 +4 -8
- package/dist/solution/BookingTicket/index.js +51 -134
- 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/BookingTicket/utils/scan/handleScan.d.ts +3 -1
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +10 -2
- 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 -2
- 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 +4 -8
- package/lib/solution/BookingTicket/index.js +19 -64
- 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/BookingTicket/utils/scan/handleScan.d.ts +3 -1
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -2
- 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
|
@@ -40,8 +40,6 @@ var import_decimal = __toESM(require("decimal.js"));
|
|
|
40
40
|
var import_lodash_es = require("lodash-es");
|
|
41
41
|
var import_types2 = require("../BookingByStep/types");
|
|
42
42
|
var import_utils = require("../../modules/Order/utils");
|
|
43
|
-
var import_payment_utils = require("../../modules/Order/payment-utils");
|
|
44
|
-
var import_payment_number = require("../../utils/payment-number");
|
|
45
43
|
var import_orderCollectionIdentity = require("../../modules/Order/utils/orderCollectionIdentity");
|
|
46
44
|
var import_dayjs = __toESM(require("dayjs"));
|
|
47
45
|
__reExport(BaseSales_exports, require("./types"), module.exports);
|
|
@@ -49,88 +47,6 @@ var import_Quotation = require("../../modules/Quotation");
|
|
|
49
47
|
var import_transformBaseProductToOrderProduct = require("./utils/transformBaseProductToOrderProduct");
|
|
50
48
|
var import_quotationPrice = require("./utils/quotationPrice");
|
|
51
49
|
var SERVER_ORDER_CHANGED_EVENT = "order:onOrdersChanged";
|
|
52
|
-
var WALLET_PAYMENT_CODE_BY_TAG = {
|
|
53
|
-
product_voucher: "PRODUCTVOUCHER",
|
|
54
|
-
gift_card: "GIFTCARD",
|
|
55
|
-
point_card: "POINTCARD"
|
|
56
|
-
};
|
|
57
|
-
function getSharedWalletAssetId(asset) {
|
|
58
|
-
return (asset == null ? void 0 : asset.id) ?? (asset == null ? void 0 : asset.voucher_id) ?? (asset == null ? void 0 : asset.code);
|
|
59
|
-
}
|
|
60
|
-
function getSharedWalletAssetAmount(asset) {
|
|
61
|
-
const value = (asset == null ? void 0 : asset.edit_current_amount) ?? (asset == null ? void 0 : asset._available_max_amount) ?? ((asset == null ? void 0 : asset.tag) === "point_card" ? asset == null ? void 0 : asset.recommended_usage_amount : asset == null ? void 0 : asset.available_max_amount) ?? (asset == null ? void 0 : asset.actualDeduction) ?? (asset == null ? void 0 : asset.amount) ?? 0;
|
|
62
|
-
const amount = Number(value);
|
|
63
|
-
return Number.isFinite(amount) && amount > 0 ? amount : 0;
|
|
64
|
-
}
|
|
65
|
-
function isRejectedSalesSubmitResult(result) {
|
|
66
|
-
var _a, _b;
|
|
67
|
-
const candidates = [
|
|
68
|
-
result,
|
|
69
|
-
result == null ? void 0 : result.data,
|
|
70
|
-
(_a = result == null ? void 0 : result.response) == null ? void 0 : _a.data,
|
|
71
|
-
(_b = result == null ? void 0 : result.response) == null ? void 0 : _b.body
|
|
72
|
-
];
|
|
73
|
-
return candidates.some((candidate) => {
|
|
74
|
-
if (!candidate || typeof candidate !== "object")
|
|
75
|
-
return false;
|
|
76
|
-
const responseCode = Number(candidate.code ?? candidate.statusCode);
|
|
77
|
-
if (Number.isFinite(responseCode) && responseCode >= 400)
|
|
78
|
-
return true;
|
|
79
|
-
if (candidate.status === false || candidate.success === false || candidate.result === false) {
|
|
80
|
-
return true;
|
|
81
|
-
}
|
|
82
|
-
return ["failed", "error"].includes(
|
|
83
|
-
String(candidate.status || "").toLowerCase()
|
|
84
|
-
);
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
function getSalesSubmitErrorMessage(result) {
|
|
88
|
-
var _a, _b;
|
|
89
|
-
return (result == null ? void 0 : result.message) || (result == null ? void 0 : result.msg) || ((_a = result == null ? void 0 : result.data) == null ? void 0 : _a.message) || ((_b = result == null ? void 0 : result.data) == null ? void 0 : _b.msg) || "Wallet 支付确认失败";
|
|
90
|
-
}
|
|
91
|
-
function toWalletFundValue(value) {
|
|
92
|
-
try {
|
|
93
|
-
return new import_decimal.default(value || 0).toDecimalPlaces(2).toFixed(2);
|
|
94
|
-
} catch {
|
|
95
|
-
return "0.00";
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
function subtractWalletFundValue(left, right) {
|
|
99
|
-
try {
|
|
100
|
-
return new import_decimal.default(left || 0).minus(right || 0).toDecimalPlaces(2).toFixed(2);
|
|
101
|
-
} catch {
|
|
102
|
-
return "0.00";
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
function getSharedWalletPassUseValue(params) {
|
|
106
|
-
const { asset, amount, paymentMethod } = params;
|
|
107
|
-
const configuredValue = Number(asset == null ? void 0 : asset.wallet_pass_use_value);
|
|
108
|
-
if (Number.isFinite(configuredValue) && configuredValue > 0) {
|
|
109
|
-
return configuredValue;
|
|
110
|
-
}
|
|
111
|
-
const isPointCard = (asset == null ? void 0 : asset.tag) === "point_card" || paymentMethod.code === "POINTCARD";
|
|
112
|
-
const usageUnit = asset == null ? void 0 : asset.wallet_pass_usage_unit;
|
|
113
|
-
if (isPointCard && (usageUnit == null ? void 0 : usageUnit.points) && (usageUnit == null ? void 0 : usageUnit.price)) {
|
|
114
|
-
return new import_decimal.default(amount).div(usageUnit.price).mul(usageUnit.points).toDecimalPlaces(2, import_decimal.default.ROUND_DOWN).toNumber();
|
|
115
|
-
}
|
|
116
|
-
return amount;
|
|
117
|
-
}
|
|
118
|
-
function buildSharedWalletFundRecord(params) {
|
|
119
|
-
const { asset, amount, paymentMethod } = params;
|
|
120
|
-
const isPointCard = (asset == null ? void 0 : asset.tag) === "point_card" || paymentMethod.code === "POINTCARD";
|
|
121
|
-
const usingBeforeValue = (asset == null ? void 0 : asset.balance_par_value) ?? (asset == null ? void 0 : asset.balance) ?? (asset == null ? void 0 : asset.using_before_value) ?? 0;
|
|
122
|
-
const walletPassUseValue = getSharedWalletPassUseValue(params);
|
|
123
|
-
const usingValue = isPointCard ? walletPassUseValue : amount;
|
|
124
|
-
const walletPassName = (asset == null ? void 0 : asset.wallet_pass_name) || (asset == null ? void 0 : asset.format_title) || (asset == null ? void 0 : asset.product_name) || (asset == null ? void 0 : asset.name) || paymentMethod.name;
|
|
125
|
-
return {
|
|
126
|
-
voucher_id: (asset == null ? void 0 : asset.voucher_id) ?? (asset == null ? void 0 : asset.id),
|
|
127
|
-
wallet_pass_name: walletPassName && typeof walletPassName === "object" ? walletPassName : { default: walletPassName || "" },
|
|
128
|
-
code: (asset == null ? void 0 : asset.code) || (asset == null ? void 0 : asset.tag),
|
|
129
|
-
encoded: asset == null ? void 0 : asset.encoded,
|
|
130
|
-
using_before_value: toWalletFundValue(usingBeforeValue),
|
|
131
|
-
using_after_value: subtractWalletFundValue(usingBeforeValue, usingValue)
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
50
|
function isBaseSalesManualProductDiscountProduct(product) {
|
|
135
51
|
var _a, _b;
|
|
136
52
|
return ((_a = product == null ? void 0 : product.metadata) == null ? void 0 : _a.is_manual_discount) === true || ((_b = product == null ? void 0 : product.metadata) == null ? void 0 : _b.is_manual_discount) === 1 || ((product == null ? void 0 : product.discount_list) || []).some((item) => (item == null ? void 0 : item.type) === "product");
|
|
@@ -161,11 +77,6 @@ function isBaseSalesHistoricalDiscountEntry(discount) {
|
|
|
161
77
|
(discount == null ? void 0 : discount.isEditMode) || (discount == null ? void 0 : discount.isDisabled) || (discount == null ? void 0 : discount.order_discount_id) != null
|
|
162
78
|
);
|
|
163
79
|
}
|
|
164
|
-
function getBaseSalesUniqueArrayMetadataKey(key) {
|
|
165
|
-
if (key === "products" || key === "bookings")
|
|
166
|
-
return "unique_identification_number";
|
|
167
|
-
return null;
|
|
168
|
-
}
|
|
169
80
|
var BASE_SALES_PERSISTENT_ID_FIELD_BY_KIND = {
|
|
170
81
|
product: "order_detail_id",
|
|
171
82
|
booking: "schedule_event_id",
|
|
@@ -239,15 +150,6 @@ function mergeBaseSalesCollectionItem(kind, currentItem, incomingItem, uidRemaps
|
|
|
239
150
|
return kind === "product" ? mergeBaseSalesProductSnapshotFields(currentItem, mergedItem) : mergedItem;
|
|
240
151
|
}
|
|
241
152
|
function mergeBaseSalesOrderCollection(kind, currentValue, incomingValue, strategy, uidRemaps) {
|
|
242
|
-
if (kind === "payment") {
|
|
243
|
-
return (0, import_payment_utils.mergeOrderPaymentListsByIdentity)(
|
|
244
|
-
currentValue,
|
|
245
|
-
incomingValue,
|
|
246
|
-
strategy === "preserve-local" ? { preserveUnmatchedExisting: true } : {
|
|
247
|
-
preserveUnmatchedExistingWhen: (payment) => (0, import_payment_utils.isIdentifiedPendingOrderPayment)(payment) || !(0, import_orderCollectionIdentity.getOrderCollectionPersistentId)("payment", payment)
|
|
248
|
-
}
|
|
249
|
-
);
|
|
250
|
-
}
|
|
251
153
|
const currentItems = (0, import_orderCollectionIdentity.normalizeOrderCollection)(kind, currentValue, {
|
|
252
154
|
ensureUid: false
|
|
253
155
|
}).items;
|
|
@@ -307,35 +209,6 @@ function normalizeBaseSalesRecordCollections(sourceRecord, options) {
|
|
|
307
209
|
}
|
|
308
210
|
return normalizedRecord;
|
|
309
211
|
}
|
|
310
|
-
function getBaseSalesMetadataUid(item, metadataKey) {
|
|
311
|
-
var _a;
|
|
312
|
-
const uid = ((_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a[metadataKey]) ?? (item == null ? void 0 : item[metadataKey]);
|
|
313
|
-
if (uid === void 0 || uid === null || uid === "")
|
|
314
|
-
return null;
|
|
315
|
-
return String(uid);
|
|
316
|
-
}
|
|
317
|
-
function mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey) {
|
|
318
|
-
const result = [];
|
|
319
|
-
const indexByUid = /* @__PURE__ */ new Map();
|
|
320
|
-
const appendOrReplaceByUid = (item) => {
|
|
321
|
-
const clonedItem = (0, import_lodash_es.cloneDeep)(item);
|
|
322
|
-
const uid = getBaseSalesMetadataUid(clonedItem, metadataKey);
|
|
323
|
-
if (!uid) {
|
|
324
|
-
result.push(clonedItem);
|
|
325
|
-
return;
|
|
326
|
-
}
|
|
327
|
-
const existingIndex = indexByUid.get(uid);
|
|
328
|
-
if (existingIndex !== void 0) {
|
|
329
|
-
result[existingIndex] = clonedItem;
|
|
330
|
-
return;
|
|
331
|
-
}
|
|
332
|
-
indexByUid.set(uid, result.length);
|
|
333
|
-
result.push(clonedItem);
|
|
334
|
-
};
|
|
335
|
-
currentValue.forEach(appendOrReplaceByUid);
|
|
336
|
-
loadedValue.forEach(appendOrReplaceByUid);
|
|
337
|
-
return result;
|
|
338
|
-
}
|
|
339
212
|
function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, strategy) {
|
|
340
213
|
const normalizedLoadedRecord = normalizeBaseSalesRecordCollections(
|
|
341
214
|
loadedRecord || {},
|
|
@@ -364,15 +237,6 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, str
|
|
|
364
237
|
);
|
|
365
238
|
}
|
|
366
239
|
if (Array.isArray(currentValue) && Array.isArray(loadedValue)) {
|
|
367
|
-
if (key === "payments" || key === "payment") {
|
|
368
|
-
return (0, import_payment_utils.mergeOrderPaymentListsByIdentity)(currentValue, loadedValue, {
|
|
369
|
-
preserveUnmatchedExisting: true
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
|
-
const metadataKey = getBaseSalesUniqueArrayMetadataKey(key);
|
|
373
|
-
if (metadataKey) {
|
|
374
|
-
return mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey);
|
|
375
|
-
}
|
|
376
240
|
return [
|
|
377
241
|
...(0, import_lodash_es.cloneDeep)(currentValue),
|
|
378
242
|
...(0, import_lodash_es.cloneDeep)(loadedValue)
|
|
@@ -391,18 +255,6 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, str
|
|
|
391
255
|
(0, import_orderCollectionIdentity.applyOrderCollectionUidRemaps)(mergedRecord, uidRemaps)
|
|
392
256
|
);
|
|
393
257
|
}
|
|
394
|
-
function filterPendingPaymentsFromLoadedSalesDetail(sourceRecord) {
|
|
395
|
-
if (!sourceRecord || typeof sourceRecord !== "object")
|
|
396
|
-
return sourceRecord;
|
|
397
|
-
const record = { ...sourceRecord };
|
|
398
|
-
if (Array.isArray(sourceRecord.payments)) {
|
|
399
|
-
record.payments = sourceRecord.payments.filter((payment) => !(0, import_payment_utils.isPendingOrderPayment)(payment));
|
|
400
|
-
}
|
|
401
|
-
if (Array.isArray(sourceRecord.payment)) {
|
|
402
|
-
record.payment = sourceRecord.payment.filter((payment) => !(0, import_payment_utils.isPendingOrderPayment)(payment));
|
|
403
|
-
}
|
|
404
|
-
return record;
|
|
405
|
-
}
|
|
406
258
|
var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
407
259
|
constructor(name, version) {
|
|
408
260
|
super(name, version);
|
|
@@ -414,11 +266,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
414
266
|
order: void 0
|
|
415
267
|
};
|
|
416
268
|
this.otherParams = {};
|
|
417
|
-
/**
|
|
418
|
-
* 由已在初始化阶段解析过设备短号的业务解决方案写入。
|
|
419
|
-
* 未设置时,支付编号仍按原逻辑实时读取设备信息。
|
|
420
|
-
*/
|
|
421
|
-
this.paymentNumberDevicePrefix = null;
|
|
422
269
|
// 当前缓存中已加载的最新 SalesDetail;只读 getter 走它对外暴露详情数据。
|
|
423
270
|
this.currentSalesDetail = null;
|
|
424
271
|
this.discountConfigCacheKey = null;
|
|
@@ -430,7 +277,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
430
277
|
this.autoPaymentSyncTimer = null;
|
|
431
278
|
this.salesDetailLoadInFlightCount = 0;
|
|
432
279
|
this.salesDetailLoadSequence = 0;
|
|
433
|
-
this.walletAssetsRefreshSequence = 0;
|
|
434
280
|
this.salesDetailHydrateQueue = Promise.resolve();
|
|
435
281
|
this.serverOrderChangeUnsubscribe = null;
|
|
436
282
|
this.serverOrderChangeHydrateInFlight = null;
|
|
@@ -950,27 +796,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
950
796
|
const coreData = (_f = (_d = (_c = app == null ? void 0 : app.models) == null ? void 0 : _c.getStore) == null ? void 0 : (_e = _d.call(_c)).getDataByModel) == null ? void 0 : _f.call(_e, "core", "core");
|
|
951
797
|
return coreData == null ? void 0 : coreData[key];
|
|
952
798
|
}
|
|
953
|
-
/**
|
|
954
|
-
* 复用业务解决方案初始化时已解析的支付设备短号。
|
|
955
|
-
* 空值会清除缓存,使后续支付恢复实时读取设备信息的兼容路径。
|
|
956
|
-
*/
|
|
957
|
-
setPaymentNumberDevicePrefix(prefix) {
|
|
958
|
-
const normalized = String(prefix ?? "").trim();
|
|
959
|
-
this.paymentNumberDevicePrefix = normalized || null;
|
|
960
|
-
}
|
|
961
|
-
getPaymentNumberDevicePrefixSync() {
|
|
962
|
-
if (!this.appPlugin)
|
|
963
|
-
return "LOCAL";
|
|
964
|
-
return (0, import_payment_number.resolvePaymentNumberDevicePrefixFromDeviceId)((key) => this.getAppData(key));
|
|
965
|
-
}
|
|
966
|
-
getPaymentNumberDevicePrefixAsync() {
|
|
967
|
-
if (!this.appPlugin)
|
|
968
|
-
return Promise.resolve("LOCAL");
|
|
969
|
-
if (this.paymentNumberDevicePrefix) {
|
|
970
|
-
return Promise.resolve(this.paymentNumberDevicePrefix);
|
|
971
|
-
}
|
|
972
|
-
return (0, import_payment_number.resolvePaymentNumberDevicePrefix)((key) => this.getAppData(key));
|
|
973
|
-
}
|
|
974
799
|
syncAppDataToTempOrder(tempOrder) {
|
|
975
800
|
const isPriceIncludeTax = this.getAppData("is_price_include_tax");
|
|
976
801
|
const taxCountryCode = this.getAppData("tax_country_code");
|
|
@@ -1008,10 +833,9 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1008
833
|
return isChanged;
|
|
1009
834
|
}
|
|
1010
835
|
async initialize(core, options = {}) {
|
|
1011
|
-
var _a, _b;
|
|
836
|
+
var _a, _b, _c, _d;
|
|
1012
837
|
this.core = core;
|
|
1013
838
|
this.initializeOptions = options || {};
|
|
1014
|
-
this.paymentNumberDevicePrefix = null;
|
|
1015
839
|
this.otherParams = options.otherParams || {};
|
|
1016
840
|
this.cacheId = (_a = this.otherParams) == null ? void 0 : _a.cacheId;
|
|
1017
841
|
this.reusedSharedSubModuleNames.clear();
|
|
@@ -1019,10 +843,9 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1019
843
|
this.request = core.getPlugin("request");
|
|
1020
844
|
this.appPlugin = core.getPlugin("app");
|
|
1021
845
|
if (!this.appPlugin) {
|
|
1022
|
-
throw new Error("Checkout 解决方案需要 app 插件支持");
|
|
1023
846
|
}
|
|
1024
|
-
const app = this.appPlugin.getApp();
|
|
1025
|
-
this.logger = app.logger;
|
|
847
|
+
const app = (_c = (_b = this.appPlugin) == null ? void 0 : _b.getApp) == null ? void 0 : _c.call(_b);
|
|
848
|
+
this.logger = app == null ? void 0 : app.logger;
|
|
1026
849
|
const targetCacheData = this.readSessionCacheData();
|
|
1027
850
|
const moduleNames = this.getRegisteredModuleNames();
|
|
1028
851
|
moduleNames.forEach((step) => {
|
|
@@ -1047,7 +870,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1047
870
|
if (this.store.schedule && !this.isScheduleListLoaded(this.store.schedule)) {
|
|
1048
871
|
await this.store.schedule.loadAllSchedule();
|
|
1049
872
|
}
|
|
1050
|
-
if (this.store.order && typeof ((
|
|
873
|
+
if (this.store.order && typeof ((_d = this.otherParams) == null ? void 0 : _d.enableTempOrderPersist) === "boolean") {
|
|
1051
874
|
this.store.order.setEnableTempOrderPersist(
|
|
1052
875
|
this.otherParams.enableTempOrderPersist
|
|
1053
876
|
);
|
|
@@ -1073,10 +896,8 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1073
896
|
}
|
|
1074
897
|
});
|
|
1075
898
|
this.currentSalesDetail = null;
|
|
1076
|
-
this.paymentNumberDevicePrefix = null;
|
|
1077
899
|
this.queuedServerOrderChanges = [];
|
|
1078
900
|
this.salesDetailLoadSequence += 1;
|
|
1079
|
-
this.walletAssetsRefreshSequence += 1;
|
|
1080
901
|
await this.core.effects.emit(`${this.name}:onDestroy`, {});
|
|
1081
902
|
super.destroy();
|
|
1082
903
|
}
|
|
@@ -1108,16 +929,13 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1108
929
|
const message = loadedRecord && (loadedRecord.message || loadedRecord.msg) || `加载销售详情失败: ${lookup}`;
|
|
1109
930
|
throw new Error(message);
|
|
1110
931
|
}
|
|
1111
|
-
const remoteRecord =
|
|
1112
|
-
preloadedSalesDetail ?? loadedRecord.data
|
|
1113
|
-
);
|
|
932
|
+
const remoteRecord = preloadedSalesDetail ?? loadedRecord.data;
|
|
1114
933
|
const currentTempOrder = params.merge ? this.store.order.getTempOrder() : null;
|
|
1115
|
-
const
|
|
934
|
+
const record = params.merge ? mergeSalesDetailRecordWithTempOrder(
|
|
1116
935
|
currentTempOrder,
|
|
1117
936
|
remoteRecord,
|
|
1118
937
|
"preserve-local"
|
|
1119
938
|
) : remoteRecord;
|
|
1120
|
-
const record = filterPendingPaymentsFromLoadedSalesDetail(mergedRecord);
|
|
1121
939
|
return await this.hydrateLatestLoadedSalesDetail(record, loadSequence);
|
|
1122
940
|
} finally {
|
|
1123
941
|
this.salesDetailLoadInFlightCount = Math.max(
|
|
@@ -1293,7 +1111,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1293
1111
|
// 重置 tempOrder 与与上一单强相关的运行态(resource/entryPaxNumber/enabledReservationRuleProducts),
|
|
1294
1112
|
// 适用于从支付页通过 react-router 跳回继续下单时清理残留数据
|
|
1295
1113
|
async restoreOrder() {
|
|
1296
|
-
var _a;
|
|
1297
1114
|
try {
|
|
1298
1115
|
if (!this.store.order) {
|
|
1299
1116
|
throw new Error("scanOrder 解决方案需要 order 模块支持");
|
|
@@ -1302,12 +1119,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1302
1119
|
this.currentSalesDetail = null;
|
|
1303
1120
|
this.discountConfigCacheKey = null;
|
|
1304
1121
|
this.hasManualDiscountSelection = false;
|
|
1305
|
-
const wallet = (_a = this.store.payment) == null ? void 0 : _a.wallet;
|
|
1306
|
-
if (wallet) {
|
|
1307
|
-
this.walletAssetsRefreshSequence += 1;
|
|
1308
|
-
wallet.clearAllCache();
|
|
1309
|
-
await this.publishWalletAssetsState(wallet.getWalletAssetsState());
|
|
1310
|
-
}
|
|
1311
1122
|
await this.effectsEmit("onTempOrderReplaced", { tempOrder });
|
|
1312
1123
|
if (this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled()) {
|
|
1313
1124
|
this.store.order.persistTempOrder();
|
|
@@ -1900,6 +1711,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1900
1711
|
throw new Error("BaseSales 解决方案需要 order 模块支持");
|
|
1901
1712
|
}
|
|
1902
1713
|
const inferredPaymentStatus = this.getSubmitPaymentStatus(params == null ? void 0 : params.paymentStatus);
|
|
1714
|
+
const smallTicketDataFlag = (params == null ? void 0 : params.smallTicketDataFlag) ?? this.getDefaultCheckoutSmallTicketDataFlag();
|
|
1903
1715
|
const submitParams = {
|
|
1904
1716
|
cacheId: this.cacheId,
|
|
1905
1717
|
platform: (_a = this.otherParams) == null ? void 0 : _a.platform,
|
|
@@ -1909,25 +1721,11 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1909
1721
|
request_unique_idempotency_token: this.store.order.generateIdempotencyToken(),
|
|
1910
1722
|
...(params == null ? void 0 : params.payments) !== void 0 ? { payments: params.payments } : {},
|
|
1911
1723
|
...inferredPaymentStatus !== void 0 ? { paymentStatus: inferredPaymentStatus } : {},
|
|
1912
|
-
...
|
|
1724
|
+
...smallTicketDataFlag !== void 0 ? { smallTicketDataFlag } : {},
|
|
1913
1725
|
...(params == null ? void 0 : params.confirmPendingVoucherPayments) !== void 0 ? { confirmPendingVoucherPayments: params.confirmPendingVoucherPayments } : {},
|
|
1914
1726
|
...(params == null ? void 0 : params.enhancePayload) !== void 0 ? { enhancePayload: params.enhancePayload } : {}
|
|
1915
1727
|
};
|
|
1916
|
-
return this.store.order.submitTempOrder(submitParams);
|
|
1917
|
-
}
|
|
1918
|
-
async saveSalesOrderDraft(params) {
|
|
1919
|
-
var _a, _b, _c, _d;
|
|
1920
|
-
if (!this.store.order) {
|
|
1921
|
-
throw new Error("BaseSales 解决方案需要 order 模块支持");
|
|
1922
|
-
}
|
|
1923
|
-
return this.store.order.saveTempOrderAsDraft({
|
|
1924
|
-
cacheId: this.cacheId,
|
|
1925
|
-
platform: (params == null ? void 0 : params.platform) ?? ((_a = this.otherParams) == null ? void 0 : _a.platform),
|
|
1926
|
-
businessCode: (params == null ? void 0 : params.businessCode) || ((_b = this.otherParams) == null ? void 0 : _b.businessCode) || ((_c = this.otherParams) == null ? void 0 : _c.business_code),
|
|
1927
|
-
channel: (params == null ? void 0 : params.channel) ?? this.getSubmitOrderSalesChannel(),
|
|
1928
|
-
type: (params == null ? void 0 : params.type) ?? ((_d = this.otherParams) == null ? void 0 : _d.type),
|
|
1929
|
-
...(params == null ? void 0 : params.enhancePayload) !== void 0 ? { enhancePayload: params.enhancePayload } : {}
|
|
1930
|
-
});
|
|
1728
|
+
return this.shouldUseCheckoutSyncTask() ? this.store.order.submitTempOrder(submitParams) : this.store.order.submitTempOrderAsync(submitParams);
|
|
1931
1729
|
}
|
|
1932
1730
|
async submitTempOrderAsync(params) {
|
|
1933
1731
|
var _a, _b, _c, _d;
|
|
@@ -1935,20 +1733,35 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1935
1733
|
throw new Error("BaseSales 解决方案需要 order 模块支持");
|
|
1936
1734
|
}
|
|
1937
1735
|
const inferredPaymentStatus = this.getSubmitPaymentStatus(params == null ? void 0 : params.paymentStatus);
|
|
1736
|
+
const smallTicketDataFlag = (params == null ? void 0 : params.smallTicketDataFlag) ?? this.getDefaultCheckoutSmallTicketDataFlag();
|
|
1938
1737
|
const submitParams = {
|
|
1939
1738
|
cacheId: this.cacheId,
|
|
1940
1739
|
platform: (_a = this.otherParams) == null ? void 0 : _a.platform,
|
|
1941
1740
|
businessCode: ((_b = this.otherParams) == null ? void 0 : _b.businessCode) || ((_c = this.otherParams) == null ? void 0 : _c.business_code),
|
|
1942
1741
|
channel: this.getSubmitOrderSalesChannel(),
|
|
1943
1742
|
type: (_d = this.otherParams) == null ? void 0 : _d.type,
|
|
1743
|
+
request_unique_idempotency_token: this.store.order.generateIdempotencyToken(),
|
|
1944
1744
|
...(params == null ? void 0 : params.payments) !== void 0 ? { payments: params.payments } : {},
|
|
1945
1745
|
...inferredPaymentStatus !== void 0 ? { paymentStatus: inferredPaymentStatus } : {},
|
|
1946
|
-
...
|
|
1746
|
+
...smallTicketDataFlag !== void 0 ? { smallTicketDataFlag } : {},
|
|
1947
1747
|
...(params == null ? void 0 : params.confirmPendingVoucherPayments) !== void 0 ? { confirmPendingVoucherPayments: params.confirmPendingVoucherPayments } : {},
|
|
1948
1748
|
...(params == null ? void 0 : params.enhancePayload) !== void 0 ? { enhancePayload: params.enhancePayload } : {}
|
|
1949
1749
|
};
|
|
1950
1750
|
return this.store.order.submitTempOrderAsync(submitParams);
|
|
1951
1751
|
}
|
|
1752
|
+
/**
|
|
1753
|
+
* 默认保持 WebPOS 的本地待同步订单模式;需要云端确认后才算成功的渠道可覆盖此策略。
|
|
1754
|
+
* otherParams.checkoutSyncTaskEnabled 优先,便于同一 solution 按入口恢复旧行为。
|
|
1755
|
+
*/
|
|
1756
|
+
shouldUseCheckoutSyncTask() {
|
|
1757
|
+
var _a;
|
|
1758
|
+
const configured = (_a = this.otherParams) == null ? void 0 : _a.checkoutSyncTaskEnabled;
|
|
1759
|
+
return typeof configured === "boolean" ? configured : true;
|
|
1760
|
+
}
|
|
1761
|
+
/** 可由特定 solution 为真实 checkout 补充默认收据数据请求。 */
|
|
1762
|
+
getDefaultCheckoutSmallTicketDataFlag() {
|
|
1763
|
+
return void 0;
|
|
1764
|
+
}
|
|
1952
1765
|
async printLocalOrderReceipt(lookup) {
|
|
1953
1766
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
1954
1767
|
if (!this.store.order) {
|
|
@@ -2008,6 +1821,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
2008
1821
|
const channel = params.channel ?? this.getSubmitOrderSalesChannel();
|
|
2009
1822
|
const syncParams = {
|
|
2010
1823
|
...params,
|
|
1824
|
+
checkoutSyncTaskEnabled: this.shouldUseCheckoutSyncTask(),
|
|
2011
1825
|
...businessCode !== void 0 ? { businessCode } : {},
|
|
2012
1826
|
...channel !== void 0 ? { channel } : {}
|
|
2013
1827
|
};
|
|
@@ -2129,29 +1943,8 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
2129
1943
|
}
|
|
2130
1944
|
}
|
|
2131
1945
|
}
|
|
2132
|
-
/**
|
|
2133
|
-
* 同步兼容入口。无法等待 IoT 短号时,按调用当下的 device_id 或 LOCAL 生成。
|
|
2134
|
-
*/
|
|
1946
|
+
/** 追加单个支付项到当前订单。 */
|
|
2135
1947
|
addOrderPayment(payment) {
|
|
2136
|
-
const hasPaymentNumber = String(
|
|
2137
|
-
payment.payment_number || ""
|
|
2138
|
-
).trim() !== "";
|
|
2139
|
-
return this.addOrderPaymentWithDevicePrefix(
|
|
2140
|
-
payment,
|
|
2141
|
-
hasPaymentNumber ? "LOCAL" : this.getPaymentNumberDevicePrefixSync()
|
|
2142
|
-
);
|
|
2143
|
-
}
|
|
2144
|
-
/**
|
|
2145
|
-
* 创建新支付项时优先使用业务解决方案初始化阶段缓存的设备短号;
|
|
2146
|
-
* 未缓存的通用 BaseSales 保持实时读取设备信息的兼容语义。
|
|
2147
|
-
*/
|
|
2148
|
-
async addOrderPaymentAsync(payment) {
|
|
2149
|
-
const paymentRecord = payment;
|
|
2150
|
-
const hasPaymentNumber = String(paymentRecord.payment_number || "").trim() !== "";
|
|
2151
|
-
const devicePrefix = hasPaymentNumber ? "LOCAL" : await this.getPaymentNumberDevicePrefixAsync();
|
|
2152
|
-
return this.addOrderPaymentWithDevicePrefix(payment, devicePrefix);
|
|
2153
|
-
}
|
|
2154
|
-
addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
|
|
2155
1948
|
var _a;
|
|
2156
1949
|
if (!this.store.order)
|
|
2157
1950
|
throw new Error("order 模块未初始化");
|
|
@@ -2168,26 +1961,21 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
2168
1961
|
if (shopWalletPassId !== void 0 && shopWalletPassId !== null) {
|
|
2169
1962
|
metadata.shop_wallet_pass_id = shopWalletPassId;
|
|
2170
1963
|
}
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
import_utils.createUuidV4
|
|
2175
|
-
);
|
|
1964
|
+
if (!metadata.unique_payment_number) {
|
|
1965
|
+
metadata.unique_payment_number = (0, import_utils.createUuidV4)();
|
|
1966
|
+
}
|
|
2176
1967
|
const paymentTimestamp = (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss");
|
|
2177
1968
|
const paymentTime = paymentRecord.payment_time ?? paymentTimestamp;
|
|
2178
1969
|
const createdAt = paymentRecord.created_at ?? paymentTimestamp;
|
|
2179
1970
|
const serviceCharge = paymentRecord.service_charge && typeof paymentRecord.service_charge === "object" ? paymentRecord.service_charge : null;
|
|
2180
1971
|
const calculatedServiceFee = serviceCharge ? new import_decimal.default(paymentRecord.origin_amount ?? paymentRecord.amount ?? 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : void 0;
|
|
2181
1972
|
const payments = this.store.order.addOrderPayment({
|
|
2182
|
-
...
|
|
1973
|
+
...paymentRecord,
|
|
2183
1974
|
...calculatedServiceFee !== void 0 ? { service_fee: calculatedServiceFee } : {},
|
|
2184
1975
|
metadata,
|
|
2185
1976
|
payment_time: paymentTime,
|
|
2186
1977
|
created_at: createdAt
|
|
2187
1978
|
});
|
|
2188
|
-
if (paymentRecord.status === "payment_pending") {
|
|
2189
|
-
return payments;
|
|
2190
|
-
}
|
|
2191
1979
|
const amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
2192
1980
|
const syncState = this.store.order.getOrderSyncState();
|
|
2193
1981
|
if (amountSnapshot) {
|
|
@@ -2209,73 +1997,10 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
2209
1997
|
return payments;
|
|
2210
1998
|
}
|
|
2211
1999
|
/** 更新当前订单中的指定支付项。 */
|
|
2212
|
-
|
|
2213
|
-
var _a, _b, _c;
|
|
2000
|
+
updateOrderPayment(paymentIdentity, updates) {
|
|
2214
2001
|
if (!this.store.order)
|
|
2215
2002
|
throw new Error("order 模块未初始化");
|
|
2216
|
-
|
|
2217
|
-
const previousMatch = (0, import_payment_utils.resolveOrderPaymentIdentity)(
|
|
2218
|
-
this.store.order.getOrderPayments(),
|
|
2219
|
-
paymentIdentity,
|
|
2220
|
-
matchMode
|
|
2221
|
-
);
|
|
2222
|
-
const previousPayment = previousMatch == null ? void 0 : previousMatch.payment;
|
|
2223
|
-
if ((previousPayment == null ? void 0 : previousPayment.status) === "paid" && !options.applyUpdatesWhenPaid) {
|
|
2224
|
-
const currentPayments = this.store.order.getOrderPayments();
|
|
2225
|
-
let syncResult2;
|
|
2226
|
-
if (options.submitWhenPaid && options.forceSubmitIfPaid) {
|
|
2227
|
-
syncResult2 = await this.syncPaymentsToOrder({
|
|
2228
|
-
payments: currentPayments,
|
|
2229
|
-
paymentStatus: this.getPaymentStatusForSync(currentPayments),
|
|
2230
|
-
submitWhenPaid: true,
|
|
2231
|
-
smallTicketDataFlag: options.smallTicketDataFlag ?? 1
|
|
2232
|
-
});
|
|
2233
|
-
}
|
|
2234
|
-
return {
|
|
2235
|
-
updated: false,
|
|
2236
|
-
payment: previousPayment,
|
|
2237
|
-
payments: currentPayments,
|
|
2238
|
-
summary: ((_a = this.store.order.getOrderAmountSnapshot()) == null ? void 0 : _a.summary) || null,
|
|
2239
|
-
...syncResult2 !== void 0 ? { syncResult: syncResult2 } : {}
|
|
2240
|
-
};
|
|
2241
|
-
}
|
|
2242
|
-
const result = await this.store.order.updateOrderPayment(paymentIdentity, updates, {
|
|
2243
|
-
matchBy: matchMode
|
|
2244
|
-
});
|
|
2245
|
-
let draftResult;
|
|
2246
|
-
let draftError;
|
|
2247
|
-
if (options.persistDraft !== false) {
|
|
2248
|
-
try {
|
|
2249
|
-
draftResult = await this.saveSalesOrderDraft();
|
|
2250
|
-
} catch (error) {
|
|
2251
|
-
draftError = error;
|
|
2252
|
-
this.logError("updateOrderPayment: 保存支付草稿失败", {
|
|
2253
|
-
paymentIdentity,
|
|
2254
|
-
error: error instanceof Error ? error.message : String(error)
|
|
2255
|
-
});
|
|
2256
|
-
if (!options.submitWhenPaid)
|
|
2257
|
-
throw error;
|
|
2258
|
-
}
|
|
2259
|
-
}
|
|
2260
|
-
const becamePaid = (previousPayment == null ? void 0 : previousPayment.status) !== "paid" && ((_b = result.payment) == null ? void 0 : _b.status) === "paid";
|
|
2261
|
-
const shouldSubmit = Boolean(
|
|
2262
|
-
options.submitWhenPaid && ((_c = result.payment) == null ? void 0 : _c.status) === "paid" && (becamePaid || options.forceSubmitIfPaid)
|
|
2263
|
-
);
|
|
2264
|
-
let syncResult;
|
|
2265
|
-
if (shouldSubmit) {
|
|
2266
|
-
syncResult = await this.syncPaymentsToOrder({
|
|
2267
|
-
payments: result.payments,
|
|
2268
|
-
paymentStatus: this.getPaymentStatusForSync(result.payments),
|
|
2269
|
-
submitWhenPaid: true,
|
|
2270
|
-
smallTicketDataFlag: options.smallTicketDataFlag ?? 1
|
|
2271
|
-
});
|
|
2272
|
-
}
|
|
2273
|
-
return {
|
|
2274
|
-
...result,
|
|
2275
|
-
...draftResult !== void 0 ? { draftResult } : {},
|
|
2276
|
-
...draftError !== void 0 ? { draftError } : {},
|
|
2277
|
-
...syncResult !== void 0 ? { syncResult } : {}
|
|
2278
|
-
};
|
|
2003
|
+
return this.store.order.updateOrderPayment(paymentIdentity, updates);
|
|
2279
2004
|
}
|
|
2280
2005
|
/** 删除当前订单中的指定支付项。 */
|
|
2281
2006
|
deleteOrderPayment(paymentIdentity) {
|
|
@@ -2289,24 +2014,10 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
2289
2014
|
throw new Error("order 模块未初始化");
|
|
2290
2015
|
return this.store.order.updateVoucherOrderPayments(payments, options);
|
|
2291
2016
|
}
|
|
2292
|
-
async updateVoucherOrderPaymentsAsync(payments, options) {
|
|
2293
|
-
if (!this.store.order)
|
|
2294
|
-
throw new Error("order 模块未初始化");
|
|
2295
|
-
return this.store.order.updateVoucherOrderPaymentsAsync(payments, options);
|
|
2296
|
-
}
|
|
2297
2017
|
confirmPendingVoucherPayments() {
|
|
2298
2018
|
if (!this.store.order)
|
|
2299
2019
|
throw new Error("order 模块未初始化");
|
|
2300
|
-
|
|
2301
|
-
if (this.store.payment) {
|
|
2302
|
-
const committed = this.getCommittedWalletAssets();
|
|
2303
|
-
const state = this.store.payment.wallet.setCommittedWalletAssets(
|
|
2304
|
-
committed.ids,
|
|
2305
|
-
committed.assets
|
|
2306
|
-
);
|
|
2307
|
-
void this.publishWalletAssetsState(state);
|
|
2308
|
-
}
|
|
2309
|
-
return payments;
|
|
2020
|
+
return this.store.order.confirmPendingVoucherPayments();
|
|
2310
2021
|
}
|
|
2311
2022
|
discardPendingVoucherPayments() {
|
|
2312
2023
|
if (!this.store.order)
|
|
@@ -2367,14 +2078,24 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
2367
2078
|
});
|
|
2368
2079
|
return walletProducts;
|
|
2369
2080
|
}
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2081
|
+
async initWalletData(params) {
|
|
2082
|
+
if (!this.store.order)
|
|
2083
|
+
throw new Error("order 模块未初始化");
|
|
2084
|
+
if (!this.store.payment)
|
|
2085
|
+
throw new Error("payment 模块未初始化");
|
|
2086
|
+
const snapshot = this.store.order.getOrderSnapshot();
|
|
2373
2087
|
const tempOrder = snapshot == null ? void 0 : snapshot.tempOrder;
|
|
2374
2088
|
const amount = snapshot == null ? void 0 : snapshot.amount;
|
|
2375
|
-
if (!tempOrder || !amount)
|
|
2376
|
-
return
|
|
2377
|
-
|
|
2089
|
+
if (!tempOrder || !amount) {
|
|
2090
|
+
return {
|
|
2091
|
+
walletRecommendList: [],
|
|
2092
|
+
userIdentificationCodes: [],
|
|
2093
|
+
transformList: [],
|
|
2094
|
+
noApplicableVoucher: [],
|
|
2095
|
+
products: []
|
|
2096
|
+
};
|
|
2097
|
+
}
|
|
2098
|
+
const walletBusinessData = {
|
|
2378
2099
|
customer_id: tempOrder.customer_id ? Number(tempOrder.customer_id) : void 0,
|
|
2379
2100
|
holder: tempOrder.holder,
|
|
2380
2101
|
amountInfo: {
|
|
@@ -2388,29 +2109,11 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
2388
2109
|
is_price_include_tax: tempOrder.is_price_include_tax ?? this.otherParams.is_price_include_tax ?? 1,
|
|
2389
2110
|
...snapshot.identity.orderId ? { payment_order_id: String(snapshot.identity.orderId) } : {}
|
|
2390
2111
|
};
|
|
2391
|
-
}
|
|
2392
|
-
async initWalletData(params) {
|
|
2393
|
-
var _a;
|
|
2394
|
-
if (!this.store.order)
|
|
2395
|
-
throw new Error("order 模块未初始化");
|
|
2396
|
-
if (!this.store.payment)
|
|
2397
|
-
throw new Error("payment 模块未初始化");
|
|
2398
|
-
const snapshot = this.store.order.getOrderSnapshot();
|
|
2399
|
-
const walletBusinessData = this.buildWalletInitBusinessData(params);
|
|
2400
|
-
if (!walletBusinessData) {
|
|
2401
|
-
return {
|
|
2402
|
-
walletRecommendList: [],
|
|
2403
|
-
userIdentificationCodes: [],
|
|
2404
|
-
transformList: [],
|
|
2405
|
-
noApplicableVoucher: [],
|
|
2406
|
-
products: []
|
|
2407
|
-
};
|
|
2408
|
-
}
|
|
2409
2112
|
const result = await this.store.payment.wallet.initializeWalletDataFromBusinessAsync(
|
|
2410
2113
|
walletBusinessData
|
|
2411
2114
|
);
|
|
2412
2115
|
await this.core.effects.emit(`${this.name}:onWalletDataInitialized`, {
|
|
2413
|
-
orderId:
|
|
2116
|
+
orderId: snapshot.identity.orderId,
|
|
2414
2117
|
customerId: walletBusinessData.customer_id,
|
|
2415
2118
|
walletBusinessData: {
|
|
2416
2119
|
customer_id: walletBusinessData.customer_id,
|
|
@@ -2421,202 +2124,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
2421
2124
|
});
|
|
2422
2125
|
return result;
|
|
2423
2126
|
}
|
|
2424
|
-
getCommittedWalletAssets() {
|
|
2425
|
-
var _a, _b;
|
|
2426
|
-
const payments = ((_b = (_a = this.store.order) == null ? void 0 : _a.getOrderPayments) == null ? void 0 : _b.call(_a)) || [];
|
|
2427
|
-
const committed = payments.filter((payment) => {
|
|
2428
|
-
const voucherId = payment == null ? void 0 : payment.voucher_id;
|
|
2429
|
-
if (voucherId === void 0 || voucherId === null || voucherId === 0) {
|
|
2430
|
-
return false;
|
|
2431
|
-
}
|
|
2432
|
-
return (payment == null ? void 0 : payment.status) === "paid" || (payment == null ? void 0 : payment.isSynced) === true || (payment == null ? void 0 : payment.order_payment_id) !== void 0 && (payment == null ? void 0 : payment.order_payment_id) !== null && (payment == null ? void 0 : payment.order_payment_id) !== "";
|
|
2433
|
-
});
|
|
2434
|
-
return {
|
|
2435
|
-
ids: committed.map((payment) => payment.voucher_id),
|
|
2436
|
-
assets: committed.map((payment) => {
|
|
2437
|
-
var _a2;
|
|
2438
|
-
const fundRecord = (payment == null ? void 0 : payment.fund_record) || {};
|
|
2439
|
-
const walletPassName = fundRecord.wallet_pass_name;
|
|
2440
|
-
const title = walletPassName && typeof walletPassName === "object" ? walletPassName.default || Object.values(walletPassName)[0] : walletPassName;
|
|
2441
|
-
const code = String((payment == null ? void 0 : payment.code) || "").toUpperCase();
|
|
2442
|
-
const tag = ((_a2 = Object.entries(WALLET_PAYMENT_CODE_BY_TAG).find(
|
|
2443
|
-
([, paymentCode]) => paymentCode === code
|
|
2444
|
-
)) == null ? void 0 : _a2[0]) || fundRecord.tag;
|
|
2445
|
-
return {
|
|
2446
|
-
id: payment.voucher_id,
|
|
2447
|
-
voucher_id: payment.voucher_id,
|
|
2448
|
-
code: fundRecord.code,
|
|
2449
|
-
tag,
|
|
2450
|
-
product_name: title || payment.name,
|
|
2451
|
-
name: title || payment.name,
|
|
2452
|
-
amount: Number(payment.amount || 0),
|
|
2453
|
-
_available_max_amount: Number(payment.amount || 0),
|
|
2454
|
-
unified_available_status: 1,
|
|
2455
|
-
_unified_available_status: 1,
|
|
2456
|
-
_committed_payment: payment
|
|
2457
|
-
};
|
|
2458
|
-
})
|
|
2459
|
-
};
|
|
2460
|
-
}
|
|
2461
|
-
async publishWalletAssetsState(state) {
|
|
2462
|
-
await this.effectsEmit(import_types.BaseSalesHookNames.onWalletAssetsStateChanged, {
|
|
2463
|
-
state
|
|
2464
|
-
});
|
|
2465
|
-
return state;
|
|
2466
|
-
}
|
|
2467
|
-
async syncSelectedWalletAssets(state) {
|
|
2468
|
-
if (!this.store.order || !this.store.payment) {
|
|
2469
|
-
throw new Error("订单或支付模块未初始化");
|
|
2470
|
-
}
|
|
2471
|
-
let paymentMethods = this.getPaymentMethods();
|
|
2472
|
-
if (!paymentMethods.length && state.selectedItems.length) {
|
|
2473
|
-
paymentMethods = await this.getPaymentMethodsAsync();
|
|
2474
|
-
}
|
|
2475
|
-
const methodByCode = new Map(
|
|
2476
|
-
paymentMethods.map((method) => [String(method.code || "").toUpperCase(), method])
|
|
2477
|
-
);
|
|
2478
|
-
const preparePayments = this.store.payment.wallet.formatWalletPassList2PreparePayments(
|
|
2479
|
-
state.selectedItems
|
|
2480
|
-
);
|
|
2481
|
-
const selectedAssetById = new Map(
|
|
2482
|
-
state.selectedItems.map((asset) => [
|
|
2483
|
-
String(getSharedWalletAssetId(asset)),
|
|
2484
|
-
asset
|
|
2485
|
-
])
|
|
2486
|
-
);
|
|
2487
|
-
const voucherPayments = preparePayments.flatMap((item) => {
|
|
2488
|
-
const asset = selectedAssetById.get(String(item.voucher_id));
|
|
2489
|
-
const paymentCode = WALLET_PAYMENT_CODE_BY_TAG[String(item.tag || (asset == null ? void 0 : asset.tag) || "")] || String(item.tag || (asset == null ? void 0 : asset.tag) || "").toUpperCase();
|
|
2490
|
-
const paymentMethod = methodByCode.get(paymentCode);
|
|
2491
|
-
const formattedAmount = Number(item.amount);
|
|
2492
|
-
const amount = Number.isFinite(formattedAmount) && formattedAmount > 0 ? formattedAmount : getSharedWalletAssetAmount(asset);
|
|
2493
|
-
if (!asset || !paymentMethod || !Number.isFinite(amount) || amount <= 0) {
|
|
2494
|
-
return [];
|
|
2495
|
-
}
|
|
2496
|
-
const walletPassUseValue = getSharedWalletPassUseValue({
|
|
2497
|
-
asset,
|
|
2498
|
-
amount,
|
|
2499
|
-
paymentMethod
|
|
2500
|
-
});
|
|
2501
|
-
return [
|
|
2502
|
-
{
|
|
2503
|
-
amount: amount.toFixed(2),
|
|
2504
|
-
code: paymentMethod.code,
|
|
2505
|
-
custom_payment_id: paymentMethod.id,
|
|
2506
|
-
name: paymentMethod.name,
|
|
2507
|
-
type: paymentMethod.type,
|
|
2508
|
-
voucher_id: item.voucher_id,
|
|
2509
|
-
wallet_pass_usage_unit: item.wallet_pass_usage_unit,
|
|
2510
|
-
wallet_pass_use_value: walletPassUseValue,
|
|
2511
|
-
fund_record: buildSharedWalletFundRecord({
|
|
2512
|
-
asset,
|
|
2513
|
-
amount,
|
|
2514
|
-
paymentMethod
|
|
2515
|
-
})
|
|
2516
|
-
}
|
|
2517
|
-
];
|
|
2518
|
-
});
|
|
2519
|
-
const payments = this.updateVoucherOrderPayments(voucherPayments, {
|
|
2520
|
-
status: "payment_pending"
|
|
2521
|
-
});
|
|
2522
|
-
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
2523
|
-
return payments;
|
|
2524
|
-
}
|
|
2525
|
-
/** 读取购物车与 Shared Checkout 共用的钱包资产状态。 */
|
|
2526
|
-
getWalletAssetsState() {
|
|
2527
|
-
if (!this.store.payment)
|
|
2528
|
-
throw new Error("payment 模块未初始化");
|
|
2529
|
-
return this.store.payment.wallet.getWalletAssetsState();
|
|
2530
|
-
}
|
|
2531
|
-
/** 导出 Shared Checkout 跨运行时恢复所需的钱包状态与搜索缓存。 */
|
|
2532
|
-
exportWalletAssetsSnapshot() {
|
|
2533
|
-
if (!this.store.payment)
|
|
2534
|
-
throw new Error("payment 模块未初始化");
|
|
2535
|
-
return this.store.payment.wallet.exportWalletAssetsSnapshot();
|
|
2536
|
-
}
|
|
2537
|
-
/**
|
|
2538
|
-
* 恢复 Shared Checkout 钱包快照,并把选择重新同步为订单 pending payment。
|
|
2539
|
-
*/
|
|
2540
|
-
async importWalletAssetsSnapshot(snapshot) {
|
|
2541
|
-
if (!this.store.payment)
|
|
2542
|
-
throw new Error("payment 模块未初始化");
|
|
2543
|
-
const state = this.store.payment.wallet.importWalletAssetsSnapshot(snapshot);
|
|
2544
|
-
await this.syncSelectedWalletAssets(state);
|
|
2545
|
-
return this.publishWalletAssetsState(state);
|
|
2546
|
-
}
|
|
2547
|
-
/**
|
|
2548
|
-
* 基于当前订单快照刷新钱包资产。商品变化保留并重验选择;客户变化强制清空。
|
|
2549
|
-
*/
|
|
2550
|
-
async refreshWalletAssets(params) {
|
|
2551
|
-
if (!this.store.order)
|
|
2552
|
-
throw new Error("order 模块未初始化");
|
|
2553
|
-
if (!this.store.payment)
|
|
2554
|
-
throw new Error("payment 模块未初始化");
|
|
2555
|
-
const refreshSequence = ++this.walletAssetsRefreshSequence;
|
|
2556
|
-
const wallet = this.store.payment.wallet;
|
|
2557
|
-
const businessData = this.buildWalletInitBusinessData(params);
|
|
2558
|
-
if (!businessData) {
|
|
2559
|
-
wallet.clearAllCache();
|
|
2560
|
-
const emptyState = wallet.getWalletAssetsState();
|
|
2561
|
-
this.updateVoucherOrderPayments([], { status: "payment_pending" });
|
|
2562
|
-
return this.publishWalletAssetsState(emptyState);
|
|
2563
|
-
}
|
|
2564
|
-
const previousState = wallet.getWalletAssetsState();
|
|
2565
|
-
const hasPreviousWalletContext = previousState.status !== "idle" || previousState.items.length > 0 || previousState.selectedIds.length > 0 || previousState.customerId !== void 0;
|
|
2566
|
-
const customerChanged = hasPreviousWalletContext && String(previousState.customerId ?? "") !== String(businessData.customer_id ?? "");
|
|
2567
|
-
if (customerChanged) {
|
|
2568
|
-
const clearedState = wallet.clearWalletAssetSelection();
|
|
2569
|
-
this.updateVoucherOrderPayments([], { status: "payment_pending" });
|
|
2570
|
-
await this.publishWalletAssetsState(clearedState);
|
|
2571
|
-
}
|
|
2572
|
-
const refreshTask = wallet.refreshWalletAssetsFromBusinessAsync(
|
|
2573
|
-
businessData,
|
|
2574
|
-
{
|
|
2575
|
-
preserveSelection: (params == null ? void 0 : params.preserveSelection) !== false && !customerChanged
|
|
2576
|
-
}
|
|
2577
|
-
);
|
|
2578
|
-
await this.publishWalletAssetsState(wallet.getWalletAssetsState());
|
|
2579
|
-
let state = await refreshTask;
|
|
2580
|
-
if (refreshSequence !== this.walletAssetsRefreshSequence) {
|
|
2581
|
-
return wallet.getWalletAssetsState();
|
|
2582
|
-
}
|
|
2583
|
-
if (state.status !== "error") {
|
|
2584
|
-
const committed = this.getCommittedWalletAssets();
|
|
2585
|
-
state = wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
2586
|
-
}
|
|
2587
|
-
await this.syncSelectedWalletAssets(state);
|
|
2588
|
-
return this.publishWalletAssetsState(state);
|
|
2589
|
-
}
|
|
2590
|
-
/** 选择或取消单张钱包资产,并立即同步 pending wallet payments。 */
|
|
2591
|
-
async selectWalletAsset(params) {
|
|
2592
|
-
if (!this.store.payment)
|
|
2593
|
-
throw new Error("payment 模块未初始化");
|
|
2594
|
-
const state = this.store.payment.wallet.selectWalletAsset(params.assetId, {
|
|
2595
|
-
selected: params.selected,
|
|
2596
|
-
source: params.source
|
|
2597
|
-
});
|
|
2598
|
-
await this.syncSelectedWalletAssets(state);
|
|
2599
|
-
return this.publishWalletAssetsState(state);
|
|
2600
|
-
}
|
|
2601
|
-
/** 扫码精确查券;仅可用资产会被自动选中。 */
|
|
2602
|
-
async scanWalletAsset(code) {
|
|
2603
|
-
if (!this.store.payment)
|
|
2604
|
-
throw new Error("payment 模块未初始化");
|
|
2605
|
-
const result = await this.store.payment.wallet.scanWalletAssetAsync(code);
|
|
2606
|
-
if (result.type === "normalCode") {
|
|
2607
|
-
await this.syncSelectedWalletAssets(result.state);
|
|
2608
|
-
await this.publishWalletAssetsState(result.state);
|
|
2609
|
-
}
|
|
2610
|
-
return result;
|
|
2611
|
-
}
|
|
2612
|
-
/** 清空全部未确认钱包选择,已支付钱包项由 Order 模块继续保留。 */
|
|
2613
|
-
async clearWalletAssetSelection() {
|
|
2614
|
-
if (!this.store.payment)
|
|
2615
|
-
throw new Error("payment 模块未初始化");
|
|
2616
|
-
const state = this.store.payment.wallet.clearWalletAssetSelection();
|
|
2617
|
-
await this.syncSelectedWalletAssets(state);
|
|
2618
|
-
return this.publishWalletAssetsState(state);
|
|
2619
|
-
}
|
|
2620
2127
|
/**
|
|
2621
2128
|
* 更新当前订单客户字段。
|
|
2622
2129
|
*
|
|
@@ -2653,346 +2160,28 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
2653
2160
|
getPaymentMethods() {
|
|
2654
2161
|
return [...this.paymentMethodsCache];
|
|
2655
2162
|
}
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
} catch {
|
|
2672
|
-
return total;
|
|
2673
|
-
}
|
|
2674
|
-
}, new import_decimal.default(0));
|
|
2675
|
-
}
|
|
2676
|
-
/** 读取现金 action 所需的支付方式、待付金额和快捷金额。 */
|
|
2677
|
-
async getCashPaymentConfig() {
|
|
2678
|
-
var _a, _b, _c, _d, _e, _f;
|
|
2679
|
-
if (!this.store.payment)
|
|
2680
|
-
throw new Error("payment 模块未初始化");
|
|
2681
|
-
let paymentMethods = this.getPaymentMethods();
|
|
2682
|
-
let paymentMethod = this.findCashPaymentMethod(paymentMethods);
|
|
2683
|
-
if (!paymentMethod) {
|
|
2684
|
-
paymentMethods = await this.getPaymentMethodsAsync();
|
|
2685
|
-
paymentMethod = this.findCashPaymentMethod(paymentMethods);
|
|
2686
|
-
}
|
|
2687
|
-
const amountSnapshot = (_b = (_a = this.store.order) == null ? void 0 : _a.getOrderAmountSnapshot) == null ? void 0 : _b.call(_a);
|
|
2688
|
-
const pendingWalletAmount = this.getPendingWalletPaymentAmount();
|
|
2689
|
-
const amountDue = import_decimal.default.max(
|
|
2690
|
-
new import_decimal.default((amountSnapshot == null ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount),
|
|
2691
|
-
0
|
|
2692
|
-
).toDecimalPlaces(2).toNumber();
|
|
2693
|
-
const currency = ((_e = (_d = (_c = this.store.order) == null ? void 0 : _c.getTempOrder) == null ? void 0 : _d.call(_c)) == null ? void 0 : _e.currency_code) || ((_f = this.otherParams) == null ? void 0 : _f.currency) || "USD";
|
|
2694
|
-
const recommendedAmounts = amountDue > 0 ? this.store.payment.cash.getRecommendedAmount(amountDue, currency) : [];
|
|
2695
|
-
return {
|
|
2696
|
-
available: Boolean(paymentMethod && amountDue > 0),
|
|
2697
|
-
paymentMethod,
|
|
2698
|
-
amountDue,
|
|
2699
|
-
recommendedAmounts
|
|
2700
|
-
};
|
|
2701
|
-
}
|
|
2702
|
-
/**
|
|
2703
|
-
* 确认足额覆盖订单的 pending Wallet 支付并提交订单。
|
|
2704
|
-
*
|
|
2705
|
-
* Order 模块在构造提交参数时将 pending voucher 转为 paid;只有提交成功后
|
|
2706
|
-
* 才同步 Wallet committed 状态。失败时恢复调用前 payments,允许用户重试。
|
|
2707
|
-
*/
|
|
2708
|
-
async confirmWalletPayment() {
|
|
2709
|
-
var _a, _b, _c, _d, _e;
|
|
2710
|
-
if (!this.store.order)
|
|
2711
|
-
throw new Error("order 模块未初始化");
|
|
2712
|
-
const beforePayments = (0, import_lodash_es.cloneDeep)(this.store.order.getOrderPayments());
|
|
2713
|
-
const pendingWalletAmount = this.getPendingWalletPaymentAmount(beforePayments);
|
|
2714
|
-
if (pendingWalletAmount.lte(0)) {
|
|
2715
|
-
throw new Error("当前订单没有待确认的 Wallet 支付");
|
|
2716
|
-
}
|
|
2717
|
-
const amountSnapshot = (_b = (_a = this.store.order).getOrderAmountSnapshot) == null ? void 0 : _b.call(_a);
|
|
2718
|
-
const effectiveAmountDue = import_decimal.default.max(
|
|
2719
|
-
new import_decimal.default((amountSnapshot == null ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount),
|
|
2720
|
-
0
|
|
2721
|
-
);
|
|
2722
|
-
if (effectiveAmountDue.gt(0.01)) {
|
|
2723
|
-
throw new Error("Wallet 支付尚未覆盖全部待支付金额");
|
|
2724
|
-
}
|
|
2725
|
-
const beforePaymentStatus = (_c = this.store.order.getTempOrder()) == null ? void 0 : _c.payment_status;
|
|
2726
|
-
let submitResult;
|
|
2727
|
-
try {
|
|
2728
|
-
submitResult = await this.submitSalesOrder({
|
|
2729
|
-
smallTicketDataFlag: 1,
|
|
2730
|
-
confirmPendingVoucherPayments: true
|
|
2731
|
-
});
|
|
2732
|
-
if (isRejectedSalesSubmitResult(submitResult)) {
|
|
2733
|
-
throw new Error(getSalesSubmitErrorMessage(submitResult));
|
|
2734
|
-
}
|
|
2735
|
-
} catch (error) {
|
|
2736
|
-
this.store.order.setOrderPayments(beforePayments);
|
|
2737
|
-
const restoredTempOrder = this.store.order.getTempOrder();
|
|
2738
|
-
if (restoredTempOrder && beforePaymentStatus !== void 0) {
|
|
2739
|
-
restoredTempOrder.payment_status = beforePaymentStatus;
|
|
2740
|
-
this.store.order.persistTempOrder();
|
|
2741
|
-
}
|
|
2742
|
-
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
2743
|
-
throw error;
|
|
2744
|
-
}
|
|
2745
|
-
if (this.store.payment) {
|
|
2746
|
-
try {
|
|
2747
|
-
const committed = this.getCommittedWalletAssets();
|
|
2748
|
-
const walletState = this.store.payment.wallet.setCommittedWalletAssets(
|
|
2749
|
-
committed.ids,
|
|
2750
|
-
committed.assets
|
|
2751
|
-
);
|
|
2752
|
-
await this.publishWalletAssetsState(walletState);
|
|
2753
|
-
} catch (error) {
|
|
2754
|
-
this.logWarning("confirmWalletPayment: Wallet committed 状态同步失败", {
|
|
2755
|
-
error: error instanceof Error ? error.message : String(error)
|
|
2756
|
-
});
|
|
2757
|
-
}
|
|
2163
|
+
/** 轻量舍入能力,供现金支付 UI 计算 rounding_amount。 */
|
|
2164
|
+
roundAmount(params) {
|
|
2165
|
+
const amount = new import_decimal.default(params.amount || 0);
|
|
2166
|
+
const interval = new import_decimal.default(params.interval || 0.05);
|
|
2167
|
+
const rule = params.rule || "standard_rounding";
|
|
2168
|
+
const quotient = amount.div(interval);
|
|
2169
|
+
let roundedQuotient;
|
|
2170
|
+
if (rule === "always_up") {
|
|
2171
|
+
roundedQuotient = quotient.ceil();
|
|
2172
|
+
} else if (rule === "always_down") {
|
|
2173
|
+
roundedQuotient = quotient.floor();
|
|
2174
|
+
} else if (rule === "standard_down") {
|
|
2175
|
+
roundedQuotient = quotient.toDecimalPlaces(0, import_decimal.default.ROUND_HALF_DOWN);
|
|
2176
|
+
} else {
|
|
2177
|
+
roundedQuotient = quotient.toDecimalPlaces(0, import_decimal.default.ROUND_HALF_UP);
|
|
2758
2178
|
}
|
|
2759
|
-
const
|
|
2179
|
+
const roundedAmount = roundedQuotient.times(interval).toDecimalPlaces(2);
|
|
2760
2180
|
return {
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
(latestAmountSnapshot == null ? void 0 : latestAmountSnapshot.amountGap) || 0
|
|
2765
|
-
).lte(0)
|
|
2766
|
-
};
|
|
2767
|
-
}
|
|
2768
|
-
/**
|
|
2769
|
-
* 购物车现金直付:写入现金记录并等待支付同步完成。
|
|
2770
|
-
* 同步失败会恢复调用前 payments(包含 Wallet pending 状态)。
|
|
2771
|
-
*/
|
|
2772
|
-
async payCash(params) {
|
|
2773
|
-
var _a, _b, _c, _d, _e;
|
|
2774
|
-
if (!this.store.order)
|
|
2775
|
-
throw new Error("order 模块未初始化");
|
|
2776
|
-
const amount = Number(params.amount || 0);
|
|
2777
|
-
if (!Number.isFinite(amount) || amount <= 0) {
|
|
2778
|
-
throw new Error("现金支付金额必须大于 0");
|
|
2779
|
-
}
|
|
2780
|
-
const config = await this.getCashPaymentConfig();
|
|
2781
|
-
const paymentMethod = config.paymentMethod;
|
|
2782
|
-
if (!paymentMethod)
|
|
2783
|
-
throw new Error("未找到可用的 CASHMANUAL 支付方式");
|
|
2784
|
-
if (config.amountDue <= 0)
|
|
2785
|
-
throw new Error("当前订单没有待支付金额");
|
|
2786
|
-
const roundingAmount = Number(params.roundingAmount || 0);
|
|
2787
|
-
const effectivePaymentAmount = new import_decimal.default(amount).minus(roundingAmount);
|
|
2788
|
-
if (effectivePaymentAmount.gt(new import_decimal.default(config.amountDue).plus(0.01))) {
|
|
2789
|
-
throw new Error("现金支付金额超过当前待支付金额");
|
|
2790
|
-
}
|
|
2791
|
-
const beforePayments = (0, import_lodash_es.cloneDeep)(this.store.order.getOrderPayments());
|
|
2792
|
-
const beforePaymentStatus = (_a = this.store.order.getTempOrder()) == null ? void 0 : _a.payment_status;
|
|
2793
|
-
const uniquePaymentNumber = (0, import_utils.createUuidV4)();
|
|
2794
|
-
const paymentTimestamp = (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss");
|
|
2795
|
-
const actualPaidAmount = Number(params.actualPaidAmount ?? amount);
|
|
2796
|
-
const changeAmount = Number(params.changeAmount || 0);
|
|
2797
|
-
if (!Number.isFinite(actualPaidAmount) || actualPaidAmount + 0.01 < amount) {
|
|
2798
|
-
throw new Error("顾客实收现金不能小于支付金额");
|
|
2799
|
-
}
|
|
2800
|
-
(_e = (_d = (_c = (_b = this.window) == null ? void 0 : _b.interaction) == null ? void 0 : _c.utils) == null ? void 0 : _d.postMessageToApp) == null ? void 0 : _e.call(_d, {
|
|
2801
|
-
module: "till",
|
|
2802
|
-
key: "open_till",
|
|
2803
|
-
data: { type: "cash" }
|
|
2804
|
-
});
|
|
2805
|
-
const payments = this.store.order.addOrderPayment({
|
|
2806
|
-
amount: amount.toFixed(2),
|
|
2807
|
-
code: paymentMethod.code,
|
|
2808
|
-
custom_payment_id: paymentMethod.id,
|
|
2809
|
-
name: paymentMethod.name,
|
|
2810
|
-
custom_payment_type: paymentMethod.type,
|
|
2811
|
-
voucher_id: 0,
|
|
2812
|
-
rounding_amount: roundingAmount.toFixed(2),
|
|
2813
|
-
metadata: {
|
|
2814
|
-
unique_payment_number: uniquePaymentNumber,
|
|
2815
|
-
actual_paid_amount: Number.isFinite(actualPaidAmount) ? actualPaidAmount : amount,
|
|
2816
|
-
change_given_amount: Number.isFinite(changeAmount) ? changeAmount : 0
|
|
2817
|
-
},
|
|
2818
|
-
payment_time: paymentTimestamp,
|
|
2819
|
-
created_at: paymentTimestamp
|
|
2820
|
-
});
|
|
2821
|
-
const payment = payments.find(
|
|
2822
|
-
(item) => {
|
|
2823
|
-
var _a2;
|
|
2824
|
-
return ((_a2 = item == null ? void 0 : item.metadata) == null ? void 0 : _a2.unique_payment_number) === uniquePaymentNumber;
|
|
2825
|
-
}
|
|
2826
|
-
);
|
|
2827
|
-
try {
|
|
2828
|
-
const syncResult = await this.syncPaymentsToOrder({
|
|
2829
|
-
payments,
|
|
2830
|
-
submitWhenPaid: true,
|
|
2831
|
-
smallTicketDataFlag: 1,
|
|
2832
|
-
confirmPendingVoucherPayments: true
|
|
2833
|
-
});
|
|
2834
|
-
if (this.store.payment) {
|
|
2835
|
-
const committed = this.getCommittedWalletAssets();
|
|
2836
|
-
const walletState = this.store.payment.wallet.setCommittedWalletAssets(
|
|
2837
|
-
committed.ids,
|
|
2838
|
-
committed.assets
|
|
2839
|
-
);
|
|
2840
|
-
await this.publishWalletAssetsState(walletState);
|
|
2841
|
-
}
|
|
2842
|
-
return {
|
|
2843
|
-
payment: payment || {},
|
|
2844
|
-
payments: this.store.order.getOrderPayments(),
|
|
2845
|
-
syncResult,
|
|
2846
|
-
isOrderFullyPaid: syncResult.isOrderFullyPaid
|
|
2847
|
-
};
|
|
2848
|
-
} catch (error) {
|
|
2849
|
-
this.store.order.setOrderPayments(beforePayments);
|
|
2850
|
-
const restoredTempOrder = this.store.order.getTempOrder();
|
|
2851
|
-
if (restoredTempOrder && beforePaymentStatus !== void 0) {
|
|
2852
|
-
restoredTempOrder.payment_status = beforePaymentStatus;
|
|
2853
|
-
this.store.order.persistTempOrder();
|
|
2854
|
-
}
|
|
2855
|
-
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
2856
|
-
throw error;
|
|
2857
|
-
}
|
|
2858
|
-
}
|
|
2859
|
-
/**
|
|
2860
|
-
* 提交一次已由支付设备确认成功的非 Wallet 支付。
|
|
2861
|
-
*
|
|
2862
|
-
* 与 addOrderPayment 不同,本入口不会启动后台 fire-and-forget 同步;调用方会等待
|
|
2863
|
-
* 本次 payment、当前 pending Wallet 以及订单提交共同完成。任何同步失败都会恢复
|
|
2864
|
-
* 调用前的 payments 与 payment_status,便于 UI 安全解锁并重试。
|
|
2865
|
-
*/
|
|
2866
|
-
async commitPaymentMethodPayment(params) {
|
|
2867
|
-
var _a, _b, _c, _d;
|
|
2868
|
-
if (!this.store.order)
|
|
2869
|
-
throw new Error("order 模块未初始化");
|
|
2870
|
-
const amount = Number(params.amount || 0);
|
|
2871
|
-
if (!Number.isFinite(amount) || amount <= 0) {
|
|
2872
|
-
throw new Error("支付金额必须大于 0");
|
|
2873
|
-
}
|
|
2874
|
-
let paymentMethods = this.getPaymentMethods();
|
|
2875
|
-
const findPaymentMethod = () => {
|
|
2876
|
-
const methodCode = String(params.paymentMethodCode || "").toUpperCase();
|
|
2877
|
-
return paymentMethods.find((method) => {
|
|
2878
|
-
const idMatched = params.paymentMethodId !== void 0 && String(method.id) === String(params.paymentMethodId);
|
|
2879
|
-
const codeMatched = Boolean(methodCode) && String(method.code || "").toUpperCase() === methodCode;
|
|
2880
|
-
return (idMatched || codeMatched) && method.enabled !== false && method.enable !== false;
|
|
2881
|
-
});
|
|
2181
|
+
originalAmount: amount.toFixed(2),
|
|
2182
|
+
roundedAmount: roundedAmount.toFixed(2),
|
|
2183
|
+
roundingDifference: roundedAmount.minus(amount).toFixed(2)
|
|
2882
2184
|
};
|
|
2883
|
-
let paymentMethod = findPaymentMethod();
|
|
2884
|
-
if (!paymentMethod) {
|
|
2885
|
-
paymentMethods = await this.getPaymentMethodsAsync();
|
|
2886
|
-
paymentMethod = findPaymentMethod();
|
|
2887
|
-
}
|
|
2888
|
-
if (!paymentMethod) {
|
|
2889
|
-
throw new Error(
|
|
2890
|
-
`未找到可用的支付方式:${params.paymentMethodCode || params.paymentMethodId || ""}`
|
|
2891
|
-
);
|
|
2892
|
-
}
|
|
2893
|
-
const amountSnapshot = (_b = (_a = this.store.order).getOrderAmountSnapshot) == null ? void 0 : _b.call(_a);
|
|
2894
|
-
const pendingWalletAmount = this.getPendingWalletPaymentAmount();
|
|
2895
|
-
const amountDue = import_decimal.default.max(
|
|
2896
|
-
new import_decimal.default((amountSnapshot == null ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount),
|
|
2897
|
-
0
|
|
2898
|
-
);
|
|
2899
|
-
if (amountDue.lte(0))
|
|
2900
|
-
throw new Error("当前订单没有待支付金额");
|
|
2901
|
-
if (new import_decimal.default(amount).gt(amountDue.plus(0.01))) {
|
|
2902
|
-
throw new Error("支付金额超过当前待支付金额");
|
|
2903
|
-
}
|
|
2904
|
-
const beforePayments = (0, import_lodash_es.cloneDeep)(this.store.order.getOrderPayments());
|
|
2905
|
-
const beforePaymentStatus = (_c = this.store.order.getTempOrder()) == null ? void 0 : _c.payment_status;
|
|
2906
|
-
const paymentTimestamp = (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss");
|
|
2907
|
-
const metadata = {
|
|
2908
|
-
...params.metadata || {},
|
|
2909
|
-
unique_payment_number: ((_d = params.metadata) == null ? void 0 : _d.unique_payment_number) || (0, import_utils.createUuidV4)()
|
|
2910
|
-
};
|
|
2911
|
-
const serviceCharge = params.serviceCharge ? {
|
|
2912
|
-
amount: String(params.serviceCharge.amount || 0),
|
|
2913
|
-
percentage: String(params.serviceCharge.percentage || 0)
|
|
2914
|
-
} : void 0;
|
|
2915
|
-
const serviceFee = serviceCharge ? new import_decimal.default(params.originAmount ?? amount).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : void 0;
|
|
2916
|
-
const payments = this.store.order.addOrderPayment({
|
|
2917
|
-
...params.paymentData || {},
|
|
2918
|
-
amount: amount.toFixed(2),
|
|
2919
|
-
...params.originAmount !== void 0 ? { origin_amount: Number(params.originAmount).toFixed(2) } : {},
|
|
2920
|
-
code: paymentMethod.code,
|
|
2921
|
-
custom_payment_id: paymentMethod.id,
|
|
2922
|
-
name: paymentMethod.name,
|
|
2923
|
-
custom_payment_type: paymentMethod.type,
|
|
2924
|
-
voucher_id: 0,
|
|
2925
|
-
...serviceCharge ? { service_charge: serviceCharge } : {},
|
|
2926
|
-
...serviceFee !== void 0 ? { service_fee: serviceFee } : {},
|
|
2927
|
-
metadata,
|
|
2928
|
-
payment_time: paymentTimestamp,
|
|
2929
|
-
created_at: paymentTimestamp
|
|
2930
|
-
});
|
|
2931
|
-
const payment = payments.find(
|
|
2932
|
-
(item) => {
|
|
2933
|
-
var _a2;
|
|
2934
|
-
return ((_a2 = item == null ? void 0 : item.metadata) == null ? void 0 : _a2.unique_payment_number) === metadata.unique_payment_number;
|
|
2935
|
-
}
|
|
2936
|
-
);
|
|
2937
|
-
try {
|
|
2938
|
-
const syncResult = await this.syncPaymentsToOrder({
|
|
2939
|
-
payments,
|
|
2940
|
-
submitWhenPaid: true,
|
|
2941
|
-
smallTicketDataFlag: 1,
|
|
2942
|
-
confirmPendingVoucherPayments: true
|
|
2943
|
-
});
|
|
2944
|
-
if (this.store.payment) {
|
|
2945
|
-
const committed = this.getCommittedWalletAssets();
|
|
2946
|
-
const walletState = this.store.payment.wallet.setCommittedWalletAssets(
|
|
2947
|
-
committed.ids,
|
|
2948
|
-
committed.assets
|
|
2949
|
-
);
|
|
2950
|
-
await this.publishWalletAssetsState(walletState);
|
|
2951
|
-
}
|
|
2952
|
-
return {
|
|
2953
|
-
payment: payment || {},
|
|
2954
|
-
payments: this.store.order.getOrderPayments(),
|
|
2955
|
-
syncResult,
|
|
2956
|
-
isOrderFullyPaid: syncResult.isOrderFullyPaid
|
|
2957
|
-
};
|
|
2958
|
-
} catch (error) {
|
|
2959
|
-
this.store.order.setOrderPayments(beforePayments);
|
|
2960
|
-
const restoredTempOrder = this.store.order.getTempOrder();
|
|
2961
|
-
if (restoredTempOrder && beforePaymentStatus !== void 0) {
|
|
2962
|
-
restoredTempOrder.payment_status = beforePaymentStatus;
|
|
2963
|
-
this.store.order.persistTempOrder();
|
|
2964
|
-
}
|
|
2965
|
-
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
2966
|
-
throw error;
|
|
2967
|
-
}
|
|
2968
|
-
}
|
|
2969
|
-
/**
|
|
2970
|
-
* 按当前店铺的现金舍入配置计算金额,供现金支付 UI 使用。
|
|
2971
|
-
*
|
|
2972
|
-
* 舍入开关取自 CASHMANUAL 支付方式;舍入规则取自
|
|
2973
|
-
* otherParams.order_rounding_setting,金额算法统一由 PaymentModule 维护。
|
|
2974
|
-
*/
|
|
2975
|
-
async roundAmount(params) {
|
|
2976
|
-
var _a, _b, _c;
|
|
2977
|
-
const amount = params.amount;
|
|
2978
|
-
const cashManualPayment = this.paymentMethodsCache.find(
|
|
2979
|
-
(paymentMethod) => paymentMethod.code === "CASHMANUAL"
|
|
2980
|
-
);
|
|
2981
|
-
if (!((_a = cashManualPayment == null ? void 0 : cashManualPayment.metadata) == null ? void 0 : _a.order_rounding_switch)) {
|
|
2982
|
-
return {
|
|
2983
|
-
originalAmount: amount.toString(),
|
|
2984
|
-
roundedAmount: amount.toString(),
|
|
2985
|
-
roundingDifference: "0.00"
|
|
2986
|
-
};
|
|
2987
|
-
}
|
|
2988
|
-
if (!this.payment) {
|
|
2989
|
-
throw new Error("payment 模块未初始化");
|
|
2990
|
-
}
|
|
2991
|
-
return this.payment.roundAmountAsync(
|
|
2992
|
-
amount,
|
|
2993
|
-
(_b = this.otherParams.order_rounding_setting) == null ? void 0 : _b.interval,
|
|
2994
|
-
(_c = this.otherParams.order_rounding_setting) == null ? void 0 : _c.type
|
|
2995
|
-
);
|
|
2996
2185
|
}
|
|
2997
2186
|
/**
|
|
2998
2187
|
* 发送支付链接。
|