Commit 7c07242b authored by zhangfeng's avatar zhangfeng

bugfix-476: 积分规则唯一性校验修改

parent 2360294e
......@@ -37,6 +37,7 @@ public class ScoreRuleRedisDao {
}
public ScoreRuleDO getEnableScoreRule(ScoreRuleTypeEnum type, TransportTypeEnum transportType) {
ScoreRuleDO useScoreRuleDO;
// 如果transportType不为空则是订单V值类型
if (transportType == null) {
String redisKey = formatKey(type.getValue(), null);
......@@ -44,15 +45,20 @@ public class ScoreRuleRedisDao {
if (scoreRuleJson == null) {
return null;
}
return JsonUtils.parseObject(scoreRuleJson, ScoreRuleDO.class);
useScoreRuleDO = JsonUtils.parseObject(scoreRuleJson, ScoreRuleDO.class);
} else {
String redisKey = formatKey(type.getValue(), transportType.getValue());
String scoreRuleJson = stringRedisTemplate.opsForValue().get(redisKey);
if (scoreRuleJson == null) {
return null;
}
return JsonUtils.parseObject(scoreRuleJson, ScoreRuleDO.class);
useScoreRuleDO = JsonUtils.parseObject(scoreRuleJson, ScoreRuleDO.class);
}
// 如果当前时间不在规则时间区间
if (System.currentTimeMillis() < useScoreRuleDO.getStartTime().getTime() || System.currentTimeMillis() > useScoreRuleDO.getEndTime().getTime()) {
return null;
}
return useScoreRuleDO;
}
public ScoreRuleDO getEnableScoreRule(ScoreRuleTypeEnum type) {
......@@ -72,7 +78,7 @@ public class ScoreRuleRedisDao {
scoreRuleDO.setDescZh(null);
if (scoreRuleDO.getType() == ScoreRuleTypeEnum.ORDER_V.getValue()) {
ScoreRuleOrderVExtraVO scoreRuleOrderVExtraVO = JsonUtils.parseObject(scoreRuleDO.getExtra(), ScoreRuleOrderVExtraVO.class);
stringRedisTemplate.opsForValue().set(formatKey(scoreRuleDO.getType(), scoreRuleOrderVExtraVO.getTransportType()), JsonUtils.toJsonString(scoreRuleDO));
stringRedisTemplate.opsForValue().set(formatKey(scoreRuleDO.getType(), scoreRuleOrderVExtraVO.getTransportType()), JsonUtils.toJsonString(scoreRuleDO), 24L, TimeUnit.HOURS);
}
stringRedisTemplate.opsForValue().set(formatKey(scoreRuleDO.getType(), null), JsonUtils.toJsonString(scoreRuleDO), 24L, TimeUnit.HOURS);
}
......
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