Merge branch 'gyj' into test

This commit is contained in:
2024-08-22 16:20:51 +08:00
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.AnonymousGetMapping;
import cn.ysk.cashier.annotation.rest.AnonymousPostMapping; import cn.ysk.cashier.annotation.rest.AnonymousPostMapping;
import cn.ysk.cashier.dto.ShopSummaryDto; import cn.ysk.cashier.dto.shop.ShopTableSaleInfoDto;
import cn.ysk.cashier.dto.shop.ShopTableSeleInfoDto;
import cn.ysk.cashier.service.SummaryService; import cn.ysk.cashier.service.SummaryService;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
@@ -68,8 +65,8 @@ public class SummaryController {
@PostMapping("/table/download") @PostMapping("/table/download")
@AnonymousPostMapping @AnonymousPostMapping
private void downloadShopSummaryTable(HttpServletResponse response, @RequestBody ShopTableSeleInfoDto exportRequest) throws IOException { private void downloadShopSummaryTable(HttpServletResponse response, @RequestBody ShopTableSaleInfoDto exportRequest) throws IOException {
summaryService.downloadTableSeleInfo(exportRequest, response); summaryService.downloadTableSaleInfo(exportRequest, response);
} }
} }

View File

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

View File

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