@pisell/private-materials 6.3.79 → 6.3.80

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 (151) 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/meta.js +1 -1
  5. package/build/lowcode/render/default/view.css +1 -1
  6. package/build/lowcode/render/default/view.js +9 -9
  7. package/build/lowcode/view.css +1 -1
  8. package/build/lowcode/view.js +9 -9
  9. package/es/components/appointmentBooking/components/Cart/Item/Total.d.ts +0 -1
  10. package/es/components/appointmentBooking/components/Cart/index.d.ts +0 -1
  11. package/es/components/appointmentBooking/components/Footer/index.d.ts +0 -1
  12. package/es/components/appointmentBooking/deposit/components/PolicyModal/index.d.ts +0 -1
  13. package/es/components/booking/forms/footer.d.ts +0 -1
  14. package/es/components/booking/forms/sendModal/useSendModal.d.ts +0 -1
  15. package/es/components/booking/hooks/useClearCart.d.ts +0 -1
  16. package/es/components/booking/info/date/index.d.ts +1 -0
  17. package/es/components/booking/info/dateRange/index.d.ts +0 -1
  18. package/es/components/eftpos/const.d.ts +3 -1
  19. package/es/components/eftpos/const.js +2 -0
  20. package/es/components/eftpos/device.d.ts +3 -1
  21. package/es/components/eftpos/device.js +5 -3
  22. package/es/components/eftpos/index.d.ts +0 -1
  23. package/es/components/eftpos/index.js +34 -11
  24. package/es/components/eftpos/index.less +26 -1
  25. package/es/components/eftpos/locales.d.ts +3 -0
  26. package/es/components/eftpos/locales.js +3 -0
  27. package/es/components/eftposPay/aggregatePayment/hooks/usePayment.d.ts +6 -0
  28. package/es/components/eftposPay/aggregatePayment/hooks/usePayment.js +125 -0
  29. package/es/components/eftposPay/aggregatePayment/index.d.ts +3 -0
  30. package/es/components/eftposPay/aggregatePayment/index.js +3 -0
  31. package/es/components/eftposPay/aggregatePayment/mock.d.ts +495 -0
  32. package/es/components/eftposPay/aggregatePayment/mock.js +567 -0
  33. package/es/components/eftposPay/aggregatePayment/service.d.ts +24 -0
  34. package/es/components/eftposPay/aggregatePayment/service.js +70 -0
  35. package/es/components/eftposPay/aggregatePayment/types.d.ts +96 -0
  36. package/es/components/eftposPay/aggregatePayment/types.js +61 -0
  37. package/es/components/eftposPay/aggregatePayment/utils/logs.d.ts +110 -0
  38. package/es/components/eftposPay/aggregatePayment/utils/logs.js +385 -0
  39. package/es/components/eftposPay/aggregatePayment/utils/payment.d.ts +132 -0
  40. package/es/components/eftposPay/aggregatePayment/utils/payment.js +1127 -0
  41. package/es/components/eftposPay/amount.d.ts +0 -1
  42. package/es/components/eftposPay/const.d.ts +6 -1
  43. package/es/components/eftposPay/const.js +2 -0
  44. package/es/components/eftposPay/hooks.d.ts +2 -1
  45. package/es/components/eftposPay/hooks.js +12 -0
  46. package/es/components/eftposPay/linkly/index.js +1 -0
  47. package/es/components/eftposPay/manufacturer.d.ts +1 -0
  48. package/es/components/eftposPay/manufacturer.js +4 -0
  49. package/es/components/eftposPay/mx51/Action.d.ts +6 -0
  50. package/es/components/eftposPay/mx51/Action.js +91 -0
  51. package/es/components/eftposPay/mx51/const.d.ts +5 -0
  52. package/es/components/eftposPay/mx51/const.js +69 -0
  53. package/es/components/eftposPay/mx51/index.d.ts +6 -0
  54. package/es/components/eftposPay/mx51/index.js +362 -0
  55. package/es/components/eftposPay/mx51/types.d.ts +136 -0
  56. package/es/components/eftposPay/mx51/types.js +29 -0
  57. package/es/components/eftposPay/mx51/utils.d.ts +10 -0
  58. package/es/components/eftposPay/mx51/utils.js +120 -0
  59. package/es/components/eftposPay/pay.js +7 -2
  60. package/es/components/eftposPay/store/index.d.ts +1 -1
  61. package/es/components/eventBooking/components/Provider/Content/index.d.ts +1 -0
  62. package/es/components/eventBooking/components/Provider/EmptyHolderModal/index.d.ts +0 -1
  63. package/es/components/eventBooking/components/Provider/Header/index.d.ts +1 -0
  64. package/es/components/eventBooking/components/Provider/OrderProductModal/index.d.ts +0 -1
  65. package/es/components/eventBooking/components/Provider/RemoveOptionConfirmModal.d.ts +0 -1
  66. package/es/components/eventBooking/components/Provider/SelectHolderModal.d.ts +1 -0
  67. package/es/components/eventBooking/components/bookingDetailModal/components/Resource.d.ts +1 -0
  68. package/es/components/eventBooking/components/bookingDetailModal/components/Schedule.d.ts +1 -0
  69. package/es/components/eventBooking/components/scheduleCalendar/components/ScheduleTimeItem/index.d.ts +0 -1
  70. package/es/components/pay/toC/WalletPassBlock/components/WalletUseList/index.d.ts +0 -1
  71. package/es/components/pisellSelectCustomerModal/RightPanel/List/index.d.ts +0 -1
  72. package/es/components/shoppingCart/hooks/useAddService.d.ts +0 -1
  73. package/es/components/shoppingCart/hooks/useClearCart.d.ts +0 -1
  74. package/es/plus/saasRegister/components/VertifyEmail.d.ts +0 -1
  75. package/es/plus/skuOptionsSelection/components/OptionsCard/index.d.ts +0 -1
  76. package/es/plus/skuOptionsSelection/components/TitleExtra/index.d.ts +0 -1
  77. package/es/plus/skuOptionsSelection/components/VariantCard/index.d.ts +0 -1
  78. package/es/plus/walletPassGallery/components/passList/index.d.ts +0 -1
  79. package/lib/components/appointmentBooking/components/Cart/Item/Total.d.ts +0 -1
  80. package/lib/components/appointmentBooking/components/Cart/index.d.ts +0 -1
  81. package/lib/components/appointmentBooking/components/Footer/index.d.ts +0 -1
  82. package/lib/components/appointmentBooking/deposit/components/PolicyModal/index.d.ts +0 -1
  83. package/lib/components/booking/forms/footer.d.ts +0 -1
  84. package/lib/components/booking/forms/sendModal/useSendModal.d.ts +0 -1
  85. package/lib/components/booking/hooks/useClearCart.d.ts +0 -1
  86. package/lib/components/booking/info/date/index.d.ts +1 -0
  87. package/lib/components/booking/info/dateRange/index.d.ts +0 -1
  88. package/lib/components/eftpos/const.d.ts +3 -1
  89. package/lib/components/eftpos/const.js +2 -0
  90. package/lib/components/eftpos/device.d.ts +3 -1
  91. package/lib/components/eftpos/device.js +3 -3
  92. package/lib/components/eftpos/index.d.ts +0 -1
  93. package/lib/components/eftpos/index.js +20 -5
  94. package/lib/components/eftpos/index.less +26 -1
  95. package/lib/components/eftpos/locales.d.ts +3 -0
  96. package/lib/components/eftpos/locales.js +3 -0
  97. package/lib/components/eftposPay/aggregatePayment/hooks/usePayment.d.ts +6 -0
  98. package/lib/components/eftposPay/aggregatePayment/hooks/usePayment.js +152 -0
  99. package/lib/components/eftposPay/aggregatePayment/index.d.ts +3 -0
  100. package/lib/components/eftposPay/aggregatePayment/index.js +32 -0
  101. package/lib/components/eftposPay/aggregatePayment/mock.d.ts +495 -0
  102. package/lib/components/eftposPay/aggregatePayment/mock.js +679 -0
  103. package/lib/components/eftposPay/aggregatePayment/service.d.ts +24 -0
  104. package/lib/components/eftposPay/aggregatePayment/service.js +81 -0
  105. package/lib/components/eftposPay/aggregatePayment/types.d.ts +96 -0
  106. package/lib/components/eftposPay/aggregatePayment/types.js +74 -0
  107. package/lib/components/eftposPay/aggregatePayment/utils/logs.d.ts +110 -0
  108. package/lib/components/eftposPay/aggregatePayment/utils/logs.js +302 -0
  109. package/lib/components/eftposPay/aggregatePayment/utils/payment.d.ts +132 -0
  110. package/lib/components/eftposPay/aggregatePayment/utils/payment.js +746 -0
  111. package/lib/components/eftposPay/amount.d.ts +0 -1
  112. package/lib/components/eftposPay/const.d.ts +6 -1
  113. package/lib/components/eftposPay/const.js +2 -0
  114. package/lib/components/eftposPay/hooks.d.ts +2 -1
  115. package/lib/components/eftposPay/hooks.js +16 -0
  116. package/lib/components/eftposPay/linkly/index.js +1 -0
  117. package/lib/components/eftposPay/manufacturer.d.ts +1 -0
  118. package/lib/components/eftposPay/manufacturer.js +6 -0
  119. package/lib/components/eftposPay/mx51/Action.d.ts +6 -0
  120. package/lib/components/eftposPay/mx51/Action.js +127 -0
  121. package/lib/components/eftposPay/mx51/const.d.ts +5 -0
  122. package/lib/components/eftposPay/mx51/const.js +85 -0
  123. package/lib/components/eftposPay/mx51/index.d.ts +6 -0
  124. package/lib/components/eftposPay/mx51/index.js +330 -0
  125. package/lib/components/eftposPay/mx51/types.d.ts +136 -0
  126. package/lib/components/eftposPay/mx51/types.js +39 -0
  127. package/lib/components/eftposPay/mx51/utils.d.ts +10 -0
  128. package/lib/components/eftposPay/mx51/utils.js +114 -0
  129. package/lib/components/eftposPay/pay.js +4 -2
  130. package/lib/components/eftposPay/store/index.d.ts +1 -1
  131. package/lib/components/eventBooking/components/Provider/Content/index.d.ts +1 -0
  132. package/lib/components/eventBooking/components/Provider/EmptyHolderModal/index.d.ts +0 -1
  133. package/lib/components/eventBooking/components/Provider/Header/index.d.ts +1 -0
  134. package/lib/components/eventBooking/components/Provider/OrderProductModal/index.d.ts +0 -1
  135. package/lib/components/eventBooking/components/Provider/RemoveOptionConfirmModal.d.ts +0 -1
  136. package/lib/components/eventBooking/components/Provider/SelectHolderModal.d.ts +1 -0
  137. package/lib/components/eventBooking/components/bookingDetailModal/components/Resource.d.ts +1 -0
  138. package/lib/components/eventBooking/components/bookingDetailModal/components/Schedule.d.ts +1 -0
  139. package/lib/components/eventBooking/components/scheduleCalendar/components/ScheduleTimeItem/index.d.ts +0 -1
  140. package/lib/components/pay/toC/WalletPassBlock/components/WalletUseList/index.d.ts +0 -1
  141. package/lib/components/pisellSelectCustomerModal/RightPanel/List/index.d.ts +0 -1
  142. package/lib/components/shoppingCart/hooks/useAddService.d.ts +0 -1
  143. package/lib/components/shoppingCart/hooks/useClearCart.d.ts +0 -1
  144. package/lib/plus/saasRegister/components/VertifyEmail.d.ts +0 -1
  145. package/lib/plus/skuOptionsSelection/components/OptionsCard/index.d.ts +0 -1
  146. package/lib/plus/skuOptionsSelection/components/TitleExtra/index.d.ts +0 -1
  147. package/lib/plus/skuOptionsSelection/components/VariantCard/index.d.ts +0 -1
  148. package/lib/plus/walletPassGallery/components/passList/index.d.ts +0 -1
  149. package/lowcode/eco-cup-list/meta.ts +63 -0
  150. package/lowcode/eco-customer-list/meta.ts +63 -0
  151. package/package.json +1 -1
@@ -0,0 +1,96 @@
1
+ import PaymentMethod from './utils/payment';
2
+ export declare enum EVisibleButtonType {
3
+ /** 取消按钮 */
4
+ CancelButton = "CancelButton",
5
+ /** 等待按钮 */
6
+ WaitButton = "WaitButton"
7
+ }
8
+ export declare enum EActionStatus {
9
+ /** 空 */
10
+ Empty = "Empty",
11
+ /** 取消 */
12
+ Cancel = "Cancel",
13
+ /** 取消中 */
14
+ CancelWaiting = "CancelWaiting",
15
+ /** 签名 */
16
+ Signature = "Signature",
17
+ /** 签名等待中 */
18
+ SignatureWaiting = "SignatureWaiting"
19
+ }
20
+ export declare const QUERY_START_DELAY: number;
21
+ export declare const GLOBAL_TIMEOUT: number;
22
+ export declare const REQUEST_TIMEOUT: number;
23
+ export declare const QUERY_INTERVAL: number;
24
+ /**
25
+ * 聚合支付初始化参数
26
+ */
27
+ export interface PaymentMethodOptions {
28
+ /** 支付类型 */
29
+ paymentCode: string;
30
+ /** 交易号 */
31
+ paymentNum: string;
32
+ /** 订单ID */
33
+ orderId?: string | number;
34
+ /** 设备ID */
35
+ deviceId?: string | number;
36
+ /** 统一回调函数 */
37
+ callback: PaymentCallback;
38
+ /** 检查是否应该继续处理结果 */
39
+ shouldContinue?: () => boolean;
40
+ config?: PaymentMethodConfig;
41
+ }
42
+ /**
43
+ * 聚合支付操作类型
44
+ */
45
+ export declare enum ActionType {
46
+ /** 支付 */
47
+ Pay = "pay",
48
+ /** 支付查询 */
49
+ PayQuery = "payQuery",
50
+ /** 支付行为 */
51
+ PayAction = "payAction",
52
+ /** 退款 */
53
+ Refund = "refund",
54
+ /** 退款查询 */
55
+ RefundQuery = "refundQuery",
56
+ /** 退款行为 */
57
+ RefundAction = "refundAction"
58
+ }
59
+ /** 回调事件 */
60
+ export interface CallbackEvent {
61
+ /** 事件类型:成功、失败、进度 */
62
+ status: EPaymentStatus;
63
+ /** 操作类型 */
64
+ actionType: ActionType;
65
+ /** 数据:成功时是结果,失败时是错误信息,进度时是进度数据 */
66
+ data: any;
67
+ }
68
+ /** 统一回调函数 */
69
+ export declare type PaymentCallback = (instance: PaymentMethod, event: CallbackEvent) => void;
70
+ /**
71
+ * 执行操作参数
72
+ */
73
+ export interface RunOptions {
74
+ /** 操作类型 */
75
+ actionType: ActionType;
76
+ /** 请求参数 */
77
+ params?: Record<string, any>;
78
+ }
79
+ /**
80
+ * 聚合支付配置参数
81
+ */
82
+ export interface PaymentMethodConfig {
83
+ /** 是否需要轮询间隔 */
84
+ hasQueryInterval?: boolean;
85
+ }
86
+ /**
87
+ * 支付状态
88
+ */
89
+ export declare enum EPaymentStatus {
90
+ /** 支付中 */
91
+ Processing = "processing",
92
+ /** 支付成功 */
93
+ Success = "success",
94
+ /** 支付失败 */
95
+ Failed = "failed"
96
+ }
@@ -0,0 +1,61 @@
1
+ export var EVisibleButtonType = /*#__PURE__*/function (EVisibleButtonType) {
2
+ EVisibleButtonType["CancelButton"] = "CancelButton";
3
+ EVisibleButtonType["WaitButton"] = "WaitButton";
4
+ return EVisibleButtonType;
5
+ }({});
6
+ export var EActionStatus = /*#__PURE__*/function (EActionStatus) {
7
+ EActionStatus["Empty"] = "Empty";
8
+ EActionStatus["Cancel"] = "Cancel";
9
+ EActionStatus["CancelWaiting"] = "CancelWaiting";
10
+ EActionStatus["Signature"] = "Signature";
11
+ EActionStatus["SignatureWaiting"] = "SignatureWaiting";
12
+ return EActionStatus;
13
+ }({});
14
+
15
+ // 开始轮询的延迟时间(支付发起后等待10秒)
16
+ export var QUERY_START_DELAY = 1000 * 10;
17
+ // 全局超时时间(2分钟)
18
+ export var GLOBAL_TIMEOUT = 1000 * 60 * 2;
19
+ // 单次请求超时时间(10秒)
20
+ export var REQUEST_TIMEOUT = 1000 * 10;
21
+ // 轮询间隔时间(2秒)
22
+ export var QUERY_INTERVAL = 1000 * 2;
23
+
24
+ /**
25
+ * 聚合支付初始化参数
26
+ */
27
+
28
+ /**
29
+ * 聚合支付操作类型
30
+ */
31
+ export var ActionType = /*#__PURE__*/function (ActionType) {
32
+ ActionType["Pay"] = "pay";
33
+ ActionType["PayQuery"] = "payQuery";
34
+ ActionType["PayAction"] = "payAction";
35
+ ActionType["Refund"] = "refund";
36
+ ActionType["RefundQuery"] = "refundQuery";
37
+ ActionType["RefundAction"] = "refundAction";
38
+ return ActionType;
39
+ }({});
40
+
41
+ /** 回调事件 */
42
+
43
+ /** 统一回调函数 */
44
+
45
+ /**
46
+ * 执行操作参数
47
+ */
48
+
49
+ /**
50
+ * 聚合支付配置参数
51
+ */
52
+
53
+ /**
54
+ * 支付状态
55
+ */
56
+ export var EPaymentStatus = /*#__PURE__*/function (EPaymentStatus) {
57
+ EPaymentStatus["Processing"] = "processing";
58
+ EPaymentStatus["Success"] = "success";
59
+ EPaymentStatus["Failed"] = "failed";
60
+ return EPaymentStatus;
61
+ }({});
@@ -0,0 +1,110 @@
1
+ export interface LogEntry {
2
+ /** 日志标题 */
3
+ title: string;
4
+ /** 日志内容 */
5
+ content?: any;
6
+ /** 支付时间(精确到毫秒) */
7
+ time: string;
8
+ }
9
+ interface PaymentLogRecord {
10
+ /** 交易记录号 */
11
+ number: string;
12
+ /** 订单ID */
13
+ orderId?: string | number;
14
+ /** 设备ID */
15
+ deviceId?: string | number;
16
+ /** 支付类型 */
17
+ paymentCode?: string;
18
+ /** 创建时间 */
19
+ createdAt: string;
20
+ /** 日志条目列表 */
21
+ logs: LogEntry[];
22
+ }
23
+ declare class PaymentLogInstance {
24
+ private static instance;
25
+ /** 当前交易记录号 */
26
+ private currentNumber;
27
+ /** 当前日志记录 */
28
+ private currentRecord;
29
+ private constructor();
30
+ /**
31
+ * 获取单例实例
32
+ */
33
+ static getInstance(): PaymentLogInstance;
34
+ /**
35
+ * 初始化支付日志
36
+ * @param number 交易记录号
37
+ * @param options 初始化选项
38
+ */
39
+ init(number: string, options?: {
40
+ orderId?: string | number;
41
+ deviceId?: string | number;
42
+ paymentCode?: string;
43
+ [key: string]: any;
44
+ }): void;
45
+ /**
46
+ * 添加日志条目
47
+ * @param title 日志标题
48
+ * @param content 日志内容
49
+ */
50
+ addLog(params: {
51
+ title: string;
52
+ content?: any;
53
+ }): void;
54
+ /**
55
+ * 构建日志内容
56
+ * @param record 日志记录
57
+ * @returns 格式化的日志内容数组
58
+ */
59
+ private buildLogContent;
60
+ /**
61
+ * 发送单条日志记录到飞书
62
+ * @param record 日志记录
63
+ * @param isRestore 是否是恢复上传
64
+ */
65
+ private sendLogRecord;
66
+ /**
67
+ * 发送日志到飞书
68
+ * @param title 日志标题(可选,仅在需要自定义标题时使用)
69
+ */
70
+ sendLogs(title?: string): void;
71
+ /**
72
+ * 清除当前日志
73
+ * @param shouldSend 清除前是否发送到飞书,默认为 true
74
+ */
75
+ clearLogs(shouldSend?: boolean): void;
76
+ /**
77
+ * 检查并上传旧日志
78
+ */
79
+ private checkAndUploadOldLogs;
80
+ /**
81
+ * 获取所有支付日志对象
82
+ */
83
+ private getAllLogsObject;
84
+ /**
85
+ * 保存所有支付日志对象
86
+ */
87
+ private saveAllLogsObject;
88
+ /**
89
+ * 保存到 localStorage
90
+ */
91
+ private saveToLocalStorage;
92
+ /**
93
+ * 从 localStorage 中删除
94
+ */
95
+ private removeFromLocalStorage;
96
+ /**
97
+ * 获取所有旧日志
98
+ */
99
+ private getOldLogsFromLocalStorage;
100
+ /**
101
+ * 获取当前日志记录(用于调试)
102
+ */
103
+ getCurrentRecord(): PaymentLogRecord | null;
104
+ /**
105
+ * 获取当前交易号(用于调试)
106
+ */
107
+ getCurrentNumber(): string | null;
108
+ }
109
+ declare const paymentLog: PaymentLogInstance;
110
+ export default paymentLog;
@@ -0,0 +1,385 @@
1
+ var _excluded = ["pay_param_base64"];
2
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
6
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
7
+ 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); }
8
+ 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; }
9
+ 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; }
10
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
11
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
12
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
13
+ 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; }
14
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
15
+ 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); }
16
+ import dayjs from 'dayjs';
17
+ import { sendWarningLog } from '@pisell/utils';
18
+
19
+ /**
20
+ * 支付日志
21
+ * 1. 支付日志实行单例模式,以交易记录的number为key
22
+ * 2. 需要有init方法,用于初始化一次支付流程的日志,在初始化过程中需要首先判断localstorage中是否存在交易记录,如果存在需要将之前的交易记录上传飞书并从localstorage中删除,
23
+ * 然后创建一个新的日志对象,用于记录本次支付流程的日志
24
+ * 3. 需要有addLog方法,用于添加日志,日志内容需要包括支付状态,支付时间,支付金额,支付方式,支付结果等信息,需要记录到localstorage中
25
+ * 4. 需要有sendLogs方法,用于发送日志,日志内容需要包括支付状态,支付时间,支付金额,支付方式,支付结果等信息,需要上传飞书
26
+ * 5. 需要有clearLogs方法,用于清除日志,清除后需要将localstorage中记录的日志删除
27
+ */
28
+
29
+ // 本地存储的固定key
30
+ var PAYMENT_LOGS_KEY = 'pisell2_eftpos_payment_logs';
31
+
32
+ // 日志条目接口
33
+
34
+ // 日志记录接口
35
+ var PaymentLogInstance = /*#__PURE__*/function () {
36
+ function PaymentLogInstance() {
37
+ _classCallCheck(this, PaymentLogInstance);
38
+ /** 当前交易记录号 */
39
+ _defineProperty(this, "currentNumber", null);
40
+ /** 当前日志记录 */
41
+ _defineProperty(this, "currentRecord", null);
42
+ }
43
+
44
+ /**
45
+ * 获取单例实例
46
+ */
47
+ _createClass(PaymentLogInstance, [{
48
+ key: "init",
49
+ value:
50
+ /**
51
+ * 初始化支付日志
52
+ * @param number 交易记录号
53
+ * @param options 初始化选项
54
+ */
55
+ function init(number, options) {
56
+ try {
57
+ // 1. 检查是否有旧的日志记录需要上传
58
+ this.checkAndUploadOldLogs();
59
+
60
+ // 2. 创建新的日志记录
61
+ this.currentNumber = number;
62
+ this.currentRecord = {
63
+ number: number,
64
+ orderId: options === null || options === void 0 ? void 0 : options.orderId,
65
+ deviceId: options === null || options === void 0 ? void 0 : options.deviceId,
66
+ paymentCode: options === null || options === void 0 ? void 0 : options.paymentCode,
67
+ createdAt: dayjs().format('YYYY-MM-DD HH:mm:ss.SSS'),
68
+ logs: []
69
+ };
70
+
71
+ // 3. 添加初始化日志
72
+ this.addLog({
73
+ title: 'EFTPOS日志初始化',
74
+ content: _objectSpread({
75
+ number: number
76
+ }, options || {})
77
+ });
78
+ console.log("\uD83D\uDCDD \u652F\u4ED8\u65E5\u5FD7\u521D\u59CB\u5316\u6210\u529F\uFF0C\u4EA4\u6613\u53F7: ".concat(number));
79
+ } catch (error) {
80
+ console.error('❌ 支付日志初始化失败:', error);
81
+ }
82
+ }
83
+
84
+ /**
85
+ * 添加日志条目
86
+ * @param title 日志标题
87
+ * @param content 日志内容
88
+ */
89
+ }, {
90
+ key: "addLog",
91
+ value: function addLog(params) {
92
+ try {
93
+ if (!this.currentRecord || !this.currentNumber) {
94
+ console.warn('⚠️ 日志未初始化,无法添加日志');
95
+ return;
96
+ }
97
+ var logEntry = {
98
+ title: params.title,
99
+ time: dayjs().format('YYYY-MM-DD HH:mm:ss.SSS')
100
+ };
101
+ // 如果content存在,则添加到日志内容中,节约空间
102
+ if (params !== null && params !== void 0 && params.content) {
103
+ var _params$content;
104
+ // 特殊操作:如果content是对象并且对象中含有params字段,需要将对应的pay_param_base64字段删除
105
+ if (_typeof(params.content) === 'object' && (_params$content = params.content) !== null && _params$content !== void 0 && _params$content.params) {
106
+ var _params$content2, _params$content3;
107
+ var _ref = ((_params$content2 = params.content) === null || _params$content2 === void 0 || (_params$content2 = _params$content2.params) === null || _params$content2 === void 0 ? void 0 : _params$content2.eftpos) || {},
108
+ pay_param_base64 = _ref.pay_param_base64,
109
+ otherParams = _objectWithoutProperties(_ref, _excluded);
110
+ params.content.params = _objectSpread(_objectSpread({}, ((_params$content3 = params.content) === null || _params$content3 === void 0 ? void 0 : _params$content3.params) || {}), {}, {
111
+ eftpos: otherParams
112
+ });
113
+ }
114
+ logEntry.content = params.content;
115
+ }
116
+
117
+ // 添加到当前记录
118
+ this.currentRecord.logs.push(logEntry);
119
+
120
+ // 保存到 localStorage
121
+ this.saveToLocalStorage();
122
+ console.log("\uD83D\uDCDD \u6DFB\u52A0\u652F\u4ED8\u65E5\u5FD7: ".concat(params.title), logEntry);
123
+ } catch (error) {
124
+ console.error('❌ 添加日志失败:', error);
125
+ }
126
+ }
127
+
128
+ /**
129
+ * 构建日志内容
130
+ * @param record 日志记录
131
+ * @returns 格式化的日志内容数组
132
+ */
133
+ }, {
134
+ key: "buildLogContent",
135
+ value: function buildLogContent(record) {
136
+ return [{
137
+ key: '交易记录号',
138
+ value: record.number
139
+ }, {
140
+ key: '订单ID',
141
+ value: (record === null || record === void 0 ? void 0 : record.orderId) || '未知'
142
+ }, {
143
+ key: '设备ID',
144
+ value: (record === null || record === void 0 ? void 0 : record.deviceId) || '未知'
145
+ }, {
146
+ key: '支付类型',
147
+ value: (record === null || record === void 0 ? void 0 : record.paymentCode) || '未知'
148
+ }, {
149
+ key: '创建时间',
150
+ value: record.createdAt
151
+ }, {
152
+ key: '详细日志',
153
+ value: JSON.stringify(record.logs || [])
154
+ }];
155
+ }
156
+
157
+ /**
158
+ * 发送单条日志记录到飞书
159
+ * @param record 日志记录
160
+ * @param isRestore 是否是恢复上传
161
+ */
162
+ }, {
163
+ key: "sendLogRecord",
164
+ value: function sendLogRecord(record) {
165
+ var isRestore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
166
+ var prefix = isRestore ? '-[历史]' : '';
167
+ var title = "\u652F\u4ED8\u65E5\u5FD7-".concat(record.paymentCode || 'Unknown', "-").concat(record.orderId || 'Unknown').concat(prefix);
168
+ var content = this.buildLogContent(record);
169
+ sendWarningLog({
170
+ title: title,
171
+ content: content
172
+ });
173
+ console.log("\u2705 \u65E5\u5FD7\u5DF2\u53D1\u9001\u5230\u98DE\u4E66: ".concat(title));
174
+ }
175
+
176
+ /**
177
+ * 发送日志到飞书
178
+ * @param title 日志标题(可选,仅在需要自定义标题时使用)
179
+ */
180
+ }, {
181
+ key: "sendLogs",
182
+ value: function sendLogs(title) {
183
+ try {
184
+ if (!this.currentRecord) {
185
+ console.warn('⚠️ 没有日志记录需要发送');
186
+ return;
187
+ }
188
+ if (title) {
189
+ // 如果提供了自定义标题,使用自定义标题
190
+ var content = this.buildLogContent(this.currentRecord);
191
+ sendWarningLog({
192
+ title: title,
193
+ content: content
194
+ });
195
+ console.log("\u2705 \u65E5\u5FD7\u5DF2\u53D1\u9001\u5230\u98DE\u4E66: ".concat(title));
196
+ } else {
197
+ // 否则使用默认格式
198
+ this.sendLogRecord(this.currentRecord, false);
199
+ }
200
+ } catch (error) {
201
+ console.error('❌ 发送日志到飞书失败:', error);
202
+ }
203
+ }
204
+
205
+ /**
206
+ * 清除当前日志
207
+ * @param shouldSend 清除前是否发送到飞书,默认为 true
208
+ */
209
+ }, {
210
+ key: "clearLogs",
211
+ value: function clearLogs() {
212
+ var shouldSend = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
213
+ try {
214
+ if (!this.currentNumber) {
215
+ console.warn('⚠️ 没有活动的日志记录需要清除');
216
+ return;
217
+ }
218
+
219
+ // 如果需要,先发送到飞书
220
+ if (shouldSend && this.currentRecord) {
221
+ this.sendLogs();
222
+ }
223
+
224
+ // 从 localStorage 中删除
225
+ this.removeFromLocalStorage(this.currentNumber);
226
+
227
+ // 重置当前状态
228
+ this.currentNumber = null;
229
+ this.currentRecord = null;
230
+ console.log('🧹 日志已清除');
231
+ } catch (error) {
232
+ console.error('❌ 清除日志失败:', error);
233
+ }
234
+ }
235
+
236
+ /**
237
+ * 检查并上传旧日志
238
+ */
239
+ }, {
240
+ key: "checkAndUploadOldLogs",
241
+ value: function checkAndUploadOldLogs() {
242
+ try {
243
+ var oldLogs = this.getOldLogsFromLocalStorage();
244
+ if (oldLogs.length === 0) {
245
+ return;
246
+ }
247
+ console.log("\uD83D\uDCE4 \u53D1\u73B0 ".concat(oldLogs.length, " \u6761\u65E7\u65E5\u5FD7\u8BB0\u5F55\uFF0C\u51C6\u5907\u4E0A\u4F20..."));
248
+
249
+ // 逐个上传并删除
250
+ var _iterator = _createForOfIteratorHelper(oldLogs),
251
+ _step;
252
+ try {
253
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
254
+ var log = _step.value;
255
+ try {
256
+ // 使用统一的发送方法
257
+ this.sendLogRecord(log, true);
258
+
259
+ // 上传后删除
260
+ this.removeFromLocalStorage(log.number);
261
+ console.log("\u2705 \u65E7\u65E5\u5FD7\u5DF2\u4E0A\u4F20\u5E76\u5220\u9664: ".concat(log.number));
262
+ } catch (error) {
263
+ console.error("\u274C \u4E0A\u4F20\u65E7\u65E5\u5FD7\u5931\u8D25 (".concat(log.number, "):"), error);
264
+ }
265
+ }
266
+ } catch (err) {
267
+ _iterator.e(err);
268
+ } finally {
269
+ _iterator.f();
270
+ }
271
+ } catch (error) {
272
+ console.error('❌ 检查旧日志失败:', error);
273
+ }
274
+ }
275
+
276
+ /**
277
+ * 获取所有支付日志对象
278
+ */
279
+ }, {
280
+ key: "getAllLogsObject",
281
+ value: function getAllLogsObject() {
282
+ try {
283
+ var value = localStorage.getItem(PAYMENT_LOGS_KEY);
284
+ if (!value) {
285
+ return {};
286
+ }
287
+ return JSON.parse(value);
288
+ } catch (error) {
289
+ console.error('❌ 读取 localStorage 失败:', error);
290
+ return {};
291
+ }
292
+ }
293
+
294
+ /**
295
+ * 保存所有支付日志对象
296
+ */
297
+ }, {
298
+ key: "saveAllLogsObject",
299
+ value: function saveAllLogsObject(logsObject) {
300
+ try {
301
+ localStorage.setItem(PAYMENT_LOGS_KEY, JSON.stringify(logsObject));
302
+ } catch (error) {
303
+ console.error('❌ 保存到 localStorage 失败:', error);
304
+ }
305
+ }
306
+
307
+ /**
308
+ * 保存到 localStorage
309
+ */
310
+ }, {
311
+ key: "saveToLocalStorage",
312
+ value: function saveToLocalStorage() {
313
+ try {
314
+ if (!this.currentRecord || !this.currentNumber) {
315
+ return;
316
+ }
317
+ var allLogs = this.getAllLogsObject();
318
+ allLogs[this.currentNumber] = this.currentRecord;
319
+ this.saveAllLogsObject(allLogs);
320
+ } catch (error) {
321
+ console.error('❌ 保存到 localStorage 失败:', error);
322
+ }
323
+ }
324
+
325
+ /**
326
+ * 从 localStorage 中删除
327
+ */
328
+ }, {
329
+ key: "removeFromLocalStorage",
330
+ value: function removeFromLocalStorage(number) {
331
+ try {
332
+ var allLogs = this.getAllLogsObject();
333
+ delete allLogs[number];
334
+ this.saveAllLogsObject(allLogs);
335
+ } catch (error) {
336
+ console.error('❌ 从 localStorage 删除失败:', error);
337
+ }
338
+ }
339
+
340
+ /**
341
+ * 获取所有旧日志
342
+ */
343
+ }, {
344
+ key: "getOldLogsFromLocalStorage",
345
+ value: function getOldLogsFromLocalStorage() {
346
+ try {
347
+ var allLogs = this.getAllLogsObject();
348
+ return Object.values(allLogs);
349
+ } catch (error) {
350
+ console.error('❌ 获取旧日志失败:', error);
351
+ return [];
352
+ }
353
+ }
354
+
355
+ /**
356
+ * 获取当前日志记录(用于调试)
357
+ */
358
+ }, {
359
+ key: "getCurrentRecord",
360
+ value: function getCurrentRecord() {
361
+ return this.currentRecord;
362
+ }
363
+
364
+ /**
365
+ * 获取当前交易号(用于调试)
366
+ */
367
+ }, {
368
+ key: "getCurrentNumber",
369
+ value: function getCurrentNumber() {
370
+ return this.currentNumber;
371
+ }
372
+ }], [{
373
+ key: "getInstance",
374
+ value: function getInstance() {
375
+ if (!PaymentLogInstance.instance) {
376
+ PaymentLogInstance.instance = new PaymentLogInstance();
377
+ }
378
+ return PaymentLogInstance.instance;
379
+ }
380
+ }]);
381
+ return PaymentLogInstance;
382
+ }();
383
+ _defineProperty(PaymentLogInstance, "instance", void 0);
384
+ var paymentLog = PaymentLogInstance.getInstance();
385
+ export default paymentLog;