Skip to content

Commit

Permalink
fix: 修复订单和其它监控重复通知
Browse files Browse the repository at this point in the history
  • Loading branch information
v03413 committed Sep 29, 2024
1 parent bd5f85b commit 295e5e0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions app/monitor/tron.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,7 @@ func parseBlockTrans(block *api.BlockExtention, nowHeight int64) {
}

if len(transfers) > 0 {
handleOrderTransaction(block.GetBlockHeader().GetRawData().GetNumber(), nowHeight, transfers)
handleOtherNotify(transfers)
handleOtherNotify(handleOrderTransaction(block.GetBlockHeader().GetRawData().GetNumber(), nowHeight, transfers))
}

if len(resources) > 0 {
Expand Down Expand Up @@ -274,12 +273,13 @@ func parseUsdtTrc20Contract(reader *bytes.Reader) usdtTrc20TransferRaw {
}

// handleOrderTransaction 处理支付交易
func handleOrderTransaction(refBlockNum, nowHeight int64, transfers []transfer) {
func handleOrderTransaction(refBlockNum, nowHeight int64, transfers []transfer) []transfer {
var orders, err = getAllPendingOrders()
var notOrderTransfers []transfer
if err != nil {
log.Error(err.Error())

return
return notOrderTransfers
}

for _, t := range transfers {
Expand All @@ -295,6 +295,7 @@ func handleOrderTransaction(refBlockNum, nowHeight int64, transfers []transfer)
// 判断是否存在对应订单
order, isOrder := orders[fmt.Sprintf("%s%v%s", t.RecvAddress, quant, t.TradeType)]
if !isOrder {
notOrderTransfers = append(notOrderTransfers, t)

continue
}
Expand Down Expand Up @@ -342,6 +343,8 @@ func handleOrderTransaction(refBlockNum, nowHeight int64, transfers []transfer)
go notify.OrderNotify(order) // 通知订单支付成功
go telegram.SendTradeSuccMsg(order) // TG发送订单信息
}

return notOrderTransfers
}

// handleOtherNotify 处理其他通知
Expand Down
2 changes: 1 addition & 1 deletion app/version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app

// Version 版本号说明 1.0.0 代表主版本号.功能版本号.修订号
const Version = "1.13.29"
const Version = "1.13.30"

0 comments on commit 295e5e0

Please sign in to comment.