@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.
Files changed (71) 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/meta.js +1 -1
  5. package/build/lowcode/render/default/view.css +1 -1
  6. package/build/lowcode/render/default/view.js +1 -1
  7. package/build/lowcode/view.css +1 -1
  8. package/build/lowcode/view.js +1 -1
  9. package/es/components/appointmentBooking/components/Voucher/index.js +22 -7
  10. package/es/components/booking/addons/index.js +3 -2
  11. package/es/components/booking/components/footer/amount.js +2 -2
  12. package/es/components/booking/components/footer/index.js +7 -0
  13. package/es/components/booking/components/footer/utils.d.ts +1 -1
  14. package/es/components/booking/components/footer/utils.js +5 -3
  15. package/es/components/booking/components/voucher/index.js +6 -0
  16. package/es/components/booking/components/voucher/index.less +4 -1
  17. package/es/components/booking/components/voucherModal/index.less +1 -0
  18. package/es/components/booking/info2/service/editService/index.js +33 -2
  19. package/es/components/checkout/components/WalletPassModule/index.js +1 -0
  20. package/es/components/checkout/components/WalletPassModule/utils.js +14 -3
  21. package/es/components/checkout/hooks/useWalletPass.d.ts +1 -1
  22. package/es/components/checkout/hooks/useWalletPass.js +310 -189
  23. package/es/components/pay/toC/PaymentMethods/WalletPass/index.d.ts +5 -0
  24. package/es/components/pay/toC/PaymentMethods/WalletPass/index.js +166 -145
  25. package/es/components/pay/toC/PaymentMethods/WalletPass/serve.d.ts +6 -0
  26. package/es/components/pay/toC/PaymentMethods/WalletPass/utils.js +3 -3
  27. package/es/components/pay/toC/WalletPassBlock/index.js +3 -1
  28. package/es/components/pay/toC/index.js +66 -27
  29. package/es/components/pay/toC/model.d.ts +1 -0
  30. package/es/components/pay/toC/serve.d.ts +18 -0
  31. package/es/components/pay/toC/serve.js +29 -1
  32. package/es/components/pay/toC/utils.d.ts +2 -2
  33. package/es/components/pay/toC/utils.js +4 -0
  34. package/es/components/systemSettings/registry/components/SectionList.js +5 -1
  35. package/es/components/ticketBooking/components/addServiceVariant/addService.js +7 -4
  36. package/es/plus/walletPassGallery/serve.js +2 -0
  37. package/es/pro/Login2.0/AuthModal.js +12 -4
  38. package/es/pro/Login2.0/index.less +7 -7
  39. package/lib/components/appointmentBooking/components/Voucher/index.js +10 -2
  40. package/lib/components/booking/addons/index.js +3 -2
  41. package/lib/components/booking/components/footer/amount.js +1 -1
  42. package/lib/components/booking/components/footer/index.js +9 -0
  43. package/lib/components/booking/components/footer/utils.d.ts +1 -1
  44. package/lib/components/booking/components/footer/utils.js +5 -3
  45. package/lib/components/booking/components/voucher/index.js +6 -0
  46. package/lib/components/booking/components/voucher/index.less +4 -1
  47. package/lib/components/booking/components/voucherModal/index.less +1 -0
  48. package/lib/components/booking/info2/service/editService/index.js +48 -24
  49. package/lib/components/checkout/components/WalletPassModule/index.js +1 -0
  50. package/lib/components/checkout/components/WalletPassModule/utils.js +13 -2
  51. package/lib/components/checkout/hooks/useWalletPass.d.ts +1 -1
  52. package/lib/components/checkout/hooks/useWalletPass.js +151 -104
  53. package/lib/components/pay/toC/PaymentMethods/WalletPass/index.d.ts +5 -0
  54. package/lib/components/pay/toC/PaymentMethods/WalletPass/index.js +90 -103
  55. package/lib/components/pay/toC/PaymentMethods/WalletPass/serve.d.ts +6 -0
  56. package/lib/components/pay/toC/PaymentMethods/WalletPass/utils.js +2 -2
  57. package/lib/components/pay/toC/WalletPassBlock/index.js +3 -1
  58. package/lib/components/pay/toC/index.js +52 -11
  59. package/lib/components/pay/toC/model.d.ts +1 -0
  60. package/lib/components/pay/toC/serve.d.ts +18 -0
  61. package/lib/components/pay/toC/serve.js +6 -0
  62. package/lib/components/pay/toC/utils.d.ts +2 -2
  63. package/lib/components/pay/toC/utils.js +4 -0
  64. package/lib/components/systemSettings/registry/components/SectionList.js +4 -1
  65. package/lib/components/ticketBooking/components/addServiceVariant/addService.js +11 -7
  66. package/lib/plus/walletPassGallery/serve.js +2 -0
  67. package/lib/pro/Login2.0/AuthModal.js +15 -7
  68. package/lib/pro/Login2.0/index.less +7 -7
  69. package/package.json +2 -2
  70. package/es/components/checkout/PaymentModal.d.ts +0 -31
  71. package/lib/components/checkout/PaymentModal.d.ts +0 -31
