Commit 65bf4671 authored by zhangfeng's avatar zhangfeng

错误码配置

parent 7f8837a4
...@@ -55,8 +55,19 @@ public interface ErrorCodeConstants { ...@@ -55,8 +55,19 @@ public interface ErrorCodeConstants {
ErrorCode SCORE_RULE_NOT_EXISTS = new ErrorCode(1004008010, "score.rule.not.exists"); ErrorCode SCORE_RULE_NOT_EXISTS = new ErrorCode(1004008010, "score.rule.not.exists");
ErrorCode SCORE_RULE_DELETE_ERROR = new ErrorCode(1004008011, "score.rule.delete.error"); ErrorCode SCORE_RULE_DELETE_ERROR = new ErrorCode(1004008011, "score.rule.delete.error");
ErrorCode SCORE_RULE_UPDATE_ERROR = new ErrorCode(1004008012, "score.rule.update.error"); ErrorCode SCORE_RULE_UPDATE_ERROR = new ErrorCode(1004008012, "score.rule.update.error");
ErrorCode SCORE_RULE_FIELD_ERROR = new ErrorCode(1004008013, "score.rule.field.error"); ErrorCode SCORE_RULE_STATUS_ERROR = new ErrorCode(1004008014, "score.rule.status.error");
ErrorCode SCORE_RULE_STATUS_NOT_ENABLE = new ErrorCode(1004008015, "score.rule.status.not.enable");
ErrorCode USER_ADDRESS_NOT_EXISTS = new ErrorCode(1004008014, "user.address.not.exists"); ErrorCode SCORE_RULE_UNIQUE_CHECK_ERROR = new ErrorCode(1004008016, "score.rule.unique.check.error");
ErrorCode USER_ADDRESS_FIELD_ERROR = new ErrorCode(1004008015, "user.address.field.error"); ErrorCode SCORE_RULE_TRANSPORT_TYPE_ERROR = new ErrorCode(1004008017, "score.rule.transport.type.error");
ErrorCode SCORE_RULE_TIME_ERROR = new ErrorCode(1004008018, "score.rule.time.error");
ErrorCode SCORE_RULE_PERIOD_ERROR = new ErrorCode(1004008019, "score.rule.period.error");
ErrorCode ORDERV_SCORE_RULE_ERROR = new ErrorCode(1004008020, "orderv.score.rule.error");
ErrorCode SCORE_RULE_SHARE_STATUS_ERROR = new ErrorCode(1004008021, "score.rule.share.status.error");
ErrorCode SCORE_RULE_EXTRA_ERROR = new ErrorCode(1004008022, "score.rule.extra.error");
ErrorCode SCORE_RULE_RECEIVE_ADDRESS_ERROR = new ErrorCode(1004008023, "score.rule.receive.address.error");
ErrorCode SCORE_RULE_ORDERENTRY_ERROR = new ErrorCode(1004008024, "score.rule.orderentry.error");
ErrorCode SCORE_RULE_FIRST_ORDER_ERROR = new ErrorCode(1004008025, "score.rule.first.order.error");
ErrorCode USER_ADDRESS_NOT_EXISTS = new ErrorCode(1004008026, "user.address.not.exists");
ErrorCode USER_ADDRESS_FIELD_ERROR = new ErrorCode(1004008027, "user.address.field.error");
} }
...@@ -46,9 +46,11 @@ public class ScoreRuleBaseVO { ...@@ -46,9 +46,11 @@ public class ScoreRuleBaseVO {
private String coverImageEn; private String coverImageEn;
@ApiModelProperty(value = "单次获取积分数(订单V值不传)", required = true) @ApiModelProperty(value = "单次获取积分数(订单V值不传)", required = true)
@Min(value = 0,message = "单次获取积分数不能小于0")
private Integer getScoreOnce = 0; private Integer getScoreOnce = 0;
@ApiModelProperty(value = "累积最高积分(注册不传)", required = true) @ApiModelProperty(value = "累积最高积分(注册不传)", required = true)
@Min(value = 0,message = "累积最高积分不能小于0")
private Integer maxScoreTotal = 0; private Integer maxScoreTotal = 0;
@ApiModelProperty(value = "活动开始时间", required = true) @ApiModelProperty(value = "活动开始时间", required = true)
...@@ -63,6 +65,7 @@ public class ScoreRuleBaseVO { ...@@ -63,6 +65,7 @@ public class ScoreRuleBaseVO {
@ApiModelProperty(value = "积分有效期(天)", required = true) @ApiModelProperty(value = "积分有效期(天)", required = true)
@NotNull(message = "积分有效期不能为空") @NotNull(message = "积分有效期不能为空")
@Min(value = 0,message = "积分有效期不能小于0天")
private Integer scorePeriod; private Integer scorePeriod;
@ApiModelProperty(value = "排序值", required = true) @ApiModelProperty(value = "排序值", required = true)
......
...@@ -11,7 +11,7 @@ import java.util.List; ...@@ -11,7 +11,7 @@ import java.util.List;
*/ */
public interface RedeemRewardApi { public interface RedeemRewardApi {
RedeemRewardRespDTO redeemReward(RedeemRewardReqVO redeemRewardReqVO); Boolean redeemReward(RedeemRewardReqVO redeemRewardReqVO);
List<RedeemRewardRespDTO> redeemRewards(List<RedeemRewardReqVO> redeemRewardReqVOList); List<RedeemRewardRespDTO> redeemRewards(List<RedeemRewardReqVO> redeemRewardReqVOList);
RedeemDetailForUserDTO getRedeemDetailForUser(Long redeemId); RedeemDetailForUserDTO getRedeemDetailForUser(Long redeemId);
......
...@@ -18,6 +18,7 @@ import cn.iocoder.yudao.module.reward.dal.dataobject.reward.RewardDO; ...@@ -18,6 +18,7 @@ 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.reward.enums.RewardStatusEnum;
import cn.iocoder.yudao.module.system.api.sms.SmsCodeApi; 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.SmsCodeSendReqDTO;
import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeUseReqDTO; import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeUseReqDTO;
...@@ -65,7 +66,7 @@ public class RedeemRewardApiImpl implements RedeemRewardApi { ...@@ -65,7 +66,7 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public RedeemRewardRespDTO redeemReward(RedeemRewardReqVO redeemRewardReqVO) { 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; AppRedeemRewardReqVO appRedeemRewardReqVO = (AppRedeemRewardReqVO) redeemRewardReqVO;
SmsCodeUseReqDTO smsCodeUseReqDTO = new SmsCodeUseReqDTO(); SmsCodeUseReqDTO smsCodeUseReqDTO = new SmsCodeUseReqDTO();
...@@ -82,28 +83,28 @@ public class RedeemRewardApiImpl implements RedeemRewardApi { ...@@ -82,28 +83,28 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
// 查询礼品 // 查询礼品
RewardDO rewardDO = rewardMapper.selectById(redeemRewardReqVO.getRewardId()); RewardDO rewardDO = rewardMapper.selectById(redeemRewardReqVO.getRewardId());
if (rewardDO == null) { if (rewardDO == null) {
return getRedeemResp(false, "礼品不存在", "reward do not exist!"); throw exception(REWARD_NOT_EXISTS);
} }
// 礼品未开启 // 礼品未开启
if (rewardDO.getStatus() != 1) { if (rewardDO.getStatus() != 1) {
return getRedeemResp(false, "礼品未开启", "reward do not enable!"); throw exception(REWARD_NOT_ENABLE);
} }
// 礼品数量不够 // 礼品数量不够
if (rewardDO.getQuantityRemain() < redeemRewardReqVO.getRewardCount()) { if (rewardDO.getQuantityRemain() < redeemRewardReqVO.getRewardCount()) {
return getRedeemResp(false, "礼品数量不够", "reward do not enough!"); throw exception(REWARD_COUNT_NOT_ENOUGH);
} }
// 兑换方式不匹配 // 兑换方式不匹配
String pickMethod = rewardDO.getPickMethod(); String pickMethod = rewardDO.getPickMethod();
String[] split = pickMethod.split(","); String[] split = pickMethod.split(",");
if (!Arrays.asList(split).contains(String.valueOf(redeemRewardReqVO.getRedeemType()))) { if (!Arrays.asList(split).contains(String.valueOf(redeemRewardReqVO.getRedeemType()))) {
return getRedeemResp(false, "兑换方式不支持", "redeem type do not support!"); throw exception(REWARD_PICK_METHOD_NOT_ALLOW);
} }
verifyMemberUser(redeemRewardReqVO, rewardDO); verifyMemberUser(redeemRewardReqVO, rewardDO);
String lockKey = "reward:redeem:lock:" + redeemRewardReqVO.getRewardId(); String lockKey = "reward:redeem:lock:" + redeemRewardReqVO.getRewardId();
RLock lock = redissonClient.getLock(lockKey); RLock lock = redissonClient.getLock(lockKey);
try { try {
if (!lock.tryLock(2, 10, TimeUnit.SECONDS)) { if (!lock.tryLock(2, 10, TimeUnit.SECONDS)) {
return getRedeemResp(false, "系统繁忙,请稍后再试", "The service is busy, please try again later"); throw exception(GET_LOCK_FAILED);
} }
// 添加兑换记录 // 添加兑换记录
Long redeemId = addRedeemRecord(redeemRewardReqVO, rewardDO); Long redeemId = addRedeemRecord(redeemRewardReqVO, rewardDO);
...@@ -112,19 +113,11 @@ public class RedeemRewardApiImpl implements RedeemRewardApi { ...@@ -112,19 +113,11 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
// 更新礼品 // 更新礼品
redeemReward(rewardDO, redeemRewardReqVO.getRewardCount()); redeemReward(rewardDO, redeemRewardReqVO.getRewardCount());
} catch (InterruptedException e) { } catch (InterruptedException e) {
return getRedeemResp(false, "系统繁忙,请稍后再试", "The service is busy, please try again later"); throw exception(GET_LOCK_FAILED);
} finally { } finally {
lock.unlock(); lock.unlock();
} }
return getRedeemResp(true, "兑换成功!", "redeem success!"); return true;
}
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) { private void redeemReward(RewardDO reward, Integer rewardCount) {
...@@ -171,7 +164,7 @@ public class RedeemRewardApiImpl implements RedeemRewardApi { ...@@ -171,7 +164,7 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
// 查询礼品 // 查询礼品
RewardDO rewardDO = rewardMapper.selectById(rewardId); RewardDO rewardDO = rewardMapper.selectById(rewardId);
// 礼品未开启 // 礼品未开启
if (rewardDO.getStatus() != 1) { if (rewardDO.getStatus() != RewardStatusEnum.ENABLED.getValue()) {
throw exception(REWARD_NOT_ENABLE); throw exception(REWARD_NOT_ENABLE);
} }
int totalCount = 0; int totalCount = 0;
......
...@@ -125,7 +125,7 @@ public class RedeemRewardController { ...@@ -125,7 +125,7 @@ public class RedeemRewardController {
@PostMapping("/single") @PostMapping("/single")
@ApiOperation("兑换礼品") @ApiOperation("兑换礼品")
@PreAuthorize("@ss.hasPermission('ecw:giftManagement:exchange')") @PreAuthorize("@ss.hasPermission('ecw:giftManagement:exchange')")
public CommonResult<RedeemRewardRespDTO> redeemReward(@Valid @RequestBody RedeemRewardReqVO redeemRewardReqVO) { public CommonResult<Boolean> redeemReward(@Valid @RequestBody RedeemRewardReqVO redeemRewardReqVO) {
return success(redeemRewardApi.redeemReward(redeemRewardReqVO)); return success(redeemRewardApi.redeemReward(redeemRewardReqVO));
} }
......
...@@ -58,7 +58,7 @@ public class AppRedeemRewardController { ...@@ -58,7 +58,7 @@ public class AppRedeemRewardController {
@ApiOperation("兑换礼品") @ApiOperation("兑换礼品")
@Idempotent(timeout = 5) @Idempotent(timeout = 5)
//@PreAuthenticated //@PreAuthenticated
public CommonResult<RedeemRewardRespDTO> redeemReward(@Valid @RequestBody AppRedeemRewardReqVO redeemRewardReqVO) { public CommonResult<Boolean> redeemReward(@Valid @RequestBody AppRedeemRewardReqVO redeemRewardReqVO) {
return success(redeemRewardApi.redeemReward(redeemRewardReqVO)); return success(redeemRewardApi.redeemReward(redeemRewardReqVO));
} }
@PostMapping("/send-sms-code") @PostMapping("/send-sms-code")
......
...@@ -1036,9 +1036,21 @@ level.bound.range.conflict = score range exist conflict ...@@ -1036,9 +1036,21 @@ level.bound.range.conflict = score range exist conflict
score.operate.idempotent.error = idempotent key conflict score.operate.idempotent.error = idempotent key conflict
score.rule.not.exists = score rule not exists score.rule.not.exists = score rule not exists
score.rule.field.error = score rule field error:{} score.rule.field.error = score rule field error
score.rule.update.error = score rule update error:{} score.rule.update.error = only disabled rule can update
score.rule.delete.error = score rule delete error:{} 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.transport.type.error = transport type error
score.rule.time.error = score rule time error
score.rule.period.error = score rule period error
orderv.score.rule.error = order v score rule error
score.rule.share.status.error = score rule share status error
score.rule.extra.error = score rule extra error
score.rule.receive.address.error = score rule receive address error
score.rule.orderentry.error = order entry must not null
score.rule.first.order.error = firstOrder must 0 or 1
user.address.not.exists = user address not exists user.address.not.exists = user address not exists
user.address.field.error = user address field error:{} user.address.field.error = user address field error:{}
\ No newline at end of file
...@@ -1040,9 +1040,21 @@ level.bound.range.conflict = \u79EF\u5206\u8303\u56F4\u5B58\u5728\u51B2\u7A81 ...@@ -1040,9 +1040,21 @@ level.bound.range.conflict = \u79EF\u5206\u8303\u56F4\u5B58\u5728\u51B2\u7A81
score.operate.idempotent.error = \u5E42\u7B49key\u51B2\u7A81 score.operate.idempotent.error = \u5E42\u7B49key\u51B2\u7A81
score.rule.not.exists = \u79EF\u5206\u89C4\u5219\u4E0D\u5B58\u5728 score.rule.not.exists = \u79EF\u5206\u89C4\u5219\u4E0D\u5B58\u5728
score.rule.field.error = \u79EF\u5206\u89C4\u5219\u5B57\u6BB5\u9519\u8BEF\uFF1A{} score.rule.field.error = \u79EF\u5206\u89C4\u5219\u5B57\u6BB5\u9519\u8BEF
score.rule.update.error = \u79EF\u5206\u89C4\u5219\u66F4\u65B0\u5931\u8D25\uFF1A{} score.rule.update.error = \u53EA\u6709\u672A\u542F\u7528\u89C4\u5219\u53EF\u4EE5\u66F4\u65B0
score.rule.delete.error = \u79EF\u5206\u89C4\u5219\u5220\u9664\u5931\u8D25\uFF1A{} score.rule.delete.error = \u53EA\u6709\u672A\u542F\u7528\u53EF\u4EE5\u5220\u9664
score.rule.status.error = \u79EF\u5206\u89C4\u5219\u72B6\u6001\u9519\u8BEF
score.rule.status.not.enable = \u79EF\u5206\u89C4\u5219\u672A\u542F\u7528
score.rule.unique.check.error = \u79EF\u5206\u89C4\u5219\u552F\u4E00\u6027\u68C0\u67E5\u5931\u8D25
score.rule.transport.type.error = \u8FD0\u8F93\u7C7B\u578B\u9519\u8BEF
score.rule.time.error = \u6D3B\u52A8\u65F6\u95F4\u4E0D\u5408\u6CD5
score.rule.period.error = \u8FC7\u671F\u65F6\u95F4\u9519\u8BEF
orderv.score.rule.error = \u8BA2\u5355V\u503C\u79EF\u5206\u89C4\u5219\u9519\u8BEF
score.rule.share.status.error = \u5206\u4EAB\u72B6\u6001\u9519\u8BEF
score.rule.extra.error = \u79EF\u5206\u89C4\u5219\u989D\u5916\u5B57\u6BB5\u9519\u8BEF
score.rule.receive.address.error = \u8BA2\u5355V\u503C\u89C4\u5219\u63D0\u8D27\u70B9\u5217\u8868\u9519\u8BEF
score.rule.orderentry.error = \u8BA2\u5355\u5165\u53E3\u4E0D\u80FD\u4E3A\u7A7A
score.rule.first.order.error = \u662F\u5426\u9996\u5355\u5FC5\u987B\u4E3A\u662F\uFF080\uFF09\u6216\u5426\uFF081\uFF09
user.address.not.exists = \u7528\u6237\u5730\u5740\u4E0D\u5B58\u5728 user.address.not.exists = \u7528\u6237\u5730\u5740\u4E0D\u5B58\u5728
user.address.field.error = \u7528\u6237\u5730\u5740\u5B57\u6BB5\u9519\u8BEF\uFF1A{} user.address.field.error = \u7528\u6237\u5730\u5740\u5B57\u6BB5\u9519\u8BEF\uFF1A{}
\ No newline at end of file
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