@pisell/private-materials 6.6.50 → 6.6.51
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/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 +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/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 +192 -316
- 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/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/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 +108 -157
- 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/package.json +1 -1
|
@@ -19,12 +19,12 @@ 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";
|
|
@@ -36,33 +36,21 @@ import { useShopDiscountModule } from "../../ticketBooking/hooks/pisellos/useSho
|
|
|
36
36
|
export var useWalletPass = function useWalletPass(props) {
|
|
37
37
|
var onSelectChange = props.onSelectChange,
|
|
38
38
|
customAmount = props.customAmount,
|
|
39
|
-
clientId = props.clientId
|
|
40
|
-
totalAmount = props.totalAmount;
|
|
39
|
+
clientId = props.clientId;
|
|
41
40
|
var logger = usePaymentLogger();
|
|
42
41
|
var _useActiveExecute = useActiveExecute(),
|
|
43
42
|
executeIfActive = _useActiveExecute.executeIfActive;
|
|
44
43
|
|
|
45
|
-
//
|
|
44
|
+
// 钱包推荐列表
|
|
46
45
|
var _useState = useState([]),
|
|
47
46
|
_useState2 = _slicedToArray(_useState, 2),
|
|
48
47
|
walletRecommendList = _useState2[0],
|
|
49
48
|
setWalletRecommendList = _useState2[1];
|
|
50
|
-
//
|
|
49
|
+
// 用户识别码列表
|
|
51
50
|
var _useState3 = useState([]),
|
|
52
51
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
53
52
|
userIdentificationCodes = _useState4[0],
|
|
54
53
|
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
54
|
// 保存初始顺序的数组
|
|
67
55
|
var initialOrderedDataRef = useRef([]);
|
|
68
56
|
|
|
@@ -72,34 +60,31 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
72
60
|
// 跟踪执行过 handleConfirmEditAmount 的 data.id
|
|
73
61
|
var confirmedEditAmountIdsRef = useRef([]);
|
|
74
62
|
|
|
75
|
-
//
|
|
63
|
+
// 保存setTimeout的引用,用于清理
|
|
64
|
+
var timeoutRef = useRef(null);
|
|
65
|
+
|
|
66
|
+
// 搜索用户识别码列表
|
|
67
|
+
var _useState5 = useState([]),
|
|
68
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
69
|
+
searchIdentificationCodeList = _useState6[0],
|
|
70
|
+
setSearchIdentificationCodeList = _useState6[1];
|
|
71
|
+
var _useState7 = useState({}),
|
|
72
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
73
|
+
orderInfo = _useState8[0],
|
|
74
|
+
setOrderInfo = _useState8[1];
|
|
75
|
+
|
|
76
|
+
// 当前选中的钱包
|
|
76
77
|
var _useState9 = useState([]),
|
|
77
78
|
_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];
|
|
79
|
+
selectedWallet = _useState10[0],
|
|
80
|
+
setSelectedWallet = _useState10[1];
|
|
90
81
|
var selectedWalletRef = useRef([]);
|
|
91
82
|
|
|
92
|
-
// 当前选中的券ID列表(按选中顺序)
|
|
93
|
-
var _useState15 = useState([]),
|
|
94
|
-
_useState16 = _slicedToArray(_useState15, 2),
|
|
95
|
-
selectedVoucherIds = _useState16[0],
|
|
96
|
-
setSelectedVoucherIds = _useState16[1];
|
|
97
|
-
|
|
98
83
|
// 不可用的钱包数据
|
|
99
|
-
var
|
|
100
|
-
|
|
101
|
-
disabledWalletData =
|
|
102
|
-
setDisabledWalletData =
|
|
84
|
+
var _useState11 = useState([]),
|
|
85
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
86
|
+
disabledWalletData = _useState12[0],
|
|
87
|
+
setDisabledWalletData = _useState12[1];
|
|
103
88
|
|
|
104
89
|
// 设置钱包但不设置使用默认钱包
|
|
105
90
|
var notSetWalletSelectRef = useRef(false);
|
|
@@ -107,13 +92,7 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
107
92
|
// 是否显示最佳优惠
|
|
108
93
|
var showBestToastRef = useRef(false);
|
|
109
94
|
|
|
110
|
-
//
|
|
111
|
-
var _useState19 = useState([]),
|
|
112
|
-
_useState20 = _slicedToArray(_useState19, 2),
|
|
113
|
-
products = _useState20[0],
|
|
114
|
-
setProducts = _useState20[1];
|
|
115
|
-
|
|
116
|
-
// 当前选中的钱包id(保留兼容性)
|
|
95
|
+
// 当前选中的钱包id
|
|
117
96
|
var selectedWalletIds = useMemo(function () {
|
|
118
97
|
return selectedWallet.map(function (item) {
|
|
119
98
|
return item.id;
|
|
@@ -123,30 +102,24 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
123
102
|
var Toast = useToast();
|
|
124
103
|
|
|
125
104
|
// 加载状态
|
|
126
|
-
var
|
|
127
|
-
|
|
128
|
-
loading =
|
|
129
|
-
setLoading =
|
|
105
|
+
var _useState13 = useState(false),
|
|
106
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
107
|
+
loading = _useState14[0],
|
|
108
|
+
setLoading = _useState14[1];
|
|
130
109
|
// 错误信息
|
|
131
|
-
var
|
|
132
|
-
|
|
133
|
-
error =
|
|
134
|
-
setError =
|
|
135
|
-
var
|
|
136
|
-
|
|
137
|
-
discountList =
|
|
138
|
-
setDiscountList =
|
|
110
|
+
var _useState15 = useState(null),
|
|
111
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
|
112
|
+
error = _useState16[0],
|
|
113
|
+
setError = _useState16[1];
|
|
114
|
+
var _useState17 = useState([]),
|
|
115
|
+
_useState18 = _slicedToArray(_useState17, 2),
|
|
116
|
+
discountList = _useState18[0],
|
|
117
|
+
setDiscountList = _useState18[1];
|
|
139
118
|
|
|
140
119
|
// 获取checkout模块
|
|
141
120
|
var checkoutModule = pisellos.getModule('checkout');
|
|
142
121
|
var shopDiscount = useShopDiscountModule();
|
|
143
122
|
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
123
|
var setWalletSelect = useMemoizedFn(function (data) {
|
|
151
124
|
setSelectedWallet(data);
|
|
152
125
|
selectedWalletRef.current = data;
|
|
@@ -303,77 +276,15 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
303
276
|
orderedResult.push.apply(orderedResult, _toConsumableArray(newItems));
|
|
304
277
|
return orderedResult;
|
|
305
278
|
});
|
|
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
279
|
var data = useMemo(function () {
|
|
369
|
-
//
|
|
370
|
-
return formatMachineCodeServer2CardList(uniqueByKey(mergeDataWithInitialOrder([].concat(_toConsumableArray(selectedWallet), _toConsumableArray(
|
|
371
|
-
}, [
|
|
280
|
+
// 使用初始顺序作为基础,保持原有顺序
|
|
281
|
+
return formatMachineCodeServer2CardList(uniqueByKey(mergeDataWithInitialOrder([].concat(_toConsumableArray(selectedWallet), _toConsumableArray(userIdentificationCodes))), 'id'), selectedWalletIds);
|
|
282
|
+
}, [userIdentificationCodes, selectedWalletIds, selectedWallet]);
|
|
372
283
|
|
|
373
|
-
//
|
|
374
|
-
var
|
|
284
|
+
// 获取钱包推荐列表
|
|
285
|
+
var fetchWalletRecommendList = useMemoizedFn( /*#__PURE__*/function () {
|
|
375
286
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
|
|
376
|
-
var result
|
|
287
|
+
var result;
|
|
377
288
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
378
289
|
while (1) switch (_context.prev = _context.next) {
|
|
379
290
|
case 0:
|
|
@@ -381,31 +292,66 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
381
292
|
setError(null);
|
|
382
293
|
_context.prev = 2;
|
|
383
294
|
_context.next = 5;
|
|
384
|
-
return paymentModule.wallet.
|
|
295
|
+
return paymentModule.wallet.getWalletPassRecommendListAsync(params);
|
|
385
296
|
case 5:
|
|
386
297
|
result = _context.sent;
|
|
387
|
-
|
|
388
|
-
setUserIdentificationCodes(newData);
|
|
298
|
+
setWalletRecommendList(result);
|
|
389
299
|
return _context.abrupt("return", result);
|
|
390
|
-
case
|
|
391
|
-
_context.prev =
|
|
300
|
+
case 10:
|
|
301
|
+
_context.prev = 10;
|
|
392
302
|
_context.t0 = _context["catch"](2);
|
|
393
|
-
setError(_context.t0 instanceof Error ? _context.t0.message : '
|
|
303
|
+
setError(_context.t0 instanceof Error ? _context.t0.message : '获取钱包推荐列表失败');
|
|
394
304
|
throw _context.t0;
|
|
395
|
-
case
|
|
396
|
-
_context.prev =
|
|
305
|
+
case 14:
|
|
306
|
+
_context.prev = 14;
|
|
397
307
|
setLoading(false);
|
|
398
|
-
return _context.finish(
|
|
399
|
-
case
|
|
308
|
+
return _context.finish(14);
|
|
309
|
+
case 17:
|
|
400
310
|
case "end":
|
|
401
311
|
return _context.stop();
|
|
402
312
|
}
|
|
403
|
-
}, _callee, null, [[2,
|
|
313
|
+
}, _callee, null, [[2, 10, 14, 17]]);
|
|
404
314
|
}));
|
|
405
315
|
return function (_x) {
|
|
406
316
|
return _ref.apply(this, arguments);
|
|
407
317
|
};
|
|
408
318
|
}());
|
|
319
|
+
// 获取用户识别码列表
|
|
320
|
+
var fetchUserIdentificationCodes = useMemoizedFn( /*#__PURE__*/function () {
|
|
321
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
|
|
322
|
+
var result, newData;
|
|
323
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
324
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
325
|
+
case 0:
|
|
326
|
+
setLoading(true);
|
|
327
|
+
setError(null);
|
|
328
|
+
_context2.prev = 2;
|
|
329
|
+
_context2.next = 5;
|
|
330
|
+
return paymentModule.wallet.getUserIdentificationCodeListAsync(params);
|
|
331
|
+
case 5:
|
|
332
|
+
result = _context2.sent;
|
|
333
|
+
newData = uniqueByKey([].concat(_toConsumableArray(result), _toConsumableArray(selectedWalletRef.current)), 'id'); // const orderedData = mergeDataWithInitialOrder(newData);
|
|
334
|
+
setUserIdentificationCodes(newData);
|
|
335
|
+
return _context2.abrupt("return", result);
|
|
336
|
+
case 11:
|
|
337
|
+
_context2.prev = 11;
|
|
338
|
+
_context2.t0 = _context2["catch"](2);
|
|
339
|
+
setError(_context2.t0 instanceof Error ? _context2.t0.message : '获取用户识别码列表失败');
|
|
340
|
+
throw _context2.t0;
|
|
341
|
+
case 15:
|
|
342
|
+
_context2.prev = 15;
|
|
343
|
+
setLoading(false);
|
|
344
|
+
return _context2.finish(15);
|
|
345
|
+
case 18:
|
|
346
|
+
case "end":
|
|
347
|
+
return _context2.stop();
|
|
348
|
+
}
|
|
349
|
+
}, _callee2, null, [[2, 11, 15, 18]]);
|
|
350
|
+
}));
|
|
351
|
+
return function (_x2) {
|
|
352
|
+
return _ref2.apply(this, arguments);
|
|
353
|
+
};
|
|
354
|
+
}());
|
|
409
355
|
|
|
410
356
|
// 获取缓存数据
|
|
411
357
|
var getCachedWalletRecommendList = useMemoizedFn(function () {
|
|
@@ -437,103 +383,46 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
437
383
|
var handleSearchIdentificationCodeCompleted = useMemoizedFn(function (data) {
|
|
438
384
|
var currentSearchResults = data.currentSearchResults,
|
|
439
385
|
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
386
|
var isAvailableData = [];
|
|
463
387
|
var isDisabledData = [];
|
|
464
|
-
if (
|
|
465
|
-
|
|
466
|
-
if (
|
|
388
|
+
if (currentSearchResults.length > 0) {
|
|
389
|
+
currentSearchResults.forEach(function (item) {
|
|
390
|
+
if (!!item.unified_available_status) {
|
|
467
391
|
isAvailableData.push(item);
|
|
468
392
|
} else {
|
|
469
393
|
isDisabledData.push(item);
|
|
470
394
|
}
|
|
471
395
|
});
|
|
472
396
|
}
|
|
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
397
|
|
|
482
|
-
//
|
|
398
|
+
// 更新不可用钱包数据
|
|
399
|
+
setDisabledWalletData(isDisabledData);
|
|
483
400
|
var newValues = _toConsumableArray(selectedWalletRef.current);
|
|
484
401
|
if (isAvailableData.length === 1) {
|
|
485
402
|
newValues = [].concat(_toConsumableArray(selectedWalletRef.current), isAvailableData);
|
|
486
403
|
}
|
|
487
|
-
|
|
488
|
-
// 更新搜索结果列表(合并缓存和当前搜索结果,使用去重后的数据)
|
|
489
|
-
setSearchIdentificationCodeList(availableData);
|
|
490
|
-
setNoApplicableVoucher(allDisabledData);
|
|
404
|
+
setSearchIdentificationCodeList(cachedSearchResults);
|
|
491
405
|
setWalletSelect(newValues);
|
|
492
|
-
|
|
493
|
-
// 更新选中的券ID列表(会触发 useMemo 重新计算 selectedWithDetails)
|
|
494
|
-
setSelectedVoucherIds(newValues.map(function (item) {
|
|
406
|
+
handleFetchUserIdentificationCodes(newValues.map(function (item) {
|
|
495
407
|
return item.id;
|
|
496
408
|
}));
|
|
497
|
-
|
|
498
|
-
// useUpdateEffect 会自动在 selectedWithDetails 更新后通知外部
|
|
499
409
|
});
|
|
500
410
|
var onOrderCreated = useMemoizedFn(function () {
|
|
501
|
-
var _paymentModule$wallet, _paymentModule$wallet2;
|
|
502
411
|
var orderInfo = checkoutModule.getOrderOriginalData();
|
|
503
412
|
setOrderInfo(orderInfo);
|
|
504
|
-
|
|
505
|
-
// 从缓存获取初始化数据(包含新的数据结构)
|
|
506
413
|
var recommendList = getCachedWalletRecommendList();
|
|
507
414
|
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
415
|
var initialData = [].concat(_toConsumableArray(recommendList), _toConsumableArray(userIdentificationCodes));
|
|
516
416
|
|
|
517
417
|
// 设置钱包推荐列表
|
|
518
418
|
setWalletRecommendList(recommendList);
|
|
519
|
-
//
|
|
520
|
-
setUserIdentificationCodes(
|
|
521
|
-
// 设置可计算的券列表
|
|
522
|
-
setTransformList(transformListData);
|
|
523
|
-
// 设置不适用的券列表
|
|
524
|
-
setNoApplicableVoucher(noApplicableVoucherData);
|
|
525
|
-
// 设置产品列表
|
|
526
|
-
setProducts(productsData);
|
|
419
|
+
// 设置用户识别码列表
|
|
420
|
+
setUserIdentificationCodes(initialData);
|
|
527
421
|
// 设置初始顺序
|
|
528
422
|
initialOrderedDataRef.current = initialData;
|
|
529
|
-
|
|
530
423
|
// 设置默认选中钱包
|
|
531
424
|
if (!notSetWalletSelectRef.current) {
|
|
532
425
|
setWalletSelect(recommendList);
|
|
533
|
-
// 设置默认选中的券ID
|
|
534
|
-
setSelectedVoucherIds(recommendList.map(function (item) {
|
|
535
|
-
return item.id;
|
|
536
|
-
}));
|
|
537
426
|
var _select = paymentModule.wallet.formatWalletPassList2PreparePayments(recommendList).map(function (item) {
|
|
538
427
|
return {
|
|
539
428
|
code: item.tag,
|
|
@@ -552,7 +441,6 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
552
441
|
onSelectChange === null || onSelectChange === void 0 || onSelectChange(_select);
|
|
553
442
|
} else {
|
|
554
443
|
setWalletSelect([]);
|
|
555
|
-
setSelectedVoucherIds([]);
|
|
556
444
|
notSetWalletSelectRef.current = false;
|
|
557
445
|
onSelectChange === null || onSelectChange === void 0 || onSelectChange([]);
|
|
558
446
|
}
|
|
@@ -599,27 +487,27 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
599
487
|
setLoading(false);
|
|
600
488
|
});
|
|
601
489
|
var handlePaymentStarted = useMemoizedFn( /*#__PURE__*/function () {
|
|
602
|
-
var
|
|
603
|
-
return _regeneratorRuntime().wrap(function
|
|
604
|
-
while (1) switch (
|
|
490
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
491
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
492
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
605
493
|
case 0:
|
|
606
|
-
if (!(params.paymentMethodCode !== 'VOUCHER_BATCH'
|
|
607
|
-
|
|
494
|
+
if (!(params.paymentMethodCode !== 'VOUCHER_BATCH')) {
|
|
495
|
+
_context3.next = 4;
|
|
608
496
|
break;
|
|
609
497
|
}
|
|
610
498
|
notSetWalletSelectRef.current = true;
|
|
611
|
-
|
|
499
|
+
_context3.next = 4;
|
|
612
500
|
return checkoutModule.initWalletData({
|
|
613
501
|
order_wait_pay_amount: Number(customAmount)
|
|
614
502
|
});
|
|
615
503
|
case 4:
|
|
616
504
|
case "end":
|
|
617
|
-
return
|
|
505
|
+
return _context3.stop();
|
|
618
506
|
}
|
|
619
|
-
},
|
|
507
|
+
}, _callee3);
|
|
620
508
|
}));
|
|
621
|
-
return function (
|
|
622
|
-
return
|
|
509
|
+
return function (_x3) {
|
|
510
|
+
return _ref3.apply(this, arguments);
|
|
623
511
|
};
|
|
624
512
|
}());
|
|
625
513
|
|
|
@@ -671,6 +559,16 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
671
559
|
};
|
|
672
560
|
}, [paymentModule]);
|
|
673
561
|
|
|
562
|
+
// 组件卸载时清理定时器
|
|
563
|
+
useEffect(function () {
|
|
564
|
+
return function () {
|
|
565
|
+
if (timeoutRef.current) {
|
|
566
|
+
clearTimeout(timeoutRef.current);
|
|
567
|
+
timeoutRef.current = null;
|
|
568
|
+
}
|
|
569
|
+
};
|
|
570
|
+
}, []);
|
|
571
|
+
|
|
674
572
|
// 所有列表 包含推荐列表、用户识别码列表、搜索用户识别码列表
|
|
675
573
|
var allList = useMemo(function () {
|
|
676
574
|
var reversedSearchData = _toConsumableArray(searchIdentificationCodeList).reverse();
|
|
@@ -686,9 +584,12 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
686
584
|
});
|
|
687
585
|
});
|
|
688
586
|
|
|
689
|
-
//
|
|
690
|
-
var
|
|
691
|
-
var
|
|
587
|
+
// 处理获取用户识别码
|
|
588
|
+
var handleFetchUserIdentificationCodes = useMemoizedFn(function (value, walletRecommendList) {
|
|
589
|
+
var val = uniqueByKey(walletRecommendList || allList, 'id').filter(function (item) {
|
|
590
|
+
return value.includes(item.id);
|
|
591
|
+
});
|
|
592
|
+
var prepare_payments = paymentModule.wallet.formatWalletPassList2PreparePayments(val);
|
|
692
593
|
var select = prepare_payments.map(function (item) {
|
|
693
594
|
return {
|
|
694
595
|
voucher_id: item.voucher_id,
|
|
@@ -700,13 +601,16 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
700
601
|
});
|
|
701
602
|
logger === null || logger === void 0 || logger.addLog({
|
|
702
603
|
type: 'info',
|
|
703
|
-
title: '
|
|
704
|
-
metadata: {
|
|
705
|
-
selectedDetails: selectedDetails,
|
|
706
|
-
select: select
|
|
707
|
-
}
|
|
604
|
+
title: 'useWalletPass_handleFetchUserIdentificationCodes onSelectChange 开始调用',
|
|
605
|
+
metadata: {}
|
|
708
606
|
});
|
|
709
607
|
onSelectChange === null || onSelectChange === void 0 || onSelectChange(select);
|
|
608
|
+
fetchUserIdentificationCodes({
|
|
609
|
+
prepare_payments: prepare_payments,
|
|
610
|
+
available: 2,
|
|
611
|
+
filter_prepare_wallet_pass: 1,
|
|
612
|
+
other_exact_codes: getOtherExactCodes()
|
|
613
|
+
});
|
|
710
614
|
});
|
|
711
615
|
var handleSearchIdentificationCode = useMemoizedFn(function (value) {
|
|
712
616
|
return paymentModule.wallet.searchIdentificationCodeAsync({
|
|
@@ -715,46 +619,13 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
715
619
|
});
|
|
716
620
|
});
|
|
717
621
|
|
|
718
|
-
//
|
|
622
|
+
// 处理选中钱包
|
|
719
623
|
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) {
|
|
624
|
+
var val = userIdentificationCodes.filter(function (item) {
|
|
755
625
|
return value.includes(item.id);
|
|
756
626
|
});
|
|
757
627
|
setWalletSelect(val);
|
|
628
|
+
handleFetchUserIdentificationCodes(value);
|
|
758
629
|
});
|
|
759
630
|
|
|
760
631
|
// 获取过期钱包id
|
|
@@ -777,15 +648,12 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
777
648
|
|
|
778
649
|
// 清除所有选中的钱包
|
|
779
650
|
var clearAllSelectedWallet = useMemoizedFn(function () {
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
confirmedEditAmountIdsRef.current = [];
|
|
787
|
-
}
|
|
788
|
-
|
|
651
|
+
logger === null || logger === void 0 || logger.addLog({
|
|
652
|
+
type: 'info',
|
|
653
|
+
title: 'useWalletPass_clearAllSelectedWallet onSelectChange 开始调用',
|
|
654
|
+
metadata: {}
|
|
655
|
+
});
|
|
656
|
+
onSelectChange === null || onSelectChange === void 0 || onSelectChange([]);
|
|
789
657
|
// 如果没有选中钱包,则不处理
|
|
790
658
|
if (selectedWalletIds.length === 0 && selectedDiscountList.length === 0) {
|
|
791
659
|
return;
|
|
@@ -808,19 +676,8 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
808
676
|
pisellos === null || pisellos === void 0 || (_pisellos$effects = pisellos.effects) === null || _pisellos$effects === void 0 || _pisellos$effects.emit('shopDiscount:onSelectedDiscountListChange', detail);
|
|
809
677
|
return;
|
|
810
678
|
}
|
|
811
|
-
|
|
812
|
-
// 清空选中的钱包
|
|
813
679
|
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);
|
|
680
|
+
handleFetchUserIdentificationCodes([]);
|
|
824
681
|
});
|
|
825
682
|
|
|
826
683
|
// 判断当前选择是否已是最优选择
|
|
@@ -875,14 +732,12 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
875
732
|
Toast === null || Toast === void 0 || Toast.info(locales.getText('wallet-pass-module-already-best-combination'));
|
|
876
733
|
} else {
|
|
877
734
|
var _select2 = searchIdentificationCodeList.filter(function (item) {
|
|
878
|
-
return
|
|
735
|
+
return item.unified_available_status;
|
|
879
736
|
});
|
|
880
737
|
setWalletSelect(_select2);
|
|
881
|
-
|
|
882
|
-
setSelectedVoucherIds(_select2.map(function (item) {
|
|
738
|
+
handleFetchUserIdentificationCodes(_select2.map(function (item) {
|
|
883
739
|
return item.id;
|
|
884
|
-
}));
|
|
885
|
-
// useUpdateEffect 会自动在 selectedWithDetails 更新后通知外部
|
|
740
|
+
}), _select2);
|
|
886
741
|
if (_select2.length) {
|
|
887
742
|
Toast === null || Toast === void 0 || Toast.success(locales.getText('wallet-pass-module-best-combination-selected'));
|
|
888
743
|
}
|
|
@@ -911,14 +766,11 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
911
766
|
if (hasGoodPass && !isBestDiscount) return;
|
|
912
767
|
// 重置为最优选择并显示Toast提示
|
|
913
768
|
setWalletSelect(newWalletRecommendList);
|
|
914
|
-
|
|
915
|
-
setSelectedVoucherIds(newWalletRecommendList.map(function (item) {
|
|
769
|
+
handleFetchUserIdentificationCodes(newWalletRecommendList.map(function (item) {
|
|
916
770
|
return item.id;
|
|
917
|
-
}));
|
|
918
|
-
// useUpdateEffect 会自动在 selectedWithDetails 更新后通知外部
|
|
771
|
+
}), newWalletRecommendList);
|
|
919
772
|
Toast === null || Toast === void 0 || Toast.success(locales.getText('wallet-pass-module-best-combination-selected'));
|
|
920
773
|
}
|
|
921
|
-
setLoading(false);
|
|
922
774
|
});
|
|
923
775
|
var handleSelectDiscount = useMemoizedFn(function (value, option) {
|
|
924
776
|
var _detail$discountList, _pisellos$effects2;
|
|
@@ -963,10 +815,6 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
963
815
|
var newUserIdentificationCodes = updateArrayItemById(userIdentificationCodes, targetId, updateData);
|
|
964
816
|
setUserIdentificationCodes(newUserIdentificationCodes);
|
|
965
817
|
|
|
966
|
-
// 更新transformList中对应ID的数据(用于前端计算)
|
|
967
|
-
var newTransformList = updateArrayItemById(transformList, targetId, updateData);
|
|
968
|
-
setTransformList(newTransformList);
|
|
969
|
-
|
|
970
818
|
// 更新searchIdentificationCodeList中对应ID的数据
|
|
971
819
|
var newSearchIdentificationCodeList = updateArrayItemById(searchIdentificationCodeList, targetId, updateData);
|
|
972
820
|
setSearchIdentificationCodeList(newSearchIdentificationCodeList);
|
|
@@ -977,7 +825,6 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
977
825
|
return {
|
|
978
826
|
newWalletRecommendList: newWalletRecommendList,
|
|
979
827
|
newUserIdentificationCodes: newUserIdentificationCodes,
|
|
980
|
-
newTransformList: newTransformList,
|
|
981
828
|
newSearchIdentificationCodeList: newSearchIdentificationCodeList,
|
|
982
829
|
newSelectedWallet: newSelectedWallet
|
|
983
830
|
};
|
|
@@ -985,42 +832,70 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
985
832
|
var handleConfirmEditAmount = useMemoizedFn(function (value, id, data) {
|
|
986
833
|
// 如果金额为0,直接触发 handleSelectWallet 把当前id过滤掉
|
|
987
834
|
if (value === 0) {
|
|
988
|
-
var filteredIds =
|
|
835
|
+
var filteredIds = selectedWalletIds.filter(function (walletId) {
|
|
989
836
|
return walletId !== data.id;
|
|
990
837
|
});
|
|
991
838
|
handleSelectWallet(filteredIds);
|
|
992
839
|
return;
|
|
993
840
|
}
|
|
994
|
-
setLoading(true);
|
|
995
841
|
|
|
996
842
|
// 将执行过的 data.id 添加到跟踪数组中(避免重复)
|
|
997
843
|
if (!confirmedEditAmountIdsRef.current.includes(data.id)) {
|
|
998
844
|
confirmedEditAmountIdsRef.current.push(data.id);
|
|
999
845
|
}
|
|
1000
846
|
|
|
1001
|
-
//
|
|
1002
|
-
// 这会触发 useMemo 重新计算 selectedWithDetails
|
|
847
|
+
// 使用通用函数更新所有相关状态
|
|
1003
848
|
updateWalletDataById(data.id, {
|
|
1004
849
|
edit_current_amount: value
|
|
1005
850
|
});
|
|
1006
851
|
|
|
1007
|
-
//
|
|
1008
|
-
|
|
852
|
+
// 清理之前的定时器
|
|
853
|
+
if (timeoutRef.current) {
|
|
854
|
+
clearTimeout(timeoutRef.current);
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
// 设置新的定时器并保存引用
|
|
858
|
+
timeoutRef.current = setTimeout(function () {
|
|
859
|
+
handleFetchUserIdentificationCodes(selectedWalletIds);
|
|
860
|
+
timeoutRef.current = null; // 执行完成后清空引用
|
|
861
|
+
});
|
|
1009
862
|
});
|
|
1010
863
|
var handleBeforeEditAmount = useMemoizedFn( /*#__PURE__*/function () {
|
|
1011
|
-
var
|
|
1012
|
-
|
|
1013
|
-
|
|
864
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(value, index, data) {
|
|
865
|
+
var result, resultItem;
|
|
866
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
867
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
1014
868
|
case 0:
|
|
1015
|
-
|
|
1016
|
-
|
|
869
|
+
_context4.next = 2;
|
|
870
|
+
return paymentModule.wallet.searchIdentificationCodeAsync({
|
|
871
|
+
code: data.code,
|
|
872
|
+
prepare_payments: paymentModule.wallet.formatWalletPassList2PreparePayments(selectedWalletRef.current.filter(function (item) {
|
|
873
|
+
return item.id !== data.id;
|
|
874
|
+
}))
|
|
875
|
+
}, {
|
|
876
|
+
noCache: true
|
|
877
|
+
});
|
|
878
|
+
case 2:
|
|
879
|
+
result = _context4.sent;
|
|
880
|
+
// 如果result中有数据,使用result中的数据更新状态
|
|
881
|
+
if (result.data && result.data.length > 0) {
|
|
882
|
+
resultItem = result.data.find(function (item) {
|
|
883
|
+
return item.id === data.id;
|
|
884
|
+
});
|
|
885
|
+
if (resultItem) {
|
|
886
|
+
// 使用通用函数更新所有相关状态
|
|
887
|
+
updateWalletDataById(data.id, resultItem);
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
return _context4.abrupt("return", true);
|
|
891
|
+
case 5:
|
|
1017
892
|
case "end":
|
|
1018
|
-
return
|
|
893
|
+
return _context4.stop();
|
|
1019
894
|
}
|
|
1020
|
-
},
|
|
895
|
+
}, _callee4);
|
|
1021
896
|
}));
|
|
1022
|
-
return function (
|
|
1023
|
-
return
|
|
897
|
+
return function (_x4, _x5, _x6) {
|
|
898
|
+
return _ref4.apply(this, arguments);
|
|
1024
899
|
};
|
|
1025
900
|
}());
|
|
1026
901
|
return {
|
|
@@ -1044,6 +919,7 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
1044
919
|
selectedDiscountList: selectedDiscountList,
|
|
1045
920
|
handleSelectDiscount: handleSelectDiscount,
|
|
1046
921
|
customerName: customerName,
|
|
922
|
+
fetchWalletRecommendList: fetchWalletRecommendList,
|
|
1047
923
|
fetchUserIdentificationCodes: fetchUserIdentificationCodes,
|
|
1048
924
|
getCachedWalletRecommendList: getCachedWalletRecommendList,
|
|
1049
925
|
getCachedUserIdentificationCodes: getCachedUserIdentificationCodes,
|