xhxu 5 лет назад
Родитель
Сommit
7ed4e1fac3
5 измененных файлов: 68 добавлений и 6 удалений
  1. +37
    -5
      mallinkAdmin/src/main/java/com/iformall/controller/mem/WxScoreRulesController.java
  2. +2
    -1
      mallinkService/src/main/java/com/iformall/enums/EnumScoreRules.java
  3. +1
    -0
      mallinkService/src/main/java/com/iformall/service/WxScoreRulesService.java
  4. +26
    -0
      mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java
  5. +2
    -0
      mallinkService/src/main/java/com/iformall/utils/Constant.java

+ 37
- 5
mallinkAdmin/src/main/java/com/iformall/controller/mem/WxScoreRulesController.java Просмотреть файл

@@ -4,9 +4,13 @@ import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ErrorCode; import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData; import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController; import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxMall;
import com.iformall.domain.po.WxScoreRules; import com.iformall.domain.po.WxScoreRules;
import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.po.base.TenantEntity;
import com.iformall.enums.EnumCreditLockedStatus; import com.iformall.enums.EnumCreditLockedStatus;
import com.iformall.enums.EnumGroupSupport;
import com.iformall.enums.EnumScoreRules;
import com.iformall.service.WxMallService;
import com.iformall.service.WxScoreRulesService; import com.iformall.service.WxScoreRulesService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@@ -25,6 +29,9 @@ public class WxScoreRulesController extends BaseController {
@Autowired @Autowired
private WxScoreRulesService wxScoreRulesService; private WxScoreRulesService wxScoreRulesService;


@Autowired
private WxMallService wxMallService;

@ApiOperation("成长值配置") @ApiOperation("成长值配置")
@GetMapping("setting") @GetMapping("setting")
@SystemControllerLog(description = "成长值-配置") @SystemControllerLog(description = "成长值-配置")
@@ -42,11 +49,27 @@ public class WxScoreRulesController extends BaseController {
@SystemControllerLog(description = "成长值-积分-配置-新增") @SystemControllerLog(description = "成长值-积分-配置-新增")
public ResultData add(@RequestBody WxScoreRules wxScoreRules) { public ResultData add(@RequestBody WxScoreRules wxScoreRules) {
logger.debug("[" + getIpAddr() + "] WxScoreRulesController::add"); logger.debug("[" + getIpAddr() + "] WxScoreRulesController::add");
TenantEntity tenantEntity = ifParentUpdateTenantInfo();
if (StringUtils.isNotBlank(tenantEntity.getParentTenantId())) {
return new ResultData(ErrorCode.USER_NO_PERMISSION.getCode(), "广场用户无此权限");
if(wxScoreRules.getType() != null){
if(wxScoreRules.getType().equals(EnumScoreRules.SCORE.getCode()) || wxScoreRules.getType().equals(EnumScoreRules.CREDIT.getCode())){
TenantEntity tenantEntity = ifParentUpdateTenantInfo();
if (StringUtils.isNotBlank(tenantEntity.getParentTenantId())) {
return new ResultData(ErrorCode.USER_NO_PERMISSION.getCode(), "广场用户无此权限");
}
wxScoreRules.updateTenantInfo(tenantEntity);
}else if(wxScoreRules.getType().equals(EnumScoreRules.CREDIT_DOUBLE.getCode())){
TenantEntity tenantEntity = getTenantInfo();
WxMall mall = wxMallService.getByTenantId(getUser().getTenantId());
if((mall.getGroupSupport().equals(EnumGroupSupport.SUPPORT.getCode()) && StringUtils.isBlank(getUser().getParentTenantId())) ||
StringUtils.isBlank(tenantEntity.getTenantId())){
return new ResultData(ErrorCode.USER_NO_PERMISSION.getCode(), "集团用户无此权限");
}
wxScoreRules.updateTenantInfo(tenantEntity);
}else{
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"type");
}
}else{
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"type");
} }
wxScoreRules.updateTenantInfo(tenantEntity);
wxScoreRulesService.saveOrUpdate(wxScoreRules); wxScoreRulesService.saveOrUpdate(wxScoreRules);
return new ResultData(); return new ResultData();
} }
@@ -55,11 +78,20 @@ public class WxScoreRulesController extends BaseController {
@GetMapping("/credit_rules") @GetMapping("/credit_rules")
@SystemControllerLog(description = "积分-配置") @SystemControllerLog(description = "积分-配置")
public ResultData creditRulesList() { public ResultData creditRulesList() {
logger.debug("[" + getIpAddr() + "] WxScoreRulesController::list");
logger.debug("[" + getIpAddr() + "] creditRulesList::list");
WxScoreRules scoreRules = wxScoreRulesService.getCreditRules(getTenantInfo().getFinalTenantId()); WxScoreRules scoreRules = wxScoreRulesService.getCreditRules(getTenantInfo().getFinalTenantId());
return new ResultData(scoreRules); return new ResultData(scoreRules);
} }


@ApiOperation("积分倍率")
@GetMapping("/credit_double")
@SystemControllerLog(description = "积分-配置")
public ResultData creditDoubleRulesList() {
logger.debug("[" + getIpAddr() + "] creditDoubleRulesList::list");
WxScoreRules scoreRules = wxScoreRulesService.getCreditDoubleRules(getTenantInfo().getTenantId());
return new ResultData(scoreRules);
}

@ApiOperation("更新积分开关状态") @ApiOperation("更新积分开关状态")
@PostMapping("updateCreditLocked") @PostMapping("updateCreditLocked")
@SystemControllerLog(description = "更新积分开关状态") @SystemControllerLog(description = "更新积分开关状态")


+ 2
- 1
mallinkService/src/main/java/com/iformall/enums/EnumScoreRules.java Просмотреть файл

@@ -3,7 +3,8 @@ package com.iformall.enums;
public enum EnumScoreRules { public enum EnumScoreRules {


SCORE(1, "成长值"), SCORE(1, "成长值"),
CREDIT(2, "积分")
CREDIT(2, "积分"),
CREDIT_DOUBLE(4, "积分倍率")
; ;


public static EnumScoreRules getEnum(Integer code) { public static EnumScoreRules getEnum(Integer code) {


+ 1
- 0
mallinkService/src/main/java/com/iformall/service/WxScoreRulesService.java Просмотреть файл

@@ -62,4 +62,5 @@ public interface WxScoreRulesService {


void updateCreditLocked(WxScoreRules wxScoreRules); void updateCreditLocked(WxScoreRules wxScoreRules);


WxScoreRules getCreditDoubleRules(String tenantId);
} }

+ 26
- 0
mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java Просмотреть файл

@@ -679,6 +679,32 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService {
updateMerchantCreditLocked(wxScoreRules); updateMerchantCreditLocked(wxScoreRules);
} }


@Override
public WxScoreRules getCreditDoubleRules(String tenantId) {
String key = Constant.CREDIT_DOUBLE_RULES_KEY_PREV + tenantId;

// 缓存存在
if (scoreRulesRedisTemplate.hasKey(key)) {
WxScoreRules wScoreRules = scoreRulesRedisTemplate.opsForValue().get(key);
logger.info("WxScoreRulesServiceImpl.getScoreRules() : 从缓存中获取了积分倍率设置 >> " + wScoreRules.toString());
return wScoreRules;
}

WxScoreRules scoreRules = new WxScoreRules();
scoreRules.setTenantId(tenantId);
scoreRules.setType(EnumScoreRules.CREDIT_DOUBLE.getCode());
List<WxScoreRules> list = wxScoreRulesMapper.findList(scoreRules);
if (list.size() > 0) {
scoreRules = list.get(0);
// 插入缓存
scoreRulesRedisTemplate.opsForValue().set(key, scoreRules);
logger.info("WxScoreRulesServiceImpl.getScoreRules() : 积分设置插入缓存 >> " + scoreRules.toString());
} else{
return null;
}
return scoreRules;
}

public void updateMerchantCreditLocked(WxScoreRules wxScoreRules) { public void updateMerchantCreditLocked(WxScoreRules wxScoreRules) {
WxMerchant wxMerchant = new WxMerchant(); WxMerchant wxMerchant = new WxMerchant();
wxMerchant.updateTenantInfo(wxScoreRules); wxMerchant.updateTenantInfo(wxScoreRules);


+ 2
- 0
mallinkService/src/main/java/com/iformall/utils/Constant.java Просмотреть файл

@@ -65,6 +65,8 @@ public class Constant {
public static final String SCORE_RULES_KEY_PREV = "setting:scorerules:"; public static final String SCORE_RULES_KEY_PREV = "setting:scorerules:";
// 积分规则 key prev // 积分规则 key prev
public static final String CREDIT_RULES_KEY_PREV = "setting:creditrules:"; public static final String CREDIT_RULES_KEY_PREV = "setting:creditrules:";
// 倍率规则 key prev
public static final String CREDIT_DOUBLE_RULES_KEY_PREV = "setting:creditdoublerules:";


// 导入会员 // 导入会员
public static final String importMemPrev = "importmem:"; public static final String importMemPrev = "importmem:";


Загрузка…
Отмена
Сохранить