@pisell/private-materials 6.3.112 → 6.3.113

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.
Files changed (63) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/index.js +1 -1
  5. package/build/lowcode/meta.js +1 -1
  6. package/build/lowcode/preview.js +4 -4
  7. package/build/lowcode/render/default/view.js +4 -4
  8. package/build/lowcode/view.js +4 -4
  9. package/es/components/booking/forms/sendModal/useSendModal.d.ts +0 -1
  10. package/es/components/booking/info/clientVariant/hooks/useIsLowSpeedNetwork.d.ts +0 -1
  11. package/es/components/eftpos/hooks.d.ts +0 -1
  12. package/es/components/eftposPay/tyro/hooks.d.ts +0 -1
  13. package/es/components/eventBooking/components/ErrorTip/index.d.ts +0 -1
  14. package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateStatus/index.d.ts +0 -1
  15. package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateWeek/WeekItem/index.d.ts +0 -1
  16. package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateWeek/index.d.ts +0 -1
  17. package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/Item/DayItem/index.d.ts +0 -1
  18. package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/Item/index.d.ts +0 -1
  19. package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/Status/index.d.ts +0 -1
  20. package/es/components/pay/toC/PaymentMethods/StripePay/Stripe/StripeSDK/index.d.ts +0 -1
  21. package/es/components/pay/toC/PaymentMethods/WalletPass/index.d.ts +5 -0
  22. package/es/components/pay/toC/PaymentMethods/WalletPass/index.js +165 -142
  23. package/es/components/pay/toC/PaymentMethods/WalletPass/serve.d.ts +6 -0
  24. package/es/components/pay/toC/PaymentMethods/WalletPass/utils.js +3 -3
  25. package/es/components/pay/toC/WalletPassBlock/index.js +3 -1
  26. package/es/components/pay/toC/index.js +65 -31
  27. package/es/components/pay/toC/model.d.ts +1 -0
  28. package/es/components/pay/toC/serve.d.ts +18 -0
  29. package/es/components/pay/toC/serve.js +42 -15
  30. package/es/components/pay/toC/utils.d.ts +2 -2
  31. package/es/components/pay/toC/utils.js +4 -0
  32. package/es/components/shoppingCart/components/Empty/index.d.ts +0 -1
  33. package/es/hooks/usePaymentLogger.d.ts +0 -1
  34. package/es/plus/pisellSalesManagement/config/booking.d.ts +0 -1
  35. package/es/plus/selectHolder/components/ErrorTip/index.d.ts +0 -1
  36. package/lib/components/booking/forms/sendModal/useSendModal.d.ts +0 -1
  37. package/lib/components/booking/info/clientVariant/hooks/useIsLowSpeedNetwork.d.ts +0 -1
  38. package/lib/components/eftpos/hooks.d.ts +0 -1
  39. package/lib/components/eftposPay/tyro/hooks.d.ts +0 -1
  40. package/lib/components/eventBooking/components/ErrorTip/index.d.ts +0 -1
  41. package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateStatus/index.d.ts +0 -1
  42. package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateWeek/WeekItem/index.d.ts +0 -1
  43. package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateWeek/index.d.ts +0 -1
  44. package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/Item/DayItem/index.d.ts +0 -1
  45. package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/Item/index.d.ts +0 -1
  46. package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/Status/index.d.ts +0 -1
  47. package/lib/components/pay/toC/PaymentMethods/StripePay/Stripe/StripeSDK/index.d.ts +0 -1
  48. package/lib/components/pay/toC/PaymentMethods/WalletPass/index.d.ts +5 -0
  49. package/lib/components/pay/toC/PaymentMethods/WalletPass/index.js +90 -100
  50. package/lib/components/pay/toC/PaymentMethods/WalletPass/serve.d.ts +6 -0
  51. package/lib/components/pay/toC/PaymentMethods/WalletPass/utils.js +2 -2
  52. package/lib/components/pay/toC/WalletPassBlock/index.js +3 -1
  53. package/lib/components/pay/toC/index.js +52 -19
  54. package/lib/components/pay/toC/model.d.ts +1 -0
  55. package/lib/components/pay/toC/serve.d.ts +18 -0
  56. package/lib/components/pay/toC/serve.js +6 -0
  57. package/lib/components/pay/toC/utils.d.ts +2 -2
  58. package/lib/components/pay/toC/utils.js +6 -2
  59. package/lib/components/shoppingCart/components/Empty/index.d.ts +0 -1
  60. package/lib/hooks/usePaymentLogger.d.ts +0 -1
  61. package/lib/plus/pisellSalesManagement/config/booking.d.ts +0 -1
  62. package/lib/plus/selectHolder/components/ErrorTip/index.d.ts +0 -1
  63. package/package.json +3 -3
@@ -47,10 +47,14 @@ var import_index = require("./index.less");
47
47
  var import_useEngineContext = __toESM(require("../../../../../hooks/useEngineContext"));
48
48
  var { Amount } = import_materials.PisellText;
49
49
  var WalletPass = (0, import_react.forwardRef)((props, ref) => {
50
- var _a, _b, _c, _d, _e;
51
- const { onWalletPassChange, walletPass, walletSetting } = props;
50
+ var _a, _b, _c, _d, _e, _f;
51
+ const { onWalletPassChange, walletPass, walletSetting, orderDetail, total_amount } = props;
52
52
  const context = (0, import_useEngineContext.default)();
53
- const isWalletCode = (_d = (_c = (_b = (_a = context == null ? void 0 : context.appHelper) == null ? void 0 : _a.utils) == null ? void 0 : _b.businessUtils) == null ? void 0 : _c.getAppByModal) == null ? void 0 : _d.call(_c, "wallet");
53
+ const { walletPassEvaluator } = ((_a = context == null ? void 0 : context.appHelper) == null ? void 0 : _a.utils) || {};
54
+ const { detail } = orderDetail;
55
+ const isWalletCode = (_e = (_d = (_c = (_b = context == null ? void 0 : context.appHelper) == null ? void 0 : _b.utils) == null ? void 0 : _c.businessUtils) == null ? void 0 : _d.getAppByModal) == null ? void 0 : _e.call(_d, "wallet");
56
+ const { cards: recommended, transformList, noApplicableVoucher } = walletPass;
57
+ const [selectedVoucherIds, setSelectedVoucherIds] = (0, import_react.useState)([]);
54
58
  const [currentWalletPass, setCurrentWalletPass] = (0, import_react.useState)(walletPass);
55
59
  const [loading, setLoading] = (0, import_react.useState)(false);
56
60
  const [open, setOpen] = (0, import_react.useState)(false);
@@ -63,78 +67,69 @@ var WalletPass = (0, import_react.forwardRef)((props, ref) => {
63
67
  details: []
64
68
  });
65
69
  const isAutoSelect = (0, import_react.useRef)(false);
66
- const listRef = (0, import_react.useRef)(null);
67
70
  const searchValRef = (0, import_react.useRef)(null);
68
71
  const pinVerifyModalRef = (0, import_react.useRef)(null);
69
- const { cards: walletPassSelectCards, amount } = currentWalletPass || {};
70
- const [currentCustomerWalletPass, otherCustomerWalletPass] = (0, import_react.useMemo)(() => {
71
- const current = [];
72
- const other = [];
73
- (walletPassSelectCards || []).forEach((item) => {
74
- if (item.customer_id === (order == null ? void 0 : order.customer_id)) {
75
- current.push(item);
72
+ const allVouchersForCalculation = (0, import_react.useMemo)(() => {
73
+ return [...transformList || [], ...addList || []];
74
+ }, [transformList, addList]);
75
+ const selectedVouchers = (0, import_react.useMemo)(() => {
76
+ return selectedVoucherIds.map((id) => allVouchersForCalculation.find((v) => v.id === id)).filter(Boolean);
77
+ }, [selectedVoucherIds, allVouchersForCalculation]);
78
+ const { displayVouchers, displayOtherVouchers, selectedWithDetails, totalDeduction } = (0, import_react.useMemo)(() => {
79
+ if (!walletPassEvaluator || !allVouchersForCalculation.length || !(order == null ? void 0 : order.total_amount)) {
80
+ return {
81
+ displayVouchers: [...transformList || [], ...noApplicableVoucher || []],
82
+ displayOtherVouchers: addList || [],
83
+ selectedWithDetails: [],
84
+ totalDeduction: 0
85
+ };
86
+ }
87
+ if (selectedVouchers.length === 0) {
88
+ return {
89
+ displayVouchers: [...transformList || [], ...noApplicableVoucher || []],
90
+ displayOtherVouchers: addList || [],
91
+ selectedWithDetails: [],
92
+ totalDeduction: 0
93
+ };
94
+ }
95
+ const result = walletPassEvaluator.recalculateVouchers(
96
+ allVouchersForCalculation,
97
+ selectedVouchers,
98
+ order.total_amount,
99
+ detail || []
100
+ );
101
+ const currentCustomerVouchers = [];
102
+ const otherCustomerVouchers = [];
103
+ result.allWithUpdatedStatus.forEach((voucher) => {
104
+ if (voucher.customer_id === (order == null ? void 0 : order.customer_id)) {
105
+ currentCustomerVouchers.push(voucher);
76
106
  } else {
77
- other.push(item);
107
+ otherCustomerVouchers.push(voucher);
78
108
  }
79
109
  });
80
- return [current, other];
81
- }, [walletPassSelectCards, order == null ? void 0 : order.customer_id]);
110
+ return {
111
+ displayVouchers: [...currentCustomerVouchers, ...noApplicableVoucher || []],
112
+ displayOtherVouchers: otherCustomerVouchers,
113
+ selectedWithDetails: result.selectedWithDetails,
114
+ totalDeduction: result.selectedWithDetails.reduce((sum, v) => sum + (v.actualDeduction || 0), 0)
115
+ };
116
+ }, [selectedVouchers, allVouchersForCalculation, transformList, addList, noApplicableVoucher, order == null ? void 0 : order.total_amount, order == null ? void 0 : order.customer_id, detail, walletPassEvaluator]);
82
117
  const prepare_payments = (0, import_react.useMemo)(() => {
83
118
  return (0, import_utils3.formatWalletPassList2PreparePayments)(
84
119
  (0, import_utils.uniqueByKey)(
85
- (walletPassSelectCards || []).concat(searchSelectData.details),
120
+ (selectedWithDetails || []).concat(searchSelectData.details),
86
121
  "id"
87
122
  )
88
123
  );
89
- }, [walletPassSelectCards, searchSelectData]);
124
+ }, [selectedWithDetails, searchSelectData]);
90
125
  const selectValue = (0, import_react.useMemo)(() => {
91
- return (walletPassSelectCards == null ? void 0 : walletPassSelectCards.map((item) => item.id)) || [];
92
- }, [walletPassSelectCards]);
93
- const otherCustomerWalletPassList = (0, import_react.useMemo)(() => {
94
- return (0, import_utils2.formatMachineCodeServer2CardList)(addList, selectValue);
95
- }, [addList, selectValue]);
96
- const other_exact_codes = (0, import_react.useMemo)(() => {
97
- const codes = [];
98
- addList.forEach((item) => {
99
- if (!selectValue.includes(item.id)) {
100
- codes.push(item.code);
101
- }
102
- });
103
- return codes;
104
- }, [addList, selectValue]);
105
- const refreshList = (0, import_ahooks.useMemoizedFn)(() => {
106
- var _a2, _b2;
107
- if ((order == null ? void 0 : order.order_id) && (order == null ? void 0 : order.customer_id)) {
108
- (_b2 = listRef.current) == null ? void 0 : _b2.init(
109
- {
110
- order_id: order.order_id,
111
- available: 2,
112
- prepare_payments,
113
- filter_prepare_wallet_pass: 1,
114
- sale_channel: ((_a2 = order._order) == null ? void 0 : _a2.sale_channel) || "online-store",
115
- other_exact_codes
116
- },
117
- // 已选择的卡片接口中不会返回,所以追加进入列表
118
- (val) => {
119
- const idMap = val.reduce((pre, cur) => {
120
- return {
121
- ...pre,
122
- [cur.id]: cur
123
- };
124
- }, {});
125
- setAddList((prevState) => {
126
- return prevState.map((item) => {
127
- if (idMap[item.id]) {
128
- return idMap[item.id];
129
- }
130
- return item;
131
- });
132
- });
133
- return [...currentCustomerWalletPass || [], ...val];
134
- }
135
- );
126
+ return selectedVoucherIds;
127
+ }, [selectedVoucherIds]);
128
+ (0, import_react.useEffect)(() => {
129
+ if (recommended && recommended.length > 0) {
130
+ setSelectedVoucherIds(recommended.map((v) => v.id));
136
131
  }
137
- });
132
+ }, [recommended]);
138
133
  (0, import_react.useEffect)(() => {
139
134
  if ((order == null ? void 0 : order.order_id) && searchValRef.current) {
140
135
  searchList(searchValRef.current, true);
@@ -145,16 +140,16 @@ var WalletPass = (0, import_react.forwardRef)((props, ref) => {
145
140
  setOrder(res);
146
141
  setOpen(true);
147
142
  setCurrentWalletPass(walletPass);
148
- setTimeout(() => {
149
- refreshList();
150
- });
143
+ if (recommended && recommended.length > 0) {
144
+ setSelectedVoucherIds(recommended.map((v) => v.id));
145
+ }
151
146
  };
152
147
  const searchList = async ({ code, customer_pin_key }, isSelectChange) => {
153
148
  var _a2;
154
149
  if (!(order == null ? void 0 : order.order_id)) return;
155
150
  setLoading(true);
156
151
  try {
157
- const result = await (0, import_serve.searchMachineCodeList)({
152
+ const baseResult = await (0, import_serve.searchMachineCodeList)({
158
153
  order_id: order.order_id,
159
154
  code,
160
155
  prepare_payments,
@@ -162,7 +157,7 @@ var WalletPass = (0, import_react.forwardRef)((props, ref) => {
162
157
  sale_channel: ((_a2 = order._order) == null ? void 0 : _a2.sale_channel) || "online-store",
163
158
  customer_pin_key
164
159
  });
165
- if (!result) {
160
+ if (!baseResult) {
166
161
  if (!isSelectChange) {
167
162
  (0, import_materials.PisellToast)({
168
163
  content: import_utils.locales.getText("tocPay.text.walletSearchEmpty")
@@ -173,6 +168,11 @@ var WalletPass = (0, import_react.forwardRef)((props, ref) => {
173
168
  if (isSelectChange && !searchValRef.current) {
174
169
  return;
175
170
  }
171
+ let result = walletPassEvaluator.searchVoucherFormat({
172
+ vouchers: baseResult,
173
+ orderTotalAmount: order.total_amount,
174
+ products: detail
175
+ });
176
176
  setSearchData(
177
177
  (0, import_utils2.formatMachineCodeServer2CardList)(
178
178
  [...searchSelectData.details, ...result],
@@ -235,23 +235,23 @@ var WalletPass = (0, import_react.forwardRef)((props, ref) => {
235
235
  });
236
236
  };
237
237
  const handleSelectOk = () => {
238
- changeWalletPass(
239
- (0, import_utils.uniqueByKey)(
240
- [
241
- ...walletPassSelectCards || [],
242
- ...searchSelectData.details
243
- ],
244
- "id"
245
- )
238
+ const otherCustomerSearchVouchers = searchSelectData.details.filter(
239
+ (item) => item.customer_id !== (order == null ? void 0 : order.customer_id)
246
240
  );
247
241
  setAddList((prevState) => {
248
242
  return (0, import_utils.uniqueByKey)(
249
- [...prevState, ...searchSelectData.details],
243
+ [...prevState, ...otherCustomerSearchVouchers],
250
244
  "id"
251
- ).filter(
252
- (item) => !(order == null ? void 0 : order.customer_id) || item.customer_id !== (order == null ? void 0 : order.customer_id)
253
245
  );
254
246
  });
247
+ const newSelectedIds = (0, import_utils.uniqueByKey)(
248
+ [
249
+ ...selectedWithDetails || [],
250
+ ...searchSelectData.details
251
+ ],
252
+ "id"
253
+ ).map((v) => v.id);
254
+ setSelectedVoucherIds(newSelectedIds);
255
255
  handleSearchModalClose();
256
256
  };
257
257
  const handleAddChange = (0, import_ahooks.useMemoizedFn)(
@@ -263,26 +263,15 @@ var WalletPass = (0, import_react.forwardRef)((props, ref) => {
263
263
  });
264
264
  }
265
265
  );
266
- const changeWalletPass = (cards) => {
267
- setCurrentWalletPass == null ? void 0 : setCurrentWalletPass({
268
- cards,
269
- amount: (0, import_utils3.calcWalletPassListAmount)(cards)
270
- });
271
- setTimeout(() => {
272
- refreshList();
273
- });
274
- };
275
266
  const handleSelectChange = (val, details, type) => {
276
- let cards = details.map((item) => item.originData);
277
- if (type === "other") {
278
- cards = currentCustomerWalletPass.concat(cards);
279
- } else if (type === "current") {
280
- cards = otherCustomerWalletPass.concat(cards);
281
- }
282
- changeWalletPass(cards);
267
+ setSelectedVoucherIds(val);
283
268
  };
284
269
  const handleRedeem = () => {
285
- onWalletPassChange == null ? void 0 : onWalletPassChange(currentWalletPass);
270
+ onWalletPassChange == null ? void 0 : onWalletPassChange({
271
+ ...currentWalletPass,
272
+ cards: selectedWithDetails,
273
+ amount: totalDeduction
274
+ });
286
275
  setOpen(false);
287
276
  };
288
277
  const handleWalletClose = () => {
@@ -307,16 +296,16 @@ var WalletPass = (0, import_react.forwardRef)((props, ref) => {
307
296
  onCancel: () => handleWalletClose(),
308
297
  cancelVisible: false,
309
298
  destroyOnClose: true,
310
- okText: /* @__PURE__ */ import_react.default.createElement("div", null, import_utils.locales.getText("tocPay.text.redeem"), " ", /* @__PURE__ */ import_react.default.createElement(Amount, { value: amount })),
299
+ okText: /* @__PURE__ */ import_react.default.createElement("div", null, import_utils.locales.getText("tocPay.text.redeem"), " ", /* @__PURE__ */ import_react.default.createElement(Amount, { value: totalDeduction })),
311
300
  onOk: handleRedeem
312
301
  },
313
302
  /* @__PURE__ */ import_react.default.createElement("div", { className: "", style: { marginTop: 24 } }, /* @__PURE__ */ import_react.default.createElement(import_MultiModeSearch.default, { onChange: handleSearch }), /* @__PURE__ */ import_react.default.createElement("div", { className: "wallet-pass-modal-multi-selection-available" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "wallet-pass-modal-multi-selection-available-title" }, /* @__PURE__ */ import_react.default.createElement(import_icons.InfoCircleOutlined, { className: "wallet-pass-modal-multi-selection-available-title-icon" }), import_utils.locales.getText("tocPay.text.multipleSelectionAvailable")), /* @__PURE__ */ import_react.default.createElement("div", { className: "wallet-pass-modal-multi-selection-available-desc" }, import_utils.locales.getText(
314
303
  "tocPay.text.youCanSelectMultipleWalletPassesToCombineForPayment"
315
- )(walletSetting.name))), otherCustomerWalletPassList.length > 0 && /* @__PURE__ */ import_react.default.createElement(
304
+ )(walletSetting.name))), displayOtherVouchers.length > 0 && /* @__PURE__ */ import_react.default.createElement(
316
305
  import_List.default,
317
306
  {
318
307
  walletSetting,
319
- data: otherCustomerWalletPassList,
308
+ data: (0, import_utils2.formatMachineCodeServer2CardList)(displayOtherVouchers, selectValue),
320
309
  title: import_utils.locales.getText("tocPay.text.couponCodesAdded"),
321
310
  onChange: handleOtherChange,
322
311
  value: selectValue,
@@ -329,9 +318,10 @@ var WalletPass = (0, import_react.forwardRef)((props, ref) => {
329
318
  walletSetting,
330
319
  title: walletSetting.name,
331
320
  onChange: handleCurrentChange,
332
- ref: listRef,
321
+ data: (0, import_utils2.formatMachineCodeServer2CardList)(displayVouchers, selectValue),
333
322
  value: selectValue,
334
323
  onLoadingChange: setLoading,
324
+ loading,
335
325
  customer_id: order == null ? void 0 : order.customer_id
336
326
  }
337
327
  ))
@@ -347,7 +337,7 @@ var WalletPass = (0, import_react.forwardRef)((props, ref) => {
347
337
  okText: import_utils.locales.getText("tocPay.text.select"),
348
338
  onOk: handleSelectOk,
349
339
  okButtonProps: {
350
- disabled: ((_e = searchSelectData.ids) == null ? void 0 : _e.length) === 0
340
+ disabled: ((_f = searchSelectData.ids) == null ? void 0 : _f.length) === 0
351
341
  }
352
342
  },
353
343
  /* @__PURE__ */ import_react.default.createElement("div", { className: "", style: { marginTop: 24 } }, /* @__PURE__ */ import_react.default.createElement(
@@ -56,6 +56,12 @@ export declare type WalletPassDataType = {
56
56
  metadata?: {
57
57
  validity_type: string;
58
58
  };
59
+ /** 前端计算 可用最大金额 */
60
+ _available_max_amount?: number;
61
+ /** 前端计算 统一可用状态 */
62
+ _unified_available_status?: 0 | 1;
63
+ /** 前端计算 禁用原因 */
64
+ reason?: string;
59
65
  };
60
66
  declare type Shop = {
61
67
  id: number;
@@ -53,8 +53,8 @@ var formatMachineCodeServer2CardList = (data, selectId = []) => {
53
53
  showDetail: false,
54
54
  showQrCode: false,
55
55
  code: item.code,
56
- disabled: !item.unified_available_status,
57
- disabledReason: (_b = item.unified_messages) == null ? void 0 : _b.title,
56
+ disabled: (0, import_utils.isNumber)(item._unified_available_status) ? !item._unified_available_status : !item.unified_available_status,
57
+ disabledReason: (0, import_utils.isNumber)(item._unified_available_status) ? item.reason : (_b = item.unified_messages) == null ? void 0 : _b.title,
58
58
  cover: (_c = item.product) == null ? void 0 : _c.cover,
59
59
  qrCode: item.code,
60
60
  validDate: voucherTime(item),
@@ -166,7 +166,9 @@ var WalletPassBlock = (props, ref) => {
166
166
  ref: walletPassRef,
167
167
  walletSetting,
168
168
  onWalletPassChange,
169
- walletPass: payGroup == null ? void 0 : payGroup.walletPass
169
+ walletPass: payGroup == null ? void 0 : payGroup.walletPass,
170
+ orderDetail: payGroup == null ? void 0 : payGroup.orderDetail,
171
+ total_amount: payGroup == null ? void 0 : payGroup.total_amount
170
172
  }
171
173
  ), /* @__PURE__ */ import_react.default.createElement(
172
174
  import_WalletAvailable.default,
@@ -49,6 +49,7 @@ var import_usePaymentLogger = __toESM(require("../../../hooks/usePaymentLogger")
49
49
  var import_utils2 = require("../../../utils");
50
50
  var import_payGroup = require("./payGroup");
51
51
  var import_locales = __toESM(require("./locales"));
52
+ var import_serve2 = require("./PaymentMethods/WalletPass/serve");
52
53
  var import_utils3 = require("./utils");
53
54
  var import_status = require("./status");
54
55
  var import_index = require("./index.less");
@@ -169,7 +170,7 @@ var ToCPay = (props, ref) => {
169
170
  }
170
171
  };
171
172
  const _getPaymentsAndWalletPass = async (order) => {
172
- var _a2, _b2;
173
+ var _a2, _b2, _c2;
173
174
  paymentLogger.addLog({
174
175
  key: "获取支付列表开始",
175
176
  value: {
@@ -177,11 +178,22 @@ var ToCPay = (props, ref) => {
177
178
  }
178
179
  });
179
180
  try {
180
- const data = await (0, import_serve.getPaymentsAndWalletPass)({
181
- order_id: order.order_id,
182
- total_amount: order.amount,
183
- sale_channel: order.sale_channel || "online-store"
184
- });
181
+ const [data, allList, orderBasicDetail] = await Promise.all([
182
+ (0, import_serve.getPaymentsAndWalletPass)({
183
+ order_id: order.order_id,
184
+ total_amount: order.amount,
185
+ sale_channel: order.sale_channel || "online-store"
186
+ }),
187
+ (0, import_serve2.getMachineCodeList)({
188
+ order_id: order.order_id,
189
+ available: 2,
190
+ prepare_payments: [],
191
+ filter_prepare_wallet_pass: 1,
192
+ sale_channel: ((_a2 = order._order) == null ? void 0 : _a2.sale_channel) || "online-store",
193
+ other_exact_codes: []
194
+ }),
195
+ (0, import_serve.getOrderBasicDetail)(order.order_id)
196
+ ]);
185
197
  const {
186
198
  remain_amount = 0,
187
199
  wallet_pass_recommend_list,
@@ -189,39 +201,60 @@ var ToCPay = (props, ref) => {
189
201
  payment_list,
190
202
  walletPass
191
203
  } = data || {};
204
+ const products = (orderBasicDetail.detail || []).map((item) => {
205
+ var _a3;
206
+ return {
207
+ ...item,
208
+ is_price_include_tax: orderBasicDetail.is_price_include_tax,
209
+ product_bundle: (_a3 = item.product_bundle || []) == null ? void 0 : _a3.map((bundle) => {
210
+ return {
211
+ ...bundle,
212
+ is_price_include_tax: orderBasicDetail.is_price_include_tax
213
+ };
214
+ })
215
+ };
216
+ });
217
+ const res = utils.walletPassEvaluator.getRecommendedVouchers({
218
+ orderTotalAmount: Math.min(orderBasicDetail.product_unpaid_total_pay_amount, order.amount),
219
+ products,
220
+ vouchers: allList || []
221
+ });
222
+ const { recommended, transformList, noApplicableVoucher, recommendedAmount } = res;
192
223
  paymentLogger.addLog({
193
224
  key: "支付数据获取",
194
225
  value: ""
195
226
  });
196
- const withCustomerIdList = (wallet_pass_recommend_list || []).map(
197
- (item) => {
198
- return {
199
- ...item,
200
- customer_id: customer_id || item.customer_id
201
- };
202
- }
203
- );
227
+ const waitAmount2 = new import_decimal.Decimal((order == null ? void 0 : order.amount) || 0).minus(new import_decimal.Decimal(recommendedAmount)).toNumber();
204
228
  dispatch({
205
229
  type: "setPayGroup",
206
230
  payload: {
207
231
  // ...state.payGroup,
208
232
  order_id: order == null ? void 0 : order.order_id,
209
233
  // total_amount: order?.amount,
234
+ orderDetail: orderBasicDetail,
210
235
  // 原订单信息
211
236
  _order: order,
212
237
  payment_group_id: order == null ? void 0 : order.payment_group_id,
213
238
  // 支付方式没有walletPass时walletPass设置null
214
239
  walletPass: walletPass ? {
215
- ...(_a2 = state.payGroup) == null ? void 0 : _a2.walletPass,
240
+ ...(_b2 = state.payGroup) == null ? void 0 : _b2.walletPass,
216
241
  ...walletPass,
217
- amount: wallet_pass_amount,
218
- cards: withCustomerIdList
242
+ // 推荐钱包
243
+ cards: recommended,
244
+ // 推荐金额
245
+ amount: recommendedAmount,
246
+ // 不可用钱包
247
+ noApplicableVoucher,
248
+ // 转换列表
249
+ transformList
250
+ // amount: wallet_pass_amount,
251
+ // cards: wallet_pass_recommend_list,
219
252
  } : null,
220
253
  total_amount: order == null ? void 0 : order.amount,
221
- wait_amount: remain_amount
254
+ wait_amount: Math.max(0, waitAmount2)
222
255
  }
223
256
  });
224
- await ((_b2 = paymentListRef.current) == null ? void 0 : _b2.init(payment_list, remain_amount || 0));
257
+ await ((_c2 = paymentListRef.current) == null ? void 0 : _c2.init(payment_list, remain_amount || 0));
225
258
  setTimeout(() => {
226
259
  setLoading(false);
227
260
  }, 100);
@@ -29,6 +29,7 @@ export interface PayGroup {
29
29
  pay_number?: string;
30
30
  _order: any;
31
31
  front_order_uuid?: string;
32
+ orderDetail: any;
32
33
  }
33
34
  export declare const Provider: (ComponentUi: any) => any, Context: import("react").Context<{
34
35
  state: FormState;
@@ -62,6 +62,23 @@ export declare const getWalletNameAndPopupStatus: (values: {
62
62
  * @description: 获取支付结果
63
63
  */
64
64
  export declare const getPaymentResult: (values: any) => Promise<any>;
65
+ declare type OrderBasicDetail = {
66
+ id: number;
67
+ status: string;
68
+ payment_status: string;
69
+ order_time: string;
70
+ detail: any[];
71
+ product_unpaid_total_pay_amount: number;
72
+ product_paid_total_pay_amount: number;
73
+ is_price_include_tax: 1 | 0;
74
+ };
75
+ /**
76
+ * @title: 查询订单基础信息和订单商品信息
77
+ * @description: 查询订单基础信息和订单商品信息
78
+ * @param {string} order_id
79
+ * @return {*}
80
+ */
81
+ export declare const getOrderBasicDetail: (order_id: string) => Promise<OrderBasicDetail>;
65
82
  /**
66
83
  * @title: 检测订单是否有正在处理中的交易
67
84
  * @param {object} values - { order_id: string }
@@ -72,3 +89,4 @@ export declare const checkPendingPayment: (values: {
72
89
  }) => Promise<{
73
90
  has_pending: boolean;
74
91
  }>;
92
+ export {};
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  var serve_exports = {};
21
21
  __export(serve_exports, {
22
22
  checkPendingPayment: () => checkPendingPayment,
23
+ getOrderBasicDetail: () => getOrderBasicDetail,
23
24
  getPaymentInit: () => getPaymentInit,
24
25
  getPaymentList: () => getPaymentList,
25
26
  getPaymentResult: () => getPaymentResult,
@@ -78,6 +79,10 @@ var getWalletNameAndPopupStatus = async (values) => {
78
79
  return data;
79
80
  };
80
81
  var getPaymentResult = (values) => import_utils.request.getRequest().get(`/h5/pay/order/payment/result`, values);
82
+ var getOrderBasicDetail = async (order_id) => {
83
+ const { data } = await import_utils.request.getRequest().get(`/h5/order/order/${order_id}/basic-detail`, {});
84
+ return data;
85
+ };
81
86
  var checkPendingPayment = async (values) => {
82
87
  var _a;
83
88
  const { data } = await import_utils.request.getRequest().post(`/h5/pay/payment/check`, values);
@@ -89,6 +94,7 @@ var checkPendingPayment = async (values) => {
89
94
  // Annotate the CommonJS export names for ESM import in node:
90
95
  0 && (module.exports = {
91
96
  checkPendingPayment,
97
+ getOrderBasicDetail,
92
98
  getPaymentInit,
93
99
  getPaymentList,
94
100
  getPaymentResult,
@@ -22,7 +22,7 @@ export declare const formatWalletPassParams: (payGroup: PayGroup) => {
22
22
  order_id: string;
23
23
  payment_group_id: number;
24
24
  payments: {
25
- amount: string;
25
+ amount: string | number;
26
26
  wallet_pass_use_value: any;
27
27
  voucher_id: any;
28
28
  tag: any;
@@ -48,7 +48,7 @@ export declare const isFranchiseeShop: (path?: any, history?: any) => any;
48
48
  */
49
49
  export declare const getFranchiseeShopId: (path?: any, history?: any) => number;
50
50
  export declare const formatFranchiseeRoute: (url: string, history?: any) => string;
51
- export declare const getAvailableMaxAmount: (data: WalletPassDataType) => string;
51
+ export declare const getAvailableMaxAmount: (data: WalletPassDataType) => string | number;
52
52
  export declare const clientPayment: (params: {
53
53
  order_id: number;
54
54
  type: "aliPay" | "wxPay" | 'google_pay';
@@ -43,8 +43,9 @@ __export(utils_exports, {
43
43
  module.exports = __toCommonJS(utils_exports);
44
44
  var import_decimal = require("decimal.js");
45
45
  var import_status = require("./status");
46
- var import_dayjs = __toESM(require("dayjs"));
47
46
  var import_utils = require("@pisell/utils");
47
+ var import_dayjs = __toESM(require("dayjs"));
48
+ var import_utils2 = require("@pisell/utils");
48
49
  var calcWalletPassListAmount = (list) => {
49
50
  return list.reduce((pre, cur) => pre.add(new import_decimal.Decimal(String(getAvailableMaxAmount(cur) || 0))), new import_decimal.Decimal("0")).toNumber();
50
51
  };
@@ -97,6 +98,9 @@ var formatFranchiseeRoute = (url, history) => {
97
98
  return url;
98
99
  };
99
100
  var getAvailableMaxAmount = (data) => {
101
+ if ((0, import_utils.isNumber)(data._available_max_amount)) {
102
+ return data._available_max_amount;
103
+ }
100
104
  return data.tag !== "point_card" ? data.available_max_amount : data == null ? void 0 : data.recommended_usage_amount;
101
105
  };
102
106
  var clientPayment = (params) => {
@@ -113,7 +117,7 @@ var clientPayment = (params) => {
113
117
  });
114
118
  };
115
119
  var getUniqueIdempotencyToken = () => {
116
- return `${(0, import_dayjs.default)().format("YYYYMMDDHHmmssSSS")}-${(0, import_utils.getUniqueId)()}`;
120
+ return `${(0, import_dayjs.default)().format("YYYYMMDDHHmmssSSS")}-${(0, import_utils2.getUniqueId)()}`;
117
121
  };
118
122
  // Annotate the CommonJS export names for ESM import in node:
119
123
  0 && (module.exports = {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import './index.less';
3
2
  declare const Empty: (props: any) => import("react").JSX.Element;
4
3
  export default Empty;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  interface LogData {
3
2
  key: string;
4
3
  value: any;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const getBookingStatusMap: () => Record<string, string>;
3
2
  export declare const BOOKING_STATUS_COLOR_MAP: Record<string, string>;
4
3
  export declare const getBookingPlatformMap: () => Record<string, string>;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import './index.less';
3
2
  declare const ErrorTip: ({ text }: any) => import("react").JSX.Element;
4
3
  export default ErrorTip;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/private-materials",
3
- "version": "6.3.112",
3
+ "version": "6.3.113",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -77,9 +77,9 @@
77
77
  "react-resizable": "^3.0.5",
78
78
  "styled-components": "^6.0.0-rc.3",
79
79
  "@pisell/utils": "3.0.5",
80
- "@pisell/date-picker": "3.0.8",
80
+ "@pisell/materials": "6.3.29",
81
81
  "@pisell/icon": "0.0.11",
82
- "@pisell/materials": "6.3.27"
82
+ "@pisell/date-picker": "3.0.8"
83
83
  },
84
84
  "peerDependencies": {
85
85
  "react": "^18.0.0",