@@ -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,80 +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].filter(
134
- (item) => !(order == null ? void 0 : order.customer_id) || item.customer_id === (order == null ? void 0 : order.customer_id)
135
- );
136
- }
137
- );
126
+ return selectedVoucherIds;
127
+ }, [selectedVoucherIds]);
128
+ (0, import_react.useEffect)(() => {
129
+ if (recommended && recommended.length > 0) {
130
+ setSelectedVoucherIds(recommended.map((v) => v.id));
138
131
  }
139
- });
132
+ }, [recommended]);
140
133
  (0, import_react.useEffect)(() => {
141
134
  if ((order == null ? void 0 : order.order_id) && searchValRef.current) {
142
135
  searchList(searchValRef.current, true);
@@ -147,16 +140,16 @@ var WalletPass = (0, import_react.forwardRef)((props, ref) => {
147
140
  setOrder(res);
148
141
  setOpen(true);
149
142
  setCurrentWalletPass(walletPass);
150
- setTimeout(() => {
151
- refreshList();
152
- });
143
+ if (recommended && recommended.length > 0) {
144
+ setSelectedVoucherIds(recommended.map((v) => v.id));
145
+ }
153
146
  };
154
147
  const searchList = async ({ code, customer_pin_key }, isSelectChange) => {
155
148
  var _a2;
156
149
  if (!(order == null ? void 0 : order.order_id)) return;
157
150
  setLoading(true);
158
151
  try {
159
- const result = await (0, import_serve.searchMachineCodeList)({
152
+ const baseResult = await (0, import_serve.searchMachineCodeList)({
160
153
  order_id: order.order_id,
161
154
  code,
162
155
  prepare_payments,
@@ -164,7 +157,7 @@ var WalletPass = (0, import_react.forwardRef)((props, ref) => {
164
157
  sale_channel: ((_a2 = order._order) == null ? void 0 : _a2.sale_channel) || "online-store",
165
158
  customer_pin_key
166
159
  });
167
- if (!result) {
160
+ if (!baseResult) {
168
161
  if (!isSelectChange) {
169
162
  (0, import_materials.PisellToast)({
170
163
  content: import_utils.locales.getText("tocPay.text.walletSearchEmpty")
@@ -175,6 +168,11 @@ var WalletPass = (0, import_react.forwardRef)((props, ref) => {
175
168
  if (isSelectChange && !searchValRef.current) {
176
169
  return;
177
170
  }
171
+ let result = walletPassEvaluator.searchVoucherFormat({
172
+ vouchers: baseResult,
173
+ orderTotalAmount: order.total_amount,
174
+ products: detail
175
+ });
178
176
  setSearchData(
179
177
  (0, import_utils2.formatMachineCodeServer2CardList)(
180
178
  [...searchSelectData.details, ...result],
@@ -237,23 +235,23 @@ var WalletPass = (0, import_react.forwardRef)((props, ref) => {
237
235
  });
238
236
  };
239
237
  const handleSelectOk = () => {
240
- changeWalletPass(
241
- (0, import_utils.uniqueByKey)(
242
- [
243
- ...walletPassSelectCards || [],
244
- ...searchSelectData.details
245
- ],
246
- "id"
247
- )
238
+ const otherCustomerSearchVouchers = searchSelectData.details.filter(
239
+ (item) => item.customer_id !== (order == null ? void 0 : order.customer_id)
248
240
  );
249
241
  setAddList((prevState) => {
250
242
  return (0, import_utils.uniqueByKey)(
251
- [...prevState, ...searchSelectData.details],
243
+ [...prevState, ...otherCustomerSearchVouchers],
252
244
  "id"
253
- ).filter(
254
- (item) => !(order == null ? void 0 : order.customer_id) || item.customer_id !== (order == null ? void 0 : order.customer_id)
255
245
  );
256
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);
257
255
  handleSearchModalClose();
258
256
  };
259
257
  const handleAddChange = (0, import_ahooks.useMemoizedFn)(
@@ -265,26 +263,15 @@ var WalletPass = (0, import_react.forwardRef)((props, ref) => {
265
263
  });
266
264
  }
267
265
  );
268
- const changeWalletPass = (cards) => {
269
- setCurrentWalletPass == null ? void 0 : setCurrentWalletPass({
270
- cards,
271
- amount: (0, import_utils3.calcWalletPassListAmount)(cards)
272
- });
273
- setTimeout(() => {
274
- refreshList();
275
- });
276
- };
277
266
  const handleSelectChange = (val, details, type) => {
278
- let cards = details.map((item) => item.originData);
279
- if (type === "other") {
280
- cards = currentCustomerWalletPass.concat(cards);
281
- } else if (type === "current") {
282
- cards = otherCustomerWalletPass.concat(cards);
283
- }
284
- changeWalletPass(cards);
267
+ setSelectedVoucherIds(val);
285
268
  };
286
269
  const handleRedeem = () => {
287
- onWalletPassChange == null ? void 0 : onWalletPassChange(currentWalletPass);
270
+ onWalletPassChange == null ? void 0 : onWalletPassChange({
271
+ ...currentWalletPass,
272
+ cards: selectedWithDetails,
273
+ amount: totalDeduction
274
+ });
288
275
  setOpen(false);
289
276
  };
290
277
  const handleWalletClose = () => {
@@ -309,16 +296,16 @@ var WalletPass = (0, import_react.forwardRef)((props, ref) => {
309
296
  onCancel: () => handleWalletClose(),
310
297
  cancelVisible: false,
311
298
  destroyOnClose: true,
312
- 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 })),
313
300
  onOk: handleRedeem
314
301
  },
315
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(
316
303
  "tocPay.text.youCanSelectMultipleWalletPassesToCombineForPayment"
317
- )(walletSetting.name))), otherCustomerWalletPassList.length > 0 && /* @__PURE__ */ import_react.default.createElement(
304
+ )(walletSetting.name))), displayOtherVouchers.length > 0 && /* @__PURE__ */ import_react.default.createElement(
318
305
  import_List.default,
319
306
  {
320
307
  walletSetting,
321
- data: otherCustomerWalletPassList,
308
+ data: (0, import_utils2.formatMachineCodeServer2CardList)(displayOtherVouchers, selectValue),
322
309
  title: import_utils.locales.getText("tocPay.text.couponCodesAdded"),
323
310
  onChange: handleOtherChange,
324
311
  value: selectValue,
@@ -331,9 +318,9 @@ var WalletPass = (0, import_react.forwardRef)((props, ref) => {
331
318
  walletSetting,
332
319
  title: walletSetting.name,
333
320
  onChange: handleCurrentChange,
334
- ref: listRef,
321
+ data: (0, import_utils2.formatMachineCodeServer2CardList)(displayVouchers, selectValue),
335
322
  value: selectValue,
336
- onLoadingChange: setLoading
323
+ loading
337
324
  }
338
325
  ))
339
326
  ), /* @__PURE__ */ import_react.default.createElement(
@@ -348,7 +335,7 @@ var WalletPass = (0, import_react.forwardRef)((props, ref) => {
348
335
  okText: import_utils.locales.getText("tocPay.text.select"),
349
336
  onOk: handleSelectOk,
350
337
  okButtonProps: {
351
- disabled: ((_e = searchSelectData.ids) == null ? void 0 : _e.length) === 0
338
+ disabled: ((_f = searchSelectData.ids) == null ? void 0 : _f.length) === 0
352
339
  }
353
340
  },
354
341
  /* @__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");
@@ -154,7 +155,7 @@ var ToCPay = (props, ref) => {
154
155
  }
155
156
  };
156
157
  const _getPaymentsAndWalletPass = async (order) => {
157
- var _a2, _b2;
158
+ var _a2, _b2, _c2;
158
159
  paymentLogger.addLog({
159
160
  key: "获取支付列表开始",
160
161
  value: {
@@ -162,11 +163,22 @@ var ToCPay = (props, ref) => {
162
163
  }
163
164
  });
164
165
  try {
165
- const data = await (0, import_serve.getPaymentsAndWalletPass)({
166
- order_id: order.order_id,
167
- total_amount: order.amount,
168
- sale_channel: order.sale_channel || "online-store"
169
- });
166
+ const [data, allList, orderBasicDetail] = await Promise.all([
167
+ (0, import_serve.getPaymentsAndWalletPass)({
168
+ order_id: order.order_id,
169
+ total_amount: order.amount,
170
+ sale_channel: order.sale_channel || "online-store"
171
+ }),
172
+ (0, import_serve2.getMachineCodeList)({
173
+ order_id: order.order_id,
174
+ available: 2,
175
+ prepare_payments: [],
176
+ filter_prepare_wallet_pass: 1,
177
+ sale_channel: ((_a2 = order._order) == null ? void 0 : _a2.sale_channel) || "online-store",
178
+ other_exact_codes: []
179
+ }),
180
+ (0, import_serve.getOrderBasicDetail)(order.order_id)
181
+ ]);
170
182
  const {
171
183
  remain_amount = 0,
172
184
  wallet_pass_recommend_list,
@@ -174,6 +186,25 @@ var ToCPay = (props, ref) => {
174
186
  payment_list,
175
187
  walletPass
176
188
  } = data || {};
189
+ const products = (orderBasicDetail.detail || []).map((item) => {
190
+ var _a3;
191
+ return {
192
+ ...item,
193
+ is_price_include_tax: orderBasicDetail.is_price_include_tax,
194
+ product_bundle: (_a3 = item.product_bundle || []) == null ? void 0 : _a3.map((bundle) => {
195
+ return {
196
+ ...bundle,
197
+ is_price_include_tax: orderBasicDetail.is_price_include_tax
198
+ };
199
+ })
200
+ };
201
+ });
202
+ const res = utils.walletPassEvaluator.getRecommendedVouchers({
203
+ orderTotalAmount: Math.min(orderBasicDetail.product_unpaid_total_pay_amount, order.amount),
204
+ products,
205
+ vouchers: allList || []
206
+ });
207
+ const { recommended, transformList, noApplicableVoucher, recommendedAmount } = res;
177
208
  paymentLogger.addLog({
178
209
  key: "支付数据获取",
179
210
  value: ""
@@ -186,27 +217,37 @@ var ToCPay = (props, ref) => {
186
217
  };
187
218
  }
188
219
  );
220
+ const waitAmount2 = new import_decimal.Decimal((order == null ? void 0 : order.amount) || 0).minus(new import_decimal.Decimal(recommendedAmount)).toNumber();
189
221
  dispatch({
190
222
  type: "setPayGroup",
191
223
  payload: {
192
224
  // ...state.payGroup,
193
225
  order_id: order == null ? void 0 : order.order_id,
194
226
  // total_amount: order?.amount,
227
+ orderDetail: orderBasicDetail,
195
228
  // 原订单信息
196
229
  _order: order,
197
230
  payment_group_id: order == null ? void 0 : order.payment_group_id,
198
231
  // 支付方式没有walletPass时walletPass设置null
199
232
  walletPass: walletPass ? {
200
- ...(_a2 = state.payGroup) == null ? void 0 : _a2.walletPass,
233
+ ...(_b2 = state.payGroup) == null ? void 0 : _b2.walletPass,
201
234
  ...walletPass,
202
- amount: wallet_pass_amount,
203
- cards: withCustomerIdList
235
+ // 推荐钱包
236
+ cards: recommended,
237
+ // 推荐金额
238
+ amount: recommendedAmount,
239
+ // 不可用钱包
240
+ noApplicableVoucher,
241
+ // 转换列表
242
+ transformList
243
+ // amount: wallet_pass_amount,
244
+ // cards: wallet_pass_recommend_list,
204
245
  } : null,
205
246
  total_amount: order == null ? void 0 : order.amount,
206
- wait_amount: remain_amount
247
+ wait_amount: Math.max(0, waitAmount2)
207
248
  }
208
249
  });
209
- await ((_b2 = paymentListRef.current) == null ? void 0 : _b2.init(payment_list));
250
+ await ((_c2 = paymentListRef.current) == null ? void 0 : _c2.init(payment_list));
210
251
  setTimeout(() => {
211
252
  setLoading(false);
212
253
  }, 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;
@@ -60,3 +60,21 @@ export declare const getWalletNameAndPopupStatus: (values: {
60
60
  * @description: 获取支付结果
61
61
  */
62
62
  export declare const getPaymentResult: (values: any) => Promise<any>;
63
+ declare type OrderBasicDetail = {
64
+ id: number;
65
+ status: string;
66
+ payment_status: string;
67
+ order_time: string;
68
+ detail: any[];
69
+ product_unpaid_total_pay_amount: number;
70
+ product_paid_total_pay_amount: number;
71
+ is_price_include_tax: 1 | 0;
72
+ };
73
+ /**
74
+ * @title: 查询订单基础信息和订单商品信息
75
+ * @description: 查询订单基础信息和订单商品信息
76
+ * @param {string} order_id
77
+ * @return {*}
78
+ */
79
+ export declare const getOrderBasicDetail: (order_id: string) => Promise<OrderBasicDetail>;
80
+ export {};
@@ -19,6 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  // src/components/pay/toC/serve.ts
20
20
  var serve_exports = {};
21
21
  __export(serve_exports, {
22
+ getOrderBasicDetail: () => getOrderBasicDetail,
22
23
  getPaymentInit: () => getPaymentInit,
23
24
  getPaymentList: () => getPaymentList,
24
25
  getPaymentResult: () => getPaymentResult,
@@ -77,8 +78,13 @@ var getWalletNameAndPopupStatus = async (values) => {
77
78
  return data;
78
79
  };
79
80
  var getPaymentResult = (values) => import_utils.request.getRequest().get(`/h5/pay/order/payment/result`, values);
81
+ var getOrderBasicDetail = async (order_id) => {
82
+ const { data } = await import_utils.request.getRequest().get(`/h5/order/order/${order_id}/basic-detail`, {});
83
+ return data;
84
+ };
80
85
  // Annotate the CommonJS export names for ESM import in node:
81
86
  0 && (module.exports = {
87
+ getOrderBasicDetail,
82
88
  getPaymentInit,
83
89
  getPaymentList,
84
90
  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';
@@ -32,6 +32,7 @@ __export(utils_exports, {
32
32
  module.exports = __toCommonJS(utils_exports);
33
33
  var import_decimal = require("decimal.js");
34
34
  var import_status = require("./status");
35
+ var import_utils = require("@pisell/utils");
35
36
  var calcWalletPassListAmount = (list) => {
36
37
  return list.reduce((pre, cur) => pre.add(new import_decimal.Decimal(String(getAvailableMaxAmount(cur) || 0))), new import_decimal.Decimal("0")).toNumber();
37
38
  };
@@ -84,6 +85,9 @@ var formatFranchiseeRoute = (url, history) => {
84
85
  return url;
85
86
  };
86
87
  var getAvailableMaxAmount = (data) => {
88
+ if ((0, import_utils.isNumber)(data._available_max_amount)) {
89
+ return data._available_max_amount;
90
+ }
87
91
  return data.tag !== "point_card" ? data.available_max_amount : data == null ? void 0 : data.recommended_usage_amount;
88
92
  };
89
93
  var clientPayment = (params) => {
@@ -37,6 +37,7 @@ var import_antd = require("antd");
37
37
  var import_icons = require("@ant-design/icons");
38
38
  var import_icon = require("@pisell/icon");
39
39
  var import_utils = require("@pisell/utils");
40
+ var import_useEngineContext = __toESM(require("../../../../hooks/useEngineContext"));
40
41
  var getLocalizedText = (text, locale = "zh-CN") => {
41
42
  if (typeof text === "string") {
42
43
  return text;
@@ -66,9 +67,11 @@ var SectionList = ({
66
67
  hasMore = false,
67
68
  onLoadMore
68
69
  }) => {
70
+ var _a, _b;
69
71
  const scrollContainerRef = (0, import_react.useRef)(null);
70
72
  const loadingRef = (0, import_react.useRef)(null);
71
- const currentLocale = localStorage.getItem("umi_locale") || "zh-CN";
73
+ const context = (0, import_useEngineContext.default)();
74
+ const currentLocale = ((_b = (_a = context == null ? void 0 : context.engine) == null ? void 0 : _a.props) == null ? void 0 : _b.locale) || localStorage.getItem("umi_locale") || "en";
72
75
  const handleScroll = (0, import_react.useCallback)(() => {
73
76
  if (!scrollContainerRef.current || !hasMore || loading || !onLoadMore) {
74
77
  return;
@@ -66,7 +66,7 @@ var productListSetting = {
66
66
  isStock: 0
67
67
  };
68
68
  var AddSerivce = (props) => {
69
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
69
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
70
70
  const {
71
71
  onEdit,
72
72
  state,
@@ -75,6 +75,9 @@ var AddSerivce = (props) => {
75
75
  productDisplayConfig
76
76
  } = props;
77
77
  const context = (0, import_useEngineContext.default)();
78
+ const {
79
+ getData
80
+ } = (_a = context.appHelper) == null ? void 0 : _a.utils;
78
81
  const notAvailableRef = (0, import_react.useRef)(null);
79
82
  import_utils2.request.setRequest(context.appHelper.utils.request);
80
83
  const isActive = (0, import_IsActiveContext.useIsActive)();
@@ -86,9 +89,9 @@ var AddSerivce = (props) => {
86
89
  dispatch
87
90
  });
88
91
  const isBooking4 = (0, import_utils5.isBooking4Shop)(
89
- ((_c = (_b = (_a = context.appHelper) == null ? void 0 : _a.utils) == null ? void 0 : _b.getData) == null ? void 0 : _c.call(_b, "shop_id")) || ((_h = (_g = (_f = (_e = (_d = context.appHelper.utils.store) == null ? void 0 : _d.getState) == null ? void 0 : _e.call(_d)) == null ? void 0 : _f.global) == null ? void 0 : _g.globalConfig) == null ? void 0 : _h.id),
92
+ ((_d = (_c = (_b = context.appHelper) == null ? void 0 : _b.utils) == null ? void 0 : _c.getData) == null ? void 0 : _d.call(_c, "shop_id")) || ((_i = (_h = (_g = (_f = (_e = context.appHelper.utils.store) == null ? void 0 : _e.getState) == null ? void 0 : _f.call(_e)) == null ? void 0 : _g.global) == null ? void 0 : _h.globalConfig) == null ? void 0 : _i.id),
90
93
  state == null ? void 0 : state.renderType,
91
- (_i = context.appHelper.utils) == null ? void 0 : _i.businessUtils
94
+ (_j = context.appHelper.utils) == null ? void 0 : _j.businessUtils
92
95
  );
93
96
  const [currentProduct, setCurrentProduct] = (0, import_react.useState)(null);
94
97
  const [firstLoading, setFirstLoading] = (0, import_react.useState)(true);
@@ -133,11 +136,11 @@ var AddSerivce = (props) => {
133
136
  const menuList = (0, import_react.useMemo)(() => {
134
137
  var _a2, _b2, _c2;
135
138
  return ((_c2 = (_b2 = (_a2 = state == null ? void 0 : state.bookingConfig) == null ? void 0 : _a2.config) == null ? void 0 : _b2.menu_list_tab) == null ? void 0 : _c2.menu_list) || [];
136
- }, [(_j = state == null ? void 0 : state.bookingConfig) == null ? void 0 : _j.config]);
139
+ }, [(_k = state == null ? void 0 : state.bookingConfig) == null ? void 0 : _k.config]);
137
140
  const customerId = (0, import_react.useMemo)(() => {
138
141
  var _a2, _b2;
139
142
  return ((_b2 = (_a2 = state.client) == null ? void 0 : _a2.value) == null ? void 0 : _b2.id) || void 0;
140
- }, [(_l = (_k = state.client) == null ? void 0 : _k.value) == null ? void 0 : _l.id]);
143
+ }, [(_m = (_l = state.client) == null ? void 0 : _l.value) == null ? void 0 : _m.id]);
141
144
  const scanAddService = (0, import_ahooks.useMemoizedFn)((list, code) => {
142
145
  let newService = [...state.service.value];
143
146
  list.forEach((item) => {
@@ -202,7 +205,7 @@ var AddSerivce = (props) => {
202
205
  }
203
206
  );
204
207
  const processAddService = (0, import_ahooks.useMemoizedFn)(async (item, _detail, e, notShowToast, startDate, endDate) => {
205
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m, _n, _o, _p;
208
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n, _o, _p;
206
209
  const other = JSON.parse(JSON.stringify(e));
207
210
  other.session = e.session;
208
211
  let cacheItem = {
@@ -210,6 +213,7 @@ var AddSerivce = (props) => {
210
213
  product_id: item.id,
211
214
  _id: (0, import_utils.getUniqueId)(),
212
215
  _key: e.key,
216
+ is_price_include_tax: getData("is_price_include_tax"),
213
217
  _extend: {
214
218
  start_date: startDate,
215
219
  quantity: (e == null ? void 0 : e.quantity) || 1,
@@ -287,7 +291,7 @@ var AddSerivce = (props) => {
287
291
  })
288
292
  );
289
293
  try {
290
- if (((_o = (_n = (_m = (_l2 = (_k2 = context.appHelper.utils.store) == null ? void 0 : _k2.getState) == null ? void 0 : _l2.call(_k2)) == null ? void 0 : _m.global) == null ? void 0 : _n.globalConfig) == null ? void 0 : _o.id) === 2155) {
294
+ if (((_o = (_n = (_m2 = (_l2 = (_k2 = context.appHelper.utils.store) == null ? void 0 : _k2.getState) == null ? void 0 : _l2.call(_k2)) == null ? void 0 : _m2.global) == null ? void 0 : _n.globalConfig) == null ? void 0 : _o.id) === 2155) {
291
295
  const val = _list == null ? void 0 : _list.map((s) => {
292
296
  return {
293
297
  product_id: s == null ? void 0 : s.product_id,
@@ -77,6 +77,8 @@ var getDetailApi = async (params) => {
77
77
  order_behavior_count_customer: 1,
78
78
  // 客户订单行为次数
79
79
  order_behavior_count_customer_id: params.apiPrefix === "/shop" ? params.order_behavior_count_customer_id : void 0
80
+ }, {
81
+ isOriginHost: true
80
82
  });
81
83
  return data;
82
84
  };