Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jiedao-api-boot-master
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
lanbaoming
jiedao-api-boot-master
Commits
8d3d0413
Commit
8d3d0413
authored
Aug 02, 2024
by
zhaobiyan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
积分操作新增唯一键幂等处理
parent
c259ec47
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
46 additions
and
2 deletions
+46
-2
MemberUserScoreBatchOperateReqDTO.java
...mber/api/score/dto/MemberUserScoreBatchOperateReqDTO.java
+2
-0
MemberUserScoreOperateReqDTO.java
...le/member/api/score/dto/MemberUserScoreOperateReqDTO.java
+4
-0
ErrorCodeConstants.java
...iocoder/yudao/module/member/enums/ErrorCodeConstants.java
+3
-0
MemberUserScoreApiImpl.java
...yudao/module/member/api/score/MemberUserScoreApiImpl.java
+13
-0
MemberUserScoreExpireTask.java
...ember/controller/admin/job/MemberUserScoreExpireTask.java
+1
-0
MemberUserScoreController.java
...controller/admin/userScore/MemberUserScoreController.java
+1
-0
MemberUserScoreLogDO.java
.../member/dal/dataobject/scoreLog/MemberUserScoreLogDO.java
+2
-0
MemberUserScoreDetailExpireListener.java
.../member/listener/MemberUserScoreDetailExpireListener.java
+1
-0
MemberUserScoreLogService.java
...le/member/service/scoreLog/MemberUserScoreLogService.java
+2
-0
MemberUserScoreLogServiceImpl.java
...ember/service/scoreLog/MemberUserScoreLogServiceImpl.java
+10
-0
MemberUserScoreLogCreateReq.java
...er/vo/memberUserScoreLog/MemberUserScoreLogCreateReq.java
+1
-0
RedeemRewardApiImpl.java
...r/yudao/module/reward/api/reward/RedeemRewardApiImpl.java
+1
-0
RewardRedeemServiceImpl.java
...module/reward/service/redeem/RewardRedeemServiceImpl.java
+1
-0
messages_en.properties
yudao-server/src/main/resources/i18n/messages_en.properties
+2
-1
messages_zh.properties
yudao-server/src/main/resources/i18n/messages_zh.properties
+2
-1
No files found.
yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/score/dto/MemberUserScoreBatchOperateReqDTO.java
View file @
8d3d0413
...
...
@@ -41,4 +41,6 @@ public class MemberUserScoreBatchOperateReqDTO {
* 扩展参数
*/
private
Map
<
String
,
Object
>
extParam
;
private
String
uniqueId
;
}
yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/score/dto/MemberUserScoreOperateReqDTO.java
View file @
8d3d0413
...
...
@@ -12,6 +12,10 @@ import java.util.Map;
@Builder
@ToString
public
class
MemberUserScoreOperateReqDTO
{
/**
* 唯一键 增加积分时必须,做幂等判断使用
*/
private
String
uniqueId
;
/**
* 会员id
*/
...
...
yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/ErrorCodeConstants.java
View file @
8d3d0413
...
...
@@ -48,4 +48,7 @@ public interface ErrorCodeConstants {
ErrorCode
REVERSE_SOURCE_NO_RELEATION_ID
=
new
ErrorCode
(
1004008004
,
"reverse.source.no.releation.id"
);
ErrorCode
LEVEL_BOUND_RANGE_ERROR
=
new
ErrorCode
(
1004008005
,
"level.bound.range.error"
);
ErrorCode
LEVEL_BOUND_RANGE_CONFLICT
=
new
ErrorCode
(
1004008006
,
"level.bound.range.conflict"
);
ErrorCode
SOURCE_TYPE_IS_NULL
=
new
ErrorCode
(
1004008007
,
"source.type.is.null"
);
ErrorCode
SCORE_OPERATE_MUST_HAVE_UNIQUE_ID
=
new
ErrorCode
(
1004008008
,
"score.operate.must.have.unique.id"
);
ErrorCode
SCORE_OPERATE_IDEMPOTENT_ERROR
=
new
ErrorCode
(
1004008008
,
"score.operate.idempotent.error"
);
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/api/score/MemberUserScoreApiImpl.java
View file @
8d3d0413
...
...
@@ -5,6 +5,7 @@ import cn.iocoder.yudao.module.member.api.score.dto.*;
import
cn.iocoder.yudao.module.member.dal.dataobject.score.MemberUserScoreDO
;
import
cn.iocoder.yudao.module.member.dal.dataobject.scoreDetail.MemberUserScoreDetailDO
;
import
cn.iocoder.yudao.module.member.dal.dataobject.scoreDetailReleation.MemberUserScoreDetailReleationDO
;
import
cn.iocoder.yudao.module.member.dal.dataobject.scoreLog.MemberUserScoreLogDO
;
import
cn.iocoder.yudao.module.member.dto.ScoreDetailChangeDto
;
import
cn.iocoder.yudao.module.member.enums.MemberScoreDetailReleationStatueEnum
;
import
cn.iocoder.yudao.module.member.enums.ScoreOperateTypeEnum
;
...
...
@@ -64,6 +65,16 @@ public class MemberUserScoreApiImpl implements MemberUserScoreApi{
if
(
req
.
getScoreCount
()
<=
0
)
{
throw
exception
(
SCORE_COUNT_ERROR
);
}
if
(
req
.
getSourceType
()
==
null
)
{
throw
exception
(
SOURCE_TYPE_IS_NULL
);
}
if
(
StringUtils
.
isBlank
(
req
.
getUniqueId
()))
{
throw
exception
(
SCORE_OPERATE_MUST_HAVE_UNIQUE_ID
);
}
MemberUserScoreLogDO
memberUserScoreLogDO
=
logService
.
getByUniqueId
(
req
.
getUniqueId
());
if
(
memberUserScoreLogDO
!=
null
)
{
throw
exception
(
SCORE_OPERATE_IDEMPOTENT_ERROR
);
}
String
lockKey
=
"member:operate:score:"
+
req
.
getMemberId
();
RLock
lock
=
redissonClient
.
getLock
(
lockKey
);
try
{
...
...
@@ -127,6 +138,7 @@ public class MemberUserScoreApiImpl implements MemberUserScoreApi{
.
operateType
(
req
.
getOperateType
())
.
sourceType
(
req
.
getSourceType
())
.
extParam
(
req
.
getExtParam
())
.
uniqueId
(
req
.
getUniqueId
()
+
"_"
+
memberId
)
.
build
()))
.
collect
(
Collectors
.
toList
());
}
...
...
@@ -187,6 +199,7 @@ public class MemberUserScoreApiImpl implements MemberUserScoreApi{
req
.
getOperateType
().
getValue
()
:
req
.
getSourceType
().
getOperateType
().
getValue
())
.
sourceType
(
req
.
getSourceType
().
getValue
())
.
extParam
(
req
.
getExtParam
())
.
uniqueId
(
req
.
getUniqueId
())
.
build
());
}
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/controller/admin/job/MemberUserScoreExpireTask.java
View file @
8d3d0413
...
...
@@ -64,6 +64,7 @@ public class MemberUserScoreExpireTask implements JobHandler {
.
memberId
(
memberUserScoreDetailDO
.
getMemberId
())
.
scoreCount
(
memberUserScoreDetailDO
.
getRemainCount
())
.
sourceType
(
ScoreSourceTypeEnum
.
SYSTEM_EXPIRED
)
.
uniqueId
(
ScoreSourceTypeEnum
.
SYSTEM_EXPIRED
+
"_"
+
memberUserScoreDetailDO
.
getId
()
+
"_"
+
System
.
currentTimeMillis
())
.
extParam
(
extParam
)
.
build
());
}
catch
(
Exception
e
)
{
...
...
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/controller/admin/userScore/MemberUserScoreController.java
View file @
8d3d0413
...
...
@@ -60,6 +60,7 @@ public class MemberUserScoreController {
.
operateType
(
ScoreOperateTypeEnum
.
parseByValue
(
query
.
getOperateType
()))
.
sourceType
(
ScoreSourceTypeEnum
.
MANUAL_OPERATE
)
.
extParam
(
extParam
)
.
uniqueId
(
ScoreSourceTypeEnum
.
MANUAL_OPERATE
+
"_"
+
System
.
currentTimeMillis
())
.
build
());
return
success
(
null
);
}
...
...
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/scoreLog/MemberUserScoreLogDO.java
View file @
8d3d0413
...
...
@@ -32,4 +32,6 @@ public class MemberUserScoreLogDO extends BaseDO {
private
Long
ruleId
;
private
String
extParam
=
"{}"
;
private
String
uniqueId
;
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/listener/MemberUserScoreDetailExpireListener.java
View file @
8d3d0413
...
...
@@ -55,6 +55,7 @@ public class MemberUserScoreDetailExpireListener {
.
memberId
(
detail
.
getMemberId
())
.
scoreCount
(
detail
.
getRemainCount
())
.
sourceType
(
ScoreSourceTypeEnum
.
SYSTEM_EXPIRED
)
.
uniqueId
(
ScoreSourceTypeEnum
.
SYSTEM_EXPIRED
+
"_"
+
detail
.
getId
()
+
"_"
+
System
.
currentTimeMillis
())
.
extParam
(
extParam
)
.
build
());
}
catch
(
Exception
e
)
{
...
...
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/service/scoreLog/MemberUserScoreLogService.java
View file @
8d3d0413
...
...
@@ -17,4 +17,6 @@ public interface MemberUserScoreLogService extends IService<MemberUserScoreLogDO
PageResult
<
MemberUserScoreLogBackVO
>
getPage
(
MemberUserScoreLogQueryVO
query
);
Long
createScoreLog
(
MemberUserScoreLogCreateReq
createReq
);
MemberUserScoreLogDO
getByUniqueId
(
String
uniqueId
);
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/service/scoreLog/MemberUserScoreLogServiceImpl.java
View file @
8d3d0413
...
...
@@ -10,6 +10,8 @@ import cn.iocoder.yudao.module.member.vo.memberUserScoreLog.MemberUserScoreLogBa
import
cn.iocoder.yudao.module.member.vo.memberUserScoreLog.MemberUserScoreLogCreateReq
;
import
cn.iocoder.yudao.module.member.vo.memberUserScoreLog.MemberUserScoreLogQueryVO
;
import
cn.iocoder.yudao.module.system.service.dict.DictTypeService
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
org.springframework.stereotype.Service
;
import
org.springframework.validation.annotation.Validated
;
...
...
@@ -59,10 +61,18 @@ public class MemberUserScoreLogServiceImpl extends AbstractService<MemberUserSco
userScoreLogDO
.
setOperateType
(
createReq
.
getOperateType
());
userScoreLogDO
.
setSourceType
(
createReq
.
getSourceType
());
userScoreLogDO
.
setRuleId
(
createReq
.
getRuleId
());
userScoreLogDO
.
setUniqueId
(
createReq
.
getUniqueId
());
if
(
createReq
.
getExtParam
()
!=
null
)
{
userScoreLogDO
.
setExtParam
(
JSONUtil
.
toJsonStr
(
createReq
.
getExtParam
()));
}
this
.
saveOrUpdate
(
userScoreLogDO
);
return
userScoreLogDO
.
getId
();
}
@Override
public
MemberUserScoreLogDO
getByUniqueId
(
String
uniqueId
)
{
LambdaQueryWrapper
<
MemberUserScoreLogDO
>
wrapper
=
Wrappers
.
lambdaQuery
();
wrapper
.
eq
(
MemberUserScoreLogDO:
:
getUniqueId
,
uniqueId
);
return
this
.
selectOne
(
wrapper
);
}
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/vo/memberUserScoreLog/MemberUserScoreLogCreateReq.java
View file @
8d3d0413
...
...
@@ -17,4 +17,5 @@ public class MemberUserScoreLogCreateReq {
private
Integer
sourceType
;
private
Long
ruleId
;
private
Map
<
String
,
Object
>
extParam
;
private
String
uniqueId
;
}
yudao-module-reward/yudao-module-reward-impl/src/main/java/cn/iocoder/yudao/module/reward/api/reward/RedeemRewardApiImpl.java
View file @
8d3d0413
...
...
@@ -112,6 +112,7 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
.
sourceType
(
ScoreSourceTypeEnum
.
EXCHANGE_REWARD
)
.
scoreCount
(
redeemRewardReqVO
.
getRewardCount
()
*
rewardDO
.
getPointsRequire
())
.
releationId
(
String
.
valueOf
(
redeemId
))
.
uniqueId
(
ScoreSourceTypeEnum
.
EXCHANGE_REWARD
+
"_"
+
redeemId
)
.
extParam
(
extParam
)
.
build
());
}
...
...
yudao-module-reward/yudao-module-reward-impl/src/main/java/cn/iocoder/yudao/module/reward/service/redeem/RewardRedeemServiceImpl.java
View file @
8d3d0413
...
...
@@ -274,6 +274,7 @@ public class RewardRedeemServiceImpl extends AbstractService<RewardRedeemMapper,
.
scoreCount
(
rewardRedeemDO
.
getScoreCount
())
.
extParam
(
extParam
)
.
releationId
(
String
.
valueOf
(
req
.
getId
()))
.
uniqueId
(
ScoreSourceTypeEnum
.
EXCHANGE_REWARD_CANCEL
+
"_"
+
req
.
getId
())
.
build
());
return
true
;
}
...
...
yudao-server/src/main/resources/i18n/messages_en.properties
View file @
8d3d0413
...
...
@@ -1023,4 +1023,5 @@ currency.not.exist = currency not exist
date.format.error
=
date format error, for example : 2024-01-01 12:11:11
redeem.cancel.status.error
=
record status must be redeeming
level.bound.range.error
=
upper count must greater than lower count
level.bound.range.conflict
=
score range exist conflict
\ No newline at end of file
level.bound.range.conflict
=
score range exist conflict
score.operate.idempotent.error
=
idempotent key conflict
\ No newline at end of file
yudao-server/src/main/resources/i18n/messages_zh.properties
View file @
8d3d0413
...
...
@@ -1027,4 +1027,5 @@ currency.not.exist = \u5E01\u79CD\u4E0D\u5B58\u5728
date.format.error
=
\u
65E5
\u
671F
\u
683C
\u
5F0F
\u
4E0D
\u
6B63
\u
786E,
\u
6B63
\u
786E
\u
683C
\u
5F0F
\u
53C2
\u8003
: 2024-01-01 12:11:11
redeem.cancel.status.error
=
\u5151\u6362\u
4E2D
\u
72B6
\u6001\u7684\u
8BB0
\u
5F55
\u
624D
\u
80FD
\u
64A4
\u9500
level.bound.range.error
=
\u
4E0A
\u
754C
\u6570\u
503C
\u
5FC5
\u
987B
\u5927\u
4E8E
\u
4E0B
\u
754C
\u6570\u
503C
level.bound.range.conflict
=
\u
79EF
\u5206\u8303\u
56F4
\u
5B58
\u5728\u
51B2
\u
7A81
\ No newline at end of file
level.bound.range.conflict
=
\u
79EF
\u5206\u8303\u
56F4
\u
5B58
\u5728\u
51B2
\u
7A81
score.operate.idempotent.error
=
\u
5E42
\u
7B49key
\u
51B2
\u
7A81
\ 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