数据报表
This commit is contained in:
parent
05e1acaef2
commit
8cbe957833
|
|
@ -1,6 +1,7 @@
|
|||
package cn.ysk.cashier.controller.shop;
|
||||
|
||||
import cn.ysk.cashier.annotation.Log;
|
||||
import cn.ysk.cashier.dto.ShopSummaryDto;
|
||||
import cn.ysk.cashier.service.SummaryService;
|
||||
import cn.ysk.cashier.vo.TbOrderPayCountVo;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
|
@ -8,13 +9,12 @@ import lombok.RequiredArgsConstructor;
|
|||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -29,30 +29,23 @@ public class SummaryByDayController {
|
|||
|
||||
@Log("导出数据")
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "download")
|
||||
public void exportTbOrderInfo(HttpServletResponse response,
|
||||
@RequestParam String shopId,
|
||||
@RequestParam(required = false) Integer type,
|
||||
@RequestParam(required = false) Long startTime,
|
||||
@RequestParam(required = false) Long endTime) throws IOException {
|
||||
summaryService.download(type, shopId, startTime, endTime,response);
|
||||
@PostMapping(value = "download")
|
||||
public void exportTbOrderInfo(HttpServletResponse response, @RequestBody ShopSummaryDto exportRequest) throws IOException {
|
||||
summaryService.download(exportRequest,response);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping
|
||||
public Page<T> shopSummary(@RequestParam String shopId,
|
||||
@RequestParam(required = false) Integer type,
|
||||
@RequestParam(required = false) Long startTime,
|
||||
@RequestParam(required = false) Long endTime,
|
||||
public Page<T> shopSummary(ShopSummaryDto summaryDto,
|
||||
@RequestParam(required = false, defaultValue = "0") Integer page,
|
||||
@RequestParam(required = false, defaultValue = "10") Integer size) {
|
||||
return summaryService.selectSummaryByDay(type, shopId, startTime, endTime, page, size);
|
||||
return summaryService.selectSummaryByDay(summaryDto, page, size);
|
||||
}
|
||||
|
||||
@GetMapping(value = "count")
|
||||
public List<TbOrderPayCountVo> summaryCount(@RequestParam String shopId,
|
||||
@RequestParam(required = false) Long startTime,
|
||||
@RequestParam(required = false) Long endTime) {
|
||||
@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) {
|
||||
return summaryService.summaryCount(shopId, startTime, endTime);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,48 @@
|
|||
package cn.ysk.cashier.dto;
|
||||
|
||||
import cn.ysk.cashier.utils.DateUtil;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
public class ShopSummaryDto {
|
||||
private String shopId;
|
||||
private Integer type;
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date startTime;
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date endTime;
|
||||
|
||||
public String getShopId() {
|
||||
return shopId;
|
||||
}
|
||||
|
||||
public void setShopId(String shopId) {
|
||||
this.shopId = shopId;
|
||||
}
|
||||
|
||||
public Integer getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(Integer type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Date getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(Date startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public Date getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(Date endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +1,13 @@
|
|||
package cn.ysk.cashier.service;
|
||||
|
||||
import cn.ysk.cashier.dto.ShopSummaryDto;
|
||||
import cn.ysk.cashier.vo.SummaryVO;
|
||||
import cn.ysk.cashier.vo.TbOrderPayCountVo;
|
||||
import org.springframework.data.domain.Page;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -24,14 +26,16 @@ public interface SummaryService {
|
|||
|
||||
Map<String,Object> selectSummaryPayType(Integer shopId, Integer day);
|
||||
|
||||
<T> Page<T> selectSummaryByDay(Integer type, String shopId, Long startTime, Long endTime, Integer page, Integer size);
|
||||
<T> Page<T> selectSummaryByDay(ShopSummaryDto summaryDto, Integer page, Integer size);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
void download(Integer type, String shopId, Long startTime, Long endTime, HttpServletResponse response) throws IOException;
|
||||
// void download(Integer type, String shopId, Long startTime, Long endTime, HttpServletResponse response) throws IOException;
|
||||
void download(ShopSummaryDto summaryDto, HttpServletResponse response) throws IOException;
|
||||
|
||||
List<TbOrderPayCountVo> summaryCount(String shopId, Long startTime, Long endTime);
|
||||
// List<TbOrderPayCountVo> summaryCount(String shopId, Long startTime, Long endTime);
|
||||
List<TbOrderPayCountVo> summaryCount(String shopId, Date startTime, Date endTime);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package cn.ysk.cashier.service.impl;
|
||||
|
||||
import cn.ysk.cashier.dto.ShopSummaryDto;
|
||||
import cn.ysk.cashier.enums.PayTypeEnum;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.repository.ShopUserDutyDetailRepository;
|
||||
|
|
@ -326,38 +327,100 @@ public class SummaryServiceImpl implements SummaryService {
|
|||
return map;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public <T> Page<T> selectSummaryByDay(ShopSummaryDto summaryDto, Integer page, Integer size) {
|
||||
// Pageable pageable = PageRequest.of(page, size);
|
||||
// if (summaryDto.getType() != null && summaryDto.getType() == 1) {//金额
|
||||
// if (summaryDto.getStartTime() == null || summaryDto.getEndTime() == null) {
|
||||
// summaryDto.setStartTime(1704038400000L);
|
||||
// summaryDto.setEndTime(Instant.now().toEpochMilli());
|
||||
// }
|
||||
// return (Page<T>) tbOrderInfoRepository.queryTbOrderPayCountByDay(summaryDto.getShopId(), summaryDto.getStartTime(), summaryDto.getEndTime(), pageable);
|
||||
// } else {//销量
|
||||
// Date end = null;
|
||||
// Date start = null;
|
||||
// if (summaryDto.getStartTime() == null || summaryDto.getEndTime() == null) {
|
||||
// start = DateUtil.toDate(DateUtil.fromTimeStamp(1704038400L));
|
||||
// end = new Date();
|
||||
// } else {
|
||||
// start = DateUtil.toDate(DateUtil.fromTimeStamp(summaryDto.getStartTime()));
|
||||
// end = DateUtil.toDate(DateUtil.fromTimeStamp(summaryDto.getEndTime()));
|
||||
// }
|
||||
// return (Page<T>) detailRepository.queryTbOrderSalesCountByDay(Integer.valueOf(summaryDto.getShopId()), start, end, pageable);
|
||||
// }
|
||||
// }
|
||||
@Override
|
||||
public <T> Page<T> selectSummaryByDay(Integer type, String shopId, Long startTime, Long endTime, Integer page, Integer size) {
|
||||
public <T> Page<T> selectSummaryByDay(ShopSummaryDto summaryDto, Integer page, Integer size) {
|
||||
Pageable pageable = PageRequest.of(page, size);
|
||||
if (type != null && type == 1) {//金额
|
||||
if (startTime == null || endTime == null) {
|
||||
startTime = 1704038400000L;
|
||||
endTime = Instant.now().toEpochMilli();
|
||||
if (summaryDto.getType() != null && summaryDto.getType() == 1) {//金额
|
||||
Long start = 1704038400000L;
|
||||
Long end = Instant.now().toEpochMilli();
|
||||
if (summaryDto.getStartTime() != null && summaryDto.getEndTime() != null) {
|
||||
start = summaryDto.getStartTime().getTime();
|
||||
end = summaryDto.getEndTime().getTime();
|
||||
}
|
||||
return (Page<T>) tbOrderInfoRepository.queryTbOrderPayCountByDay(shopId, startTime, endTime, pageable);
|
||||
return (Page<T>) tbOrderInfoRepository.queryTbOrderPayCountByDay(summaryDto.getShopId(), start, end, pageable);
|
||||
} else {//销量
|
||||
Date end = null;
|
||||
Date start = null;
|
||||
if (startTime == null || endTime == null) {
|
||||
start = DateUtil.toDate(DateUtil.fromTimeStamp(1704038400L));
|
||||
end = new Date();
|
||||
} else {
|
||||
start = DateUtil.toDate(DateUtil.fromTimeStamp(startTime));
|
||||
end = DateUtil.toDate(DateUtil.fromTimeStamp(endTime));
|
||||
if (summaryDto.getStartTime() == null || summaryDto.getEndTime() == null) {
|
||||
summaryDto.setStartTime(DateUtil.toDate(DateUtil.fromTimeStamp(1704038400L)));
|
||||
summaryDto.setEndTime(new Date());
|
||||
}
|
||||
return (Page<T>) detailRepository.queryTbOrderSalesCountByDay(Integer.valueOf(shopId), start, end, pageable);
|
||||
return (Page<T>) detailRepository.queryTbOrderSalesCountByDay(Integer.valueOf(summaryDto.getShopId()), summaryDto.getStartTime(), summaryDto.getEndTime(), pageable);
|
||||
}
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void download(Integer type, String shopId, Long startTime, Long endTime, HttpServletResponse response) throws IOException {
|
||||
// List<Map<String, Object>> list = new ArrayList<>();
|
||||
// if (type != null && type == 1) {//金额
|
||||
// if (startTime == null || endTime == null) {
|
||||
// startTime = 1704038400000L;
|
||||
// endTime = Instant.now().toEpochMilli();
|
||||
// }
|
||||
// List<TbOrderPayCountByDayVo> tbOrderPayCountByDayVos = tbOrderInfoRepository.queryTbOrderPayCountByDay(shopId, startTime, endTime);
|
||||
// for (TbOrderPayCountByDayVo all : tbOrderPayCountByDayVos) {
|
||||
// Map<String, Object> map = new LinkedHashMap<>();
|
||||
// map.put("现金", all.getCash());
|
||||
// map.put("扫码支付", all.getScanCode());
|
||||
// map.put("微信小程序支付", all.getWxLite());
|
||||
// map.put("总金额", all.getTotal());
|
||||
// map.put("日期", all.getTradeDay());
|
||||
// list.add(map);
|
||||
// }
|
||||
// } else {//销量
|
||||
// Date end = null;
|
||||
// Date start = null;
|
||||
// if (startTime == null || endTime == null) {
|
||||
// start = DateUtil.toDate(DateUtil.fromTimeStamp(1704038400L));
|
||||
// end = new Date();
|
||||
// } else {
|
||||
// start = DateUtil.toDate(DateUtil.fromTimeStamp(startTime));
|
||||
// end = DateUtil.toDate(DateUtil.fromTimeStamp(endTime));
|
||||
// }
|
||||
// List<TbOrderSalesCountByDayVo> tbOrderSalesCountByDayVos = detailRepository.queryTbOrderSalesCountByDay(Integer.valueOf(shopId), start, end);
|
||||
// for (TbOrderSalesCountByDayVo all : tbOrderSalesCountByDayVos) {
|
||||
// Map<String, Object> map = new LinkedHashMap<>();
|
||||
// map.put("商品名称", all.getProductName());
|
||||
// map.put("商品规格", StringUtils.isBlank(all.getProductSkuName()) ? "" : all.getProductSkuName());
|
||||
// map.put("销量", all.getSalesNum());
|
||||
// map.put("退单量", all.getRefNum());
|
||||
// map.put("总量", all.getNum());
|
||||
// list.add(map);
|
||||
// }
|
||||
// }
|
||||
// FileUtil.downloadExcel(list, response);
|
||||
// }
|
||||
@Override
|
||||
public void download(Integer type, String shopId, Long startTime, Long endTime, HttpServletResponse response) throws IOException {
|
||||
public void download(ShopSummaryDto summaryDto, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
if (type != null && type == 1) {//金额
|
||||
if (startTime == null || endTime == null) {
|
||||
startTime = 1704038400000L;
|
||||
endTime = Instant.now().toEpochMilli();
|
||||
if (summaryDto.getType() != null && summaryDto.getType() == 1) {//金额
|
||||
Long start = 1704038400000L;
|
||||
Long end = Instant.now().toEpochMilli();
|
||||
if (summaryDto.getStartTime() != null && summaryDto.getEndTime() != null) {
|
||||
start = summaryDto.getStartTime().getTime();
|
||||
end = summaryDto.getEndTime().getTime();
|
||||
}
|
||||
List<TbOrderPayCountByDayVo> tbOrderPayCountByDayVos = tbOrderInfoRepository.queryTbOrderPayCountByDay(shopId, startTime, endTime);
|
||||
List<TbOrderPayCountByDayVo> tbOrderPayCountByDayVos = tbOrderInfoRepository.queryTbOrderPayCountByDay(summaryDto.getShopId(), start, end);
|
||||
for (TbOrderPayCountByDayVo all : tbOrderPayCountByDayVos) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("现金", all.getCash());
|
||||
|
|
@ -368,16 +431,11 @@ public class SummaryServiceImpl implements SummaryService {
|
|||
list.add(map);
|
||||
}
|
||||
} else {//销量
|
||||
Date end = null;
|
||||
Date start = null;
|
||||
if (startTime == null || endTime == null) {
|
||||
start = DateUtil.toDate(DateUtil.fromTimeStamp(1704038400L));
|
||||
end = new Date();
|
||||
} else {
|
||||
start = DateUtil.toDate(DateUtil.fromTimeStamp(startTime));
|
||||
end = DateUtil.toDate(DateUtil.fromTimeStamp(endTime));
|
||||
if (summaryDto.getStartTime() == null || summaryDto.getEndTime() == null) {
|
||||
summaryDto.setStartTime(DateUtil.toDate(DateUtil.fromTimeStamp(1704038400L)));
|
||||
summaryDto.setEndTime(new Date());
|
||||
}
|
||||
List<TbOrderSalesCountByDayVo> tbOrderSalesCountByDayVos = detailRepository.queryTbOrderSalesCountByDay(Integer.valueOf(shopId), start, end);
|
||||
List<TbOrderSalesCountByDayVo> tbOrderSalesCountByDayVos = detailRepository.queryTbOrderSalesCountByDay(Integer.valueOf(summaryDto.getShopId()), summaryDto.getStartTime(), summaryDto.getEndTime());
|
||||
for (TbOrderSalesCountByDayVo all : tbOrderSalesCountByDayVos) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("商品名称", all.getProductName());
|
||||
|
|
@ -391,26 +449,55 @@ public class SummaryServiceImpl implements SummaryService {
|
|||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public List<TbOrderPayCountVo> summaryCount(String shopId, Long startTime, Long endTime) {
|
||||
// List<TbOrderPayCountVo> list = new ArrayList<>();
|
||||
// Date end = null;
|
||||
// Date start = null;
|
||||
// if (startTime == null || endTime == null) {
|
||||
// startTime = 1704038400000L;
|
||||
// endTime = Instant.now().toEpochMilli();
|
||||
// start = DateUtil.toDate(DateUtil.fromTimeStamp(1704038400L));
|
||||
// end = new Date();
|
||||
// } else {//销量
|
||||
// start = DateUtil.toDate(DateUtil.fromTimeStamp(startTime));
|
||||
// end = DateUtil.toDate(DateUtil.fromTimeStamp(endTime));
|
||||
// }
|
||||
// TbOrderPayCountVo payCount = tbOrderInfoRepository.queryOrderPayCount(shopId, startTime, endTime);
|
||||
// list.add(payCount);
|
||||
// TbOrderPayCountVo refCount = tbOrderInfoRepository.queryTbOrderRefund(shopId, startTime, endTime);
|
||||
// refCount.setPayType("退款金额");
|
||||
// list.add(refCount);
|
||||
// List<TbOrderPayCountVo> tbOrderPayCountVos = detailRepository.queryTbOrderSalesCount(Integer.valueOf(shopId), start, end);
|
||||
// for (TbOrderPayCountVo tbOrderPayCountVo : tbOrderPayCountVos) {
|
||||
// if (tbOrderPayCountVo.getPayType().equals("closed")) {
|
||||
// tbOrderPayCountVo.setPayType("销售量");
|
||||
// } else if (tbOrderPayCountVo.getPayType().equals("refund")) {
|
||||
// tbOrderPayCountVo.setPayType("退单量");
|
||||
// }
|
||||
// list.add(tbOrderPayCountVo);
|
||||
// }
|
||||
// return list;
|
||||
// }
|
||||
@Override
|
||||
public List<TbOrderPayCountVo> summaryCount(String shopId, Long startTime, Long endTime) {
|
||||
public List<TbOrderPayCountVo> summaryCount(String shopId, Date startTime, Date endTime) {
|
||||
List<TbOrderPayCountVo> list = new ArrayList<>();
|
||||
Date end = null;
|
||||
Date start = null;
|
||||
if (startTime == null || endTime == null) {
|
||||
startTime = 1704038400000L;
|
||||
endTime = Instant.now().toEpochMilli();
|
||||
start = DateUtil.toDate(DateUtil.fromTimeStamp(1704038400L));
|
||||
end = new Date();
|
||||
} else {//销量
|
||||
start = DateUtil.toDate(DateUtil.fromTimeStamp(startTime));
|
||||
end = DateUtil.toDate(DateUtil.fromTimeStamp(endTime));
|
||||
Long start = 1704038400000L;
|
||||
Long end = Instant.now().toEpochMilli();
|
||||
if (startTime != null || endTime != null) {
|
||||
start = startTime.getTime();
|
||||
end = endTime.getTime();
|
||||
} else {
|
||||
startTime = DateUtil.toDate(DateUtil.fromTimeStamp(1704038400L));
|
||||
endTime = new Date();
|
||||
}
|
||||
TbOrderPayCountVo payCount = tbOrderInfoRepository.queryOrderPayCount(shopId, startTime, endTime);
|
||||
TbOrderPayCountVo payCount = tbOrderInfoRepository.queryOrderPayCount(shopId, start, end);
|
||||
list.add(payCount);
|
||||
TbOrderPayCountVo refCount = tbOrderInfoRepository.queryTbOrderRefund(shopId, startTime, endTime);
|
||||
TbOrderPayCountVo refCount = tbOrderInfoRepository.queryTbOrderRefund(shopId, start, end);
|
||||
refCount.setPayType("退款金额");
|
||||
list.add(refCount);
|
||||
List<TbOrderPayCountVo> tbOrderPayCountVos = detailRepository.queryTbOrderSalesCount(Integer.valueOf(shopId), start, end);
|
||||
|
||||
List<TbOrderPayCountVo> tbOrderPayCountVos = detailRepository.queryTbOrderSalesCount(Integer.valueOf(shopId), startTime, endTime);
|
||||
for (TbOrderPayCountVo tbOrderPayCountVo : tbOrderPayCountVos) {
|
||||
if (tbOrderPayCountVo.getPayType().equals("closed")) {
|
||||
tbOrderPayCountVo.setPayType("销售量");
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package cn.ysk.cashier.vo;
|
||||
|
||||
|
||||
public class TbOrderPayCountVo{
|
||||
public class TbOrderPayCountVo {
|
||||
private String icon;
|
||||
private String payType;
|
||||
private Object payAmount;
|
||||
|
|
@ -32,6 +32,9 @@ public class TbOrderPayCountVo{
|
|||
|
||||
public TbOrderPayCountVo(String payType, Object payAmount) {
|
||||
this.payType = payType;
|
||||
this.payAmount=payAmount;
|
||||
this.payAmount = payAmount;
|
||||
if (payAmount == null) {
|
||||
this.payAmount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue