Commit b572669c16e67cf7b617c90e85a42e39a4dd4861
1 parent
20f06c51
fix(mall): 补齐商城统计查询的租户过滤条件
补齐订单、售后、佣金、会员、钱包、访问量和商品统计的 tenant_id 条件 覆盖关联子查询和 JOIN 两侧,并将租户条件统一放在 WHERE 条件末尾 保持全局租户拦截器行为不变
Showing
7 changed files
with
143 additions
and
12 deletions
yudao-module-mall/yudao-module-statistics/src/main/resources/mapper/infra/ApiAccessLogStatisticsMapper.xml
| @@ -8,6 +8,9 @@ | @@ -8,6 +8,9 @@ | ||
| 8 | WHERE user_type = #{userType} | 8 | WHERE user_type = #{userType} |
| 9 | AND create_time BETWEEN #{beginTime} AND #{endTime} | 9 | AND create_time BETWEEN #{beginTime} AND #{endTime} |
| 10 | AND deleted = FALSE | 10 | AND deleted = FALSE |
| 11 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 12 | + AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 13 | + </if> | ||
| 11 | </select> | 14 | </select> |
| 12 | 15 | ||
| 13 | <select id="selectUserCountByUserTypeAndCreateTimeBetween" resultType="java.lang.Integer"> | 16 | <select id="selectUserCountByUserTypeAndCreateTimeBetween" resultType="java.lang.Integer"> |
| @@ -17,6 +20,9 @@ | @@ -17,6 +20,9 @@ | ||
| 17 | AND user_type = #{userType} | 20 | AND user_type = #{userType} |
| 18 | AND create_time BETWEEN #{beginTime} AND #{endTime} | 21 | AND create_time BETWEEN #{beginTime} AND #{endTime} |
| 19 | AND deleted = FALSE | 22 | AND deleted = FALSE |
| 23 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 24 | + AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 25 | + </if> | ||
| 20 | </select> | 26 | </select> |
| 21 | 27 | ||
| 22 | </mapper> | 28 | </mapper> |
yudao-module-mall/yudao-module-statistics/src/main/resources/mapper/member/MemberStatisticsMapper.xml
| @@ -7,6 +7,9 @@ | @@ -7,6 +7,9 @@ | ||
| 7 | SELECT area_id, COUNT(1) AS userCount | 7 | SELECT area_id, COUNT(1) AS userCount |
| 8 | FROM member_user | 8 | FROM member_user |
| 9 | WHERE deleted = FALSE | 9 | WHERE deleted = FALSE |
| 10 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 11 | + AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 12 | + </if> | ||
| 10 | GROUP BY area_id | 13 | GROUP BY area_id |
| 11 | </select> | 14 | </select> |
| 12 | 15 | ||
| @@ -15,6 +18,9 @@ | @@ -15,6 +18,9 @@ | ||
| 15 | SELECT sex, COUNT(1) AS userCount | 18 | SELECT sex, COUNT(1) AS userCount |
| 16 | FROM member_user | 19 | FROM member_user |
| 17 | WHERE deleted = FALSE | 20 | WHERE deleted = FALSE |
| 21 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 22 | + AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 23 | + </if> | ||
| 18 | GROUP BY sex | 24 | GROUP BY sex |
| 19 | </select> | 25 | </select> |
| 20 | 26 | ||
| @@ -23,6 +29,9 @@ | @@ -23,6 +29,9 @@ | ||
| 23 | SELECT register_terminal as terminal, COUNT(1) AS userCount | 29 | SELECT register_terminal as terminal, COUNT(1) AS userCount |
| 24 | FROM member_user | 30 | FROM member_user |
| 25 | WHERE deleted = FALSE | 31 | WHERE deleted = FALSE |
| 32 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 33 | + AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 34 | + </if> | ||
| 26 | GROUP BY register_terminal | 35 | GROUP BY register_terminal |
| 27 | </select> | 36 | </select> |
| 28 | 37 | ||
| @@ -36,6 +45,9 @@ | @@ -36,6 +45,9 @@ | ||
| 36 | <if test="endTime != null"> | 45 | <if test="endTime != null"> |
| 37 | AND create_time <= #{endTime} | 46 | AND create_time <= #{endTime} |
| 38 | </if> | 47 | </if> |
| 48 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 49 | + AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 50 | + </if> | ||
| 39 | </select> | 51 | </select> |
| 40 | 52 | ||
| 41 | <select id="selectListByCreateTimeBetween" | 53 | <select id="selectListByCreateTimeBetween" |
| @@ -45,6 +57,9 @@ | @@ -45,6 +57,9 @@ | ||
| 45 | FROM member_user | 57 | FROM member_user |
| 46 | WHERE create_time BETWEEN #{beginTime} AND #{endTime} | 58 | WHERE create_time BETWEEN #{beginTime} AND #{endTime} |
| 47 | AND deleted = FALSE | 59 | AND deleted = FALSE |
| 60 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 61 | + AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 62 | + </if> | ||
| 48 | GROUP BY date | 63 | GROUP BY date |
| 49 | </select> | 64 | </select> |
| 50 | 65 |
yudao-module-mall/yudao-module-statistics/src/main/resources/mapper/pay/PayWalletStatisticsMapper.xml
| @@ -10,6 +10,9 @@ | @@ -10,6 +10,9 @@ | ||
| 10 | WHERE pay_status = #{payStatus} | 10 | WHERE pay_status = #{payStatus} |
| 11 | AND pay_time BETWEEN #{beginTime} AND #{endTime} | 11 | AND pay_time BETWEEN #{beginTime} AND #{endTime} |
| 12 | AND deleted = FALSE | 12 | AND deleted = FALSE |
| 13 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 14 | + AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 15 | + </if> | ||
| 13 | </select> | 16 | </select> |
| 14 | 17 | ||
| 15 | <select id="selectRechargeSummaryByRefundTimeBetween" | 18 | <select id="selectRechargeSummaryByRefundTimeBetween" |
| @@ -20,6 +23,9 @@ | @@ -20,6 +23,9 @@ | ||
| 20 | WHERE refund_status = #{refundStatus} | 23 | WHERE refund_status = #{refundStatus} |
| 21 | AND refund_time BETWEEN #{beginTime} AND #{endTime} | 24 | AND refund_time BETWEEN #{beginTime} AND #{endTime} |
| 22 | AND deleted = FALSE | 25 | AND deleted = FALSE |
| 26 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 27 | + AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 28 | + </if> | ||
| 23 | </select> | 29 | </select> |
| 24 | 30 | ||
| 25 | <select id="selectPriceSummaryByBizTypeAndCreateTimeBetween" resultType="java.lang.Integer"> | 31 | <select id="selectPriceSummaryByBizTypeAndCreateTimeBetween" resultType="java.lang.Integer"> |
| @@ -28,6 +34,9 @@ | @@ -28,6 +34,9 @@ | ||
| 28 | WHERE biz_type = #{bizType} | 34 | WHERE biz_type = #{bizType} |
| 29 | AND create_time BETWEEN #{beginTime} AND #{endTime} | 35 | AND create_time BETWEEN #{beginTime} AND #{endTime} |
| 30 | AND deleted = FALSE | 36 | AND deleted = FALSE |
| 37 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 38 | + AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 39 | + </if> | ||
| 31 | </select> | 40 | </select> |
| 32 | 41 | ||
| 33 | <select id="selectRechargeSummaryGroupByWalletId" | 42 | <select id="selectRechargeSummaryGroupByWalletId" |
| @@ -43,6 +52,9 @@ | @@ -43,6 +52,9 @@ | ||
| 43 | AND pay_time <= #{endTime} | 52 | AND pay_time <= #{endTime} |
| 44 | </if> | 53 | </if> |
| 45 | AND deleted = FALSE | 54 | AND deleted = FALSE |
| 55 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 56 | + AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 57 | + </if> | ||
| 46 | </select> | 58 | </select> |
| 47 | 59 | ||
| 48 | <select id="selectRechargePriceSummary" resultType="java.lang.Integer"> | 60 | <select id="selectRechargePriceSummary" resultType="java.lang.Integer"> |
| @@ -50,6 +62,9 @@ | @@ -50,6 +62,9 @@ | ||
| 50 | FROM pay_wallet_recharge | 62 | FROM pay_wallet_recharge |
| 51 | WHERE pay_status = #{payStatus} | 63 | WHERE pay_status = #{payStatus} |
| 52 | AND deleted = FALSE | 64 | AND deleted = FALSE |
| 65 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 66 | + AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 67 | + </if> | ||
| 53 | </select> | 68 | </select> |
| 54 | 69 | ||
| 55 | </mapper> | 70 | </mapper> |
yudao-module-mall/yudao-module-statistics/src/main/resources/mapper/product/ProductStatisticsMapper.xml
| @@ -9,55 +9,96 @@ | @@ -9,55 +9,96 @@ | ||
| 9 | , (SELECT COUNT(1) | 9 | , (SELECT COUNT(1) |
| 10 | FROM product_browse_history | 10 | FROM product_browse_history |
| 11 | WHERE spu_id = spu.id | 11 | WHERE spu_id = spu.id |
| 12 | - AND create_time BETWEEN #{beginTime} AND #{endTime}) AS browse_count | 12 | + AND create_time BETWEEN #{beginTime} AND #{endTime} |
| 13 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 14 | + AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 15 | + </if> | ||
| 16 | + ) AS browse_count | ||
| 13 | -- 访客量:按用户去重计数 | 17 | -- 访客量:按用户去重计数 |
| 14 | , (SELECT COUNT(DISTINCT user_id) | 18 | , (SELECT COUNT(DISTINCT user_id) |
| 15 | FROM product_browse_history | 19 | FROM product_browse_history |
| 16 | WHERE spu_id = spu.id | 20 | WHERE spu_id = spu.id |
| 17 | - AND create_time BETWEEN #{beginTime} AND #{endTime}) AS browse_user_count | 21 | + AND create_time BETWEEN #{beginTime} AND #{endTime} |
| 22 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 23 | + AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 24 | + </if> | ||
| 25 | + ) AS browse_user_count | ||
| 18 | -- 收藏数量:按用户去重计数 | 26 | -- 收藏数量:按用户去重计数 |
| 19 | , (SELECT COUNT(DISTINCT user_id) | 27 | , (SELECT COUNT(DISTINCT user_id) |
| 20 | FROM product_favorite | 28 | FROM product_favorite |
| 21 | WHERE spu_id = spu.id | 29 | WHERE spu_id = spu.id |
| 22 | - AND create_time BETWEEN #{beginTime} AND #{endTime}) AS favorite_count | 30 | + AND create_time BETWEEN #{beginTime} AND #{endTime} |
| 31 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 32 | + AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 33 | + </if> | ||
| 34 | + ) AS favorite_count | ||
| 23 | -- 加购数量:按用户去重计数 | 35 | -- 加购数量:按用户去重计数 |
| 24 | , (SELECT COUNT(DISTINCT user_id) | 36 | , (SELECT COUNT(DISTINCT user_id) |
| 25 | FROM trade_cart | 37 | FROM trade_cart |
| 26 | WHERE spu_id = spu.id | 38 | WHERE spu_id = spu.id |
| 27 | - AND create_time BETWEEN #{beginTime} AND #{endTime}) AS cart_count | 39 | + AND create_time BETWEEN #{beginTime} AND #{endTime} |
| 40 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 41 | + AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 42 | + </if> | ||
| 43 | + ) AS cart_count | ||
| 28 | -- 下单件数 | 44 | -- 下单件数 |
| 29 | , (SELECT IFNULL(SUM(count), 0) | 45 | , (SELECT IFNULL(SUM(count), 0) |
| 30 | FROM trade_order_item | 46 | FROM trade_order_item |
| 31 | WHERE spu_id = spu.id | 47 | WHERE spu_id = spu.id |
| 32 | - AND create_time BETWEEN #{beginTime} AND #{endTime}) AS order_count | 48 | + AND create_time BETWEEN #{beginTime} AND #{endTime} |
| 49 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 50 | + AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 51 | + </if> | ||
| 52 | + ) AS order_count | ||
| 33 | -- 支付件数 | 53 | -- 支付件数 |
| 34 | , (SELECT IFNULL(SUM(item.count), 0) | 54 | , (SELECT IFNULL(SUM(item.count), 0) |
| 35 | FROM trade_order_item item | 55 | FROM trade_order_item item |
| 36 | JOIN trade_order o ON item.order_id = o.id | 56 | JOIN trade_order o ON item.order_id = o.id |
| 37 | WHERE spu_id = spu.id | 57 | WHERE spu_id = spu.id |
| 38 | AND o.pay_status = TRUE | 58 | AND o.pay_status = TRUE |
| 39 | - AND item.create_time BETWEEN #{beginTime} AND #{endTime}) AS order_pay_count | 59 | + AND item.create_time BETWEEN #{beginTime} AND #{endTime} |
| 60 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 61 | + AND item.tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 62 | + AND o.tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 63 | + </if> | ||
| 64 | + ) AS order_pay_count | ||
| 40 | -- 支付金额 | 65 | -- 支付金额 |
| 41 | , (SELECT IFNULL(SUM(item.pay_price), 0) | 66 | , (SELECT IFNULL(SUM(item.pay_price), 0) |
| 42 | FROM trade_order_item item | 67 | FROM trade_order_item item |
| 43 | JOIN trade_order o ON item.order_id = o.id | 68 | JOIN trade_order o ON item.order_id = o.id |
| 44 | WHERE spu_id = spu.id | 69 | WHERE spu_id = spu.id |
| 45 | AND o.pay_status = TRUE | 70 | AND o.pay_status = TRUE |
| 46 | - AND item.create_time BETWEEN #{beginTime} AND #{endTime}) AS order_pay_price | 71 | + AND item.create_time BETWEEN #{beginTime} AND #{endTime} |
| 72 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 73 | + AND item.tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 74 | + AND o.tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 75 | + </if> | ||
| 76 | + ) AS order_pay_price | ||
| 47 | -- 退款件数 | 77 | -- 退款件数 |
| 48 | , (SELECT IFNULL(SUM(count), 0) | 78 | , (SELECT IFNULL(SUM(count), 0) |
| 49 | FROM trade_after_sale | 79 | FROM trade_after_sale |
| 50 | WHERE spu_id = spu.id | 80 | WHERE spu_id = spu.id |
| 51 | AND refund_time IS NOT NULL | 81 | AND refund_time IS NOT NULL |
| 52 | - AND create_time BETWEEN #{beginTime} AND #{endTime}) AS after_sale_count | 82 | + AND create_time BETWEEN #{beginTime} AND #{endTime} |
| 83 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 84 | + AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 85 | + </if> | ||
| 86 | + ) AS after_sale_count | ||
| 53 | -- 退款金额 | 87 | -- 退款金额 |
| 54 | , (SELECT IFNULL(SUM(refund_price), 0) | 88 | , (SELECT IFNULL(SUM(refund_price), 0) |
| 55 | FROM trade_after_sale | 89 | FROM trade_after_sale |
| 56 | WHERE spu_id = spu.id | 90 | WHERE spu_id = spu.id |
| 57 | AND refund_time IS NOT NULL | 91 | AND refund_time IS NOT NULL |
| 58 | - AND create_time BETWEEN #{beginTime} AND #{endTime}) AS after_sale_refund_price | 92 | + AND create_time BETWEEN #{beginTime} AND #{endTime} |
| 93 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 94 | + AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 95 | + </if> | ||
| 96 | + ) AS after_sale_refund_price | ||
| 59 | FROM product_spu spu | 97 | FROM product_spu spu |
| 60 | WHERE spu.deleted = FALSE | 98 | WHERE spu.deleted = FALSE |
| 99 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 100 | + AND spu.tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 101 | + </if> | ||
| 61 | ORDER BY spu.id | 102 | ORDER BY spu.id |
| 62 | </select> | 103 | </select> |
| 63 | 104 |
yudao-module-mall/yudao-module-statistics/src/main/resources/mapper/trade/AfterSaleStatisticsMapper.xml
| @@ -9,6 +9,9 @@ | @@ -9,6 +9,9 @@ | ||
| 9 | FROM trade_after_sale | 9 | FROM trade_after_sale |
| 10 | WHERE refund_time BETWEEN #{beginTime} AND #{endTime} | 10 | WHERE refund_time BETWEEN #{beginTime} AND #{endTime} |
| 11 | AND deleted = FALSE | 11 | AND deleted = FALSE |
| 12 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 13 | + AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 14 | + </if> | ||
| 12 | </select> | 15 | </select> |
| 13 | 16 | ||
| 14 | <select id="selectCountByStatus" resultType="java.lang.Long"> | 17 | <select id="selectCountByStatus" resultType="java.lang.Long"> |
| @@ -16,6 +19,9 @@ | @@ -16,6 +19,9 @@ | ||
| 16 | FROM trade_after_sale | 19 | FROM trade_after_sale |
| 17 | WHERE status = #{status} | 20 | WHERE status = #{status} |
| 18 | AND deleted = FALSE | 21 | AND deleted = FALSE |
| 22 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 23 | + AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 24 | + </if> | ||
| 19 | </select> | 25 | </select> |
| 20 | 26 | ||
| 21 | </mapper> | 27 | </mapper> |
yudao-module-mall/yudao-module-statistics/src/main/resources/mapper/trade/BrokerageStatisticsMapper.xml
| @@ -9,6 +9,9 @@ | @@ -9,6 +9,9 @@ | ||
| 9 | AND status = #{status} | 9 | AND status = #{status} |
| 10 | AND unfreeze_time BETWEEN #{beginTime} AND #{endTime} | 10 | AND unfreeze_time BETWEEN #{beginTime} AND #{endTime} |
| 11 | AND deleted = FALSE | 11 | AND deleted = FALSE |
| 12 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 13 | + AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 14 | + </if> | ||
| 12 | </select> | 15 | </select> |
| 13 | 16 | ||
| 14 | <select id="selectWithdrawCountByStatus" resultType="java.lang.Long"> | 17 | <select id="selectWithdrawCountByStatus" resultType="java.lang.Long"> |
| @@ -16,6 +19,9 @@ | @@ -16,6 +19,9 @@ | ||
| 16 | FROM trade_brokerage_withdraw | 19 | FROM trade_brokerage_withdraw |
| 17 | WHERE status = #{status} | 20 | WHERE status = #{status} |
| 18 | AND deleted = FALSE | 21 | AND deleted = FALSE |
| 22 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 23 | + AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 24 | + </if> | ||
| 19 | </select> | 25 | </select> |
| 20 | 26 | ||
| 21 | </mapper> | 27 | </mapper> |
yudao-module-mall/yudao-module-statistics/src/main/resources/mapper/trade/TradeOrderStatisticsMapper.xml
| @@ -7,19 +7,34 @@ | @@ -7,19 +7,34 @@ | ||
| 7 | SELECT receiver_area_id AS areaId, | 7 | SELECT receiver_area_id AS areaId, |
| 8 | (SELECT COUNT(DISTINCT s.user_id) | 8 | (SELECT COUNT(DISTINCT s.user_id) |
| 9 | FROM trade_order AS s | 9 | FROM trade_order AS s |
| 10 | - WHERE s.receiver_area_id = m.receiver_area_id) AS orderCreateUserCount, | 10 | + WHERE s.receiver_area_id = m.receiver_area_id |
| 11 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 12 | + AND s.tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 13 | + </if> | ||
| 14 | + ) AS orderCreateUserCount, | ||
| 11 | (SELECT COUNT(DISTINCT s.user_id) | 15 | (SELECT COUNT(DISTINCT s.user_id) |
| 12 | FROM trade_order AS s | 16 | FROM trade_order AS s |
| 13 | WHERE s.receiver_area_id = m.receiver_area_id | 17 | WHERE s.receiver_area_id = m.receiver_area_id |
| 14 | AND s.pay_status = TRUE | 18 | AND s.pay_status = TRUE |
| 15 | - AND s.deleted = FALSE) AS orderPayUserCount, | 19 | + AND s.deleted = FALSE |
| 20 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 21 | + AND s.tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 22 | + </if> | ||
| 23 | + ) AS orderPayUserCount, | ||
| 16 | (SELECT SUM(s.pay_price) | 24 | (SELECT SUM(s.pay_price) |
| 17 | FROM trade_order AS s | 25 | FROM trade_order AS s |
| 18 | WHERE s.receiver_area_id = m.receiver_area_id | 26 | WHERE s.receiver_area_id = m.receiver_area_id |
| 19 | AND s.pay_status = TRUE | 27 | AND s.pay_status = TRUE |
| 20 | - AND s.deleted = FALSE) AS orderPayPrice | 28 | + AND s.deleted = FALSE |
| 29 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 30 | + AND s.tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 31 | + </if> | ||
| 32 | + ) AS orderPayPrice | ||
| 21 | FROM trade_order m | 33 | FROM trade_order m |
| 22 | WHERE deleted = FALSE | 34 | WHERE deleted = FALSE |
| 35 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 36 | + AND m.tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 37 | + </if> | ||
| 23 | GROUP BY receiver_area_id | 38 | GROUP BY receiver_area_id |
| 24 | </select> | 39 | </select> |
| 25 | 40 | ||
| @@ -28,6 +43,9 @@ | @@ -28,6 +43,9 @@ | ||
| 28 | FROM trade_order | 43 | FROM trade_order |
| 29 | WHERE deleted = FALSE | 44 | WHERE deleted = FALSE |
| 30 | AND create_time BETWEEN #{beginTime} AND #{endTime} | 45 | AND create_time BETWEEN #{beginTime} AND #{endTime} |
| 46 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 47 | + AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 48 | + </if> | ||
| 31 | </select> | 49 | </select> |
| 32 | 50 | ||
| 33 | <select id="selectUserCountByPayTimeBetween" resultType="java.lang.Integer"> | 51 | <select id="selectUserCountByPayTimeBetween" resultType="java.lang.Integer"> |
| @@ -36,6 +54,9 @@ | @@ -36,6 +54,9 @@ | ||
| 36 | WHERE pay_time BETWEEN #{beginTime} AND #{endTime} | 54 | WHERE pay_time BETWEEN #{beginTime} AND #{endTime} |
| 37 | AND pay_status = TRUE | 55 | AND pay_status = TRUE |
| 38 | AND deleted = FALSE | 56 | AND deleted = FALSE |
| 57 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 58 | + AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 59 | + </if> | ||
| 39 | </select> | 60 | </select> |
| 40 | 61 | ||
| 41 | <select id="selectCountByCreateTimeBetween" resultType="java.lang.Integer"> | 62 | <select id="selectCountByCreateTimeBetween" resultType="java.lang.Integer"> |
| @@ -43,6 +64,9 @@ | @@ -43,6 +64,9 @@ | ||
| 43 | FROM trade_order | 64 | FROM trade_order |
| 44 | WHERE create_time BETWEEN #{beginTime} AND #{endTime} | 65 | WHERE create_time BETWEEN #{beginTime} AND #{endTime} |
| 45 | AND deleted = FALSE | 66 | AND deleted = FALSE |
| 67 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 68 | + AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 69 | + </if> | ||
| 46 | </select> | 70 | </select> |
| 47 | 71 | ||
| 48 | <select id="selectCountByPayTimeBetween" resultType="java.lang.Integer"> | 72 | <select id="selectCountByPayTimeBetween" resultType="java.lang.Integer"> |
| @@ -51,6 +75,9 @@ | @@ -51,6 +75,9 @@ | ||
| 51 | WHERE pay_status = TRUE | 75 | WHERE pay_status = TRUE |
| 52 | AND create_time BETWEEN #{beginTime} AND #{endTime} | 76 | AND create_time BETWEEN #{beginTime} AND #{endTime} |
| 53 | AND deleted = FALSE | 77 | AND deleted = FALSE |
| 78 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 79 | + AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 80 | + </if> | ||
| 54 | </select> | 81 | </select> |
| 55 | 82 | ||
| 56 | <select id="selectSummaryPriceByPayTimeBetween" resultType="java.lang.Integer"> | 83 | <select id="selectSummaryPriceByPayTimeBetween" resultType="java.lang.Integer"> |
| @@ -59,6 +86,9 @@ | @@ -59,6 +86,9 @@ | ||
| 59 | WHERE s.pay_status = TRUE | 86 | WHERE s.pay_status = TRUE |
| 60 | AND deleted = FALSE | 87 | AND deleted = FALSE |
| 61 | AND create_time BETWEEN #{beginTime} AND #{endTime} | 88 | AND create_time BETWEEN #{beginTime} AND #{endTime} |
| 89 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 90 | + AND s.tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 91 | + </if> | ||
| 62 | </select> | 92 | </select> |
| 63 | 93 | ||
| 64 | <select id="selectListByPayTimeBetweenAndGroupByDay" | 94 | <select id="selectListByPayTimeBetweenAndGroupByDay" |
| @@ -70,6 +100,9 @@ | @@ -70,6 +100,9 @@ | ||
| 70 | WHERE pay_status = TRUE | 100 | WHERE pay_status = TRUE |
| 71 | AND create_time BETWEEN #{beginTime} AND #{endTime} | 101 | AND create_time BETWEEN #{beginTime} AND #{endTime} |
| 72 | AND deleted = FALSE | 102 | AND deleted = FALSE |
| 103 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 104 | + AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 105 | + </if> | ||
| 73 | GROUP BY date | 106 | GROUP BY date |
| 74 | </select> | 107 | </select> |
| 75 | 108 | ||
| @@ -82,6 +115,9 @@ | @@ -82,6 +115,9 @@ | ||
| 82 | WHERE pay_status = TRUE | 115 | WHERE pay_status = TRUE |
| 83 | AND create_time BETWEEN #{beginTime} AND #{endTime} | 116 | AND create_time BETWEEN #{beginTime} AND #{endTime} |
| 84 | AND deleted = FALSE | 117 | AND deleted = FALSE |
| 118 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 119 | + AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 120 | + </if> | ||
| 85 | GROUP BY date | 121 | GROUP BY date |
| 86 | </select> | 122 | </select> |
| 87 | 123 | ||
| @@ -91,6 +127,9 @@ | @@ -91,6 +127,9 @@ | ||
| 91 | WHERE status = #{status} | 127 | WHERE status = #{status} |
| 92 | ANd delivery_type = #{deliveryType} | 128 | ANd delivery_type = #{deliveryType} |
| 93 | AND deleted = FALSE | 129 | AND deleted = FALSE |
| 130 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 131 | + AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 132 | + </if> | ||
| 94 | </select> | 133 | </select> |
| 95 | 134 | ||
| 96 | <select id="selectPaySummaryByPayStatusAndPayTimeBetween" | 135 | <select id="selectPaySummaryByPayStatusAndPayTimeBetween" |
| @@ -101,6 +140,9 @@ | @@ -101,6 +140,9 @@ | ||
| 101 | WHERE pay_status = #{payStatus} | 140 | WHERE pay_status = #{payStatus} |
| 102 | AND pay_time BETWEEN #{beginTime} AND #{endTime} | 141 | AND pay_time BETWEEN #{beginTime} AND #{endTime} |
| 103 | AND deleted = FALSE | 142 | AND deleted = FALSE |
| 143 | + <if test="@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId() != null"> | ||
| 144 | + AND tenant_id = ${@cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder@getTenantId()} | ||
| 145 | + </if> | ||
| 104 | </select> | 146 | </select> |
| 105 | 147 | ||
| 106 | </mapper> | 148 | </mapper> |