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
c835a8d9
Commit
c835a8d9
authored
Apr 24, 2023
by
chenweijian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
家族月度排行活动
parent
8330b0ff
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
38 deletions
+57
-38
groupPower.go
domain/model/groupPower_m/groupPower.go
+1
-0
group_rank.go
domain/model/groupPower_m/group_rank.go
+5
-1
group_power.go
domain/service/group_power_s/group_power.go
+36
-30
group_power_month_act.sql
mysql/group_power_month_act.sql
+3
-1
group_rank.go
route/group_power_r/group_rank.go
+12
-6
No files found.
domain/model/groupPower_m/groupPower.go
View file @
c835a8d9
...
...
@@ -51,6 +51,7 @@ type ActFamilyMonthRankLog struct {
RankUser
int
`json:"rank_user"`
UserId
uint64
`json:"user_id"`
Award
string
`json:"award"`
Area
int
`json:"area"`
}
func
(
gpu
*
GroupPowerUser
)
Get
(
db
*
gorm
.
DB
)
([]
GroupPowerUser
,
error
)
{
...
...
domain/model/groupPower_m/group_rank.go
View file @
c835a8d9
...
...
@@ -15,12 +15,16 @@ type GroupPowerExpRank struct {
// 获取家族经验排行榜
// 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
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
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
{
model
.
Log
.
Errorf
(
"GetGroupPowerExpRank fail:%v"
,
err
)
...
...
domain/service/group_power_s/group_power.go
View file @
c835a8d9
...
...
@@ -79,8 +79,9 @@ func (s *GroupPowerService) GroupPowerUserLeave(groupPowerId mysql.ID, userId my
return
remainSeconds
,
err
}
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
)
func
GetGroupPowerRankResp
(
model
*
domain
.
Model
,
beginDate
,
endDate
string
,
userId
uint64
,
gpStatus
groupPower_e
.
GroupPowerStatus
,
area
int
)
(
response
group_power_cv
.
CvGroupPowerRank
,
err
error
)
{
rank
,
err
:=
groupPower_m
.
GetGroupPowerExpRank
(
model
,
beginDate
,
endDate
,
30
,
gpStatus
,
area
)
if
err
!=
nil
{
return
}
...
...
@@ -193,8 +194,9 @@ func CalcGroupPowerMonthRankAct(model *domain.Model) error {
}
func
DoCalcGroupPowerMonthRankAct
(
model
*
domain
.
Model
,
calcMonth
,
beginDate
,
endDate
string
)
error
{
// 计算获奖
response
,
err
:=
GetGroupPowerRankResp
(
model
,
beginDate
,
endDate
,
0
,
groupPower_e
.
GroupPowerUserHas
)
areaList
:=
[]
int
{
1
,
2
}
for
_
,
area
:=
range
areaList
{
// 计算获奖
response
,
err
:=
GetGroupPowerRankResp
(
model
,
beginDate
,
endDate
,
0
,
groupPower_e
.
GroupPowerUserHas
,
area
)
if
err
!=
nil
{
return
err
}
...
...
@@ -207,7 +209,7 @@ func DoCalcGroupPowerMonthRankAct(model *domain.Model, calcMonth, beginDate, end
}
}
// 奖励、日志
awardList
,
logList
,
err
:=
getAwardAndLogList
(
model
,
powerIds
,
response
.
Items
,
calcMonth
)
awardList
,
logList
,
err
:=
getAwardAndLogList
(
model
,
powerIds
,
response
.
Items
,
calcMonth
,
area
)
if
err
!=
nil
{
return
err
}
...
...
@@ -229,9 +231,11 @@ func DoCalcGroupPowerMonthRankAct(model *domain.Model, calcMonth, beginDate, end
}
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
()
awardList
:=
make
([]
*
award_tx
.
UserAward
,
0
,
50
)
// 奖励
...
...
@@ -273,6 +277,7 @@ func getAwardAndLogList(model *domain.Model, powerIds []uint64, items []group_po
RankUser
:
0
,
UserId
:
ownerId
,
Award
:
string
(
oAwardJ
),
Area
:
area
,
})
awardList
=
append
(
awardList
,
&
award_tx
.
UserAward
{
UserId
:
ownerId
,
...
...
@@ -304,6 +309,7 @@ func getAwardAndLogList(model *domain.Model, powerIds []uint64, items []group_po
RankUser
:
uRank
,
UserId
:
m
.
User
.
Id
,
Award
:
string
(
mAwardJ
),
Area
:
area
,
})
awardList
=
append
(
awardList
,
&
award_tx
.
UserAward
{
UserId
:
m
.
User
.
Id
,
...
...
mysql/group_power_month_act.sql
View file @
c835a8d9
...
...
@@ -13,3 +13,5 @@ CREATE TABLE `act_family_month_rank_log` (
KEY
`user_idx`
(
`user_id`
)
USING
BTREE
,
KEY
`created_time`
(
`created_time`
)
USING
BTREE
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
COLLATE
=
utf8mb4_0900_ai_ci
COMMENT
=
'家族月度排行发奖日志'
;
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 @
c835a8d9
...
...
@@ -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
,
0
)
response
,
err
:=
group_power_s
.
GetGroupPowerRankResp
(
model
,
beginDate
,
endDate
,
userId
,
0
,
0
)
if
err
!=
nil
{
return
myContext
,
err
}
...
...
@@ -66,9 +66,15 @@ func GroupPowerMonthRankAct(c *gin.Context) (*mycontext.MyContext, error) {
return
myContext
,
err
}
var
model
=
domain
.
CreateModelContext
(
myContext
)
// 国家区域
_
,
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
)
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
{
return
myContext
,
err
}
...
...
@@ -76,7 +82,7 @@ func GroupPowerMonthRankAct(c *gin.Context) (*mycontext.MyContext, error) {
lastMonthStart
:=
utils
.
GetLastMonthStart
(
time
.
Now
())
lastTime
:=
now
.
New
(
lastMonthStart
)
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
{
return
myContext
,
err
}
...
...
@@ -92,8 +98,8 @@ func GroupPowerMonthRankAct(c *gin.Context) (*mycontext.MyContext, error) {
return
myContext
,
nil
}
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
,
groupPower_e
.
GroupPowerUserHas
)
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
,
area
)
if
err
!=
nil
{
return
response
,
err
}
...
...
@@ -133,7 +139,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
,
0
)
rank
,
err
:=
groupPower_m
.
GetGroupPowerExpRank
(
model
,
beginDate
,
endDate
,
3
,
0
,
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