diff --git a/pkg/service/cast/report.go b/pkg/service/cast/report.go index d716d09..6ccdc06 100644 --- a/pkg/service/cast/report.go +++ b/pkg/service/cast/report.go @@ -402,20 +402,6 @@ func UpdateCompetitiveReportStatus(ctx *gin.Context) { userInfo := login.GetUserInfoFromC(ctx) newCtx := NewCtxWithUserInfo(ctx) - // 获取竞品报告详情 - resp, err := service.CastProvider.GetCompetitiveReport(context.Background(), &cast.GetCompetitiveReportDetailReq{ - Uuid: req.Uuid, - }) - if err != nil { - service.Error(ctx, err) - return - } - artistID, _ := strconv.ParseUint(resp.ArtistID, 10, 64) - if artistID != uint64(userInfo.ID) { - service.Error(ctx, errors.New("非本人竞品报告,无法操作")) - return - } - // 判断 work_action 是否为 1(确认)或 6(阅读) if req.WorkAction != 1 && req.WorkAction != 6 { service.Error(ctx, errors.New("非法操作")) @@ -430,6 +416,28 @@ func UpdateCompetitiveReportStatus(ctx *gin.Context) { } } + // 只有当 WorkAction = 1 或 6 时,才获取竞品报告详情并验证权限 + var resp *cast.GetCompetitiveReportDetailResp + if req.WorkAction == 1 || req.WorkAction == 6 { + var err error + resp, err = service.CastProvider.GetCompetitiveReport(context.Background(), &cast.GetCompetitiveReportDetailReq{ + Uuid: req.Uuid, + }) + if err != nil { + service.Error(ctx, err) + return + } + if resp == nil { + service.Error(ctx, errors.New("竞品报告不存在")) + return + } + artistID, _ := strconv.ParseUint(resp.ArtistID, 10, 64) + if artistID != uint64(userInfo.ID) { + service.Error(ctx, errors.New("非本人竞品报告,无法操作")) + return + } + } + // 当 WorkAction == 1(确认)且 ConfirmStatus == 1(通过)时,需要检查并扣减余额 if req.WorkAction == 1 && req.ConfirmStatus == 1 { // 检查竞品报告状态是否为待确认(状态4)