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
e3dea02c
Commit
e3dea02c
authored
Oct 12, 2024
by
zhangfeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(redeem): 记录用户兑换前积分
parent
e275c3aa
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
10 deletions
+23
-10
RedeemRewardApi.java
...coder/yudao/module/reward/api/reward/RedeemRewardApi.java
+5
-2
RedeemRewardApiImpl.java
...r/yudao/module/reward/api/reward/RedeemRewardApiImpl.java
+10
-7
RewardRedeemDO.java
...o/module/reward/dal/dataobject/redeem/RewardRedeemDO.java
+7
-0
RewardRedeemMapper.xml
...ard-impl/src/main/resources/mapper/RewardRedeemMapper.xml
+1
-1
No files found.
yudao-module-reward/yudao-module-reward-api/src/main/java/cn/iocoder/yudao/module/reward/api/reward/RedeemRewardApi.java
View file @
e3dea02c
...
...
@@ -4,6 +4,7 @@ import cn.iocoder.yudao.module.reward.api.reward.dto.RedeemDetailForUserDTO;
import
cn.iocoder.yudao.module.reward.api.reward.dto.RedeemRewardReqVO
;
import
cn.iocoder.yudao.module.reward.api.reward.dto.RedeemRewardRespDTO
;
import
java.util.HashMap
;
import
java.util.List
;
/**
...
...
@@ -25,8 +26,9 @@ public interface RedeemRewardApi {
* @param redeemRewardReqVO
* @param pointsRequire
* @param rewardId
* @param holdScore
*/
void
executeRedeem
(
RedeemRewardReqVO
redeemRewardReqVO
,
Integer
pointsRequire
,
Long
rewardId
);
void
executeRedeem
(
RedeemRewardReqVO
redeemRewardReqVO
,
Integer
pointsRequire
,
Long
rewardId
,
Integer
holdScore
);
/**
* 批量兑换礼品
...
...
@@ -42,8 +44,9 @@ public interface RedeemRewardApi {
* @param redeemRewardReqVOList
* @param pointsRequire
* @param rewardId
* @param holdScoreMap
*/
void
batchExecuteRedeem
(
List
<
RedeemRewardReqVO
>
redeemRewardReqVOList
,
Integer
pointsRequire
,
Long
rewardId
);
void
batchExecuteRedeem
(
List
<
RedeemRewardReqVO
>
redeemRewardReqVOList
,
Integer
pointsRequire
,
Long
rewardId
,
HashMap
<
Long
,
Integer
>
holdScoreMap
);
/**
* 客户端获取礼品详情
...
...
yudao-module-reward/yudao-module-reward-impl/src/main/java/cn/iocoder/yudao/module/reward/api/reward/RedeemRewardApiImpl.java
View file @
e3dea02c
...
...
@@ -102,7 +102,7 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
throw
exception
(
GET_LOCK_FAILED
);
}
RedeemRewardApi
currentProxy
=
(
RedeemRewardApi
)
AopContext
.
currentProxy
();
currentProxy
.
executeRedeem
(
redeemRewardReqVO
,
rewardDO
.
getPointsRequire
(),
rewardDO
.
getId
());
currentProxy
.
executeRedeem
(
redeemRewardReqVO
,
rewardDO
.
getPointsRequire
(),
rewardDO
.
getId
()
,
memberUser
.
getHoldScore
()
);
}
catch
(
InterruptedException
e
)
{
throw
exception
(
GET_LOCK_FAILED
);
}
finally
{
...
...
@@ -113,9 +113,9 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
executeRedeem
(
RedeemRewardReqVO
redeemRewardReqVO
,
Integer
pointsRequire
,
Long
rewardId
)
{
public
void
executeRedeem
(
RedeemRewardReqVO
redeemRewardReqVO
,
Integer
pointsRequire
,
Long
rewardId
,
Integer
holdScore
)
{
// 添加兑换记录
RewardRedeemDO
redeemRecord
=
addRedeemRecord
(
redeemRewardReqVO
,
pointsRequire
);
RewardRedeemDO
redeemRecord
=
addRedeemRecord
(
redeemRewardReqVO
,
pointsRequire
,
holdScore
);
// 更新会员积分
updateMemberScore
(
redeemRewardReqVO
,
pointsRequire
,
redeemRecord
.
getId
(),
redeemRecord
.
getRedemptionNumber
());
// 更新礼品
...
...
@@ -187,11 +187,12 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
.
build
());
}
private
RewardRedeemDO
addRedeemRecord
(
RedeemRewardReqVO
redeemRewardReqVO
,
Integer
pointsRequire
)
{
private
RewardRedeemDO
addRedeemRecord
(
RedeemRewardReqVO
redeemRewardReqVO
,
Integer
pointsRequire
,
Integer
holdScore
)
{
RewardRedeemDO
rewardRedeemDO
=
BeanUtil
.
copyProperties
(
redeemRewardReqVO
,
RewardRedeemDO
.
class
);
rewardRedeemDO
.
setId
(
snowflakeGenerator
.
next
());
rewardRedeemDO
.
setRedemptionNumber
(
rewardGenCodeUtils
.
generateRedemptionNumber
());
rewardRedeemDO
.
setStatus
(
RewardRedeemStatusEnum
.
REDEEMING
.
getValue
());
rewardRedeemDO
.
setHoldScoreBeforeRedeem
(
holdScore
);
rewardRedeemDO
.
setScoreCount
(
redeemRewardReqVO
.
getRewardCount
()
*
pointsRequire
);
rewardRedeemMapper
.
insert
(
rewardRedeemDO
);
return
rewardRedeemDO
;
...
...
@@ -214,6 +215,7 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
throw
exception
(
REWARD_NOT_ENABLE
);
}
int
totalCount
=
0
;
HashMap
<
Long
,
Integer
>
holdScoreMap
=
new
HashMap
<>();
for
(
RedeemRewardReqVO
redeemRewardReqVO
:
redeemRewardReqVOList
)
{
UserRespDTO
memberUser
=
memberUserApi
.
getUser
(
redeemRewardReqVO
.
getMemberId
());
if
(
memberUser
==
null
)
{
...
...
@@ -230,6 +232,7 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
}
}
verifyMemberUser
(
redeemRewardReqVO
,
rewardDO
,
memberUser
.
getHoldScore
());
holdScoreMap
.
put
(
redeemRewardReqVO
.
getMemberId
(),
memberUser
.
getHoldScore
());
// 记录兑换总数
totalCount
+=
redeemRewardReqVO
.
getRewardCount
();
// 判断兑换总数是否大于礼物数量
...
...
@@ -244,7 +247,7 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
throw
exception
(
GET_LOCK_FAILED
);
}
RedeemRewardApi
currentProxy
=
(
RedeemRewardApi
)
AopContext
.
currentProxy
();
currentProxy
.
batchExecuteRedeem
(
redeemRewardReqVOList
,
rewardDO
.
getPointsRequire
(),
rewardDO
.
getId
());
currentProxy
.
batchExecuteRedeem
(
redeemRewardReqVOList
,
rewardDO
.
getPointsRequire
(),
rewardDO
.
getId
()
,
holdScoreMap
);
}
catch
(
ServiceException
e
)
{
log
.
error
(
"batch redeem rewards exception:{}"
,
e
.
getMessage
());
throw
e
;
...
...
@@ -258,9 +261,9 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
batchExecuteRedeem
(
List
<
RedeemRewardReqVO
>
redeemRewardReqVOList
,
Integer
pointsRequire
,
Long
rewardId
)
{
public
void
batchExecuteRedeem
(
List
<
RedeemRewardReqVO
>
redeemRewardReqVOList
,
Integer
pointsRequire
,
Long
rewardId
,
HashMap
<
Long
,
Integer
>
holdScoreMap
)
{
for
(
RedeemRewardReqVO
redeemRewardReqVO
:
redeemRewardReqVOList
)
{
executeRedeem
(
redeemRewardReqVO
,
pointsRequire
,
rewardId
);
executeRedeem
(
redeemRewardReqVO
,
pointsRequire
,
rewardId
,
holdScoreMap
.
get
(
redeemRewardReqVO
.
getMemberId
())
);
}
}
...
...
yudao-module-reward/yudao-module-reward-impl/src/main/java/cn/iocoder/yudao/module/reward/dal/dataobject/redeem/RewardRedeemDO.java
View file @
e3dea02c
...
...
@@ -37,6 +37,13 @@ public class RewardRedeemDO extends BaseDO {
* 兑换状态
*/
private
Integer
status
;
/**
* 兑换前持有的积分
*/
private
Integer
holdScoreBeforeRedeem
;
/**
* 兑换消耗积分数量
*/
private
Integer
scoreCount
;
/**
* 兑换数量
...
...
yudao-module-reward/yudao-module-reward-impl/src/main/resources/mapper/RewardRedeemMapper.xml
View file @
e3dea02c
...
...
@@ -39,7 +39,7 @@
</select>
<select
id=
"detail"
resultType=
"cn.iocoder.yudao.module.reward.vo.reward.RewardRedeemPageRespVO"
>
select
mus.hold_score
as holdScore,
err.hold_score_before_redeem
as holdScore,
er.points_require as pointsRequire,
er.start_time as startTime,
er.end_time as endTime,
...
...
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