Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
A
antai-sport-http-server
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
antai-sport
antai-sport-http-server
Commits
c990fede
Commit
c990fede
authored
Jul 20, 2022
by
liming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
用户运动积分结算
parent
988d6884
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
97 additions
and
15 deletions
+97
-15
GameCurrencyLogType.java
...ntai/sport/http/server/constants/GameCurrencyLogType.java
+6
-0
SportUserGameCurrencyMatchRule.java
...epository/shop/entity/SportUserGameCurrencyMatchRule.java
+3
-1
SportUserTrainingLogService.java
...ness/traininglog/service/SportUserTrainingLogService.java
+88
-14
No files found.
constants/src/main/java/com/antai/sport/http/server/constants/GameCurrencyLogType.java
0 → 100644
View file @
c990fede
package
com
.
antai
.
sport
.
http
.
server
.
constants
;
public
class
GameCurrencyLogType
{
public
static
final
Integer
ADD
=
1
;
public
static
final
Integer
SUBTRACT
=
2
;
}
repository/src/main/java/com/antai/sport/http/server/repository/shop/entity/SportUserGameCurrencyMatchRule.java
View file @
c990fede
...
...
@@ -2,6 +2,8 @@ package com.antai.sport.http.server.repository.shop.entity;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
java.math.BigDecimal
;
import
java.time.LocalDateTime
;
import
java.io.Serializable
;
import
lombok.Data
;
...
...
@@ -35,7 +37,7 @@ public class SportUserGameCurrencyMatchRule implements Serializable {
/**
* 倍率
*/
private
Integer
rate
;
private
BigDecimal
rate
;
/**
* 排名启示值
...
...
server-api/src/main/java/com/antai/sport/http/server/server/api/business/traininglog/service/SportUserTrainingLogService.java
View file @
c990fede
package
com
.
antai
.
sport
.
http
.
server
.
server
.
api
.
business
.
traininglog
.
service
;
import
com.antai.sport.http.server.constants.DeleteStatus
;
import
com.antai.sport.http.server.constants.GameMode
;
import
com.antai.sport.http.server.constants.RankType
;
import
com.antai.sport.http.server.constants.SportType
;
import
com.antai.sport.http.server.constants.*
;
import
com.antai.sport.http.server.repository.club.entity.Club
;
import
com.antai.sport.http.server.repository.club.entity.ClubMember
;
import
com.antai.sport.http.server.repository.club.mapper.ClubMapper
;
import
com.antai.sport.http.server.repository.club.mapper.ClubMemberMapper
;
import
com.antai.sport.http.server.repository.roommode.entity.RoomMode
;
import
com.antai.sport.http.server.repository.roommode.mapper.RoomModeMapper
;
import
com.antai.sport.http.server.repository.shop.entity.SportUserGameCurrency
;
import
com.antai.sport.http.server.repository.shop.entity.SportUserGameCurrencyBaseRule
;
import
com.antai.sport.http.server.repository.shop.entity.SportUserGameCurrencyLog
;
import
com.antai.sport.http.server.repository.shop.entity.SportUserGameCurrencyMatchRule
;
import
com.antai.sport.http.server.repository.shop.mapper.SportUserGameCurrencyBaseRuleMapper
;
import
com.antai.sport.http.server.repository.shop.mapper.SportUserGameCurrencyLogMapper
;
import
com.antai.sport.http.server.repository.shop.mapper.SportUserGameCurrencyMapper
;
import
com.antai.sport.http.server.repository.shop.mapper.SportUserGameCurrencyMatchRuleMapper
;
import
com.antai.sport.http.server.repository.simplematch.entity.SimpleMatch
;
import
com.antai.sport.http.server.repository.simplematch.mapper.SimpleMatchMapper
;
import
com.antai.sport.http.server.repository.sport.entity.*
;
...
...
@@ -82,7 +87,8 @@ public class SportUserTrainingLogService {
@Resource
private
SportUserConverter
sportUserConverter
;
public
void
createBicycleTrainingLog
(
Long
playerId
,
Integer
gameMode
,
Long
sourceId
,
String
sourceName
,
String
map
,
String
path
,
Integer
praiseNum
,
CyclingDataDTO
sportData
)
{
public
void
createBicycleTrainingLog
(
Long
playerId
,
Integer
gameMode
,
Long
sourceId
,
String
sourceName
,
String
map
,
String
path
,
Integer
praiseNum
,
CyclingDataDTO
sportData
)
{
SportUserTrainingLog
log
=
sportUserTrainingLogConverter
.
toSportUserTrainingLog
(
sportData
);
log
.
setSportType
(
SportType
.
BICYCLE
);
log
.
setGameMode
(
gameMode
);
...
...
@@ -96,7 +102,8 @@ public class SportUserTrainingLogService {
log
.
setCreateDate
(
LocalDate
.
now
());
//处理是否俱乐部日志
QueryWrapper
<
ClubMember
>
clubMemberQuery
=
new
QueryWrapper
<>();
clubMemberQuery
.
lambda
().
eq
(
ClubMember:
:
getSportUserId
,
playerId
).
eq
(
ClubMember:
:
getDeleted
,
DeleteStatus
.
UNDELETED
);
clubMemberQuery
.
lambda
().
eq
(
ClubMember:
:
getSportUserId
,
playerId
).
eq
(
ClubMember:
:
getDeleted
,
DeleteStatus
.
UNDELETED
);
ClubMember
clubMember
=
clubMemberMapper
.
selectOne
(
clubMemberQuery
);
if
(
clubMember
!=
null
)
{
log
.
setClubId
(
clubMember
.
getClubId
());
...
...
@@ -110,6 +117,63 @@ public class SportUserTrainingLogService {
this
.
modifyMonthRank
(
playerId
,
log
);
//处理总排行
this
.
modifyTotalRank
(
playerId
,
log
);
//处理玩家积分
this
.
handleSportUserCurrency
(
playerId
,
log
.
getId
(),
log
.
getCalorie
(),
gameMode
,
log
.
getMatchRank
());
}
@Resource
private
SportUserGameCurrencyBaseRuleMapper
sportUserGameCurrencyBaseRuleMapper
;
@Resource
private
SportUserGameCurrencyMapper
sportUserGameCurrencyMapper
;
@Resource
private
SportUserGameCurrencyLogMapper
sportUserGameCurrencyLogMapper
;
@Resource
private
SportUserGameCurrencyMatchRuleMapper
sportUserGameCurrencyMatchRuleMapper
;
/**
* 处理用户积分
*
* @param playerId
* @param gameMode
* @param rank
*/
public
void
handleSportUserCurrency
(
Long
playerId
,
Long
logId
,
Integer
calorie
,
Integer
gameMode
,
Integer
rank
)
{
if
(
calorie
==
null
||
calorie
==
0
)
{
return
;
}
List
<
SportUserGameCurrencyBaseRule
>
baseRule
=
sportUserGameCurrencyBaseRuleMapper
.
selectList
(
null
);
if
(
baseRule
.
size
()
==
0
||
baseRule
.
get
(
0
).
getCoefficient
()
==
null
)
{
return
;
}
Integer
coefficient
=
baseRule
.
get
(
0
).
getCoefficient
();
Integer
currency
=
calorie
/
coefficient
;
SportUserGameCurrencyMatchRule
matchRule
=
sportUserGameCurrencyMatchRuleMapper
.
selectOne
(
new
QueryWrapper
<
SportUserGameCurrencyMatchRule
>().
lambda
().
eq
(
SportUserGameCurrencyMatchRule:
:
getGameMode
,
gameMode
).
le
(
SportUserGameCurrencyMatchRule:
:
getRankStart
,
rank
).
ge
(
SportUserGameCurrencyMatchRule:
:
getRankEnd
,
rank
));
if
(
matchRule
!=
null
&&
matchRule
.
getRate
()
!=
null
)
{
currency
=
matchRule
.
getRate
().
multiply
(
BigDecimal
.
valueOf
(
currency
)).
intValue
();
}
SportUserGameCurrency
userGameCurrency
=
sportUserGameCurrencyMapper
.
selectOne
(
new
QueryWrapper
<
SportUserGameCurrency
>().
lambda
().
eq
(
SportUserGameCurrency:
:
getSportUserId
,
playerId
));
if
(
userGameCurrency
==
null
)
{
userGameCurrency
=
new
SportUserGameCurrency
();
userGameCurrency
.
setSportUserId
(
playerId
);
userGameCurrency
.
setAmmount
(
currency
);
userGameCurrency
.
setCtDate
(
LocalDateTime
.
now
());
sportUserGameCurrencyMapper
.
insert
(
userGameCurrency
);
}
else
{
userGameCurrency
.
setAmmount
(
userGameCurrency
.
getAmmount
()
+
currency
);
sportUserGameCurrencyMapper
.
updateById
(
userGameCurrency
);
}
SportUserGameCurrencyLog
gameCurrencyLog
=
new
SportUserGameCurrencyLog
();
gameCurrencyLog
.
setSportUserId
(
playerId
);
gameCurrencyLog
.
setAmmount
(
currency
);
gameCurrencyLog
.
setSourceId
(
logId
);
gameCurrencyLog
.
setCtDate
(
LocalDateTime
.
now
());
gameCurrencyLog
.
setType
(
GameCurrencyLogType
.
ADD
);
sportUserGameCurrencyLogMapper
.
insert
(
gameCurrencyLog
);
}
/**
...
...
@@ -200,7 +264,9 @@ public class SportUserTrainingLogService {
if
(
log
.
getTwentyMinutesWkg
().
compareTo
(
rank
.
getTwentyMinutesWkg
())
==
1
)
{
rank
.
setTwentyMinutesWkg
(
log
.
getTwentyMinutesWkg
());
}
rank
.
setScore
(
ScoreUtils
.
calculate
(
rank
.
getOneMinutesFtp
(),
rank
.
getFiveMinutesFtp
(),
rank
.
getTwentyMinutesFtp
(),
rank
.
getOneMinutesWkg
(),
rank
.
getFiveMinutesWkg
(),
rank
.
getTwentyMinutesWkg
()));
rank
.
setScore
(
ScoreUtils
.
calculate
(
rank
.
getOneMinutesFtp
(),
rank
.
getFiveMinutesFtp
(),
rank
.
getTwentyMinutesFtp
(),
rank
.
getOneMinutesWkg
(),
rank
.
getFiveMinutesWkg
(),
rank
.
getTwentyMinutesWkg
()));
sportUserMonthRankMapper
.
updateById
(
rank
);
}
...
...
@@ -239,7 +305,9 @@ public class SportUserTrainingLogService {
if
(
log
.
getTwentyMinutesWkg
().
compareTo
(
rank
.
getTwentyMinutesWkg
())
==
1
)
{
rank
.
setTwentyMinutesWkg
(
log
.
getTwentyMinutesWkg
());
}
rank
.
setScore
(
ScoreUtils
.
calculate
(
rank
.
getOneMinutesFtp
(),
rank
.
getFiveMinutesFtp
(),
rank
.
getTwentyMinutesFtp
(),
rank
.
getOneMinutesWkg
(),
rank
.
getFiveMinutesWkg
(),
rank
.
getTwentyMinutesWkg
()));
rank
.
setScore
(
ScoreUtils
.
calculate
(
rank
.
getOneMinutesFtp
(),
rank
.
getFiveMinutesFtp
(),
rank
.
getTwentyMinutesFtp
(),
rank
.
getOneMinutesWkg
(),
rank
.
getFiveMinutesWkg
(),
rank
.
getTwentyMinutesWkg
()));
sportUserRankMapper
.
updateById
(
rank
);
}
...
...
@@ -265,7 +333,8 @@ public class SportUserTrainingLogService {
public
SportUserTrainingLogSummaryVO
getTrainingLogSummary
(
Integer
sportType
,
Long
userId
,
Integer
daysCondition
)
{
LocalDate
now
=
LocalDate
.
now
();
LocalDate
beginDate
=
now
.
minusDays
(
daysCondition
-
1
);
SportUserTrainingLogSummaryVO
summaryVO
=
sportUserTrainingLogBusinessMapper
.
getTrainingLogSummary
(
sportType
,
userId
,
beginDate
,
now
);
SportUserTrainingLogSummaryVO
summaryVO
=
sportUserTrainingLogBusinessMapper
.
getTrainingLogSummary
(
sportType
,
userId
,
beginDate
,
now
);
if
(
summaryVO
==
null
)
{
summaryVO
=
new
SportUserTrainingLogSummaryVO
();
summaryVO
.
setLongestDistance
(
BigDecimal
.
ZERO
);
...
...
@@ -283,7 +352,8 @@ public class SportUserTrainingLogService {
* @return
*/
public
List
<
SportUserTrainingLogVO
>
getSportUserTrainingLog
(
ReqSportUserTrainingLog
param
)
{
return
sportUserTrainingLogBusinessMapper
.
getSportUserTrainingLog
(
param
.
getPlayerId
(),
param
.
getDate
(),
param
.
getGameMode
());
return
sportUserTrainingLogBusinessMapper
.
getSportUserTrainingLog
(
param
.
getPlayerId
(),
param
.
getDate
(),
param
.
getGameMode
());
}
/**
...
...
@@ -312,7 +382,8 @@ public class SportUserTrainingLogService {
result
.
setScore
(
BigDecimal
.
ZERO
);
}
else
{
result
=
sportUserConverter
.
toSportUserMonthRankResponseDTO
(
rank
);
result
.
setRank
(
sportUserMonthRankBusinessMapper
.
getMyRank
(
type
,
rank
.
getScore
(),
rank
.
getTotalCalorie
(),
rank
.
getUpdateTime
(),
year
,
month
));
result
.
setRank
(
sportUserMonthRankBusinessMapper
.
getMyRank
(
type
,
rank
.
getScore
(),
rank
.
getTotalCalorie
(),
rank
.
getUpdateTime
(),
year
,
month
));
}
SportUser
user
=
sportUserMapper
.
selectById
(
userId
);
...
...
@@ -355,14 +426,16 @@ public class SportUserTrainingLogService {
LocalDate
beginDate
=
LocalDate
.
of
(
year
,
month
,
1
);
LocalDate
endDate
=
beginDate
.
plusMonths
(
1
);
LocalDate
today
=
LocalDate
.
now
();
List
<
ScheduleResponseDTO
>
trainList
=
sportUserTrainingLogBusinessMapper
.
getMonthTrainingSummary
(
userId
,
beginDate
,
endDate
,
today
);
List
<
ScheduleResponseDTO
>
trainList
=
sportUserTrainingLogBusinessMapper
.
getMonthTrainingSummary
(
userId
,
beginDate
,
endDate
,
today
);
trainList
.
forEach
(
item
->
{
item
.
setActive
(
true
);
item
.
setScheduleList
(
new
ArrayList
<>());
resultMap
.
put
(
item
.
getDay
(),
item
);
});
List
<
SimpleMatchUserScheduleVO
>
userScheduleList
=
simpleMatchBusinessMapper
.
getUserRegistSchedule
(
userId
,
beginDate
,
endDate
,
today
);
List
<
SimpleMatchUserScheduleVO
>
userScheduleList
=
simpleMatchBusinessMapper
.
getUserRegistSchedule
(
userId
,
beginDate
,
endDate
,
today
);
userScheduleList
.
forEach
(
item
->
{
if
(!
resultMap
.
containsKey
(
item
.
getDay
()))
{
ScheduleResponseDTO
scheduleResponseDTO
=
new
ScheduleResponseDTO
();
...
...
@@ -378,7 +451,8 @@ public class SportUserTrainingLogService {
resultMap
.
get
(
item
.
getDay
()).
getScheduleList
().
add
(
schedule
);
});
List
<
TeamTrainingUserScheduleVO
>
teamTrainingUserScheduleList
=
teamTrainingBusinessMapper
.
getUserRegistSchedule
(
userId
,
beginDate
,
endDate
,
today
);
List
<
TeamTrainingUserScheduleVO
>
teamTrainingUserScheduleList
=
teamTrainingBusinessMapper
.
getUserRegistSchedule
(
userId
,
beginDate
,
endDate
,
today
);
teamTrainingUserScheduleList
.
forEach
(
item
->
{
if
(!
resultMap
.
containsKey
(
item
.
getDay
()))
{
ScheduleResponseDTO
scheduleResponseDTO
=
new
ScheduleResponseDTO
();
...
...
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