修复(#143): 邀请权益查询排序 inviteeAndInviterIds 消除 map 迭代序 flake
inviteeAndInviterSet 是 map,按 range 收集到 slice 后顺序不固定, 传给 fillGiftBenefits 的 IN (?,?) 参数随之乱序,导致 sqlmock 按位置 匹配的单测 TestQueryBenefitsKeepsDirectInviteeGift 偶现失败(本地 10 次复现约 2-4 次)。 在收集后追加 slices.Sort,让生产代码本身的下游 SQL 参数稳定;同步把 测试期望改为升序。50 次重复 + race 全绿。 Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -2,6 +2,7 @@ package invite
|
||||
|
||||
import (
|
||||
"context"
|
||||
"slices"
|
||||
|
||||
modellog "github.com/perfect-panel/server/internal/model/log"
|
||||
"github.com/perfect-panel/server/pkg/xerr"
|
||||
@@ -113,6 +114,7 @@ func QueryBenefits(ctx context.Context, db *gorm.DB, relations []InviteRelation)
|
||||
for userId := range inviteeAndInviterSet {
|
||||
inviteeAndInviterIds = append(inviteeAndInviterIds, userId)
|
||||
}
|
||||
slices.Sort(inviteeAndInviterIds)
|
||||
|
||||
if err := fillCommissionBenefits(ctx, db, result, orderToInvitee, inviteeToInviter, orderNos, inviterIds); err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user