diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/SummaryController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/SummaryController.java index 2c7f0406..08182484 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/SummaryController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/SummaryController.java @@ -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); + } + } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/order/TbOrderInfoRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/order/TbOrderInfoRepository.java index 24d9291b..8e632eda 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/order/TbOrderInfoRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/repository/order/TbOrderInfoRepository.java @@ -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 :startTime AND info.createdAt < :endTime " + + "AND ((info.status = 'closed') OR ( info.status ='refund' AND info.orderType != 'return' )) " + + "GROUP BY info.tableId") + List queryShopTableSaleInfo(@Param("shopId") String shopId, @Param("startTime") Long startTime, @Param("endTime") Long endTime); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/SummaryService.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/SummaryService.java index 52b05e35..a511fc00 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/SummaryService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/SummaryService.java @@ -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 summaryCount(String shopId, Date startTime, Date endTime); + + List selectSummaryTable(Integer shopId, Date startTime, Date endTime); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/SummaryServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/SummaryServiceImpl.java index d84f51c6..98fa1981 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/SummaryServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/SummaryServiceImpl.java @@ -471,4 +471,15 @@ public class SummaryServiceImpl implements SummaryService { list.add(refNum); return list; } + + @Override + public List 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); + } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/vo/ShopTableSaleInfoVo.java b/eladmin-system/src/main/java/cn/ysk/cashier/vo/ShopTableSaleInfoVo.java new file mode 100644 index 00000000..5fef58a8 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/vo/ShopTableSaleInfoVo.java @@ -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; + } +}