xuhy
2024-09-11 9ca97fd558700e7054c5f54192a9db7a1e6b8230
完善导出等接口
5个文件已添加
18个文件已修改
897 ■■■■ 已修改文件
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TDataGeneratorController.java 79 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TDataStatisticsController.java 177 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TOrderSaleController.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/domain/TOrderStock.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/domain/TOrderStockGoods.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/export/MealGeneratorListExport.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/export/SaleGeneratorListExport.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/export/TOrderStockExportExcel.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TOrderMealMapper.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TOrderSaleMapper.java 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/query/ProfitDetailsQuery.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/query/TDataGeneratorQuery.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/TOrderMealService.java 25 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/TOrderSaleService.java 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/TOrderStockService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TOrderMealServiceImpl.java 82 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TOrderSaleServiceImpl.java 91 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TOrderStockServiceImpl.java 34 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/vo/GoodsProfitVO.java 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/vo/ProfitDetailsVO.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/TOrderMealMapper.xml 118 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/TOrderSaleMapper.xml 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/TOrderStockMapper.xml 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TDataGeneratorController.java
@@ -14,9 +14,7 @@
import com.ruoyi.system.domain.TOrderStockGoods;
import com.ruoyi.system.dto.OrderMealGeneratorDTO;
import com.ruoyi.system.dto.OrderSaleGeneratorDTO;
import com.ruoyi.system.export.TOrderMealExportExcel;
import com.ruoyi.system.export.TOrderSaleAndGoodsExportExcel;
import com.ruoyi.system.export.TOrderStockExportExcel;
import com.ruoyi.system.export.*;
import com.ruoyi.system.query.TDataGeneratorMealQuery;
import com.ruoyi.system.query.TDataGeneratorQuery;
import com.ruoyi.system.query.TDataGeneratorSaleQuery;
@@ -214,7 +212,6 @@
        for (TOrderStockVO orderStockVO : list) {
            TOrderStockExportExcel orderStockExportExcel = new TOrderStockExportExcel();
            BeanUtils.copyProperties(orderStockVO, orderStockExportExcel);
            orderStockExportExcel.setGoodsAmount(orderStockVO.getOrderStockGoods().stream().map(TOrderStockGoods::getSalePrice).reduce(BigDecimal::add).get());
            orderStockExportExcel.setStockTime(DateUtils.localDateToString(orderStockVO.getStockTime()));
            orderStockExportExcels.add(orderStockExportExcel);
        }
@@ -224,7 +221,7 @@
        response.setCharacterEncoding("utf-8");
        ServletOutputStream outputStream = null;
        try {
            String fileName = URLEncoder.encode("销售生成列表.xls", "utf-8");
            String fileName = URLEncoder.encode("进货生成列表.xls", "utf-8");
            response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
            response.setContentType("application/vnd.ms-excel;charset=UTF-8");
            response.setHeader("Pragma", "no-cache");
@@ -242,6 +239,78 @@
        }
    }
    @ApiOperation( value = "餐饮数据生成列表导出")
    @PostMapping(value = "/mealGeneratorListExport")
    public void mealGeneratorListExport(@RequestBody TDataGeneratorQuery query) {
        List<TDataGeneratorVO> list = orderMealService.mealGeneratorListExport(query);
        List<MealGeneratorListExport> mealGeneratorListExports = new ArrayList<>();
        for (TDataGeneratorVO dataGeneratorVO : list) {
            MealGeneratorListExport mealGeneratorListExport = new MealGeneratorListExport();
            BeanUtils.copyProperties(dataGeneratorVO, mealGeneratorListExport);
            mealGeneratorListExport.setGeneratorTime(DateUtils.localDateTimeToString(dataGeneratorVO.getCreateTime()));
            mealGeneratorListExport.setStartTimeStr(DateUtils.localDateToString(dataGeneratorVO.getStartTime()) + " ~ " + DateUtils.localDateToString(dataGeneratorVO.getEndTime()));
            mealGeneratorListExport.setRevenueRange(dataGeneratorVO.getMinMoney() + " ~ " + dataGeneratorVO.getMaxMoney());
            mealGeneratorListExports.add(mealGeneratorListExport);
        }
        Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), MealGeneratorListExport.class, mealGeneratorListExports);
        HttpServletResponse response = WebUtils.response();
        response.setContentType("application/vnd.ms-excel");
        response.setCharacterEncoding("utf-8");
        ServletOutputStream outputStream = null;
        try {
            String fileName = URLEncoder.encode("餐饮数据生成列表.xls", "utf-8");
            response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
            response.setContentType("application/vnd.ms-excel;charset=UTF-8");
            response.setHeader("Pragma", "no-cache");
            response.setHeader("Cache-Control", "no-cache");
            outputStream = response.getOutputStream();
            workbook.write(outputStream);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                outputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    @ApiOperation( value = "销售数据生成列表导出")
    @PostMapping(value = "/saleGeneratorListExport")
    public void saleGeneratorListExport(@RequestBody TDataGeneratorQuery query) {
        List<TDataGeneratorVO> list = orderSaleService.saleGeneratorListExport(query);
        List<SaleGeneratorListExport> saleGeneratorListExports = new ArrayList<>();
        for (TDataGeneratorVO dataGeneratorVO : list) {
            SaleGeneratorListExport saleGeneratorListExport = new SaleGeneratorListExport();
            BeanUtils.copyProperties(dataGeneratorVO, saleGeneratorListExport);
            saleGeneratorListExport.setGeneratorTime(DateUtils.localDateTimeToString(dataGeneratorVO.getCreateTime()));
            saleGeneratorListExport.setStartTimeStr(DateUtils.localDateToString(dataGeneratorVO.getStartTime()) + " ~ " + DateUtils.localDateToString(dataGeneratorVO.getEndTime()));
            saleGeneratorListExports.add(saleGeneratorListExport);
        }
        Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), SaleGeneratorListExport.class, saleGeneratorListExports);
        HttpServletResponse response = WebUtils.response();
        response.setContentType("application/vnd.ms-excel");
        response.setCharacterEncoding("utf-8");
        ServletOutputStream outputStream = null;
        try {
            String fileName = URLEncoder.encode("销售数据生成列表.xls", "utf-8");
            response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
            response.setContentType("application/vnd.ms-excel;charset=UTF-8");
            response.setHeader("Pragma", "no-cache");
            response.setHeader("Cache-Control", "no-cache");
            outputStream = response.getOutputStream();
            workbook.write(outputStream);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                outputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TDataStatisticsController.java
@@ -1,22 +1,33 @@
package com.ruoyi.web.controller.api;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.WebUtils;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.export.SaleGeneratorListExport;
import com.ruoyi.system.query.ProfitDetailsQuery;
import com.ruoyi.system.query.TDataGeneratorQuery;
import com.ruoyi.system.query.TDataStatisticsQuery;
import com.ruoyi.system.service.TOrderMealService;
import com.ruoyi.system.service.TOrderSaleService;
import com.ruoyi.system.vo.OrderTrendsVO;
import com.ruoyi.system.vo.PersonnelStatisticsVO;
import com.ruoyi.system.vo.SalesRankingVO;
import com.ruoyi.system.vo.SalesVolumeVO;
import com.ruoyi.system.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -58,23 +69,23 @@
        switch (query.getTimeType()){
            case 1:
                // 今日
                startTime = LocalDateTime.MIN;
                endTime = LocalDateTime.MAX;
                startTime = DateUtils.getDayStart(LocalDateTime.now());
                endTime = DateUtils.getDayEnd(LocalDateTime.now());
                break;
            case 2:
                // 昨日
                startTime = LocalDateTime.now().minusDays(1);
                endTime = LocalDateTime.now().minusDays(1);
                startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(1));
                endTime = DateUtils.getDayEnd(LocalDateTime.now().minusDays(1));
                break;
            case 3:
                // 近7天
                startTime = LocalDateTime.now().minusDays(7);
                endTime = LocalDateTime.now();
                startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(7));
                endTime = DateUtils.getDayEnd(LocalDateTime.now());
                break;
            case 4:
                // 近30天
                startTime = LocalDateTime.now().minusDays(30);
                endTime = LocalDateTime.now();
                startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(30));
                endTime = DateUtils.getDayEnd(LocalDateTime.now());
                break;
        }
        query.setStartTime(DateUtils.localDateTimeToDate(startTime));
@@ -86,6 +97,100 @@
            salesVolumeVO = orderSaleService.salesVolume(query);
        }
        return AjaxResult.success(salesVolumeVO);
    }
    @ApiOperation( value = "盈利明细")
    @PostMapping(value = "/profitDetails")
    public AjaxResult<ProfitDetailsVO> profitDetails(@RequestBody ProfitDetailsQuery query) {
        Long objectId = tokenService.getLoginUser().getObjectId();
        query.setShopId(objectId);
        if(Objects.nonNull(query.getTimeType())){
            LocalDateTime startTime = null;
            LocalDateTime endTime = null;
            switch (query.getTimeType()){
                case 1:
                    // 今日
                    startTime = DateUtils.getDayStart(LocalDateTime.now());
                    endTime = DateUtils.getDayEnd(LocalDateTime.now());
                    break;
                case 2:
                    // 昨日
                    startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(1));
                    endTime = DateUtils.getDayEnd(LocalDateTime.now().minusDays(1));
                    break;
                case 3:
                    // 近7天
                    startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(7));
                    endTime = DateUtils.getDayEnd(LocalDateTime.now());
                    break;
                case 4:
                    // 近30天
                    startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(30));
                    endTime = DateUtils.getDayEnd(LocalDateTime.now());
                    break;
            }
            query.setStartTime(DateUtils.localDateTimeToDate(startTime));
            query.setEndTime(DateUtils.localDateTimeToDate(endTime));
        }
        return AjaxResult.success(orderMealService.profitDetails(query));
    }
    @ApiOperation( value = "盈利明细导出")
    @PostMapping(value = "/profitDetailsExport")
    public void profitDetailsExport(@RequestBody ProfitDetailsQuery query) {
        Long objectId = tokenService.getLoginUser().getObjectId();
        query.setShopId(objectId);
        if(Objects.nonNull(query.getTimeType())){
            LocalDateTime startTime = null;
            LocalDateTime endTime = null;
            switch (query.getTimeType()){
                case 1:
                    // 今日
                    startTime = DateUtils.getDayStart(LocalDateTime.now());
                    endTime = DateUtils.getDayEnd(LocalDateTime.now());
                    break;
                case 2:
                    // 昨日
                    startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(1));
                    endTime = DateUtils.getDayEnd(LocalDateTime.now().minusDays(1));
                    break;
                case 3:
                    // 近7天
                    startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(7));
                    endTime = DateUtils.getDayEnd(LocalDateTime.now());
                    break;
                case 4:
                    // 近30天
                    startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(30));
                    endTime = DateUtils.getDayEnd(LocalDateTime.now());
                    break;
            }
            query.setStartTime(DateUtils.localDateTimeToDate(startTime));
            query.setEndTime(DateUtils.localDateTimeToDate(endTime));
        }
        List<GoodsProfitVO> list  = orderMealService.profitDetailsExport(query);
        Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), GoodsProfitVO.class, list);
        HttpServletResponse response = WebUtils.response();
        response.setContentType("application/vnd.ms-excel");
        response.setCharacterEncoding("utf-8");
        ServletOutputStream outputStream = null;
        try {
            String fileName = URLEncoder.encode("盈利明细.xls", "utf-8");
            response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
            response.setContentType("application/vnd.ms-excel;charset=UTF-8");
            response.setHeader("Pragma", "no-cache");
            response.setHeader("Cache-Control", "no-cache");
            outputStream = response.getOutputStream();
            workbook.write(outputStream);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                outputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    @ApiOperation( value = "商品分类销售排行")
@@ -102,23 +207,23 @@
        switch (query.getTimeType()){
            case 1:
                // 今日
                startTime = LocalDateTime.MIN;
                endTime = LocalDateTime.MAX;
                startTime = DateUtils.getDayStart(LocalDateTime.now());
                endTime = DateUtils.getDayEnd(LocalDateTime.now());
                break;
            case 2:
                // 昨日
                startTime = LocalDateTime.now().minusDays(1);
                endTime = LocalDateTime.now().minusDays(1);
                startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(1));
                endTime = DateUtils.getDayEnd(LocalDateTime.now().minusDays(1));
                break;
            case 3:
                // 近7天
                startTime = LocalDateTime.now().minusDays(7);
                endTime = LocalDateTime.now();
                startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(7));
                endTime = DateUtils.getDayEnd(LocalDateTime.now());
                break;
            case 4:
                // 近30天
                startTime = LocalDateTime.now().minusDays(30);
                endTime = LocalDateTime.now();
                startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(30));
                endTime = DateUtils.getDayEnd(LocalDateTime.now());
                break;
        }
        query.setStartTime(DateUtils.localDateTimeToDate(startTime));
