会员余额明细获取

This commit is contained in:
张松
2025-03-25 00:49:39 +08:00
parent 25a80d5bb5
commit c309e73575

View File

@@ -39,31 +39,44 @@
</select>
<select id="selectAssetsSummary" resultType="com.czg.account.dto.user.userinfo.UserInfoAssetsSummaryDTO">
select sum(IFNULL(b.amount, 0)) as amount,
sum(IFNULL(b.account_points, 0)) as points,
count(c.id) as couponNum
from tb_user_info as a
join tb_shop_user as b on a.id = b.user_id
join tb_shop_activate_coupon_record as c
on c.shop_id = b.shop_id and c.shop_user_id = b.id and c.`status` = 1 and c.use_start_time &lt; now() and c.use_end_time > now()
where a.id = #{userId}
SELECT
SUM(amount) AS amount,
SUM(points) AS points,
COUNT(DISTINCT c.id) AS couponNum
FROM (
SELECT
b.id,
IFNULL(b.amount, 0) AS amount,
IFNULL(b.account_points, 0) AS points
FROM tb_shop_user AS b
WHERE b.user_id = #{userId}
) AS sub_b
LEFT JOIN tb_shop_activate_coupon_record AS c
ON c.shop_id = sub_b.id
AND c.shop_user_id = sub_b.id
AND c.`status` = 1
AND c.use_start_time &lt; NOW()
AND c.use_end_time > NOW();
</select>
<select id="selectPageByKeyAndIsVip" resultType="com.czg.account.dto.shopuser.ShopUserDTO">
SELECT
a.*, COUNT(DISTINCT c.id) AS couponNum,
a.*, COUNT(DISTINCT c.id) AS couponNum,
COUNT(DISTINCT d.id) AS orderNumber,
IFNULL(SUM(DISTINCT f.amount), 0) AS rechargeAmount
FROM
tb_shop_user a
left JOIN tb_user_info b ON b.id = a.user_id
left join tb_shop_activate_coupon_record c on c.shop_user_id=a.id and c.`status`=0 and c.use_start_time &lt; now() and c.use_end_time > now()
tb_shop_user a
left JOIN tb_user_info b ON b.id = a.user_id
left join tb_shop_activate_coupon_record c on c.shop_user_id=a.id and c.`status`=0 and c.use_start_time &lt;
now() and c.use_end_time > now()
left join tb_order_info as d on d.user_id=a.user_id and d.shop_id=a.shop_id
left join tb_shop_user_flow as f on f.user_id=a.user_id and f.shop_id=a.shop_id and f.biz_code in ('cashIn', 'wechatIn', 'alipayIn')
left join tb_shop_user_flow as f on f.user_id=a.user_id and f.shop_id=a.shop_id and f.biz_code in ('cashIn',
'wechatIn', 'alipayIn')
where a.shop_id=#{shopId}
<if test="isVip != null">
and a.is_vip=#{isVip}
</if>
<if test="isVip != null">
and a.is_vip=#{isVip}
</if>
<if test="key != null and key != ''">
and (a.nick_name like concat('%', #{key}, '%') or a.phone like concat('%', #{key}, '%'))
</if>