Commit 347ba750 authored by zhangfeng's avatar zhangfeng

Merge branch 'refs/heads/feature_member_score' into dev

parents f05ac208 7f8837a4
package cn.iocoder.yudao.module.member.controller.app.scoreRule;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import cn.iocoder.yudao.module.member.api.ScoreProducerApi;
import cn.iocoder.yudao.module.member.controller.app.scoreRule.vo.AppScoreRuleBackDetailVO;
import cn.iocoder.yudao.module.member.controller.app.scoreRule.vo.AppScoreRuleListBackVO;
import cn.iocoder.yudao.module.member.controller.app.scoreRule.vo.AppScoreRuleListReqVO;
import cn.iocoder.yudao.module.member.service.scoreRule.ScoreRuleService;
import cn.iocoder.yudao.module.member.vo.scoreRule.IdReqVo;
import cn.iocoder.yudao.module.member.vo.scoreRule.ScoreRuleBackVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.ScoreRuleQueryVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.context.ApplicationContext;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Validated
@RestController
@Api(tags = "客户端 - 积分规则")
@RequestMapping("/member/score-rule")
public class AppScoreRuleController {
@Resource
private ScoreRuleService scoreRuleService;
@Resource
private ApplicationContext applicationContext;
@Resource
private ScoreProducerApi scoreProducerApi;
@PostMapping("/get")
@ApiOperation("客户端获得积分规则详情")
public CommonResult<AppScoreRuleBackDetailVO> getScoreRule(@Valid @RequestBody IdReqVo idReqVo) {
AppScoreRuleBackDetailVO scoreRuleBackDetailVO = scoreRuleService.appGetScoreRule(idReqVo.getId());
return success(scoreRuleBackDetailVO);
}
@PostMapping("/list")
@ApiOperation("客户端获得积分规则列表")
public CommonResult<List<AppScoreRuleListBackVO>> getScoreRuleList(@Valid @RequestBody AppScoreRuleListReqVO reqVO) {
List<AppScoreRuleListBackVO> list = scoreRuleService.appGetScoreRuleList(reqVO);
return success(list);
}
//@PostMapping("/page")
//@ApiOperation("获得积分规则分页")
//public CommonResult<PageResult<ScoreRuleBackVO>> getScoreRulePage(@Valid @RequestBody ScoreRuleQueryVO query, PageVO page) {
// PageResult<ScoreRuleBackVO> pageResult = scoreRuleService.getScoreRulePage(query, page);
// return success(pageResult);
//}
}
package cn.iocoder.yudao.module.member.controller.app.scoreRule.vo;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleShareExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRulerRecommendExtraVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel("客户端 - 积分规则详细信息 Response VO")
public class AppScoreRuleBackDetailVO extends AppScoreRuleListBackVO {
@ApiModelProperty(value = "单次获取积分数")
private Integer getScoreOnce;
@ApiModelProperty(value = "累积最高积分")
private Integer maxScoreTotal;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "活动开始时间")
private Date startTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "活动结束时间")
private Date endTime;
@ApiModelProperty(value = "积分有效期")
private Integer scorePeriod;
//@ApiModelProperty(value = "扩展字段原始")
//private String extra;
//@ApiModelProperty(value = "订单V值扩展字段")
//private ScoreRuleOrderVExtraVO extraOrderV;
//@ApiModelProperty(value = "注册扩展字段")
//private ScoreRuleRegisterExtraVO extraRegister;
}
package cn.iocoder.yudao.module.member.controller.app.scoreRule.vo;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleShareExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRulerRecommendExtraVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 积分规则 resp VO
*
* @author 系统管理员
*/
@Data
@ApiModel("客户端 - 积分规则列表 Response VO")
public class AppScoreRuleListBackVO {
@ApiModelProperty(value = "主键", required = true)
private Long id;
@ApiModelProperty(value = "指标类型", required = true)
private Integer type;
@ApiModelProperty(value = "规则标题中文", required = true)
private String titleZh;
@ApiModelProperty(value = "规则标题英文", required = true)
private String titleEn;
@ApiModelProperty(value = "规则说明中文", required = true)
private String descZh;
@ApiModelProperty(value = "规则说明英文", required = true)
private String descEn;
@ApiModelProperty(value = "封面图中文")
private String coverImageZh;
@ApiModelProperty(value = "封面图英文")
private String coverImageEn;
@ApiModelProperty(value = "推荐扩展字段")
private ScoreRulerRecommendExtraVO extraRecommend;
@ApiModelProperty(value = "分享扩展字段")
private ScoreRuleShareExtraVO extraShare;
}
package cn.iocoder.yudao.module.member.controller.app.scoreRule.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
* 积分规则 req VO
* @author 系统管理员
*/
@Data
@ApiModel("客户端 - 积分规则列表 req VO")
public class AppScoreRuleListReqVO {
@ApiModelProperty(value = "平台入口(2APP,3WEB)", required = true)
@NotNull(message = "平台入口不能为空")
private Integer platform;
}
......@@ -3,8 +3,10 @@ package cn.iocoder.yudao.module.member.service.address;
import java.util.*;
import javax.annotation.Resource;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.service.AbstractService;
import cn.iocoder.yudao.module.ecw.api.paramValid.ParamValidatorApi;
import cn.iocoder.yudao.module.member.convert.address.UserAddressConvert;
import cn.iocoder.yudao.module.member.dal.dataobject.address.UserAddressDO;
import cn.iocoder.yudao.module.member.dal.mysql.address.UserAddressMapper;
......@@ -35,9 +37,12 @@ public class UserAddressServiceImpl extends AbstractService<UserAddressMapper, U
private UserAddressMapper userAddressMapper;
@Resource
private MemberUserService userService;
@Resource
private ParamValidatorApi paramValidatorApi;
@Override
public Long createUserAddress(UserAddressCreateReqVO createReqVO) {
verifyUserAddress(createReqVO);
// 插入
UserAddressDO userAddress = UserAddressConvert.INSTANCE.convert(createReqVO);
updateIsDefault(createReqVO, 0L);
......@@ -48,6 +53,7 @@ public class UserAddressServiceImpl extends AbstractService<UserAddressMapper, U
@Override
public void updateUserAddress(UserAddressUpdateReqVO updateReqVO) {
verifyUserAddress(updateReqVO);
// 校验存在
this.validateUserAddressExists(updateReqVO.getId());
updateIsDefault(updateReqVO, updateReqVO.getId());
......@@ -67,9 +73,8 @@ public class UserAddressServiceImpl extends AbstractService<UserAddressMapper, U
throw exception(USER_ADDRESS_FIELD_ERROR,"Address,AreaCode,Name,Phone must not null");
}
// 校验手机号格式
if (!reqVO.getPhone().matches("^1[3-9]\\d{9}$")) {
throw exception(USER_ADDRESS_FIELD_ERROR,"phone number error");
}
String mobileCode = reqVO.getAreaCode() + StrUtil.COLON + reqVO.getPhone();
paramValidatorApi.validatorMobile(mobileCode);
}
private void updateIsDefault(UserAddressBaseVO updateReqVO, Long id) {
......
......@@ -6,6 +6,9 @@ import javax.validation.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.service.IService;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import cn.iocoder.yudao.module.member.controller.app.scoreRule.vo.AppScoreRuleBackDetailVO;
import cn.iocoder.yudao.module.member.controller.app.scoreRule.vo.AppScoreRuleListBackVO;
import cn.iocoder.yudao.module.member.controller.app.scoreRule.vo.AppScoreRuleListReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.scoreRule.ScoreRuleDO;
import cn.iocoder.yudao.module.member.enums.ScoreRuleTypeEnum;
import cn.iocoder.yudao.module.member.enums.TransportTypeEnum;
......@@ -121,4 +124,18 @@ public interface ScoreRuleService extends IService<ScoreRuleDO> {
ScoreRuleDO getEnableScoreRuleByType(ScoreRuleTypeEnum scoreRuleType, TransportTypeEnum transportType);
List<WarehouseTreeRegionSimpleVO> getWarehouseTreeRegionListSimple();
/**
* 客户端获取积分规则列表
* @param reqVO
* @return
*/
List<AppScoreRuleListBackVO> appGetScoreRuleList(AppScoreRuleListReqVO reqVO);
/**
* 客户端获取积分规则详情
* @param id
* @return
*/
AppScoreRuleBackDetailVO appGetScoreRule(Long id);
}
......@@ -3,11 +3,15 @@ package cn.iocoder.yudao.module.member.service.scoreRule;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.json.JSONUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQuery;
import cn.iocoder.yudao.framework.mybatis.core.service.AbstractService;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import cn.iocoder.yudao.module.depository.service.warehouse.WarehouseService;
import cn.iocoder.yudao.module.depository.vo.warehouse.WarehouseTreeRegionVO;
import cn.iocoder.yudao.module.member.controller.app.scoreRule.vo.AppScoreRuleBackDetailVO;
import cn.iocoder.yudao.module.member.controller.app.scoreRule.vo.AppScoreRuleListBackVO;
import cn.iocoder.yudao.module.member.controller.app.scoreRule.vo.AppScoreRuleListReqVO;
import cn.iocoder.yudao.module.member.convert.scoreRule.ScoreRuleConvert;
import cn.iocoder.yudao.module.member.dal.dataobject.scoreRule.ScoreRuleDO;
import cn.iocoder.yudao.module.member.dal.mysql.scoreRule.ScoreRuleMapper;
......@@ -22,6 +26,7 @@ import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleRegisterExtraV
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleShareExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRulerRecommendExtraVO;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
......@@ -75,7 +80,7 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
if (scoreRuleIn.getType() != ScoreRuleTypeEnum.ORDER_V.getValue() && scoreRuleIn.getGetScoreOnce() <= 0) {
throw exception(SCORE_RULE_FIELD_ERROR, LocaleContextHolder.getLocale().equals(Locale.SIMPLIFIED_CHINESE) ? "单次获得积分必须大于0" : "getScoreOnce must > 0");
}
if (scoreRuleIn.getType() != ScoreRuleTypeEnum.RECOMMEND.getValue() && scoreRuleIn.getMaxScoreTotal() <= 0) {
if (scoreRuleIn.getType() != ScoreRuleTypeEnum.REGISTER.getValue() && scoreRuleIn.getMaxScoreTotal() <= 0) {
throw exception(SCORE_RULE_FIELD_ERROR, LocaleContextHolder.getLocale().equals(Locale.SIMPLIFIED_CHINESE) ? "累积最高积分必须大于0" : "maxScoreTotal must > 0");
}
if (scoreRuleIn.getStartTime().after((scoreRuleIn.getEndTime())) || scoreRuleIn.getEndTime().before(Date.from(Instant.now()))) {
......@@ -497,4 +502,39 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
}
return warehouseTreeRegionSimpleVOS;
}
@Override
public List<AppScoreRuleListBackVO> appGetScoreRuleList(AppScoreRuleListReqVO reqVO) {
List<ScoreRuleDO> scoreRuleDOS = scoreRuleMapper.selectList("status", ScoreRuleStatusEnum.ENABLED.getValue());
if (CollectionUtils.isNotEmpty(scoreRuleDOS)) {
List<AppScoreRuleListBackVO> appScoreRuleListBackVOS = new ArrayList<>();
for (ScoreRuleDO scoreRuleDO : scoreRuleDOS) {
// 校验平台入口
if (!Arrays.asList(scoreRuleDO.getShowPlatform().split(",")).contains(String.valueOf(reqVO.getPlatform()))) {
continue;
}
AppScoreRuleListBackVO appScoreRuleListBackVO = new AppScoreRuleListBackVO();
BeanUtils.copyProperties(scoreRuleDO, appScoreRuleListBackVO);
// 推荐和分享设置额外字段
if (scoreRuleDO.getType() == ScoreRuleTypeEnum.RECOMMEND.getValue()) {
ScoreRulerRecommendExtraVO scoreRulerRecommendExtraVO = JsonUtils.parseObject(scoreRuleDO.getExtra(), ScoreRulerRecommendExtraVO.class);
appScoreRuleListBackVO.setExtraRecommend(scoreRulerRecommendExtraVO);
} else if (scoreRuleDO.getType() == ScoreRuleTypeEnum.SHARE.getValue()) {
ScoreRuleShareExtraVO scoreRuleShareExtraVO = JsonUtils.parseObject(scoreRuleDO.getExtra(), ScoreRuleShareExtraVO.class);
appScoreRuleListBackVO.setExtraShare(scoreRuleShareExtraVO);
}
appScoreRuleListBackVOS.add(appScoreRuleListBackVO);
}
return appScoreRuleListBackVOS;
}
return null;
}
@Override
public AppScoreRuleBackDetailVO appGetScoreRule(Long id) {
ScoreRuleBackDetailVO scoreRule = getScoreRule(id);
AppScoreRuleBackDetailVO appScoreRuleBackDetailVO = new AppScoreRuleBackDetailVO();
BeanUtils.copyProperties(scoreRule, appScoreRuleBackDetailVO);
return appScoreRuleBackDetailVO;
}
}
......@@ -15,4 +15,5 @@ public interface RedeemRewardApi {
List<RedeemRewardRespDTO> redeemRewards(List<RedeemRewardReqVO> redeemRewardReqVOList);
RedeemDetailForUserDTO getRedeemDetailForUser(Long redeemId);
void sendSmsCode(Long memberId);
}
......@@ -13,19 +13,19 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@Data
@ApiModel("管理后台 - 礼品兑换 Request VO")
public class RedeemRewardReqVO {
@ApiModelProperty(value = "会员id")
@ApiModelProperty(value = "会员id", required = true)
private Long memberId;
@ApiModelProperty(value = "礼品id")
@ApiModelProperty(value = "礼品id", required = true)
private Long rewardId;
@ApiModelProperty(value = "兑换数量")
@ApiModelProperty(value = "兑换数量", required = true)
private Integer rewardCount;
@ApiModelProperty(value = "兑换方式,同领取方式(1上门领取,2包邮到家,3邮寄到付)")
@ApiModelProperty(value = "兑换方式,同领取方式(1上门领取,2包邮到家,3邮寄到付)", required = true)
private Integer redeemType;
@ApiModelProperty(value = "兑换入口(后台,app,web)")
@ApiModelProperty(value = "兑换入口(后台,app,web)", required = true)
private Integer entrance;
@ApiModelProperty(value = "费用数字(两位小数)")
......@@ -34,13 +34,13 @@ public class RedeemRewardReqVO {
@ApiModelProperty(value = "费用币种(字典配置)")
private Integer currency;
@ApiModelProperty(value = "收件人姓名")
@ApiModelProperty(value = "收件人姓名", required = true)
private String recipientName;
@ApiModelProperty(value = "收件人电话")
@ApiModelProperty(value = "收件人电话", required = true)
private String recipientPhoneNum;
@ApiModelProperty(value = "收件人地址")
@ApiModelProperty(value = "收件人地址", required = true)
private String recipientAddress;
@ApiModelProperty(value = "兑换人")
......@@ -68,5 +68,4 @@ public class RedeemRewardReqVO {
@ApiModelProperty(value = "备注")
private String remark;
}
......@@ -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.RedeemRewardReqVO;
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.reward.RewardDO;
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.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 lombok.extern.slf4j.Slf4j;
import org.redisson.api.RLock;
......@@ -33,6 +38,7 @@ import java.util.Map;
import java.util.concurrent.TimeUnit;
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.member.enums.ErrorCodeConstants.USER_NOT_EXISTS;
import static cn.iocoder.yudao.module.reward.enums.ErrorCodeConstants.*;
......@@ -54,10 +60,25 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
private MemberUserScoreApi memberUserScoreApi;
@Resource
private SnowflakeGenerator snowflakeGenerator;
@Resource
private SmsCodeApi smsCodeApi;
@Override
@Transactional(rollbackFor = Exception.class)
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());
if (rewardDO == null) {
......@@ -211,6 +232,21 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
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) {
// 查询会员积分
UserRespDTO memberUser = memberUserApi.getUser(redeemRewardReqVO.getMemberId());
......
package cn.iocoder.yudao.module.reward.controller.app.redeem;
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.dto.RedeemRewardReqVO;
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.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.controller.app.redeem.vo.*;
import cn.iocoder.yudao.module.reward.service.redeem.RewardRedeemService;
import cn.iocoder.yudao.module.reward.vo.reward.RewardRedeemPageRespVO;
import io.swagger.annotations.Api;
......@@ -58,8 +56,17 @@ public class AppRedeemRewardController {
@PostMapping("/single")
@ApiOperation("兑换礼品")
@Idempotent(timeout = 5)
//@PreAuthenticated
public CommonResult<RedeemRewardRespDTO> redeemReward(@Valid @RequestBody RedeemRewardReqVO redeemRewardReqVO) {
public CommonResult<RedeemRewardRespDTO> redeemReward(@Valid @RequestBody AppRedeemRewardReqVO 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);
}
}
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;
}
......@@ -7,7 +7,7 @@ import lombok.Data;
import javax.validation.constraints.NotNull;
@Data
@ApiModel("客户端 - 礼品兑换记录列表 req VO")
@ApiModel("客户端 - 礼品兑换 req VO")
public class AppRewardRedeemReqVO {
@ApiModelProperty(value = "会员id")
@NotNull(message = "会员id不能为空")
......
......@@ -28,6 +28,8 @@ public enum SmsSceneEnum implements IntArrayValuable {
NOTIFICATION_SUCCESS_CANCEL_DELIVERY(7, "notification-successful-cancel-delivery", "订单 - 取消放货通知"),
NOTIFICATION_SUCCESS_SEASONING_CONDIMENTS(8, "notification-successful-seasoning-condiments", "订单 - 调货通知"),
MEMBER_REDEEM_REWARD(9, "user-sms-redeem-reward", "会员用户 - 兑换礼品"),
SHIPMENT_ARRIVALS(20, "shipment-arrivals", "出货 - 到港通知(多订单)"),
SHIPMENT_CUSTOMS_CLEARANCES(21, "shipment-customs-clearances", "出货 - 清关通知(多订单)"),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment