refactor(mcwl-pay): 调整收入接口返回数据精度
parent
39059b6f4c
commit
4369932fa7
|
@ -7,6 +7,7 @@ import com.mcwl.system.service.ISysUserService;
|
|||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
@ -24,7 +25,7 @@ public class PlatformData {
|
|||
* 今日收益总额
|
||||
*/
|
||||
@ApiOperation(value = "今日收益总额")
|
||||
@RequestMapping("getTodayIncome")
|
||||
@GetMapping("getTodayIncome")
|
||||
public R<Double> getTodayIncome() {
|
||||
Double amount = orderTradeService.getTodayIncome();
|
||||
return R.ok(amount);
|
||||
|
@ -35,7 +36,7 @@ public class PlatformData {
|
|||
* 本月收益总额
|
||||
*/
|
||||
@ApiOperation(value = "本月收益总额")
|
||||
@RequestMapping("getMonthIncome")
|
||||
@GetMapping("getMonthIncome")
|
||||
public R<Double> getMonthIncome() {
|
||||
Double amount = orderTradeService.getMonthIncome();
|
||||
return R.ok(amount);
|
||||
|
@ -45,7 +46,7 @@ public class PlatformData {
|
|||
* 年度收益总额
|
||||
*/
|
||||
@ApiOperation(value = "年度收益总额")
|
||||
@RequestMapping("getYearIncome")
|
||||
@GetMapping("getYearIncome")
|
||||
public R<Double> getYearIncome() {
|
||||
Double amount = orderTradeService.getYearIncome();
|
||||
return R.ok(amount);
|
||||
|
@ -55,7 +56,7 @@ public class PlatformData {
|
|||
* 总收益总额
|
||||
*/
|
||||
@ApiOperation(value = "总收益总额")
|
||||
@RequestMapping("getTotalIncome")
|
||||
@GetMapping("getTotalIncome")
|
||||
public R<Double> getTotalIncome() {
|
||||
Double amount = orderTradeService.getTotalIncome();
|
||||
return R.ok(amount);
|
||||
|
@ -66,7 +67,7 @@ public class PlatformData {
|
|||
* (本期数-同期数)/同期数×100%
|
||||
*/
|
||||
@ApiOperation(value = "收益同比增长")
|
||||
@RequestMapping("getYoYTrend")
|
||||
@GetMapping("getYoYTrend")
|
||||
public R<Double> getYoYTrend() {
|
||||
Double yoyTrend = orderTradeService.getYoYTrend();
|
||||
return R.ok(yoyTrend);
|
||||
|
@ -77,7 +78,7 @@ public class PlatformData {
|
|||
* (本期数 - 上期数) / 上期数 × 100%
|
||||
*/
|
||||
@ApiOperation(value = "收益环比增长")
|
||||
@RequestMapping("getMoMTrend")
|
||||
@GetMapping("getMoMTrend")
|
||||
public R<Double> getMoMTrend() {
|
||||
Double momTrend = orderTradeService.getMoMTrend();
|
||||
return R.ok(momTrend);
|
||||
|
@ -87,7 +88,7 @@ public class PlatformData {
|
|||
* 获取用户数量
|
||||
*/
|
||||
@ApiOperation(value = "获取用户数量")
|
||||
@RequestMapping("getUserCount")
|
||||
@GetMapping("getUserCount")
|
||||
public R<Integer> getUserCount() {
|
||||
int count = sysUserService.getUserCount();
|
||||
return R.ok(count);
|
||||
|
@ -97,7 +98,7 @@ public class PlatformData {
|
|||
* 本月新增用户数
|
||||
*/
|
||||
@ApiOperation(value = "本月新增用户数")
|
||||
@RequestMapping("getMonthUserCount")
|
||||
@GetMapping("getMonthUserCount")
|
||||
public R<Integer> getMonthUserCount() {
|
||||
int count = sysUserService.getMonthUserCount();
|
||||
return R.ok(count);
|
||||
|
|
|
@ -185,8 +185,10 @@ public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTr
|
|||
return todayIncome;
|
||||
}
|
||||
todayIncome = orderTradeMapper.getTodayIncome();
|
||||
redisCache.setCacheObject("income:todayIncome", todayIncome, 1, TimeUnit.MINUTES);
|
||||
return todayIncome;
|
||||
// 保留小数点后两位
|
||||
double doubleValue = new BigDecimal(todayIncome).setScale(2, RoundingMode.HALF_UP).doubleValue();
|
||||
redisCache.setCacheObject("income:todayIncome", doubleValue, 1, TimeUnit.MINUTES);
|
||||
return doubleValue;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -201,8 +203,9 @@ public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTr
|
|||
return monthIncome;
|
||||
}
|
||||
monthIncome = orderTradeMapper.getMonthIncome();
|
||||
redisCache.setCacheObject("income:monthIncome", monthIncome, 1, TimeUnit.MINUTES);
|
||||
return monthIncome;
|
||||
double doubleValue = new BigDecimal(monthIncome).setScale(2, RoundingMode.HALF_UP).doubleValue();
|
||||
redisCache.setCacheObject("income:monthIncome", doubleValue, 1, TimeUnit.MINUTES);
|
||||
return doubleValue;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -217,8 +220,9 @@ public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTr
|
|||
return yearIncome;
|
||||
}
|
||||
yearIncome = orderTradeMapper.getYearIncome();
|
||||
redisCache.setCacheObject("income:yearIncome", yearIncome, 1, TimeUnit.MINUTES);
|
||||
return yearIncome;
|
||||
double doubleValue = new BigDecimal(yearIncome).setScale(2, RoundingMode.HALF_UP).doubleValue();
|
||||
redisCache.setCacheObject("income:yearIncome", doubleValue, 1, TimeUnit.MINUTES);
|
||||
return doubleValue;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -233,8 +237,9 @@ public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTr
|
|||
return totalIncome;
|
||||
}
|
||||
totalIncome = orderTradeMapper.getTotalIncome();
|
||||
redisCache.setCacheObject("income:totalIncome", totalIncome, 1, TimeUnit.MINUTES);
|
||||
return totalIncome;
|
||||
double doubleValue = new BigDecimal(totalIncome).setScale(2, RoundingMode.HALF_UP).doubleValue();
|
||||
redisCache.setCacheObject("income:totalIncome", doubleValue, 1, TimeUnit.MINUTES);
|
||||
return doubleValue;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -265,9 +270,10 @@ public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTr
|
|||
}
|
||||
|
||||
yoyTrend = (yearIncome - lastYearIncome) / lastYearIncome;
|
||||
redisCache.setCacheObject(cacheKey, yoyTrend, 12, TimeUnit.HOURS);
|
||||
double doubleValue = new BigDecimal(yoyTrend).setScale(2, RoundingMode.HALF_UP).doubleValue();
|
||||
redisCache.setCacheObject(cacheKey, doubleValue, 12, TimeUnit.HOURS);
|
||||
|
||||
return yoyTrend;
|
||||
return doubleValue;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -297,9 +303,12 @@ public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTr
|
|||
}
|
||||
|
||||
momTrend = (month - lastMonth) / lastMonth;
|
||||
redisCache.setCacheObject(cacheKey, momTrend, 12, TimeUnit.HOURS);
|
||||
// 保留小数点后两位
|
||||
double doubleValue = new BigDecimal(momTrend).setScale(2, RoundingMode.HALF_UP).doubleValue();
|
||||
|
||||
return momTrend;
|
||||
redisCache.setCacheObject(cacheKey, doubleValue, 12, TimeUnit.HOURS);
|
||||
|
||||
return doubleValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue