优化台桌统计

This commit is contained in:
GYJ 2024-08-08 10:42:13 +08:00
parent 260d6eb7d7
commit bff2ad2250
2 changed files with 2 additions and 26 deletions

View File

@ -171,28 +171,6 @@ public interface TbOrderInfoRepository extends JpaRepository<TbOrderInfo, Intege
"AND ((info.status = 'closed') OR ( info.status ='refund' AND info.orderType != 'return' )) ")
TbOrderPayCountVo queryOrderPayCash(@Param("shopId") String shopId, @Param("startTime") Long startTime, @Param("endTime") Long endTime);
@Query("SELECT new cn.ysk.cashier.vo.ShopTableSaleInfoVo(" +
"info.id," +
"info.shopId," +
"info.tableId," +
"table.name," +
"table.areaId," +
"area.name," +
"COUNT(1)," +
"SUM( info.orderAmount)) " +
"FROM TbOrderInfo info " +
"LEFT JOIN TbShopTable table ON info.tableId = table.qrcode " +
"LEFT JOIN TbShopArea as area on table.areaId = area.id " +
"WHERE info.shopId = :shopId " +
"AND info.createdAt > :startTime AND info.createdAt < :endTime " +
"AND ((info.status = 'closed') OR ( info.status ='refund' AND info.orderType != 'return' )) " +
"AND info.tableId = :qrcode ")
ShopTableSaleInfoVo queryShopTableSaleInfo(@Param("shopId") String shopId, @Param("qrcode") String qrcode,
@Param("startTime") Long startTime, @Param("endTime") Long endTime);
@Query("select table.qrcode from TbShopTable table where table.shopId = :shopId")
List<String> queryShopTableIds(@Param("shopId") Integer shopId);
@Query("SELECT new cn.ysk.cashier.vo.ShopTableVo(" +
"table.qrcode," +
"table.shopId," +
@ -225,6 +203,6 @@ public interface TbOrderInfoRepository extends JpaRepository<TbOrderInfo, Intege
"AND table.qrcode is not null " +
"AND table.qrcode != '' " +
"GROUP BY info.tableId ")
List<ShopTableSaleInfoVo> queryShopTableSaleInfo2(@Param("shopId") String shopId,
List<ShopTableSaleInfoVo> queryShopTableSaleInfo(@Param("shopId") String shopId,
@Param("startTime") Long startTime, @Param("endTime") Long endTime);
}

View File

@ -506,8 +506,6 @@ public class SummaryServiceImpl implements SummaryService {
@Override
public List<ShopTableSaleInfoVo> selectSummaryTable(Integer shopId, Date startTime, Date endTime) {
// List<String> shopTableCodes = tbOrderInfoRepository.queryShopTableIds(shopId);
List<ShopTableVo> tableVos = tbOrderInfoRepository.queryShopTableVoByShopId(shopId);
long start = 1704038400000L;
@ -517,7 +515,7 @@ public class SummaryServiceImpl implements SummaryService {
end = endTime.getTime();
}
List<ShopTableSaleInfoVo> saleInfoVo = tbOrderInfoRepository.queryShopTableSaleInfo2(shopId.toString(), start, end);
List<ShopTableSaleInfoVo> saleInfoVo = tbOrderInfoRepository.queryShopTableSaleInfo(shopId.toString(), start, end);
Map<String, ShopTableVo> tableMap = tableVos.stream()
.collect(Collectors.toMap(ShopTableVo::getQrcode, Function.identity()));