数据报表
This commit is contained in:
@@ -0,0 +1,59 @@
|
|||||||
|
package cn.ysk.cashier.controller.shop;
|
||||||
|
|
||||||
|
import cn.ysk.cashier.annotation.Log;
|
||||||
|
import cn.ysk.cashier.service.SummaryService;
|
||||||
|
import cn.ysk.cashier.vo.TbOrderPayCountVo;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
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 javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author lyf
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RequestMapping("/api/summary/day")
|
||||||
|
public class SummaryByDayController {
|
||||||
|
@Autowired
|
||||||
|
private SummaryService summaryService;
|
||||||
|
|
||||||
|
@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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
public Page<T> shopSummary(@RequestParam String shopId,
|
||||||
|
@RequestParam(required = false) Integer type,
|
||||||
|
@RequestParam(required = false) Long startTime,
|
||||||
|
@RequestParam(required = false) Long endTime,
|
||||||
|
@RequestParam(required = false, defaultValue = "0") Integer page,
|
||||||
|
@RequestParam(required = false, defaultValue = "10") Integer size) {
|
||||||
|
return summaryService.selectSummaryByDay(type, shopId, startTime, endTime, page, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping(value = "count")
|
||||||
|
public List<TbOrderPayCountVo> summaryCount(@RequestParam String shopId,
|
||||||
|
@RequestParam(required = false) Long startTime,
|
||||||
|
@RequestParam(required = false) Long endTime) {
|
||||||
|
return summaryService.summaryCount(shopId, startTime, endTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -16,11 +16,18 @@
|
|||||||
package cn.ysk.cashier.repository.order;
|
package cn.ysk.cashier.repository.order;
|
||||||
|
|
||||||
import cn.ysk.cashier.pojo.order.TbOrderDetail;
|
import cn.ysk.cashier.pojo.order.TbOrderDetail;
|
||||||
|
import cn.ysk.cashier.vo.TbOrderPayCountVo;
|
||||||
|
import cn.ysk.cashier.vo.TbOrderSalesCountByDayVo;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
import org.springframework.data.repository.query.Param;
|
|
||||||
|
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,4 +39,44 @@ public interface TbOrderDetailRepository extends JpaRepository<TbOrderDetail, In
|
|||||||
|
|
||||||
@Query("SELECT cart FROM TbOrderDetail cart WHERE cart.orderId = :orderId")
|
@Query("SELECT cart FROM TbOrderDetail cart WHERE cart.orderId = :orderId")
|
||||||
List<TbOrderDetail> searchDetailByOrderId(@Param("orderId")Integer orderId);
|
List<TbOrderDetail> searchDetailByOrderId(@Param("orderId")Integer orderId);
|
||||||
|
|
||||||
|
|
||||||
|
@Query("SELECT new cn.ysk.cashier.vo.TbOrderSalesCountByDayVo(" +
|
||||||
|
"info.productName," +
|
||||||
|
"info.productSkuName," +
|
||||||
|
"SUM( CASE WHEN info.status = 'closed' THEN info.num ELSE 0 END )," +
|
||||||
|
"SUM( CASE WHEN info.status = 'refund' THEN info.num ELSE 0 END )," +
|
||||||
|
"SUM( info.num )) " +
|
||||||
|
"FROM TbOrderDetail info " +
|
||||||
|
"WHERE info.shopId = :shopId " +
|
||||||
|
"AND info.createTime > :startTime AND info.createTime < :endTime " +
|
||||||
|
"AND ((info.status = 'closed') OR ( info.status ='refund')) " +
|
||||||
|
"GROUP BY info.productId,info.productSkuId " +
|
||||||
|
"ORDER BY info.productId DESC")
|
||||||
|
Page<TbOrderSalesCountByDayVo> queryTbOrderSalesCountByDay(@Param("shopId") Integer shopId, @Param("startTime") Date startTime, @Param("endTime") Date endTime, Pageable pageable);
|
||||||
|
|
||||||
|
@Query("SELECT new cn.ysk.cashier.vo.TbOrderSalesCountByDayVo(" +
|
||||||
|
"info.productName," +
|
||||||
|
"info.productSkuName," +
|
||||||
|
"SUM( CASE WHEN info.status = 'closed' THEN info.num ELSE 0 END )," +
|
||||||
|
"SUM( CASE WHEN info.status = 'refund' THEN info.num ELSE 0 END )," +
|
||||||
|
"SUM( info.num )) " +
|
||||||
|
"FROM TbOrderDetail info " +
|
||||||
|
"WHERE info.shopId = :shopId " +
|
||||||
|
"AND info.createTime > :startTime AND info.createTime < :endTime " +
|
||||||
|
"AND ((info.status = 'closed') OR ( info.status ='refund')) " +
|
||||||
|
"GROUP BY info.productId,info.productSkuId " +
|
||||||
|
"ORDER BY info.productId DESC")
|
||||||
|
List<TbOrderSalesCountByDayVo> queryTbOrderSalesCountByDay(@Param("shopId") Integer shopId, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
|
||||||
|
|
||||||
|
@Query("SELECT new cn.ysk.cashier.vo.TbOrderPayCountVo(" +
|
||||||
|
"info.status," +
|
||||||
|
"SUM( info.num )) " +
|
||||||
|
"FROM TbOrderDetail info " +
|
||||||
|
"WHERE info.shopId = :shopId " +
|
||||||
|
"AND info.createTime > :startTime AND info.createTime < :endTime " +
|
||||||
|
"AND ((info.status = 'closed') OR ( info.status ='refund')) " +
|
||||||
|
"GROUP BY info.status")
|
||||||
|
List<TbOrderPayCountVo> queryTbOrderSalesCount(@Param("shopId") Integer shopId, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -17,8 +17,11 @@ package cn.ysk.cashier.repository.order;
|
|||||||
|
|
||||||
import cn.ysk.cashier.pojo.order.TbOrderInfo;
|
import cn.ysk.cashier.pojo.order.TbOrderInfo;
|
||||||
import cn.ysk.cashier.repository.mapping.CountPayTypeMapping;
|
import cn.ysk.cashier.repository.mapping.CountPayTypeMapping;
|
||||||
|
import cn.ysk.cashier.vo.TbOrderPayCountByDayVo;
|
||||||
import cn.ysk.cashier.vo.TbOrderPayCountVo;
|
import cn.ysk.cashier.vo.TbOrderPayCountVo;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
@@ -54,4 +57,44 @@ public interface TbOrderInfoRepository extends JpaRepository<TbOrderInfo, Intege
|
|||||||
|
|
||||||
@Query("SELECT count(1) FROM TbOrderInfo WHERE source = :source AND shopId=:shopId")
|
@Query("SELECT count(1) FROM TbOrderInfo WHERE source = :source AND shopId=:shopId")
|
||||||
int isRefund(@Param("source")Integer source,@Param("shopId") String shopId);
|
int isRefund(@Param("source")Integer source,@Param("shopId") String shopId);
|
||||||
|
|
||||||
|
|
||||||
|
@Query("SELECT new cn.ysk.cashier.vo.TbOrderPayCountByDayVo(" +
|
||||||
|
"info.tradeDay," +
|
||||||
|
"SUM( CASE WHEN info.payType = 'scanCode' THEN info.orderAmount ELSE 0 END )," +
|
||||||
|
"SUM( CASE WHEN info.payType = 'wx_lite' THEN info.orderAmount ELSE 0 END )," +
|
||||||
|
"SUM( CASE WHEN info.payType = 'cash' THEN info.orderAmount ELSE 0 END )," +
|
||||||
|
"SUM( info.orderAmount)) " +
|
||||||
|
"FROM TbOrderInfo info " +
|
||||||
|
"WHERE info.shopId = :shopId " +
|
||||||
|
"AND info.createdAt > :startTime AND info.createdAt < :endTime " +
|
||||||
|
"AND ((info.status = 'closed') OR ( info.status ='refund' AND info.orderType != 'return' )) " +
|
||||||
|
"GROUP BY info.tradeDay " +
|
||||||
|
"ORDER BY info.tradeDay DESC")
|
||||||
|
Page<TbOrderPayCountByDayVo> queryTbOrderPayCountByDay(@Param("shopId") String shopId, @Param("startTime") Long startTime, @Param("endTime") Long endTime, Pageable pageable);
|
||||||
|
|
||||||
|
|
||||||
|
@Query("SELECT new cn.ysk.cashier.vo.TbOrderPayCountByDayVo(" +
|
||||||
|
"info.tradeDay," +
|
||||||
|
"SUM( CASE WHEN info.payType = 'scanCode' THEN info.orderAmount ELSE 0 END )," +
|
||||||
|
"SUM( CASE WHEN info.payType = 'wx_lite' THEN info.orderAmount ELSE 0 END )," +
|
||||||
|
"SUM( CASE WHEN info.payType = 'cash' THEN info.orderAmount ELSE 0 END )," +
|
||||||
|
"SUM( info.orderAmount)) " +
|
||||||
|
"FROM TbOrderInfo info " +
|
||||||
|
"WHERE info.shopId = :shopId " +
|
||||||
|
"AND info.createdAt > :startTime AND info.createdAt < :endTime " +
|
||||||
|
"AND ((info.status = 'closed') OR ( info.status ='refund' AND info.orderType != 'return' )) " +
|
||||||
|
"GROUP BY info.tradeDay " +
|
||||||
|
"ORDER BY info.tradeDay DESC")
|
||||||
|
List<TbOrderPayCountByDayVo> queryTbOrderPayCountByDay(@Param("shopId") String shopId, @Param("startTime") Long startTime, @Param("endTime") Long endTime);
|
||||||
|
|
||||||
|
@Query("SELECT new cn.ysk.cashier.vo.TbOrderPayCountVo(" +
|
||||||
|
"'总金额'," +
|
||||||
|
"SUM( info.orderAmount)) " +
|
||||||
|
"FROM TbOrderInfo info " +
|
||||||
|
"WHERE info.shopId = :shopId " +
|
||||||
|
"AND info.createdAt > :startTime AND info.createdAt < :endTime " +
|
||||||
|
"AND ((info.status = 'closed') OR ( info.status ='refund' AND info.orderType != 'return' )) ")
|
||||||
|
TbOrderPayCountVo queryOrderPayCount(@Param("shopId") String shopId, @Param("startTime") Long startTime, @Param("endTime") Long endTime);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,11 @@
|
|||||||
package cn.ysk.cashier.service;
|
package cn.ysk.cashier.service;
|
||||||
|
|
||||||
import cn.ysk.cashier.repository.mapping.SumDateMapping;
|
|
||||||
import cn.ysk.cashier.vo.SummaryVO;
|
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.List;
|
||||||
import java.util.Map;
|
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> selectSummaryProduct(Integer shopId, Integer day,Integer page,Integer size);
|
||||||
|
|
||||||
Map<String,Object> selectSummaryPayType(Integer shopId, Integer day);
|
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.ShopUserDutyDetailRepository;
|
||||||
import cn.ysk.cashier.repository.ShopUserDutyRepository;
|
import cn.ysk.cashier.repository.ShopUserDutyRepository;
|
||||||
import cn.ysk.cashier.repository.TbTokenRepository;
|
import cn.ysk.cashier.repository.TbTokenRepository;
|
||||||
import cn.ysk.cashier.repository.mapping.CountPayTypeMapping;
|
import cn.ysk.cashier.repository.order.TbOrderDetailRepository;
|
||||||
import cn.ysk.cashier.repository.mapping.SumDateMapping;
|
|
||||||
import cn.ysk.cashier.repository.order.TbOrderInfoRepository;
|
import cn.ysk.cashier.repository.order.TbOrderInfoRepository;
|
||||||
import cn.ysk.cashier.repository.shop.TbShopUserRepository;
|
import cn.ysk.cashier.repository.shop.TbShopUserRepository;
|
||||||
import cn.ysk.cashier.service.SummaryService;
|
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.vo.*;
|
import cn.ysk.cashier.vo.*;
|
||||||
import lombok.RequiredArgsConstructor;
|
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 org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.persistence.Tuple;
|
import javax.persistence.Tuple;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
|
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.stream.Collectors;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@@ -37,8 +42,12 @@ public class SummaryServiceImpl implements SummaryService {
|
|||||||
private TbShopUserRepository tbShopUserRepository;
|
private TbShopUserRepository tbShopUserRepository;
|
||||||
@Resource
|
@Resource
|
||||||
private TbOrderInfoRepository tbOrderInfoRepository;
|
private TbOrderInfoRepository tbOrderInfoRepository;
|
||||||
|
@Resource
|
||||||
|
private TbOrderDetailRepository detailRepository;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private TbTokenRepository tbTokenRepository;
|
private TbTokenRepository tbTokenRepository;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SummaryVO selectSummary(Integer shopId) {
|
public SummaryVO selectSummary(Integer shopId) {
|
||||||
SummaryVO summaryVO = new SummaryVO();
|
SummaryVO summaryVO = new SummaryVO();
|
||||||
@@ -216,6 +225,7 @@ public class SummaryServiceImpl implements SummaryService {
|
|||||||
map.put("total", tuple1 == null ? 0 : tuple1.get(0, BigInteger.class));
|
map.put("total", tuple1 == null ? 0 : tuple1.get(0, BigInteger.class));
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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<>();
|
HashMap<String, Object> map = new HashMap<>();
|
||||||
@@ -286,6 +296,7 @@ public class SummaryServiceImpl implements SummaryService {
|
|||||||
map.put("totalVisitsToday", tupleToday == null ? 0 : tupleToday.get(0, Long.class));
|
map.put("totalVisitsToday", tupleToday == null ? 0 : tupleToday.get(0, Long.class));
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> selectSummaryPayType(Integer shopId, Integer day) {
|
public Map<String, Object> selectSummaryPayType(Integer shopId, Integer day) {
|
||||||
Long startTime;
|
Long startTime;
|
||||||
@@ -314,4 +325,100 @@ public class SummaryServiceImpl implements SummaryService {
|
|||||||
map.put("countPayType", countPayTypeVOList);
|
map.put("countPayType", countPayTypeVOList);
|
||||||
return map;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package cn.ysk.cashier.vo;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
|
||||||
|
public class TbOrderPayCountByDayVo {
|
||||||
|
|
||||||
|
private String tradeDay;
|
||||||
|
private Object scanCode;
|
||||||
|
private Object wxLite;
|
||||||
|
private Object cash;
|
||||||
|
private BigDecimal total;
|
||||||
|
|
||||||
|
public String getTradeDay() {
|
||||||
|
return tradeDay;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTradeDay(String tradeDay) {
|
||||||
|
this.tradeDay = tradeDay;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getScanCode() {
|
||||||
|
return scanCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setScanCode(Object scanCode) {
|
||||||
|
this.scanCode = scanCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getWxLite() {
|
||||||
|
return wxLite;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWxLite(Object wxLite) {
|
||||||
|
this.wxLite = wxLite;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getCash() {
|
||||||
|
return cash;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCash(Object cash) {
|
||||||
|
this.cash = cash;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getTotal() {
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotal(BigDecimal total) {
|
||||||
|
this.total = total;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TbOrderPayCountByDayVo(String tradeDay, Object scanCode, Object wxLite, Object cash, BigDecimal total) {
|
||||||
|
this.tradeDay = tradeDay;
|
||||||
|
this.scanCode = scanCode;
|
||||||
|
this.wxLite = wxLite;
|
||||||
|
this.cash = cash;
|
||||||
|
this.total = total;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,13 +1,10 @@
|
|||||||
package cn.ysk.cashier.vo;
|
package cn.ysk.cashier.vo;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.StringJoiner;
|
|
||||||
|
|
||||||
|
|
||||||
public class TbOrderPayCountVo{
|
public class TbOrderPayCountVo{
|
||||||
private String icon;
|
private String icon;
|
||||||
private String payType;
|
private String payType;
|
||||||
private BigDecimal payAmount;
|
private Object payAmount;
|
||||||
|
|
||||||
public String getIcon() {
|
public String getIcon() {
|
||||||
return icon;
|
return icon;
|
||||||
@@ -25,28 +22,16 @@ public class TbOrderPayCountVo{
|
|||||||
this.payType = payType;
|
this.payType = payType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getPayAmount() {
|
public Object getPayAmount() {
|
||||||
return payAmount;
|
return payAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPayAmount(BigDecimal payAmount) {
|
public void setPayAmount(Object payAmount) {
|
||||||
this.payAmount = payAmount;
|
this.payAmount = payAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TbOrderPayCountVo() {
|
public TbOrderPayCountVo(String payType, Object payAmount) {
|
||||||
}
|
|
||||||
|
|
||||||
public TbOrderPayCountVo(String payType, BigDecimal payAmount) {
|
|
||||||
this.payType = payType;
|
this.payType = payType;
|
||||||
this.payAmount=payAmount;
|
this.payAmount=payAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return new StringJoiner(", ", TbOrderPayCountVo.class.getSimpleName() + "[", "]")
|
|
||||||
.add("icon='" + icon + "'")
|
|
||||||
.add("payType='" + payType + "'")
|
|
||||||
.add("payAmount=" + payAmount)
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package cn.ysk.cashier.vo;
|
||||||
|
|
||||||
|
|
||||||
|
public class TbOrderSalesCountByDayVo {
|
||||||
|
|
||||||
|
private String productName;
|
||||||
|
private String productSkuName;
|
||||||
|
|
||||||
|
private Long salesNum;
|
||||||
|
private Long refNum;
|
||||||
|
private Long num;
|
||||||
|
|
||||||
|
public String getProductName() {
|
||||||
|
return productName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProductName(String productName) {
|
||||||
|
this.productName = productName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProductSkuName() {
|
||||||
|
return productSkuName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProductSkuName(String productSkuName) {
|
||||||
|
this.productSkuName = productSkuName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getSalesNum() {
|
||||||
|
return salesNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSalesNum(Long salesNum) {
|
||||||
|
this.salesNum = salesNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getRefNum() {
|
||||||
|
return refNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRefNum(Long refNum) {
|
||||||
|
this.refNum = refNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getNum() {
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNum(Long num) {
|
||||||
|
this.num = num;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TbOrderSalesCountByDayVo(String productName, String productSkuName, Long salesNum, Long refNum, Long num) {
|
||||||
|
this.productName = productName;
|
||||||
|
this.productSkuName = productSkuName;
|
||||||
|
this.salesNum = salesNum;
|
||||||
|
this.refNum = refNum;
|
||||||
|
this.num = num;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user