diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go index 895fd9f0..12ab027c 100644 --- a/app/mix/service/apiservice.go +++ b/app/mix/service/apiservice.go @@ -2653,6 +2653,26 @@ func (s *Service) ApiDeleteZoneMoment(ctx *gin.Context, req *zonemomentproto.Api return } + // 回退空间内统计总数,只回退公开的情况 + if zonemoment.GetStatus() == consts.ZoneMoment_Public { + mediaCountInc := len(zonemoment.MediaComp.GetImageIds()) + videoCountInc := len(zonemoment.MediaComp.GetVideoIds()) + err = _DefaultZone.RecordStatisticsById(ctx, zonemoment.GetZid(), -1, -int64(mediaCountInc), -int64(videoCountInc)) + if err != nil { + logger.Error("RecordStatisticsById fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeZoneSrvFail + return + } + } + + // 回退每日发帖次数 + totalIncr := int64(-1) + _, err = _DefaultZoneMomentCreateTimes.OpGetAndUpdate(ctx, zone.GetMid(), totalIncr) + if err != nil { + logger.Error("OpGetAndUpdate fail, err: %v", err) + ec = errcode.ErrCodeZoneMomentSrvFail + } + // 查看空间最后更新时间是否需要回退 if zonemoment.GetStatus() == consts.ZoneMoment_Public { list, err := _DefaultZoneMoment.OpListByMid(ctx, &zonemomentproto.OpListByMidReq{ @@ -2699,26 +2719,6 @@ func (s *Service) ApiDeleteZoneMoment(ctx *gin.Context, req *zonemomentproto.Api } } - // 回退空间内统计总数,只回退公开的情况 - if zonemoment.GetStatus() == consts.ZoneMoment_Public { - mediaCountInc := len(zonemoment.MediaComp.GetImageIds()) - videoCountInc := len(zonemoment.MediaComp.GetVideoIds()) - err = _DefaultZone.RecordStatisticsById(ctx, zonemoment.GetZid(), -1, -int64(mediaCountInc), -int64(videoCountInc)) - if err != nil { - logger.Error("RecordStatisticsById fail, req: %v, err: %v", util.ToJson(req), err) - ec = errcode.ErrCodeZoneSrvFail - return - } - } - - // 回退每日发帖次数 - totalIncr := int64(-1) - _, err = _DefaultZoneMomentCreateTimes.OpGetAndUpdate(ctx, zone.GetMid(), totalIncr) - if err != nil { - logger.Error("OpGetAndUpdate fail, err: %v", err) - ec = errcode.ErrCodeZoneMomentSrvFail - } - return } diff --git a/app/mix/service/service.go b/app/mix/service/service.go index f99428a9..43498ee0 100644 --- a/app/mix/service/service.go +++ b/app/mix/service/service.go @@ -3416,6 +3416,18 @@ func (s *Service) OpDeleteZoneMoment(ctx *gin.Context, req *zonemomentproto.OpDe return } + // 回退空间内统计总数,只回退公开的情况 + if zonemoment.GetStatus() == consts.ZoneMoment_Public { + mediaCountInc := len(zonemoment.MediaComp.GetImageIds()) + videoCountInc := len(zonemoment.MediaComp.GetVideoIds()) + err = _DefaultZone.RecordStatisticsById(ctx, zonemoment.GetZid(), -1, -int64(mediaCountInc), -int64(videoCountInc)) + if err != nil { + logger.Error("RecordStatisticsById fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeZoneSrvFail + return + } + } + // 查看空间最后更新时间是否需要回退 if zonemoment.GetStatus() == consts.ZoneMoment_Public { list, err := _DefaultZoneMoment.OpListByMid(ctx, &zonemomentproto.OpListByMidReq{ @@ -3462,18 +3474,6 @@ func (s *Service) OpDeleteZoneMoment(ctx *gin.Context, req *zonemomentproto.OpDe } } - // 回退空间内统计总数,只回退公开的情况 - if zonemoment.GetStatus() == consts.ZoneMoment_Public { - mediaCountInc := len(zonemoment.MediaComp.GetImageIds()) - videoCountInc := len(zonemoment.MediaComp.GetVideoIds()) - err = _DefaultZone.RecordStatisticsById(ctx, zonemoment.GetZid(), -1, -int64(mediaCountInc), -int64(videoCountInc)) - if err != nil { - logger.Error("RecordStatisticsById fail, req: %v, err: %v", util.ToJson(req), err) - ec = errcode.ErrCodeZoneSrvFail - return - } - } - return }