diff --git a/api/proto/zone/proto/zone_op.go b/api/proto/zone/proto/zone_op.go index baafd0a1..f826906b 100644 --- a/api/proto/zone/proto/zone_op.go +++ b/api/proto/zone/proto/zone_op.go @@ -37,6 +37,12 @@ type OpDeleteResp struct { type OpUpdateReq struct { base.BaseRequest *dbstruct.Zone + AdmissionPrice int64 `json:"admission_price"` // 空间解锁价格, 单位: 分 + IronfanshipPrice int64 `json:"ironfanship_price"` // 铁粉解锁价格, 单位: 分 + IsSuperfanshipEnabled int `json:"is_superfanship_enabled"` // 是否开启超粉空间 0: 关闭, 1: 开启 + SuperfanshipPrice int64 `json:"superfanship_price"` // 超粉价格, 单位: 分 + SuperfanshipValidPeriod int `json:"superfanship_valid_period"` // 超粉有效期类型, SuperfanshipValidPeriod* + IsSuperfanshipGiveWechat int `json:"is_superfanship_give_wechat"` // 是否开启超粉空间赠送微信 0: 不赠送, 1: 赠送 } type OpUpdateData struct { diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go index 4e45744b..895fd9f0 100644 --- a/app/mix/service/apiservice.go +++ b/app/mix/service/apiservice.go @@ -2654,38 +2654,25 @@ func (s *Service) ApiDeleteZoneMoment(ctx *gin.Context, req *zonemomentproto.Api } // 查看空间最后更新时间是否需要回退 - list, err := _DefaultZoneMoment.OpListByMid(ctx, &zonemomentproto.OpListByMidReq{ - BaseRequest: req.BaseRequest, - Limit: 1, - Sort: []string{"-ut"}, - }) - if err != nil { - logger.Error("OpListByMid fail, err: %v", err) - ec = errcode.ErrCodeZoneMomentSrvFail - return - } - - // 已经没有动态,最后更新时间回退到0 - if len(list) == 0 { - err = _DefaultZone.OpUpdateByIdAndLastZoneMomentCt(ctx, &zoneproto.OpUpdateReq{ - Zone: &dbstruct.Zone{ - Id: goproto.Int64(zid), - LastZoneMomentCt: goproto.Int64(0), - }, - }, zone.GetLastZoneMomentCt()) + if zonemoment.GetStatus() == consts.ZoneMoment_Public { + list, err := _DefaultZoneMoment.OpListByMid(ctx, &zonemomentproto.OpListByMidReq{ + BaseRequest: req.BaseRequest, + Status: goproto.Int64(consts.ZoneMoment_Public), + Limit: 1, + Sort: []string{"-ut"}, + }) if err != nil { - logger.Error("OpUpdate fail, err: %v", err) + logger.Error("OpListByMid fail, err: %v", err) ec = errcode.ErrCodeZoneMomentSrvFail return } - } else { - //还有动态,看最后一条更新的动态的更新时间是否比删除的那条动态更早,若更早,则需要把空间的更新时间回拨 - lastzonemoment := list[0] - if lastzonemoment.GetUt() < zonemoment.GetUt() { + + // 已经没有动态,最后更新时间回退到0 + if len(list) == 0 { err = _DefaultZone.OpUpdateByIdAndLastZoneMomentCt(ctx, &zoneproto.OpUpdateReq{ Zone: &dbstruct.Zone{ Id: goproto.Int64(zid), - LastZoneMomentCt: lastzonemoment.Ut, + LastZoneMomentCt: goproto.Int64(0), }, }, zone.GetLastZoneMomentCt()) if err != nil { @@ -2693,6 +2680,22 @@ func (s *Service) ApiDeleteZoneMoment(ctx *gin.Context, req *zonemomentproto.Api ec = errcode.ErrCodeZoneMomentSrvFail return } + } else { + //还有动态,看最后一条更新的动态的更新时间是否比删除的那条动态更早,若更早,则需要把空间的更新时间回拨 + lastzonemoment := list[0] + if lastzonemoment.GetUt() < zonemoment.GetUt() { + err = _DefaultZone.OpUpdateByIdAndLastZoneMomentCt(ctx, &zoneproto.OpUpdateReq{ + Zone: &dbstruct.Zone{ + Id: goproto.Int64(zid), + LastZoneMomentCt: lastzonemoment.Ut, + }, + }, zone.GetLastZoneMomentCt()) + if err != nil { + logger.Error("OpUpdate fail, err: %v", err) + ec = errcode.ErrCodeZoneMomentSrvFail + return + } + } } } diff --git a/app/mix/service/logic/zone.go b/app/mix/service/logic/zone.go index 302e27f4..e78037ce 100644 --- a/app/mix/service/logic/zone.go +++ b/app/mix/service/logic/zone.go @@ -37,6 +37,7 @@ func (p *Zone) OpCreate(ctx *gin.Context, req *zoneproto.OpCreateReq) (error, in req.Zone.Ct = goproto.Int64(time.Now().Unix()) req.Zone.Ut = goproto.Int64(time.Now().Unix()) req.Zone.DelFlag = goproto.Int64(consts.Exist) + req.Zone.LastZoneMomentCt = goproto.Int64(0) err = p.store.CreateZone(ctx, req.Zone) if err != nil { logger.Error("CreateZone fail, err: %v", err) diff --git a/app/mix/service/service.go b/app/mix/service/service.go index a0f28e5a..7406a0a7 100644 --- a/app/mix/service/service.go +++ b/app/mix/service/service.go @@ -3181,6 +3181,26 @@ func (s *Service) OpUpdateZone(ctx *gin.Context, req *zoneproto.OpUpdateReq) (ec ec = errcode.ErrCodeZoneSrvFail return } + + err = _DefaultVas.UpdateZoneVasInfo(ctx, &vasproto.UpdateZoneVasReq{ + ZoneVas: &dbstruct.ZoneVas{ + Zid: *req.Zone.Id, + Mid: req.BaseRequest.Mid, + Ct: time.Now().Unix(), + Ut: time.Now().Unix(), + AdmissionPrice: req.AdmissionPrice, + IronfanshipPrice: req.IronfanshipPrice, + IsSuperfanshipEnabled: req.IsSuperfanshipEnabled, + SuperfanshipPrice: req.SuperfanshipPrice, + SuperfanshipValidPeriod: req.SuperfanshipValidPeriod, + IsSuperfanshipGiveWechat: req.IsSuperfanshipGiveWechat, + }, + }) + if err != nil { + logger.Error("UpdateZoneVasInfo fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeZoneSrvFail + return + } return } @@ -3397,38 +3417,25 @@ func (s *Service) OpDeleteZoneMoment(ctx *gin.Context, req *zonemomentproto.OpDe } // 查看空间最后更新时间是否需要回退 - list, err := _DefaultZoneMoment.OpListByMid(ctx, &zonemomentproto.OpListByMidReq{ - BaseRequest: req.BaseRequest, - Limit: 1, - Sort: []string{"-ut"}, - }) - if err != nil { - logger.Error("OpListByMid fail, err: %v", err) - ec = errcode.ErrCodeZoneMomentSrvFail - return - } - - // 已经没有动态,最后更新时间回退到0 - if len(list) == 0 { - err = _DefaultZone.OpUpdateByIdAndLastZoneMomentCt(ctx, &zoneproto.OpUpdateReq{ - Zone: &dbstruct.Zone{ - Id: goproto.Int64(zid), - LastZoneMomentCt: goproto.Int64(0), - }, - }, zone.GetLastZoneMomentCt()) + if zonemoment.GetStatus() == consts.ZoneMoment_Public { + list, err := _DefaultZoneMoment.OpListByMid(ctx, &zonemomentproto.OpListByMidReq{ + BaseRequest: req.BaseRequest, + Status: goproto.Int64(consts.ZoneMoment_Public), + Limit: 1, + Sort: []string{"-ut"}, + }) if err != nil { - logger.Error("OpUpdate fail, err: %v", err) + logger.Error("OpListByMid fail, err: %v", err) ec = errcode.ErrCodeZoneMomentSrvFail return } - } else { - //还有动态,看最后一条更新的动态的更新时间是否比删除的那条动态更早,若更早,则需要把空间的更新时间回拨 - lastzonemoment := list[0] - if lastzonemoment.GetUt() < zonemoment.GetUt() { + + // 已经没有动态,最后更新时间回退到0 + if len(list) == 0 { err = _DefaultZone.OpUpdateByIdAndLastZoneMomentCt(ctx, &zoneproto.OpUpdateReq{ Zone: &dbstruct.Zone{ Id: goproto.Int64(zid), - LastZoneMomentCt: lastzonemoment.Ut, + LastZoneMomentCt: goproto.Int64(0), }, }, zone.GetLastZoneMomentCt()) if err != nil { @@ -3436,6 +3443,22 @@ func (s *Service) OpDeleteZoneMoment(ctx *gin.Context, req *zonemomentproto.OpDe ec = errcode.ErrCodeZoneMomentSrvFail return } + } else { + //还有动态,看最后一条更新的动态的更新时间是否比删除的那条动态更早,若更早,则需要把空间的更新时间回拨 + lastzonemoment := list[0] + if lastzonemoment.GetUt() < zonemoment.GetUt() { + err = _DefaultZone.OpUpdateByIdAndLastZoneMomentCt(ctx, &zoneproto.OpUpdateReq{ + Zone: &dbstruct.Zone{ + Id: goproto.Int64(zid), + LastZoneMomentCt: lastzonemoment.Ut, + }, + }, zone.GetLastZoneMomentCt()) + if err != nil { + logger.Error("OpUpdate fail, err: %v", err) + ec = errcode.ErrCodeZoneMomentSrvFail + return + } + } } }