Commit ef2c8c1a authored by liming's avatar liming

积分查询接口

parent c7f82a46
......@@ -138,6 +138,36 @@ public class SportUserTrainingLogService {
achievementService.handleSportAchievement(gameMode, summary);
}
/**
* 计算积分
* @param gameMode
* @param calorie
* @param rank
* @return
*/
public Integer calcCurrency(Integer gameMode, Integer calorie , Integer rank){
if (calorie == null || calorie == 0) {
return 0;
}
List<SportUserGameCurrencyBaseRule> baseRule = sportUserGameCurrencyBaseRuleMapper.selectList(null);
if (baseRule.size() == 0 || baseRule.get(0).getCoefficient() == null) {
return 0;
}
Integer coefficient = baseRule.get(0).getCoefficient();
Integer currency = calorie / coefficient;
if (currency == 0) {
return 0;
}
if(rank !=null){
SportUserGameCurrencyMatchRule matchRule =
sportUserGameCurrencyMatchRuleMapper.selectOne(new QueryWrapper<SportUserGameCurrencyMatchRule>().lambda().eq(SportUserGameCurrencyMatchRule::getGameMode, gameMode).le(SportUserGameCurrencyMatchRule::getRankStart, rank).ge(SportUserGameCurrencyMatchRule::getRankEnd, rank));
if (matchRule != null && matchRule.getRate() != null) {
currency = matchRule.getRate().multiply(BigDecimal.valueOf(currency)).intValue();
}
}
return currency;
}
/**
* 处理用户积分
*
......
......@@ -45,7 +45,10 @@ public class SportUserController {
@ApiOperation("查询我的排名 type: 1能力榜 2活跃度榜")
@GetMapping("/{userId}/rank")
public ResponseEntity<Result<SportUserMonthRankResponseDTO>> getMyRank(@PathVariable("userId") Long userId, @RequestParam Integer type, @RequestParam Integer year, @RequestParam Integer month) {
public ResponseEntity<Result<SportUserMonthRankResponseDTO>> getMyRank(@PathVariable("userId") Long userId,
@RequestParam Integer type,
@RequestParam Integer year,
@RequestParam Integer month) {
return success(sportUserTrainingLogService.getMyRank(userId, type, year, month));
}
......@@ -59,7 +62,9 @@ public class SportUserController {
@ApiOperation("查询玩家运动日历")
@PostMapping("/{userId}/schedule")
public ResponseEntity<Result<List<ScheduleResponseDTO>>> getSchedule(@PathVariable("userId") Long userId, @RequestParam Integer year, @RequestParam Integer month) {
public ResponseEntity<Result<List<ScheduleResponseDTO>>> getSchedule(@PathVariable("userId") Long userId,
@RequestParam Integer year,
@RequestParam Integer month) {
return success(sportUserTrainingLogService.getSchedule(userId, year, month));
}
......@@ -94,4 +99,11 @@ public class SportUserController {
public ResponseEntity<Result<NewMessageVO>> getUserNewMessage(@PathVariable("sportUserId") Long sportUserId) {
return success(sportUserService.getUserNewMessage(sportUserId));
}
@ApiOperation("根据卡路里、排名计算积分")
@GetMapping("/calc/currency")
public ResponseEntity<Result<Integer>> calcCurrency(@RequestBody CalcCurrencyDTO param) {
return success(sportUserTrainingLogService.calcCurrency(param.getGameMode(), param.getCalorie(),
param.getRank()));
}
}
package com.antai.sport.http.server.server.api.business.user.dto;
import io.swagger.annotations.ApiModel;
import lombok.Data;
@Data
@ApiModel("积分计算接口")
public class CalcCurrencyDTO {
private Integer gameMode;
private Integer calorie;
private Integer rank;
}
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