@@ -146,23 +251,23 @@
        switch (query.getTimeType()){
            case 1:
                // 今日
                startTime = LocalDateTime.MIN;
                endTime = LocalDateTime.MAX;
                startTime = DateUtils.getDayStart(LocalDateTime.now());
                endTime = DateUtils.getDayEnd(LocalDateTime.now());
                break;
            case 2:
                // 昨日
                startTime = LocalDateTime.now().minusDays(1);
                endTime = LocalDateTime.now().minusDays(1);
                startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(1));
                endTime = DateUtils.getDayEnd(LocalDateTime.now().minusDays(1));
                break;
            case 3:
                // 近7天
                startTime = LocalDateTime.now().minusDays(7);
                endTime = LocalDateTime.now();
                startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(7));
                endTime = DateUtils.getDayEnd(LocalDateTime.now());
                break;
            case 4:
                // 近30天
                startTime = LocalDateTime.now().minusDays(30);
                endTime = LocalDateTime.now();
                startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(30));
                endTime = DateUtils.getDayEnd(LocalDateTime.now());
                break;
        }
        query.setStartTime(DateUtils.localDateTimeToDate(startTime));
@@ -189,23 +294,23 @@
        switch (query.getTimeType()){
            case 1:
                // 今日
                startTime = LocalDateTime.MIN;
                endTime = LocalDateTime.MAX;
                startTime = DateUtils.getDayStart(LocalDateTime.now());
                endTime = DateUtils.getDayEnd(LocalDateTime.now());
                break;
            case 2:
                // 昨日
                startTime = LocalDateTime.now().minusDays(1);
                endTime = LocalDateTime.now().minusDays(1);
                startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(1));
                endTime = DateUtils.getDayEnd(LocalDateTime.now().minusDays(1));
                break;
            case 3:
                // 近7天
                startTime = LocalDateTime.now().minusDays(7);
                endTime = LocalDateTime.now();
                startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(7));
                endTime = DateUtils.getDayEnd(LocalDateTime.now());
                break;
            case 4:
                // 近30天
                startTime = LocalDateTime.now().minusDays(30);
                endTime = LocalDateTime.now();
                startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(30));
                endTime = DateUtils.getDayEnd(LocalDateTime.now());
                break;
        }
        query.setStartTime(DateUtils.localDateTimeToDate(startTime));
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TOrderSaleController.java
@@ -115,6 +115,16 @@
        return AjaxResult.success();
    }
    /**
     * 销售下单接口
     */
    @ApiOperation( value = "销售单修改接口")
    @PostMapping(value = "/edit")
    public AjaxResult<String> edit(@RequestBody TOrderSaleDTO dto) {
        orderSaleService.edit(dto);
        return AjaxResult.success();
    }
    @ApiOperation( value = "结账接口")
    @PostMapping(value = "/checkout")
    public AjaxResult<String> checkout(@Validated @RequestBody CheckoutDTO dto) {
ruoyi-system/src/main/java/com/ruoyi/system/domain/TOrderStock.java
@@ -42,9 +42,9 @@
    @TableField("stockTime")
    private LocalDate stockTime;
//    @ApiModelProperty(value = "进货总价")
//    @TableField("stockTotalPrice")
//    private BigDecimal stockTotalPrice;
    @ApiModelProperty(value = "进货总价")
    @TableField("stockTotalPrice")
    private BigDecimal stockTotalPrice;
    @ApiModelProperty(value = "是否覆盖 1=是 0=否")
    @TableField("isCover")
    private Integer isCover;
ruoyi-system/src/main/java/com/ruoyi/system/domain/TOrderStockGoods.java
@@ -46,7 +46,6 @@
    private String goodsName;
    @ApiModelProperty(value = "成本价")
    @Excel(name = "进货价格",width = 15)
    @TableField("costPrice")
    private BigDecimal costPrice;
@@ -55,6 +54,7 @@
    private BigDecimal salePrice;
    @ApiModelProperty(value = "本次进货价格")
    @Excel(name = "进货价格",width = 15)
    @TableField("thisSalePrice")
    private BigDecimal thisSalePrice;
ruoyi-system/src/main/java/com/ruoyi/system/export/MealGeneratorListExport.java
New file
@@ -0,0 +1,34 @@
package com.ruoyi.system.export;
import cn.afterturn.easypoi.excel.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
public class MealGeneratorListExport implements Serializable {
    @Excel(name = "营业数据生成时间",width = 30)
    private String generatorTime;
    @Excel(name = "操作人",width = 30)
    private String userName;
    @Excel(name = "店铺名称",width = 30)
    private String shopName;
    @Excel(name = "覆盖时间段",width = 30)
    private String startTimeStr;
    @Excel(name = "营业额范围",width = 30)
    private String revenueRange;
    @Excel(name = "生成营业额合计(元)",width = 30)
    private BigDecimal totalRevenue;
    @Excel(name = "状态",width = 30,replace = {"生成中_1","待覆盖_2","已覆盖_3"})
    private Integer status;
}
ruoyi-system/src/main/java/com/ruoyi/system/export/SaleGeneratorListExport.java
New file
@@ -0,0 +1,29 @@
package com.ruoyi.system.export;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
public class SaleGeneratorListExport implements Serializable {
    @Excel(name = "营业数据生成时间",width = 30)
    private String generatorTime;
    @Excel(name = "操作人",width = 30)
    private String userName;
    @Excel(name = "店铺名称",width = 30)
    private String shopName;
    @Excel(name = "覆盖时间段",width = 30)
    private String startTimeStr;
    @Excel(name = "生成营业额合计(元)",width = 30)
    private BigDecimal totalRevenue;
    @Excel(name = "状态",width = 30,replace = {"生成中_1","待覆盖_2","已覆盖_3"})
    private Integer status;
}
ruoyi-system/src/main/java/com/ruoyi/system/export/TOrderStockExportExcel.java
@@ -24,6 +24,6 @@
    private List<TOrderStockGoods> orderStockGoods;
    @Excel(width = 30,name = "商品总价",needMerge = true)
    private BigDecimal goodsAmount;
    private BigDecimal stockTotalPrice;
}
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TOrderMealMapper.java
@@ -3,9 +3,7 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.system.domain.TOrderMeal;
import com.ruoyi.system.query.TDataGeneratorMealQuery;
import com.ruoyi.system.query.TDataStatisticsQuery;
import com.ruoyi.system.query.TOrderMealQuery;
import com.ruoyi.system.query.*;
import com.ruoyi.system.vo.*;
import org.apache.ibatis.annotations.Param;
@@ -88,4 +86,33 @@
     * @return
     */
    List<TOrderMealVO> mealGeneratorExport(@Param("query")TDataGeneratorMealQuery query);
    /**
     * 导出数据生成列表
     * @param query
     * @return
     */
    List<TDataGeneratorVO> mealGeneratorListExport(@Param("query")TDataGeneratorQuery query);
    /**
     * 盈利明细分页
     * @param query
     * @param pageInfo
     * @return
     */
    List<GoodsProfitVO> profitDetails(@Param("query") ProfitDetailsQuery query, @Param("pageInfo")PageInfo<GoodsProfitVO> pageInfo);
    /**
     * 统计商品金额
     * @param query
     * @return
     */
    Map<String, BigDecimal> profitDetailsStatistics(@Param("query")ProfitDetailsQuery query);
    /**
     * 导出盈利明细
     * @param query
     * @return
     */
    List<GoodsProfitVO> profitDetailsExport(@Param("query")ProfitDetailsQuery query);
}
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TOrderSaleMapper.java
@@ -3,14 +3,8 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.system.domain.TOrderSale;
import com.ruoyi.system.query.TDataGeneratorSaleQuery;
import com.ruoyi.system.query.TDataStatisticsQuery;
import com.ruoyi.system.query.TOrderMealQuery;
import com.ruoyi.system.query.TOrderSaleQuery;
import com.ruoyi.system.vo.AmountSumVO;
import com.ruoyi.system.vo.OrderTrendsVO;
import com.ruoyi.system.vo.SalesVolumeVO;
import com.ruoyi.system.vo.TOrderSaleVO;
import com.ruoyi.system.query.*;
import com.ruoyi.system.vo.*;
import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
@@ -76,4 +70,11 @@
     * @return
     */
    List<TOrderSaleVO> saleGeneratorExport(@Param("query")TDataGeneratorSaleQuery query);
    /**
     * 销售生成数据详情导出
     * @param query
     * @return
     */
    List<TDataGeneratorVO> saleGeneratorListExport(@Param("query")TDataGeneratorQuery query);
}
ruoyi-system/src/main/java/com/ruoyi/system/query/ProfitDetailsQuery.java
New file
@@ -0,0 +1,22 @@
package com.ruoyi.system.query;
import com.ruoyi.common.core.domain.model.TimeRangeQueryBody;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "营业数据统计营业明细Query")
public class ProfitDetailsQuery extends TimeRangeQueryBody {
    @ApiModelProperty(value = "时间类型 1=今日 2=昨日 3=近7天 4=近30天")
    private Integer timeType;
    @ApiModelProperty(value = "店铺id")
    private Long shopId;
    @ApiModelProperty(value = "分类id")
    private Long typeId;
    @ApiModelProperty(value = "商品名称")
    private String goodsName;
}
ruoyi-system/src/main/java/com/ruoyi/system/query/TDataGeneratorQuery.java
@@ -6,6 +6,7 @@
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.List;
@Data
@ApiModel(value = "数据生成分页")
@@ -19,5 +20,7 @@
    @ApiModelProperty(value = "订单类型 1=餐饮 2=销售")
    @NotNull(message = "订单类型不能为空")
    private Integer orderType;
    @ApiModelProperty(value = "id集合")
    private List<Long> ids;
}
ruoyi-system/src/main/java/com/ruoyi/system/service/TOrderMealService.java
@@ -7,9 +7,7 @@
import com.ruoyi.system.dto.CheckoutDTO;
import com.ruoyi.system.dto.OrderMealGeneratorDTO;
import com.ruoyi.system.dto.TOrderMealDTO;
import com.ruoyi.system.query.TDataGeneratorMealQuery;
import com.ruoyi.system.query.TDataStatisticsQuery;
import com.ruoyi.system.query.TOrderMealQuery;
import com.ruoyi.system.query.*;
import com.ruoyi.system.vo.*;
import java.math.BigDecimal;
@@ -120,4 +118,25 @@
     * @param dto
     */
    void startMeal(TOrderMeal dto);
    /**
     * 餐饮数据生成列表导出
     * @param query
     * @return
     */
    List<TDataGeneratorVO> mealGeneratorListExport(TDataGeneratorQuery query);
    /**
     * 盈利明细
     * @param query
     * @return
     */
    ProfitDetailsVO profitDetails(ProfitDetailsQuery query);
    /**
     * 盈利明细导出
     * @param query
     * @return
     */
    List<GoodsProfitVO> profitDetailsExport(ProfitDetailsQuery query);
}
ruoyi-system/src/main/java/com/ruoyi/system/service/TOrderSaleService.java
@@ -5,10 +5,7 @@
import com.ruoyi.system.domain.TOrderSale;
import com.ruoyi.system.dto.CheckoutDTO;
import com.ruoyi.system.dto.TOrderSaleDTO;
import com.ruoyi.system.query.TDataGeneratorSaleQuery;
import com.ruoyi.system.query.TDataStatisticsQuery;
import com.ruoyi.system.query.TOrderMealQuery;
import com.ruoyi.system.query.TOrderSaleQuery;
import com.ruoyi.system.query.*;
import com.ruoyi.system.vo.*;
import java.math.BigDecimal;
@@ -92,4 +89,17 @@
     * @param dto
     */
    void checkout(CheckoutDTO dto);
    /**
     * 修改订单
     * @param dto
     */
    void edit(TOrderSaleDTO dto);
    /**
     * 销售数据生成列表导出
     * @param query
     * @return
     */
    List<TDataGeneratorVO> saleGeneratorListExport(TDataGeneratorQuery query);
}
ruoyi-system/src/main/java/com/ruoyi/system/service/TOrderStockService.java
@@ -5,8 +5,10 @@
import com.ruoyi.system.domain.TOrderStock;
import com.ruoyi.system.dto.TOrderSaleDTO;
import com.ruoyi.system.dto.TOrderStockDTO;
import com.ruoyi.system.query.TDataGeneratorQuery;
import com.ruoyi.system.query.TDataGeneratorStockQuery;
import com.ruoyi.system.query.TOrderStockQuery;
import com.ruoyi.system.vo.TDataGeneratorVO;
import com.ruoyi.system.vo.TOrderStockVO;
import java.util.List;
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TOrderMealServiceImpl.java
@@ -11,9 +11,7 @@
import com.ruoyi.system.dto.*;
import com.ruoyi.system.mapper.TOrderMealGoodsMapper;
import com.ruoyi.system.mapper.TOrderMealMapper;
import com.ruoyi.system.query.TDataGeneratorMealQuery;
import com.ruoyi.system.query.TDataStatisticsQuery;
import com.ruoyi.system.query.TOrderMealQuery;
import com.ruoyi.system.query.*;
import com.ruoyi.system.service.*;
import com.ruoyi.system.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
@@ -164,23 +162,23 @@
            switch (query.getTimeType()){
                case 1:
                    // 今日
                    startTime = LocalDateTime.MIN;
                    endTime = LocalDateTime.MAX;
                    startTime = DateUtils.getDayStart(LocalDateTime.now());
                    endTime = DateUtils.getDayEnd(LocalDateTime.now());
                    break;
                case 2:
                    // 昨日
                    startTime = LocalDateTime.now().minusDays(1);
                    endTime = LocalDateTime.now().minusDays(1);
                    startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(1));
                    endTime = DateUtils.getDayEnd(LocalDateTime.now().minusDays(1));
                    break;
                case 3:
                    // 近7天
                    startTime = LocalDateTime.now().minusDays(7);
                    endTime = LocalDateTime.now();
                    startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(7));
                    endTime = DateUtils.getDayEnd(LocalDateTime.now());
                    break;
                case 4:
                    // 近30天
                    startTime = LocalDateTime.now().minusDays(30);
                    endTime = LocalDateTime.now();
                    startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(30));
                    endTime = DateUtils.getDayEnd(LocalDateTime.now());
                    break;
            }
            query.setStartTime(DateUtils.localDateTimeToDate(startTime));
