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
e688a1d4
Commit
e688a1d4
authored
Aug 08, 2024
by
zhangfeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
客户端兑换礼品短信验证码
parent
df1a30a9
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
83 additions
and
16 deletions
+83
-16
RedeemRewardApi.java
...coder/yudao/module/reward/api/reward/RedeemRewardApi.java
+1
-0
RedeemRewardReqVO.java
...yudao/module/reward/api/reward/dto/RedeemRewardReqVO.java
+8
-9
RedeemRewardApiImpl.java
...r/yudao/module/reward/api/reward/RedeemRewardApiImpl.java
+36
-0
AppRedeemRewardController.java
...ward/controller/app/redeem/AppRedeemRewardController.java
+13
-6
AppRedeemRewardReqVO.java
...reward/controller/app/redeem/vo/AppRedeemRewardReqVO.java
+22
-0
AppRewardRedeemReqVO.java
...reward/controller/app/redeem/vo/AppRewardRedeemReqVO.java
+1
-1
SmsSceneEnum.java
...n/iocoder/yudao/module/system/enums/sms/SmsSceneEnum.java
+2
-0
No files found.
yudao-module-reward/yudao-module-reward-api/src/main/java/cn/iocoder/yudao/module/reward/api/reward/RedeemRewardApi.java
View file @
e688a1d4
...
@@ -15,4 +15,5 @@ public interface RedeemRewardApi {
...
@@ -15,4 +15,5 @@ public interface RedeemRewardApi {
List
<
RedeemRewardRespDTO
>
redeemRewards
(
List
<
RedeemRewardReqVO
>
redeemRewardReqVOList
);
List
<
RedeemRewardRespDTO
>
redeemRewards
(
List
<
RedeemRewardReqVO
>
redeemRewardReqVOList
);
RedeemDetailForUserDTO
getRedeemDetailForUser
(
Long
redeemId
);
RedeemDetailForUserDTO
getRedeemDetailForUser
(
Long
redeemId
);
void
sendSmsCode
(
Long
memberId
);
}
}
yudao-module-reward/yudao-module-reward-api/src/main/java/cn/iocoder/yudao/module/reward/api/reward/dto/RedeemRewardReqVO.java
View file @
e688a1d4
...
@@ -13,19 +13,19 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
...
@@ -13,19 +13,19 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@Data
@Data
@ApiModel
(
"管理后台 - 礼品兑换 Request VO"
)
@ApiModel
(
"管理后台 - 礼品兑换 Request VO"
)
public
class
RedeemRewardReqVO
{
public
class
RedeemRewardReqVO
{
@ApiModelProperty
(
value
=
"会员id"
)
@ApiModelProperty
(
value
=
"会员id"
,
required
=
true
)
private
Long
memberId
;
private
Long
memberId
;
@ApiModelProperty
(
value
=
"礼品id"
)
@ApiModelProperty
(
value
=
"礼品id"
,
required
=
true
)
private
Long
rewardId
;
private
Long
rewardId
;
@ApiModelProperty
(
value
=
"兑换数量"
)
@ApiModelProperty
(
value
=
"兑换数量"
,
required
=
true
)
private
Integer
rewardCount
;
private
Integer
rewardCount
;
@ApiModelProperty
(
value
=
"兑换方式,同领取方式(1上门领取,2包邮到家,3邮寄到付)"
)
@ApiModelProperty
(
value
=
"兑换方式,同领取方式(1上门领取,2包邮到家,3邮寄到付)"
,
required
=
true
)
private
Integer
redeemType
;
private
Integer
redeemType
;
@ApiModelProperty
(
value
=
"兑换入口(后台,app,web)"
)
@ApiModelProperty
(
value
=
"兑换入口(后台,app,web)"
,
required
=
true
)
private
Integer
entrance
;
private
Integer
entrance
;
@ApiModelProperty
(
value
=
"费用数字(两位小数)"
)
@ApiModelProperty
(
value
=
"费用数字(两位小数)"
)
...
@@ -34,13 +34,13 @@ public class RedeemRewardReqVO {
...
@@ -34,13 +34,13 @@ public class RedeemRewardReqVO {
@ApiModelProperty
(
value
=
"费用币种(字典配置)"
)
@ApiModelProperty
(
value
=
"费用币种(字典配置)"
)
private
Integer
currency
;
private
Integer
currency
;
@ApiModelProperty
(
value
=
"收件人姓名"
)
@ApiModelProperty
(
value
=
"收件人姓名"
,
required
=
true
)
private
String
recipientName
;
private
String
recipientName
;
@ApiModelProperty
(
value
=
"收件人电话"
)
@ApiModelProperty
(
value
=
"收件人电话"
,
required
=
true
)
private
String
recipientPhoneNum
;
private
String
recipientPhoneNum
;
@ApiModelProperty
(
value
=
"收件人地址"
)
@ApiModelProperty
(
value
=
"收件人地址"
,
required
=
true
)
private
String
recipientAddress
;
private
String
recipientAddress
;
@ApiModelProperty
(
value
=
"兑换人"
)
@ApiModelProperty
(
value
=
"兑换人"
)
...
@@ -68,5 +68,4 @@ public class RedeemRewardReqVO {
...
@@ -68,5 +68,4 @@ public class RedeemRewardReqVO {
@ApiModelProperty
(
value
=
"备注"
)
@ApiModelProperty
(
value
=
"备注"
)
private
String
remark
;
private
String
remark
;
}
}
yudao-module-reward/yudao-module-reward-impl/src/main/java/cn/iocoder/yudao/module/reward/api/reward/RedeemRewardApiImpl.java
View file @
e688a1d4
...
@@ -12,11 +12,16 @@ import cn.iocoder.yudao.module.member.enums.ScoreSourceTypeEnum;
...
@@ -12,11 +12,16 @@ import cn.iocoder.yudao.module.member.enums.ScoreSourceTypeEnum;
import
cn.iocoder.yudao.module.reward.api.reward.dto.RedeemDetailForUserDTO
;
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.RedeemRewardReqVO
;
import
cn.iocoder.yudao.module.reward.api.reward.dto.RedeemRewardRespDTO
;
import
cn.iocoder.yudao.module.reward.api.reward.dto.RedeemRewardRespDTO
;
import
cn.iocoder.yudao.module.reward.controller.app.redeem.vo.AppRedeemRewardReqVO
;
import
cn.iocoder.yudao.module.reward.dal.dataobject.redeem.RewardRedeemDO
;
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.dataobject.reward.RewardDO
;
import
cn.iocoder.yudao.module.reward.dal.mysql.redeem.RewardRedeemMapper
;
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.dal.mysql.reward.RewardMapper
;
import
cn.iocoder.yudao.module.reward.enums.RewardRedeemStatusEnum
;
import
cn.iocoder.yudao.module.reward.enums.RewardRedeemStatusEnum
;
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
;
import
cn.iocoder.yudao.module.system.enums.sms.SmsSceneEnum
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.redisson.api.RLock
;
import
org.redisson.api.RLock
;
...
@@ -33,6 +38,7 @@ import java.util.Map;
...
@@ -33,6 +38,7 @@ import java.util.Map;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
exception
.
util
.
ServiceExceptionUtil
.
exception
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
exception
.
util
.
ServiceExceptionUtil
.
exception
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
util
.
servlet
.
ServletUtils
.
getClientIP
;
import
static
cn
.
iocoder
.
yudao
.
module
.
infra
.
enums
.
ErrorCodeConstants
.
GET_LOCK_FAILED
;
import
static
cn
.
iocoder
.
yudao
.
module
.
infra
.
enums
.
ErrorCodeConstants
.
GET_LOCK_FAILED
;
import
static
cn
.
iocoder
.
yudao
.
module
.
member
.
enums
.
ErrorCodeConstants
.
USER_NOT_EXISTS
;
import
static
cn
.
iocoder
.
yudao
.
module
.
member
.
enums
.
ErrorCodeConstants
.
USER_NOT_EXISTS
;
import
static
cn
.
iocoder
.
yudao
.
module
.
reward
.
enums
.
ErrorCodeConstants
.*;
import
static
cn
.
iocoder
.
yudao
.
module
.
reward
.
enums
.
ErrorCodeConstants
.*;
...
@@ -54,10 +60,25 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
...
@@ -54,10 +60,25 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
private
MemberUserScoreApi
memberUserScoreApi
;
private
MemberUserScoreApi
memberUserScoreApi
;
@Resource
@Resource
private
SnowflakeGenerator
snowflakeGenerator
;
private
SnowflakeGenerator
snowflakeGenerator
;
@Resource
private
SmsCodeApi
smsCodeApi
;
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
RedeemRewardRespDTO
redeemReward
(
RedeemRewardReqVO
redeemRewardReqVO
)
{
public
RedeemRewardRespDTO
redeemReward
(
RedeemRewardReqVO
redeemRewardReqVO
)
{
if
(
redeemRewardReqVO
.
getEntrance
()
!=
PlatformTypeEnum
.
BACKEND
.
getValue
()
&&
redeemRewardReqVO
instanceof
AppRedeemRewardReqVO
){
AppRedeemRewardReqVO
appRedeemRewardReqVO
=
(
AppRedeemRewardReqVO
)
redeemRewardReqVO
;
SmsCodeUseReqDTO
smsCodeUseReqDTO
=
new
SmsCodeUseReqDTO
();
UserRespDTO
memberUserApiUser
=
memberUserApi
.
getUser
(
redeemRewardReqVO
.
getMemberId
());
if
(
memberUserApiUser
==
null
)
{
throw
exception
(
USER_NOT_EXISTS
);
}
smsCodeUseReqDTO
.
setMobile
(
memberUserApiUser
.
getMobile
());
smsCodeUseReqDTO
.
setCode
(
appRedeemRewardReqVO
.
getCode
());
smsCodeUseReqDTO
.
setUsedIp
(
getClientIP
());
smsCodeUseReqDTO
.
setScene
(
SmsSceneEnum
.
MEMBER_REDEEM_REWARD
.
getScene
());
smsCodeApi
.
useSmsCode
(
smsCodeUseReqDTO
);
}
// 查询礼品
// 查询礼品
RewardDO
rewardDO
=
rewardMapper
.
selectById
(
redeemRewardReqVO
.
getRewardId
());
RewardDO
rewardDO
=
rewardMapper
.
selectById
(
redeemRewardReqVO
.
getRewardId
());
if
(
rewardDO
==
null
)
{
if
(
rewardDO
==
null
)
{
...
@@ -211,6 +232,21 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
...
@@ -211,6 +232,21 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
return
null
;
return
null
;
}
}
@Override
public
void
sendSmsCode
(
Long
memberId
)
{
UserRespDTO
memberUserApiUser
=
memberUserApi
.
getUser
(
memberId
);
if
(
memberUserApiUser
==
null
)
{
throw
exception
(
USER_NOT_EXISTS
);
}
SmsCodeSendReqDTO
smsCodeSendReqDTO
=
new
SmsCodeSendReqDTO
();
smsCodeSendReqDTO
.
setMobile
(
memberUserApiUser
.
getMobile
());
smsCodeSendReqDTO
.
setAreaCode
(
memberUserApiUser
.
getAreaCode
());
smsCodeSendReqDTO
.
setCreateIp
(
getClientIP
());
smsCodeSendReqDTO
.
setScene
(
SmsSceneEnum
.
MEMBER_REDEEM_REWARD
.
getScene
());
smsCodeApi
.
sendSmsCode
(
smsCodeSendReqDTO
);
}
private
void
verifyMemberUser
(
RedeemRewardReqVO
redeemRewardReqVO
,
RewardDO
rewardDO
)
{
private
void
verifyMemberUser
(
RedeemRewardReqVO
redeemRewardReqVO
,
RewardDO
rewardDO
)
{
// 查询会员积分
// 查询会员积分
UserRespDTO
memberUser
=
memberUserApi
.
getUser
(
redeemRewardReqVO
.
getMemberId
());
UserRespDTO
memberUser
=
memberUserApi
.
getUser
(
redeemRewardReqVO
.
getMemberId
());
...
...
yudao-module-reward/yudao-module-reward-impl/src/main/java/cn/iocoder/yudao/module/reward/controller/app/redeem/AppRedeemRewardController.java
View file @
e688a1d4
package
cn
.
iocoder
.
yudao
.
module
.
reward
.
controller
.
app
.
redeem
;
package
cn
.
iocoder
.
yudao
.
module
.
reward
.
controller
.
app
.
redeem
;
import
cn.iocoder.yudao.framework.common.pojo.CommonResult
;
import
cn.iocoder.yudao.framework.common.pojo.CommonResult
;
import
cn.iocoder.yudao.framework.idempotent.core.annotation.Idempotent
;
import
cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog
;
import
cn.iocoder.yudao.module.reward.api.reward.RedeemRewardApi
;
import
cn.iocoder.yudao.module.reward.api.reward.RedeemRewardApi
;
import
cn.iocoder.yudao.module.reward.api.reward.dto.RedeemRewardReqVO
;
import
cn.iocoder.yudao.module.reward.api.reward.dto.RedeemRewardRespDTO
;
import
cn.iocoder.yudao.module.reward.api.reward.dto.RedeemRewardRespDTO
;
import
cn.iocoder.yudao.module.reward.controller.app.redeem.vo.AppRewardRedeemDetailReqVO
;
import
cn.iocoder.yudao.module.reward.controller.app.redeem.vo.*
;
import
cn.iocoder.yudao.module.reward.controller.app.redeem.vo.AppRewardRedeemDetailRespVO
;
import
cn.iocoder.yudao.module.reward.controller.app.redeem.vo.AppRewardRedeemListRespVO
;
import
cn.iocoder.yudao.module.reward.controller.app.redeem.vo.AppRewardRedeemReqVO
;
import
cn.iocoder.yudao.module.reward.service.redeem.RewardRedeemService
;
import
cn.iocoder.yudao.module.reward.service.redeem.RewardRedeemService
;
import
cn.iocoder.yudao.module.reward.vo.reward.RewardRedeemPageRespVO
;
import
cn.iocoder.yudao.module.reward.vo.reward.RewardRedeemPageRespVO
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
...
@@ -58,8 +56,17 @@ public class AppRedeemRewardController {
...
@@ -58,8 +56,17 @@ public class AppRedeemRewardController {
@PostMapping
(
"/single"
)
@PostMapping
(
"/single"
)
@ApiOperation
(
"兑换礼品"
)
@ApiOperation
(
"兑换礼品"
)
@Idempotent
(
timeout
=
5
)
//@PreAuthenticated
//@PreAuthenticated
public
CommonResult
<
RedeemRewardRespDTO
>
redeemReward
(
@Valid
@RequestBody
RedeemRewardReqVO
redeemRewardReqVO
)
{
public
CommonResult
<
RedeemRewardRespDTO
>
redeemReward
(
@Valid
@RequestBody
App
RedeemRewardReqVO
redeemRewardReqVO
)
{
return
success
(
redeemRewardApi
.
redeemReward
(
redeemRewardReqVO
));
return
success
(
redeemRewardApi
.
redeemReward
(
redeemRewardReqVO
));
}
}
@PostMapping
(
"/send-sms-code"
)
@ApiOperation
(
value
=
"兑换礼品发送手机验证码"
)
@OperateLog
(
enable
=
false
)
// 避免 Post 请求被记录操作日志
@Idempotent
(
timeout
=
5
)
public
CommonResult
<
Boolean
>
sendSmsCode
(
@RequestBody
@Valid
AppRewardRedeemReqVO
reqVO
)
{
redeemRewardApi
.
sendSmsCode
(
reqVO
.
getMemberId
());
return
success
(
true
);
}
}
}
yudao-module-reward/yudao-module-reward-impl/src/main/java/cn/iocoder/yudao/module/reward/controller/app/redeem/vo/AppRedeemRewardReqVO.java
0 → 100644
View file @
e688a1d4
package
cn
.
iocoder
.
yudao
.
module
.
reward
.
controller
.
app
.
redeem
.
vo
;
import
cn.iocoder.yudao.module.reward.api.reward.dto.RedeemRewardReqVO
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
org.hibernate.validator.constraints.Length
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.Pattern
;
@Data
@ApiModel
(
"客户端 - 礼品兑换 req VO"
)
@EqualsAndHashCode
(
callSuper
=
true
)
public
class
AppRedeemRewardReqVO
extends
RedeemRewardReqVO
{
@ApiModelProperty
(
value
=
"手机验证码"
,
required
=
true
,
example
=
"1024"
)
@NotBlank
(
message
=
"{app.auth.captcha.not.blank}"
)
@Length
(
min
=
4
,
max
=
4
,
message
=
"{app.auth.captcha.len.err}"
)
@Pattern
(
regexp
=
"^[0-9]+$"
,
message
=
"{app.auth.captcha.pattern}"
)
private
String
code
;
}
yudao-module-reward/yudao-module-reward-impl/src/main/java/cn/iocoder/yudao/module/reward/controller/app/redeem/vo/AppRewardRedeemReqVO.java
View file @
e688a1d4
...
@@ -7,7 +7,7 @@ import lombok.Data;
...
@@ -7,7 +7,7 @@ import lombok.Data;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.NotNull
;
@Data
@Data
@ApiModel
(
"客户端 - 礼品兑换
记录列表
req VO"
)
@ApiModel
(
"客户端 - 礼品兑换 req VO"
)
public
class
AppRewardRedeemReqVO
{
public
class
AppRewardRedeemReqVO
{
@ApiModelProperty
(
value
=
"会员id"
)
@ApiModelProperty
(
value
=
"会员id"
)
@NotNull
(
message
=
"会员id不能为空"
)
@NotNull
(
message
=
"会员id不能为空"
)
...
...
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/sms/SmsSceneEnum.java
View file @
e688a1d4
...
@@ -28,6 +28,8 @@ public enum SmsSceneEnum implements IntArrayValuable {
...
@@ -28,6 +28,8 @@ public enum SmsSceneEnum implements IntArrayValuable {
NOTIFICATION_SUCCESS_CANCEL_DELIVERY
(
7
,
"notification-successful-cancel-delivery"
,
"订单 - 取消放货通知"
),
NOTIFICATION_SUCCESS_CANCEL_DELIVERY
(
7
,
"notification-successful-cancel-delivery"
,
"订单 - 取消放货通知"
),
NOTIFICATION_SUCCESS_SEASONING_CONDIMENTS
(
8
,
"notification-successful-seasoning-condiments"
,
"订单 - 调货通知"
),
NOTIFICATION_SUCCESS_SEASONING_CONDIMENTS
(
8
,
"notification-successful-seasoning-condiments"
,
"订单 - 调货通知"
),
MEMBER_REDEEM_REWARD
(
9
,
"user-sms-redeem-reward"
,
"会员用户 - 兑换礼品"
),
SHIPMENT_ARRIVALS
(
20
,
"shipment-arrivals"
,
"出货 - 到港通知(多订单)"
),
SHIPMENT_ARRIVALS
(
20
,
"shipment-arrivals"
,
"出货 - 到港通知(多订单)"
),
SHIPMENT_CUSTOMS_CLEARANCES
(
21
,
"shipment-customs-clearances"
,
"出货 - 清关通知(多订单)"
),
SHIPMENT_CUSTOMS_CLEARANCES
(
21
,
"shipment-customs-clearances"
,
"出货 - 清关通知(多订单)"
),
...
...
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