ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/FinanceController.java
New file @@ -0,0 +1,44 @@ package com.ruoyi.web.controller.system; import com.ruoyi.system.mapper.WithdrawMapper; import com.ruoyi.system.service.WithdrawService; import io.swagger.annotations.Api; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; @Slf4j @RestController @RequestMapping("/system/finance") @Api( tags = "后台-财务管理") public class FinanceController { @Resource private WithdrawService withdrawService; /** * 财务流水-顶部 */ /** * 财务流水-分页 */ /** * 提现申请-分页 */ /** * 同意 */ /** * 拒绝 */ } ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/IndexController.java
New file @@ -0,0 +1,81 @@ package com.ruoyi.web.controller.system; import com.ruoyi.common.core.domain.R; import com.ruoyi.system.pojo.dto.AddLicenceDTO; import com.ruoyi.system.pojo.vo.IndexLineChartVO; import com.ruoyi.system.pojo.vo.QichachaStatisticsVO; import com.ruoyi.system.pojo.vo.TodayStatisticsVO; import com.ruoyi.system.service.OrderService; import com.ruoyi.system.service.QichachaService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import javafx.scene.chart.Chart; import lombok.extern.slf4j.Slf4j; import org.apache.poi.ss.formula.functions.Index; import org.springframework.format.annotation.DateTimeFormat; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.validation.Valid; import java.time.LocalDate; import java.time.temporal.ChronoUnit; @Slf4j @RestController @RequestMapping("/system/index") @Api( tags = "后台-首页统计") public class IndexController { @Resource private OrderService orderService; @Resource private QichachaService qichachaService; /** * 接口统计 */ @GetMapping("/qichacha") @ApiOperation(value = "接口统计") @PreAuthorize("@ss.hasPermi('index:manage')") public R<QichachaStatisticsVO> qichacha() { return R.ok( qichachaService.qichacha()); } /** * 收入统计 - 今日入账 */ @GetMapping("/today") @ApiOperation(value = "收入统计-今日入账") @PreAuthorize("@ss.hasPermi('index:manage')") public R<TodayStatisticsVO> today() { return R.ok( orderService.today()); } /** * 折线图 */ @GetMapping("/chart") @ApiOperation(value = "收入统计-折线图") @PreAuthorize("@ss.hasPermi('index:manage')") public R<IndexLineChartVO> chart(@RequestParam(required = false, defaultValue = "7") Integer days, @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd ") LocalDate startDate, @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate endDate) { // 处理日期范围 LocalDate now = LocalDate.now(); if (startDate == null || endDate == null) { startDate = now.minusDays(days - 1); endDate = now; } else { // 验证日期范围不超过30天 long daysBetween = ChronoUnit.DAYS.between(startDate, endDate); if (daysBetween > 30) { endDate = startDate.plusDays(30); } } return R.ok(orderService.chart(startDate,endDate)); } } ruoyi-system/src/main/java/com/ruoyi/system/domain/Qichacha.java
New file @@ -0,0 +1,25 @@ package com.ruoyi.system.domain; import com.baomidou.mybatisplus.annotation.*; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.Date; @Data @TableName("tb_qichacha") @ApiModel(value = "企查查三方接口调用记录表") public class Qichacha { @TableId(type = IdType.AUTO) @ApiModelProperty(value = "主键ID") private Integer id; @TableField("type") @ApiModelProperty(value = "查询类型(1=基础查询,2=异常查询)", example = "1") private Integer type; @TableField(value = "time") @ApiModelProperty(value = "调用时间") private Date time; } ruoyi-system/src/main/java/com/ruoyi/system/mapper/OrderMapper.java
@@ -5,12 +5,16 @@ import com.ruoyi.system.domain.Agreement; import com.ruoyi.system.domain.Order; import com.ruoyi.system.pojo.dto.OrderPageDTO; import com.ruoyi.system.pojo.model.DailyStatistics; import com.ruoyi.system.pojo.vo.OrderDetailVO; import com.ruoyi.system.pojo.vo.OrderPageVO; import com.ruoyi.system.pojo.vo.TodayStatisticsVO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.List; @Mapper public interface OrderMapper extends BaseMapper<Order> { @@ -19,4 +23,8 @@ IPage<OrderPageVO> getOrderPage(@Param("page")IPage<OrderPageVO> page,@Param("dto") OrderPageDTO dto); OrderDetailVO getDetailById(@Param("id")String id); TodayStatisticsVO today(@Param("startTime")LocalDateTime startTime,@Param("endTime") LocalDateTime endTime); List<DailyStatistics> getDailyStatistics(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime); } ruoyi-system/src/main/java/com/ruoyi/system/mapper/QichachaMapper.java
New file @@ -0,0 +1,12 @@ package com.ruoyi.system.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.system.domain.Agreement; import com.ruoyi.system.domain.Qichacha; import com.ruoyi.system.pojo.vo.QichachaStatisticsVO; import org.apache.ibatis.annotations.Mapper; @Mapper public interface QichachaMapper extends BaseMapper<Qichacha> { QichachaStatisticsVO qichacha(); } ruoyi-system/src/main/java/com/ruoyi/system/mapper/WithdrawMapper.java
New file @@ -0,0 +1,10 @@ package com.ruoyi.system.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.system.domain.AccountDetail; import com.ruoyi.system.domain.Withdrawal; import org.apache.ibatis.annotations.Mapper; @Mapper public interface WithdrawMapper extends BaseMapper<Withdrawal> { } ruoyi-system/src/main/java/com/ruoyi/system/pojo/model/DailyStatistics.java
New file @@ -0,0 +1,16 @@ package com.ruoyi.system.pojo.model; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import java.math.BigDecimal; @Data @NoArgsConstructor @AllArgsConstructor public class DailyStatistics { private String date; // 日期(格式:yyyy-MM-dd) private BigDecimal totalPrice; // 订单总金额 private BigDecimal platformCommission; // 平台分佣总金额 } ruoyi-system/src/main/java/com/ruoyi/system/pojo/vo/IndexLineChartVO.java
New file @@ -0,0 +1,21 @@ package com.ruoyi.system.pojo.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import org.w3c.dom.stylesheets.LinkStyle; import java.math.BigDecimal; import java.time.LocalDate; import java.util.List; @Data @ApiModel("主页折线图VO") public class IndexLineChartVO { @ApiModelProperty("总收入") private List<BigDecimal> totalList; @ApiModelProperty("平台利润") private List<BigDecimal> profitList; @ApiModelProperty("日期(yyyy-MM-dd)") private List<LocalDate> days; } ruoyi-system/src/main/java/com/ruoyi/system/pojo/vo/QichachaStatisticsVO.java
New file @@ -0,0 +1,19 @@ package com.ruoyi.system.pojo.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data @ApiModel("企查查调用接口次数") public class QichachaStatisticsVO { @ApiModelProperty("基础-调用总次数") private Integer baseTotal; @ApiModelProperty("基础-今日调用次数") private Integer baseToday; @ApiModelProperty("异常-调用总次数") private Integer exceptionTotal; @ApiModelProperty("异常-今日调用次数") private Integer exceptionToday; } ruoyi-system/src/main/java/com/ruoyi/system/pojo/vo/TodayStatisticsVO.java
New file @@ -0,0 +1,17 @@ package com.ruoyi.system.pojo.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; @Data @ApiModel("今日统计VO") public class TodayStatisticsVO { @ApiModelProperty("今日入账") private BigDecimal total = new BigDecimal("0.00"); @ApiModelProperty("今日利润") private BigDecimal profit = new BigDecimal("0.00"); } ruoyi-system/src/main/java/com/ruoyi/system/service/OrderService.java
@@ -10,6 +10,8 @@ import com.ruoyi.system.pojo.dto.OrderPageDTO; import com.ruoyi.system.pojo.vo.*; import java.time.LocalDate; public interface OrderService extends IService<Order> { @@ -34,4 +36,8 @@ void cancel(String id); R refundPayMoneyCallback(RefundCallbackResult refundCallbackResult); TodayStatisticsVO today(); IndexLineChartVO chart(LocalDate startDate, LocalDate endDate); } ruoyi-system/src/main/java/com/ruoyi/system/service/QichachaService.java
New file @@ -0,0 +1,12 @@ package com.ruoyi.system.service; import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.system.domain.Agreement; import com.ruoyi.system.domain.Qichacha; import com.ruoyi.system.pojo.dto.AddAgreementDTO; import com.ruoyi.system.pojo.vo.QichachaStatisticsVO; public interface QichachaService extends IService<Qichacha> { QichachaStatisticsVO qichacha(); } ruoyi-system/src/main/java/com/ruoyi/system/service/WithdrawService.java
New file @@ -0,0 +1,11 @@ package com.ruoyi.system.service; import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.system.domain.Agreement; import com.ruoyi.system.domain.Withdrawal; import com.ruoyi.system.pojo.dto.AddAgreementDTO; public interface WithdrawService extends IService<Withdrawal> { } ruoyi-system/src/main/java/com/ruoyi/system/service/WithdrawServiceImpl.java
New file @@ -0,0 +1,19 @@ package com.ruoyi.system.service; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.system.domain.Agreement; import com.ruoyi.system.domain.Withdrawal; import com.ruoyi.system.mapper.AgreementMapper; import com.ruoyi.system.mapper.WithdrawMapper; import com.ruoyi.system.pojo.dto.AddAgreementDTO; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; @Service public class WithdrawServiceImpl extends ServiceImpl<WithdrawMapper, Withdrawal> implements WithdrawService { } ruoyi-system/src/main/java/com/ruoyi/system/service/impl/OrderServiceImpl.java
@@ -1,5 +1,6 @@ package com.ruoyi.system.service.impl; import com.alibaba.fastjson2.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -13,20 +14,25 @@ import com.ruoyi.system.mapper.*; import com.ruoyi.system.pojo.dto.AddAgreementDTO; import com.ruoyi.system.pojo.dto.OrderPageDTO; import com.ruoyi.system.pojo.model.DailyStatistics; import com.ruoyi.system.pojo.model.DrawSheet; import com.ruoyi.system.pojo.vo.*; import com.ruoyi.system.service.AgreementService; import com.ruoyi.system.service.OrderService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.math.BigDecimal; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; import java.util.Optional; @Slf4j @Service @@ -45,6 +51,8 @@ private ScheduleMapper scheduleMapper; @Resource private CompanyMapper companyMapper; @Autowired private SystemConfigMapper systemConfigMapper; @Override public IPage<OrderPageVO> getOrderPage(OrderPageDTO dto) { @@ -276,7 +284,6 @@ this.updateById(order); return R.ok(); } /** * 返回订单支付金额 */ @@ -294,4 +301,49 @@ return R.ok(); } @Override public TodayStatisticsVO today() { LocalDateTime startTime = LocalDate.now().atStartOfDay(); LocalDateTime endTime =LocalDate.now().atTime(23, 59, 59); return this.baseMapper.today(startTime, endTime); } @Override public IndexLineChartVO chart(LocalDate startDate, LocalDate endDate) { // 查询数据库 List<DailyStatistics> statisticsList = this.baseMapper.getDailyStatistics( startDate.atStartOfDay(), endDate.atTime(23, 59, 59) ); // 构建返回对象 IndexLineChartVO vo = new IndexLineChartVO(); vo.setDays(new ArrayList<>()); vo.setTotalList(new ArrayList<>()); vo.setProfitList(new ArrayList<>()); // 按日期顺序填充数据 LocalDate currentDate = startDate; while (!currentDate.isAfter(endDate)) { String dateStr = currentDate.format(DateTimeFormatter.ISO_LOCAL_DATE); vo.getDays().add(currentDate); // 查找当天数据,若无则默认为0 Optional<DailyStatistics> statOptional = statisticsList.stream() .filter(s -> s.getDate().equals(dateStr)) .findFirst(); DailyStatistics stat = statOptional.orElse( new DailyStatistics(dateStr, BigDecimal.ZERO, BigDecimal.ZERO) ); vo.getTotalList().add(stat.getTotalPrice()); vo.getProfitList().add(stat.getPlatformCommission()); currentDate = currentDate.plusDays(1); } return vo; } } ruoyi-system/src/main/java/com/ruoyi/system/service/impl/QichachaServiceImpl.java
New file @@ -0,0 +1,27 @@ package com.ruoyi.system.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.system.domain.Agreement; import com.ruoyi.system.domain.Qichacha; import com.ruoyi.system.mapper.AgreementMapper; import com.ruoyi.system.mapper.QichachaMapper; import com.ruoyi.system.pojo.dto.AddAgreementDTO; import com.ruoyi.system.pojo.vo.QichachaStatisticsVO; import com.ruoyi.system.service.AgreementService; import com.ruoyi.system.service.QichachaService; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; @Service public class QichachaServiceImpl extends ServiceImpl<QichachaMapper, Qichacha> implements QichachaService { @Override public QichachaStatisticsVO qichacha() { return this.baseMapper.qichacha(); } } ruoyi-system/src/main/resources/mapper/system/OrderMapper.xml
@@ -174,4 +174,25 @@ </select> <select id="today" resultType="com.ruoyi.system.pojo.vo.TodayStatisticsVO"> select ifnull(sum(price),0.00)as total, ifnull(sum(commission_platform),0.00) as profit from tb_order where status in (4,5,6) -- 4办理中 5卖家已完成 6买家完成 and pay_time between #{startTime} and #{endTime} </select> <select id="getDailyStatistics" resultType="com.ruoyi.system.pojo.model.DailyStatistics"> SELECT DATE_FORMAT(pay_time, '%Y-%m-%d') as `date`, ifnull(SUM(price),0.00) as totalPrice, ifnull(SUM(commission_platform),0.00) as platformCommission FROM tb_order WHERE pay_time BETWEEN #{startTime} AND #{endTime} AND status IN (4, 5, 6) GROUP BY DATE(pay_time) ORDER BY DATE(pay_time) ASC </select> </mapper> ruoyi-system/src/main/resources/mapper/system/QichachaMapper.xml
New file @@ -0,0 +1,14 @@ <?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.ruoyi.system.mapper.QichachaMapper"> <select id="qichacha" resultType="com.ruoyi.system.pojo.vo.QichachaStatisticsVO"> SELECT ifnull(SUM(CASE WHEN type = 1 THEN 1 ELSE 0 END) ,0)AS baseTotal, ifnull(SUM(CASE WHEN type = 1 AND DATE(time) = CURDATE() THEN 1 ELSE 0 END) ,0)AS baseToday, ifnull(SUM(CASE WHEN type = 2 THEN 1 ELSE 0 END) ,0)AS exceptionTotal, ifnull(SUM(CASE WHEN type = 2 AND DATE(time) = CURDATE() THEN 1 ELSE 0 END) ,0)AS exceptionToday FROM tb_qichacha; </select> </mapper> ruoyi-system/src/main/resources/mapper/system/WithdrawMapper.xml
New file @@ -0,0 +1,6 @@ <?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.ruoyi.system.mapper.WithdrawMapper"> </mapper>