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
22487c2e
Commit
22487c2e
authored
Aug 10, 2022
by
liming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加签到成就处理
parent
8f610d4f
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
143 additions
and
32 deletions
+143
-32
AchievementCondition.java
...tai/sport/http/server/constants/AchievementCondition.java
+5
-0
GameCurrencySourceType.java
...i/sport/http/server/constants/GameCurrencySourceType.java
+8
-0
Achievement.java
...ttp/server/repository/achievement/entity/Achievement.java
+1
-1
AchievementForSportUser.java
...epository/achievement/entity/AchievementForSportUser.java
+1
-1
SportUserGameCurrencyLog.java
...rver/repository/shop/entity/SportUserGameCurrencyLog.java
+5
-0
AchievementBizMapper.java
...api/business/achievement/mapper/AchievementBizMapper.java
+11
-0
AchievementService.java
.../api/business/achievement/service/AchievementService.java
+41
-0
SportUserGameCurrencyService.java
...sergamecurrency/service/SportUserGameCurrencyService.java
+46
-0
SportUserTrainingLogService.java
...ness/traininglog/service/SportUserTrainingLogService.java
+5
-30
SportUserService.java
...er/server/api/business/user/service/SportUserService.java
+4
-0
AchievementBizMapper.xml
...ain/resources/mapper/achievement/AchievementBizMapper.xml
+16
-0
No files found.
constants/src/main/java/com/antai/sport/http/server/constants/AchievementCondition.java
0 → 100644
View file @
22487c2e
package
com
.
antai
.
sport
.
http
.
server
.
constants
;
public
class
AchievementCondition
{
public
static
final
Integer
SIGN_IN_DAYS
=
10
;
}
constants/src/main/java/com/antai/sport/http/server/constants/GameCurrencySourceType.java
0 → 100644
View file @
22487c2e
package
com
.
antai
.
sport
.
http
.
server
.
constants
;
public
class
GameCurrencySourceType
{
//运动训练
public
static
final
Integer
SPORT
=
10
;
//成就
public
static
final
Integer
ACHIEVEMENT
=
20
;
}
repository/src/main/java/com/antai/sport/http/server/repository/achievement/entity/Achievement.java
View file @
22487c2e
...
...
@@ -40,7 +40,7 @@ public class Achievement implements Serializable {
/**
* 条件 10 登录天数 20 团练完成场数 30 日常赛完成场数 40 娱乐赛场数 50 里程 60 爬升高度 70 卡路里消耗
*/
private
Integer
c
ondition
;
private
Integer
achievementC
ondition
;
/**
* 成就名称
...
...
repository/src/main/java/com/antai/sport/http/server/repository/achievement/entity/AchievementForSportUser.java
View file @
22487c2e
...
...
@@ -40,7 +40,7 @@ public class AchievementForSportUser implements Serializable {
/**
* 已读状态
*/
private
Boolean
r
ead
;
private
Boolean
markR
ead
;
/**
* 创建时间
...
...
repository/src/main/java/com/antai/sport/http/server/repository/shop/entity/SportUserGameCurrencyLog.java
View file @
22487c2e
...
...
@@ -42,6 +42,11 @@ public class SportUserGameCurrencyLog implements Serializable {
*/
private
Integer
type
;
/**
* 源头类型 10:训练 20:成就
*/
private
Integer
sourceType
;
/**
* 源头id 漫游记录id 或消费订单id
*/
...
...
server-api/src/main/java/com/antai/sport/http/server/server/api/business/achievement/mapper/AchievementBizMapper.java
0 → 100644
View file @
22487c2e
package
com
.
antai
.
sport
.
http
.
server
.
server
.
api
.
business
.
achievement
.
mapper
;
import
com.antai.sport.http.server.repository.achievement.entity.Achievement
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
public
interface
AchievementBizMapper
{
List
<
Achievement
>
getSignInAchievement
(
@Param
(
"achievementCondition"
)
Integer
achievementCondition
,
@Param
(
"sportUserId"
)
Long
sportUserId
);
}
server-api/src/main/java/com/antai/sport/http/server/server/api/business/achievement/service/AchievementService.java
View file @
22487c2e
package
com
.
antai
.
sport
.
http
.
server
.
server
.
api
.
business
.
achievement
.
service
;
import
com.antai.sport.http.server.constants.AchievementCondition
;
import
com.antai.sport.http.server.constants.GameCurrencySourceType
;
import
com.antai.sport.http.server.repository.achievement.entity.Achievement
;
import
com.antai.sport.http.server.repository.achievement.entity.AchievementForSportUser
;
import
com.antai.sport.http.server.repository.achievement.mapper.AchievementForSportUserMapper
;
import
com.antai.sport.http.server.server.api.business.achievement.mapper.AchievementBizMapper
;
import
com.antai.sport.http.server.server.api.business.sportusergamecurrency.service.SportUserGameCurrencyService
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.time.LocalDateTime
;
import
java.util.List
;
@Service
public
class
AchievementService
{
@Resource
private
AchievementForSportUserMapper
achievementForSportUserMapper
;
@Resource
private
AchievementBizMapper
achievementBizMapper
;
@Resource
private
SportUserGameCurrencyService
sportUserGameCurrencyService
;
/**
* 处理签到类成就
*
* @param sportUserId
*/
public
void
handleSignInAchievement
(
Long
sportUserId
,
Integer
continuousLoginDays
)
{
List
<
Achievement
>
achievementList
=
achievementBizMapper
.
getSignInAchievement
(
AchievementCondition
.
SIGN_IN_DAYS
,
sportUserId
);
for
(
Achievement
achievement
:
achievementList
)
{
if
(
continuousLoginDays
.
compareTo
(
achievement
.
getConditionValue
())
>=
0
)
{
AchievementForSportUser
achievementForSportUser
=
new
AchievementForSportUser
();
achievementForSportUser
.
setSportUserId
(
sportUserId
);
achievementForSportUser
.
setAchievementId
(
achievement
.
getId
());
achievementForSportUser
.
setMarkRead
(
false
);
achievementForSportUser
.
setCreateTime
(
LocalDateTime
.
now
());
achievementForSportUserMapper
.
insert
(
achievementForSportUser
);
sportUserGameCurrencyService
.
addCurrency
(
sportUserId
,
achievement
.
getCurrency
(),
GameCurrencySourceType
.
ACHIEVEMENT
,
achievement
.
getId
());
}
}
}
}
server-api/src/main/java/com/antai/sport/http/server/server/api/business/sportusergamecurrency/service/SportUserGameCurrencyService.java
0 → 100644
View file @
22487c2e
package
com
.
antai
.
sport
.
http
.
server
.
server
.
api
.
business
.
sportusergamecurrency
.
service
;
import
com.antai.sport.http.server.constants.GameCurrencyLogType
;
import
com.antai.sport.http.server.repository.shop.entity.SportUserGameCurrency
;
import
com.antai.sport.http.server.repository.shop.entity.SportUserGameCurrencyLog
;
import
com.antai.sport.http.server.repository.shop.mapper.SportUserGameCurrencyLogMapper
;
import
com.antai.sport.http.server.repository.shop.mapper.SportUserGameCurrencyMapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.time.LocalDateTime
;
@Service
public
class
SportUserGameCurrencyService
{
@Resource
private
SportUserGameCurrencyMapper
sportUserGameCurrencyMapper
;
@Resource
private
SportUserGameCurrencyLogMapper
sportUserGameCurrencyLogMapper
;
public
void
addCurrency
(
Long
sportUserId
,
Integer
currency
,
Integer
sourceType
,
Long
sourceId
)
{
SportUserGameCurrency
userGameCurrency
=
sportUserGameCurrencyMapper
.
selectOne
(
new
QueryWrapper
<
SportUserGameCurrency
>().
lambda
()
.
eq
(
SportUserGameCurrency:
:
getSportUserId
,
sportUserId
));
if
(
userGameCurrency
==
null
)
{
userGameCurrency
=
new
SportUserGameCurrency
();
userGameCurrency
.
setSportUserId
(
sportUserId
);
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
(
sportUserId
);
gameCurrencyLog
.
setAmmount
(
currency
);
gameCurrencyLog
.
setSourceType
(
sourceType
);
gameCurrencyLog
.
setSourceId
(
sourceId
);
gameCurrencyLog
.
setCtDate
(
LocalDateTime
.
now
());
gameCurrencyLog
.
setType
(
GameCurrencyLogType
.
ADD
);
sportUserGameCurrencyLogMapper
.
insert
(
gameCurrencyLog
);
}
}
server-api/src/main/java/com/antai/sport/http/server/server/api/business/traininglog/service/SportUserTrainingLogService.java
View file @
22487c2e
...
...
@@ -7,13 +7,9 @@ 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
;
...
...
@@ -23,6 +19,7 @@ import com.antai.sport.http.server.repository.teamtraining.entity.TeamTraining;
import
com.antai.sport.http.server.repository.teamtraining.mapper.TeamTrainingMapper
;
import
com.antai.sport.http.server.server.api.business.simplematch.dto.SimpleMatchUserScheduleVO
;
import
com.antai.sport.http.server.server.api.business.simplematch.mapper.SimpleMatchBusinessMapper
;
import
com.antai.sport.http.server.server.api.business.sportusergamecurrency.service.SportUserGameCurrencyService
;
import
com.antai.sport.http.server.server.api.business.teamtraining.dto.TeamTrainingUserScheduleVO
;
import
com.antai.sport.http.server.server.api.business.teamtraining.mapper.TeamTrainingBusinessMapper
;
import
com.antai.sport.http.server.server.api.business.traininglog.converter.SportUserTrainingLogConverter
;
...
...
@@ -84,10 +81,6 @@ public class SportUserTrainingLogService {
@Resource
private
SportUserGameCurrencyBaseRuleMapper
sportUserGameCurrencyBaseRuleMapper
;
@Resource
private
SportUserGameCurrencyMapper
sportUserGameCurrencyMapper
;
@Resource
private
SportUserGameCurrencyLogMapper
sportUserGameCurrencyLogMapper
;
@Resource
private
SportUserGameCurrencyMatchRuleMapper
sportUserGameCurrencyMatchRuleMapper
;
@Resource
...
...
@@ -95,6 +88,9 @@ public class SportUserTrainingLogService {
@Resource
private
SportUserConverter
sportUserConverter
;
@Resource
private
SportUserGameCurrencyService
sportUserGameCurrencyService
;
public
void
createBicycleTrainingLog
(
Long
playerId
,
Integer
gameMode
,
Long
sourceId
,
String
sourceName
,
String
map
,
String
path
,
Integer
praiseNum
,
CyclingDataDTO
sportData
)
{
SportUserTrainingLog
log
=
sportUserTrainingLogConverter
.
toSportUserTrainingLog
(
sportData
);
...
...
@@ -151,28 +147,7 @@ public class SportUserTrainingLogService {
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
);
sportUserGameCurrencyService
.
addCurrency
(
playerId
,
currency
,
GameCurrencySourceType
.
SPORT
,
logId
);
}
/**
...
...
server-api/src/main/java/com/antai/sport/http/server/server/api/business/user/service/SportUserService.java
View file @
22487c2e
...
...
@@ -5,6 +5,7 @@ import com.antai.sport.http.server.repository.sport.entity.*;
import
com.antai.sport.http.server.repository.sport.mapper.SportUserContinuousLoginDaysMapper
;
import
com.antai.sport.http.server.repository.sport.mapper.SportUserLoginLogMapper
;
import
com.antai.sport.http.server.repository.sport.mapper.SportUserMapper
;
import
com.antai.sport.http.server.server.api.business.achievement.service.AchievementService
;
import
com.antai.sport.http.server.server.api.business.traininglog.dto.SportUserTrainingLogSummaryVO
;
import
com.antai.sport.http.server.server.api.business.traininglog.service.SportUserTrainingLogService
;
import
com.antai.sport.http.server.server.api.business.user.dto.RespUserHomeInfo
;
...
...
@@ -33,6 +34,8 @@ public class SportUserService {
@Resource
private
SportUserTrainingLogService
sportUserTrainingLogService
;
@Resource
private
AchievementService
achievementService
;
public
RespUserHomeInfo
getUserHomeInfo
(
Long
userId
)
{
RespUserHomeInfo
resp
=
new
RespUserHomeInfo
();
...
...
@@ -113,6 +116,7 @@ public class SportUserService {
continuousLoginDays
.
setDays
(
continuousLoginDays
.
getDays
()
+
1
);
continuousLoginDays
.
setLastLoginDate
(
LocalDate
.
now
());
sportUserContinuousLoginDaysMapper
.
updateById
(
continuousLoginDays
);
achievementService
.
handleSignInAchievement
(
sportUserId
,
continuousLoginDays
.
getDays
());
return
;
}
//其他情况重置连续登录天数
...
...
server-api/src/main/resources/mapper/achievement/AchievementBizMapper.xml
0 → 100644
View file @
22487c2e
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.antai.sport.http.server.server.api.business.achievement.mapper.AchievementBizMapper"
>
<select
id=
"getSignInAchievement"
resultType=
"com.antai.sport.http.server.repository.achievement.entity.Achievement"
>
select *
from achievement t1
where t1.deleted = 0
and t1.achievement_condition = #{achievementCondition}
and t1.id not in (
select w1.achievement_id
from achievement_for_sport_user w1
where w1.sport_user_id = #{sportUserId}
)
order by level
</select>
</mapper>
\ No newline at end of file
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