Commit 9ad267bc by YG8999

管理系统首页统计

parent 24e39ea8
package share.web.controller.system;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import share.common.core.controller.BaseController;
import share.common.core.domain.AjaxResult;
import share.system.service.StatisticsService;
/**
* @className: share.web.controller.system.HomeController
* @description: 首页
* @author: lwj
* @create: 2024-01-09 15:13
*/
@Api(tags = "首页")
@RestController
@RequestMapping("/system/home")
public class HomeController extends BaseController {
@Autowired
private StatisticsService statisticsService;
@ApiOperation(value = "首页数据统计")
@GetMapping(value = "/statistics")
public AjaxResult statistics() {
return success(statisticsService.homeStatistics());
}
}
......@@ -10,7 +10,6 @@ import share.common.core.domain.BaseEntity;
* @create: 2023-11-07 16:10
*/
@Data
public class DeviceParamVo extends BaseEntity {
/** 设备mac */
......
package share.system.domain.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @className: share.system.domain.vo.HomeStatistics
* @description: 首页统计
* @author: lwj
* @create: 2024-01-10 10:00
*/
@Data
public class HomeStatistics implements Serializable {
@ApiModelProperty(value = "门店id")
private Long storeId;
@ApiModelProperty(value = "门店名称")
private String storeName;
@ApiModelProperty(value = "订单总数")
private Integer orderNum;
@ApiModelProperty(value = "待使用/使用中订单数")
private Integer orderNumWait;
@ApiModelProperty(value = "已完成订单数")
private Integer orderNumFinish;
@ApiModelProperty(value = "退款订单数")
private Integer orderNumRefund;
@ApiModelProperty(value = "套餐金额-全部订单")
private BigDecimal packPrice;
@ApiModelProperty(value = "套餐金额-待使用/使用中")
private BigDecimal packPriceWait;
@ApiModelProperty(value = "套餐金额-已完成订单")
private BigDecimal packPriceFinish;
@ApiModelProperty(value = "套餐金额-退款订单")
private BigDecimal packPriceRefund;
@ApiModelProperty(name = "优惠券金额-全部订单")
private BigDecimal couponPrice;
@ApiModelProperty(value = "优惠券金额-待使用/使用中")
private BigDecimal couponPriceWait;
@ApiModelProperty(value = "优惠券金额-已完成订单")
private BigDecimal couponPriceFinish;
@ApiModelProperty(value = "优惠券金额-退款订单")
private BigDecimal couponPriceRefund;
@ApiModelProperty(name = "订单总价-全部订单")
private BigDecimal totalPrice;
@ApiModelProperty(value = "订单总价-待使用/使用中")
private BigDecimal totalPriceWait;
@ApiModelProperty(value = "订单总价-已完成订单")
private BigDecimal totalPriceFinish;
@ApiModelProperty(value = "订单总价-退款订单")
private BigDecimal totalPriceRefund;
@ApiModelProperty(name = "实际支付金额-全部订单")
private BigDecimal payPrice;
@ApiModelProperty(value = "实际支付金额-待使用/使用中")
private BigDecimal payPriceWait;
@ApiModelProperty(value = "实际支付金额-已完成订单")
private BigDecimal payPriceFinish;
@ApiModelProperty(value = "实际支付金额-退款订单")
private BigDecimal payPriceRefund;
}
package share.system.mapper;
import share.system.domain.vo.HomeStatistics;
import java.util.List;
/**
* @className: share.system.mapper.StatisticsMapper
* @description: 数据统计
* @author: lwj
* @create: 2024-01-10 10:37
*/
public interface StatisticsMapper {
List<HomeStatistics> homeStatistics();
}
package share.system.service;
import share.system.domain.vo.HomeStatistics;
import java.util.List;
/**
* @className: share.system.service.StatisticsService
* @description: 报表统计
* @author: lwj
* @create: 2024-01-10 10:32
*/
public interface StatisticsService {
List<HomeStatistics> homeStatistics();
}
package share.system.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import share.system.domain.vo.HomeStatistics;
import share.system.mapper.StatisticsMapper;
import share.system.service.StatisticsService;
import java.util.List;
/**
* @className: share.system.service.impl.StatisticsServiceImpl
* @description: 报表统计
* @author: lwj
* @create: 2024-01-10 10:33
*/
@Service
public class StatisticsServiceImpl implements StatisticsService {
@Autowired
private StatisticsMapper statisticsMapper;
@Override
public List<HomeStatistics> homeStatistics() {
return statisticsMapper.homeStatistics();
}
}
<?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="share.system.mapper.StatisticsMapper">
<select id="homeStatistics" resultType="share.system.domain.vo.HomeStatistics">
select so.store_id as storeId, ss.name as storeName,
count(0) as orderNum,
sum(case when so.status in (0,1) then 1 else 0 end) as orderNumWait,
sum(case when so.status in (2) then 1 else 0 end) as orderNumFinish,
sum(case when so.status in (3) then 1 else 0 end) as orderNumRefund,
sum(so.pay_price) as payPrice,
sum(case when so.status in (0,1) then so.pay_price else 0 end) as payPriceWait,
sum(case when so.status in (2) then so.pay_price else 0 end) as payPriceFinish,
sum(case when so.status in (3) then so.pay_price else 0 end) as payPriceRefund,
sum(so.pack_price) as packPrice,
sum(case when so.status in (0,1) then so.pack_price else 0 end) as packPriceWait,
sum(case when so.status in (2) then so.pack_price else 0 end) as packPriceFinish,
sum(case when so.status in (3) then so.pack_price else 0 end) as packPriceRefund,
sum(so.coupon_price) as couponPrice,
sum(case when so.status in (0,1) then so.coupon_price else 0 end) as couponPriceWait,
sum(case when so.status in (2) then so.coupon_price else 0 end) as couponPriceFinish,
sum(case when so.status in (3) then so.coupon_price else 0 end) as couponPriceRefund,
sum(so.total_price) as totalPrice,
sum(case when so.status in (0,1) then so.total_price else 0 end) as totalPriceWait,
sum(case when so.status in (2) then so.total_price else 0 end) as totalPriceFinish,
sum(case when so.status in (3) then so.total_price else 0 end) as totalPriceRefund
from s_order so inner join s_store ss on so.store_id = ss.id
where pay_status in (1) group by so.store_id, ss.name
</select>
</mapper>
\ No newline at end of file
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