diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/WxUserStructureController.java b/mallinkAdmin/src/main/java/com/iformall/controller/WxUserStructureController.java index 04c72d3e0..0d1e3771c 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/WxUserStructureController.java +++ b/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") - @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 params) { 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. 检查用户积分 - WxCUserBasicInfo info = wxCUserBasicInfoService.getById(basicInfo.getId()); + WxCUserBasicInfo info = wxCUserBasicInfoService.getById(userId); if(info == null) { logger.error(ErrorCode.USER_IS_EMPTY.getMessage()); return new ResultData(ErrorCode.USER_IS_EMPTY); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java index 8b9862bdb..7437da782 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java +++ b/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.EnumScoreType; import com.iformall.mapper.WxCUserBasicInfoMapper; +import com.iformall.mapper.WxCUserMapper; import com.iformall.mapper.WxScoreHistoryMapper; import com.iformall.mapper.WxScoreRulesMapper; import com.iformall.service.WxCUserService; @@ -34,6 +35,8 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { @Autowired WxCUserBasicInfoMapper wxCUserBasicInfoMapper; @Autowired + WxCUserMapper wxCUserMapper; + @Autowired WxCUserService wxCUserService; @Autowired @@ -320,10 +323,11 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { // 2. 修改 c_user表积分 score if (userInfo.getPhone() != null) { WxCUser wxCUser = new WxCUser(); + wxCUser.setId(userInfo.getId()); wxCUser.setTenantId(userInfo.getTenantId()); wxCUser.setPhone(userInfo.getPhone()); wxCUser.setScore(score); - wxCUserService.saveOrUpdate(wxCUser); + wxCUserMapper.updateByPrimaryKeySelective(wxCUser); } // 2. 记录历史