refactor(mcwl): 调整平台数据统计

master
yang 2025-03-08 17:50:48 +08:00
parent 4369932fa7
commit f22bb0dde2
9 changed files with 169 additions and 72 deletions

View File

@ -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);
} }

View File

@ -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("超时");

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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();
} }

View File

@ -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 实例

View File

@ -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;
}

View File

@ -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();
} }

View File

@ -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();
}
} }