统计台桌售出信息

This commit is contained in:
GYJ 2024-07-06 16:40:21 +08:00
parent 48950bcf14
commit 5e16de0bc8
5 changed files with 81 additions and 3 deletions

View File

@ -1,8 +1,10 @@
package cn.ysk.cashier.controller.shop;
import cn.ysk.cashier.annotation.rest.AnonymousGetMapping;
import cn.ysk.cashier.service.SummaryService;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@ -10,6 +12,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.Date;
/**
* @author lyf
@ -51,5 +54,13 @@ public class SummaryController {
return summaryService.selectSummaryPayType(shopId,day);
}
@GetMapping("/table")
@AnonymousGetMapping
private Object shopSummaryTable(@RequestParam Integer shopId,
@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.selectSummaryTable(shopId, startTime, endTime);
}
}

View File

@ -16,8 +16,7 @@
package cn.ysk.cashier.repository.order;
import cn.ysk.cashier.pojo.order.TbOrderInfo;
import cn.ysk.cashier.repository.mapping.CountPayTypeMapping;
import cn.ysk.cashier.vo.ProductExtVO;
import cn.ysk.cashier.vo.ShopTableSaleInfoVo;
import cn.ysk.cashier.vo.TbOrderPayCountByDayVo;
import cn.ysk.cashier.vo.TbOrderPayCountVo;
import org.apache.ibatis.annotations.Param;
@ -170,5 +169,21 @@ 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' )) " +
"GROUP BY info.tableId")
List<ShopTableSaleInfoVo> queryShopTableSaleInfo(@Param("shopId") String shopId, @Param("startTime") Long startTime, @Param("endTime") Long endTime);
}

View File

@ -1,6 +1,7 @@
package cn.ysk.cashier.service;
import cn.ysk.cashier.dto.ShopSummaryDto;
import cn.ysk.cashier.vo.ShopTableSaleInfoVo;
import cn.ysk.cashier.vo.SummaryVO;
import cn.ysk.cashier.vo.TbOrderPayCountVo;
import org.springframework.data.domain.Page;
@ -36,4 +37,6 @@ public interface SummaryService {
void download(ShopSummaryDto summaryDto, HttpServletResponse response) throws IOException;
List<TbOrderPayCountVo> summaryCount(String shopId, Date startTime, Date endTime);
List<ShopTableSaleInfoVo> selectSummaryTable(Integer shopId, Date startTime, Date endTime);
}

View File

@ -471,4 +471,15 @@ public class SummaryServiceImpl implements SummaryService {
list.add(refNum);
return list;
}
@Override
public List<ShopTableSaleInfoVo> selectSummaryTable(Integer shopId, Date startTime, Date endTime) {
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);
}
}

View File

@ -0,0 +1,38 @@
package cn.ysk.cashier.vo;
import lombok.Data;
/**
* @author GYJ
*/
@Data
public class ShopTableSaleInfoVo {
private Integer id;
private Object shopId;
private Object tableId;
private Object tableName;
private Object areaId;
private Object areaName;
private Object orderCount;
private Object orderAmount;
public ShopTableSaleInfoVo(Integer id, Object shopId, Object tableId, Object tableName,
Object areaId, Object areaName, Object orderCount, Object orderAmount) {
this.id = id;
this.shopId = shopId;
this.tableId = tableId;
this.tableName = tableName;
this.areaId = areaId;
this.areaName = areaName;
this.orderCount = orderCount;
this.orderAmount = orderAmount;
}
}