diff --git a/yudao-module-mall/yudao-module-statistics/src/main/resources/mapper/infra/ApiAccessLogStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics/src/main/resources/mapper/infra/ApiAccessLogStatisticsMapper.xml
index e641615..c307c02 100644
--- a/yudao-module-mall/yudao-module-statistics/src/main/resources/mapper/infra/ApiAccessLogStatisticsMapper.xml
+++ b/yudao-module-mall/yudao-module-statistics/src/main/resources/mapper/infra/ApiAccessLogStatisticsMapper.xml
@@ -8,6 +8,9 @@
WHERE user_type = #{userType}
AND create_time BETWEEN #{beginTime} AND #{endTime}
AND deleted = FALSE
+
+ AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()}
+
diff --git a/yudao-module-mall/yudao-module-statistics/src/main/resources/mapper/member/MemberStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics/src/main/resources/mapper/member/MemberStatisticsMapper.xml
index 33500fb..0c1be40 100644
--- a/yudao-module-mall/yudao-module-statistics/src/main/resources/mapper/member/MemberStatisticsMapper.xml
+++ b/yudao-module-mall/yudao-module-statistics/src/main/resources/mapper/member/MemberStatisticsMapper.xml
@@ -7,6 +7,9 @@
SELECT area_id, COUNT(1) AS userCount
FROM member_user
WHERE deleted = FALSE
+
+ AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()}
+
GROUP BY area_id
@@ -15,6 +18,9 @@
SELECT sex, COUNT(1) AS userCount
FROM member_user
WHERE deleted = FALSE
+
+ AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()}
+
GROUP BY sex
@@ -23,6 +29,9 @@
SELECT register_terminal as terminal, COUNT(1) AS userCount
FROM member_user
WHERE deleted = FALSE
+
+ AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()}
+
GROUP BY register_terminal
@@ -36,6 +45,9 @@
AND create_time <= #{endTime}
+
+ AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()}
+
diff --git a/yudao-module-mall/yudao-module-statistics/src/main/resources/mapper/pay/PayWalletStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics/src/main/resources/mapper/pay/PayWalletStatisticsMapper.xml
index 0977808..78403c8 100644
--- a/yudao-module-mall/yudao-module-statistics/src/main/resources/mapper/pay/PayWalletStatisticsMapper.xml
+++ b/yudao-module-mall/yudao-module-statistics/src/main/resources/mapper/pay/PayWalletStatisticsMapper.xml
@@ -10,6 +10,9 @@
WHERE pay_status = #{payStatus}
AND pay_time BETWEEN #{beginTime} AND #{endTime}
AND deleted = FALSE
+
+ AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()}
+
diff --git a/yudao-module-mall/yudao-module-statistics/src/main/resources/mapper/product/ProductStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics/src/main/resources/mapper/product/ProductStatisticsMapper.xml
index e640d1d..43a1540 100644
--- a/yudao-module-mall/yudao-module-statistics/src/main/resources/mapper/product/ProductStatisticsMapper.xml
+++ b/yudao-module-mall/yudao-module-statistics/src/main/resources/mapper/product/ProductStatisticsMapper.xml
@@ -9,55 +9,96 @@
, (SELECT COUNT(1)
FROM product_browse_history
WHERE spu_id = spu.id
- AND create_time BETWEEN #{beginTime} AND #{endTime}) AS browse_count
+ AND create_time BETWEEN #{beginTime} AND #{endTime}
+
+ AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()}
+
+ ) AS browse_count
-- 访客量:按用户去重计数
, (SELECT COUNT(DISTINCT user_id)
FROM product_browse_history
WHERE spu_id = spu.id
- AND create_time BETWEEN #{beginTime} AND #{endTime}) AS browse_user_count
+ AND create_time BETWEEN #{beginTime} AND #{endTime}
+
+ AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()}
+
+ ) AS browse_user_count
-- 收藏数量:按用户去重计数
, (SELECT COUNT(DISTINCT user_id)
FROM product_favorite
WHERE spu_id = spu.id
- AND create_time BETWEEN #{beginTime} AND #{endTime}) AS favorite_count
+ AND create_time BETWEEN #{beginTime} AND #{endTime}
+
+ AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()}
+
+ ) AS favorite_count
-- 加购数量:按用户去重计数
, (SELECT COUNT(DISTINCT user_id)
FROM trade_cart
WHERE spu_id = spu.id
- AND create_time BETWEEN #{beginTime} AND #{endTime}) AS cart_count
+ AND create_time BETWEEN #{beginTime} AND #{endTime}
+
+ AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()}
+
+ ) AS cart_count
-- 下单件数
, (SELECT IFNULL(SUM(count), 0)
FROM trade_order_item
WHERE spu_id = spu.id
- AND create_time BETWEEN #{beginTime} AND #{endTime}) AS order_count
+ AND create_time BETWEEN #{beginTime} AND #{endTime}
+
+ AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()}
+
+ ) AS order_count
-- 支付件数
, (SELECT IFNULL(SUM(item.count), 0)
FROM trade_order_item item
JOIN trade_order o ON item.order_id = o.id
WHERE spu_id = spu.id
AND o.pay_status = TRUE
- AND item.create_time BETWEEN #{beginTime} AND #{endTime}) AS order_pay_count
+ AND item.create_time BETWEEN #{beginTime} AND #{endTime}
+
+ AND item.tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()}
+ AND o.tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()}
+
+ ) AS order_pay_count
-- 支付金额
, (SELECT IFNULL(SUM(item.pay_price), 0)
FROM trade_order_item item
JOIN trade_order o ON item.order_id = o.id
WHERE spu_id = spu.id
AND o.pay_status = TRUE
- AND item.create_time BETWEEN #{beginTime} AND #{endTime}) AS order_pay_price
+ AND item.create_time BETWEEN #{beginTime} AND #{endTime}
+
+ AND item.tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()}
+ AND o.tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()}
+
+ ) AS order_pay_price
-- 退款件数
, (SELECT IFNULL(SUM(count), 0)
FROM trade_after_sale
WHERE spu_id = spu.id
AND refund_time IS NOT NULL
- AND create_time BETWEEN #{beginTime} AND #{endTime}) AS after_sale_count
+ AND create_time BETWEEN #{beginTime} AND #{endTime}
+
+ AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()}
+
+ ) AS after_sale_count
-- 退款金额
, (SELECT IFNULL(SUM(refund_price), 0)
FROM trade_after_sale
WHERE spu_id = spu.id
AND refund_time IS NOT NULL
- AND create_time BETWEEN #{beginTime} AND #{endTime}) AS after_sale_refund_price
+ AND create_time BETWEEN #{beginTime} AND #{endTime}
+
+ AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()}
+
+ ) AS after_sale_refund_price
FROM product_spu spu
WHERE spu.deleted = FALSE
+
+ AND spu.tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()}
+
ORDER BY spu.id
diff --git a/yudao-module-mall/yudao-module-statistics/src/main/resources/mapper/trade/AfterSaleStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics/src/main/resources/mapper/trade/AfterSaleStatisticsMapper.xml
index 933c456..cd24b50 100644
--- a/yudao-module-mall/yudao-module-statistics/src/main/resources/mapper/trade/AfterSaleStatisticsMapper.xml
+++ b/yudao-module-mall/yudao-module-statistics/src/main/resources/mapper/trade/AfterSaleStatisticsMapper.xml
@@ -9,6 +9,9 @@
FROM trade_after_sale
WHERE refund_time BETWEEN #{beginTime} AND #{endTime}
AND deleted = FALSE
+
+ AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()}
+
diff --git a/yudao-module-mall/yudao-module-statistics/src/main/resources/mapper/trade/BrokerageStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics/src/main/resources/mapper/trade/BrokerageStatisticsMapper.xml
index dff7e44..cd91e92 100644
--- a/yudao-module-mall/yudao-module-statistics/src/main/resources/mapper/trade/BrokerageStatisticsMapper.xml
+++ b/yudao-module-mall/yudao-module-statistics/src/main/resources/mapper/trade/BrokerageStatisticsMapper.xml
@@ -9,6 +9,9 @@
AND status = #{status}
AND unfreeze_time BETWEEN #{beginTime} AND #{endTime}
AND deleted = FALSE
+
+ AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()}
+
diff --git a/yudao-module-mall/yudao-module-statistics/src/main/resources/mapper/trade/TradeOrderStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics/src/main/resources/mapper/trade/TradeOrderStatisticsMapper.xml
index e47c85e..270c90b 100644
--- a/yudao-module-mall/yudao-module-statistics/src/main/resources/mapper/trade/TradeOrderStatisticsMapper.xml
+++ b/yudao-module-mall/yudao-module-statistics/src/main/resources/mapper/trade/TradeOrderStatisticsMapper.xml
@@ -7,19 +7,34 @@
SELECT receiver_area_id AS areaId,
(SELECT COUNT(DISTINCT s.user_id)
FROM trade_order AS s
- WHERE s.receiver_area_id = m.receiver_area_id) AS orderCreateUserCount,
+ WHERE s.receiver_area_id = m.receiver_area_id
+
+ AND s.tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()}
+
+ ) AS orderCreateUserCount,
(SELECT COUNT(DISTINCT s.user_id)
FROM trade_order AS s
WHERE s.receiver_area_id = m.receiver_area_id
AND s.pay_status = TRUE
- AND s.deleted = FALSE) AS orderPayUserCount,
+ AND s.deleted = FALSE
+
+ AND s.tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()}
+
+ ) AS orderPayUserCount,
(SELECT SUM(s.pay_price)
FROM trade_order AS s
WHERE s.receiver_area_id = m.receiver_area_id
AND s.pay_status = TRUE
- AND s.deleted = FALSE) AS orderPayPrice
+ AND s.deleted = FALSE
+
+ AND s.tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()}
+
+ ) AS orderPayPrice
FROM trade_order m
WHERE deleted = FALSE
+
+ AND m.tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()}
+
GROUP BY receiver_area_id
@@ -28,6 +43,9 @@
FROM trade_order
WHERE deleted = FALSE
AND create_time BETWEEN #{beginTime} AND #{endTime}
+
+ AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()}
+
@@ -82,6 +115,9 @@
WHERE pay_status = TRUE
AND create_time BETWEEN #{beginTime} AND #{endTime}
AND deleted = FALSE
+
+ AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()}
+
GROUP BY date
@@ -91,6 +127,9 @@
WHERE status = #{status}
ANd delivery_type = #{deliveryType}
AND deleted = FALSE
+
+ AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()}
+