diff --git a/api/errcode/errcode.go b/api/errcode/errcode.go index 7af9d41e..a8acabd1 100644 --- a/api/errcode/errcode.go +++ b/api/errcode/errcode.go @@ -189,12 +189,14 @@ var ErrCodeMsgMap = map[ErrCode]string{ ErrCodeAccountCancellationSrvFail: "账户注销服务错误", ErrCodeAccountCancellationNotExist: "账户注销不存在", - ErrCodeZoneSrvFail: "空间服务错误", - ErrCodeZoneNotExist: "空间不存在", - ErrCodeUnlockedZone: "访客未解锁该空间", - ErrCodeZoneDuplicateKey: "您已创建空间", - ErrcodeZoneIronFansUnLock: "您已解锁空间铁粉", - ErrcodeZoneIronFansNotUnLock: "暂不满足铁粉条件", + ErrCodeZoneSrvFail: "空间服务错误", + ErrCodeZoneNotExist: "空间不存在", + ErrCodeUnlockedZone: "访客未解锁该空间", + ErrCodeZoneDuplicateKey: "您已创建空间", + ErrcodeZoneIronFansUnLock: "您已解锁空间铁粉", + ErrcodeZoneIronFansAlreadyUnLock: "您已是空间铁粉", + ErrcodeZoneIronFansNotUnLock: "暂不满足铁粉条件", + ErrcodeZoneIronFansRefreshErr: "铁粉刷新失败,服务错误", ErrCodeZoneMomentSrvFail: "私密圈动态服务错误", ErrCodeZoneMomentNotExist: "私密圈动态不存在", @@ -523,13 +525,15 @@ const ( ErrCodeAccountPunishmentStreamerOnly ErrCode = -32007 // 该账号处罚仅能对主播进行 // Zone: 33xxx - ErrCodeZoneSrvOk ErrCode = ErrCodeOk - ErrCodeZoneSrvFail ErrCode = -33001 // 空间服务错误 - ErrCodeZoneNotExist ErrCode = -33002 // 空间不存在 - ErrCodeUnlockedZone ErrCode = -33003 // 未解锁的空间 - ErrCodeZoneDuplicateKey ErrCode = -33004 // 空间已存在 - ErrcodeZoneIronFansUnLock ErrCode = -33005 // 空间已解锁铁粉 - ErrcodeZoneIronFansNotUnLock ErrCode = -33006 // 空间未解锁铁粉 + ErrCodeZoneSrvOk ErrCode = ErrCodeOk + ErrCodeZoneSrvFail ErrCode = -33001 // 空间服务错误 + ErrCodeZoneNotExist ErrCode = -33002 // 空间不存在 + ErrCodeUnlockedZone ErrCode = -33003 // 未解锁的空间 + ErrCodeZoneDuplicateKey ErrCode = -33004 // 空间已存在 + ErrcodeZoneIronFansUnLock ErrCode = -33005 // 空间已解锁铁粉 + ErrcodeZoneIronFansNotUnLock ErrCode = -33006 // 空间未解锁铁粉 + ErrcodeZoneIronFansAlreadyUnLock ErrCode = -33007 // 已经是空间铁粉 + ErrcodeZoneIronFansRefreshErr ErrCode = -33008 // 铁粉刷新服务错误 // ZoneMoment: 34xxx ErrCodeZoneMomentSrvOk ErrCode = ErrCodeOk diff --git a/app/mix/controller/zonemoment_api.go b/app/mix/controller/zonemoment_api.go index 1cdb9cb8..b8ac8897 100644 --- a/app/mix/controller/zonemoment_api.go +++ b/app/mix/controller/zonemoment_api.go @@ -242,12 +242,16 @@ func ApiFansIdentityRefresh(ctx *gin.Context) { return } - err := service.DefaultService.FansIdentityRefresh(ctx, req) + ec, 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) + ReplyErrCodeMsg(ctx, ec) return } + if ec != errcode.ErrCodeOk { + ReplyErrCodeMsg(ctx, ec) + } + ReplyOk(ctx, nil) } diff --git a/app/mix/service/logic/vas.go b/app/mix/service/logic/vas.go index 6bed31cd..b6096d10 100644 --- a/app/mix/service/logic/vas.go +++ b/app/mix/service/logic/vas.go @@ -15,6 +15,7 @@ import ( "net/http" "service/api/adapter/dingtalkapi" "service/api/base" + "service/api/errcode" "service/api/errs" "service/api/message/response" accountproto "service/api/proto/account/proto" @@ -4297,13 +4298,13 @@ func (v *Vas) UnilaterallyWithdrawAccomplish(ctx *gin.Context, orderId string) ( return } -func (v *Vas) FansIdentityRefresh(ctx *gin.Context, mid, zid int64) error { - err := v.UnlockZoneIronfanshipRefresh(ctx, mid, zid, 0) +func (v *Vas) FansIdentityRefresh(ctx *gin.Context, mid, zid int64) (errcode.ErrCode, error) { + ec, err := v.UnlockZoneIronfanshipRefresh(ctx, mid, zid, 0) if err != nil { logger.Error("vas FansIdentityRefresh UnlockZoneIronFanShipRefresh fail, mid: %v, zid: %v, err: %v", mid, zid, err) - return err + return ec, err } - return nil + return ec, nil } diff --git a/app/mix/service/logic/vas_zone.go b/app/mix/service/logic/vas_zone.go index 2feff22d..fb2805bd 100644 --- a/app/mix/service/logic/vas_zone.go +++ b/app/mix/service/logic/vas_zone.go @@ -3,6 +3,7 @@ package logic import ( "database/sql" "fmt" + "service/api/errcode" "service/api/errs" vasproto "service/api/proto/vas/proto" zone_collaborator_proto "service/api/proto/zone_collaborator/proto" @@ -530,13 +531,14 @@ func (v *Vas) UnlockZoneIronfanshipReachConsume(ctx *gin.Context, tx *sqlx.Tx, m } // 铁粉刷新(主播涨价降价后逻辑后更新逻辑) -func (v *Vas) UnlockZoneIronfanshipRefresh(ctx *gin.Context, mid, zid, streamerMid int64) error { - +func (v *Vas) UnlockZoneIronfanshipRefresh(ctx *gin.Context, mid, zid, streamerMid int64) (errcode.ErrCode, error) { + ec := errcode.ErrCodeOk // 开启事务 tx, err := v.store.VasBegin(ctx) if err != nil { logger.Error("vas begin fail, err: %v", err) - return err + ec = errcode.ErrcodeZoneIronFansRefreshErr + return ec, err } defer func() { @@ -548,8 +550,9 @@ func (v *Vas) UnlockZoneIronfanshipRefresh(ctx *gin.Context, mid, zid, streamerM }() if tx == nil { + ec = errcode.ErrcodeZoneIronFansRefreshErr err := fmt.Errorf("nil tx") - return err + return ec, err } // 获取zid @@ -561,47 +564,54 @@ func (v *Vas) UnlockZoneIronfanshipRefresh(ctx *gin.Context, mid, zid, streamerM } } if zid <= 0 { - return fmt.Errorf("zone not exist, mid: %v, streamerMid: %v", mid, streamerMid) + ec = errcode.ErrcodeZoneIronFansRefreshErr + return ec, 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) + ec = errcode.ErrcodeZoneIronFansRefreshErr + return ec, 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) + ec = errcode.ErrcodeZoneIronFansRefreshErr + return ec, fmt.Errorf("zone unlock not exist, mid: %v, zid: %v", mid, zid) } // 主播涨价后,原用户是否是铁粉 if zUnlock.IsUnlockIronfanship() { - logger.Info("UnlockZoneIronFanShipRefresh, users are already iron fans") - return nil + logger.Info("UnlockZoneIronFanShipRefresh, users are already iron fans, mid: %v, streamerMid: %v", mid, streamerMid) + ec = errcode.ErrcodeZoneIronFansAlreadyUnLock + return ec, nil } if zUnlock.GetConsume() < zVas.IronfanshipPrice { // 主播降价后消费额是否达到了解锁铁粉的消费额 - return fmt.Errorf("not reach ironfan unlock consume, mid: %v, zid: %v", mid, zid) + ec = errcode.ErrcodeZoneIronFansNotUnLock + return ec, nil } // 解锁铁粉 err = v.MustUnlockIronfanship(ctx, tx, mid, zid, -1, "ironfan", dbstruct.ZoneUnlockTypeReachConsume) if err != nil { logger.Error("UnlockZoneIronfanshipRefresh MustUnlockIronfanship fail, mid: %v, zid: %v, err: %v", mid, zid, err) - return err + ec = errcode.ErrcodeZoneIronFansRefreshErr + return ec, err } // 添加到空间成员 err = v.store.AddZoneMember(ctx, tx, mid, zid, dbstruct.ZoneMemberTypeIronfan) if err != nil { logger.Error("UnlockZoneIronfanshipRefresh AddZoneMember normal fail, mid: %v, zid: %v, err: %v", mid, zid, err) - return err + ec = errcode.ErrcodeZoneIronFansRefreshErr + return ec, err } - return nil + return ec, nil } type IncomeInfo struct { diff --git a/app/mix/service/utilservice.go b/app/mix/service/utilservice.go index 8504aa06..dca9e7ff 100644 --- a/app/mix/service/utilservice.go +++ b/app/mix/service/utilservice.go @@ -2209,13 +2209,13 @@ func (s *Service) UtilEncryptVideosForZoneMomentVOs(ctx *gin.Context, list []*zo } } -func (s *Service) FansIdentityRefresh(ctx *gin.Context, req *zonemomentproto.ApiFansIdentityRefreshReq) error { +func (s *Service) FansIdentityRefresh(ctx *gin.Context, req *zonemomentproto.ApiFansIdentityRefreshReq) (errcode.ErrCode, error) { - err := _DefaultVas.FansIdentityRefresh(ctx, req.Mid, req.Zid) + ec, err := _DefaultVas.FansIdentityRefresh(ctx, req.Mid, req.Zid) if err != nil { logger.Error("util service FansIdentityRefresh failed, err: %v", err) - return err + return ec, err } - return nil + return ec, nil }