@pisell/private-materials 3.4.13 → 3.4.14

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 (108) 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.js +11 -11
  8. package/build/lowcode/view.js +11 -11
  9. package/es/components/booking/components/TabProduct/tabs/index.js +1 -5
  10. package/es/components/booking/components/browserSelect/index.js +1 -1
  11. package/es/components/booking/editBookingModal/index.js +3 -4
  12. package/es/components/booking/forms/model.js +5 -5
  13. package/es/components/booking/info/service/addService/utils.d.ts +1 -1
  14. package/es/components/booking/info/service/like/index.js +1 -1
  15. package/es/components/booking/info/service2/utils.d.ts +1 -1
  16. package/es/components/booking/info2/service/addService/utils.d.ts +1 -1
  17. package/es/components/booking/info2/service/addService/utils.js +16 -1
  18. package/es/components/booking/notes/NoteBlock/NoteItem/index.js +1 -1
  19. package/es/components/booking/notes/NoteBlock/index.js +11 -11
  20. package/es/components/booking/notes/model.js +5 -5
  21. package/es/components/booking/payments/model.js +5 -5
  22. package/es/components/booking/utils.d.ts +2 -2
  23. package/es/components/eftposPay/const.d.ts +4 -1
  24. package/es/components/eftposPay/const.js +3 -1
  25. package/es/components/eftposPay/hooks.d.ts +2 -2
  26. package/es/components/eftposPay/hooks.js +3 -1
  27. package/es/components/eftposPay/index.js +1 -1
  28. package/es/components/eftposPay/linkly/const.d.ts +23 -0
  29. package/es/components/eftposPay/linkly/const.js +82 -0
  30. package/es/components/eftposPay/linkly/hooks/index.d.ts +2 -0
  31. package/es/components/eftposPay/linkly/hooks/index.js +2 -0
  32. package/es/components/eftposPay/linkly/hooks/normal.d.ts +30 -0
  33. package/es/components/eftposPay/linkly/hooks/normal.js +321 -0
  34. package/es/components/eftposPay/linkly/hooks/useTimeQuery.d.ts +4 -0
  35. package/es/components/eftposPay/linkly/hooks/useTimeQuery.js +273 -0
  36. package/es/components/eftposPay/linkly/index.d.ts +2 -0
  37. package/es/components/eftposPay/linkly/index.js +197 -0
  38. package/es/components/eftposPay/linkly/service.d.ts +32 -0
  39. package/es/components/eftposPay/linkly/service.js +81 -0
  40. package/es/components/eftposPay/manufacturer.d.ts +1 -0
  41. package/es/components/eftposPay/manufacturer.js +4 -0
  42. package/es/components/eftposPay/pay.d.ts +1 -1
  43. package/es/components/eftposPay/pay.js +6 -2
  44. package/es/components/eftposPay/store/index.d.ts +4 -4
  45. package/es/components/listComponent/index.js +5 -5
  46. package/es/components/productExtension/card/index.js +3 -3
  47. package/es/components/productExtension/fields/Actor/CutOffTime/index.js +1 -1
  48. package/es/components/productExtension/fields/Forms/index.js +12 -12
  49. package/es/components/productExtension/fields/SelectProducts/ProductItemPreview/index.js +1 -1
  50. package/es/components/productExtension/fields/SelectProducts/server.js +2 -2
  51. package/es/components/productExtension/fields/SelectResourcesTable/server.js +2 -2
  52. package/es/components/productExtension/server.js +2 -2
  53. package/es/components/ruleSetting/ruleBorder/index.js +1 -1
  54. package/es/components/schedules/calendar/index.js +4 -4
  55. package/es/components/schedules/calendar/serve.js +2 -2
  56. package/es/components/schedules/components/CurrentDay/index.js +5 -5
  57. package/es/components/schedules/components/CurrentDay/serve.js +2 -2
  58. package/es/components/schedules/components/DropdownSort/index.js +1 -1
  59. package/es/components/schedules/components/ResourceList/index.js +1 -1
  60. package/es/components/schedules/components/Search/index.js +5 -5
  61. package/es/components/schedules/model.js +5 -5
  62. package/es/components/schedules/openHours/index.js +1 -1
  63. package/es/components/schedules/openHours/serve.js +2 -2
  64. package/es/components/schedules/products/ProductDetailDrawer/ProductDetail/MaxParticipantsModule/index.js +1 -1
  65. package/es/components/schedules/products/ProductDetailDrawer/ProductDetail/ResourcesModule/index.js +5 -5
  66. package/es/components/schedules/products/ProductDetailDrawer/ProductDetail/SchedulesModule/index.js +4 -4
  67. package/es/components/schedules/products/ProductDetailDrawer/index.js +3 -3
  68. package/es/components/schedules/products/serve.js +2 -2
  69. package/es/components/schedules/products/utils.js +5 -5
  70. package/es/components/schedules/resources/detail/detailContent.js +2 -2
  71. package/es/components/schedules/resources/detail/index.js +10 -10
  72. package/es/components/schedules/resources/list/index.js +2 -2
  73. package/es/components/schedules/resources/relationProduct/index.js +1 -1
  74. package/es/components/schedules/resources/serve.js +2 -2
  75. package/es/components/schedules/schedules/ScheduleDetailDrawer/index.js +9 -9
  76. package/es/components/schedules/utils.js +4 -4
  77. package/es/components/selectModal/index.js +2 -2
  78. package/es/hooks/useComponents.js +1 -1
  79. package/lib/components/booking/editBookingModal/index.js +3 -4
  80. package/lib/components/booking/info/service/addService/utils.d.ts +1 -1
  81. package/lib/components/booking/info/service2/utils.d.ts +1 -1
  82. package/lib/components/booking/info2/service/addService/utils.d.ts +1 -1
  83. package/lib/components/booking/info2/service/addService/utils.js +15 -3
  84. package/lib/components/booking/utils.d.ts +2 -2
  85. package/lib/components/eftposPay/const.d.ts +4 -1
  86. package/lib/components/eftposPay/const.js +2 -0
  87. package/lib/components/eftposPay/hooks.d.ts +2 -2
  88. package/lib/components/eftposPay/hooks.js +11 -4
  89. package/lib/components/eftposPay/index.js +1 -1
  90. package/lib/components/eftposPay/linkly/const.d.ts +23 -0
  91. package/lib/components/eftposPay/linkly/const.js +102 -0
  92. package/lib/components/eftposPay/linkly/hooks/index.d.ts +2 -0
  93. package/lib/components/eftposPay/linkly/hooks/index.js +25 -0
  94. package/lib/components/eftposPay/linkly/hooks/normal.d.ts +30 -0
  95. package/lib/components/eftposPay/linkly/hooks/normal.js +242 -0
  96. package/lib/components/eftposPay/linkly/hooks/useTimeQuery.d.ts +4 -0
  97. package/lib/components/eftposPay/linkly/hooks/useTimeQuery.js +222 -0
  98. package/lib/components/eftposPay/linkly/index.d.ts +2 -0
  99. package/lib/components/eftposPay/linkly/index.js +208 -0
  100. package/lib/components/eftposPay/linkly/service.d.ts +32 -0
  101. package/lib/components/eftposPay/linkly/service.js +55 -0
  102. package/lib/components/eftposPay/manufacturer.d.ts +1 -0
  103. package/lib/components/eftposPay/manufacturer.js +6 -0
  104. package/lib/components/eftposPay/pay.d.ts +1 -1
  105. package/lib/components/eftposPay/pay.js +13 -2
  106. package/lib/components/eftposPay/store/index.d.ts +4 -4
  107. package/lib/components/schedules/utils.js +1 -1
  108. package/package.json +1 -1
@@ -0,0 +1,242 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/components/eftposPay/linkly/hooks/normal.ts
20
+ var normal_exports = {};
21
+ __export(normal_exports, {
22
+ useLinklyCancel: () => useLinklyCancel,
23
+ useLinklyPayOrRefund: () => useLinklyPayOrRefund,
24
+ useLinklySignature: () => useLinklySignature
25
+ });
26
+ module.exports = __toCommonJS(normal_exports);
27
+ var import_ahooks = require("ahooks");
28
+ var import_react = require("react");
29
+ var import_utils = require("@pisell/utils");
30
+ var import_service = require("../service");
31
+ var import_hooks = require("../../hooks");
32
+ var import_const = require("../../const");
33
+ var import_store = require("../../store");
34
+ var import_const2 = require("../const");
35
+ var useLinklyPayOrRefund = (handleCheck) => {
36
+ const dispatch = (0, import_store.useDispatch)();
37
+ const { numRef, modeRef, orderIdRef, deviceRef, payRef, amountRef } = (0, import_hooks.useStoreRef)();
38
+ const fail = (0, import_hooks.useFail)(0);
39
+ const failRef = (0, import_react.useRef)(fail);
40
+ const resultQueryRef = (0, import_react.useRef)(null);
41
+ const handleLinklySuccessRef = (0, import_react.useRef)(null);
42
+ (0, import_react.useEffect)(() => {
43
+ failRef.current = fail;
44
+ }, [fail]);
45
+ const isPay = modeRef.current === import_const.ModeEnum.Pay || modeRef.current === import_const.ModeEnum.FullPay;
46
+ const _pay = (0, import_ahooks.useRequest)(isPay ? import_service.linklyPayApi : import_service.linklyRefundApi, {
47
+ manual: true,
48
+ onSuccess: (res) => {
49
+ onSuccess(res);
50
+ },
51
+ onError: (error) => {
52
+ onError(error);
53
+ }
54
+ });
55
+ const onSuccess = (res) => {
56
+ var _a, _b, _c, _d;
57
+ console.log(`linkly${isPay ? "Pay" : "Refund"}Success---->>>>>>>`, res);
58
+ if (!handleCheck()) {
59
+ return;
60
+ }
61
+ (0, import_utils.sendWarningLog)({
62
+ title: `Linkly-${isPay ? "Pay" : "Refund"}-接口成功`,
63
+ content: [{ key: "response", value: JSON.stringify(res) }]
64
+ });
65
+ const status = (_a = res == null ? void 0 : res.data) == null ? void 0 : _a.status;
66
+ if (status === 0) {
67
+ numRef.current = (_b = res == null ? void 0 : res.data) == null ? void 0 : _b.session_id;
68
+ dispatch((0, import_store.updateState)({ number: numRef.current }));
69
+ dispatch((0, import_store.updateCustom)({ actionStatus: import_const2.LinklyActionStatus.Cancel }));
70
+ setTimeout(() => {
71
+ var _a2;
72
+ (_a2 = resultQueryRef.current) == null ? void 0 : _a2.call(resultQueryRef);
73
+ });
74
+ return;
75
+ }
76
+ dispatch((0, import_store.updateCustom)({ actionStatus: import_const2.LinklyActionStatus.Empty }));
77
+ if (status === 1) {
78
+ (_c = handleLinklySuccessRef.current) == null ? void 0 : _c.call(handleLinklySuccessRef, res);
79
+ return;
80
+ }
81
+ if (status < 0) {
82
+ res.code = import_const.PayStatus.Unknown;
83
+ (_d = failRef.current) == null ? void 0 : _d.call(failRef, res, false);
84
+ }
85
+ };
86
+ const onError = (error) => {
87
+ var _a;
88
+ console.log(`linkly${isPay ? "Pay" : "Refund"}Error---->>>>>>>`, error);
89
+ if (!handleCheck()) {
90
+ return;
91
+ }
92
+ (0, import_utils.sendWarningLog)({
93
+ title: `Linkly-${isPay ? "Pay" : "Refund"}-接口失败`,
94
+ content: [{ key: "error", value: JSON.stringify(error) }]
95
+ });
96
+ (_a = failRef.current) == null ? void 0 : _a.call(failRef, error, false);
97
+ };
98
+ const payOrRefund = (resultQuery, handleLinklySuccess) => {
99
+ var _a, _b, _c;
100
+ handleLinklySuccessRef.current = handleLinklySuccess;
101
+ resultQueryRef.current = resultQuery;
102
+ const param = {
103
+ // 订单id
104
+ order_id: orderIdRef.current,
105
+ // 设备id
106
+ pinpad_id: (_b = (_a = deviceRef == null ? void 0 : deviceRef.current) == null ? void 0 : _a.metadata) == null ? void 0 : _b.linkly_pinpad_id,
107
+ // 交易金额, 包含选择的订单金额+手续费,订单金额+手续费=交易金额
108
+ amount: isPay ? (_c = payRef.current) == null ? void 0 : _c.total : amountRef.current
109
+ };
110
+ (0, import_utils.sendWarningLog)({
111
+ title: `Linkly-${isPay ? "Pay" : "Refund"}`,
112
+ content: [{ key: "params", value: JSON.stringify(param) }]
113
+ });
114
+ _pay.run(param);
115
+ };
116
+ return {
117
+ action: { pay: _pay },
118
+ payOrRefund
119
+ };
120
+ };
121
+ var useLinklyCancel = (handleCheck) => {
122
+ const dispatch = (0, import_store.useDispatch)();
123
+ const { numRef, modeRef, deviceRef } = (0, import_hooks.useStoreRef)();
124
+ const resultQueryRef = (0, import_react.useRef)(null);
125
+ const isPay = modeRef.current === import_const.ModeEnum.Pay || modeRef.current === import_const.ModeEnum.FullPay;
126
+ const cancelAction = (res, type) => {
127
+ var _a;
128
+ dispatch((0, import_store.updateCustom)({ buttonDisabled: false }));
129
+ if (!handleCheck()) {
130
+ return;
131
+ }
132
+ if (type === "success") {
133
+ (0, import_utils.sendWarningLog)({
134
+ title: `Linkly-${isPay ? "Pay" : "Refund"}-取消成功`,
135
+ content: [{ key: "response", value: JSON.stringify(res) }]
136
+ });
137
+ } else {
138
+ (0, import_utils.sendWarningLog)({
139
+ title: `Linkly-${isPay ? "Pay" : "Refund"}-取消失败`,
140
+ content: [{ key: "error", value: JSON.stringify(res) }]
141
+ });
142
+ }
143
+ (_a = resultQueryRef.current) == null ? void 0 : _a.call(resultQueryRef);
144
+ };
145
+ const _cancel = (0, import_ahooks.useRequest)(
146
+ isPay ? import_service.linklyPayCancelApi : import_service.linklyRefundCancelApi,
147
+ {
148
+ manual: true,
149
+ onSuccess: (res) => cancelAction(res, "success"),
150
+ onError: (error) => cancelAction(error, "error")
151
+ }
152
+ );
153
+ const linklyCancel = (resultQuery) => {
154
+ var _a, _b;
155
+ resultQueryRef.current = resultQuery;
156
+ dispatch((0, import_store.updateCustom)({ buttonDisabled: true }));
157
+ const param = {
158
+ // 设备id
159
+ pinpad_id: (_b = (_a = deviceRef == null ? void 0 : deviceRef.current) == null ? void 0 : _a.metadata) == null ? void 0 : _b.linkly_pinpad_id,
160
+ // 交易流水号
161
+ session_id: numRef.current
162
+ };
163
+ (0, import_utils.sendWarningLog)({
164
+ title: `Linkly-${isPay ? "Pay" : "Refund"}-取消`,
165
+ content: [{ key: "params", value: JSON.stringify(param) }]
166
+ });
167
+ _cancel.run(param);
168
+ dispatch((0, import_store.updateCustom)({ actionStatus: import_const2.LinklyActionStatus.CancelWaiting }));
169
+ };
170
+ return {
171
+ action: { cancel: _cancel },
172
+ linklyCancel
173
+ };
174
+ };
175
+ var useLinklySignature = (handleCheck) => {
176
+ const dispatch = (0, import_store.useDispatch)();
177
+ const { numRef, modeRef, deviceRef } = (0, import_hooks.useStoreRef)();
178
+ const resultQueryRef = (0, import_react.useRef)(null);
179
+ const isPay = modeRef.current === import_const.ModeEnum.Pay || modeRef.current === import_const.ModeEnum.FullPay;
180
+ const signatureAction = (res, type) => {
181
+ var _a;
182
+ console.log("signatureAction---->>>>>>>", res);
183
+ if (!handleCheck()) {
184
+ return;
185
+ }
186
+ if (type === "success") {
187
+ (0, import_utils.sendWarningLog)({
188
+ title: `Linkly-${isPay ? "Pay" : "Refund"}-签名成功`,
189
+ content: [{ key: "response", value: JSON.stringify(res) }]
190
+ });
191
+ } else {
192
+ (0, import_utils.sendWarningLog)({
193
+ title: `Linkly-${isPay ? "Pay" : "Refund"}-签名失败`,
194
+ content: [{ key: "error", value: JSON.stringify(res) }]
195
+ });
196
+ }
197
+ (_a = resultQueryRef.current) == null ? void 0 : _a.call(resultQueryRef);
198
+ };
199
+ const _signature = (0, import_ahooks.useRequest)(
200
+ isPay ? import_service.linklyPaySignatureApi : import_service.linklyRefundSignatureApi,
201
+ {
202
+ manual: true,
203
+ onSuccess: (res) => signatureAction(res, "success"),
204
+ onError: (error) => signatureAction(error, "error")
205
+ }
206
+ );
207
+ const linklySignature = (status, resultQuery) => {
208
+ var _a, _b;
209
+ resultQueryRef.current = resultQuery;
210
+ const param = {
211
+ // 设备id
212
+ pinpad_id: (_b = (_a = deviceRef == null ? void 0 : deviceRef.current) == null ? void 0 : _a.metadata) == null ? void 0 : _b.linkly_pinpad_id,
213
+ // 交易流水号
214
+ session_id: numRef.current,
215
+ signature_flag: status
216
+ };
217
+ dispatch((0, import_store.updateStatus)(import_const.StatusEnum.Loading));
218
+ dispatch(
219
+ (0, import_store.updateState)({
220
+ title: import_utils.locales.getText("page.eftpos-pay.text.loading")(modeRef.current)
221
+ })
222
+ );
223
+ dispatch(
224
+ (0, import_store.updateCustom)({ actionStatus: import_const2.LinklyActionStatus.SignatureWaiting })
225
+ );
226
+ (0, import_utils.sendWarningLog)({
227
+ title: `Linkly-${isPay ? "Pay" : "Refund"}-签名`,
228
+ content: [{ key: "params", value: JSON.stringify(param) }]
229
+ });
230
+ _signature.run(param);
231
+ };
232
+ return {
233
+ action: { signature: _signature },
234
+ linklySignature
235
+ };
236
+ };
237
+ // Annotate the CommonJS export names for ESM import in node:
238
+ 0 && (module.exports = {
239
+ useLinklyCancel,
240
+ useLinklyPayOrRefund,
241
+ useLinklySignature
242
+ });
@@ -0,0 +1,4 @@
1
+ export declare const useTimeResultQuery: (api: any, resultCheck: () => boolean, handleLinklySuccess: (res: any) => void) => {
2
+ run: () => Promise<void>;
3
+ stop: () => void;
4
+ };
@@ -0,0 +1,222 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/components/eftposPay/linkly/hooks/useTimeQuery.ts
20
+ var useTimeQuery_exports = {};
21
+ __export(useTimeQuery_exports, {
22
+ useTimeResultQuery: () => useTimeResultQuery
23
+ });
24
+ module.exports = __toCommonJS(useTimeQuery_exports);
25
+ var import_react = require("react");
26
+ var import_utils = require("@pisell/utils");
27
+ var import_store = require("../../store");
28
+ var import_hooks = require("../../hooks");
29
+ var import_const = require("../../const");
30
+ var import_const2 = require("../const");
31
+ var GlobalTimeout = 1e3 * 60;
32
+ var RequestTimeout = 1e3 * 5;
33
+ var useTimeResultQuery = (api, resultCheck, handleLinklySuccess) => {
34
+ const dispatch = (0, import_store.useDispatch)();
35
+ const { numRef, modeRef, deviceRef } = (0, import_hooks.useStoreRef)();
36
+ const fail = (0, import_hooks.useFail)(0);
37
+ const failRef = (0, import_react.useRef)(fail);
38
+ const isPay = modeRef.current === import_const.ModeEnum.Pay || modeRef.current === import_const.ModeEnum.FullPay;
39
+ const controllerRef = (0, import_react.useRef)(null);
40
+ const requestTimeoutIdRef = (0, import_react.useRef)(
41
+ null
42
+ );
43
+ const globalTimeoutIdRef = (0, import_react.useRef)(null);
44
+ const isRequestCanceledRef = (0, import_react.useRef)(false);
45
+ const startTimeRef = (0, import_react.useRef)(null);
46
+ const isQueryFinishedRef = (0, import_react.useRef)(true);
47
+ const queryIdRef = (0, import_react.useRef)(null);
48
+ const _resultQuery = async () => {
49
+ var _a, _b;
50
+ if (controllerRef.current) {
51
+ controllerRef.current.abort();
52
+ controllerRef.current = null;
53
+ }
54
+ if (requestTimeoutIdRef.current) {
55
+ clearTimeout(requestTimeoutIdRef.current);
56
+ requestTimeoutIdRef.current = null;
57
+ }
58
+ controllerRef.current = new AbortController();
59
+ const { signal } = controllerRef.current;
60
+ isRequestCanceledRef.current = false;
61
+ requestTimeoutIdRef.current = setTimeout(() => {
62
+ var _a2;
63
+ console.log("单次请求超时,将尝试重试");
64
+ _log("RequestTimeout" /* RequestTimeout */);
65
+ (_a2 = controllerRef.current) == null ? void 0 : _a2.abort();
66
+ isRequestCanceledRef.current = true;
67
+ }, RequestTimeout);
68
+ const requestApi = isPay ? api.linklyPayQuery : api.linklyRefundQuery;
69
+ const params = {
70
+ // 设备id
71
+ pinpad_id: (_b = (_a = deviceRef == null ? void 0 : deviceRef.current) == null ? void 0 : _a.metadata) == null ? void 0 : _b.linkly_pinpad_id,
72
+ // 交易流水号
73
+ session_id: numRef.current
74
+ };
75
+ const requestPromise = requestApi(params, { signal });
76
+ requestPromise.then((result) => {
77
+ var _a2;
78
+ console.log("Success: 请求成功", result);
79
+ if (checkNeedToHandleResult()) {
80
+ console.log("Success: 全局超时或不需要处理结果,终止查询");
81
+ return;
82
+ }
83
+ _log("Success" /* Success */, result);
84
+ isQueryFinishedRef.current = true;
85
+ const data = (result == null ? void 0 : result.data) || {};
86
+ if (data.status === 1) {
87
+ console.log("交易成功,终止查询");
88
+ reset();
89
+ handleLinklySuccess(result);
90
+ return;
91
+ }
92
+ if (data.status !== void 0 && (data == null ? void 0 : data.status) === 0) {
93
+ console.log("交易状态为0需要继续查询");
94
+ isQueryFinishedRef.current = false;
95
+ _resultQuery();
96
+ return;
97
+ }
98
+ if (data.status < 0) {
99
+ console.log("交易失败,终止查询");
100
+ reset();
101
+ result.code = import_const.PayStatus.Unknown;
102
+ (_a2 = failRef.current) == null ? void 0 : _a2.call(failRef, result, false);
103
+ return;
104
+ }
105
+ if (data.signature_flag === 1) {
106
+ console.log("交易需要签名,终止查询");
107
+ reset();
108
+ gotoSignature();
109
+ return;
110
+ }
111
+ }).catch((error) => {
112
+ var _a2;
113
+ console.log("Error: 请求失败", error);
114
+ if (checkNeedToHandleResult()) {
115
+ console.log("Error: 全局超时或不需要处理结果,终止查询");
116
+ return;
117
+ }
118
+ isQueryFinishedRef.current = true;
119
+ if ((error == null ? void 0 : error.name) === "AbortError" /* AbortError */ || isRequestCanceledRef.current) {
120
+ _log("AbortError" /* AbortError */);
121
+ console.log("Error: 请求被取消,将继续查询");
122
+ isQueryFinishedRef.current = false;
123
+ _resultQuery();
124
+ return;
125
+ }
126
+ _log("Error" /* Error */, error);
127
+ reset();
128
+ (_a2 = failRef.current) == null ? void 0 : _a2.call(failRef, error, true);
129
+ }).finally(() => {
130
+ if (requestTimeoutIdRef.current) {
131
+ clearTimeout(requestTimeoutIdRef.current);
132
+ requestTimeoutIdRef.current = null;
133
+ }
134
+ });
135
+ };
136
+ const gotoSignature = () => {
137
+ dispatch((0, import_store.updateStatus)(import_const.StatusEnum.Question));
138
+ dispatch(
139
+ (0, import_store.updateState)({
140
+ title: import_utils.locales.getText("page.eftpos-pay.text.receipt.again.title")
141
+ })
142
+ );
143
+ dispatch((0, import_store.updateCustom)({ actionStatus: import_const2.LinklyActionStatus.Signature }));
144
+ };
145
+ const checkNeedToHandleResult = () => {
146
+ return checkIsGlobalTimeout() || !resultCheck() || isQueryFinishedRef.current;
147
+ };
148
+ const checkIsGlobalTimeout = () => {
149
+ if (startTimeRef.current) {
150
+ const elapsedTime = Date.now() - startTimeRef.current;
151
+ if (elapsedTime > GlobalTimeout) {
152
+ return true;
153
+ } else {
154
+ return false;
155
+ }
156
+ }
157
+ return false;
158
+ };
159
+ const reset = () => {
160
+ console.log("linkly查询状态重制<<<<<<<----");
161
+ _log("Reset" /* Reset */);
162
+ if (globalTimeoutIdRef.current) {
163
+ clearTimeout(globalTimeoutIdRef.current);
164
+ globalTimeoutIdRef.current = null;
165
+ }
166
+ if (requestTimeoutIdRef.current) {
167
+ clearTimeout(requestTimeoutIdRef.current);
168
+ requestTimeoutIdRef.current = null;
169
+ }
170
+ if (controllerRef.current) {
171
+ controllerRef.current.abort();
172
+ controllerRef.current = null;
173
+ }
174
+ startTimeRef.current = null;
175
+ isRequestCanceledRef.current = false;
176
+ isQueryFinishedRef.current = true;
177
+ queryIdRef.current = null;
178
+ };
179
+ const _log = (type, res) => {
180
+ var _a, _b;
181
+ const params = {
182
+ // 设备id
183
+ pinpad_id: (_b = (_a = deviceRef == null ? void 0 : deviceRef.current) == null ? void 0 : _a.metadata) == null ? void 0 : _b.linkly_pinpad_id,
184
+ // 交易流水号
185
+ session_id: numRef.current
186
+ };
187
+ const content = [
188
+ { key: "queryId", value: JSON.stringify(queryIdRef.current) },
189
+ { key: "params", value: JSON.stringify(params) }
190
+ ];
191
+ if (type === "Success" /* Success */) {
192
+ content.push({ key: "response", value: JSON.stringify(res) });
193
+ } else if (type === "Error" /* Error */) {
194
+ content.push({ key: "error", value: JSON.stringify(res) });
195
+ }
196
+ (0, import_utils.sendWarningLog)({
197
+ title: `Linkly-${isPay ? "Pay" : "Refund"}-结果查询--${type}`,
198
+ content
199
+ });
200
+ };
201
+ const run = () => {
202
+ reset();
203
+ console.log("开始查询linkly结果---->>>>>>>");
204
+ _log("Start" /* Start */);
205
+ globalTimeoutIdRef.current = setTimeout(() => {
206
+ var _a;
207
+ console.log("全局超时,终止所有重试");
208
+ _log("GlobalTimeout" /* GlobalTimeout */);
209
+ setTimeout(reset, 0);
210
+ (_a = failRef.current) == null ? void 0 : _a.call(failRef, { code: import_const.PayStatus.Timeout }, false);
211
+ }, GlobalTimeout);
212
+ startTimeRef.current = Date.now();
213
+ isQueryFinishedRef.current = false;
214
+ queryIdRef.current = (0, import_utils.getUniqueId)();
215
+ return _resultQuery();
216
+ };
217
+ return { run, stop: reset };
218
+ };
219
+ // Annotate the CommonJS export names for ESM import in node:
220
+ 0 && (module.exports = {
221
+ useTimeResultQuery
222
+ });
@@ -0,0 +1,2 @@
1
+ declare const Linkly: ({ api, onChange }: any) => JSX.Element;
2
+ export default Linkly;
@@ -0,0 +1,208 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/components/eftposPay/linkly/index.tsx
30
+ var linkly_exports = {};
31
+ __export(linkly_exports, {
32
+ default: () => linkly_default
33
+ });
34
+ module.exports = __toCommonJS(linkly_exports);
35
+ var import_react = __toESM(require("react"));
36
+ var import_antd = require("antd");
37
+ var import_utils = require("@pisell/utils");
38
+ var import_store = require("../store");
39
+ var import_hooks = require("../hooks");
40
+ var import_useEngineContext = __toESM(require("../../../hooks/useEngineContext"));
41
+ var import_utils2 = require("../../../utils");
42
+ var import_step = __toESM(require("../component/step/step"));
43
+ var import_const = require("../const");
44
+ var import_hooks2 = require("./hooks");
45
+ var import_const2 = require("./const");
46
+ var import_helper = require("../helper");
47
+ var Linkly = ({ api, onChange }) => {
48
+ const context = (0, import_useEngineContext.default)();
49
+ const utils = context.appHelper.utils || {};
50
+ import_utils2.request.setRequest(utils == null ? void 0 : utils.request);
51
+ const { custom, status } = (0, import_store.useContextData)();
52
+ const {
53
+ statusRef,
54
+ netRef,
55
+ modeRef,
56
+ amountRef,
57
+ orderIdRef,
58
+ numRef,
59
+ deviceRef,
60
+ payRef
61
+ } = (0, import_hooks.useStoreRef)();
62
+ const dispatch = (0, import_store.useDispatch)();
63
+ const stepRef = (0, import_react.useRef)(custom == null ? void 0 : custom.step);
64
+ const fail = (0, import_hooks.useFail)(0);
65
+ const failRef = (0, import_react.useRef)(fail);
66
+ const initRef = (0, import_react.useRef)(false);
67
+ const controllerRef = (0, import_react.useRef)();
68
+ const unloadRef = (0, import_react.useRef)(false);
69
+ const clearRef = (0, import_react.useRef)();
70
+ const handleCheck = () => !(unloadRef.current || !netRef.current);
71
+ const handleLinklySuccess = (res) => {
72
+ const resData = (res == null ? void 0 : res.data) || {};
73
+ let receipt = Array.isArray(resData == null ? void 0 : resData.receipt) ? resData.receipt : [resData.receipt];
74
+ receipt = receipt.filter((item) => typeof item === "string").filter(Boolean);
75
+ dispatch((0, import_store.updateNextStep)());
76
+ dispatch(
77
+ (0, import_store.updateCustom)({
78
+ card_reader_surcharge: (resData == null ? void 0 : resData.card_reader_surcharge) || 0,
79
+ receipt
80
+ })
81
+ );
82
+ dispatch(
83
+ (0, import_store.updateState)({
84
+ status: "success",
85
+ title: import_utils.locales.getText("page.eftpos-pay.text.successful")(
86
+ modeRef.current
87
+ )
88
+ })
89
+ );
90
+ clearRef.current = setTimeout(() => {
91
+ var _a, _b;
92
+ const params = (0, import_helper.getPayParams)(
93
+ {
94
+ mode: modeRef.current,
95
+ amount: amountRef.current,
96
+ order_id: orderIdRef.current,
97
+ number: numRef.current,
98
+ device: deviceRef.current,
99
+ pay: payRef.current,
100
+ custom: {
101
+ card_reader_surcharge: (resData == null ? void 0 : resData.card_reader_surcharge) || 0,
102
+ receipt
103
+ }
104
+ },
105
+ "success"
106
+ );
107
+ onChange("success", {
108
+ ...params,
109
+ receipt: ((_b = (_a = deviceRef.current) == null ? void 0 : _a.setting) == null ? void 0 : _b.receipts) ? [] : receipt
110
+ });
111
+ }, 1e3);
112
+ };
113
+ const { payOrRefund } = (0, import_hooks2.useLinklyPayOrRefund)(handleCheck);
114
+ const { linklyCancel } = (0, import_hooks2.useLinklyCancel)(handleCheck);
115
+ const { run: resultQuery, stop: stopResultQuery } = (0, import_hooks2.useTimeResultQuery)(
116
+ api,
117
+ handleCheck,
118
+ handleLinklySuccess
119
+ );
120
+ const { linklySignature } = (0, import_hooks2.useLinklySignature)(handleCheck);
121
+ (0, import_react.useEffect)(() => {
122
+ stepRef.current = custom == null ? void 0 : custom.step;
123
+ }, [custom == null ? void 0 : custom.step]);
124
+ (0, import_react.useEffect)(() => {
125
+ failRef.current = fail;
126
+ }, [fail]);
127
+ (0, import_react.useEffect)(() => {
128
+ if (statusRef.current === import_const.StatusEnum.Success || statusRef.current === import_const.StatusEnum.Fail) {
129
+ return;
130
+ }
131
+ if (initRef.current) {
132
+ return;
133
+ }
134
+ initRef.current = true;
135
+ if (numRef.current) {
136
+ resultQuery();
137
+ return;
138
+ }
139
+ payOrRefund(resultQuery, handleLinklySuccess);
140
+ }, []);
141
+ (0, import_react.useEffect)(() => {
142
+ return () => {
143
+ var _a;
144
+ (_a = controllerRef.current) == null ? void 0 : _a.abort();
145
+ unloadRef.current = true;
146
+ if (clearRef.current) {
147
+ clearTimeout(clearRef.current);
148
+ }
149
+ };
150
+ }, []);
151
+ const onCancel = () => {
152
+ stopResultQuery();
153
+ linklyCancel(resultQuery);
154
+ };
155
+ const onDecline = () => {
156
+ stopResultQuery();
157
+ linklySignature(2, resultQuery);
158
+ };
159
+ const onAccept = () => {
160
+ stopResultQuery();
161
+ linklySignature(3, resultQuery);
162
+ };
163
+ return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__eft-pay-body" }, ((custom == null ? void 0 : custom.list) || []).map((item) => /* @__PURE__ */ import_react.default.createElement(
164
+ import_step.default,
165
+ {
166
+ key: item.index,
167
+ pedding: item.pedding,
168
+ resolve: item.resolve,
169
+ reject: item.reject,
170
+ status: item.status
171
+ }
172
+ )), status === import_const.StatusEnum.Loading ? /* @__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.processing")) : null, status === import_const.StatusEnum.Question ? /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__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.receipt.again.title")), /* @__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.receipt.again.text"))) : null, 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), (custom == null ? void 0 : custom.actionStatus) === import_const2.LinklyActionStatus.Cancel ? /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__eft-pay-step-item-btns" }, /* @__PURE__ */ import_react.default.createElement(
173
+ import_antd.Button,
174
+ {
175
+ block: true,
176
+ className: "pisell-lowcode__eft-pay-step-item-btn",
177
+ onClick: onCancel,
178
+ disabled: !!(custom == null ? void 0 : custom.buttonDisabled)
179
+ },
180
+ import_utils.locales.getText("page.eftpos-pay.text.cancel")
181
+ )) : null, (custom == null ? void 0 : custom.actionStatus) === import_const2.LinklyActionStatus.CancelWaiting || (custom == null ? void 0 : custom.actionStatus) === import_const2.LinklyActionStatus.SignatureWaiting ? /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__eft-pay-step-item-btns" }, /* @__PURE__ */ import_react.default.createElement(
182
+ import_antd.Button,
183
+ {
184
+ block: true,
185
+ className: "pisell-lowcode__eft-pay-step-item-btn",
186
+ disabled: true
187
+ },
188
+ import_utils.locales.getText("page.eftpos-pay.text.leave")
189
+ )) : null, (custom == null ? void 0 : custom.actionStatus) === import_const2.LinklyActionStatus.Signature ? /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__eft-pay-step-item-btns" }, /* @__PURE__ */ import_react.default.createElement(
190
+ import_antd.Button,
191
+ {
192
+ block: true,
193
+ className: "pisell-lowcode__eft-pay-step-item-btn",
194
+ onClick: onDecline
195
+ },
196
+ import_utils.locales.getText("page.eftpos-pay.text.decline")
197
+ ), /* @__PURE__ */ import_react.default.createElement(
198
+ import_antd.Button,
199
+ {
200
+ block: true,
201
+ type: "primary",
202
+ className: "pisell-lowcode__eft-pay-step-item-btn",
203
+ onClick: onAccept
204
+ },
205
+ import_utils.locales.getText("page.eftpos-pay.text.accept")
206
+ )) : null);
207
+ };
208
+ var linkly_default = Linkly;