diff --git a/app/models/orders/orders.go b/app/models/orders/orders.go index 4111027..d45c7b2 100644 --- a/app/models/orders/orders.go +++ b/app/models/orders/orders.go @@ -378,6 +378,7 @@ func (m *ordersModel) GetRechargeTimeoutOrder( sql := "1=1" var args []interface{} sql += " and transfer_status = 2" + 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(DATE_ADD(NOW(),INTERVAL 8 HOUR), INTERVAL 7 MINUTE)" err = m.GetDb().Where(sql, args...).OrderBy("created_at").Limit(limit).Find(&orders) diff --git a/app/services/transfersys/transfersys_recharge_timeout.go b/app/services/transfersys/transfersys_recharge_timeout.go index e6332a6..036e2c0 100644 --- a/app/services/transfersys/transfersys_recharge_timeout.go +++ b/app/services/transfersys/transfersys_recharge_timeout.go @@ -14,8 +14,8 @@ import ( func DoRechargeTimeout() { fmt.Println("开始执行周期任务:DoTimeout") - // 创建一个新的Ticker,每3秒钟触发一次 - ticker := time.NewTicker(3 * time.Second) + // 创建一个新的Ticker,每分钟触发一次 + ticker := time.NewTicker(60 * time.Second) defer ticker.Stop() // 在函数结束时停止Ticker for range ticker.C { res, err := models.GetInstance().GetRechargeTimeoutOrder(10) @@ -24,12 +24,16 @@ func DoRechargeTimeout() { continue } for i := 0; i < len(res); i++ { + models.GetInstance().Update(&models.Orders{ + Id: res[i].Id, + FailReason: "超时", + }) dingStr := fmt.Sprintf( ` 系统出现了超时7分钟的订单啦,快去后台查看! - 异常单号: %s; - 充值账号: %s; - `, + `, res[i].OutTradeNo, res[i].RechargeAccount, )