refactor(mcwl): 调整平台数据统计
parent
4369932fa7
commit
f22bb0dde2
|
@ -2,7 +2,10 @@ package com.mcwl.web.controller.platformData;
|
||||||
|
|
||||||
|
|
||||||
import com.mcwl.common.core.domain.R;
|
import com.mcwl.common.core.domain.R;
|
||||||
|
import com.mcwl.pay.domain.vo.IncomeVo;
|
||||||
|
import com.mcwl.pay.domain.vo.TrendVo;
|
||||||
import com.mcwl.pay.service.OrderTradeService;
|
import com.mcwl.pay.service.OrderTradeService;
|
||||||
|
import com.mcwl.system.domain.vo.UserDataVo;
|
||||||
import com.mcwl.system.service.ISysUserService;
|
import com.mcwl.system.service.ISysUserService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
@ -11,7 +14,7 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@Api(tags = "平台数据")
|
@Api(tags = "平台数据统计")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("platformData")
|
@RequestMapping("platformData")
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
|
@ -22,86 +25,33 @@ public class PlatformData {
|
||||||
private final ISysUserService sysUserService;
|
private final ISysUserService sysUserService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 今日收益总额
|
* 平台收益
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "今日收益总额")
|
@ApiOperation(value = "平台收益")
|
||||||
@GetMapping("getTodayIncome")
|
@GetMapping("getIncome")
|
||||||
public R<Double> getTodayIncome() {
|
public R<IncomeVo> getIncome() {
|
||||||
Double amount = orderTradeService.getTodayIncome();
|
|
||||||
return R.ok(amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return R.ok(orderTradeService.getIncome());
|
||||||
/**
|
|
||||||
* 本月收益总额
|
|
||||||
*/
|
|
||||||
@ApiOperation(value = "本月收益总额")
|
|
||||||
@GetMapping("getMonthIncome")
|
|
||||||
public R<Double> getMonthIncome() {
|
|
||||||
Double amount = orderTradeService.getMonthIncome();
|
|
||||||
return R.ok(amount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 年度收益总额
|
* 收益趋势
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "年度收益总额")
|
@ApiOperation(value = "收益趋势")
|
||||||
@GetMapping("getYearIncome")
|
@GetMapping("getTrend")
|
||||||
public R<Double> getYearIncome() {
|
public R<TrendVo> getTrend() {
|
||||||
Double amount = orderTradeService.getYearIncome();
|
|
||||||
return R.ok(amount);
|
return R.ok(orderTradeService.getTrend());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 总收益总额
|
* 用户数据
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "总收益总额")
|
@ApiOperation(value = "用户数据")
|
||||||
@GetMapping("getTotalIncome")
|
@GetMapping("getUserData")
|
||||||
public R<Double> getTotalIncome() {
|
public R<UserDataVo> getUserData() {
|
||||||
Double amount = orderTradeService.getTotalIncome();
|
|
||||||
return R.ok(amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
return R.ok(sysUserService.getUserData());
|
||||||
* 收益同比增长 (Year-on-Year, YoY)
|
|
||||||
* (本期数-同期数)/同期数×100%
|
|
||||||
*/
|
|
||||||
@ApiOperation(value = "收益同比增长")
|
|
||||||
@GetMapping("getYoYTrend")
|
|
||||||
public R<Double> getYoYTrend() {
|
|
||||||
Double yoyTrend = orderTradeService.getYoYTrend();
|
|
||||||
return R.ok(yoyTrend);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 收益环比增长 (Month-on-Month, MoM)
|
|
||||||
* (本期数 - 上期数) / 上期数 × 100%
|
|
||||||
*/
|
|
||||||
@ApiOperation(value = "收益环比增长")
|
|
||||||
@GetMapping("getMoMTrend")
|
|
||||||
public R<Double> getMoMTrend() {
|
|
||||||
Double momTrend = orderTradeService.getMoMTrend();
|
|
||||||
return R.ok(momTrend);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取用户数量
|
|
||||||
*/
|
|
||||||
@ApiOperation(value = "获取用户数量")
|
|
||||||
@GetMapping("getUserCount")
|
|
||||||
public R<Integer> getUserCount() {
|
|
||||||
int count = sysUserService.getUserCount();
|
|
||||||
return R.ok(count);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 本月新增用户数
|
|
||||||
*/
|
|
||||||
@ApiOperation(value = "本月新增用户数")
|
|
||||||
@GetMapping("getMonthUserCount")
|
|
||||||
public R<Integer> getMonthUserCount() {
|
|
||||||
int count = sysUserService.getMonthUserCount();
|
|
||||||
return R.ok(count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -49,8 +49,8 @@ public class GlobalExceptionHandler {
|
||||||
/**
|
/**
|
||||||
* redis连接超时异常
|
* redis连接超时异常
|
||||||
*/
|
*/
|
||||||
@ExceptionHandler(RedisCommandTimeoutException.class)
|
@ExceptionHandler(QueryTimeoutException.class)
|
||||||
public AjaxResult commandTimeoutException(RedisCommandTimeoutException e, HttpServletRequest request) {
|
public AjaxResult commandTimeoutException(QueryTimeoutException e, HttpServletRequest request) {
|
||||||
String requestURI = request.getRequestURI();
|
String requestURI = request.getRequestURI();
|
||||||
log.error("redis异常{},{}", requestURI, e.getMessage());
|
log.error("redis异常{},{}", requestURI, e.getMessage());
|
||||||
return AjaxResult.warn("超时");
|
return AjaxResult.warn("超时");
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.mcwl.pay.domain.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
|
@ApiModel(value = "收益返回对象")
|
||||||
|
public class IncomeVo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 今日收益总额
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "今日收益总额")
|
||||||
|
private Double todayIncome;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 本月收益总额
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "本月收益总额")
|
||||||
|
private Double monthIncome;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 年度收益总额
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "年度收益总额")
|
||||||
|
private Double yearIncome;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收益总额
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "收益总额")
|
||||||
|
private Double totalIncome;
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.mcwl.pay.domain.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
|
@ApiModel(value = "收益趋势返回对象")
|
||||||
|
public class TrendVo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收益同比增长
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "收益同比增长")
|
||||||
|
private Double yoyTrend;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收益环比增长
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "收益环比增长")
|
||||||
|
private Double momTrend;
|
||||||
|
}
|
|
@ -5,6 +5,8 @@ import com.mcwl.common.core.page.PageDomain;
|
||||||
import com.mcwl.common.core.page.TableDataInfo;
|
import com.mcwl.common.core.page.TableDataInfo;
|
||||||
import com.mcwl.common.domain.IdsParam;
|
import com.mcwl.common.domain.IdsParam;
|
||||||
import com.mcwl.pay.domain.OrderTrade;
|
import com.mcwl.pay.domain.OrderTrade;
|
||||||
|
import com.mcwl.pay.domain.vo.IncomeVo;
|
||||||
|
import com.mcwl.pay.domain.vo.TrendVo;
|
||||||
import com.mcwl.resource.domain.dto.ProductRes;
|
import com.mcwl.resource.domain.dto.ProductRes;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -75,4 +77,16 @@ public interface OrderTradeService extends IService<OrderTrade> {
|
||||||
* @return Double
|
* @return Double
|
||||||
*/
|
*/
|
||||||
Double getMoMTrend();
|
Double getMoMTrend();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取收益
|
||||||
|
* @return IncomeVo
|
||||||
|
*/
|
||||||
|
IncomeVo getIncome();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取收益趋势
|
||||||
|
* @return IncomeVo
|
||||||
|
*/
|
||||||
|
TrendVo getTrend();
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@ import com.mcwl.myInvitation.service.CommissionService;
|
||||||
import com.mcwl.myInvitation.service.ConsumeService;
|
import com.mcwl.myInvitation.service.ConsumeService;
|
||||||
import com.mcwl.pay.domain.OrderTrade;
|
import com.mcwl.pay.domain.OrderTrade;
|
||||||
import com.mcwl.pay.domain.enums.CommissionRationEnum;
|
import com.mcwl.pay.domain.enums.CommissionRationEnum;
|
||||||
|
import com.mcwl.pay.domain.vo.IncomeVo;
|
||||||
|
import com.mcwl.pay.domain.vo.TrendVo;
|
||||||
import com.mcwl.pay.domain.vo.WalletRechargeRecordVo;
|
import com.mcwl.pay.domain.vo.WalletRechargeRecordVo;
|
||||||
import com.mcwl.pay.mapper.OrderTradeMapper;
|
import com.mcwl.pay.mapper.OrderTradeMapper;
|
||||||
import com.mcwl.pay.service.OrderTradeService;
|
import com.mcwl.pay.service.OrderTradeService;
|
||||||
|
@ -311,6 +313,28 @@ public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTr
|
||||||
return doubleValue;
|
return doubleValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IncomeVo getIncome() {
|
||||||
|
return IncomeVo.builder()
|
||||||
|
.todayIncome(this.getTodayIncome())
|
||||||
|
.monthIncome(this.getMonthIncome())
|
||||||
|
.yearIncome(this.getYearIncome())
|
||||||
|
.totalIncome(this.getTotalIncome())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取收入趋势
|
||||||
|
* @return IncomeVo
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public TrendVo getTrend() {
|
||||||
|
return TrendVo.builder()
|
||||||
|
.yoyTrend(this.getYoYTrend())
|
||||||
|
.momTrend(this.getMoMTrend())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<OrderTrade> selectMallProductList(OrderTrade orderTrade) {
|
public List<OrderTrade> selectMallProductList(OrderTrade orderTrade) {
|
||||||
// 创建一个 LambdaQueryWrapper 实例
|
// 创建一个 LambdaQueryWrapper 实例
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.mcwl.system.domain.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
|
@ApiModel(value = "用户数据返回对象")
|
||||||
|
public class UserDataVo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户总数
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "用户总数")
|
||||||
|
private Integer userCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 本月新增用户数
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "本月新增用户数")
|
||||||
|
private Integer monthUserCount;
|
||||||
|
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ package com.mcwl.system.service;
|
||||||
|
|
||||||
import com.mcwl.common.core.domain.AjaxResult;
|
import com.mcwl.common.core.domain.AjaxResult;
|
||||||
import com.mcwl.common.core.domain.entity.SysUser;
|
import com.mcwl.common.core.domain.entity.SysUser;
|
||||||
|
import com.mcwl.system.domain.vo.UserDataVo;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -223,4 +224,6 @@ public interface ISysUserService
|
||||||
Integer getUserCount();
|
Integer getUserCount();
|
||||||
|
|
||||||
Integer getMonthUserCount();
|
Integer getMonthUserCount();
|
||||||
|
|
||||||
|
UserDataVo getUserData();
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ import com.mcwl.system.domain.SysPost;
|
||||||
import com.mcwl.system.domain.SysUserPost;
|
import com.mcwl.system.domain.SysUserPost;
|
||||||
import com.mcwl.system.domain.SysUserRole;
|
import com.mcwl.system.domain.SysUserRole;
|
||||||
import com.mcwl.system.domain.SysUserThirdAccount;
|
import com.mcwl.system.domain.SysUserThirdAccount;
|
||||||
|
import com.mcwl.system.domain.vo.UserDataVo;
|
||||||
import com.mcwl.system.mapper.*;
|
import com.mcwl.system.mapper.*;
|
||||||
import com.mcwl.system.service.ISysConfigService;
|
import com.mcwl.system.service.ISysConfigService;
|
||||||
import com.mcwl.system.service.ISysDeptService;
|
import com.mcwl.system.service.ISysDeptService;
|
||||||
|
@ -704,4 +705,12 @@ public class SysUserServiceImpl implements ISysUserService
|
||||||
public Integer getMonthUserCount() {
|
public Integer getMonthUserCount() {
|
||||||
return userMapper.getMonthUserCount();
|
return userMapper.getMonthUserCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserDataVo getUserData() {
|
||||||
|
return UserDataVo.builder()
|
||||||
|
.userCount(this.getMonthUserCount())
|
||||||
|
.monthUserCount(this.getUserCount())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue