@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,6 +1,6 @@
1
1
  import { State } from './store';
2
2
  export { default as Payo } from './payo';
3
3
  export { default as Windcave } from './windcave/windcave';
4
- export { default as Eftpos } from './eftpos';
4
+ export { default as Tyro } from './tyro';
5
5
  export declare const getInitState: (type: string, params?: any) => State;
6
- export declare const getDeviceInfo: (store: State) => import("./const").Amount;
6
+ export declare const getAmonunt: (store: State) => import("./const").Amount;
@@ -29,49 +29,49 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
29
29
  // src/components/eftposPay/manufacturer.tsx
30
30
  var manufacturer_exports = {};
31
31
  __export(manufacturer_exports, {
32
- Eftpos: () => import_eftpos.default,
33
32
  Payo: () => import_payo.default,
33
+ Tyro: () => import_tyro.default,
34
34
  Windcave: () => import_windcave.default,
35
- getDeviceInfo: () => getDeviceInfo,
35
+ getAmonunt: () => getAmonunt,
36
36
  getInitState: () => getInitState
37
37
  });
38
38
  module.exports = __toCommonJS(manufacturer_exports);
39
39
  var import_const = require("./const");
40
- var import_const2 = __toESM(require("./eftpos/const"));
41
- var import_const3 = __toESM(require("./payo/const"));
40
+ var import_const2 = __toESM(require("./payo/const"));
41
+ var import_const3 = __toESM(require("./tyro/const"));
42
42
  var import_const4 = __toESM(require("./windcave/const"));
43
43
  var import_payo = __toESM(require("./payo"));
44
44
  var import_windcave = __toESM(require("./windcave/windcave"));
45
- var import_eftpos = __toESM(require("./eftpos"));
45
+ var import_tyro = __toESM(require("./tyro"));
46
46
  var getInitState = (type, params) => {
47
47
  switch (type) {
48
48
  case import_const.EftposEnum.Payo:
49
- return (0, import_const3.default)(params);
50
- case import_const.EftposEnum.Eftpos:
51
49
  return (0, import_const2.default)(params);
52
50
  case import_const.EftposEnum.Windcave:
53
51
  return (0, import_const4.default)(params);
52
+ case import_const.EftposEnum.Tyro:
53
+ return (0, import_const3.default)(params);
54
54
  default:
55
55
  throw new Error("未知的厂商类型");
56
56
  }
57
57
  };
