commit
8c9b08c07e
@ -0,0 +1,37 @@
|
|||||||
|
package com.cyl.job;
|
||||||
|
|
||||||
|
import com.cyl.manager.aws.domain.SystemStatistics;
|
||||||
|
import com.cyl.manager.aws.mapper.SystemStatisticsMapper;
|
||||||
|
import com.cyl.manager.aws.service.SystemStatisticsService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class StatisticsJob {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SystemStatisticsService systemStatisticsService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SystemStatisticsMapper systemStatisticsMapper;
|
||||||
|
|
||||||
|
@Async
|
||||||
|
@Scheduled(cron = "00 00 3 * * ?")
|
||||||
|
public void cancelOrder() {
|
||||||
|
log.info("【统计昨日系统数据任务开始】");
|
||||||
|
LocalDateTime startTime = LocalDateTime.of(LocalDate.now(), LocalTime.MIN).plusDays(-1);
|
||||||
|
LocalDateTime endTime = LocalDateTime.of(LocalDate.now(), LocalTime.MAX).plusDays(-1);
|
||||||
|
SystemStatistics data = systemStatisticsService.stat(startTime, endTime);
|
||||||
|
systemStatisticsMapper.insert(data);
|
||||||
|
log.info("【统计昨日系统数据任务结束】");
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,93 @@
|
|||||||
|
package com.cyl.manager.aws.controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.data.domain.PageImpl;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import com.ruoyi.common.annotation.Log;
|
||||||
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
|
import com.cyl.manager.aws.convert.SystemStatisticsConvert;
|
||||||
|
import com.cyl.manager.aws.domain.SystemStatistics;
|
||||||
|
import com.cyl.manager.aws.pojo.query.SystemStatisticsQuery;
|
||||||
|
import com.cyl.manager.aws.service.SystemStatisticsService;
|
||||||
|
import com.cyl.manager.aws.pojo.vo.SystemStatisticsVO;
|
||||||
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
|
/**
|
||||||
|
* 系统数据统计Controller
|
||||||
|
*
|
||||||
|
* @author zcc
|
||||||
|
* @date 2023-07-28
|
||||||
|
*/
|
||||||
|
@Api(description ="系统数据统计接口列表")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/aws/systemStatistics")
|
||||||
|
public class SystemStatisticsController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private SystemStatisticsService service;
|
||||||
|
@Autowired
|
||||||
|
private SystemStatisticsConvert convert;
|
||||||
|
|
||||||
|
@ApiOperation("查询系统数据统计列表")
|
||||||
|
@PreAuthorize("@ss.hasPermi('aws:systemStatistics:list')")
|
||||||
|
@PostMapping("/list")
|
||||||
|
public ResponseEntity<Page<SystemStatistics>> list(@RequestBody SystemStatisticsQuery query, Pageable page) {
|
||||||
|
return ResponseEntity.ok(service.selectList(query, page));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("导出系统数据统计列表")
|
||||||
|
@PreAuthorize("@ss.hasPermi('aws:systemStatistics:export')")
|
||||||
|
@Log(title = "系统数据统计", businessType = BusinessType.EXPORT)
|
||||||
|
@GetMapping("/export")
|
||||||
|
public ResponseEntity<String> export(SystemStatisticsQuery query) {
|
||||||
|
// List<SystemStatistics> list = service.selectList(query, null);
|
||||||
|
// ExcelUtil<SystemStatisticsVO> util = new ExcelUtil<>(SystemStatisticsVO.class);
|
||||||
|
// return ResponseEntity.ok(util.writeExcel(convert.dos2vos(list), "系统数据统计数据"));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("获取系统数据统计详细信息")
|
||||||
|
@PreAuthorize("@ss.hasPermi('aws:systemStatistics:query')")
|
||||||
|
@GetMapping(value = "/{id}")
|
||||||
|
public ResponseEntity<SystemStatistics> getInfo(@PathVariable("id") Long id) {
|
||||||
|
return ResponseEntity.ok(service.selectById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("新增系统数据统计")
|
||||||
|
@PreAuthorize("@ss.hasPermi('aws:systemStatistics:add')")
|
||||||
|
@Log(title = "系统数据统计", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
public ResponseEntity<Integer> add(@RequestBody SystemStatistics systemStatistics) {
|
||||||
|
return ResponseEntity.ok(service.insert(systemStatistics));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("修改系统数据统计")
|
||||||
|
@PreAuthorize("@ss.hasPermi('aws:systemStatistics:edit')")
|
||||||
|
@Log(title = "系统数据统计", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
public ResponseEntity<Integer> edit(@RequestBody SystemStatistics systemStatistics) {
|
||||||
|
return ResponseEntity.ok(service.update(systemStatistics));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("删除系统数据统计")
|
||||||
|
@PreAuthorize("@ss.hasPermi('aws:systemStatistics:remove')")
|
||||||
|
@Log(title = "系统数据统计", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{id}")
|
||||||
|
public ResponseEntity<Integer> remove(@PathVariable Long id) {
|
||||||
|
return ResponseEntity.ok(service.deleteById(id));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
package com.cyl.manager.aws.convert;
|
||||||
|
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import com.cyl.manager.aws.domain.SystemStatistics;
|
||||||
|
import com.cyl.manager.aws.pojo.vo.SystemStatisticsVO;
|
||||||
|
import java.util.List;
|
||||||
|
/**
|
||||||
|
* 系统数据统计 DO <=> DTO <=> VO / BO / Query
|
||||||
|
*
|
||||||
|
* @author zcc
|
||||||
|
*/
|
||||||
|
@Mapper(componentModel = "spring")
|
||||||
|
public interface SystemStatisticsConvert {
|
||||||
|
|
||||||
|
List<SystemStatisticsVO> dos2vos(List<SystemStatistics> list);
|
||||||
|
}
|
||||||
@ -0,0 +1,68 @@
|
|||||||
|
package com.cyl.manager.aws.domain;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.ruoyi.common.annotation.Excel;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
/**
|
||||||
|
* 系统数据统计对象 aws_system_statistics
|
||||||
|
*
|
||||||
|
* @author zcc
|
||||||
|
*/
|
||||||
|
@ApiModel(description="系统数据统计对象")
|
||||||
|
@Data
|
||||||
|
@TableName("aws_system_statistics")
|
||||||
|
public class SystemStatistics {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty("ID")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@ApiModelProperty("统计日期")
|
||||||
|
@Excel(name = "统计日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private LocalDateTime date;
|
||||||
|
|
||||||
|
@ApiModelProperty("登录用户数")
|
||||||
|
@Excel(name = "登录用户数")
|
||||||
|
private Integer loginMemberCount;
|
||||||
|
|
||||||
|
@ApiModelProperty("注册用户数")
|
||||||
|
@Excel(name = "注册用户数")
|
||||||
|
private Integer registerMemberCount;
|
||||||
|
|
||||||
|
@ApiModelProperty("加购用户数")
|
||||||
|
@Excel(name = "加购用户数")
|
||||||
|
private Integer addCartMemberCount;
|
||||||
|
|
||||||
|
@ApiModelProperty("下单用户数")
|
||||||
|
@Excel(name = "下单用户数")
|
||||||
|
private Integer createOrderMemberCount;
|
||||||
|
|
||||||
|
@ApiModelProperty("成交用户数")
|
||||||
|
@Excel(name = "成交用户数")
|
||||||
|
private Integer dealMemberCount;
|
||||||
|
|
||||||
|
@ApiModelProperty("下单数")
|
||||||
|
@Excel(name = "下单数")
|
||||||
|
private Integer orderCount;
|
||||||
|
|
||||||
|
@ApiModelProperty("成交数")
|
||||||
|
@Excel(name = "成交数")
|
||||||
|
private Integer dealCount;
|
||||||
|
|
||||||
|
@ApiModelProperty("成交金额")
|
||||||
|
@Excel(name = "成交金额")
|
||||||
|
private BigDecimal dealAmount;
|
||||||
|
|
||||||
|
@ApiModelProperty("售后数")
|
||||||
|
@Excel(name = "售后数")
|
||||||
|
private Integer aftersaleCount;
|
||||||
|
|
||||||
|
@ApiModelProperty("售后金额")
|
||||||
|
@Excel(name = "售后金额")
|
||||||
|
private BigDecimal aftersaleAmount;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
package com.cyl.manager.aws.mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import com.cyl.manager.aws.domain.SystemStatistics;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统数据统计Mapper接口
|
||||||
|
*
|
||||||
|
* @author zcc
|
||||||
|
*/
|
||||||
|
public interface SystemStatisticsMapper extends BaseMapper<SystemStatistics> {
|
||||||
|
/**
|
||||||
|
* 查询系统数据统计列表
|
||||||
|
*
|
||||||
|
* @param systemStatistics 系统数据统计
|
||||||
|
* @return 系统数据统计集合
|
||||||
|
*/
|
||||||
|
List<SystemStatistics> selectByEntity(SystemStatistics systemStatistics);
|
||||||
|
}
|
||||||
@ -0,0 +1,57 @@
|
|||||||
|
package com.cyl.manager.aws.pojo.query;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.Data;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统数据统计 查询 对象
|
||||||
|
*
|
||||||
|
* @author zcc
|
||||||
|
*/
|
||||||
|
@ApiModel(description="系统数据统计 查询 对象")
|
||||||
|
@Data
|
||||||
|
public class SystemStatisticsQuery {
|
||||||
|
@ApiModelProperty("统计开始日期")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private LocalDateTime beginTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("统计结束日期")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private LocalDateTime endTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("登录用户数 精确匹配")
|
||||||
|
private Integer loginMemberCount;
|
||||||
|
|
||||||
|
@ApiModelProperty("注册用户数 精确匹配")
|
||||||
|
private Integer registerMemberCount;
|
||||||
|
|
||||||
|
@ApiModelProperty("加购用户数 精确匹配")
|
||||||
|
private Integer addCartMemberCount;
|
||||||
|
|
||||||
|
@ApiModelProperty("下单用户数 精确匹配")
|
||||||
|
private Integer createOrderMemberCount;
|
||||||
|
|
||||||
|
@ApiModelProperty("成交用户数 精确匹配")
|
||||||
|
private Integer dealMemberCount;
|
||||||
|
|
||||||
|
@ApiModelProperty("下单数 精确匹配")
|
||||||
|
private Integer orderCount;
|
||||||
|
|
||||||
|
@ApiModelProperty("成交数 精确匹配")
|
||||||
|
private Integer dealCount;
|
||||||
|
|
||||||
|
@ApiModelProperty("成交金额 精确匹配")
|
||||||
|
private BigDecimal dealAmount;
|
||||||
|
|
||||||
|
@ApiModelProperty("售后数 精确匹配")
|
||||||
|
private Integer aftersaleCount;
|
||||||
|
|
||||||
|
@ApiModelProperty("售后金额 精确匹配")
|
||||||
|
private BigDecimal aftersaleAmount;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,51 @@
|
|||||||
|
package com.cyl.manager.aws.pojo.vo;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.ruoyi.common.annotation.Excel;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.Data;
|
||||||
|
/**
|
||||||
|
* 系统数据统计 数据视图对象
|
||||||
|
*
|
||||||
|
* @author zcc
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SystemStatisticsVO {
|
||||||
|
/** ID */
|
||||||
|
private Long id;
|
||||||
|
/** 统计日期 */
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@Excel(name = "统计日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private LocalDateTime date;
|
||||||
|
/** 登录用户数 */
|
||||||
|
@Excel(name = "登录用户数")
|
||||||
|
private Integer loginMemberCount;
|
||||||
|
/** 注册用户数 */
|
||||||
|
@Excel(name = "注册用户数")
|
||||||
|
private Integer registerMemberCount;
|
||||||
|
/** 加购用户数 */
|
||||||
|
@Excel(name = "加购用户数")
|
||||||
|
private Integer addCartMemberCount;
|
||||||
|
/** 下单用户数 */
|
||||||
|
@Excel(name = "下单用户数")
|
||||||
|
private Integer createOrderMemberCount;
|
||||||
|
/** 成交用户数 */
|
||||||
|
@Excel(name = "成交用户数")
|
||||||
|
private Integer dealMemberCount;
|
||||||
|
/** 下单数 */
|
||||||
|
@Excel(name = "下单数")
|
||||||
|
private Integer orderCount;
|
||||||
|
/** 成交数 */
|
||||||
|
@Excel(name = "成交数")
|
||||||
|
private Integer dealCount;
|
||||||
|
/** 成交金额 */
|
||||||
|
@Excel(name = "成交金额")
|
||||||
|
private BigDecimal dealAmount;
|
||||||
|
/** 售后数 */
|
||||||
|
@Excel(name = "售后数")
|
||||||
|
private Integer aftersaleCount;
|
||||||
|
/** 售后金额 */
|
||||||
|
@Excel(name = "售后金额")
|
||||||
|
private BigDecimal aftersaleAmount;
|
||||||
|
}
|
||||||
@ -0,0 +1,157 @@
|
|||||||
|
package com.cyl.manager.aws.service;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.cyl.manager.oms.domain.Aftersale;
|
||||||
|
import com.cyl.manager.oms.mapper.AftersaleMapper;
|
||||||
|
import com.cyl.manager.oms.mapper.OrderMapper;
|
||||||
|
import com.cyl.manager.ums.domain.Member;
|
||||||
|
import com.cyl.manager.ums.domain.MemberCart;
|
||||||
|
import com.cyl.manager.ums.mapper.MemberCartMapper;
|
||||||
|
import com.cyl.manager.ums.mapper.MemberLogininforMapper;
|
||||||
|
import com.cyl.manager.ums.mapper.MemberMapper;
|
||||||
|
import com.github.pagehelper.Page;
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.domain.PageImpl;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.cyl.manager.aws.mapper.SystemStatisticsMapper;
|
||||||
|
import com.cyl.manager.aws.domain.SystemStatistics;
|
||||||
|
import com.cyl.manager.aws.pojo.query.SystemStatisticsQuery;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统数据统计Service业务层处理
|
||||||
|
*
|
||||||
|
* @author zcc
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class SystemStatisticsService {
|
||||||
|
@Autowired
|
||||||
|
private SystemStatisticsMapper systemStatisticsMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OrderMapper orderMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AftersaleMapper aftersaleMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MemberLogininforMapper memberLogininforMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MemberMapper memberMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MemberCartMapper memberCartMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询系统数据统计
|
||||||
|
*
|
||||||
|
* @param id 系统数据统计主键
|
||||||
|
* @return 系统数据统计
|
||||||
|
*/
|
||||||
|
public SystemStatistics selectById(Long id) {
|
||||||
|
return systemStatisticsMapper.selectById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询系统数据统计列表
|
||||||
|
*
|
||||||
|
* @param query 查询条件
|
||||||
|
* @param page 分页条件
|
||||||
|
* @return 系统数据统计
|
||||||
|
*/
|
||||||
|
public PageImpl<SystemStatistics> selectList(SystemStatisticsQuery query, Pageable page) {
|
||||||
|
if (page != null) {
|
||||||
|
PageHelper.startPage(page.getPageNumber() + 1, page.getPageSize());
|
||||||
|
}
|
||||||
|
LambdaQueryWrapper<SystemStatistics> qw = new LambdaQueryWrapper<>();
|
||||||
|
if (query.getBeginTime() != null && query.getEndTime() != null){
|
||||||
|
qw.ge(SystemStatistics::getDate, query.getBeginTime());
|
||||||
|
qw.lt(SystemStatistics::getDate, query.getEndTime());
|
||||||
|
}
|
||||||
|
qw.orderByDesc(SystemStatistics::getDate);
|
||||||
|
List<SystemStatistics> statList = systemStatisticsMapper.selectList(qw);
|
||||||
|
long total = ((Page)statList).getTotal();
|
||||||
|
if ((query.getBeginTime() == null && query.getEndTime() == null) || (query.getEndTime() != null && query.getEndTime().isAfter(LocalDateTime.now()))){
|
||||||
|
SystemStatistics stat = this.stat(LocalDateTime.of(LocalDate.now(), LocalTime.MIN), LocalDateTime.of(LocalDate.now(), LocalTime.MAX));
|
||||||
|
statList.add(0, stat);
|
||||||
|
return new PageImpl<>(statList, page, total);
|
||||||
|
}
|
||||||
|
return new PageImpl<>(statList, page, total);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增系统数据统计
|
||||||
|
*
|
||||||
|
* @param systemStatistics 系统数据统计
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insert(SystemStatistics systemStatistics) {
|
||||||
|
return systemStatisticsMapper.insert(systemStatistics);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改系统数据统计
|
||||||
|
*
|
||||||
|
* @param systemStatistics 系统数据统计
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int update(SystemStatistics systemStatistics) {
|
||||||
|
return systemStatisticsMapper.updateById(systemStatistics);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除系统数据统计信息
|
||||||
|
*
|
||||||
|
* @param id 系统数据统计主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteById(Long id) {
|
||||||
|
return systemStatisticsMapper.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SystemStatistics stat(LocalDateTime startTime, LocalDateTime endTime) {
|
||||||
|
//统计下单用户数、成交用户数、下单数、成交数、成交金额
|
||||||
|
SystemStatistics systemStatistics = orderMapper.statNewAndDeal(startTime, endTime);
|
||||||
|
//统计成交用户数
|
||||||
|
systemStatistics.setDealMemberCount(orderMapper.statDealMember(startTime, endTime));
|
||||||
|
//统计售后
|
||||||
|
LambdaQueryWrapper<Aftersale> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.between(Aftersale::getCreateTime, startTime, endTime);
|
||||||
|
wrapper.orderByDesc(Aftersale::getCreateTime);
|
||||||
|
List<Aftersale> aftersaleList = aftersaleMapper.selectList(wrapper);
|
||||||
|
if (CollectionUtil.isEmpty(aftersaleList)) {
|
||||||
|
systemStatistics.setAftersaleCount(0);
|
||||||
|
systemStatistics.setAftersaleAmount(BigDecimal.ZERO);
|
||||||
|
} else {
|
||||||
|
Map<Long, BigDecimal> map = aftersaleList.stream().collect(Collectors.toMap(Aftersale::getOrderId, Aftersale::getReturnAmount, (v1, v2) -> v1, LinkedHashMap::new));
|
||||||
|
systemStatistics.setAftersaleCount(map.values().size());
|
||||||
|
systemStatistics.setAftersaleAmount(map.values().stream().reduce(BigDecimal::add).get());
|
||||||
|
}
|
||||||
|
//统计登录用户数
|
||||||
|
systemStatistics.setLoginMemberCount(memberLogininforMapper.statLoginMember(startTime, endTime));
|
||||||
|
//统计注册用户
|
||||||
|
LambdaQueryWrapper<Member> memberWrapper = new LambdaQueryWrapper<>();
|
||||||
|
memberWrapper.between(Member::getCreateTime, startTime, endTime);
|
||||||
|
systemStatistics.setRegisterMemberCount(memberMapper.selectCount(memberWrapper));
|
||||||
|
//统计加购数
|
||||||
|
systemStatistics.setAddCartMemberCount(memberCartMapper.statAddCount(startTime, endTime));
|
||||||
|
systemStatistics.setDate(startTime);
|
||||||
|
return systemStatistics;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.cyl.manager.aws.mapper.SystemStatisticsMapper">
|
||||||
|
|
||||||
|
<resultMap type="SystemStatistics" id="SystemStatisticsResult">
|
||||||
|
<result property="id" column="id"/>
|
||||||
|
<result property="date" column="date"/>
|
||||||
|
<result property="loginMemberCount" column="login_member_count"/>
|
||||||
|
<result property="registerMemberCount" column="register_member_count"/>
|
||||||
|
<result property="addCartMemberCount" column="add_cart_member_count"/>
|
||||||
|
<result property="createOrderMemberCount" column="create_order_member_count"/>
|
||||||
|
<result property="dealMemberCount" column="deal_member_count"/>
|
||||||
|
<result property="orderCount" column="order_count"/>
|
||||||
|
<result property="dealCount" column="deal_count"/>
|
||||||
|
<result property="dealAmount" column="deal_amount"/>
|
||||||
|
<result property="aftersaleCount" column="aftersale_count"/>
|
||||||
|
<result property="aftersaleAmount" column="aftersale_amount"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectSystemStatisticsVo">
|
||||||
|
select id, date, login_member_count, register_member_count, add_cart_member_count, create_order_member_count, deal_member_count, order_count, deal_count, deal_amount, aftersale_count, aftersale_amount from aws_system_statistics
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectByEntity" parameterType="SystemStatistics" resultMap="SystemStatisticsResult">
|
||||||
|
<include refid="selectSystemStatisticsVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="date != null "> and date = #{date}</if>
|
||||||
|
<if test="loginMemberCount != null "> and login_member_count = #{loginMemberCount}</if>
|
||||||
|
<if test="registerMemberCount != null "> and register_member_count = #{registerMemberCount}</if>
|
||||||
|
<if test="addCartMemberCount != null "> and add_cart_member_count = #{addCartMemberCount}</if>
|
||||||
|
<if test="createOrderMemberCount != null "> and create_order_member_count = #{createOrderMemberCount}</if>
|
||||||
|
<if test="dealMemberCount != null "> and deal_member_count = #{dealMemberCount}</if>
|
||||||
|
<if test="orderCount != null "> and order_count = #{orderCount}</if>
|
||||||
|
<if test="dealCount != null "> and deal_count = #{dealCount}</if>
|
||||||
|
<if test="dealAmount != null "> and deal_amount = #{dealAmount}</if>
|
||||||
|
<if test="aftersaleCount != null "> and aftersale_count = #{aftersaleCount}</if>
|
||||||
|
<if test="aftersaleAmount != null "> and aftersale_amount = #{aftersaleAmount}</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
-- 菜单 SQL
|
||||||
|
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||||
|
values('系统数据统计', '3', '1', 'systemStatistics', 'aws/systemStatistics/index', 1, 0, 'C', '0', '0', 'aws:systemStatistics:list', '#', 1, sysdate(), '', null, '系统数据统计菜单');
|
||||||
|
|
||||||
|
-- 按钮父菜单ID
|
||||||
|
SELECT @parentId := LAST_INSERT_ID();
|
||||||
|
|
||||||
|
-- 按钮 SQL
|
||||||
|
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||||
|
values('系统数据统计查询', @parentId, '1', '#', '', 1, 0, 'F', '0', '0', 'aws:systemStatistics:query', '#', 1, sysdate(), '', null, '');
|
||||||
|
|
||||||
|
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||||
|
values('系统数据统计新增', @parentId, '2', '#', '', 1, 0, 'F', '0', '0', 'aws:systemStatistics:add', '#', 1, sysdate(), '', null, '');
|
||||||
|
|
||||||
|
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||||
|
values('系统数据统计修改', @parentId, '3', '#', '', 1, 0, 'F', '0', '0', 'aws:systemStatistics:edit', '#', 1, sysdate(), '', null, '');
|
||||||
|
|
||||||
|
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||||
|
values('系统数据统计删除', @parentId, '4', '#', '', 1, 0, 'F', '0', '0', 'aws:systemStatistics:remove', '#', 1, sysdate(), '', null, '');
|
||||||
|
|
||||||
|
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||||
|
values('系统数据统计导出', @parentId, '5', '#', '', 1, 0, 'F', '0', '0', 'aws:systemStatistics:export', '#', 1, sysdate(), '', null, '');
|
||||||
Loading…
Reference in new issue