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
b9dde787
Commit
b9dde787
authored
May 01, 2023
by
chenweijian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
家族排行奖励补发
parent
8c06f31f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
187 additions
and
6 deletions
+187
-6
cron.go
cron/cron.go
+1
-0
group_power_month_act.go
cron/group_cron/group_power_month_act.go
+13
-0
group_power.go
domain/service/group_power_s/group_power.go
+163
-5
group_power_test.go
test/group_power_test.go
+10
-1
No files found.
cron/cron.go
View file @
b9dde787
...
...
@@ -16,4 +16,5 @@ func Init() {
mic_cron
.
OnMicCheck
()
// 检查上麦
group_cron
.
GroupPowerExpClear
()
// 清理家族经验/等级
group_cron
.
GroupPowerMonthRankAct
()
group_cron
.
BufaGroupPowerMonthRankAct
()
}
cron/group_cron/group_power_month_act.go
View file @
b9dde787
...
...
@@ -20,3 +20,16 @@ func GroupPowerMonthRankAct() {
c
.
Start
()
}
func
BufaGroupPowerMonthRankAct
()
{
c
:=
cron
.
New
()
spec
:=
"0 4 15 1 * ?"
_
=
c
.
AddFunc
(
spec
,
func
()
{
var
model
=
domain
.
CreateModelNil
()
if
err
:=
group_power_s
.
BufaCalcGroupPowerMonthRankAct
(
model
);
err
!=
nil
{
model
.
Log
.
Errorf
(
"BufaGroupPowerMonthRankAct fail:%v"
,
err
)
}
})
c
.
Start
()
}
domain/service/group_power_s/group_power.go
View file @
b9dde787
...
...
@@ -16,11 +16,11 @@ import (
"hilo-group/domain/cache/user_c"
"hilo-group/domain/event/group_power_ev"
"hilo-group/domain/model/groupPower_m"
"time"
"hilo-group/domain/model/msg_m"
"hilo-group/domain/model/noble_m"
"hilo-group/domain/model/user_m"
"hilo-group/myerr/bizerr"
"time"
)
type
GroupPowerService
struct
{
...
...
@@ -193,11 +193,21 @@ func CalcGroupPowerMonthRankAct(model *domain.Model) error {
lastDayTime
:=
time
.
Now
()
.
AddDate
(
0
,
0
,
-
1
)
_now
:=
now
.
New
(
lastDayTime
)
calcMonth
:=
_now
.
BeginningOfMonth
()
.
Format
(
utils
.
MONTH_FORMAT
)
starDate
:=
_now
.
BeginningOfMonth
()
.
Format
(
utils
.
COMPACT_MONTH_FORMAT
)
beginDate
,
endDate
:=
_now
.
BeginningOfMonth
()
.
Format
(
"2006-01-02"
),
_now
.
EndOfMonth
()
.
Format
(
"2006-01-02"
)
return
DoCalcGroupPowerMonthRankAct
(
model
,
calcMonth
,
beginDate
,
endDate
,
starDate
)
}
func
BufaCalcGroupPowerMonthRankAct
(
model
*
domain
.
Model
)
error
{
lastDayTime
:=
time
.
Now
()
.
AddDate
(
0
,
0
,
-
1
)
_now
:=
now
.
New
(
lastDayTime
)
calcMonth
:=
_now
.
BeginningOfMonth
()
.
Format
(
utils
.
MONTH_FORMAT
)
starDate
:=
_now
.
BeginningOfMonth
()
.
Format
(
utils
.
COMPACT_MONTH_FORMAT
)
beginDate
,
endDate
:=
_now
.
BeginningOfMonth
()
.
Format
(
"2006-01-02"
),
_now
.
EndOfMonth
()
.
Format
(
"2006-01-02"
)
return
DoCalcGroupPowerMonthRankAct
(
model
,
calcMonth
,
beginDate
,
end
Date
)
return
BufaDoCalcGroupPowerMonthRankAct
(
model
,
calcMonth
,
beginDate
,
endDate
,
star
Date
)
}
func
DoCalcGroupPowerMonthRankAct
(
model
*
domain
.
Model
,
calcMonth
,
beginDate
,
endDate
string
)
error
{
func
DoCalcGroupPowerMonthRankAct
(
model
*
domain
.
Model
,
calcMonth
,
beginDate
,
endDate
,
starDate
string
)
error
{
areaList
:=
[]
int
{
1
,
2
}
for
_
,
area
:=
range
areaList
{
// 计算获奖
model
:=
domain
.
CreateModelContext
(
model
.
MyContext
)
...
...
@@ -208,7 +218,7 @@ func DoCalcGroupPowerMonthRankAct(model *domain.Model, calcMonth, beginDate, end
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
)
)
response
.
Items
[
i
]
.
StarList
,
err
=
GetGroupPowerStar
(
model
,
v
.
Id
,
groupPower_e
.
GroupPowerStarTypeFamous
,
0
,
10
,
starDate
)
if
err
!=
nil
{
return
err
}
...
...
@@ -244,10 +254,65 @@ func DoCalcGroupPowerMonthRankAct(model *domain.Model, calcMonth, beginDate, end
return
nil
}
func
BufaDoCalcGroupPowerMonthRankAct
(
model
*
domain
.
Model
,
calcMonth
,
beginDate
,
endDate
,
starDate
string
)
error
{
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
}
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
,
starDate
)
if
err
!=
nil
{
return
err
}
}
// 奖励、日志
awardList
,
logList
,
err
:=
bufaGetAwardAndLogList
(
model
,
powerIds
,
response
.
Items
,
calcMonth
,
area
)
if
err
!=
nil
{
return
err
}
//if area == 1 {
// for _, v := range logList {
// if v.RankUser == 1 {
// model.Log.Infof("bufajiangli award:%+v", v)
// }
// }
//}
err
=
model
.
Transaction
(
func
(
model
*
domain
.
Model
)
error
{
// log
err
=
groupPower_m
.
CreateActFamilyMonthRankLog
(
model
,
logList
)
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"CalcGroupPowerMonthRankAct area:%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
}
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
,
5
0
)
// 奖励
awardList
:=
make
([]
*
award_tx
.
UserAward
,
0
,
12
0
)
// 奖励
ownerMap
,
err
:=
groupPower_m
.
GetPowerOwnerMap
(
model
,
powerIds
)
if
err
!=
nil
{
return
nil
,
nil
,
err
...
...
@@ -334,6 +399,99 @@ func getAwardAndLogList(model *domain.Model, powerIds []uint64, items []group_po
return
awardList
,
logList
,
nil
}
func
bufaGetAwardAndLogList
(
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
,
120
)
// 奖励
ownerMap
,
err
:=
groupPower_m
.
GetPowerOwnerMap
(
model
,
powerIds
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
// log list
logList
:=
make
([]
*
groupPower_m
.
ActFamilyMonthRankLog
,
0
,
50
)
for
_
,
v
:=
range
items
{
teamRank
:=
0
if
v
.
Rank
>=
1
&&
v
.
Rank
<=
3
{
teamRank
=
v
.
Rank
}
else
if
v
.
Rank
>=
4
&&
v
.
Rank
<=
10
{
teamRank
=
4
}
else
{
break
}
ownerId
,
ok
:=
ownerMap
[
v
.
Id
]
if
!
ok
||
ownerId
<=
0
{
model
.
Log
.
Errorf
(
"CalcGroupPowerMonthRankAct 获取势力主错误 familyId:%d"
,
v
.
Id
)
return
nil
,
nil
,
bizerr
.
InvalidParameter
}
uRankConfMap
,
tCOk
:=
confMap
[
teamRank
]
if
!
tCOk
{
break
}
//// 家族长奖励
//oAward, aOk := uRankConfMap[0]
//if !aOk {
// model.Log.Errorf("CalcGroupPowerMonthRankAct 配置错误:%v", confMap)
// return nil, nil, bizerr.InvalidParameter
//}
//oAwardJ, _ := json.Marshal(oAward)
//logList = append(logList, &groupPower_m.ActFamilyMonthRankLog{
// Period: calcMonth,
// FamilyId: v.Id,
// RankFamily: v.Rank,
// RankUser: 0,
// UserId: ownerId,
// Award: string(oAwardJ),
// Area: area,
//})
//awardList = append(awardList, &award_tx.UserAward{
// UserId: ownerId,
// MedalId: oAward.MedalId,
// MedalDuration: oAward.MedalDay,
// Diamond: oAward.Diamond,
// NobleLevel: oAward.Noble,
// NobleDuration: oAward.NobleDay,
// HeaddressId: oAward.HeaddressId,
// HeaddressDuration: oAward.HeaddressDay})
// 家族成员奖励
for
i
,
m
:=
range
v
.
StarList
{
if
m
.
User
.
Id
==
5343751
||
m
.
User
.
Id
==
1180791
{
continue
}
uRank
:=
i
+
1
confIdx
:=
9
if
uRank
>=
1
&&
uRank
<=
3
{
confIdx
=
1
}
else
if
uRank
>=
4
&&
uRank
<=
10
{
confIdx
=
4
}
mAward
,
aOk
:=
uRankConfMap
[
confIdx
]
if
!
aOk
{
break
}
mAwardJ
,
_
:=
json
.
Marshal
(
mAward
)
logList
=
append
(
logList
,
&
groupPower_m
.
ActFamilyMonthRankLog
{
Period
:
calcMonth
,
FamilyId
:
v
.
Id
,
RankFamily
:
v
.
Rank
,
RankUser
:
uRank
,
UserId
:
m
.
User
.
Id
,
Award
:
string
(
mAwardJ
),
Area
:
area
,
})
awardList
=
append
(
awardList
,
&
award_tx
.
UserAward
{
UserId
:
m
.
User
.
Id
,
MedalId
:
mAward
.
MedalId
,
MedalDuration
:
mAward
.
MedalDay
,
Diamond
:
mAward
.
Diamond
,
NobleLevel
:
mAward
.
Noble
,
NobleDuration
:
mAward
.
NobleDay
,
HeaddressId
:
mAward
.
HeaddressId
,
HeaddressDuration
:
mAward
.
HeaddressDay
})
}
}
return
awardList
,
logList
,
nil
}
// 奖励配置
type
awardConf
struct
{
MedalId
uint64
...
...
test/group_power_test.go
View file @
b9dde787
...
...
@@ -38,5 +38,14 @@ func TestDoCalcGroupPowerMonthRankAct(t *testing.T) {
_now
:=
now
.
New
(
lastDayTime
)
calcMonth
:=
_now
.
BeginningOfMonth
()
.
Format
(
utils
.
MONTH_FORMAT
)
beginDate
,
endDate
:=
_now
.
BeginningOfMonth
()
.
Format
(
"2006-01-02"
),
_now
.
EndOfMonth
()
.
Format
(
"2006-01-02"
)
_
=
group_power_s
.
DoCalcGroupPowerMonthRankAct
(
domain
.
CreateModelNil
(),
calcMonth
,
beginDate
,
endDate
)
_
=
group_power_s
.
DoCalcGroupPowerMonthRankAct
(
domain
.
CreateModelNil
(),
calcMonth
,
beginDate
,
endDate
,
""
)
}
func
TestDoCalcGroupPowerMonthRankActbufa
(
t
*
testing
.
T
)
{
lastDayTime
:=
time
.
Now
()
.
AddDate
(
0
,
0
,
-
1
)
_now
:=
now
.
New
(
lastDayTime
)
calcMonth
:=
_now
.
BeginningOfMonth
()
.
Format
(
utils
.
MONTH_FORMAT
)
starDate
:=
_now
.
BeginningOfMonth
()
.
Format
(
utils
.
COMPACT_MONTH_FORMAT
)
beginDate
,
endDate
:=
_now
.
BeginningOfMonth
()
.
Format
(
"2006-01-02"
),
_now
.
EndOfMonth
()
.
Format
(
"2006-01-02"
)
_
=
group_power_s
.
BufaDoCalcGroupPowerMonthRankAct
(
domain
.
CreateModelNil
(),
calcMonth
,
beginDate
,
endDate
,
starDate
)
}
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