@@ -258,23 +256,23 @@
            switch (query.getTimeType()){
                case 1:
                    // 今日
                    startTime = LocalDateTime.MIN;
                    endTime = LocalDateTime.MAX;
                    startTime = DateUtils.getDayStart(LocalDateTime.now());
                    endTime = DateUtils.getDayEnd(LocalDateTime.now());
                    break;
                case 2:
                    // 昨日
                    startTime = LocalDateTime.now().minusDays(1);
                    endTime = LocalDateTime.now().minusDays(1);
                    startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(1));
                    endTime = DateUtils.getDayEnd(LocalDateTime.now().minusDays(1));
                    break;
                case 3:
                    // 近7天
                    startTime = LocalDateTime.now().minusDays(7);
                    endTime = LocalDateTime.now();
                    startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(7));
                    endTime = DateUtils.getDayEnd(LocalDateTime.now());
                    break;
                case 4:
                    // 近30天
                    startTime = LocalDateTime.now().minusDays(30);
                    endTime = LocalDateTime.now();
                    startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(30));
                    endTime = DateUtils.getDayEnd(LocalDateTime.now());
                    break;
            }
            query.setStartTime(DateUtils.localDateTimeToDate(startTime));
@@ -365,4 +363,50 @@
        this.save(dto);
    }
    @Override
    public List<TDataGeneratorVO> mealGeneratorListExport(TDataGeneratorQuery query) {
        List<TDataGeneratorVO> list = this.baseMapper.mealGeneratorListExport(query);
        List<Long> ids = list.stream().map(TDataGeneratorVO::getId).collect(Collectors.toList());
        if(CollectionUtils.isEmpty(ids)){
            return new ArrayList<>();
        }
        List<TOrderMeal> orderMeals = this.list(Wrappers.lambdaQuery(TOrderMeal.class)
                .in(TOrderMeal::getGeneratorId, ids));
        List<Long> mealIds = orderMeals.stream().map(TOrderMeal::getId).collect(Collectors.toList());
        if(!CollectionUtils.isEmpty(mealIds)){
            List<TOrderMealGoods> mealGoods = orderMealGoodsService.list(Wrappers.lambdaQuery(TOrderMealGoods.class)
                    .in(TOrderMealGoods::getOrderId, mealIds));
            for (TDataGeneratorVO tDataGeneratorVO : list) {
                List<Long> collect = orderMeals.stream().filter(e -> e.getGeneratorId().equals(tDataGeneratorVO.getId())).map(TOrderMeal::getId).collect(Collectors.toList());
                BigDecimal money = mealGoods.stream().filter(e -> collect.contains(e.getOrderId()))
                        .reduce(BigDecimal.ZERO, (x, y) -> x.add(y.getGoodsSalePrice().multiply(new BigDecimal(y.getGoodsCount()))), BigDecimal::add);
                tDataGeneratorVO.setTotalRevenue(money);
            }
        }
        return list;
    }
    @Override
    public ProfitDetailsVO profitDetails(ProfitDetailsQuery query) {
        ProfitDetailsVO profitDetailsVO = new ProfitDetailsVO();
        // 查询商品盈利明细
        PageInfo<GoodsProfitVO> pageInfo = new PageInfo<>(query.getPageNum(),query.getPageSize());
        List<GoodsProfitVO> list = this.baseMapper.profitDetails(query,pageInfo);
        pageInfo.setRecords(list);
        profitDetailsVO.setGoodsProfitVOS(pageInfo);
        // 统计商品金额
        Map<String,BigDecimal> map = this.baseMapper.profitDetailsStatistics(query);
        profitDetailsVO.setTotalProfits(new BigDecimal(map.get("totalProfits").toString()));
        profitDetailsVO.setTotalCosts(new BigDecimal(map.get("totalCosts").toString()));
        profitDetailsVO.setTotalSales(new BigDecimal(map.get("totalSales").toString()));
        return profitDetailsVO;
    }
    @Override
    public List<GoodsProfitVO> profitDetailsExport(ProfitDetailsQuery query) {
        return this.baseMapper.profitDetailsExport(query);
    }
}
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TOrderSaleServiceImpl.java
@@ -10,10 +10,7 @@
import com.ruoyi.system.dto.CheckoutDTO;
import com.ruoyi.system.dto.TOrderSaleDTO;
import com.ruoyi.system.mapper.TOrderSaleMapper;
import com.ruoyi.system.query.TDataGeneratorSaleQuery;
import com.ruoyi.system.query.TDataStatisticsQuery;
import com.ruoyi.system.query.TOrderMealQuery;
import com.ruoyi.system.query.TOrderSaleQuery;
import com.ruoyi.system.query.*;
import com.ruoyi.system.service.TGoodsService;
import com.ruoyi.system.service.TGoodsTypeService;
import com.ruoyi.system.service.TOrderSaleGoodsService;
@@ -58,8 +55,6 @@
        List<TOrderSaleGoods> orderSaleGoods = dto.getOrderSaleGoods();
        BigDecimal sum = orderSaleGoods.stream().map(TOrderSaleGoods::getGoodsSalePrice).reduce(BigDecimal::add).get();
        dto.setOrderMoney(sum);
        BigDecimal sum1 = orderSaleGoods.stream().map(TOrderSaleGoods::getThisSalePrice).reduce(BigDecimal::add).get();
        dto.setPayMoney(sum1);
        this.save(dto);
        // 添加商品
        orderSaleGoods.forEach(orderSaleGoods1 -> {
@@ -77,23 +72,23 @@
            switch (query.getTimeType()){
                case 1:
                    // 今日
                    startTime = LocalDateTime.MIN;
                    endTime = LocalDateTime.MAX;
                    startTime = DateUtils.getDayStart(LocalDateTime.now());
                    endTime = DateUtils.getDayEnd(LocalDateTime.now());
                    break;
                case 2:
                    // 昨日
                    startTime = LocalDateTime.now().minusDays(1);
                    endTime = LocalDateTime.now().minusDays(1);
                    startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(1));
                    endTime = DateUtils.getDayEnd(LocalDateTime.now().minusDays(1));
                    break;
                case 3:
                    // 近7天
                    startTime = LocalDateTime.now().minusDays(7);
                    endTime = LocalDateTime.now();
                    startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(7));
                    endTime = DateUtils.getDayEnd(LocalDateTime.now());
                    break;
                case 4:
                    // 近30天
                    startTime = LocalDateTime.now().minusDays(30);
                    endTime = LocalDateTime.now();
                    startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(30));
                    endTime = DateUtils.getDayEnd(LocalDateTime.now());
                    break;
            }
            query.setStartTime(DateUtils.localDateTimeToDate(startTime));
