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
cfbe3b54
Commit
cfbe3b54
authored
Aug 08, 2024
by
zhangfeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
礼品过期校验
parent
cde39899
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
6 deletions
+12
-6
RedeemRewardApiImpl.java
...r/yudao/module/reward/api/reward/RedeemRewardApiImpl.java
+6
-3
RewardService.java
...der/yudao/module/reward/service/reward/RewardService.java
+1
-0
RewardServiceImpl.java
...yudao/module/reward/service/reward/RewardServiceImpl.java
+5
-3
No files found.
yudao-module-reward/yudao-module-reward-impl/src/main/java/cn/iocoder/yudao/module/reward/api/reward/RedeemRewardApiImpl.java
View file @
cfbe3b54
...
...
@@ -19,6 +19,7 @@ import cn.iocoder.yudao.module.reward.dal.mysql.redeem.RewardRedeemMapper;
import
cn.iocoder.yudao.module.reward.dal.mysql.reward.RewardMapper
;
import
cn.iocoder.yudao.module.reward.enums.RewardRedeemStatusEnum
;
import
cn.iocoder.yudao.module.reward.enums.RewardStatusEnum
;
import
cn.iocoder.yudao.module.reward.service.reward.RewardService
;
import
cn.iocoder.yudao.module.system.api.sms.SmsCodeApi
;
import
cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeSendReqDTO
;
import
cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeUseReqDTO
;
...
...
@@ -52,6 +53,8 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
@Resource
private
RewardMapper
rewardMapper
;
@Resource
private
RewardService
rewardService
;
@Resource
private
RewardRedeemMapper
rewardRedeemMapper
;
@Resource
private
MemberUserApi
memberUserApi
;
...
...
@@ -67,7 +70,7 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
Boolean
redeemReward
(
RedeemRewardReqVO
redeemRewardReqVO
)
{
if
(
redeemRewardReqVO
.
getEntrance
()
!=
PlatformTypeEnum
.
BACKEND
.
getValue
()
&&
redeemRewardReqVO
instanceof
AppRedeemRewardReqVO
){
if
(
redeemRewardReqVO
.
getEntrance
()
!=
PlatformTypeEnum
.
BACKEND
.
getValue
()
&&
redeemRewardReqVO
instanceof
AppRedeemRewardReqVO
)
{
AppRedeemRewardReqVO
appRedeemRewardReqVO
=
(
AppRedeemRewardReqVO
)
redeemRewardReqVO
;
SmsCodeUseReqDTO
smsCodeUseReqDTO
=
new
SmsCodeUseReqDTO
();
UserRespDTO
memberUserApiUser
=
memberUserApi
.
getUser
(
redeemRewardReqVO
.
getMemberId
());
...
...
@@ -86,7 +89,7 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
throw
exception
(
REWARD_NOT_EXISTS
);
}
// 礼品未开启
if
(
rewardDO
.
getStatus
()
!=
1
)
{
if
(
rewardDO
.
getStatus
()
!=
RewardStatusEnum
.
ENABLED
.
getValue
()
||
rewardService
.
validateExpire
(
rewardDO
)
)
{
throw
exception
(
REWARD_NOT_ENABLE
);
}
// 礼品数量不够
...
...
@@ -164,7 +167,7 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
// 查询礼品
RewardDO
rewardDO
=
rewardMapper
.
selectById
(
rewardId
);
// 礼品未开启
if
(
rewardDO
.
getStatus
()
!=
RewardStatusEnum
.
ENABLED
.
getValue
())
{
if
(
rewardDO
.
getStatus
()
!=
RewardStatusEnum
.
ENABLED
.
getValue
()
||
rewardService
.
validateExpire
(
rewardDO
)
)
{
throw
exception
(
REWARD_NOT_ENABLE
);
}
int
totalCount
=
0
;
...
...
yudao-module-reward/yudao-module-reward-impl/src/main/java/cn/iocoder/yudao/module/reward/service/reward/RewardService.java
View file @
cfbe3b54
...
...
@@ -78,6 +78,7 @@ public interface RewardService extends IService<RewardDO> {
void
updateStatus
(
RewardStatusReqVO
statusVO
);
Boolean
validateExpire
(
RewardDO
rewardDO
);
/**
* 客户端获得礼品列表
* @param reqVO
...
...
yudao-module-reward/yudao-module-reward-impl/src/main/java/cn/iocoder/yudao/module/reward/service/reward/RewardServiceImpl.java
View file @
cfbe3b54
...
...
@@ -320,15 +320,17 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i
/**
* 校验礼品是否过期并修改礼品状态
*/
private
void
validateExpire
(
RewardDO
rewardDO
)
{
//TODO:异步更新礼品状态
public
Boolean
validateExpire
(
RewardDO
rewardDO
)
{
if
(
rewardDO
.
getEndTime
()
!=
null
)
{
if
(
rewardDO
.
getStatus
()
==
RewardStatusEnum
.
DISABLED
.
getValue
()
&&
rewardDO
.
getEndTime
().
toInstant
().
isBefore
(
Instant
.
now
()))
{
if
(
rewardDO
.
getStatus
()
==
RewardStatusEnum
.
ENABLED
.
getValue
()
&&
rewardDO
.
getEndTime
().
toInstant
().
isBefore
(
Instant
.
now
()))
{
rewardDO
.
setStatus
(
RewardStatusEnum
.
EXPIRED
.
getValue
());
RewardDO
expireReward
=
new
RewardDO
();
expireReward
.
setId
(
rewardDO
.
getId
());
expireReward
.
setStatus
(
RewardStatusEnum
.
EXPIRED
.
getValue
());
rewardMapper
.
updateById
(
expireReward
);
return
true
;
}
}
return
false
;
}
}
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