Просмотр исходного кода

[成长值扣减][修改]

release_toaliyun_real
Stormeye Wu 7 лет назад
Родитель
Сommit
d11aed4e04
2 измененных файлов: 42 добавлений и 7 удалений
  1. +37
    -6
      mallinkAdmin/src/main/java/com/iformall/controller/WxUserStructureController.java
  2. +5
    -1
      mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java

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

@@ -545,16 +545,47 @@ public class WxUserStructureController extends BaseController {
} }


// 成长值扣除 // 成长值扣除
@ApiOperation("用户成长值扣减")
@ApiOperation(value = "用户成长值扣减", notes = "{\"userId\":\"Long\", \"reason\":\"String\", \"score\":\"Integer\"}")
@PostMapping("/scoreReduce") @PostMapping("/scoreReduce")
@ApiImplicitParams({
@ApiImplicitParam(name = "reason", value = "扣减理由", dataType = "String", required = true),
@ApiImplicitParam(name = "score", value = "扣减分数", dataType = "int", required = true)})
public ResultData scoreReduce(@ModelAttribute WxCUserBasicInfo basicInfo, String reason, Integer score) {
public ResultData scoreReduce(@RequestBody Map<String, String> params) {
logger.debug("[" + getIpAddr() + "] WxUserStructureController::scoreReduce"); logger.debug("[" + getIpAddr() + "] WxUserStructureController::scoreReduce");


String userIdStr = params.get("userId");
String reason = params.get("reason");
String scoreStr = params.get("score");
if (StringUtils.isBlank(userIdStr)) {
logger.error("userId为空:" + userIdStr);
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "userId为空");
}
if (StringUtils.isBlank(reason)) {
logger.error("reason为空:" + reason);
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "reason为空");
}
if (StringUtils.isBlank(scoreStr)) {
logger.error("score为空:" + scoreStr);
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "score为空");
}

Long userId = null;
Integer score = null;

try {
userId = Long.valueOf(userIdStr);
score = Integer.valueOf(scoreStr);
} catch (Exception e) {
logger.error(e.getMessage());
}
if(userId == null || userId == 0) {
logger.error(ErrorCode.USER_IS_EMPTY.getMessage());
return new ResultData(ErrorCode.USER_IS_EMPTY);
}
if(score == null ) {
logger.error(ErrorCode.SYS_PARAMETER_NOT_NULL.getMessage());
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "score不能为空");
}

// 1. 检查用户积分 // 1. 检查用户积分
WxCUserBasicInfo info = wxCUserBasicInfoService.getById(basicInfo.getId());
WxCUserBasicInfo info = wxCUserBasicInfoService.getById(userId);
if(info == null) { if(info == null) {
logger.error(ErrorCode.USER_IS_EMPTY.getMessage()); logger.error(ErrorCode.USER_IS_EMPTY.getMessage());
return new ResultData(ErrorCode.USER_IS_EMPTY); return new ResultData(ErrorCode.USER_IS_EMPTY);


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

@@ -7,6 +7,7 @@ import com.iformall.domain.po.*;
import com.iformall.enums.EnumBusiness; import com.iformall.enums.EnumBusiness;
import com.iformall.enums.EnumScoreType; import com.iformall.enums.EnumScoreType;
import com.iformall.mapper.WxCUserBasicInfoMapper; import com.iformall.mapper.WxCUserBasicInfoMapper;
import com.iformall.mapper.WxCUserMapper;
import com.iformall.mapper.WxScoreHistoryMapper; import com.iformall.mapper.WxScoreHistoryMapper;
import com.iformall.mapper.WxScoreRulesMapper; import com.iformall.mapper.WxScoreRulesMapper;
import com.iformall.service.WxCUserService; import com.iformall.service.WxCUserService;
@@ -34,6 +35,8 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService {
@Autowired @Autowired
WxCUserBasicInfoMapper wxCUserBasicInfoMapper; WxCUserBasicInfoMapper wxCUserBasicInfoMapper;
@Autowired @Autowired
WxCUserMapper wxCUserMapper;
@Autowired
WxCUserService wxCUserService; WxCUserService wxCUserService;


@Autowired @Autowired
@@ -320,10 +323,11 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService {
// 2. 修改 c_user表积分 score // 2. 修改 c_user表积分 score
if (userInfo.getPhone() != null) { if (userInfo.getPhone() != null) {
WxCUser wxCUser = new WxCUser(); WxCUser wxCUser = new WxCUser();
wxCUser.setId(userInfo.getId());
wxCUser.setTenantId(userInfo.getTenantId()); wxCUser.setTenantId(userInfo.getTenantId());
wxCUser.setPhone(userInfo.getPhone()); wxCUser.setPhone(userInfo.getPhone());
wxCUser.setScore(score); wxCUser.setScore(score);
wxCUserService.saveOrUpdate(wxCUser);
wxCUserMapper.updateByPrimaryKeySelective(wxCUser);
} }


// 2. 记录历史 // 2. 记录历史


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