Merge pull request 'feature-fans_identity_refresh-wxy-20241216' (#923) from feature-fans_identity_refresh-wxy-20241216 into main
Reviewed-on: https://git.wishpal.cn/wishpal_ironfan/service/pulls/923
This commit is contained in:
commit
f130609635
|
@ -189,10 +189,14 @@ var ErrCodeMsgMap = map[ErrCode]string{
|
|||
ErrCodeAccountCancellationSrvFail: "账户注销服务错误",
|
||||
ErrCodeAccountCancellationNotExist: "账户注销不存在",
|
||||
|
||||
ErrCodeZoneSrvFail: "空间服务错误",
|
||||
ErrCodeZoneNotExist: "空间不存在",
|
||||
ErrCodeUnlockedZone: "访客未解锁该空间",
|
||||
ErrCodeZoneDuplicateKey: "您已创建空间",
|
||||
ErrCodeZoneSrvFail: "空间服务错误",
|
||||
ErrCodeZoneNotExist: "空间不存在",
|
||||
ErrCodeUnlockedZone: "访客未解锁该空间",
|
||||
ErrCodeZoneDuplicateKey: "您已创建空间",
|
||||
ErrcodeZoneIronFansUnLock: "您已解锁空间铁粉",
|
||||
ErrcodeZoneIronFansAlreadyUnLock: "您已是空间铁粉",
|
||||
ErrcodeZoneIronFansNotUnLock: "暂不满足铁粉条件",
|
||||
ErrcodeZoneIronFansRefreshErr: "铁粉刷新失败,服务错误",
|
||||
|
||||
ErrCodeZoneMomentSrvFail: "私密圈动态服务错误",
|
||||
ErrCodeZoneMomentNotExist: "私密圈动态不存在",
|
||||
|
@ -524,11 +528,15 @@ const (
|
|||
ErrCodeAccountPunishmentStreamerOnly ErrCode = -32007 // 该账号处罚仅能对主播进行
|
||||
|
||||
// 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 // 空间未解锁铁粉
|
||||
ErrcodeZoneIronFansAlreadyUnLock ErrCode = -33007 // 已经是空间铁粉
|
||||
ErrcodeZoneIronFansRefreshErr ErrCode = -33008 // 铁粉刷新服务错误
|
||||
|
||||
// ZoneMoment: 34xxx
|
||||
ErrCodeZoneMomentSrvOk ErrCode = ErrCodeOk
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -269,6 +269,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())
|
||||
|
|
|
@ -247,3 +247,27 @@ 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
|
||||
}
|
||||
|
||||
ec, err := service.DefaultService.FansIdentityRefresh(ctx, req)
|
||||
if err != nil {
|
||||
logger.Error("ApiFansIdentityRefresh fail, req: %v, err: %v", util.ToJson(req), err)
|
||||
ReplyErrCodeMsg(ctx, ec)
|
||||
return
|
||||
}
|
||||
|
||||
if ec != errcode.ErrCodeOk {
|
||||
ReplyErrCodeMsg(ctx, ec)
|
||||
return
|
||||
}
|
||||
|
||||
ReplyOk(ctx, nil)
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
@ -4296,3 +4297,14 @@ func (v *Vas) UnilaterallyWithdrawAccomplish(ctx *gin.Context, orderId string) (
|
|||
|
||||
return
|
||||
}
|
||||
|
||||
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 ec, err
|
||||
}
|
||||
|
||||
return ec, nil
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
@ -529,6 +530,90 @@ func (v *Vas) UnlockZoneIronfanshipReachConsume(ctx *gin.Context, tx *sqlx.Tx, m
|
|||
return nil
|
||||
}
|
||||
|
||||
// 铁粉刷新(主播涨价降价后逻辑后更新逻辑)
|
||||
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)
|
||||
ec = errcode.ErrcodeZoneIronFansRefreshErr
|
||||
return ec, err
|
||||
}
|
||||
|
||||
defer func() {
|
||||
errTx := v.store.DealTxCR(tx, err)
|
||||
if errTx != nil {
|
||||
logger.Error("DealTxCR fail, err: %v", errTx)
|
||||
return
|
||||
}
|
||||
}()
|
||||
|
||||
if tx == nil {
|
||||
ec = errcode.ErrcodeZoneIronFansRefreshErr
|
||||
err := fmt.Errorf("nil tx")
|
||||
return ec, err
|
||||
}
|
||||
|
||||
// 获取zid
|
||||
if zid <= 0 && streamerMid > 0 {
|
||||
// 获取空间id
|
||||
zone, _ := v.zone.GetByMid(ctx, streamerMid)
|
||||
if zone != nil {
|
||||
zid = zone.GetId()
|
||||
}
|
||||
}
|
||||
if zid <= 0 {
|
||||
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 {
|
||||
ec = errcode.ErrcodeZoneIronFansRefreshErr
|
||||
return ec, fmt.Errorf("zone vas not exist, zid: %v", zid)
|
||||
}
|
||||
|
||||
// 获取空间消费信息
|
||||
zUnlock, exists := v.CheckZoneUnlockExist(ctx, tx, mid, zid)
|
||||
if !exists {
|
||||
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, mid: %v, streamerMid: %v", mid, streamerMid)
|
||||
ec = errcode.ErrcodeZoneIronFansAlreadyUnLock
|
||||
return ec, nil
|
||||
}
|
||||
|
||||
if zUnlock.GetConsume() < zVas.IronfanshipPrice {
|
||||
// 主播降价后消费额是否达到了解锁铁粉的消费额
|
||||
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)
|
||||
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)
|
||||
ec = errcode.ErrcodeZoneIronFansRefreshErr
|
||||
return ec, err
|
||||
}
|
||||
|
||||
return ec, nil
|
||||
}
|
||||
|
||||
type IncomeInfo struct {
|
||||
Mid int64 `json:"mid"` // mid
|
||||
IncomeSType int32 `json:"income_stype"` // 收入类类型
|
||||
|
|
|
@ -2208,3 +2208,14 @@ func (s *Service) UtilEncryptVideosForZoneMomentVOs(ctx *gin.Context, list []*zo
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Service) FansIdentityRefresh(ctx *gin.Context, req *zonemomentproto.ApiFansIdentityRefreshReq) (errcode.ErrCode, error) {
|
||||
|
||||
ec, err := _DefaultVas.FansIdentityRefresh(ctx, req.Mid, req.Zid)
|
||||
if err != nil {
|
||||
logger.Error("util service FansIdentityRefresh failed, err: %v", err)
|
||||
return ec, err
|
||||
}
|
||||
|
||||
return ec, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue