@pisell/private-materials 6.6.61 → 6.6.63
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.
- package/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/index.js +1 -1
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/preview.js +7 -7
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +9 -9
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +9 -9
- package/es/components/booking/components/footer/amount.js +4 -3
- package/es/components/booking/components/footer/utils.js +10 -3
- package/es/components/booking/components/voucher/index.js +1 -1
- package/es/components/booking/info2/service/editService/index.js +76 -8
- package/es/components/booking/info2/service/editService/utils.d.ts +1 -0
- package/es/components/booking/info2/service/editService/utils.js +16 -0
- package/es/components/booking/payments/index.js +1 -1
- package/es/components/eftpos/PairModal/hooks.d.ts +27 -0
- package/es/components/eftpos/PairModal/hooks.js +67 -0
- package/es/components/eftpos/PairModal/index.d.ts +11 -0
- package/es/components/eftpos/PairModal/index.js +246 -0
- package/es/components/eftpos/PairModal/index.less +70 -0
- package/es/components/eftpos/SettlementModal/Action.d.ts +7 -0
- package/es/components/eftpos/SettlementModal/Action.js +141 -0
- package/es/components/eftpos/SettlementModal/index.d.ts +7 -0
- package/es/components/eftpos/SettlementModal/index.js +135 -0
- package/es/components/eftpos/SettlementModal/index.less +33 -0
- package/es/components/eftpos/SettlementModal/serve.d.ts +8 -0
- package/es/components/eftpos/SettlementModal/serve.js +171 -0
- package/es/components/eftpos/SettlementModal/types.d.ts +138 -0
- package/es/components/eftpos/SettlementModal/types.js +35 -0
- package/es/components/eftpos/SettlementModal/utils.d.ts +18 -0
- package/es/components/eftpos/SettlementModal/utils.js +351 -0
- package/es/components/eftpos/assets/mx51SCI.svg +15 -0
- package/es/components/eftpos/const.d.ts +3 -1
- package/es/components/eftpos/const.js +2 -0
- package/es/components/eftpos/device.d.ts +3 -1
- package/es/components/eftpos/device.js +14 -3
- package/es/components/eftpos/hooks.d.ts +13 -0
- package/es/components/eftpos/hooks.js +35 -0
- package/es/components/eftpos/index.js +198 -24
- package/es/components/eftpos/index.less +32 -1
- package/es/components/eftpos/locales.d.ts +80 -0
- package/es/components/eftpos/locales.js +205 -25
- package/es/components/eftpos/table.js +47 -3
- package/es/components/eftposPay/aggregatePayment/hooks/useMicropay.d.ts +2 -2
- package/es/components/eftposPay/aggregatePayment/hooks/usePayment.d.ts +8 -0
- package/es/components/eftposPay/aggregatePayment/hooks/usePayment.js +145 -0
- package/es/components/eftposPay/aggregatePayment/index.d.ts +2 -1
- package/es/components/eftposPay/aggregatePayment/index.js +2 -1
- package/es/components/eftposPay/aggregatePayment/mock.d.ts +495 -0
- package/es/components/eftposPay/aggregatePayment/mock.js +567 -0
- package/es/components/eftposPay/aggregatePayment/service.js +1 -0
- package/es/components/eftposPay/aggregatePayment/types.d.ts +12 -12
- package/es/components/eftposPay/aggregatePayment/types.js +4 -8
- package/es/components/eftposPay/aggregatePayment/utils/payment.d.ts +13 -13
- package/es/components/eftposPay/aggregatePayment/utils/payment.js +231 -168
- package/es/components/eftposPay/amount.js +15 -1
- package/es/components/eftposPay/app.js +2 -3
- package/es/components/eftposPay/component/fail/failCustom.js +13 -4
- package/es/components/eftposPay/component/fail/index.js +12 -5
- package/es/components/eftposPay/component/fail/network.js +3 -0
- package/es/components/eftposPay/component/fail/unknow.js +8 -0
- package/es/components/eftposPay/component/manual/index.js +17 -3
- package/es/components/eftposPay/component/signature/index.js +3 -0
- package/es/components/eftposPay/const.d.ts +8 -3
- package/es/components/eftposPay/const.js +2 -0
- package/es/components/eftposPay/device.js +225 -38
- package/es/components/eftposPay/helper.d.ts +3 -0
- package/es/components/eftposPay/helper.js +2 -1
- package/es/components/eftposPay/hooks.d.ts +1 -1
- package/es/components/eftposPay/index.js +50 -13
- package/es/components/eftposPay/linkly/const.js +1 -1
- package/es/components/eftposPay/linkly/hooks/normal.js +21 -68
- package/es/components/eftposPay/linkly/hooks/useTimeQuery.js +20 -81
- package/es/components/eftposPay/linkly/index.js +11 -23
- package/es/components/eftposPay/locales.d.ts +15 -0
- package/es/components/eftposPay/locales.js +30 -15
- package/es/components/eftposPay/manufacturer.d.ts +1 -0
- package/es/components/eftposPay/manufacturer.js +4 -0
- package/es/components/eftposPay/mx51/Action.d.ts +6 -0
- package/es/components/eftposPay/mx51/Action.js +144 -0
- package/es/components/eftposPay/mx51/const.d.ts +5 -0
- package/es/components/eftposPay/mx51/const.js +69 -0
- package/es/components/eftposPay/mx51/index.d.ts +6 -0
- package/es/components/eftposPay/mx51/index.js +498 -0
- package/es/components/eftposPay/mx51/types.d.ts +142 -0
- package/es/components/eftposPay/mx51/types.js +35 -0
- package/es/components/eftposPay/mx51/utils.d.ts +10 -0
- package/es/components/eftposPay/mx51/utils.js +121 -0
- package/es/components/eftposPay/pay.js +21 -9
- package/es/components/eftposPay/payo/config.js +39 -5
- package/es/components/eftposPay/payo/const.js +1 -1
- package/es/components/eftposPay/payo/hooks.js +3 -12
- package/es/components/eftposPay/payo/payment.js +69 -136
- package/es/components/eftposPay/store/index.d.ts +5 -9
- package/es/components/eftposPay/tip.js +5 -0
- package/es/components/eftposPay/tyro/const.js +1 -1
- package/es/components/eftposPay/tyro/index.js +44 -11
- package/es/components/eftposPay/utils/payLog.d.ts +81 -0
- package/es/components/eftposPay/utils/payLog.js +458 -0
- package/es/components/eftposPay/windcave/const.js +1 -1
- package/es/components/eftposPay/windcave/receiptAction.js +5 -0
- package/es/components/eftposPay/windcave/windcave.js +37 -38
- package/es/components/ticketBooking/utils/formatProductMessage.js +47 -2
- package/lib/components/booking/components/footer/amount.js +3 -3
- package/lib/components/booking/components/footer/utils.js +12 -5
- package/lib/components/booking/components/voucher/index.js +1 -1
- package/lib/components/booking/info2/service/editService/index.js +56 -5
- package/lib/components/booking/info2/service/editService/utils.d.ts +1 -0
- package/lib/components/booking/info2/service/editService/utils.js +16 -0
- package/lib/components/booking/payments/index.js +1 -1
- package/lib/components/eftpos/PairModal/hooks.d.ts +27 -0
- package/lib/components/eftpos/PairModal/hooks.js +70 -0
- package/lib/components/eftpos/PairModal/index.d.ts +11 -0
- package/lib/components/eftpos/PairModal/index.js +197 -0
- package/lib/components/eftpos/PairModal/index.less +70 -0
- package/lib/components/eftpos/SettlementModal/Action.d.ts +7 -0
- package/lib/components/eftpos/SettlementModal/Action.js +153 -0
- package/lib/components/eftpos/SettlementModal/index.d.ts +7 -0
- package/lib/components/eftpos/SettlementModal/index.js +170 -0
- package/lib/components/eftpos/SettlementModal/index.less +33 -0
- package/lib/components/eftpos/SettlementModal/serve.d.ts +8 -0
- package/lib/components/eftpos/SettlementModal/serve.js +45 -0
- package/lib/components/eftpos/SettlementModal/types.d.ts +138 -0
- package/lib/components/eftpos/SettlementModal/types.js +43 -0
- package/lib/components/eftpos/SettlementModal/utils.d.ts +18 -0
- package/lib/components/eftpos/SettlementModal/utils.js +248 -0
- package/lib/components/eftpos/assets/mx51SCI.svg +15 -0
- package/lib/components/eftpos/const.d.ts +3 -1
- package/lib/components/eftpos/const.js +2 -0
- package/lib/components/eftpos/device.d.ts +3 -1
- package/lib/components/eftpos/device.js +13 -3
- package/lib/components/eftpos/hooks.d.ts +13 -0
- package/lib/components/eftpos/hooks.js +30 -0
- package/lib/components/eftpos/index.js +121 -8
- package/lib/components/eftpos/index.less +32 -1
- package/lib/components/eftpos/locales.d.ts +80 -0
- package/lib/components/eftpos/locales.js +231 -21
- package/lib/components/eftpos/table.js +30 -2
- package/lib/components/eftposPay/aggregatePayment/hooks/useMicropay.d.ts +2 -2
- package/lib/components/eftposPay/aggregatePayment/hooks/usePayment.d.ts +8 -0
- package/lib/components/eftposPay/aggregatePayment/hooks/usePayment.js +171 -0
- package/lib/components/eftposPay/aggregatePayment/index.d.ts +2 -1
- package/lib/components/eftposPay/aggregatePayment/index.js +5 -2
- package/lib/components/eftposPay/aggregatePayment/mock.d.ts +495 -0
- package/lib/components/eftposPay/aggregatePayment/mock.js +679 -0
- package/lib/components/eftposPay/aggregatePayment/types.d.ts +12 -12
- package/lib/components/eftposPay/aggregatePayment/utils/payment.d.ts +13 -13
- package/lib/components/eftposPay/aggregatePayment/utils/payment.js +173 -123
- package/lib/components/eftposPay/amount.js +13 -1
- package/lib/components/eftposPay/app.js +4 -5
- package/lib/components/eftposPay/component/fail/failCustom.js +10 -2
- package/lib/components/eftposPay/component/fail/index.js +10 -2
- package/lib/components/eftposPay/component/fail/network.js +3 -0
- package/lib/components/eftposPay/component/fail/unknow.js +8 -0
- package/lib/components/eftposPay/component/manual/index.js +16 -2
- package/lib/components/eftposPay/component/signature/index.js +3 -0
- package/lib/components/eftposPay/const.d.ts +8 -3
- package/lib/components/eftposPay/const.js +2 -0
- package/lib/components/eftposPay/device.js +114 -25
- package/lib/components/eftposPay/helper.d.ts +3 -0
- package/lib/components/eftposPay/helper.js +2 -1
- package/lib/components/eftposPay/hooks.d.ts +1 -1
- package/lib/components/eftposPay/index.js +38 -13
- package/lib/components/eftposPay/linkly/const.js +1 -1
- package/lib/components/eftposPay/linkly/hooks/normal.js +22 -43
- package/lib/components/eftposPay/linkly/hooks/useTimeQuery.js +13 -65
- package/lib/components/eftposPay/linkly/index.js +8 -10
- package/lib/components/eftposPay/locales.d.ts +15 -0
- package/lib/components/eftposPay/locales.js +30 -15
- package/lib/components/eftposPay/manufacturer.d.ts +1 -0
- package/lib/components/eftposPay/manufacturer.js +6 -0
- package/lib/components/eftposPay/mx51/Action.d.ts +6 -0
- package/lib/components/eftposPay/mx51/Action.js +154 -0
- package/lib/components/eftposPay/mx51/const.d.ts +5 -0
- package/lib/components/eftposPay/mx51/const.js +85 -0
- package/lib/components/eftposPay/mx51/index.d.ts +6 -0
- package/lib/components/eftposPay/mx51/index.js +433 -0
- package/lib/components/eftposPay/mx51/types.d.ts +142 -0
- package/lib/components/eftposPay/mx51/types.js +43 -0
- package/lib/components/eftposPay/mx51/utils.d.ts +10 -0
- package/lib/components/eftposPay/mx51/utils.js +115 -0
- package/lib/components/eftposPay/pay.js +13 -3
- package/lib/components/eftposPay/payo/config.js +16 -8
- package/lib/components/eftposPay/payo/const.js +1 -1
- package/lib/components/eftposPay/payo/hooks.js +12 -10
- package/lib/components/eftposPay/payo/payment.js +31 -65
- package/lib/components/eftposPay/store/index.d.ts +5 -9
- package/lib/components/eftposPay/tip.js +5 -0
- package/lib/components/eftposPay/tyro/const.js +1 -1
- package/lib/components/eftposPay/tyro/index.js +21 -17
- package/lib/components/eftposPay/utils/payLog.d.ts +81 -0
- package/lib/components/eftposPay/utils/payLog.js +321 -0
- package/lib/components/eftposPay/windcave/const.js +1 -1
- package/lib/components/eftposPay/windcave/receiptAction.js +5 -0
- package/lib/components/eftposPay/windcave/windcave.js +27 -29
- package/lib/components/ticketBooking/utils/formatProductMessage.js +44 -2
- package/package.json +4 -4
- package/es/components/eftposPay/utils/log/index.d.ts +0 -110
- package/es/components/eftposPay/utils/log/index.js +0 -371
- package/lib/components/eftposPay/utils/log/index.d.ts +0 -110
- package/lib/components/eftposPay/utils/log/index.js +0 -294
|
@@ -42,6 +42,7 @@ var import_decimal = require("decimal.js");
|
|
|
42
42
|
var import_helper = require("../helper");
|
|
43
43
|
var import_step = __toESM(require("../component/step/step"));
|
|
44
44
|
var import_hooks2 = require("../hooks");
|
|
45
|
+
var import_payLog = __toESM(require("../utils/payLog"));
|
|
45
46
|
var Minute = 1e3 * 60;
|
|
46
47
|
var tyro_default = ({
|
|
47
48
|
api,
|
|
@@ -98,6 +99,7 @@ var tyro_default = ({
|
|
|
98
99
|
console.log(integrationKey, tid, mid);
|
|
99
100
|
iClient.terminalInfo(
|
|
100
101
|
({ status: status2, message, terminalInfo }) => {
|
|
102
|
+
import_payLog.default.log("Tyro:终端信息回调", { status: status2, terminalInfo, message });
|
|
101
103
|
if (status2 === "success" && (terminalInfo == null ? void 0 : terminalInfo.available)) {
|
|
102
104
|
cb();
|
|
103
105
|
}
|
|
@@ -110,7 +112,7 @@ var tyro_default = ({
|
|
|
110
112
|
);
|
|
111
113
|
};
|
|
112
114
|
const refundOrder = () => {
|
|
113
|
-
var _a, _b, _c;
|
|
115
|
+
var _a, _b, _c, _d;
|
|
114
116
|
const iClient = iClientRef.current;
|
|
115
117
|
if (!iClient) {
|
|
116
118
|
return;
|
|
@@ -173,6 +175,8 @@ var tyro_default = ({
|
|
|
173
175
|
})
|
|
174
176
|
);
|
|
175
177
|
});
|
|
178
|
+
import_payLog.default.setContext({ transactionNumber: numRef.current });
|
|
179
|
+
import_payLog.default.log("Tyro:发起退款", { number: numRef == null ? void 0 : numRef.current, amount: (_d = requestParams.current) == null ? void 0 : _d.amount });
|
|
176
180
|
iClient.initiateRefund(requestParams.current, {
|
|
177
181
|
receiptCallback: receiptCallbackImpl,
|
|
178
182
|
transactionCompleteCallback: transactionCompleteCallbackImpl,
|
|
@@ -250,6 +254,8 @@ var tyro_default = ({
|
|
|
250
254
|
})
|
|
251
255
|
);
|
|
252
256
|
});
|
|
257
|
+
import_payLog.default.setContext({ transactionNumber: numRef.current });
|
|
258
|
+
import_payLog.default.log("Tyro:发起支付", { number: numRef.current, amount: requestParams.current.amount });
|
|
253
259
|
iClient.initiatePurchase(requestParams.current, {
|
|
254
260
|
receiptCallback: receiptCallbackImpl,
|
|
255
261
|
transactionCompleteCallback: transactionCompleteCallbackImpl,
|
|
@@ -267,6 +273,7 @@ var tyro_default = ({
|
|
|
267
273
|
}
|
|
268
274
|
setStatus(Date.now());
|
|
269
275
|
merchantReceiptRef.current = {};
|
|
276
|
+
import_payLog.default.log("Tyro:恢复上次交易");
|
|
270
277
|
iClient.continueLastTransaction({
|
|
271
278
|
receiptCallback: receiptCallbackImpl,
|
|
272
279
|
transactionCompleteCallback: transactionCompleteCallbackImpl,
|
|
@@ -275,8 +282,7 @@ var tyro_default = ({
|
|
|
275
282
|
});
|
|
276
283
|
};
|
|
277
284
|
const receiptCallbackImpl = ({ signatureRequired, merchantReceipt }) => {
|
|
278
|
-
|
|
279
|
-
console.log("商家小票 小票内容 = \n", merchantReceipt);
|
|
285
|
+
import_payLog.default.log("Tyro:小票回调", { signatureRequired, hasReceipt: !!merchantReceipt });
|
|
280
286
|
const receipt = [merchantReceipt].filter((item) => typeof item === "string").filter(Boolean);
|
|
281
287
|
merchantReceiptRef.current = { signatureRequired, merchantReceipt };
|
|
282
288
|
if (signatureRequired) {
|
|
@@ -289,6 +295,7 @@ var tyro_default = ({
|
|
|
289
295
|
};
|
|
290
296
|
const statusMessageCallbackImpl = (message) => {
|
|
291
297
|
var _a;
|
|
298
|
+
import_payLog.default.log("Tyro:状态消息", { message });
|
|
292
299
|
const translateMsg = import_utils.locales.getText("page.eftpos-pay.text.tyro")(message);
|
|
293
300
|
const msg = Array.isArray(translateMsg) ? translateMsg.reduce(
|
|
294
301
|
(accumulator, currentValue) => accumulator + " " + currentValue,
|
|
@@ -319,7 +326,7 @@ var tyro_default = ({
|
|
|
319
326
|
);
|
|
320
327
|
};
|
|
321
328
|
const questionCallbackImpl = (question, answerCallback) => {
|
|
322
|
-
|
|
329
|
+
import_payLog.default.log("Tyro:交互问题回调", { question });
|
|
323
330
|
setStatus(-1);
|
|
324
331
|
setManually(false);
|
|
325
332
|
const msg = import_utils.locales.getText("page.eftpos-pay.text.tyro")(question.text);
|
|
@@ -375,15 +382,7 @@ var tyro_default = ({
|
|
|
375
382
|
var _a, _b;
|
|
376
383
|
setStatus(-1);
|
|
377
384
|
setManually(false);
|
|
378
|
-
|
|
379
|
-
"Response = " + JSON.stringify(response),
|
|
380
|
-
", Request = ",
|
|
381
|
-
JSON.stringify(requestParams.current)
|
|
382
|
-
);
|
|
383
|
-
console.log(
|
|
384
|
-
" 客户小票 response.customerReceipt = \n",
|
|
385
|
-
response.customerReceipt
|
|
386
|
-
);
|
|
385
|
+
import_payLog.default.log("Tyro:交易完成回调", { response });
|
|
387
386
|
const receipt = [
|
|
388
387
|
// merchantReceiptRef.current?.merchantReceipt,
|
|
389
388
|
response == null ? void 0 : response.customerReceipt
|
|
@@ -488,20 +487,22 @@ var tyro_default = ({
|
|
|
488
487
|
if (load && TyroRef.current) {
|
|
489
488
|
const IClient = TyroRef.current.IClient;
|
|
490
489
|
if (IClient) {
|
|
491
|
-
console.log("apiKey = ", apiKey, "posProductData = ", posProductData);
|
|
492
490
|
const iclient = new IClient(apiKey, posProductData);
|
|
493
|
-
console.log(iclient.posProductData);
|
|
494
491
|
iClientRef.current = iclient;
|
|
492
|
+
import_payLog.default.log("Tyro:SDK 初始化完成");
|
|
495
493
|
if (isCancelRef.current) {
|
|
496
494
|
return;
|
|
497
495
|
}
|
|
498
496
|
if (!numRef.current) {
|
|
499
497
|
if (modeRef.current === import_const.ModeEnum.Pay || modeRef.current === import_const.ModeEnum.FullPay) {
|
|
498
|
+
import_payLog.default.log("Tyro:支付交易,查询终端信息");
|
|
500
499
|
getTerminalInfo(payOrder);
|
|
501
500
|
} else if (modeRef.current === import_const.ModeEnum.Refund) {
|
|
501
|
+
import_payLog.default.log("Tyro:退款交易,查询终端信息");
|
|
502
502
|
getTerminalInfo(refundOrder);
|
|
503
503
|
}
|
|
504
504
|
} else {
|
|
505
|
+
import_payLog.default.log("Tyro:恢复上次交易,查询终端信息");
|
|
505
506
|
getTerminalInfo(continueLastOrder);
|
|
506
507
|
}
|
|
507
508
|
}
|
|
@@ -520,8 +521,8 @@ var tyro_default = ({
|
|
|
520
521
|
};
|
|
521
522
|
}
|
|
522
523
|
if (status === 0) {
|
|
523
|
-
console.log("开始倒计时...");
|
|
524
524
|
clear = setTimeout(() => {
|
|
525
|
+
import_payLog.default.log("Tyro:连接超时");
|
|
525
526
|
dispatch(
|
|
526
527
|
(0, import_store.updateState)({
|
|
527
528
|
status: "fail"
|
|
@@ -554,7 +555,7 @@ var tyro_default = ({
|
|
|
554
555
|
if (!iClient) {
|
|
555
556
|
return;
|
|
556
557
|
}
|
|
557
|
-
|
|
558
|
+
import_payLog.default.log("Tyro:交易超时,显示手动标记");
|
|
558
559
|
setManually(true);
|
|
559
560
|
}, Minute);
|
|
560
561
|
return () => {
|
|
@@ -564,6 +565,7 @@ var tyro_default = ({
|
|
|
564
565
|
};
|
|
565
566
|
}, [status]);
|
|
566
567
|
const onManually = () => {
|
|
568
|
+
import_payLog.default.log("Tyro:点击手动标记");
|
|
567
569
|
dispatch(
|
|
568
570
|
(0, import_store.updateState)({
|
|
569
571
|
manual: {
|
|
@@ -580,12 +582,14 @@ var tyro_default = ({
|
|
|
580
582
|
return;
|
|
581
583
|
}
|
|
582
584
|
if (status > 0) {
|
|
585
|
+
import_payLog.default.log("Tyro:取消当前交易");
|
|
583
586
|
iClient.cancelCurrentTransaction();
|
|
584
587
|
return;
|
|
585
588
|
}
|
|
586
589
|
if (isCancelRef.current) {
|
|
587
590
|
return;
|
|
588
591
|
}
|
|
592
|
+
import_payLog.default.log("Tyro:取消(交易未开始)");
|
|
589
593
|
isCancelRef.current = true;
|
|
590
594
|
dispatch(
|
|
591
595
|
(0, import_store.updateState)({
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export interface PayLogContext {
|
|
2
|
+
/** 渠道 */
|
|
3
|
+
channel?: string;
|
|
4
|
+
/** 订单ID */
|
|
5
|
+
orderId?: string | number;
|
|
6
|
+
/** 设备ID */
|
|
7
|
+
deviceId?: string | number;
|
|
8
|
+
/** 支付类型:PAYO / WINDCAVE / LINKLY / TYRO */
|
|
9
|
+
paymentType?: string;
|
|
10
|
+
/** 交易记录号 */
|
|
11
|
+
transactionNumber?: string;
|
|
12
|
+
/** 模式:pay / refund / query */
|
|
13
|
+
mode?: string;
|
|
14
|
+
/** 其他扩展信息 */
|
|
15
|
+
extra?: Record<string, any>;
|
|
16
|
+
}
|
|
17
|
+
declare class PayLog {
|
|
18
|
+
private static instance;
|
|
19
|
+
private sessionKey;
|
|
20
|
+
private context;
|
|
21
|
+
private logs;
|
|
22
|
+
private startTime;
|
|
23
|
+
private flushed;
|
|
24
|
+
private constructor();
|
|
25
|
+
static getInstance(): PayLog;
|
|
26
|
+
/**
|
|
27
|
+
* 初始化一次交易会话
|
|
28
|
+
* - 生成唯一 sessionKey
|
|
29
|
+
* - 恢复上报 localStorage 中残留的旧日志
|
|
30
|
+
* - 接受部分 context(后续可通过 setContext 补充)
|
|
31
|
+
*/
|
|
32
|
+
init(context?: Partial<PayLogContext>): void;
|
|
33
|
+
/**
|
|
34
|
+
* 补充/更新上下文信息
|
|
35
|
+
* 新值覆盖旧值,extra 做浅合并
|
|
36
|
+
*/
|
|
37
|
+
setContext(partial: Partial<PayLogContext>): void;
|
|
38
|
+
/**
|
|
39
|
+
* 记录一条日志
|
|
40
|
+
*/
|
|
41
|
+
log(title: string, data?: any): void;
|
|
42
|
+
/**
|
|
43
|
+
* 上报日志到飞书并清理 localStorage
|
|
44
|
+
*/
|
|
45
|
+
flush(customTitle?: string): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* flush + 重置内部状态
|
|
48
|
+
*/
|
|
49
|
+
destroy(): void;
|
|
50
|
+
/**
|
|
51
|
+
* 构建 sendWarningLog 所需的 content 数组
|
|
52
|
+
*/
|
|
53
|
+
private buildContent;
|
|
54
|
+
/**
|
|
55
|
+
* 持久化当前会话到 localStorage
|
|
56
|
+
*/
|
|
57
|
+
private persistToStorage;
|
|
58
|
+
/**
|
|
59
|
+
* 从 localStorage 移除指定 session
|
|
60
|
+
*/
|
|
61
|
+
private removeFromStorage;
|
|
62
|
+
/**
|
|
63
|
+
* 获取 localStorage 中所有 session
|
|
64
|
+
*/
|
|
65
|
+
private getAllSessions;
|
|
66
|
+
/**
|
|
67
|
+
* 恢复上报 localStorage 中残留的旧日志(崩溃/异常退出场景)
|
|
68
|
+
*/
|
|
69
|
+
private recoverOrphanedLogs;
|
|
70
|
+
}
|
|
71
|
+
declare const payLog: PayLog;
|
|
72
|
+
export default payLog;
|
|
73
|
+
/**
|
|
74
|
+
* 在根组件中使用,管理 PayLog 生命周期
|
|
75
|
+
* - mount 时 init(+ 恢复上报残留日志)
|
|
76
|
+
* - unmount 时 flush
|
|
77
|
+
*/
|
|
78
|
+
export declare function usePayLog(context?: Partial<PayLogContext>): {
|
|
79
|
+
log: (title: string, data?: any) => void;
|
|
80
|
+
setContext: (partial: Partial<PayLogContext>) => void;
|
|
81
|
+
};
|
|
@@ -0,0 +1,321 @@
|
|
|
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/utils/payLog.ts
|
|
30
|
+
var payLog_exports = {};
|
|
31
|
+
__export(payLog_exports, {
|
|
32
|
+
default: () => payLog_default,
|
|
33
|
+
usePayLog: () => usePayLog
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(payLog_exports);
|
|
36
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
37
|
+
var import_react = require("react");
|
|
38
|
+
var import_utils = require("@pisell/utils");
|
|
39
|
+
var STORAGE_KEY = "pisell2_eftpos_paylog";
|
|
40
|
+
var ERROR_KEYWORDS = ["失败", "错误", "异常", "error", "fail", "timeout", "超时"];
|
|
41
|
+
function generateSessionKey() {
|
|
42
|
+
const ts = Date.now();
|
|
43
|
+
const rand = Math.random().toString(36).substring(2, 8);
|
|
44
|
+
return `eft_${ts}_${rand}`;
|
|
45
|
+
}
|
|
46
|
+
function isErrorLog(title) {
|
|
47
|
+
const lower = title.toLowerCase();
|
|
48
|
+
return ERROR_KEYWORDS.some((kw) => lower.includes(kw));
|
|
49
|
+
}
|
|
50
|
+
function shallowEqual(a, b) {
|
|
51
|
+
if (a === b) return true;
|
|
52
|
+
if (a == null && b == null) return true;
|
|
53
|
+
if (a == null || b == null) return false;
|
|
54
|
+
try {
|
|
55
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
56
|
+
} catch {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function compressLogs(logs) {
|
|
61
|
+
if (logs.length === 0) return [];
|
|
62
|
+
const result = [];
|
|
63
|
+
let i = 0;
|
|
64
|
+
while (i < logs.length) {
|
|
65
|
+
const current = logs[i];
|
|
66
|
+
if (isErrorLog(current.t)) {
|
|
67
|
+
result.push({ t: current.t, ts: current.ts, d: current.d });
|
|
68
|
+
i++;
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
let j = i + 1;
|
|
72
|
+
while (j < logs.length && logs[j].t === current.t && !isErrorLog(logs[j].t)) {
|
|
73
|
+
j++;
|
|
74
|
+
}
|
|
75
|
+
const count = j - i;
|
|
76
|
+
if (count === 1) {
|
|
77
|
+
result.push({ t: current.t, ts: current.ts, d: current.d });
|
|
78
|
+
} else {
|
|
79
|
+
const last = logs[j - 1];
|
|
80
|
+
const entry = {
|
|
81
|
+
t: current.t,
|
|
82
|
+
ts: current.ts,
|
|
83
|
+
count,
|
|
84
|
+
lastTs: last.ts
|
|
85
|
+
};
|
|
86
|
+
if (current.d !== void 0) entry.d = current.d;
|
|
87
|
+
if (!shallowEqual(current.d, last.d) && last.d !== void 0) {
|
|
88
|
+
entry.lastD = last.d;
|
|
89
|
+
}
|
|
90
|
+
result.push(entry);
|
|
91
|
+
}
|
|
92
|
+
i = j;
|
|
93
|
+
}
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
var PayLog = class _PayLog {
|
|
97
|
+
static instance;
|
|
98
|
+
sessionKey = null;
|
|
99
|
+
context = {};
|
|
100
|
+
logs = [];
|
|
101
|
+
startTime = 0;
|
|
102
|
+
flushed = false;
|
|
103
|
+
constructor() {
|
|
104
|
+
}
|
|
105
|
+
static getInstance() {
|
|
106
|
+
if (!_PayLog.instance) {
|
|
107
|
+
_PayLog.instance = new _PayLog();
|
|
108
|
+
}
|
|
109
|
+
return _PayLog.instance;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* 初始化一次交易会话
|
|
113
|
+
* - 生成唯一 sessionKey
|
|
114
|
+
* - 恢复上报 localStorage 中残留的旧日志
|
|
115
|
+
* - 接受部分 context(后续可通过 setContext 补充)
|
|
116
|
+
*/
|
|
117
|
+
init(context) {
|
|
118
|
+
try {
|
|
119
|
+
this.recoverOrphanedLogs();
|
|
120
|
+
this.sessionKey = generateSessionKey();
|
|
121
|
+
this.context = context || {};
|
|
122
|
+
this.logs = [];
|
|
123
|
+
this.startTime = Date.now();
|
|
124
|
+
this.flushed = false;
|
|
125
|
+
this.log("PayLog 初始化", context);
|
|
126
|
+
} catch (error) {
|
|
127
|
+
console.error("PayLog init error:", error);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* 补充/更新上下文信息
|
|
132
|
+
* 新值覆盖旧值,extra 做浅合并
|
|
133
|
+
*/
|
|
134
|
+
setContext(partial) {
|
|
135
|
+
var _a;
|
|
136
|
+
if (!this.sessionKey) return;
|
|
137
|
+
const { extra, ...rest } = partial;
|
|
138
|
+
Object.assign(this.context, rest);
|
|
139
|
+
if (extra) {
|
|
140
|
+
this.context.extra = { ...((_a = this.context) == null ? void 0 : _a.extra) || {}, ...extra || {} };
|
|
141
|
+
}
|
|
142
|
+
this.persistToStorage();
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* 记录一条日志
|
|
146
|
+
*/
|
|
147
|
+
log(title, data) {
|
|
148
|
+
if (!this.sessionKey) {
|
|
149
|
+
console.warn("PayLog: 未初始化,日志将被忽略 -", title);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
const entry = {
|
|
153
|
+
t: title,
|
|
154
|
+
ts: (0, import_dayjs.default)().format("HH:mm:ss.SSS")
|
|
155
|
+
};
|
|
156
|
+
if (data !== void 0) {
|
|
157
|
+
entry.d = data;
|
|
158
|
+
}
|
|
159
|
+
this.logs.push(entry);
|
|
160
|
+
this.persistToStorage();
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* 上报日志到飞书并清理 localStorage
|
|
164
|
+
*/
|
|
165
|
+
async flush(customTitle) {
|
|
166
|
+
if (this.flushed || !this.sessionKey) return;
|
|
167
|
+
this.flushed = true;
|
|
168
|
+
const _sessionKey = this.sessionKey;
|
|
169
|
+
try {
|
|
170
|
+
const elapsed = ((Date.now() - this.startTime) / 1e3).toFixed(1);
|
|
171
|
+
const compressed = compressLogs(this.logs);
|
|
172
|
+
const { paymentType, mode, orderId } = this.context;
|
|
173
|
+
const title = customTitle || `[EFTPOS] ${paymentType || "Unknown"}-${mode || "unknown"}-${orderId || "Unknown"}`;
|
|
174
|
+
const content = this.buildContent(compressed, elapsed);
|
|
175
|
+
await (0, import_utils.sendWarningLog)({ title, content });
|
|
176
|
+
this.removeFromStorage(_sessionKey);
|
|
177
|
+
} catch (error) {
|
|
178
|
+
console.error("PayLog flush error:", error);
|
|
179
|
+
} finally {
|
|
180
|
+
this.sessionKey = null;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* flush + 重置内部状态
|
|
185
|
+
*/
|
|
186
|
+
destroy() {
|
|
187
|
+
this.flush();
|
|
188
|
+
this.sessionKey = null;
|
|
189
|
+
this.context = {};
|
|
190
|
+
this.logs = [];
|
|
191
|
+
this.startTime = 0;
|
|
192
|
+
this.flushed = false;
|
|
193
|
+
}
|
|
194
|
+
// ─── 私有方法 ───
|
|
195
|
+
/**
|
|
196
|
+
* 构建 sendWarningLog 所需的 content 数组
|
|
197
|
+
*/
|
|
198
|
+
buildContent(compressed, elapsed) {
|
|
199
|
+
const ctx = this.context;
|
|
200
|
+
return [
|
|
201
|
+
{ key: "sessionKey", value: this.sessionKey || "" },
|
|
202
|
+
{ key: "发起时间", value: (0, import_dayjs.default)(this.startTime).format("YYYY-MM-DD HH:mm:ss") },
|
|
203
|
+
{ key: "交易号", value: String(ctx.transactionNumber || "未知") },
|
|
204
|
+
{ key: "订单ID", value: String(ctx.orderId || "未知") },
|
|
205
|
+
{ key: "设备ID", value: String(ctx.deviceId || "未知") },
|
|
206
|
+
{ key: "支付类型", value: String(ctx.paymentType || "未知") },
|
|
207
|
+
{ key: "模式", value: String(ctx.mode || "未知") },
|
|
208
|
+
{ key: "渠道", value: String(ctx.channel || "未知") },
|
|
209
|
+
{ key: "总耗时", value: `${elapsed}s` },
|
|
210
|
+
// { key: '日志条数(原始/压缩)', value: `${this.logs.length}/${compressed.length}` },
|
|
211
|
+
{ key: "时间线", value: JSON.stringify(compressed) }
|
|
212
|
+
];
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* 持久化当前会话到 localStorage
|
|
216
|
+
*/
|
|
217
|
+
persistToStorage() {
|
|
218
|
+
if (!this.sessionKey) return;
|
|
219
|
+
try {
|
|
220
|
+
const all = this.getAllSessions();
|
|
221
|
+
all[this.sessionKey] = {
|
|
222
|
+
sessionKey: this.sessionKey,
|
|
223
|
+
context: this.context,
|
|
224
|
+
logs: this.logs,
|
|
225
|
+
startTime: this.startTime
|
|
226
|
+
};
|
|
227
|
+
localStorage.setItem(STORAGE_KEY, JSON.stringify(all));
|
|
228
|
+
} catch (error) {
|
|
229
|
+
console.error("PayLog persist error:", error);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* 从 localStorage 移除指定 session
|
|
234
|
+
*/
|
|
235
|
+
removeFromStorage(key) {
|
|
236
|
+
try {
|
|
237
|
+
const all = this.getAllSessions();
|
|
238
|
+
delete all[key];
|
|
239
|
+
if (Object.keys(all).length === 0) {
|
|
240
|
+
localStorage.removeItem(STORAGE_KEY);
|
|
241
|
+
} else {
|
|
242
|
+
localStorage.setItem(STORAGE_KEY, JSON.stringify(all));
|
|
243
|
+
}
|
|
244
|
+
} catch (error) {
|
|
245
|
+
console.error("PayLog removeFromStorage error:", error);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* 获取 localStorage 中所有 session
|
|
250
|
+
*/
|
|
251
|
+
getAllSessions() {
|
|
252
|
+
try {
|
|
253
|
+
const raw = localStorage.getItem(STORAGE_KEY);
|
|
254
|
+
if (!raw) return {};
|
|
255
|
+
return JSON.parse(raw);
|
|
256
|
+
} catch {
|
|
257
|
+
return {};
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* 恢复上报 localStorage 中残留的旧日志(崩溃/异常退出场景)
|
|
262
|
+
*/
|
|
263
|
+
recoverOrphanedLogs() {
|
|
264
|
+
try {
|
|
265
|
+
const all = this.getAllSessions();
|
|
266
|
+
const keys = Object.keys(all);
|
|
267
|
+
if (keys.length === 0) return;
|
|
268
|
+
for (const key of keys) {
|
|
269
|
+
const session = all[key];
|
|
270
|
+
try {
|
|
271
|
+
const elapsed = ((Date.now() - session.startTime) / 1e3).toFixed(1);
|
|
272
|
+
const compressed = compressLogs(session.logs);
|
|
273
|
+
const ctx = session.context;
|
|
274
|
+
const title = `[PRE][EFTPOS] ${ctx.paymentType || "未知支付"}-${ctx.mode || "未知模式"}-${ctx.orderId || "未知订单ID"}`;
|
|
275
|
+
const content = [
|
|
276
|
+
{ key: "sessionKey", value: session.sessionKey },
|
|
277
|
+
{ key: "发起时间", value: (0, import_dayjs.default)(session.startTime).format("YYYY-MM-DD HH:mm:ss") },
|
|
278
|
+
{ key: "交易号", value: String(ctx.transactionNumber || "未知") },
|
|
279
|
+
{ key: "订单ID", value: String(ctx.orderId || "未知") },
|
|
280
|
+
{ key: "设备ID", value: String(ctx.deviceId || "未知") },
|
|
281
|
+
{ key: "支付类型", value: String(ctx.paymentType || "未知") },
|
|
282
|
+
{ key: "模式", value: String(ctx.mode || "未知") },
|
|
283
|
+
{ key: "总耗时", value: `${elapsed}s` },
|
|
284
|
+
{ key: "日志条数(原始/压缩)", value: `${session.logs.length}/${compressed.length}` },
|
|
285
|
+
{ key: "时间线", value: JSON.stringify(compressed) }
|
|
286
|
+
];
|
|
287
|
+
(0, import_utils.sendWarningLog)({ title, content });
|
|
288
|
+
this.removeFromStorage(key);
|
|
289
|
+
} catch (err) {
|
|
290
|
+
console.error(`PayLog: 恢复上报失败 (${key}):`, err);
|
|
291
|
+
this.removeFromStorage(key);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
} catch (error) {
|
|
295
|
+
console.error("PayLog recoverOrphanedLogs error:", error);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
var payLog = PayLog.getInstance();
|
|
300
|
+
var payLog_default = payLog;
|
|
301
|
+
function usePayLog(context) {
|
|
302
|
+
const initialized = (0, import_react.useRef)(false);
|
|
303
|
+
(0, import_react.useEffect)(() => {
|
|
304
|
+
if (!initialized.current) {
|
|
305
|
+
initialized.current = true;
|
|
306
|
+
payLog.init(context);
|
|
307
|
+
}
|
|
308
|
+
return () => {
|
|
309
|
+
payLog.log("流程结束,上报日志");
|
|
310
|
+
payLog.destroy();
|
|
311
|
+
};
|
|
312
|
+
}, []);
|
|
313
|
+
return {
|
|
314
|
+
log: (title, data) => payLog.log(title, data),
|
|
315
|
+
setContext: (partial) => payLog.setContext(partial)
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
319
|
+
0 && (module.exports = {
|
|
320
|
+
usePayLog
|
|
321
|
+
});
|
|
@@ -60,7 +60,7 @@ var const_default = (params) => {
|
|
|
60
60
|
status: import_const.StatusEnum.Loading,
|
|
61
61
|
steps: [],
|
|
62
62
|
render: true,
|
|
63
|
-
client: client !== "undefined" ? client : import_const.ClientEnum.Merchant,
|
|
63
|
+
client: client !== "undefined" && client !== void 0 ? client : import_const.ClientEnum.Merchant,
|
|
64
64
|
custom: other ? { ...other, list: [], step: 1 /* Free */ } : { list: [], step: 1 /* Free */ },
|
|
65
65
|
...typeof net !== "undefined" ? { net } : {},
|
|
66
66
|
...typeof number !== "undefined" ? { number } : {},
|
|
@@ -40,6 +40,7 @@ var import_const = require("../const");
|
|
|
40
40
|
var import_store = require("../store");
|
|
41
41
|
var import_hooks = require("../hooks");
|
|
42
42
|
var import_const2 = require("./const");
|
|
43
|
+
var import_payLog = __toESM(require("../utils/payLog"));
|
|
43
44
|
var ReceiptAction = ({
|
|
44
45
|
api,
|
|
45
46
|
onChange
|
|
@@ -67,6 +68,7 @@ var ReceiptAction = ({
|
|
|
67
68
|
listRef.current = custom == null ? void 0 : custom.list;
|
|
68
69
|
}, [custom == null ? void 0 : custom.list]);
|
|
69
70
|
const onAccept = () => {
|
|
71
|
+
import_payLog.default.log("Windcave:签名-点击确认");
|
|
70
72
|
dispatch((0, import_store.updateStatus)(import_const.StatusEnum.Loading));
|
|
71
73
|
dispatch(
|
|
72
74
|
(0, import_store.updateCustom)({
|
|
@@ -144,6 +146,7 @@ var ReceiptAction = ({
|
|
|
144
146
|
});
|
|
145
147
|
};
|
|
146
148
|
const onBack = () => {
|
|
149
|
+
import_payLog.default.log("Windcave:签名-点击后退");
|
|
147
150
|
dispatch(
|
|
148
151
|
(0, import_store.updateState)({
|
|
149
152
|
title: import_utils.locales.getText("page.eftpos-pay.text.waiting.signature"),
|
|
@@ -154,6 +157,7 @@ var ReceiptAction = ({
|
|
|
154
157
|
dispatch((0, import_store.updateCustom)({ receiptPage: "receipt" }));
|
|
155
158
|
};
|
|
156
159
|
const onConfirm = () => {
|
|
160
|
+
import_payLog.default.log("Windcave:签名-点击取消");
|
|
157
161
|
dispatch(
|
|
158
162
|
(0, import_store.updateState)({
|
|
159
163
|
title: import_utils.locales.getText("page.eftpos-pay.text.processing"),
|
|
@@ -243,6 +247,7 @@ var ReceiptAction = ({
|
|
|
243
247
|
});
|
|
244
248
|
};
|
|
245
249
|
const onDecline = () => {
|
|
250
|
+
import_payLog.default.log("Windcave:签名-点击取消");
|
|
246
251
|
dispatch(
|
|
247
252
|
(0, import_store.updateState)({
|
|
248
253
|
title: import_utils.locales.getText("page.eftpos-pay.text.signature.title"),
|