修改销量和台桌导出
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package cn.ysk.cashier.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.ysk.cashier.dto.ShopSummaryDto;
|
||||
import cn.ysk.cashier.dto.shop.ShopTableSeleInfoDto;
|
||||
import cn.ysk.cashier.enums.PayTypeEnum;
|
||||
@@ -21,6 +22,7 @@ import cn.ysk.cashier.vo.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -68,6 +70,8 @@ public class SummaryServiceImpl implements SummaryService {
|
||||
|
||||
@Resource
|
||||
TbShopAreaRepository tbShopAreaRepository;
|
||||
@Autowired
|
||||
private TbOrderDetailRepository tbOrderDetailRepository;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -366,7 +370,7 @@ public class SummaryServiceImpl implements SummaryService {
|
||||
@Override
|
||||
public <T> Page<T> selectSummaryByDay(ShopSummaryDto summaryDto, Integer page, Integer size) {
|
||||
Pageable pageable = PageRequest.of(page, size);
|
||||
if(StringUtils.isBlank(summaryDto.getCateId())){
|
||||
if (StringUtils.isBlank(summaryDto.getCateId())) {
|
||||
summaryDto.setCateId(null);
|
||||
}
|
||||
if (summaryDto.getType() != null && summaryDto.getType() == 1) {//金额
|
||||
@@ -400,7 +404,7 @@ public class SummaryServiceImpl implements SummaryService {
|
||||
summaryDto.setStartTime(DateUtil.toDate(DateUtil.fromTimeStamp(1704038400L)));
|
||||
summaryDto.setEndTime(new Date());
|
||||
}
|
||||
return (Page<T>) detailRepository.queryTbOrderSalesCountByDay(Integer.valueOf(summaryDto.getShopId()),summaryDto.getCateId(),summaryDto.getProName(), summaryDto.getStartTime(), summaryDto.getEndTime(), pageable);
|
||||
return (Page<T>) detailRepository.queryTbOrderSalesCountByDay(Integer.valueOf(summaryDto.getShopId()), summaryDto.getCateId(), summaryDto.getProName(), summaryDto.getStartTime(), summaryDto.getEndTime(), pageable);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -408,12 +412,10 @@ public class SummaryServiceImpl implements SummaryService {
|
||||
@Override
|
||||
public void download(ShopSummaryDto summaryDto, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
// ConcurrentLinkedQueue<Map<String, Object>> list = new ConcurrentLinkedQueue();
|
||||
if(StringUtils.isBlank(summaryDto.getCateId())){
|
||||
if (StringUtils.isBlank(summaryDto.getCateId())) {
|
||||
summaryDto.setCateId(null);
|
||||
}
|
||||
|
||||
ArrayList<Integer> mergeRowIndex = new ArrayList<>();
|
||||
if (summaryDto.getType() != null && summaryDto.getType() == 1) {//金额
|
||||
Long start = 1704038400000L;
|
||||
Long end = Instant.now().toEpochMilli();
|
||||
@@ -438,38 +440,24 @@ public class SummaryServiceImpl implements SummaryService {
|
||||
summaryDto.setEndTime(new Date());
|
||||
}
|
||||
List<TbOrderSalesCountByDayVo> tbOrderSalesCountByDayVos = detailRepository
|
||||
.queryTbOrderSalesCountByDay(Integer.valueOf(summaryDto.getShopId()),summaryDto.getCateId(),summaryDto.getProName(), summaryDto.getStartTime(), summaryDto.getEndTime());
|
||||
.queryTbOrderSalesCountByDay(Integer.valueOf(summaryDto.getShopId()), summaryDto.getCateId(), summaryDto.getProName(), summaryDto.getStartTime(), summaryDto.getEndTime());
|
||||
tbOrderSalesCountByDayVos.forEach(all -> {
|
||||
List<TbOrderSaleVO> tbOrderSaleVOS = detailRepository.querySaleOrderInfo(new Timestamp(summaryDto.getStartTime().getTime()),
|
||||
new Timestamp(summaryDto.getEndTime().getTime()), all.getProductId(), all.getProductSkuId(), Integer.valueOf(summaryDto.getShopId()));
|
||||
for (TbOrderSaleVO tbOrderSaleVO : tbOrderSaleVOS) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("商品分类", all.getCateName());
|
||||
map.put("商品名称", all.getProductName());
|
||||
map.put("单 位", all.getUnitName());
|
||||
map.put("商品规格", StringUtils.isBlank(all.getProductSkuName()) ? "" : all.getProductSkuName());
|
||||
map.put("销 售 额", all.getSalesAmount());
|
||||
map.put("销 量", all.getSalesNum());
|
||||
map.put("单 价", all.getPrice());
|
||||
map.put("退 单 量", all.getRefNum());
|
||||
map.put("退 单 额", all.getRefAmount().compareTo(BigDecimal.ZERO)==0?all.getRefAmount():"-"+all.getRefAmount());
|
||||
map.put("总 量", all.getNum()-all.getRefNum());
|
||||
map.put("订单编号", tbOrderSaleVO.getOrderNo());
|
||||
map.put("售出数量", tbOrderSaleVO.getNum());
|
||||
list.add(map);
|
||||
}
|
||||
if (!tbOrderSaleVOS.isEmpty()) {
|
||||
if (mergeRowIndex.isEmpty()) {
|
||||
mergeRowIndex.add(tbOrderSaleVOS.size());
|
||||
}else {
|
||||
mergeRowIndex.add(mergeRowIndex.get(mergeRowIndex.size() - 1) + tbOrderSaleVOS.size());
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("商品分类", all.getCateName());
|
||||
map.put("商品名称", all.getProductName());
|
||||
map.put("单 位", all.getUnitName());
|
||||
map.put("商品规格", StringUtils.isBlank(all.getProductSkuName()) ? "" : all.getProductSkuName());
|
||||
map.put("单 价", all.getPrice());
|
||||
map.put("销 售 额", all.getSalesAmount());
|
||||
map.put("退 单 额", all.getRefAmount().compareTo(BigDecimal.ZERO) == 0 ? all.getRefAmount() : "-" + all.getRefAmount());
|
||||
map.put("总 销 量", all.getNum() - all.getRefNum());
|
||||
map.put("实际销量", all.getSalesNum());
|
||||
map.put("退 单 量", all.getRefNum());
|
||||
list.add(map);
|
||||
});
|
||||
|
||||
}
|
||||
FileUtil.downloadExcelAndMerge(list, 10, response, mergeRowIndex);
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -485,7 +473,7 @@ public class SummaryServiceImpl implements SummaryService {
|
||||
endTime = new Date();
|
||||
}
|
||||
TbOrderPayCountVo payCount = tbOrderInfoRepository.queryOrderPayCount(shopId, start, end);
|
||||
TbOrderPayCountVo refCount = tbOrderInfoRepository.queryTbOrderRefund(shopId, null,start, end);
|
||||
TbOrderPayCountVo refCount = tbOrderInfoRepository.queryTbOrderRefund(shopId, null, start, end);
|
||||
payCount.setPayAmount(new BigDecimal(payCount.getPayAmount().toString()).subtract(new BigDecimal(refCount.getPayAmount().toString())));
|
||||
payCount.setIcon("el-icon-coin");
|
||||
list.add(payCount);
|
||||
@@ -497,8 +485,8 @@ public class SummaryServiceImpl implements SummaryService {
|
||||
list.add(refCount);
|
||||
|
||||
TbOrderSalesCountByDayVo numCount = detailRepository.queryTbOrderSalesCount(Integer.valueOf(shopId), startTime, endTime);
|
||||
TbOrderPayCountVo salesNum =new TbOrderPayCountVo("el-icon-goods","销售量","0",numCount.getSalesNum()-numCount.getRefNum());
|
||||
TbOrderPayCountVo refNum =new TbOrderPayCountVo("el-icon-goods","退单量","0",numCount.getRefNum());
|
||||
TbOrderPayCountVo salesNum = new TbOrderPayCountVo("el-icon-goods", "销售量", "0", numCount.getSalesNum() - numCount.getRefNum());
|
||||
TbOrderPayCountVo refNum = new TbOrderPayCountVo("el-icon-goods", "退单量", "0", numCount.getRefNum());
|
||||
list.add(salesNum);
|
||||
list.add(refNum);
|
||||
return list;
|
||||
@@ -563,20 +551,62 @@ public class SummaryServiceImpl implements SummaryService {
|
||||
|
||||
List<ShopTableSaleInfoVo> infoVos = selectSummaryTable(shopTableSeleInfoDto.getShopId(), shopTableSeleInfoDto.getStartTime(), shopTableSeleInfoDto.getEndTime());
|
||||
|
||||
List<TbOrderSalesCountByTable> countByTables = tbOrderDetailRepository.queryTbOrderSalesCountByTable(shopTableSeleInfoDto.getShopId(), shopTableSeleInfoDto.getStartTime(), shopTableSeleInfoDto.getEndTime());
|
||||
|
||||
Map<String, List<TbOrderSalesCountByTable>> countByTableMap = countByTables.stream()
|
||||
.collect(Collectors.groupingBy(TbOrderSalesCountByTable::getTableId));
|
||||
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
|
||||
ArrayList<Integer> mergeRowIndex = new ArrayList<>();
|
||||
for (ShopTableSaleInfoVo all : infoVos) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
List<TbOrderSalesCountByTable> tables = countByTableMap.get(all.getTableCode());
|
||||
if (tables == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
map.put("开始时间", shopTableSeleInfoDto.getStartTime());
|
||||
map.put("结束时间", shopTableSeleInfoDto.getEndTime());
|
||||
map.put("区域名称", all.getAreaName());
|
||||
map.put("桌台名称", all.getTableName());
|
||||
map.put("订单数量", all.getOrderCount());
|
||||
map.put("销售额", all.getOrderAmount());
|
||||
for (TbOrderSalesCountByTable table : tables) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("开始时间", shopTableSeleInfoDto.getStartTime());
|
||||
map.put("结束时间", shopTableSeleInfoDto.getEndTime());
|
||||
map.put("区域名称", all.getAreaName());
|
||||
map.put("桌台名称", all.getTableName());
|
||||
map.put("商品分类", table.getCateName());
|
||||
map.put("商品名称", table.getProductName());
|
||||
map.put("单位", table.getUnitName());
|
||||
map.put("商品规格", table.getProductSkuName());
|
||||
map.put("销量", table.getSalesNum());
|
||||
map.put("销售额", table.getSalesAmount());
|
||||
// map.put("订单数量", all.getOrderCount());
|
||||
// map.put("销售额", all.getOrderAmount());
|
||||
// map.put("商品名称", table.getProductName());
|
||||
// map.put("销售数量", table.getSalesNum());
|
||||
list.add(map);
|
||||
}
|
||||
|
||||
list.add(map);
|
||||
|
||||
|
||||
// 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);
|
||||
|
||||
|
||||
if (!tables.isEmpty()) {
|
||||
if (mergeRowIndex.isEmpty()) {
|
||||
mergeRowIndex.add(tables.size());
|
||||
}else {
|
||||
mergeRowIndex.add(mergeRowIndex.get(mergeRowIndex.size() - 1) + tables.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
// FileUtil.downloadExcel(list, response);
|
||||
FileUtil.downloadExcelAndMerge(list, 4, response, mergeRowIndex);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user