Skip to content

Commit

Permalink
修复整数没有补位0导致无法匹配交易
Browse files Browse the repository at this point in the history
  • Loading branch information
assimon committed Mar 29, 2022
1 parent fce84c9 commit 7b1512f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/model/service/task_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package service

import (
"context"
"fmt"
"github.com/assimon/luuu/model/data"
"github.com/assimon/luuu/model/request"
"github.com/assimon/luuu/util/http_client"
Expand Down Expand Up @@ -97,8 +98,9 @@ func Trc20CallBack(token string, wg *sync.WaitGroup) {
}
x, _ := decimal.NewFromString(transfer.Quant)
y, _ := decimal.NewFromString("1000000")
quant := x.Div(y).String()
result, err := data.GetExpirationTimeByAmount(ctx, token, quant)
quant := x.Div(y).InexactFloat64()
amount := fmt.Sprintf("%.4f", quant)
result, err := data.GetExpirationTimeByAmount(ctx, token, amount)
if err != nil {
panic(err)
}
Expand All @@ -107,12 +109,12 @@ func Trc20CallBack(token string, wg *sync.WaitGroup) {
// 但是过期了
if expTime < nowTime {
// 删掉过期
_ = data.ClearPayCache(token, quant)
_ = data.ClearPayCache(token, amount)
continue
}
}
// 该钱包下有无匹配金额订单
tradeId, err := data.GetTradeIdByAmount(ctx, token, quant)
tradeId, err := data.GetTradeIdByAmount(ctx, token, amount)
if err != nil {
panic(err)
}
Expand All @@ -123,7 +125,7 @@ func Trc20CallBack(token string, wg *sync.WaitGroup) {
req := &request.OrderProcessingRequest{
Token: token,
TradeId: tradeId,
Amount: quant,
Amount: amount,
BlockTransactionId: transfer.TransactionID,
}
err = OrderProcessing(req)
Expand Down

0 comments on commit 7b1512f

Please sign in to comment.