查询所有桌台信息

This commit is contained in:
GYJ
2024-07-08 18:24:24 +08:00
parent 8245ae9b8c
commit 52ebdfa90b
3 changed files with 52 additions and 39 deletions

View File

@@ -32,8 +32,8 @@ import java.util.Date;
import java.util.List;
/**
* @website https://eladmin.vip
* @author lyf
* @website https://eladmin.vip
* @date 2024-03-02
**/
public interface TbOrderInfoRepository extends JpaRepository<TbOrderInfo, Integer>, JpaSpecificationExecutor<TbOrderInfo> {
@@ -65,7 +65,6 @@ public interface TbOrderInfoRepository extends JpaRepository<TbOrderInfo, Intege
int isRefund(@Param("source") Integer source, @Param("shopId") String shopId);
/**
*
* @param shopId
* @param startTime
* @param endTime
@@ -115,6 +114,7 @@ public interface TbOrderInfoRepository extends JpaRepository<TbOrderInfo, Intege
"AND trade_day BETWEEN :startTime AND :endTime " +
"GROUP BY shop_id,trade_day", nativeQuery = true)
List<Object[]> queryTbOrderPaySumByDay(@Param("shopId") String shopId, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
@Query(value = "SELECT ifnull( sum( order_amount ), 0 )" +
"FROM tb_order_info WHERE shop_id = :shopId AND ((status = 'closed') OR ( status ='refund' AND order_type != 'return' ))" +
"AND created_at > :startTime AND created_at < :endTime ", nativeQuery = true)
@@ -130,6 +130,7 @@ public interface TbOrderInfoRepository extends JpaRepository<TbOrderInfo, Intege
"AND trade_day BETWEEN :startTime AND :endTime " +
"GROUP BY shop_id,trade_day", nativeQuery = true)
List<Object[]> sumByDateOrderNum(@Param("shopId") String shopId, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
@Query(value = "select count(1), sum(pay_amount) FROM tb_order_info WHERE shop_id = :shopId AND status = 'closed' " +
"AND trade_day BETWEEN :startTime AND :endTime ", nativeQuery = true)
Tuple sumByShopIdToday(@Param("shopId") String shopId, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
@@ -184,6 +185,10 @@ public interface TbOrderInfoRepository extends JpaRepository<TbOrderInfo, Intege
"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.tableId")
List<ShopTableSaleInfoVo> queryShopTableSaleInfo(@Param("shopId") String shopId, @Param("startTime") Long startTime, @Param("endTime") Long endTime);
"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);
}

View File

@@ -475,13 +475,21 @@ public class SummaryServiceImpl implements SummaryService {
@Override
public List<ShopTableSaleInfoVo> selectSummaryTable(Integer shopId, Date startTime, Date endTime) {
List<String> shopTableCodes = tbOrderInfoRepository.queryShopTableIds(shopId);
long start = 1704038400000L;
long end = Instant.now().toEpochMilli();
if (startTime != null && endTime != null) {
start = startTime.getTime();
end = endTime.getTime();
}
return tbOrderInfoRepository.queryShopTableSaleInfo(shopId.toString(), start, end);
List<ShopTableSaleInfoVo> list = new ArrayList<>();
for (String shopTableCode : shopTableCodes) {
ShopTableSaleInfoVo shopTableSaleInfoVo = tbOrderInfoRepository.queryShopTableSaleInfo(shopId.toString(), shopTableCode, start, end);
list.add(shopTableSaleInfoVo);
}
return list;
}
@Override

View File

@@ -32,7 +32,7 @@ public class ShopTableSaleInfoVo {
this.tableName = tableName;
this.areaId = areaId;
this.areaName = areaName;
this.orderCount = orderCount;
this.orderAmount = orderAmount;
this.orderCount = orderCount == null ? 0 : orderCount;
this.orderAmount = orderAmount == null ? 0 : orderAmount;
}
}