Commit 62f23b58 authored by zhangfeng's avatar zhangfeng

积分规则列表返回字段优化

parent 3ba25141
...@@ -21,6 +21,7 @@ import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleOrderVExtraVO; ...@@ -21,6 +21,7 @@ import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleOrderVExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleRegisterExtraVO; import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleRegisterExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleShareExtraVO; 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.member.vo.scoreRule.extra.ScoreRulerRecommendExtraVO;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import org.apache.commons.collections4.ListUtils; 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;
...@@ -50,6 +51,8 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score ...@@ -50,6 +51,8 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
private ScoreRuleRedisDao scoreRuleRedisDao; private ScoreRuleRedisDao scoreRuleRedisDao;
@Resource @Resource
private WarehouseService warehouseService; private WarehouseService warehouseService;
@Resource
private AdminUserApi adminUserApi;
@Override @Override
public Long createScoreRule(ScoreRuleCreateReqVO createReqVO) { public Long createScoreRule(ScoreRuleCreateReqVO createReqVO) {
...@@ -208,7 +211,7 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score ...@@ -208,7 +211,7 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
} }
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, "scoreRuleType error");
} }
} }
...@@ -219,7 +222,7 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score ...@@ -219,7 +222,7 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
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, "ordervrule does not conform to the rules");
} }
low = orderVRule.getHigh(); low = orderVRule.getHigh();
} }
...@@ -266,6 +269,12 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score ...@@ -266,6 +269,12 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
@Override @Override
public PageResult<ScoreRuleBackVO> getScoreRulePage(ScoreRuleQueryVO query, PageVO page) { public PageResult<ScoreRuleBackVO> getScoreRulePage(ScoreRuleQueryVO query, PageVO page) {
PageResult<ScoreRuleDO> pageResult = scoreRuleMapper.selectPage(page, query); PageResult<ScoreRuleDO> pageResult = scoreRuleMapper.selectPage(page, query);
pageResult.getList().forEach(scoreRuleDO -> {
String creator = adminUserApi.getUserName(scoreRuleDO.getCreator());
scoreRuleDO.setCreator(creator);
String updater = adminUserApi.getUserName(scoreRuleDO.getUpdater());
scoreRuleDO.setUpdater(updater);
});
return ScoreRuleConvert.INSTANCE.convertPage(pageResult); return ScoreRuleConvert.INSTANCE.convertPage(pageResult);
} }
...@@ -331,12 +340,12 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score ...@@ -331,12 +340,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, "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, "status not allow");
} }
scoreRuleMapper.updateById(upScoreRuleDO); scoreRuleMapper.updateById(upScoreRuleDO);
scoreRuleRedisDao.deleteEnableScoreRule(scoreRuleDO.getType()); scoreRuleRedisDao.deleteEnableScoreRule(scoreRuleDO.getType());
...@@ -364,12 +373,12 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score ...@@ -364,12 +373,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, "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, "end time must after now and start time");
} }
ScoreRuleDO upScoreRuleDO = new ScoreRuleDO(); ScoreRuleDO upScoreRuleDO = new ScoreRuleDO();
upScoreRuleDO.setId(delayReqVO.getId()); upScoreRuleDO.setId(delayReqVO.getId());
...@@ -380,7 +389,7 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score ...@@ -380,7 +389,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, "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())
......
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