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
145b0db7
Commit
145b0db7
authored
Apr 27, 2023
by
chenweijian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merge master
parent
e0394ec5
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
82 additions
and
38 deletions
+82
-38
groupPower.go
domain/model/groupPower_m/groupPower.go
+1
-0
group_rank.go
domain/model/groupPower_m/group_rank.go
+6
-2
group_power.go
domain/service/group_power_s/group_power.go
+40
-29
group_power_month_act.sql
mysql/group_power_month_act.sql
+3
-1
group_rank.go
route/group_power_r/group_rank.go
+32
-6
No files found.
domain/model/groupPower_m/groupPower.go
View file @
145b0db7
...
@@ -51,6 +51,7 @@ type ActFamilyMonthRankLog struct {
...
@@ -51,6 +51,7 @@ type ActFamilyMonthRankLog struct {
RankUser
int
`json:"rank_user"`
RankUser
int
`json:"rank_user"`
UserId
uint64
`json:"user_id"`
UserId
uint64
`json:"user_id"`
Award
string
`json:"award"`
Award
string
`json:"award"`
Area
int
`json:"area"`
}
}
func
(
gpu
*
GroupPowerUser
)
Get
(
db
*
gorm
.
DB
)
([]
GroupPowerUser
,
error
)
{
func
(
gpu
*
GroupPowerUser
)
Get
(
db
*
gorm
.
DB
)
([]
GroupPowerUser
,
error
)
{
...
...
domain/model/groupPower_m/group_rank.go
View file @
145b0db7
...
@@ -15,12 +15,16 @@ type GroupPowerExpRank struct {
...
@@ -15,12 +15,16 @@ type GroupPowerExpRank struct {
// 获取家族经验排行榜
// 获取家族经验排行榜
// param limit: 排行榜人数
// param limit: 排行榜人数
func
GetGroupPowerExpRank
(
model
*
domain
.
Model
,
beginDate
,
endDate
string
,
limit
int
,
gpStatus
groupPower_e
.
GroupPowerStatus
)
([]
GroupPowerExpRank
,
error
)
{
func
GetGroupPowerExpRank
(
model
*
domain
.
Model
,
beginDate
,
endDate
string
,
limit
int
,
gpStatus
groupPower_e
.
GroupPowerStatus
,
area
int
)
([]
GroupPowerExpRank
,
error
)
{
var
res
[]
GroupPowerExpRank
var
res
[]
GroupPowerExpRank
db
:=
model
.
DB
()
.
Table
(
"group_power_day_exp gpd"
)
.
Select
(
"gpd.group_power_id,SUM(gpd.exp) as exp"
)
.
db
:=
model
.
DB
()
.
Table
(
"group_power_day_exp gpd"
)
.
Select
(
"gpd.group_power_id,SUM(gpd.exp) as exp"
)
.
Where
(
"gpd.date BETWEEN ? AND ?"
,
beginDate
,
endDate
)
Where
(
"gpd.date BETWEEN ? AND ?"
,
beginDate
,
endDate
)
if
gpStatus
>
0
{
if
gpStatus
>
0
{
db
=
db
.
Joins
(
"left join group_power gp on gpd.group_power_id = gp.id"
)
.
Where
(
"status = ?"
,
gpStatus
)
db
=
db
.
Joins
(
"left join group_power gp on gpd.group_power_id = gp.id"
)
.
Where
(
"gp.status = ?"
,
gpStatus
)
if
area
>
0
{
db
=
db
.
Joins
(
"left join group_info gi on gp.group_uid = gi.im_group_id left join res_country rs on gi.country = rs.name"
)
.
Where
(
"rs.area = ?"
,
area
)
}
}
}
if
err
:=
db
.
Group
(
"gpd.group_power_id"
)
.
Order
(
"exp DESC"
)
.
Limit
(
limit
)
.
Find
(
&
res
)
.
Error
;
err
!=
nil
{
if
err
:=
db
.
Group
(
"gpd.group_power_id"
)
.
Order
(
"exp DESC"
)
.
Limit
(
limit
)
.
Find
(
&
res
)
.
Error
;
err
!=
nil
{
model
.
Log
.
Errorf
(
"GetGroupPowerExpRank fail:%v"
,
err
)
model
.
Log
.
Errorf
(
"GetGroupPowerExpRank fail:%v"
,
err
)
...
...
domain/service/group_power_s/group_power.go
View file @
145b0db7
...
@@ -140,8 +140,9 @@ func CheckoutSendMsgToMgr(myContext *mycontext.MyContext, groupPowerId uint64) {
...
@@ -140,8 +140,9 @@ func CheckoutSendMsgToMgr(myContext *mycontext.MyContext, groupPowerId uint64) {
}
}
}
}
func
GetGroupPowerRankResp
(
model
*
domain
.
Model
,
beginDate
,
endDate
string
,
userId
uint64
,
gpStatus
groupPower_e
.
GroupPowerStatus
)
(
response
group_power_cv
.
CvGroupPowerRank
,
err
error
)
{
func
GetGroupPowerRankResp
(
model
*
domain
.
Model
,
beginDate
,
endDate
string
,
userId
uint64
,
gpStatus
groupPower_e
.
GroupPowerStatus
,
rank
,
err
:=
groupPower_m
.
GetGroupPowerExpRank
(
model
,
beginDate
,
endDate
,
30
,
gpStatus
)
area
int
)
(
response
group_power_cv
.
CvGroupPowerRank
,
err
error
)
{
rank
,
err
:=
groupPower_m
.
GetGroupPowerExpRank
(
model
,
beginDate
,
endDate
,
30
,
gpStatus
,
area
)
if
err
!=
nil
{
if
err
!=
nil
{
return
return
}
}
...
@@ -254,45 +255,53 @@ func CalcGroupPowerMonthRankAct(model *domain.Model) error {
...
@@ -254,45 +255,53 @@ func CalcGroupPowerMonthRankAct(model *domain.Model) error {
}
}
func
DoCalcGroupPowerMonthRankAct
(
model
*
domain
.
Model
,
calcMonth
,
beginDate
,
endDate
string
)
error
{
func
DoCalcGroupPowerMonthRankAct
(
model
*
domain
.
Model
,
calcMonth
,
beginDate
,
endDate
string
)
error
{
// 计算获奖
areaList
:=
[]
int
{
1
,
2
}
response
,
err
:=
GetGroupPowerRankResp
(
model
,
beginDate
,
endDate
,
0
,
groupPower_e
.
GroupPowerUserHas
)
for
_
,
area
:=
range
areaList
{
// 计算获奖
if
err
!=
nil
{
model
:=
domain
.
CreateModelContext
(
model
.
MyContext
)
return
err
response
,
err
:=
GetGroupPowerRankResp
(
model
,
beginDate
,
endDate
,
0
,
groupPower_e
.
GroupPowerUserHas
,
area
)
}
powerIds
:=
make
([]
uint64
,
0
,
len
(
response
.
Items
))
for
i
,
v
:=
range
response
.
Items
{
powerIds
=
append
(
powerIds
,
v
.
Id
)
response
.
Items
[
i
]
.
StarList
,
err
=
GetGroupPowerStar
(
model
,
v
.
Id
,
groupPower_e
.
GroupPowerStarTypeFamous
,
0
,
10
,
time
.
Now
()
.
Format
(
utils
.
COMPACT_MONTH_FORMAT
))
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
}
powerIds
:=
make
([]
uint64
,
0
,
len
(
response
.
Items
))
// 奖励、日志
for
i
,
v
:=
range
response
.
Items
{
awardList
,
logList
,
err
:=
getAwardAndLogList
(
model
,
powerIds
,
response
.
Items
,
calcMonth
)
powerIds
=
append
(
powerIds
,
v
.
Id
)
if
err
!=
nil
{
response
.
Items
[
i
]
.
StarList
,
err
=
GetGroupPowerStar
(
model
,
v
.
Id
,
groupPower_e
.
GroupPowerStarTypeFamous
,
0
,
10
,
time
.
Now
()
.
Format
(
utils
.
COMPACT_MONTH_FORMAT
))
return
err
if
err
!=
nil
{
}
return
err
}
return
model
.
Transaction
(
func
(
model
*
domain
.
Model
)
error
{
}
//
log
//
奖励、日志
err
=
groupPower_m
.
CreateActFamilyMonthRankLog
(
model
,
logList
)
awardList
,
logList
,
err
:=
getAwardAndLogList
(
model
,
powerIds
,
response
.
Items
,
calcMonth
,
area
)
if
err
!=
nil
{
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"CalcGroupPowerMonthRankAct err:%+v"
,
err
)
return
err
return
err
}
}
// award
for
_
,
v
:=
range
awardList
{
err
=
model
.
Transaction
(
func
(
model
*
domain
.
Model
)
error
{
err
=
award_tx
.
SendUserAward
(
model
,
v
,
diamond_e
.
GeneralActivity
,
msg_e
.
MgrSendDiamondProperty
)
// log
err
=
groupPower_m
.
CreateActFamilyMonthRankLog
(
model
,
logList
)
if
err
!=
nil
{
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"CalcGroupPowerMonthRankAct a
ward:%+v, err:%+v"
,
v
,
err
)
model
.
Log
.
Errorf
(
"CalcGroupPowerMonthRankAct a
rea:%d, err:%+v"
,
area
,
err
)
return
err
return
err
}
}
// award
for
_
,
v
:=
range
awardList
{
err
=
award_tx
.
SendUserAward
(
model
,
v
,
diamond_e
.
GeneralActivity
,
msg_e
.
MgrSendDiamondProperty
)
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"CalcGroupPowerMonthRankAct award:%+v, err:%+v"
,
v
,
err
)
return
err
}
}
return
nil
})
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"CalcGroupPowerMonthRankAct area:%d, err:%+v"
,
area
,
err
)
return
err
}
}
return
nil
}
})
return
nil
}
}
func
getAwardAndLogList
(
model
*
domain
.
Model
,
powerIds
[]
uint64
,
items
[]
group_power_cv
.
CvGroupPowerRankData
,
calcMonth
string
)
([]
*
award_tx
.
UserAward
,
[]
*
groupPower_m
.
ActFamilyMonthRankLog
,
error
)
{
func
getAwardAndLogList
(
model
*
domain
.
Model
,
powerIds
[]
uint64
,
items
[]
group_power_cv
.
CvGroupPowerRankData
,
calcMonth
string
,
area
int
)
([]
*
award_tx
.
UserAward
,
[]
*
groupPower_m
.
ActFamilyMonthRankLog
,
error
)
{
// 读奖励配置
// 读奖励配置
confMap
:=
CalcGroupPowerMonthRankActConf
()
confMap
:=
CalcGroupPowerMonthRankActConf
()
awardList
:=
make
([]
*
award_tx
.
UserAward
,
0
,
50
)
// 奖励
awardList
:=
make
([]
*
award_tx
.
UserAward
,
0
,
50
)
// 奖励
...
@@ -334,6 +343,7 @@ func getAwardAndLogList(model *domain.Model, powerIds []uint64, items []group_po
...
@@ -334,6 +343,7 @@ func getAwardAndLogList(model *domain.Model, powerIds []uint64, items []group_po
RankUser
:
0
,
RankUser
:
0
,
UserId
:
ownerId
,
UserId
:
ownerId
,
Award
:
string
(
oAwardJ
),
Award
:
string
(
oAwardJ
),
Area
:
area
,
})
})
awardList
=
append
(
awardList
,
&
award_tx
.
UserAward
{
awardList
=
append
(
awardList
,
&
award_tx
.
UserAward
{
UserId
:
ownerId
,
UserId
:
ownerId
,
...
@@ -365,6 +375,7 @@ func getAwardAndLogList(model *domain.Model, powerIds []uint64, items []group_po
...
@@ -365,6 +375,7 @@ func getAwardAndLogList(model *domain.Model, powerIds []uint64, items []group_po
RankUser
:
uRank
,
RankUser
:
uRank
,
UserId
:
m
.
User
.
Id
,
UserId
:
m
.
User
.
Id
,
Award
:
string
(
mAwardJ
),
Award
:
string
(
mAwardJ
),
Area
:
area
,
})
})
awardList
=
append
(
awardList
,
&
award_tx
.
UserAward
{
awardList
=
append
(
awardList
,
&
award_tx
.
UserAward
{
UserId
:
m
.
User
.
Id
,
UserId
:
m
.
User
.
Id
,
...
...
mysql/group_power_month_act.sql
View file @
145b0db7
...
@@ -12,4 +12,6 @@ CREATE TABLE `act_family_month_rank_log` (
...
@@ -12,4 +12,6 @@ CREATE TABLE `act_family_month_rank_log` (
UNIQUE
KEY
`period`
(
`period`
,
`family_id`
,
`rank_user`
),
UNIQUE
KEY
`period`
(
`period`
,
`family_id`
,
`rank_user`
),
KEY
`user_idx`
(
`user_id`
)
USING
BTREE
,
KEY
`user_idx`
(
`user_id`
)
USING
BTREE
,
KEY
`created_time`
(
`created_time`
)
USING
BTREE
KEY
`created_time`
(
`created_time`
)
USING
BTREE
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
COLLATE
=
utf8mb4_0900_ai_ci
COMMENT
=
'家族月度排行发奖日志'
;
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
COLLATE
=
utf8mb4_0900_ai_ci
COMMENT
=
'家族月度排行发奖日志'
;
\ No newline at end of file
ALTER
TABLE
hilo
.
act_family_month_rank_log
ADD
area
TINYINT
DEFAULT
0
NOT
NULL
COMMENT
'区域1.阿语区2.非阿语区'
;
route/group_power_r/group_rank.go
View file @
145b0db7
...
@@ -47,7 +47,7 @@ func GroupPowerRank(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -47,7 +47,7 @@ func GroupPowerRank(c *gin.Context) (*mycontext.MyContext, error) {
beginDate
,
endDate
=
now
.
BeginningOfMonth
()
.
Format
(
"2006-01-02"
),
now
.
EndOfMonth
()
.
Format
(
"2006-01-02"
)
beginDate
,
endDate
=
now
.
BeginningOfMonth
()
.
Format
(
"2006-01-02"
),
now
.
EndOfMonth
()
.
Format
(
"2006-01-02"
)
}
}
var
model
=
domain
.
CreateModelContext
(
myContext
)
var
model
=
domain
.
CreateModelContext
(
myContext
)
response
,
err
:=
group_power_s
.
GetGroupPowerRankResp
(
model
,
beginDate
,
endDate
,
userId
,
0
)
response
,
err
:=
group_power_s
.
GetGroupPowerRankResp
(
model
,
beginDate
,
endDate
,
userId
,
0
,
0
)
if
err
!=
nil
{
if
err
!=
nil
{
return
myContext
,
err
return
myContext
,
err
}
}
...
@@ -66,9 +66,35 @@ func GroupPowerMonthRankAct(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -66,9 +66,35 @@ func GroupPowerMonthRankAct(c *gin.Context) (*mycontext.MyContext, error) {
return
myContext
,
err
return
myContext
,
err
}
}
var
model
=
domain
.
CreateModelContext
(
myContext
)
var
model
=
domain
.
CreateModelContext
(
myContext
)
// 国家区域
var
area
int
// 我的家族
myGroupPower
,
err
:=
groupPower_m
.
GetGroupPowerUserOrNil
(
model
,
userId
)
if
err
!=
nil
{
return
myContext
,
err
}
if
myGroupPower
!=
nil
&&
myGroupPower
.
GroupPowerId
>
0
{
//获取势力主
mgrUserId
,
err
:=
groupPower_m
.
GetGroupPowerMgr
(
model
,
myGroupPower
.
GroupPowerId
)
if
err
!=
nil
{
return
myContext
,
err
}
_
,
area
,
err
=
user_m
.
GetUserCountryArea
(
model
,
mgrUserId
)
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"GroupPowerMonthRankAct 获取国家资源错误 userId:%d, err:%v"
,
userId
,
err
)
return
myContext
,
err
}
}
if
area
==
0
{
_
,
area
,
err
=
user_m
.
GetUserCountryArea
(
model
,
userId
)
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"GroupPowerMonthRankAct 获取国家资源错误 userId:%d, err:%v"
,
userId
,
err
)
return
myContext
,
err
}
}
// 这个月
// 这个月
beginDate
,
endDate
:=
now
.
BeginningOfMonth
()
.
Format
(
utils
.
DATE_FORMAT
),
now
.
EndOfMonth
()
.
Format
(
utils
.
DATE_FORMAT
)
beginDate
,
endDate
:=
now
.
BeginningOfMonth
()
.
Format
(
utils
.
DATE_FORMAT
),
now
.
EndOfMonth
()
.
Format
(
utils
.
DATE_FORMAT
)
response
,
err
:=
GroupPowerMonthRankActByMonth
(
model
,
userId
,
beginDate
,
endDate
,
time
.
Now
()
.
Format
(
utils
.
COMPACT_MONTH_FORMAT
))
response
,
err
:=
GroupPowerMonthRankActByMonth
(
model
,
userId
,
beginDate
,
endDate
,
time
.
Now
()
.
Format
(
utils
.
COMPACT_MONTH_FORMAT
)
,
area
)
if
err
!=
nil
{
if
err
!=
nil
{
return
myContext
,
err
return
myContext
,
err
}
}
...
@@ -76,7 +102,7 @@ func GroupPowerMonthRankAct(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -76,7 +102,7 @@ func GroupPowerMonthRankAct(c *gin.Context) (*mycontext.MyContext, error) {
lastMonthStart
:=
utils
.
GetLastMonthStart
(
time
.
Now
())
lastMonthStart
:=
utils
.
GetLastMonthStart
(
time
.
Now
())
lastTime
:=
now
.
New
(
lastMonthStart
)
lastTime
:=
now
.
New
(
lastMonthStart
)
beginDateLast
,
endDateLast
:=
lastTime
.
BeginningOfMonth
()
.
Format
(
utils
.
DATE_FORMAT
),
lastTime
.
EndOfMonth
()
.
Format
(
utils
.
DATE_FORMAT
)
beginDateLast
,
endDateLast
:=
lastTime
.
BeginningOfMonth
()
.
Format
(
utils
.
DATE_FORMAT
),
lastTime
.
EndOfMonth
()
.
Format
(
utils
.
DATE_FORMAT
)
responseLast
,
err
:=
GroupPowerMonthRankActByMonth
(
model
,
userId
,
beginDateLast
,
endDateLast
,
lastMonthStart
.
Format
(
utils
.
COMPACT_MONTH_FORMAT
))
responseLast
,
err
:=
GroupPowerMonthRankActByMonth
(
model
,
userId
,
beginDateLast
,
endDateLast
,
lastMonthStart
.
Format
(
utils
.
COMPACT_MONTH_FORMAT
)
,
area
)
if
err
!=
nil
{
if
err
!=
nil
{
return
myContext
,
err
return
myContext
,
err
}
}
...
@@ -92,8 +118,8 @@ func GroupPowerMonthRankAct(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -92,8 +118,8 @@ func GroupPowerMonthRankAct(c *gin.Context) (*mycontext.MyContext, error) {
return
myContext
,
nil
return
myContext
,
nil
}
}
func
GroupPowerMonthRankActByMonth
(
model
*
domain
.
Model
,
userId
uint64
,
beginDate
,
endDate
,
month
string
)
(
response
group_power_cv
.
CvGroupPowerRank
,
err
error
)
{
func
GroupPowerMonthRankActByMonth
(
model
*
domain
.
Model
,
userId
uint64
,
beginDate
,
endDate
,
month
string
,
area
int
)
(
response
group_power_cv
.
CvGroupPowerRank
,
err
error
)
{
response
,
err
=
group_power_s
.
GetGroupPowerRankResp
(
model
,
beginDate
,
endDate
,
userId
,
groupPower_e
.
GroupPowerUserHas
)
response
,
err
=
group_power_s
.
GetGroupPowerRankResp
(
model
,
beginDate
,
endDate
,
userId
,
groupPower_e
.
GroupPowerUserHas
,
area
)
if
err
!=
nil
{
if
err
!=
nil
{
return
response
,
err
return
response
,
err
}
}
...
@@ -133,7 +159,7 @@ func GroupPowerRankTop(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -133,7 +159,7 @@ func GroupPowerRankTop(c *gin.Context) (*mycontext.MyContext, error) {
beginDate
,
endDate
=
now
.
BeginningOfMonth
()
.
Format
(
"2006-01-02"
),
now
.
EndOfMonth
()
.
Format
(
"2006-01-02"
)
beginDate
,
endDate
=
now
.
BeginningOfMonth
()
.
Format
(
"2006-01-02"
),
now
.
EndOfMonth
()
.
Format
(
"2006-01-02"
)
}
}
var
model
=
domain
.
CreateModelContext
(
myContext
)
var
model
=
domain
.
CreateModelContext
(
myContext
)
rank
,
err
:=
groupPower_m
.
GetGroupPowerExpRank
(
model
,
beginDate
,
endDate
,
3
,
0
)
rank
,
err
:=
groupPower_m
.
GetGroupPowerExpRank
(
model
,
beginDate
,
endDate
,
3
,
0
,
0
)
if
err
!=
nil
{
if
err
!=
nil
{
return
myContext
,
err
return
myContext
,
err
}
}
...
...
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