用户列表 1

This commit is contained in:
2025-12-23 14:23:58 +08:00
parent f318c18606
commit 8635c42506
5 changed files with 16 additions and 74 deletions

View File

@@ -5,7 +5,7 @@
<mapper namespace="com.czg.service.account.mapper.ShopUserMapper">
<update id="incrAccount">
update tb_shop_user
set amount = COALESCE(amount, 0) + #{money},
set amount = amount + #{money},
update_time = #{time}
where id = #{id}
@@ -44,7 +44,7 @@
</select>
<select id="selectVipCard" resultType="com.czg.account.dto.shopuser.ShopUserVipCardDTO">
select tb_shop_info.logo, tb_shop_info.shop_name shopName, tb_shop_user.amount, tb_shop_user.shop_id shopId
select tb_shop_info.logo, tb_shop_info.shop_name shopName, tb_shop_user.amount, tb_shop_user.main_shop_id shopId
from tb_shop_user
left join tb_shop_info on tb_shop_user.main_shop_id = tb_shop_info.id
${qwSql}
@@ -72,41 +72,20 @@
IFNULL(c.couponNum, 0) AS couponNum,
IFNULL(d.orderNumber, 0) AS orderNumber,
IFNULL(f.rechargeAmount, 0) AS rechargeAmount,
c.name as memberLevelName,
c.discount
point.point_balance as pointBalance,
c1.name as memberLevelName,
c1.discount
FROM tb_shop_user a
LEFT JOIN tb_user_info b ON b.id = a.user_id
LEFT JOIN tb_member_level_config c on c.id=a.member_level_id
LEFT JOIN tb_member_level_config c1 on c1.id=a.member_level_id
LEFT JOIN mk_points_user point on point.shop_user_id = a.id
-- 预计算优惠券数量
LEFT JOIN (
SELECT shop_user_id, COUNT(*) AS couponNum
FROM mk_shop_coupon_record
WHERE
is_del = 0
# AND status = 0
# AND use_start_time &lt; NOW()
# AND use_end_time > NOW()
GROUP BY shop_user_id
) c ON c.shop_user_id = a.id
LEFT JOIN (SELECT shop_user_id, COUNT(*) AS couponNum FROM mk_shop_coupon_record WHERE is_del = 0 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.main_shop_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.main_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.main_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.main_shop_id
WHERE a.main_shop_id = #{shopId}
<if test="isVip != null">
AND a.is_vip = #{isVip}
</if>