diff --git a/internal/data/repoimpl/order.go b/internal/data/repoimpl/order.go index 0062dd6..b62e9ea 100644 --- a/internal/data/repoimpl/order.go +++ b/internal/data/repoimpl/order.go @@ -55,6 +55,8 @@ func (p *OrderRepoImpl) SpecifyFindInBatches(ctx context.Context, req *bo.FindIn tx = tx.Where("voucher_no IN (?)", req.VoucherNos) } + tx.Order("") // 显式清除排序,移除默认的 ORDER BY + var results = make([]*model.Order, 0) result := tx.FindInBatches(&results, 100, func(tx *gorm.DB, batch int) error { @@ -93,6 +95,8 @@ func (p *OrderRepoImpl) FinSucByStockIdInBatches(ctx context.Context, req *do.We var results = make([]*model.Order, 0) + tx.Order("") // 显式清除排序,移除默认的 ORDER BY + result := tx.FindInBatches(&results, 100, func(tx *gorm.DB, batch int) error { return fun(ctx, p.ToBos(results)) @@ -112,6 +116,7 @@ func (p *OrderRepoImpl) FinFailByStockIdInBatches(ctx context.Context, batchNo s result := p.DB(ctx). Where("batch_no = ?", batchNo). Where("`status` = ?", vo.OrderStatusFail.GetValue()). + Order(""). // 显式清除排序,移除默认的 ORDER BY FindInBatches(&results, 100, func(tx *gorm.DB, batch int) error { return fun(ctx, p.ToBos(results)) }) @@ -130,6 +135,7 @@ func (p *OrderRepoImpl) FindIngInBatches(ctx context.Context, fun func(ctx conte result := p.DB(ctx). Where("`status` = ?", vo.OrderStatusIng.GetValue()). Limit(20). + Order(""). // 显式清除排序,移除默认的 ORDER BY FindInBatches(&results, 10, func(tx *gorm.DB, batch int) error { return fun(ctx, p.ToBos(results)) })