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
569fbe66
Commit
569fbe66
authored
Apr 23, 2023
by
chenweijian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
月度排行发奖
parent
67817eb2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
9 deletions
+14
-9
group_rank.go
domain/model/groupPower_m/group_rank.go
+8
-3
group_power.go
domain/service/group_power_s/group_power.go
+3
-3
group_rank.go
route/group_power_r/group_rank.go
+3
-3
No files found.
domain/model/groupPower_m/group_rank.go
View file @
569fbe66
...
...
@@ -4,6 +4,7 @@ import (
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
"gorm.io/gorm"
"hilo-group/_const/enum/groupPower_e"
)
type
GroupPowerExpRank
struct
{
...
...
@@ -14,10 +15,14 @@ type GroupPowerExpRank struct {
// 获取家族经验排行榜
// param limit: 排行榜人数
func
GetGroupPowerExpRank
(
model
*
domain
.
Model
,
beginDate
,
endDate
string
,
limit
int
)
([]
GroupPowerExpRank
,
error
)
{
func
GetGroupPowerExpRank
(
model
*
domain
.
Model
,
beginDate
,
endDate
string
,
limit
int
,
gpStatus
groupPower_e
.
GroupPowerStatus
)
([]
GroupPowerExpRank
,
error
)
{
var
res
[]
GroupPowerExpRank
if
err
:=
model
.
DB
()
.
Table
(
"group_power_day_exp"
)
.
Select
(
"group_power_id,SUM(exp) as exp"
)
.
Where
(
"date BETWEEN ? AND ?"
,
beginDate
,
endDate
)
.
Group
(
"group_power_id"
)
.
Order
(
"exp DESC"
)
.
Limit
(
limit
)
.
Find
(
&
res
)
.
Error
;
err
!=
nil
{
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
)
if
gpStatus
>
0
{
db
=
db
.
Joins
(
"left join group_power gp on gpd.group_power_id = gp.id"
)
.
Where
(
"status = ?"
,
gpStatus
)
}
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
)
return
res
,
err
}
...
...
domain/service/group_power_s/group_power.go
View file @
569fbe66
...
...
@@ -79,8 +79,8 @@ func (s *GroupPowerService) GroupPowerUserLeave(groupPowerId mysql.ID, userId my
return
remainSeconds
,
err
}
func
GetGroupPowerRankResp
(
model
*
domain
.
Model
,
beginDate
,
endDate
string
,
userId
uint64
)
(
response
group_power_cv
.
CvGroupPowerRank
,
err
error
)
{
rank
,
err
:=
groupPower_m
.
GetGroupPowerExpRank
(
model
,
beginDate
,
endDate
,
30
)
func
GetGroupPowerRankResp
(
model
*
domain
.
Model
,
beginDate
,
endDate
string
,
userId
uint64
,
gpStatus
groupPower_e
.
GroupPowerStatus
)
(
response
group_power_cv
.
CvGroupPowerRank
,
err
error
)
{
rank
,
err
:=
groupPower_m
.
GetGroupPowerExpRank
(
model
,
beginDate
,
endDate
,
30
,
gpStatus
)
if
err
!=
nil
{
return
}
...
...
@@ -194,7 +194,7 @@ func CalcGroupPowerMonthRankAct(model *domain.Model) error {
func
DoCalcGroupPowerMonthRankAct
(
model
*
domain
.
Model
,
calcMonth
,
beginDate
,
endDate
string
)
error
{
// 计算获奖
response
,
err
:=
GetGroupPowerRankResp
(
model
,
beginDate
,
endDate
,
0
)
response
,
err
:=
GetGroupPowerRankResp
(
model
,
beginDate
,
endDate
,
0
,
groupPower_e
.
GroupPowerUserHas
)
if
err
!=
nil
{
return
err
}
...
...
route/group_power_r/group_rank.go
View file @
569fbe66
...
...
@@ -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"
)
}
var
model
=
domain
.
CreateModelContext
(
myContext
)
response
,
err
:=
group_power_s
.
GetGroupPowerRankResp
(
model
,
beginDate
,
endDate
,
userId
)
response
,
err
:=
group_power_s
.
GetGroupPowerRankResp
(
model
,
beginDate
,
endDate
,
userId
,
0
)
if
err
!=
nil
{
return
myContext
,
err
}
...
...
@@ -93,7 +93,7 @@ func GroupPowerMonthRankAct(c *gin.Context) (*mycontext.MyContext, error) {
}
func
GroupPowerMonthRankActByMonth
(
model
*
domain
.
Model
,
userId
uint64
,
beginDate
,
endDate
,
month
string
)
(
response
group_power_cv
.
CvGroupPowerRank
,
err
error
)
{
response
,
err
=
group_power_s
.
GetGroupPowerRankResp
(
model
,
beginDate
,
endDate
,
userId
)
response
,
err
=
group_power_s
.
GetGroupPowerRankResp
(
model
,
beginDate
,
endDate
,
userId
,
groupPower_e
.
GroupPowerUserHas
)
if
err
!=
nil
{
return
response
,
err
}
...
...
@@ -133,7 +133,7 @@ func GroupPowerRankTop(c *gin.Context) (*mycontext.MyContext, error) {
beginDate
,
endDate
=
now
.
BeginningOfMonth
()
.
Format
(
"2006-01-02"
),
now
.
EndOfMonth
()
.
Format
(
"2006-01-02"
)
}
var
model
=
domain
.
CreateModelContext
(
myContext
)
rank
,
err
:=
groupPower_m
.
GetGroupPowerExpRank
(
model
,
beginDate
,
endDate
,
3
)
rank
,
err
:=
groupPower_m
.
GetGroupPowerExpRank
(
model
,
beginDate
,
endDate
,
3
,
0
)
if
err
!=
nil
{
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