@pisell/private-materials 6.4.29 → 6.4.30
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 +5 -5
- package/build/lowcode/render/default/view.js +6 -6
- package/build/lowcode/view.js +6 -6
- package/es/components/booking/info/index.d.ts +1 -0
- package/es/components/checkout/PaymentModal.js +14 -7
- package/es/components/checkout/components/ScrollableList/index.js +1 -0
- package/es/components/pay/toB/components/MX51/index.js +44 -14
- package/es/components/pay/toB/types/index.d.ts +12 -0
- package/es/components/pay/toB/types/index.js +4 -0
- package/es/components/ticketBooking/components/ticketBooking/index.d.ts +1 -0
- package/es/hooks/printer.d.ts +4 -0
- package/es/hooks/printer.js +35 -0
- package/lib/components/booking/info/index.d.ts +1 -0
- package/lib/components/checkout/PaymentModal.js +15 -7
- package/lib/components/checkout/components/ScrollableList/index.js +1 -0
- package/lib/components/pay/toB/components/MX51/index.js +37 -12
- package/lib/components/pay/toB/types/index.d.ts +12 -0
- package/lib/components/ticketBooking/components/ticketBooking/index.d.ts +1 -0
- package/lib/hooks/printer.d.ts +4 -0
- package/lib/hooks/printer.js +60 -0
- package/package.json +1 -1
@@ -16,7 +16,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
16
16
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
17
17
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
18
18
|
import React, { useRef, useState, useEffect, useCallback, useMemo, useImperativeHandle, forwardRef } from 'react';
|
19
|
-
import { locales
|
19
|
+
import { locales } from '@pisell/utils';
|
20
20
|
import { getLocale } from "../../utils/locales";
|
21
21
|
import { useMemoizedFn } from 'ahooks';
|
22
22
|
import { createPortal } from 'react-dom';
|
@@ -47,6 +47,7 @@ import { cloneDeep } from 'lodash';
|
|
47
47
|
import { getShopWalletPassId, reorderPaymentMethodList } from "./utils";
|
48
48
|
import usePaymentLogger from "./hooks/usePaymentLogger";
|
49
49
|
import { Button } from 'antd';
|
50
|
+
import usePrinter from "../../hooks/printer";
|
50
51
|
|
51
52
|
// Checkout 模块的事件常量
|
52
53
|
var CheckoutHooks = {
|
@@ -139,6 +140,8 @@ var PaymentContent = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
139
140
|
_useState16 = _slicedToArray(_useState15, 2),
|
140
141
|
walletPassData = _useState16[0],
|
141
142
|
setWalletPassData = _useState16[1];
|
143
|
+
var _usePrinter = usePrinter(),
|
144
|
+
nativePrint = _usePrinter.nativePrint;
|
142
145
|
var isOrderFree = useMemo(function () {
|
143
146
|
if (!customAmount) return false;
|
144
147
|
var amount = parseFloat(customAmount);
|
@@ -675,11 +678,12 @@ var PaymentContent = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
675
678
|
data: {
|
676
679
|
order_id: responseData.order_id,
|
677
680
|
machine_code_print_info: responseData === null || responseData === void 0 ? void 0 : responseData.machine_code_print_info,
|
678
|
-
small_ticket_data: responseData === null || responseData === void 0 || (_responseData$payment = responseData.payment_info) === null || _responseData$payment === void 0 ? void 0 : _responseData$payment.small_ticket_data
|
681
|
+
small_ticket_data: responseData === null || responseData === void 0 || (_responseData$payment = responseData.payment_info) === null || _responseData$payment === void 0 ? void 0 : _responseData$payment.small_ticket_data,
|
682
|
+
machine_code_print_info_v2: responseData === null || responseData === void 0 ? void 0 : responseData.machine_code_print_info_v2
|
679
683
|
}
|
680
684
|
};
|
681
685
|
console.log('print_order_onOrderSynced_params>>>>', params);
|
682
|
-
|
686
|
+
nativePrint(params, function (res) {
|
683
687
|
console.log('print_order_onOrderSynced_res>>>>', res);
|
684
688
|
});
|
685
689
|
} catch (error) {
|
@@ -969,7 +973,7 @@ var PaymentContent = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
969
973
|
}
|
970
974
|
};
|
971
975
|
try {
|
972
|
-
|
976
|
+
nativePrint(params, function (res) {
|
973
977
|
console.log('handleButtonClick_print-receipt_res>>>>', res);
|
974
978
|
if (!(res !== null && res !== void 0 && res.result)) {
|
975
979
|
Toast === null || Toast === void 0 || Toast.error((res === null || res === void 0 ? void 0 : res.msg) || '');
|
@@ -1284,6 +1288,8 @@ var PaymentModal = function PaymentModal(_ref17) {
|
|
1284
1288
|
showRetryModal = _useState30[0],
|
1285
1289
|
setShowRetryModal = _useState30[1];
|
1286
1290
|
var Toast = useToast();
|
1291
|
+
var _usePrinter2 = usePrinter(),
|
1292
|
+
nativePrint = _usePrinter2.nativePrint;
|
1287
1293
|
|
1288
1294
|
// 重试处理函数(逻辑由用户自己实现)
|
1289
1295
|
var handleRetry = /*#__PURE__*/function () {
|
@@ -1702,7 +1708,8 @@ var PaymentModal = function PaymentModal(_ref17) {
|
|
1702
1708
|
data: {
|
1703
1709
|
order_id: responseData.order_id,
|
1704
1710
|
machine_code_print_info: responseData === null || responseData === void 0 ? void 0 : responseData.machine_code_print_info,
|
1705
|
-
small_ticket_data: responseData === null || responseData === void 0 || (_responseData$payment3 = responseData.payment_info) === null || _responseData$payment3 === void 0 ? void 0 : _responseData$payment3.small_ticket_data
|
1711
|
+
small_ticket_data: responseData === null || responseData === void 0 || (_responseData$payment3 = responseData.payment_info) === null || _responseData$payment3 === void 0 ? void 0 : _responseData$payment3.small_ticket_data,
|
1712
|
+
machine_code_print_info_v2: responseData === null || responseData === void 0 ? void 0 : responseData.machine_code_print_info_v2
|
1706
1713
|
}
|
1707
1714
|
};
|
1708
1715
|
console.log('print_order_onOrderSynced_params>>>>', params);
|
@@ -1713,7 +1720,7 @@ var PaymentModal = function PaymentModal(_ref17) {
|
|
1713
1720
|
params: params
|
1714
1721
|
}
|
1715
1722
|
});
|
1716
|
-
|
1723
|
+
nativePrint(params, function (res) {
|
1717
1724
|
console.log('print_order_onOrderSynced_res>>>>', res);
|
1718
1725
|
logger === null || logger === void 0 || logger.addLog({
|
1719
1726
|
type: 'info',
|
@@ -1934,7 +1941,7 @@ var PaymentModal = function PaymentModal(_ref17) {
|
|
1934
1941
|
}
|
1935
1942
|
};
|
1936
1943
|
try {
|
1937
|
-
|
1944
|
+
nativePrint(params, function (res) {
|
1938
1945
|
console.log('handleButtonClick_print-receipt_res>>>>', res);
|
1939
1946
|
if (!(res !== null && res !== void 0 && res.result)) {
|
1940
1947
|
Toast === null || Toast === void 0 || Toast.error((res === null || res === void 0 ? void 0 : res.msg) || '');
|
@@ -241,6 +241,7 @@ var ScrollableList = function ScrollableList(_ref) {
|
|
241
241
|
style: getGridStyle()
|
242
242
|
}, children)), isScrollable && /*#__PURE__*/React.createElement("button", {
|
243
243
|
style: _objectSpread(_objectSpread({}, bottomGradientStyle), {}, {
|
244
|
+
width: '100%',
|
244
245
|
border: 'none',
|
245
246
|
background: 'linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, #A78BE1 100%)'
|
246
247
|
}, gradientStyle),
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { forwardRef, useImperativeHandle } from 'react';
|
2
|
-
import { webPayment } from '@pisell/utils';
|
3
2
|
import useLogger from "../../../../../hooks/useLogger";
|
3
|
+
import useEngineContext from "../../../../../hooks/useEngineContext";
|
4
4
|
var getUuid = function getUuid() {
|
5
5
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxx'.replace(/[xy]/g, function (c) {
|
6
6
|
var r = Math.random() * 16 | 0;
|
@@ -9,7 +9,10 @@ var getUuid = function getUuid() {
|
|
9
9
|
});
|
10
10
|
};
|
11
11
|
var MX51 = function MX51(props, ref) {
|
12
|
+
var _context$appHelper;
|
12
13
|
var logger = useLogger();
|
14
|
+
var context = useEngineContext();
|
15
|
+
var action = context === null || context === void 0 || (_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 || (_context$appHelper = _context$appHelper.utils) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.action;
|
13
16
|
var onOpen = function onOpen(_ref) {
|
14
17
|
var data = _ref.data,
|
15
18
|
payCallback = _ref.payCallback;
|
@@ -33,20 +36,47 @@ var MX51 = function MX51(props, ref) {
|
|
33
36
|
params: newData
|
34
37
|
}
|
35
38
|
});
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
39
|
+
|
40
|
+
// 通过action调用mx51支付
|
41
|
+
action({
|
42
|
+
type: 'webpos.handleMX51Pay',
|
43
|
+
data: newData,
|
44
|
+
callback: function callback(res) {
|
45
|
+
var isSame = false;
|
46
|
+
if (res !== null && res !== void 0 && res.uniquePaymentNumber) {
|
47
|
+
// jsbridge调用场景结果
|
48
|
+
var _res = res;
|
49
|
+
// 判断是否是同一个支付
|
50
|
+
isSame = (_res === null || _res === void 0 ? void 0 : _res.uniquePaymentNumber) === uniquePaymentNumber;
|
51
|
+
if (isSame) {
|
52
|
+
payCallback === null || payCallback === void 0 || payCallback(_res);
|
53
|
+
}
|
54
|
+
} else {
|
55
|
+
var _res2$data, _res2$data2;
|
56
|
+
// 原生调用场景结果
|
57
|
+
var _res2 = res;
|
58
|
+
// 转换为MX51PayResult类型,上层调用需要
|
59
|
+
var newRes = {
|
60
|
+
result: (_res2 === null || _res2 === void 0 ? void 0 : _res2.code) == '200' ? true : false,
|
61
|
+
msg: _res2 === null || _res2 === void 0 ? void 0 : _res2.msg,
|
62
|
+
amount: _res2 === null || _res2 === void 0 || (_res2$data = _res2.data) === null || _res2$data === void 0 ? void 0 : _res2$data.amount,
|
63
|
+
surcharge: _res2 === null || _res2 === void 0 || (_res2$data2 = _res2.data) === null || _res2$data2 === void 0 ? void 0 : _res2$data2.surcharge,
|
64
|
+
uniquePaymentNumber: _res2 === null || _res2 === void 0 ? void 0 : _res2.uuid
|
65
|
+
};
|
66
|
+
// 判断是否是同一个支付
|
67
|
+
isSame = (_res2 === null || _res2 === void 0 ? void 0 : _res2.uuid) === uniquePaymentNumber;
|
68
|
+
if (isSame) {
|
69
|
+
payCallback === null || payCallback === void 0 || payCallback(newRes);
|
70
|
+
}
|
46
71
|
}
|
47
|
-
|
48
|
-
|
49
|
-
|
72
|
+
logger === null || logger === void 0 || logger.addLog({
|
73
|
+
type: 'info',
|
74
|
+
title: 'ToB_MX51_onOpen_callback',
|
75
|
+
metadata: {
|
76
|
+
msg: isSame ? '交易流水号一致' : '交易流水号不一致',
|
77
|
+
res: res
|
78
|
+
}
|
79
|
+
});
|
50
80
|
}
|
51
81
|
});
|
52
82
|
};
|
@@ -58,3 +58,15 @@ export interface MX51PayResult {
|
|
58
58
|
surcharge: number;
|
59
59
|
uniquePaymentNumber: string;
|
60
60
|
}
|
61
|
+
/**
|
62
|
+
* @title 原生MX51支付结果
|
63
|
+
*/
|
64
|
+
export interface NativeMX51PayResult {
|
65
|
+
code: string;
|
66
|
+
msg?: string;
|
67
|
+
data: {
|
68
|
+
amount: number;
|
69
|
+
surcharge: number;
|
70
|
+
};
|
71
|
+
uuid: string;
|
72
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
7
|
+
import useEngineContext from "./useEngineContext";
|
8
|
+
var usePrinter = function usePrinter() {
|
9
|
+
var _context$appHelper;
|
10
|
+
var context = useEngineContext();
|
11
|
+
var _ref = (context === null || context === void 0 || (_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.utils) || {},
|
12
|
+
action = _ref.action;
|
13
|
+
var nativePrint = function nativePrint(data, _callback) {
|
14
|
+
// 转换注意事项:
|
15
|
+
// data.type: 0 是JSBridge调用小票打印,nativePlugin中调用时需要转为 'INVOICE'
|
16
|
+
// data.type: 99 是JSBridge调用全部打印,nativePlugin中调用时需要转为 'ALL'
|
17
|
+
action({
|
18
|
+
type: 'webpos.handlePrint',
|
19
|
+
data: data,
|
20
|
+
callback: function callback(res) {
|
21
|
+
if (typeof (res === null || res === void 0 ? void 0 : res.status) === 'string') {
|
22
|
+
_callback === null || _callback === void 0 || _callback(_objectSpread(_objectSpread({}, res || {}), {}, {
|
23
|
+
result: (res === null || res === void 0 ? void 0 : res.status) == 'success' ? true : false
|
24
|
+
}));
|
25
|
+
} else {
|
26
|
+
_callback === null || _callback === void 0 || _callback(res);
|
27
|
+
}
|
28
|
+
}
|
29
|
+
});
|
30
|
+
};
|
31
|
+
return {
|
32
|
+
nativePrint: nativePrint
|
33
|
+
};
|
34
|
+
};
|
35
|
+
export default usePrinter;
|
@@ -64,6 +64,7 @@ var import_lodash = require("lodash");
|
|
64
64
|
var import_utils2 = require("./utils");
|
65
65
|
var import_usePaymentLogger = __toESM(require("./hooks/usePaymentLogger"));
|
66
66
|
var import_antd = require("antd");
|
67
|
+
var import_printer = __toESM(require("../../hooks/printer"));
|
67
68
|
var CheckoutHooks = {
|
68
69
|
OnStateAmountChanged: "checkout:onStateAmountChanged",
|
69
70
|
OnBalanceDueAmountChanged: "checkout:onBalanceDueAmountChanged",
|
@@ -117,6 +118,7 @@ var PaymentContent = (0, import_react.forwardRef)(
|
|
117
118
|
const walletPassRef = (0, import_react.useRef)(null);
|
118
119
|
const [paymentItems, setPaymentItems] = (0, import_react.useState)([]);
|
119
120
|
const [walletPassData, setWalletPassData] = (0, import_react.useState)({});
|
121
|
+
const { nativePrint } = (0, import_printer.default)();
|
120
122
|
const isOrderFree = (0, import_react.useMemo)(() => {
|
121
123
|
if (!customAmount) return false;
|
122
124
|
const amount = parseFloat(customAmount);
|
@@ -299,7 +301,10 @@ var PaymentContent = (0, import_react.forwardRef)(
|
|
299
301
|
}
|
300
302
|
if (checkoutModule && isModalOpen) {
|
301
303
|
checkoutModule.getPaymentMethodsAsync().then(async (paymentMethods2) => {
|
302
|
-
const reorderedPaymentMethods = await (0, import_utils2.reorderPaymentMethodList)(
|
304
|
+
const reorderedPaymentMethods = await (0, import_utils2.reorderPaymentMethodList)(
|
305
|
+
paymentMethods2,
|
306
|
+
interaction
|
307
|
+
);
|
303
308
|
setPaymentMethods(reorderedPaymentMethods);
|
304
309
|
const isShowCashPayment = paymentMethods2.some(
|
305
310
|
(item) => item.code === "CASHMANUAL"
|
@@ -512,11 +517,12 @@ var PaymentContent = (0, import_react.forwardRef)(
|
|
512
517
|
data: {
|
513
518
|
order_id: responseData.order_id,
|
514
519
|
machine_code_print_info: responseData == null ? void 0 : responseData.machine_code_print_info,
|
515
|
-
small_ticket_data: (_b2 = responseData == null ? void 0 : responseData.payment_info) == null ? void 0 : _b2.small_ticket_data
|
520
|
+
small_ticket_data: (_b2 = responseData == null ? void 0 : responseData.payment_info) == null ? void 0 : _b2.small_ticket_data,
|
521
|
+
machine_code_print_info_v2: responseData == null ? void 0 : responseData.machine_code_print_info_v2
|
516
522
|
}
|
517
523
|
};
|
518
524
|
console.log("print_order_onOrderSynced_params>>>>", params);
|
519
|
-
(
|
525
|
+
nativePrint(params, (res) => {
|
520
526
|
console.log("print_order_onOrderSynced_res>>>>", res);
|
521
527
|
});
|
522
528
|
} catch (error) {
|
@@ -685,7 +691,7 @@ var PaymentContent = (0, import_react.forwardRef)(
|
|
685
691
|
data: { order_id: data.orderId }
|
686
692
|
};
|
687
693
|
try {
|
688
|
-
(
|
694
|
+
nativePrint(params, (res) => {
|
689
695
|
console.log("handleButtonClick_print-receipt_res>>>>", res);
|
690
696
|
if (!(res == null ? void 0 : res.result)) {
|
691
697
|
Toast == null ? void 0 : Toast.error((res == null ? void 0 : res.msg) || "");
|
@@ -988,6 +994,7 @@ var PaymentModal = ({
|
|
988
994
|
const [windowHeight, setWindowHeight] = (0, import_react.useState)(0);
|
989
995
|
const [showRetryModal, setShowRetryModal] = (0, import_react.useState)(false);
|
990
996
|
const Toast = (0, import_useToast.default)();
|
997
|
+
const { nativePrint } = (0, import_printer.default)();
|
991
998
|
const handleRetry = async () => {
|
992
999
|
const checkoutModule = pisellos == null ? void 0 : pisellos.getModule("checkout");
|
993
1000
|
const res = await (checkoutModule == null ? void 0 : checkoutModule.manualSyncOrderAsync());
|
@@ -1272,7 +1279,8 @@ var PaymentModal = ({
|
|
1272
1279
|
data: {
|
1273
1280
|
order_id: responseData.order_id,
|
1274
1281
|
machine_code_print_info: responseData == null ? void 0 : responseData.machine_code_print_info,
|
1275
|
-
small_ticket_data: (_c2 = responseData == null ? void 0 : responseData.payment_info) == null ? void 0 : _c2.small_ticket_data
|
1282
|
+
small_ticket_data: (_c2 = responseData == null ? void 0 : responseData.payment_info) == null ? void 0 : _c2.small_ticket_data,
|
1283
|
+
machine_code_print_info_v2: responseData == null ? void 0 : responseData.machine_code_print_info_v2
|
1276
1284
|
}
|
1277
1285
|
};
|
1278
1286
|
console.log("print_order_onOrderSynced_params>>>>", params);
|
@@ -1283,7 +1291,7 @@ var PaymentModal = ({
|
|
1283
1291
|
params
|
1284
1292
|
}
|
1285
1293
|
});
|
1286
|
-
(
|
1294
|
+
nativePrint(params, (res) => {
|
1287
1295
|
console.log("print_order_onOrderSynced_res>>>>", res);
|
1288
1296
|
logger == null ? void 0 : logger.addLog({
|
1289
1297
|
type: "info",
|
@@ -1427,7 +1435,7 @@ var PaymentModal = ({
|
|
1427
1435
|
data: { order_id: data2.orderId }
|
1428
1436
|
};
|
1429
1437
|
try {
|
1430
|
-
(
|
1438
|
+
nativePrint(params, (res) => {
|
1431
1439
|
console.log("handleButtonClick_print-receipt_res>>>>", res);
|
1432
1440
|
if (!(res == null ? void 0 : res.result)) {
|
1433
1441
|
Toast == null ? void 0 : Toast.error((res == null ? void 0 : res.msg) || "");
|
@@ -33,8 +33,8 @@ __export(MX51_exports, {
|
|
33
33
|
});
|
34
34
|
module.exports = __toCommonJS(MX51_exports);
|
35
35
|
var import_react = require("react");
|
36
|
-
var import_utils = require("@pisell/utils");
|
37
36
|
var import_useLogger = __toESM(require("../../../../../hooks/useLogger"));
|
37
|
+
var import_useEngineContext = __toESM(require("../../../../../hooks/useEngineContext"));
|
38
38
|
var getUuid = () => {
|
39
39
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxx".replace(/[xy]/g, (c) => {
|
40
40
|
const r = Math.random() * 16 | 0;
|
@@ -43,7 +43,10 @@ var getUuid = () => {
|
|
43
43
|
});
|
44
44
|
};
|
45
45
|
var MX51 = (props, ref) => {
|
46
|
+
var _a, _b;
|
46
47
|
const logger = (0, import_useLogger.default)();
|
48
|
+
const context = (0, import_useEngineContext.default)();
|
49
|
+
const action = (_b = (_a = context == null ? void 0 : context.appHelper) == null ? void 0 : _a.utils) == null ? void 0 : _b.action;
|
47
50
|
const onOpen = ({ data, payCallback }) => {
|
48
51
|
const { params, mode } = data;
|
49
52
|
const uniquePaymentNumber = getUuid();
|
@@ -62,18 +65,40 @@ var MX51 = (props, ref) => {
|
|
62
65
|
title: "ToB_MX51_onOpen 开始调用",
|
63
66
|
metadata: { params: newData }
|
64
67
|
});
|
65
|
-
(
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
res
|
68
|
+
action({
|
69
|
+
type: "webpos.handleMX51Pay",
|
70
|
+
data: newData,
|
71
|
+
callback: (res) => {
|
72
|
+
var _a2, _b2;
|
73
|
+
let isSame = false;
|
74
|
+
if (res == null ? void 0 : res.uniquePaymentNumber) {
|
75
|
+
const _res = res;
|
76
|
+
isSame = (_res == null ? void 0 : _res.uniquePaymentNumber) === uniquePaymentNumber;
|
77
|
+
if (isSame) {
|
78
|
+
payCallback == null ? void 0 : payCallback(_res);
|
79
|
+
}
|
80
|
+
} else {
|
81
|
+
const _res = res;
|
82
|
+
const newRes = {
|
83
|
+
result: (_res == null ? void 0 : _res.code) == "200" ? true : false,
|
84
|
+
msg: _res == null ? void 0 : _res.msg,
|
85
|
+
amount: (_a2 = _res == null ? void 0 : _res.data) == null ? void 0 : _a2.amount,
|
86
|
+
surcharge: (_b2 = _res == null ? void 0 : _res.data) == null ? void 0 : _b2.surcharge,
|
87
|
+
uniquePaymentNumber: _res == null ? void 0 : _res.uuid
|
88
|
+
};
|
89
|
+
isSame = (_res == null ? void 0 : _res.uuid) === uniquePaymentNumber;
|
90
|
+
if (isSame) {
|
91
|
+
payCallback == null ? void 0 : payCallback(newRes);
|
92
|
+
}
|
73
93
|
}
|
74
|
-
|
75
|
-
|
76
|
-
|
94
|
+
logger == null ? void 0 : logger.addLog({
|
95
|
+
type: "info",
|
96
|
+
title: "ToB_MX51_onOpen_callback",
|
97
|
+
metadata: {
|
98
|
+
msg: isSame ? "交易流水号一致" : "交易流水号不一致",
|
99
|
+
res
|
100
|
+
}
|
101
|
+
});
|
77
102
|
}
|
78
103
|
});
|
79
104
|
};
|
@@ -58,3 +58,15 @@ export interface MX51PayResult {
|
|
58
58
|
surcharge: number;
|
59
59
|
uniquePaymentNumber: string;
|
60
60
|
}
|
61
|
+
/**
|
62
|
+
* @title 原生MX51支付结果
|
63
|
+
*/
|
64
|
+
export interface NativeMX51PayResult {
|
65
|
+
code: string;
|
66
|
+
msg?: string;
|
67
|
+
data: {
|
68
|
+
amount: number;
|
69
|
+
surcharge: number;
|
70
|
+
};
|
71
|
+
uuid: string;
|
72
|
+
}
|
@@ -0,0 +1,60 @@
|
|
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/hooks/printer.ts
|
30
|
+
var printer_exports = {};
|
31
|
+
__export(printer_exports, {
|
32
|
+
default: () => printer_default
|
33
|
+
});
|
34
|
+
module.exports = __toCommonJS(printer_exports);
|
35
|
+
var import_useEngineContext = __toESM(require("./useEngineContext"));
|
36
|
+
var usePrinter = () => {
|
37
|
+
var _a;
|
38
|
+
const context = (0, import_useEngineContext.default)();
|
39
|
+
const { action } = ((_a = context == null ? void 0 : context.appHelper) == null ? void 0 : _a.utils) || {};
|
40
|
+
const nativePrint = (data, callback) => {
|
41
|
+
action({
|
42
|
+
type: "webpos.handlePrint",
|
43
|
+
data,
|
44
|
+
callback: (res) => {
|
45
|
+
if (typeof (res == null ? void 0 : res.status) === "string") {
|
46
|
+
callback == null ? void 0 : callback({
|
47
|
+
...res || {},
|
48
|
+
result: (res == null ? void 0 : res.status) == "success" ? true : false
|
49
|
+
});
|
50
|
+
} else {
|
51
|
+
callback == null ? void 0 : callback(res);
|
52
|
+
}
|
53
|
+
}
|
54
|
+
});
|
55
|
+
};
|
56
|
+
return {
|
57
|
+
nativePrint
|
58
|
+
};
|
59
|
+
};
|
60
|
+
var printer_default = usePrinter;
|