@@ -169,23 +164,23 @@
            switch (query.getTimeType()){
                case 1:
                    // 今日
                    startTime = LocalDateTime.MIN;
                    endTime = LocalDateTime.MAX;
                    startTime = DateUtils.getDayStart(LocalDateTime.now());
                    endTime = DateUtils.getDayEnd(LocalDateTime.now());
                    break;
                case 2:
                    // 昨日
                    startTime = LocalDateTime.now().minusDays(1);
                    endTime = LocalDateTime.now().minusDays(1);
                    startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(1));
                    endTime = DateUtils.getDayEnd(LocalDateTime.now().minusDays(1));
                    break;
                case 3:
                    // 近7天
                    startTime = LocalDateTime.now().minusDays(7);
                    endTime = LocalDateTime.now();
                    startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(7));
                    endTime = DateUtils.getDayEnd(LocalDateTime.now());
                    break;
                case 4:
                    // 近30天
                    startTime = LocalDateTime.now().minusDays(30);
                    endTime = LocalDateTime.now();
                    startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(30));
                    endTime = DateUtils.getDayEnd(LocalDateTime.now());
                    break;
            }
            query.setStartTime(DateUtils.localDateTimeToDate(startTime));
@@ -221,23 +216,23 @@
            switch (query.getTimeType()){
                case 1:
                    // 今日
                    startTime = LocalDateTime.MIN;
                    endTime = LocalDateTime.MAX;
                    startTime = DateUtils.getDayStart(LocalDateTime.now());
                    endTime = DateUtils.getDayEnd(LocalDateTime.now());
                    break;
                case 2:
                    // 昨日
                    startTime = LocalDateTime.now().minusDays(1);
                    endTime = LocalDateTime.now().minusDays(1);
                    startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(1));
                    endTime = DateUtils.getDayEnd(LocalDateTime.now().minusDays(1));
                    break;
                case 3:
                    // 近7天
                    startTime = LocalDateTime.now().minusDays(7);
                    endTime = LocalDateTime.now();
                    startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(7));
                    endTime = DateUtils.getDayEnd(LocalDateTime.now());
                    break;
                case 4:
                    // 近30天
                    startTime = LocalDateTime.now().minusDays(30);
                    endTime = LocalDateTime.now();
                    startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(30));
                    endTime = DateUtils.getDayEnd(LocalDateTime.now());
                    break;
            }
            query.setStartTime(DateUtils.localDateTimeToDate(startTime));
