Commit e8452c4e authored by hujiebin's avatar hujiebin

Merge branch 'feature/roomInfo-billboard' into test

parents 028a1262 47ef3686
...@@ -908,16 +908,122 @@ func GetUserDetail(model *domain.Model, userId mysql.ID, myUserId mysql.ID) (*Cv ...@@ -908,16 +908,122 @@ func GetUserDetail(model *domain.Model, userId mysql.ID, myUserId mysql.ID) (*Cv
noble, superManagerMap[userId], myGroups, phoneInfo, thirdList, cvCountryManager) noble, superManagerMap[userId], myGroups, phoneInfo, thirdList, cvCountryManager)
} }
//群主信息
func GetRoomInfoOwner(model *domain.Model, userId mysql.ID, myUserId mysql.ID) (*CvUserDetail, error) {
model.Log.Infof("GetUserDetail %d begin", userId)
var user user_m.User
var err error
if err = mysql.Db.First(&user, userId).Error; err != nil {
return nil, myerr.WrapErr(err)
}
var wealthUserScore user_m.MatchWealthUserScore
if err := mysql.Db.Model(&user_m.MatchWealthUserScore{}).Where(&user_m.MatchWealthUserScore{UserId: userId}).First(&wealthUserScore).Error; err != nil {
if err != nil {
if err == gorm.ErrRecordNotFound {
wealthUserScore = user_m.MatchWealthUserScore{
UserId: userId,
Score: 0,
Grade: 0,
}
} else {
return nil, myerr.WrapErr(err)
}
}
}
var charmUserScore user_m.MatchCharmUserScore
if err := mysql.Db.Model(&user_m.MatchCharmUserScore{}).Where(&user_m.MatchCharmUserScore{
UserId: userId,
}).First(&charmUserScore).Error; err != nil {
if err != nil {
if err == gorm.ErrRecordNotFound {
charmUserScore = user_m.MatchCharmUserScore{
UserId: userId,
Score: 0,
Grade: 0,
}
} else {
return nil, myerr.WrapErr(err)
}
}
}
isVip, expireTime, err := user_m.IsVip(userId)
if err != nil {
return nil, myerr.WrapErr(err)
}
svip, err := rpc.GetUserSvip(model, userId)
if err != nil {
return nil, myerr.WrapErr(err)
}
medals := make(map[uint64][]uint32, 0)
medals[userId], err = user_m.GetUserMedalMerge(model.Log, mysql.Db, userId)
if err != nil {
return nil, err
}
medals, medalInfo, err := medal_cv.GetMedalInfoMap(mysql.Db, medals)
if err != nil {
return nil, err
}
groupPowerId, groupPowerName, err := groupPower_m.GetUserGroupPower(model, userId)
if err != nil {
return nil, err
}
powers := map[mysql.ID]uint64{userId: groupPowerId}
powerNames := map[mysql.ID]string{userId: groupPowerName}
groupPowerInfos, err := groupPower_m.MGetGroupPowerInfoMap(model, []mysql.ID{groupPowerId})
groupPowerGrades, err := groupPower_m.MGetGroupPowerGrade(model, []mysql.ID{groupPowerId})
groupPowerUsers, err := groupPower_m.MGetGroupPowerUsers(model, []mysql.ID{groupPowerId})
var memberMax int
grade := groupPowerGrades[groupPowerId].Grade
if grade >= groupPower_e.GroupPowerGrade0 && grade <= groupPower_e.GroupPowerGradeMax {
if grade == groupPower_e.GroupPowerGrade0 {
memberMax = 300
}
if grade == groupPower_e.GroupPowerGrade1 {
memberMax = 500
}
if grade == groupPower_e.GroupPowerGrade2 {
memberMax = 800
}
if grade == groupPower_e.GroupPowerGrade3 {
memberMax = 1200
}
}
memberNum := len(groupPowerUsers[groupPowerId])
if memberNum > memberMax {
memberMax = memberNum
}
groupPowerMembers := [2]int{memberNum, memberMax} // 0->memberNum 1->memberLimit
noble, err := noble_m.FindActiveNoble(mysql.Db, userId)
if err != nil {
return nil, err
}
return userToDetailOne(model, &user, myUserId, nil, false, false,
map[mysql.ID]Relation{}, isVip, expireTime, svip, nil, property_cv.CvProperty{}, wealthUserScore.Grade, charmUserScore.Grade,
0, medals[userId], medalInfo[userId], "", powers[userId], powerNames[userId], groupPowerInfos[groupPowerId], groupPowerGrades[groupPowerId], groupPowerMembers,
noble, false, nil, nil, nil, nil)
}
// 单用户版,简化参数 // 单用户版,简化参数
func userToDetailOne(model *domain.Model, user *user_m.User, myUserId mysql.ID, userTradeUnion *user_m.UserTradeUnion, isLike bool, likeMe bool, hvMap map[mysql.ID]Relation, func userToDetailOne(model *domain.Model, user *user_m.User, myUserId mysql.ID, userTradeUnion *user_m.UserTradeUnion, isLike bool, likeMe bool, hvMap map[mysql.ID]Relation,
isVip bool, vipExpireTime *int64, svip rpc.CvSvip, headwear *headwear_cv.CvHeadwear, ride property_cv.CvProperty, wealthGrade uint32, charmGrade uint32, activityGrade uint32, isVip bool, vipExpireTime *int64, svip rpc.CvSvip, headwear *headwear_cv.CvHeadwear, ride property_cv.CvProperty, wealthGrade uint32, charmGrade uint32, activityGrade uint32,
medals []uint32, medalInfo []medal_cv.CvMedal, room string, power uint64, powerName string, powerInfo groupPower_m.GroupPowerInfo, grade groupPower_m.GroupPowerGrade, members [2]int, noble *noble_m.UserNoble, isOfficialStaff bool, medals []uint32, medalInfo []medal_cv.CvMedal, room string, power uint64, powerName string, powerInfo groupPower_m.GroupPowerInfo, grade groupPower_m.GroupPowerGrade, members [2]int, noble *noble_m.UserNoble, isOfficialStaff bool,
myGroups []group_m.GroupInfo, phoneInfo *user_m.UserPhoneInfo, thirdList []int8, countryManager *country_cv.CVCountryManager) (*CvUserDetail, error) { myGroups []group_m.GroupInfo, phoneInfo *user_m.UserPhoneInfo, thirdList []int8, countryManager *country_cv.CVCountryManager) (*CvUserDetail, error) {
room, err := group_m.ToTxGroupId(model, room) if len(room) > 0 {
if err != nil { var err error
model.Log.Warnf("ToTxGroupId failed for %s, err:%v", room, err) room, err = group_m.ToTxGroupId(model, room)
room = "" if err != nil {
model.Log.Warnf("ToTxGroupId failed for %s, err:%v", room, err)
room = ""
}
} }
cvUserDetail := &CvUserDetail{ cvUserDetail := &CvUserDetail{
......
...@@ -374,7 +374,7 @@ func PluginReady(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -374,7 +374,7 @@ func PluginReady(c *gin.Context) (*mycontext.MyContext, error) {
// @Router /v1/imGroup/roomInfo/{groupId} [get] // @Router /v1/imGroup/roomInfo/{groupId} [get]
func GetRoomInfo(c *gin.Context) (*mycontext.MyContext, error) { func GetRoomInfo(c *gin.Context) (*mycontext.MyContext, error) {
myContext := mycontext.CreateMyContext(c.Keys) myContext := mycontext.CreateMyContext(c.Keys)
start := time.Now()
groupId := c.Param("groupId") groupId := c.Param("groupId")
if len(groupId) <= 0 { if len(groupId) <= 0 {
return myContext, myerr.NewSysError("groupId 为必填项") return myContext, myerr.NewSysError("groupId 为必填项")
...@@ -407,7 +407,8 @@ func GetRoomInfo(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -407,7 +407,8 @@ func GetRoomInfo(c *gin.Context) (*mycontext.MyContext, error) {
deviceType, appVersion := cast.ToString(_deviceType), cast.ToString(_appVersion) deviceType, appVersion := cast.ToString(_deviceType), cast.ToString(_appVersion)
vc := version_m.GetVersionControlByPlatform(model, deviceType) vc := version_m.GetVersionControlByPlatform(model, deviceType)
allow, err := utils.CompareVersion(appVersion, fmt.Sprintf("<= %s", vc.AuditVersion)) allow, err := utils.CompareVersion(appVersion, fmt.Sprintf("<= %s", vc.AuditVersion))
model.Log.Infof("GetRoomInfo CompareVersion appVersion:%v,auditVersion:%v,allow:%v,err:%v", appVersion, vc.AuditVersion, allow, err)
model.Log.Infof("GetRoomInfo cost 0:%v", time.Now().Sub(start).Seconds())
themeUrl := "" themeUrl := ""
var themeId uint64 = 0 var themeId uint64 = 0
...@@ -464,7 +465,8 @@ func GetRoomInfo(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -464,7 +465,8 @@ func GetRoomInfo(c *gin.Context) (*mycontext.MyContext, error) {
}, },
} }
roles, _, err := group_m.GetRolesInGroup(model, groupInfo.ImGroupId) model.Log.Infof("GetRoomInfo cost 1:%v", time.Now().Sub(start).Seconds())
roles, orderList, err := group_m.GetRolesInGroup(model, groupId)
if err != nil { if err != nil {
return myContext, err return myContext, err
} }
...@@ -507,11 +509,7 @@ func GetRoomInfo(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -507,11 +509,7 @@ func GetRoomInfo(c *gin.Context) (*mycontext.MyContext, error) {
} }
} }
roles, orderList, err := group_m.GetRolesInGroup(model, groupId) model.Log.Infof("GetRoomInfo cost 2:%v", time.Now().Sub(start).Seconds())
if err != nil {
return myContext, err
}
users, err := user_cv.GetUserTinyMap(orderList) users, err := user_cv.GetUserTinyMap(orderList)
if err != nil { if err != nil {
return myContext, err return myContext, err
...@@ -549,6 +547,7 @@ func GetRoomInfo(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -549,6 +547,7 @@ func GetRoomInfo(c *gin.Context) (*mycontext.MyContext, error) {
} }
result.WelcomeText = strings.ReplaceAll(result.WelcomeText, "@%s", "") result.WelcomeText = strings.ReplaceAll(result.WelcomeText, "@%s", "")
model.Log.Infof("GetRoomInfo cost 3:%v", time.Now().Sub(start).Seconds())
// 补上房间流水勋章 // 补上房间流水勋章
var pe *medal_cv.PicElement var pe *medal_cv.PicElement
result.TotalConsume, pe, err = medal_cv.GetGroupConsumeMedal(model, groupId) result.TotalConsume, pe, err = medal_cv.GetGroupConsumeMedal(model, groupId)
...@@ -558,7 +557,7 @@ func GetRoomInfo(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -558,7 +557,7 @@ func GetRoomInfo(c *gin.Context) (*mycontext.MyContext, error) {
result.GroupMedals = append(result.GroupMedals, medal_cv.PicElement{PicUrl: pe.PicUrl}) result.GroupMedals = append(result.GroupMedals, medal_cv.PicElement{PicUrl: pe.PicUrl})
} }
resMedals := []res_m.ResMedal{} var resMedals []res_m.ResMedal
err = mysql.Db.Model(&res_m.ResMedal{}). err = mysql.Db.Model(&res_m.ResMedal{}).
Joins("INNER JOIN group_medal m ON m.res_medal_id = res_medal.id"). Joins("INNER JOIN group_medal m ON m.res_medal_id = res_medal.id").
Where("m.im_group_id = ?", groupId). Where("m.im_group_id = ?", groupId).
...@@ -573,8 +572,9 @@ func GetRoomInfo(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -573,8 +572,9 @@ func GetRoomInfo(c *gin.Context) (*mycontext.MyContext, error) {
}) })
} }
} else { } else {
model.Log.Infof("GetRoomInfo: group_medal: %s", err.Error()) model.Log.Errorf("GetRoomInfo: group_medal: %s", err.Error())
} }
model.Log.Infof("GetRoomInfo cost 4:%v", time.Now().Sub(start).Seconds())
// 获取国家信息 // 获取国家信息
country, area, err := user_m.GetUserCountryArea(model, userId) country, area, err := user_m.GetUserCountryArea(model, userId)
if err != nil { if err != nil {
...@@ -601,18 +601,21 @@ func GetRoomInfo(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -601,18 +601,21 @@ func GetRoomInfo(c *gin.Context) (*mycontext.MyContext, error) {
}) })
} }
} else { } else {
model.Log.Infof("GetRoomInfo: GetRoomBanners: %s", err.Error()) model.Log.Errorf("GetRoomInfo: GetRoomBanners: %s", err.Error())
} }
result.LuckyWheel, err = group_cv.GetLuckWheelState(model, groupId) model.Log.Infof("GetRoomInfo cost 5:%v", time.Now().Sub(start).Seconds())
result.LuckyWheel, err = group_cv.GetLuckWheelState(model, groupId) // todo check 耗时
if err != nil { if err != nil {
model.Log.Infof("GetRoomInfo: GetLuckWheelState: %s", err.Error()) model.Log.Errorf("GetRoomInfo: GetLuckWheelState: %s", err.Error())
} }
model.Log.Infof("GetRoomInfo cost 6:%v", time.Now().Sub(start).Seconds())
// 群主的详情 // 群主的详情
owner, err := user_cv.GetUserDetail(model, groupInfo.Owner, userId) owner, err := user_cv.GetRoomInfoOwner(model, groupInfo.Owner, userId)
result.Owner = user_cv.UserDetailToRoomInfoOwner(owner) result.Owner = user_cv.UserDetailToRoomInfoOwner(owner)
if err != nil { if err != nil {
model.Log.Errorf("GetRoomInfo: GetUserBase: %s", err.Error()) model.Log.Errorf("GetRoomInfo: GetUserBase: %s", err.Error())
} }
model.Log.Infof("GetRoomInfo cost 7:%v", time.Now().Sub(start).Seconds())
// 进场特效类型 // 进场特效类型
var entryEffectType int // 进场特效类型 1: CP 2:神秘人 3:贵族 4:vip ,顺序从小到大 var entryEffectType int // 进场特效类型 1: CP 2:神秘人 3:贵族 4:vip ,顺序从小到大
...@@ -639,6 +642,7 @@ func GetRoomInfo(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -639,6 +642,7 @@ func GetRoomInfo(c *gin.Context) (*mycontext.MyContext, error) {
entryEffectType = 1 entryEffectType = 1
} }
result.EntryEffectType = entryEffectType result.EntryEffectType = entryEffectType
model.Log.Infof("GetRoomInfo cost 8:%v", time.Now().Sub(start).Seconds())
resp.ResponseOk(c, result) resp.ResponseOk(c, result)
return myContext, nil return myContext, nil
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment