@pisell/private-materials 6.6.55 → 6.6.57
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/index.js +1 -1
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/preview.js +7 -7
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +8 -8
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +9 -9
- package/es/components/appointmentBooking/components/Voucher/index.js +7 -22
- package/es/components/booking/addons/index.js +2 -3
- package/es/components/booking/components/footer/amount.js +1 -1
- package/es/components/booking/components/footer/index.js +0 -7
- package/es/components/booking/components/footer/utils.d.ts +1 -1
- package/es/components/booking/components/footer/utils.js +5 -7
- package/es/components/booking/components/voucher/index.js +0 -6
- package/es/components/booking/components/voucher/index.less +1 -4
- package/es/components/booking/components/voucherModal/index.less +0 -1
- package/es/components/booking/dashboard/index.js +3 -3
- package/es/components/booking/info/service2/utils.d.ts +219 -0
- package/es/components/booking/info2/service/editService/index.js +2 -8
- package/es/components/checkout/components/WalletPassModule/index.js +0 -1
- package/es/components/checkout/components/WalletPassModule/utils.d.ts +0 -1
- package/es/components/checkout/components/WalletPassModule/utils.js +3 -17
- package/es/components/checkout/hooks/useWalletPass.d.ts +1 -1
- package/es/components/checkout/hooks/useWalletPass.js +215 -331
- package/es/components/pay/toC/PaymentMethods/WalletPass/index.d.ts +0 -5
- package/es/components/pay/toC/PaymentMethods/WalletPass/index.js +145 -166
- package/es/components/pay/toC/PaymentMethods/WalletPass/serve.d.ts +0 -6
- package/es/components/pay/toC/PaymentMethods/WalletPass/utils.js +3 -3
- package/es/components/pay/toC/WalletPassBlock/index.js +1 -3
- package/es/components/pay/toC/index.js +27 -66
- package/es/components/pay/toC/model.d.ts +0 -1
- package/es/components/pay/toC/serve.d.ts +0 -18
- package/es/components/pay/toC/serve.js +1 -29
- package/es/components/pay/toC/utils.d.ts +2 -2
- package/es/components/pay/toC/utils.js +0 -4
- package/es/components/ticketBooking/components/addServiceVariant/addService.js +4 -7
- package/es/pro/Login2.0/components/phoneValidation.js +65 -58
- package/lib/components/appointmentBooking/components/Voucher/index.js +2 -10
- package/lib/components/booking/addons/index.js +2 -3
- package/lib/components/booking/components/footer/amount.js +1 -1
- package/lib/components/booking/components/footer/index.js +0 -9
- package/lib/components/booking/components/footer/utils.d.ts +1 -1
- package/lib/components/booking/components/footer/utils.js +3 -5
- package/lib/components/booking/components/voucher/index.js +0 -6
- package/lib/components/booking/components/voucher/index.less +1 -4
- package/lib/components/booking/components/voucherModal/index.less +0 -1
- package/lib/components/booking/dashboard/index.js +3 -3
- package/lib/components/booking/info/service2/utils.d.ts +219 -0
- package/lib/components/booking/info2/service/editService/index.js +18 -24
- package/lib/components/checkout/components/WalletPassModule/index.js +0 -1
- package/lib/components/checkout/components/WalletPassModule/utils.d.ts +0 -1
- package/lib/components/checkout/components/WalletPassModule/utils.js +2 -18
- package/lib/components/checkout/hooks/useWalletPass.d.ts +1 -1
- package/lib/components/checkout/hooks/useWalletPass.js +131 -173
- package/lib/components/pay/toC/PaymentMethods/WalletPass/index.d.ts +0 -5
- package/lib/components/pay/toC/PaymentMethods/WalletPass/index.js +103 -90
- package/lib/components/pay/toC/PaymentMethods/WalletPass/serve.d.ts +0 -6
- package/lib/components/pay/toC/PaymentMethods/WalletPass/utils.js +2 -2
- package/lib/components/pay/toC/WalletPassBlock/index.js +1 -3
- package/lib/components/pay/toC/index.js +11 -52
- package/lib/components/pay/toC/model.d.ts +0 -1
- package/lib/components/pay/toC/serve.d.ts +0 -18
- package/lib/components/pay/toC/serve.js +0 -6
- package/lib/components/pay/toC/utils.d.ts +2 -2
- package/lib/components/pay/toC/utils.js +0 -4
- package/lib/components/ticketBooking/components/addServiceVariant/addService.js +7 -11
- package/lib/pro/Login2.0/components/phoneValidation.js +4 -2
- package/package.json +1 -1
|
@@ -19,16 +19,18 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
19
19
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
20
20
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
21
21
|
import { useState, useEffect, useMemo, useRef } from 'react';
|
|
22
|
-
import { useMemoizedFn
|
|
22
|
+
import { useMemoizedFn } from 'ahooks';
|
|
23
23
|
import { uniqueByKey, locales } from '@pisell/utils';
|
|
24
24
|
import { useToast } from '@pisell/materials';
|
|
25
25
|
import dayjs from 'dayjs';
|
|
26
26
|
import { usePisellOS } from "../../../hooks/useEngineContext";
|
|
27
|
-
import { formatDiscountWalletData, formatMachineCodeServer2CardList,
|
|
27
|
+
import { formatDiscountWalletData, formatMachineCodeServer2CardList, isSameContent } from "../components/WalletPassModule/utils";
|
|
28
28
|
import usePaymentLogger from "./usePaymentLogger";
|
|
29
29
|
import { isWalkIn } from "../../booking/utils";
|
|
30
30
|
import { useActiveExecute } from "../../ticketBooking/hooks/pisellos";
|
|
31
31
|
import { useShopDiscountModule } from "../../ticketBooking/hooks/pisellos/useShopDiscountModule";
|
|
32
|
+
import { useOsKey } from "../../ticketBooking/context";
|
|
33
|
+
import { getShopDiscountKey } from "../../ticketBooking/utils";
|
|
32
34
|
|
|
33
35
|
/**
|
|
34
36
|
* 自定义Hook:使用WalletPass功能
|
|
@@ -36,33 +38,25 @@ import { useShopDiscountModule } from "../../ticketBooking/hooks/pisellos/useSho
|
|
|
36
38
|
export var useWalletPass = function useWalletPass(props) {
|
|
37
39
|
var onSelectChange = props.onSelectChange,
|
|
38
40
|
customAmount = props.customAmount,
|
|
39
|
-
clientId = props.clientId
|
|
40
|
-
totalAmount = props.totalAmount;
|
|
41
|
+
clientId = props.clientId;
|
|
41
42
|
var logger = usePaymentLogger();
|
|
42
43
|
var _useActiveExecute = useActiveExecute(),
|
|
43
44
|
executeIfActive = _useActiveExecute.executeIfActive;
|
|
45
|
+
var osKey = useOsKey();
|
|
44
46
|
|
|
45
|
-
//
|
|
47
|
+
// 根据 osKey 生成模块名称
|
|
48
|
+
var moduleKey = getShopDiscountKey(osKey || 'ticket');
|
|
49
|
+
|
|
50
|
+
// 钱包推荐列表
|
|
46
51
|
var _useState = useState([]),
|
|
47
52
|
_useState2 = _slicedToArray(_useState, 2),
|
|
48
53
|
walletRecommendList = _useState2[0],
|
|
49
54
|
setWalletRecommendList = _useState2[1];
|
|
50
|
-
//
|
|
55
|
+
// 用户识别码列表
|
|
51
56
|
var _useState3 = useState([]),
|
|
52
57
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
53
58
|
userIdentificationCodes = _useState4[0],
|
|
54
59
|
setUserIdentificationCodes = _useState4[1];
|
|
55
|
-
// 可计算的券列表(transformList)
|
|
56
|
-
var _useState5 = useState([]),
|
|
57
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
58
|
-
transformList = _useState6[0],
|
|
59
|
-
setTransformList = _useState6[1];
|
|
60
|
-
// 不适用的券列表(noApplicableVoucher)
|
|
61
|
-
var _useState7 = useState([]),
|
|
62
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
63
|
-
noApplicableVoucher = _useState8[0],
|
|
64
|
-
setNoApplicableVoucher = _useState8[1];
|
|
65
|
-
|
|
66
60
|
// 保存初始顺序的数组
|
|
67
61
|
var initialOrderedDataRef = useRef([]);
|
|
68
62
|
|
|
@@ -72,34 +66,31 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
72
66
|
// 跟踪执行过 handleConfirmEditAmount 的 data.id
|
|
73
67
|
var confirmedEditAmountIdsRef = useRef([]);
|
|
74
68
|
|
|
75
|
-
//
|
|
69
|
+
// 保存setTimeout的引用,用于清理
|
|
70
|
+
var timeoutRef = useRef(null);
|
|
71
|
+
|
|
72
|
+
// 搜索用户识别码列表
|
|
73
|
+
var _useState5 = useState([]),
|
|
74
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
75
|
+
searchIdentificationCodeList = _useState6[0],
|
|
76
|
+
setSearchIdentificationCodeList = _useState6[1];
|
|
77
|
+
var _useState7 = useState({}),
|
|
78
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
79
|
+
orderInfo = _useState8[0],
|
|
80
|
+
setOrderInfo = _useState8[1];
|
|
81
|
+
|
|
82
|
+
// 当前选中的钱包
|
|
76
83
|
var _useState9 = useState([]),
|
|
77
84
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
var _useState11 = useState({}),
|
|
81
|
-
_useState12 = _slicedToArray(_useState11, 2),
|
|
82
|
-
orderInfo = _useState12[0],
|
|
83
|
-
setOrderInfo = _useState12[1];
|
|
84
|
-
|
|
85
|
-
// 当前选中的钱包(完整对象)
|
|
86
|
-
var _useState13 = useState([]),
|
|
87
|
-
_useState14 = _slicedToArray(_useState13, 2),
|
|
88
|
-
selectedWallet = _useState14[0],
|
|
89
|
-
setSelectedWallet = _useState14[1];
|
|
85
|
+
selectedWallet = _useState10[0],
|
|
86
|
+
setSelectedWallet = _useState10[1];
|
|
90
87
|
var selectedWalletRef = useRef([]);
|
|
91
88
|
|
|
92
|
-
// 当前选中的券ID列表(按选中顺序)
|
|
93
|
-
var _useState15 = useState([]),
|
|
94
|
-
_useState16 = _slicedToArray(_useState15, 2),
|
|
95
|
-
selectedVoucherIds = _useState16[0],
|
|
96
|
-
setSelectedVoucherIds = _useState16[1];
|
|
97
|
-
|
|
98
89
|
// 不可用的钱包数据
|
|
99
|
-
var
|
|
100
|
-
|
|
101
|
-
disabledWalletData =
|
|
102
|
-
setDisabledWalletData =
|
|
90
|
+
var _useState11 = useState([]),
|
|
91
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
92
|
+
disabledWalletData = _useState12[0],
|
|
93
|
+
setDisabledWalletData = _useState12[1];
|
|
103
94
|
|
|
104
95
|
// 设置钱包但不设置使用默认钱包
|
|
105
96
|
var notSetWalletSelectRef = useRef(false);
|
|
@@ -107,13 +98,7 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
107
98
|
// 是否显示最佳优惠
|
|
108
99
|
var showBestToastRef = useRef(false);
|
|
109
100
|
|
|
110
|
-
//
|
|
111
|
-
var _useState19 = useState([]),
|
|
112
|
-
_useState20 = _slicedToArray(_useState19, 2),
|
|
113
|
-
products = _useState20[0],
|
|
114
|
-
setProducts = _useState20[1];
|
|
115
|
-
|
|
116
|
-
// 当前选中的钱包id(保留兼容性)
|
|
101
|
+
// 当前选中的钱包id
|
|
117
102
|
var selectedWalletIds = useMemo(function () {
|
|
118
103
|
return selectedWallet.map(function (item) {
|
|
119
104
|
return item.id;
|
|
@@ -123,30 +108,24 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
123
108
|
var Toast = useToast();
|
|
124
109
|
|
|
125
110
|
// 加载状态
|
|
126
|
-
var
|
|
127
|
-
|
|
128
|
-
loading =
|
|
129
|
-
setLoading =
|
|
111
|
+
var _useState13 = useState(false),
|
|
112
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
113
|
+
loading = _useState14[0],
|
|
114
|
+
setLoading = _useState14[1];
|
|
130
115
|
// 错误信息
|
|
131
|
-
var
|
|
132
|
-
|
|
133
|
-
error =
|
|
134
|
-
setError =
|
|
135
|
-
var
|
|
136
|
-
|
|
137
|
-
discountList =
|
|
138
|
-
setDiscountList =
|
|
116
|
+
var _useState15 = useState(null),
|
|
117
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
|
118
|
+
error = _useState16[0],
|
|
119
|
+
setError = _useState16[1];
|
|
120
|
+
var _useState17 = useState([]),
|
|
121
|
+
_useState18 = _slicedToArray(_useState17, 2),
|
|
122
|
+
discountList = _useState18[0],
|
|
123
|
+
setDiscountList = _useState18[1];
|
|
139
124
|
|
|
140
125
|
// 获取checkout模块
|
|
141
126
|
var checkoutModule = pisellos.getModule('checkout');
|
|
142
127
|
var shopDiscount = useShopDiscountModule();
|
|
143
128
|
var paymentModule = checkoutModule === null || checkoutModule === void 0 ? void 0 : checkoutModule.payment;
|
|
144
|
-
|
|
145
|
-
// 获取钱包计算器
|
|
146
|
-
var walletPassEvaluator = useMemo(function () {
|
|
147
|
-
var _paymentModule$window, _paymentModule$window2;
|
|
148
|
-
return paymentModule === null || paymentModule === void 0 || (_paymentModule$window = paymentModule.window) === null || _paymentModule$window === void 0 || (_paymentModule$window2 = _paymentModule$window.getWalletPassEvaluator) === null || _paymentModule$window2 === void 0 ? void 0 : _paymentModule$window2.call(_paymentModule$window);
|
|
149
|
-
}, []);
|
|
150
129
|
var setWalletSelect = useMemoizedFn(function (data) {
|
|
151
130
|
setSelectedWallet(data);
|
|
152
131
|
selectedWalletRef.current = data;
|
|
@@ -303,77 +282,15 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
303
282
|
orderedResult.push.apply(orderedResult, _toConsumableArray(newItems));
|
|
304
283
|
return orderedResult;
|
|
305
284
|
});
|
|
306
|
-
|
|
307
|
-
// 合并计算数据源:transformList + searchIdentificationCodeList(addList)
|
|
308
|
-
var allVouchersForCalculation = useMemo(function () {
|
|
309
|
-
return [].concat(_toConsumableArray(transformList || []), _toConsumableArray(searchIdentificationCodeList || []));
|
|
310
|
-
}, [transformList, searchIdentificationCodeList]);
|
|
311
|
-
|
|
312
|
-
// 根据选中的券ID获取选中的券对象列表(保持选中顺序)
|
|
313
|
-
var selectedVouchers = useMemo(function () {
|
|
314
|
-
return selectedVoucherIds.map(function (id) {
|
|
315
|
-
return allVouchersForCalculation.find(function (v) {
|
|
316
|
-
return v.id === id;
|
|
317
|
-
});
|
|
318
|
-
}).filter(Boolean);
|
|
319
|
-
}, [selectedVoucherIds, allVouchersForCalculation]);
|
|
320
|
-
|
|
321
|
-
// 前端计算展示列表和当前券的详细信息
|
|
322
|
-
var _useMemo = useMemo(function () {
|
|
323
|
-
if (!walletPassEvaluator || !allVouchersForCalculation.length || !totalAmount) {
|
|
324
|
-
return {
|
|
325
|
-
displayVouchers: [].concat(_toConsumableArray(transformList || []), _toConsumableArray(noApplicableVoucher || [])),
|
|
326
|
-
displayOtherVouchers: searchIdentificationCodeList || [],
|
|
327
|
-
selectedWithDetails: [],
|
|
328
|
-
totalDeduction: 0
|
|
329
|
-
};
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
// 有选中的券,重新计算(基于 transformList + searchIdentificationCodeList)
|
|
333
|
-
var result = walletPassEvaluator.recalculateVouchers(allVouchersForCalculation, selectedVouchers, totalAmount, products || []);
|
|
334
|
-
|
|
335
|
-
// 分离当前客户的券和其他客户的券(搜索添加的券)
|
|
336
|
-
var currentCustomerVouchers = [];
|
|
337
|
-
var otherCustomerVouchers = [];
|
|
338
|
-
result.allWithUpdatedStatus.forEach(function (voucher) {
|
|
339
|
-
// 判断是否是搜索添加的券
|
|
340
|
-
var isSearchVoucher = searchIdentificationCodeList.some(function (item) {
|
|
341
|
-
return item.id === voucher.id;
|
|
342
|
-
});
|
|
343
|
-
if (isSearchVoucher) {
|
|
344
|
-
otherCustomerVouchers.push(voucher);
|
|
345
|
-
} else {
|
|
346
|
-
currentCustomerVouchers.push(voucher);
|
|
347
|
-
}
|
|
348
|
-
});
|
|
349
|
-
return {
|
|
350
|
-
displayVouchers: [].concat(currentCustomerVouchers, _toConsumableArray(noApplicableVoucher || [])),
|
|
351
|
-
displayOtherVouchers: otherCustomerVouchers,
|
|
352
|
-
selectedWithDetails: result.selectedWithDetails,
|
|
353
|
-
totalDeduction: result.selectedWithDetails.reduce(function (sum, v) {
|
|
354
|
-
return sum + (v.actualDeduction || 0);
|
|
355
|
-
}, 0)
|
|
356
|
-
};
|
|
357
|
-
}, [selectedVouchers, allVouchersForCalculation, transformList, searchIdentificationCodeList, noApplicableVoucher, totalAmount, products]),
|
|
358
|
-
displayVouchers = _useMemo.displayVouchers,
|
|
359
|
-
displayOtherVouchers = _useMemo.displayOtherVouchers,
|
|
360
|
-
selectedWithDetails = _useMemo.selectedWithDetails,
|
|
361
|
-
totalDeduction = _useMemo.totalDeduction;
|
|
362
|
-
|
|
363
|
-
// 监听 selectedWithDetails 变化,自动通知外部
|
|
364
|
-
useUpdateEffect(function () {
|
|
365
|
-
notifySelectChange(selectedWithDetails);
|
|
366
|
-
setLoading(false);
|
|
367
|
-
}, [selectedWithDetails]);
|
|
368
285
|
var data = useMemo(function () {
|
|
369
|
-
//
|
|
370
|
-
return formatMachineCodeServer2CardList(uniqueByKey(mergeDataWithInitialOrder([].concat(_toConsumableArray(selectedWallet), _toConsumableArray(
|
|
371
|
-
}, [
|
|
286
|
+
// 使用初始顺序作为基础,保持原有顺序
|
|
287
|
+
return formatMachineCodeServer2CardList(uniqueByKey(mergeDataWithInitialOrder([].concat(_toConsumableArray(selectedWallet), _toConsumableArray(userIdentificationCodes))), 'id'), selectedWalletIds);
|
|
288
|
+
}, [userIdentificationCodes, selectedWalletIds, selectedWallet]);
|
|
372
289
|
|
|
373
|
-
//
|
|
374
|
-
var
|
|
290
|
+
// 获取钱包推荐列表
|
|
291
|
+
var fetchWalletRecommendList = useMemoizedFn( /*#__PURE__*/function () {
|
|
375
292
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
|
|
376
|
-
var result
|
|
293
|
+
var result;
|
|
377
294
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
378
295
|
while (1) switch (_context.prev = _context.next) {
|
|
379
296
|
case 0:
|
|
@@ -381,31 +298,66 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
381
298
|
setError(null);
|
|
382
299
|
_context.prev = 2;
|
|
383
300
|
_context.next = 5;
|
|
384
|
-
return paymentModule.wallet.
|
|
301
|
+
return paymentModule.wallet.getWalletPassRecommendListAsync(params);
|
|
385
302
|
case 5:
|
|
386
303
|
result = _context.sent;
|
|
387
|
-
|
|
388
|
-
setUserIdentificationCodes(newData);
|
|
304
|
+
setWalletRecommendList(result);
|
|
389
305
|
return _context.abrupt("return", result);
|
|
390
|
-
case
|
|
391
|
-
_context.prev =
|
|
306
|
+
case 10:
|
|
307
|
+
_context.prev = 10;
|
|
392
308
|
_context.t0 = _context["catch"](2);
|
|
393
|
-
setError(_context.t0 instanceof Error ? _context.t0.message : '
|
|
309
|
+
setError(_context.t0 instanceof Error ? _context.t0.message : '获取钱包推荐列表失败');
|
|
394
310
|
throw _context.t0;
|
|
395
|
-
case
|
|
396
|
-
_context.prev =
|
|
311
|
+
case 14:
|
|
312
|
+
_context.prev = 14;
|
|
397
313
|
setLoading(false);
|
|
398
|
-
return _context.finish(
|
|
399
|
-
case
|
|
314
|
+
return _context.finish(14);
|
|
315
|
+
case 17:
|
|
400
316
|
case "end":
|
|
401
317
|
return _context.stop();
|
|
402
318
|
}
|
|
403
|
-
}, _callee, null, [[2,
|
|
319
|
+
}, _callee, null, [[2, 10, 14, 17]]);
|
|
404
320
|
}));
|
|
405
321
|
return function (_x) {
|
|
406
322
|
return _ref.apply(this, arguments);
|
|
407
323
|
};
|
|
408
324
|
}());
|
|
325
|
+
// 获取用户识别码列表
|
|
326
|
+
var fetchUserIdentificationCodes = useMemoizedFn( /*#__PURE__*/function () {
|
|
327
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
|
|
328
|
+
var result, newData;
|
|
329
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
330
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
331
|
+
case 0:
|
|
332
|
+
setLoading(true);
|
|
333
|
+
setError(null);
|
|
334
|
+
_context2.prev = 2;
|
|
335
|
+
_context2.next = 5;
|
|
336
|
+
return paymentModule.wallet.getUserIdentificationCodeListAsync(params);
|
|
337
|
+
case 5:
|
|
338
|
+
result = _context2.sent;
|
|
339
|
+
newData = uniqueByKey([].concat(_toConsumableArray(result), _toConsumableArray(selectedWalletRef.current)), 'id'); // const orderedData = mergeDataWithInitialOrder(newData);
|
|
340
|
+
setUserIdentificationCodes(newData);
|
|
341
|
+
return _context2.abrupt("return", result);
|
|
342
|
+
case 11:
|
|
343
|
+
_context2.prev = 11;
|
|
344
|
+
_context2.t0 = _context2["catch"](2);
|
|
345
|
+
setError(_context2.t0 instanceof Error ? _context2.t0.message : '获取用户识别码列表失败');
|
|
346
|
+
throw _context2.t0;
|
|
347
|
+
case 15:
|
|
348
|
+
_context2.prev = 15;
|
|
349
|
+
setLoading(false);
|
|
350
|
+
return _context2.finish(15);
|
|
351
|
+
case 18:
|
|
352
|
+
case "end":
|
|
353
|
+
return _context2.stop();
|
|
354
|
+
}
|
|
355
|
+
}, _callee2, null, [[2, 11, 15, 18]]);
|
|
356
|
+
}));
|
|
357
|
+
return function (_x2) {
|
|
358
|
+
return _ref2.apply(this, arguments);
|
|
359
|
+
};
|
|
360
|
+
}());
|
|
409
361
|
|
|
410
362
|
// 获取缓存数据
|
|
411
363
|
var getCachedWalletRecommendList = useMemoizedFn(function () {
|
|
@@ -437,103 +389,46 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
437
389
|
var handleSearchIdentificationCodeCompleted = useMemoizedFn(function (data) {
|
|
438
390
|
var currentSearchResults = data.currentSearchResults,
|
|
439
391
|
cachedSearchResults = data.cachedSearchResults;
|
|
440
|
-
// 使用 walletPassEvaluator.searchVoucherFormat 格式化搜索结果
|
|
441
|
-
var formattedResults = currentSearchResults;
|
|
442
|
-
if (walletPassEvaluator && currentSearchResults.length > 0 && totalAmount) {
|
|
443
|
-
formattedResults = walletPassEvaluator.searchVoucherFormat({
|
|
444
|
-
vouchers: currentSearchResults,
|
|
445
|
-
orderTotalAmount: totalAmount,
|
|
446
|
-
products: products || []
|
|
447
|
-
});
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
// 格式化缓存的搜索结果(如果存在)
|
|
451
|
-
var formattedCachedResults = cachedSearchResults || [];
|
|
452
|
-
if (walletPassEvaluator && cachedSearchResults && cachedSearchResults.length > 0 && totalAmount) {
|
|
453
|
-
formattedCachedResults = walletPassEvaluator.searchVoucherFormat({
|
|
454
|
-
vouchers: cachedSearchResults,
|
|
455
|
-
orderTotalAmount: totalAmount,
|
|
456
|
-
products: products || []
|
|
457
|
-
});
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
// 合并缓存的搜索结果和当前搜索结果,并去重
|
|
461
|
-
var mergedSearchResults = uniqueByKey([].concat(_toConsumableArray(formattedCachedResults || []), _toConsumableArray(formattedResults)), 'id');
|
|
462
392
|
var isAvailableData = [];
|
|
463
393
|
var isDisabledData = [];
|
|
464
|
-
if (
|
|
465
|
-
|
|
466
|
-
if (
|
|
394
|
+
if (currentSearchResults.length > 0) {
|
|
395
|
+
currentSearchResults.forEach(function (item) {
|
|
396
|
+
if (!!item.unified_available_status) {
|
|
467
397
|
isAvailableData.push(item);
|
|
468
398
|
} else {
|
|
469
399
|
isDisabledData.push(item);
|
|
470
400
|
}
|
|
471
401
|
});
|
|
472
402
|
}
|
|
473
|
-
var availableData = mergedSearchResults.filter(function (item) {
|
|
474
|
-
return getVoucherAvailableStatus(item);
|
|
475
|
-
});
|
|
476
|
-
// 更新不可用钱包数据(需要包含所有搜索结果中的不可用数据)
|
|
477
|
-
var allDisabledData = mergedSearchResults.filter(function (item) {
|
|
478
|
-
return !getVoucherAvailableStatus(item);
|
|
479
|
-
});
|
|
480
|
-
setDisabledWalletData(allDisabledData);
|
|
481
403
|
|
|
482
|
-
//
|
|
404
|
+
// 更新不可用钱包数据
|
|
405
|
+
setDisabledWalletData(isDisabledData);
|
|
483
406
|
var newValues = _toConsumableArray(selectedWalletRef.current);
|
|
484
407
|
if (isAvailableData.length === 1) {
|
|
485
408
|
newValues = [].concat(_toConsumableArray(selectedWalletRef.current), isAvailableData);
|
|
486
409
|
}
|
|
487
|
-
|
|
488
|
-
// 更新搜索结果列表(合并缓存和当前搜索结果,使用去重后的数据)
|
|
489
|
-
setSearchIdentificationCodeList(availableData);
|
|
490
|
-
setNoApplicableVoucher(allDisabledData);
|
|
410
|
+
setSearchIdentificationCodeList(cachedSearchResults);
|
|
491
411
|
setWalletSelect(newValues);
|
|
492
|
-
|
|
493
|
-
// 更新选中的券ID列表(会触发 useMemo 重新计算 selectedWithDetails)
|
|
494
|
-
setSelectedVoucherIds(newValues.map(function (item) {
|
|
412
|
+
handleFetchUserIdentificationCodes(newValues.map(function (item) {
|
|
495
413
|
return item.id;
|
|
496
414
|
}));
|
|
497
|
-
|
|
498
|
-
// useUpdateEffect 会自动在 selectedWithDetails 更新后通知外部
|
|
499
415
|
});
|
|
500
416
|
var onOrderCreated = useMemoizedFn(function () {
|
|
501
|
-
var _paymentModule$wallet, _paymentModule$wallet2;
|
|
502
417
|
var orderInfo = checkoutModule.getOrderOriginalData();
|
|
503
418
|
setOrderInfo(orderInfo);
|
|
504
|
-
|
|
505
|
-
// 从缓存获取初始化数据(包含新的数据结构)
|
|
506
419
|
var recommendList = getCachedWalletRecommendList();
|
|
507
420
|
var userIdentificationCodes = getCachedUserIdentificationCodes();
|
|
508
|
-
|
|
509
|
-
// 获取 transformList 和 noApplicableVoucher(从 paymentModule 的缓存中)
|
|
510
|
-
// 这些数据在 initializeWalletDataAsync 中已经计算并缓存
|
|
511
|
-
var walletInitData = (paymentModule === null || paymentModule === void 0 || (_paymentModule$wallet = paymentModule.wallet) === null || _paymentModule$wallet === void 0 || (_paymentModule$wallet2 = _paymentModule$wallet.getStoredWalletInitData) === null || _paymentModule$wallet2 === void 0 ? void 0 : _paymentModule$wallet2.call(_paymentModule$wallet)) || {};
|
|
512
|
-
var transformListData = walletInitData.transformList || userIdentificationCodes;
|
|
513
|
-
var noApplicableVoucherData = walletInitData.noApplicableVoucher || [];
|
|
514
|
-
var productsData = walletInitData.products || [];
|
|
515
421
|
var initialData = [].concat(_toConsumableArray(recommendList), _toConsumableArray(userIdentificationCodes));
|
|
516
422
|
|
|
517
423
|
// 设置钱包推荐列表
|
|
518
424
|
setWalletRecommendList(recommendList);
|
|
519
|
-
//
|
|
520
|
-
setUserIdentificationCodes(
|
|
521
|
-
// 设置可计算的券列表
|
|
522
|
-
setTransformList(transformListData);
|
|
523
|
-
// 设置不适用的券列表
|
|
524
|
-
setNoApplicableVoucher(noApplicableVoucherData);
|
|
525
|
-
// 设置产品列表
|
|
526
|
-
setProducts(productsData);
|
|
425
|
+
// 设置用户识别码列表
|
|
426
|
+
setUserIdentificationCodes(initialData);
|
|
527
427
|
// 设置初始顺序
|
|
528
428
|
initialOrderedDataRef.current = initialData;
|
|
529
|
-
|
|
530
429
|
// 设置默认选中钱包
|
|
531
430
|
if (!notSetWalletSelectRef.current) {
|
|
532
431
|
setWalletSelect(recommendList);
|
|
533
|
-
// 设置默认选中的券ID
|
|
534
|
-
setSelectedVoucherIds(recommendList.map(function (item) {
|
|
535
|
-
return item.id;
|
|
536
|
-
}));
|
|
537
432
|
var _select = paymentModule.wallet.formatWalletPassList2PreparePayments(recommendList).map(function (item) {
|
|
538
433
|
return {
|
|
539
434
|
code: item.tag,
|
|
@@ -552,7 +447,6 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
552
447
|
onSelectChange === null || onSelectChange === void 0 || onSelectChange(_select);
|
|
553
448
|
} else {
|
|
554
449
|
setWalletSelect([]);
|
|
555
|
-
setSelectedVoucherIds([]);
|
|
556
450
|
notSetWalletSelectRef.current = false;
|
|
557
451
|
onSelectChange === null || onSelectChange === void 0 || onSelectChange([]);
|
|
558
452
|
}
|
|
@@ -599,27 +493,27 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
599
493
|
setLoading(false);
|
|
600
494
|
});
|
|
601
495
|
var handlePaymentStarted = useMemoizedFn( /*#__PURE__*/function () {
|
|
602
|
-
var
|
|
603
|
-
return _regeneratorRuntime().wrap(function
|
|
604
|
-
while (1) switch (
|
|
496
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
497
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
498
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
605
499
|
case 0:
|
|
606
|
-
if (!(params.paymentMethodCode !== 'VOUCHER_BATCH'
|
|
607
|
-
|
|
500
|
+
if (!(params.paymentMethodCode !== 'VOUCHER_BATCH')) {
|
|
501
|
+
_context3.next = 4;
|
|
608
502
|
break;
|
|
609
503
|
}
|
|
610
504
|
notSetWalletSelectRef.current = true;
|
|
611
|
-
|
|
505
|
+
_context3.next = 4;
|
|
612
506
|
return checkoutModule.initWalletData({
|
|
613
507
|
order_wait_pay_amount: Number(customAmount)
|
|
614
508
|
});
|
|
615
509
|
case 4:
|
|
616
510
|
case "end":
|
|
617
|
-
return
|
|
511
|
+
return _context3.stop();
|
|
618
512
|
}
|
|
619
|
-
},
|
|
513
|
+
}, _callee3);
|
|
620
514
|
}));
|
|
621
|
-
return function (
|
|
622
|
-
return
|
|
515
|
+
return function (_x3) {
|
|
516
|
+
return _ref3.apply(this, arguments);
|
|
623
517
|
};
|
|
624
518
|
}());
|
|
625
519
|
|
|
@@ -671,6 +565,16 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
671
565
|
};
|
|
672
566
|
}, [paymentModule]);
|
|
673
567
|
|
|
568
|
+
// 组件卸载时清理定时器
|
|
569
|
+
useEffect(function () {
|
|
570
|
+
return function () {
|
|
571
|
+
if (timeoutRef.current) {
|
|
572
|
+
clearTimeout(timeoutRef.current);
|
|
573
|
+
timeoutRef.current = null;
|
|
574
|
+
}
|
|
575
|
+
};
|
|
576
|
+
}, []);
|
|
577
|
+
|
|
674
578
|
// 所有列表 包含推荐列表、用户识别码列表、搜索用户识别码列表
|
|
675
579
|
var allList = useMemo(function () {
|
|
676
580
|
var reversedSearchData = _toConsumableArray(searchIdentificationCodeList).reverse();
|
|
@@ -686,9 +590,12 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
686
590
|
});
|
|
687
591
|
});
|
|
688
592
|
|
|
689
|
-
//
|
|
690
|
-
var
|
|
691
|
-
var
|
|
593
|
+
// 处理获取用户识别码
|
|
594
|
+
var handleFetchUserIdentificationCodes = useMemoizedFn(function (value, walletRecommendList) {
|
|
595
|
+
var val = uniqueByKey(walletRecommendList || allList, 'id').filter(function (item) {
|
|
596
|
+
return value.includes(item.id);
|
|
597
|
+
});
|
|
598
|
+
var prepare_payments = paymentModule.wallet.formatWalletPassList2PreparePayments(val);
|
|
692
599
|
var select = prepare_payments.map(function (item) {
|
|
693
600
|
return {
|
|
694
601
|
voucher_id: item.voucher_id,
|
|
@@ -700,13 +607,16 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
700
607
|
});
|
|
701
608
|
logger === null || logger === void 0 || logger.addLog({
|
|
702
609
|
type: 'info',
|
|
703
|
-
title: '
|
|
704
|
-
metadata: {
|
|
705
|
-
selectedDetails: selectedDetails,
|
|
706
|
-
select: select
|
|
707
|
-
}
|
|
610
|
+
title: 'useWalletPass_handleFetchUserIdentificationCodes onSelectChange 开始调用',
|
|
611
|
+
metadata: {}
|
|
708
612
|
});
|
|
709
613
|
onSelectChange === null || onSelectChange === void 0 || onSelectChange(select);
|
|
614
|
+
fetchUserIdentificationCodes({
|
|
615
|
+
prepare_payments: prepare_payments,
|
|
616
|
+
available: 2,
|
|
617
|
+
filter_prepare_wallet_pass: 1,
|
|
618
|
+
other_exact_codes: getOtherExactCodes()
|
|
619
|
+
});
|
|
710
620
|
});
|
|
711
621
|
var handleSearchIdentificationCode = useMemoizedFn(function (value) {
|
|
712
622
|
return paymentModule.wallet.searchIdentificationCodeAsync({
|
|
@@ -715,46 +625,13 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
715
625
|
});
|
|
716
626
|
});
|
|
717
627
|
|
|
718
|
-
//
|
|
628
|
+
// 处理选中钱包
|
|
719
629
|
var handleSelectWallet = useMemoizedFn(function (value) {
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
// 1. 找出被取消选中的券ID
|
|
723
|
-
var deselectedIds = selectedVoucherIds.filter(function (id) {
|
|
724
|
-
return !value.includes(id);
|
|
725
|
-
});
|
|
726
|
-
|
|
727
|
-
// 2. 如果有被取消选中的券,检查是否需要重置 edit_current_amount
|
|
728
|
-
if (deselectedIds.length > 0) {
|
|
729
|
-
// 找出这些券中有 edit_current_amount 的
|
|
730
|
-
var needResetIds = deselectedIds.filter(function (id) {
|
|
731
|
-
var voucher = allVouchersForCalculation.find(function (v) {
|
|
732
|
-
return v.id === id;
|
|
733
|
-
});
|
|
734
|
-
return (voucher === null || voucher === void 0 ? void 0 : voucher.edit_current_amount) !== undefined;
|
|
735
|
-
});
|
|
736
|
-
|
|
737
|
-
// 重置这些券的 edit_current_amount
|
|
738
|
-
if (needResetIds.length > 0) {
|
|
739
|
-
updateWalletDataById(needResetIds, {
|
|
740
|
-
edit_current_amount: undefined
|
|
741
|
-
});
|
|
742
|
-
|
|
743
|
-
// 从 confirmedEditAmountIdsRef 中移除这些ID
|
|
744
|
-
confirmedEditAmountIdsRef.current = confirmedEditAmountIdsRef.current.filter(function (id) {
|
|
745
|
-
return !needResetIds.includes(id);
|
|
746
|
-
});
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
// 3. 更新选中的券ID列表(会触发 useMemo 重新计算 selectedWithDetails)
|
|
751
|
-
setSelectedVoucherIds(value);
|
|
752
|
-
|
|
753
|
-
// 4. 同时更新 selectedWallet 用于兼容现有逻辑
|
|
754
|
-
var val = allVouchersForCalculation.filter(function (item) {
|
|
630
|
+
var val = userIdentificationCodes.filter(function (item) {
|
|
755
631
|
return value.includes(item.id);
|
|
756
632
|
});
|
|
757
633
|
setWalletSelect(val);
|
|
634
|
+
handleFetchUserIdentificationCodes(value);
|
|
758
635
|
});
|
|
759
636
|
|
|
760
637
|
// 获取过期钱包id
|
|
@@ -777,15 +654,12 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
777
654
|
|
|
778
655
|
// 清除所有选中的钱包
|
|
779
656
|
var clearAllSelectedWallet = useMemoizedFn(function () {
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
confirmedEditAmountIdsRef.current = [];
|
|
787
|
-
}
|
|
788
|
-
|
|
657
|
+
logger === null || logger === void 0 || logger.addLog({
|
|
658
|
+
type: 'info',
|
|
659
|
+
title: 'useWalletPass_clearAllSelectedWallet onSelectChange 开始调用',
|
|
660
|
+
metadata: {}
|
|
661
|
+
});
|
|
662
|
+
onSelectChange === null || onSelectChange === void 0 || onSelectChange([]);
|
|
789
663
|
// 如果没有选中钱包,则不处理
|
|
790
664
|
if (selectedWalletIds.length === 0 && selectedDiscountList.length === 0) {
|
|
791
665
|
return;
|
|
@@ -805,22 +679,11 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
805
679
|
// 保持初始顺序设置折扣列表
|
|
806
680
|
var sortedDiscountList = sortDiscountListWithInitialOrder(detail.discountList);
|
|
807
681
|
setDiscountList(sortedDiscountList);
|
|
808
|
-
pisellos === null || pisellos === void 0 || (_pisellos$effects = pisellos.effects) === null || _pisellos$effects === void 0 || _pisellos$effects.emit(
|
|
682
|
+
pisellos === null || pisellos === void 0 || (_pisellos$effects = pisellos.effects) === null || _pisellos$effects === void 0 || _pisellos$effects.emit("".concat(moduleKey, ":onSelectedDiscountListChange"), detail);
|
|
809
683
|
return;
|
|
810
684
|
}
|
|
811
|
-
|
|
812
|
-
// 清空选中的钱包
|
|
813
685
|
setWalletSelect([]);
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
// 清空时立即通知外部(不等待 useUpdateEffect)
|
|
817
|
-
logger === null || logger === void 0 || logger.addLog({
|
|
818
|
-
type: 'info',
|
|
819
|
-
title: 'useWalletPass_clearAllSelectedWallet 立即通知外部清空',
|
|
820
|
-
metadata: {}
|
|
821
|
-
});
|
|
822
|
-
onSelectChange === null || onSelectChange === void 0 || onSelectChange([]);
|
|
823
|
-
setLoading(false);
|
|
686
|
+
handleFetchUserIdentificationCodes([]);
|
|
824
687
|
});
|
|
825
688
|
|
|
826
689
|
// 判断当前选择是否已是最优选择
|
|
@@ -875,14 +738,12 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
875
738
|
Toast === null || Toast === void 0 || Toast.info(locales.getText('wallet-pass-module-already-best-combination'));
|
|
876
739
|
} else {
|
|
877
740
|
var _select2 = searchIdentificationCodeList.filter(function (item) {
|
|
878
|
-
return
|
|
741
|
+
return item.unified_available_status;
|
|
879
742
|
});
|
|
880
743
|
setWalletSelect(_select2);
|
|
881
|
-
|
|
882
|
-
setSelectedVoucherIds(_select2.map(function (item) {
|
|
744
|
+
handleFetchUserIdentificationCodes(_select2.map(function (item) {
|
|
883
745
|
return item.id;
|
|
884
|
-
}));
|
|
885
|
-
// useUpdateEffect 会自动在 selectedWithDetails 更新后通知外部
|
|
746
|
+
}), _select2);
|
|
886
747
|
if (_select2.length) {
|
|
887
748
|
Toast === null || Toast === void 0 || Toast.success(locales.getText('wallet-pass-module-best-combination-selected'));
|
|
888
749
|
}
|
|
@@ -911,33 +772,32 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
911
772
|
if (hasGoodPass && !isBestDiscount) return;
|
|
912
773
|
// 重置为最优选择并显示Toast提示
|
|
913
774
|
setWalletSelect(newWalletRecommendList);
|
|
914
|
-
|
|
915
|
-
setSelectedVoucherIds(newWalletRecommendList.map(function (item) {
|
|
775
|
+
handleFetchUserIdentificationCodes(newWalletRecommendList.map(function (item) {
|
|
916
776
|
return item.id;
|
|
917
|
-
}));
|
|
918
|
-
// useUpdateEffect 会自动在 selectedWithDetails 更新后通知外部
|
|
777
|
+
}), newWalletRecommendList);
|
|
919
778
|
Toast === null || Toast === void 0 || Toast.success(locales.getText('wallet-pass-module-best-combination-selected'));
|
|
920
779
|
}
|
|
921
|
-
setLoading(false);
|
|
922
780
|
});
|
|
923
781
|
var handleSelectDiscount = useMemoizedFn(function (value, option) {
|
|
924
|
-
var _detail$discountList, _pisellos$effects2;
|
|
925
782
|
setLoading(true);
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
783
|
+
try {
|
|
784
|
+
var _pisellos$effects2;
|
|
785
|
+
var isSelected = value.includes(option.id);
|
|
786
|
+
var detail = shopDiscount.setDiscountSelected({
|
|
787
|
+
discountId: option.id,
|
|
788
|
+
isSelected: isSelected
|
|
789
|
+
});
|
|
790
|
+
|
|
791
|
+
// 保持初始顺序设置折扣列表
|
|
792
|
+
var sortedDiscountList = sortDiscountListWithInitialOrder(detail.discountList);
|
|
793
|
+
setDiscountList(sortedDiscountList);
|
|
794
|
+
pisellos === null || pisellos === void 0 || (_pisellos$effects2 = pisellos.effects) === null || _pisellos$effects2 === void 0 || _pisellos$effects2.emit("".concat(moduleKey, ":onSelectedDiscountListChange"), detail);
|
|
795
|
+
} catch (err) {
|
|
796
|
+
console.log(err, '1234err');
|
|
797
|
+
} finally {
|
|
798
|
+
// 商品券选择流程结束后统一回收loading,避免出现转圈不停止
|
|
934
799
|
setLoading(false);
|
|
935
800
|
}
|
|
936
|
-
|
|
937
|
-
// 保持初始顺序设置折扣列表
|
|
938
|
-
var sortedDiscountList = sortDiscountListWithInitialOrder(detail.discountList);
|
|
939
|
-
setDiscountList(sortedDiscountList);
|
|
940
|
-
pisellos === null || pisellos === void 0 || (_pisellos$effects2 = pisellos.effects) === null || _pisellos$effects2 === void 0 || _pisellos$effects2.emit('shopDiscount:onSelectedDiscountListChange', detail);
|
|
941
801
|
});
|
|
942
802
|
|
|
943
803
|
// 清空不可用钱包数据
|
|
@@ -963,10 +823,6 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
963
823
|
var newUserIdentificationCodes = updateArrayItemById(userIdentificationCodes, targetId, updateData);
|
|
964
824
|
setUserIdentificationCodes(newUserIdentificationCodes);
|
|
965
825
|
|
|
966
|
-
// 更新transformList中对应ID的数据(用于前端计算)
|
|
967
|
-
var newTransformList = updateArrayItemById(transformList, targetId, updateData);
|
|
968
|
-
setTransformList(newTransformList);
|
|
969
|
-
|
|
970
826
|
// 更新searchIdentificationCodeList中对应ID的数据
|
|
971
827
|
var newSearchIdentificationCodeList = updateArrayItemById(searchIdentificationCodeList, targetId, updateData);
|
|
972
828
|
setSearchIdentificationCodeList(newSearchIdentificationCodeList);
|
|
@@ -977,7 +833,6 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
977
833
|
return {
|
|
978
834
|
newWalletRecommendList: newWalletRecommendList,
|
|
979
835
|
newUserIdentificationCodes: newUserIdentificationCodes,
|
|
980
|
-
newTransformList: newTransformList,
|
|
981
836
|
newSearchIdentificationCodeList: newSearchIdentificationCodeList,
|
|
982
837
|
newSelectedWallet: newSelectedWallet
|
|
983
838
|
};
|
|
@@ -985,42 +840,70 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
985
840
|
var handleConfirmEditAmount = useMemoizedFn(function (value, id, data) {
|
|
986
841
|
// 如果金额为0,直接触发 handleSelectWallet 把当前id过滤掉
|
|
987
842
|
if (value === 0) {
|
|
988
|
-
var filteredIds =
|
|
843
|
+
var filteredIds = selectedWalletIds.filter(function (walletId) {
|
|
989
844
|
return walletId !== data.id;
|
|
990
845
|
});
|
|
991
846
|
handleSelectWallet(filteredIds);
|
|
992
847
|
return;
|
|
993
848
|
}
|
|
994
|
-
setLoading(true);
|
|
995
849
|
|
|
996
850
|
// 将执行过的 data.id 添加到跟踪数组中(避免重复)
|
|
997
851
|
if (!confirmedEditAmountIdsRef.current.includes(data.id)) {
|
|
998
852
|
confirmedEditAmountIdsRef.current.push(data.id);
|
|
999
853
|
}
|
|
1000
854
|
|
|
1001
|
-
//
|
|
1002
|
-
// 这会触发 useMemo 重新计算 selectedWithDetails
|
|
855
|
+
// 使用通用函数更新所有相关状态
|
|
1003
856
|
updateWalletDataById(data.id, {
|
|
1004
857
|
edit_current_amount: value
|
|
1005
858
|
});
|
|
1006
859
|
|
|
1007
|
-
//
|
|
1008
|
-
|
|
860
|
+
// 清理之前的定时器
|
|
861
|
+
if (timeoutRef.current) {
|
|
862
|
+
clearTimeout(timeoutRef.current);
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
// 设置新的定时器并保存引用
|
|
866
|
+
timeoutRef.current = setTimeout(function () {
|
|
867
|
+
handleFetchUserIdentificationCodes(selectedWalletIds);
|
|
868
|
+
timeoutRef.current = null; // 执行完成后清空引用
|
|
869
|
+
});
|
|
1009
870
|
});
|
|
1010
871
|
var handleBeforeEditAmount = useMemoizedFn( /*#__PURE__*/function () {
|
|
1011
|
-
var
|
|
1012
|
-
|
|
1013
|
-
|
|
872
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(value, index, data) {
|
|
873
|
+
var result, resultItem;
|
|
874
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
875
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
1014
876
|
case 0:
|
|
1015
|
-
|
|
1016
|
-
|
|
877
|
+
_context4.next = 2;
|
|
878
|
+
return paymentModule.wallet.searchIdentificationCodeAsync({
|
|
879
|
+
code: data.code,
|
|
880
|
+
prepare_payments: paymentModule.wallet.formatWalletPassList2PreparePayments(selectedWalletRef.current.filter(function (item) {
|
|
881
|
+
return item.id !== data.id;
|
|
882
|
+
}))
|
|
883
|
+
}, {
|
|
884
|
+
noCache: true
|
|
885
|
+
});
|
|
886
|
+
case 2:
|
|
887
|
+
result = _context4.sent;
|
|
888
|
+
// 如果result中有数据,使用result中的数据更新状态
|
|
889
|
+
if (result.data && result.data.length > 0) {
|
|
890
|
+
resultItem = result.data.find(function (item) {
|
|
891
|
+
return item.id === data.id;
|
|
892
|
+
});
|
|
893
|
+
if (resultItem) {
|
|
894
|
+
// 使用通用函数更新所有相关状态
|
|
895
|
+
updateWalletDataById(data.id, resultItem);
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
return _context4.abrupt("return", true);
|
|
899
|
+
case 5:
|
|
1017
900
|
case "end":
|
|
1018
|
-
return
|
|
901
|
+
return _context4.stop();
|
|
1019
902
|
}
|
|
1020
|
-
},
|
|
903
|
+
}, _callee4);
|
|
1021
904
|
}));
|
|
1022
|
-
return function (
|
|
1023
|
-
return
|
|
905
|
+
return function (_x4, _x5, _x6) {
|
|
906
|
+
return _ref4.apply(this, arguments);
|
|
1024
907
|
};
|
|
1025
908
|
}());
|
|
1026
909
|
return {
|
|
@@ -1044,6 +927,7 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
1044
927
|
selectedDiscountList: selectedDiscountList,
|
|
1045
928
|
handleSelectDiscount: handleSelectDiscount,
|
|
1046
929
|
customerName: customerName,
|
|
930
|
+
fetchWalletRecommendList: fetchWalletRecommendList,
|
|
1047
931
|
fetchUserIdentificationCodes: fetchUserIdentificationCodes,
|
|
1048
932
|
getCachedWalletRecommendList: getCachedWalletRecommendList,
|
|
1049
933
|
getCachedUserIdentificationCodes: getCachedUserIdentificationCodes,
|