@pisell/private-materials 3.0.136 → 3.0.138

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 (219) 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 +12 -12
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +11 -11
  11. package/es/components/booking/forms/single/index.js +3 -0
  12. package/es/components/eftpos/const.d.ts +26 -0
  13. package/es/components/eftpos/const.js +40 -8
  14. package/es/components/eftpos/device.d.ts +3 -2
  15. package/es/components/eftpos/device.js +6 -5
  16. package/es/components/eftpos/form/index.d.ts +5 -0
  17. package/es/components/eftpos/form/index.js +8 -0
  18. package/es/components/eftpos/hooks.d.ts +34 -0
  19. package/es/components/{eftposPay/windcave/hook.js → eftpos/hooks.js} +96 -122
  20. package/es/components/eftpos/icon/apiKey.d.ts +5 -0
  21. package/es/components/eftpos/icon/apiKey.js +17 -0
  22. package/es/components/eftpos/icon/device.d.ts +5 -0
  23. package/es/components/eftpos/icon/device.js +19 -0
  24. package/es/components/eftpos/index.d.ts +10 -0
  25. package/es/components/eftpos/index.js +329 -46
  26. package/es/components/eftpos/index.less +38 -1
  27. package/es/components/eftpos/locales.d.ts +12 -0
  28. package/es/components/eftpos/locales.js +15 -3
  29. package/es/components/eftpos/log.d.ts +8 -0
  30. package/es/components/eftpos/log.js +85 -0
  31. package/es/components/eftpos/pos.d.ts +1 -1
  32. package/es/components/eftpos/pos.js +8 -5
  33. package/es/components/eftpos/surcharge/index.d.ts +25 -2
  34. package/es/components/eftpos/surcharge/index.js +100 -16
  35. package/es/components/eftpos/table.d.ts +4 -0
  36. package/es/components/eftpos/table.js +102 -10
  37. package/es/components/eftposPay/amount.d.ts +7 -1
  38. package/es/components/eftposPay/amount.js +65 -38
  39. package/es/components/eftposPay/component/fail/failCustom.js +65 -20
  40. package/es/components/eftposPay/component/fail/index.js +60 -30
  41. package/es/components/eftposPay/component/fail/network.d.ts +5 -0
  42. package/es/components/eftposPay/component/fail/network.js +13 -0
  43. package/es/components/eftposPay/component/fail/unknow.d.ts +6 -0
  44. package/es/components/eftposPay/component/fail/unknow.js +18 -3
  45. package/es/components/eftposPay/component/header/index.d.ts +2 -1
  46. package/es/components/eftposPay/component/header/index.js +4 -1
  47. package/es/components/eftposPay/component/header/index.less +1 -10
  48. package/es/components/eftposPay/component/manual/index.d.ts +6 -1
  49. package/es/components/eftposPay/component/manual/index.js +174 -23
  50. package/es/components/eftposPay/component/manual/index.less +42 -14
  51. package/es/components/eftposPay/component/signature/index.d.ts +5 -0
  52. package/es/components/eftposPay/component/signature/index.js +20 -2
  53. package/es/components/eftposPay/component/step/index.d.ts +7 -7
  54. package/es/components/eftposPay/component/step/step.d.ts +4 -4
  55. package/es/components/eftposPay/const.d.ts +19 -4
  56. package/es/components/eftposPay/const.js +4 -2
  57. package/es/components/eftposPay/device.d.ts +7 -0
  58. package/es/components/eftposPay/device.js +22 -0
  59. package/es/components/eftposPay/helper.d.ts +54 -0
  60. package/es/components/eftposPay/helper.js +93 -1
  61. package/es/components/eftposPay/hooks.d.ts +30 -1
  62. package/es/components/eftposPay/hooks.js +181 -26
  63. package/es/components/eftposPay/index.d.ts +2 -4
  64. package/es/components/eftposPay/index.js +119 -31
  65. package/es/components/eftposPay/index.less +27 -19
  66. package/es/components/eftposPay/locales.d.ts +45 -0
  67. package/es/components/eftposPay/locales.js +348 -3
  68. package/es/components/eftposPay/manufacturer.d.ts +2 -2
  69. package/es/components/eftposPay/manufacturer.js +9 -10
  70. package/es/components/eftposPay/pay.d.ts +10 -1
  71. package/es/components/eftposPay/pay.js +112 -34
  72. package/es/components/eftposPay/payo/config.js +137 -270
  73. package/es/components/eftposPay/payo/const.d.ts +22 -2
  74. package/es/components/eftposPay/payo/const.js +83 -33
  75. package/es/components/eftposPay/payo/hooks.d.ts +5 -0
  76. package/es/components/eftposPay/payo/hooks.js +19 -2
  77. package/es/components/eftposPay/store/index.d.ts +154 -53
  78. package/es/components/eftposPay/store/index.js +112 -60
  79. package/es/components/eftposPay/tyro/const.d.ts +17 -0
  80. package/es/components/eftposPay/{eftpos → tyro}/const.js +71 -90
  81. package/es/components/eftposPay/tyro/hooks.d.ts +14 -0
  82. package/es/components/eftposPay/tyro/hooks.js +40 -0
  83. package/es/components/eftposPay/tyro/index.d.ts +9 -0
  84. package/es/components/eftposPay/tyro/index.js +575 -0
  85. package/es/components/eftposPay/windcave/const.d.ts +24 -9
  86. package/es/components/eftposPay/windcave/const.js +90 -81
  87. package/es/components/eftposPay/windcave/helper.d.ts +16 -2
  88. package/es/components/eftposPay/windcave/helper.js +175 -42
  89. package/es/components/eftposPay/windcave/receiptAction.d.ts +12 -0
  90. package/es/components/eftposPay/windcave/receiptAction.js +91 -43
  91. package/es/components/eftposPay/windcave/timer.d.ts +13 -1
  92. package/es/components/eftposPay/windcave/timer.js +18 -1
  93. package/es/components/eftposPay/windcave/windcave.d.ts +2 -1
  94. package/es/components/eftposPay/windcave/windcave.js +155 -139
  95. package/es/utils/load.d.ts +11 -0
  96. package/es/utils/load.js +85 -0
  97. package/lib/components/booking/forms/single/index.js +1 -0
  98. package/lib/components/eftpos/const.d.ts +26 -0
  99. package/lib/components/eftpos/const.js +13 -1
  100. package/lib/components/eftpos/device.d.ts +3 -2
  101. package/lib/components/eftpos/device.js +2 -2
  102. package/lib/components/eftpos/form/index.d.ts +5 -0
  103. package/lib/components/eftpos/hooks.d.ts +34 -0
  104. package/lib/components/eftpos/hooks.js +106 -0
  105. package/lib/components/eftpos/icon/apiKey.d.ts +5 -0
  106. package/lib/components/eftpos/icon/apiKey.js +57 -0
  107. package/lib/components/eftpos/icon/device.d.ts +5 -0
  108. package/lib/components/eftpos/icon/device.js +57 -0
  109. package/lib/components/eftpos/index.d.ts +10 -0
  110. package/lib/components/eftpos/index.js +262 -97
  111. package/lib/components/eftpos/index.less +38 -1
  112. package/lib/components/eftpos/locales.d.ts +12 -0
  113. package/lib/components/eftpos/locales.js +15 -3
  114. package/lib/components/eftpos/log.d.ts +8 -0
  115. package/lib/components/eftpos/log.js +87 -0
  116. package/lib/components/eftpos/pos.d.ts +1 -1
  117. package/lib/components/eftpos/pos.js +5 -4
  118. package/lib/components/eftpos/surcharge/index.d.ts +25 -2
  119. package/lib/components/eftpos/surcharge/index.js +36 -6
  120. package/lib/components/eftpos/table.d.ts +4 -0
  121. package/lib/components/eftpos/table.js +40 -8
  122. package/lib/components/eftposPay/amount.d.ts +7 -1
  123. package/lib/components/eftposPay/amount.js +10 -33
  124. package/lib/components/eftposPay/component/fail/failCustom.js +27 -6
  125. package/lib/components/eftposPay/component/fail/index.js +39 -18
  126. package/lib/components/eftposPay/component/fail/network.d.ts +5 -0
  127. package/lib/components/eftposPay/component/fail/unknow.d.ts +6 -0
  128. package/lib/components/eftposPay/component/fail/unknow.js +3 -3
  129. package/lib/components/eftposPay/component/header/index.d.ts +2 -1
  130. package/lib/components/eftposPay/component/header/index.js +2 -1
  131. package/lib/components/eftposPay/component/header/index.less +1 -10
  132. package/lib/components/eftposPay/component/manual/index.d.ts +6 -1
  133. package/lib/components/eftposPay/component/manual/index.js +122 -31
  134. package/lib/components/eftposPay/component/manual/index.less +42 -14
  135. package/lib/components/eftposPay/component/signature/index.d.ts +5 -0
  136. package/lib/components/eftposPay/component/signature/index.js +2 -2
  137. package/lib/components/eftposPay/component/step/index.d.ts +7 -7
  138. package/lib/components/eftposPay/component/step/step.d.ts +4 -4
  139. package/lib/components/eftposPay/const.d.ts +19 -4
  140. package/lib/components/eftposPay/const.js +3 -1
  141. package/lib/components/eftposPay/device.d.ts +7 -0
  142. package/lib/components/eftposPay/helper.d.ts +54 -0
  143. package/lib/components/eftposPay/helper.js +64 -0
  144. package/lib/components/eftposPay/hooks.d.ts +30 -1
  145. package/lib/components/eftposPay/hooks.js +182 -44
  146. package/lib/components/eftposPay/index.d.ts +2 -4
  147. package/lib/components/eftposPay/index.js +74 -27
  148. package/lib/components/eftposPay/index.less +27 -19
  149. package/lib/components/eftposPay/locales.d.ts +45 -0
  150. package/lib/components/eftposPay/locales.js +352 -3
  151. package/lib/components/eftposPay/manufacturer.d.ts +2 -2
  152. package/lib/components/eftposPay/manufacturer.js +13 -13
  153. package/lib/components/eftposPay/pay.d.ts +10 -1
  154. package/lib/components/eftposPay/pay.js +86 -25
  155. package/lib/components/eftposPay/payo/config.js +121 -268
  156. package/lib/components/eftposPay/payo/const.d.ts +22 -2
  157. package/lib/components/eftposPay/payo/const.js +55 -36
  158. package/lib/components/eftposPay/payo/hooks.d.ts +5 -0
  159. package/lib/components/eftposPay/payo/hooks.js +1 -1
  160. package/lib/components/eftposPay/store/index.d.ts +154 -53
  161. package/lib/components/eftposPay/store/index.js +7 -66
  162. package/lib/components/eftposPay/tyro/const.d.ts +17 -0
  163. package/lib/components/eftposPay/tyro/const.js +114 -0
  164. package/lib/components/eftposPay/tyro/hooks.d.ts +14 -0
  165. package/lib/components/eftposPay/{eftpos/index.js → tyro/hooks.js} +31 -36
  166. package/lib/components/eftposPay/tyro/index.d.ts +9 -0
  167. package/lib/components/eftposPay/tyro/index.js +558 -0
  168. package/lib/components/eftposPay/windcave/const.d.ts +24 -9
  169. package/lib/components/eftposPay/windcave/const.js +53 -104
  170. package/lib/components/eftposPay/windcave/helper.d.ts +16 -2
  171. package/lib/components/eftposPay/windcave/helper.js +163 -48
  172. package/lib/components/eftposPay/windcave/receiptAction.d.ts +12 -0
  173. package/lib/components/eftposPay/windcave/receiptAction.js +15 -47
  174. package/lib/components/eftposPay/windcave/timer.d.ts +13 -1
  175. package/lib/components/eftposPay/windcave/timer.js +5 -0
  176. package/lib/components/eftposPay/windcave/windcave.d.ts +2 -1
  177. package/lib/components/eftposPay/windcave/windcave.js +130 -130
  178. package/lib/utils/load.d.ts +11 -0
  179. package/lib/utils/load.js +100 -0
  180. package/lowcode/eftpos/meta.ts +202 -160
  181. package/lowcode/eftpos-pay/meta.ts +45 -12
  182. package/package.json +4 -4
  183. package/es/components/eftposPay/eftpos/config.d.ts +0 -11
  184. package/es/components/eftposPay/eftpos/config.js +0 -178
  185. package/es/components/eftposPay/eftpos/const.d.ts +0 -10
  186. package/es/components/eftposPay/eftpos/index.d.ts +0 -7
  187. package/es/components/eftposPay/eftpos/index.js +0 -35
  188. package/es/components/eftposPay/windcave/action.d.ts +0 -8
  189. package/es/components/eftposPay/windcave/action.js +0 -104
  190. package/es/components/eftposPay/windcave/hook.d.ts +0 -14
  191. package/es/components/eftposPay/windcave/index.d.ts +0 -8
  192. package/es/components/eftposPay/windcave/index.js +0 -49
  193. package/es/components/eftposPay/windcave/pos.d.ts +0 -8
  194. package/es/components/eftposPay/windcave/pos.js +0 -180
  195. package/es/components/eftposPay/windcave/pwd.d.ts +0 -8
  196. package/es/components/eftposPay/windcave/pwd.js +0 -124
  197. package/es/components/eftposPay/windcave/receipet.d.ts +0 -6
  198. package/es/components/eftposPay/windcave/receipet.js +0 -67
  199. package/es/components/eftposPay/windcave/wait.d.ts +0 -12
  200. package/es/components/eftposPay/windcave/wait.js +0 -139
  201. package/lib/components/eftposPay/eftpos/config.d.ts +0 -11
  202. package/lib/components/eftposPay/eftpos/config.js +0 -199
  203. package/lib/components/eftposPay/eftpos/const.d.ts +0 -10
  204. package/lib/components/eftposPay/eftpos/const.js +0 -165
  205. package/lib/components/eftposPay/eftpos/index.d.ts +0 -7
  206. package/lib/components/eftposPay/windcave/action.d.ts +0 -8
  207. package/lib/components/eftposPay/windcave/action.js +0 -143
  208. package/lib/components/eftposPay/windcave/hook.d.ts +0 -14
  209. package/lib/components/eftposPay/windcave/hook.js +0 -139
  210. package/lib/components/eftposPay/windcave/index.d.ts +0 -8
  211. package/lib/components/eftposPay/windcave/index.js +0 -78
  212. package/lib/components/eftposPay/windcave/pos.d.ts +0 -8
  213. package/lib/components/eftposPay/windcave/pos.js +0 -197
  214. package/lib/components/eftposPay/windcave/pwd.d.ts +0 -8
  215. package/lib/components/eftposPay/windcave/pwd.js +0 -143
  216. package/lib/components/eftposPay/windcave/receipet.d.ts +0 -6
  217. package/lib/components/eftposPay/windcave/receipet.js +0 -93
  218. package/lib/components/eftposPay/windcave/wait.d.ts +0 -12
  219. package/lib/components/eftposPay/windcave/wait.js +0 -163
@@ -6,17 +6,27 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _ty
6
6
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
7
  /* eslint-disable @typescript-eslint/no-unused-expressions */
8
8
  import { locales } from '@pisell/utils';
9
- import React, { useCallback, useEffect, useRef } from 'react';
9
+ import { useCallback, useEffect, useRef } from 'react';
10
10
  import { StatusEnum, PayStatus } from "../const";
11
11
  import { useContextData, useDispatch, updateComponent, updateState, updateStatus, updateCustom, updateKey } from "../store";
12
12
  import { StepStatusEnum, getStepMapping, StemTypeEnum } from "./const";
13
+ import { useStoreRef } from "../hooks";
13
14
  import XhrTimer from "./timer";
14
15
  var Max4004 = 1;
16
+
17
+ /**
18
+ * @title: windcave 支付,退款,查询 错误逻辑处理
19
+ * @description: 动态步骤页 异常前往 FailCustom 页面
20
+ * @return null
21
+ * @Author: hongbing.wang
22
+ * @Date: 2024-08-12 10:29
23
+ */
15
24
  export var useFail = function useFail() {
16
25
  var dispatch = useDispatch();
17
26
  var _useContextData = useContextData(),
18
- custom = _useContextData.custom,
19
- mode = _useContextData.mode;
27
+ custom = _useContextData.custom;
28
+ var _useStoreRef = useStoreRef(),
29
+ modeRef = _useStoreRef.modeRef;
20
30
  var ref = useRef((custom === null || custom === void 0 ? void 0 : custom.retry) || 0);
21
31
  useEffect(function () {
22
32
  ref.current = (custom === null || custom === void 0 ? void 0 : custom.retry) || 0;
@@ -24,6 +34,7 @@ export var useFail = function useFail() {
24
34
  return useCallback(function (res) {
25
35
  var isMark = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
26
36
  if (!res || !res.code) {
37
+ // 去往未知处理页面
27
38
  dispatch(updateCustom({
28
39
  errorStatus: 'unknow' // unknow know
29
40
  }));
@@ -33,13 +44,14 @@ export var useFail = function useFail() {
33
44
  }
34
45
  var code = "".concat(res.code);
35
46
  if ("".concat(res.code) === PayStatus.Unknown) {
47
+ // 前往报错页 不可标记
36
48
  dispatch(updateCustom({
37
49
  failCustom: {
38
50
  isPosNetworkError: false,
39
51
  status: 'fail',
40
52
  fail: locales.getText('page.eftpos-pay.text.transaction.fail'),
41
53
  warn: null,
42
- title: locales.getText('page.eftpos-pay.text.failed')(mode)
54
+ title: locales.getText('page.eftpos-pay.text.failed')(modeRef.current)
43
55
  }
44
56
  }));
45
57
  dispatch(updateComponent('FailCustom'));
@@ -47,7 +59,9 @@ export var useFail = function useFail() {
47
59
  }
48
60
  console.log(code, ref.current, Max4004);
49
61
  if (code === PayStatus.NoPay) {
62
+ // 如果未查询到支付状态,则重新发起支付
50
63
  if (ref.current > Max4004) {
64
+ // 前往错误页 不可标记状态
51
65
  dispatch(updateCustom({
52
66
  retry: 0,
53
67
  failCustom: {
@@ -55,39 +69,57 @@ export var useFail = function useFail() {
55
69
  status: 'fail',
56
70
  fail: locales.getText('page.eftpos-pay.text.transaction.fail'),
57
71
  warn: null,
58
- titl: locales.getText('page.eftpos-pay.text.failed')(mode)
72
+ titl: locales.getText('page.eftpos-pay.text.failed')(modeRef.current)
59
73
  }
60
74
  }));
61
75
  dispatch(updateComponent('FailCustom'));
62
76
  return;
63
77
  }
78
+ // 重新支付 最多到重新发起2次
64
79
  ref.current += 1;
80
+ // 清掉 支付流水号
81
+ dispatch(updateState({
82
+ number: ''
83
+ }));
65
84
  dispatch(updateCustom({
66
85
  retry: ref.current,
67
- number: undefined,
68
- isPay: false,
69
86
  list: []
70
87
  }));
71
88
  dispatch(updateKey(Date.now()));
72
89
  return;
73
90
  }
74
- if (code === PayStatus.Timeout || code === PayStatus.PayTimeout) {
91
+ if (code === PayStatus.PayTimeout) {
92
+ dispatch(updateCustom({
93
+ failCustom: {
94
+ isPosNetworkError: false,
95
+ status: 'fail',
96
+ fail: locales.getText('page.eftpos-pay.text.transaction.fail.timeout'),
97
+ title: locales.getText('page.eftpos-pay.text.failed')(modeRef.current),
98
+ warn: null
99
+ }
100
+ }));
101
+ dispatch(updateComponent('FailCustom'));
102
+ return;
103
+ }
104
+ if (code === PayStatus.Timeout) {
75
105
  if (isMark) {
106
+ // 超时 前往标记页
76
107
  dispatch(updateState({
77
108
  manual: {
78
109
  title: locales.getText('page.eftpos-pay.text.timedout.title'),
79
- text: locales.getText('page.eftpos-pay.text.timedout.text')(mode)
110
+ text: locales.getText('page.eftpos-pay.text.timedout.text')(modeRef.current)
80
111
  }
81
112
  }));
82
113
  dispatch(updateComponent('Manual'));
83
114
  return;
84
115
  }
116
+ // 前往错误页 不可标记状态
85
117
  dispatch(updateCustom({
86
118
  failCustom: {
87
119
  isPosNetworkError: false,
88
120
  status: 'fail',
89
- fail: code === PayStatus.Timeout ? locales.getText('page.eftpos-pay.text.transaction.pay.fail.timeout') : locales.getText('page.eftpos-pay.text.transaction.fail.timeout'),
90
- title: locales.getText('page.eftpos-pay.text.failed')(mode),
121
+ fail: locales.getText('page.eftpos-pay.text.transaction.fail.timeout'),
122
+ title: locales.getText('page.eftpos-pay.text.failed')(modeRef.current),
91
123
  warn: null
92
124
  }
93
125
  }));
@@ -95,6 +127,7 @@ export var useFail = function useFail() {
95
127
  return;
96
128
  }
97
129
  if (code === PayStatus.PayOtherEftposFailed) {
130
+ // 前往错误页 不可标记状态
98
131
  dispatch(updateCustom({
99
132
  failCustom: {
100
133
  isPosNetworkError: false,
@@ -108,9 +141,9 @@ export var useFail = function useFail() {
108
141
  return;
109
142
  }
110
143
  if (code === PayStatus.PayCardErrorFailed) {
144
+ // 前往错误页 不可标记状态
111
145
  dispatch(updateCustom({
112
146
  failCustom: {
113
- isPosNetworkError: true,
114
147
  status: 'fail',
115
148
  fail: locales.getText('page.eftpos-pay.text.transaction.fail.cancel'),
116
149
  title: locales.getText('page.eftpos-pay.text.transaction.fail.cancel.title'),
@@ -121,18 +154,85 @@ export var useFail = function useFail() {
121
154
  return;
122
155
  }
123
156
  if (code === PayStatus.NoNetWork || code === PayStatus.SocketError) {
157
+ // 前往错误页 可标记状态
124
158
  dispatch(updateCustom({
125
159
  failCustom: {
126
160
  isPosNetworkError: true,
127
161
  status: 'warn',
128
162
  fail: null,
129
163
  title: locales.getText('page.eftpos-pay.text.interrupted'),
130
- warn: /*#__PURE__*/React.createElement(React.Fragment, null, locales.getText('page.eftpos-pay.text.transaction.eftpos.fail.title'), /*#__PURE__*/React.createElement("br", null), locales.getText('page.eftpos-pay.text.transaction.eftpos.fail.power'), ". ", /*#__PURE__*/React.createElement("br", null), locales.getText('page.eftpos-pay.text.transaction.eftpos.fail.device'), /*#__PURE__*/React.createElement("br", null), locales.getText('page.eftpos-pay.text.transaction.eftpos.fail.network'), /*#__PURE__*/React.createElement("br", null), locales.getText('page.eftpos-pay.text.transaction.eftpos.fail.if')(mode))
164
+ warn: "".concat(locales.getText('page.eftpos-pay.text.transaction.eftpos.fail.title'), "\n").concat(locales.getText('page.eftpos-pay.text.transaction.eftpos.fail.power'), "\n ").concat(locales.getText('page.eftpos-pay.text.transaction.eftpos.fail.device'), "\n").concat(locales.getText('page.eftpos-pay.text.transaction.eftpos.fail.network'), "\n").concat(locales.getText('page.eftpos-pay.text.transaction.eftpos.fail.if')(modeRef.current), "\n ")
165
+ // warn: (
166
+ // <>
167
+ // {locales.getText(
168
+ // 'page.eftpos-pay.text.transaction.eftpos.fail.title'
169
+ // )}
170
+ // <br />
171
+ // {locales.getText(
172
+ // 'page.eftpos-pay.text.transaction.eftpos.fail.power'
173
+ // )}
174
+ // . <br />
175
+ // {locales.getText(
176
+ // 'page.eftpos-pay.text.transaction.eftpos.fail.device'
177
+ // )}
178
+ // <br />
179
+ // {locales.getText(
180
+ // 'page.eftpos-pay.text.transaction.eftpos.fail.network'
181
+ // )}
182
+ // <br />
183
+ // {locales.getText(
184
+ // 'page.eftpos-pay.text.transaction.eftpos.fail.if'
185
+ // )(modeRef.current)}
186
+ // </>
187
+ // ),
188
+ }
189
+ }));
190
+
191
+ dispatch(updateComponent('FailCustom'));
192
+ return;
193
+ }
194
+ if (code === PayStatus.PayBankRefuses) {
195
+ //
196
+ dispatch(updateCustom({
197
+ failCustom: {
198
+ isPosNetworkError: false,
199
+ status: 'fail',
200
+ fail: locales.getText('page.eftpos-pay.text.transaction.back.declined.text'),
201
+ title: locales.getText('page.eftpos-pay.text.transaction.back.declined.title'),
202
+ warn: null
203
+ }
204
+ }));
205
+ dispatch(updateComponent('FailCustom'));
206
+ return;
207
+ }
208
+ if (code === PayStatus.SignatureDeclined) {
209
+ dispatch(updateCustom({
210
+ failCustom: {
211
+ isPosNetworkError: false,
212
+ status: 'fail',
213
+ fail: locales.getText('page.eftpos-pay.text.transaction.user.declined.text'),
214
+ title: locales.getText('page.eftpos-pay.text.transaction.user.declined.title'),
215
+ warn: null
216
+ }
217
+ }));
218
+ dispatch(updateComponent('FailCustom'));
219
+ return;
220
+ }
221
+ if (code === PayStatus.UserConfigError) {
222
+ dispatch(updateCustom({
223
+ failCustom: {
224
+ isPosNetworkError: false,
225
+ status: 'fail',
226
+ fail: locales.getText('page.eftpos-pay.text.transaction.user.config.text'),
227
+ title: locales.getText('page.eftpos-pay.text.transaction.user.config.title'),
228
+ warn: null
131
229
  }
132
230
  }));
133
231
  dispatch(updateComponent('FailCustom'));
134
232
  return;
135
233
  }
234
+
235
+ // 其他场景前往未知错误页
136
236
  dispatch(updateCustom({
137
237
  errorStatus: 'unknow' // unknow know
138
238
  }));
@@ -140,6 +240,14 @@ export var useFail = function useFail() {
140
240
  dispatch(updateComponent('UnknowFail'));
141
241
  }, [dispatch]);
142
242
  };
243
+
244
+ /**
245
+ * @title: 轮询 check 接口
246
+ * @description: 轮询 终止条件 1.超时 , 2. 返回非200状态码 , 3. 外部关闭
247
+ * @return [run, XhrTimer] run: 启动函数 , XhrTimer 轮询类
248
+ * @Author: hongbing.wang
249
+ * @Date: 2024-08-12 10:30
250
+ */
143
251
  export var useValidate = function useValidate(check, num, onChange) {
144
252
  var unloadRef = useRef(false);
145
253
  var dispatch = useDispatch();
@@ -147,51 +255,46 @@ export var useValidate = function useValidate(check, num, onChange) {
147
255
  var failRef = useRef(fail);
148
256
  var ref = useRef();
149
257
  var _useContextData2 = useContextData(),
150
- custom = _useContextData2.custom,
151
- mode = _useContextData2.mode;
258
+ custom = _useContextData2.custom;
259
+ var _useStoreRef2 = useStoreRef(),
260
+ netRef = _useStoreRef2.netRef,
261
+ payRef = _useStoreRef2.payRef,
262
+ numRef = _useStoreRef2.numRef,
263
+ modeRef = _useStoreRef2.modeRef;
152
264
  var stepRef = useRef(custom === null || custom === void 0 ? void 0 : custom.step);
153
265
  var listRef = useRef(custom === null || custom === void 0 ? void 0 : custom.list);
154
- var numberRef = useRef(custom === null || custom === void 0 ? void 0 : custom.number);
155
- var payRef = useRef(custom === null || custom === void 0 ? void 0 : custom.pay);
156
- var netRef = useRef(custom === null || custom === void 0 ? void 0 : custom.net);
157
- var watchRef = useRef();
158
266
  useEffect(function () {
159
267
  listRef.current = custom === null || custom === void 0 ? void 0 : custom.list;
160
268
  }, [custom === null || custom === void 0 ? void 0 : custom.list]);
161
269
  useEffect(function () {
162
270
  stepRef.current = custom === null || custom === void 0 ? void 0 : custom.step;
163
271
  }, [custom === null || custom === void 0 ? void 0 : custom.step]);
164
- useEffect(function () {
165
- numberRef.current = custom === null || custom === void 0 ? void 0 : custom.number;
166
- }, [custom === null || custom === void 0 ? void 0 : custom.number]);
167
- useEffect(function () {
168
- console.log('custom?.net = ', custom);
169
- netRef.current = custom === null || custom === void 0 ? void 0 : custom.net;
170
- }, [custom === null || custom === void 0 ? void 0 : custom.net]);
171
- useEffect(function () {
172
- payRef.current = custom === null || custom === void 0 ? void 0 : custom.pay;
173
- }, [custom === null || custom === void 0 ? void 0 : custom.pay]);
272
+ var watchRef = useRef();
174
273
  var run = useCallback(function (timeout) {
175
274
  var _ref$current2, _ref$current3;
275
+ if (timeout === -1) {
276
+ console.log('无限加载');
277
+ } else {
278
+ console.log('计时加载 ', typeof timeout === 'number' ? timeout : num);
279
+ }
176
280
  if (unloadRef.current) {
177
281
  var _ref$current;
178
282
  (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.close();
179
283
  return;
180
284
  }
181
- if (!watchRef.current) {
182
- return;
183
- }
184
- if (!netRef.current) {
285
+ if (!watchRef.current || !netRef.current) {
185
286
  return;
186
287
  }
288
+ // 关闭上一轮 查询
187
289
  (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.close();
290
+ // 开启新一轮查询
188
291
  ref.current = new XhrTimer({
189
292
  xhr: check,
190
293
  timeout: typeof timeout === 'number' ? timeout : num,
191
294
  callback: watchRef.current
192
295
  });
193
296
  (_ref$current3 = ref.current) === null || _ref$current3 === void 0 ? void 0 : _ref$current3.run({
194
- number: numberRef.current
297
+ number: numRef.current
195
298
  })
196
299
  // eslint-disable-next-line consistent-return
197
300
  .then(function (res) {
@@ -216,11 +319,19 @@ export var useValidate = function useValidate(check, num, onChange) {
216
319
  if (res && res.code === -1) {
217
320
  return;
218
321
  }
219
- (_failRef$current = failRef.current) === null || _failRef$current === void 0 ? void 0 : _failRef$current.call(failRef, res, stepRef.current >= 3);
322
+ (_failRef$current = failRef.current) === null || _failRef$current === void 0 ? void 0 : _failRef$current.call(failRef, res, stepRef.current >= StepStatusEnum.Account);
220
323
  });
221
324
  }, [check, num]);
222
325
  useEffect(function () {
223
- watchRef.current = function (res) {
326
+ /**
327
+ * @title: 轮询结果处理
328
+ * @description: 将轮询结果进行处理,根据不同的轮询结果进行不同的业务逻辑处理
329
+ * @param {any} res 轮询接口范湖遗址
330
+ * @return null
331
+ * @Author: hongbing.wang
332
+ * @Date: 2024-08-12 12:42
333
+ */
334
+ watchRef.current = function (res, isRun) {
224
335
  if (unloadRef.current) {
225
336
  var _ref$current4;
226
337
  (_ref$current4 = ref.current) === null || _ref$current4 === void 0 ? void 0 : _ref$current4.close();
@@ -234,14 +345,19 @@ export var useValidate = function useValidate(check, num, onChange) {
234
345
  txn_status_id = _ref[0],
235
346
  status_id = _ref[1],
236
347
  complete = _ref[2];
348
+
349
+ // 支付成功状态
237
350
  if (txn_status_id === StepStatusEnum.Wait && status_id === 6 && complete === 1) {
238
351
  var _ref$current6;
239
352
  (_ref$current6 = ref.current) === null || _ref$current6 === void 0 ? void 0 : _ref$current6.close();
353
+
354
+ // 步骤列表中不存在当前步骤
240
355
  if (stepRef.current !== txn_status_id && listRef.current.every(function (_ref2) {
241
356
  var index = _ref2.index;
242
357
  return txn_status_id !== index;
243
358
  })) {
244
359
  var _payRef$current;
360
+ // 将所有步骤状态设为完成 resolve
245
361
  var current = listRef.current.map(function (item) {
246
362
  if (Number(item === null || item === void 0 ? void 0 : item.index) < Number(stepRef.current)) {
247
363
  return _objectSpread(_objectSpread({}, item), {}, {
@@ -250,11 +366,15 @@ export var useValidate = function useValidate(check, num, onChange) {
250
366
  }
251
367
  return item;
252
368
  });
369
+ // 创建下一步骤信息
253
370
  var nextStep = getStepMapping(txn_status_id, {
254
371
  money: (_payRef$current = payRef.current) === null || _payRef$current === void 0 ? void 0 : _payRef$current.totalUnit,
255
- mode: mode
372
+ mode: modeRef.current
256
373
  });
257
- current.push(nextStep);
374
+ if (nextStep) {
375
+ current.push(nextStep);
376
+ }
377
+ // 更新步骤
258
378
  dispatch(updateCustom({
259
379
  list: current,
260
380
  step: txn_status_id
@@ -263,14 +383,20 @@ export var useValidate = function useValidate(check, num, onChange) {
263
383
  onChange(res.data);
264
384
  return;
265
385
  }
386
+
387
+ // 普通状态
266
388
  if (stepRef.current !== txn_status_id && listRef.current.every(function (_ref3) {
267
389
  var index = _ref3.index;
268
390
  return txn_status_id !== index;
269
391
  })) {
270
392
  var _ref$current7, _payRef$current2;
393
+ // 查询到不存在的状态,则新增步骤状态
271
394
  console.log('self.flag stepRef.current, txn_status_id ', stepRef.current, txn_status_id);
272
395
  stepRef.current = txn_status_id;
396
+ // 构建新状态时,将之前的查询关闭
273
397
  (_ref$current7 = ref.current) === null || _ref$current7 === void 0 ? void 0 : _ref$current7.close();
398
+
399
+ // 将当前步骤列表数据翻转成完成 - resolve
274
400
  var _current = listRef.current.map(function (item) {
275
401
  if (Number(item === null || item === void 0 ? void 0 : item.index) < Number(stepRef.current)) {
276
402
  return _objectSpread(_objectSpread({}, item), {}, {
@@ -279,27 +405,34 @@ export var useValidate = function useValidate(check, num, onChange) {
279
405
  }
280
406
  return item;
281
407
  });
408
+ // 获取下一步配置
282
409
  var _nextStep = getStepMapping(txn_status_id, {
283
410
  money: (_payRef$current2 = payRef.current) === null || _payRef$current2 === void 0 ? void 0 : _payRef$current2.totalUnit,
284
- mode: mode
411
+ mode: modeRef.current
285
412
  });
286
413
  if (_nextStep) {
287
414
  _current.push(_nextStep);
415
+ // 如果是被动提交等待用户行为则给出 Question 提示 用户操作
288
416
  if (_nextStep.type === StemTypeEnum.Passive) {
289
417
  dispatch(updateStatus(StatusEnum.Question));
290
418
  }
291
419
  if (_nextStep.index === StepStatusEnum.Receipt) {
420
+ // 签名步骤定制签名步骤签名
292
421
  dispatch(updateState({
293
- title: locales.getText('page.eftpos-pay.text.waiting.signature') // 等待签名
422
+ title: locales.getText('page.eftpos-pay.text.waiting.signature')
294
423
  }));
295
424
  }
296
425
  }
297
-
298
426
  dispatch(updateCustom({
299
427
  list: _current,
300
428
  step: txn_status_id
301
429
  }));
430
+ // 如果是签名页 则开启无限查询, 如果不是则开启计时查询
302
431
  txn_status_id === StepStatusEnum.Receipt ? run(-1) : run();
432
+ return;
433
+ }
434
+ if (isRun) {
435
+ run();
303
436
  }
304
437
  };
305
438
  }, [dispatch, onChange, run]);
@@ -310,5 +443,5 @@ export var useValidate = function useValidate(check, num, onChange) {
310
443
  unloadRef.current = true;
311
444
  };
312
445
  }, []);
313
- return [run, ref];
446
+ return [run, watchRef, ref];
314
447
  };
@@ -1,8 +1,20 @@
1
1
  import React from 'react';
2
+ /**
3
+ * @title: 按钮操作区
4
+ * @description: 仅包含签名
5
+ * @Author: hongbing.wang
6
+ * @Date: 2024-08-20 12:33
7
+ */
2
8
  export declare const ReceiptAction: ({ api, onChange, }: {
3
9
  api: any;
4
10
  onChange: (status: boolean) => void;
5
11
  }) => React.JSX.Element;
12
+ /**
13
+ * @title: 按钮操作区
14
+ * @description: 不包含签名
15
+ * @Author: hongbing.wang
16
+ * @Date: 2024-08-20 12:32
17
+ */
6
18
  declare const Action: ({ index, onCancel, disabled, }: {
7
19
  index: number;
8
20
  onCancel: () => void;