Merge pull request 'by Robin at 20240912; add streamer cancel proc' (#732) from feat-IRONFANS-213-Robin into main

Reviewed-on: http://121.41.31.146:3000/wishpal_ironfan/service/pulls/732
This commit is contained in:
chenhao 2024-09-12 15:19:39 +08:00
commit 5c795206d0
4 changed files with 55 additions and 2 deletions

View File

@ -2871,6 +2871,22 @@ func (m *Mongo) GetStreamerList(ctx *gin.Context, req *streamerproto.OpListReq)
return list, err
}
func (m *Mongo) UpdateStreamerByMids(ctx *gin.Context, streamer *dbstruct.Streamer, mids []int64) error {
col := m.getColStreamer()
set := util.EntityToM(streamer)
set["ut"] = time.Now().Unix()
filter := qmgo.M{
"mid": qmgo.M{
"$in": mids,
},
}
up := qmgo.M{
"$set": set,
}
_, err := col.UpdateAll(ctx, filter, up)
return err
}
func (m *Mongo) CreateBatchStreamer(ctx *gin.Context, streamers []*dbstruct.Streamer) error {
col := m.getColStreamer()
_, err := col.InsertMany(ctx, streamers)

View File

@ -138,3 +138,12 @@ func (p *Streamer) OpCreateBatch(ctx *gin.Context, req *streamerproto.OpCreateBa
}
return nil
}
func (p *Streamer) OpUpdateByMids(ctx *gin.Context, streamer *dbstruct.Streamer, mids []int64) error {
err := p.store.UpdateStreamerByMids(ctx, streamer, mids)
if err != nil {
logger.Error("UpdateStreamerByMids fail, err: %v", err)
return err
}
return nil
}

View File

@ -626,6 +626,31 @@ func (s *Service) utilCancelAccountByMids(ctx *gin.Context, midList []int64) err
}
}
// 针对主播账户隐藏streamer并从es表中删除
streamerMids := make([]int64, 0)
for _, acct := range accounts {
if acct.GetRole() == consts.Streamer {
streamerMids = append(streamerMids, acct.GetMid())
}
}
if len(streamerMids) > 0 {
err = _DefaultStreamer.OpUpdateByMids(ctx, &dbstruct.Streamer{
IsHided: goproto.Int64(consts.IsHided_Yes),
}, streamerMids)
if err != nil {
logger.Error("_DefaultStreamer OpUpdateByMids fail, err: %v", err)
return err
}
err = _DefaultStreamerAcct.OpUpdateSelectivelyByMids(ctx, &dbstruct.EsStreamerAcctUpdater{
DelFlag: goproto.Int64(consts.Deleted),
}, streamerMids)
if err != nil {
logger.Error("_DefaultStreamerAcct OpUpdateSelectivelyByMids fail, err: %v", err)
return err
}
}
return nil
}

View File

@ -31,8 +31,11 @@ type EsStreamerAcctUpdater struct {
City *string `json:"city" bson:"city"` // 所在城市
Constellation *string `json:"constellation" bson:"constellation"` // 星座
LastZoneMomentCreateDayStart *int64 `json:"last_zone_moment_create_day_start" bson:"last_zone_moment_create_day_start"` // 最后空间动态创建日始整点
WechatCoinPrice *int64 `json:"wechat_coin_price"` // 微信金币价格
ZoneAdmissionPrice *int64 `json:"zone_admission_price"` // 空间解锁价格, 单位: 分
WechatCoinPrice *int64 `json:"wechat_coin_price" bson:"wechat_coin_price"` // 微信金币价格
ZoneAdmissionPrice *int64 `json:"zone_admission_price" bson:"zone_admission_price"`
Ct *int64 `json:"ct" bson:"ct"`
Ut *int64 `json:"ut" bson:"ut"`
DelFlag *int64 `json:"del_flag" bson:"del_flag"`
}
func (p *EsStreamerAcctUpdater) GetMid() int64 {