1、在线支付
Some checks failed
Build / build (push) Has been cancelled
CodeQL / Analyze (go) (push) Has been cancelled
build / Build (push) Has been cancelled
GitHub Actions Mirror / mirror_to_gitee (push) Has been cancelled
GitHub Actions Mirror / mirror_to_gitlab (push) Has been cancelled
Issue Close Require / issue-close-require (push) Has been cancelled
Some checks failed
Build / build (push) Has been cancelled
CodeQL / Analyze (go) (push) Has been cancelled
build / Build (push) Has been cancelled
GitHub Actions Mirror / mirror_to_gitee (push) Has been cancelled
GitHub Actions Mirror / mirror_to_gitlab (push) Has been cancelled
Issue Close Require / issue-close-require (push) Has been cancelled
2、查询平台剩余字符数
This commit is contained in:
@ -9,6 +9,7 @@ import (
|
||||
"go-admin/utils/utility"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/go-admin-team/go-admin-core/logger"
|
||||
@ -23,7 +24,7 @@ const (
|
||||
)
|
||||
|
||||
// trx 链上支付定时查询
|
||||
func (j *TrxPaymentJob) Exec(args interface{}) error {
|
||||
func (j TrxPaymentJob) Exec(arg interface{}) error {
|
||||
configService := service.SysConfig{}
|
||||
configService.Orm = GetDb()
|
||||
req := dto.SysConfigByKeyReq{}
|
||||
@ -37,39 +38,58 @@ func (j *TrxPaymentJob) Exec(args interface{}) error {
|
||||
|
||||
rechargeService := service.TmRechargeLog{}
|
||||
rechargeService.Orm = GetDb()
|
||||
platforms, err := rechargeService.GetPlatforms()
|
||||
toAddresss := []string{}
|
||||
|
||||
if err != nil {
|
||||
logger.Error("查询平台失败", err)
|
||||
return err
|
||||
}
|
||||
|
||||
for _, platform := range platforms {
|
||||
if strings.ToLower(platform.BlockChain) == "trx" && !utility.ContainsString(toAddresss, platform.ReceiveAddress) {
|
||||
toAddresss = append(toAddresss, platform.ReceiveAddress)
|
||||
}
|
||||
}
|
||||
|
||||
startTime := time.Now().UnixMilli()
|
||||
endTime := time.Now().Add(-1 * time.Hour).UnixMilli()
|
||||
transfers, err := GetTRC20Transfers(UsdtContractAddress, configData.ConfigValue, endTime, startTime)
|
||||
if err != nil {
|
||||
logger.Error("查询失败", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
logs := make([]dto.TmRechargeCallbackReq, 0)
|
||||
item := dto.TmRechargeCallbackReq{}
|
||||
|
||||
for _, transfer := range transfers {
|
||||
if transfer.TransactionID == "" || transfer.ToAddress != configData.ConfigValue {
|
||||
continue
|
||||
}
|
||||
|
||||
//实际金额
|
||||
payableAmount := utility.StringToDecimal(transfer.Value).Div(decimal.NewFromInt(10).Pow(decimal.NewFromInt(int64(transfer.TokenInfo.Decimals)))).Truncate(6)
|
||||
item.TxHash = transfer.TransactionID
|
||||
item.PayableAmount = payableAmount
|
||||
item.FromAddress = transfer.FromAddress
|
||||
|
||||
logs = append(logs, item)
|
||||
}
|
||||
|
||||
if len(logs) > 0 {
|
||||
err := rechargeService.PayCallBack(&logs)
|
||||
|
||||
for _, toAddress := range toAddresss {
|
||||
transfers, err := GetTRC20Transfers(UsdtContractAddress, toAddress, endTime, startTime)
|
||||
if err != nil {
|
||||
logger.Error("执行完毕,err:")
|
||||
logger.Error("查询失败", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
logs := make([]dto.TmRechargeCallbackReq, 0)
|
||||
item := dto.TmRechargeCallbackReq{}
|
||||
|
||||
for _, transfer := range transfers {
|
||||
if transfer.TransactionID == "" || transfer.ToAddress != toAddress {
|
||||
continue
|
||||
}
|
||||
|
||||
//实际金额
|
||||
payableAmount := utility.StringToDecimal(transfer.Value).Div(decimal.NewFromInt(10).Pow(decimal.NewFromInt(int64(transfer.TokenInfo.Decimals)))).Truncate(6)
|
||||
item.TxHash = transfer.TransactionID
|
||||
item.PayableAmount = payableAmount
|
||||
item.FromAddress = transfer.FromAddress
|
||||
item.ToAddress = transfer.ToAddress
|
||||
|
||||
if utility.ContainsString(toAddresss, item.ToAddress) {
|
||||
logs = append(logs, item)
|
||||
}
|
||||
}
|
||||
|
||||
if len(logs) > 0 {
|
||||
err := rechargeService.PayCallBack(&logs)
|
||||
|
||||
if err != nil {
|
||||
logger.Error("执行完毕,err:", err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user