fix(camel_oil): correct payment timeout and order query duration
- Adjust order query time window from 6 hours ahead to 1 day before the current time - Update payment timeout check duration from 24 hours to 1 hour - Remove unused time package import from cron_tasks.go - Fix logic to properly identify unpaid orders within the correct timeframe
This commit is contained in:
@@ -7,8 +7,6 @@ import (
|
||||
"github.com/gogf/gf/v2/net/gtrace"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
"time"
|
||||
|
||||
"kami/internal/consts"
|
||||
"kami/internal/dao"
|
||||
"kami/internal/model"
|
||||
@@ -90,7 +88,7 @@ func (s *sCamelOil) CronOrderPaymentCheckTask(ctx context.Context) error {
|
||||
var orders []*entity.V1CamelOilOrder
|
||||
err := dao.V1CamelOilOrder.Ctx(ctx).DB(config.GetDatabaseV1()).
|
||||
Where(dao.V1CamelOilOrder.Columns().PayStatus, consts.CamelOilPaymentStatusUnpaid).
|
||||
WhereGTE(dao.V1CamelOilOrder.Columns().CreatedAt, gtime.Now().Add(time.Hour*6)).
|
||||
WhereGTE(dao.V1CamelOilOrder.Columns().CreatedAt, gtime.Now().Add(-gtime.D)).
|
||||
Scan(&orders)
|
||||
|
||||
if err != nil {
|
||||
@@ -136,7 +134,7 @@ func (s *sCamelOil) CronOrderPaymentCheckTask(ctx context.Context) error {
|
||||
continue
|
||||
}
|
||||
|
||||
// 订单未支付,检查是否超时(24小时)
|
||||
// 订单未支付,检查是否超时(1小时)
|
||||
if gtime.Now().Sub(order.CreatedAt) >= consts.CamelOilOrderExpireDuration {
|
||||
glog.Warningf(ctx, "订单%s支付超时,创建时间: %v", order.OrderNo, order.CreatedAt)
|
||||
_, _ = dao.V1CamelOilOrder.Ctx(ctx).DB(config.GetDatabaseV1()).
|
||||
|
||||
Reference in New Issue
Block a user