Commit 62f23b58 authored by zhangfeng's avatar zhangfeng

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

parent 3ba25141
......@@ -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.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.ListUtils;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
......@@ -50,6 +51,8 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
private ScoreRuleRedisDao scoreRuleRedisDao;
@Resource
private WarehouseService warehouseService;
@Resource
private AdminUserApi adminUserApi;
@Override
public Long createScoreRule(ScoreRuleCreateReqVO createReqVO) {
......@@ -208,7 +211,7 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
}
scoreRule.setExtra(JSONUtil.toJsonStr(extraShare));
} 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
int low = 0;
for (ScoreRuleOrderVExtraVO.OrderVRule orderVRule : extraOrderVRule) {
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();
}
......@@ -266,6 +269,12 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
@Override
public PageResult<ScoreRuleBackVO> getScoreRulePage(ScoreRuleQueryVO query, PageVO page) {
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);
}
......@@ -331,12 +340,12 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
.eq(ScoreRuleDO::getStatus, ScoreRuleStatusEnum.ENABLED.getValue());
Long count = scoreRuleMapper.selectCount(scoreRuleDOLambdaQuery);
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());
} else {
throw exception(SCORE_RULE_UPDATE_ERROR,"status not allow");
throw exception(SCORE_RULE_UPDATE_ERROR, "status not allow");
}
scoreRuleMapper.updateById(upScoreRuleDO);
scoreRuleRedisDao.deleteEnableScoreRule(scoreRuleDO.getType());
......@@ -364,12 +373,12 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
throw exception(SCORE_RULE_NOT_EXISTS);
}
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();
//结束时间不能小于当前时间
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();
upScoreRuleDO.setId(delayReqVO.getId());
......@@ -380,7 +389,7 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
@Override
public ScoreRuleDO getEnabledOrderVScoreRuleByTransportType(Integer transportType) {
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.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