@pisell/private-materials 6.6.11 → 6.6.12
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 +2 -2
- 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 +5 -3
- package/es/components/booking/components/voucher/index.js +6 -0
- package/es/components/booking/components/voucher/index.less +4 -1
- package/es/components/booking/components/voucherModal/index.less +1 -0
- package/es/components/booking/info2/service/editService/index.js +33 -2
- package/es/components/checkout/components/WalletPassModule/index.js +1 -0
- package/es/components/checkout/components/WalletPassModule/utils.js +14 -3
- package/es/components/checkout/hooks/useWalletPass.d.ts +1 -1
- package/es/components/checkout/hooks/useWalletPass.js +310 -189
- 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/systemSettings/registry/components/SectionList.js +5 -1
- package/es/components/ticketBooking/components/addServiceVariant/addService.js +7 -4
- package/es/plus/walletPassGallery/serve.js +2 -0
- package/es/pro/Login2.0/AuthModal.js +12 -4
- package/es/pro/Login2.0/index.less +7 -7
- 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 +1 -1
- 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 +5 -3
- package/lib/components/booking/components/voucher/index.js +6 -0
- package/lib/components/booking/components/voucher/index.less +4 -1
- package/lib/components/booking/components/voucherModal/index.less +1 -0
- package/lib/components/booking/info2/service/editService/index.js +48 -24
- package/lib/components/checkout/components/WalletPassModule/index.js +1 -0
- package/lib/components/checkout/components/WalletPassModule/utils.js +13 -2
- package/lib/components/checkout/hooks/useWalletPass.d.ts +1 -1
- package/lib/components/checkout/hooks/useWalletPass.js +151 -104
- 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/systemSettings/registry/components/SectionList.js +4 -1
- package/lib/components/ticketBooking/components/addServiceVariant/addService.js +11 -7
- package/lib/plus/walletPassGallery/serve.js +2 -0
- package/lib/pro/Login2.0/AuthModal.js +15 -7
- package/lib/pro/Login2.0/index.less +7 -7
- package/package.json +2 -2
- package/es/components/checkout/PaymentModal.d.ts +0 -31
- package/lib/components/checkout/PaymentModal.d.ts +0 -31
|
@@ -19,7 +19,7 @@ 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 } from 'ahooks';
|
|
22
|
+
import { useMemoizedFn, useUpdateEffect } from 'ahooks';
|
|
23
23
|
import { uniqueByKey, locales } from '@pisell/utils';
|
|
24
24
|
import { useToast } from '@pisell/materials';
|
|
25
25
|
import dayjs from 'dayjs';
|
|
@@ -36,21 +36,33 @@ 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
|
|
39
|
+
clientId = props.clientId,
|
|
40
|
+
totalAmount = props.totalAmount;
|
|
40
41
|
var logger = usePaymentLogger();
|
|
41
42
|
var _useActiveExecute = useActiveExecute(),
|
|
42
43
|
executeIfActive = _useActiveExecute.executeIfActive;
|
|
43
44
|
|
|
44
|
-
//
|
|
45
|
+
// 钱包推荐列表(推荐选中的券)
|
|
45
46
|
var _useState = useState([]),
|
|
46
47
|
_useState2 = _slicedToArray(_useState, 2),
|
|
47
48
|
walletRecommendList = _useState2[0],
|
|
48
49
|
setWalletRecommendList = _useState2[1];
|
|
49
|
-
//
|
|
50
|
+
// 用户识别码列表(全部券列表,包括可用和不可用)
|
|
50
51
|
var _useState3 = useState([]),
|
|
51
52
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
52
53
|
userIdentificationCodes = _useState4[0],
|
|
53
54
|
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
|
+
|
|
54
66
|
// 保存初始顺序的数组
|
|
55
67
|
var initialOrderedDataRef = useRef([]);
|
|
56
68
|
|
|
@@ -60,31 +72,34 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
60
72
|
// 跟踪执行过 handleConfirmEditAmount 的 data.id
|
|
61
73
|
var confirmedEditAmountIdsRef = useRef([]);
|
|
62
74
|
|
|
63
|
-
//
|
|
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
|
-
// 当前选中的钱包
|
|
75
|
+
// 搜索用户识别码列表(addList)
|
|
77
76
|
var _useState9 = useState([]),
|
|
78
77
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
searchIdentificationCodeList = _useState10[0],
|
|
79
|
+
setSearchIdentificationCodeList = _useState10[1];
|
|
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];
|
|
81
90
|
var selectedWalletRef = useRef([]);
|
|
82
91
|
|
|
92
|
+
// 当前选中的券ID列表(按选中顺序)
|
|
93
|
+
var _useState15 = useState([]),
|
|
94
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
|
95
|
+
selectedVoucherIds = _useState16[0],
|
|
96
|
+
setSelectedVoucherIds = _useState16[1];
|
|
97
|
+
|
|
83
98
|
// 不可用的钱包数据
|
|
84
|
-
var
|
|
85
|
-
|
|
86
|
-
disabledWalletData =
|
|
87
|
-
setDisabledWalletData =
|
|
99
|
+
var _useState17 = useState([]),
|
|
100
|
+
_useState18 = _slicedToArray(_useState17, 2),
|
|
101
|
+
disabledWalletData = _useState18[0],
|
|
102
|
+
setDisabledWalletData = _useState18[1];
|
|
88
103
|
|
|
89
104
|
// 设置钱包但不设置使用默认钱包
|
|
90
105
|
var notSetWalletSelectRef = useRef(false);
|
|
@@ -92,7 +107,13 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
92
107
|
// 是否显示最佳优惠
|
|
93
108
|
var showBestToastRef = useRef(false);
|
|
94
109
|
|
|
95
|
-
//
|
|
110
|
+
// 商品列表
|
|
111
|
+
var _useState19 = useState([]),
|
|
112
|
+
_useState20 = _slicedToArray(_useState19, 2),
|
|
113
|
+
products = _useState20[0],
|
|
114
|
+
setProducts = _useState20[1];
|
|
115
|
+
|
|
116
|
+
// 当前选中的钱包id(保留兼容性)
|
|
96
117
|
var selectedWalletIds = useMemo(function () {
|
|
97
118
|
return selectedWallet.map(function (item) {
|
|
98
119
|
return item.id;
|
|
@@ -102,24 +123,30 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
102
123
|
var Toast = useToast();
|
|
103
124
|
|
|
104
125
|
// 加载状态
|
|
105
|
-
var
|
|
106
|
-
|
|
107
|
-
loading =
|
|
108
|
-
setLoading =
|
|
126
|
+
var _useState21 = useState(false),
|
|
127
|
+
_useState22 = _slicedToArray(_useState21, 2),
|
|
128
|
+
loading = _useState22[0],
|
|
129
|
+
setLoading = _useState22[1];
|
|
109
130
|
// 错误信息
|
|
110
|
-
var
|
|
111
|
-
|
|
112
|
-
error =
|
|
113
|
-
setError =
|
|
114
|
-
var
|
|
115
|
-
|
|
116
|
-
discountList =
|
|
117
|
-
setDiscountList =
|
|
131
|
+
var _useState23 = useState(null),
|
|
132
|
+
_useState24 = _slicedToArray(_useState23, 2),
|
|
133
|
+
error = _useState24[0],
|
|
134
|
+
setError = _useState24[1];
|
|
135
|
+
var _useState25 = useState([]),
|
|
136
|
+
_useState26 = _slicedToArray(_useState25, 2),
|
|
137
|
+
discountList = _useState26[0],
|
|
138
|
+
setDiscountList = _useState26[1];
|
|
118
139
|
|
|
119
140
|
// 获取checkout模块
|
|
120
141
|
var checkoutModule = pisellos.getModule('checkout');
|
|
121
142
|
var shopDiscount = useShopDiscountModule();
|
|
122
143
|
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
|
+
}, []);
|
|
123
150
|
var setWalletSelect = useMemoizedFn(function (data) {
|
|
124
151
|
setSelectedWallet(data);
|
|
125
152
|
selectedWalletRef.current = data;
|
|
@@ -276,15 +303,77 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
276
303
|
orderedResult.push.apply(orderedResult, _toConsumableArray(newItems));
|
|
277
304
|
return orderedResult;
|
|
278
305
|
});
|
|
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]);
|
|
279
368
|
var data = useMemo(function () {
|
|
280
|
-
//
|
|
281
|
-
return formatMachineCodeServer2CardList(uniqueByKey(mergeDataWithInitialOrder([].concat(_toConsumableArray(selectedWallet), _toConsumableArray(
|
|
282
|
-
}, [
|
|
369
|
+
// 使用前端计算后的数据
|
|
370
|
+
return formatMachineCodeServer2CardList(uniqueByKey(mergeDataWithInitialOrder([].concat(_toConsumableArray(selectedWallet), _toConsumableArray(displayVouchers), _toConsumableArray(displayOtherVouchers))), 'id'), selectedVoucherIds);
|
|
371
|
+
}, [displayVouchers, displayOtherVouchers, selectedVoucherIds, selectedWallet]);
|
|
283
372
|
|
|
284
|
-
//
|
|
285
|
-
var
|
|
373
|
+
// 获取用户识别码列表
|
|
374
|
+
var fetchUserIdentificationCodes = useMemoizedFn( /*#__PURE__*/function () {
|
|
286
375
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
|
|
287
|
-
var result;
|
|
376
|
+
var result, newData;
|
|
288
377
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
289
378
|
while (1) switch (_context.prev = _context.next) {
|
|
290
379
|
case 0:
|
|
@@ -292,66 +381,31 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
292
381
|
setError(null);
|
|
293
382
|
_context.prev = 2;
|
|
294
383
|
_context.next = 5;
|
|
295
|
-
return paymentModule.wallet.
|
|
384
|
+
return paymentModule.wallet.getUserIdentificationCodeListAsync(params);
|
|
296
385
|
case 5:
|
|
297
386
|
result = _context.sent;
|
|
298
|
-
|
|
387
|
+
newData = uniqueByKey([].concat(_toConsumableArray(result), _toConsumableArray(selectedWalletRef.current)), 'id'); // const orderedData = mergeDataWithInitialOrder(newData);
|
|
388
|
+
setUserIdentificationCodes(newData);
|
|
299
389
|
return _context.abrupt("return", result);
|
|
300
|
-
case
|
|
301
|
-
_context.prev =
|
|
390
|
+
case 11:
|
|
391
|
+
_context.prev = 11;
|
|
302
392
|
_context.t0 = _context["catch"](2);
|
|
303
|
-
setError(_context.t0 instanceof Error ? _context.t0.message : '
|
|
393
|
+
setError(_context.t0 instanceof Error ? _context.t0.message : '获取用户识别码列表失败');
|
|
304
394
|
throw _context.t0;
|
|
305
|
-
case
|
|
306
|
-
_context.prev =
|
|
395
|
+
case 15:
|
|
396
|
+
_context.prev = 15;
|
|
307
397
|
setLoading(false);
|
|
308
|
-
return _context.finish(
|
|
309
|
-
case
|
|
398
|
+
return _context.finish(15);
|
|
399
|
+
case 18:
|
|
310
400
|
case "end":
|
|
311
401
|
return _context.stop();
|
|
312
402
|
}
|
|
313
|
-
}, _callee, null, [[2,
|
|
403
|
+
}, _callee, null, [[2, 11, 15, 18]]);
|
|
314
404
|
}));
|
|
315
405
|
return function (_x) {
|
|
316
406
|
return _ref.apply(this, arguments);
|
|
317
407
|
};
|
|
318
408
|
}());
|
|
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
|
-
}());
|
|
355
409
|
|
|
356
410
|
// 获取缓存数据
|
|
357
411
|
var getCachedWalletRecommendList = useMemoizedFn(function () {
|
|
@@ -383,10 +437,32 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
383
437
|
var handleSearchIdentificationCodeCompleted = useMemoizedFn(function (data) {
|
|
384
438
|
var currentSearchResults = data.currentSearchResults,
|
|
385
439
|
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');
|
|
386
462
|
var isAvailableData = [];
|
|
387
463
|
var isDisabledData = [];
|
|
388
|
-
if (
|
|
389
|
-
|
|
464
|
+
if (formattedResults.length > 0) {
|
|
465
|
+
formattedResults.forEach(function (item) {
|
|
390
466
|
if (!!item.unified_available_status) {
|
|
391
467
|
isAvailableData.push(item);
|
|
392
468
|
} else {
|
|
@@ -395,34 +471,66 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
395
471
|
});
|
|
396
472
|
}
|
|
397
473
|
|
|
398
|
-
//
|
|
399
|
-
|
|
474
|
+
// 更新不可用钱包数据(需要包含所有搜索结果中的不可用数据)
|
|
475
|
+
var allDisabledData = mergedSearchResults.filter(function (item) {
|
|
476
|
+
return !item.unified_available_status;
|
|
477
|
+
});
|
|
478
|
+
setDisabledWalletData(allDisabledData);
|
|
479
|
+
|
|
480
|
+
// 如果只有一个可用券,自动选中
|
|
400
481
|
var newValues = _toConsumableArray(selectedWalletRef.current);
|
|
401
482
|
if (isAvailableData.length === 1) {
|
|
402
483
|
newValues = [].concat(_toConsumableArray(selectedWalletRef.current), isAvailableData);
|
|
403
484
|
}
|
|
404
|
-
|
|
485
|
+
|
|
486
|
+
// 更新搜索结果列表(合并缓存和当前搜索结果,使用去重后的数据)
|
|
487
|
+
setSearchIdentificationCodeList(mergedSearchResults);
|
|
405
488
|
setWalletSelect(newValues);
|
|
406
|
-
|
|
489
|
+
|
|
490
|
+
// 更新选中的券ID列表(会触发 useMemo 重新计算 selectedWithDetails)
|
|
491
|
+
setSelectedVoucherIds(newValues.map(function (item) {
|
|
407
492
|
return item.id;
|
|
408
493
|
}));
|
|
494
|
+
|
|
495
|
+
// useUpdateEffect 会自动在 selectedWithDetails 更新后通知外部
|
|
409
496
|
});
|
|
410
497
|
var onOrderCreated = useMemoizedFn(function () {
|
|
498
|
+
var _paymentModule$wallet, _paymentModule$wallet2;
|
|
411
499
|
var orderInfo = checkoutModule.getOrderOriginalData();
|
|
412
500
|
setOrderInfo(orderInfo);
|
|
501
|
+
|
|
502
|
+
// 从缓存获取初始化数据(包含新的数据结构)
|
|
413
503
|
var recommendList = getCachedWalletRecommendList();
|
|
414
504
|
var userIdentificationCodes = getCachedUserIdentificationCodes();
|
|
505
|
+
|
|
506
|
+
// 获取 transformList 和 noApplicableVoucher(从 paymentModule 的缓存中)
|
|
507
|
+
// 这些数据在 initializeWalletDataAsync 中已经计算并缓存
|
|
508
|
+
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)) || {};
|
|
509
|
+
var transformListData = walletInitData.transformList || userIdentificationCodes;
|
|
510
|
+
var noApplicableVoucherData = walletInitData.noApplicableVoucher || [];
|
|
511
|
+
var productsData = walletInitData.products || [];
|
|
415
512
|
var initialData = [].concat(_toConsumableArray(recommendList), _toConsumableArray(userIdentificationCodes));
|
|
416
513
|
|
|
417
514
|
// 设置钱包推荐列表
|
|
418
515
|
setWalletRecommendList(recommendList);
|
|
419
|
-
//
|
|
420
|
-
setUserIdentificationCodes(
|
|
516
|
+
// 设置用户识别码列表(全部券)
|
|
517
|
+
setUserIdentificationCodes(userIdentificationCodes);
|
|
518
|
+
// 设置可计算的券列表
|
|
519
|
+
setTransformList(transformListData);
|
|
520
|
+
// 设置不适用的券列表
|
|
521
|
+
setNoApplicableVoucher(noApplicableVoucherData);
|
|
522
|
+
// 设置产品列表
|
|
523
|
+
setProducts(productsData);
|
|
421
524
|
// 设置初始顺序
|
|
422
525
|
initialOrderedDataRef.current = initialData;
|
|
526
|
+
|
|
423
527
|
// 设置默认选中钱包
|
|
424
528
|
if (!notSetWalletSelectRef.current) {
|
|
425
529
|
setWalletSelect(recommendList);
|
|
530
|
+
// 设置默认选中的券ID
|
|
531
|
+
setSelectedVoucherIds(recommendList.map(function (item) {
|
|
532
|
+
return item.id;
|
|
533
|
+
}));
|
|
426
534
|
var _select = paymentModule.wallet.formatWalletPassList2PreparePayments(recommendList).map(function (item) {
|
|
427
535
|
return {
|
|
428
536
|
code: item.tag,
|
|
@@ -439,6 +547,7 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
439
547
|
onSelectChange === null || onSelectChange === void 0 || onSelectChange(_select);
|
|
440
548
|
} else {
|
|
441
549
|
setWalletSelect([]);
|
|
550
|
+
setSelectedVoucherIds([]);
|
|
442
551
|
notSetWalletSelectRef.current = false;
|
|
443
552
|
onSelectChange === null || onSelectChange === void 0 || onSelectChange([]);
|
|
444
553
|
}
|
|
@@ -485,27 +594,27 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
485
594
|
setLoading(false);
|
|
486
595
|
});
|
|
487
596
|
var handlePaymentStarted = useMemoizedFn( /*#__PURE__*/function () {
|
|
488
|
-
var
|
|
489
|
-
return _regeneratorRuntime().wrap(function
|
|
490
|
-
while (1) switch (
|
|
597
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
|
|
598
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
599
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
491
600
|
case 0:
|
|
492
|
-
if (!(params.paymentMethodCode !== 'VOUCHER_BATCH')) {
|
|
493
|
-
|
|
601
|
+
if (!(params.paymentMethodCode !== 'VOUCHER_BATCH' && Number(customAmount || 0) > 0)) {
|
|
602
|
+
_context2.next = 4;
|
|
494
603
|
break;
|
|
495
604
|
}
|
|
496
605
|
notSetWalletSelectRef.current = true;
|
|
497
|
-
|
|
606
|
+
_context2.next = 4;
|
|
498
607
|
return checkoutModule.initWalletData({
|
|
499
608
|
order_wait_pay_amount: Number(customAmount)
|
|
500
609
|
});
|
|
501
610
|
case 4:
|
|
502
611
|
case "end":
|
|
503
|
-
return
|
|
612
|
+
return _context2.stop();
|
|
504
613
|
}
|
|
505
|
-
},
|
|
614
|
+
}, _callee2);
|
|
506
615
|
}));
|
|
507
|
-
return function (
|
|
508
|
-
return
|
|
616
|
+
return function (_x2) {
|
|
617
|
+
return _ref2.apply(this, arguments);
|
|
509
618
|
};
|
|
510
619
|
}());
|
|
511
620
|
|
|
@@ -557,16 +666,6 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
557
666
|
};
|
|
558
667
|
}, [paymentModule]);
|
|
559
668
|
|
|
560
|
-
// 组件卸载时清理定时器
|
|
561
|
-
useEffect(function () {
|
|
562
|
-
return function () {
|
|
563
|
-
if (timeoutRef.current) {
|
|
564
|
-
clearTimeout(timeoutRef.current);
|
|
565
|
-
timeoutRef.current = null;
|
|
566
|
-
}
|
|
567
|
-
};
|
|
568
|
-
}, []);
|
|
569
|
-
|
|
570
669
|
// 所有列表 包含推荐列表、用户识别码列表、搜索用户识别码列表
|
|
571
670
|
var allList = useMemo(function () {
|
|
572
671
|
var reversedSearchData = _toConsumableArray(searchIdentificationCodeList).reverse();
|
|
@@ -582,12 +681,9 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
582
681
|
});
|
|
583
682
|
});
|
|
584
683
|
|
|
585
|
-
//
|
|
586
|
-
var
|
|
587
|
-
var
|
|
588
|
-
return value.includes(item.id);
|
|
589
|
-
});
|
|
590
|
-
var prepare_payments = paymentModule.wallet.formatWalletPassList2PreparePayments(val);
|
|
684
|
+
// 纯粹的通知函数,将选中的券详情通知给外部
|
|
685
|
+
var notifySelectChange = useMemoizedFn(function (selectedDetails) {
|
|
686
|
+
var prepare_payments = paymentModule.wallet.formatWalletPassList2PreparePayments(selectedDetails);
|
|
591
687
|
var select = prepare_payments.map(function (item) {
|
|
592
688
|
return {
|
|
593
689
|
voucher_id: item.voucher_id,
|
|
@@ -597,16 +693,13 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
597
693
|
});
|
|
598
694
|
logger === null || logger === void 0 || logger.addLog({
|
|
599
695
|
type: 'info',
|
|
600
|
-
title: '
|
|
601
|
-
metadata: {
|
|
696
|
+
title: 'useWalletPass_notifySelectChange 通知外部选择变化',
|
|
697
|
+
metadata: {
|
|
698
|
+
selectedDetails: selectedDetails,
|
|
699
|
+
select: select
|
|
700
|
+
}
|
|
602
701
|
});
|
|
603
702
|
onSelectChange === null || onSelectChange === void 0 || onSelectChange(select);
|
|
604
|
-
fetchUserIdentificationCodes({
|
|
605
|
-
prepare_payments: prepare_payments,
|
|
606
|
-
available: 2,
|
|
607
|
-
filter_prepare_wallet_pass: 1,
|
|
608
|
-
other_exact_codes: getOtherExactCodes()
|
|
609
|
-
});
|
|
610
703
|
});
|
|
611
704
|
var handleSearchIdentificationCode = useMemoizedFn(function (value) {
|
|
612
705
|
return paymentModule.wallet.searchIdentificationCodeAsync({
|
|
@@ -615,13 +708,46 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
615
708
|
});
|
|
616
709
|
});
|
|
617
710
|
|
|
618
|
-
//
|
|
711
|
+
// 处理选中钱包(只更新选中ID,触发前端重新计算)
|
|
619
712
|
var handleSelectWallet = useMemoizedFn(function (value) {
|
|
620
|
-
|
|
713
|
+
setLoading(true);
|
|
714
|
+
|
|
715
|
+
// 1. 找出被取消选中的券ID
|
|
716
|
+
var deselectedIds = selectedVoucherIds.filter(function (id) {
|
|
717
|
+
return !value.includes(id);
|
|
718
|
+
});
|
|
719
|
+
|
|
720
|
+
// 2. 如果有被取消选中的券,检查是否需要重置 edit_current_amount
|
|
721
|
+
if (deselectedIds.length > 0) {
|
|
722
|
+
// 找出这些券中有 edit_current_amount 的
|
|
723
|
+
var needResetIds = deselectedIds.filter(function (id) {
|
|
724
|
+
var voucher = allVouchersForCalculation.find(function (v) {
|
|
725
|
+
return v.id === id;
|
|
726
|
+
});
|
|
727
|
+
return (voucher === null || voucher === void 0 ? void 0 : voucher.edit_current_amount) !== undefined;
|
|
728
|
+
});
|
|
729
|
+
|
|
730
|
+
// 重置这些券的 edit_current_amount
|
|
731
|
+
if (needResetIds.length > 0) {
|
|
732
|
+
updateWalletDataById(needResetIds, {
|
|
733
|
+
edit_current_amount: undefined
|
|
734
|
+
});
|
|
735
|
+
|
|
736
|
+
// 从 confirmedEditAmountIdsRef 中移除这些ID
|
|
737
|
+
confirmedEditAmountIdsRef.current = confirmedEditAmountIdsRef.current.filter(function (id) {
|
|
738
|
+
return !needResetIds.includes(id);
|
|
739
|
+
});
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
// 3. 更新选中的券ID列表(会触发 useMemo 重新计算 selectedWithDetails)
|
|
744
|
+
setSelectedVoucherIds(value);
|
|
745
|
+
|
|
746
|
+
// 4. 同时更新 selectedWallet 用于兼容现有逻辑
|
|
747
|
+
var val = allVouchersForCalculation.filter(function (item) {
|
|
621
748
|
return value.includes(item.id);
|
|
622
749
|
});
|
|
623
750
|
setWalletSelect(val);
|
|
624
|
-
handleFetchUserIdentificationCodes(value);
|
|
625
751
|
});
|
|
626
752
|
|
|
627
753
|
// 获取过期钱包id
|
|
@@ -644,12 +770,15 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
644
770
|
|
|
645
771
|
// 清除所有选中的钱包
|
|
646
772
|
var clearAllSelectedWallet = useMemoizedFn(function () {
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
773
|
+
// 1. 重置所有已编辑过金额的券
|
|
774
|
+
if (confirmedEditAmountIdsRef.current.length > 0) {
|
|
775
|
+
updateWalletDataById(confirmedEditAmountIdsRef.current, {
|
|
776
|
+
edit_current_amount: undefined
|
|
777
|
+
});
|
|
778
|
+
// 清空已编辑的券ID列表
|
|
779
|
+
confirmedEditAmountIdsRef.current = [];
|
|
780
|
+
}
|
|
781
|
+
|
|
653
782
|
// 如果没有选中钱包,则不处理
|
|
654
783
|
if (selectedWalletIds.length === 0 && selectedDiscountList.length === 0) {
|
|
655
784
|
return;
|
|
@@ -672,8 +801,19 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
672
801
|
pisellos === null || pisellos === void 0 || (_pisellos$effects = pisellos.effects) === null || _pisellos$effects === void 0 || _pisellos$effects.emit('shopDiscount:onSelectedDiscountListChange', detail);
|
|
673
802
|
return;
|
|
674
803
|
}
|
|
804
|
+
|
|
805
|
+
// 清空选中的钱包
|
|
675
806
|
setWalletSelect([]);
|
|
676
|
-
|
|
807
|
+
setSelectedVoucherIds([]);
|
|
808
|
+
|
|
809
|
+
// 清空时立即通知外部(不等待 useUpdateEffect)
|
|
810
|
+
logger === null || logger === void 0 || logger.addLog({
|
|
811
|
+
type: 'info',
|
|
812
|
+
title: 'useWalletPass_clearAllSelectedWallet 立即通知外部清空',
|
|
813
|
+
metadata: {}
|
|
814
|
+
});
|
|
815
|
+
onSelectChange === null || onSelectChange === void 0 || onSelectChange([]);
|
|
816
|
+
setLoading(false);
|
|
677
817
|
});
|
|
678
818
|
|
|
679
819
|
// 判断当前选择是否已是最优选择
|
|
@@ -731,9 +871,11 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
731
871
|
return item.unified_available_status;
|
|
732
872
|
});
|
|
733
873
|
setWalletSelect(_select2);
|
|
734
|
-
|
|
874
|
+
// 更新选中的券ID列表(会触发 useMemo 重新计算 selectedWithDetails)
|
|
875
|
+
setSelectedVoucherIds(_select2.map(function (item) {
|
|
735
876
|
return item.id;
|
|
736
|
-
})
|
|
877
|
+
}));
|
|
878
|
+
// useUpdateEffect 会自动在 selectedWithDetails 更新后通知外部
|
|
737
879
|
if (_select2.length) {
|
|
738
880
|
Toast === null || Toast === void 0 || Toast.success(locales.getText('wallet-pass-module-best-combination-selected'));
|
|
739
881
|
}
|
|
@@ -762,11 +904,14 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
762
904
|
if (hasGoodPass && !isBestDiscount) return;
|
|
763
905
|
// 重置为最优选择并显示Toast提示
|
|
764
906
|
setWalletSelect(newWalletRecommendList);
|
|
765
|
-
|
|
907
|
+
// 更新选中的券ID列表(会触发 useMemo 重新计算 selectedWithDetails)
|
|
908
|
+
setSelectedVoucherIds(newWalletRecommendList.map(function (item) {
|
|
766
909
|
return item.id;
|
|
767
|
-
})
|
|
910
|
+
}));
|
|
911
|
+
// useUpdateEffect 会自动在 selectedWithDetails 更新后通知外部
|
|
768
912
|
Toast === null || Toast === void 0 || Toast.success(locales.getText('wallet-pass-module-best-combination-selected'));
|
|
769
913
|
}
|
|
914
|
+
setLoading(false);
|
|
770
915
|
});
|
|
771
916
|
var handleSelectDiscount = useMemoizedFn(function (value, option) {
|
|
772
917
|
var _detail$discountList, _pisellos$effects2;
|
|
@@ -811,6 +956,10 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
811
956
|
var newUserIdentificationCodes = updateArrayItemById(userIdentificationCodes, targetId, updateData);
|
|
812
957
|
setUserIdentificationCodes(newUserIdentificationCodes);
|
|
813
958
|
|
|
959
|
+
// 更新transformList中对应ID的数据(用于前端计算)
|
|
960
|
+
var newTransformList = updateArrayItemById(transformList, targetId, updateData);
|
|
961
|
+
setTransformList(newTransformList);
|
|
962
|
+
|
|
814
963
|
// 更新searchIdentificationCodeList中对应ID的数据
|
|
815
964
|
var newSearchIdentificationCodeList = updateArrayItemById(searchIdentificationCodeList, targetId, updateData);
|
|
816
965
|
setSearchIdentificationCodeList(newSearchIdentificationCodeList);
|
|
@@ -821,6 +970,7 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
821
970
|
return {
|
|
822
971
|
newWalletRecommendList: newWalletRecommendList,
|
|
823
972
|
newUserIdentificationCodes: newUserIdentificationCodes,
|
|
973
|
+
newTransformList: newTransformList,
|
|
824
974
|
newSearchIdentificationCodeList: newSearchIdentificationCodeList,
|
|
825
975
|
newSelectedWallet: newSelectedWallet
|
|
826
976
|
};
|
|
@@ -828,70 +978,42 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
828
978
|
var handleConfirmEditAmount = useMemoizedFn(function (value, id, data) {
|
|
829
979
|
// 如果金额为0,直接触发 handleSelectWallet 把当前id过滤掉
|
|
830
980
|
if (value === 0) {
|
|
831
|
-
var filteredIds =
|
|
981
|
+
var filteredIds = selectedVoucherIds.filter(function (walletId) {
|
|
832
982
|
return walletId !== data.id;
|
|
833
983
|
});
|
|
834
984
|
handleSelectWallet(filteredIds);
|
|
835
985
|
return;
|
|
836
986
|
}
|
|
987
|
+
setLoading(true);
|
|
837
988
|
|
|
838
989
|
// 将执行过的 data.id 添加到跟踪数组中(避免重复)
|
|
839
990
|
if (!confirmedEditAmountIdsRef.current.includes(data.id)) {
|
|
840
991
|
confirmedEditAmountIdsRef.current.push(data.id);
|
|
841
992
|
}
|
|
842
993
|
|
|
843
|
-
//
|
|
994
|
+
// 使用通用函数更新所有相关状态(包括 transformList 和 searchIdentificationCodeList)
|
|
995
|
+
// 这会触发 useMemo 重新计算 selectedWithDetails
|
|
844
996
|
updateWalletDataById(data.id, {
|
|
845
997
|
edit_current_amount: value
|
|
846
998
|
});
|
|
847
999
|
|
|
848
|
-
//
|
|
849
|
-
|
|
850
|
-
clearTimeout(timeoutRef.current);
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
// 设置新的定时器并保存引用
|
|
854
|
-
timeoutRef.current = setTimeout(function () {
|
|
855
|
-
handleFetchUserIdentificationCodes(selectedWalletIds);
|
|
856
|
-
timeoutRef.current = null; // 执行完成后清空引用
|
|
857
|
-
});
|
|
1000
|
+
// useUpdateEffect 会自动在 selectedWithDetails 更新后通知外部
|
|
1001
|
+
// walletPassEvaluator.recalculateVouchers 会识别 edit_current_amount 字段
|
|
858
1002
|
});
|
|
859
1003
|
var handleBeforeEditAmount = useMemoizedFn( /*#__PURE__*/function () {
|
|
860
|
-
var
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
1004
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(value, index, data) {
|
|
1005
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
1006
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
864
1007
|
case 0:
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
code: data.code,
|
|
868
|
-
prepare_payments: paymentModule.wallet.formatWalletPassList2PreparePayments(selectedWalletRef.current.filter(function (item) {
|
|
869
|
-
return item.id !== data.id;
|
|
870
|
-
}))
|
|
871
|
-
}, {
|
|
872
|
-
noCache: true
|
|
873
|
-
});
|
|
874
|
-
case 2:
|
|
875
|
-
result = _context4.sent;
|
|
876
|
-
// 如果result中有数据,使用result中的数据更新状态
|
|
877
|
-
if (result.data && result.data.length > 0) {
|
|
878
|
-
resultItem = result.data.find(function (item) {
|
|
879
|
-
return item.id === data.id;
|
|
880
|
-
});
|
|
881
|
-
if (resultItem) {
|
|
882
|
-
// 使用通用函数更新所有相关状态
|
|
883
|
-
updateWalletDataById(data.id, resultItem);
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
return _context4.abrupt("return", true);
|
|
887
|
-
case 5:
|
|
1008
|
+
return _context3.abrupt("return", true);
|
|
1009
|
+
case 1:
|
|
888
1010
|
case "end":
|
|
889
|
-
return
|
|
1011
|
+
return _context3.stop();
|
|
890
1012
|
}
|
|
891
|
-
},
|
|
1013
|
+
}, _callee3);
|
|
892
1014
|
}));
|
|
893
|
-
return function (_x4, _x5
|
|
894
|
-
return
|
|
1015
|
+
return function (_x3, _x4, _x5) {
|
|
1016
|
+
return _ref3.apply(this, arguments);
|
|
895
1017
|
};
|
|
896
1018
|
}());
|
|
897
1019
|
return {
|
|
@@ -915,7 +1037,6 @@ export var useWalletPass = function useWalletPass(props) {
|
|
|
915
1037
|
selectedDiscountList: selectedDiscountList,
|
|
916
1038
|
handleSelectDiscount: handleSelectDiscount,
|
|
917
1039
|
customerName: customerName,
|
|
918
|
-
fetchWalletRecommendList: fetchWalletRecommendList,
|
|
919
1040
|
fetchUserIdentificationCodes: fetchUserIdentificationCodes,
|
|
920
1041
|
getCachedWalletRecommendList: getCachedWalletRecommendList,
|
|
921
1042
|
getCachedUserIdentificationCodes: getCachedUserIdentificationCodes,
|