桌台统计添加收银台

This commit is contained in:
yijiegong 2024-08-22 16:20:20 +08:00
parent beea5e902c
commit 2a6c54ba47
4 changed files with 20 additions and 24 deletions

View File

@ -2,13 +2,10 @@ package cn.ysk.cashier.controller.shop;
import cn.ysk.cashier.annotation.rest.AnonymousGetMapping;
import cn.ysk.cashier.annotation.rest.AnonymousPostMapping;
import cn.ysk.cashier.dto.ShopSummaryDto;
import cn.ysk.cashier.dto.shop.ShopTableSeleInfoDto;
import cn.ysk.cashier.dto.shop.ShopTableSaleInfoDto;
import cn.ysk.cashier.service.SummaryService;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -68,8 +65,8 @@ public class SummaryController {
@PostMapping("/table/download")
@AnonymousPostMapping
private void downloadShopSummaryTable(HttpServletResponse response, @RequestBody ShopTableSeleInfoDto exportRequest) throws IOException {
summaryService.downloadTableSeleInfo(exportRequest, response);
private void downloadShopSummaryTable(HttpServletResponse response, @RequestBody ShopTableSaleInfoDto exportRequest) throws IOException {
summaryService.downloadTableSaleInfo(exportRequest, response);
}
}

View File

@ -9,7 +9,7 @@ import java.util.Date;
* @author GYJ
*/
@Data
public class ShopTableSeleInfoDto {
public class ShopTableSaleInfoDto {
private Integer shopId;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date startTime;

View File

@ -1,7 +1,7 @@
package cn.ysk.cashier.service;
import cn.ysk.cashier.dto.ShopSummaryDto;
import cn.ysk.cashier.dto.shop.ShopTableSeleInfoDto;
import cn.ysk.cashier.dto.shop.ShopTableSaleInfoDto;
import cn.ysk.cashier.vo.ShopTableSaleInfoVo;
import cn.ysk.cashier.vo.SummaryVO;
import cn.ysk.cashier.vo.TbOrderPayCountVo;
@ -41,5 +41,5 @@ public interface SummaryService {
List<ShopTableSaleInfoVo> selectSummaryTable(Integer shopId, Date startTime, Date endTime);
void downloadTableSeleInfo(ShopTableSeleInfoDto shopTableSeleInfoDto, HttpServletResponse response) throws IOException;
void downloadTableSaleInfo(ShopTableSaleInfoDto shopTableSaleInfoDto, HttpServletResponse response) throws IOException;
}

View File

@ -1,7 +1,7 @@
package cn.ysk.cashier.service.impl;
import cn.ysk.cashier.dto.ShopSummaryDto;
import cn.ysk.cashier.dto.shop.ShopTableSeleInfoDto;
import cn.ysk.cashier.dto.shop.ShopTableSaleInfoDto;
import cn.ysk.cashier.enums.PayTypeEnum;
import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.mybatis.service.TbShopUserFlowService;
@ -15,8 +15,6 @@ import cn.ysk.cashier.service.SummaryService;
import cn.ysk.cashier.utils.DateUtil;
import cn.ysk.cashier.utils.FileUtil;
import cn.ysk.cashier.vo.*;
import com.alibaba.fastjson.JSONObject;
import com.beust.ah.A;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
@ -37,7 +35,6 @@ import java.time.Instant;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -543,29 +540,31 @@ public class SummaryServiceImpl implements SummaryService {
}
@Override
public void downloadTableSeleInfo(ShopTableSeleInfoDto shopTableSeleInfoDto, HttpServletResponse response) throws IOException {
if (shopTableSeleInfoDto.getStartTime() == null) {
shopTableSeleInfoDto.setStartTime(DateUtil.toDate(DateUtil.fromTimeStamp(1704038400L)));
public void downloadTableSaleInfo(ShopTableSaleInfoDto shopTableSaleInfoDto, HttpServletResponse response) throws IOException {
if (shopTableSaleInfoDto.getStartTime() == null) {
shopTableSaleInfoDto.setStartTime(DateUtil.toDate(DateUtil.fromTimeStamp(1704038400L)));
}
if (shopTableSeleInfoDto.getEndTime() == null) {
shopTableSeleInfoDto.setEndTime(new Date());
if (shopTableSaleInfoDto.getEndTime() == null) {
shopTableSaleInfoDto.setEndTime(new Date());
}
List<ShopTableSaleInfoVo> infoVos = selectSummaryTable(shopTableSeleInfoDto.getShopId(), shopTableSeleInfoDto.getStartTime(), shopTableSeleInfoDto.getEndTime());
List<ShopTableSaleInfoVo> infoVos = selectSummaryTable(shopTableSaleInfoDto.getShopId(), shopTableSaleInfoDto.getStartTime(), shopTableSaleInfoDto.getEndTime());
List<TbOrderSalesCountByTable> countByTables = tbOrderDetailRepository.queryTbOrderSalesCountByTable(shopTableSeleInfoDto.getShopId(), shopTableSeleInfoDto.getStartTime(), shopTableSeleInfoDto.getEndTime());
infoVos.add(new ShopTableSaleInfoVo(99999, shopTableSaleInfoDto.getShopId(), null, "", "收银台", null, null, null, null));
List<TbOrderSalesCountByTable> countByTables = tbOrderDetailRepository.queryTbOrderSalesCountByTable(shopTableSaleInfoDto.getShopId(), shopTableSaleInfoDto.getStartTime(), shopTableSaleInfoDto.getEndTime());
Map<String, List<TbOrderSalesCountByTable>> countByTableMap = countByTables.stream()
.collect(Collectors.groupingBy(TbOrderSalesCountByTable::getTableId));
// 比较 shopTableSeleInfoDto startTime endTime 是不是同一天
boolean sameDay = cn.hutool.core.date.DateUtil.isSameDay(shopTableSeleInfoDto.getStartTime(), shopTableSeleInfoDto.getEndTime());
// 比较 shopTableSaleInfoDto startTime endTime 是不是同一天
boolean sameDay = cn.hutool.core.date.DateUtil.isSameDay(shopTableSaleInfoDto.getStartTime(), shopTableSaleInfoDto.getEndTime());
String queryDate = cn.hutool.core.date.DateUtil.format(shopTableSeleInfoDto.getStartTime(), "yyyy-MM-dd");
String queryDate = cn.hutool.core.date.DateUtil.format(shopTableSaleInfoDto.getStartTime(), "yyyy-MM-dd");
if (!sameDay) {
queryDate += "" + cn.hutool.core.date.DateUtil.format(shopTableSeleInfoDto.getEndTime(), "yyyy-MM-dd");
queryDate += "" + cn.hutool.core.date.DateUtil.format(shopTableSaleInfoDto.getEndTime(), "yyyy-MM-dd");
}
List<Map<String, Object>> list = new ArrayList<>();