@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
@@ -1,16 +1,20 @@
1
+ function _objectDestructuringEmpty(obj) { if (obj == null) throw new TypeError("Cannot destructure " + obj); }
1
2
  import { locales } from '@pisell/utils';
2
- import React, { useEffect, useRef } from 'react';
3
+ import React, { useEffect, useRef, useCallback } from 'react';
3
4
  import Fail from "./component/fail";
4
5
  import FailCustom from "./component/fail/failCustom";
5
6
  import Network from "./component/fail/network";
6
7
  import UnknowFail from "./component/fail/unknow";
7
8
  import Header from "./component/header";
9
+ import { getPayParams } from "./helper";
8
10
  import Manual from "./component/manual";
9
11
  import Signature from "./component/signature";
10
12
  import { StatusEnum, PayRouteEnum } from "./const";
11
- import { Payo, Windcave, Eftpos } from "./manufacturer";
12
- import { useContextData, useDispatch, updateStatus, backUpProduction, updateComponent, updateCustom, backUpFree, updateState } from "./store";
13
+ import { Payo, Windcave, Tyro } from "./manufacturer";
14
+ import { useContextData, useDispatch, updateStatus, backUpProduction, updateComponent, backUpFree, updateState } from "./store";
13
15
  import "./index.less";
16
+
17
+ // 定制组件 用于当前页面无法扩展场景
14
18
  var Mapping = {
15
19
  Fail: Fail,
16
20
  Network: Network,
@@ -19,61 +23,133 @@ var Mapping = {
19
23
  FailCustom: FailCustom,
20
24
  UnknowFail: UnknowFail
21
25
  };
26
+ /**
27
+ * @title: 支付组件
28
+ * @description:
29
+ * @Author: hongbing.wang
30
+ * @Date: 2024-08-20 14:59
31
+ */
22
32
  var Pay = function Pay(_ref) {
23
33
  var api = _ref.api,
24
34
  onChangeStatus = _ref.onChange,
25
35
  className = _ref.className,
26
36
  terminal = _ref.terminal,
27
37
  net = _ref.net,
28
- isIpad = _ref.isIpad;
38
+ isIpad = _ref.isIpad,
39
+ tyroUrl = _ref.tyroUrl,
40
+ tyroVersion = _ref.tyroVersion,
41
+ _ref$formatAmount = _ref.formatAmount,
42
+ formatAmount = _ref$formatAmount === void 0 ? function (number, precision, symbol) {
43
+ return "".concat(symbol).concat(number);
44
+ } : _ref$formatAmount;
29
45
  var data = useContextData();
46
+ var dataRef = useRef(data);
47
+ // console.log("pay = ",'pay')
30
48
  var dispatch = useDispatch();
31
49
  var ref = useRef(false);
32
50
  var statusRef = useRef(data.status);
33
51
  var comonentRef = useRef(data.component);
52
+ var backupRef = useRef(data.backup);
53
+ var clearRef = useRef(0);
34
54
  useEffect(function () {
35
55
  comonentRef.current = data.component;
36
56
  }, [data.component]);
57
+ useEffect(function () {
58
+ backupRef.current = data.backup;
59
+ }, [data.backup]);
60
+ useEffect(function () {
61
+ dataRef.current = data;
62
+ }, [data]);
37
63
  var Comm = Mapping[data.component];
38
- var onChange = function onChange(status, params) {
39
- if (status !== 'page') {
64
+
65
+ /**
66
+ * @title: 获取组件状态
67
+ * @Author: hongbing.wang
68
+ * @Date: 2024-08-20 15:00
69
+ */
70
+ var onChange = useCallback(function (status, params) {
71
+ if (status === StatusEnum.Success || status === StatusEnum.Fail) {
40
72
  dispatch(updateStatus(status));
41
73
  }
42
74
  onChangeStatus(status, params);
43
- };
75
+ }, [dispatch, onChangeStatus]);
76
+
77
+ // 主流程 已完成 的崩溃恢复
44
78
  useEffect(function () {
45
- ref.current = true;
46
- }, []);
79
+ if (statusRef.current === 'success') {
80
+ var status = statusRef.current;
81
+ var params = getPayParams(dataRef.current, status);
82
+ clearRef.current = setTimeout(function () {
83
+ onChange(status, params);
84
+ }, 1000);
85
+ }
86
+ }, [onChange]);
87
+
88
+ // 监控网络状态
47
89
  useEffect(function () {
48
- console.log('net = ', net);
49
- dispatch(updateCustom({
90
+ dispatch(updateState({
50
91
  net: net
51
92
  }));
52
93
  if (!ref.current) {
94
+ // 初始化
53
95
  ref.current = true;
54
- return;
55
- }
56
- if (statusRef.current === StatusEnum.Success) {
96
+ // 断网&崩溃 恢复处理
97
+ if (backupRef.current && net) {
98
+ var _data = Object.assign({}, (_objectDestructuringEmpty(backupRef.current), backupRef.current));
99
+ dispatch(backUpFree({
100
+ key: Date.now()
101
+ }));
102
+ dispatch(updateState({
103
+ net: net
104
+ }));
105
+ // 主流程 已完成 断网&崩溃 恢复
106
+ if (_data.status === 'success') {
107
+ var status = _data.status;
108
+ var params = getPayParams(dataRef.current, status);
109
+ clearRef.current = setTimeout(function () {
110
+ onChange(status, params);
111
+ }, 1000);
112
+ }
113
+ }
57
114
  return;
58
115
  }
59
116
  if (net) {
117
+ var _data2 = Object.assign({}, (_objectDestructuringEmpty(backupRef.current), backupRef.current));
118
+ // 网络恢复 释放备份
60
119
  dispatch(backUpFree({
61
120
  key: Date.now()
62
121
  }));
63
- dispatch(updateCustom({
64
- net: net
65
- }));
66
- } else {
67
122
  dispatch(updateState({
68
- lastComponent: 'Network'
69
- }));
70
- dispatch(backUpProduction({}));
71
- dispatch(updateCustom({
72
123
  net: net
73
124
  }));
74
- dispatch(updateComponent('Network'));
125
+ if (_data2.status === 'success') {
126
+ var _status = _data2.status;
127
+ var _params = getPayParams(dataRef.current, _status);
128
+ clearRef.current = setTimeout(function () {
129
+ onChange(_status, _params);
130
+ }, 1000);
131
+ }
132
+ return;
75
133
  }
76
- }, [dispatch, net]);
134
+ // 网络终端 - 备份数据
135
+ dispatch(updateState({
136
+ form: 'Network'
137
+ })); // 最新的展示的组件为 Network
138
+ dispatch(backUpProduction({}));
139
+ dispatch(updateState({
140
+ net: net,
141
+ status: 'warn'
142
+ }));
143
+ dispatch(updateComponent('Network')); // 前往 Network 页面
144
+ }, [dispatch, net, onChange]);
145
+ useEffect(function () {
146
+ return function () {
147
+ if (clearRef.current) {
148
+ clearTimeout(clearRef.current);
149
+ }
150
+ };
151
+ }, []);
152
+ // console.log("pay2222 = ",'pay 222' , data.render,data.type)
77
153
  return /*#__PURE__*/React.createElement(React.Fragment, null, data.render ? /*#__PURE__*/React.createElement("div", {
78
154
  className: "pisell-lowcode__eft-pay-box ".concat(className),
79
155
  style: data.type === 'step' ? {} : {
@@ -81,7 +157,8 @@ var Pay = function Pay(_ref) {
81
157
  }
82
158
  }, /*#__PURE__*/React.createElement(Header, {
83
159
  status: data.status,
84
- title: data.title
160
+ title: data.title,
161
+ subTitle: data.subTitle
85
162
  }), data.eftpos === 'payo' ? /*#__PURE__*/React.createElement(Payo, {
86
163
  api: api,
87
164
  onChange: onChange
@@ -89,22 +166,23 @@ var Pay = function Pay(_ref) {
89
166
  className: "pisell-lowcode__eft-pay-step-item pisell-lowcode__eft-pay-step-item-warn"
90
167
  }, data.warn) : null, data.status === StatusEnum.Success ? /*#__PURE__*/React.createElement("div", {
91
168
  className: "pisell-lowcode__eft-pay-step-item pisell-lowcode__eft-pay-step-item-tip"
92
- }, locales.getText('page.eftpos-pay.text.transaction.end')) : null) : null, data.eftpos === 'eftpos' ? /*#__PURE__*/React.createElement(Eftpos, {
169
+ }, locales.getText('page.eftpos-pay.text.transaction.end')) : null) : null, data.eftpos === 'tyro' ? /*#__PURE__*/React.createElement(Tyro, {
93
170
  api: api,
94
- onChange: onChange
95
- }, data.warn && data.status !== StatusEnum.Success ? /*#__PURE__*/React.createElement("div", {
96
- className: "pisell-lowcode__eft-pay-step-item pisell-lowcode__eft-pay-step-item-warn"
97
- }, data.warn) : null, data.status === StatusEnum.Success ? /*#__PURE__*/React.createElement("div", {
98
- className: "pisell-lowcode__eft-pay-step-item pisell-lowcode__eft-pay-step-item-tip"
99
- }, locales.getText('page.eftpos-pay.text.transaction.end')) : null) : null, data.eftpos === 'windcave' ? /*#__PURE__*/React.createElement(Windcave, {
171
+ onChange: onChange,
172
+ key: data.key,
173
+ url: tyroUrl,
174
+ version: tyroVersion
175
+ }) : null, data.eftpos === 'windcave' ? /*#__PURE__*/React.createElement(Windcave, {
100
176
  api: api,
101
177
  onChange: onChange,
102
- key: data.key
178
+ key: data.key,
179
+ formatAmount: formatAmount
103
180
  }) : null) : null, data.type === PayRouteEnum.Unset && Comm ? /*#__PURE__*/React.createElement(Comm, {
104
181
  onChange: onChange,
105
182
  api: api,
106
183
  className: className,
107
- isIpad: true
184
+ isIpad: isIpad,
185
+ formatAmount: formatAmount
108
186
  }) : null);
109
187
  };
110
188
  export default Pay;
@@ -21,307 +21,168 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
21
21
  import { locales } from '@pisell/utils';
22
22
  import { Button } from 'antd';
23
23
  import React, { useEffect, useRef } from 'react';
24
- import { Decimal } from 'decimal.js';
25
24
  import Step from "../component/step";
26
25
  import { PayStatus, StatusEnum, ModeEnum } from "../const";
27
- import { getUuid } from "../helper";
28
- import { useFail } from "../hooks";
29
- import { useContextData, useDispatch, updateNextStep, updateComponent, updateState, updateCurrentCustomStemItem } from "../store";
26
+ import { getUuid, getPayParams } from "../helper";
27
+ import { useFail, useStoreRef } from "../hooks";
28
+ import { useContextData, useDispatch, updateNextStep, updateComponent, updateState, updateCustom } from "../store";
30
29
  import { useValidate } from "./hooks";
30
+
31
+ // 注意断网与卸载未完成的回调将终止处理
31
32
  export var POS = function POS(_ref) {
32
- var _props$custom, _props$custom3;
33
33
  var api = _ref.api,
34
34
  onChange = _ref.onChange;
35
35
  var _useContextData = useContextData(),
36
- steps = _useContextData.steps,
37
- eftpos = _useContextData.eftpos,
38
- device = _useContextData.device,
39
- custom = _useContextData.custom,
40
- status = _useContextData.status,
41
- mode = _useContextData.mode;
42
- var refundRef = useRef(custom === null || custom === void 0 ? void 0 : custom.refund);
43
- var statusRef = useRef(status);
36
+ steps = _useContextData.steps;
37
+ var _useStoreRef = useStoreRef(),
38
+ deviceRef = _useStoreRef.deviceRef,
39
+ payRef = _useStoreRef.payRef,
40
+ numRef = _useStoreRef.numRef,
41
+ statusRef = _useStoreRef.statusRef,
42
+ modeRef = _useStoreRef.modeRef,
43
+ netRef = _useStoreRef.netRef,
44
+ orderIdRef = _useStoreRef.orderIdRef,
45
+ amountRef = _useStoreRef.amountRef,
46
+ eftposRef = _useStoreRef.eftposRef;
44
47
  var dispatch = useDispatch();
45
48
  var _steps$ = steps[0],
46
49
  key = _steps$.key,
47
50
  props = _objectWithoutProperties(_steps$, _excluded);
48
- var modeRef = useRef(mode);
49
- var ref = useRef(custom === null || custom === void 0 ? void 0 : custom.number);
50
- var customRef = useRef(custom);
51
- var deviceRef = useRef(device);
52
- var stepStatusRef = useRef(props === null || props === void 0 ? void 0 : (_props$custom = props.custom) === null || _props$custom === void 0 ? void 0 : _props$custom.status);
53
51
  var fail = useFail(0, true);
54
52
  var failRef = useRef(fail);
55
53
  var controllerRef = useRef();
56
54
  var clearRef = useRef();
57
55
  var initRef = useRef(false);
58
56
  var unloadRef = useRef(false);
59
- var netRef = useRef(custom === null || custom === void 0 ? void 0 : custom.net);
60
57
  var _useValidate = useValidate(1000 * 60),
61
58
  _useValidate2 = _slicedToArray(_useValidate, 1),
62
59
  check = _useValidate2[0];
63
- useEffect(function () {
64
- customRef.current = custom;
65
- }, [custom]);
66
- useEffect(function () {
67
- deviceRef.current = device;
68
- }, [device]);
69
- useEffect(function () {
70
- modeRef.current = mode;
71
- }, [mode]);
72
- useEffect(function () {
73
- refundRef.current = custom === null || custom === void 0 ? void 0 : custom.refund;
74
- }, [custom === null || custom === void 0 ? void 0 : custom.refund]);
75
- useEffect(function () {
76
- statusRef.current = status;
77
- }, [status]);
78
- useEffect(function () {
79
- netRef.current = custom === null || custom === void 0 ? void 0 : custom.net;
80
- }, [custom === null || custom === void 0 ? void 0 : custom.net]);
81
- useEffect(function () {
82
- var _props$custom2;
83
- stepStatusRef.current = props === null || props === void 0 ? void 0 : (_props$custom2 = props.custom) === null || _props$custom2 === void 0 ? void 0 : _props$custom2.status;
84
- }, [props === null || props === void 0 ? void 0 : (_props$custom3 = props.custom) === null || _props$custom3 === void 0 ? void 0 : _props$custom3.status]);
85
60
  useEffect(function () {
86
61
  failRef.current = fail;
87
62
  }, [fail]);
63
+
64
+ /**
65
+ * @title: 支付,退款,查询 成功 后续逻辑处理
66
+ * @description:
67
+ * @return {*}
68
+ * @Author: zhiwei.Wang
69
+ * @Date: 2024-01-30 16:34
70
+ */
71
+ var success = function success(res) {
72
+ dispatch(updateNextStep());
73
+ dispatch(updateCustom({
74
+ card_reader_surcharge: (res === null || res === void 0 ? void 0 : res.card_reader_surcharge) || 0
75
+ }));
76
+ clearRef.current = setTimeout(function () {
77
+ var _deviceRef$current, _deviceRef$current$se;
78
+ var params = getPayParams({
79
+ mode: modeRef.current,
80
+ amount: amountRef.current,
81
+ order_id: orderIdRef.current,
82
+ number: numRef.current,
83
+ device: deviceRef.current,
84
+ pay: payRef.current,
85
+ custom: {
86
+ card_reader_surcharge: (res === null || res === void 0 ? void 0 : res.card_reader_surcharge) || 0
87
+ }
88
+ }, 'success');
89
+ var receipt = Array.isArray(res.receipt) ? res.receipt : [res.receipt];
90
+ onChange('success', _objectSpread(_objectSpread({}, params), {}, {
91
+ receipt: (_deviceRef$current = deviceRef.current) !== null && _deviceRef$current !== void 0 && (_deviceRef$current$se = _deviceRef$current.setting) !== null && _deviceRef$current$se !== void 0 && _deviceRef$current$se.receipts ? [] : receipt
92
+ }));
93
+ }, 1000);
94
+ };
95
+
96
+ /**
97
+ * @title: 检查支付状态
98
+ * @Author: hongbing.wang
99
+ * @Date: 2024-08-20 11:53
100
+ */
101
+ var checkApi = function checkApi() {
102
+ check(api.check, numRef.current).then(function (res) {
103
+ // 无网 或 已卸载 则不进行处理
104
+ if (unloadRef.current || !netRef.current) {
105
+ return;
106
+ }
107
+ if (res && "".concat(res.code) === '200') {
108
+ success(res);
109
+ return;
110
+ }
111
+ failRef.current(res);
112
+ }, function (res) {
113
+ // 无网 或 已卸载 则不进行处理
114
+ if (unloadRef.current || !netRef.current) {
115
+ return;
116
+ }
117
+ failRef.current(res);
118
+ });
119
+ };
120
+
121
+ /**
122
+ * @title: 支付,退款,查询 初始化逻辑处理
123
+ * @Author: hongbing.wang
124
+ * @Date: 2024-08-12 10:14
125
+ */
88
126
  useEffect(function () {
127
+ var _deviceRef$current2, _deviceRef$current3;
128
+ if (statusRef.current === StatusEnum.Success || statusRef.current === StatusEnum.Fail) {
129
+ return;
130
+ }
89
131
  if (initRef.current) {
90
132
  return;
91
133
  }
92
134
  initRef.current = true;
93
- if (statusRef.current !== StatusEnum.Loading) {
135
+ // 存在交易流水进行查询
136
+ if (numRef.current) {
137
+ checkApi();
94
138
  return;
95
139
  }
96
- if (!ref.current) {
97
- var _ref2 = customRef.current,
98
- pay = _ref2.pay,
99
- order_id = _ref2.order_id;
100
- ref.current = getUuid();
101
- dispatch(updateState({
102
- custom: _objectSpread(_objectSpread({}, customRef.current), {}, {
103
- number: ref.current
104
- })
105
- }));
106
- if (api && api.pay) {
107
- var _deviceRef$current, _refundRef$current, _deviceRef$current2;
108
- controllerRef.current = new AbortController();
109
- var clear;
110
- var resultPromise = modeRef.current === ModeEnum.Pay ? api.pay({
111
- order_id: order_id,
112
- amount: pay.total,
113
- card_reader_type: eftpos,
114
- card_reader_id: (_deviceRef$current = deviceRef.current) === null || _deviceRef$current === void 0 ? void 0 : _deviceRef$current.id,
115
- number: ref.current
116
- }, {
117
- signal: controllerRef.current.signal
118
- }) : api.refund({
119
- order_id: order_id,
120
- amount: (_refundRef$current = refundRef.current) === null || _refundRef$current === void 0 ? void 0 : _refundRef$current.total,
121
- card_reader_type: eftpos,
122
- card_reader_id: (_deviceRef$current2 = deviceRef.current) === null || _deviceRef$current2 === void 0 ? void 0 : _deviceRef$current2.id,
123
- number: ref.current
124
- }, {
125
- signal: controllerRef.current.signal
126
- });
127
- resultPromise.then(function (res) {
128
- var _customRef$current;
129
- console.log('netRef.current = ', netRef.current);
130
- if (unloadRef.current) {
131
- return;
132
- }
133
- if (!((_customRef$current = customRef.current) !== null && _customRef$current !== void 0 && _customRef$current.net)) {
134
- return;
135
- }
136
- if (res && (res.code === 200 || res.code === '200')) {
137
- dispatch(updateCurrentCustomStemItem({
138
- status: 'pay'
139
- }));
140
- return res;
141
- }
142
- if (res && "".concat(res.code) === PayStatus.Timeout) {
143
- dispatch(updateCurrentCustomStemItem({
144
- status: 'pay'
145
- }));
146
- }
147
- return Promise.reject(res);
148
- }).then(function (res) {
149
- var _customRef$current2;
150
- console.log('netRef.current = ', netRef.current);
151
- if (unloadRef.current) {
152
- return;
153
- }
154
- if (!((_customRef$current2 = customRef.current) !== null && _customRef$current2 !== void 0 && _customRef$current2.net)) {
155
- return;
156
- }
157
- dispatch(updateNextStep());
158
- clear = setTimeout(function () {
159
- if (modeRef.current === ModeEnum.Pay) {
160
- var _customRef$current3, _res$data;
161
- var obj = ((_customRef$current3 = customRef.current) === null || _customRef$current3 === void 0 ? void 0 : _customRef$current3.pay) || {};
162
- var cardReaderSurcharge = (res === null || res === void 0 ? void 0 : (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.card_reader_surcharge) || 0;
163
-
164
- // 卡手续费
165
- var surCardDeci = new Decimal(Number(cardReaderSurcharge));
166
-
167
- // 手续费-固定金额
168
- var surMoneyDeci = new Decimal(Number((obj === null || obj === void 0 ? void 0 : obj.surMoney) || 0));
169
-
170
- // 手续费-比例金额
171
- var surRateMoneyDeci = new Decimal(Number(obj === null || obj === void 0 ? void 0 : obj.surRateMoney));
172
-
173
- // 手续费-固定金额 + 卡手续费 = 固定金额总额
174
- var surMoneyTotal = surMoneyDeci.add(surCardDeci);
175
-
176
- // 手续费-固定金额 + 卡手续费 + 手续费-比例金额 = 总手续费
177
- var surchargeDeci = surMoneyTotal.add(surRateMoneyDeci);
178
- onChange('success', _objectSpread(_objectSpread({}, obj), {}, {
179
- number: ref.current,
180
- device: deviceRef.current,
181
- cardReaderSurcharge: cardReaderSurcharge,
182
- surMoney: surMoneyTotal.toFixed(2, Decimal.ROUND_HALF_UP),
183
- surcharge: surchargeDeci.toFixed(2, Decimal.ROUND_HALF_UP)
184
- }));
185
- return;
186
- }
187
- if (modeRef.current === ModeEnum.Refund) {
188
- var _obj = refundRef.current || {};
189
- onChange('success', _objectSpread(_objectSpread({}, _obj), {}, {
190
- number: ref.current,
191
- device: deviceRef.current
192
- }));
193
- return;
194
- }
195
- onChange('success', {
196
- number: ref.current
197
- });
198
- }, 1000);
199
- }, function (res) {
200
- return Promise.reject(res);
201
- }).catch(function (res) {
202
- var _customRef$current4;
203
- console.log('netRef.current = ', netRef.current);
204
- if (unloadRef.current) {
205
- return;
206
- }
207
- if (!((_customRef$current4 = customRef.current) !== null && _customRef$current4 !== void 0 && _customRef$current4.net)) {
208
- return;
209
- }
210
- if (res && "".concat(res.code) === PayStatus.Timeout) {
211
- check(api.check, ref.current).then(function (r) {
212
- var _customRef$current5;
213
- console.log(' check :检车2 ,r ', r);
214
- if (unloadRef.current) {
215
- return;
216
- }
217
- if (!((_customRef$current5 = customRef.current) !== null && _customRef$current5 !== void 0 && _customRef$current5.net)) {
218
- return;
219
- }
220
- if (r && (r.code === 200 || r.code === '200')) {
221
- dispatch(updateCurrentCustomStemItem({
222
- status: 'pay'
223
- }));
224
- dispatch(updateNextStep());
225
- clearRef.current = setTimeout(function () {
226
- var _res$data2, _customRef$current6;
227
- var cardReaderSurcharge = (res === null || res === void 0 ? void 0 : (_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : _res$data2.card_reader_surcharge) || 0;
228
- var obj = ((_customRef$current6 = customRef.current) === null || _customRef$current6 === void 0 ? void 0 : _customRef$current6.pay) || {};
229
- // 卡手续费
230
- var surCardDeci = new Decimal(Number(cardReaderSurcharge));
231
-
232
- // 手续费-固定金额
233
- var surMoneyDeci = new Decimal(Number((obj === null || obj === void 0 ? void 0 : obj.surMoney) || 0));
234
-
235
- // 手续费-比例金额
236
- var surRateMoneyDeci = new Decimal(Number(obj === null || obj === void 0 ? void 0 : obj.surRateMoney));
237
-
238
- // 手续费-固定金额 + 卡手续费 = 固定金额总额
239
- var surMoneyTotal = surMoneyDeci.add(surCardDeci);
240
-
241
- // 手续费-固定金额 + 卡手续费 + 手续费-比例金额 = 总手续费
242
- var surchargeDeci = surMoneyTotal.add(surRateMoneyDeci);
243
- onChange('success', _objectSpread(_objectSpread({}, obj), {}, {
244
- number: ref.current,
245
- device: deviceRef.current,
246
- cardReaderSurcharge: cardReaderSurcharge,
247
- surMoney: surMoneyTotal.toFixed(2, Decimal.ROUND_HALF_UP),
248
- surcharge: surchargeDeci.toFixed(2, Decimal.ROUND_HALF_UP)
249
- }));
250
- }, 1000);
251
- return;
252
- }
253
- failRef.current(r);
254
- }, function (r) {
255
- var _customRef$current7;
256
- if (unloadRef.current) {
257
- return;
258
- }
259
- if (!((_customRef$current7 = customRef.current) !== null && _customRef$current7 !== void 0 && _customRef$current7.net)) {
260
- return;
261
- }
262
- failRef.current(r);
263
- });
264
- } else {
265
- failRef.current(res);
266
- }
267
- });
140
+ numRef.current = getUuid();
141
+ dispatch(updateState({
142
+ number: numRef.current
143
+ }));
144
+ controllerRef.current = new AbortController();
145
+ // 支付 or 退款
146
+ var resultPromise = modeRef.current === ModeEnum.Pay ? api.pay({
147
+ order_id: orderIdRef.current,
148
+ amount: payRef.current.total,
149
+ card_reader_type: eftposRef.current,
150
+ card_reader_id: (_deviceRef$current2 = deviceRef.current) === null || _deviceRef$current2 === void 0 ? void 0 : _deviceRef$current2.id,
151
+ number: numRef.current
152
+ }, {
153
+ signal: controllerRef.current.signal
154
+ }) : api.refund({
155
+ order_id: orderIdRef.current,
156
+ amount: amountRef.current,
157
+ card_reader_type: eftposRef.current,
158
+ card_reader_id: (_deviceRef$current3 = deviceRef.current) === null || _deviceRef$current3 === void 0 ? void 0 : _deviceRef$current3.id,
159
+ number: numRef.current
160
+ }, {
161
+ signal: controllerRef.current.signal
162
+ });
163
+ resultPromise.then(function (res) {
164
+ console.log('netRef.current111 = ', netRef.current);
165
+ if (unloadRef.current || !netRef.current) {
166
+ return;
268
167
  }
269
- } else {
270
- check(api.check, ref.current).then(function (res) {
271
- var _customRef$current8;
272
- console.log(' check 检车 ,r ', res);
273
- if (unloadRef.current) {
274
- return;
275
- }
276
- if (!((_customRef$current8 = customRef.current) !== null && _customRef$current8 !== void 0 && _customRef$current8.net)) {
277
- return;
278
- }
279
- if (res && (res.code === 200 || res.code === '200')) {
280
- dispatch(updateCurrentCustomStemItem({
281
- status: 'pay'
282
- }));
283
- dispatch(updateNextStep());
284
- clearRef.current = setTimeout(function () {
285
- var _res$data3, _customRef$current9;
286
- var cardReaderSurcharge = (res === null || res === void 0 ? void 0 : (_res$data3 = res.data) === null || _res$data3 === void 0 ? void 0 : _res$data3.card_reader_surcharge) || 0;
287
- var obj = ((_customRef$current9 = customRef.current) === null || _customRef$current9 === void 0 ? void 0 : _customRef$current9.pay) || {};
288
- // 卡手续费
289
- var surCardDeci = new Decimal(Number(cardReaderSurcharge));
290
-
291
- // 手续费-固定金额
292
- var surMoneyDeci = new Decimal(Number((obj === null || obj === void 0 ? void 0 : obj.surMoney) || 0));
293
-
294
- // 手续费-比例金额
295
- var surRateMoneyDeci = new Decimal(Number(obj === null || obj === void 0 ? void 0 : obj.surRateMoney));
296
-
297
- // 手续费-固定金额 + 卡手续费 = 固定金额总额
298
- var surMoneyTotal = surMoneyDeci.add(surCardDeci);
299
-
300
- // 手续费-固定金额 + 卡手续费 + 手续费-比例金额 = 总手续费
301
- var surchargeDeci = surMoneyTotal.add(surRateMoneyDeci);
302
- onChange('success', _objectSpread(_objectSpread({}, obj), {}, {
303
- number: ref.current,
304
- device: deviceRef.current,
305
- cardReaderSurcharge: cardReaderSurcharge,
306
- surMoney: surMoneyTotal.toFixed(2, Decimal.ROUND_HALF_UP),
307
- surcharge: surchargeDeci.toFixed(2, Decimal.ROUND_HALF_UP)
308
- }));
309
- }, 1000);
310
- return;
311
- }
312
- failRef.current(res);
313
- }, function (res) {
314
- var _customRef$current10;
315
- if (unloadRef.current) {
316
- return;
317
- }
318
- if (!((_customRef$current10 = customRef.current) !== null && _customRef$current10 !== void 0 && _customRef$current10.net)) {
319
- return;
320
- }
321
- failRef.current(res);
322
- });
323
- }
324
- }, [api, check, dispatch, eftpos, onChange]);
168
+ if (res && "".concat(res.code) === '200') {
169
+ success(res);
170
+ return;
171
+ }
172
+ return Promise.reject(res);
173
+ }).catch(function (err) {
174
+ console.log('netRef.current222 = ', netRef.current, unloadRef.current, err);
175
+ if (unloadRef.current || !netRef.current) {
176
+ return;
177
+ }
178
+ // 支付接口超时 进行支付状态查询
179
+ if (err && "".concat(err.code) === PayStatus.Timeout) {
180
+ checkApi();
181
+ return;
182
+ }
183
+ failRef.current(err);
184
+ });
185
+ }, [api, check, dispatch, onChange]);
325
186
  useEffect(function () {
326
187
  return function () {
327
188
  var _controllerRef$curren;
@@ -338,6 +199,12 @@ export var Action = function Action() {
338
199
  var dispatch = useDispatch();
339
200
  var _useContextData2 = useContextData(),
340
201
  mode = _useContextData2.mode;
202
+
203
+ /**
204
+ * @title: 前往手动标记页
205
+ * @Author: hongbing.wang
206
+ * @Date: 2024-08-20 12:18
207
+ */
341
208
  var onManually = function onManually() {
342
209
  dispatch(updateState({
343
210
  manual: {