From 0642f09549fec535246fe13b3fd39d723878241f Mon Sep 17 00:00:00 2001
From: wangw <1594593906@qq.com>
Date: Tue, 25 Nov 2025 16:59:56 +0800
Subject: [PATCH 1/6] =?UTF-8?q?=E5=95=86=E5=93=81=E5=90=8D=E7=A7=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/main/resources/mapper/ShopProdStatisticMapper.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/cash-service/order-service/src/main/resources/mapper/ShopProdStatisticMapper.xml b/cash-service/order-service/src/main/resources/mapper/ShopProdStatisticMapper.xml
index 6cc2a68f7..4ca551b7f 100644
--- a/cash-service/order-service/src/main/resources/mapper/ShopProdStatisticMapper.xml
+++ b/cash-service/order-service/src/main/resources/mapper/ShopProdStatisticMapper.xml
@@ -23,7 +23,7 @@
AND `order`.trade_day = #{day}
AND `order`.paid_time IS NOT NULL
- AND detail.name LIKE CONCAT('%',#{productName},'%')
+ AND detail.product_name LIKE CONCAT('%',#{productName},'%')
GROUP BY prodId
@@ -85,7 +85,7 @@
AND `order`.trade_day = #{day}
AND `order`.paid_time IS NOT NULL
- AND detail.name LIKE CONCAT('%',#{productName},'%')
+ AND detail.product_name LIKE CONCAT('%',#{productName},'%')
From 8087ba1d6a58bd1b50ff836cda4f6f3fa69fb839 Mon Sep 17 00:00:00 2001
From: wangw <1594593906@qq.com>
Date: Tue, 25 Nov 2025 17:13:03 +0800
Subject: [PATCH 2/6] =?UTF-8?q?=E5=95=86=E5=93=81=E5=90=8D=E7=A7=B0=20?=
=?UTF-8?q?=E6=9F=A5=E8=AF=A2=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../resources/mapper/ShopProdStatisticMapper.xml | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/cash-service/order-service/src/main/resources/mapper/ShopProdStatisticMapper.xml b/cash-service/order-service/src/main/resources/mapper/ShopProdStatisticMapper.xml
index 4ca551b7f..53605da2d 100644
--- a/cash-service/order-service/src/main/resources/mapper/ShopProdStatisticMapper.xml
+++ b/cash-service/order-service/src/main/resources/mapper/ShopProdStatisticMapper.xml
@@ -95,10 +95,11 @@
sum(tb_shop_prod_statistic.refund_count) AS refundCount,
sum(tb_shop_prod_statistic.refund_amount) AS refundAmount
FROM
- tb_shop_prod_statistic
+ tb_shop_prod_statistic statistic
+ INNER JOIN tb_product prod ON tb_shop_prod_statistic.prod_id = prod.id
WHERE
- tb_shop_prod_statistic.shop_id = #{shopId}
- AND tb_shop_prod_statistic.create_day = #{day}
+ statistic.shop_id = #{shopId}
+ AND statistic.create_day = #{day}
AND prod.name LIKE CONCAT('%',#{productName},'%')
@@ -111,11 +112,12 @@
sum(tb_shop_prod_statistic.refund_count) AS refundCount,
sum(tb_shop_prod_statistic.refund_amount) AS refundAmount
FROM
- tb_shop_prod_statistic
+ tb_shop_prod_statistic statistic
+ INNER JOIN tb_product prod ON statistic.prod_id = prod.id
WHERE
- tb_shop_prod_statistic.shop_id = #{shopId}
- AND tb_shop_prod_statistic.create_day >= #{start}
- AND tb_shop_prod_statistic.create_day <= #{end}
+ statistic.shop_id = #{shopId}
+ AND statistic.create_day >= #{start}
+ AND statistic.create_day <= #{end}
AND prod.name LIKE CONCAT('%',#{productName},'%')
From fe161394465ec74398509750e64deb7d9ae18901 Mon Sep 17 00:00:00 2001
From: wangw <1594593906@qq.com>
Date: Tue, 25 Nov 2025 17:16:03 +0800
Subject: [PATCH 3/6] =?UTF-8?q?=E5=AF=BC=E5=87=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../czg/controller/admin/SaleSummaryController.java | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/cash-api/order-server/src/main/java/com/czg/controller/admin/SaleSummaryController.java b/cash-api/order-server/src/main/java/com/czg/controller/admin/SaleSummaryController.java
index c53a7164c..81a51ef96 100644
--- a/cash-api/order-server/src/main/java/com/czg/controller/admin/SaleSummaryController.java
+++ b/cash-api/order-server/src/main/java/com/czg/controller/admin/SaleSummaryController.java
@@ -7,6 +7,7 @@ import com.czg.order.service.ShopProdStatisticService;
import com.czg.order.vo.SaleSummaryCountVo;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
+import com.pig4cloud.plugin.excel.annotation.ResponseExcel;
import jakarta.annotation.Resource;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -62,4 +63,15 @@ public class SaleSummaryController {
return CzgResult.success(list);
}
+ @ResponseExcel(name = "销售统计明细")
+ @GetMapping("/export")
+ public List summaryExport(SaleSummaryCountParam param) {
+ Long shopId = StpKit.USER.getShopId();
+ if (param.getShopId() == null) {
+ param.setShopId(shopId);
+ }
+ return prodStatisticService.getArchiveTradeData(
+ param.getShopId(),param.getProductName(), param.getRangeType(), param.getBeginDate(), param.getEndDate());
+ }
+
}
From 9af596b93cc74791b2edd4cef03932cd0f307135 Mon Sep 17 00:00:00 2001
From: wangw <1594593906@qq.com>
Date: Tue, 25 Nov 2025 17:35:51 +0800
Subject: [PATCH 4/6] =?UTF-8?q?=E9=94=80=E9=87=8F=E8=AE=B0=E5=BD=95?=
=?UTF-8?q?=E5=AF=BC=E5=87=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../czg/order/entity/ShopProdStatistic.java | 39 ++++++++++++++++++-
.../impl/ShopProdStatisticServiceImpl.java | 22 +++++------
.../mapper/ShopProdStatisticMapper.xml | 16 ++++----
3 files changed, 57 insertions(+), 20 deletions(-)
diff --git a/cash-common/cash-common-service/src/main/java/com/czg/order/entity/ShopProdStatistic.java b/cash-common/cash-common-service/src/main/java/com/czg/order/entity/ShopProdStatistic.java
index 30a468f9a..7abfdde8c 100644
--- a/cash-common/cash-common-service/src/main/java/com/czg/order/entity/ShopProdStatistic.java
+++ b/cash-common/cash-common-service/src/main/java/com/czg/order/entity/ShopProdStatistic.java
@@ -1,5 +1,8 @@
package com.czg.order.entity;
+import cn.idev.excel.annotation.ExcelIgnore;
+import cn.idev.excel.annotation.ExcelProperty;
+import cn.idev.excel.annotation.write.style.ColumnWidth;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
@@ -20,7 +23,6 @@ import java.util.Date;
* @since 2025-03-07
*/
@Data
-
@NoArgsConstructor
@AllArgsConstructor
@Table("tb_shop_prod_statistic")
@@ -30,48 +32,83 @@ public class ShopProdStatistic implements Serializable {
private static final long serialVersionUID = 1L;
@Id(keyType = KeyType.Auto)
+ @ExcelIgnore
private Long id;
/**
* 商品id
*/
+ @ExcelIgnore
private Long prodId;
/**
* 商品名称
*/
@Column(ignore = true)
+ @ExcelProperty("商品名称")
+ @ColumnWidth(80)
private String productName;
/**
* 销售数量
*/
+ @ExcelProperty("销售数量")
+ @ColumnWidth(30)
private BigDecimal saleCount;
/**
* 销售金额
*/
+ @ExcelProperty("销售金额")
+ @ColumnWidth(50)
private BigDecimal saleAmount;
/**
* 退单量
*/
+ @ExcelProperty("退单量")
+ @ColumnWidth(30)
private BigDecimal refundCount;
/**
* 退单金额
*/
+ @ExcelProperty("退单金额")
+ @ColumnWidth(50)
private BigDecimal refundAmount;
+ /**
+ * 实际销售数量(过滤掉退单后的数量)
+ */
+ @ExcelProperty("实际销售数量")
+ @ColumnWidth(30)
+ private BigDecimal validSaleCount;
+
+ /**
+ * 实际销售金额(过滤掉退单后的金额)
+ */
+ @ExcelProperty("实际销售金额")
+ @ColumnWidth(50)
+ private BigDecimal validSaleAmount;
+
/**
* 店铺id
*/
+ @ExcelIgnore
private Long shopId;
/**
* 创建时间
*/
+ @ExcelIgnore
private Date createDay;
+
+ public void initValidData() {
+ // 初始化实际销售数量和金额(过滤退单数据)
+ this.validSaleCount = this.saleCount.subtract(this.refundCount);
+ this.validSaleAmount = this.saleAmount.subtract(this.refundAmount);
+ }
+
// 在 ShopProdStatistic.java 中添加以下方法
/**
* 判断当前统计数据是否有效(销售数量、金额,退单数量、金额均有值且大于0)
diff --git a/cash-service/order-service/src/main/java/com/czg/service/order/service/impl/ShopProdStatisticServiceImpl.java b/cash-service/order-service/src/main/java/com/czg/service/order/service/impl/ShopProdStatisticServiceImpl.java
index 04aa7a67d..356350df0 100644
--- a/cash-service/order-service/src/main/java/com/czg/service/order/service/impl/ShopProdStatisticServiceImpl.java
+++ b/cash-service/order-service/src/main/java/com/czg/service/order/service/impl/ShopProdStatisticServiceImpl.java
@@ -108,23 +108,23 @@ public class ShopProdStatisticServiceImpl extends ServiceImpl realTimeData = getRealTimeDataByDay(shopId, day, null);
if (CollUtil.isNotEmpty(realTimeData)) {
- // 过滤掉没有有效数据的记录
- realTimeData = realTimeData.stream()
- .filter(ShopProdStatistic::isValid)
- .toList();
- if (CollUtil.isNotEmpty(realTimeData)) {
- boolean exists = exists(QueryWrapper.create().eq(ShopProdStatistic::getShopId, shopId).eq(ShopProdStatistic::getCreateDay, day));
- if (exists) {
- remove(QueryWrapper.create().eq(ShopProdStatistic::getShopId, shopId).eq(ShopProdStatistic::getCreateDay, day));
- }
- saveBatch(realTimeData);
+ boolean exists = exists(QueryWrapper.create().eq(ShopProdStatistic::getShopId, shopId).eq(ShopProdStatistic::getCreateDay, day));
+ if (exists) {
+ remove(QueryWrapper.create().eq(ShopProdStatistic::getShopId, shopId).eq(ShopProdStatistic::getCreateDay, day));
}
+ saveBatch(realTimeData);
}
}
@Override
public List getRealTimeDataByDay(Long shopId, LocalDate day, String productName) {
- return mapper.selectProStatByDay(shopId, day, productName);
+ List shopProdStatistics = mapper.selectProStatByDay(shopId, day, productName);
+ // 过滤掉没有有效数据的记录
+ shopProdStatistics = shopProdStatistics.stream()
+ .filter(ShopProdStatistic::isValid)
+ .peek(ShopProdStatistic::initValidData)
+ .toList();
+ return shopProdStatistics;
}
@Override
diff --git a/cash-service/order-service/src/main/resources/mapper/ShopProdStatisticMapper.xml b/cash-service/order-service/src/main/resources/mapper/ShopProdStatisticMapper.xml
index 53605da2d..116e7fc5d 100644
--- a/cash-service/order-service/src/main/resources/mapper/ShopProdStatisticMapper.xml
+++ b/cash-service/order-service/src/main/resources/mapper/ShopProdStatisticMapper.xml
@@ -90,10 +90,10 @@
SELECT
- sum(tb_shop_prod_statistic.sale_count) AS saleCount,
- sum(tb_shop_prod_statistic.sale_amount) AS saleAmount,
- sum(tb_shop_prod_statistic.refund_count) AS refundCount,
- sum(tb_shop_prod_statistic.refund_amount) AS refundAmount
+ sum(statistic.sale_count) AS saleCount,
+ sum(statistic.sale_amount) AS saleAmount,
+ sum(statistic.refund_count) AS refundCount,
+ sum(statistic.refund_amount) AS refundAmount
FROM
tb_shop_prod_statistic statistic
INNER JOIN tb_product prod ON tb_shop_prod_statistic.prod_id = prod.id
@@ -107,10 +107,10 @@
SELECT
- sum(tb_shop_prod_statistic.sale_count) AS saleCount,
- sum(tb_shop_prod_statistic.sale_amount) AS totalAmount,
- sum(tb_shop_prod_statistic.refund_count) AS refundCount,
- sum(tb_shop_prod_statistic.refund_amount) AS refundAmount
+ sum(statistic.sale_count) AS saleCount,
+ sum(statistic.sale_amount) AS totalAmount,
+ sum(statistic.refund_count) AS refundCount,
+ sum(statistic.refund_amount) AS refundAmount
FROM
tb_shop_prod_statistic statistic
INNER JOIN tb_product prod ON statistic.prod_id = prod.id
From c366862327ed0b7f5f1e02345d38af9d23e3c4af Mon Sep 17 00:00:00 2001
From: wangw <1594593906@qq.com>
Date: Tue, 25 Nov 2025 17:44:34 +0800
Subject: [PATCH 5/6] =?UTF-8?q?=E5=AF=BC=E5=87=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../czg/order/entity/ShopProdStatistic.java | 22 +++++++++----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/cash-common/cash-common-service/src/main/java/com/czg/order/entity/ShopProdStatistic.java b/cash-common/cash-common-service/src/main/java/com/czg/order/entity/ShopProdStatistic.java
index 7abfdde8c..ef8e31b32 100644
--- a/cash-common/cash-common-service/src/main/java/com/czg/order/entity/ShopProdStatistic.java
+++ b/cash-common/cash-common-service/src/main/java/com/czg/order/entity/ShopProdStatistic.java
@@ -45,49 +45,49 @@ public class ShopProdStatistic implements Serializable {
*/
@Column(ignore = true)
@ExcelProperty("商品名称")
- @ColumnWidth(80)
+ @ColumnWidth(30)
private String productName;
/**
* 销售数量
*/
- @ExcelProperty("销售数量")
- @ColumnWidth(30)
+ @ExcelProperty("销量")
+ @ColumnWidth(5)
private BigDecimal saleCount;
/**
* 销售金额
*/
@ExcelProperty("销售金额")
- @ColumnWidth(50)
+ @ColumnWidth(7)
private BigDecimal saleAmount;
/**
* 退单量
*/
@ExcelProperty("退单量")
- @ColumnWidth(30)
+ @ColumnWidth(5)
private BigDecimal refundCount;
/**
* 退单金额
*/
- @ExcelProperty("退单金额")
- @ColumnWidth(50)
+ @ExcelProperty("退款金额")
+ @ColumnWidth(7)
private BigDecimal refundAmount;
/**
* 实际销售数量(过滤掉退单后的数量)
*/
- @ExcelProperty("实际销售数量")
- @ColumnWidth(30)
+ @ExcelProperty("实际销量")
+ @ColumnWidth(5)
private BigDecimal validSaleCount;
/**
* 实际销售金额(过滤掉退单后的金额)
*/
- @ExcelProperty("实际销售金额")
- @ColumnWidth(50)
+ @ExcelProperty("实际销售额")
+ @ColumnWidth(7)
private BigDecimal validSaleAmount;
/**
From 881f33ff2b7bb7394baae23db8293b61de60004b Mon Sep 17 00:00:00 2001
From: wangw <1594593906@qq.com>
Date: Tue, 25 Nov 2025 18:24:51 +0800
Subject: [PATCH 6/6] =?UTF-8?q?=E5=8F=B0=E6=A1=8C=E7=BB=9F=E8=AE=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../czg/order/vo/TableSummaryExportVo.java | 34 ++++-----
.../service/impl/TableSummaryServiceImpl.java | 19 +----
.../mapper/ShopTableOrderStatisticMapper.xml | 71 +++++++------------
3 files changed, 45 insertions(+), 79 deletions(-)
diff --git a/cash-common/cash-common-service/src/main/java/com/czg/order/vo/TableSummaryExportVo.java b/cash-common/cash-common-service/src/main/java/com/czg/order/vo/TableSummaryExportVo.java
index 83e1eaf95..7a46142d4 100644
--- a/cash-common/cash-common-service/src/main/java/com/czg/order/vo/TableSummaryExportVo.java
+++ b/cash-common/cash-common-service/src/main/java/com/czg/order/vo/TableSummaryExportVo.java
@@ -33,8 +33,8 @@ public class TableSummaryExportVo implements Serializable {
/**
* 台桌+日期
*/
- @ExcelIgnore
- private String tableConcatDate;
+// @ExcelIgnore
+// private String tableConcatDate;
/**
* 台桌
*/
@@ -80,27 +80,27 @@ public class TableSummaryExportVo implements Serializable {
/**
* 单价
*/
- @ExcelProperty("单价")
- @ColumnWidth(10)
- private BigDecimal unitPrice;
- /**
- * 金额
- */
- @ExcelProperty("金额")
- @ColumnWidth(10)
- private BigDecimal amount;
+// @ExcelProperty("单价")
+// @ColumnWidth(10)
+// private BigDecimal unitPrice;
+// /**
+// * 金额
+// */
+// @ExcelProperty("金额")
+// @ColumnWidth(10)
+// private BigDecimal amount;
/**
* 销售额
*/
@ExcelProperty("销售额")
@ColumnWidth(10)
private BigDecimal salesAmount;
- /**
- * 总销售额
- */
- @ExcelProperty("总销售额")
- @ColumnWidth(15)
- private BigDecimal totalSalesAmount;
+// /**
+// * 总销售额
+// */
+// @ExcelProperty("总销售额")
+// @ColumnWidth(15)
+// private BigDecimal totalSalesAmount;
/**
* 退单量
*/
diff --git a/cash-service/order-service/src/main/java/com/czg/service/order/service/impl/TableSummaryServiceImpl.java b/cash-service/order-service/src/main/java/com/czg/service/order/service/impl/TableSummaryServiceImpl.java
index 34d9b8a27..6686ddb35 100644
--- a/cash-service/order-service/src/main/java/com/czg/service/order/service/impl/TableSummaryServiceImpl.java
+++ b/cash-service/order-service/src/main/java/com/czg/service/order/service/impl/TableSummaryServiceImpl.java
@@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@@ -51,24 +52,6 @@ public class TableSummaryServiceImpl implements TableSummaryService {
if (CollUtil.isEmpty(list)) {
return List.of();
}
- Map totalSalesAmountMap = list.stream().collect(
- Collectors.groupingBy(
- TableSummaryExportVo::getTableName, Collectors.reducing(BigDecimal.ZERO,
- TableSummaryExportVo::getAmount,
- BigDecimal::add)
- )
- );
- Map salesAmountMap = list.stream().collect(
- Collectors.groupingBy(
- TableSummaryExportVo::getTableConcatDate, Collectors.reducing(BigDecimal.ZERO,
- TableSummaryExportVo::getAmount,
- BigDecimal::add)
- )
- );
- list.parallelStream().forEach(data -> {
- data.setSalesAmount(salesAmountMap.get(data.getTableConcatDate()));
- data.setTotalSalesAmount(totalSalesAmountMap.get(data.getTableName()));
- });
// 追加个空行用于处理表格样式
TableSummaryExportVo nullVo = new TableSummaryExportVo();
list.add(nullVo);
diff --git a/cash-service/order-service/src/main/resources/mapper/ShopTableOrderStatisticMapper.xml b/cash-service/order-service/src/main/resources/mapper/ShopTableOrderStatisticMapper.xml
index b4514137f..7629e447e 100644
--- a/cash-service/order-service/src/main/resources/mapper/ShopTableOrderStatisticMapper.xml
+++ b/cash-service/order-service/src/main/resources/mapper/ShopTableOrderStatisticMapper.xml
@@ -5,49 +5,32 @@
- SELECT
- t.product_name,
- date_format(t.create_time, '%Y-%m-%d') as create_date,
- if(t.table_name = 'NONE','银收客',t.table_name) as table_name,
- concat(if(t.table_name = 'NONE','银收客',t.table_name),'-',date_format(t.create_time, '%Y-%m-%d')) as tableConcatDate,
- t.category_name,
- t.unit_name,
- group_concat(distinct t.sku_name SEPARATOR ';') as sku_name,
- sum(t.num) as num,
- avg(t.unit_price) as unit_price,
- sum(t.num*t.unit_price) as amount,
- sum(-t.refund_num) as refund_num,
- sum(-t.refund_num*t.unit_price) as refund_amount
- FROM
- (
- SELECT
- t1.product_id,
- t2.table_code,
- IF(t2.table_code is null or t2.table_code = '' or t6.NAME is null, 'NONE', t6.NAME) AS table_name,
- t1.create_time,
- t4.NAME AS category_name,
- t3.name as product_name,
- t5.NAME AS unit_name,
- t1.sku_name,
- t1.num,
- t1.unit_price,
- t1.refund_num as refund_num
- FROM
- tb_order_detail t1
- LEFT JOIN tb_order_info t2 ON t1.order_id = t2.id
- LEFT JOIN tb_product t3 ON t1.product_id = t3.id
- LEFT JOIN tb_shop_prod_category t4 ON t3.category_id = t4.id
- LEFT JOIN tb_shop_prod_unit t5 ON t3.unit_id = t5.id
- LEFT JOIN tb_shop_table t6 ON t2.table_code = t6.table_code AND t1.shop_id = t6.shop_id and t6.table_code != '' and t6.table_code is not null
- WHERE t1.shop_id = #{shopId}
-
- AND t1.create_time >= str_to_date(#{beginDate}, '%Y-%m-%d %H:%i:%s')
-
-
- and t1.create_time <= str_to_date(#{endDate}, '%Y-%m-%d %H:%i:%s')
-
- ) t
- group by t.product_id,date_format(t.create_time, '%Y-%m-%d'),t.table_name
- order by t.table_name,t.table_code,date_format(t.create_time, '%Y-%m-%d'),t.category_name,t.product_id
+ SELECT `order`.table_code,
+ `order`.trade_day as create_date,
+ IF(`order`.table_code IS NULL OR `order`.table_code = '' OR `table`.NAME IS NULL, '吧台',
+ `table`.NAME) AS table_name,
+ category.`name` AS category_name,
+ product.`name` AS product_name,
+ unit.`name` AS unit_name,
+ detail.sku_name,
+ sum(detail.num - detail.return_num) AS num,
+ sum(detail.pay_amount) AS salesAmount,
+ sum(detail.refund_num) AS refund_num,
+ sum(detail.return_amount) AS refund_amount
+ FROM tb_order_info `order`
+ INNER JOIN tb_order_detail detail ON detail.order_id = `order`.id
+ AND detail.is_temporary = 0
+ LEFT JOIN tb_product product ON detail.product_id = product.id
+ LEFT JOIN tb_shop_prod_category category ON product.category_id = category.id
+ LEFT JOIN tb_shop_prod_unit unit ON product.unit_id = unit.id
+ LEFT JOIN tb_shop_table `table`
+ ON `order`.table_code = `table`.table_code AND `order`.shop_id = `table`.shop_id
+ AND `table`.table_code != '' AND `table`.table_code IS NOT NULL
+ WHERE `order`.shop_id = #{shopId}
+ AND `order`.paid_time IS NOT NULL
+ AND `order`.pay_mode != 'no-table'
+ AND `order`.trade_day >= #{beginDate}
+ AND `order`.trade_day <= #{endDate}
+ group by `order`.trade_day, `order`.table_code, detail.product_id