diff --git a/api/errcode/errcode.go b/api/errcode/errcode.go index b129894b..5454d534 100644 --- a/api/errcode/errcode.go +++ b/api/errcode/errcode.go @@ -200,10 +200,12 @@ var ErrCodeMsgMap = map[ErrCode]string{ ErrCodeAccountPunishmentStreamerOnly: "该账号处罚行为仅能对主播进行!", ErrCodeAccountPunishmentEndTimeCalcFail: "账号处罚结束时间计算错误", - ErrCodeZoneSrvFail: "空间服务错误", - ErrCodeZoneNotExist: "空间不存在", - ErrCodeUnlockedZone: "访客未解锁该空间", - ErrCodeZoneDuplicateKey: "您已创建空间", + ErrCodeZoneSrvFail: "空间服务错误", + ErrCodeZoneNotExist: "空间不存在", + ErrCodeUnlockedZone: "访客未解锁该空间", + ErrCodeZoneDuplicateKey: "您已创建空间", + ErrcodeZoneIronFansUnLock: "您已解锁空间铁粉", + ErrcodeZoneIronFansNotUnLock: "咱不满足铁粉条件", ErrCodeZoneMomentSrvFail: "私密圈动态服务错误", ErrCodeZoneMomentNotExist: "私密圈动态不存在", @@ -558,11 +560,13 @@ const ( ErrCodeAccountPunishmentEndTimeCalcFail ErrCode = -32008 // 账号处罚结束时间计算错误 // Zone: 33xxx - ErrCodeZoneSrvOk ErrCode = ErrCodeOk - ErrCodeZoneSrvFail ErrCode = -33001 // 空间服务错误 - ErrCodeZoneNotExist ErrCode = -33002 // 空间不存在 - ErrCodeUnlockedZone ErrCode = -33003 // 未解锁的空间 - ErrCodeZoneDuplicateKey ErrCode = -33004 // 空间已存在 + ErrCodeZoneSrvOk ErrCode = ErrCodeOk + ErrCodeZoneSrvFail ErrCode = -33001 // 空间服务错误 + ErrCodeZoneNotExist ErrCode = -33002 // 空间不存在 + ErrCodeUnlockedZone ErrCode = -33003 // 未解锁的空间 + ErrCodeZoneDuplicateKey ErrCode = -33004 // 空间已存在 + ErrcodeZoneIronFansUnLock ErrCode = -33005 // 空间已解锁铁粉 + ErrcodeZoneIronFansNotUnLock ErrCode = -33006 // 空间未解锁铁粉 // ZoneMoment: 34xxx ErrCodeZoneMomentSrvOk ErrCode = ErrCodeOk diff --git a/api/proto/zonemoment/proto/zonemoment_api.go b/api/proto/zonemoment/proto/zonemoment_api.go index f5d9fb37..c9d6b041 100644 --- a/api/proto/zonemoment/proto/zonemoment_api.go +++ b/api/proto/zonemoment/proto/zonemoment_api.go @@ -178,3 +178,13 @@ type ApiListByIdsFromCreaterResp struct { base.BaseResponse Data *ApiListByIdsFromCreaterData `json:"data"` } + +// 主播空间降价/涨价 +type ApiFansIdentityRefreshReq struct { + base.BaseRequest + Zid int64 `json:"zid"` +} + +type ApiFansIdentityRefreshResp struct { + base.BaseResponse +} diff --git a/app/mix/controller/init.go b/app/mix/controller/init.go index 07b433d0..fcf58688 100644 --- a/app/mix/controller/init.go +++ b/app/mix/controller/init.go @@ -281,6 +281,7 @@ func Init(r *gin.Engine) { apiZoneMomentGroup.POST("head", middleware.JSONParamValidator(zonemomentproto.ApiHeadReq{}), middleware.JwtAuthenticator(), ApiHeadZoneMoment) apiZoneMomentGroup.POST("list_statistics_by_creater_mid", middleware.JSONParamValidator(zonemomentproto.ApiListStatisticsByCreaterMidReq{}), middleware.JwtAuthenticator(), ApiGetZoneMomentStatisticsByCreaterMid) apiZoneMomentGroup.POST("list_by_ids_from_creater", middleware.JSONParamValidator(zonemomentproto.ApiListByIdsFromCreaterReq{}), middleware.JwtAuthenticator(), ApiGetZoneMomentListByIdsFromCreater) + apiZoneMomentGroup.POST("fans_identity_refresh", middleware.JSONParamValidator(zonemomentproto.ApiFansIdentityRefreshReq{}), middleware.JwtAuthenticator(), ApiFansIdentityRefresh) // 空间对话 apiZoneSessionGroup := r.Group("/api/zone_session", PrepareToC()) diff --git a/app/mix/controller/zonemoment_api.go b/app/mix/controller/zonemoment_api.go index 14ed6dae..1cdb9cb8 100644 --- a/app/mix/controller/zonemoment_api.go +++ b/app/mix/controller/zonemoment_api.go @@ -232,3 +232,22 @@ func ApiGetZoneMomentListByIdsFromCreater(ctx *gin.Context) { } ReplyOk(ctx, data) } + +// 铁粉刷新(主播涨价降价后更新逻辑) +func ApiFansIdentityRefresh(ctx *gin.Context) { + req := ctx.MustGet("client_req").(*zonemomentproto.ApiFansIdentityRefreshReq) + if req.Mid <= 0 || req.Zid <= 0 { + logger.Error("ApiFansIdentityRefresh, invalid param, req: %v", util.ToJson(req)) + ReplyErrCodeMsg(ctx, errcode.ErrCodeBadParam) + return + } + + err := service.DefaultService.FansIdentityRefresh(ctx, req) + if err != nil { + logger.Error("ApiFansIdentityRefresh fail, req: %v, err: %v", util.ToJson(req), err) + ReplyErrCodeMsg(ctx, errcode.ErrcodeZoneIronFansNotUnLock) + return + } + + ReplyOk(ctx, nil) +} diff --git a/app/mix/service/logic/vas.go b/app/mix/service/logic/vas.go index bda4699f..cafff040 100644 --- a/app/mix/service/logic/vas.go +++ b/app/mix/service/logic/vas.go @@ -4361,3 +4361,22 @@ func (v *Vas) IsWithdrawFreeze(ctx *gin.Context, mid int64) bool { } return false } + +func (v *Vas) FansIdentityRefresh(ctx *gin.Context, mid, zid int64) error { + + // 开启事务 + tx, err := v.store.VasBegin(ctx) + if err != nil { + logger.Error("vas begin fail, err: %v", err) + return err + } + + err = v.UnlockZoneIronfanshipRefresh(ctx, tx, mid, zid, 0) + + if err != nil { + logger.Error("vas FansIdentityRefresh UnlockZoneIronFanShipRefresh fail, mid: %v, zid: %v, err: %v", mid, zid, err) + return err + } + + return nil +} diff --git a/app/mix/service/logic/vas_zone.go b/app/mix/service/logic/vas_zone.go index 9e0a7046..fba64f59 100644 --- a/app/mix/service/logic/vas_zone.go +++ b/app/mix/service/logic/vas_zone.go @@ -646,6 +646,62 @@ func (v *Vas) UnlockZoneIronfanshipReachConsume(ctx *gin.Context, tx *sqlx.Tx, m return nil } +// 铁粉刷新(主播涨价降价后逻辑后更新逻辑) +func (v *Vas) UnlockZoneIronfanshipRefresh(ctx *gin.Context, tx *sqlx.Tx, mid, zid, streamerMid int64) error { + if tx == nil { + err := fmt.Errorf("nil tx") + return err + } + + // 获取zid + if zid <= 0 && streamerMid > 0 { + // 获取空间id + zone, _ := v.zone.GetByMid(ctx, streamerMid) + if zone != nil { + zid = zone.GetId() + } + } + if zid <= 0 { + return fmt.Errorf("zone not exist, mid: %v, streamerMid: %v", mid, streamerMid) + } + + // 获取空间价格 + zVas, _ := v.store.GetZoneVasById(ctx, zid) + if zVas == nil { + return fmt.Errorf("zone vas not exist, zid: %v", zid) + } + + // 获取空间消费信息 + zUnlock, exists := v.CheckZoneUnlockExist(ctx, tx, mid, zid) + if !exists { + return fmt.Errorf("zone unlock not exist, mid: %v, zid: %v", mid, zid) + } + + if zUnlock.GetConsume() < zVas.IronfanshipPrice { + // 主播降价后消费额是否达到了解锁铁粉的消费额 + return fmt.Errorf("not reach ironfan unlock consume, mid: %v, zid: %v", mid, zid) + } else if zUnlock.GetIronfanshipUnlockType() != dbstruct.ZoneUnlockTypeReachConsume { + // 主播涨价后,原用户是否是铁粉 + return fmt.Errorf("the iron fans unlock condition is not met, mid: %v, zid: %v", mid, zid) + } + + // 解锁铁粉 + err := v.MustUnlockIronfanship(ctx, tx, mid, zid, -1, "ironfan", dbstruct.ZoneUnlockTypeReachConsume) + if err != nil { + logger.Error("MustUnlockIronfanship fail, mid: %v, zid: %v, err: %v", mid, zid, err) + return err + } + + // 添加到空间成员 + err = v.store.AddZoneMember(ctx, tx, mid, zid, dbstruct.ZoneMemberTypeIronfan) + if err != nil { + logger.Error("AddZoneMember normal fail, mid: %v, zid: %v, err: %v", mid, zid, err) + return err + } + + return nil +} + type IncomeInfo struct { Mid int64 `json:"mid"` // mid IncomeSType int32 `json:"income_stype"` // 收入类类型 diff --git a/app/mix/service/utilservice.go b/app/mix/service/utilservice.go index f2c6e107..996f0e6b 100644 --- a/app/mix/service/utilservice.go +++ b/app/mix/service/utilservice.go @@ -2614,3 +2614,14 @@ func (s *Service) utilAbortAccountCancellation(ctx *gin.Context, mid int64) erro } return nil } + +func (s *Service) FansIdentityRefresh(ctx *gin.Context, req *zonemomentproto.ApiFansIdentityRefreshReq) error { + + err := _DefaultVas.FansIdentityRefresh(ctx, req.Mid, req.Zid) + if err != nil { + logger.Error("util service FansIdentityRefresh failed, err: %v", err) + return err + } + + return nil +}