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
3a84402f
Commit
3a84402f
authored
Aug 07, 2024
by
zhangfeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
客户端兑换礼品
parent
9bf98be2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
9 deletions
+19
-9
RedeemRewardRespDTO.java
...dao/module/reward/api/reward/dto/RedeemRewardRespDTO.java
+4
-2
RedeemRewardApiImpl.java
...r/yudao/module/reward/api/reward/RedeemRewardApiImpl.java
+15
-7
No files found.
yudao-module-reward/yudao-module-reward-api/src/main/java/cn/iocoder/yudao/module/reward/api/reward/dto/RedeemRewardRespDTO.java
View file @
3a84402f
...
...
@@ -10,6 +10,8 @@ public class RedeemRewardRespDTO {
@ApiModelProperty
(
value
=
"兑换操作结果"
)
private
Boolean
exchangeResult
;
@ApiModelProperty
(
value
=
"兑换操作详情"
)
private
String
msg
;
@ApiModelProperty
(
value
=
"兑换操作详情中文"
)
private
String
msgZh
;
@ApiModelProperty
(
value
=
"兑换操作详情英文"
)
private
String
msgEn
;
}
yudao-module-reward/yudao-module-reward-impl/src/main/java/cn/iocoder/yudao/module/reward/api/reward/RedeemRewardApiImpl.java
View file @
3a84402f
...
...
@@ -61,28 +61,28 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
// 查询礼品
RewardDO
rewardDO
=
rewardMapper
.
selectById
(
redeemRewardReqVO
.
getRewardId
());
if
(
rewardDO
==
null
)
{
throw
exception
(
REWARD_NOT_EXISTS
);
return
getRedeemResp
(
false
,
"礼品不存在"
,
"reward do not exist!"
);
}
// 礼品未开启
if
(
rewardDO
.
getStatus
()
!=
1
)
{
throw
exception
(
REWARD_NOT_ENABLE
);
return
getRedeemResp
(
false
,
"礼品未开启"
,
"reward do not enable!"
);
}
// 礼品数量不够
if
(
rewardDO
.
getQuantityRemain
()
<
redeemRewardReqVO
.
getRewardCount
())
{
throw
exception
(
REWARD_COUNT_NOT_ENOUGH
);
return
getRedeemResp
(
false
,
"礼品数量不够"
,
"reward do not enough!"
);
}
// 兑换方式不匹配
String
pickMethod
=
rewardDO
.
getPickMethod
();
String
[]
split
=
pickMethod
.
split
(
","
);
if
(!
Arrays
.
asList
(
split
).
contains
(
String
.
valueOf
(
redeemRewardReqVO
.
getRedeemType
())))
{
throw
exception
(
REWARD_PICK_METHOD_NOT_ALLOW_CREATE
);
return
getRedeemResp
(
false
,
"兑换方式不支持"
,
"redeem type do not support!"
);
}
verifyMemberUser
(
redeemRewardReqVO
,
rewardDO
);
String
lockKey
=
"reward:redeem:lock:"
+
redeemRewardReqVO
.
getRewardId
();
RLock
lock
=
redissonClient
.
getLock
(
lockKey
);
try
{
if
(!
lock
.
tryLock
(
2
,
10
,
TimeUnit
.
SECONDS
))
{
throw
exception
(
GET_LOCK_FAILED
);
return
getRedeemResp
(
false
,
"系统繁忙,请稍后再试"
,
"The service is busy, please try again later"
);
}
// 添加兑换记录
Long
redeemId
=
addRedeemRecord
(
redeemRewardReqVO
,
rewardDO
);
...
...
@@ -91,11 +91,19 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
// 更新礼品
redeemReward
(
rewardDO
,
redeemRewardReqVO
.
getRewardCount
());
}
catch
(
InterruptedException
e
)
{
throw
exception
(
GET_LOCK_FAILED
);
return
getRedeemResp
(
false
,
"系统繁忙,请稍后再试"
,
"The service is busy, please try again later"
);
}
finally
{
lock
.
unlock
();
}
return
null
;
return
getRedeemResp
(
true
,
"兑换成功!"
,
"redeem success!"
);
}
private
RedeemRewardRespDTO
getRedeemResp
(
Boolean
exchangeResult
,
String
msgZh
,
String
msgEn
)
{
RedeemRewardRespDTO
redeemRewardRespDTO
=
new
RedeemRewardRespDTO
();
redeemRewardRespDTO
.
setExchangeResult
(
false
);
redeemRewardRespDTO
.
setMsgZh
(
msgZh
);
redeemRewardRespDTO
.
setMsgEn
(
msgEn
);
return
redeemRewardRespDTO
;
}
private
void
redeemReward
(
RewardDO
reward
,
Integer
rewardCount
)
{
...
...
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