45 lines
1.0 KiB
Go
45 lines
1.0 KiB
Go
package transfersys
|
||
|
||
import (
|
||
"context"
|
||
"fmt"
|
||
"strconv"
|
||
"time"
|
||
|
||
models "com.snow.auto_monitor/app/models/orders"
|
||
dingServ "com.snow.auto_monitor/app/services/dingding"
|
||
"github.com/qit-team/snow-core/log/logger"
|
||
)
|
||
|
||
func DoRechargeTimeout() {
|
||
fmt.Println("开始执行周期任务:DoTimeout")
|
||
|
||
// 创建一个新的Ticker,每3秒钟触发一次
|
||
ticker := time.NewTicker(3 * time.Second)
|
||
defer ticker.Stop() // 在函数结束时停止Ticker
|
||
for range ticker.C {
|
||
res, err := models.GetInstance().GetRechargeTimeoutOrder(10)
|
||
if err != nil {
|
||
fmt.Println(err.Error())
|
||
continue
|
||
}
|
||
for i := 0; i < len(res); i++ {
|
||
dingStr := fmt.Sprintf(
|
||
`
|
||
系统出现了超时7分钟的订单啦,快去后台查看!
|
||
- 异常单号: %s;
|
||
- 充值账号: %s;
|
||
`,
|
||
res[i].OutTradeNo,
|
||
res[i].RechargeAccount,
|
||
)
|
||
dingServ.DingSend("订单超时", dingStr, true)
|
||
logger.Info(context.TODO(), "order recharge timeout", "orderId: "+strconv.FormatInt(res[i].Id, 10))
|
||
}
|
||
}
|
||
}
|
||
|
||
func init() {
|
||
go DoRechargeTimeout()
|
||
}
|