@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
@@ -19,41 +19,52 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
19
19
  /* eslint-disable array-callback-return */
20
20
  import { locales } from '@pisell/utils';
21
21
  import React, { useEffect, useMemo, useRef, useState } from 'react';
22
- import { Decimal } from 'decimal.js';
22
+ import { useStoreRef } from "../hooks";
23
23
  import Step from "../component/step/step";
24
24
  import { StatusEnum, ModeEnum } from "../const";
25
- import { getUuid } from "../helper";
25
+ import { getUuid, getPayParams } from "../helper";
26
26
  import { useDispatch, useContextData, updateState, updateCustom } from "../store";
27
27
  import { StemTypeEnum, StepStatusEnum, getStepMapping } from "./const";
28
28
  import { useFail, useValidate } from "./helper";
29
29
  import Action, { ReceiptAction } from "./receiptAction";
30
30
  var Minute = 1000 * 60;
31
+
32
+ // 注意断网与卸载未完成的回调将终止处理
31
33
  export default (function (_ref) {
32
34
  var api = _ref.api,
33
- onChange = _ref.onChange;
35
+ onChange = _ref.onChange,
36
+ _ref$formatAmount = _ref.formatAmount,
37
+ formatAmount = _ref$formatAmount === void 0 ? function (number, precision, symbol) {
38
+ return "".concat(symbol).concat(number);
39
+ } : _ref$formatAmount;
34
40
  var _useContextData = useContextData(),
35
- eftpos = _useContextData.eftpos,
36
41
  custom = _useContextData.custom,
37
- device = _useContextData.device,
38
- status = _useContextData.status,
39
- mode = _useContextData.mode;
42
+ status = _useContextData.status;
43
+ var _useStoreRef = useStoreRef(),
44
+ deviceRef = _useStoreRef.deviceRef,
45
+ payRef = _useStoreRef.payRef,
46
+ numRef = _useStoreRef.numRef,
47
+ orderIdRef = _useStoreRef.orderIdRef,
48
+ modeRef = _useStoreRef.modeRef,
49
+ statusRef = _useStoreRef.statusRef,
50
+ netRef = _useStoreRef.netRef,
51
+ symbolRef = _useStoreRef.symbolRef,
52
+ amountRef = _useStoreRef.amountRef,
53
+ eftposRef = _useStoreRef.eftposRef;
40
54
  var dispatch = useDispatch();
41
55
  var fail = useFail();
42
56
  var failRef = useRef(fail);
43
- var modeRef = useRef(mode);
44
- var statusRef = useRef(status);
45
57
  var unloadRef = useRef(false);
46
- var customRef = useRef(custom);
47
- var deviceRef = useRef(device);
48
- var refundRef = useRef(custom === null || custom === void 0 ? void 0 : custom.refund);
49
- var ref = useRef(custom === null || custom === void 0 ? void 0 : custom.number);
50
58
  var stepRef = useRef(custom === null || custom === void 0 ? void 0 : custom.step);
51
59
  var listRef = useRef(custom === null || custom === void 0 ? void 0 : custom.list);
52
60
  var initRef = useRef(false);
53
- var isPayRef = useRef(custom === null || custom === void 0 ? void 0 : custom.isPay);
61
+ var clearRef = useRef();
62
+
63
+ /** 是否是签名页面 */
54
64
  var isReceiptPage = useMemo(function () {
55
65
  return (custom === null || custom === void 0 ? void 0 : custom.step) === StepStatusEnum.Receipt;
56
66
  }, [custom === null || custom === void 0 ? void 0 : custom.step]);
67
+ /** 签名页面状态 */
57
68
  var receiptPage = useMemo(function () {
58
69
  return (custom === null || custom === void 0 ? void 0 : custom.step) !== StepStatusEnum.Receipt ? '' : (custom === null || custom === void 0 ? void 0 : custom.receiptPage) || 'receipt';
59
70
  }, [custom === null || custom === void 0 ? void 0 : custom.step, custom === null || custom === void 0 ? void 0 : custom.receiptPage]);
@@ -61,166 +72,148 @@ export default (function (_ref) {
61
72
  _useState2 = _slicedToArray(_useState, 2),
62
73
  disabled = _useState2[0],
63
74
  setDisabled = _useState2[1];
64
- useEffect(function () {
65
- statusRef.current = status;
66
- }, [status]);
67
- useEffect(function () {
68
- modeRef.current = mode;
69
- }, [mode]);
70
- useEffect(function () {
71
- isPayRef.current = custom === null || custom === void 0 ? void 0 : custom.isPay;
72
- }, [custom === null || custom === void 0 ? void 0 : custom.isPay]);
73
75
  useEffect(function () {
74
76
  listRef.current = custom === null || custom === void 0 ? void 0 : custom.list;
75
77
  }, [custom === null || custom === void 0 ? void 0 : custom.list]);
76
78
  useEffect(function () {
77
79
  stepRef.current = custom === null || custom === void 0 ? void 0 : custom.step;
78
80
  }, [custom === null || custom === void 0 ? void 0 : custom.step]);
79
- useEffect(function () {
80
- refundRef.current = custom === null || custom === void 0 ? void 0 : custom.refund;
81
- }, [custom === null || custom === void 0 ? void 0 : custom.refund]);
82
- useEffect(function () {
83
- customRef.current = custom;
84
- }, [custom]);
85
- useEffect(function () {
86
- deviceRef.current = device;
87
- }, [device]);
88
- useEffect(function () {
89
- ref.current = custom === null || custom === void 0 ? void 0 : custom.number;
90
- }, [custom === null || custom === void 0 ? void 0 : custom.number]);
91
81
  useEffect(function () {
92
82
  failRef.current = fail;
93
83
  }, [fail]);
84
+
85
+ /**
86
+ * @title: 查询支付状态
87
+ * @description: 轮询 api.check 检查支付状态, 中间状态转换在 useValidate 中进行,结束在当前回调中完成
88
+ * @param {*} useValidate
89
+ * @return {*}
90
+ * @Author: hongbing.wang
91
+ * @Date: 2024-08-12 11:02
92
+ */
94
93
  var _useValidate = useValidate(api.check, Minute, function (res) {
94
+ // 将所有步骤状态设为完成 resolve
95
95
  dispatch(updateCustom({
96
96
  list: listRef.current.map(function (item) {
97
97
  return _objectSpread(_objectSpread({}, item), {}, {
98
98
  status: 'resolve'
99
99
  });
100
- })
100
+ }),
101
+ card_reader_surcharge: (res === null || res === void 0 ? void 0 : res.card_reader_surcharge) || 0
101
102
  }));
103
+
104
+ // 更新支付状态与文案
102
105
  dispatch(updateState({
103
106
  status: 'success',
104
- title: locales.getText('page.eftpos-pay.text.successful')(mode)
107
+ title: locales.getText('page.eftpos-pay.text.successful')(modeRef.current)
105
108
  }));
106
- setTimeout(function () {
107
- if (modeRef.current === ModeEnum.Pay) {
108
- var _customRef$current;
109
- var obj = ((_customRef$current = customRef.current) === null || _customRef$current === void 0 ? void 0 : _customRef$current.pay) || {};
110
- var cardReaderSurcharge = (res === null || res === void 0 ? void 0 : res.card_reader_surcharge) || 0;
111
- // 卡手续费
112
- var surCardDeci = new Decimal(Number(cardReaderSurcharge));
113
-
114
- // 手续费-固定金额
115
- var surMoneyDeci = new Decimal(Number((obj === null || obj === void 0 ? void 0 : obj.surMoney) || 0));
116
-
117
- // 手续费-比例金额
118
- var surRateMoneyDeci = new Decimal(Number(obj === null || obj === void 0 ? void 0 : obj.surRateMoney));
119
-
120
- // 手续费-固定金额 + 卡手续费 = 固定金额总额
121
- var surMoneyTotal = surMoneyDeci.add(surCardDeci);
122
-
123
- // 手续费-固定金额 + 卡手续费 + 手续费-比例金额 = 总手续费
124
- var surchargeDeci = surMoneyTotal.add(surRateMoneyDeci);
125
- onChange('success', _objectSpread(_objectSpread({}, obj), {}, {
126
- cardReaderSurcharge: cardReaderSurcharge,
127
- surMoney: surMoneyTotal.toFixed(2, Decimal.ROUND_HALF_UP),
128
- surcharge: surchargeDeci.toFixed(2, Decimal.ROUND_HALF_UP),
129
- number: ref.current,
130
- device: deviceRef.current
131
- }));
132
- return;
133
- }
134
- if (modeRef.current === ModeEnum.Refund) {
135
- var _obj = refundRef.current || {};
136
- onChange('success', _objectSpread(_objectSpread({}, _obj), {}, {
137
- number: ref.current,
138
- device: deviceRef.current
139
- }));
140
- return;
141
- }
142
- onChange('success', {
143
- number: ref.current
144
- });
109
+ clearRef.current = setTimeout(function () {
110
+ var _deviceRef$current, _deviceRef$current$se;
111
+ var params = getPayParams({
112
+ mode: modeRef.current,
113
+ amount: amountRef.current,
114
+ order_id: orderIdRef.current,
115
+ number: numRef.current,
116
+ device: deviceRef.current,
117
+ pay: payRef.current,
118
+ custom: {
119
+ card_reader_surcharge: (res === null || res === void 0 ? void 0 : res.card_reader_surcharge) || 0
120
+ }
121
+ }, 'success');
122
+ var receipt = Array.isArray(res.receipt) ? res.receipt : [res.receipt];
123
+ onChange('success', _objectSpread(_objectSpread({}, params), {}, {
124
+ 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
125
+ }));
145
126
  }, 1000);
146
127
  }),
147
- _useValidate2 = _slicedToArray(_useValidate, 1),
148
- run = _useValidate2[0];
128
+ _useValidate2 = _slicedToArray(_useValidate, 2),
129
+ run = _useValidate2[0],
130
+ validateRef = _useValidate2[1];
149
131
  var controllerRef = useRef();
150
132
  useEffect(function () {
133
+ var _deviceRef$current2, _deviceRef$current3;
134
+ if (statusRef.current === StatusEnum.Success || statusRef.current === StatusEnum.Fail) {
135
+ return;
136
+ }
151
137
  if (initRef.current) {
152
138
  return;
153
139
  }
154
140
  initRef.current = true;
155
- var _ref2 = customRef.current,
156
- pay = _ref2.pay,
157
- order_id = _ref2.order_id;
141
+ // 是否在签名步骤
158
142
  if (stepRef.current === StepStatusEnum.Receipt) {
159
143
  if (StatusEnum.Loading === statusRef.current) {
144
+ // 签名页面处于运行中(已发送签名,或取消签名接口),则进行计时查询
160
145
  run();
161
146
  } else {
147
+ // 签名页面处于未加载中,则进行无限查询
162
148
  run(-1);
163
149
  }
164
150
  return;
165
151
  }
166
152
  controllerRef.current = new AbortController();
167
- if (!ref.current) {
168
- var _deviceRef$current, _refundRef$current, _deviceRef$current2;
169
- console.log('modeRef.current = ', modeRef.current);
170
- ref.current = getUuid();
171
- dispatch(updateCustom({
172
- number: ref.current
173
- }));
174
- var resultPromise = modeRef.current === ModeEnum.Pay ? api.pay({
175
- order_id: order_id,
176
- amount: pay.total,
177
- card_reader_type: eftpos,
178
- card_reader_id: (_deviceRef$current = deviceRef.current) === null || _deviceRef$current === void 0 ? void 0 : _deviceRef$current.id,
179
- number: ref.current
180
- }, {
181
- signal: controllerRef.current.signal
182
- }) : api.refund({
183
- order_id: order_id,
184
- amount: (_refundRef$current = refundRef.current) === null || _refundRef$current === void 0 ? void 0 : _refundRef$current.total,
185
- card_reader_type: eftpos,
186
- card_reader_id: (_deviceRef$current2 = deviceRef.current) === null || _deviceRef$current2 === void 0 ? void 0 : _deviceRef$current2.id,
187
- number: ref.current
188
- }, {
189
- signal: controllerRef.current.signal
190
- });
191
- resultPromise.then(function (res) {
192
- var _customRef$current2;
193
- if (unloadRef.current) {
194
- return;
195
- }
196
- if (!((_customRef$current2 = customRef.current) !== null && _customRef$current2 !== void 0 && _customRef$current2.net)) {
197
- return;
198
- }
199
- if (res && (res.code === 200 || res.code === '200')) {
200
- dispatch(updateCustom({
201
- isPay: true
202
- }));
203
- run();
204
- }
205
- }).catch(function (res) {
206
- var _customRef$current3, _failRef$current;
207
- if (unloadRef.current) {
208
- return;
209
- }
210
- if (!((_customRef$current3 = customRef.current) !== null && _customRef$current3 !== void 0 && _customRef$current3.net)) {
211
- return;
212
- }
213
- (_failRef$current = failRef.current) === null || _failRef$current === void 0 ? void 0 : _failRef$current.call(failRef, res, stepRef.current >= 3);
214
- });
153
+
154
+ // 存在支付流水号
155
+ if (numRef.current) {
156
+ // 计时查询
157
+ run();
215
158
  return;
216
159
  }
217
- run();
218
- }, [api, run, eftpos, dispatch]);
160
+
161
+ // 不存在支付流水号 则去创建支付
162
+ console.log('modeRef.current = ', modeRef.current);
163
+ numRef.current = getUuid();
164
+ dispatch(updateState({
165
+ number: numRef.current
166
+ }));
167
+ var resultPromise = modeRef.current === ModeEnum.Pay ? api.pay({
168
+ order_id: orderIdRef.current,
169
+ amount: payRef.current.total,
170
+ card_reader_type: eftposRef.current,
171
+ card_reader_id: (_deviceRef$current2 = deviceRef.current) === null || _deviceRef$current2 === void 0 ? void 0 : _deviceRef$current2.id,
172
+ number: numRef.current
173
+ }, {
174
+ signal: controllerRef.current.signal
175
+ }) : api.refund({
176
+ order_id: orderIdRef.current,
177
+ amount: amountRef.current,
178
+ card_reader_type: eftposRef.current,
179
+ card_reader_id: (_deviceRef$current3 = deviceRef.current) === null || _deviceRef$current3 === void 0 ? void 0 : _deviceRef$current3.id,
180
+ number: numRef.current
181
+ }, {
182
+ signal: controllerRef.current.signal
183
+ });
184
+ resultPromise.then(function (res) {
185
+ var _failRef$current;
186
+ // 无网 或 已卸载 则不进行处理
187
+ if (unloadRef.current || !netRef.current) {
188
+ return;
189
+ }
190
+ if (res && "".concat(res.code) === '200' && res.data && res.data.txn_status_id) {
191
+ var _validateRef$current;
192
+ (_validateRef$current = validateRef.current) === null || _validateRef$current === void 0 ? void 0 : _validateRef$current.call(validateRef, res, true);
193
+ return;
194
+ }
195
+ (_failRef$current = failRef.current) === null || _failRef$current === void 0 ? void 0 : _failRef$current.call(failRef, res, stepRef.current >= StepStatusEnum.Account);
196
+ }).catch(function (res) {
197
+ var _failRef$current2;
198
+ // 无网 或 已卸载 则不进行处理
199
+ if (unloadRef.current || !netRef.current) {
200
+ return;
201
+ }
202
+ (_failRef$current2 = failRef.current) === null || _failRef$current2 === void 0 ? void 0 : _failRef$current2.call(failRef, res, stepRef.current >= StepStatusEnum.Account);
203
+ });
204
+ return;
205
+ }, [api, run, dispatch]);
206
+
207
+ /**
208
+ * @title: 取消支付
209
+ * @Author: hongbing.wang
210
+ * @Date: 2024-08-20 12:51
211
+ */
219
212
  var onCancel = function onCancel() {
220
213
  setDisabled(true);
221
214
  api.update({
222
215
  type: 'CANCEL',
223
- number: custom === null || custom === void 0 ? void 0 : custom.number
216
+ number: numRef.current
224
217
  });
225
218
  };
226
219
  useEffect(function () {
@@ -228,30 +221,53 @@ export default (function (_ref) {
228
221
  var _controllerRef$curren, _controllerRef$curren2;
229
222
  unloadRef.current = true;
230
223
  (_controllerRef$curren = controllerRef.current) === null || _controllerRef$curren === void 0 ? void 0 : (_controllerRef$curren2 = _controllerRef$curren.abort) === null || _controllerRef$curren2 === void 0 ? void 0 : _controllerRef$curren2.call(_controllerRef$curren);
224
+ if (clearRef.current) {
225
+ clearTimeout(clearRef.current);
226
+ }
231
227
  };
232
228
  }, []);
229
+
230
+ /**
231
+ * @title: 签名状态
232
+ * @param {boolean} status 签名状态
233
+ * @Author: hongbing.wang
234
+ * @Date: 2024-08-20 12:54
235
+ */
233
236
  var onChangeReceipt = function onChangeReceipt(status) {
234
237
  if (status) {
238
+ // 签名,取消签名接口执行成功, 进行计时查询
235
239
  run();
236
240
  }
237
241
  };
238
242
  useEffect(function () {
239
243
  if (listRef.current.length === 0) {
244
+ // 总金额(+ 单位)
240
245
  var totalUnit = '';
241
246
  if (modeRef.current === ModeEnum.Pay) {
242
- var _customRef$current4, _customRef$current4$p;
243
- totalUnit = (_customRef$current4 = customRef.current) === null || _customRef$current4 === void 0 ? void 0 : (_customRef$current4$p = _customRef$current4.pay) === null || _customRef$current4$p === void 0 ? void 0 : _customRef$current4$p.totalUnit;
247
+ var _payRef$current;
248
+ // 支付状态,前往pay中获取
249
+ totalUnit = (_payRef$current = payRef.current) === null || _payRef$current === void 0 ? void 0 : _payRef$current.totalUnit;
244
250
  } else if (modeRef.current === ModeEnum.Refund) {
245
- var _refundRef$current2;
246
- totalUnit = ((_refundRef$current2 = refundRef.current) === null || _refundRef$current2 === void 0 ? void 0 : _refundRef$current2.totalUnit) || '';
251
+ // 退款状态,直接使用总额(退款状态不存在金额编辑)
252
+ if (payRef.current) {
253
+ totalUnit = payRef.current.totalUnit;
254
+ } else {
255
+ totalUnit = formatAmount(amountRef.current, 2, symbolRef.current);
256
+ dispatch(updateState({
257
+ pay: {
258
+ total: amountRef.current,
259
+ totalUnit: totalUnit
260
+ }
261
+ }));
262
+ }
247
263
  }
248
264
  var nextStep = getStepMapping(StepStatusEnum.Free, {
249
265
  money: totalUnit,
250
- mode: mode
266
+ mode: modeRef.current
251
267
  });
252
268
  dispatch(updateCustom({
253
269
  list: [nextStep],
254
- step: 2
270
+ step: StepStatusEnum.Free
255
271
  }));
256
272
  }
257
273
  }, [dispatch]);
@@ -268,7 +284,7 @@ export default (function (_ref) {
268
284
  });
269
285
  }) : null, receiptPage === 'again' ? /*#__PURE__*/React.createElement("div", {
270
286
  className: "pisell-lowcode__eft-pay-warn-text pisell-lowcode__eft-pay-body"
271
- }, locales.getText('page.eftpos-pay.text.signature.text')(mode)) : null, status === StatusEnum.Loading ? /*#__PURE__*/React.createElement("div", {
287
+ }, locales.getText('page.eftpos-pay.text.signature.text')(modeRef.current)) : null, status === StatusEnum.Loading ? /*#__PURE__*/React.createElement("div", {
272
288
  className: "pisell-lowcode__eft-pay-step-item pisell-lowcode__eft-pay-step-item-tip"
273
289
  }, locales.getText('page.eftpos-pay.text.processing')) : null, status === StatusEnum.Success ? /*#__PURE__*/React.createElement("div", {
274
290
  className: "pisell-lowcode__eft-pay-step-item pisell-lowcode__eft-pay-step-item-tip"
@@ -0,0 +1,11 @@
1
+ declare type OptionType = {
2
+ id?: string;
3
+ url: string;
4
+ debug?: boolean;
5
+ allowExternal?: boolean;
6
+ text?: string;
7
+ type?: 'text/javascript';
8
+ async?: boolean;
9
+ };
10
+ export default function exec(options: OptionType | string, parent: HTMLElement): Promise<unknown>;
11
+ export {};
@@ -0,0 +1,85 @@
1
+ var cache = {};
2
+ function createScript(options) {
3
+ var script = document.createElement('script');
4
+ script.type = options.type || 'text/javascript';
5
+ script.async = !!options.async;
6
+ script.id = options.id || options.url;
7
+ if (options.url) {
8
+ script.src = options.url;
9
+ }
10
+ if (options.text) {
11
+ script.text = options.text;
12
+ }
13
+ return script;
14
+ }
15
+ function loadScript(head, script) {
16
+ return new Promise(function (resolve, reject) {
17
+ // Handle Script loading
18
+ var done = false;
19
+
20
+ // Attach handlers for all browsers.
21
+ //
22
+ // References:
23
+ // http://stackoverflow.com/questions/4845762/onload-handler-for-script-tag-in-internet-explorer
24
+ // http://stevesouders.com/efws/script-onload.php
25
+ // https://www.html5rocks.com/en/tutorials/speed/script-loading/
26
+ //
27
+ script.onload = script.onreadystatechange = function () {
28
+ if (!done && (!script.readyState || script.readyState === 'loaded' || script.readyState === 'complete')) {
29
+ done = true;
30
+ script.onload = null;
31
+ resolve(script);
32
+ }
33
+ };
34
+ script.onerror = reject;
35
+ head.appendChild(script);
36
+ });
37
+ }
38
+ function getScriptById(id) {
39
+ var script = id && document.getElementById(id);
40
+ if (script) {
41
+ return script;
42
+ }
43
+ }
44
+ function getScriptByUrl(url) {
45
+ var script = url && document.querySelector("script[src='" + url + "']");
46
+ if (script) {
47
+ return script;
48
+ }
49
+ }
50
+ export default function exec(options, parent) {
51
+ if (typeof options === 'string') {
52
+ options = {
53
+ url: options,
54
+ debug: false
55
+ };
56
+ }
57
+ var cacheId = options.id || options.url;
58
+ var cacheEntry = cache[cacheId];
59
+ if (cacheEntry) {
60
+ if (!!options.debug) {
61
+ console.log('load-js: cache hit', cacheId);
62
+ }
63
+ return cacheEntry;
64
+ }
65
+ if (options.allowExternal !== false) {
66
+ var el;
67
+ if (options.id) {
68
+ el = getScriptById(options.id);
69
+ }
70
+ if (!el) {
71
+ el = getScriptByUrl(options.url);
72
+ }
73
+ if (el) {
74
+ var promise = Promise.resolve(el);
75
+ if (cacheId) {
76
+ cache[cacheId] = promise;
77
+ }
78
+ return promise;
79
+ }
80
+ }
81
+ if (!options.url && !options.text) {
82
+ throw new Error('load-js: must provide a url or text to load');
83
+ }
84
+ return loadScript(parent, createScript(options));
85
+ }
@@ -118,6 +118,7 @@ var Single = ({
118
118
  const renderItem = (0, import_react.useCallback)(
119
119
  (fieldData) => {
120
120
  let _fields = form.field || [];
121
+ _fields = _fields.filter((item) => item.status !== "hide");
121
122
  return /* @__PURE__ */ import_react.default.createElement(
122
123
  import_collapsibleList.default,
123
124
  {
@@ -5,25 +5,51 @@ export declare enum Eftpos {
5
5
  Stripe = "stripe"
6
6
  }
7
7
  export declare enum DeviceEnum {
8
+ /** 新增 */
8
9
  Add = "add",
10
+ /** 编辑 */
9
11
  Edit = "edit",
12
+ /** 重新链接 */
10
13
  Repair = "repair"
11
14
  }
12
15
  export declare type DeviceStatus = `${DeviceEnum}`;
16
+ /** 设备配置信息 */
13
17
  export interface DeviceProp {
18
+ /** 设备id */
14
19
  id?: string | number;
20
+ /** 设备名称 */
15
21
  name: string;
22
+ /** 设备类型(厂商) */
16
23
  type: Eftpos.Tyro;
24
+ /** 设备状态 */
17
25
  status: "unpaired" | "paired";
26
+ /** 设备设置(商户配置) */
18
27
  setting: {
19
28
  [key: string]: unknown;
20
29
  } | null;
30
+ /** 设备设置(第三方配置) */
21
31
  connection: {
22
32
  [key: string]: unknown;
23
33
  } | null;
24
34
  [key: string]: unknown;
25
35
  }
36
+ /**
37
+ * @title: 获取表单结果数据
38
+ * @description: 获取表单结果数据
39
+ * @param {any} list 表单配置信息
40
+ * @return {*} 表单结果信息
41
+ * @Author: hongbing.wang
42
+ * @Date: 2024-08-19 11:10
43
+ */
26
44
  export declare const getDefaultValue: (list: any) => any;
45
+ /**
46
+ * @title: 构建通用表单配置信息,构建动态表单
47
+ * @description:
48
+ * @param {any} field : array 字段信息 value 结果信息,name 上级字段信息用于嵌套, getComm : 获取字段组件配置信息
49
+ * @return form 表单配置信息
50
+ * @Author: hongbing.wang
51
+ * @Date: 2024-08-19 11:11
52
+ */
27
53
  export declare function getCommByFields({ field, value, name, getComm, }: {
28
54
  field: (string | {
29
55
  name: string;
@@ -79,6 +79,18 @@ async function getCommByFields({
79
79
  if (!commConfig) {
80
80
  return void 0;
81
81
  }
82
+ if (Array.isArray(commConfig)) {
83
+ return commConfig.map((item2) => {
84
+ const ComponentName2 = item2.Component;
85
+ const helpFn2 = import_form.helpMapping[ComponentName2];
86
+ if (helpFn2) {
87
+ return helpFn2.getCommName(item2, name);
88
+ }
89
+ item2.__sourceName = item2.name;
90
+ item2.name = name.length > 0 ? [...name, item2.name] : item2.name;
91
+ return item2;
92
+ });
93
+ }
82
94
  const ComponentName = commConfig.Component;
83
95
  const helpFn = import_form.helpMapping[ComponentName];
84
96
  if (helpFn) {
@@ -101,7 +113,7 @@ async function getCommByFields({
101
113
  };
102
114
  })
103
115
  );
104
- return result.filter(Boolean);
116
+ return result.flat().filter(Boolean);
105
117
  }
106
118
  // Annotate the CommonJS export names for ESM import in node:
107
119
  0 && (module.exports = {
@@ -1,8 +1,9 @@
1
- import React from "react";
2
- import { DeviceProp } from "./const";
1
+ import React from 'react';
2
+ import { DeviceProp } from './const';
3
3
  interface DeviceProps {
4
4
  formItemList: any[];
5
5
  onSave: (device: DeviceProp) => void;
6
+ children?: React.ReactNode;
6
7
  }
7
8
  declare const Device: (props: DeviceProps) => React.JSX.Element;
8
9
  export default Device;
@@ -38,7 +38,7 @@ var import_utils = require("@pisell/utils");
38
38
  var import_const = require("./const");
39
39
  var import_form = __toESM(require("./form"));
40
40
  var Device = (props) => {
41
- const { onSave, formItemList } = props;
41
+ const { onSave, children, formItemList } = props;
42
42
  const initialValues = (0, import_const.getDefaultValue)(formItemList);
43
43
  return /* @__PURE__ */ import_react.default.createElement(
44
44
  import_antd.Form,
@@ -48,7 +48,7 @@ var Device = (props) => {
48
48
  initialValues,
49
49
  className: "pisell-lowcode__pos-device"
50
50
  },
51
- /* @__PURE__ */ import_react.default.createElement("div", { style: { flex: 1, overflow: "auto", padding: "0 0 60px 0" } }, /* @__PURE__ */ import_react.default.createElement(import_form.default, { formItemList })),
51
+ /* @__PURE__ */ import_react.default.createElement("div", { style: { flex: 1, overflow: "auto", padding: "0 0 60px 0" } }, /* @__PURE__ */ import_react.default.createElement(import_form.default, { formItemList }), children),
52
52
  /* @__PURE__ */ import_react.default.createElement(import_antd.Form.Item, { className: "pisell-lowcode__pos-device-btn" }, /* @__PURE__ */ import_react.default.createElement(import_antd.Button, { htmlType: "submit", block: true, style: { height: "48px" } }, import_utils.locales.getText("page.eftpos.text.save")))
53
53
  );
54
54
  };
@@ -1,4 +1,9 @@
1
1
  import React from 'react';
2
+ /**
3
+ * @title: 递归循环表单数据
4
+ * @Author: hongbing.wang
5
+ * @Date: 2024-08-20 13:21
6
+ */
2
7
  declare const CustomFormItem: ({ formItemList, level, onChange, }: {
3
8
  formItemList: any[];
4
9
  level?: number | undefined;
@@ -0,0 +1,34 @@
1
+ /// <reference types="react" />
2
+ import { Eftpos } from './const';
3
+ /**
4
+ * @title: tyro 设备连接
5
+ * @Author: hongbing.wang
6
+ * @Date: 2024-08-20 13:23
7
+ */
8
+ export declare const usePairTerminalo: (type: Eftpos, params: {
9
+ url?: string | undefined;
10
+ version?: string | undefined;
11
+ }) => ({ mid, tid, apiKey, posProductData, }: {
12
+ mid: string;
13
+ tid: string;
14
+ apiKey: string;
15
+ posProductData: {
16
+ posProductVendor: string;
17
+ posProductName: string;
18
+ posProductVersion: string;
19
+ siteReference: string;
20
+ };
21
+ }, cb: (...agrn: unknown[]) => void) => Promise<void>;
22
+ /**
23
+ * @title: 获取 Tyro 资源
24
+ * @description:
25
+ * @param {Eftpos} type 类型
26
+ * @param {string} url 链接
27
+ * @return {*}
28
+ * @Author: hongbing.wang
29
+ * @Date: 2024-08-19 18:36
30
+ */
31
+ export declare const useTyro: (params: {
32
+ url?: string | undefined;
33
+ version?: string | undefined;
34
+ }) => readonly [import("react").MutableRefObject<any>, boolean];