@@ -263,4 +258,40 @@
        orderSale.setStatus(2);
        this.updateById(orderSale);
    }
    @Override
    public void edit(TOrderSaleDTO dto) {
        // 销售单号
        List<TOrderSaleGoods> orderSaleGoods = dto.getOrderSaleGoods();
        BigDecimal sum = orderSaleGoods.stream().map(TOrderSaleGoods::getGoodsSalePrice).reduce(BigDecimal::add).get();
        dto.setOrderMoney(sum);
        this.updateById(dto);
        // 删除商品
        orderSaleGoodsService.remove(Wrappers.lambdaQuery(TOrderSaleGoods.class)
                .eq(TOrderSaleGoods::getOrderId,dto.getId()));
        // 添加商品
        orderSaleGoods.forEach(orderSaleGoods1 -> {
            orderSaleGoods1.setOrderId(dto.getId());
            orderSaleGoods1.setId(null);
        });
        orderSaleGoodsService.saveBatch(orderSaleGoods);
    }
    @Override
    public List<TDataGeneratorVO> saleGeneratorListExport(TDataGeneratorQuery query) {
        List<TDataGeneratorVO> list = this.baseMapper.saleGeneratorListExport(query);
        List<Long> ids = list.stream().map(TDataGeneratorVO::getId).collect(Collectors.toList());
        if(CollectionUtils.isEmpty(ids)){
            return new ArrayList<>();
        }
        List<TOrderSale> orderSales = this.list(Wrappers.lambdaQuery(TOrderSale.class)
                .in(TOrderSale::getGeneratorId, ids));
        for (TDataGeneratorVO tDataGeneratorVO : list) {
            if(!CollectionUtils.isEmpty(orderSales)){
                BigDecimal money = orderSales.stream().map(TOrderSale::getPayMoney).reduce(BigDecimal::add).get();
                tDataGeneratorVO.setTotalRevenue(money);
            }
        }
        return list;
    }
}
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TOrderStockServiceImpl.java
@@ -12,10 +12,12 @@
import com.ruoyi.system.dto.TOrderSaleDTO;
import com.ruoyi.system.dto.TOrderStockDTO;
import com.ruoyi.system.mapper.TOrderStockMapper;
import com.ruoyi.system.query.TDataGeneratorQuery;
import com.ruoyi.system.query.TDataGeneratorStockQuery;
import com.ruoyi.system.query.TOrderStockQuery;
import com.ruoyi.system.service.TOrderStockGoodsService;
import com.ruoyi.system.service.TOrderStockService;
import com.ruoyi.system.vo.TDataGeneratorVO;
import com.ruoyi.system.vo.TOrderStockVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -84,23 +86,23 @@
            switch (query.getTimeType()){
                case 1:
                    // 今日
                    startTime = LocalDateTime.MIN;
                    endTime = LocalDateTime.MAX;
                    startTime = DateUtils.getDayStart(LocalDateTime.now());
                    endTime = DateUtils.getDayEnd(LocalDateTime.now());
                    break;
                case 2:
                    // 昨日
                    startTime = LocalDateTime.now().minusDays(1);
                    endTime = LocalDateTime.now().minusDays(1);
                    startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(1));
                    endTime = DateUtils.getDayEnd(LocalDateTime.now().minusDays(1));
                    break;
                case 3:
                    // 近7天
                    startTime = LocalDateTime.now().minusDays(7);
                    endTime = LocalDateTime.now();
                    startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(7));
                    endTime = DateUtils.getDayEnd(LocalDateTime.now());
                    break;
                case 4:
                    // 近30天
                    startTime = LocalDateTime.now().minusDays(30);
                    endTime = LocalDateTime.now();
                    startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(30));
                    endTime = DateUtils.getDayEnd(LocalDateTime.now());
                    break;
            }
            query.setStartTime(DateUtils.localDateTimeToDate(startTime));
