Commit 12f7c412 authored by zhangfeng's avatar zhangfeng

异常类优化,双语配置

parent 7fd2097c
...@@ -53,10 +53,10 @@ public interface ErrorCodeConstants { ...@@ -53,10 +53,10 @@ public interface ErrorCodeConstants {
ErrorCode SCORE_OPERATE_IDEMPOTENT_ERROR = new ErrorCode(1004008009, "score.operate.idempotent.error"); ErrorCode SCORE_OPERATE_IDEMPOTENT_ERROR = new ErrorCode(1004008009, "score.operate.idempotent.error");
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_FIELD_ERROR = new ErrorCode(1004008013, "score.rule.field.error");
ErrorCode USER_ADDRESS_NOT_EXISTS = new ErrorCode(1004008014, "user.address.not.exists"); ErrorCode USER_ADDRESS_NOT_EXISTS = new ErrorCode(1004008014, "user.address.not.exists");
ErrorCode USER_ADDRESS_FIELD_ERROR = new ErrorCode(1004008015, "user.address.field.error:{}"); ErrorCode USER_ADDRESS_FIELD_ERROR = new ErrorCode(1004008015, "user.address.field.error");
} }
...@@ -26,6 +26,7 @@ import org.apache.commons.collections4.ListUtils; ...@@ -26,6 +26,7 @@ import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
...@@ -44,6 +45,7 @@ import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*; ...@@ -44,6 +45,7 @@ import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*;
@Service @Service
@Validated @Validated
public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, ScoreRuleDO> implements ScoreRuleService { public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, ScoreRuleDO> implements ScoreRuleService {
public static final Locale LOCALE = LocaleContextHolder.getLocale();
@Resource @Resource
private ScoreRuleMapper scoreRuleMapper; private ScoreRuleMapper scoreRuleMapper;
...@@ -58,7 +60,7 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score ...@@ -58,7 +60,7 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
public Long createScoreRule(ScoreRuleCreateReqVO createReqVO) { public Long createScoreRule(ScoreRuleCreateReqVO createReqVO) {
ScoreRuleDO scoreRule = ScoreRuleConvert.INSTANCE.convert(createReqVO); ScoreRuleDO scoreRule = ScoreRuleConvert.INSTANCE.convert(createReqVO);
if (scoreRule.getStatus() != ScoreRuleStatusEnum.DISABLED.getValue() && scoreRule.getStatus() != ScoreRuleStatusEnum.ENABLED.getValue()) { if (scoreRule.getStatus() != ScoreRuleStatusEnum.DISABLED.getValue() && scoreRule.getStatus() != ScoreRuleStatusEnum.ENABLED.getValue()) {
throw exception(SCORE_RULE_FIELD_ERROR, "status must be 1 or 2"); throw exception(SCORE_RULE_FIELD_ERROR, LOCALE == Locale.SIMPLIFIED_CHINESE ? "新增规则状态必须是启用或未启用" : "status must be 1 or 2");
} }
verifyCommon(createReqVO); verifyCommon(createReqVO);
Integer scoreRuleType = scoreRule.getType(); Integer scoreRuleType = scoreRule.getType();
...@@ -72,16 +74,16 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score ...@@ -72,16 +74,16 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
private void verifyCommon(ScoreRuleBaseVO scoreRuleIn) { private void verifyCommon(ScoreRuleBaseVO scoreRuleIn) {
//校验公共入参 //校验公共入参
if (scoreRuleIn.getType() != ScoreRuleTypeEnum.ORDER_V.getValue() && scoreRuleIn.getGetScoreOnce() <= 0) { if (scoreRuleIn.getType() != ScoreRuleTypeEnum.ORDER_V.getValue() && scoreRuleIn.getGetScoreOnce() <= 0) {
throw exception(SCORE_RULE_FIELD_ERROR, "getScoreOnce must > 0"); throw exception(SCORE_RULE_FIELD_ERROR, LOCALE == Locale.SIMPLIFIED_CHINESE ? "单次获得积分必须大于0" : "getScoreOnce must > 0");
} }
if (scoreRuleIn.getType() != ScoreRuleTypeEnum.RECOMMEND.getValue() && scoreRuleIn.getMaxScoreTotal() <= 0) { if (scoreRuleIn.getType() != ScoreRuleTypeEnum.RECOMMEND.getValue() && scoreRuleIn.getMaxScoreTotal() <= 0) {
throw exception(SCORE_RULE_FIELD_ERROR, "maxScoreTotal must > 0"); throw exception(SCORE_RULE_FIELD_ERROR, LOCALE == Locale.SIMPLIFIED_CHINESE ? "累积最高积分必须大于0" : "maxScoreTotal must > 0");
} }
if (scoreRuleIn.getStartTime().after((scoreRuleIn.getEndTime())) || scoreRuleIn.getEndTime().before(Date.from(Instant.now()))) { if (scoreRuleIn.getStartTime().after((scoreRuleIn.getEndTime())) || scoreRuleIn.getEndTime().before(Date.from(Instant.now()))) {
throw exception(SCORE_RULE_FIELD_ERROR, "startTime must before endTime and endTime must after now"); throw exception(SCORE_RULE_FIELD_ERROR, LOCALE == Locale.SIMPLIFIED_CHINESE ? "开始时间需早于结束时间,结束时间需比当前时间晚" : "startTime must before endTime and endTime must after now");
} }
if (scoreRuleIn.getScorePeriod() <= 0) { if (scoreRuleIn.getScorePeriod() <= 0) {
throw exception(SCORE_RULE_FIELD_ERROR, "scorePeriod must > 0"); throw exception(SCORE_RULE_FIELD_ERROR, LOCALE == Locale.SIMPLIFIED_CHINESE ? "积分过期时间必须大于0" : "scorePeriod must > 0");
} }
//如果是启用,校验同一个规则下,有效期内有没有重复的规则设置,分享不校验。海运空运分开算 //如果是启用,校验同一个规则下,有效期内有没有重复的规则设置,分享不校验。海运空运分开算
if (scoreRuleIn.getStatus() == ScoreRuleStatusEnum.ENABLED.getValue() && scoreRuleIn.getType() != ScoreRuleTypeEnum.SHARE.getValue()) { if (scoreRuleIn.getStatus() == ScoreRuleStatusEnum.ENABLED.getValue() && scoreRuleIn.getType() != ScoreRuleTypeEnum.SHARE.getValue()) {
...@@ -91,25 +93,25 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score ...@@ -91,25 +93,25 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
if (scoreRuleIn.getType() == ScoreRuleTypeEnum.ORDER_V.getValue()) { if (scoreRuleIn.getType() == ScoreRuleTypeEnum.ORDER_V.getValue()) {
ScoreRuleOrderVExtraVO extraOrderV = scoreRuleIn.getExtraOrderV(); ScoreRuleOrderVExtraVO extraOrderV = scoreRuleIn.getExtraOrderV();
if (extraOrderV == null) { if (extraOrderV == null) {
throw exception(SCORE_RULE_FIELD_ERROR, "extraOrderV must not null"); throw exception(SCORE_RULE_FIELD_ERROR, LOCALE == Locale.SIMPLIFIED_CHINESE ? "订单V值额外参数必填" : "extraOrderV must not null");
} }
Integer transportType = extraOrderV.getTransportType(); Integer transportType = extraOrderV.getTransportType();
if (transportType != TransportTypeEnum.OCEAN_LCL.getValue() && transportType != TransportTypeEnum.SPECIAL_LINE_AIR_FREIGHT.getValue()) { if (transportType != TransportTypeEnum.OCEAN_LCL.getValue() && transportType != TransportTypeEnum.SPECIAL_LINE_AIR_FREIGHT.getValue()) {
throw exception(SCORE_RULE_FIELD_ERROR, "transportType must 1 or 3"); throw exception(SCORE_RULE_FIELD_ERROR, LOCALE == Locale.SIMPLIFIED_CHINESE ? "运输方式只能填海运(1)或空运(3)" : "transportType must 1 or 3");
} }
List<ScoreRuleDO> scoreRuleDOS = scoreRuleMapper.selectList(scoreRuleDOLambdaQuery); List<ScoreRuleDO> scoreRuleDOS = scoreRuleMapper.selectList(scoreRuleDOLambdaQuery);
if (scoreRuleDOS != null && !scoreRuleDOS.isEmpty()) { if (scoreRuleDOS != null && !scoreRuleDOS.isEmpty()) {
for (ScoreRuleDO scoreRuleDO : scoreRuleDOS) { for (ScoreRuleDO scoreRuleDO : scoreRuleDOS) {
ScoreRuleOrderVExtraVO bean = JSONUtil.toBean(scoreRuleDO.getExtra(), ScoreRuleOrderVExtraVO.class); ScoreRuleOrderVExtraVO bean = JSONUtil.toBean(scoreRuleDO.getExtra(), ScoreRuleOrderVExtraVO.class);
if (Objects.equals(bean.getTransportType(), transportType)) { if (Objects.equals(bean.getTransportType(), transportType)) {
throw exception(SCORE_RULE_FIELD_ERROR, "such rule is already enabled"); throw exception(SCORE_RULE_FIELD_ERROR, LOCALE == Locale.SIMPLIFIED_CHINESE ? "规则唯一校验:已存在此类规则启用" : "such rule is already enabled");
} }
} }
} }
} else { } else {
Long count = scoreRuleMapper.selectCount(scoreRuleDOLambdaQuery); Long count = scoreRuleMapper.selectCount(scoreRuleDOLambdaQuery);
if (count > 0) { if (count > 0) {
throw exception(SCORE_RULE_FIELD_ERROR, "such rule is already enabled"); throw exception(SCORE_RULE_FIELD_ERROR, LOCALE == Locale.SIMPLIFIED_CHINESE ? "规则唯一校验:已存在此类规则启用" : "such rule is already enabled");
} }
} }
} }
...@@ -123,7 +125,7 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score ...@@ -123,7 +125,7 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
throw exception(SCORE_RULE_NOT_EXISTS); throw exception(SCORE_RULE_NOT_EXISTS);
} }
if (scoreRuleDO.getStatus() != ScoreRuleStatusEnum.DISABLED.getValue()) { if (scoreRuleDO.getStatus() != ScoreRuleStatusEnum.DISABLED.getValue()) {
throw exception(SCORE_RULE_UPDATE_ERROR, "only disabled rule can update"); throw exception(SCORE_RULE_UPDATE_ERROR, LOCALE == Locale.SIMPLIFIED_CHINESE ? "只有未启用规则可以更新" : "only disabled rule can update");
} }
ScoreRuleDO scoreRule = ScoreRuleConvert.INSTANCE.convert(updateReqVO); ScoreRuleDO scoreRule = ScoreRuleConvert.INSTANCE.convert(updateReqVO);
verifyCommon(updateReqVO); verifyCommon(updateReqVO);
...@@ -144,18 +146,18 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score ...@@ -144,18 +146,18 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
if (scoreRuleType == ScoreRuleTypeEnum.ORDER_V.getValue()) { if (scoreRuleType == ScoreRuleTypeEnum.ORDER_V.getValue()) {
ScoreRuleOrderVExtraVO extraOrderV = reqVO.getExtraOrderV(); ScoreRuleOrderVExtraVO extraOrderV = reqVO.getExtraOrderV();
if (extraOrderV == null) { if (extraOrderV == null) {
throw exception(SCORE_RULE_FIELD_ERROR, "extraOrderV must not null"); throw exception(SCORE_RULE_FIELD_ERROR, LOCALE == Locale.SIMPLIFIED_CHINESE ? "订单V值额外参数不能为空" : "extraOrderV must not null");
} }
if (extraOrderV.getFirstOrder() != YesOrNoTypeEnum.YES.ordinal() && extraOrderV.getFirstOrder() != YesOrNoTypeEnum.NO.ordinal()) { if (extraOrderV.getFirstOrder() != YesOrNoTypeEnum.YES.ordinal() && extraOrderV.getFirstOrder() != YesOrNoTypeEnum.NO.ordinal()) {
throw exception(SCORE_RULE_FIELD_ERROR, "firstOrder must 0 or 1"); throw exception(SCORE_RULE_FIELD_ERROR, LOCALE == Locale.SIMPLIFIED_CHINESE ? "是否首单必须为是(0)或否(1)" : "firstOrder must 0 or 1");
} }
if (extraOrderV.getTransportType() != TransportTypeEnum.OCEAN_LCL.getValue() && extraOrderV.getTransportType() != TransportTypeEnum.SPECIAL_LINE_AIR_FREIGHT.getValue()) { if (extraOrderV.getTransportType() != TransportTypeEnum.OCEAN_LCL.getValue() && extraOrderV.getTransportType() != TransportTypeEnum.SPECIAL_LINE_AIR_FREIGHT.getValue()) {
throw exception(SCORE_RULE_FIELD_ERROR, "transportType must 1 or 3"); throw exception(SCORE_RULE_FIELD_ERROR, LOCALE == Locale.SIMPLIFIED_CHINESE ? "运输方式只能填海运(1)或空运(3)" : "transportType must 1 or 3");
} }
// 国家,城市,仓库id从receiveAddrList中获取 // 国家,城市,仓库id从receiveAddrList中获取
List<List<Long>> receiveAddrList = extraOrderV.getReceiveAddrList(); List<List<Long>> receiveAddrList = extraOrderV.getReceiveAddrList();
if (receiveAddrList == null || extraOrderV.getReceiveAddrList().isEmpty()) { if (receiveAddrList == null || extraOrderV.getReceiveAddrList().isEmpty()) {
throw exception(SCORE_RULE_FIELD_ERROR, "receiveAddrList must not null"); throw exception(SCORE_RULE_FIELD_ERROR, LOCALE == Locale.SIMPLIFIED_CHINESE ? "国家,城市,提货点信息不能为空" : "receiveAddrList must not null");
} }
StringBuilder targetCountry = new StringBuilder(); StringBuilder targetCountry = new StringBuilder();
StringBuilder targetCity = new StringBuilder(); StringBuilder targetCity = new StringBuilder();
...@@ -166,7 +168,7 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score ...@@ -166,7 +168,7 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
targetCity.append(integers.get(1)).append(","); targetCity.append(integers.get(1)).append(",");
receiveAddr.append(integers.get(2)).append(","); receiveAddr.append(integers.get(2)).append(",");
} catch (Exception e) { } catch (Exception e) {
throw exception(SCORE_RULE_FIELD_ERROR, "receiveAddrList format error"); throw exception(SCORE_RULE_FIELD_ERROR, LOCALE == Locale.SIMPLIFIED_CHINESE ? "国家,城市,提货点参数列表不符合规则" : "receiveAddrList format error");
} }
} }
extraOrderV.setTargetCountry(targetCountry.toString()); extraOrderV.setTargetCountry(targetCountry.toString());
...@@ -174,55 +176,55 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score ...@@ -174,55 +176,55 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
extraOrderV.setReceiveAddr(receiveAddr.toString()); extraOrderV.setReceiveAddr(receiveAddr.toString());
extraOrderV.setReceiveAddrList(null); extraOrderV.setReceiveAddrList(null);
if (StringUtils.isBlank(extraOrderV.getOrderEntry())) { if (StringUtils.isBlank(extraOrderV.getOrderEntry())) {
throw exception(SCORE_RULE_FIELD_ERROR, "orderEntry must not null"); throw exception(SCORE_RULE_FIELD_ERROR, LOCALE == Locale.SIMPLIFIED_CHINESE ? "订单入口不能为空" : "orderEntry must not null");
} }
verifyOrderVRule(extraOrderV.getOrderVRule()); verifyOrderVRule(extraOrderV.getOrderVRule());
scoreRule.setExtra(JSONUtil.toJsonStr(extraOrderV)); scoreRule.setExtra(JSONUtil.toJsonStr(extraOrderV));
} else if (scoreRuleType == ScoreRuleTypeEnum.REGISTER.getValue()) { } else if (scoreRuleType == ScoreRuleTypeEnum.REGISTER.getValue()) {
if (reqVO.getExtraRegister() == null) { if (reqVO.getExtraRegister() == null) {
throw exception(SCORE_RULE_FIELD_ERROR, "extraRegister must not null"); throw exception(SCORE_RULE_FIELD_ERROR, LOCALE == Locale.SIMPLIFIED_CHINESE ? "注册规则额外参数不能为空" : "extraRegister must not null");
} }
if (StringUtils.isBlank(reqVO.getExtraRegister().getRegisterPlatform())) { if (StringUtils.isBlank(reqVO.getExtraRegister().getRegisterPlatform())) {
throw exception(SCORE_RULE_FIELD_ERROR, "registerPlatform must not null"); throw exception(SCORE_RULE_FIELD_ERROR, LOCALE == Locale.SIMPLIFIED_CHINESE ? "注册平台不能为空" : "registerPlatform must not null");
} }
scoreRule.setExtra(JSONUtil.toJsonStr(reqVO.getExtraRegister())); scoreRule.setExtra(JSONUtil.toJsonStr(reqVO.getExtraRegister()));
} else if (scoreRuleType == ScoreRuleTypeEnum.RECOMMEND.getValue()) { } else if (scoreRuleType == ScoreRuleTypeEnum.RECOMMEND.getValue()) {
ScoreRulerRecommendExtraVO extraRecommend = reqVO.getExtraRecommend(); ScoreRulerRecommendExtraVO extraRecommend = reqVO.getExtraRecommend();
if (extraRecommend == null) { if (extraRecommend == null) {
throw exception(SCORE_RULE_FIELD_ERROR, "extraRecommend must not null"); throw exception(SCORE_RULE_FIELD_ERROR, LOCALE == Locale.SIMPLIFIED_CHINESE ? "推荐规则额外参数不能为空" : "extraRecommend must not null");
} }
if (extraRecommend.getShareStatus() != YesOrNoTypeEnum.YES.ordinal() && extraRecommend.getShareStatus() != YesOrNoTypeEnum.NO.ordinal()) { if (extraRecommend.getShareStatus() != YesOrNoTypeEnum.YES.ordinal() && extraRecommend.getShareStatus() != YesOrNoTypeEnum.NO.ordinal()) {
throw exception(SCORE_RULE_FIELD_ERROR, "shareStatus must 0 or 1"); throw exception(SCORE_RULE_FIELD_ERROR, LOCALE == Locale.SIMPLIFIED_CHINESE ? "是否分享为是(0)或否(1)" : "shareStatus must 0 or 1");
} }
if (StringUtils.isAnyBlank(extraRecommend.getShareContentEn(), extraRecommend.getShareContentZh())) { if (StringUtils.isAnyBlank(extraRecommend.getShareContentEn(), extraRecommend.getShareContentZh())) {
throw exception(SCORE_RULE_FIELD_ERROR, "shareContentEn and shareContentZh must not null"); throw exception(SCORE_RULE_FIELD_ERROR, LOCALE == Locale.SIMPLIFIED_CHINESE ? "分享文案不能为空" : "shareContentEn and shareContentZh must not null");
} }
scoreRule.setExtra(JSONUtil.toJsonStr(extraRecommend)); scoreRule.setExtra(JSONUtil.toJsonStr(extraRecommend));
} else if (scoreRuleType == ScoreRuleTypeEnum.SHARE.getValue()) { } else if (scoreRuleType == ScoreRuleTypeEnum.SHARE.getValue()) {
ScoreRuleShareExtraVO extraShare = reqVO.getExtraShare(); ScoreRuleShareExtraVO extraShare = reqVO.getExtraShare();
if (extraShare == null) { if (extraShare == null) {
throw exception(SCORE_RULE_FIELD_ERROR, "extraShare must not null"); throw exception(SCORE_RULE_FIELD_ERROR, LOCALE == Locale.SIMPLIFIED_CHINESE ? "分享规则额外参数不能为空" : "extraShare must not null");
} }
if (StringUtils.isAnyBlank(extraShare.getActivityDescZh(), extraShare.getActivityDescEn(), extraShare.getActivityUrl())) { if (StringUtils.isAnyBlank(extraShare.getActivityDescZh(), extraShare.getActivityDescEn(), extraShare.getActivityUrl())) {
throw exception(SCORE_RULE_FIELD_ERROR, "activityDescZh,activityDescEn,activityUrl must not null"); throw exception(SCORE_RULE_FIELD_ERROR, LOCALE == Locale.SIMPLIFIED_CHINESE ? "活动详情,活动链接不能为空" : "activityDescZh,activityDescEn,activityUrl must not null");
} }
if (extraShare.getShareStatus() != YesOrNoTypeEnum.YES.ordinal() && extraShare.getShareStatus() != YesOrNoTypeEnum.NO.ordinal()) { if (extraShare.getShareStatus() != YesOrNoTypeEnum.YES.ordinal() && extraShare.getShareStatus() != YesOrNoTypeEnum.NO.ordinal()) {
throw exception(SCORE_RULE_FIELD_ERROR, "shareStatus must 0 or 1"); throw exception(SCORE_RULE_FIELD_ERROR, LOCALE == Locale.SIMPLIFIED_CHINESE ? "是否分享为是(0)或否(1)" : "shareStatus must 0 or 1");
} }
scoreRule.setExtra(JSONUtil.toJsonStr(extraShare)); scoreRule.setExtra(JSONUtil.toJsonStr(extraShare));
} else { } else {
throw exception(SCORE_RULE_NOT_EXISTS, "scoreRuleType error"); throw exception(SCORE_RULE_NOT_EXISTS, LOCALE == Locale.SIMPLIFIED_CHINESE ? "规则类型错误" : "scoreRuleType error");
} }
} }
private void verifyOrderVRule(List<ScoreRuleOrderVExtraVO.OrderVRule> extraOrderVRule) { private void verifyOrderVRule(List<ScoreRuleOrderVExtraVO.OrderVRule> extraOrderVRule) {
if (extraOrderVRule == null || extraOrderVRule.isEmpty()) { if (extraOrderVRule == null || extraOrderVRule.isEmpty()) {
throw exception(SCORE_RULE_FIELD_ERROR, "orderVRule must not null"); throw exception(SCORE_RULE_FIELD_ERROR, LOCALE == Locale.SIMPLIFIED_CHINESE ? "订单V值积分规则不能为空" : "orderVRule must not null");
} }
int low = 0; int low = 0;
for (ScoreRuleOrderVExtraVO.OrderVRule orderVRule : extraOrderVRule) { for (ScoreRuleOrderVExtraVO.OrderVRule orderVRule : extraOrderVRule) {
if (orderVRule.getLow() < low || orderVRule.getHigh() <= orderVRule.getLow() || orderVRule.getScore() <= 0) { if (orderVRule.getLow() < low || orderVRule.getHigh() <= orderVRule.getLow() || orderVRule.getScore() <= 0) {
throw exception(SCORE_RULE_FIELD_ERROR, "ordervrule does not conform to the rules"); throw exception(SCORE_RULE_FIELD_ERROR, LOCALE == Locale.SIMPLIFIED_CHINESE ? "订单V值积分规则参数不符合规则" : "ordervrule does not conform to the rules");
} }
low = orderVRule.getHigh(); low = orderVRule.getHigh();
} }
...@@ -235,7 +237,7 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score ...@@ -235,7 +237,7 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
throw exception(SCORE_RULE_NOT_EXISTS); throw exception(SCORE_RULE_NOT_EXISTS);
} }
if (scoreRuleDO.getStatus() != ScoreRuleStatusEnum.DISABLED.getValue()) { if (scoreRuleDO.getStatus() != ScoreRuleStatusEnum.DISABLED.getValue()) {
throw exception(SCORE_RULE_DELETE_ERROR, "only disabled rule can update"); throw exception(SCORE_RULE_DELETE_ERROR, LOCALE == Locale.SIMPLIFIED_CHINESE ? "只有未启用可以删除" : "only disabled rule can update");
} }
// 删除 // 删除
scoreRuleMapper.deleteById(id); scoreRuleMapper.deleteById(id);
...@@ -340,12 +342,12 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score ...@@ -340,12 +342,12 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
.eq(ScoreRuleDO::getStatus, ScoreRuleStatusEnum.ENABLED.getValue()); .eq(ScoreRuleDO::getStatus, ScoreRuleStatusEnum.ENABLED.getValue());
Long count = scoreRuleMapper.selectCount(scoreRuleDOLambdaQuery); Long count = scoreRuleMapper.selectCount(scoreRuleDOLambdaQuery);
if (count > 0) { if (count > 0) {
throw exception(SCORE_RULE_FIELD_ERROR, "such rule is already enabled"); throw exception(SCORE_RULE_FIELD_ERROR, LOCALE == Locale.SIMPLIFIED_CHINESE ? "规则唯一校验:已存在此类规则启用" : "such rule is already enabled");
} }
} }
upScoreRuleDO.setStatus(scoreRuleStatusReqVO.getStatus()); upScoreRuleDO.setStatus(scoreRuleStatusReqVO.getStatus());
} else { } else {
throw exception(SCORE_RULE_UPDATE_ERROR, "status not allow"); throw exception(SCORE_RULE_UPDATE_ERROR, LOCALE == Locale.SIMPLIFIED_CHINESE ? "规则状态不允许改变" : "status not allow");
} }
scoreRuleMapper.updateById(upScoreRuleDO); scoreRuleMapper.updateById(upScoreRuleDO);
scoreRuleRedisDao.deleteEnableScoreRule(scoreRuleDO.getType()); scoreRuleRedisDao.deleteEnableScoreRule(scoreRuleDO.getType());
...@@ -373,12 +375,12 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score ...@@ -373,12 +375,12 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
throw exception(SCORE_RULE_NOT_EXISTS); throw exception(SCORE_RULE_NOT_EXISTS);
} }
if (scoreRuleDO.getStatus() != ScoreRuleStatusEnum.ENABLED.getValue()) { if (scoreRuleDO.getStatus() != ScoreRuleStatusEnum.ENABLED.getValue()) {
throw exception(SCORE_RULE_UPDATE_ERROR, "only enabled rule can delay"); throw exception(SCORE_RULE_UPDATE_ERROR, LOCALE == Locale.SIMPLIFIED_CHINESE ? "只有启用规则可以延期" : "only enabled rule can delay");
} }
Instant now = Instant.now(); Instant now = Instant.now();
//结束时间不能小于当前时间 //结束时间不能小于当前时间
if (!delayReqVO.getEndTime().toInstant().isAfter(now) || !delayReqVO.getEndTime().toInstant().isAfter(scoreRuleDO.getStartTime().toInstant())) { if (!delayReqVO.getEndTime().toInstant().isAfter(now) || !delayReqVO.getEndTime().toInstant().isAfter(scoreRuleDO.getStartTime().toInstant())) {
throw exception(SCORE_RULE_UPDATE_ERROR, "end time must after now and start time"); throw exception(SCORE_RULE_UPDATE_ERROR, LOCALE == Locale.SIMPLIFIED_CHINESE ? "活动结束时间不能早于当前时间" : "end time must after now and start time");
} }
ScoreRuleDO upScoreRuleDO = new ScoreRuleDO(); ScoreRuleDO upScoreRuleDO = new ScoreRuleDO();
upScoreRuleDO.setId(delayReqVO.getId()); upScoreRuleDO.setId(delayReqVO.getId());
...@@ -389,7 +391,7 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score ...@@ -389,7 +391,7 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
@Override @Override
public ScoreRuleDO getEnabledOrderVScoreRuleByTransportType(Integer transportType) { public ScoreRuleDO getEnabledOrderVScoreRuleByTransportType(Integer transportType) {
if (transportType != TransportTypeEnum.OCEAN_LCL.getValue() && transportType != TransportTypeEnum.SPECIAL_LINE_AIR_FREIGHT.getValue()) { if (transportType != TransportTypeEnum.OCEAN_LCL.getValue() && transportType != TransportTypeEnum.SPECIAL_LINE_AIR_FREIGHT.getValue()) {
throw exception(SCORE_RULE_FIELD_ERROR, "transportType must 1 or 3"); throw exception(SCORE_RULE_FIELD_ERROR, LOCALE == Locale.SIMPLIFIED_CHINESE ? "运输方式只能填海运(1)或空运(3)" : "transportType must 1 or 3");
} }
LambdaQuery<ScoreRuleDO> lambdaQuery = new LambdaQuery<>(); LambdaQuery<ScoreRuleDO> lambdaQuery = new LambdaQuery<>();
lambdaQuery.eq(ScoreRuleDO::getStatus, ScoreRuleStatusEnum.ENABLED.getValue()) lambdaQuery.eq(ScoreRuleDO::getStatus, ScoreRuleStatusEnum.ENABLED.getValue())
......
...@@ -17,10 +17,10 @@ public interface ErrorCodeConstants { ...@@ -17,10 +17,10 @@ public interface ErrorCodeConstants {
ErrorCode REWARD_STATUS_NOT_ALLOW_UPDATE = new ErrorCode(1001011010, "reward.status.not.allow.update"); ErrorCode REWARD_STATUS_NOT_ALLOW_UPDATE = new ErrorCode(1001011010, "reward.status.not.allow.update");
ErrorCode REWARD_STATUS_NOT_ALLOW_ENABLE = new ErrorCode(1001011011, "reward.status.not.allow.enable"); ErrorCode REWARD_STATUS_NOT_ALLOW_ENABLE = new ErrorCode(1001011011, "reward.status.not.allow.enable");
ErrorCode REWARD_NOT_ENABLE = new ErrorCode(1001011012, "reward.not.enable"); ErrorCode REWARD_NOT_ENABLE = new ErrorCode(1001011012, "reward.not.enable");
ErrorCode REWARD_SCORE_NOT_ENOUGH = new ErrorCode(1001011013, "reward.score.not.enough:{}"); ErrorCode REWARD_SCORE_NOT_ENOUGH = new ErrorCode(1001011013, "reward.score.not.enough");
ErrorCode REWARD_COUNT_NOT_ENOUGH = new ErrorCode(1001011014, "reward.count.not.enough"); ErrorCode REWARD_COUNT_NOT_ENOUGH = new ErrorCode(1001011014, "reward.count.not.enough");
ErrorCode REWARD_REDEEM_COUNT_NOT_ALLOW = new ErrorCode(1001011016, "reward.redeem.count.not.allow"); ErrorCode REWARD_REDEEM_COUNT_NOT_ALLOW = new ErrorCode(1001011016, "reward.redeem.count.not.allow");
ErrorCode REWARD_REDEEM_ALLOW_COUNT_ERROR = new ErrorCode(1001011017, "reward.redeem.allow.count.error:{}"); ErrorCode REWARD_REDEEM_ALLOW_COUNT_ERROR = new ErrorCode(1001011017, "reward.redeem.allow.count.error");
ErrorCode REWARD_REDEEM_NOT_EXIST = new ErrorCode(1001011018, "reward.redeem.not.exist"); ErrorCode REWARD_REDEEM_NOT_EXIST = new ErrorCode(1001011018, "reward.redeem.not.exist");
ErrorCode REWARD_REDEEM_STATUS_ERROR = new ErrorCode(1001011019, "reward.redeem.status.error"); ErrorCode REWARD_REDEEM_STATUS_ERROR = new ErrorCode(1001011019, "reward.redeem.status.error");
ErrorCode REWARD_REDEEM_VERIFY_NO_PARAM = new ErrorCode(1001011020, "reward.redeem.verify.no.param"); ErrorCode REWARD_REDEEM_VERIFY_NO_PARAM = new ErrorCode(1001011020, "reward.redeem.verify.no.param");
......
...@@ -1020,10 +1020,10 @@ reward.pick.method.not.allow = pick method not allow ...@@ -1020,10 +1020,10 @@ reward.pick.method.not.allow = pick method not allow
reward.status.not.allow.update = reward status not allow update reward.status.not.allow.update = reward status not allow update
reward.status.not.allow.enable = reward status not allow enable reward.status.not.allow.enable = reward status not allow enable
reward.not.enable = reward is not enable reward.not.enable = reward is not enable
reward.score.not.enough = user score not enough reward.score.not.enough = user score not enough:{}
reward.count.not.enough = reward count not enough reward.count.not.enough = reward count not enough
reward.redeem.count.not.allow = bulk redemption is limited to a maximum of 10 pieces at a time reward.redeem.count.not.allow = bulk redemption is limited to a maximum of 10 pieces at a time
reward.redeem.allow.count.error = the number of redemptions allowed by the individual has been exceeded reward.redeem.allow.count.error = the number of redemptions allowed by the individual has been exceeded:{}
redeem.import.max.count = allow maximum number of imports is {} redeem.import.max.count = allow maximum number of imports is {}
dict.unknown.error = Not in dict {0}: {1} dict.unknown.error = Not in dict {0}: {1}
...@@ -1036,9 +1036,9 @@ level.bound.range.conflict = score range exist conflict ...@@ -1036,9 +1036,9 @@ 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 = score rule update error:{}
score.rule.delete.error = score rule delete error score.rule.delete.error = score rule delete error:{}
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 \ No newline at end of file
...@@ -1018,10 +1018,10 @@ reward.pick.method.not.allow = \u793C\u54C1\u9886\u53D6\u65B9\u5F0F\u4E0D\u652F\ ...@@ -1018,10 +1018,10 @@ reward.pick.method.not.allow = \u793C\u54C1\u9886\u53D6\u65B9\u5F0F\u4E0D\u652F\
reward.status.not.allow.update = \u793C\u54C1\u72B6\u6001\u64CD\u4F5C\u4E0D\u7B26\u5408\u89C4\u5219 reward.status.not.allow.update = \u793C\u54C1\u72B6\u6001\u64CD\u4F5C\u4E0D\u7B26\u5408\u89C4\u5219
reward.status.not.allow.enable = \u793C\u54C1\u4E0D\u5141\u8BB8\u542F\u7528 reward.status.not.allow.enable = \u793C\u54C1\u4E0D\u5141\u8BB8\u542F\u7528
reward.not.enable = \u793C\u54C1\u672A\u542F\u7528 reward.not.enable = \u793C\u54C1\u672A\u542F\u7528
reward.score.not.enough = \u79EF\u5206\u4E0D\u8DB3 reward.score.not.enough = \u79EF\u5206\u4E0D\u8DB3\uFF1A{}
reward.count.not.enough = \u793C\u54C1\u6570\u91CF\u4E0D\u8DB3 reward.count.not.enough = \u793C\u54C1\u6570\u91CF\u4E0D\u8DB3
reward.redeem.count.not.allow = \u6279\u91CF\u5151\u6362\u6BCF\u6B21\u6700\u591A\u5341\u6761 reward.redeem.count.not.allow = \u6279\u91CF\u5151\u6362\u6BCF\u6B21\u6700\u591A\u5341\u6761
reward.redeem.allow.count.error = \u5DF2\u8D85\u51FA\u4E2A\u4EBA\u5141\u8BB8\u5151\u6362\u6B21\u6570 reward.redeem.allow.count.error = \u5DF2\u8D85\u51FA\u4E2A\u4EBA\u5141\u8BB8\u5151\u6362\u6B21\u6570\uFF1A{}
get.lock.failed = \u670D\u52A1\u7E41\u5FD9\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5 get.lock.failed = \u670D\u52A1\u7E41\u5FD9\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5
reward.redeem.not.exist = \u793C\u54C1\u5151\u6362\u8BB0\u5F55\u4E0D\u5B58\u5728 reward.redeem.not.exist = \u793C\u54C1\u5151\u6362\u8BB0\u5F55\u4E0D\u5B58\u5728
...@@ -1040,9 +1040,9 @@ level.bound.range.conflict = \u79EF\u5206\u8303\u56F4\u5B58\u5728\u51B2\u7A81 ...@@ -1040,9 +1040,9 @@ 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 score.rule.field.error = \u79EF\u5206\u89C4\u5219\u5B57\u6BB5\u9519\u8BEF\uFF1A{}
score.rule.update.error = \u79EF\u5206\u89C4\u5219\u66F4\u65B0\u5931\u8D25 score.rule.update.error = \u79EF\u5206\u89C4\u5219\u66F4\u65B0\u5931\u8D25\uFF1A{}
score.rule.delete.error = \u79EF\u5206\u89C4\u5219\u5220\u9664\u5931\u8D25 score.rule.delete.error = \u79EF\u5206\u89C4\u5219\u5220\u9664\u5931\u8D25\uFF1A{}
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 user.address.field.error = \u7528\u6237\u5730\u5740\u5B57\u6BB5\u9519\u8BEF\uFF1A{}
\ No newline at end of file \ 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