Commit 74b4d5ec authored by zhangfeng's avatar zhangfeng

Merge branch 'refs/heads/feature_member_score' into dev

parents ec4cc447 a682a25a
...@@ -145,4 +145,17 @@ public class ScoreRuleController { ...@@ -145,4 +145,17 @@ public class ScoreRuleController {
List<ScoreRuleBackVO> datas = ScoreRuleConvert.INSTANCE.convertList(list); List<ScoreRuleBackVO> datas = ScoreRuleConvert.INSTANCE.convertList(list);
ExcelUtils.write(response, "积分规则.xls", "数据", ScoreRuleBackVO.class, datas); ExcelUtils.write(response, "积分规则.xls", "数据", ScoreRuleBackVO.class, datas);
} }
@PostMapping("/switch/set")
@ApiOperation("设置会员工能开关")
@PreAuthorize("@ss.hasPermission('member:score-rule:update')")
public CommonResult<Boolean> setScoreRuleSwitch(@RequestBody SwitchReqVo switchReqVo) {
return success(scoreRuleService.setScoreRuleSwitch(switchReqVo));
}
@GetMapping("/switch/get")
@ApiOperation("获取会员功能开关")
public CommonResult<Boolean> getScoreRuleSwitch() {
return success(scoreRuleService.getScoreRuleSwitch());
}
} }
...@@ -5,4 +5,5 @@ package cn.iocoder.yudao.module.member.dal.redis; ...@@ -5,4 +5,5 @@ package cn.iocoder.yudao.module.member.dal.redis;
*/ */
public interface RedisKeyConstant { public interface RedisKeyConstant {
String MEMBER_USER_SCORE_RULE = "member:user:score:rule:"; String MEMBER_USER_SCORE_RULE = "member:user:score:rule:";
String MEMBER_USER_SCORE_RULE_SWITCH = "member:user:score:rule:switch";
} }
...@@ -12,6 +12,8 @@ import org.springframework.stereotype.Repository; ...@@ -12,6 +12,8 @@ import org.springframework.stereotype.Repository;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import static cn.iocoder.yudao.module.member.dal.redis.RedisKeyConstant.MEMBER_USER_SCORE_RULE_SWITCH;
/** /**
* 会员积分规则 Redis DAO * 会员积分规则 Redis DAO
*/ */
...@@ -20,6 +22,20 @@ public class ScoreRuleRedisDao { ...@@ -20,6 +22,20 @@ public class ScoreRuleRedisDao {
@Resource @Resource
private StringRedisTemplate stringRedisTemplate; private StringRedisTemplate stringRedisTemplate;
public Boolean setScoreRuleSwitch(Boolean switchStatus) {
stringRedisTemplate.opsForValue().set(MEMBER_USER_SCORE_RULE_SWITCH, switchStatus.toString());
return switchStatus;
}
public Boolean getScoreRuleSwitch() {
String string = stringRedisTemplate.opsForValue().get(MEMBER_USER_SCORE_RULE_SWITCH);
if (string == null) {
stringRedisTemplate.opsForValue().set(MEMBER_USER_SCORE_RULE_SWITCH, "false");
return false;
}
return Boolean.parseBoolean(string);
}
public ScoreRuleDO getEnableScoreRule(ScoreRuleTypeEnum type, TransportTypeEnum transportType) { public ScoreRuleDO getEnableScoreRule(ScoreRuleTypeEnum type, TransportTypeEnum transportType) {
// 如果transportType不为空则是订单V值类型 // 如果transportType不为空则是订单V值类型
if (transportType == null) { if (transportType == null) {
...@@ -58,7 +74,7 @@ public class ScoreRuleRedisDao { ...@@ -58,7 +74,7 @@ public class ScoreRuleRedisDao {
ScoreRuleOrderVExtraVO scoreRuleOrderVExtraVO = JsonUtils.parseObject(scoreRuleDO.getExtra(), ScoreRuleOrderVExtraVO.class); 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));
} }
stringRedisTemplate.opsForValue().set(formatKey(scoreRuleDO.getType(), null), JsonUtils.toJsonString(scoreRuleDO),24L, TimeUnit.HOURS); stringRedisTemplate.opsForValue().set(formatKey(scoreRuleDO.getType(), null), JsonUtils.toJsonString(scoreRuleDO), 24L, TimeUnit.HOURS);
} }
public void deleteEnableScoreRule(Integer type) { public void deleteEnableScoreRule(Integer type) {
......
...@@ -138,4 +138,17 @@ public interface ScoreRuleService extends IService<ScoreRuleDO> { ...@@ -138,4 +138,17 @@ public interface ScoreRuleService extends IService<ScoreRuleDO> {
* @return * @return
*/ */
AppScoreRuleBackDetailVO appGetScoreRule(Long id); AppScoreRuleBackDetailVO appGetScoreRule(Long id);
/**
* 获取会员功能开关状态
* @return
*/
Boolean getScoreRuleSwitch();
/**
* 设置会员功能开关
* @param switchReqVo
* @return
*/
Boolean setScoreRuleSwitch(SwitchReqVo switchReqVo);
} }
...@@ -533,4 +533,14 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score ...@@ -533,4 +533,14 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
appScoreRuleBackDetailVO.setTypeEn(DictFrameworkUtils.getDictDataFromCache("score_rule_type", type).getLabelEn()); appScoreRuleBackDetailVO.setTypeEn(DictFrameworkUtils.getDictDataFromCache("score_rule_type", type).getLabelEn());
return appScoreRuleBackDetailVO; return appScoreRuleBackDetailVO;
} }
@Override
public Boolean getScoreRuleSwitch() {
return scoreRuleRedisDao.getScoreRuleSwitch();
}
@Override
public Boolean setScoreRuleSwitch(SwitchReqVo switchReqVo) {
return scoreRuleRedisDao.setScoreRuleSwitch(switchReqVo.getSwitchState());
}
} }
package cn.iocoder.yudao.module.member.vo.scoreRule;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
@Data
@ApiModel("管理后台 - 会员功能开关状态 VO")
public class SwitchReqVo {
@ApiModelProperty(value = "开关状态", required = true)
private Boolean switchState;
}
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