fix
This commit is contained in:
parent
f86624aa1b
commit
e2bd32c96c
|
@ -379,8 +379,8 @@ func (m *ordersModel) GetRechargeTimeoutOrder(
|
||||||
var args []interface{}
|
var args []interface{}
|
||||||
sql += " and transfer_status = 2"
|
sql += " and transfer_status = 2"
|
||||||
sql += " and (fail_reason = '' or fail_reason IS NULL)"
|
sql += " and (fail_reason = '' or fail_reason IS NULL)"
|
||||||
// sql += " and created_at <= DATE_SUB(NOW(), INTERVAL 3 MINUTE)"
|
sql += " and created_at <= DATE_SUB(NOW(), INTERVAL 3 MINUTE)"
|
||||||
sql += " and created_at <= DATE_SUB(DATE_ADD(NOW(),INTERVAL 8 HOUR), INTERVAL 7 MINUTE)"
|
// sql += " and created_at <= DATE_SUB(DATE_ADD(NOW(),INTERVAL 8 HOUR), INTERVAL 7 MINUTE)"
|
||||||
err = m.GetDb().Where(sql, args...).OrderBy("created_at").Limit(limit).Find(&orders)
|
err = m.GetDb().Where(sql, args...).OrderBy("created_at").Limit(limit).Find(&orders)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,10 +137,10 @@ func DingSend(title string, content string, retry bool) (err error) {
|
||||||
logger.Error(context.TODO(), "dingding", err)
|
logger.Error(context.TODO(), "dingding", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// fmt.Println("响应状态码:", resp.StatusCode)
|
// fmt.Println("响应状态码:", resp.StatusCode)
|
||||||
// fmt.Println("响应内容:", string(body))
|
// fmt.Println("响应内容:", string(body))
|
||||||
|
|
||||||
|
// fmt.Println("参数:", data)
|
||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != 200 {
|
||||||
logger.Error(context.TODO(), "dingding", "钉钉发送公告失败")
|
logger.Error(context.TODO(), "dingding", "钉钉发送公告失败")
|
||||||
logger.Error(context.TODO(), "dingding", string(body))
|
logger.Error(context.TODO(), "dingding", string(body))
|
||||||
|
|
|
@ -8,15 +8,14 @@ import (
|
||||||
|
|
||||||
models "com.snow.auto_monitor/app/models/orders"
|
models "com.snow.auto_monitor/app/models/orders"
|
||||||
dingServ "com.snow.auto_monitor/app/services/dingding"
|
dingServ "com.snow.auto_monitor/app/services/dingding"
|
||||||
orderServ "com.snow.auto_monitor/app/services/orders"
|
|
||||||
"github.com/qit-team/snow-core/log/logger"
|
"github.com/qit-team/snow-core/log/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
func DoRechargeTimeout() {
|
func DoRechargeTimeout() {
|
||||||
fmt.Println("开始执行周期任务:DoTimeout")
|
fmt.Println("开始执行周期任务:DoRechargeTimeout")
|
||||||
|
|
||||||
// 创建一个新的Ticker,每分钟触发一次
|
// 创建一个新的Ticker,每分钟触发一次
|
||||||
ticker := time.NewTicker(60 * time.Second)
|
ticker := time.NewTicker(3 * time.Second)
|
||||||
defer ticker.Stop() // 在函数结束时停止Ticker
|
defer ticker.Stop() // 在函数结束时停止Ticker
|
||||||
for range ticker.C {
|
for range ticker.C {
|
||||||
res, err := models.GetInstance().GetRechargeTimeoutOrder(10)
|
res, err := models.GetInstance().GetRechargeTimeoutOrder(10)
|
||||||
|
@ -25,21 +24,25 @@ func DoRechargeTimeout() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
for i := 0; i < len(res); i++ {
|
for i := 0; i < len(res); i++ {
|
||||||
orderServ.Update(&models.Orders{
|
models.GetInstance().Update(&models.Orders{
|
||||||
Id: res[i].Id,
|
Id: res[i].Id,
|
||||||
FailReason: "超时",
|
FailReason: "超时",
|
||||||
})
|
})
|
||||||
|
logger.Info(context.TODO(), "order recharge timeout", "orderId: "+strconv.FormatInt(res[i].Id, 10))
|
||||||
|
}
|
||||||
|
if len(res) > 0 {
|
||||||
dingStr := fmt.Sprintf(
|
dingStr := fmt.Sprintf(
|
||||||
`
|
`
|
||||||
系统出现了超时7分钟的订单啦,快去后台查看!
|
系统出现了超时7分钟的订单啦,快去后台查看!
|
||||||
- 异常单号: %s;
|
- 异常单号: %s;
|
||||||
- 充值账号: %s;
|
- 充值账号: %s;
|
||||||
`,
|
`,
|
||||||
res[i].OutTradeNo,
|
res[0].OutTradeNo,
|
||||||
res[i].RechargeAccount,
|
res[0].RechargeAccount,
|
||||||
)
|
)
|
||||||
dingServ.DingSend("订单超时", dingStr, true)
|
err = dingServ.DingSend("订单超时", dingStr, true)
|
||||||
logger.Info(context.TODO(), "order recharge timeout", "orderId: "+strconv.FormatInt(res[i].Id, 10))
|
fmt.Println(err)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue