@pisell/private-materials 6.3.45 → 6.3.47

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 (90) 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 +8 -8
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +9 -9
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +9 -9
  11. package/es/components/Sales/Summary/utils.d.ts +1 -1
  12. package/es/components/appointmentBooking/components/Voucher/index.js +1 -0
  13. package/es/components/booking/components/voucher/index.js +3 -1
  14. package/es/components/booking/info/service2/utils.d.ts +1 -1
  15. package/es/components/booking/utils.d.ts +2 -2
  16. package/es/components/eftposPay/amount.d.ts +1 -1
  17. package/es/components/eftposPay/device.d.ts +1 -1
  18. package/es/components/eftposPay/hooks.d.ts +2 -2
  19. package/es/components/eftposPay/linkly/hooks/useTimeQuery.js +14 -6
  20. package/es/components/eftposPay/payo/config.js +70 -32
  21. package/es/components/eftposPay/payo/payment.d.ts +66 -0
  22. package/es/components/eftposPay/payo/payment.js +579 -0
  23. package/es/components/eftposPay/store/index.d.ts +6 -6
  24. package/es/components/eftposPay/utils/log/index.d.ts +110 -0
  25. package/es/components/eftposPay/utils/log/index.js +371 -0
  26. package/es/components/index.d.ts +2 -1
  27. package/es/components/index.js +2 -1
  28. package/es/components/pay/toC/PaymentMethods/WalletPass/serve.d.ts +6 -0
  29. package/es/components/pay/toC/PaymentMethods/WalletPass/utils.js +4 -2
  30. package/es/components/pay/toC/PaymentMethods/components/PaymentReturnContent/index.js +2 -0
  31. package/es/components/pay/toC/PaymentMethods/components/PaymentReturnContent/index.less +13 -3
  32. package/es/components/pay/toC/locales.d.ts +3 -0
  33. package/es/components/pay/toC/locales.js +6 -3
  34. package/es/components/wallet/Detail/index.js +34 -2
  35. package/es/components/wallet/Detail/index.less +11 -0
  36. package/es/components/wallet/Detail/locales.d.ts +6 -0
  37. package/es/components/wallet/Detail/locales.js +14 -2
  38. package/es/components/wallet/Voucher/index.js +11 -10
  39. package/es/components/wallet/components/WalletCard.js +5 -1
  40. package/es/components/wallet/index.js +4 -2
  41. package/es/components/wallet/serve.d.ts +7 -0
  42. package/es/components/wallet/utils.d.ts +48 -0
  43. package/es/components/wallet/utils.js +342 -0
  44. package/es/index.d.ts +3 -2
  45. package/es/index.js +4 -3
  46. package/es/plus/walletPassGallery/components/passDetail/index.js +72 -28
  47. package/es/plus/walletPassGallery/index.js +4 -2
  48. package/es/plus/walletPassGallery/serve.d.ts +2 -0
  49. package/es/plus/walletPassGallery/serve.js +1 -1
  50. package/lib/components/Sales/Summary/utils.d.ts +1 -1
  51. package/lib/components/appointmentBooking/components/Voucher/index.js +1 -0
  52. package/lib/components/booking/components/voucher/index.js +3 -1
  53. package/lib/components/booking/info/service2/utils.d.ts +1 -1
  54. package/lib/components/booking/utils.d.ts +2 -2
  55. package/lib/components/eftposPay/amount.d.ts +1 -1
  56. package/lib/components/eftposPay/device.d.ts +1 -1
  57. package/lib/components/eftposPay/hooks.d.ts +2 -2
  58. package/lib/components/eftposPay/linkly/hooks/useTimeQuery.js +12 -6
  59. package/lib/components/eftposPay/payo/config.js +98 -73
  60. package/lib/components/eftposPay/payo/payment.d.ts +66 -0
  61. package/lib/components/eftposPay/payo/payment.js +357 -0
  62. package/lib/components/eftposPay/store/index.d.ts +6 -6
  63. package/lib/components/eftposPay/utils/log/index.d.ts +110 -0
  64. package/lib/components/eftposPay/utils/log/index.js +294 -0
  65. package/lib/components/index.d.ts +2 -1
  66. package/lib/components/index.js +3 -0
  67. package/lib/components/pay/toC/PaymentMethods/WalletPass/serve.d.ts +6 -0
  68. package/lib/components/pay/toC/PaymentMethods/WalletPass/utils.js +4 -2
  69. package/lib/components/pay/toC/PaymentMethods/components/PaymentReturnContent/index.js +1 -1
  70. package/lib/components/pay/toC/PaymentMethods/components/PaymentReturnContent/index.less +13 -3
  71. package/lib/components/pay/toC/locales.d.ts +3 -0
  72. package/lib/components/pay/toC/locales.js +6 -3
  73. package/lib/components/wallet/Detail/index.js +31 -3
  74. package/lib/components/wallet/Detail/index.less +11 -0
  75. package/lib/components/wallet/Detail/locales.d.ts +6 -0
  76. package/lib/components/wallet/Detail/locales.js +14 -2
  77. package/lib/components/wallet/Voucher/index.js +8 -8
  78. package/lib/components/wallet/components/WalletCard.js +4 -0
  79. package/lib/components/wallet/index.js +2 -2
  80. package/lib/components/wallet/serve.d.ts +7 -0
  81. package/lib/components/wallet/utils.d.ts +48 -0
  82. package/lib/components/wallet/utils.js +287 -0
  83. package/lib/index.d.ts +3 -2
  84. package/lib/index.js +5 -2
  85. package/lib/plus/walletPassGallery/components/passDetail/index.js +46 -12
  86. package/lib/plus/walletPassGallery/index.js +4 -2
  87. package/lib/plus/walletPassGallery/serve.d.ts +2 -0
  88. package/lib/plus/walletPassGallery/serve.js +1 -1
  89. package/lowcode/wallet-pass-detail/meta.ts +84 -0
  90. package/package.json +2 -2
package/es/index.js CHANGED
@@ -51,11 +51,12 @@ export { default as StepController } from "./components/stepController";
51
51
  export { default as SaasLogin } from "./plus/saasLogin";
52
52
  export { default as SaasRegister } from "./plus/saasRegister";
53
53
  export { default as SaasCreateOrganization } from "./plus/saasCreateOrganization";
54
- export { default as WalletEditor } from "./plus/walletEditor";
55
- export { default as WalletPassGallery } from "./plus/walletPassGallery";
56
54
  export { default as PinModal } from "./components/pinModal";
57
55
  export { default as PinVerifyModal } from "./components/pinVerifyModal";
58
56
  export { OAuthConfig, SaaSAdminAuth, OrgAdminAuth, CustomerAuth, CustomerOAuthConfig, DeviceAuth, POSOperatorAuth, OnlineShopAuth, SaaSManagermentAuth } from "./components/authentication/admin";
59
57
  export { default as ContactInfo } from "./plus/contactInfo";
60
58
  export { default as ContactInfoModal } from "./plus/contactInfoModal";
61
- export { Login2, Register2, AuthModal } from "./pro/Login2.0";
59
+ export { Login2, Register2, AuthModal } from "./pro/Login2.0";
60
+ export { default as WalletEditor } from "./plus/walletEditor";
61
+ export { default as WalletPassGallery } from "./plus/walletPassGallery";
62
+ export { default as WalletPassDetail } from "./plus/walletPassGallery/components/passDetail";
@@ -20,10 +20,12 @@ import Recharge from "../recharge";
20
20
  import FooterButtons from "../footerButton";
21
21
  import useEngineContext from "../../../../hooks/useEngineContext";
22
22
  import "./index.less";
23
+ import { formatScheduleText } from "../../../../components/wallet/utils";
24
+ import localeTexts from "../../locales";
25
+ import { request } from "../../../../utils";
23
26
  var Text = Typography.Text;
24
27
  var PassDetail = function PassDetail(props) {
25
- var _context$appHelper, _store$getState, _dataSource$machineco, _getDetail$data, _getDetail$data2, _dataSource$machineco2;
26
- if (!props.dataSource) return null;
28
+ var _context$appHelper, _context$appHelper2, _store$getState, _context$engine, _context$appHelper3, _dataSource$machineco, _getDetail$data, _getDetail$data2, _dataSource$machineco2;
27
29
  var _usePisellConfig = usePisellConfig(),
28
30
  _usePisellConfig$symb = _usePisellConfig.symbol,
29
31
  symbol = _usePisellConfig$symb === void 0 ? '$' : _usePisellConfig$symb;
@@ -47,38 +49,52 @@ var PassDetail = function PassDetail(props) {
47
49
  store: {}
48
50
  },
49
51
  store = _ref.store;
50
- var timezone = (store === null || store === void 0 || (_store$getState = store.getState) === null || _store$getState === void 0 || (_store$getState = _store$getState.call(store)) === null || _store$getState === void 0 || (_store$getState = _store$getState.global) === null || _store$getState === void 0 || (_store$getState = _store$getState.symbol) === null || _store$getState === void 0 ? void 0 : _store$getState.shop.timezone) || 'Asia/Shanghai';
51
- var _ref2 = dataSource || {},
52
- _ref2$id = _ref2.id,
53
- id = _ref2$id === void 0 ? '' : _ref2$id,
54
- _ref2$code = _ref2.code,
55
- code = _ref2$code === void 0 ? '' : _ref2$code,
56
- _ref2$tag = _ref2.tag,
57
- tag = _ref2$tag === void 0 ? '' : _ref2$tag,
58
- _ref2$product_title = _ref2.product_title,
59
- product_title = _ref2$product_title === void 0 ? '' : _ref2$product_title,
60
- _ref2$encoded = _ref2.encoded,
61
- encoded = _ref2$encoded === void 0 ? '' : _ref2$encoded,
62
- balance = _ref2.balance,
63
- _ref2$expire_date = _ref2.expire_date,
64
- expire_date = _ref2$expire_date === void 0 ? '' : _ref2$expire_date,
65
- _ref2$product = _ref2.product,
66
- product = _ref2$product === void 0 ? {} : _ref2$product;
67
- var _ref3 = product || {},
68
- _ref3$description = _ref3.description,
69
- description = _ref3$description === void 0 ? '' : _ref3$description,
70
- _ref3$extension_data = _ref3.extension_data,
71
- extension_data = _ref3$extension_data === void 0 ? [] : _ref3$extension_data,
72
- _ref3$customer_order_ = _ref3.customer_order_behavior_count,
73
- customer_order_behavior_count = _ref3$customer_order_ === void 0 ? 0 : _ref3$customer_order_;
52
+ var _ref2 = ((_context$appHelper2 = context.appHelper) === null || _context$appHelper2 === void 0 ? void 0 : _context$appHelper2.constants) || {
53
+ apiPrefix: "/h5"
54
+ },
55
+ apiPrefix = _ref2.apiPrefix;
56
+ var timezone = (store === null || store === void 0 || (_store$getState = store.getState) === null || _store$getState === void 0 || (_store$getState = _store$getState.call(store)) === null || _store$getState === void 0 || (_store$getState = _store$getState.global) === null || _store$getState === void 0 || (_store$getState = _store$getState.symbol) === null || _store$getState === void 0 || (_store$getState = _store$getState.shop) === null || _store$getState === void 0 ? void 0 : _store$getState.timezone) || 'Asia/Shanghai';
57
+ locales.init(localeTexts, (context === null || context === void 0 || (_context$engine = context.engine) === null || _context$engine === void 0 || (_context$engine = _context$engine.props) === null || _context$engine === void 0 ? void 0 : _context$engine.locale) || 'en');
58
+ if ((_context$appHelper3 = context.appHelper) !== null && _context$appHelper3 !== void 0 && (_context$appHelper3 = _context$appHelper3.utils) !== null && _context$appHelper3 !== void 0 && _context$appHelper3.request) {
59
+ var _context$appHelper4;
60
+ request.setRequest((_context$appHelper4 = context.appHelper) === null || _context$appHelper4 === void 0 || (_context$appHelper4 = _context$appHelper4.utils) === null || _context$appHelper4 === void 0 ? void 0 : _context$appHelper4.request);
61
+ }
62
+ var _ref3 = dataSource || {},
63
+ _ref3$id = _ref3.id,
64
+ id = _ref3$id === void 0 ? '' : _ref3$id,
65
+ _ref3$code = _ref3.code,
66
+ code = _ref3$code === void 0 ? '' : _ref3$code,
67
+ _ref3$tag = _ref3.tag,
68
+ tag = _ref3$tag === void 0 ? '' : _ref3$tag,
69
+ _ref3$product_title = _ref3.product_title,
70
+ product_title = _ref3$product_title === void 0 ? '' : _ref3$product_title,
71
+ _ref3$encoded = _ref3.encoded,
72
+ encoded = _ref3$encoded === void 0 ? '' : _ref3$encoded,
73
+ balance = _ref3.balance,
74
+ _ref3$expire_date = _ref3.expire_date,
75
+ expire_date = _ref3$expire_date === void 0 ? '' : _ref3$expire_date,
76
+ _ref3$product = _ref3.product,
77
+ product = _ref3$product === void 0 ? {} : _ref3$product,
78
+ custom_schedule_snapshot = _ref3.custom_schedule_snapshot;
79
+ var _ref4 = product || {},
80
+ _ref4$description = _ref4.description,
81
+ description = _ref4$description === void 0 ? '' : _ref4$description,
82
+ _ref4$extension_data = _ref4.extension_data,
83
+ extension_data = _ref4$extension_data === void 0 ? [] : _ref4$extension_data,
84
+ _ref4$customer_order_ = _ref4.customer_order_behavior_count,
85
+ customer_order_behavior_count = _ref4$customer_order_ === void 0 ? 0 : _ref4$customer_order_;
74
86
  var _getDetail = useRequest(function () {
75
87
  return getDetailApi({
76
- id: id
88
+ id: id,
89
+ apiPrefix: apiPrefix
77
90
  });
78
91
  }, {
79
92
  ready: !!id,
80
93
  refreshDeps: [id]
81
94
  });
95
+ var scheduleList = useMemo(function () {
96
+ return (custom_schedule_snapshot === null || custom_schedule_snapshot === void 0 ? void 0 : custom_schedule_snapshot.data) || [];
97
+ }, [custom_schedule_snapshot]);
82
98
  useEffect(function () {
83
99
  if (tag === 'product_discount_card') {
84
100
  setActiveKey('detail');
@@ -113,6 +129,33 @@ var PassDetail = function PassDetail(props) {
113
129
  };
114
130
  }, []);
115
131
  var descs = useMemo(function () {
132
+ var _context$engine2;
133
+ var detail = formatScheduleText(scheduleList, context === null || context === void 0 || (_context$engine2 = context.engine) === null || _context$engine2 === void 0 || (_context$engine2 = _context$engine2.props) === null || _context$engine2 === void 0 ? void 0 : _context$engine2.locale);
134
+ var expireText = expire_date ? expire_date : locales.getText('wallet-pass-gallery.expireDate');
135
+ if (scheduleList.length > 0) {
136
+ // 换行展示
137
+ var validityTexts = "";
138
+ var excludedText = "";
139
+ var includedText = "";
140
+ detail.forEach(function (item) {
141
+ if (item.validityTexts.length > 0) {
142
+ validityTexts = "".concat(validityTexts).concat(item.validityTexts.join('\n'), "\n");
143
+ }
144
+ if (item.excluded_date.length > 0) {
145
+ excludedText = "".concat(excludedText).concat(item.excluded_date.join('\n'), "\n");
146
+ }
147
+ if (item.included_date.length > 0) {
148
+ includedText = "".concat(includedText).concat(item.included_date.join('\n'), "\n");
149
+ }
150
+ });
151
+ expireText = /*#__PURE__*/React.createElement("span", {
152
+ className: "wallet-detail-expire-text"
153
+ }, validityTexts, excludedText && /*#__PURE__*/React.createElement("div", {
154
+ className: "wallet-detail-expire-text-title"
155
+ }, locales.getText('page.wallet.notValidDate')), excludedText, includedText && /*#__PURE__*/React.createElement("div", {
156
+ className: "wallet-detail-expire-text-title"
157
+ }, locales.getText('page.wallet.includedDate')), includedText);
158
+ }
116
159
  var data = [{
117
160
  label: locales.getText('wallet-pass-gallery.cardName'),
118
161
  value: product_title
@@ -122,7 +165,7 @@ var PassDetail = function PassDetail(props) {
122
165
  isLink: false
123
166
  }, {
124
167
  label: locales.getText('wallet-pass-gallery.validDate'),
125
- value: expire_date ? expire_date : locales.getText('wallet-pass-gallery.expireDate')
168
+ value: expireText
126
169
  }];
127
170
  //折扣卡显示折扣字段 其他显示余额字段
128
171
  if (tag === 'product_discount_card') {
@@ -197,6 +240,7 @@ var PassDetail = function PassDetail(props) {
197
240
  timezone: timezone
198
241
  });
199
242
  };
243
+ if (!props.dataSource) return null;
200
244
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
201
245
  className: classNames("pisell-wallet-pass-gallery_detail", "pisell-wallet-pass-gallery_detail-".concat(platform))
202
246
  }, /*#__PURE__*/React.createElement("div", {
@@ -82,7 +82,8 @@ var WalletPassGallery = function WalletPassGallery(props) {
82
82
  num: 20,
83
83
  skip: (d === null || d === void 0 ? void 0 : d.nextId) || 1,
84
84
  tags: TAGS,
85
- filter_wallet_id: walletId || undefined
85
+ filter_wallet_id: walletId || undefined,
86
+ "with": ['customScheduleSnapshot']
86
87
  });
87
88
  case 3:
88
89
  res = _context.sent;
@@ -121,7 +122,8 @@ var WalletPassGallery = function WalletPassGallery(props) {
121
122
  num: 20,
122
123
  skip: (d === null || d === void 0 ? void 0 : d.nextId) || 1,
123
124
  tags: TAGS,
124
- filter_wallet_id: walletId || undefined
125
+ filter_wallet_id: walletId || undefined,
126
+ "with": ['customScheduleSnapshot']
125
127
  });
126
128
  case 3:
127
129
  res = _context2.sent;
@@ -17,6 +17,7 @@ export interface IWalletListParmsProps {
17
17
  skip?: number;
18
18
  filter_wallet_id?: string;
19
19
  available: 0 | 1;
20
+ with?: string[];
20
21
  }
21
22
  /**
22
23
  * 钱包列表项属性接口
@@ -171,6 +172,7 @@ export declare const getAssetList: (params: IAssetListProps) => Promise<{
171
172
  */
172
173
  export declare const getDetailApi: (params: {
173
174
  id: string;
175
+ apiPrefix: string;
174
176
  }) => Promise<IDetailResponse>;
175
177
  /**
176
178
  * 详情响应数据结构,供组件消费
@@ -214,7 +214,7 @@ export var getDetailApi = /*#__PURE__*/function () {
214
214
  while (1) switch (_context6.prev = _context6.next) {
215
215
  case 0:
216
216
  _context6.next = 2;
217
- return request.getRequest().get("/h5/machinecode/lowcode/detail/".concat(params.id), {
217
+ return request.getRequest().get("".concat(params.apiPrefix || '/h5', "/machinecode/lowcode/detail/").concat(params.id), {
218
218
  order_behavior_count: 1,
219
219
  // 订单行为次数
220
220
  order_behavior_count_customer: 1 // 客户订单行为次数
@@ -30,7 +30,7 @@ export declare const calculateSubtotal: (items: CartItem[]) => string;
30
30
  * @return {*}
31
31
  * @Author: xiangfeng.xue
32
32
  */
33
- export declare const calculateTaxFee: (shopInfo: any, items: CartItem[]) => "0.00" | Decimal;
33
+ export declare const calculateTaxFee: (shopInfo: any, items: CartItem[]) => Decimal | "0.00";
34
34
  /**
35
35
  * 计算所有价格明细
36
36
  * @param items - 购物车商品数组
@@ -122,6 +122,7 @@ var VoucherCard = (props) => {
122
122
  );
123
123
  pisellos.effects.on("appointmentBooking_cart:onAddItem", onCartChange);
124
124
  pisellos.effects.on("appointmentBooking_cart:onUpdateQuotationPrice", onCartChange);
125
+ pisellos.effects.on("appointmentBooking_cart:onUpdateBookingDate", onCartChange);
125
126
  pisellos.effects.on("appointmentBooking_cart:onUpdateCartItemNums", onCartChange);
126
127
  pisellos.effects.on("appointmentBooking_cart:onRemoveItem", onCartChange);
127
128
  pisellos.effects.on(
@@ -96,7 +96,9 @@ var VoucherCard = (props) => {
96
96
  price: value.price,
97
97
  total: (_a3 = value == null ? void 0 : value._extend) == null ? void 0 : _a3.total,
98
98
  discount_list: value.discount_list,
99
- origin_total: (_b2 = value == null ? void 0 : value._extend) == null ? void 0 : _b2.origin_total
99
+ origin_total: (_b2 = value == null ? void 0 : value._extend) == null ? void 0 : _b2.origin_total,
100
+ quantity: value._extend.quantity,
101
+ startDate: value._extend.startDate
100
102
  };
101
103
  });
102
104
  return val;
@@ -244,4 +244,4 @@ export declare const updateAppointmentServicePrice: (state: any, { start_date, e
244
244
  * @Author: WangHan
245
245
  * @Date: 2024-12-24 11:32
246
246
  */
247
- export declare const updateServicePrice: (state: any) => never[] | Promise<any>;
247
+ export declare const updateServicePrice: (state: any) => Promise<any> | never[];
@@ -165,10 +165,10 @@ export declare const getProductTotalPrice: (item: any) => number;
165
165
  export declare const getDuration: (duration: number | {
166
166
  type: string;
167
167
  value: number;
168
- }) => number | "flexible" | {
168
+ }) => number | {
169
169
  type: string;
170
170
  value: number;
171
- };
171
+ } | "flexible";
172
172
  export declare const isWalkIn: (customer_id?: number | string) => boolean;
173
173
  export declare const getIsEdit: (state: any) => boolean;
174
174
  export {};
@@ -8,7 +8,7 @@ import { PosProps } from './const';
8
8
  */
9
9
  declare const _default: ({ className, onChange, onClose, formatAmount, isMobile, net, client }: {
10
10
  className?: string | undefined;
11
- onChange?: ((status: "page" | "success" | "print" | "fail" | "mark_tx_processed", params?: string | {
11
+ onChange?: ((status: "success" | "page" | "fail" | "print" | "mark_tx_processed", params?: string | {
12
12
  [keys: string]: unknown;
13
13
  } | undefined, other?: any) => void) | undefined;
14
14
  onClose: () => void;
@@ -10,7 +10,7 @@ import './device.less';
10
10
  declare const _default: ({ api, onChange, onClose, className, device_number, isMobile, net, client, formatAmount, }: {
11
11
  api: PayProps['api'];
12
12
  className?: string | undefined;
13
- onChange?: ((status: "page" | "success" | "print" | "fail" | "mark_tx_processed", params?: string | {
13
+ onChange?: ((status: "success" | "page" | "fail" | "print" | "mark_tx_processed", params?: string | {
14
14
  [keys: string]: unknown;
15
15
  } | undefined, other?: any) => void) | undefined;
16
16
  onClose: () => void;
@@ -15,11 +15,11 @@ export declare const useStoreRef: <T extends {
15
15
  readonly numRef: React.MutableRefObject<string | number | undefined>;
16
16
  readonly orderIdRef: React.MutableRefObject<string | number>;
17
17
  readonly modeRef: React.MutableRefObject<ModeEnum>;
18
- readonly statusRef: React.MutableRefObject<"loading" | "warn" | "success" | "fail" | "pedding" | "resove" | "reject" | "question">;
18
+ readonly statusRef: React.MutableRefObject<"success" | "warn" | "loading" | "fail" | "pedding" | "resove" | "reject" | "question">;
19
19
  readonly netRef: React.MutableRefObject<boolean | undefined>;
20
20
  readonly symbolRef: React.MutableRefObject<string>;
21
21
  readonly amountRef: React.MutableRefObject<string | number>;
22
- readonly eftposRef: React.MutableRefObject<"stripe" | "payo" | "tyro" | "windcave" | "linkly">;
22
+ readonly eftposRef: React.MutableRefObject<"payo" | "tyro" | "windcave" | "stripe" | "linkly">;
23
23
  readonly clientRef: React.MutableRefObject<ClientEnum>;
24
24
  readonly dataRef: React.MutableRefObject<import("./store").State>;
25
25
  };
@@ -41,6 +41,7 @@ var import_const = require("../../const");
41
41
  var import_const2 = require("../const");
42
42
  var GlobalTimeout = 1e3 * 60 * 2;
43
43
  var RequestTimeout = 1e3 * 5;
44
+ var QUERY_INTERVAL = 1e3 * 2;
44
45
  var useTimeResultQuery = (api, resultCheck, handleLinklySuccess) => {
45
46
  const dispatch = (0, import_store.useDispatch)();
46
47
  const { numRef, modeRef, deviceRef, orderIdRef } = (0, import_hooks.useStoreRef)();
@@ -56,6 +57,7 @@ var useTimeResultQuery = (api, resultCheck, handleLinklySuccess) => {
56
57
  const startTimeRef = (0, import_react.useRef)(null);
57
58
  const isQueryFinishedRef = (0, import_react.useRef)(true);
58
59
  const queryIdRef = (0, import_react.useRef)(null);
60
+ const queryIntervalTimerRef = (0, import_react.useRef)(null);
59
61
  const _resultQuery = async () => {
60
62
  var _a, _b;
61
63
  if (controllerRef.current) {
@@ -107,9 +109,9 @@ var useTimeResultQuery = (api, resultCheck, handleLinklySuccess) => {
107
109
  console.log("交易状态为0需要继续查询");
108
110
  _log("Querying" /* Querying */, result);
109
111
  isQueryFinishedRef.current = false;
110
- setTimeout(() => {
112
+ queryIntervalTimerRef.current = setTimeout(() => {
111
113
  _resultQuery();
112
- }, 1500);
114
+ }, QUERY_INTERVAL);
113
115
  return;
114
116
  }
115
117
  if (data.status < 0) {
@@ -145,18 +147,18 @@ var useTimeResultQuery = (api, resultCheck, handleLinklySuccess) => {
145
147
  _log("AbortError" /* AbortError */);
146
148
  console.log("Error: 请求被取消,将继续查询");
147
149
  isQueryFinishedRef.current = false;
148
- setTimeout(() => {
150
+ queryIntervalTimerRef.current = setTimeout(() => {
149
151
  _resultQuery();
150
- }, 1500);
152
+ }, QUERY_INTERVAL);
151
153
  return;
152
154
  }
153
155
  if (!(error == null ? void 0 : error.code) || `${error.code}` === import_const.PayStatus.Timeout) {
154
156
  _log("NetworkError" /* NetworkError */);
155
157
  console.log("Error: 网关类报错,将继续查询");
156
158
  isQueryFinishedRef.current = false;
157
- setTimeout(() => {
159
+ queryIntervalTimerRef.current = setTimeout(() => {
158
160
  _resultQuery();
159
- }, 1500);
161
+ }, QUERY_INTERVAL);
160
162
  return;
161
163
  }
162
164
  _log("Error" /* Error */, error);
@@ -203,6 +205,10 @@ var useTimeResultQuery = (api, resultCheck, handleLinklySuccess) => {
203
205
  clearTimeout(requestTimeoutIdRef.current);
204
206
  requestTimeoutIdRef.current = null;
205
207
  }
208
+ if (queryIntervalTimerRef.current) {
209
+ clearTimeout(queryIntervalTimerRef.current);
210
+ queryIntervalTimerRef.current = null;
211
+ }
206
212
  if (controllerRef.current) {
207
213
  controllerRef.current.abort();
208
214
  controllerRef.current = null;
@@ -42,6 +42,7 @@ var import_helper = require("../helper");
42
42
  var import_hooks = require("../hooks");
43
43
  var import_store = require("../store");
44
44
  var import_hooks2 = require("./hooks");
45
+ var import_payment = require("./payment");
45
46
  var POS = ({
46
47
  api,
47
48
  onChange
@@ -68,6 +69,13 @@ var POS = ({
68
69
  const initRef = (0, import_react.useRef)(false);
69
70
  const unloadRef = (0, import_react.useRef)(false);
70
71
  const [check] = (0, import_hooks2.useValidate)(1e3 * 60);
72
+ const { run: paymentRun, clean: paymentClean } = (0, import_payment.usePayment)({
73
+ payApi: api.pay,
74
+ checkApi: api.check,
75
+ shouldContinue: () => {
76
+ return !(unloadRef.current || !netRef.current);
77
+ }
78
+ });
71
79
  (0, import_react.useEffect)(() => {
72
80
  failRef.current = fail;
73
81
  }, [fail]);
@@ -126,7 +134,7 @@ var POS = ({
126
134
  );
127
135
  };
128
136
  (0, import_react.useEffect)(() => {
129
- var _a, _b;
137
+ var _a, _b, _c;
130
138
  if (statusRef.current === import_const.StatusEnum.Success || statusRef.current === import_const.StatusEnum.Fail) {
131
139
  return;
132
140
  }
@@ -145,82 +153,98 @@ var POS = ({
145
153
  })
146
154
  );
147
155
  controllerRef.current = new AbortController();
148
- const resultPromise = modeRef.current === import_const.ModeEnum.Pay || modeRef.current === import_const.ModeEnum.FullPay ? api.pay(
149
- {
150
- ...(custom == null ? void 0 : custom.platform) ? {
151
- operator_id: custom.operator_id,
152
- operator_type: custom.operator_type,
153
- platform: custom.platform,
154
- custom_payment_id: custom.custom_payment_id,
155
- service_charge: {
156
- amount: payRef.current.surMoney,
157
- percentage: payRef.current.surPercentRate
158
- },
159
- original_amount: payRef.current.amount
160
- } : {},
161
- order_id: orderIdRef.current,
162
- amount: payRef.current.total,
163
- card_reader_type: eftposRef.current,
164
- card_reader_id: (_a = deviceRef.current) == null ? void 0 : _a.id,
165
- number: numRef.current,
166
- pay_param_base64: encodeURIComponent(
167
- btoa(
168
- encodeURIComponent(
169
- JSON.stringify({
170
- ...dataRef.current,
171
- number: numRef.current
172
- })
173
- )
156
+ const isPay = modeRef.current === import_const.ModeEnum.Pay || modeRef.current === import_const.ModeEnum.FullPay;
157
+ const apiParams = isPay ? {
158
+ ...(custom == null ? void 0 : custom.platform) ? {
159
+ operator_id: custom.operator_id,
160
+ operator_type: custom.operator_type,
161
+ platform: custom.platform,
162
+ custom_payment_id: custom.custom_payment_id
163
+ } : {},
164
+ original_amount: payRef.current.amount,
165
+ service_charge: {
166
+ amount: payRef.current.surMoney,
167
+ percentage: payRef.current.surPercentRate
168
+ },
169
+ order_id: orderIdRef.current,
170
+ amount: payRef.current.total,
171
+ card_reader_type: eftposRef.current,
172
+ card_reader_id: (_a = deviceRef.current) == null ? void 0 : _a.id,
173
+ number: numRef.current,
174
+ pay_param_base64: encodeURIComponent(
175
+ btoa(
176
+ encodeURIComponent(
177
+ JSON.stringify({
178
+ ...dataRef.current,
179
+ number: numRef.current
180
+ })
174
181
  )
175
182
  )
176
- },
177
- { signal: controllerRef.current.signal }
178
- ) : api.refund(
179
- {
180
- order_id: orderIdRef.current,
181
- amount: amountRef.current,
182
- card_reader_type: eftposRef.current,
183
- card_reader_id: (_b = deviceRef.current) == null ? void 0 : _b.id,
184
- number: numRef.current,
185
- pay_param_base64: encodeURIComponent(
186
- btoa(
187
- encodeURIComponent(
188
- JSON.stringify({
189
- ...dataRef.current,
190
- number: numRef.current
191
- })
192
- )
183
+ )
184
+ } : {
185
+ order_id: orderIdRef.current,
186
+ amount: amountRef.current,
187
+ card_reader_type: eftposRef.current,
188
+ card_reader_id: (_b = deviceRef.current) == null ? void 0 : _b.id,
189
+ number: numRef.current,
190
+ pay_param_base64: encodeURIComponent(
191
+ btoa(
192
+ encodeURIComponent(
193
+ JSON.stringify({
194
+ ...dataRef.current,
195
+ number: numRef.current
196
+ })
193
197
  )
194
198
  )
195
- },
196
- { signal: controllerRef.current.signal }
197
- );
198
- resultPromise.then((res) => {
199
- console.log("netRef.current111 = ", netRef.current);
200
- if (unloadRef.current || !netRef.current) {
201
- return;
202
- }
203
- if (res && `${res.code}` === "200") {
204
- success(res);
205
- return;
206
- }
207
- return Promise.reject(res);
208
- }).catch((err) => {
209
- console.log(
210
- "netRef.current222 = ",
211
- netRef.current,
212
- unloadRef.current,
213
- err
214
- );
215
- if (unloadRef.current || !netRef.current) {
216
- return;
217
- }
218
- if (!(err == null ? void 0 : err.code) || `${err.code}` === import_const.PayStatus.Timeout) {
219
- checkApi();
220
- return;
221
- }
222
- failRef.current(err, true);
223
- });
199
+ )
200
+ };
201
+ if (isPay) {
202
+ paymentRun({
203
+ paymentType: import_payment.ActionType.Pay,
204
+ paymentNum: numRef.current,
205
+ orderId: orderIdRef.current,
206
+ deviceId: (_c = deviceRef.current) == null ? void 0 : _c.id,
207
+ params: apiParams,
208
+ callbacks: {
209
+ onSuccess: (res) => {
210
+ success(res);
211
+ },
212
+ onError: (err) => {
213
+ console.log("err = >>>>>", err);
214
+ failRef.current(err, true);
215
+ }
216
+ }
217
+ });
218
+ return;
219
+ } else {
220
+ const resultPromise = api.refund(apiParams, { signal: controllerRef.current.signal });
221
+ resultPromise.then((res) => {
222
+ console.log("netRef.current111 = ", netRef.current);
223
+ if (unloadRef.current || !netRef.current) {
224
+ return;
225
+ }
226
+ if (res && `${res.code}` === "200") {
227
+ success(res);
228
+ return;
229
+ }
230
+ return Promise.reject(res);
231
+ }).catch((err) => {
232
+ console.log(
233
+ "netRef.current222 = ",
234
+ netRef.current,
235
+ unloadRef.current,
236
+ err
237
+ );
238
+ if (unloadRef.current || !netRef.current) {
239
+ return;
240
+ }
241
+ if (!(err == null ? void 0 : err.code) || `${err.code}` === import_const.PayStatus.Timeout) {
242
+ checkApi();
243
+ return;
244
+ }
245
+ failRef.current(err, true);
246
+ });
247
+ }
224
248
  }, [api, check, dispatch, onChange]);
225
249
  (0, import_react.useEffect)(
226
250
  () => () => {
@@ -230,6 +254,7 @@ var POS = ({
230
254
  if (clearRef.current) {
231
255
  clearTimeout(clearRef.current);
232
256
  }
257
+ paymentClean();
233
258
  },
234
259
  []
235
260
  );
@@ -0,0 +1,66 @@
1
+ interface RunApiParams {
2
+ [key: string]: any;
3
+ }
4
+ export declare enum ActionType {
5
+ Pay = "pay",
6
+ Refund = "refund",
7
+ Query = "query"
8
+ }
9
+ interface UsePaymentOptions {
10
+ /**
11
+ * 支付接口
12
+ */
13
+ payApi: (params: RunApiParams, options?: {
14
+ signal?: AbortSignal;
15
+ }) => Promise<any>;
16
+ /**
17
+ * 退款接口
18
+ */
19
+ refundApi?: (params: RunApiParams, options?: {
20
+ signal?: AbortSignal;
21
+ }) => Promise<any>;
22
+ /**
23
+ * 查询接口
24
+ */
25
+ checkApi: (params: {
26
+ number: string;
27
+ }, options?: {
28
+ signal?: AbortSignal;
29
+ }) => Promise<any>;
30
+ /**
31
+ * 检查是否应该继续处理结果(用于处理网络断开、组件卸载等情况)
32
+ */
33
+ shouldContinue?: () => boolean;
34
+ }
35
+ interface RunParams {
36
+ /** 支付类型 */
37
+ paymentType: ActionType;
38
+ /** 支付交易号 */
39
+ paymentNum: string;
40
+ /** 订单ID */
41
+ orderId?: string | number;
42
+ /** 设备ID */
43
+ deviceId?: string | number;
44
+ /** 支付参数 */
45
+ params: RunApiParams;
46
+ /** 回调方法 */
47
+ callbacks: RunCallbacks;
48
+ }
49
+ interface RunCallbacks {
50
+ /**
51
+ * 成功回调
52
+ */
53
+ onSuccess: (res: any) => void;
54
+ /**
55
+ * 失败回调
56
+ */
57
+ onError: (error: any) => void;
58
+ }
59
+ export declare const usePayment: (options: UsePaymentOptions) => {
60
+ run: (options: RunParams) => Promise<void>;
61
+ stop: () => void;
62
+ clean: (params?: {
63
+ clearCallbacks?: boolean;
64
+ }) => void;
65
+ };
66
+ export {};