Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-group
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujiebin
hilo-group
Commits
d2c4ccbf
Commit
d2c4ccbf
authored
Apr 27, 2023
by
chenweijian
Browse files
Options
Browse Files
Download
Plain Diff
3.7.0
parents
34e0cfed
39078600
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
222 additions
and
34 deletions
+222
-34
redisPrefix.go
_const/redis_key/redisPrefix.go
+7
-0
group.go
cv/group_cv/group.go
+9
-8
country.go
domain/cache/res_c/country.go
+29
-0
groupMedal.go
domain/model/group_m/groupMedal.go
+7
-2
groupSetting.go
domain/model/group_m/groupSetting.go
+14
-0
country.go
domain/model/res_m/country.go
+17
-1
group_power.go
domain/service/group_power_s/group_power.go
+63
-1
group_power.go
route/group_power_r/group_power.go
+18
-10
inner.go
route/group_power_r/inner.go
+3
-1
group_info.go
route/group_r/group_info.go
+2
-2
group_list.go
route/group_r/group_list.go
+41
-9
group_op.go
route/group_r/group_op.go
+7
-0
group_power_test.go
test/group_power_test.go
+5
-0
No files found.
_const/redis_key/redisPrefix.go
View file @
d2c4ccbf
...
@@ -261,6 +261,9 @@ const groupPowerDiamond = "group_diamond_{period}"
...
@@ -261,6 +261,9 @@ const groupPowerDiamond = "group_diamond_{period}"
// 国家Icon
// 国家Icon
const
countryIcon
=
"contry_icon"
const
countryIcon
=
"contry_icon"
// 国家Area
const
countryArea
=
"contry:area"
// 群贡献前三
// 群贡献前三
const
groupTop3Consume
=
"group_top3_consume_{period}_{groupId}"
const
groupTop3Consume
=
"group_top3_consume_{period}_{groupId}"
...
@@ -778,6 +781,10 @@ func GetCountryIconKey() string {
...
@@ -778,6 +781,10 @@ func GetCountryIconKey() string {
return
countryIcon
return
countryIcon
}
}
func
GetCountryAreaKey
()
string
{
return
countryArea
}
func
GetGroupTop3ConsumeKey
(
period
string
,
groupId
string
)
string
{
func
GetGroupTop3ConsumeKey
(
period
string
,
groupId
string
)
string
{
return
strings
.
Replace
(
strings
.
Replace
(
groupTop3Consume
,
"{period}"
,
period
,
-
1
),
"groupId"
,
groupId
,
-
1
)
return
strings
.
Replace
(
strings
.
Replace
(
groupTop3Consume
,
"{period}"
,
period
,
-
1
),
"groupId"
,
groupId
,
-
1
)
}
}
...
...
cv/group_cv/group.go
View file @
d2c4ccbf
...
@@ -357,6 +357,15 @@ func BuildJoinedGroupInfo(myService *domain.Service, myUserId uint64, groupIds [
...
@@ -357,6 +357,15 @@ func BuildJoinedGroupInfo(myService *domain.Service, myUserId uint64, groupIds [
}
}
medals
:=
make
([]
medal_cv
.
PicElement
,
0
)
medals
:=
make
([]
medal_cv
.
PicElement
,
0
)
// 补上房间流水勋章
var
pe
*
medal_cv
.
PicElement
_
,
pe
,
err
=
medal_cv
.
GetGroupConsumeMedal
(
model
,
i
)
if
err
!=
nil
{
model
.
Log
.
Infof
(
"BuildJoinedGroupInfo: GetGroupConsumeMedal: %s"
,
err
.
Error
())
}
else
if
pe
!=
nil
{
medals
=
append
(
medals
,
medal_cv
.
PicElement
{
PicUrl
:
pe
.
PicUrl
})
}
// res_medal
if
m
,
ok
:=
groupMedals
[
i
];
ok
{
if
m
,
ok
:=
groupMedals
[
i
];
ok
{
for
_
,
j
:=
range
m
{
for
_
,
j
:=
range
m
{
mId
:=
uint32
(
j
)
mId
:=
uint32
(
j
)
...
@@ -367,14 +376,6 @@ func BuildJoinedGroupInfo(myService *domain.Service, myUserId uint64, groupIds [
...
@@ -367,14 +376,6 @@ func BuildJoinedGroupInfo(myService *domain.Service, myUserId uint64, groupIds [
}
}
}
}
}
}
// 补上房间流水勋章
var
pe
*
medal_cv
.
PicElement
_
,
pe
,
err
=
medal_cv
.
GetGroupConsumeMedal
(
model
,
i
)
if
err
!=
nil
{
model
.
Log
.
Infof
(
"BuildJoinedGroupInfo: GetGroupConsumeMedal: %s"
,
err
.
Error
())
}
else
if
pe
!=
nil
{
medals
=
append
(
medals
,
medal_cv
.
PicElement
{
PicUrl
:
pe
.
PicUrl
})
}
var
password
*
string
=
nil
var
password
*
string
=
nil
if
len
(
g
.
Password
)
>
0
&&
g
.
Owner
!=
myUserId
{
if
len
(
g
.
Password
)
>
0
&&
g
.
Owner
!=
myUserId
{
...
...
domain/cache/res_c/country.go
View file @
d2c4ccbf
...
@@ -36,3 +36,32 @@ func SaveAllCountryIcon(model *domain.Model, icons map[string]string) (int64, er
...
@@ -36,3 +36,32 @@ func SaveAllCountryIcon(model *domain.Model, icons map[string]string) (int64, er
}
}
return
ret
,
err
return
ret
,
err
}
}
func
GetCountryAreaMap
(
model
*
domain
.
Model
)
(
map
[
string
]
string
,
error
)
{
m
,
err
:=
GetAllCountryArea
(
model
)
if
err
!=
nil
||
len
(
m
)
<=
0
{
m
,
err
=
res_m
.
GetAllCountriesArea
(
model
)
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
m
)
<=
0
{
return
map
[
string
]
string
{},
nil
}
SaveAllCountryArea
(
model
,
m
)
}
return
m
,
nil
}
func
GetAllCountryArea
(
model
*
domain
.
Model
)
(
map
[
string
]
string
,
error
)
{
key
:=
redis_key
.
GetCountryAreaKey
()
return
model
.
Redis
.
HGetAll
(
context
.
Background
(),
key
)
.
Result
()
}
func
SaveAllCountryArea
(
model
*
domain
.
Model
,
data
map
[
string
]
string
)
(
int64
,
error
)
{
key
:=
redis_key
.
GetCountryAreaKey
()
ret
,
err
:=
model
.
Redis
.
HSet
(
context
.
Background
(),
key
,
data
)
.
Result
()
if
err
==
nil
{
model
.
Redis
.
Expire
(
context
.
Background
(),
key
,
time
.
Minute
*
10
)
}
return
ret
,
err
}
domain/model/group_m/groupMedal.go
View file @
d2c4ccbf
...
@@ -3,9 +3,11 @@ package group_m
...
@@ -3,9 +3,11 @@ package group_m
import
(
import
(
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
"git.hilo.cn/hilo-common/resource/mysql"
"git.hilo.cn/hilo-common/utils"
"gorm.io/gorm"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/clause"
"hilo-group/myerr"
"hilo-group/myerr"
"time"
)
)
//群组勋章
//群组勋章
...
@@ -30,7 +32,6 @@ func (groupInfo *GroupInfo) GroupMedalMgrAdd(model *domain.Model, resMedalId uin
...
@@ -30,7 +32,6 @@ func (groupInfo *GroupInfo) GroupMedalMgrAdd(model *domain.Model, resMedalId uin
}
}
}
}
func
GetGroupMedalOrErr
(
model
*
domain
.
Model
,
id
mysql
.
ID
)
(
*
GroupMedal
,
error
)
{
func
GetGroupMedalOrErr
(
model
*
domain
.
Model
,
id
mysql
.
ID
)
(
*
GroupMedal
,
error
)
{
groupMedal
:=
GroupMedal
{}
groupMedal
:=
GroupMedal
{}
if
err
:=
model
.
Db
.
Model
(
&
GroupMedal
{})
.
First
(
&
groupMedal
,
id
)
.
Error
;
err
!=
nil
{
if
err
:=
model
.
Db
.
Model
(
&
GroupMedal
{})
.
First
(
&
groupMedal
,
id
)
.
Error
;
err
!=
nil
{
...
@@ -65,7 +66,11 @@ func BatchGetMedals(db *gorm.DB, groupIds []string) (map[string][]uint64, error)
...
@@ -65,7 +66,11 @@ func BatchGetMedals(db *gorm.DB, groupIds []string) (map[string][]uint64, error)
return
nil
,
nil
return
nil
,
nil
}
}
rows
:=
make
([]
GroupMedal
,
0
)
rows
:=
make
([]
GroupMedal
,
0
)
if
err
:=
db
.
Model
(
&
GroupMedal
{})
.
Where
(
"im_group_id IN ?"
,
groupIds
)
.
Find
(
&
rows
)
.
Error
;
err
!=
nil
{
if
err
:=
db
.
Model
(
GroupMedal
{})
.
Joins
(
"left join res_medal rm on group_medal.res_medal_id = rm.id"
)
.
Where
(
"group_medal.im_group_id IN ?"
,
groupIds
)
.
Where
(
"(group_medal.expire_at is null or group_medal.expire_at > ?)"
,
time
.
Now
()
.
Format
(
utils
.
DATETIME_FORMAT
))
.
Order
(
"rm.sort"
)
.
Find
(
&
rows
)
.
Error
;
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
result
:=
make
(
map
[
string
][]
uint64
,
0
)
result
:=
make
(
map
[
string
][]
uint64
,
0
)
...
...
domain/model/group_m/groupSetting.go
View file @
d2c4ccbf
...
@@ -64,6 +64,20 @@ func IsHiddenGroup(db *gorm.DB, groupId string) (bool, error) {
...
@@ -64,6 +64,20 @@ func IsHiddenGroup(db *gorm.DB, groupId string) (bool, error) {
}
}
}
}
func
IsHiddenGroupBy
(
model
*
domain
.
Model
,
imGroupId
string
)
bool
{
info
:=
new
(
GroupSetting
)
if
err
:=
model
.
DB
()
.
Model
(
GroupSetting
{})
.
Where
(
"group_id = ? and is_hidden = 1"
,
imGroupId
)
.
First
(
&
info
)
.
Error
;
err
!=
nil
{
if
err
==
gorm
.
ErrRecordNotFound
{
return
false
}
return
false
}
if
info
!=
nil
&&
info
.
ID
>
0
{
return
true
}
return
false
}
func
(
gs
*
GroupSetting
)
Get
(
db
*
gorm
.
DB
)
error
{
func
(
gs
*
GroupSetting
)
Get
(
db
*
gorm
.
DB
)
error
{
return
db
.
Where
(
gs
)
.
First
(
gs
)
.
Error
return
db
.
Where
(
gs
)
.
First
(
gs
)
.
Error
}
}
...
...
domain/model/res_m/country.go
View file @
d2c4ccbf
...
@@ -23,6 +23,7 @@ type ResCountry struct {
...
@@ -23,6 +23,7 @@ type ResCountry struct {
StandardShortName
mysql
.
Str
StandardShortName
mysql
.
Str
AreaCode
mysql
.
Str
AreaCode
mysql
.
Str
AreaCodeName
mysql
.
Str
AreaCodeName
mysql
.
Str
Area
mysql
.
Str
}
}
type
ResLanguage
struct
{
type
ResLanguage
struct
{
...
@@ -81,6 +82,22 @@ func GetAllCountries(model *domain.Model) (map[string]string, error) {
...
@@ -81,6 +82,22 @@ func GetAllCountries(model *domain.Model) (map[string]string, error) {
return
result
,
nil
return
result
,
nil
}
}
// 获取所有国家的Area信息
func
GetAllCountriesArea
(
model
*
domain
.
Model
)
(
map
[
string
]
string
,
error
)
{
var
countrys
[]
ResCountry
if
err
:=
model
.
Db
.
Model
(
&
ResCountry
{})
.
Where
(
&
ResCountry
{
Status
:
mysql
.
USER
,
})
.
Find
(
&
countrys
)
.
Error
;
err
!=
nil
{
return
nil
,
myerr
.
WrapErr
(
err
)
}
result
:=
make
(
map
[
string
]
string
,
0
)
for
_
,
i
:=
range
countrys
{
result
[
i
.
Name
]
=
i
.
Area
}
return
result
,
nil
}
func
GetAllCountryByFilter
(
model
*
domain
.
Model
,
shortNames
[]
string
)
([]
ResCountry
,
error
)
{
func
GetAllCountryByFilter
(
model
*
domain
.
Model
,
shortNames
[]
string
)
([]
ResCountry
,
error
)
{
var
countrys
[]
ResCountry
var
countrys
[]
ResCountry
if
err
:=
model
.
Db
.
Model
(
&
ResCountry
{})
.
Where
(
&
ResCountry
{
if
err
:=
model
.
Db
.
Model
(
&
ResCountry
{})
.
Where
(
&
ResCountry
{
...
@@ -196,4 +213,3 @@ func GetLangeByCountry(db *gorm.DB, country mysql.Str) (string, error) {
...
@@ -196,4 +213,3 @@ func GetLangeByCountry(db *gorm.DB, country mysql.Str) (string, error) {
return
""
,
myerr
.
WrapErr
(
err
)
return
""
,
myerr
.
WrapErr
(
err
)
}
}
}
}
domain/service/group_power_s/group_power.go
View file @
d2c4ccbf
...
@@ -16,8 +16,11 @@ import (
...
@@ -16,8 +16,11 @@ import (
"hilo-group/domain/cache/user_c"
"hilo-group/domain/cache/user_c"
"hilo-group/domain/event/group_power_ev"
"hilo-group/domain/event/group_power_ev"
"hilo-group/domain/model/groupPower_m"
"hilo-group/domain/model/groupPower_m"
"hilo-group/myerr/bizerr"
"time"
"time"
"hilo-group/domain/model/msg_m"
"hilo-group/domain/model/noble_m"
"hilo-group/domain/model/user_m"
"hilo-group/myerr/bizerr"
)
)
type
GroupPowerService
struct
{
type
GroupPowerService
struct
{
...
@@ -365,3 +368,62 @@ func CalcGroupPowerMonthRankActConf() map[int]map[int]*awardConf {
...
@@ -365,3 +368,62 @@ func CalcGroupPowerMonthRankActConf() map[int]map[int]*awardConf {
},
},
}
}
}
}
func
GetGroupPowerMaxMemberNum
(
model
*
domain
.
Model
,
familyId
uint64
,
groupPowerGrade
groupPower_e
.
GroupPowerGrade
)
(
maxNum
int
)
{
maxNum
=
group_power_cv
.
GroupPowerGradePrivilegeNum
[
groupPowerGrade
][
0
]
.
Num
ownerId
,
err
:=
groupPower_m
.
GetPowerOwner
(
model
.
Db
,
familyId
)
if
err
==
nil
{
//检查是否是贵族
if
flag
,
err
:=
noble_m
.
CheckNobleLevel
(
model
.
Db
,
ownerId
,
6
);
err
!=
nil
{
}
else
if
flag
{
newNumMap
:=
map
[
groupPower_e
.
GroupPowerGrade
]
int
{
groupPower_e
.
GroupPowerGrade0
:
400
,
groupPower_e
.
GroupPowerGrade1
:
600
,
groupPower_e
.
GroupPowerGrade2
:
1000
,
groupPower_e
.
GroupPowerGrade3
:
1400
}
if
newNum
,
ok
:=
newNumMap
[
groupPowerGrade
];
ok
{
maxNum
=
newNum
}
}
}
users
,
err
:=
groupPower_m
.
GetGroupPowerUser
(
model
,
familyId
)
if
err
!=
nil
{
return
}
memberNum
:=
len
(
users
)
if
memberNum
>
maxNum
{
maxNum
=
memberNum
}
return
}
// 检查需不需要通知用户拉取家族小助手消息
func
CheckoutSendMsgToMgr
(
myContext
*
mycontext
.
MyContext
,
groupPowerId
uint64
)
{
defer
utils
.
CheckGoPanic
()
model
:=
domain
.
CreateModelContext
(
myContext
)
//// 申请人数
//cnt, err := groupPower_m.CountGroupPowerApply(model, groupPowerId, 0)
//if err != nil {
// model.Log.Errorf("CheckoutSendMsgToMgr err:%v, id:%v", err, groupPowerId)
// return
//}
//if cnt <= 0 {
// return
//}
// 找到家族管理员们
mgrList
,
err
:=
groupPower_m
.
GetGroupPowerMgrList
(
model
,
groupPowerId
)
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"CheckoutSendMsgToMgr err:%v, id:%v"
,
err
,
groupPowerId
)
return
}
userMap
,
err
:=
user_m
.
GetUserMapByIds
(
model
,
mgrList
)
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"CheckoutSendMsgToMgr err:%v, id:%v"
,
err
,
groupPowerId
)
return
}
for
_
,
v
:=
range
mgrList
{
if
user
,
ok
:=
userMap
[
v
];
ok
{
msg_m
.
SendEmasMsgAssistant
(
model
,
user
.
ExternalId
,
user
.
DeviceType
)
}
}
}
route/group_power_r/group_power.go
View file @
d2c4ccbf
...
@@ -774,10 +774,11 @@ func GroupPowerInfo(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -774,10 +774,11 @@ func GroupPowerInfo(c *gin.Context) (*mycontext.MyContext, error) {
if
grade
.
Grade
!=
groupPower_e
.
GroupPowerGradeMax
{
if
grade
.
Grade
!=
groupPower_e
.
GroupPowerGradeMax
{
nextExp
=
groupPower_e
.
GroupPowerGradeExp
[
grade
.
Grade
+
1
]
nextExp
=
groupPower_e
.
GroupPowerGradeExp
[
grade
.
Grade
+
1
]
}
}
maxNum
:=
group_power_s
.
GetGroupPowerMaxMemberNum
(
model
,
gpInfo
.
ID
,
grade
.
Grade
)
info
:=
&
group_power_cv
.
GroupPower
{
info
:=
&
group_power_cv
.
GroupPower
{
Id
:
gpInfo
.
ID
,
Name
:
gpInfo
.
Name
,
Nameplate
:
gpInfo
.
Nameplate
,
Declaration
:
gpInfo
.
Declaration
,
Icon
:
gpInfo
.
Icon
,
Id
:
gpInfo
.
ID
,
Name
:
gpInfo
.
Name
,
Nameplate
:
gpInfo
.
Nameplate
,
Declaration
:
gpInfo
.
Declaration
,
Icon
:
gpInfo
.
Icon
,
Grade
:
grade
.
Grade
,
Exp
:
grade
.
Exp
,
NextExp
:
nextExp
,
GradeName
:
gpInfo
.
GradeName
,
GradeMedal
:
gpInfo
.
GradeMedal
,
Grade
:
grade
.
Grade
,
Exp
:
grade
.
Exp
,
NextExp
:
nextExp
,
GradeName
:
gpInfo
.
GradeName
,
GradeMedal
:
gpInfo
.
GradeMedal
,
MemberNum
:
mysql
.
Num
(
total
),
MemberMax
:
mysql
.
Num
(
group_power_cv
.
GroupPowerGradePrivilegeNum
[
grade
.
Grade
][
0
]
.
Num
),
MemberNum
:
mysql
.
Num
(
total
),
MemberMax
:
mysql
.
Num
(
max
Num
),
}
}
if
info
.
Icon
!=
""
{
if
info
.
Icon
!=
""
{
info
.
Icon
=
common
.
MakeFullUrl
(
info
.
Icon
)
info
.
Icon
=
common
.
MakeFullUrl
(
info
.
Icon
)
...
@@ -1007,7 +1008,8 @@ func GroupPowerApplyJoin(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -1007,7 +1008,8 @@ func GroupPowerApplyJoin(c *gin.Context) (*mycontext.MyContext, error) {
if
err
!=
nil
{
if
err
!=
nil
{
return
myContext
,
myerr
.
WrapErr
(
err
)
return
myContext
,
myerr
.
WrapErr
(
err
)
}
}
maxNum
:=
group_power_cv
.
GroupPowerGradePrivilegeNum
[
gpInfo
.
Grade
][
0
]
.
Num
maxNum
:=
group_power_s
.
GetGroupPowerMaxMemberNum
(
model
,
familyId
,
gpInfo
.
Grade
)
//maxNum := group_power_cv.GroupPowerGradePrivilegeNum[gpInfo.Grade][0].Num
if
nowNum
+
1
>
int64
(
maxNum
)
{
if
nowNum
+
1
>
int64
(
maxNum
)
{
return
myContext
,
bizerr
.
GroupPowerMemberMax
return
myContext
,
bizerr
.
GroupPowerMemberMax
}
}
...
@@ -1025,7 +1027,8 @@ func GroupPowerApplyJoin(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -1025,7 +1027,8 @@ func GroupPowerApplyJoin(c *gin.Context) (*mycontext.MyContext, error) {
}
else
{
}
else
{
for
_
,
v
:=
range
mgrList
{
for
_
,
v
:=
range
mgrList
{
// 发小助手通知用户
// 发小助手通知用户
msg
.
SendLittleAssistantMsg
(
model
,
v
,
msg_e
.
GroupPowerApplyJoinMsg
,
""
,
""
,
""
,
""
,
""
)
msg
.
SendLittleAssistantMsg
(
model
,
v
,
0
,
""
,
""
,
""
,
""
,
""
)
//msg.SendLittleAssistantMsg(model, v, msg_e.GroupPowerApplyJoinMsg, "", "", "", "", "")
}
}
}
}
...
@@ -1097,6 +1100,8 @@ func GroupPowerApplyPass(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -1097,6 +1100,8 @@ func GroupPowerApplyPass(c *gin.Context) (*mycontext.MyContext, error) {
return
myContext
,
err
return
myContext
,
err
}
}
resp
.
ResponseOk
(
c
,
nil
)
resp
.
ResponseOk
(
c
,
nil
)
// 家族小助手通知
go
group_power_s
.
CheckoutSendMsgToMgr
(
myContext
,
myGroupPUser
.
GroupPowerId
)
return
myContext
,
nil
return
myContext
,
nil
}
}
// 判断家族是否满人了
// 判断家族是否满人了
...
@@ -1109,7 +1114,8 @@ func GroupPowerApplyPass(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -1109,7 +1114,8 @@ func GroupPowerApplyPass(c *gin.Context) (*mycontext.MyContext, error) {
return
myContext
,
err
return
myContext
,
err
}
}
grade
:=
gradeM
[
apply
.
GroupPowerId
]
grade
:=
gradeM
[
apply
.
GroupPowerId
]
maxNum
:=
group_power_cv
.
GroupPowerGradePrivilegeNum
[
grade
.
Grade
][
0
]
.
Num
//maxNum := group_power_cv.GroupPowerGradePrivilegeNum[grade.Grade][0].Num
maxNum
:=
group_power_s
.
GetGroupPowerMaxMemberNum
(
model
,
apply
.
GroupPowerId
,
grade
.
Grade
)
if
int
(
nowNum
+
1
)
>
maxNum
{
if
int
(
nowNum
+
1
)
>
maxNum
{
return
myContext
,
bizerr
.
GroupPowerMemberMax
return
myContext
,
bizerr
.
GroupPowerMemberMax
}
}
...
@@ -1149,10 +1155,12 @@ func GroupPowerApplyPass(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -1149,10 +1155,12 @@ func GroupPowerApplyPass(c *gin.Context) (*mycontext.MyContext, error) {
return
myContext
,
err
return
myContext
,
err
}
}
// 发小助手通知用户
// 发小助手通知用户
err
=
msg
.
SendLittleAssistantMsg
(
model
,
apply
.
UserId
,
msg_e
.
GroupPowerWelcomeJoin
,
""
,
""
,
""
,
""
,
""
)
//err = msg.SendLittleAssistantMsg(model, apply.UserId, msg_e.GroupPowerWelcomeJoin, "", "", "", "", "")
if
err
!=
nil
{
//if err != nil {
model
.
Log
.
Errorf
(
"GroupPowerApplyPass msg err:%v"
,
err
)
// model.Log.Errorf("GroupPowerApplyPass msg err:%v", err)
}
//}
// 家族小助手通知
go
group_power_s
.
CheckoutSendMsgToMgr
(
myContext
,
myGroupPUser
.
GroupPowerId
)
resp
.
ResponseOk
(
c
,
nil
)
resp
.
ResponseOk
(
c
,
nil
)
return
myContext
,
nil
return
myContext
,
nil
...
@@ -1587,7 +1595,6 @@ func GroupPowerSetInfo(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -1587,7 +1595,6 @@ func GroupPowerSetInfo(c *gin.Context) (*mycontext.MyContext, error) {
if
err
!=
nil
{
if
err
!=
nil
{
return
myContext
,
myerr
.
WrapErr
(
err
)
return
myContext
,
myerr
.
WrapErr
(
err
)
}
}
groupPowerGrade
,
err
:=
groupPower_m
.
MGetGroupPowerGrade
(
model
,
[]
mysql
.
ID
{
gp
.
ID
})
gradeM
,
err
:=
groupPower_m
.
MGetGroupPowerGrade
(
model
,
[]
mysql
.
ID
{
gp
.
ID
})
gradeM
,
err
:=
groupPower_m
.
MGetGroupPowerGrade
(
model
,
[]
mysql
.
ID
{
gp
.
ID
})
if
err
!=
nil
{
if
err
!=
nil
{
return
myContext
,
err
return
myContext
,
err
...
@@ -1597,10 +1604,11 @@ func GroupPowerSetInfo(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -1597,10 +1604,11 @@ func GroupPowerSetInfo(c *gin.Context) (*mycontext.MyContext, error) {
if
grade
.
Grade
!=
groupPower_e
.
GroupPowerGradeMax
{
if
grade
.
Grade
!=
groupPower_e
.
GroupPowerGradeMax
{
nextExp
=
groupPower_e
.
GroupPowerGradeExp
[
grade
.
Grade
+
1
]
nextExp
=
groupPower_e
.
GroupPowerGradeExp
[
grade
.
Grade
+
1
]
}
}
maxNum
:=
group_power_s
.
GetGroupPowerMaxMemberNum
(
model
,
gpInfo
.
ID
,
grade
.
Grade
)
info
:=
&
group_power_cv
.
GroupPower
{
info
:=
&
group_power_cv
.
GroupPower
{
Id
:
gpInfo
.
ID
,
Name
:
gpInfo
.
Name
,
Nameplate
:
gpInfo
.
Nameplate
,
Declaration
:
gpInfo
.
Declaration
,
Icon
:
gpInfo
.
Icon
,
Id
:
gpInfo
.
ID
,
Name
:
gpInfo
.
Name
,
Nameplate
:
gpInfo
.
Nameplate
,
Declaration
:
gpInfo
.
Declaration
,
Icon
:
gpInfo
.
Icon
,
Grade
:
grade
.
Grade
,
Exp
:
grade
.
Exp
,
NextExp
:
nextExp
,
GradeName
:
gpInfo
.
GradeName
,
GradeMedal
:
gpInfo
.
GradeMedal
,
Grade
:
grade
.
Grade
,
Exp
:
grade
.
Exp
,
NextExp
:
nextExp
,
GradeName
:
gpInfo
.
GradeName
,
GradeMedal
:
gpInfo
.
GradeMedal
,
MemberNum
:
mysql
.
Num
(
total
),
MemberMax
:
mysql
.
Num
(
group_power_cv
.
GroupPowerGradePrivilegeNum
[
groupPowerGrade
[
gp
.
ID
]
.
Grade
][
0
]
.
Num
),
MemberNum
:
mysql
.
Num
(
total
),
MemberMax
:
mysql
.
Num
(
max
Num
),
}
}
if
info
.
Icon
!=
""
{
if
info
.
Icon
!=
""
{
info
.
Icon
=
common
.
MakeFullUrl
(
info
.
Icon
)
info
.
Icon
=
common
.
MakeFullUrl
(
info
.
Icon
)
...
...
route/group_power_r/inner.go
View file @
d2c4ccbf
...
@@ -11,6 +11,7 @@ import (
...
@@ -11,6 +11,7 @@ import (
"hilo-group/domain/model/groupPower_m"
"hilo-group/domain/model/groupPower_m"
"hilo-group/domain/model/msg_m"
"hilo-group/domain/model/msg_m"
"hilo-group/domain/model/user_m"
"hilo-group/domain/model/user_m"
"hilo-group/domain/service/group_power_s"
"hilo-group/resp"
"hilo-group/resp"
)
)
...
@@ -48,7 +49,8 @@ func MGetGroupPowers(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -48,7 +49,8 @@ func MGetGroupPowers(c *gin.Context) (*mycontext.MyContext, error) {
var
memberMax
mysql
.
Num
var
memberMax
mysql
.
Num
grade
:=
groupPowerGrade
[
groupPowerId
]
.
Grade
grade
:=
groupPowerGrade
[
groupPowerId
]
.
Grade
if
grade
>=
groupPower_e
.
GroupPowerGrade0
&&
grade
<=
groupPower_e
.
GroupPowerGradeMax
{
if
grade
>=
groupPower_e
.
GroupPowerGrade0
&&
grade
<=
groupPower_e
.
GroupPowerGradeMax
{
memberMax
=
mysql
.
Num
(
group_power_cv
.
GroupPowerGradePrivilegeNum
[
groupPowerGrade
[
groupPowerId
]
.
Grade
][
0
]
.
Num
)
//memberMax = mysql.Num(group_power_cv.GroupPowerGradePrivilegeNum[groupPowerGrade[groupPowerId].Grade][0].Num)
memberMax
=
mysql
.
Num
(
group_power_s
.
GetGroupPowerMaxMemberNum
(
model
,
groupPowerId
,
grade
))
}
}
memberNum
:=
mysql
.
Num
(
len
(
groupPowerUsers
[
groupPowerId
]))
memberNum
:=
mysql
.
Num
(
len
(
groupPowerUsers
[
groupPowerId
]))
if
memberNum
>
memberMax
{
if
memberNum
>
memberMax
{
...
...
route/group_r/group_info.go
View file @
d2c4ccbf
...
@@ -558,7 +558,7 @@ func GetRoomInfo(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -558,7 +558,7 @@ func GetRoomInfo(c *gin.Context) (*mycontext.MyContext, error) {
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
)
.
Where
(
"(expire_at is null or expire_at > ?)"
,
time
.
Now
()
.
Format
(
utils
.
DATETIME_FORMAT
))
.
Where
(
"(expire_at is null or expire_at > ?)"
,
time
.
Now
()
.
Format
(
utils
.
DATETIME_FORMAT
))
.
Order
(
"
m.id desc
"
)
.
Order
(
"
res_medal.sort
"
)
.
Find
(
&
resMedals
)
.
Error
Find
(
&
resMedals
)
.
Error
if
err
==
nil
{
if
err
==
nil
{
for
_
,
r
:=
range
resMedals
{
for
_
,
r
:=
range
resMedals
{
...
@@ -1174,7 +1174,7 @@ func GroupMedalAll(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -1174,7 +1174,7 @@ func GroupMedalAll(c *gin.Context) (*mycontext.MyContext, error) {
if
err
:=
mysql
.
Db
.
Model
(
&
res_m
.
ResMedal
{})
.
Joins
(
"inner join group_medal m on m.res_medal_id = res_medal.id"
)
.
if
err
:=
mysql
.
Db
.
Model
(
&
res_m
.
ResMedal
{})
.
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
)
.
Where
(
"(expire_at is null or expire_at > ?)"
,
time
.
Now
()
.
Format
(
utils
.
DATETIME_FORMAT
))
.
Where
(
"(expire_at is null or expire_at > ?)"
,
time
.
Now
()
.
Format
(
utils
.
DATETIME_FORMAT
))
.
Order
(
"
m.id desc
"
)
.
Find
(
&
resMedals
)
.
Error
;
err
!=
nil
{
Order
(
"
res_medal.sort
"
)
.
Find
(
&
resMedals
)
.
Error
;
err
!=
nil
{
return
myContext
,
err
return
myContext
,
err
}
}
...
...
route/group_r/group_list.go
View file @
d2c4ccbf
package
group_r
package
group_r
import
(
import
(
"fmt"
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/mycontext"
"git.hilo.cn/hilo-common/mycontext"
"git.hilo.cn/hilo-common/resource/mysql"
"git.hilo.cn/hilo-common/resource/mysql"
...
@@ -155,6 +156,20 @@ func GetPopularGroups(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -155,6 +156,20 @@ func GetPopularGroups(c *gin.Context) (*mycontext.MyContext, error) {
//}
//}
//logstr += " |"
//logstr += " |"
// 获取国家信息
_
,
area
,
err
:=
user_m
.
GetUserCountryArea
(
model
,
myUserId
)
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"GetUserCountryArea 获取国家资源错误 userId:%d, err:%v"
,
myUserId
,
err
)
return
myContext
,
err
}
myArea
:=
fmt
.
Sprintf
(
"%d"
,
area
)
// 国家区域信息
resAreaMap
,
err
:=
res_c
.
GetCountryAreaMap
(
model
)
if
err
!=
nil
{
return
myContext
,
err
}
areaScore
:=
make
(
map
[
string
]
int
)
countryScore
:=
make
(
map
[
string
]
int
)
countryScore
:=
make
(
map
[
string
]
int
)
if
len
(
myCountry
)
>
0
{
if
len
(
myCountry
)
>
0
{
for
_
,
i
:=
range
sortedGroupIds
{
for
_
,
i
:=
range
sortedGroupIds
{
...
@@ -163,6 +178,13 @@ func GetPopularGroups(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -163,6 +178,13 @@ func GetPopularGroups(c *gin.Context) (*mycontext.MyContext, error) {
}
else
{
}
else
{
countryScore
[
i
]
=
0
countryScore
[
i
]
=
0
}
}
if
cArea
,
ok
:=
resAreaMap
[
groups
[
i
]
.
Country
];
ok
{
if
myArea
==
cArea
{
areaScore
[
i
]
=
1
}
else
{
areaScore
[
i
]
=
0
}
}
}
}
}
}
model
.
Log
.
Infof
(
"GetPopularGroups, countryScore[*]: %v,cost:%v"
,
countryScore
,
time
.
Now
()
.
Sub
(
start
))
model
.
Log
.
Infof
(
"GetPopularGroups, countryScore[*]: %v,cost:%v"
,
countryScore
,
time
.
Now
()
.
Sub
(
start
))
...
@@ -192,6 +214,15 @@ func GetPopularGroups(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -192,6 +214,15 @@ func GetPopularGroups(c *gin.Context) (*mycontext.MyContext, error) {
}
else
if
countryScore
[
gi
]
<
countryScore
[
gj
]
{
}
else
if
countryScore
[
gi
]
<
countryScore
[
gj
]
{
return
false
return
false
}
}
// 不是我的国家,按区域排序
if
countryScore
[
gi
]
==
0
{
if
areaScore
[
gi
]
>
areaScore
[
gj
]
{
return
true
}
else
if
areaScore
[
gi
]
<
areaScore
[
gj
]
{
return
false
}
}
// 2、按麦上人数多少排序
// 2、按麦上人数多少排序
if
micGroupNum
[
gi
]
>
micGroupNum
[
gj
]
{
if
micGroupNum
[
gi
]
>
micGroupNum
[
gj
]
{
return
true
return
true
...
@@ -296,6 +327,16 @@ func GetPopularGroups(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -296,6 +327,16 @@ func GetPopularGroups(c *gin.Context) (*mycontext.MyContext, error) {
}
}
medals
:=
make
([]
medal_cv
.
PicElement
,
0
)
medals
:=
make
([]
medal_cv
.
PicElement
,
0
)
// 补上房间流水勋章
var
pe
*
medal_cv
.
PicElement
_
,
pe
,
err
=
medal_cv
.
GetGroupConsumeMedal
(
model
,
i
.
ImGroupId
)
if
err
!=
nil
{
model
.
Log
.
Infof
(
"GetPopularGroups: GetGroupConsumeMedal: %s"
,
err
.
Error
())
}
else
if
pe
!=
nil
{
medals
=
append
(
medals
,
medal_cv
.
PicElement
{
PicUrl
:
pe
.
PicUrl
})
}
if
m
,
ok
:=
groupMedals
[
i
.
ImGroupId
];
ok
{
if
m
,
ok
:=
groupMedals
[
i
.
ImGroupId
];
ok
{
for
_
,
j
:=
range
m
{
for
_
,
j
:=
range
m
{
mId
:=
uint32
(
j
)
mId
:=
uint32
(
j
)
...
@@ -307,15 +348,6 @@ func GetPopularGroups(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -307,15 +348,6 @@ func GetPopularGroups(c *gin.Context) (*mycontext.MyContext, error) {
}
}
}
}
// 补上房间流水勋章
var
pe
*
medal_cv
.
PicElement
_
,
pe
,
err
=
medal_cv
.
GetGroupConsumeMedal
(
model
,
i
.
ImGroupId
)
if
err
!=
nil
{
model
.
Log
.
Infof
(
"GetPopularGroups: GetGroupConsumeMedal: %s"
,
err
.
Error
())
}
else
if
pe
!=
nil
{
medals
=
append
(
medals
,
medal_cv
.
PicElement
{
PicUrl
:
pe
.
PicUrl
})
}
var
password
*
string
=
nil
var
password
*
string
=
nil
if
len
(
i
.
Password
)
>
0
&&
i
.
Owner
!=
myUserId
{
if
len
(
i
.
Password
)
>
0
&&
i
.
Owner
!=
myUserId
{
emptyStr
:=
""
emptyStr
:=
""
...
...
route/group_r/group_op.go
View file @
d2c4ccbf
...
@@ -883,6 +883,13 @@ func SearchGroup(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -883,6 +883,13 @@ func SearchGroup(c *gin.Context) (*mycontext.MyContext, error) {
return
myContext
,
nil
return
myContext
,
nil
}
}
}
}
if
group_m
.
IsHiddenGroupBy
(
model
,
g
.
ImGroupId
)
{
if
flag
,
_
:=
user_m
.
IsSuperManager
(
model
,
myUserId
);
!
flag
{
// 被隐藏的用户,除了超管账户,其它用户搜索他的群组和个人ID,搜索结果为空
resp
.
ResponsePageOk
(
c
,
result
,
uint
(
total
),
1
)
return
myContext
,
nil
}
}
supportLevels
,
err
:=
group_s
.
NewGroupService
(
myContext
)
.
GetWeekMaxSupportLevelMap
()
supportLevels
,
err
:=
group_s
.
NewGroupService
(
myContext
)
.
GetWeekMaxSupportLevelMap
()
if
err
!=
nil
{
if
err
!=
nil
{
return
myContext
,
err
return
myContext
,
err
...
...
test/group_power_test.go
View file @
d2c4ccbf
...
@@ -28,6 +28,11 @@ func TestIsUseTRTC(t *testing.T) {
...
@@ -28,6 +28,11 @@ func TestIsUseTRTC(t *testing.T) {
}
}
}
}
func
TestIsMaxMember
(
t
*
testing
.
T
)
{
//maxNum := group_power_s.GetGroupPowerMaxMemberNum(domain.CreateModelNil(), 263, grade.Grade)
fmt
.
Println
(
"true--------------"
)
}
func
TestDoCalcGroupPowerMonthRankAct
(
t
*
testing
.
T
)
{
func
TestDoCalcGroupPowerMonthRankAct
(
t
*
testing
.
T
)
{
lastDayTime
:=
time
.
Now
()
.
AddDate
(
0
,
0
,
-
1
)
lastDayTime
:=
time
.
Now
()
.
AddDate
(
0
,
0
,
-
1
)
_now
:=
now
.
New
(
lastDayTime
)
_now
:=
now
.
New
(
lastDayTime
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment