This commit is contained in:
lzx
2025-10-27 16:27:33 +08:00
parent b7c84fd101
commit b1d3e07c36
14 changed files with 2982 additions and 948 deletions

View File

@@ -188,20 +188,20 @@ func compressFile(filePath string) error {
}
// LogTopup 记录充值消息
func LogTopup(address string, status string, amount float64, txHash string, blockHeight uint64) {
func LogTopup(toAddress string, status string, amount float64, txHash string, blockHeight uint64) {
if txLogger == nil {
return
}
lf, err := txLogger.getOrCreateLogFile(address)
lf, err := txLogger.getOrCreateLogFile(toAddress)
if err != nil {
fmt.Printf("⚠️ 获取日志文件失败: %v\n", err)
return
}
timestamp := time.Now().Format("2006-01-02 15:04:05")
content := fmt.Sprintf("%s [topup]-[%s] | 金额: %.6f | 交易哈希: %s | 区块高度: %d | 地址: %s",
timestamp, status, amount, txHash, blockHeight, address)
content := fmt.Sprintf("%s [topup]-[%s] | 金额: %.6f | 交易哈希: %s | 区块高度: %d | ToAddress: %s",
timestamp, status, amount, txHash, blockHeight, toAddress)
if err := lf.write(content); err != nil {
fmt.Printf("⚠️ 写入日志失败: %v\n", err)
@@ -209,21 +209,21 @@ func LogTopup(address string, status string, amount float64, txHash string, bloc
}
// LogWithdraw 记录提现消息
func LogWithdraw(queueId string, status string, amount float64, from string, to string, txHash string, blockHeight uint64) {
func LogWithdraw(toAddress string, status string, amount float64, fromAddress string, txHash string, blockHeight uint64) {
if txLogger == nil {
return
}
// 使用 queueId 作为文件名
lf, err := txLogger.getOrCreateLogFile(queueId)
// 使用 toAddress 作为文件名
lf, err := txLogger.getOrCreateLogFile(toAddress)
if err != nil {
fmt.Printf("⚠️ 获取日志文件失败: %v\n", err)
return
}
timestamp := time.Now().Format("2006-01-02 15:04:05")
content := fmt.Sprintf("%s [withdraw]-[%s] | 金额: %.6f | From: %s | To: %s | 交易哈希: %s | 区块高度: %d",
timestamp, status, amount, from, to, txHash, blockHeight)
content := fmt.Sprintf("%s [withdraw]-[%s] | 金额: %.6f | FromAddress: %s | ToAddress: %s | 交易哈希: %s | 区块高度: %d",
timestamp, status, amount, fromAddress, toAddress, txHash, blockHeight)
if err := lf.write(content); err != nil {
fmt.Printf("⚠️ 写入日志失败: %v\n", err)
@@ -231,21 +231,21 @@ func LogWithdraw(queueId string, status string, amount float64, from string, to
}
// LogPay 记录支付消息
func LogPay(orderId string, queueId string, status string, amount float64, from string, to string, txHash string, blockHeight uint64) {
func LogPay(toAddress string, status string, amount float64, fromAddress string, txHash string, blockHeight uint64, orderId string, queueId string) {
if txLogger == nil {
return
}
// 使用 orderId 作为文件名
lf, err := txLogger.getOrCreateLogFile(orderId)
// 使用 toAddress 作为文件名
lf, err := txLogger.getOrCreateLogFile(toAddress)
if err != nil {
fmt.Printf("⚠️ 获取日志文件失败: %v\n", err)
return
}
timestamp := time.Now().Format("2006-01-02 15:04:05")
content := fmt.Sprintf("%s [pay]-[%s] | 订单ID: %s | 队列ID: %s | 金额: %.6f | From: %s | To: %s | 交易哈希: %s | 区块高度: %d",
timestamp, status, orderId, queueId, amount, from, to, txHash, blockHeight)
content := fmt.Sprintf("%s [pay]-[%s] | 金额: %.6f | FromAddress: %s | ToAddress: %s | 交易哈希: %s | 区块高度: %d | OrderId: %s | QueueId: %s",
timestamp, status, amount, fromAddress, toAddress, txHash, blockHeight, orderId, queueId)
if err := lf.write(content); err != nil {
fmt.Printf("⚠️ 写入日志失败: %v\n", err)