diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/order/TbOrderInfoQueryCriteria.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/order/TbOrderInfoQueryCriteria.java index 6bc87bab..581cf64c 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/order/TbOrderInfoQueryCriteria.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/order/TbOrderInfoQueryCriteria.java @@ -68,4 +68,8 @@ public class TbOrderInfoQueryCriteria{ /** BETWEEN */ @Query(type = Query.Type.BETWEEN) private List createdAt; + + + @Query + private String tableName; } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/order/TbPayCountQueryCriteria.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/order/TbPayCountQueryCriteria.java index 60395400..164d6a7f 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/order/TbPayCountQueryCriteria.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/order/TbPayCountQueryCriteria.java @@ -6,6 +6,11 @@ import java.util.List; @Data public class TbPayCountQueryCriteria { + + private String shopId; + + private String tableName; + private List createdAt; } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/TbProductSpecQueryCriteria.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/TbProductSpecQueryCriteria.java index 9f793adf..e20296fc 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/TbProductSpecQueryCriteria.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/TbProductSpecQueryCriteria.java @@ -30,4 +30,7 @@ public class TbProductSpecQueryCriteria{ */ @Query private String shopId; + + @Query(type = Query.Type.INNER_LIKE) + private String name; } \ No newline at end of file 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 ec595db9..0e2f6781 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 @@ -1,18 +1,18 @@ /* - * 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. - */ +* 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.repository.order; import cn.ysk.cashier.pojo.order.TbOrderInfo; @@ -32,26 +32,26 @@ import java.util.Date; import java.util.List; /** - * @author lyf - * @website https://eladmin.vip - * @date 2024-03-02 - **/ +* @website https://eladmin.vip +* @author lyf +* @date 2024-03-02 +**/ public interface TbOrderInfoRepository extends JpaRepository, JpaSpecificationExecutor { @Query("SELECT new cn.ysk.cashier.vo.TbOrderPayCountVo(info.payType, SUM(info.orderAmount)) " + "FROM TbOrderInfo info " + - "WHERE info.shopId = :shopId " + + "WHERE 1=1 and (:tableName is null or info.tableName=:tableName ) and info.shopId = :shopId " + "AND info.createdAt>:start AND info.createdAt<:end " + "AND ((info.status = 'closed') OR (info.status = 'refund' AND info.orderType != 'return')) " + "GROUP BY info.payType") - List queryTbOrderPayCount(@Param("shopId") String shopId, @Param("start") Long start, @Param("end") Long end); + List queryTbOrderPayCount(@Param("shopId")String shopId,@Param("tableName") String tableName ,@Param("start") Long start, @Param("end") Long end); @Query("SELECT new cn.ysk.cashier.vo.TbOrderPayCountVo('refund', SUM(info.orderAmount)) " + "FROM TbOrderInfo info " + - "WHERE info.shopId = :shopId " + + "WHERE 1=1 and (:tableName is null or info.tableName=:tableName ) and info.shopId = :shopId " + "AND info.status = 'refund' AND info.orderType = 'return' " + "AND info.createdAt>:start AND info.createdAt<:end") - TbOrderPayCountVo queryTbOrderRefund(@Param("shopId") String shopId, @Param("start") Long start, @Param("end") Long end); + TbOrderPayCountVo queryTbOrderRefund(@Param("shopId")String shopId, @Param("tableName") String tableName ,@Param("start") Long start, @Param("end") Long end); @Query(value = "SELECT COUNT(1) ,pay_type AS payType FROM tb_order_info Where shop_id = :shopId AND " + " created_at BETWEEN :startTime AND :endTime AND status='closed'AND order_type <>'return' GROUP BY pay_type", nativeQuery = true) @@ -191,4 +191,4 @@ public interface TbOrderInfoRepository extends JpaRepository queryShopTableIds(@Param("shopId") Integer shopId); -} +} \ No newline at end of file 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 e5efa3ec..0f9000e1 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 @@ -463,7 +463,7 @@ public class SummaryServiceImpl implements SummaryService { endTime = new Date(); } TbOrderPayCountVo payCount = tbOrderInfoRepository.queryOrderPayCount(shopId, start, end); - TbOrderPayCountVo refCount = tbOrderInfoRepository.queryTbOrderRefund(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); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/order/TbOrderInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/order/TbOrderInfoServiceImpl.java index 5a498eb9..33ecb66d 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/order/TbOrderInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/order/TbOrderInfoServiceImpl.java @@ -150,7 +150,10 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService { end = createdAt.get(1); } } - List payCountVoList = tbOrderInfoRepository.queryTbOrderPayCount(criteria.getShopId(), start, end); + if(ObjectUtil.isEmpty(criteria.getTableName())){ + criteria.setTableName(null); + } + List payCountVoList = tbOrderInfoRepository.queryTbOrderPayCount(criteria.getShopId(),criteria.getTableName(), start, end); BigDecimal totalPayAmount = BigDecimal.ZERO; for (TbOrderPayCountVo payCount : payCountVoList) { totalPayAmount = totalPayAmount.add(new BigDecimal(payCount.getPayAmount().toString())); @@ -167,7 +170,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService { result.add(payCount); } } - TbOrderPayCountVo payRufund = tbOrderInfoRepository.queryTbOrderRefund(criteria.getShopId(), start, end); + TbOrderPayCountVo payRufund = tbOrderInfoRepository.queryTbOrderRefund(criteria.getShopId(),criteria.getTableName(), start, end); if (payRufund != null) { totalPayAmount = totalPayAmount.subtract(new BigDecimal(payRufund.getPayAmount().toString())); payRufund.setPayType("退单"); @@ -400,6 +403,28 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService { .collect(Collectors.joining("/")); map.put("商品信息", productNames); // + + if(ObjectUtil.isNotEmpty(tbOrderInfo.getPayType())&&ObjectUtil.isNotNull(tbOrderInfo.getPayType())){ + switch (tbOrderInfo.getPayType()){ + case "scanCode": + tbOrderInfo.setPayType("收款码支付"); + break; + case "deposit": + tbOrderInfo.setPayType("会员卡支付"); + break; + case "cash": + tbOrderInfo.setPayType("现金支付"); + break; + case "wx_lite": + tbOrderInfo.setPayType("微信支付"); + break; + + } + }else { + tbOrderInfo.setPayType(""); + } + + map.put("支付类型", tbOrderInfo.getPayType()); map.put("订单金额", tbOrderInfo.getOrderAmount()); map.put("退单金额", tbOrderInfo.getRefundAmount()); @@ -442,6 +467,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService { map.put("状态", tbOrderInfo.getStatus()); map.put("创建日期", DateUtil.timeStampFormatyMdHms(tbOrderInfo.getCreatedAt())); map.put("备注", tbOrderInfo.getRemark()); + map.put("台桌",tbOrderInfo.getTableName()); list.add(map); } FileUtil.downloadExcel(list, response);