Merge remote-tracking branch 'origin/dev' into zs
This commit is contained in:
commit
62ca02cdc4
|
|
@ -36,12 +36,12 @@ public class TbProductGroupController {
|
|||
@Resource
|
||||
private TbProductService tbProductService;
|
||||
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('tbProductGroup:list')")
|
||||
public void exportTbProductGroup(HttpServletResponse response, TbProductGroupQueryCriteria criteria) throws IOException {
|
||||
tbProductGroupService.download(tbProductGroupService.queryAll(criteria), response);
|
||||
}
|
||||
// @ApiOperation("导出数据")
|
||||
// @GetMapping(value = "/download")
|
||||
// @PreAuthorize("@el.check('tbProductGroup:list')")
|
||||
// public void exportTbProductGroup(HttpServletResponse response, TbProductGroupQueryCriteria criteria) throws IOException {
|
||||
// tbProductGroupService.download(tbProductGroupService.queryAll(criteria), response);
|
||||
// }
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation("查询product/group")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package cn.ysk.cashier.controller.shop;
|
||||
|
||||
import cn.ysk.cashier.annotation.rest.AnonymousPostMapping;
|
||||
import cn.ysk.cashier.dto.ShopSummaryDto;
|
||||
import cn.ysk.cashier.service.SummaryService;
|
||||
import cn.ysk.cashier.vo.TbOrderPayCountVo;
|
||||
|
|
@ -41,10 +42,10 @@ public class SummaryByDayController {
|
|||
}
|
||||
|
||||
@GetMapping(value = "count")
|
||||
public List<TbOrderPayCountVo> summaryCount(@RequestParam String shopId,
|
||||
public List<TbOrderPayCountVo> summaryCount(ShopSummaryDto summaryDto,
|
||||
@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);
|
||||
return summaryService.summaryCount(summaryDto, startTime, endTime);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ public class SummaryController {
|
|||
}
|
||||
|
||||
@PostMapping("/table/download")
|
||||
@AnonymousPostMapping
|
||||
private void downloadShopSummaryTable(HttpServletResponse response, @RequestBody ShopTableSeleInfoDto exportRequest) throws IOException {
|
||||
summaryService.downloadTableSeleInfo(exportRequest, response);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,9 @@ public class ShopSummaryDto {
|
|||
}
|
||||
|
||||
public void setCateId(String cateId) {
|
||||
this.cateId = cateId;
|
||||
if(StringUtils.isNotBlank(cateId)){
|
||||
this.cateId = cateId;
|
||||
}
|
||||
}
|
||||
|
||||
public String getShopId() {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@
|
|||
package cn.ysk.cashier.dto.product;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -60,4 +62,10 @@ public class TbProductGroupDto implements Serializable {
|
|||
private Long createdAt;
|
||||
|
||||
private Long updatedAt;
|
||||
|
||||
private Integer useTime;
|
||||
|
||||
private String saleStartTime;
|
||||
|
||||
private String saleEndTime;
|
||||
}
|
||||
|
|
@ -1,18 +1,3 @@
|
|||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package cn.ysk.cashier.pojo.product;
|
||||
|
||||
import lombok.Data;
|
||||
|
|
@ -86,6 +71,17 @@ public class TbProductGroup implements Serializable {
|
|||
@ApiModelProperty(value = "updatedAt")
|
||||
private Long updatedAt;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "`use_time`",nullable = false)
|
||||
@ApiModelProperty(value = "是否开启时间管控")
|
||||
private Integer useTime = 0;
|
||||
|
||||
@Column(name = "`sale_start_time`")
|
||||
private String saleStartTime;
|
||||
|
||||
@Column(name = "`sale_end_time`")
|
||||
private String saleEndTime;
|
||||
|
||||
public void copy(TbProductGroup source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import cn.ysk.cashier.pojo.order.TbOrderDetail;
|
|||
import cn.ysk.cashier.vo.TbOrderPayCountVo;
|
||||
import cn.ysk.cashier.vo.TbOrderSaleVO;
|
||||
import cn.ysk.cashier.vo.TbOrderSalesCountByDayVo;
|
||||
import cn.ysk.cashier.vo.TbOrderSalesCountByTable;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
|
@ -37,20 +38,6 @@ public interface TbOrderDetailRepository extends JpaRepository<TbOrderDetail, In
|
|||
|
||||
@Query("SELECT cart FROM TbOrderDetail cart WHERE cart.orderId in :ids")
|
||||
List<TbOrderDetail> searchDetailByOrderIds(@Param("ids")List<Integer> ids);
|
||||
@Query(value = "SELECT " +
|
||||
"new cn.ysk.cashier.vo.TbOrderSaleVO(oi.orderNo, od.num, od.price, od.status, 0)\n" +
|
||||
"FROM\n" +
|
||||
"TbOrderInfo oi\n" +
|
||||
"LEFT JOIN TbOrderDetail od ON oi.id = od.orderId \n" +
|
||||
"WHERE\n" +
|
||||
"od.shopId = :shopId \n" +
|
||||
"AND ( od.status = 'closed' OR od.status = 'refund' ) \n" +
|
||||
"AND od.createTime > :startTime \n" +
|
||||
"AND od.createTime < :endTime \n" +
|
||||
"AND (:productId is null or od.productId = :productId)\n" +
|
||||
"AND (:productId is null or od.productSkuId = :productSkuId)")
|
||||
List<TbOrderSaleVO> querySaleOrderInfo(@Param("startTime") Timestamp startTime, @Param("endTime") Timestamp endTime, @Param("productId") Integer productId, @Param("productSkuId") Integer productSkuId, @Param("shopId") Integer shopId);
|
||||
|
||||
|
||||
@Query("SELECT new cn.ysk.cashier.vo.TbOrderSalesCountByDayVo(" +
|
||||
"info.productName, info.productSkuName, cate.name, unit.name,info.price," +
|
||||
|
|
@ -115,7 +102,37 @@ public interface TbOrderDetailRepository extends JpaRepository<TbOrderDetail, In
|
|||
"ORDER BY salesNum DESC")
|
||||
List<TbOrderSalesCountByDayVo> queryTbOrderSalesCountByDay(@Param("shopId") Integer shopId,@Param("cateId")String cateId,@Param("proName")String proName, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
|
||||
|
||||
@Query("SELECT new cn.ysk.cashier.vo.TbOrderSalesCountByDayVo(" +
|
||||
@Query(value = "SELECT " +
|
||||
"new cn.ysk.cashier.vo.TbOrderSaleVO(oi.orderNo, od.num, od.price, od.status,od.productSkuId)\n" +
|
||||
"FROM\n" +
|
||||
"TbOrderInfo oi\n" +
|
||||
"LEFT JOIN TbOrderDetail od ON oi.id = od.orderId \n" +
|
||||
"WHERE\n" +
|
||||
"od.shopId = :shopId \n" +
|
||||
"AND ( od.status = 'closed' OR od.status = 'refund' ) \n" +
|
||||
"AND od.createTime > :startTime \n" +
|
||||
"AND od.createTime < :endTime \n" +
|
||||
"AND (:productId is null or od.productId = :productId)\n" +
|
||||
"AND (:productSkuId is null or od.productSkuId = :productSkuId)")
|
||||
List<TbOrderSaleVO> querySaleOrderInfo(@Param("startTime") Timestamp startTime, @Param("endTime") Timestamp endTime, @Param("productId") Integer productId, @Param("productSkuId") Integer productSkuId, @Param("shopId") Integer shopId);
|
||||
@Query("SELECT new cn.ysk.cashier.vo.TbOrderSalesCountByDayVo(" +
|
||||
"SUM(CASE WHEN orders.orderType!='return' THEN info.num ELSE 0 END)," +
|
||||
"SUM(CASE WHEN orders.orderType='return' THEN info.num ELSE 0 END), " +
|
||||
"SUM(info.num), " +
|
||||
"SUM(CASE WHEN orders.orderType!='return' THEN info.priceAmount ELSE 0 END), " +
|
||||
"SUM(CASE WHEN orders.orderType='return' THEN info.priceAmount ELSE 0 END)) " +
|
||||
"FROM TbOrderInfo orders " +
|
||||
"LEFT JOIN TbOrderDetail info on orders.id=info.orderId " +
|
||||
"LEFT JOIN TbProduct pro ON info.productId = pro.id " +
|
||||
"WHERE info.shopId = :shopId " +
|
||||
"AND (:cateId IS NULL OR pro.categoryId = :cateId) " +
|
||||
"AND (:proName IS NULL OR info.productName LIKE %:proName%) " +
|
||||
"AND info.createTime > :startTime AND info.createTime < :endTime " +
|
||||
"AND (info.status = 'closed' OR info.status = 'refund') ")
|
||||
TbOrderSalesCountByDayVo queryTbOrderSalesCountByDaysummaryCount(@Param("shopId") Integer shopId,@Param("cateId")String cateId,@Param("proName")String proName, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
|
||||
|
||||
|
||||
@Query("SELECT new cn.ysk.cashier.vo.TbOrderSalesCountByDayVo(" +
|
||||
"COALESCE(CAST(SUM(CASE WHEN orders.orderType!='return' THEN info.num ELSE 0 END) as long),0), " +
|
||||
"COALESCE(CAST(SUM(CASE WHEN orders.orderType='return' THEN info.num ELSE 0 END) as long),0))" +
|
||||
"FROM TbOrderInfo orders " +
|
||||
|
|
@ -164,4 +181,26 @@ public interface TbOrderDetailRepository extends JpaRepository<TbOrderDetail, In
|
|||
@Param("startTime") Date startTime, @Param("endTime") Date endTime);
|
||||
|
||||
|
||||
@Query("SELECT new cn.ysk.cashier.vo.TbOrderSalesCountByTable(" +
|
||||
"info.productName, info.productSkuName, cate.name, unit.name,info.price," +
|
||||
"SUM(CASE WHEN orders.orderType!='return' THEN info.num ELSE 0 END) as salesNum, " +
|
||||
"SUM(CASE WHEN orders.orderType='return' THEN info.num ELSE 0 END), " +
|
||||
"SUM(info.num), " +
|
||||
"SUM(CASE WHEN orders.orderType!='return' THEN info.priceAmount ELSE 0 END), " +
|
||||
"SUM(CASE WHEN orders.orderType='return' THEN info.priceAmount ELSE 0 END), " +
|
||||
"info.productId, " +
|
||||
"info.productSkuId," +
|
||||
"orders.tableId ) " +
|
||||
"FROM TbOrderInfo orders " +
|
||||
"LEFT JOIN TbOrderDetail info on orders.id=info.orderId " +
|
||||
"LEFT JOIN TbProduct pro ON info.productId = pro.id " +
|
||||
"LEFT JOIN TbShopUnit unit ON unit.id = pro.unitId " +
|
||||
"LEFT JOIN TbShopCategory cate ON cate.id = pro.categoryId " +
|
||||
"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, orders.tableId " +
|
||||
"ORDER BY salesNum DESC")
|
||||
List<TbOrderSalesCountByTable> queryTbOrderSalesCountByTable(@Param("shopId") Integer shopId, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -189,6 +189,7 @@ public interface TbOrderInfoRepository extends JpaRepository<TbOrderInfo, Intege
|
|||
"info.id," +
|
||||
"info.shopId," +
|
||||
"info.tableId," +
|
||||
"table.qrcode," +
|
||||
"table.name," +
|
||||
"table.areaId," +
|
||||
"area.name," +
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public interface SummaryService {
|
|||
*/
|
||||
void download(ShopSummaryDto summaryDto, HttpServletResponse response) throws IOException;
|
||||
|
||||
List<TbOrderPayCountVo> summaryCount(String shopId, Date startTime, Date endTime);
|
||||
List<TbOrderPayCountVo> summaryCount(ShopSummaryDto summaryDto, Date startTime, Date endTime);
|
||||
|
||||
List<ShopTableSaleInfoVo> selectSummaryTable(Integer shopId, Date startTime, Date endTime);
|
||||
|
||||
|
|
|
|||
|
|
@ -4,16 +4,12 @@ import cn.ysk.cashier.dto.ShopSummaryDto;
|
|||
import cn.ysk.cashier.dto.shop.ShopTableSeleInfoDto;
|
||||
import cn.ysk.cashier.enums.PayTypeEnum;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbOrderInfoMapper;
|
||||
import cn.ysk.cashier.mybatis.service.TbShopUserFlowService;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopTable;
|
||||
import cn.ysk.cashier.repository.ShopUserDutyDetailRepository;
|
||||
import cn.ysk.cashier.repository.ShopUserDutyRepository;
|
||||
import cn.ysk.cashier.repository.TbTokenRepository;
|
||||
import cn.ysk.cashier.repository.order.TbOrderDetailRepository;
|
||||
import cn.ysk.cashier.repository.order.TbOrderInfoRepository;
|
||||
import cn.ysk.cashier.repository.shop.TbShopAreaRepository;
|
||||
import cn.ysk.cashier.repository.shop.TbShopTableRepository;
|
||||
import cn.ysk.cashier.repository.shop.TbShopUserRepository;
|
||||
import cn.ysk.cashier.service.SummaryService;
|
||||
import cn.ysk.cashier.utils.DateUtil;
|
||||
|
|
@ -22,6 +18,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;
|
||||
|
|
@ -34,13 +31,11 @@ import java.io.IOException;
|
|||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.math.RoundingMode;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -64,13 +59,8 @@ public class SummaryServiceImpl implements SummaryService {
|
|||
|
||||
@Resource
|
||||
private TbShopUserFlowService tbShopUserFlowService;
|
||||
|
||||
@Resource
|
||||
private TbShopTableRepository shopTableRepository;
|
||||
|
||||
@Resource
|
||||
TbShopAreaRepository tbShopAreaRepository;
|
||||
private final TbOrderInfoMapper orderInfoMapper;
|
||||
@Autowired
|
||||
private TbOrderDetailRepository tbOrderDetailRepository;
|
||||
|
||||
|
||||
@Override
|
||||
|
|
@ -369,7 +359,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) {//金额
|
||||
|
|
@ -403,19 +393,18 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@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())){
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
if (StringUtils.isBlank(summaryDto.getCateId())) {
|
||||
summaryDto.setCateId(null);
|
||||
}
|
||||
List<Integer> mergeRowIndex = Collections.synchronizedList(new ArrayList<>());
|
||||
|
||||
if (summaryDto.getType() != null && summaryDto.getType() == 1) {//金额
|
||||
Long start = 1704038400000L;
|
||||
Long end = Instant.now().toEpochMilli();
|
||||
|
|
@ -440,71 +429,28 @@ 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());
|
||||
|
||||
ArrayList<Integer> skuIds = new ArrayList<>();
|
||||
for (TbOrderSalesCountByDayVo tbOrderSalesCountByDayVo : tbOrderSalesCountByDayVos) {
|
||||
if (tbOrderSalesCountByDayVo.getProductSkuId() != null) {
|
||||
skuIds.add(tbOrderSalesCountByDayVo.getProductSkuId());
|
||||
}
|
||||
}
|
||||
|
||||
HashMap<String, List<TbOrderSaleVO>> saleOrderMap = new HashMap<>();
|
||||
if (!skuIds.isEmpty()) {
|
||||
List<TbOrderSaleVO> tbOrderSaleVOS = orderInfoMapper.selectAllSaleInfo(new Timestamp(summaryDto.getStartTime().getTime()),
|
||||
new Timestamp(summaryDto.getEndTime().getTime()), skuIds, Integer.valueOf(summaryDto.getShopId()));
|
||||
|
||||
for (TbOrderSaleVO tbOrderSaleVO : tbOrderSaleVOS) {
|
||||
List<TbOrderSaleVO> orderSaleVOS = saleOrderMap.get(tbOrderSaleVO.getSkuId().toString());
|
||||
if (orderSaleVOS == null) {
|
||||
orderSaleVOS = new ArrayList<>();
|
||||
}
|
||||
orderSaleVOS.add(tbOrderSaleVO);
|
||||
|
||||
saleOrderMap.put(tbOrderSaleVO.getSkuId().toString(), orderSaleVOS);
|
||||
}
|
||||
}
|
||||
|
||||
.queryTbOrderSalesCountByDay(Integer.valueOf(summaryDto.getShopId()), summaryDto.getCateId(), summaryDto.getProName(), summaryDto.getStartTime(), summaryDto.getEndTime());
|
||||
tbOrderSalesCountByDayVos.forEach(all -> {
|
||||
List<TbOrderSaleVO> tbOrderSaleVOS = saleOrderMap.get(all.getProductSkuId().toString());
|
||||
if (tbOrderSaleVOS == null) {
|
||||
return;
|
||||
}
|
||||
// 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
|
||||
public List<TbOrderPayCountVo> summaryCount(String shopId, Date startTime, Date endTime) {
|
||||
public List<TbOrderPayCountVo> summaryCount(ShopSummaryDto summaryDto, Date startTime, Date endTime) {
|
||||
List<TbOrderPayCountVo> list = new ArrayList<>();
|
||||
Long start = 1704038400000L;
|
||||
Long end = Instant.now().toEpochMilli();
|
||||
|
|
@ -515,23 +461,35 @@ public class SummaryServiceImpl implements SummaryService {
|
|||
startTime = DateUtil.toDate(DateUtil.fromTimeStamp(1704038400L));
|
||||
endTime = new Date();
|
||||
}
|
||||
TbOrderPayCountVo payCount = tbOrderInfoRepository.queryOrderPayCount(shopId, 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);
|
||||
TbOrderPayCountVo cashCount = tbOrderInfoRepository.queryOrderPayCash(shopId, start, end);
|
||||
cashCount.setIcon("el-icon-circle-check");
|
||||
list.add(cashCount);
|
||||
refCount.setPayType("退款金额");
|
||||
refCount.setIcon("el-icon-money");
|
||||
list.add(refCount);
|
||||
if (summaryDto.getType() != null && summaryDto.getType() == 1) {
|
||||
TbOrderPayCountVo payCount = tbOrderInfoRepository.queryOrderPayCount(summaryDto.getShopId(), start, end);
|
||||
TbOrderPayCountVo refCount = tbOrderInfoRepository.queryTbOrderRefund(summaryDto.getShopId(), null,start, end);
|
||||
payCount.setPayAmount(new BigDecimal(payCount.getPayAmount().toString()).subtract(new BigDecimal(refCount.getPayAmount().toString())));
|
||||
payCount.setIcon("el-icon-coin");
|
||||
list.add(payCount);
|
||||
TbOrderPayCountVo cashCount = tbOrderInfoRepository.queryOrderPayCash(summaryDto.getShopId(), start, end);
|
||||
cashCount.setIcon("el-icon-circle-check");
|
||||
list.add(cashCount);
|
||||
refCount.setPayType("退款金额");
|
||||
refCount.setIcon("el-icon-money");
|
||||
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());
|
||||
list.add(salesNum);
|
||||
list.add(refNum);
|
||||
TbOrderSalesCountByDayVo numCount = detailRepository.queryTbOrderSalesCount(Integer.valueOf(summaryDto.getShopId()), startTime, endTime);
|
||||
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);
|
||||
}else {
|
||||
TbOrderSalesCountByDayVo tbOrderSalesCountByDayVo = detailRepository.queryTbOrderSalesCountByDaysummaryCount(Integer.valueOf(summaryDto.getShopId()), summaryDto.getCateId(), summaryDto.getProName(), summaryDto.getStartTime(), summaryDto.getEndTime());
|
||||
TbOrderPayCountVo zong =new TbOrderPayCountVo("el-icon-coin","总金额","1",tbOrderSalesCountByDayVo.getSalesAmount());
|
||||
TbOrderPayCountVo tuikuan =new TbOrderPayCountVo("el-icon-money","退款金额","1",tbOrderSalesCountByDayVo.getRefAmount());
|
||||
TbOrderPayCountVo xiaoliang =new TbOrderPayCountVo("el-icon-goods","销售量","0",tbOrderSalesCountByDayVo.getSalesNum());
|
||||
TbOrderPayCountVo tuidan =new TbOrderPayCountVo("el-icon-goods","退单量","0",tbOrderSalesCountByDayVo.getRefNum());
|
||||
list.add(zong);
|
||||
list.add(tuikuan);
|
||||
list.add(xiaoliang);
|
||||
list.add(tuidan);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
|
@ -594,20 +552,43 @@ public class SummaryServiceImpl implements SummaryService {
|
|||
|
||||
List<ShopTableSaleInfoVo> infoVos = selectSummaryTable(shopTableSeleInfoDto.getShopId(), shopTableSeleInfoDto.getStartTime(), shopTableSeleInfoDto.getEndTime());
|
||||
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
List<TbOrderSalesCountByTable> countByTables = tbOrderDetailRepository.queryTbOrderSalesCountByTable(shopTableSeleInfoDto.getShopId(), shopTableSeleInfoDto.getStartTime(), shopTableSeleInfoDto.getEndTime());
|
||||
|
||||
Map<String, List<TbOrderSalesCountByTable>> countByTableMap = countByTables.stream()
|
||||
.collect(Collectors.groupingBy(TbOrderSalesCountByTable::getTableId));
|
||||
|
||||
ConcurrentLinkedQueue<Map<String, Object>> list = new ConcurrentLinkedQueue<>();
|
||||
|
||||
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());
|
||||
list.add(map);
|
||||
}
|
||||
|
||||
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.downloadExcelAndMerge(list, 4, response, mergeRowIndex);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package cn.ysk.cashier.service.impl.productimpl;
|
||||
|
||||
import cn.ysk.cashier.dto.product.TbProductSortCriteria;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.pojo.product.TbProduct;
|
||||
import cn.ysk.cashier.repository.product.TbProductRepository;
|
||||
import cn.ysk.cashier.pojo.product.TbProductGroup;
|
||||
|
|
@ -14,6 +15,7 @@ import cn.ysk.cashier.config.security.service.dto.OnlineUserDto;
|
|||
import lombok.RequiredArgsConstructor;
|
||||
import cn.ysk.cashier.service.product.TbProductGroupService;
|
||||
import cn.ysk.cashier.mapper.product.TbProductGroupMapper;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
|
@ -86,6 +88,10 @@ public class TbProductGroupServiceImpl implements TbProductGroupService {
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public TbProductGroupDto create(TbProductGroup resources) {
|
||||
if (resources.getUseTime() == 1) {
|
||||
if (StringUtils.isBlank(resources.getSaleStartTime()) || StringUtils.isBlank(resources.getSaleEndTime()))
|
||||
throw new BadRequestException("可售时间不可为空");
|
||||
}
|
||||
resources.setCreatedAt(Instant.now().toEpochMilli());
|
||||
resources.setUpdatedAt(Instant.now().toEpochMilli());
|
||||
TbProductGroup save = tbProductGroupRepository.save(resources);
|
||||
|
|
@ -96,7 +102,10 @@ public class TbProductGroupServiceImpl implements TbProductGroupService {
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(TbProductGroup resources) {
|
||||
|
||||
if (resources.getUseTime() == 1) {
|
||||
if (StringUtils.isBlank(resources.getSaleStartTime()) || StringUtils.isBlank(resources.getSaleEndTime()))
|
||||
throw new BadRequestException("可售时间不可为空");
|
||||
}
|
||||
TbProductGroup tbProductGroup = tbProductGroupRepository.findById(resources.getId()).orElseGet(TbProductGroup::new);
|
||||
// TbProductGroup byName = tbProductGroupRepository.findByName(resources.getName(), resources.getShopId());
|
||||
// if (byName != null){
|
||||
|
|
@ -191,7 +200,7 @@ public class TbProductGroupServiceImpl implements TbProductGroupService {
|
|||
|
||||
@Override
|
||||
public ResponseEntity<Object> updateProductIds(AddProduct addProduct, String userName) {
|
||||
OnlineUserDto onlineUser = onlineUserService.getOne(addProduct.getKey());
|
||||
// OnlineUserDto onlineUser = onlineUserService.getOne(addProduct.getKey());
|
||||
|
||||
if (addProduct.getIds().size()<1){
|
||||
return new ResponseEntity<>("错误", HttpStatus.NOT_ACCEPTABLE);
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ public class ShopTableSaleInfoVo {
|
|||
|
||||
private Object tableId;
|
||||
|
||||
private String tableCode;
|
||||
|
||||
private Object tableName;
|
||||
|
||||
private Object areaId;
|
||||
|
|
@ -24,11 +26,12 @@ public class ShopTableSaleInfoVo {
|
|||
private Object orderAmount;
|
||||
|
||||
|
||||
public ShopTableSaleInfoVo(Integer id, Object shopId, Object tableId, Object tableName,
|
||||
public ShopTableSaleInfoVo(Integer id, Object shopId, Object tableId, String tableCode, Object tableName,
|
||||
Object areaId, Object areaName, Object orderCount, Object orderAmount) {
|
||||
this.id = id;
|
||||
this.shopId = shopId;
|
||||
this.tableId = tableId;
|
||||
this.tableCode = tableCode;
|
||||
this.tableName = tableName;
|
||||
this.areaId = areaId;
|
||||
this.areaName = areaName;
|
||||
|
|
|
|||
|
|
@ -266,10 +266,10 @@ public class StockV2Vo {
|
|||
this.type = "称重商品";
|
||||
break;
|
||||
case "currentPrice":
|
||||
this.type = "套餐商品/团购卷";
|
||||
this.type = "时价商品";
|
||||
break;
|
||||
case "group":
|
||||
this.type = "时价商品";
|
||||
this.type = "套餐商品/团购卷";
|
||||
break;
|
||||
default:
|
||||
this.type = type;
|
||||
|
|
|
|||
|
|
@ -48,10 +48,10 @@ public class StockVo {
|
|||
this.type = "称重商品";
|
||||
break;
|
||||
case "currentPrice":
|
||||
this.type = "套餐商品/团购卷";
|
||||
this.type = "时价商品";
|
||||
break;
|
||||
case "group":
|
||||
this.type = "时价商品";
|
||||
this.type = "套餐商品/团购卷";
|
||||
break;
|
||||
default:
|
||||
this.type = type;
|
||||
|
|
|
|||
|
|
@ -152,11 +152,21 @@ public class TbOrderSalesCountByDayVo {
|
|||
count();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public TbOrderSalesCountByDayVo(Long salesNum, Long refNum, Long num, BigDecimal salesAmount, BigDecimal refAmount) {
|
||||
this.salesNum = salesNum;
|
||||
this.refNum = refNum;
|
||||
this.salesAmount = salesAmount;
|
||||
this.refAmount = refAmount;
|
||||
this.num = num;
|
||||
count();
|
||||
}
|
||||
|
||||
public void count(){
|
||||
salesNum=salesNum-refNum;
|
||||
salesAmount=salesAmount.subtract(refAmount);
|
||||
if (salesNum == null) salesNum = 0l;
|
||||
if (refNum == null) refNum = 0l;
|
||||
salesNum = salesNum - refNum;
|
||||
if (salesAmount == null) salesAmount = BigDecimal.ZERO;
|
||||
if (refAmount == null) refAmount = BigDecimal.ZERO;
|
||||
salesAmount = salesAmount.subtract(refAmount);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,64 @@
|
|||
package cn.ysk.cashier.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author GYJ
|
||||
*/
|
||||
@Data
|
||||
public class TbOrderSalesCountByTable {
|
||||
private String productName;
|
||||
private String productSkuName;
|
||||
private String cateName;
|
||||
private String unitName;
|
||||
private BigDecimal price;
|
||||
private Long salesNum;
|
||||
private Long refNum;
|
||||
private BigDecimal salesAmount;
|
||||
private BigDecimal refAmount;
|
||||
private Long num;
|
||||
private Integer productId;
|
||||
private Integer productSkuId;
|
||||
private String tableId;
|
||||
|
||||
public TbOrderSalesCountByTable(String productName, String productSkuName, String cateName,String unitName,BigDecimal price,
|
||||
Long salesNum, Long refNum, Long num, BigDecimal salesAmount, BigDecimal refAmount) {
|
||||
this.productName = productName;
|
||||
this.productSkuName = productSkuName;
|
||||
this.cateName = cateName;
|
||||
this.unitName = unitName;
|
||||
this.price = price;
|
||||
this.salesNum = salesNum;
|
||||
this.refNum = refNum;
|
||||
this.salesAmount = salesAmount;
|
||||
this.refAmount = refAmount;
|
||||
this.num = num;
|
||||
count();
|
||||
}
|
||||
|
||||
public TbOrderSalesCountByTable(String productName, String productSkuName, String cateName,String unitName,BigDecimal price,
|
||||
Long salesNum, Long refNum, Long num, BigDecimal salesAmount, BigDecimal refAmount,
|
||||
Integer productId, Integer productSkuId, String tableId) {
|
||||
this.productName = productName;
|
||||
this.productSkuName = productSkuName;
|
||||
this.cateName = cateName;
|
||||
this.unitName = unitName;
|
||||
this.price = price;
|
||||
this.salesNum = salesNum;
|
||||
this.refNum = refNum;
|
||||
this.salesAmount = salesAmount;
|
||||
this.refAmount = refAmount;
|
||||
this.num = num;
|
||||
this.productId = productId;
|
||||
this.productSkuId = productSkuId;
|
||||
this.tableId = tableId;
|
||||
count();
|
||||
}
|
||||
|
||||
public void count(){
|
||||
salesNum=salesNum-refNum;
|
||||
salesAmount=salesAmount.subtract(refAmount);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue