会员列表sql修改
This commit is contained in:
parent
2d80aa5b2f
commit
8bb654080a
|
|
@ -57,30 +57,37 @@
|
|||
<select id="selectPageByKeyAndIsVip" resultType="com.czg.account.dto.shopuser.ShopUserDTO">
|
||||
SELECT
|
||||
a.*,
|
||||
(SELECT COUNT(*)
|
||||
FROM tb_shop_activate_coupon_record c
|
||||
WHERE c.shop_user_id = a.id
|
||||
AND c.status = 0
|
||||
AND c.use_start_time < NOW()
|
||||
AND c.use_end_time > NOW()
|
||||
) AS couponNum,
|
||||
|
||||
(SELECT COUNT(*)
|
||||
FROM tb_order_info d
|
||||
WHERE d.user_id = a.user_id
|
||||
AND d.shop_id = a.shop_id
|
||||
) AS orderNumber,
|
||||
|
||||
(SELECT IFNULL(SUM(f.amount), 0)
|
||||
FROM tb_shop_user_flow f
|
||||
WHERE f.user_id = a.user_id
|
||||
AND f.shop_id = a.shop_id
|
||||
AND f.biz_code IN ('cashIn', 'wechatIn', 'alipayIn')
|
||||
) AS rechargeAmount
|
||||
|
||||
IFNULL(c.couponNum, 0) AS couponNum,
|
||||
IFNULL(d.orderNumber, 0) AS orderNumber,
|
||||
IFNULL(f.rechargeAmount, 0) AS rechargeAmount
|
||||
FROM tb_shop_user a
|
||||
LEFT JOIN tb_user_info b ON b.id = a.user_id
|
||||
|
||||
-- 预计算优惠券数量
|
||||
LEFT JOIN (
|
||||
SELECT shop_user_id, COUNT(*) AS couponNum
|
||||
FROM tb_shop_activate_coupon_record
|
||||
WHERE status = 0
|
||||
AND use_start_time < NOW()
|
||||
AND use_end_time > NOW()
|
||||
GROUP BY shop_user_id
|
||||
) c ON c.shop_user_id = a.id
|
||||
|
||||
-- 预计算订单数量
|
||||
LEFT JOIN (
|
||||
SELECT user_id, shop_id, COUNT(*) AS orderNumber
|
||||
FROM tb_order_info
|
||||
GROUP BY user_id, shop_id
|
||||
) d ON d.user_id = a.user_id AND d.shop_id = a.shop_id
|
||||
|
||||
-- 预计算充值总金额
|
||||
LEFT JOIN (
|
||||
SELECT user_id, shop_id, SUM(amount) AS rechargeAmount
|
||||
FROM tb_shop_user_flow
|
||||
WHERE biz_code IN ('cashIn', 'wechatIn', 'alipayIn')
|
||||
GROUP BY user_id, shop_id
|
||||
) f ON f.user_id = a.user_id AND f.shop_id = a.shop_id
|
||||
|
||||
WHERE a.shop_id = #{shopId}
|
||||
|
||||
<if test="isVip != null">
|
||||
|
|
|
|||
Loading…
Reference in New Issue