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
1103043b
Commit
1103043b
authored
Sep 03, 2024
by
zhangfeng
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'release-zf' into 'release'
bugfix-172,175,180,181,186 See merge request
!13
parents
9dcc4893
285a39fa
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
270 additions
and
62 deletions
+270
-62
MemberUserScoreMapper.xml
.../src/main/resources/mapper/user/MemberUserScoreMapper.xml
+2
-2
RedeemRewardApiImpl.java
...r/yudao/module/reward/api/reward/RedeemRewardApiImpl.java
+11
-6
RedemptionNumberFlushTask.java
...eward/controller/admin/job/RedemptionNumberFlushTask.java
+26
-0
RewardCodeFlushTask.java
...dule/reward/controller/admin/job/RewardCodeFlushTask.java
+26
-0
AppRewardRedeemDetailRespVO.java
...controller/app/redeem/vo/AppRewardRedeemDetailRespVO.java
+2
-0
AppRewardRedeemListRespVO.java
...d/controller/app/redeem/vo/AppRewardRedeemListRespVO.java
+2
-0
RewardRedeemDO.java
...o/module/reward/dal/dataobject/redeem/RewardRedeemDO.java
+4
-0
RewardRedeemMapper.java
...ao/module/reward/dal/mysql/redeem/RewardRedeemMapper.java
+2
-0
RewardMapper.java
...er/yudao/module/reward/dal/mysql/reward/RewardMapper.java
+29
-22
RewardRedeemServiceImpl.java
...module/reward/service/redeem/RewardRedeemServiceImpl.java
+2
-0
RewardServiceImpl.java
...yudao/module/reward/service/reward/RewardServiceImpl.java
+8
-23
RewardGenCodeUtils.java
.../iocoder/yudao/module/reward/util/RewardGenCodeUtils.java
+138
-0
RewardRedeemBaseVO.java
...der/yudao/module/reward/vo/reward/RewardRedeemBaseVO.java
+5
-0
RewardRedeemMapper.xml
...ard-impl/src/main/resources/mapper/RewardRedeemMapper.xml
+4
-0
messages_en.properties
yudao-server/src/main/resources/i18n/messages_en.properties
+1
-1
messages_zh.properties
yudao-server/src/main/resources/i18n/messages_zh.properties
+8
-8
No files found.
yudao-module-member/yudao-module-member-impl/src/main/resources/mapper/user/MemberUserScoreMapper.xml
View file @
1103043b
...
...
@@ -22,7 +22,7 @@
left join member_user_score mus on mus.member_id = mu.id
left join ecw_region re on re.id = mu.country
left join ecw_region rea on rea.id = mu.city
where 1 = 1
where 1 = 1
and mu.deleted = 0
<include
refid=
"scoreCondition"
/>
order by mu.id
limit #{start}, #{size}
...
...
@@ -33,7 +33,7 @@
from member_user mu
left join member_user_score mus on mus.member_id = mu.id
left join ecw_region re on re.id = mu.country
where 1 = 1
where 1 = 1
and mu.deleted = 0
<include
refid=
"scoreCondition"
/>
</select>
<select
id=
"getByMemberId"
...
...
yudao-module-reward/yudao-module-reward-impl/src/main/java/cn/iocoder/yudao/module/reward/api/reward/RedeemRewardApiImpl.java
View file @
1103043b
...
...
@@ -21,6 +21,7 @@ import cn.iocoder.yudao.module.reward.enums.RewardPickMethedEnum;
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.reward.util.RewardGenCodeUtils
;
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
;
...
...
@@ -69,6 +70,8 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
private
SnowflakeGenerator
snowflakeGenerator
;
@Resource
private
SmsCodeApi
smsCodeApi
;
@Resource
private
RewardGenCodeUtils
rewardGenCodeUtils
;
@Override
public
Boolean
redeemReward
(
RedeemRewardReqVO
redeemRewardReqVO
)
{
...
...
@@ -112,9 +115,9 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
executeRedeem
(
RedeemRewardReqVO
redeemRewardReqVO
,
Integer
pointsRequire
,
Long
rewardId
)
{
// 添加兑换记录
Long
redeemI
d
=
addRedeemRecord
(
redeemRewardReqVO
,
pointsRequire
);
RewardRedeemDO
redeemRecor
d
=
addRedeemRecord
(
redeemRewardReqVO
,
pointsRequire
);
// 更新会员积分
updateMemberScore
(
redeemRewardReqVO
,
pointsRequire
,
redeem
Id
);
updateMemberScore
(
redeemRewardReqVO
,
pointsRequire
,
redeem
Record
.
getId
(),
redeemRecord
.
getRedemptionNumber
()
);
// 更新礼品
redeemReward
(
rewardId
,
redeemRewardReqVO
.
getRewardCount
());
}
...
...
@@ -150,7 +153,7 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
if
(
StringUtils
.
isBlank
(
redeemRewardReqVO
.
getRecipientPhoneNum
()))
{
redeemRewardReqVO
.
setRecipientPhoneNum
(
memberUser
.
getMobile
());
}
}
else
{
}
else
if
(
redeemRewardReqVO
.
getEntrance
()
!=
PlatformTypeEnum
.
BACKEND
.
getValue
())
{
if
(
StringUtils
.
isAnyBlank
(
redeemRewardReqVO
.
getRecipientName
(),
redeemRewardReqVO
.
getRecipientPhoneNum
(),
redeemRewardReqVO
.
getRecipientAddress
()))
{
throw
exception
(
REWARD_REDEEM_RECIPIENT_ERROR
);
}
...
...
@@ -170,9 +173,10 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
rewardMapper
.
updateById
(
upReward
);
}
private
void
updateMemberScore
(
RedeemRewardReqVO
redeemRewardReqVO
,
Integer
pointsRequire
,
Long
redeemId
)
{
private
void
updateMemberScore
(
RedeemRewardReqVO
redeemRewardReqVO
,
Integer
pointsRequire
,
Long
redeemId
,
String
redemptionNumber
)
{
Map
<
String
,
Object
>
extParam
=
new
HashMap
<>();
extParam
.
put
(
"redeemId"
,
redeemId
);
extParam
.
put
(
"redemptionNumber"
,
redemptionNumber
);
memberUserScoreApi
.
operateScore
(
MemberUserScoreOperateReqDTO
.
builder
()
.
memberId
(
redeemRewardReqVO
.
getMemberId
())
.
sourceType
(
ScoreSourceTypeEnum
.
EXCHANGE_REWARD
)
...
...
@@ -183,13 +187,14 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
.
build
());
}
private
Long
addRedeemRecord
(
RedeemRewardReqVO
redeemRewardReqVO
,
Integer
pointsRequire
)
{
private
RewardRedeemDO
addRedeemRecord
(
RedeemRewardReqVO
redeemRewardReqVO
,
Integer
pointsRequire
)
{
RewardRedeemDO
rewardRedeemDO
=
BeanUtil
.
copyProperties
(
redeemRewardReqVO
,
RewardRedeemDO
.
class
);
rewardRedeemDO
.
setId
(
snowflakeGenerator
.
next
());
rewardRedeemDO
.
setRedemptionNumber
(
rewardGenCodeUtils
.
generateRedemptionNumber
());
rewardRedeemDO
.
setStatus
(
RewardRedeemStatusEnum
.
REDEEMING
.
getValue
());
rewardRedeemDO
.
setScoreCount
(
redeemRewardReqVO
.
getRewardCount
()
*
pointsRequire
);
rewardRedeemMapper
.
insert
(
rewardRedeemDO
);
return
rewardRedeemDO
.
getId
()
;
return
rewardRedeemDO
;
}
@Override
...
...
yudao-module-reward/yudao-module-reward-impl/src/main/java/cn/iocoder/yudao/module/reward/controller/admin/job/RedemptionNumberFlushTask.java
0 → 100644
View file @
1103043b
package
cn
.
iocoder
.
yudao
.
module
.
reward
.
controller
.
admin
.
job
;
import
cn.iocoder.yudao.framework.quartz.core.handler.JobHandler
;
import
cn.iocoder.yudao.module.reward.util.RewardGenCodeUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
/**
* 兑换记录编号刷新任务
* @author zhaobiyan
*/
@Component
@Slf4j
public
class
RedemptionNumberFlushTask
implements
JobHandler
{
@Resource
private
RewardGenCodeUtils
rewardGenCodeUtils
;
@Override
public
String
execute
(
String
param
)
throws
Exception
{
rewardGenCodeUtils
.
redemptionNumberFlush
();
return
"success"
;
}
}
\ No newline at end of file
yudao-module-reward/yudao-module-reward-impl/src/main/java/cn/iocoder/yudao/module/reward/controller/admin/job/RewardCodeFlushTask.java
0 → 100644
View file @
1103043b
package
cn
.
iocoder
.
yudao
.
module
.
reward
.
controller
.
admin
.
job
;
import
cn.iocoder.yudao.framework.quartz.core.handler.JobHandler
;
import
cn.iocoder.yudao.module.reward.util.RewardGenCodeUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
/**
* 礼品编号刷新任务
* @author zhaobiyan
*/
@Component
@Slf4j
public
class
RewardCodeFlushTask
implements
JobHandler
{
@Resource
private
RewardGenCodeUtils
rewardGenCodeUtils
;
@Override
public
String
execute
(
String
param
)
throws
Exception
{
rewardGenCodeUtils
.
historyRewardCodeFlush
();
return
"success"
;
}
}
\ No newline at end of file
yudao-module-reward/yudao-module-reward-impl/src/main/java/cn/iocoder/yudao/module/reward/controller/app/redeem/vo/AppRewardRedeemDetailRespVO.java
View file @
1103043b
...
...
@@ -14,6 +14,8 @@ public class AppRewardRedeemDetailRespVO {
@ApiModelProperty
(
value
=
"id"
)
@JsonSerialize
(
using
=
ToStringSerializer
.
class
)
private
Long
id
;
@ApiModelProperty
(
value
=
"兑换记录编号"
)
private
String
redemptionNumber
;
@ApiModelProperty
(
value
=
"会员id"
)
private
Long
memberId
;
@ApiModelProperty
(
value
=
"礼品id"
)
...
...
yudao-module-reward/yudao-module-reward-impl/src/main/java/cn/iocoder/yudao/module/reward/controller/app/redeem/vo/AppRewardRedeemListRespVO.java
View file @
1103043b
...
...
@@ -23,6 +23,8 @@ public class AppRewardRedeemListRespVO {
@ApiModelProperty
(
value
=
"id"
)
@JsonSerialize
(
using
=
ToStringSerializer
.
class
)
private
Long
id
;
@ApiModelProperty
(
value
=
"兑换记录编号"
)
private
String
redemptionNumber
;
@ApiModelProperty
(
value
=
"礼品ID"
)
private
Long
rewardCode
;
@ApiModelProperty
(
value
=
"礼品名称(中文)"
)
...
...
yudao-module-reward/yudao-module-reward-impl/src/main/java/cn/iocoder/yudao/module/reward/dal/dataobject/redeem/RewardRedeemDO.java
View file @
1103043b
...
...
@@ -21,6 +21,10 @@ public class RewardRedeemDO extends BaseDO {
*/
@TableId
private
Long
id
;
/**
* 兑换记录编号
*/
private
String
redemptionNumber
;
/**
* 会员id
*/
...
...
yudao-module-reward/yudao-module-reward-impl/src/main/java/cn/iocoder/yudao/module/reward/dal/mysql/redeem/RewardRedeemMapper.java
View file @
1103043b
...
...
@@ -23,4 +23,6 @@ public interface RewardRedeemMapper extends AbstractMapper<RewardRedeemDO> {
RewardRedeemPageRespVO
detail
(
@Param
(
"id"
)
Long
id
);
List
<
RewardRedeemPageRespVO
>
exportList
(
@Param
(
"req"
)
RewardRedeemPageReqVO
request
);
String
getCurrentMaxRedemptionNumber
();
}
yudao-module-reward/yudao-module-reward-impl/src/main/java/cn/iocoder/yudao/module/reward/dal/mysql/reward/RewardMapper.java
View file @
1103043b
...
...
@@ -7,11 +7,14 @@ import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import
cn.iocoder.yudao.module.reward.dal.dataobject.reward.RewardDO
;
import
cn.iocoder.yudao.module.reward.vo.reward.RewardQueryVO
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.ResultType
;
import
org.apache.ibatis.annotations.Select
;
import
java.util.List
;
/**
* 礼品 Mapper
*
* @author 系统管理员
*/
@Mapper
...
...
@@ -19,18 +22,18 @@ public interface RewardMapper extends AbstractMapper<RewardDO> {
@Override
default
PageResult
<
RewardDO
>
selectPage
(
PageVO
page
,
Object
object
)
{
if
(
object
instanceof
RewardQueryVO
)
{
RewardQueryVO
vo
=
(
RewardQueryVO
)
object
;
RewardQueryVO
vo
=
(
RewardQueryVO
)
object
;
return
selectPage
(
page
,
new
LambdaQuery
<
RewardDO
>()
.
eqIfPresent
(
RewardDO:
:
getCode
,
vo
.
getCode
())
.
eqIfPresent
(
RewardDO:
:
getTitleZh
,
vo
.
getTitle
())
.
eqIfPresent
(
RewardDO:
:
getTitleEn
,
vo
.
getTitle
())
.
eqIfPresent
(
RewardDO:
:
getTitleFr
,
vo
.
getTitle
())
.
eqIfPresent
(
RewardDO:
:
getPointsRequire
,
vo
.
getPointsRequire
())
.
eqIfPresent
(
RewardDO:
:
getNodeId
,
vo
.
getNodeId
())
.
eqIfPresent
(
RewardDO:
:
getQuantityRemain
,
vo
.
getQuantityRemain
())
.
eqIfPresent
(
RewardDO:
:
getPickMethod
,
vo
.
getPickMethod
())
.
eqIfPresent
(
RewardDO:
:
getStatus
,
vo
.
getStatus
())
.
betweenIfPresent
(
RewardDO:
:
getCreateTime
,
vo
.
getBeginCreateTime
(),
vo
.
getEndCreateTime
())
.
eqIfPresent
(
RewardDO:
:
getCode
,
vo
.
getCode
())
.
eqIfPresent
(
RewardDO:
:
getTitleZh
,
vo
.
getTitle
())
.
eqIfPresent
(
RewardDO:
:
getTitleEn
,
vo
.
getTitle
())
.
eqIfPresent
(
RewardDO:
:
getTitleFr
,
vo
.
getTitle
())
.
eqIfPresent
(
RewardDO:
:
getPointsRequire
,
vo
.
getPointsRequire
())
.
eqIfPresent
(
RewardDO:
:
getNodeId
,
vo
.
getNodeId
())
.
eqIfPresent
(
RewardDO:
:
getQuantityRemain
,
vo
.
getQuantityRemain
())
.
eqIfPresent
(
RewardDO:
:
getPickMethod
,
vo
.
getPickMethod
())
.
eqIfPresent
(
RewardDO:
:
getStatus
,
vo
.
getStatus
())
.
betweenIfPresent
(
RewardDO:
:
getCreateTime
,
vo
.
getBeginCreateTime
(),
vo
.
getEndCreateTime
())
.
orderByDesc
(
RewardDO:
:
getId
));
}
...
...
@@ -40,21 +43,25 @@ public interface RewardMapper extends AbstractMapper<RewardDO> {
@Override
default
List
<
RewardDO
>
selectList
(
Object
object
)
{
if
(
object
instanceof
RewardQueryVO
)
{
RewardQueryVO
vo
=
(
RewardQueryVO
)
object
;
RewardQueryVO
vo
=
(
RewardQueryVO
)
object
;
return
selectList
(
new
LambdaQuery
<
RewardDO
>()
.
eqIfPresent
(
RewardDO:
:
getCode
,
vo
.
getCode
())
.
eqIfPresent
(
RewardDO:
:
getTitleZh
,
vo
.
getTitle
())
.
eqIfPresent
(
RewardDO:
:
getTitleEn
,
vo
.
getTitle
())
.
eqIfPresent
(
RewardDO:
:
getTitleFr
,
vo
.
getTitle
())
.
eqIfPresent
(
RewardDO:
:
getPointsRequire
,
vo
.
getPointsRequire
())
.
eqIfPresent
(
RewardDO:
:
getNodeId
,
vo
.
getNodeId
())
.
eqIfPresent
(
RewardDO:
:
getQuantityRemain
,
vo
.
getQuantityRemain
())
.
eqIfPresent
(
RewardDO:
:
getPickMethod
,
vo
.
getPickMethod
())
.
eqIfPresent
(
RewardDO:
:
getStatus
,
vo
.
getStatus
())
.
betweenIfPresent
(
RewardDO:
:
getCreateTime
,
vo
.
getBeginCreateTime
(),
vo
.
getEndCreateTime
())
.
eqIfPresent
(
RewardDO:
:
getCode
,
vo
.
getCode
())
.
eqIfPresent
(
RewardDO:
:
getTitleZh
,
vo
.
getTitle
())
.
eqIfPresent
(
RewardDO:
:
getTitleEn
,
vo
.
getTitle
())
.
eqIfPresent
(
RewardDO:
:
getTitleFr
,
vo
.
getTitle
())
.
eqIfPresent
(
RewardDO:
:
getPointsRequire
,
vo
.
getPointsRequire
())
.
eqIfPresent
(
RewardDO:
:
getNodeId
,
vo
.
getNodeId
())
.
eqIfPresent
(
RewardDO:
:
getQuantityRemain
,
vo
.
getQuantityRemain
())
.
eqIfPresent
(
RewardDO:
:
getPickMethod
,
vo
.
getPickMethod
())
.
eqIfPresent
(
RewardDO:
:
getStatus
,
vo
.
getStatus
())
.
betweenIfPresent
(
RewardDO:
:
getCreateTime
,
vo
.
getBeginCreateTime
(),
vo
.
getEndCreateTime
())
.
orderByDesc
(
RewardDO:
:
getId
));
}
return
null
;
}
@ResultType
(
String
.
class
)
@Select
({
"select code from ecw_reward order by code desc limit 1"
})
String
getCurrentMaxRewardCode
();
}
yudao-module-reward/yudao-module-reward-impl/src/main/java/cn/iocoder/yudao/module/reward/service/redeem/RewardRedeemServiceImpl.java
View file @
1103043b
...
...
@@ -288,6 +288,7 @@ public class RewardRedeemServiceImpl extends AbstractService<RewardRedeemMapper,
}
Map
<
String
,
Object
>
extParam
=
new
HashMap
<>();
extParam
.
put
(
"redeemId"
,
req
.
getId
());
extParam
.
put
(
"redemptionNumber"
,
rewardRedeemDO
.
getRedemptionNumber
());
memberUserScoreApi
.
operateScore
(
MemberUserScoreOperateReqDTO
.
builder
()
.
memberId
(
rewardRedeemDO
.
getMemberId
())
.
sourceType
(
ScoreSourceTypeEnum
.
EXCHANGE_REWARD_CANCEL
)
...
...
@@ -323,6 +324,7 @@ public class RewardRedeemServiceImpl extends AbstractService<RewardRedeemMapper,
RewardDO
rewardDO
=
rewardService
.
getById
(
rewardRedeemDO
.
getRewardId
());
return
AppRewardRedeemListRespVO
.
builder
()
.
id
(
rewardRedeemDO
.
getId
())
.
redemptionNumber
(
rewardRedeemDO
.
getRedemptionNumber
())
.
createTime
(
rewardRedeemDO
.
getCreateTime
())
.
rewardCode
(
rewardRedeemDO
.
getRewardId
())
.
rewardTitleEn
(
rewardDO
.
getTitleEn
())
...
...
yudao-module-reward/yudao-module-reward-impl/src/main/java/cn/iocoder/yudao/module/reward/service/reward/RewardServiceImpl.java
View file @
1103043b
...
...
@@ -22,11 +22,11 @@ import cn.iocoder.yudao.module.reward.enums.RewardPickMethedEnum;
import
cn.iocoder.yudao.module.reward.enums.RewardStatusEnum
;
import
cn.iocoder.yudao.module.reward.vo.reward.*
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.apache.commons.lang3.RandomStringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.validation.annotation.Validated
;
import
cn.iocoder.yudao.module.reward.util.RewardGenCodeUtils
;
import
javax.annotation.Resource
;
import
java.time.Instant
;
...
...
@@ -51,6 +51,8 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i
private
NodeApi
nodeApi
;
@Resource
private
MemberUserApi
memberUserApi
;
@Resource
private
RewardGenCodeUtils
rewardGenCodeUtils
;
@Override
public
List
<
Long
>
create
(
RewardCreateReqVO
createReqVO
)
{
...
...
@@ -65,14 +67,9 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i
for
(
RewardCreateReqVO
.
NodeAndPoints
nodeId
:
createReqVO
.
getNodeIds
())
{
rewardDO
.
setNodeId
(
nodeId
.
getNodeId
());
rewardDO
.
setPointsRequire
(
nodeId
.
getPoints
());
rewardDO
.
setCode
(
generateRewardCode
());
//如果插入失败,重新生成code再次插入
try
{
rewardMapper
.
insert
(
rewardDO
);
}
catch
(
Exception
e
)
{
rewardDO
.
setCode
(
generateRewardCode
());
rewardMapper
.
insert
(
rewardDO
);
}
rewardDO
.
setCode
(
rewardGenCodeUtils
.
generateRewardCode
());
rewardMapper
.
insert
(
rewardDO
);
ids
.
add
(
rewardDO
.
getId
());
rewardDO
.
setId
(
null
);
}
...
...
@@ -267,7 +264,7 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i
throw
exception
(
REWARD_NOT_EXISTS
);
}
//重新生成礼品ID
reward
.
setCode
(
generateRewardCode
());
reward
.
setCode
(
rewardGenCodeUtils
.
generateRewardCode
());
//设置为未启用
reward
.
setStatus
(
RewardStatusEnum
.
DISABLED
.
getValue
());
//已兑换次数清零
...
...
@@ -277,12 +274,7 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i
reward
.
setCreateTime
(
null
);
reward
.
setUpdateTime
(
null
);
reward
.
setDeleted
(
null
);
try
{
rewardMapper
.
insert
(
reward
);
}
catch
(
Exception
e
)
{
reward
.
setCode
(
generateRewardCode
());
rewardMapper
.
insert
(
reward
);
}
rewardMapper
.
insert
(
reward
);
return
reward
.
getId
();
}
...
...
@@ -407,13 +399,6 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i
}
}
/**
* 生成礼品ID
*/
private
String
generateRewardCode
()
{
return
RandomStringUtils
.
randomAlphanumeric
(
12
).
toUpperCase
();
}
/**
* 校验礼品是否过期并修改礼品状态
*/
...
...
yudao-module-reward/yudao-module-reward-impl/src/main/java/cn/iocoder/yudao/module/reward/util/RewardGenCodeUtils.java
0 → 100644
View file @
1103043b
package
cn
.
iocoder
.
yudao
.
module
.
reward
.
util
;
import
cn.iocoder.yudao.framework.redis.helper.RedisHelper
;
import
cn.iocoder.yudao.module.reward.dal.dataobject.redeem.RewardRedeemDO
;
import
cn.iocoder.yudao.module.reward.dal.dataobject.reward.RewardDO
;
import
cn.iocoder.yudao.module.reward.dal.mysql.redeem.RewardRedeemMapper
;
import
cn.iocoder.yudao.module.reward.dal.mysql.reward.RewardMapper
;
import
com.alibaba.excel.util.DateUtils
;
import
org.redisson.api.RLock
;
import
org.redisson.api.RedissonClient
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.concurrent.TimeUnit
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
exception
.
util
.
ServiceExceptionUtil
.
exception
;
import
static
cn
.
iocoder
.
yudao
.
module
.
infra
.
enums
.
ErrorCodeConstants
.
GET_LOCK_FAILED
;
/**
* 根据规则生成各种code
*/
@Component
public
class
RewardGenCodeUtils
{
@Resource
private
RewardMapper
rewardMapper
;
@Resource
private
RedisHelper
redisHelper
;
@Resource
private
RedissonClient
redissonClient
;
@Resource
private
RewardRedeemMapper
rewardRedeemMapper
;
/**
* 生成礼品ID
*/
public
String
generateRewardCode
()
{
// 礼品ID命名规则:G+年+5位序列号,例如G2400005
String
key
=
"rewardCode:max:number"
;
StringBuilder
code
=
new
StringBuilder
();
code
.
append
(
"G"
);
code
.
append
(
DateUtils
.
format
(
new
Date
(),
"yy"
));
Long
codeNum
;
if
(
redisHelper
.
hasKey
(
key
))
{
codeNum
=
redisHelper
.
incrBy
(
key
,
1
);
}
else
{
RLock
lock
=
redissonClient
.
getLock
(
"next:reward:code:lock"
);
try
{
boolean
lockSuccess
=
lock
.
tryLock
(
2
,
2
,
TimeUnit
.
SECONDS
);
if
(!
lockSuccess
)
{
throw
exception
(
GET_LOCK_FAILED
);
}
String
currentMaxRewardCode
=
rewardMapper
.
getCurrentMaxRewardCode
();
if
(
currentMaxRewardCode
==
null
){
codeNum
=
1L
;
}
else
{
codeNum
=
Long
.
parseLong
(
currentMaxRewardCode
.
substring
(
3
))
+
1
;
}
redisHelper
.
set
(
key
,
String
.
valueOf
(
codeNum
),
10
,
TimeUnit
.
SECONDS
);
}
catch
(
InterruptedException
e
)
{
throw
exception
(
GET_LOCK_FAILED
);
}
finally
{
lock
.
unlock
();
}
}
// 获得5位序列号,不足位前面补0
code
.
append
(
String
.
format
(
"%05d"
,
codeNum
));
return
code
.
toString
();
}
/**
* 生成兑换记录编号
*/
public
String
generateRedemptionNumber
()
{
String
key
=
"redemptionNumber:max:number"
;
// EC+年月+5位序列号,例如EC240900005
StringBuilder
code
=
new
StringBuilder
();
code
.
append
(
"EC"
);
String
currentYearMonth
=
DateUtils
.
format
(
new
Date
(),
"yyMM"
);
code
.
append
(
currentYearMonth
);
Long
codeNum
;
if
(
redisHelper
.
hasKey
(
key
))
{
codeNum
=
redisHelper
.
incrBy
(
key
,
1
);
}
else
{
RLock
lock
=
redissonClient
.
getLock
(
"next:redemptionNumber:code:lock"
);
try
{
boolean
lockSuccess
=
lock
.
tryLock
(
2
,
2
,
TimeUnit
.
SECONDS
);
if
(!
lockSuccess
)
{
throw
exception
(
GET_LOCK_FAILED
);
}
String
currentMaxRedemptionNumber
=
rewardRedeemMapper
.
getCurrentMaxRedemptionNumber
();
if
(
currentMaxRedemptionNumber
==
null
){
codeNum
=
1L
;
}
else
{
codeNum
=
Long
.
parseLong
(
currentMaxRedemptionNumber
.
substring
(
6
))
+
1
;
}
redisHelper
.
set
(
key
,
String
.
valueOf
(
codeNum
),
10
,
TimeUnit
.
SECONDS
);
}
catch
(
InterruptedException
e
)
{
throw
exception
(
GET_LOCK_FAILED
);
}
finally
{
lock
.
unlock
();
}
}
// 获得5位序列号,不足位前面补0
code
.
append
(
String
.
format
(
"%05d"
,
codeNum
));
return
code
.
toString
();
}
public
void
historyRewardCodeFlush
()
{
long
start
=
1L
;
redisHelper
.
delete
(
"rewardCode:max:number"
);
List
<
RewardDO
>
rewardDOS
=
rewardMapper
.
selectList
();
for
(
RewardDO
rewardDO
:
rewardDOS
)
{
StringBuilder
code
=
new
StringBuilder
();
code
.
append
(
"G"
);
code
.
append
(
DateUtils
.
format
(
new
Date
(),
"yy"
));
code
.
append
(
String
.
format
(
"%05d"
,
start
));
rewardDO
.
setCode
(
code
.
toString
());
rewardMapper
.
updateById
(
rewardDO
);
start
+=
1
;
}
}
public
void
redemptionNumberFlush
()
{
long
start
=
1L
;
redisHelper
.
delete
(
"redemptionNumber:max:number"
);
List
<
RewardRedeemDO
>
rewardRedeemDOList
=
rewardRedeemMapper
.
selectList
();
for
(
RewardRedeemDO
rewardRedeemDO
:
rewardRedeemDOList
)
{
StringBuilder
code
=
new
StringBuilder
();
code
.
append
(
"EC"
);
String
currentYearMonth
=
DateUtils
.
format
(
new
Date
(),
"yyMM"
);
code
.
append
(
currentYearMonth
);
code
.
append
(
String
.
format
(
"%05d"
,
start
));
rewardRedeemDO
.
setRedemptionNumber
(
code
.
toString
());
rewardRedeemMapper
.
updateById
(
rewardRedeemDO
);
start
+=
1
;
}
}
}
yudao-module-reward/yudao-module-reward-impl/src/main/java/cn/iocoder/yudao/module/reward/vo/reward/RewardRedeemBaseVO.java
View file @
1103043b
...
...
@@ -12,6 +12,11 @@ public class RewardRedeemBaseVO {
@ApiModelProperty
(
value
=
"id"
)
@JsonSerialize
(
using
=
ToStringSerializer
.
class
)
private
Long
id
;
/**
* 兑换记录编号
*/
@ApiModelProperty
(
value
=
"兑换记录编号"
)
private
String
redemptionNumber
;
/**
* 会员id
*/
...
...
yudao-module-reward/yudao-module-reward-impl/src/main/resources/mapper/RewardRedeemMapper.xml
View file @
1103043b
...
...
@@ -73,9 +73,13 @@
<include
refid=
"pageCondition"
/>
order by er.create_time desc
</select>
<select
id=
"getCurrentMaxRedemptionNumber"
resultType=
"java.lang.String"
>
select redemption_number from ecw_reward_redeem order by redemption_number desc limit 1
</select>
<sql
id=
"columns"
>
err.id ,
err.redemption_number as redemptionNumber,
err.member_id as memberId,
err.reward_id as rewardId,
err.status,
...
...
yudao-server/src/main/resources/i18n/messages_en.properties
View file @
1103043b
...
...
@@ -1057,7 +1057,7 @@ score.rule.update.error = only disabled rule can update
score.rule.delete.error
=
only disabled rule can delete
score.rule.status.error
=
score rule status error
score.rule.status.not.enable
=
score rule status not enable
score.rule.unique.check.error
=
score rule unique check error
score.rule.unique.check.error
=
The same rule already exists during the validity period
score.rule.transport.type.error
=
transport type error
score.rule.time.error
=
score rule time error
score.rule.period.error
=
score rule period error
...
...
yudao-server/src/main/resources/i18n/messages_zh.properties
View file @
1103043b
...
...
@@ -1001,13 +1001,13 @@ case.num.in.merge.pkg=\u6B64\u7BB1\u5DF2\u88AB\u5408\u5305\uFF0C\u8BF7\u626B\u63
order.already.in.merge.pkg
=
\u
8BA2
\u5355\u
5DF2
\u5728\u5408\u5305\u
7BB1
\u
4E0B
customer.is.new.or.old.no.change
=
\u
5BA2
\u6237\u
5F53
\u
524D
\u
4E1A
\u
7EE9
\u
7C7B
\u
578B
\u
662F{}
\u
5BA2
\u6237\u
FF0C
\u
4E0D
\u9700\u8981\u
66F4
\u
65B0
order.is.pre.installed
=
\u
8BA2
\u5355\u
5DF2
\u9884\u
88C5
order.is.not.pre.installed
=
\u
8
ba2
\u5355\u
672a
\u9884\u
88c5
\u
ff0c
\u
4e0d
\u
80fd
\u5408\u5305
order.item.charging.not.null
=
\u
8
ba2
\u5355\u5546\u
54c1
\u
8ba1
\u
8d39
\u
65b9
\u
5f0f
\u
4e0d
\u
80fd
\u
4e3a
\u
7a7a
order.item.is.pay.advance.not.null
=
\u
8
ba2
\u5355\u5546\u
54c1
\u
662f
\u5426\u9884\u
4ed8
\u
4e0d
\u
80fd
\u
4e3a
\u
7a7a
order.item.freight.currency.not.null
=
\u
8
ba2
\u5355\u5546\u
54c1
\u
8fd0
\u
8d39
\u
8d27
\u
5e01
\u5355\u
4f4d
\u
4e0d
\u
80fd
\u
4e3a
\u
7a7a
order.item.freight.unit.not.null
=
\u
8
ba2
\u5355\u5546\u
54c1
\u
8fd0
\u
8d39
\u
8ba1
\u
91cf
\u5355\u
4f4d
\u
4e0d
\u
80fd
\u
4e3a
\u
7a7a
order.item.clearance.currency.not.null
=
\u
8
ba2
\u5355\u5546\u
54c1
\u
6e05
\u5173\u
8d39
\u
8d27
\u
5e01
\u5355\u
4f4d
\u
4e0d
\u
80fd
\u
4e3a
\u
7a7a
order.item.clearance.unit.not.null
=
\u
8
ba2
\u5355\u5546\u
54c1
\u
6e05
\u5173\u
8d39
\u
8ba1
\u
91cf
\u5355\u
4f4d
\u
4e0d
\u
80fd
\u
4e3a
\u
7a7a
order.is.not.pre.installed
=
\u
8
BA2
\u5355\u
672A
\u9884\u
88C5
\u
FF0C
\u
4E0D
\u
80FD
\u5408\u5305
order.item.charging.not.null
=
\u
8
BA2
\u5355\u5546\u
54C1
\u
8BA1
\u
8D39
\u
65B9
\u
5F0F
\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
order.item.is.pay.advance.not.null
=
\u
8
BA2
\u5355\u5546\u
54C1
\u
662F
\u5426\u9884\u
4ED8
\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
order.item.freight.currency.not.null
=
\u
8
BA2
\u5355\u5546\u
54C1
\u
8FD0
\u
8D39
\u
8D27
\u
5E01
\u5355\u
4F4D
\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
order.item.freight.unit.not.null
=
\u
8
BA2
\u5355\u5546\u
54C1
\u
8FD0
\u
8D39
\u
8BA1
\u
91CF
\u5355\u
4F4D
\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
order.item.clearance.currency.not.null
=
\u
8
BA2
\u5355\u5546\u
54C1
\u
6E05
\u5173\u
8D39
\u
8D27
\u
5E01
\u5355\u
4F4D
\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
order.item.clearance.unit.not.null
=
\u
8
BA2
\u5355\u5546\u
54C1
\u
6E05
\u5173\u
8D39
\u
8BA1
\u
91CF
\u5355\u
4F4D
\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
member.id.is.null
=
\u
7F3A
\u
5C11
\u
4F1A
\u5458
id
score.count.error
=
\u
79EF
\u5206\u
5FC5
\u
987B > 0
member.score.not.enough
=
\u
4F1A
\u5458\u
79EF
\u5206\u
4E0D
\u
8DB3
...
...
@@ -1058,7 +1058,7 @@ score.rule.update.error = \u53EA\u6709\u672A\u542F\u7528\u89C4\u5219\u53EF\u4EE5
score.rule.delete.error
=
\u
53EA
\u6709\u
672A
\u
542F
\u7528\u
53EF
\u
4EE5
\u5220\u9664
score.rule.status.error
=
\u
79EF
\u5206\u
89C4
\u5219\u
72B6
\u6001\u9519\u
8BEF
score.rule.status.not.enable
=
\u
79EF
\u5206\u
89C4
\u5219\u
672A
\u
542F
\u7528
score.rule.unique.check.error
=
\u
79EF
\u5206\u
89C4
\u5219\u
552F
\u
4E00
\u6027\u
68C0
\u
67E5
\u5931\u
8D25
score.rule.unique.check.error
=
\u
6709\u6548\u
671F
\u5185\u
5DF2
\u
5B58
\u5728\u
76F8
\u
540C
\u
89C4
\u5219
score.rule.transport.type.error
=
\u
8FD0
\u
8F93
\u
7C7B
\u
578B
\u9519\u
8BEF
score.rule.time.error
=
\u
6D3B
\u
52A8
\u
65F6
\u
95F4
\u
4E0D
\u5408\u
6CD5
score.rule.period.error
=
\u
8FC7
\u
671F
\u
65F6
\u
95F4
\u9519\u
8BEF
...
...
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