@pisell/private-materials 3.4.51 → 3.4.53

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 (128) 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 +2 -2
  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 +10 -10
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +10 -10
  11. package/es/components/booking/addons/model.d.ts +10 -1
  12. package/es/components/booking/forms/model.d.ts +10 -1
  13. package/es/components/booking/info/model.d.ts +10 -1
  14. package/es/components/booking/info/service/addService/utils.d.ts +1 -1
  15. package/es/components/booking/info2/service/addService/utils.d.ts +1 -1
  16. package/es/components/booking/model.d.ts +9 -1
  17. package/es/components/booking/notes/model.d.ts +10 -1
  18. package/es/components/booking/payments/model.d.ts +10 -1
  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/utils/log/index.d.ts +110 -0
  24. package/es/components/eftposPay/utils/log/index.js +371 -0
  25. package/es/components/index.d.ts +2 -1
  26. package/es/components/index.js +2 -1
  27. package/es/components/pay/toC/model.d.ts +9 -1
  28. package/es/components/schedules/model.d.ts +9 -1
  29. package/es/components/systemSettings/registry/components/GroupModal.d.ts +4 -0
  30. package/es/components/systemSettings/registry/components/GroupModal.js +160 -0
  31. package/es/components/systemSettings/registry/components/ItemModal.d.ts +4 -0
  32. package/es/components/systemSettings/registry/components/ItemModal.js +547 -0
  33. package/es/components/systemSettings/registry/components/ModuleList.d.ts +4 -0
  34. package/es/components/systemSettings/registry/components/ModuleList.js +54 -0
  35. package/es/components/systemSettings/registry/components/SectionList.d.ts +4 -0
  36. package/es/components/systemSettings/registry/components/SectionList.js +174 -0
  37. package/es/components/systemSettings/registry/components/SettingsTable.d.ts +4 -0
  38. package/es/components/systemSettings/registry/components/SettingsTable.js +765 -0
  39. package/es/components/systemSettings/registry/components/index.d.ts +4 -0
  40. package/es/components/systemSettings/registry/components/index.js +4 -0
  41. package/es/components/systemSettings/registry/index.d.ts +5 -0
  42. package/es/components/systemSettings/registry/index.js +1059 -0
  43. package/es/components/systemSettings/registry/index.less +410 -0
  44. package/es/components/systemSettings/registry/locales.d.ts +272 -0
  45. package/es/components/systemSettings/registry/locales.js +300 -0
  46. package/es/components/systemSettings/registry/services.d.ts +77 -0
  47. package/es/components/systemSettings/registry/services.js +472 -0
  48. package/es/components/systemSettings/registry/types.d.ts +126 -0
  49. package/es/components/systemSettings/registry/types.js +1 -0
  50. package/es/components/systemSettings/registry/utils/typeValidation.d.ts +16 -0
  51. package/es/components/systemSettings/registry/utils/typeValidation.js +284 -0
  52. package/es/components/systemSettings/registry/utils/validators.d.ts +8 -0
  53. package/es/components/systemSettings/registry/utils/validators.js +44 -0
  54. package/es/components/wallet/Detail/model.d.ts +13 -1
  55. package/es/components/wallet/DiscountCard/model.d.ts +14 -1
  56. package/es/components/wallet/PointCard/model.d.ts +13 -1
  57. package/es/components/wallet/RechargeableCard/model.d.ts +29 -1
  58. package/es/components/wallet/Voucher/model.d.ts +13 -1
  59. package/es/components/wallet/model.d.ts +9 -1
  60. package/es/index.d.ts +2 -0
  61. package/es/index.js +3 -1
  62. package/es/plus/walletPassGallery/components/footerButton/index.js +2 -4
  63. package/es/plus/walletPassGallery/components/footerButton/index.less +14 -59
  64. package/es/plus/walletPassGallery/components/passDetail/index.js +5 -1
  65. package/es/plus/walletPassGallery/components/passDetail/index.less +4 -0
  66. package/es/plus/walletPassGallery/components/recharge/index.js +19 -8
  67. package/es/plus/walletPassGallery/index.js +3 -1
  68. package/es/pro/Login2.0/index.less +15 -8
  69. package/lib/components/booking/addons/model.d.ts +10 -1
  70. package/lib/components/booking/forms/model.d.ts +10 -1
  71. package/lib/components/booking/info/model.d.ts +10 -1
  72. package/lib/components/booking/info/service/addService/utils.d.ts +1 -1
  73. package/lib/components/booking/info2/service/addService/utils.d.ts +1 -1
  74. package/lib/components/booking/model.d.ts +9 -1
  75. package/lib/components/booking/notes/model.d.ts +10 -1
  76. package/lib/components/booking/payments/model.d.ts +10 -1
  77. package/lib/components/eftposPay/linkly/hooks/useTimeQuery.js +12 -6
  78. package/lib/components/eftposPay/payo/config.js +98 -73
  79. package/lib/components/eftposPay/payo/payment.d.ts +66 -0
  80. package/lib/components/eftposPay/payo/payment.js +357 -0
  81. package/lib/components/eftposPay/utils/log/index.d.ts +110 -0
  82. package/lib/components/eftposPay/utils/log/index.js +294 -0
  83. package/lib/components/index.d.ts +2 -1
  84. package/lib/components/index.js +3 -0
  85. package/lib/components/pay/toC/model.d.ts +9 -1
  86. package/lib/components/schedules/model.d.ts +9 -1
  87. package/lib/components/systemSettings/registry/components/GroupModal.d.ts +4 -0
  88. package/lib/components/systemSettings/registry/components/GroupModal.js +177 -0
  89. package/lib/components/systemSettings/registry/components/ItemModal.d.ts +4 -0
  90. package/lib/components/systemSettings/registry/components/ItemModal.js +508 -0
  91. package/lib/components/systemSettings/registry/components/ModuleList.d.ts +4 -0
  92. package/lib/components/systemSettings/registry/components/ModuleList.js +71 -0
  93. package/lib/components/systemSettings/registry/components/SectionList.d.ts +4 -0
  94. package/lib/components/systemSettings/registry/components/SectionList.js +181 -0
  95. package/lib/components/systemSettings/registry/components/SettingsTable.d.ts +4 -0
  96. package/lib/components/systemSettings/registry/components/SettingsTable.js +575 -0
  97. package/lib/components/systemSettings/registry/components/index.d.ts +4 -0
  98. package/lib/components/systemSettings/registry/components/index.js +48 -0
  99. package/lib/components/systemSettings/registry/index.d.ts +5 -0
  100. package/lib/components/systemSettings/registry/index.js +529 -0
  101. package/lib/components/systemSettings/registry/index.less +410 -0
  102. package/lib/components/systemSettings/registry/locales.d.ts +272 -0
  103. package/lib/components/systemSettings/registry/locales.js +324 -0
  104. package/lib/components/systemSettings/registry/services.d.ts +77 -0
  105. package/lib/components/systemSettings/registry/services.js +290 -0
  106. package/lib/components/systemSettings/registry/types.d.ts +126 -0
  107. package/lib/components/systemSettings/registry/types.js +17 -0
  108. package/lib/components/systemSettings/registry/utils/typeValidation.d.ts +16 -0
  109. package/lib/components/systemSettings/registry/utils/typeValidation.js +228 -0
  110. package/lib/components/systemSettings/registry/utils/validators.d.ts +8 -0
  111. package/lib/components/systemSettings/registry/utils/validators.js +54 -0
  112. package/lib/components/wallet/Detail/model.d.ts +13 -1
  113. package/lib/components/wallet/DiscountCard/model.d.ts +14 -1
  114. package/lib/components/wallet/PointCard/model.d.ts +13 -1
  115. package/lib/components/wallet/RechargeableCard/model.d.ts +29 -1
  116. package/lib/components/wallet/Voucher/model.d.ts +13 -1
  117. package/lib/components/wallet/model.d.ts +9 -1
  118. package/lib/index.d.ts +2 -0
  119. package/lib/index.js +6 -0
  120. package/lib/plus/walletPassGallery/components/footerButton/index.js +2 -2
  121. package/lib/plus/walletPassGallery/components/footerButton/index.less +14 -59
  122. package/lib/plus/walletPassGallery/components/passDetail/index.js +4 -1
  123. package/lib/plus/walletPassGallery/components/passDetail/index.less +4 -0
  124. package/lib/plus/walletPassGallery/components/recharge/index.js +7 -1
  125. package/lib/plus/walletPassGallery/index.js +3 -1
  126. package/lib/pro/Login2.0/index.less +15 -8
  127. package/lowcode/settings-registry/meta.ts +29 -0
  128. package/package.json +4 -4
