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
124073a1
Commit
124073a1
authored
Apr 25, 2023
by
chenweijian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
家族月度排行活动分区
parent
4e9c0510
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 @
124073a1
...
...
@@ -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 @
124073a1
...
...
@@ -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
)
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
{
model
.
Log
.
Errorf
(
"GetGroupPowerExpRank fail:%v"
,
err
)
...
...
domain/service/group_power_s/group_power.go
View file @
124073a1
...
...
@@ -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,45 +194,53 @@ 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
)
if
err
!=
nil
{
return
err
}
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
))
areaList
:=
[]
int
{
1
,
2
}
for
_
,
area
:=
range
areaList
{
// 计算获奖
model
:=
domain
.
CreateModelContext
(
model
.
MyContext
)
response
,
err
:=
GetGroupPowerRankResp
(
model
,
beginDate
,
endDate
,
0
,
groupPower_e
.
GroupPowerUserHas
,
area
)
if
err
!=
nil
{
return
err
}
}
// 奖励、日志
awardList
,
logList
,
err
:=
getAwardAndLogList
(
model
,
powerIds
,
response
.
Items
,
calcMonth
)
if
err
!=
nil
{
return
err
}
return
model
.
Transaction
(
func
(
model
*
domain
.
Model
)
error
{
//
log
err
=
groupPower_m
.
CreateActFamilyMonthRankLog
(
model
,
logList
)
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
{
return
err
}
}
//
奖励、日志
awardList
,
logList
,
err
:=
getAwardAndLogList
(
model
,
powerIds
,
response
.
Items
,
calcMonth
,
area
)
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"CalcGroupPowerMonthRankAct err:%+v"
,
err
)
return
err
}
// award
for
_
,
v
:=
range
awardList
{
err
=
award_tx
.
SendUserAward
(
model
,
v
,
diamond_e
.
GeneralActivity
,
msg_e
.
MgrSendDiamondProperty
)
err
=
model
.
Transaction
(
func
(
model
*
domain
.
Model
)
error
{
// log
err
=
groupPower_m
.
CreateActFamilyMonthRankLog
(
model
,
logList
)
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
}
// 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
()
awardList
:=
make
([]
*
award_tx
.
UserAward
,
0
,
50
)
// 奖励
...
...
@@ -273,6 +282,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 +314,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 @
124073a1
...
...
@@ -12,4 +12,6 @@ CREATE TABLE `act_family_month_rank_log` (
UNIQUE
KEY
`period`
(
`period`
,
`family_id`
,
`rank_user`
),
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
=
'家族月度排行发奖日志'
;
\ No newline at end of file
)
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 @
124073a1
...
...
@@ -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,35 @@ func GroupPowerMonthRankAct(c *gin.Context) (*mycontext.MyContext, error) {
return
myContext
,
err
}
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
)
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 +102,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 +118,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 +159,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