@pisell/private-materials 6.6.45 → 6.6.47
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +1 -1
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +1 -1
- package/es/components/appointmentBooking/components/Voucher/index.js +22 -7
- package/es/components/booking/addons/index.js +3 -2
- package/es/components/booking/components/footer/amount.js +4 -5
- package/es/components/booking/components/footer/index.js +7 -0
- package/es/components/booking/components/footer/utils.d.ts +1 -1
- package/es/components/booking/components/footer/utils.js +10 -15
- package/es/components/booking/components/voucher/index.js +7 -1
- package/es/components/booking/components/voucher/index.less +4 -1
- package/es/components/booking/components/voucherModal/index.less +1 -0
- package/es/components/booking/hooks/useQuotation.js +2 -2
- package/es/components/booking/info2/service/editService/index.js +10 -8
- package/es/components/booking/info2/service/editService/utils.d.ts +0 -1
- package/es/components/booking/info2/service/editService/utils.js +0 -16
- package/es/components/booking/payments/index.js +1 -1
- package/es/components/checkout/components/WalletPassModule/index.js +1 -0
- package/es/components/checkout/components/WalletPassModule/utils.d.ts +1 -0
- package/es/components/checkout/components/WalletPassModule/utils.js +17 -3
- package/es/components/checkout/hooks/useWalletPass.d.ts +1 -1
- package/es/components/checkout/hooks/useWalletPass.js +316 -192
- package/es/components/pay/toC/PaymentMethods/WalletPass/index.d.ts +5 -0
- package/es/components/pay/toC/PaymentMethods/WalletPass/index.js +166 -145
- package/es/components/pay/toC/PaymentMethods/WalletPass/serve.d.ts +6 -0
- package/es/components/pay/toC/PaymentMethods/WalletPass/utils.js +3 -3
- package/es/components/pay/toC/WalletPassBlock/index.js +3 -1
- package/es/components/pay/toC/index.js +66 -27
- package/es/components/pay/toC/model.d.ts +1 -0
- package/es/components/pay/toC/serve.d.ts +18 -0
- package/es/components/pay/toC/serve.js +29 -1
- package/es/components/pay/toC/utils.d.ts +2 -2
- package/es/components/pay/toC/utils.js +4 -0
- package/es/components/ticketBooking/components/addServiceVariant/addService.js +7 -4
- package/lib/components/appointmentBooking/components/Voucher/index.js +10 -2
- package/lib/components/booking/addons/index.js +3 -2
- package/lib/components/booking/components/footer/amount.js +4 -4
- package/lib/components/booking/components/footer/index.js +9 -0
- package/lib/components/booking/components/footer/utils.d.ts +1 -1
- package/lib/components/booking/components/footer/utils.js +10 -15
- package/lib/components/booking/components/voucher/index.js +7 -1
- package/lib/components/booking/components/voucher/index.less +4 -1
- package/lib/components/booking/components/voucherModal/index.less +1 -0
- package/lib/components/booking/hooks/useQuotation.js +2 -2
- package/lib/components/booking/info2/service/editService/index.js +24 -21
- package/lib/components/booking/info2/service/editService/utils.d.ts +0 -1
- package/lib/components/booking/info2/service/editService/utils.js +0 -16
- package/lib/components/booking/payments/index.js +1 -1
- package/lib/components/checkout/components/WalletPassModule/index.js +1 -0
- package/lib/components/checkout/components/WalletPassModule/utils.d.ts +1 -0
- package/lib/components/checkout/components/WalletPassModule/utils.js +18 -2
- package/lib/components/checkout/hooks/useWalletPass.d.ts +1 -1
- package/lib/components/checkout/hooks/useWalletPass.js +157 -108
- package/lib/components/pay/toC/PaymentMethods/WalletPass/index.d.ts +5 -0
- package/lib/components/pay/toC/PaymentMethods/WalletPass/index.js +90 -103
- package/lib/components/pay/toC/PaymentMethods/WalletPass/serve.d.ts +6 -0
- package/lib/components/pay/toC/PaymentMethods/WalletPass/utils.js +2 -2
- package/lib/components/pay/toC/WalletPassBlock/index.js +3 -1
- package/lib/components/pay/toC/index.js +52 -11
- package/lib/components/pay/toC/model.d.ts +1 -0
- package/lib/components/pay/toC/serve.d.ts +18 -0
- package/lib/components/pay/toC/serve.js +6 -0
- package/lib/components/pay/toC/utils.d.ts +2 -2
- package/lib/components/pay/toC/utils.js +4 -0
- package/lib/components/ticketBooking/components/addServiceVariant/addService.js +11 -7
- package/lowcode/eco-cup-list/meta.ts +63 -0
- package/lowcode/eco-customer-list/meta.ts +63 -0
- package/package.json +2 -2
|
@@ -44,24 +44,27 @@ var import_utils3 = require("../../booking/utils");
|
|
|
44
44
|
var import_pisellos = require("../../ticketBooking/hooks/pisellos");
|
|
45
45
|
var import_useShopDiscountModule = require("../../ticketBooking/hooks/pisellos/useShopDiscountModule");
|
|
46
46
|
var useWalletPass = (props) => {
|
|
47
|
-
const { onSelectChange, customAmount, clientId } = props;
|
|
47
|
+
const { onSelectChange, customAmount, clientId, totalAmount } = props;
|
|
48
48
|
const logger = (0, import_usePaymentLogger.default)();
|
|
49
49
|
const { executeIfActive } = (0, import_pisellos.useActiveExecute)();
|
|
50
50
|
const [walletRecommendList, setWalletRecommendList] = (0, import_react.useState)([]);
|
|
51
51
|
const [userIdentificationCodes, setUserIdentificationCodes] = (0, import_react.useState)(
|
|
52
52
|
[]
|
|
53
53
|
);
|
|
54
|
+
const [transformList, setTransformList] = (0, import_react.useState)([]);
|
|
55
|
+
const [noApplicableVoucher, setNoApplicableVoucher] = (0, import_react.useState)([]);
|
|
54
56
|
const initialOrderedDataRef = (0, import_react.useRef)([]);
|
|
55
57
|
const initialDiscountOrderRef = (0, import_react.useRef)([]);
|
|
56
58
|
const confirmedEditAmountIdsRef = (0, import_react.useRef)([]);
|
|
57
|
-
const timeoutRef = (0, import_react.useRef)(null);
|
|
58
59
|
const [searchIdentificationCodeList, setSearchIdentificationCodeList] = (0, import_react.useState)([]);
|
|
59
60
|
const [orderInfo, setOrderInfo] = (0, import_react.useState)({});
|
|
60
61
|
const [selectedWallet, setSelectedWallet] = (0, import_react.useState)([]);
|
|
61
62
|
const selectedWalletRef = (0, import_react.useRef)([]);
|
|
63
|
+
const [selectedVoucherIds, setSelectedVoucherIds] = (0, import_react.useState)([]);
|
|
62
64
|
const [disabledWalletData, setDisabledWalletData] = (0, import_react.useState)([]);
|
|
63
65
|
const notSetWalletSelectRef = (0, import_react.useRef)(false);
|
|
64
66
|
const showBestToastRef = (0, import_react.useRef)(false);
|
|
67
|
+
const [products, setProducts] = (0, import_react.useState)([]);
|
|
65
68
|
const selectedWalletIds = (0, import_react.useMemo)(() => {
|
|
66
69
|
return selectedWallet.map((item) => item.id);
|
|
67
70
|
}, [selectedWallet]);
|
|
@@ -73,6 +76,10 @@ var useWalletPass = (props) => {
|
|
|
73
76
|
const checkoutModule = pisellos.getModule("checkout");
|
|
74
77
|
const shopDiscount = (0, import_useShopDiscountModule.useShopDiscountModule)();
|
|
75
78
|
const paymentModule = checkoutModule == null ? void 0 : checkoutModule.payment;
|
|
79
|
+
const walletPassEvaluator = (0, import_react.useMemo)(() => {
|
|
80
|
+
var _a, _b;
|
|
81
|
+
return (_b = (_a = paymentModule == null ? void 0 : paymentModule.window) == null ? void 0 : _a.getWalletPassEvaluator) == null ? void 0 : _b.call(_a);
|
|
82
|
+
}, []);
|
|
76
83
|
const setWalletSelect = (0, import_ahooks.useMemoizedFn)((data2) => {
|
|
77
84
|
setSelectedWallet(data2);
|
|
78
85
|
selectedWalletRef.current = data2;
|
|
@@ -163,34 +170,61 @@ var useWalletPass = (props) => {
|
|
|
163
170
|
return orderedResult;
|
|
164
171
|
}
|
|
165
172
|
);
|
|
173
|
+
const allVouchersForCalculation = (0, import_react.useMemo)(() => {
|
|
174
|
+
return [...transformList || [], ...searchIdentificationCodeList || []];
|
|
175
|
+
}, [transformList, searchIdentificationCodeList]);
|
|
176
|
+
const selectedVouchers = (0, import_react.useMemo)(() => {
|
|
177
|
+
return selectedVoucherIds.map((id) => allVouchersForCalculation.find((v) => v.id === id)).filter(Boolean);
|
|
178
|
+
}, [selectedVoucherIds, allVouchersForCalculation]);
|
|
179
|
+
const { displayVouchers, displayOtherVouchers, selectedWithDetails, totalDeduction } = (0, import_react.useMemo)(() => {
|
|
180
|
+
if (!walletPassEvaluator || !allVouchersForCalculation.length || !totalAmount) {
|
|
181
|
+
return {
|
|
182
|
+
displayVouchers: [...transformList || [], ...noApplicableVoucher || []],
|
|
183
|
+
displayOtherVouchers: searchIdentificationCodeList || [],
|
|
184
|
+
selectedWithDetails: [],
|
|
185
|
+
totalDeduction: 0
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
const result = walletPassEvaluator.recalculateVouchers(
|
|
189
|
+
allVouchersForCalculation,
|
|
190
|
+
selectedVouchers,
|
|
191
|
+
totalAmount,
|
|
192
|
+
products || []
|
|
193
|
+
);
|
|
194
|
+
const currentCustomerVouchers = [];
|
|
195
|
+
const otherCustomerVouchers = [];
|
|
196
|
+
result.allWithUpdatedStatus.forEach((voucher) => {
|
|
197
|
+
const isSearchVoucher = searchIdentificationCodeList.some((item) => item.id === voucher.id);
|
|
198
|
+
if (isSearchVoucher) {
|
|
199
|
+
otherCustomerVouchers.push(voucher);
|
|
200
|
+
} else {
|
|
201
|
+
currentCustomerVouchers.push(voucher);
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
return {
|
|
205
|
+
displayVouchers: [...currentCustomerVouchers, ...noApplicableVoucher || []],
|
|
206
|
+
displayOtherVouchers: otherCustomerVouchers,
|
|
207
|
+
selectedWithDetails: result.selectedWithDetails,
|
|
208
|
+
totalDeduction: result.selectedWithDetails.reduce((sum, v) => sum + (v.actualDeduction || 0), 0)
|
|
209
|
+
};
|
|
210
|
+
}, [selectedVouchers, allVouchersForCalculation, transformList, searchIdentificationCodeList, noApplicableVoucher, totalAmount, products]);
|
|
211
|
+
(0, import_ahooks.useUpdateEffect)(() => {
|
|
212
|
+
notifySelectChange(selectedWithDetails);
|
|
213
|
+
setLoading(false);
|
|
214
|
+
}, [selectedWithDetails]);
|
|
166
215
|
const data = (0, import_react.useMemo)(() => {
|
|
167
216
|
return (0, import_utils2.formatMachineCodeServer2CardList)(
|
|
168
217
|
(0, import_utils.uniqueByKey)(
|
|
169
218
|
mergeDataWithInitialOrder([
|
|
170
219
|
...selectedWallet,
|
|
171
|
-
...
|
|
220
|
+
...displayVouchers,
|
|
221
|
+
...displayOtherVouchers
|
|
172
222
|
]),
|
|
173
223
|
"id"
|
|
174
224
|
),
|
|
175
|
-
|
|
225
|
+
selectedVoucherIds
|
|
176
226
|
);
|
|
177
|
-
}, [
|
|
178
|
-
const fetchWalletRecommendList = (0, import_ahooks.useMemoizedFn)(async (params) => {
|
|
179
|
-
setLoading(true);
|
|
180
|
-
setError(null);
|
|
181
|
-
try {
|
|
182
|
-
const result = await paymentModule.wallet.getWalletPassRecommendListAsync(
|
|
183
|
-
params
|
|
184
|
-
);
|
|
185
|
-
setWalletRecommendList(result);
|
|
186
|
-
return result;
|
|
187
|
-
} catch (err) {
|
|
188
|
-
setError(err instanceof Error ? err.message : "获取钱包推荐列表失败");
|
|
189
|
-
throw err;
|
|
190
|
-
} finally {
|
|
191
|
-
setLoading(false);
|
|
192
|
-
}
|
|
193
|
-
});
|
|
227
|
+
}, [displayVouchers, displayOtherVouchers, selectedVoucherIds, selectedWallet]);
|
|
194
228
|
const fetchUserIdentificationCodes = (0, import_ahooks.useMemoizedFn)(async (params) => {
|
|
195
229
|
setLoading(true);
|
|
196
230
|
setError(null);
|
|
@@ -233,37 +267,69 @@ var useWalletPass = (props) => {
|
|
|
233
267
|
});
|
|
234
268
|
const handleSearchIdentificationCodeCompleted = (0, import_ahooks.useMemoizedFn)((data2) => {
|
|
235
269
|
const { currentSearchResults, cachedSearchResults } = data2;
|
|
270
|
+
let formattedResults = currentSearchResults;
|
|
271
|
+
if (walletPassEvaluator && currentSearchResults.length > 0 && totalAmount) {
|
|
272
|
+
formattedResults = walletPassEvaluator.searchVoucherFormat({
|
|
273
|
+
vouchers: currentSearchResults,
|
|
274
|
+
orderTotalAmount: totalAmount,
|
|
275
|
+
products: products || []
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
let formattedCachedResults = cachedSearchResults || [];
|
|
279
|
+
if (walletPassEvaluator && cachedSearchResults && cachedSearchResults.length > 0 && totalAmount) {
|
|
280
|
+
formattedCachedResults = walletPassEvaluator.searchVoucherFormat({
|
|
281
|
+
vouchers: cachedSearchResults,
|
|
282
|
+
orderTotalAmount: totalAmount,
|
|
283
|
+
products: products || []
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
const mergedSearchResults = (0, import_utils.uniqueByKey)(
|
|
287
|
+
[...formattedCachedResults || [], ...formattedResults],
|
|
288
|
+
"id"
|
|
289
|
+
);
|
|
236
290
|
let isAvailableData = [];
|
|
237
291
|
let isDisabledData = [];
|
|
238
|
-
if (
|
|
239
|
-
|
|
240
|
-
if (
|
|
292
|
+
if (formattedResults.length > 0) {
|
|
293
|
+
formattedResults.forEach((item) => {
|
|
294
|
+
if ((0, import_utils2.getVoucherAvailableStatus)(item)) {
|
|
241
295
|
isAvailableData.push(item);
|
|
242
296
|
} else {
|
|
243
297
|
isDisabledData.push(item);
|
|
244
298
|
}
|
|
245
299
|
});
|
|
246
300
|
}
|
|
247
|
-
|
|
301
|
+
const availableData = mergedSearchResults.filter((item) => (0, import_utils2.getVoucherAvailableStatus)(item));
|
|
302
|
+
const allDisabledData = mergedSearchResults.filter((item) => !(0, import_utils2.getVoucherAvailableStatus)(item));
|
|
303
|
+
setDisabledWalletData(allDisabledData);
|
|
248
304
|
let newValues = [...selectedWalletRef.current];
|
|
249
305
|
if (isAvailableData.length === 1) {
|
|
250
306
|
newValues = [...selectedWalletRef.current, ...isAvailableData];
|
|
251
307
|
}
|
|
252
|
-
setSearchIdentificationCodeList(
|
|
308
|
+
setSearchIdentificationCodeList(availableData);
|
|
309
|
+
setNoApplicableVoucher(allDisabledData);
|
|
253
310
|
setWalletSelect(newValues);
|
|
254
|
-
|
|
311
|
+
setSelectedVoucherIds(newValues.map((item) => item.id));
|
|
255
312
|
});
|
|
256
313
|
const onOrderCreated = (0, import_ahooks.useMemoizedFn)(() => {
|
|
314
|
+
var _a, _b;
|
|
257
315
|
const orderInfo2 = checkoutModule.getOrderOriginalData();
|
|
258
316
|
setOrderInfo(orderInfo2);
|
|
259
317
|
const recommendList = getCachedWalletRecommendList();
|
|
260
318
|
const userIdentificationCodes2 = getCachedUserIdentificationCodes();
|
|
319
|
+
const walletInitData = ((_b = (_a = paymentModule == null ? void 0 : paymentModule.wallet) == null ? void 0 : _a.getStoredWalletInitData) == null ? void 0 : _b.call(_a)) || {};
|
|
320
|
+
const transformListData = walletInitData.transformList || userIdentificationCodes2;
|
|
321
|
+
const noApplicableVoucherData = walletInitData.noApplicableVoucher || [];
|
|
322
|
+
const productsData = walletInitData.products || [];
|
|
261
323
|
const initialData = [...recommendList, ...userIdentificationCodes2];
|
|
262
324
|
setWalletRecommendList(recommendList);
|
|
263
|
-
setUserIdentificationCodes(
|
|
325
|
+
setUserIdentificationCodes(userIdentificationCodes2);
|
|
326
|
+
setTransformList(transformListData);
|
|
327
|
+
setNoApplicableVoucher(noApplicableVoucherData);
|
|
328
|
+
setProducts(productsData);
|
|
264
329
|
initialOrderedDataRef.current = initialData;
|
|
265
330
|
if (!notSetWalletSelectRef.current) {
|
|
266
331
|
setWalletSelect(recommendList);
|
|
332
|
+
setSelectedVoucherIds(recommendList.map((item) => item.id));
|
|
267
333
|
const select = paymentModule.wallet.formatWalletPassList2PreparePayments(recommendList).map((item) => ({
|
|
268
334
|
code: item.tag,
|
|
269
335
|
voucher_id: item.voucher_id,
|
|
@@ -279,6 +345,7 @@ var useWalletPass = (props) => {
|
|
|
279
345
|
onSelectChange == null ? void 0 : onSelectChange(select);
|
|
280
346
|
} else {
|
|
281
347
|
setWalletSelect([]);
|
|
348
|
+
setSelectedVoucherIds([]);
|
|
282
349
|
notSetWalletSelectRef.current = false;
|
|
283
350
|
onSelectChange == null ? void 0 : onSelectChange([]);
|
|
284
351
|
}
|
|
@@ -316,7 +383,7 @@ var useWalletPass = (props) => {
|
|
|
316
383
|
});
|
|
317
384
|
const handlePaymentStarted = (0, import_ahooks.useMemoizedFn)(
|
|
318
385
|
async (params) => {
|
|
319
|
-
if (params.paymentMethodCode !== "VOUCHER_BATCH") {
|
|
386
|
+
if (params.paymentMethodCode !== "VOUCHER_BATCH" && Number(customAmount || 0) > 0) {
|
|
320
387
|
notSetWalletSelectRef.current = true;
|
|
321
388
|
await checkoutModule.initWalletData({
|
|
322
389
|
order_wait_pay_amount: Number(customAmount)
|
|
@@ -398,14 +465,6 @@ var useWalletPass = (props) => {
|
|
|
398
465
|
);
|
|
399
466
|
};
|
|
400
467
|
}, [paymentModule]);
|
|
401
|
-
(0, import_react.useEffect)(() => {
|
|
402
|
-
return () => {
|
|
403
|
-
if (timeoutRef.current) {
|
|
404
|
-
clearTimeout(timeoutRef.current);
|
|
405
|
-
timeoutRef.current = null;
|
|
406
|
-
}
|
|
407
|
-
};
|
|
408
|
-
}, []);
|
|
409
468
|
const allList = (0, import_react.useMemo)(() => {
|
|
410
469
|
const reversedSearchData = [...searchIdentificationCodeList].reverse();
|
|
411
470
|
return [
|
|
@@ -425,33 +484,22 @@ var useWalletPass = (props) => {
|
|
|
425
484
|
)
|
|
426
485
|
).map((item) => item.code);
|
|
427
486
|
});
|
|
428
|
-
const
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
metadata: {}
|
|
445
|
-
});
|
|
446
|
-
onSelectChange == null ? void 0 : onSelectChange(select);
|
|
447
|
-
fetchUserIdentificationCodes({
|
|
448
|
-
prepare_payments,
|
|
449
|
-
available: 2,
|
|
450
|
-
filter_prepare_wallet_pass: 1,
|
|
451
|
-
other_exact_codes: getOtherExactCodes()
|
|
452
|
-
});
|
|
453
|
-
}
|
|
454
|
-
);
|
|
487
|
+
const notifySelectChange = (0, import_ahooks.useMemoizedFn)((selectedDetails) => {
|
|
488
|
+
const prepare_payments = paymentModule.wallet.formatWalletPassList2PreparePayments(selectedDetails);
|
|
489
|
+
const select = prepare_payments.map((item) => ({
|
|
490
|
+
voucher_id: item.voucher_id,
|
|
491
|
+
amount: item.amount,
|
|
492
|
+
code: item.tag,
|
|
493
|
+
wallet_pass_usage_unit: item.wallet_pass_usage_unit,
|
|
494
|
+
wallet_pass_use_value: item.wallet_pass_use_value
|
|
495
|
+
}));
|
|
496
|
+
logger == null ? void 0 : logger.addLog({
|
|
497
|
+
type: "info",
|
|
498
|
+
title: "useWalletPass_notifySelectChange 通知外部选择变化",
|
|
499
|
+
metadata: { selectedDetails, select }
|
|
500
|
+
});
|
|
501
|
+
onSelectChange == null ? void 0 : onSelectChange(select);
|
|
502
|
+
});
|
|
455
503
|
const handleSearchIdentificationCode = (0, import_ahooks.useMemoizedFn)((value) => {
|
|
456
504
|
return paymentModule.wallet.searchIdentificationCodeAsync({
|
|
457
505
|
code: value,
|
|
@@ -461,11 +509,27 @@ var useWalletPass = (props) => {
|
|
|
461
509
|
});
|
|
462
510
|
});
|
|
463
511
|
const handleSelectWallet = (0, import_ahooks.useMemoizedFn)((value) => {
|
|
464
|
-
|
|
512
|
+
setLoading(true);
|
|
513
|
+
const deselectedIds = selectedVoucherIds.filter(
|
|
514
|
+
(id) => !value.includes(id)
|
|
515
|
+
);
|
|
516
|
+
if (deselectedIds.length > 0) {
|
|
517
|
+
const needResetIds = deselectedIds.filter((id) => {
|
|
518
|
+
const voucher = allVouchersForCalculation.find((v) => v.id === id);
|
|
519
|
+
return (voucher == null ? void 0 : voucher.edit_current_amount) !== void 0;
|
|
520
|
+
});
|
|
521
|
+
if (needResetIds.length > 0) {
|
|
522
|
+
updateWalletDataById(needResetIds, { edit_current_amount: void 0 });
|
|
523
|
+
confirmedEditAmountIdsRef.current = confirmedEditAmountIdsRef.current.filter(
|
|
524
|
+
(id) => !needResetIds.includes(id)
|
|
525
|
+
);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
setSelectedVoucherIds(value);
|
|
529
|
+
const val = allVouchersForCalculation.filter(
|
|
465
530
|
(item) => value.includes(item.id)
|
|
466
531
|
);
|
|
467
532
|
setWalletSelect(val);
|
|
468
|
-
handleFetchUserIdentificationCodes(value);
|
|
469
533
|
});
|
|
470
534
|
const expiredWalletIds = (0, import_react.useMemo)(() => {
|
|
471
535
|
return (0, import_utils.uniqueByKey)(allList, "id").filter(
|
|
@@ -483,12 +547,12 @@ var useWalletPass = (props) => {
|
|
|
483
547
|
}, [allList]);
|
|
484
548
|
const clearAllSelectedWallet = (0, import_ahooks.useMemoizedFn)(() => {
|
|
485
549
|
var _a;
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
550
|
+
if (confirmedEditAmountIdsRef.current.length > 0) {
|
|
551
|
+
updateWalletDataById(confirmedEditAmountIdsRef.current, {
|
|
552
|
+
edit_current_amount: void 0
|
|
553
|
+
});
|
|
554
|
+
confirmedEditAmountIdsRef.current = [];
|
|
555
|
+
}
|
|
492
556
|
if (selectedWalletIds.length === 0 && selectedDiscountList.length === 0) {
|
|
493
557
|
return;
|
|
494
558
|
}
|
|
@@ -512,7 +576,14 @@ var useWalletPass = (props) => {
|
|
|
512
576
|
return;
|
|
513
577
|
}
|
|
514
578
|
setWalletSelect([]);
|
|
515
|
-
|
|
579
|
+
setSelectedVoucherIds([]);
|
|
580
|
+
logger == null ? void 0 : logger.addLog({
|
|
581
|
+
type: "info",
|
|
582
|
+
title: "useWalletPass_clearAllSelectedWallet 立即通知外部清空",
|
|
583
|
+
metadata: {}
|
|
584
|
+
});
|
|
585
|
+
onSelectChange == null ? void 0 : onSelectChange([]);
|
|
586
|
+
setLoading(false);
|
|
516
587
|
});
|
|
517
588
|
const isCurrentSelectionBest = (0, import_ahooks.useMemoizedFn)(() => {
|
|
518
589
|
if (walletRecommendList.length === 0) return true;
|
|
@@ -559,12 +630,9 @@ var useWalletPass = (props) => {
|
|
|
559
630
|
import_utils.locales.getText("wallet-pass-module-already-best-combination")
|
|
560
631
|
);
|
|
561
632
|
} else {
|
|
562
|
-
const select = searchIdentificationCodeList.filter((item) =>
|
|
633
|
+
const select = searchIdentificationCodeList.filter((item) => (0, import_utils2.getVoucherAvailableStatus)(item));
|
|
563
634
|
setWalletSelect(select);
|
|
564
|
-
|
|
565
|
-
select.map((item) => item.id),
|
|
566
|
-
select
|
|
567
|
-
);
|
|
635
|
+
setSelectedVoucherIds(select.map((item) => item.id));
|
|
568
636
|
if (select.length) {
|
|
569
637
|
Toast == null ? void 0 : Toast.success(
|
|
570
638
|
import_utils.locales.getText("wallet-pass-module-best-combination-selected")
|
|
@@ -593,14 +661,12 @@ var useWalletPass = (props) => {
|
|
|
593
661
|
} else {
|
|
594
662
|
if (hasGoodPass && !isBestDiscount) return;
|
|
595
663
|
setWalletSelect(newWalletRecommendList);
|
|
596
|
-
|
|
597
|
-
newWalletRecommendList.map((item) => item.id),
|
|
598
|
-
newWalletRecommendList
|
|
599
|
-
);
|
|
664
|
+
setSelectedVoucherIds(newWalletRecommendList.map((item) => item.id));
|
|
600
665
|
Toast == null ? void 0 : Toast.success(
|
|
601
666
|
import_utils.locales.getText("wallet-pass-module-best-combination-selected")
|
|
602
667
|
);
|
|
603
668
|
}
|
|
669
|
+
setLoading(false);
|
|
604
670
|
});
|
|
605
671
|
const handleSelectDiscount = (0, import_ahooks.useMemoizedFn)((value, option) => {
|
|
606
672
|
var _a, _b, _c;
|
|
@@ -647,6 +713,12 @@ var useWalletPass = (props) => {
|
|
|
647
713
|
updateData
|
|
648
714
|
);
|
|
649
715
|
setUserIdentificationCodes(newUserIdentificationCodes);
|
|
716
|
+
const newTransformList = updateArrayItemById(
|
|
717
|
+
transformList,
|
|
718
|
+
targetId,
|
|
719
|
+
updateData
|
|
720
|
+
);
|
|
721
|
+
setTransformList(newTransformList);
|
|
650
722
|
const newSearchIdentificationCodeList = updateArrayItemById(
|
|
651
723
|
searchIdentificationCodeList,
|
|
652
724
|
targetId,
|
|
@@ -662,6 +734,7 @@ var useWalletPass = (props) => {
|
|
|
662
734
|
return {
|
|
663
735
|
newWalletRecommendList,
|
|
664
736
|
newUserIdentificationCodes,
|
|
737
|
+
newTransformList,
|
|
665
738
|
newSearchIdentificationCodeList,
|
|
666
739
|
newSelectedWallet
|
|
667
740
|
};
|
|
@@ -670,44 +743,21 @@ var useWalletPass = (props) => {
|
|
|
670
743
|
const handleConfirmEditAmount = (0, import_ahooks.useMemoizedFn)(
|
|
671
744
|
(value, id, data2) => {
|
|
672
745
|
if (value === 0) {
|
|
673
|
-
const filteredIds =
|
|
746
|
+
const filteredIds = selectedVoucherIds.filter(
|
|
674
747
|
(walletId) => walletId !== data2.id
|
|
675
748
|
);
|
|
676
749
|
handleSelectWallet(filteredIds);
|
|
677
750
|
return;
|
|
678
751
|
}
|
|
752
|
+
setLoading(true);
|
|
679
753
|
if (!confirmedEditAmountIdsRef.current.includes(data2.id)) {
|
|
680
754
|
confirmedEditAmountIdsRef.current.push(data2.id);
|
|
681
755
|
}
|
|
682
756
|
updateWalletDataById(data2.id, { edit_current_amount: value });
|
|
683
|
-
if (timeoutRef.current) {
|
|
684
|
-
clearTimeout(timeoutRef.current);
|
|
685
|
-
}
|
|
686
|
-
timeoutRef.current = setTimeout(() => {
|
|
687
|
-
handleFetchUserIdentificationCodes(selectedWalletIds);
|
|
688
|
-
timeoutRef.current = null;
|
|
689
|
-
});
|
|
690
757
|
}
|
|
691
758
|
);
|
|
692
759
|
const handleBeforeEditAmount = (0, import_ahooks.useMemoizedFn)(
|
|
693
760
|
async (value, index, data2) => {
|
|
694
|
-
const result = await paymentModule.wallet.searchIdentificationCodeAsync(
|
|
695
|
-
{
|
|
696
|
-
code: data2.code,
|
|
697
|
-
prepare_payments: paymentModule.wallet.formatWalletPassList2PreparePayments(
|
|
698
|
-
selectedWalletRef.current.filter(
|
|
699
|
-
(item) => item.id !== data2.id
|
|
700
|
-
)
|
|
701
|
-
)
|
|
702
|
-
},
|
|
703
|
-
{ noCache: true }
|
|
704
|
-
);
|
|
705
|
-
if (result.data && result.data.length > 0) {
|
|
706
|
-
const resultItem = result.data.find((item) => item.id === data2.id);
|
|
707
|
-
if (resultItem) {
|
|
708
|
-
updateWalletDataById(data2.id, resultItem);
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
761
|
return true;
|
|
712
762
|
}
|
|
713
763
|
);
|
|
@@ -732,7 +782,6 @@ var useWalletPass = (props) => {
|
|
|
732
782
|
selectedDiscountList,
|
|
733
783
|
handleSelectDiscount,
|
|
734
784
|
customerName,
|
|
735
|
-
fetchWalletRecommendList,
|
|
736
785
|
fetchUserIdentificationCodes,
|
|
737
786
|
getCachedWalletRecommendList,
|
|
738
787
|
getCachedUserIdentificationCodes,
|
|
@@ -15,11 +15,16 @@ export interface WalletPassProps {
|
|
|
15
15
|
walletPass: {
|
|
16
16
|
cards: WalletPassDataType[];
|
|
17
17
|
amount: number;
|
|
18
|
+
recommended?: WalletPassDataType[];
|
|
19
|
+
transformList?: WalletPassDataType[];
|
|
20
|
+
noApplicableVoucher?: WalletPassDataType[];
|
|
18
21
|
};
|
|
19
22
|
walletSetting: {
|
|
20
23
|
name: string;
|
|
21
24
|
popup_status: 0 | 1;
|
|
22
25
|
};
|
|
26
|
+
orderDetail: any;
|
|
27
|
+
total_amount: number;
|
|
23
28
|
}
|
|
24
29
|
declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<WalletPassProps & React.RefAttributes<WalletPassRef>>>;
|
|
25
30
|
export default _default;
|