@@ -32,6 +32,10 @@ var Recharge = function Recharge(_ref) {
32
32
  storage = _ref2.storage;
33
33
  var dvaStore = (_context$appHelper2 = context.appHelper) === null || _context$appHelper2 === void 0 || (_context$appHelper2 = _context$appHelper2.utils) === null || _context$appHelper2 === void 0 || (_context$appHelper2$g = _context$appHelper2.getStore) === null || _context$appHelper2$g === void 0 || (_context$appHelper2$g = _context$appHelper2$g.call(_context$appHelper2)) === null || _context$appHelper2$g === void 0 ? void 0 : _context$appHelper2$g.getState();
34
34
  var shop = (dvaStore === null || dvaStore === void 0 || (_dvaStore$core = dvaStore.core) === null || _dvaStore$core === void 0 || (_dvaStore$core = _dvaStore$core.core) === null || _dvaStore$core === void 0 ? void 0 : _dvaStore$core.shop) || {};
35
+ var _useState3 = useState(false),
36
+ _useState4 = _slicedToArray(_useState3, 2),
37
+ loading = _useState4[0],
38
+ setLoading = _useState4[1];
35
39
  useEffect(function () {
36
40
  if (detailData) {
37
41
  setChargeItem(((detailData === null || detailData === void 0 ? void 0 : detailData.gift_option) || [])[0]);
@@ -44,6 +48,7 @@ var Recharge = function Recharge(_ref) {
44
48
  while (1) switch (_context.prev = _context.next) {
45
49
  case 0:
46
50
  _context.prev = 0;
51
+ setLoading(true);
47
52
  params = {
48
53
  voucher_id: (detailData === null || detailData === void 0 ? void 0 : detailData.id) || '',
49
54
  product_id: (detailData === null || detailData === void 0 ? void 0 : detailData.product_id) || '',
@@ -57,9 +62,9 @@ var Recharge = function Recharge(_ref) {
57
62
  currency_format: (shop === null || shop === void 0 ? void 0 : shop.currency_format) || ''
58
63
  }
59
64
  };
60
- _context.next = 4;
65
+ _context.next = 5;
61
66
  return orderRechargeProduct(params);
62
- case 4:
67
+ case 5:
63
68
  data = _context.sent;
64
69
  if (data !== null && data !== void 0 && data.order_id) {
65
70
  storage === null || storage === void 0 || (_storage$set = storage.set) === null || _storage$set === void 0 || _storage$set.call(storage, 'orderId', data.order_id);
@@ -69,23 +74,28 @@ var Recharge = function Recharge(_ref) {
69
74
  callback: function callback() {}
70
75
  });
71
76
  }
72
- _context.next = 11;
77
+ _context.next = 12;
73
78
  break;
74
- case 8:
75
- _context.prev = 8;
79
+ case 9:
80
+ _context.prev = 9;
76
81
  _context.t0 = _context["catch"](0);
77
82
  console.error(locales.getText('wallet-pass-gallery.log.rechargeOrderFailed'), _context.t0);
78
- case 11:
83
+ case 12:
84
+ _context.prev = 12;
85
+ setLoading(false);
86
+ return _context.finish(12);
87
+ case 15:
79
88
  case "end":
80
89
  return _context.stop();
81
90
  }
82
- }, _callee, null, [[0, 8]]);
91
+ }, _callee, null, [[0, 9, 12, 15]]);
83
92
  }));
