桌台统计--导出
This commit is contained in:
@@ -1,17 +1,19 @@
|
|||||||
package cn.ysk.cashier.controller.shop;
|
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.dto.ShopSummaryDto;
|
||||||
|
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 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.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,44 +25,49 @@ import java.util.Date;
|
|||||||
public class SummaryController {
|
public class SummaryController {
|
||||||
@Resource
|
@Resource
|
||||||
private SummaryService summaryService;
|
private SummaryService summaryService;
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
private Object shopSummary(@RequestParam Integer shopId){
|
private Object shopSummary(@RequestParam Integer shopId) {
|
||||||
return summaryService.selectSummary(shopId);
|
return summaryService.selectSummary(shopId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/date")
|
@GetMapping("/date")
|
||||||
private Object shopSummaryDate(@RequestParam Integer shopId,@RequestParam Integer day){
|
private Object shopSummaryDate(@RequestParam Integer shopId, @RequestParam Integer day) {
|
||||||
return summaryService.selectSummaryDate(shopId,day);
|
return summaryService.selectSummaryDate(shopId, day);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/today")
|
@GetMapping("/today")
|
||||||
private Object shopSummaryDate(@RequestParam Integer shopId){
|
private Object shopSummaryDate(@RequestParam Integer shopId) {
|
||||||
return summaryService.selectSummaryToday(shopId);
|
return summaryService.selectSummaryToday(shopId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/dateAmount")
|
@GetMapping("/dateAmount")
|
||||||
private Object shopSummaryAmount(@RequestParam Integer shopId,@RequestParam Integer day){
|
private Object shopSummaryAmount(@RequestParam Integer shopId, @RequestParam Integer day) {
|
||||||
return summaryService.selectSummaryAmount(shopId,day);
|
return summaryService.selectSummaryAmount(shopId, day);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/dateProduct")
|
@GetMapping("/dateProduct")
|
||||||
private Object shopSummaryProduct(@RequestParam Integer shopId,@RequestParam Integer day,
|
private Object shopSummaryProduct(@RequestParam Integer shopId, @RequestParam Integer day,
|
||||||
@RequestParam Integer page, @RequestParam Integer size){
|
@RequestParam Integer page, @RequestParam Integer size) {
|
||||||
return summaryService.selectSummaryProduct(shopId,day,page,size);
|
return summaryService.selectSummaryProduct(shopId, day, page, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/datePayType")
|
@GetMapping("/datePayType")
|
||||||
private Object shopSummaryPayType(@RequestParam Integer shopId,@RequestParam Integer day){
|
private Object shopSummaryPayType(@RequestParam Integer shopId, @RequestParam Integer day) {
|
||||||
return summaryService.selectSummaryPayType(shopId,day);
|
return summaryService.selectSummaryPayType(shopId, day);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/table")
|
@GetMapping("/table")
|
||||||
@AnonymousGetMapping
|
|
||||||
private Object shopSummaryTable(@RequestParam Integer shopId,
|
private Object shopSummaryTable(@RequestParam Integer shopId,
|
||||||
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date startTime,
|
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date startTime,
|
||||||
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date endTime){
|
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date endTime) {
|
||||||
return summaryService.selectSummaryTable(shopId, startTime, endTime);
|
return summaryService.selectSummaryTable(shopId, startTime, endTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/table/download")
|
||||||
|
private void downloadShopSummaryTable(HttpServletResponse response, @RequestBody ShopTableSeleInfoDto exportRequest) throws IOException {
|
||||||
|
summaryService.downloadTableSeleInfo(exportRequest, response);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package cn.ysk.cashier.dto.shop;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author GYJ
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ShopTableSeleInfoDto {
|
||||||
|
private Integer shopId;
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date startTime;
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date endTime;
|
||||||
|
}
|
||||||
@@ -1,6 +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.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;
|
||||||
@@ -39,4 +40,6 @@ public interface SummaryService {
|
|||||||
List<TbOrderPayCountVo> summaryCount(String shopId, Date startTime, Date endTime);
|
List<TbOrderPayCountVo> summaryCount(String shopId, Date startTime, Date endTime);
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +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.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;
|
||||||
@@ -474,12 +475,41 @@ public class SummaryServiceImpl implements SummaryService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ShopTableSaleInfoVo> selectSummaryTable(Integer shopId, Date startTime, Date endTime) {
|
public List<ShopTableSaleInfoVo> selectSummaryTable(Integer shopId, Date startTime, Date endTime) {
|
||||||
Long start = 1704038400000L;
|
long start = 1704038400000L;
|
||||||
Long end = Instant.now().toEpochMilli();
|
long end = Instant.now().toEpochMilli();
|
||||||
if (startTime != null && endTime != null) {
|
if (startTime != null && endTime != null) {
|
||||||
start = startTime.getTime();
|
start = startTime.getTime();
|
||||||
end = endTime.getTime();
|
end = endTime.getTime();
|
||||||
}
|
}
|
||||||
return tbOrderInfoRepository.queryShopTableSaleInfo(shopId.toString(), start, end);
|
return tbOrderInfoRepository.queryShopTableSaleInfo(shopId.toString(), start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void downloadTableSeleInfo(ShopTableSeleInfoDto shopTableSeleInfoDto, HttpServletResponse response) throws IOException {
|
||||||
|
if (shopTableSeleInfoDto.getStartTime() == null) {
|
||||||
|
shopTableSeleInfoDto.setStartTime(DateUtil.toDate(DateUtil.fromTimeStamp(1704038400L)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shopTableSeleInfoDto.getEndTime() == null) {
|
||||||
|
shopTableSeleInfoDto.setEndTime(new Date());
|
||||||
|
}
|
||||||
|
|
||||||
|
List<ShopTableSaleInfoVo> infoVos = selectSummaryTable(shopTableSeleInfoDto.getShopId(), shopTableSeleInfoDto.getStartTime(), shopTableSeleInfoDto.getEndTime());
|
||||||
|
|
||||||
|
List<Map<String, Object>> list = new ArrayList<>();
|
||||||
|
|
||||||
|
for (ShopTableSaleInfoVo all : infoVos) {
|
||||||
|
Map<String, Object> map = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
map.put("开始时间", shopTableSeleInfoDto.getStartTime());
|
||||||
|
map.put("结束时间", shopTableSeleInfoDto.getEndTime());
|
||||||
|
map.put("区域名称", all.getAreaName());
|
||||||
|
map.put("桌台名称", all.getTableName());
|
||||||
|
map.put("订单数量", all.getOrderCount());
|
||||||
|
map.put("销售额", all.getOrderAmount());
|
||||||
|
|
||||||
|
list.add(map);
|
||||||
|
}
|
||||||
|
FileUtil.downloadExcel(list, response);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -220,6 +220,7 @@ public class StockServiceImpl implements StockService {
|
|||||||
|
|
||||||
stockDetail.setShopId(sku.getShopId());
|
stockDetail.setShopId(sku.getShopId());
|
||||||
stockDetail.setSkuId(sku.getId().toString());
|
stockDetail.setSkuId(sku.getId().toString());
|
||||||
|
stockDetail.setProductId(product.getId().toString());
|
||||||
stockDetail.setProductName(product.getName());
|
stockDetail.setProductName(product.getName());
|
||||||
stockDetail.setUnitName(shopUnit.getName());
|
stockDetail.setUnitName(shopUnit.getName());
|
||||||
stockDetail.setLeftNumber(0);
|
stockDetail.setLeftNumber(0);
|
||||||
|
|||||||
Reference in New Issue
Block a user