From da6d60020cc1383b3a55dfb23bae3f689305f9f0 Mon Sep 17 00:00:00 2001 From: Leufolium Date: Tue, 16 Apr 2024 07:41:52 +0800 Subject: [PATCH] by Robin at 20240416 --- api/errcode/errcode.go | 2 + api/proto/zone/proto/zone_vo_api.go | 10 + ...{moment_vo_api.go => zonemoment_vo_api.go} | 0 .../zonesession/proto/not_null_def_api.go | 13 + .../zonesession/proto/zonesession_api.go | 10 +- api/proto/zonesession/proto/zonesession_op.go | 7 +- app/mix/controller/init.go | 2 +- app/mix/controller/zone_session_api.go | 8 +- app/mix/dao/mongo.go | 5 +- app/mix/dao/mysql_zone.go | 24 +- app/mix/service/apiservice.go | 245 ++++++------------ .../service/apiservice_business_validation.go | 2 +- app/mix/service/logic/vas_zone.go | 28 +- app/mix/service/logic/zone_collaborator.go | 2 +- app/mix/service/logic/zonesession.go | 5 +- app/mix/service/utilservice.go | 174 +++++++++++-- dbstruct/vas_mysql.go | 9 + dbstruct/zone.go | 14 + dbstruct/zonemoment.go | 28 ++ dbstruct/zonesession.go | 7 + 20 files changed, 383 insertions(+), 212 deletions(-) rename api/proto/zonemoment/proto/{moment_vo_api.go => zonemoment_vo_api.go} (100%) create mode 100644 api/proto/zonesession/proto/not_null_def_api.go diff --git a/api/errcode/errcode.go b/api/errcode/errcode.go index 97ee5cd3..11174813 100644 --- a/api/errcode/errcode.go +++ b/api/errcode/errcode.go @@ -172,6 +172,7 @@ var ErrCodeMsgMap = map[ErrCode]string{ ErrCodeZoneSrvFail: "空间服务错误", ErrCodeZoneNotExist: "空间不存在", + ErrCodeUnlockedZone: "访客未解锁该空间", ErrCodeZoneMomentSrvFail: "私密圈动态服务错误", ErrCodeZoneMomentNotExist: "私密圈动态不存在", @@ -437,6 +438,7 @@ const ( ErrCodeZoneSrvOk ErrCode = ErrCodeOk ErrCodeZoneSrvFail ErrCode = -33001 // 空间服务错误 ErrCodeZoneNotExist ErrCode = -33002 // 空间不存在 + ErrCodeUnlockedZone ErrCode = -33003 // 未解锁的空间 // ZoneMoment: 34xxx ErrCodeZoneMomentSrvOk ErrCode = ErrCodeOk diff --git a/api/proto/zone/proto/zone_vo_api.go b/api/proto/zone/proto/zone_vo_api.go index 8ce52c34..70e3c50a 100644 --- a/api/proto/zone/proto/zone_vo_api.go +++ b/api/proto/zone/proto/zone_vo_api.go @@ -13,6 +13,8 @@ type ApiZoneVO struct { VisitorRole int64 `json:"visitor_role"` Previews *dbstruct.MediaComponent `json:"previews"` Expenditure int64 `json:"expenditure"` + IsIronfanshipUnlocked int64 `json:"is_ironfanship_unlocked"` + IsSuperfanshipUnlocked int64 `json:"is_superfanship_unlocked"` } func (vo *ApiZoneVO) GetMid() int64 { @@ -35,3 +37,11 @@ func (vo *ApiZoneVO) CopyStreamerExt(streamerExt streamerproto.StreamerExtVO) { } } } + +func (vo *ApiZoneVO) SetIsIronfanshipUnlocked(is_ironfanship_unlocked int64) { + vo.IsIronfanshipUnlocked = is_ironfanship_unlocked +} + +func (vo *ApiZoneVO) SetIsSuperfanshipUnlocked(is_superfanship_unlocked int64) { + vo.IsSuperfanshipUnlocked = is_superfanship_unlocked +} diff --git a/api/proto/zonemoment/proto/moment_vo_api.go b/api/proto/zonemoment/proto/zonemoment_vo_api.go similarity index 100% rename from api/proto/zonemoment/proto/moment_vo_api.go rename to api/proto/zonemoment/proto/zonemoment_vo_api.go diff --git a/api/proto/zonesession/proto/not_null_def_api.go b/api/proto/zonesession/proto/not_null_def_api.go new file mode 100644 index 00000000..7a086fa6 --- /dev/null +++ b/api/proto/zonesession/proto/not_null_def_api.go @@ -0,0 +1,13 @@ +package proto + +import ( + "service/library/validator" +) + +func (p *ApiUpsertReq) ProvideNotNullValue() (params []*validator.JsonParam) { + params = make([]*validator.JsonParam, 0) + + params = append(params, validator.NewInt64PtrParam("请确认创建动态的所属空间id!", p.Zid)) + + return +} diff --git a/api/proto/zonesession/proto/zonesession_api.go b/api/proto/zonesession/proto/zonesession_api.go index 0f39e384..da5bac40 100644 --- a/api/proto/zonesession/proto/zonesession_api.go +++ b/api/proto/zonesession/proto/zonesession_api.go @@ -5,15 +5,15 @@ import ( ) // op 更新 -type ApiUpdateReq struct { +type ApiUpsertReq struct { base.BaseRequest - Zid int64 `json:"zid"` + Zid *int64 `json:"zid"` } -type ApiUpdateData struct { +type ApiUpsertData struct { } -type ApiUpdateResp struct { +type ApiUpsertResp struct { base.BaseResponse - Data *ApiUpdateData `json:"data"` + Data *ApiUpsertData `json:"data"` } diff --git a/api/proto/zonesession/proto/zonesession_op.go b/api/proto/zonesession/proto/zonesession_op.go index 51e3d43a..aeb6cb24 100644 --- a/api/proto/zonesession/proto/zonesession_op.go +++ b/api/proto/zonesession/proto/zonesession_op.go @@ -50,9 +50,10 @@ type OpUpdateResp struct { // op 列表 type OpListReq struct { base.BaseRequest - Mid int64 `json:"mid"` - Offset int `json:"offset"` - Limit int `json:"limit"` + Mid int64 `json:"mid"` + Zids []int64 `json:"zids"` + Offset int `json:"offset"` + Limit int `json:"limit"` } type OpListData struct { diff --git a/app/mix/controller/init.go b/app/mix/controller/init.go index d9d4f7d7..4e8e0307 100644 --- a/app/mix/controller/init.go +++ b/app/mix/controller/init.go @@ -238,7 +238,7 @@ func Init(r *gin.Engine) { // 空间对话 apiZoneSessionGroup := r.Group("/api/zone_session", PrepareToC()) - apiZoneSessionGroup.POST("update", middleware.JSONParamValidator(zonesessionproto.ApiUpdateReq{}), middleware.JwtAuthenticator(), ApiUpdateZoneSession) + apiZoneSessionGroup.POST("upsert", middleware.JSONParamValidator(zonesessionproto.ApiUpsertReq{}), middleware.JwtAuthenticator(), ApiUpsertZoneSession) // 空间代运营表 apiZoneThirdPartnerGroup := r.Group("/api/zone_third_partner", PrepareToC()) diff --git a/app/mix/controller/zone_session_api.go b/app/mix/controller/zone_session_api.go index 90a1dec7..e6389637 100644 --- a/app/mix/controller/zone_session_api.go +++ b/app/mix/controller/zone_session_api.go @@ -10,11 +10,11 @@ import ( "github.com/gin-gonic/gin" ) -func ApiUpdateZoneSession(ctx *gin.Context) { - req := ctx.MustGet("client_req").(*zonesessionproto.ApiUpdateReq) - ec := service.DefaultService.ApiUpdateZoneSession(ctx, req) +func ApiUpsertZoneSession(ctx *gin.Context) { + req := ctx.MustGet("client_req").(*zonesessionproto.ApiUpsertReq) + ec := service.DefaultService.ApiUpsertZoneSession(ctx, req) if ec != errcode.ErrCodeZoneSessionSrvOk { - logger.Error("ApiUpdateZoneSession fail, req: %v, ec: %v", util.ToJson(req), ec) + logger.Error("ApiUpsertZoneSession fail, req: %v, ec: %v", util.ToJson(req), ec) ReplyErrCodeMsg(ctx, ec) return } diff --git a/app/mix/dao/mongo.go b/app/mix/dao/mongo.go index 901b7d7a..09c8bd82 100644 --- a/app/mix/dao/mongo.go +++ b/app/mix/dao/mongo.go @@ -4458,7 +4458,10 @@ func (m *Mongo) GetZoneSessionList(ctx *gin.Context, req *zonesessionproto.OpLis list := make([]*dbstruct.ZoneSession, 0) col := m.getColZoneSession() query := qmgo.M{ - "sub_mid": req.Mid, + "sub_mid": req.Mid, + "obj_zid": qmgo.M{ + "$in": req.Zids, + }, "del_flag": 0, } err := col.Find(ctx, query).Sort("-ct").Skip(int64(req.Offset)).Limit(int64(req.Limit)).All(&list) diff --git a/app/mix/dao/mysql_zone.go b/app/mix/dao/mysql_zone.go index 4c1dae9d..7643a207 100644 --- a/app/mix/dao/mysql_zone.go +++ b/app/mix/dao/mysql_zone.go @@ -3,12 +3,13 @@ package dao import ( "database/sql" "fmt" - "github.com/gin-gonic/gin" - "github.com/jmoiron/sqlx" "service/bizcommon/util" "service/dbstruct" "service/library/logger" "time" + + "github.com/gin-gonic/gin" + "github.com/jmoiron/sqlx" ) // 获取空间解锁信息 @@ -27,6 +28,25 @@ func (m *Mysql) GetZoneUnlock(ctx *gin.Context, tx *sqlx.Tx, mid, zid int64) (zu return } +// 获取空间解锁信息 by mid +func (m *Mysql) GetZoneUnlockListByMid(ctx *gin.Context, tx *sqlx.Tx, mid int64) (list []*dbstruct.ZoneUnlock, err error) { + list = make([]*dbstruct.ZoneUnlock, 0) + if tx != nil { + err = tx.SelectContext(ctx, &list, fmt.Sprintf("select * from %s where mid=?", TableVasZoneUnlock), mid) + } else { + db := m.getDBVas() + err = db.SelectContext(ctx, &list, fmt.Sprintf("select * from %s where mid=?", TableVasZoneUnlock), mid) + } + if err == sql.ErrNoRows { + err = nil + return + } + if err != nil { + return + } + return +} + // 获取空间解锁信息 by zid func (m *Mysql) GetZoneUnlockListByZid(ctx *gin.Context, tx *sqlx.Tx, zid int64) (list []*dbstruct.ZoneUnlock, err error) { list = make([]*dbstruct.ZoneUnlock, 0) diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go index aedd4c38..dfd9db92 100644 --- a/app/mix/service/apiservice.go +++ b/app/mix/service/apiservice.go @@ -2213,10 +2213,19 @@ func (s *Service) ApiGetZoneList(ctx *gin.Context, req *zoneproto.ApiListReq) (l func (s *Service) ApiGetZoneListByMid(ctx *gin.Context, req *zoneproto.ApiListByMidReq) (volist []*zoneproto.ApiZoneVO, ec errcode.ErrCode) { ec = errcode.ErrCodeZoneSrvOk + // 若uid为空,则判断为主播查自己的空间 if req.Uid == nil { req.Uid = goproto.Int64(req.BaseRequest.Mid) } + // 查询该用户解锁的空间 + zidZuMap, err := _DefaultVas.GetZoneUnlockMapByMid(ctx, req.BaseRequest.Mid) + if err != nil { + logger.Error("GetZoneUnlockMapByMid fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeZoneSrvFail + return + } + list, err := _DefaultZone.OpListByMid(ctx, &zoneproto.OpListByMidReq{ BaseRequest: req.BaseRequest, Uid: req.Uid, @@ -2230,7 +2239,7 @@ func (s *Service) ApiGetZoneListByMid(ctx *gin.Context, req *zoneproto.ApiListBy } // 填充必要信息 - volist, err = s.utilFillZonesWithApiVOInfo(ctx, list, req.BaseRequest.Mid) + volist, err = s.utilFillZonesWithApiVOInfo(ctx, list, req.BaseRequest.Mid, zidZuMap) if err != nil { logger.Error("utilFillZonesWithApiVOInfo fail, req: %v, err: %v", util.ToJson(req), err) ec = errcode.ErrCodeZoneSrvFail @@ -2243,8 +2252,17 @@ func (s *Service) ApiGetZoneListByMid(ctx *gin.Context, req *zoneproto.ApiListBy func (s *Service) ApiGetZoneListByVisitorMid(ctx *gin.Context, req *zoneproto.ApiListByVisitorMidReq) (volist []*zoneproto.ApiZoneVO, ec errcode.ErrCode) { ec = errcode.ErrCodeZoneSrvOk + // 查询该用户解锁的空间 + zidZuMap, err := _DefaultVas.GetZoneUnlockMapByMid(ctx, req.BaseRequest.Mid) + if err != nil { + logger.Error("GetZoneUnlockMapByMid fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeZoneSrvFail + return + } zids := make([]int64, 0) - zids = append(zids, 1) + for _, zidZu := range zidZuMap { + zids = append(zids, zidZu.GetZid()) + } list, err := _DefaultZone.OpListByZids(ctx, zids) if err != nil { @@ -2254,7 +2272,7 @@ func (s *Service) ApiGetZoneListByVisitorMid(ctx *gin.Context, req *zoneproto.Ap } // 填充必要信息 - volist, err = s.utilFillZonesWithApiVOInfo(ctx, list, req.BaseRequest.Mid) + volist, err = s.utilFillZonesWithApiVOInfo(ctx, list, req.BaseRequest.Mid, zidZuMap) if err != nil { logger.Error("utilFillZonesWithApiVOInfo fail, req: %v, err: %v", util.ToJson(req), err) ec = errcode.ErrCodeZoneSrvFail @@ -2381,7 +2399,7 @@ func (s *Service) ApiCreateZoneMoment(ctx *gin.Context, req *zonemomentproto.Api textaudit.AddTasks(textaudittasks) // 设置价格 - if util.DerefInt64(req.ZoneMoment.CType) == consts.ZoneMomentCType_Paid { + if req.ZoneMoment.GetCType() == consts.ZoneMomentCType_Paid { err = _DefaultVas.UpdateZoneMomentPrice(ctx, &vasproto.UpdateZoneMomentPriceReq{ ZoneMomentPrice: &dbstruct.ZoneMomentPrice{ MomentId: momentId, @@ -2403,7 +2421,7 @@ func (s *Service) ApiCreateZoneMoment(ctx *gin.Context, req *zonemomentproto.Api func (s *Service) ApiUpdateZoneMoment(ctx *gin.Context, req *zonemomentproto.ApiUpdateReq) (ec errcode.ErrCode) { ec = errcode.ErrCodeZoneMomentSrvOk - zonemoment, err := _DefaultZoneMoment.GetById(ctx, util.DerefInt64(req.Id)) + zonemoment, err := _DefaultZoneMoment.GetById(ctx, req.ZoneMoment.GetId()) if err != nil { logger.Error("_DefaultZoneMoment GetById fail, req: %v, err: %v", util.ToJson(req), err) ec = errcode.ErrCodeZoneMomentSrvFail @@ -2416,13 +2434,13 @@ func (s *Service) ApiUpdateZoneMoment(ctx *gin.Context, req *zonemomentproto.Api // 抹消审核信息,回退到初始 isReauditRequired := false - if req.ZoneMoment.MediaComp != nil && util.DerefInt64(req.ZoneMoment.MType) == consts.MediaTypeImg { + if req.ZoneMoment.MediaComp != nil && req.ZoneMoment.GetMType() == consts.MediaTypeImg { isReauditRequired = true req.ZoneMoment.ImageAuditStatus = goproto.Int64(consts.ImageAudit_Created) // 创建 req.ZoneMoment.ImageAuditOpinion = goproto.String("") // 信息抹除 req.ZoneMoment.MediaAmount = goproto.Int64(int64(len(req.ZoneMoment.MediaComp.GetImageIds()))) } - if req.ZoneMoment.MediaComp != nil && util.DerefInt64(req.ZoneMoment.MType) == consts.MediaTypeVideo { + if req.ZoneMoment.MediaComp != nil && req.ZoneMoment.GetMType() == consts.MediaTypeVideo { req.ZoneMoment.MediaAmount = goproto.Int64(int64(len(req.ZoneMoment.MediaComp.GetVideoIds()))) } if req.ZoneMoment.Text != nil { @@ -2457,7 +2475,7 @@ func (s *Service) ApiUpdateZoneMoment(ctx *gin.Context, req *zonemomentproto.Api if isReauditRequired { mediaCountInc := len(zonemoment.MediaComp.GetImageIds()) videoCountInc := len(zonemoment.MediaComp.GetVideoIds()) - err := _DefaultZone.RecordStatisticsById(ctx, util.DerefInt64(zonemoment.Zid), -1, -int64(mediaCountInc), -int64(videoCountInc)) + 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 @@ -2484,7 +2502,7 @@ func (s *Service) ApiDeleteZoneMoment(ctx *gin.Context, req *zonemomentproto.Api ec = errcode.ErrCodeZoneSrvFail return } - zid := util.DerefInt64(zonemoment.Zid) + zid := zonemoment.GetZid() zone, err := _DefaultZone.GetById(ctx, zid) if err != nil { logger.Error("_DefaultZone GetById fail, err: %v", err) @@ -2518,7 +2536,7 @@ func (s *Service) ApiDeleteZoneMoment(ctx *gin.Context, req *zonemomentproto.Api Id: goproto.Int64(zid), LastZoneMomentCt: goproto.Int64(0), }, - }, util.DerefInt64(zone.LastZoneMomentCt)) + }, zone.GetLastZoneMomentCt()) if err != nil { logger.Error("OpUpdate fail, err: %v", err) ec = errcode.ErrCodeZoneMomentSrvFail @@ -2527,13 +2545,13 @@ func (s *Service) ApiDeleteZoneMoment(ctx *gin.Context, req *zonemomentproto.Api } else { //还有动态,看最后一条更新的动态的更新时间是否比删除的那条动态更早,若更早,则需要把空间的更新时间回拨 lastzonemoment := list[0] - if util.DerefInt64(lastzonemoment.Ut) < util.DerefInt64(zonemoment.Ut) { + if lastzonemoment.GetUt() < zonemoment.GetUt() { err = _DefaultZone.OpUpdateByIdAndLastZoneMomentCt(ctx, &zoneproto.OpUpdateReq{ Zone: &dbstruct.Zone{ Id: goproto.Int64(zid), LastZoneMomentCt: lastzonemoment.Ut, }, - }, util.DerefInt64(zone.LastZoneMomentCt)) + }, zone.GetLastZoneMomentCt()) if err != nil { logger.Error("OpUpdate fail, err: %v", err) ec = errcode.ErrCodeZoneMomentSrvFail @@ -2548,11 +2566,17 @@ func (s *Service) ApiDeleteZoneMoment(ctx *gin.Context, req *zonemomentproto.Api func (s *Service) ApiGetZoneMomentListByVisitorMid(ctx *gin.Context, req *zonemomentproto.ApiListByVisitorMidReq) (volist []*zonemomentproto.ApiZoneMomentVO, ec errcode.ErrCode) { ec = errcode.ErrCodeZoneMomentSrvOk - // 1.查询访客关注的空间 + // 1.查询该用户解锁的空间 + zidZuMap, err := _DefaultVas.GetZoneUnlockMapByMid(ctx, req.BaseRequest.Mid) + if err != nil { + logger.Error("GetZoneUnlockMapByMid fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeZoneSrvFail + return + } zids := make([]int64, 0) - zids = append(zids, 1) - zids = append(zids, 2) - zids = append(zids, 3) + for _, zidZu := range zidZuMap { + zids = append(zids, zidZu.GetZid()) + } // 2.根据关注的zids查询得到这一轮的动态基底 list, err := _DefaultZoneMoment.OpListByZids(ctx, &zonemomentproto.OpListByZidsReq{ @@ -2570,96 +2594,28 @@ func (s *Service) ApiGetZoneMomentListByVisitorMid(ctx *gin.Context, req *zonemo } // 3.填充信息 - volist = make([]*zonemomentproto.ApiZoneMomentVO, 0) - midSet := make(map[int64]*dbstruct.Moment) - mids := make([]int64, 0) - for _, zonemoment := range list { - vo := &zonemomentproto.ApiZoneMomentVO{ - ZoneMoment: zonemoment, - } - volist = append(volist, vo) - mid := zonemoment.GetMid() - if midSet[mid] == nil { - midSet[mid] = &dbstruct.Moment{} - mids = append(mids, mid) - } - } - - // 4.通过mids获取主播信息map - ignoreMap := make(map[string]bool) - ignoreMap["zones"] = true - streamerExtMap, err := s.utilGetStreamerExtMapByMids(ctx, mids, consts.InterfaceType_Api, ignoreMap) + volist, err = s.utilFillZoneMomentsWithApiVOInfo(ctx, list, req.BaseRequest.Mid, zidZuMap) if err != nil { - logger.Error("utilGetStreamerExtMapByMids fail, req: %v, err: %v", util.ToJson(req), err) - ec = errcode.ErrCodeStreamerSrvFail + logger.Error("utilFillZoneMomentsWithApiVOInfo fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeZoneMomentSrvFail return } - // 5.获取访客已解锁的铁粉资格 - unlockedIronfanshipMap := make(map[int64]*int64, 0) - - // 6.获取访客已解锁的超粉资格 - unlockedSuperfanshipMap := make(map[int64]*int64, 0) - - // 7.获取访客创建的空间 - zoneMap, err := _DefaultZone.GetZoneMapByMids(ctx, []int64{req.BaseRequest.Mid}) - if err != nil { - logger.Error("_DefaultZone GetZoneMapByMids fail, req: %v, err: %v", err) - return - } - zones := zoneMap[req.BaseRequest.Mid] - zoneZidMap := make(map[int64]*dbstruct.Zone, 0) - for _, zone := range zones { - zoneZidMap[util.DerefInt64(zone.Id)] = zone - } - - // 获取动态的一些静态数据信息 - momentIds := make([]int64, 0) - zmStatMap, _ := _DefaultVas.GetZoneMomentStatByIds(ctx, momentIds) - - // 8.填充所有信息 - for _, vo := range volist { - - // 主播信息 - vo.CopyStreamerExt(streamerExtMap[vo.GetMid()]) - - // 是否点赞 - if err = s.utilFillIsZoneMomentThumbedUpFillable(ctx, vo.GetMid(), vo); err != nil { - logger.Error("utilFillIsZoneMomentThumbedUpFillable fail, req: %v, err: %v", util.ToJson(req), err) - ec = errcode.ErrCodeZoneMomentThumbsUpSrvFail - return - } - - // 是否解锁铁粉 - if unlockedIronfanshipMap[vo.GetMid()] == nil { - vo.SetIsIronfanshipUnlocked(consts.IsIronfanshipUnlocked_No) - } else { - vo.SetIsIronfanshipUnlocked(consts.IsIronfanshipUnlocked_Yes) - } - - // 是否解锁超粉 - if unlockedSuperfanshipMap[vo.GetMid()] == nil { - vo.SetIsSuperfanshipUnlocked(consts.IsSuperfanshipUnlocked_No) - } else { - vo.SetIsSuperfanshipUnlocked(consts.IsSuperfanshipUnlocked_Yes) - } - - // 是否解锁动态 - s.utilFillIsZoneMomentUnlocked(vo, zoneZidMap) - - // 动态价格 - if zmStat, ok := zmStatMap[vo.ZoneMoment.GetId()]; ok { - vo.BuyerCnt = zmStat.BuyerCnt - } - } - return } func (s *Service) ApiGetZoneMomentListByZid(ctx *gin.Context, req *zonemomentproto.ApiListByZidReq) (volist []*zonemomentproto.ApiZoneMomentVO, ec errcode.ErrCode) { ec = errcode.ErrCodeZoneMomentSrvOk - // 1.查询访客是否是空间创建者,不是创建者,则只查询公开动态 + // 1.查询该用户解锁的空间 + zidZuMap, err := _DefaultVas.GetZoneUnlockMapByMid(ctx, req.BaseRequest.Mid) + if err != nil { + logger.Error("GetZoneUnlockMapByMid fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeZoneSrvFail + return + } + + // 2.查询访客是否是空间创建者,不是创建者,则只查询公开动态 zoneMap, err := _DefaultZone.GetZoneMapByMids(ctx, []int64{req.BaseRequest.Mid}) if err != nil { logger.Error("_DefaultZone GetZoneMapByMids fail, req: %v, err: %v", util.ToJson(req), err) @@ -2669,13 +2625,18 @@ func (s *Service) ApiGetZoneMomentListByZid(ctx *gin.Context, req *zonemomentpro zones := zoneMap[req.BaseRequest.Mid] zoneZidMap := make(map[int64]*dbstruct.Zone, 0) for _, zone := range zones { - zoneZidMap[util.DerefInt64(zone.Id)] = zone + zoneZidMap[zone.GetId()] = zone } if zoneZidMap[util.DerefInt64(req.Zid)] == nil { + if zidZuMap[util.DerefInt64(req.Zid)] == nil { + logger.Error("Visitor has not unlocked this zone, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeUnlockedZone + return + } req.Status = goproto.Int64(consts.ZoneMoment_Public) } - // 2.根据关注的zids查询得到这一轮的动态基底 + // 3.根据关注的zids查询得到这一轮的动态基底 list, err := _DefaultZoneMoment.OpListByZid(ctx, &zonemomentproto.OpListByZidReq{ Zid: req.Zid, MType: req.MType, @@ -2693,66 +2654,13 @@ func (s *Service) ApiGetZoneMomentListByZid(ctx *gin.Context, req *zonemomentpro return } - // 3.初始化返回的volist,获取mids,并将动态基底填充进去 - volist = make([]*zonemomentproto.ApiZoneMomentVO, 0) - for _, zonemoment := range list { - vo := &zonemomentproto.ApiZoneMomentVO{ - ZoneMoment: zonemoment, - } - volist = append(volist, vo) - } - - if len(list) == 0 { - return - } - - // 4.通过mids获取主播信息map - ignoreMap := make(map[string]bool) - ignoreMap["zones"] = true - streamerExtMap, err := s.utilGetStreamerExtMapByMids(ctx, []int64{volist[0].GetMid()}, consts.InterfaceType_Api, ignoreMap) + // 4.初始化返回的volist,获取mids,并将动态基底填充进去 + volist, err = s.utilFillZoneMomentsWithApiVOInfo(ctx, list, req.BaseRequest.Mid, zidZuMap) if err != nil { - logger.Error("utilGetStreamerExtMapByMids fail, req: %v, err: %v", util.ToJson(req), err) - ec = errcode.ErrCodeStreamerSrvFail + logger.Error("utilFillZoneMomentsWithApiVOInfo fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeZoneMomentSrvFail return } - streamerExt := streamerExtMap[volist[0].GetMid()] - - // 5.获取访客已解锁的铁粉资格 - unlockedIronfanshipMap := make(map[int64]*int64, 0) - - // 6.获取访客已解锁的超粉资格 - unlockedSuperfanshipMap := make(map[int64]*int64, 0) - - // 7.填充所有信息 - for _, vo := range volist { - - // 主播信息 - vo.CopyStreamerExt(streamerExt) - - // 是否点赞 - if err = s.utilFillIsZoneMomentThumbedUpFillable(ctx, vo.GetMid(), vo); err != nil { - logger.Error("utilFillIsZoneMomentThumbedUpFillable fail, req: %v, err: %v", util.ToJson(req), err) - ec = errcode.ErrCodeZoneMomentThumbsUpSrvFail - return - } - - // 是否解锁铁粉 - if unlockedIronfanshipMap[vo.GetMid()] == nil { - vo.SetIsIronfanshipUnlocked(consts.IsIronfanshipUnlocked_No) - } else { - vo.SetIsIronfanshipUnlocked(consts.IsIronfanshipUnlocked_Yes) - } - - // 是否解锁超粉 - if unlockedSuperfanshipMap[vo.GetMid()] == nil { - vo.SetIsSuperfanshipUnlocked(consts.IsSuperfanshipUnlocked_No) - } else { - vo.SetIsSuperfanshipUnlocked(consts.IsSuperfanshipUnlocked_Yes) - } - - // 是否解锁动态 - s.utilFillIsZoneMomentUnlocked(vo, zoneZidMap) - } return } @@ -2912,17 +2820,28 @@ func (s *Service) ApiGetZoneMomentThumbsUpList(ctx *gin.Context, req *zonemoment return } -func (s *Service) ApiUpdateZoneSession(ctx *gin.Context, req *zonesessionproto.ApiUpdateReq) (ec errcode.ErrCode) { +func (s *Service) ApiUpsertZoneSession(ctx *gin.Context, req *zonesessionproto.ApiUpsertReq) (ec errcode.ErrCode) { ec = errcode.ErrCodeZoneSrvOk - err := _DefaultZoneSession.OpUpdateBySentence(ctx, req.BaseRequest.Mid, req.Zid) + err := _DefaultZoneSession.OpUpdateBySentence(ctx, req.BaseRequest.Mid, util.DerefInt64(req.Zid)) + // 如果命中失败,则创建空间对话 if err == qmgo.ErrNoSuchDocuments { - ec = errcode.ErrCodeZoneNotExist - err = nil + err := _DefaultZoneSession.OpCreate(ctx, &zonesessionproto.OpCreateReq{ + BaseRequest: req.BaseRequest, + ZoneSession: &dbstruct.ZoneSession{ + SubMid: goproto.Int64(req.BaseRequest.Mid), + ObjZid: req.Zid, + }, + }) + if err != nil { + logger.Error("OpCreate fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeZoneSessionSrvFail + return + } return } if err != nil { - logger.Error("OpUpdateBySentence fail, req: %v, err: %v", util.ToJson(req), err) - ec = errcode.ErrCodeZoneSrvFail + logger.Error("OpUpdate fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeZoneSessionSrvFail return } return @@ -3089,7 +3008,7 @@ func (s *Service) ApiGetZoneCollaboratorList(ctx *gin.Context, req *zone_collabo midSet := make(map[int64]*dbstruct.Moment) mids := make([]int64, 0) for _, zone_collaborator := range list { - mid := util.DerefInt64(zone_collaborator.CollaboratorMid) + mid := zone_collaborator.GetCollaboratorMid() if midSet[mid] == nil { midSet[mid] = &dbstruct.Moment{} mids = append(mids, mid) @@ -3104,7 +3023,7 @@ func (s *Service) ApiGetZoneCollaboratorList(ctx *gin.Context, req *zone_collabo } for _, zone_collaborator := range list { - mid := util.DerefInt64(zone_collaborator.CollaboratorMid) + mid := zone_collaborator.GetCollaboratorMid() vo := &zone_collaborator_proto.ZoneCollaboratorApiVO{ ZoneCollaborator: zone_collaborator, Account: acctMp[mid], diff --git a/app/mix/service/apiservice_business_validation.go b/app/mix/service/apiservice_business_validation.go index ad4b7ea1..cf323baf 100644 --- a/app/mix/service/apiservice_business_validation.go +++ b/app/mix/service/apiservice_business_validation.go @@ -576,7 +576,7 @@ func (s *Service) ApiCreateZoneMomentBusinessValidate(ctx *gin.Context, req *zon return } -// 验证码登录 +// 代运营创建验证码 func (s *Service) ApiCreateZoneThirdPartnerBusinessValidate(ctx *gin.Context, req *zone_third_partner_proto.ApiCreateReq) (vericode *dbstruct.VeriCode, ec errcode.ErrCode) { ec = errcode.ErrCodeLoginSrvOk diff --git a/app/mix/service/logic/vas_zone.go b/app/mix/service/logic/vas_zone.go index 69e35a13..d34221c7 100644 --- a/app/mix/service/logic/vas_zone.go +++ b/app/mix/service/logic/vas_zone.go @@ -3,9 +3,6 @@ package logic import ( "database/sql" "fmt" - "github.com/gin-gonic/gin" - "github.com/jmoiron/sqlx" - goproto "google.golang.org/protobuf/proto" "service/api/errs" vasproto "service/api/proto/vas/proto" zone_collaborator_proto "service/api/proto/zone_collaborator/proto" @@ -14,6 +11,10 @@ import ( "service/dbstruct" "service/library/logger" "time" + + "github.com/gin-gonic/gin" + "github.com/jmoiron/sqlx" + goproto "google.golang.org/protobuf/proto" ) // 检查mid对空间的解锁是否存在 @@ -599,6 +600,19 @@ func (v *Vas) GetZoneMomentStatByIds(ctx *gin.Context, momentIds []int64) (midZm return } +// 获取用户已解锁的空间的信息,返回值:key: zid, value: 解锁信息 +func (v *Vas) GetZoneUnlockMapByMid(ctx *gin.Context, mid int64) (zidZuMap map[int64]*dbstruct.ZoneUnlock, err error) { + zidZuMap = make(map[int64]*dbstruct.ZoneUnlock) + list, err := v.store.GetZoneUnlockListByMid(ctx, nil, mid) + if err != nil { + return + } + for _, v := range list { + zidZuMap[v.GetZid()] = v + } + return +} + // 获取空间解锁人的信息,返回值:key: mid, value: 解锁信息 func (v *Vas) GetZoneUnlockMapByZid(ctx *gin.Context, zid int64) (midZuMap map[int64]*dbstruct.ZoneUnlock, err error) { midZuMap = make(map[int64]*dbstruct.ZoneUnlock) @@ -625,15 +639,15 @@ func (v *Vas) GetZoneUnlockMapByMidZids(ctx *gin.Context, mid int64, zids []int6 return } -// 获取mid对动态解锁信息 by mid, momentIds,返回值:key: zid, value: 解锁信息 -func (v *Vas) GetZoneMomentUnlockMapByMidMomentIds(ctx *gin.Context, mid int64, momentIds []int64) (zidZuMap map[int64]*dbstruct.ZoneMomentUnlock, err error) { - zidZuMap = make(map[int64]*dbstruct.ZoneMomentUnlock) +// 获取mid对动态解锁信息 by mid, momentIds,返回值:key: moment_id, value: 解锁信息 +func (v *Vas) GetZoneMomentUnlockMapByMidMomentIds(ctx *gin.Context, mid int64, momentIds []int64) (momentIdZmuMap map[int64]*dbstruct.ZoneMomentUnlock, err error) { + momentIdZmuMap = make(map[int64]*dbstruct.ZoneMomentUnlock) list, err := v.store.GetZoneMomentUnlockListByMidMomentIds(ctx, nil, mid, momentIds) if err != nil { return } for _, v := range list { - zidZuMap[v.GetZid()] = v + momentIdZmuMap[v.GetMomentId()] = v } return } diff --git a/app/mix/service/logic/zone_collaborator.go b/app/mix/service/logic/zone_collaborator.go index 4170be94..59f022dc 100644 --- a/app/mix/service/logic/zone_collaborator.go +++ b/app/mix/service/logic/zone_collaborator.go @@ -72,7 +72,7 @@ func (p *ZoneCollaborator) OpList(ctx *gin.Context, req *zone_collaborator_proto return list, nil } -func (p *ZoneCollaborator) GetZoneCollaboratorMapByTpMid(ctx *gin.Context, c_mid int64) (map[int64]*dbstruct.ZoneCollaborator, error) { +func (p *ZoneCollaborator) GetZoneCollaboratorMapByCMid(ctx *gin.Context, c_mid int64) (map[int64]*dbstruct.ZoneCollaborator, error) { list, err := p.store.GetZoneCollaboratorListByCMid(ctx, c_mid) if err != nil { logger.Error("GetZoneCollaboratorListByCMid fail, err: %v", err) diff --git a/app/mix/service/logic/zonesession.go b/app/mix/service/logic/zonesession.go index 91f7ec5f..d63d7efe 100644 --- a/app/mix/service/logic/zonesession.go +++ b/app/mix/service/logic/zonesession.go @@ -65,9 +65,10 @@ func (p *ZoneSession) OpList(ctx *gin.Context, req *zonesessionproto.OpListReq) return list, nil } -func (p *ZoneSession) GetZoneSessionMapByMid(ctx *gin.Context, mid int64) (map[int64]*dbstruct.ZoneSession, error) { +func (p *ZoneSession) GetZoneSessionMapByMidAndZids(ctx *gin.Context, mid int64, zids []int64) (map[int64]*dbstruct.ZoneSession, error) { list, err := p.store.GetZoneSessionList(ctx, &zonesessionproto.OpListReq{ - Mid: mid, + Mid: mid, + Zids: zids, }) if err != nil { logger.Error("GetZoneSessionList fail, err: %v", err) diff --git a/app/mix/service/utilservice.go b/app/mix/service/utilservice.go index afea5a8d..65eea473 100644 --- a/app/mix/service/utilservice.go +++ b/app/mix/service/utilservice.go @@ -895,7 +895,7 @@ func (s *Service) utilEncryptInaccessibleZoneMoment(vo *zonemomentproto.ApiZoneM } // 填充动态是否解锁 -func (s *Service) utilFillIsZoneMomentUnlocked(vo *zonemomentproto.ApiZoneMomentVO, zoneZidMap map[int64]*dbstruct.Zone) { +func (s *Service) utilFillIsZoneMomentUnlocked(vo *zonemomentproto.ApiZoneMomentVO, zoneZidMap map[int64]*dbstruct.Zone, momentIdZmuMap map[int64]*dbstruct.ZoneMomentUnlock) { // 若动态在本人创建的空间内,则必然解锁 if zoneZidMap[util.DerefInt64(vo.ZoneMoment.Zid)] != nil { vo.SetIsZoneMomentUnlocked(consts.IsZoneMomentUnlocked_Yes) @@ -905,12 +905,13 @@ func (s *Service) utilFillIsZoneMomentUnlocked(vo *zonemomentproto.ApiZoneMoment case consts.ZoneMomentCType_Free: vo.SetIsZoneMomentUnlocked(consts.IsZoneMomentUnlocked_Yes) case consts.ZoneMomentCType_Paid: - if vo.IsSuperfanshipUnlocked == consts.IsIronfanshipUnlocked_Yes { + if vo.IsSuperfanshipUnlocked == consts.IsSuperfanshipUnlocked_Yes { // 超粉解锁 vo.SetIsZoneMomentUnlocked(consts.IsZoneMomentUnlocked_Yes) - } else if util.DerefInt64(vo.IsIronfanVisible) == consts.IsIronfanVisible_Yes && vo.IsIronfanshipUnlocked == consts.IsIronfanshipUnlocked_Yes { + } else if util.DerefInt64(vo.IsIronfanVisible) == consts.IsIronfanVisible_Yes && vo.IsIronfanshipUnlocked == consts.IsIronfanshipUnlocked_Yes { // 铁粉可见 vo.SetIsZoneMomentUnlocked(consts.IsZoneMomentUnlocked_Yes) - } else { - // 是否已购买该条动态 + } else if momentIdZmuMap[vo.ZoneMoment.GetId()].IsUnlock() { // 动态已购买 + vo.SetIsZoneMomentUnlocked(consts.IsZoneMomentUnlocked_Yes) + } else { // 未解锁,上锁 vo.SetIsZoneMomentUnlocked(consts.IsZoneMomentUnlocked_No) s.utilEncryptInaccessibleZoneMoment(vo) } @@ -1445,18 +1446,25 @@ func (s *Service) utilGetApiMomentVOListByIds(ctx *gin.Context, visitorMid int64 return } -func (s *Service) utilFillZonesWithApiVOInfo(ctx *gin.Context, list []*dbstruct.Zone, visitorMid int64) (volist []*zoneproto.ApiZoneVO, err error) { +func (s *Service) utilFillZonesWithApiVOInfo(ctx *gin.Context, list []*dbstruct.Zone, visitorMid int64, zidZuMap map[int64]*dbstruct.ZoneUnlock) (volist []*zoneproto.ApiZoneVO, err error) { - // 1.获取mids,并填充空间基底 + // 1.获取mids,zids,并填充空间基底 volist = make([]*zoneproto.ApiZoneVO, 0) mids := make([]int64, 0) + zids := make([]int64, 0) midSet := make(map[int64]*dbstruct.Zone) + zidSet := make(map[int64]*dbstruct.Zone) for _, zone := range list { - mid := util.DerefInt64(zone.Mid) + mid := zone.GetMid() + zid := zone.GetId() if midSet[mid] == nil { midSet[mid] = &dbstruct.Zone{} mids = append(mids, mid) } + if zidSet[zid] == nil { + zidSet[zid] = &dbstruct.Zone{} + zids = append(zids, zid) + } vo := &zoneproto.ApiZoneVO{} vo.CopyZone(zone) volist = append(volist, vo) @@ -1471,10 +1479,10 @@ func (s *Service) utilFillZonesWithApiVOInfo(ctx *gin.Context, list []*dbstruct. return } - // 3.获取访客所有空间的session - zonesessionMp, err := _DefaultZoneSession.GetZoneSessionMapByMid(ctx, visitorMid) + // 3.获取访客访问这些空间的session + zonesessionMp, err := _DefaultZoneSession.GetZoneSessionMapByMidAndZids(ctx, visitorMid, zids) if err != nil { - logger.Error("GetZoneSessionMapByMid fail, req: %v, err: %v", err) + logger.Error("GetZoneSessionMapByMidAndZids fail, req: %v, err: %v", err) return } @@ -1486,9 +1494,9 @@ func (s *Service) utilFillZonesWithApiVOInfo(ctx *gin.Context, list []*dbstruct. } // 5.获取访客协作的空间 - collabZoneMap, err := _DefaultZoneCollaborator.GetZoneCollaboratorMapByTpMid(ctx, visitorMid) + collabZoneMap, err := _DefaultZoneCollaborator.GetZoneCollaboratorMapByCMid(ctx, visitorMid) if err != nil { - logger.Error("GetZoneCollaboratorMapByTpMid fail, req: %v, err: %v", err) + logger.Error("GetZoneCollaboratorMapByCMid fail, req: %v, err: %v", err) return } @@ -1504,33 +1512,38 @@ func (s *Service) utilFillZonesWithApiVOInfo(ctx *gin.Context, list []*dbstruct. zones := zoneMap[visitorMid] zoneZidMap := make(map[int64]*dbstruct.Zone, 0) for _, zone := range zones { - zoneZidMap[util.DerefInt64(zone.Id)] = zone + zoneZidMap[zone.GetId()] = zone } // 8.填充信息 for _, vo := range volist { + zid := vo.Zone.GetId() + // 填充主播信息 vo.CopyStreamerExt(streamerExtMap[vo.GetMid()]) // 填充是否有未读信息 - zonesession := zonesessionMp[util.DerefInt64(vo.Zone.Id)] - if zonesession != nil && util.DerefInt64(zonesession.Ut) < util.DerefInt64(vo.Zone.LastZoneMomentCt) { + zonesession := zonesessionMp[zid] + if zonesession != nil && zonesession.GetUt() < vo.Zone.GetLastZoneMomentCt() { vo.IsUnreadZoneMomentExist = consts.IsUnreadZoneMomentExist_Yes + } else { + vo.IsUnreadZoneMomentExist = consts.IsUnreadZoneMomentExist_No } // 填充访客身份 - vo.VisitorRole = consts.Zone_Visitor - if zoneZidMap[util.DerefInt64(vo.Zone.Id)] != nil { + vo.VisitorRole = consts.Zone_Outsider + if zidZuMap[zid] != nil { // 访客已解锁空间是否有该zid + vo.VisitorRole = consts.Zone_Visitor + } else if zoneZidMap[zid] != nil { // 访客创建的空间是否有该zid vo.VisitorRole = consts.Zone_Creater - } else if tpZoneMap[visitorMid] != nil { + } else if tpZoneMap[zid] != nil { // 访客代运营的空间是否有该zid vo.VisitorRole = consts.Zone_ThridPartner - } else if collabZoneMap[visitorMid] != nil { + } else if collabZoneMap[zid] != nil { // 访客协作的空间是否有该zid vo.VisitorRole = consts.Zone_Collaborator } // 填充该空间预览图 - zid := util.DerefInt64(vo.Zone.Id) if zonePreviewsMp[zid] != nil { vo.Previews = zonePreviewsMp[zid] } else { @@ -1543,7 +1556,21 @@ func (s *Service) utilFillZonesWithApiVOInfo(ctx *gin.Context, list []*dbstruct. } // 填充该空间总消耗费用 - vo.Expenditure = 0 + vo.Expenditure = zidZuMap[zid].GetConsume() + + // 填充铁粉解锁信息 + if zidZuMap[zid].IsUnlockIronfanship() { + vo.IsIronfanshipUnlocked = consts.IsIronfanshipUnlocked_Yes + } else { + vo.IsIronfanshipUnlocked = consts.IsIronfanshipUnlocked_No + } + + // 填充超粉解锁信息 + if zidZuMap[zid].IsUnlockSuperfanship() { + vo.IsSuperfanshipUnlocked = consts.IsSuperfanshipUnlocked_Yes + } else { + vo.IsSuperfanshipUnlocked = consts.IsSuperfanshipUnlocked_No + } } return @@ -1578,3 +1605,106 @@ func (s *Service) utilGetZonePreviews(ctx *gin.Context, zid int64) (previews *db return } + +func (s *Service) utilFillZoneMomentsWithApiVOInfo(ctx *gin.Context, list []*dbstruct.ZoneMoment, visitorMid int64, zidZuMap map[int64]*dbstruct.ZoneUnlock) (volist []*zonemomentproto.ApiZoneMomentVO, err error) { + + // 1.填充信息 + volist = make([]*zonemomentproto.ApiZoneMomentVO, 0) + midSet := make(map[int64]*dbstruct.Moment) + mids := make([]int64, 0) + zids := make([]int64, 0) + zidSet := make(map[int64]*dbstruct.Zone) + momentIds := make([]int64, 0) + for _, zonemoment := range list { + vo := &zonemomentproto.ApiZoneMomentVO{ + ZoneMoment: zonemoment, + } + volist = append(volist, vo) + momentIds = append(momentIds, zonemoment.GetId()) + mid := zonemoment.GetMid() + if midSet[mid] == nil { + midSet[mid] = &dbstruct.Moment{} + mids = append(mids, mid) + } + zid := zonemoment.GetZid() + if zidSet[zid] == nil { + zidSet[zid] = &dbstruct.Zone{} + zids = append(zids, zid) + } + } + + // 2.通过mids获取主播信息map + ignoreMap := make(map[string]bool) + ignoreMap["zones"] = true + streamerExtMap, err := s.utilGetStreamerExtMapByMids(ctx, mids, consts.InterfaceType_Api, ignoreMap) + if err != nil { + logger.Error("utilGetStreamerExtMapByMids fail, err: %v", err) + return + } + + // 3.获取访客创建的空间 + zoneMap, err := _DefaultZone.GetZoneMapByMids(ctx, []int64{visitorMid}) + if err != nil { + logger.Error("_DefaultZone GetZoneMapByMids fail, req: %v, err: %v", err) + return + } + zones := zoneMap[visitorMid] + zoneZidMap := make(map[int64]*dbstruct.Zone, 0) + for _, zone := range zones { + zoneZidMap[zone.GetId()] = zone + } + + // 4.获取动态的一些静态数据信息 + zmStatMap, _ := _DefaultVas.GetZoneMomentStatByIds(ctx, momentIds) + + // 5.获取该mid是否已解锁这些动态 + momentIdZmuMap, _ := _DefaultVas.GetZoneMomentUnlockMapByMidMomentIds(ctx, visitorMid, momentIds) + + // 6.获取空间价格 + zvMap, _ := _DefaultVas.GetZoneVasByIds(ctx, zids) + + // 7.填充所有信息 + for _, vo := range volist { + + zid := vo.ZoneMoment.GetId() + + // 主播信息 + vo.CopyStreamerExt(streamerExtMap[vo.GetMid()]) + + // 是否点赞 + if err = s.utilFillIsZoneMomentThumbedUpFillable(ctx, vo.GetMid(), vo); err != nil { + logger.Error("utilFillIsZoneMomentThumbedUpFillable fail, err: %v", err) + return + } + + // 填充铁粉解锁信息 + if zidZuMap[zid].IsUnlockIronfanship() { + vo.IsIronfanshipUnlocked = consts.IsIronfanshipUnlocked_Yes + } else { + vo.IsIronfanshipUnlocked = consts.IsIronfanshipUnlocked_No + } + + // 填充超粉解锁信息 + if zidZuMap[zid].IsUnlockSuperfanship() { + vo.IsSuperfanshipUnlocked = consts.IsSuperfanshipUnlocked_Yes + } else { + vo.IsSuperfanshipUnlocked = consts.IsSuperfanshipUnlocked_No + } + + // 是否解锁动态 + s.utilFillIsZoneMomentUnlocked(vo, zoneZidMap, momentIdZmuMap) + + // 动态已解锁信息 + if zmStat, ok := zmStatMap[vo.ZoneMoment.GetId()]; ok { + vo.BuyerCnt = zmStat.BuyerCnt + } + + // 已消费金额 + vo.Expenditure = zidZuMap[zid].GetConsume() + + // 铁粉价格 + vo.IronfanshipPrice = zvMap[zid].IronfanshipPrice + } + + return +} diff --git a/dbstruct/vas_mysql.go b/dbstruct/vas_mysql.go index 491d6ab9..83def0fb 100644 --- a/dbstruct/vas_mysql.go +++ b/dbstruct/vas_mysql.go @@ -943,6 +943,9 @@ type ZoneUnlock struct { } func (p *ZoneUnlock) IsUnlockAdmission() bool { + if p.AdmissionCt == nil { + return false + } if p.GetAdmissionUntil() == -1 || p.GetAdmissionUntil() < time.Now().Unix() { return true } @@ -950,6 +953,9 @@ func (p *ZoneUnlock) IsUnlockAdmission() bool { } func (p *ZoneUnlock) IsUnlockIronfanship() bool { + if p.IronfanshipCt == nil { + return false + } if p.GetIronfanshipUntil() == -1 || p.GetIronfanshipUntil() < time.Now().Unix() { return true } @@ -957,6 +963,9 @@ func (p *ZoneUnlock) IsUnlockIronfanship() bool { } func (p *ZoneUnlock) IsUnlockSuperfanship() bool { + if p.SuperfanshipCt == nil { + return false + } if p.GetSuperfanshipUntil() == -1 || p.GetSuperfanshipUntil() < time.Now().Unix() { return true } diff --git a/dbstruct/zone.go b/dbstruct/zone.go index 9e2bbf7c..bcd64ca7 100644 --- a/dbstruct/zone.go +++ b/dbstruct/zone.go @@ -19,3 +19,17 @@ func (p *Zone) GetId() int64 { } return 0 } + +func (p *Zone) GetMid() int64 { + if p != nil && p.Mid != nil { + return *p.Mid + } + return 0 +} + +func (p *Zone) GetLastZoneMomentCt() int64 { + if p != nil && p.LastZoneMomentCt != nil { + return *p.LastZoneMomentCt + } + return 0 +} diff --git a/dbstruct/zonemoment.go b/dbstruct/zonemoment.go index d47a982e..5a460fc8 100644 --- a/dbstruct/zonemoment.go +++ b/dbstruct/zonemoment.go @@ -45,3 +45,31 @@ func (p *ZoneMoment) GetMid() int64 { } return 0 } + +func (p *ZoneMoment) GetZid() int64 { + if p != nil && p.Zid != nil { + return *p.Zid + } + return 0 +} + +func (p *ZoneMoment) GetMType() int64 { + if p != nil && p.MType != nil { + return *p.MType + } + return 0 +} + +func (p *ZoneMoment) GetCType() int64 { + if p != nil && p.CType != nil { + return *p.CType + } + return 0 +} + +func (p *ZoneMoment) GetUt() int64 { + if p != nil && p.Ut != nil { + return *p.Ut + } + return 0 +} diff --git a/dbstruct/zonesession.go b/dbstruct/zonesession.go index 0aba9a9a..deca4c0f 100644 --- a/dbstruct/zonesession.go +++ b/dbstruct/zonesession.go @@ -8,3 +8,10 @@ type ZoneSession struct { Ut *int64 `json:"ut" bson:"ut"` // 更新时间 DelFlag *int64 `json:"del_flag" bson:"del_flag"` // 删除标记 } + +func (p *ZoneSession) GetUt() int64 { + if p != nil && p.Ut != nil { + return *p.Ut + } + return 0 +}