This commit is contained in:
lwl0608 2024-08-14 11:01:03 +08:00
parent dd7b04a6df
commit b6338fb391
7 changed files with 118 additions and 0 deletions

View File

@ -326,3 +326,14 @@ type IncomePageResp struct {
base.BaseResponse
Data *IncomePageData `json:"data"`
}
// 获取空间成员
type SearchMemberReq struct {
base.BaseRequest
MemberType int32 `json:"member_type"`
MemberUserId int64 `json:"member_user_id"`
}
type SearchMemberData struct {
List []*dbstruct.Account `json:"list"`
}

View File

@ -247,6 +247,7 @@ func Init(r *gin.Engine) {
apiZoneGroup.POST("refund_page", middleware.JSONParamValidator(vasproto.ZoneRefundPageReq{}), middleware.JwtAuthenticator(), ZoneRefundPage)
apiZoneGroup.POST("refund", middleware.JSONParamValidator(vasproto.ZoneRefundReq{}), middleware.JwtAuthenticator(), ZoneRefund)
apiZoneGroup.POST("member_list", middleware.JSONParamValidator(vasproto.GetZoneMemberListReq{}), middleware.JwtAuthenticator(), ZoneMemberList)
apiZoneGroup.POST("search_zone_member", middleware.JSONParamValidator(vasproto.SearchMemberReq{}), middleware.JwtAuthenticator(), SearchZoneMember)
apiZoneGroup.POST("free_join", middleware.JSONParamValidator(vasproto.ZoneFreeJoinReq{}), middleware.JwtAuthenticator(), ZoneFreeJoin)
apiZoneGroup.POST("exit", middleware.JSONParamValidator(vasproto.ZoneExitReq{}), middleware.JwtAuthenticator(), ZoneExit)

View File

@ -198,3 +198,26 @@ func ZoneMomentOrderList(ctx *gin.Context) {
}
ReplyOk(ctx, data)
}
func SearchZoneMember(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*vasproto.SearchMemberReq)
if req.Mid <= 0 || req.MemberUserId <= 0 {
logger.Error("SearchZoneMember, invalid param, req: %v", util.ToJson(req))
ReplyErrCodeMsg(ctx, errcode.ErrCodeBadParam)
return
}
list, ec, err := service.DefaultService.SearchZoneMember(ctx, req)
if ec != errcode.ErrCodeVasSrvOk {
logger.Error("SearchZoneMember fail, req: %v, ec: %v", util.ToJson(req), ec)
if ec == errcode.ErrCodeVasSrvFail && err != nil {
ReplyErrorMsg(ctx, err.Error())
return
}
ReplyErrCodeMsg(ctx, ec)
return
}
data := &vasproto.SearchMemberData{
List: list,
}
ReplyOk(ctx, data)
}

View File

@ -444,6 +444,26 @@ func (m *Mysql) GetZoneMemberList(ctx *gin.Context, tx *sqlx.Tx, zid int64, memT
return
}
// 获取空间成员列表
func (m *Mysql) SearchZoneMember(ctx *gin.Context, tx *sqlx.Tx, zid, memMid int64, memType int32) (list []*dbstruct.ZoneMember, err error) {
list = make([]*dbstruct.ZoneMember, 0)
sqlStr := fmt.Sprintf(fmt.Sprintf("select * from %s where zid=? and mid=? and member_type=?", TableVasZoneMember))
if tx != nil {
err = tx.SelectContext(ctx, &list, sqlStr, zid, memType, memMid)
} else {
db := m.getDBVas()
err = db.SelectContext(ctx, &list, sqlStr, zid, memType, memMid)
}
if err == sql.ErrNoRows {
err = nil
return
}
if err != nil {
return
}
return
}
// 空间退款记录
func (m *Mysql) CreateZoneRefundHis(ctx *gin.Context, tx *sqlx.Tx, o *dbstruct.ZoneRefundHis) error {
var err error

View File

@ -997,6 +997,15 @@ func (v *Vas) GetZoneMemberList(ctx *gin.Context, zid int64, memType int32) (lis
return
}
// 空间成员列表
func (v *Vas) SearchZoneMember(ctx *gin.Context, zid, memMid int64, memType int32) (list []*dbstruct.ZoneMember, err error) {
list, err = v.store.SearchZoneMember(ctx, nil, zid, memMid, memType)
if err != nil {
return
}
return
}
func (v *Vas) MustUnlockAdmission(ctx *gin.Context, tx *sqlx.Tx, mid, zid, until int64, orderId string, unlockType int32) error {
// 检查解锁
_, exist := v.CheckZoneUnlockExist(ctx, tx, mid, zid)

View File

@ -1257,3 +1257,56 @@ func (s *Service) OpRollbackZoneAdmissionExitStatus(ctx *gin.Context, req *zonep
logger.Info("RollbackZoneAdmissionExitStatus success, uid: %v, suid: %v, mid: %v, sMid: %v, zu: %v", req.Userid, req.StreamerUserid, uMid, sMid, util.ToJson(zu))
return
}
func (s *Service) SearchZoneMember(ctx *gin.Context, req *vasproto.SearchMemberReq) (list []*dbstruct.Account, ec errcode.ErrCode, err error) {
defer func() {
ec, err = errs.DealVasErr(err)
}()
list = make([]*dbstruct.Account, 0)
var (
streamerMid = req.Mid
memUserId = req.MemberUserId
)
// 获取主播空间
zone, _ := _DefaultZone.GetByMid(ctx, streamerMid)
if zone == nil {
err = fmt.Errorf("主播空间不存在")
return
}
zid := zone.GetId()
// 通过userid拿用户mid
acnt, _ := _DefaultAccount.OpListByUserId(ctx, &accountproto.OpListByUserIdReq{
UserId: goproto.Int64(memUserId),
})
if acnt == nil {
err = fmt.Errorf("成员不存在")
return
}
memMid := acnt.GetMid()
// 获取成员列表
zmList, err := _DefaultVas.SearchZoneMember(ctx, zid, memMid, req.MemberType)
ec, err = errs.DealVasErr(err)
if err != nil {
logger.Error("ZoneRefund fail, err: %v", err)
return
}
mids := make([]int64, 0)
for _, zm := range zmList {
mids = append(mids, zm.GetMid())
}
logger.Info("SearchZoneMember, zid: %v, typ: %v, memUserId: %v, mids: %v, zmList: %v", zid, req.MemberType, memUserId, mids, util.ToJson(zmList))
// 获取用户信息
acntMap, _ := _DefaultAccount.GetAccountMapByMids(ctx, mids)
logger.Info("GetAccountMapByMids, zid: %v, typ: %v, acntMap: %v", zid, req.MemberType, util.ToJson(acntMap))
for _, zm := range zmList {
mid := zm.GetMid()
if acnt, ok := acntMap[mid]; ok {
list = append(list, acnt)
}
}
return
}

View File

@ -236,6 +236,7 @@ CREATE TABLE `vas_zone_member`
);
CREATE INDEX ix_mid_zid_member_type ON vas_zone_member (mid,zid,member_type);
CREATE INDEX ix_zid_member_type ON vas_zone_member (zid,member_type);
CREATE INDEX ix_zid_mid_member_type ON vas_zone_member (zid,mid,member_type);
-- 空间动态解锁
CREATE TABLE `vas_zone_moment_unlock`