84
93
  return function handleRecharge() {
85
94
  return _ref3.apply(this, arguments);
86
95
  };
87
96
  }();
88
97
  return /*#__PURE__*/React.createElement(Drawer, {
98
+ destroyOnClose: true,
89
99
  title: locales.getText('wallet-pass-gallery.rechargeOptions'),
90
100
  open: open,
91
101
  zIndex: 999,
@@ -97,7 +107,8 @@ var Recharge = function Recharge(_ref) {
97
107
  block: true,
98
108
  size: "large",
99
109
  onClick: handleRecharge,
100
- disabled: !(chargeItem !== null && chargeItem !== void 0 && chargeItem.id)
110
+ disabled: !(chargeItem !== null && chargeItem !== void 0 && chargeItem.id),
111
+ loading: loading
101
112
  }, locales.getText('wallet-pass-gallery.recharge'))
102
113
  }, /*#__PURE__*/React.createElement("div", {
103
114
  className: "pisell-wallet-pass-gallery_recharge"
@@ -552,7 +552,9 @@ var WalletPassGallery = function WalletPassGallery(props) {
552
552
  },
553
553
  block: true
554
554
  }, locales.getText('wallet-pass-gallery.button.add'))), /*#__PURE__*/React.createElement(PisellModal, {
555
- platform: 'h5',
555
+ zIndex: 997,
556
+ destroyOnClose: true,
557
+ platform: platform,
556
558
  visible: !!_currentItem,
557
559
  onCancel: function onCancel() {
558
560
  return setCurrentItemId('');
@@ -15,6 +15,14 @@
15
15
 
16
16
  /* 默认底部内边距 */
17
17
  padding-bottom: 24px;
18
+
19
+ // 加载状态优化
20
+ .pisell-lowcode-btn-loading-icon {
21
+ .anticon {
22
+ color: #ffffff !important;
23
+ }
24
+ }
25
+
18
26
 
19
27
  /* 在弹窗模式下不需要额外的底部内边距,因为使用 sticky 定位 */
20
28
  .pisell-lowcode-modal-body & {
@@ -462,6 +470,13 @@
462
470
  .login-lm-drawer-popover & {
463
471
  padding-bottom: 100px;
464
472
  }
473
+ // 加载状态优化
474
+ .pisell-lowcode-btn-loading-icon {
475
+ .anticon {
476
+ color: #ffffff !important;
477
+ }
478
+ }
479
+
465
480
  }
466
481
 
467
482
  // 错误提示样式优化
@@ -521,14 +536,6 @@
521
536
  // }
522
537
  // }
523
538
  // }
524
-
525
- // 加载状态优化
526
- .pisell-lowcode-btn-loading-icon {
527
- .anticon {
528
- color: #ffffff !important;
529
- }
530
- }
531
-
532
539
  // 切换认证方式按钮
533
540
  .login2-switch-button {
534
541
  margin-top: 0;
@@ -1 +1,10 @@
1
- export declare const Provider: any, Context: any;
1
+ /// <reference types="react" />
2
+ import { FormState } from "../model";
3
+ export declare const Provider: (ComponentUi: any) => any, Context: import("react").Context<{
4
+ state: FormState;
5
+ } & {
6
+ dispatch: (params: {
7
+ type: string;
8
+ payload: any;
9
+ }) => void;
10
+ }>;
@@ -1 +1,10 @@
1
- export declare const Provider: any, Context: any;
1
+ /// <reference types="react" />
2
+ import { FormState } from "../model";
3
+ export declare const Provider: (ComponentUi: any) => any, Context: import("react").Context<{
4
+ state: FormState;
5
+ } & {
6
+ dispatch: (params: {
7
+ type: string;
8
+ payload: any;
9
+ }) => void;
10
+ }>;
@@ -1,5 +1,14 @@
1
+ /// <reference types="react" />
2
+ import { FormState } from '../model';
1
3
  export declare const walkInData: {
2
4
  id: number;
3
5
  nickname: string;
4
6
  };
5
- export declare const Provider: any, Context: any;
7
+ export declare const Provider: (ComponentUi: any) => any, Context: import("react").Context<{
8
+ state: FormState;
9
+ } & {
10
+ dispatch: (params: {
11
+ type: string;
12
+ payload: any;
13
+ }) => void;
14
+ }>;
@@ -6,7 +6,7 @@ export declare const getDurationProps: ({ cacheItem, useStartTime, currentResour
6
6
  type: string;
7
7
  value: number;
8
8
  };
9
- locale: any;
9
+ locale: string;
10
10
  slice: any;
11
11
  selectProps: {
12
12
  size: string;
@@ -7,7 +7,7 @@ export declare const getDurationProps: ({ cacheItem, useStartTime, currentResour
7
7
  type: string;
8
8
  value: number;
9
9
  };
10
- locale: any;
10
+ locale: string;
11
11
  slice: any;
12
12
  selectProps: {
13
13
  size: string;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export interface FormState {
2
3
  amountSymbol: string;
3
4
  apis: {
@@ -108,4 +109,11 @@ export declare const walkInData: {
108
109
  id: number;
109
110
  nickname: string;
110
111
  };
111
- export declare const Provider: any, Context: any;
112
+ export declare const Provider: (ComponentUi: any) => any, Context: import("react").Context<{
113
+ state: FormState;
114
+ } & {
115
+ dispatch: (params: {
116
+ type: string;
117
+ payload: any;
118
+ }) => void;
119
+ }>;
@@ -1 +1,10 @@
1
- export declare const Provider: any, Context: any;
1
+ /// <reference types="react" />
2
+ import { FormState } from "../model";
3
+ export declare const Provider: (ComponentUi: any) => any, Context: import("react").Context<{
4
+ state: FormState;
5
+ } & {
6
+ dispatch: (params: {
7
+ type: string;
8
+ payload: any;
9
+ }) => void;
10
+ }>;
@@ -1 +1,10 @@
1
- export declare const Provider: any, Context: any;
1
+ /// <reference types="react" />
2
+ import { FormState } from "../model";
3
+ export declare const Provider: (ComponentUi: any) => any, Context: import("react").Context<{
4
+ state: FormState;
5
+ } & {
6
+ dispatch: (params: {
7
+ type: string;
8
+ payload: any;
9
+ }) => void;
10
+ }>;
@@ -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 {};