@@ -138,23 +140,23 @@
            switch (query.getTimeType()){
                case 1:
                    // 今日
                    startTime = LocalDateTime.MIN;
                    endTime = LocalDateTime.MAX;
                    startTime = DateUtils.getDayStart(LocalDateTime.now());
                    endTime = DateUtils.getDayEnd(LocalDateTime.now());
                    break;
                case 2:
                    // 昨日
                    startTime = LocalDateTime.now().minusDays(1);
                    endTime = LocalDateTime.now().minusDays(1);
                    startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(1));
                    endTime = DateUtils.getDayEnd(LocalDateTime.now().minusDays(1));
                    break;
                case 3:
                    // 近7天
                    startTime = LocalDateTime.now().minusDays(7);
                    endTime = LocalDateTime.now();
                    startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(7));
                    endTime = DateUtils.getDayEnd(LocalDateTime.now());
                    break;
                case 4:
                    // 近30天
                    startTime = LocalDateTime.now().minusDays(30);
                    endTime = LocalDateTime.now();
                    startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(30));
                    endTime = DateUtils.getDayEnd(LocalDateTime.now());
                    break;
            }
            query.setStartTime(DateUtils.localDateTimeToDate(startTime));
ruoyi-system/src/main/java/com/ruoyi/system/vo/GoodsProfitVO.java
New file
@@ -0,0 +1,38 @@
package com.ruoyi.system.vo;
import cn.afterturn.easypoi.excel.annotation.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
@ApiModel(value = "商品盈利明细")
public class GoodsProfitVO implements Serializable {
    @ApiModelProperty(value = "商品分类")
    @Excel(name = "商品分类",width = 30)
    private String typeName;
    @ApiModelProperty(value = "商品名称")
    @Excel(name = "商品名称",width = 30)
    private String goodsName;
    @ApiModelProperty(value = "商品销售数量")
    @Excel(name = "商品销售数量",width = 30)
    private Integer totalSalesCount;
    @ApiModelProperty(value = "商品成本")
    @Excel(name = "商品成本",width = 30)
    private BigDecimal goodsCostAmount;
    @ApiModelProperty(value = "商品售价")
    @Excel(name = "商品售价",width = 30)
    private BigDecimal goodsSaleAmount;
    @ApiModelProperty(value = "商品盈利")
    @Excel(name = "商品盈利",width = 30)
    private BigDecimal goodsProfitAmount;
}
ruoyi-system/src/main/java/com/ruoyi/system/vo/ProfitDetailsVO.java
New file
@@ -0,0 +1,28 @@
package com.ruoyi.system.vo;
import com.ruoyi.common.basic.PageInfo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
@Data
@ApiModel(value = "盈利明细")
public class ProfitDetailsVO implements Serializable {
    @ApiModelProperty(value = "总销售额")
    private BigDecimal totalSales;
    @ApiModelProperty(value = "总成本")
    private BigDecimal totalCosts;
    @ApiModelProperty(value = "总盈利")
    private BigDecimal totalProfits;
    @ApiModelProperty(value = "商品盈利明细")
    private PageInfo<GoodsProfitVO> goodsProfitVOS;
}
ruoyi-system/src/main/resources/mapper/system/TOrderMealMapper.xml
@@ -230,5 +230,123 @@
        </where>
        ORDER BY tom.createTime DESC
    </select>
    <select id="mealGeneratorListExport" resultType="com.ruoyi.system.vo.TDataGeneratorVO">
        select tdg.id, tdg.userId, tdg.userName, tdg.shopId, tdg.startTime, tdg.endTime, tdg.minMoney, tdg.maxMoney, tdg.status, tdg.createTime,
        tdg.updateTime, tdg.disabled, tdg.createBy, tdg.updateBy,tdg.orderType,tdg.weiXinPay,tdg.aliPay,tdg.cardPay,tdg.moneyPay,tdg.otherPay,
        ts.shopName
        from t_data_generator tdg
        left join t_shop ts on tdg.shopId = ts.id
        <where>
            <if test="query.shopName != null and query.shopName != ''">
                and ts.shopName like concat('%', #{query.shopName}, '%')
            </if>
            <if test="query.userName != null and query.userName != ''">
                and tdg.shopName like concat('%', #{query.userName}, '%')
            </if>
            <if test="query.status != null">
                and tdg.status = #{query.status}
            </if>
            <if test="query.ids != null and query.ids.size()>0">
                and tdg.id IN
                <foreach collection="query.ids" item="id" open="(" separator="," close=")">
                    #{id}
                </foreach>
            </if>
            <if test="query.orderType != null">
                and tdg.orderType = #{query.orderType}
            </if>
            <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''">
                AND (tdg.createTime BETWEEN #{query.startTime} AND #{query.endTime})
            </if>
            AND tdg.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
            and tdg.orderType = 1
        </where>
    </select>
    <select id="profitDetails" resultType="com.ruoyi.system.vo.GoodsProfitVO">
        SELECT
        tomg.goodsName,
        tomg.typeName,
        IFNULL(SUM( tomg.goodsCount ),0) AS totalSalesCount,
        IFNULL(SUM( tomg.goodsCount * tomg.goodsSalePrice ),0) AS goodsSaleAmount,
        IFNULL(SUM( tomg.goodsCount * tomg.costPrice ),0) AS goodsCostAmount,
        IFNULL(SUM(tomg.goodsCount *(tomg.goodsSalePrice - tomg.costPrice)),0) AS goodsProfitAmount
        FROM t_order_meal_goods tomg
        LEFT JOIN t_order_meal tom ON tom.id = tomg.orderId
        <where>
            <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''">
                AND (tom.createTime BETWEEN #{query.startTime} AND #{query.endTime})
            </if>
            <if test="query.goodsName != null and query.goodsName != ''">
                AND tomg.goodsName like concat('%', #{query.goodsName}, '%')
            </if>
            <if test="query.typeId != null and query.typeId != ''">
                AND tomg.typeId = #{query.typeId}
            </if>
            <if test="query.shopId != null">
                AND tom.shopId = #{query.shopId}
            </if>
            AND tom.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
        </where>
        GROUP BY tomg.goodsName
    </select>
    <select id="profitDetailsStatistics" resultType="java.util.Map">
        SELECT
        IFNULL(SUM(a.goodsSaleAmount),0) AS totalSales,
        IFNULL(SUM(a.goodsCostAmount),0) AS totalCosts,
        IFNULL(SUM(a.goodsProfitAmount),0) AS totalProfits
        FROM (
        SELECT
        tomg.goodsName,
        tomg.typeName,
        IFNULL(SUM( tomg.goodsCount ),0) AS totalSalesCount,
        IFNULL(SUM( tomg.goodsCount * tomg.goodsSalePrice ),0) AS goodsSaleAmount,
        IFNULL(SUM( tomg.goodsCount * tomg.costPrice ),0) AS goodsCostAmount,
        IFNULL(SUM(tomg.goodsCount *(tomg.goodsSalePrice - tomg.costPrice)),0) AS goodsProfitAmount
        FROM t_order_meal_goods tomg
        LEFT JOIN t_order_meal tom ON tom.id = tomg.orderId
        <where>
            <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''">
                AND (tom.createTime BETWEEN #{query.startTime} AND #{query.endTime})
            </if>
            <if test="query.goodsName != null and query.goodsName != ''">
                AND tomg.goodsName like concat('%', #{query.goodsName}, '%')
            </if>
            <if test="query.typeId != null and query.typeId != ''">
                AND tomg.typeId = #{query.typeId}
            </if>
            <if test="query.shopId != null">
                AND tom.shopId = #{query.shopId}
            </if>
            AND tom.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
        </where>
        GROUP BY tomg.goodsName) a
    </select>
    <select id="profitDetailsExport" resultType="com.ruoyi.system.vo.GoodsProfitVO">
        SELECT
        tomg.goodsName,
        tomg.typeName,
        IFNULL(SUM( tomg.goodsCount ),0) AS totalSalesCount,
        IFNULL(SUM( tomg.goodsCount * tomg.goodsSalePrice ),0) AS goodsSaleAmount,
        IFNULL(SUM( tomg.goodsCount * tomg.costPrice ),0) AS goodsCostAmount,
        IFNULL(SUM(tomg.goodsCount *(tomg.goodsSalePrice - tomg.costPrice)),0) AS goodsProfitAmount
        FROM t_order_meal_goods tomg
        LEFT JOIN t_order_meal tom ON tom.id = tomg.orderId
        <where>
            <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''">
                AND (tom.createTime BETWEEN #{query.startTime} AND #{query.endTime})
            </if>
            <if test="query.goodsName != null and query.goodsName != ''">
                AND tomg.goodsName like concat('%', #{query.goodsName}, '%')
            </if>
            <if test="query.typeId != null and query.typeId != ''">
                AND tomg.typeId = #{query.typeId}
            </if>
            <if test="query.shopId != null">
                AND tom.shopId = #{query.shopId}
            </if>
            AND tom.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
        </where>
        GROUP BY tomg.goodsName
    </select>
</mapper>
ruoyi-system/src/main/resources/mapper/system/TOrderSaleMapper.xml
@@ -133,7 +133,7 @@
            AND disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
        </where>
    </select>
    <select id="getDataGeneratorMealDetail" resultType="java.util.Map">
    <select id="getDataGeneratorSaleDetail" resultType="java.util.Map">
        SELECT
       IFNULL(SUM(CASE WHEN payType = 1 THEN payMoney ELSE 0 END),0) AS moneyPay,
       IFNULL(SUM(CASE WHEN payType = 2 THEN payMoney ELSE 0 END),0) AS aliPay,
@@ -177,5 +177,37 @@
        </where>
        ORDER BY orderTime DESC
    </select>
    <select id="saleGeneratorListExport" resultType="com.ruoyi.system.vo.TDataGeneratorVO">
        select tdg.id, tdg.userId, tdg.userName, tdg.shopId, tdg.startTime, tdg.endTime, tdg.minMoney, tdg.maxMoney, tdg.status, tdg.createTime,
        tdg.updateTime, tdg.disabled, tdg.createBy, tdg.updateBy,tdg.orderType,tdg.weiXinPay,tdg.aliPay,tdg.cardPay,tdg.moneyPay,tdg.otherPay,
        ts.shopName
        from t_data_generator tdg
        left join t_shop ts on tdg.shopId = ts.id
        <where>
            <if test="query.shopName != null and query.shopName != ''">
                and ts.shopName like concat('%', #{query.shopName}, '%')
            </if>
            <if test="query.userName != null and query.userName != ''">
                and tdg.shopName like concat('%', #{query.userName}, '%')
            </if>
            <if test="query.status != null">
                and tdg.status = #{query.status}
            </if>
            <if test="query.ids != null and query.ids.size()>0">
                and tdg.id IN
                <foreach collection="query.ids" item="id" open="(" separator="," close=")">
                    #{id}
                </foreach>
            </if>
            <if test="query.orderType != null">
                and tdg.orderType = #{query.orderType}
            </if>
            <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''">
                AND (tdg.createTime BETWEEN #{query.startTime} AND #{query.endTime})
            </if>
            AND tdg.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
            and tdg.orderType = 2
        </where>
    </select>
</mapper>
ruoyi-system/src/main/resources/mapper/system/TOrderStockMapper.xml
@@ -15,11 +15,12 @@
        <result column="isCover" property="isCover" />
        <result column="shopId" property="shopId" />
        <result column="generatorId" property="generatorId" />
        <result column="stockTotalPrice" property="stockTotalPrice" />
    </resultMap>
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, stockNum, stockTime, createTime, updateTime, disabled, createBy, updateBy,isCover,shopId,generatorId
        id, stockNum, stockTime, createTime, updateTime, disabled, createBy, updateBy,isCover,shopId,generatorId,stockTotalPrice
    </sql>
    <select id="pageList" resultType="com.ruoyi.system.vo.TOrderStockVO">
        SELECT <include refid="Base_Column_List"></include>
@@ -43,12 +44,12 @@
    </select>
    <select id="getDataGeneratorStockDetail" resultType="java.util.Map">
        SELECT
        SUM(payMoney) AS stockAmountSum,
        IFNULL(SUM(stockTotalPrice),0) AS stockAmountSum,
        COUNT(id) AS totalStock
        from t_order_stock
        <where>
            <if test="query.stockNum != null and query.stockNum != ''">
                AND stockNum LIKE concat('%',#{query.stockNum},'%')
            <if test="query.orderNum != null and query.orderNum != ''">
                AND stockNum LIKE concat('%',#{query.orderNum},'%')
            </if>
            <if test="query.generatorId != null">
                AND generatorId = #{query.generatorId}
@@ -63,8 +64,8 @@
        SELECT <include refid="Base_Column_List"></include>
        FROM t_order_stock
        <where>
            <if test="query.stockNum != null and query.stockNum != ''">
                AND stockNum LIKE concat('%',#{query.stockNum},'%')
            <if test="query.orderNum != null and query.orderNum != ''">
                AND stockNum LIKE concat('%',#{query.orderNum},'%')
            </if>
            <if test="query.generatorId != null">
                AND generatorId = #{query.generatorId}