diff --git a/_const/enum/groupPower_e/enum.go b/_const/enum/groupPower_e/enum.go index a9e4a84e0c26ccc9d55cd45718cf8acdbce6f775..bdc148ea91bdccfefd1224d7fa916d851c6c7c8b 100644 --- a/_const/enum/groupPower_e/enum.go +++ b/_const/enum/groupPower_e/enum.go @@ -1,9 +1,7 @@ package groupPower_e -import "git.hilo.cn/hilo-common/resource/mysql" - //国家势力状态 -type GroupPowerStatus = mysql.Type +type GroupPowerStatus = uint8 const ( //上架 @@ -15,7 +13,7 @@ const ( ) //国家势力用户角色 -type GroupPowerUserRole = mysql.Type +type GroupPowerUserRole = uint8 const ( //普通用户 @@ -27,7 +25,7 @@ const ( ) //国家势力排行榜类型 -type GroupPowerRankType = mysql.Type +type GroupPowerRankType = uint8 const ( GroupPowerRankTypeFamous GroupPowerRankType = 1 @@ -36,7 +34,7 @@ const ( ) //国家势力日志操作类型 -type GroupPowerUserLogType = mysql.Type +type GroupPowerUserLogType = uint8 const ( //加入 @@ -51,7 +49,7 @@ const ( GroupPowerUserLogDissolve GroupPowerUserLogType = 5 ) -type GroupPowerDiamondLogType = mysql.Type +type GroupPowerDiamondLogType = uint8 const ( //群组原因加入 @@ -67,3 +65,7 @@ const ( PowerSuppportAwarded PowerSupportAwardState = 1 // 已经领取 PowerSuppportWaiting PowerSupportAwardState = 2 // 待领取 ) + +const ( + LongestNameplate = 15 +) diff --git a/_const/enum/group_e/enum.go b/_const/enum/group_e/enum.go index 10f7c5bb8402a6207e8a49c367c50cab679babf7..e93adf92381f1de096af77bd6e5e1107bf6db3a9 100644 --- a/_const/enum/group_e/enum.go +++ b/_const/enum/group_e/enum.go @@ -156,3 +156,11 @@ var GROUP_NOBLE4_JOIN_LIMIT uint = 1000 var GROUP_ROLE_PERSONAL_VIEW_LIMIT = 5 var GROUP_MANAGER_LIMIT uint = 30 var GROUP_ADMIN_LIMIT uint = 50 + +type GroupProvider = uint8 + +const ( + // 群组声音供应商 + GroupProvider_SW GroupProvider = 0 // 声网 + GroupProvider_TRTC GroupProvider = 1 // 腾讯trtc +) diff --git a/cv/group_cv/group.go b/cv/group_cv/group.go index 4661d4b42227404976739b9b15783232d819b777..28cb11bcaac52c813f9d02273f72c39f0fc62a04 100644 --- a/cv/group_cv/group.go +++ b/cv/group_cv/group.go @@ -221,6 +221,7 @@ type GroupChannelId struct { Token string `json:"token"` AgoraId uint32 `json:"agoraId"` MicNumType uint8 `json:"micNumType"` + Provider uint8 `json:"provider"` // 供应商 1.声网 2.腾讯trtc } //国籍视图 diff --git a/debug.ini b/debug.ini index 976183cd1a852198b8cf18f1331e3aa96ed04d16..3205478c8644930029b550d4078412daa9ddc844 100644 --- a/debug.ini +++ b/debug.ini @@ -72,6 +72,9 @@ APP_CERTIFICATE=ff29c100a613433db82324e8411eabc8 CUSTOMER_KEY=6b132c0ff7164560a2bc53fda06ea85a CUSTOMER_SECRET=eedad2cd16d24834990d5450ace9f1ce CALLBACK_SECRET=n_ZizS_N8 +[TRTC] +APP_ID=1400548270 +APP_CERTIFICATE=321bd60f73096b059c7350f1cd97d51028850b34fa58c5c0d26bb4a19e783de8 [CHECKOUT] AUTHORIZATION=sk_test_9b5e771c-5a3f-4a8d-a4da-31b19bd43d83 URL=https://api.sandbox.checkout.com/hosted-payments @@ -114,6 +117,8 @@ NOBLE_BUY_IOS=https://h5.whoisamy.shop/action/hiloHtml/22_05_26_buy_nobility/pag GUILD_DATA_URL=https://test.chathot.me/action/hiloHtml/22_10_18_app_data_coins/index.html MGR_GUILD_DATA_URL=https://test.chathot.me/action/hiloHtml/22_10_18_app_data_coins/union.html RANKING_PINK_DIAMOND_URL=https://test.chathot.me/action/activitiesPage/2022_10_17HiloLiveH5/index.html +AGENT_SHARE_URL=https://test.chathot.me/action/hiloHtml/22_05_30_recharge/topup.html?external_id= +AGENT_SHARE_ICON=https://image.whoisamy.shop/hilo/resource/user_transfer1.png [GROUPIM] MSG_SORT_EXPIRE=21600 MSG_SORT_SNAP=300 diff --git a/domain/model/groupPower_m/family.go b/domain/model/groupPower_m/family.go index 9e12e5825c9d7dbbcd11bae25913723945f9a080..dc734ea2a81a74254f7cff19362f500fb6f85046 100644 --- a/domain/model/groupPower_m/family.go +++ b/domain/model/groupPower_m/family.go @@ -140,8 +140,8 @@ func UpdateFamily(model *domain.Model, familyId uint64, name, nameplate, declara if groupPower.ModifyNameplate != mysql.YES { // 同步修改铭牌 n := len([]rune(name)) - if n > 6 { - n = 6 + if n > groupPower_e.LongestNameplate { + n = groupPower_e.LongestNameplate } updateMap["nameplate"] = string([]rune(name[0:n])) } diff --git a/domain/model/groupPower_m/group_power_apply.go b/domain/model/groupPower_m/group_power_apply.go index 9d09a20b3573aa7c74921d684c0f226d61284329..5bed0f25782e8145e6ad2e5047d63ee7b051a5c0 100644 --- a/domain/model/groupPower_m/group_power_apply.go +++ b/domain/model/groupPower_m/group_power_apply.go @@ -2,6 +2,7 @@ package groupPower_m import ( "git.hilo.cn/hilo-common/domain" + "git.hilo.cn/hilo-common/resource/mysql" "gorm.io/gorm" "hilo-group/common" "hilo-group/myerr" @@ -88,3 +89,16 @@ func DelGroupPowerApplyJoinNoDeal(model *domain.Model, userId uint64) error { } return nil } + +// 获取家族申请人数 +// param: isAccept 0:未审核 1:通过 2:拒绝 +func CountGroupPowerApply(model *domain.Model, groupPowerId mysql.ID, isAccept int) (int64, error) { + var cnt int64 + if err := model.DB().Model(GroupPowerApplyJoin{}). + Where("group_power_id = ?", groupPowerId). + Where("is_accept = ?", isAccept).Count(&cnt).Error; err != nil { + model.Log.Errorf("CountGroupPowerApply fail:%v", err) + return cnt, err + } + return cnt, nil +} diff --git a/domain/model/group_m/groupInfo.go b/domain/model/group_m/groupInfo.go index a6b4551aeb6b7ed8a3277ce974ed2cd7edb89bdd..fe9b6f0f55f9876e92f234092335531efa051c44 100644 --- a/domain/model/group_m/groupInfo.go +++ b/domain/model/group_m/groupInfo.go @@ -7,6 +7,7 @@ import ( "git.hilo.cn/hilo-common/utils" "github.com/bluele/gcache" "gorm.io/gorm" + "gorm.io/gorm/clause" "hilo-group/_const/enum/group_e" "hilo-group/myerr" "hilo-group/myerr/bizerr" @@ -566,3 +567,26 @@ func GetFamilyRooms(model *domain.Model, familyId uint64, pageSize, pageIndex in return res, nextIdx, hasNext, nil } + +func IsUseTRTC(model *domain.Model, imGroupId string) bool { + var count int64 + if err := model.DB().Table("group_trtc").Where("im_group_id=?", imGroupId).Count(&count).Error; err != nil { + model.Log.Errorf("IsUseTRTC err:%v, groupId:%s", err, imGroupId) + return false + } + return count > 0 +} + +type GroupTrtc struct { + mysql.Entity + ImGroupId mysql.Str +} + +// 初始化trtc房间 +func InitTRTC(model *domain.Model, imGroupId string) error { + if err := model.DB().Model(GroupTrtc{}).Clauses(clause.OnConflict{DoNothing: true}).Create(&GroupTrtc{ImGroupId: imGroupId}).Error; err != nil { + model.Log.Errorf("InitTRTC err:%v, groupId:%s", err, imGroupId) + return err + } + return nil +} diff --git a/domain/model/mic_m/mic.go b/domain/model/mic_m/mic.go index 64b44ef4ecac3a0a46a476f47b09cc0b8271338f..d83f144c4d8ad7973b2097256d3dd0f42673358b 100644 --- a/domain/model/mic_m/mic.go +++ b/domain/model/mic_m/mic.go @@ -1,6 +1,7 @@ package mic_m import ( + "git.hilo.cn/hilo-common/_const/enum/timezone_e" "git.hilo.cn/hilo-common/domain" "git.hilo.cn/hilo-common/resource/mysql" "git.hilo.cn/hilo-common/utils" @@ -17,14 +18,15 @@ type UserOnMic struct { LastCalTs int64 CreatedTime time.Time `gorm:"->"` UpdatedTime time.Time `gorm:"->"` + Tz timezone_e.Timezone } // 获取用户当日上麦 // 允许返回gorm.ErrRecordNotFound -func GetUserOnMic(model *domain.Model, userId mysql.ID) (*UserOnMic, error) { +func GetUserOnMic(model *domain.Model, userId mysql.ID, tz timezone_e.Timezone) (*UserOnMic, error) { res := new(UserOnMic) day := time.Now().Format("2006-01-02") - if err := model.DB().Where("date = ? AND user_id = ?", day, userId).First(res).Error; err != nil { + if err := model.DB().Where("date = ? AND user_id = ? AND tz = ?", day, userId, tz).First(res).Error; err != nil { return nil, err } return res, nil @@ -34,37 +36,40 @@ func GetUserOnMic(model *domain.Model, userId mysql.ID) (*UserOnMic, error) { // 事务操作 func IncrUserOnMic(model *domain.Model, userId mysql.ID, joinMicTimestamp int64) error { return model.Transaction(func(model *domain.Model) error { - omMic, err := GetUserOnMic(model, userId) - if err != nil && err != gorm.ErrRecordNotFound { - return err - } - curTs := joinMicTimestamp - nowTs := time.Now().Unix() - day0Ts := utils.GetZeroTime(time.Now()).Unix() - if omMic != nil && joinMicTimestamp < omMic.LastCalTs { // 加入的时间比上次计算时间小 - curTs = omMic.LastCalTs - } - // 跨天 - if curTs < day0Ts { - curTs = day0Ts - } - score := nowTs - curTs - day := time.Now().Format("2006-01-02") - onMicNew := &UserOnMic{ - Date: day, - UserId: userId, - Seconds: mysql.Num(score), - LastCalTs: nowTs, - } - if err := model.DB().Model(UserOnMic{}).Clauses(clause.OnConflict{ - Columns: []clause.Column{{Name: "date"}, {Name: "user_id"}}, - DoUpdates: clause.Assignments(map[string]interface{}{ - "seconds": gorm.Expr("seconds + ?", onMicNew.Seconds), - "last_cal_ts": nowTs, - }), - }).Create(onMicNew).Error; err != nil { - model.Log.Errorf("IncrUserOnMic fail:%v", err) - return err + for _, tz := range timezone_e.Timezones { + omMic, err := GetUserOnMic(model, userId, tz) + if err != nil && err != gorm.ErrRecordNotFound { + return err + } + curTs := joinMicTimestamp + nowTs := time.Now().Unix() + day0Ts := utils.GetZeroTime(time.Now().In(timezone_e.TimezoneLocMap[tz])).Unix() + if omMic != nil && joinMicTimestamp < omMic.LastCalTs { // 加入的时间比上次计算时间小 + curTs = omMic.LastCalTs + } + // 跨天 + if curTs < day0Ts { + curTs = day0Ts + } + score := nowTs - curTs + day := time.Now().In(timezone_e.TimezoneLocMap[tz]).Format("2006-01-02") + onMicNew := &UserOnMic{ + Date: day, + UserId: userId, + Seconds: mysql.Num(score), + LastCalTs: nowTs, + Tz: tz, + } + if err := model.DB().Model(UserOnMic{}).Clauses(clause.OnConflict{ + Columns: []clause.Column{{Name: "date"}, {Name: "user_id"}, {Name: "tz"}}, + DoUpdates: clause.Assignments(map[string]interface{}{ + "seconds": gorm.Expr("seconds + ?", onMicNew.Seconds), + "last_cal_ts": nowTs, + }), + }).Create(onMicNew).Error; err != nil { + model.Log.Errorf("IncrUserOnMic fail:%v", err) + return err + } } return nil }) @@ -72,10 +77,25 @@ func IncrUserOnMic(model *domain.Model, userId mysql.ID, joinMicTimestamp int64) // 批量获取用户上麦时长 // @return userId->seconds -func MGetUserOnMicSeconds(model *domain.Model, day string, userIds []uint64) (map[mysql.ID]mysql.Num, error) { +func MGetUserOnMicSeconds(model *domain.Model, day string, tz timezone_e.Timezone, userIds []uint64) (map[mysql.ID]mysql.Num, error) { + var rows []UserOnMic + res := make(map[mysql.ID]mysql.Num) + if err := model.DB().Model(UserOnMic{}).Where("`date`= ? AND tz = ? AND user_id in ?", day, tz, userIds).Find(&rows).Error; err != nil { + model.Log.Errorf("MGetUserOnMic fail:%v", err) + return res, err + } + for _, r := range rows { + res[r.UserId] = r.Seconds + } + return res, nil +} + +// 批量获取用户上麦时长 +// @return userId->seconds +func MGetUserOnMicSecondsRange(model *domain.Model, beginDate, endDate string, tz timezone_e.Timezone, userIds []uint64) (map[mysql.ID]mysql.Num, error) { var rows []UserOnMic res := make(map[mysql.ID]mysql.Num) - if err := model.DB().Model(UserOnMic{}).Where("`date`= ? AND user_id in ?", day, userIds).Find(&rows).Error; err != nil { + if err := model.DB().Model(UserOnMic{}).Where("`date` >= ? AND `date` <= ? AND tz = ? AND user_id in ?", beginDate, endDate, tz, userIds).Find(&rows).Error; err != nil { model.Log.Errorf("MGetUserOnMic fail:%v", err) return res, err } diff --git a/domain/service/group_s/group_op.go b/domain/service/group_s/group_op.go index c547f751a2c1b68bd48c6e187e03d62bc7b78612..6618d9e124d52936b1a38c44a0be1e74e0f444a9 100644 --- a/domain/service/group_s/group_op.go +++ b/domain/service/group_s/group_op.go @@ -6,11 +6,13 @@ import ( "fmt" "git.hilo.cn/hilo-common/domain" "git.hilo.cn/hilo-common/mylogrus" + "git.hilo.cn/hilo-common/resource/config" "git.hilo.cn/hilo-common/resource/mysql" "git.hilo.cn/hilo-common/resource/redisCli" "git.hilo.cn/hilo-common/rpc" "git.hilo.cn/hilo-common/sdk/agora" "git.hilo.cn/hilo-common/sdk/tencentyun" + "git.hilo.cn/hilo-common/sdk/trtc" "git.hilo.cn/hilo-common/utils" "gorm.io/gorm" "hilo-group/_const/enum/group_e" @@ -115,7 +117,7 @@ func (s *GroupService) LeaveGroupMember(model *domain.Model, groupId string, use } //进入房间, 返回channelId, err -func (s *GroupService) GroupIn(userId uint64, externalId string, groupUuid string, password, imei, ip string) (string, string, error) { +func (s *GroupService) GroupIn(userId uint64, externalId string, groupUuid string, password, imei, ip string, provider group_e.GroupProvider) (string, string, error) { var channelId string var token string err := s.svc.Transactional(func() error { @@ -171,7 +173,13 @@ func (s *GroupService) GroupIn(userId uint64, externalId string, groupUuid strin if err != nil { return err } - channelId, token, err = agora.CreateGroupAgora(groupInfo.ChannelId, uint32(userId)) + if provider == group_e.GroupProvider_TRTC { + channelId = groupInfo.ChannelId + token = trtc.CreateGroupTRTCUserSig(userId, config.GetTRTCConfig()) + model.Log.Infof("enter trtc group userId:%v, groupId:%v", userId, groupUuid) + } else { + channelId, token, err = agora.CreateGroupAgora(groupInfo.ChannelId, uint32(userId)) + } if err != nil { return err } else { diff --git a/local.ini b/local.ini index d46aed480fd91ce5e7aab47a378c97006d98d95c..a46fe7acc7d5dcbc3a00b831dd0954b4aae92253 100644 --- a/local.ini +++ b/local.ini @@ -72,6 +72,9 @@ APP_CERTIFICATE=ff29c100a613433db82324e8411eabc8 CUSTOMER_KEY=6b132c0ff7164560a2bc53fda06ea85a CUSTOMER_SECRET=eedad2cd16d24834990d5450ace9f1ce CALLBACK_SECRET=n_ZizS_N8 +[TRTC] +APP_ID=1400548270 +APP_CERTIFICATE=321bd60f73096b059c7350f1cd97d51028850b34fa58c5c0d26bb4a19e783de8 [CHECKOUT] AUTHORIZATION=sk_test_9b5e771c-5a3f-4a8d-a4da-31b19bd43d83 URL=https://api.sandbox.checkout.com/hosted-payments @@ -107,6 +110,8 @@ USER_LEVEL=http://test.chathot.me/action/activityhtml/hiloUserLevel/index.html GROUP_SUPPORT=http://test.chathot.me/action/activityhtml/21_12_06/page.html LUCKY_WHEEL=https://h5.whoisamy.shop/action/activityhtml/21_12_30/page.html NOBLE_BUY_IOS=https://h5.whoisamy.shop/action/hiloHtml/lxt_h5/page.html +AGENT_SHARE_URL= +AGENT_SHARE_ICON= [GROUPIM] MSG_SORT_EXPIRE=43200 MSG_SORT_SNAP=300 diff --git a/mysql/trtc.sql b/mysql/trtc.sql new file mode 100644 index 0000000000000000000000000000000000000000..fdc3fe807e5a9d78cfb9258bf597ce0f9b204cda --- /dev/null +++ b/mysql/trtc.sql @@ -0,0 +1,9 @@ +-CREATE TABLE `group_trtc` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', + `im_group_id` char(32) COLLATE utf8mb4_unicode_ci NOT NULL, + `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + UNIQUE KEY `im_group_id` (`im_group_id`), + KEY `created_time` (`created_time`) USING BTREE + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='使用trtc的群组'; \ No newline at end of file diff --git a/release.ini b/release.ini index 4e7a5683fa44b5826e694d59900842d12ea88a86..ba72927d76fe8c142e8d1a79a34eb4378874b68d 100644 --- a/release.ini +++ b/release.ini @@ -72,6 +72,9 @@ APP_ID=6291d069123642d9929a49c734c50719 APP_CERTIFICATE=d5de40350aa54e60bcdce90c71e9598a CUSTOMER_KEY=6b132c0ff7164560a2bc53fda06ea85a CUSTOMER_SECRET=eedad2cd16d24834990d5450ace9f1ce +[TRTC] +APP_ID=40000066 +APP_CERTIFICATE=3ab68ea5bddc8774d90b8c764ae71188914bd5fd06f30b28790c51e44ca7885c [CHECKOUT] AUTHORIZATION=sk_fca6e213-b7df-4bd7-99f4-7c0a9f7c778c URL=https://api.checkout.com/hosted-payments @@ -115,6 +118,8 @@ NOBLE_BUY_IOS=https://h5.whoisamy.shop/action/hiloHtml/lxt_h5/page.html GUILD_DATA_URL=https://h5.whoisamy.shop/action/hiloHtml/22_10_18_app_data_coins/index.html MGR_GUILD_DATA_URL=https://h5.whoisamy.shop/action/hiloHtml/22_10_18_app_data_coins/union.html RANKING_PINK_DIAMOND_URL=https://h5.whoisamy.shop/action/activitiesPage/2022_10_17HiloLiveH5/index.html +AGENT_SHARE_URL=https://h5.chathot.me/action/hiloHtml/22_05_30_recharge/topup.html?external_id= +AGENT_SHARE_ICON=https://image.whoisamy.shop/hilo/resource/user_transfer1.png [GROUPIM] MSG_SORT_EXPIRE=1209600 MSG_SORT_SNAP=300 diff --git a/route/charge_r/charge.go b/route/charge_r/charge.go index 7007aacce3163fad885b2da29a337428b2ef1eb1..7b6b100d79dff9999a4935b7424ca6e2000e2f2a 100644 --- a/route/charge_r/charge.go +++ b/route/charge_r/charge.go @@ -3,6 +3,7 @@ package charge_r import ( "git.hilo.cn/hilo-common/domain" "git.hilo.cn/hilo-common/mycontext" + "git.hilo.cn/hilo-common/resource/config" "github.com/gin-gonic/gin" "hilo-group/domain/cache/user_c" "hilo-group/domain/service/diamond_s" @@ -35,7 +36,11 @@ func CanShareChargeLink(c *gin.Context) (*mycontext.MyContext, error) { myContext.Log.Errorf("CanShareChargeLink err:%v", err) return myContext, err } + type res struct { + ShareUrl string `json:"shareUrl"` + ShareIcon string `json:"shareIcon"` + } - resp.ResponseOk(c, nil) + resp.ResponseOk(c, res{config.GetH5Config().AGENT_SHARE_URL, config.GetH5Config().AGENT_SHARE_ICON}) return myContext, nil } diff --git a/route/group_power_r/group_power.go b/route/group_power_r/group_power.go index 8210c1419791f11104a163b2c37e2a054f79953b..a809c3839fa5ff49a4a09e20fd585ca8d34317e0 100644 --- a/route/group_power_r/group_power.go +++ b/route/group_power_r/group_power.go @@ -1223,6 +1223,41 @@ func GroupPowerApplyList(c *gin.Context) (*mycontext.MyContext, error) { return myContext, nil } +// @Tags 家族 +// @Summary 申请人数 +// @Success 200 {object} int +// @Router /v1/groupPower/apply/count [get] +func GroupPowerApplyCount(c *gin.Context) (*mycontext.MyContext, error) { + myContext := mycontext.CreateMyContext(c.Keys) + userId, err := req.GetUserId(c) + if err != nil { + return myContext, err + } + model := domain.CreateModelContext(myContext) + + // 判断是否加入了家族 + gpU := groupPower_m.GroupPowerUser{UserId: userId} + myGroupPUser, err := gpU.GetGroupPowerUser(model) + if err != nil { + return myContext, err + } + // 操作者是否加入了家族,是否有操作权限 + if myGroupPUser == nil || myGroupPUser.ID == 0 { + return myContext, bizerr.GroupPowerHaveNoJoin + } + if myGroupPUser.Role == 0 || myGroupPUser.Role == groupPower_e.GroupPowerUserRoleUser { + return myContext, bizerr.GroupPowerHaveNoPower + } + // 申请人数 + cnt, err := groupPower_m.CountGroupPowerApply(model, myGroupPUser.GroupPowerId, 0) + if err != nil { + return myContext, err + } + + resp.ResponseOk(c, cnt) + return myContext, nil +} + // @Tags 家族 // @Summary 退出/踢出家族 // @Param type formData int true "1.自己退出,2.踢人" @@ -1510,7 +1545,7 @@ func GroupPowerSetInfo(c *gin.Context) (*mycontext.MyContext, error) { return myContext, res_m.GetErrByLanguage(model.Db, common.MSG_ID_SET_FAMILY_NAMEPL, lang, bizerr.GroupPowerChangeNameplate) } // 检查铭牌长度和唯一性 - if len(para.Nameplate) > 6 { + if len(para.Nameplate) > groupPower_e.LongestNameplate { return myContext, bizerr.GroupPowerHaveTooLong } if groupPower_m.IsExistsNameplate(model, para.Nameplate) { diff --git a/route/group_r/group_op.go b/route/group_r/group_op.go index bb62b80536b82aff4324c6b77b5c012dc01d0a96..f1d7d604e43b6867f8550aac8b21a03994b398cf 100644 --- a/route/group_r/group_op.go +++ b/route/group_r/group_op.go @@ -1751,7 +1751,33 @@ func GroupIn(c *gin.Context) (*mycontext.MyContext, error) { } model.Log.Infof("GroupIn ip userId:%v,imGroupId:%v,ip:%v,imei:%v", userId, groupId, ip, imei) - if channelId, token, err := group_s.NewGroupService(myContext).GroupIn(userId, externalId, groupId, password, imei, ip); err != nil { + provider := group_e.GroupProvider_SW + if group_m.IsUseTRTC(model, groupId) { + provider = group_e.GroupProvider_TRTC + } else { + if time.Now().Unix() > 1683820800 { // todo 1683820800=5月2号,等过审再修改 + roomUser, err := group_m.GetRoomOnlineUser(myContext, groupId) + if err == nil && roomUser.Total == 0 { + if err := group_m.InitTRTC(model, groupId); err != nil { + return myContext, err + } + provider = group_e.GroupProvider_TRTC + model.Log.Infof("auto shift trtc room groupId:%v,%+v-%v", groupId, roomUser, err) + } + } + } + if provider == group_e.GroupProvider_TRTC { + // 版本升级提示,旧版本(3.6.0以下),提示升级 + _, major, minor, _, err := req.GetAppVersion(c) + if err != nil { + return myContext, err + } + if (major < 3) || (major == 3 && minor < 6) { + return myContext, bizerr.UpgradeRequired + } + } + + if channelId, token, err := group_s.NewGroupService(myContext).GroupIn(userId, externalId, groupId, password, imei, ip, provider); err != nil { return myContext, err } else { // 加入房间缓存 @@ -1767,6 +1793,7 @@ func GroupIn(c *gin.Context) (*mycontext.MyContext, error) { Token: token, AgoraId: uint32(userId), MicNumType: gi.MicNumType, + Provider: provider, }) // v2.26及以后,客户端自己加TIM群,不再由服务器代加 diff --git a/route/mic_r/inner.go b/route/mic_r/inner.go index d212ae9833ca38c8631deed207490a666a9f710c..fd263e40c8c5c4342e2774baf820899f59d3f7bf 100644 --- a/route/mic_r/inner.go +++ b/route/mic_r/inner.go @@ -1,6 +1,7 @@ package mic_r import ( + "git.hilo.cn/hilo-common/_const/enum/timezone_e" "git.hilo.cn/hilo-common/domain" "git.hilo.cn/hilo-common/mycontext" "git.hilo.cn/hilo-common/resource/mysql" @@ -10,14 +11,16 @@ import ( ) type MGetUserOnMicSecondsReq struct { - Day string `form:"day" binding:"required"` - Ids []mysql.ID `form:"ids" binding:"required"` + Day string `form:"day" binding:"required"` + Ids []mysql.ID `form:"ids" binding:"required"` + Tz timezone_e.Timezone `form:"tz"` } // @Tags 麦位-内部 // @Summary 批量获取用户天上麦时长 // @Param day query string true "天 格式2006-001-02" // @Param ids query string true "用户id,如:ids=1&ids=2&ids=3" +// @Param tz query string false "时区 0:北京时间(默认) 1:沙特时间" // @Success 200 {object} map[uint64]uint32 // @Router /inner/mic/onMicSeconds [get] func MGetUserOnMicSeconds(c *gin.Context) (*mycontext.MyContext, error) { @@ -27,7 +30,38 @@ func MGetUserOnMicSeconds(c *gin.Context) (*mycontext.MyContext, error) { if err := c.ShouldBindQuery(&req); err != nil { return myCtx, err } - onMic, err := mic_m.MGetUserOnMicSeconds(model, req.Day, req.Ids) + onMic, err := mic_m.MGetUserOnMicSeconds(model, req.Day, req.Tz, req.Ids) + if err != nil { + return myCtx, err + } + response := onMic + resp.ResponseOk(c, response) + return myCtx, nil +} + +type MGetUserOnMicSecondsRangeReq struct { + BeginDate string `form:"beginDate" binding:"required"` + EndDate string `form:"endDate" binding:"required"` + Ids []mysql.ID `form:"ids" binding:"required"` + Tz timezone_e.Timezone `form:"tz"` +} + +// @Tags 麦位-内部 +// @Summary 批量获取用户范围上麦时长 +// @Param beginDate query string true "天 格式2006-001-02" +// @Param endDate query string true "天 格式2006-001-02" +// @Param ids query string true "用户id,如:ids=1&ids=2&ids=3" +// @Param tz query string false "时区 0:北京时间(默认) 1:沙特时间" +// @Success 200 {object} map[uint64]uint32 +// @Router /inner/mic/onMicSeconds/range [get] +func MGetUserOnMicSecondsRange(c *gin.Context) (*mycontext.MyContext, error) { + myCtx := mycontext.CreateMyContext(c.Keys) + var model = domain.CreateModelContext(myCtx) + var req MGetUserOnMicSecondsRangeReq + if err := c.ShouldBindQuery(&req); err != nil { + return myCtx, err + } + onMic, err := mic_m.MGetUserOnMicSecondsRange(model, req.BeginDate, req.EndDate, req.Tz, req.Ids) if err != nil { return myCtx, err } diff --git a/route/router.go b/route/router.go index 19d523c3660980c670557001cd1c88a125ada903..f0910f906e15eada46d8b6a6e15e2bc72a15f214 100644 --- a/route/router.go +++ b/route/router.go @@ -133,6 +133,7 @@ func InitRouter() *gin.Engine { groupPower.POST("/apply", wrapper(group_power_r.GroupPowerApplyJoin)) groupPower.POST("/apply/pass", wrapper(group_power_r.GroupPowerApplyPass)) groupPower.GET("/apply/list", wrapper(group_power_r.GroupPowerApplyList)) + groupPower.GET("/apply/count", wrapper(group_power_r.GroupPowerApplyCount)) groupPower.POST("/quit", wrapper(group_power_r.GroupPowerQuit)) groupPower.GET("/quit/list", wrapper(group_power_r.GroupPowerQuitList)) groupPower.POST("/admin", wrapper(group_power_r.GroupPowerSetAdmin)) @@ -161,6 +162,7 @@ func InitRouter() *gin.Engine { innerMic := inner.Group("/mic") { innerMic.GET("/onMicSeconds", wrapper(mic_r.MGetUserOnMicSeconds)) + innerMic.GET("/onMicSeconds/range", wrapper(mic_r.MGetUserOnMicSecondsRange)) } r.GET("/test", wrapper(group_power_r.Test)) return r diff --git a/test/group_power_test.go b/test/group_power_test.go index b0d364aec4e6c9748d6bf38fa91d97899acd57f6..c8300997d445e401828bab84c167a705ceb8d956 100644 --- a/test/group_power_test.go +++ b/test/group_power_test.go @@ -1,17 +1,25 @@ package test import ( + "fmt" "git.hilo.cn/hilo-common/domain" "hilo-group/domain/model/groupPower_m" + "hilo-group/domain/model/group_m" "testing" ) func TestGetAllGroupPowerOwner(t *testing.T) { - owners, err := groupPower_m.BatchGetAllGroupPowerUsers(domain.CreateModelNil()) + owners, _, err := groupPower_m.BatchGetAllGroupPowerUsers(domain.CreateModelNil(), 1, 1) println(owners, err) } func TestGetGroupPowerMonthStartTop1(t *testing.T) { res, err := groupPower_m.GetGroupPowerMonthStartTop1(domain.CreateModelNil(), 250) - println(res,err) + println(res, err) +} + +func TestIsUseTRTC(t *testing.T) { + if group_m.IsUseTRTC(domain.CreateModelNil(), "@TGS#3I57DMRIB") { + fmt.Println("true--------------") + } }