58
- var getDeviceInfo = (store) => {
59
- if (store.eftpos === import_const.EftposEnum.Eftpos) {
60
- return (0, import_const3.getAmonunt)(store);
61
- }
58
+ var getAmonunt = (store) => {
62
59
  if (store.eftpos === import_const.EftposEnum.Payo) {
63
60
  return (0, import_const2.getAmonunt)(store);
64
61
  }
65
62
  if (store.eftpos === import_const.EftposEnum.Windcave) {
66
63
  return (0, import_const4.getAmonunt)(store);
67
64
  }
65
+ if (store.eftpos === import_const.EftposEnum.Tyro) {
66
+ return (0, import_const3.getAmonunt)(store);
67
+ }
68
68
  throw new Error("未知的厂商类型");
69
69
  };
70
70
  // Annotate the CommonJS export names for ESM import in node:
71
71
  0 && (module.exports = {
72
- Eftpos,
73
72
  Payo,
73
+ Tyro,
74
74
  Windcave,
75
- getDeviceInfo,
75
+ getAmonunt,
76
76
  getInitState
77
77
  });
@@ -1,11 +1,20 @@
1
1
  import React from 'react';
2
2
  import { PayProps } from './const';
3
3
  import './index.less';
4
- declare const Pay: ({ api, onChange: onChangeStatus, className, terminal, net, isIpad }: PayProps & {
4
+ /**
5
+ * @title: 支付组件
6
+ * @description:
7
+ * @Author: hongbing.wang
8
+ * @Date: 2024-08-20 14:59
9
+ */
10
+ declare const Pay: ({ api, onChange: onChangeStatus, className, terminal, net, isIpad, tyroUrl, tyroVersion, formatAmount, }: PayProps & {
5
11
  terminal: {
6
12
  network: boolean;
7
13
  };
8
14
  net: boolean;
9
15
  isIpad: boolean;
16
+ tyroUrl?: string | undefined;
17
+ tyroVersion?: string | undefined;
18
+ formatAmount(amount: number | string, precision: number, symbol: string): string;
10
19
  }) => React.JSX.Element;
11
20
  export default Pay;
@@ -39,6 +39,7 @@ var import_failCustom = __toESM(require("./component/fail/failCustom"));
39
39
  var import_network = __toESM(require("./component/fail/network"));
40
40
  var import_unknow = __toESM(require("./component/fail/unknow"));
41
41
  var import_header = __toESM(require("./component/header"));
42
+ var import_helper = require("./helper");
42
43
  var import_manual = __toESM(require("./component/manual"));
43
44
  var import_signature = __toESM(require("./component/signature"));
44
45
  var import_const = require("./const");
@@ -59,63 +60,123 @@ var Pay = ({
59
60
  className,
60
61
  terminal,
61
62
  net,
62
- isIpad
63
+ isIpad,
64
+ tyroUrl,
65
+ tyroVersion,
66
+ formatAmount = (number, precision, symbol) => `${symbol}${number}`
63
67
  }) => {
64
68
  const data = (0, import_store.useContextData)();
69
+ const dataRef = (0, import_react.useRef)(data);
65
70
  const dispatch = (0, import_store.useDispatch)();
66
71
  const ref = (0, import_react.useRef)(false);
67
72
  const statusRef = (0, import_react.useRef)(data.status);
68
73
  const comonentRef = (0, import_react.useRef)(data.component);
74
+ const backupRef = (0, import_react.useRef)(data.backup);
75
+ const clearRef = (0, import_react.useRef)(0);
69
76
  (0, import_react.useEffect)(() => {
70
77
  comonentRef.current = data.component;
71
78
  }, [data.component]);
79
+ (0, import_react.useEffect)(() => {
80
+ backupRef.current = data.backup;
81
+ }, [data.backup]);
82
+ (0, import_react.useEffect)(() => {
83
+ dataRef.current = data;
84
+ }, [data]);
72
85
  const Comm = Mapping[data.component];
73
- const onChange = (status, params) => {
74
- if (status !== "page") {
75
- dispatch((0, import_store.updateStatus)(status));
76
- }
77
- onChangeStatus(status, params);
78
- };
86
+ const onChange = (0, import_react.useCallback)(
87
+ (status, params) => {
88
+ if (status === import_const.StatusEnum.Success || status === import_const.StatusEnum.Fail) {
89
+ dispatch((0, import_store.updateStatus)(status));
90
+ }
91
+ onChangeStatus(status, params);
92
+ },
93
+ [dispatch, onChangeStatus]
94
+ );
79
95
  (0, import_react.useEffect)(() => {
80
- ref.current = true;
81
- }, []);
96
+ if (statusRef.current === "success") {
97
+ const status = statusRef.current;
98
+ const params = (0, import_helper.getPayParams)(dataRef.current, status);
99
+ clearRef.current = setTimeout(() => {
100
+ onChange(status, params);
101
+ }, 1e3);
102
+ }
103
+ }, [onChange]);
82
104
  (0, import_react.useEffect)(() => {
83
- console.log("net = ", net);
84
- dispatch((0, import_store.updateCustom)({ net }));
105
+ dispatch((0, import_store.updateState)({ net }));
85
106
  if (!ref.current) {
86
107
  ref.current = true;
87
- return;
88
- }
89
- if (statusRef.current === import_const.StatusEnum.Success) {
108
+ if (backupRef.current && net) {
109
+ const { ...data2 } = backupRef.current;
110
+ dispatch((0, import_store.backUpFree)({ key: Date.now() }));
111
+ dispatch((0, import_store.updateState)({ net }));
112
+ if (data2.status === "success") {
113
+ const status = data2.status;
114
+ const params = (0, import_helper.getPayParams)(dataRef.current, status);
115
+ clearRef.current = setTimeout(() => {
116
+ onChange(status, params);
117
+ }, 1e3);
118
+ }
119
+ }
90
120
  return;
91
121
  }
92
122
  if (net) {
123
+ const { ...data2 } = backupRef.current;
93
124
  dispatch((0, import_store.backUpFree)({ key: Date.now() }));
94
- dispatch((0, import_store.updateCustom)({ net }));
95
- } else {
96
- dispatch((0, import_store.updateState)({ lastComponent: "Network" }));
97
- dispatch((0, import_store.backUpProduction)({}));
98
- dispatch((0, import_store.updateCustom)({ net }));
99
- dispatch((0, import_store.updateComponent)("Network"));
125
+ dispatch((0, import_store.updateState)({ net }));
126
+ if (data2.status === "success") {
127
+ const status = data2.status;
128
+ const params = (0, import_helper.getPayParams)(dataRef.current, status);
129
+ clearRef.current = setTimeout(() => {
130
+ onChange(status, params);
131
+ }, 1e3);
132
+ }
133
+ return;
100
134
  }
101
- }, [dispatch, net]);
135
+ dispatch((0, import_store.updateState)({ form: "Network" }));
136
+ dispatch((0, import_store.backUpProduction)({}));
137
+ dispatch((0, import_store.updateState)({ net, status: "warn" }));
138
+ dispatch((0, import_store.updateComponent)("Network"));
139
+ }, [dispatch, net, onChange]);
140
+ (0, import_react.useEffect)(() => {
141
+ return () => {
142
+ if (clearRef.current) {
143
+ clearTimeout(clearRef.current);
144
+ }
145
+ };
146
+ }, []);
102
147
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, data.render ? /* @__PURE__ */ import_react.default.createElement(
103
148
  "div",
104
149
  {
105
150
  className: `pisell-lowcode__eft-pay-box ${className}`,
106
151
  style: data.type === "step" ? {} : { display: "none" }
107
152
  },
108
- /* @__PURE__ */ import_react.default.createElement(import_header.default, { status: data.status, title: data.title }),
153
+ /* @__PURE__ */ import_react.default.createElement(
154
+ import_header.default,
155
+ {
156
+ status: data.status,
157
+ title: data.title,
158
+ subTitle: data.subTitle
159
+ }
160
+ ),
109
161
  data.eftpos === "payo" ? /* @__PURE__ */ import_react.default.createElement(import_manufacturer.Payo, { api, onChange }, data.warn && data.status !== import_const.StatusEnum.Success ? /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__eft-pay-step-item pisell-lowcode__eft-pay-step-item-warn" }, data.warn) : null, data.status === import_const.StatusEnum.Success ? /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__eft-pay-step-item pisell-lowcode__eft-pay-step-item-tip" }, import_utils.locales.getText("page.eftpos-pay.text.transaction.end")) : null) : null,
110
- data.eftpos === "eftpos" ? /* @__PURE__ */ import_react.default.createElement(import_manufacturer.Eftpos, { api, onChange }, data.warn && data.status !== import_const.StatusEnum.Success ? /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__eft-pay-step-item pisell-lowcode__eft-pay-step-item-warn" }, data.warn) : null, data.status === import_const.StatusEnum.Success ? /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__eft-pay-step-item pisell-lowcode__eft-pay-step-item-tip" }, import_utils.locales.getText("page.eftpos-pay.text.transaction.end")) : null) : null,
111
- data.eftpos === "windcave" ? /* @__PURE__ */ import_react.default.createElement(import_manufacturer.Windcave, { api, onChange, key: data.key }) : null
162
+ data.eftpos === "tyro" ? /* @__PURE__ */ import_react.default.createElement(import_manufacturer.Tyro, { api, onChange, key: data.key, url: tyroUrl, version: tyroVersion }) : null,
163
+ data.eftpos === "windcave" ? /* @__PURE__ */ import_react.default.createElement(
164
+ import_manufacturer.Windcave,
165
+ {
166
+ api,
167
+ onChange,
168
+ key: data.key,
169
+ formatAmount
170
+ }
171
+ ) : null
112
172
  ) : null, data.type === import_const.PayRouteEnum.Unset && Comm ? /* @__PURE__ */ import_react.default.createElement(
113
173
  Comm,
114
174
  {
115
175
  onChange,
116
176
  api,
117
177
  className,
118
- isIpad: true
178
+ isIpad,
179
+ formatAmount
119
180
  }
120
181
  ) : null);
121
182
  };
@@ -36,7 +36,6 @@ module.exports = __toCommonJS(config_exports);
36
36
  var import_utils = require("@pisell/utils");
37
37
  var import_antd = require("antd");
38
38
  var import_react = __toESM(require("react"));
39
- var import_decimal = require("decimal.js");
40
39
  var import_step = __toESM(require("../component/step"));
41
40
  var import_const = require("../const");
42
41
  var import_helper = require("../helper");
@@ -47,296 +46,150 @@ var POS = ({
47
46
  api,
48
47
  onChange
49
48
  }) => {
50
- var _a, _b;
51
- const { steps, eftpos, device, custom, status, mode } = (0, import_store.useContextData)();
52
- const refundRef = (0, import_react.useRef)(
53
- custom == null ? void 0 : custom.refund
54
- );
55
- const statusRef = (0, import_react.useRef)(status);
49
+ const { steps } = (0, import_store.useContextData)();
50
+ const {
51
+ deviceRef,
52
+ payRef,
53
+ numRef,
54
+ statusRef,
55
+ modeRef,
56
+ netRef,
57
+ orderIdRef,
58
+ amountRef,
59
+ eftposRef
60
+ } = (0, import_hooks.useStoreRef)();
56
61
  const dispatch = (0, import_store.useDispatch)();
57
62
  const { key, ...props } = steps[0];
58
- const modeRef = (0, import_react.useRef)(mode);
59
- const ref = (0, import_react.useRef)(custom == null ? void 0 : custom.number);
60
- const customRef = (0, import_react.useRef)(custom);
61
- const deviceRef = (0, import_react.useRef)(device);
62
- const stepStatusRef = (0, import_react.useRef)((_a = props == null ? void 0 : props.custom) == null ? void 0 : _a.status);
63
63
  const fail = (0, import_hooks.useFail)(0, true);
64
64
  const failRef = (0, import_react.useRef)(fail);
65
65
  const controllerRef = (0, import_react.useRef)();
66
66
  const clearRef = (0, import_react.useRef)();
67
67
  const initRef = (0, import_react.useRef)(false);
68
68
  const unloadRef = (0, import_react.useRef)(false);
69
- const netRef = (0, import_react.useRef)(custom == null ? void 0 : custom.net);
70
69
  const [check] = (0, import_hooks2.useValidate)(1e3 * 60);
71
- (0, import_react.useEffect)(() => {
72
- customRef.current = custom;
73
- }, [custom]);
74
- (0, import_react.useEffect)(() => {
75
- deviceRef.current = device;
76
- }, [device]);
77
- (0, import_react.useEffect)(() => {
78
- modeRef.current = mode;
79
- }, [mode]);
80
- (0, import_react.useEffect)(() => {
81
- refundRef.current = custom == null ? void 0 : custom.refund;
82
- }, [custom == null ? void 0 : custom.refund]);
83
- (0, import_react.useEffect)(() => {
84
- statusRef.current = status;
85
- }, [status]);
86
- (0, import_react.useEffect)(() => {
87
- netRef.current = custom == null ? void 0 : custom.net;
88
- }, [custom == null ? void 0 : custom.net]);
89
- (0, import_react.useEffect)(() => {
90
- var _a2;
91
- stepStatusRef.current = (_a2 = props == null ? void 0 : props.custom) == null ? void 0 : _a2.status;
92
- }, [(_b = props == null ? void 0 : props.custom) == null ? void 0 : _b.status]);
93
70
  (0, import_react.useEffect)(() => {
94
71
  failRef.current = fail;
95
72
  }, [fail]);
73
+ const success = (res) => {
74
+ dispatch((0, import_store.updateNextStep)());
75
+ dispatch(
76
+ (0, import_store.updateCustom)({
77
+ card_reader_surcharge: (res == null ? void 0 : res.card_reader_surcharge) || 0
78
+ })
79
+ );
80
+ clearRef.current = setTimeout(() => {
81
+ var _a, _b;
82
+ const params = (0, import_helper.getPayParams)(
83
+ {
84
+ mode: modeRef.current,
85
+ amount: amountRef.current,
86
+ order_id: orderIdRef.current,
87
+ number: numRef.current,
88
+ device: deviceRef.current,
89
+ pay: payRef.current,
90
+ custom: {
91
+ card_reader_surcharge: (res == null ? void 0 : res.card_reader_surcharge) || 0
92
+ }
93
+ },
94
+ "success"
95
+ );
96
+ const receipt = Array.isArray(res.receipt) ? res.receipt : [res.receipt];
97
+ onChange("success", {
98
+ ...params,
99
+ receipt: ((_b = (_a = deviceRef.current) == null ? void 0 : _a.setting) == null ? void 0 : _b.receipts) ? [] : receipt
100
+ });
101
+ }, 1e3);
102
+ };
103
+ const checkApi = () => {
104
+ check(api.check, numRef.current).then(
105
+ (res) => {
106
+ if (unloadRef.current || !netRef.current) {
107
+ return;
108
+ }
109
+ if (res && `${res.code}` === "200") {
110
+ success(res);
111
+ return;
112
+ }
113
+ failRef.current(res);
114
+ },
115
+ (res) => {
116
+ if (unloadRef.current || !netRef.current) {
117
+ return;
118
+ }
119
+ failRef.current(res);
120
+ }
121
+ );
122
+ };
96
123
  (0, import_react.useEffect)(() => {
97
- var _a2, _b2, _c;
124
+ var _a, _b;
125
+ if (statusRef.current === import_const.StatusEnum.Success || statusRef.current === import_const.StatusEnum.Fail) {
126
+ return;
127
+ }
98
128
  if (initRef.current) {
99
129
  return;
100
130
  }
101
131
  initRef.current = true;
102
- if (statusRef.current !== import_const.StatusEnum.Loading) {
132
+ if (numRef.current) {
133
+ checkApi();
103
134
  return;
104
135
  }
105
- if (!ref.current) {
106
- const { pay, order_id } = customRef.current;
107
- ref.current = (0, import_helper.getUuid)();
108
- dispatch(
109
- (0, import_store.updateState)({
110
- custom: { ...customRef.current, number: ref.current }
111
- })
112
- );
113
- if (api && api.pay) {
114
- controllerRef.current = new AbortController();
115
- let clear;
116
- const resultPromise = modeRef.current === import_const.ModeEnum.Pay ? api.pay(
117
- {
118
- order_id,
119
- amount: pay.total,
120
- card_reader_type: eftpos,
121
- card_reader_id: (_a2 = deviceRef.current) == null ? void 0 : _a2.id,
122
- number: ref.current
123
- },
124
- { signal: controllerRef.current.signal }
125
- ) : api.refund(
126
- {
127
- order_id,
128
- amount: (_b2 = refundRef.current) == null ? void 0 : _b2.total,
129
- card_reader_type: eftpos,
130
- card_reader_id: (_c = deviceRef.current) == null ? void 0 : _c.id,
131
- number: ref.current
132
- },
133
- { signal: controllerRef.current.signal }
134
- );
135
- resultPromise.then((res) => {
136
- var _a3;
137
- console.log("netRef.current = ", netRef.current);
138
- if (unloadRef.current) {
139
- return;
140
- }
141
- if (!((_a3 = customRef.current) == null ? void 0 : _a3.net)) {
142
- return;
143
- }
144
- if (res && (res.code === 200 || res.code === "200")) {
145
- dispatch(
146
- (0, import_store.updateCurrentCustomStemItem)({
147
- status: "pay"
148
- })
149
- );
150
- return res;
151
- }
152
- if (res && `${res.code}` === import_const.PayStatus.Timeout) {
153
- dispatch(
154
- (0, import_store.updateCurrentCustomStemItem)({
155
- status: "pay"
156
- })
157
- );
158
- }
159
- return Promise.reject(res);
160
- }).then(
161
- (res) => {
162
- var _a3;
163
- console.log("netRef.current = ", netRef.current);
164
- if (unloadRef.current) {
165
- return;
166
- }
167
- if (!((_a3 = customRef.current) == null ? void 0 : _a3.net)) {
168
- return;
169
- }
170
- dispatch((0, import_store.updateNextStep)());
171
- clear = setTimeout(() => {
172
- var _a4, _b3;
173
- if (modeRef.current === import_const.ModeEnum.Pay) {
174
- const obj = ((_a4 = customRef.current) == null ? void 0 : _a4.pay) || {};
175
- const cardReaderSurcharge = ((_b3 = res == null ? void 0 : res.data) == null ? void 0 : _b3.card_reader_surcharge) || 0;
176
- const surCardDeci = new import_decimal.Decimal(Number(cardReaderSurcharge));
177
- const surMoneyDeci = new import_decimal.Decimal(Number((obj == null ? void 0 : obj.surMoney) || 0));
178
- const surRateMoneyDeci = new import_decimal.Decimal(
179
- Number(obj == null ? void 0 : obj.surRateMoney)
180
- );
181
- const surMoneyTotal = surMoneyDeci.add(surCardDeci);
182
- const surchargeDeci = surMoneyTotal.add(surRateMoneyDeci);
183
- onChange("success", {
184
- ...obj,
185
- number: ref.current,
186
- device: deviceRef.current,
187
- cardReaderSurcharge,
188
- surMoney: surMoneyTotal.toFixed(2, import_decimal.Decimal.ROUND_HALF_UP),
189
- surcharge: surchargeDeci.toFixed(2, import_decimal.Decimal.ROUND_HALF_UP)
190
- });
191
- return;
192
- }
193
- if (modeRef.current === import_const.ModeEnum.Refund) {
194
- const obj = refundRef.current || {};
195
- onChange("success", {
196
- ...obj,
197
- number: ref.current,
198
- device: deviceRef.current
199
- });
200
- return;
201
- }
202
- onChange("success", { number: ref.current });
203
- }, 1e3);
204
- },
205
- (res) => Promise.reject(res)
206
- ).catch((res) => {
207
- var _a3;
208
- console.log("netRef.current = ", netRef.current);
209
- if (unloadRef.current) {
210
- return;
211
- }
212
- if (!((_a3 = customRef.current) == null ? void 0 : _a3.net)) {
213
- return;
214
- }
215
- if (res && `${res.code}` === import_const.PayStatus.Timeout) {
216
- check(api.check, ref.current).then(
217
- (r) => {
218
- var _a4;
219
- console.log(" check :检车2 ,r ", r);
220
- if (unloadRef.current) {
221
- return;
222
- }
223
- if (!((_a4 = customRef.current) == null ? void 0 : _a4.net)) {
224
- return;
225
- }
226
- if (r && (r.code === 200 || r.code === "200")) {
227
- dispatch(
228
- (0, import_store.updateCurrentCustomStemItem)({
229
- status: "pay"
230
- })
231
- );
232
- dispatch((0, import_store.updateNextStep)());
233
- clearRef.current = setTimeout(() => {
234
- var _a5, _b3;
235
- const cardReaderSurcharge = ((_a5 = res == null ? void 0 : res.data) == null ? void 0 : _a5.card_reader_surcharge) || 0;
236
- const obj = ((_b3 = customRef.current) == null ? void 0 : _b3.pay) || {};
237
- const surCardDeci = new import_decimal.Decimal(
238
- Number(cardReaderSurcharge)
239
- );
240
- const surMoneyDeci = new import_decimal.Decimal(
241
- Number((obj == null ? void 0 : obj.surMoney) || 0)
242
- );
243
- const surRateMoneyDeci = new import_decimal.Decimal(
244
- Number(obj == null ? void 0 : obj.surRateMoney)
245
- );
246
- const surMoneyTotal = surMoneyDeci.add(surCardDeci);
247
- const surchargeDeci = surMoneyTotal.add(surRateMoneyDeci);
248
- onChange("success", {
249
- ...obj,
250
- number: ref.current,
251
- device: deviceRef.current,
252
- cardReaderSurcharge,
253
- surMoney: surMoneyTotal.toFixed(
254
- 2,
255
- import_decimal.Decimal.ROUND_HALF_UP
256
- ),
257
- surcharge: surchargeDeci.toFixed(
258
- 2,
259
- import_decimal.Decimal.ROUND_HALF_UP
260
- )
261
- });
262
- }, 1e3);
263
- return;
264
- }
265
- failRef.current(r);
266
- },
267
- (r) => {
268
- var _a4;
269
- if (unloadRef.current) {
270
- return;
271
- }
272
- if (!((_a4 = customRef.current) == null ? void 0 : _a4.net)) {
273
- return;
274
- }
275
- failRef.current(r);
276
- }
277
- );
278
- } else {
279
- failRef.current(res);
280
- }
281
- });
136
+ numRef.current = (0, import_helper.getUuid)();
137
+ dispatch(
138
+ (0, import_store.updateState)({
139
+ number: numRef.current
140
+ })
141
+ );
142
+ controllerRef.current = new AbortController();
143
+ const resultPromise = modeRef.current === import_const.ModeEnum.Pay ? api.pay(
144
+ {
145
+ order_id: orderIdRef.current,
146
+ amount: payRef.current.total,
147
+ card_reader_type: eftposRef.current,
148
+ card_reader_id: (_a = deviceRef.current) == null ? void 0 : _a.id,
149
+ number: numRef.current
150
+ },
151
+ { signal: controllerRef.current.signal }
152
+ ) : api.refund(
153
+ {
154
+ order_id: orderIdRef.current,
155
+ amount: amountRef.current,
156
+ card_reader_type: eftposRef.current,
157
+ card_reader_id: (_b = deviceRef.current) == null ? void 0 : _b.id,
158
+ number: numRef.current
159
+ },
160
+ { signal: controllerRef.current.signal }
161
+ );
162
+ resultPromise.then((res) => {
163
+ console.log("netRef.current111 = ", netRef.current);
164
+ if (unloadRef.current || !netRef.current) {
165
+ return;
282
166
  }
283
- } else {
284
- check(api.check, ref.current).then(
285
- (res) => {
286
- var _a3;
287
- console.log(" check 检车 ,r ", res);
288
- if (unloadRef.current) {
289
- return;
290
- }
291
- if (!((_a3 = customRef.current) == null ? void 0 : _a3.net)) {
292
- return;
293
- }
294
- if (res && (res.code === 200 || res.code === "200")) {
295
- dispatch(
296
- (0, import_store.updateCurrentCustomStemItem)({
297
- status: "pay"
298
- })
299
- );
300
- dispatch((0, import_store.updateNextStep)());
301
- clearRef.current = setTimeout(() => {
302
- var _a4, _b3;
303
- const cardReaderSurcharge = ((_a4 = res == null ? void 0 : res.data) == null ? void 0 : _a4.card_reader_surcharge) || 0;
304
- const obj = ((_b3 = customRef.current) == null ? void 0 : _b3.pay) || {};
305
- const surCardDeci = new import_decimal.Decimal(Number(cardReaderSurcharge));
306
- const surMoneyDeci = new import_decimal.Decimal(Number((obj == null ? void 0 : obj.surMoney) || 0));
307
- const surRateMoneyDeci = new import_decimal.Decimal(Number(obj == null ? void 0 : obj.surRateMoney));
308
- const surMoneyTotal = surMoneyDeci.add(surCardDeci);
309
- const surchargeDeci = surMoneyTotal.add(surRateMoneyDeci);
310
- onChange("success", {
311
- ...obj,
312
- number: ref.current,
313
- device: deviceRef.current,
314
- cardReaderSurcharge,
315
- surMoney: surMoneyTotal.toFixed(2, import_decimal.Decimal.ROUND_HALF_UP),
316
- surcharge: surchargeDeci.toFixed(2, import_decimal.Decimal.ROUND_HALF_UP)
317
- });
318
- }, 1e3);
319
- return;
320
- }
321
- failRef.current(res);
322
- },
323
- (res) => {
324
- var _a3;
325
- if (unloadRef.current) {
326
- return;
327
- }
328
- if (!((_a3 = customRef.current) == null ? void 0 : _a3.net)) {
329
- return;
330
- }
331
- failRef.current(res);
332
- }
167
+ if (res && `${res.code}` === "200") {
168
+ success(res);
169
+ return;
170
+ }
171
+ return Promise.reject(res);
172
+ }).catch((err) => {
173
+ console.log(
174
+ "netRef.current222 = ",
175
+ netRef.current,
176
+ unloadRef.current,
177
+ err
333
178
  );
334
- }
335
- }, [api, check, dispatch, eftpos, onChange]);
179
+ if (unloadRef.current || !netRef.current) {
180
+ return;
181
+ }
182
+ if (err && `${err.code}` === import_const.PayStatus.Timeout) {
183
+ checkApi();
184
+ return;
185
+ }
186
+ failRef.current(err);
187
+ });
188
+ }, [api, check, dispatch, onChange]);
336
189
  (0, import_react.useEffect)(
337
190
  () => () => {
338
- var _a2;
339
- (_a2 = controllerRef.current) == null ? void 0 : _a2.abort();
191
+ var _a;
192
+ (_a = controllerRef.current) == null ? void 0 : _a.abort();
340
193
  unloadRef.current = true;
341
194
  if (clearRef.current) {
342
195
  clearTimeout(clearRef.current);