数据报表
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
package cn.ysk.cashier.service;
|
||||
|
||||
import cn.ysk.cashier.repository.mapping.SumDateMapping;
|
||||
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.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -20,4 +23,15 @@ public interface SummaryService {
|
||||
Map<String,Object> selectSummaryProduct(Integer shopId, Integer day,Integer page,Integer size);
|
||||
|
||||
Map<String,Object> selectSummaryPayType(Integer shopId, Integer day);
|
||||
|
||||
<T> Page<T> selectSummaryByDay(Integer type, String shopId, Long startTime, Long endTime, Integer page, Integer size);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
void download(Integer type, String shopId, Long startTime, Long endTime, HttpServletResponse response) throws IOException;
|
||||
|
||||
List<TbOrderPayCountVo> summaryCount(String shopId, Long startTime, Long endTime);
|
||||
}
|
||||
|
||||
@@ -5,26 +5,31 @@ import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.repository.ShopUserDutyDetailRepository;
|
||||
import cn.ysk.cashier.repository.ShopUserDutyRepository;
|
||||
import cn.ysk.cashier.repository.TbTokenRepository;
|
||||
import cn.ysk.cashier.repository.mapping.CountPayTypeMapping;
|
||||
import cn.ysk.cashier.repository.mapping.SumDateMapping;
|
||||
import cn.ysk.cashier.repository.order.TbOrderDetailRepository;
|
||||
import cn.ysk.cashier.repository.order.TbOrderInfoRepository;
|
||||
import cn.ysk.cashier.repository.shop.TbShopUserRepository;
|
||||
import cn.ysk.cashier.service.SummaryService;
|
||||
import cn.ysk.cashier.utils.DateUtil;
|
||||
import cn.ysk.cashier.utils.FileUtil;
|
||||
import cn.ysk.cashier.vo.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.persistence.Tuple;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@@ -37,27 +42,31 @@ public class SummaryServiceImpl implements SummaryService {
|
||||
private TbShopUserRepository tbShopUserRepository;
|
||||
@Resource
|
||||
private TbOrderInfoRepository tbOrderInfoRepository;
|
||||
@Resource
|
||||
private TbOrderDetailRepository detailRepository;
|
||||
|
||||
@Resource
|
||||
private TbTokenRepository tbTokenRepository;
|
||||
|
||||
@Override
|
||||
public SummaryVO selectSummary(Integer shopId) {
|
||||
SummaryVO summaryVO = new SummaryVO();
|
||||
//支付笔数
|
||||
Tuple result = shopUserDutyRepository.sumByShopId(shopId);
|
||||
summaryVO.setPaymentsNumber(result.get(0, Long.class) == null?0L : result.get(0, Long.class));
|
||||
summaryVO.setTotalSales(result.get(1, BigDecimal.class) == null? new BigDecimal("0") : result.get(1, BigDecimal.class));
|
||||
if (summaryVO.getPaymentsNumber() == 0){
|
||||
summaryVO.setPaymentsNumber(result.get(0, Long.class) == null ? 0L : result.get(0, Long.class));
|
||||
summaryVO.setTotalSales(result.get(1, BigDecimal.class) == null ? new BigDecimal("0") : result.get(1, BigDecimal.class));
|
||||
if (summaryVO.getPaymentsNumber() == 0) {
|
||||
summaryVO.setAverageSales(new BigDecimal("0"));
|
||||
}else {
|
||||
} else {
|
||||
summaryVO.setAverageSales(summaryVO.getTotalSales().divide(new BigDecimal(summaryVO.getPaymentsNumber()), 2, RoundingMode.DOWN));
|
||||
}
|
||||
//用户数
|
||||
Tuple count = tbShopUserRepository.searchByCount(shopId.toString());
|
||||
summaryVO.setTotalUser(count==null?0L:count.get(0, Long.class));
|
||||
summaryVO.setTotalUser(count == null ? 0L : count.get(0, Long.class));
|
||||
//支付笔数柱形图
|
||||
List<Object[]> objects = shopUserDutyRepository.sumByDateOrderNum(shopId, DateUtil.getDate30DaysAgo(), DateUtil.getDayEnd());
|
||||
List<CountDateVO> countDateList = new ArrayList<>();
|
||||
for (Object[] o :objects) {
|
||||
for (Object[] o : objects) {
|
||||
CountDateVO countDateVO = new CountDateVO();
|
||||
countDateVO.setCount((BigDecimal) o[0]);
|
||||
countDateVO.setTradeDay((String) o[1]);
|
||||
@@ -67,7 +76,7 @@ public class SummaryServiceImpl implements SummaryService {
|
||||
Map<String, CountDateVO> dataMap = new HashMap<>();
|
||||
for (CountDateVO entry : countDateList) {
|
||||
String tradeDay = entry.getTradeDay();
|
||||
BigDecimal countOrder = entry.getCount();
|
||||
BigDecimal countOrder = entry.getCount();
|
||||
dataMap.put(tradeDay, new CountDateVO(tradeDay, countOrder));
|
||||
}
|
||||
// 获取今天的日期
|
||||
@@ -90,15 +99,15 @@ public class SummaryServiceImpl implements SummaryService {
|
||||
// 将SumDateVO对象添加到列表中
|
||||
countDateLists.add(countDateVO);
|
||||
}
|
||||
countDateLists.sort((a,b)->a.getTradeDay().compareTo(b.getTradeDay()));
|
||||
countDateLists.sort((a, b) -> a.getTradeDay().compareTo(b.getTradeDay()));
|
||||
summaryVO.setCountDateList(countDateLists);
|
||||
//访问量
|
||||
Tuple tuple = tbTokenRepository.countByAccountId(shopId);
|
||||
summaryVO.setTotalVisits(tuple == null?0L:tuple.get(0, Long.class));
|
||||
summaryVO.setTotalVisits(tuple == null ? 0L : tuple.get(0, Long.class));
|
||||
//访问量柱状图
|
||||
List<Object[]> objectsVisits = tbTokenRepository.countByMonth(shopId, DateUtil.getDate30DaysAgo(), DateUtil.getDayEnd());
|
||||
List<CountVisitsVO> visitsList = new ArrayList<>();
|
||||
for (Object[] o :objectsVisits){
|
||||
for (Object[] o : objectsVisits) {
|
||||
CountVisitsVO countDateVO = new CountVisitsVO();
|
||||
countDateVO.setCount((BigInteger) o[0]);
|
||||
countDateVO.setTradeDay((String) o[1]);
|
||||
@@ -108,7 +117,7 @@ public class SummaryServiceImpl implements SummaryService {
|
||||
Map<String, CountVisitsVO> dataVisitsMap = new HashMap<>();
|
||||
for (CountVisitsVO entry : visitsList) {
|
||||
String tradeDay = entry.getTradeDay();
|
||||
BigInteger countOrder = entry.getCount();
|
||||
BigInteger countOrder = entry.getCount();
|
||||
dataVisitsMap.put(tradeDay, new CountVisitsVO(tradeDay, countOrder));
|
||||
}
|
||||
// 转换为字符串
|
||||
@@ -127,25 +136,25 @@ public class SummaryServiceImpl implements SummaryService {
|
||||
// 将SumDateVO对象添加到列表中
|
||||
countVisitsLists.add(countDateVO);
|
||||
}
|
||||
countVisitsLists.sort((a,b)->a.getTradeDay().compareTo(b.getTradeDay()));
|
||||
countVisitsLists.sort((a, b) -> a.getTradeDay().compareTo(b.getTradeDay()));
|
||||
summaryVO.setVisitsCountList(countVisitsLists);
|
||||
return summaryVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String,Object> selectSummaryDate(Integer shopId, Integer day) {
|
||||
public Map<String, Object> selectSummaryDate(Integer shopId, Integer day) {
|
||||
Date startTime = new Date();
|
||||
Date endTime = new Date();
|
||||
if (day == 7){
|
||||
if (day == 7) {
|
||||
startTime = DateUtil.getDate7DaysAgo();
|
||||
endTime = DateUtil.getDayEnd();
|
||||
}else if (day == 30){
|
||||
} else if (day == 30) {
|
||||
startTime = DateUtil.getDate30DaysAgo();
|
||||
endTime = DateUtil.getDayEnd();
|
||||
}else if (day == 360){
|
||||
} else if (day == 360) {
|
||||
startTime = DateUtil.getBeginDayOfYear();
|
||||
endTime = DateUtil.getDateOneYearAgo();
|
||||
}else if (day ==1){
|
||||
} else if (day == 1) {
|
||||
startTime = DateUtil.getDayBegin();
|
||||
endTime = DateUtil.getDayEnd();
|
||||
}
|
||||
@@ -153,7 +162,7 @@ public class SummaryServiceImpl implements SummaryService {
|
||||
Tuple tuple = shopUserDutyDetailRepository.searchByDutyIdSum(shopId, startTime, endTime);
|
||||
List<Object[]> objects = shopUserDutyDetailRepository.searchByDutyGroup(shopId, DateUtil.getDate30DaysAgo(), DateUtil.getDayEnd());
|
||||
List<CountDateVO> numList = new ArrayList<>();
|
||||
for (Object[] o :objects) {
|
||||
for (Object[] o : objects) {
|
||||
CountDateVO countDateVO = new CountDateVO();
|
||||
countDateVO.setCount((BigDecimal) o[0]);
|
||||
countDateVO.setTradeDay((String) o[1]);
|
||||
@@ -161,80 +170,81 @@ public class SummaryServiceImpl implements SummaryService {
|
||||
}
|
||||
List<Object[]> objects1 = shopUserDutyDetailRepository.searchByGroup(shopId, DateUtil.getDate30DaysAgo(), DateUtil.getDayEnd());
|
||||
List<CountDateVO> amountList = new ArrayList<>();
|
||||
for (Object[] o :objects1) {
|
||||
for (Object[] o : objects1) {
|
||||
CountDateVO countDateVO = new CountDateVO();
|
||||
countDateVO.setCount((BigDecimal) o[0]);
|
||||
countDateVO.setTradeDay((String) o[1]);
|
||||
amountList.add(countDateVO);
|
||||
}
|
||||
map.put("productCount",tuple == null? 0:tuple.get(0, BigDecimal.class));
|
||||
map.put("productSum",tuple == null?0:tuple.get(1, BigDecimal.class));
|
||||
map.put("numList",numList);
|
||||
map.put("amountList",amountList);
|
||||
map.put("productCount", tuple == null ? 0 : tuple.get(0, BigDecimal.class));
|
||||
map.put("productSum", tuple == null ? 0 : tuple.get(1, BigDecimal.class));
|
||||
map.put("numList", numList);
|
||||
map.put("amountList", amountList);
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String,Object> selectSummaryProduct(Integer shopId, Integer day,Integer currentPage, Integer currentSize){
|
||||
public Map<String, Object> selectSummaryProduct(Integer shopId, Integer day, Integer currentPage, Integer currentSize) {
|
||||
//根据时间商品排行
|
||||
currentPage = (currentPage - 1) * currentSize;
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
Date startTime ;
|
||||
Date endTime ;
|
||||
if (day == 7){
|
||||
Date startTime;
|
||||
Date endTime;
|
||||
if (day == 7) {
|
||||
startTime = DateUtil.getDate7DaysAgo();
|
||||
endTime = DateUtil.getDayEnd();
|
||||
}else if (day == 30){
|
||||
} else if (day == 30) {
|
||||
startTime = DateUtil.getDate30DaysAgo();
|
||||
endTime = DateUtil.getDayEnd();
|
||||
}else if (day == 360){
|
||||
} else if (day == 360) {
|
||||
startTime = DateUtil.getBeginDayOfYear();
|
||||
endTime = DateUtil.getEndDayOfYear();
|
||||
}else if (day ==1){
|
||||
} else if (day == 1) {
|
||||
startTime = DateUtil.getDayBegin();
|
||||
endTime = DateUtil.getDayEnd();
|
||||
} else {
|
||||
throw new BadRequestException("日期有误");
|
||||
}
|
||||
List<Object[]> objects = shopUserDutyDetailRepository.searchByDutyId(shopId,startTime,endTime,currentPage,currentSize);
|
||||
List<Object[]> objects = shopUserDutyDetailRepository.searchByDutyId(shopId, startTime, endTime, currentPage, currentSize);
|
||||
List<ProductExtVO> list = new ArrayList<>();
|
||||
for (Object[] o :objects) {
|
||||
for (Object[] o : objects) {
|
||||
ProductExtVO productVO = new ProductExtVO();
|
||||
productVO.setProductId((BigInteger) o[0]);
|
||||
productVO.setProductName((String) o[1]);
|
||||
productVO.setProductNum((BigDecimal)o[2]);
|
||||
productVO.setAmount((BigDecimal)o[3]);
|
||||
productVO.setProductNum((BigDecimal) o[2]);
|
||||
productVO.setAmount((BigDecimal) o[3]);
|
||||
list.add(productVO);
|
||||
}
|
||||
//汇总数据
|
||||
Tuple tuple = shopUserDutyDetailRepository.searchByDutyIdSum(shopId, startTime, endTime);
|
||||
//分页数据
|
||||
Tuple tuple1 = shopUserDutyDetailRepository.searchCount(shopId, startTime, endTime);
|
||||
map.put("productCount",tuple == null? 0:tuple.get(0, BigDecimal.class));
|
||||
map.put("productSum",tuple == null? 0:tuple.get(1, BigDecimal.class));
|
||||
map.put("totalProduct",list);
|
||||
map.put("total",tuple1 == null?0:tuple1.get(0, BigInteger.class));
|
||||
map.put("productCount", tuple == null ? 0 : tuple.get(0, BigDecimal.class));
|
||||
map.put("productSum", tuple == null ? 0 : tuple.get(1, BigDecimal.class));
|
||||
map.put("totalProduct", list);
|
||||
map.put("total", tuple1 == null ? 0 : tuple1.get(0, BigInteger.class));
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String,Object> selectSummaryAmount(Integer shopId, Integer day){
|
||||
public Map<String, Object> selectSummaryAmount(Integer shopId, Integer day) {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
Date startTime ;
|
||||
Date endTime ;
|
||||
if (day == 7){
|
||||
Date startTime;
|
||||
Date endTime;
|
||||
if (day == 7) {
|
||||
startTime = DateUtil.getDate7DaysAgo();
|
||||
endTime = DateUtil.getDayEnd();
|
||||
}else if (day == 30){
|
||||
} else if (day == 30) {
|
||||
startTime = DateUtil.getDate30DaysAgo();
|
||||
endTime = DateUtil.getDayEnd();
|
||||
}else {
|
||||
} else {
|
||||
throw new BadRequestException("日期有误");
|
||||
}
|
||||
|
||||
List<Object[]> objects = shopUserDutyRepository.sumByDate(shopId, startTime, endTime);
|
||||
//根据时间的销量
|
||||
List<SumDateVO> sumDateVOList = new ArrayList<>();
|
||||
for (Object[] o :objects) {
|
||||
for (Object[] o : objects) {
|
||||
SumDateVO sumDateVO = new SumDateVO();
|
||||
sumDateVO.setAmount((BigDecimal) o[0]);
|
||||
sumDateVO.setTradeDay((String) o[1]);
|
||||
@@ -244,7 +254,7 @@ public class SummaryServiceImpl implements SummaryService {
|
||||
Map<String, SumDateVO> dataMap = new HashMap<>();
|
||||
for (SumDateVO entry : sumDateVOList) {
|
||||
String tradeDay = entry.getTradeDay();
|
||||
BigDecimal amount = entry.getAmount();
|
||||
BigDecimal amount = entry.getAmount();
|
||||
dataMap.put(tradeDay, new SumDateVO(tradeDay, amount));
|
||||
}
|
||||
// 获取今天的日期
|
||||
@@ -269,8 +279,8 @@ public class SummaryServiceImpl implements SummaryService {
|
||||
}
|
||||
|
||||
|
||||
sumDateList.sort((a,b)->a.getTradeDay().compareTo(b.getTradeDay()));
|
||||
map.put("total",sumDateList);
|
||||
sumDateList.sort((a, b) -> a.getTradeDay().compareTo(b.getTradeDay()));
|
||||
map.put("total", sumDateList);
|
||||
return map;
|
||||
}
|
||||
|
||||
@@ -278,40 +288,137 @@ public class SummaryServiceImpl implements SummaryService {
|
||||
public Map<String, Object> selectSummaryToday(Integer shopId) {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
Tuple tuple = shopUserDutyRepository.sumByShopIdToday(shopId, DateUtil.getDayBegin(), DateUtil.getDayEnd());
|
||||
map.put("paymentsNumberToday", tuple == null?0L : tuple.get(0, Long.class));
|
||||
map.put("totalSalesToday", tuple == null? new BigDecimal("0") : tuple.get(1, BigDecimal.class));
|
||||
map.put("paymentsNumberToday", tuple == null ? 0L : tuple.get(0, Long.class));
|
||||
map.put("totalSalesToday", tuple == null ? new BigDecimal("0") : tuple.get(1, BigDecimal.class));
|
||||
Tuple tuple1 = tbShopUserRepository.searchByCountToday(shopId.toString(), DateUtil.getTodayStartTimestamp(), DateUtil.getTodayEndTimestamp());
|
||||
map.put("userToday", tuple1.get(0, Long.class));
|
||||
Tuple tupleToday = tbTokenRepository.countByAccountId(shopId, DateUtil.getDayBegin(), DateUtil.getDayEnd());
|
||||
map.put("totalVisitsToday",tupleToday == null?0:tupleToday.get(0,Long.class));
|
||||
map.put("totalVisitsToday", tupleToday == null ? 0 : tupleToday.get(0, Long.class));
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String,Object> selectSummaryPayType(Integer shopId, Integer day){
|
||||
Long startTime ;
|
||||
Long endTime ;
|
||||
if (day == 7){
|
||||
public Map<String, Object> selectSummaryPayType(Integer shopId, Integer day) {
|
||||
Long startTime;
|
||||
Long endTime;
|
||||
if (day == 7) {
|
||||
startTime = DateUtil.getSevenDaysAgoInMilliseconds();
|
||||
endTime = DateUtil.getTodayEndTimestamp();
|
||||
}else if (day == 30){
|
||||
} else if (day == 30) {
|
||||
startTime = DateUtil.getThirtyDaysAgoInMilliseconds();
|
||||
endTime = DateUtil.getTodayEndTimestamp();
|
||||
}else if (day == 360){
|
||||
} else if (day == 360) {
|
||||
startTime = DateUtil.getBeginningOfYearInMilliseconds();
|
||||
endTime = DateUtil.getEndOfYearInMilliseconds();
|
||||
}else {
|
||||
} else {
|
||||
throw new BadRequestException("日期有误");
|
||||
}
|
||||
List<Object[]> countPayTypeMappings = tbOrderInfoRepository.countByShopId(shopId.toString(),startTime,endTime);
|
||||
List<Object[]> countPayTypeMappings = tbOrderInfoRepository.countByShopId(shopId.toString(), startTime, endTime);
|
||||
List<CountPayTypeVO> countPayTypeVOList = new ArrayList<>();
|
||||
for (Object[] o :countPayTypeMappings) {
|
||||
for (Object[] o : countPayTypeMappings) {
|
||||
CountPayTypeVO countPayTypeVO = new CountPayTypeVO();
|
||||
countPayTypeVO.setCount((BigInteger) o[0]);
|
||||
countPayTypeVO.setPayType(PayTypeEnum.getCodeByName((String) o[1]));
|
||||
countPayTypeVOList.add(countPayTypeVO);
|
||||
}
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("countPayType",countPayTypeVOList);
|
||||
map.put("countPayType", countPayTypeVOList);
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Page<T> selectSummaryByDay(Integer type, String shopId, Long startTime, Long endTime, 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();
|
||||
}
|
||||
return (Page<T>) tbOrderInfoRepository.queryTbOrderPayCountByDay(shopId, startTime, endTime, 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));
|
||||
}
|
||||
return (Page<T>) detailRepository.queryTbOrderSalesCountByDay(Integer.valueOf(shopId), start, end, 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 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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user